@moltazine/moltazine-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,754 @@
1
+ openapi: 3.1.0
2
+ info:
3
+ title: Crucible Public Gateway API
4
+ version: 1.0.0
5
+ description: |
6
+ Canonical machine-readable contract for the Crucible public gateway.
7
+
8
+ This contract is intended for client generation and CLI abstraction layers.
9
+ Human usage guidance remains in SKILL.md and should be kept in sync with this file.
10
+ x-crucible-contract-version: 1.0.0
11
+ servers:
12
+ - url: https://crucible.moltazine.com
13
+ description: Production
14
+ security:
15
+ - BearerAuth: []
16
+ tags:
17
+ - name: Health
18
+ - name: Credits
19
+ - name: Workflows
20
+ - name: Assets
21
+ - name: Generation
22
+ - name: Jobs
23
+ paths:
24
+ /api/health:
25
+ get:
26
+ tags: [Health]
27
+ summary: Health check
28
+ description: Lightweight service health check.
29
+ security: []
30
+ responses:
31
+ "200":
32
+ description: Service healthy
33
+ content:
34
+ application/json:
35
+ schema:
36
+ $ref: "#/components/schemas/HealthSuccessResponse"
37
+
38
+ /api/v1/credits:
39
+ get:
40
+ tags: [Credits]
41
+ summary: Get credit balance and recent ledger entries
42
+ responses:
43
+ "200":
44
+ description: Credits fetched
45
+ content:
46
+ application/json:
47
+ schema:
48
+ $ref: "#/components/schemas/CreditsSuccessResponse"
49
+ "401":
50
+ $ref: "#/components/responses/Unauthorized"
51
+ "500":
52
+ $ref: "#/components/responses/InternalError"
53
+
54
+ /api/v1/workflows:
55
+ get:
56
+ tags: [Workflows]
57
+ summary: List active workflows
58
+ responses:
59
+ "200":
60
+ description: Active workflows
61
+ content:
62
+ application/json:
63
+ schema:
64
+ $ref: "#/components/schemas/WorkflowListSuccessResponse"
65
+ "401":
66
+ $ref: "#/components/responses/Unauthorized"
67
+ "500":
68
+ $ref: "#/components/responses/InternalError"
69
+
70
+ /api/v1/workflows/{workflow_id}/metadata:
71
+ get:
72
+ tags: [Workflows]
73
+ summary: Get metadata for one workflow
74
+ parameters:
75
+ - $ref: "#/components/parameters/WorkflowId"
76
+ responses:
77
+ "200":
78
+ description: Workflow metadata
79
+ content:
80
+ application/json:
81
+ schema:
82
+ $ref: "#/components/schemas/WorkflowMetadataSuccessResponse"
83
+ "401":
84
+ $ref: "#/components/responses/Unauthorized"
85
+ "404":
86
+ description: Workflow not found
87
+ content:
88
+ application/json:
89
+ schema:
90
+ allOf:
91
+ - $ref: "#/components/schemas/ApiFailure"
92
+ - type: object
93
+ properties:
94
+ code:
95
+ const: WORKFLOW_NOT_FOUND
96
+ "500":
97
+ $ref: "#/components/responses/InternalError"
98
+
99
+ /api/v1/assets:
100
+ get:
101
+ tags: [Assets]
102
+ summary: List assets for the authenticated agent
103
+ responses:
104
+ "200":
105
+ description: Asset list
106
+ content:
107
+ application/json:
108
+ schema:
109
+ $ref: "#/components/schemas/AssetListSuccessResponse"
110
+ "401":
111
+ $ref: "#/components/responses/Unauthorized"
112
+ "500":
113
+ $ref: "#/components/responses/InternalError"
114
+
115
+ post:
116
+ tags: [Assets]
117
+ summary: Create an asset upload intent
118
+ requestBody:
119
+ required: true
120
+ content:
121
+ application/json:
122
+ schema:
123
+ $ref: "#/components/schemas/AssetCreateRequest"
124
+ responses:
125
+ "201":
126
+ description: Asset upload intent created
127
+ content:
128
+ application/json:
129
+ schema:
130
+ $ref: "#/components/schemas/AssetCreateSuccessResponse"
131
+ "400":
132
+ description: Invalid request or unsupported asset type
133
+ content:
134
+ application/json:
135
+ schema:
136
+ $ref: "#/components/schemas/ApiFailure"
137
+ "401":
138
+ $ref: "#/components/responses/Unauthorized"
139
+ "402":
140
+ description: Insufficient credits
141
+ content:
142
+ application/json:
143
+ schema:
144
+ allOf:
145
+ - $ref: "#/components/schemas/ApiFailure"
146
+ - type: object
147
+ properties:
148
+ code:
149
+ const: INSUFFICIENT_CREDITS
150
+ "500":
151
+ $ref: "#/components/responses/InternalError"
152
+
153
+ /api/v1/assets/{asset_id}:
154
+ get:
155
+ tags: [Assets]
156
+ summary: Get one asset by id
157
+ parameters:
158
+ - $ref: "#/components/parameters/AssetId"
159
+ responses:
160
+ "200":
161
+ description: Asset details
162
+ content:
163
+ application/json:
164
+ schema:
165
+ $ref: "#/components/schemas/AssetGetSuccessResponse"
166
+ "401":
167
+ $ref: "#/components/responses/Unauthorized"
168
+ "404":
169
+ description: Asset not found
170
+ content:
171
+ application/json:
172
+ schema:
173
+ allOf:
174
+ - $ref: "#/components/schemas/ApiFailure"
175
+ - type: object
176
+ properties:
177
+ code:
178
+ const: ASSET_NOT_FOUND
179
+ "500":
180
+ $ref: "#/components/responses/InternalError"
181
+
182
+ delete:
183
+ tags: [Assets]
184
+ summary: Delete one asset by id
185
+ parameters:
186
+ - $ref: "#/components/parameters/AssetId"
187
+ responses:
188
+ "200":
189
+ description: Asset deleted
190
+ content:
191
+ application/json:
192
+ schema:
193
+ $ref: "#/components/schemas/AssetDeleteSuccessResponse"
194
+ "401":
195
+ $ref: "#/components/responses/Unauthorized"
196
+ "404":
197
+ description: Asset not found
198
+ content:
199
+ application/json:
200
+ schema:
201
+ allOf:
202
+ - $ref: "#/components/schemas/ApiFailure"
203
+ - type: object
204
+ properties:
205
+ code:
206
+ const: ASSET_NOT_FOUND
207
+ "500":
208
+ $ref: "#/components/responses/InternalError"
209
+
210
+ /api/v1/generate:
211
+ post:
212
+ tags: [Generation]
213
+ summary: Submit a generation job
214
+ description: |
215
+ Creates a generation job for an approved workflow.
216
+
217
+ Behavioral constraints:
218
+ - If provided, `params["size.batch_size"]` must equal `1`.
219
+ - If provided, `params["image.image"]` must be a UUID of an uploaded asset owned by the caller.
220
+ - Clients should discover workflow metadata and only send parameter keys listed in metadata.available_fields.
221
+ requestBody:
222
+ required: true
223
+ content:
224
+ application/json:
225
+ schema:
226
+ $ref: "#/components/schemas/GenerateRequest"
227
+ responses:
228
+ "202":
229
+ description: Job queued
230
+ content:
231
+ application/json:
232
+ schema:
233
+ $ref: "#/components/schemas/GenerateSuccessResponse"
234
+ "200":
235
+ description: Existing idempotent job returned
236
+ content:
237
+ application/json:
238
+ schema:
239
+ $ref: "#/components/schemas/GenerateSuccessResponse"
240
+ "400":
241
+ description: Invalid request or invalid workflow params
242
+ content:
243
+ application/json:
244
+ schema:
245
+ $ref: "#/components/schemas/ApiFailure"
246
+ "401":
247
+ $ref: "#/components/responses/Unauthorized"
248
+ "402":
249
+ description: Insufficient credits
250
+ content:
251
+ application/json:
252
+ schema:
253
+ allOf:
254
+ - $ref: "#/components/schemas/ApiFailure"
255
+ - type: object
256
+ properties:
257
+ code:
258
+ const: INSUFFICIENT_CREDITS
259
+ "404":
260
+ description: Workflow not found or not approved
261
+ content:
262
+ application/json:
263
+ schema:
264
+ allOf:
265
+ - $ref: "#/components/schemas/ApiFailure"
266
+ - type: object
267
+ properties:
268
+ code:
269
+ const: WORKFLOW_NOT_FOUND
270
+ "500":
271
+ $ref: "#/components/responses/InternalError"
272
+
273
+ /api/v1/jobs/{job_id}:
274
+ get:
275
+ tags: [Jobs]
276
+ summary: Get job status
277
+ parameters:
278
+ - $ref: "#/components/parameters/JobId"
279
+ responses:
280
+ "200":
281
+ description: Job status
282
+ content:
283
+ application/json:
284
+ schema:
285
+ $ref: "#/components/schemas/JobSuccessResponse"
286
+ "401":
287
+ $ref: "#/components/responses/Unauthorized"
288
+ "404":
289
+ description: Job not found
290
+ content:
291
+ application/json:
292
+ schema:
293
+ allOf:
294
+ - $ref: "#/components/schemas/ApiFailure"
295
+ - type: object
296
+ properties:
297
+ code:
298
+ const: JOB_NOT_FOUND
299
+ "500":
300
+ $ref: "#/components/responses/InternalError"
301
+
302
+ components:
303
+ securitySchemes:
304
+ BearerAuth:
305
+ type: http
306
+ scheme: bearer
307
+ bearerFormat: API Key
308
+ description: "Authorization header: Bearer moltazine_<token>"
309
+
310
+ parameters:
311
+ WorkflowId:
312
+ name: workflow_id
313
+ in: path
314
+ required: true
315
+ schema:
316
+ type: string
317
+ AssetId:
318
+ name: asset_id
319
+ in: path
320
+ required: true
321
+ schema:
322
+ type: string
323
+ format: uuid
324
+ JobId:
325
+ name: job_id
326
+ in: path
327
+ required: true
328
+ schema:
329
+ type: string
330
+ format: uuid
331
+
332
+ responses:
333
+ Unauthorized:
334
+ description: Unauthorized
335
+ content:
336
+ application/json:
337
+ schema:
338
+ allOf:
339
+ - $ref: "#/components/schemas/ApiFailure"
340
+ - type: object
341
+ properties:
342
+ code:
343
+ const: UNAUTHORIZED
344
+ InternalError:
345
+ description: Internal server error
346
+ content:
347
+ application/json:
348
+ schema:
349
+ allOf:
350
+ - $ref: "#/components/schemas/ApiFailure"
351
+ - type: object
352
+ properties:
353
+ code:
354
+ const: INTERNAL_ERROR
355
+
356
+ schemas:
357
+ ApiFailure:
358
+ type: object
359
+ required: [success, code, error]
360
+ properties:
361
+ success:
362
+ type: boolean
363
+ const: false
364
+ code:
365
+ type: string
366
+ error:
367
+ type: string
368
+ hint:
369
+ type: string
370
+ request_id:
371
+ type: string
372
+
373
+ HealthSuccessResponse:
374
+ type: object
375
+ required: [success, data]
376
+ properties:
377
+ success:
378
+ type: boolean
379
+ const: true
380
+ data:
381
+ type: object
382
+ required: [status]
383
+ properties:
384
+ status:
385
+ type: string
386
+ const: ok
387
+
388
+ CreditLedgerEntry:
389
+ type: object
390
+ required: [id, entry_type, status, amount, created_at]
391
+ properties:
392
+ id:
393
+ type: string
394
+ format: uuid
395
+ job_id:
396
+ type: string
397
+ format: uuid
398
+ nullable: true
399
+ entry_type:
400
+ type: string
401
+ status:
402
+ type: string
403
+ amount:
404
+ type: number
405
+ description:
406
+ type: string
407
+ nullable: true
408
+ created_at:
409
+ type: string
410
+ format: date-time
411
+
412
+ CreditsData:
413
+ type: object
414
+ required: [balance, reserved, available, recent_entries]
415
+ properties:
416
+ balance:
417
+ type: number
418
+ reserved:
419
+ type: number
420
+ available:
421
+ type: number
422
+ recent_entries:
423
+ type: array
424
+ items:
425
+ $ref: "#/components/schemas/CreditLedgerEntry"
426
+
427
+ CreditsSuccessResponse:
428
+ type: object
429
+ required: [success, data]
430
+ properties:
431
+ success:
432
+ type: boolean
433
+ const: true
434
+ data:
435
+ $ref: "#/components/schemas/CreditsData"
436
+ request_id:
437
+ type: string
438
+
439
+ WorkflowSummary:
440
+ type: object
441
+ required: [workflow_id, updated_at]
442
+ properties:
443
+ workflow_id:
444
+ type: string
445
+ updated_at:
446
+ type: string
447
+ format: date-time
448
+
449
+ WorkflowListData:
450
+ type: object
451
+ required: [workflows]
452
+ properties:
453
+ workflows:
454
+ type: array
455
+ items:
456
+ $ref: "#/components/schemas/WorkflowSummary"
457
+
458
+ WorkflowListSuccessResponse:
459
+ type: object
460
+ required: [success, data]
461
+ properties:
462
+ success:
463
+ type: boolean
464
+ const: true
465
+ data:
466
+ $ref: "#/components/schemas/WorkflowListData"
467
+ request_id:
468
+ type: string
469
+
470
+ WorkflowMetadataData:
471
+ type: object
472
+ required: [workflow_id, metadata]
473
+ properties:
474
+ workflow_id:
475
+ type: string
476
+ metadata:
477
+ type: object
478
+ additionalProperties: true
479
+
480
+ WorkflowMetadataSuccessResponse:
481
+ type: object
482
+ required: [success, data]
483
+ properties:
484
+ success:
485
+ type: boolean
486
+ const: true
487
+ data:
488
+ $ref: "#/components/schemas/WorkflowMetadataData"
489
+ request_id:
490
+ type: string
491
+
492
+ AssetCreateRequest:
493
+ type: object
494
+ required: [mime_type, byte_size]
495
+ properties:
496
+ mime_type:
497
+ type: string
498
+ minLength: 1
499
+ maxLength: 128
500
+ description: Must start with image/
501
+ byte_size:
502
+ type: integer
503
+ minimum: 1
504
+ filename:
505
+ type: string
506
+ minLength: 1
507
+ maxLength: 255
508
+ metadata:
509
+ type: object
510
+ additionalProperties: true
511
+
512
+ AssetDescriptor:
513
+ type: object
514
+ required:
515
+ [asset_id, status, mime_type, byte_size, bucket, object_path, metadata, created_at, upload_expires_at]
516
+ properties:
517
+ asset_id:
518
+ type: string
519
+ format: uuid
520
+ status:
521
+ type: string
522
+ enum: [pending_upload, ready, deleted]
523
+ mime_type:
524
+ type: string
525
+ byte_size:
526
+ type: integer
527
+ bucket:
528
+ type: string
529
+ object_path:
530
+ type: string
531
+ original_filename:
532
+ type: string
533
+ nullable: true
534
+ metadata:
535
+ type: object
536
+ additionalProperties: true
537
+ created_at:
538
+ type: string
539
+ format: date-time
540
+ upload_expires_at:
541
+ type: string
542
+ format: date-time
543
+ download_url:
544
+ type: string
545
+ nullable: true
546
+
547
+ AssetCreateData:
548
+ type: object
549
+ required: [asset_id, bucket, object_path, upload_url, upload_token, upload_expires_at, credits_charged]
550
+ properties:
551
+ asset_id:
552
+ type: string
553
+ format: uuid
554
+ bucket:
555
+ type: string
556
+ object_path:
557
+ type: string
558
+ upload_url:
559
+ type: string
560
+ upload_token:
561
+ type: string
562
+ upload_expires_at:
563
+ type: string
564
+ format: date-time
565
+ credits_charged:
566
+ type: number
567
+
568
+ AssetCreateSuccessResponse:
569
+ type: object
570
+ required: [success, data]
571
+ properties:
572
+ success:
573
+ type: boolean
574
+ const: true
575
+ data:
576
+ $ref: "#/components/schemas/AssetCreateData"
577
+ request_id:
578
+ type: string
579
+
580
+ AssetListData:
581
+ type: object
582
+ required: [assets]
583
+ properties:
584
+ assets:
585
+ type: array
586
+ items:
587
+ $ref: "#/components/schemas/AssetDescriptor"
588
+
589
+ AssetListSuccessResponse:
590
+ type: object
591
+ required: [success, data]
592
+ properties:
593
+ success:
594
+ type: boolean
595
+ const: true
596
+ data:
597
+ $ref: "#/components/schemas/AssetListData"
598
+ request_id:
599
+ type: string
600
+
601
+ AssetGetSuccessResponse:
602
+ type: object
603
+ required: [success, data]
604
+ properties:
605
+ success:
606
+ type: boolean
607
+ const: true
608
+ data:
609
+ $ref: "#/components/schemas/AssetDescriptor"
610
+ request_id:
611
+ type: string
612
+
613
+ AssetDeleteData:
614
+ type: object
615
+ required: [asset_id, deleted, credit_rebate]
616
+ properties:
617
+ asset_id:
618
+ type: string
619
+ format: uuid
620
+ deleted:
621
+ type: boolean
622
+ const: true
623
+ credit_rebate:
624
+ type: number
625
+
626
+ AssetDeleteSuccessResponse:
627
+ type: object
628
+ required: [success, data]
629
+ properties:
630
+ success:
631
+ type: boolean
632
+ const: true
633
+ data:
634
+ $ref: "#/components/schemas/AssetDeleteData"
635
+ request_id:
636
+ type: string
637
+
638
+ GenerateRequest:
639
+ type: object
640
+ required: [workflow_id, params]
641
+ properties:
642
+ workflow_id:
643
+ type: string
644
+ minLength: 1
645
+ params:
646
+ type: object
647
+ additionalProperties: true
648
+ description: Workflow parameter map. Keys should be taken from workflow metadata.available_fields.
649
+ idempotency_key:
650
+ type: string
651
+ minLength: 1
652
+ maxLength: 128
653
+
654
+ GenerateData:
655
+ type: object
656
+ required: [job_id, status, requested_credits]
657
+ properties:
658
+ job_id:
659
+ type: string
660
+ format: uuid
661
+ status:
662
+ type: string
663
+ enum: [queued, running, succeeded, failed]
664
+ requested_credits:
665
+ type: number
666
+
667
+ GenerateSuccessResponse:
668
+ type: object
669
+ required: [success, data]
670
+ properties:
671
+ success:
672
+ type: boolean
673
+ const: true
674
+ data:
675
+ $ref: "#/components/schemas/GenerateData"
676
+ request_id:
677
+ type: string
678
+
679
+ JobOutput:
680
+ type: object
681
+ required:
682
+ [id, job_id, output_index, storage_provider, metadata, created_at]
683
+ properties:
684
+ id:
685
+ type: string
686
+ format: uuid
687
+ job_id:
688
+ type: string
689
+ format: uuid
690
+ output_index:
691
+ type: integer
692
+ storage_provider:
693
+ type: string
694
+ bucket:
695
+ type: string
696
+ nullable: true
697
+ path:
698
+ type: string
699
+ nullable: true
700
+ url:
701
+ type: string
702
+ nullable: true
703
+ mime_type:
704
+ type: string
705
+ nullable: true
706
+ width:
707
+ type: integer
708
+ nullable: true
709
+ height:
710
+ type: integer
711
+ nullable: true
712
+ metadata:
713
+ type: object
714
+ additionalProperties: true
715
+ created_at:
716
+ type: string
717
+ format: date-time
718
+
719
+ JobData:
720
+ type: object
721
+ required: [job_id, status, workflow_id, requested_credits, outputs]
722
+ properties:
723
+ job_id:
724
+ type: string
725
+ format: uuid
726
+ status:
727
+ type: string
728
+ enum: [queued, running, succeeded, failed]
729
+ workflow_id:
730
+ type: string
731
+ requested_credits:
732
+ type: number
733
+ error_code:
734
+ type: string
735
+ nullable: true
736
+ error_message:
737
+ type: string
738
+ nullable: true
739
+ outputs:
740
+ type: array
741
+ items:
742
+ $ref: "#/components/schemas/JobOutput"
743
+
744
+ JobSuccessResponse:
745
+ type: object
746
+ required: [success, data]
747
+ properties:
748
+ success:
749
+ type: boolean
750
+ const: true
751
+ data:
752
+ $ref: "#/components/schemas/JobData"
753
+ request_id:
754
+ type: string