@wix/evalforge-evaluator 0.7.0 → 0.9.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
CHANGED
|
@@ -57,6 +57,7 @@ function loadConfig() {
|
|
|
57
57
|
}
|
|
58
58
|
const tracePushUrl = process.env.TRACE_PUSH_URL;
|
|
59
59
|
const routeHeader = process.env.EVAL_ROUTE_HEADER;
|
|
60
|
+
const authToken = process.env.EVAL_AUTH_TOKEN;
|
|
60
61
|
return {
|
|
61
62
|
serverUrl,
|
|
62
63
|
apiPrefix,
|
|
@@ -64,7 +65,8 @@ function loadConfig() {
|
|
|
64
65
|
aiGatewayHeaders,
|
|
65
66
|
evaluationsDir,
|
|
66
67
|
tracePushUrl,
|
|
67
|
-
routeHeader
|
|
68
|
+
routeHeader,
|
|
69
|
+
authToken
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -73,15 +75,20 @@ function createApiClient(serverUrl, options = "") {
|
|
|
73
75
|
const opts = typeof options === "string" ? { apiPrefix: options } : options;
|
|
74
76
|
const apiPrefix = opts.apiPrefix ?? "";
|
|
75
77
|
const routeHeader = opts.routeHeader;
|
|
78
|
+
const authToken = opts.authToken;
|
|
79
|
+
const pathPrefix = authToken ? "/public" : "";
|
|
76
80
|
function buildHeaders(additionalHeaders) {
|
|
77
81
|
const headers = { ...additionalHeaders };
|
|
82
|
+
if (authToken) {
|
|
83
|
+
headers["Authorization"] = `Bearer ${authToken}`;
|
|
84
|
+
}
|
|
78
85
|
if (routeHeader) {
|
|
79
86
|
headers["x-wix-route"] = routeHeader;
|
|
80
87
|
}
|
|
81
88
|
return headers;
|
|
82
89
|
}
|
|
83
90
|
async function fetchJson(path9) {
|
|
84
|
-
const url = `${serverUrl}${apiPrefix}${path9}`;
|
|
91
|
+
const url = `${serverUrl}${apiPrefix}${pathPrefix}${path9}`;
|
|
85
92
|
console.error(`[API] GET ${url}`);
|
|
86
93
|
const headers = buildHeaders();
|
|
87
94
|
const response = await fetch(url, {
|
|
@@ -96,7 +103,7 @@ function createApiClient(serverUrl, options = "") {
|
|
|
96
103
|
return response.json();
|
|
97
104
|
}
|
|
98
105
|
async function postJson(path9, body) {
|
|
99
|
-
const url = `${serverUrl}${apiPrefix}${path9}`;
|
|
106
|
+
const url = `${serverUrl}${apiPrefix}${pathPrefix}${path9}`;
|
|
100
107
|
console.error(`[API] POST ${url}`);
|
|
101
108
|
const response = await fetch(url, {
|
|
102
109
|
method: "POST",
|
|
@@ -111,7 +118,7 @@ function createApiClient(serverUrl, options = "") {
|
|
|
111
118
|
}
|
|
112
119
|
}
|
|
113
120
|
async function deleteRequest(path9) {
|
|
114
|
-
const url = `${serverUrl}${apiPrefix}${path9}`;
|
|
121
|
+
const url = `${serverUrl}${apiPrefix}${pathPrefix}${path9}`;
|
|
115
122
|
console.error(`[API] DELETE ${url}`);
|
|
116
123
|
const headers = buildHeaders();
|
|
117
124
|
const response = await fetch(url, {
|
|
@@ -126,7 +133,7 @@ function createApiClient(serverUrl, options = "") {
|
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
135
|
async function putJson(path9, body) {
|
|
129
|
-
const url = `${serverUrl}${apiPrefix}${path9}`;
|
|
136
|
+
const url = `${serverUrl}${apiPrefix}${pathPrefix}${path9}`;
|
|
130
137
|
console.error(`[API] PUT ${url}`);
|
|
131
138
|
const response = await fetch(url, {
|
|
132
139
|
method: "PUT",
|
|
@@ -6097,19 +6104,22 @@ var import_crypto = require("crypto");
|
|
|
6097
6104
|
var import_promises3 = require("fs/promises");
|
|
6098
6105
|
var import_path5 = require("path");
|
|
6099
6106
|
var DEFAULT_MODEL = "claude-sonnet-4-20250514";
|
|
6100
|
-
function emitTraceEvent(event, tracePushUrl, routeHeader) {
|
|
6107
|
+
function emitTraceEvent(event, tracePushUrl, routeHeader, authToken) {
|
|
6101
6108
|
console.log(`${import_evalforge_types.TRACE_EVENT_PREFIX}${JSON.stringify(event)}`);
|
|
6102
6109
|
if (tracePushUrl) {
|
|
6103
|
-
pushTraceEvent(tracePushUrl, event, routeHeader).catch((err) => {
|
|
6110
|
+
pushTraceEvent(tracePushUrl, event, routeHeader, authToken).catch((err) => {
|
|
6104
6111
|
console.error("[Trace Push] Failed to push trace event:", err);
|
|
6105
6112
|
});
|
|
6106
6113
|
}
|
|
6107
6114
|
}
|
|
6108
|
-
async function pushTraceEvent(url, event, routeHeader) {
|
|
6115
|
+
async function pushTraceEvent(url, event, routeHeader, authToken) {
|
|
6109
6116
|
try {
|
|
6110
6117
|
const headers = {
|
|
6111
6118
|
"Content-Type": "application/json"
|
|
6112
6119
|
};
|
|
6120
|
+
if (authToken) {
|
|
6121
|
+
headers["Authorization"] = `Bearer ${authToken}`;
|
|
6122
|
+
}
|
|
6113
6123
|
if (routeHeader) {
|
|
6114
6124
|
headers["x-wix-route"] = routeHeader;
|
|
6115
6125
|
}
|
|
@@ -6287,7 +6297,8 @@ async function executeWithClaudeCode(skill, scenario, options) {
|
|
|
6287
6297
|
emitTraceEvent(
|
|
6288
6298
|
traceEvent,
|
|
6289
6299
|
traceContext.tracePushUrl,
|
|
6290
|
-
traceContext.routeHeader
|
|
6300
|
+
traceContext.routeHeader,
|
|
6301
|
+
traceContext.authToken
|
|
6291
6302
|
);
|
|
6292
6303
|
}
|
|
6293
6304
|
}
|
|
@@ -6311,7 +6322,8 @@ async function executeWithClaudeCode(skill, scenario, options) {
|
|
|
6311
6322
|
isComplete: true
|
|
6312
6323
|
},
|
|
6313
6324
|
traceContext.tracePushUrl,
|
|
6314
|
-
traceContext.routeHeader
|
|
6325
|
+
traceContext.routeHeader,
|
|
6326
|
+
traceContext.authToken
|
|
6315
6327
|
);
|
|
6316
6328
|
}
|
|
6317
6329
|
const endTime = /* @__PURE__ */ new Date();
|
|
@@ -6532,7 +6544,8 @@ async function callSkill(config, evalRunId2, scenario, skill, agent, workDir) {
|
|
|
6532
6544
|
targetId: skill.id,
|
|
6533
6545
|
targetName: skill.name,
|
|
6534
6546
|
tracePushUrl: config.tracePushUrl,
|
|
6535
|
-
routeHeader: config.routeHeader
|
|
6547
|
+
routeHeader: config.routeHeader,
|
|
6548
|
+
authToken: config.authToken
|
|
6536
6549
|
}
|
|
6537
6550
|
});
|
|
6538
6551
|
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -6650,7 +6663,8 @@ async function runEvaluation(projectId2, evalRunId2) {
|
|
|
6650
6663
|
});
|
|
6651
6664
|
const api = createApiClient(config.serverUrl, {
|
|
6652
6665
|
apiPrefix: config.apiPrefix,
|
|
6653
|
-
routeHeader: config.routeHeader
|
|
6666
|
+
routeHeader: config.routeHeader,
|
|
6667
|
+
authToken: config.authToken
|
|
6654
6668
|
});
|
|
6655
6669
|
console.error(
|
|
6656
6670
|
"[DEBUG-H2] fetchEvaluationData START",
|
|
@@ -6737,7 +6751,8 @@ runEvaluation(projectId, evalRunId).then(() => {
|
|
|
6737
6751
|
const config = loadConfig();
|
|
6738
6752
|
const api = createApiClient(config.serverUrl, {
|
|
6739
6753
|
apiPrefix: config.apiPrefix,
|
|
6740
|
-
routeHeader: config.routeHeader
|
|
6754
|
+
routeHeader: config.routeHeader,
|
|
6755
|
+
authToken: config.authToken
|
|
6741
6756
|
});
|
|
6742
6757
|
await api.updateEvalRun(projectId, evalRunId, {
|
|
6743
6758
|
status: import_evalforge_types3.EvalStatus.FAILED,
|