@automate.ax/api-contract 0.71.0 → 0.73.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.
@@ -17,18 +17,12 @@ export declare const automationContract: {
17
17
  }>;
18
18
  completedAt: z.ZodNullable<z.ZodDate>;
19
19
  createdAt: z.ZodDate;
20
- failure: z.ZodNullable<z.ZodObject<{
21
- message: z.ZodString;
22
- name: z.ZodString;
23
- }, z.core.$strip>>;
20
+ failure: z.ZodNullable<z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>>;
24
21
  actions: z.ZodArray<z.ZodObject<{
25
22
  completedAt: z.ZodNullable<z.ZodDate>;
26
23
  createdAt: z.ZodDate;
27
24
  description: z.ZodNullable<z.ZodString>;
28
- failure: z.ZodNullable<z.ZodObject<{
29
- message: z.ZodString;
30
- name: z.ZodString;
31
- }, z.core.$strip>>;
25
+ failure: z.ZodNullable<z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>>;
32
26
  hasOutput: z.ZodBoolean;
33
27
  id: z.ZodString;
34
28
  name: z.ZodString;
@@ -63,10 +57,7 @@ export declare const automationContract: {
63
57
  completedAt: z.ZodNullable<z.ZodDate>;
64
58
  createdAt: z.ZodDate;
65
59
  eventTypes: z.ZodArray<z.ZodString>;
66
- failure: z.ZodNullable<z.ZodObject<{
67
- message: z.ZodString;
68
- name: z.ZodString;
69
- }, z.core.$strip>>;
60
+ failure: z.ZodNullable<z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>>;
70
61
  id: z.ZodString;
71
62
  status: z.ZodEnum<{
72
63
  failed: "failed";
@@ -1,20 +1,17 @@
1
1
  import { encodableSchema } from "@automate.ax/codec";
2
2
  import { oc } from "@orpc/contract";
3
3
  import { z } from "zod";
4
+ import { automationErrorSchema } from "./errors.js";
4
5
  export const automationExecutionStatusSchema = z.enum([
5
6
  "running",
6
7
  "completed",
7
8
  "failed",
8
9
  ]);
9
- const EXECUTION_FAILURE_SCHEMA = z.object({
10
- message: z.string(),
11
- name: z.string(),
12
- });
13
10
  const EXECUTION_SUMMARY_SCHEMA = z.object({
14
11
  completedAt: z.date().nullable(),
15
12
  createdAt: z.date(),
16
13
  eventTypes: z.string().array(),
17
- failure: EXECUTION_FAILURE_SCHEMA.nullable(),
14
+ failure: automationErrorSchema.nullable(),
18
15
  id: z.string(),
19
16
  status: automationExecutionStatusSchema,
20
17
  });
@@ -30,7 +27,7 @@ export const automationContract = {
30
27
  completedAt: z.date().nullable(),
31
28
  createdAt: z.date(),
32
29
  description: z.string().nullable(),
33
- failure: EXECUTION_FAILURE_SCHEMA.nullable(),
30
+ failure: automationErrorSchema.nullable(),
34
31
  hasOutput: z.boolean(),
35
32
  id: z.string(),
36
33
  name: z.string(),
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ export declare const AUTOMATION_ERROR_CAUSE_DEPTH = 3;
3
+ export interface AutomationErrorValue {
4
+ /** Normalized and depth-limited underlying failure. */
5
+ cause?: AutomationErrorValue;
6
+ /** Stable machine-readable classification. */
7
+ code: string;
8
+ /** Structured author-safe diagnostics such as validation issues. */
9
+ details?: z.output<ReturnType<typeof z.json>>;
10
+ /** Human-readable summary safe to show automation authors. */
11
+ message: string;
12
+ /** Original JavaScript or provider error class when available. */
13
+ name?: string;
14
+ }
15
+ /** Author-safe normalized automation lifecycle error. */
16
+ export declare const automationErrorSchema: z.ZodType<AutomationErrorValue, AutomationErrorValue, z.core.$ZodTypeInternals<AutomationErrorValue, AutomationErrorValue>>;
package/dist/errors.js ADDED
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ const AUTOMATION_ERROR_BASE_SCHEMA = z.object({
3
+ code: z.string().min(1),
4
+ details: z.json().optional(),
5
+ message: z.string(),
6
+ name: z.string().optional(),
7
+ });
8
+ export const AUTOMATION_ERROR_CAUSE_DEPTH = 3;
9
+ /** Author-safe normalized automation lifecycle error. */
10
+ export const automationErrorSchema = createAutomationErrorSchema(AUTOMATION_ERROR_CAUSE_DEPTH);
11
+ /**
12
+ * Builds the finite public causal chain accepted at runtime boundaries.
13
+ *
14
+ * @param remainingDepth - Additional nested causes accepted by this level.
15
+ */
16
+ function createAutomationErrorSchema(remainingDepth) {
17
+ return AUTOMATION_ERROR_BASE_SCHEMA.extend({
18
+ cause: remainingDepth > 0
19
+ ? createAutomationErrorSchema(remainingDepth - 1).optional()
20
+ : z.never().optional(),
21
+ });
22
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { automationExecutionStatusSchema } from "./automation.js";
2
2
  export { AUTOMATION_SDK_VERSION } from "./deployment.js";
3
+ export { AUTOMATION_ERROR_CAUSE_DEPTH, automationErrorSchema, type AutomationErrorValue, } from "./errors.js";
3
4
  export { integrationAccountOutputSchema } from "./account.js";
4
5
  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
6
  export type { GatewayModelId } from "@ai-sdk/gateway";
@@ -353,18 +354,12 @@ export declare const firstPartyContract: {
353
354
  }>;
354
355
  completedAt: import("zod").ZodNullable<import("zod").ZodDate>;
355
356
  createdAt: import("zod").ZodDate;
356
- failure: import("zod").ZodNullable<import("zod").ZodObject<{
357
- message: import("zod").ZodString;
358
- name: import("zod").ZodString;
359
- }, import("zod/v4/core").$strip>>;
357
+ failure: import("zod").ZodNullable<import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>>;
360
358
  actions: import("zod").ZodArray<import("zod").ZodObject<{
361
359
  completedAt: import("zod").ZodNullable<import("zod").ZodDate>;
362
360
  createdAt: import("zod").ZodDate;
363
361
  description: import("zod").ZodNullable<import("zod").ZodString>;
364
- failure: import("zod").ZodNullable<import("zod").ZodObject<{
365
- message: import("zod").ZodString;
366
- name: import("zod").ZodString;
367
- }, import("zod/v4/core").$strip>>;
362
+ failure: import("zod").ZodNullable<import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>>;
368
363
  hasOutput: import("zod").ZodBoolean;
369
364
  id: import("zod").ZodString;
370
365
  name: import("zod").ZodString;
@@ -399,10 +394,7 @@ export declare const firstPartyContract: {
399
394
  completedAt: import("zod").ZodNullable<import("zod").ZodDate>;
400
395
  createdAt: import("zod").ZodDate;
401
396
  eventTypes: import("zod").ZodArray<import("zod").ZodString>;
402
- failure: import("zod").ZodNullable<import("zod").ZodObject<{
403
- message: import("zod").ZodString;
404
- name: import("zod").ZodString;
405
- }, import("zod/v4/core").$strip>>;
397
+ failure: import("zod").ZodNullable<import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>>;
406
398
  id: import("zod").ZodString;
407
399
  status: import("zod").ZodEnum<{
408
400
  failed: "failed";
@@ -1105,10 +1097,7 @@ export declare const contract: {
1105
1097
  scopePath: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodNumber>>;
1106
1098
  signalDependencyIds: import("zod").ZodArray<import("zod").ZodString>;
1107
1099
  slot: import("zod").ZodNumber;
1108
- failure: import("zod").ZodObject<{
1109
- message: import("zod").ZodString;
1110
- name: import("zod").ZodString;
1111
- }, import("zod/v4/core").$strip>;
1100
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1112
1101
  reason: import("zod").ZodLiteral<"failed-dependency">;
1113
1102
  status: import("zod").ZodLiteral<"skipped">;
1114
1103
  }, import("zod/v4/core").$strip>]>>>;
@@ -1201,10 +1190,7 @@ export declare const contract: {
1201
1190
  policy: import("zod").ZodLiteral<"race">;
1202
1191
  scopeOrigins: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
1203
1192
  selectedIndex: import("zod").ZodNumber;
1204
- failure: import("zod").ZodObject<{
1205
- message: import("zod").ZodString;
1206
- name: import("zod").ZodString;
1207
- }, import("zod/v4/core").$strip>;
1193
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1208
1194
  status: import("zod").ZodLiteral<"failed">;
1209
1195
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1210
1196
  actionDependencyIds: import("zod").ZodArray<import("zod").ZodString>;
@@ -1234,10 +1220,7 @@ export declare const contract: {
1234
1220
  scopePath: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodNumber>>;
1235
1221
  signalDependencyIds: import("zod").ZodArray<import("zod").ZodString>;
1236
1222
  slot: import("zod").ZodNumber;
1237
- failure: import("zod").ZodObject<{
1238
- message: import("zod").ZodString;
1239
- name: import("zod").ZodString;
1240
- }, import("zod/v4/core").$strip>;
1223
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1241
1224
  status: import("zod").ZodLiteral<"failed">;
1242
1225
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1243
1226
  actionDependencyIds: import("zod").ZodArray<import("zod").ZodString>;
@@ -1262,17 +1245,11 @@ export declare const contract: {
1262
1245
  reason: import("zod").ZodLiteral<"closed-dependency">;
1263
1246
  status: import("zod").ZodLiteral<"skipped">;
1264
1247
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1265
- failure: import("zod").ZodObject<{
1266
- message: import("zod").ZodString;
1267
- name: import("zod").ZodString;
1268
- }, import("zod/v4/core").$strip>;
1248
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1269
1249
  reason: import("zod").ZodLiteral<"failed-dependency">;
1270
1250
  status: import("zod").ZodLiteral<"skipped">;
1271
1251
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1272
- failure: import("zod").ZodObject<{
1273
- message: import("zod").ZodString;
1274
- name: import("zod").ZodString;
1275
- }, import("zod/v4/core").$strip>;
1252
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1276
1253
  status: import("zod").ZodLiteral<"failed">;
1277
1254
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1278
1255
  output: import("zod").ZodOptional<import("zod").ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
@@ -1427,10 +1404,7 @@ export declare const contract: {
1427
1404
  slot: import("zod").ZodNumber;
1428
1405
  actionInvocationId: import("zod").ZodString;
1429
1406
  contextId: import("zod").ZodString;
1430
- failure: import("zod").ZodObject<{
1431
- message: import("zod").ZodString;
1432
- name: import("zod").ZodString;
1433
- }, import("zod/v4/core").$strip>;
1407
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1434
1408
  outcomeSeq: import("zod").ZodNumber;
1435
1409
  status: import("zod").ZodLiteral<"failed">;
1436
1410
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
@@ -1458,10 +1432,7 @@ export declare const contract: {
1458
1432
  slot: import("zod").ZodNumber;
1459
1433
  actionInvocationId: import("zod").ZodString;
1460
1434
  contextId: import("zod").ZodString;
1461
- failure: import("zod").ZodObject<{
1462
- message: import("zod").ZodString;
1463
- name: import("zod").ZodString;
1464
- }, import("zod/v4/core").$strip>;
1435
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1465
1436
  outcomeSeq: import("zod").ZodNumber;
1466
1437
  reason: import("zod").ZodLiteral<"failed-dependency">;
1467
1438
  status: import("zod").ZodLiteral<"skipped">;
@@ -1525,10 +1496,7 @@ export declare const contract: {
1525
1496
  contextId: import("zod").ZodString;
1526
1497
  outcomeSeq: import("zod").ZodNumber;
1527
1498
  signalInvocationId: import("zod").ZodString;
1528
- failure: import("zod").ZodObject<{
1529
- message: import("zod").ZodString;
1530
- name: import("zod").ZodString;
1531
- }, import("zod/v4/core").$strip>;
1499
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1532
1500
  status: import("zod").ZodLiteral<"failed">;
1533
1501
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1534
1502
  actionDependencyIds: import("zod").ZodArray<import("zod").ZodString>;
@@ -1555,10 +1523,7 @@ export declare const contract: {
1555
1523
  timestamp: import("zod").ZodDate;
1556
1524
  outcomeSeq: import("zod").ZodNumber;
1557
1525
  status: import("zod").ZodLiteral<"failed">;
1558
- failure: import("zod").ZodObject<{
1559
- message: import("zod").ZodString;
1560
- name: import("zod").ZodString;
1561
- }, import("zod/v4/core").$strip>;
1526
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1562
1527
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1563
1528
  actionInvocationId: import("zod").ZodString;
1564
1529
  contextId: import("zod").ZodString;
@@ -1575,10 +1540,7 @@ export declare const contract: {
1575
1540
  scopePath: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodNumber>>;
1576
1541
  slot: import("zod").ZodNumber;
1577
1542
  timestamp: import("zod").ZodDate;
1578
- failure: import("zod").ZodObject<{
1579
- message: import("zod").ZodString;
1580
- name: import("zod").ZodString;
1581
- }, import("zod/v4/core").$strip>;
1543
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1582
1544
  reason: import("zod").ZodLiteral<"failed-dependency">;
1583
1545
  status: import("zod").ZodLiteral<"skipped">;
1584
1546
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
@@ -1639,10 +1601,7 @@ export declare const contract: {
1639
1601
  signalInvocationId: import("zod").ZodString;
1640
1602
  slot: import("zod").ZodNumber;
1641
1603
  timestamp: import("zod").ZodDate;
1642
- failure: import("zod").ZodObject<{
1643
- message: import("zod").ZodString;
1644
- name: import("zod").ZodString;
1645
- }, import("zod/v4/core").$strip>;
1604
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1646
1605
  status: import("zod").ZodLiteral<"failed">;
1647
1606
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1648
1607
  contextId: import("zod").ZodString;
@@ -1684,10 +1643,7 @@ export declare const contract: {
1684
1643
  timestamp: import("zod").ZodDate;
1685
1644
  outcomeSeq: import("zod").ZodNumber;
1686
1645
  status: import("zod").ZodLiteral<"failed">;
1687
- failure: import("zod").ZodObject<{
1688
- message: import("zod").ZodString;
1689
- name: import("zod").ZodString;
1690
- }, import("zod/v4/core").$strip>;
1646
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1691
1647
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1692
1648
  actionInvocationId: import("zod").ZodString;
1693
1649
  contextId: import("zod").ZodString;
@@ -1704,10 +1660,7 @@ export declare const contract: {
1704
1660
  scopePath: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodNumber>>;
1705
1661
  slot: import("zod").ZodNumber;
1706
1662
  timestamp: import("zod").ZodDate;
1707
- failure: import("zod").ZodObject<{
1708
- message: import("zod").ZodString;
1709
- name: import("zod").ZodString;
1710
- }, import("zod/v4/core").$strip>;
1663
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1711
1664
  reason: import("zod").ZodLiteral<"failed-dependency">;
1712
1665
  status: import("zod").ZodLiteral<"skipped">;
1713
1666
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
@@ -1768,10 +1721,7 @@ export declare const contract: {
1768
1721
  signalInvocationId: import("zod").ZodString;
1769
1722
  slot: import("zod").ZodNumber;
1770
1723
  timestamp: import("zod").ZodDate;
1771
- failure: import("zod").ZodObject<{
1772
- message: import("zod").ZodString;
1773
- name: import("zod").ZodString;
1774
- }, import("zod/v4/core").$strip>;
1724
+ failure: import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1775
1725
  status: import("zod").ZodLiteral<"failed">;
1776
1726
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
1777
1727
  contextId: import("zod").ZodString;
@@ -1884,18 +1834,12 @@ export declare const contract: {
1884
1834
  }>;
1885
1835
  completedAt: import("zod").ZodNullable<import("zod").ZodDate>;
1886
1836
  createdAt: import("zod").ZodDate;
1887
- failure: import("zod").ZodNullable<import("zod").ZodObject<{
1888
- message: import("zod").ZodString;
1889
- name: import("zod").ZodString;
1890
- }, import("zod/v4/core").$strip>>;
1837
+ failure: import("zod").ZodNullable<import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>>;
1891
1838
  actions: import("zod").ZodArray<import("zod").ZodObject<{
1892
1839
  completedAt: import("zod").ZodNullable<import("zod").ZodDate>;
1893
1840
  createdAt: import("zod").ZodDate;
1894
1841
  description: import("zod").ZodNullable<import("zod").ZodString>;
1895
- failure: import("zod").ZodNullable<import("zod").ZodObject<{
1896
- message: import("zod").ZodString;
1897
- name: import("zod").ZodString;
1898
- }, import("zod/v4/core").$strip>>;
1842
+ failure: import("zod").ZodNullable<import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>>;
1899
1843
  hasOutput: import("zod").ZodBoolean;
1900
1844
  id: import("zod").ZodString;
1901
1845
  name: import("zod").ZodString;
@@ -1930,10 +1874,7 @@ export declare const contract: {
1930
1874
  completedAt: import("zod").ZodNullable<import("zod").ZodDate>;
1931
1875
  createdAt: import("zod").ZodDate;
1932
1876
  eventTypes: import("zod").ZodArray<import("zod").ZodString>;
1933
- failure: import("zod").ZodNullable<import("zod").ZodObject<{
1934
- message: import("zod").ZodString;
1935
- name: import("zod").ZodString;
1936
- }, import("zod/v4/core").$strip>>;
1877
+ failure: import("zod").ZodNullable<import("zod").ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, import("zod/v4/core").$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>>;
1937
1878
  id: import("zod").ZodString;
1938
1879
  status: import("zod").ZodEnum<{
1939
1880
  failed: "failed";
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ import { projectContract } from "./project.js";
10
10
  import { runtimeContract } from "./runtime.js";
11
11
  export { automationExecutionStatusSchema } from "./automation.js";
12
12
  export { AUTOMATION_SDK_VERSION } from "./deployment.js";
13
+ export { AUTOMATION_ERROR_CAUSE_DEPTH, automationErrorSchema, } from "./errors.js";
13
14
  export { integrationAccountOutputSchema } from "./account.js";
14
15
  export { AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT, AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX, DEFAULT_GATEWAY_MODEL_ID, automationInvocationInputSchema, automationInvocationOutputSchema, automationInvocationScheduleSchema, generationInputSchema, generationResultSchema, hashSignalCoordinatorConfiguration, runtimeContract, } from "./runtime.js";
15
16
  export { createdOrganizationApiKeyOutputSchema, organizationApiKeyOutputSchema, } from "./api-key.js";
package/dist/runtime.d.ts CHANGED
@@ -127,10 +127,7 @@ declare const COORDINATION_OFFER_SCHEMA: z.ZodUnion<readonly [z.ZodObject<{
127
127
  policy: z.ZodLiteral<"race">;
128
128
  scopeOrigins: z.ZodDefault<z.ZodArray<z.ZodString>>;
129
129
  selectedIndex: z.ZodNumber;
130
- failure: z.ZodObject<{
131
- message: z.ZodString;
132
- name: z.ZodString;
133
- }, z.core.$strip>;
130
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
134
131
  status: z.ZodLiteral<"failed">;
135
132
  }, z.core.$strip>, z.ZodObject<{
136
133
  actionDependencyIds: z.ZodArray<z.ZodString>;
@@ -335,10 +332,7 @@ export declare const runtimeContract: {
335
332
  scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
336
333
  signalDependencyIds: z.ZodArray<z.ZodString>;
337
334
  slot: z.ZodNumber;
338
- failure: z.ZodObject<{
339
- message: z.ZodString;
340
- name: z.ZodString;
341
- }, z.core.$strip>;
335
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
342
336
  reason: z.ZodLiteral<"failed-dependency">;
343
337
  status: z.ZodLiteral<"skipped">;
344
338
  }, z.core.$strip>]>>>;
@@ -431,10 +425,7 @@ export declare const runtimeContract: {
431
425
  policy: z.ZodLiteral<"race">;
432
426
  scopeOrigins: z.ZodDefault<z.ZodArray<z.ZodString>>;
433
427
  selectedIndex: z.ZodNumber;
434
- failure: z.ZodObject<{
435
- message: z.ZodString;
436
- name: z.ZodString;
437
- }, z.core.$strip>;
428
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
438
429
  status: z.ZodLiteral<"failed">;
439
430
  }, z.core.$strip>, z.ZodObject<{
440
431
  actionDependencyIds: z.ZodArray<z.ZodString>;
@@ -464,10 +455,7 @@ export declare const runtimeContract: {
464
455
  scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
465
456
  signalDependencyIds: z.ZodArray<z.ZodString>;
466
457
  slot: z.ZodNumber;
467
- failure: z.ZodObject<{
468
- message: z.ZodString;
469
- name: z.ZodString;
470
- }, z.core.$strip>;
458
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
471
459
  status: z.ZodLiteral<"failed">;
472
460
  }, z.core.$strip>, z.ZodObject<{
473
461
  actionDependencyIds: z.ZodArray<z.ZodString>;
@@ -492,17 +480,11 @@ export declare const runtimeContract: {
492
480
  reason: z.ZodLiteral<"closed-dependency">;
493
481
  status: z.ZodLiteral<"skipped">;
494
482
  }, z.core.$strip>, z.ZodObject<{
495
- failure: z.ZodObject<{
496
- message: z.ZodString;
497
- name: z.ZodString;
498
- }, z.core.$strip>;
483
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
499
484
  reason: z.ZodLiteral<"failed-dependency">;
500
485
  status: z.ZodLiteral<"skipped">;
501
486
  }, z.core.$strip>, z.ZodObject<{
502
- failure: z.ZodObject<{
503
- message: z.ZodString;
504
- name: z.ZodString;
505
- }, z.core.$strip>;
487
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
506
488
  status: z.ZodLiteral<"failed">;
507
489
  }, z.core.$strip>, z.ZodObject<{
508
490
  output: z.ZodOptional<z.ZodCustom<import("@automate.ax/codec").Encodable, import("@automate.ax/codec").Encodable>>;
@@ -657,10 +639,7 @@ export declare const runtimeContract: {
657
639
  slot: z.ZodNumber;
658
640
  actionInvocationId: z.ZodString;
659
641
  contextId: z.ZodString;
660
- failure: z.ZodObject<{
661
- message: z.ZodString;
662
- name: z.ZodString;
663
- }, z.core.$strip>;
642
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
664
643
  outcomeSeq: z.ZodNumber;
665
644
  status: z.ZodLiteral<"failed">;
666
645
  }, z.core.$strip>, z.ZodObject<{
@@ -688,10 +667,7 @@ export declare const runtimeContract: {
688
667
  slot: z.ZodNumber;
689
668
  actionInvocationId: z.ZodString;
690
669
  contextId: z.ZodString;
691
- failure: z.ZodObject<{
692
- message: z.ZodString;
693
- name: z.ZodString;
694
- }, z.core.$strip>;
670
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
695
671
  outcomeSeq: z.ZodNumber;
696
672
  reason: z.ZodLiteral<"failed-dependency">;
697
673
  status: z.ZodLiteral<"skipped">;
@@ -755,10 +731,7 @@ export declare const runtimeContract: {
755
731
  contextId: z.ZodString;
756
732
  outcomeSeq: z.ZodNumber;
757
733
  signalInvocationId: z.ZodString;
758
- failure: z.ZodObject<{
759
- message: z.ZodString;
760
- name: z.ZodString;
761
- }, z.core.$strip>;
734
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
762
735
  status: z.ZodLiteral<"failed">;
763
736
  }, z.core.$strip>, z.ZodObject<{
764
737
  actionDependencyIds: z.ZodArray<z.ZodString>;
@@ -785,10 +758,7 @@ export declare const runtimeContract: {
785
758
  timestamp: z.ZodDate;
786
759
  outcomeSeq: z.ZodNumber;
787
760
  status: z.ZodLiteral<"failed">;
788
- failure: z.ZodObject<{
789
- message: z.ZodString;
790
- name: z.ZodString;
791
- }, z.core.$strip>;
761
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
792
762
  }, z.core.$strip>, z.ZodObject<{
793
763
  actionInvocationId: z.ZodString;
794
764
  contextId: z.ZodString;
@@ -805,10 +775,7 @@ export declare const runtimeContract: {
805
775
  scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
806
776
  slot: z.ZodNumber;
807
777
  timestamp: z.ZodDate;
808
- failure: z.ZodObject<{
809
- message: z.ZodString;
810
- name: z.ZodString;
811
- }, z.core.$strip>;
778
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
812
779
  reason: z.ZodLiteral<"failed-dependency">;
813
780
  status: z.ZodLiteral<"skipped">;
814
781
  }, z.core.$strip>, z.ZodObject<{
@@ -869,10 +836,7 @@ export declare const runtimeContract: {
869
836
  signalInvocationId: z.ZodString;
870
837
  slot: z.ZodNumber;
871
838
  timestamp: z.ZodDate;
872
- failure: z.ZodObject<{
873
- message: z.ZodString;
874
- name: z.ZodString;
875
- }, z.core.$strip>;
839
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
876
840
  status: z.ZodLiteral<"failed">;
877
841
  }, z.core.$strip>, z.ZodObject<{
878
842
  contextId: z.ZodString;
@@ -914,10 +878,7 @@ export declare const runtimeContract: {
914
878
  timestamp: z.ZodDate;
915
879
  outcomeSeq: z.ZodNumber;
916
880
  status: z.ZodLiteral<"failed">;
917
- failure: z.ZodObject<{
918
- message: z.ZodString;
919
- name: z.ZodString;
920
- }, z.core.$strip>;
881
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
921
882
  }, z.core.$strip>, z.ZodObject<{
922
883
  actionInvocationId: z.ZodString;
923
884
  contextId: z.ZodString;
@@ -934,10 +895,7 @@ export declare const runtimeContract: {
934
895
  scopePath: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
935
896
  slot: z.ZodNumber;
936
897
  timestamp: z.ZodDate;
937
- failure: z.ZodObject<{
938
- message: z.ZodString;
939
- name: z.ZodString;
940
- }, z.core.$strip>;
898
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
941
899
  reason: z.ZodLiteral<"failed-dependency">;
942
900
  status: z.ZodLiteral<"skipped">;
943
901
  }, z.core.$strip>, z.ZodObject<{
@@ -998,10 +956,7 @@ export declare const runtimeContract: {
998
956
  signalInvocationId: z.ZodString;
999
957
  slot: z.ZodNumber;
1000
958
  timestamp: z.ZodDate;
1001
- failure: z.ZodObject<{
1002
- message: z.ZodString;
1003
- name: z.ZodString;
1004
- }, z.core.$strip>;
959
+ failure: z.ZodType<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue, z.core.$ZodTypeInternals<import("./errors").AutomationErrorValue, import("./errors").AutomationErrorValue>>;
1005
960
  status: z.ZodLiteral<"failed">;
1006
961
  }, z.core.$strip>, z.ZodObject<{
1007
962
  contextId: z.ZodString;
package/dist/runtime.js CHANGED
@@ -2,14 +2,11 @@ import { encodableSchema } from "@automate.ax/codec";
2
2
  import { oc } from "@orpc/contract";
3
3
  import stableStringify from "fast-json-stable-stringify";
4
4
  import { z } from "zod";
5
+ import { automationErrorSchema } from "./errors.js";
5
6
  /** Default model used by the platform Vercel AI Gateway account. */
6
7
  export const DEFAULT_GATEWAY_MODEL_ID = "openai/gpt-4.1-nano";
7
8
  export const AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT = "default";
8
9
  export const AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX = "__$";
9
- const SIGNAL_FAILURE_SCHEMA = z.object({
10
- message: z.string(),
11
- name: z.string(),
12
- });
13
10
  const OUTCOME_SEQUENCE_SCHEMA = z.number().int().positive();
14
11
  const HOOK_SCOPE_PATH_SCHEMA = z
15
12
  .number()
@@ -98,7 +95,7 @@ const ACTION_INVOCATION_SCHEMA = z.union([
98
95
  status: z.literal("skipped"),
99
96
  }),
100
97
  ACTION_INVOCATION_BASE_SCHEMA.extend({
101
- failure: SIGNAL_FAILURE_SCHEMA,
98
+ failure: automationErrorSchema,
102
99
  reason: z.literal("failed-dependency"),
103
100
  status: z.literal("skipped"),
104
101
  }),
@@ -110,7 +107,7 @@ const ACTION_RUN_INVOCATION_BASE_SCHEMA = ACTION_INVOCATION_BASE_SCHEMA.extend({
110
107
  const ACTION_RUN_INVOCATION_SCHEMA = z.union([
111
108
  ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({ status: z.literal("pending") }),
112
109
  ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({
113
- failure: SIGNAL_FAILURE_SCHEMA,
110
+ failure: automationErrorSchema,
114
111
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
115
112
  status: z.literal("failed"),
116
113
  }),
@@ -120,7 +117,7 @@ const ACTION_RUN_INVOCATION_SCHEMA = z.union([
120
117
  status: z.literal("skipped"),
121
118
  }),
122
119
  ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({
123
- failure: SIGNAL_FAILURE_SCHEMA,
120
+ failure: automationErrorSchema,
124
121
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
125
122
  reason: z.literal("failed-dependency"),
126
123
  status: z.literal("skipped"),
@@ -246,7 +243,7 @@ const RACE_OFFER_SCHEMA = z
246
243
  .union([
247
244
  RACE_OFFER_BASE_SCHEMA.extend({ status: z.literal("closed") }),
248
245
  RACE_OFFER_BASE_SCHEMA.extend({
249
- failure: SIGNAL_FAILURE_SCHEMA,
246
+ failure: automationErrorSchema,
250
247
  status: z.literal("failed"),
251
248
  }),
252
249
  RACE_OFFER_BASE_SCHEMA.extend({ status: z.literal("succeeded") }),
@@ -268,7 +265,7 @@ const SIGNAL_INVOCATION_SCHEMA = z.union([
268
265
  status: z.literal("closed"),
269
266
  }),
270
267
  SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
271
- failure: SIGNAL_FAILURE_SCHEMA,
268
+ failure: automationErrorSchema,
272
269
  status: z.literal("failed"),
273
270
  }),
274
271
  SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
@@ -291,7 +288,7 @@ const SIGNAL_BATCH_OUTCOME_SCHEMA = z.union([
291
288
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("open") }),
292
289
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
293
290
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
294
- failure: SIGNAL_FAILURE_SCHEMA,
291
+ failure: automationErrorSchema,
295
292
  status: z.literal("failed"),
296
293
  }),
297
294
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
@@ -311,14 +308,14 @@ const ACTION_VALUE_OUTCOME_SCHEMA = z.union([
311
308
  ACTION_VALUE_OUTCOME_BASE_SCHEMA.extend({
312
309
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
313
310
  status: z.literal("failed"),
314
- failure: SIGNAL_FAILURE_SCHEMA,
311
+ failure: automationErrorSchema,
315
312
  }),
316
313
  ACTION_VALUE_OUTCOME_BASE_SCHEMA.extend({
317
314
  reason: z.literal("closed-dependency"),
318
315
  status: z.literal("skipped"),
319
316
  }),
320
317
  ACTION_VALUE_OUTCOME_BASE_SCHEMA.extend({
321
- failure: SIGNAL_FAILURE_SCHEMA,
318
+ failure: automationErrorSchema,
322
319
  reason: z.literal("failed-dependency"),
323
320
  status: z.literal("skipped"),
324
321
  }),
@@ -354,7 +351,7 @@ const SIGNAL_VALUE_OUTCOME_SCHEMA = z.union([
354
351
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("open") }),
355
352
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
356
353
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
357
- failure: SIGNAL_FAILURE_SCHEMA,
354
+ failure: automationErrorSchema,
358
355
  status: z.literal("failed"),
359
356
  }),
360
357
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
@@ -581,12 +578,12 @@ export const runtimeContract = {
581
578
  status: z.literal("skipped"),
582
579
  }),
583
580
  z.object({
584
- failure: SIGNAL_FAILURE_SCHEMA,
581
+ failure: automationErrorSchema,
585
582
  reason: z.literal("failed-dependency"),
586
583
  status: z.literal("skipped"),
587
584
  }),
588
585
  z.object({
589
- failure: SIGNAL_FAILURE_SCHEMA,
586
+ failure: automationErrorSchema,
590
587
  status: z.literal("failed"),
591
588
  }),
592
589
  z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automate.ax/api-contract",
3
- "version": "0.71.0",
3
+ "version": "0.73.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.71.0",
31
+ "@automate.ax/codec": "0.73.0",
32
32
  "@orpc/contract": "1.15.0",
33
33
  "fast-json-stable-stringify": "^2.1.0",
34
34
  "zod": "^4.3.6"
package/src/automation.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { encodableSchema } from "@automate.ax/codec"
2
2
  import { oc } from "@orpc/contract"
3
3
  import { z } from "zod"
4
+ import { automationErrorSchema } from "./errors"
4
5
 
5
6
  export const automationExecutionStatusSchema = z.enum([
6
7
  "running",
@@ -8,16 +9,11 @@ export const automationExecutionStatusSchema = z.enum([
8
9
  "failed",
9
10
  ])
10
11
 
11
- const EXECUTION_FAILURE_SCHEMA = z.object({
12
- message: z.string(),
13
- name: z.string(),
14
- })
15
-
16
12
  const EXECUTION_SUMMARY_SCHEMA = z.object({
17
13
  completedAt: z.date().nullable(),
18
14
  createdAt: z.date(),
19
15
  eventTypes: z.string().array(),
20
- failure: EXECUTION_FAILURE_SCHEMA.nullable(),
16
+ failure: automationErrorSchema.nullable(),
21
17
  id: z.string(),
22
18
  status: automationExecutionStatusSchema,
23
19
  })
@@ -37,7 +33,7 @@ export const automationContract = {
37
33
  completedAt: z.date().nullable(),
38
34
  createdAt: z.date(),
39
35
  description: z.string().nullable(),
40
- failure: EXECUTION_FAILURE_SCHEMA.nullable(),
36
+ failure: automationErrorSchema.nullable(),
41
37
  hasOutput: z.boolean(),
42
38
  id: z.string(),
43
39
  name: z.string(),
package/src/errors.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { z } from "zod"
2
+
3
+ const AUTOMATION_ERROR_BASE_SCHEMA = z.object({
4
+ code: z.string().min(1),
5
+ details: z.json().optional(),
6
+ message: z.string(),
7
+ name: z.string().optional(),
8
+ })
9
+
10
+ export const AUTOMATION_ERROR_CAUSE_DEPTH = 3
11
+
12
+ export interface AutomationErrorValue {
13
+ /** Normalized and depth-limited underlying failure. */
14
+ cause?: AutomationErrorValue
15
+
16
+ /** Stable machine-readable classification. */
17
+ code: string
18
+
19
+ /** Structured author-safe diagnostics such as validation issues. */
20
+ details?: z.output<ReturnType<typeof z.json>>
21
+
22
+ /** Human-readable summary safe to show automation authors. */
23
+ message: string
24
+
25
+ /** Original JavaScript or provider error class when available. */
26
+ name?: string
27
+ }
28
+
29
+ /** Author-safe normalized automation lifecycle error. */
30
+ export const automationErrorSchema = createAutomationErrorSchema(
31
+ AUTOMATION_ERROR_CAUSE_DEPTH,
32
+ )
33
+
34
+ /**
35
+ * Builds the finite public causal chain accepted at runtime boundaries.
36
+ *
37
+ * @param remainingDepth - Additional nested causes accepted by this level.
38
+ */
39
+ function createAutomationErrorSchema(
40
+ remainingDepth: number,
41
+ ): z.ZodType<AutomationErrorValue, AutomationErrorValue> {
42
+ return AUTOMATION_ERROR_BASE_SCHEMA.extend({
43
+ cause:
44
+ remainingDepth > 0
45
+ ? createAutomationErrorSchema(remainingDepth - 1).optional()
46
+ : z.never().optional(),
47
+ })
48
+ }
package/src/index.ts CHANGED
@@ -11,6 +11,11 @@ import { runtimeContract } from "./runtime"
11
11
 
12
12
  export { automationExecutionStatusSchema } from "./automation"
13
13
  export { AUTOMATION_SDK_VERSION } from "./deployment"
14
+ export {
15
+ AUTOMATION_ERROR_CAUSE_DEPTH,
16
+ automationErrorSchema,
17
+ type AutomationErrorValue,
18
+ } from "./errors"
14
19
  export { integrationAccountOutputSchema } from "./account"
15
20
  export {
16
21
  AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT,
package/src/runtime.ts CHANGED
@@ -3,6 +3,7 @@ import type { GatewayModelId } from "@ai-sdk/gateway"
3
3
  import { oc } from "@orpc/contract"
4
4
  import stableStringify from "fast-json-stable-stringify"
5
5
  import { z } from "zod"
6
+ import { automationErrorSchema } from "./errors"
6
7
 
7
8
  /** Default model used by the platform Vercel AI Gateway account. */
8
9
  export const DEFAULT_GATEWAY_MODEL_ID =
@@ -10,11 +11,6 @@ export const DEFAULT_GATEWAY_MODEL_ID =
10
11
  export const AUTOMATION_INVOCATION_DEFAULT_ENTRYPOINT = "default"
11
12
  export const AUTOMATION_INVOCATION_RESERVED_ENTRYPOINT_PREFIX = "__$"
12
13
 
13
- const SIGNAL_FAILURE_SCHEMA = z.object({
14
- message: z.string(),
15
- name: z.string(),
16
- })
17
-
18
14
  const OUTCOME_SEQUENCE_SCHEMA = z.number().int().positive()
19
15
  const HOOK_SCOPE_PATH_SCHEMA = z
20
16
  .number()
@@ -111,7 +107,7 @@ const ACTION_INVOCATION_SCHEMA = z.union([
111
107
  status: z.literal("skipped"),
112
108
  }),
113
109
  ACTION_INVOCATION_BASE_SCHEMA.extend({
114
- failure: SIGNAL_FAILURE_SCHEMA,
110
+ failure: automationErrorSchema,
115
111
  reason: z.literal("failed-dependency"),
116
112
  status: z.literal("skipped"),
117
113
  }),
@@ -125,7 +121,7 @@ const ACTION_RUN_INVOCATION_BASE_SCHEMA = ACTION_INVOCATION_BASE_SCHEMA.extend({
125
121
  const ACTION_RUN_INVOCATION_SCHEMA = z.union([
126
122
  ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({ status: z.literal("pending") }),
127
123
  ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({
128
- failure: SIGNAL_FAILURE_SCHEMA,
124
+ failure: automationErrorSchema,
129
125
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
130
126
  status: z.literal("failed"),
131
127
  }),
@@ -135,7 +131,7 @@ const ACTION_RUN_INVOCATION_SCHEMA = z.union([
135
131
  status: z.literal("skipped"),
136
132
  }),
137
133
  ACTION_RUN_INVOCATION_BASE_SCHEMA.extend({
138
- failure: SIGNAL_FAILURE_SCHEMA,
134
+ failure: automationErrorSchema,
139
135
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
140
136
  reason: z.literal("failed-dependency"),
141
137
  status: z.literal("skipped"),
@@ -275,7 +271,7 @@ const RACE_OFFER_SCHEMA = z
275
271
  .union([
276
272
  RACE_OFFER_BASE_SCHEMA.extend({ status: z.literal("closed") }),
277
273
  RACE_OFFER_BASE_SCHEMA.extend({
278
- failure: SIGNAL_FAILURE_SCHEMA,
274
+ failure: automationErrorSchema,
279
275
  status: z.literal("failed"),
280
276
  }),
281
277
  RACE_OFFER_BASE_SCHEMA.extend({ status: z.literal("succeeded") }),
@@ -304,7 +300,7 @@ const SIGNAL_INVOCATION_SCHEMA = z.union([
304
300
  status: z.literal("closed"),
305
301
  }),
306
302
  SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
307
- failure: SIGNAL_FAILURE_SCHEMA,
303
+ failure: automationErrorSchema,
308
304
  status: z.literal("failed"),
309
305
  }),
310
306
  SIGNAL_INVOCATION_DEPENDENCIES_SCHEMA.extend({
@@ -330,7 +326,7 @@ const SIGNAL_BATCH_OUTCOME_SCHEMA = z.union([
330
326
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("open") }),
331
327
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
332
328
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
333
- failure: SIGNAL_FAILURE_SCHEMA,
329
+ failure: automationErrorSchema,
334
330
  status: z.literal("failed"),
335
331
  }),
336
332
  SIGNAL_BATCH_OUTCOME_BASE_SCHEMA.extend({
@@ -352,14 +348,14 @@ const ACTION_VALUE_OUTCOME_SCHEMA = z.union([
352
348
  ACTION_VALUE_OUTCOME_BASE_SCHEMA.extend({
353
349
  outcomeSeq: OUTCOME_SEQUENCE_SCHEMA,
354
350
  status: z.literal("failed"),
355
- failure: SIGNAL_FAILURE_SCHEMA,
351
+ failure: automationErrorSchema,
356
352
  }),
357
353
  ACTION_VALUE_OUTCOME_BASE_SCHEMA.extend({
358
354
  reason: z.literal("closed-dependency"),
359
355
  status: z.literal("skipped"),
360
356
  }),
361
357
  ACTION_VALUE_OUTCOME_BASE_SCHEMA.extend({
362
- failure: SIGNAL_FAILURE_SCHEMA,
358
+ failure: automationErrorSchema,
363
359
  reason: z.literal("failed-dependency"),
364
360
  status: z.literal("skipped"),
365
361
  }),
@@ -399,7 +395,7 @@ const SIGNAL_VALUE_OUTCOME_SCHEMA = z.union([
399
395
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("open") }),
400
396
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({ status: z.literal("closed") }),
401
397
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
402
- failure: SIGNAL_FAILURE_SCHEMA,
398
+ failure: automationErrorSchema,
403
399
  status: z.literal("failed"),
404
400
  }),
405
401
  SIGNAL_VALUE_OUTCOME_BASE_SCHEMA.extend({
@@ -672,12 +668,12 @@ export const runtimeContract = {
672
668
  status: z.literal("skipped"),
673
669
  }),
674
670
  z.object({
675
- failure: SIGNAL_FAILURE_SCHEMA,
671
+ failure: automationErrorSchema,
676
672
  reason: z.literal("failed-dependency"),
677
673
  status: z.literal("skipped"),
678
674
  }),
679
675
  z.object({
680
- failure: SIGNAL_FAILURE_SCHEMA,
676
+ failure: automationErrorSchema,
681
677
  status: z.literal("failed"),
682
678
  }),
683
679
  z.object({