@sideboard-ai/core 0.1.311 → 0.1.313

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.
@@ -27,7 +27,7 @@ import {
27
27
  parseSessionQuotaResetAt,
28
28
  planModeTurnInstruction,
29
29
  resolveQuotaFallbackAgent
30
- } from "./chunk-GQJOLTZU.js";
30
+ } from "./chunk-2JOBQUUS.js";
31
31
  import {
32
32
  REVIEW_TAB_TITLE,
33
33
  applyWorktreePkgCacheEnv,
@@ -1500,6 +1500,15 @@ function thisProcessShouldDrainAgentQueues() {
1500
1500
  return !isDesktopHostAlive();
1501
1501
  }
1502
1502
 
1503
+ // src/mcp-ui/model-context.ts
1504
+ function takeMcpAppModelContext(threadId) {
1505
+ const thread = readThread(threadId);
1506
+ const text3 = thread?.mcpAppModelContext?.trim();
1507
+ if (!text3) return void 0;
1508
+ updateThread(threadId, { mcpAppModelContext: null });
1509
+ return text3;
1510
+ }
1511
+
1503
1512
  // src/agents/tool-permission.ts
1504
1513
  import { randomUUID } from "crypto";
1505
1514
  import { dirname } from "path";
@@ -6429,7 +6438,7 @@ function formatScheduledPrompt(name, prompt) {
6429
6438
  ${prompt}`;
6430
6439
  }
6431
6440
  async function defaultDeps() {
6432
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-3W5S6TNP.js");
6441
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-RRHB7RNN.js");
6433
6442
  const orch = getOrchestrator2();
6434
6443
  return {
6435
6444
  findThread: (id) => findThreadByRef(id),
@@ -7516,6 +7525,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
7516
7525
  orchestrationReminder,
7517
7526
  prGateDirective,
7518
7527
  injectedNoticeContext,
7528
+ takeMcpAppModelContext(threadId),
7519
7529
  expandedPrompt
7520
7530
  ].filter(Boolean).join("\n\n");
7521
7531
  if (!autoContinue && sentAttachments) {
@@ -5,27 +5,50 @@ import {
5
5
  } from "./chunk-2GPQZZLY.js";
6
6
 
7
7
  // src/brightsy/config.ts
8
- import { existsSync, readFileSync, writeFileSync } from "fs";
8
+ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
9
9
  import { homedir } from "os";
10
- import { join } from "path";
10
+ import { dirname, join } from "path";
11
+ function resolveBrightsyConfigFile(path) {
12
+ try {
13
+ if (existsSync(path) && statSync(path).isDirectory()) {
14
+ return join(path, "config.json");
15
+ }
16
+ } catch {
17
+ }
18
+ return path;
19
+ }
11
20
  function brightsyConfigPath() {
12
21
  const override = process.env.BRIGHTSY_CONFIG?.trim();
13
- if (override) return override;
14
- return join(homedir(), ".brightsy", "config.json");
22
+ const raw = override || join(homedir(), ".brightsy", "config.json");
23
+ return resolveBrightsyConfigFile(raw);
15
24
  }
16
25
  function loadBrightsyConfig() {
17
26
  const path = brightsyConfigPath();
18
27
  if (!existsSync(path)) {
19
28
  throw new Error("Brightsy not logged in \u2014 run `brightsy login` first");
20
29
  }
21
- const raw = JSON.parse(readFileSync(path, "utf8"));
30
+ let text;
31
+ try {
32
+ text = readFileSync(path, "utf8");
33
+ } catch (err) {
34
+ const code = err && typeof err === "object" && "code" in err ? String(err.code) : "";
35
+ if (code === "EISDIR") {
36
+ throw new Error(
37
+ `Brightsy config is a directory (${path}) \u2014 expected ~/.brightsy/config.json`
38
+ );
39
+ }
40
+ throw err;
41
+ }
42
+ const raw = JSON.parse(text);
22
43
  if (!raw.access_token || !raw.account_id) {
23
44
  throw new Error("Brightsy config incomplete \u2014 run `brightsy login`");
24
45
  }
25
46
  return raw;
26
47
  }
27
48
  function saveBrightsyConfig(cfg) {
28
- writeFileSync(brightsyConfigPath(), `${JSON.stringify(cfg, null, 2)}
49
+ const path = brightsyConfigPath();
50
+ mkdirSync(dirname(path), { recursive: true });
51
+ writeFileSync(path, `${JSON.stringify(cfg, null, 2)}
29
52
  `, {
30
53
  mode: 384
31
54
  });
@@ -5,7 +5,7 @@ import {
5
5
  loadBrightsyConfig,
6
6
  refreshBrightsyAccessToken,
7
7
  saveBrightsyConfig
8
- } from "./chunk-33KDPEK4.js";
8
+ } from "./chunk-RSA47QYR.js";
9
9
  import {
10
10
  run
11
11
  } from "./chunk-QVN2WOKJ.js";
@@ -19,7 +19,7 @@ import { join } from "path";
19
19
 
20
20
  // src/brightsy/accounts.ts
21
21
  async function loadConnectedTeams() {
22
- const { listConnectedBrightsyTeams: listConnectedBrightsyTeams2 } = await import("./connected-teams-BBNYTR3I.js");
22
+ const { listConnectedBrightsyTeams: listConnectedBrightsyTeams2 } = await import("./connected-teams-IHK2WXUI.js");
23
23
  return listConnectedBrightsyTeams2();
24
24
  }
25
25
  async function runBrightsyTeamsJson(args) {
@@ -47,15 +47,15 @@ async function listBrightsyAccounts() {
47
47
  }
48
48
  async function getBrightsySession() {
49
49
  try {
50
- const { ensureBrightsyLocalConfigFresh: ensureBrightsyLocalConfigFresh2 } = await import("./oauth-DP4ZV2M2.js");
51
- const { ensureConnectedBrightsyTeamTokens: ensureConnectedBrightsyTeamTokens2 } = await import("./connected-teams-BBNYTR3I.js");
50
+ const { ensureBrightsyLocalConfigFresh: ensureBrightsyLocalConfigFresh2 } = await import("./oauth-CR5FY4CJ.js");
51
+ const { ensureConnectedBrightsyTeamTokens: ensureConnectedBrightsyTeamTokens2 } = await import("./connected-teams-IHK2WXUI.js");
52
52
  await ensureBrightsyLocalConfigFresh2();
53
53
  await ensureConnectedBrightsyTeamTokens2();
54
54
  loadBrightsyConfig();
55
55
  const data = await runBrightsyTeamsJson([]);
56
56
  const accounts = Array.isArray(data.teams) ? data.teams : [];
57
57
  const active = data.active ?? accounts.find((a) => a.active) ?? null;
58
- const { ensureCliTeamTracked: ensureCliTeamTracked2 } = await import("./connected-teams-BBNYTR3I.js");
58
+ const { ensureCliTeamTracked: ensureCliTeamTracked2 } = await import("./connected-teams-IHK2WXUI.js");
59
59
  const connectedTeams = ensureCliTeamTracked2(
60
60
  active ? { id: active.id, slug: active.slug, name: active.name } : void 0
61
61
  );
@@ -95,7 +95,7 @@ async function performBrightsyAccountSwitch(accountIdOrSlug) {
95
95
  return { cfg, target: data.active };
96
96
  }
97
97
  async function switchBrightsyAccount(accountIdOrSlug) {
98
- const { connectBrightsyTeam: connectBrightsyTeam2 } = await import("./connected-teams-BBNYTR3I.js");
98
+ const { connectBrightsyTeam: connectBrightsyTeam2 } = await import("./connected-teams-IHK2WXUI.js");
99
99
  await connectBrightsyTeam2(accountIdOrSlug);
100
100
  return getBrightsySession();
101
101
  }
@@ -134,6 +134,25 @@ function listConnectedBrightsyTeams() {
134
134
  function getConnectedBrightsyTeamsRaw() {
135
135
  return readStore();
136
136
  }
137
+ function teamFromCliSession(cfg, current) {
138
+ return {
139
+ ...current,
140
+ access_token: cfg.access_token,
141
+ refresh_token: cfg.refresh_token ?? current.refresh_token,
142
+ expires_at: cfg.expires_at ?? current.expires_at,
143
+ endpoint: cfg.endpoint ?? current.endpoint,
144
+ oauth_client_id: cfg.oauth_client_id ?? current.oauth_client_id,
145
+ slug: cfg.account_slug || current.slug
146
+ };
147
+ }
148
+ function brightsySessionShouldReplace(a, b) {
149
+ if (!a.access_token) return false;
150
+ const aStale = brightsyAccessTokenNeedsRefresh(a.expires_at);
151
+ const bStale = !b.access_token || brightsyAccessTokenNeedsRefresh(b.expires_at);
152
+ if (!aStale && bStale) return true;
153
+ if (aStale) return false;
154
+ return (a.expires_at ?? 0) > (b.expires_at ?? 0);
155
+ }
137
156
  function applyConnectedTeamToCli(team) {
138
157
  let base = {};
139
158
  try {
@@ -220,22 +239,34 @@ async function ensureConnectedBrightsyTeamTokens(opts) {
220
239
  }
221
240
  next.push(refreshed);
222
241
  }
223
- if (changed) writeStore(next);
224
242
  try {
225
243
  const cfg2 = loadBrightsyConfig();
226
- const active = next.find((t) => t.id === cfg2.account_id);
227
- if (active && active.access_token !== cfg2.access_token) {
228
- applyConnectedTeamToCli(active);
244
+ const idx = next.findIndex((t) => t.id === cfg2.account_id);
245
+ if (idx >= 0) {
246
+ const active = next[idx];
247
+ if (brightsySessionShouldReplace(cfg2, active)) {
248
+ next[idx] = teamFromCliSession(cfg2, active);
249
+ changed = true;
250
+ } else if (active.access_token !== cfg2.access_token) {
251
+ applyConnectedTeamToCli(active);
252
+ }
229
253
  }
230
254
  } catch {
231
255
  }
256
+ if (changed) writeStore(next);
232
257
  return next;
233
258
  }
234
259
  function ensureCliTeamTracked(meta) {
235
260
  try {
236
261
  const cfg = loadBrightsyConfig();
237
262
  const existing = readStore();
238
- if (existing.some((t) => t.id === cfg.account_id)) {
263
+ const idx = existing.findIndex((t) => t.id === cfg.account_id);
264
+ if (idx >= 0) {
265
+ const current = existing[idx];
266
+ if (brightsySessionShouldReplace(cfg, current)) {
267
+ existing[idx] = teamFromCliSession(cfg, current);
268
+ writeStore(existing);
269
+ }
239
270
  return listConnectedBrightsyTeams();
240
271
  }
241
272
  const team = {
@@ -312,6 +343,7 @@ export {
312
343
  switchBrightsyAccount,
313
344
  listConnectedBrightsyTeams,
314
345
  getConnectedBrightsyTeamsRaw,
346
+ brightsySessionShouldReplace,
315
347
  applyConnectedTeamToCli,
316
348
  ensureConnectedBrightsyTeamTokens,
317
349
  ensureCliTeamTracked,
@@ -3,27 +3,50 @@ import {
3
3
  } from "./chunk-JAT3JFOS.js";
4
4
 
5
5
  // src/brightsy/config.ts
6
- import { existsSync, readFileSync, writeFileSync } from "fs";
6
+ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
7
7
  import { homedir } from "os";
8
- import { join } from "path";
8
+ import { dirname, join } from "path";
9
+ function resolveBrightsyConfigFile(path) {
10
+ try {
11
+ if (existsSync(path) && statSync(path).isDirectory()) {
12
+ return join(path, "config.json");
13
+ }
14
+ } catch {
15
+ }
16
+ return path;
17
+ }
9
18
  function brightsyConfigPath() {
10
19
  const override = process.env.BRIGHTSY_CONFIG?.trim();
11
- if (override) return override;
12
- return join(homedir(), ".brightsy", "config.json");
20
+ const raw = override || join(homedir(), ".brightsy", "config.json");
21
+ return resolveBrightsyConfigFile(raw);
13
22
  }
14
23
  function loadBrightsyConfig() {
15
24
  const path = brightsyConfigPath();
16
25
  if (!existsSync(path)) {
17
26
  throw new Error("Brightsy not logged in \u2014 run `brightsy login` first");
18
27
  }
19
- const raw = JSON.parse(readFileSync(path, "utf8"));
28
+ let text;
29
+ try {
30
+ text = readFileSync(path, "utf8");
31
+ } catch (err) {
32
+ const code = err && typeof err === "object" && "code" in err ? String(err.code) : "";
33
+ if (code === "EISDIR") {
34
+ throw new Error(
35
+ `Brightsy config is a directory (${path}) \u2014 expected ~/.brightsy/config.json`
36
+ );
37
+ }
38
+ throw err;
39
+ }
40
+ const raw = JSON.parse(text);
20
41
  if (!raw.access_token || !raw.account_id) {
21
42
  throw new Error("Brightsy config incomplete \u2014 run `brightsy login`");
22
43
  }
23
44
  return raw;
24
45
  }
25
46
  function saveBrightsyConfig(cfg) {
26
- writeFileSync(brightsyConfigPath(), `${JSON.stringify(cfg, null, 2)}
47
+ const path = brightsyConfigPath();
48
+ mkdirSync(dirname(path), { recursive: true });
49
+ writeFileSync(path, `${JSON.stringify(cfg, null, 2)}
27
50
  `, {
28
51
  mode: 384
29
52
  });