'use strict';

var chunkZYXDUS6Q_cjs = require('./chunk-ZYXDUS6Q.cjs');
var z = require('zod');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var z__default = /*#__PURE__*/_interopDefault(z);

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

exports.createWorkflowRunBodySchema = createWorkflowRunBodySchema;
exports.createWorkflowRunResponseSchema = createWorkflowRunResponseSchema;
exports.listWorkflowRunsQuerySchema = listWorkflowRunsQuerySchema;
exports.listWorkflowsResponseSchema = listWorkflowsResponseSchema;
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-U4YUXGDH.cjs.map
//# sourceMappingURL=chunk-U4YUXGDH.cjs.map