@wix/evalforge-evaluator 0.7.0 → 0.8.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.mjs
CHANGED
|
@@ -34,6 +34,7 @@ function loadConfig() {
|
|
|
34
34
|
}
|
|
35
35
|
const tracePushUrl = process.env.TRACE_PUSH_URL;
|
|
36
36
|
const routeHeader = process.env.EVAL_ROUTE_HEADER;
|
|
37
|
+
const authToken = process.env.EVAL_AUTH_TOKEN;
|
|
37
38
|
return {
|
|
38
39
|
serverUrl,
|
|
39
40
|
apiPrefix,
|
|
@@ -41,7 +42,8 @@ function loadConfig() {
|
|
|
41
42
|
aiGatewayHeaders,
|
|
42
43
|
evaluationsDir,
|
|
43
44
|
tracePushUrl,
|
|
44
|
-
routeHeader
|
|
45
|
+
routeHeader,
|
|
46
|
+
authToken
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -50,15 +52,20 @@ function createApiClient(serverUrl, options = "") {
|
|
|
50
52
|
const opts = typeof options === "string" ? { apiPrefix: options } : options;
|
|
51
53
|
const apiPrefix = opts.apiPrefix ?? "";
|
|
52
54
|
const routeHeader = opts.routeHeader;
|
|
55
|
+
const authToken = opts.authToken;
|
|
56
|
+
const pathPrefix = authToken ? "/public" : "";
|
|
53
57
|
function buildHeaders(additionalHeaders) {
|
|
54
58
|
const headers = { ...additionalHeaders };
|
|
59
|
+
if (authToken) {
|
|
60
|
+
headers["Authorization"] = `Bearer ${authToken}`;
|
|
61
|
+
}
|
|
55
62
|
if (routeHeader) {
|
|
56
63
|
headers["x-wix-route"] = routeHeader;
|
|
57
64
|
}
|
|
58
65
|
return headers;
|
|
59
66
|
}
|
|
60
67
|
async function fetchJson(path9) {
|
|
61
|
-
const url = `${serverUrl}${apiPrefix}${path9}`;
|
|
68
|
+
const url = `${serverUrl}${apiPrefix}${pathPrefix}${path9}`;
|
|
62
69
|
console.error(`[API] GET ${url}`);
|
|
63
70
|
const headers = buildHeaders();
|
|
64
71
|
const response = await fetch(url, {
|
|
@@ -73,7 +80,7 @@ function createApiClient(serverUrl, options = "") {
|
|
|
73
80
|
return response.json();
|
|
74
81
|
}
|
|
75
82
|
async function postJson(path9, body) {
|
|
76
|
-
const url = `${serverUrl}${apiPrefix}${path9}`;
|
|
83
|
+
const url = `${serverUrl}${apiPrefix}${pathPrefix}${path9}`;
|
|
77
84
|
console.error(`[API] POST ${url}`);
|
|
78
85
|
const response = await fetch(url, {
|
|
79
86
|
method: "POST",
|
|
@@ -88,7 +95,7 @@ function createApiClient(serverUrl, options = "") {
|
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
97
|
async function deleteRequest(path9) {
|
|
91
|
-
const url = `${serverUrl}${apiPrefix}${path9}`;
|
|
98
|
+
const url = `${serverUrl}${apiPrefix}${pathPrefix}${path9}`;
|
|
92
99
|
console.error(`[API] DELETE ${url}`);
|
|
93
100
|
const headers = buildHeaders();
|
|
94
101
|
const response = await fetch(url, {
|
|
@@ -103,7 +110,7 @@ function createApiClient(serverUrl, options = "") {
|
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
async function putJson(path9, body) {
|
|
106
|
-
const url = `${serverUrl}${apiPrefix}${path9}`;
|
|
113
|
+
const url = `${serverUrl}${apiPrefix}${pathPrefix}${path9}`;
|
|
107
114
|
console.error(`[API] PUT ${url}`);
|
|
108
115
|
const response = await fetch(url, {
|
|
109
116
|
method: "PUT",
|
|
@@ -6080,19 +6087,22 @@ import { randomUUID } from "crypto";
|
|
|
6080
6087
|
import { mkdir as mkdir2, writeFile } from "fs/promises";
|
|
6081
6088
|
import { join as join2 } from "path";
|
|
6082
6089
|
var DEFAULT_MODEL = "claude-sonnet-4-20250514";
|
|
6083
|
-
function emitTraceEvent(event, tracePushUrl, routeHeader) {
|
|
6090
|
+
function emitTraceEvent(event, tracePushUrl, routeHeader, authToken) {
|
|
6084
6091
|
console.log(`${TRACE_EVENT_PREFIX}${JSON.stringify(event)}`);
|
|
6085
6092
|
if (tracePushUrl) {
|
|
6086
|
-
pushTraceEvent(tracePushUrl, event, routeHeader).catch((err) => {
|
|
6093
|
+
pushTraceEvent(tracePushUrl, event, routeHeader, authToken).catch((err) => {
|
|
6087
6094
|
console.error("[Trace Push] Failed to push trace event:", err);
|
|
6088
6095
|
});
|
|
6089
6096
|
}
|
|
6090
6097
|
}
|
|
6091
|
-
async function pushTraceEvent(url, event, routeHeader) {
|
|
6098
|
+
async function pushTraceEvent(url, event, routeHeader, authToken) {
|
|
6092
6099
|
try {
|
|
6093
6100
|
const headers = {
|
|
6094
6101
|
"Content-Type": "application/json"
|
|
6095
6102
|
};
|
|
6103
|
+
if (authToken) {
|
|
6104
|
+
headers["Authorization"] = `Bearer ${authToken}`;
|
|
6105
|
+
}
|
|
6096
6106
|
if (routeHeader) {
|
|
6097
6107
|
headers["x-wix-route"] = routeHeader;
|
|
6098
6108
|
}
|
|
@@ -6270,7 +6280,8 @@ async function executeWithClaudeCode(skill, scenario, options) {
|
|
|
6270
6280
|
emitTraceEvent(
|
|
6271
6281
|
traceEvent,
|
|
6272
6282
|
traceContext.tracePushUrl,
|
|
6273
|
-
traceContext.routeHeader
|
|
6283
|
+
traceContext.routeHeader,
|
|
6284
|
+
traceContext.authToken
|
|
6274
6285
|
);
|
|
6275
6286
|
}
|
|
6276
6287
|
}
|
|
@@ -6294,7 +6305,8 @@ async function executeWithClaudeCode(skill, scenario, options) {
|
|
|
6294
6305
|
isComplete: true
|
|
6295
6306
|
},
|
|
6296
6307
|
traceContext.tracePushUrl,
|
|
6297
|
-
traceContext.routeHeader
|
|
6308
|
+
traceContext.routeHeader,
|
|
6309
|
+
traceContext.authToken
|
|
6298
6310
|
);
|
|
6299
6311
|
}
|
|
6300
6312
|
const endTime = /* @__PURE__ */ new Date();
|
|
@@ -6515,7 +6527,8 @@ async function callSkill(config, evalRunId2, scenario, skill, agent, workDir) {
|
|
|
6515
6527
|
targetId: skill.id,
|
|
6516
6528
|
targetName: skill.name,
|
|
6517
6529
|
tracePushUrl: config.tracePushUrl,
|
|
6518
|
-
routeHeader: config.routeHeader
|
|
6530
|
+
routeHeader: config.routeHeader,
|
|
6531
|
+
authToken: config.authToken
|
|
6519
6532
|
}
|
|
6520
6533
|
});
|
|
6521
6534
|
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -6633,7 +6646,8 @@ async function runEvaluation(projectId2, evalRunId2) {
|
|
|
6633
6646
|
});
|
|
6634
6647
|
const api = createApiClient(config.serverUrl, {
|
|
6635
6648
|
apiPrefix: config.apiPrefix,
|
|
6636
|
-
routeHeader: config.routeHeader
|
|
6649
|
+
routeHeader: config.routeHeader,
|
|
6650
|
+
authToken: config.authToken
|
|
6637
6651
|
});
|
|
6638
6652
|
console.error(
|
|
6639
6653
|
"[DEBUG-H2] fetchEvaluationData START",
|