@automate.ax/api-contract 0.58.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { automationExecutionStatusSchema } from "./automation.js";
2
2
  export { AUTOMATION_SDK_VERSION } from "./deployment.js";
3
3
  export { integrationAccountOutputSchema } from "./account.js";
4
- export { AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT, AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX, DEFAULT_GATEWAY_MODEL_ID, automationInvocationInputSchema, automationInvocationOutputSchema, automationInvocationScheduleSchema, generationInputSchema, generationResultSchema, hashSignalCoordinatorConfiguration, runtimeContract, type GenerationInput, type GenerationResult, type RuntimeGenerationInput, } from "./runtime.js";
4
+ export { AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT, AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX, DEFAULT_GATEWAY_MODEL_ID, automationInvocationInputSchema, automationInvocationOutputSchema, automationInvocationScheduleSchema, generationInputSchema, generationResultSchema, hashSignalCoordinatorConfiguration, runtimeContract, type GenerationInput, type GenerationResult, type RuntimeGenerationInput, type RuntimeCoordinationOffer, } from "./runtime.js";
5
5
  export type { GatewayModelId } from "@ai-sdk/gateway";
6
6
  export { createdOrganizationApiKeyOutputSchema, organizationApiKeyOutputSchema, } from "./api-key.js";
7
7
  export { activeSubscriptionOutputSchema, createdInvitationOutputSchema, organizationDetailsOutputSchema, organizationInvitationOutputSchema, organizationMemberOutputSchema, organizationProjectOutputSchema, organizationRoleSchema, organizationSummaryOutputSchema, publicOrganizationOutputSchema, } from "./org.js";
@@ -1234,8 +1234,16 @@ export declare const contract: {
1234
1234
  signalDependencyIds: import("zod").ZodArray<import("zod").ZodString>;
1235
1235
  slot: import("zod").ZodNumber;
1236
1236
  outcomeSeq: import("zod").ZodOptional<import("zod").ZodNumber>;
1237
- selectedIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
1238
1237
  status: import("zod").ZodLiteral<"open">;
1238
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1239
+ actionDependencyIds: import("zod").ZodArray<import("zod").ZodString>;
1240
+ eventDependencyIds: import("zod").ZodArray<import("zod").ZodString>;
1241
+ scopePath: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodNumber>>;
1242
+ signalDependencyIds: import("zod").ZodArray<import("zod").ZodString>;
1243
+ slot: import("zod").ZodNumber;
1244
+ outcomeSeq: import("zod").ZodOptional<import("zod").ZodNumber>;
1245
+ selectedIndex: import("zod").ZodNumber;
1246
+ status: import("zod").ZodLiteral<"succeeded">;
1239
1247
  }, import("zod/v4/core").$strip>]>>>;
1240
1248
  }, import("zod/v4/core").$strip>, import("zod").ZodVoid, Record<never, never>, Record<never, never>>;
1241
1249
  completeAction: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodUnion<readonly [import("zod").ZodObject<{
@@ -1483,7 +1491,6 @@ export declare const contract: {
1483
1491
  contextId: import("zod").ZodString;
1484
1492
  outcomeSeq: import("zod").ZodNumber;
1485
1493
  signalInvocationId: import("zod").ZodString;
1486
- selectedIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
1487
1494
  status: import("zod").ZodLiteral<"open">;
1488
1495
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1489
1496
  actionDependencyIds: import("zod").ZodArray<import("zod").ZodString>;
@@ -1521,6 +1528,7 @@ export declare const contract: {
1521
1528
  contextId: import("zod").ZodString;
1522
1529
  outcomeSeq: import("zod").ZodNumber;
1523
1530
  signalInvocationId: import("zod").ZodString;
1531
+ selectedIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
1524
1532
  status: import("zod").ZodLiteral<"succeeded">;
1525
1533
  }, import("zod/v4/core").$strip>]>>;
1526
1534
  }, import("zod/v4/core").$strip>;
@@ -1597,7 +1605,6 @@ export declare const contract: {
1597
1605
  scopePath: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodNumber>>;
1598
1606
  signalInvocationId: import("zod").ZodString;
1599
1607
  slot: import("zod").ZodNumber;
1600
- selectedIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
1601
1608
  status: import("zod").ZodLiteral<"open">;
1602
1609
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1603
1610
  contextId: import("zod").ZodString;
@@ -1623,7 +1630,8 @@ export declare const contract: {
1623
1630
  scopePath: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodNumber>>;
1624
1631
  signalInvocationId: import("zod").ZodString;
1625
1632
  slot: import("zod").ZodNumber;
1626
- output: import("zod").ZodOptional<import("zod").ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
1633
+ output: import("zod").ZodOptional<import("zod").ZodOptional<import("zod").ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>;
1634
+ selectedIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
1627
1635
  status: import("zod").ZodLiteral<"succeeded">;
1628
1636
  }, import("zod/v4/core").$strip>]>>;
1629
1637
  }, import("zod/v4/core").$strip>;
@@ -1717,7 +1725,6 @@ export declare const contract: {
1717
1725
  scopePath: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodNumber>>;
1718
1726
  signalInvocationId: import("zod").ZodString;
1719
1727
  slot: import("zod").ZodNumber;
1720
- selectedIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
1721
1728
  status: import("zod").ZodLiteral<"open">;
1722
1729
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1723
1730
  contextId: import("zod").ZodString;
@@ -1743,7 +1750,8 @@ export declare const contract: {
1743
1750
  scopePath: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodNumber>>;
1744
1751
  signalInvocationId: import("zod").ZodString;
1745
1752
  slot: import("zod").ZodNumber;
1746
- output: import("zod").ZodOptional<import("zod").ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
1753
+ output: import("zod").ZodOptional<import("zod").ZodOptional<import("zod").ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>;
1754
+ selectedIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
1747
1755
  status: import("zod").ZodLiteral<"succeeded">;
1748
1756
  }, import("zod/v4/core").$strip>]>>;
1749
1757
  }, import("zod/v4/core").$strip>, Record<never, never>, Record<never, never>>;
package/dist/runtime.d.ts CHANGED
@@ -38,6 +38,114 @@ export declare const automationInvocationInputSchema: z.ZodIntersection<z.ZodInt
38
38
  runAt: z.ZodOptional<z.ZodNever>;
39
39
  runIn: z.ZodOptional<z.ZodNever>;
40
40
  }, z.core.$strip>]>>;
41
+ declare const COORDINATION_OFFER_SCHEMA: z.ZodUnion<readonly [z.ZodObject<{
42
+ actionDependencyIds: z.ZodArray<z.ZodString>;
43
+ eventDependencyIds: z.ZodArray<z.ZodString>;
44
+ scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
45
+ signalDependencyIds: z.ZodArray<z.ZodString>;
46
+ slot: z.ZodNumber;
47
+ count: z.ZodNumber;
48
+ key: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
49
+ outcomeSeq: z.ZodNumber;
50
+ policy: z.ZodLiteral<"collect">;
51
+ position: z.ZodOptional<z.ZodNumber>;
52
+ primaryPosition: z.ZodEnum<{
53
+ first: "first";
54
+ last: "last";
55
+ }>;
56
+ ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
57
+ }, z.core.$strip>, z.ZodObject<{
58
+ actionDependencyIds: z.ZodArray<z.ZodString>;
59
+ eventDependencyIds: z.ZodArray<z.ZodString>;
60
+ scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
61
+ signalDependencyIds: z.ZodArray<z.ZodString>;
62
+ slot: z.ZodNumber;
63
+ key: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
64
+ order: z.ZodOptional<z.ZodArray<z.ZodString>>;
65
+ outcomeSeq: z.ZodNumber;
66
+ policy: z.ZodLiteral<"correlate">;
67
+ streamName: z.ZodString;
68
+ streamNames: z.ZodArray<z.ZodString>;
69
+ ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ actionDependencyIds: z.ZodArray<z.ZodString>;
72
+ eventDependencyIds: z.ZodArray<z.ZodString>;
73
+ scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
74
+ signalDependencyIds: z.ZodArray<z.ZodString>;
75
+ slot: z.ZodNumber;
76
+ count: z.ZodNumber;
77
+ outcomeSeq: z.ZodNumber;
78
+ policy: z.ZodLiteral<"fanout">;
79
+ }, z.core.$strip>, z.ZodObject<{
80
+ actionDependencyIds: z.ZodArray<z.ZodString>;
81
+ eventDependencyIds: z.ZodArray<z.ZodString>;
82
+ scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
83
+ signalDependencyIds: z.ZodArray<z.ZodString>;
84
+ slot: z.ZodNumber;
85
+ key: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
86
+ maxBurstDuration: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
87
+ minGap: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
88
+ minQuietPeriod: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
89
+ outcomeSeq: z.ZodNumber;
90
+ policy: z.ZodLiteral<"funnel">;
91
+ primaryPosition: z.ZodEnum<{
92
+ first: "first";
93
+ last: "last";
94
+ }>;
95
+ selection: z.ZodEnum<{
96
+ first: "first";
97
+ last: "last";
98
+ all: "all";
99
+ }>;
100
+ triggerAt: z.ZodEnum<{
101
+ start: "start";
102
+ end: "end";
103
+ both: "both";
104
+ }>;
105
+ ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
106
+ }, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
107
+ actionDependencyIds: z.ZodArray<z.ZodString>;
108
+ eventDependencyIds: z.ZodArray<z.ZodString>;
109
+ scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
110
+ signalDependencyIds: z.ZodArray<z.ZodString>;
111
+ slot: z.ZodNumber;
112
+ inputOrigins: z.ZodArray<z.ZodArray<z.ZodString>>;
113
+ outcomeSeq: z.ZodNumber;
114
+ policy: z.ZodLiteral<"race">;
115
+ scopeOrigins: z.ZodDefault<z.ZodArray<z.ZodString>>;
116
+ selectedIndex: z.ZodNumber;
117
+ status: z.ZodLiteral<"closed">;
118
+ }, z.core.$strip>, z.ZodObject<{
119
+ actionDependencyIds: z.ZodArray<z.ZodString>;
120
+ eventDependencyIds: z.ZodArray<z.ZodString>;
121
+ scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
122
+ signalDependencyIds: z.ZodArray<z.ZodString>;
123
+ slot: z.ZodNumber;
124
+ inputOrigins: z.ZodArray<z.ZodArray<z.ZodString>>;
125
+ outcomeSeq: z.ZodNumber;
126
+ policy: z.ZodLiteral<"race">;
127
+ scopeOrigins: z.ZodDefault<z.ZodArray<z.ZodString>>;
128
+ selectedIndex: z.ZodNumber;
129
+ failure: z.ZodObject<{
130
+ message: z.ZodString;
131
+ name: z.ZodString;
132
+ }, z.core.$strip>;
133
+ status: z.ZodLiteral<"failed">;
134
+ }, z.core.$strip>, z.ZodObject<{
135
+ actionDependencyIds: z.ZodArray<z.ZodString>;
136
+ eventDependencyIds: z.ZodArray<z.ZodString>;
137
+ scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
138
+ signalDependencyIds: z.ZodArray<z.ZodString>;
139
+ slot: z.ZodNumber;
140
+ inputOrigins: z.ZodArray<z.ZodArray<z.ZodString>>;
141
+ outcomeSeq: z.ZodNumber;
142
+ policy: z.ZodLiteral<"race">;
143
+ scopeOrigins: z.ZodDefault<z.ZodArray<z.ZodString>>;
144
+ selectedIndex: z.ZodNumber;
145
+ status: z.ZodLiteral<"succeeded">;
146
+ }, z.core.$strip>]>]>;
147
+ /** One validated durable coordination offer sent by the automation runtime. */
148
+ export type RuntimeCoordinationOffer = z.output<typeof COORDINATION_OFFER_SCHEMA>;
41
149
  /** Shared text-generation options accepted by the built-in generate action. */
42
150
  export declare const generationInputSchema: z.ZodUnion<readonly [z.ZodObject<{
43
151
  frequencyPenalty: z.ZodOptional<z.ZodNumber>;
@@ -366,8 +474,16 @@ export declare const runtimeContract: {
366
474
  signalDependencyIds: z.ZodArray<z.ZodString>;
367
475
  slot: z.ZodNumber;
368
476
  outcomeSeq: z.ZodOptional<z.ZodNumber>;
369
- selectedIndex: z.ZodOptional<z.ZodNumber>;
370
477
  status: z.ZodLiteral<"open">;
478
+ }, z.core.$strip>, z.ZodObject<{
479
+ actionDependencyIds: z.ZodArray<z.ZodString>;
480
+ eventDependencyIds: z.ZodArray<z.ZodString>;
481
+ scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
482
+ signalDependencyIds: z.ZodArray<z.ZodString>;
483
+ slot: z.ZodNumber;
484
+ outcomeSeq: z.ZodOptional<z.ZodNumber>;
485
+ selectedIndex: z.ZodNumber;
486
+ status: z.ZodLiteral<"succeeded">;
371
487
  }, z.core.$strip>]>>>;
372
488
  }, z.core.$strip>, z.ZodVoid, Record<never, never>, Record<never, never>>;
373
489
  completeAction: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodUnion<readonly [z.ZodObject<{
@@ -615,7 +731,6 @@ export declare const runtimeContract: {
615
731
  contextId: z.ZodString;
616
732
  outcomeSeq: z.ZodNumber;
617
733
  signalInvocationId: z.ZodString;
618
- selectedIndex: z.ZodOptional<z.ZodNumber>;
619
734
  status: z.ZodLiteral<"open">;
620
735
  }, z.core.$strip>, z.ZodObject<{
621
736
  actionDependencyIds: z.ZodArray<z.ZodString>;
@@ -653,6 +768,7 @@ export declare const runtimeContract: {
653
768
  contextId: z.ZodString;
654
769
  outcomeSeq: z.ZodNumber;
655
770
  signalInvocationId: z.ZodString;
771
+ selectedIndex: z.ZodOptional<z.ZodNumber>;
656
772
  status: z.ZodLiteral<"succeeded">;
657
773
  }, z.core.$strip>]>>;
658
774
  }, z.core.$strip>;
@@ -729,7 +845,6 @@ export declare const runtimeContract: {
729
845
  scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
730
846
  signalInvocationId: z.ZodString;
731
847
  slot: z.ZodNumber;
732
- selectedIndex: z.ZodOptional<z.ZodNumber>;
733
848
  status: z.ZodLiteral<"open">;
734
849
  }, z.core.$strip>, z.ZodObject<{
735
850
  contextId: z.ZodString;
@@ -755,7 +870,8 @@ export declare const runtimeContract: {
755
870
  scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
756
871
  signalInvocationId: z.ZodString;
757
872
  slot: z.ZodNumber;
758
- output: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
873
+ output: z.ZodOptional<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>;
874
+ selectedIndex: z.ZodOptional<z.ZodNumber>;
759
875
  status: z.ZodLiteral<"succeeded">;
760
876
  }, z.core.$strip>]>>;
761
877
  }, z.core.$strip>;
@@ -849,7 +965,6 @@ export declare const runtimeContract: {
849
965
  scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
850
966
  signalInvocationId: z.ZodString;
851
967
  slot: z.ZodNumber;
852
- selectedIndex: z.ZodOptional<z.ZodNumber>;
853
968
  status: z.ZodLiteral<"open">;
854
969
  }, z.core.$strip>, z.ZodObject<{
855
970
  contextId: z.ZodString;
@@ -875,7 +990,8 @@ export declare const runtimeContract: {
875
990
  scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
876
991
  signalInvocationId: z.ZodString;
877
992
  slot: z.ZodNumber;
878
- output: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
993
+ output: z.ZodOptional<z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>>;
994
+ selectedIndex: z.ZodOptional<z.ZodNumber>;
879
995
  status: z.ZodLiteral<"succeeded">;
880
996
  }, z.core.$strip>]>>;
881
997
  }, z.core.$strip>, Record<never, never>, Record<never, never>>;
package/dist/runtime.js CHANGED
@@ -201,6 +201,14 @@ const FUNNEL_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
201
201
  triggerAt: z.enum(["start", "end", "both"]),
202
202
  ttl: COORDINATION_DURATION_SCHEMA.optional(),
203
203
  }).superRefine((offer, context) => {
204
+ if (offer.maxBurstDuration === undefined &&
205
+ offer.minGap === undefined &&
206
+ offer.minQuietPeriod === undefined) {
207
+ context.addIssue({
208
+ code: "custom",
209
+ message: "A funnel requires at least one timing control.",
210
+ });
211
+ }
204
212
  if (offer.triggerAt === "end" &&
205
213
  offer.minGap !== undefined &&
206
214
  offer.minQuietPeriod === undefined &&
@@ -214,7 +222,7 @@ const FUNNEL_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
214
222
  if (offer.selection !== "all" && offer.selection !== offer.primaryPosition) {
215
223
  context.addIssue({
216
224
  code: "custom",
217
- message: "A selecting funnel must continue from its selected occurrence.",
225
+ message: "A selecting funnel must inherit conflicting values from its selected occurrence.",
218
226
  path: ["primaryPosition"],
219
227
  });
220
228
  }
@@ -227,7 +235,7 @@ const FUNNEL_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
227
235
  }
228
236
  });
229
237
  const RACE_OFFER_BASE_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
230
- inputOrigins: z.string().array().array().min(1),
238
+ inputOrigins: z.string().array().array().min(2),
231
239
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
232
240
  policy: z.literal("race"),
233
241
  scopeOrigins: z.string().array().default([]),
@@ -246,6 +254,13 @@ const RACE_OFFER_SCHEMA = z
246
254
  message: "Race input must identify a declared input.",
247
255
  path: ["selectedIndex"],
248
256
  });
257
+ const COORDINATION_OFFER_SCHEMA = z.union([
258
+ COLLECTION_OFFER_SCHEMA,
259
+ CORRELATION_OFFER_SCHEMA,
260
+ FANOUT_OFFER_SCHEMA,
261
+ FUNNEL_OFFER_SCHEMA,
262
+ RACE_OFFER_SCHEMA,
263
+ ]);
249
264
  const SIGNAL_INVOCATION_SCHEMA = z.union([
250
265
  SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
251
266
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA.optional(),
@@ -257,9 +272,13 @@ const SIGNAL_INVOCATION_SCHEMA = z.union([
257
272
  }),
258
273
  SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
259
274
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA.optional(),
260
- selectedIndex: z.number().int().nonnegative().optional(),
261
275
  status: z.literal("open"),
262
276
  }),
277
+ SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
278
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA.optional(),
279
+ selectedIndex: z.number().int().nonnegative(),
280
+ status: z.literal("succeeded"),
281
+ }),
263
282
  ]);
264
283
  const SIGNAL_BATCH_OUTCOME_BASE_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
265
284
  coordinatorConfigurationHash: z.string().optional(),
@@ -268,16 +287,16 @@ const SIGNAL_BATCH_OUTCOME_BASE_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.e
268
287
  signalInvocationId: z.string(),
269
288
  });
270
289
  const SIGNAL_BATCH_OUTCOME_SCHEMA = z.union([
271
- SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
272
- selectedIndex: z.number().int().nonnegative().optional(),
273
- status: z.literal("open"),
274
- }),
290
+ SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("open") }),
275
291
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
276
292
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
277
293
  failure: SIGNAL_FAILURE_SCHEMA,
278
294
  status: z.literal("failed"),
279
295
  }),
280
- SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("succeeded") }),
296
+ SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
297
+ selectedIndex: z.number().int().nonnegative().optional(),
298
+ status: z.literal("succeeded"),
299
+ }),
281
300
  ]);
282
301
  const ACTION_VALUE_OUTCOME_BASE_SCHEMA = z.object({
283
302
  actionInvocationId: z.string(),
@@ -329,17 +348,15 @@ const COORDINATION_SELECTION_SCHEMA = z.object({
329
348
  signalInvocationId: z.string(),
330
349
  });
331
350
  const SIGNAL_VALUE_OUTCOME_SCHEMA = z.union([
332
- SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
333
- selectedIndex: z.number().int().nonnegative().optional(),
334
- status: z.literal("open"),
335
- }),
351
+ SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("open") }),
336
352
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
337
353
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
338
354
  failure: SIGNAL_FAILURE_SCHEMA,
339
355
  status: z.literal("failed"),
340
356
  }),
341
357
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
342
- output: encodableSchema,
358
+ output: encodableSchema.optional(),
359
+ selectedIndex: z.number().int().nonnegative().optional(),
343
360
  status: z.literal("succeeded"),
344
361
  }),
345
362
  ]);
@@ -512,9 +529,25 @@ const RUNTIME_GENERATION_INPUT_SCHEMA = z.union([
512
529
  * @param primaryPosition - Optional inherited-parent precedence.
513
530
  */
514
531
  export async function hashSignalCoordinatorConfiguration(definition, primaryPosition) {
532
+ const definitionEntries = typeof definition === "object" &&
533
+ definition !== null &&
534
+ !Array.isArray(definition)
535
+ ? Object.entries(definition)
536
+ : undefined;
537
+ const policy = definitionEntries?.find(([key]) => key === "policy")?.[1];
538
+ // Existing coordinators were hashed with `strategy` and implicit primary
539
+ // positions for race and fan-out. Preserve that identity while the runtime
540
+ // uses the clearer policy vocabulary and no longer overloads primary state.
541
+ const persistedDefinition = definitionEntries
542
+ ? Object.fromEntries(definitionEntries.map(([key, value]) => [
543
+ key === "policy" ? "strategy" : key,
544
+ value,
545
+ ]))
546
+ : definition;
515
547
  return await sha256Base64Url(JSON.stringify({
516
- definitionHash: await sha256Base64Url(JSON.stringify(definition)),
517
- primaryPosition: primaryPosition ?? null,
548
+ definitionHash: await sha256Base64Url(JSON.stringify(persistedDefinition)),
549
+ primaryPosition: primaryPosition ??
550
+ (policy === "fanout" || policy === "race" ? "first" : null),
518
551
  }));
519
552
  }
520
553
  /**
@@ -532,16 +565,7 @@ export const runtimeContract = {
532
565
  commit: oc
533
566
  .input(z.object({
534
567
  actionInvocations: ACTION_INVOCATION_SCHEMA.array().default([]),
535
- coordinationOffers: z
536
- .union([
537
- COLLECTION_OFFER_SCHEMA,
538
- CORRELATION_OFFER_SCHEMA,
539
- FANOUT_OFFER_SCHEMA,
540
- FUNNEL_OFFER_SCHEMA,
541
- RACE_OFFER_SCHEMA,
542
- ])
543
- .array()
544
- .default([]),
568
+ coordinationOffers: COORDINATION_OFFER_SCHEMA.array().default([]),
545
569
  settled: z.boolean().default(true),
546
570
  signalInvocations: SIGNAL_INVOCATION_SCHEMA.array().default([]),
547
571
  }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automate.ax/api-contract",
3
- "version": "0.58.0",
3
+ "version": "0.59.0",
4
4
  "description": "Public oRPC contract for the Automate.ax API.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@ai-sdk/gateway": "^4.0.46",
31
- "@automate.ax/codec": "0.58.0",
31
+ "@automate.ax/codec": "0.59.0",
32
32
  "@orpc/contract": "1.15.0",
33
33
  "zod": "^4.3.6"
34
34
  },
package/src/index.ts CHANGED
@@ -26,6 +26,7 @@ export {
26
26
  type GenerationInput,
27
27
  type GenerationResult,
28
28
  type RuntimeGenerationInput,
29
+ type RuntimeCoordinationOffer,
29
30
  } from "./runtime"
30
31
  export type { GatewayModelId } from "@ai-sdk/gateway"
31
32
  export {
package/src/runtime.ts CHANGED
@@ -224,6 +224,16 @@ const FUNNEL_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
224
224
  triggerAt: z.enum(["start", "end", "both"]),
225
225
  ttl: COORDINATION_DURATION_SCHEMA.optional(),
226
226
  }).superRefine((offer, context) => {
227
+ if (
228
+ offer.maxBurstDuration === undefined &&
229
+ offer.minGap === undefined &&
230
+ offer.minQuietPeriod === undefined
231
+ ) {
232
+ context.addIssue({
233
+ code: "custom",
234
+ message: "A funnel requires at least one timing control.",
235
+ })
236
+ }
227
237
  if (
228
238
  offer.triggerAt === "end" &&
229
239
  offer.minGap !== undefined &&
@@ -240,7 +250,8 @@ const FUNNEL_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
240
250
  if (offer.selection !== "all" && offer.selection !== offer.primaryPosition) {
241
251
  context.addIssue({
242
252
  code: "custom",
243
- message: "A selecting funnel must continue from its selected occurrence.",
253
+ message:
254
+ "A selecting funnel must inherit conflicting values from its selected occurrence.",
244
255
  path: ["primaryPosition"],
245
256
  })
246
257
  }
@@ -254,7 +265,7 @@ const FUNNEL_OFFER_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
254
265
  })
255
266
 
256
267
  const RACE_OFFER_BASE_SCHEMA = SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
257
- inputOrigins: z.string().array().array().min(1),
268
+ inputOrigins: z.string().array().array().min(2),
258
269
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
259
270
  policy: z.literal("race"),
260
271
  scopeOrigins: z.string().array().default([]),
@@ -275,6 +286,19 @@ const RACE_OFFER_SCHEMA = z
275
286
  path: ["selectedIndex"],
276
287
  })
277
288
 
289
+ const COORDINATION_OFFER_SCHEMA = z.union([
290
+ COLLECTION_OFFER_SCHEMA,
291
+ CORRELATION_OFFER_SCHEMA,
292
+ FANOUT_OFFER_SCHEMA,
293
+ FUNNEL_OFFER_SCHEMA,
294
+ RACE_OFFER_SCHEMA,
295
+ ])
296
+
297
+ /** One validated durable coordination offer sent by the automation runtime. */
298
+ export type RuntimeCoordinationOffer = z.output<
299
+ typeof COORDINATION_OFFER_SCHEMA
300
+ >
301
+
278
302
  const SIGNAL_INVOCATION_SCHEMA = z.union([
279
303
  SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
280
304
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA.optional(),
@@ -286,9 +310,13 @@ const SIGNAL_INVOCATION_SCHEMA = z.union([
286
310
  }),
287
311
  SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
288
312
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA.optional(),
289
- selectedIndex: z.number().int().nonnegative().optional(),
290
313
  status: z.literal("open"),
291
314
  }),
315
+ SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
316
+ outcomeSeq: OUTCOME_SEQUENCE_SCHEMA.optional(),
317
+ selectedIndex: z.number().int().nonnegative(),
318
+ status: z.literal("succeeded"),
319
+ }),
292
320
  ])
293
321
 
294
322
  const SIGNAL_BATCH_OUTCOME_BASE_SCHEMA =
@@ -300,16 +328,16 @@ const SIGNAL_BATCH_OUTCOME_BASE_SCHEMA =
300
328
  })
301
329
 
302
330
  const SIGNAL_BATCH_OUTCOME_SCHEMA = z.union([
303
- SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
304
- selectedIndex: z.number().int().nonnegative().optional(),
305
- status: z.literal("open"),
306
- }),
331
+ SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("open") }),
307
332
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
308
333
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
309
334
  failure: SIGNAL_FAILURE_SCHEMA,
310
335
  status: z.literal("failed"),
311
336
  }),
312
- SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("succeeded") }),
337
+ SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
338
+ selectedIndex: z.number().int().nonnegative().optional(),
339
+ status: z.literal("succeeded"),
340
+ }),
313
341
  ])
314
342
 
315
343
  const ACTION_VALUE_OUTCOME_BASE_SCHEMA = z.object({
@@ -367,17 +395,15 @@ const COORDINATION_SELECTION_SCHEMA = z.object({
367
395
  })
368
396
 
369
397
  const SIGNAL_VALUE_OUTCOME_SCHEMA = z.union([
370
- SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
371
- selectedIndex: z.number().int().nonnegative().optional(),
372
- status: z.literal("open"),
373
- }),
398
+ SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("open") }),
374
399
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
375
400
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
376
401
  failure: SIGNAL_FAILURE_SCHEMA,
377
402
  status: z.literal("failed"),
378
403
  }),
379
404
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
380
- output: encodableSchema,
405
+ output: encodableSchema.optional(),
406
+ selectedIndex: z.number().int().nonnegative().optional(),
381
407
  status: z.literal("succeeded"),
382
408
  }),
383
409
  ])
@@ -577,10 +603,32 @@ export async function hashSignalCoordinatorConfiguration(
577
603
  definition: unknown,
578
604
  primaryPosition?: "first" | "last",
579
605
  ) {
606
+ const definitionEntries =
607
+ typeof definition === "object" &&
608
+ definition !== null &&
609
+ !Array.isArray(definition)
610
+ ? Object.entries(definition)
611
+ : undefined
612
+ const policy = definitionEntries?.find(([key]) => key === "policy")?.[1]
613
+ // Existing coordinators were hashed with `strategy` and implicit primary
614
+ // positions for race and fan-out. Preserve that identity while the runtime
615
+ // uses the clearer policy vocabulary and no longer overloads primary state.
616
+ const persistedDefinition = definitionEntries
617
+ ? Object.fromEntries(
618
+ definitionEntries.map(([key, value]) => [
619
+ key === "policy" ? "strategy" : key,
620
+ value,
621
+ ]),
622
+ )
623
+ : definition
580
624
  return await sha256Base64Url(
581
625
  JSON.stringify({
582
- definitionHash: await sha256Base64Url(JSON.stringify(definition)),
583
- primaryPosition: primaryPosition ?? null,
626
+ definitionHash: await sha256Base64Url(
627
+ JSON.stringify(persistedDefinition),
628
+ ),
629
+ primaryPosition:
630
+ primaryPosition ??
631
+ (policy === "fanout" || policy === "race" ? "first" : null),
584
632
  }),
585
633
  )
586
634
  }
@@ -608,16 +656,7 @@ export const runtimeContract = {
608
656
  .input(
609
657
  z.object({
610
658
  actionInvocations: ACTION_INVOCATION_SCHEMA.array().default([]),
611
- coordinationOffers: z
612
- .union([
613
- COLLECTION_OFFER_SCHEMA,
614
- CORRELATION_OFFER_SCHEMA,
615
- FANOUT_OFFER_SCHEMA,
616
- FUNNEL_OFFER_SCHEMA,
617
- RACE_OFFER_SCHEMA,
618
- ])
619
- .array()
620
- .default([]),
659
+ coordinationOffers: COORDINATION_OFFER_SCHEMA.array().default([]),
621
660
  settled: z.boolean().default(true),
622
661
  signalInvocations: SIGNAL_INVOCATION_SCHEMA.array().default([]),
623
662
  }),