@outputai/cli 0.16.1-next.d850344.0 → 0.17.1-next.78fc808.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.
@@ -20,6 +20,26 @@ export interface ErrorResponse {
20
20
  */
21
21
  workflowId?: string | null;
22
22
  }
23
+ export type TraceFileTooLargeResponseError = typeof TraceFileTooLargeResponseError[keyof typeof TraceFileTooLargeResponseError];
24
+ export declare const TraceFileTooLargeResponseError: {
25
+ readonly TraceFileTooLargeError: "TraceFileTooLargeError";
26
+ };
27
+ /**
28
+ * The trace file is bigger than the API serves inline. Download it directly with `downloadUrl`.
29
+ */
30
+ export interface TraceFileTooLargeResponse {
31
+ error: TraceFileTooLargeResponseError;
32
+ /** Human-readable error message */
33
+ message: string;
34
+ /** Trace file size in bytes */
35
+ size: number;
36
+ /** Maximum trace file size served inline, in bytes */
37
+ maxSize: number;
38
+ /** Signed S3 URL to download the trace file directly. Treat it as a secret, it grants read access until it expires. */
39
+ downloadUrl: string;
40
+ /** When `downloadUrl` stops working */
41
+ expiresAt: string;
42
+ }
23
43
  export type ValidationErrorResponseError = typeof ValidationErrorResponseError[keyof typeof ValidationErrorResponseError];
24
44
  export declare const ValidationErrorResponseError: {
25
45
  readonly ValidationError: "ValidationError";
@@ -370,6 +390,10 @@ export type BadRequestResponse = ValidationErrorResponse | ErrorResponse;
370
390
  * Workflow execution, workflow type, or catalog not found
371
391
  */
372
392
  export type NotFoundResponse = ErrorResponse;
393
+ /**
394
+ * The trace file is bigger than the API serves inline. The body carries a signed `downloadUrl`.
395
+ */
396
+ export type PayloadTooLargeResponse = TraceFileTooLargeResponse;
373
397
  /**
374
398
  * Synchronous execution timed out before workflow completed
375
399
  */
@@ -1109,6 +1133,10 @@ export type getWorkflowIdTraceLogResponse404 = {
1109
1133
  data: NotFoundResponse;
1110
1134
  status: 404;
1111
1135
  };
1136
+ export type getWorkflowIdTraceLogResponse413 = {
1137
+ data: PayloadTooLargeResponse;
1138
+ status: 413;
1139
+ };
1112
1140
  export type getWorkflowIdTraceLogResponse424 = {
1113
1141
  data: FailedDependencyResponse;
1114
1142
  status: 424;
@@ -1120,13 +1148,13 @@ export type getWorkflowIdTraceLogResponse500 = {
1120
1148
  export type getWorkflowIdTraceLogResponseSuccess = (getWorkflowIdTraceLogResponse200) & {
1121
1149
  headers: Headers;
1122
1150
  };
1123
- export type getWorkflowIdTraceLogResponseError = (getWorkflowIdTraceLogResponse404 | getWorkflowIdTraceLogResponse424 | getWorkflowIdTraceLogResponse500) & {
1151
+ export type getWorkflowIdTraceLogResponseError = (getWorkflowIdTraceLogResponse404 | getWorkflowIdTraceLogResponse413 | getWorkflowIdTraceLogResponse424 | getWorkflowIdTraceLogResponse500) & {
1124
1152
  headers: Headers;
1125
1153
  };
1126
1154
  export type getWorkflowIdTraceLogResponse = (getWorkflowIdTraceLogResponseSuccess | getWorkflowIdTraceLogResponseError);
1127
1155
  export declare const getGetWorkflowIdTraceLogUrl: (id: string) => string;
1128
1156
  /**
1129
- * Returns trace data for the latest run of the given workflow. If trace is stored remotely (S3), fetches and returns the data inline. If trace is local only, returns the local path. To pin a specific run, use `/workflow/{id}/runs/{rid}/trace-log`.
1157
+ * Returns trace data for the latest run of the given workflow. If trace is stored remotely (S3), fetches and returns the data inline, unless it is over 256 MB, in which case it responds 413 with a signed `downloadUrl` and `X-Trace-Size` and `X-Trace-Max-Size` headers. If trace is local only, returns the local path. To pin a specific run, use `/workflow/{id}/runs/{rid}/trace-log`.
1130
1158
  * @summary Get workflow trace log data (latest run)
1131
1159
  */
1132
1160
  export declare const getWorkflowIdTraceLog: (id: string, options?: Parameters<typeof customFetchInstance>[1]) => Promise<getWorkflowIdTraceLogResponse>;
@@ -1142,6 +1170,10 @@ export type getWorkflowIdRunsRidTraceLogResponse404 = {
1142
1170
  data: NotFoundResponse;
1143
1171
  status: 404;
1144
1172
  };
1173
+ export type getWorkflowIdRunsRidTraceLogResponse413 = {
1174
+ data: PayloadTooLargeResponse;
1175
+ status: 413;
1176
+ };
1145
1177
  export type getWorkflowIdRunsRidTraceLogResponse424 = {
1146
1178
  data: FailedDependencyResponse;
1147
1179
  status: 424;
@@ -1153,13 +1185,13 @@ export type getWorkflowIdRunsRidTraceLogResponse500 = {
1153
1185
  export type getWorkflowIdRunsRidTraceLogResponseSuccess = (getWorkflowIdRunsRidTraceLogResponse200) & {
1154
1186
  headers: Headers;
1155
1187
  };
1156
- export type getWorkflowIdRunsRidTraceLogResponseError = (getWorkflowIdRunsRidTraceLogResponse400 | getWorkflowIdRunsRidTraceLogResponse404 | getWorkflowIdRunsRidTraceLogResponse424 | getWorkflowIdRunsRidTraceLogResponse500) & {
1188
+ export type getWorkflowIdRunsRidTraceLogResponseError = (getWorkflowIdRunsRidTraceLogResponse400 | getWorkflowIdRunsRidTraceLogResponse404 | getWorkflowIdRunsRidTraceLogResponse413 | getWorkflowIdRunsRidTraceLogResponse424 | getWorkflowIdRunsRidTraceLogResponse500) & {
1157
1189
  headers: Headers;
1158
1190
  };
1159
1191
  export type getWorkflowIdRunsRidTraceLogResponse = (getWorkflowIdRunsRidTraceLogResponseSuccess | getWorkflowIdRunsRidTraceLogResponseError);
1160
1192
  export declare const getGetWorkflowIdRunsRidTraceLogUrl: (id: string, rid: string) => string;
1161
1193
  /**
1162
- * Returns trace data for a pinned workflow run. If trace is stored remotely (S3), fetches and returns the data inline. If trace is local only, returns the local path.
1194
+ * Returns trace data for a pinned workflow run. If trace is stored remotely (S3), fetches and returns the data inline, unless it is over 256 MB, in which case it responds 413 with a signed `downloadUrl` and `X-Trace-Size` and `X-Trace-Max-Size` headers. If trace is local only, returns the local path.
1163
1195
  * @summary Get workflow trace log data for a specific run
1164
1196
  */
1165
1197
  export declare const getWorkflowIdRunsRidTraceLog: (id: string, rid: string, options?: Parameters<typeof customFetchInstance>[1]) => Promise<getWorkflowIdRunsRidTraceLogResponse>;
@@ -6,6 +6,9 @@
6
6
  * OpenAPI spec version: 1.0.0
7
7
  */
8
8
  import { customFetchInstance } from '../http_client.js';
9
+ export const TraceFileTooLargeResponseError = {
10
+ TraceFileTooLargeError: 'TraceFileTooLargeError',
11
+ };
9
12
  export const ValidationErrorResponseError = {
10
13
  ValidationError: 'ValidationError',
11
14
  };
@@ -356,7 +359,7 @@ export const getGetWorkflowIdTraceLogUrl = (id) => {
356
359
  return `/workflow/${id}/trace-log`;
357
360
  };
358
361
  /**
359
- * Returns trace data for the latest run of the given workflow. If trace is stored remotely (S3), fetches and returns the data inline. If trace is local only, returns the local path. To pin a specific run, use `/workflow/{id}/runs/{rid}/trace-log`.
362
+ * Returns trace data for the latest run of the given workflow. If trace is stored remotely (S3), fetches and returns the data inline, unless it is over 256 MB, in which case it responds 413 with a signed `downloadUrl` and `X-Trace-Size` and `X-Trace-Max-Size` headers. If trace is local only, returns the local path. To pin a specific run, use `/workflow/{id}/runs/{rid}/trace-log`.
360
363
  * @summary Get workflow trace log data (latest run)
361
364
  */
362
365
  export const getWorkflowIdTraceLog = async (id, options) => {
@@ -369,7 +372,7 @@ export const getGetWorkflowIdRunsRidTraceLogUrl = (id, rid) => {
369
372
  return `/workflow/${id}/runs/${rid}/trace-log`;
370
373
  };
371
374
  /**
372
- * Returns trace data for a pinned workflow run. If trace is stored remotely (S3), fetches and returns the data inline. If trace is local only, returns the local path.
375
+ * Returns trace data for a pinned workflow run. If trace is stored remotely (S3), fetches and returns the data inline, unless it is over 256 MB, in which case it responds 413 with a signed `downloadUrl` and `X-Trace-Size` and `X-Trace-Max-Size` headers. If trace is local only, returns the local path.
373
376
  * @summary Get workflow trace log data for a specific run
374
377
  */
375
378
  export const getWorkflowIdRunsRidTraceLog = async (id, rid, options) => {
@@ -80,7 +80,7 @@ services:
80
80
  condition: service_healthy
81
81
  worker:
82
82
  condition: service_healthy
83
- image: outputai/api:${OUTPUT_API_VERSION:-0.16.1-next.d850344.0}
83
+ image: outputai/api:${OUTPUT_API_VERSION:-0.17.1-next.78fc808.0}
84
84
  init: true
85
85
  networks:
86
86
  - main
@@ -1,3 +1,3 @@
1
1
  {
2
- "framework": "0.16.1-next.d850344.0"
2
+ "framework": "0.17.1-next.78fc808.0"
3
3
  }
@@ -8,6 +8,14 @@ export interface TraceResult {
8
8
  data: TraceData;
9
9
  location: TraceLocation;
10
10
  }
11
+ /**
12
+ * Builds the user-facing message for the API's 413 (trace too big to be served), even though the response
13
+ * carries a download URL. The CLI does not download these files.
14
+ *
15
+ * @param error - Error thrown by a trace log request
16
+ * @returns The message, or null when the error is not a 413
17
+ */
18
+ export declare function buildTraceTooLargeMessage(error: unknown): string | null;
11
19
  /**
12
20
  * Get trace data from workflow ID using the API
13
21
  * The API handles S3 fetching - CLI only needs to read local files when necessary
@@ -1,6 +1,8 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { getWorkflowIdTraceLog } from '#api/generated/api.js';
3
+ import { HttpError } from '#api/http_client.js';
3
4
  import { getErrorCode } from '#utils/error_utils.js';
5
+ import { formatBytes } from '#utils/size_formatter.js';
4
6
  /**
5
7
  * Read and parse trace file from local path
6
8
  */
@@ -19,13 +21,39 @@ async function readLocalTraceFile(path) {
19
21
  throw error;
20
22
  }
21
23
  }
24
+ /**
25
+ * Builds the user-facing message for the API's 413 (trace too big to be served), even though the response
26
+ * carries a download URL. The CLI does not download these files.
27
+ *
28
+ * @param error - Error thrown by a trace log request
29
+ * @returns The message, or null when the error is not a 413
30
+ */
31
+ export function buildTraceTooLargeMessage(error) {
32
+ if (!(error instanceof HttpError) || error.response.status !== 413) {
33
+ return null;
34
+ }
35
+ const { size, maxSize } = (error.response.data ?? {});
36
+ const message = 'Trace file is too big for this feature.';
37
+ return typeof size === 'number' && typeof maxSize === 'number' ?
38
+ `${message} Max size ${formatBytes(maxSize)}, file size ${formatBytes(size)}` :
39
+ message;
40
+ }
41
+ async function fetchTraceLog(workflowId) {
42
+ try {
43
+ return await getWorkflowIdTraceLog(workflowId);
44
+ }
45
+ catch (error) {
46
+ const message = buildTraceTooLargeMessage(error);
47
+ throw message ? new Error(message) : error;
48
+ }
49
+ }
22
50
  /**
23
51
  * Get trace data from workflow ID using the API
24
52
  * The API handles S3 fetching - CLI only needs to read local files when necessary
25
53
  * @returns Both the trace data and the location it was fetched from
26
54
  */
27
55
  export async function getTrace(workflowId) {
28
- const response = await getWorkflowIdTraceLog(workflowId);
56
+ const response = await fetchTraceLog(workflowId);
29
57
  if (response.status === 404) {
30
58
  throw new Error(`Workflow not found or no trace available: ${workflowId}`);
31
59
  }
@@ -1,4 +1,5 @@
1
1
  import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
2
+ import { HttpError } from '#api/http_client.js';
2
3
  const mockGetWorkflowIdTraceLog = vi.fn();
3
4
  vi.mock('#api/generated/api.js', () => ({
4
5
  getWorkflowIdTraceLog: (...args) => mockGetWorkflowIdTraceLog(...args)
@@ -75,4 +76,40 @@ describe('trace_reader', () => {
75
76
  .toThrow('S3 access denied');
76
77
  });
77
78
  });
79
+ describe('buildTraceTooLargeMessage', () => {
80
+ it('should build the friendly message with both sizes for a 413', async () => {
81
+ const error = new HttpError('Payload Too Large', { status: 413, data: { size: 587158372, maxSize: 268435456 } });
82
+ const { buildTraceTooLargeMessage } = await import('./trace_reader.js');
83
+ expect(buildTraceTooLargeMessage(error))
84
+ .toBe('Trace file is too big for this feature. Max size 256 MB, file size 560 MB');
85
+ });
86
+ it('should omit the sizes when the 413 body does not carry them', async () => {
87
+ const { buildTraceTooLargeMessage } = await import('./trace_reader.js');
88
+ expect(buildTraceTooLargeMessage(new HttpError('Payload Too Large', { status: 413 })))
89
+ .toBe('Trace file is too big for this feature.');
90
+ expect(buildTraceTooLargeMessage(new HttpError('Payload Too Large', { status: 413, data: { size: 'x' } })))
91
+ .toBe('Trace file is too big for this feature.');
92
+ });
93
+ it('should return null for other statuses and other errors', async () => {
94
+ const { buildTraceTooLargeMessage } = await import('./trace_reader.js');
95
+ expect(buildTraceTooLargeMessage(new HttpError('Server error', { status: 500 }))).toBeNull();
96
+ expect(buildTraceTooLargeMessage(new Error('boom'))).toBeNull();
97
+ expect(buildTraceTooLargeMessage(undefined)).toBeNull();
98
+ });
99
+ });
100
+ describe('getTrace with a 413', () => {
101
+ it('should throw the friendly message instead of the HTTP error', async () => {
102
+ mockGetWorkflowIdTraceLog.mockRejectedValue(new HttpError('Payload Too Large', { status: 413, data: { size: 587158372, maxSize: 268435456 } }));
103
+ const { getTrace } = await import('./trace_reader.js');
104
+ await expect(getTrace('wf-123'))
105
+ .rejects
106
+ .toThrow('Trace file is too big for this feature. Max size 256 MB, file size 560 MB');
107
+ });
108
+ it('should rethrow other request errors unchanged', async () => {
109
+ const error = new HttpError('Server error', { status: 500 });
110
+ mockGetWorkflowIdTraceLog.mockRejectedValue(error);
111
+ const { getTrace } = await import('./trace_reader.js');
112
+ await expect(getTrace('wf-123')).rejects.toBe(error);
113
+ });
114
+ });
78
115
  });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Formats a byte count for humans in binary units (1 MB = 1024 KB), as S3 reports sizes.
3
+ *
4
+ * @param bytes - Size in bytes
5
+ * @returns Size such as `256 MB` or `1.5 KB`
6
+ */
7
+ export declare function formatBytes(bytes: number): string;
@@ -0,0 +1,12 @@
1
+ const units = ['B', 'KB', 'MB', 'GB'];
2
+ /**
3
+ * Formats a byte count for humans in binary units (1 MB = 1024 KB), as S3 reports sizes.
4
+ *
5
+ * @param bytes - Size in bytes
6
+ * @returns Size such as `256 MB` or `1.5 KB`
7
+ */
8
+ export function formatBytes(bytes) {
9
+ const index = bytes > 0 ? Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1) : 0;
10
+ const value = bytes / (1024 ** index);
11
+ return `${Number(value.toFixed(1))} ${units[index]}`;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { formatBytes } from '#utils/size_formatter.js';
3
+ describe('formatBytes', () => {
4
+ it('formats zero and small values in bytes', () => {
5
+ expect(formatBytes(0)).toBe('0 B');
6
+ expect(formatBytes(512)).toBe('512 B');
7
+ });
8
+ it('uses 1024-based units', () => {
9
+ expect(formatBytes(1024)).toBe('1 KB');
10
+ expect(formatBytes(1024 * 1024)).toBe('1 MB');
11
+ expect(formatBytes(256 * 1024 * 1024)).toBe('256 MB');
12
+ expect(formatBytes(1024 ** 3)).toBe('1 GB');
13
+ });
14
+ it('keeps one decimal at most and drops a trailing zero', () => {
15
+ expect(formatBytes(1536)).toBe('1.5 KB');
16
+ expect(formatBytes(587158372)).toBe('560 MB');
17
+ });
18
+ it('caps the unit at GB', () => {
19
+ expect(formatBytes(2048 * (1024 ** 3))).toBe('2048 GB');
20
+ });
21
+ });
@@ -13,6 +13,8 @@ export interface RunStep {
13
13
  export interface RunDetail {
14
14
  result: WorkflowResultResponse | null;
15
15
  trace: TraceData | null;
16
+ /** Why the trace is missing, when the API refused to serve it (for example, it is too big). */
17
+ traceError: string | null;
16
18
  steps: RunStep[];
17
19
  loading: boolean;
18
20
  }
@@ -4,9 +4,11 @@ import { getWorkflowIdResult, getWorkflowIdRunsRidResult, getWorkflowIdTraceLog,
4
4
  import { normalizeWorkflowStatus } from '#utils/normalize_workflow_status.js';
5
5
  import { isTerminalStatus } from '#utils/format_workflow_result.js';
6
6
  import { createBoundedCache } from '#views/dev/utils/bounded_cache.js';
7
+ import { buildTraceTooLargeMessage } from '#services/trace_reader.js';
7
8
  const EMPTY_DETAIL = {
8
9
  result: null,
9
10
  trace: null,
11
+ traceError: null,
10
12
  steps: [],
11
13
  loading: false
12
14
  };
@@ -81,10 +83,11 @@ const fetchTrace = async (workflowId, runId) => {
81
83
  const response = runId ?
82
84
  await getWorkflowIdRunsRidTraceLog(workflowId, runId) :
83
85
  await getWorkflowIdTraceLog(workflowId);
84
- return await readTraceLog(response.data);
86
+ return { trace: await readTraceLog(response.data), traceError: null };
85
87
  }
86
- catch {
87
- return null;
88
+ catch (error) {
89
+ // A trace the API refuses to serve because of its size is the one failure worth telling the user about.
90
+ return { trace: null, traceError: buildTraceTooLargeMessage(error) };
88
91
  }
89
92
  };
90
93
  const fetchResult = async (workflowId, runId) => {
@@ -127,13 +130,14 @@ export const useRunDetail = (workflowId, runId, status) => {
127
130
  void Promise.all([
128
131
  fetchResult(workflowId, runId),
129
132
  fetchTrace(workflowId, runId)
130
- ]).then(([result, trace]) => {
133
+ ]).then(([result, { trace, traceError }]) => {
131
134
  if (fetchIdRef.current !== id) {
132
135
  return;
133
136
  }
134
137
  const next = {
135
138
  result,
136
139
  trace,
140
+ traceError,
137
141
  steps: extractSteps(trace),
138
142
  loading: false
139
143
  };
@@ -57,7 +57,7 @@ const StepDetail = ({ step, activeTab, rows }) => {
57
57
  };
58
58
  export const StepsModal = ({ run, height }) => {
59
59
  const ui = useUiState();
60
- const { steps, loading } = useRunDetail(run.workflowId, run.runId, run.status);
60
+ const { steps, loading, traceError } = useRunDetail(run.workflowId, run.runId, run.status);
61
61
  const { selectedIndex: clamped, selectPrevious, selectNext } = useListSelection(steps.length);
62
62
  const selectedStep = steps[clamped];
63
63
  const activeTab = ui.runStepPaneTab;
@@ -94,7 +94,7 @@ export const StepsModal = ({ run, height }) => {
94
94
  return (_jsx(LoadingSpinner, { label: "Loading steps..." }));
95
95
  }
96
96
  if (steps.length === 0) {
97
- return (_jsx(Text, { dimColor: true, children: "No steps recorded for this run." }));
97
+ return (_jsx(Text, { dimColor: true, children: traceError ?? 'No steps recorded for this run.' }));
98
98
  }
99
99
  return _jsx(StepDetail, { step: selectedStep, activeTab: activeTab, rows: rows });
100
100
  };
@@ -1772,5 +1772,5 @@
1772
1772
  ]
1773
1773
  }
1774
1774
  },
1775
- "version": "0.16.1-next.d850344.0"
1775
+ "version": "0.17.1-next.78fc808.0"
1776
1776
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outputai/cli",
3
- "version": "0.16.1-next.d850344.0",
3
+ "version": "0.17.1-next.78fc808.0",
4
4
  "description": "CLI for Output.ai workflow generation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "react": "19.3.0",
38
38
  "semver": "7.8.5",
39
39
  "undici": "8.12.3",
40
- "@outputai/core": "0.16.1-next.d850344.0"
40
+ "@outputai/core": "0.17.1-next.78fc808.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/cli-progress": "3.11.6",