@automate.ax/api-contract 0.87.0 → 0.87.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/src/runtime.ts CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  isSensitivityMask,
4
4
  type SensitivityMask,
5
5
  } from "@automate.ax/codec"
6
+ import { codecEnvelopeSchema } from "@automate.ax/codec/rpc"
6
7
  import type { GatewayImageModelId, GatewayModelId } from "@ai-sdk/gateway"
7
8
  import { oc } from "@orpc/contract"
8
9
  import stableStringify from "fast-json-stable-stringify"
@@ -30,34 +31,12 @@ export const AUTOMATION_TRACE_MAX_SPANS = 250
30
31
  export const AUTOMATION_OBSERVABILITY_MAX_FIELDS = 64
31
32
  export const AUTOMATION_OBSERVABILITY_MAX_ENCODED_BYTES = 64 * 1_024
32
33
 
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
- }
55
34
  export const AUTOMATION_LOG_MAX_MESSAGE_LENGTH = 16_384
56
35
  export const AUTOMATION_TRACE_MAX_NAME_LENGTH = 256
57
36
 
58
37
  const OUTCOME_SEQUENCE_SCHEMA = z.number().int().positive()
59
38
  const HOOK_SCOPE_PATH_SCHEMA = z.number().int().nonnegative().array()
60
- const OBSERVABILITY_FIELDS_SCHEMA = z
39
+ export const runtimeObservabilityFieldsSchema = z
61
40
  .record(z.string().min(1).max(128), encodableSchema)
62
41
  .refine(
63
42
  (fields) =>
@@ -129,27 +108,34 @@ export const automationInvocationOutputSchema = z.object({
129
108
  runAt: z.date(),
130
109
  })
131
110
 
132
- export const automationInvocationInputSchema = z
133
- .object({
134
- entrypoint: z
135
- .string()
136
- .min(1)
137
- .default(AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT),
138
- payload: encodableSchema,
111
+ const AUTOMATION_INVOCATION_BASE_SCHEMA = z.object({
112
+ entrypoint: z
113
+ .string()
114
+ .min(1)
115
+ .default(AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT),
116
+ })
117
+ const AUTOMATION_INVOCATION_TARGET_SCHEMA = z.union([
118
+ z.object({
119
+ automationId: z.string().min(1),
120
+ automationName: z.never().optional(),
121
+ }),
122
+ z.object({
123
+ automationId: z.never().optional(),
124
+ automationName: z.string().min(1),
125
+ }),
126
+ ])
127
+
128
+ export const automationInvocationInputSchema =
129
+ AUTOMATION_INVOCATION_BASE_SCHEMA.extend({ payload: encodableSchema })
130
+ .and(AUTOMATION_INVOCATION_TARGET_SCHEMA)
131
+ .and(automationInvocationScheduleSchema)
132
+
133
+ const AUTOMATION_INVOCATION_TRANSPORT_INPUT_SCHEMA =
134
+ AUTOMATION_INVOCATION_BASE_SCHEMA.extend({
135
+ payload: codecEnvelopeSchema,
139
136
  })
140
- .and(
141
- z.union([
142
- z.object({
143
- automationId: z.string().min(1),
144
- automationName: z.never().optional(),
145
- }),
146
- z.object({
147
- automationId: z.never().optional(),
148
- automationName: z.string().min(1),
149
- }),
150
- ]),
151
- )
152
- .and(automationInvocationScheduleSchema)
137
+ .and(AUTOMATION_INVOCATION_TARGET_SCHEMA)
138
+ .and(automationInvocationScheduleSchema)
153
139
 
154
140
  const SIGNAL_DERIVATION_NODE_SCHEMA = z.discriminatedUnion("type", [
155
141
  z.object({
@@ -283,33 +269,39 @@ const CORRELATION_STREAM_ORIGINS_SCHEMA = z
283
269
  .array()
284
270
  .min(2)
285
271
 
286
- const CORRELATION_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
287
- key: encodableSchema,
288
- ordered: z.boolean(),
289
- outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
290
- policy: z.literal("correlate"),
291
- streamIndex: z.number().int().nonnegative(),
292
- streamOrigins: CORRELATION_STREAM_ORIGINS_SCHEMA,
293
- ttl: z.union([z.string().min(1), z.number().nonnegative()]).optional(),
294
- }).superRefine((entry, context) => {
295
- if (entry.streamIndex >= entry.streamOrigins.length) {
296
- context.addIssue({
297
- code: "custom",
298
- message: "Correlation stream index must identify an input stream.",
299
- path: ["streamIndex"],
300
- })
301
- }
302
- })
272
+ const createCorrelationOfferSchema = <TKeySchema extends z.ZodType>(
273
+ keySchema: TKeySchema,
274
+ ) =>
275
+ SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
276
+ key: keySchema,
277
+ ordered: z.boolean(),
278
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
279
+ policy: z.literal("correlate"),
280
+ streamIndex: z.number().int().nonnegative(),
281
+ streamOrigins: CORRELATION_STREAM_ORIGINS_SCHEMA,
282
+ ttl: z.union([z.string().min(1), z.number().nonnegative()]).optional(),
283
+ }).superRefine((entry, context) => {
284
+ if (entry.streamIndex >= entry.streamOrigins.length) {
285
+ context.addIssue({
286
+ code: "custom",
287
+ message: "Correlation stream index must identify an input stream.",
288
+ path: ["streamIndex"],
289
+ })
290
+ }
291
+ })
303
292
 
304
- const COLLECTION_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
305
- count: z.number().int().positive(),
306
- key: encodableSchema,
307
- outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
308
- policy: z.literal("collect"),
309
- position: z.number().int().nonnegative().optional(),
310
- primaryPosition: COORDINATION_PRIMARY_POSITION_SCHEMA,
311
- ttl: z.union([z.string().min(1), z.number().nonnegative()]).optional(),
312
- })
293
+ const createCollectionOfferSchema = <TKeySchema extends z.ZodType>(
294
+ keySchema: TKeySchema,
295
+ ) =>
296
+ SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
297
+ count: z.number().int().positive(),
298
+ key: keySchema,
299
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
300
+ policy: z.literal("collect"),
301
+ position: z.number().int().nonnegative().optional(),
302
+ primaryPosition: COORDINATION_PRIMARY_POSITION_SCHEMA,
303
+ ttl: z.union([z.string().min(1), z.number().nonnegative()]).optional(),
304
+ })
313
305
 
314
306
  const FANOUT_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
315
307
  count: z.number().int().nonnegative(),
@@ -317,67 +309,77 @@ const FANOUT_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
317
309
  policy: z.literal("fanout"),
318
310
  })
319
311
 
320
- const FUNNEL_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
321
- key: encodableSchema,
322
- maxBurstDuration: COORDINATION_DURATION_SCHEMA.optional(),
323
- minGap: COORDINATION_DURATION_SCHEMA.optional(),
324
- minQuietPeriod: COORDINATION_DURATION_SCHEMA.optional(),
325
- outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
326
- policy: z.literal("funnel"),
327
- primaryPosition: COORDINATION_PRIMARY_POSITION_SCHEMA,
328
- selection: z.enum(["all", "first", "last"]),
329
- triggerAt: z.enum(["start", "end", "both"]),
330
- ttl: COORDINATION_DURATION_SCHEMA.optional(),
331
- until: z.date().optional(),
332
- }).superRefine((offer, context) => {
333
- if (
334
- offer.maxBurstDuration === undefined &&
335
- offer.minGap === undefined &&
336
- offer.minQuietPeriod === undefined &&
337
- offer.until === undefined
338
- ) {
339
- context.addIssue({
340
- code: "custom",
341
- message: "A funnel requires at least one timing control.",
342
- })
343
- }
344
- if (
345
- offer.triggerAt === "end" &&
346
- offer.minGap !== undefined &&
347
- offer.minQuietPeriod === undefined &&
348
- offer.maxBurstDuration === undefined &&
349
- offer.until === undefined
350
- ) {
351
- context.addIssue({
352
- code: "custom",
353
- message:
354
- "A trailing funnel with minGap also requires minQuietPeriod, maxBurstDuration, or until.",
355
- path: ["minGap"],
356
- })
357
- }
358
- if (offer.maxBurstDuration !== undefined && offer.until !== undefined) {
359
- context.addIssue({
360
- code: "custom",
361
- message: "A funnel cannot use maxBurstDuration and until together.",
362
- path: ["until"],
363
- })
364
- }
365
- if (offer.selection !== "all" && offer.selection !== offer.primaryPosition) {
366
- context.addIssue({
367
- code: "custom",
368
- message:
369
- "A selecting funnel must inherit conflicting values from its selected occurrence.",
370
- path: ["primaryPosition"],
371
- })
372
- }
373
- if (offer.triggerAt === "start" && offer.selection !== "first") {
374
- context.addIssue({
375
- code: "custom",
376
- message: "A start-only funnel can only select its first occurrence.",
377
- path: ["selection"],
378
- })
379
- }
380
- })
312
+ const createFunnelOfferSchema = <TKeySchema extends z.ZodType>(
313
+ keySchema: TKeySchema,
314
+ ) =>
315
+ SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
316
+ key: keySchema,
317
+ maxBurstDuration: COORDINATION_DURATION_SCHEMA.optional(),
318
+ minGap: COORDINATION_DURATION_SCHEMA.optional(),
319
+ minQuietPeriod: COORDINATION_DURATION_SCHEMA.optional(),
320
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
321
+ policy: z.literal("funnel"),
322
+ primaryPosition: COORDINATION_PRIMARY_POSITION_SCHEMA,
323
+ selection: z.enum(["all", "first", "last"]),
324
+ triggerAt: z.enum(["start", "end", "both"]),
325
+ ttl: COORDINATION_DURATION_SCHEMA.optional(),
326
+ until: z.date().optional(),
327
+ }).superRefine((offer, context) => {
328
+ if (
329
+ offer.maxBurstDuration === undefined &&
330
+ offer.minGap === undefined &&
331
+ offer.minQuietPeriod === undefined &&
332
+ offer.until === undefined
333
+ ) {
334
+ context.addIssue({
335
+ code: "custom",
336
+ message: "A funnel requires at least one timing control.",
337
+ })
338
+ }
339
+ if (
340
+ offer.triggerAt === "end" &&
341
+ offer.minGap !== undefined &&
342
+ offer.minQuietPeriod === undefined &&
343
+ offer.maxBurstDuration === undefined &&
344
+ offer.until === undefined
345
+ ) {
346
+ context.addIssue({
347
+ code: "custom",
348
+ message:
349
+ "A trailing funnel with minGap also requires minQuietPeriod, maxBurstDuration, or until.",
350
+ path: ["minGap"],
351
+ })
352
+ }
353
+ if (offer.maxBurstDuration !== undefined && offer.until !== undefined) {
354
+ context.addIssue({
355
+ code: "custom",
356
+ message: "A funnel cannot use maxBurstDuration and until together.",
357
+ path: ["until"],
358
+ })
359
+ }
360
+ if (
361
+ offer.selection !== "all" &&
362
+ offer.selection !== offer.primaryPosition
363
+ ) {
364
+ context.addIssue({
365
+ code: "custom",
366
+ message:
367
+ "A selecting funnel must inherit conflicting values from its selected occurrence.",
368
+ path: ["primaryPosition"],
369
+ })
370
+ }
371
+ if (offer.triggerAt === "start" && offer.selection !== "first") {
372
+ context.addIssue({
373
+ code: "custom",
374
+ message: "A start-only funnel can only select its first occurrence.",
375
+ path: ["selection"],
376
+ })
377
+ }
378
+ })
379
+
380
+ const COLLECTION_OFFER_SCHEMA = createCollectionOfferSchema(encodableSchema)
381
+ const CORRELATION_OFFER_SCHEMA = createCorrelationOfferSchema(encodableSchema)
382
+ const FUNNEL_OFFER_SCHEMA = createFunnelOfferSchema(encodableSchema)
381
383
 
382
384
  const RACE_OFFER_BASE_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
383
385
  cohortActionDependencyIds: z.string().array(),
@@ -413,6 +415,14 @@ const COORDINATION_OFFER_SCHEMA = z.union([
413
415
  RACE_OFFER_SCHEMA,
414
416
  ])
415
417
 
418
+ const COORDINATION_OFFER_TRANSPORT_SCHEMA = z.union([
419
+ createCollectionOfferSchema(codecEnvelopeSchema),
420
+ createCorrelationOfferSchema(codecEnvelopeSchema),
421
+ FANOUT_OFFER_SCHEMA,
422
+ createFunnelOfferSchema(codecEnvelopeSchema),
423
+ RACE_OFFER_SCHEMA,
424
+ ])
425
+
416
426
  /** One validated durable coordination offer sent by the automation runtime. */
417
427
  export type RuntimeCoordinationOffer = z.output<
418
428
  typeof COORDINATION_OFFER_SCHEMA
@@ -490,6 +500,28 @@ const ACTION_VALUE_OUTCOME_SCHEMA = z.union([
490
500
  }),
491
501
  ])
492
502
 
503
+ const ACTION_VALUE_TRANSPORT_OUTCOME_SCHEMA = z.union([
504
+ ACTION_VALUE_OUTCOME_BASE_SCHEMA.extend({
505
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
506
+ status: z.literal("failed"),
507
+ failure: automationErrorSchema,
508
+ }),
509
+ ACTION_VALUE_OUTCOME_BASE_SCHEMA.extend({
510
+ reason: z.literal("closed-dependency"),
511
+ status: z.literal("skipped"),
512
+ }),
513
+ ACTION_VALUE_OUTCOME_BASE_SCHEMA.extend({
514
+ failure: automationErrorSchema,
515
+ reason: z.literal("failed-dependency"),
516
+ status: z.literal("skipped"),
517
+ }),
518
+ ACTION_VALUE_OUTCOME_BASE_SCHEMA.extend({
519
+ output: codecEnvelopeSchema,
520
+ outputSensitivity: sensitivityMaskSchema.nullable().optional(),
521
+ status: z.literal("succeeded"),
522
+ }),
523
+ ])
524
+
493
525
  const SIGNAL_VALUE_OUTCOME_BASE_SCHEMA = z.object({
494
526
  contextId: z.string(),
495
527
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
@@ -530,6 +562,20 @@ const SIGNAL_VALUE_OUTCOME_SCHEMA = z.union([
530
562
  }),
531
563
  ])
532
564
 
565
+ const SIGNAL_VALUE_TRANSPORT_OUTCOME_SCHEMA = z.union([
566
+ SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("open") }),
567
+ SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
568
+ SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
569
+ failure: automationErrorSchema,
570
+ status: z.literal("failed"),
571
+ }),
572
+ SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
573
+ output: codecEnvelopeSchema.optional(),
574
+ selectedIndex: z.number().int().nonnegative().optional(),
575
+ status: z.literal("succeeded"),
576
+ }),
577
+ ])
578
+
533
579
  const RUNTIME_VALUE_CONTEXT_SCHEMA = z.object({
534
580
  actionOutputs: ACTION_VALUE_OUTCOME_SCHEMA.array(),
535
581
  coordinationSelections: COORDINATION_SELECTION_SCHEMA.array(),
@@ -549,6 +595,28 @@ const RUNTIME_VALUE_CONTEXT_SCHEMA = z.object({
549
595
  signalOutputs: SIGNAL_VALUE_OUTCOME_SCHEMA.array(),
550
596
  })
551
597
 
598
+ const RUNTIME_VALUE_TRANSPORT_CONTEXT_SCHEMA = z.object({
599
+ actionOutputs: ACTION_VALUE_TRANSPORT_OUTCOME_SCHEMA.array(),
600
+ coordinationSelections: COORDINATION_SELECTION_SCHEMA.array(),
601
+ contextId: z.string(),
602
+ contextParents: RUNTIME_CONTEXT_PARENT_SCHEMA.array(),
603
+ events: z
604
+ .object({
605
+ automationEventId: z.string(),
606
+ contextId: z.string(),
607
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
608
+ payload: codecEnvelopeSchema,
609
+ scopePath: HOOK_SCOPE_PATH_SCHEMA,
610
+ slot: z.number().int(),
611
+ timestamp: z.date(),
612
+ })
613
+ .array(),
614
+ signalOutputs: SIGNAL_VALUE_TRANSPORT_OUTCOME_SCHEMA.array(),
615
+ })
616
+
617
+ /** Durable values resolved by one runtime traversal. */
618
+ export type RuntimeValueContext = z.output<typeof RUNTIME_VALUE_CONTEXT_SCHEMA>
619
+
552
620
  const RUNTIME_RUN_CONTEXT_SCHEMA = z.object({
553
621
  actions: ACTION_RUN_INVOCATION_SCHEMA.array(),
554
622
  contextId: z.string(),
@@ -565,6 +633,9 @@ const RUNTIME_RUN_CONTEXT_SCHEMA = z.object({
565
633
  signalOutputs: SIGNAL_BATCH_OUTCOME_SCHEMA.array(),
566
634
  })
567
635
 
636
+ /** Durable frontier and declarations loaded for one runtime traversal. */
637
+ export type RuntimeRunContext = z.output<typeof RUNTIME_RUN_CONTEXT_SCHEMA>
638
+
568
639
  const TARGET_ACTION_SCHEMA = z.union([
569
640
  z.object({
570
641
  context: RUNTIME_VALUE_CONTEXT_SCHEMA,
@@ -581,6 +652,25 @@ const TARGET_ACTION_SCHEMA = z.union([
581
652
  }),
582
653
  ])
583
654
 
655
+ /** Optional action targeted by one runtime execution. */
656
+ export type RuntimeTargetAction = z.output<typeof TARGET_ACTION_SCHEMA>
657
+
658
+ const TARGET_ACTION_TRANSPORT_SCHEMA = z.union([
659
+ z.object({
660
+ context: RUNTIME_VALUE_TRANSPORT_CONTEXT_SCHEMA,
661
+ id: z.string(),
662
+ scopePath: HOOK_SCOPE_PATH_SCHEMA,
663
+ slot: z.number().int(),
664
+ status: z.literal("pending"),
665
+ }),
666
+ z.object({
667
+ id: z.string(),
668
+ scopePath: HOOK_SCOPE_PATH_SCHEMA,
669
+ slot: z.number().int(),
670
+ status: z.enum(["failed", "skipped", "succeeded"]),
671
+ }),
672
+ ])
673
+
584
674
  const AI_WARNING_SCHEMA = z.discriminatedUnion("type", [
585
675
  z.object({
586
676
  details: z.string().optional(),
@@ -692,6 +782,16 @@ export const generationResultSchema = z.object({
692
782
  warnings: AI_WARNING_SCHEMA.array().optional(),
693
783
  })
694
784
 
785
+ const RUNTIME_GENERATION_RESULT_SCHEMA = generationResultSchema
786
+ .omit({ output: true, providerMetadata: true, usage: true })
787
+ .extend({
788
+ output: codecEnvelopeSchema,
789
+ providerMetadata: codecEnvelopeSchema,
790
+ usage: GENERATION_USAGE_SCHEMA.omit({ raw: true }).extend({
791
+ raw: codecEnvelopeSchema,
792
+ }),
793
+ })
794
+
695
795
  export type GenerationInput = z.output<typeof generationInputSchema>
696
796
  export type GenerationResult = z.output<typeof generationResultSchema>
697
797
 
@@ -816,6 +916,44 @@ export type PlatformImageGenerationInput = z.output<
816
916
  typeof platformImageGenerationInputSchema
817
917
  >
818
918
 
919
+ const PLATFORM_IMAGE_GENERATION_TRANSPORT_INPUT_SCHEMA =
920
+ platformImageGenerationInputSchema.omit({ prompt: true }).extend({
921
+ prompt: codecEnvelopeSchema,
922
+ })
923
+
924
+ const ACTION_COMPLETION_SCHEMA = z.union([
925
+ z.object({
926
+ reason: z.literal("closed-dependency"),
927
+ status: z.literal("skipped"),
928
+ }),
929
+ z.object({
930
+ failure: automationErrorSchema,
931
+ reason: z.literal("failed-dependency"),
932
+ status: z.literal("skipped"),
933
+ }),
934
+ z.object({
935
+ failure: automationErrorSchema,
936
+ status: z.literal("failed"),
937
+ }),
938
+ z.object({
939
+ output: encodableSchema,
940
+ status: z.literal("succeeded"),
941
+ }),
942
+ ])
943
+
944
+ /** Terminal action result produced inside an automation runtime. */
945
+ export type RuntimeActionCompletion = z.output<typeof ACTION_COMPLETION_SCHEMA>
946
+
947
+ const ACTION_COMPLETION_TRANSPORT_SCHEMA = z.union([
948
+ ACTION_COMPLETION_SCHEMA.options[0],
949
+ ACTION_COMPLETION_SCHEMA.options[1],
950
+ ACTION_COMPLETION_SCHEMA.options[2],
951
+ z.object({
952
+ output: codecEnvelopeSchema,
953
+ status: z.literal("succeeded"),
954
+ }),
955
+ ])
956
+
819
957
  /**
820
958
  * Hashes one coordinator definition exactly as the runtime stores it.
821
959
  *
@@ -857,35 +995,13 @@ export const runtimeContract = {
857
995
  .input(
858
996
  z.object({
859
997
  actionInvocations: ACTION_INVOCATION_SCHEMA.array(),
860
- coordinationOffers: COORDINATION_OFFER_SCHEMA.array(),
998
+ coordinationOffers: COORDINATION_OFFER_TRANSPORT_SCHEMA.array(),
861
999
  settled: z.boolean(),
862
1000
  signalInvocations: SIGNAL_INVOCATION_SCHEMA.array(),
863
1001
  }),
864
1002
  )
865
1003
  .output(z.void()),
866
- completeAction: oc
867
- .input(
868
- z.union([
869
- z.object({
870
- reason: z.literal("closed-dependency"),
871
- status: z.literal("skipped"),
872
- }),
873
- z.object({
874
- failure: automationErrorSchema,
875
- reason: z.literal("failed-dependency"),
876
- status: z.literal("skipped"),
877
- }),
878
- z.object({
879
- failure: automationErrorSchema,
880
- status: z.literal("failed"),
881
- }),
882
- z.object({
883
- output: encodableSchema,
884
- status: z.literal("succeeded"),
885
- }),
886
- ]),
887
- )
888
- .output(z.void()),
1004
+ completeAction: oc.input(ACTION_COMPLETION_TRANSPORT_SCHEMA).output(z.void()),
889
1005
  completeTraceSpan: oc
890
1006
  .input(
891
1007
  z
@@ -906,21 +1022,21 @@ export const runtimeContract = {
906
1022
  .output(z.void()),
907
1023
  generate: oc
908
1024
  .input(RUNTIME_GENERATION_INPUT_SCHEMA)
909
- .output(generationResultSchema),
1025
+ .output(RUNTIME_GENERATION_RESULT_SCHEMA),
910
1026
  startImageGeneration: oc
911
- .input(platformImageGenerationInputSchema)
1027
+ .input(PLATFORM_IMAGE_GENERATION_TRANSPORT_INPUT_SCHEMA)
912
1028
  .output(platformImageGenerationStartSchema),
913
1029
  createCallbackToken: oc
914
1030
  .input(z.object({ endpointKey: z.string().min(1) }))
915
1031
  .output(z.string()),
916
1032
  invokeAutomation: oc
917
- .input(automationInvocationInputSchema)
1033
+ .input(AUTOMATION_INVOCATION_TRANSPORT_INPUT_SCHEMA)
918
1034
  .output(automationInvocationOutputSchema),
919
1035
  load: oc.output(
920
1036
  z.object({
921
1037
  context: RUNTIME_RUN_CONTEXT_SCHEMA,
922
1038
  finalAttempt: z.boolean(),
923
- targetAction: TARGET_ACTION_SCHEMA.optional(),
1039
+ targetAction: TARGET_ACTION_TRANSPORT_SCHEMA.optional(),
924
1040
  }),
925
1041
  ),
926
1042
  loadValues: oc
@@ -930,7 +1046,7 @@ export const runtimeContract = {
930
1046
  slot: true,
931
1047
  }),
932
1048
  )
933
- .output(RUNTIME_VALUE_CONTEXT_SCHEMA),
1049
+ .output(RUNTIME_VALUE_TRANSPORT_CONTEXT_SCHEMA),
934
1050
  resolveAccountInput: oc
935
1051
  .input(
936
1052
  z.strictObject({
@@ -949,7 +1065,7 @@ export const runtimeContract = {
949
1065
  .input(
950
1066
  z.object({
951
1067
  output: z.object({
952
- data: encodableSchema,
1068
+ data: codecEnvelopeSchema,
953
1069
  type: z.string().min(1),
954
1070
  }),
955
1071
  outputIndex: z.number().int().nonnegative(),
@@ -960,7 +1076,7 @@ export const runtimeContract = {
960
1076
  sendLog: oc
961
1077
  .input(
962
1078
  z.object({
963
- fields: OBSERVABILITY_FIELDS_SCHEMA.optional(),
1079
+ fields: codecEnvelopeSchema.optional(),
964
1080
  level: z.enum(["debug", "info", "warn", "error"]),
965
1081
  logIndex: LOG_INDEX_SCHEMA,
966
1082
  message: z.string().min(1).max(AUTOMATION_LOG_MAX_MESSAGE_LENGTH),
@@ -973,7 +1089,7 @@ export const runtimeContract = {
973
1089
  startTraceSpan: oc
974
1090
  .input(
975
1091
  z.object({
976
- attributes: OBSERVABILITY_FIELDS_SCHEMA.optional(),
1092
+ attributes: codecEnvelopeSchema.optional(),
977
1093
  name: z.string().min(1).max(AUTOMATION_TRACE_MAX_NAME_LENGTH),
978
1094
  sensitivity: sensitivityMaskSchema.optional(),
979
1095
  parentSpanIndex: TRACE_SPAN_INDEX_SCHEMA.optional(),