@automate.ax/api-contract 0.85.0 → 0.86.2
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.
- package/dist/index.d.ts +21 -2
- package/dist/index.js +1 -1
- package/dist/runtime.d.ts +152 -2
- package/dist/runtime.js +105 -2
- package/package.json +4 -4
- package/src/index.ts +12 -1
- package/src/runtime.ts +136 -4
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export { AUTOMATION_SDK_VERSION, deploymentOutputSchema, deploymentStatusSchema,
|
|
|
4
4
|
export { AUTOMATION_RUNTIME_PROTOCOL_VERSION } from "./runtime-protocol.js";
|
|
5
5
|
export { AUTOMATION_ERROR_CAUSE_DEPTH, automationErrorSchema, type AutomationErrorValue, } from "./errors.js";
|
|
6
6
|
export { integrationAccountOutputSchema, integrationAccountRevocationImpactOutputSchema, integrationAccountRevocationOutputSchema, integrationServiceOutputSchema, } from "./account.js";
|
|
7
|
-
export { AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT, AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX, AUTOMATION_LOG_MAX_ENTRIES, AUTOMATION_LOG_MAX_MESSAGE_LENGTH, AUTOMATION_OBSERVABILITY_MAX_ENCODED_BYTES, AUTOMATION_OBSERVABILITY_MAX_FIELDS, AUTOMATION_TRACE_MAX_NAME_LENGTH, AUTOMATION_TRACE_MAX_SPANS, DEFAULT_GATEWAY_MODEL_ID, automationInvocationInputSchema, automationInvocationOutputSchema, automationInvocationScheduleSchema, generationInputSchema, generationResultSchema, hashSignalCoordinatorConfiguration, runtimeContract, type GenerationInput, type GenerationResult, type RuntimeGenerationInput, type RuntimeCoordinationOffer, } from "./runtime.js";
|
|
8
|
-
export type { GatewayModelId } from "@ai-sdk/gateway";
|
|
7
|
+
export { AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT, AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX, AUTOMATION_IMAGE_GENERATION_ENTRYPOINT_PREFIX, AUTOMATION_LOG_MAX_ENTRIES, AUTOMATION_LOG_MAX_MESSAGE_LENGTH, AUTOMATION_OBSERVABILITY_MAX_ENCODED_BYTES, AUTOMATION_OBSERVABILITY_MAX_FIELDS, AUTOMATION_TRACE_MAX_NAME_LENGTH, AUTOMATION_TRACE_MAX_SPANS, DEFAULT_GATEWAY_IMAGE_MODEL_ID, DEFAULT_GATEWAY_MODEL_ID, automationInvocationInputSchema, automationInvocationOutputSchema, automationInvocationScheduleSchema, generationInputSchema, generationResultSchema, imageGenerationInputSchema, imageGenerationCompletionSchema, imageGenerationResultSchema, platformImageGenerationInputSchema, platformImageGenerationStartSchema, hashSignalCoordinatorConfiguration, runtimeContract, type GenerationInput, type GenerationResult, type ImageGenerationInput, type ImageGenerationCompletion, type ImageGenerationResult, type PlatformImageGenerationInput, type RuntimeGenerationInput, type RuntimeCoordinationOffer, } from "./runtime.js";
|
|
8
|
+
export type { GatewayImageModelId, GatewayModelId } from "@ai-sdk/gateway";
|
|
9
9
|
export { createdOrganizationApiKeyOutputSchema, organizationApiKeyOutputSchema, } from "./api-key.js";
|
|
10
10
|
export { activeSubscriptionOutputSchema, createdInvitationOutputSchema, organizationDetailsOutputSchema, organizationInvitationOutputSchema, organizationMemberOutputSchema, organizationProjectOutputSchema, organizationRoleSchema, organizationSummaryOutputSchema, publicOrganizationOutputSchema, } from "./org.js";
|
|
11
11
|
export { projectOutputSchema } from "./project.js";
|
|
@@ -2841,6 +2841,25 @@ export declare const contract: {
|
|
|
2841
2841
|
type: import("zod").ZodLiteral<"other">;
|
|
2842
2842
|
}, import("zod/v4/core").$strip>], "type">>>;
|
|
2843
2843
|
}, import("zod/v4/core").$strip>, Record<never, never>, Record<never, never>>;
|
|
2844
|
+
startImageGeneration: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
|
|
2845
|
+
aspectRatio: import("zod").ZodOptional<import("zod").ZodCustom<`${number}:${number}`, `${number}:${number}`>>;
|
|
2846
|
+
headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
|
|
2847
|
+
maxImagesPerCall: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
2848
|
+
maxRetries: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
2849
|
+
model: import("zod").ZodDefault<import("zod").ZodCustom<import("@ai-sdk/gateway").GatewayImageModelId, import("@ai-sdk/gateway").GatewayImageModelId>>;
|
|
2850
|
+
n: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
2851
|
+
prompt: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
2852
|
+
images: import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<ArrayBuffer, ArrayBuffer>, import("zod").ZodCustom<Blob, Blob>]>>;
|
|
2853
|
+
mask: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, import("zod").ZodCustom<ArrayBuffer, ArrayBuffer>, import("zod").ZodCustom<Blob, Blob>]>>;
|
|
2854
|
+
text: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2855
|
+
}, import("zod/v4/core").$strip>]>;
|
|
2856
|
+
providerOptions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodJSONSchema>>>;
|
|
2857
|
+
seed: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
2858
|
+
size: import("zod").ZodOptional<import("zod").ZodCustom<`${number}x${number}`, `${number}x${number}`>>;
|
|
2859
|
+
entrypoint: import("zod").ZodString;
|
|
2860
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
2861
|
+
key: import("zod").ZodString;
|
|
2862
|
+
}, import("zod/v4/core").$strip>, Record<never, never>, Record<never, never>>;
|
|
2844
2863
|
createCallbackToken: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
|
|
2845
2864
|
endpointKey: import("zod").ZodString;
|
|
2846
2865
|
}, import("zod/v4/core").$strip>, import("zod").ZodString, Record<never, never>, Record<never, never>>;
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export { AUTOMATION_SDK_VERSION, deploymentOutputSchema, deploymentStatusSchema,
|
|
|
15
15
|
export { AUTOMATION_RUNTIME_PROTOCOL_VERSION } from "./runtime-protocol.js";
|
|
16
16
|
export { AUTOMATION_ERROR_CAUSE_DEPTH, automationErrorSchema, } from "./errors.js";
|
|
17
17
|
export { integrationAccountOutputSchema, integrationAccountRevocationImpactOutputSchema, integrationAccountRevocationOutputSchema, integrationServiceOutputSchema, } from "./account.js";
|
|
18
|
-
export { AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT, AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX, AUTOMATION_LOG_MAX_ENTRIES, AUTOMATION_LOG_MAX_MESSAGE_LENGTH, AUTOMATION_OBSERVABILITY_MAX_ENCODED_BYTES, AUTOMATION_OBSERVABILITY_MAX_FIELDS, AUTOMATION_TRACE_MAX_NAME_LENGTH, AUTOMATION_TRACE_MAX_SPANS, DEFAULT_GATEWAY_MODEL_ID, automationInvocationInputSchema, automationInvocationOutputSchema, automationInvocationScheduleSchema, generationInputSchema, generationResultSchema, hashSignalCoordinatorConfiguration, runtimeContract, } from "./runtime.js";
|
|
18
|
+
export { AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT, AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX, AUTOMATION_IMAGE_GENERATION_ENTRYPOINT_PREFIX, AUTOMATION_LOG_MAX_ENTRIES, AUTOMATION_LOG_MAX_MESSAGE_LENGTH, AUTOMATION_OBSERVABILITY_MAX_ENCODED_BYTES, AUTOMATION_OBSERVABILITY_MAX_FIELDS, AUTOMATION_TRACE_MAX_NAME_LENGTH, AUTOMATION_TRACE_MAX_SPANS, DEFAULT_GATEWAY_IMAGE_MODEL_ID, DEFAULT_GATEWAY_MODEL_ID, automationInvocationInputSchema, automationInvocationOutputSchema, automationInvocationScheduleSchema, generationInputSchema, generationResultSchema, imageGenerationInputSchema, imageGenerationCompletionSchema, imageGenerationResultSchema, platformImageGenerationInputSchema, platformImageGenerationStartSchema, hashSignalCoordinatorConfiguration, runtimeContract, } from "./runtime.js";
|
|
19
19
|
export { createdOrganizationApiKeyOutputSchema, organizationApiKeyOutputSchema, } from "./api-key.js";
|
|
20
20
|
export { activeSubscriptionOutputSchema, createdInvitationOutputSchema, organizationDetailsOutputSchema, organizationInvitationOutputSchema, organizationMemberOutputSchema, organizationProjectOutputSchema, organizationRoleSchema, organizationSummaryOutputSchema, publicOrganizationOutputSchema, } from "./org.js";
|
|
21
21
|
export { projectOutputSchema } from "./project.js";
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import { type SensitivityMask } from "@automate.ax/codec";
|
|
2
|
-
import type { GatewayModelId } from "@ai-sdk/gateway";
|
|
2
|
+
import type { GatewayImageModelId, GatewayModelId } from "@ai-sdk/gateway";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
export type { GatewayModelId } from "@ai-sdk/gateway";
|
|
4
|
+
export type { GatewayImageModelId, GatewayModelId } from "@ai-sdk/gateway";
|
|
5
5
|
/** Default model used by the platform Vercel AI Gateway account. */
|
|
6
6
|
export declare const DEFAULT_GATEWAY_MODEL_ID = "openai/gpt-4.1-nano";
|
|
7
|
+
/** Default image model used by the platform Vercel AI Gateway account. */
|
|
8
|
+
export declare const DEFAULT_GATEWAY_IMAGE_MODEL_ID = "bfl/flux-2-flex";
|
|
7
9
|
export declare const AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT = "default";
|
|
8
10
|
export declare const AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX = "__$";
|
|
9
11
|
export declare const AUTOMATION_DELAY_ENTRYPOINT_PREFIX: "__$delay:";
|
|
12
|
+
export declare const AUTOMATION_IMAGE_GENERATION_ENTRYPOINT_PREFIX: "__$generate-image:";
|
|
10
13
|
export declare const CALLBACK_PROTECTION_QUERY_PARAMETER = "_axCallback";
|
|
11
14
|
export declare const AUTOMATION_LOG_MAX_ENTRIES = 1000;
|
|
12
15
|
export declare const AUTOMATION_TRACE_MAX_SPANS = 250;
|
|
13
16
|
export declare const AUTOMATION_OBSERVABILITY_MAX_FIELDS = 64;
|
|
14
17
|
export declare const AUTOMATION_OBSERVABILITY_MAX_ENCODED_BYTES: number;
|
|
18
|
+
/** Preserves Blob media types while oRPC carries the bytes as multipart data. */
|
|
19
|
+
export declare const runtimeBlobJsonSerializer: {
|
|
20
|
+
type: number;
|
|
21
|
+
condition: (value: unknown) => boolean;
|
|
22
|
+
serialize(value: Blob): {
|
|
23
|
+
transportValue: Blob;
|
|
24
|
+
type: string;
|
|
25
|
+
};
|
|
26
|
+
deserialize(value: unknown): Blob;
|
|
27
|
+
};
|
|
15
28
|
export declare const AUTOMATION_LOG_MAX_MESSAGE_LENGTH = 16384;
|
|
16
29
|
export declare const AUTOMATION_TRACE_MAX_NAME_LENGTH = 256;
|
|
17
30
|
/** Runtime-validated structural policy for author-visible value projection. */
|
|
@@ -472,6 +485,124 @@ declare const RUNTIME_GENERATION_INPUT_SCHEMA: z.ZodUnion<readonly [z.ZodObject<
|
|
|
472
485
|
}, z.core.$strip>>;
|
|
473
486
|
}, z.core.$strip>]>;
|
|
474
487
|
export type RuntimeGenerationInput = z.output<typeof RUNTIME_GENERATION_INPUT_SCHEMA>;
|
|
488
|
+
/** Shared options accepted by the built-in image-generation action. */
|
|
489
|
+
export declare const imageGenerationInputSchema: z.ZodObject<{
|
|
490
|
+
aspectRatio: z.ZodOptional<z.ZodCustom<`${number}:${number}`, `${number}:${number}`>>;
|
|
491
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
492
|
+
maxImagesPerCall: z.ZodOptional<z.ZodNumber>;
|
|
493
|
+
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
494
|
+
model: z.ZodDefault<z.ZodCustom<GatewayImageModelId, GatewayImageModelId>>;
|
|
495
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
496
|
+
prompt: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
497
|
+
images: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodCustom<ArrayBuffer, ArrayBuffer>, z.ZodCustom<Blob, Blob>]>>;
|
|
498
|
+
mask: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodCustom<ArrayBuffer, ArrayBuffer>, z.ZodCustom<Blob, Blob>]>>;
|
|
499
|
+
text: z.ZodOptional<z.ZodString>;
|
|
500
|
+
}, z.core.$strip>]>;
|
|
501
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
502
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
503
|
+
size: z.ZodOptional<z.ZodCustom<`${number}x${number}`, `${number}x${number}`>>;
|
|
504
|
+
}, z.core.$strip>;
|
|
505
|
+
/** Serializable subset of the AI SDK image-generation result. */
|
|
506
|
+
export declare const imageGenerationResultSchema: z.ZodObject<{
|
|
507
|
+
images: z.ZodArray<z.ZodCustom<Blob, Blob>>;
|
|
508
|
+
providerMetadata: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
509
|
+
images: z.ZodOptional<z.ZodArray<z.ZodJSONSchema>>;
|
|
510
|
+
}, z.core.$catchall<z.ZodJSONSchema>>>;
|
|
511
|
+
responses: z.ZodArray<z.ZodObject<{
|
|
512
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
513
|
+
modelId: z.ZodString;
|
|
514
|
+
timestamp: z.ZodISODateTime;
|
|
515
|
+
}, z.core.$strip>>;
|
|
516
|
+
usage: z.ZodObject<{
|
|
517
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
518
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
519
|
+
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
520
|
+
}, z.core.$strip>;
|
|
521
|
+
warnings: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
522
|
+
details: z.ZodOptional<z.ZodString>;
|
|
523
|
+
feature: z.ZodString;
|
|
524
|
+
type: z.ZodLiteral<"unsupported">;
|
|
525
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
526
|
+
details: z.ZodOptional<z.ZodString>;
|
|
527
|
+
feature: z.ZodString;
|
|
528
|
+
type: z.ZodLiteral<"compatibility">;
|
|
529
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
530
|
+
message: z.ZodString;
|
|
531
|
+
setting: z.ZodString;
|
|
532
|
+
type: z.ZodLiteral<"deprecated">;
|
|
533
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
534
|
+
message: z.ZodString;
|
|
535
|
+
type: z.ZodLiteral<"other">;
|
|
536
|
+
}, z.core.$strip>], "type">>;
|
|
537
|
+
}, z.core.$strip>;
|
|
538
|
+
/** Internal terminal delivery emitted by a platform image-generation job. */
|
|
539
|
+
export declare const imageGenerationCompletionSchema: z.ZodObject<{
|
|
540
|
+
key: z.ZodString;
|
|
541
|
+
outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
542
|
+
result: z.ZodObject<{
|
|
543
|
+
images: z.ZodArray<z.ZodCustom<Blob, Blob>>;
|
|
544
|
+
providerMetadata: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
545
|
+
images: z.ZodOptional<z.ZodArray<z.ZodJSONSchema>>;
|
|
546
|
+
}, z.core.$catchall<z.ZodJSONSchema>>>;
|
|
547
|
+
responses: z.ZodArray<z.ZodObject<{
|
|
548
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
549
|
+
modelId: z.ZodString;
|
|
550
|
+
timestamp: z.ZodISODateTime;
|
|
551
|
+
}, z.core.$strip>>;
|
|
552
|
+
usage: z.ZodObject<{
|
|
553
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
554
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
555
|
+
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
556
|
+
}, z.core.$strip>;
|
|
557
|
+
warnings: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
558
|
+
details: z.ZodOptional<z.ZodString>;
|
|
559
|
+
feature: z.ZodString;
|
|
560
|
+
type: z.ZodLiteral<"unsupported">;
|
|
561
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
562
|
+
details: z.ZodOptional<z.ZodString>;
|
|
563
|
+
feature: z.ZodString;
|
|
564
|
+
type: z.ZodLiteral<"compatibility">;
|
|
565
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
566
|
+
message: z.ZodString;
|
|
567
|
+
setting: z.ZodString;
|
|
568
|
+
type: z.ZodLiteral<"deprecated">;
|
|
569
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
570
|
+
message: z.ZodString;
|
|
571
|
+
type: z.ZodLiteral<"other">;
|
|
572
|
+
}, z.core.$strip>], "type">>;
|
|
573
|
+
}, z.core.$strip>;
|
|
574
|
+
status: z.ZodLiteral<"succeeded">;
|
|
575
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
576
|
+
failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
|
|
577
|
+
status: z.ZodLiteral<"failed">;
|
|
578
|
+
}, z.core.$strip>], "status">;
|
|
579
|
+
}, z.core.$strip>;
|
|
580
|
+
/** Starts platform image generation for one reserved internal entrypoint. */
|
|
581
|
+
export declare const platformImageGenerationInputSchema: z.ZodObject<{
|
|
582
|
+
aspectRatio: z.ZodOptional<z.ZodCustom<`${number}:${number}`, `${number}:${number}`>>;
|
|
583
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
584
|
+
maxImagesPerCall: z.ZodOptional<z.ZodNumber>;
|
|
585
|
+
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
586
|
+
model: z.ZodDefault<z.ZodCustom<GatewayImageModelId, GatewayImageModelId>>;
|
|
587
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
588
|
+
prompt: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
589
|
+
images: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodCustom<ArrayBuffer, ArrayBuffer>, z.ZodCustom<Blob, Blob>]>>;
|
|
590
|
+
mask: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodCustom<ArrayBuffer, ArrayBuffer>, z.ZodCustom<Blob, Blob>]>>;
|
|
591
|
+
text: z.ZodOptional<z.ZodString>;
|
|
592
|
+
}, z.core.$strip>]>;
|
|
593
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
594
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
595
|
+
size: z.ZodOptional<z.ZodCustom<`${number}x${number}`, `${number}x${number}`>>;
|
|
596
|
+
entrypoint: z.ZodString;
|
|
597
|
+
}, z.core.$strip>;
|
|
598
|
+
/** Durable identity returned after platform image generation is queued. */
|
|
599
|
+
export declare const platformImageGenerationStartSchema: z.ZodObject<{
|
|
600
|
+
key: z.ZodString;
|
|
601
|
+
}, z.core.$strip>;
|
|
602
|
+
export type ImageGenerationInput = z.output<typeof imageGenerationInputSchema>;
|
|
603
|
+
export type ImageGenerationResult = z.output<typeof imageGenerationResultSchema>;
|
|
604
|
+
export type ImageGenerationCompletion = z.output<typeof imageGenerationCompletionSchema>;
|
|
605
|
+
export type PlatformImageGenerationInput = z.output<typeof platformImageGenerationInputSchema>;
|
|
475
606
|
/**
|
|
476
607
|
* Hashes one coordinator definition exactly as the runtime stores it.
|
|
477
608
|
*
|
|
@@ -1061,6 +1192,25 @@ export declare const runtimeContract: {
|
|
|
1061
1192
|
type: z.ZodLiteral<"other">;
|
|
1062
1193
|
}, z.core.$strip>], "type">>>;
|
|
1063
1194
|
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
1195
|
+
startImageGeneration: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
1196
|
+
aspectRatio: z.ZodOptional<z.ZodCustom<`${number}:${number}`, `${number}:${number}`>>;
|
|
1197
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1198
|
+
maxImagesPerCall: z.ZodOptional<z.ZodNumber>;
|
|
1199
|
+
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
1200
|
+
model: z.ZodDefault<z.ZodCustom<GatewayImageModelId, GatewayImageModelId>>;
|
|
1201
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
1202
|
+
prompt: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
1203
|
+
images: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodCustom<ArrayBuffer, ArrayBuffer>, z.ZodCustom<Blob, Blob>]>>;
|
|
1204
|
+
mask: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodCustom<ArrayBuffer, ArrayBuffer>, z.ZodCustom<Blob, Blob>]>>;
|
|
1205
|
+
text: z.ZodOptional<z.ZodString>;
|
|
1206
|
+
}, z.core.$strip>]>;
|
|
1207
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
1208
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
1209
|
+
size: z.ZodOptional<z.ZodCustom<`${number}x${number}`, `${number}x${number}`>>;
|
|
1210
|
+
entrypoint: z.ZodString;
|
|
1211
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1212
|
+
key: z.ZodString;
|
|
1213
|
+
}, z.core.$strip>, Record<never, never>, Record<never, never>>;
|
|
1064
1214
|
createCallbackToken: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
1065
1215
|
endpointKey: z.ZodString;
|
|
1066
1216
|
}, z.core.$strip>, z.ZodString, Record<never, never>, Record<never, never>>;
|
package/dist/runtime.js
CHANGED
|
@@ -5,14 +5,36 @@ import * as z from "zod";
|
|
|
5
5
|
import { automationErrorSchema } from "./errors.js";
|
|
6
6
|
/** Default model used by the platform Vercel AI Gateway account. */
|
|
7
7
|
export const DEFAULT_GATEWAY_MODEL_ID = "openai/gpt-4.1-nano";
|
|
8
|
+
/** Default image model used by the platform Vercel AI Gateway account. */
|
|
9
|
+
export const DEFAULT_GATEWAY_IMAGE_MODEL_ID = "bfl/flux-2-flex";
|
|
8
10
|
export const AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT = "default";
|
|
9
11
|
export const AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX = "__$";
|
|
10
12
|
export const AUTOMATION_DELAY_ENTRYPOINT_PREFIX = `${AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX}delay:`;
|
|
13
|
+
export const AUTOMATION_IMAGE_GENERATION_ENTRYPOINT_PREFIX = `${AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX}generate-image:`;
|
|
11
14
|
export const CALLBACK_PROTECTION_QUERY_PARAMETER = "_axCallback";
|
|
12
15
|
export const AUTOMATION_LOG_MAX_ENTRIES = 1_000;
|
|
13
16
|
export const AUTOMATION_TRACE_MAX_SPANS = 250;
|
|
14
17
|
export const AUTOMATION_OBSERVABILITY_MAX_FIELDS = 64;
|
|
15
18
|
export const AUTOMATION_OBSERVABILITY_MAX_ENCODED_BYTES = 64 * 1_024;
|
|
19
|
+
const RUNTIME_BLOB_JSON_SERIALIZER_TYPE = 8;
|
|
20
|
+
/** Blob wrappers that should use oRPC's native multipart serialization. */
|
|
21
|
+
const runtimeBlobTransportValues = new WeakSet();
|
|
22
|
+
/** Preserves Blob media types while oRPC carries the bytes as multipart data. */
|
|
23
|
+
export const runtimeBlobJsonSerializer = {
|
|
24
|
+
type: RUNTIME_BLOB_JSON_SERIALIZER_TYPE,
|
|
25
|
+
condition: (value) => value instanceof Blob && !runtimeBlobTransportValues.has(value),
|
|
26
|
+
serialize(value) {
|
|
27
|
+
const transportValue = new Blob([value]);
|
|
28
|
+
runtimeBlobTransportValues.add(transportValue);
|
|
29
|
+
return { transportValue, type: value.type };
|
|
30
|
+
},
|
|
31
|
+
deserialize(value) {
|
|
32
|
+
const { transportValue, type } = z
|
|
33
|
+
.object({ transportValue: z.instanceof(Blob), type: z.string() })
|
|
34
|
+
.parse(value);
|
|
35
|
+
return new Blob([transportValue], { type });
|
|
36
|
+
},
|
|
37
|
+
};
|
|
16
38
|
export const AUTOMATION_LOG_MAX_MESSAGE_LENGTH = 16_384;
|
|
17
39
|
export const AUTOMATION_TRACE_MAX_NAME_LENGTH = 256;
|
|
18
40
|
const OUTCOME_SEQUENCE_SCHEMA = z.number().int().positive();
|
|
@@ -482,7 +504,7 @@ const TARGET_ACTION_SCHEMA = z.union([
|
|
|
482
504
|
status: z.enum(["failed", "skipped", "succeeded"]),
|
|
483
505
|
}),
|
|
484
506
|
]);
|
|
485
|
-
const
|
|
507
|
+
const AI_WARNING_SCHEMA = z.discriminatedUnion("type", [
|
|
486
508
|
z.object({
|
|
487
509
|
details: z.string().optional(),
|
|
488
510
|
feature: z.string(),
|
|
@@ -580,7 +602,7 @@ export const generationResultSchema = z.object({
|
|
|
580
602
|
}),
|
|
581
603
|
text: z.string(),
|
|
582
604
|
usage: GENERATION_USAGE_SCHEMA,
|
|
583
|
-
warnings:
|
|
605
|
+
warnings: AI_WARNING_SCHEMA.array().optional(),
|
|
584
606
|
});
|
|
585
607
|
const RUNTIME_GENERATION_OUTPUT_SCHEMA = z
|
|
586
608
|
.object({
|
|
@@ -597,6 +619,84 @@ const RUNTIME_GENERATION_INPUT_SCHEMA = z.union([
|
|
|
597
619
|
output: RUNTIME_GENERATION_OUTPUT_SCHEMA,
|
|
598
620
|
}),
|
|
599
621
|
]);
|
|
622
|
+
const IMAGE_DATA_CONTENT_SCHEMA = z.union([
|
|
623
|
+
z.string(),
|
|
624
|
+
z.custom((value) => value instanceof Uint8Array),
|
|
625
|
+
z.instanceof(ArrayBuffer),
|
|
626
|
+
z.instanceof(Blob),
|
|
627
|
+
]);
|
|
628
|
+
const IMAGE_GENERATION_PROMPT_SCHEMA = z.union([
|
|
629
|
+
z.string(),
|
|
630
|
+
z.object({
|
|
631
|
+
images: IMAGE_DATA_CONTENT_SCHEMA.array(),
|
|
632
|
+
mask: IMAGE_DATA_CONTENT_SCHEMA.optional(),
|
|
633
|
+
text: z.string().optional(),
|
|
634
|
+
}),
|
|
635
|
+
]);
|
|
636
|
+
const GATEWAY_IMAGE_MODEL_ID_SCHEMA = z
|
|
637
|
+
.custom((value) => typeof value === "string" && value.length > 0, "Model must be a nonempty AI Gateway image model ID.")
|
|
638
|
+
.default(DEFAULT_GATEWAY_IMAGE_MODEL_ID);
|
|
639
|
+
/** Shared options accepted by the built-in image-generation action. */
|
|
640
|
+
export const imageGenerationInputSchema = z.object({
|
|
641
|
+
aspectRatio: z
|
|
642
|
+
.custom((value) => typeof value === "string" && /^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/.test(value), "Aspect ratio must use the format {width}:{height}.")
|
|
643
|
+
.optional(),
|
|
644
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
645
|
+
maxImagesPerCall: z.number().int().positive().optional(),
|
|
646
|
+
maxRetries: z.number().int().nonnegative().optional(),
|
|
647
|
+
model: GATEWAY_IMAGE_MODEL_ID_SCHEMA,
|
|
648
|
+
n: z.number().int().positive().optional(),
|
|
649
|
+
prompt: IMAGE_GENERATION_PROMPT_SCHEMA,
|
|
650
|
+
providerOptions: z
|
|
651
|
+
.record(z.string(), z.record(z.string(), z.json()))
|
|
652
|
+
.optional(),
|
|
653
|
+
seed: z.number().int().optional(),
|
|
654
|
+
size: z
|
|
655
|
+
.custom((value) => typeof value === "string" && /^\d+x\d+$/.test(value), "Size must use the format {width}x{height}.")
|
|
656
|
+
.optional(),
|
|
657
|
+
});
|
|
658
|
+
const IMAGE_PROVIDER_METADATA_SCHEMA = z
|
|
659
|
+
.object({ images: z.json().array().optional() })
|
|
660
|
+
.catchall(z.json());
|
|
661
|
+
/** Serializable subset of the AI SDK image-generation result. */
|
|
662
|
+
export const imageGenerationResultSchema = z.object({
|
|
663
|
+
images: z.instanceof(Blob).array().min(1),
|
|
664
|
+
providerMetadata: z.record(z.string(), IMAGE_PROVIDER_METADATA_SCHEMA),
|
|
665
|
+
responses: z
|
|
666
|
+
.object({
|
|
667
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
668
|
+
modelId: z.string(),
|
|
669
|
+
timestamp: z.iso.datetime(),
|
|
670
|
+
})
|
|
671
|
+
.array(),
|
|
672
|
+
usage: z.object({
|
|
673
|
+
inputTokens: z.number().optional(),
|
|
674
|
+
outputTokens: z.number().optional(),
|
|
675
|
+
totalTokens: z.number().optional(),
|
|
676
|
+
}),
|
|
677
|
+
warnings: AI_WARNING_SCHEMA.array(),
|
|
678
|
+
});
|
|
679
|
+
/** Internal terminal delivery emitted by a platform image-generation job. */
|
|
680
|
+
export const imageGenerationCompletionSchema = z.object({
|
|
681
|
+
key: z.string().min(1),
|
|
682
|
+
outcome: z.discriminatedUnion("status", [
|
|
683
|
+
z.object({
|
|
684
|
+
result: imageGenerationResultSchema,
|
|
685
|
+
status: z.literal("succeeded"),
|
|
686
|
+
}),
|
|
687
|
+
z.object({ failure: automationErrorSchema, status: z.literal("failed") }),
|
|
688
|
+
]),
|
|
689
|
+
});
|
|
690
|
+
/** Starts platform image generation for one reserved internal entrypoint. */
|
|
691
|
+
export const platformImageGenerationInputSchema = imageGenerationInputSchema.extend({
|
|
692
|
+
entrypoint: z
|
|
693
|
+
.string()
|
|
694
|
+
.startsWith(AUTOMATION_IMAGE_GENERATION_ENTRYPOINT_PREFIX),
|
|
695
|
+
});
|
|
696
|
+
/** Durable identity returned after platform image generation is queued. */
|
|
697
|
+
export const platformImageGenerationStartSchema = z.object({
|
|
698
|
+
key: z.string().min(1),
|
|
699
|
+
});
|
|
600
700
|
/**
|
|
601
701
|
* Hashes one coordinator definition exactly as the runtime stores it.
|
|
602
702
|
*
|
|
@@ -667,6 +767,9 @@ export const runtimeContract = {
|
|
|
667
767
|
generate: oc
|
|
668
768
|
.input(RUNTIME_GENERATION_INPUT_SCHEMA)
|
|
669
769
|
.output(generationResultSchema),
|
|
770
|
+
startImageGeneration: oc
|
|
771
|
+
.input(platformImageGenerationInputSchema)
|
|
772
|
+
.output(platformImageGenerationStartSchema),
|
|
670
773
|
createCallbackToken: oc
|
|
671
774
|
.input(z.object({ endpointKey: z.string().min(1) }))
|
|
672
775
|
.output(z.string()),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automate.ax/api-contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.2",
|
|
4
4
|
"description": "Public oRPC contract for the Automate.ax API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ai-sdk/gateway": "
|
|
34
|
-
"@automate.ax/codec": "0.
|
|
35
|
-
"@automate.ax/integration-contracts": "0.
|
|
33
|
+
"@ai-sdk/gateway": "4.0.46",
|
|
34
|
+
"@automate.ax/codec": "0.86.2",
|
|
35
|
+
"@automate.ax/integration-contracts": "0.86.2",
|
|
36
36
|
"@orpc/contract": "1.15.0",
|
|
37
37
|
"fast-json-stable-stringify": "^2.1.0",
|
|
38
38
|
"zod": "^4.3.6"
|
package/src/index.ts
CHANGED
|
@@ -44,26 +44,37 @@ export {
|
|
|
44
44
|
export {
|
|
45
45
|
AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT,
|
|
46
46
|
AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX,
|
|
47
|
+
AUTOMATION_IMAGE_GENERATION_ENTRYPOINT_PREFIX,
|
|
47
48
|
AUTOMATION_LOG_MAX_ENTRIES,
|
|
48
49
|
AUTOMATION_LOG_MAX_MESSAGE_LENGTH,
|
|
49
50
|
AUTOMATION_OBSERVABILITY_MAX_ENCODED_BYTES,
|
|
50
51
|
AUTOMATION_OBSERVABILITY_MAX_FIELDS,
|
|
51
52
|
AUTOMATION_TRACE_MAX_NAME_LENGTH,
|
|
52
53
|
AUTOMATION_TRACE_MAX_SPANS,
|
|
54
|
+
DEFAULT_GATEWAY_IMAGE_MODEL_ID,
|
|
53
55
|
DEFAULT_GATEWAY_MODEL_ID,
|
|
54
56
|
automationInvocationInputSchema,
|
|
55
57
|
automationInvocationOutputSchema,
|
|
56
58
|
automationInvocationScheduleSchema,
|
|
57
59
|
generationInputSchema,
|
|
58
60
|
generationResultSchema,
|
|
61
|
+
imageGenerationInputSchema,
|
|
62
|
+
imageGenerationCompletionSchema,
|
|
63
|
+
imageGenerationResultSchema,
|
|
64
|
+
platformImageGenerationInputSchema,
|
|
65
|
+
platformImageGenerationStartSchema,
|
|
59
66
|
hashSignalCoordinatorConfiguration,
|
|
60
67
|
runtimeContract,
|
|
61
68
|
type GenerationInput,
|
|
62
69
|
type GenerationResult,
|
|
70
|
+
type ImageGenerationInput,
|
|
71
|
+
type ImageGenerationCompletion,
|
|
72
|
+
type ImageGenerationResult,
|
|
73
|
+
type PlatformImageGenerationInput,
|
|
63
74
|
type RuntimeGenerationInput,
|
|
64
75
|
type RuntimeCoordinationOffer,
|
|
65
76
|
} from "./runtime"
|
|
66
|
-
export type { GatewayModelId } from "@ai-sdk/gateway"
|
|
77
|
+
export type { GatewayImageModelId, GatewayModelId } from "@ai-sdk/gateway"
|
|
67
78
|
export {
|
|
68
79
|
createdOrganizationApiKeyOutputSchema,
|
|
69
80
|
organizationApiKeyOutputSchema,
|
package/src/runtime.ts
CHANGED
|
@@ -3,26 +3,55 @@ import {
|
|
|
3
3
|
isSensitivityMask,
|
|
4
4
|
type SensitivityMask,
|
|
5
5
|
} from "@automate.ax/codec"
|
|
6
|
-
import type { GatewayModelId } from "@ai-sdk/gateway"
|
|
6
|
+
import type { GatewayImageModelId, GatewayModelId } from "@ai-sdk/gateway"
|
|
7
7
|
import { oc } from "@orpc/contract"
|
|
8
8
|
import stableStringify from "fast-json-stable-stringify"
|
|
9
9
|
import * as z from "zod"
|
|
10
10
|
import { automationErrorSchema } from "./errors"
|
|
11
11
|
|
|
12
|
-
export type { GatewayModelId } from "@ai-sdk/gateway"
|
|
12
|
+
export type { GatewayImageModelId, GatewayModelId } from "@ai-sdk/gateway"
|
|
13
13
|
|
|
14
14
|
/** Default model used by the platform Vercel AI Gateway account. */
|
|
15
15
|
export const DEFAULT_GATEWAY_MODEL_ID =
|
|
16
16
|
"openai/gpt-4.1-nano" satisfies GatewayModelId
|
|
17
|
+
|
|
18
|
+
/** Default image model used by the platform Vercel AI Gateway account. */
|
|
19
|
+
export const DEFAULT_GATEWAY_IMAGE_MODEL_ID =
|
|
20
|
+
"bfl/flux-2-flex" satisfies GatewayImageModelId
|
|
17
21
|
export const AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT = "default"
|
|
18
22
|
export const AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX = "__$"
|
|
19
23
|
export const AUTOMATION_DELAY_ENTRYPOINT_PREFIX =
|
|
20
24
|
`${AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX}delay:` as const
|
|
25
|
+
export const AUTOMATION_IMAGE_GENERATION_ENTRYPOINT_PREFIX =
|
|
26
|
+
`${AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX}generate-image:` as const
|
|
21
27
|
export const CALLBACK_PROTECTION_QUERY_PARAMETER = "_axCallback"
|
|
22
28
|
export const AUTOMATION_LOG_MAX_ENTRIES = 1_000
|
|
23
29
|
export const AUTOMATION_TRACE_MAX_SPANS = 250
|
|
24
30
|
export const AUTOMATION_OBSERVABILITY_MAX_FIELDS = 64
|
|
25
31
|
export const AUTOMATION_OBSERVABILITY_MAX_ENCODED_BYTES = 64 * 1_024
|
|
32
|
+
|
|
33
|
+
const RUNTIME_BLOB_JSON_SERIALIZER_TYPE = 8
|
|
34
|
+
|
|
35
|
+
/** Blob wrappers that should use oRPC's native multipart serialization. */
|
|
36
|
+
const runtimeBlobTransportValues = new WeakSet<Blob>()
|
|
37
|
+
|
|
38
|
+
/** Preserves Blob media types while oRPC carries the bytes as multipart data. */
|
|
39
|
+
export const runtimeBlobJsonSerializer = {
|
|
40
|
+
type: RUNTIME_BLOB_JSON_SERIALIZER_TYPE,
|
|
41
|
+
condition: (value: unknown) =>
|
|
42
|
+
value instanceof Blob && !runtimeBlobTransportValues.has(value),
|
|
43
|
+
serialize(value: Blob) {
|
|
44
|
+
const transportValue = new Blob([value])
|
|
45
|
+
runtimeBlobTransportValues.add(transportValue)
|
|
46
|
+
return { transportValue, type: value.type }
|
|
47
|
+
},
|
|
48
|
+
deserialize(value: unknown) {
|
|
49
|
+
const { transportValue, type } = z
|
|
50
|
+
.object({ transportValue: z.instanceof(Blob), type: z.string() })
|
|
51
|
+
.parse(value)
|
|
52
|
+
return new Blob([transportValue], { type })
|
|
53
|
+
},
|
|
54
|
+
}
|
|
26
55
|
export const AUTOMATION_LOG_MAX_MESSAGE_LENGTH = 16_384
|
|
27
56
|
export const AUTOMATION_TRACE_MAX_NAME_LENGTH = 256
|
|
28
57
|
|
|
@@ -552,7 +581,7 @@ const TARGET_ACTION_SCHEMA = z.union([
|
|
|
552
581
|
}),
|
|
553
582
|
])
|
|
554
583
|
|
|
555
|
-
const
|
|
584
|
+
const AI_WARNING_SCHEMA = z.discriminatedUnion("type", [
|
|
556
585
|
z.object({
|
|
557
586
|
details: z.string().optional(),
|
|
558
587
|
feature: z.string(),
|
|
@@ -660,7 +689,7 @@ export const generationResultSchema = z.object({
|
|
|
660
689
|
}),
|
|
661
690
|
text: z.string(),
|
|
662
691
|
usage: GENERATION_USAGE_SCHEMA,
|
|
663
|
-
warnings:
|
|
692
|
+
warnings: AI_WARNING_SCHEMA.array().optional(),
|
|
664
693
|
})
|
|
665
694
|
|
|
666
695
|
export type GenerationInput = z.output<typeof generationInputSchema>
|
|
@@ -687,6 +716,106 @@ export type RuntimeGenerationInput = z.output<
|
|
|
687
716
|
typeof RUNTIME_GENERATION_INPUT_SCHEMA
|
|
688
717
|
>
|
|
689
718
|
|
|
719
|
+
const IMAGE_DATA_CONTENT_SCHEMA = z.union([
|
|
720
|
+
z.string(),
|
|
721
|
+
z.custom<Uint8Array>((value) => value instanceof Uint8Array),
|
|
722
|
+
z.instanceof(ArrayBuffer),
|
|
723
|
+
z.instanceof(Blob),
|
|
724
|
+
])
|
|
725
|
+
|
|
726
|
+
const IMAGE_GENERATION_PROMPT_SCHEMA = z.union([
|
|
727
|
+
z.string(),
|
|
728
|
+
z.object({
|
|
729
|
+
images: IMAGE_DATA_CONTENT_SCHEMA.array(),
|
|
730
|
+
mask: IMAGE_DATA_CONTENT_SCHEMA.optional(),
|
|
731
|
+
text: z.string().optional(),
|
|
732
|
+
}),
|
|
733
|
+
])
|
|
734
|
+
|
|
735
|
+
const GATEWAY_IMAGE_MODEL_ID_SCHEMA = z
|
|
736
|
+
.custom<GatewayImageModelId>(
|
|
737
|
+
(value) => typeof value === "string" && value.length > 0,
|
|
738
|
+
"Model must be a nonempty AI Gateway image model ID.",
|
|
739
|
+
)
|
|
740
|
+
.default(DEFAULT_GATEWAY_IMAGE_MODEL_ID)
|
|
741
|
+
|
|
742
|
+
/** Shared options accepted by the built-in image-generation action. */
|
|
743
|
+
export const imageGenerationInputSchema = z.object({
|
|
744
|
+
aspectRatio: z
|
|
745
|
+
.custom<`${number}:${number}`>((value) => typeof value === "string" && /^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/.test(value), "Aspect ratio must use the format {width}:{height}.")
|
|
746
|
+
.optional(),
|
|
747
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
748
|
+
maxImagesPerCall: z.number().int().positive().optional(),
|
|
749
|
+
maxRetries: z.number().int().nonnegative().optional(),
|
|
750
|
+
model: GATEWAY_IMAGE_MODEL_ID_SCHEMA,
|
|
751
|
+
n: z.number().int().positive().optional(),
|
|
752
|
+
prompt: IMAGE_GENERATION_PROMPT_SCHEMA,
|
|
753
|
+
providerOptions: z
|
|
754
|
+
.record(z.string(), z.record(z.string(), z.json()))
|
|
755
|
+
.optional(),
|
|
756
|
+
seed: z.number().int().optional(),
|
|
757
|
+
size: z
|
|
758
|
+
.custom<`${number}x${number}`>((value) => typeof value === "string" && /^\d+x\d+$/.test(value), "Size must use the format {width}x{height}.")
|
|
759
|
+
.optional(),
|
|
760
|
+
})
|
|
761
|
+
|
|
762
|
+
const IMAGE_PROVIDER_METADATA_SCHEMA = z
|
|
763
|
+
.object({ images: z.json().array().optional() })
|
|
764
|
+
.catchall(z.json())
|
|
765
|
+
|
|
766
|
+
/** Serializable subset of the AI SDK image-generation result. */
|
|
767
|
+
export const imageGenerationResultSchema = z.object({
|
|
768
|
+
images: z.instanceof(Blob).array().min(1),
|
|
769
|
+
providerMetadata: z.record(z.string(), IMAGE_PROVIDER_METADATA_SCHEMA),
|
|
770
|
+
responses: z
|
|
771
|
+
.object({
|
|
772
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
773
|
+
modelId: z.string(),
|
|
774
|
+
timestamp: z.iso.datetime(),
|
|
775
|
+
})
|
|
776
|
+
.array(),
|
|
777
|
+
usage: z.object({
|
|
778
|
+
inputTokens: z.number().optional(),
|
|
779
|
+
outputTokens: z.number().optional(),
|
|
780
|
+
totalTokens: z.number().optional(),
|
|
781
|
+
}),
|
|
782
|
+
warnings: AI_WARNING_SCHEMA.array(),
|
|
783
|
+
})
|
|
784
|
+
|
|
785
|
+
/** Internal terminal delivery emitted by a platform image-generation job. */
|
|
786
|
+
export const imageGenerationCompletionSchema = z.object({
|
|
787
|
+
key: z.string().min(1),
|
|
788
|
+
outcome: z.discriminatedUnion("status", [
|
|
789
|
+
z.object({
|
|
790
|
+
result: imageGenerationResultSchema,
|
|
791
|
+
status: z.literal("succeeded"),
|
|
792
|
+
}),
|
|
793
|
+
z.object({ failure: automationErrorSchema, status: z.literal("failed") }),
|
|
794
|
+
]),
|
|
795
|
+
})
|
|
796
|
+
|
|
797
|
+
/** Starts platform image generation for one reserved internal entrypoint. */
|
|
798
|
+
export const platformImageGenerationInputSchema =
|
|
799
|
+
imageGenerationInputSchema.extend({
|
|
800
|
+
entrypoint: z
|
|
801
|
+
.string()
|
|
802
|
+
.startsWith(AUTOMATION_IMAGE_GENERATION_ENTRYPOINT_PREFIX),
|
|
803
|
+
})
|
|
804
|
+
|
|
805
|
+
/** Durable identity returned after platform image generation is queued. */
|
|
806
|
+
export const platformImageGenerationStartSchema = z.object({
|
|
807
|
+
key: z.string().min(1),
|
|
808
|
+
})
|
|
809
|
+
|
|
810
|
+
export type ImageGenerationInput = z.output<typeof imageGenerationInputSchema>
|
|
811
|
+
export type ImageGenerationResult = z.output<typeof imageGenerationResultSchema>
|
|
812
|
+
export type ImageGenerationCompletion = z.output<
|
|
813
|
+
typeof imageGenerationCompletionSchema
|
|
814
|
+
>
|
|
815
|
+
export type PlatformImageGenerationInput = z.output<
|
|
816
|
+
typeof platformImageGenerationInputSchema
|
|
817
|
+
>
|
|
818
|
+
|
|
690
819
|
/**
|
|
691
820
|
* Hashes one coordinator definition exactly as the runtime stores it.
|
|
692
821
|
*
|
|
@@ -778,6 +907,9 @@ export const runtimeContract = {
|
|
|
778
907
|
generate: oc
|
|
779
908
|
.input(RUNTIME_GENERATION_INPUT_SCHEMA)
|
|
780
909
|
.output(generationResultSchema),
|
|
910
|
+
startImageGeneration: oc
|
|
911
|
+
.input(platformImageGenerationInputSchema)
|
|
912
|
+
.output(platformImageGenerationStartSchema),
|
|
781
913
|
createCallbackToken: oc
|
|
782
914
|
.input(z.object({ endpointKey: z.string().min(1) }))
|
|
783
915
|
.output(z.string()),
|