import { JSONSchema7 } from 'json-schema'; import * as z from 'zod'; import { z as z$1 } from 'zod'; import { ActionContext } from './context.js'; import { StatusName } from './statusTypes.js'; import { Dotprompt } from 'dotprompt'; import { JSONSchemaType } from 'ajv'; /** * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Zod schema of an opration representing a background task. */ declare const OperationSchema: z.ZodObject<{ action: z.ZodOptional; id: z.ZodString; done: z.ZodOptional; output: z.ZodOptional; error: z.ZodOptional, z.objectInputType<{ message: z.ZodString; }, z.ZodTypeAny, "passthrough">>>; metadata: z.ZodOptional>; }, "strip", z.ZodTypeAny, { id: string; done?: boolean | undefined; error?: z.objectOutputType<{ message: z.ZodString; }, z.ZodTypeAny, "passthrough"> | undefined; output?: any; metadata?: Record | undefined; action?: string | undefined; }, { id: string; done?: boolean | undefined; error?: z.objectInputType<{ message: z.ZodString; }, z.ZodTypeAny, "passthrough"> | undefined; output?: any; metadata?: Record | undefined; action?: string | undefined; }>; /** * Background operation. */ interface Operation { action?: string; id: string; done?: boolean; output?: O; error?: { message: string; [key: string]: unknown; }; metadata?: Record; } /** * Background action. Unlike regular action, background action can run for a long time in the background. * The returned operation can used to check the status of the background operation and retrieve the response. */ interface BackgroundAction { __action: ActionMetadata; readonly startAction: Action; readonly checkAction: Action; readonly cancelAction?: Action; readonly supportsCancel: boolean; start(input?: z.infer, options?: RunOptions): Promise>>; check(operation: Operation>, options?: RunOptions): Promise>>; cancel(operation: Operation>, options?: RunOptions): Promise>>; } declare function lookupBackgroundAction(registry: Registry, key: string): Promise | undefined>; /** * Options (side channel) data to pass to the model. */ interface BackgroundActionRunOptions { /** * Additional runtime context data (ex. auth context data). */ context?: ActionContext; /** * Additional span attributes to apply to OT spans. */ telemetryLabels?: Record; } /** * Options (side channel) data to pass to the model. */ interface BackgroundActionFnArg { /** * Additional runtime context data (ex. auth context data). */ context?: ActionContext; /** * Trace context containing trace and span IDs. */ trace: { traceId: string; spanId: string; }; } /** * Action factory params. */ type BackgroundActionParams = { name: string; start: (input: z.infer, options: BackgroundActionFnArg>) => Promise>>; check: (input: Operation>, options: BackgroundActionFnArg>) => Promise>>; cancel?: (input: Operation>, options: BackgroundActionFnArg>) => Promise>>; actionType: ActionType; description?: string; inputSchema?: I; inputJsonSchema?: JSONSchema7; outputSchema?: O; outputJsonSchema?: JSONSchema7; metadata?: Record; use?: Middleware, z.infer>[]; streamSchema?: S; }; /** * Defines an action with the given config and registers it in the registry. */ declare function defineBackgroundAction(registry: Registry, config: BackgroundActionParams): BackgroundAction; declare function registerBackgroundAction(registry: Registry, act: BackgroundAction, opts?: { namespace?: string; }): void; /** * Creates a background action with the given config. */ declare function backgroundAction(config: BackgroundActionParams): BackgroundAction; declare function isBackgroundAction(a: unknown): a is BackgroundAction; /** * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ interface Provider { id: string; value: T; } interface PluginProvider { name: string; initializer: () => InitializedPlugin | void | Promise; resolver?: (action: ActionType, target: string) => Promise; listActions?: () => Promise; } interface InitializedPlugin { models?: Action[]; retrievers?: Action[]; embedders?: Action[]; indexers?: Action[]; evaluators?: Action[]; /** @deprecated */ flowStateStore?: Provider | Provider[]; /** @deprecated */ traceStore?: Provider | Provider[]; /** @deprecated */ telemetry?: any; } type Plugin = (...args: T) => PluginProvider; type ResolvableAction = Action | BackgroundAction; /** * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ interface HttpErrorWireFormat { details?: unknown; message: string; status: StatusName; } /** * Metadata from the HTTP response that triggered this error. * This is not serialized into the wire format — it's only available * in-process for middleware (e.g. retry) to make informed decisions. */ interface ErrorResponseMetadata { /** Provider-suggested retry delay in milliseconds (parsed from Retry-After header). */ retryAfterMs?: number; /** Raw HTTP response headers, if available. */ headers?: Record; } /** * The markers tracing stamps on an error as it passes through spans: * `ignoreFailedSpan` once a span has claimed to be the failure's source, and * `traceId` once an action has recorded the trace it failed in. */ interface SpanFailureMarks { ignoreFailedSpan?: boolean; traceId?: string; } /** * Copies the span markers `source` carries onto `target` where `target` has * none of its own. An error thrown in place of one that already passed * through spans (a wrapper, or the error a wrapper stood for) keeps the * span that first failed as the failure's source, so an enclosing span does * not claim it again. */ declare function inheritSpanMarks(target: object, source: unknown): void; /** * Base error class for Genkit errors. */ declare class GenkitError extends Error { source?: string; status: StatusName; detail?: any; code: number; /** * Metadata from the HTTP response that triggered this error. * Not serialized into the wire format — only available in-process * for middleware (e.g. retry) to make informed decisions. */ responseMetadata?: ErrorResponseMetadata; originalMessage: string; /** * The message safe to send to a client when `originalMessage` is not. * A `GenkitError` is treated as user-facing by the HTTP handlers (see * {@link getCallableJSON}), so an error that wraps arbitrary text (a tool's * own exception, a provider SDK error) sets this to keep that text * in-process only. Unset means `originalMessage` is safe. */ publicMessage?: string; constructor({ status, message, detail, source, responseMetadata, cause, publicMessage, }: { status: StatusName; message: string; detail?: any; source?: string; responseMetadata?: ErrorResponseMetadata; /** The underlying error, exposed as the standard `Error.cause`. */ cause?: unknown; publicMessage?: string; }); /** * Returns a JSON-serializable representation of this object. */ toJSON(): HttpErrorWireFormat; } declare class UnstableApiError extends GenkitError { constructor(level: 'beta', message?: string); } /** * assertUnstable allows features to raise exceptions when using Genkit from *more* stable initialized instances. * * @param level The maximum stability channel allowed. * @param message An optional message describing which feature is not allowed. */ declare function assertUnstable(registry: Registry, level: 'beta', message?: string): void; /** * Creates a new class of Error for issues to be returned to users. * Using this error allows a web framework handler (e.g. express, next) to know it * is safe to return the message in a request. Other kinds of errors will * result in a generic 500 message to avoid the possibility of internal * exceptions being leaked to attackers. * In JSON requests, code will be an HTTP code and error will be a response body. * In streaming requests, { code, message } will be passed as the error message. */ declare class UserFacingError extends GenkitError { constructor(status: StatusName, message: string, details?: any); } declare function getHttpStatus(e: any): number; declare function getCallableJSON(e: any): HttpErrorWireFormat; /** * Extracts error message from the given error object, or if input is not an error then just turn the error into a string. */ declare function getErrorMessage(e: any): string; /** * Extracts stack trace from the given error object, or if input is not an error then returns undefined. */ declare function getErrorStack(e: any): string | undefined; /** * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * JSON schema. */ type JSONSchema = JSONSchemaType | any; /** * Annotates a Zod schema with UI-specific metadata. * * NOTE: It's typically recommended to use x-genkit-* (or similar) as the prefix. */ declare function annotateSchema(schema: T, annotations: Record): T; /** * Wrapper object for various ways schema can be provided. */ interface ProvidedSchema { jsonSchema?: JSONSchema; schema?: z$1.ZodTypeAny; } /** * Schema validation error. */ declare class ValidationError extends GenkitError { constructor({ data, errors, schema, }: { data: any; errors: ValidationErrorDetail[]; schema: JSONSchema; }); } /** * Converts a Zod schema into a JSON schema, utilizing an in-memory cache for known objects. * @param options Provide a json schema and/or zod schema. JSON schema has priority. * @returns A JSON schema. */ declare function toJsonSchema({ jsonSchema, schema, }: ProvidedSchema): JSONSchema | undefined; /** * Schema validation error details. */ interface ValidationErrorDetail { path: string; message: string; } /** * Validation response. */ type ValidationResponse = { valid: true; errors?: undefined; schema: JSONSchema; } | { valid: false; errors: ValidationErrorDetail[]; schema: JSONSchema; }; /** * Validates the provided data against the provided schema. */ declare function validateSchema(data: unknown, options: ProvidedSchema): ValidationResponse; /** * Parses raw data object against the provided schema. */ declare function parseSchema(data: unknown, options: ProvidedSchema): T; /** * Registers provided schema as a named schema object in the Genkit registry. * * @hidden */ declare function defineSchema(registry: Registry, name: string, schema: T): T; /** * Registers provided JSON schema as a named schema object in the Genkit registry. * * @hidden */ declare function defineJsonSchema(registry: Registry, name: string, jsonSchema: JSONSchema): any; type AsyncProvider = () => Promise; /** * Type of a runnable action. */ declare const ACTION_TYPES: readonly ["custom", "dynamic-action-provider", "embedder", "evaluator", "executable-prompt", "flow", "indexer", "model", "background-model", "check-operation", "cancel-operation", "prompt", "reranker", "retriever", "tool", "tool.v2", "util", "resource", "agent", "agent-snapshot", "agent-wait", "agent-abort"]; type ActionType = (typeof ACTION_TYPES)[number]; declare function isActionType(value: string): value is ActionType; /** * A schema is either a Zod schema or a JSON schema. */ interface Schema { schema?: z.ZodTypeAny; jsonSchema?: JSONSchema; } interface ParsedRegistryKey { dynamicActionHost?: string; actionType: ActionType; pluginName?: string; actionName: string; } /** * Parses the registry key into key parts as per the key format convention. Ex: * - mcp-host:tool/my-tool * - /model/googleai/gemini-2.5-flash * - /prompt/my-plugin/folder/my-prompt * - /util/generate */ declare function parseRegistryKey(registryKey: string): ParsedRegistryKey | undefined; type ActionsRecord = Record>; type ActionMetadataRecord = Record; /** * The registry is used to store and lookup actions, trace stores, flow state stores, plugins, and schemas. */ declare class Registry { private actionsById; private pluginsByName; private schemasByName; private valueByTypeAndName; private allPluginsInitialized; apiStability: 'stable' | 'beta'; readonly dotprompt: Dotprompt; readonly parent?: Registry; /** Additional runtime context data for flows and tools. */ context?: ActionContext; constructor(parent?: Registry); /** * Creates a new registry overlaid onto the provided registry. * @param parent The parent registry. * @returns The new overlaid registry. */ static withParent(parent: Registry): Registry; resolveActionNames(key: string): Promise; /** * Looks up an action in the registry. * @param key The key of the action to lookup. * @returns The action. */ lookupAction>(key: string): Promise; /** * Looks up a background action from the registry. * @param key The key of the action to lookup. * @returns The action. */ lookupBackgroundAction(key: string): Promise; /** * Registers an action in the registry. * @param type The type of the action to register. * @param action The action to register. */ registerAction(type: ActionType, action: Action, opts?: { namespace?: string; }): void; /** * Registers an action promise in the registry. */ registerActionAsync(type: ActionType, name: string, action: PromiseLike>, opts?: { namespace?: string; }): void; /** * Returns all actions that have been registered in the registry. * @returns All actions in the registry as a map of . */ listActions(): Promise; /** * Returns all actions that are resolvable by plugins as well as those that are already * in the registry. * * NOTE: this method should not be used in latency sensitive code paths. * It may rely on "admin" API calls such as "list models", which may cause increased cold start latency. * * @returns All resolvable action metadata as a map of . */ listResolvableActions(): Promise; /** * Initializes all plugins in the registry. */ initializeAllPlugins(): Promise; /** * Registers a plugin provider. This plugin must be initialized before it can be used by calling {@link initializePlugin} or {@link initializeAllPlugins}. * @param name The name of the plugin to register. * @param provider The plugin provider. */ registerPluginProvider(name: string, provider: PluginProvider): void; /** * Looks up a plugin. * @param name The name of the plugin to lookup. * @returns The plugin provider. */ lookupPlugin(name: string): PluginProvider | undefined; /** * Resolves a new Action dynamically by registering it. * @param pluginName The name of the plugin * @param actionType The type of the action * @param actionName The name of the action * @returns */ resolvePluginAction(pluginName: string, actionType: ActionType, actionName: string): Promise; getDynamicAction(key: ParsedRegistryKey): Promise | undefined>; /** * Initializes a plugin already registered with {@link registerPluginProvider}. * @param name The name of the plugin to initialize. * @returns The plugin. */ initializePlugin(name: string): Promise; /** * Registers a schema. * @param name The name of the schema to register. * @param data The schema to register (either a Zod schema or a JSON schema). */ registerSchema(name: string, data: Schema): void; registerValue(type: string, name: string, value: any): void; lookupValue(type: string, key: string): Promise; listValues(type: string): Promise>; /** * Looks up a schema. * @param name The name of the schema to lookup. * @returns The schema. */ lookupSchema(name: string): Schema | undefined; } /** * An object that has a reference to Genkit Registry. */ interface HasRegistry { get registry(): Registry; } /** * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Error thrown when a stream cannot be found. */ declare class StreamNotFoundError extends GenkitError { constructor(message: string); } /** * Interface for writing content to a stream. * @template S The type of the stream chunks. * @template O The type of the final output. */ interface ActionStreamInput { /** * Writes a chunk to the stream. * @param chunk The chunk data to write. */ write(chunk: S): Promise; /** * Closes the stream with a final output. * @param output The final output data. */ done(output: O): Promise; /** * Closes the stream with an error. * @param err The error that occurred. */ error(err: any): Promise; } /** * Subscriber callbacks for receiving stream events. * @template S The type of the stream chunks. * @template O The type of the final output. */ type ActionStreamSubscriber = { /** Called when a chunk is received. */ onChunk: (chunk: S) => void; /** Called when the stream completes successfully. */ onDone: (output: O) => void; /** Called when the stream encounters an error. */ onError: (error: any) => void; }; /** * Interface for managing streaming actions, allowing creation and subscription to streams. * Implementations can provide different storage backends (e.g., in-memory, database, cache). */ interface StreamManager { /** * Opens a stream for writing. * @param streamId The unique identifier for the stream. * @returns An object to write to the stream. */ open(streamId: string): Promise>; /** * Subscribes to a stream to receive its events. * @param streamId The unique identifier for the stream. * @param options The subscriber callbacks. * @returns A promise resolving to an object containing an unsubscribe function. */ subscribe(streamId: string, options: ActionStreamSubscriber): Promise<{ unsubscribe: () => void; }>; } /** * An in-memory implementation of StreamManager. * Useful for testing or single-instance deployments where persistence is not required. */ declare class InMemoryStreamManager implements StreamManager { private options; private streams; /** * @param options Configuration options. * @param options.ttlSeconds Time-to-live for streams in seconds. Defaults to 5 minutes. */ constructor(options?: { ttlSeconds?: number; }); private _cleanup; open(streamId: string): Promise>; subscribe(streamId: string, subscriber: ActionStreamSubscriber): Promise<{ unsubscribe: () => void; }>; } /** * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Action metadata. */ interface ActionMetadata { /** The type of action (e.g. 'prompt', 'flow'). */ actionType?: ActionType; /** Registry key (unique identifier). */ key?: string; /** The name of the action. */ name: string; /** Description of the action. */ description?: string; /** Input Zod schema. */ inputSchema?: I; /** Input JSON schema. */ inputJsonSchema?: JSONSchema7; /** Output Zod schema. */ outputSchema?: O; /** Output JSON schema. */ outputJsonSchema?: JSONSchema7; /** Stream Zod schema. */ streamSchema?: S; /** Schema of the initialization data. */ initSchema?: z.ZodTypeAny; /** JSON schema of the initialization data. */ initJsonSchema?: JSONSchema7; /** Metadata for the action. */ metadata?: Record; } /** Zod schema for {@link ActionMetadata}. */ declare const ActionMetadataSchema: z.ZodObject<{ key: z.ZodOptional; actionType: z.ZodOptional; name: z.ZodString; description: z.ZodOptional; inputSchema: z.ZodOptional; inputJsonSchema: z.ZodOptional>; outputSchema: z.ZodOptional; outputJsonSchema: z.ZodOptional>; streamSchema: z.ZodOptional; initSchema: z.ZodOptional; initJsonSchema: z.ZodOptional>; metadata: z.ZodOptional>; }, "strip", z.ZodTypeAny, { name: string; metadata?: Record | undefined; description?: string | undefined; key?: string | undefined; outputSchema?: unknown; actionType?: string | undefined; inputSchema?: unknown; inputJsonSchema?: {} | undefined; outputJsonSchema?: {} | undefined; streamSchema?: unknown; initSchema?: unknown; initJsonSchema?: {} | undefined; }, { name: string; metadata?: Record | undefined; description?: string | undefined; key?: string | undefined; outputSchema?: unknown; actionType?: string | undefined; inputSchema?: unknown; inputJsonSchema?: {} | undefined; outputJsonSchema?: {} | undefined; streamSchema?: unknown; initSchema?: unknown; initJsonSchema?: {} | undefined; }>; /** * Results of an action run. Includes telemetry. */ interface ActionResult { result: O; telemetry: { traceId: string; spanId: string; }; } /** * Options (side channel) data to pass to the model. */ interface ActionRunOptions { /** * Streaming callback (optional). */ onChunk?: StreamingCallback; /** * Additional runtime context data (ex. auth context data). */ context?: ActionContext; /** * Additional span attributes to apply to OT spans. */ telemetryLabels?: Record; /** * Abort signal for the action request. */ abortSignal?: AbortSignal; /** * Callback that fires immediately when the root span is created for the action, * providing early access to telemetry data (trace ID, span ID). * This is useful for scenarios where telemetry needs to be available before the action completes. * Note: This only fires once for the root action span, not for nested spans. */ onTraceStart?: (traceInfo: { traceId: string; spanId: string; }) => void; /** * Initialization data provided to the action. */ init?: Init; } /** * Options (side channel) data to pass to the model for bi-directional actions. */ interface BidiActionRunOptions extends ActionRunOptions { /** * Streaming input (optional). */ inputStream?: AsyncIterable; } /** * Options (side channel) data to pass to the model. */ interface ActionFnArg { /** * Whether the caller of the action requested streaming. */ streamingRequested: boolean; /** * Streaming callback (optional). */ sendChunk: StreamingCallback; /** * Additional runtime context data (ex. auth context data). */ context?: ActionContext; /** * Trace context containing trace and span IDs. */ trace: { traceId: string; spanId: string; }; /** * Abort signal for the action request. */ abortSignal: AbortSignal; registry?: Registry; /** * Streaming input. * * The action runtime always provides this. For single-input (unary) actions * it is a stream containing just the one input item. */ inputStream: AsyncIterable; /** * Initialization data provided to the action. */ init: Init; } /** * Streaming response from an action. */ interface StreamingResponse { /** Iterator over the streaming chunks. */ stream: AsyncGenerator>; /** Final output of the action. */ output: Promise>; } /** * Streaming response from a bi-directional action. */ interface BidiStreamingResponse extends StreamingResponse { /** * Sends a chunk of data to the action (for bi-directional streaming). */ send(chunk: z.infer): void; /** * Closes the input stream to the action. */ close(): void; } /** * Self-describing, validating, observable, locally and remotely callable function. */ type Action, z.infer> = ActionRunOptions, any>, Init extends z.ZodTypeAny = z.ZodTypeAny> = ((input?: z.infer, options?: RunOptions) => Promise>) & { /** @hidden */ __action: ActionMetadata; /** @hidden */ __registry?: Registry; run(input?: z.infer, options?: RunOptions): Promise>>; stream(input?: z.infer, opts?: RunOptions): StreamingResponse; }; interface BidiAction, z.infer, z.infer> = BidiActionRunOptions, z.infer, z.infer>> extends Action { streamBidi(init?: z.infer, opts?: RunOptions): BidiStreamingResponse; } /** * Action factory params. */ type ActionParams = { /** * Name of the action, or an object with pluginId and actionId. */ name: string | { pluginId: string; actionId: string; }; /** * Description of the action. */ description?: string; /** * Input Zod schema. */ inputSchema?: I; /** * Input JSON schema. */ inputJsonSchema?: JSONSchema7; /** * Output Zod schema. */ outputSchema?: O; /** * Output JSON schema. */ outputJsonSchema?: JSONSchema7; /** * Metadata for the action. */ metadata?: Record; /** * Middleware to apply to the action. */ use?: Middleware, z.infer, z.infer>[]; /** * Stream Zod schema. */ streamSchema?: S; /** * The type of action. */ actionType: ActionType; /** * Zod schema for the initialization data. */ initSchema?: Init; /** * JSON schema for the initialization data. */ initJsonSchema?: JSONSchema7; }; /** * Configuration for an async action (lazy loaded). */ type ActionAsyncParams = ActionParams & { fn: (input: z.infer, options: ActionFnArg, z.infer>) => Promise>; }; /** * Simple middleware that only modifies request/response. */ type SimpleMiddleware = (req: I, next: (req?: I) => Promise) => Promise; /** * Middleware that has access to options (including streaming callback). */ type MiddlewareWithOptions = (req: I, options: ActionRunOptions | undefined, next: (req?: I, options?: ActionRunOptions) => Promise) => Promise; /** * Middleware function for actions. */ type Middleware = SimpleMiddleware | MiddlewareWithOptions; /** * Creates an action with provided middleware. */ declare function actionWithMiddleware(action: Action, middleware: Middleware, z.infer, z.infer>[]): Action; /** * Creates an action with the provided config. */ declare function action(config: ActionParams, fn: (input: z.infer, options: ActionFnArg, z.infer>) => Promise>): Action, any, Init>; declare function isAction(a: unknown): a is Action; /** * Defines an action with the given config and registers it in the registry. */ declare function defineAction(registry: Registry, config: ActionParams, fn: (input: z.infer, options: ActionFnArg, z.infer, z.infer>) => Promise>): Action, z.infer>, Init>; /** * Defines a bi-directional action with the given config and registers it in the registry. */ declare function defineBidiAction(registry: Registry, config: ActionParams, fn: (input: ActionFnArg, z.infer, z.infer>) => AsyncGenerator, z.infer, void>): BidiAction; /** * Creates a bi-directional action with the given config. */ declare function bidiAction(config: ActionParams, fn: (input: ActionFnArg, z.infer, z.infer>) => AsyncGenerator, z.infer, void>): BidiAction; /** * Defines an action with the given config promise and registers it in the registry. */ declare function defineActionAsync(registry: Registry, actionType: ActionType, name: string | { pluginId: string; actionId: string; }, config: PromiseLike>, onInit?: (action: Action) => void): PromiseLike>; /** Callback function invoked with each streaming chunk during action execution. */ type StreamingCallback = (chunk: T) => void; declare const sentinelNoopStreamingCallback: () => null; /** * Executes provided function with streaming callback in async local storage which can be retrieved * using {@link getStreamingCallback}. */ declare function runWithStreamingCallback(streamingCallback: StreamingCallback | undefined, fn: () => O): O; /** * Retrieves the {@link StreamingCallback} previously set by {@link runWithStreamingCallback} * * @hidden */ declare function getStreamingCallback(): StreamingCallback | undefined; /** * Checks whether the caller is currently in the runtime context of an action. */ declare function isInRuntimeContext(): boolean; /** * Execute the provided function in the action runtime context. */ declare function runInActionRuntimeContext(fn: () => R): R; /** * Execute the provided function outside the action runtime context. */ declare function runOutsideActionRuntimeContext(fn: () => R): R; export { getHttpStatus as $, type Action as A, type BackgroundAction as B, action as C, actionWithMiddleware as D, type ErrorResponseMetadata as E, annotateSchema as F, GenkitError as G, type HttpErrorWireFormat as H, InMemoryStreamManager as I, type JSONSchema as J, assertUnstable as K, backgroundAction as L, type Middleware as M, bidiAction as N, type Operation as O, type Plugin as P, defineAction as Q, type ResolvableAction as R, type SimpleMiddleware as S, defineActionAsync as T, UnstableApiError as U, defineBackgroundAction as V, defineBidiAction as W, defineJsonSchema as X, defineSchema as Y, getCallableJSON as Z, getErrorMessage as _, type ActionAsyncParams as a, getStreamingCallback as a0, inheritSpanMarks as a1, isAction as a2, isBackgroundAction as a3, isInRuntimeContext as a4, registerBackgroundAction as a5, runInActionRuntimeContext as a6, runOutsideActionRuntimeContext as a7, runWithStreamingCallback as a8, sentinelNoopStreamingCallback as a9, toJsonSchema as aa, type ActionType as ab, type ActionMetadataRecord as ac, Registry as ad, type HasRegistry as ae, lookupBackgroundAction as af, getErrorStack as ag, type ProvidedSchema as ah, ValidationError as ai, type ValidationErrorDetail as aj, type ValidationResponse as ak, parseSchema as al, validateSchema as am, type ActionsRecord as an, type AsyncProvider as ao, type Schema as ap, isActionType as aq, parseRegistryKey as ar, type ActionFnArg as b, type ActionMetadata as c, ActionMetadataSchema as d, type ActionParams as e, type ActionResult as f, type ActionRunOptions as g, type ActionStreamInput as h, type ActionStreamSubscriber as i, type BackgroundActionFnArg as j, type BackgroundActionParams as k, type BackgroundActionRunOptions as l, type BidiAction as m, type BidiActionRunOptions as n, type BidiStreamingResponse as o, type InitializedPlugin as p, type MiddlewareWithOptions as q, OperationSchema as r, type PluginProvider as s, type Provider as t, type SpanFailureMarks as u, type StreamManager as v, StreamNotFoundError as w, type StreamingCallback as x, type StreamingResponse as y, UserFacingError as z };