@output.ai/core 0.1.8-dev.pr156.ac53caf → 0.1.8-dev.pr156.c8e7f40
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,12 +1,12 @@
|
|
|
1
1
|
import { appendFileSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import {
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
2
|
+
import { join } from 'node:path';
|
|
4
3
|
import buildTraceTree from '../../tools/build_trace_tree.js';
|
|
5
4
|
import { EOL } from 'node:os';
|
|
6
5
|
|
|
7
6
|
const oneWeekInMS = 1000 * 60 * 60 * 24 * 7;
|
|
8
|
-
|
|
9
|
-
const
|
|
7
|
+
// Use project root (passed as argv[2]) for temp files, fallback to cwd
|
|
8
|
+
const projectRoot = process.argv[2] || process.cwd();
|
|
9
|
+
const tempDir = join( projectRoot, 'logs', 'temp', 'traces' );
|
|
10
10
|
|
|
11
11
|
const accumulate = ( { entry, executionContext: { workflowId, startTime } } ) => {
|
|
12
12
|
const path = join( tempDir, `${startTime}_${workflowId}.trace` );
|
|
@@ -28,31 +28,25 @@ export const init = () => {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Get the
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
|
|
35
|
-
const getContainerBasePath = () => {
|
|
36
|
-
return join( process.cwd(), 'logs' );
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get the base path for reporting trace file locations
|
|
41
|
-
* Uses HOST_TRACE_PATH if set (for reporting to host), otherwise uses local path
|
|
42
|
-
* @returns {string} The base path where traces can be accessed from the host
|
|
31
|
+
* Get the local file system path for ALL file I/O operations (read/write)
|
|
32
|
+
* Uses the project root path passed as argv[2], falls back to cwd
|
|
33
|
+
* @param {string} workflowName - The name of the workflow
|
|
34
|
+
* @returns {string} The local filesystem path for file operations
|
|
43
35
|
*/
|
|
44
|
-
const
|
|
45
|
-
|
|
36
|
+
const getLocalOutputDir = workflowName => {
|
|
37
|
+
const root = process.argv[2] || process.cwd();
|
|
38
|
+
return join( root, 'logs', 'runs', workflowName );
|
|
46
39
|
};
|
|
47
40
|
|
|
48
41
|
/**
|
|
49
|
-
* Get the
|
|
42
|
+
* Get the host path for reporting trace file locations to users
|
|
43
|
+
* Uses HOST_TRACE_PATH if set (for Docker), otherwise uses project root
|
|
50
44
|
* @param {string} workflowName - The name of the workflow
|
|
51
|
-
* @
|
|
52
|
-
* @returns {string} The output directory path
|
|
45
|
+
* @returns {string} The path to report to users/API
|
|
53
46
|
*/
|
|
54
|
-
const
|
|
55
|
-
const
|
|
47
|
+
const getReportOutputDir = workflowName => {
|
|
48
|
+
const root = process.argv[2] || process.cwd();
|
|
49
|
+
const basePath = process.env.HOST_TRACE_PATH || join( root, 'logs' );
|
|
56
50
|
return join( basePath, 'runs', workflowName );
|
|
57
51
|
};
|
|
58
52
|
|
|
@@ -75,8 +69,8 @@ export const exec = ( { entry, executionContext } ) => {
|
|
|
75
69
|
const { workflowId, workflowName, startTime } = executionContext;
|
|
76
70
|
const content = buildTraceTree( accumulate( { entry, executionContext } ) );
|
|
77
71
|
|
|
78
|
-
//
|
|
79
|
-
const dir =
|
|
72
|
+
// Always use local path for writing files
|
|
73
|
+
const dir = getLocalOutputDir( workflowName );
|
|
80
74
|
const path = join( dir, buildOutputFileName( { startTime, workflowId } ) );
|
|
81
75
|
|
|
82
76
|
mkdirSync( dir, { recursive: true } );
|
|
@@ -92,5 +86,6 @@ export const exec = ( { entry, executionContext } ) => {
|
|
|
92
86
|
* @returns {string} The absolute path where the trace will be saved
|
|
93
87
|
*/
|
|
94
88
|
export const getDestination = ( { startTime, workflowId, workflowName } ) => {
|
|
95
|
-
|
|
89
|
+
// Use report path for reporting to users/API
|
|
90
|
+
return join( getReportOutputDir( workflowName ), buildOutputFileName( { workflowId, startTime } ) );
|
|
96
91
|
};
|
|
@@ -40,7 +40,8 @@ describe( 'tracing/processors/local', () => {
|
|
|
40
40
|
|
|
41
41
|
init();
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
// Should create temp dir under process.cwd()/logs, not module-relative
|
|
44
|
+
expect( mkdirSyncMock ).toHaveBeenCalledWith( expect.stringMatching( /logs\/temp\/traces$/ ), { recursive: true } );
|
|
44
45
|
expect( rmSyncMock ).toHaveBeenCalledTimes( 1 );
|
|
45
46
|
} );
|
|
46
47
|
|