@outputai/cli 0.2.1-next.7fd86e7.0 → 0.2.1-next.bd54540.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 +139 -2
- package/dist/api/generated/api.js +32 -0
- package/dist/api/http_client.js +24 -19
- package/dist/assets/docker/docker-compose-dev.yml +1 -1
- package/dist/config.d.ts +6 -38
- package/dist/config.js +22 -42
- package/dist/config.spec.d.ts +1 -0
- package/dist/config.spec.js +75 -0
- package/dist/generated/framework_version.json +1 -1
- package/dist/utils/env_loader.js +1 -2
- package/dist/utils/error_handler.js +10 -8
- package/package.json +4 -4
|
@@ -257,9 +257,9 @@ export interface ResetWorkflowResponse {
|
|
|
257
257
|
runId?: string;
|
|
258
258
|
}
|
|
259
259
|
/**
|
|
260
|
-
* Invalid request body or
|
|
260
|
+
* Invalid request body, query, or pagination token
|
|
261
261
|
*/
|
|
262
|
-
export type BadRequestResponse = ValidationErrorResponse;
|
|
262
|
+
export type BadRequestResponse = ValidationErrorResponse | ErrorResponse;
|
|
263
263
|
/**
|
|
264
264
|
* Workflow execution, workflow type, or catalog not found
|
|
265
265
|
*/
|
|
@@ -344,6 +344,86 @@ export type PostWorkflowIdRunsRidTerminateBody = {
|
|
|
344
344
|
export type PostWorkflowIdTerminateBody = {
|
|
345
345
|
reason?: string;
|
|
346
346
|
};
|
|
347
|
+
export type GetWorkflowIdHistoryParams = {
|
|
348
|
+
/**
|
|
349
|
+
* Specific run ID. Required when using pageToken.
|
|
350
|
+
*/
|
|
351
|
+
runId?: string;
|
|
352
|
+
/**
|
|
353
|
+
* Number of events per page
|
|
354
|
+
* @minimum 1
|
|
355
|
+
* @maximum 50
|
|
356
|
+
*/
|
|
357
|
+
pageSize?: number;
|
|
358
|
+
/**
|
|
359
|
+
* Base64 pagination token from previous response
|
|
360
|
+
*/
|
|
361
|
+
pageToken?: string;
|
|
362
|
+
/**
|
|
363
|
+
* Include decoded input/output payloads in events
|
|
364
|
+
*/
|
|
365
|
+
includePayloads?: boolean;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Workflow metadata (null on subsequent pages)
|
|
369
|
+
* @nullable
|
|
370
|
+
*/
|
|
371
|
+
export type GetWorkflowIdHistory200Workflow = {
|
|
372
|
+
[key: string]: unknown;
|
|
373
|
+
} | null;
|
|
374
|
+
export type GetWorkflowIdHistory200EventsItem = {
|
|
375
|
+
[key: string]: unknown;
|
|
376
|
+
};
|
|
377
|
+
export type GetWorkflowIdHistory200 = {
|
|
378
|
+
/**
|
|
379
|
+
* Workflow metadata (null on subsequent pages)
|
|
380
|
+
* @nullable
|
|
381
|
+
*/
|
|
382
|
+
workflow?: GetWorkflowIdHistory200Workflow;
|
|
383
|
+
events?: GetWorkflowIdHistory200EventsItem[];
|
|
384
|
+
/** Resolved run ID. Echo this value as the runId query parameter when fetching subsequent pages. */
|
|
385
|
+
runId?: string;
|
|
386
|
+
/** @nullable */
|
|
387
|
+
nextPageToken?: string | null;
|
|
388
|
+
};
|
|
389
|
+
export type GetWorkflowIdRunsRidHistoryParams = {
|
|
390
|
+
/**
|
|
391
|
+
* Number of events per page
|
|
392
|
+
* @minimum 1
|
|
393
|
+
* @maximum 50
|
|
394
|
+
*/
|
|
395
|
+
pageSize?: number;
|
|
396
|
+
/**
|
|
397
|
+
* Base64 pagination token from previous response
|
|
398
|
+
*/
|
|
399
|
+
pageToken?: string;
|
|
400
|
+
/**
|
|
401
|
+
* Include decoded input/output payloads in events
|
|
402
|
+
*/
|
|
403
|
+
includePayloads?: boolean;
|
|
404
|
+
};
|
|
405
|
+
/**
|
|
406
|
+
* Workflow metadata (null on subsequent pages)
|
|
407
|
+
* @nullable
|
|
408
|
+
*/
|
|
409
|
+
export type GetWorkflowIdRunsRidHistory200Workflow = {
|
|
410
|
+
[key: string]: unknown;
|
|
411
|
+
} | null;
|
|
412
|
+
export type GetWorkflowIdRunsRidHistory200EventsItem = {
|
|
413
|
+
[key: string]: unknown;
|
|
414
|
+
};
|
|
415
|
+
export type GetWorkflowIdRunsRidHistory200 = {
|
|
416
|
+
/**
|
|
417
|
+
* Workflow metadata (null on subsequent pages)
|
|
418
|
+
* @nullable
|
|
419
|
+
*/
|
|
420
|
+
workflow?: GetWorkflowIdRunsRidHistory200Workflow;
|
|
421
|
+
events?: GetWorkflowIdRunsRidHistory200EventsItem[];
|
|
422
|
+
/** The pinned run ID */
|
|
423
|
+
runId?: string;
|
|
424
|
+
/** @nullable */
|
|
425
|
+
nextPageToken?: string | null;
|
|
426
|
+
};
|
|
347
427
|
export type GetWorkflowCatalogId200 = {
|
|
348
428
|
/** Each workflow available in this catalog */
|
|
349
429
|
workflows?: Workflow[];
|
|
@@ -854,6 +934,63 @@ export type getWorkflowIdRunsRidTraceLogResponseError = (getWorkflowIdRunsRidTra
|
|
|
854
934
|
export type getWorkflowIdRunsRidTraceLogResponse = (getWorkflowIdRunsRidTraceLogResponseSuccess | getWorkflowIdRunsRidTraceLogResponseError);
|
|
855
935
|
export declare const getGetWorkflowIdRunsRidTraceLogUrl: (id: string, rid: string) => string;
|
|
856
936
|
export declare const getWorkflowIdRunsRidTraceLog: (id: string, rid: string, options?: ApiRequestOptions) => Promise<getWorkflowIdRunsRidTraceLogResponse>;
|
|
937
|
+
/**
|
|
938
|
+
* Returns decoded Temporal history events with optional payload inclusion. First page includes workflow metadata; subsequent pages return events only.
|
|
939
|
+
* @summary Get paginated workflow execution history
|
|
940
|
+
*/
|
|
941
|
+
export type getWorkflowIdHistoryResponse200 = {
|
|
942
|
+
data: GetWorkflowIdHistory200;
|
|
943
|
+
status: 200;
|
|
944
|
+
};
|
|
945
|
+
export type getWorkflowIdHistoryResponse400 = {
|
|
946
|
+
data: BadRequestResponse;
|
|
947
|
+
status: 400;
|
|
948
|
+
};
|
|
949
|
+
export type getWorkflowIdHistoryResponse404 = {
|
|
950
|
+
data: NotFoundResponse;
|
|
951
|
+
status: 404;
|
|
952
|
+
};
|
|
953
|
+
export type getWorkflowIdHistoryResponse500 = {
|
|
954
|
+
data: InternalServerErrorResponse;
|
|
955
|
+
status: 500;
|
|
956
|
+
};
|
|
957
|
+
export type getWorkflowIdHistoryResponseSuccess = (getWorkflowIdHistoryResponse200) & {
|
|
958
|
+
headers: Headers;
|
|
959
|
+
};
|
|
960
|
+
export type getWorkflowIdHistoryResponseError = (getWorkflowIdHistoryResponse400 | getWorkflowIdHistoryResponse404 | getWorkflowIdHistoryResponse500) & {
|
|
961
|
+
headers: Headers;
|
|
962
|
+
};
|
|
963
|
+
export type getWorkflowIdHistoryResponse = (getWorkflowIdHistoryResponseSuccess | getWorkflowIdHistoryResponseError);
|
|
964
|
+
export declare const getGetWorkflowIdHistoryUrl: (id: string, params?: GetWorkflowIdHistoryParams) => string;
|
|
965
|
+
export declare const getWorkflowIdHistory: (id: string, params?: GetWorkflowIdHistoryParams, options?: ApiRequestOptions) => Promise<getWorkflowIdHistoryResponse>;
|
|
966
|
+
/**
|
|
967
|
+
* @summary Get paginated workflow execution history for a specific run
|
|
968
|
+
*/
|
|
969
|
+
export type getWorkflowIdRunsRidHistoryResponse200 = {
|
|
970
|
+
data: GetWorkflowIdRunsRidHistory200;
|
|
971
|
+
status: 200;
|
|
972
|
+
};
|
|
973
|
+
export type getWorkflowIdRunsRidHistoryResponse400 = {
|
|
974
|
+
data: BadRequestResponse;
|
|
975
|
+
status: 400;
|
|
976
|
+
};
|
|
977
|
+
export type getWorkflowIdRunsRidHistoryResponse404 = {
|
|
978
|
+
data: NotFoundResponse;
|
|
979
|
+
status: 404;
|
|
980
|
+
};
|
|
981
|
+
export type getWorkflowIdRunsRidHistoryResponse500 = {
|
|
982
|
+
data: InternalServerErrorResponse;
|
|
983
|
+
status: 500;
|
|
984
|
+
};
|
|
985
|
+
export type getWorkflowIdRunsRidHistoryResponseSuccess = (getWorkflowIdRunsRidHistoryResponse200) & {
|
|
986
|
+
headers: Headers;
|
|
987
|
+
};
|
|
988
|
+
export type getWorkflowIdRunsRidHistoryResponseError = (getWorkflowIdRunsRidHistoryResponse400 | getWorkflowIdRunsRidHistoryResponse404 | getWorkflowIdRunsRidHistoryResponse500) & {
|
|
989
|
+
headers: Headers;
|
|
990
|
+
};
|
|
991
|
+
export type getWorkflowIdRunsRidHistoryResponse = (getWorkflowIdRunsRidHistoryResponseSuccess | getWorkflowIdRunsRidHistoryResponseError);
|
|
992
|
+
export declare const getGetWorkflowIdRunsRidHistoryUrl: (id: string, rid: string, params?: GetWorkflowIdRunsRidHistoryParams) => string;
|
|
993
|
+
export declare const getWorkflowIdRunsRidHistory: (id: string, rid: string, params?: GetWorkflowIdRunsRidHistoryParams, options?: ApiRequestOptions) => Promise<getWorkflowIdRunsRidHistoryResponse>;
|
|
857
994
|
/**
|
|
858
995
|
* @summary Get a specific workflow catalog by ID
|
|
859
996
|
*/
|
|
@@ -194,6 +194,38 @@ export const getWorkflowIdRunsRidTraceLog = async (id, rid, options) => {
|
|
|
194
194
|
method: 'GET'
|
|
195
195
|
});
|
|
196
196
|
};
|
|
197
|
+
export const getGetWorkflowIdHistoryUrl = (id, params) => {
|
|
198
|
+
const normalizedParams = new URLSearchParams();
|
|
199
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
200
|
+
if (value !== undefined) {
|
|
201
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
const stringifiedParams = normalizedParams.toString();
|
|
205
|
+
return stringifiedParams.length > 0 ? `/workflow/${id}/history?${stringifiedParams}` : `/workflow/${id}/history`;
|
|
206
|
+
};
|
|
207
|
+
export const getWorkflowIdHistory = async (id, params, options) => {
|
|
208
|
+
return customFetchInstance(getGetWorkflowIdHistoryUrl(id, params), {
|
|
209
|
+
...options,
|
|
210
|
+
method: 'GET'
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
export const getGetWorkflowIdRunsRidHistoryUrl = (id, rid, params) => {
|
|
214
|
+
const normalizedParams = new URLSearchParams();
|
|
215
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
216
|
+
if (value !== undefined) {
|
|
217
|
+
normalizedParams.append(key, value === null ? 'null' : value.toString());
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
const stringifiedParams = normalizedParams.toString();
|
|
221
|
+
return stringifiedParams.length > 0 ? `/workflow/${id}/runs/${rid}/history?${stringifiedParams}` : `/workflow/${id}/runs/${rid}/history`;
|
|
222
|
+
};
|
|
223
|
+
export const getWorkflowIdRunsRidHistory = async (id, rid, params, options) => {
|
|
224
|
+
return customFetchInstance(getGetWorkflowIdRunsRidHistoryUrl(id, rid, params), {
|
|
225
|
+
...options,
|
|
226
|
+
method: 'GET'
|
|
227
|
+
});
|
|
228
|
+
};
|
|
197
229
|
export const getGetWorkflowCatalogIdUrl = (id) => {
|
|
198
230
|
return `/workflow/catalog/${id}`;
|
|
199
231
|
};
|
package/dist/api/http_client.js
CHANGED
|
@@ -14,26 +14,31 @@ export class HttpError extends Error {
|
|
|
14
14
|
this.name = 'HttpError';
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
request
|
|
32
|
-
|
|
17
|
+
const apiState = {};
|
|
18
|
+
function getApi() {
|
|
19
|
+
if (!apiState.api) {
|
|
20
|
+
apiState.api = ky.create({
|
|
21
|
+
prefixUrl: config.apiUrl,
|
|
22
|
+
timeout: config.requestTimeout,
|
|
23
|
+
retry: {
|
|
24
|
+
limit: 2,
|
|
25
|
+
methods: ['get', 'put', 'head', 'delete', 'options', 'trace'],
|
|
26
|
+
statusCodes: [408, 413, 429, 502, 503, 504]
|
|
27
|
+
},
|
|
28
|
+
throwHttpErrors: false,
|
|
29
|
+
hooks: {
|
|
30
|
+
beforeRequest: [
|
|
31
|
+
request => {
|
|
32
|
+
if (config.apiToken) {
|
|
33
|
+
request.headers.set('Authorization', `Basic ${config.apiToken}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
33
37
|
}
|
|
34
|
-
|
|
38
|
+
});
|
|
35
39
|
}
|
|
36
|
-
|
|
40
|
+
return apiState.api;
|
|
41
|
+
}
|
|
37
42
|
const stripLeadingSlash = (url) => url.startsWith('/') ? url.slice(1) : url;
|
|
38
43
|
const buildKyOptions = (options) => {
|
|
39
44
|
// Extract params, config, and body for special handling
|
|
@@ -55,7 +60,7 @@ const wrapResponse = (response, data) => ({
|
|
|
55
60
|
headers: response.headers
|
|
56
61
|
});
|
|
57
62
|
export const customFetchInstance = async (url, options) => {
|
|
58
|
-
const response = await
|
|
63
|
+
const response = await getApi()(stripLeadingSlash(url), buildKyOptions(options));
|
|
59
64
|
const data = await response.json().catch(() => undefined);
|
|
60
65
|
// Throw for non-2xx responses so catch handlers can process errors
|
|
61
66
|
if (!response.ok) {
|
package/dist/config.d.ts
CHANGED
|
@@ -1,44 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI configuration
|
|
3
|
-
*/
|
|
4
1
|
export declare const config: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Can be overridden with OUTPUT_API_URL environment variable
|
|
8
|
-
*/
|
|
9
|
-
apiUrl: string;
|
|
10
|
-
/**
|
|
11
|
-
* API authentication token
|
|
12
|
-
* Set via OUTPUT_API_AUTH_TOKEN environment variable
|
|
13
|
-
*/
|
|
14
|
-
apiToken: string | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Default timeout for API requests (in milliseconds)
|
|
17
|
-
*/
|
|
2
|
+
readonly apiUrl: string;
|
|
3
|
+
readonly apiToken: string | undefined;
|
|
18
4
|
requestTimeout: number;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
dockerServiceName: string;
|
|
24
|
-
/**
|
|
25
|
-
* Set the debug mode
|
|
26
|
-
*/
|
|
27
|
-
debugMode: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Where the env vars are stored, defaults to `.env`
|
|
30
|
-
*/
|
|
31
|
-
envFile: string;
|
|
32
|
-
/**
|
|
33
|
-
* Agent configuration directory name
|
|
34
|
-
*/
|
|
5
|
+
readonly dockerServiceName: string;
|
|
6
|
+
readonly debugMode: boolean;
|
|
7
|
+
readonly envFile: string;
|
|
35
8
|
agentConfigDir: string;
|
|
36
|
-
|
|
37
|
-
* S3 configuration for remote trace storage
|
|
38
|
-
* Set via OUTPUT_TRACE_REMOTE_S3_BUCKET, OUTPUT_AWS_REGION,
|
|
39
|
-
* OUTPUT_AWS_ACCESS_KEY_ID, and OUTPUT_AWS_SECRET_ACCESS_KEY environment variables
|
|
40
|
-
*/
|
|
41
|
-
s3: {
|
|
9
|
+
readonly s3: {
|
|
42
10
|
bucket: string | undefined;
|
|
43
11
|
region: string | undefined;
|
|
44
12
|
accessKeyId: string | undefined;
|
package/dist/config.js
CHANGED
|
@@ -1,47 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI configuration
|
|
3
|
-
*/
|
|
4
1
|
export const config = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* API authentication token
|
|
12
|
-
* Set via OUTPUT_API_AUTH_TOKEN environment variable
|
|
13
|
-
*/
|
|
14
|
-
apiToken: process.env.OUTPUT_API_AUTH_TOKEN,
|
|
15
|
-
/**
|
|
16
|
-
* Default timeout for API requests (in milliseconds)
|
|
17
|
-
*/
|
|
2
|
+
get apiUrl() {
|
|
3
|
+
return process.env.OUTPUT_API_URL || 'http://localhost:3001';
|
|
4
|
+
},
|
|
5
|
+
get apiToken() {
|
|
6
|
+
return process.env.OUTPUT_API_AUTH_TOKEN;
|
|
7
|
+
},
|
|
18
8
|
requestTimeout: 30000,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Where the env vars are stored, defaults to `.env`
|
|
30
|
-
*/
|
|
31
|
-
envFile: process.env.OUTPUT_CLI_ENV || '.env',
|
|
32
|
-
/**
|
|
33
|
-
* Agent configuration directory name
|
|
34
|
-
*/
|
|
9
|
+
get dockerServiceName() {
|
|
10
|
+
return process.env.DOCKER_SERVICE_NAME || 'output-sdk';
|
|
11
|
+
},
|
|
12
|
+
get debugMode() {
|
|
13
|
+
return process.env.OUTPUT_DEBUG === 'true';
|
|
14
|
+
},
|
|
15
|
+
get envFile() {
|
|
16
|
+
return process.env.OUTPUT_CLI_ENV || '.env';
|
|
17
|
+
},
|
|
35
18
|
agentConfigDir: '.outputai',
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
region: process.env.OUTPUT_AWS_REGION,
|
|
44
|
-
accessKeyId: process.env.OUTPUT_AWS_ACCESS_KEY_ID,
|
|
45
|
-
secretAccessKey: process.env.OUTPUT_AWS_SECRET_ACCESS_KEY
|
|
19
|
+
get s3() {
|
|
20
|
+
return {
|
|
21
|
+
bucket: process.env.OUTPUT_TRACE_REMOTE_S3_BUCKET,
|
|
22
|
+
region: process.env.OUTPUT_AWS_REGION,
|
|
23
|
+
accessKeyId: process.env.OUTPUT_AWS_ACCESS_KEY_ID,
|
|
24
|
+
secretAccessKey: process.env.OUTPUT_AWS_SECRET_ACCESS_KEY
|
|
25
|
+
};
|
|
46
26
|
}
|
|
47
27
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { config } from '#config.js';
|
|
3
|
+
describe('config', () => {
|
|
4
|
+
const envVars = [
|
|
5
|
+
'OUTPUT_API_URL',
|
|
6
|
+
'OUTPUT_API_AUTH_TOKEN',
|
|
7
|
+
'DOCKER_SERVICE_NAME',
|
|
8
|
+
'OUTPUT_DEBUG',
|
|
9
|
+
'OUTPUT_CLI_ENV',
|
|
10
|
+
'OUTPUT_TRACE_REMOTE_S3_BUCKET',
|
|
11
|
+
'OUTPUT_AWS_REGION',
|
|
12
|
+
'OUTPUT_AWS_ACCESS_KEY_ID',
|
|
13
|
+
'OUTPUT_AWS_SECRET_ACCESS_KEY'
|
|
14
|
+
];
|
|
15
|
+
const saved = {};
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
for (const key of envVars) {
|
|
18
|
+
saved[key] = process.env[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
for (const key of envVars) {
|
|
23
|
+
if (saved[key] === undefined) {
|
|
24
|
+
delete process.env[key];
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
process.env[key] = saved[key];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
it('reads env vars lazily, not at module evaluation time', () => {
|
|
32
|
+
process.env.OUTPUT_API_URL = 'https://lazy-test.example.com';
|
|
33
|
+
expect(config.apiUrl).toBe('https://lazy-test.example.com');
|
|
34
|
+
process.env.OUTPUT_API_URL = 'https://changed.example.com';
|
|
35
|
+
expect(config.apiUrl).toBe('https://changed.example.com');
|
|
36
|
+
});
|
|
37
|
+
it('falls back to defaults when env vars are unset', () => {
|
|
38
|
+
delete process.env.OUTPUT_API_URL;
|
|
39
|
+
delete process.env.DOCKER_SERVICE_NAME;
|
|
40
|
+
delete process.env.OUTPUT_DEBUG;
|
|
41
|
+
delete process.env.OUTPUT_CLI_ENV;
|
|
42
|
+
expect(config.apiUrl).toBe('http://localhost:3001');
|
|
43
|
+
expect(config.dockerServiceName).toBe('output-sdk');
|
|
44
|
+
expect(config.debugMode).toBe(false);
|
|
45
|
+
expect(config.envFile).toBe('.env');
|
|
46
|
+
});
|
|
47
|
+
it('reads apiToken from env', () => {
|
|
48
|
+
process.env.OUTPUT_API_AUTH_TOKEN = 'test-token-123';
|
|
49
|
+
expect(config.apiToken).toBe('test-token-123');
|
|
50
|
+
delete process.env.OUTPUT_API_AUTH_TOKEN;
|
|
51
|
+
expect(config.apiToken).toBeUndefined();
|
|
52
|
+
});
|
|
53
|
+
it('reads debugMode as boolean', () => {
|
|
54
|
+
process.env.OUTPUT_DEBUG = 'true';
|
|
55
|
+
expect(config.debugMode).toBe(true);
|
|
56
|
+
process.env.OUTPUT_DEBUG = 'false';
|
|
57
|
+
expect(config.debugMode).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
it('reads s3 config lazily', () => {
|
|
60
|
+
process.env.OUTPUT_TRACE_REMOTE_S3_BUCKET = 'my-bucket';
|
|
61
|
+
process.env.OUTPUT_AWS_REGION = 'us-west-2';
|
|
62
|
+
process.env.OUTPUT_AWS_ACCESS_KEY_ID = 'AKIA123';
|
|
63
|
+
process.env.OUTPUT_AWS_SECRET_ACCESS_KEY = 'secret123';
|
|
64
|
+
expect(config.s3).toEqual({
|
|
65
|
+
bucket: 'my-bucket',
|
|
66
|
+
region: 'us-west-2',
|
|
67
|
+
accessKeyId: 'AKIA123',
|
|
68
|
+
secretAccessKey: 'secret123'
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
it('has static properties that are not env-derived', () => {
|
|
72
|
+
expect(config.requestTimeout).toBe(30000);
|
|
73
|
+
expect(config.agentConfigDir).toBe('.outputai');
|
|
74
|
+
});
|
|
75
|
+
});
|
package/dist/utils/env_loader.js
CHANGED
|
@@ -7,11 +7,10 @@ import { existsSync } from 'node:fs';
|
|
|
7
7
|
import { resolve } from 'node:path';
|
|
8
8
|
import * as dotenv from 'dotenv';
|
|
9
9
|
import debugFactory from 'debug';
|
|
10
|
-
import { config } from '#config.js';
|
|
11
10
|
const debug = debugFactory('output-cli:env-loader');
|
|
12
11
|
export function loadEnvironment() {
|
|
13
12
|
const cwd = process.cwd();
|
|
14
|
-
const envFile =
|
|
13
|
+
const envFile = process.env.OUTPUT_CLI_ENV || '.env';
|
|
15
14
|
const envPath = resolve(cwd, envFile);
|
|
16
15
|
if (!existsSync(envPath)) {
|
|
17
16
|
debug(`Warning: Env file not found: ${envPath}`);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { config } from '#config.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
function getDefaultMessages() {
|
|
3
|
+
return {
|
|
4
|
+
ECONNREFUSED: `Connection refused to ${config.apiUrl}. Is the API server running?`,
|
|
5
|
+
401: 'Authentication failed. Check your OUTPUT_API_AUTH_TOKEN.',
|
|
6
|
+
404: 'Resource not found.',
|
|
7
|
+
500: 'Server error.',
|
|
8
|
+
UNKNOWN: 'An unknown error occurred.'
|
|
9
|
+
};
|
|
10
|
+
}
|
|
9
11
|
/**
|
|
10
12
|
* Extract error type and message from API response data
|
|
11
13
|
*/
|
|
@@ -49,7 +51,7 @@ function getDetailedErrorMessage(error) {
|
|
|
49
51
|
}
|
|
50
52
|
export function handleApiError(error, errorFn, overrides = {}) {
|
|
51
53
|
const apiError = error;
|
|
52
|
-
const errorMessages = { ...
|
|
54
|
+
const errorMessages = { ...getDefaultMessages(), ...overrides };
|
|
53
55
|
if (apiError.code === 'ECONNREFUSED' || apiError.cause?.code === 'ECONNREFUSED') {
|
|
54
56
|
errorFn(errorMessages.ECONNREFUSED, { exit: 1 });
|
|
55
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outputai/cli",
|
|
3
|
-
"version": "0.2.1-next.
|
|
3
|
+
"version": "0.2.1-next.bd54540.0",
|
|
4
4
|
"description": "CLI for Output.ai workflow generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"semver": "7.7.4",
|
|
37
37
|
"undici": "8.0.2",
|
|
38
38
|
"yaml": "^2.8.3",
|
|
39
|
-
"@outputai/
|
|
40
|
-
"@outputai/
|
|
41
|
-
"@outputai/llm": "0.2.1-next.
|
|
39
|
+
"@outputai/credentials": "0.2.1-next.bd54540.0",
|
|
40
|
+
"@outputai/evals": "0.2.1-next.bd54540.0",
|
|
41
|
+
"@outputai/llm": "0.2.1-next.bd54540.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/cli-progress": "3.11.6",
|