import { z } from 'zod'; import { A as Action, g as ActionRunOptions, b as ActionFnArg, ad as Registry } from './action-2eSGxHx0.js'; import { JSONSchema7 } from 'json-schema'; import './context.js'; import './statusTypes.js'; import 'dotprompt'; import '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. */ /** * Flow is an observable, streamable, (optionally) strongly typed function. */ interface Flow extends Action, z.infer>, Init> { } /** * Configuration for a streaming flow. */ interface FlowConfig { /** Name of the flow. */ name: string; /** Schema of the input to the flow. */ inputSchema?: I; /** Schema of the output from the flow. */ outputSchema?: O; /** Schema of the streaming chunks from the flow. */ streamSchema?: S; /** Metadata of the flow used by tooling. */ metadata?: Record; /** Schema of the initialization data. */ initSchema?: Init; /** JSON schema of the initialization data. */ initJsonSchema?: JSONSchema7; } /** * Flow execution context for flow to access the streaming callback and * side-channel context data. The context itself is a function, a short-cut * for streaming callback. */ interface FlowSideChannel extends ActionFnArg { (chunk: S): void; } /** * Function to be executed in the flow. */ type FlowFn = ( /** Input to the flow. */ input: z.infer, /** Callback for streaming functions only. */ streamingCallback: FlowSideChannel>) => Promise> | z.infer; /** * Defines a flow. This operates on the currently active registry. */ declare function flow(config: FlowConfig | string, fn: FlowFn): Flow; /** * Defines a non-streaming flow. This operates on the currently active registry. */ declare function defineFlow(registry: Registry, config: FlowConfig | string, fn: FlowFn): Flow; /** * A flow step that executes the provided function. */ declare function run(name: string, func: () => Promise, _?: Registry): Promise; /** * A flow step that executes the provided function with input. */ declare function run(name: string, input: any, func: (input?: any) => Promise, registry?: Registry): Promise; export { type Flow, type FlowConfig, type FlowFn, type FlowSideChannel, defineFlow, flow, run };