@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,277 @@
1
+ import {agentAccessOutputSchema} from './envelope.js';
2
+ import {AGENT_ACCESS_PAGE_LIMIT_MAX} from './paged-tools.js';
3
+ import {
4
+ AGENT_ACCESS_WORKFLOW_SOURCE_MAX_BYTES,
5
+ getStepAttemptResultJsonSchema,
6
+ getStepAttemptResultSchema,
7
+ getWorkflowExecutionContextResultJsonSchema,
8
+ getWorkflowExecutionContextResultSchema,
9
+ getWorkflowRunSourceResultJsonSchema,
10
+ getWorkflowRunSourceResultSchema,
11
+ listWorkflowRunJobExplanationsResultJsonSchema,
12
+ listWorkflowRunJobExplanationsResultSchema,
13
+ } from './workflow-diagnostics.js';
14
+ import {AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX} from './workflow-tools.js';
15
+
16
+ const runId = '00000000-0000-4000-8000-000000000001';
17
+ const jobId = '00000000-0000-4000-8000-000000000002';
18
+ const executionId = '00000000-0000-4000-8000-000000000003';
19
+ const stepId = '00000000-0000-4000-8000-000000000004';
20
+ const stepAttemptId = '00000000-0000-4000-8000-000000000005';
21
+ const projectId = '00000000-0000-4000-8000-000000000006';
22
+ const deliveryId = '00000000-0000-4000-8000-000000000007';
23
+ const isoDate = '2026-08-01T00:00:00.000Z';
24
+
25
+ describe('workflow diagnostic Agent Access schemas', () => {
26
+ test('accepts canonical source, context, step, and explanation values', () => {
27
+ expect(getWorkflowRunSourceResultSchema.safeParse(sourceAvailable()).success).toBe(true);
28
+ expect(getWorkflowRunSourceResultSchema.safeParse(sourceUnavailable()).success).toBe(true);
29
+ expect(getWorkflowExecutionContextResultSchema.safeParse(contextResult()).success).toBe(true);
30
+ expect(getStepAttemptResultSchema.safeParse(stepResult()).success).toBe(true);
31
+ expect(listWorkflowRunJobExplanationsResultSchema.safeParse(explanationsResult()).success).toBe(
32
+ true,
33
+ );
34
+ });
35
+
36
+ test('keeps source availability branches distinct in the JSON schema mirror', () => {
37
+ const branches = getWorkflowRunSourceResultJsonSchema.oneOf;
38
+ expect(branches).toHaveLength(2);
39
+ expect(branches[0]).toMatchObject({
40
+ properties: {kind: {const: 'available'}},
41
+ required: expect.arrayContaining(['source_snapshot']),
42
+ });
43
+ expect(branches[1]).toMatchObject({
44
+ properties: {kind: {const: 'unavailable'}},
45
+ required: expect.arrayContaining(['reason']),
46
+ });
47
+
48
+ expect(
49
+ getWorkflowRunSourceResultSchema.safeParse({
50
+ ...sourceAvailable(),
51
+ reason: 'temporary_run',
52
+ }).success,
53
+ ).toBe(false);
54
+ expect(
55
+ getWorkflowRunSourceResultSchema.safeParse({
56
+ ...sourceUnavailable(),
57
+ source_snapshot: {content: 'name: build', format: 'yaml'},
58
+ }).success,
59
+ ).toBe(false);
60
+ });
61
+
62
+ test('mirrors collection, truncation, and response-field bounds in tool schemas', () => {
63
+ const envelopes = [
64
+ agentAccessOutputSchema(getWorkflowRunSourceResultJsonSchema),
65
+ agentAccessOutputSchema(getWorkflowExecutionContextResultJsonSchema),
66
+ agentAccessOutputSchema(getStepAttemptResultJsonSchema),
67
+ agentAccessOutputSchema(listWorkflowRunJobExplanationsResultJsonSchema),
68
+ ];
69
+ for (const envelope of envelopes) {
70
+ expect(envelope.type).toBe('object');
71
+ expect(envelope).not.toHaveProperty('oneOf');
72
+ }
73
+
74
+ expect(getWorkflowRunSourceResultJsonSchema.properties.workflow_run_attempt).toMatchObject({
75
+ maximum: AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX,
76
+ });
77
+ expect(getWorkflowRunSourceResultJsonSchema.properties.source_snapshot).toMatchObject({
78
+ properties: {content: {maxLength: AGENT_ACCESS_WORKFLOW_SOURCE_MAX_BYTES}},
79
+ });
80
+ expect(getWorkflowRunSourceResultJsonSchema.properties.reason).toMatchObject({
81
+ enum: ['temporary_run', 'pre_snapshot_run', 'legacy_snapshot_too_large'],
82
+ });
83
+
84
+ expect(getStepAttemptResultJsonSchema.properties.error.anyOf[0]).toMatchObject({
85
+ properties: {
86
+ reason: {
87
+ enum: [
88
+ 'checkout_failed',
89
+ 'checkout_auth_failed',
90
+ 'checkout_unavailable',
91
+ 'checkout_path_invalid',
92
+ 'checkout_destination_occupied',
93
+ 'git_unavailable',
94
+ 'workspace_prep_failed',
95
+ 'setup_aborted',
96
+ 'config_unresolvable',
97
+ 'output_invalid',
98
+ 'agent_config_invalid',
99
+ 'agent_invocation_failed',
100
+ 'agent_harness_unavailable',
101
+ 'agent_inference_credentials_unavailable',
102
+ 'agent_session_key_invalid',
103
+ 'agent_session_held',
104
+ 'agent_session_harness_mismatch',
105
+ 'agent_session_unavailable',
106
+ 'execution_payload_too_large',
107
+ 'step_result_too_large',
108
+ 'diagnostic_too_large',
109
+ 'tool_error',
110
+ 'tool_config_invalid',
111
+ 'invocation_interrupted',
112
+ ],
113
+ },
114
+ agent_config_issue: {
115
+ enum: [
116
+ 'step_config_invalid',
117
+ 'provider_not_configured',
118
+ 'provider_unsupported',
119
+ 'model_unavailable',
120
+ 'credentials_invalid',
121
+ ],
122
+ },
123
+ category: {enum: ['setup', 'user']},
124
+ },
125
+ });
126
+ expect(getStepAttemptResultJsonSchema.properties.gate_result.anyOf[0]).toMatchObject({
127
+ properties: {
128
+ kind: {
129
+ enum: [
130
+ 'none',
131
+ 'not_evaluated',
132
+ 'passed',
133
+ 'failed',
134
+ 'uncheckable',
135
+ 'evaluation_error',
136
+ 'unknown',
137
+ ],
138
+ },
139
+ },
140
+ });
141
+ expect(
142
+ listWorkflowRunJobExplanationsResultJsonSchema.properties.explanations.items.properties
143
+ .status,
144
+ ).toMatchObject({enum: ['failed', 'skipped']});
145
+ expect(
146
+ getWorkflowExecutionContextResultJsonSchema.properties.oversized_fields.items.properties
147
+ .reason,
148
+ ).toMatchObject({
149
+ enum: [
150
+ 'legacy_value_exceeds_inline_limit',
151
+ 'value_exceeds_inline_limit',
152
+ 'value_truncated_at_write_limit',
153
+ ],
154
+ });
155
+
156
+ expect(getWorkflowExecutionContextResultJsonSchema.properties.trigger_events).toMatchObject({
157
+ type: 'array',
158
+ maxItems: AGENT_ACCESS_PAGE_LIMIT_MAX,
159
+ });
160
+ expect(getWorkflowExecutionContextResultJsonSchema.properties.trigger_events_truncated).toEqual(
161
+ {const: true},
162
+ );
163
+ expect(getWorkflowExecutionContextResultJsonSchema.properties.condition_truncated).toEqual({
164
+ const: true,
165
+ });
166
+
167
+ expect(getStepAttemptResultJsonSchema.properties.response_text_truncated).toEqual({
168
+ const: true,
169
+ });
170
+ expect(getStepAttemptResultJsonSchema.properties.restart_feedback_truncated).toEqual({
171
+ const: true,
172
+ });
173
+ expect(listWorkflowRunJobExplanationsResultJsonSchema.properties.explanations).toMatchObject({
174
+ type: 'array',
175
+ maxItems: AGENT_ACCESS_PAGE_LIMIT_MAX,
176
+ });
177
+ });
178
+ });
179
+
180
+ function sourceAvailable() {
181
+ return {
182
+ kind: 'available' as const,
183
+ workflow_run_id: runId,
184
+ workflow_run_attempt: 1,
185
+ source_snapshot: {content: 'name: build', format: 'yaml' as const},
186
+ };
187
+ }
188
+
189
+ function sourceUnavailable() {
190
+ return {
191
+ kind: 'unavailable' as const,
192
+ workflow_run_id: runId,
193
+ workflow_run_attempt: 1,
194
+ reason: 'pre_snapshot_run' as const,
195
+ };
196
+ }
197
+
198
+ function contextResult() {
199
+ return {
200
+ workflow_run_id: runId,
201
+ workflow_run_attempt: 1,
202
+ job_id: jobId,
203
+ job_execution_id: executionId,
204
+ job_runner: ['runner-a'],
205
+ execution_runner: null,
206
+ job_outputs: {closed: {status: 'succeeded'}},
207
+ execution_outputs: {mapped: [{id: 1}]},
208
+ trigger_events: [
209
+ {
210
+ source: 'github',
211
+ event: 'push',
212
+ delivery_id: deliveryId,
213
+ received_at: isoDate,
214
+ project: {id: projectId},
215
+ repository: 'shipfox/app',
216
+ ref: 'refs/heads/main',
217
+ commit: 'abc123',
218
+ data: {message: 'external data'},
219
+ },
220
+ ],
221
+ job_evaluation_trace: [
222
+ {
223
+ expression: 'steps.build.outputs.ok',
224
+ roots: ['steps.build.outputs.ok'],
225
+ fill_target: 'job.condition',
226
+ evaluated_at: isoDate,
227
+ field: 'condition',
228
+ value: 'true',
229
+ },
230
+ ],
231
+ execution_evaluation_trace: null,
232
+ condition: 'steps.build.outputs.ok',
233
+ oversized_fields: [],
234
+ };
235
+ }
236
+
237
+ function stepResult() {
238
+ return {
239
+ workflow_run_id: runId,
240
+ workflow_run_attempt: 1,
241
+ job_id: jobId,
242
+ job_execution_id: executionId,
243
+ step_id: stepId,
244
+ step_attempt_id: stepAttemptId,
245
+ attempt: 1,
246
+ authored_config: {prompt: 'external data'},
247
+ config: null,
248
+ session: null,
249
+ evaluation_trace: null,
250
+ output: {value: 1},
251
+ outputs: {answer: 42},
252
+ response: 'done',
253
+ error: {message: 'tool failed', reason: 'tool_error' as const, category: 'user' as const},
254
+ gate_result: {kind: 'passed' as const, passed: true, source: 'test', exit_code: 0},
255
+ invocations: [{call_index: 0, started_at: isoDate}],
256
+ restart_feedback: null,
257
+ oversized_fields: [],
258
+ };
259
+ }
260
+
261
+ function explanationsResult() {
262
+ return {
263
+ workflow_run_id: runId,
264
+ workflow_run_attempt: 1,
265
+ explanations: [
266
+ {
267
+ job_id: jobId,
268
+ job_label: 'Build',
269
+ job_position: 0,
270
+ status: 'failed' as const,
271
+ status_reason: 'condition_errored',
272
+ evaluation_trace: null,
273
+ },
274
+ ],
275
+ next_cursor: null,
276
+ };
277
+ }