@sideboard-ai/core 0.1.303 → 0.1.305
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/{abletime-APP3DZ4P.js → abletime-SJUVZVRU.js} +6 -6
- package/dist/{abletime-RYDAQ3FE.js → abletime-T5YSJLNZ.js} +6 -6
- package/dist/{abletime-oauth-ZURGXSY6.js → abletime-oauth-2TOOZ2FN.js} +5 -5
- package/dist/{abletime-oauth-KTERKARA.js → abletime-oauth-73TFJME4.js} +5 -5
- package/dist/{abletime-rest-4TVIWLZK.js → abletime-rest-5TDRIFEV.js} +5 -5
- package/dist/{abletime-rest-EUB6RW7K.js → abletime-rest-PNUGH2FS.js} +5 -5
- package/dist/agents/claude-runner.js +2 -2
- package/dist/agents/cursor-runner.js +5 -5
- package/dist/{agents-3GN4E2X3.js → agents-IWNQOQOU.js} +12 -12
- package/dist/{agents-XLHFVC64.js → agents-PGU5WVSO.js} +10 -10
- package/dist/{app-settings-2IH42VA5.js → app-settings-CC65VPBL.js} +3 -3
- package/dist/{app-settings-3OQWRKOK.js → app-settings-DZ5AY7N5.js} +3 -3
- package/dist/{caffeinate-hold-7JM5H5P3.js → caffeinate-hold-H7TTUDGM.js} +2 -2
- package/dist/{caffeinate-hold-DYJGWK6Y.js → caffeinate-hold-ZNUEZGHB.js} +2 -2
- package/dist/{chunk-545DY7CQ.js → chunk-33HIBNSF.js} +106 -64
- package/dist/{chunk-FA3V56KF.js → chunk-3UDRWMIM.js} +2 -2
- package/dist/{chunk-7IAMHN2N.js → chunk-42JGPPVS.js} +1 -1
- package/dist/{chunk-BRFDPV7Z.js → chunk-5QX2NYXL.js} +4 -4
- package/dist/{chunk-DW6NNYUJ.js → chunk-5SFA27CF.js} +61 -8
- package/dist/{chunk-XCXUVX7I.js → chunk-62ESCTJ4.js} +1 -1
- package/dist/{chunk-SSETL5EX.js → chunk-6424BACS.js} +2 -2
- package/dist/{chunk-RSATPXU4.js → chunk-A2YXQC65.js} +264 -2
- package/dist/{chunk-GEFH4QFX.js → chunk-BIPXOHZI.js} +3 -3
- package/dist/{chunk-HSF2RQSQ.js → chunk-CFTOKVQN.js} +5 -5
- package/dist/{chunk-3D3GGL6X.js → chunk-CW4FIIDE.js} +3 -3
- package/dist/{chunk-5DZUWGKV.js → chunk-DC3VZXMA.js} +1 -1
- package/dist/{chunk-5MVOZLN7.js → chunk-DLGGLV2M.js} +3 -3
- package/dist/{chunk-WZCPZVUC.js → chunk-EGTCXNQM.js} +3 -3
- package/dist/{chunk-3TZRSKFJ.js → chunk-EZYZGDWU.js} +422 -175
- package/dist/{chunk-7AYOOG77.js → chunk-G2L3CR3A.js} +471 -107
- package/dist/{chunk-EHT2DRT4.js → chunk-H4UEFJRI.js} +4 -0
- package/dist/{chunk-P2GHFJOB.js → chunk-HG25AYBV.js} +2 -2
- package/dist/{chunk-GS6O65Q2.js → chunk-I34DCC4L.js} +104 -62
- package/dist/{chunk-UN5Q7POQ.js → chunk-J2LNLI4S.js} +1 -1
- package/dist/{chunk-MOP5L5QZ.js → chunk-JARCAPKL.js} +3 -3
- package/dist/{chunk-FAXOEKQR.js → chunk-JWW66PO3.js} +5 -5
- package/dist/{chunk-3HO2OY5T.js → chunk-KI45T4DI.js} +1 -1
- package/dist/{chunk-NOT4SEAM.js → chunk-LAWLUOWQ.js} +1 -1
- package/dist/{chunk-UWQ6UCIB.js → chunk-LG6RJBIY.js} +1 -1
- package/dist/{chunk-IOY2LF3Y.js → chunk-MMVMQ34G.js} +1 -1
- package/dist/{chunk-LZVWKJXY.js → chunk-OLSLE3LO.js} +3 -3
- package/dist/{chunk-RAGDMEIB.js → chunk-OVNIP265.js} +59 -8
- package/dist/{chunk-BU6HH5VA.js → chunk-PHMFAU35.js} +66 -2
- package/dist/{chunk-ISEYRGMP.js → chunk-RU6DTCCV.js} +2 -2
- package/dist/{chunk-R3R3ZDFC.js → chunk-SZ3XS2WM.js} +2 -2
- package/dist/{chunk-B42H6GJR.js → chunk-U4WACWBC.js} +3 -3
- package/dist/{chunk-VGNLMGBK.js → chunk-VEVFHO6K.js} +5 -5
- package/dist/{chunk-4RZRHTSZ.js → chunk-WMZIANPV.js} +1 -1
- package/dist/{chunk-H5XL4KUS.js → chunk-WOU343SI.js} +4 -0
- package/dist/{chunk-QDDTVIWE.js → chunk-WRZRX4Q7.js} +2 -2
- package/dist/{chunk-YCDHLK2Z.js → chunk-X3FSWWW2.js} +4 -4
- package/dist/{chunk-QDA6NXRA.js → chunk-YDUHLWI5.js} +1 -1
- package/dist/{chunk-J54UPHXZ.js → chunk-YJBUYGPN.js} +1 -1
- package/dist/{conductor-ATST6OMC.js → conductor-YBXURAUL.js} +10 -8
- package/dist/{conductor-2AVFGSQJ.js → conductor-ZFRXTVGP.js} +10 -8
- package/dist/{connected-teams-BJ6PMIST.js → connected-teams-BBNYTR3I.js} +2 -2
- package/dist/{connected-teams-AB7ZHJVO.js → connected-teams-WLWIVYGD.js} +2 -2
- package/dist/{coordinator-prompt-TIAI6A47.js → coordinator-prompt-GZCWQAAV.js} +7 -7
- package/dist/{coordinator-prompt-CQPUNMRX.js → coordinator-prompt-YAZRQ4BI.js} +7 -7
- package/dist/{cursor-recover-A6V5UVFT.js → cursor-recover-OWPQUHFH.js} +2 -2
- package/dist/{cursor-recover-MB3T2K5T.js → cursor-recover-TEBFKAZ4.js} +2 -2
- package/dist/{global-workspace-7YABMLQG.js → global-workspace-BZAVBOH3.js} +7 -7
- package/dist/{global-workspace-UZJUHGQP.js → global-workspace-H6X32IJZ.js} +7 -7
- package/dist/index.cjs +13486 -12609
- package/dist/index.d.cts +94 -14
- package/dist/index.d.ts +94 -14
- package/dist/index.js +11807 -11663
- package/dist/{managed-accounts-2AK5RIAF.js → managed-accounts-JJTAKHMG.js} +2 -2
- package/dist/{managed-accounts-46A4KRUE.js → managed-accounts-PITLFLKU.js} +2 -2
- package/dist/mcp/run-stdio.cjs +1037 -616
- package/dist/mcp/run-stdio.js +20 -20
- package/dist/{optional-cli-JQVNSMSU.js → optional-cli-QDIT57VD.js} +5 -5
- package/dist/{optional-cli-PZXDOVJJ.js → optional-cli-QY6V5S5N.js} +6 -6
- package/dist/{orchestrator-CZPRDLHV.js → orchestrator-IKKSYIQ3.js} +16 -16
- package/dist/{orchestrator-COX6QO2B.js → orchestrator-JGHYZDDB.js} +14 -14
- package/dist/{paths-HYT5WOOX.js → paths-HAAJNTTE.js} +1 -1
- package/dist/{paths-5JYXTAPC.js → paths-PHWEVXD5.js} +1 -1
- package/dist/{thread-store-PNX4HVLO.js → thread-store-HY22M5A7.js} +3 -3
- package/dist/{thread-store-VC4AIKN3.js → thread-store-XMUQDO5O.js} +3 -3
- package/dist/{workspaces-GZ7F5EJR.js → workspaces-AGOLRBYZ.js} +7 -7
- package/dist/{workspaces-6DJL4IST.js → workspaces-BQUDYTBX.js} +7 -7
- package/dist/{worktree-2BYVRYPJ.js → worktree-C5VI46RZ.js} +6 -6
- package/dist/{worktree-VXPOY2LE.js → worktree-FMK57ULT.js} +6 -6
- package/package.json +4 -1
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
brightsyMcpServerName,
|
|
6
6
|
ensureCliTeamTracked,
|
|
7
7
|
ensureConnectedBrightsyTeamTokens
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-42JGPPVS.js";
|
|
9
9
|
import {
|
|
10
10
|
loadBrightsyConfig
|
|
11
11
|
} from "./chunk-PXMLMBMI.js";
|
|
@@ -24,13 +24,13 @@ import {
|
|
|
24
24
|
} from "./chunk-5XQ43YZU.js";
|
|
25
25
|
import {
|
|
26
26
|
isOrchestratorThread
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-X3FSWWW2.js";
|
|
28
28
|
import {
|
|
29
29
|
codexUnattendedGitConfigArgs,
|
|
30
30
|
mergeAgentGitAuthEnv,
|
|
31
31
|
resolveAgentGitAuthEnv,
|
|
32
32
|
resolveCodexGitWritableRoots
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-DLGGLV2M.js";
|
|
34
34
|
import {
|
|
35
35
|
npmGlobalNodeModules,
|
|
36
36
|
run
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
loadAppSettings,
|
|
45
45
|
resolveAgentExecutable,
|
|
46
46
|
resolveClaudeExecutable
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-PHMFAU35.js";
|
|
48
48
|
import {
|
|
49
49
|
isElectronLikeCommand,
|
|
50
50
|
unwrapStrippedElectronLaunch,
|
|
@@ -56,10 +56,10 @@ import {
|
|
|
56
56
|
CLAUDE_POSTHOG_CONNECTOR_ALLOWED_TOOLS,
|
|
57
57
|
CLAUDE_PRINT_BG_WAIT_CEILING_MS,
|
|
58
58
|
mcpAllowToolsFromNames
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-3UDRWMIM.js";
|
|
60
60
|
import {
|
|
61
61
|
appDataDir
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-WOU343SI.js";
|
|
63
63
|
|
|
64
64
|
// src/agents/brightsy.ts
|
|
65
65
|
import { existsSync } from "fs";
|
|
@@ -446,24 +446,265 @@ var brightsyAdapter = {
|
|
|
446
446
|
};
|
|
447
447
|
|
|
448
448
|
// src/agents/claude.ts
|
|
449
|
-
import { existsSync as
|
|
449
|
+
import { existsSync as existsSync11 } from "fs";
|
|
450
|
+
import { homedir as homedir5 } from "os";
|
|
450
451
|
|
|
451
452
|
// src/agents/orch-mcp-isolation.ts
|
|
452
|
-
import { existsSync as
|
|
453
|
-
|
|
454
|
-
|
|
453
|
+
import { existsSync as existsSync8, readFileSync as readFileSync4 } from "fs";
|
|
454
|
+
|
|
455
|
+
// src/agents/claude-plugins.ts
|
|
456
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
457
|
+
import { homedir } from "os";
|
|
458
|
+
import { isAbsolute, join, relative, resolve } from "path";
|
|
459
|
+
|
|
460
|
+
// src/mcp-ui/meta.ts
|
|
461
|
+
function parseMcpServerLaunch(entry) {
|
|
462
|
+
const command = typeof entry.command === "string" ? entry.command.trim() : "";
|
|
463
|
+
if (command) {
|
|
464
|
+
const args = Array.isArray(entry.args) ? entry.args.filter((a) => typeof a === "string") : [];
|
|
465
|
+
const env = stringRecord(entry.env);
|
|
466
|
+
const cwd = typeof entry.cwd === "string" && entry.cwd.trim() ? entry.cwd.trim() : void 0;
|
|
467
|
+
return {
|
|
468
|
+
kind: "stdio",
|
|
469
|
+
command,
|
|
470
|
+
args,
|
|
471
|
+
...env ? { env } : {},
|
|
472
|
+
...cwd ? { cwd } : {}
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
const url = typeof entry.url === "string" ? entry.url.trim() : "";
|
|
476
|
+
if (!url) return null;
|
|
477
|
+
let parsed;
|
|
478
|
+
try {
|
|
479
|
+
parsed = new URL(url);
|
|
480
|
+
} catch {
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
|
|
484
|
+
const type = typeof entry.type === "string" ? entry.type.trim().toLowerCase() : "";
|
|
485
|
+
const headers = stringRecord(entry.headers);
|
|
486
|
+
return {
|
|
487
|
+
kind: type === "sse" ? "sse" : "http",
|
|
488
|
+
url: parsed.toString(),
|
|
489
|
+
...headers ? { headers } : {}
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function stringRecord(value) {
|
|
493
|
+
const rec = asRecord(value);
|
|
494
|
+
const out = {};
|
|
495
|
+
for (const [key, item] of Object.entries(rec)) {
|
|
496
|
+
if (typeof item === "string") out[key] = item;
|
|
497
|
+
}
|
|
498
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
499
|
+
}
|
|
500
|
+
function asRecord(value) {
|
|
501
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
502
|
+
return value;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// src/agents/claude-plugins.ts
|
|
506
|
+
function claudePluginServerId(pluginName, serverName) {
|
|
507
|
+
return `plugin_${pluginName}_${serverName}`.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
508
|
+
}
|
|
509
|
+
function listEnabledClaudePluginMcpServers(opts) {
|
|
510
|
+
const home = opts?.home ?? homedir();
|
|
511
|
+
const pluginsRoot = claudePluginsRoot(home);
|
|
512
|
+
const enabled = enabledPluginIds(home, opts?.projectDirs ?? []);
|
|
513
|
+
const installed = readInstalledPlugins(join(pluginsRoot, "installed_plugins.json"));
|
|
514
|
+
const out = {};
|
|
515
|
+
for (const [id, on] of enabled) {
|
|
516
|
+
if (!on) continue;
|
|
517
|
+
const root = installPathFor(id, installed);
|
|
518
|
+
if (!root || !existsSync2(root)) continue;
|
|
519
|
+
const pluginName = manifestName(root) || id.split("@")[0]?.trim() || "";
|
|
520
|
+
if (!pluginName) continue;
|
|
521
|
+
const dataDir = join(pluginsRoot, "data", pluginDataId(id));
|
|
522
|
+
for (const [serverName, entry] of Object.entries(loadPluginMcpServers(root))) {
|
|
523
|
+
const expanded = expandPluginEntry(entry, root, dataDir);
|
|
524
|
+
if (!parseMcpServerLaunch(expanded)) continue;
|
|
525
|
+
const key = claudePluginServerId(pluginName, serverName);
|
|
526
|
+
if (!key || key === "plugin__") continue;
|
|
527
|
+
out[key] = expanded;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return out;
|
|
531
|
+
}
|
|
532
|
+
function claudePluginsRoot(home) {
|
|
533
|
+
const override = process.env.CLAUDE_CODE_PLUGIN_CACHE_DIR?.trim();
|
|
534
|
+
if (override && isAbsolute(override)) return override;
|
|
535
|
+
return join(home, ".claude", "plugins");
|
|
536
|
+
}
|
|
537
|
+
function pluginDataId(pluginId) {
|
|
538
|
+
return pluginId.replace(/[^A-Za-z0-9_-]/g, "-");
|
|
539
|
+
}
|
|
540
|
+
function enabledPluginIds(home, projectDirs) {
|
|
541
|
+
const enabled = /* @__PURE__ */ new Map();
|
|
542
|
+
applyEnabled(enabled, readEnabledPlugins(join(home, ".claude", "settings.json")));
|
|
543
|
+
const dirs = [...new Set(projectDirs.map((dir) => dir.trim()).filter(Boolean))];
|
|
544
|
+
for (const dir of dirs) {
|
|
545
|
+
applyEnabled(enabled, readEnabledPlugins(join(dir, ".claude", "settings.json")));
|
|
546
|
+
}
|
|
547
|
+
for (const dir of dirs) {
|
|
548
|
+
applyEnabled(enabled, readEnabledPlugins(join(dir, ".claude", "settings.local.json")));
|
|
549
|
+
}
|
|
550
|
+
return enabled;
|
|
551
|
+
}
|
|
552
|
+
function applyEnabled(into, next) {
|
|
553
|
+
for (const [id, on] of Object.entries(next)) {
|
|
554
|
+
const key = id.trim();
|
|
555
|
+
if (!key) continue;
|
|
556
|
+
into.set(key, on);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
function readEnabledPlugins(path) {
|
|
560
|
+
const root = readJson(path);
|
|
561
|
+
const raw = root.enabledPlugins;
|
|
562
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
563
|
+
const out = {};
|
|
564
|
+
for (const [id, value] of Object.entries(raw)) {
|
|
565
|
+
if (value === true || value === false) out[id] = value;
|
|
566
|
+
}
|
|
567
|
+
return out;
|
|
568
|
+
}
|
|
569
|
+
function readInstalledPlugins(path) {
|
|
570
|
+
const root = readJson(path);
|
|
571
|
+
const plugins = root.plugins;
|
|
572
|
+
if (!plugins || typeof plugins !== "object" || Array.isArray(plugins)) return {};
|
|
573
|
+
const out = {};
|
|
574
|
+
for (const [id, value] of Object.entries(plugins)) {
|
|
575
|
+
const rows = Array.isArray(value) ? value : [value];
|
|
576
|
+
const installs = [];
|
|
577
|
+
for (const row of rows) {
|
|
578
|
+
if (!row || typeof row !== "object" || Array.isArray(row)) continue;
|
|
579
|
+
const installPath = row.installPath;
|
|
580
|
+
installs.push({
|
|
581
|
+
...typeof installPath === "string" && installPath.trim() ? { installPath: installPath.trim() } : {}
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
if (installs.length) out[id] = installs;
|
|
585
|
+
}
|
|
586
|
+
return out;
|
|
587
|
+
}
|
|
588
|
+
function installPathFor(id, installed) {
|
|
589
|
+
const rows = installed[id] ?? [];
|
|
590
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
591
|
+
const path = rows[i]?.installPath;
|
|
592
|
+
if (path && existsSync2(path)) return path;
|
|
593
|
+
}
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
function manifestName(root) {
|
|
597
|
+
const manifest = readJson(join(root, ".claude-plugin", "plugin.json"));
|
|
598
|
+
return typeof manifest.name === "string" ? manifest.name.trim() : "";
|
|
599
|
+
}
|
|
600
|
+
function loadPluginMcpServers(root) {
|
|
601
|
+
const servers = {};
|
|
602
|
+
mergeServerMap(servers, serversFromFile(join(root, ".mcp.json"), root));
|
|
603
|
+
const manifest = readJson(join(root, ".claude-plugin", "plugin.json"));
|
|
604
|
+
mergeServerMap(servers, serversFromManifest(manifest.mcpServers, root));
|
|
605
|
+
return servers;
|
|
606
|
+
}
|
|
607
|
+
function serversFromManifest(value, root) {
|
|
608
|
+
if (!value) return {};
|
|
609
|
+
if (typeof value === "string") return serversFromFile(resolveInside(root, value), root);
|
|
610
|
+
if (Array.isArray(value)) {
|
|
611
|
+
const out = {};
|
|
612
|
+
for (const item of value) {
|
|
613
|
+
if (typeof item === "string") mergeServerMap(out, serversFromFile(resolveInside(root, item), root));
|
|
614
|
+
else mergeServerMap(out, serverMap(item, root));
|
|
615
|
+
}
|
|
616
|
+
return out;
|
|
617
|
+
}
|
|
618
|
+
return serverMap(value, root);
|
|
619
|
+
}
|
|
620
|
+
function serversFromFile(path, root) {
|
|
621
|
+
if (!path || !existsSync2(path)) return {};
|
|
622
|
+
return serverMap(readJson(path), root);
|
|
623
|
+
}
|
|
624
|
+
function serverMap(value, root) {
|
|
625
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
626
|
+
const record = value;
|
|
627
|
+
const wrapped = record.mcpServers;
|
|
628
|
+
const source = wrapped && typeof wrapped === "object" && !Array.isArray(wrapped) ? wrapped : record;
|
|
629
|
+
if (typeof wrapped === "string") return serversFromFile(resolveInside(root, wrapped), root);
|
|
630
|
+
const out = {};
|
|
631
|
+
for (const [name, entry] of Object.entries(source)) {
|
|
632
|
+
if (!name.trim() || !entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
633
|
+
const row = entry;
|
|
634
|
+
if (row.disabled === true) continue;
|
|
635
|
+
if (typeof row.command !== "string" && typeof row.url !== "string") continue;
|
|
636
|
+
out[name.trim()] = row;
|
|
637
|
+
}
|
|
638
|
+
return out;
|
|
639
|
+
}
|
|
640
|
+
function mergeServerMap(into, extra) {
|
|
641
|
+
for (const [name, entry] of Object.entries(extra)) into[name] = entry;
|
|
642
|
+
}
|
|
643
|
+
function expandPluginEntry(entry, root, dataDir) {
|
|
644
|
+
const next = { ...entry };
|
|
645
|
+
if (typeof next.command === "string") next.command = expandVars(next.command, root, dataDir);
|
|
646
|
+
if (Array.isArray(next.args)) {
|
|
647
|
+
next.args = next.args.map((arg) => typeof arg === "string" ? expandVars(arg, root, dataDir) : arg);
|
|
648
|
+
}
|
|
649
|
+
if (typeof next.url === "string") next.url = expandVars(next.url, root, dataDir);
|
|
650
|
+
if (next.env && typeof next.env === "object" && !Array.isArray(next.env)) {
|
|
651
|
+
const env = {};
|
|
652
|
+
for (const [key, value] of Object.entries(next.env)) {
|
|
653
|
+
if (typeof value === "string") env[key] = expandVars(value, root, dataDir);
|
|
654
|
+
}
|
|
655
|
+
env.CLAUDE_PLUGIN_ROOT = env.CLAUDE_PLUGIN_ROOT || root;
|
|
656
|
+
env.CLAUDE_PLUGIN_DATA = env.CLAUDE_PLUGIN_DATA || dataDir;
|
|
657
|
+
next.env = env;
|
|
658
|
+
} else if (typeof next.command === "string") {
|
|
659
|
+
next.env = { CLAUDE_PLUGIN_ROOT: root, CLAUDE_PLUGIN_DATA: dataDir };
|
|
660
|
+
}
|
|
661
|
+
if (next.headers && typeof next.headers === "object" && !Array.isArray(next.headers)) {
|
|
662
|
+
const headers = {};
|
|
663
|
+
for (const [key, value] of Object.entries(next.headers)) {
|
|
664
|
+
if (typeof value === "string") headers[key] = expandVars(value, root, dataDir);
|
|
665
|
+
}
|
|
666
|
+
next.headers = headers;
|
|
667
|
+
}
|
|
668
|
+
return next;
|
|
669
|
+
}
|
|
670
|
+
function expandVars(value, root, dataDir) {
|
|
671
|
+
return value.replaceAll("${CLAUDE_PLUGIN_ROOT}", root).replaceAll("${CLAUDE_PLUGIN_DATA}", dataDir);
|
|
672
|
+
}
|
|
673
|
+
function resolveInside(root, spec) {
|
|
674
|
+
const trimmed = spec.trim();
|
|
675
|
+
if (!trimmed || trimmed.endsWith(".mcpb") || trimmed.endsWith(".dxt")) return null;
|
|
676
|
+
if (/^https?:\/\//i.test(trimmed)) return null;
|
|
677
|
+
const abs = resolve(root, trimmed);
|
|
678
|
+
const rel = relative(root, abs);
|
|
679
|
+
if (!rel || rel.startsWith("..") || isAbsolute(rel)) return null;
|
|
680
|
+
return abs;
|
|
681
|
+
}
|
|
682
|
+
function readJson(path) {
|
|
683
|
+
if (!existsSync2(path)) return {};
|
|
684
|
+
try {
|
|
685
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
686
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
687
|
+
return parsed;
|
|
688
|
+
} catch {
|
|
689
|
+
return {};
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// src/agents/orch-mcp-isolation.ts
|
|
694
|
+
import { homedir as homedir4 } from "os";
|
|
695
|
+
import { join as join7 } from "path";
|
|
455
696
|
import { parse as parseToml } from "smol-toml";
|
|
456
697
|
|
|
457
698
|
// src/agents/user-mcp-config.ts
|
|
458
|
-
import { existsSync as
|
|
459
|
-
import { homedir as
|
|
460
|
-
import { dirname as dirname3, join as
|
|
699
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
700
|
+
import { homedir as homedir3 } from "os";
|
|
701
|
+
import { dirname as dirname3, join as join6 } from "path";
|
|
461
702
|
|
|
462
703
|
// src/agents/injected-mcp.ts
|
|
463
|
-
import { existsSync as
|
|
704
|
+
import { existsSync as existsSync6, mkdtempSync, writeFileSync as writeFileSync2 } from "fs";
|
|
464
705
|
import { createRequire } from "module";
|
|
465
706
|
import { tmpdir } from "os";
|
|
466
|
-
import { dirname as dirname2, join as
|
|
707
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
467
708
|
import { fileURLToPath } from "url";
|
|
468
709
|
|
|
469
710
|
// src/agent-rpc/protocol.ts
|
|
@@ -537,14 +778,14 @@ function sideboardMcpProfile(env = process.env) {
|
|
|
537
778
|
}
|
|
538
779
|
|
|
539
780
|
// src/agents/node-launch.ts
|
|
540
|
-
import { existsSync as
|
|
541
|
-
import { homedir } from "os";
|
|
542
|
-
import { join as
|
|
781
|
+
import { existsSync as existsSync5, readdirSync, realpathSync } from "fs";
|
|
782
|
+
import { homedir as homedir2 } from "os";
|
|
783
|
+
import { join as join4 } from "path";
|
|
543
784
|
|
|
544
785
|
// src/http/system-ca.ts
|
|
545
786
|
import { spawnSync } from "child_process";
|
|
546
|
-
import { existsSync as
|
|
547
|
-
import { dirname, join } from "path";
|
|
787
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, statSync, writeFileSync } from "fs";
|
|
788
|
+
import { dirname, join as join2 } from "path";
|
|
548
789
|
import tls from "tls";
|
|
549
790
|
var NODE_USE_SYSTEM_CA = "NODE_USE_SYSTEM_CA";
|
|
550
791
|
var NODE_EXTRA_CA_CERTS = "NODE_EXTRA_CA_CERTS";
|
|
@@ -562,7 +803,7 @@ function splitPemCertificates(pem) {
|
|
|
562
803
|
}
|
|
563
804
|
function readExistingFile(path) {
|
|
564
805
|
try {
|
|
565
|
-
return
|
|
806
|
+
return existsSync3(path) ? readFileSync2(path, "utf8") : "";
|
|
566
807
|
} catch {
|
|
567
808
|
return "";
|
|
568
809
|
}
|
|
@@ -594,12 +835,12 @@ function collectSystemCaPem(io = {}) {
|
|
|
594
835
|
return "";
|
|
595
836
|
}
|
|
596
837
|
function systemCaBundlePath(io = {}) {
|
|
597
|
-
return
|
|
838
|
+
return join2((io.appData ?? appDataDir)(), BUNDLE_NAME);
|
|
598
839
|
}
|
|
599
840
|
function bundleIsFresh(path, now) {
|
|
600
841
|
try {
|
|
601
|
-
if (!
|
|
602
|
-
if (splitPemCertificates(
|
|
842
|
+
if (!existsSync3(path)) return false;
|
|
843
|
+
if (splitPemCertificates(readFileSync2(path, "utf8")).length === 0) return false;
|
|
603
844
|
return now - statSync(path).mtimeMs < BUNDLE_MAX_AGE_MS;
|
|
604
845
|
} catch {
|
|
605
846
|
return false;
|
|
@@ -621,7 +862,7 @@ function materializeSystemCaBundle(io = {}) {
|
|
|
621
862
|
if (bundleIsFresh(dest, now)) return dest;
|
|
622
863
|
const pem = collectSystemCaPem(io);
|
|
623
864
|
if (splitPemCertificates(pem).length === 0) {
|
|
624
|
-
return
|
|
865
|
+
return existsSync3(dest) && splitPemCertificates(readExistingFile(dest)).length > 0 ? dest : void 0;
|
|
625
866
|
}
|
|
626
867
|
try {
|
|
627
868
|
mkdirSync(dirname(dest), { recursive: true });
|
|
@@ -667,8 +908,8 @@ function trustSystemCertificates(io = {}) {
|
|
|
667
908
|
}
|
|
668
909
|
|
|
669
910
|
// src/agents/packaged-runtime.ts
|
|
670
|
-
import { existsSync as
|
|
671
|
-
import { join as
|
|
911
|
+
import { existsSync as existsSync4 } from "fs";
|
|
912
|
+
import { join as join3 } from "path";
|
|
672
913
|
function electronResourcesPath() {
|
|
673
914
|
const resources = process.resourcesPath;
|
|
674
915
|
if (typeof resources !== "string" || !resources) return null;
|
|
@@ -677,36 +918,36 @@ function electronResourcesPath() {
|
|
|
677
918
|
function packagedCursorRuntimeDir() {
|
|
678
919
|
const resources = electronResourcesPath();
|
|
679
920
|
if (!resources) return null;
|
|
680
|
-
const dir =
|
|
681
|
-
if (!
|
|
921
|
+
const dir = join3(resources, "cursor-runtime");
|
|
922
|
+
if (!existsSync4(join3(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
|
|
682
923
|
return dir;
|
|
683
924
|
}
|
|
684
925
|
function packagedCursorRunnerPath() {
|
|
685
926
|
const dir = packagedCursorRuntimeDir();
|
|
686
|
-
return dir ?
|
|
927
|
+
return dir ? join3(dir, "core-dist", "agents", "cursor-runner.js") : null;
|
|
687
928
|
}
|
|
688
929
|
function packagedMcpDir() {
|
|
689
930
|
const resources = electronResourcesPath();
|
|
690
931
|
if (!resources) return null;
|
|
691
|
-
const dir =
|
|
692
|
-
if (!
|
|
932
|
+
const dir = join3(resources, "sideboard-mcp");
|
|
933
|
+
if (!existsSync4(join3(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
|
|
693
934
|
return dir;
|
|
694
935
|
}
|
|
695
936
|
function packagedMcpStdioPath() {
|
|
696
937
|
const dir = packagedMcpDir();
|
|
697
|
-
return dir ?
|
|
938
|
+
return dir ? join3(dir, "core-dist", "mcp", "run-stdio.js") : null;
|
|
698
939
|
}
|
|
699
940
|
function packagedBundledNodePath() {
|
|
700
941
|
const resources = electronResourcesPath();
|
|
701
942
|
if (!resources) return null;
|
|
702
|
-
const bin =
|
|
703
|
-
if (!
|
|
943
|
+
const bin = join3(resources, "node", "bin", "node");
|
|
944
|
+
if (!existsSync4(bin)) return null;
|
|
704
945
|
return bin;
|
|
705
946
|
}
|
|
706
947
|
function packagedCursorRipgrepCandidate(platformPkg, binName) {
|
|
707
948
|
const dir = packagedCursorRuntimeDir();
|
|
708
949
|
if (!dir) return null;
|
|
709
|
-
return
|
|
950
|
+
return join3(dir, "node_modules", platformPkg, "bin", binName);
|
|
710
951
|
}
|
|
711
952
|
|
|
712
953
|
// src/agents/node-launch.ts
|
|
@@ -742,7 +983,7 @@ function unpackedAsarPath(filePath) {
|
|
|
742
983
|
if (!isAsarPath(filePath)) return null;
|
|
743
984
|
const unpacked = filePath.replace(/\.asar(?=[/\\])/, ".asar.unpacked");
|
|
744
985
|
if (unpacked === filePath) return null;
|
|
745
|
-
return
|
|
986
|
+
return existsSync5(unpacked) ? unpacked : null;
|
|
746
987
|
}
|
|
747
988
|
function nodeReadableScriptPath(scriptPath) {
|
|
748
989
|
return unpackedAsarPath(scriptPath) ?? scriptPath;
|
|
@@ -783,37 +1024,37 @@ function pickPreferredNode(candidates) {
|
|
|
783
1024
|
return best;
|
|
784
1025
|
}
|
|
785
1026
|
function versionDirNodeBins(root, toBin) {
|
|
786
|
-
if (!
|
|
1027
|
+
if (!existsSync5(root)) return [];
|
|
787
1028
|
try {
|
|
788
1029
|
return readdirSync(root).map(toBin);
|
|
789
1030
|
} catch {
|
|
790
1031
|
return [];
|
|
791
1032
|
}
|
|
792
1033
|
}
|
|
793
|
-
function defaultNodeBinCandidates(home =
|
|
1034
|
+
function defaultNodeBinCandidates(home = homedir2()) {
|
|
794
1035
|
const kegs = ["/opt/homebrew", "/usr/local"].flatMap(
|
|
795
|
-
(prefix) => PREFERRED_LTS_MAJORS.map((major) =>
|
|
1036
|
+
(prefix) => PREFERRED_LTS_MAJORS.map((major) => join4(prefix, "opt", `node@${major}`, "bin", "node"))
|
|
796
1037
|
);
|
|
797
1038
|
return [
|
|
798
1039
|
...kegs,
|
|
799
1040
|
"/opt/homebrew/bin/node",
|
|
800
1041
|
"/usr/local/bin/node",
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
1042
|
+
join4(home, ".local/share/fnm/aliases/default/bin/node"),
|
|
1043
|
+
join4(home, ".nvm/current/bin/node"),
|
|
1044
|
+
join4(home, ".volta/bin/node"),
|
|
1045
|
+
join4(home, ".asdf/shims/node"),
|
|
1046
|
+
join4(home, ".local/share/mise/shims/node"),
|
|
806
1047
|
...versionDirNodeBins(
|
|
807
|
-
|
|
808
|
-
(name) =>
|
|
1048
|
+
join4(home, ".nvm", "versions", "node"),
|
|
1049
|
+
(name) => join4(home, ".nvm", "versions", "node", name, "bin", "node")
|
|
809
1050
|
),
|
|
810
1051
|
...versionDirNodeBins(
|
|
811
|
-
|
|
812
|
-
(name) =>
|
|
1052
|
+
join4(home, ".local/share/fnm", "node-versions"),
|
|
1053
|
+
(name) => join4(home, ".local/share/fnm", "node-versions", name, "installation", "bin", "node")
|
|
813
1054
|
),
|
|
814
1055
|
...versionDirNodeBins(
|
|
815
|
-
|
|
816
|
-
(name) =>
|
|
1056
|
+
join4(home, ".volta", "tools", "image", "node"),
|
|
1057
|
+
(name) => join4(home, ".volta", "tools", "image", "node", name, "bin", "node")
|
|
817
1058
|
)
|
|
818
1059
|
];
|
|
819
1060
|
}
|
|
@@ -822,7 +1063,7 @@ function uniqueExistingNodeBins(paths) {
|
|
|
822
1063
|
const out = [];
|
|
823
1064
|
for (const raw of paths) {
|
|
824
1065
|
const p = raw.trim();
|
|
825
|
-
if (!p || !
|
|
1066
|
+
if (!p || !existsSync5(p) || isElectronLikeCommand(p)) continue;
|
|
826
1067
|
let key = p;
|
|
827
1068
|
try {
|
|
828
1069
|
key = realpathSync(p);
|
|
@@ -1041,7 +1282,7 @@ function corePackageDir() {
|
|
|
1041
1282
|
} catch {
|
|
1042
1283
|
}
|
|
1043
1284
|
try {
|
|
1044
|
-
const req = createRequire(
|
|
1285
|
+
const req = createRequire(join5(process.cwd(), "package.json"));
|
|
1045
1286
|
return dirname2(req.resolve("@sideboard-ai/core"));
|
|
1046
1287
|
} catch {
|
|
1047
1288
|
return process.cwd();
|
|
@@ -1049,22 +1290,22 @@ function corePackageDir() {
|
|
|
1049
1290
|
}
|
|
1050
1291
|
function findSideboardMcpJsEntry() {
|
|
1051
1292
|
const override = process.env.SIDEBOARD_MCP_ENTRY?.trim() || process.env.SIDEBOARD_CLI?.trim();
|
|
1052
|
-
if (override &&
|
|
1293
|
+
if (override && existsSync6(override)) return override;
|
|
1053
1294
|
const packaged = packagedMcpStdioPath();
|
|
1054
1295
|
if (packaged) return packaged;
|
|
1055
1296
|
let dir = corePackageDir();
|
|
1056
1297
|
for (let i = 0; i < 10; i++) {
|
|
1057
1298
|
const candidates = [
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1299
|
+
join5(dir, "mcp/run-stdio.js"),
|
|
1300
|
+
join5(dir, "mcp/run-stdio.cjs"),
|
|
1301
|
+
join5(dir, "dist/mcp/run-stdio.js"),
|
|
1302
|
+
join5(dir, "dist/mcp/run-stdio.cjs"),
|
|
1303
|
+
join5(dir, "packages/core/dist/mcp/run-stdio.js"),
|
|
1304
|
+
join5(dir, "packages/cli/dist/index.js"),
|
|
1305
|
+
join5(dir, "cli/dist/index.js")
|
|
1065
1306
|
];
|
|
1066
1307
|
for (const p of candidates) {
|
|
1067
|
-
if (
|
|
1308
|
+
if (existsSync6(p) && !isAsarPath(p)) return p;
|
|
1068
1309
|
}
|
|
1069
1310
|
const parent = dirname2(dir);
|
|
1070
1311
|
if (parent === dir) break;
|
|
@@ -1227,15 +1468,15 @@ function mcpServersRecord(servers, extraServers) {
|
|
|
1227
1468
|
function writeMcpServersConfig(servers, extraServers) {
|
|
1228
1469
|
const mcpServers = mcpServersRecord(servers, extraServers);
|
|
1229
1470
|
if (Object.keys(mcpServers).length === 0) return null;
|
|
1230
|
-
const dir = mkdtempSync(
|
|
1231
|
-
const cfgPath =
|
|
1471
|
+
const dir = mkdtempSync(join5(tmpdir(), "sideboard-mcp-"));
|
|
1472
|
+
const cfgPath = join5(dir, "mcp.json");
|
|
1232
1473
|
writeFileSync2(cfgPath, JSON.stringify({ mcpServers }, null, 2));
|
|
1233
1474
|
return cfgPath;
|
|
1234
1475
|
}
|
|
1235
1476
|
|
|
1236
1477
|
// src/agents/user-mcp-config.ts
|
|
1237
1478
|
function userClaudeMcpConfigPath() {
|
|
1238
|
-
return
|
|
1479
|
+
return join6(homedir3(), ".claude.json");
|
|
1239
1480
|
}
|
|
1240
1481
|
|
|
1241
1482
|
// src/agents/orch-mcp-isolation.ts
|
|
@@ -1260,25 +1501,25 @@ function listMcpNamesFromCodexToml(text) {
|
|
|
1260
1501
|
}
|
|
1261
1502
|
function readJsonObject(path) {
|
|
1262
1503
|
try {
|
|
1263
|
-
return JSON.parse(
|
|
1504
|
+
return JSON.parse(readFileSync4(path, "utf8"));
|
|
1264
1505
|
} catch {
|
|
1265
1506
|
return {};
|
|
1266
1507
|
}
|
|
1267
1508
|
}
|
|
1268
1509
|
function readText(path) {
|
|
1269
1510
|
try {
|
|
1270
|
-
return
|
|
1511
|
+
return readFileSync4(path, "utf8");
|
|
1271
1512
|
} catch {
|
|
1272
1513
|
return "";
|
|
1273
1514
|
}
|
|
1274
1515
|
}
|
|
1275
|
-
function userCodexConfigPaths(home =
|
|
1276
|
-
return [
|
|
1516
|
+
function userCodexConfigPaths(home = homedir4()) {
|
|
1517
|
+
return [join7(home, ".codex", "config.toml"), join7(home, ".config", "codex", "config.toml")];
|
|
1277
1518
|
}
|
|
1278
|
-
function userOpencodeConfigPaths(home =
|
|
1519
|
+
function userOpencodeConfigPaths(home = homedir4()) {
|
|
1279
1520
|
return [
|
|
1280
|
-
|
|
1281
|
-
|
|
1521
|
+
join7(home, ".config", "opencode", "opencode.json"),
|
|
1522
|
+
join7(home, ".config", "opencode", "opencode.jsonc")
|
|
1282
1523
|
];
|
|
1283
1524
|
}
|
|
1284
1525
|
function userMcpNamesToDisable(opts) {
|
|
@@ -1297,29 +1538,35 @@ function userMcpNamesToDisable(opts) {
|
|
|
1297
1538
|
}
|
|
1298
1539
|
return out;
|
|
1299
1540
|
}
|
|
1300
|
-
function listUserCodexMcpNames(home =
|
|
1541
|
+
function listUserCodexMcpNames(home = homedir4()) {
|
|
1301
1542
|
const names = [];
|
|
1302
1543
|
for (const path of userCodexConfigPaths(home)) {
|
|
1303
|
-
if (!
|
|
1544
|
+
if (!existsSync8(path)) continue;
|
|
1304
1545
|
names.push(...listMcpNamesFromCodexToml(readText(path)));
|
|
1305
1546
|
}
|
|
1306
1547
|
return names;
|
|
1307
1548
|
}
|
|
1308
|
-
function listUserOpencodeMcpNames(home =
|
|
1549
|
+
function listUserOpencodeMcpNames(home = homedir4()) {
|
|
1309
1550
|
const names = [];
|
|
1310
1551
|
for (const path of userOpencodeConfigPaths(home)) {
|
|
1311
|
-
if (!
|
|
1552
|
+
if (!existsSync8(path)) continue;
|
|
1312
1553
|
names.push(...listMcpNamesFromJsonMap(readJsonObject(path), "mcp"));
|
|
1313
1554
|
}
|
|
1314
1555
|
return names;
|
|
1315
1556
|
}
|
|
1316
|
-
function userClaudeMcpConfigObject(home =
|
|
1317
|
-
const claudePath = home ===
|
|
1318
|
-
if (!
|
|
1557
|
+
function userClaudeMcpConfigObject(home = homedir4()) {
|
|
1558
|
+
const claudePath = home === homedir4() ? userClaudeMcpConfigPath() : join7(home, ".claude.json");
|
|
1559
|
+
if (!existsSync8(claudePath)) return {};
|
|
1319
1560
|
return asObject(asObject(readJsonObject(claudePath)).mcpServers);
|
|
1320
1561
|
}
|
|
1321
|
-
function listUserClaudeMcpServerEntries(home =
|
|
1562
|
+
function listUserClaudeMcpServerEntries(home = homedir4(), projectDirs) {
|
|
1322
1563
|
const out = {};
|
|
1564
|
+
for (const [name, entry] of Object.entries(
|
|
1565
|
+
listEnabledClaudePluginMcpServers({ home, projectDirs })
|
|
1566
|
+
)) {
|
|
1567
|
+
if (!name || isInjectedOrchMcpName(name)) continue;
|
|
1568
|
+
out[name] = entry;
|
|
1569
|
+
}
|
|
1323
1570
|
for (const [rawName, value] of Object.entries(userClaudeMcpConfigObject(home))) {
|
|
1324
1571
|
const name = rawName.trim();
|
|
1325
1572
|
if (!name || isInjectedOrchMcpName(name)) continue;
|
|
@@ -1395,14 +1642,14 @@ function permissionMode(thread) {
|
|
|
1395
1642
|
}
|
|
1396
1643
|
|
|
1397
1644
|
// src/agent-rpc/metadata.ts
|
|
1398
|
-
import { existsSync as
|
|
1399
|
-
import { join as
|
|
1645
|
+
import { existsSync as existsSync9, readFileSync as readFileSync5, unlinkSync, writeFileSync as writeFileSync4 } from "fs";
|
|
1646
|
+
import { join as join8 } from "path";
|
|
1400
1647
|
function agentRuntimeMetadataPath() {
|
|
1401
|
-
return
|
|
1648
|
+
return join8(appDataDir(), "agent-runtime.json");
|
|
1402
1649
|
}
|
|
1403
1650
|
function readAgentRuntimeMetadata() {
|
|
1404
1651
|
try {
|
|
1405
|
-
const raw = JSON.parse(
|
|
1652
|
+
const raw = JSON.parse(readFileSync5(agentRuntimeMetadataPath(), "utf8"));
|
|
1406
1653
|
if (!raw || typeof raw !== "object") return null;
|
|
1407
1654
|
const rec = raw;
|
|
1408
1655
|
if (typeof rec.runtimeId !== "string" || !rec.runtimeId.trim()) return null;
|
|
@@ -1465,9 +1712,9 @@ function agentRpcChildEnv(rpc, cwd) {
|
|
|
1465
1712
|
}
|
|
1466
1713
|
|
|
1467
1714
|
// src/agents/claude-host.ts
|
|
1468
|
-
import { existsSync as
|
|
1715
|
+
import { existsSync as existsSync10 } from "fs";
|
|
1469
1716
|
import { createRequire as createRequire2 } from "module";
|
|
1470
|
-
import { dirname as dirname4, join as
|
|
1717
|
+
import { dirname as dirname4, join as join9 } from "path";
|
|
1471
1718
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1472
1719
|
|
|
1473
1720
|
// src/agent-rpc/client.ts
|
|
@@ -1512,20 +1759,20 @@ function entryDir() {
|
|
|
1512
1759
|
function claudeRunnerPath() {
|
|
1513
1760
|
const packagedDir = packagedCursorRuntimeDir();
|
|
1514
1761
|
if (packagedDir) {
|
|
1515
|
-
const packaged =
|
|
1516
|
-
if (
|
|
1762
|
+
const packaged = join9(packagedDir, "core-dist", "agents", "claude-runner.js");
|
|
1763
|
+
if (existsSync10(packaged)) return packaged;
|
|
1517
1764
|
}
|
|
1518
1765
|
const root = entryDir();
|
|
1519
1766
|
const candidates = [
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1767
|
+
join9(root, "agents", "claude-runner.js"),
|
|
1768
|
+
join9(root, "agents", "claude-runner.cjs"),
|
|
1769
|
+
join9(root, "dist", "agents", "claude-runner.js"),
|
|
1770
|
+
join9(root, "dist", "agents", "claude-runner.cjs"),
|
|
1771
|
+
join9(root, "claude-runner.ts"),
|
|
1772
|
+
join9(root, "src", "agents", "claude-runner.ts")
|
|
1526
1773
|
];
|
|
1527
1774
|
for (const candidate of candidates) {
|
|
1528
|
-
if (
|
|
1775
|
+
if (existsSync10(candidate)) return candidate;
|
|
1529
1776
|
}
|
|
1530
1777
|
return candidates[0];
|
|
1531
1778
|
}
|
|
@@ -1930,7 +2177,7 @@ var claudeAdapter = {
|
|
|
1930
2177
|
async detect() {
|
|
1931
2178
|
const claude = resolveClaudeExecutable();
|
|
1932
2179
|
if (claude !== "claude") {
|
|
1933
|
-
if (!
|
|
2180
|
+
if (!existsSync11(claude)) {
|
|
1934
2181
|
return {
|
|
1935
2182
|
agent: "claude",
|
|
1936
2183
|
installed: false,
|
|
@@ -1979,7 +2226,7 @@ var claudeAdapter = {
|
|
|
1979
2226
|
);
|
|
1980
2227
|
}
|
|
1981
2228
|
const mode = permissionMode(thread);
|
|
1982
|
-
const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-
|
|
2229
|
+
const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-H6X32IJZ.js");
|
|
1983
2230
|
const isOrchestrator = isOrchestratorThread2(thread);
|
|
1984
2231
|
const rpc = worktreeAgentRpc(isOrchestrator);
|
|
1985
2232
|
const injectedServers = await buildInjectedMcpServers({
|
|
@@ -1993,7 +2240,7 @@ var claudeAdapter = {
|
|
|
1993
2240
|
});
|
|
1994
2241
|
const injectedBrightsyNames = injectedServers.filter((s) => s.name === "brightsy" || s.name.startsWith("brightsy_")).map((s) => s.name);
|
|
1995
2242
|
const chromeOn = claudeChromeEnabled();
|
|
1996
|
-
const userMcpEntries = isOrchestrator ? {} : listUserClaudeMcpServerEntries();
|
|
2243
|
+
const userMcpEntries = isOrchestrator ? {} : listUserClaudeMcpServerEntries(homedir5(), [thread.repoPath, thread.worktreePath]);
|
|
1997
2244
|
let allowedTools;
|
|
1998
2245
|
if (isOrchestrator) {
|
|
1999
2246
|
allowedTools = [
|
|
@@ -2244,9 +2491,9 @@ function parseIssuesJson(raw) {
|
|
|
2244
2491
|
}
|
|
2245
2492
|
|
|
2246
2493
|
// src/agents/codex.ts
|
|
2247
|
-
import { existsSync as
|
|
2248
|
-
import { homedir as
|
|
2249
|
-
import { join as
|
|
2494
|
+
import { existsSync as existsSync12, readFileSync as readFileSync6, statSync as statSync2 } from "fs";
|
|
2495
|
+
import { homedir as homedir6 } from "os";
|
|
2496
|
+
import { join as join10 } from "path";
|
|
2250
2497
|
var CODEX_PROMPT_ARG_MAX = 2e5;
|
|
2251
2498
|
var FALLBACK_CODEX_MODELS = [
|
|
2252
2499
|
{ id: "gpt-5.6-sol", displayName: "GPT-5.6 Sol" },
|
|
@@ -2266,7 +2513,7 @@ async function listCodexModels() {
|
|
|
2266
2513
|
if (codex === "codex") {
|
|
2267
2514
|
const which = await run("which", ["codex"], { reject: false });
|
|
2268
2515
|
if (which.exitCode !== 0) return FALLBACK_CODEX_MODELS;
|
|
2269
|
-
} else if (!
|
|
2516
|
+
} else if (!existsSync12(codex)) {
|
|
2270
2517
|
return FALLBACK_CODEX_MODELS;
|
|
2271
2518
|
}
|
|
2272
2519
|
const listed = await run(codex, ["debug", "models"], { reject: false });
|
|
@@ -2301,12 +2548,12 @@ function usageFromCodex(usage) {
|
|
|
2301
2548
|
}
|
|
2302
2549
|
function codexConfigHasNetworkAccess() {
|
|
2303
2550
|
const candidates = [
|
|
2304
|
-
|
|
2305
|
-
|
|
2551
|
+
join10(homedir6(), ".codex", "config.toml"),
|
|
2552
|
+
join10(homedir6(), ".config", "codex", "config.toml")
|
|
2306
2553
|
];
|
|
2307
2554
|
for (const path of candidates) {
|
|
2308
|
-
if (!
|
|
2309
|
-
const text =
|
|
2555
|
+
if (!existsSync12(path)) continue;
|
|
2556
|
+
const text = readFileSync6(path, "utf8");
|
|
2310
2557
|
if (/network_access\s*=\s*true/.test(text)) return true;
|
|
2311
2558
|
}
|
|
2312
2559
|
return false;
|
|
@@ -2331,15 +2578,15 @@ function unwrapCodexMcpResult(result) {
|
|
|
2331
2578
|
return String(result);
|
|
2332
2579
|
}
|
|
2333
2580
|
}
|
|
2334
|
-
function
|
|
2581
|
+
function asRecord2(value) {
|
|
2335
2582
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
2336
2583
|
return value;
|
|
2337
2584
|
}
|
|
2338
2585
|
return void 0;
|
|
2339
2586
|
}
|
|
2340
2587
|
function codexLooksAuthenticated() {
|
|
2341
|
-
const authPath =
|
|
2342
|
-
if (!
|
|
2588
|
+
const authPath = join10(homedir6(), ".codex", "auth.json");
|
|
2589
|
+
if (!existsSync12(authPath)) return false;
|
|
2343
2590
|
try {
|
|
2344
2591
|
return statSync2(authPath).size > 2;
|
|
2345
2592
|
} catch {
|
|
@@ -2351,7 +2598,7 @@ var codexAdapter = {
|
|
|
2351
2598
|
async detect() {
|
|
2352
2599
|
const codex = resolveAgentExecutable("codex");
|
|
2353
2600
|
if (codex !== "codex") {
|
|
2354
|
-
if (!
|
|
2601
|
+
if (!existsSync12(codex)) {
|
|
2355
2602
|
return {
|
|
2356
2603
|
agent: "codex",
|
|
2357
2604
|
installed: false,
|
|
@@ -2484,7 +2731,7 @@ var codexAdapter = {
|
|
|
2484
2731
|
}
|
|
2485
2732
|
if (itemType === "mcp_tool_call" && item.id && item.server && item.tool) {
|
|
2486
2733
|
const name = `mcp__${item.server}__${item.tool}`;
|
|
2487
|
-
const input =
|
|
2734
|
+
const input = asRecord2(item.arguments);
|
|
2488
2735
|
const events = [
|
|
2489
2736
|
{ type: "tool_use", id: item.id, name, input }
|
|
2490
2737
|
];
|
|
@@ -2625,31 +2872,31 @@ var codexAdapter = {
|
|
|
2625
2872
|
};
|
|
2626
2873
|
|
|
2627
2874
|
// src/agents/cursor.ts
|
|
2628
|
-
import { existsSync as
|
|
2875
|
+
import { existsSync as existsSync15 } from "fs";
|
|
2629
2876
|
import { createRequire as createRequire5 } from "module";
|
|
2630
|
-
import { dirname as dirname7, join as
|
|
2877
|
+
import { dirname as dirname7, join as join13 } from "path";
|
|
2631
2878
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
2632
2879
|
|
|
2633
2880
|
// src/agents/cursor-sdk-resolve.ts
|
|
2634
|
-
import { existsSync as
|
|
2881
|
+
import { existsSync as existsSync13, readFileSync as readFileSync7 } from "fs";
|
|
2635
2882
|
import { createRequire as createRequire3 } from "module";
|
|
2636
|
-
import { basename, dirname as dirname5, join as
|
|
2883
|
+
import { basename, dirname as dirname5, join as join11 } from "path";
|
|
2637
2884
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
|
|
2638
2885
|
var CURSOR_SDK_INSTALL_HINT = "Cursor SDK is not installed. Settings \u2192 Agents \u2192 Cursor \u2192 Install (`npm i -g @cursor/sdk`). Sideboard does not ship the SDK \u2014 update it anytime without a new Sideboard build.";
|
|
2639
2886
|
function thisModuleFile() {
|
|
2640
2887
|
const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
|
|
2641
|
-
if (cjsDir) return
|
|
2888
|
+
if (cjsDir) return join11(cjsDir, "cursor-sdk-resolve.js");
|
|
2642
2889
|
try {
|
|
2643
2890
|
return fileURLToPath3(import.meta.url);
|
|
2644
2891
|
} catch {
|
|
2645
|
-
return
|
|
2892
|
+
return join11(process.cwd(), "package.json");
|
|
2646
2893
|
}
|
|
2647
2894
|
}
|
|
2648
2895
|
function packageRootLooksLikeSdk(dir) {
|
|
2649
2896
|
try {
|
|
2650
|
-
const raw =
|
|
2897
|
+
const raw = readFileSync7(join11(dir, "package.json"), "utf8");
|
|
2651
2898
|
const pkg = JSON.parse(raw);
|
|
2652
|
-
return pkg.name === "@cursor/sdk" &&
|
|
2899
|
+
return pkg.name === "@cursor/sdk" && existsSync13(dir);
|
|
2653
2900
|
} catch {
|
|
2654
2901
|
return false;
|
|
2655
2902
|
}
|
|
@@ -2672,10 +2919,10 @@ function resolveCursorSdkRoot(opts) {
|
|
|
2672
2919
|
}
|
|
2673
2920
|
const globalNm = npmGlobalNodeModules(env);
|
|
2674
2921
|
if (globalNm) {
|
|
2675
|
-
const globalRoot =
|
|
2922
|
+
const globalRoot = join11(globalNm, "@cursor/sdk");
|
|
2676
2923
|
if (packageRootLooksLikeSdk(globalRoot)) return globalRoot;
|
|
2677
2924
|
}
|
|
2678
|
-
const cwdPkg =
|
|
2925
|
+
const cwdPkg = join11(process.cwd(), "package.json");
|
|
2679
2926
|
return resolvedPackageRoot(thisModuleFile()) ?? resolvedPackageRoot(cwdPkg);
|
|
2680
2927
|
}
|
|
2681
2928
|
function isCursorSdkInstalled(opts) {
|
|
@@ -2691,13 +2938,13 @@ function exportTarget(value) {
|
|
|
2691
2938
|
}
|
|
2692
2939
|
function cursorSdkEsmEntry(root) {
|
|
2693
2940
|
try {
|
|
2694
|
-
const pkg = JSON.parse(
|
|
2941
|
+
const pkg = JSON.parse(readFileSync7(join11(root, "package.json"), "utf8"));
|
|
2695
2942
|
const exp = pkg.exports;
|
|
2696
2943
|
const dot = exp && typeof exp === "object" && !Array.isArray(exp) && "." in exp ? exp["."] : exp;
|
|
2697
2944
|
const rel = exportTarget(dot) ?? (typeof pkg.module === "string" ? pkg.module : null);
|
|
2698
2945
|
if (!rel) return null;
|
|
2699
|
-
const entry =
|
|
2700
|
-
return
|
|
2946
|
+
const entry = join11(root, rel);
|
|
2947
|
+
return existsSync13(entry) ? entry : null;
|
|
2701
2948
|
} catch {
|
|
2702
2949
|
return null;
|
|
2703
2950
|
}
|
|
@@ -2713,7 +2960,7 @@ async function importCursorSdk(opts) {
|
|
|
2713
2960
|
try {
|
|
2714
2961
|
let entry = cursorSdkEsmEntry(root);
|
|
2715
2962
|
if (!entry) {
|
|
2716
|
-
const req = createRequire3(
|
|
2963
|
+
const req = createRequire3(join11(root, "package.json"));
|
|
2717
2964
|
entry = req.resolve("@cursor/sdk");
|
|
2718
2965
|
}
|
|
2719
2966
|
return unwrapCursorSdkModule(await import(pathToFileURL(entry).href));
|
|
@@ -2734,10 +2981,10 @@ function cursorSdkRipgrepCandidate(opts) {
|
|
|
2734
2981
|
const nm = nodeModulesDirForPackageRoot(root);
|
|
2735
2982
|
const pkg = cursorSdkPlatformRipgrepPackage();
|
|
2736
2983
|
const bin = process.platform === "win32" ? "rg.exe" : "rg";
|
|
2737
|
-
const sibling =
|
|
2738
|
-
if (
|
|
2739
|
-
const nested =
|
|
2740
|
-
return
|
|
2984
|
+
const sibling = join11(nm, pkg, "bin", bin);
|
|
2985
|
+
if (existsSync13(sibling)) return sibling;
|
|
2986
|
+
const nested = join11(root, "node_modules", pkg, "bin", bin);
|
|
2987
|
+
return existsSync13(nested) ? nested : null;
|
|
2741
2988
|
}
|
|
2742
2989
|
|
|
2743
2990
|
// src/agents/cursor-events.ts
|
|
@@ -2785,20 +3032,20 @@ function turnCostUsdFromCursorUsage(before, after) {
|
|
|
2785
3032
|
if (!(delta >= 0) || !Number.isFinite(delta)) return void 0;
|
|
2786
3033
|
return delta / 100;
|
|
2787
3034
|
}
|
|
2788
|
-
function
|
|
3035
|
+
function asRecord3(value) {
|
|
2789
3036
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
2790
3037
|
return value;
|
|
2791
3038
|
}
|
|
2792
3039
|
return void 0;
|
|
2793
3040
|
}
|
|
2794
3041
|
function normalizeCursorToolCall(name, args) {
|
|
2795
|
-
const raw =
|
|
3042
|
+
const raw = asRecord3(args);
|
|
2796
3043
|
const toolName = typeof raw?.toolName === "string" && raw.toolName.trim() ? raw.toolName.trim() : null;
|
|
2797
|
-
const looksLikeMcp = name === "mcp" || toolName != null && (typeof raw?.providerIdentifier === "string" ||
|
|
3044
|
+
const looksLikeMcp = name === "mcp" || toolName != null && (typeof raw?.providerIdentifier === "string" || asRecord3(raw?.args) != null);
|
|
2798
3045
|
if (looksLikeMcp && toolName) {
|
|
2799
3046
|
const providerRaw = typeof raw.providerIdentifier === "string" && raw.providerIdentifier.trim() ? raw.providerIdentifier.trim() : "sideboard";
|
|
2800
3047
|
const provider = providerRaw.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2801
|
-
const nested =
|
|
3048
|
+
const nested = asRecord3(raw.args);
|
|
2802
3049
|
return {
|
|
2803
3050
|
name: `mcp__${provider}__${toolName}`,
|
|
2804
3051
|
input: nested ?? { toolName }
|
|
@@ -2809,7 +3056,7 @@ function normalizeCursorToolCall(name, args) {
|
|
|
2809
3056
|
function unwrapCursorToolResult(result) {
|
|
2810
3057
|
if (result == null) return void 0;
|
|
2811
3058
|
if (typeof result === "string") return result;
|
|
2812
|
-
const rec =
|
|
3059
|
+
const rec = asRecord3(result);
|
|
2813
3060
|
if (!rec) {
|
|
2814
3061
|
try {
|
|
2815
3062
|
return JSON.stringify(result);
|
|
@@ -2820,18 +3067,18 @@ function unwrapCursorToolResult(result) {
|
|
|
2820
3067
|
const collectTexts = (items) => {
|
|
2821
3068
|
const texts = [];
|
|
2822
3069
|
for (const item of items) {
|
|
2823
|
-
const row =
|
|
3070
|
+
const row = asRecord3(item);
|
|
2824
3071
|
if (!row) continue;
|
|
2825
3072
|
if (typeof row.text === "string") {
|
|
2826
3073
|
texts.push(row.text);
|
|
2827
3074
|
continue;
|
|
2828
3075
|
}
|
|
2829
|
-
const nested =
|
|
3076
|
+
const nested = asRecord3(row.text);
|
|
2830
3077
|
if (typeof nested?.text === "string") texts.push(nested.text);
|
|
2831
3078
|
}
|
|
2832
3079
|
return texts;
|
|
2833
3080
|
};
|
|
2834
|
-
const value =
|
|
3081
|
+
const value = asRecord3(rec.value);
|
|
2835
3082
|
if (value && Array.isArray(value.content)) {
|
|
2836
3083
|
const texts = collectTexts(value.content);
|
|
2837
3084
|
if (texts.length) return texts.join("\n");
|
|
@@ -2848,10 +3095,10 @@ function unwrapCursorToolResult(result) {
|
|
|
2848
3095
|
}
|
|
2849
3096
|
function cursorToolResultIsError(status, result) {
|
|
2850
3097
|
if (status === "error") return true;
|
|
2851
|
-
const rec =
|
|
3098
|
+
const rec = asRecord3(result);
|
|
2852
3099
|
if (!rec) return false;
|
|
2853
3100
|
if (rec.status === "error") return true;
|
|
2854
|
-
const value =
|
|
3101
|
+
const value = asRecord3(rec.value);
|
|
2855
3102
|
return value?.isError === true;
|
|
2856
3103
|
}
|
|
2857
3104
|
function cursorSdkMessageToEvents(msg) {
|
|
@@ -2952,9 +3199,9 @@ function parseCursorRunnerLine(line) {
|
|
|
2952
3199
|
}
|
|
2953
3200
|
|
|
2954
3201
|
// src/agents/cursor-ripgrep.ts
|
|
2955
|
-
import { existsSync as
|
|
3202
|
+
import { existsSync as existsSync14 } from "fs";
|
|
2956
3203
|
import { createRequire as createRequire4 } from "module";
|
|
2957
|
-
import { dirname as dirname6, isAbsolute, join as
|
|
3204
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join12, parse, resolve as resolvePath } from "path";
|
|
2958
3205
|
var RIPGREP_ENV = "CURSOR_RIPGREP_PATH";
|
|
2959
3206
|
function rgBinaryName() {
|
|
2960
3207
|
return process.platform === "win32" ? "rg.exe" : "rg";
|
|
@@ -2964,9 +3211,9 @@ function platformRipgrepPackage() {
|
|
|
2964
3211
|
}
|
|
2965
3212
|
function usableRipgrepPath(candidate) {
|
|
2966
3213
|
const raw = candidate?.trim();
|
|
2967
|
-
if (!raw || !
|
|
3214
|
+
if (!raw || !isAbsolute2(raw)) return null;
|
|
2968
3215
|
const readable = nodeReadableScriptPath(raw);
|
|
2969
|
-
if (!
|
|
3216
|
+
if (!existsSync14(readable) || isAsarPath(readable)) return null;
|
|
2970
3217
|
return readable;
|
|
2971
3218
|
}
|
|
2972
3219
|
function walkForBundledRipgrep(startFile) {
|
|
@@ -2976,7 +3223,7 @@ function walkForBundledRipgrep(startFile) {
|
|
|
2976
3223
|
let dir = dirname6(resolvePath(startFile));
|
|
2977
3224
|
const root = parse(dir).root;
|
|
2978
3225
|
while (dir !== root) {
|
|
2979
|
-
const hit = usableRipgrepPath(
|
|
3226
|
+
const hit = usableRipgrepPath(join12(dir, "node_modules", pkg, "bin", name));
|
|
2980
3227
|
if (hit) return hit;
|
|
2981
3228
|
const next = dirname6(dir);
|
|
2982
3229
|
if (next === dir) break;
|
|
@@ -2988,7 +3235,7 @@ function requireResolveBundledRipgrep(fromFile) {
|
|
|
2988
3235
|
try {
|
|
2989
3236
|
const req = createRequire4(fromFile);
|
|
2990
3237
|
const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
|
|
2991
|
-
return usableRipgrepPath(
|
|
3238
|
+
return usableRipgrepPath(join12(dirname6(pkgJson), "bin", rgBinaryName()));
|
|
2992
3239
|
} catch {
|
|
2993
3240
|
return null;
|
|
2994
3241
|
}
|
|
@@ -3077,17 +3324,17 @@ function cursorRunnerPath() {
|
|
|
3077
3324
|
if (packaged) return packaged;
|
|
3078
3325
|
const root = entryDir2();
|
|
3079
3326
|
const candidates = [
|
|
3080
|
-
|
|
3081
|
-
|
|
3327
|
+
join13(root, "agents", "cursor-runner.js"),
|
|
3328
|
+
join13(root, "agents", "cursor-runner.cjs"),
|
|
3082
3329
|
// If somehow resolved from package root instead of dist/
|
|
3083
|
-
|
|
3084
|
-
|
|
3330
|
+
join13(root, "dist", "agents", "cursor-runner.js"),
|
|
3331
|
+
join13(root, "dist", "agents", "cursor-runner.cjs"),
|
|
3085
3332
|
// Source tree (dev): packages/core/src/agents/cursor-runner.ts
|
|
3086
|
-
|
|
3087
|
-
|
|
3333
|
+
join13(root, "cursor-runner.ts"),
|
|
3334
|
+
join13(root, "src", "agents", "cursor-runner.ts")
|
|
3088
3335
|
];
|
|
3089
3336
|
for (const candidate of candidates) {
|
|
3090
|
-
if (
|
|
3337
|
+
if (existsSync15(candidate)) return candidate;
|
|
3091
3338
|
}
|
|
3092
3339
|
return candidates[0];
|
|
3093
3340
|
}
|
|
@@ -3190,11 +3437,11 @@ var cursorAdapter = {
|
|
|
3190
3437
|
};
|
|
3191
3438
|
|
|
3192
3439
|
// src/agents/opencode.ts
|
|
3193
|
-
import { existsSync as
|
|
3440
|
+
import { existsSync as existsSync16 } from "fs";
|
|
3194
3441
|
|
|
3195
3442
|
// src/agent-rpc/opencode-hook.ts
|
|
3196
3443
|
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
3197
|
-
import { join as
|
|
3444
|
+
import { join as join14 } from "path";
|
|
3198
3445
|
var OPENCODE_PLUGIN_SOURCE = `import { tool } from "@opencode-ai/plugin"
|
|
3199
3446
|
|
|
3200
3447
|
const URL = process.env[${JSON.stringify(AGENT_RPC_URL_ENV)}] || ""
|
|
@@ -3299,10 +3546,10 @@ export const SideboardRpc = async (ctx) => {
|
|
|
3299
3546
|
}
|
|
3300
3547
|
`;
|
|
3301
3548
|
function writeOpencodeRpcPlugin() {
|
|
3302
|
-
const configDir =
|
|
3303
|
-
const pluginDir =
|
|
3549
|
+
const configDir = join14(appDataDir(), "agent-rpc", "opencode");
|
|
3550
|
+
const pluginDir = join14(configDir, "plugins");
|
|
3304
3551
|
mkdirSync3(pluginDir, { recursive: true });
|
|
3305
|
-
const pluginFile =
|
|
3552
|
+
const pluginFile = join14(pluginDir, "sideboard-rpc.js");
|
|
3306
3553
|
writeFileSync5(pluginFile, OPENCODE_PLUGIN_SOURCE);
|
|
3307
3554
|
return { configDir, pluginFile };
|
|
3308
3555
|
}
|
|
@@ -3352,7 +3599,7 @@ var FALLBACK_OPENCODE_MODELS = [
|
|
|
3352
3599
|
];
|
|
3353
3600
|
var cachedOpencodeModels = null;
|
|
3354
3601
|
var OPENCODE_MODEL_CACHE_MS = 5 * 60 * 1e3;
|
|
3355
|
-
function
|
|
3602
|
+
function asRecord4(value) {
|
|
3356
3603
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
3357
3604
|
return value;
|
|
3358
3605
|
}
|
|
@@ -3397,7 +3644,7 @@ async function listOpencodeModels() {
|
|
|
3397
3644
|
if (opencode === "opencode") {
|
|
3398
3645
|
const which = await run("which", ["opencode"], { reject: false });
|
|
3399
3646
|
if (which.exitCode !== 0) return FALLBACK_OPENCODE_MODELS;
|
|
3400
|
-
} else if (!
|
|
3647
|
+
} else if (!existsSync16(opencode)) {
|
|
3401
3648
|
return FALLBACK_OPENCODE_MODELS;
|
|
3402
3649
|
}
|
|
3403
3650
|
const listed = await run(opencode, ["models"], { reject: false });
|
|
@@ -3432,7 +3679,7 @@ var opencodeAdapter = {
|
|
|
3432
3679
|
async detect() {
|
|
3433
3680
|
const opencode = resolveAgentExecutable("opencode");
|
|
3434
3681
|
if (opencode !== "opencode") {
|
|
3435
|
-
if (!
|
|
3682
|
+
if (!existsSync16(opencode)) {
|
|
3436
3683
|
return {
|
|
3437
3684
|
agent: "opencode",
|
|
3438
3685
|
installed: false,
|
|
@@ -3523,7 +3770,7 @@ var opencodeAdapter = {
|
|
|
3523
3770
|
const name = part?.tool ?? part?.name ?? obj.tool ?? obj.name ?? "tool";
|
|
3524
3771
|
const state = part?.state;
|
|
3525
3772
|
const input = (state?.input && typeof state.input === "object" ? state.input : void 0) ?? part?.input ?? obj.input;
|
|
3526
|
-
const metadata =
|
|
3773
|
+
const metadata = asRecord4(state?.metadata);
|
|
3527
3774
|
const id = opencodeToolId(
|
|
3528
3775
|
name,
|
|
3529
3776
|
part?.callID ?? part?.id ?? obj.id,
|
|
@@ -3558,7 +3805,7 @@ var opencodeAdapter = {
|
|
|
3558
3805
|
}
|
|
3559
3806
|
if (obj.type === "subtask_event") {
|
|
3560
3807
|
const parentId = str(obj.childSessionID) ?? str(obj.childSessionId);
|
|
3561
|
-
const part =
|
|
3808
|
+
const part = asRecord4(obj.part);
|
|
3562
3809
|
if (!parentId || !part) return null;
|
|
3563
3810
|
if (part.type === "text" && str(part.text)) {
|
|
3564
3811
|
return withTaskParent(
|
|
@@ -3569,8 +3816,8 @@ var opencodeAdapter = {
|
|
|
3569
3816
|
if (part.type === "tool" || str(part.tool)) {
|
|
3570
3817
|
const name = str(part.tool) ?? str(part.name) ?? "tool";
|
|
3571
3818
|
const id = str(part.callID) ?? str(part.id) ?? `${parentId}-${name}`;
|
|
3572
|
-
const state =
|
|
3573
|
-
const input =
|
|
3819
|
+
const state = asRecord4(part.state);
|
|
3820
|
+
const input = asRecord4(state?.input) ?? asRecord4(part.input);
|
|
3574
3821
|
const nested = [
|
|
3575
3822
|
withEventParentId({ type: "tool_use", id, name, input }, parentId)
|
|
3576
3823
|
];
|
|
@@ -3812,12 +4059,12 @@ function parseSessionQuotaResetAt(text, now = /* @__PURE__ */ new Date()) {
|
|
|
3812
4059
|
}
|
|
3813
4060
|
return at;
|
|
3814
4061
|
}
|
|
3815
|
-
const
|
|
4062
|
+
const relative2 = text.match(
|
|
3816
4063
|
/resets\s+in\s+(\d+)\s*(minutes?|hours?|days?)/i
|
|
3817
4064
|
);
|
|
3818
|
-
if (
|
|
3819
|
-
const n = Number(
|
|
3820
|
-
const unit =
|
|
4065
|
+
if (relative2) {
|
|
4066
|
+
const n = Number(relative2[1]);
|
|
4067
|
+
const unit = relative2[2].toLowerCase();
|
|
3821
4068
|
const ms = unit.startsWith("day") ? n * 24 * 60 * 60 * 1e3 : unit.startsWith("hour") ? n * 60 * 60 * 1e3 : n * 60 * 1e3;
|
|
3822
4069
|
return new Date(now.getTime() + ms);
|
|
3823
4070
|
}
|
|
@@ -4097,9 +4344,9 @@ function formatClaudeUsageOverLimitWait(windows, now = /* @__PURE__ */ new Date(
|
|
|
4097
4344
|
}
|
|
4098
4345
|
|
|
4099
4346
|
// src/agents/claude-usage-client.ts
|
|
4100
|
-
import { existsSync as
|
|
4101
|
-
import { homedir as
|
|
4102
|
-
import { join as
|
|
4347
|
+
import { existsSync as existsSync17, readFileSync as readFileSync8 } from "fs";
|
|
4348
|
+
import { homedir as homedir7 } from "os";
|
|
4349
|
+
import { join as join15 } from "path";
|
|
4103
4350
|
var CLAUDE_OAUTH_USAGE_URL = "https://api.anthropic.com/api/oauth/usage";
|
|
4104
4351
|
var CLAUDE_USAGE_TTL_MS = 9e4;
|
|
4105
4352
|
var CLAUDE_USAGE_ERROR_TTL_MS = 5 * 6e4;
|
|
@@ -4139,14 +4386,14 @@ function accessTokenFromCredentialsJson(raw) {
|
|
|
4139
4386
|
}
|
|
4140
4387
|
}
|
|
4141
4388
|
function claudeCredentialsPath(configDir) {
|
|
4142
|
-
const root = configDir?.trim() || process.env.CLAUDE_CONFIG_DIR?.trim() ||
|
|
4143
|
-
return
|
|
4389
|
+
const root = configDir?.trim() || process.env.CLAUDE_CONFIG_DIR?.trim() || join15(homedir7(), ".claude");
|
|
4390
|
+
return join15(root, ".credentials.json");
|
|
4144
4391
|
}
|
|
4145
4392
|
async function readFileAccessToken(configDir) {
|
|
4146
4393
|
const path = claudeCredentialsPath(configDir);
|
|
4147
|
-
if (!
|
|
4394
|
+
if (!existsSync17(path)) return null;
|
|
4148
4395
|
try {
|
|
4149
|
-
return accessTokenFromCredentialsJson(
|
|
4396
|
+
return accessTokenFromCredentialsJson(readFileSync8(path, "utf8"));
|
|
4150
4397
|
} catch {
|
|
4151
4398
|
return null;
|
|
4152
4399
|
}
|