@outputai/cli 0.1.13-dev.01b8dea.0 → 0.1.13-dev.59a1b6d.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.
@@ -24,11 +24,7 @@ export const WorkflowRunInfoStatus = {
24
24
  timed_out: 'timed_out',
25
25
  continued: 'continued',
26
26
  };
27
- export const PostWorkflowRun200Status = {
28
- completed: 'completed',
29
- failed: 'failed',
30
- };
31
- export const GetWorkflowIdStatus200Status = {
27
+ export const WorkflowStatusResponseStatus = {
32
28
  canceled: 'canceled',
33
29
  completed: 'completed',
34
30
  continued_as_new: 'continued_as_new',
@@ -38,7 +34,7 @@ export const GetWorkflowIdStatus200Status = {
38
34
  timed_out: 'timed_out',
39
35
  unspecified: 'unspecified',
40
36
  };
41
- export const GetWorkflowIdResult200Status = {
37
+ export const WorkflowResultResponseStatus = {
42
38
  completed: 'completed',
43
39
  failed: 'failed',
44
40
  canceled: 'canceled',
@@ -46,6 +42,10 @@ export const GetWorkflowIdResult200Status = {
46
42
  timed_out: 'timed_out',
47
43
  continued: 'continued',
48
44
  };
45
+ export const PostWorkflowRun200Status = {
46
+ completed: 'completed',
47
+ failed: 'failed',
48
+ };
49
49
  ;
50
50
  export const getGetHealthUrl = () => {
51
51
  return `/health`;
@@ -87,6 +87,24 @@ export const getWorkflowIdStatus = async (id, options) => {
87
87
  method: 'GET'
88
88
  });
89
89
  };
90
+ export const getGetWorkflowIdRunsRidStatusUrl = (id, rid) => {
91
+ return `/workflow/${id}/runs/${rid}/status`;
92
+ };
93
+ export const getWorkflowIdRunsRidStatus = async (id, rid, options) => {
94
+ return customFetchInstance(getGetWorkflowIdRunsRidStatusUrl(id, rid), {
95
+ ...options,
96
+ method: 'GET'
97
+ });
98
+ };
99
+ export const getPatchWorkflowIdRunsRidStopUrl = (id, rid) => {
100
+ return `/workflow/${id}/runs/${rid}/stop`;
101
+ };
102
+ export const patchWorkflowIdRunsRidStop = async (id, rid, options) => {
103
+ return customFetchInstance(getPatchWorkflowIdRunsRidStopUrl(id, rid), {
104
+ ...options,
105
+ method: 'PATCH'
106
+ });
107
+ };
90
108
  export const getPatchWorkflowIdStopUrl = (id) => {
91
109
  return `/workflow/${id}/stop`;
92
110
  };
@@ -96,6 +114,17 @@ export const patchWorkflowIdStop = async (id, options) => {
96
114
  method: 'PATCH'
97
115
  });
98
116
  };
117
+ export const getPostWorkflowIdRunsRidTerminateUrl = (id, rid) => {
118
+ return `/workflow/${id}/runs/${rid}/terminate`;
119
+ };
120
+ export const postWorkflowIdRunsRidTerminate = async (id, rid, postWorkflowIdRunsRidTerminateBody, options) => {
121
+ return customFetchInstance(getPostWorkflowIdRunsRidTerminateUrl(id, rid), {
122
+ ...options,
123
+ method: 'POST',
124
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
125
+ body: JSON.stringify(postWorkflowIdRunsRidTerminateBody)
126
+ });
127
+ };
99
128
  export const getPostWorkflowIdTerminateUrl = (id) => {
100
129
  return `/workflow/${id}/terminate`;
101
130
  };
@@ -107,15 +136,26 @@ export const postWorkflowIdTerminate = async (id, postWorkflowIdTerminateBody, o
107
136
  body: JSON.stringify(postWorkflowIdTerminateBody)
108
137
  });
109
138
  };
139
+ export const getPostWorkflowIdRunsRidResetUrl = (id, rid) => {
140
+ return `/workflow/${id}/runs/${rid}/reset`;
141
+ };
142
+ export const postWorkflowIdRunsRidReset = async (id, rid, resetWorkflowRequest, options) => {
143
+ return customFetchInstance(getPostWorkflowIdRunsRidResetUrl(id, rid), {
144
+ ...options,
145
+ method: 'POST',
146
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
147
+ body: JSON.stringify(resetWorkflowRequest)
148
+ });
149
+ };
110
150
  export const getPostWorkflowIdResetUrl = (id) => {
111
151
  return `/workflow/${id}/reset`;
112
152
  };
113
- export const postWorkflowIdReset = async (id, postWorkflowIdResetBody, options) => {
153
+ export const postWorkflowIdReset = async (id, resetWorkflowRequest, options) => {
114
154
  return customFetchInstance(getPostWorkflowIdResetUrl(id), {
115
155
  ...options,
116
156
  method: 'POST',
117
157
  headers: { 'Content-Type': 'application/json', ...options?.headers },
118
- body: JSON.stringify(postWorkflowIdResetBody)
158
+ body: JSON.stringify(resetWorkflowRequest)
119
159
  });
120
160
  };
121
161
  export const getGetWorkflowIdResultUrl = (id) => {
@@ -127,6 +167,15 @@ export const getWorkflowIdResult = async (id, options) => {
127
167
  method: 'GET'
128
168
  });
129
169
  };
170
+ export const getGetWorkflowIdRunsRidResultUrl = (id, rid) => {
171
+ return `/workflow/${id}/runs/${rid}/result`;
172
+ };
173
+ export const getWorkflowIdRunsRidResult = async (id, rid, options) => {
174
+ return customFetchInstance(getGetWorkflowIdRunsRidResultUrl(id, rid), {
175
+ ...options,
176
+ method: 'GET'
177
+ });
178
+ };
130
179
  export const getGetWorkflowIdTraceLogUrl = (id) => {
131
180
  return `/workflow/${id}/trace-log`;
132
181
  };
@@ -136,6 +185,15 @@ export const getWorkflowIdTraceLog = async (id, options) => {
136
185
  method: 'GET'
137
186
  });
138
187
  };
188
+ export const getGetWorkflowIdRunsRidTraceLogUrl = (id, rid) => {
189
+ return `/workflow/${id}/runs/${rid}/trace-log`;
190
+ };
191
+ export const getWorkflowIdRunsRidTraceLog = async (id, rid, options) => {
192
+ return customFetchInstance(getGetWorkflowIdRunsRidTraceLogUrl(id, rid), {
193
+ ...options,
194
+ method: 'GET'
195
+ });
196
+ };
139
197
  export const getGetWorkflowCatalogIdUrl = (id) => {
140
198
  return `/workflow/catalog/${id}`;
141
199
  };
@@ -81,7 +81,7 @@ services:
81
81
  condition: service_healthy
82
82
  worker:
83
83
  condition: service_healthy
84
- image: outputai/api:${OUTPUT_API_VERSION:-0.1.13-dev.01b8dea.0}
84
+ image: outputai/api:${OUTPUT_API_VERSION:-0.1.13-dev.59a1b6d.0}
85
85
  init: true
86
86
  networks:
87
87
  - main
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class CredentialsSet extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ path: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ value: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
8
+ };
9
+ static flags: {
10
+ environment: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ workflow: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ };
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,57 @@
1
+ import { Args, Command, Flags } from '@oclif/core';
2
+ import { load as parseYaml, dump as stringifyYaml } from 'js-yaml';
3
+ import { decryptCredentials, credentialsExist, writeEncrypted, resolveCredentialsPath } from '#services/credentials_service.js';
4
+ const setNestedValue = (obj, dotPath, value) => {
5
+ const parts = dotPath.split('.');
6
+ const parent = parts.slice(0, -1).reduce((current, key) => {
7
+ if (!current[key] || typeof current[key] !== 'object') {
8
+ current[key] = {};
9
+ }
10
+ return current[key];
11
+ }, obj);
12
+ parent[parts[parts.length - 1]] = value;
13
+ };
14
+ export default class CredentialsSet extends Command {
15
+ static description = 'Set a credential value by dot-notation path';
16
+ static examples = [
17
+ '<%= config.bin %> <%= command.id %> anthropic.api_key sk-ant-...',
18
+ '<%= config.bin %> <%= command.id %> openai.api_key sk-... --environment production',
19
+ '<%= config.bin %> <%= command.id %> stripe.key sk_live_... --workflow my_workflow'
20
+ ];
21
+ static args = {
22
+ path: Args.string({
23
+ description: 'Dot-notation path to the credential (e.g. anthropic.api_key)',
24
+ required: true
25
+ }),
26
+ value: Args.string({
27
+ description: 'Value to set',
28
+ required: true
29
+ })
30
+ };
31
+ static flags = {
32
+ environment: Flags.string({
33
+ char: 'e',
34
+ description: 'Target environment (e.g. production, development)'
35
+ }),
36
+ workflow: Flags.string({
37
+ char: 'w',
38
+ description: 'Target a specific workflow directory'
39
+ })
40
+ };
41
+ async run() {
42
+ const { args, flags } = await this.parse(CredentialsSet);
43
+ const environment = flags.environment;
44
+ const workflow = flags.workflow;
45
+ if (environment && workflow) {
46
+ this.error('Cannot specify both --environment and --workflow.');
47
+ }
48
+ if (!credentialsExist(environment, workflow)) {
49
+ this.error(`No credentials file found at ${resolveCredentialsPath(environment, workflow)}. Run "output credentials init" first.`);
50
+ }
51
+ const plaintext = decryptCredentials(environment, workflow);
52
+ const data = (parseYaml(plaintext) || {});
53
+ setNestedValue(data, args.path, args.value);
54
+ writeEncrypted(environment, stringifyYaml(data), workflow);
55
+ this.log(`Set ${args.path}`);
56
+ }
57
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,95 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
3
+ import * as credentialsService from '#services/credentials_service.js';
4
+ import CredentialsSet from './set.js';
5
+ vi.mock('#services/credentials_service.js');
6
+ vi.mock('js-yaml', () => ({
7
+ load: vi.fn((yaml) => {
8
+ if (yaml.includes('sk-existing')) {
9
+ return { anthropic: { api_key: 'sk-existing' } };
10
+ }
11
+ return {};
12
+ }),
13
+ dump: vi.fn((obj) => JSON.stringify(obj))
14
+ }));
15
+ describe('credentials set command', () => {
16
+ beforeEach(() => {
17
+ vi.clearAllMocks();
18
+ vi.mocked(credentialsService.credentialsExist).mockReturnValue(true);
19
+ vi.mocked(credentialsService.decryptCredentials).mockReturnValue('anthropic:\n api_key: sk-existing\n');
20
+ vi.mocked(credentialsService.writeEncrypted).mockImplementation(() => { });
21
+ });
22
+ afterEach(() => {
23
+ vi.restoreAllMocks();
24
+ });
25
+ const createTestCommand = (parsedArgs = {}, flags = {}) => {
26
+ const cmd = new CredentialsSet([], {});
27
+ cmd.log = vi.fn();
28
+ cmd.error = vi.fn((msg) => {
29
+ throw new Error(msg);
30
+ });
31
+ Object.defineProperty(cmd, 'parse', {
32
+ value: vi.fn().mockResolvedValue({
33
+ args: { path: 'anthropic.api_key', value: 'sk-new-key', ...parsedArgs },
34
+ flags: { environment: undefined, workflow: undefined, ...flags }
35
+ }),
36
+ configurable: true
37
+ });
38
+ return cmd;
39
+ };
40
+ describe('command structure', () => {
41
+ it('should have correct description', () => {
42
+ expect(CredentialsSet.description).toContain('credential value');
43
+ });
44
+ it('should have required path and value arguments', () => {
45
+ expect(CredentialsSet.args.path).toBeDefined();
46
+ expect(CredentialsSet.args.path.required).toBe(true);
47
+ expect(CredentialsSet.args.value).toBeDefined();
48
+ expect(CredentialsSet.args.value.required).toBe(true);
49
+ });
50
+ it('should have environment and workflow flags', () => {
51
+ expect(CredentialsSet.flags.environment).toBeDefined();
52
+ expect(CredentialsSet.flags.workflow).toBeDefined();
53
+ });
54
+ });
55
+ describe('command execution', () => {
56
+ it('should decrypt, update, and re-encrypt credentials', async () => {
57
+ const cmd = createTestCommand();
58
+ await cmd.run();
59
+ expect(credentialsService.decryptCredentials).toHaveBeenCalledWith(undefined, undefined);
60
+ expect(credentialsService.writeEncrypted).toHaveBeenCalledWith(undefined, expect.any(String), undefined);
61
+ expect(cmd.log).toHaveBeenCalledWith('Set anthropic.api_key');
62
+ });
63
+ it('should create nested keys that do not exist', async () => {
64
+ vi.mocked(credentialsService.decryptCredentials).mockReturnValue('');
65
+ const cmd = createTestCommand({ path: 'new.nested.key', value: 'my-value' });
66
+ await cmd.run();
67
+ expect(credentialsService.writeEncrypted).toHaveBeenCalledTimes(1);
68
+ expect(cmd.log).toHaveBeenCalledWith('Set new.nested.key');
69
+ });
70
+ it('should pass environment flag to service functions', async () => {
71
+ const cmd = createTestCommand({}, { environment: 'production' });
72
+ await cmd.run();
73
+ expect(credentialsService.credentialsExist).toHaveBeenCalledWith('production', undefined);
74
+ expect(credentialsService.decryptCredentials).toHaveBeenCalledWith('production', undefined);
75
+ expect(credentialsService.writeEncrypted).toHaveBeenCalledWith('production', expect.any(String), undefined);
76
+ });
77
+ it('should pass workflow flag to service functions', async () => {
78
+ const cmd = createTestCommand({}, { workflow: 'my_workflow' });
79
+ await cmd.run();
80
+ expect(credentialsService.credentialsExist).toHaveBeenCalledWith(undefined, 'my_workflow');
81
+ expect(credentialsService.decryptCredentials).toHaveBeenCalledWith(undefined, 'my_workflow');
82
+ expect(credentialsService.writeEncrypted).toHaveBeenCalledWith(undefined, expect.any(String), 'my_workflow');
83
+ });
84
+ it('should error when both environment and workflow are specified', async () => {
85
+ const cmd = createTestCommand({}, { environment: 'production', workflow: 'my_workflow' });
86
+ await expect(cmd.run()).rejects.toThrow('Cannot specify both');
87
+ });
88
+ it('should error when credentials file does not exist', async () => {
89
+ vi.mocked(credentialsService.credentialsExist).mockReturnValue(false);
90
+ vi.mocked(credentialsService.resolveCredentialsPath).mockReturnValue('/project/config/credentials.yml.enc');
91
+ const cmd = createTestCommand();
92
+ await expect(cmd.run()).rejects.toThrow('No credentials file found');
93
+ });
94
+ });
95
+ });
@@ -6,6 +6,7 @@ export default class WorkflowRunsList extends Command {
6
6
  workflowName: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
7
  };
8
8
  static flags: {
9
+ 'task-queue': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
10
  limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
10
11
  format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
12
  };
@@ -65,6 +65,11 @@ export default class WorkflowRunsList extends Command {
65
65
  })
66
66
  };
67
67
  static flags = {
68
+ 'task-queue': Flags.string({
69
+ char: 'q',
70
+ description: 'Filter runs by task queue (defaults to OUTPUT_CATALOG_ID)',
71
+ env: 'OUTPUT_CATALOG_ID'
72
+ }),
68
73
  limit: Flags.integer({
69
74
  char: 'l',
70
75
  description: 'Maximum number of runs to return',
@@ -81,6 +86,7 @@ export default class WorkflowRunsList extends Command {
81
86
  const { args, flags } = await this.parse(WorkflowRunsList);
82
87
  const { runs, count } = await fetchWorkflowRuns({
83
88
  workflowType: args.workflowName,
89
+ taskQueue: flags['task-queue'],
84
90
  limit: flags.limit
85
91
  });
86
92
  if (runs.length === 0) {
@@ -114,7 +114,7 @@ export default class WorkflowTest extends Command {
114
114
  }
115
115
  };
116
116
  if (save) {
117
- const filePath = join(dir, `${dataset.name}.yml`);
117
+ const filePath = dataset._source ?? join(dir, `${dataset.name}.yml`);
118
118
  await writeDataset(updated, filePath);
119
119
  this.log(` Saved output to ${filePath}`);
120
120
  }
@@ -137,7 +137,7 @@ export default class WorkflowTest extends Command {
137
137
  date: now
138
138
  }
139
139
  };
140
- const filePath = join(dir, `${dataset.name}.yml`);
140
+ const filePath = dataset._source ?? join(dir, `${dataset.name}.yml`);
141
141
  await writeDataset(updated, filePath);
142
142
  this.log(` Saved eval result to ${filePath}`);
143
143
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "framework": "0.1.13-dev.01b8dea.0"
2
+ "framework": "0.1.13-dev.59a1b6d.0"
3
3
  }
@@ -8,7 +8,7 @@ export interface DatasetInfo {
8
8
  }
9
9
  export declare function resolveDatasetsDir(workflowName: string, basePath?: string): string | null;
10
10
  export declare function resolveDefaultDatasetsDir(workflowName: string, basePath?: string): string;
11
- export declare function readDataset(filePath: string): Promise<Dataset>;
11
+ export declare function readDatasetFile(filePath: string): Promise<Dataset[]>;
12
12
  export declare function readAllDatasets(workflowName: string, filterNames?: string[], basePath?: string): Promise<{
13
13
  datasets: Dataset[];
14
14
  dir: string;
@@ -24,10 +24,19 @@ export function resolveDefaultDatasetsDir(workflowName, basePath = process.cwd()
24
24
  // Default to first workflows path
25
25
  return resolve(basePath, WORKFLOWS_PATHS[0], workflowName, DATASETS_DIR);
26
26
  }
27
- export async function readDataset(filePath) {
28
- const content = await readFile(filePath, 'utf-8');
29
- const raw = yaml.load(content);
30
- return DatasetSchema.parse(raw);
27
+ export async function readDatasetFile(filePath) {
28
+ const raw = yaml.load(await readFile(filePath, 'utf-8'));
29
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
30
+ throw new Error(`Invalid dataset file: ${filePath}`);
31
+ }
32
+ return Object.entries(raw).map(([name, body]) => {
33
+ if (!body || typeof body !== 'object' || !('input' in body)) {
34
+ throw new Error(`Dataset case "${name}" in ${filePath} is missing required "input" field`);
35
+ }
36
+ const dataset = DatasetSchema.parse({ name, ...body });
37
+ dataset._source = filePath;
38
+ return dataset;
39
+ });
31
40
  }
32
41
  export async function readAllDatasets(workflowName, filterNames, basePath) {
33
42
  const dir = resolveDatasetsDir(workflowName, basePath);
@@ -36,42 +45,35 @@ export async function readAllDatasets(workflowName, filterNames, basePath) {
36
45
  }
37
46
  const files = await readdir(dir);
38
47
  const ymlFiles = files.filter(f => f.endsWith('.yml') || f.endsWith('.yaml'));
48
+ const seen = new Set();
39
49
  const datasets = [];
40
50
  for (const file of ymlFiles) {
41
- const dataset = await readDataset(join(dir, file));
42
- if (filterNames && !filterNames.includes(dataset.name)) {
43
- continue;
51
+ const cases = await readDatasetFile(join(dir, file));
52
+ for (const dataset of cases) {
53
+ if (seen.has(dataset.name)) {
54
+ throw new Error(`Duplicate dataset case name "${dataset.name}" found in ${file}`);
55
+ }
56
+ seen.add(dataset.name);
57
+ if (filterNames && !filterNames.includes(dataset.name)) {
58
+ continue;
59
+ }
60
+ datasets.push(dataset);
44
61
  }
45
- datasets.push(dataset);
46
62
  }
47
63
  return { datasets, dir };
48
64
  }
49
- async function mergeWithExisting(dataset, filePath) {
50
- if (!existsSync(filePath)) {
51
- return dataset;
52
- }
53
- try {
54
- const existing = await readDataset(filePath);
55
- return {
56
- ...existing,
57
- ...dataset,
58
- ground_truth: dataset.ground_truth ?? existing.ground_truth,
59
- last_output: dataset.last_output ?? existing.last_output,
60
- last_eval: dataset.last_eval ?? existing.last_eval
61
- };
62
- }
63
- catch {
64
- return dataset;
65
- }
66
- }
67
65
  export async function writeDataset(dataset, filePath) {
68
- const merged = await mergeWithExisting(dataset, filePath);
69
66
  const dir = resolve(filePath, '..');
70
67
  if (!existsSync(dir)) {
71
68
  await mkdir(dir, { recursive: true });
72
69
  }
73
- const content = yaml.dump(merged, { lineWidth: 120, noRefs: true, sortKeys: false });
74
- await writeFile(filePath, content, 'utf-8');
70
+ const loaded = existsSync(filePath) ? yaml.load(await readFile(filePath, 'utf-8')) : null;
71
+ const fileObj = (loaded && typeof loaded === 'object' && !Array.isArray(loaded)) ?
72
+ loaded :
73
+ {};
74
+ const { name, _source, ...caseBody } = dataset;
75
+ fileObj[name] = { ...fileObj[name], ...caseBody };
76
+ await writeFile(filePath, yaml.dump(fileObj, { lineWidth: 120, noRefs: true, sortKeys: false }), 'utf-8');
75
77
  }
76
78
  export async function listDatasets(workflowName, basePath) {
77
79
  const dir = resolveDatasetsDir(workflowName, basePath);
@@ -84,14 +86,16 @@ export async function listDatasets(workflowName, basePath) {
84
86
  for (const file of ymlFiles) {
85
87
  const filePath = join(dir, file);
86
88
  try {
87
- const dataset = await readDataset(filePath);
88
- results.push({
89
- name: dataset.name,
90
- path: filePath,
91
- hasLastOutput: dataset.last_output?.output !== undefined,
92
- lastOutputDate: dataset.last_output?.date,
93
- lastEvalDate: dataset.last_eval?.date
94
- });
89
+ const cases = await readDatasetFile(filePath);
90
+ for (const dataset of cases) {
91
+ results.push({
92
+ name: dataset.name,
93
+ path: filePath,
94
+ hasLastOutput: dataset.last_output?.output !== undefined,
95
+ lastOutputDate: dataset.last_output?.date,
96
+ lastEvalDate: dataset.last_eval?.date
97
+ });
98
+ }
95
99
  }
96
100
  catch {
97
101
  results.push({
@@ -0,0 +1 @@
1
+ export {};