@sideboard-ai/core 0.1.203 → 0.1.204

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-JFGZBDHH.js → abletime-S3UHQZVW.js} +3 -3
  2. package/dist/{abletime-SISJEPJ3.js → abletime-TONBQP4O.js} +3 -3
  3. package/dist/{abletime-oauth-7TD5Z2QV.js → abletime-oauth-AVCEO2DY.js} +54 -5
  4. package/dist/{abletime-oauth-OSQYFB3E.js → abletime-oauth-SD4SZY5U.js} +14 -2
  5. package/dist/{abletime-rest-QPJTDLKX.js → abletime-rest-6ODSXV7G.js} +2 -2
  6. package/dist/{abletime-rest-ZJGWYALM.js → abletime-rest-J2OBB4VA.js} +2 -2
  7. package/dist/agents/cursor-runner.js +1 -1
  8. package/dist/{agents-ZMWL43SP.js → agents-67K4BQFJ.js} +3 -3
  9. package/dist/{agents-3755WYQM.js → agents-BVOJNHV6.js} +4 -4
  10. package/dist/{chunk-6VEIKW5C.js → chunk-3K257PCS.js} +6 -3
  11. package/dist/{chunk-LCU6GBZP.js → chunk-5SMS6QTO.js} +1 -1
  12. package/dist/{chunk-MHPINQKY.js → chunk-6Q7DFVDQ.js} +54 -5
  13. package/dist/{chunk-3PYH2RLA.js → chunk-CYLDJWRK.js} +6 -3
  14. package/dist/{chunk-FZ6IBUKY.js → chunk-FO2NTJ7L.js} +3 -3
  15. package/dist/{chunk-2DVCCLII.js → chunk-FO45DMJ5.js} +60 -60
  16. package/dist/{chunk-CQ5R3VPP.js → chunk-KZ7PI7FE.js} +18 -0
  17. package/dist/{chunk-FZYYEMET.js → chunk-QAVWH2RQ.js} +3 -3
  18. package/dist/{chunk-QSEF2YVQ.js → chunk-QUW5D62C.js} +33 -19
  19. package/dist/{chunk-PJHFNFXA.js → chunk-SGUVAK66.js} +27 -8
  20. package/dist/{chunk-TZNJKZ2A.js → chunk-ULZLWQBS.js} +58 -58
  21. package/dist/{chunk-TNDUTGDV.js → chunk-VIPA75ZA.js} +1 -1
  22. package/dist/{chunk-BFEBFGCS.js → chunk-W6VM36YO.js} +30 -8
  23. package/dist/{chunk-X2TFUFIS.js → chunk-WF33LOP4.js} +43 -5
  24. package/dist/{chunk-CMGRV36E.js → chunk-WVATAIF4.js} +33 -19
  25. package/dist/{chunk-5IXJTUST.js → chunk-YOSTWSNC.js} +26 -6
  26. package/dist/{coordinator-prompt-U4PEZDAW.js → coordinator-prompt-NPT555BO.js} +2 -2
  27. package/dist/{coordinator-prompt-2B2JA2IE.js → coordinator-prompt-WEPXXLLX.js} +2 -2
  28. package/dist/{global-workspace-JPJ3FKKY.js → global-workspace-2I2T7FL5.js} +2 -2
  29. package/dist/{global-workspace-PU7ZS3LS.js → global-workspace-NSILADOM.js} +2 -2
  30. package/dist/index.cjs +237 -83
  31. package/dist/index.d.cts +33 -11
  32. package/dist/index.d.ts +33 -11
  33. package/dist/index.js +39 -9
  34. package/dist/mcp/run-stdio.cjs +192 -78
  35. package/dist/mcp/run-stdio.js +7 -7
  36. package/dist/{orchestrator-3A6KUTNI.js → orchestrator-CMAVNELS.js} +5 -5
  37. package/dist/{orchestrator-Q33M24ZJ.js → orchestrator-I7GFXLHF.js} +4 -4
  38. package/dist/{workspaces-IMG7ZRUQ.js → workspaces-BOC6M7BW.js} +2 -2
  39. package/dist/{workspaces-U6P6DB44.js → workspaces-RFGZBUAR.js} +2 -2
  40. package/dist/{worktree-JSCDJPBU.js → worktree-G3ZLM4DC.js} +3 -1
  41. package/dist/{worktree-FL3UIUKQ.js → worktree-WSUQMMK4.js} +3 -1
  42. package/package.json +1 -1
@@ -43,7 +43,7 @@ import {
43
43
  summarizeTurnStderr,
44
44
  toolDescription,
45
45
  turnFailChatText
46
- } from "./chunk-X2TFUFIS.js";
46
+ } from "./chunk-WF33LOP4.js";
47
47
  import {
48
48
  SLACK_REPLY_FORMATTING,
49
49
  addWorkspace,
@@ -66,13 +66,14 @@ import {
66
66
  stageAbsolutePathsAsAttachments,
67
67
  stageBuffersAsAttachments,
68
68
  syncWorkspacesFromThreads
69
- } from "./chunk-LCU6GBZP.js";
69
+ } from "./chunk-5SMS6QTO.js";
70
70
  import {
71
71
  addPrStackLayer,
72
72
  allocateTeamName,
73
73
  allocateTeamSlug,
74
74
  canonicalizeRepoPath,
75
75
  commitAll,
76
+ connectedPrSelectors,
76
77
  createExistingBranchWorktree,
77
78
  createOrUpdatePr,
78
79
  createThreadWorktree,
@@ -107,7 +108,6 @@ import {
107
108
  resolveDiffBaseRef,
108
109
  resolveGithubRepoSlug,
109
110
  resolvePrSelector,
110
- resolvePrSelectors,
111
111
  resolveRepoRoot,
112
112
  takenSlugsFromThread,
113
113
  threadDisplayLabel,
@@ -116,7 +116,7 @@ import {
116
116
  worktreeDisplayLabelForGroup,
117
117
  worktreeNameFromPath,
118
118
  worktreeSlugForTicket
119
- } from "./chunk-QSEF2YVQ.js";
119
+ } from "./chunk-QUW5D62C.js";
120
120
  import {
121
121
  ATTACHMENTS_DIR,
122
122
  DETACHED_JOBS_DIR,
@@ -408,7 +408,7 @@ async function continueSourceThread(threadId, prompt) {
408
408
  await continueOnReply(threadId, prompt);
409
409
  return;
410
410
  }
411
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-Q33M24ZJ.js");
411
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-I7GFXLHF.js");
412
412
  await getOrchestrator2().send(threadId, prompt);
413
413
  } catch {
414
414
  }
@@ -801,9 +801,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
801
801
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
802
802
  );
803
803
  }
804
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-JPJ3FKKY.js");
804
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-2I2T7FL5.js");
805
805
  if (isGlobalThread2(thread)) {
806
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-U4PEZDAW.js");
806
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-NPT555BO.js");
807
807
  ensureGlobalCoordinatorCwd2(
808
808
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
809
809
  );
@@ -1011,6 +1011,33 @@ var FIX_CI_RE = /^Fix CI: .+\.$/;
1011
1011
  function normalizePrState(state) {
1012
1012
  return (state ?? "").trim().toUpperCase();
1013
1013
  }
1014
+ function sameLoginList(a, b) {
1015
+ const left = [...a ?? []].map((s) => s.trim().toLowerCase()).filter(Boolean).sort();
1016
+ const right = [...b ?? []].map((s) => s.trim().toLowerCase()).filter(Boolean).sort();
1017
+ return left.length === right.length && left.every((login, i) => login === right[i]);
1018
+ }
1019
+ function threadPrMetaPatch(thread, meta) {
1020
+ const prevState = normalizePrState(thread.prState);
1021
+ const nextState = normalizePrState(meta.state);
1022
+ const patch = {};
1023
+ if (meta.url && meta.url !== thread.prUrl) patch.prUrl = meta.url;
1024
+ if (meta.title && meta.title !== thread.prTitle) patch.prTitle = meta.title;
1025
+ if (nextState && nextState !== prevState) patch.prState = nextState;
1026
+ const nextDraft = Boolean(meta.isDraft) && nextState !== "MERGED" && nextState !== "CLOSED";
1027
+ if (nextDraft !== Boolean(thread.prIsDraft)) patch.prIsDraft = nextDraft;
1028
+ const nextAuthor = meta.authorLogin?.trim() || "";
1029
+ if (nextAuthor && nextAuthor !== (thread.prAuthorLogin ?? "").trim()) {
1030
+ patch.prAuthorLogin = nextAuthor;
1031
+ }
1032
+ const nextReviewers = meta.reviewerLogins ?? [];
1033
+ if (!sameLoginList(nextReviewers, thread.prReviewerLogins)) {
1034
+ patch.prReviewerLogins = nextReviewers;
1035
+ }
1036
+ if (thread.skipAutoArchiveOnMerge && nextState && nextState !== "MERGED" && nextState !== "CLOSED") {
1037
+ patch.skipAutoArchiveOnMerge = false;
1038
+ }
1039
+ return patch;
1040
+ }
1014
1041
  function shouldAutoArchiveOnPrMerge(opts) {
1015
1042
  if (!opts.autoArchiveEnabled) return false;
1016
1043
  if (opts.isGlobal) return false;
@@ -3660,7 +3687,7 @@ async function createThread(input, _onSetupLine) {
3660
3687
  let sourceIsFork = false;
3661
3688
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
3662
3689
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
3663
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-JFGZBDHH.js");
3690
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-S3UHQZVW.js");
3664
3691
  const task = await ensureAbleTimeTask({
3665
3692
  title: title?.trim() || "Untitled work",
3666
3693
  description: input.prompt?.trim() || void 0
@@ -4196,7 +4223,7 @@ async function adoptThread(input) {
4196
4223
  messages: input.messages ?? []
4197
4224
  });
4198
4225
  writeThread(thread);
4199
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-U6P6DB44.js");
4226
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-RFGZBUAR.js");
4200
4227
  await ensureWorkspace2(repoPath);
4201
4228
  const { ensureWorktreeSideboardIgnored: ensureWorktreeSideboardIgnored2 } = await import("./worktree-exclude-N5X5I422.js");
4202
4229
  await ensureWorktreeSideboardIgnored2(input.worktreePath);
@@ -6574,7 +6601,7 @@ function formatScheduledPrompt(name, prompt) {
6574
6601
  ${prompt}`;
6575
6602
  }
6576
6603
  async function defaultDeps() {
6577
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-Q33M24ZJ.js");
6604
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-I7GFXLHF.js");
6578
6605
  const orch = getOrchestrator2();
6579
6606
  return {
6580
6607
  findThread: (id) => findThreadByRef(id),
@@ -6688,11 +6715,6 @@ function isPidAlive(pid) {
6688
6715
  return false;
6689
6716
  }
6690
6717
  }
6691
- function sameLoginList(a, b) {
6692
- const left = [...a ?? []].map((s) => s.trim().toLowerCase()).filter(Boolean).sort();
6693
- const right = [...b ?? []].map((s) => s.trim().toLowerCase()).filter(Boolean).sort();
6694
- return left.length === right.length && left.every((login, i) => login === right[i]);
6695
- }
6696
6718
  async function waitForPidExit(pid, timeoutMs) {
6697
6719
  const start = Date.now();
6698
6720
  while (isPidAlive(pid)) {
@@ -8403,12 +8425,18 @@ var Orchestrator = class {
8403
8425
  /** Resolve PR selectors and optionally persist `prUrl` when found. */
8404
8426
  async withPrSelector(threadRef) {
8405
8427
  const thread = this.requireThread(threadRef);
8406
- const selectors = resolvePrSelectors(thread);
8407
8428
  const cwd = thread.worktreePath;
8408
8429
  if (!cwd?.trim()) {
8409
8430
  throw new Error(`Thread ${threadRef} has no worktreePath`);
8410
8431
  }
8411
- return { thread, selectors, cwd };
8432
+ let headUrl = null;
8433
+ try {
8434
+ const head = await getPrForHeadBranch(cwd, thread.branchName);
8435
+ headUrl = head?.url?.trim() || null;
8436
+ } catch {
8437
+ headUrl = null;
8438
+ }
8439
+ return { thread, selectors: connectedPrSelectors(thread, headUrl), cwd };
8412
8440
  }
8413
8441
  async getPrChecks(threadRef) {
8414
8442
  const { selectors, cwd } = await this.withPrSelector(threadRef);
@@ -8436,29 +8464,16 @@ var Orchestrator = class {
8436
8464
  async persistPrMetaAndMaybeArchive(thread, meta) {
8437
8465
  const prevState = normalizePrState(thread.prState);
8438
8466
  const nextState = normalizePrState(meta.state);
8439
- const patch = {};
8440
- if (meta.url && meta.url !== thread.prUrl) patch.prUrl = meta.url;
8441
- if (meta.title && meta.title !== thread.prTitle) patch.prTitle = meta.title;
8442
- if (nextState && nextState !== prevState) patch.prState = nextState;
8443
- const nextDraft = Boolean(meta.isDraft) && nextState !== "MERGED" && nextState !== "CLOSED";
8444
- if (nextDraft !== Boolean(thread.prIsDraft)) patch.prIsDraft = nextDraft;
8445
- const nextAuthor = meta.authorLogin?.trim() || "";
8446
- if (nextAuthor && nextAuthor !== (thread.prAuthorLogin ?? "").trim()) {
8447
- patch.prAuthorLogin = nextAuthor;
8448
- }
8449
- const nextReviewers = meta.reviewerLogins ?? [];
8450
- if (!sameLoginList(nextReviewers, thread.prReviewerLogins)) {
8451
- patch.prReviewerLogins = nextReviewers;
8452
- }
8453
- if (thread.skipAutoArchiveOnMerge && nextState && nextState !== "MERGED" && nextState !== "CLOSED") {
8454
- patch.skipAutoArchiveOnMerge = false;
8467
+ const siblings = threadsSharingWorktree(thread.worktreePath);
8468
+ const targets = siblings.length > 0 ? siblings : [thread];
8469
+ for (const t of targets) {
8470
+ const patch = threadPrMetaPatch(t, meta);
8471
+ if (Object.keys(patch).length === 0) continue;
8472
+ updateThread(t.id, patch);
8455
8473
  }
8456
- if (Object.keys(patch).length > 0) {
8457
- updateThread(thread.id, patch);
8458
- const latest2 = this.requireThread(thread.id);
8459
- if (!latest2.userSetTitle && meta.title && latest2.title !== meta.title) {
8460
- updateThread(thread.id, { title: meta.title });
8461
- }
8474
+ const titled = this.requireThread(thread.id);
8475
+ if (!titled.userSetTitle && meta.title && titled.title !== meta.title) {
8476
+ updateThread(thread.id, { title: meta.title });
8462
8477
  }
8463
8478
  const { autoArchiveOnMergeEnabled } = await import("./app-settings-LGHMNHSP.js");
8464
8479
  const latest = this.requireThread(thread.id);
@@ -8472,22 +8487,7 @@ var Orchestrator = class {
8472
8487
  })) {
8473
8488
  return;
8474
8489
  }
8475
- const siblings = threadsSharingWorktree(latest.worktreePath);
8476
- for (const t of siblings) {
8477
- const sibPatch = { prState: "MERGED", prIsDraft: false };
8478
- if (meta.url && meta.url !== t.prUrl) sibPatch.prUrl = meta.url;
8479
- if (meta.title && meta.title !== t.prTitle) sibPatch.prTitle = meta.title;
8480
- const sibAuthor = meta.authorLogin?.trim() || "";
8481
- if (sibAuthor && sibAuthor !== (t.prAuthorLogin ?? "").trim()) {
8482
- sibPatch.prAuthorLogin = sibAuthor;
8483
- }
8484
- const sibReviewers = meta.reviewerLogins ?? [];
8485
- if (!sameLoginList(sibReviewers, t.prReviewerLogins)) {
8486
- sibPatch.prReviewerLogins = sibReviewers;
8487
- }
8488
- if (Object.keys(sibPatch).length > 0) updateThread(t.id, sibPatch);
8489
- }
8490
- for (const t of siblings) {
8490
+ for (const t of threadsSharingWorktree(latest.worktreePath)) {
8491
8491
  if (this.requireThread(t.id).status === "archived") continue;
8492
8492
  await this.archive(t.id);
8493
8493
  }
@@ -8752,7 +8752,7 @@ var Orchestrator = class {
8752
8752
  this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
8753
8753
  if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
8754
8754
  try {
8755
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-U6P6DB44.js");
8755
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-RFGZBUAR.js");
8756
8756
  await ensureWorkspace2(thread.repoPath);
8757
8757
  } catch {
8758
8758
  }
@@ -8806,7 +8806,7 @@ var Orchestrator = class {
8806
8806
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
8807
8807
  );
8808
8808
  }
8809
- const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-FL3UIUKQ.js");
8809
+ const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-WSUQMMK4.js");
8810
8810
  const slug = thread.worktreePath.split("/").pop();
8811
8811
  const dest = thread.worktreePath;
8812
8812
  await withRepoGitLock(thread.repoPath, async () => {
@@ -8916,7 +8916,7 @@ async function startOrchestration(opts) {
8916
8916
  sourceRef: "default",
8917
8917
  ...createOpts
8918
8918
  }).catch(async () => {
8919
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-FL3UIUKQ.js");
8919
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-WSUQMMK4.js");
8920
8920
  const repo = await resolveRepoRoot2(repoPath);
8921
8921
  const def = await resolveDefaultBranch2(repo);
8922
8922
  return orch.createThread({
@@ -5,7 +5,7 @@ import {
5
5
  resolveRepoRoot,
6
6
  takenSlugsFromThread,
7
7
  teamSlugFromName
8
- } from "./chunk-CMGRV36E.js";
8
+ } from "./chunk-WVATAIF4.js";
9
9
  import {
10
10
  ATTACHMENTS_DIR,
11
11
  attachmentsGitignoreBody
@@ -37,18 +37,33 @@ function abletimeMcpUrl(host, opts) {
37
37
  }
38
38
  var ABLETIME_PAT_PREFIX = "apt_";
39
39
  var ABLETIME_ORG_KEY_PREFIX = "atk_";
40
+ var ABLETIME_OAUTH_TOKEN_PREFIX = "acn_";
40
41
  var ORG_KEY_HINT = "AbleTime MCP needs a personal access token (apt_\u2026) from Edit Profile \u2192 API Access, not an organization API key (atk_\u2026) from Settings \u2192 Integrations \u2192 API Keys.";
41
- var REJECTED_CREDENTIAL_HINT = "AbleTime rejected this credential (unknown, revoked, or expired). Use a personal access token (apt_\u2026) from Edit Profile \u2192 API Access \u2014 organization API keys (atk_\u2026) cannot call MCP. Tokens are shown once; rotating replaces the previous one.";
42
+ var REJECTED_CREDENTIAL_HINT = "AbleTime rejected this credential (unknown, revoked, or expired). Reconnect via browser, or paste a personal access token (apt_\u2026) from Edit Profile \u2192 API Access. Organization API keys (atk_\u2026) use REST, not MCP.";
42
43
  var REWRITE_APPLIED = /— Enable Agent access \(MCP\)|— AbleTime MCP needs a personal access token|— AbleTime plan does not include API access|— AbleTime rejected this credential/;
43
44
  function normalizeAbleTimeCredential(raw) {
44
45
  return raw.trim().replace(/^bearer\s+/i, "").trim();
45
46
  }
46
47
  function ableTimeCredentialKind(raw) {
47
- const token = normalizeAbleTimeCredential(raw).toLowerCase();
48
- if (token.startsWith(ABLETIME_PAT_PREFIX)) return "pat";
49
- if (token.startsWith(ABLETIME_ORG_KEY_PREFIX)) return "org";
48
+ const token = normalizeAbleTimeCredential(raw);
49
+ const lower = token.toLowerCase();
50
+ if (lower.startsWith(ABLETIME_PAT_PREFIX)) return "pat";
51
+ if (lower.startsWith(ABLETIME_ORG_KEY_PREFIX)) return "org";
52
+ if (lower.startsWith(ABLETIME_OAUTH_TOKEN_PREFIX) || token.startsWith("eyJ")) return "oauth";
50
53
  return "unknown";
51
54
  }
55
+ function ableTimeUsesRest(raw) {
56
+ const token = normalizeAbleTimeCredential(raw);
57
+ const kind = ableTimeCredentialKind(token);
58
+ if (kind === "org") return true;
59
+ if (kind === "oauth") return token.startsWith("eyJ");
60
+ return kind === "unknown";
61
+ }
62
+ function isAbleTimeRejectedCredential(message) {
63
+ return /INTEGRATION_KEY_INVALID|INTEGRATION_KEY_MISSING|INTEGRATION_PAT_REQUIRED|\b401\b/i.test(
64
+ message
65
+ );
66
+ }
52
67
  function assertAbleTimeMcpCredential(raw) {
53
68
  const token = normalizeAbleTimeCredential(raw);
54
69
  if (!token) {
@@ -138,7 +153,7 @@ function textsFromUnknown(value) {
138
153
  return "";
139
154
  }
140
155
  async function abletimeMcpRequest(method, params, opts) {
141
- const rawToken = opts?.token ?? await import("./abletime-oauth-OSQYFB3E.js").then((m) => m.ensureAbleTimeAccessToken());
156
+ const rawToken = opts?.token ?? await import("./abletime-oauth-SD4SZY5U.js").then((m) => m.ensureAbleTimeAccessToken());
142
157
  if (!rawToken?.trim()) {
143
158
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
144
159
  }
@@ -209,9 +224,9 @@ async function callAbleTimeTool(name, args = {}, opts) {
209
224
  if (!opts?.token && !isAbleTimeConnected()) {
210
225
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
211
226
  }
212
- const rawToken = opts?.token ?? await import("./abletime-oauth-OSQYFB3E.js").then((m) => m.ensureAbleTimeAccessToken());
213
- if (rawToken && ableTimeCredentialKind(rawToken) === "org") {
214
- const { callAbleTimeRestTool } = await import("./abletime-rest-ZJGWYALM.js");
227
+ const rawToken = opts?.token ?? await import("./abletime-oauth-SD4SZY5U.js").then((m) => m.ensureAbleTimeAccessToken());
228
+ if (rawToken && ableTimeUsesRest(rawToken)) {
229
+ const { callAbleTimeRestTool } = await import("./abletime-rest-J2OBB4VA.js");
215
230
  return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
216
231
  }
217
232
  const requestOpts = { ...opts, pm: opts?.pm ?? abletimeToolUsesPm(name) };
@@ -226,6 +241,10 @@ async function callAbleTimeTool(name, args = {}, opts) {
226
241
  await initializeIfNeeded(requestOpts);
227
242
  return await call();
228
243
  }
244
+ if (rawToken && ableTimeUsesRest(rawToken) && isAbleTimeRejectedCredential(message)) {
245
+ const { callAbleTimeRestTool } = await import("./abletime-rest-J2OBB4VA.js");
246
+ return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
247
+ }
229
248
  throw err instanceof Error ? new Error(rewriteAbleTimeError(err.message)) : err;
230
249
  }
231
250
  }
@@ -240,8 +259,11 @@ export {
240
259
  abletimeMcpUrl,
241
260
  ABLETIME_PAT_PREFIX,
242
261
  ABLETIME_ORG_KEY_PREFIX,
262
+ ABLETIME_OAUTH_TOKEN_PREFIX,
243
263
  normalizeAbleTimeCredential,
244
264
  ableTimeCredentialKind,
265
+ ableTimeUsesRest,
266
+ isAbleTimeRejectedCredential,
245
267
  assertAbleTimeMcpCredential,
246
268
  assertAbleTimeCredential,
247
269
  rewriteAbleTimeError,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {
4
4
  isOrchestratorThread
5
- } from "./chunk-LCU6GBZP.js";
5
+ } from "./chunk-5SMS6QTO.js";
6
6
  import {
7
7
  applyConnectedTeamToCli,
8
8
  brightsyMcpServerName,
@@ -20,7 +20,7 @@ import {
20
20
  mergeAgentGitAuthEnv,
21
21
  resolveAgentGitAuthEnv,
22
22
  resolveCodexGitWritableRoots
23
- } from "./chunk-QSEF2YVQ.js";
23
+ } from "./chunk-QUW5D62C.js";
24
24
  import {
25
25
  enrichPathWithNpmGlobalBin,
26
26
  isConductorBundledCli,
@@ -410,6 +410,9 @@ function humanizeAgentFailDetail(detail) {
410
410
  if (/\[resource_exhausted\]|resource_exhausted|findfileswithripgrep/.test(lower)) {
411
411
  return "Cursor local file search failed (ripgrep / resource_exhausted). Wait a minute and retry; if it keeps happening, check Cursor usage.";
412
412
  }
413
+ if (looksLikeCodexMcpError(raw)) {
414
+ return `${raw} \u2014 skip that vendor MCP and continue (PostHog: Settings \u2192 Connectors + HTTP API).`;
415
+ }
413
416
  if (/invalid user api key|invalid api key|not logged in|not authenticated|unauthorized|authentication|please run.*login|codex login|claude auth|cursor api/.test(
414
417
  lower
415
418
  )) {
@@ -467,9 +470,24 @@ function turnFailChatText(opts) {
467
470
 
468
471
  ${fail}`;
469
472
  }
473
+ function looksLikeCodexMcpError(text) {
474
+ const t = text.trim().toLowerCase();
475
+ if (!t) return false;
476
+ if (/authrequired|authorization required/.test(t) && /mcp|posthog|rmcp|connector|plugin/.test(t)) {
477
+ return true;
478
+ }
479
+ if (/\bposthog\b/.test(t) && /mcp|oauth|auth|unauthorized|401|plugin|app/.test(t)) {
480
+ return true;
481
+ }
482
+ if (/\brmcp\b/.test(t) && /fatal|quit|transport|error|died|kill|auth/.test(t)) {
483
+ return true;
484
+ }
485
+ return /mcp[_ -]?(server|tool|error|transport|client)/.test(t) && /fail|error|timeout|disconnect|auth|unauthorized/.test(t);
486
+ }
470
487
  function shouldFeedErrorBackToAgent(opts) {
471
488
  const detail = opts.detail.trim();
472
489
  const chat = (opts.assistantText ?? "").trim();
490
+ if (looksLikeCodexMcpError(detail)) return true;
473
491
  if (looksLikeAgentFailureMessage(detail) || looksLikeAgentFailureMessage(chat)) {
474
492
  return false;
475
493
  }
@@ -2423,7 +2441,7 @@ var claudeAdapter = {
2423
2441
  );
2424
2442
  }
2425
2443
  const mode = permissionMode(thread);
2426
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-JPJ3FKKY.js");
2444
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-2I2T7FL5.js");
2427
2445
  const isOrchestrator = isOrchestratorThread2(thread);
2428
2446
  const injectedServers = await buildInjectedMcpServers({
2429
2447
  includeSideboard: true,
@@ -2755,7 +2773,18 @@ function toCodexDisableUserMcpArgs(names) {
2755
2773
  return args;
2756
2774
  }
2757
2775
  function toCodexUnattendedAppsArgs() {
2758
- return ["-c", "features.apps=false", "-c", "apps._default.enabled=false"];
2776
+ return [
2777
+ "-c",
2778
+ "features.apps=false",
2779
+ "-c",
2780
+ "apps._default.enabled=false",
2781
+ "-c",
2782
+ "apps.posthog.enabled=false",
2783
+ "-c",
2784
+ "features.plugins=false",
2785
+ "-c",
2786
+ "mcp_servers.posthog.enabled=false"
2787
+ ];
2759
2788
  }
2760
2789
 
2761
2790
  // src/agents/codex.ts
@@ -4422,11 +4451,14 @@ function staleOk(now) {
4422
4451
  if (now - lastGood.at > CLAUDE_USAGE_STALE_OK_MS) return null;
4423
4452
  return lastGood.value;
4424
4453
  }
4454
+ function reuseLast() {
4455
+ return lastGood?.value ?? null;
4456
+ }
4425
4457
  async function getClaudePlanUsage(opts = {}) {
4426
4458
  const now = opts.now ?? Date.now();
4459
+ if (now < errorUntil) return reuseLast() ?? staleOk(now);
4427
4460
  if (!opts.force) {
4428
4461
  if (cache && now - cache.at < CLAUDE_USAGE_TTL_MS) return cache.value;
4429
- if (now < errorUntil) return staleOk(now);
4430
4462
  }
4431
4463
  if (inflight) return inflight;
4432
4464
  inflight = (async () => {
@@ -4457,6 +4489,12 @@ async function getClaudePlanUsage(opts = {}) {
4457
4489
  cache = { at: now, value: null };
4458
4490
  return null;
4459
4491
  }
4492
+ if (res.status === 429) {
4493
+ errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
4494
+ const last = reuseLast();
4495
+ if (last) cache = { at: now, value: last };
4496
+ return last;
4497
+ }
4460
4498
  if (!res.ok) {
4461
4499
  errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
4462
4500
  return staleOk(now);
@@ -2154,26 +2154,21 @@ function resolvePrSelectors(thread) {
2154
2154
  function resolvePrSelector(thread) {
2155
2155
  return resolvePrSelectors(thread)[0] ?? null;
2156
2156
  }
2157
+ function connectedPrSelectors(thread, currentHeadPrUrl) {
2158
+ const out = [];
2159
+ const push = (value) => {
2160
+ const v = value?.trim();
2161
+ if (!v || out.includes(v)) return;
2162
+ out.push(v);
2163
+ };
2164
+ push(currentHeadPrUrl);
2165
+ for (const selector of resolvePrSelectors(thread)) push(selector);
2166
+ return out;
2167
+ }
2157
2168
  async function getPrForHeadBranch(repoPath, branch) {
2158
2169
  const head = normalizeGitBranchName(branch);
2159
2170
  if (!head || isDefaultishSourceRef(head)) return null;
2160
2171
  const slug = await resolveGithubRepoSlug(repoPath);
2161
- const viewArgs = [
2162
- "pr",
2163
- "view",
2164
- head,
2165
- "--json",
2166
- "number,title,headRefName,url,isCrossRepository,author"
2167
- ];
2168
- if (slug) viewArgs.push("--repo", slug);
2169
- const viewed = await gh(viewArgs, repoPath, { reject: false });
2170
- if (viewed.exitCode === 0 && viewed.stdout.trim()) {
2171
- try {
2172
- return JSON.parse(viewed.stdout);
2173
- } catch {
2174
- return null;
2175
- }
2176
- }
2177
2172
  const listHead = slug ? ghHeadRef(slug, head) : head;
2178
2173
  const listArgs = [
2179
2174
  "pr",
@@ -2189,10 +2184,28 @@ async function getPrForHeadBranch(repoPath, branch) {
2189
2184
  ];
2190
2185
  if (slug) listArgs.push("--repo", slug);
2191
2186
  const listed = await gh(listArgs, repoPath, { reject: false });
2192
- if (listed.exitCode !== 0 || !listed.stdout.trim()) return null;
2187
+ if (listed.exitCode === 0 && listed.stdout.trim()) {
2188
+ try {
2189
+ const rows = JSON.parse(listed.stdout);
2190
+ if (rows[0]) return rows[0];
2191
+ } catch {
2192
+ }
2193
+ }
2194
+ const viewArgs = [
2195
+ "pr",
2196
+ "view",
2197
+ head,
2198
+ "--json",
2199
+ "number,title,headRefName,url,isCrossRepository,author,state"
2200
+ ];
2201
+ if (slug) viewArgs.push("--repo", slug);
2202
+ const viewed = await gh(viewArgs, repoPath, { reject: false });
2203
+ if (viewed.exitCode !== 0 || !viewed.stdout.trim()) return null;
2193
2204
  try {
2194
- const rows = JSON.parse(listed.stdout);
2195
- return rows[0] ?? null;
2205
+ const info = JSON.parse(viewed.stdout);
2206
+ const state = (info.state ?? "OPEN").trim().toUpperCase();
2207
+ if (state !== "OPEN") return null;
2208
+ return info;
2196
2209
  } catch {
2197
2210
  return null;
2198
2211
  }
@@ -3313,6 +3326,7 @@ export {
3313
3326
  isDefaultishSourceRef,
3314
3327
  resolvePrSelectors,
3315
3328
  resolvePrSelector,
3329
+ connectedPrSelectors,
3316
3330
  getPrForHeadBranch,
3317
3331
  detectLocalMergeConflicts,
3318
3332
  getPrChecks,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  isOrchestratorThread
3
- } from "./chunk-TNDUTGDV.js";
3
+ } from "./chunk-VIPA75ZA.js";
4
4
  import {
5
5
  codexUnattendedGitConfigArgs,
6
6
  mergeAgentGitAuthEnv,
7
7
  resolveAgentGitAuthEnv,
8
8
  resolveCodexGitWritableRoots
9
- } from "./chunk-CMGRV36E.js";
9
+ } from "./chunk-WVATAIF4.js";
10
10
  import {
11
11
  applyConnectedTeamToCli,
12
12
  brightsyMcpServerName,
@@ -33,7 +33,7 @@ import {
33
33
  packagedMcpStdioPath,
34
34
  parseCursorRunnerLine,
35
35
  resolveNodeLaunch
36
- } from "./chunk-CQ5R3VPP.js";
36
+ } from "./chunk-KZ7PI7FE.js";
37
37
  import {
38
38
  claudeChromeEnabled,
39
39
  isAbleTimeConnected,
@@ -1937,7 +1937,7 @@ var claudeAdapter = {
1937
1937
  );
1938
1938
  }
1939
1939
  const mode = permissionMode(thread);
1940
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-PU7ZS3LS.js");
1940
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-NSILADOM.js");
1941
1941
  const isOrchestrator = isOrchestratorThread2(thread);
1942
1942
  const injectedServers = await buildInjectedMcpServers({
1943
1943
  includeSideboard: true,
@@ -2333,7 +2333,18 @@ function toCodexDisableUserMcpArgs(names) {
2333
2333
  return args;
2334
2334
  }
2335
2335
  function toCodexUnattendedAppsArgs() {
2336
- return ["-c", "features.apps=false", "-c", "apps._default.enabled=false"];
2336
+ return [
2337
+ "-c",
2338
+ "features.apps=false",
2339
+ "-c",
2340
+ "apps._default.enabled=false",
2341
+ "-c",
2342
+ "apps.posthog.enabled=false",
2343
+ "-c",
2344
+ "features.plugins=false",
2345
+ "-c",
2346
+ "mcp_servers.posthog.enabled=false"
2347
+ ];
2337
2348
  }
2338
2349
 
2339
2350
  // src/agents/codex.ts
@@ -3727,11 +3738,14 @@ function staleOk(now) {
3727
3738
  if (now - lastGood.at > CLAUDE_USAGE_STALE_OK_MS) return null;
3728
3739
  return lastGood.value;
3729
3740
  }
3741
+ function reuseLast() {
3742
+ return lastGood?.value ?? null;
3743
+ }
3730
3744
  async function getClaudePlanUsage(opts = {}) {
3731
3745
  const now = opts.now ?? Date.now();
3746
+ if (now < errorUntil) return reuseLast() ?? staleOk(now);
3732
3747
  if (!opts.force) {
3733
3748
  if (cache && now - cache.at < CLAUDE_USAGE_TTL_MS) return cache.value;
3734
- if (now < errorUntil) return staleOk(now);
3735
3749
  }
3736
3750
  if (inflight) return inflight;
3737
3751
  inflight = (async () => {
@@ -3762,6 +3776,12 @@ async function getClaudePlanUsage(opts = {}) {
3762
3776
  cache = { at: now, value: null };
3763
3777
  return null;
3764
3778
  }
3779
+ if (res.status === 429) {
3780
+ errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
3781
+ const last = reuseLast();
3782
+ if (last) cache = { at: now, value: last };
3783
+ return last;
3784
+ }
3765
3785
  if (!res.ok) {
3766
3786
  errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
3767
3787
  return staleOk(now);
@@ -9,8 +9,8 @@ import {
9
9
  enrichWorkspacesWithGithub,
10
10
  ensureGlobalCoordinatorCwd,
11
11
  formatWorkspaceInventory
12
- } from "./chunk-LCU6GBZP.js";
13
- import "./chunk-QSEF2YVQ.js";
12
+ } from "./chunk-5SMS6QTO.js";
13
+ import "./chunk-QUW5D62C.js";
14
14
  import "./chunk-D6JWYJ4P.js";
15
15
  import "./chunk-INNLWYXW.js";
16
16
  import "./chunk-SYFVUF2C.js";
@@ -7,8 +7,8 @@ import {
7
7
  enrichWorkspacesWithGithub,
8
8
  ensureGlobalCoordinatorCwd,
9
9
  formatWorkspaceInventory
10
- } from "./chunk-TNDUTGDV.js";
11
- import "./chunk-CMGRV36E.js";
10
+ } from "./chunk-VIPA75ZA.js";
11
+ import "./chunk-WVATAIF4.js";
12
12
  import "./chunk-6K64FJDD.js";
13
13
  import "./chunk-QQKDGPUI.js";
14
14
  import "./chunk-QFBBUFD4.js";
@@ -17,8 +17,8 @@ import {
17
17
  orchestratorSessionPoisonedByBuiltins,
18
18
  slackCoordinatorSourceRef,
19
19
  takenTeamSlugsForOrchestration
20
- } from "./chunk-LCU6GBZP.js";
21
- import "./chunk-QSEF2YVQ.js";
20
+ } from "./chunk-5SMS6QTO.js";
21
+ import "./chunk-QUW5D62C.js";
22
22
  import "./chunk-D6JWYJ4P.js";
23
23
  import "./chunk-INNLWYXW.js";
24
24
  import "./chunk-SYFVUF2C.js";
@@ -15,8 +15,8 @@ import {
15
15
  orchestratorSessionPoisonedByBuiltins,
16
16
  slackCoordinatorSourceRef,
17
17
  takenTeamSlugsForOrchestration
18
- } from "./chunk-TNDUTGDV.js";
19
- import "./chunk-CMGRV36E.js";
18
+ } from "./chunk-VIPA75ZA.js";
19
+ import "./chunk-WVATAIF4.js";
20
20
  import "./chunk-6K64FJDD.js";
21
21
  import "./chunk-QQKDGPUI.js";
22
22
  import "./chunk-QFBBUFD4.js";