@shipfox/api-agent-access-dto 21.0.0 → 21.2.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 +19 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/schemas/diagnostic-tools.d.ts +3 -1
- package/dist/schemas/diagnostic-tools.d.ts.map +1 -1
- package/dist/schemas/diagnostic-tools.js +7 -8
- 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-execution-events.d.ts +272 -0
- package/dist/schemas/workflow-execution-events.d.ts.map +1 -0
- package/dist/schemas/workflow-execution-events.js +250 -0
- package/dist/schemas/workflow-execution-events.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 +113 -0
- package/src/schemas/diagnostic-tools.test.ts +43 -0
- package/src/schemas/diagnostic-tools.ts +12 -14
- 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-execution-events.test.ts +126 -0
- package/src/schemas/workflow-execution-events.ts +217 -0
- package/src/schemas/workflow-tools.test.ts +202 -0
- package/src/schemas/workflow-tools.ts +738 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/api-agent-access-dto",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "21.
|
|
4
|
+
"version": "21.2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"zod": "^4.4.3"
|
|
34
|
+
"zod": "^4.4.3",
|
|
35
|
+
"@shipfox/api-logs-dto": "20.0.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@shipfox/biome": "1.10.1",
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,19 @@ export {
|
|
|
29
29
|
agentAccessErrorSchema,
|
|
30
30
|
agentAccessOutputSchema,
|
|
31
31
|
} from './schemas/envelope.js';
|
|
32
|
+
export {
|
|
33
|
+
AGENT_ACCESS_LOG_ATTEMPT_MAX,
|
|
34
|
+
AGENT_ACCESS_LOG_CONTENT_MAX_BYTES,
|
|
35
|
+
AGENT_ACCESS_LOG_SECTION_MAX_ITEMS,
|
|
36
|
+
AGENT_ACCESS_LOG_TAIL_LINES_DEFAULT,
|
|
37
|
+
AGENT_ACCESS_LOG_TAIL_LINES_MAX,
|
|
38
|
+
type GetStepLogsInputDto,
|
|
39
|
+
type GetStepLogsResultDto,
|
|
40
|
+
getStepLogsInputJsonSchema,
|
|
41
|
+
getStepLogsInputSchema,
|
|
42
|
+
getStepLogsResultJsonSchema,
|
|
43
|
+
getStepLogsResultSchema,
|
|
44
|
+
} from './schemas/log-tools.js';
|
|
32
45
|
export {
|
|
33
46
|
AGENT_ACCESS_ANNOTATION_BODY_MAX_BYTES,
|
|
34
47
|
AGENT_ACCESS_CONNECTION_NAME_MAX_BYTES,
|
|
@@ -71,3 +84,103 @@ export {
|
|
|
71
84
|
listWorkflowRunsResultJsonSchema,
|
|
72
85
|
listWorkflowRunsResultSchema,
|
|
73
86
|
} from './schemas/paged-tools.js';
|
|
87
|
+
export {
|
|
88
|
+
AGENT_ACCESS_WORKFLOW_DIAGNOSTIC_VALUE_MAX_BYTES,
|
|
89
|
+
AGENT_ACCESS_WORKFLOW_SOURCE_MAX_BYTES,
|
|
90
|
+
type AgentAccessOversizedFieldDto,
|
|
91
|
+
type AgentAccessWorkflowDiagnosticFieldDto,
|
|
92
|
+
agentAccessOversizedFieldSchema,
|
|
93
|
+
agentAccessWorkflowDiagnosticFieldSchema,
|
|
94
|
+
type GetStepAttemptInputDto,
|
|
95
|
+
type GetStepAttemptResultDto,
|
|
96
|
+
type GetWorkflowExecutionContextInputDto,
|
|
97
|
+
type GetWorkflowExecutionContextResultDto,
|
|
98
|
+
type GetWorkflowRunSourceInputDto,
|
|
99
|
+
type GetWorkflowRunSourceResultDto,
|
|
100
|
+
getStepAttemptInputJsonSchema,
|
|
101
|
+
getStepAttemptInputSchema,
|
|
102
|
+
getStepAttemptResultJsonSchema,
|
|
103
|
+
getStepAttemptResultSchema,
|
|
104
|
+
getWorkflowExecutionContextInputJsonSchema,
|
|
105
|
+
getWorkflowExecutionContextInputSchema,
|
|
106
|
+
getWorkflowExecutionContextResultJsonSchema,
|
|
107
|
+
getWorkflowExecutionContextResultSchema,
|
|
108
|
+
getWorkflowRunSourceInputJsonSchema,
|
|
109
|
+
getWorkflowRunSourceInputSchema,
|
|
110
|
+
getWorkflowRunSourceResultJsonSchema,
|
|
111
|
+
getWorkflowRunSourceResultSchema,
|
|
112
|
+
type ListWorkflowRunJobExplanationsInputDto,
|
|
113
|
+
type ListWorkflowRunJobExplanationsResultDto,
|
|
114
|
+
listWorkflowRunJobExplanationsInputJsonSchema,
|
|
115
|
+
listWorkflowRunJobExplanationsInputSchema,
|
|
116
|
+
listWorkflowRunJobExplanationsResultJsonSchema,
|
|
117
|
+
listWorkflowRunJobExplanationsResultSchema,
|
|
118
|
+
} from './schemas/workflow-diagnostics.js';
|
|
119
|
+
export {
|
|
120
|
+
AGENT_ACCESS_EXECUTION_TRIGGER_EVENT_PAGE_LIMIT,
|
|
121
|
+
AGENT_ACCESS_EXECUTION_TRIGGER_EVENT_PAGE_MAX,
|
|
122
|
+
AGENT_ACCESS_EXECUTION_TRIGGER_EVENT_PREVIEW_MAX_BYTES,
|
|
123
|
+
type GetExecutionTriggerEventInputDto,
|
|
124
|
+
type GetExecutionTriggerEventResultDto,
|
|
125
|
+
getExecutionTriggerEventInputJsonSchema,
|
|
126
|
+
getExecutionTriggerEventInputSchema,
|
|
127
|
+
getExecutionTriggerEventResultJsonSchema,
|
|
128
|
+
getExecutionTriggerEventResultSchema,
|
|
129
|
+
type ListExecutionTriggerEventsInputDto,
|
|
130
|
+
type ListExecutionTriggerEventsResultDto,
|
|
131
|
+
listExecutionTriggerEventsInputJsonSchema,
|
|
132
|
+
listExecutionTriggerEventsInputSchema,
|
|
133
|
+
listExecutionTriggerEventsResultJsonSchema,
|
|
134
|
+
listExecutionTriggerEventsResultSchema,
|
|
135
|
+
} from './schemas/workflow-execution-events.js';
|
|
136
|
+
export {
|
|
137
|
+
AGENT_ACCESS_WORKFLOW_ATTEMPT_MAX,
|
|
138
|
+
AGENT_ACCESS_WORKFLOW_EXECUTION_COUNT_MAX,
|
|
139
|
+
AGENT_ACCESS_WORKFLOW_EXECUTION_PAGE_LIMIT,
|
|
140
|
+
AGENT_ACCESS_WORKFLOW_JOB_PAGE_LIMIT,
|
|
141
|
+
AGENT_ACCESS_WORKFLOW_RUN_ATTEMPT_PAGE_LIMIT,
|
|
142
|
+
AGENT_ACCESS_WORKFLOW_STEP_ATTEMPT_PAGE_LIMIT,
|
|
143
|
+
AGENT_ACCESS_WORKFLOW_STEP_PAGE_LIMIT,
|
|
144
|
+
type GetWorkflowJobInputDto,
|
|
145
|
+
type GetWorkflowJobResultDto,
|
|
146
|
+
type GetWorkflowRunInputDto,
|
|
147
|
+
type GetWorkflowRunResultDto,
|
|
148
|
+
getWorkflowJobInputJsonSchema,
|
|
149
|
+
getWorkflowJobInputSchema,
|
|
150
|
+
getWorkflowJobResultJsonSchema,
|
|
151
|
+
getWorkflowJobResultSchema,
|
|
152
|
+
getWorkflowRunInputJsonSchema,
|
|
153
|
+
getWorkflowRunInputSchema,
|
|
154
|
+
getWorkflowRunResultJsonSchema,
|
|
155
|
+
getWorkflowRunResultSchema,
|
|
156
|
+
type ListWorkflowExecutionStepsInputDto,
|
|
157
|
+
type ListWorkflowExecutionStepsResultDto,
|
|
158
|
+
type ListWorkflowJobExecutionsInputDto,
|
|
159
|
+
type ListWorkflowJobExecutionsResultDto,
|
|
160
|
+
type ListWorkflowRunAttemptsInputDto,
|
|
161
|
+
type ListWorkflowRunAttemptsResultDto,
|
|
162
|
+
type ListWorkflowRunJobsInputDto,
|
|
163
|
+
type ListWorkflowRunJobsResultDto,
|
|
164
|
+
type ListWorkflowStepAttemptsInputDto,
|
|
165
|
+
type ListWorkflowStepAttemptsResultDto,
|
|
166
|
+
listWorkflowExecutionStepsInputJsonSchema,
|
|
167
|
+
listWorkflowExecutionStepsInputSchema,
|
|
168
|
+
listWorkflowExecutionStepsResultJsonSchema,
|
|
169
|
+
listWorkflowExecutionStepsResultSchema,
|
|
170
|
+
listWorkflowJobExecutionsInputJsonSchema,
|
|
171
|
+
listWorkflowJobExecutionsInputSchema,
|
|
172
|
+
listWorkflowJobExecutionsResultJsonSchema,
|
|
173
|
+
listWorkflowJobExecutionsResultSchema,
|
|
174
|
+
listWorkflowRunAttemptsInputJsonSchema,
|
|
175
|
+
listWorkflowRunAttemptsInputSchema,
|
|
176
|
+
listWorkflowRunAttemptsResultJsonSchema,
|
|
177
|
+
listWorkflowRunAttemptsResultSchema,
|
|
178
|
+
listWorkflowRunJobsInputJsonSchema,
|
|
179
|
+
listWorkflowRunJobsInputSchema,
|
|
180
|
+
listWorkflowRunJobsResultJsonSchema,
|
|
181
|
+
listWorkflowRunJobsResultSchema,
|
|
182
|
+
listWorkflowStepAttemptsInputJsonSchema,
|
|
183
|
+
listWorkflowStepAttemptsInputSchema,
|
|
184
|
+
listWorkflowStepAttemptsResultJsonSchema,
|
|
185
|
+
listWorkflowStepAttemptsResultSchema,
|
|
186
|
+
} from './schemas/workflow-tools.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {getTriggerEventResultJsonSchema, getTriggerEventResultSchema} from './diagnostic-tools.js';
|
|
2
|
+
|
|
3
|
+
const eventId = '00000000-0000-4000-8000-000000000001';
|
|
4
|
+
|
|
5
|
+
describe('diagnostic agent-access schemas', () => {
|
|
6
|
+
test('accepts filtered trigger decisions in runtime and JSON schemas', () => {
|
|
7
|
+
const result = {
|
|
8
|
+
id: eventId,
|
|
9
|
+
origin: 'integration',
|
|
10
|
+
provider: 'github',
|
|
11
|
+
source: 'github',
|
|
12
|
+
event: 'push',
|
|
13
|
+
outcome: 'discarded',
|
|
14
|
+
matched_count: 0,
|
|
15
|
+
connection_id: null,
|
|
16
|
+
connection_name: null,
|
|
17
|
+
replay_of_event_id: null,
|
|
18
|
+
received_at: '2026-09-04T12:00:00.000Z',
|
|
19
|
+
processed_at: '2026-09-04T12:00:01.000Z',
|
|
20
|
+
payload_preview: '{}',
|
|
21
|
+
decisions: [
|
|
22
|
+
{
|
|
23
|
+
id: '00000000-0000-4000-8000-000000000002',
|
|
24
|
+
subscription_kind: 'trigger',
|
|
25
|
+
outcome: 'filtered',
|
|
26
|
+
reason: null,
|
|
27
|
+
workflow_definition_id: '00000000-0000-4000-8000-000000000003',
|
|
28
|
+
project_id: '00000000-0000-4000-8000-000000000004',
|
|
29
|
+
workflow_run_id: null,
|
|
30
|
+
job_id: null,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
decisions_total_count: 1,
|
|
34
|
+
replays: [],
|
|
35
|
+
replays_total_count: 0,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
expect(getTriggerEventResultSchema.safeParse(result).success).toBe(true);
|
|
39
|
+
expect(
|
|
40
|
+
getTriggerEventResultJsonSchema.properties.decisions.items.properties.outcome.enum,
|
|
41
|
+
).toContain('filtered');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
AGENT_ACCESS_CONNECTION_NAME_MAX_BYTES,
|
|
5
5
|
AGENT_ACCESS_TEXT_MAX_BYTES,
|
|
6
6
|
} from './paged-tools.js';
|
|
7
|
+
import {dateTimeSchema, idSchema, utf8CappedString} from './primitives.js';
|
|
7
8
|
|
|
8
9
|
export const AGENT_ACCESS_SERIALIZED_JSON_MAX_BYTES = 16 * 1024;
|
|
9
10
|
export const AGENT_ACCESS_TRIGGER_DECISION_MAX_ITEMS = 50;
|
|
@@ -11,18 +12,6 @@ export const AGENT_ACCESS_TRIGGER_REPLAY_MAX_ITEMS = 20;
|
|
|
11
12
|
export const AGENT_ACCESS_FACET_MAX_ITEMS = 50;
|
|
12
13
|
export const AGENT_ACCESS_FACET_VALUE_MAX_BYTES = 256;
|
|
13
14
|
|
|
14
|
-
const idSchema = z.string().uuid();
|
|
15
|
-
const dateTimeSchema = z.string().datetime();
|
|
16
|
-
const utf8Encoder = new TextEncoder();
|
|
17
|
-
|
|
18
|
-
const utf8CappedString = (maxBytes: number) =>
|
|
19
|
-
z
|
|
20
|
-
.string()
|
|
21
|
-
.max(maxBytes)
|
|
22
|
-
.refine((value) => utf8Encoder.encode(value).byteLength <= maxBytes, {
|
|
23
|
-
message: `String must contain at most ${maxBytes} UTF-8 bytes`,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
15
|
const textSchema = utf8CappedString(AGENT_ACCESS_TEXT_MAX_BYTES);
|
|
27
16
|
const shortTextSchema = utf8CappedString(AGENT_ACCESS_CONNECTION_NAME_MAX_BYTES);
|
|
28
17
|
const serializedJsonSchema = utf8CappedString(AGENT_ACCESS_SERIALIZED_JSON_MAX_BYTES).refine(
|
|
@@ -39,7 +28,13 @@ export type GetTriggerEventFacetsInputDto = z.infer<typeof getTriggerEventFacets
|
|
|
39
28
|
|
|
40
29
|
const triggerOriginSchema = z.enum(['integration', 'manual', 'cron', 'dev']);
|
|
41
30
|
const triggerOutcomeSchema = z.enum(['received', 'routed', 'discarded', 'failed', 'errored']);
|
|
42
|
-
const triggerDecisionOutcomeSchema = z.enum([
|
|
31
|
+
const triggerDecisionOutcomeSchema = z.enum([
|
|
32
|
+
'triggered',
|
|
33
|
+
'filtered',
|
|
34
|
+
'filter-error',
|
|
35
|
+
'dispatch-error',
|
|
36
|
+
'rejected',
|
|
37
|
+
]);
|
|
43
38
|
const triggerDecisionSchema = z
|
|
44
39
|
.object({
|
|
45
40
|
id: idSchema,
|
|
@@ -146,7 +141,10 @@ const triggerDecisionJsonSchema = {
|
|
|
146
141
|
properties: {
|
|
147
142
|
id: uuid,
|
|
148
143
|
subscription_kind: {type: 'string', enum: ['trigger', 'listener', 'dev']},
|
|
149
|
-
outcome: {
|
|
144
|
+
outcome: {
|
|
145
|
+
type: 'string',
|
|
146
|
+
enum: ['triggered', 'filtered', 'filter-error', 'dispatch-error', 'rejected'],
|
|
147
|
+
},
|
|
150
148
|
reason: nullable(text),
|
|
151
149
|
workflow_definition_id: nullable(uuid),
|
|
152
150
|
project_id: nullable(uuid),
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_STEP_LOG_TAIL_LINES,
|
|
3
|
+
MAX_STEP_LOG_TAIL_LINES,
|
|
4
|
+
} from '@shipfox/api-logs-dto/inter-module';
|
|
5
|
+
import {z} from 'zod';
|
|
6
|
+
import type {AgentAccessObjectSchema} from './envelope.js';
|
|
7
|
+
import {idSchema, utf8CappedString} from './primitives.js';
|
|
8
|
+
|
|
9
|
+
export const AGENT_ACCESS_LOG_CONTENT_MAX_BYTES = 64 * 1024;
|
|
10
|
+
export const AGENT_ACCESS_LOG_SECTION_MAX_ITEMS = 10;
|
|
11
|
+
export const AGENT_ACCESS_LOG_TAIL_LINES_DEFAULT = DEFAULT_STEP_LOG_TAIL_LINES;
|
|
12
|
+
export const AGENT_ACCESS_LOG_TAIL_LINES_MAX = MAX_STEP_LOG_TAIL_LINES;
|
|
13
|
+
export const AGENT_ACCESS_LOG_ATTEMPT_MAX = 2_147_483_647;
|
|
14
|
+
|
|
15
|
+
const attemptSchema = z.number().int().min(1).max(AGENT_ACCESS_LOG_ATTEMPT_MAX);
|
|
16
|
+
const tailLinesSchema = z
|
|
17
|
+
.number()
|
|
18
|
+
.int()
|
|
19
|
+
.min(1)
|
|
20
|
+
.max(AGENT_ACCESS_LOG_TAIL_LINES_MAX)
|
|
21
|
+
.default(AGENT_ACCESS_LOG_TAIL_LINES_DEFAULT);
|
|
22
|
+
const contentSchema = utf8CappedString(AGENT_ACCESS_LOG_CONTENT_MAX_BYTES);
|
|
23
|
+
|
|
24
|
+
export const getStepLogsInputSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
step_id: idSchema.optional(),
|
|
27
|
+
run_id: idSchema.optional(),
|
|
28
|
+
attempt: attemptSchema.optional(),
|
|
29
|
+
failed_only: z.literal(true).optional(),
|
|
30
|
+
tail_lines: tailLinesSchema,
|
|
31
|
+
})
|
|
32
|
+
.superRefine((value, context) => {
|
|
33
|
+
const hasStep = value.step_id !== undefined;
|
|
34
|
+
const hasRun = value.run_id !== undefined;
|
|
35
|
+
|
|
36
|
+
if (hasStep === hasRun) {
|
|
37
|
+
context.addIssue({
|
|
38
|
+
code: 'custom',
|
|
39
|
+
path: [hasStep ? 'run_id' : 'step_id'],
|
|
40
|
+
message: 'Provide exactly one of step_id or run_id',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (hasRun && value.failed_only !== true) {
|
|
44
|
+
context.addIssue({
|
|
45
|
+
code: 'custom',
|
|
46
|
+
path: ['failed_only'],
|
|
47
|
+
message: 'run_id requires failed_only to be true',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (hasStep && value.failed_only !== undefined) {
|
|
51
|
+
context.addIssue({
|
|
52
|
+
code: 'custom',
|
|
53
|
+
path: ['failed_only'],
|
|
54
|
+
message: 'failed_only is only valid with run_id',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (hasRun && value.attempt !== undefined) {
|
|
58
|
+
context.addIssue({
|
|
59
|
+
code: 'custom',
|
|
60
|
+
path: ['attempt'],
|
|
61
|
+
message: 'attempt is only valid with step_id',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
.strict();
|
|
66
|
+
|
|
67
|
+
export type GetStepLogsInputDto = z.output<typeof getStepLogsInputSchema>;
|
|
68
|
+
|
|
69
|
+
const logSectionSchema = z
|
|
70
|
+
.object({
|
|
71
|
+
workflow_run_id: idSchema.optional(),
|
|
72
|
+
workflow_run_attempt: attemptSchema.optional(),
|
|
73
|
+
job_id: idSchema.optional(),
|
|
74
|
+
job_execution_id: idSchema.optional(),
|
|
75
|
+
step_id: idSchema,
|
|
76
|
+
step_attempt_id: idSchema.optional(),
|
|
77
|
+
attempt: attemptSchema,
|
|
78
|
+
content: contentSchema,
|
|
79
|
+
total_lines: z.number().int().nonnegative().optional(),
|
|
80
|
+
content_truncated: z.literal(true).optional(),
|
|
81
|
+
content_total_bytes: z.number().int().nonnegative().optional(),
|
|
82
|
+
})
|
|
83
|
+
.strict();
|
|
84
|
+
|
|
85
|
+
export const getStepLogsResultSchema = z
|
|
86
|
+
.object({
|
|
87
|
+
run_id: idSchema.optional(),
|
|
88
|
+
workflow_run_attempt: attemptSchema.optional(),
|
|
89
|
+
sections: z.array(logSectionSchema).max(AGENT_ACCESS_LOG_SECTION_MAX_ITEMS),
|
|
90
|
+
})
|
|
91
|
+
.superRefine((value, context) => {
|
|
92
|
+
const hasRun = value.run_id !== undefined;
|
|
93
|
+
const hasRunAttempt = value.workflow_run_attempt !== undefined;
|
|
94
|
+
|
|
95
|
+
if (hasRun !== hasRunAttempt) {
|
|
96
|
+
context.addIssue({
|
|
97
|
+
code: 'custom',
|
|
98
|
+
path: [hasRun ? 'workflow_run_attempt' : 'run_id'],
|
|
99
|
+
message: 'run_id and workflow_run_attempt must be provided together',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (!hasRun && value.sections.length !== 1) {
|
|
103
|
+
context.addIssue({
|
|
104
|
+
code: 'custom',
|
|
105
|
+
path: ['sections'],
|
|
106
|
+
message: 'A direct step read must contain exactly one section',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
.strict();
|
|
111
|
+
|
|
112
|
+
export type GetStepLogsResultDto = z.output<typeof getStepLogsResultSchema>;
|
|
113
|
+
|
|
114
|
+
const uuid = {type: 'string', format: 'uuid'} as const;
|
|
115
|
+
const attempt = {
|
|
116
|
+
type: 'integer',
|
|
117
|
+
minimum: 1,
|
|
118
|
+
maximum: AGENT_ACCESS_LOG_ATTEMPT_MAX,
|
|
119
|
+
} as const;
|
|
120
|
+
|
|
121
|
+
const directInputJsonSchema = {
|
|
122
|
+
type: 'object',
|
|
123
|
+
properties: {
|
|
124
|
+
step_id: uuid,
|
|
125
|
+
attempt,
|
|
126
|
+
tail_lines: {
|
|
127
|
+
type: 'integer',
|
|
128
|
+
minimum: 1,
|
|
129
|
+
maximum: AGENT_ACCESS_LOG_TAIL_LINES_MAX,
|
|
130
|
+
default: AGENT_ACCESS_LOG_TAIL_LINES_DEFAULT,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
required: ['step_id'],
|
|
134
|
+
additionalProperties: false,
|
|
135
|
+
} as const;
|
|
136
|
+
|
|
137
|
+
const failedOnlyInputJsonSchema = {
|
|
138
|
+
type: 'object',
|
|
139
|
+
properties: {
|
|
140
|
+
run_id: uuid,
|
|
141
|
+
failed_only: {const: true},
|
|
142
|
+
tail_lines: {
|
|
143
|
+
type: 'integer',
|
|
144
|
+
minimum: 1,
|
|
145
|
+
maximum: AGENT_ACCESS_LOG_TAIL_LINES_MAX,
|
|
146
|
+
default: AGENT_ACCESS_LOG_TAIL_LINES_DEFAULT,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
required: ['run_id', 'failed_only'],
|
|
150
|
+
additionalProperties: false,
|
|
151
|
+
} as const;
|
|
152
|
+
|
|
153
|
+
export const getStepLogsInputJsonSchema = {
|
|
154
|
+
type: 'object',
|
|
155
|
+
oneOf: [directInputJsonSchema, failedOnlyInputJsonSchema],
|
|
156
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
157
|
+
|
|
158
|
+
const logSectionJsonSchema = {
|
|
159
|
+
type: 'object',
|
|
160
|
+
properties: {
|
|
161
|
+
workflow_run_id: uuid,
|
|
162
|
+
workflow_run_attempt: attempt,
|
|
163
|
+
job_id: uuid,
|
|
164
|
+
job_execution_id: uuid,
|
|
165
|
+
step_id: uuid,
|
|
166
|
+
step_attempt_id: uuid,
|
|
167
|
+
attempt,
|
|
168
|
+
content: {type: 'string', maxLength: AGENT_ACCESS_LOG_CONTENT_MAX_BYTES},
|
|
169
|
+
total_lines: {type: 'integer', minimum: 0},
|
|
170
|
+
content_truncated: {const: true},
|
|
171
|
+
content_total_bytes: {type: 'integer', minimum: 0},
|
|
172
|
+
},
|
|
173
|
+
required: ['step_id', 'attempt', 'content'],
|
|
174
|
+
additionalProperties: false,
|
|
175
|
+
} as const;
|
|
176
|
+
|
|
177
|
+
const directResultJsonSchema = {
|
|
178
|
+
type: 'object',
|
|
179
|
+
properties: {
|
|
180
|
+
sections: {
|
|
181
|
+
type: 'array',
|
|
182
|
+
minItems: 1,
|
|
183
|
+
maxItems: 1,
|
|
184
|
+
items: logSectionJsonSchema,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
required: ['sections'],
|
|
188
|
+
additionalProperties: false,
|
|
189
|
+
} as const;
|
|
190
|
+
|
|
191
|
+
const aggregateResultJsonSchema = {
|
|
192
|
+
type: 'object',
|
|
193
|
+
properties: {
|
|
194
|
+
run_id: uuid,
|
|
195
|
+
workflow_run_attempt: attempt,
|
|
196
|
+
sections: {
|
|
197
|
+
type: 'array',
|
|
198
|
+
maxItems: AGENT_ACCESS_LOG_SECTION_MAX_ITEMS,
|
|
199
|
+
items: logSectionJsonSchema,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
required: ['run_id', 'workflow_run_attempt', 'sections'],
|
|
203
|
+
additionalProperties: false,
|
|
204
|
+
} as const;
|
|
205
|
+
|
|
206
|
+
export const getStepLogsResultJsonSchema = {
|
|
207
|
+
type: 'object',
|
|
208
|
+
oneOf: [directResultJsonSchema, aggregateResultJsonSchema],
|
|
209
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {z} from 'zod';
|
|
2
2
|
import type {AgentAccessObjectSchema} from './envelope.js';
|
|
3
|
+
import {dateTimeSchema, idSchema, utf8CappedString} from './primitives.js';
|
|
3
4
|
|
|
4
5
|
export const AGENT_ACCESS_DEFAULT_PAGE_LIMIT = 50;
|
|
5
6
|
export const AGENT_ACCESS_PAGE_LIMIT_MAX = 100;
|
|
@@ -12,16 +13,6 @@ export const AGENT_ACCESS_DIAGNOSTIC_PATH_MAX_BYTES = 512;
|
|
|
12
13
|
export const AGENT_ACCESS_DIAGNOSTIC_MAX_ITEMS = 10;
|
|
13
14
|
export const AGENT_ACCESS_ANNOTATION_BODY_MAX_BYTES = 8 * 1024;
|
|
14
15
|
|
|
15
|
-
const idSchema = z.string().uuid();
|
|
16
|
-
const dateTimeSchema = z.string().datetime();
|
|
17
|
-
const utf8Encoder = new TextEncoder();
|
|
18
|
-
const utf8CappedString = (maxBytes: number) =>
|
|
19
|
-
z
|
|
20
|
-
.string()
|
|
21
|
-
.max(maxBytes)
|
|
22
|
-
.refine((value) => utf8Encoder.encode(value).byteLength <= maxBytes, {
|
|
23
|
-
message: `String must contain at most ${maxBytes} UTF-8 bytes`,
|
|
24
|
-
});
|
|
25
16
|
const pageInputFields = {
|
|
26
17
|
limit: z
|
|
27
18
|
.number()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {z} from 'zod';
|
|
2
|
+
|
|
3
|
+
export const idSchema = z.string().uuid();
|
|
4
|
+
export const dateTimeSchema = z.string().datetime();
|
|
5
|
+
|
|
6
|
+
const utf8Encoder = new TextEncoder();
|
|
7
|
+
|
|
8
|
+
export const utf8CappedString = (maxBytes: number) =>
|
|
9
|
+
z
|
|
10
|
+
.string()
|
|
11
|
+
.max(maxBytes)
|
|
12
|
+
.refine((value) => utf8Encoder.encode(value).byteLength <= maxBytes, {
|
|
13
|
+
message: `String must contain at most ${maxBytes} UTF-8 bytes`,
|
|
14
|
+
});
|