@wix/evalforge-evaluator 0.188.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 +5 -5
package/build/index.mjs
CHANGED
|
@@ -7081,7 +7081,10 @@ function createApiClient(serverUrl, options = "") {
|
|
|
7081
7081
|
},
|
|
7082
7082
|
async provisionScenarioSite(projectId2, evalRunId2, scenarioId) {
|
|
7083
7083
|
const res = await httpClient.request(provisionScenarioSite({ projectId: projectId2, evalRunId: evalRunId2, scenarioId })).catch(
|
|
7084
|
-
(err) => rethrowWithRequestId(
|
|
7084
|
+
(err) => rethrowWithRequestId(
|
|
7085
|
+
err,
|
|
7086
|
+
`provision a site for scenario ${scenarioId}`
|
|
7087
|
+
)
|
|
7085
7088
|
);
|
|
7086
7089
|
const site = res.data.site;
|
|
7087
7090
|
if (!site) {
|
|
@@ -7516,12 +7519,71 @@ async function installDependencies(workDir, onProgress, options = {}) {
|
|
|
7516
7519
|
}
|
|
7517
7520
|
|
|
7518
7521
|
// src/run-scenario/environment.ts
|
|
7519
|
-
async function
|
|
7522
|
+
async function withTimeout(promise, ms, label) {
|
|
7523
|
+
let timer;
|
|
7524
|
+
const timeout = new Promise((_, reject) => {
|
|
7525
|
+
timer = setTimeout(
|
|
7526
|
+
() => reject(new Error(`${label} did not complete within ${ms}ms`)),
|
|
7527
|
+
ms
|
|
7528
|
+
);
|
|
7529
|
+
});
|
|
7530
|
+
try {
|
|
7531
|
+
return await Promise.race([promise, timeout]);
|
|
7532
|
+
} finally {
|
|
7533
|
+
clearTimeout(timer);
|
|
7534
|
+
}
|
|
7535
|
+
}
|
|
7536
|
+
async function probeGitHubAccess(source, onProgress) {
|
|
7537
|
+
const token = process.env.GITHUB_TOKEN;
|
|
7538
|
+
const url = `https://api.github.com/repos/${source.owner}/${source.repo}`;
|
|
7539
|
+
const controller = new AbortController();
|
|
7540
|
+
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
7541
|
+
const startedAt = Date.now();
|
|
7542
|
+
try {
|
|
7543
|
+
const res = await fetch(url, {
|
|
7544
|
+
headers: {
|
|
7545
|
+
"User-Agent": "EvalForge-Evaluator",
|
|
7546
|
+
...token ? { Authorization: `Bearer ${token}` } : {}
|
|
7547
|
+
},
|
|
7548
|
+
signal: controller.signal
|
|
7549
|
+
});
|
|
7550
|
+
onProgress(
|
|
7551
|
+
`[diag] github reachable: HTTP ${res.status} for repos/${source.owner}/${source.repo} in ${Date.now() - startedAt}ms (token: ${token ? "present" : "MISSING"})`
|
|
7552
|
+
);
|
|
7553
|
+
} catch (err) {
|
|
7554
|
+
onProgress(
|
|
7555
|
+
`[diag] github UNREACHABLE after ${Date.now() - startedAt}ms: ${err instanceof Error ? err.message : String(err)} (token: ${token ? "present" : "MISSING"})`
|
|
7556
|
+
);
|
|
7557
|
+
} finally {
|
|
7558
|
+
clearTimeout(timer);
|
|
7559
|
+
}
|
|
7560
|
+
}
|
|
7561
|
+
async function fetchAndWriteTemplateFiles(template, workDir, onProgress) {
|
|
7520
7562
|
let sourceFiles = [];
|
|
7521
7563
|
if (template.source) {
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7564
|
+
const { owner, repo, path: srcPath, ref } = template.source;
|
|
7565
|
+
onProgress(
|
|
7566
|
+
`[diag] template.source = ${owner}/${repo}/${srcPath ?? ""}@${ref ?? "default"}`
|
|
7567
|
+
);
|
|
7568
|
+
await probeGitHubAccess(template.source, onProgress);
|
|
7569
|
+
const startedAt = Date.now();
|
|
7570
|
+
try {
|
|
7571
|
+
sourceFiles = await withTimeout(
|
|
7572
|
+
fetchGitHubFolder(template.source, {
|
|
7573
|
+
userAgent: "EvalForge-Evaluator"
|
|
7574
|
+
}),
|
|
7575
|
+
6e4,
|
|
7576
|
+
"template source fetch"
|
|
7577
|
+
);
|
|
7578
|
+
onProgress(
|
|
7579
|
+
`[diag] fetched ${sourceFiles.length} template file(s) in ${Date.now() - startedAt}ms`
|
|
7580
|
+
);
|
|
7581
|
+
} catch (err) {
|
|
7582
|
+
onProgress(
|
|
7583
|
+
`[diag] template source fetch FAILED after ${Date.now() - startedAt}ms: ${err instanceof Error ? err.message : String(err)}`
|
|
7584
|
+
);
|
|
7585
|
+
throw err;
|
|
7586
|
+
}
|
|
7525
7587
|
} else if (template.sourceFiles?.length) {
|
|
7526
7588
|
sourceFiles = template.sourceFiles;
|
|
7527
7589
|
} else {
|
|
@@ -7582,7 +7644,7 @@ async function prepareWorkingDirectory(config, evalRunId2, targetId, scenarioId,
|
|
|
7582
7644
|
}
|
|
7583
7645
|
mkdirSync2(workDir2, { recursive: true });
|
|
7584
7646
|
onProgress("Fetching template files...");
|
|
7585
|
-
await fetchAndWriteTemplateFiles(template, workDir2);
|
|
7647
|
+
await fetchAndWriteTemplateFiles(template, workDir2, onProgress);
|
|
7586
7648
|
console.log(`Template files written to ${workDir2}`);
|
|
7587
7649
|
writeWixEnvFile(workDir2);
|
|
7588
7650
|
await installDependencies(workDir2, onProgress, {
|