@slock-ai/daemon 0.28.1-alpha.1 → 0.28.1-alpha.2
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/dist/index.js +36 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -434,6 +434,19 @@ var ClaudeDriver = class {
|
|
|
434
434
|
return [];
|
|
435
435
|
}
|
|
436
436
|
const events = [];
|
|
437
|
+
const pushResultError = (message, fallback) => {
|
|
438
|
+
const parts = [];
|
|
439
|
+
if (Array.isArray(message.errors)) {
|
|
440
|
+
for (const err of message.errors) {
|
|
441
|
+
if (typeof err === "string" && err.trim()) parts.push(err.trim());
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (typeof message.result === "string" && message.result.trim()) {
|
|
445
|
+
parts.push(message.result.trim());
|
|
446
|
+
}
|
|
447
|
+
const detail = parts.join(" | ") || fallback;
|
|
448
|
+
events.push({ kind: "error", message: detail });
|
|
449
|
+
};
|
|
437
450
|
switch (event.type) {
|
|
438
451
|
case "system":
|
|
439
452
|
if (event.subtype === "init" && event.session_id) {
|
|
@@ -456,6 +469,29 @@ var ClaudeDriver = class {
|
|
|
456
469
|
break;
|
|
457
470
|
}
|
|
458
471
|
case "result": {
|
|
472
|
+
const subtype = typeof event.subtype === "string" ? event.subtype : "success";
|
|
473
|
+
const stopReason = typeof event.stop_reason === "string" ? event.stop_reason : null;
|
|
474
|
+
switch (subtype) {
|
|
475
|
+
case "success":
|
|
476
|
+
if (event.is_error && stopReason !== "max_tokens") {
|
|
477
|
+
pushResultError(event, "Execution failed");
|
|
478
|
+
}
|
|
479
|
+
break;
|
|
480
|
+
case "error_during_execution":
|
|
481
|
+
if (stopReason !== "max_tokens") {
|
|
482
|
+
pushResultError(event, "Execution failed");
|
|
483
|
+
}
|
|
484
|
+
break;
|
|
485
|
+
case "error_max_budget_usd":
|
|
486
|
+
pushResultError(event, "Budget limit exceeded");
|
|
487
|
+
break;
|
|
488
|
+
case "error_max_turns":
|
|
489
|
+
pushResultError(event, "Max turns exceeded");
|
|
490
|
+
break;
|
|
491
|
+
case "error_max_structured_output_retries":
|
|
492
|
+
pushResultError(event, "Structured output retries exceeded");
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
459
495
|
events.push({ kind: "turn_end", sessionId: event.session_id });
|
|
460
496
|
break;
|
|
461
497
|
}
|