@wix/evalforge-evaluator 0.189.0 → 0.190.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/build/index.js +68 -6
- package/build/index.js.map +2 -2
- package/build/index.mjs +68 -6
- package/build/index.mjs.map +2 -2
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -7076,7 +7076,10 @@ function createApiClient(serverUrl, options = "") {
|
|
|
7076
7076
|
},
|
|
7077
7077
|
async provisionScenarioSite(projectId2, evalRunId2, scenarioId) {
|
|
7078
7078
|
const res = await httpClient.request(provisionScenarioSite({ projectId: projectId2, evalRunId: evalRunId2, scenarioId })).catch(
|
|
7079
|
-
(err) => rethrowWithRequestId(
|
|
7079
|
+
(err) => rethrowWithRequestId(
|
|
7080
|
+
err,
|
|
7081
|
+
`provision a site for scenario ${scenarioId}`
|
|
7082
|
+
)
|
|
7080
7083
|
);
|
|
7081
7084
|
const site = res.data.site;
|
|
7082
7085
|
if (!site) {
|
|
@@ -7494,12 +7497,71 @@ async function installDependencies(workDir, onProgress, options = {}) {
|
|
|
7494
7497
|
}
|
|
7495
7498
|
|
|
7496
7499
|
// src/run-scenario/environment.ts
|
|
7497
|
-
async function
|
|
7500
|
+
async function withTimeout(promise, ms, label) {
|
|
7501
|
+
let timer;
|
|
7502
|
+
const timeout = new Promise((_, reject) => {
|
|
7503
|
+
timer = setTimeout(
|
|
7504
|
+
() => reject(new Error(`${label} did not complete within ${ms}ms`)),
|
|
7505
|
+
ms
|
|
7506
|
+
);
|
|
7507
|
+
});
|
|
7508
|
+
try {
|
|
7509
|
+
return await Promise.race([promise, timeout]);
|
|
7510
|
+
} finally {
|
|
7511
|
+
clearTimeout(timer);
|
|
7512
|
+
}
|
|
7513
|
+
}
|
|
7514
|
+
async function probeGitHubAccess(source, onProgress) {
|
|
7515
|
+
const token = process.env.GITHUB_TOKEN;
|
|
7516
|
+
const url = `https://api.github.com/repos/${source.owner}/${source.repo}`;
|
|
7517
|
+
const controller = new AbortController();
|
|
7518
|
+
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
7519
|
+
const startedAt = Date.now();
|
|
7520
|
+
try {
|
|
7521
|
+
const res = await fetch(url, {
|
|
7522
|
+
headers: {
|
|
7523
|
+
"User-Agent": "EvalForge-Evaluator",
|
|
7524
|
+
...token ? { Authorization: `Bearer ${token}` } : {}
|
|
7525
|
+
},
|
|
7526
|
+
signal: controller.signal
|
|
7527
|
+
});
|
|
7528
|
+
onProgress(
|
|
7529
|
+
`[diag] github reachable: HTTP ${res.status} for repos/${source.owner}/${source.repo} in ${Date.now() - startedAt}ms (token: ${token ? "present" : "MISSING"})`
|
|
7530
|
+
);
|
|
7531
|
+
} catch (err) {
|
|
7532
|
+
onProgress(
|
|
7533
|
+
`[diag] github UNREACHABLE after ${Date.now() - startedAt}ms: ${err instanceof Error ? err.message : String(err)} (token: ${token ? "present" : "MISSING"})`
|
|
7534
|
+
);
|
|
7535
|
+
} finally {
|
|
7536
|
+
clearTimeout(timer);
|
|
7537
|
+
}
|
|
7538
|
+
}
|
|
7539
|
+
async function fetchAndWriteTemplateFiles(template, workDir, onProgress) {
|
|
7498
7540
|
let sourceFiles = [];
|
|
7499
7541
|
if (template.source) {
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7542
|
+
const { owner, repo, path: srcPath, ref } = template.source;
|
|
7543
|
+
onProgress(
|
|
7544
|
+
`[diag] template.source = ${owner}/${repo}/${srcPath ?? ""}@${ref ?? "default"}`
|
|
7545
|
+
);
|
|
7546
|
+
await probeGitHubAccess(template.source, onProgress);
|
|
7547
|
+
const startedAt = Date.now();
|
|
7548
|
+
try {
|
|
7549
|
+
sourceFiles = await withTimeout(
|
|
7550
|
+
(0, import_evalforge_github_client.fetchGitHubFolder)(template.source, {
|
|
7551
|
+
userAgent: "EvalForge-Evaluator"
|
|
7552
|
+
}),
|
|
7553
|
+
6e4,
|
|
7554
|
+
"template source fetch"
|
|
7555
|
+
);
|
|
7556
|
+
onProgress(
|
|
7557
|
+
`[diag] fetched ${sourceFiles.length} template file(s) in ${Date.now() - startedAt}ms`
|
|
7558
|
+
);
|
|
7559
|
+
} catch (err) {
|
|
7560
|
+
onProgress(
|
|
7561
|
+
`[diag] template source fetch FAILED after ${Date.now() - startedAt}ms: ${err instanceof Error ? err.message : String(err)}`
|
|
7562
|
+
);
|
|
7563
|
+
throw err;
|
|
7564
|
+
}
|
|
7503
7565
|
} else if (template.sourceFiles?.length) {
|
|
7504
7566
|
sourceFiles = template.sourceFiles;
|
|
7505
7567
|
} else {
|
|
@@ -7560,7 +7622,7 @@ async function prepareWorkingDirectory(config, evalRunId2, targetId, scenarioId,
|
|
|
7560
7622
|
}
|
|
7561
7623
|
(0, import_fs2.mkdirSync)(workDir2, { recursive: true });
|
|
7562
7624
|
onProgress("Fetching template files...");
|
|
7563
|
-
await fetchAndWriteTemplateFiles(template, workDir2);
|
|
7625
|
+
await fetchAndWriteTemplateFiles(template, workDir2, onProgress);
|
|
7564
7626
|
console.log(`Template files written to ${workDir2}`);
|
|
7565
7627
|
writeWixEnvFile(workDir2);
|
|
7566
7628
|
await installDependencies(workDir2, onProgress, {
|