@wix/evalforge-evaluator 0.12.0 → 0.14.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 +187 -31
- package/build/index.js.map +3 -3
- package/build/index.mjs +187 -31
- package/build/index.mjs.map +3 -3
- package/package.json +2 -2
package/build/index.mjs
CHANGED
|
@@ -6216,10 +6216,45 @@ async function executeWithClaudeCode(skill, scenario, options) {
|
|
|
6216
6216
|
);
|
|
6217
6217
|
}
|
|
6218
6218
|
const sdkEnv = buildSdkEnvironment(options);
|
|
6219
|
-
console.log("[
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6219
|
+
console.log("[SDK-DEBUG] ====== CLAUDE SDK INITIALIZATION ======");
|
|
6220
|
+
console.log("[SDK-DEBUG] Timestamp:", (/* @__PURE__ */ new Date()).toISOString());
|
|
6221
|
+
console.log("[SDK-DEBUG] Node version:", process.version);
|
|
6222
|
+
console.log("[SDK-DEBUG] Platform:", process.platform, process.arch);
|
|
6223
|
+
console.log("[SDK-DEBUG] CWD:", options.cwd);
|
|
6224
|
+
console.log("[SDK-DEBUG] Process CWD:", process.cwd());
|
|
6225
|
+
console.log("[SDK-DEBUG] SDK Environment:");
|
|
6226
|
+
console.log(
|
|
6227
|
+
"[SDK-DEBUG] ANTHROPIC_API_KEY:",
|
|
6228
|
+
sdkEnv.ANTHROPIC_API_KEY ? `${sdkEnv.ANTHROPIC_API_KEY.substring(0, 15)}...` : "NOT SET"
|
|
6229
|
+
);
|
|
6230
|
+
console.log(
|
|
6231
|
+
"[SDK-DEBUG] ANTHROPIC_AUTH_TOKEN:",
|
|
6232
|
+
sdkEnv.ANTHROPIC_AUTH_TOKEN ? `${sdkEnv.ANTHROPIC_AUTH_TOKEN.substring(0, 15)}...` : "NOT SET"
|
|
6233
|
+
);
|
|
6234
|
+
console.log(
|
|
6235
|
+
"[SDK-DEBUG] ANTHROPIC_BASE_URL:",
|
|
6236
|
+
sdkEnv.ANTHROPIC_BASE_URL || "NOT SET"
|
|
6237
|
+
);
|
|
6238
|
+
console.log(
|
|
6239
|
+
"[SDK-DEBUG] ANTHROPIC_CUSTOM_HEADERS present:",
|
|
6240
|
+
!!sdkEnv.ANTHROPIC_CUSTOM_HEADERS
|
|
6241
|
+
);
|
|
6242
|
+
if (sdkEnv.ANTHROPIC_CUSTOM_HEADERS) {
|
|
6243
|
+
const headerNames = sdkEnv.ANTHROPIC_CUSTOM_HEADERS.split("\n").map((h) => {
|
|
6244
|
+
const colonIdx = h.indexOf(":");
|
|
6245
|
+
return colonIdx > 0 ? h.substring(0, colonIdx) : h;
|
|
6246
|
+
}).join(", ");
|
|
6247
|
+
console.log("[SDK-DEBUG] ANTHROPIC_CUSTOM_HEADERS keys:", headerNames);
|
|
6248
|
+
}
|
|
6249
|
+
console.log("[SDK-DEBUG] PATH available:", !!sdkEnv.PATH);
|
|
6250
|
+
console.log("[SDK-DEBUG] HOME:", sdkEnv.HOME || "NOT SET");
|
|
6251
|
+
console.log("[SDK-DEBUG] Skill:", skill.id, "-", skill.name);
|
|
6252
|
+
console.log("[SDK-DEBUG] Scenario:", scenario.id, "-", scenario.name);
|
|
6253
|
+
console.log(
|
|
6254
|
+
"[SDK-DEBUG] Prompt preview:",
|
|
6255
|
+
scenario.triggerPrompt.substring(0, 100) + "..."
|
|
6256
|
+
);
|
|
6257
|
+
console.log("[SDK-DEBUG] ============================================");
|
|
6223
6258
|
let traceStepNumber = 0;
|
|
6224
6259
|
const traceContext = options.traceContext;
|
|
6225
6260
|
const maxTurns = options.maxTurns ?? 10;
|
|
@@ -6251,6 +6286,27 @@ async function executeWithClaudeCode(skill, scenario, options) {
|
|
|
6251
6286
|
if (options.maxTokens !== void 0) {
|
|
6252
6287
|
queryOptions.maxTokens = options.maxTokens;
|
|
6253
6288
|
}
|
|
6289
|
+
console.log("[SDK-DEBUG] Query options:");
|
|
6290
|
+
console.log("[SDK-DEBUG] model:", queryOptions.model);
|
|
6291
|
+
console.log("[SDK-DEBUG] maxTurns:", queryOptions.maxTurns);
|
|
6292
|
+
console.log(
|
|
6293
|
+
"[SDK-DEBUG] maxThinkingTokens:",
|
|
6294
|
+
queryOptions.maxThinkingTokens
|
|
6295
|
+
);
|
|
6296
|
+
console.log("[SDK-DEBUG] temperature:", queryOptions.temperature);
|
|
6297
|
+
console.log("[SDK-DEBUG] maxTokens:", queryOptions.maxTokens);
|
|
6298
|
+
console.log("[SDK-DEBUG] permissionMode:", queryOptions.permissionMode);
|
|
6299
|
+
console.log(
|
|
6300
|
+
"[SDK-DEBUG] allowDangerouslySkipPermissions:",
|
|
6301
|
+
queryOptions.allowDangerouslySkipPermissions
|
|
6302
|
+
);
|
|
6303
|
+
console.log("[SDK-DEBUG] settingSources:", queryOptions.settingSources);
|
|
6304
|
+
console.log("[SDK-DEBUG] allowedTools:", queryOptions.allowedTools);
|
|
6305
|
+
console.log(
|
|
6306
|
+
"[SDK-DEBUG] mcpServers:",
|
|
6307
|
+
queryOptions.mcpServers ? Object.keys(queryOptions.mcpServers) : "none"
|
|
6308
|
+
);
|
|
6309
|
+
console.log("[SDK-DEBUG] Calling SDK query()...");
|
|
6254
6310
|
try {
|
|
6255
6311
|
for await (const message of query({
|
|
6256
6312
|
prompt: scenario.triggerPrompt,
|
|
@@ -6292,51 +6348,149 @@ async function executeWithClaudeCode(skill, scenario, options) {
|
|
|
6292
6348
|
"messages"
|
|
6293
6349
|
);
|
|
6294
6350
|
} catch (sdkError) {
|
|
6351
|
+
console.error("[SDK-ERROR] ====== CLAUDE SDK EXECUTION FAILED ======");
|
|
6352
|
+
console.error("[SDK-ERROR] Timestamp:", (/* @__PURE__ */ new Date()).toISOString());
|
|
6353
|
+
console.error(
|
|
6354
|
+
"[SDK-ERROR] Messages received before failure:",
|
|
6355
|
+
messageCount
|
|
6356
|
+
);
|
|
6295
6357
|
const errorMessage = sdkError instanceof Error ? sdkError.message : String(sdkError);
|
|
6296
6358
|
const errorStack = sdkError instanceof Error ? sdkError.stack : void 0;
|
|
6297
|
-
|
|
6298
|
-
console.error("[
|
|
6359
|
+
const errorName = sdkError instanceof Error ? sdkError.name : "Unknown";
|
|
6360
|
+
console.error("[SDK-ERROR] Error name:", errorName);
|
|
6361
|
+
console.error("[SDK-ERROR] Error message:", errorMessage);
|
|
6299
6362
|
if (errorStack) {
|
|
6300
|
-
console.error("[
|
|
6363
|
+
console.error("[SDK-ERROR] Full stack trace:");
|
|
6364
|
+
console.error(errorStack);
|
|
6301
6365
|
}
|
|
6302
6366
|
if (sdkError && typeof sdkError === "object") {
|
|
6303
|
-
const
|
|
6304
|
-
|
|
6305
|
-
for (const key of
|
|
6367
|
+
const errObj2 = sdkError;
|
|
6368
|
+
console.error("[SDK-ERROR] Error object properties:");
|
|
6369
|
+
for (const key of Object.keys(errObj2)) {
|
|
6370
|
+
const value = errObj2[key];
|
|
6371
|
+
if (value !== void 0 && key !== "stack") {
|
|
6372
|
+
try {
|
|
6373
|
+
const valueStr = typeof value === "object" ? JSON.stringify(value, null, 2) : String(value);
|
|
6374
|
+
console.error(`[SDK-ERROR] ${key}:`, valueStr.substring(0, 1e3));
|
|
6375
|
+
} catch {
|
|
6376
|
+
console.error(`[SDK-ERROR] ${key}: [cannot serialize]`);
|
|
6377
|
+
}
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
6380
|
+
const sdkErrorKeys2 = [
|
|
6306
6381
|
"code",
|
|
6307
6382
|
"status",
|
|
6383
|
+
"statusCode",
|
|
6384
|
+
"statusText",
|
|
6308
6385
|
"stderr",
|
|
6309
6386
|
"stdout",
|
|
6387
|
+
"output",
|
|
6310
6388
|
"exitCode",
|
|
6311
6389
|
"signal",
|
|
6312
|
-
"
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6390
|
+
"killed",
|
|
6391
|
+
"cause",
|
|
6392
|
+
"reason",
|
|
6393
|
+
"details",
|
|
6394
|
+
"response",
|
|
6395
|
+
"request",
|
|
6396
|
+
"config",
|
|
6397
|
+
"errno",
|
|
6398
|
+
"syscall",
|
|
6399
|
+
"path",
|
|
6400
|
+
"spawnargs"
|
|
6401
|
+
];
|
|
6402
|
+
const extraInfo = {};
|
|
6403
|
+
for (const key of sdkErrorKeys2) {
|
|
6404
|
+
if (key in errObj2 && errObj2[key] !== void 0) {
|
|
6405
|
+
extraInfo[key] = errObj2[key];
|
|
6316
6406
|
}
|
|
6317
6407
|
}
|
|
6318
6408
|
if (Object.keys(extraInfo).length > 0) {
|
|
6319
|
-
console.error(
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6409
|
+
console.error("[SDK-ERROR] SDK-specific error details:");
|
|
6410
|
+
console.error(JSON.stringify(extraInfo, null, 2));
|
|
6411
|
+
}
|
|
6412
|
+
if (errObj2.cause && typeof errObj2.cause === "object") {
|
|
6413
|
+
console.error("[SDK-ERROR] Error cause:");
|
|
6414
|
+
try {
|
|
6415
|
+
console.error(JSON.stringify(errObj2.cause, null, 2));
|
|
6416
|
+
} catch {
|
|
6417
|
+
console.error("[SDK-ERROR] Error cause: [cannot serialize]");
|
|
6418
|
+
}
|
|
6323
6419
|
}
|
|
6324
6420
|
}
|
|
6421
|
+
console.error("[SDK-ERROR] Execution context:");
|
|
6422
|
+
console.error("[SDK-ERROR] skillId:", skill.id);
|
|
6423
|
+
console.error("[SDK-ERROR] skillName:", skill.name);
|
|
6424
|
+
console.error("[SDK-ERROR] scenarioId:", scenario.id);
|
|
6425
|
+
console.error("[SDK-ERROR] scenarioName:", scenario.name);
|
|
6426
|
+
console.error("[SDK-ERROR] cwd:", options.cwd);
|
|
6427
|
+
console.error("[SDK-ERROR] model:", options.model || DEFAULT_MODEL);
|
|
6428
|
+
console.error("[SDK-ERROR] aiGatewayUrl:", options.aiGatewayUrl);
|
|
6325
6429
|
console.error(
|
|
6326
|
-
"[
|
|
6327
|
-
|
|
6328
|
-
skillId: skill.id,
|
|
6329
|
-
skillName: skill.name,
|
|
6330
|
-
scenarioId: scenario.id,
|
|
6331
|
-
scenarioName: scenario.name,
|
|
6332
|
-
messagesReceived: messageCount,
|
|
6333
|
-
cwd: options.cwd,
|
|
6334
|
-
model: options.model || DEFAULT_MODEL
|
|
6335
|
-
})
|
|
6430
|
+
"[SDK-ERROR] hasAiGatewayHeaders:",
|
|
6431
|
+
!!options.aiGatewayHeaders
|
|
6336
6432
|
);
|
|
6433
|
+
console.error("[SDK-ERROR] Environment info:");
|
|
6434
|
+
console.error("[SDK-ERROR] NODE_ENV:", process.env.NODE_ENV);
|
|
6435
|
+
console.error("[SDK-ERROR] HOME:", process.env.HOME);
|
|
6436
|
+
console.error("[SDK-ERROR] USER:", process.env.USER);
|
|
6437
|
+
console.error("[SDK-ERROR] SHELL:", process.env.SHELL);
|
|
6438
|
+
console.error("[SDK-ERROR] ==========================================");
|
|
6439
|
+
const errObj = sdkError;
|
|
6440
|
+
const sdkSpecificInfo = {};
|
|
6441
|
+
const sdkErrorKeys = [
|
|
6442
|
+
"exitCode",
|
|
6443
|
+
"stderr",
|
|
6444
|
+
"stdout",
|
|
6445
|
+
"signal",
|
|
6446
|
+
"killed",
|
|
6447
|
+
"code",
|
|
6448
|
+
"status",
|
|
6449
|
+
"errno",
|
|
6450
|
+
"syscall",
|
|
6451
|
+
"spawnargs"
|
|
6452
|
+
];
|
|
6453
|
+
for (const key of sdkErrorKeys) {
|
|
6454
|
+
if (errObj && key in errObj && errObj[key] !== void 0) {
|
|
6455
|
+
const val = errObj[key];
|
|
6456
|
+
if (typeof val === "string" && val.length > 500) {
|
|
6457
|
+
sdkSpecificInfo[key] = val.substring(0, 500) + "... [truncated]";
|
|
6458
|
+
} else {
|
|
6459
|
+
sdkSpecificInfo[key] = val;
|
|
6460
|
+
}
|
|
6461
|
+
}
|
|
6462
|
+
}
|
|
6463
|
+
let causeInfo;
|
|
6464
|
+
if (errObj?.cause && typeof errObj.cause === "object") {
|
|
6465
|
+
try {
|
|
6466
|
+
const causeStr = JSON.stringify(errObj.cause, null, 2);
|
|
6467
|
+
causeInfo = causeStr.length > 500 ? causeStr.substring(0, 500) + "... [truncated]" : causeStr;
|
|
6468
|
+
} catch {
|
|
6469
|
+
causeInfo = "[cannot serialize cause]";
|
|
6470
|
+
}
|
|
6471
|
+
}
|
|
6472
|
+
const sdkEnvDebug = {
|
|
6473
|
+
ANTHROPIC_BASE_URL: sdkEnv.ANTHROPIC_BASE_URL,
|
|
6474
|
+
hasANTHROPIC_API_KEY: !!sdkEnv.ANTHROPIC_API_KEY,
|
|
6475
|
+
hasANTHROPIC_AUTH_TOKEN: !!sdkEnv.ANTHROPIC_AUTH_TOKEN,
|
|
6476
|
+
hasANTHROPIC_CUSTOM_HEADERS: !!sdkEnv.ANTHROPIC_CUSTOM_HEADERS,
|
|
6477
|
+
ANTHROPIC_CUSTOM_HEADERS_preview: sdkEnv.ANTHROPIC_CUSTOM_HEADERS ? sdkEnv.ANTHROPIC_CUSTOM_HEADERS.split("\n").map((h) => h.split(":")[0]).join(", ") : void 0
|
|
6478
|
+
};
|
|
6479
|
+
const errorDetails = {
|
|
6480
|
+
messageCount,
|
|
6481
|
+
errorName,
|
|
6482
|
+
errorMessage,
|
|
6483
|
+
skillId: skill.id,
|
|
6484
|
+
scenarioId: scenario.id,
|
|
6485
|
+
model: options.model || DEFAULT_MODEL,
|
|
6486
|
+
sdkEnv: sdkEnvDebug,
|
|
6487
|
+
sdkError: Object.keys(sdkSpecificInfo).length > 0 ? sdkSpecificInfo : void 0,
|
|
6488
|
+
cause: causeInfo
|
|
6489
|
+
};
|
|
6337
6490
|
throw new Error(
|
|
6338
|
-
`Claude SDK execution failed after ${messageCount} messages: ${errorMessage}
|
|
6339
|
-
|
|
6491
|
+
`Claude SDK execution failed after ${messageCount} messages: ${errorMessage}
|
|
6492
|
+
Details: ${JSON.stringify(errorDetails, null, 2)}` + (errorStack ? `
|
|
6493
|
+
Stack: ${errorStack.split("\n").slice(0, 5).join("\n")}` : "")
|
|
6340
6494
|
);
|
|
6341
6495
|
}
|
|
6342
6496
|
if (traceContext) {
|
|
@@ -6393,7 +6547,9 @@ async function writeSkillToFilesystem(cwd, skill) {
|
|
|
6393
6547
|
}
|
|
6394
6548
|
function buildSdkEnvironment(options) {
|
|
6395
6549
|
const env = { ...process.env };
|
|
6396
|
-
|
|
6550
|
+
const placeholderApiKey = "sk-ant-api03-placeholder-auth-handled-by-gateway-000000000000000000000000";
|
|
6551
|
+
env.ANTHROPIC_API_KEY = placeholderApiKey;
|
|
6552
|
+
env.ANTHROPIC_AUTH_TOKEN = placeholderApiKey;
|
|
6397
6553
|
if (options.aiGatewayUrl) {
|
|
6398
6554
|
env.ANTHROPIC_BASE_URL = options.aiGatewayUrl;
|
|
6399
6555
|
}
|