@shipfox/api-agent-access-dto 21.0.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.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-type.log +0 -1
- package/CHANGELOG.md +8 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/schemas/diagnostic-tools.d.ts.map +1 -1
- package/dist/schemas/diagnostic-tools.js +1 -6
- package/dist/schemas/diagnostic-tools.js.map +1 -1
- package/dist/schemas/log-tools.d.ts +215 -0
- package/dist/schemas/log-tools.d.ts.map +1 -0
- package/dist/schemas/log-tools.js +224 -0
- package/dist/schemas/log-tools.js.map +1 -0
- package/dist/schemas/paged-tools.d.ts.map +1 -1
- package/dist/schemas/paged-tools.js +1 -6
- package/dist/schemas/paged-tools.js.map +1 -1
- package/dist/schemas/primitives.d.ts +5 -0
- package/dist/schemas/primitives.d.ts.map +1 -0
- package/dist/schemas/primitives.js +9 -0
- package/dist/schemas/primitives.js.map +1 -0
- package/dist/schemas/workflow-diagnostics.d.ts +862 -0
- package/dist/schemas/workflow-diagnostics.d.ts.map +1 -0
- package/dist/schemas/workflow-diagnostics.js +876 -0
- package/dist/schemas/workflow-diagnostics.js.map +1 -0
- package/dist/schemas/workflow-tools.d.ts +1305 -0
- package/dist/schemas/workflow-tools.d.ts.map +1 -0
- package/dist/schemas/workflow-tools.js +938 -0
- package/dist/schemas/workflow-tools.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/index.ts +96 -0
- package/src/schemas/diagnostic-tools.ts +1 -12
- package/src/schemas/log-tools.ts +209 -0
- package/src/schemas/paged-tools.ts +1 -10
- package/src/schemas/primitives.ts +14 -0
- package/src/schemas/workflow-diagnostics.test.ts +277 -0
- package/src/schemas/workflow-diagnostics.ts +693 -0
- package/src/schemas/workflow-tools.test.ts +202 -0
- package/src/schemas/workflow-tools.ts +738 -0
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
import {z} from 'zod';
|
|
2
|
+
import type {AgentAccessObjectSchema} from './envelope.js';
|
|
3
|
+
import {AGENT_ACCESS_PAGE_LIMIT_MAX, AGENT_ACCESS_TEXT_MAX_BYTES} from './paged-tools.js';
|
|
4
|
+
import {dateTimeSchema, idSchema, utf8CappedString} from './primitives.js';
|
|
5
|
+
|
|
6
|
+
export const AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX = 2_147_483_647;
|
|
7
|
+
export const AGENT_ACCESS_WORKFLOW_RUN_ATTEMPT_PAGE_LIMIT = 25;
|
|
8
|
+
export const AGENT_ACCESS_WORKFLOW_JOB_PAGE_LIMIT = 100;
|
|
9
|
+
export const AGENT_ACCESS_WORKFLOW_EXECUTION_PAGE_LIMIT = 25;
|
|
10
|
+
export const AGENT_ACCESS_WORKFLOW_STEP_PAGE_LIMIT = 100;
|
|
11
|
+
export const AGENT_ACCESS_WORKFLOW_STEP_ATTEMPT_PAGE_LIMIT = 25;
|
|
12
|
+
export const AGENT_ACCESS_WORKFLOW_EXECUTION_COUNT_MAX = 100;
|
|
13
|
+
|
|
14
|
+
const textSchema = utf8CappedString(AGENT_ACCESS_TEXT_MAX_BYTES);
|
|
15
|
+
const attemptSchema = z.number().int().min(1).max(AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX);
|
|
16
|
+
const pageInput = (defaultLimit: number) => ({
|
|
17
|
+
limit: z.number().int().min(1).max(AGENT_ACCESS_PAGE_LIMIT_MAX).default(defaultLimit),
|
|
18
|
+
cursor: z.string().min(1).optional(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const getWorkflowRunInputSchema = z
|
|
22
|
+
.object({run_id: idSchema, attempt: attemptSchema.optional()})
|
|
23
|
+
.strict();
|
|
24
|
+
|
|
25
|
+
export const listWorkflowRunAttemptsInputSchema = z
|
|
26
|
+
.object({run_id: idSchema, ...pageInput(AGENT_ACCESS_WORKFLOW_RUN_ATTEMPT_PAGE_LIMIT)})
|
|
27
|
+
.strict();
|
|
28
|
+
|
|
29
|
+
export const listWorkflowRunJobsInputSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
run_id: idSchema,
|
|
32
|
+
attempt: attemptSchema,
|
|
33
|
+
...pageInput(AGENT_ACCESS_WORKFLOW_JOB_PAGE_LIMIT),
|
|
34
|
+
})
|
|
35
|
+
.strict();
|
|
36
|
+
|
|
37
|
+
export const getWorkflowJobInputSchema = z
|
|
38
|
+
.object({job_id: idSchema, execution_id: idSchema.optional()})
|
|
39
|
+
.strict();
|
|
40
|
+
|
|
41
|
+
export const listWorkflowJobExecutionsInputSchema = z
|
|
42
|
+
.object({job_id: idSchema, ...pageInput(AGENT_ACCESS_WORKFLOW_EXECUTION_PAGE_LIMIT)})
|
|
43
|
+
.strict();
|
|
44
|
+
|
|
45
|
+
export const listWorkflowExecutionStepsInputSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
job_id: idSchema,
|
|
48
|
+
execution_id: idSchema,
|
|
49
|
+
...pageInput(AGENT_ACCESS_WORKFLOW_STEP_PAGE_LIMIT),
|
|
50
|
+
})
|
|
51
|
+
.strict();
|
|
52
|
+
|
|
53
|
+
export const listWorkflowStepAttemptsInputSchema = z
|
|
54
|
+
.object({step_id: idSchema, ...pageInput(AGENT_ACCESS_WORKFLOW_STEP_ATTEMPT_PAGE_LIMIT)})
|
|
55
|
+
.strict();
|
|
56
|
+
|
|
57
|
+
export type GetWorkflowRunInputDto = z.output<typeof getWorkflowRunInputSchema>;
|
|
58
|
+
export type ListWorkflowRunAttemptsInputDto = z.output<typeof listWorkflowRunAttemptsInputSchema>;
|
|
59
|
+
export type ListWorkflowRunJobsInputDto = z.output<typeof listWorkflowRunJobsInputSchema>;
|
|
60
|
+
export type GetWorkflowJobInputDto = z.output<typeof getWorkflowJobInputSchema>;
|
|
61
|
+
export type ListWorkflowJobExecutionsInputDto = z.output<
|
|
62
|
+
typeof listWorkflowJobExecutionsInputSchema
|
|
63
|
+
>;
|
|
64
|
+
export type ListWorkflowExecutionStepsInputDto = z.output<
|
|
65
|
+
typeof listWorkflowExecutionStepsInputSchema
|
|
66
|
+
>;
|
|
67
|
+
export type ListWorkflowStepAttemptsInputDto = z.output<typeof listWorkflowStepAttemptsInputSchema>;
|
|
68
|
+
|
|
69
|
+
const workflowRunStatusSchema = z.enum(['pending', 'running', 'succeeded', 'failed', 'cancelled']);
|
|
70
|
+
const workflowRunOriginSchema = z.enum(['synced', 'dev']);
|
|
71
|
+
const workflowRunRerunModeSchema = z.enum(['all', 'failed']);
|
|
72
|
+
const jobStatusSchema = z.enum([
|
|
73
|
+
'pending',
|
|
74
|
+
'running',
|
|
75
|
+
'succeeded',
|
|
76
|
+
'failed',
|
|
77
|
+
'cancelled',
|
|
78
|
+
'skipped',
|
|
79
|
+
]);
|
|
80
|
+
const jobStatusReasonSchema = z.enum([
|
|
81
|
+
'dependency_not_completed',
|
|
82
|
+
'condition_false',
|
|
83
|
+
'default_gate_rejected',
|
|
84
|
+
'condition_rejected',
|
|
85
|
+
'condition_errored',
|
|
86
|
+
'user_cancelled',
|
|
87
|
+
'run_cancelled',
|
|
88
|
+
'timed_out',
|
|
89
|
+
'runner_lost',
|
|
90
|
+
'output_too_large',
|
|
91
|
+
'step_failed',
|
|
92
|
+
'unknown',
|
|
93
|
+
'output_invalid',
|
|
94
|
+
]);
|
|
95
|
+
const jobModeSchema = z.enum(['one_shot', 'listening']);
|
|
96
|
+
const listenerStatusSchema = z.enum(['inactive', 'listening', 'resolved']);
|
|
97
|
+
const executionStatusSchema = z.enum(['pending', 'running', 'succeeded', 'failed', 'cancelled']);
|
|
98
|
+
const stepStatusSchema = jobStatusSchema;
|
|
99
|
+
const stepTypeSchema = z.enum(['setup', 'run', 'agent', 'checkout', 'tool']);
|
|
100
|
+
const stepStatusReasonSchema = z.enum([
|
|
101
|
+
'default_gate_rejected',
|
|
102
|
+
'condition_rejected',
|
|
103
|
+
'condition_errored',
|
|
104
|
+
]);
|
|
105
|
+
const boundedExecutionCountSchema = z.union([
|
|
106
|
+
z.number().int().nonnegative().max(AGENT_ACCESS_WORKFLOW_EXECUTION_COUNT_MAX),
|
|
107
|
+
z.literal('100+'),
|
|
108
|
+
]);
|
|
109
|
+
|
|
110
|
+
const workflowRunAttemptResultSchema = z
|
|
111
|
+
.object({
|
|
112
|
+
id: idSchema,
|
|
113
|
+
workflow_run_id: idSchema,
|
|
114
|
+
attempt: attemptSchema,
|
|
115
|
+
status: workflowRunStatusSchema,
|
|
116
|
+
created_at: dateTimeSchema,
|
|
117
|
+
started_at: dateTimeSchema.nullable(),
|
|
118
|
+
finished_at: dateTimeSchema.nullable(),
|
|
119
|
+
rerun_mode: workflowRunRerunModeSchema.nullable(),
|
|
120
|
+
})
|
|
121
|
+
.strict();
|
|
122
|
+
|
|
123
|
+
const workflowRunDevSourceSchema = z
|
|
124
|
+
.object({
|
|
125
|
+
ref: textSchema,
|
|
126
|
+
commit: textSchema,
|
|
127
|
+
config_path: textSchema,
|
|
128
|
+
initiated_by_user_id: idSchema,
|
|
129
|
+
replay_of_event_id: idSchema.nullable(),
|
|
130
|
+
})
|
|
131
|
+
.strict();
|
|
132
|
+
|
|
133
|
+
const workflowRunTriggerReferenceSchema = z
|
|
134
|
+
.object({
|
|
135
|
+
repository: textSchema.nullable(),
|
|
136
|
+
ref: textSchema.nullable(),
|
|
137
|
+
commit: textSchema.nullable(),
|
|
138
|
+
actor: textSchema.nullable(),
|
|
139
|
+
})
|
|
140
|
+
.strict();
|
|
141
|
+
|
|
142
|
+
const jobExecutionSummarySchema = z
|
|
143
|
+
.object({
|
|
144
|
+
id: idSchema,
|
|
145
|
+
sequence: z.number().int().positive(),
|
|
146
|
+
name: textSchema,
|
|
147
|
+
status: executionStatusSchema,
|
|
148
|
+
display_status: executionStatusSchema,
|
|
149
|
+
status_reason: jobStatusReasonSchema.nullable(),
|
|
150
|
+
status_reason_message: textSchema.nullable(),
|
|
151
|
+
queued_at: dateTimeSchema.nullable(),
|
|
152
|
+
started_at: dateTimeSchema.nullable(),
|
|
153
|
+
finished_at: dateTimeSchema.nullable(),
|
|
154
|
+
timed_out_at: dateTimeSchema.nullable(),
|
|
155
|
+
updated_at: dateTimeSchema,
|
|
156
|
+
})
|
|
157
|
+
.strict();
|
|
158
|
+
|
|
159
|
+
const jobExecutionStatusCountsSchema = z
|
|
160
|
+
.object({
|
|
161
|
+
pending: boundedExecutionCountSchema,
|
|
162
|
+
running: boundedExecutionCountSchema,
|
|
163
|
+
succeeded: boundedExecutionCountSchema,
|
|
164
|
+
failed: boundedExecutionCountSchema,
|
|
165
|
+
cancelled: boundedExecutionCountSchema,
|
|
166
|
+
})
|
|
167
|
+
.strict();
|
|
168
|
+
|
|
169
|
+
const workflowJobSummarySchema = z
|
|
170
|
+
.object({
|
|
171
|
+
id: idSchema,
|
|
172
|
+
key: textSchema,
|
|
173
|
+
name: textSchema.nullable(),
|
|
174
|
+
position: z.number().int().nonnegative(),
|
|
175
|
+
status: jobStatusSchema,
|
|
176
|
+
status_reason: jobStatusReasonSchema.nullable(),
|
|
177
|
+
mode: jobModeSchema,
|
|
178
|
+
listener_status: listenerStatusSchema,
|
|
179
|
+
carried_over: z.boolean(),
|
|
180
|
+
execution_count: boundedExecutionCountSchema,
|
|
181
|
+
execution_status_counts: jobExecutionStatusCountsSchema,
|
|
182
|
+
default_execution: jobExecutionSummarySchema.nullable(),
|
|
183
|
+
})
|
|
184
|
+
.strict();
|
|
185
|
+
|
|
186
|
+
const workflowRunJobStatusCountSchema = z
|
|
187
|
+
.object({status: jobStatusSchema, count: z.number().int().positive()})
|
|
188
|
+
.strict();
|
|
189
|
+
|
|
190
|
+
/** Compact run data used to start traversal; it deliberately has no jobs field. */
|
|
191
|
+
export const getWorkflowRunResultSchema = z
|
|
192
|
+
.object({
|
|
193
|
+
id: idSchema,
|
|
194
|
+
project_id: idSchema,
|
|
195
|
+
definition_id: idSchema,
|
|
196
|
+
number: z.number().int().positive(),
|
|
197
|
+
name: textSchema,
|
|
198
|
+
workflow_name: textSchema,
|
|
199
|
+
status: workflowRunStatusSchema,
|
|
200
|
+
origin: workflowRunOriginSchema,
|
|
201
|
+
dev_source: workflowRunDevSourceSchema.nullable(),
|
|
202
|
+
trigger_provider: textSchema.nullable(),
|
|
203
|
+
trigger_source: textSchema,
|
|
204
|
+
trigger_event: textSchema,
|
|
205
|
+
trigger_reference: workflowRunTriggerReferenceSchema.nullable(),
|
|
206
|
+
created_at: dateTimeSchema,
|
|
207
|
+
started_at: dateTimeSchema.nullable(),
|
|
208
|
+
finished_at: dateTimeSchema.nullable(),
|
|
209
|
+
attempt: workflowRunAttemptResultSchema,
|
|
210
|
+
job_status_counts: z.array(workflowRunJobStatusCountSchema),
|
|
211
|
+
has_started_job_execution: z.boolean(),
|
|
212
|
+
})
|
|
213
|
+
.strict();
|
|
214
|
+
|
|
215
|
+
export type GetWorkflowRunResultDto = z.infer<typeof getWorkflowRunResultSchema>;
|
|
216
|
+
|
|
217
|
+
export const listWorkflowRunAttemptsResultSchema = z
|
|
218
|
+
.object({
|
|
219
|
+
attempts: z.array(workflowRunAttemptResultSchema).max(AGENT_ACCESS_PAGE_LIMIT_MAX),
|
|
220
|
+
next_cursor: z.string().nullable(),
|
|
221
|
+
})
|
|
222
|
+
.strict();
|
|
223
|
+
|
|
224
|
+
export type ListWorkflowRunAttemptsResultDto = z.infer<typeof listWorkflowRunAttemptsResultSchema>;
|
|
225
|
+
|
|
226
|
+
export const listWorkflowRunJobsResultSchema = z
|
|
227
|
+
.object({
|
|
228
|
+
workflow_run_id: idSchema,
|
|
229
|
+
workflow_run_attempt: attemptSchema,
|
|
230
|
+
jobs: z.array(workflowJobSummarySchema).max(AGENT_ACCESS_PAGE_LIMIT_MAX),
|
|
231
|
+
next_cursor: z.string().nullable(),
|
|
232
|
+
total: z.number().int().nonnegative().optional(),
|
|
233
|
+
})
|
|
234
|
+
.strict();
|
|
235
|
+
|
|
236
|
+
export type ListWorkflowRunJobsResultDto = z.infer<typeof listWorkflowRunJobsResultSchema>;
|
|
237
|
+
|
|
238
|
+
const selectedExecutionSummarySchema = jobExecutionSummarySchema
|
|
239
|
+
.extend({has_context: z.boolean()})
|
|
240
|
+
.strict();
|
|
241
|
+
|
|
242
|
+
export const getWorkflowJobResultSchema = z
|
|
243
|
+
.object({
|
|
244
|
+
workflow_run_id: idSchema,
|
|
245
|
+
workflow_run_attempt: attemptSchema,
|
|
246
|
+
job: workflowJobSummarySchema,
|
|
247
|
+
selected_execution: selectedExecutionSummarySchema.nullable(),
|
|
248
|
+
})
|
|
249
|
+
.strict();
|
|
250
|
+
|
|
251
|
+
export type GetWorkflowJobResultDto = z.infer<typeof getWorkflowJobResultSchema>;
|
|
252
|
+
|
|
253
|
+
export const listWorkflowJobExecutionsResultSchema = z
|
|
254
|
+
.object({
|
|
255
|
+
job_id: idSchema,
|
|
256
|
+
executions: z.array(jobExecutionSummarySchema).max(AGENT_ACCESS_PAGE_LIMIT_MAX),
|
|
257
|
+
next_cursor: z.string().nullable(),
|
|
258
|
+
total: boundedExecutionCountSchema.optional(),
|
|
259
|
+
})
|
|
260
|
+
.strict();
|
|
261
|
+
|
|
262
|
+
export type ListWorkflowJobExecutionsResultDto = z.infer<
|
|
263
|
+
typeof listWorkflowJobExecutionsResultSchema
|
|
264
|
+
>;
|
|
265
|
+
|
|
266
|
+
const workflowStepSummarySchema = z
|
|
267
|
+
.object({
|
|
268
|
+
id: idSchema,
|
|
269
|
+
key: textSchema.nullable(),
|
|
270
|
+
name: textSchema,
|
|
271
|
+
type: stepTypeSchema,
|
|
272
|
+
position: z.number().int().nonnegative(),
|
|
273
|
+
status: stepStatusSchema,
|
|
274
|
+
status_reason: stepStatusReasonSchema.nullable(),
|
|
275
|
+
current_attempt: attemptSchema,
|
|
276
|
+
})
|
|
277
|
+
.strict();
|
|
278
|
+
|
|
279
|
+
export const listWorkflowExecutionStepsResultSchema = z
|
|
280
|
+
.object({
|
|
281
|
+
job_id: idSchema,
|
|
282
|
+
execution_id: idSchema,
|
|
283
|
+
steps: z.array(workflowStepSummarySchema).max(AGENT_ACCESS_PAGE_LIMIT_MAX),
|
|
284
|
+
next_cursor: z.string().nullable(),
|
|
285
|
+
total: z.number().int().nonnegative().optional(),
|
|
286
|
+
})
|
|
287
|
+
.strict();
|
|
288
|
+
|
|
289
|
+
export type ListWorkflowExecutionStepsResultDto = z.infer<
|
|
290
|
+
typeof listWorkflowExecutionStepsResultSchema
|
|
291
|
+
>;
|
|
292
|
+
|
|
293
|
+
const workflowStepAttemptSummarySchema = z
|
|
294
|
+
.object({
|
|
295
|
+
id: idSchema,
|
|
296
|
+
attempt: attemptSchema,
|
|
297
|
+
execution_order: z.number().int().positive(),
|
|
298
|
+
status: stepStatusSchema,
|
|
299
|
+
exit_code: z.number().int().nullable(),
|
|
300
|
+
started_at: dateTimeSchema,
|
|
301
|
+
finished_at: dateTimeSchema.nullable(),
|
|
302
|
+
})
|
|
303
|
+
.strict();
|
|
304
|
+
|
|
305
|
+
export const listWorkflowStepAttemptsResultSchema = z
|
|
306
|
+
.object({
|
|
307
|
+
step_id: idSchema,
|
|
308
|
+
attempts: z.array(workflowStepAttemptSummarySchema).max(AGENT_ACCESS_PAGE_LIMIT_MAX),
|
|
309
|
+
next_cursor: z.string().nullable(),
|
|
310
|
+
total: z.number().int().nonnegative().optional(),
|
|
311
|
+
})
|
|
312
|
+
.strict();
|
|
313
|
+
|
|
314
|
+
export type ListWorkflowStepAttemptsResultDto = z.infer<
|
|
315
|
+
typeof listWorkflowStepAttemptsResultSchema
|
|
316
|
+
>;
|
|
317
|
+
|
|
318
|
+
const uuid = {type: 'string', format: 'uuid'} as const;
|
|
319
|
+
const dateTime = {type: 'string', format: 'date-time'} as const;
|
|
320
|
+
const text = {type: 'string', maxLength: AGENT_ACCESS_TEXT_MAX_BYTES} as const;
|
|
321
|
+
const nullable = (schema: Record<string, unknown>) => ({anyOf: [schema, {type: 'null'}]}) as const;
|
|
322
|
+
const pageInputJson = (defaultLimit: number) => ({
|
|
323
|
+
limit: {
|
|
324
|
+
type: 'integer',
|
|
325
|
+
minimum: 1,
|
|
326
|
+
maximum: AGENT_ACCESS_PAGE_LIMIT_MAX,
|
|
327
|
+
default: defaultLimit,
|
|
328
|
+
},
|
|
329
|
+
cursor: {type: 'string', minLength: 1},
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
export const getWorkflowRunInputJsonSchema = {
|
|
333
|
+
type: 'object',
|
|
334
|
+
properties: {
|
|
335
|
+
run_id: uuid,
|
|
336
|
+
attempt: {type: 'integer', minimum: 1, maximum: AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX},
|
|
337
|
+
},
|
|
338
|
+
required: ['run_id'],
|
|
339
|
+
additionalProperties: false,
|
|
340
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
341
|
+
|
|
342
|
+
export const listWorkflowRunAttemptsInputJsonSchema = {
|
|
343
|
+
type: 'object',
|
|
344
|
+
properties: {run_id: uuid, ...pageInputJson(AGENT_ACCESS_WORKFLOW_RUN_ATTEMPT_PAGE_LIMIT)},
|
|
345
|
+
required: ['run_id'],
|
|
346
|
+
additionalProperties: false,
|
|
347
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
348
|
+
|
|
349
|
+
export const listWorkflowRunJobsInputJsonSchema = {
|
|
350
|
+
type: 'object',
|
|
351
|
+
properties: {
|
|
352
|
+
run_id: uuid,
|
|
353
|
+
attempt: {type: 'integer', minimum: 1, maximum: AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX},
|
|
354
|
+
...pageInputJson(AGENT_ACCESS_WORKFLOW_JOB_PAGE_LIMIT),
|
|
355
|
+
},
|
|
356
|
+
required: ['run_id', 'attempt'],
|
|
357
|
+
additionalProperties: false,
|
|
358
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
359
|
+
|
|
360
|
+
export const getWorkflowJobInputJsonSchema = {
|
|
361
|
+
type: 'object',
|
|
362
|
+
properties: {job_id: uuid, execution_id: uuid},
|
|
363
|
+
required: ['job_id'],
|
|
364
|
+
additionalProperties: false,
|
|
365
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
366
|
+
|
|
367
|
+
export const listWorkflowJobExecutionsInputJsonSchema = {
|
|
368
|
+
type: 'object',
|
|
369
|
+
properties: {job_id: uuid, ...pageInputJson(AGENT_ACCESS_WORKFLOW_EXECUTION_PAGE_LIMIT)},
|
|
370
|
+
required: ['job_id'],
|
|
371
|
+
additionalProperties: false,
|
|
372
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
373
|
+
|
|
374
|
+
export const listWorkflowExecutionStepsInputJsonSchema = {
|
|
375
|
+
type: 'object',
|
|
376
|
+
properties: {
|
|
377
|
+
job_id: uuid,
|
|
378
|
+
execution_id: uuid,
|
|
379
|
+
...pageInputJson(AGENT_ACCESS_WORKFLOW_STEP_PAGE_LIMIT),
|
|
380
|
+
},
|
|
381
|
+
required: ['job_id', 'execution_id'],
|
|
382
|
+
additionalProperties: false,
|
|
383
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
384
|
+
|
|
385
|
+
export const listWorkflowStepAttemptsInputJsonSchema = {
|
|
386
|
+
type: 'object',
|
|
387
|
+
properties: {step_id: uuid, ...pageInputJson(AGENT_ACCESS_WORKFLOW_STEP_ATTEMPT_PAGE_LIMIT)},
|
|
388
|
+
required: ['step_id'],
|
|
389
|
+
additionalProperties: false,
|
|
390
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
391
|
+
|
|
392
|
+
const workflowRunAttemptJsonSchema = {
|
|
393
|
+
type: 'object',
|
|
394
|
+
properties: {
|
|
395
|
+
id: uuid,
|
|
396
|
+
workflow_run_id: uuid,
|
|
397
|
+
attempt: {type: 'integer', minimum: 1, maximum: AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX},
|
|
398
|
+
status: {type: 'string', enum: ['pending', 'running', 'succeeded', 'failed', 'cancelled']},
|
|
399
|
+
created_at: dateTime,
|
|
400
|
+
started_at: nullable(dateTime),
|
|
401
|
+
finished_at: nullable(dateTime),
|
|
402
|
+
rerun_mode: nullable({type: 'string', enum: ['all', 'failed']}),
|
|
403
|
+
},
|
|
404
|
+
required: [
|
|
405
|
+
'id',
|
|
406
|
+
'workflow_run_id',
|
|
407
|
+
'attempt',
|
|
408
|
+
'status',
|
|
409
|
+
'created_at',
|
|
410
|
+
'started_at',
|
|
411
|
+
'finished_at',
|
|
412
|
+
'rerun_mode',
|
|
413
|
+
],
|
|
414
|
+
additionalProperties: false,
|
|
415
|
+
} as const;
|
|
416
|
+
|
|
417
|
+
const devSourceJsonSchema = {
|
|
418
|
+
type: 'object',
|
|
419
|
+
properties: {
|
|
420
|
+
ref: text,
|
|
421
|
+
commit: text,
|
|
422
|
+
config_path: text,
|
|
423
|
+
initiated_by_user_id: uuid,
|
|
424
|
+
replay_of_event_id: nullable(uuid),
|
|
425
|
+
},
|
|
426
|
+
required: ['ref', 'commit', 'config_path', 'initiated_by_user_id', 'replay_of_event_id'],
|
|
427
|
+
additionalProperties: false,
|
|
428
|
+
} as const;
|
|
429
|
+
|
|
430
|
+
const triggerReferenceJsonSchema = {
|
|
431
|
+
type: 'object',
|
|
432
|
+
properties: {
|
|
433
|
+
repository: nullable(text),
|
|
434
|
+
ref: nullable(text),
|
|
435
|
+
commit: nullable(text),
|
|
436
|
+
actor: nullable(text),
|
|
437
|
+
},
|
|
438
|
+
required: ['repository', 'ref', 'commit', 'actor'],
|
|
439
|
+
additionalProperties: false,
|
|
440
|
+
} as const;
|
|
441
|
+
|
|
442
|
+
const executionStatusJsonSchema = {
|
|
443
|
+
type: 'string',
|
|
444
|
+
enum: ['pending', 'running', 'succeeded', 'failed', 'cancelled'],
|
|
445
|
+
} as const;
|
|
446
|
+
const boundedExecutionCountJsonSchema = {
|
|
447
|
+
anyOf: [
|
|
448
|
+
{type: 'integer', minimum: 0, maximum: AGENT_ACCESS_WORKFLOW_EXECUTION_COUNT_MAX},
|
|
449
|
+
{const: '100+'},
|
|
450
|
+
],
|
|
451
|
+
} as const;
|
|
452
|
+
const executionSummaryJsonSchema = {
|
|
453
|
+
type: 'object',
|
|
454
|
+
properties: {
|
|
455
|
+
id: uuid,
|
|
456
|
+
sequence: {type: 'integer', minimum: 1},
|
|
457
|
+
name: text,
|
|
458
|
+
status: executionStatusJsonSchema,
|
|
459
|
+
display_status: executionStatusJsonSchema,
|
|
460
|
+
status_reason: nullable({
|
|
461
|
+
type: 'string',
|
|
462
|
+
enum: [
|
|
463
|
+
'dependency_not_completed',
|
|
464
|
+
'condition_false',
|
|
465
|
+
'default_gate_rejected',
|
|
466
|
+
'condition_rejected',
|
|
467
|
+
'condition_errored',
|
|
468
|
+
'user_cancelled',
|
|
469
|
+
'run_cancelled',
|
|
470
|
+
'timed_out',
|
|
471
|
+
'runner_lost',
|
|
472
|
+
'output_too_large',
|
|
473
|
+
'step_failed',
|
|
474
|
+
'unknown',
|
|
475
|
+
'output_invalid',
|
|
476
|
+
],
|
|
477
|
+
}),
|
|
478
|
+
status_reason_message: nullable(text),
|
|
479
|
+
queued_at: nullable(dateTime),
|
|
480
|
+
started_at: nullable(dateTime),
|
|
481
|
+
finished_at: nullable(dateTime),
|
|
482
|
+
timed_out_at: nullable(dateTime),
|
|
483
|
+
updated_at: dateTime,
|
|
484
|
+
},
|
|
485
|
+
required: [
|
|
486
|
+
'id',
|
|
487
|
+
'sequence',
|
|
488
|
+
'name',
|
|
489
|
+
'status',
|
|
490
|
+
'display_status',
|
|
491
|
+
'status_reason',
|
|
492
|
+
'status_reason_message',
|
|
493
|
+
'queued_at',
|
|
494
|
+
'started_at',
|
|
495
|
+
'finished_at',
|
|
496
|
+
'timed_out_at',
|
|
497
|
+
'updated_at',
|
|
498
|
+
],
|
|
499
|
+
additionalProperties: false,
|
|
500
|
+
} as const;
|
|
501
|
+
const executionCountsJsonSchema = {
|
|
502
|
+
type: 'object',
|
|
503
|
+
properties: {
|
|
504
|
+
pending: boundedExecutionCountJsonSchema,
|
|
505
|
+
running: boundedExecutionCountJsonSchema,
|
|
506
|
+
succeeded: boundedExecutionCountJsonSchema,
|
|
507
|
+
failed: boundedExecutionCountJsonSchema,
|
|
508
|
+
cancelled: boundedExecutionCountJsonSchema,
|
|
509
|
+
},
|
|
510
|
+
required: ['pending', 'running', 'succeeded', 'failed', 'cancelled'],
|
|
511
|
+
additionalProperties: false,
|
|
512
|
+
} as const;
|
|
513
|
+
const jobStatusJsonSchema = {
|
|
514
|
+
type: 'string',
|
|
515
|
+
enum: ['pending', 'running', 'succeeded', 'failed', 'cancelled', 'skipped'],
|
|
516
|
+
} as const;
|
|
517
|
+
const jobReasonJsonSchema = nullable({
|
|
518
|
+
type: 'string',
|
|
519
|
+
enum: [
|
|
520
|
+
'dependency_not_completed',
|
|
521
|
+
'condition_false',
|
|
522
|
+
'default_gate_rejected',
|
|
523
|
+
'condition_rejected',
|
|
524
|
+
'condition_errored',
|
|
525
|
+
'user_cancelled',
|
|
526
|
+
'run_cancelled',
|
|
527
|
+
'timed_out',
|
|
528
|
+
'runner_lost',
|
|
529
|
+
'output_too_large',
|
|
530
|
+
'step_failed',
|
|
531
|
+
'unknown',
|
|
532
|
+
'output_invalid',
|
|
533
|
+
],
|
|
534
|
+
});
|
|
535
|
+
const jobSummaryJsonSchema = {
|
|
536
|
+
type: 'object',
|
|
537
|
+
properties: {
|
|
538
|
+
id: uuid,
|
|
539
|
+
key: text,
|
|
540
|
+
name: nullable(text),
|
|
541
|
+
position: {type: 'integer', minimum: 0},
|
|
542
|
+
status: jobStatusJsonSchema,
|
|
543
|
+
status_reason: jobReasonJsonSchema,
|
|
544
|
+
mode: {type: 'string', enum: ['one_shot', 'listening']},
|
|
545
|
+
listener_status: {type: 'string', enum: ['inactive', 'listening', 'resolved']},
|
|
546
|
+
carried_over: {type: 'boolean'},
|
|
547
|
+
execution_count: boundedExecutionCountJsonSchema,
|
|
548
|
+
execution_status_counts: executionCountsJsonSchema,
|
|
549
|
+
default_execution: nullable(executionSummaryJsonSchema),
|
|
550
|
+
},
|
|
551
|
+
required: [
|
|
552
|
+
'id',
|
|
553
|
+
'key',
|
|
554
|
+
'name',
|
|
555
|
+
'position',
|
|
556
|
+
'status',
|
|
557
|
+
'status_reason',
|
|
558
|
+
'mode',
|
|
559
|
+
'listener_status',
|
|
560
|
+
'carried_over',
|
|
561
|
+
'execution_count',
|
|
562
|
+
'execution_status_counts',
|
|
563
|
+
'default_execution',
|
|
564
|
+
],
|
|
565
|
+
additionalProperties: false,
|
|
566
|
+
} as const;
|
|
567
|
+
|
|
568
|
+
export const getWorkflowRunResultJsonSchema = {
|
|
569
|
+
type: 'object',
|
|
570
|
+
properties: {
|
|
571
|
+
id: uuid,
|
|
572
|
+
project_id: uuid,
|
|
573
|
+
definition_id: uuid,
|
|
574
|
+
number: {type: 'integer', minimum: 1},
|
|
575
|
+
name: text,
|
|
576
|
+
workflow_name: text,
|
|
577
|
+
status: {type: 'string', enum: ['pending', 'running', 'succeeded', 'failed', 'cancelled']},
|
|
578
|
+
origin: {type: 'string', enum: ['synced', 'dev']},
|
|
579
|
+
dev_source: nullable(devSourceJsonSchema),
|
|
580
|
+
trigger_provider: nullable(text),
|
|
581
|
+
trigger_source: text,
|
|
582
|
+
trigger_event: text,
|
|
583
|
+
trigger_reference: nullable(triggerReferenceJsonSchema),
|
|
584
|
+
created_at: dateTime,
|
|
585
|
+
started_at: nullable(dateTime),
|
|
586
|
+
finished_at: nullable(dateTime),
|
|
587
|
+
attempt: workflowRunAttemptJsonSchema,
|
|
588
|
+
job_status_counts: {
|
|
589
|
+
type: 'array',
|
|
590
|
+
items: {
|
|
591
|
+
type: 'object',
|
|
592
|
+
properties: {status: jobStatusJsonSchema, count: {type: 'integer', minimum: 1}},
|
|
593
|
+
required: ['status', 'count'],
|
|
594
|
+
additionalProperties: false,
|
|
595
|
+
},
|
|
596
|
+
},
|
|
597
|
+
has_started_job_execution: {type: 'boolean'},
|
|
598
|
+
},
|
|
599
|
+
required: [
|
|
600
|
+
'id',
|
|
601
|
+
'project_id',
|
|
602
|
+
'definition_id',
|
|
603
|
+
'number',
|
|
604
|
+
'name',
|
|
605
|
+
'workflow_name',
|
|
606
|
+
'status',
|
|
607
|
+
'origin',
|
|
608
|
+
'dev_source',
|
|
609
|
+
'trigger_provider',
|
|
610
|
+
'trigger_source',
|
|
611
|
+
'trigger_event',
|
|
612
|
+
'trigger_reference',
|
|
613
|
+
'created_at',
|
|
614
|
+
'started_at',
|
|
615
|
+
'finished_at',
|
|
616
|
+
'attempt',
|
|
617
|
+
'job_status_counts',
|
|
618
|
+
'has_started_job_execution',
|
|
619
|
+
],
|
|
620
|
+
additionalProperties: false,
|
|
621
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
622
|
+
|
|
623
|
+
const attemptsArrayJsonSchema = {type: 'array', items: workflowRunAttemptJsonSchema} as const;
|
|
624
|
+
export const listWorkflowRunAttemptsResultJsonSchema = {
|
|
625
|
+
type: 'object',
|
|
626
|
+
properties: {attempts: attemptsArrayJsonSchema, next_cursor: nullable({type: 'string'})},
|
|
627
|
+
required: ['attempts', 'next_cursor'],
|
|
628
|
+
additionalProperties: false,
|
|
629
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
630
|
+
|
|
631
|
+
const stepsJsonSchema = {
|
|
632
|
+
type: 'object',
|
|
633
|
+
properties: {
|
|
634
|
+
id: uuid,
|
|
635
|
+
key: nullable(text),
|
|
636
|
+
name: text,
|
|
637
|
+
type: {type: 'string', enum: ['setup', 'run', 'agent', 'checkout', 'tool']},
|
|
638
|
+
position: {type: 'integer', minimum: 0},
|
|
639
|
+
status: jobStatusJsonSchema,
|
|
640
|
+
status_reason: nullable({
|
|
641
|
+
type: 'string',
|
|
642
|
+
enum: ['default_gate_rejected', 'condition_rejected', 'condition_errored'],
|
|
643
|
+
}),
|
|
644
|
+
current_attempt: {type: 'integer', minimum: 1, maximum: AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX},
|
|
645
|
+
},
|
|
646
|
+
required: ['id', 'key', 'name', 'type', 'position', 'status', 'status_reason', 'current_attempt'],
|
|
647
|
+
additionalProperties: false,
|
|
648
|
+
} as const;
|
|
649
|
+
const stepAttemptsJsonSchema = {
|
|
650
|
+
type: 'object',
|
|
651
|
+
properties: {
|
|
652
|
+
id: uuid,
|
|
653
|
+
attempt: {type: 'integer', minimum: 1, maximum: AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX},
|
|
654
|
+
execution_order: {type: 'integer', minimum: 1},
|
|
655
|
+
status: jobStatusJsonSchema,
|
|
656
|
+
exit_code: nullable({type: 'integer'}),
|
|
657
|
+
started_at: dateTime,
|
|
658
|
+
finished_at: nullable(dateTime),
|
|
659
|
+
},
|
|
660
|
+
required: [
|
|
661
|
+
'id',
|
|
662
|
+
'attempt',
|
|
663
|
+
'execution_order',
|
|
664
|
+
'status',
|
|
665
|
+
'exit_code',
|
|
666
|
+
'started_at',
|
|
667
|
+
'finished_at',
|
|
668
|
+
],
|
|
669
|
+
additionalProperties: false,
|
|
670
|
+
} as const;
|
|
671
|
+
|
|
672
|
+
export const listWorkflowRunJobsResultJsonSchema = {
|
|
673
|
+
type: 'object',
|
|
674
|
+
properties: {
|
|
675
|
+
workflow_run_id: uuid,
|
|
676
|
+
workflow_run_attempt: {type: 'integer', minimum: 1, maximum: AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX},
|
|
677
|
+
jobs: {type: 'array', items: jobSummaryJsonSchema},
|
|
678
|
+
next_cursor: nullable({type: 'string'}),
|
|
679
|
+
total: {type: 'integer', minimum: 0},
|
|
680
|
+
},
|
|
681
|
+
required: ['workflow_run_id', 'workflow_run_attempt', 'jobs', 'next_cursor'],
|
|
682
|
+
additionalProperties: false,
|
|
683
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
684
|
+
|
|
685
|
+
const selectedExecutionJsonSchema = {
|
|
686
|
+
...executionSummaryJsonSchema,
|
|
687
|
+
properties: {...executionSummaryJsonSchema.properties, has_context: {type: 'boolean'}},
|
|
688
|
+
required: [...executionSummaryJsonSchema.required, 'has_context'],
|
|
689
|
+
} as const;
|
|
690
|
+
|
|
691
|
+
export const getWorkflowJobResultJsonSchema = {
|
|
692
|
+
type: 'object',
|
|
693
|
+
properties: {
|
|
694
|
+
workflow_run_id: uuid,
|
|
695
|
+
workflow_run_attempt: {type: 'integer', minimum: 1, maximum: AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX},
|
|
696
|
+
job: jobSummaryJsonSchema,
|
|
697
|
+
selected_execution: nullable(selectedExecutionJsonSchema),
|
|
698
|
+
},
|
|
699
|
+
required: ['workflow_run_id', 'workflow_run_attempt', 'job', 'selected_execution'],
|
|
700
|
+
additionalProperties: false,
|
|
701
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
702
|
+
|
|
703
|
+
export const listWorkflowJobExecutionsResultJsonSchema = {
|
|
704
|
+
type: 'object',
|
|
705
|
+
properties: {
|
|
706
|
+
job_id: uuid,
|
|
707
|
+
executions: {type: 'array', items: executionSummaryJsonSchema},
|
|
708
|
+
next_cursor: nullable({type: 'string'}),
|
|
709
|
+
total: boundedExecutionCountJsonSchema,
|
|
710
|
+
},
|
|
711
|
+
required: ['job_id', 'executions', 'next_cursor'],
|
|
712
|
+
additionalProperties: false,
|
|
713
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
714
|
+
|
|
715
|
+
export const listWorkflowExecutionStepsResultJsonSchema = {
|
|
716
|
+
type: 'object',
|
|
717
|
+
properties: {
|
|
718
|
+
job_id: uuid,
|
|
719
|
+
execution_id: uuid,
|
|
720
|
+
steps: {type: 'array', items: stepsJsonSchema},
|
|
721
|
+
next_cursor: nullable({type: 'string'}),
|
|
722
|
+
total: {type: 'integer', minimum: 0},
|
|
723
|
+
},
|
|
724
|
+
required: ['job_id', 'execution_id', 'steps', 'next_cursor'],
|
|
725
|
+
additionalProperties: false,
|
|
726
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
727
|
+
|
|
728
|
+
export const listWorkflowStepAttemptsResultJsonSchema = {
|
|
729
|
+
type: 'object',
|
|
730
|
+
properties: {
|
|
731
|
+
step_id: uuid,
|
|
732
|
+
attempts: {type: 'array', items: stepAttemptsJsonSchema},
|
|
733
|
+
next_cursor: nullable({type: 'string'}),
|
|
734
|
+
total: {type: 'integer', minimum: 0},
|
|
735
|
+
},
|
|
736
|
+
required: ['step_id', 'attempts', 'next_cursor'],
|
|
737
|
+
additionalProperties: false,
|
|
738
|
+
} as const satisfies AgentAccessObjectSchema;
|