import { createCombinedPaginationSchema, tracingOptionsSchema, messageResponseSchema } from './chunk-USZD5AX2.js';
import z from 'zod';

var workflowRunStatusSchema = z.enum([
  "running",
  "waiting",
  "suspended",
  "success",
  "failed",
  "canceled",
  "pending",
  "bailed",
  "tripwire",
  "paused"
]);
var workflowIdPathParams = z.object({
  workflowId: z.string().describe("Unique identifier for the workflow")
});
var workflowRunPathParams = workflowIdPathParams.extend({
  runId: z.string().describe("Unique identifier for the workflow run")
});
var serializedStepSchema = z.object({
  id: z.string(),
  description: z.string().optional(),
  stateSchema: z.string().optional(),
  inputSchema: z.string().optional(),
  outputSchema: z.string().optional(),
  resumeSchema: z.string().optional(),
  suspendSchema: z.string().optional(),
  component: z.string().optional(),
  isWorkflow: z.boolean().optional(),
  metadata: z.record(z.string(), z.unknown()).optional()
});
var serializedStepFlowEntrySchema = z.object({
  type: z.enum(["step", "sleep", "sleepUntil", "waitForEvent", "parallel", "conditional", "loop", "foreach"])
});
var workflowInfoSchema = z.object({
  steps: z.record(z.string(), serializedStepSchema),
  allSteps: z.record(z.string(), serializedStepSchema),
  name: z.string().optional(),
  description: z.string().optional(),
  stepGraph: z.array(serializedStepFlowEntrySchema),
  inputSchema: z.string().optional(),
  outputSchema: z.string().optional(),
  stateSchema: z.string().optional(),
  options: z.object({}).optional(),
  isProcessorWorkflow: z.boolean().optional()
});
var listWorkflowsResponseSchema = z.record(z.string(), workflowInfoSchema);
var workflowRunSchema = z.object({
  workflowName: z.string(),
  runId: z.string(),
  snapshot: z.union([z.record(z.string(), z.any()), z.string()]),
  createdAt: z.date(),
  updatedAt: z.date(),
  resourceId: z.string().optional()
});
var workflowRunsResponseSchema = z.object({
  runs: z.array(workflowRunSchema),
  total: z.number()
});
var listWorkflowRunsQuerySchema = createCombinedPaginationSchema().extend({
  fromDate: z.coerce.date().optional(),
  toDate: z.coerce.date().optional(),
  resourceId: z.string().optional(),
  status: workflowRunStatusSchema.optional()
});
var workflowExecutionBodySchema = z.object({
  resourceId: z.string().optional(),
  inputData: z.unknown().optional(),
  initialState: z.unknown().optional(),
  requestContext: z.record(z.string(), z.unknown()).optional(),
  tracingOptions: tracingOptionsSchema.optional(),
  perStep: z.boolean().optional()
});
var streamLegacyWorkflowBodySchema = workflowExecutionBodySchema;
var streamWorkflowBodySchema = workflowExecutionBodySchema.extend({
  closeOnSuspend: z.boolean().optional()
});
var resumeBodySchema = z.object({
  step: z.union([z.string(), z.array(z.string())]).optional(),
  // Optional - workflow can auto-resume all suspended steps
  resumeData: z.unknown().optional(),
  requestContext: z.record(z.string(), z.unknown()).optional(),
  tracingOptions: tracingOptionsSchema.optional(),
  perStep: z.boolean().optional()
});
var restartBodySchema = z.object({
  requestContext: z.record(z.string(), z.unknown()).optional(),
  tracingOptions: tracingOptionsSchema.optional()
});
var timeTravelBodySchema = z.object({
  inputData: z.unknown().optional(),
  resumeData: z.unknown().optional(),
  initialState: z.unknown().optional(),
  step: z.union([z.string(), z.array(z.string())]),
  context: z.record(z.string(), z.any()).optional(),
  nestedStepsContext: z.record(z.string(), z.record(z.string(), z.any())).optional(),
  requestContext: z.record(z.string(), z.unknown()).optional(),
  tracingOptions: tracingOptionsSchema.optional(),
  perStep: z.boolean().optional()
});
var startAsyncWorkflowBodySchema = workflowExecutionBodySchema;
var sendWorkflowRunEventBodySchema = z.object({
  event: z.string(),
  data: z.unknown()
});
var VALID_WORKFLOW_RESULT_FIELDS = /* @__PURE__ */ new Set([
  "result",
  "error",
  "payload",
  "steps",
  "activeStepsPath",
  "serializedStepGraph"
]);
var WORKFLOW_RESULT_FIELDS_ERROR = "Invalid field name. Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph";
var createFieldsValidator = (description) => z.string().optional().refine(
  (value) => {
    if (!value) return true;
    const requestedFields = value.split(",").map((f) => f.trim());
    return requestedFields.every((field) => VALID_WORKFLOW_RESULT_FIELDS.has(field));
  },
  { message: WORKFLOW_RESULT_FIELDS_ERROR }
).describe(description);
var withNestedWorkflowsField = z.enum(["true", "false"]).optional().describe("Whether to include nested workflow data in steps. Defaults to true. Set to false for better performance.");
var workflowExecutionResultSchema = z.object({
  status: workflowRunStatusSchema.optional(),
  result: z.unknown().optional(),
  error: z.unknown().optional(),
  payload: z.unknown().optional(),
  initialState: z.unknown().optional(),
  steps: z.record(z.string(), z.any()).optional(),
  activeStepsPath: z.record(z.string(), z.array(z.number())).optional(),
  serializedStepGraph: z.array(serializedStepFlowEntrySchema).optional()
});
var workflowRunResultQuerySchema = z.object({
  fields: createFieldsValidator(
    "Comma-separated list of fields to return. Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph. Metadata fields (runId, workflowName, resourceId, createdAt, updatedAt) and status are always included."
  ),
  withNestedWorkflows: withNestedWorkflowsField
});
var workflowRunResultSchema = z.object({
  // Metadata - always present
  runId: z.string(),
  workflowName: z.string(),
  resourceId: z.string().optional(),
  createdAt: z.date(),
  updatedAt: z.date(),
  // Execution state
  status: workflowRunStatusSchema,
  initialState: z.record(z.string(), z.any()).optional(),
  result: z.unknown().optional(),
  error: z.unknown().optional(),
  payload: z.unknown().optional(),
  steps: z.record(z.string(), z.any()).optional(),
  // Optional detailed fields
  activeStepsPath: z.record(z.string(), z.array(z.number())).optional(),
  serializedStepGraph: z.array(serializedStepFlowEntrySchema).optional()
});
var workflowControlResponseSchema = messageResponseSchema;
var createWorkflowRunResponseSchema = z.object({
  runId: z.string()
});
var createWorkflowRunBodySchema = z.object({
  resourceId: z.string().optional(),
  disableScorers: z.boolean().optional()
});

export { createWorkflowRunBodySchema, createWorkflowRunResponseSchema, listWorkflowRunsQuerySchema, listWorkflowsResponseSchema, restartBodySchema, resumeBodySchema, sendWorkflowRunEventBodySchema, startAsyncWorkflowBodySchema, streamLegacyWorkflowBodySchema, streamWorkflowBodySchema, timeTravelBodySchema, workflowControlResponseSchema, workflowExecutionResultSchema, workflowIdPathParams, workflowInfoSchema, workflowRunPathParams, workflowRunResultQuerySchema, workflowRunResultSchema, workflowRunsResponseSchema };
//# sourceMappingURL=chunk-II6TN6MR.js.map
//# sourceMappingURL=chunk-II6TN6MR.js.map