@outputai/cli 0.10.1-next.2cbd0a2.0 → 0.10.1-next.2e221c7.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.
@@ -18,7 +18,7 @@ const apiState = {};
18
18
  function getApi() {
19
19
  if (!apiState.api) {
20
20
  apiState.api = ky.create({
21
- prefixUrl: config.apiUrl,
21
+ prefix: config.apiUrl,
22
22
  timeout: config.requestTimeout,
23
23
  retry: {
24
24
  limit: 2,
@@ -28,7 +28,7 @@ function getApi() {
28
28
  throwHttpErrors: false,
29
29
  hooks: {
30
30
  beforeRequest: [
31
- request => {
31
+ ({ request }) => {
32
32
  if (config.apiToken) {
33
33
  request.headers.set('Authorization', `Basic ${config.apiToken}`);
34
34
  }
@@ -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.10.1-next.2cbd0a2.0}
83
+ image: outputai/api:${OUTPUT_API_VERSION:-0.10.1-next.2e221c7.0}
84
84
  init: true
85
85
  networks:
86
86
  - main
@@ -63,7 +63,14 @@ export default class WorkflowRun extends Command {
63
63
  };
64
64
  async run() {
65
65
  const { args, flags } = await this.parse(WorkflowRun);
66
- const input = await resolveInput(args.workflowName, args.scenario, flags.input, 'run', flags.catalog);
66
+ const input = await resolveInput({
67
+ workflowName: args.workflowName,
68
+ scenario: args.scenario,
69
+ inputFlag: flags.input,
70
+ commandName: 'run',
71
+ catalog: flags.catalog,
72
+ json: this.jsonEnabled()
73
+ });
67
74
  this.log(`Executing workflow: ${args.workflowName}...`);
68
75
  const response = await executeWorkflow({
69
76
  body: {
@@ -64,7 +64,12 @@ describe('workflow run command', () => {
64
64
  headers: new Headers()
65
65
  });
66
66
  await cmd.run();
67
- expect(resolveInput).toHaveBeenCalledWith('my_workflow', undefined, undefined, 'run', undefined);
67
+ expect(resolveInput).toHaveBeenCalledWith(expect.objectContaining({
68
+ workflowName: 'my_workflow',
69
+ commandName: 'run',
70
+ catalog: undefined,
71
+ json: false
72
+ }));
68
73
  expect(postWorkflowRun).toHaveBeenCalledTimes(1);
69
74
  expect(postWorkflowRun).toHaveBeenCalledWith({ workflowName: 'my_workflow', input: { key: 'value' }, catalog: undefined }, expect.objectContaining({ config: { timeout: 600000 } }));
70
75
  expect(cmd.log).toHaveBeenCalledWith('Executing workflow: my_workflow...');
@@ -83,7 +88,12 @@ describe('workflow run command', () => {
83
88
  headers: new Headers()
84
89
  });
85
90
  await cmd.run();
86
- expect(resolveInput).toHaveBeenCalledWith('my_workflow', 'basic', undefined, 'run', 'my-catalog');
91
+ expect(resolveInput).toHaveBeenCalledWith(expect.objectContaining({
92
+ workflowName: 'my_workflow',
93
+ scenario: 'basic',
94
+ commandName: 'run',
95
+ catalog: 'my-catalog'
96
+ }));
87
97
  expect(postWorkflowRun).toHaveBeenCalledWith(expect.objectContaining({ catalog: 'my-catalog' }), expect.anything());
88
98
  });
89
99
  it('retries when response has Retry-After and succeeds on second attempt', async () => {
@@ -1,6 +1,8 @@
1
1
  import { Command } from '@oclif/core';
2
+ import { type PostWorkflowStart200 } from '#api/generated/api.js';
2
3
  export default class WorkflowStart extends Command {
3
4
  static description: string;
5
+ static enableJsonFlag: boolean;
4
6
  static examples: string[];
5
7
  static args: {
6
8
  workflowName: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
@@ -10,6 +12,6 @@ export default class WorkflowStart extends Command {
10
12
  input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
13
  catalog: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
14
  };
13
- run(): Promise<void>;
15
+ run(): Promise<PostWorkflowStart200>;
14
16
  catch(error: Error): Promise<void>;
15
17
  }
@@ -4,11 +4,13 @@ import { handleApiError } from '#utils/error_handler.js';
4
4
  import { resolveInput } from '#utils/resolve_input.js';
5
5
  export default class WorkflowStart extends Command {
6
6
  static description = 'Start a workflow asynchronously without waiting for completion';
7
+ static enableJsonFlag = true;
7
8
  static examples = [
8
9
  '<%= config.bin %> <%= command.id %> simple basic_input',
9
10
  '<%= config.bin %> <%= command.id %> simple --input \'{"values":[1,2,3]}\'',
10
11
  '<%= config.bin %> <%= command.id %> simple --input input.json',
11
- '<%= config.bin %> <%= command.id %> simple --input \'{"key":"value"}\' --catalog my-catalog'
12
+ '<%= config.bin %> <%= command.id %> simple --input \'{"key":"value"}\' --catalog my-catalog',
13
+ '<%= config.bin %> <%= command.id %> simple --json'
12
14
  ];
13
15
  static args = {
14
16
  workflowName: Args.string({
@@ -37,7 +39,14 @@ export default class WorkflowStart extends Command {
37
39
  };
38
40
  async run() {
39
41
  const { args, flags } = await this.parse(WorkflowStart);
40
- const input = await resolveInput(args.workflowName, args.scenario, flags.input, 'start', flags.catalog);
42
+ const input = await resolveInput({
43
+ workflowName: args.workflowName,
44
+ scenario: args.scenario,
45
+ inputFlag: flags.input,
46
+ commandName: 'start',
47
+ catalog: flags.catalog,
48
+ json: this.jsonEnabled()
49
+ });
41
50
  this.log(`Starting workflow: ${args.workflowName}...`);
42
51
  const response = await postWorkflowStart({
43
52
  workflowName: args.workflowName,
@@ -57,6 +66,7 @@ export default class WorkflowStart extends Command {
57
66
  `Use "workflow result ${result.workflowId || '<workflow-id>'}" to get the workflow result when complete`
58
67
  ].join('\n');
59
68
  this.log(`\n${output}`);
69
+ return result;
60
70
  }
61
71
  async catch(error) {
62
72
  return handleApiError(error, (...args) => this.error(...args), {
@@ -36,13 +36,17 @@ describe('workflow start command', () => {
36
36
  expect(WorkflowStart.flags.catalog.env).toBe('OUTPUT_CATALOG_ID');
37
37
  expect(WorkflowStart.flags.catalog.char).toBe('c');
38
38
  });
39
+ it('enables the built-in --json flag', async () => {
40
+ const WorkflowStart = (await import('./start.js')).default;
41
+ expect(WorkflowStart.enableJsonFlag).toBe(true);
42
+ });
39
43
  });
40
44
  describe('run()', () => {
41
- const createCommand = async (flagOverrides = {}) => {
45
+ const createCommand = async (flagOverrides = {}, argv = ['my_workflow']) => {
42
46
  const WorkflowStart = (await import('./start.js')).default;
43
47
  const { postWorkflowStart } = await import('#api/generated/api.js');
44
48
  const { resolveInput } = await import('#utils/resolve_input.js');
45
- const cmd = new WorkflowStart(['my_workflow'], {});
49
+ const cmd = new WorkflowStart(argv, {});
46
50
  cmd.log = vi.fn();
47
51
  cmd.error = vi.fn(() => {
48
52
  throw new Error('error called');
@@ -61,9 +65,15 @@ describe('workflow start command', () => {
61
65
  status: 200,
62
66
  headers: new Headers()
63
67
  });
64
- await cmd.run();
65
- expect(resolveInput).toHaveBeenCalledWith('my_workflow', undefined, undefined, 'start', 'my-catalog');
68
+ const result = await cmd.run();
69
+ expect(resolveInput).toHaveBeenCalledWith(expect.objectContaining({
70
+ workflowName: 'my_workflow',
71
+ commandName: 'start',
72
+ catalog: 'my-catalog',
73
+ json: false
74
+ }));
66
75
  expect(postWorkflowStart).toHaveBeenCalledWith(expect.objectContaining({ workflowName: 'my_workflow', catalog: 'my-catalog' }));
76
+ expect(result).toEqual({ workflowId: 'wf-123' });
67
77
  });
68
78
  it('passes undefined catalog through when none is set', async () => {
69
79
  const { cmd, postWorkflowStart, resolveInput } = await createCommand();
@@ -74,7 +84,22 @@ describe('workflow start command', () => {
74
84
  headers: new Headers()
75
85
  });
76
86
  await cmd.run();
77
- expect(resolveInput).toHaveBeenCalledWith('my_workflow', undefined, undefined, 'start', undefined);
87
+ expect(resolveInput).toHaveBeenCalledWith(expect.objectContaining({
88
+ workflowName: 'my_workflow',
89
+ commandName: 'start',
90
+ catalog: undefined
91
+ }));
92
+ });
93
+ it('tells resolveInput to stay quiet when --json is set', async () => {
94
+ const { cmd, postWorkflowStart, resolveInput } = await createCommand({}, ['my_workflow', 'basic', '--json']);
95
+ resolveInput.mockResolvedValue({});
96
+ postWorkflowStart.mockResolvedValue({
97
+ data: { workflowId: 'wf-123' },
98
+ status: 200,
99
+ headers: new Headers()
100
+ });
101
+ await cmd.run();
102
+ expect(resolveInput).toHaveBeenCalledWith(expect.objectContaining({ json: true }));
78
103
  });
79
104
  });
80
105
  });
@@ -1,3 +1,3 @@
1
1
  {
2
- "framework": "0.10.1-next.2cbd0a2.0"
2
+ "framework": "0.10.1-next.2e221c7.0"
3
3
  }
@@ -44,7 +44,7 @@ config/
44
44
  ## Key Conventions
45
45
 
46
46
  - **Workflows are deterministic**: No I/O, no `Date.now()`, no `Math.random()` in `workflow.ts`. All side effects go in steps or evaluators.
47
- - **HTTP clients**: Always use `httpClient` from `@outputai/http` -- never raw `fetch` or `axios`. This enables automatic tracing and cost tracking.
47
+ - **HTTP clients**: Use `outputFetch` or `createKyClient` from `@outputai/http` instead of raw `fetch` or `axios`. Requests are automatically traced; use `addRequestCost` when cost tracking is needed.
48
48
  - **LLM calls**: Use `generateText` from `@outputai/llm` with `.prompt` files. Never call LLM APIs directly.
49
49
 
50
50
  ---
@@ -1,4 +1,4 @@
1
- import { httpClient } from '@outputai/http';
1
+ import { createKyClient } from '@outputai/http';
2
2
 
3
3
  export interface JinaReaderResponse {
4
4
  code: number;
@@ -12,13 +12,13 @@ export interface JinaReaderResponse {
12
12
  };
13
13
  }
14
14
 
15
- const jinaClient = httpClient( {
16
- prefixUrl: 'https://r.jina.ai',
15
+ const client = createKyClient( {
16
+ prefix: 'https://r.jina.ai',
17
17
  timeout: 30000
18
18
  } );
19
19
 
20
20
  export async function fetchBlogContent( url: string ): Promise<JinaReaderResponse> {
21
- const response = await jinaClient.post( '', {
21
+ const response = await client.post( '', {
22
22
  json: { url },
23
23
  headers: {
24
24
  'Accept': 'application/json',
@@ -1 +1,9 @@
1
- export declare function resolveInput(workflowName: string, scenario: string | undefined, inputFlag: string | undefined, commandName: string, catalog?: string): Promise<unknown>;
1
+ export type ResolveInputOptions = {
2
+ workflowName: string;
3
+ scenario?: string;
4
+ inputFlag?: string;
5
+ commandName: string;
6
+ catalog?: string;
7
+ json?: boolean;
8
+ };
9
+ export declare function resolveInput(options: ResolveInputOptions): Promise<unknown>;
@@ -1,7 +1,8 @@
1
1
  import { ux } from '@oclif/core';
2
2
  import { parseInputFlag } from '#utils/input_parser.js';
3
3
  import { resolveScenarioPath, getScenarioNotFoundMessage } from '#utils/scenario_resolver.js';
4
- export async function resolveInput(workflowName, scenario, inputFlag, commandName, catalog) {
4
+ export async function resolveInput(options) {
5
+ const { workflowName, scenario, inputFlag, commandName, catalog, json } = options;
5
6
  if (inputFlag && scenario) {
6
7
  return ux.error('Cannot use both scenario argument and --input flag. Choose one.', { exit: 1 });
7
8
  }
@@ -13,7 +14,12 @@ export async function resolveInput(workflowName, scenario, inputFlag, commandNam
13
14
  if (!resolution.found) {
14
15
  return ux.error(getScenarioNotFoundMessage(workflowName, scenario, resolution.searchedPaths), { exit: 1 });
15
16
  }
16
- ux.stdout(`Using scenario: ${resolution.path}\n`);
17
+ // Advisory notice goes to stderr so stdout stays clean for piping, and is
18
+ // skipped entirely under --json where even stderr is noise to a script
19
+ // consuming the structured output (same rule as the init hook's banner).
20
+ if (!json) {
21
+ ux.stderr(`Using scenario: ${resolution.path}`);
22
+ }
17
23
  return parseInputFlag(resolution.path);
18
24
  }
19
25
  return ux.error('Input required. Provide either:\n' +
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,75 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
3
+ vi.mock('@oclif/core', () => ({
4
+ ux: {
5
+ stdout: vi.fn(),
6
+ stderr: vi.fn(),
7
+ error: vi.fn(() => {
8
+ throw new Error('ux.error called');
9
+ })
10
+ }
11
+ }));
12
+ vi.mock('#utils/input_parser.js', () => ({
13
+ parseInputFlag: vi.fn()
14
+ }));
15
+ vi.mock('#utils/scenario_resolver.js', () => ({
16
+ resolveScenarioPath: vi.fn(),
17
+ getScenarioNotFoundMessage: vi.fn()
18
+ }));
19
+ describe('resolveInput', () => {
20
+ beforeEach(() => {
21
+ vi.clearAllMocks();
22
+ });
23
+ it('emits the scenario notice on stderr so --json stdout stays clean', async () => {
24
+ const { ux } = await import('@oclif/core');
25
+ const { parseInputFlag } = await import('#utils/input_parser.js');
26
+ const { resolveScenarioPath } = await import('#utils/scenario_resolver.js');
27
+ const { resolveInput } = await import('./resolve_input.js');
28
+ vi.mocked(resolveScenarioPath).mockResolvedValue({
29
+ found: true,
30
+ path: '/scenarios/happy_path.json'
31
+ });
32
+ vi.mocked(parseInputFlag).mockReturnValue({ key: 'value' });
33
+ const result = await resolveInput({
34
+ workflowName: 'web_search',
35
+ scenario: 'happy_path',
36
+ commandName: 'start'
37
+ });
38
+ expect(result).toEqual({ key: 'value' });
39
+ expect(ux.stderr).toHaveBeenCalledWith('Using scenario: /scenarios/happy_path.json');
40
+ expect(ux.stdout).not.toHaveBeenCalled();
41
+ });
42
+ it('suppresses the scenario notice entirely under --json', async () => {
43
+ const { ux } = await import('@oclif/core');
44
+ const { parseInputFlag } = await import('#utils/input_parser.js');
45
+ const { resolveScenarioPath } = await import('#utils/scenario_resolver.js');
46
+ const { resolveInput } = await import('./resolve_input.js');
47
+ vi.mocked(resolveScenarioPath).mockResolvedValue({
48
+ found: true,
49
+ path: '/scenarios/happy_path.json'
50
+ });
51
+ vi.mocked(parseInputFlag).mockReturnValue({ key: 'value' });
52
+ const result = await resolveInput({
53
+ workflowName: 'web_search',
54
+ scenario: 'happy_path',
55
+ commandName: 'start',
56
+ json: true
57
+ });
58
+ expect(result).toEqual({ key: 'value' });
59
+ expect(ux.stderr).not.toHaveBeenCalled();
60
+ expect(ux.stdout).not.toHaveBeenCalled();
61
+ });
62
+ it('does not emit the scenario notice when input comes from --input', async () => {
63
+ const { ux } = await import('@oclif/core');
64
+ const { parseInputFlag } = await import('#utils/input_parser.js');
65
+ const { resolveInput } = await import('./resolve_input.js');
66
+ vi.mocked(parseInputFlag).mockReturnValue({ key: 'value' });
67
+ await resolveInput({
68
+ workflowName: 'web_search',
69
+ inputFlag: '{"key":"value"}',
70
+ commandName: 'start'
71
+ });
72
+ expect(ux.stderr).not.toHaveBeenCalled();
73
+ expect(ux.stdout).not.toHaveBeenCalled();
74
+ });
75
+ });
@@ -1236,9 +1236,17 @@
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 '{\"key\":\"value\"}' --catalog my-catalog"
1239
+ "<%= config.bin %> <%= command.id %> simple --input '{\"key\":\"value\"}' --catalog my-catalog",
1240
+ "<%= config.bin %> <%= command.id %> simple --json"
1240
1241
  ],
1241
1242
  "flags": {
1243
+ "json": {
1244
+ "description": "Format output as json.",
1245
+ "helpGroup": "GLOBAL",
1246
+ "name": "json",
1247
+ "allowNo": false,
1248
+ "type": "boolean"
1249
+ },
1242
1250
  "input": {
1243
1251
  "char": "i",
1244
1252
  "description": "Workflow input as JSON string or file path (overrides scenario)",
@@ -1272,7 +1280,7 @@
1272
1280
  "pluginName": "@outputai/cli",
1273
1281
  "pluginType": "core",
1274
1282
  "strict": true,
1275
- "enableJsonFlag": false,
1283
+ "enableJsonFlag": true,
1276
1284
  "isESM": true,
1277
1285
  "relativePath": [
1278
1286
  "dist",
@@ -1707,5 +1715,5 @@
1707
1715
  ]
1708
1716
  }
1709
1717
  },
1710
- "version": "0.10.1-next.2cbd0a2.0"
1718
+ "version": "0.10.1-next.2e221c7.0"
1711
1719
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outputai/cli",
3
- "version": "0.10.1-next.2cbd0a2.0",
3
+ "version": "0.10.1-next.2e221c7.0",
4
4
  "description": "CLI for Output.ai workflow generation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,14 +33,14 @@
33
33
  "ink-spinner": "5.0.0",
34
34
  "js-yaml": "4.1.1",
35
35
  "json-schema-library": "11.4.0",
36
- "ky": "1.14.3",
36
+ "ky": "2.0.2",
37
37
  "react": "19.2.5",
38
38
  "semver": "7.7.4",
39
39
  "undici": "8.5.0",
40
40
  "yaml": "^2.8.3",
41
- "@outputai/evals": "0.10.1-next.2cbd0a2.0",
42
- "@outputai/llm": "0.10.1-next.2cbd0a2.0",
43
- "@outputai/credentials": "0.10.1-next.2cbd0a2.0"
41
+ "@outputai/evals": "0.10.1-next.2e221c7.0",
42
+ "@outputai/credentials": "0.10.1-next.2e221c7.0",
43
+ "@outputai/llm": "0.10.1-next.2e221c7.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/cli-progress": "3.11.6",