{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Operation, StreamingCallback } from '@genkit-ai/core';\nimport { z } from 'zod';\nimport { Flow } from './flow.js';\n\nexport type Invoker<\n  I extends z.ZodTypeAny = z.ZodTypeAny,\n  O extends z.ZodTypeAny = z.ZodTypeAny,\n  S extends z.ZodTypeAny = z.ZodTypeAny,\n> = (\n  flow: Flow<I, O, S>,\n  msg: FlowInvokeEnvelopeMessage,\n  streamingCallback?: StreamingCallback<any>\n) => Promise<Operation>;\n\nexport type Scheduler<\n  I extends z.ZodTypeAny = z.ZodTypeAny,\n  O extends z.ZodTypeAny = z.ZodTypeAny,\n  S extends z.ZodTypeAny = z.ZodTypeAny,\n> = (\n  flow: Flow<I, O, S>,\n  msg: FlowInvokeEnvelopeMessage,\n  delaySeconds?: number\n) => Promise<void>;\n\n/**\n * The message format used by the flow task queue and control interface.\n */\nexport const FlowInvokeEnvelopeMessageSchema = z.object({\n  // Start new flow.\n  start: z\n    .object({\n      input: z.unknown().optional(),\n      labels: z.record(z.string(), z.string()).optional(),\n    })\n    .optional(),\n  // Schedule new flow.\n  schedule: z\n    .object({\n      input: z.unknown().optional(),\n      delay: z.number().optional(),\n    })\n    .optional(),\n  // Run previously scheduled flow.\n  runScheduled: z\n    .object({\n      flowId: z.string(),\n    })\n    .optional(),\n  // Retry failed step (only if step is setup for retry)\n  retry: z\n    .object({\n      flowId: z.string(),\n    })\n    .optional(),\n  // Resume an interrupted flow.\n  resume: z\n    .object({\n      flowId: z.string(),\n      payload: z.unknown().optional(),\n    })\n    .optional(),\n  // State check for a given flow ID. No side effects, can be used to check flow state.\n  state: z\n    .object({\n      flowId: z.string(),\n    })\n    .optional(),\n});\nexport type FlowInvokeEnvelopeMessage = z.infer<\n  typeof FlowInvokeEnvelopeMessageSchema\n>;\n\nexport const FlowActionInputSchema = FlowInvokeEnvelopeMessageSchema.extend({\n  auth: z.unknown().optional(),\n});\n\n/**\n * Retry options for flows and steps.\n */\nexport interface RetryConfig {\n  /**\n   * Maximum number of times a request should be attempted.\n   * If left unspecified, will default to 3.\n   */\n  maxAttempts?: number;\n  /**\n   * Maximum amount of time for retrying failed task.\n   * If left unspecified will retry indefinitely.\n   */\n  maxRetrySeconds?: number;\n  /**\n   * The maximum amount of time to wait between attempts.\n   * If left unspecified will default to 1hr.\n   */\n  maxBackoffSeconds?: number;\n  /**\n   * The maximum number of times to double the backoff between\n   * retries. If left unspecified will default to 16.\n   */\n  maxDoublings?: number;\n  /**\n   * The minimum time to wait between attempts. If left unspecified\n   * will default to 100ms.\n   */\n  minBackoffSeconds?: number;\n}\n"],"mappings":";AAiBA,SAAS,SAAS;AA0BX,MAAM,kCAAkC,EAAE,OAAO;AAAA;AAAA,EAEtD,OAAO,EACJ,OAAO;AAAA,IACN,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,IAC5B,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACpD,CAAC,EACA,SAAS;AAAA;AAAA,EAEZ,UAAU,EACP,OAAO;AAAA,IACN,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,IAC5B,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,CAAC,EACA,SAAS;AAAA;AAAA,EAEZ,cAAc,EACX,OAAO;AAAA,IACN,QAAQ,EAAE,OAAO;AAAA,EACnB,CAAC,EACA,SAAS;AAAA;AAAA,EAEZ,OAAO,EACJ,OAAO;AAAA,IACN,QAAQ,EAAE,OAAO;AAAA,EACnB,CAAC,EACA,SAAS;AAAA;AAAA,EAEZ,QAAQ,EACL,OAAO;AAAA,IACN,QAAQ,EAAE,OAAO;AAAA,IACjB,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAChC,CAAC,EACA,SAAS;AAAA;AAAA,EAEZ,OAAO,EACJ,OAAO;AAAA,IACN,QAAQ,EAAE,OAAO;AAAA,EACnB,CAAC,EACA,SAAS;AACd,CAAC;AAKM,MAAM,wBAAwB,gCAAgC,OAAO;AAAA,EAC1E,MAAM,EAAE,QAAQ,EAAE,SAAS;AAC7B,CAAC;","names":[]}