@shipfox/api-workflows-dto 12.1.0 → 12.3.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.
Files changed (53) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +16 -0
  3. package/dist/events.d.ts +64 -33
  4. package/dist/events.d.ts.map +1 -1
  5. package/dist/events.js +31 -1
  6. package/dist/events.js.map +1 -1
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +2 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/inter-module.d.ts +50 -50
  12. package/dist/inter-module.d.ts.map +1 -1
  13. package/dist/schemas/evaluation-trace.d.ts +36 -0
  14. package/dist/schemas/evaluation-trace.d.ts.map +1 -0
  15. package/dist/schemas/evaluation-trace.js +25 -0
  16. package/dist/schemas/evaluation-trace.js.map +1 -0
  17. package/dist/schemas/index.d.ts +3 -2
  18. package/dist/schemas/index.d.ts.map +1 -1
  19. package/dist/schemas/index.js +3 -2
  20. package/dist/schemas/index.js.map +1 -1
  21. package/dist/schemas/job-execution.d.ts +48 -27
  22. package/dist/schemas/job-execution.d.ts.map +1 -1
  23. package/dist/schemas/job-listening.d.ts +6 -6
  24. package/dist/schemas/job.d.ts +40 -22
  25. package/dist/schemas/job.d.ts.map +1 -1
  26. package/dist/schemas/job.js +4 -0
  27. package/dist/schemas/job.js.map +1 -1
  28. package/dist/schemas/log-outcome.d.ts +1 -1
  29. package/dist/schemas/step.d.ts +125 -36
  30. package/dist/schemas/step.d.ts.map +1 -1
  31. package/dist/schemas/step.js +13 -0
  32. package/dist/schemas/step.js.map +1 -1
  33. package/dist/schemas/workflow-run-detail.d.ts +295 -84
  34. package/dist/schemas/workflow-run-detail.d.ts.map +1 -1
  35. package/dist/schemas/workflow-run-detail.js +11 -1
  36. package/dist/schemas/workflow-run-detail.js.map +1 -1
  37. package/dist/schemas/workflow-run.d.ts +27 -27
  38. package/dist/tsconfig.test.tsbuildinfo +1 -1
  39. package/dist/working-directory.d.ts.map +1 -1
  40. package/package.json +2 -2
  41. package/src/events.test.ts +3 -0
  42. package/src/events.ts +38 -0
  43. package/src/index.ts +14 -0
  44. package/src/schemas/evaluation-trace.test.ts +40 -0
  45. package/src/schemas/evaluation-trace.ts +30 -0
  46. package/src/schemas/index.ts +13 -0
  47. package/src/schemas/job.test.ts +3 -0
  48. package/src/schemas/job.ts +4 -0
  49. package/src/schemas/step-source-location.test.ts +2 -0
  50. package/src/schemas/step.test.ts +17 -1
  51. package/src/schemas/step.ts +20 -0
  52. package/src/schemas/workflow-run-detail.ts +14 -1
  53. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"working-directory.d.ts","sourceRoot":"","sources":["../src/working-directory.ts"],"names":[],"mappings":"AAGA,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,KAAK,EAAE,OAAO;CAM3B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAW9E"}
1
+ {"version":3,"file":"working-directory.d.ts","sourceRoot":"","sources":["../src/working-directory.ts"],"names":[],"mappings":"AAGA,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,YAAY,KAAK,EAAE,OAAO,EAKzB;CACF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAW9E"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipfox/api-workflows-dto",
3
3
  "license": "MIT",
4
- "version": "12.1.0",
4
+ "version": "12.3.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ShipfoxHQ/shipfox.git",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "zod": "^4.4.3",
26
- "@shipfox/api-agent-dto": "12.0.0",
26
+ "@shipfox/api-agent-dto": "12.2.0",
27
27
  "@shipfox/inter-module": "0.2.3"
28
28
  },
29
29
  "imports": {
@@ -100,6 +100,7 @@ const validStepAttemptTerminated = {
100
100
  projectId: 'proj-1',
101
101
  stepId: 'step-1',
102
102
  attempt: 1,
103
+ status: 'failed',
103
104
  logOutcome: 'drained',
104
105
  };
105
106
 
@@ -226,6 +227,7 @@ describe('workflowsJobActivatedSchema', () => {
226
227
  event: 'pull_request_review',
227
228
  filter: 'jobs.build.outputs.pr_number == event.pull_request.number',
228
229
  filter_snapshot: {jobs: {build: {outputs: {pr_number: 42}}}},
230
+ filter_output_types: {build: {pr_number: 'int'}},
229
231
  },
230
232
  ],
231
233
  until: [
@@ -234,6 +236,7 @@ describe('workflowsJobActivatedSchema', () => {
234
236
  event: 'pull_request',
235
237
  filter: 'jobs.build.outputs.pr_number == event.pull_request.number',
236
238
  filter_snapshot: {jobs: {build: {outputs: {pr_number: 42}}}},
239
+ filter_output_types: {build: {pr_number: 'int'}},
237
240
  },
238
241
  ],
239
242
  };
package/src/events.ts CHANGED
@@ -80,8 +80,39 @@ const workflowsJobActivatedBaseSchema = z.object({
80
80
  workspaceId: nonEmptyStringSchema,
81
81
  });
82
82
 
83
+ // Keep this passive DTO schema local so the transport package does not depend on expression runtime code.
84
+ export type ListenerFilterExpressionType =
85
+ | 'string'
86
+ | 'int'
87
+ | 'double'
88
+ | 'bool'
89
+ | 'null'
90
+ | 'timestamp'
91
+ | {kind: 'object'; fields: Record<string, ListenerFilterExpressionType>}
92
+ | {kind: 'map'}
93
+ | {kind: 'list'; element: ListenerFilterExpressionType};
94
+
95
+ const listenerFilterExpressionTypeSchema: z.ZodType<ListenerFilterExpressionType> = z.lazy(() =>
96
+ z.union([
97
+ z.enum(['string', 'int', 'double', 'bool', 'null', 'timestamp']),
98
+ z.object({
99
+ kind: z.literal('object'),
100
+ fields: z.record(z.string(), listenerFilterExpressionTypeSchema),
101
+ }),
102
+ z.object({kind: z.literal('map')}),
103
+ z.object({kind: z.literal('list'), element: listenerFilterExpressionTypeSchema}),
104
+ ]),
105
+ );
106
+
107
+ export const listenerFilterOutputTypesSchema = z.record(
108
+ z.string(),
109
+ z.record(z.string(), listenerFilterExpressionTypeSchema),
110
+ );
111
+ export type ListenerFilterOutputTypes = z.infer<typeof listenerFilterOutputTypesSchema>;
112
+
83
113
  const resolvedListeningTriggerSchema = listeningTriggerSchema.extend({
84
114
  filter_snapshot: z.record(z.string(), z.unknown()).optional(),
115
+ filter_output_types: listenerFilterOutputTypesSchema.optional(),
85
116
  });
86
117
 
87
118
  export const workflowsJobActivatedSchema = z.discriminatedUnion('mode', [
@@ -108,6 +139,10 @@ export type WorkflowsJobEventDeliveredEventDto = z.infer<typeof workflowsJobEven
108
139
 
109
140
  export const workflowsJobTerminatedSchema = z.object({
110
141
  jobId: nonEmptyStringSchema,
142
+ // Optional for compatibility with terminal events written before the current execution
143
+ // identity became part of the event contract. New events always include the value, or null
144
+ // when the job was terminated before an execution was created.
145
+ jobExecutionId: nonEmptyStringSchema.nullable().optional(),
111
146
  workflowRunId: nonEmptyStringSchema,
112
147
  workflowRunAttemptId: nonEmptyStringSchema,
113
148
  status: jobTerminalStatusSchema,
@@ -147,6 +182,9 @@ export const workflowsStepAttemptTerminatedSchema = z.object({
147
182
  projectId: nonEmptyStringSchema,
148
183
  stepId: nonEmptyStringSchema,
149
184
  attempt: z.number().int().positive(),
185
+ // Optional so the subscriber can continue to consume terminal events written
186
+ // before the status field was added. New outbox events always include it.
187
+ status: terminalStatusSchema.optional(),
150
188
  logOutcome: logOutcomeSchema,
151
189
  });
152
190
  export type WorkflowsStepAttemptTerminatedEventDto = z.infer<
package/src/index.ts CHANGED
@@ -15,6 +15,10 @@ export {
15
15
  checkoutTokenParamsSchema,
16
16
  checkoutTokenQuerySchema,
17
17
  checkoutTokenResponseSchema,
18
+ type EvaluationTraceDto,
19
+ type EvaluationTraceEntryDto,
20
+ evaluationTraceEntrySchema,
21
+ evaluationTraceSchema,
18
22
  type JobDto,
19
23
  type JobExecutionDto,
20
24
  type JobListeningDto,
@@ -45,18 +49,25 @@ export {
45
49
  resolutionReasonSchema,
46
50
  STEP_ERROR_MESSAGE_MAX_LENGTH,
47
51
  STEP_RESPONSE_MAX_LENGTH,
52
+ STEP_STATUS_REASONS,
53
+ type StepAttemptDetailDto,
54
+ type StepAttemptDetailResponseDto,
48
55
  type StepAttemptDto,
49
56
  type StepDto,
50
57
  type StepErrorCategoryDto,
51
58
  type StepErrorDto,
52
59
  type StepErrorReasonDto,
53
60
  type StepGateResultDto,
61
+ type StepStatusReasonDto,
62
+ stepAttemptDetailDtoSchema,
63
+ stepAttemptDetailResponseSchema,
54
64
  stepAttemptDtoSchema,
55
65
  stepDtoSchema,
56
66
  stepErrorCategorySchema,
57
67
  stepErrorDtoSchema,
58
68
  stepErrorReasonSchema,
59
69
  stepGateResultDtoSchema,
70
+ stepStatusReasonSchema,
60
71
  type TriggerEventsBatchDto,
61
72
  triggerEventsBatchSchema,
62
73
  type WorkflowExecutionContextDto,
@@ -108,6 +119,9 @@ export {
108
119
  } from '#schemas/workflow-run.js';
109
120
  export {
110
121
  jobTerminalStatusSchema,
122
+ type ListenerFilterExpressionType,
123
+ type ListenerFilterOutputTypes,
124
+ listenerFilterOutputTypesSchema,
111
125
  terminalStatusSchema,
112
126
  WORKFLOWS_JOB_ACTIVATED,
113
127
  WORKFLOWS_JOB_EVENT_DELIVERED,
@@ -0,0 +1,40 @@
1
+ import {evaluationTraceSchema} from './evaluation-trace.js';
2
+
3
+ describe('evaluation trace schema', () => {
4
+ it('accepts value entries with resolved and diagnostic metadata', () => {
5
+ const trace = evaluationTraceSchema.parse([
6
+ {
7
+ expression: 'inputs.environment',
8
+ roots: ['inputs.environment'],
9
+ fill_target: 'agent.prompt',
10
+ evaluated_at: '2026-08-05T12:00:00.000Z',
11
+ field: 'agent.prompt',
12
+ value: 'production',
13
+ reference: true,
14
+ degraded: false,
15
+ env_key: 'ENVIRONMENT',
16
+ },
17
+ ]);
18
+
19
+ expect(trace[0]).toMatchObject({
20
+ field: 'agent.prompt',
21
+ value: 'production',
22
+ reference: true,
23
+ env_key: 'ENVIRONMENT',
24
+ });
25
+ });
26
+
27
+ it('accepts an explicit trace budget marker', () => {
28
+ expect(evaluationTraceSchema.parse([{truncated: true, dropped: 3}])).toEqual([
29
+ {truncated: true, dropped: 3},
30
+ ]);
31
+ });
32
+
33
+ it('rejects malformed trace entries', () => {
34
+ const result = evaluationTraceSchema.safeParse([
35
+ {expression: 'inputs.environment', field: 'agent.prompt'},
36
+ ]);
37
+
38
+ expect(result.success).toBe(false);
39
+ });
40
+ });
@@ -0,0 +1,30 @@
1
+ import {z} from 'zod';
2
+
3
+ const evaluationTraceValueSchema = z.object({
4
+ expression: z.string(),
5
+ roots: z.array(z.string()),
6
+ fill_target: z.string(),
7
+ evaluated_at: z.string(),
8
+ field: z.string(),
9
+ value: z.string().optional(),
10
+ truncated: z.boolean().optional(),
11
+ expr_truncated: z.boolean().optional(),
12
+ reference: z.boolean().optional(),
13
+ degraded: z.boolean().optional(),
14
+ env_key: z.string().optional(),
15
+ });
16
+
17
+ const evaluationTraceLimitSchema = z.object({
18
+ truncated: z.literal(true),
19
+ dropped: z.number().int().nonnegative(),
20
+ });
21
+
22
+ export const evaluationTraceEntrySchema = z.union([
23
+ evaluationTraceValueSchema,
24
+ evaluationTraceLimitSchema,
25
+ ]);
26
+
27
+ export const evaluationTraceSchema = z.array(evaluationTraceEntrySchema);
28
+
29
+ export type EvaluationTraceEntryDto = z.infer<typeof evaluationTraceEntrySchema>;
30
+ export type EvaluationTraceDto = z.infer<typeof evaluationTraceSchema>;
@@ -13,6 +13,12 @@ export {
13
13
  checkoutTokenQuerySchema,
14
14
  checkoutTokenResponseSchema,
15
15
  } from './checkout-token.js';
16
+ export {
17
+ type EvaluationTraceDto,
18
+ type EvaluationTraceEntryDto,
19
+ evaluationTraceEntrySchema,
20
+ evaluationTraceSchema,
21
+ } from './evaluation-trace.js';
16
22
  export {
17
23
  type JobDto,
18
24
  type JobStatusDto,
@@ -56,18 +62,23 @@ export {
56
62
  type AgentConfigIssueDto,
57
63
  agentConfigIssueSchema,
58
64
  STEP_ERROR_MESSAGE_MAX_LENGTH,
65
+ STEP_STATUS_REASONS,
66
+ type StepAttemptDetailDto,
59
67
  type StepAttemptDto,
60
68
  type StepDto,
61
69
  type StepErrorCategoryDto,
62
70
  type StepErrorDto,
63
71
  type StepErrorReasonDto,
64
72
  type StepGateResultDto,
73
+ type StepStatusReasonDto,
74
+ stepAttemptDetailDtoSchema,
65
75
  stepAttemptDtoSchema,
66
76
  stepDtoSchema,
67
77
  stepErrorCategorySchema,
68
78
  stepErrorDtoSchema,
69
79
  stepErrorReasonSchema,
70
80
  stepGateResultDtoSchema,
81
+ stepStatusReasonSchema,
71
82
  } from './step.js';
72
83
  export {
73
84
  type RerunWorkflowRunBodyDto,
@@ -108,6 +119,8 @@ export {
108
119
  type JobExecutionDto,
109
120
  jobExecutionDtoSchema,
110
121
  jobExecutionStatusSchema,
122
+ type StepAttemptDetailResponseDto,
123
+ stepAttemptDetailResponseSchema,
111
124
  type WorkflowRunDetailResponseDto,
112
125
  type WorkflowRunJobDetailDto,
113
126
  type WorkflowRunJobExecutionDetailDto,
@@ -9,6 +9,9 @@ const baseJob = {
9
9
  status: 'pending',
10
10
  status_reason: null,
11
11
  carried_over: false,
12
+ success: null,
13
+ runner: null,
14
+ evaluation_trace: null,
12
15
  listening: null,
13
16
  listener_status: 'inactive',
14
17
  resolution_reason: null,
@@ -1,4 +1,5 @@
1
1
  import {z} from 'zod';
2
+ import {evaluationTraceSchema} from './evaluation-trace.js';
2
3
  import {
3
4
  jobListeningSchema,
4
5
  jobModeSchema,
@@ -38,6 +39,9 @@ export const jobDtoSchema = z.object({
38
39
  status: jobStatusSchema,
39
40
  status_reason: jobStatusReasonSchema.nullable(),
40
41
  carried_over: z.boolean(),
42
+ success: z.string().nullable(),
43
+ runner: z.array(z.string()).nullable(),
44
+ evaluation_trace: evaluationTraceSchema.nullable(),
41
45
  listening: jobListeningSchema.nullable(),
42
46
  listener_status: listenerStatusSchema,
43
47
  resolution_reason: resolutionReasonSchema.nullable(),
@@ -6,8 +6,10 @@ const baseStep = {
6
6
  key: null,
7
7
  name: 'echo hello',
8
8
  status: 'pending',
9
+ status_reason: null,
9
10
  type: 'run',
10
11
  config: {run: 'echo hello'},
12
+ evaluation_trace: null,
11
13
  error: null,
12
14
  position: 1,
13
15
  current_attempt: 1,
@@ -1,4 +1,10 @@
1
- import {STEP_ERROR_MESSAGE_MAX_LENGTH, stepAttemptDtoSchema, stepErrorDtoSchema} from './step.js';
1
+ import {
2
+ STEP_ERROR_MESSAGE_MAX_LENGTH,
3
+ STEP_STATUS_REASONS,
4
+ stepAttemptDtoSchema,
5
+ stepErrorDtoSchema,
6
+ stepStatusReasonSchema,
7
+ } from './step.js';
2
8
 
3
9
  const baseAttempt = {
4
10
  id: '11111111-1111-4111-8111-111111111111',
@@ -111,6 +117,16 @@ describe('stepErrorDtoSchema', () => {
111
117
  });
112
118
  });
113
119
 
120
+ describe('stepStatusReasonSchema', () => {
121
+ it.each(STEP_STATUS_REASONS)('accepts the domain reason %s', (reason) => {
122
+ expect(stepStatusReasonSchema.parse(reason)).toBe(reason);
123
+ });
124
+
125
+ it('rejects an unknown step status reason', () => {
126
+ expect(stepStatusReasonSchema.safeParse('runner_lost').success).toBe(false);
127
+ });
128
+ });
129
+
114
130
  describe('stepAttemptDtoSchema', () => {
115
131
  it('accepts an attempt with no gate or restart feedback', () => {
116
132
  const attempt = {...baseAttempt, gate_result: {kind: 'none'}};
@@ -1,4 +1,15 @@
1
1
  import {z} from 'zod';
2
+ import {evaluationTraceSchema} from './evaluation-trace.js';
3
+
4
+ export const STEP_STATUS_REASONS = [
5
+ 'default_gate_rejected',
6
+ 'condition_rejected',
7
+ 'condition_errored',
8
+ ] as const;
9
+
10
+ export const stepStatusReasonSchema = z.enum(STEP_STATUS_REASONS);
11
+
12
+ export type StepStatusReasonDto = z.infer<typeof stepStatusReasonSchema>;
2
13
 
3
14
  // Machine-readable cause of a step failure, for DB troubleshooting. The runner
4
15
  // reports it and the server stores it as-is. The `checkout_*`, `git_unavailable`,
@@ -86,8 +97,10 @@ export const stepDtoSchema = z.object({
86
97
  name: z.string(),
87
98
  source_location: stepSourceLocationSchema.nullable(),
88
99
  status: z.string(),
100
+ status_reason: stepStatusReasonSchema.nullable(),
89
101
  type: z.string(),
90
102
  config: z.record(z.string(), z.unknown()),
103
+ evaluation_trace: evaluationTraceSchema.nullable(),
91
104
  error: stepErrorDtoSchema,
92
105
  position: z.number(),
93
106
  // Execution-attempt identity of the current projection (>1 after a restart).
@@ -165,3 +178,10 @@ export const stepAttemptDtoSchema = z.object({
165
178
  });
166
179
 
167
180
  export type StepAttemptDto = z.infer<typeof stepAttemptDtoSchema>;
181
+
182
+ export const stepAttemptDetailDtoSchema = stepAttemptDtoSchema.extend({
183
+ config: z.record(z.string(), z.unknown()).nullable(),
184
+ evaluation_trace: evaluationTraceSchema.nullable(),
185
+ });
186
+
187
+ export type StepAttemptDetailDto = z.infer<typeof stepAttemptDetailDtoSchema>;
@@ -1,7 +1,8 @@
1
1
  import {z} from 'zod';
2
+ import {evaluationTraceSchema} from './evaluation-trace.js';
2
3
  import {jobDtoSchema} from './job.js';
3
4
  import {workflowExecutionEventSchema} from './job-listening.js';
4
- import {stepAttemptDtoSchema, stepDtoSchema} from './step.js';
5
+ import {stepAttemptDetailDtoSchema, stepAttemptDtoSchema, stepDtoSchema} from './step.js';
5
6
  import {workflowRunAttemptDtoSchema, workflowRunResponseSchema} from './workflow-run.js';
6
7
 
7
8
  export const jobExecutionStatusSchema = z.enum([
@@ -19,8 +20,10 @@ export const jobExecutionDtoSchema = z.object({
19
20
  name: z.string(),
20
21
  status: jobExecutionStatusSchema,
21
22
  status_reason: z.string().nullable(),
23
+ runner: z.array(z.string()).nullable(),
22
24
  trigger_events: z.array(workflowExecutionEventSchema).default([]),
23
25
  outputs: z.record(z.string(), z.unknown()).nullable(),
26
+ evaluation_trace: evaluationTraceSchema.nullable(),
24
27
  queued_at: z.string().nullable(),
25
28
  started_at: z.string().nullable(),
26
29
  finished_at: z.string().nullable(),
@@ -43,6 +46,16 @@ export const workflowRunStepDetailDtoSchema = stepDtoSchema.extend({
43
46
 
44
47
  export type WorkflowRunStepDetailDto = z.infer<typeof workflowRunStepDetailDtoSchema>;
45
48
 
49
+ export const stepAttemptDetailResponseSchema = z.object({
50
+ step_id: z.string().uuid(),
51
+ attempt: stepAttemptDetailDtoSchema.shape.attempt,
52
+ authored_config: z.record(z.string(), z.unknown()).nullable(),
53
+ config: stepAttemptDetailDtoSchema.shape.config,
54
+ evaluation_trace: stepAttemptDetailDtoSchema.shape.evaluation_trace,
55
+ });
56
+
57
+ export type StepAttemptDetailResponseDto = z.infer<typeof stepAttemptDetailResponseSchema>;
58
+
46
59
  export const workflowRunJobExecutionDetailDtoSchema = jobExecutionDtoSchema.extend({
47
60
  steps: z.array(workflowRunStepDetailDtoSchema),
48
61
  });