@wix/evalforge-evaluator 0.12.0 → 0.13.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
@@ -6233,10 +6233,45 @@ async function executeWithClaudeCode(skill, scenario, options) {
6233
6233
  );
6234
6234
  }
6235
6235
  const sdkEnv = buildSdkEnvironment(options);
6236
- console.log("[executeWithClaudeCode] SDK environment built", {
6237
- hasAnthropicBaseUrl: !!sdkEnv.ANTHROPIC_BASE_URL,
6238
- hasAnthropicCustomHeaders: !!sdkEnv.ANTHROPIC_CUSTOM_HEADERS
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,106 @@ 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
- console.error("[executeWithClaudeCode] Claude SDK execution FAILED");
6315
- console.error("[executeWithClaudeCode] Error message:", errorMessage);
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("[executeWithClaudeCode] Stack trace:", errorStack);
6380
+ console.error("[SDK-ERROR] Full stack trace:");
6381
+ console.error(errorStack);
6318
6382
  }
6319
6383
  if (sdkError && typeof sdkError === "object") {
6320
6384
  const errObj = sdkError;
6321
- const extraInfo = {};
6322
- for (const key of [
6385
+ console.error("[SDK-ERROR] Error object properties:");
6386
+ for (const key of Object.keys(errObj)) {
6387
+ const value = errObj[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 sdkErrorKeys = [
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
- "cause"
6330
- ]) {
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 sdkErrorKeys) {
6331
6421
  if (key in errObj && errObj[key] !== void 0) {
6332
6422
  extraInfo[key] = errObj[key];
6333
6423
  }
6334
6424
  }
6335
6425
  if (Object.keys(extraInfo).length > 0) {
6336
- console.error(
6337
- "[executeWithClaudeCode] Additional error info:",
6338
- JSON.stringify(extraInfo)
6339
- );
6426
+ console.error("[SDK-ERROR] SDK-specific error details:");
6427
+ console.error(JSON.stringify(extraInfo, null, 2));
6428
+ }
6429
+ if (errObj.cause && typeof errObj.cause === "object") {
6430
+ console.error("[SDK-ERROR] Error cause:");
6431
+ try {
6432
+ console.error(JSON.stringify(errObj.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
- "[executeWithClaudeCode] Context:",
6344
- JSON.stringify({
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 errorDetails = {
6457
+ messageCount,
6458
+ errorName,
6459
+ errorMessage,
6460
+ skillId: skill.id,
6461
+ scenarioId: scenario.id,
6462
+ model: options.model || DEFAULT_MODEL
6463
+ };
6354
6464
  throw new Error(
6355
- `Claude SDK execution failed after ${messageCount} messages: ${errorMessage}` + (errorStack ? `
6356
- Stack: ${errorStack.split("\n").slice(0, 3).join("\n")}` : "")
6465
+ `Claude SDK execution failed after ${messageCount} messages: ${errorMessage}
6466
+ Details: ${JSON.stringify(errorDetails)}` + (errorStack ? `
6467
+ Stack: ${errorStack.split("\n").slice(0, 5).join("\n")}` : "")
6357
6468
  );
6358
6469
  }
6359
6470
  if (traceContext) {
@@ -6410,7 +6521,9 @@ async function writeSkillToFilesystem(cwd, skill) {
6410
6521
  }
6411
6522
  function buildSdkEnvironment(options) {
6412
6523
  const env = { ...process.env };
6413
- env.ANTHROPIC_AUTH_TOKEN = "fake-api-token";
6524
+ const placeholderApiKey = "sk-ant-api03-placeholder-auth-handled-by-gateway-000000000000000000000000";
6525
+ env.ANTHROPIC_API_KEY = placeholderApiKey;
6526
+ env.ANTHROPIC_AUTH_TOKEN = placeholderApiKey;
6414
6527
  if (options.aiGatewayUrl) {
6415
6528
  env.ANTHROPIC_BASE_URL = options.aiGatewayUrl;
6416
6529
  }