@sideboard-ai/core 0.1.284 → 0.1.285

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 (42) hide show
  1. package/dist/{abletime-WLDBJJUI.js → abletime-4CH2IOX5.js} +4 -4
  2. package/dist/{abletime-X64E3GUJ.js → abletime-I4RODUKT.js} +4 -4
  3. package/dist/{abletime-oauth-AXR676W5.js → abletime-oauth-7OZZ3ABX.js} +3 -3
  4. package/dist/{abletime-oauth-UWOCEICP.js → abletime-oauth-C2HN2Q6F.js} +3 -3
  5. package/dist/{abletime-rest-S4XWEXV2.js → abletime-rest-E4LBRFLM.js} +3 -3
  6. package/dist/{abletime-rest-LPUDJUEP.js → abletime-rest-WFI2HWBU.js} +3 -3
  7. package/dist/agents/cursor-runner.cjs +48 -11
  8. package/dist/agents/cursor-runner.js +48 -11
  9. package/dist/{agents-PM5ICSO3.js → agents-FKMYAKFD.js} +4 -4
  10. package/dist/{agents-6U2RQK7P.js → agents-ITNCZ6CA.js} +4 -4
  11. package/dist/chunk-2GPQZZLY.js +59 -0
  12. package/dist/{chunk-OEJQK7CY.js → chunk-2K723QZH.js} +3 -3
  13. package/dist/{chunk-ROPGQRPU.js → chunk-33KDPEK4.js} +1 -1
  14. package/dist/{chunk-I6HSGKMZ.js → chunk-5T4YWFLD.js} +2 -2
  15. package/dist/{chunk-U7HAVAGJ.js → chunk-6CVVNAIU.js} +2 -2
  16. package/dist/{chunk-TQRSVE7D.js → chunk-7IAMHN2N.js} +1 -1
  17. package/dist/{chunk-WQ4M2L44.js → chunk-C6NVTLZK.js} +5 -5
  18. package/dist/{chunk-VA55JG2I.js → chunk-DEJALWKM.js} +5 -5
  19. package/dist/{chunk-XTPQEZZA.js → chunk-IJMUYHPT.js} +3 -3
  20. package/dist/chunk-JAT3JFOS.js +61 -0
  21. package/dist/{chunk-DGPROCE5.js → chunk-LS4FFCPL.js} +3 -3
  22. package/dist/{chunk-P2BSMNHB.js → chunk-PXMLMBMI.js} +1 -1
  23. package/dist/{chunk-BS3QLVPL.js → chunk-TMM4FEZ5.js} +3 -3
  24. package/dist/{chunk-BSN6DJ4L.js → chunk-TXHZJESB.js} +3 -3
  25. package/dist/{chunk-GWFVCCJZ.js → chunk-VGNLMGBK.js} +6 -6
  26. package/dist/{chunk-PY4UCMRI.js → chunk-VQEARG5H.js} +5 -5
  27. package/dist/{chunk-COQLZNKQ.js → chunk-XSPOJFTV.js} +3 -3
  28. package/dist/{connected-teams-JIUOSZ6C.js → connected-teams-AB7ZHJVO.js} +3 -3
  29. package/dist/{connected-teams-RU6VATCM.js → connected-teams-BJ6PMIST.js} +3 -3
  30. package/dist/index.cjs +209 -112
  31. package/dist/index.d.cts +9 -2
  32. package/dist/index.d.ts +9 -2
  33. package/dist/index.js +171 -96
  34. package/dist/mcp/run-stdio.cjs +36 -17
  35. package/dist/mcp/run-stdio.js +8 -8
  36. package/dist/{oauth-S3M7B475.js → oauth-DP4ZV2M2.js} +2 -2
  37. package/dist/{oauth-K6CWZEQO.js → oauth-WCUZ6Z5G.js} +2 -2
  38. package/dist/{orchestrator-6YVY6T5I.js → orchestrator-F7KXYDQW.js} +5 -5
  39. package/dist/{orchestrator-CRBIW2RG.js → orchestrator-VUIRO6NC.js} +5 -5
  40. package/package.json +1 -1
  41. package/dist/chunk-N7WZ6NIN.js +0 -41
  42. package/dist/chunk-VKQGAWHY.js +0 -40
@@ -18,10 +18,10 @@ import {
18
18
  toAbleTimeIssueInfo,
19
19
  updateAbleTimeTask,
20
20
  verifyAbleTimeConnection
21
- } from "./chunk-BS3QLVPL.js";
22
- import "./chunk-I6HSGKMZ.js";
23
- import "./chunk-PY4UCMRI.js";
24
- import "./chunk-VKQGAWHY.js";
21
+ } from "./chunk-TMM4FEZ5.js";
22
+ import "./chunk-5T4YWFLD.js";
23
+ import "./chunk-VQEARG5H.js";
24
+ import "./chunk-2GPQZZLY.js";
25
25
  import "./chunk-N2WW62LF.js";
26
26
  import "./chunk-WRIMAEF2.js";
27
27
  import "./chunk-NSTQ6QKD.js";
@@ -16,10 +16,10 @@ import {
16
16
  toAbleTimeIssueInfo,
17
17
  updateAbleTimeTask,
18
18
  verifyAbleTimeConnection
19
- } from "./chunk-DGPROCE5.js";
20
- import "./chunk-U7HAVAGJ.js";
21
- import "./chunk-VA55JG2I.js";
22
- import "./chunk-N7WZ6NIN.js";
19
+ } from "./chunk-LS4FFCPL.js";
20
+ import "./chunk-6CVVNAIU.js";
21
+ import "./chunk-DEJALWKM.js";
22
+ import "./chunk-JAT3JFOS.js";
23
23
  import "./chunk-6K64FJDD.js";
24
24
  import "./chunk-YNTXWFXT.js";
25
25
  import "./chunk-77WWLBCI.js";
@@ -3,10 +3,10 @@
3
3
  import {
4
4
  DEFAULT_ABLETIME_HOST,
5
5
  normalizeAbleTimeHost
6
- } from "./chunk-PY4UCMRI.js";
6
+ } from "./chunk-VQEARG5H.js";
7
7
  import {
8
8
  httpFetch
9
- } from "./chunk-VKQGAWHY.js";
9
+ } from "./chunk-2GPQZZLY.js";
10
10
  import {
11
11
  disconnectAbleTimeConnection,
12
12
  getAbleTimeHost,
@@ -288,7 +288,7 @@ async function startAbleTimeOAuth(opts) {
288
288
  persistAbleTimeTokens(data, { host });
289
289
  const token = data.access_token.trim();
290
290
  try {
291
- const { getAbleTimeOrientation } = await import("./abletime-WLDBJJUI.js");
291
+ const { getAbleTimeOrientation } = await import("./abletime-4CH2IOX5.js");
292
292
  const orientation = await getAbleTimeOrientation({ token, host });
293
293
  return saveAbleTimeConnection({
294
294
  accessToken: token,
@@ -20,9 +20,9 @@ import {
20
20
  parseAbleTimeOAuthCallbackUrl,
21
21
  resolveAbleTimeOAuthHost,
22
22
  startAbleTimeOAuth
23
- } from "./chunk-XTPQEZZA.js";
24
- import "./chunk-VA55JG2I.js";
25
- import "./chunk-N7WZ6NIN.js";
23
+ } from "./chunk-IJMUYHPT.js";
24
+ import "./chunk-DEJALWKM.js";
25
+ import "./chunk-JAT3JFOS.js";
26
26
  import "./chunk-YNTXWFXT.js";
27
27
  import "./chunk-77WWLBCI.js";
28
28
  import "./chunk-4TR3HZFT.js";
@@ -5,9 +5,9 @@ import {
5
5
  callAbleTimeRestTool,
6
6
  looksLikeAbleTimeUlid,
7
7
  textFromAbleTimeDoc
8
- } from "./chunk-U7HAVAGJ.js";
9
- import "./chunk-VA55JG2I.js";
10
- import "./chunk-N7WZ6NIN.js";
8
+ } from "./chunk-6CVVNAIU.js";
9
+ import "./chunk-DEJALWKM.js";
10
+ import "./chunk-JAT3JFOS.js";
11
11
  import "./chunk-YNTXWFXT.js";
12
12
  import "./chunk-77WWLBCI.js";
13
13
  import "./chunk-4TR3HZFT.js";
@@ -7,9 +7,9 @@ import {
7
7
  callAbleTimeRestTool,
8
8
  looksLikeAbleTimeUlid,
9
9
  textFromAbleTimeDoc
10
- } from "./chunk-I6HSGKMZ.js";
11
- import "./chunk-PY4UCMRI.js";
12
- import "./chunk-VKQGAWHY.js";
10
+ } from "./chunk-5T4YWFLD.js";
11
+ import "./chunk-VQEARG5H.js";
12
+ import "./chunk-2GPQZZLY.js";
13
13
  import "./chunk-WRIMAEF2.js";
14
14
  import "./chunk-NSTQ6QKD.js";
15
15
  import "./chunk-WWUABK6B.js";
@@ -490,8 +490,10 @@ function cursorErrorMessage(err) {
490
490
  function isAgentBusyError(err) {
491
491
  const name = err instanceof Error ? err.name : "";
492
492
  if (name === "AgentBusyError") return true;
493
- return /already has active run/i.test(cursorErrorMessage(err));
493
+ const message = cursorErrorMessage(err);
494
+ return /already has active run/i.test(message) || /agent still running/i.test(message) || /\[agent_busy\]/i.test(message);
494
495
  }
496
+ var CURSOR_BUSY_RETRY_DELAY_MS = 400;
495
497
  function isUnresumableCursorSession(err) {
496
498
  const name = err instanceof Error ? err.name : "";
497
499
  if (name === "AgentNotFoundError") return true;
@@ -1508,14 +1510,14 @@ function localAgentStore(Store, threadId) {
1508
1510
  (0, import_node_fs17.mkdirSync)(root, { recursive: true });
1509
1511
  return new Store(root);
1510
1512
  }
1511
- async function cancelStaleLocalRuns(Agent, agentId, opts) {
1513
+ async function cancelStaleRuns(Agent, agentId, opts) {
1514
+ let cancelled = 0;
1512
1515
  const listed = await Agent.listRuns(agentId, {
1513
1516
  runtime: "local",
1514
1517
  cwd: opts.cwd,
1515
1518
  store: opts.store,
1516
1519
  limit: 20
1517
1520
  });
1518
- let cancelled = 0;
1519
1521
  for (const run2 of listed.items) {
1520
1522
  if (run2.status !== "running") continue;
1521
1523
  try {
@@ -1528,6 +1530,27 @@ async function cancelStaleLocalRuns(Agent, agentId, opts) {
1528
1530
  } catch {
1529
1531
  }
1530
1532
  }
1533
+ if (cancelled > 0 || !opts.apiKey) return cancelled;
1534
+ try {
1535
+ const cloud = await Agent.listRuns(agentId, {
1536
+ runtime: "cloud",
1537
+ apiKey: opts.apiKey,
1538
+ limit: 20
1539
+ });
1540
+ for (const run2 of cloud.items) {
1541
+ if (run2.status !== "running") continue;
1542
+ try {
1543
+ await Agent.cancelRun(run2.id, {
1544
+ runtime: "cloud",
1545
+ agentId,
1546
+ apiKey: opts.apiKey
1547
+ });
1548
+ cancelled += 1;
1549
+ } catch {
1550
+ }
1551
+ }
1552
+ } catch {
1553
+ }
1531
1554
  return cancelled;
1532
1555
  }
1533
1556
  async function readStdinJson() {
@@ -1643,6 +1666,20 @@ async function main() {
1643
1666
  return createAgent();
1644
1667
  }
1645
1668
  }
1669
+ async function retryAfterBusy(agent) {
1670
+ const n = await cancelStaleRuns(Agent, agent.agentId, {
1671
+ cwd: req.cwd,
1672
+ store,
1673
+ ...apiKey ? { apiKey } : {}
1674
+ });
1675
+ emit({
1676
+ type: "stderr",
1677
+ data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
1678
+ });
1679
+ if (CURSOR_BUSY_RETRY_DELAY_MS > 0) {
1680
+ await new Promise((resolve2) => setTimeout(resolve2, CURSOR_BUSY_RETRY_DELAY_MS));
1681
+ }
1682
+ }
1646
1683
  async function sendPrompt(agent, extra) {
1647
1684
  const sendOpts = {
1648
1685
  ...cursorSendOptions(mcpServers),
@@ -1652,14 +1689,7 @@ async function main() {
1652
1689
  return await retryTransport(() => agent.send(req.prompt, sendOpts));
1653
1690
  } catch (err) {
1654
1691
  if (!isAgentBusyError(err)) throw err;
1655
- const n = await cancelStaleLocalRuns(Agent, agent.agentId, {
1656
- cwd: req.cwd,
1657
- store
1658
- });
1659
- emit({
1660
- type: "stderr",
1661
- data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
1662
- });
1692
+ await retryAfterBusy(agent);
1663
1693
  return retryTransport(() => agent.send(req.prompt, sendOpts));
1664
1694
  }
1665
1695
  }
@@ -1742,6 +1772,9 @@ async function main() {
1742
1772
  ]) : await run2.wait();
1743
1773
  if (result.status === "error") {
1744
1774
  const detail = formatUnknownDetail(result.error);
1775
+ if (isAgentBusyError(detail)) {
1776
+ throw Object.assign(new Error(detail || "agent still running"), { name: "AgentBusyError" });
1777
+ }
1745
1778
  emit({
1746
1779
  type: "stderr",
1747
1780
  data: detail ? `Cursor run failed (${result.id}): ${detail}` : `Cursor run failed (${result.id})`
@@ -1772,6 +1805,10 @@ async function main() {
1772
1805
  try {
1773
1806
  return await runTurn(agent);
1774
1807
  } catch (err) {
1808
+ if (isAgentBusyError(err)) {
1809
+ await retryAfterBusy(agent);
1810
+ return await runTurn(agent);
1811
+ }
1775
1812
  if (!isUnresumableCursorSession(err)) throw err;
1776
1813
  emit({
1777
1814
  type: "stderr",
@@ -46,8 +46,10 @@ function cursorErrorMessage(err) {
46
46
  function isAgentBusyError(err) {
47
47
  const name = err instanceof Error ? err.name : "";
48
48
  if (name === "AgentBusyError") return true;
49
- return /already has active run/i.test(cursorErrorMessage(err));
49
+ const message = cursorErrorMessage(err);
50
+ return /already has active run/i.test(message) || /agent still running/i.test(message) || /\[agent_busy\]/i.test(message);
50
51
  }
52
+ var CURSOR_BUSY_RETRY_DELAY_MS = 400;
51
53
  function isUnresumableCursorSession(err) {
52
54
  const name = err instanceof Error ? err.name : "";
53
55
  if (name === "AgentNotFoundError") return true;
@@ -307,14 +309,14 @@ function localAgentStore(Store, threadId) {
307
309
  mkdirSync(root, { recursive: true });
308
310
  return new Store(root);
309
311
  }
310
- async function cancelStaleLocalRuns(Agent, agentId, opts) {
312
+ async function cancelStaleRuns(Agent, agentId, opts) {
313
+ let cancelled = 0;
311
314
  const listed = await Agent.listRuns(agentId, {
312
315
  runtime: "local",
313
316
  cwd: opts.cwd,
314
317
  store: opts.store,
315
318
  limit: 20
316
319
  });
317
- let cancelled = 0;
318
320
  for (const run of listed.items) {
319
321
  if (run.status !== "running") continue;
320
322
  try {
@@ -327,6 +329,27 @@ async function cancelStaleLocalRuns(Agent, agentId, opts) {
327
329
  } catch {
328
330
  }
329
331
  }
332
+ if (cancelled > 0 || !opts.apiKey) return cancelled;
333
+ try {
334
+ const cloud = await Agent.listRuns(agentId, {
335
+ runtime: "cloud",
336
+ apiKey: opts.apiKey,
337
+ limit: 20
338
+ });
339
+ for (const run of cloud.items) {
340
+ if (run.status !== "running") continue;
341
+ try {
342
+ await Agent.cancelRun(run.id, {
343
+ runtime: "cloud",
344
+ agentId,
345
+ apiKey: opts.apiKey
346
+ });
347
+ cancelled += 1;
348
+ } catch {
349
+ }
350
+ }
351
+ } catch {
352
+ }
330
353
  return cancelled;
331
354
  }
332
355
  async function readStdinJson() {
@@ -442,6 +465,20 @@ async function main() {
442
465
  return createAgent();
443
466
  }
444
467
  }
468
+ async function retryAfterBusy(agent) {
469
+ const n = await cancelStaleRuns(Agent, agent.agentId, {
470
+ cwd: req.cwd,
471
+ store,
472
+ ...apiKey ? { apiKey } : {}
473
+ });
474
+ emit({
475
+ type: "stderr",
476
+ data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
477
+ });
478
+ if (CURSOR_BUSY_RETRY_DELAY_MS > 0) {
479
+ await new Promise((resolve2) => setTimeout(resolve2, CURSOR_BUSY_RETRY_DELAY_MS));
480
+ }
481
+ }
445
482
  async function sendPrompt(agent, extra) {
446
483
  const sendOpts = {
447
484
  ...cursorSendOptions(mcpServers),
@@ -451,14 +488,7 @@ async function main() {
451
488
  return await retryTransport(() => agent.send(req.prompt, sendOpts));
452
489
  } catch (err) {
453
490
  if (!isAgentBusyError(err)) throw err;
454
- const n = await cancelStaleLocalRuns(Agent, agent.agentId, {
455
- cwd: req.cwd,
456
- store
457
- });
458
- emit({
459
- type: "stderr",
460
- data: n > 0 ? `Cursor agent had ${n} stale active run(s) \u2014 cancelled and retrying` : "Cursor agent busy \u2014 retrying send"
461
- });
491
+ await retryAfterBusy(agent);
462
492
  return retryTransport(() => agent.send(req.prompt, sendOpts));
463
493
  }
464
494
  }
@@ -541,6 +571,9 @@ async function main() {
541
571
  ]) : await run.wait();
542
572
  if (result.status === "error") {
543
573
  const detail = formatUnknownDetail(result.error);
574
+ if (isAgentBusyError(detail)) {
575
+ throw Object.assign(new Error(detail || "agent still running"), { name: "AgentBusyError" });
576
+ }
544
577
  emit({
545
578
  type: "stderr",
546
579
  data: detail ? `Cursor run failed (${result.id}): ${detail}` : `Cursor run failed (${result.id})`
@@ -571,6 +604,10 @@ async function main() {
571
604
  try {
572
605
  return await runTurn(agent);
573
606
  } catch (err) {
607
+ if (isAgentBusyError(err)) {
608
+ await retryAfterBusy(agent);
609
+ return await runTurn(agent);
610
+ }
574
611
  if (!isUnresumableCursorSession(err)) throw err;
575
612
  emit({
576
613
  type: "stderr",
@@ -56,10 +56,10 @@ import {
56
56
  resolveQuotaFallbackAgent,
57
57
  turnCostUsdFromCursorUsage,
58
58
  whichOnPath
59
- } from "./chunk-BSN6DJ4L.js";
60
- import "./chunk-TQRSVE7D.js";
61
- import "./chunk-P2BSMNHB.js";
62
- import "./chunk-VKQGAWHY.js";
59
+ } from "./chunk-TXHZJESB.js";
60
+ import "./chunk-7IAMHN2N.js";
61
+ import "./chunk-PXMLMBMI.js";
62
+ import "./chunk-2GPQZZLY.js";
63
63
  import "./chunk-5QOLFOAX.js";
64
64
  import "./chunk-2SJXQ4UX.js";
65
65
  import "./chunk-5MGLNVNK.js";
@@ -47,15 +47,15 @@ import {
47
47
  resolveLoginCommand,
48
48
  resolveQuotaFallbackAgent,
49
49
  whichOnPath
50
- } from "./chunk-COQLZNKQ.js";
51
- import "./chunk-GWFVCCJZ.js";
50
+ } from "./chunk-XSPOJFTV.js";
51
+ import "./chunk-VGNLMGBK.js";
52
52
  import "./chunk-XSDCLM3F.js";
53
53
  import "./chunk-WY2IAB7J.js";
54
54
  import "./chunk-K5XSTHHP.js";
55
55
  import "./chunk-N5UGX3JL.js";
56
56
  import "./chunk-2P4XKWV2.js";
57
- import "./chunk-ROPGQRPU.js";
58
- import "./chunk-N7WZ6NIN.js";
57
+ import "./chunk-33KDPEK4.js";
58
+ import "./chunk-JAT3JFOS.js";
59
59
  import {
60
60
  CURSOR_SDK_INSTALL_HINT,
61
61
  cursorSdkMessageToEvents,
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+
3
+
4
+ // src/http/fetch.ts
5
+ var injected = null;
6
+ var TLS_ISSUER_RE = /UNABLE_TO_GET_ISSUER_CERT|UNABLE_TO_VERIFY_LEAF_SIGNATURE|SELF_SIGNED_CERT_IN_CHAIN/i;
7
+ var TLS_ISSUER_HINT = " \u2014 Node rejected the TLS certificate (corporate VPN/proxy CA). Desktop Linear can still work; reconnecting the API key will not fix this.";
8
+ function isTlsIssuerFailure(code, message) {
9
+ return TLS_ISSUER_RE.test(`${code ?? ""} ${message}`);
10
+ }
11
+ function describeCause(cause, depth = 0) {
12
+ if (depth > 5 || cause == null) return null;
13
+ if (cause instanceof AggregateError) {
14
+ for (const item of cause.errors) {
15
+ const found = describeCause(item, depth + 1);
16
+ if (found && (found.code || found.message)) return found;
17
+ }
18
+ return cause.message ? { message: cause.message } : null;
19
+ }
20
+ if (cause instanceof Error) {
21
+ const code = typeof cause.code === "string" ? cause.code : void 0;
22
+ const nested = describeCause(cause.cause, depth + 1);
23
+ if ((!cause.message || cause.message === "fetch failed") && nested) return nested;
24
+ if (cause.message || code) return { code, message: cause.message };
25
+ return nested;
26
+ }
27
+ return { message: String(cause) };
28
+ }
29
+ function causeSuffix(detail) {
30
+ if (!detail) return "";
31
+ if (detail.code && detail.message) return ` [${detail.code}: ${detail.message}]`;
32
+ if (detail.code) return ` [${detail.code}]`;
33
+ if (detail.message) return ` [${detail.message}]`;
34
+ return "";
35
+ }
36
+ function formatFetchError(err, url, opts) {
37
+ if (!(err instanceof Error)) return `${String(err)} (${url})`;
38
+ const detail = describeCause(err.cause);
39
+ const hintSource = `${err.message} ${detail?.code ?? ""} ${detail?.message ?? ""}`;
40
+ const tls = isTlsIssuerFailure(detail?.code, hintSource);
41
+ const hint = tls ? opts?.tlsHint ?? TLS_ISSUER_HINT : "";
42
+ return `${err.message}${causeSuffix(detail)} (${url})${hint}`;
43
+ }
44
+ function currentHttpFetch() {
45
+ return injected ?? globalThis.fetch.bind(globalThis);
46
+ }
47
+ async function httpFetch(input, init) {
48
+ const url = typeof input === "string" ? input : input.href;
49
+ try {
50
+ return await currentHttpFetch()(url, init);
51
+ } catch (err) {
52
+ throw new Error(formatFetchError(err, url));
53
+ }
54
+ }
55
+
56
+ export {
57
+ formatFetchError,
58
+ httpFetch
59
+ };
@@ -23,7 +23,7 @@ import {
23
23
  parseSessionQuotaResetAt,
24
24
  planModeTurnInstruction,
25
25
  resolveQuotaFallbackAgent
26
- } from "./chunk-BSN6DJ4L.js";
26
+ } from "./chunk-TXHZJESB.js";
27
27
  import {
28
28
  REVIEW_TAB_TITLE,
29
29
  applyWorktreePkgCacheEnv,
@@ -2507,7 +2507,7 @@ async function createThread(input, _onSetupLine) {
2507
2507
  let sourceIsFork = false;
2508
2508
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
2509
2509
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
2510
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-WLDBJJUI.js");
2510
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-4CH2IOX5.js");
2511
2511
  const task = await ensureAbleTimeTask({
2512
2512
  title: title?.trim() || "Untitled work",
2513
2513
  description: input.prompt?.trim() || void 0
@@ -6094,7 +6094,7 @@ function formatScheduledPrompt(name, prompt) {
6094
6094
  ${prompt}`;
6095
6095
  }
6096
6096
  async function defaultDeps() {
6097
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-CRBIW2RG.js");
6097
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-VUIRO6NC.js");
6098
6098
  const orch = getOrchestrator2();
6099
6099
  return {
6100
6100
  findThread: (id) => findThreadByRef(id),
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  formatFetchError
3
- } from "./chunk-N7WZ6NIN.js";
3
+ } from "./chunk-JAT3JFOS.js";
4
4
 
5
5
  // src/brightsy/config.ts
6
6
  import { existsSync, readFileSync, writeFileSync } from "fs";
@@ -6,10 +6,10 @@ import {
6
6
  normalizeAbleTimeCredential,
7
7
  normalizeAbleTimeHost,
8
8
  rewriteAbleTimeError
9
- } from "./chunk-PY4UCMRI.js";
9
+ } from "./chunk-VQEARG5H.js";
10
10
  import {
11
11
  httpFetch
12
- } from "./chunk-VKQGAWHY.js";
12
+ } from "./chunk-2GPQZZLY.js";
13
13
  import {
14
14
  getAbleTimeAccessToken,
15
15
  getAbleTimeHost
@@ -4,10 +4,10 @@ import {
4
4
  normalizeAbleTimeCredential,
5
5
  normalizeAbleTimeHost,
6
6
  rewriteAbleTimeError
7
- } from "./chunk-VA55JG2I.js";
7
+ } from "./chunk-DEJALWKM.js";
8
8
  import {
9
9
  httpFetch
10
- } from "./chunk-N7WZ6NIN.js";
10
+ } from "./chunk-JAT3JFOS.js";
11
11
  import {
12
12
  getAbleTimeAccessToken,
13
13
  getAbleTimeHost
@@ -7,7 +7,7 @@ import {
7
7
  loadBrightsyConfig,
8
8
  refreshBrightsyAccessToken,
9
9
  saveBrightsyConfig
10
- } from "./chunk-P2BSMNHB.js";
10
+ } from "./chunk-PXMLMBMI.js";
11
11
  import {
12
12
  run
13
13
  } from "./chunk-2UG25RMK.js";
@@ -8,7 +8,7 @@ import {
8
8
  parseSessionQuotaResetAt,
9
9
  planModeTurnInstruction,
10
10
  resolveQuotaFallbackAgent
11
- } from "./chunk-COQLZNKQ.js";
11
+ } from "./chunk-XSPOJFTV.js";
12
12
  import {
13
13
  REVIEW_TAB_TITLE,
14
14
  applyWorktreePkgCacheEnv,
@@ -164,7 +164,7 @@ import {
164
164
  } from "./chunk-N5UGX3JL.js";
165
165
  import {
166
166
  httpFetch
167
- } from "./chunk-N7WZ6NIN.js";
167
+ } from "./chunk-JAT3JFOS.js";
168
168
  import {
169
169
  createAgentStreamCoalescer
170
170
  } from "./chunk-AXQ4ZWHK.js";
@@ -2628,7 +2628,7 @@ async function createThread(input, _onSetupLine) {
2628
2628
  let sourceIsFork = false;
2629
2629
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
2630
2630
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
2631
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-X64E3GUJ.js");
2631
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-I4RODUKT.js");
2632
2632
  const task = await ensureAbleTimeTask({
2633
2633
  title: title?.trim() || "Untitled work",
2634
2634
  description: input.prompt?.trim() || void 0
@@ -2739,7 +2739,7 @@ async function createThread(input, _onSetupLine) {
2739
2739
  return readThread(thread.id) ?? thread;
2740
2740
  }
2741
2741
  async function listLinearIssues(agent, repoPath) {
2742
- const { getAdapter: getAdapter2 } = await import("./agents-6U2RQK7P.js");
2742
+ const { getAdapter: getAdapter2 } = await import("./agents-ITNCZ6CA.js");
2743
2743
  await requireAgent(agent, { requireLinear: true });
2744
2744
  const adapter = getAdapter2(agent);
2745
2745
  if (!adapter.listLinearIssues) {
@@ -6436,7 +6436,7 @@ function formatScheduledPrompt(name, prompt) {
6436
6436
  ${prompt}`;
6437
6437
  }
6438
6438
  async function defaultDeps() {
6439
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-6YVY6T5I.js");
6439
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-F7KXYDQW.js");
6440
6440
  const orch = getOrchestrator2();
6441
6441
  return {
6442
6442
  findThread: (id) => findThreadByRef(id),
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  httpFetch
3
- } from "./chunk-N7WZ6NIN.js";
3
+ } from "./chunk-JAT3JFOS.js";
4
4
  import {
5
5
  getAbleTimeHost,
6
6
  isAbleTimeConnected
@@ -153,7 +153,7 @@ function textsFromUnknown(value) {
153
153
  return "";
154
154
  }
155
155
  async function abletimeMcpRequest(method, params, opts) {
156
- const rawToken = opts?.token ?? await import("./abletime-oauth-UWOCEICP.js").then((m) => m.ensureAbleTimeAccessToken());
156
+ const rawToken = opts?.token ?? await import("./abletime-oauth-C2HN2Q6F.js").then((m) => m.ensureAbleTimeAccessToken());
157
157
  if (!rawToken?.trim()) {
158
158
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
159
159
  }
@@ -224,9 +224,9 @@ async function callAbleTimeTool(name, args = {}, opts) {
224
224
  if (!opts?.token && !isAbleTimeConnected()) {
225
225
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
226
226
  }
227
- const rawToken = opts?.token ?? await import("./abletime-oauth-UWOCEICP.js").then((m) => m.ensureAbleTimeAccessToken());
227
+ const rawToken = opts?.token ?? await import("./abletime-oauth-C2HN2Q6F.js").then((m) => m.ensureAbleTimeAccessToken());
228
228
  if (rawToken && ableTimeUsesRest(rawToken)) {
229
- const { callAbleTimeRestTool } = await import("./abletime-rest-S4XWEXV2.js");
229
+ const { callAbleTimeRestTool } = await import("./abletime-rest-E4LBRFLM.js");
230
230
  return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
231
231
  }
232
232
  const requestOpts = { ...opts, pm: opts?.pm ?? abletimeToolUsesPm(name) };
@@ -242,7 +242,7 @@ async function callAbleTimeTool(name, args = {}, opts) {
242
242
  return await call();
243
243
  }
244
244
  if (rawToken && ableTimeUsesRest(rawToken) && isAbleTimeRejectedCredential(message)) {
245
- const { callAbleTimeRestTool } = await import("./abletime-rest-S4XWEXV2.js");
245
+ const { callAbleTimeRestTool } = await import("./abletime-rest-E4LBRFLM.js");
246
246
  return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
247
247
  }
248
248
  throw err instanceof Error ? new Error(rewriteAbleTimeError(err.message)) : err;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  DEFAULT_ABLETIME_HOST,
3
3
  normalizeAbleTimeHost
4
- } from "./chunk-VA55JG2I.js";
4
+ } from "./chunk-DEJALWKM.js";
5
5
  import {
6
6
  httpFetch
7
- } from "./chunk-N7WZ6NIN.js";
7
+ } from "./chunk-JAT3JFOS.js";
8
8
  import {
9
9
  disconnectAbleTimeConnection,
10
10
  getAbleTimeHost,
@@ -280,7 +280,7 @@ async function startAbleTimeOAuth(opts) {
280
280
  persistAbleTimeTokens(data, { host });
281
281
  const token = data.access_token.trim();
282
282
  try {
283
- const { getAbleTimeOrientation } = await import("./abletime-X64E3GUJ.js");
283
+ const { getAbleTimeOrientation } = await import("./abletime-I4RODUKT.js");
284
284
  const orientation = await getAbleTimeOrientation({ token, host });
285
285
  return saveAbleTimeConnection({
286
286
  accessToken: token,
@@ -0,0 +1,61 @@
1
+ // src/http/fetch.ts
2
+ var injected = null;
3
+ function setHttpFetchImpl(fetchImpl) {
4
+ injected = fetchImpl;
5
+ }
6
+ var TLS_ISSUER_RE = /UNABLE_TO_GET_ISSUER_CERT|UNABLE_TO_VERIFY_LEAF_SIGNATURE|SELF_SIGNED_CERT_IN_CHAIN/i;
7
+ var TLS_ISSUER_HINT = " \u2014 Node rejected the TLS certificate (corporate VPN/proxy CA). Desktop Linear can still work; reconnecting the API key will not fix this.";
8
+ function isTlsIssuerFailure(code, message) {
9
+ return TLS_ISSUER_RE.test(`${code ?? ""} ${message}`);
10
+ }
11
+ function describeCause(cause, depth = 0) {
12
+ if (depth > 5 || cause == null) return null;
13
+ if (cause instanceof AggregateError) {
14
+ for (const item of cause.errors) {
15
+ const found = describeCause(item, depth + 1);
16
+ if (found && (found.code || found.message)) return found;
17
+ }
18
+ return cause.message ? { message: cause.message } : null;
19
+ }
20
+ if (cause instanceof Error) {
21
+ const code = typeof cause.code === "string" ? cause.code : void 0;
22
+ const nested = describeCause(cause.cause, depth + 1);
23
+ if ((!cause.message || cause.message === "fetch failed") && nested) return nested;
24
+ if (cause.message || code) return { code, message: cause.message };
25
+ return nested;
26
+ }
27
+ return { message: String(cause) };
28
+ }
29
+ function causeSuffix(detail) {
30
+ if (!detail) return "";
31
+ if (detail.code && detail.message) return ` [${detail.code}: ${detail.message}]`;
32
+ if (detail.code) return ` [${detail.code}]`;
33
+ if (detail.message) return ` [${detail.message}]`;
34
+ return "";
35
+ }
36
+ function formatFetchError(err, url, opts) {
37
+ if (!(err instanceof Error)) return `${String(err)} (${url})`;
38
+ const detail = describeCause(err.cause);
39
+ const hintSource = `${err.message} ${detail?.code ?? ""} ${detail?.message ?? ""}`;
40
+ const tls = isTlsIssuerFailure(detail?.code, hintSource);
41
+ const hint = tls ? opts?.tlsHint ?? TLS_ISSUER_HINT : "";
42
+ return `${err.message}${causeSuffix(detail)} (${url})${hint}`;
43
+ }
44
+ function currentHttpFetch() {
45
+ return injected ?? globalThis.fetch.bind(globalThis);
46
+ }
47
+ async function httpFetch(input, init) {
48
+ const url = typeof input === "string" ? input : input.href;
49
+ try {
50
+ return await currentHttpFetch()(url, init);
51
+ } catch (err) {
52
+ throw new Error(formatFetchError(err, url));
53
+ }
54
+ }
55
+
56
+ export {
57
+ setHttpFetchImpl,
58
+ formatFetchError,
59
+ currentHttpFetch,
60
+ httpFetch
61
+ };