@ascenda-one/history-import 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.
Files changed (2) hide show
  1. package/dist/cli.js +64 -29
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3363,16 +3363,20 @@ var require_liveBus = __commonJS({
3363
3363
  path13.join(home, "Library", "Containers", SAVER_HOST_BUNDLE_ID, "Data", "l.sock")
3364
3364
  ];
3365
3365
  }
3366
- function liveBusSocketPath() {
3366
+ function existingSocketCandidates() {
3367
3367
  const candidates = liveBusSocketCandidates();
3368
- for (const candidate of candidates) {
3368
+ if (process.env.ASCENDA_LIVE_BUS_SOCKET)
3369
+ return candidates;
3370
+ return candidates.filter((candidate) => {
3369
3371
  try {
3370
- if (fs12.statSync(candidate).isSocket())
3371
- return candidate;
3372
+ return fs12.statSync(candidate).isSocket();
3372
3373
  } catch {
3374
+ return false;
3373
3375
  }
3374
- }
3375
- return candidates[0];
3376
+ });
3377
+ }
3378
+ function liveBusSocketPath() {
3379
+ return existingSocketCandidates()[0] ?? liveBusSocketCandidates()[0];
3376
3380
  }
3377
3381
  function bucketPromptSize(text) {
3378
3382
  const length = typeof text === "string" ? text.length : 0;
@@ -3384,44 +3388,75 @@ var require_liveBus = __commonJS({
3384
3388
  return "l";
3385
3389
  return "xl";
3386
3390
  }
3391
+ var NOBODY_LISTENING = /* @__PURE__ */ new Set(["ECONNREFUSED", "ENOENT"]);
3387
3392
  function emitLiveSignal(signal) {
3388
3393
  return new Promise((resolve2) => {
3394
+ const candidates = existingSocketCandidates();
3395
+ if (candidates.length === 0) {
3396
+ resolve2();
3397
+ return;
3398
+ }
3389
3399
  let settled = false;
3400
+ let socket;
3401
+ const drop = () => {
3402
+ try {
3403
+ socket?.destroy();
3404
+ } catch {
3405
+ }
3406
+ socket = void 0;
3407
+ };
3390
3408
  const done = () => {
3391
3409
  if (settled)
3392
3410
  return;
3393
3411
  settled = true;
3394
- try {
3395
- socket.destroy();
3396
- } catch {
3397
- }
3412
+ clearTimeout(timer);
3413
+ drop();
3398
3414
  resolve2();
3399
3415
  };
3400
- let socket;
3401
- try {
3402
- socket = net.createConnection(liveBusSocketPath());
3403
- } catch {
3404
- resolve2();
3405
- return;
3406
- }
3407
3416
  const timer = setTimeout(done, WRITE_TIMEOUT_MS);
3408
3417
  if (typeof timer.unref === "function")
3409
3418
  timer.unref();
3410
- if (typeof socket.unref === "function")
3411
- socket.unref();
3412
- socket.on("error", done);
3413
- socket.on("connect", () => {
3419
+ const tryFrom = (index) => {
3420
+ if (settled)
3421
+ return;
3422
+ if (index >= candidates.length) {
3423
+ done();
3424
+ return;
3425
+ }
3426
+ let attempt;
3414
3427
  try {
3415
- socket.write(`${JSON.stringify(signal)}
3416
- `, () => {
3417
- clearTimeout(timer);
3418
- done();
3419
- });
3428
+ attempt = net.createConnection(candidates[index]);
3420
3429
  } catch {
3421
- clearTimeout(timer);
3422
- done();
3430
+ tryFrom(index + 1);
3431
+ return;
3423
3432
  }
3424
- });
3433
+ socket = attempt;
3434
+ if (typeof attempt.unref === "function")
3435
+ attempt.unref();
3436
+ let connected = false;
3437
+ attempt.on("error", (error) => {
3438
+ if (settled || socket !== attempt)
3439
+ return;
3440
+ if (!connected && error.code && NOBODY_LISTENING.has(error.code)) {
3441
+ drop();
3442
+ tryFrom(index + 1);
3443
+ return;
3444
+ }
3445
+ done();
3446
+ });
3447
+ attempt.on("connect", () => {
3448
+ if (settled || socket !== attempt)
3449
+ return;
3450
+ connected = true;
3451
+ try {
3452
+ attempt.write(`${JSON.stringify(signal)}
3453
+ `, done);
3454
+ } catch {
3455
+ done();
3456
+ }
3457
+ });
3458
+ };
3459
+ tryFrom(0);
3425
3460
  });
3426
3461
  }
3427
3462
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "publishConfig": { "access": "public" },
3
3
  "name": "@ascenda-one/history-import",
4
- "version": "0.1.26",
4
+ "version": "0.1.27",
5
5
  "description": "Retrospective AI-usage import for Ascenda work telemetry — extracts the baseline already sitting in Claude Code, Codex, Cursor and VS Code stores.",
6
6
  "repository": {
7
7
  "type": "git",