'use strict';

var chunkDIG2K5CV_cjs = require('./chunk-DIG2K5CV.cjs');
var v4 = require('zod/v4');

var workflowRunStatusSchema = v4.z.enum([
  "running",
  "waiting",
  "suspended",
  "success",
  "failed",
  "canceled",
  "pending",
  "bailed",
  "tripwire",
  "paused"
]);
var workflowIdPathParams = v4.z.object({
  workflowId: v4.z.string().describe("Unique identifier for the workflow")
});
var workflowRunPathParams = workflowIdPathParams.extend({
  runId: v4.z.string().describe("Unique identifier for the workflow run")
});
var serializedStepSchema = v4.z.object({
  id: v4.z.string(),
  description: v4.z.string().optional(),
  stateSchema: v4.z.string().optional(),
  inputSchema: v4.z.string().optional(),
  outputSchema: v4.z.string().optional(),
  resumeSchema: v4.z.string().optional(),
  suspendSchema: v4.z.string().optional(),
  component: v4.z.string().optional(),
  isWorkflow: v4.z.boolean().optional(),
  metadata: v4.z.record(v4.z.string(), v4.z.unknown()).optional()
});
var serializedStepFlowEntrySchema = v4.z.object({
  type: v4.z.enum(["step", "sleep", "sleepUntil", "waitForEvent", "parallel", "conditional", "loop", "foreach"])
});
var workflowInfoSchema = v4.z.object({
  steps: v4.z.record(v4.z.string(), serializedStepSchema),
  allSteps: v4.z.record(v4.z.string(), serializedStepSchema),
  name: v4.z.string().optional(),
  description: v4.z.string().optional(),
  stepGraph: v4.z.array(serializedStepFlowEntrySchema),
  inputSchema: v4.z.string().optional(),
  outputSchema: v4.z.string().optional(),
  stateSchema: v4.z.string().optional(),
  options: v4.z.object({}).optional(),
  isProcessorWorkflow: v4.z.boolean().optional()
});
var listWorkflowsResponseSchema = v4.z.record(v4.z.string(), workflowInfoSchema);
var workflowRunSchema = v4.z.object({
  workflowName: v4.z.string(),
  runId: v4.z.string(),
  snapshot: v4.z.union([v4.z.record(v4.z.string(), v4.z.any()), v4.z.string()]),
  createdAt: v4.z.date(),
  updatedAt: v4.z.date(),
  resourceId: v4.z.string().optional()
});
var workflowRunsResponseSchema = v4.z.object({
  runs: v4.z.array(workflowRunSchema),
  total: v4.z.number()
});
var listWorkflowRunsQuerySchema = chunkDIG2K5CV_cjs.createCombinedPaginationSchema().extend({
  fromDate: v4.z.coerce.date().optional(),
  toDate: v4.z.coerce.date().optional(),
  resourceId: v4.z.string().optional(),
  status: workflowRunStatusSchema.optional()
});
var workflowExecutionBodySchema = v4.z.object({
  resourceId: v4.z.string().optional(),
  inputData: v4.z.unknown().optional(),
  initialState: v4.z.unknown().optional(),
  requestContext: v4.z.record(v4.z.string(), v4.z.unknown()).optional(),
  tracingOptions: chunkDIG2K5CV_cjs.tracingOptionsSchema.optional(),
  perStep: v4.z.boolean().optional()
});
var streamLegacyWorkflowBodySchema = workflowExecutionBodySchema;
var streamWorkflowBodySchema = workflowExecutionBodySchema.extend({
  closeOnSuspend: v4.z.boolean().optional()
});
var resumeBodySchema = v4.z.object({
  step: v4.z.union([v4.z.string(), v4.z.array(v4.z.string())]).optional(),
  // Optional - workflow can auto-resume all suspended steps
  resumeData: v4.z.unknown().optional(),
  requestContext: v4.z.record(v4.z.string(), v4.z.unknown()).optional(),
  tracingOptions: chunkDIG2K5CV_cjs.tracingOptionsSchema.optional(),
  perStep: v4.z.boolean().optional(),
  forEachIndex: v4.z.number().int().nonnegative().optional()
});
var restartBodySchema = v4.z.object({
  requestContext: v4.z.record(v4.z.string(), v4.z.unknown()).optional(),
  tracingOptions: chunkDIG2K5CV_cjs.tracingOptionsSchema.optional()
});
var timeTravelBodySchema = v4.z.object({
  inputData: v4.z.unknown().optional(),
  resumeData: v4.z.unknown().optional(),
  initialState: v4.z.unknown().optional(),
  step: v4.z.union([v4.z.string(), v4.z.array(v4.z.string())]),
  context: v4.z.record(v4.z.string(), v4.z.any()).optional(),
  nestedStepsContext: v4.z.record(v4.z.string(), v4.z.record(v4.z.string(), v4.z.any())).optional(),
  requestContext: v4.z.record(v4.z.string(), v4.z.unknown()).optional(),
  tracingOptions: chunkDIG2K5CV_cjs.tracingOptionsSchema.optional(),
  perStep: v4.z.boolean().optional()
});
var startAsyncWorkflowBodySchema = workflowExecutionBodySchema;
var sendWorkflowRunEventBodySchema = v4.z.object({
  event: v4.z.string(),
  data: v4.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) => v4.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 = v4.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 = v4.z.object({
  status: workflowRunStatusSchema.optional(),
  result: v4.z.unknown().optional(),
  error: v4.z.unknown().optional(),
  payload: v4.z.unknown().optional(),
  initialState: v4.z.unknown().optional(),
  steps: v4.z.record(v4.z.string(), v4.z.any()).optional(),
  activeStepsPath: v4.z.record(v4.z.string(), v4.z.array(v4.z.number())).optional(),
  serializedStepGraph: v4.z.array(serializedStepFlowEntrySchema).optional()
});
var workflowRunResultQuerySchema = v4.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 = v4.z.object({
  // Metadata - always present
  runId: v4.z.string(),
  workflowName: v4.z.string(),
  resourceId: v4.z.string().optional(),
  createdAt: v4.z.date(),
  updatedAt: v4.z.date(),
  // Execution state
  status: workflowRunStatusSchema,
  initialState: v4.z.record(v4.z.string(), v4.z.any()).optional(),
  result: v4.z.unknown().optional(),
  error: v4.z.unknown().optional(),
  payload: v4.z.unknown().optional(),
  steps: v4.z.record(v4.z.string(), v4.z.any()).optional(),
  // Optional detailed fields
  activeStepsPath: v4.z.record(v4.z.string(), v4.z.array(v4.z.number())).optional(),
  serializedStepGraph: v4.z.array(serializedStepFlowEntrySchema).optional()
});
var workflowControlResponseSchema = chunkDIG2K5CV_cjs.messageResponseSchema;
var createWorkflowRunResponseSchema = v4.z.object({
  runId: v4.z.string()
});
var createWorkflowRunBodySchema = v4.z.object({
  resourceId: v4.z.string().optional(),
  disableScorers: v4.z.boolean().optional()
});
var observeWorkflowQuerySchema = v4.z.object({
  runId: v4.z.string().describe("Unique identifier for the run"),
  offset: v4.z.coerce.number().optional().describe("Resume from this event index (0-based). If omitted, replays all events.")
});

exports.createWorkflowRunBodySchema = createWorkflowRunBodySchema;
exports.createWorkflowRunResponseSchema = createWorkflowRunResponseSchema;
exports.listWorkflowRunsQuerySchema = listWorkflowRunsQuerySchema;
exports.listWorkflowsResponseSchema = listWorkflowsResponseSchema;
exports.observeWorkflowQuerySchema = observeWorkflowQuerySchema;
exports.restartBodySchema = restartBodySchema;
exports.resumeBodySchema = resumeBodySchema;
exports.sendWorkflowRunEventBodySchema = sendWorkflowRunEventBodySchema;
exports.startAsyncWorkflowBodySchema = startAsyncWorkflowBodySchema;
exports.streamLegacyWorkflowBodySchema = streamLegacyWorkflowBodySchema;
exports.streamWorkflowBodySchema = streamWorkflowBodySchema;
exports.timeTravelBodySchema = timeTravelBodySchema;
exports.workflowControlResponseSchema = workflowControlResponseSchema;
exports.workflowExecutionResultSchema = workflowExecutionResultSchema;
exports.workflowIdPathParams = workflowIdPathParams;
exports.workflowInfoSchema = workflowInfoSchema;
exports.workflowRunPathParams = workflowRunPathParams;
exports.workflowRunResultQuerySchema = workflowRunResultQuerySchema;
exports.workflowRunResultSchema = workflowRunResultSchema;
exports.workflowRunsResponseSchema = workflowRunsResponseSchema;
//# sourceMappingURL=chunk-TF7NSMHW.cjs.map
//# sourceMappingURL=chunk-TF7NSMHW.cjs.map