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