@sideboard-ai/core 0.1.44 → 0.1.45

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.
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  cursorSdkMessageToEvents,
4
4
  formatUnknownDetail
5
- } from "../chunk-PU27NUO4.js";
5
+ } from "../chunk-J5JTEJ5O.js";
6
6
  import {
7
7
  appDataDir
8
8
  } from "../chunk-M37RITA6.js";
@@ -1,4 +1,5 @@
1
1
  import {
2
+ CLAUDE_MODEL_CATALOG,
2
3
  PLAN_MODE_INSTRUCTION,
3
4
  allAdapters,
4
5
  brightsyAdapter,
@@ -11,29 +12,34 @@ import {
11
12
  getAgentSetupInfo,
12
13
  installAgent,
13
14
  isCursorAutoModel,
15
+ isSessionQuotaLimit,
14
16
  listAgentSetupInfo,
15
17
  listBrightsyChatTargets,
16
18
  listCodexModels,
17
19
  listCursorModels,
20
+ listModelsForAgent,
18
21
  listOpencodeModels,
19
22
  loginAgent,
20
23
  openInSystemTerminal,
21
24
  opencodeAdapter,
25
+ parseSessionQuotaResetAt,
22
26
  permissionMode,
23
- resolveCursorModelId
24
- } from "./chunk-XX26NCB6.js";
27
+ resolveCursorModelId,
28
+ resolveQuotaFallbackAgent
29
+ } from "./chunk-ANZ566Z5.js";
25
30
  import "./chunk-ILQK4P5R.js";
26
31
  import {
27
32
  cursorSdkMessageToEvents,
28
33
  parseCursorRunnerLine
29
- } from "./chunk-PU27NUO4.js";
30
- import "./chunk-FSIK442J.js";
34
+ } from "./chunk-J5JTEJ5O.js";
35
+ import "./chunk-WYY3J7GR.js";
31
36
  import "./chunk-77WWLBCI.js";
32
37
  import "./chunk-M37RITA6.js";
33
38
  import {
34
39
  ensureAgentPath
35
40
  } from "./chunk-AJ6ROGD7.js";
36
41
  export {
42
+ CLAUDE_MODEL_CATALOG,
37
43
  PLAN_MODE_INSTRUCTION,
38
44
  allAdapters,
39
45
  brightsyAdapter,
@@ -48,15 +54,19 @@ export {
48
54
  getAgentSetupInfo,
49
55
  installAgent,
50
56
  isCursorAutoModel,
57
+ isSessionQuotaLimit,
51
58
  listAgentSetupInfo,
52
59
  listBrightsyChatTargets,
53
60
  listCodexModels,
54
61
  listCursorModels,
62
+ listModelsForAgent,
55
63
  listOpencodeModels,
56
64
  loginAgent,
57
65
  openInSystemTerminal,
58
66
  opencodeAdapter,
59
67
  parseCursorRunnerLine,
68
+ parseSessionQuotaResetAt,
60
69
  permissionMode,
61
- resolveCursorModelId
70
+ resolveCursorModelId,
71
+ resolveQuotaFallbackAgent
62
72
  };
@@ -23,6 +23,8 @@ import {
23
23
  isLinearConnected,
24
24
  loadAppSettings,
25
25
  maxConcurrentAgents,
26
+ orchestrationQuotaFallbackAgent,
27
+ orchestrationQuotaOnLimit,
26
28
  resolveClaudeExecutable,
27
29
  resolveEffectiveIssueSource,
28
30
  resolveThreadDefaults,
@@ -33,7 +35,7 @@ import {
33
35
  updateClaudeSettings,
34
36
  updateDefaultsSettings,
35
37
  updateIntegrationsSettings
36
- } from "./chunk-FSIK442J.js";
38
+ } from "./chunk-WYY3J7GR.js";
37
39
  import "./chunk-77WWLBCI.js";
38
40
  import "./chunk-M37RITA6.js";
39
41
  export {
@@ -61,6 +63,8 @@ export {
61
63
  isLinearConnected,
62
64
  loadAppSettings,
63
65
  maxConcurrentAgents,
66
+ orchestrationQuotaFallbackAgent,
67
+ orchestrationQuotaOnLimit,
64
68
  resolveClaudeExecutable,
65
69
  resolveEffectiveIssueSource,
66
70
  resolveThreadDefaults,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveGithubRepoSlug
3
- } from "./chunk-7PCTK4WO.js";
3
+ } from "./chunk-FV6FN6V5.js";
4
4
  import {
5
5
  globalAgentCwd,
6
6
  sideboardReposDir
@@ -42,11 +42,14 @@ var COORDINATOR_TOOL_PLAYBOOK = [
42
42
  "Discover:",
43
43
  "- list_workspaces \u2014 registered repos (path + github slug when known)",
44
44
  "- list_branches / list_prs / list_issues \u2014 pass repoPath from list_workspaces (issues: Linear API or GitHub Issues)",
45
+ "- list_models \u2014 only when you need a specific model (rare); otherwise leave model unset = Auto",
45
46
  "- list_threads / get_thread \u2014 fleet status (what is going on)",
46
47
  "Workspaces:",
47
48
  "- add_workspace / remove_workspace \u2014 register or unregister a git repo",
48
49
  "Worktree threads (chats):",
49
50
  "- create_thread \u2014 create a worktree + chat from branch | pr | ticket; pass repoPath + parentThreadId",
51
+ "- fork_worktree \u2014 fork a worktree chat into a NEW git worktree + chat (transcript attached); optional agent; leave model unset (Auto) unless you have a reason. Not for orchestration chats.",
52
+ "- fork_chat \u2014 fork a worktree chat (same worktree tab) OR a Global orchestration chat (new orchestration tab); optional agent; leave model unset (Auto) unless you have a reason. Remote coordinators: use this to continue another orchestration chat on a different agent after session limits.",
50
53
  "- send_to_thread \u2014 queue a prompt (start/continue a chat turn); pass force_stop: true to interrupt mid-turn / clear stale queued prompts before replacing with a new request",
51
54
  "- wait_for_turn / get_turn_result \u2014 wait for and read the agent reply",
52
55
  "- stop_thread \u2014 force-stop: kill in-flight turn AND clear queued prompts (do not leave stale queue after an interrupt)",
@@ -10,12 +10,12 @@ import {
10
10
  formatUnknownDetail,
11
11
  looksLikeAgentFailureMessage,
12
12
  parseCursorRunnerLine
13
- } from "./chunk-PU27NUO4.js";
13
+ } from "./chunk-J5JTEJ5O.js";
14
14
  import {
15
15
  claudeChromeEnabled,
16
16
  loadAppSettings,
17
17
  resolveClaudeExecutable
18
- } from "./chunk-FSIK442J.js";
18
+ } from "./chunk-WYY3J7GR.js";
19
19
  import {
20
20
  ensureAgentPath,
21
21
  run
@@ -798,7 +798,7 @@ var claudeAdapter = {
798
798
  );
799
799
  }
800
800
  const mode = permissionMode(thread);
801
- const { isOrchestratorThread } = await import("./global-workspace-FU6UIPDY.js");
801
+ const { isOrchestratorThread } = await import("./global-workspace-YFOQUGWD.js");
802
802
  const isOrchestrator = isOrchestratorThread(thread);
803
803
  const injectedServers = await buildInjectedMcpServers({
804
804
  includeSideboard: true,
@@ -1616,6 +1616,182 @@ var opencodeAdapter = {
1616
1616
  }
1617
1617
  };
1618
1618
 
1619
+ // src/agents/list-models.ts
1620
+ var CLAUDE_MODEL_CATALOG = [
1621
+ { id: "fable", displayName: "Fable" },
1622
+ { id: "opus", displayName: "Opus" },
1623
+ { id: "sonnet", displayName: "Sonnet" },
1624
+ { id: "haiku", displayName: "Haiku" }
1625
+ ];
1626
+ async function listBrightsyModels() {
1627
+ try {
1628
+ const targets = await listBrightsyChatTargets();
1629
+ const accountId = targets.activeAccountId;
1630
+ const models = (targets.models ?? []).map((m) => ({
1631
+ id: encodeBrightsyTarget("model", m.id, accountId),
1632
+ displayName: m.name || m.id,
1633
+ description: m.description ?? void 0
1634
+ }));
1635
+ const agents = (targets.agents ?? []).map((a) => ({
1636
+ id: encodeBrightsyTarget("agent", a.id, accountId),
1637
+ displayName: a.name || a.id,
1638
+ description: a.description ?? "Brightsy agent target"
1639
+ }));
1640
+ return [...models, ...agents].slice(0, 80);
1641
+ } catch {
1642
+ return [];
1643
+ }
1644
+ }
1645
+ async function listModelsForAgent(agent) {
1646
+ const kinds = agent ? [agent] : ["claude", "codex", "opencode", "cursor", "brightsy"];
1647
+ const out = [];
1648
+ for (const kind of kinds) {
1649
+ if (kind === "claude") {
1650
+ out.push({
1651
+ agent: kind,
1652
+ auto: true,
1653
+ models: CLAUDE_MODEL_CATALOG,
1654
+ note: "Default Auto \u2014 only pass a model id when you have a reason."
1655
+ });
1656
+ continue;
1657
+ }
1658
+ if (kind === "codex") {
1659
+ out.push({
1660
+ agent: kind,
1661
+ auto: true,
1662
+ models: await listCodexModels(),
1663
+ note: "Default Auto \u2014 only pass a model slug when you have a reason."
1664
+ });
1665
+ continue;
1666
+ }
1667
+ if (kind === "opencode") {
1668
+ out.push({
1669
+ agent: kind,
1670
+ auto: true,
1671
+ models: await listOpencodeModels(),
1672
+ note: "Default Auto \u2014 only pass a provider/model id when you have a reason."
1673
+ });
1674
+ continue;
1675
+ }
1676
+ if (kind === "cursor") {
1677
+ out.push({
1678
+ agent: kind,
1679
+ auto: true,
1680
+ models: await listCursorModels(),
1681
+ note: 'Default Auto \u2014 only pass a model id when you have a reason (or use "default").'
1682
+ });
1683
+ continue;
1684
+ }
1685
+ if (kind === "brightsy") {
1686
+ const models = await listBrightsyModels();
1687
+ out.push({
1688
+ agent: kind,
1689
+ auto: true,
1690
+ models,
1691
+ note: models.length ? "Default Auto / Default agent \u2014 only pass a model/agent id when you have a reason." : "Brightsy not logged in or no targets \u2014 leave model unset for Default."
1692
+ });
1693
+ }
1694
+ }
1695
+ return out;
1696
+ }
1697
+
1698
+ // src/agents/session-quota.ts
1699
+ function isSessionQuotaLimit(text) {
1700
+ const lower = text.trim().toLowerCase();
1701
+ if (!lower) return false;
1702
+ if (/credit balance is too low|out of credits|insufficient.?quota|billing/.test(lower)) {
1703
+ return false;
1704
+ }
1705
+ if (/prompt is too long|context.*(too long|exceed)|conversation too long/.test(lower)) {
1706
+ return false;
1707
+ }
1708
+ return /you've hit your/.test(lower) || /hit your (session|weekly|opus) limit/.test(lower) || /usage limit/.test(lower) || /rate.?limit|too many requests|\b429\b/.test(lower) && /reset/i.test(text);
1709
+ }
1710
+ function parseSessionQuotaResetAt(text, now = /* @__PURE__ */ new Date()) {
1711
+ const absolute = text.match(
1712
+ /resets\s+(?:at\s+)?(\d{1,2}):(\d{2})\s*(am|pm)(?:\s*\(([^)]+)\))?/i
1713
+ );
1714
+ if (absolute) {
1715
+ const hour12 = Number(absolute[1]);
1716
+ const minute = Number(absolute[2]);
1717
+ const ampm = absolute[3].toLowerCase();
1718
+ const timeZone = absolute[4]?.trim() || Intl.DateTimeFormat().resolvedOptions().timeZone;
1719
+ let hour = hour12 % 12;
1720
+ if (ampm === "pm") hour += 12;
1721
+ const at = zonedWallTimeToUtc(now, hour, minute, timeZone);
1722
+ if (!at) return null;
1723
+ if (at.getTime() <= now.getTime() + 3e4) {
1724
+ const tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1e3);
1725
+ return zonedWallTimeToUtc(tomorrow, hour, minute, timeZone);
1726
+ }
1727
+ return at;
1728
+ }
1729
+ const relative = text.match(
1730
+ /resets\s+in\s+(\d+)\s*(minutes?|hours?|days?)/i
1731
+ );
1732
+ if (relative) {
1733
+ const n = Number(relative[1]);
1734
+ const unit = relative[2].toLowerCase();
1735
+ const ms = unit.startsWith("day") ? n * 24 * 60 * 60 * 1e3 : unit.startsWith("hour") ? n * 60 * 60 * 1e3 : n * 60 * 1e3;
1736
+ return new Date(now.getTime() + ms);
1737
+ }
1738
+ return null;
1739
+ }
1740
+ function zonedWallTimeToUtc(day, hour, minute, timeZone) {
1741
+ try {
1742
+ const cal = new Intl.DateTimeFormat("en-US", {
1743
+ timeZone,
1744
+ year: "numeric",
1745
+ month: "2-digit",
1746
+ day: "2-digit"
1747
+ });
1748
+ const parts = Object.fromEntries(
1749
+ cal.formatToParts(day).filter((p) => p.type !== "literal").map((p) => [p.type, p.value])
1750
+ );
1751
+ const year = Number(parts.year);
1752
+ const month = Number(parts.month);
1753
+ const date = Number(parts.day);
1754
+ if (![year, month, date].every((n) => Number.isFinite(n))) return null;
1755
+ const utcGuess = Date.UTC(year, month - 1, date, hour, minute, 0);
1756
+ const dtf = new Intl.DateTimeFormat("en-US", {
1757
+ timeZone,
1758
+ year: "numeric",
1759
+ month: "2-digit",
1760
+ day: "2-digit",
1761
+ hour: "2-digit",
1762
+ minute: "2-digit",
1763
+ second: "2-digit",
1764
+ hourCycle: "h23"
1765
+ });
1766
+ const asParts = Object.fromEntries(
1767
+ dtf.formatToParts(new Date(utcGuess)).filter((p) => p.type !== "literal").map((p) => [p.type, p.value])
1768
+ );
1769
+ const asUtc = Date.UTC(
1770
+ Number(asParts.year),
1771
+ Number(asParts.month) - 1,
1772
+ Number(asParts.day),
1773
+ Number(asParts.hour),
1774
+ Number(asParts.minute),
1775
+ Number(asParts.second || "0")
1776
+ );
1777
+ const offset = asUtc - utcGuess;
1778
+ return new Date(utcGuess - offset);
1779
+ } catch {
1780
+ return null;
1781
+ }
1782
+ }
1783
+ var FALLBACK_ORDER = [
1784
+ "cursor",
1785
+ "codex",
1786
+ "opencode",
1787
+ "brightsy",
1788
+ "claude"
1789
+ ];
1790
+ function resolveQuotaFallbackAgent(current, preferred) {
1791
+ const ordered = preferred ? [preferred, ...FALLBACK_ORDER.filter((a) => a !== preferred)] : FALLBACK_ORDER;
1792
+ return ordered.find((a) => a !== current) ?? (current === "cursor" ? "codex" : "cursor");
1793
+ }
1794
+
1619
1795
  // src/agents/install.ts
1620
1796
  var SETUP = {
1621
1797
  claude: {
@@ -1833,6 +2009,11 @@ export {
1833
2009
  cursorAdapter,
1834
2010
  listOpencodeModels,
1835
2011
  opencodeAdapter,
2012
+ CLAUDE_MODEL_CATALOG,
2013
+ listModelsForAgent,
2014
+ isSessionQuotaLimit,
2015
+ parseSessionQuotaResetAt,
2016
+ resolveQuotaFallbackAgent,
1836
2017
  getAgentSetupInfo,
1837
2018
  listAgentSetupInfo,
1838
2019
  openInSystemTerminal,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  listThreads
3
- } from "./chunk-ENSD62HW.js";
3
+ } from "./chunk-O6W3P7V3.js";
4
4
  import {
5
5
  worktreesRoot
6
6
  } from "./chunk-M37RITA6.js";