// Auto-generated by generate.py - DO NOT EDIT

import { z } from 'zod'

export const scheduleRequestSchema = z.object({
	"path": z.string().describe("The unique Windmill path for this schedule. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`."),
	"schedule": z.string().describe("Cron expression with 6 fields (seconds, minutes, hours, day of month, month, day of week). Example '0 0 12 * * *' for daily at noon"),
	"timezone": z.string().describe("IANA timezone for the schedule (e.g., 'UTC', 'Europe/Paris', 'America/New_York')"),
	"script_path": z.string().describe("Path to the script or flow to execute when triggered"),
	"is_flow": z.boolean().describe("True if script_path points to a flow, false if it points to a script"),
	"args": z.record(z.string(), z.any()).describe("The arguments to pass to the script or flow").nullable(),
	"enabled": z.boolean().describe("Whether the schedule is currently active and will trigger jobs").optional(),
	"on_failure": z.string().describe("Path to a script or flow to run when the scheduled job fails").nullable().optional(),
	"on_failure_times": z.number().describe("Number of consecutive failures before the on_failure handler is triggered (default 1)").nullable().optional(),
	"on_failure_exact": z.boolean().describe("If true, trigger on_failure handler only on exactly N failures, not on every failure after N").nullable().optional(),
	"on_failure_extra_args": z.record(z.string(), z.any()).describe("The arguments to pass to the script or flow").nullable().optional(),
	"on_recovery": z.string().describe("Path to a script or flow to run when the schedule recovers after failures").nullable().optional(),
	"on_recovery_times": z.number().describe("Number of consecutive successes before the on_recovery handler is triggered (default 1)").nullable().optional(),
	"on_recovery_extra_args": z.record(z.string(), z.any()).describe("The arguments to pass to the script or flow").nullable().optional(),
	"on_success": z.string().describe("Path to a script or flow to run after each successful execution").nullable().optional(),
	"on_success_extra_args": z.record(z.string(), z.any()).describe("The arguments to pass to the script or flow").nullable().optional(),
	"ws_error_handler_muted": z.boolean().describe("If true, the workspace-level error handler will not be triggered for this schedule's failures").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed module executions").nullable().optional(),
	"no_flow_overlap": z.boolean().describe("If true, skip this schedule's execution if the previous run is still in progress (prevents concurrent runs)").optional(),
	"summary": z.string().describe("Short summary describing the purpose of this schedule").nullable().optional(),
	"description": z.string().describe("Detailed description of what this schedule does").nullable().optional(),
	"tag": z.string().describe("Worker tag to route jobs to specific worker groups").nullable().optional(),
	"paused_until": z.string().datetime({ offset: true }).describe("ISO 8601 datetime until which the schedule is paused. Schedule resumes automatically after this time").nullable().optional(),
	"cron_version": z.string().describe("Cron parser version. Use 'v2' for extended syntax with additional features").nullable().optional(),
	"dynamic_skip": z.string().describe("Path to a script that validates scheduled datetimes. Receives scheduled_for datetime and returns boolean to skip (true) or run (false)").nullable().optional(),
	"permissioned_as": z.string().describe("The user or group this schedule runs as. Used during deployment to preserve the original schedule owner.").optional(),
	"preserve_permissioned_as": z.boolean().describe("When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.").optional(),
	"labels": z.array(z.string()).optional()
})

export const httpTriggerRequestSchema = z.object({
	"path": z.string().describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path."),
	"script_path": z.string().describe("Path to the script or flow to execute when triggered"),
	"route_path": z.string().describe("The URL route path that will trigger this endpoint (e.g., 'api/myendpoint'). Must NOT start with a /."),
	"workspaced_route": z.boolean().describe("If true, the route includes the workspace ID in the path").optional(),
	"summary": z.string().describe("Short summary describing the purpose of this trigger").nullable().optional(),
	"description": z.string().describe("Detailed description of what this trigger does").nullable().optional(),
	"static_asset_config": z.object({
		"s3": z.string().describe("S3 bucket path for static assets"),
		"storage": z.string().describe("Storage path for static assets").optional(),
		"filename": z.string().describe("Filename for the static asset").optional()
	}).describe("Configuration for serving static assets (s3 bucket, storage path, filename)").nullable().optional(),
	"is_flow": z.boolean().describe("True if script_path points to a flow, false if it points to a script"),
	"http_method": z.enum(["get", "post", "put", "delete", "patch"]).describe("HTTP method (get, post, put, delete, patch) that triggers this endpoint"),
	"authentication_resource_path": z.string().describe("Path to the resource containing authentication configuration (for api_key, basic_http, custom_script, signature methods)").nullable().optional(),
	"is_async": z.boolean().describe("Deprecated, use request_type instead").optional(),
	"request_type": z.enum(["sync", "async", "sync_sse"]).describe("How the request is handled - 'sync' waits for result, 'async' returns job ID immediately, 'sync_sse' streams results via Server-Sent Events").optional(),
	"authentication_method": z.enum(["none", "windmill", "api_key", "basic_http", "custom_script", "signature"]).describe("How requests are authenticated - 'none' (public), 'windmill' (Windmill token), 'api_key', 'basic_http', 'custom_script', 'signature'"),
	"is_static_website": z.boolean().describe("If true, serves static files from S3/storage instead of running a script"),
	"wrap_body": z.boolean().describe("If true, wraps the request body in a 'body' parameter").optional(),
	"mode": z.enum(["enabled", "disabled", "suspended"]).describe("job trigger mode").optional(),
	"raw_string": z.boolean().describe("If true, passes the request body as a raw string instead of parsing as JSON").optional(),
	"error_handler_path": z.string().describe("Path to a script or flow to run when the triggered job fails").optional(),
	"error_handler_args": z.record(z.string(), z.any()).describe("Arguments to pass to the error handler").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed executions").optional(),
	"permissioned_as": z.string().describe("The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.").optional(),
	"preserve_permissioned_as": z.boolean().describe("When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.").optional(),
	"labels": z.array(z.string()).optional()
})

export const websocketTriggerRequestSchema = z.object({
	"path": z.string().describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path."),
	"script_path": z.string().describe("Path to the script or flow to execute when a message is received"),
	"is_flow": z.boolean().describe("True if script_path points to a flow, false if it points to a script"),
	"url": z.string().describe("The WebSocket URL to connect to (can be a static URL or computed by a runnable)"),
	"mode": z.enum(["enabled", "disabled", "suspended"]).describe("job trigger mode").optional(),
	"filters": z.array(z.object({
		"key": z.string(),
		"value": z.any()
	})).describe("Array of key-value filters to match incoming messages (only matching messages trigger the script)"),
	"filter_logic": z.enum(["and", "or"]).describe("Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.").default("and").optional(),
	"initial_messages": z.array(z.union([z.object({
		"raw_message": z.string()
	}), z.object({
		"runnable_result": z.object({
			"path": z.string(),
			"args": z.record(z.string(), z.any()).describe("The arguments to pass to the script or flow"),
			"is_flow": z.boolean()
		})
	})])).describe("Messages to send immediately after connecting (can be raw strings or computed by runnables)").nullable().optional(),
	"url_runnable_args": z.record(z.string(), z.any()).describe("Arguments to pass to the script/flow that computes the WebSocket URL").nullable().optional(),
	"can_return_message": z.boolean().describe("If true, the script can return a message to send back through the WebSocket"),
	"can_return_error_result": z.boolean().describe("If true, error results are sent back through the WebSocket"),
	"heartbeat": z.object({
		"interval_secs": z.number().int().gte(1).describe("Interval in seconds between heartbeat messages"),
		"message": z.string().describe("Message to send as heartbeat. Use {{state}} as a placeholder for a value extracted from incoming messages (see state_field)."),
		"state_field": z.string().describe("Optional. Top-level JSON field to extract from incoming messages. The extracted value replaces {{state}} in the heartbeat message.").optional()
	}).describe("Optional periodic heartbeat message configuration").nullable().optional(),
	"error_handler_path": z.string().describe("Path to a script or flow to run when the triggered job fails").optional(),
	"error_handler_args": z.record(z.string(), z.any()).describe("Arguments to pass to the error handler").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed executions").optional(),
	"permissioned_as": z.string().describe("The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.").optional(),
	"preserve_permissioned_as": z.boolean().describe("When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.").optional(),
	"labels": z.array(z.string()).optional()
})

export const kafkaTriggerRequestSchema = z.object({
	"path": z.string().describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path."),
	"script_path": z.string().describe("Path to the script or flow to execute when a message is received"),
	"is_flow": z.boolean().describe("True if script_path points to a flow, false if it points to a script"),
	"kafka_resource_path": z.string().describe("Path to the Kafka resource containing connection configuration"),
	"group_id": z.string().describe("Kafka consumer group ID for this trigger"),
	"topics": z.array(z.string()).describe("Array of Kafka topic names to subscribe to"),
	"filters": z.array(z.object({
		"key": z.string(),
		"value": z.any()
	})),
	"filter_logic": z.enum(["and", "or"]).describe("Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.").default("and").optional(),
	"auto_offset_reset": z.enum(["latest", "earliest"]).describe("Initial offset behavior when consumer group has no committed offset.").default("latest").optional(),
	"auto_commit": z.boolean().describe("When true (default), offsets are committed automatically after receiving each message. When false, you must manually commit offsets using the commit_offsets endpoint.").default(true).optional(),
	"mode": z.enum(["enabled", "disabled", "suspended"]).describe("job trigger mode").optional(),
	"error_handler_path": z.string().describe("Path to a script or flow to run when the triggered job fails").optional(),
	"error_handler_args": z.record(z.string(), z.any()).describe("Arguments to pass to the error handler").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed executions").optional(),
	"permissioned_as": z.string().describe("The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.").optional(),
	"preserve_permissioned_as": z.boolean().describe("When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.").optional(),
	"labels": z.array(z.string()).optional()
})

export const natsTriggerRequestSchema = z.object({
	"path": z.string().describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path."),
	"script_path": z.string().describe("Path to the script or flow to execute when a message is received"),
	"is_flow": z.boolean().describe("True if script_path points to a flow, false if it points to a script"),
	"nats_resource_path": z.string().describe("Path to the NATS resource containing connection configuration"),
	"use_jetstream": z.boolean().describe("If true, uses NATS JetStream for durable message delivery"),
	"stream_name": z.string().describe("JetStream stream name (required when use_jetstream is true)").nullable().optional(),
	"consumer_name": z.string().describe("JetStream consumer name (required when use_jetstream is true)").nullable().optional(),
	"subjects": z.array(z.string()).describe("Array of NATS subjects to subscribe to"),
	"mode": z.enum(["enabled", "disabled", "suspended"]).describe("job trigger mode").optional(),
	"error_handler_path": z.string().describe("Path to a script or flow to run when the triggered job fails").optional(),
	"error_handler_args": z.record(z.string(), z.any()).describe("Arguments to pass to the error handler").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed executions").optional(),
	"permissioned_as": z.string().describe("The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.").optional(),
	"preserve_permissioned_as": z.boolean().describe("When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.").optional(),
	"labels": z.array(z.string()).optional()
})

export const postgresTriggerRequestSchema = z.object({
	"replication_slot_name": z.string().describe("Name of the PostgreSQL logical replication slot to use").optional(),
	"publication_name": z.string().describe("Name of the PostgreSQL publication to subscribe to for change data capture").optional(),
	"path": z.string().describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path."),
	"script_path": z.string().describe("Path to the script or flow to execute when database changes are detected"),
	"is_flow": z.boolean().describe("True if script_path points to a flow, false if it points to a script"),
	"mode": z.enum(["enabled", "disabled", "suspended"]).describe("job trigger mode").optional(),
	"postgres_resource_path": z.string().describe("Path to the PostgreSQL resource containing connection configuration"),
	"publication": z.object({
		"table_to_track": z.array(z.object({
			"schema_name": z.string(),
			"table_to_track": z.array(z.object({
				"table_name": z.string(),
				"columns_name": z.array(z.string()).optional(),
				"where_clause": z.string().optional()
			}))
		})).optional(),
		"transaction_to_track": z.array(z.string())
	}).describe("Configuration for creating/managing the publication (tables, operations)").optional(),
	"error_handler_path": z.string().describe("Path to a script or flow to run when the triggered job fails").optional(),
	"error_handler_args": z.record(z.string(), z.any()).describe("Arguments to pass to the error handler").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed executions").optional(),
	"permissioned_as": z.string().describe("The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.").optional(),
	"preserve_permissioned_as": z.boolean().describe("When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.").optional(),
	"labels": z.array(z.string()).optional()
})

export const mqttTriggerRequestSchema = z.object({
	"mqtt_resource_path": z.string().describe("Path to the MQTT resource containing broker connection configuration"),
	"subscribe_topics": z.array(z.object({
		"qos": z.enum(["qos0", "qos1", "qos2"]),
		"topic": z.string()
	})).describe("Array of MQTT topics to subscribe to, each with topic name and QoS level"),
	"client_id": z.string().describe("MQTT client ID for this connection").nullable().optional(),
	"v3_config": z.object({
		"clean_session": z.boolean().optional()
	}).describe("MQTT v3 specific configuration (clean_session)").nullable().optional(),
	"v5_config": z.object({
		"clean_start": z.boolean().optional(),
		"topic_alias_maximum": z.number().optional(),
		"session_expiry_interval": z.number().optional()
	}).describe("MQTT v5 specific configuration (clean_start, topic_alias_maximum, session_expiry_interval)").nullable().optional(),
	"client_version": z.enum(["v3", "v5"]).describe("MQTT protocol version ('v3' or 'v5')").nullable().optional(),
	"path": z.string().describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path."),
	"script_path": z.string().describe("Path to the script or flow to execute when a message is received"),
	"is_flow": z.boolean().describe("True if script_path points to a flow, false if it points to a script"),
	"mode": z.enum(["enabled", "disabled", "suspended"]).describe("job trigger mode").optional(),
	"error_handler_path": z.string().describe("Path to a script or flow to run when the triggered job fails").optional(),
	"error_handler_args": z.record(z.string(), z.any()).describe("Arguments to pass to the error handler").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed executions").optional(),
	"permissioned_as": z.string().describe("The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.").optional(),
	"preserve_permissioned_as": z.boolean().describe("When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.").optional(),
	"labels": z.array(z.string()).optional()
})

export const amqpTriggerRequestSchema = z.object({
	"amqp_resource_path": z.string().describe("Path to the AMQP resource containing broker connection configuration"),
	"queue_name": z.string().describe("Name of the queue to consume messages from"),
	"exchange": z.object({
		"exchange_name": z.string().describe("Name of the exchange to bind the consumed queue to"),
		"routing_keys": z.array(z.string()).describe("Routing keys used to bind the queue to the exchange").optional()
	}).describe("Optional exchange binding for the consumed queue").nullable().optional(),
	"options": z.object({
		"declare_queue": z.boolean().describe("Declare the queue (durable) before consuming; when false the queue is declared passively and must already exist").optional(),
		"prefetch_count": z.number().int().gte(1).lte(65535).describe("Maximum number of unacknowledged messages the broker delivers at once (1-65535)").optional()
	}).describe("Optional consumer options (queue declaration, prefetch)").nullable().optional(),
	"path": z.string().describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`."),
	"script_path": z.string().describe("Path to the script or flow to execute when a message is received"),
	"is_flow": z.boolean().describe("True if script_path points to a flow, false if it points to a script"),
	"mode": z.enum(["enabled", "disabled", "suspended"]).describe("job trigger mode").optional(),
	"error_handler_path": z.string().describe("Path to a script or flow to run when the triggered job fails").optional(),
	"error_handler_args": z.record(z.string(), z.any()).describe("Arguments to pass to the error handler").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed executions").optional(),
	"permissioned_as": z.string().describe("The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.").optional(),
	"preserve_permissioned_as": z.boolean().describe("When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.").optional(),
	"labels": z.array(z.string()).optional()
})

export const sqsTriggerRequestSchema = z.object({
	"queue_url": z.string().describe("The full URL of the AWS SQS queue to poll for messages"),
	"aws_auth_resource_type": z.enum(["oidc", "credentials"]).describe("Authentication type - 'credentials' for access key/secret, 'oidc' for OpenID Connect"),
	"aws_resource_path": z.string().describe("Path to the AWS resource containing credentials or OIDC configuration"),
	"message_attributes": z.array(z.string()).describe("Array of SQS message attribute names to include with each message").nullable().optional(),
	"path": z.string().describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path."),
	"script_path": z.string().describe("Path to the script or flow to execute when a message is received"),
	"is_flow": z.boolean().describe("True if script_path points to a flow, false if it points to a script"),
	"mode": z.enum(["enabled", "disabled", "suspended"]).describe("job trigger mode").optional(),
	"error_handler_path": z.string().describe("Path to a script or flow to run when the triggered job fails").optional(),
	"error_handler_args": z.record(z.string(), z.any()).describe("Arguments to pass to the error handler").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed executions").optional(),
	"permissioned_as": z.string().describe("The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.").optional(),
	"preserve_permissioned_as": z.boolean().describe("When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.").optional(),
	"labels": z.array(z.string()).optional()
})

export const gcpTriggerRequestSchema = z.object({
	"gcp_resource_path": z.string().describe("Path to the GCP resource containing service account credentials for authentication."),
	"subscription_mode": z.enum(["existing", "create_update"]).describe("The mode of subscription. 'existing' means using an existing GCP subscription, while 'create_update' involves creating or updating a new subscription."),
	"topic_id": z.string().describe("Google Cloud Pub/Sub topic ID to subscribe to."),
	"subscription_id": z.string().describe("Google Cloud Pub/Sub subscription ID.").optional(),
	"base_endpoint": z.string().describe("Base URL for push delivery endpoint.").optional(),
	"delivery_type": z.enum(["push", "pull"]).describe("Delivery mode for messages. 'push' for HTTP push delivery where messages are sent to a webhook endpoint, 'pull' for polling where the trigger actively fetches messages.").optional(),
	"delivery_config": z.object({
		"audience": z.string().describe("The audience claim for OIDC tokens used in push authentication.").optional(),
		"authenticate": z.boolean().describe("If true, push messages will include OIDC authentication tokens.")
	}).describe("Configuration for push delivery mode.").nullable().optional(),
	"path": z.string().describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path."),
	"script_path": z.string().describe("Path to the script or flow to execute when a message is received."),
	"is_flow": z.boolean().describe("True if script_path points to a flow, false if it points to a script."),
	"mode": z.enum(["enabled", "disabled", "suspended"]).describe("job trigger mode").optional(),
	"auto_acknowledge_msg": z.boolean().describe("If true, automatically acknowledge messages after processing.").optional(),
	"ack_deadline": z.number().int().gte(10).lte(600).describe("Time in seconds within which the message must be acknowledged. If not provided, defaults to the subscription's acknowledgment deadline (600 seconds).").optional(),
	"error_handler_path": z.string().describe("Path to a script or flow to run when the triggered job fails.").optional(),
	"error_handler_args": z.record(z.string(), z.any()).describe("Arguments to pass to the error handler.").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed executions.").optional(),
	"permissioned_as": z.string().describe("The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.").optional(),
	"preserve_permissioned_as": z.boolean().describe("When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.").optional(),
	"labels": z.array(z.string()).optional()
}).describe("Data for creating or updating a Google Cloud Pub/Sub trigger.")

export const azureTriggerRequestSchema = z.object({
	"azure_resource_path": z.string(),
	"azure_mode": z.enum(["basic_push", "namespace_push", "namespace_pull"]).describe("Azure Event Grid trigger mode."),
	"scope_resource_id": z.string(),
	"topic_name": z.string().nullable().optional(),
	"subscription_name": z.string(),
	"base_endpoint": z.string().describe("Base URL for push delivery endpoints (push modes only).").optional(),
	"event_type_filters": z.array(z.string()).optional(),
	"path": z.string().describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path."),
	"script_path": z.string(),
	"is_flow": z.boolean(),
	"mode": z.enum(["enabled", "disabled", "suspended"]).describe("job trigger mode").optional(),
	"error_handler_path": z.string().optional(),
	"error_handler_args": z.record(z.string(), z.any()).describe("The arguments to pass to the script or flow").optional(),
	"retry": z.object({
		"constant": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"seconds": z.number().int().describe("Seconds to wait between retries").optional()
		}).describe("Retry with constant delay between attempts").optional(),
		"exponential": z.object({
			"attempts": z.number().int().describe("Number of retry attempts").optional(),
			"multiplier": z.number().int().describe("Multiplier for exponential backoff").optional(),
			"seconds": z.number().int().gte(1).describe("Initial delay in seconds").optional(),
			"random_factor": z.number().int().gte(0).lte(100).describe("Random jitter percentage (0-100) to avoid thundering herd").optional()
		}).describe("Retry with exponential backoff (delay doubles each time)").optional(),
		"retry_if": z.object({
			"expr": z.string().describe("JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables")
		}).describe("Conditional retry based on error or result").optional()
	}).describe("Retry configuration for failed module executions").optional(),
	"permissioned_as": z.string().optional(),
	"preserve_permissioned_as": z.boolean().optional(),
	"labels": z.array(z.string()).optional()
}).describe("Data for creating or updating an Azure Event Grid trigger.")

export const variableRequestSchema = z.object({
	"path": z.string().describe("The path to the variable"),
	"value": z.string().describe("The value of the variable"),
	"is_secret": z.boolean().describe("Whether the variable is a secret"),
	"description": z.string().describe("The description of the variable"),
	"account": z.number().int().describe("The account identifier").optional(),
	"is_oauth": z.boolean().describe("Whether the variable is an OAuth variable").optional(),
	"expires_at": z.string().datetime({ offset: true }).describe("The expiration date of the variable").optional(),
	"labels": z.array(z.string()).optional(),
	"ws_specific": z.boolean().optional()
})

export const resourceRequestSchema = z.object({
	"path": z.string().describe("The path to the resource"),
	"value": z.any(),
	"description": z.string().describe("The description of the resource").optional(),
	"resource_type": z.string().describe("The resource_type associated with the resource"),
	"labels": z.array(z.string()).optional(),
	"ws_specific": z.boolean().optional()
})

export const triggerRequestSchemas = {
	http: httpTriggerRequestSchema,
	websocket: websocketTriggerRequestSchema,
	kafka: kafkaTriggerRequestSchema,
	nats: natsTriggerRequestSchema,
	postgres: postgresTriggerRequestSchema,
	mqtt: mqttTriggerRequestSchema,
	amqp: amqpTriggerRequestSchema,
	sqs: sqsTriggerRequestSchema,
	gcp: gcpTriggerRequestSchema,
	azure: azureTriggerRequestSchema,
} as const

const triggerPathSchema = z.string().min(1).describe("The unique Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path.")

export const createTriggerToolSchema = z.object({
	kind: z.enum([
		"http",
		"websocket",
		"kafka",
		"nats",
		"postgres",
		"mqtt",
		"amqp",
		"sqs",
		"gcp",
		"azure",
	]),
	path: triggerPathSchema,
	config: z.union([
		httpTriggerRequestSchema.omit({ path: true, script_path: true, is_flow: true }),
		websocketTriggerRequestSchema.omit({ path: true, script_path: true, is_flow: true }),
		kafkaTriggerRequestSchema.omit({ path: true, script_path: true, is_flow: true }),
		natsTriggerRequestSchema.omit({ path: true, script_path: true, is_flow: true }),
		postgresTriggerRequestSchema.omit({ path: true, script_path: true, is_flow: true }),
		mqttTriggerRequestSchema.omit({ path: true, script_path: true, is_flow: true }),
		amqpTriggerRequestSchema.omit({ path: true, script_path: true, is_flow: true }),
		sqsTriggerRequestSchema.omit({ path: true, script_path: true, is_flow: true }),
		gcpTriggerRequestSchema.omit({ path: true, script_path: true, is_flow: true }),
		azureTriggerRequestSchema.omit({ path: true, script_path: true, is_flow: true }),
	])
})
