@output.ai/core 0.3.7 → 0.3.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@output.ai/core",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "The core module of the output framework",
5
5
  "type": "module",
6
6
  "exports": {
package/src/consts.js CHANGED
@@ -10,7 +10,3 @@ export const ComponentType = {
10
10
  INTERNAL_STEP: 'internal_step',
11
11
  STEP: 'step'
12
12
  };
13
-
14
- const DEFAULT_HEARTBEAT_INTERVAL_MS = 2 * 60 * 1000; // 2 minutes
15
- export const HEARTBEAT_INTERVAL_MS = Number( process.env.OUTPUT_HEARTBEAT_INTERVAL_MS ) || DEFAULT_HEARTBEAT_INTERVAL_MS;
16
- export const HEARTBEAT_ENABLED = process.env.OUTPUT_HEARTBEAT_ENABLED !== 'false'; // on by default, set to 'false' to disable
@@ -2,7 +2,14 @@ import { Context } from '@temporalio/activity';
2
2
  import { Storage } from '#async_storage';
3
3
  import { addEventStart, addEventEnd, addEventError } from '#tracing';
4
4
  import { headersToObject } from '../sandboxed_utils.js';
5
- import { METADATA_ACCESS_SYMBOL, HEARTBEAT_INTERVAL_MS, HEARTBEAT_ENABLED } from '#consts';
5
+ import { METADATA_ACCESS_SYMBOL } from '#consts';
6
+
7
+ // Heartbeat config lives here (not in #consts) because consts.js is bundled into
8
+ // the Temporal workflow sandbox where `process` is not available.
9
+ // Activity interceptors run in the worker context where process.env is safe.
10
+ const DEFAULT_HEARTBEAT_INTERVAL_MS = 2 * 60 * 1000; // 2 minutes
11
+ const HEARTBEAT_INTERVAL_MS = Number( process.env.OUTPUT_HEARTBEAT_INTERVAL_MS ) || DEFAULT_HEARTBEAT_INTERVAL_MS;
12
+ const HEARTBEAT_ENABLED = process.env.OUTPUT_HEARTBEAT_ENABLED !== 'false'; // on by default, set to 'false' to disable
6
13
 
7
14
  /*
8
15
  This interceptor wraps every activity execution with cross-cutting concerns:
@@ -37,17 +37,9 @@ vi.mock( '../sandboxed_utils.js', () => ( {
37
37
  headersToObject: () => ( { executionContext: { workflowId: 'wf-1' } } )
38
38
  } ) );
39
39
 
40
- const mockConfig = { heartbeatEnabled: true, heartbeatIntervalMs: 50 };
41
-
42
40
  vi.mock( '#consts', () => ( {
43
41
  get METADATA_ACCESS_SYMBOL() {
44
42
  return METADATA_ACCESS_SYMBOL;
45
- },
46
- get HEARTBEAT_ENABLED() {
47
- return mockConfig.heartbeatEnabled;
48
- },
49
- get HEARTBEAT_INTERVAL_MS() {
50
- return mockConfig.heartbeatIntervalMs;
51
43
  }
52
44
  } ) );
53
45
 
@@ -64,12 +56,15 @@ describe( 'ActivityExecutionInterceptor', () => {
64
56
  beforeEach( () => {
65
57
  vi.clearAllMocks();
66
58
  vi.useFakeTimers();
67
- mockConfig.heartbeatEnabled = true;
68
- mockConfig.heartbeatIntervalMs = 50;
59
+ vi.resetModules();
60
+ // Default: heartbeat enabled with 50ms interval for fast tests
61
+ vi.stubEnv( 'OUTPUT_HEARTBEAT_ENABLED', 'true' );
62
+ vi.stubEnv( 'OUTPUT_HEARTBEAT_INTERVAL_MS', '50' );
69
63
  } );
70
64
 
71
65
  afterEach( () => {
72
66
  vi.useRealTimers();
67
+ vi.unstubAllEnvs();
73
68
  } );
74
69
 
75
70
  it( 'records trace start and end events on successful execution', async () => {
@@ -158,7 +153,7 @@ describe( 'ActivityExecutionInterceptor', () => {
158
153
  } );
159
154
 
160
155
  it( 'does not heartbeat when HEARTBEAT_ENABLED is false', async () => {
161
- mockConfig.heartbeatEnabled = false;
156
+ vi.stubEnv( 'OUTPUT_HEARTBEAT_ENABLED', 'false' );
162
157
  const { ActivityExecutionInterceptor } = await import( './activity.js' );
163
158
  const interceptor = new ActivityExecutionInterceptor( makeActivities() );
164
159