@ascenda-one/claude-code-hooks 0.1.26 → 0.1.27
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/cli.js +64 -29
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3370,16 +3370,20 @@ var require_liveBus = __commonJS({
|
|
|
3370
3370
|
path3.join(home, "Library", "Containers", SAVER_HOST_BUNDLE_ID, "Data", "l.sock")
|
|
3371
3371
|
];
|
|
3372
3372
|
}
|
|
3373
|
-
function
|
|
3373
|
+
function existingSocketCandidates() {
|
|
3374
3374
|
const candidates = liveBusSocketCandidates();
|
|
3375
|
-
|
|
3375
|
+
if (process.env.ASCENDA_LIVE_BUS_SOCKET)
|
|
3376
|
+
return candidates;
|
|
3377
|
+
return candidates.filter((candidate) => {
|
|
3376
3378
|
try {
|
|
3377
|
-
|
|
3378
|
-
return candidate;
|
|
3379
|
+
return fs3.statSync(candidate).isSocket();
|
|
3379
3380
|
} catch {
|
|
3381
|
+
return false;
|
|
3380
3382
|
}
|
|
3381
|
-
}
|
|
3382
|
-
|
|
3383
|
+
});
|
|
3384
|
+
}
|
|
3385
|
+
function liveBusSocketPath() {
|
|
3386
|
+
return existingSocketCandidates()[0] ?? liveBusSocketCandidates()[0];
|
|
3383
3387
|
}
|
|
3384
3388
|
function bucketPromptSize2(text) {
|
|
3385
3389
|
const length = typeof text === "string" ? text.length : 0;
|
|
@@ -3391,44 +3395,75 @@ var require_liveBus = __commonJS({
|
|
|
3391
3395
|
return "l";
|
|
3392
3396
|
return "xl";
|
|
3393
3397
|
}
|
|
3398
|
+
var NOBODY_LISTENING = /* @__PURE__ */ new Set(["ECONNREFUSED", "ENOENT"]);
|
|
3394
3399
|
function emitLiveSignal2(signal) {
|
|
3395
3400
|
return new Promise((resolve2) => {
|
|
3401
|
+
const candidates = existingSocketCandidates();
|
|
3402
|
+
if (candidates.length === 0) {
|
|
3403
|
+
resolve2();
|
|
3404
|
+
return;
|
|
3405
|
+
}
|
|
3396
3406
|
let settled = false;
|
|
3407
|
+
let socket;
|
|
3408
|
+
const drop = () => {
|
|
3409
|
+
try {
|
|
3410
|
+
socket?.destroy();
|
|
3411
|
+
} catch {
|
|
3412
|
+
}
|
|
3413
|
+
socket = void 0;
|
|
3414
|
+
};
|
|
3397
3415
|
const done = () => {
|
|
3398
3416
|
if (settled)
|
|
3399
3417
|
return;
|
|
3400
3418
|
settled = true;
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
} catch {
|
|
3404
|
-
}
|
|
3419
|
+
clearTimeout(timer);
|
|
3420
|
+
drop();
|
|
3405
3421
|
resolve2();
|
|
3406
3422
|
};
|
|
3407
|
-
let socket;
|
|
3408
|
-
try {
|
|
3409
|
-
socket = net.createConnection(liveBusSocketPath());
|
|
3410
|
-
} catch {
|
|
3411
|
-
resolve2();
|
|
3412
|
-
return;
|
|
3413
|
-
}
|
|
3414
3423
|
const timer = setTimeout(done, WRITE_TIMEOUT_MS);
|
|
3415
3424
|
if (typeof timer.unref === "function")
|
|
3416
3425
|
timer.unref();
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3426
|
+
const tryFrom = (index) => {
|
|
3427
|
+
if (settled)
|
|
3428
|
+
return;
|
|
3429
|
+
if (index >= candidates.length) {
|
|
3430
|
+
done();
|
|
3431
|
+
return;
|
|
3432
|
+
}
|
|
3433
|
+
let attempt;
|
|
3421
3434
|
try {
|
|
3422
|
-
|
|
3423
|
-
`, () => {
|
|
3424
|
-
clearTimeout(timer);
|
|
3425
|
-
done();
|
|
3426
|
-
});
|
|
3435
|
+
attempt = net.createConnection(candidates[index]);
|
|
3427
3436
|
} catch {
|
|
3428
|
-
|
|
3429
|
-
|
|
3437
|
+
tryFrom(index + 1);
|
|
3438
|
+
return;
|
|
3430
3439
|
}
|
|
3431
|
-
|
|
3440
|
+
socket = attempt;
|
|
3441
|
+
if (typeof attempt.unref === "function")
|
|
3442
|
+
attempt.unref();
|
|
3443
|
+
let connected = false;
|
|
3444
|
+
attempt.on("error", (error) => {
|
|
3445
|
+
if (settled || socket !== attempt)
|
|
3446
|
+
return;
|
|
3447
|
+
if (!connected && error.code && NOBODY_LISTENING.has(error.code)) {
|
|
3448
|
+
drop();
|
|
3449
|
+
tryFrom(index + 1);
|
|
3450
|
+
return;
|
|
3451
|
+
}
|
|
3452
|
+
done();
|
|
3453
|
+
});
|
|
3454
|
+
attempt.on("connect", () => {
|
|
3455
|
+
if (settled || socket !== attempt)
|
|
3456
|
+
return;
|
|
3457
|
+
connected = true;
|
|
3458
|
+
try {
|
|
3459
|
+
attempt.write(`${JSON.stringify(signal)}
|
|
3460
|
+
`, done);
|
|
3461
|
+
} catch {
|
|
3462
|
+
done();
|
|
3463
|
+
}
|
|
3464
|
+
});
|
|
3465
|
+
};
|
|
3466
|
+
tryFrom(0);
|
|
3432
3467
|
});
|
|
3433
3468
|
}
|
|
3434
3469
|
}
|
package/package.json
CHANGED