@outputai/cli 0.2.0 → 0.2.1-next.0cbee89.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/bin/run.js CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  import { execute } from '@oclif/core';
4
4
  import { loadEnvironment } from '../dist/utils/env_loader.js';
5
+ import { bootstrapProxy } from '../dist/utils/proxy.js';
5
6
  import { resolveCredentialRefs } from '@outputai/credentials';
6
7
 
7
8
  // Load environment variables from .env files before executing CLI
8
9
  loadEnvironment();
10
+ bootstrapProxy();
9
11
  resolveCredentialRefs();
10
12
 
11
13
  await execute( { dir: import.meta.url } );
@@ -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.2.0}
84
+ image: outputai/api:${OUTPUT_API_VERSION:-0.2.1-next.0cbee89.0}
85
85
  init: true
86
86
  networks:
87
87
  - main
@@ -1,3 +1,3 @@
1
1
  {
2
- "framework": "0.2.0"
2
+ "framework": "0.2.1-next.0cbee89.0"
3
3
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Routes all `fetch()` calls through an HTTP/HTTPS proxy when standard
3
+ * proxy env vars are set (`HTTPS_PROXY`, `https_proxy`, `HTTP_PROXY`,
4
+ * `http_proxy`). No-op when none are set. Invalid URLs are logged and
5
+ * skipped so the CLI keeps running.
6
+ *
7
+ * Call once at CLI startup, before any network activity.
8
+ */
9
+ export declare const bootstrapProxy: () => void;
@@ -0,0 +1,24 @@
1
+ import { EnvHttpProxyAgent, setGlobalDispatcher } from 'undici';
2
+ /**
3
+ * Routes all `fetch()` calls through an HTTP/HTTPS proxy when standard
4
+ * proxy env vars are set (`HTTPS_PROXY`, `https_proxy`, `HTTP_PROXY`,
5
+ * `http_proxy`). No-op when none are set. Invalid URLs are logged and
6
+ * skipped so the CLI keeps running.
7
+ *
8
+ * Call once at CLI startup, before any network activity.
9
+ */
10
+ export const bootstrapProxy = () => {
11
+ const proxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy ||
12
+ process.env.HTTP_PROXY || process.env.http_proxy;
13
+ if (!proxyUrl) {
14
+ return;
15
+ }
16
+ try {
17
+ new URL(proxyUrl);
18
+ }
19
+ catch {
20
+ console.warn(`[proxy] Ignoring invalid proxy URL: ${proxyUrl}`);
21
+ return;
22
+ }
23
+ setGlobalDispatcher(new EnvHttpProxyAgent());
24
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
+ const mockSetGlobalDispatcher = vi.fn();
3
+ const MockEnvHttpProxyAgent = vi.fn();
4
+ vi.mock('undici', () => ({
5
+ EnvHttpProxyAgent: MockEnvHttpProxyAgent,
6
+ setGlobalDispatcher: mockSetGlobalDispatcher
7
+ }));
8
+ describe('proxy bootstrap', () => {
9
+ const originalEnv = { ...process.env };
10
+ beforeEach(() => {
11
+ vi.clearAllMocks();
12
+ delete process.env.HTTPS_PROXY;
13
+ delete process.env.https_proxy;
14
+ delete process.env.HTTP_PROXY;
15
+ delete process.env.http_proxy;
16
+ });
17
+ afterEach(() => {
18
+ process.env = { ...originalEnv };
19
+ });
20
+ it('does nothing when no proxy env vars are set', async () => {
21
+ const { bootstrapProxy } = await import('./proxy.js');
22
+ bootstrapProxy();
23
+ expect(mockSetGlobalDispatcher).not.toHaveBeenCalled();
24
+ });
25
+ it('sets global dispatcher when HTTPS_PROXY is set', async () => {
26
+ process.env.HTTPS_PROXY = 'http://proxy:8080';
27
+ const { bootstrapProxy } = await import('./proxy.js');
28
+ bootstrapProxy();
29
+ expect(MockEnvHttpProxyAgent).toHaveBeenCalled();
30
+ expect(mockSetGlobalDispatcher).toHaveBeenCalledTimes(1);
31
+ });
32
+ it('sets global dispatcher when HTTP_PROXY is set', async () => {
33
+ process.env.HTTP_PROXY = 'http://proxy:8080';
34
+ const { bootstrapProxy } = await import('./proxy.js');
35
+ bootstrapProxy();
36
+ expect(MockEnvHttpProxyAgent).toHaveBeenCalled();
37
+ expect(mockSetGlobalDispatcher).toHaveBeenCalledTimes(1);
38
+ });
39
+ it('does not set global dispatcher when proxy URL is malformed', async () => {
40
+ process.env.HTTPS_PROXY = 'not a url';
41
+ const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => { });
42
+ const { bootstrapProxy } = await import('./proxy.js');
43
+ bootstrapProxy();
44
+ expect(mockSetGlobalDispatcher).not.toHaveBeenCalled();
45
+ expect(warnSpy).toHaveBeenCalled();
46
+ warnSpy.mockRestore();
47
+ });
48
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outputai/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-next.0cbee89.0",
4
4
  "description": "CLI for Output.ai workflow generation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,10 +34,11 @@
34
34
  "ky": "1.14.3",
35
35
  "react": "19.2.5",
36
36
  "semver": "7.7.4",
37
+ "undici": "8.0.2",
37
38
  "yaml": "^2.8.3",
38
- "@outputai/credentials": "0.2.0",
39
- "@outputai/llm": "0.2.0",
40
- "@outputai/evals": "0.2.0"
39
+ "@outputai/credentials": "0.2.1-next.0cbee89.0",
40
+ "@outputai/llm": "0.2.1-next.0cbee89.0",
41
+ "@outputai/evals": "0.2.1-next.0cbee89.0"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@types/cli-progress": "3.11.6",