@sideboard-ai/core 0.1.257 → 0.1.261

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 (66) hide show
  1. package/dist/{abletime-IDQJI2KW.js → abletime-CDGINDXG.js} +6 -5
  2. package/dist/{abletime-OGQR4LIL.js → abletime-OQ4PC52L.js} +7 -6
  3. package/dist/{abletime-oauth-ZQUIY4EM.js → abletime-oauth-5A5EOH2A.js} +5 -4
  4. package/dist/{abletime-oauth-MBAG5MYU.js → abletime-oauth-KX2TDFTE.js} +6 -5
  5. package/dist/{abletime-rest-WEJERY4O.js → abletime-rest-PUGKYTRR.js} +6 -5
  6. package/dist/{abletime-rest-JZIIT5W3.js → abletime-rest-UEHOBLXD.js} +5 -4
  7. package/dist/agents/cursor-runner.cjs +274 -12
  8. package/dist/agents/cursor-runner.js +156 -13
  9. package/dist/{agents-HZP7YEKC.js → agents-IKVUGW5H.js} +12 -9
  10. package/dist/{agents-FSUI5MET.js → agents-J2P4KNEY.js} +21 -18
  11. package/dist/{app-settings-CLARFJUX.js → app-settings-OM7H64YM.js} +12 -3
  12. package/dist/{app-settings-ONYJ36XH.js → app-settings-VQEUCONM.js} +11 -2
  13. package/dist/chunk-3HO2OY5T.js +159 -0
  14. package/dist/{chunk-F7ANS66U.js → chunk-4F7J6UWD.js} +75 -33
  15. package/dist/{chunk-WDDUIGFK.js → chunk-4GK32AYX.js} +1 -1
  16. package/dist/{chunk-ZC3TVLY6.js → chunk-5OKJDCBK.js} +5 -5
  17. package/dist/{chunk-KJM3E3NF.js → chunk-6PFZ6XO7.js} +65 -6
  18. package/dist/{title-4A2ATYNY.js → chunk-7H655NEW.js} +1 -0
  19. package/dist/{chunk-R4DWUBOL.js → chunk-ABPNIYRS.js} +78 -37
  20. package/dist/{chunk-XIEDFRBP.js → chunk-B6XFBNYM.js} +2 -2
  21. package/dist/chunk-CEMNIGQH.js +161 -0
  22. package/dist/{chunk-66LAOKLK.js → chunk-D554YCHG.js} +2 -2
  23. package/dist/{chunk-HCNCZPDL.js → chunk-FSZ7YYFQ.js} +119 -63
  24. package/dist/{chunk-4723RAO3.js → chunk-FWNL62VA.js} +3 -1
  25. package/dist/{chunk-Y7CS2WGJ.js → chunk-GIZQAOHZ.js} +247 -109
  26. package/dist/chunk-HHEKVR6C.js +72 -0
  27. package/dist/{chunk-IFHHPPSL.js → chunk-J6ONZP74.js} +5 -5
  28. package/dist/{chunk-PJK24CN3.js → chunk-JTNY5CK4.js} +10 -10
  29. package/dist/{chunk-CPEIHTG7.js → chunk-KVQX62XI.js} +3 -3
  30. package/dist/{chunk-5F4YFGHL.js → chunk-LDXSAVWO.js} +7 -7
  31. package/dist/{title-4WAKWZRF.js → chunk-LX5R5JOR.js} +1 -0
  32. package/dist/{chunk-D6JWYJ4P.js → chunk-N2WW62LF.js} +1 -0
  33. package/dist/{chunk-RTQOCFIV.js → chunk-S7VDDJ34.js} +3 -3
  34. package/dist/{chunk-RJC2MKXN.js → chunk-TJ673EZT.js} +3 -1
  35. package/dist/{chunk-63YSFXLT.js → chunk-U3AOJLH3.js} +126 -70
  36. package/dist/{chunk-452Y24PW.js → chunk-VIC6TDYT.js} +68 -9
  37. package/dist/{chunk-553IEH7O.js → chunk-W5PWGEKS.js} +241 -104
  38. package/dist/{chunk-VVHHBOIA.js → chunk-WV7KJH2E.js} +5 -3
  39. package/dist/{chunk-BYRZS2S2.js → chunk-X2OTZ36G.js} +4 -4
  40. package/dist/{chunk-FGWUZOZN.js → chunk-YFTO7U2A.js} +3 -3
  41. package/dist/connected-teams-7CENZDWU.js +1 -1
  42. package/dist/{connected-teams-Z5GOIC5I.js → connected-teams-RU6VATCM.js} +2 -2
  43. package/dist/{coordinator-prompt-HZUWK3NP.js → coordinator-prompt-TU6656OK.js} +9 -8
  44. package/dist/{coordinator-prompt-Y6S6USNS.js → coordinator-prompt-VQHQ3RIX.js} +8 -7
  45. package/dist/{global-workspace-4JCITHB6.js → global-workspace-47NZVA44.js} +8 -7
  46. package/dist/{global-workspace-YA7U4M2N.js → global-workspace-PHF2MOGW.js} +9 -8
  47. package/dist/index.cjs +1443 -856
  48. package/dist/index.d.cts +118 -37
  49. package/dist/index.d.ts +118 -37
  50. package/dist/index.js +148 -64
  51. package/dist/managed-accounts-2AK5RIAF.js +39 -0
  52. package/dist/managed-accounts-4BLTJKAN.js +41 -0
  53. package/dist/mcp/run-stdio.cjs +2722 -2248
  54. package/dist/mcp/run-stdio.js +136 -50
  55. package/dist/{orchestrator-LWADJQTN.js → orchestrator-OCG4QVA5.js} +13 -11
  56. package/dist/{orchestrator-VHJZEVGA.js → orchestrator-VLTO5JBR.js} +13 -11
  57. package/dist/{plan-file-CKXUFTQ2.js → plan-file-VAHV5WBB.js} +2 -2
  58. package/dist/{thread-store-HDQ4CH54.js → thread-store-FJ5CDX2M.js} +1 -1
  59. package/dist/{thread-store-ZDR3Z5UG.js → thread-store-SHCUBWB3.js} +1 -1
  60. package/dist/title-ERD6D3C3.js +8 -0
  61. package/dist/title-Z7WAJN57.js +6 -0
  62. package/dist/{workspaces-IXZD7EC4.js → workspaces-2XTDS7N2.js} +9 -8
  63. package/dist/{workspaces-4KHEUPEX.js → workspaces-I7TWFTJM.js} +8 -7
  64. package/dist/{worktree-DAAF64UU.js → worktree-DDDF3WHV.js} +8 -7
  65. package/dist/{worktree-S3FOMEQ2.js → worktree-YASFE65H.js} +7 -6
  66. package/package.json +1 -1
@@ -2,7 +2,13 @@
2
2
 
3
3
  import {
4
4
  isOrchestratorThread
5
- } from "./chunk-PJK24CN3.js";
5
+ } from "./chunk-JTNY5CK4.js";
6
+ import {
7
+ codexUnattendedGitConfigArgs,
8
+ mergeAgentGitAuthEnv,
9
+ resolveAgentGitAuthEnv,
10
+ resolveCodexGitWritableRoots
11
+ } from "./chunk-FSZ7YYFQ.js";
6
12
  import {
7
13
  applyConnectedTeamToCli,
8
14
  brightsyMcpServerName,
@@ -15,12 +21,6 @@ import {
15
21
  import {
16
22
  httpFetch
17
23
  } from "./chunk-VKQGAWHY.js";
18
- import {
19
- codexUnattendedGitConfigArgs,
20
- mergeAgentGitAuthEnv,
21
- resolveAgentGitAuthEnv,
22
- resolveCodexGitWritableRoots
23
- } from "./chunk-HCNCZPDL.js";
24
24
  import {
25
25
  enrichPathWithNpmGlobalBin,
26
26
  isConductorBundledCli,
@@ -37,15 +37,15 @@ import {
37
37
  loadAppSettings,
38
38
  resolveAgentExecutable,
39
39
  resolveClaudeExecutable
40
- } from "./chunk-452Y24PW.js";
41
- import {
42
- appDataDir
43
- } from "./chunk-Z2LGMV6C.js";
40
+ } from "./chunk-VIC6TDYT.js";
44
41
  import {
45
42
  isElectronLikeCommand,
46
43
  unwrapStrippedElectronLaunch,
47
44
  wrapElectronAsNodeLaunch
48
45
  } from "./chunk-WWUABK6B.js";
46
+ import {
47
+ appDataDir
48
+ } from "./chunk-Z2LGMV6C.js";
49
49
 
50
50
  // src/agents/brightsy.ts
51
51
  import { existsSync } from "fs";
@@ -2970,7 +2970,7 @@ var claudeAdapter = {
2970
2970
  );
2971
2971
  }
2972
2972
  const mode = permissionMode(thread);
2973
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-YA7U4M2N.js");
2973
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-PHF2MOGW.js");
2974
2974
  const isOrchestrator = isOrchestratorThread2(thread);
2975
2975
  const injectedServers = await buildInjectedMcpServers({
2976
2976
  includeSideboard: true,
@@ -4937,6 +4937,18 @@ var errorUntil = 0;
4937
4937
  var inflight = null;
4938
4938
  var lastGood = null;
4939
4939
  var claudeVersion = null;
4940
+ var cacheDirKey = "";
4941
+ function usageCacheDir(opts) {
4942
+ return opts.configDir?.trim() || "";
4943
+ }
4944
+ function adoptCacheDir(dir) {
4945
+ if (dir === cacheDirKey) return;
4946
+ cache = null;
4947
+ lastGood = null;
4948
+ errorUntil = 0;
4949
+ inflight = null;
4950
+ cacheDirKey = dir;
4951
+ }
4940
4952
  function accessTokenFromCredentialsJson(raw) {
4941
4953
  const trimmed = raw.trim();
4942
4954
  if (!trimmed) return null;
@@ -4953,12 +4965,12 @@ function accessTokenFromCredentialsJson(raw) {
4953
4965
  return null;
4954
4966
  }
4955
4967
  }
4956
- function claudeCredentialsPath() {
4957
- const root = process.env.CLAUDE_CONFIG_DIR?.trim() || join11(homedir5(), ".claude");
4968
+ function claudeCredentialsPath(configDir) {
4969
+ const root = configDir?.trim() || process.env.CLAUDE_CONFIG_DIR?.trim() || join11(homedir5(), ".claude");
4958
4970
  return join11(root, ".credentials.json");
4959
4971
  }
4960
- async function readFileAccessToken() {
4961
- const path = claudeCredentialsPath();
4972
+ async function readFileAccessToken(configDir) {
4973
+ const path = claudeCredentialsPath(configDir);
4962
4974
  if (!existsSync14(path)) return null;
4963
4975
  try {
4964
4976
  return accessTokenFromCredentialsJson(readFileSync6(path, "utf8"));
@@ -4966,25 +4978,31 @@ async function readFileAccessToken() {
4966
4978
  return null;
4967
4979
  }
4968
4980
  }
4969
- async function readKeychainAccessToken() {
4981
+ async function readKeychainAccessToken(configDir) {
4970
4982
  if (process.platform !== "darwin") return null;
4983
+ const root = configDir?.trim();
4984
+ const accounts = root ? [root, void 0] : [void 0];
4971
4985
  for (const service of KEYCHAIN_SERVICES) {
4972
- const result = await run("security", ["find-generic-password", "-s", service, "-w"], {
4973
- reject: false,
4974
- timeoutMs: 4e3
4975
- });
4976
- if (result.exitCode !== 0 || !result.stdout.trim()) continue;
4977
- const token = accessTokenFromCredentialsJson(result.stdout);
4978
- if (token) return token;
4986
+ for (const account of accounts) {
4987
+ const args = ["find-generic-password", "-s", service, "-w"];
4988
+ if (account) args.splice(3, 0, "-a", account);
4989
+ const result = await run("security", args, {
4990
+ reject: false,
4991
+ timeoutMs: 4e3
4992
+ });
4993
+ if (result.exitCode !== 0 || !result.stdout.trim()) continue;
4994
+ const token = accessTokenFromCredentialsJson(result.stdout);
4995
+ if (token) return token;
4996
+ }
4979
4997
  }
4980
4998
  return null;
4981
4999
  }
4982
- async function readClaudeAccessToken() {
5000
+ async function readClaudeAccessToken(configDir) {
4983
5001
  const envToken = process.env.CLAUDE_CODE_OAUTH_TOKEN?.trim();
4984
5002
  if (envToken) return envToken;
4985
- const fromFile = await readFileAccessToken();
5003
+ const fromFile = await readFileAccessToken(configDir);
4986
5004
  if (fromFile) return fromFile;
4987
- return readKeychainAccessToken();
5005
+ return readKeychainAccessToken(configDir);
4988
5006
  }
4989
5007
  async function resolveClaudeUserAgent() {
4990
5008
  if (claudeVersion) return `claude-code/${claudeVersion}`;
@@ -5009,6 +5027,7 @@ function reuseLast() {
5009
5027
  }
5010
5028
  async function getClaudePlanUsage(opts = {}) {
5011
5029
  const now = opts.now ?? Date.now();
5030
+ adoptCacheDir(usageCacheDir(opts));
5012
5031
  if (now < errorUntil) return reuseLast() ?? staleOk(now);
5013
5032
  if (!opts.force) {
5014
5033
  if (cache && now - cache.at < CLAUDE_USAGE_TTL_MS) return cache.value;
@@ -5016,9 +5035,9 @@ async function getClaudePlanUsage(opts = {}) {
5016
5035
  if (inflight) return inflight;
5017
5036
  inflight = (async () => {
5018
5037
  try {
5019
- const token = await (opts.readAccessToken ?? readClaudeAccessToken)();
5038
+ const token = await (opts.readAccessToken ?? (() => readClaudeAccessToken(opts.configDir)))();
5020
5039
  if (!token) {
5021
- cache = { at: now, value: null };
5040
+ cache = { at: now, dir: cacheDirKey, value: null };
5022
5041
  return null;
5023
5042
  }
5024
5043
  const fetchFn = opts.fetch ?? httpFetch;
@@ -5039,13 +5058,13 @@ async function getClaudePlanUsage(opts = {}) {
5039
5058
  clearTimeout(timer);
5040
5059
  }
5041
5060
  if (res.status === 401 || res.status === 403) {
5042
- cache = { at: now, value: null };
5061
+ cache = { at: now, dir: cacheDirKey, value: null };
5043
5062
  return null;
5044
5063
  }
5045
5064
  if (res.status === 429) {
5046
5065
  errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
5047
5066
  const last = reuseLast();
5048
- if (last) cache = { at: now, value: last };
5067
+ if (last) cache = { at: now, dir: cacheDirKey, value: last };
5049
5068
  return last;
5050
5069
  }
5051
5070
  if (!res.ok) {
@@ -5053,8 +5072,8 @@ async function getClaudePlanUsage(opts = {}) {
5053
5072
  return staleOk(now);
5054
5073
  }
5055
5074
  const usage = parseClaudeUsagePayload(await res.json(), new Date(now).toISOString());
5056
- cache = { at: now, value: usage };
5057
- if (usage) lastGood = { at: now, value: usage };
5075
+ cache = { at: now, dir: cacheDirKey, value: usage };
5076
+ if (usage) lastGood = { at: now, dir: cacheDirKey, value: usage };
5058
5077
  return usage;
5059
5078
  } catch {
5060
5079
  errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
@@ -5321,6 +5340,27 @@ async function loginAgent(agent) {
5321
5340
  message: `Opened Terminal to run: ${prepared}`
5322
5341
  };
5323
5342
  }
5343
+ async function loginManagedAccount(accountId) {
5344
+ const { loadAppSettings: loadAppSettings2 } = await import("./app-settings-OM7H64YM.js");
5345
+ const { loginEnvPrefix } = await import("./managed-accounts-4BLTJKAN.js");
5346
+ const account = loadAppSettings2().accounts.accounts.find((a) => a.id === accountId);
5347
+ if (!account) {
5348
+ return { ok: false, message: `Account not found: ${accountId}` };
5349
+ }
5350
+ const loginCommand = resolveLoginCommand(account.kind);
5351
+ if (!loginCommand) {
5352
+ return { ok: false, message: `No login command for ${account.kind}` };
5353
+ }
5354
+ const prepared = await prepareTerminalCommand(loginCommand);
5355
+ const prefixed = `${loginEnvPrefix(account)} && ${prepared}`;
5356
+ await openInSystemTerminal(prefixed);
5357
+ return {
5358
+ ok: true,
5359
+ openedTerminal: true,
5360
+ command: prefixed,
5361
+ message: `Opened Terminal to run: ${prefixed}`
5362
+ };
5363
+ }
5324
5364
 
5325
5365
  // src/agents/index.ts
5326
5366
  var adapters = {
@@ -5342,6 +5382,7 @@ export {
5342
5382
  applySystemCaEnv,
5343
5383
  trustSystemCertificates,
5344
5384
  pushTurnStderr,
5385
+ looksLikeHugeToolResultDump,
5345
5386
  clipToolResultForStore,
5346
5387
  looksLikeV8Oom,
5347
5388
  summarizeTurnStderr,
@@ -5425,6 +5466,7 @@ export {
5425
5466
  installNpmGlobalPackage,
5426
5467
  installAgent,
5427
5468
  loginAgent,
5469
+ loginManagedAccount,
5428
5470
  getAdapter,
5429
5471
  allAdapters
5430
5472
  };
@@ -4,7 +4,7 @@ import {
4
4
  ATTACHMENTS_DIR,
5
5
  LEGACY_ATTACHMENTS_DIR,
6
6
  attachmentsGitignoreBody
7
- } from "./chunk-D6JWYJ4P.js";
7
+ } from "./chunk-N2WW62LF.js";
8
8
 
9
9
  // src/plan/plan-file.ts
10
10
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  getAbleTimeHost,
8
8
  isAbleTimeConnected
9
- } from "./chunk-452Y24PW.js";
9
+ } from "./chunk-VIC6TDYT.js";
10
10
 
11
11
  // src/integrations/abletime-mcp.ts
12
12
  var DEFAULT_ABLETIME_HOST = "https://track.abletime.com";
@@ -155,7 +155,7 @@ function textsFromUnknown(value) {
155
155
  return "";
156
156
  }
157
157
  async function abletimeMcpRequest(method, params, opts) {
158
- const rawToken = opts?.token ?? await import("./abletime-oauth-MBAG5MYU.js").then((m) => m.ensureAbleTimeAccessToken());
158
+ const rawToken = opts?.token ?? await import("./abletime-oauth-KX2TDFTE.js").then((m) => m.ensureAbleTimeAccessToken());
159
159
  if (!rawToken?.trim()) {
160
160
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
161
161
  }
@@ -226,9 +226,9 @@ async function callAbleTimeTool(name, args = {}, opts) {
226
226
  if (!opts?.token && !isAbleTimeConnected()) {
227
227
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
228
228
  }
229
- const rawToken = opts?.token ?? await import("./abletime-oauth-MBAG5MYU.js").then((m) => m.ensureAbleTimeAccessToken());
229
+ const rawToken = opts?.token ?? await import("./abletime-oauth-KX2TDFTE.js").then((m) => m.ensureAbleTimeAccessToken());
230
230
  if (rawToken && ableTimeUsesRest(rawToken)) {
231
- const { callAbleTimeRestTool } = await import("./abletime-rest-WEJERY4O.js");
231
+ const { callAbleTimeRestTool } = await import("./abletime-rest-PUGKYTRR.js");
232
232
  return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
233
233
  }
234
234
  const requestOpts = { ...opts, pm: opts?.pm ?? abletimeToolUsesPm(name) };
@@ -244,7 +244,7 @@ async function callAbleTimeTool(name, args = {}, opts) {
244
244
  return await call();
245
245
  }
246
246
  if (rawToken && ableTimeUsesRest(rawToken) && isAbleTimeRejectedCredential(message)) {
247
- const { callAbleTimeRestTool } = await import("./abletime-rest-WEJERY4O.js");
247
+ const { callAbleTimeRestTool } = await import("./abletime-rest-PUGKYTRR.js");
248
248
  return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
249
249
  }
250
250
  throw err instanceof Error ? new Error(rewriteAbleTimeError(err.message)) : err;
@@ -1,6 +1,17 @@
1
+ import {
2
+ stripNestedElectronEnv
3
+ } from "./chunk-4TR3HZFT.js";
1
4
  import {
2
5
  sanitizeGitBranchPrefix
3
6
  } from "./chunk-WDRMZKVB.js";
7
+ import {
8
+ EMPTY_MANAGED_ACCOUNTS,
9
+ ensureManagedAccountDir,
10
+ normalizeManagedAccounts,
11
+ withAddedAccount,
12
+ withRemovedAccount,
13
+ withSelectedAccount
14
+ } from "./chunk-3HO2OY5T.js";
4
15
  import {
5
16
  chmodOwnerOnly,
6
17
  writePrivateFile
@@ -11,9 +22,6 @@ import {
11
22
  import {
12
23
  appDataDir
13
24
  } from "./chunk-EHT2DRT4.js";
14
- import {
15
- stripNestedElectronEnv
16
- } from "./chunk-4TR3HZFT.js";
17
25
 
18
26
  // src/store/app-settings.ts
19
27
  import { randomUUID } from "crypto";
@@ -524,11 +532,12 @@ function planHistoryAgePurge(archived, olderThanDays, nowMs = Date.now()) {
524
532
  var USAGE_ON_LIMIT_VALUES = [
525
533
  "keep_going",
526
534
  "confirm",
535
+ "switch_account",
527
536
  "switch_agent",
528
537
  "wait_reset"
529
538
  ];
530
539
  function isUsageOnLimit(value) {
531
- return value === "keep_going" || value === "confirm" || value === "switch_agent" || value === "wait_reset";
540
+ return value === "keep_going" || value === "confirm" || value === "switch_account" || value === "switch_agent" || value === "wait_reset";
532
541
  }
533
542
  function resolveUsageOnLimit(advanced = {}) {
534
543
  if (isUsageOnLimit(advanced.usageOnLimit)) return advanced.usageOnLimit;
@@ -1062,6 +1071,7 @@ function normalizeSettings(raw) {
1062
1071
  let defaults = {};
1063
1072
  let projects = {};
1064
1073
  let advanced = {};
1074
+ let accounts = { ...EMPTY_MANAGED_ACCOUNTS };
1065
1075
  if (raw && typeof raw === "object") {
1066
1076
  if ("environment" in raw) {
1067
1077
  const source = raw.environment;
@@ -1099,6 +1109,9 @@ function normalizeSettings(raw) {
1099
1109
  if ("advanced" in raw) {
1100
1110
  advanced = normalizeAdvanced(raw.advanced);
1101
1111
  }
1112
+ if ("accounts" in raw) {
1113
+ accounts = normalizeManagedAccounts(raw.accounts);
1114
+ }
1102
1115
  }
1103
1116
  return {
1104
1117
  environment: env,
@@ -1109,7 +1122,8 @@ function normalizeSettings(raw) {
1109
1122
  integrations,
1110
1123
  defaults,
1111
1124
  projects,
1112
- advanced
1125
+ advanced,
1126
+ accounts
1113
1127
  };
1114
1128
  }
1115
1129
  var EMPTY_SETTINGS = {
@@ -1121,7 +1135,8 @@ var EMPTY_SETTINGS = {
1121
1135
  integrations: {},
1122
1136
  defaults: {},
1123
1137
  projects: {},
1124
- advanced: {}
1138
+ advanced: {},
1139
+ accounts: { ...EMPTY_MANAGED_ACCOUNTS }
1125
1140
  };
1126
1141
  function readSettingsFile() {
1127
1142
  const path = appSettingsPath();
@@ -1245,6 +1260,46 @@ function saveAppSettings(settings) {
1245
1260
  persistSplit(normalized);
1246
1261
  return normalized;
1247
1262
  }
1263
+ function addManagedAccount(kind, label) {
1264
+ const current = loadAppSettings();
1265
+ const id = randomUUID();
1266
+ const configDir = ensureManagedAccountDir(kind, id);
1267
+ const trimmed = label.trim().slice(0, 80) || (kind === "claude" ? "Claude" : "Codex");
1268
+ const next = withAddedAccount(current.accounts, {
1269
+ id,
1270
+ kind,
1271
+ label: trimmed,
1272
+ configDir,
1273
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
1274
+ });
1275
+ return saveAppSettings({ ...current, accounts: next });
1276
+ }
1277
+ function selectManagedAccount(kind, accountId) {
1278
+ const current = loadAppSettings();
1279
+ return saveAppSettings({
1280
+ ...current,
1281
+ accounts: withSelectedAccount(current.accounts, kind, accountId)
1282
+ });
1283
+ }
1284
+ function removeManagedAccount(id) {
1285
+ const current = loadAppSettings();
1286
+ return saveAppSettings({
1287
+ ...current,
1288
+ accounts: withRemovedAccount(current.accounts, id)
1289
+ });
1290
+ }
1291
+ function renameManagedAccount(id, label) {
1292
+ const current = loadAppSettings();
1293
+ const trimmed = label.trim().slice(0, 80);
1294
+ if (!trimmed) return current;
1295
+ const accounts = current.accounts.accounts.map(
1296
+ (a) => a.id === id ? { ...a, label: trimmed } : a
1297
+ );
1298
+ return saveAppSettings({
1299
+ ...current,
1300
+ accounts: { ...current.accounts, accounts }
1301
+ });
1302
+ }
1248
1303
  function updateAppEnvironment(patch) {
1249
1304
  const current = loadAppSettings();
1250
1305
  const environment = { ...current.environment };
@@ -2227,6 +2282,10 @@ export {
2227
2282
  findProjectProfileKey,
2228
2283
  loadAppSettings,
2229
2284
  saveAppSettings,
2285
+ addManagedAccount,
2286
+ selectManagedAccount,
2287
+ removeManagedAccount,
2288
+ renameManagedAccount,
2230
2289
  updateAppEnvironment,
2231
2290
  updateClaudeSettings,
2232
2291
  updateBrightsySettings,
@@ -19,6 +19,7 @@ function titleFromPrompt(prompt, max = 60) {
19
19
  const base = lastSpace > Math.floor(max * 0.4) ? sliced.slice(0, lastSpace) : sliced;
20
20
  return `${base.trimEnd()}\u2026`;
21
21
  }
22
+
22
23
  export {
23
24
  titleFromPrompt
24
25
  };
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  isOrchestratorThread
3
- } from "./chunk-BYRZS2S2.js";
3
+ } from "./chunk-X2OTZ36G.js";
4
4
  import {
5
5
  codexUnattendedGitConfigArgs,
6
6
  mergeAgentGitAuthEnv,
7
7
  resolveAgentGitAuthEnv,
8
8
  resolveCodexGitWritableRoots
9
- } from "./chunk-63YSFXLT.js";
9
+ } from "./chunk-U3AOJLH3.js";
10
10
  import {
11
11
  applyConnectedTeamToCli,
12
12
  brightsyMcpServerName,
13
13
  ensureCliTeamTracked,
14
14
  ensureConnectedBrightsyTeamTokens
15
- } from "./chunk-5F4YFGHL.js";
15
+ } from "./chunk-LDXSAVWO.js";
16
16
  import {
17
17
  loadBrightsyConfig
18
18
  } from "./chunk-ROPGQRPU.js";
@@ -36,7 +36,14 @@ import {
36
36
  packagedMcpStdioPath,
37
37
  parseCursorRunnerLine,
38
38
  resolveNodeLaunch
39
- } from "./chunk-VVHHBOIA.js";
39
+ } from "./chunk-WV7KJH2E.js";
40
+ import {
41
+ enrichPathWithNpmGlobalBin,
42
+ isConductorBundledCli,
43
+ resolveCommandBinarySync,
44
+ run,
45
+ withExportedPath
46
+ } from "./chunk-QVN2WOKJ.js";
40
47
  import {
41
48
  claudeChromeEnabled,
42
49
  fromInclusiveInputUsage,
@@ -45,21 +52,14 @@ import {
45
52
  loadAppSettings,
46
53
  resolveAgentExecutable,
47
54
  resolveClaudeExecutable
48
- } from "./chunk-KJM3E3NF.js";
49
- import {
50
- appDataDir
51
- } from "./chunk-EHT2DRT4.js";
52
- import {
53
- enrichPathWithNpmGlobalBin,
54
- isConductorBundledCli,
55
- resolveCommandBinarySync,
56
- run,
57
- withExportedPath
58
- } from "./chunk-QVN2WOKJ.js";
55
+ } from "./chunk-6PFZ6XO7.js";
59
56
  import {
60
57
  isElectronLikeCommand,
61
58
  unwrapStrippedElectronLaunch
62
59
  } from "./chunk-4TR3HZFT.js";
60
+ import {
61
+ appDataDir
62
+ } from "./chunk-EHT2DRT4.js";
63
63
 
64
64
  // src/agents/brightsy.ts
65
65
  import { existsSync } from "fs";
@@ -2561,7 +2561,7 @@ var claudeAdapter = {
2561
2561
  );
2562
2562
  }
2563
2563
  const mode = permissionMode(thread);
2564
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-4JCITHB6.js");
2564
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-47NZVA44.js");
2565
2565
  const isOrchestrator = isOrchestratorThread2(thread);
2566
2566
  const injectedServers = await buildInjectedMcpServers({
2567
2567
  includeSideboard: true,
@@ -4145,6 +4145,18 @@ var errorUntil = 0;
4145
4145
  var inflight = null;
4146
4146
  var lastGood = null;
4147
4147
  var claudeVersion = null;
4148
+ var cacheDirKey = "";
4149
+ function usageCacheDir(opts) {
4150
+ return opts.configDir?.trim() || "";
4151
+ }
4152
+ function adoptCacheDir(dir) {
4153
+ if (dir === cacheDirKey) return;
4154
+ cache = null;
4155
+ lastGood = null;
4156
+ errorUntil = 0;
4157
+ inflight = null;
4158
+ cacheDirKey = dir;
4159
+ }
4148
4160
  function accessTokenFromCredentialsJson(raw) {
4149
4161
  const trimmed = raw.trim();
4150
4162
  if (!trimmed) return null;
@@ -4161,12 +4173,12 @@ function accessTokenFromCredentialsJson(raw) {
4161
4173
  return null;
4162
4174
  }
4163
4175
  }
4164
- function claudeCredentialsPath() {
4165
- const root = process.env.CLAUDE_CONFIG_DIR?.trim() || join6(homedir4(), ".claude");
4176
+ function claudeCredentialsPath(configDir) {
4177
+ const root = configDir?.trim() || process.env.CLAUDE_CONFIG_DIR?.trim() || join6(homedir4(), ".claude");
4166
4178
  return join6(root, ".credentials.json");
4167
4179
  }
4168
- async function readFileAccessToken() {
4169
- const path = claudeCredentialsPath();
4180
+ async function readFileAccessToken(configDir) {
4181
+ const path = claudeCredentialsPath(configDir);
4170
4182
  if (!existsSync9(path)) return null;
4171
4183
  try {
4172
4184
  return accessTokenFromCredentialsJson(readFileSync4(path, "utf8"));
@@ -4174,25 +4186,31 @@ async function readFileAccessToken() {
4174
4186
  return null;
4175
4187
  }
4176
4188
  }
4177
- async function readKeychainAccessToken() {
4189
+ async function readKeychainAccessToken(configDir) {
4178
4190
  if (process.platform !== "darwin") return null;
4191
+ const root = configDir?.trim();
4192
+ const accounts = root ? [root, void 0] : [void 0];
4179
4193
  for (const service of KEYCHAIN_SERVICES) {
4180
- const result = await run("security", ["find-generic-password", "-s", service, "-w"], {
4181
- reject: false,
4182
- timeoutMs: 4e3
4183
- });
4184
- if (result.exitCode !== 0 || !result.stdout.trim()) continue;
4185
- const token = accessTokenFromCredentialsJson(result.stdout);
4186
- if (token) return token;
4194
+ for (const account of accounts) {
4195
+ const args = ["find-generic-password", "-s", service, "-w"];
4196
+ if (account) args.splice(3, 0, "-a", account);
4197
+ const result = await run("security", args, {
4198
+ reject: false,
4199
+ timeoutMs: 4e3
4200
+ });
4201
+ if (result.exitCode !== 0 || !result.stdout.trim()) continue;
4202
+ const token = accessTokenFromCredentialsJson(result.stdout);
4203
+ if (token) return token;
4204
+ }
4187
4205
  }
4188
4206
  return null;
4189
4207
  }
4190
- async function readClaudeAccessToken() {
4208
+ async function readClaudeAccessToken(configDir) {
4191
4209
  const envToken = process.env.CLAUDE_CODE_OAUTH_TOKEN?.trim();
4192
4210
  if (envToken) return envToken;
4193
- const fromFile = await readFileAccessToken();
4211
+ const fromFile = await readFileAccessToken(configDir);
4194
4212
  if (fromFile) return fromFile;
4195
- return readKeychainAccessToken();
4213
+ return readKeychainAccessToken(configDir);
4196
4214
  }
4197
4215
  async function resolveClaudeUserAgent() {
4198
4216
  if (claudeVersion) return `claude-code/${claudeVersion}`;
@@ -4217,6 +4235,7 @@ function reuseLast() {
4217
4235
  }
4218
4236
  async function getClaudePlanUsage(opts = {}) {
4219
4237
  const now = opts.now ?? Date.now();
4238
+ adoptCacheDir(usageCacheDir(opts));
4220
4239
  if (now < errorUntil) return reuseLast() ?? staleOk(now);
4221
4240
  if (!opts.force) {
4222
4241
  if (cache && now - cache.at < CLAUDE_USAGE_TTL_MS) return cache.value;
@@ -4224,9 +4243,9 @@ async function getClaudePlanUsage(opts = {}) {
4224
4243
  if (inflight) return inflight;
4225
4244
  inflight = (async () => {
4226
4245
  try {
4227
- const token = await (opts.readAccessToken ?? readClaudeAccessToken)();
4246
+ const token = await (opts.readAccessToken ?? (() => readClaudeAccessToken(opts.configDir)))();
4228
4247
  if (!token) {
4229
- cache = { at: now, value: null };
4248
+ cache = { at: now, dir: cacheDirKey, value: null };
4230
4249
  return null;
4231
4250
  }
4232
4251
  const fetchFn = opts.fetch ?? httpFetch;
@@ -4247,13 +4266,13 @@ async function getClaudePlanUsage(opts = {}) {
4247
4266
  clearTimeout(timer);
4248
4267
  }
4249
4268
  if (res.status === 401 || res.status === 403) {
4250
- cache = { at: now, value: null };
4269
+ cache = { at: now, dir: cacheDirKey, value: null };
4251
4270
  return null;
4252
4271
  }
4253
4272
  if (res.status === 429) {
4254
4273
  errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
4255
4274
  const last = reuseLast();
4256
- if (last) cache = { at: now, value: last };
4275
+ if (last) cache = { at: now, dir: cacheDirKey, value: last };
4257
4276
  return last;
4258
4277
  }
4259
4278
  if (!res.ok) {
@@ -4261,8 +4280,8 @@ async function getClaudePlanUsage(opts = {}) {
4261
4280
  return staleOk(now);
4262
4281
  }
4263
4282
  const usage = parseClaudeUsagePayload(await res.json(), new Date(now).toISOString());
4264
- cache = { at: now, value: usage };
4265
- if (usage) lastGood = { at: now, value: usage };
4283
+ cache = { at: now, dir: cacheDirKey, value: usage };
4284
+ if (usage) lastGood = { at: now, dir: cacheDirKey, value: usage };
4266
4285
  return usage;
4267
4286
  } catch {
4268
4287
  errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
@@ -4529,6 +4548,27 @@ async function loginAgent(agent) {
4529
4548
  message: `Opened Terminal to run: ${prepared}`
4530
4549
  };
4531
4550
  }
4551
+ async function loginManagedAccount(accountId) {
4552
+ const { loadAppSettings: loadAppSettings2 } = await import("./app-settings-VQEUCONM.js");
4553
+ const { loginEnvPrefix } = await import("./managed-accounts-2AK5RIAF.js");
4554
+ const account = loadAppSettings2().accounts.accounts.find((a) => a.id === accountId);
4555
+ if (!account) {
4556
+ return { ok: false, message: `Account not found: ${accountId}` };
4557
+ }
4558
+ const loginCommand = resolveLoginCommand(account.kind);
4559
+ if (!loginCommand) {
4560
+ return { ok: false, message: `No login command for ${account.kind}` };
4561
+ }
4562
+ const prepared = await prepareTerminalCommand(loginCommand);
4563
+ const prefixed = `${loginEnvPrefix(account)} && ${prepared}`;
4564
+ await openInSystemTerminal(prefixed);
4565
+ return {
4566
+ ok: true,
4567
+ openedTerminal: true,
4568
+ command: prefixed,
4569
+ message: `Opened Terminal to run: ${prefixed}`
4570
+ };
4571
+ }
4532
4572
 
4533
4573
  // src/agents/index.ts
4534
4574
  var adapters = {
@@ -4668,6 +4708,7 @@ export {
4668
4708
  installNpmGlobalPackage,
4669
4709
  installAgent,
4670
4710
  loginAgent,
4711
+ loginManagedAccount,
4671
4712
  getAdapter,
4672
4713
  allAdapters
4673
4714
  };
@@ -6,14 +6,14 @@ import {
6
6
  normalizeAbleTimeCredential,
7
7
  normalizeAbleTimeHost,
8
8
  rewriteAbleTimeError
9
- } from "./chunk-ZC3TVLY6.js";
9
+ } from "./chunk-5OKJDCBK.js";
10
10
  import {
11
11
  httpFetch
12
12
  } from "./chunk-VKQGAWHY.js";
13
13
  import {
14
14
  getAbleTimeAccessToken,
15
15
  getAbleTimeHost
16
- } from "./chunk-452Y24PW.js";
16
+ } from "./chunk-VIC6TDYT.js";
17
17
 
18
18
  // src/integrations/abletime-rest.ts
19
19
  var ABLETIME_REST_PREFIX = "/api/public/v2";