@wix/evalforge-evaluator 0.16.0 → 0.17.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 +74 -0
- package/build/index.js.map +2 -2
- package/build/index.mjs +74 -0
- package/build/index.mjs.map +2 -2
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -7289,6 +7289,79 @@ async function testNetworkConnectivity(config) {
|
|
|
7289
7289
|
durationMs: Date.now() - start
|
|
7290
7290
|
};
|
|
7291
7291
|
}
|
|
7292
|
+
async function testAiGatewayApiCall(config) {
|
|
7293
|
+
const start = Date.now();
|
|
7294
|
+
const details = {};
|
|
7295
|
+
const gatewayUrl = config.aiGatewayUrl;
|
|
7296
|
+
const headers = config.aiGatewayHeaders;
|
|
7297
|
+
details.gatewayUrl = gatewayUrl;
|
|
7298
|
+
details.hasHeaders = !!headers;
|
|
7299
|
+
details.headerKeys = headers ? Object.keys(headers) : [];
|
|
7300
|
+
if (!gatewayUrl) {
|
|
7301
|
+
return {
|
|
7302
|
+
name: "ai-gateway-api-call",
|
|
7303
|
+
passed: false,
|
|
7304
|
+
details,
|
|
7305
|
+
error: "No AI_GATEWAY_URL configured",
|
|
7306
|
+
durationMs: Date.now() - start
|
|
7307
|
+
};
|
|
7308
|
+
}
|
|
7309
|
+
if (!headers) {
|
|
7310
|
+
return {
|
|
7311
|
+
name: "ai-gateway-api-call",
|
|
7312
|
+
passed: false,
|
|
7313
|
+
details,
|
|
7314
|
+
error: "No AI_GATEWAY_HEADERS configured",
|
|
7315
|
+
durationMs: Date.now() - start
|
|
7316
|
+
};
|
|
7317
|
+
}
|
|
7318
|
+
const headerFlags = Object.entries(headers).map(([k, v]) => `-H "${k}: ${v}"`).join(" ");
|
|
7319
|
+
const requestBody = JSON.stringify({
|
|
7320
|
+
model: "claude-3-5-sonnet-latest",
|
|
7321
|
+
max_tokens: 10,
|
|
7322
|
+
messages: [{ role: "user", content: "Say hi" }]
|
|
7323
|
+
}).replace(/"/g, '\\"');
|
|
7324
|
+
const messagesUrl = `${gatewayUrl}/v1/messages`;
|
|
7325
|
+
const curlCmd = `curl -s --max-time 15 ${headerFlags} -H "Content-Type: application/json" -H "anthropic-version: 2023-06-01" -d "${requestBody}" "${messagesUrl}" 2>&1`;
|
|
7326
|
+
const redactedCmd = curlCmd.replace(/app-secret:[^"]+/g, "app-secret:[REDACTED]").replace(
|
|
7327
|
+
/-H "x-wix-ai-gateway-app-secret: [^"]+"/g,
|
|
7328
|
+
'-H "x-wix-ai-gateway-app-secret: [REDACTED]"'
|
|
7329
|
+
);
|
|
7330
|
+
details.curlCommand = redactedCmd;
|
|
7331
|
+
console.error("[DIAG] Making actual API call to AI Gateway...");
|
|
7332
|
+
console.error("[DIAG] URL:", messagesUrl);
|
|
7333
|
+
const result = await execCommand(curlCmd, 2e4);
|
|
7334
|
+
details.responseRaw = result.stdout.slice(0, 1500);
|
|
7335
|
+
details.exitCode = result.exitCode;
|
|
7336
|
+
let responseJson = null;
|
|
7337
|
+
try {
|
|
7338
|
+
responseJson = JSON.parse(result.stdout);
|
|
7339
|
+
details.responseParsed = true;
|
|
7340
|
+
} catch {
|
|
7341
|
+
details.responseParsed = false;
|
|
7342
|
+
details.parseError = "Response is not valid JSON";
|
|
7343
|
+
}
|
|
7344
|
+
const isError = result.stdout.includes('"type":"error"') || result.stdout.includes('"error":{') || result.stdout.includes("authentication_error") || result.stdout.includes("permission_error");
|
|
7345
|
+
const isSuccess = result.stdout.includes('"type":"message"') || result.stdout.includes('"content":');
|
|
7346
|
+
details.isError = isError;
|
|
7347
|
+
details.isSuccess = isSuccess;
|
|
7348
|
+
if (isError && responseJson && typeof responseJson === "object") {
|
|
7349
|
+
const errorObj = responseJson;
|
|
7350
|
+
if (errorObj.error && typeof errorObj.error === "object") {
|
|
7351
|
+
const error = errorObj.error;
|
|
7352
|
+
details.errorType = error.type;
|
|
7353
|
+
details.errorMessage = error.message;
|
|
7354
|
+
}
|
|
7355
|
+
}
|
|
7356
|
+
const passed = result.exitCode === 0 && isSuccess && !isError;
|
|
7357
|
+
return {
|
|
7358
|
+
name: "ai-gateway-api-call",
|
|
7359
|
+
passed,
|
|
7360
|
+
details,
|
|
7361
|
+
error: passed ? void 0 : isError ? `API returned error: ${details.errorType || "unknown"} - ${details.errorMessage || result.stdout.slice(0, 200)}` : `API call failed: exit=${result.exitCode}, response=${result.stdout.slice(0, 200)}`,
|
|
7362
|
+
durationMs: Date.now() - start
|
|
7363
|
+
};
|
|
7364
|
+
}
|
|
7292
7365
|
async function testChildProcessSpawning() {
|
|
7293
7366
|
const start = Date.now();
|
|
7294
7367
|
const details = {};
|
|
@@ -7494,6 +7567,7 @@ async function runDiagnostics(config, evalRunId2) {
|
|
|
7494
7567
|
await runTest("environment-dump", testEnvironmentDump);
|
|
7495
7568
|
await runTest("file-system-structure", testFileSystemStructure);
|
|
7496
7569
|
await runTest("network-connectivity", () => testNetworkConnectivity(config));
|
|
7570
|
+
await runTest("ai-gateway-api-call", () => testAiGatewayApiCall(config));
|
|
7497
7571
|
await runTest("child-process-spawning", testChildProcessSpawning);
|
|
7498
7572
|
await runTest("sdk-import", testSdkImport);
|
|
7499
7573
|
await runTest("file-system-write", testFileSystemWrite);
|