Line data Source code
1 : // This file is auto-generated by @hey-api/openapi-ts
2 :
3 : import * as z from 'zod'
4 :
5 : import type { CccPublicationCondition } from './types.gen'
6 :
7 : /**
8 : * Response returned after successfully accepting a workspace invitation.
9 : */
10 2356 : export const zAcceptInviteResponse = z.object({
11 : workspace_id: z.string(),
12 : workspace_name: z.string()
13 : })
14 :
15 : /**
16 : * The auto top-up settings a purchase was accepted with, echoed so checkout and its done state show exactly what turns on. Present only on a purchase sent with auto_top_up.
17 : */
18 2356 : export const zAcceptedAutoTopUpSettings = z.object({
19 : monthly_budget_cents: z.coerce
20 : .bigint()
21 : .min(BigInt('-9223372036854775808'), {
22 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
23 : })
24 : .max(BigInt('9223372036854775807'), {
25 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
26 : }),
27 : monthly_budget_is_default: z.boolean(),
28 : target_credits: z.coerce
29 : .bigint()
30 : .min(BigInt('-9223372036854775808'), {
31 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
32 : })
33 : .max(BigInt('9223372036854775807'), {
34 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
35 : }),
36 : threshold_credits: z.coerce
37 : .bigint()
38 : .min(BigInt('-9223372036854775808'), {
39 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
40 : })
41 : .max(BigInt('9223372036854775807'), {
42 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
43 : })
44 : })
45 :
46 : /**
47 : * Returned when a request to run the agent is declined before the turn starts, because of a billing or account condition on the workspace. The `error` object carries a `message` you can show the user, a `type` that matches the HTTP status, and a more specific `reason` you can branch on to offer the right next step.
48 : */
49 2356 : export const zAgentAdmissionError = z.object({
50 : error: z.object({
51 : message: z.string(),
52 : reason: z.enum(['no_funds', 'manual_block', 'funds_unavailable']),
53 : type: z.enum(['PAYMENT_REQUIRED', 'SERVICE_UNAVAILABLE'])
54 : })
55 : })
56 :
57 : /**
58 : * Acknowledgement that the ask is answered and the parked turn was woken; its continuation streams over the WebSocket. `selected` and `other_text` are the answer committed to the ask row. The first answer wins: when an earlier request already committed one (a retry, or another tab), this carries THAT answer, not the request body, so compare it with what you sent before showing it as the user's choice.
59 : */
60 2356 : export const zAgentAnswerAccepted = z.object({
61 : other_text: z.string().optional(),
62 : selected: z.array(z.string()),
63 : status: z.enum(['answered'])
64 : })
65 :
66 : /**
67 : * The user's answer to a pending ask_user prompt. `selected` holds the chosen option ids; a permission gate answers with one id (e.g. the Approve/Deny option). `other_text` carries a free-text answer when the ask set allow_other.
68 : */
69 2356 : export const zAgentAnswerRequest = z.object({
70 : other_text: z.string().optional(),
71 : selected: z.array(z.string())
72 : })
73 :
74 : /**
75 : * Which card renders an ask. `ask_user` is the generic prompt raised by the ask_user tool. `run_approval` is the run consent card raised when the caller's ask_approval run mode gates a run: exactly the Run and Cancel options, never free text. `paused` is the admission pause card: one Resume option, never free text. `delete_approval` is the delete consent card for nodes the user made: exactly the Delete and Keep options, never free text. The same value is the agent_ask event's `kind`, the message list's `pending_ask.kind`, and an entry of `ask_kinds` on the message POST.
76 : */
77 2356 : export const zAgentAskKind = z.enum([
78 : 'ask_user',
79 : 'run_approval',
80 : 'paused',
81 : 'delete_approval'
82 : ])
83 :
84 : /**
85 : * One node a `delete_approval` ask names, read from the turn's workflow.
86 : */
87 2356 : export const zAgentAskNodeRef = z.object({
88 : id: z.string(),
89 : title: z.string().optional(),
90 : type: z.string().optional()
91 : })
92 :
93 2356 : export const zAgentAskOption = z.object({
94 : description: z.string().optional(),
95 : id: z.string(),
96 : label: z.string()
97 : })
98 :
99 : /**
100 : * How an ask left pending, as stored on the ask row. `answered` means an answer was committed and delivered to the turn; `cancelled` means the turn ended, was stopped, or could not take the answer; `expired` means the ask timed out. There is no "unknown" status: when an answer request fails with a 5xx the client does not know the outcome and should wait for agent_ask_resolved or refetch the thread.
101 : */
102 2356 : export const zAgentAskStatus = z.enum(['answered', 'cancelled', 'expired'])
103 :
104 : /**
105 : * 409 from the answer route: the ask is no longer pending, or its turn is gone so the answer can never be delivered. `status`, `selected` and `other_text` report the outcome stored on the ask row when the server knows it, with the same rules as the agent_ask_resolved event.
106 : */
107 2356 : export const zAgentAskConflict = z.object({
108 : error: z.string(),
109 : other_text: z.string().optional(),
110 : selected: z.array(z.string()).nullish(),
111 : status: zAgentAskStatus.optional()
112 : })
113 :
114 : /**
115 : * The `data` of an agent_ask_resolved WebSocket event: the outcome the server committed to the ask row. Every open tab gets the same frame, including tabs that did not send the answer, so a client reads the answer that won from here and never infers it from what it sent.
116 : */
117 2356 : export const zAgentAskResolvedData = z.object({
118 : ask_id: z.string(),
119 : message_id: z.string(),
120 : other_text: z.string().optional(),
121 : selected: z.array(z.string()).nullable(),
122 : status: zAgentAskStatus,
123 : thread_id: z.string()
124 : })
125 :
126 : /**
127 : * Server-to-client agent_ask_resolved frame on /ws. An ask left pending.
128 : */
129 2356 : export const zAgentAskResolvedFrame = z.object({
130 : data: zAgentAskResolvedData,
131 : type: z.enum(['agent_ask_resolved'])
132 : })
133 :
134 2356 : export const zAgentAttachmentBoundsExceeded = z.object({
135 : error: z.string(),
136 : limits: z.object({
137 : max_item_length: z.int(),
138 : max_items: z.int()
139 : }),
140 : overlong_ref: z.string(),
141 : received_count: z.int(),
142 : type: z.enum(['ATTACHMENT_BOUNDS_EXCEEDED'])
143 : })
144 :
145 : /**
146 : * Acknowledgement that a turn cancellation was requested. Cancellation is asynchronous; the terminal message state (status=error with stop copy) arrives over the WebSocket.
147 : */
148 2356 : export const zAgentCancelAccepted = z.object({
149 : status: z.enum(['cancelling'])
150 : })
151 :
152 : /**
153 : * A stop whose cancellation request did not land, or could not be confirmed as landed, on the durable engine. The turn is unaffected and still streaming, so the same request may be retried; cancellation is idempotent per turn. Distinct from the 500, which means the failure was one the service could not classify and a retry may never work.
154 : */
155 2356 : export const zAgentCancelUnconfirmed = z.object({
156 : code: z.enum(['cancel_not_requested', 'cancel_outcome_unknown']),
157 : error: z.string(),
158 : retryable: z.boolean()
159 : })
160 :
161 : /**
162 : * Consent to the in-app Agent panel. `true` is the only value that can be written — consent is revoked by DELETE, not by writing `false`, so the audit trail records a revocation rather than a value flip.
163 : */
164 2356 : export const zAgentConsentSettingValue = z.object({
165 : key: z.enum(['Comfy.AgentPanel.ConsentAccepted']),
166 : value: z.literal(true)
167 : })
168 :
169 : /**
170 : * The `context` of a `delete_approval` ask: the user-made nodes the agent's delete would remove. The server always lists at least one node, and lists at most 50; any more are counted in `hidden_node_count`, so the card can say how many it did not list.
171 : */
172 2356 : export const zAgentDeleteApprovalContext = z.object({
173 : action: z.enum(['delete_nodes']),
174 : hidden_node_count: z.int().gte(1).optional(),
175 : nodes: z.array(zAgentAskNodeRef).min(1).max(50)
176 : })
177 :
178 : /**
179 : * Authoritative snapshot of a workflow's agent draft — a snapshot for recovery and tooling.
180 : */
181 2356 : export const zAgentDraftSnapshot = z.object({
182 : content: z.record(z.string(), z.unknown()),
183 : version: z.int()
184 : })
185 :
186 : /**
187 : * Error body authored by the comfy-agent service and proxied verbatim through ingest. Errors raised by ingest itself (authentication, an unreachable agent service) use the standard ErrorResponse shape instead.
188 : */
189 2356 : export const zAgentError = z.object({
190 : code: z.string().optional(),
191 : error: z.string(),
192 : kind: z.enum(['unauthenticated', 'not_provisioned']).optional()
193 : })
194 :
195 : /**
196 : * The `data` of an agent_extension_changed WebSocket event. The local agent sends it after turning a custom node pack on or off, or removing it. The change is already on disk; dropping the event loses only the informational card.
197 : */
198 2356 : export const zAgentExtensionChangedData = z.object({
199 : action: z.enum(['enabled', 'disabled', 'removed']),
200 : agent_created: z.boolean(),
201 : message_id: z.string(),
202 : pack: z.string().min(1),
203 : restart_required: z.boolean(),
204 : thread_id: z.string()
205 : })
206 :
207 : /**
208 : * Server-to-client agent_extension_changed frame on /ws.
209 : */
210 2356 : export const zAgentExtensionChangedFrame = z.object({
211 : data: zAgentExtensionChangedData,
212 : type: z.enum(['agent_extension_changed'])
213 : })
214 :
215 : /**
216 : * The (workspace, user) the agent service attributes the caller's requests to.
217 : */
218 2356 : export const zAgentIdentity = z.object({
219 : user_id: z.string(),
220 : workspace_id: z.string()
221 : })
222 :
223 : /**
224 : * Anthropic-shaped error envelope on POST /api/agent/llm/v1/messages, written by the agent's LLM proxy or passed through from Anthropic.
225 : */
226 2356 : export const zAgentLlmError = z.object({
227 : error: z.object({
228 : message: z.string(),
229 : reason: z.string().optional(),
230 : type: z.string()
231 : }),
232 : type: z.enum(['error'])
233 : })
234 :
235 : /**
236 : * An explicit exact model selection. Unknown properties are refused with 400 so a newer intent is never silently ignored by an older server.
237 : */
238 2356 : export const zAgentModelSelection = z.object({
239 : model_id: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:\/-]{0,127}$/),
240 : option_id: z.string().optional()
241 : })
242 :
243 : /**
244 : * The immutable model selection receipt for an accepted turn.
245 : */
246 2356 : export const zAgentModelReceipt = z.object({
247 : contract: z.enum(['v1']),
248 : model_id: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:\/-]{0,127}$/),
249 : profile_revision: z.string(),
250 : requested: zAgentModelSelection.nullable(),
251 : source: z.enum(['request', 'deployment_default']),
252 : strategy: z.enum(['anthropic']),
253 : wire: z.enum(['anthropic_messages', 'openai_chat'])
254 : })
255 :
256 2356 : export const zAgentModelUnavailable = zAgentError.and(
257 : z.object({
258 : code: z.enum(['model_unavailable'])
259 : })
260 : )
261 :
262 : /**
263 : * The `context` of a `paused` ask.
264 : */
265 2356 : export const zAgentPausedContext = z.object({
266 : message: z.string(),
267 : reason: z.string(),
268 : recheck_after_seconds: z.int()
269 : })
270 :
271 : /**
272 : * The fields every pending ask carries, whatever its kind.
273 : */
274 2356 : export const zAgentPendingAskBase = z.object({
275 : allow_other: z.boolean(),
276 : ask_id: z.string(),
277 : kind: zAgentAskKind,
278 : max_selections: z.int(),
279 : message_id: z.string(),
280 : min_selections: z.int(),
281 : options: z.array(zAgentAskOption),
282 : prompt: z.string()
283 : })
284 :
285 : /**
286 : * A pending `ask_user` prompt. It carries no context.
287 : */
288 2356 : export const zAgentPendingAskUser = zAgentPendingAskBase.and(
289 : z.object({
290 : kind: z.enum(['ask_user'])
291 : })
292 : )
293 :
294 : /**
295 : * A pending `delete_approval` consent card.
296 : */
297 2356 : export const zAgentPendingDeleteApproval = zAgentPendingAskBase.and(
298 : z.object({
299 : context: zAgentDeleteApprovalContext,
300 : kind: z.enum(['delete_approval'])
301 : })
302 : )
303 :
304 : /**
305 : * A pending `paused` admission card.
306 : */
307 2356 : export const zAgentPendingPaused = zAgentPendingAskBase.and(
308 : z.object({
309 : context: zAgentPausedContext,
310 : kind: z.enum(['paused'])
311 : })
312 : )
313 :
314 : /**
315 : * A user turn posted to the agent.
316 : */
317 2356 : export const zAgentPostMessageRequest = z.object({
318 : ask_kinds: z.array(zAgentAskKind).optional(),
319 : attachments: z.array(z.string().max(256)).max(25).optional(),
320 : client_id: z.string().optional(),
321 : client_message_id: z.string().max(128).optional(),
322 : client_version: z.string().optional(),
323 : content: z.string(),
324 : current_tab: z.string().optional(),
325 : current_tab_unbound: z.boolean().optional(),
326 : draft: z
327 : .object({
328 : content: z.record(z.string(), z.unknown()).optional()
329 : })
330 : .optional(),
331 : model_selection: zAgentModelSelection.optional(),
332 : open_tabs: z
333 : .array(
334 : z.object({
335 : name: z.string().optional(),
336 : workflow_id: z.string()
337 : })
338 : )
339 : .optional(),
340 : selection: z.record(z.string(), z.unknown()).optional(),
341 : workflow_id: z.string().optional(),
342 : workflow_references: z
343 : .array(
344 : z.object({
345 : name: z.string().optional(),
346 : workflow_id: z.string()
347 : })
348 : )
349 : .optional()
350 : })
351 :
352 : /**
353 : * Attachment extensions the agent can only describe from metadata. A subset of the containers
354 : * ingest sorts into a load node's video/audio lists: that categoriser also accepts .wmv, .flv,
355 : * .aac and .wma, which the agreed attachment list rejects.
356 : *
357 : */
358 2356 : export const zAgentProbeableAttachmentExtension = z.enum([
359 : '.mp4',
360 : '.webm',
361 : '.mov',
362 : '.m4v',
363 : '.avi',
364 : '.mkv',
365 : '.mp3',
366 : '.wav',
367 : '.ogg',
368 : '.opus',
369 : '.flac',
370 : '.m4a'
371 : ])
372 :
373 : /**
374 : * Attachment extensions whose contents the agent reads verbatim, with read_asset. The bytes
375 : * are decoded as UTF-8 and returned as text, bounded and truncation-marked.
376 : *
377 : * This tier describes CONTENT ACCESS only and says nothing about whether the file can be
378 : * wired into a graph. Those are separate questions, so a format becoming a node input later
379 : * does not move it out of this tier.
380 : *
381 : * .svg is here rather than with the images because it is XML: view_asset cannot decode it,
382 : * but its markup is exactly what a caller would want read.
383 : *
384 : */
385 2356 : export const zAgentReadableAttachmentExtension = z.enum([
386 : '.md',
387 : '.markdown',
388 : '.txt',
389 : '.json',
390 : '.csv',
391 : '.yaml',
392 : '.yml',
393 : '.xml',
394 : '.log',
395 : '.svg'
396 : ])
397 :
398 : /**
399 : * Attachment extensions the agent cannot open but wires into a load node by filename. The 3D
400 : * models go into Load3D's model_file widget and are exactly the set Load3D accepts
401 : * (comfy_extras/nodes_load_3d.py); .usdz is absent from both lists, so it is not an exclusion
402 : * this tier makes. .exr goes into LoadImage's image widget: ComfyUI core v0.40.0 registers it
403 : * as an image type, but it is HDR, so view_asset cannot decode it and it is not on the view
404 : * tier.
405 : *
406 : */
407 2356 : export const zAgentReferenceAttachmentExtension = z.enum([
408 : '.glb',
409 : '.obj',
410 : '.fbx',
411 : '.gltf',
412 : '.stl',
413 : '.ply',
414 : '.spz',
415 : '.splat',
416 : '.ksplat',
417 : '.exr'
418 : ])
419 :
420 : /**
421 : * Attachment extensions that are accepted so a user can keep them beside a workflow, and
422 : * nothing more — the agent can neither read the contents nor wire the file in.
423 : *
424 : * .avif is the only one: it is an image the turn cannot decode (no registry entry, so
425 : * view_asset would fail) and it is not text, so read_asset would return mojibake. It stays
426 : * accepted because it was attachable before the policy existed.
427 : *
428 : */
429 2356 : export const zAgentRetainedAttachmentExtension = z.enum(['.avif'])
430 :
431 : /**
432 : * The `context` of a `run_approval` ask. It names the workflow and, for cards opened by content-binding builds, the exact canonical graph the user approved. Older in-flight cards may omit graph_binding; consumers must preserve that explicit legacy compatibility case.
433 : */
434 2356 : export const zAgentRunApprovalContext = z.object({
435 : doc_seq: z.coerce
436 : .bigint()
437 : .gte(BigInt(1))
438 : .max(BigInt('9223372036854775807'), {
439 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
440 : })
441 : .optional(),
442 : graph_binding: z.enum(['sha256', 'identity_only', 'unavailable']).optional(),
443 : graph_sha256: z
444 : .string()
445 : .regex(/^[0-9a-f]{64}$/)
446 : .optional(),
447 : workflow_id: z.string(),
448 : workflow_name: z.string().optional()
449 : })
450 :
451 : /**
452 : * A pending `run_approval` consent card.
453 : */
454 2356 : export const zAgentPendingRunApproval = zAgentPendingAskBase.and(
455 : z.object({
456 : context: zAgentRunApprovalContext,
457 : kind: z.enum(['run_approval'])
458 : })
459 : )
460 :
461 : /**
462 : * An unanswered ask attached to its assistant message, so a reload rehydrates the prompt from the ROW rather than from the agent_ask WebSocket event the client missed. Present only while the ask is pending; answer it via POST /agent/threads/{id}/asks/{ask_id}/answer. Discriminated on `kind`: narrowing on it gives the kind's `context` schema. The agent_ask WebSocket event's `data` is this same shape plus `thread_id`.
463 : */
464 2356 : export const zAgentPendingAsk = z.union([
465 : z
466 : .object({
467 : kind: z.literal('ask_user')
468 : })
469 : .and(zAgentPendingAskUser),
470 : z
471 : .object({
472 : kind: z.literal('run_approval')
473 : })
474 : .and(zAgentPendingRunApproval),
475 : z
476 : .object({
477 : kind: z.literal('paused')
478 : })
479 : .and(zAgentPendingPaused),
480 : z
481 : .object({
482 : kind: z.literal('delete_approval')
483 : })
484 : .and(zAgentPendingDeleteApproval)
485 : ])
486 :
487 : /**
488 : * Server-to-client agent_ask frame on /ws. A turn is parked on this ask.
489 : */
490 2356 : export const zAgentAskFrame = z.object({
491 : data: zAgentPendingAsk.and(
492 : z.object({
493 : thread_id: z.string()
494 : })
495 : ),
496 : type: z.enum(['agent_ask'])
497 : })
498 :
499 : /**
500 : * The ask frames the server sends on /ws, discriminated on `type`.
501 : */
502 2356 : export const zAgentAskServerFrame = z.union([
503 : zAgentAskFrame,
504 : zAgentAskResolvedFrame
505 : ])
506 :
507 : /**
508 : * How the agent may spend the caller's credits by running workflows from chat. The saved choice, or the default (ask_approval, no limit) for a caller who never chose.
509 : */
510 2356 : export const zAgentRunMode = z.object({
511 : credit_limit: z.int().gte(1).lte(2147483647).nullable(),
512 : mode: z.enum(['ask_approval', 'auto', 'auto_limited'])
513 : })
514 :
515 : /**
516 : * The run mode to save.
517 : */
518 2356 : export const zAgentRunModePutRequest = z.object({
519 : credit_limit: z.int().gte(1).lte(2147483647).nullish(),
520 : mode: z.enum(['ask_approval', 'auto', 'auto_limited'])
521 : })
522 :
523 : /**
524 : * One of the caller's user-authored skill packs.
525 : */
526 2356 : export const zAgentSkill = z.object({
527 : body: z.string(),
528 : body_hash: z.string(),
529 : created_at: z.string(),
530 : description: z.string(),
531 : id: z.string(),
532 : name: z.string(),
533 : updated_at: z.string()
534 : })
535 :
536 : /**
537 : * The caller's skill packs, ordered by name.
538 : */
539 2356 : export const zAgentSkillListResponse = z.object({
540 : skills: z.array(zAgentSkill)
541 : })
542 :
543 : /**
544 : * A user-authored skill pack to create or replace. Plain JSON — a pack body is small enough that a signed-URL upload would be pure overhead.
545 : */
546 2356 : export const zAgentSkillPublishRequest = z.object({
547 : always: z.boolean().optional().default(false),
548 : body: z.string(),
549 : description: z.string().max(1024),
550 : name: z
551 : .string()
552 : .max(64)
553 : .regex(/^[A-Za-z0-9._-]*[A-Za-z0-9_-][A-Za-z0-9._-]*$/)
554 : })
555 :
556 : /**
557 : * One model round's thinking as persisted on an assistant message's content.thinking (services/agent/internal/loop.persistedThinking): the round's reasoning text, then its narration, scrubbed exactly as the live agent_thinking frames were. Display data only.
558 : */
559 2356 : export const zAgentThinkingEntry = z.object({
560 : text: z.string(),
561 : tool_call_id: z.string().optional(),
562 : truncated: z.boolean().optional()
563 : })
564 :
565 : /**
566 : * Optional body for creating an agent thread.
567 : */
568 2356 : export const zAgentThreadCreateRequest = z.object({
569 : workflow_id: z.string().optional()
570 : })
571 :
572 : /**
573 : * Result of creating an agent thread.
574 : */
575 2356 : export const zAgentThreadCreated = z.object({
576 : thread_id: z.string()
577 : })
578 :
579 : /**
580 : * One agent thread row for the history sidebar.
581 : */
582 2356 : export const zAgentThreadSummary = z.object({
583 : created_at: z.string(),
584 : id: z.string(),
585 : last_message_at: z.string(),
586 : message_count: z.int().gte(0),
587 : preview: z.string(),
588 : status: z.enum(['active', 'archived']),
589 : title: z.string(),
590 : updated_at: z.string(),
591 : workflow_id: z.string()
592 : })
593 :
594 : /**
595 : * The `data` of an agent_tool_call WebSocket event: one tool invocation's lifecycle. Mirrors `$defs.agent_tool_call.data` in services/agent/api/agent_events.schema.json, which also states the presence rules: the document correlation fields appear only on a terminal (success or error) frame, workflow_id and op_ids appear together, doc_seq and doc_lineage_seq appear together and only with both of them, and job_id and job_workflow_id appear together only on a terminal run frame when a job was submitted. This schema leaves those rules out on purpose. A oneOf over closed variants could express them, but it would turn the generated frontend type into a union the consumer cannot extend field by field. The producer enforces them instead: the Publisher omits incomplete correlation, and TestToolCallEmissionsSatisfyBothContracts validates every emitted shape against the canonical schema. Consumers treat correlation as advisory and use it only when workflow_id and op_ids are both present on a terminal frame. TestToolCallFrameMatchesContract holds the two definitions to the same fields and constraints.
596 : */
597 2356 : export const zAgentToolCallData = z.object({
598 : doc_lineage_seq: z.int().gte(1).optional(),
599 : doc_seq: z.int().gte(1).optional(),
600 : duration_ms: z.int().optional(),
601 : error_code: z.string().optional(),
602 : job_id: z
603 : .string()
604 : .min(1)
605 : .max(128)
606 : .regex(/^[^\x00\n\r\t]+$/)
607 : .optional(),
608 : job_workflow_id: z.string().min(1).optional(),
609 : message_id: z.string(),
610 : op_ids: z
611 : .array(
612 : z
613 : .string()
614 : .min(1)
615 : .max(128)
616 : .regex(/^[^\x00\n\r\t]+$/)
617 : )
618 : .min(1)
619 : .max(256)
620 : .optional(),
621 : skill: z.string().optional(),
622 : status: z.enum(['running', 'success', 'error']),
623 : thread_id: z.string(),
624 : tool_call_id: z.string(),
625 : tool_name: z.string(),
626 : workflow_id: z.string().min(1).optional()
627 : })
628 :
629 : /**
630 : * Server-to-client agent_tool_call frame on /ws. A tool invocation started or reached a terminal state. Closed, like the canonical envelope.
631 : */
632 2356 : export const zAgentToolCallFrame = z.object({
633 : data: zAgentToolCallData,
634 : type: z.enum(['agent_tool_call'])
635 : })
636 :
637 : /**
638 : * Acknowledgement that a turn was accepted. The agent runs asynchronously; output streams over the WebSocket (agent_message_delta, agent_tool_call, agent_message_done); canvas edits arrive as doc_update frames. The model selection receipt is present when the backend supports its configured wire. A client that requested selection must treat a missing receipt as selection not applied.
639 : */
640 2356 : export const zAgentTurnAccepted = z.object({
641 : message_id: z.string(),
642 : model_selection: zAgentModelReceipt.optional(),
643 : thread_id: z.string()
644 : })
645 :
646 : /**
647 : * Present on agent_message_done only when the model service refused the turn. Mirrors `$defs.agent_message_done.data.refusal` in services/agent/api/agent_events.schema.json, which states the full rendering rules. Absence must not be read as the account having credit.
648 : */
649 2356 : export const zAgentTurnRefusal = z.object({
650 : can_add_credit: z.boolean(),
651 : kind: z.enum([
652 : 'no_funds',
653 : 'manual_block',
654 : 'payment_required',
655 : 'auth',
656 : 'rate_limit'
657 : ]),
658 : reason: z.string().optional()
659 : })
660 :
661 : /**
662 : * Usage of a completed turn, as carried on agent_message_done. Mirrors `$defs.agent_message_done.data.usage` in services/agent/api/agent_events.schema.json; TestMessageDoneFrameMatchesContract holds the two definitions to the same fields and constraints. charge_micro_usd appears only when the server durably captured priced billing for at least one round. It is the exact charge in millionths of a US dollar; clients convert that denomination to catalog credits for display and must not read its absence as a zero charge. On a local-agent turn it is the proxy-reported lower bound, and priced_rounds / unpriced_rounds count the rounds that did and did not report a price.
663 : */
664 2356 : export const zAgentTurnUsage = z.object({
665 : cache_creation_input_tokens: z.int().gte(0),
666 : cache_read_input_tokens: z.int().gte(0),
667 : charge_micro_usd: z.int().gte(1).optional(),
668 : input_tokens: z.int().gte(0),
669 : output_tokens: z.int().gte(0),
670 : priced_rounds: z.int().gte(0).optional(),
671 : total_tokens: z.int().gte(0),
672 : unpriced_rounds: z.int().gte(0).optional()
673 : })
674 :
675 : /**
676 : * The `data` of an agent_message_done WebSocket event: the assistant message is complete. Mirrors `$defs.agent_message_done.data` in services/agent/api/agent_events.schema.json.
677 : */
678 2356 : export const zAgentMessageDoneData = z.object({
679 : message_id: z.string(),
680 : refusal: zAgentTurnRefusal.optional(),
681 : thread_id: z.string(),
682 : usage: zAgentTurnUsage.nullable()
683 : })
684 :
685 : /**
686 : * Server-to-client agent_message_done frame on /ws. Closed, like the canonical envelope.
687 : */
688 2356 : export const zAgentMessageDoneFrame = z.object({
689 : data: zAgentMessageDoneData,
690 : type: z.enum(['agent_message_done'])
691 : })
692 :
693 2356 : export const zAgentUsageStatusResponse = z.object({
694 : has_used_agent: z.boolean()
695 : })
696 :
697 : /**
698 : * Attachment extensions whose content the model can see: the raster formats Go's image
699 : * package decodes, plus HEIC/HEIF stills (iPhone photos), which view_asset converts to JPEG
700 : * first. view_asset always re-encodes to PNG or JPEG, so the provider's own four-type image
701 : * allowlist is satisfied by construction rather than by matching this list.
702 : *
703 : */
704 2356 : export const zAgentViewableAttachmentExtension = z.enum([
705 : '.png',
706 : '.jpg',
707 : '.jpeg',
708 : '.gif',
709 : '.webp',
710 : '.bmp',
711 : '.tif',
712 : '.tiff',
713 : '.heic',
714 : '.heif'
715 : ])
716 :
717 : /**
718 : * Every extension the agent accepts as an attachment, grouped by what it can actually DO with
719 : * one. The grouping is the point: the tiers differ sharply, and a client that renders them as
720 : * one flat "supported files" list tells the user something false (PM-1855).
721 : *
722 : * - `view`: the model sees the content. view_asset decodes the still (converting HEIC/HEIF to
723 : * JPEG first) and re-encodes it as PNG/JPEG into the turn, so the model reasons about actual
724 : * pixels.
725 : * - `probe`: metadata only. probe_media reports duration, resolution, frame rate and codecs;
726 : * nothing in the model's input can carry a clip, so the CONTENT stays unreadable. Seeing a
727 : * video means cutting a frame out with process_media and viewing that.
728 : * - `reference`: the agent knows what the file is, with its kind and id, and wires its
729 : * filename into the load node that takes it: a 3D model into a Load3D node's model_file
730 : * widget, an .exr into a LoadImage node's image widget. No tool opens the file itself: the
731 : * cloud turn registers neither a shell nor a file-read tool, by design, as it is a shared
732 : * multi-tenant pod, and view_asset cannot decode an EXR.
733 : * - `read`: the agent reads the contents verbatim with read_asset — UTF-8 decoded, bounded
734 : * and truncation-marked. The tier describes CONTENT ACCESS only; whether the file can also
735 : * be wired into a graph is a separate axis, so a format gaining an upload-backed node input
736 : * later stays in this tier.
737 : * - `retain`: the file is attached and nothing more — neither readable nor wirable. Only
738 : * .avif, which the turn cannot decode as an image and is not text.
739 : *
740 : * The union of the five arrays is the accepted list. Anything absent is rejected.
741 : *
742 : */
743 2356 : export const zAgentAttachmentPolicy = z.object({
744 : probe: z.array(zAgentProbeableAttachmentExtension),
745 : read: z.array(zAgentReadableAttachmentExtension),
746 : reference: z.array(zAgentReferenceAttachmentExtension),
747 : retain: z.array(zAgentRetainedAttachmentExtension),
748 : view: z.array(zAgentViewableAttachmentExtension)
749 : })
750 :
751 : /**
752 : * 422 body when a posted attachment's extension is outside the accepted list. It carries the
753 : * policy rather than only an error string so a client never has to hardcode the list to
754 : * explain the refusal — the same reason the list is expressed as enums the frontend generates
755 : * its types from.
756 : *
757 : */
758 2356 : export const zAgentAttachmentRejected = z.object({
759 : accepted: zAgentAttachmentPolicy,
760 : error: z.string(),
761 : rejected: z.array(z.string()),
762 : rejected_count: z.int(),
763 : type: z.enum(['ATTACHMENT_TYPE_NOT_ACCEPTED'])
764 : })
765 :
766 2356 : export const zAgentAttachmentError = z.discriminatedUnion('type', [
767 : zAgentAttachmentRejected.extend({
768 : type: z.literal('ATTACHMENT_TYPE_NOT_ACCEPTED')
769 : }),
770 : zAgentAttachmentBoundsExceeded.extend({
771 : type: z.literal('ATTACHMENT_BOUNDS_EXCEEDED')
772 : })
773 : ])
774 :
775 : /**
776 : * Represents a user-owned asset (image, video, or other generated output).
777 : */
778 2356 : export const zAsset = z.object({
779 : created_at: z.iso.datetime(),
780 : display_name: z.string().nullish(),
781 : file_path: z.string().nullish(),
782 : hash: z
783 : .string()
784 : .regex(/^blake3:[a-f0-9]{64}$/)
785 : .optional(),
786 : id: z.uuid(),
787 : is_immutable: z.boolean().optional(),
788 : job_id: z.uuid().nullish(),
789 : last_access_time: z.iso.datetime().optional(),
790 : loader_path: z.string().nullish(),
791 : metadata: z.record(z.string(), z.unknown()).readonly().optional(),
792 : mime_type: z.string().optional(),
793 : name: z.string(),
794 : preview_id: z.uuid().nullish(),
795 : preview_url: z.url().optional(),
796 : short_url: z.string().nullish(),
797 : size: z.coerce
798 : .bigint()
799 : .min(BigInt('-9223372036854775808'), {
800 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
801 : })
802 : .max(BigInt('9223372036854775807'), {
803 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
804 : })
805 : .optional(),
806 : tags: z.array(z.string()).optional(),
807 : updated_at: z.iso.datetime(),
808 : user_metadata: z.record(z.string(), z.unknown()).optional()
809 : })
810 :
811 : /**
812 : * Response returned when a new asset is successfully created.
813 : */
814 2356 : export const zAssetCreated = zAsset.and(
815 : z.object({
816 : created_new: z.boolean()
817 : })
818 : )
819 :
820 : /**
821 : * Acknowledgement of an async asset download task; clients poll GET /api/tasks/{task_id} for status.
822 : */
823 2356 : export const zAssetDownloadResponse = z.object({
824 : message: z.string().optional(),
825 : status: z.enum(['created', 'running', 'completed', 'failed', 'cancelled']),
826 : task_id: z.uuid()
827 : })
828 :
829 : /**
830 : * Lightweight asset reference used in workflow publishing payloads.
831 : */
832 2356 : export const zAssetInfo = z.object({
833 : id: z.string(),
834 : in_library: z.boolean(),
835 : model: z.boolean(),
836 : name: z.string(),
837 : preview_url: z.string(),
838 : public: z.boolean(),
839 : storage_url: z.string()
840 : })
841 :
842 : /**
843 : * Histogram of tag counts used for refining asset search results.
844 : */
845 2356 : export const zAssetTagHistogramResponse = z.object({
846 : tag_counts: z.record(z.string(), z.int())
847 : })
848 :
849 : /**
850 : * Response returned when an existing asset is successfully updated.
851 : */
852 2356 : export const zAssetUpdated = z.object({
853 : display_name: z.string().nullish(),
854 : file_path: z.string().nullish(),
855 : hash: z
856 : .string()
857 : .regex(/^blake3:[a-f0-9]{64}$/)
858 : .optional(),
859 : id: z.uuid(),
860 : job_id: z.uuid().nullish(),
861 : loader_path: z.string().nullish(),
862 : mime_type: z.string().optional(),
863 : name: z.string().optional(),
864 : tags: z.array(z.string()).optional(),
865 : updated_at: z.iso.datetime(),
866 : user_metadata: z.record(z.string(), z.unknown()).optional()
867 : })
868 :
869 : /**
870 : * 403 for a credential the route does not take. `accepted` names the ones it does, as `WWW-Authenticate` does.
871 : */
872 2356 : export const zAuthTypeNotAllowedError = z.object({
873 : accepted: z.array(z.string()),
874 : error: z.object({
875 : message: z.string(),
876 : type: z.enum(['auth_type_not_allowed'])
877 : })
878 : })
879 :
880 2356 : export const zAuthenticateRefusal = z.object({
881 : code: z.string(),
882 : message: z.string(),
883 : organization_id: z.string().optional(),
884 : start_url: z.string().optional()
885 : })
886 :
887 2356 : export const zAuthenticateRequest = z.object({
888 : email: z.string().max(320),
889 : password: z.string().max(4096).optional()
890 : })
891 :
892 2356 : export const zAuthenticateResponse = z.object({
893 : expires_in: z.int().optional(),
894 : method: z.enum(['sso', 'password', 'session', 'firebase']),
895 : organization_name: z.string().optional(),
896 : start_url: z.string().optional()
897 : })
898 :
899 : /**
900 : * Expiry of the default card. Carries no identifier.
901 : */
902 2356 : export const zAutoReloadCardExpiry = z.object({
903 : expired: z.boolean(),
904 : month: z.int().gte(1).lte(12),
905 : year: z.int().gte(1000).lte(9999)
906 : })
907 :
908 : /**
909 : * Display facts about a declined payment method. Carries no identifier.
910 : */
911 2356 : export const zAutoReloadDeclinedPaymentMethod = z.object({
912 : brand: z.string().nullable(),
913 : last4: z.string().nullable(),
914 : type: z.string()
915 : })
916 :
917 : /**
918 : * Estimated automatic charge for the proposed settings.
919 : */
920 2356 : export const zAutoReloadPreview = z.object({
921 : balance_after_credits: z.coerce
922 : .bigint()
923 : .min(BigInt('-9223372036854775808'), {
924 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
925 : })
926 : .max(BigInt('9223372036854775807'), {
927 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
928 : })
929 : .nullish(),
930 : capped: z.boolean().optional(),
931 : charge_cents: z.coerce
932 : .bigint()
933 : .min(BigInt('-9223372036854775808'), {
934 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
935 : })
936 : .max(BigInt('9223372036854775807'), {
937 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
938 : })
939 : .nullable(),
940 : charge_credits: z.coerce
941 : .bigint()
942 : .min(BigInt('-9223372036854775808'), {
943 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
944 : })
945 : .max(BigInt('9223372036854775807'), {
946 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
947 : })
948 : .nullable(),
949 : charges_now: z.boolean(),
950 : monthly_budget_remaining_cents: z.coerce
951 : .bigint()
952 : .min(BigInt('-9223372036854775808'), {
953 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
954 : })
955 : .max(BigInt('9223372036854775807'), {
956 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
957 : })
958 : .optional(),
959 : not_charging_reason: z
960 : .enum(['above_threshold', 'monthly_budget', 'paused_by_decline'])
961 : .nullable()
962 : })
963 :
964 : /**
965 : * billing-api's automatic top-up settings, server prices and automatic
966 : * spend this cycle, passed through unchanged. Credits are whole credits;
967 : * amounts are US cents. When `configured` is false, `enabled` is false
968 : * and the other setting fields are null.
969 : *
970 : */
971 2356 : export const zAutoReloadSettings = z.object({
972 : auto_top_up_conflict: z.boolean(),
973 : card_expiring_soon: z.boolean().nullish(),
974 : card_expiry: zAutoReloadCardExpiry.nullable(),
975 : configured: z.boolean(),
976 : cycle_resets_at: z.iso.datetime().nullable(),
977 : declined_payment_method: zAutoReloadDeclinedPaymentMethod.nullable(),
978 : disabled_reason: z.string().nullable(),
979 : enabled: z.boolean(),
980 : last_failure_at: z.iso.datetime().nullable(),
981 : last_failure_reason: z.string().nullable(),
982 : max_monthly_budget_cents: z.coerce
983 : .bigint()
984 : .min(BigInt('-9223372036854775808'), {
985 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
986 : })
987 : .max(BigInt('9223372036854775807'), {
988 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
989 : }),
990 : max_reload_credits: z.coerce
991 : .bigint()
992 : .min(BigInt('-9223372036854775808'), {
993 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
994 : })
995 : .max(BigInt('9223372036854775807'), {
996 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
997 : })
998 : .nullable(),
999 : min_reload_credits: z.coerce
1000 : .bigint()
1001 : .min(BigInt('-9223372036854775808'), {
1002 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1003 : })
1004 : .max(BigInt('9223372036854775807'), {
1005 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1006 : }),
1007 : monthly_budget_cents: z.coerce
1008 : .bigint()
1009 : .min(BigInt('-9223372036854775808'), {
1010 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1011 : })
1012 : .max(BigInt('9223372036854775807'), {
1013 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1014 : })
1015 : .nullable(),
1016 : monthly_budget_is_default: z.boolean(),
1017 : paused_by_budget: z.boolean(),
1018 : paused_by_budget_remainder: z.boolean(),
1019 : paused_by_decline: z.boolean(),
1020 : reload_amount_cents: z.coerce
1021 : .bigint()
1022 : .min(BigInt('-9223372036854775808'), {
1023 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1024 : })
1025 : .max(BigInt('9223372036854775807'), {
1026 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1027 : })
1028 : .nullable(),
1029 : reload_credits: z.coerce
1030 : .bigint()
1031 : .min(BigInt('-9223372036854775808'), {
1032 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1033 : })
1034 : .max(BigInt('9223372036854775807'), {
1035 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1036 : })
1037 : .nullable(),
1038 : spent_this_cycle_cents: z.coerce
1039 : .bigint()
1040 : .min(BigInt('-9223372036854775808'), {
1041 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1042 : })
1043 : .max(BigInt('9223372036854775807'), {
1044 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1045 : }),
1046 : status: z.enum(['failed', 'off', 'on_hold', 'paused_by_budget', 'on']),
1047 : target_credits: z.coerce
1048 : .bigint()
1049 : .min(BigInt('-9223372036854775808'), {
1050 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1051 : })
1052 : .max(BigInt('9223372036854775807'), {
1053 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1054 : })
1055 : .nullable(),
1056 : threshold_credits: z.coerce
1057 : .bigint()
1058 : .min(BigInt('-9223372036854775808'), {
1059 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1060 : })
1061 : .max(BigInt('9223372036854775807'), {
1062 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1063 : })
1064 : .nullable()
1065 : })
1066 :
1067 : /**
1068 : * Every listed field is required, and one of target_credits or
1069 : * reload_credits. reload_credits alone means target_credits =
1070 : * threshold_credits + reload_credits. On every save, disabled included,
1071 : * threshold_credits must be a positive whole number of credits and a
1072 : * non-null monthly_budget_cents positive. When enabled is true:
1073 : * target_credits must be greater than threshold_credits; target_credits
1074 : * and reload_credits must agree (reload_credits = target_credits -
1075 : * threshold_credits) when both are sent; a non-null monthly_budget_cents
1076 : * must be at most max_monthly_budget_cents, and a null one means no
1077 : * owner limit and is stored as max_monthly_budget_cents; target_credits
1078 : * must be at least threshold_credits + min_reload_credits and at most
1079 : * threshold_credits + max_reload_credits; and the smallest automatic
1080 : * reload (from one credit below threshold_credits to target_credits)
1081 : * must cost no more than the budget. A save with enabled false accepts a
1082 : * null budget, stores it as null, and skips the enabled-only rules. A
1083 : * save with enabled false is never refused over target_credits or
1084 : * reload_credits: it stores target_credits minus threshold_credits when
1085 : * the target is above the threshold, else a positive reload_credits,
1086 : * else min_reload_credits.
1087 : *
1088 : */
1089 2356 : export const zAutoReloadSettingsRequest = z.object({
1090 : enabled: z.boolean(),
1091 : monthly_budget_cents: z.coerce
1092 : .bigint()
1093 : .min(BigInt('-9223372036854775808'), {
1094 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1095 : })
1096 : .max(BigInt('9223372036854775807'), {
1097 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1098 : })
1099 : .nullable(),
1100 : reload_credits: z.coerce
1101 : .bigint()
1102 : .min(BigInt('-9223372036854775808'), {
1103 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1104 : })
1105 : .max(BigInt('9223372036854775807'), {
1106 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1107 : })
1108 : .optional(),
1109 : target_credits: z.coerce
1110 : .bigint()
1111 : .min(BigInt('-9223372036854775808'), {
1112 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1113 : })
1114 : .max(BigInt('9223372036854775807'), {
1115 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1116 : })
1117 : .optional(),
1118 : threshold_credits: z.coerce
1119 : .bigint()
1120 : .min(BigInt('-9223372036854775808'), {
1121 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1122 : })
1123 : .max(BigInt('9223372036854775807'), {
1124 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1125 : })
1126 : })
1127 :
1128 : /**
1129 : * Did auto top-up turn on with a purchase sent with auto_top_up; absent otherwise, so absence is not "off". pending: payment or activation has not finished; keep polling. on: on with auto_top_up's settings. failed: payment and credits stand but auto top-up did not turn on; send the owner to set it up in Billing. not_attempted: the payment did not succeed (or the checkout expired). Not the current status; read GET /api/billing/auto-reload.
1130 : */
1131 2356 : export const zAutoTopUpActivation = z.enum([
1132 : 'pending',
1133 : 'on',
1134 : 'failed',
1135 : 'not_attempted'
1136 : ])
1137 :
1138 : /**
1139 : * Only when auto_top_up_activation is failed. An auto_top_up_setup reason (GET /api/billing/capabilities) or activation_error. For support and analytics, not copy.
1140 : */
1141 2356 : export const zAutoTopUpActivationReason = z.string()
1142 :
1143 : /**
1144 : * Read-only auto top-up display for non-owner workspace members. Omitted when unavailable, hidden, or unsupported by an older server; keep the member discoverability notice as the fallback. Never grants management access and contains no limit amounts, spending or payment details.
1145 : */
1146 2356 : export const zAutoTopUpMemberView = z.object({
1147 : cycle_resets_at: z.iso.datetime().nullable(),
1148 : disabled_reason: z.enum(['consecutive_declines']).optional(),
1149 : monthly_budget_is_default: z.boolean(),
1150 : status: z.enum(['off', 'on', 'on_hold', 'paused_by_budget', 'failed']),
1151 : target_credits: z.coerce
1152 : .bigint()
1153 : .min(BigInt('-9223372036854775808'), {
1154 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1155 : })
1156 : .max(BigInt('9223372036854775807'), {
1157 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1158 : })
1159 : .nullable(),
1160 : threshold_credits: z.coerce
1161 : .bigint()
1162 : .min(BigInt('-9223372036854775808'), {
1163 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1164 : })
1165 : .max(BigInt('9223372036854775807'), {
1166 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1167 : })
1168 : .nullable()
1169 : })
1170 :
1171 : /**
1172 : * Recorded account setup guidance, separate from owner authority in
1173 : * can_manage_auto_top_up. Frozen prevents enabling/editing; unavailable
1174 : * means setup is not available. Owner read/disable authority remains separate.
1175 : * These states do not determine surface visibility. Unified billing settings
1176 : * show the auto top-up card only when capabilities.can_view_auto_top_up is
1177 : * true. Paused or payment-failed billing hides it; the manual-purchase
1178 : * switch does not.
1179 : * Ready does not authorize a charge or guarantee an off-session payment method.
1180 : * This fact ignores saved consent and monthly budget. An absent fact is unknown.
1181 : *
1182 : */
1183 2356 : export const zAutoTopUpSetup = z.object({
1184 : reason: z
1185 : .enum([
1186 : 'workspace_deleted',
1187 : 'workspace_blocked',
1188 : 'billing_not_provisioned',
1189 : 'billing_rail_not_supported',
1190 : 'billing_status_unrecognized',
1191 : 'payment_past_due',
1192 : 'billing_paused',
1193 : 'billing_awaiting_payment_method',
1194 : 'billing_payment_pending',
1195 : 'subscription_tier_unrecognized',
1196 : 'subscription_status_unrecognized',
1197 : 'subscription_state_unknown',
1198 : 'billing_operation_parked',
1199 : 'default_payment_method_missing',
1200 : 'default_payment_method_unsupported',
1201 : 'creator_only_provisioning'
1202 : ])
1203 : .optional(),
1204 : state: z.enum(['ready', 'frozen', 'unavailable'])
1205 : })
1206 :
1207 : /**
1208 : * A billing address for a company Stripe customer. city and postal_code
1209 : * are optional because some countries (e.g. Hong Kong, the UAE, Panama)
1210 : * have no postal code and are not collected for them; Stripe validates
1211 : * what a given country actually requires.
1212 : *
1213 : */
1214 2356 : export const zBillingAddress = z.object({
1215 : city: z.string().optional(),
1216 : country: z.string(),
1217 : line1: z.string(),
1218 : line2: z.string().optional(),
1219 : postal_code: z.string().optional(),
1220 : state: z.string().optional()
1221 : })
1222 :
1223 : /**
1224 : * Conservative UI guidance. These values do not authorize billing writes;
1225 : * each write endpoint independently enforces its permission policy.
1226 : *
1227 : * Each field answers one UI question for the authenticated user in the
1228 : * authenticated workspace. Render each as received and never combine fields
1229 : * into a new decision. False without a matching key in denied_reasons means no
1230 : * recognised explanation, not necessarily a refusal. A field is never
1231 : * per-surface: one value serves every screen. The plan-lifecycle fields
1232 : * (can_subscribe_self_serve, can_cancel, can_reactivate,
1233 : * can_revert_scheduled_change) require the workspace's creator only when the
1234 : * rollout mode is not `owner`; every other owner-level field stays open to
1235 : * every owner.
1236 : *
1237 : * When the deployment has billing disabled, this endpoint answers without
1238 : * consulting billing-api: can_top_up is true; can_manage_members,
1239 : * can_invite_members, can_manage_subscription, can_manage_auto_top_up and
1240 : * can_view_auto_top_up follow the owner role, and
1241 : * can_view_auto_top_up_member_notice is true for a non-owner. Other billing-action fields are false. These role
1242 : * facts do not promise that billing endpoints are available.
1243 : *
1244 : */
1245 2356 : export const zBillingCapabilities = z.object({
1246 : can_cancel: z.boolean(),
1247 : can_change_seats: z.boolean(),
1248 : can_delete_workspace: z.boolean(),
1249 : can_downgrade_to_personal: z.boolean(),
1250 : can_edit_workspace: z.boolean(),
1251 : can_invite_members: z.boolean(),
1252 : can_leave_workspace: z.boolean(),
1253 : can_manage_auto_top_up: z.boolean(),
1254 : can_manage_billing: z.boolean(),
1255 : can_manage_members: z.boolean(),
1256 : can_manage_partner_node_access: z.boolean(),
1257 : can_manage_subscription: z.boolean(),
1258 : can_open_plans: z.boolean(),
1259 : can_reactivate: z.boolean(),
1260 : can_revert_scheduled_change: z.boolean(),
1261 : can_run_workflows: z.boolean(),
1262 : can_set_budgets: z.boolean(),
1263 : can_set_hard_caps: z.boolean(),
1264 : can_subscribe_self_serve: z.boolean(),
1265 : can_top_up: z.boolean(),
1266 : can_upgrade: z.boolean(),
1267 : can_view_auto_top_up: z.boolean(),
1268 : can_view_auto_top_up_member_notice: z.boolean(),
1269 : can_view_own_usage: z.boolean().optional(),
1270 : can_view_pending_invites: z.boolean(),
1271 : can_view_team_usage: z.boolean()
1272 : })
1273 :
1274 : /**
1275 : * Why a capability resolved false, keyed by the capability. The value
1276 : * names the policy branch that decided, not customer-facing wording: the
1277 : * client owns the message.
1278 : *
1279 : * How to read this: render each capability from `capabilities` as received, and
1280 : * use a reason only to explain a capability that is false. Never recombine
1281 : * capabilities or reasons into a new decision, and never derive a reason from
1282 : * tier, role, status or plan slug. A missing reason is not a grant. A refused
1283 : * capability usually has a key here naming the branch that refused it. A false
1284 : * capability with no matching key is an unexplained refusal: no recognised
1285 : * explanation, still false. A true capability never has a key.
1286 : * Within a key the values are listed in the order the resolver reaches them,
1287 : * and the first one reached is the one reported. Capabilities are UI guidance,
1288 : * not authorization: the write endpoints decide.
1289 : *
1290 : * The invariant runs one way only. **Presence implies refusal**: a key is
1291 : * present only alongside `capabilities.<key> == false`, reconciled before
1292 : * the response is built, so a reason never accompanies a granted
1293 : * capability. **Absence implies nothing**: on a false capability it
1294 : * means no recognised explanation, and on a true capability it is the
1295 : * expected state. Consult `capabilities`, which stays authoritative for what
1296 : * the client may offer.
1297 : *
1298 : * A key is absent for a refused capability whenever this service is
1299 : * talking to a billing-api that predates the field, and whenever it drops
1300 : * a reason it does not recognise rather than forwarding a value outside
1301 : * the enum below. Both are supported states, so a client must never infer
1302 : * a capability's value from a missing reason -- only from `capabilities`.
1303 : *
1304 : * This endpoint omits the entire `denied_reasons` object when no recognised
1305 : * reason survives. The billing-api endpoint may emit `{}` for the same
1306 : * logical state, so object presence must not be used to detect support.
1307 : *
1308 : */
1309 2356 : export const zBillingCapabilityDenials = z.object({
1310 : can_cancel: z
1311 : .enum([
1312 : 'not_a_member',
1313 : 'not_workspace_owner',
1314 : 'not_original_owner',
1315 : 'free_plan',
1316 : 'no_subscription',
1317 : 'tier_not_self_serve',
1318 : 'billing_operation_in_progress',
1319 : 'billing_operation_parked',
1320 : 'cancellation_scheduled',
1321 : 'subscription_ended',
1322 : 'subscription_not_started',
1323 : 'subscription_status_unrecognized'
1324 : ])
1325 : .optional(),
1326 : can_change_seats: z
1327 : .enum([
1328 : 'not_a_member',
1329 : 'not_workspace_owner',
1330 : 'no_subscription',
1331 : 'tier_not_self_serve',
1332 : 'subscription_ended',
1333 : 'subscription_not_started',
1334 : 'subscription_status_unrecognized'
1335 : ])
1336 : .optional(),
1337 : can_delete_workspace: z
1338 : .enum([
1339 : 'not_a_member',
1340 : 'sales_managed_plan',
1341 : 'not_workspace_owner',
1342 : 'not_original_owner',
1343 : 'workspace_sso_attached',
1344 : 'personal_workspace',
1345 : 'billing_operation_in_progress',
1346 : 'billing_operation_parked',
1347 : 'plan_not_ended',
1348 : 'plan_ending'
1349 : ])
1350 : .optional(),
1351 : can_downgrade_to_personal: z
1352 : .enum([
1353 : 'not_a_member',
1354 : 'not_workspace_owner',
1355 : 'not_original_owner',
1356 : 'no_subscription',
1357 : 'tier_not_self_serve',
1358 : 'subscription_change_in_progress',
1359 : 'subscription_ended',
1360 : 'subscription_not_started',
1361 : 'subscription_status_unrecognized',
1362 : 'rollout_disabled'
1363 : ])
1364 : .optional(),
1365 : can_edit_workspace: z
1366 : .enum(['not_a_member', 'not_workspace_owner'])
1367 : .optional(),
1368 : can_invite_members: z
1369 : .enum(['not_a_member', 'not_workspace_owner', 'invite_capacity_reached'])
1370 : .optional(),
1371 : can_leave_workspace: z
1372 : .enum([
1373 : 'not_a_member',
1374 : 'membership_managed_by_directory',
1375 : 'personal_workspace_creator',
1376 : 'workspace_creator',
1377 : 'only_owner'
1378 : ])
1379 : .optional(),
1380 : can_manage_auto_top_up: z
1381 : .enum(['not_a_member', 'not_workspace_owner'])
1382 : .optional(),
1383 : can_manage_billing: z
1384 : .enum(['not_a_member', 'not_workspace_owner', 'creator_only_provisioning'])
1385 : .optional(),
1386 : can_manage_members: z
1387 : .enum(['not_a_member', 'not_workspace_owner'])
1388 : .optional(),
1389 : can_manage_partner_node_access: z
1390 : .enum([
1391 : 'not_a_member',
1392 : 'not_workspace_owner',
1393 : 'partner_governance_not_entitled'
1394 : ])
1395 : .optional(),
1396 : can_manage_subscription: z
1397 : .enum(['not_a_member', 'not_workspace_owner'])
1398 : .optional(),
1399 : can_open_plans: z
1400 : .enum([
1401 : 'not_a_member',
1402 : 'not_workspace_owner',
1403 : 'not_original_owner',
1404 : 'creator_only_provisioning',
1405 : 'tier_not_self_serve',
1406 : 'subscription_not_started',
1407 : 'subscription_status_unrecognized'
1408 : ])
1409 : .optional(),
1410 : can_reactivate: z
1411 : .enum([
1412 : 'not_a_member',
1413 : 'not_workspace_owner',
1414 : 'not_original_owner',
1415 : 'no_subscription',
1416 : 'tier_not_self_serve',
1417 : 'billing_operation_in_progress',
1418 : 'billing_operation_parked',
1419 : 'cancellation_not_scheduled',
1420 : 'subscription_ended',
1421 : 'subscription_not_started',
1422 : 'subscription_status_unrecognized'
1423 : ])
1424 : .optional(),
1425 : can_revert_scheduled_change: z
1426 : .enum([
1427 : 'not_a_member',
1428 : 'not_workspace_owner',
1429 : 'not_original_owner',
1430 : 'tier_not_self_serve',
1431 : 'subscription_ended',
1432 : 'subscription_not_started',
1433 : 'subscription_status_unrecognized',
1434 : 'no_revertible_scheduled_change'
1435 : ])
1436 : .optional(),
1437 : can_run_workflows: z
1438 : .enum([
1439 : 'manual_block',
1440 : 'subscription_inactive',
1441 : 'payment_past_due',
1442 : 'no_funds',
1443 : 'workspace_cap_exceeded',
1444 : 'project_cap_exceeded',
1445 : 'user_cap_exceeded',
1446 : 'free_tier_exhausted'
1447 : ])
1448 : .optional(),
1449 : can_set_budgets: z
1450 : .enum([
1451 : 'not_a_member',
1452 : 'not_workspace_owner',
1453 : 'creator_only_provisioning',
1454 : 'no_subscription',
1455 : 'free_plan',
1456 : 'subscription_ended',
1457 : 'subscription_not_started',
1458 : 'subscription_status_unrecognized'
1459 : ])
1460 : .optional(),
1461 : can_set_hard_caps: z
1462 : .enum([
1463 : 'not_a_member',
1464 : 'not_workspace_owner',
1465 : 'creator_only_provisioning',
1466 : 'no_subscription',
1467 : 'free_plan',
1468 : 'subscription_ended',
1469 : 'subscription_not_started',
1470 : 'subscription_status_unrecognized',
1471 : 'plan_not_enterprise'
1472 : ])
1473 : .optional(),
1474 : can_subscribe_self_serve: z
1475 : .enum([
1476 : 'not_a_member',
1477 : 'not_workspace_owner',
1478 : 'not_original_owner',
1479 : 'creator_only_provisioning',
1480 : 'tier_not_self_serve',
1481 : 'subscription_change_in_progress',
1482 : 'subscription_not_started',
1483 : 'subscription_status_unrecognized'
1484 : ])
1485 : .optional(),
1486 : can_top_up: z
1487 : .enum([
1488 : 'not_a_member',
1489 : 'not_workspace_owner',
1490 : 'creator_only_provisioning',
1491 : 'payment_past_due',
1492 : 'tier_not_self_serve',
1493 : 'subscription_status_unrecognized',
1494 : 'topup_purchases_paused',
1495 : 'free_plan',
1496 : 'no_subscription',
1497 : 'subscription_ended'
1498 : ])
1499 : .optional(),
1500 : can_upgrade: z
1501 : .enum([
1502 : 'not_a_member',
1503 : 'not_workspace_owner',
1504 : 'not_original_owner',
1505 : 'creator_only_provisioning',
1506 : 'tier_not_self_serve',
1507 : 'subscription_change_in_progress',
1508 : 'subscription_not_started',
1509 : 'subscription_status_unrecognized',
1510 : 'billing_state_unknown',
1511 : 'no_subscription',
1512 : 'subscription_ended',
1513 : 'payment_past_due',
1514 : 'billing_operation_parked',
1515 : 'billing_operation_in_progress',
1516 : 'sales_managed',
1517 : 'no_upgrade_available'
1518 : ])
1519 : .optional(),
1520 : can_view_auto_top_up: z
1521 : .enum([
1522 : 'not_a_member',
1523 : 'not_workspace_owner',
1524 : 'creator_only_provisioning',
1525 : 'payment_past_due',
1526 : 'tier_not_self_serve',
1527 : 'subscription_status_unrecognized',
1528 : 'topup_purchases_paused'
1529 : ])
1530 : .optional(),
1531 : can_view_auto_top_up_member_notice: z
1532 : .enum([
1533 : 'not_a_member',
1534 : 'workspace_owner',
1535 : 'payment_past_due',
1536 : 'tier_not_self_serve',
1537 : 'subscription_status_unrecognized',
1538 : 'topup_purchases_paused'
1539 : ])
1540 : .optional(),
1541 : can_view_own_usage: z
1542 : .enum(['not_a_member', 'usage_attribution_unavailable'])
1543 : .optional(),
1544 : can_view_pending_invites: z
1545 : .enum(['not_a_member', 'not_workspace_owner'])
1546 : .optional(),
1547 : can_view_team_usage: z
1548 : .enum([
1549 : 'not_a_member',
1550 : 'not_workspace_owner',
1551 : 'usage_attribution_unavailable'
1552 : ])
1553 : .optional()
1554 : })
1555 :
1556 : /**
1557 : * Identifies capability values currently using safe rollout defaults
1558 : * instead of deterministic policy results. A true value is UI guidance,
1559 : * not evidence that the corresponding write will succeed.
1560 : *
1561 : */
1562 2356 : export const zBillingCapabilityRolloutDefaults = z.object({
1563 : can_downgrade_to_personal: z.boolean(),
1564 : can_subscribe_self_serve: z.boolean(),
1565 : can_top_up: z.boolean()
1566 : })
1567 :
1568 2356 : export const zBillingCapabilityScope = z.object({
1569 : user_id: z.string(),
1570 : workspace_id: z.string()
1571 : })
1572 :
1573 : /**
1574 : * A single history event. The cloud history-events store is the single source of truth for both billing events (charges, credits, adjustments) and user-facing usage events.
1575 : */
1576 2356 : export const zBillingEvent = z.object({
1577 : api_key_name: z.string().optional(),
1578 : api_key_prefix: z.string().optional(),
1579 : api_key_revoked: z.boolean().optional(),
1580 : createdAt: z.iso.datetime(),
1581 : deployment_id: z.string().optional(),
1582 : deployment_name: z.string().optional(),
1583 : event_id: z.string(),
1584 : event_type: z.string(),
1585 : member_display_name: z.string().optional(),
1586 : member_email: z.string().optional(),
1587 : member_former: z.boolean().optional(),
1588 : member_user_id: z.string().optional(),
1589 : params: z.record(z.string(), z.unknown()).optional(),
1590 : unattributed: z.boolean().optional()
1591 : })
1592 :
1593 : /**
1594 : * Paginated list of billing events for a workspace.
1595 : */
1596 2356 : export const zBillingEventsResponse = z.object({
1597 : attribution_since: z.iso.datetime().optional(),
1598 : events: z.array(zBillingEvent),
1599 : limit: z.int(),
1600 : page: z.int(),
1601 : total: z.int(),
1602 : totalPages: z.int()
1603 : })
1604 :
1605 : /**
1606 : * Asks for a one-time handoff that signs a billing receiver tab in as the caller.
1607 : */
1608 2356 : export const zBillingHandoffCreateRequest = z.object({
1609 : amount_cents: z.coerce
1610 : .bigint()
1611 : .gte(BigInt(500))
1612 : .lte(BigInt(250000))
1613 : .optional(),
1614 : client_version: z.string().max(64),
1615 : intent: z.enum(['top-up', 'subscription']).optional(),
1616 : receiver: z.enum(['billing_web', 'platform']),
1617 : surface: z.enum(['local_web', 'desktop']),
1618 : workspace_id: z.string().min(1)
1619 : })
1620 :
1621 : /**
1622 : * An issued handoff. The token is single use and expires within 60 seconds.
1623 : */
1624 2356 : export const zBillingHandoffCreateResponse = z.object({
1625 : entry_url: z.string(),
1626 : expires_at: z.iso.datetime(),
1627 : request_id: z.string()
1628 : })
1629 :
1630 : /**
1631 : * The handoff token a receiver read from its URL fragment.
1632 : */
1633 2356 : export const zBillingHandoffExchangeRequest = z.object({
1634 : token: z.string().min(1).max(128)
1635 : })
1636 :
1637 : /**
1638 : * The user a scoped billing session acts as.
1639 : */
1640 2356 : export const zBillingHandoffUser = z.object({
1641 : email: z.string(),
1642 : id: z.string()
1643 : })
1644 :
1645 : /**
1646 : * The workspace a scoped billing session is bound to.
1647 : */
1648 2356 : export const zBillingHandoffWorkspace = z.object({
1649 : id: z.string(),
1650 : name: z.string(),
1651 : type: z.string()
1652 : })
1653 :
1654 : /**
1655 : * A scoped billing session for the handoff's user and workspace.
1656 : */
1657 2356 : export const zBillingHandoffExchangeResponse = z.object({
1658 : expires_at: z.iso.datetime(),
1659 : role: z.enum(['owner', 'member']),
1660 : session_token: z.string(),
1661 : user: zBillingHandoffUser,
1662 : workspace: zBillingHandoffWorkspace
1663 : })
1664 :
1665 2356 : export const zBillingOpCancelResponse = z.object({
1666 : billing_op_id: z.string(),
1667 : status: z.enum(['canceled', 'cancel_requested'])
1668 : })
1669 :
1670 : /**
1671 : * How a billing operation ended, for a billing handoff tab whose scoped session has ended.
1672 : */
1673 2356 : export const zBillingOpOutcomeResponse = z.object({
1674 : status: z.enum(['pending', 'succeeded', 'failed', 'reconciliation_needed'])
1675 : })
1676 :
1677 : /**
1678 : * Payment lifecycle status
1679 : */
1680 2356 : export const zBillingStatus = z.enum([
1681 : 'awaiting_payment_method',
1682 : 'pending_payment',
1683 : 'paid',
1684 : 'payment_failed',
1685 : 'paused',
1686 : 'inactive'
1687 : ])
1688 :
1689 : /**
1690 : * A tax identifier for a company Stripe customer. Stripe validates the
1691 : * type/value combination synchronously and verifies VAT/ABN-style IDs
1692 : * asynchronously.
1693 : *
1694 : */
1695 2356 : export const zBillingTaxId = z.object({
1696 : type: z.string(),
1697 : value: z.string()
1698 : })
1699 :
1700 : /**
1701 : * Company billing details on file for the workspace's Stripe customer.
1702 : * A field is absent until the workspace sets it via PATCH
1703 : * /api/billing/company-details.
1704 : *
1705 : */
1706 2356 : export const zBillingCompanyDetailsResponse = z.object({
1707 : address: zBillingAddress.optional(),
1708 : company_name: z.string().optional(),
1709 : tax_id: zBillingTaxId.optional()
1710 : })
1711 :
1712 : /**
1713 : * Fields to set on the workspace's Stripe customer. Every group is
1714 : * optional; omit a group to leave that part of the customer unchanged.
1715 : *
1716 : */
1717 2356 : export const zBillingCompanyDetailsUpdateRequest = z.object({
1718 : address: zBillingAddress.optional(),
1719 : company_name: z.string().optional(),
1720 : tax_id: zBillingTaxId.optional()
1721 : })
1722 :
1723 2356 : export const zBudgetAlert = z.object({
1724 : percent: z.int(),
1725 : sent_at: z.iso.datetime(),
1726 : status: z.string()
1727 : })
1728 :
1729 2356 : export const zBudgetChange = z.object({
1730 : action: z.enum(['created', 'updated', 'archived', 'downgraded']),
1731 : actor_user_id: z.string(),
1732 : after: z.record(z.string(), z.unknown()).nullable(),
1733 : before: z.record(z.string(), z.unknown()).nullable(),
1734 : changed_at: z.iso.datetime()
1735 : })
1736 :
1737 2356 : export const zBudgetHistory = z.object({
1738 : changes: z.array(zBudgetChange)
1739 : })
1740 :
1741 : /**
1742 : * `soft` alerts at its thresholds and never refuses spend. `hard` also refuses spend once the limit is reached; Enterprise plans only.
1743 : *
1744 : */
1745 2356 : export const zBudgetMode = z.enum(['hard', 'soft'])
1746 :
1747 : /**
1748 : * How long a budget applies. `current_period`: until the current billing period ends. `until`: through the period holding `ends_at`. `indefinitely`: every period, with no end.
1749 : *
1750 : */
1751 2356 : export const zBudgetRepeat = z.enum(['current_period', 'until', 'indefinitely'])
1752 :
1753 : /**
1754 : * What a budget limits.
1755 : */
1756 2356 : export const zBudgetScopeKind = z.enum([
1757 : 'workspace',
1758 : 'member',
1759 : 'api_key',
1760 : 'deployment'
1761 : ])
1762 :
1763 : /**
1764 : * A budget with its spend in the workspace's current billing period. Amounts come in credits and in micro-USD; a client shows credits as received and never converts.
1765 : *
1766 : */
1767 2356 : export const zBudget = z.object({
1768 : alert_percents: z.array(z.int()),
1769 : alerts: z.array(zBudgetAlert),
1770 : created_by: z.string(),
1771 : ends_at: z.iso.datetime().nullable(),
1772 : id: z.string(),
1773 : limit_credits: z.coerce
1774 : .bigint()
1775 : .min(BigInt('-9223372036854775808'), {
1776 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1777 : })
1778 : .max(BigInt('9223372036854775807'), {
1779 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1780 : }),
1781 : limit_micro_usd: z.coerce
1782 : .bigint()
1783 : .min(BigInt('-9223372036854775808'), {
1784 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1785 : })
1786 : .max(BigInt('9223372036854775807'), {
1787 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1788 : }),
1789 : mode: zBudgetMode,
1790 : percent_used: z.coerce
1791 : .bigint()
1792 : .min(BigInt('-9223372036854775808'), {
1793 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1794 : })
1795 : .max(BigInt('9223372036854775807'), {
1796 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1797 : }),
1798 : repeat: zBudgetRepeat,
1799 : resets_at: z.iso.datetime().nullable(),
1800 : scope_id: z.string(),
1801 : scope_kind: zBudgetScopeKind,
1802 : spend_updated_at: z.iso.datetime().nullable(),
1803 : spent_credits: z.coerce
1804 : .bigint()
1805 : .min(BigInt('-9223372036854775808'), {
1806 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1807 : })
1808 : .max(BigInt('9223372036854775807'), {
1809 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1810 : }),
1811 : spent_micro_usd: z.coerce
1812 : .bigint()
1813 : .min(BigInt('-9223372036854775808'), {
1814 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1815 : })
1816 : .max(BigInt('9223372036854775807'), {
1817 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1818 : }),
1819 : updated_by: z.string()
1820 : })
1821 :
1822 2356 : export const zBudgetCreateRequest = z.object({
1823 : alert_percents: z.array(z.int().gte(1).lte(100)).min(1).max(5).optional(),
1824 : ends_at: z.iso.datetime().optional(),
1825 : limit_credits: z.coerce
1826 : .bigint()
1827 : .min(BigInt('-9223372036854775808'), {
1828 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1829 : })
1830 : .max(BigInt('9223372036854775807'), {
1831 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1832 : })
1833 : .optional(),
1834 : limit_micro_usd: z.coerce
1835 : .bigint()
1836 : .min(BigInt('-9223372036854775808'), {
1837 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1838 : })
1839 : .max(BigInt('9223372036854775807'), {
1840 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1841 : })
1842 : .optional(),
1843 : mode: zBudgetMode,
1844 : repeat: zBudgetRepeat.optional(),
1845 : scope_id: z.string(),
1846 : scope_kind: zBudgetScopeKind
1847 : })
1848 :
1849 2356 : export const zBudgetList = z.object({
1850 : auto_top_up_conflict: z.boolean(),
1851 : budgets: z.array(zBudget)
1852 : })
1853 :
1854 2356 : export const zBudgetUpdateRequest = z.object({
1855 : alert_percents: z.array(z.int().gte(1).lte(100)).min(1).max(5).optional(),
1856 : ends_at: z.iso.datetime().optional(),
1857 : limit_credits: z.coerce
1858 : .bigint()
1859 : .min(BigInt('-9223372036854775808'), {
1860 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1861 : })
1862 : .max(BigInt('9223372036854775807'), {
1863 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1864 : })
1865 : .optional(),
1866 : limit_micro_usd: z.coerce
1867 : .bigint()
1868 : .min(BigInt('-9223372036854775808'), {
1869 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1870 : })
1871 : .max(BigInt('9223372036854775807'), {
1872 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1873 : })
1874 : .optional(),
1875 : mode: zBudgetMode.optional(),
1876 : repeat: zBudgetRepeat.optional()
1877 : })
1878 :
1879 2356 : export const zBudgetWriteResult = z.object({
1880 : auto_top_up_conflict: z.boolean(),
1881 : budget: zBudget
1882 : })
1883 :
1884 : /**
1885 : * Response after bulk-revoking API keys for a workspace member.
1886 : */
1887 2356 : export const zBulkRevokeApiKeysResponse = z.object({
1888 : revoked_count: z.int().gte(0)
1889 : })
1890 :
1891 2356 : export const zCccActivityPageRef = z.object({
1892 : slug: z.string(),
1893 : title: z.string(),
1894 : type: z.enum(['model', 'workflow', 'app']),
1895 : uid: z.uuid()
1896 : })
1897 :
1898 2356 : export const zCccActivityItem = z.object({
1899 : actor_uid: z.string(),
1900 : at: z.iso.datetime(),
1901 : catalog_status: z
1902 : .enum(['draft', 'published', 'reverted', 'archived'])
1903 : .optional(),
1904 : changed_fields: z.array(z.string()).max(50).optional(),
1905 : file_count: z.int().optional(),
1906 : is_deleted: z.boolean().optional(),
1907 : is_new: z.boolean().optional(),
1908 : kind: z.enum(['save', 'publish', 'discard', 'revert']),
1909 : page: zCccActivityPageRef.optional(),
1910 : page_count: z.int().optional(),
1911 : pages: z.array(zCccActivityPageRef).max(50).optional(),
1912 : previous_revision_uid: z.uuid().optional(),
1913 : restored_from: z.coerce
1914 : .bigint()
1915 : .min(BigInt('-9223372036854775808'), {
1916 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1917 : })
1918 : .max(BigInt('9223372036854775807'), {
1919 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1920 : })
1921 : .optional(),
1922 : restored_revision: z.coerce
1923 : .bigint()
1924 : .min(BigInt('-9223372036854775808'), {
1925 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1926 : })
1927 : .max(BigInt('9223372036854775807'), {
1928 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1929 : })
1930 : .optional(),
1931 : reverted: z.boolean().optional(),
1932 : reverted_revision: z.coerce
1933 : .bigint()
1934 : .min(BigInt('-9223372036854775808'), {
1935 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1936 : })
1937 : .max(BigInt('9223372036854775807'), {
1938 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1939 : })
1940 : .optional(),
1941 : revision: z.coerce
1942 : .bigint()
1943 : .min(BigInt('-9223372036854775808'), {
1944 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1945 : })
1946 : .max(BigInt('9223372036854775807'), {
1947 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1948 : })
1949 : .optional(),
1950 : revision_uid: z.uuid().optional()
1951 : })
1952 :
1953 2356 : export const zCccActivityPage = z.object({
1954 : has_more: z.boolean(),
1955 : items: z.array(zCccActivityItem).max(100),
1956 : last_publish: z
1957 : .object({
1958 : actor_uid: z.string(),
1959 : at: z.iso.datetime(),
1960 : reverted: z.boolean(),
1961 : revision: z.coerce
1962 : .bigint()
1963 : .min(BigInt('-9223372036854775808'), {
1964 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
1965 : })
1966 : .max(BigInt('9223372036854775807'), {
1967 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1968 : })
1969 : })
1970 : .nullable(),
1971 : next_cursor: z.string().max(256).optional()
1972 : })
1973 :
1974 2356 : export const zCccCatalogState = z.object({
1975 : draft_generation: z.coerce
1976 : .bigint()
1977 : .gte(BigInt(0))
1978 : .max(BigInt('9223372036854775807'), {
1979 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1980 : }),
1981 : draft_rev: z.coerce
1982 : .bigint()
1983 : .gte(BigInt(1))
1984 : .max(BigInt('9223372036854775807'), {
1985 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1986 : }),
1987 : live_rev: z.coerce
1988 : .bigint()
1989 : .gte(BigInt(1))
1990 : .max(BigInt('9223372036854775807'), {
1991 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1992 : }),
1993 : next_rev: z.coerce
1994 : .bigint()
1995 : .gte(BigInt(1))
1996 : .max(BigInt('9223372036854775807'), {
1997 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
1998 : }),
1999 : previous_live_rev: z.coerce
2000 : .bigint()
2001 : .gte(BigInt(1))
2002 : .max(BigInt('9223372036854775807'), {
2003 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2004 : })
2005 : .nullable()
2006 : })
2007 :
2008 2356 : export const zCccAuthoringContext = z.object({
2009 : actor_uid: z.string().min(1),
2010 : can_access_catalog: z.boolean(),
2011 : can_apply: z.boolean(),
2012 : can_edit: z.boolean(),
2013 : can_manage_users: z.boolean(),
2014 : can_transfer: z.boolean(),
2015 : owner_uid: z.string().min(1),
2016 : state: zCccCatalogState
2017 : })
2018 :
2019 2356 : export const zCccCheckedReviewReceipt = z.object({
2020 : publish_enabled: z.boolean(),
2021 : receipt_version: z.literal(1),
2022 : selected_count: z.int().gte(1).lte(5000),
2023 : selected_versions_digest: z.string().regex(/^[0-9a-f]{64}$/),
2024 : selection_digest: z.string().regex(/^[0-9a-f]{64}$/),
2025 : state: zCccCatalogState,
2026 : unchecked_count: z.int().gte(0).lte(5000)
2027 : })
2028 :
2029 2356 : export const zCccCreatorLink = z.object({
2030 : label: z.string(),
2031 : url: z.url()
2032 : })
2033 :
2034 2356 : export const zCccCreatorProfile = z.object({
2035 : avatar_url: z.string(),
2036 : bio: z.string().max(5000),
2037 : display_name: z.string(),
2038 : links: z.array(zCccCreatorLink).max(8),
2039 : username: z.string()
2040 : })
2041 :
2042 2356 : export const zCccCreatorSummary = z.object({
2043 : avatar_url: z.string(),
2044 : display_name: z.string(),
2045 : username: z.string(),
2046 : workflow_count: z.int().gte(1)
2047 : })
2048 :
2049 2356 : export const zCccCreatorsPage = z.object({
2050 : items: z.array(zCccCreatorSummary).max(100),
2051 : next_cursor: z.string().max(200).optional()
2052 : })
2053 :
2054 : /**
2055 : * Flat type-versioned CCC JSON. Domain schemas (/api/v1/catalog/schemas/{type}/{version}) constrain authored fields. The readOnly properties are server metadata returned by reads; a save may send them back unchanged and they are ignored, never applied. expected_draft_rev and expected_revision_uid are the save concurrency tokens.
2056 : */
2057 2356 : export const zCccjson = z.object({
2058 : catalog_rev: z.coerce
2059 : .bigint()
2060 : .min(BigInt('-9223372036854775808'), {
2061 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2062 : })
2063 : .max(BigInt('9223372036854775807'), {
2064 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2065 : })
2066 : .readonly()
2067 : .optional(),
2068 : creator_uid: z.string().readonly().optional(),
2069 : digest: z.string().readonly().optional(),
2070 : draft_generation: z.coerce
2071 : .bigint()
2072 : .min(BigInt('-9223372036854775808'), {
2073 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2074 : })
2075 : .max(BigInt('9223372036854775807'), {
2076 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2077 : })
2078 : .readonly()
2079 : .optional(),
2080 : edit_sequence: z.coerce
2081 : .bigint()
2082 : .min(BigInt('-9223372036854775808'), {
2083 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2084 : })
2085 : .max(BigInt('9223372036854775807'), {
2086 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2087 : })
2088 : .readonly()
2089 : .optional(),
2090 : is_deleted: z.boolean().readonly().optional(),
2091 : owner_uid: z.string().readonly().optional(),
2092 : revision_uid: z.uuid().readonly().optional(),
2093 : saved_at: z.iso.datetime().readonly().optional(),
2094 : saved_by_uid: z.string().readonly().optional(),
2095 : uid: z.uuid().readonly().optional()
2096 : })
2097 :
2098 : /**
2099 : * One immutable save: the flat CCCJSON read plus the status of the catalog revision that holds it and its save time.
2100 : */
2101 2356 : export const zCccHistoryItem = zCccjson.and(
2102 : z.object({
2103 : catalog_status: z.enum(['draft', 'published', 'reverted', 'archived']),
2104 : saved_at: z.iso.datetime()
2105 : })
2106 : )
2107 :
2108 : /**
2109 : * One page of save history, newest edit_sequence first. next_cursor is present only when has_more is true. There is no total.
2110 : */
2111 2356 : export const zCccHistoryPage = z.object({
2112 : has_more: z.boolean(),
2113 : items: z.array(zCccHistoryItem),
2114 : next_cursor: z.string().optional()
2115 : })
2116 :
2117 : /**
2118 : * Current Hub page that replaces an old public URL
2119 : */
2120 2356 : export const zCccLegacyTarget = z.object({
2121 : path: z.string(),
2122 : slug: z.string(),
2123 : type: z.enum(['workflow', 'app', 'model'])
2124 : })
2125 :
2126 2356 : export const zCccMediaConstraint = z.object({
2127 : max_bytes: z.coerce
2128 : .bigint()
2129 : .min(BigInt('-9223372036854775808'), {
2130 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2131 : })
2132 : .max(BigInt('9223372036854775807'), {
2133 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2134 : })
2135 : .optional(),
2136 : max_height: z.int().optional(),
2137 : max_width: z.int().optional(),
2138 : mime_type: z.string(),
2139 : min_bytes: z.coerce
2140 : .bigint()
2141 : .min(BigInt('-9223372036854775808'), {
2142 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2143 : })
2144 : .max(BigInt('9223372036854775807'), {
2145 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2146 : })
2147 : .optional()
2148 : })
2149 :
2150 : /**
2151 : * Matching pages per type. Every filter applies except types.
2152 : */
2153 2356 : export const zCccPageCounts = z.object({
2154 : app: z.int().gte(0),
2155 : model: z.int().gte(0),
2156 : workflow: z.int().gte(0)
2157 : })
2158 :
2159 : /**
2160 : * Card picture. Absent when the page has none, which is what missing=cover selects.
2161 : */
2162 2356 : export const zCccPagePreview = z.object({
2163 : kind: z.enum(['image', 'video']),
2164 : src: z.string()
2165 : })
2166 :
2167 : /**
2168 : * Display data for the row.
2169 : */
2170 2356 : export const zCccPagePresentation = z.object({
2171 : preview: zCccPagePreview.optional()
2172 : })
2173 :
2174 : /**
2175 : * One model, workflow or app page at its Draft head.
2176 : */
2177 2356 : export const zCccPageRow = z.object({
2178 : author_uid: z.string(),
2179 : description: z.string().max(1000),
2180 : enabled: z.boolean(),
2181 : has_draft_edits: z.boolean(),
2182 : has_live: z.boolean(),
2183 : held_until_start: z.boolean(),
2184 : is_deleted: z.boolean(),
2185 : on_desktop: z.boolean(),
2186 : on_hub: z.boolean(),
2187 : presentation: zCccPagePresentation,
2188 : revision_uid: z.uuid(),
2189 : saved_at: z.iso.datetime(),
2190 : saved_by_uid: z.string(),
2191 : slug: z.string().max(200),
2192 : status: z.enum([
2193 : 'removed',
2194 : 'not_live',
2195 : 'unpublished',
2196 : 'hidden',
2197 : 'scheduled',
2198 : 'live'
2199 : ]),
2200 : title: z.string().max(300),
2201 : type: z.enum(['model', 'workflow', 'app']),
2202 : uid: z.uuid(),
2203 : visibility: z.string().max(20),
2204 : visible_from: z.string().max(100)
2205 : })
2206 :
2207 : /**
2208 : * Live and Draft revisions this page was read from.
2209 : */
2210 2356 : export const zCccPagesState = z.object({
2211 : draft_generation: z.coerce
2212 : .bigint()
2213 : .min(BigInt('-9223372036854775808'), {
2214 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2215 : })
2216 : .max(BigInt('9223372036854775807'), {
2217 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2218 : }),
2219 : draft_rev: z.coerce
2220 : .bigint()
2221 : .min(BigInt('-9223372036854775808'), {
2222 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2223 : })
2224 : .max(BigInt('9223372036854775807'), {
2225 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2226 : }),
2227 : live_rev: z.coerce
2228 : .bigint()
2229 : .min(BigInt('-9223372036854775808'), {
2230 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2231 : })
2232 : .max(BigInt('9223372036854775807'), {
2233 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2234 : }),
2235 : next_rev: z.coerce
2236 : .bigint()
2237 : .min(BigInt('-9223372036854775808'), {
2238 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2239 : })
2240 : .max(BigInt('9223372036854775807'), {
2241 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2242 : }),
2243 : previous_live_rev: z.coerce
2244 : .bigint()
2245 : .min(BigInt('-9223372036854775808'), {
2246 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2247 : })
2248 : .max(BigInt('9223372036854775807'), {
2249 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2250 : })
2251 : .nullable()
2252 : })
2253 :
2254 : /**
2255 : * One page of the staff page list.
2256 : */
2257 2356 : export const zCccPagesPage = z.object({
2258 : as_of: z.iso.datetime(),
2259 : counts: zCccPageCounts,
2260 : has_more: z.boolean(),
2261 : items: z.array(zCccPageRow).max(100),
2262 : next_cursor: z.string().max(2048).optional(),
2263 : state: zCccPagesState
2264 : })
2265 :
2266 : /**
2267 : * Holds when field equals equals (a bool or string). if_absent decides when field is absent or null; a value of another shape holds.
2268 : */
2269 2356 : export const zCccPublicationCondition = z.object({
2270 : equals: z.unknown(),
2271 : field: z.string(),
2272 : if_absent: z
2273 : .lazy((): z.ZodType<CccPublicationCondition> => zCccPublicationCondition)
2274 : .optional()
2275 : })
2276 :
2277 : /**
2278 : * One publish-time field rule. Publish enforces required levels, media constraints and resolves_to references; recommended levels are advice only.
2279 : */
2280 2356 : export const zCccPublicationRule = z.object({
2281 : fields: z.array(z.string()).min(1),
2282 : level: z.enum(['required', 'recommended']).optional(),
2283 : media: zCccMediaConstraint.optional(),
2284 : message: z.string(),
2285 : resolves_to: z.string().optional(),
2286 : types: z
2287 : .array(z.enum(['model', 'workflow', 'app', 'template_set']))
2288 : .optional(),
2289 : when: zCccPublicationCondition.optional()
2290 : })
2291 :
2292 : /**
2293 : * One tag and the number of eligible model and workflow pages that carry it
2294 : */
2295 2356 : export const zCccSiteTagUsageItem = z.object({
2296 : count: z.int().gte(1),
2297 : tag: z.string().min(1)
2298 : })
2299 :
2300 : /**
2301 : * Every tag on the eligible hub model and workflow pages, most used first
2302 : */
2303 2356 : export const zCccSiteTagUsage = z.object({
2304 : generation: z.int(),
2305 : revision_id: z.int(),
2306 : tags: z.array(zCccSiteTagUsageItem).max(5000)
2307 : })
2308 :
2309 2356 : export const zCccStaffPermissions = z.object({
2310 : account_id: z.string().min(1).max(128),
2311 : avatar_url: z.string().max(4000).optional(),
2312 : can_edit: z.boolean(),
2313 : can_manage_users: z.boolean(),
2314 : can_publish: z.boolean(),
2315 : can_transfer: z.boolean(),
2316 : display_name: z.string().max(200).optional(),
2317 : updated_at: z.iso.datetime(),
2318 : updated_by: z.string(),
2319 : version: z.coerce.bigint().gte(BigInt(1)).max(BigInt('9223372036854775807'), {
2320 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2321 : })
2322 : })
2323 :
2324 2356 : export const zCccStagingMediaUse = z.object({
2325 : differs_from_head: z.boolean(),
2326 : file_version_uid: z.uuid().optional(),
2327 : is_deleted: z.boolean(),
2328 : mime_type: z.string().optional(),
2329 : name: z.string().optional(),
2330 : origin: z.boolean(),
2331 : slug: z.string().optional(),
2332 : title: z.string(),
2333 : type: z.enum(['model', 'workflow', 'app', 'template_set']),
2334 : uid: z.uuid()
2335 : })
2336 :
2337 2356 : export const zCccStagingPresentation = z.object({
2338 : media_name: z.string().optional(),
2339 : preview: z
2340 : .object({
2341 : kind: z.enum(['image', 'video']),
2342 : src: z.string()
2343 : })
2344 : .optional(),
2345 : uses: z.array(zCccStagingMediaUse).optional()
2346 : })
2347 :
2348 2356 : export const zCccStagingResource = z.object({
2349 : author_uid: z.string(),
2350 : document: z.object({
2351 : change_id: z.string().optional(),
2352 : enabled: z.boolean().optional(),
2353 : name: z.string().optional(),
2354 : provider: z.string().optional(),
2355 : slug: z.string().optional(),
2356 : title: z.string().optional(),
2357 : visibility: z.string().optional(),
2358 : visible_from: z.string().optional()
2359 : }),
2360 : is_deleted: z.boolean(),
2361 : revision_uid: z.uuid(),
2362 : saved_by_uid: z.string().optional(),
2363 : type: z.enum(['model', 'workflow', 'app', 'media', 'template_set']),
2364 : uid: z.uuid()
2365 : })
2366 :
2367 2356 : export const zCccStagingRow = z.object({
2368 : before: zCccStagingResource.optional(),
2369 : content: zCccStagingResource,
2370 : decision: z.enum(['NEW', 'APPROVED', 'DEFERRED', 'DELETED']),
2371 : presentation: zCccStagingPresentation.optional(),
2372 : saved_at: z.iso.datetime().optional(),
2373 : status: z.enum(['NEW', 'APPROVED', 'DEFERRED', 'DELETED']),
2374 : summary: z.string()
2375 : })
2376 :
2377 : /**
2378 : * Staging read. Page and selection rows are sparse; detail and the legacy read return full content.
2379 : */
2380 2356 : export const zCccStagingReview = z.object({
2381 : items: z.array(zCccStagingRow).max(5000).optional(),
2382 : representation: z.enum(['page', 'selection', 'detail']).optional(),
2383 : selection_digest: z.string().optional(),
2384 : state: zCccCatalogState.optional(),
2385 : unresolved_count: z.int().optional()
2386 : })
2387 :
2388 2356 : export const zCccTypeSchema = z.object({
2389 : contract_version: z.string(),
2390 : environment: z.string(),
2391 : format: z.enum(['openapi-3.0-schema']),
2392 : publication: z
2393 : .object({
2394 : rules: z.array(zCccPublicationRule)
2395 : })
2396 : .optional(),
2397 : schema: z.record(z.string(), z.unknown()),
2398 : schema_version: z.int(),
2399 : server_fields: z.array(z.string()).optional(),
2400 : type: z.enum(['model', 'workflow', 'app', 'template_set', 'media'])
2401 : })
2402 :
2403 2356 : export const zCccWebsiteCardFacet = z.object({
2404 : count: z.int().gte(0).optional(),
2405 : label: z.string(),
2406 : value: z.string()
2407 : })
2408 :
2409 2356 : export const zCccWebsiteCardFacets = z.object({
2410 : categories: z.array(zCccWebsiteCardFacet).max(100),
2411 : models: z.array(zCccWebsiteCardFacet).max(100),
2412 : use_cases: z.array(zCccWebsiteCardFacet).max(100)
2413 : })
2414 :
2415 2356 : export const zCccWebsiteModelDirectory = z.object({
2416 : generation: z.coerce
2417 : .bigint()
2418 : .min(BigInt('-9223372036854775808'), {
2419 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2420 : })
2421 : .max(BigInt('9223372036854775807'), {
2422 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2423 : })
2424 : .optional(),
2425 : items: z
2426 : .array(
2427 : z.object({
2428 : provider: z.string(),
2429 : slug: z.string(),
2430 : title: z.string(),
2431 : uid: z.uuid()
2432 : })
2433 : )
2434 : .max(5000),
2435 : revision_id: z.coerce
2436 : .bigint()
2437 : .min(BigInt('-9223372036854775808'), {
2438 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2439 : })
2440 : .max(BigInt('9223372036854775807'), {
2441 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2442 : })
2443 : })
2444 :
2445 2356 : export const zCccWebsiteRootPageInfo = z.object({
2446 : has_more: z.boolean(),
2447 : page_size: z.literal(24)
2448 : })
2449 :
2450 2356 : export const zCccWebsiteRootTab = z.object({
2451 : facets: zCccWebsiteCardFacets,
2452 : page: zCccWebsiteRootPageInfo,
2453 : sort_orders: z
2454 : .array(z.enum(['popular', 'name', 'priceAsc', 'priceDesc']))
2455 : .max(4)
2456 : })
2457 :
2458 2356 : export const zCccWebsiteRootTabs = z.object({
2459 : apps: zCccWebsiteRootTab,
2460 : models: zCccWebsiteRootTab,
2461 : workflows: zCccWebsiteRootTab
2462 : })
2463 :
2464 : /**
2465 : * Response when a cancellation is accepted but has not committed yet. Carries no cancel_at: no cancellation time exists to report until the operation settles. The billing operation reports only status, so once it reaches `succeeded` the committed date is read from `cancel_at` on `GET /api/billing/status`.
2466 : */
2467 2356 : export const zCancelSubscriptionAcceptedResponse = z.object({
2468 : billing_op_id: z.string(),
2469 : status: z.enum(['pending'])
2470 : })
2471 :
2472 : /**
2473 : * Request body for cancelling the current subscription.
2474 : */
2475 2356 : export const zCancelSubscriptionRequest = z.object({
2476 : idempotency_key: z.string().optional()
2477 : })
2478 :
2479 : /**
2480 : * Response after successfully cancelling a subscription.
2481 : */
2482 2356 : export const zCancelSubscriptionResponse = z.object({
2483 : billing_op_id: z.string(),
2484 : cancel_at: z.iso.datetime()
2485 : })
2486 :
2487 : /**
2488 : * Display data for one governable partner provider.
2489 : */
2490 2356 : export const zCatalogProvider = z.object({
2491 : display_name: z.string(),
2492 : node_categories: z.array(z.string()),
2493 : provider_id: z.string()
2494 : })
2495 :
2496 : /**
2497 : * Credentials the Churnkey embed requires to launch the cancel flow.
2498 : * `auth_hash` is hex-encoded HMAC-SHA256 of `customer_id` signed with the
2499 : * server's CHURNKEY_HMAC_SECRET; it is bound to that single customer ID
2500 : * and must not be reused for other customers.
2501 : *
2502 : */
2503 2356 : export const zChurnkeyAuthResponse = z.object({
2504 : auth_hash: z.string(),
2505 : customer_id: z.string(),
2506 : mode: z.enum(['live', 'test', 'sandbox']),
2507 : offer_subscription_id: z.string().min(1).optional()
2508 : })
2509 :
2510 2356 : export const zCloudNodeCompatibility = z.object({
2511 : missing_node_types: z.array(z.string())
2512 : })
2513 :
2514 : /**
2515 : * A model file and the ComfyUI model folder it is read from.
2516 : */
2517 2356 : export const zCompatibilityModel = z.object({
2518 : folder: z.string(),
2519 : name: z.string()
2520 : })
2521 :
2522 : /**
2523 : * The node types and models of a workflow.
2524 : */
2525 2356 : export const zCloudCompatibilityRequest = z.object({
2526 : models: z.array(zCompatibilityModel).optional(),
2527 : node_types: z.array(z.string())
2528 : })
2529 :
2530 2356 : export const zCloudWorkflowCompatibility = z.object({
2531 : missing_models: z.array(zCompatibilityModel).optional(),
2532 : missing_node_types: z.array(z.string())
2533 : })
2534 :
2535 : /**
2536 : * Which of the posted node types and models Comfy Cloud does not have.
2537 : */
2538 2356 : export const zCloudCompatibility = z.object({
2539 : cloud: zCloudWorkflowCompatibility
2540 : })
2541 :
2542 2356 : export const zContentCatalogRecord = z.object({
2543 : data: z.record(z.string(), z.unknown()),
2544 : deleted: z.boolean(),
2545 : edit_version: z.string(),
2546 : enabled: z.boolean(),
2547 : kind: z.enum(['MODEL', 'WORKFLOW', 'APP', 'TEMPLATE_SET']),
2548 : last_modified: z.iso.datetime().optional(),
2549 : revision: z.coerce
2550 : .bigint()
2551 : .gte(BigInt(1))
2552 : .max(BigInt('9223372036854775807'), {
2553 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2554 : }),
2555 : slug: z.string(),
2556 : uid: z.string(),
2557 : visibility: z.enum(['PUBLIC', 'STAFF']),
2558 : visible_from: z.iso.datetime().optional()
2559 : })
2560 :
2561 2356 : export const zCccWebsiteCardsPage = z.object({
2562 : available_kinds: z.array(z.enum(['MODEL', 'WORKFLOW', 'APP'])).max(3),
2563 : facets: zCccWebsiteCardFacets,
2564 : generation: z.coerce
2565 : .bigint()
2566 : .min(BigInt('-9223372036854775808'), {
2567 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2568 : })
2569 : .max(BigInt('9223372036854775807'), {
2570 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2571 : })
2572 : .optional(),
2573 : has_more: z.boolean(),
2574 : items: z.array(zContentCatalogRecord).max(24),
2575 : next_cursor: z.string().max(4096).optional(),
2576 : page_size: z.int().gte(1).lte(24),
2577 : previous_cursor: z.string().max(4096).optional(),
2578 : revision_id: z.coerce
2579 : .bigint()
2580 : .min(BigInt('-9223372036854775808'), {
2581 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2582 : })
2583 : .max(BigInt('9223372036854775807'), {
2584 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2585 : }),
2586 : sort_orders: z
2587 : .array(z.enum(['popular', 'name', 'priceAsc', 'priceDesc']))
2588 : .max(4),
2589 : total: z.int().gte(0).optional()
2590 : })
2591 :
2592 2356 : export const zCccWebsiteRootPresentation = z.object({
2593 : as_of: z.iso.datetime(),
2594 : items: z.array(zContentCatalogRecord).max(5000),
2595 : model_directory: zCccWebsiteModelDirectory,
2596 : next_visibility_at: z.iso.datetime().nullable(),
2597 : revision_id: z.coerce
2598 : .bigint()
2599 : .min(BigInt('-9223372036854775808'), {
2600 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2601 : })
2602 : .max(BigInt('9223372036854775807'), {
2603 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2604 : }),
2605 : tabs: zCccWebsiteRootTabs
2606 : })
2607 :
2608 2356 : export const zContentCatalogProjection = z.object({
2609 : generation: z.coerce
2610 : .bigint()
2611 : .min(BigInt('-9223372036854775808'), {
2612 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2613 : })
2614 : .max(BigInt('9223372036854775807'), {
2615 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2616 : }),
2617 : items: z.array(zContentCatalogRecord),
2618 : revision_id: z.coerce
2619 : .bigint()
2620 : .gte(BigInt(1))
2621 : .max(BigInt('9223372036854775807'), {
2622 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2623 : })
2624 : })
2625 :
2626 : export const zCccPublicItemsPage = zContentCatalogProjection.and(
2627 : z.object({
2628 : has_more: z.boolean(),
2629 : next_cursor: z.string().optional(),
2630 : page_size: z.int().gte(1).lte(100)
2631 : })
2632 : )
2633 :
2634 : /**
2635 : * Request body for creating a new Hub profile.
2636 : */
2637 2356 : export const zCreateHubProfileRequest = z.object({
2638 : avatar_token: z.string().optional(),
2639 : description: z.string().optional(),
2640 : display_name: z.string().optional(),
2641 : username: z.string(),
2642 : website_urls: z.array(z.string()).optional(),
2643 : workspace_id: z.string()
2644 : })
2645 :
2646 : /**
2647 : * Request body for inviting a user to a workspace.
2648 : */
2649 2356 : export const zCreateInviteRequest = z.object({
2650 : email: z.email()
2651 : })
2652 :
2653 : /**
2654 : * Request body for creating a new user secret.
2655 : */
2656 2356 : export const zCreateSecretRequest = z.object({
2657 : credential_type: z
2658 : .enum(['api_key', 'gcp_service_account'])
2659 : .optional()
2660 : .default('api_key'),
2661 : name: z.string().min(1).max(255),
2662 : provider: z.string().max(64).optional(),
2663 : secret_value: z.string().min(1)
2664 : })
2665 :
2666 : /**
2667 : * Response after creating a session cookie
2668 : */
2669 2356 : export const zCreateSessionResponse = z.object({
2670 : expiresIn: z.int().optional(),
2671 : success: z.boolean()
2672 : })
2673 :
2674 : /**
2675 : * A hosted Stripe Checkout session for a credit top-up.
2676 : */
2677 2356 : export const zCreateTopupCheckoutResponse = z.object({
2678 : checkout_url: z.url(),
2679 : session_id: z.string().optional()
2680 : })
2681 :
2682 : /**
2683 : * Request body for previewing a credit top-up.
2684 : */
2685 2356 : export const zCreateTopupQuoteRequest = z.object({
2686 : amount_cents: z.coerce
2687 : .bigint()
2688 : .min(BigInt('-9223372036854775808'), {
2689 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2690 : })
2691 : .max(BigInt('9223372036854775807'), {
2692 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2693 : })
2694 : })
2695 :
2696 : /**
2697 : * Legacy on-file top-up. Explicit payment authority, save/default fields and auto_top_up require the dedicated interactive route and are rejected here, including null or false values.
2698 : */
2699 2356 : export const zCreateTopupRequest = z.object({
2700 : amount_cents: z.coerce
2701 : .bigint()
2702 : .gte(BigInt(500))
2703 : .max(BigInt('9223372036854775807'), {
2704 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2705 : }),
2706 : checkout_attempt_id: z.string().optional(),
2707 : idempotency_key: z.string().optional()
2708 : })
2709 :
2710 : /**
2711 : * Response after successfully purchasing a credit top-up.
2712 : */
2713 2356 : export const zCreateTopupResponse = z.object({
2714 : amount_cents: z.coerce
2715 : .bigint()
2716 : .min(BigInt('-9223372036854775808'), {
2717 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2718 : })
2719 : .max(BigInt('9223372036854775807'), {
2720 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2721 : }),
2722 : billing_op_id: z.string(),
2723 : status: z.enum(['pending', 'completed', 'failed']),
2724 : topup_id: z.string()
2725 : })
2726 :
2727 : /**
2728 : * Request body for creating a new saved workflow.
2729 : */
2730 2356 : export const zCreateWorkflowRequest = z.object({
2731 : default_view: z.enum(['workflow', 'app']).optional(),
2732 : description: z.string().optional(),
2733 : forked_from_workflow_id: z.string().optional(),
2734 : forked_from_workflow_version_id: z.string().optional(),
2735 : name: z.string().optional(),
2736 : workflow_json: z.record(z.string(), z.unknown())
2737 : })
2738 :
2739 : /**
2740 : * Request body for creating a new version of a saved workflow.
2741 : */
2742 2356 : export const zCreateWorkflowVersionRequest = z.object({
2743 : base_version: z.int(),
2744 : workflow_json: z.record(z.string(), z.unknown())
2745 : })
2746 :
2747 : /**
2748 : * Request body for creating a new workspace-scoped API key.
2749 : */
2750 2356 : export const zCreateWorkspaceApiKeyRequest = z.object({
2751 : description: z.string().max(5000).optional(),
2752 : expires_at: z.iso.datetime().optional(),
2753 : name: z.string()
2754 : })
2755 :
2756 : /**
2757 : * Response containing the newly created workspace API key.
2758 : */
2759 2356 : export const zCreateWorkspaceApiKeyResponse = z.object({
2760 : created_at: z.iso.datetime(),
2761 : description: z.string().max(5000),
2762 : expires_at: z.iso.datetime().optional(),
2763 : id: z.uuid(),
2764 : key: z.string(),
2765 : key_prefix: z.string(),
2766 : name: z.string()
2767 : })
2768 :
2769 : /**
2770 : * Request body for creating a new workspace.
2771 : */
2772 2356 : export const zCreateWorkspaceRequest = z.object({
2773 : name: z.string().min(1).max(100)
2774 : })
2775 :
2776 : /**
2777 : * One way a provider's credential can be entered. When a provider exposes more than one option, clients present a sub-selection; the selected option's credential_type is sent on CreateSecretRequest.
2778 : */
2779 2356 : export const zCredentialOption = z.object({
2780 : credential_type: z.enum(['api_key', 'gcp_service_account']),
2781 : input_type: z.enum(['text', 'json_file']),
2782 : label: z.string()
2783 : })
2784 :
2785 2356 : export const zCreditValidityFact = z.object({
2786 : expires_at: z.iso.datetime().optional(),
2787 : rollover: z.enum(['none', 'allowed', 'unknown']).optional(),
2788 : state: z.enum(['expiring', 'mixed', 'unknown'])
2789 : })
2790 :
2791 : /**
2792 : * Display-only validity of the current shared wallet, including old-contract value and custom grants. Not a new-purchase quote or a spend decision. Missing facts on an older server mean unknown. No default year is inferred.
2793 : */
2794 2356 : export const zCreditValidity = z.object({
2795 : plan: zCreditValidityFact,
2796 : top_up: zCreditValidityFact
2797 : })
2798 :
2799 : /**
2800 : * Current credit balance and usage details for a workspace. Every amount here is CENTS of `currency`. The `*_micros` fields are a misnamed legacy set kept for wire compatibility; the `*_cents` fields beside them carry the identical values under honest names. `amount_micros` stays required and `amount_cents` is optional so existing strict clients are unaffected.
2801 : */
2802 2356 : export const zBillingBalanceResponse = z.object({
2803 : amount_cents: z.number().optional(),
2804 : amount_micros: z.number(),
2805 : cloud_credit_balance_cents: z.number().optional(),
2806 : cloud_credit_balance_micros: z.number().optional(),
2807 : cloud_credit_display_balance_cents: z.number().optional(),
2808 : credit_validity: zCreditValidity.optional(),
2809 : currency: z.string(),
2810 : effective_balance_authoritative: z.boolean().optional(),
2811 : effective_balance_cents: z.number().optional(),
2812 : effective_balance_micros: z.number().optional(),
2813 : low_balance: z.boolean().optional(),
2814 : max_topup_cents: z.coerce
2815 : .bigint()
2816 : .min(BigInt('-9223372036854775808'), {
2817 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2818 : })
2819 : .max(BigInt('9223372036854775807'), {
2820 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2821 : })
2822 : .optional(),
2823 : max_topup_credits: z.coerce
2824 : .bigint()
2825 : .min(BigInt('-9223372036854775808'), {
2826 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2827 : })
2828 : .max(BigInt('9223372036854775807'), {
2829 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2830 : })
2831 : .optional(),
2832 : min_topup_cents: z.coerce
2833 : .bigint()
2834 : .min(BigInt('-9223372036854775808'), {
2835 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2836 : })
2837 : .max(BigInt('9223372036854775807'), {
2838 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2839 : })
2840 : .optional(),
2841 : min_topup_credits: z.coerce
2842 : .bigint()
2843 : .min(BigInt('-9223372036854775808'), {
2844 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2845 : })
2846 : .max(BigInt('9223372036854775807'), {
2847 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2848 : })
2849 : .optional(),
2850 : pending_charges_cents: z.number().optional(),
2851 : pending_charges_micros: z.number().optional(),
2852 : prepaid_balance_cents: z.number().optional(),
2853 : prepaid_balance_micros: z.number().optional(),
2854 : suggested_topup_amount_cents: z.coerce
2855 : .bigint()
2856 : .min(BigInt('-9223372036854775808'), {
2857 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
2858 : })
2859 : .max(BigInt('9223372036854775807'), {
2860 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
2861 : })
2862 : .nullish()
2863 : })
2864 :
2865 : /**
2866 : * The workspace bound to the presented credential, plus how that credential authenticated. Same shape as Workspace with the caller's role and the auth method added, and without created_at (callers of this endpoint want identity, not provenance).
2867 : */
2868 2356 : export const zCurrentWorkspaceResponse = z.object({
2869 : auth_method: z.string(),
2870 : id: z.string(),
2871 : name: z.string(),
2872 : permissions: z.array(z.string()).optional(),
2873 : role: z.enum(['owner', 'member']).optional(),
2874 : type: z.enum(['personal', 'team'])
2875 : })
2876 :
2877 : /**
2878 : * Response after deleting a session cookie
2879 : */
2880 2356 : export const zDeleteSessionResponse = z.object({
2881 : success: z.boolean()
2882 : })
2883 :
2884 : /**
2885 : * Error body of local ComfyUI's /api/deploy* routes. Branch on `error`, never on `message`.
2886 : */
2887 2356 : export const zDeployToCloudError = z.object({
2888 : error: z.enum([
2889 : 'offline',
2890 : 'multiple_credentials',
2891 : 'invalid_api_key_format',
2892 : 'invalid_body',
2893 : 'missing_credentials',
2894 : 'unauthorized',
2895 : 'too_large',
2896 : 'too_many_bundles',
2897 : 'builder_rejected',
2898 : 'builder_unavailable',
2899 : 'builder_busy'
2900 : ]),
2901 : message: z.string().optional()
2902 : })
2903 :
2904 : /**
2905 : * The node types of the workflow open in the editor.
2906 : */
2907 2356 : export const zDeploymentCompatibilityRequest = z.object({
2908 : node_types: z.array(z.string())
2909 : })
2910 :
2911 2356 : export const zDeploymentNodeCompatibility = z.object({
2912 : deployment_id: z.string(),
2913 : missing_node_types: z.array(z.string()),
2914 : unknown: z.boolean()
2915 : })
2916 :
2917 : /**
2918 : * Which of the posted node types each of the workspace's deployments, and Comfy Cloud, does not have.
2919 : */
2920 2356 : export const zDeploymentCompatibility = z.object({
2921 : cloud: zCloudNodeCompatibility,
2922 : deployments: z.array(zDeploymentNodeCompatibility)
2923 : })
2924 :
2925 : /**
2926 : * Request to mint a desktop login code.
2927 : */
2928 2356 : export const zDesktopLoginCodeCreateRequest = z.object({
2929 : app_version: z.string().min(1).max(64),
2930 : code_challenge: z.string().min(43).max(128),
2931 : installation_id: z
2932 : .string()
2933 : .min(8)
2934 : .max(128)
2935 : .regex(/^[A-Za-z0-9._-]+$/)
2936 : .optional(),
2937 : platform: z.string().min(1).max(32)
2938 : })
2939 :
2940 : /**
2941 : * A freshly minted desktop login code and its polling parameters.
2942 : */
2943 2356 : export const zDesktopLoginCodeCreateResponse = z.object({
2944 : code: z.string(),
2945 : expires_in: z.int(),
2946 : poll_interval: z.int()
2947 : })
2948 :
2949 : /**
2950 : * Request to exchange a redeemed login code for a custom token.
2951 : */
2952 2356 : export const zDesktopLoginCodeExchangeRequest = z.object({
2953 : code: z.string(),
2954 : code_verifier: z.string().min(43).max(128)
2955 : })
2956 :
2957 : /**
2958 : * Exchange poll result. Pending until the code is redeemed in the browser.
2959 : */
2960 2356 : export const zDesktopLoginCodeExchangeResponse = z.object({
2961 : custom_token: z.string().optional(),
2962 : status: z.enum(['pending', 'complete'])
2963 : })
2964 :
2965 : /**
2966 : * Request to claim a desktop login code for the authenticated user.
2967 : */
2968 2356 : export const zDesktopLoginCodeRedeemRequest = z.object({
2969 : code: z.string()
2970 : })
2971 :
2972 : /**
2973 : * Result of redeeming a desktop login code.
2974 : */
2975 2356 : export const zDesktopLoginCodeRedeemResponse = z.object({
2976 : status: z.enum(['redeemed'])
2977 : })
2978 :
2979 : /**
2980 : * First rejected op in an abort-remainder batch.
2981 : */
2982 2356 : export const zDocOpFailure = z.object({
2983 : code: z.string(),
2984 : index: z.int(),
2985 : message: z.string(),
2986 : op_id: z.string().max(128).optional()
2987 : })
2988 :
2989 2356 : export const zDocOpsResultData = z.object({
2990 : applied: z.array(z.string()).optional(),
2991 : code: z.string().optional(),
2992 : failed: zDocOpFailure.optional(),
2993 : lww_dropped: z.array(z.string()).optional(),
2994 : message: z.string().optional(),
2995 : ok: z.boolean(),
2996 : op_ids: z.array(z.string().min(1).max(128)).max(256).optional(),
2997 : seq: z.coerce
2998 : .bigint()
2999 : .min(BigInt('-9223372036854775808'), {
3000 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3001 : })
3002 : .max(BigInt('9223372036854775807'), {
3003 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3004 : })
3005 : .optional(),
3006 : skipped: z.array(z.string()).optional(),
3007 : v: z.int().gte(1).lte(1),
3008 : workflow_id: z.string().min(1).max(128)
3009 : })
3010 :
3011 : /**
3012 : * Host acknowledgement for a doc_ops batch.
3013 : */
3014 2356 : export const zDocOpsResultFrame = z.object({
3015 : data: zDocOpsResultData,
3016 : type: z.enum(['doc_ops_result'])
3017 : })
3018 :
3019 2356 : export const zDocResetData = z.object({
3020 : actor: z.string().max(256).optional(),
3021 : lineage_seq: z.coerce
3022 : .bigint()
3023 : .min(BigInt('-9223372036854775808'), {
3024 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3025 : })
3026 : .max(BigInt('9223372036854775807'), {
3027 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3028 : }),
3029 : seq: z.coerce
3030 : .bigint()
3031 : .min(BigInt('-9223372036854775808'), {
3032 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3033 : })
3034 : .max(BigInt('9223372036854775807'), {
3035 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3036 : }),
3037 : v: z.int().gte(1).lte(1),
3038 : workflow_id: z.string().min(1).max(128)
3039 : })
3040 :
3041 : /**
3042 : * Host-to-follower lineage break. The follower must resubscribe for fresh state.
3043 : */
3044 2356 : export const zDocResetFrame = z.object({
3045 : data: zDocResetData,
3046 : type: z.enum(['doc_reset'])
3047 : })
3048 :
3049 2356 : export const zDocSubscribedData = z.object({
3050 : code: z.string().optional(),
3051 : expected_seq: z.coerce
3052 : .bigint()
3053 : .min(BigInt('-9223372036854775808'), {
3054 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3055 : })
3056 : .max(BigInt('9223372036854775807'), {
3057 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3058 : })
3059 : .optional(),
3060 : lineage_seq: z.coerce
3061 : .bigint()
3062 : .min(BigInt('-9223372036854775808'), {
3063 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3064 : })
3065 : .max(BigInt('9223372036854775807'), {
3066 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3067 : })
3068 : .optional(),
3069 : message: z.string().optional(),
3070 : ok: z.boolean(),
3071 : seq: z.coerce
3072 : .bigint()
3073 : .min(BigInt('-9223372036854775808'), {
3074 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3075 : })
3076 : .max(BigInt('9223372036854775807'), {
3077 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3078 : })
3079 : .optional(),
3080 : v: z.int().gte(1).lte(1),
3081 : workflow_id: z.string().min(1).max(128)
3082 : })
3083 :
3084 : /**
3085 : * Server acknowledgement for a doc_subscribe request.
3086 : */
3087 2356 : export const zDocSubscribedFrame = z.object({
3088 : data: zDocSubscribedData,
3089 : type: z.enum(['doc_subscribed'])
3090 : })
3091 :
3092 2356 : export const zDocUpdateData = z.object({
3093 : actor: z.string().max(256).optional(),
3094 : lineage_seq: z.coerce
3095 : .bigint()
3096 : .min(BigInt('-9223372036854775808'), {
3097 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3098 : })
3099 : .max(BigInt('9223372036854775807'), {
3100 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3101 : }),
3102 : op_ids: z.array(z.string().min(1).max(128)).max(256).optional(),
3103 : seq: z.coerce
3104 : .bigint()
3105 : .min(BigInt('-9223372036854775808'), {
3106 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3107 : })
3108 : .max(BigInt('9223372036854775807'), {
3109 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3110 : }),
3111 : update_b64: z.string(),
3112 : v: z.int().gte(1).lte(1),
3113 : workflow_id: z.string().min(1).max(128)
3114 : })
3115 :
3116 : /**
3117 : * Host-to-follower incremental Yjs document update.
3118 : */
3119 2356 : export const zDocUpdateFrame = z.object({
3120 : data: zDocUpdateData,
3121 : type: z.enum(['doc_update'])
3122 : })
3123 :
3124 : /**
3125 : * Optional request body for the token exchange endpoint. The Firebase JWT
3126 : * being exchanged is supplied via the `Authorization: Bearer` header; this
3127 : * body only carries workspace-selection input.
3128 : *
3129 : */
3130 2356 : export const zExchangeTokenRequest = z.object({
3131 : resource: z.enum(['partner-node']).optional(),
3132 : workspace_id: z.string().optional()
3133 : })
3134 :
3135 : /**
3136 : * Detailed execution error information from ComfyUI
3137 : */
3138 2356 : export const zExecutionError = z.object({
3139 : current_inputs: z.record(z.string(), z.unknown()),
3140 : current_outputs: z.record(z.string(), z.unknown()),
3141 : exception_message: z.string(),
3142 : exception_type: z.string(),
3143 : node_id: z.string(),
3144 : node_type: z.string(),
3145 : traceback: z.array(z.string())
3146 : })
3147 :
3148 : /**
3149 : * Response containing a signed download URL for an exported asset archive.
3150 : */
3151 2356 : export const zExportDownloadUrlResponse = z.object({
3152 : expires_at: z.iso.datetime().optional(),
3153 : url: z.string()
3154 : })
3155 :
3156 : /**
3157 : * Request to submit user feedback
3158 : */
3159 2356 : export const zFeedbackRequest = z.object({
3160 : content: z.string().optional(),
3161 : metadata: z.record(z.string(), z.unknown()).optional(),
3162 : rating: z.int().gte(1).lte(5).optional(),
3163 : type: z.enum(['missing_nodes', 'general', 'missing_models'])
3164 : })
3165 :
3166 : /**
3167 : * Response after submitting feedback
3168 : */
3169 2356 : export const zFeedbackResponse = z.record(z.string(), z.unknown())
3170 :
3171 : /**
3172 : * Request body for forking an existing workflow into the user's account.
3173 : */
3174 2356 : export const zForkWorkflowRequest = z.object({
3175 : name: z.string().optional(),
3176 : source_version: z.int()
3177 : })
3178 :
3179 : /**
3180 : * Individual file entry within a full user data response.
3181 : */
3182 2356 : export const zGetUserDataResponseFullFile = z.object({
3183 : modified: z.coerce
3184 : .bigint()
3185 : .min(BigInt('-9223372036854775808'), {
3186 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3187 : })
3188 : .max(BigInt('9223372036854775807'), {
3189 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3190 : })
3191 : .optional(),
3192 : path: z.string().optional(),
3193 : size: z.int().optional()
3194 : })
3195 :
3196 : /**
3197 : * List of user data file entries (each with path, size, and modification time) returned when full_info=true.
3198 : */
3199 2356 : export const zGetUserDataResponseFull = z.array(zGetUserDataResponseFullFile)
3200 :
3201 : /**
3202 : * The union of setting keys this server accepts. Published as an enum so clients cannot address a key the registry does not know.
3203 : */
3204 2356 : export const zGlobalSettingKey = z.enum(['Comfy.AgentPanel.ConsentAccepted'])
3205 :
3206 : /**
3207 : * The last-changed timestamp every stored setting carries.
3208 : */
3209 2356 : export const zGlobalSettingUpdatedAt = z.object({
3210 : updated_at: z.iso.datetime()
3211 : })
3212 :
3213 : /**
3214 : * A setting key with its value, discriminated on `key`. Narrowing on the key yields exactly one value schema, which is what gives writes their type safety.
3215 : */
3216 : export const zGlobalSettingValue = zAgentConsentSettingValue
3217 :
3218 : /**
3219 : * Full data for a global subgraph blueprint
3220 : */
3221 2356 : export const zGlobalSubgraphData = z.object({
3222 : data: z.string(),
3223 : info: z.object({
3224 : node_pack: z.string()
3225 : }),
3226 : name: z.string(),
3227 : source: z.string()
3228 : })
3229 :
3230 : /**
3231 : * Metadata for a global subgraph blueprint (without full data)
3232 : */
3233 2356 : export const zGlobalSubgraphInfo = z.object({
3234 : data: z.string().optional(),
3235 : info: z.object({
3236 : node_pack: z.string()
3237 : }),
3238 : name: z.string(),
3239 : source: z.string()
3240 : })
3241 :
3242 : /**
3243 : * History entry with full prompt data. The workflow graph (extra_data.extra_pnginfo) is omitted from records persisted after it stopped being stored; older records may still contain it.
3244 : */
3245 2356 : export const zHistoryDetailEntry = z.object({
3246 : meta: z.record(z.string(), z.unknown()).optional(),
3247 : outputs: z.record(z.string(), z.unknown()).optional(),
3248 : prompt: z
3249 : .object({
3250 : extra_data: z.record(z.string(), z.unknown()).optional(),
3251 : outputs_to_execute: z.array(z.string()).optional(),
3252 : priority: z.number().optional(),
3253 : prompt: z.record(z.string(), z.unknown()).optional(),
3254 : prompt_id: z.string().optional()
3255 : })
3256 : .optional(),
3257 : status: z.record(z.string(), z.unknown()).optional()
3258 : })
3259 :
3260 : /**
3261 : * Detailed execution history response for a specific prompt.
3262 : * Returns a dictionary with prompt_id as key and full history data as value.
3263 : *
3264 : */
3265 2356 : export const zHistoryDetailResponse = z.record(z.string(), zHistoryDetailEntry)
3266 :
3267 : /**
3268 : * History entry with prompt_id and execution data
3269 : */
3270 2356 : export const zHistoryEntry = z.object({
3271 : create_time: z.coerce
3272 : .bigint()
3273 : .min(BigInt('-9223372036854775808'), {
3274 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3275 : })
3276 : .max(BigInt('9223372036854775807'), {
3277 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3278 : })
3279 : .optional(),
3280 : meta: z.record(z.string(), z.unknown()).optional(),
3281 : outputs: z.record(z.string(), z.unknown()).optional(),
3282 : prompt: z
3283 : .object({
3284 : extra_data: z.record(z.string(), z.unknown()).optional(),
3285 : priority: z.number().optional(),
3286 : prompt_id: z.string().optional()
3287 : })
3288 : .optional(),
3289 : prompt_id: z.string(),
3290 : status: z.record(z.string(), z.unknown()).optional(),
3291 : workflow_id: z.string().optional()
3292 : })
3293 :
3294 : /**
3295 : * Request to manage history operations
3296 : */
3297 2356 : export const zHistoryManageRequest = z.object({
3298 : clear: z.boolean().optional(),
3299 : delete: z.array(z.string()).optional()
3300 : })
3301 :
3302 : /**
3303 : * Execution history response with history array.
3304 : * Returns an object with a "history" key containing an array of history entries.
3305 : * Each entry includes prompt_id as a property along with execution data.
3306 : *
3307 : */
3308 2356 : export const zHistoryResponse = z.object({
3309 : history: z.array(zHistoryEntry)
3310 : })
3311 :
3312 2356 : export const zHostedTopupCheckout = z.object({
3313 : amount_cents: z.coerce
3314 : .bigint()
3315 : .min(BigInt('-9223372036854775808'), {
3316 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3317 : })
3318 : .max(BigInt('9223372036854775807'), {
3319 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3320 : }),
3321 : auto_top_up: zAcceptedAutoTopUpSettings.optional(),
3322 : auto_top_up_activation: zAutoTopUpActivation.optional(),
3323 : auto_top_up_activation_reason: zAutoTopUpActivationReason.optional(),
3324 : payment_amount_cents: z.coerce
3325 : .bigint()
3326 : .min(BigInt('-9223372036854775808'), {
3327 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3328 : })
3329 : .max(BigInt('9223372036854775807'), {
3330 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3331 : })
3332 : .nullable(),
3333 : session_id: z.string(),
3334 : state: z.enum([
3335 : 'open',
3336 : 'payment_processing',
3337 : 'credits_applying',
3338 : 'fulfilled',
3339 : 'expired',
3340 : 'failed'
3341 : ])
3342 : })
3343 :
3344 : /**
3345 : * Durable discovery record only. Fetch the session endpoint for current payment and credit-fulfillment state; a summary proves neither. An unavailable session remains discoverable without hiding other rows.
3346 : *
3347 : */
3348 2356 : export const zHostedTopupCheckoutSummary = z.object({
3349 : amount_cents: z.coerce
3350 : .bigint()
3351 : .min(BigInt('-9223372036854775808'), {
3352 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3353 : })
3354 : .max(BigInt('9223372036854775807'), {
3355 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3356 : }),
3357 : created_at: z.iso.datetime(),
3358 : session_id: z.string()
3359 : })
3360 :
3361 2356 : export const zHostedTopupCheckoutList = z.object({
3362 : checkouts: z.array(zHostedTopupCheckoutSummary),
3363 : next_cursor: z.string().nullable()
3364 : })
3365 :
3366 : /**
3367 : * Request body for requesting a signed upload URL for a Hub asset.
3368 : */
3369 2356 : export const zHubAssetUploadUrlRequest = z.object({
3370 : content_type: z.string(),
3371 : filename: z.string()
3372 : })
3373 :
3374 : /**
3375 : * Response containing a signed upload URL and the target asset path.
3376 : */
3377 2356 : export const zHubAssetUploadUrlResponse = z.object({
3378 : public_url: z.string(),
3379 : token: z.string(),
3380 : upload_url: z.string()
3381 : })
3382 :
3383 : /**
3384 : * Metadata for a single Hub label.
3385 : */
3386 2356 : export const zHubLabelInfo = z.object({
3387 : description: z.string().optional(),
3388 : display_name: z.string(),
3389 : name: z.string(),
3390 : type: z.enum(['tag', 'model', 'custom_node'])
3391 : })
3392 :
3393 : /**
3394 : * List of available Hub labels for categorizing workflows.
3395 : */
3396 2356 : export const zHubLabelListResponse = z.object({
3397 : labels: z.array(zHubLabelInfo)
3398 : })
3399 :
3400 : /**
3401 : * Full public profile for a Hub creator.
3402 : */
3403 2356 : export const zHubProfile = z.object({
3404 : avatar_url: z.string().optional(),
3405 : description: z.string().optional(),
3406 : display_name: z.string().optional(),
3407 : username: z.string(),
3408 : website_urls: z.array(z.string()).optional()
3409 : })
3410 :
3411 : /**
3412 : * Abbreviated Hub profile used in workflow listings.
3413 : */
3414 2356 : export const zHubProfileSummary = z.object({
3415 : avatar_url: z.string().optional(),
3416 : display_name: z.string().optional(),
3417 : username: z.string()
3418 : })
3419 :
3420 : /**
3421 : * Response indicating whether a Hub username is available.
3422 : */
3423 2356 : export const zHubUsernameCheckResponse = z.object({
3424 : available: z.boolean(),
3425 : suggestions: z.array(z.string()).optional(),
3426 : username: z.string(),
3427 : validation_error: z.string().optional()
3428 : })
3429 :
3430 : /**
3431 : * Public workflow status. NULL in the database is represented as pending in API responses.
3432 : */
3433 2356 : export const zHubWorkflowStatus = z.enum([
3434 : 'pending',
3435 : 'approved',
3436 : 'rejected',
3437 : 'deprecated'
3438 : ])
3439 :
3440 : /**
3441 : * Entry in the curated workflow template gallery shown on the home page.
3442 : */
3443 2356 : export const zHubWorkflowTemplateEntry = z.object({
3444 : contentTemplate: z.string().optional(),
3445 : date: z.string().optional(),
3446 : description: z.string().optional(),
3447 : extendedDescription: z.string().optional(),
3448 : faqItems: z
3449 : .array(
3450 : z.object({
3451 : answer: z.string(),
3452 : question: z.string()
3453 : })
3454 : )
3455 : .optional(),
3456 : howToUse: z.array(z.string()).optional(),
3457 : includeOnDistributions: z.array(z.string()).optional(),
3458 : io: z
3459 : .object({
3460 : inputs: z.array(z.record(z.string(), z.unknown())).optional(),
3461 : outputs: z.array(z.record(z.string(), z.unknown())).optional()
3462 : })
3463 : .optional(),
3464 : isApp: z.boolean(),
3465 : isEssential: z.boolean().optional(),
3466 : logos: z.array(z.record(z.string(), z.unknown())).optional(),
3467 : mediaSubtype: z.string().optional(),
3468 : mediaType: z.string().optional(),
3469 : metaDescription: z.string().optional(),
3470 : models: z.array(z.string()).optional(),
3471 : name: z.string(),
3472 : openSource: z.boolean().optional(),
3473 : profile: zHubProfileSummary.optional(),
3474 : requiresCustomNodes: z.array(z.string()).optional(),
3475 : searchRank: z.coerce
3476 : .bigint()
3477 : .min(BigInt('-9223372036854775808'), {
3478 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3479 : })
3480 : .max(BigInt('9223372036854775807'), {
3481 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3482 : })
3483 : .optional(),
3484 : shareId: z.string().optional(),
3485 : size: z.coerce
3486 : .bigint()
3487 : .min(BigInt('-9223372036854775808'), {
3488 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3489 : })
3490 : .max(BigInt('9223372036854775807'), {
3491 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3492 : })
3493 : .optional(),
3494 : status: zHubWorkflowStatus,
3495 : suggestedUseCases: z.array(z.string()).optional(),
3496 : tags: z.array(z.string()).optional(),
3497 : thumbnailComparisonUrl: z.string().optional(),
3498 : thumbnailUrl: z.string().optional(),
3499 : thumbnailVariant: z.string().optional(),
3500 : title: z.string(),
3501 : tutorialUrl: z.string().optional(),
3502 : usage: z.coerce
3503 : .bigint()
3504 : .min(BigInt('-9223372036854775808'), {
3505 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3506 : })
3507 : .max(BigInt('9223372036854775807'), {
3508 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3509 : })
3510 : .optional(),
3511 : vram: z.coerce
3512 : .bigint()
3513 : .min(BigInt('-9223372036854775808'), {
3514 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3515 : })
3516 : .max(BigInt('9223372036854775807'), {
3517 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3518 : })
3519 : .optional()
3520 : })
3521 :
3522 : /**
3523 : * Request body for importing assets from a published workflow.
3524 : */
3525 2356 : export const zImportPublishedAssetsRequest = z.object({
3526 : published_asset_ids: z.array(z.string()),
3527 : share_id: z.string().nullish()
3528 : })
3529 :
3530 : /**
3531 : * Response after importing published workflow assets.
3532 : */
3533 2356 : export const zImportPublishedAssetsResponse = z.object({
3534 : assets: z.array(zAssetInfo)
3535 : })
3536 :
3537 : /**
3538 : * Result of redeeming an input-image upload grant. Identical in shape to
3539 : * the POST /api/upload/image response.
3540 : *
3541 : */
3542 2356 : export const zInputUploadResponse = z.object({
3543 : name: z.string(),
3544 : subfolder: z.string(),
3545 : type: z.string()
3546 : })
3547 :
3548 : /**
3549 : * Request body for minting an input-image, input-audio or input-video upload grant.
3550 : */
3551 2356 : export const zInputUploadUrlRequest = z.object({
3552 : content_type: z.string().max(64)
3553 : })
3554 :
3555 : /**
3556 : * Response for POST /api/jobs/{job_id}/cancel. Returned on both fresh cancels and idempotent no-ops.
3557 : */
3558 2356 : export const zJobCancelResponse = z.object({
3559 : cancelled: z.boolean()
3560 : })
3561 :
3562 : /**
3563 : * The deployment a job ran on and the Release it ran, as they were when the job was sent: deployment_id and release_id stay the same after the deployment is updated to another Release or deleted. build_name and release_version are read from comfy-builder when the job is read, so a renamed Build shows its new name within a few minutes.
3564 : */
3565 2356 : export const zJobDeployment = z.object({
3566 : build_name: z.string().optional(),
3567 : deployment_id: z.string(),
3568 : name: z.string().optional(),
3569 : release_id: z.string(),
3570 : release_version: z.int().optional()
3571 : })
3572 :
3573 : /**
3574 : * Lightweight job data for list views (workflow and full outputs excluded)
3575 : */
3576 2356 : export const zJobEntry = z.object({
3577 : create_time: z.coerce
3578 : .bigint()
3579 : .min(BigInt('-9223372036854775808'), {
3580 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3581 : })
3582 : .max(BigInt('9223372036854775807'), {
3583 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3584 : }),
3585 : deployment: zJobDeployment.optional(),
3586 : execution_end_time: z.coerce
3587 : .bigint()
3588 : .min(BigInt('-9223372036854775808'), {
3589 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3590 : })
3591 : .max(BigInt('9223372036854775807'), {
3592 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3593 : })
3594 : .optional(),
3595 : execution_error: zExecutionError.optional(),
3596 : execution_start_time: z.coerce
3597 : .bigint()
3598 : .min(BigInt('-9223372036854775808'), {
3599 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3600 : })
3601 : .max(BigInt('9223372036854775807'), {
3602 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3603 : })
3604 : .optional(),
3605 : executor: z.enum(['cloud_inference', 'platform_gateway']).optional(),
3606 : id: z.uuid(),
3607 : outputs_count: z.int().optional(),
3608 : preview_output: z.record(z.string(), z.unknown()).optional(),
3609 : previewable_outputs_count: z.int().optional(),
3610 : status: z.enum([
3611 : 'pending',
3612 : 'in_progress',
3613 : 'completed',
3614 : 'failed',
3615 : 'cancelled'
3616 : ]),
3617 : workflow_id: z.string().optional()
3618 : })
3619 :
3620 : /**
3621 : * Where one executed node ran and where its output is shown, as ComfyUI
3622 : * records it in the history `meta`. Live `executed` messages carry the
3623 : * same `display_node`.
3624 : *
3625 : */
3626 2356 : export const zJobExecutionMetaEntry = z.object({
3627 : display_node: z.string().optional(),
3628 : node_id: z.string().optional(),
3629 : parent_node: z.string().nullish(),
3630 : real_node_id: z.string().optional()
3631 : })
3632 :
3633 : /**
3634 : * Full job details including workflow and outputs
3635 : */
3636 2356 : export const zJobDetailResponse = z.object({
3637 : create_time: z.coerce
3638 : .bigint()
3639 : .min(BigInt('-9223372036854775808'), {
3640 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3641 : })
3642 : .max(BigInt('9223372036854775807'), {
3643 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3644 : }),
3645 : deployment: zJobDeployment.optional(),
3646 : execution_end_time: z.coerce
3647 : .bigint()
3648 : .min(BigInt('-9223372036854775808'), {
3649 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3650 : })
3651 : .max(BigInt('9223372036854775807'), {
3652 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3653 : })
3654 : .optional(),
3655 : execution_error: zExecutionError.optional(),
3656 : execution_meta: z.record(z.string(), zJobExecutionMetaEntry).optional(),
3657 : execution_start_time: z.coerce
3658 : .bigint()
3659 : .min(BigInt('-9223372036854775808'), {
3660 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3661 : })
3662 : .max(BigInt('9223372036854775807'), {
3663 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3664 : })
3665 : .optional(),
3666 : execution_status: z.record(z.string(), z.unknown()).optional(),
3667 : executor: z.enum(['cloud_inference', 'platform_gateway']).optional(),
3668 : id: z.uuid(),
3669 : outputs: z.record(z.string(), z.unknown()).optional(),
3670 : outputs_count: z.int().optional(),
3671 : preview_output: z.record(z.string(), z.unknown()).optional(),
3672 : previewable_outputs_count: z.int().optional(),
3673 : queue_position: z.int().gte(1).nullish(),
3674 : queue_reason: z.enum(['concurrency_limit', 'capacity']).optional(),
3675 : status: z.enum([
3676 : 'pending',
3677 : 'in_progress',
3678 : 'completed',
3679 : 'failed',
3680 : 'cancelled'
3681 : ]),
3682 : update_time: z.coerce
3683 : .bigint()
3684 : .min(BigInt('-9223372036854775808'), {
3685 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3686 : })
3687 : .max(BigInt('9223372036854775807'), {
3688 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3689 : }),
3690 : user_id: z.string().optional(),
3691 : workflow: z.record(z.string(), z.unknown()).optional(),
3692 : workflow_id: z.string().optional(),
3693 : workflow_version_id: z.string().optional(),
3694 : workspace_id: z.string().optional()
3695 : })
3696 :
3697 : /**
3698 : * An asset produced by a job, enriched with the per-output node context
3699 : * (`node_id`, `output_key`, `output_index`) correlated from the job's
3700 : * execution outputs by content hash. The node-context fields are null
3701 : * when the asset cannot be matched to an output entry.
3702 : *
3703 : */
3704 2356 : export const zJobOutputAsset = z.object({
3705 : created_at: z.iso.datetime(),
3706 : hash: z
3707 : .string()
3708 : .regex(/^blake3:[a-f0-9]{64}$/)
3709 : .optional(),
3710 : id: z.uuid(),
3711 : mime_type: z.string().optional(),
3712 : name: z.string(),
3713 : node_id: z.string().nullish(),
3714 : output_index: z.int().nullish(),
3715 : output_key: z.string().nullish(),
3716 : preview_url: z.string().optional(),
3717 : size: z.coerce
3718 : .bigint()
3719 : .min(BigInt('-9223372036854775808'), {
3720 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3721 : })
3722 : .max(BigInt('9223372036854775807'), {
3723 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3724 : })
3725 : .optional()
3726 : })
3727 :
3728 : /**
3729 : * Job status information
3730 : */
3731 2356 : export const zJobStatusResponse = z.object({
3732 : assigned_inference: z.string().nullish(),
3733 : created_at: z.iso.datetime(),
3734 : error_message: z.string().nullish(),
3735 : id: z.uuid(),
3736 : last_state_update: z.iso.datetime().optional(),
3737 : status: z.enum([
3738 : 'waiting_to_dispatch',
3739 : 'pending',
3740 : 'in_progress',
3741 : 'completed',
3742 : 'error',
3743 : 'cancelled'
3744 : ]),
3745 : updated_at: z.iso.datetime()
3746 : })
3747 :
3748 : /**
3749 : * Request to cancel multiple jobs by ID.
3750 : */
3751 2356 : export const zJobsCancelRequest = z.object({
3752 : job_ids: z.array(z.uuid()).min(1).max(100)
3753 : })
3754 :
3755 : /**
3756 : * Response for POST /api/jobs/cancel.
3757 : */
3758 2356 : export const zJobsCancelResponse = z.object({
3759 : cancelled: z.array(z.string())
3760 : })
3761 :
3762 : /**
3763 : * A single JSON Web Key entry within a JWKS response.
3764 : */
3765 2356 : export const zJwkKey = z.object({
3766 : alg: z.string(),
3767 : crv: z.string(),
3768 : kid: z.string(),
3769 : kty: z.string(),
3770 : use: z.string(),
3771 : x: z.string(),
3772 : y: z.string()
3773 : })
3774 :
3775 : /**
3776 : * JSON Web Key Set containing the public keys used to verify Cloud JWTs.
3777 : */
3778 2356 : export const zJwksResponse = z.object({
3779 : keys: z.array(zJwkKey)
3780 : })
3781 :
3782 : /**
3783 : * Reference to a Hub label by ID.
3784 : */
3785 2356 : export const zLabelRef = z.object({
3786 : display_name: z.string(),
3787 : name: z.string()
3788 : })
3789 :
3790 : /**
3791 : * Full Hub workflow detail including versions, assets, and statistics.
3792 : */
3793 2356 : export const zHubWorkflowDetail = z.object({
3794 : assets: z.array(zAssetInfo),
3795 : custom_nodes: z.array(zLabelRef).optional(),
3796 : description: z.string().optional(),
3797 : is_app: z.boolean(),
3798 : metadata: z.record(z.string(), z.unknown()).optional(),
3799 : models: z.array(zLabelRef).optional(),
3800 : name: z.string(),
3801 : profile: zHubProfileSummary,
3802 : publish_time: z.iso.datetime().nullish(),
3803 : sample_image_urls: z.array(z.string()).optional(),
3804 : share_id: z.string(),
3805 : status: zHubWorkflowStatus,
3806 : tags: z.array(zLabelRef).optional(),
3807 : thumbnail_comparison_url: z.string().optional(),
3808 : thumbnail_type: z.enum(['image', 'video', 'image_comparison']).optional(),
3809 : thumbnail_url: z.string().optional(),
3810 : tutorial_url: z.string().optional(),
3811 : workflow_id: z.string(),
3812 : workflow_json: z.record(z.string(), z.unknown())
3813 : })
3814 :
3815 : /**
3816 : * Abbreviated Hub workflow metadata used in search and listing results.
3817 : */
3818 2356 : export const zHubWorkflowSummary = z.object({
3819 : custom_nodes: z.array(zLabelRef).optional(),
3820 : description: z.string().optional(),
3821 : is_app: z.boolean(),
3822 : metadata: z.record(z.string(), z.unknown()).optional(),
3823 : models: z.array(zLabelRef).optional(),
3824 : name: z.string(),
3825 : profile: zHubProfileSummary,
3826 : publish_time: z.iso.datetime().nullish(),
3827 : sample_image_urls: z.array(z.string()).optional(),
3828 : share_id: z.string(),
3829 : status: zHubWorkflowStatus,
3830 : tags: z.array(zLabelRef).optional(),
3831 : thumbnail_comparison_url: z.string().optional(),
3832 : thumbnail_type: z.enum(['image', 'video', 'image_comparison']).optional(),
3833 : thumbnail_url: z.string().optional(),
3834 : tutorial_url: z.string().optional()
3835 : })
3836 :
3837 : /**
3838 : * Paginated list of Hub workflows matching search criteria.
3839 : */
3840 2356 : export const zHubWorkflowListResponse = z.object({
3841 : next_cursor: z.string().optional(),
3842 : workflows: z.array(z.union([zHubWorkflowSummary, zHubWorkflowDetail]))
3843 : })
3844 :
3845 : /**
3846 : * Paginated list of assets belonging to the authenticated user.
3847 : */
3848 2356 : export const zListAssetsResponse = z.object({
3849 : assets: z.array(zAsset),
3850 : has_more: z.boolean(),
3851 : next_cursor: z.string().optional(),
3852 : total: z.int()
3853 : })
3854 :
3855 : /**
3856 : * 400 for a missing `filename` or a `res` that is not a number, on the media routes served outside the generated wrapper.
3857 : */
3858 2356 : export const zMediaQueryError = z.object({
3859 : error: z.string()
3860 : })
3861 :
3862 : /**
3863 : * The `data` of a model_download WebSocket event: the latest state of one model file a Cloud job on a deployment downloads before ComfyUI starts it. Sent by the deployment's worker (services/comfy-deploy/containerruntime worker.py, _ModelNews) only when the job asked for live progress, for each file the job fetches and never for a file the release ships, all before the job's execution_start. A failed file ends the job: no other source is tried and the job is not retried, so its execution_error (or execution_interrupted, when a cancel was in flight) follows. New fields may be added; a client ignores the ones it does not read.
3864 : */
3865 2356 : export const zModelDownloadData = z.object({
3866 : bytes_downloaded: z.int(),
3867 : bytes_total: z.int().nullable(),
3868 : count: z.int(),
3869 : dir: z.string(),
3870 : index: z.int(),
3871 : name: z.string(),
3872 : progress: z.number().nullable(),
3873 : prompt_id: z.string(),
3874 : status: z.string(),
3875 : workflow_id: z.string().optional()
3876 : })
3877 :
3878 : /**
3879 : * Server-to-client model_download frame on /ws. A Cloud job's model file download moved.
3880 : */
3881 2356 : export const zModelDownloadFrame = z.object({
3882 : data: zModelDownloadData,
3883 : type: z.enum(['model_download'])
3884 : })
3885 :
3886 : /**
3887 : * Represents a model file with metadata
3888 : */
3889 2356 : export const zModelFile = z.object({
3890 : name: z.string(),
3891 : pathIndex: z.int()
3892 : })
3893 :
3894 : /**
3895 : * Represents a folder containing models
3896 : */
3897 2356 : export const zModelFolder = z.object({
3898 : folders: z.array(z.string()),
3899 : name: z.string()
3900 : })
3901 :
3902 : /**
3903 : * Optional client observations. Invalid values are discarded without refusing the upload.
3904 : * Unknown or absent client becomes unknown. Missing resumed stays unknown; choosing resumable mode
3905 : * does not mean recovery. Start ignores resumed. Older servers ignore this entire object.
3906 : *
3907 : */
3908 2356 : export const zModelUploadAnalytics = z.object({
3909 : client: z.string().optional(),
3910 : resumed: z.boolean().optional()
3911 : })
3912 :
3913 : /**
3914 : * Where and how the browser sends a model file's bytes (POST /api/assets/uploads).
3915 : */
3916 2356 : export const zModelUploadStarted = z.object({
3917 : chunk_size_bytes: z.coerce
3918 : .bigint()
3919 : .min(BigInt('-9223372036854775808'), {
3920 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3921 : })
3922 : .max(BigInt('9223372036854775807'), {
3923 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3924 : })
3925 : .optional(),
3926 : expires_at: z.iso.datetime(),
3927 : headers: z.record(z.string(), z.string()),
3928 : max_size_bytes: z.coerce
3929 : .bigint()
3930 : .min(BigInt('-9223372036854775808'), {
3931 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3932 : })
3933 : .max(BigInt('9223372036854775807'), {
3934 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3935 : }),
3936 : method: z.enum(['PUT']),
3937 : upload_analytics_version: z.int().optional(),
3938 : upload_id: z.uuid(),
3939 : upload_mode: z.enum(['resumable']).optional(),
3940 : upload_url: z.string()
3941 : })
3942 :
3943 2356 : export const zModelUploadTransferReport = z.object({
3944 : client: z.string(),
3945 : model_folder: z.string(),
3946 : reason: z.enum([
3947 : 'network',
3948 : 'http',
3949 : 'session_expired',
3950 : 'file_changed',
3951 : 'file_unreadable',
3952 : 'canceled',
3953 : 'unknown'
3954 : ]),
3955 : resumed: z.boolean().optional(),
3956 : size_bytes: z.coerce.bigint().gte(BigInt(1)).lte(BigInt(26843545600))
3957 : })
3958 :
3959 : /**
3960 : * The next charge to the card on file, as Stripe's invoice preview reported it, after proration, discounts, tax and account credit.
3961 : */
3962 2356 : export const zNextCharge = z.object({
3963 : amount: z.coerce
3964 : .bigint()
3965 : .min(BigInt('-9223372036854775808'), {
3966 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
3967 : })
3968 : .max(BigInt('9223372036854775807'), {
3969 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
3970 : }),
3971 : currency: z.string(),
3972 : date: z.iso.datetime(),
3973 : reflects_scheduled_change: z.boolean()
3974 : })
3975 :
3976 : /**
3977 : * Metadata describing a single ComfyUI node type and its inputs/outputs.
3978 : */
3979 2356 : export const zNodeInfo = z.object({
3980 : api_node: z.boolean().optional(),
3981 : category: z.string().optional(),
3982 : deprecated: z.boolean().optional(),
3983 : description: z.string().optional(),
3984 : display_name: z.string().optional(),
3985 : experimental: z.boolean().optional(),
3986 : input: z.record(z.string(), z.unknown()).optional(),
3987 : input_order: z.record(z.string(), z.array(z.string())).optional(),
3988 : name: z.string().optional(),
3989 : output: z.array(z.string()).optional(),
3990 : output_is_list: z.array(z.boolean()).optional(),
3991 : output_name: z.array(z.string()).optional(),
3992 : output_node: z.boolean().optional(),
3993 : output_tooltips: z.array(z.string()).optional(),
3994 : python_module: z.string().optional()
3995 : })
3996 :
3997 : /**
3998 : * OAuth 2.1 authorization-server metadata (RFC 8414).
3999 : */
4000 2356 : export const zOAuthAuthorizationServerMetadata = z.object({
4001 : authorization_endpoint: z.url(),
4002 : code_challenge_methods_supported: z.array(z.string()),
4003 : grant_types_supported: z.array(z.string()),
4004 : issuer: z.url(),
4005 : jwks_uri: z.url(),
4006 : registration_endpoint: z.url().optional(),
4007 : response_types_supported: z.array(z.string()),
4008 : scopes_supported: z.array(z.string()).optional(),
4009 : token_endpoint: z.url(),
4010 : token_endpoint_auth_methods_supported: z.array(z.string())
4011 : })
4012 :
4013 : /**
4014 : * Redirect target produced after a JSON consent submission. The frontend must navigate the browser to this URL so custom-scheme client callbacks work without relying on fetch-visible 302 headers.
4015 : */
4016 2356 : export const zOAuthAuthorizeRedirectResponse = z.object({
4017 : redirect_url: z.url()
4018 : })
4019 :
4020 : /**
4021 : * One workspace option presented in the OAuth consent challenge. Promoted to a named schema so the generated Go type is referenceable in handlers and tests rather than re-declared as an anonymous struct at every callsite.
4022 : *
4023 : */
4024 2356 : export const zOAuthConsentChallengeWorkspace = z.object({
4025 : id: z.string(),
4026 : name: z.string(),
4027 : role: z.enum(['owner', 'member']),
4028 : type: z.enum(['personal', 'team'])
4029 : })
4030 :
4031 : /**
4032 : * The platform this authorization code will be delivered to, when the
4033 : * request's validated redirect_uri is one of a known platform's own OAuth
4034 : * callbacks (ChatGPT, Claude, Cursor). Derived server-side ONLY from the
4035 : * redirect_uri this request was byte-matched against at GET time —
4036 : * never from the registrant-supplied client_name — against a
4037 : * version-controlled registry of exact callbacks and anchored callback
4038 : * patterns (no host-only or prefix matching). Present only on `dynamic`
4039 : * clients; omitted for first-party clients and for any redirect that is
4040 : * not a registered platform callback. It verifies the destination
4041 : * platform, NOT that the registrant is that platform's own app (any
4042 : * connector on the platform can hold such a callback, and any local
4043 : * process can listen on Cursor's loopback callback or claim its
4044 : * `cursor://` scheme), so consumers should label it by `display_name`
4045 : * and still show the redirect host.
4046 : * `client_display_name` is unchanged and remains registrant-supplied.
4047 : *
4048 : */
4049 2356 : export const zOAuthConsentVerifiedClient = z.object({
4050 : display_name: z.string(),
4051 : platform: z.enum(['chatgpt', 'claude', 'cursor'])
4052 : })
4053 :
4054 : /**
4055 : * Server-side state describing the OAuth consent decision the user is being asked to make. Returned by GET /oauth/authorize when a valid Cloud session exists; the frontend renders the consent UI from this payload and POSTs the decision back. Browser never sees the original OAuth params on resume.
4056 : *
4057 : */
4058 2356 : export const zOAuthConsentChallenge = z.object({
4059 : client_display_name: z.string(),
4060 : client_provenance: z.enum(['first_party', 'dynamic']),
4061 : csrf_token: z.string(),
4062 : oauth_request_id: z.uuid(),
4063 : redirect_uri: z.url(),
4064 : resource_display_name: z.string(),
4065 : scopes: z.array(z.string()),
4066 : verified_client: zOAuthConsentVerifiedClient.optional(),
4067 : workspaces: z.array(zOAuthConsentChallengeWorkspace)
4068 : })
4069 :
4070 : /**
4071 : * OAuth 2.1 protected-resource metadata (RFC 9728).
4072 : */
4073 2356 : export const zOAuthProtectedResourceMetadata = z.object({
4074 : authorization_servers: z.array(z.url()),
4075 : bearer_methods_supported: z.array(z.string()).optional(),
4076 : resource: z.url(),
4077 : scopes_supported: z.array(z.string())
4078 : })
4079 :
4080 : /**
4081 : * RFC 7591 §3.2.2 error response.
4082 : */
4083 2356 : export const zOAuthRegisterError = z.object({
4084 : error: z.enum(['invalid_redirect_uri', 'invalid_client_metadata']),
4085 : error_description: z.string().nullish()
4086 : })
4087 :
4088 : /**
4089 : * RFC 7591 §2 client metadata document. Fields fall into three groups: the ones the server honors, the purely informational ones it accepts and ignores (`scope` plus the client-profile fields `client_uri`, `logo_uri`, `tos_uri`, `policy_uri`, `contacts`, `software_id`, `software_version` — parsed, never persisted, never echoed, per RFC 7591 §2's "MAY ignore" allowance), and the ones it rejects with `invalid_client_metadata` (`resource_grants`, because scopes/grants are server-owned for dynamic clients; `jwks`/`jwks_uri`, because they only apply to the JWT client-authentication methods DCR does not offer). `additionalProperties: false` mirrors the runtime middleware that rejects any unknown metadata key.
4090 : *
4091 : */
4092 2356 : export const zOAuthRegisterRequest = z.object({
4093 : application_type: z.enum(['native', 'web']).optional(),
4094 : client_name: z.string().max(100).optional(),
4095 : client_uri: z.string().nullish(),
4096 : contacts: z.array(z.string()).nullish(),
4097 : grant_types: z
4098 : .array(z.enum(['authorization_code', 'refresh_token']))
4099 : .optional(),
4100 : jwks: z.record(z.string(), z.unknown()).nullish(),
4101 : jwks_uri: z.string().nullish(),
4102 : logo_uri: z.string().nullish(),
4103 : policy_uri: z.string().nullish(),
4104 : redirect_uris: z.array(z.string()).min(1).max(5),
4105 : resource_grants: z.record(z.string(), z.array(z.string())).nullish(),
4106 : response_types: z.array(z.enum(['code'])).optional(),
4107 : scope: z.string().nullish(),
4108 : software_id: z.string().nullish(),
4109 : software_version: z.string().nullish(),
4110 : token_endpoint_auth_method: z.string().optional(),
4111 : tos_uri: z.string().nullish()
4112 : })
4113 :
4114 : /**
4115 : * RFC 7591 §3.2.1 successful registration response.
4116 : */
4117 2356 : export const zOAuthRegisterResponse = z.object({
4118 : application_type: z.enum(['native', 'web']),
4119 : client_id: z.string(),
4120 : client_id_issued_at: z.coerce
4121 : .bigint()
4122 : .min(BigInt('-9223372036854775808'), {
4123 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4124 : })
4125 : .max(BigInt('9223372036854775807'), {
4126 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4127 : }),
4128 : client_name: z.string().optional(),
4129 : grant_types: z.array(z.string()),
4130 : redirect_uris: z.array(z.string()),
4131 : response_types: z.array(z.string()),
4132 : token_endpoint_auth_method: z.enum(['none'])
4133 : })
4134 :
4135 : /**
4136 : * RFC 6749 §5.2 error response.
4137 : */
4138 2356 : export const zOAuthTokenError = z.object({
4139 : error: z.string(),
4140 : error_description: z.string().optional()
4141 : })
4142 :
4143 : /**
4144 : * RFC 6749 §5.1 successful token response.
4145 : */
4146 2356 : export const zOAuthTokenResponse = z.object({
4147 : access_token: z.string(),
4148 : expires_in: z.int(),
4149 : refresh_token: z.string(),
4150 : scope: z.string(),
4151 : token_type: z.enum(['Bearer'])
4152 : })
4153 :
4154 : /**
4155 : * Pagination metadata included in list responses. Supports both legacy
4156 : * offset/limit pagination and cursor-based pagination. When cursor-based
4157 : * pagination is used, `next_cursor` is the primary pagination token and
4158 : * `offset`/`total` may be zero.
4159 : *
4160 : */
4161 2356 : export const zPaginationInfo = z.object({
4162 : has_more: z.boolean(),
4163 : limit: z.int().gte(1),
4164 : next_cursor: z.string().optional(),
4165 : offset: z.int().gte(0),
4166 : total: z.int().gte(0)
4167 : })
4168 :
4169 : /**
4170 : * A paginated page of the caller's agent threads.
4171 : */
4172 2356 : export const zAgentThreadListResponse = z.object({
4173 : pagination: zPaginationInfo,
4174 : threads: z.array(zAgentThreadSummary)
4175 : })
4176 :
4177 : /**
4178 : * Paginated list of the assets produced by a single job.
4179 : */
4180 2356 : export const zJobAssetsResponse = z.object({
4181 : assets: z.array(zJobOutputAsset),
4182 : job_id: z.uuid(),
4183 : pagination: zPaginationInfo
4184 : })
4185 :
4186 : /**
4187 : * Paginated list of jobs for the authenticated user.
4188 : */
4189 2356 : export const zJobsListResponse = z.object({
4190 : jobs: z.array(zJobEntry),
4191 : pagination: zPaginationInfo
4192 : })
4193 :
4194 : /**
4195 : * Request body for generating a payment portal session URL.
4196 : */
4197 2356 : export const zPaymentPortalRequest = z.object({
4198 : flow_type: z.enum(['', 'payment_method_update']).optional(),
4199 : return_url: z.string().optional()
4200 : })
4201 :
4202 : /**
4203 : * Response containing a redirect URL to the payment portal.
4204 : */
4205 2356 : export const zPaymentPortalResponse = z.object({
4206 : url: z.string()
4207 : })
4208 :
4209 : /**
4210 : * An outstanding workspace invitation that has not yet been accepted.
4211 : */
4212 2356 : export const zPendingInvite = z.object({
4213 : email: z.email(),
4214 : expires_at: z.iso.datetime(),
4215 : id: z.string(),
4216 : invited_at: z.iso.datetime(),
4217 : token: z.string().optional()
4218 : })
4219 :
4220 : /**
4221 : * List of pending invitations for the current workspace.
4222 : */
4223 2356 : export const zListInvitesResponse = z.object({
4224 : invites: z.array(zPendingInvite)
4225 : })
4226 :
4227 : /**
4228 : * Which developer-platform deployment this browser should run on.
4229 : */
4230 2356 : export const zPickWorkspaceDeploymentRequest = z.object({
4231 : deployment_id: z.string()
4232 : })
4233 :
4234 : /**
4235 : * Action for this exact plan and billing interval. Render as received. Subscribe starts or resumes checkout, change changes the plan now, reactivate removes a scheduled cancellation, downgrade schedules a reduction at the billing boundary, and none disables the choice. This is presentation guidance, not authorization; writes recheck policy.
4236 : */
4237 2356 : export const zPlanAction = z.enum([
4238 : 'subscribe',
4239 : 'change',
4240 : 'reactivate',
4241 : 'downgrade',
4242 : 'none'
4243 : ])
4244 :
4245 : /**
4246 : * Why action is none. Permission refusals precede sales management, parked and running operations, a scheduled successor, transition restrictions, and seats. Scheduled successors include effective_at in denied_reason_params. Unknown or unavailable state fails closed with billing_state_unknown. Absent for an actionable choice.
4247 : */
4248 2356 : export const zPlanActionDeniedReason = z.enum([
4249 : 'not_a_member',
4250 : 'not_workspace_owner',
4251 : 'not_original_owner',
4252 : 'sales_managed',
4253 : 'billing_operation_parked',
4254 : 'billing_operation_in_progress',
4255 : 'subscription_change_in_progress',
4256 : 'annual_to_monthly_unsupported',
4257 : 'same_plan',
4258 : 'incompatible_transition',
4259 : 'exceeds_max_seats',
4260 : 'billing_state_unknown'
4261 : ])
4262 :
4263 2356 : export const zPlanActionDeniedReasonParams = z.object({
4264 : effective_at: z.iso.datetime().optional()
4265 : })
4266 :
4267 : /**
4268 : * Why a plan is unavailable. Present exactly when available is false and
4269 : * absent when it is true. Only the first reason that applies is reported,
4270 : * in the order below. Render the value as received; do not recompute it.
4271 : * same_plan: (a) Why can this plan not be picked? (b) It is the plan the workspace is already on. (c) Absent means the plan is not the current one. (d) Not a refusal of a different plan; see incompatible_transition. (e) The plan slug equals the slug of the workspace's active subscription.
4272 : * incompatible_transition: (a) Why is this plan closed for the workspace's current plan? (b) The transition rules never allow it: the Free plan, which is provisioned only through free-tier eligibility, or a switch into the Founders plan. (c) Absent means no such rule applies. (d) Not a temporary state, and not billing_operation_in_progress, billing_operation_parked or annual_to_monthly_unsupported. (e) The target is the Free plan, or the transition matrix refuses the pair for a reason other than annual_to_monthly_unsupported.
4273 : * billing_operation_in_progress: (a) Why can no other plan be picked for now? (b) A subscription-changing billing operation is running for the workspace's active subscription. It settles on its own, so a client may say that plans will be available again shortly. (c) Absent means no such operation is running. (d) Not billing_operation_parked, which does not clear on its own, not a successor already scheduled for a future billing boundary, and not a seat problem. (e) The workspace has a non-scheduled active subscription and a subscription-changing billing operation is running and none is parked.
4274 : * billing_operation_parked: (a) Why can no other plan be picked until support steps in? (b) A subscription-changing billing operation is parked for reconciliation for the workspace's active subscription: it is either paid but credits not granted, or a replacement subscription that could not finish superseding the old one. It does not clear on its own, so a client must route the user to support and never imply a wait. (c) Absent means no operation is parked. (d) Not billing_operation_in_progress, which settles on its own, not a successor already scheduled for a future billing boundary, and not a seat problem. (e) The workspace has a non-scheduled active subscription and a subscription-changing billing operation is parked; reported instead of billing_operation_in_progress when both exist.
4275 : * annual_to_monthly_unsupported: (a) Why can a monthly plan not be chosen from an annual plan? (b) The annual commitment binds, so a move to a higher-tier monthly plan is not supported before the term ends. (c) Absent means the transition is not an annual to higher-tier monthly move. (d) Not a downgrade, which is allowed and scheduled, and not incompatible_transition. (e) The transition matrix refuses the pair with its annual-to-monthly tier upgrade rule.
4276 : * exceeds_max_seats: (a) Why is this plan closed to a workspace with many people? (b) The occupied seats exceed the plan's seat limit, counted as the subscribe request counts them: a team plan counts members plus unexpired pending invitations, any other plan counts members alone. (c) Absent means the occupied seats fit the plan. (d) Not a pending-invitation count for non-team plans, where an invitation does not occupy a seat. (e) For a team plan, members + pending invitations is greater than the seat limit; for any other plan, members is greater than the seat limit; a positive workspace override replaces the plan default in both cases.
4277 : * requires_team and requires_personal are part of this enum but are not reported today.
4278 : */
4279 2356 : export const zPlanAvailabilityReason = z.enum([
4280 : 'same_plan',
4281 : 'incompatible_transition',
4282 : 'billing_operation_in_progress',
4283 : 'billing_operation_parked',
4284 : 'annual_to_monthly_unsupported',
4285 : 'exceeds_max_seats',
4286 : 'requires_team',
4287 : 'requires_personal'
4288 : ])
4289 :
4290 : /**
4291 : * Availability and eligibility information for a billing plan.
4292 : */
4293 2356 : export const zPlanAvailability = z.object({
4294 : available: z.boolean(),
4295 : reason: zPlanAvailabilityReason.optional()
4296 : })
4297 :
4298 2356 : export const zPlanFeatureItem = z.object({
4299 : key: z.enum([
4300 : 'shortRuntime',
4301 : 'longRuntime',
4302 : 'addCredits',
4303 : 'importModels',
4304 : 'sharedCreditPool',
4305 : 'membersUpTo',
4306 : 'perMemberCreditLimits',
4307 : 'memberSpendAuditing',
4308 : 'sharedWorkflowsAssets',
4309 : 'projects'
4310 : ]),
4311 : params: z
4312 : .object({
4313 : count: z.coerce
4314 : .bigint()
4315 : .gte(BigInt(1))
4316 : .max(BigInt('9223372036854775807'), {
4317 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4318 : })
4319 : })
4320 : .optional(),
4321 : status: z.enum(['available', 'coming_soon']),
4322 : text: z.string()
4323 : })
4324 :
4325 : /**
4326 : * Summary of seat costs based on current workspace members
4327 : */
4328 2356 : export const zPlanSeatSummary = z.object({
4329 : seat_count: z.int(),
4330 : total_cost_cents: z.coerce
4331 : .bigint()
4332 : .min(BigInt('-9223372036854775808'), {
4333 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4334 : })
4335 : .max(BigInt('9223372036854775807'), {
4336 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4337 : }),
4338 : total_credits_cents: z.coerce
4339 : .bigint()
4340 : .min(BigInt('-9223372036854775808'), {
4341 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4342 : })
4343 : .max(BigInt('9223372036854775807'), {
4344 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4345 : })
4346 : })
4347 :
4348 : /**
4349 : * Request body for previewing the cost of a plan subscription change.
4350 : */
4351 2356 : export const zPreviewSubscribeRequest = z.object({
4352 : checkout_attempt_id: z.string().optional(),
4353 : plan_slug: z.string(),
4354 : promotion_code: z.string().optional(),
4355 : team_credit_stop_id: z.string().optional()
4356 : })
4357 :
4358 : /**
4359 : * Identity of the workspace-bound terminal subscription, not a checkout target or permission to resubscribe. Historical identity is independent of current plan availability and pricing.
4360 : */
4361 2356 : export const zPreviousPlan = z.object({
4362 : plan_slug: z.string(),
4363 : team_credit_stop_id: z.string().optional()
4364 : })
4365 :
4366 : /**
4367 : * Error response for ComfyUI prompt execution.
4368 : */
4369 2356 : export const zPromptErrorResponse = z.record(z.string(), z.unknown())
4370 :
4371 : /**
4372 : * Metadata about the currently running and queued prompts.
4373 : */
4374 2356 : export const zPromptInfo = z.object({
4375 : exec_info: z
4376 : .object({
4377 : queue_remaining: z.int().optional()
4378 : })
4379 : .optional()
4380 : })
4381 :
4382 : /**
4383 : * One validation error as ComfyUI reports it, with tracebacks and every other field removed. type, message and details are each present only when ComfyUI sent them as strings.
4384 : */
4385 2356 : export const zPromptOutputsSkippedValidationError = z.object({
4386 : details: z.string().optional(),
4387 : extra_info: z
4388 : .object({
4389 : input_name: z.union([z.string(), z.number(), z.boolean()]).optional(),
4390 : received_type: z.union([z.string(), z.number(), z.boolean()]).optional(),
4391 : received_value: z.union([z.string(), z.number(), z.boolean()]).optional()
4392 : })
4393 : .optional(),
4394 : message: z.string().optional(),
4395 : type: z.string().optional()
4396 : })
4397 :
4398 : /**
4399 : * One rejected node in a prompt_outputs_skipped event.
4400 : */
4401 2356 : export const zPromptOutputsSkippedNodeError = z.object({
4402 : class_type: z.string(),
4403 : dependent_outputs: z.array(z.string()),
4404 : errors: z.array(z.union([z.string(), zPromptOutputsSkippedValidationError]))
4405 : })
4406 :
4407 : /**
4408 : * The `data` of a prompt_outputs_skipped WebSocket event. Sent when ComfyUI accepts a Cloud job's prompt but rejects some nodes: ComfyUI skips the outputs that depend on them and runs the rest, and the job keeps running. The inference server sends it to the user's channel (services/inference/server/services/joborchestrator/prompt_validation.go). Every string taken from ComfyUI has its lists of allowed values or file names replaced ("is not a valid value", "[list omitted]") and is capped at 512 characters.
4409 : */
4410 2356 : export const zPromptOutputsSkippedData = z.object({
4411 : node_errors: z.record(z.string(), zPromptOutputsSkippedNodeError),
4412 : prompt_id: z.string()
4413 : })
4414 :
4415 : /**
4416 : * Server-to-client prompt_outputs_skipped frame on /ws. ComfyUI skipped some of a Cloud job's outputs because nodes failed validation.
4417 : */
4418 2356 : export const zPromptOutputsSkippedFrame = z.object({
4419 : data: zPromptOutputsSkippedData,
4420 : type: z.enum(['prompt_outputs_skipped'])
4421 : })
4422 :
4423 : /**
4424 : * Request body for submitting a ComfyUI workflow prompt for execution.
4425 : */
4426 2356 : export const zPromptRequest = z.object({
4427 : extra_data: z.record(z.string(), z.unknown()).optional(),
4428 : front: z.boolean().optional(),
4429 : number: z.number().optional(),
4430 : partial_execution_targets: z.array(z.string()).optional(),
4431 : prompt: z.record(z.string(), z.unknown()),
4432 : workflow_id: z.string().optional(),
4433 : workflow_version_id: z.string().optional()
4434 : })
4435 :
4436 : /**
4437 : * Response returned after successfully queuing a workflow prompt.
4438 : */
4439 2356 : export const zPromptResponse = z.object({
4440 : node_errors: z.record(z.string(), z.unknown()).optional(),
4441 : number: z.number().optional(),
4442 : prompt_id: z.uuid().optional()
4443 : })
4444 :
4445 : /**
4446 : * The partner-provider governance catalog: every governable provider, identical for all workspaces. A projection of the curated catalog minus the internal api_names.
4447 : */
4448 2356 : export const zProviderCatalogResponse = z.object({
4449 : providers: z.array(zCatalogProvider)
4450 : })
4451 :
4452 : /**
4453 : * One provider's policy state.
4454 : */
4455 2356 : export const zProviderPolicyEntry = z.object({
4456 : enabled: z.boolean(),
4457 : provider_id: z.string()
4458 : })
4459 :
4460 : /**
4461 : * A workspace's partner-provider governance policy document — the exact shape PUT accepts (round-trips; entries come back sorted by provider_id, write order is not significant). Effective rule: enabled(P) = !enforcement_enabled || (the entry for P has enabled=true); absent from the array = unset (deny when enforcing).
4462 : */
4463 2356 : export const zProviderPolicy = z.object({
4464 : enforcement_enabled: z.boolean(),
4465 : providers: z.array(zProviderPolicyEntry)
4466 : })
4467 :
4468 : /**
4469 : * Request body for publishing or updating a workflow on the Hub.
4470 : */
4471 2356 : export const zPublishHubWorkflowRequest = z.object({
4472 : asset_ids: z.array(z.string()),
4473 : custom_nodes: z.array(z.string()).optional(),
4474 : description: z.string().optional(),
4475 : metadata: z.record(z.string(), z.unknown()).optional(),
4476 : models: z.array(z.string()).optional(),
4477 : name: z.string(),
4478 : sample_image_tokens_or_urls: z.array(z.string()).optional(),
4479 : tags: z.array(z.string()).optional(),
4480 : thumbnail_comparison_token_or_url: z.string().optional(),
4481 : thumbnail_token_or_url: z.string().optional(),
4482 : thumbnail_type: z.enum(['image', 'video', 'image_comparison']).optional(),
4483 : tutorial_url: z.string().optional(),
4484 : username: z.string(),
4485 : workflow_filename: z.string()
4486 : })
4487 :
4488 : /**
4489 : * Request body for publishing workflow assets to the Hub.
4490 : */
4491 2356 : export const zPublishWorkflowAssetsRequest = z.object({
4492 : asset_ids: z.array(z.string())
4493 : })
4494 :
4495 : /**
4496 : * Full detail of a publicly published workflow on the Hub.
4497 : */
4498 2356 : export const zPublishedWorkflowDetail = z.object({
4499 : assets: z.array(zAssetInfo),
4500 : listed: z.boolean(),
4501 : name: z.string(),
4502 : publish_time: z.iso.datetime().nullish(),
4503 : share_id: z.string(),
4504 : workflow_id: z.string(),
4505 : workflow_json: z.record(z.string(), z.unknown())
4506 : })
4507 :
4508 : /**
4509 : * Queue information with pending and running jobs
4510 : */
4511 2356 : export const zQueueInfo = z.object({
4512 : queue_pending: z
4513 : .array(
4514 : z.tuple([z.unknown(), z.unknown(), z.unknown(), z.unknown(), z.unknown()])
4515 : )
4516 : .optional(),
4517 : queue_running: z
4518 : .array(
4519 : z.tuple([z.unknown(), z.unknown(), z.unknown(), z.unknown(), z.unknown()])
4520 : )
4521 : .optional()
4522 : })
4523 :
4524 : /**
4525 : * Request to manage queue operations
4526 : */
4527 2356 : export const zQueueManageRequest = z.object({
4528 : clear: z.boolean().optional(),
4529 : delete: z.array(z.string()).optional()
4530 : })
4531 :
4532 : /**
4533 : * Response after a queue management action (delete or clear).
4534 : */
4535 2356 : export const zQueueManageResponse = z.object({
4536 : cleared: z.boolean().optional(),
4537 : deleted: z.array(z.string()).optional()
4538 : })
4539 :
4540 : /**
4541 : * A 429 body with a fixed message and no machine-readable code.
4542 : */
4543 2356 : export const zRateLimitExceededError = z.object({
4544 : error: z.string()
4545 : })
4546 :
4547 : /**
4548 : * One declared pack that failed to import on the Release's build, as comfy-builder names it.
4549 : */
4550 2356 : export const zReleaseUnsupportedPack = z.object({
4551 : cause: z.string(),
4552 : folder: z.string(),
4553 : registry_id: z.string(),
4554 : repository: z.string()
4555 : })
4556 :
4557 : /**
4558 : * The declared packs that failed to import on the build of the editor's Release, in the order the build declared them, and which Release that is.
4559 : */
4560 2356 : export const zReleaseUnsupportedPacks = z.object({
4561 : packs: z.array(zReleaseUnsupportedPack),
4562 : release_id: z.string().nullable()
4563 : })
4564 :
4565 : /**
4566 : * The newest open renewal invoice of the workspace's Stripe subscription (active, or canceled but not yet ended). Returned only to workspace owners on the stripe billing rail while billing_status is payment_failed or paused, and not while a payment for it is processing. hosted_invoice_url is a bearer payment link.
4567 : */
4568 2356 : export const zRenewalInvoice = z.object({
4569 : amount_due: z.coerce
4570 : .bigint()
4571 : .min(BigInt('-9223372036854775808'), {
4572 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4573 : })
4574 : .max(BigInt('9223372036854775807'), {
4575 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4576 : }),
4577 : currency: z.string(),
4578 : hosted_invoice_url: z.string(),
4579 : next_payment_attempt: z.iso.datetime().optional()
4580 : })
4581 :
4582 : /**
4583 : * Request body for reactivating a previously cancelled subscription.
4584 : */
4585 2356 : export const zResubscribeRequest = z.object({
4586 : idempotency_key: z.string().optional()
4587 : })
4588 :
4589 : /**
4590 : * Response after accepting a resubscribe request.
4591 : */
4592 2356 : export const zResubscribeResponse = z.object({
4593 : billing_op_id: z.string(),
4594 : message: z.string().optional(),
4595 : status: z.enum(['active', 'pending'])
4596 : })
4597 :
4598 2356 : export const zRetentionAcceptRequest = z.object({
4599 : session_id: z.uuid()
4600 : })
4601 :
4602 2356 : export const zRetentionAcceptance = z.object({
4603 : billing_op_id: z.string(),
4604 : status: z.enum(['pending', 'succeeded'])
4605 : })
4606 :
4607 2356 : export const zRetentionFlowEventRequest = z.object({
4608 : event: z.enum(['flow_opened', 'offer_shown']),
4609 : session_id: z.uuid()
4610 : })
4611 :
4612 2356 : export const zRetentionFlowSubscription = z.object({
4613 : currency: z.string(),
4614 : period_end: z.int().lte(9007199254740991),
4615 : quantity: z.int().lte(9007199254740991),
4616 : unit_amount: z.int().lte(9007199254740991)
4617 : })
4618 :
4619 : /**
4620 : * Present only when the session's arm is an offer. Terms come from the server catalog.
4621 : */
4622 2356 : export const zRetentionOffer = z.object({
4623 : duration_in_months: z.int().lte(9007199254740991),
4624 : id: z.string(),
4625 : percent_off: z.int().lte(9007199254740991)
4626 : })
4627 :
4628 2356 : export const zRetentionFlowResponse = z.object({
4629 : experiment_variant: z.string().optional(),
4630 : expires_at: z.int().lte(9007199254740991),
4631 : offer: zRetentionOffer.optional(),
4632 : session_id: z.uuid(),
4633 : subscription: zRetentionFlowSubscription
4634 : })
4635 :
4636 : /**
4637 : * Request body for undoing a pending scheduled plan change.
4638 : */
4639 2356 : export const zRevertScheduledChangeRequest = z.object({
4640 : idempotency_key: z.string().optional()
4641 : })
4642 :
4643 : /**
4644 : * Response after accepting a scheduled-change revert.
4645 : */
4646 2356 : export const zRevertScheduledChangeResponse = z.object({
4647 : billing_op_id: z.string(),
4648 : status: z.enum(['reverted', 'pending'])
4649 : })
4650 :
4651 : /**
4652 : * Response after signing out of all devices
4653 : */
4654 2356 : export const zRevokeAllSessionsResponse = z.object({
4655 : revoked: z.int()
4656 : })
4657 :
4658 2356 : export const zSsoDiscoverResponse = z.object({
4659 : organization_name: z.string().optional(),
4660 : required: z.boolean().optional(),
4661 : sso: z.boolean()
4662 : })
4663 :
4664 2356 : export const zSavedPaymentMethod = z.object({
4665 : bank_name: z.string().optional(),
4666 : brand: z.string().optional(),
4667 : created_at: z.iso.datetime().optional(),
4668 : email: z.string().optional(),
4669 : exp_month: z.int().gte(1).lte(12).optional(),
4670 : exp_year: z.int().gte(1000).lte(9999).optional(),
4671 : expired: z.boolean().optional(),
4672 : expiring_soon: z.boolean().optional(),
4673 : id: z.string().regex(/^pm_/),
4674 : is_default: z.boolean(),
4675 : last4: z
4676 : .string()
4677 : .regex(/^[0-9]{4}$/)
4678 : .optional(),
4679 : type: z.string()
4680 : })
4681 :
4682 : /**
4683 : * A provider the user may configure a secret for, with its display label and credential-entry options.
4684 : */
4685 2356 : export const zSecretProvider = z.object({
4686 : credential_options: z.array(zCredentialOption).optional(),
4687 : id: z.string(),
4688 : label: z.string().optional()
4689 : })
4690 :
4691 : /**
4692 : * The providers available to the authenticated user in the current workspace.
4693 : */
4694 2356 : export const zSecretProvidersResponse = z.object({
4695 : data: z.array(zSecretProvider)
4696 : })
4697 :
4698 : /**
4699 : * User secret metadata (the secret value itself is never returned after creation).
4700 : */
4701 2356 : export const zSecretResponse = z.object({
4702 : created_at: z.iso.datetime(),
4703 : credential_type: z.enum(['api_key', 'gcp_service_account']).optional(),
4704 : id: z.uuid(),
4705 : last_used_at: z.iso.datetime().optional(),
4706 : name: z.string(),
4707 : provider: z.string().optional(),
4708 : updated_at: z.iso.datetime()
4709 : })
4710 :
4711 : /**
4712 : * List of user secrets with metadata only.
4713 : */
4714 2356 : export const zSecretListResponse = z.object({
4715 : data: z.array(zSecretResponse)
4716 : })
4717 :
4718 : /**
4719 : * Server-to-client CRDT document frame carried by the /ws envelope.
4720 : */
4721 2356 : export const zServerDocFrame = z.union([
4722 : zDocSubscribedFrame,
4723 : zDocUpdateFrame,
4724 : zDocResetFrame,
4725 : zDocOpsResultFrame
4726 : ])
4727 :
4728 : /**
4729 : * The deployment a start was asked for, and its status after the ask.
4730 : */
4731 2356 : export const zStartWorkspaceDeploymentResult = z.object({
4732 : deployment_id: z.string(),
4733 : status: z.string()
4734 : })
4735 :
4736 : /**
4737 : * A stored AgentConsentSettingValue with its timestamp. Named apart from the write schema because codegen derives nested property type names from the schema name, and `AgentConsentSetting` would generate an `AgentConsentSettingValue` that collides with the write schema itself.
4738 : */
4739 : export const zStoredAgentConsentSetting = zAgentConsentSettingValue.and(
4740 : zGlobalSettingUpdatedAt
4741 : )
4742 :
4743 : /**
4744 : * A stored setting: one GlobalSettingValue member plus when it last changed. Discriminated on `key` like GlobalSettingValue, so narrowing a read yields the same single value schema a write is typed by.
4745 : */
4746 2356 : export const zGlobalSetting = zStoredAgentConsentSetting
4747 :
4748 : /**
4749 : * Request body for subscribing a workspace to a billing plan.
4750 : */
4751 2356 : export const zSubscribeRequest = z.object({
4752 : billing_cycle: z.enum(['monthly', 'yearly']).optional(),
4753 : cancel_url: z.string().optional(),
4754 : checkout_attempt_id: z.string().optional(),
4755 : confirm_reactivation: z.boolean().optional(),
4756 : confirmation_token: z.string().optional(),
4757 : idempotency_key: z.string().optional(),
4758 : plan_slug: z.string(),
4759 : promotion_code: z.string().optional(),
4760 : proration_at: z.iso.datetime().optional(),
4761 : quote_id: z.string().optional(),
4762 : quote_version: z.int().optional(),
4763 : return_url: z.string().optional(),
4764 : saved_payment_method_id: z.string().regex(/^pm_/).optional(),
4765 : team_credit_stop_id: z.string().optional()
4766 : })
4767 :
4768 : /**
4769 : * Response after successfully subscribing to a billing plan.
4770 : */
4771 2356 : export const zSubscribeResponse = z.object({
4772 : billing_op_id: z.string(),
4773 : effective_at: z.iso.datetime().optional(),
4774 : payment_method_url: z.string().optional(),
4775 : status: z.enum(['subscribed', 'needs_payment_method', 'pending_payment'])
4776 : })
4777 :
4778 2356 : export const zSubscriptionDiscount = z.object({
4779 : amount_off_cents: z.coerce
4780 : .bigint()
4781 : .min(BigInt('-9223372036854775808'), {
4782 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4783 : })
4784 : .max(BigInt('9223372036854775807'), {
4785 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4786 : })
4787 : .optional(),
4788 : code: z.string(),
4789 : duration: z.enum(['once', 'repeating', 'forever']).optional(),
4790 : duration_in_months: z.coerce
4791 : .bigint()
4792 : .min(BigInt('-9223372036854775808'), {
4793 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4794 : })
4795 : .max(BigInt('9223372036854775807'), {
4796 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4797 : })
4798 : .optional(),
4799 : kind: z.enum(['plan', 'promotion']),
4800 : name: z.string().optional(),
4801 : term: z
4802 : .enum(['this_payment', 'first_month', 'first_year', 'months', 'ongoing'])
4803 : .optional()
4804 : })
4805 :
4806 : /**
4807 : * One deduction from today's charge. discount is the promotion in the
4808 : * quote's discount shape (kind promotion, without amount_off_cents; the
4809 : * amount is amount_cents), present exactly for promo_code and
4810 : * subscription_discount. Its duration_in_months is set only for
4811 : * promo_code: a carried promotion's remaining term is not the coupon's.
4812 : *
4813 : */
4814 2356 : export const zBillingOpChargeReason = z.object({
4815 : amount_cents: z.coerce
4816 : .bigint()
4817 : .min(BigInt('-9223372036854775808'), {
4818 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4819 : })
4820 : .max(BigInt('9223372036854775807'), {
4821 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4822 : }),
4823 : discount: zSubscriptionDiscount.optional(),
4824 : kind: z.enum(['promo_code', 'subscription_discount', 'account_balance'])
4825 : })
4826 :
4827 : /**
4828 : * Display only. Why a succeeded subscription operation charged other
4829 : * than its plan rate, read from the operation's paid Stripe invoice.
4830 : * Present only when that invoice collected more than zero and a
4831 : * promotion, the account balance or proration moved the charge off the
4832 : * plan rate; absent means no rows. Plan coupons (the annual or team
4833 : * commitment rate) are part of the rate and are never a reason. Never
4834 : * present for top-ups. Returned only to workspace billing managers,
4835 : * like amount_charged_cents.
4836 : *
4837 : */
4838 2356 : export const zBillingOpChargeBreakdown = z.object({
4839 : amount_charged_cents: z.coerce
4840 : .bigint()
4841 : .min(BigInt('-9223372036854775808'), {
4842 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4843 : })
4844 : .max(BigInt('9223372036854775807'), {
4845 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4846 : }),
4847 : currency: z.string(),
4848 : prorated: z.boolean(),
4849 : reasons: z.array(zBillingOpChargeReason)
4850 : })
4851 :
4852 : /**
4853 : * Billing period (uppercase to match comfy-api)
4854 : */
4855 2356 : export const zSubscriptionDuration = z.enum(['MONTHLY', 'ANNUAL'])
4856 :
4857 : /**
4858 : * Configured credit allowance of the current plan, not remaining balance, an invoice or proof of live provider grants. Amount includes credits and period; none is a proven configured zero. Native-empty or incoherent Enterprise configuration remains unknown, never none. Missing data and unresolved, unsupported, ended or activating plans remain unknown. Unknown or missing means unavailable; clients must not render zero. Does not change eligibility.
4859 : */
4860 2356 : export const zPeriodCreditGrant = z.object({
4861 : credits: z.coerce
4862 : .bigint()
4863 : .gte(BigInt(1))
4864 : .max(BigInt('9223372036854775807'), {
4865 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4866 : })
4867 : .optional(),
4868 : period: zSubscriptionDuration.optional(),
4869 : state: z.enum(['amount', 'none', 'unknown'])
4870 : })
4871 :
4872 : /**
4873 : * Owner-only customer-action recovery for the exact pending initial
4874 : * subscription blocking plan changes. This does not enable another plan
4875 : * purchase. Fetch GET /api/billing/ops/{billing_op_id} to resolve the
4876 : * existing authorized payment action. No payment URL or secret is included.
4877 : * Omitted when no safe action is known, including unavailable reads;
4878 : * omission must not be treated as payment success or completed recovery.
4879 : *
4880 : */
4881 2356 : export const zSubscriptionPaymentRecovery = z.object({
4882 : billing_op_id: z.string(),
4883 : reason: z.enum(['payment_required'])
4884 : })
4885 :
4886 : /**
4887 : * Server-owned subscription presentation state. A future scheduled plan change remains active, with its target in scheduled_change. Paused means a recoverable renewal collection failure; past_due requires direct subscription payment evidence, never an unattributed workspace or top-up failure. Activating means the initial subscription is awaiting payment. This is not an authorization or workflow admission decision; use capabilities.
4888 : */
4889 2356 : export const zSubscriptionState = z.enum([
4890 : 'never_subscribed',
4891 : 'active',
4892 : 'cancel_scheduled',
4893 : 'past_due',
4894 : 'paused',
4895 : 'activating',
4896 : 'ended'
4897 : ])
4898 :
4899 : /**
4900 : * Subscription tier (uppercase to match comfy-api)
4901 : */
4902 2356 : export const zSubscriptionTier = z.enum([
4903 : 'FREE',
4904 : 'STANDARD',
4905 : 'CREATOR',
4906 : 'PRO',
4907 : 'FOUNDERS_EDITION',
4908 : 'TEAM',
4909 : 'ENTERPRISE'
4910 : ])
4911 :
4912 : /**
4913 : * Display only. The plan the operation targets; for a scheduled change,
4914 : * the plan it switches to at period end. Present for plan changes,
4915 : * initial subscriptions and resubscribes in every status (pending,
4916 : * failed and succeeded alike), so a recovered pending operation can be
4917 : * labelled with its own plan. Absent when the target plan could not be
4918 : * resolved. Visible to any workspace member who can read the operation.
4919 : * tier and the price fields are absent when the server cannot describe
4920 : * the plan, as for the retired seat-based Team plans, whose rows carry a
4921 : * personal tier and whose price depends on the workspace's seats.
4922 : *
4923 : */
4924 2356 : export const zBillingOpReceiptPlan = z.object({
4925 : currency: z.string().optional(),
4926 : duration: zSubscriptionDuration,
4927 : monthly_price_cents: z.coerce
4928 : .bigint()
4929 : .min(BigInt('-9223372036854775808'), {
4930 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4931 : })
4932 : .max(BigInt('9223372036854775807'), {
4933 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4934 : })
4935 : .optional(),
4936 : price_cents: z.coerce
4937 : .bigint()
4938 : .min(BigInt('-9223372036854775808'), {
4939 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4940 : })
4941 : .max(BigInt('9223372036854775807'), {
4942 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4943 : })
4944 : .optional(),
4945 : slug: z.string(),
4946 : team_credit_stop_id: z.string().optional(),
4947 : tier: zSubscriptionTier.optional()
4948 : })
4949 :
4950 : /**
4951 : * Billing plan details including pricing, limits, and features.
4952 : */
4953 2356 : export const zPlan = z.object({
4954 : action: zPlanAction,
4955 : availability: zPlanAvailability,
4956 : credits: z.coerce
4957 : .bigint()
4958 : .min(BigInt('-9223372036854775808'), {
4959 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4960 : })
4961 : .max(BigInt('9223372036854775807'), {
4962 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4963 : })
4964 : .optional(),
4965 : credits_cents: z.coerce
4966 : .bigint()
4967 : .min(BigInt('-9223372036854775808'), {
4968 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4969 : })
4970 : .max(BigInt('9223372036854775807'), {
4971 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4972 : }),
4973 : denied_reason: zPlanActionDeniedReason.optional(),
4974 : denied_reason_params: zPlanActionDeniedReasonParams.optional(),
4975 : discount_percent: z.number().optional(),
4976 : duration: zSubscriptionDuration,
4977 : feature_items: z.array(zPlanFeatureItem).optional(),
4978 : features: z.array(z.string()).optional(),
4979 : list_price_cents: z.coerce
4980 : .bigint()
4981 : .min(BigInt('-9223372036854775808'), {
4982 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4983 : })
4984 : .max(BigInt('9223372036854775807'), {
4985 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4986 : })
4987 : .optional(),
4988 : max_seats: z.coerce
4989 : .bigint()
4990 : .min(BigInt('-9223372036854775808'), {
4991 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
4992 : })
4993 : .max(BigInt('9223372036854775807'), {
4994 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
4995 : }),
4996 : popular: z.boolean().optional(),
4997 : price_cents: z.coerce
4998 : .bigint()
4999 : .min(BigInt('-9223372036854775808'), {
5000 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5001 : })
5002 : .max(BigInt('9223372036854775807'), {
5003 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5004 : }),
5005 : seat_summary: zPlanSeatSummary,
5006 : slug: z.string(),
5007 : tier: zSubscriptionTier
5008 : })
5009 :
5010 : /**
5011 : * Plan information for preview display
5012 : */
5013 2356 : export const zPreviewPlanInfo = z.object({
5014 : credits_cents: z.coerce
5015 : .bigint()
5016 : .min(BigInt('-9223372036854775808'), {
5017 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5018 : })
5019 : .max(BigInt('9223372036854775807'), {
5020 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5021 : }),
5022 : duration: zSubscriptionDuration,
5023 : list_price_cents: z.coerce
5024 : .bigint()
5025 : .min(BigInt('-9223372036854775808'), {
5026 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5027 : })
5028 : .max(BigInt('9223372036854775807'), {
5029 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5030 : })
5031 : .optional(),
5032 : monthly_list_price_cents: z.coerce
5033 : .bigint()
5034 : .min(BigInt('-9223372036854775808'), {
5035 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5036 : })
5037 : .max(BigInt('9223372036854775807'), {
5038 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5039 : })
5040 : .optional(),
5041 : monthly_price_cents: z.coerce
5042 : .bigint()
5043 : .min(BigInt('-9223372036854775808'), {
5044 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5045 : })
5046 : .max(BigInt('9223372036854775807'), {
5047 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5048 : })
5049 : .optional(),
5050 : period_end: z.iso.datetime().optional(),
5051 : period_start: z.iso.datetime().optional(),
5052 : price_cents: z.coerce
5053 : .bigint()
5054 : .min(BigInt('-9223372036854775808'), {
5055 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5056 : })
5057 : .max(BigInt('9223372036854775807'), {
5058 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5059 : }),
5060 : seat_summary: zPlanSeatSummary,
5061 : slug: z.string(),
5062 : tier: zSubscriptionTier
5063 : })
5064 :
5065 : /**
5066 : * Itemized cost preview for a pending subscription change.
5067 : */
5068 2356 : export const zPreviewSubscribeResponse = z.object({
5069 : allowed: z.boolean(),
5070 : amount_due_cents: z.coerce
5071 : .bigint()
5072 : .min(BigInt('-9223372036854775808'), {
5073 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5074 : })
5075 : .max(BigInt('9223372036854775807'), {
5076 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5077 : })
5078 : .optional(),
5079 : balance_applied_cents: z.coerce
5080 : .bigint()
5081 : .min(BigInt('-9223372036854775808'), {
5082 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5083 : })
5084 : .max(BigInt('9223372036854775807'), {
5085 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5086 : })
5087 : .optional(),
5088 : cancel_at: z.iso.datetime().optional(),
5089 : cost_next_period_cents: z.coerce
5090 : .bigint()
5091 : .min(BigInt('-9223372036854775808'), {
5092 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5093 : })
5094 : .max(BigInt('9223372036854775807'), {
5095 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5096 : }),
5097 : cost_today_cents: z.coerce
5098 : .bigint()
5099 : .min(BigInt('-9223372036854775808'), {
5100 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5101 : })
5102 : .max(BigInt('9223372036854775807'), {
5103 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5104 : }),
5105 : credits_next_period: z.coerce
5106 : .bigint()
5107 : .min(BigInt('-9223372036854775808'), {
5108 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5109 : })
5110 : .max(BigInt('9223372036854775807'), {
5111 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5112 : })
5113 : .optional(),
5114 : credits_next_period_cents: z.coerce
5115 : .bigint()
5116 : .min(BigInt('-9223372036854775808'), {
5117 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5118 : })
5119 : .max(BigInt('9223372036854775807'), {
5120 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5121 : }),
5122 : credits_today: z.coerce
5123 : .bigint()
5124 : .min(BigInt('-9223372036854775808'), {
5125 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5126 : })
5127 : .max(BigInt('9223372036854775807'), {
5128 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5129 : })
5130 : .optional(),
5131 : credits_today_cents: z.coerce
5132 : .bigint()
5133 : .min(BigInt('-9223372036854775808'), {
5134 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5135 : })
5136 : .max(BigInt('9223372036854775807'), {
5137 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5138 : }),
5139 : currency: z.string().optional(),
5140 : current_plan: zPreviewPlanInfo.optional(),
5141 : discounts: z.array(zSubscriptionDiscount).optional(),
5142 : effective_at: z.iso.datetime(),
5143 : is_immediate: z.boolean(),
5144 : new_plan: zPreviewPlanInfo,
5145 : payment_method_configuration_id: z.string().optional(),
5146 : promotion_code: z.string().optional(),
5147 : proration_at: z.iso.datetime().optional(),
5148 : proration_remaining_cents: z.coerce
5149 : .bigint()
5150 : .min(BigInt('-9223372036854775808'), {
5151 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5152 : })
5153 : .max(BigInt('9223372036854775807'), {
5154 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5155 : })
5156 : .optional(),
5157 : proration_unused_cents: z.coerce
5158 : .bigint()
5159 : .min(BigInt('-9223372036854775808'), {
5160 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5161 : })
5162 : .max(BigInt('9223372036854775807'), {
5163 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5164 : })
5165 : .optional(),
5166 : quote_id: z.string().optional(),
5167 : quote_version: z.int().optional(),
5168 : reason: z.string().optional(),
5169 : renewal_amount_cents: z.coerce
5170 : .bigint()
5171 : .min(BigInt('-9223372036854775808'), {
5172 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5173 : })
5174 : .max(BigInt('9223372036854775807'), {
5175 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5176 : })
5177 : .optional(),
5178 : renewal_at: z.iso.datetime().optional(),
5179 : requires_reactivation_charge_confirmation: z.boolean().optional(),
5180 : requires_reactivation_confirmation: z.boolean().optional(),
5181 : subtotal_cents: z.coerce
5182 : .bigint()
5183 : .min(BigInt('-9223372036854775808'), {
5184 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5185 : })
5186 : .max(BigInt('9223372036854775807'), {
5187 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5188 : })
5189 : .optional(),
5190 : transition_type: z.enum([
5191 : 'new_subscription',
5192 : 'upgrade',
5193 : 'downgrade',
5194 : 'duration_change'
5195 : ])
5196 : })
5197 :
5198 : /**
5199 : * System statistics response
5200 : */
5201 2356 : export const zSystemStatsResponse = z.object({
5202 : devices: z.array(
5203 : z.object({
5204 : name: z.string(),
5205 : type: z.string(),
5206 : vram_free: z.number().optional(),
5207 : vram_total: z.number().optional()
5208 : })
5209 : ),
5210 : system: z.object({
5211 : argv: z.array(z.string()),
5212 : cloud_version: z.string().optional(),
5213 : comfyui_frontend_version: z.string().optional(),
5214 : comfyui_version: z.string(),
5215 : deploy_environment: z.string().optional(),
5216 : embedded_python: z.boolean(),
5217 : os: z.string(),
5218 : python_version: z.string(),
5219 : pytorch_version: z.string(),
5220 : ram_free: z.number(),
5221 : ram_total: z.number(),
5222 : workflow_templates_version: z.string().optional()
5223 : })
5224 : })
5225 :
5226 : /**
5227 : * Metadata for a single tag that can be applied to assets.
5228 : */
5229 2356 : export const zTagInfo = z.object({
5230 : count: z.int(),
5231 : name: z.string()
5232 : })
5233 :
5234 : /**
5235 : * Paginated list of available asset tags.
5236 : */
5237 2356 : export const zListTagsResponse = z.object({
5238 : has_more: z.boolean(),
5239 : tags: z.array(zTagInfo),
5240 : total: z.int()
5241 : })
5242 :
5243 : /**
5244 : * Response after adding, updating, or removing tags on an asset.
5245 : */
5246 2356 : export const zTagsModificationResponse = z.object({
5247 : added: z.array(z.string()).optional(),
5248 : already_present: z.array(z.string()).optional(),
5249 : not_present: z.array(z.string()).optional(),
5250 : removed: z.array(z.string()).optional(),
5251 : total_tags: z.array(z.string())
5252 : })
5253 :
5254 : /**
5255 : * Task data for list views
5256 : */
5257 2356 : export const zTaskEntry = z.object({
5258 : completed_at: z.iso.datetime().optional(),
5259 : create_time: z.iso.datetime(),
5260 : id: z.uuid(),
5261 : started_at: z.iso.datetime().optional(),
5262 : status: z.enum(['created', 'running', 'completed', 'failed', 'cancelled']),
5263 : task_name: z.string()
5264 : })
5265 :
5266 : /**
5267 : * Full task details including payload and result
5268 : */
5269 2356 : export const zTaskResponse = z.object({
5270 : completed_at: z.iso.datetime().optional(),
5271 : create_time: z.iso.datetime(),
5272 : error_message: z.string().optional(),
5273 : id: z.uuid(),
5274 : idempotency_key: z.string(),
5275 : payload: z.record(z.string(), z.unknown()),
5276 : result: z.record(z.string(), z.unknown()).optional(),
5277 : started_at: z.iso.datetime().optional(),
5278 : status: z.enum(['created', 'running', 'completed', 'failed', 'cancelled']),
5279 : task_name: z.string(),
5280 : update_time: z.iso.datetime()
5281 : })
5282 :
5283 : /**
5284 : * Paginated list of background tasks for the authenticated user.
5285 : */
5286 2356 : export const zTasksListResponse = z.object({
5287 : pagination: zPaginationInfo,
5288 : tasks: z.array(zTaskEntry)
5289 : })
5290 :
5291 : /**
5292 : * Pre/post-discount price for a team credit stop, in cents.
5293 : */
5294 2356 : export const zTeamCreditStopPrice = z.object({
5295 : action: zPlanAction,
5296 : denied_reason: zPlanActionDeniedReason.optional(),
5297 : denied_reason_params: zPlanActionDeniedReasonParams.optional(),
5298 : list_price_cents: z.coerce
5299 : .bigint()
5300 : .min(BigInt('-9223372036854775808'), {
5301 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5302 : })
5303 : .max(BigInt('9223372036854775807'), {
5304 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5305 : }),
5306 : period_charge_cents: z.coerce
5307 : .bigint()
5308 : .min(BigInt('-9223372036854775808'), {
5309 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5310 : })
5311 : .max(BigInt('9223372036854775807'), {
5312 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5313 : }),
5314 : price_cents: z.coerce
5315 : .bigint()
5316 : .min(BigInt('-9223372036854775808'), {
5317 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5318 : })
5319 : .max(BigInt('9223372036854775807'), {
5320 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5321 : })
5322 : })
5323 :
5324 : /**
5325 : * A selectable preset on the team pricing slider. Echoed on subscribe via
5326 : * team_credit_stop_id; the backend owns the resolved amounts. credits is a
5327 : * RAW monthly credit count (not cents). Save% is derived by the FE as
5328 : * (list_price_cents - price_cents) / list_price_cents.
5329 : *
5330 : */
5331 2356 : export const zTeamCreditStop = z.object({
5332 : credits: z.coerce
5333 : .bigint()
5334 : .min(BigInt('-9223372036854775808'), {
5335 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5336 : })
5337 : .max(BigInt('9223372036854775807'), {
5338 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5339 : }),
5340 : id: z.string(),
5341 : monthly: zTeamCreditStopPrice,
5342 : yearly: zTeamCreditStopPrice
5343 : })
5344 :
5345 : /**
5346 : * The team credit stop a workspace is currently subscribed to: the
5347 : * per-workspace slider choice recorded at subscribe time
5348 : * (workspace_subscriptions.team_credit_stop_id). Amounts are owned by the
5349 : * catalog, not the subscription row. Returned on GET /api/billing/status
5350 : * for per-credit Team plans (BE-1254).
5351 : *
5352 : */
5353 2356 : export const zTeamCreditStopSummary = z.object({
5354 : credits_monthly: z.coerce
5355 : .bigint()
5356 : .min(BigInt('-9223372036854775808'), {
5357 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5358 : })
5359 : .max(BigInt('9223372036854775807'), {
5360 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5361 : }),
5362 : id: z.string(),
5363 : stop_usd: z.coerce
5364 : .bigint()
5365 : .min(BigInt('-9223372036854775808'), {
5366 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5367 : })
5368 : .max(BigInt('9223372036854775807'), {
5369 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5370 : })
5371 : })
5372 :
5373 : /**
5374 : * A plan change persisted to take effect at a future billing boundary.
5375 : */
5376 2356 : export const zScheduledPlanChange = z.object({
5377 : effective_at: z.iso.datetime(),
5378 : plan_slug: z.string(),
5379 : team_credit_stop: zTeamCreditStopSummary.nullable()
5380 : })
5381 :
5382 : /**
5383 : * Current billing and subscription status for a workspace.
5384 : */
5385 2356 : export const zBillingStatusResponse = z.object({
5386 : action_url: z.string().optional(),
5387 : billing_rail: z.enum(['stripe']).optional(),
5388 : billing_status: zBillingStatus.optional(),
5389 : cancel_at: z.iso.datetime().optional(),
5390 : current_period_start: z.iso.datetime().optional(),
5391 : ended_at: z.iso.datetime().nullable(),
5392 : ended_at_unavailable_reason: z.enum(['not_recorded']).optional(),
5393 : has_funds: z.boolean(),
5394 : is_active: z.boolean(),
5395 : latest_subscription_op_id: z.string().optional(),
5396 : max_seats: z.int(),
5397 : next_charge: zNextCharge.nullable(),
5398 : next_credit_refill_at: z.iso.datetime().optional(),
5399 : occupied_seats: z.int(),
5400 : payment_intent_client_secret: z.string().optional(),
5401 : pending_billing_op_id: z.string().optional(),
5402 : pending_billing_op_type: z.enum(['subscription', 'topup']).optional(),
5403 : period_credit_grant: zPeriodCreditGrant.optional(),
5404 : plan_slug: z.string().optional(),
5405 : previous_plan: zPreviousPlan.optional(),
5406 : renewal_date: z.iso.datetime().optional(),
5407 : renewal_invoice: zRenewalInvoice.optional(),
5408 : scheduled_change: zScheduledPlanChange.nullable(),
5409 : scoped_effective_has_funds: z.record(z.string(), z.boolean()).optional(),
5410 : scoped_has_funds: z.record(z.string(), z.boolean()).optional(),
5411 : subscription_duration: zSubscriptionDuration.optional(),
5412 : subscription_payment_recovery: zSubscriptionPaymentRecovery.optional(),
5413 : subscription_state: zSubscriptionState.optional(),
5414 : subscription_status: z.enum(['active', 'ended', 'canceled']).optional(),
5415 : subscription_tier: zSubscriptionTier.optional(),
5416 : team_credit_stop: zTeamCreditStopSummary.nullable(),
5417 : usage_period_end: z.iso.datetime().optional(),
5418 : usage_period_start: z.iso.datetime().optional()
5419 : })
5420 :
5421 : /**
5422 : * Credit-stop ladder for the pricing slider (BE-1254). Returned by GET /api/billing/plans for every workspace regardless of the caller's token or workspace type (the personal/team distinction was removed); omitted only when the catalog defines no stops.
5423 : */
5424 2356 : export const zTeamCreditStops = z.object({
5425 : default_stop_index: z.int(),
5426 : stops: z.array(zTeamCreditStop)
5427 : })
5428 :
5429 : /**
5430 : * List of available billing plans for subscription.
5431 : */
5432 2356 : export const zBillingPlansResponse = z.object({
5433 : current_plan_slug: z.string().optional(),
5434 : plans: z.array(zPlan),
5435 : subscription_payment_recovery: zSubscriptionPaymentRecovery.optional(),
5436 : team_credit_stops: zTeamCreditStops.optional()
5437 : })
5438 :
5439 : /**
5440 : * One persisted tool call attached to an assistant message's content.tool_calls (services/agent/internal/persist.ToolCallSummary), so a chat reload can render the tool-call history a turn produced. Display data only — raw arguments/results are never projected here. The optional produced_asset field is a strict exception containing only the server-recorded id/hash from a successful asset-producing media call. Only terminal rows (status ok/error) are ever surfaced; a row a dead turn left in pending/running has no wire-status mapping and is dropped rather than shown as a perpetual-progress chip.
5441 : * This object is projected at read time by services/agent/internal/persist.ToolCallsForThread from agent_tool_calls; it is never stored in agent_messages.content, so there is no legacy persisted shape. Because of that projection the contract holds for every row ever served: tool_call_id is always present (it falls back to id for rows written before the column existed), status is always one of the enum values (the audit-table word "ok" is translated by ToolCallWireStatus), and duration_ms is always an integer when present. Clients (the frontend's zPersistedToolCallSummary) must not relax these fields to parse "historical" rows — a row that fails this schema is a server bug (BE-20134).
5442 : */
5443 2356 : export const zToolCallSummary = z.object({
5444 : duration_ms: z.int().optional(),
5445 : error_code: z.string().optional(),
5446 : finished_at: z.iso.datetime().optional(),
5447 : id: z.string(),
5448 : job_id: z.string().optional(),
5449 : produced_asset: z
5450 : .object({
5451 : hash: z.string(),
5452 : id: z.string()
5453 : })
5454 : .optional(),
5455 : started_at: z.iso.datetime().optional(),
5456 : status: z.enum(['success', 'error']),
5457 : tool_call_id: z.string(),
5458 : tool_name: z.string()
5459 : })
5460 :
5461 : /**
5462 : * A persisted message in an agent thread.
5463 : */
5464 2356 : export const zAgentMessage = z.object({
5465 : content: z
5466 : .object({
5467 : attachment_refs: z
5468 : .array(
5469 : z.object({
5470 : display_name: z.string().optional(),
5471 : id: z.string().optional(),
5472 : kind: z.string().optional(),
5473 : name: z.string().optional()
5474 : })
5475 : )
5476 : .optional(),
5477 : thinking: z.array(zAgentThinkingEntry).optional(),
5478 : tool_calls: z.array(zToolCallSummary).optional()
5479 : })
5480 : .optional(),
5481 : id: z.string(),
5482 : pending_ask: zAgentPendingAsk.optional(),
5483 : role: z.enum(['user', 'assistant', 'tool', 'system']),
5484 : seq: z.int(),
5485 : status: z.enum(['streaming', 'complete', 'error', 'interrupted']),
5486 : thread_id: z.string(),
5487 : turn_id: z.string(),
5488 : workflow_id: z.string().optional()
5489 : })
5490 :
5491 : /**
5492 : * Requested credit purchase from this operation's validated stored interactive top-up intent. Visible only to callers authorized for payment details. Not the amount charged or proof of payment. Omitted for historical, non-interactive, invalid or non-top-up operations.
5493 : *
5494 : */
5495 2356 : export const zTopUpPurchaseAmount = z.object({
5496 : amount_cents: z.coerce
5497 : .bigint()
5498 : .gte(BigInt(1))
5499 : .max(BigInt('9223372036854775807'), {
5500 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5501 : }),
5502 : currency: z.enum(['usd'])
5503 : })
5504 :
5505 : /**
5506 : * Status of an asynchronous billing operation.
5507 : */
5508 2356 : export const zBillingOpStatusResponse = z.object({
5509 : action_url: z.string().optional(),
5510 : amount_charged_cents: z.coerce
5511 : .bigint()
5512 : .min(BigInt('-9223372036854775808'), {
5513 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5514 : })
5515 : .max(BigInt('9223372036854775807'), {
5516 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5517 : })
5518 : .optional(),
5519 : authentication_deadline: z.iso.datetime().optional(),
5520 : authentication_state: z
5521 : .enum([
5522 : 'requires_action',
5523 : 'processing',
5524 : 'failed_retryable',
5525 : 'succeeded',
5526 : 'reconciliation_needed'
5527 : ])
5528 : .optional(),
5529 : auto_top_up: zAcceptedAutoTopUpSettings.optional(),
5530 : auto_top_up_activation: zAutoTopUpActivation.optional(),
5531 : auto_top_up_activation_reason: zAutoTopUpActivationReason.optional(),
5532 : cancelable: z.boolean().optional(),
5533 : charge_breakdown: zBillingOpChargeBreakdown.optional(),
5534 : checkout_state: z
5535 : .enum([
5536 : 'unfinished',
5537 : 'verify_payment',
5538 : 'processing',
5539 : 'payment_received',
5540 : 'failed',
5541 : 'none'
5542 : ])
5543 : .optional(),
5544 : completed_at: z.iso.datetime().optional(),
5545 : credits_added: z.coerce
5546 : .bigint()
5547 : .min(BigInt('-9223372036854775808'), {
5548 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5549 : })
5550 : .max(BigInt('9223372036854775807'), {
5551 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5552 : })
5553 : .optional(),
5554 : decline_reason: z
5555 : .enum([
5556 : 'card_declined',
5557 : 'insufficient_funds',
5558 : 'expired_card',
5559 : 'incorrect_cvc',
5560 : 'authentication_required',
5561 : 'authentication_failed',
5562 : 'processing_error',
5563 : 'payment_not_completed',
5564 : 'generic'
5565 : ])
5566 : .optional(),
5567 : error_message: z.string().optional(),
5568 : id: z.string(),
5569 : payment_intent_client_secret: z.string().optional(),
5570 : phase: z
5571 : .enum([
5572 : 'awaiting_payment_method',
5573 : 'awaiting_invoice_payment',
5574 : 'in_progress'
5575 : ])
5576 : .optional(),
5577 : plan: zBillingOpReceiptPlan.optional(),
5578 : recovery_action: z
5579 : .enum([
5580 : 'retry',
5581 : 'replace_payment_method',
5582 : 'authenticate_payment',
5583 : 'contact_support'
5584 : ])
5585 : .optional(),
5586 : retryable: z.boolean().optional(),
5587 : started_at: z.iso.datetime(),
5588 : status: z.enum(['pending', 'succeeded', 'failed', 'reconciliation_needed']),
5589 : topup_purchase_amount: zTopUpPurchaseAmount.optional()
5590 : })
5591 :
5592 : /**
5593 : * Turns auto top-up on after this purchase's payment succeeds; the server does it, so never follow with PUT /api/billing/auto-reload. Absent leaves auto top-up unchanged. Owner who may manage auto top-up only. Hosted checkout shows a $0.00 "Auto top-up" line and consent covering future top-ups.
5594 : * PUT /api/billing/auto-reload's enabled-save rules apply before anything is charged (400 INVALID_AUTO_TOP_UP); 400 AUTO_TOP_UP_NOT_ELIGIBLE when setup is unavailable or frozen except for a missing default card; 400 AUTO_TOP_UP_NOT_AVAILABLE when first enrollment is outside the rollout.
5595 : * Auto top-up charges the default card. With none, the paid card is saved off-session and becomes the default; an existing default is kept and a new card is not saved. On the interactive route a new card's confirmation token must use setup_future_usage off_session exactly when there is no default card.
5596 : * A replay with other settings is refused. The outcome is auto_top_up_activation on the checkout read (hosted) or GET /api/billing/ops/{id} (interactive).
5597 : *
5598 : */
5599 2356 : export const zTopupAutoTopUpSettings = z.object({
5600 : monthly_budget_cents: z.coerce
5601 : .bigint()
5602 : .min(BigInt('-9223372036854775808'), {
5603 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5604 : })
5605 : .max(BigInt('9223372036854775807'), {
5606 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5607 : })
5608 : .nullish(),
5609 : target_credits: z.coerce
5610 : .bigint()
5611 : .min(BigInt('-9223372036854775808'), {
5612 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5613 : })
5614 : .max(BigInt('9223372036854775807'), {
5615 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5616 : }),
5617 : threshold_credits: z.coerce
5618 : .bigint()
5619 : .min(BigInt('-9223372036854775808'), {
5620 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5621 : })
5622 : .max(BigInt('9223372036854775807'), {
5623 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5624 : })
5625 : })
5626 :
5627 : /**
5628 : * Request body for creating a hosted credit top-up checkout session.
5629 : */
5630 2356 : export const zCreateTopupCheckoutRequest = z.object({
5631 : amount_cents: z.coerce.bigint().gte(BigInt(500)).lte(BigInt(250000)),
5632 : auto_top_up: zTopupAutoTopUpSettings.optional(),
5633 : idempotency_key: z.string().optional(),
5634 : return_url: z.url()
5635 : })
5636 :
5637 : /**
5638 : * Pay once with exactly one new-card confirmation token or explicitly selected attached card. Keep the exact request and key on retry; never fall back to the on-file route.
5639 : */
5640 2356 : export const zInteractiveTopupRequest = z.object({
5641 : amount_cents: z.coerce.bigint().gte(BigInt(500)).lte(BigInt(99999999)),
5642 : auto_top_up: zTopupAutoTopUpSettings.optional(),
5643 : checkout_attempt_id: z.string().optional(),
5644 : confirmation_token: z.string().min(1).max(255).optional(),
5645 : idempotency_key: z.string().min(1).max(255),
5646 : make_default: z.boolean().optional().default(false),
5647 : return_url: z.string().min(1).max(2048).optional(),
5648 : save_payment_method: z.boolean().optional().default(false),
5649 : saved_payment_method_id: z.string().min(1).max(255).optional()
5650 : })
5651 :
5652 : /**
5653 : * What a credit top-up of the requested amount would grant.
5654 : */
5655 2356 : export const zTopupQuoteResponse = z.object({
5656 : amount_cents: z.coerce
5657 : .bigint()
5658 : .min(BigInt('-9223372036854775808'), {
5659 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5660 : })
5661 : .max(BigInt('9223372036854775807'), {
5662 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5663 : }),
5664 : credits: z.coerce
5665 : .bigint()
5666 : .min(BigInt('-9223372036854775808'), {
5667 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5668 : })
5669 : .max(BigInt('9223372036854775807'), {
5670 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5671 : }),
5672 : expires_at: z.iso.datetime(),
5673 : payment_method_configuration_id: z.string().optional()
5674 : })
5675 :
5676 : /**
5677 : * Request body for updating an existing Hub profile.
5678 : */
5679 2356 : export const zUpdateHubProfileRequest = z.object({
5680 : avatar_token: z.string().nullish(),
5681 : description: z.string().optional(),
5682 : display_name: z.string().optional(),
5683 : website_urls: z.array(z.string()).optional()
5684 : })
5685 :
5686 : /**
5687 : * Request body for changing a workspace member's role.
5688 : */
5689 2356 : export const zUpdateMemberRoleRequest = z.object({
5690 : role: z.enum(['owner', 'member'])
5691 : })
5692 :
5693 : /**
5694 : * Request body for updating an existing user secret.
5695 : */
5696 2356 : export const zUpdateSecretRequest = z.object({
5697 : name: z.string().min(1).max(255).optional(),
5698 : secret_value: z.string().min(1).optional()
5699 : })
5700 :
5701 : /**
5702 : * Request body for updating an existing saved workflow.
5703 : */
5704 2356 : export const zUpdateWorkflowRequest = z.object({
5705 : default_view: z.enum(['workflow', 'app']).optional(),
5706 : description: z.string().optional(),
5707 : name: z.string().optional()
5708 : })
5709 :
5710 : /**
5711 : * Request body for updating an existing workspace's settings.
5712 : */
5713 2356 : export const zUpdateWorkspaceRequest = z.object({
5714 : name: z.string().min(1).max(100).optional()
5715 : })
5716 :
5717 : /**
5718 : * A minted single-use upload grant.
5719 : */
5720 2356 : export const zUploadGrantResponse = z.object({
5721 : expires_in: z.int(),
5722 : upload_path: z.string()
5723 : })
5724 :
5725 : /**
5726 : * Current remaining balance, mirroring /billing/balance. Every amount is CENTS of `currency`; the `*_micros` names are a misnomer kept for wire compatibility.
5727 : */
5728 2356 : export const zUsageBalance = z.object({
5729 : amount_cents: z.number().optional(),
5730 : amount_micros: z.number().optional(),
5731 : cloud_credit_balance_cents: z.number().optional(),
5732 : cloud_credit_balance_micros: z.number().optional(),
5733 : currency: z.string().optional(),
5734 : prepaid_balance_cents: z.number().optional(),
5735 : prepaid_balance_micros: z.number().optional()
5736 : })
5737 :
5738 2356 : export const zUsageBreakdownRow = z.object({
5739 : cost_micros: z.number(),
5740 : group_key: z.string(),
5741 : run_count: z.coerce
5742 : .bigint()
5743 : .min(BigInt('-9223372036854775808'), {
5744 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5745 : })
5746 : .max(BigInt('9223372036854775807'), {
5747 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5748 : })
5749 : .optional(),
5750 : share: z.number()
5751 : })
5752 :
5753 2356 : export const zUsageBucket = z.object({
5754 : cost_micros: z.number(),
5755 : group_key: z.string(),
5756 : period_end: z.iso.datetime(),
5757 : period_start: z.iso.datetime()
5758 : })
5759 :
5760 2356 : export const zUsageGroupLabel = z.object({
5761 : cost_kind: z.enum(['gpu', 'storage']).optional(),
5762 : deployment_id: z.string().optional(),
5763 : deployment_name: z.string().optional(),
5764 : display_name: z.string().optional(),
5765 : email: z.string().optional(),
5766 : former_member: z.boolean().optional(),
5767 : key: z.string(),
5768 : key_name: z.string().optional(),
5769 : key_prefix: z.string().optional(),
5770 : key_revoked: z.boolean().optional(),
5771 : kind: z.enum(['api_key', 'session', 'deployment']).optional(),
5772 : owner_display_name: z.string().optional(),
5773 : owner_email: z.string().optional(),
5774 : owner_user_id: z.string().optional(),
5775 : provider: z.string().optional(),
5776 : provider_display_name: z.string().optional()
5777 : })
5778 :
5779 : /**
5780 : * Present, with empty groups, buckets and breakdown, when the requested grouping is not served for this workspace. Render as unavailable, not as zero spend.
5781 : */
5782 2356 : export const zUsageNotAvailable = z.object({
5783 : reason: z.enum(['no_attribution_source', 'filter_needs_ledger'])
5784 : })
5785 :
5786 : /**
5787 : * Mixed units, deliberately. `spend_micros` here (and `cost_micros` on UsageBucket / UsageBreakdownRow) is genuinely MICROS -- 1/1,000,000 of the currency unit -- because it comes from Metronome's usage figures. The `balance` breakdown below is CENTS, and its `*_micros` names are a misnomer; use its `*_cents` fields.
5788 : */
5789 2356 : export const zUsageSummary = z.object({
5790 : balance: zUsageBalance.optional(),
5791 : spend_micros: z.number()
5792 : })
5793 :
5794 2356 : export const zUsageTimeSeries = z.object({
5795 : as_of: z.iso.datetime().optional(),
5796 : attribution_since: z.iso.datetime().optional(),
5797 : breakdown: z.array(zUsageBreakdownRow),
5798 : buckets: z.array(zUsageBucket),
5799 : ending_before: z.iso.datetime(),
5800 : granularity: z.enum(['hour', 'day', 'month']),
5801 : group_by: z.enum([
5802 : 'model',
5803 : 'endpoint',
5804 : 'product',
5805 : 'product_line',
5806 : 'person',
5807 : 'source'
5808 : ]),
5809 : group_labels: z.array(zUsageGroupLabel).optional(),
5810 : groups: z.array(z.string()),
5811 : not_available: zUsageNotAvailable.optional(),
5812 : served_from: z.enum(['ledger', 'invoice']).optional(),
5813 : starting_on: z.iso.datetime(),
5814 : summary: zUsageSummary
5815 : })
5816 :
5817 : /**
5818 : * User data listing entry with file metadata (path, size, modification time).
5819 : */
5820 2356 : export const zUserDataResponseFull = z.object({
5821 : modified: z.coerce
5822 : .bigint()
5823 : .min(BigInt('-9223372036854775808'), {
5824 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5825 : })
5826 : .max(BigInt('9223372036854775807'), {
5827 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5828 : })
5829 : .optional(),
5830 : path: z.string().optional(),
5831 : size: z.int().optional()
5832 : })
5833 :
5834 : /**
5835 : * User information response
5836 : */
5837 2356 : export const zUserResponse = z.object({
5838 : id: z.string(),
5839 : status: z.string()
5840 : })
5841 :
5842 : /**
5843 : * Details of a single validation error encountered during asset operations.
5844 : */
5845 2356 : export const zValidationError = z.object({
5846 : code: z.string(),
5847 : field: z.string(),
5848 : message: z.string()
5849 : })
5850 :
5851 : /**
5852 : * Result of validating a set of asset operations.
5853 : */
5854 2356 : export const zValidationResult = z.object({
5855 : errors: z.array(zValidationError).optional(),
5856 : is_valid: z.boolean(),
5857 : warnings: z.array(zValidationError).optional()
5858 : })
5859 :
5860 : /**
5861 : * Metadata for a remotely hosted asset resolved by URL.
5862 : */
5863 2356 : export const zAssetMetadataResponse = z.object({
5864 : content_length: z.coerce
5865 : .bigint()
5866 : .min(BigInt('-9223372036854775808'), {
5867 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5868 : })
5869 : .max(BigInt('9223372036854775807'), {
5870 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5871 : }),
5872 : content_type: z.string().optional(),
5873 : filename: z.string().optional(),
5874 : name: z.string().optional(),
5875 : preview_image: z.string().optional(),
5876 : tags: z.array(z.string()).optional(),
5877 : validation: zValidationResult.optional()
5878 : })
5879 :
5880 : /**
5881 : * The signed link `GET /api/view?redirect=false` answers with: the same link the 302 sends in `Location`, so it expires like that one.
5882 : */
5883 2356 : export const zViewFileUrlResponse = z.object({
5884 : url: z.string()
5885 : })
5886 :
5887 : /**
5888 : * The user a web session belongs to
5889 : */
5890 2356 : export const zWebSessionUser = z.object({
5891 : email: z.string(),
5892 : email_verified: z.boolean(),
5893 : id: z.string(),
5894 : name: z.string().optional(),
5895 : sign_in_provider: z.string().optional()
5896 : })
5897 :
5898 : /**
5899 : * The live web session and the user it belongs to
5900 : */
5901 2356 : export const zWebSessionResponse = z.object({
5902 : absolute_expires_at: z.iso.datetime(),
5903 : csrf_token: z.string(),
5904 : expires_at: z.iso.datetime(),
5905 : has_personal_workspace: z.boolean(),
5906 : user: zWebSessionUser
5907 : })
5908 :
5909 : /**
5910 : * Request body for querying assets associated with a workflow.
5911 : */
5912 2356 : export const zWorkflowApiAssetsRequest = z.object({
5913 : workflow_api_json: z.record(z.string(), z.unknown())
5914 : })
5915 :
5916 : /**
5917 : * Response containing assets associated with a workflow.
5918 : */
5919 2356 : export const zWorkflowApiAssetsResponse = z.object({
5920 : assets: z.array(zAssetInfo)
5921 : })
5922 :
5923 : /**
5924 : * Reference to the parent workflow from which this workflow was forked.
5925 : */
5926 2356 : export const zWorkflowForkedFrom = z.object({
5927 : workflow_id: z.string().optional(),
5928 : workflow_version_id: z.string().optional()
5929 : })
5930 :
5931 : /**
5932 : * Publishing metadata for a workflow shared to the Hub.
5933 : */
5934 2356 : export const zWorkflowPublishInfo = z.object({
5935 : assets: z.array(zAssetInfo),
5936 : listed: z.boolean(),
5937 : publish_time: z.iso.datetime().nullish(),
5938 : share_id: z.string(),
5939 : workflow_id: z.string()
5940 : })
5941 :
5942 : /**
5943 : * Full workflow entity including metadata and version history.
5944 : */
5945 2356 : export const zWorkflowResponse = z.object({
5946 : created_at: z.iso.datetime(),
5947 : created_by: z.string(),
5948 : default_view: z.enum(['workflow', 'app']).optional(),
5949 : description: z.string().optional(),
5950 : forked_from: zWorkflowForkedFrom.optional(),
5951 : id: z.string(),
5952 : latest_version: z.int(),
5953 : name: z.string().optional(),
5954 : updated_at: z.iso.datetime()
5955 : })
5956 :
5957 : /**
5958 : * Paginated list of saved workflows.
5959 : */
5960 2356 : export const zWorkflowListResponse = z.object({
5961 : data: z.array(zWorkflowResponse),
5962 : pagination: zPaginationInfo
5963 : })
5964 :
5965 : /**
5966 : * The sidebar file a workflow was copied from, when the two agree. No content and no userdata id: open the path through the userdata API.
5967 : */
5968 2356 : export const zWorkflowSidebarFileResponse = z.object({
5969 : modified: z.coerce
5970 : .bigint()
5971 : .min(BigInt('-9223372036854775808'), {
5972 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
5973 : })
5974 : .max(BigInt('9223372036854775807'), {
5975 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
5976 : }),
5977 : path: z.string(),
5978 : size: z.int()
5979 : })
5980 :
5981 : /**
5982 : * Workflow metadata captured at mint time. The subsequent PUT body is the
5983 : * raw workflow JSON document and nothing else, so everything that would
5984 : * normally accompany workflow_json in POST /api/workflows is declared
5985 : * here instead.
5986 : *
5987 : */
5988 2356 : export const zWorkflowUploadUrlRequest = z.object({
5989 : default_view: z.enum(['workflow', 'app']).optional(),
5990 : description: z.string().max(2000).optional(),
5991 : forked_from_workflow_id: z.string().max(128).optional(),
5992 : forked_from_workflow_version_id: z.string().max(128).optional(),
5993 : name: z.string().max(255).optional()
5994 : })
5995 :
5996 : /**
5997 : * Full workflow version including the serialized workflow JSON.
5998 : */
5999 2356 : export const zWorkflowVersionContentResponse = z.object({
6000 : created_at: z.iso.datetime(),
6001 : created_by: z.string(),
6002 : dependency_asset_ids: z.array(z.string()).optional(),
6003 : id: z.string(),
6004 : version: z.int(),
6005 : workflow_json: z.record(z.string(), z.unknown())
6006 : })
6007 :
6008 : /**
6009 : * Metadata for a single workflow version.
6010 : */
6011 2356 : export const zWorkflowVersionResponse = z.object({
6012 : created_at: z.iso.datetime(),
6013 : created_by: z.string(),
6014 : id: z.string(),
6015 : latest_version: z.int(),
6016 : version: z.int()
6017 : })
6018 :
6019 : /**
6020 : * Full workspace entity with configuration and ownership details.
6021 : */
6022 2356 : export const zWorkspace = z.object({
6023 : created_at: z.iso.datetime(),
6024 : id: z.string(),
6025 : name: z.string(),
6026 : type: z.enum(['personal', 'team'])
6027 : })
6028 :
6029 : /**
6030 : * Metadata for a workspace-scoped API key (secret is never returned).
6031 : */
6032 2356 : export const zWorkspaceApiKeyInfo = z.object({
6033 : created_at: z.iso.datetime(),
6034 : description: z.string().max(5000),
6035 : expires_at: z.iso.datetime().optional(),
6036 : id: z.uuid(),
6037 : key_prefix: z.string(),
6038 : last_used_at: z.iso.datetime().optional(),
6039 : name: z.string(),
6040 : revoked_at: z.iso.datetime().optional(),
6041 : user_id: z.string(),
6042 : workspace_id: z.string()
6043 : })
6044 :
6045 : /**
6046 : * List of API keys associated with the current workspace.
6047 : */
6048 2356 : export const zListWorkspaceApiKeysResponse = z.object({
6049 : api_keys: z.array(zWorkspaceApiKeyInfo)
6050 : })
6051 :
6052 : /**
6053 : * Reasons creation is unavailable. Returned beside can_create_workspace false or on a creation refusal; first applicable reason wins.
6054 : */
6055 2356 : export const zWorkspaceCreationDenials = z.object({
6056 : can_create_workspace: z
6057 : .enum(['organization_managed', 'owned_workspace_limit'])
6058 : .optional()
6059 : })
6060 :
6061 : /**
6062 : * Standard error response with a machine-readable code and human-readable message.
6063 : */
6064 2356 : export const zErrorResponse = z.object({
6065 : code: z.string(),
6066 : denied_reasons: zWorkspaceCreationDenials.optional(),
6067 : details: z.record(z.string(), z.unknown()).optional(),
6068 : message: z.string(),
6069 : organization_id: z.string().optional()
6070 : })
6071 :
6072 : /**
6073 : * A 403 body: ErrorResponse, or AuthTypeNotAllowedError for a credential the route does not take.
6074 : */
6075 2356 : export const zForbiddenError = z.union([
6076 : zErrorResponse,
6077 : zAuthTypeNotAllowedError
6078 : ])
6079 :
6080 : /**
6081 : * A 400 from a media route served outside the generated wrapper: ErrorResponse, or MediaQueryError for a bad query parameter.
6082 : */
6083 2356 : export const zMediaBadRequestError = z.union([zErrorResponse, zMediaQueryError])
6084 :
6085 : /**
6086 : * Union of the two 400 shapes /oauth/register can emit. `OAuthRegisterError` is the handler-shaped RFC 7591 §3.2.2 error; `ErrorResponse` is the strict-server binding-layer error fired when the request body fails OpenAPI-schema validation before the handler runs, normalized to the standard {code, message} shape by the custom Echo HTTPErrorHandler (BE-1178).
6087 : *
6088 : */
6089 2356 : export const zOAuthRegisterBadRequestResponse = z.union([
6090 : zOAuthRegisterError,
6091 : zErrorResponse
6092 : ])
6093 :
6094 : /**
6095 : * Creation refused because the account has reached its live owner membership threshold for creation.
6096 : */
6097 2356 : export const zWorkspaceCreationLimitError = z.object({
6098 : code: z.enum(['OWNED_WORKSPACE_LIMIT']),
6099 : denied_reasons: zWorkspaceCreationDenials,
6100 : max_owned_workspaces: z.int(),
6101 : message: z.string()
6102 : })
6103 :
6104 : /**
6105 : * Present only for can_delete_workspace denied with plan_ending when all live subscription rows carry a known future cancel_at. This is guidance, not a promise that deletion will succeed at that time; writes recheck.
6106 : */
6107 2356 : export const zWorkspaceDeletionDenialParams = z.object({
6108 : effective_at: z.iso.datetime().optional()
6109 : })
6110 :
6111 : /**
6112 : * Optional facts for the matching denied_reasons key; absent facts are unknown and must not be inferred from other fields.
6113 : */
6114 2356 : export const zBillingCapabilityDenialParams = z.object({
6115 : can_delete_workspace: zWorkspaceDeletionDenialParams.optional()
6116 : })
6117 :
6118 : /**
6119 : * Effective billing UI guidance for one authenticated user and workspace.
6120 : */
6121 2356 : export const zBillingCapabilitiesResponse = z.object({
6122 : auto_top_up_enabled: z.boolean(),
6123 : auto_top_up_member_view: zAutoTopUpMemberView.optional(),
6124 : auto_top_up_setup: zAutoTopUpSetup.optional(),
6125 : billing_notice_audience: z.enum(['none', 'team', 'personal']).optional(),
6126 : billing_web_checkout_ui: z.enum(['embedded', 'full_page']),
6127 : cancel_takes_effect_immediately: z.boolean().optional(),
6128 : capabilities: zBillingCapabilities,
6129 : denied_reason_params: zBillingCapabilityDenialParams.optional(),
6130 : denied_reasons: zBillingCapabilityDenials.optional(),
6131 : ending_notice_starts_at: z.iso.datetime().optional(),
6132 : expires_at: z.iso.datetime(),
6133 : has_parked_billing_operation: z.boolean().optional(),
6134 : payment_recovery_available: z.boolean().optional(),
6135 : plan_kind: z.enum(['none', 'self_serve', 'sales_managed']).optional(),
6136 : primary_billing_action: z
6137 : .enum(['update_payment', 'subscribe', 'resubscribe', 'add_credits', 'none'])
6138 : .optional(),
6139 : recovery_route: z.enum(['none', 'resubscribe', 'contact_sales']).optional(),
6140 : resolved_for: zBillingCapabilityScope,
6141 : revision: z.coerce
6142 : .bigint()
6143 : .min(BigInt('-9223372036854775808'), {
6144 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
6145 : })
6146 : .lte(BigInt(9007199254740991)),
6147 : rollout_defaults_applied: zBillingCapabilityRolloutDefaults,
6148 : subscription_state_authoritative: z.boolean().optional()
6149 : })
6150 :
6151 : /**
6152 : * One live deployment of the workspace, as the editor's switcher shows it.
6153 : */
6154 2356 : export const zWorkspaceDeployment = z.object({
6155 : build_id: z.string().optional(),
6156 : build_name: z.string().optional(),
6157 : can_start: z.boolean(),
6158 : created_at: z.iso.datetime(),
6159 : deployment_id: z.string(),
6160 : deployment_name: z.string().optional(),
6161 : release_id: z.string(),
6162 : release_version: z.int().optional(),
6163 : status: z.enum([
6164 : 'queued',
6165 : 'provisioning',
6166 : 'starting',
6167 : 'ready',
6168 : 'unhealthy',
6169 : 'stopping',
6170 : 'stop_failed',
6171 : 'stopped',
6172 : 'failed'
6173 : ])
6174 : })
6175 :
6176 : /**
6177 : * Which step the CPU server of the deployment this browser's editor runs on is on.
6178 : */
6179 2356 : export const zWorkspaceDeploymentCpuServer = z.object({
6180 : cpu_server: z.enum(['none', 'creating', 'building', 'created']),
6181 : deployment_id: z.string().optional()
6182 : })
6183 :
6184 : /**
6185 : * The deployments a browser in this workspace may pick, newest first by created_at (always present). A row without a Build name keeps its place in that order.
6186 : */
6187 2356 : export const zWorkspaceDeploymentList = z.object({
6188 : builds_visible: z.boolean(),
6189 : default_deployment_id: z.string().optional(),
6190 : gone_default_deployment_id: z.string().optional(),
6191 : gone_picked_deployment_id: z.string().optional(),
6192 : items: z.array(zWorkspaceDeployment),
6193 : pick_source: z.enum(['browser', 'workspace_default']).optional(),
6194 : picked_deployment_id: z.string().optional()
6195 : })
6196 :
6197 : /**
6198 : * Per-member action guidance for the authenticated actor; render each field as received rather than deriving it from roles.
6199 : */
6200 2356 : export const zWorkspaceMemberCapabilities = z.object({
6201 : can_change_role: z.boolean(),
6202 : can_remove: z.boolean(),
6203 : can_set_credit_limit: z.boolean()
6204 : })
6205 :
6206 : /**
6207 : * Workspace member with profile and role information.
6208 : */
6209 2356 : export const zMember = z.object({
6210 : capabilities: zWorkspaceMemberCapabilities.optional(),
6211 : email: z.string(),
6212 : id: z.string(),
6213 : is_original_owner: z.boolean(),
6214 : joined_at: z.iso.datetime(),
6215 : managed_by_directory: z.boolean().optional(),
6216 : name: z.string(),
6217 : role: z.enum(['owner', 'member'])
6218 : })
6219 :
6220 : /**
6221 : * List of members in the current workspace.
6222 : */
6223 2356 : export const zListMembersResponse = z.object({
6224 : members: z.array(zMember),
6225 : pagination: zPaginationInfo
6226 : })
6227 :
6228 : /**
6229 : * Workspace-switcher display fact, not spend authorization or plan-action eligibility. Uses billing subscription-state precedence: ending, scheduled changes and activating display as active; renewal payment failures confirmed by the provider display as payment_due. Unknown or unavailable facts omit the entire summary; clients must not infer no_plan from omission.
6230 : */
6231 2356 : export const zWorkspacePlanSummary = z.object({
6232 : plan_name: z.string().nullable(),
6233 : status: z.enum(['active', 'no_plan', 'paused', 'payment_due', 'ended'])
6234 : })
6235 :
6236 : /**
6237 : * Abbreviated workspace metadata used in list responses.
6238 : */
6239 2356 : export const zWorkspaceSummary = z.object({
6240 : id: z.string(),
6241 : name: z.string(),
6242 : type: z.enum(['personal', 'team'])
6243 : })
6244 :
6245 : /**
6246 : * Response containing the issued Cloud JWT and its expiry.
6247 : */
6248 2356 : export const zExchangeTokenResponse = z.object({
6249 : expires_at: z.iso.datetime(),
6250 : permissions: z.array(z.string()),
6251 : role: z.enum(['owner', 'member']),
6252 : token: z.string(),
6253 : user_id: z.string(),
6254 : workspace: zWorkspaceSummary
6255 : })
6256 :
6257 : /**
6258 : * Workspace entity annotated with the requesting user's role.
6259 : */
6260 2356 : export const zWorkspaceWithRole = z.object({
6261 : created_at: z.iso.datetime(),
6262 : id: z.string(),
6263 : joined_at: z.iso.datetime(),
6264 : name: z.string(),
6265 : plan_summary: zWorkspacePlanSummary.optional(),
6266 : role: z.enum(['owner', 'member']),
6267 : subscription_tier: zSubscriptionTier.optional(),
6268 : type: z.enum(['personal', 'team'])
6269 : })
6270 :
6271 : /**
6272 : * Paginated list of workspaces the authenticated user belongs to.
6273 : */
6274 2356 : export const zListWorkspacesResponse = z.object({
6275 : can_create_workspace: z.boolean(),
6276 : default_workspace_id: z.string().optional(),
6277 : denied_reasons: zWorkspaceCreationDenials.optional(),
6278 : max_owned_workspaces: z.int(),
6279 : workspaces: z.array(zWorkspaceWithRole)
6280 : })
6281 :
6282 : /**
6283 : * Represents a user-owned asset (image, video, or other generated output).
6284 : */
6285 2356 : export const zAssetWritable = z.object({
6286 : created_at: z.iso.datetime(),
6287 : display_name: z.string().nullish(),
6288 : file_path: z.string().nullish(),
6289 : hash: z
6290 : .string()
6291 : .regex(/^blake3:[a-f0-9]{64}$/)
6292 : .optional(),
6293 : id: z.uuid(),
6294 : is_immutable: z.boolean().optional(),
6295 : job_id: z.uuid().nullish(),
6296 : last_access_time: z.iso.datetime().optional(),
6297 : loader_path: z.string().nullish(),
6298 : mime_type: z.string().optional(),
6299 : name: z.string(),
6300 : preview_id: z.uuid().nullish(),
6301 : preview_url: z.url().optional(),
6302 : short_url: z.string().nullish(),
6303 : size: z.coerce
6304 : .bigint()
6305 : .min(BigInt('-9223372036854775808'), {
6306 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
6307 : })
6308 : .max(BigInt('9223372036854775807'), {
6309 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
6310 : })
6311 : .optional(),
6312 : tags: z.array(z.string()).optional(),
6313 : updated_at: z.iso.datetime(),
6314 : user_metadata: z.record(z.string(), z.unknown()).optional()
6315 : })
6316 :
6317 : /**
6318 : * Response returned when a new asset is successfully created.
6319 : */
6320 2356 : export const zAssetCreatedWritable = zAssetWritable.and(
6321 : z.object({
6322 : created_new: z.boolean()
6323 : })
6324 : )
6325 :
6326 : /**
6327 : * One immutable save: the flat CCCJSON read plus the status of the catalog revision that holds it and its save time.
6328 : */
6329 2356 : export const zCccHistoryItemWritable = z.object({
6330 : catalog_status: z.enum(['draft', 'published', 'reverted', 'archived']),
6331 : saved_at: z.iso.datetime()
6332 : })
6333 :
6334 : /**
6335 : * One page of save history, newest edit_sequence first. next_cursor is present only when has_more is true. There is no total.
6336 : */
6337 2356 : export const zCccHistoryPageWritable = z.object({
6338 : has_more: z.boolean(),
6339 : items: z.array(zCccHistoryItemWritable),
6340 : next_cursor: z.string().optional()
6341 : })
6342 :
6343 : /**
6344 : * Paginated list of assets belonging to the authenticated user.
6345 : */
6346 2356 : export const zListAssetsResponseWritable = z.object({
6347 : assets: z.array(zAssetWritable),
6348 : has_more: z.boolean(),
6349 : next_cursor: z.string().optional(),
6350 : total: z.int()
6351 : })
6352 :
6353 : /**
6354 : * The workspace a media request reads from, where a media tag cannot
6355 : * send `X-Comfy-Workspace-ID`. It applies only while
6356 : * `web_session_enabled` is on for the user; with it off, and always on
6357 : * the `CookieAuth` cookie, it is ignored.
6358 : *
6359 : * On a `WebSessionAuth` request it selects the workspace: a workspace
6360 : * the user cannot access is 403 `workspace_access_denied`, and a
6361 : * malformed value, or one that disagrees with `X-Comfy-Workspace-ID`,
6362 : * is 400 `workspace_id_invalid`. A token or API key keeps its own
6363 : * workspace, and naming another is 400 `workspace_id_invalid`. A cookie
6364 : * request that names no workspace looks a filename up across all of the
6365 : * user's workspaces, and an asset id up in the personal one.
6366 : *
6367 : */
6368 2356 : export const zMediaWorkspaceId = z.string()
6369 :
6370 : /**
6371 : * JWKS response
6372 : */
6373 : export const zGetJwksResponse = zJwksResponse
6374 :
6375 : /**
6376 : * Authorization-server metadata
6377 : */
6378 : export const zGetOAuthAuthorizationServerResponse =
6379 : zOAuthAuthorizationServerMetadata
6380 :
6381 : /**
6382 : * Protected-resource metadata
6383 : */
6384 : export const zGetOAuthProtectedResourceResponse =
6385 : zOAuthProtectedResourceMetadata
6386 :
6387 2356 : export const zGetOAuthProtectedResourceByPathPath = z.object({
6388 : resourcePath: z.string().regex(/^[a-zA-Z0-9._-]+$/)
6389 : })
6390 :
6391 : /**
6392 : * Protected-resource metadata
6393 : */
6394 : export const zGetOAuthProtectedResourceByPathResponse =
6395 : zOAuthProtectedResourceMetadata
6396 :
6397 2356 : export const zGetCustomNodeProxyPath = z.object({
6398 : path: z.string()
6399 : })
6400 :
6401 2356 : export const zPostCustomNodeProxyPath = z.object({
6402 : path: z.string()
6403 : })
6404 :
6405 2356 : export const zAgentGetDraftQuery = z.object({
6406 : workflow_id: z.string()
6407 : })
6408 :
6409 : /**
6410 : * Current draft snapshot
6411 : */
6412 : export const zAgentGetDraftResponse = zAgentDraftSnapshot
6413 :
6414 2356 : export const zGetAgentEventsQuery = z.object({
6415 : token: z.string().optional(),
6416 : workspace_id: z.string().optional()
6417 : })
6418 :
6419 2356 : export const zAgentGetExecutionsQuery = z.object({
6420 : thread_id: z.uuid().optional(),
6421 : message_id: z.uuid().optional()
6422 : })
6423 :
6424 : /**
6425 : * Contract probe or the complete uncapped submission snapshot
6426 : */
6427 2356 : export const zAgentGetExecutionsResponse = z.object({
6428 : complete: z.boolean().optional(),
6429 : executions: z
6430 : .array(
6431 : z.object({
6432 : job_id: z.string().min(1),
6433 : paid: z.boolean().nullable(),
6434 : partner: z.boolean().nullable(),
6435 : status: z.string(),
6436 : submitted_at: z.iso.datetime()
6437 : })
6438 : )
6439 : .optional(),
6440 : message_id: z.string().optional(),
6441 : schema_version: z.enum(['agent-executions.v1']),
6442 : thread_id: z.string().optional(),
6443 : turn_id: z.string().optional()
6444 : })
6445 :
6446 : /**
6447 : * The caller's agent identity.
6448 : */
6449 : export const zAgentGetIdentityResponse = zAgentIdentity
6450 :
6451 2356 : export const zAgentLlmAdmitBody = z.object({
6452 : message_id: z.string().optional(),
6453 : step: z.int().gte(0),
6454 : turn_id: z.string()
6455 : })
6456 :
6457 : /**
6458 : * The admission verdict for the round.
6459 : */
6460 2356 : export const zAgentLlmAdmitResponse = z.object({
6461 : after_seconds: z.int().optional(),
6462 : kind: z.enum(['proceed', 'wait', 'pause', 'fail']),
6463 : message: z.string().optional(),
6464 : position: z.int().optional(),
6465 : reason: z.string().optional()
6466 : })
6467 :
6468 : /**
6469 : * Opaque Anthropic Messages request body, passed through to the upstream. Not modeled here — the agent's LLM proxy owns the contract.
6470 : */
6471 2356 : export const zAgentLlmMessagesBody = z.record(z.string(), z.unknown())
6472 :
6473 : /**
6474 : * The upstream LLM response, streamed back as Server-Sent Events (text/event-stream) chunk-by-chunk.
6475 : */
6476 2356 : export const zAgentLlmMessagesResponse = z.string()
6477 :
6478 : /**
6479 : * An OTLP ExportTraceServiceRequest, optionally gzip-encoded (Content-Encoding gzip); at most 4 MiB encoded and decoded, and 4096 spans.
6480 : */
6481 2356 : export const zAgentLlmTracesBody = z.string()
6482 :
6483 : /**
6484 : * Accepted; the body is an empty OTLP ExportTraceServiceResponse.
6485 : */
6486 2356 : export const zAgentLlmTracesResponse = z.string()
6487 :
6488 : /**
6489 : * The caller's run mode (the saved choice, or the default).
6490 : */
6491 : export const zAgentGetRunModeResponse = zAgentRunMode
6492 :
6493 : export const zAgentPutRunModeBody = zAgentRunModePutRequest
6494 :
6495 : /**
6496 : * The saved run mode.
6497 : */
6498 : export const zAgentPutRunModeResponse = zAgentRunMode
6499 :
6500 : /**
6501 : * The caller's skill packs.
6502 : */
6503 : export const zAgentListSkillsResponse = zAgentSkillListResponse
6504 :
6505 : export const zAgentPublishSkillBody = zAgentSkillPublishRequest
6506 :
6507 : /**
6508 : * An existing pack of the same name was replaced.
6509 : */
6510 : export const zAgentPublishSkillResponse = zAgentSkill
6511 :
6512 2356 : export const zAgentDeleteSkillPath = z.object({
6513 : name: z
6514 : .string()
6515 : .max(64)
6516 : .regex(/^[A-Za-z0-9._-]*[A-Za-z0-9_-][A-Za-z0-9._-]*$/)
6517 : })
6518 :
6519 : /**
6520 : * The pack was deleted.
6521 : */
6522 2356 : export const zAgentDeleteSkillResponse = z.void()
6523 :
6524 2356 : export const zAgentListThreadsQuery = z.object({
6525 : limit: z.int().gte(1).lte(100).optional().default(20),
6526 : after: z.string().optional(),
6527 : workflow_id: z.string().min(1).max(128).optional()
6528 : })
6529 :
6530 : /**
6531 : * A page of the caller's agent threads.
6532 : */
6533 : export const zAgentListThreadsResponse = zAgentThreadListResponse
6534 :
6535 : export const zAgentCreateThreadBody = zAgentThreadCreateRequest
6536 :
6537 : /**
6538 : * Thread created
6539 : */
6540 : export const zAgentCreateThreadResponse = zAgentThreadCreated
6541 :
6542 : export const zAgentAnswerAskBody = zAgentAnswerRequest
6543 :
6544 2356 : export const zAgentAnswerAskPath = z.object({
6545 : id: z.string(),
6546 : ask_id: z.string()
6547 : })
6548 :
6549 : /**
6550 : * Answer accepted; the turn resumes and streams over the WebSocket
6551 : */
6552 : export const zAgentAnswerAskResponse = zAgentAnswerAccepted
6553 :
6554 2356 : export const zAgentGetMessagesPath = z.object({
6555 : id: z.string()
6556 : })
6557 :
6558 : /**
6559 : * Messages in the thread, ordered by seq
6560 : */
6561 2356 : export const zAgentGetMessagesResponse = z.array(zAgentMessage)
6562 :
6563 : export const zAgentPostMessageBody = zAgentPostMessageRequest
6564 :
6565 2356 : export const zAgentPostMessagePath = z.object({
6566 : id: z.string()
6567 : })
6568 :
6569 : /**
6570 : * Turn accepted; the agent runs asynchronously and streams output over the WebSocket
6571 : */
6572 : export const zAgentPostMessageResponse = zAgentTurnAccepted
6573 :
6574 2356 : export const zAgentCancelMessagePath = z.object({
6575 : id: z.string(),
6576 : message_id: z.string()
6577 : })
6578 :
6579 : /**
6580 : * Cancellation requested; the terminal state arrives over the WebSocket
6581 : */
6582 : export const zAgentCancelMessageResponse = zAgentCancelAccepted
6583 :
6584 : /**
6585 : * Message usage for the authenticated user and workspace.
6586 : */
6587 : export const zAgentGetUsageStatusResponse = zAgentUsageStatusResponse
6588 :
6589 2356 : export const zListAssetsQuery = z.object({
6590 : include_tags: z.array(z.string()).optional(),
6591 : exclude_tags: z.array(z.string()).optional(),
6592 : tags_all: z.array(z.string()).optional(),
6593 : tags_any: z.array(z.string()).optional(),
6594 : tags_none: z.array(z.string()).optional(),
6595 : name_contains: z.string().optional(),
6596 : metadata_filter: z.string().optional(),
6597 : limit: z.int().gte(1).lte(500).optional().default(20),
6598 : offset: z.int().gte(0).optional().default(0),
6599 : sort: z
6600 : .enum(['name', 'created_at', 'updated_at', 'size', 'last_access_time'])
6601 : .optional()
6602 : .default('created_at'),
6603 : order: z.enum(['asc', 'desc']).optional().default('desc'),
6604 : include_public: z.boolean().optional().default(true),
6605 : workspace_library: z.boolean().optional().default(false),
6606 : hash: z.string().optional(),
6607 : after: z.string().optional(),
6608 : capped_total: z.boolean().optional().default(true),
6609 : include_total: z.boolean().optional().default(true)
6610 : })
6611 :
6612 : /**
6613 : * Success - Assets returned
6614 : */
6615 : export const zListAssetsResponse2 = zListAssetsResponse
6616 :
6617 2356 : export const zCreateAssetBody = z.object({
6618 : file: z.string(),
6619 : hash: z
6620 : .string()
6621 : .regex(/^(blake3|sha256):[a-f0-9]{64}$/)
6622 : .optional(),
6623 : id: z.uuid().optional(),
6624 : mime_type: z.string().optional(),
6625 : name: z.string().optional(),
6626 : preview_id: z.uuid().optional(),
6627 : tags: z.string().optional(),
6628 : user_metadata: z.string().optional()
6629 : })
6630 :
6631 : /**
6632 : * Asset already existed for this user (deduplicated by content hash); the
6633 : * existing asset is returned with created_new=false.
6634 : *
6635 : */
6636 : export const zCreateAssetResponse = zAssetCreated
6637 :
6638 2356 : export const zDeleteAssetPath = z.object({
6639 : id: z.uuid()
6640 : })
6641 :
6642 : /**
6643 : * Asset record deleted successfully
6644 : */
6645 2356 : export const zDeleteAssetResponse = z.void()
6646 :
6647 2356 : export const zGetAssetByIdPath = z.object({
6648 : id: z.uuid()
6649 : })
6650 :
6651 : /**
6652 : * Asset details retrieved successfully
6653 : */
6654 : export const zGetAssetByIdResponse = zAsset
6655 :
6656 2356 : export const zUpdateAssetBody = z.object({
6657 : mime_type: z.string().optional(),
6658 : name: z.string().optional(),
6659 : preview_id: z.uuid().optional(),
6660 : user_metadata: z.record(z.string(), z.unknown()).optional()
6661 : })
6662 :
6663 2356 : export const zUpdateAssetPath = z.object({
6664 : id: z.uuid()
6665 : })
6666 :
6667 : /**
6668 : * Asset updated successfully
6669 : */
6670 : export const zUpdateAssetResponse = zAssetUpdated
6671 :
6672 2356 : export const zGetAssetContentPath = z.object({
6673 : id: z.string()
6674 : })
6675 :
6676 2356 : export const zGetAssetContentQuery = z.object({
6677 : disposition: z
6678 : .enum(['inline', 'attachment'])
6679 : .optional()
6680 : .default('attachment'),
6681 : workspace_id: z.string().optional()
6682 : })
6683 :
6684 : /**
6685 : * Asset content stream (local runtime streams the bytes directly)
6686 : */
6687 2356 : export const zGetAssetContentResponse = z.string()
6688 :
6689 2356 : export const zRemoveAssetTagsBody = z.object({
6690 : tags: z.array(z.string()).min(1)
6691 : })
6692 :
6693 2356 : export const zRemoveAssetTagsPath = z.object({
6694 : id: z.uuid()
6695 : })
6696 :
6697 : /**
6698 : * Tags removed successfully
6699 : */
6700 : export const zRemoveAssetTagsResponse = zTagsModificationResponse
6701 :
6702 2356 : export const zAddAssetTagsBody = z.object({
6703 : tags: z.array(z.string()).min(1).max(64)
6704 : })
6705 :
6706 2356 : export const zAddAssetTagsPath = z.object({
6707 : id: z.uuid()
6708 : })
6709 :
6710 : /**
6711 : * Tags added successfully
6712 : */
6713 : export const zAddAssetTagsResponse = zTagsModificationResponse
6714 :
6715 2356 : export const zCreateAssetDownloadBody = z.object({
6716 : preview_id: z.uuid().optional(),
6717 : source_url: z.url(),
6718 : tags: z.array(z.string()).max(64).optional(),
6719 : user_metadata: z.record(z.string(), z.unknown()).optional()
6720 : })
6721 :
6722 2356 : export const zCreateAssetDownloadResponse = z.union([
6723 : zAssetCreated,
6724 : zAssetDownloadResponse
6725 : ])
6726 :
6727 2356 : export const zCreateAssetExportBody = z.object({
6728 : asset_ids: z.array(z.string()).optional(),
6729 : include_previews: z.boolean().optional().default(false),
6730 : job_asset_name_filters: z
6731 : .record(z.string(), z.array(z.string()).min(1))
6732 : .optional(),
6733 : job_ids: z.array(z.string()).optional(),
6734 : naming_strategy: z
6735 : .enum(['group_by_job_id', 'preserve', 'asset_id', 'group_by_job_time'])
6736 : .optional()
6737 : .default('group_by_job_time')
6738 : })
6739 :
6740 : /**
6741 : * Accepted - Export task created and processing in background
6742 : */
6743 : export const zCreateAssetExportResponse = zAssetDownloadResponse
6744 :
6745 2356 : export const zDownloadExportPath = z.object({
6746 : exportName: z.string().regex(/^[a-zA-Z0-9_-]+\.zip$/)
6747 : })
6748 :
6749 : /**
6750 : * Signed URL for downloading the export
6751 : */
6752 : export const zDownloadExportResponse = zExportDownloadUrlResponse
6753 :
6754 2356 : export const zCreateAssetFromHashBody = z.object({
6755 : hash: z.string().regex(/^blake3:[a-f0-9]{64}$/),
6756 : mime_type: z.string().optional(),
6757 : name: z.string().optional(),
6758 : tags: z.array(z.string()).min(1).max(64),
6759 : user_metadata: z.record(z.string(), z.unknown()).optional()
6760 : })
6761 :
6762 : /**
6763 : * Asset reference already existed for this user (deduplicated by content
6764 : * hash); the existing asset is returned with created_new=false.
6765 : *
6766 : */
6767 : export const zCreateAssetFromHashResponse = zAssetCreated
6768 :
6769 : export const zPostAssetsFromWorkflowBody = zWorkflowApiAssetsRequest
6770 :
6771 : /**
6772 : * Success
6773 : */
6774 2356 : export const zPostAssetsFromWorkflowResponse = zWorkflowApiAssetsResponse
6775 :
6776 2356 : export const zCheckAssetByHashPath = z.object({
6777 : hash: z.string().regex(/^blake3:[a-f0-9]{64}$/)
6778 : })
6779 :
6780 : export const zImportPublishedAssetsBody = zImportPublishedAssetsRequest
6781 :
6782 : /**
6783 : * Successfully imported assets
6784 : */
6785 : export const zImportPublishedAssetsResponse2 = zImportPublishedAssetsResponse
6786 :
6787 : /**
6788 : * Prune result
6789 : */
6790 2356 : export const zPruneAssetsResponse = z.object({
6791 : marked: z.int().optional(),
6792 : status: z.string().optional()
6793 : })
6794 :
6795 2356 : export const zGetRemoteAssetMetadataQuery = z.object({
6796 : url: z.url()
6797 : })
6798 :
6799 : /**
6800 : * Metadata retrieved successfully
6801 : */
6802 : export const zGetRemoteAssetMetadataResponse = zAssetMetadataResponse
6803 :
6804 2356 : export const zSeedAssetsBody = z.object({
6805 : roots: z.array(z.string()).optional()
6806 : })
6807 :
6808 : /**
6809 : * Seed started
6810 : */
6811 2356 : export const zSeedAssetsResponse = z.object({
6812 : status: z.string().optional()
6813 : })
6814 :
6815 : /**
6816 : * Scan cancelled
6817 : */
6818 2356 : export const zCancelAssetSeedResponse = z.object({
6819 : status: z.string().optional()
6820 : })
6821 :
6822 : /**
6823 : * Scan progress details (files scanned, total, status, etc.)
6824 : */
6825 2356 : export const zGetAssetSeedStatusResponse = z.record(z.string(), z.unknown())
6826 :
6827 2356 : export const zGetAssetTagHistogramQuery = z.object({
6828 : include_tags: z.array(z.string()).optional(),
6829 : exclude_tags: z.array(z.string()).optional(),
6830 : tags_all: z.array(z.string()).optional(),
6831 : tags_any: z.array(z.string()).optional(),
6832 : tags_none: z.array(z.string()).optional(),
6833 : name_contains: z.string().optional(),
6834 : metadata_filter: z.string().optional(),
6835 : limit: z.int().gte(1).lte(1000).optional().default(100),
6836 : include_public: z.boolean().optional().default(true)
6837 : })
6838 :
6839 : /**
6840 : * Success - Tag histogram returned
6841 : */
6842 : export const zGetAssetTagHistogramResponse = zAssetTagHistogramResponse
6843 :
6844 2356 : export const zStartModelUploadBody = z.object({
6845 : filename: z.string(),
6846 : resumable: z.boolean().optional().default(false),
6847 : size_bytes: z.coerce
6848 : .bigint()
6849 : .min(BigInt('-9223372036854775808'), {
6850 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
6851 : })
6852 : .max(BigInt('9223372036854775807'), {
6853 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
6854 : }),
6855 : tags: z.array(z.string()),
6856 : upload_analytics: zModelUploadAnalytics.optional()
6857 : })
6858 :
6859 2356 : export const zStartModelUploadHeaders = z.object({
6860 : Origin: z.string().optional()
6861 : })
6862 :
6863 : /**
6864 : * Signed upload URL or resumable session for one staged object
6865 : */
6866 2356 : export const zStartModelUploadResponse = zModelUploadStarted
6867 :
6868 2356 : export const zCompleteModelUploadBody = z.object({
6869 : filename: z.string(),
6870 : tags: z.array(z.string()),
6871 : upload_analytics: zModelUploadAnalytics.optional()
6872 : })
6873 :
6874 2356 : export const zCompleteModelUploadPath = z.object({
6875 : upload_id: z.string()
6876 : })
6877 :
6878 : /**
6879 : * Accepted; a task stores the file as an asset
6880 : */
6881 2356 : export const zCompleteModelUploadResponse = zAssetDownloadResponse
6882 :
6883 : export const zReportModelUploadEventBody = zModelUploadTransferReport
6884 :
6885 2356 : export const zReportModelUploadEventPath = z.object({
6886 : upload_id: z.uuid()
6887 : })
6888 :
6889 : /**
6890 : * Report accepted; delivery is best effort
6891 : */
6892 2356 : export const zReportModelUploadEventResponse = z.void()
6893 :
6894 : export const zAuthenticateBody = zAuthenticateRequest
6895 :
6896 : /**
6897 : * Where the email signs in, or a signed-in session
6898 : */
6899 : export const zAuthenticateResponse2 = zAuthenticateResponse
6900 :
6901 : export const zCreateDesktopLoginCodeBody = zDesktopLoginCodeCreateRequest
6902 :
6903 : /**
6904 : * Login code created
6905 : */
6906 : export const zCreateDesktopLoginCodeResponse = zDesktopLoginCodeCreateResponse
6907 :
6908 : export const zExchangeDesktopLoginCodeBody = zDesktopLoginCodeExchangeRequest
6909 :
6910 : /**
6911 : * Pending (not yet redeemed) or complete with a custom token
6912 : */
6913 : export const zExchangeDesktopLoginCodeResponse =
6914 : zDesktopLoginCodeExchangeResponse
6915 :
6916 : export const zRedeemDesktopLoginCodeBody = zDesktopLoginCodeRedeemRequest
6917 :
6918 : /**
6919 : * Code redeemed (or already redeemed by the same user)
6920 : */
6921 : export const zRedeemDesktopLoginCodeResponse = zDesktopLoginCodeRedeemResponse
6922 :
6923 : export const zCreateBillingHandoffBody = zBillingHandoffCreateRequest
6924 :
6925 : /**
6926 : * Handoff issued
6927 : */
6928 : export const zCreateBillingHandoffResponse = zBillingHandoffCreateResponse
6929 :
6930 : export const zExchangeBillingHandoffBody = zBillingHandoffExchangeRequest
6931 :
6932 : /**
6933 : * Scoped session created
6934 : */
6935 : export const zExchangeBillingHandoffResponse = zBillingHandoffExchangeResponse
6936 :
6937 : /**
6938 : * Session deleted successfully
6939 : */
6940 : export const zDeleteSessionResponse2 = zDeleteSessionResponse
6941 :
6942 : /**
6943 : * The live session
6944 : */
6945 2356 : export const zGetSessionResponse = zWebSessionResponse
6946 :
6947 : /**
6948 : * Session created successfully
6949 : */
6950 : export const zCreateSessionResponse2 = zCreateSessionResponse
6951 :
6952 : /**
6953 : * Every session ended
6954 : */
6955 : export const zRevokeAllSessionsResponse2 = zRevokeAllSessionsResponse
6956 :
6957 2356 : export const zDiscoverSsoBody = z.object({
6958 : email: z.string().max(320)
6959 : })
6960 :
6961 : /**
6962 : * Whether the email's domain belongs to an SSO organization
6963 : */
6964 2356 : export const zDiscoverSsoResponse = zSsoDiscoverResponse
6965 :
6966 : export const zExchangeTokenBody = zExchangeTokenRequest
6967 :
6968 : /**
6969 : * Token exchanged successfully
6970 : */
6971 : export const zExchangeTokenResponse2 = zExchangeTokenResponse
6972 :
6973 : /**
6974 : * The sessions are revoked
6975 : */
6976 2356 : export const zRevokePartnerNodeSessionsResponse = z.void()
6977 :
6978 : /**
6979 : * Success
6980 : */
6981 : export const zGetBillingAutoReloadResponse = zAutoReloadSettings
6982 :
6983 : export const zPutBillingAutoReloadBody = zAutoReloadSettingsRequest
6984 :
6985 : /**
6986 : * The saved settings and current accounting
6987 : */
6988 : export const zPutBillingAutoReloadResponse = zAutoReloadSettings
6989 :
6990 2356 : export const zGetBillingAutoReloadPreviewQuery = z.object({
6991 : threshold_credits: z.coerce
6992 : .bigint()
6993 : .min(BigInt('-9223372036854775808'), {
6994 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
6995 : })
6996 : .max(BigInt('9223372036854775807'), {
6997 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
6998 : }),
6999 : target_credits: z.coerce
7000 : .bigint()
7001 : .min(BigInt('-9223372036854775808'), {
7002 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
7003 : })
7004 : .max(BigInt('9223372036854775807'), {
7005 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
7006 : }),
7007 : monthly_budget_cents: z.coerce
7008 : .bigint()
7009 : .min(BigInt('-9223372036854775808'), {
7010 : error: 'Invalid value: Expected int64 to be >= -9223372036854775808'
7011 : })
7012 : .max(BigInt('9223372036854775807'), {
7013 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
7014 : })
7015 : .optional()
7016 : })
7017 :
7018 : /**
7019 : * Success
7020 : */
7021 : export const zGetBillingAutoReloadPreviewResponse = zAutoReloadPreview
7022 :
7023 : /**
7024 : * Credit balance
7025 : */
7026 : export const zGetBillingBalanceResponse = zBillingBalanceResponse
7027 :
7028 : /**
7029 : * Success
7030 : */
7031 : export const zListBillingBudgetsResponse = zBudgetList
7032 :
7033 : export const zCreateBillingBudgetBody = zBudgetCreateRequest
7034 :
7035 : /**
7036 : * The new budget
7037 : */
7038 : export const zCreateBillingBudgetResponse = zBudgetWriteResult
7039 :
7040 2356 : export const zDeleteBillingBudgetPath = z.object({
7041 : id: z.string()
7042 : })
7043 :
7044 : /**
7045 : * Archived
7046 : */
7047 2356 : export const zDeleteBillingBudgetResponse = z.void()
7048 :
7049 : export const zUpdateBillingBudgetBody = zBudgetUpdateRequest
7050 :
7051 2356 : export const zUpdateBillingBudgetPath = z.object({
7052 : id: z.string()
7053 : })
7054 :
7055 : /**
7056 : * The budget after the change
7057 : */
7058 : export const zUpdateBillingBudgetResponse = zBudgetWriteResult
7059 :
7060 2356 : export const zGetBillingBudgetHistoryPath = z.object({
7061 : id: z.string()
7062 : })
7063 :
7064 : /**
7065 : * Success
7066 : */
7067 : export const zGetBillingBudgetHistoryResponse = zBudgetHistory
7068 :
7069 : /**
7070 : * Effective billing capabilities
7071 : */
7072 : export const zGetBillingCapabilitiesResponse = zBillingCapabilitiesResponse
7073 :
7074 : /**
7075 : * Success
7076 : */
7077 : export const zGetChurnkeyAuthResponse = zChurnkeyAuthResponse
7078 :
7079 : /**
7080 : * Success
7081 : */
7082 : export const zGetBillingCompanyDetailsResponse = zBillingCompanyDetailsResponse
7083 :
7084 : export const zUpdateBillingCompanyDetailsBody =
7085 : zBillingCompanyDetailsUpdateRequest
7086 :
7087 : /**
7088 : * Success
7089 : */
7090 : export const zUpdateBillingCompanyDetailsResponse =
7091 : zBillingCompanyDetailsResponse
7092 :
7093 2356 : export const zGetBillingEventsQuery = z.object({
7094 : page: z.int().gte(1).optional().default(1),
7095 : limit: z.int().gte(1).lte(100).optional().default(20),
7096 : scope: z.enum(['self', 'workspace', 'user']).optional(),
7097 : user_id: z.string().optional(),
7098 : spend_source: z.string().max(200).optional(),
7099 : filter: z.string().optional(),
7100 : start_date: z.iso.datetime().optional(),
7101 : end_date: z.iso.datetime().optional()
7102 : })
7103 :
7104 : /**
7105 : * Paginated billing events
7106 : */
7107 2356 : export const zGetBillingEventsResponse = zBillingEventsResponse
7108 :
7109 2356 : export const zGetBillingOpStatusPath = z.object({
7110 : id: z.string()
7111 : })
7112 :
7113 : /**
7114 : * Billing operation status
7115 : */
7116 : export const zGetBillingOpStatusResponse = zBillingOpStatusResponse
7117 :
7118 2356 : export const zCancelBillingOpPath = z.object({
7119 : id: z.string()
7120 : })
7121 :
7122 : /**
7123 : * Canceled; nothing was charged. Also returned for an operation already discarded or expired without authentication, so a repeat is safe.
7124 : */
7125 2356 : export const zCancelBillingOpResponse = zBillingOpCancelResponse
7126 :
7127 2356 : export const zGetBillingOpOutcomePath = z.object({
7128 : id: z.string()
7129 : })
7130 :
7131 : /**
7132 : * Billing operation outcome
7133 : */
7134 : export const zGetBillingOpOutcomeResponse = zBillingOpOutcomeResponse
7135 :
7136 : /**
7137 : * Saved payment methods
7138 : */
7139 2356 : export const zListSavedPaymentMethodsResponse = z.array(zSavedPaymentMethod)
7140 :
7141 : export const zGetPaymentPortalBody = zPaymentPortalRequest
7142 :
7143 : /**
7144 : * Success
7145 : */
7146 : export const zGetPaymentPortalResponse = zPaymentPortalResponse
7147 :
7148 : /**
7149 : * Available plans with pricing
7150 : */
7151 2356 : export const zGetBillingPlansResponse = zBillingPlansResponse
7152 :
7153 : export const zPreviewSubscribeBody = zPreviewSubscribeRequest
7154 :
7155 : /**
7156 : * Subscription preview
7157 : */
7158 : export const zPreviewSubscribeResponse2 = zPreviewSubscribeResponse
7159 :
7160 : export const zAcceptRetentionOfferBody = zRetentionAcceptRequest
7161 :
7162 : /**
7163 : * Success
7164 : */
7165 : export const zAcceptRetentionOfferResponse = zRetentionAcceptance
7166 :
7167 : export const zRecordRetentionFlowEventBody = zRetentionFlowEventRequest
7168 :
7169 : /**
7170 : * Success
7171 : */
7172 2356 : export const zRecordRetentionFlowEventResponse = z.void()
7173 :
7174 : /**
7175 : * Success
7176 : */
7177 : export const zPrepareRetentionFlowResponse = zRetentionFlowResponse
7178 :
7179 : /**
7180 : * Billing status
7181 : */
7182 : export const zGetBillingStatusResponse = zBillingStatusResponse
7183 :
7184 : export const zSubscribeBody = zSubscribeRequest
7185 :
7186 : /**
7187 : * Subscription created or payment method needed
7188 : */
7189 : export const zSubscribeResponse2 = zSubscribeResponse
7190 :
7191 : export const zCancelSubscriptionBody = zCancelSubscriptionRequest
7192 :
7193 2356 : export const zCancelSubscriptionResponse2 = z.union([
7194 : zCancelSubscriptionResponse,
7195 : zCancelSubscriptionAcceptedResponse
7196 : ])
7197 :
7198 : export const zResubscribeBody = zResubscribeRequest
7199 :
7200 : /**
7201 : * Subscription resumed successfully
7202 : */
7203 : export const zResubscribeResponse2 = zResubscribeResponse
7204 :
7205 : export const zRevertScheduledChangeBody = zRevertScheduledChangeRequest
7206 :
7207 : /**
7208 : * Revert accepted
7209 : */
7210 : export const zRevertScheduledChangeResponse2 = zRevertScheduledChangeResponse
7211 :
7212 : export const zCreateTopupBody = zCreateTopupRequest
7213 :
7214 : /**
7215 : * Top-up initiated successfully
7216 : */
7217 : export const zCreateTopupResponse2 = zCreateTopupResponse
7218 :
7219 : export const zCreateTopupCheckoutBody = zCreateTopupCheckoutRequest
7220 :
7221 : /**
7222 : * Checkout session created
7223 : */
7224 : export const zCreateTopupCheckoutResponse2 = zCreateTopupCheckoutResponse
7225 :
7226 2356 : export const zListTopupCheckoutsQuery = z.object({
7227 : cursor: z.string().optional()
7228 : })
7229 :
7230 : /**
7231 : * Durable discovery summaries; Cache-Control no-store.
7232 : */
7233 : export const zListTopupCheckoutsResponse = zHostedTopupCheckoutList
7234 :
7235 2356 : export const zGetTopupCheckoutPath = z.object({
7236 : id: z.string()
7237 : })
7238 :
7239 : /**
7240 : * Current checkout facts; Cache-Control no-store.
7241 : */
7242 : export const zGetTopupCheckoutResponse = zHostedTopupCheckout
7243 :
7244 : export const zCreateInteractiveTopupBody = zInteractiveTopupRequest
7245 :
7246 : /**
7247 : * Top-up initiated successfully
7248 : */
7249 : export const zCreateInteractiveTopupResponse = zCreateTopupResponse
7250 :
7251 : export const zCreateTopupQuoteBody = zCreateTopupQuoteRequest
7252 :
7253 : /**
7254 : * Top-up quote
7255 : */
7256 : export const zCreateTopupQuoteResponse = zTopupQuoteResponse
7257 :
7258 2356 : export const zGetBillingUsageTimeSeriesQuery = z.object({
7259 : group_by: z
7260 : .enum(['model', 'endpoint', 'product', 'product_line', 'person', 'source'])
7261 : .optional()
7262 : .default('model'),
7263 : filter_product_line: z.string().max(200).optional(),
7264 : filter_model: z.string().max(200).optional(),
7265 : filter_person: z.string().max(200).optional(),
7266 : filter_source: z.string().max(200).optional(),
7267 : granularity: z.enum(['hour', 'day', 'month']).optional().default('month'),
7268 : starting_on: z.iso.datetime().optional(),
7269 : ending_before: z.iso.datetime().optional(),
7270 : months: z.int().gte(1).lte(24).optional().default(6)
7271 : })
7272 :
7273 : /**
7274 : * Workspace usage
7275 : */
7276 : export const zGetBillingUsageTimeSeriesResponse = zUsageTimeSeries
7277 :
7278 : export const zCheckCloudCompatibilityBody = zCloudCompatibilityRequest
7279 :
7280 : /**
7281 : * The posted node types and models Comfy Cloud is missing
7282 : */
7283 2356 : export const zCheckCloudCompatibilityResponse = zCloudCompatibility
7284 :
7285 : /**
7286 : * Default workflow JSON
7287 : */
7288 2356 : export const zGetDefaultWorkflowResponse = z.record(z.string(), z.unknown())
7289 :
7290 : /**
7291 : * A JSON object; `{}` is valid. Null members count as absent.
7292 : */
7293 2356 : export const zCreateDeployBundleBody = z.object({
7294 : name: z.string().max(200).nullish(),
7295 : workflow: z.record(z.string(), z.unknown()).nullish()
7296 : })
7297 :
7298 : /**
7299 : * Bundle stored on comfy-builder
7300 : */
7301 2356 : export const zCreateDeployBundleResponse = z.object({
7302 : bundle_id: z.uuid(),
7303 : expires_at: z.iso.datetime(),
7304 : url: z.url(),
7305 : workspace_id: z.string()
7306 : })
7307 :
7308 : /**
7309 : * Counts of what the bundle would include
7310 : */
7311 2356 : export const zGetDeploySummaryResponse = z.object({
7312 : custom_nodes: z.int(),
7313 : models: z.int()
7314 : })
7315 :
7316 : /**
7317 : * Embedding names
7318 : */
7319 2356 : export const zGetEmbeddingsResponse = z.array(z.string())
7320 :
7321 : /**
7322 : * Success - List of model folders
7323 : */
7324 2356 : export const zGetModelFoldersResponse = z.array(zModelFolder)
7325 :
7326 2356 : export const zGetModelsInFolderPath = z.object({
7327 : folder: z.string()
7328 : })
7329 :
7330 : /**
7331 : * Success - List of models in the folder
7332 : */
7333 2356 : export const zGetModelsInFolderResponse = z.array(zModelFile)
7334 :
7335 2356 : export const zGetModelPreviewPath = z.object({
7336 : folder: z.string(),
7337 : path_index: z.int(),
7338 : filename: z.string()
7339 : })
7340 :
7341 2356 : export const zGetNodeByIdPath = z.object({
7342 : id: z.string()
7343 : })
7344 :
7345 : /**
7346 : * URL paths (relative to web root) of available extension JS files
7347 : */
7348 2356 : export const zGetExtensionsResponse = z.array(z.string())
7349 :
7350 : /**
7351 : * Success
7352 : */
7353 2356 : export const zGetFeaturesResponse = z.object({
7354 : agent: z
7355 : .object({
7356 : state: z.enum(['ready'])
7357 : })
7358 : .optional(),
7359 : 'agent-credit-usage-summary': z
7360 : .enum(['control', 'treatment'])
7361 : .optional()
7362 : .default('control'),
7363 : 'agent-free-use-message-placement': z
7364 : .enum([
7365 : 'control',
7366 : 'top-banner',
7367 : 'near-composer',
7368 : 'above-input',
7369 : 'inside-input'
7370 : ])
7371 : .optional()
7372 : .default('control'),
7373 : 'agent-starter-prompt-set': z
7374 : .enum(['control', 'test'])
7375 : .optional()
7376 : .default('control'),
7377 : agent_gratis_local_arm: z.enum(['control', 'treatment']).optional(),
7378 : billing_web_url: z.string().optional(),
7379 : can_run_partner_nodes: z.boolean().optional(),
7380 : deploy_to_cloud: z.boolean().optional(),
7381 : free_tier_balance: z
7382 : .object({
7383 : allowance: z.int(),
7384 : remaining: z.int(),
7385 : used: z.int()
7386 : })
7387 : .optional(),
7388 : free_tier_offer: z
7389 : .object({
7390 : job_allowance: z.int(),
7391 : requires_google_sign_in: z.boolean()
7392 : })
7393 : .optional(),
7394 : max_upload_size: z.int().optional(),
7395 : model_upload_folders: z.array(z.string()).optional(),
7396 : new_free_tier_subscriptions: z.boolean().optional(),
7397 : open_on_cloud_enabled: z.boolean().optional(),
7398 : private_workflow_links_enabled: z.boolean().optional(),
7399 : sso_enabled: z.boolean().optional(),
7400 : stripe_publishable_key: z.string().optional(),
7401 : supports_preview_metadata: z.boolean().optional(),
7402 : web_session_probe: z.boolean().optional()
7403 : })
7404 :
7405 : export const zSubmitFeedbackBody = zFeedbackRequest
7406 :
7407 : /**
7408 : * Feedback submitted successfully
7409 : */
7410 : export const zSubmitFeedbackResponse = zFeedbackResponse
7411 :
7412 2356 : export const zGetMaskLayersQuery = z.object({
7413 : filename: z.string()
7414 : })
7415 :
7416 : /**
7417 : * Success - Related mask layers returned
7418 : */
7419 2356 : export const zGetMaskLayersResponse = z.object({
7420 : mask: z.string().nullish(),
7421 : paint: z.string().nullish(),
7422 : painted: z.string().nullish(),
7423 : painted_masked: z.string().nullish()
7424 : })
7425 :
7426 2356 : export const zFreeMemoryBody = z.object({
7427 : free_memory: z.boolean().optional(),
7428 : unload_models: z.boolean().optional()
7429 : })
7430 :
7431 : export const zSetGlobalSettingBody = zGlobalSettingValue
7432 :
7433 : /**
7434 : * Setting stored
7435 : */
7436 : export const zSetGlobalSettingResponse = zGlobalSetting
7437 :
7438 2356 : export const zDeleteGlobalSettingPath = z.object({
7439 : key: zGlobalSettingKey
7440 : })
7441 :
7442 : /**
7443 : * Setting unset
7444 : */
7445 2356 : export const zDeleteGlobalSettingResponse = z.void()
7446 :
7447 2356 : export const zGetGlobalSettingPath = z.object({
7448 : key: zGlobalSettingKey
7449 : })
7450 :
7451 : /**
7452 : * Success
7453 : */
7454 : export const zGetGlobalSettingResponse = zGlobalSetting
7455 :
7456 : /**
7457 : * Success - Map of subgraph IDs to their metadata
7458 : */
7459 2356 : export const zGetGlobalSubgraphsResponse = z.record(
7460 : z.string(),
7461 : zGlobalSubgraphInfo
7462 : )
7463 :
7464 2356 : export const zGetGlobalSubgraphPath = z.object({
7465 : id: z.string()
7466 : })
7467 :
7468 : /**
7469 : * Success - Full subgraph data
7470 : */
7471 : export const zGetGlobalSubgraphResponse = zGlobalSubgraphData
7472 :
7473 : export const zManageHistoryBody = zHistoryManageRequest
7474 :
7475 2356 : export const zGetLegacyHistoryByIdPath = z.object({
7476 : prompt_id: z.string()
7477 : })
7478 :
7479 2356 : export const zGetHistoryQuery = z.object({
7480 : max_items: z.int().optional(),
7481 : offset: z.int().optional().default(0)
7482 : })
7483 :
7484 : /**
7485 : * Success - Execution history retrieved
7486 : */
7487 : export const zGetHistoryResponse = zHistoryResponse
7488 :
7489 2356 : export const zGetHistoryForPromptPath = z.object({
7490 : prompt_id: z.string()
7491 : })
7492 :
7493 : /**
7494 : * Success - History for prompt retrieved
7495 : */
7496 : export const zGetHistoryForPromptResponse = zHistoryDetailResponse
7497 :
7498 : export const zCreateHubAssetUploadUrlBody = zHubAssetUploadUrlRequest
7499 :
7500 : /**
7501 : * Presigned upload URL and token
7502 : */
7503 : export const zCreateHubAssetUploadUrlResponse = zHubAssetUploadUrlResponse
7504 :
7505 2356 : export const zListHubLabelsQuery = z.object({
7506 : type: z.enum(['tag', 'model', 'custom_node']).optional()
7507 : })
7508 :
7509 : /**
7510 : * List of labels
7511 : */
7512 : export const zListHubLabelsResponse = zHubLabelListResponse
7513 :
7514 : export const zCreateHubProfileBody = zCreateHubProfileRequest
7515 :
7516 : /**
7517 : * Hub profile created
7518 : */
7519 : export const zCreateHubProfileResponse = zHubProfile
7520 :
7521 2356 : export const zGetHubProfileByUsernamePath = z.object({
7522 : username: z.string()
7523 : })
7524 :
7525 : /**
7526 : * Hub profile
7527 : */
7528 : export const zGetHubProfileByUsernameResponse = zHubProfile
7529 :
7530 : export const zUpdateHubProfileBody = zUpdateHubProfileRequest
7531 :
7532 2356 : export const zUpdateHubProfilePath = z.object({
7533 : username: z.string()
7534 : })
7535 :
7536 : /**
7537 : * Hub profile updated
7538 : */
7539 : export const zUpdateHubProfileResponse = zHubProfile
7540 :
7541 2356 : export const zCheckHubUsernameQuery = z.object({
7542 : username: z.string()
7543 : })
7544 :
7545 : /**
7546 : * Username availability result
7547 : */
7548 : export const zCheckHubUsernameResponse = zHubUsernameCheckResponse
7549 :
7550 : /**
7551 : * Hub profile
7552 : */
7553 : export const zGetMyHubProfileResponse = zHubProfile
7554 :
7555 2356 : export const zListHubWorkflowsQuery = z.object({
7556 : cursor: z.string().optional(),
7557 : limit: z.int().gte(1).lte(100).optional().default(20),
7558 : search: z.string().optional(),
7559 : tag: z.string().optional(),
7560 : username: z.string().optional(),
7561 : detail: z.boolean().optional().default(false),
7562 : status: z.array(zHubWorkflowStatus).optional()
7563 : })
7564 :
7565 : /**
7566 : * Paginated list of hub workflows
7567 : */
7568 : export const zListHubWorkflowsResponse = zHubWorkflowListResponse
7569 :
7570 : export const zPublishHubWorkflowBody = zPublishHubWorkflowRequest
7571 :
7572 : /**
7573 : * Workflow published to hub
7574 : */
7575 : export const zPublishHubWorkflowResponse = zHubWorkflowDetail
7576 :
7577 2356 : export const zDeleteHubWorkflowPath = z.object({
7578 : share_id: z.string()
7579 : })
7580 :
7581 : /**
7582 : * Successfully unpublished
7583 : */
7584 2356 : export const zDeleteHubWorkflowResponse = z.void()
7585 :
7586 2356 : export const zGetHubWorkflowPath = z.object({
7587 : share_id: z.string()
7588 : })
7589 :
7590 : /**
7591 : * Hub workflow detail
7592 : */
7593 2356 : export const zGetHubWorkflowResponse = zHubWorkflowDetail
7594 :
7595 2356 : export const zListHubWorkflowIndexQuery = z.object({
7596 : status: z.array(zHubWorkflowStatus).optional()
7597 : })
7598 :
7599 : /**
7600 : * List of hub workflow template entries
7601 : */
7602 2356 : export const zListHubWorkflowIndexResponse = z.array(zHubWorkflowTemplateEntry)
7603 :
7604 : /**
7605 : * Nested map of locale to translation key-value pairs
7606 : */
7607 2356 : export const zGetI18nResponse = z.record(z.string(), z.unknown())
7608 :
7609 : export const zCreateInputUploadUrlBody = zInputUploadUrlRequest
7610 :
7611 : /**
7612 : * Upload grant minted
7613 : */
7614 : export const zCreateInputUploadUrlResponse = zUploadGrantResponse
7615 :
7616 2356 : export const zAcceptWorkspaceInvitePath = z.object({
7617 : token: z.string()
7618 : })
7619 :
7620 : /**
7621 : * Invite accepted, user is now a member
7622 : */
7623 : export const zAcceptWorkspaceInviteResponse = zAcceptInviteResponse
7624 :
7625 2356 : export const zGetLegacyJobByIdPath = z.object({
7626 : job_id: z.string()
7627 : })
7628 :
7629 2356 : export const zGetLegacyJobOutputsPath = z.object({
7630 : job_id: z.string()
7631 : })
7632 :
7633 2356 : export const zGetJobStatusPath = z.object({
7634 : job_id: z.uuid()
7635 : })
7636 :
7637 : /**
7638 : * Success - Job status returned
7639 : */
7640 : export const zGetJobStatusResponse = zJobStatusResponse
7641 :
7642 2356 : export const zListJobsQuery = z.object({
7643 : status: z.string().optional(),
7644 : workflow_id: z.string().optional(),
7645 : output_type: z.enum(['image', 'video', 'audio', '3d']).optional(),
7646 : sort_by: z
7647 : .enum(['create_time', 'execution_time'])
7648 : .optional()
7649 : .default('create_time'),
7650 : sort_order: z.enum(['asc', 'desc']).optional().default('desc'),
7651 : after: z.string().optional(),
7652 : offset: z.int().gte(0).optional().default(0),
7653 : limit: z.int().gte(1).lte(1000).optional().default(100),
7654 : capped_total: z.boolean().optional().default(true)
7655 : })
7656 :
7657 : /**
7658 : * Success - Jobs retrieved
7659 : */
7660 : export const zListJobsResponse = zJobsListResponse
7661 :
7662 2356 : export const zDeleteJobPath = z.object({
7663 : job_id: z.uuid()
7664 : })
7665 :
7666 : /**
7667 : * Job and its assets deleted successfully, or the job was not in a deletable state (pending/in-progress/already-deleted) and no change was made (no-op)
7668 : */
7669 2356 : export const zDeleteJobResponse = z.void()
7670 :
7671 2356 : export const zGetJobDetailPath = z.object({
7672 : job_id: z.uuid()
7673 : })
7674 :
7675 2356 : export const zGetJobDetailQuery = z.object({
7676 : short_link: z.enum(['ephemeral_tool_chain', 'default']).optional()
7677 : })
7678 :
7679 : /**
7680 : * Success - Job details retrieved
7681 : */
7682 : export const zGetJobDetailResponse = zJobDetailResponse
7683 :
7684 2356 : export const zGetJobAssetsPath = z.object({
7685 : job_id: z.uuid()
7686 : })
7687 :
7688 2356 : export const zGetJobAssetsQuery = z.object({
7689 : limit: z.int().gte(1).lte(500).optional().default(20),
7690 : offset: z.int().gte(0).optional().default(0)
7691 : })
7692 :
7693 : /**
7694 : * Success - Job assets returned
7695 : */
7696 : export const zGetJobAssetsResponse = zJobAssetsResponse
7697 :
7698 2356 : export const zCancelJobPath = z.object({
7699 : job_id: z.uuid()
7700 : })
7701 :
7702 : /**
7703 : * Success - Cancel request accepted (or job was already terminal)
7704 : */
7705 : export const zCancelJobResponse = zJobCancelResponse
7706 :
7707 : export const zCancelJobsBody = zJobsCancelRequest
7708 :
7709 : /**
7710 : * Success - cancel requests dispatched (or jobs were already terminal)
7711 : */
7712 : export const zCancelJobsResponse = zJobsCancelResponse
7713 :
7714 2356 : export const zGetLegacyModelsByFolderPath = z.object({
7715 : folder: z.string()
7716 : })
7717 :
7718 : /**
7719 : * Success - Node replacement mappings
7720 : */
7721 2356 : export const zGetNodeReplacementsResponse = z.record(z.string(), z.unknown())
7722 :
7723 2356 : export const zGetNodeInfoQuery = z.object({
7724 : include_user_models: z.boolean().optional().default(false)
7725 : })
7726 :
7727 : /**
7728 : * Success
7729 : */
7730 2356 : export const zGetNodeInfoResponse = z.record(z.string(), zNodeInfo)
7731 :
7732 2356 : export const zGetLegacyObjectInfoByNodeClassPath = z.object({
7733 : node_class: z.string()
7734 : })
7735 :
7736 : /**
7737 : * Success
7738 : */
7739 : export const zGetPromptInfoResponse = zPromptInfo
7740 :
7741 : export const zExecutePromptBody = zPromptRequest
7742 :
7743 : /**
7744 : * Success - Prompt accepted
7745 : */
7746 : export const zExecutePromptResponse = zPromptResponse
7747 :
7748 2356 : export const zGetLegacyPromptByIdPath = z.object({
7749 : prompt_id: z.string()
7750 : })
7751 :
7752 : /**
7753 : * The provider catalog
7754 : */
7755 : export const zGetProvidersResponse = zProviderCatalogResponse
7756 :
7757 : /**
7758 : * Success
7759 : */
7760 : export const zGetQueueInfoResponse = zQueueInfo
7761 :
7762 : export const zManageQueueBody = zQueueManageRequest
7763 :
7764 : /**
7765 : * Success
7766 : */
7767 : export const zManageQueueResponse = zQueueManageResponse
7768 :
7769 : /**
7770 : * The packs the Release built without, in the order the build declared them
7771 : */
7772 : export const zGetReleaseUnsupportedPacksResponse = zReleaseUnsupportedPacks
7773 :
7774 : /**
7775 : * Success
7776 : */
7777 : export const zListSecretsResponse = zSecretListResponse
7778 :
7779 : export const zCreateSecretBody = zCreateSecretRequest
7780 :
7781 : /**
7782 : * Secret created successfully
7783 : */
7784 : export const zCreateSecretResponse = zSecretResponse
7785 :
7786 2356 : export const zDeleteSecretPath = z.object({
7787 : id: z.uuid()
7788 : })
7789 :
7790 : /**
7791 : * Secret deleted successfully
7792 : */
7793 2356 : export const zDeleteSecretResponse = z.void()
7794 :
7795 2356 : export const zGetSecretPath = z.object({
7796 : id: z.uuid()
7797 : })
7798 :
7799 : /**
7800 : * Success
7801 : */
7802 : export const zGetSecretResponse = zSecretResponse
7803 :
7804 : export const zUpdateSecretBody = zUpdateSecretRequest
7805 :
7806 2356 : export const zUpdateSecretPath = z.object({
7807 : id: z.uuid()
7808 : })
7809 :
7810 : /**
7811 : * Secret updated successfully
7812 : */
7813 : export const zUpdateSecretResponse = zSecretResponse
7814 :
7815 : /**
7816 : * Success
7817 : */
7818 : export const zListSecretProvidersResponse = zSecretProvidersResponse
7819 :
7820 : /**
7821 : * User settings as key-value pairs
7822 : */
7823 2356 : export const zGetAllSettingsResponse = z.record(z.string(), z.unknown())
7824 :
7825 : /**
7826 : * Settings to update as key-value pairs
7827 : */
7828 2356 : export const zUpdateMultipleSettingsBody = z.record(z.string(), z.unknown())
7829 :
7830 : /**
7831 : * Updated user settings
7832 : */
7833 2356 : export const zUpdateMultipleSettingsResponse = z.record(z.string(), z.unknown())
7834 :
7835 2356 : export const zGetSettingByIdPath = z.object({
7836 : id: z.string()
7837 : })
7838 :
7839 : /**
7840 : * Setting value response
7841 : */
7842 2356 : export const zGetSettingByIdResponse = z.object({
7843 : value: z.unknown().optional()
7844 : })
7845 :
7846 : /**
7847 : * New value for the setting
7848 : */
7849 2356 : export const zUpdateSettingByIdBody = z.unknown()
7850 :
7851 2356 : export const zUpdateSettingByIdPath = z.object({
7852 : id: z.string()
7853 : })
7854 :
7855 : /**
7856 : * Updated setting value response
7857 : */
7858 2356 : export const zUpdateSettingByIdResponse = z.object({
7859 : value: z.unknown().optional()
7860 : })
7861 :
7862 : /**
7863 : * Success
7864 : */
7865 : export const zGetSystemStatsResponse = zSystemStatsResponse
7866 :
7867 2356 : export const zListTagsQuery = z.object({
7868 : prefix: z.string().optional(),
7869 : limit: z.int().gte(1).lte(1000).optional().default(100),
7870 : offset: z.int().gte(0).optional().default(0),
7871 : order: z.enum(['count_desc', 'name_asc']).optional().default('count_desc'),
7872 : include_zero: z.boolean().optional().default(false),
7873 : include_public: z.boolean().optional().default(true)
7874 : })
7875 :
7876 : /**
7877 : * Tags retrieved successfully
7878 : */
7879 : export const zListTagsResponse2 = zListTagsResponse
7880 :
7881 2356 : export const zListTasksQuery = z.object({
7882 : task_name: z.string().optional(),
7883 : idempotency_key: z.string().optional(),
7884 : status: z.string().optional(),
7885 : created_after: z.iso.datetime().optional(),
7886 : created_before: z.iso.datetime().optional(),
7887 : sort_order: z.enum(['asc', 'desc']).optional().default('desc'),
7888 : offset: z.int().gte(0).optional().default(0),
7889 : limit: z.int().gte(1).lte(100).optional().default(20)
7890 : })
7891 :
7892 : /**
7893 : * Success - Tasks retrieved
7894 : */
7895 : export const zListTasksResponse = zTasksListResponse
7896 :
7897 2356 : export const zCancelTaskPath = z.object({
7898 : task_id: z.uuid()
7899 : })
7900 :
7901 : /**
7902 : * Cancellation accepted
7903 : */
7904 2356 : export const zCancelTaskResponse = z.void()
7905 :
7906 2356 : export const zGetTaskPath = z.object({
7907 : task_id: z.uuid()
7908 : })
7909 :
7910 : /**
7911 : * Success - Task details retrieved
7912 : */
7913 : export const zGetTaskResponse = zTaskResponse
7914 :
7915 2356 : export const zUploadImageBody = z.object({
7916 : image: z.string(),
7917 : overwrite: z.string().optional(),
7918 : subfolder: z.string().optional(),
7919 : type: z.string().optional()
7920 : })
7921 :
7922 : /**
7923 : * Image uploaded successfully
7924 : */
7925 2356 : export const zUploadImageResponse = z.object({
7926 : name: z.string().optional(),
7927 : subfolder: z.string().optional(),
7928 : type: z.string().optional()
7929 : })
7930 :
7931 2356 : export const zUploadMaskBody = z.object({
7932 : image: z.string(),
7933 : original_ref: z.string()
7934 : })
7935 :
7936 : /**
7937 : * Mask uploaded successfully
7938 : */
7939 2356 : export const zUploadMaskResponse = z.object({
7940 : name: z.string().optional(),
7941 : subfolder: z.string().optional(),
7942 : type: z.string().optional()
7943 : })
7944 :
7945 2356 : export const zUploadGrantPutBody = z.string()
7946 :
7947 2356 : export const zUploadGrantPutPath = z.object({
7948 : upload_id: z.string()
7949 : })
7950 :
7951 2356 : export const zUploadGrantPutResponse = z.union([
7952 : zInputUploadResponse,
7953 : zWorkflowResponse
7954 : ])
7955 :
7956 : /**
7957 : * Success
7958 : */
7959 : export const zGetUserResponse = zUserResponse
7960 :
7961 2356 : export const zGetUserdataQuery = z.object({
7962 : dir: z.string().optional(),
7963 : recurse: z.boolean().optional().default(false),
7964 : split: z.boolean().optional().default(false),
7965 : full_info: z.boolean().optional().default(false)
7966 : })
7967 :
7968 : /**
7969 : * A list of user data files.
7970 : */
7971 : export const zGetUserdataResponse = zGetUserDataResponseFull
7972 :
7973 2356 : export const zDeleteUserdataFilePath = z.object({
7974 : file: z.string()
7975 : })
7976 :
7977 : /**
7978 : * File deleted successfully (No Content).
7979 : */
7980 2356 : export const zDeleteUserdataFileResponse = z.void()
7981 :
7982 2356 : export const zGetUserdataFilePath = z.object({
7983 : file: z.string()
7984 : })
7985 :
7986 : /**
7987 : * Successfully retrieved the file.
7988 : */
7989 2356 : export const zGetUserdataFileResponse = z.string()
7990 :
7991 2356 : export const zPostUserdataFileBody = z.string()
7992 :
7993 2356 : export const zPostUserdataFilePath = z.object({
7994 : file: z.string()
7995 : })
7996 :
7997 2356 : export const zPostUserdataFileQuery = z.object({
7998 : overwrite: z.enum(['true', 'false']).optional().default('true'),
7999 : full_info: z.enum(['true', 'false']).optional().default('false')
8000 : })
8001 :
8002 : /**
8003 : * File uploaded successfully.
8004 : */
8005 : export const zPostUserdataFileResponse = zUserDataResponseFull
8006 :
8007 2356 : export const zMoveUserdataFilePath = z.object({
8008 : file: z.string(),
8009 : dest: z.string()
8010 : })
8011 :
8012 2356 : export const zMoveUserdataFileQuery = z.object({
8013 : overwrite: z.enum(['true', 'false']).optional().default('true')
8014 : })
8015 :
8016 : /**
8017 : * File moved successfully.
8018 : */
8019 : export const zMoveUserdataFileResponse = zUserDataResponseFull
8020 :
8021 2356 : export const zDeleteUserdataFilePublishPath = z.object({
8022 : file: z.string()
8023 : })
8024 :
8025 : /**
8026 : * Share revoked
8027 : */
8028 2356 : export const zDeleteUserdataFilePublishResponse = z.void()
8029 :
8030 2356 : export const zGetUserdataFilePublishPath = z.object({
8031 : file: z.string()
8032 : })
8033 :
8034 : /**
8035 : * Publish info (publish_time is null if never published)
8036 : */
8037 : export const zGetUserdataFilePublishResponse = zWorkflowPublishInfo
8038 :
8039 : export const zPostUserdataFilePublishBody = zPublishWorkflowAssetsRequest
8040 :
8041 2356 : export const zPostUserdataFilePublishPath = z.object({
8042 : file: z.string()
8043 : })
8044 :
8045 : /**
8046 : * Workflow published
8047 : */
8048 : export const zPostUserdataFilePublishResponse = zWorkflowPublishInfo
8049 :
8050 : /**
8051 : * Userdata storage information
8052 : */
8053 2356 : export const zGetUsersInfoResponse = z.object({
8054 : migrated: z.boolean(),
8055 : storage: z.string()
8056 : })
8057 :
8058 2356 : export const zGetCccActivityQuery = z.object({
8059 : kind: z
8060 : .array(z.enum(['save', 'publish', 'discard', 'revert']))
8061 : .max(4)
8062 : .optional(),
8063 : actor_uid: z.string().min(1).max(200).optional(),
8064 : type: z
8065 : .array(z.enum(['model', 'workflow', 'app']))
8066 : .max(3)
8067 : .optional(),
8068 : since: z.iso.datetime().optional(),
8069 : until: z.iso.datetime().optional(),
8070 : limit: z.int().gte(1).lte(100).optional().default(50),
8071 : cursor: z.string().max(256).optional()
8072 : })
8073 :
8074 : /**
8075 : * One page of activity, has_more, optional next_cursor and the newest publication
8076 : */
8077 : export const zGetCccActivityResponse = zCccActivityPage
8078 :
8079 : /**
8080 : * Editing instructions from this deployed catalog API build; private no-store
8081 : */
8082 2356 : export const zGetCatalogAgentInstructionsResponse = z.string()
8083 :
8084 : /**
8085 : * Current verified authoring context; private no-store
8086 : */
8087 : export const zGetCccAuthoringContextResponse = zCccAuthoringContext
8088 :
8089 2356 : export const zListCccWebsiteCardsHeaders = z.object({
8090 : 'X-Comfy-Catalog-Authority': z.string().optional()
8091 : })
8092 :
8093 2356 : export const zListCccWebsiteCardsQuery = z.object({
8094 : kind: z.enum(['MODEL', 'WORKFLOW', 'APP']),
8095 : limit: z.int().gte(1).lte(24).optional().default(24),
8096 : cursor: z.string().max(4096).optional(),
8097 : locale: z.enum(['en', 'zh-CN', 'ja']).optional().default('en'),
8098 : q: z.string().max(300).optional(),
8099 : sort: z
8100 : .enum(['popular', 'name', 'priceAsc', 'priceDesc'])
8101 : .optional()
8102 : .default('popular'),
8103 : category: z.array(z.string().max(200)).max(30).optional(),
8104 : model: z.array(z.string().max(200)).max(30).optional(),
8105 : use: z.array(z.string().max(200)).max(30).optional(),
8106 : modality: z.array(z.string().max(200)).max(30).optional(),
8107 : provider: z.array(z.string().max(200)).max(30).optional(),
8108 : capability: z.array(z.string().max(200)).max(30).optional(),
8109 : author: z.string().min(1).max(30).optional()
8110 : })
8111 :
8112 : /**
8113 : * At most 24 card summaries; no graphs, inputs, examples or long bodies. Anonymous responses omit total, generation and facet counts. Cursors are audience and filter bound. LIVE cursors resume after their sort key at the current Live and clock; Draft cursors are clock and state bound and expire after five minutes.
8114 : */
8115 : export const zListCccWebsiteCardsResponse = zCccWebsiteCardsPage
8116 :
8117 2356 : export const zListCccCreatorsQuery = z.object({
8118 : limit: z.int().gte(1).lte(100).optional().default(24),
8119 : cursor: z.string().max(200).optional()
8120 : })
8121 :
8122 : /**
8123 : * One page of creators
8124 : */
8125 : export const zListCccCreatorsResponse = zCccCreatorsPage
8126 :
8127 2356 : export const zGetCccCreatorPath = z.object({
8128 : username: z.string().min(1).max(30)
8129 : })
8130 :
8131 : /**
8132 : * Public creator profile
8133 : */
8134 : export const zGetCccCreatorResponse = zCccCreatorProfile
8135 :
8136 2356 : export const zBatchCccItemsBody = z.object({
8137 : expected_draft_rev: z.coerce
8138 : .bigint()
8139 : .gte(BigInt(1))
8140 : .max(BigInt('9223372036854775807'), {
8141 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
8142 : }),
8143 : items: z.array(zCccjson).min(1).max(100)
8144 : })
8145 :
8146 2356 : export const zBatchCccItemsHeaders = z.object({
8147 : 'Idempotency-Key': z.string().min(1).max(200)
8148 : })
8149 :
8150 : /**
8151 : * Flat immutable edits in request order; retry returns identical UIDs/tokens
8152 : */
8153 2356 : export const zBatchCccItemsResponse = z.array(zCccjson)
8154 :
8155 : export const zDiscardCccChangesBody = zCccjson
8156 :
8157 2356 : export const zDiscardCccChangesHeaders = z.object({
8158 : 'Idempotency-Key': z.string().min(1).max(200),
8159 : Prefer: z.enum(['return=minimal']).optional()
8160 : })
8161 :
8162 : /**
8163 : * Updated complete unfiltered private staging snapshot and global unresolved_count
8164 : */
8165 : export const zDiscardCccChangesResponse = zCccjson
8166 :
8167 : /**
8168 : * Private exact approved changes, deferred work, state and selection digest
8169 : */
8170 : export const zGetCccFinalReviewResponse = zCccjson
8171 :
8172 : export const zReviewCccCheckedPublicationBody = zCccjson
8173 :
8174 : /**
8175 : * Exact checked changes and unchecked private work with state and selection digest
8176 : */
8177 : export const zReviewCccCheckedPublicationResponse = zCccjson
8178 :
8179 : export const zReviewCccCheckedReceiptBody = zCccjson
8180 :
8181 : /**
8182 : * Exact checked-version receipt after complete candidate validation
8183 : */
8184 : export const zReviewCccCheckedReceiptResponse = zCccCheckedReviewReceipt
8185 :
8186 : export const zCreateCccItemBody = zCccjson
8187 :
8188 2356 : export const zCreateCccItemHeaders = z.object({
8189 : 'Idempotency-Key': z.string().min(1).max(200)
8190 : })
8191 :
8192 : /**
8193 : * Flat immutable Content edit with exact concurrency tokens
8194 : */
8195 : export const zCreateCccItemResponse = zCccjson
8196 :
8197 2356 : export const zDeleteCccItemBody = z.object({
8198 : expected_draft_rev: z.coerce
8199 : .bigint()
8200 : .gte(BigInt(1))
8201 : .max(BigInt('9223372036854775807'), {
8202 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
8203 : }),
8204 : expected_revision_uid: z.uuid()
8205 : })
8206 :
8207 2356 : export const zDeleteCccItemHeaders = z.object({
8208 : 'Idempotency-Key': z.string().min(1).max(200)
8209 : })
8210 :
8211 2356 : export const zDeleteCccItemPath = z.object({
8212 : uid: z.uuid()
8213 : })
8214 :
8215 : /**
8216 : * Flat retained Content with is_deleted=true and new exact edit token
8217 : */
8218 : export const zDeleteCccItemResponse = zCccjson
8219 :
8220 2356 : export const zGetCccDraftItemPath = z.object({
8221 : uid: z.uuid()
8222 : })
8223 :
8224 : /**
8225 : * Current complete authored JSON with exact working-save tokens and read-only metadata
8226 : */
8227 : export const zGetCccDraftItemResponse = zCccjson
8228 :
8229 : export const zReplaceCccItemBody = zCccjson
8230 :
8231 2356 : export const zReplaceCccItemHeaders = z.object({
8232 : 'Idempotency-Key': z.string().min(1).max(200)
8233 : })
8234 :
8235 2356 : export const zReplaceCccItemPath = z.object({
8236 : uid: z.uuid()
8237 : })
8238 :
8239 : /**
8240 : * New immutable edit; owner stays fixed, author attribution is versioned and saved_by_uid records the actual editor
8241 : */
8242 : export const zReplaceCccItemResponse = zCccjson
8243 :
8244 2356 : export const zRestoreCccItemVersionBody = z.object({
8245 : expected_draft_rev: z.coerce
8246 : .bigint()
8247 : .gte(BigInt(1))
8248 : .max(BigInt('9223372036854775807'), {
8249 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
8250 : }),
8251 : expected_revision_uid: z.uuid(),
8252 : source_revision_uid: z.uuid()
8253 : })
8254 :
8255 2356 : export const zRestoreCccItemVersionHeaders = z.object({
8256 : 'Idempotency-Key': z.string().min(1).max(200)
8257 : })
8258 :
8259 2356 : export const zRestoreCccItemVersionPath = z.object({
8260 : uid: z.uuid()
8261 : })
8262 :
8263 : /**
8264 : * New immutable forward Draft save and exact concurrency tokens
8265 : */
8266 : export const zRestoreCccItemVersionResponse = zCccjson
8267 :
8268 2356 : export const zUploadCccMediaBody = z.intersection(
8269 : z.unknown(),
8270 : z.object({
8271 : change_id: z
8272 : .string()
8273 : .min(1)
8274 : .max(128)
8275 : .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/)
8276 : .optional(),
8277 : expected_draft_rev: z.int().gte(1),
8278 : file: z.string().optional(),
8279 : name: z.string().min(1).max(500),
8280 : originating_entity_uid: z.uuid(),
8281 : role: z.string().min(1).max(500),
8282 : upload_token: z.string().min(1).max(8192).optional()
8283 : })
8284 : )
8285 :
8286 2356 : export const zUploadCccMediaHeaders = z.object({
8287 : 'Idempotency-Key': z.string().min(1).max(200)
8288 : })
8289 :
8290 : /**
8291 : * Private verified media metadata and exact Draft/edit tokens; bytes remain unreleased
8292 : */
8293 : export const zUploadCccMediaResponse = zCccjson
8294 :
8295 : export const zDeleteCccMediaBody = zCccjson
8296 :
8297 2356 : export const zDeleteCccMediaHeaders = z.object({
8298 : 'Idempotency-Key': z.string().min(1).max(200)
8299 : })
8300 :
8301 2356 : export const zDeleteCccMediaPath = z.object({
8302 : uid: z.uuid()
8303 : })
8304 :
8305 : /**
8306 : * New tombstone version and Draft generation; history bytes retained
8307 : */
8308 : export const zDeleteCccMediaResponse = zCccjson
8309 :
8310 2356 : export const zReplaceCccMediaFileBody = z.intersection(
8311 : z.unknown(),
8312 : z.object({
8313 : change_id: z
8314 : .string()
8315 : .min(1)
8316 : .max(128)
8317 : .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/)
8318 : .optional(),
8319 : expected_draft_rev: z.int().gte(1),
8320 : expected_revision_uid: z.uuid(),
8321 : file: z.string().optional(),
8322 : name: z.string().min(1).max(500),
8323 : upload_token: z.string().min(1).max(8192).optional()
8324 : })
8325 : )
8326 :
8327 2356 : export const zReplaceCccMediaFileHeaders = z.object({
8328 : 'Idempotency-Key': z.string().min(1).max(200)
8329 : })
8330 :
8331 2356 : export const zReplaceCccMediaFilePath = z.object({
8332 : uid: z.uuid()
8333 : })
8334 :
8335 : /**
8336 : * New immutable Draft file-version metadata under the same media UID
8337 : */
8338 : export const zReplaceCccMediaFileResponse = zCccjson
8339 :
8340 : export const zRequestCccUploadUrlBody = zCccjson
8341 :
8342 : /**
8343 : * Expiring private upload URL, token and required request headers
8344 : */
8345 : export const zRequestCccUploadUrlResponse = zCccjson
8346 :
8347 : export const zPublishCccDraftBody = zCccjson
8348 :
8349 2356 : export const zPublishCccDraftHeaders = z.object({
8350 : 'Idempotency-Key': z.string().min(1).max(200)
8351 : })
8352 :
8353 : /**
8354 : * New Live, previous Live and fresh Draft state after atomic commit
8355 : */
8356 : export const zPublishCccDraftResponse = zCccjson
8357 :
8358 2356 : export const zGetCccStagingQuery = z.object({
8359 : representation: z.enum(['page', 'selection', 'detail']).optional(),
8360 : limit: z.int().gte(1).lte(100).optional().default(50),
8361 : cursor: z.string().max(2048).optional(),
8362 : sort: z.enum(['name', 'latest']).optional().default('name'),
8363 : change: z.enum(['new', 'updates']).optional(),
8364 : uid: z.uuid().optional(),
8365 : search: z.string().max(300).optional(),
8366 : author_uid: z.string().min(1).optional(),
8367 : saved_by: z.string().min(1).optional(),
8368 : change_id: z
8369 : .string()
8370 : .min(1)
8371 : .max(128)
8372 : .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/)
8373 : .optional(),
8374 : tags: z.array(z.string().min(1).max(200)).max(30).optional(),
8375 : types: z
8376 : .array(z.enum(['model', 'workflow', 'app', 'media', 'template_set']))
8377 : .max(5)
8378 : .optional(),
8379 : statuses: z
8380 : .array(z.enum(['NEW', 'APPROVED', 'DEFERRED', 'DELETED']))
8381 : .max(4)
8382 : .optional()
8383 : })
8384 :
8385 : /**
8386 : * Private review with exact Draft generation and optional sparse page metadata
8387 : */
8388 : export const zGetCccStagingResponse = zCccStagingReview
8389 :
8390 : export const zStageCccChangesBody = zCccjson
8391 :
8392 2356 : export const zStageCccChangesHeaders = z.object({
8393 : 'Idempotency-Key': z.string().min(1).max(200)
8394 : })
8395 :
8396 : /**
8397 : * Atomic matching-set decisions and updated private staging state
8398 : */
8399 : export const zStageCccChangesResponse = zCccjson
8400 :
8401 2356 : export const zListContentCatalogItemsHeaders = z.object({
8402 : 'X-Comfy-Catalog-Authority': z.string().optional()
8403 : })
8404 :
8405 2356 : export const zListContentCatalogItemsQuery = z.object({
8406 : q: z.string().max(300).optional(),
8407 : slug: z.string().optional(),
8408 : kind: z.enum(['MODEL', 'WORKFLOW', 'APP']).optional(),
8409 : type: z.enum(['model', 'workflow', 'app', 'template_set']).optional(),
8410 : surface: z
8411 : .enum([
8412 : 'hub',
8413 : 'cloud_templates',
8414 : 'local_templates',
8415 : 'desktop_starters',
8416 : 'nvidia_performance_tests'
8417 : ])
8418 : .optional(),
8419 : tag: z.string().max(200).optional(),
8420 : use_case: z.string().max(200).optional(),
8421 : sort: z.enum(['sort_order', 'title']).optional().default('sort_order'),
8422 : limit: z.int().gte(1).lte(100).optional().default(20),
8423 : cursor: z.string().max(4096).optional(),
8424 : workflow_slug: z.string().min(1).max(300).optional()
8425 : })
8426 :
8427 : /**
8428 : * Bounded LIVE page with continuation metadata
8429 : */
8430 : export const zListContentCatalogItemsResponse = zCccPublicItemsPage
8431 :
8432 2356 : export const zGetContentCatalogItemHeaders = z.object({
8433 : 'X-Comfy-Catalog-Authority': z.string().optional()
8434 : })
8435 :
8436 2356 : export const zGetContentCatalogItemPath = z.object({
8437 : uid: z.string()
8438 : })
8439 :
8440 : /**
8441 : * Website content record
8442 : */
8443 : export const zGetContentCatalogItemResponse = zContentCatalogRecord
8444 :
8445 2356 : export const zGetCccItemHistoryPath = z.object({
8446 : uid: z.uuid()
8447 : })
8448 :
8449 2356 : export const zGetCccItemHistoryQuery = z.object({
8450 : limit: z.int().gte(1).lte(100).optional().default(20),
8451 : cursor: z.string().max(256).optional()
8452 : })
8453 :
8454 : /**
8455 : * Flat immutable items with catalog_status and saved_at, has_more and optional opaque next_cursor; no total
8456 : */
8457 : export const zGetCccItemHistoryResponse = zCccHistoryPage
8458 :
8459 2356 : export const zGetCccLegacyTargetPath = z.object({
8460 : source: z.string().max(20),
8461 : id: z.string().max(500)
8462 : })
8463 :
8464 : /**
8465 : * Current Hub page of the mapped record
8466 : */
8467 : export const zGetCccLegacyTargetResponse = zCccLegacyTarget
8468 :
8469 2356 : export const zGetCccPublicMediaBytesPath = z.object({
8470 : uid: z.uuid(),
8471 : version: z.uuid()
8472 : })
8473 :
8474 : /**
8475 : * Exact current LIVE bytes; authority checked before byte access; public, max-age=120, must-revalidate with a strong ETag
8476 : */
8477 2356 : export const zGetCccPublicMediaBytesResponse = z.string()
8478 :
8479 2356 : export const zHeadCccPublicMediaBytesPath = z.object({
8480 : uid: z.uuid(),
8481 : version: z.uuid()
8482 : })
8483 :
8484 2356 : export const zListCccWebsiteModelDirectoryHeaders = z.object({
8485 : 'X-Comfy-Catalog-Authority': z.string().optional()
8486 : })
8487 :
8488 2356 : export const zListCccWebsiteModelDirectoryQuery = z.object({
8489 : locale: z.enum(['en', 'zh-CN', 'ja']).optional().default('en')
8490 : })
8491 :
8492 : /**
8493 : * Complete eligible model directory, without Draft generation
8494 : */
8495 : export const zListCccWebsiteModelDirectoryResponse = zCccWebsiteModelDirectory
8496 :
8497 : /**
8498 : * Catalog OpenAPI with contract fingerprint and environment; private no-store
8499 : */
8500 : export const zGetCatalogOpenApiResponse = zCccjson
8501 :
8502 2356 : export const zListCccAdminItemsQuery = z.object({
8503 : types: z
8504 : .array(z.enum(['model', 'workflow', 'app']))
8505 : .max(3)
8506 : .optional(),
8507 : q: z.string().max(300).optional(),
8508 : status: z
8509 : .array(
8510 : z.enum([
8511 : 'not_live',
8512 : 'unpublished',
8513 : 'live',
8514 : 'scheduled',
8515 : 'hidden',
8516 : 'removed'
8517 : ])
8518 : )
8519 : .max(6)
8520 : .optional(),
8521 : saved_by: z.string().min(1).max(200).optional(),
8522 : enabled: z.boolean().optional(),
8523 : uid: z.array(z.uuid()).max(100).optional(),
8524 : missing: z
8525 : .array(z.enum(['cover']))
8526 : .max(1)
8527 : .optional(),
8528 : sort: z.enum(['saved_desc', 'title_asc']).optional().default('saved_desc'),
8529 : limit: z.int().gte(1).lte(100).optional().default(50),
8530 : cursor: z.string().max(2048).optional()
8531 : })
8532 :
8533 : /**
8534 : * One page of staff page rows, the per-type counts and the optional opaque next_cursor
8535 : */
8536 : export const zListCccAdminItemsResponse = zCccPagesPage
8537 :
8538 : /**
8539 : * Current website permission records
8540 : */
8541 2356 : export const zListCccStaffPermissionsResponse = z.object({
8542 : items: z.array(zCccStaffPermissions)
8543 : })
8544 :
8545 2356 : export const zDeleteCccStaffPermissionsPath = z.object({
8546 : account_id: z.string().min(1).max(128)
8547 : })
8548 :
8549 2356 : export const zDeleteCccStaffPermissionsQuery = z.object({
8550 : expected_version: z.coerce
8551 : .bigint()
8552 : .gte(BigInt(1))
8553 : .max(BigInt('9223372036854775807'), {
8554 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
8555 : })
8556 : })
8557 :
8558 : /**
8559 : * Website access removed
8560 : */
8561 2356 : export const zDeleteCccStaffPermissionsResponse = z.void()
8562 :
8563 2356 : export const zPutCccStaffPermissionsBody = z.object({
8564 : can_edit: z.boolean(),
8565 : can_manage_users: z.boolean(),
8566 : can_publish: z.boolean(),
8567 : can_transfer: z.boolean(),
8568 : expected_version: z.coerce
8569 : .bigint()
8570 : .gte(BigInt(0))
8571 : .max(BigInt('9223372036854775807'), {
8572 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
8573 : })
8574 : })
8575 :
8576 2356 : export const zPutCccStaffPermissionsPath = z.object({
8577 : account_id: z.string().min(1).max(128)
8578 : })
8579 :
8580 : /**
8581 : * Saved website permissions and the new version token
8582 : */
8583 : export const zPutCccStaffPermissionsResponse = zCccStaffPermissions
8584 :
8585 2356 : export const zResolveCccStaffAccountBody = z.object({
8586 : email: z.email().max(254)
8587 : })
8588 :
8589 : /**
8590 : * Verified active account, without granting access
8591 : */
8592 2356 : export const zResolveCccStaffAccountResponse = z.object({
8593 : account_id: z.string().min(1).max(128),
8594 : display_name: z.string().max(200).optional()
8595 : })
8596 :
8597 2356 : export const zGetCccPreviewMediaBytesPath = z.object({
8598 : rev: z.int().gte(1),
8599 : uid: z.uuid(),
8600 : version: z.uuid()
8601 : })
8602 :
8603 : /**
8604 : * Verified selected bytes; private no-store; no origin redirect
8605 : */
8606 2356 : export const zGetCccPreviewMediaBytesResponse = z.string()
8607 :
8608 2356 : export const zHeadCccPreviewMediaBytesPath = z.object({
8609 : rev: z.int().gte(1),
8610 : uid: z.uuid(),
8611 : version: z.uuid()
8612 : })
8613 :
8614 : /**
8615 : * Current public authority and its next time boundary; no private identifiers
8616 : */
8617 2356 : export const zGetCccPublicCacheAuthorityResponse = z.object({
8618 : as_of: z.iso.datetime(),
8619 : next_visibility_at: z.iso.datetime().nullable(),
8620 : revision_id: z.coerce
8621 : .bigint()
8622 : .gte(BigInt(1))
8623 : .max(BigInt('9223372036854775807'), {
8624 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
8625 : }),
8626 : token: z.string().regex(/^[0-9a-f]{64}$/),
8627 : valid_until: z.iso.datetime()
8628 : })
8629 :
8630 2356 : export const zGetCccRevisionItemPath = z.object({
8631 : rev: z.coerce.bigint().gte(BigInt(1)).max(BigInt('9223372036854775807'), {
8632 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
8633 : }),
8634 : uid: z.uuid()
8635 : })
8636 :
8637 : /**
8638 : * Flat Content and exact edit/revision context
8639 : */
8640 : export const zGetCccRevisionItemResponse = zCccjson
8641 :
8642 2356 : export const zGetCccWebsiteRootPresentationHeaders = z.object({
8643 : 'X-Comfy-Catalog-Authority': z.string().optional()
8644 : })
8645 :
8646 2356 : export const zGetCccWebsiteRootPresentationQuery = z.object({
8647 : path: z.enum(['/hub/models/', '/hub/workflows/', '/hub/apps/']),
8648 : locale: z.enum(['en', 'zh-CN', 'ja']).optional().default('en'),
8649 : revision_id: z.coerce
8650 : .bigint()
8651 : .gte(BigInt(1))
8652 : .max(BigInt('9223372036854775807'), {
8653 : error: 'Invalid value: Expected int64 to be <= 9223372036854775807'
8654 : })
8655 : .optional()
8656 : })
8657 :
8658 : /**
8659 : * Complete root metadata; no personal data or executable bodies
8660 : */
8661 : export const zGetCccWebsiteRootPresentationResponse =
8662 : zCccWebsiteRootPresentation
8663 :
8664 2356 : export const zGetCccTypeSchemaPath = z.object({
8665 : type: z.enum(['model', 'workflow', 'app', 'template_set', 'media']),
8666 : schema_version: z.int().gte(1)
8667 : })
8668 :
8669 : /**
8670 : * Build-coupled OpenAPI 3.0 schema object, type, version and API environment
8671 : */
8672 : export const zGetCccTypeSchemaResponse = zCccTypeSchema
8673 :
8674 : /**
8675 : * Private state; never cacheable
8676 : */
8677 : export const zGetCccStateResponse = zCccjson
8678 :
8679 2356 : export const zGetCccSiteTagsQuery = z.object({
8680 : view: z.enum(['LIVE', 'DRAFT']).optional().default('DRAFT'),
8681 : now: z.iso.datetime().optional()
8682 : })
8683 :
8684 : /**
8685 : * Complete tag usage with Draft generation
8686 : */
8687 : export const zGetCccSiteTagsResponse = zCccSiteTagUsage
8688 :
8689 2356 : export const zGetVhsQueryVideoQuery = z.object({
8690 : filename: z.string(),
8691 : workspace_id: z.string().optional()
8692 : })
8693 :
8694 : /**
8695 : * Video metadata
8696 : */
8697 2356 : export const zGetVhsQueryVideoResponse = z.object({
8698 : source: z.object({
8699 : duration: z.number(),
8700 : fps: z.number(),
8701 : frames: z.int(),
8702 : size: z.tuple([z.int(), z.int()])
8703 : })
8704 : })
8705 :
8706 2356 : export const zGetVhsViewAudioQuery = z.object({
8707 : filename: z.string(),
8708 : type: z.string().optional(),
8709 : subfolder: z.string().optional(),
8710 : channel: z.string().optional(),
8711 : res: z.int().gte(64).lte(1024).optional(),
8712 : workspace_id: z.string().optional()
8713 : })
8714 :
8715 : /**
8716 : * JPEG thumbnail for `res`
8717 : */
8718 2356 : export const zGetVhsViewAudioResponse = z.string()
8719 :
8720 2356 : export const zGetVhsViewVideoQuery = z.object({
8721 : filename: z.string(),
8722 : type: z.string().optional(),
8723 : subfolder: z.string().optional(),
8724 : channel: z.string().optional(),
8725 : res: z.int().gte(64).lte(1024).optional(),
8726 : workspace_id: z.string().optional()
8727 : })
8728 :
8729 : /**
8730 : * JPEG thumbnail for `res`
8731 : */
8732 2356 : export const zGetVhsViewVideoResponse = z.string()
8733 :
8734 2356 : export const zViewFileQuery = z.object({
8735 : filename: z.string(),
8736 : subfolder: z.string().optional(),
8737 : type: z.string().optional(),
8738 : fullpath: z.string().optional(),
8739 : format: z.string().optional(),
8740 : frame_rate: z.int().optional(),
8741 : workflow: z.string().optional(),
8742 : timestamp: z.int().optional(),
8743 : channel: z.string().optional(),
8744 : res: z.int().gte(64).lte(1024).optional(),
8745 : redirect: z.string().optional(),
8746 : workspace_id: z.string().optional()
8747 : })
8748 :
8749 : /**
8750 : * Success - File content returned (used when channel or res parameter is present), or, with `redirect=false`, the signed link as JSON with `Cache-Control: no-store`.
8751 : */
8752 : export const zViewFileResponse = zViewFileUrlResponse
8753 :
8754 2356 : export const zGetLegacyViewMetadataPath = z.object({
8755 : folder_name: z.string()
8756 : })
8757 :
8758 2356 : export const zGetApiViewVideoAliasQuery = z.object({
8759 : filename: z.string(),
8760 : channel: z.string().optional(),
8761 : res: z.int().gte(64).lte(1024).optional(),
8762 : workspace_id: z.string().optional()
8763 : })
8764 :
8765 : /**
8766 : * JPEG thumbnail for `res`
8767 : */
8768 2356 : export const zGetApiViewVideoAliasResponse = z.string()
8769 :
8770 : /**
8771 : * Empty object for workflow templates
8772 : */
8773 2356 : export const zGetWorkflowTemplatesResponse = z.record(z.string(), z.unknown())
8774 :
8775 2356 : export const zListWorkflowsQuery = z.object({
8776 : limit: z.int().lte(100).optional().default(20),
8777 : offset: z.int().optional().default(0),
8778 : name: z.string().optional(),
8779 : default_view: z.enum(['workflow', 'app']).optional(),
8780 : sort: z
8781 : .enum(['create_time', 'update_time', 'name'])
8782 : .optional()
8783 : .default('create_time'),
8784 : order: z.enum(['asc', 'desc']).optional().default('desc')
8785 : })
8786 :
8787 : /**
8788 : * Success
8789 : */
8790 : export const zListWorkflowsResponse = zWorkflowListResponse
8791 :
8792 : export const zCreateWorkflowBody = zCreateWorkflowRequest
8793 :
8794 : /**
8795 : * Workflow created successfully
8796 : */
8797 : export const zCreateWorkflowResponse = zWorkflowResponse
8798 :
8799 2356 : export const zDeleteWorkflowPath = z.object({
8800 : workflow_id: z.string()
8801 : })
8802 :
8803 : /**
8804 : * Workflow deleted successfully
8805 : */
8806 2356 : export const zDeleteWorkflowResponse = z.void()
8807 :
8808 2356 : export const zGetWorkflowPath = z.object({
8809 : workflow_id: z.string()
8810 : })
8811 :
8812 : /**
8813 : * Success
8814 : */
8815 : export const zGetWorkflowResponse = zWorkflowResponse
8816 :
8817 : export const zUpdateWorkflowBody = zUpdateWorkflowRequest
8818 :
8819 2356 : export const zUpdateWorkflowPath = z.object({
8820 : workflow_id: z.string()
8821 : })
8822 :
8823 : /**
8824 : * Success
8825 : */
8826 : export const zUpdateWorkflowResponse = zWorkflowResponse
8827 :
8828 2356 : export const zGetWorkflowContentPath = z.object({
8829 : workflow_id: z.string()
8830 : })
8831 :
8832 : /**
8833 : * Success
8834 : */
8835 : export const zGetWorkflowContentResponse = zWorkflowVersionContentResponse
8836 :
8837 : export const zForkWorkflowBody = zForkWorkflowRequest
8838 :
8839 2356 : export const zForkWorkflowPath = z.object({
8840 : workflow_id: z.string()
8841 : })
8842 :
8843 : /**
8844 : * Workflow forked successfully
8845 : */
8846 : export const zForkWorkflowResponse = zWorkflowResponse
8847 :
8848 2356 : export const zGetWorkflowSidebarFilePath = z.object({
8849 : workflow_id: z.string()
8850 : })
8851 :
8852 : /**
8853 : * The workflow and its sidebar file agree.
8854 : */
8855 : export const zGetWorkflowSidebarFileResponse = zWorkflowSidebarFileResponse
8856 :
8857 : export const zCreateWorkflowVersionBody = zCreateWorkflowVersionRequest
8858 :
8859 2356 : export const zCreateWorkflowVersionPath = z.object({
8860 : workflow_id: z.string()
8861 : })
8862 :
8863 : /**
8864 : * Version created successfully
8865 : */
8866 : export const zCreateWorkflowVersionResponse = zWorkflowVersionResponse
8867 :
8868 2356 : export const zGetPublishedWorkflowPath = z.object({
8869 : share_id: z.string()
8870 : })
8871 :
8872 : /**
8873 : * Published workflow details with asset statuses
8874 : */
8875 : export const zGetPublishedWorkflowResponse = zPublishedWorkflowDetail
8876 :
8877 : export const zCreateWorkflowUploadUrlBody = zWorkflowUploadUrlRequest
8878 :
8879 : /**
8880 : * Upload grant minted
8881 : */
8882 : export const zCreateWorkflowUploadUrlResponse = zUploadGrantResponse
8883 :
8884 2356 : export const zListWorkspaceApiKeysQuery = z.object({
8885 : include_revoked: z.boolean().optional().default(false)
8886 : })
8887 :
8888 : /**
8889 : * List of API keys
8890 : */
8891 : export const zListWorkspaceApiKeysResponse2 = zListWorkspaceApiKeysResponse
8892 :
8893 : export const zCreateWorkspaceApiKeyBody = zCreateWorkspaceApiKeyRequest
8894 :
8895 : /**
8896 : * API key created (plaintext returned once)
8897 : */
8898 : export const zCreateWorkspaceApiKeyResponse2 = zCreateWorkspaceApiKeyResponse
8899 :
8900 2356 : export const zRevokeWorkspaceApiKeyPath = z.object({
8901 : id: z.uuid()
8902 : })
8903 :
8904 : /**
8905 : * API key revoked
8906 : */
8907 2356 : export const zRevokeWorkspaceApiKeyResponse = z.void()
8908 :
8909 : /**
8910 : * List of pending invites
8911 : */
8912 : export const zListWorkspaceInvitesResponse = zListInvitesResponse
8913 :
8914 : export const zCreateWorkspaceInviteBody = zCreateInviteRequest
8915 :
8916 : /**
8917 : * Invite created
8918 : */
8919 : export const zCreateWorkspaceInviteResponse = zPendingInvite
8920 :
8921 2356 : export const zRevokeWorkspaceInvitePath = z.object({
8922 : inviteId: z.string()
8923 : })
8924 :
8925 : /**
8926 : * Invite revoked
8927 : */
8928 2356 : export const zRevokeWorkspaceInviteResponse = z.void()
8929 :
8930 2356 : export const zResendWorkspaceInvitePath = z.object({
8931 : inviteId: z.string()
8932 : })
8933 :
8934 : /**
8935 : * Invite refreshed and queued for delivery
8936 : */
8937 : export const zResendWorkspaceInviteResponse = zPendingInvite
8938 :
8939 : /**
8940 : * Successfully left workspace
8941 : */
8942 2356 : export const zLeaveWorkspaceResponse = z.void()
8943 :
8944 2356 : export const zListWorkspaceMembersQuery = z.object({
8945 : offset: z.int().gte(0).optional().default(0),
8946 : limit: z.int().gte(1).lte(100).optional().default(20)
8947 : })
8948 :
8949 : /**
8950 : * List of members
8951 : */
8952 : export const zListWorkspaceMembersResponse = zListMembersResponse
8953 :
8954 2356 : export const zBulkRevokeWorkspaceMemberApiKeysPath = z.object({
8955 : user_id: z.string().min(1)
8956 : })
8957 :
8958 : /**
8959 : * Keys revoked successfully
8960 : */
8961 : export const zBulkRevokeWorkspaceMemberApiKeysResponse =
8962 : zBulkRevokeApiKeysResponse
8963 :
8964 2356 : export const zRemoveWorkspaceMemberPath = z.object({
8965 : userId: z.string()
8966 : })
8967 :
8968 : /**
8969 : * Member removed
8970 : */
8971 2356 : export const zRemoveWorkspaceMemberResponse = z.void()
8972 :
8973 : export const zUpdateWorkspaceMemberRoleBody = zUpdateMemberRoleRequest
8974 :
8975 2356 : export const zUpdateWorkspaceMemberRolePath = z.object({
8976 : userId: z.string()
8977 : })
8978 :
8979 : /**
8980 : * Member role updated
8981 : */
8982 : export const zUpdateWorkspaceMemberRoleResponse = zMember
8983 :
8984 : /**
8985 : * The policy document
8986 : */
8987 : export const zGetProviderPolicyResponse = zProviderPolicy
8988 :
8989 : export const zPutProviderPolicyBody = zProviderPolicy
8990 :
8991 : /**
8992 : * Policy replaced
8993 : */
8994 : export const zPutProviderPolicyResponse = zProviderPolicy
8995 :
8996 : /**
8997 : * List of workspaces
8998 : */
8999 : export const zListWorkspacesResponse2 = zListWorkspacesResponse
9000 :
9001 : export const zCreateWorkspaceBody = zCreateWorkspaceRequest
9002 :
9003 : /**
9004 : * Workspace created
9005 : */
9006 : export const zCreateWorkspaceResponse = zWorkspace
9007 :
9008 2356 : export const zDeleteWorkspacePath = z.object({
9009 : id: z.string()
9010 : })
9011 :
9012 : /**
9013 : * Workspace deleted
9014 : */
9015 2356 : export const zDeleteWorkspaceResponse = z.void()
9016 :
9017 2356 : export const zGetWorkspacePath = z.object({
9018 : id: z.string()
9019 : })
9020 :
9021 : /**
9022 : * Workspace details
9023 : */
9024 : export const zGetWorkspaceResponse = zWorkspace
9025 :
9026 : export const zUpdateWorkspaceBody = zUpdateWorkspaceRequest
9027 :
9028 2356 : export const zUpdateWorkspacePath = z.object({
9029 : id: z.string()
9030 : })
9031 :
9032 : /**
9033 : * Workspace updated
9034 : */
9035 : export const zUpdateWorkspaceResponse = zWorkspace
9036 :
9037 2356 : export const zClearWorkspaceDefaultDeploymentPath = z.object({
9038 : id: z.string()
9039 : })
9040 :
9041 : /**
9042 : * Cleared
9043 : */
9044 2356 : export const zClearWorkspaceDefaultDeploymentResponse = z.void()
9045 :
9046 : export const zSetWorkspaceDefaultDeploymentBody =
9047 : zPickWorkspaceDeploymentRequest
9048 :
9049 2356 : export const zSetWorkspaceDefaultDeploymentPath = z.object({
9050 : id: z.string()
9051 : })
9052 :
9053 : /**
9054 : * Set; members with no pick are on this deployment from their next request
9055 : */
9056 2356 : export const zSetWorkspaceDefaultDeploymentResponse = z.void()
9057 :
9058 2356 : export const zClearWorkspaceDeploymentPath = z.object({
9059 : id: z.string()
9060 : })
9061 :
9062 2356 : export const zClearWorkspaceDeploymentQuery = z.object({
9063 : follow: z.enum(['workspace']).optional()
9064 : })
9065 :
9066 : /**
9067 : * Cleared
9068 : */
9069 2356 : export const zClearWorkspaceDeploymentResponse = z.void()
9070 :
9071 : export const zPickWorkspaceDeploymentBody = zPickWorkspaceDeploymentRequest
9072 :
9073 2356 : export const zPickWorkspaceDeploymentPath = z.object({
9074 : id: z.string()
9075 : })
9076 :
9077 : /**
9078 : * Picked; the cookie on this response carries it
9079 : */
9080 2356 : export const zPickWorkspaceDeploymentResponse = z.void()
9081 :
9082 2356 : export const zGetWorkspaceDeploymentCpuServerPath = z.object({
9083 : id: z.string()
9084 : })
9085 :
9086 : /**
9087 : * Which step the deployment's CPU server is on
9088 : */
9089 : export const zGetWorkspaceDeploymentCpuServerResponse =
9090 : zWorkspaceDeploymentCpuServer
9091 :
9092 2356 : export const zListWorkspaceDeploymentsPath = z.object({
9093 : id: z.string()
9094 : })
9095 :
9096 2356 : export const zListWorkspaceDeploymentsQuery = z.object({
9097 : started_deployment_id: z.array(z.string()).optional()
9098 : })
9099 :
9100 : /**
9101 : * The workspace's live deployments, newest first
9102 : */
9103 : export const zListWorkspaceDeploymentsResponse = zWorkspaceDeploymentList
9104 :
9105 2356 : export const zStartWorkspaceDeploymentPath = z.object({
9106 : id: z.string(),
9107 : deployment_id: z.string()
9108 : })
9109 :
9110 : /**
9111 : * Accepted; the deployment is starting, or already up
9112 : */
9113 : export const zStartWorkspaceDeploymentResponse = zStartWorkspaceDeploymentResult
9114 :
9115 : export const zCheckWorkspaceDeploymentCompatibilityBody =
9116 : zDeploymentCompatibilityRequest
9117 :
9118 2356 : export const zCheckWorkspaceDeploymentCompatibilityPath = z.object({
9119 : id: z.string()
9120 : })
9121 :
9122 : /**
9123 : * The missing node types per deployment, newest first, and for Comfy Cloud
9124 : */
9125 : export const zCheckWorkspaceDeploymentCompatibilityResponse =
9126 : zDeploymentCompatibility
9127 :
9128 : /**
9129 : * The credential's workspace
9130 : */
9131 : export const zGetCurrentWorkspaceResponse = zCurrentWorkspaceResponse
9132 :
9133 2356 : export const zGetStaticExtensionsPath = z.object({
9134 : path: z.string()
9135 : })
9136 :
9137 2356 : export const zRedirectExtensionScriptsPath = z.object({
9138 : file: z.string()
9139 : })
9140 :
9141 : /**
9142 : * Service is healthy
9143 : */
9144 2356 : export const zGetHealthResponse = z.string()
9145 :
9146 : /**
9147 : * Map of folder type name to list of path entries
9148 : */
9149 2356 : export const zGetInternalFolderPathsResponse = z.record(
9150 : z.string(),
9151 : z.array(z.array(z.string()))
9152 : )
9153 :
9154 : /**
9155 : * Log text
9156 : */
9157 2356 : export const zGetInternalLogsResponse = z.string()
9158 :
9159 : /**
9160 : * Structured log data
9161 : */
9162 2356 : export const zGetInternalLogsRawResponse = z.object({
9163 : entries: z
9164 : .array(
9165 : z.object({
9166 : m: z.string().optional(),
9167 : t: z.number().optional()
9168 : })
9169 : )
9170 : .optional(),
9171 : size: z
9172 : .object({
9173 : cols: z.int().optional(),
9174 : rows: z.int().optional()
9175 : })
9176 : .optional()
9177 : })
9178 :
9179 2356 : export const zSubscribeToLogsBody = z.object({
9180 : clientId: z.string(),
9181 : enabled: z.boolean()
9182 : })
9183 :
9184 2356 : export const zGetStaticKjwebAsyncPath = z.object({
9185 : path: z.string()
9186 : })
9187 :
9188 2356 : export const zGetOAuthAuthorizeQuery = z.object({
9189 : response_type: z.string().optional(),
9190 : client_id: z.string().optional(),
9191 : redirect_uri: z.string().optional(),
9192 : scope: z.string().optional(),
9193 : state: z.string().optional(),
9194 : code_challenge: z.string().optional(),
9195 : code_challenge_method: z.string().optional(),
9196 : resource: z.string().optional(),
9197 : oauth_request_id: z.string().optional()
9198 : })
9199 :
9200 : /**
9201 : * Consent challenge payload (cookie present, email verified). Frontend renders the consent UI from this payload and POSTs back to /oauth/authorize.
9202 : *
9203 : */
9204 : export const zGetOAuthAuthorizeResponse = zOAuthConsentChallenge
9205 :
9206 2356 : export const zPostOAuthAuthorizeBody = z.object({
9207 : csrf_token: z.string(),
9208 : decision: z.enum(['allow', 'deny']),
9209 : oauth_request_id: z.uuid(),
9210 : workspace_id: z.string()
9211 : })
9212 :
9213 : /**
9214 : * Redirect URL for the frontend to navigate to (allow → with code+state; deny → with error+state)
9215 : */
9216 : export const zPostOAuthAuthorizeResponse = zOAuthAuthorizeRedirectResponse
9217 :
9218 : export const zPostOAuthRegisterBody = zOAuthRegisterRequest
9219 :
9220 : /**
9221 : * Registered. Body echoes the metadata RFC 7591 §3.2.1 requires.
9222 : */
9223 : export const zPostOAuthRegisterResponse = zOAuthRegisterResponse
9224 :
9225 2356 : export const zPostOAuthRevokeBody = z.object({
9226 : client_id: z.string(),
9227 : client_secret: z.string().optional(),
9228 : token: z.string(),
9229 : token_type_hint: z.string().optional()
9230 : })
9231 :
9232 2356 : export const zPostOAuthTokenBody = z.object({
9233 : client_id: z.string(),
9234 : client_secret: z.string().optional(),
9235 : code: z.string().optional(),
9236 : code_verifier: z.string().optional(),
9237 : grant_type: z.enum(['authorization_code', 'refresh_token']),
9238 : redirect_uri: z.string().optional(),
9239 : refresh_token: z.string().optional(),
9240 : scope: z.string().optional()
9241 : })
9242 :
9243 : /**
9244 : * New token pair
9245 : */
9246 : export const zPostOAuthTokenResponse = zOAuthTokenResponse
9247 :
9248 2356 : export const zGetTemplateProxyPath = z.object({
9249 : path: z.string()
9250 : })
9251 :
9252 2356 : export const zGetViewCompatAliasQuery = z.object({
9253 : filename: z.string(),
9254 : channel: z.string().optional(),
9255 : res: z.int().gte(64).lte(1024).optional(),
9256 : workspace_id: z.string().optional()
9257 : })
9258 :
9259 : /**
9260 : * JPEG thumbnail for `res`
9261 : */
9262 2356 : export const zGetViewCompatAliasResponse = z.string()
9263 :
9264 2356 : export const zGetWebsocketQuery = z.object({
9265 : token: z.string().optional(),
9266 : workspace_id: z.string().optional(),
9267 : clientId: z.string().optional()
9268 : })
|