@i14ks/ccv 0.12.1 → 0.12.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/bundle/ccv.mjs +16 -1
- package/package.json +1 -1
package/bundle/ccv.mjs
CHANGED
|
@@ -1039,6 +1039,7 @@ var STOPPED_REASONS = /* @__PURE__ */ new Set([
|
|
|
1039
1039
|
var API_ERROR_REASON = "api_error";
|
|
1040
1040
|
var PERMANENT_API_STATUS = /* @__PURE__ */ new Set([400, 404, 413, 422, 429]);
|
|
1041
1041
|
var RECONNECT_DELAYS_MS = [1e3, 5e3, 2e4, 6e4];
|
|
1042
|
+
var RESUME_TIMEOUT_MS = 3e4;
|
|
1042
1043
|
function turnOutcome(terminalReason, subtype, interruptRequested) {
|
|
1043
1044
|
if (terminalReason && ABORTED_REASONS.has(terminalReason))
|
|
1044
1045
|
return "interrupted";
|
|
@@ -1450,9 +1451,23 @@ var ClaudeSession = class extends EventEmitter {
|
|
|
1450
1451
|
* первым ответом, то есть уже после промпта, — и сессия, которая ждала бы
|
|
1451
1452
|
* его, чтобы промпт отправить, ждала бы вечно. `initializationResult()`,
|
|
1452
1453
|
* наоборот, поднимает CLI сам и не требует, чтобы его о чём-то спросили.
|
|
1454
|
+
*
|
|
1455
|
+
* Гонка с тайм-аутом (`RESUME_TIMEOUT_MS`) нужна на случай, если новый
|
|
1456
|
+
* процесс завис на той же мёртвой сети, из-за которой оборвался прошлый:
|
|
1457
|
+
* без предела `await` не отличил бы это от «ещё думает» и просто не
|
|
1458
|
+
* вернулся бы, оставив реконнект без попытки №2.
|
|
1453
1459
|
*/
|
|
1454
1460
|
async #resume(q) {
|
|
1455
|
-
|
|
1461
|
+
let timer;
|
|
1462
|
+
const timedOut = new Promise((resolve) => {
|
|
1463
|
+
timer = setTimeout(() => resolve(false), RESUME_TIMEOUT_MS);
|
|
1464
|
+
timer.unref?.();
|
|
1465
|
+
});
|
|
1466
|
+
const ready = await Promise.race([
|
|
1467
|
+
q.initializationResult().then(() => true, () => false),
|
|
1468
|
+
timedOut
|
|
1469
|
+
]);
|
|
1470
|
+
clearTimeout(timer);
|
|
1456
1471
|
if (q !== this.#query)
|
|
1457
1472
|
return;
|
|
1458
1473
|
if (!ready) {
|
package/package.json
CHANGED