@sideboard-ai/core 0.1.44 → 0.1.46
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.
- package/dist/agents/cursor-runner.cjs +11 -4
- package/dist/agents/cursor-runner.js +12 -5
- package/dist/{agents-PP3URTSF.js → agents-6L6VENDT.js} +25 -5
- package/dist/{app-settings-ZKVZHJPQ.js → app-settings-LZP632KI.js} +5 -1
- package/dist/{chunk-JM2TVGNW.js → chunk-6NAPN2N5.js} +4 -1
- package/dist/{chunk-V3S4NF5F.js → chunk-7DTJFP4D.js} +406 -30
- package/dist/{chunk-7PCTK4WO.js → chunk-FV6FN6V5.js} +1 -1
- package/dist/chunk-GI7E5733.js +30 -0
- package/dist/{chunk-PU27NUO4.js → chunk-J5JTEJ5O.js} +7 -2
- package/dist/{chunk-ENSD62HW.js → chunk-O6W3P7V3.js} +3 -1
- package/dist/{chunk-I3PKMLFW.js → chunk-SPCU3MFY.js} +8 -4
- package/dist/{chunk-TXFJEXFB.js → chunk-SZAKJ4TR.js} +2 -2
- package/dist/{chunk-FSIK442J.js → chunk-T5QQVXK3.js} +24 -0
- package/dist/{chunk-XX26NCB6.js → chunk-TQK2OYPU.js} +246 -6
- package/dist/{coordinator-prompt-I5YNS27B.js → coordinator-prompt-2XFYG3C5.js} +3 -3
- package/dist/{global-workspace-FU6UIPDY.js → global-workspace-XFOXEQCP.js} +5 -4
- package/dist/index.cjs +747 -18
- package/dist/index.d.cts +96 -2
- package/dist/index.d.ts +96 -2
- package/dist/index.js +33 -9
- package/dist/mcp/run-stdio.cjs +737 -28
- package/dist/mcp/run-stdio.js +10 -9
- package/dist/{thread-store-EHROA3VZ.js → thread-store-OV2X6PYO.js} +1 -1
- package/dist/{workspaces-RSEDTBGJ.js → workspaces-SRL2HZTB.js} +6 -5
- package/dist/{worktree-N4PRV4V3.js → worktree-TEDAJ57S.js} +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/agents/orchestrator-capable.ts
|
|
2
|
+
var ORCHESTRATOR_AGENT_KINDS = [
|
|
3
|
+
"claude",
|
|
4
|
+
"codex",
|
|
5
|
+
"opencode",
|
|
6
|
+
"cursor"
|
|
7
|
+
];
|
|
8
|
+
function isOrchestratorCapableAgent(agent) {
|
|
9
|
+
return Boolean(
|
|
10
|
+
agent && ORCHESTRATOR_AGENT_KINDS.includes(agent)
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
function assertOrchestratorCapableAgent(agent, context = "orchestration") {
|
|
14
|
+
if (!isOrchestratorCapableAgent(agent)) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`${agent} cannot run ${context} \u2014 it does not support Sideboard MCP. Use Claude, Cursor, Codex, or OpenCode.`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return agent;
|
|
20
|
+
}
|
|
21
|
+
function coerceOrchestratorAgent(agent, fallback = "claude") {
|
|
22
|
+
return isOrchestratorCapableAgent(agent) ? agent : fallback;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
ORCHESTRATOR_AGENT_KINDS,
|
|
27
|
+
isOrchestratorCapableAgent,
|
|
28
|
+
assertOrchestratorCapableAgent,
|
|
29
|
+
coerceOrchestratorAgent
|
|
30
|
+
};
|
|
@@ -102,11 +102,15 @@ function humanizeAgentFailDetail(detail) {
|
|
|
102
102
|
}
|
|
103
103
|
function formatTurnExitError(exitCode, stderrSummary) {
|
|
104
104
|
const code = exitCode ?? 1;
|
|
105
|
-
const
|
|
105
|
+
const raw = stderrSummary.trim();
|
|
106
|
+
if (/^exit\s*\d+$/i.test(raw)) {
|
|
107
|
+
return `exit ${code}: agent exited without details (credits, auth, rate limits, or a CLI error)`;
|
|
108
|
+
}
|
|
109
|
+
const detail = humanizeAgentFailDetail(raw);
|
|
106
110
|
if (!detail) {
|
|
107
111
|
return `exit ${code}: agent exited without details (credits, auth, rate limits, or a CLI error)`;
|
|
108
112
|
}
|
|
109
|
-
if (looksLikeAgentFailureMessage(
|
|
113
|
+
if (looksLikeAgentFailureMessage(raw)) return detail;
|
|
110
114
|
return `exit ${code}: ${detail}`;
|
|
111
115
|
}
|
|
112
116
|
|
|
@@ -210,6 +214,7 @@ export {
|
|
|
210
214
|
summarizeTurnStderr,
|
|
211
215
|
looksLikeAgentFailureMessage,
|
|
212
216
|
fallbackTurnFailDetail,
|
|
217
|
+
humanizeAgentFailDetail,
|
|
213
218
|
formatTurnExitError,
|
|
214
219
|
cursorSdkMessageToEvents,
|
|
215
220
|
parseCursorRunnerLine
|
|
@@ -40,7 +40,9 @@ function normalizeThread(raw) {
|
|
|
40
40
|
attachments: Array.isArray(raw.attachments) ? raw.attachments : [],
|
|
41
41
|
prTitle: raw.prTitle ?? null,
|
|
42
42
|
userSetTitle: Boolean(raw.userSetTitle),
|
|
43
|
-
activeRuns: Array.isArray(raw.activeRuns) ? raw.activeRuns : []
|
|
43
|
+
activeRuns: Array.isArray(raw.activeRuns) ? raw.activeRuns : [],
|
|
44
|
+
quotaResumeAt: raw.quotaResumeAt ?? null,
|
|
45
|
+
quotaContinuedFromId: raw.quotaContinuedFromId ?? null
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
function createEmptyThread(partial) {
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureGlobalCoordinatorCwd
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6NAPN2N5.js";
|
|
4
|
+
import {
|
|
5
|
+
assertOrchestratorCapableAgent
|
|
6
|
+
} from "./chunk-GI7E5733.js";
|
|
4
7
|
import {
|
|
5
8
|
allocateTeamName,
|
|
6
9
|
takenSlugsFromThread,
|
|
7
10
|
teamSlugFromName
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FV6FN6V5.js";
|
|
9
12
|
import {
|
|
10
13
|
createEmptyThread,
|
|
11
14
|
listThreads,
|
|
12
15
|
updateThread,
|
|
13
16
|
writeThread
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-O6W3P7V3.js";
|
|
15
18
|
import {
|
|
16
19
|
globalAgentCwd
|
|
17
20
|
} from "./chunk-M37RITA6.js";
|
|
@@ -110,6 +113,7 @@ function createGlobalChat(opts) {
|
|
|
110
113
|
const explicit = opts.title?.trim();
|
|
111
114
|
const title = explicit && explicit !== CLOUD_ORCHESTRATOR_GOAL ? explicit : allocateTeamName(takenTeamSlugsForOrchestration()).name;
|
|
112
115
|
const sourceRef = opts.sourceRef?.trim() || (isCloud ? CLOUD_ORCHESTRATOR_GOAL : title);
|
|
116
|
+
const agent = assertOrchestratorCapableAgent(opts.agent);
|
|
113
117
|
const thread = createEmptyThread({
|
|
114
118
|
title,
|
|
115
119
|
// Stick nicknames the same way chat tabs do (avoid later sync overwrites).
|
|
@@ -119,7 +123,7 @@ function createGlobalChat(opts) {
|
|
|
119
123
|
branchName: "global",
|
|
120
124
|
worktreePath: globalAgentCwd(),
|
|
121
125
|
repoPath: GLOBAL_WORKSPACE_ID,
|
|
122
|
-
agent
|
|
126
|
+
agent,
|
|
123
127
|
autonomy: opts.autonomy ?? "default",
|
|
124
128
|
model: opts.model ?? null,
|
|
125
129
|
effort: opts.effort ?? "high",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isGlobalRepoPath
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SPCU3MFY.js";
|
|
4
4
|
import {
|
|
5
5
|
ensureGhPreferOrigin,
|
|
6
6
|
resolveRepoRoot
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FV6FN6V5.js";
|
|
8
8
|
import {
|
|
9
9
|
appDataDir
|
|
10
10
|
} from "./chunk-M37RITA6.js";
|
|
@@ -130,6 +130,12 @@ function normalizeAdvanced(raw) {
|
|
|
130
130
|
if (typeof source.autoCleanupOrphans === "boolean") {
|
|
131
131
|
out.autoCleanupOrphans = source.autoCleanupOrphans;
|
|
132
132
|
}
|
|
133
|
+
if (source.orchestrationQuotaOnLimit === "switch_agent" || source.orchestrationQuotaOnLimit === "wait_reset") {
|
|
134
|
+
out.orchestrationQuotaOnLimit = source.orchestrationQuotaOnLimit;
|
|
135
|
+
}
|
|
136
|
+
if (typeof source.orchestrationQuotaFallbackAgent === "string" && DEFAULT_AGENTS.has(source.orchestrationQuotaFallbackAgent) && source.orchestrationQuotaFallbackAgent !== "brightsy") {
|
|
137
|
+
out.orchestrationQuotaFallbackAgent = source.orchestrationQuotaFallbackAgent;
|
|
138
|
+
}
|
|
133
139
|
return out;
|
|
134
140
|
}
|
|
135
141
|
function normalizeSettings(raw) {
|
|
@@ -372,6 +378,12 @@ function updateAdvancedSettings(patch) {
|
|
|
372
378
|
if (typeof patch.autoCleanupOrphans === "boolean") {
|
|
373
379
|
advanced.autoCleanupOrphans = patch.autoCleanupOrphans;
|
|
374
380
|
}
|
|
381
|
+
if (patch.orchestrationQuotaOnLimit === "switch_agent" || patch.orchestrationQuotaOnLimit === "wait_reset") {
|
|
382
|
+
advanced.orchestrationQuotaOnLimit = patch.orchestrationQuotaOnLimit;
|
|
383
|
+
}
|
|
384
|
+
if (typeof patch.orchestrationQuotaFallbackAgent === "string" && DEFAULT_AGENTS.has(patch.orchestrationQuotaFallbackAgent) && patch.orchestrationQuotaFallbackAgent !== "brightsy") {
|
|
385
|
+
advanced.orchestrationQuotaFallbackAgent = patch.orchestrationQuotaFallbackAgent;
|
|
386
|
+
}
|
|
375
387
|
return saveAppSettings({ ...current, advanced });
|
|
376
388
|
}
|
|
377
389
|
function autoRenameBranchEnabled(settings = loadAppSettings()) {
|
|
@@ -392,6 +404,16 @@ function deleteBranchOnPurgeEnabled(settings = loadAppSettings()) {
|
|
|
392
404
|
function autoCleanupOrphansEnabled(settings = loadAppSettings()) {
|
|
393
405
|
return Boolean(settings.advanced.autoCleanupOrphans);
|
|
394
406
|
}
|
|
407
|
+
function orchestrationQuotaOnLimit(settings = loadAppSettings()) {
|
|
408
|
+
return settings.advanced.orchestrationQuotaOnLimit ?? "switch_agent";
|
|
409
|
+
}
|
|
410
|
+
function orchestrationQuotaFallbackAgent(settings = loadAppSettings()) {
|
|
411
|
+
const preferred = settings.advanced.orchestrationQuotaFallbackAgent;
|
|
412
|
+
if (preferred && DEFAULT_AGENTS.has(preferred) && preferred !== "brightsy") {
|
|
413
|
+
return preferred;
|
|
414
|
+
}
|
|
415
|
+
return "cursor";
|
|
416
|
+
}
|
|
395
417
|
function maxConcurrentAgents(settings = loadAppSettings()) {
|
|
396
418
|
const n = settings.advanced.maxConcurrent;
|
|
397
419
|
if (typeof n === "number" && Number.isFinite(n)) {
|
|
@@ -459,6 +481,8 @@ export {
|
|
|
459
481
|
caffeinateWhileCloudConnectEnabled,
|
|
460
482
|
deleteBranchOnPurgeEnabled,
|
|
461
483
|
autoCleanupOrphansEnabled,
|
|
484
|
+
orchestrationQuotaOnLimit,
|
|
485
|
+
orchestrationQuotaFallbackAgent,
|
|
462
486
|
maxConcurrentAgents,
|
|
463
487
|
resolveClaudeExecutable,
|
|
464
488
|
claudeChromeEnabled,
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
formatUnknownDetail,
|
|
11
11
|
looksLikeAgentFailureMessage,
|
|
12
12
|
parseCursorRunnerLine
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-J5JTEJ5O.js";
|
|
14
14
|
import {
|
|
15
15
|
claudeChromeEnabled,
|
|
16
16
|
loadAppSettings,
|
|
17
17
|
resolveClaudeExecutable
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-T5QQVXK3.js";
|
|
19
19
|
import {
|
|
20
20
|
ensureAgentPath,
|
|
21
21
|
run
|
|
@@ -597,6 +597,45 @@ async function buildInjectedMcpServers(opts) {
|
|
|
597
597
|
}
|
|
598
598
|
return servers;
|
|
599
599
|
}
|
|
600
|
+
function toCursorMcpServers(servers) {
|
|
601
|
+
const out = {};
|
|
602
|
+
for (const s of servers) {
|
|
603
|
+
out[s.name] = {
|
|
604
|
+
command: s.command,
|
|
605
|
+
...s.args ? { args: s.args } : {},
|
|
606
|
+
...s.env ? { env: s.env } : {}
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
return out;
|
|
610
|
+
}
|
|
611
|
+
function toCodexMcpConfigArgs(servers) {
|
|
612
|
+
const args = [];
|
|
613
|
+
for (const s of servers) {
|
|
614
|
+
const prefix = `mcp_servers.${s.name}`;
|
|
615
|
+
args.push("-c", `${prefix}.command=${JSON.stringify(s.command)}`);
|
|
616
|
+
if (s.args?.length) {
|
|
617
|
+
args.push("-c", `${prefix}.args=${JSON.stringify(s.args)}`);
|
|
618
|
+
}
|
|
619
|
+
if (s.env) {
|
|
620
|
+
for (const [key, value] of Object.entries(s.env)) {
|
|
621
|
+
args.push("-c", `${prefix}.env.${key}=${JSON.stringify(value)}`);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return args;
|
|
626
|
+
}
|
|
627
|
+
function toOpencodeMcpConfigContent(servers) {
|
|
628
|
+
const mcp = {};
|
|
629
|
+
for (const s of servers) {
|
|
630
|
+
mcp[s.name] = {
|
|
631
|
+
type: "local",
|
|
632
|
+
command: [s.command, ...s.args ?? []],
|
|
633
|
+
enabled: true,
|
|
634
|
+
...s.env && Object.keys(s.env).length > 0 ? { environment: s.env } : {}
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
return JSON.stringify({ mcp });
|
|
638
|
+
}
|
|
600
639
|
function writeMcpServersConfig(servers) {
|
|
601
640
|
if (servers.length === 0) return null;
|
|
602
641
|
const mcpServers = {};
|
|
@@ -798,7 +837,7 @@ var claudeAdapter = {
|
|
|
798
837
|
);
|
|
799
838
|
}
|
|
800
839
|
const mode = permissionMode(thread);
|
|
801
|
-
const { isOrchestratorThread } = await import("./global-workspace-
|
|
840
|
+
const { isOrchestratorThread } = await import("./global-workspace-XFOXEQCP.js");
|
|
802
841
|
const isOrchestrator = isOrchestratorThread(thread);
|
|
803
842
|
const injectedServers = await buildInjectedMcpServers({
|
|
804
843
|
includeSideboard: true,
|
|
@@ -1104,6 +1143,11 @@ var codexAdapter = {
|
|
|
1104
1143
|
}
|
|
1105
1144
|
const mode = permissionMode(thread);
|
|
1106
1145
|
const model = thread.model?.trim();
|
|
1146
|
+
const injected = await buildInjectedMcpServers({
|
|
1147
|
+
includeSideboard: true,
|
|
1148
|
+
includeBrightsy: isBrightsyConnected()
|
|
1149
|
+
});
|
|
1150
|
+
const mcpOverrides = toCodexMcpConfigArgs(injected);
|
|
1107
1151
|
const args = [
|
|
1108
1152
|
"exec",
|
|
1109
1153
|
...sessionId ? ["resume", sessionId] : [],
|
|
@@ -1115,7 +1159,8 @@ var codexAdapter = {
|
|
|
1115
1159
|
mode.codexSandbox,
|
|
1116
1160
|
"--ask-for-approval",
|
|
1117
1161
|
"never",
|
|
1118
|
-
...model ? ["--model", model] : []
|
|
1162
|
+
...model ? ["--model", model] : [],
|
|
1163
|
+
...mcpOverrides
|
|
1119
1164
|
];
|
|
1120
1165
|
return {
|
|
1121
1166
|
file: "codex",
|
|
@@ -1338,6 +1383,11 @@ var cursorAdapter = {
|
|
|
1338
1383
|
const prompt = flattenTurnInput(input);
|
|
1339
1384
|
const agentId = await this.resolveSessionId(thread.worktreePath, thread.sessionId);
|
|
1340
1385
|
const apiKey = resolveCursorApiKey() || void 0;
|
|
1386
|
+
const injected = await buildInjectedMcpServers({
|
|
1387
|
+
includeSideboard: true,
|
|
1388
|
+
includeBrightsy: isBrightsyConnected()
|
|
1389
|
+
});
|
|
1390
|
+
const mcpServers = toCursorMcpServers(injected);
|
|
1341
1391
|
const req = {
|
|
1342
1392
|
prompt,
|
|
1343
1393
|
cwd: thread.worktreePath,
|
|
@@ -1346,7 +1396,8 @@ var cursorAdapter = {
|
|
|
1346
1396
|
effort: thread.effort,
|
|
1347
1397
|
fast: thread.fast,
|
|
1348
1398
|
planMode: thread.planMode,
|
|
1349
|
-
apiKey
|
|
1399
|
+
apiKey,
|
|
1400
|
+
...Object.keys(mcpServers).length > 0 ? { mcpServers } : {}
|
|
1350
1401
|
};
|
|
1351
1402
|
const runner = cursorRunnerPath();
|
|
1352
1403
|
const isTs = runner.endsWith(".ts");
|
|
@@ -1490,6 +1541,11 @@ var opencodeAdapter = {
|
|
|
1490
1541
|
if (model) {
|
|
1491
1542
|
args.push("--model", model);
|
|
1492
1543
|
}
|
|
1544
|
+
const injected = await buildInjectedMcpServers({
|
|
1545
|
+
includeSideboard: true,
|
|
1546
|
+
includeBrightsy: isBrightsyConnected()
|
|
1547
|
+
});
|
|
1548
|
+
const mcpContent = injected.length > 0 ? toOpencodeMcpConfigContent(injected) : null;
|
|
1493
1549
|
return {
|
|
1494
1550
|
file: "opencode",
|
|
1495
1551
|
args,
|
|
@@ -1498,7 +1554,8 @@ var opencodeAdapter = {
|
|
|
1498
1554
|
// message is given (see resolveRunInput in opencode's run.ts).
|
|
1499
1555
|
stdin: prompt,
|
|
1500
1556
|
env: {
|
|
1501
|
-
OPENCODE_PERMISSION: mode.opencodePermission
|
|
1557
|
+
OPENCODE_PERMISSION: mode.opencodePermission,
|
|
1558
|
+
...mcpContent ? { OPENCODE_CONFIG_CONTENT: mcpContent } : {}
|
|
1502
1559
|
}
|
|
1503
1560
|
};
|
|
1504
1561
|
},
|
|
@@ -1616,6 +1673,184 @@ var opencodeAdapter = {
|
|
|
1616
1673
|
}
|
|
1617
1674
|
};
|
|
1618
1675
|
|
|
1676
|
+
// src/agents/list-models.ts
|
|
1677
|
+
var CLAUDE_MODEL_CATALOG = [
|
|
1678
|
+
{ id: "fable", displayName: "Fable" },
|
|
1679
|
+
{ id: "opus", displayName: "Opus" },
|
|
1680
|
+
{ id: "sonnet", displayName: "Sonnet" },
|
|
1681
|
+
{ id: "haiku", displayName: "Haiku" }
|
|
1682
|
+
];
|
|
1683
|
+
async function listBrightsyModels() {
|
|
1684
|
+
try {
|
|
1685
|
+
const targets = await listBrightsyChatTargets();
|
|
1686
|
+
const accountId = targets.activeAccountId;
|
|
1687
|
+
const models = (targets.models ?? []).map((m) => ({
|
|
1688
|
+
id: encodeBrightsyTarget("model", m.id, accountId),
|
|
1689
|
+
displayName: m.name || m.id,
|
|
1690
|
+
description: m.description ?? void 0
|
|
1691
|
+
}));
|
|
1692
|
+
const agents = (targets.agents ?? []).map((a) => ({
|
|
1693
|
+
id: encodeBrightsyTarget("agent", a.id, accountId),
|
|
1694
|
+
displayName: a.name || a.id,
|
|
1695
|
+
description: a.description ?? "Brightsy agent target"
|
|
1696
|
+
}));
|
|
1697
|
+
return [...models, ...agents].slice(0, 80);
|
|
1698
|
+
} catch {
|
|
1699
|
+
return [];
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
async function listModelsForAgent(agent) {
|
|
1703
|
+
const kinds = agent ? [agent] : ["claude", "codex", "opencode", "cursor", "brightsy"];
|
|
1704
|
+
const out = [];
|
|
1705
|
+
for (const kind of kinds) {
|
|
1706
|
+
if (kind === "claude") {
|
|
1707
|
+
out.push({
|
|
1708
|
+
agent: kind,
|
|
1709
|
+
auto: true,
|
|
1710
|
+
models: CLAUDE_MODEL_CATALOG,
|
|
1711
|
+
note: "Default Auto \u2014 only pass a model id when you have a reason."
|
|
1712
|
+
});
|
|
1713
|
+
continue;
|
|
1714
|
+
}
|
|
1715
|
+
if (kind === "codex") {
|
|
1716
|
+
out.push({
|
|
1717
|
+
agent: kind,
|
|
1718
|
+
auto: true,
|
|
1719
|
+
models: await listCodexModels(),
|
|
1720
|
+
note: "Default Auto \u2014 only pass a model slug when you have a reason."
|
|
1721
|
+
});
|
|
1722
|
+
continue;
|
|
1723
|
+
}
|
|
1724
|
+
if (kind === "opencode") {
|
|
1725
|
+
out.push({
|
|
1726
|
+
agent: kind,
|
|
1727
|
+
auto: true,
|
|
1728
|
+
models: await listOpencodeModels(),
|
|
1729
|
+
note: "Default Auto \u2014 only pass a provider/model id when you have a reason."
|
|
1730
|
+
});
|
|
1731
|
+
continue;
|
|
1732
|
+
}
|
|
1733
|
+
if (kind === "cursor") {
|
|
1734
|
+
out.push({
|
|
1735
|
+
agent: kind,
|
|
1736
|
+
auto: true,
|
|
1737
|
+
models: await listCursorModels(),
|
|
1738
|
+
note: 'Default Auto \u2014 only pass a model id when you have a reason (or use "default").'
|
|
1739
|
+
});
|
|
1740
|
+
continue;
|
|
1741
|
+
}
|
|
1742
|
+
if (kind === "brightsy") {
|
|
1743
|
+
const models = await listBrightsyModels();
|
|
1744
|
+
out.push({
|
|
1745
|
+
agent: kind,
|
|
1746
|
+
auto: true,
|
|
1747
|
+
models,
|
|
1748
|
+
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."
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
return out;
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
// src/agents/session-quota.ts
|
|
1756
|
+
function isSessionQuotaLimit(text) {
|
|
1757
|
+
const lower = text.trim().toLowerCase();
|
|
1758
|
+
if (!lower) return false;
|
|
1759
|
+
if (/credit balance is too low|out of credits|insufficient.?quota|billing/.test(lower)) {
|
|
1760
|
+
return false;
|
|
1761
|
+
}
|
|
1762
|
+
if (/prompt is too long|context.*(too long|exceed)|conversation too long/.test(lower)) {
|
|
1763
|
+
return false;
|
|
1764
|
+
}
|
|
1765
|
+
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);
|
|
1766
|
+
}
|
|
1767
|
+
function parseSessionQuotaResetAt(text, now = /* @__PURE__ */ new Date()) {
|
|
1768
|
+
const absolute = text.match(
|
|
1769
|
+
/resets\s+(?:at\s+)?(\d{1,2}):(\d{2})\s*(am|pm)(?:\s*\(([^)]+)\))?/i
|
|
1770
|
+
);
|
|
1771
|
+
if (absolute) {
|
|
1772
|
+
const hour12 = Number(absolute[1]);
|
|
1773
|
+
const minute = Number(absolute[2]);
|
|
1774
|
+
const ampm = absolute[3].toLowerCase();
|
|
1775
|
+
const timeZone = absolute[4]?.trim() || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1776
|
+
let hour = hour12 % 12;
|
|
1777
|
+
if (ampm === "pm") hour += 12;
|
|
1778
|
+
const at = zonedWallTimeToUtc(now, hour, minute, timeZone);
|
|
1779
|
+
if (!at) return null;
|
|
1780
|
+
if (at.getTime() <= now.getTime() + 3e4) {
|
|
1781
|
+
const tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1e3);
|
|
1782
|
+
return zonedWallTimeToUtc(tomorrow, hour, minute, timeZone);
|
|
1783
|
+
}
|
|
1784
|
+
return at;
|
|
1785
|
+
}
|
|
1786
|
+
const relative = text.match(
|
|
1787
|
+
/resets\s+in\s+(\d+)\s*(minutes?|hours?|days?)/i
|
|
1788
|
+
);
|
|
1789
|
+
if (relative) {
|
|
1790
|
+
const n = Number(relative[1]);
|
|
1791
|
+
const unit = relative[2].toLowerCase();
|
|
1792
|
+
const ms = unit.startsWith("day") ? n * 24 * 60 * 60 * 1e3 : unit.startsWith("hour") ? n * 60 * 60 * 1e3 : n * 60 * 1e3;
|
|
1793
|
+
return new Date(now.getTime() + ms);
|
|
1794
|
+
}
|
|
1795
|
+
return null;
|
|
1796
|
+
}
|
|
1797
|
+
function zonedWallTimeToUtc(day, hour, minute, timeZone) {
|
|
1798
|
+
try {
|
|
1799
|
+
const cal = new Intl.DateTimeFormat("en-US", {
|
|
1800
|
+
timeZone,
|
|
1801
|
+
year: "numeric",
|
|
1802
|
+
month: "2-digit",
|
|
1803
|
+
day: "2-digit"
|
|
1804
|
+
});
|
|
1805
|
+
const parts = Object.fromEntries(
|
|
1806
|
+
cal.formatToParts(day).filter((p) => p.type !== "literal").map((p) => [p.type, p.value])
|
|
1807
|
+
);
|
|
1808
|
+
const year = Number(parts.year);
|
|
1809
|
+
const month = Number(parts.month);
|
|
1810
|
+
const date = Number(parts.day);
|
|
1811
|
+
if (![year, month, date].every((n) => Number.isFinite(n))) return null;
|
|
1812
|
+
const utcGuess = Date.UTC(year, month - 1, date, hour, minute, 0);
|
|
1813
|
+
const dtf = new Intl.DateTimeFormat("en-US", {
|
|
1814
|
+
timeZone,
|
|
1815
|
+
year: "numeric",
|
|
1816
|
+
month: "2-digit",
|
|
1817
|
+
day: "2-digit",
|
|
1818
|
+
hour: "2-digit",
|
|
1819
|
+
minute: "2-digit",
|
|
1820
|
+
second: "2-digit",
|
|
1821
|
+
hourCycle: "h23"
|
|
1822
|
+
});
|
|
1823
|
+
const asParts = Object.fromEntries(
|
|
1824
|
+
dtf.formatToParts(new Date(utcGuess)).filter((p) => p.type !== "literal").map((p) => [p.type, p.value])
|
|
1825
|
+
);
|
|
1826
|
+
const asUtc = Date.UTC(
|
|
1827
|
+
Number(asParts.year),
|
|
1828
|
+
Number(asParts.month) - 1,
|
|
1829
|
+
Number(asParts.day),
|
|
1830
|
+
Number(asParts.hour),
|
|
1831
|
+
Number(asParts.minute),
|
|
1832
|
+
Number(asParts.second || "0")
|
|
1833
|
+
);
|
|
1834
|
+
const offset = asUtc - utcGuess;
|
|
1835
|
+
return new Date(utcGuess - offset);
|
|
1836
|
+
} catch {
|
|
1837
|
+
return null;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
var FALLBACK_ORDER = [
|
|
1841
|
+
"cursor",
|
|
1842
|
+
"codex",
|
|
1843
|
+
"opencode",
|
|
1844
|
+
"claude"
|
|
1845
|
+
];
|
|
1846
|
+
function resolveQuotaFallbackAgent(current, preferred) {
|
|
1847
|
+
const ordered = [
|
|
1848
|
+
...preferred && preferred !== "brightsy" ? [preferred] : [],
|
|
1849
|
+
...FALLBACK_ORDER.filter((a) => a !== preferred)
|
|
1850
|
+
];
|
|
1851
|
+
return ordered.find((a) => a !== current) ?? (current === "cursor" ? "codex" : "cursor");
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1619
1854
|
// src/agents/install.ts
|
|
1620
1855
|
var SETUP = {
|
|
1621
1856
|
claude: {
|
|
@@ -1833,6 +2068,11 @@ export {
|
|
|
1833
2068
|
cursorAdapter,
|
|
1834
2069
|
listOpencodeModels,
|
|
1835
2070
|
opencodeAdapter,
|
|
2071
|
+
CLAUDE_MODEL_CATALOG,
|
|
2072
|
+
listModelsForAgent,
|
|
2073
|
+
isSessionQuotaLimit,
|
|
2074
|
+
parseSessionQuotaResetAt,
|
|
2075
|
+
resolveQuotaFallbackAgent,
|
|
1836
2076
|
getAgentSetupInfo,
|
|
1837
2077
|
listAgentSetupInfo,
|
|
1838
2078
|
openInSystemTerminal,
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
enrichWorkspacesWithGithub,
|
|
7
7
|
ensureGlobalCoordinatorCwd,
|
|
8
8
|
formatWorkspaceInventory
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-6NAPN2N5.js";
|
|
10
|
+
import "./chunk-FV6FN6V5.js";
|
|
11
|
+
import "./chunk-O6W3P7V3.js";
|
|
12
12
|
import "./chunk-77WWLBCI.js";
|
|
13
13
|
import "./chunk-M37RITA6.js";
|
|
14
14
|
import "./chunk-AJ6ROGD7.js";
|
|
@@ -11,10 +11,11 @@ import {
|
|
|
11
11
|
orchestrationTitleNeedsSoccerNickname,
|
|
12
12
|
orchestratorSessionPoisonedByBuiltins,
|
|
13
13
|
takenTeamSlugsForOrchestration
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-SPCU3MFY.js";
|
|
15
|
+
import "./chunk-6NAPN2N5.js";
|
|
16
|
+
import "./chunk-GI7E5733.js";
|
|
17
|
+
import "./chunk-FV6FN6V5.js";
|
|
18
|
+
import "./chunk-O6W3P7V3.js";
|
|
18
19
|
import "./chunk-77WWLBCI.js";
|
|
19
20
|
import {
|
|
20
21
|
globalAgentCwd
|