@snaptrude/plugin-core 0.2.6 → 0.2.8

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,871 @@
1
+ import * as z from "zod"
2
+ import type { PluginApiReturn } from "../../types"
3
+
4
+ const JsonPrimitive = z.union([z.string(), z.number(), z.boolean(), z.null()])
5
+ type JsonValue =
6
+ | z.infer<typeof JsonPrimitive>
7
+ | JsonValue[]
8
+ | { [key: string]: JsonValue }
9
+ const JsonValue: z.ZodType<JsonValue> = z.lazy(() =>
10
+ z.union([JsonPrimitive, z.array(JsonValue), z.record(z.string(), JsonValue)]),
11
+ )
12
+
13
+ export const PluginAIInspirationRunMode = z.enum(["blocking", "job"])
14
+ export type PluginAIInspirationRunMode = z.infer<
15
+ typeof PluginAIInspirationRunMode
16
+ >
17
+
18
+ export const PluginAIInspirationOutputKind = z.enum([
19
+ "source",
20
+ "image",
21
+ "video",
22
+ ])
23
+ export type PluginAIInspirationOutputKind = z.infer<
24
+ typeof PluginAIInspirationOutputKind
25
+ >
26
+
27
+ export const PluginAIInspirationModelOutput = z.enum(["image", "video"])
28
+ export type PluginAIInspirationModelOutput = z.infer<
29
+ typeof PluginAIInspirationModelOutput
30
+ >
31
+
32
+ export const PluginAIInspirationRuntimeProvider = z.enum(["gpt", "fal"])
33
+ export type PluginAIInspirationRuntimeProvider = z.infer<
34
+ typeof PluginAIInspirationRuntimeProvider
35
+ >
36
+
37
+ export const PluginAIInspirationPromptStrategy = z.enum([
38
+ "gpt-image",
39
+ "fal-image",
40
+ "fal-video",
41
+ ])
42
+ export type PluginAIInspirationPromptStrategy = z.infer<
43
+ typeof PluginAIInspirationPromptStrategy
44
+ >
45
+
46
+ export const PluginAIInspirationShapeKind = z.enum(["image", "view", "video"])
47
+ export type PluginAIInspirationShapeKind = z.infer<
48
+ typeof PluginAIInspirationShapeKind
49
+ >
50
+
51
+ export const PluginAIInspirationVideoMode = z.enum([
52
+ "animate",
53
+ "references",
54
+ "keyframes",
55
+ ])
56
+ export type PluginAIInspirationVideoMode = z.infer<
57
+ typeof PluginAIInspirationVideoMode
58
+ >
59
+
60
+ export const PluginAIInspirationVideoMotion = z.enum([
61
+ "auto",
62
+ "slow-dolly",
63
+ "subtle-orbit",
64
+ "reveal",
65
+ ])
66
+ export type PluginAIInspirationVideoMotion = z.infer<
67
+ typeof PluginAIInspirationVideoMotion
68
+ >
69
+
70
+ export const PluginAIInspirationVideoDuration = z.enum(["4s", "6s", "8s"])
71
+ export type PluginAIInspirationVideoDuration = z.infer<
72
+ typeof PluginAIInspirationVideoDuration
73
+ >
74
+
75
+ export const PluginAIInspirationJobStatus = z.enum([
76
+ "queued",
77
+ "running",
78
+ "completed",
79
+ "failed",
80
+ "cancelled",
81
+ ])
82
+ export type PluginAIInspirationJobStatus = z.infer<
83
+ typeof PluginAIInspirationJobStatus
84
+ >
85
+
86
+ export const PluginAIInspirationWorkflowRunState = z.enum([
87
+ "current",
88
+ "stale",
89
+ "running",
90
+ "failed",
91
+ "superseded",
92
+ ])
93
+ export type PluginAIInspirationWorkflowRunState = z.infer<
94
+ typeof PluginAIInspirationWorkflowRunState
95
+ >
96
+
97
+ export const PluginAIInspirationRegionHint = z.object({
98
+ x: z.number().finite(),
99
+ y: z.number().finite(),
100
+ w: z.number().finite().positive(),
101
+ h: z.number().finite().positive(),
102
+ })
103
+ export type PluginAIInspirationRegionHint = z.infer<
104
+ typeof PluginAIInspirationRegionHint
105
+ >
106
+
107
+ export const PluginAIInspirationPoint = z.object({
108
+ x: z.number().finite(),
109
+ y: z.number().finite(),
110
+ })
111
+ export type PluginAIInspirationPoint = z.infer<typeof PluginAIInspirationPoint>
112
+
113
+ export const PluginAIInspirationTextAnnotation = z.object({
114
+ text: z.string().min(1),
115
+ x: z.number().finite().optional(),
116
+ y: z.number().finite().optional(),
117
+ })
118
+ export type PluginAIInspirationTextAnnotation = z.infer<
119
+ typeof PluginAIInspirationTextAnnotation
120
+ >
121
+
122
+ export const PluginAIInspirationSketchGuidance = z.object({
123
+ visualShapeIds: z.array(z.string()).optional(),
124
+ textAnnotations: z.array(PluginAIInspirationTextAnnotation).optional(),
125
+ })
126
+ export type PluginAIInspirationSketchGuidance = z.infer<
127
+ typeof PluginAIInspirationSketchGuidance
128
+ >
129
+
130
+ export const PluginAIInspirationSiteOptions = z.object({
131
+ includeSatellite: z.boolean().optional(),
132
+ includeStreetView: z.boolean().optional(),
133
+ includeAerial: z.boolean().optional(),
134
+ aerialBearing: z.number().finite().optional(),
135
+ aerialPitch: z.number().finite().optional(),
136
+ selectedDiagramIds: z.array(z.string()).optional(),
137
+ location: z
138
+ .object({
139
+ lat: z.number().finite(),
140
+ lng: z.number().finite(),
141
+ })
142
+ .optional(),
143
+ })
144
+ export type PluginAIInspirationSiteOptions = z.infer<
145
+ typeof PluginAIInspirationSiteOptions
146
+ >
147
+
148
+ export const PluginAIInspirationAppliedPreset = z.object({
149
+ source: z.enum(["curated", "user"]),
150
+ presetId: z.string().min(1),
151
+ name: z.string().min(1),
152
+ savedPresetKind: z.enum(["prompt", "style"]).optional(),
153
+ stylePrompt: z.string().optional(),
154
+ modelId: z.string().optional(),
155
+ referenceImages: z
156
+ .array(
157
+ z.object({
158
+ url: z.string().min(1),
159
+ label: z.string().optional(),
160
+ weight: z.number().finite().optional(),
161
+ }),
162
+ )
163
+ .optional(),
164
+ siteDefaults: z
165
+ .object({
166
+ includeSatellite: z.boolean().optional(),
167
+ includeStreetView: z.boolean().optional(),
168
+ includeAerial: z.boolean().optional(),
169
+ })
170
+ .optional(),
171
+ })
172
+ export type PluginAIInspirationAppliedPreset = z.infer<
173
+ typeof PluginAIInspirationAppliedPreset
174
+ >
175
+
176
+ export const PluginAIInspirationVideoOptions = z.object({
177
+ mode: PluginAIInspirationVideoMode.optional(),
178
+ endFrameShapeId: z.string().optional(),
179
+ motion: PluginAIInspirationVideoMotion.optional(),
180
+ duration: PluginAIInspirationVideoDuration.optional(),
181
+ })
182
+ export type PluginAIInspirationVideoOptions = z.infer<
183
+ typeof PluginAIInspirationVideoOptions
184
+ >
185
+
186
+ export const PluginAIInspirationModel = z.object({
187
+ id: z.string(),
188
+ label: z.string(),
189
+ supportsMultiImage: z.boolean(),
190
+ output: PluginAIInspirationModelOutput,
191
+ isDefault: z.boolean().optional(),
192
+ })
193
+ export type PluginAIInspirationModel = z.infer<typeof PluginAIInspirationModel>
194
+
195
+ export const PluginAIInspirationModelCapability = z.object({
196
+ id: z.string(),
197
+ output: PluginAIInspirationModelOutput,
198
+ provider: PluginAIInspirationRuntimeProvider,
199
+ supportsRegionEdit: z.boolean(),
200
+ supportsReferenceImages: z.boolean(),
201
+ supportsStylePresets: z.boolean(),
202
+ supportsSiteContext: z.boolean(),
203
+ supportsSketchGuidance: z.boolean(),
204
+ supportsKeyframes: z.boolean(),
205
+ maxExtraImages: z.number().int().nonnegative(),
206
+ promptStrategy: PluginAIInspirationPromptStrategy,
207
+ })
208
+ export type PluginAIInspirationModelCapability = z.infer<
209
+ typeof PluginAIInspirationModelCapability
210
+ >
211
+
212
+ export const PluginAIInspirationListModelsResult = z.object({
213
+ defaultModelId: z.string(),
214
+ models: z.array(PluginAIInspirationModel),
215
+ })
216
+ export type PluginAIInspirationListModelsResult = z.infer<
217
+ typeof PluginAIInspirationListModelsResult
218
+ >
219
+
220
+ export const PluginAIInspirationGetModelCapabilitiesArgs = z.object({
221
+ modelId: z.string().min(1),
222
+ })
223
+ export type PluginAIInspirationGetModelCapabilitiesArgs = z.infer<
224
+ typeof PluginAIInspirationGetModelCapabilitiesArgs
225
+ >
226
+
227
+ export const PluginAIInspirationGetModelCapabilitiesResult = z.object({
228
+ capability: PluginAIInspirationModelCapability,
229
+ })
230
+ export type PluginAIInspirationGetModelCapabilitiesResult = z.infer<
231
+ typeof PluginAIInspirationGetModelCapabilitiesResult
232
+ >
233
+
234
+ export const PluginAIInspirationShapeRef = z.object({
235
+ shapeId: z.string(),
236
+ assetId: z.string().optional(),
237
+ kind: PluginAIInspirationShapeKind,
238
+ name: z.string().optional(),
239
+ width: z.number().finite().optional(),
240
+ height: z.number().finite().optional(),
241
+ outputType: PluginAIInspirationOutputKind.optional(),
242
+ sourceUrl: z.string().optional(),
243
+ })
244
+ export type PluginAIInspirationShapeRef = z.infer<
245
+ typeof PluginAIInspirationShapeRef
246
+ >
247
+
248
+ export const PluginAIInspirationListSourcesArgs = z.object({
249
+ includeGenerated: z.boolean().optional(),
250
+ includeSourceUrl: z.boolean().optional(),
251
+ })
252
+ export type PluginAIInspirationListSourcesArgs = z.infer<
253
+ typeof PluginAIInspirationListSourcesArgs
254
+ >
255
+
256
+ export const PluginAIInspirationListSourcesResult = z.object({
257
+ sources: z.array(PluginAIInspirationShapeRef),
258
+ })
259
+ export type PluginAIInspirationListSourcesResult = z.infer<
260
+ typeof PluginAIInspirationListSourcesResult
261
+ >
262
+
263
+ export const PluginAIInspirationGetSelectionResult = z.object({
264
+ selectedShapeIds: z.array(z.string()),
265
+ sources: z.array(PluginAIInspirationShapeRef),
266
+ })
267
+ export type PluginAIInspirationGetSelectionResult = z.infer<
268
+ typeof PluginAIInspirationGetSelectionResult
269
+ >
270
+
271
+ export const PluginAIInspirationPresetReferenceImage = z.object({
272
+ url: z.string(),
273
+ label: z.string().optional(),
274
+ weight: z.number().finite().optional(),
275
+ })
276
+ export type PluginAIInspirationPresetReferenceImage = z.infer<
277
+ typeof PluginAIInspirationPresetReferenceImage
278
+ >
279
+
280
+ export const PluginAIInspirationPreset = z.object({
281
+ id: z.string(),
282
+ name: z.string(),
283
+ source: z.enum(["curated", "user"]),
284
+ modelId: z.string(),
285
+ categoryId: z.string().optional(),
286
+ categoryLabel: z.string().optional(),
287
+ description: z.string().optional(),
288
+ previewImageUrl: z.string().optional(),
289
+ prompt: z.string().optional(),
290
+ stylePrompt: z.string().optional(),
291
+ tags: z.array(z.string()).optional(),
292
+ referenceImages: z.array(PluginAIInspirationPresetReferenceImage).optional(),
293
+ siteDefaults: PluginAIInspirationAppliedPreset.shape.siteDefaults.optional(),
294
+ })
295
+ export type PluginAIInspirationPreset = z.infer<
296
+ typeof PluginAIInspirationPreset
297
+ >
298
+
299
+ export const PluginAIInspirationPresetCategory = z.object({
300
+ id: z.string(),
301
+ label: z.string(),
302
+ description: z.string().optional(),
303
+ })
304
+ export type PluginAIInspirationPresetCategory = z.infer<
305
+ typeof PluginAIInspirationPresetCategory
306
+ >
307
+
308
+ export const PluginAIInspirationGetPresetCatalogResult = z.object({
309
+ categories: z.array(PluginAIInspirationPresetCategory),
310
+ presets: z.array(PluginAIInspirationPreset),
311
+ })
312
+ export type PluginAIInspirationGetPresetCatalogResult = z.infer<
313
+ typeof PluginAIInspirationGetPresetCatalogResult
314
+ >
315
+
316
+ export const PluginAIInspirationOutput = z.object({
317
+ outputType: z.enum(["image", "video"]),
318
+ shapeId: z.string(),
319
+ assetId: z.string(),
320
+ outputUrl: z.string().optional(),
321
+ position: PluginAIInspirationPoint.optional(),
322
+ })
323
+ export type PluginAIInspirationOutput = z.infer<
324
+ typeof PluginAIInspirationOutput
325
+ >
326
+
327
+ export const PluginAIInspirationDebugSummary = z.record(z.string(), JsonValue)
328
+ export type PluginAIInspirationDebugSummary = z.infer<
329
+ typeof PluginAIInspirationDebugSummary
330
+ >
331
+
332
+ export const PluginAIInspirationRunMetadata = z.object({
333
+ geometryFidelity: z.string().optional(),
334
+ debugSummary: PluginAIInspirationDebugSummary.optional(),
335
+ streetViewComposite: z
336
+ .object({
337
+ used: z.boolean(),
338
+ renderMode: z.enum(["prompt_refs_default", "masked_composite_pilot"]),
339
+ backgroundLabel: z.string().optional(),
340
+ })
341
+ .optional(),
342
+ })
343
+ export type PluginAIInspirationRunMetadata = z.infer<
344
+ typeof PluginAIInspirationRunMetadata
345
+ >
346
+
347
+ export const PluginAIInspirationGenerateArgs = z.object({
348
+ sourceShapeId: z.string().min(1),
349
+ prompt: z.string().min(1).max(8000),
350
+ modelId: z.string().optional(),
351
+ referenceShapeIds: z.array(z.string()).max(12).optional(),
352
+ referenceStrength: z.enum(["low", "medium", "high"]).optional(),
353
+ appliedPreset: PluginAIInspirationAppliedPreset.optional(),
354
+ site: PluginAIInspirationSiteOptions.optional(),
355
+ regionHint: PluginAIInspirationRegionHint.optional(),
356
+ sketchGuidance: PluginAIInspirationSketchGuidance.optional(),
357
+ video: PluginAIInspirationVideoOptions.optional(),
358
+ runMode: PluginAIInspirationRunMode.optional(),
359
+ })
360
+ export type PluginAIInspirationGenerateArgs = z.infer<
361
+ typeof PluginAIInspirationGenerateArgs
362
+ >
363
+
364
+ export const PluginAIInspirationRunResult = z.object({
365
+ jobId: z.string().optional(),
366
+ output: PluginAIInspirationOutput.optional(),
367
+ outputs: z.array(PluginAIInspirationOutput).optional(),
368
+ metadata: PluginAIInspirationRunMetadata.optional(),
369
+ })
370
+ export type PluginAIInspirationRunResult = z.infer<
371
+ typeof PluginAIInspirationRunResult
372
+ >
373
+
374
+ export const PluginAIInspirationRefineArgs = z.object({
375
+ sourceShapeId: z.string().min(1),
376
+ upscaleFactor: z
377
+ .union([z.literal(1.5), z.literal(2), z.literal(4)])
378
+ .optional(),
379
+ runMode: PluginAIInspirationRunMode.optional(),
380
+ })
381
+ export type PluginAIInspirationRefineArgs = z.infer<
382
+ typeof PluginAIInspirationRefineArgs
383
+ >
384
+
385
+ export const PluginAIInspirationJobProgress = z.object({
386
+ currentStep: z.number().int().nonnegative().optional(),
387
+ totalSteps: z.number().int().nonnegative().optional(),
388
+ message: z.string().optional(),
389
+ })
390
+ export type PluginAIInspirationJobProgress = z.infer<
391
+ typeof PluginAIInspirationJobProgress
392
+ >
393
+
394
+ export const PluginAIInspirationJob = z.object({
395
+ jobId: z.string(),
396
+ status: PluginAIInspirationJobStatus,
397
+ createdAt: z.number(),
398
+ updatedAt: z.number(),
399
+ completedAt: z.number().optional(),
400
+ method: z.string(),
401
+ progress: PluginAIInspirationJobProgress.optional(),
402
+ result: PluginAIInspirationRunResult.optional(),
403
+ error: z.string().optional(),
404
+ })
405
+ export type PluginAIInspirationJob = z.infer<typeof PluginAIInspirationJob>
406
+
407
+ export const PluginAIInspirationJobArgs = z.object({
408
+ jobId: z.string().min(1),
409
+ })
410
+ export type PluginAIInspirationJobArgs = z.infer<
411
+ typeof PluginAIInspirationJobArgs
412
+ >
413
+
414
+ export const PluginAIInspirationGetJobResult = z.object({
415
+ job: PluginAIInspirationJob,
416
+ })
417
+ export type PluginAIInspirationGetJobResult = z.infer<
418
+ typeof PluginAIInspirationGetJobResult
419
+ >
420
+
421
+ export const PluginAIInspirationCancelJobResult = z.object({
422
+ job: PluginAIInspirationJob,
423
+ })
424
+ export type PluginAIInspirationCancelJobResult = z.infer<
425
+ typeof PluginAIInspirationCancelJobResult
426
+ >
427
+
428
+ export const PluginAIInspirationListJobsResult = z.object({
429
+ jobs: z.array(PluginAIInspirationJob),
430
+ })
431
+ export type PluginAIInspirationListJobsResult = z.infer<
432
+ typeof PluginAIInspirationListJobsResult
433
+ >
434
+
435
+ export const PluginAIInspirationWorkflowVideoConfig = z.object({
436
+ mode: z.string().optional(),
437
+ motion: z.string().optional(),
438
+ duration: z.string().optional(),
439
+ endFrameShapeId: z.string().optional(),
440
+ })
441
+ export type PluginAIInspirationWorkflowVideoConfig = z.infer<
442
+ typeof PluginAIInspirationWorkflowVideoConfig
443
+ >
444
+
445
+ export const PluginAIInspirationGenerationInputSnapshot = z.object({
446
+ version: z.literal(1),
447
+ meta: z.record(z.string(), JsonValue),
448
+ regionHint: PluginAIInspirationRegionHint.optional(),
449
+ sketchGuidance: z.record(z.string(), JsonValue).optional(),
450
+ sourceCameraHeading: z.number().finite().optional(),
451
+ })
452
+ export type PluginAIInspirationGenerationInputSnapshot = z.infer<
453
+ typeof PluginAIInspirationGenerationInputSnapshot
454
+ >
455
+
456
+ export const PluginAIInspirationWorkflowOperation = z.object({
457
+ type: z.enum(["generate-image", "refine", "generate-video"]),
458
+ label: z.string(),
459
+ prompt: z.string().optional(),
460
+ modelId: z.string().optional(),
461
+ presetId: z.string().optional(),
462
+ presetName: z.string().optional(),
463
+ refineFactor: z.number().finite().optional(),
464
+ sourceRole: z.enum(["primary", "end-frame"]).optional(),
465
+ video: PluginAIInspirationWorkflowVideoConfig.optional(),
466
+ generationInput: PluginAIInspirationGenerationInputSnapshot.optional(),
467
+ })
468
+ export type PluginAIInspirationWorkflowOperation = z.infer<
469
+ typeof PluginAIInspirationWorkflowOperation
470
+ >
471
+
472
+ export const PluginAIInspirationWorkflowNode = z.object({
473
+ id: z.string(),
474
+ shapeId: z.string(),
475
+ assetId: z.string().optional(),
476
+ kind: PluginAIInspirationOutputKind,
477
+ state: z.string(),
478
+ runState: PluginAIInspirationWorkflowRunState.optional(),
479
+ staleReason: z.string().optional(),
480
+ incomingEdgeIds: z.array(z.string()),
481
+ outgoingEdgeIds: z.array(z.string()),
482
+ createdAt: z.number(),
483
+ updatedAt: z.number(),
484
+ })
485
+ export type PluginAIInspirationWorkflowNode = z.infer<
486
+ typeof PluginAIInspirationWorkflowNode
487
+ >
488
+
489
+ export const PluginAIInspirationWorkflowEdge = z.object({
490
+ id: z.string(),
491
+ sourceNodeId: z.string(),
492
+ targetNodeId: z.string(),
493
+ arrowShapeId: z.string().optional(),
494
+ operation: PluginAIInspirationWorkflowOperation,
495
+ state: z.string(),
496
+ runState: PluginAIInspirationWorkflowRunState.optional(),
497
+ staleReason: z.string().optional(),
498
+ supersededByEdgeId: z.string().optional(),
499
+ createdAt: z.number(),
500
+ updatedAt: z.number(),
501
+ })
502
+ export type PluginAIInspirationWorkflowEdge = z.infer<
503
+ typeof PluginAIInspirationWorkflowEdge
504
+ >
505
+
506
+ export const PluginAIInspirationWorkflow = z.object({
507
+ id: z.string(),
508
+ rootNodeIds: z.array(z.string()),
509
+ nodeIds: z.array(z.string()),
510
+ edgeIds: z.array(z.string()),
511
+ nodes: z.record(z.string(), PluginAIInspirationWorkflowNode),
512
+ edges: z.record(z.string(), PluginAIInspirationWorkflowEdge),
513
+ createdAt: z.number(),
514
+ updatedAt: z.number(),
515
+ })
516
+ export type PluginAIInspirationWorkflow = z.infer<
517
+ typeof PluginAIInspirationWorkflow
518
+ >
519
+
520
+ export const PluginAIInspirationGetWorkflowForShapeArgs = z.object({
521
+ shapeId: z.string().min(1),
522
+ })
523
+ export type PluginAIInspirationGetWorkflowForShapeArgs = z.infer<
524
+ typeof PluginAIInspirationGetWorkflowForShapeArgs
525
+ >
526
+
527
+ export const PluginAIInspirationGetWorkflowForShapeResult = z.object({
528
+ workflow: PluginAIInspirationWorkflow.nullable(),
529
+ node: PluginAIInspirationWorkflowNode.nullable(),
530
+ })
531
+ export type PluginAIInspirationGetWorkflowForShapeResult = z.infer<
532
+ typeof PluginAIInspirationGetWorkflowForShapeResult
533
+ >
534
+
535
+ export const PluginAIInspirationRerunPlanResult = z.discriminatedUnion(
536
+ "status",
537
+ [
538
+ z.object({
539
+ status: z.literal("ready"),
540
+ workflowId: z.string(),
541
+ sourceNode: PluginAIInspirationWorkflowNode,
542
+ edgeIds: z.array(z.string()),
543
+ edges: z.array(PluginAIInspirationWorkflowEdge),
544
+ recipe: z.lazy(() => PluginAIInspirationRecipe),
545
+ needsEndFrame: z.boolean(),
546
+ defaultEndFrameShapeId: z.string().nullable(),
547
+ }),
548
+ z.object({
549
+ status: z.literal("unavailable"),
550
+ reason: z.enum([
551
+ "not-in-workflow",
552
+ "source-only",
553
+ "running",
554
+ "missing-input",
555
+ ]),
556
+ }),
557
+ ],
558
+ )
559
+ export type PluginAIInspirationRerunPlanResult = z.infer<
560
+ typeof PluginAIInspirationRerunPlanResult
561
+ >
562
+
563
+ export const PluginAIInspirationRerunSelectedBranchArgs = z.object({
564
+ shapeId: z.string().min(1),
565
+ endFrameShapeId: z.string().optional(),
566
+ runMode: PluginAIInspirationRunMode.optional(),
567
+ })
568
+ export type PluginAIInspirationRerunSelectedBranchArgs = z.infer<
569
+ typeof PluginAIInspirationRerunSelectedBranchArgs
570
+ >
571
+
572
+ export const PluginAIInspirationRecipeSlot = z.object({
573
+ id: z.string(),
574
+ type: z.enum(["source-image", "end-frame"]),
575
+ label: z.string(),
576
+ required: z.boolean(),
577
+ })
578
+ export type PluginAIInspirationRecipeSlot = z.infer<
579
+ typeof PluginAIInspirationRecipeSlot
580
+ >
581
+
582
+ export const PluginAIInspirationRecipeStep = z.object({
583
+ id: z.string(),
584
+ operation: PluginAIInspirationWorkflowOperation,
585
+ outputKind: z.enum(["image", "video"]),
586
+ })
587
+ export type PluginAIInspirationRecipeStep = z.infer<
588
+ typeof PluginAIInspirationRecipeStep
589
+ >
590
+
591
+ export const PluginAIInspirationRecipeDraft = z.object({
592
+ name: z.string(),
593
+ summary: z.string(),
594
+ slots: z.array(PluginAIInspirationRecipeSlot),
595
+ steps: z.array(PluginAIInspirationRecipeStep).min(1).max(20),
596
+ outputKind: z.enum(["image", "video"]),
597
+ thumbnailUrl: z.string().optional(),
598
+ })
599
+ export type PluginAIInspirationRecipeDraft = z.infer<
600
+ typeof PluginAIInspirationRecipeDraft
601
+ >
602
+
603
+ export const PluginAIInspirationRecipe: z.ZodType<
604
+ PluginAIInspirationRecipeDraft & {
605
+ version: 1
606
+ id: string
607
+ fingerprint?: string
608
+ createdAt: number
609
+ updatedAt: number
610
+ }
611
+ > = PluginAIInspirationRecipeDraft.extend({
612
+ version: z.literal(1),
613
+ id: z.string(),
614
+ fingerprint: z.string().optional(),
615
+ createdAt: z.number(),
616
+ updatedAt: z.number(),
617
+ })
618
+ export type PluginAIInspirationRecipe = z.infer<
619
+ typeof PluginAIInspirationRecipe
620
+ >
621
+
622
+ export const PluginAIInspirationExtractionResult = z.discriminatedUnion(
623
+ "status",
624
+ [
625
+ z.object({
626
+ status: z.literal("ready"),
627
+ draft: PluginAIInspirationRecipeDraft,
628
+ }),
629
+ z.object({
630
+ status: z.literal("unavailable"),
631
+ reason: z.enum([
632
+ "not-in-workflow",
633
+ "source-only",
634
+ "missing-workflow",
635
+ "missing-node",
636
+ "missing-input",
637
+ "invalid-workflow",
638
+ ]),
639
+ }),
640
+ ],
641
+ )
642
+ export type PluginAIInspirationExtractionResult = z.infer<
643
+ typeof PluginAIInspirationExtractionResult
644
+ >
645
+
646
+ export const PluginAIInspirationListRecipesResult = z.object({
647
+ recipes: z.array(PluginAIInspirationRecipe),
648
+ })
649
+ export type PluginAIInspirationListRecipesResult = z.infer<
650
+ typeof PluginAIInspirationListRecipesResult
651
+ >
652
+
653
+ export const PluginAIInspirationSaveRecipeArgs = z.object({
654
+ draft: PluginAIInspirationRecipeDraft,
655
+ name: z.string().min(1),
656
+ })
657
+ export type PluginAIInspirationSaveRecipeArgs = z.infer<
658
+ typeof PluginAIInspirationSaveRecipeArgs
659
+ >
660
+
661
+ export const PluginAIInspirationSaveRecipeResult = z.discriminatedUnion(
662
+ "status",
663
+ [
664
+ z.object({ status: z.literal("saved"), recipe: PluginAIInspirationRecipe }),
665
+ z.object({
666
+ status: z.literal("duplicate"),
667
+ recipe: PluginAIInspirationRecipe,
668
+ }),
669
+ z.object({ status: z.literal("invalid-name"), recipe: z.null() }),
670
+ z.object({ status: z.literal("failed"), recipe: z.null() }),
671
+ ],
672
+ )
673
+ export type PluginAIInspirationSaveRecipeResult = z.infer<
674
+ typeof PluginAIInspirationSaveRecipeResult
675
+ >
676
+
677
+ export const PluginAIInspirationDeleteRecipeArgs = z.object({
678
+ recipeId: z.string().min(1),
679
+ })
680
+ export type PluginAIInspirationDeleteRecipeArgs = z.infer<
681
+ typeof PluginAIInspirationDeleteRecipeArgs
682
+ >
683
+
684
+ export const PluginAIInspirationDeleteRecipeResult = z.object({
685
+ deleted: z.boolean(),
686
+ })
687
+ export type PluginAIInspirationDeleteRecipeResult = z.infer<
688
+ typeof PluginAIInspirationDeleteRecipeResult
689
+ >
690
+
691
+ export const PluginAIInspirationExtractRecipeFromShapeArgs = z.object({
692
+ shapeId: z.string().min(1),
693
+ })
694
+ export type PluginAIInspirationExtractRecipeFromShapeArgs = z.infer<
695
+ typeof PluginAIInspirationExtractRecipeFromShapeArgs
696
+ >
697
+
698
+ export const PluginAIInspirationRunRecipeArgs = z.object({
699
+ recipeId: z.string().optional(),
700
+ recipe: PluginAIInspirationRecipe.optional(),
701
+ slotShapeIds: z.record(z.string(), z.string()),
702
+ runMode: PluginAIInspirationRunMode.optional(),
703
+ })
704
+ export type PluginAIInspirationRunRecipeArgs = z.infer<
705
+ typeof PluginAIInspirationRunRecipeArgs
706
+ >
707
+
708
+ /**
709
+ * Present-mode AI Inspiration APIs.
710
+ *
711
+ * These APIs operate on Present canvas shape IDs and inherit the current user's
712
+ * AI quota. They create outputs on the Present canvas; pure backend generation
713
+ * without canvas output is intentionally out of scope.
714
+ *
715
+ * Accessed via `snaptrude.documentation.aiInspiration`.
716
+ */
717
+ export abstract class PluginDocumentationAIInspirationApi {
718
+ constructor() {}
719
+
720
+ /**
721
+ * List AI Inspiration models that can be used for generation.
722
+ *
723
+ * @returns The default model ID and available model descriptors.
724
+ */
725
+ public abstract listModels(): PluginApiReturn<PluginAIInspirationListModelsResult>
726
+
727
+ /**
728
+ * Get capability flags for a model.
729
+ *
730
+ * @param args - Object containing `modelId`.
731
+ * @returns Capability flags such as reference, site-context, region, and keyframe support.
732
+ */
733
+ public abstract getModelCapabilities(
734
+ args: PluginAIInspirationGetModelCapabilitiesArgs,
735
+ ): PluginApiReturn<PluginAIInspirationGetModelCapabilitiesResult>
736
+
737
+ /**
738
+ * List image/view/video sources on the current Present page.
739
+ *
740
+ * @param args - Optional filters. Set `includeGenerated` to include AI outputs.
741
+ * @returns Serializable shape references using Present canvas shape IDs.
742
+ */
743
+ public abstract listSources(
744
+ args: PluginAIInspirationListSourcesArgs,
745
+ ): PluginApiReturn<PluginAIInspirationListSourcesResult>
746
+
747
+ /**
748
+ * Get selected Present canvas shapes that AI Inspiration can use.
749
+ *
750
+ * @returns Selected shape IDs and resolved source references.
751
+ */
752
+ public abstract getSelection(): PluginApiReturn<PluginAIInspirationGetSelectionResult>
753
+
754
+ /**
755
+ * Get the curated AI Inspiration preset catalog.
756
+ *
757
+ * @returns Preset categories and presets.
758
+ */
759
+ public abstract getPresetCatalog(): PluginApiReturn<PluginAIInspirationGetPresetCatalogResult>
760
+
761
+ /**
762
+ * Generate an image or video from a Present canvas source.
763
+ *
764
+ * @param args - Generation options including source, prompt, model, references, site context,
765
+ * region guidance, sketch guidance, and video options.
766
+ * @returns A canvas output in blocking mode or a job ID in job mode.
767
+ */
768
+ public abstract generate(
769
+ args: PluginAIInspirationGenerateArgs,
770
+ ): PluginApiReturn<PluginAIInspirationRunResult>
771
+
772
+ /**
773
+ * Refine/upscale an AI Inspiration source image.
774
+ *
775
+ * @param args - Source shape, optional upscale factor, and run mode.
776
+ * @returns A canvas output in blocking mode or a job ID in job mode.
777
+ */
778
+ public abstract refine(
779
+ args: PluginAIInspirationRefineArgs,
780
+ ): PluginApiReturn<PluginAIInspirationRunResult>
781
+
782
+ /** Get a transient AI Inspiration job by ID. */
783
+ public abstract getJob(
784
+ args: PluginAIInspirationJobArgs,
785
+ ): PluginApiReturn<PluginAIInspirationGetJobResult>
786
+
787
+ /** Cancel a transient AI Inspiration job. */
788
+ public abstract cancelJob(
789
+ args: PluginAIInspirationJobArgs,
790
+ ): PluginApiReturn<PluginAIInspirationCancelJobResult>
791
+
792
+ /** List transient AI Inspiration jobs created in the current host session. */
793
+ public abstract listJobs(): PluginApiReturn<PluginAIInspirationListJobsResult>
794
+
795
+ /**
796
+ * Get the sanitized workflow graph containing a Present shape.
797
+ *
798
+ * @param args - Object containing `shapeId`.
799
+ * @returns The workflow and matching node, or `null` values when the shape is not in a workflow.
800
+ */
801
+ public abstract getWorkflowForShape(
802
+ args: PluginAIInspirationGetWorkflowForShapeArgs,
803
+ ): PluginApiReturn<PluginAIInspirationGetWorkflowForShapeResult>
804
+
805
+ /**
806
+ * Build a rerun plan for the selected workflow branch ending at a shape.
807
+ *
808
+ * @param args - Object containing `shapeId`.
809
+ * @returns Ready plan data or an unavailable reason.
810
+ */
811
+ public abstract getSelectedBranchRerunPlan(
812
+ args: PluginAIInspirationGetWorkflowForShapeArgs,
813
+ ): PluginApiReturn<PluginAIInspirationRerunPlanResult>
814
+
815
+ /**
816
+ * Rerun the selected workflow branch and supersede the previous branch.
817
+ *
818
+ * @param args - Selected shape, optional end frame shape, and run mode.
819
+ * @returns New canvas outputs in blocking mode or a job ID in job mode.
820
+ */
821
+ public abstract rerunSelectedBranch(
822
+ args: PluginAIInspirationRerunSelectedBranchArgs,
823
+ ): PluginApiReturn<PluginAIInspirationRunResult>
824
+
825
+ /**
826
+ * Extract a reusable recipe draft from the workflow path ending at a shape.
827
+ *
828
+ * @param args - Object containing `shapeId`.
829
+ * @returns A recipe draft or an unavailable reason.
830
+ */
831
+ public abstract extractRecipeFromShape(
832
+ args: PluginAIInspirationExtractRecipeFromShapeArgs,
833
+ ): PluginApiReturn<PluginAIInspirationExtractionResult>
834
+
835
+ /**
836
+ * List project-level AI Inspiration recipes stored in Present document metadata.
837
+ *
838
+ * @returns Saved project recipes.
839
+ */
840
+ public abstract listRecipes(): PluginApiReturn<PluginAIInspirationListRecipesResult>
841
+
842
+ /**
843
+ * Save a project-level AI Inspiration recipe.
844
+ *
845
+ * @param args - Recipe draft and desired name.
846
+ * @returns Saved, duplicate, invalid-name, or failed status.
847
+ */
848
+ public abstract saveRecipe(
849
+ args: PluginAIInspirationSaveRecipeArgs,
850
+ ): PluginApiReturn<PluginAIInspirationSaveRecipeResult>
851
+
852
+ /**
853
+ * Delete a project-level AI Inspiration recipe.
854
+ *
855
+ * @param args - Object containing `recipeId`.
856
+ * @returns Whether a recipe was deleted.
857
+ */
858
+ public abstract deleteRecipe(
859
+ args: PluginAIInspirationDeleteRecipeArgs,
860
+ ): PluginApiReturn<PluginAIInspirationDeleteRecipeResult>
861
+
862
+ /**
863
+ * Run a saved or inline recipe against Present canvas slot shapes.
864
+ *
865
+ * @param args - Saved `recipeId` or inline `recipe`, slot shape IDs, and run mode.
866
+ * @returns Canvas outputs in blocking mode or a job ID in job mode.
867
+ */
868
+ public abstract runRecipe(
869
+ args: PluginAIInspirationRunRecipeArgs,
870
+ ): PluginApiReturn<PluginAIInspirationRunResult>
871
+ }