@outputai/cli 0.10.1-next.c717e35.0 → 0.10.1-next.ca7de69.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/dist/api/generated/api.d.ts +81 -26
- package/dist/api/generated/api.js +7 -4
- package/dist/assets/docker/docker-compose-dev.yml +2 -2
- package/dist/commands/workflow/monitor.d.ts +5 -20
- package/dist/commands/workflow/monitor.js +20 -182
- package/dist/commands/workflow/monitor.spec.js +82 -3
- package/dist/commands/workflow/result.js +2 -2
- package/dist/commands/workflow/result.spec.js +65 -1
- package/dist/commands/workflow/run.js +2 -2
- package/dist/commands/workflow/run.spec.js +30 -3
- package/dist/commands/workflow/start.d.ts +4 -0
- package/dist/commands/workflow/start.js +95 -10
- package/dist/commands/workflow/start.spec.js +252 -0
- package/dist/commands/workflow/status.spec.js +1 -1
- package/dist/generated/framework_version.json +1 -1
- package/dist/services/monitor_stream.d.ts +62 -0
- package/dist/services/monitor_stream.js +285 -0
- package/dist/services/monitor_stream.spec.d.ts +1 -0
- package/dist/services/monitor_stream.spec.js +285 -0
- package/dist/services/workflow_history.js +2 -2
- package/dist/utils/error_handler.d.ts +10 -0
- package/dist/utils/error_handler.js +14 -0
- package/dist/utils/error_handler.spec.d.ts +1 -0
- package/dist/utils/error_handler.spec.js +62 -0
- package/dist/utils/format_workflow_result.d.ts +15 -3
- package/dist/utils/format_workflow_result.js +39 -6
- package/dist/utils/format_workflow_result.spec.js +39 -6
- package/dist/utils/monitor_flags.d.ts +35 -0
- package/dist/utils/monitor_flags.js +76 -0
- package/dist/utils/normalize_workflow_status.d.ts +4 -3
- package/dist/utils/normalize_workflow_status.js +12 -3
- package/dist/utils/normalize_workflow_status.spec.js +3 -0
- package/dist/views/dev/components/workflow_status.js +1 -1
- package/dist/views/dev/hooks/use_run_detail.js +4 -4
- package/dist/views/dev/hooks/use_run_detail.spec.js +1 -1
- package/dist/views/dev/panels/runs_panel.js +2 -2
- package/oclif.manifest.json +40 -1
- package/package.json +5 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CLIError } from '@oclif/core/errors';
|
|
1
2
|
import { config } from '#config.js';
|
|
2
3
|
function getDefaultMessages() {
|
|
3
4
|
return {
|
|
@@ -79,3 +80,16 @@ export function handleApiError(error, errorFn, overrides = {}) {
|
|
|
79
80
|
const detailedMessage = getDetailedErrorMessage(error);
|
|
80
81
|
errorFn(detailedMessage, { exit: 1 });
|
|
81
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* `catch()` handling for a command that raises oclif errors of its own. Flag
|
|
85
|
+
* relationship failures and every `this.error( ..., { exit } )` already carry an
|
|
86
|
+
* exit code and formatted output, and `handleApiError` would flatten all of it
|
|
87
|
+
* to a bare exit 1 — so pass those straight through and only map what actually
|
|
88
|
+
* came back from the API.
|
|
89
|
+
*/
|
|
90
|
+
export function handleCommandError(error, errorFn, overrides = {}) {
|
|
91
|
+
if (error instanceof CLIError) {
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
return handleApiError(error, errorFn, overrides);
|
|
95
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
3
|
+
import { CLIError } from '@oclif/core/errors';
|
|
4
|
+
import { handleApiError, handleCommandError } from './error_handler.js';
|
|
5
|
+
const errorFn = () => vi.fn((message) => {
|
|
6
|
+
throw new Error(message);
|
|
7
|
+
});
|
|
8
|
+
const apiError = (status, data) => Object.assign(new Error('request failed'), { response: { status, data } });
|
|
9
|
+
describe('handleApiError()', () => {
|
|
10
|
+
it('prefers a caller override over the server body for the same status', () => {
|
|
11
|
+
const fn = errorFn();
|
|
12
|
+
expect(() => handleApiError(apiError(404, { error: 'WorkflowNotFoundError', message: 'Workflow "wf-1" not found' }), fn, { 404: 'Workflow not found. Check the workflow ID.' })).toThrow('Workflow not found. Check the workflow ID.');
|
|
13
|
+
});
|
|
14
|
+
it('surfaces the server body when no override covers the status', () => {
|
|
15
|
+
const fn = errorFn();
|
|
16
|
+
// What `start --monitor` relies on now that it passes no 404 override: the
|
|
17
|
+
// API's own words, rather than advice about an id the user never typed.
|
|
18
|
+
expect(() => handleApiError(apiError(404, { error: 'WorkflowNotFoundError', message: 'Workflow "wf-1" not found' }), fn)).toThrow('WorkflowNotFoundError: Workflow "wf-1" not found.');
|
|
19
|
+
});
|
|
20
|
+
it('appends a root cause to the server message when the API reports one', () => {
|
|
21
|
+
const fn = errorFn();
|
|
22
|
+
expect(() => handleApiError(apiError(500, { error: 'StepFailure', message: 'Step failed', rootCause: { error: 'TypeError', message: 'x is not a function' } }), fn)).toThrow(/TypeError: x is not a function/);
|
|
23
|
+
});
|
|
24
|
+
it('falls back to the status default when the body carries no detail', () => {
|
|
25
|
+
const fn = errorFn();
|
|
26
|
+
expect(() => handleApiError(apiError(401), fn)).toThrow(/OUTPUT_API_AUTH_TOKEN/);
|
|
27
|
+
});
|
|
28
|
+
it.each([
|
|
29
|
+
['a top-level code', Object.assign(new Error('connect'), { code: 'ECONNREFUSED' })],
|
|
30
|
+
['a nested cause', Object.assign(new Error('fetch failed'), { cause: { code: 'ECONNREFUSED' } })]
|
|
31
|
+
])('reports a refused connection from %s before looking at any status', (_label, error) => {
|
|
32
|
+
const fn = errorFn();
|
|
33
|
+
expect(() => handleApiError(error, fn)).toThrow(/Is the API server running\?/);
|
|
34
|
+
});
|
|
35
|
+
it('assembles a detailed message when there is no response at all', () => {
|
|
36
|
+
const fn = errorFn();
|
|
37
|
+
const error = Object.assign(new Error('fetch failed'), {
|
|
38
|
+
cause: Object.assign(new Error('getaddrinfo EAI_AGAIN api'), { code: 'EAI_AGAIN', hostname: 'api', port: 3001 })
|
|
39
|
+
});
|
|
40
|
+
expect(() => handleApiError(error, fn)).toThrow(/fetch failed \| Cause: getaddrinfo EAI_AGAIN api \| Code: EAI_AGAIN \| Host: api:3001/);
|
|
41
|
+
});
|
|
42
|
+
it('always exits 1, leaving a command\'s own exit codes to the command', () => {
|
|
43
|
+
const fn = errorFn();
|
|
44
|
+
expect(() => handleApiError(apiError(500), fn)).toThrow();
|
|
45
|
+
expect(fn).toHaveBeenCalledWith(expect.any(String), { exit: 1 });
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('handleCommandError()', () => {
|
|
49
|
+
it('rethrows an oclif error untouched so its exit code and formatting survive', () => {
|
|
50
|
+
const fn = errorFn();
|
|
51
|
+
// `workflow start --monitor` raises exit 2 (bad flag combination) and exit 3
|
|
52
|
+
// (started but unmonitorable); flattening those to exit 1 would let a CI job
|
|
53
|
+
// retrying on a failed workflow re-submit one that is already running.
|
|
54
|
+
const cliError = new CLIError('Cannot combine --monitor with --json', { exit: 2 });
|
|
55
|
+
expect(() => handleCommandError(cliError, fn)).toThrow(cliError);
|
|
56
|
+
expect(fn).not.toHaveBeenCalled();
|
|
57
|
+
});
|
|
58
|
+
it('maps anything that came back from the API the same way handleApiError does', () => {
|
|
59
|
+
const fn = errorFn();
|
|
60
|
+
expect(() => handleCommandError(apiError(404), fn, { 404: 'Workflow not found. Check the workflow name.' })).toThrow('Workflow not found. Check the workflow name.');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import type { WorkflowResultResponse
|
|
1
|
+
import type { WorkflowResultResponse } from '../api/generated/api.js';
|
|
2
2
|
type WorkflowResult = Pick<WorkflowResultResponse, 'workflowId' | 'output' | 'status' | 'error'>;
|
|
3
|
-
|
|
4
|
-
export
|
|
3
|
+
declare const ERROR_STATUS_VALUES: readonly ["failed", "cancelled", "terminated", "timed_out"];
|
|
4
|
+
export type ErrorStatus = typeof ERROR_STATUS_VALUES[number];
|
|
5
|
+
export type TerminalStatus = 'completed' | ErrorStatus;
|
|
6
|
+
/**
|
|
7
|
+
* Maps a raw status to a canonical error status, or `undefined` if it is not one.
|
|
8
|
+
* Legacy spellings (`canceled`) are normalized so callers only ever see the
|
|
9
|
+
* current API vocabulary — until `normalizeWorkflowStatus` is removed.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isErrorStatus(status: string | null | undefined): ErrorStatus | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Maps a raw status to a canonical terminal status, or `undefined` if it is not
|
|
14
|
+
* one. Same normalization contract as `isErrorStatus`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isTerminalStatus(status: string | null | undefined): TerminalStatus | undefined;
|
|
5
17
|
export declare function formatWorkflowResult(result: WorkflowResult): string;
|
|
6
18
|
export {};
|
|
@@ -1,9 +1,39 @@
|
|
|
1
1
|
import { normalizeWorkflowStatus } from './normalize_workflow_status.js';
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
// `satisfies` rather than a plain annotation: it pins these to the generated API
|
|
3
|
+
// union without widening them, so regenerating the API with a renamed status
|
|
4
|
+
// breaks the build instead of silently making that status non-terminal.
|
|
5
|
+
const ERROR_STATUS_VALUES = [
|
|
6
|
+
'failed', 'cancelled', 'terminated', 'timed_out'
|
|
7
|
+
];
|
|
8
|
+
const ERROR_STATUSES = new Set(ERROR_STATUS_VALUES);
|
|
9
|
+
const TERMINAL_STATUSES = new Set(['completed', ...ERROR_STATUS_VALUES]);
|
|
10
|
+
/**
|
|
11
|
+
* Maps a raw status to a canonical error status, or `undefined` if it is not one.
|
|
12
|
+
* Legacy spellings (`canceled`) are normalized so callers only ever see the
|
|
13
|
+
* current API vocabulary — until `normalizeWorkflowStatus` is removed.
|
|
14
|
+
*/
|
|
15
|
+
/* eslint-disable consistent-return -- returns ErrorStatus | undefined via early exit */
|
|
16
|
+
export function isErrorStatus(status) {
|
|
17
|
+
if (typeof status !== 'string') {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const normalized = normalizeWorkflowStatus(status);
|
|
21
|
+
return ERROR_STATUSES.has(normalized) ? normalized : undefined;
|
|
22
|
+
}
|
|
23
|
+
/* eslint-enable consistent-return */
|
|
24
|
+
/**
|
|
25
|
+
* Maps a raw status to a canonical terminal status, or `undefined` if it is not
|
|
26
|
+
* one. Same normalization contract as `isErrorStatus`.
|
|
27
|
+
*/
|
|
28
|
+
/* eslint-disable consistent-return -- returns TerminalStatus | undefined via early exit */
|
|
29
|
+
export function isTerminalStatus(status) {
|
|
30
|
+
if (typeof status !== 'string') {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const normalized = normalizeWorkflowStatus(status);
|
|
34
|
+
return TERMINAL_STATUSES.has(normalized) ? normalized : undefined;
|
|
35
|
+
}
|
|
36
|
+
/* eslint-enable consistent-return */
|
|
7
37
|
export function formatWorkflowResult(result) {
|
|
8
38
|
const status = normalizeWorkflowStatus(result.status);
|
|
9
39
|
const lines = [
|
|
@@ -17,7 +47,10 @@ export function formatWorkflowResult(result) {
|
|
|
17
47
|
else {
|
|
18
48
|
lines.push(`Status: ${status || 'unknown'}`);
|
|
19
49
|
if (result.error) {
|
|
20
|
-
|
|
50
|
+
const error = typeof result.error === 'string' ?
|
|
51
|
+
result.error :
|
|
52
|
+
result.error.message ?? JSON.stringify(result.error, null, 2);
|
|
53
|
+
lines.push(`Error: ${error}`);
|
|
21
54
|
}
|
|
22
55
|
}
|
|
23
56
|
return lines.join('\n');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { formatWorkflowResult } from './format_workflow_result.js';
|
|
2
|
+
import { formatWorkflowResult, isErrorStatus } from './format_workflow_result.js';
|
|
3
3
|
describe('formatWorkflowResult', () => {
|
|
4
4
|
it('should display output for completed workflows', () => {
|
|
5
5
|
const result = formatWorkflowResult({
|
|
@@ -13,7 +13,7 @@ describe('formatWorkflowResult', () => {
|
|
|
13
13
|
expect(result).toContain('"values"');
|
|
14
14
|
expect(result).not.toContain('Status:');
|
|
15
15
|
});
|
|
16
|
-
it('should display
|
|
16
|
+
it('should display legacy string errors for failed workflows', () => {
|
|
17
17
|
const result = formatWorkflowResult({
|
|
18
18
|
workflowId: 'wf-456',
|
|
19
19
|
status: 'failed',
|
|
@@ -25,6 +25,29 @@ describe('formatWorkflowResult', () => {
|
|
|
25
25
|
expect(result).toContain('Error: Activity task failed');
|
|
26
26
|
expect(result).not.toContain('Output:');
|
|
27
27
|
});
|
|
28
|
+
it('should display the message from structured errors', () => {
|
|
29
|
+
const result = formatWorkflowResult({
|
|
30
|
+
workflowId: 'wf-v2',
|
|
31
|
+
status: 'failed',
|
|
32
|
+
output: null,
|
|
33
|
+
error: {
|
|
34
|
+
name: 'ValidationError',
|
|
35
|
+
message: 'Input is invalid',
|
|
36
|
+
code: 'INVALID_INPUT'
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
expect(result).toContain('Error: Input is invalid');
|
|
40
|
+
expect(result).not.toContain('[object Object]');
|
|
41
|
+
});
|
|
42
|
+
it('should serialize structured errors without a message', () => {
|
|
43
|
+
const result = formatWorkflowResult({
|
|
44
|
+
workflowId: 'wf-v2',
|
|
45
|
+
status: 'failed',
|
|
46
|
+
output: null,
|
|
47
|
+
error: { code: 'UNKNOWN' }
|
|
48
|
+
});
|
|
49
|
+
expect(result).toContain('"code": "UNKNOWN"');
|
|
50
|
+
});
|
|
28
51
|
it('should display status for terminated workflows', () => {
|
|
29
52
|
const result = formatWorkflowResult({
|
|
30
53
|
workflowId: 'wf-term',
|
|
@@ -35,15 +58,25 @@ describe('formatWorkflowResult', () => {
|
|
|
35
58
|
expect(result).toContain('Status: terminated');
|
|
36
59
|
expect(result).toContain('Error: Workflow terminated by user');
|
|
37
60
|
});
|
|
38
|
-
it('should display status for
|
|
61
|
+
it('should display status for cancelled workflows', () => {
|
|
39
62
|
const result = formatWorkflowResult({
|
|
63
|
+
workflowId: 'wf-cancel',
|
|
64
|
+
status: 'cancelled',
|
|
65
|
+
output: null,
|
|
66
|
+
error: 'Workflow was cancelled'
|
|
67
|
+
});
|
|
68
|
+
expect(result).toContain('Status: cancelled');
|
|
69
|
+
expect(result).toContain('Error: Workflow was cancelled');
|
|
70
|
+
});
|
|
71
|
+
it('normalizes canceled responses without changing the current status type', () => {
|
|
72
|
+
const legacyResult = {
|
|
40
73
|
workflowId: 'wf-cancel',
|
|
41
74
|
status: 'canceled',
|
|
42
75
|
output: null,
|
|
43
76
|
error: 'Workflow was canceled'
|
|
44
|
-
}
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
77
|
+
};
|
|
78
|
+
expect(formatWorkflowResult(legacyResult)).toContain('Status: cancelled');
|
|
79
|
+
expect(isErrorStatus('canceled')).toBe('cancelled');
|
|
47
80
|
});
|
|
48
81
|
it('should display status without error line for continued_as_new workflows', () => {
|
|
49
82
|
const result = formatWorkflowResult({
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stream's defaults when the tuning flags are not given. Caller-side, not a
|
|
3
|
+
* property of the loop: `streamWorkflowUpdates` takes all three as required
|
|
4
|
+
* options and never falls back. Single-sourced because only `workflow monitor`
|
|
5
|
+
* can hand them to oclif — `workflow start --monitor` has to apply them itself
|
|
6
|
+
* (see `gatedMonitorStreamFlags`), and a literal repeated on that side would
|
|
7
|
+
* drift the moment one of these changes.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MONITOR_DEFAULTS: {
|
|
10
|
+
readonly interval: 2500;
|
|
11
|
+
readonly color: true;
|
|
12
|
+
readonly includePayloads: false;
|
|
13
|
+
};
|
|
14
|
+
/** For a command that always monitors, where oclif can apply the defaults itself. */
|
|
15
|
+
export declare function monitorStreamFlags(): {
|
|
16
|
+
'include-payloads': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
interval: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
color: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* For a command where monitoring is opt-in (`workflow start --monitor`).
|
|
22
|
+
*
|
|
23
|
+
* These carry no oclif `default` on purpose: a defaulted flag counts as present
|
|
24
|
+
* (`validateFlags` runs a relationship check whenever the parsed value is not
|
|
25
|
+
* `undefined`, and `validateDependsOn` has no `setFromDefault` exemption the way
|
|
26
|
+
* `validateExclusive` does), which triggers its own `dependsOn` check and fails
|
|
27
|
+
* every invocation that omits `--monitor` — including a plain `workflow start`.
|
|
28
|
+
* The caller applies the defaults in `run()`, so the interval's default is
|
|
29
|
+
* spelled out in the help text rather than rendered by oclif.
|
|
30
|
+
*/
|
|
31
|
+
export declare function gatedMonitorStreamFlags(gatedBy: string): {
|
|
32
|
+
'include-payloads': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
33
|
+
interval: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
34
|
+
color: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
/**
|
|
3
|
+
* The stream's defaults when the tuning flags are not given. Caller-side, not a
|
|
4
|
+
* property of the loop: `streamWorkflowUpdates` takes all three as required
|
|
5
|
+
* options and never falls back. Single-sourced because only `workflow monitor`
|
|
6
|
+
* can hand them to oclif — `workflow start --monitor` has to apply them itself
|
|
7
|
+
* (see `gatedMonitorStreamFlags`), and a literal repeated on that side would
|
|
8
|
+
* drift the moment one of these changes.
|
|
9
|
+
*/
|
|
10
|
+
export const MONITOR_DEFAULTS = {
|
|
11
|
+
interval: 2500,
|
|
12
|
+
color: true,
|
|
13
|
+
includePayloads: false
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Descriptions and constraints for the three flags that tune
|
|
17
|
+
* `streamWorkflowUpdates`, single-sourced so `workflow monitor` and
|
|
18
|
+
* `workflow start --monitor` can't drift apart on help text — the interval
|
|
19
|
+
* caveat in particular is easy to lose in a copy-paste.
|
|
20
|
+
*/
|
|
21
|
+
const PAYLOADS_DESCRIPTION = 'Include decoded step input/output payloads';
|
|
22
|
+
const COLOR_DESCRIPTION = 'Colorize status output (use --no-color to disable)';
|
|
23
|
+
const INTERVAL_DESCRIPTION = 'Poll interval in milliseconds. Once a resumed poll is long-polling ' +
|
|
24
|
+
'server-side for new events, this also bounds how long that block may last (capped at the ' +
|
|
25
|
+
'server\'s configured max), so an idle workflow\'s update cadence is roughly twice this value ' +
|
|
26
|
+
'(the long-poll bound, then this sleep) rather than a much longer, separate server default.';
|
|
27
|
+
/** For a command that always monitors, where oclif can apply the defaults itself. */
|
|
28
|
+
export function monitorStreamFlags() {
|
|
29
|
+
return {
|
|
30
|
+
'include-payloads': Flags.boolean({
|
|
31
|
+
description: PAYLOADS_DESCRIPTION,
|
|
32
|
+
default: MONITOR_DEFAULTS.includePayloads
|
|
33
|
+
}),
|
|
34
|
+
interval: Flags.integer({
|
|
35
|
+
description: INTERVAL_DESCRIPTION,
|
|
36
|
+
default: MONITOR_DEFAULTS.interval,
|
|
37
|
+
min: 1
|
|
38
|
+
}),
|
|
39
|
+
color: Flags.boolean({
|
|
40
|
+
description: COLOR_DESCRIPTION,
|
|
41
|
+
default: MONITOR_DEFAULTS.color,
|
|
42
|
+
allowNo: true
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* For a command where monitoring is opt-in (`workflow start --monitor`).
|
|
48
|
+
*
|
|
49
|
+
* These carry no oclif `default` on purpose: a defaulted flag counts as present
|
|
50
|
+
* (`validateFlags` runs a relationship check whenever the parsed value is not
|
|
51
|
+
* `undefined`, and `validateDependsOn` has no `setFromDefault` exemption the way
|
|
52
|
+
* `validateExclusive` does), which triggers its own `dependsOn` check and fails
|
|
53
|
+
* every invocation that omits `--monitor` — including a plain `workflow start`.
|
|
54
|
+
* The caller applies the defaults in `run()`, so the interval's default is
|
|
55
|
+
* spelled out in the help text rather than rendered by oclif.
|
|
56
|
+
*/
|
|
57
|
+
export function gatedMonitorStreamFlags(gatedBy) {
|
|
58
|
+
const gate = { dependsOn: [gatedBy], helpGroup: 'MONITOR' };
|
|
59
|
+
const requires = ` (requires --${gatedBy})`;
|
|
60
|
+
return {
|
|
61
|
+
'include-payloads': Flags.boolean({
|
|
62
|
+
description: `${PAYLOADS_DESCRIPTION}${requires}`,
|
|
63
|
+
...gate
|
|
64
|
+
}),
|
|
65
|
+
interval: Flags.integer({
|
|
66
|
+
description: `${INTERVAL_DESCRIPTION}${requires} [default: ${MONITOR_DEFAULTS.interval}]`,
|
|
67
|
+
min: 1,
|
|
68
|
+
...gate
|
|
69
|
+
}),
|
|
70
|
+
color: Flags.boolean({
|
|
71
|
+
description: `${COLOR_DESCRIPTION}${requires}`,
|
|
72
|
+
allowNo: true,
|
|
73
|
+
...gate
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Normalizes statuses from earlier API contracts.
|
|
3
|
+
*
|
|
4
|
+
* This can be removed after Aug, 2026
|
|
4
5
|
*
|
|
5
6
|
* @param status - Workflow status from the API
|
|
6
7
|
* @returns Normalized workflow status
|
|
7
8
|
*/
|
|
8
|
-
export declare const normalizeWorkflowStatus: <T extends string | null | undefined>(status: T) => T | "continued_as_new";
|
|
9
|
+
export declare const normalizeWorkflowStatus: <T extends string | null | undefined>(status: T) => T | "continued_as_new" | "cancelled";
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Normalizes statuses from earlier API contracts.
|
|
3
|
+
*
|
|
4
|
+
* This can be removed after Aug, 2026
|
|
4
5
|
*
|
|
5
6
|
* @param status - Workflow status from the API
|
|
6
7
|
* @returns Normalized workflow status
|
|
7
8
|
*/
|
|
8
|
-
export const normalizeWorkflowStatus = (status) =>
|
|
9
|
+
export const normalizeWorkflowStatus = (status) => {
|
|
10
|
+
if (status === 'continued') {
|
|
11
|
+
return 'continued_as_new';
|
|
12
|
+
}
|
|
13
|
+
if (status === 'canceled') {
|
|
14
|
+
return 'cancelled';
|
|
15
|
+
}
|
|
16
|
+
return status;
|
|
17
|
+
};
|
|
@@ -4,6 +4,9 @@ describe('normalizeWorkflowStatus', () => {
|
|
|
4
4
|
it('temporarily maps continued to continued_as_new', () => {
|
|
5
5
|
expect(normalizeWorkflowStatus('continued')).toBe('continued_as_new');
|
|
6
6
|
});
|
|
7
|
+
it('maps the previous canceled spelling to cancelled', () => {
|
|
8
|
+
expect(normalizeWorkflowStatus('canceled')).toBe('cancelled');
|
|
9
|
+
});
|
|
7
10
|
it('leaves other statuses and nullish values unchanged', () => {
|
|
8
11
|
expect(normalizeWorkflowStatus('completed')).toBe('completed');
|
|
9
12
|
expect(normalizeWorkflowStatus('continued_as_new')).toBe('continued_as_new');
|
|
@@ -4,7 +4,7 @@ const WORKFLOW_STATUS_MAP = {
|
|
|
4
4
|
running: { icon: '●', color: 'yellow' },
|
|
5
5
|
completed: { icon: '●', color: 'green' },
|
|
6
6
|
failed: { icon: '✗', color: 'red' },
|
|
7
|
-
|
|
7
|
+
cancelled: { icon: '○', color: 'gray' },
|
|
8
8
|
terminated: { icon: '✗', color: 'gray' },
|
|
9
9
|
timed_out: { icon: '✗', color: 'red' },
|
|
10
10
|
continued_as_new: { icon: '↻', color: 'blue' }
|
|
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { getWorkflowIdResult, getWorkflowIdRunsRidResult, getWorkflowIdTraceLog, getWorkflowIdRunsRidTraceLog } from '#api/generated/api.js';
|
|
4
4
|
import { normalizeWorkflowStatus } from '#utils/normalize_workflow_status.js';
|
|
5
|
-
import {
|
|
5
|
+
import { isTerminalStatus } from '#utils/format_workflow_result.js';
|
|
6
6
|
import { createBoundedCache } from '#views/dev/utils/bounded_cache.js';
|
|
7
7
|
const EMPTY_DETAIL = {
|
|
8
8
|
result: null,
|
|
@@ -73,7 +73,7 @@ const readTraceLog = async (source) => {
|
|
|
73
73
|
return JSON.parse(content);
|
|
74
74
|
};
|
|
75
75
|
// Run detail and trace fetches are best-effort. Many statuses (in-progress,
|
|
76
|
-
// failed,
|
|
76
|
+
// failed, cancelled) don't have a fully-formed result or trace available at
|
|
77
77
|
// any given moment, and that's expected — the caller falls back to
|
|
78
78
|
// EMPTY_DETAIL and the UI renders whatever's there. Swallow everything.
|
|
79
79
|
const fetchTrace = async (workflowId, runId) => {
|
|
@@ -104,8 +104,8 @@ const fetchResult = async (workflowId, runId) => {
|
|
|
104
104
|
};
|
|
105
105
|
// The cache is intentionally only populated for terminal statuses — partial results
|
|
106
106
|
// from a still-running workflow would otherwise stick and stall the UI when the run
|
|
107
|
-
// eventually finishes. `
|
|
108
|
-
export const isTerminalRunStatus = (status) =>
|
|
107
|
+
// eventually finishes. `isTerminalStatus` is shared with `workflow monitor`.
|
|
108
|
+
export const isTerminalRunStatus = (status) => isTerminalStatus(status) !== undefined;
|
|
109
109
|
export const useRunDetail = (workflowId, runId, status) => {
|
|
110
110
|
const [detail, setDetail] = useState(EMPTY_DETAIL);
|
|
111
111
|
const fetchIdRef = useRef(0);
|
|
@@ -4,7 +4,7 @@ describe('isTerminalRunStatus', () => {
|
|
|
4
4
|
it('returns true for completed states', () => {
|
|
5
5
|
expect(isTerminalRunStatus('completed')).toBe(true);
|
|
6
6
|
expect(isTerminalRunStatus('failed')).toBe(true);
|
|
7
|
-
expect(isTerminalRunStatus('
|
|
7
|
+
expect(isTerminalRunStatus('cancelled')).toBe(true);
|
|
8
8
|
expect(isTerminalRunStatus('terminated')).toBe(true);
|
|
9
9
|
expect(isTerminalRunStatus('timed_out')).toBe(true);
|
|
10
10
|
});
|
|
@@ -21,7 +21,7 @@ const STATUS_ORDER = {
|
|
|
21
21
|
failed: 1,
|
|
22
22
|
timed_out: 2,
|
|
23
23
|
terminated: 3,
|
|
24
|
-
|
|
24
|
+
cancelled: 4,
|
|
25
25
|
continued_as_new: 5,
|
|
26
26
|
completed: 6
|
|
27
27
|
};
|
|
@@ -110,7 +110,7 @@ const DetailPane = ({ run, pane, rows }) => {
|
|
|
110
110
|
}
|
|
111
111
|
return _jsx(Text, { dimColor: true, children: "\u2014" });
|
|
112
112
|
}
|
|
113
|
-
if (activePane === 'output' &&
|
|
113
|
+
if (activePane === 'output' && typeof pane.error === 'string') {
|
|
114
114
|
const lines = String(pane.error).split('\n').slice(0, tabContentRows);
|
|
115
115
|
return (_jsx(Box, { flexDirection: "column", children: lines.map((line, i) => (_jsx(Text, { color: "red", wrap: "truncate-end", children: line }, i))) }));
|
|
116
116
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -1236,6 +1236,7 @@
|
|
|
1236
1236
|
"<%= config.bin %> <%= command.id %> simple basic_input",
|
|
1237
1237
|
"<%= config.bin %> <%= command.id %> simple --input '{\"values\":[1,2,3]}'",
|
|
1238
1238
|
"<%= config.bin %> <%= command.id %> simple --input input.json",
|
|
1239
|
+
"<%= config.bin %> <%= command.id %> simple --input input.json --monitor",
|
|
1239
1240
|
"<%= config.bin %> <%= command.id %> simple --input '{\"key\":\"value\"}' --catalog my-catalog",
|
|
1240
1241
|
"<%= config.bin %> <%= command.id %> simple --json"
|
|
1241
1242
|
],
|
|
@@ -1271,6 +1272,44 @@
|
|
|
1271
1272
|
"hasDynamicHelp": false,
|
|
1272
1273
|
"multiple": false,
|
|
1273
1274
|
"type": "option"
|
|
1275
|
+
},
|
|
1276
|
+
"monitor": {
|
|
1277
|
+
"char": "m",
|
|
1278
|
+
"description": "After starting, attach and stream status updates until the workflow ends (Ctrl+C detaches; the workflow keeps running). Cannot be combined with --json",
|
|
1279
|
+
"name": "monitor",
|
|
1280
|
+
"allowNo": false,
|
|
1281
|
+
"type": "boolean"
|
|
1282
|
+
},
|
|
1283
|
+
"include-payloads": {
|
|
1284
|
+
"dependsOn": [
|
|
1285
|
+
"monitor"
|
|
1286
|
+
],
|
|
1287
|
+
"description": "Include decoded step input/output payloads (requires --monitor)",
|
|
1288
|
+
"helpGroup": "MONITOR",
|
|
1289
|
+
"name": "include-payloads",
|
|
1290
|
+
"allowNo": false,
|
|
1291
|
+
"type": "boolean"
|
|
1292
|
+
},
|
|
1293
|
+
"interval": {
|
|
1294
|
+
"dependsOn": [
|
|
1295
|
+
"monitor"
|
|
1296
|
+
],
|
|
1297
|
+
"description": "Poll interval in milliseconds. Once a resumed poll is long-polling server-side for new events, this also bounds how long that block may last (capped at the server's configured max), so an idle workflow's update cadence is roughly twice this value (the long-poll bound, then this sleep) rather than a much longer, separate server default. (requires --monitor) [default: 2500]",
|
|
1298
|
+
"helpGroup": "MONITOR",
|
|
1299
|
+
"name": "interval",
|
|
1300
|
+
"hasDynamicHelp": false,
|
|
1301
|
+
"multiple": false,
|
|
1302
|
+
"type": "option"
|
|
1303
|
+
},
|
|
1304
|
+
"color": {
|
|
1305
|
+
"dependsOn": [
|
|
1306
|
+
"monitor"
|
|
1307
|
+
],
|
|
1308
|
+
"description": "Colorize status output (use --no-color to disable) (requires --monitor)",
|
|
1309
|
+
"helpGroup": "MONITOR",
|
|
1310
|
+
"name": "color",
|
|
1311
|
+
"allowNo": true,
|
|
1312
|
+
"type": "boolean"
|
|
1274
1313
|
}
|
|
1275
1314
|
},
|
|
1276
1315
|
"hasDynamicHelp": false,
|
|
@@ -1713,5 +1752,5 @@
|
|
|
1713
1752
|
]
|
|
1714
1753
|
}
|
|
1715
1754
|
},
|
|
1716
|
-
"version": "0.10.1-next.
|
|
1755
|
+
"version": "0.10.1-next.ca7de69.0"
|
|
1717
1756
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outputai/cli",
|
|
3
|
-
"version": "0.10.1-next.
|
|
3
|
+
"version": "0.10.1-next.ca7de69.0",
|
|
4
4
|
"description": "CLI for Output.ai workflow generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"handlebars": "4.7.9",
|
|
31
31
|
"ink": "7.0.1",
|
|
32
32
|
"ink-spinner": "5.0.0",
|
|
33
|
-
"js-yaml": "4.3.
|
|
33
|
+
"js-yaml": "4.3.1",
|
|
34
34
|
"json-schema-library": "11.4.0",
|
|
35
35
|
"ky": "2.0.2",
|
|
36
36
|
"react": "19.2.5",
|
|
37
37
|
"semver": "7.7.4",
|
|
38
38
|
"undici": "8.9.0",
|
|
39
|
-
"@outputai/
|
|
40
|
-
"@outputai/
|
|
41
|
-
"@outputai/
|
|
39
|
+
"@outputai/evals": "0.10.1-next.ca7de69.0",
|
|
40
|
+
"@outputai/credentials": "0.10.1-next.ca7de69.0",
|
|
41
|
+
"@outputai/llm": "0.10.1-next.ca7de69.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/cli-progress": "3.11.6",
|