@outputai/core 0.10.1-dev.b7b2fbe.0 → 0.10.1-next.14a191e.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.
@@ -1,7 +1,7 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
2
  import { BusEventType, ComponentType } from '#consts';
3
3
 
4
- const messageBusMock = vi.hoisted( () => ( {
4
+ const mainEventBusMock = vi.hoisted( () => ( {
5
5
  emit: vi.fn()
6
6
  } ) );
7
7
 
@@ -15,7 +15,7 @@ const createWorkflowDetailsMock = vi.hoisted( () => vi.fn( workflowInfo => ( {
15
15
  runId: workflowInfo.runId
16
16
  } ) ) );
17
17
 
18
- vi.mock( '#bus', () => ( { messageBus: messageBusMock } ) );
18
+ vi.mock( '#bus', () => ( { mainEventBus: mainEventBusMock } ) );
19
19
  vi.mock( '#tracing', () => ( {
20
20
  addEventStart: addEventStartMock,
21
21
  addEventEnd: addEventEndMock,
@@ -69,7 +69,7 @@ describe( 'worker/sinks', () => {
69
69
  } );
70
70
 
71
71
  expect( createWorkflowDetailsMock ).toHaveBeenCalledWith( workflowInfo );
72
- expect( messageBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_LOG, {
72
+ expect( mainEventBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_LOG, {
73
73
  level: 'info',
74
74
  message: 'workflow detail',
75
75
  metadata,
@@ -83,7 +83,7 @@ describe( 'worker/sinks', () => {
83
83
 
84
84
  sinks.workflow.start.fn( workflowInfo, input );
85
85
 
86
- expect( messageBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_START, { workflowDetails } );
86
+ expect( mainEventBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_START, { workflowDetails } );
87
87
  expect( addEventStartMock ).toHaveBeenCalledWith( {
88
88
  id: 'run-1',
89
89
  kind: ComponentType.WORKFLOW,
@@ -99,7 +99,7 @@ describe( 'worker/sinks', () => {
99
99
 
100
100
  sinks.workflow.start.fn( { ...workflowInfo, memo: {} }, { value: 'input' } );
101
101
 
102
- expect( messageBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_START, { workflowDetails } );
102
+ expect( mainEventBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_START, { workflowDetails } );
103
103
  expect( addEventStartMock ).not.toHaveBeenCalled();
104
104
  } );
105
105
 
@@ -109,7 +109,7 @@ describe( 'worker/sinks', () => {
109
109
 
110
110
  sinks.workflow.end.fn( workflowInfo, output );
111
111
 
112
- expect( messageBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_END, { workflowDetails } );
112
+ expect( mainEventBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_END, { workflowDetails } );
113
113
  expect( addEventEndMock ).toHaveBeenCalledWith( {
114
114
  id: 'run-1',
115
115
  details: output,
@@ -122,7 +122,7 @@ describe( 'worker/sinks', () => {
122
122
 
123
123
  sinks.workflow.end.fn( { ...workflowInfo, memo: {} }, { value: 'output' } );
124
124
 
125
- expect( messageBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_END, { workflowDetails } );
125
+ expect( mainEventBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_END, { workflowDetails } );
126
126
  expect( addEventEndMock ).not.toHaveBeenCalled();
127
127
  } );
128
128
 
@@ -132,7 +132,7 @@ describe( 'worker/sinks', () => {
132
132
 
133
133
  sinks.workflow.error.fn( workflowInfo, error );
134
134
 
135
- expect( messageBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_ERROR, { workflowDetails, error } );
135
+ expect( mainEventBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_ERROR, { workflowDetails, error } );
136
136
  expect( addEventErrorMock ).toHaveBeenCalledWith( {
137
137
  id: 'run-1',
138
138
  details: error,
@@ -146,7 +146,7 @@ describe( 'worker/sinks', () => {
146
146
 
147
147
  sinks.workflow.error.fn( { ...workflowInfo, memo: {} }, error );
148
148
 
149
- expect( messageBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_ERROR, { workflowDetails, error } );
149
+ expect( mainEventBusMock.emit ).toHaveBeenCalledWith( BusEventType.WORKFLOW_ERROR, { workflowDetails, error } );
150
150
  expect( addEventErrorMock ).not.toHaveBeenCalled();
151
151
  } );
152
152
 
@@ -1,20 +0,0 @@
1
- import { EnvHttpProxyAgent, setGlobalDispatcher } from 'undici';
2
- import { createChildLogger } from '#logger';
3
-
4
- const log = createChildLogger( 'Proxy' );
5
-
6
- /**
7
- * Routes all `fetch()` calls (including those inside Temporal activities)
8
- * through an HTTP/HTTPS proxy when standard proxy env vars are set.
9
- * No-op when none are set.
10
- */
11
- export const bootstrapFetchProxy = () => {
12
- const httpProxyUrl = process.env.http_proxy ?? process.env.HTTP_PROXY;
13
- const httpsProxyUrl = process.env.https_proxy ?? process.env.HTTPS_PROXY;
14
-
15
- if ( httpProxyUrl?.length > 0 || httpsProxyUrl?.length > 0 ) {
16
- log.info( 'Proxy env vars detected, setting up global fetch dispatcher EnvHttpProxyAgent', { httpProxyUrl, httpsProxyUrl } );
17
- /* Ignore HTTP/2. Check: https://github.com/growthxai/output/issues/299 */
18
- setGlobalDispatcher( new EnvHttpProxyAgent( { allowH2: false } ) );
19
- }
20
- };
@@ -1,51 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
-
3
- const mockSetGlobalDispatcher = vi.fn();
4
- const MockEnvHttpProxyAgent = vi.fn();
5
- const mockLogger = { info: vi.fn(), warn: vi.fn(), error: vi.fn() };
6
-
7
- vi.mock( 'undici', () => ( {
8
- EnvHttpProxyAgent: MockEnvHttpProxyAgent,
9
- setGlobalDispatcher: mockSetGlobalDispatcher
10
- } ) );
11
-
12
- vi.mock( '#logger', () => ( {
13
- createChildLogger: () => mockLogger
14
- } ) );
15
-
16
- describe( 'worker/proxy', () => {
17
- const proxyEnv = [ 'http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY' ];
18
-
19
- beforeEach( () => {
20
- vi.clearAllMocks();
21
- for ( const key of proxyEnv ) {
22
- delete process.env[key];
23
- }
24
- } );
25
-
26
- afterEach( () => {
27
- vi.resetModules();
28
- } );
29
-
30
- it( 'does nothing when no proxy env vars are set', async () => {
31
- const { bootstrapFetchProxy } = await import( './proxy.js' );
32
- bootstrapFetchProxy();
33
-
34
- expect( MockEnvHttpProxyAgent ).not.toHaveBeenCalled();
35
- expect( mockSetGlobalDispatcher ).not.toHaveBeenCalled();
36
- expect( mockLogger.info ).not.toHaveBeenCalled();
37
- } );
38
-
39
- it( 'sets global dispatcher when proxy URL is available', async () => {
40
- process.env.HTTP_PROXY = 'http://proxy:8080/';
41
- const { bootstrapFetchProxy } = await import( './proxy.js' );
42
- bootstrapFetchProxy();
43
-
44
- expect( MockEnvHttpProxyAgent ).toHaveBeenCalledWith( { allowH2: false } );
45
- expect( mockSetGlobalDispatcher ).toHaveBeenCalledTimes( 1 );
46
- expect( mockLogger.info ).toHaveBeenCalledWith(
47
- 'Proxy env vars detected, setting up global fetch dispatcher EnvHttpProxyAgent',
48
- { httpProxyUrl: 'http://proxy:8080/', httpsProxyUrl: undefined }
49
- );
50
- } );
51
- } );