@ekairos/dataset 1.22.74-beta.development.0 → 1.22.76-beta.development.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/file/filepreview.d.ts +1 -0
- package/dist/file/filepreview.js +19 -12
- package/package.json +4 -4
|
@@ -5,5 +5,6 @@ interface PreviewOptions {
|
|
|
5
5
|
tailLines?: number;
|
|
6
6
|
midLines?: number;
|
|
7
7
|
}
|
|
8
|
+
export declare function resolveFilePreviewScriptPath(scriptName: string): string;
|
|
8
9
|
export declare function ensurePreviewScriptsAvailable(runtime: any, sandboxId: string): Promise<void>;
|
|
9
10
|
export declare function generateFilePreview(runtime: any, sandboxId: string, sandboxFilePath: string, datasetId: string, options?: PreviewOptions): Promise<FilePreviewContext>;
|
package/dist/file/filepreview.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
2
|
import { dirname, join } from "node:path";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
5
4
|
import { runDatasetSandboxCommandStep, writeDatasetSandboxFilesStep } from "../sandbox/steps.js";
|
|
@@ -16,16 +15,24 @@ const PYTHON_SCRIPT_FILES = [
|
|
|
16
15
|
"preview_tail_csv.py",
|
|
17
16
|
"preview_tail_excel.py",
|
|
18
17
|
];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
export function resolveFilePreviewScriptPath(scriptName) {
|
|
19
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const taskRoot = String(process.env.LAMBDA_TASK_ROOT ?? "").trim();
|
|
21
|
+
const candidates = [
|
|
22
|
+
join(currentDir, "scripts", scriptName),
|
|
23
|
+
join(process.cwd(), "node_modules", "@ekairos", "dataset", "dist", "file", "scripts", scriptName),
|
|
24
|
+
taskRoot
|
|
25
|
+
? join(taskRoot, "node_modules", "@ekairos", "dataset", "dist", "file", "scripts", scriptName)
|
|
26
|
+
: "",
|
|
27
|
+
join(process.cwd(), "packages", "dataset", "dist", "file", "scripts", scriptName),
|
|
28
|
+
join(process.cwd(), "packages", "dataset", "src", "file", "scripts", scriptName),
|
|
29
|
+
].filter(Boolean);
|
|
30
|
+
for (const candidate of candidates) {
|
|
31
|
+
if (existsSync(candidate)) {
|
|
32
|
+
return candidate;
|
|
33
|
+
}
|
|
24
34
|
}
|
|
25
|
-
|
|
26
|
-
// the package JS entrypoint, then address scripts as plain filesystem paths under dist.
|
|
27
|
-
const packageEntryPath = require.resolve("@ekairos/dataset");
|
|
28
|
-
return join(dirname(packageEntryPath), "file", "scripts", scriptName);
|
|
35
|
+
throw new Error(`dataset_preview_script_not_found:${scriptName}; searched=${candidates.join(",")}`);
|
|
29
36
|
}
|
|
30
37
|
const preparedSandboxIds = new Set();
|
|
31
38
|
const sandboxSetupPromises = new Map();
|
|
@@ -85,7 +92,7 @@ export async function ensurePreviewScriptsAvailable(runtime, sandboxId) {
|
|
|
85
92
|
const filesToWrite = [];
|
|
86
93
|
for (const scriptName of PYTHON_SCRIPT_FILES) {
|
|
87
94
|
try {
|
|
88
|
-
const scriptPath =
|
|
95
|
+
const scriptPath = resolveFilePreviewScriptPath(scriptName);
|
|
89
96
|
const fileBuffer = readFileSync(scriptPath);
|
|
90
97
|
filesToWrite.push({
|
|
91
98
|
path: `${SANDBOX_SCRIPT_DIRECTORY}/${scriptName}`,
|
|
@@ -191,7 +198,7 @@ async function runScript(runtime, sandboxId, scriptName, args, description) {
|
|
|
191
198
|
const command = `python ${scriptPath} ${args.join(" ")}`;
|
|
192
199
|
let scriptContent = "";
|
|
193
200
|
try {
|
|
194
|
-
const localScriptPath =
|
|
201
|
+
const localScriptPath = resolveFilePreviewScriptPath(scriptName);
|
|
195
202
|
scriptContent = readFileSync(localScriptPath, 'utf-8');
|
|
196
203
|
}
|
|
197
204
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekairos/dataset",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.76-beta.development.0",
|
|
4
4
|
"description": "Pulzar Dataset Tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"test:ai-sdk:instant": "vitest run -c vitest.codex.config.mts src/tests/materializeDataset.ai-sdk.instant.test.ts"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@ekairos/domain": "^1.22.
|
|
69
|
-
"@ekairos/events": "^1.22.
|
|
70
|
-
"@ekairos/sandbox": "^1.22.
|
|
68
|
+
"@ekairos/domain": "^1.22.76-beta.development.0",
|
|
69
|
+
"@ekairos/events": "^1.22.76-beta.development.0",
|
|
70
|
+
"@ekairos/sandbox": "^1.22.76-beta.development.0",
|
|
71
71
|
"@instantdb/admin": "0.22.158",
|
|
72
72
|
"@instantdb/core": "0.22.142",
|
|
73
73
|
"ai": "^5.0.44",
|