@shipfox/api-agent-access-dto 20.3.0 → 21.1.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 (41) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +4 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/schemas/diagnostic-tools.d.ts +322 -0
  8. package/dist/schemas/diagnostic-tools.d.ts.map +1 -0
  9. package/dist/schemas/diagnostic-tools.js +325 -0
  10. package/dist/schemas/diagnostic-tools.js.map +1 -0
  11. package/dist/schemas/log-tools.d.ts +215 -0
  12. package/dist/schemas/log-tools.d.ts.map +1 -0
  13. package/dist/schemas/log-tools.js +224 -0
  14. package/dist/schemas/log-tools.js.map +1 -0
  15. package/dist/schemas/paged-tools.d.ts.map +1 -1
  16. package/dist/schemas/paged-tools.js +1 -6
  17. package/dist/schemas/paged-tools.js.map +1 -1
  18. package/dist/schemas/primitives.d.ts +5 -0
  19. package/dist/schemas/primitives.d.ts.map +1 -0
  20. package/dist/schemas/primitives.js +9 -0
  21. package/dist/schemas/primitives.js.map +1 -0
  22. package/dist/schemas/workflow-diagnostics.d.ts +862 -0
  23. package/dist/schemas/workflow-diagnostics.d.ts.map +1 -0
  24. package/dist/schemas/workflow-diagnostics.js +876 -0
  25. package/dist/schemas/workflow-diagnostics.js.map +1 -0
  26. package/dist/schemas/workflow-tools.d.ts +1305 -0
  27. package/dist/schemas/workflow-tools.d.ts.map +1 -0
  28. package/dist/schemas/workflow-tools.js +938 -0
  29. package/dist/schemas/workflow-tools.js.map +1 -0
  30. package/dist/tsconfig.test.tsbuildinfo +1 -1
  31. package/package.json +3 -2
  32. package/src/index.ts +115 -0
  33. package/src/schemas/diagnostic-tools.ts +255 -0
  34. package/src/schemas/log-tools.ts +209 -0
  35. package/src/schemas/paged-tools.ts +1 -10
  36. package/src/schemas/primitives.ts +14 -0
  37. package/src/schemas/workflow-diagnostics.test.ts +277 -0
  38. package/src/schemas/workflow-diagnostics.ts +693 -0
  39. package/src/schemas/workflow-tools.test.ts +202 -0
  40. package/src/schemas/workflow-tools.ts +738 -0
  41. package/tsconfig.build.tsbuildinfo +1 -1
@@ -0,0 +1,202 @@
1
+ import {
2
+ AGENT_ACCESS_WORKFLOW_EXECUTION_PAGE_LIMIT,
3
+ AGENT_ACCESS_WORKFLOW_JOB_PAGE_LIMIT,
4
+ AGENT_ACCESS_WORKFLOW_RUN_ATTEMPT_PAGE_LIMIT,
5
+ AGENT_ACCESS_WORKFLOW_STEP_ATTEMPT_PAGE_LIMIT,
6
+ AGENT_ACCESS_WORKFLOW_STEP_PAGE_LIMIT,
7
+ getWorkflowJobInputSchema,
8
+ getWorkflowJobResultJsonSchema,
9
+ getWorkflowJobResultSchema,
10
+ getWorkflowRunInputSchema,
11
+ getWorkflowRunResultJsonSchema,
12
+ getWorkflowRunResultSchema,
13
+ listWorkflowExecutionStepsInputSchema,
14
+ listWorkflowExecutionStepsResultJsonSchema,
15
+ listWorkflowExecutionStepsResultSchema,
16
+ listWorkflowJobExecutionsInputSchema,
17
+ listWorkflowJobExecutionsResultJsonSchema,
18
+ listWorkflowRunAttemptsInputSchema,
19
+ listWorkflowRunAttemptsResultJsonSchema,
20
+ listWorkflowRunJobsInputSchema,
21
+ listWorkflowRunJobsResultJsonSchema,
22
+ listWorkflowStepAttemptsInputSchema,
23
+ listWorkflowStepAttemptsResultJsonSchema,
24
+ } from './workflow-tools.js';
25
+
26
+ const runId = '00000000-0000-4000-8000-000000000001';
27
+ const jobId = '00000000-0000-4000-8000-000000000002';
28
+ const executionId = '00000000-0000-4000-8000-000000000003';
29
+ const stepId = '00000000-0000-4000-8000-000000000004';
30
+ const isoDate = '2026-08-01T00:00:00.000Z';
31
+
32
+ describe('workflow agent-access schemas', () => {
33
+ test('uses producer page defaults and keeps workspace implicit', () => {
34
+ expect(listWorkflowRunAttemptsInputSchema.parse({run_id: runId}).limit).toBe(
35
+ AGENT_ACCESS_WORKFLOW_RUN_ATTEMPT_PAGE_LIMIT,
36
+ );
37
+ expect(listWorkflowRunJobsInputSchema.parse({run_id: runId, attempt: 2}).limit).toBe(
38
+ AGENT_ACCESS_WORKFLOW_JOB_PAGE_LIMIT,
39
+ );
40
+ expect(listWorkflowJobExecutionsInputSchema.parse({job_id: jobId}).limit).toBe(
41
+ AGENT_ACCESS_WORKFLOW_EXECUTION_PAGE_LIMIT,
42
+ );
43
+ expect(
44
+ listWorkflowExecutionStepsInputSchema.parse({job_id: jobId, execution_id: executionId}).limit,
45
+ ).toBe(AGENT_ACCESS_WORKFLOW_STEP_PAGE_LIMIT);
46
+ expect(listWorkflowStepAttemptsInputSchema.parse({step_id: stepId}).limit).toBe(
47
+ AGENT_ACCESS_WORKFLOW_STEP_ATTEMPT_PAGE_LIMIT,
48
+ );
49
+ expect(getWorkflowRunInputSchema.safeParse({run_id: runId, workspace_id: runId}).success).toBe(
50
+ false,
51
+ );
52
+ expect(getWorkflowJobInputSchema.safeParse({job_id: jobId, extra: true}).success).toBe(false);
53
+ });
54
+
55
+ test('requires the run attempt when listing jobs', () => {
56
+ expect(listWorkflowRunJobsInputSchema.safeParse({run_id: runId}).success).toBe(false);
57
+ expect(listWorkflowRunJobsInputSchema.safeParse({run_id: runId, attempt: 0}).success).toBe(
58
+ false,
59
+ );
60
+ });
61
+
62
+ test('declares one object result schema without embedded traversal children', () => {
63
+ const schemas = [
64
+ getWorkflowRunResultJsonSchema,
65
+ listWorkflowRunAttemptsResultJsonSchema,
66
+ listWorkflowRunJobsResultJsonSchema,
67
+ getWorkflowJobResultJsonSchema,
68
+ listWorkflowJobExecutionsResultJsonSchema,
69
+ listWorkflowExecutionStepsResultJsonSchema,
70
+ listWorkflowStepAttemptsResultJsonSchema,
71
+ ];
72
+ for (const schema of schemas) expect(schema).not.toHaveProperty('oneOf');
73
+
74
+ expect(getWorkflowRunResultJsonSchema.properties).not.toHaveProperty('jobs');
75
+ expect(getWorkflowJobResultJsonSchema.properties).toHaveProperty('selected_execution');
76
+ expect(listWorkflowExecutionStepsResultJsonSchema.properties.steps).toBeDefined();
77
+ expect(listWorkflowStepAttemptsResultJsonSchema.properties.attempts).toBeDefined();
78
+ });
79
+
80
+ test('rejects diagnostic and child collection fields from traversal results', () => {
81
+ const validRun = runResult();
82
+ expect(getWorkflowRunResultSchema.safeParse(validRun).success).toBe(true);
83
+ expect(getWorkflowRunResultSchema.safeParse({...validRun, jobs: []}).success).toBe(false);
84
+
85
+ const validJob = jobResult();
86
+ expect(getWorkflowJobResultSchema.safeParse(validJob).success).toBe(true);
87
+ expect(
88
+ getWorkflowJobResultSchema.safeParse({
89
+ ...validJob,
90
+ job: {...validJob.job, dependencies: []},
91
+ }).success,
92
+ ).toBe(false);
93
+
94
+ const validSteps = {
95
+ job_id: jobId,
96
+ execution_id: executionId,
97
+ steps: [stepResult()],
98
+ next_cursor: null,
99
+ };
100
+ expect(listWorkflowExecutionStepsResultSchema.safeParse(validSteps).success).toBe(true);
101
+ expect(
102
+ listWorkflowExecutionStepsResultSchema.safeParse({
103
+ ...validSteps,
104
+ steps: [{...stepResult(), attempts: {items: [], next_cursor: null}}],
105
+ }).success,
106
+ ).toBe(false);
107
+ });
108
+
109
+ test('enforces text caps by UTF-8 bytes', () => {
110
+ const validRun = runResult();
111
+ const underByteCap = {...validRun, name: `${'🙂'.repeat(127)}a`};
112
+ const overByteCap = {...validRun, name: '🙂'.repeat(129)};
113
+
114
+ expect(getWorkflowRunResultSchema.safeParse(underByteCap).success).toBe(true);
115
+ expect(getWorkflowRunResultSchema.safeParse(overByteCap).success).toBe(false);
116
+ });
117
+ });
118
+
119
+ function runResult() {
120
+ return {
121
+ id: runId,
122
+ project_id: runId,
123
+ definition_id: jobId,
124
+ number: 1,
125
+ name: 'Run',
126
+ workflow_name: 'Workflow',
127
+ status: 'failed' as const,
128
+ origin: 'synced' as const,
129
+ dev_source: null,
130
+ trigger_provider: 'github',
131
+ trigger_source: 'push',
132
+ trigger_event: 'push',
133
+ trigger_reference: {repository: 'shipfox/platform', ref: 'main', commit: 'abc', actor: 'noe'},
134
+ created_at: isoDate,
135
+ started_at: isoDate,
136
+ finished_at: isoDate,
137
+ attempt: {
138
+ id: executionId,
139
+ workflow_run_id: runId,
140
+ attempt: 1,
141
+ status: 'failed' as const,
142
+ created_at: isoDate,
143
+ started_at: isoDate,
144
+ finished_at: isoDate,
145
+ rerun_mode: null,
146
+ },
147
+ job_status_counts: [{status: 'failed' as const, count: 1}],
148
+ has_started_job_execution: true,
149
+ };
150
+ }
151
+
152
+ function jobResult() {
153
+ return {
154
+ workflow_run_id: runId,
155
+ workflow_run_attempt: 1,
156
+ job: {
157
+ id: jobId,
158
+ key: 'build',
159
+ name: 'Build',
160
+ position: 0,
161
+ status: 'failed' as const,
162
+ status_reason: 'step_failed' as const,
163
+ mode: 'one_shot' as const,
164
+ listener_status: 'inactive' as const,
165
+ carried_over: false,
166
+ execution_count: 1,
167
+ execution_status_counts: {pending: 0, running: 0, succeeded: 0, failed: 1, cancelled: 0},
168
+ default_execution: executionResult(),
169
+ },
170
+ selected_execution: {...executionResult(), has_context: true},
171
+ };
172
+ }
173
+
174
+ function executionResult() {
175
+ return {
176
+ id: executionId,
177
+ sequence: 1,
178
+ name: 'Build execution',
179
+ status: 'failed' as const,
180
+ display_status: 'failed' as const,
181
+ status_reason: 'step_failed' as const,
182
+ status_reason_message: 'The step failed',
183
+ queued_at: isoDate,
184
+ started_at: isoDate,
185
+ finished_at: isoDate,
186
+ timed_out_at: null,
187
+ updated_at: isoDate,
188
+ };
189
+ }
190
+
191
+ function stepResult() {
192
+ return {
193
+ id: stepId,
194
+ key: 'run',
195
+ name: 'Run command',
196
+ type: 'run' as const,
197
+ position: 0,
198
+ status: 'failed' as const,
199
+ status_reason: null,
200
+ current_attempt: 1,
201
+ };
202
+ }