@sideboard-ai/core 0.1.208 → 0.1.209
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-I4IYZBKU.js → abletime-G3MWSZVM.js} +4 -4
- package/dist/{abletime-UWSSLXH3.js → abletime-SQREWITG.js} +4 -4
- package/dist/{abletime-oauth-UZHPB3W2.js → abletime-oauth-7AOE4KJL.js} +3 -3
- package/dist/{abletime-oauth-C3BQXKW3.js → abletime-oauth-SQD6K47H.js} +3 -3
- package/dist/{abletime-rest-5YPPEOKK.js → abletime-rest-BXL7QHCX.js} +3 -3
- package/dist/{abletime-rest-HYNYDYK3.js → abletime-rest-QRTJH42S.js} +3 -3
- package/dist/agents/cursor-runner.js +3 -3
- package/dist/{agents-QHQXR55O.js → agents-KA6HDNNP.js} +6 -5
- package/dist/{agents-CCS5IEBV.js → agents-U2NVCYGC.js} +6 -5
- package/dist/{app-settings-R2KNCT37.js → app-settings-6SZLZNA7.js} +7 -1
- package/dist/{app-settings-GJ6KDYEF.js → app-settings-VBQHGX5Z.js} +7 -1
- package/dist/{chunk-OP6CFVTB.js → chunk-22A45QOI.js} +2 -2
- package/dist/{chunk-NJ2CCLV6.js → chunk-42VGWRSE.js} +2 -2
- package/dist/{chunk-X45BV4VX.js → chunk-5LFD3KCJ.js} +5 -5
- package/dist/{chunk-F4LZUEIO.js → chunk-B2RPIHNJ.js} +2 -2
- package/dist/{chunk-6YZLSZLK.js → chunk-CQZCXRVG.js} +3 -3
- package/dist/{chunk-4EGK47WV.js → chunk-FUC3XFE2.js} +215 -0
- package/dist/{chunk-C6ZNQV5W.js → chunk-HBL7ILQA.js} +117 -25
- package/dist/{chunk-TEDEVD4O.js → chunk-IIENQFJ6.js} +2 -2
- package/dist/{chunk-6J4OQ6TF.js → chunk-IOOL3T7Q.js} +3 -3
- package/dist/{chunk-A6SOSLUV.js → chunk-KJAHVQL6.js} +24 -94
- package/dist/{chunk-7PEIIN7P.js → chunk-MS2P5GXL.js} +24 -87
- package/dist/{chunk-C5MNMITQ.js → chunk-MZP2C4KE.js} +119 -25
- package/dist/{chunk-7DKX5JLT.js → chunk-OY7THBLG.js} +10 -2
- package/dist/{chunk-DNTPX6HV.js → chunk-PTOIWKDU.js} +3 -3
- package/dist/{chunk-W6X4GZJG.js → chunk-QVVJO4GN.js} +3 -3
- package/dist/{chunk-ZHCB4CKR.js → chunk-RPZFNKND.js} +10 -2
- package/dist/{chunk-HA4EZKFY.js → chunk-TZCWNRMC.js} +3 -3
- package/dist/{chunk-Y4CF7LHH.js → chunk-VJQDUD24.js} +230 -0
- package/dist/chunk-X5B3OS5I.js +34 -0
- package/dist/{chunk-WXWJ5MJ4.js → chunk-XRIF6M5H.js} +5 -5
- package/dist/{coordinator-prompt-TUHB6ZFA.js → coordinator-prompt-2YCOE5R4.js} +5 -4
- package/dist/{coordinator-prompt-WOTJQMD5.js → coordinator-prompt-EO2X2EYW.js} +5 -4
- package/dist/{cursor-recover-TXVTLAMA.js → cursor-recover-4PQAADAU.js} +3 -28
- package/dist/{global-workspace-V6G2KH2V.js → global-workspace-H2ANUSGR.js} +5 -4
- package/dist/{global-workspace-5UUUNA4A.js → global-workspace-JEKMVE42.js} +5 -4
- package/dist/index.cjs +671 -384
- package/dist/index.d.cts +93 -4
- package/dist/index.d.ts +93 -4
- package/dist/index.js +52 -19
- package/dist/mcp/run-stdio.cjs +637 -384
- package/dist/mcp/run-stdio.js +12 -11
- package/dist/{orchestrator-D4AQNF25.js → orchestrator-N7LLTK5O.js} +7 -6
- package/dist/{orchestrator-4IGHVRAF.js → orchestrator-RUQXDYM7.js} +7 -6
- package/dist/{thread-store-ESZYZSVC.js → thread-store-55X2JYDT.js} +2 -1
- package/dist/{thread-store-FMWDFAO5.js → thread-store-CMZWM5NY.js} +2 -1
- package/dist/{workspaces-CLNANACI.js → workspaces-2YNYLSPV.js} +5 -4
- package/dist/{workspaces-PZ36M7EQ.js → workspaces-SVDORZEI.js} +5 -4
- package/dist/{worktree-JKTM47K5.js → worktree-5CPGB4D2.js} +4 -3
- package/dist/{worktree-NC4XQNQI.js → worktree-YQ6XUSR2.js} +4 -3
- package/package.json +1 -1
package/dist/mcp/run-stdio.cjs
CHANGED
|
@@ -801,6 +801,37 @@ var init_thinking_effort = __esm({
|
|
|
801
801
|
}
|
|
802
802
|
});
|
|
803
803
|
|
|
804
|
+
// src/agents/cursor-store.ts
|
|
805
|
+
function cursorSdkStoreDir(threadId) {
|
|
806
|
+
const root = (0, import_node_path8.join)(appDataDir(), CURSOR_SDK_STORE_DIR);
|
|
807
|
+
const id = sanitizeCursorStoreSegment(threadId);
|
|
808
|
+
if (!id) return root;
|
|
809
|
+
return (0, import_node_path8.join)(root, "threads", id);
|
|
810
|
+
}
|
|
811
|
+
function cursorSdkRunsNdjsonPath(threadId) {
|
|
812
|
+
return (0, import_node_path8.join)(cursorSdkStoreDir(threadId), "runs.ndjson");
|
|
813
|
+
}
|
|
814
|
+
function cursorSdkRunsNdjsonSearchPaths(threadId) {
|
|
815
|
+
const scoped = cursorSdkRunsNdjsonPath(threadId);
|
|
816
|
+
const shared = cursorSdkRunsNdjsonPath(null);
|
|
817
|
+
if (!threadId || !sanitizeCursorStoreSegment(threadId) || scoped === shared) {
|
|
818
|
+
return [shared];
|
|
819
|
+
}
|
|
820
|
+
return [scoped, shared];
|
|
821
|
+
}
|
|
822
|
+
function sanitizeCursorStoreSegment(threadId) {
|
|
823
|
+
return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
824
|
+
}
|
|
825
|
+
var import_node_path8, CURSOR_SDK_STORE_DIR;
|
|
826
|
+
var init_cursor_store = __esm({
|
|
827
|
+
"src/agents/cursor-store.ts"() {
|
|
828
|
+
"use strict";
|
|
829
|
+
import_node_path8 = require("path");
|
|
830
|
+
init_paths();
|
|
831
|
+
CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
|
|
804
835
|
// src/store/thread-store.ts
|
|
805
836
|
var thread_store_exports = {};
|
|
806
837
|
__export(thread_store_exports, {
|
|
@@ -958,10 +989,10 @@ function readThread(id) {
|
|
|
958
989
|
rememberThread(thread, mtimeMs);
|
|
959
990
|
return thread;
|
|
960
991
|
}
|
|
961
|
-
function writeThread(thread) {
|
|
992
|
+
function writeThread(thread, opts) {
|
|
962
993
|
const path = threadFilePath(idPath(thread.id));
|
|
963
994
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
964
|
-
const next = { ...thread, updatedAt: nowIso() };
|
|
995
|
+
const next = opts?.touch === false ? { ...thread } : { ...thread, updatedAt: nowIso() };
|
|
965
996
|
(0, import_node_fs8.writeFileSync)(tmp, JSON.stringify(next, null, 2), "utf8");
|
|
966
997
|
(0, import_node_fs8.renameSync)(tmp, path);
|
|
967
998
|
rememberThread(next, fileMtimeMs(path) ?? Date.now());
|
|
@@ -970,7 +1001,7 @@ function idPath(id) {
|
|
|
970
1001
|
return id;
|
|
971
1002
|
}
|
|
972
1003
|
function isThreadRecordFile(nameOrPath) {
|
|
973
|
-
const name = (0,
|
|
1004
|
+
const name = (0, import_node_path9.basename)(nameOrPath);
|
|
974
1005
|
return name.endsWith(".json") && !name.endsWith(".live.json");
|
|
975
1006
|
}
|
|
976
1007
|
function listThreads(opts) {
|
|
@@ -1006,6 +1037,10 @@ function deleteThreadRecord(id) {
|
|
|
1006
1037
|
} catch {
|
|
1007
1038
|
}
|
|
1008
1039
|
}
|
|
1040
|
+
try {
|
|
1041
|
+
(0, import_node_fs8.rmSync)(cursorSdkStoreDir(id), { recursive: true, force: true });
|
|
1042
|
+
} catch {
|
|
1043
|
+
}
|
|
1009
1044
|
}
|
|
1010
1045
|
function updateThread(id, patch) {
|
|
1011
1046
|
const current = readThread(id);
|
|
@@ -1028,15 +1063,16 @@ function findThreadByRef(ref) {
|
|
|
1028
1063
|
(t) => t.id === ref || t.id.startsWith(ref) || t.branchName === ref || t.title === ref
|
|
1029
1064
|
) ?? null;
|
|
1030
1065
|
}
|
|
1031
|
-
var import_node_crypto2, import_node_fs8,
|
|
1066
|
+
var import_node_crypto2, import_node_fs8, import_node_path9, import_proper_lockfile, listCache;
|
|
1032
1067
|
var init_thread_store = __esm({
|
|
1033
1068
|
"src/store/thread-store.ts"() {
|
|
1034
1069
|
"use strict";
|
|
1035
1070
|
import_node_crypto2 = require("crypto");
|
|
1036
1071
|
import_node_fs8 = require("fs");
|
|
1037
|
-
|
|
1072
|
+
import_node_path9 = require("path");
|
|
1038
1073
|
import_proper_lockfile = __toESM(require("proper-lockfile"), 1);
|
|
1039
1074
|
init_thinking_effort();
|
|
1075
|
+
init_cursor_store();
|
|
1040
1076
|
init_paths();
|
|
1041
1077
|
listCache = null;
|
|
1042
1078
|
}
|
|
@@ -1086,7 +1122,7 @@ var init_api = __esm({
|
|
|
1086
1122
|
|
|
1087
1123
|
// src/slack/reply-target.ts
|
|
1088
1124
|
function storePath() {
|
|
1089
|
-
return (0,
|
|
1125
|
+
return (0, import_node_path10.join)(appDataDir(), "slack-reply-to.json");
|
|
1090
1126
|
}
|
|
1091
1127
|
function readStore() {
|
|
1092
1128
|
const path = storePath();
|
|
@@ -1101,12 +1137,12 @@ function readStore() {
|
|
|
1101
1137
|
function getSlackReplyTarget(threadId) {
|
|
1102
1138
|
return readStore()[threadId] ?? null;
|
|
1103
1139
|
}
|
|
1104
|
-
var import_node_fs9,
|
|
1140
|
+
var import_node_fs9, import_node_path10;
|
|
1105
1141
|
var init_reply_target = __esm({
|
|
1106
1142
|
"src/slack/reply-target.ts"() {
|
|
1107
1143
|
"use strict";
|
|
1108
1144
|
import_node_fs9 = require("fs");
|
|
1109
|
-
|
|
1145
|
+
import_node_path10 = require("path");
|
|
1110
1146
|
init_paths();
|
|
1111
1147
|
init_private_file();
|
|
1112
1148
|
init_secure_file();
|
|
@@ -1115,7 +1151,7 @@ var init_reply_target = __esm({
|
|
|
1115
1151
|
|
|
1116
1152
|
// src/slack/workspaces.ts
|
|
1117
1153
|
function storePath2() {
|
|
1118
|
-
return (0,
|
|
1154
|
+
return (0, import_node_path11.join)(appDataDir(), "slack-workspaces.json");
|
|
1119
1155
|
}
|
|
1120
1156
|
function readStore2() {
|
|
1121
1157
|
try {
|
|
@@ -1176,11 +1212,11 @@ function requireSlackWorkspace(teamId) {
|
|
|
1176
1212
|
}
|
|
1177
1213
|
return ws;
|
|
1178
1214
|
}
|
|
1179
|
-
var
|
|
1215
|
+
var import_node_path11;
|
|
1180
1216
|
var init_workspaces = __esm({
|
|
1181
1217
|
"src/slack/workspaces.ts"() {
|
|
1182
1218
|
"use strict";
|
|
1183
|
-
|
|
1219
|
+
import_node_path11 = require("path");
|
|
1184
1220
|
init_paths();
|
|
1185
1221
|
init_secure_file();
|
|
1186
1222
|
init_api();
|
|
@@ -1189,7 +1225,7 @@ var init_workspaces = __esm({
|
|
|
1189
1225
|
|
|
1190
1226
|
// src/slack/outbound-watch.ts
|
|
1191
1227
|
function storePath3() {
|
|
1192
|
-
return (0,
|
|
1228
|
+
return (0, import_node_path12.join)(appDataDir(), "slack-outbound-watch.json");
|
|
1193
1229
|
}
|
|
1194
1230
|
function watchId(teamId, channelId, ts) {
|
|
1195
1231
|
return `${teamId}:${channelId}:${ts}`;
|
|
@@ -1526,12 +1562,12 @@ async function pollSlackOutboundWatches(opts) {
|
|
|
1526
1562
|
}
|
|
1527
1563
|
if (changed) writeStore(watches);
|
|
1528
1564
|
}
|
|
1529
|
-
var import_node_fs10,
|
|
1565
|
+
var import_node_fs10, import_node_path12, MAX_WATCHES, MAX_REPLIES_PER_WATCH, WATCH_TTL_MS, POLL_INTERVAL_MS, lastPollMs, nameCache, continueOnReply;
|
|
1530
1566
|
var init_outbound_watch = __esm({
|
|
1531
1567
|
"src/slack/outbound-watch.ts"() {
|
|
1532
1568
|
"use strict";
|
|
1533
1569
|
import_node_fs10 = require("fs");
|
|
1534
|
-
|
|
1570
|
+
import_node_path12 = require("path");
|
|
1535
1571
|
init_paths();
|
|
1536
1572
|
init_private_file();
|
|
1537
1573
|
init_secure_file();
|
|
@@ -1929,23 +1965,23 @@ var init_error_detail = __esm({
|
|
|
1929
1965
|
function prependPathDir(env, dir) {
|
|
1930
1966
|
if (!dir || !(0, import_node_fs11.existsSync)(dir)) return;
|
|
1931
1967
|
const current = env.PATH ?? "";
|
|
1932
|
-
const parts = current.split(
|
|
1968
|
+
const parts = current.split(import_node_path13.delimiter).filter(Boolean);
|
|
1933
1969
|
if (parts.includes(dir)) {
|
|
1934
1970
|
env.PATH = current;
|
|
1935
1971
|
return;
|
|
1936
1972
|
}
|
|
1937
|
-
env.PATH = [dir, ...parts].join(
|
|
1973
|
+
env.PATH = [dir, ...parts].join(import_node_path13.delimiter);
|
|
1938
1974
|
}
|
|
1939
1975
|
function conductorBundledBinDir(home = process.env.HOME || process.env.USERPROFILE || (0, import_node_os3.homedir)()) {
|
|
1940
|
-
return (0,
|
|
1976
|
+
return (0, import_node_path13.join)(home, "Library", "Application Support", "com.conductor.app", "bin");
|
|
1941
1977
|
}
|
|
1942
1978
|
function ensureAgentPath(env = process.env) {
|
|
1943
1979
|
const home = env.HOME || env.USERPROFILE || (0, import_node_os3.homedir)();
|
|
1944
1980
|
const current = env.PATH ?? "";
|
|
1945
|
-
const parts = current.split(
|
|
1981
|
+
const parts = current.split(import_node_path13.delimiter).filter(Boolean);
|
|
1946
1982
|
const seen = new Set(parts);
|
|
1947
1983
|
const extras = [
|
|
1948
|
-
...EXTRA_BIN_DIRS.map((rel) => (0,
|
|
1984
|
+
...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path13.join)(home, rel)),
|
|
1949
1985
|
"/opt/homebrew/bin",
|
|
1950
1986
|
"/usr/local/bin",
|
|
1951
1987
|
// Keep after Homebrew/npm so a user-installed CLI still wins.
|
|
@@ -1956,7 +1992,7 @@ function ensureAgentPath(env = process.env) {
|
|
|
1956
1992
|
parts.unshift(dir);
|
|
1957
1993
|
seen.add(dir);
|
|
1958
1994
|
}
|
|
1959
|
-
const next = parts.join(
|
|
1995
|
+
const next = parts.join(import_node_path13.delimiter);
|
|
1960
1996
|
env.PATH = next;
|
|
1961
1997
|
return next;
|
|
1962
1998
|
}
|
|
@@ -1970,21 +2006,21 @@ function enrichPathWithNpmGlobalBin(env = process.env) {
|
|
|
1970
2006
|
stdio: ["ignore", "pipe", "ignore"]
|
|
1971
2007
|
}).trim().split(/\r?\n/).find(Boolean);
|
|
1972
2008
|
if (prefix) {
|
|
1973
|
-
const binDir = process.platform === "win32" ? prefix : (0,
|
|
2009
|
+
const binDir = process.platform === "win32" ? prefix : (0, import_node_path13.join)(prefix, "bin");
|
|
1974
2010
|
prependPathDir(env, binDir);
|
|
1975
2011
|
}
|
|
1976
2012
|
} catch {
|
|
1977
2013
|
}
|
|
1978
2014
|
return env.PATH ?? "";
|
|
1979
2015
|
}
|
|
1980
|
-
var import_node_fs11, import_node_child_process3, import_node_os3,
|
|
2016
|
+
var import_node_fs11, import_node_child_process3, import_node_os3, import_node_path13, EXTRA_BIN_DIRS;
|
|
1981
2017
|
var init_path = __esm({
|
|
1982
2018
|
"src/agents/path.ts"() {
|
|
1983
2019
|
"use strict";
|
|
1984
2020
|
import_node_fs11 = require("fs");
|
|
1985
2021
|
import_node_child_process3 = require("child_process");
|
|
1986
2022
|
import_node_os3 = require("os");
|
|
1987
|
-
|
|
2023
|
+
import_node_path13 = require("path");
|
|
1988
2024
|
EXTRA_BIN_DIRS = [
|
|
1989
2025
|
".local/bin",
|
|
1990
2026
|
".cargo/bin",
|
|
@@ -2005,18 +2041,18 @@ var init_path = __esm({
|
|
|
2005
2041
|
function githubAgentAuthDir() {
|
|
2006
2042
|
const override = process.env.SIDEBOARD_GIT_AUTH_DIR?.trim();
|
|
2007
2043
|
if (override) return override;
|
|
2008
|
-
return (0,
|
|
2044
|
+
return (0, import_node_path14.join)((0, import_node_os4.homedir)(), ".sideboard-git-auth");
|
|
2009
2045
|
}
|
|
2010
2046
|
function githubCredentialStorePath() {
|
|
2011
|
-
return (0,
|
|
2047
|
+
return (0, import_node_path14.join)(githubAgentAuthDir(), "git-credentials");
|
|
2012
2048
|
}
|
|
2013
2049
|
function githubGhConfigDir() {
|
|
2014
|
-
return (0,
|
|
2050
|
+
return (0, import_node_path14.join)(githubAgentAuthDir(), "gh");
|
|
2015
2051
|
}
|
|
2016
2052
|
function writePrivateFile2(file, body) {
|
|
2017
|
-
(0, import_node_fs12.mkdirSync)((0,
|
|
2053
|
+
(0, import_node_fs12.mkdirSync)((0, import_node_path14.dirname)(file), { recursive: true, mode: 448 });
|
|
2018
2054
|
try {
|
|
2019
|
-
(0, import_node_fs12.chmodSync)((0,
|
|
2055
|
+
(0, import_node_fs12.chmodSync)((0, import_node_path14.dirname)(file), 448);
|
|
2020
2056
|
} catch {
|
|
2021
2057
|
}
|
|
2022
2058
|
(0, import_node_fs12.writeFileSync)(file, body, { encoding: "utf8", mode: 384 });
|
|
@@ -2054,11 +2090,11 @@ function materializeGithubAgentAuth(token, user) {
|
|
|
2054
2090
|
writePrivateFile2(githubCredentialStorePath(), gitCredentialStoreContents(trimmed));
|
|
2055
2091
|
const ghDir = githubGhConfigDir();
|
|
2056
2092
|
(0, import_node_fs12.mkdirSync)(ghDir, { recursive: true, mode: 448 });
|
|
2057
|
-
writePrivateFile2((0,
|
|
2058
|
-
writePrivateFile2((0,
|
|
2093
|
+
writePrivateFile2((0, import_node_path14.join)(ghDir, "hosts.yml"), ghHostsYml(trimmed, user));
|
|
2094
|
+
writePrivateFile2((0, import_node_path14.join)(ghDir, "config.yml"), "git_protocol: https\nprompt: disabled\n");
|
|
2059
2095
|
}
|
|
2060
2096
|
function githubAgentAuthReady() {
|
|
2061
|
-
return (0, import_node_fs12.existsSync)(githubCredentialStorePath()) && (0, import_node_fs12.existsSync)((0,
|
|
2097
|
+
return (0, import_node_fs12.existsSync)(githubCredentialStorePath()) && (0, import_node_fs12.existsSync)((0, import_node_path14.join)(githubGhConfigDir(), "hosts.yml"));
|
|
2062
2098
|
}
|
|
2063
2099
|
function githubCredentialHelperGitConfig() {
|
|
2064
2100
|
const file = githubCredentialStorePath();
|
|
@@ -2073,13 +2109,13 @@ function githubGhConfigEnv() {
|
|
|
2073
2109
|
GH_PROMPT_DISABLED: "1"
|
|
2074
2110
|
};
|
|
2075
2111
|
}
|
|
2076
|
-
var import_node_fs12, import_node_os4,
|
|
2112
|
+
var import_node_fs12, import_node_os4, import_node_path14;
|
|
2077
2113
|
var init_github_agent_auth = __esm({
|
|
2078
2114
|
"src/git/github-agent-auth.ts"() {
|
|
2079
2115
|
"use strict";
|
|
2080
2116
|
import_node_fs12 = require("fs");
|
|
2081
2117
|
import_node_os4 = require("os");
|
|
2082
|
-
|
|
2118
|
+
import_node_path14 = require("path");
|
|
2083
2119
|
}
|
|
2084
2120
|
});
|
|
2085
2121
|
|
|
@@ -2088,7 +2124,7 @@ function isIndexLockError(text7) {
|
|
|
2088
2124
|
return /Unable to create ['"][^'"]*index\.lock['"]: File exists/i.test(text7);
|
|
2089
2125
|
}
|
|
2090
2126
|
function clearStaleIndexLock(gitDir, maxAgeMs = STALE_INDEX_LOCK_MS, now = Date.now()) {
|
|
2091
|
-
const lockPath = (0,
|
|
2127
|
+
const lockPath = (0, import_node_path15.join)(gitDir, "index.lock");
|
|
2092
2128
|
try {
|
|
2093
2129
|
if (!(0, import_node_fs13.existsSync)(lockPath)) return null;
|
|
2094
2130
|
if (now - (0, import_node_fs13.statSync)(lockPath).mtimeMs < maxAgeMs) return null;
|
|
@@ -2107,12 +2143,12 @@ function clearStaleIndexLocks(gitDirs, maxAgeMs = STALE_INDEX_LOCK_MS) {
|
|
|
2107
2143
|
}
|
|
2108
2144
|
return removed;
|
|
2109
2145
|
}
|
|
2110
|
-
var import_node_fs13,
|
|
2146
|
+
var import_node_fs13, import_node_path15, STALE_INDEX_LOCK_MS;
|
|
2111
2147
|
var init_stale_lock = __esm({
|
|
2112
2148
|
"src/git/stale-lock.ts"() {
|
|
2113
2149
|
"use strict";
|
|
2114
2150
|
import_node_fs13 = require("fs");
|
|
2115
|
-
|
|
2151
|
+
import_node_path15 = require("path");
|
|
2116
2152
|
STALE_INDEX_LOCK_MS = 2e4;
|
|
2117
2153
|
}
|
|
2118
2154
|
});
|
|
@@ -3222,8 +3258,8 @@ async function ensureWorktreeSideboardIgnored(worktreePath) {
|
|
|
3222
3258
|
if (gitDir.exitCode !== 0) return;
|
|
3223
3259
|
const dir = gitDir.stdout.trim();
|
|
3224
3260
|
if (!dir) return;
|
|
3225
|
-
const excludePath = (0,
|
|
3226
|
-
(0, import_node_fs14.mkdirSync)((0,
|
|
3261
|
+
const excludePath = (0, import_node_path16.join)(dir, "info", "exclude");
|
|
3262
|
+
(0, import_node_fs14.mkdirSync)((0, import_node_path16.dirname)(excludePath), { recursive: true });
|
|
3227
3263
|
let body = "";
|
|
3228
3264
|
try {
|
|
3229
3265
|
body = (0, import_node_fs14.readFileSync)(excludePath, "utf8");
|
|
@@ -3257,12 +3293,12 @@ async function ensureWorktreeSideboardIgnored(worktreePath) {
|
|
|
3257
3293
|
timeoutMs: 8e3
|
|
3258
3294
|
});
|
|
3259
3295
|
}
|
|
3260
|
-
var import_node_fs14,
|
|
3296
|
+
var import_node_fs14, import_node_path16, WORKTREE_SIDEBOARD_EXCLUDE, WORKTREE_CONTEXT_EXCLUDE, EXCLUDE_COMMENT;
|
|
3261
3297
|
var init_worktree_exclude = __esm({
|
|
3262
3298
|
"src/git/worktree-exclude.ts"() {
|
|
3263
3299
|
"use strict";
|
|
3264
3300
|
import_node_fs14 = require("fs");
|
|
3265
|
-
|
|
3301
|
+
import_node_path16 = require("path");
|
|
3266
3302
|
init_run();
|
|
3267
3303
|
WORKTREE_SIDEBOARD_EXCLUDE = ".sideboard/";
|
|
3268
3304
|
WORKTREE_CONTEXT_EXCLUDE = ".context/";
|
|
@@ -3413,7 +3449,7 @@ var init_account_profile = __esm({
|
|
|
3413
3449
|
|
|
3414
3450
|
// src/store/secret-vault.ts
|
|
3415
3451
|
function secretVaultPath() {
|
|
3416
|
-
return (0,
|
|
3452
|
+
return (0, import_node_path17.join)(appDataDir(), "secrets.json");
|
|
3417
3453
|
}
|
|
3418
3454
|
function loadSecretVault() {
|
|
3419
3455
|
const parsed = readSecureJson(secretVaultPath());
|
|
@@ -3475,11 +3511,11 @@ function normalizeVault(raw) {
|
|
|
3475
3511
|
}
|
|
3476
3512
|
return out;
|
|
3477
3513
|
}
|
|
3478
|
-
var
|
|
3514
|
+
var import_node_path17;
|
|
3479
3515
|
var init_secret_vault = __esm({
|
|
3480
3516
|
"src/store/secret-vault.ts"() {
|
|
3481
3517
|
"use strict";
|
|
3482
|
-
|
|
3518
|
+
import_node_path17 = require("path");
|
|
3483
3519
|
init_paths();
|
|
3484
3520
|
init_secure_file();
|
|
3485
3521
|
}
|
|
@@ -3511,6 +3547,177 @@ var init_branch_prefix = __esm({
|
|
|
3511
3547
|
}
|
|
3512
3548
|
});
|
|
3513
3549
|
|
|
3550
|
+
// src/agents/usage.ts
|
|
3551
|
+
function sumOptional(a, b) {
|
|
3552
|
+
if (a == null && b == null) return void 0;
|
|
3553
|
+
return (a ?? 0) + (b ?? 0);
|
|
3554
|
+
}
|
|
3555
|
+
function fromInclusiveInputUsage(opts) {
|
|
3556
|
+
const totalInput = Number(opts.inputTokens) || 0;
|
|
3557
|
+
const outputTokens = Number(opts.outputTokens) || 0;
|
|
3558
|
+
const cached = Number(opts.cachedInputTokens) || 0;
|
|
3559
|
+
if (!totalInput && !outputTokens) return null;
|
|
3560
|
+
const cacheReadTokens = cached > 0 ? Math.min(cached, totalInput) : 0;
|
|
3561
|
+
return {
|
|
3562
|
+
inputTokens: Math.max(0, totalInput - cacheReadTokens),
|
|
3563
|
+
outputTokens,
|
|
3564
|
+
cacheReadTokens: cacheReadTokens || void 0
|
|
3565
|
+
};
|
|
3566
|
+
}
|
|
3567
|
+
function requestOccupancy(u) {
|
|
3568
|
+
return u.inputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
|
|
3569
|
+
}
|
|
3570
|
+
function mergeUsage(a, b) {
|
|
3571
|
+
return {
|
|
3572
|
+
inputTokens: (a?.inputTokens ?? 0) + b.inputTokens,
|
|
3573
|
+
outputTokens: (a?.outputTokens ?? 0) + b.outputTokens,
|
|
3574
|
+
cacheReadTokens: sumOptional(a?.cacheReadTokens, b.cacheReadTokens),
|
|
3575
|
+
cacheWriteTokens: sumOptional(a?.cacheWriteTokens, b.cacheWriteTokens),
|
|
3576
|
+
costUsd: sumOptional(a?.costUsd, b.costUsd),
|
|
3577
|
+
lastRequestTokens: b.lastRequestTokens ?? a?.lastRequestTokens
|
|
3578
|
+
};
|
|
3579
|
+
}
|
|
3580
|
+
function sumUsageList(list) {
|
|
3581
|
+
let acc = null;
|
|
3582
|
+
for (const u of list) {
|
|
3583
|
+
if (!u) continue;
|
|
3584
|
+
acc = mergeUsage(acc, {
|
|
3585
|
+
inputTokens: u.inputTokens,
|
|
3586
|
+
outputTokens: u.outputTokens,
|
|
3587
|
+
cacheReadTokens: u.cacheReadTokens,
|
|
3588
|
+
cacheWriteTokens: u.cacheWriteTokens,
|
|
3589
|
+
costUsd: u.costUsd
|
|
3590
|
+
});
|
|
3591
|
+
}
|
|
3592
|
+
if (!acc) return null;
|
|
3593
|
+
return {
|
|
3594
|
+
inputTokens: acc.inputTokens,
|
|
3595
|
+
outputTokens: acc.outputTokens,
|
|
3596
|
+
...acc.cacheReadTokens != null ? { cacheReadTokens: acc.cacheReadTokens } : {},
|
|
3597
|
+
...acc.cacheWriteTokens != null ? { cacheWriteTokens: acc.cacheWriteTokens } : {},
|
|
3598
|
+
...acc.costUsd != null ? { costUsd: acc.costUsd } : {}
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
function hasBilledTokens(u) {
|
|
3602
|
+
return Boolean(
|
|
3603
|
+
u.inputTokens || u.outputTokens || u.cacheReadTokens || u.cacheWriteTokens
|
|
3604
|
+
);
|
|
3605
|
+
}
|
|
3606
|
+
function applyTurnUsage(current, incoming, scope = "request") {
|
|
3607
|
+
if (scope === "turn") {
|
|
3608
|
+
if (!hasBilledTokens(incoming) && current && incoming.costUsd != null) {
|
|
3609
|
+
return { ...current, costUsd: incoming.costUsd };
|
|
3610
|
+
}
|
|
3611
|
+
return {
|
|
3612
|
+
...incoming,
|
|
3613
|
+
costUsd: incoming.costUsd ?? current?.costUsd,
|
|
3614
|
+
lastRequestTokens: current?.lastRequestTokens ?? requestOccupancy(incoming)
|
|
3615
|
+
};
|
|
3616
|
+
}
|
|
3617
|
+
const merged = mergeUsage(current, incoming);
|
|
3618
|
+
const occ = incoming.lastRequestTokens != null && incoming.lastRequestTokens > 0 ? incoming.lastRequestTokens : requestOccupancy(incoming);
|
|
3619
|
+
return {
|
|
3620
|
+
...merged,
|
|
3621
|
+
lastRequestTokens: occ > 0 ? occ : current?.lastRequestTokens ?? occ
|
|
3622
|
+
};
|
|
3623
|
+
}
|
|
3624
|
+
function contextTokens(u) {
|
|
3625
|
+
if (u.lastRequestTokens != null && u.lastRequestTokens > 0) return u.lastRequestTokens;
|
|
3626
|
+
return requestOccupancy(u);
|
|
3627
|
+
}
|
|
3628
|
+
var init_usage = __esm({
|
|
3629
|
+
"src/agents/usage.ts"() {
|
|
3630
|
+
"use strict";
|
|
3631
|
+
}
|
|
3632
|
+
});
|
|
3633
|
+
|
|
3634
|
+
// src/store/history-retention.ts
|
|
3635
|
+
function clampHistoryMaxCount(value) {
|
|
3636
|
+
return Math.max(HISTORY_MAX_COUNT_MIN, Math.min(HISTORY_MAX_COUNT_MAX, Math.floor(value)));
|
|
3637
|
+
}
|
|
3638
|
+
function clampHistoryMaxDays(value) {
|
|
3639
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
3640
|
+
return Math.min(HISTORY_MAX_DAYS_MAX, Math.floor(value));
|
|
3641
|
+
}
|
|
3642
|
+
function archivedUpdatedMs(thread) {
|
|
3643
|
+
const updated = Date.parse(thread.updatedAt);
|
|
3644
|
+
if (Number.isFinite(updated)) return updated;
|
|
3645
|
+
const created = Date.parse(thread.createdAt);
|
|
3646
|
+
return Number.isFinite(created) ? created : 0;
|
|
3647
|
+
}
|
|
3648
|
+
function isHistoryRetentionStub(thread) {
|
|
3649
|
+
if ((thread.attachments?.length ?? 0) > 0) return false;
|
|
3650
|
+
const messages = thread.messages ?? [];
|
|
3651
|
+
if (messages.length === 0) return true;
|
|
3652
|
+
if (messages.length > 1) return false;
|
|
3653
|
+
const only = messages[0];
|
|
3654
|
+
if (only.parts?.length) return false;
|
|
3655
|
+
if ((only.attachments?.length ?? 0) > 0) return false;
|
|
3656
|
+
const text7 = (only.text ?? "").trim();
|
|
3657
|
+
return text7 === "" || text7 === HISTORY_DISCARDED_TEXT;
|
|
3658
|
+
}
|
|
3659
|
+
function historyRetentionStubMessage(thread) {
|
|
3660
|
+
const usage = sumUsageList((thread.messages ?? []).map((m) => m.usage));
|
|
3661
|
+
return {
|
|
3662
|
+
role: "summary",
|
|
3663
|
+
text: HISTORY_DISCARDED_TEXT,
|
|
3664
|
+
ts: thread.updatedAt,
|
|
3665
|
+
...usage ? { usage } : {}
|
|
3666
|
+
};
|
|
3667
|
+
}
|
|
3668
|
+
function sortArchivedOldestFirst(threads) {
|
|
3669
|
+
return [...threads].sort((a, b) => archivedUpdatedMs(a) - archivedUpdatedMs(b));
|
|
3670
|
+
}
|
|
3671
|
+
function planHistoryRetention(archived, thresholds = {}) {
|
|
3672
|
+
const maxCount = clampHistoryMaxCount(thresholds.maxCount ?? HISTORY_MAX_COUNT_DEFAULT);
|
|
3673
|
+
const maxDays = clampHistoryMaxDays(thresholds.maxDays ?? HISTORY_MAX_DAYS_DEFAULT);
|
|
3674
|
+
const nowMs = thresholds.nowMs ?? Date.now();
|
|
3675
|
+
const oldestFirst = sortArchivedOldestFirst(archived);
|
|
3676
|
+
const expiredIds = /* @__PURE__ */ new Set();
|
|
3677
|
+
if (maxDays > 0) {
|
|
3678
|
+
const cutoff = nowMs - maxDays * 864e5;
|
|
3679
|
+
for (const thread of oldestFirst) {
|
|
3680
|
+
if (archivedUpdatedMs(thread) < cutoff) expiredIds.add(thread.id);
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
const remaining = oldestFirst.filter((t) => !expiredIds.has(t.id));
|
|
3684
|
+
const overflow = remaining.length > maxCount ? remaining.slice(0, remaining.length - maxCount) : [];
|
|
3685
|
+
const stripIds = [];
|
|
3686
|
+
const purgeIds = [...expiredIds];
|
|
3687
|
+
const seenPurge = new Set(purgeIds);
|
|
3688
|
+
for (const thread of overflow) {
|
|
3689
|
+
if (isHistoryRetentionStub(thread)) {
|
|
3690
|
+
if (!seenPurge.has(thread.id)) {
|
|
3691
|
+
seenPurge.add(thread.id);
|
|
3692
|
+
purgeIds.push(thread.id);
|
|
3693
|
+
}
|
|
3694
|
+
} else {
|
|
3695
|
+
stripIds.push(thread.id);
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3698
|
+
return { stripIds, purgeIds };
|
|
3699
|
+
}
|
|
3700
|
+
function planHistoryAgePurge(archived, olderThanDays, nowMs = Date.now()) {
|
|
3701
|
+
const days = clampHistoryMaxDays(olderThanDays);
|
|
3702
|
+
if (days <= 0) return [];
|
|
3703
|
+
const cutoff = nowMs - days * 864e5;
|
|
3704
|
+
return sortArchivedOldestFirst(archived).filter((t) => archivedUpdatedMs(t) < cutoff).map((t) => t.id);
|
|
3705
|
+
}
|
|
3706
|
+
var HISTORY_MAX_COUNT_DEFAULT, HISTORY_MAX_COUNT_MIN, HISTORY_MAX_COUNT_MAX, HISTORY_MAX_DAYS_DEFAULT, HISTORY_MAX_DAYS_MAX, HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT, HISTORY_DISCARDED_TEXT;
|
|
3707
|
+
var init_history_retention = __esm({
|
|
3708
|
+
"src/store/history-retention.ts"() {
|
|
3709
|
+
"use strict";
|
|
3710
|
+
init_usage();
|
|
3711
|
+
HISTORY_MAX_COUNT_DEFAULT = 200;
|
|
3712
|
+
HISTORY_MAX_COUNT_MIN = 1;
|
|
3713
|
+
HISTORY_MAX_COUNT_MAX = 2e3;
|
|
3714
|
+
HISTORY_MAX_DAYS_DEFAULT = 0;
|
|
3715
|
+
HISTORY_MAX_DAYS_MAX = 3650;
|
|
3716
|
+
HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT = 6;
|
|
3717
|
+
HISTORY_DISCARDED_TEXT = "Transcript discarded by History retention.";
|
|
3718
|
+
}
|
|
3719
|
+
});
|
|
3720
|
+
|
|
3514
3721
|
// src/store/usage-on-limit.ts
|
|
3515
3722
|
function isUsageOnLimit(value) {
|
|
3516
3723
|
return value === "keep_going" || value === "confirm" || value === "switch_agent" || value === "wait_reset";
|
|
@@ -3567,6 +3774,7 @@ __export(app_settings_exports, {
|
|
|
3567
3774
|
appSettingsPath: () => appSettingsPath,
|
|
3568
3775
|
applyAppEnvironment: () => applyAppEnvironment,
|
|
3569
3776
|
autoArchiveOnMergeEnabled: () => autoArchiveOnMergeEnabled,
|
|
3777
|
+
autoCleanupHistoryEnabled: () => autoCleanupHistoryEnabled,
|
|
3570
3778
|
autoCleanupOrphansEnabled: () => autoCleanupOrphansEnabled,
|
|
3571
3779
|
autoRenameBranchEnabled: () => autoRenameBranchEnabled,
|
|
3572
3780
|
autoRunAfterSetupEnabled: () => autoRunAfterSetupEnabled,
|
|
@@ -3607,6 +3815,8 @@ __export(app_settings_exports, {
|
|
|
3607
3815
|
getLinearApiKey: () => getLinearApiKey,
|
|
3608
3816
|
gitBranchPrefixSetting: () => gitBranchPrefixSetting,
|
|
3609
3817
|
harnessEnvKey: () => harnessEnvKey,
|
|
3818
|
+
historyMaxCount: () => historyMaxCount,
|
|
3819
|
+
historyMaxDays: () => historyMaxDays,
|
|
3610
3820
|
isAbleTimeConnected: () => isAbleTimeConnected,
|
|
3611
3821
|
isIssueSourceConnected: () => isIssueSourceConnected,
|
|
3612
3822
|
isLinearConnected: () => isLinearConnected,
|
|
@@ -3720,10 +3930,10 @@ function toPublicAppSettings(settings) {
|
|
|
3720
3930
|
};
|
|
3721
3931
|
}
|
|
3722
3932
|
function appSettingsPath() {
|
|
3723
|
-
return (0,
|
|
3933
|
+
return (0, import_node_path18.join)(appDataDir(), "settings.json");
|
|
3724
3934
|
}
|
|
3725
3935
|
function claudeUserSettingsPath() {
|
|
3726
|
-
return (0,
|
|
3936
|
+
return (0, import_node_path18.join)((0, import_node_os5.homedir)(), ".claude", "settings.json");
|
|
3727
3937
|
}
|
|
3728
3938
|
function normalizeClaude(raw) {
|
|
3729
3939
|
if (!raw || typeof raw !== "object") return {};
|
|
@@ -3731,7 +3941,7 @@ function normalizeClaude(raw) {
|
|
|
3731
3941
|
const out = {};
|
|
3732
3942
|
if (typeof source.executablePath === "string") {
|
|
3733
3943
|
const path = source.executablePath.trim();
|
|
3734
|
-
if (path && (0,
|
|
3944
|
+
if (path && (0, import_node_path18.isAbsolute)(path)) out.executablePath = path;
|
|
3735
3945
|
}
|
|
3736
3946
|
if (typeof source.chromeEnabled === "boolean") {
|
|
3737
3947
|
out.chromeEnabled = source.chromeEnabled;
|
|
@@ -3744,13 +3954,13 @@ function normalizeCliExecutable(raw) {
|
|
|
3744
3954
|
const out = {};
|
|
3745
3955
|
if (typeof source.executablePath === "string") {
|
|
3746
3956
|
const path = source.executablePath.trim();
|
|
3747
|
-
if (path && (0,
|
|
3957
|
+
if (path && (0, import_node_path18.isAbsolute)(path)) out.executablePath = path;
|
|
3748
3958
|
}
|
|
3749
3959
|
return out;
|
|
3750
3960
|
}
|
|
3751
3961
|
function absoluteExecutablePath(value) {
|
|
3752
3962
|
const path = value.trim();
|
|
3753
|
-
if (!(0,
|
|
3963
|
+
if (!(0, import_node_path18.isAbsolute)(path)) {
|
|
3754
3964
|
throw new Error("Executable path must be absolute. Leave it empty to use the system CLI.");
|
|
3755
3965
|
}
|
|
3756
3966
|
return path;
|
|
@@ -3761,7 +3971,7 @@ function normalizeBrightsy(raw) {
|
|
|
3761
3971
|
const out = {};
|
|
3762
3972
|
if (typeof source.executablePath === "string") {
|
|
3763
3973
|
const path = source.executablePath.trim();
|
|
3764
|
-
if (path && (0,
|
|
3974
|
+
if (path && (0, import_node_path18.isAbsolute)(path)) out.executablePath = path;
|
|
3765
3975
|
}
|
|
3766
3976
|
if (typeof source.cloudConnectEnabled === "boolean") {
|
|
3767
3977
|
out.cloudConnectEnabled = source.cloudConnectEnabled;
|
|
@@ -4052,6 +4262,24 @@ function normalizeAdvanced(raw) {
|
|
|
4052
4262
|
if (typeof source.autoCleanupOrphans === "boolean") {
|
|
4053
4263
|
out.autoCleanupOrphans = source.autoCleanupOrphans;
|
|
4054
4264
|
}
|
|
4265
|
+
if (typeof source.autoCleanupHistory === "boolean") {
|
|
4266
|
+
out.autoCleanupHistory = source.autoCleanupHistory;
|
|
4267
|
+
}
|
|
4268
|
+
if (typeof source.historyMaxCount === "number" && Number.isFinite(source.historyMaxCount)) {
|
|
4269
|
+
out.historyMaxCount = clampHistoryMaxCount(source.historyMaxCount);
|
|
4270
|
+
}
|
|
4271
|
+
if (typeof source.historyMaxDays === "number" && Number.isFinite(source.historyMaxDays)) {
|
|
4272
|
+
out.historyMaxDays = clampHistoryMaxDays(source.historyMaxDays);
|
|
4273
|
+
}
|
|
4274
|
+
if (typeof source.historyCleanupIntervalHours === "number" && Number.isFinite(source.historyCleanupIntervalHours)) {
|
|
4275
|
+
out.historyCleanupIntervalHours = Math.max(
|
|
4276
|
+
1,
|
|
4277
|
+
Math.min(168, Math.floor(source.historyCleanupIntervalHours))
|
|
4278
|
+
);
|
|
4279
|
+
}
|
|
4280
|
+
if (typeof source.historyLastCleanupAt === "string" && source.historyLastCleanupAt.trim()) {
|
|
4281
|
+
out.historyLastCleanupAt = source.historyLastCleanupAt.trim();
|
|
4282
|
+
}
|
|
4055
4283
|
if (source.orchestrationQuotaOnLimit === "switch_agent" || source.orchestrationQuotaOnLimit === "wait_reset") {
|
|
4056
4284
|
out.orchestrationQuotaOnLimit = source.orchestrationQuotaOnLimit;
|
|
4057
4285
|
}
|
|
@@ -4944,6 +5172,24 @@ function updateAdvancedSettings(patch) {
|
|
|
4944
5172
|
if (typeof patch.autoCleanupOrphans === "boolean") {
|
|
4945
5173
|
advanced.autoCleanupOrphans = patch.autoCleanupOrphans;
|
|
4946
5174
|
}
|
|
5175
|
+
if (typeof patch.autoCleanupHistory === "boolean") {
|
|
5176
|
+
advanced.autoCleanupHistory = patch.autoCleanupHistory;
|
|
5177
|
+
}
|
|
5178
|
+
if (typeof patch.historyMaxCount === "number" && Number.isFinite(patch.historyMaxCount)) {
|
|
5179
|
+
advanced.historyMaxCount = clampHistoryMaxCount(patch.historyMaxCount);
|
|
5180
|
+
}
|
|
5181
|
+
if (typeof patch.historyMaxDays === "number" && Number.isFinite(patch.historyMaxDays)) {
|
|
5182
|
+
advanced.historyMaxDays = clampHistoryMaxDays(patch.historyMaxDays);
|
|
5183
|
+
}
|
|
5184
|
+
if (typeof patch.historyCleanupIntervalHours === "number" && Number.isFinite(patch.historyCleanupIntervalHours)) {
|
|
5185
|
+
advanced.historyCleanupIntervalHours = Math.max(
|
|
5186
|
+
1,
|
|
5187
|
+
Math.min(168, Math.floor(patch.historyCleanupIntervalHours))
|
|
5188
|
+
);
|
|
5189
|
+
}
|
|
5190
|
+
if (typeof patch.historyLastCleanupAt === "string") {
|
|
5191
|
+
advanced.historyLastCleanupAt = patch.historyLastCleanupAt;
|
|
5192
|
+
}
|
|
4947
5193
|
if (patch.orchestrationQuotaOnLimit === "switch_agent" || patch.orchestrationQuotaOnLimit === "wait_reset") {
|
|
4948
5194
|
advanced.orchestrationQuotaOnLimit = patch.orchestrationQuotaOnLimit;
|
|
4949
5195
|
}
|
|
@@ -4994,6 +5240,15 @@ function autoArchiveOnMergeEnabled(settings = loadAppSettings()) {
|
|
|
4994
5240
|
function autoCleanupOrphansEnabled(settings = loadAppSettings()) {
|
|
4995
5241
|
return Boolean(settings.advanced.autoCleanupOrphans);
|
|
4996
5242
|
}
|
|
5243
|
+
function autoCleanupHistoryEnabled(settings = loadAppSettings()) {
|
|
5244
|
+
return settings.advanced.autoCleanupHistory !== false;
|
|
5245
|
+
}
|
|
5246
|
+
function historyMaxCount(settings = loadAppSettings()) {
|
|
5247
|
+
return clampHistoryMaxCount(settings.advanced.historyMaxCount ?? HISTORY_MAX_COUNT_DEFAULT);
|
|
5248
|
+
}
|
|
5249
|
+
function historyMaxDays(settings = loadAppSettings()) {
|
|
5250
|
+
return clampHistoryMaxDays(settings.advanced.historyMaxDays ?? HISTORY_MAX_DAYS_DEFAULT);
|
|
5251
|
+
}
|
|
4997
5252
|
function usageOnLimit(settings = loadAppSettings()) {
|
|
4998
5253
|
return resolveUsageOnLimit(settings.advanced);
|
|
4999
5254
|
}
|
|
@@ -5098,14 +5353,14 @@ function childEnvWithAppSettings(extra) {
|
|
|
5098
5353
|
function harnessEnvKey(harness) {
|
|
5099
5354
|
return HARNESS_ENV_KEYS[harness];
|
|
5100
5355
|
}
|
|
5101
|
-
var import_node_crypto3, import_node_fs15, import_node_os5,
|
|
5356
|
+
var import_node_crypto3, import_node_fs15, import_node_os5, import_node_path18, HARNESS_ENV_KEYS, DEFAULT_AGENTS, GITHUB_GIT_AUTH_MODES, FOLLOW_UP_BEHAVIORS, CLOUD_CONNECT_AGENTS, ISSUE_SOURCES, GIT_AUTH_MODES, EMPTY_SETTINGS, CONFIRM_ACCOUNT, CONFIRM_PROJECT, DEFAULT_CLI_BIN;
|
|
5102
5357
|
var init_app_settings = __esm({
|
|
5103
5358
|
"src/store/app-settings.ts"() {
|
|
5104
5359
|
"use strict";
|
|
5105
5360
|
import_node_crypto3 = require("crypto");
|
|
5106
5361
|
import_node_fs15 = require("fs");
|
|
5107
5362
|
import_node_os5 = require("os");
|
|
5108
|
-
|
|
5363
|
+
import_node_path18 = require("path");
|
|
5109
5364
|
init_orchestrator_capable();
|
|
5110
5365
|
init_thinking_effort();
|
|
5111
5366
|
init_nested_electron_env();
|
|
@@ -5114,6 +5369,7 @@ var init_app_settings = __esm({
|
|
|
5114
5369
|
init_private_file();
|
|
5115
5370
|
init_secret_vault();
|
|
5116
5371
|
init_branch_prefix();
|
|
5372
|
+
init_history_retention();
|
|
5117
5373
|
init_usage_on_limit();
|
|
5118
5374
|
init_usage_on_limit();
|
|
5119
5375
|
init_issue_source_labels();
|
|
@@ -5274,7 +5530,7 @@ async function warmGithubAgentAuth(opts) {
|
|
|
5274
5530
|
}
|
|
5275
5531
|
function normalizeWritableRoot(raw) {
|
|
5276
5532
|
const trimmed = raw.trim().replace(/\/+$/, "");
|
|
5277
|
-
return trimmed && (0,
|
|
5533
|
+
return trimmed && (0, import_node_path19.isAbsolute)(trimmed) ? trimmed : null;
|
|
5278
5534
|
}
|
|
5279
5535
|
async function resolveCodexGitWritableRoots(cwd) {
|
|
5280
5536
|
const roots = /* @__PURE__ */ new Set();
|
|
@@ -5352,11 +5608,11 @@ function formatGitAuthModeDirective(mode) {
|
|
|
5352
5608
|
].join("\n");
|
|
5353
5609
|
}
|
|
5354
5610
|
}
|
|
5355
|
-
var
|
|
5611
|
+
var import_node_path19, HTTPS_REWRITE, TOKEN_TTL_MS, tokenMemo, GITHUB_CHILD_TOKEN_KEYS;
|
|
5356
5612
|
var init_git_auth_mode = __esm({
|
|
5357
5613
|
"src/git/git-auth-mode.ts"() {
|
|
5358
5614
|
"use strict";
|
|
5359
|
-
|
|
5615
|
+
import_node_path19 = require("path");
|
|
5360
5616
|
init_app_settings();
|
|
5361
5617
|
init_github_agent_auth();
|
|
5362
5618
|
init_run();
|
|
@@ -7041,7 +7297,7 @@ async function refreshOriginAndMaybeFastForwardMain(repoPath, sourceRef) {
|
|
|
7041
7297
|
}
|
|
7042
7298
|
async function createThreadWorktree(opts) {
|
|
7043
7299
|
let branchName = `thread/${opts.slug}`;
|
|
7044
|
-
const worktreePath = (0,
|
|
7300
|
+
const worktreePath = (0, import_node_path20.join)(worktreesRoot(opts.repoPath), opts.slug);
|
|
7045
7301
|
if ((0, import_node_fs16.existsSync)(worktreePath)) {
|
|
7046
7302
|
throw new Error(`Worktree already exists at ${worktreePath}`);
|
|
7047
7303
|
}
|
|
@@ -7083,7 +7339,7 @@ ${add.stdout}`;
|
|
|
7083
7339
|
async function createExistingBranchWorktree(opts) {
|
|
7084
7340
|
const branchName = opts.branchName.trim();
|
|
7085
7341
|
if (!branchName) throw new Error("branch name required");
|
|
7086
|
-
const worktreePath = (0,
|
|
7342
|
+
const worktreePath = (0, import_node_path20.join)(worktreesRoot(opts.repoPath), opts.slug);
|
|
7087
7343
|
if ((0, import_node_fs16.existsSync)(worktreePath)) {
|
|
7088
7344
|
throw new Error(`Worktree already exists at ${worktreePath}`);
|
|
7089
7345
|
}
|
|
@@ -7365,7 +7621,7 @@ async function createOrUpdatePr(worktreePath, opts) {
|
|
|
7365
7621
|
const headRef = ghHeadRef(slug, opts.head);
|
|
7366
7622
|
const branchOnly = opts.head.trim().replace(/^refs\/heads\//, "");
|
|
7367
7623
|
const bodyText = clampGithubPrBody(opts.body ?? opts.title);
|
|
7368
|
-
const bodyFile = (0,
|
|
7624
|
+
const bodyFile = (0, import_node_path20.join)(
|
|
7369
7625
|
(0, import_node_os6.tmpdir)(),
|
|
7370
7626
|
`sideboard-pr-body-${process.pid}-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}.md`
|
|
7371
7627
|
);
|
|
@@ -7465,7 +7721,7 @@ function sameRepoPath(a, b) {
|
|
|
7465
7721
|
return normalizeWorktreePath(a) === normalizeWorktreePath(b);
|
|
7466
7722
|
}
|
|
7467
7723
|
function listLocalThreadBranchSlugs(repoPath) {
|
|
7468
|
-
const refsDir = (0,
|
|
7724
|
+
const refsDir = (0, import_node_path20.join)(repoPath, ".git", "refs", "heads", "thread");
|
|
7469
7725
|
if (!(0, import_node_fs16.existsSync)(refsDir)) return [];
|
|
7470
7726
|
try {
|
|
7471
7727
|
return (0, import_node_fs16.readdirSync)(refsDir).filter((name) => !name.startsWith(".")).map((name) => normalizeTakenSlug(name));
|
|
@@ -7502,20 +7758,20 @@ function allocateTeamSlug(repoPath) {
|
|
|
7502
7758
|
const taken = collectTakenTeamSlugs(repoPath);
|
|
7503
7759
|
for (let attempt = 0; attempt < 32; attempt++) {
|
|
7504
7760
|
const team = allocateTeamName(taken);
|
|
7505
|
-
const path = (0,
|
|
7761
|
+
const path = (0, import_node_path20.join)(worktreesRoot(repoPath), team.slug);
|
|
7506
7762
|
if (!(0, import_node_fs16.existsSync)(path)) return team;
|
|
7507
7763
|
taken.add(team.slug);
|
|
7508
7764
|
}
|
|
7509
7765
|
throw new Error("No available soccer team worktree directories left");
|
|
7510
7766
|
}
|
|
7511
|
-
var import_node_crypto4, import_node_fs16, import_node_os6,
|
|
7767
|
+
var import_node_crypto4, import_node_fs16, import_node_os6, import_node_path20, PR_DETAILS_JSON_FIELDS;
|
|
7512
7768
|
var init_worktree = __esm({
|
|
7513
7769
|
"src/git/worktree.ts"() {
|
|
7514
7770
|
"use strict";
|
|
7515
7771
|
import_node_crypto4 = require("crypto");
|
|
7516
7772
|
import_node_fs16 = require("fs");
|
|
7517
7773
|
import_node_os6 = require("os");
|
|
7518
|
-
|
|
7774
|
+
import_node_path20 = require("path");
|
|
7519
7775
|
init_paths();
|
|
7520
7776
|
init_thread_store();
|
|
7521
7777
|
init_teams();
|
|
@@ -7587,7 +7843,7 @@ var init_cloud_connect_constants = __esm({
|
|
|
7587
7843
|
|
|
7588
7844
|
// src/composer/stage-files.ts
|
|
7589
7845
|
function fileExtension(filePath) {
|
|
7590
|
-
const base = (0,
|
|
7846
|
+
const base = (0, import_node_path21.basename)(filePath).toLowerCase();
|
|
7591
7847
|
return base.includes(".") ? base.split(".").pop() || "" : "";
|
|
7592
7848
|
}
|
|
7593
7849
|
function isImageFilePath(filePath) {
|
|
@@ -7597,9 +7853,9 @@ function imageMimeType(filePath) {
|
|
|
7597
7853
|
return IMAGE_MIME_BY_EXT[fileExtension(filePath)] || "image/png";
|
|
7598
7854
|
}
|
|
7599
7855
|
function ensureAttachmentsDir(worktreePath) {
|
|
7600
|
-
const dir = (0,
|
|
7856
|
+
const dir = (0, import_node_path21.join)(worktreePath, ATTACHMENTS_DIR);
|
|
7601
7857
|
(0, import_node_fs17.mkdirSync)(dir, { recursive: true });
|
|
7602
|
-
const gi = (0,
|
|
7858
|
+
const gi = (0, import_node_path21.join)(dir, ".gitignore");
|
|
7603
7859
|
if (!(0, import_node_fs17.existsSync)(gi)) {
|
|
7604
7860
|
(0, import_node_fs17.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
|
|
7605
7861
|
}
|
|
@@ -7607,12 +7863,12 @@ function ensureAttachmentsDir(worktreePath) {
|
|
|
7607
7863
|
}
|
|
7608
7864
|
function uniqueAttachmentName(dir, originalName) {
|
|
7609
7865
|
const safe = originalName.replace(/[/\\]/g, "_") || "file";
|
|
7610
|
-
if (!(0, import_node_fs17.existsSync)((0,
|
|
7611
|
-
const ext = (0,
|
|
7866
|
+
if (!(0, import_node_fs17.existsSync)((0, import_node_path21.join)(dir, safe))) return safe;
|
|
7867
|
+
const ext = (0, import_node_path21.extname)(safe);
|
|
7612
7868
|
const stem = ext ? safe.slice(0, -ext.length) : safe;
|
|
7613
7869
|
for (let i = 1; i < 1e4; i++) {
|
|
7614
7870
|
const candidate = `${stem}-${i}${ext}`;
|
|
7615
|
-
if (!(0, import_node_fs17.existsSync)((0,
|
|
7871
|
+
if (!(0, import_node_fs17.existsSync)((0, import_node_path21.join)(dir, candidate))) return candidate;
|
|
7616
7872
|
}
|
|
7617
7873
|
return `${stem}-${(0, import_node_crypto5.randomUUID)()}${ext}`;
|
|
7618
7874
|
}
|
|
@@ -7668,12 +7924,12 @@ function stageAbsolutePathsAsAttachments(worktreePath, absolutePaths) {
|
|
|
7668
7924
|
const dir = ensureAttachmentsDir(worktreePath);
|
|
7669
7925
|
const out = [];
|
|
7670
7926
|
for (const abs of absolutePaths) {
|
|
7671
|
-
const originalName = (0,
|
|
7927
|
+
const originalName = (0, import_node_path21.basename)(abs);
|
|
7672
7928
|
try {
|
|
7673
7929
|
const st = (0, import_node_fs17.statSync)(abs);
|
|
7674
7930
|
if (!st.isFile()) continue;
|
|
7675
7931
|
const name = uniqueAttachmentName(dir, originalName);
|
|
7676
|
-
const destAbs = (0,
|
|
7932
|
+
const destAbs = (0, import_node_path21.join)(dir, name);
|
|
7677
7933
|
(0, import_node_fs17.copyFileSync)(abs, destAbs);
|
|
7678
7934
|
const rel = `${ATTACHMENTS_DIR}/${name}`;
|
|
7679
7935
|
const buf = (0, import_node_fs17.readFileSync)(destAbs);
|
|
@@ -7698,7 +7954,7 @@ function stageBuffersAsAttachments(worktreePath, buffers2) {
|
|
|
7698
7954
|
try {
|
|
7699
7955
|
const buf = Buffer.from(item.dataBase64, "base64");
|
|
7700
7956
|
const name = uniqueAttachmentName(dir, originalName);
|
|
7701
|
-
const destAbs = (0,
|
|
7957
|
+
const destAbs = (0, import_node_path21.join)(dir, name);
|
|
7702
7958
|
(0, import_node_fs17.writeFileSync)(destAbs, buf);
|
|
7703
7959
|
const rel = `${ATTACHMENTS_DIR}/${name}`;
|
|
7704
7960
|
out.push(attachmentFromBuffer(name, buf, { path: rel }));
|
|
@@ -7760,15 +8016,15 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
|
|
|
7760
8016
|
if (!rel || rel.includes("..") || rel.startsWith("/")) {
|
|
7761
8017
|
out.push({
|
|
7762
8018
|
id: (0, import_node_crypto5.randomUUID)(),
|
|
7763
|
-
name: (0,
|
|
8019
|
+
name: (0, import_node_path21.basename)(rel) || "file",
|
|
7764
8020
|
kind: "file",
|
|
7765
8021
|
content: `(invalid path: ${rel})`
|
|
7766
8022
|
});
|
|
7767
8023
|
continue;
|
|
7768
8024
|
}
|
|
7769
|
-
const name = (0,
|
|
8025
|
+
const name = (0, import_node_path21.basename)(rel);
|
|
7770
8026
|
try {
|
|
7771
|
-
const abs = (0,
|
|
8027
|
+
const abs = (0, import_node_path21.join)(worktreePath, rel);
|
|
7772
8028
|
const st = (0, import_node_fs17.statSync)(abs);
|
|
7773
8029
|
if (!st.isFile()) continue;
|
|
7774
8030
|
const buf = (0, import_node_fs17.readFileSync)(abs);
|
|
@@ -7784,12 +8040,12 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
|
|
|
7784
8040
|
}
|
|
7785
8041
|
return out;
|
|
7786
8042
|
}
|
|
7787
|
-
var import_node_fs17,
|
|
8043
|
+
var import_node_fs17, import_node_path21, import_node_crypto5, IMAGE_EXTENSIONS, IMAGE_MIME_BY_EXT, MAX_INLINE_BYTES, MAX_PREVIEW_BYTES, IMAGE_HINT_RE, PLACEHOLDER_CONTENT_RE;
|
|
7788
8044
|
var init_stage_files = __esm({
|
|
7789
8045
|
"src/composer/stage-files.ts"() {
|
|
7790
8046
|
"use strict";
|
|
7791
8047
|
import_node_fs17 = require("fs");
|
|
7792
|
-
|
|
8048
|
+
import_node_path21 = require("path");
|
|
7793
8049
|
import_node_crypto5 = require("crypto");
|
|
7794
8050
|
init_workspace_scratch();
|
|
7795
8051
|
IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
@@ -7829,10 +8085,10 @@ __export(workspaces_exports, {
|
|
|
7829
8085
|
syncWorkspacesFromThreads: () => syncWorkspacesFromThreads
|
|
7830
8086
|
});
|
|
7831
8087
|
function workspacesFile() {
|
|
7832
|
-
return (0,
|
|
8088
|
+
return (0, import_node_path22.join)(appDataDir(), "workspaces.json");
|
|
7833
8089
|
}
|
|
7834
8090
|
function removedWorkspacesFile() {
|
|
7835
|
-
return (0,
|
|
8091
|
+
return (0, import_node_path22.join)(appDataDir(), "removed-workspaces.json");
|
|
7836
8092
|
}
|
|
7837
8093
|
function readAll() {
|
|
7838
8094
|
const path = workspacesFile();
|
|
@@ -7891,7 +8147,7 @@ async function addWorkspace(repoPath) {
|
|
|
7891
8147
|
if (existing) return existing;
|
|
7892
8148
|
const next = {
|
|
7893
8149
|
path: root,
|
|
7894
|
-
name: (0,
|
|
8150
|
+
name: (0, import_node_path22.basename)(root),
|
|
7895
8151
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
7896
8152
|
};
|
|
7897
8153
|
writeAll([...current, next]);
|
|
@@ -7916,7 +8172,7 @@ function syncWorkspacesFromThreads(repoPaths) {
|
|
|
7916
8172
|
if (!(0, import_node_fs18.existsSync)(path)) continue;
|
|
7917
8173
|
const ws = {
|
|
7918
8174
|
path,
|
|
7919
|
-
name: (0,
|
|
8175
|
+
name: (0, import_node_path22.basename)(path),
|
|
7920
8176
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
7921
8177
|
};
|
|
7922
8178
|
byPath.set(path, ws);
|
|
@@ -7926,12 +8182,12 @@ function syncWorkspacesFromThreads(repoPaths) {
|
|
|
7926
8182
|
if (dirty) writeAll(next);
|
|
7927
8183
|
return next.sort((a, b) => a.name.localeCompare(b.name));
|
|
7928
8184
|
}
|
|
7929
|
-
var import_node_fs18,
|
|
8185
|
+
var import_node_fs18, import_node_path22;
|
|
7930
8186
|
var init_workspaces2 = __esm({
|
|
7931
8187
|
"src/store/workspaces.ts"() {
|
|
7932
8188
|
"use strict";
|
|
7933
8189
|
import_node_fs18 = require("fs");
|
|
7934
|
-
|
|
8190
|
+
import_node_path22 = require("path");
|
|
7935
8191
|
init_paths();
|
|
7936
8192
|
init_global_workspace();
|
|
7937
8193
|
init_worktree();
|
|
@@ -8050,7 +8306,7 @@ function ensureGlobalCoordinatorCwd(opts) {
|
|
|
8050
8306
|
let orchId = opts?.orchestratorThreadId?.trim() || "";
|
|
8051
8307
|
if (!orchId) {
|
|
8052
8308
|
try {
|
|
8053
|
-
const existing = (0, import_node_fs19.readFileSync)((0,
|
|
8309
|
+
const existing = (0, import_node_fs19.readFileSync)((0, import_node_path23.join)(dir, "AGENTS.md"), "utf8");
|
|
8054
8310
|
const m = existing.match(
|
|
8055
8311
|
/YOUR orchestration thread id is `([0-9a-f-]{36})`/i
|
|
8056
8312
|
);
|
|
@@ -8095,9 +8351,9 @@ function ensureGlobalCoordinatorCwd(opts) {
|
|
|
8095
8351
|
"Always ask worktree agents to commit, push, and open draft PRs (`ask_git` / `send_to_thread`). If the user gave a goal (Greptile 5/5, CI green), pass that goal through so they watch-fix-push until it lands \u2014 do not start that loop on a plain push, and do not tell the human to poll. Tell them to merge only when the user explicitly asked. The worktree agent runs git/gh; never merge from this orchestration cwd."
|
|
8096
8352
|
].join("\n");
|
|
8097
8353
|
try {
|
|
8098
|
-
(0, import_node_fs19.writeFileSync)((0,
|
|
8354
|
+
(0, import_node_fs19.writeFileSync)((0, import_node_path23.join)(dir, "CLAUDE.md"), `${body}
|
|
8099
8355
|
`, "utf8");
|
|
8100
|
-
(0, import_node_fs19.writeFileSync)((0,
|
|
8356
|
+
(0, import_node_fs19.writeFileSync)((0, import_node_path23.join)(dir, "AGENTS.md"), `${body}
|
|
8101
8357
|
`, "utf8");
|
|
8102
8358
|
} catch {
|
|
8103
8359
|
}
|
|
@@ -8129,12 +8385,12 @@ function coordinatorSystemPrompt(opts) {
|
|
|
8129
8385
|
formatWorkspaceInventory(opts.workspaces)
|
|
8130
8386
|
].join("\n");
|
|
8131
8387
|
}
|
|
8132
|
-
var import_node_fs19,
|
|
8388
|
+
var import_node_fs19, import_node_path23, COORDINATOR_TOOL_PLAYBOOK, SLACK_REPLY_FORMATTING;
|
|
8133
8389
|
var init_coordinator_prompt = __esm({
|
|
8134
8390
|
"src/orchestrator/coordinator-prompt.ts"() {
|
|
8135
8391
|
"use strict";
|
|
8136
8392
|
import_node_fs19 = require("fs");
|
|
8137
|
-
|
|
8393
|
+
import_node_path23 = require("path");
|
|
8138
8394
|
init_worktree();
|
|
8139
8395
|
init_app_settings();
|
|
8140
8396
|
init_paths();
|
|
@@ -8450,7 +8706,7 @@ var init_global_workspace = __esm({
|
|
|
8450
8706
|
function brightsyConfigPath() {
|
|
8451
8707
|
const override = process.env.BRIGHTSY_CONFIG?.trim();
|
|
8452
8708
|
if (override) return override;
|
|
8453
|
-
return (0,
|
|
8709
|
+
return (0, import_node_path24.join)((0, import_node_os7.homedir)(), ".brightsy", "config.json");
|
|
8454
8710
|
}
|
|
8455
8711
|
function loadBrightsyConfig() {
|
|
8456
8712
|
const path = brightsyConfigPath();
|
|
@@ -8469,13 +8725,13 @@ function saveBrightsyConfig(cfg) {
|
|
|
8469
8725
|
mode: 384
|
|
8470
8726
|
});
|
|
8471
8727
|
}
|
|
8472
|
-
var import_node_fs20, import_node_os7,
|
|
8728
|
+
var import_node_fs20, import_node_os7, import_node_path24;
|
|
8473
8729
|
var init_config = __esm({
|
|
8474
8730
|
"src/brightsy/config.ts"() {
|
|
8475
8731
|
"use strict";
|
|
8476
8732
|
import_node_fs20 = require("fs");
|
|
8477
8733
|
import_node_os7 = require("os");
|
|
8478
|
-
|
|
8734
|
+
import_node_path24 = require("path");
|
|
8479
8735
|
}
|
|
8480
8736
|
});
|
|
8481
8737
|
|
|
@@ -8601,7 +8857,7 @@ var init_oauth = __esm({
|
|
|
8601
8857
|
|
|
8602
8858
|
// src/brightsy/connected-teams.ts
|
|
8603
8859
|
function storePath4() {
|
|
8604
|
-
return (0,
|
|
8860
|
+
return (0, import_node_path25.join)(appDataDir(), "brightsy-teams.json");
|
|
8605
8861
|
}
|
|
8606
8862
|
function readStore4() {
|
|
8607
8863
|
const path = storePath4();
|
|
@@ -8722,12 +8978,12 @@ function brightsyMcpServerName(slug) {
|
|
|
8722
8978
|
const cleaned = slug.replace(/[^A-Za-z0-9_-]/g, "_").replace(/^_+|_+$/g, "");
|
|
8723
8979
|
return `brightsy_${cleaned || "team"}`;
|
|
8724
8980
|
}
|
|
8725
|
-
var import_node_fs21,
|
|
8981
|
+
var import_node_fs21, import_node_path25;
|
|
8726
8982
|
var init_connected_teams = __esm({
|
|
8727
8983
|
"src/brightsy/connected-teams.ts"() {
|
|
8728
8984
|
"use strict";
|
|
8729
8985
|
import_node_fs21 = require("fs");
|
|
8730
|
-
|
|
8986
|
+
import_node_path25 = require("path");
|
|
8731
8987
|
init_paths();
|
|
8732
8988
|
init_accounts();
|
|
8733
8989
|
init_config();
|
|
@@ -8735,90 +8991,6 @@ var init_connected_teams = __esm({
|
|
|
8735
8991
|
}
|
|
8736
8992
|
});
|
|
8737
8993
|
|
|
8738
|
-
// src/agents/usage.ts
|
|
8739
|
-
function sumOptional(a, b) {
|
|
8740
|
-
if (a == null && b == null) return void 0;
|
|
8741
|
-
return (a ?? 0) + (b ?? 0);
|
|
8742
|
-
}
|
|
8743
|
-
function fromInclusiveInputUsage(opts) {
|
|
8744
|
-
const totalInput = Number(opts.inputTokens) || 0;
|
|
8745
|
-
const outputTokens = Number(opts.outputTokens) || 0;
|
|
8746
|
-
const cached = Number(opts.cachedInputTokens) || 0;
|
|
8747
|
-
if (!totalInput && !outputTokens) return null;
|
|
8748
|
-
const cacheReadTokens = cached > 0 ? Math.min(cached, totalInput) : 0;
|
|
8749
|
-
return {
|
|
8750
|
-
inputTokens: Math.max(0, totalInput - cacheReadTokens),
|
|
8751
|
-
outputTokens,
|
|
8752
|
-
cacheReadTokens: cacheReadTokens || void 0
|
|
8753
|
-
};
|
|
8754
|
-
}
|
|
8755
|
-
function requestOccupancy(u) {
|
|
8756
|
-
return u.inputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
|
|
8757
|
-
}
|
|
8758
|
-
function mergeUsage(a, b) {
|
|
8759
|
-
return {
|
|
8760
|
-
inputTokens: (a?.inputTokens ?? 0) + b.inputTokens,
|
|
8761
|
-
outputTokens: (a?.outputTokens ?? 0) + b.outputTokens,
|
|
8762
|
-
cacheReadTokens: sumOptional(a?.cacheReadTokens, b.cacheReadTokens),
|
|
8763
|
-
cacheWriteTokens: sumOptional(a?.cacheWriteTokens, b.cacheWriteTokens),
|
|
8764
|
-
costUsd: sumOptional(a?.costUsd, b.costUsd),
|
|
8765
|
-
lastRequestTokens: b.lastRequestTokens ?? a?.lastRequestTokens
|
|
8766
|
-
};
|
|
8767
|
-
}
|
|
8768
|
-
function sumUsageList(list) {
|
|
8769
|
-
let acc = null;
|
|
8770
|
-
for (const u of list) {
|
|
8771
|
-
if (!u) continue;
|
|
8772
|
-
acc = mergeUsage(acc, {
|
|
8773
|
-
inputTokens: u.inputTokens,
|
|
8774
|
-
outputTokens: u.outputTokens,
|
|
8775
|
-
cacheReadTokens: u.cacheReadTokens,
|
|
8776
|
-
cacheWriteTokens: u.cacheWriteTokens,
|
|
8777
|
-
costUsd: u.costUsd
|
|
8778
|
-
});
|
|
8779
|
-
}
|
|
8780
|
-
if (!acc) return null;
|
|
8781
|
-
return {
|
|
8782
|
-
inputTokens: acc.inputTokens,
|
|
8783
|
-
outputTokens: acc.outputTokens,
|
|
8784
|
-
...acc.cacheReadTokens != null ? { cacheReadTokens: acc.cacheReadTokens } : {},
|
|
8785
|
-
...acc.cacheWriteTokens != null ? { cacheWriteTokens: acc.cacheWriteTokens } : {},
|
|
8786
|
-
...acc.costUsd != null ? { costUsd: acc.costUsd } : {}
|
|
8787
|
-
};
|
|
8788
|
-
}
|
|
8789
|
-
function hasBilledTokens(u) {
|
|
8790
|
-
return Boolean(
|
|
8791
|
-
u.inputTokens || u.outputTokens || u.cacheReadTokens || u.cacheWriteTokens
|
|
8792
|
-
);
|
|
8793
|
-
}
|
|
8794
|
-
function applyTurnUsage(current, incoming, scope = "request") {
|
|
8795
|
-
if (scope === "turn") {
|
|
8796
|
-
if (!hasBilledTokens(incoming) && current && incoming.costUsd != null) {
|
|
8797
|
-
return { ...current, costUsd: incoming.costUsd };
|
|
8798
|
-
}
|
|
8799
|
-
return {
|
|
8800
|
-
...incoming,
|
|
8801
|
-
costUsd: incoming.costUsd ?? current?.costUsd,
|
|
8802
|
-
lastRequestTokens: current?.lastRequestTokens ?? requestOccupancy(incoming)
|
|
8803
|
-
};
|
|
8804
|
-
}
|
|
8805
|
-
const merged = mergeUsage(current, incoming);
|
|
8806
|
-
const occ = incoming.lastRequestTokens != null && incoming.lastRequestTokens > 0 ? incoming.lastRequestTokens : requestOccupancy(incoming);
|
|
8807
|
-
return {
|
|
8808
|
-
...merged,
|
|
8809
|
-
lastRequestTokens: occ > 0 ? occ : current?.lastRequestTokens ?? occ
|
|
8810
|
-
};
|
|
8811
|
-
}
|
|
8812
|
-
function contextTokens(u) {
|
|
8813
|
-
if (u.lastRequestTokens != null && u.lastRequestTokens > 0) return u.lastRequestTokens;
|
|
8814
|
-
return requestOccupancy(u);
|
|
8815
|
-
}
|
|
8816
|
-
var init_usage = __esm({
|
|
8817
|
-
"src/agents/usage.ts"() {
|
|
8818
|
-
"use strict";
|
|
8819
|
-
}
|
|
8820
|
-
});
|
|
8821
|
-
|
|
8822
8994
|
// src/agents/brightsy-targets.ts
|
|
8823
8995
|
function encodeBrightsyTarget(type, id, accountId) {
|
|
8824
8996
|
if (accountId) return `team:${accountId}:${type}:${id}`;
|
|
@@ -9780,43 +9952,43 @@ function electronResourcesPath() {
|
|
|
9780
9952
|
function packagedCursorRuntimeDir() {
|
|
9781
9953
|
const resources = electronResourcesPath();
|
|
9782
9954
|
if (!resources) return null;
|
|
9783
|
-
const dir = (0,
|
|
9784
|
-
if (!(0, import_node_fs23.existsSync)((0,
|
|
9955
|
+
const dir = (0, import_node_path26.join)(resources, "cursor-runtime");
|
|
9956
|
+
if (!(0, import_node_fs23.existsSync)((0, import_node_path26.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
|
|
9785
9957
|
return dir;
|
|
9786
9958
|
}
|
|
9787
9959
|
function packagedCursorRunnerPath() {
|
|
9788
9960
|
const dir = packagedCursorRuntimeDir();
|
|
9789
|
-
return dir ? (0,
|
|
9961
|
+
return dir ? (0, import_node_path26.join)(dir, "core-dist", "agents", "cursor-runner.js") : null;
|
|
9790
9962
|
}
|
|
9791
9963
|
function packagedMcpDir() {
|
|
9792
9964
|
const resources = electronResourcesPath();
|
|
9793
9965
|
if (!resources) return null;
|
|
9794
|
-
const dir = (0,
|
|
9795
|
-
if (!(0, import_node_fs23.existsSync)((0,
|
|
9966
|
+
const dir = (0, import_node_path26.join)(resources, "sideboard-mcp");
|
|
9967
|
+
if (!(0, import_node_fs23.existsSync)((0, import_node_path26.join)(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
|
|
9796
9968
|
return dir;
|
|
9797
9969
|
}
|
|
9798
9970
|
function packagedMcpStdioPath() {
|
|
9799
9971
|
const dir = packagedMcpDir();
|
|
9800
|
-
return dir ? (0,
|
|
9972
|
+
return dir ? (0, import_node_path26.join)(dir, "core-dist", "mcp", "run-stdio.js") : null;
|
|
9801
9973
|
}
|
|
9802
9974
|
function packagedBundledNodePath() {
|
|
9803
9975
|
const resources = electronResourcesPath();
|
|
9804
9976
|
if (!resources) return null;
|
|
9805
|
-
const bin = (0,
|
|
9977
|
+
const bin = (0, import_node_path26.join)(resources, "node", "bin", "node");
|
|
9806
9978
|
if (!(0, import_node_fs23.existsSync)(bin)) return null;
|
|
9807
9979
|
return bin;
|
|
9808
9980
|
}
|
|
9809
9981
|
function packagedCursorRipgrepCandidate(platformPkg, binName) {
|
|
9810
9982
|
const dir = packagedCursorRuntimeDir();
|
|
9811
9983
|
if (!dir) return null;
|
|
9812
|
-
return (0,
|
|
9984
|
+
return (0, import_node_path26.join)(dir, "node_modules", platformPkg, "bin", binName);
|
|
9813
9985
|
}
|
|
9814
|
-
var import_node_fs23,
|
|
9986
|
+
var import_node_fs23, import_node_path26;
|
|
9815
9987
|
var init_packaged_runtime = __esm({
|
|
9816
9988
|
"src/agents/packaged-runtime.ts"() {
|
|
9817
9989
|
"use strict";
|
|
9818
9990
|
import_node_fs23 = require("fs");
|
|
9819
|
-
|
|
9991
|
+
import_node_path26 = require("path");
|
|
9820
9992
|
}
|
|
9821
9993
|
});
|
|
9822
9994
|
|
|
@@ -9900,28 +10072,28 @@ function versionDirNodeBins(root, toBin) {
|
|
|
9900
10072
|
}
|
|
9901
10073
|
function defaultNodeBinCandidates(home = (0, import_node_os8.homedir)()) {
|
|
9902
10074
|
const kegs = ["/opt/homebrew", "/usr/local"].flatMap(
|
|
9903
|
-
(prefix) => PREFERRED_LTS_MAJORS.map((major) => (0,
|
|
10075
|
+
(prefix) => PREFERRED_LTS_MAJORS.map((major) => (0, import_node_path27.join)(prefix, "opt", `node@${major}`, "bin", "node"))
|
|
9904
10076
|
);
|
|
9905
10077
|
return [
|
|
9906
10078
|
...kegs,
|
|
9907
10079
|
"/opt/homebrew/bin/node",
|
|
9908
10080
|
"/usr/local/bin/node",
|
|
9909
|
-
(0,
|
|
9910
|
-
(0,
|
|
9911
|
-
(0,
|
|
9912
|
-
(0,
|
|
9913
|
-
(0,
|
|
10081
|
+
(0, import_node_path27.join)(home, ".local/share/fnm/aliases/default/bin/node"),
|
|
10082
|
+
(0, import_node_path27.join)(home, ".nvm/current/bin/node"),
|
|
10083
|
+
(0, import_node_path27.join)(home, ".volta/bin/node"),
|
|
10084
|
+
(0, import_node_path27.join)(home, ".asdf/shims/node"),
|
|
10085
|
+
(0, import_node_path27.join)(home, ".local/share/mise/shims/node"),
|
|
9914
10086
|
...versionDirNodeBins(
|
|
9915
|
-
(0,
|
|
9916
|
-
(name) => (0,
|
|
10087
|
+
(0, import_node_path27.join)(home, ".nvm", "versions", "node"),
|
|
10088
|
+
(name) => (0, import_node_path27.join)(home, ".nvm", "versions", "node", name, "bin", "node")
|
|
9917
10089
|
),
|
|
9918
10090
|
...versionDirNodeBins(
|
|
9919
|
-
(0,
|
|
9920
|
-
(name) => (0,
|
|
10091
|
+
(0, import_node_path27.join)(home, ".local/share/fnm", "node-versions"),
|
|
10092
|
+
(name) => (0, import_node_path27.join)(home, ".local/share/fnm", "node-versions", name, "installation", "bin", "node")
|
|
9921
10093
|
),
|
|
9922
10094
|
...versionDirNodeBins(
|
|
9923
|
-
(0,
|
|
9924
|
-
(name) => (0,
|
|
10095
|
+
(0, import_node_path27.join)(home, ".volta", "tools", "image", "node"),
|
|
10096
|
+
(name) => (0, import_node_path27.join)(home, ".volta", "tools", "image", "node", name, "bin", "node")
|
|
9925
10097
|
)
|
|
9926
10098
|
];
|
|
9927
10099
|
}
|
|
@@ -10013,13 +10185,13 @@ async function resolveNodeLaunch(scriptPath) {
|
|
|
10013
10185
|
env: { ELECTRON_RUN_AS_NODE: "1" }
|
|
10014
10186
|
};
|
|
10015
10187
|
}
|
|
10016
|
-
var import_node_fs24, import_node_os8,
|
|
10188
|
+
var import_node_fs24, import_node_os8, import_node_path27, AGENT_RUNNER_MAX_OLD_SPACE_MB, MAX_OLD_SPACE_FLAG, PREFERRED_LTS_MAJORS;
|
|
10017
10189
|
var init_node_launch = __esm({
|
|
10018
10190
|
"src/agents/node-launch.ts"() {
|
|
10019
10191
|
"use strict";
|
|
10020
10192
|
import_node_fs24 = require("fs");
|
|
10021
10193
|
import_node_os8 = require("os");
|
|
10022
|
-
|
|
10194
|
+
import_node_path27 = require("path");
|
|
10023
10195
|
init_nested_electron_env();
|
|
10024
10196
|
init_system_ca();
|
|
10025
10197
|
init_run();
|
|
@@ -10121,13 +10293,13 @@ function corePackageDir() {
|
|
|
10121
10293
|
try {
|
|
10122
10294
|
const url = import_meta.url;
|
|
10123
10295
|
if (typeof url === "string" && url.length > 0) {
|
|
10124
|
-
return (0,
|
|
10296
|
+
return (0, import_node_path28.dirname)((0, import_node_url.fileURLToPath)(url));
|
|
10125
10297
|
}
|
|
10126
10298
|
} catch {
|
|
10127
10299
|
}
|
|
10128
10300
|
try {
|
|
10129
|
-
const req = (0, import_node_module.createRequire)((0,
|
|
10130
|
-
return (0,
|
|
10301
|
+
const req = (0, import_node_module.createRequire)((0, import_node_path28.join)(process.cwd(), "package.json"));
|
|
10302
|
+
return (0, import_node_path28.dirname)(req.resolve("@sideboard-ai/core"));
|
|
10131
10303
|
} catch {
|
|
10132
10304
|
return process.cwd();
|
|
10133
10305
|
}
|
|
@@ -10140,18 +10312,18 @@ function findSideboardMcpJsEntry() {
|
|
|
10140
10312
|
let dir = corePackageDir();
|
|
10141
10313
|
for (let i = 0; i < 10; i++) {
|
|
10142
10314
|
const candidates = [
|
|
10143
|
-
(0,
|
|
10144
|
-
(0,
|
|
10145
|
-
(0,
|
|
10146
|
-
(0,
|
|
10147
|
-
(0,
|
|
10148
|
-
(0,
|
|
10149
|
-
(0,
|
|
10315
|
+
(0, import_node_path28.join)(dir, "mcp/run-stdio.js"),
|
|
10316
|
+
(0, import_node_path28.join)(dir, "mcp/run-stdio.cjs"),
|
|
10317
|
+
(0, import_node_path28.join)(dir, "dist/mcp/run-stdio.js"),
|
|
10318
|
+
(0, import_node_path28.join)(dir, "dist/mcp/run-stdio.cjs"),
|
|
10319
|
+
(0, import_node_path28.join)(dir, "packages/core/dist/mcp/run-stdio.js"),
|
|
10320
|
+
(0, import_node_path28.join)(dir, "packages/cli/dist/index.js"),
|
|
10321
|
+
(0, import_node_path28.join)(dir, "cli/dist/index.js")
|
|
10150
10322
|
];
|
|
10151
10323
|
for (const p of candidates) {
|
|
10152
10324
|
if ((0, import_node_fs25.existsSync)(p) && !isAsarPath(p)) return p;
|
|
10153
10325
|
}
|
|
10154
|
-
const parent = (0,
|
|
10326
|
+
const parent = (0, import_node_path28.dirname)(dir);
|
|
10155
10327
|
if (parent === dir) break;
|
|
10156
10328
|
dir = parent;
|
|
10157
10329
|
}
|
|
@@ -10298,19 +10470,19 @@ function writeMcpServersConfig(servers) {
|
|
|
10298
10470
|
...env ? { env } : {}
|
|
10299
10471
|
};
|
|
10300
10472
|
}
|
|
10301
|
-
const dir = (0, import_node_fs25.mkdtempSync)((0,
|
|
10302
|
-
const cfgPath = (0,
|
|
10473
|
+
const dir = (0, import_node_fs25.mkdtempSync)((0, import_node_path28.join)((0, import_node_os9.tmpdir)(), "sideboard-mcp-"));
|
|
10474
|
+
const cfgPath = (0, import_node_path28.join)(dir, "mcp.json");
|
|
10303
10475
|
(0, import_node_fs25.writeFileSync)(cfgPath, JSON.stringify({ mcpServers }, null, 2));
|
|
10304
10476
|
return cfgPath;
|
|
10305
10477
|
}
|
|
10306
|
-
var import_node_fs25, import_node_module, import_node_os9,
|
|
10478
|
+
var import_node_fs25, import_node_module, import_node_os9, import_node_path28, import_node_url, import_meta, SIDEBOARD_MCP_ALLOWED_TOOLS, SIDEBOARD_ARTIFACT_MCP_ALLOWED_TOOLS, SIDEBOARD_GITHUB_MCP_ALLOWED_TOOLS, SIDEBOARD_LINEAR_MCP_ALLOWED_TOOLS, SIDEBOARD_ABLETIME_MCP_ALLOWED_TOOLS, brightsyMcpCommandCache, BRIGHTSY_WORD;
|
|
10307
10479
|
var init_injected_mcp = __esm({
|
|
10308
10480
|
"src/agents/injected-mcp.ts"() {
|
|
10309
10481
|
"use strict";
|
|
10310
10482
|
import_node_fs25 = require("fs");
|
|
10311
10483
|
import_node_module = require("module");
|
|
10312
10484
|
import_node_os9 = require("os");
|
|
10313
|
-
|
|
10485
|
+
import_node_path28 = require("path");
|
|
10314
10486
|
import_node_url = require("url");
|
|
10315
10487
|
init_run();
|
|
10316
10488
|
init_config();
|
|
@@ -10547,13 +10719,31 @@ function mcpStatusThinkingFromClaudeInit(obj) {
|
|
|
10547
10719
|
}
|
|
10548
10720
|
}
|
|
10549
10721
|
}
|
|
10550
|
-
const notable = servers.filter(
|
|
10722
|
+
const notable = servers.filter(isNotableMcpInitStatus);
|
|
10551
10723
|
if (notable.length === 0) return null;
|
|
10552
10724
|
return `MCP: ${notable.map((s) => `${s.name} ${s.status}`).join(", ")}`;
|
|
10553
10725
|
}
|
|
10554
10726
|
function isCleanMcpConnect(status) {
|
|
10555
10727
|
return /^(connected|ok|ready|success)$/i.test(status.trim());
|
|
10556
10728
|
}
|
|
10729
|
+
function isMcpAuthStatus(status) {
|
|
10730
|
+
return /needs[_-]?auth|needs authentication|unauthorized|not authenticated|authrequired/i.test(
|
|
10731
|
+
status
|
|
10732
|
+
);
|
|
10733
|
+
}
|
|
10734
|
+
function isSideboardMcpName(name) {
|
|
10735
|
+
return /^sideboard$/i.test(name.trim()) || /^mcp__sideboard$/i.test(name.trim());
|
|
10736
|
+
}
|
|
10737
|
+
function isVendorClaudeAiMcpName(name) {
|
|
10738
|
+
return /^claude\.ai\b/i.test(name.trim()) || /^mcp__claude_ai_/i.test(name.trim());
|
|
10739
|
+
}
|
|
10740
|
+
function isNotableMcpInitStatus(server) {
|
|
10741
|
+
if (isCleanMcpConnect(server.status)) return false;
|
|
10742
|
+
if (isSideboardMcpName(server.name)) return true;
|
|
10743
|
+
if (isVendorClaudeAiMcpName(server.name)) return false;
|
|
10744
|
+
if (isMcpAuthStatus(server.status)) return false;
|
|
10745
|
+
return true;
|
|
10746
|
+
}
|
|
10557
10747
|
function eventsFromClaudeSystem(obj) {
|
|
10558
10748
|
const subtype = claudeString(obj, "subtype") ?? "";
|
|
10559
10749
|
const parentId = claudeParentToolUseId(obj);
|
|
@@ -10996,13 +11186,13 @@ var init_claude = __esm({
|
|
|
10996
11186
|
});
|
|
10997
11187
|
|
|
10998
11188
|
// src/agents/user-mcp-config.ts
|
|
10999
|
-
var import_node_fs27, import_node_os10,
|
|
11189
|
+
var import_node_fs27, import_node_os10, import_node_path29;
|
|
11000
11190
|
var init_user_mcp_config = __esm({
|
|
11001
11191
|
"src/agents/user-mcp-config.ts"() {
|
|
11002
11192
|
"use strict";
|
|
11003
11193
|
import_node_fs27 = require("fs");
|
|
11004
11194
|
import_node_os10 = require("os");
|
|
11005
|
-
|
|
11195
|
+
import_node_path29 = require("path");
|
|
11006
11196
|
init_paths();
|
|
11007
11197
|
init_injected_mcp();
|
|
11008
11198
|
}
|
|
@@ -11043,12 +11233,12 @@ function readText(path) {
|
|
|
11043
11233
|
}
|
|
11044
11234
|
}
|
|
11045
11235
|
function userCodexConfigPaths(home = (0, import_node_os11.homedir)()) {
|
|
11046
|
-
return [(0,
|
|
11236
|
+
return [(0, import_node_path30.join)(home, ".codex", "config.toml"), (0, import_node_path30.join)(home, ".config", "codex", "config.toml")];
|
|
11047
11237
|
}
|
|
11048
11238
|
function userOpencodeConfigPaths(home = (0, import_node_os11.homedir)()) {
|
|
11049
11239
|
return [
|
|
11050
|
-
(0,
|
|
11051
|
-
(0,
|
|
11240
|
+
(0, import_node_path30.join)(home, ".config", "opencode", "opencode.json"),
|
|
11241
|
+
(0, import_node_path30.join)(home, ".config", "opencode", "opencode.jsonc")
|
|
11052
11242
|
];
|
|
11053
11243
|
}
|
|
11054
11244
|
function userMcpNamesToDisable(opts) {
|
|
@@ -11103,13 +11293,13 @@ function toCodexUnattendedAppsArgs() {
|
|
|
11103
11293
|
"features.plugins=false"
|
|
11104
11294
|
];
|
|
11105
11295
|
}
|
|
11106
|
-
var import_node_fs28, import_node_os11,
|
|
11296
|
+
var import_node_fs28, import_node_os11, import_node_path30, import_smol_toml2;
|
|
11107
11297
|
var init_orch_mcp_isolation = __esm({
|
|
11108
11298
|
"src/agents/orch-mcp-isolation.ts"() {
|
|
11109
11299
|
"use strict";
|
|
11110
11300
|
import_node_fs28 = require("fs");
|
|
11111
11301
|
import_node_os11 = require("os");
|
|
11112
|
-
|
|
11302
|
+
import_node_path30 = require("path");
|
|
11113
11303
|
import_smol_toml2 = require("smol-toml");
|
|
11114
11304
|
init_user_mcp_config();
|
|
11115
11305
|
}
|
|
@@ -11160,8 +11350,8 @@ function usageFromCodex(usage) {
|
|
|
11160
11350
|
}
|
|
11161
11351
|
function codexConfigHasNetworkAccess() {
|
|
11162
11352
|
const candidates = [
|
|
11163
|
-
(0,
|
|
11164
|
-
(0,
|
|
11353
|
+
(0, import_node_path31.join)((0, import_node_os12.homedir)(), ".codex", "config.toml"),
|
|
11354
|
+
(0, import_node_path31.join)((0, import_node_os12.homedir)(), ".config", "codex", "config.toml")
|
|
11165
11355
|
];
|
|
11166
11356
|
for (const path of candidates) {
|
|
11167
11357
|
if (!(0, import_node_fs29.existsSync)(path)) continue;
|
|
@@ -11197,7 +11387,7 @@ function asRecord2(value) {
|
|
|
11197
11387
|
return void 0;
|
|
11198
11388
|
}
|
|
11199
11389
|
function codexLooksAuthenticated() {
|
|
11200
|
-
const authPath = (0,
|
|
11390
|
+
const authPath = (0, import_node_path31.join)((0, import_node_os12.homedir)(), ".codex", "auth.json");
|
|
11201
11391
|
if (!(0, import_node_fs29.existsSync)(authPath)) return false;
|
|
11202
11392
|
try {
|
|
11203
11393
|
return (0, import_node_fs29.statSync)(authPath).size > 2;
|
|
@@ -11205,13 +11395,13 @@ function codexLooksAuthenticated() {
|
|
|
11205
11395
|
return false;
|
|
11206
11396
|
}
|
|
11207
11397
|
}
|
|
11208
|
-
var import_node_fs29, import_node_os12,
|
|
11398
|
+
var import_node_fs29, import_node_os12, import_node_path31, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
|
|
11209
11399
|
var init_codex = __esm({
|
|
11210
11400
|
"src/agents/codex.ts"() {
|
|
11211
11401
|
"use strict";
|
|
11212
11402
|
import_node_fs29 = require("fs");
|
|
11213
11403
|
import_node_os12 = require("os");
|
|
11214
|
-
|
|
11404
|
+
import_node_path31 = require("path");
|
|
11215
11405
|
init_run();
|
|
11216
11406
|
init_app_settings();
|
|
11217
11407
|
init_global_workspace();
|
|
@@ -11545,7 +11735,7 @@ function platformRipgrepPackage() {
|
|
|
11545
11735
|
}
|
|
11546
11736
|
function usableRipgrepPath(candidate) {
|
|
11547
11737
|
const raw = candidate?.trim();
|
|
11548
|
-
if (!raw || !(0,
|
|
11738
|
+
if (!raw || !(0, import_node_path32.isAbsolute)(raw)) return null;
|
|
11549
11739
|
const readable = nodeReadableScriptPath(raw);
|
|
11550
11740
|
if (!(0, import_node_fs30.existsSync)(readable) || isAsarPath(readable)) return null;
|
|
11551
11741
|
return readable;
|
|
@@ -11554,12 +11744,12 @@ function walkForBundledRipgrep(startFile) {
|
|
|
11554
11744
|
if (!startFile) return null;
|
|
11555
11745
|
const pkg = platformRipgrepPackage();
|
|
11556
11746
|
const name = rgBinaryName();
|
|
11557
|
-
let dir = (0,
|
|
11558
|
-
const root = (0,
|
|
11747
|
+
let dir = (0, import_node_path32.dirname)((0, import_node_path32.resolve)(startFile));
|
|
11748
|
+
const root = (0, import_node_path32.parse)(dir).root;
|
|
11559
11749
|
while (dir !== root) {
|
|
11560
|
-
const hit = usableRipgrepPath((0,
|
|
11750
|
+
const hit = usableRipgrepPath((0, import_node_path32.join)(dir, "node_modules", pkg, "bin", name));
|
|
11561
11751
|
if (hit) return hit;
|
|
11562
|
-
const next = (0,
|
|
11752
|
+
const next = (0, import_node_path32.dirname)(dir);
|
|
11563
11753
|
if (next === dir) break;
|
|
11564
11754
|
dir = next;
|
|
11565
11755
|
}
|
|
@@ -11569,7 +11759,7 @@ function requireResolveBundledRipgrep(fromFile) {
|
|
|
11569
11759
|
try {
|
|
11570
11760
|
const req = (0, import_node_module2.createRequire)(fromFile);
|
|
11571
11761
|
const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
|
|
11572
|
-
return usableRipgrepPath((0,
|
|
11762
|
+
return usableRipgrepPath((0, import_node_path32.join)((0, import_node_path32.dirname)(pkgJson), "bin", rgBinaryName()));
|
|
11573
11763
|
} catch {
|
|
11574
11764
|
return null;
|
|
11575
11765
|
}
|
|
@@ -11591,13 +11781,13 @@ function cursorRipgrepEnv(opts) {
|
|
|
11591
11781
|
const path = resolveCursorRipgrepPath(opts);
|
|
11592
11782
|
return path ? { [RIPGREP_ENV]: path } : {};
|
|
11593
11783
|
}
|
|
11594
|
-
var import_node_fs30, import_node_module2,
|
|
11784
|
+
var import_node_fs30, import_node_module2, import_node_path32, RIPGREP_ENV;
|
|
11595
11785
|
var init_cursor_ripgrep = __esm({
|
|
11596
11786
|
"src/agents/cursor-ripgrep.ts"() {
|
|
11597
11787
|
"use strict";
|
|
11598
11788
|
import_node_fs30 = require("fs");
|
|
11599
11789
|
import_node_module2 = require("module");
|
|
11600
|
-
|
|
11790
|
+
import_node_path32 = require("path");
|
|
11601
11791
|
init_node_launch();
|
|
11602
11792
|
init_packaged_runtime();
|
|
11603
11793
|
RIPGREP_ENV = "CURSOR_RIPGREP_PATH";
|
|
@@ -11638,11 +11828,11 @@ function entryDir() {
|
|
|
11638
11828
|
const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
|
|
11639
11829
|
if (cjsDir) return cjsDir;
|
|
11640
11830
|
try {
|
|
11641
|
-
return (0,
|
|
11831
|
+
return (0, import_node_path33.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
|
|
11642
11832
|
} catch {
|
|
11643
11833
|
try {
|
|
11644
11834
|
const req = (0, import_node_module3.createRequire)(process.cwd() + "/");
|
|
11645
|
-
return (0,
|
|
11835
|
+
return (0, import_node_path33.dirname)(req.resolve("@sideboard-ai/core"));
|
|
11646
11836
|
} catch {
|
|
11647
11837
|
return process.cwd();
|
|
11648
11838
|
}
|
|
@@ -11653,27 +11843,27 @@ function cursorRunnerPath() {
|
|
|
11653
11843
|
if (packaged) return packaged;
|
|
11654
11844
|
const root = entryDir();
|
|
11655
11845
|
const candidates = [
|
|
11656
|
-
(0,
|
|
11657
|
-
(0,
|
|
11846
|
+
(0, import_node_path33.join)(root, "agents", "cursor-runner.js"),
|
|
11847
|
+
(0, import_node_path33.join)(root, "agents", "cursor-runner.cjs"),
|
|
11658
11848
|
// If somehow resolved from package root instead of dist/
|
|
11659
|
-
(0,
|
|
11660
|
-
(0,
|
|
11849
|
+
(0, import_node_path33.join)(root, "dist", "agents", "cursor-runner.js"),
|
|
11850
|
+
(0, import_node_path33.join)(root, "dist", "agents", "cursor-runner.cjs"),
|
|
11661
11851
|
// Source tree (dev): packages/core/src/agents/cursor-runner.ts
|
|
11662
|
-
(0,
|
|
11663
|
-
(0,
|
|
11852
|
+
(0, import_node_path33.join)(root, "cursor-runner.ts"),
|
|
11853
|
+
(0, import_node_path33.join)(root, "src", "agents", "cursor-runner.ts")
|
|
11664
11854
|
];
|
|
11665
11855
|
for (const candidate of candidates) {
|
|
11666
11856
|
if ((0, import_node_fs31.existsSync)(candidate)) return candidate;
|
|
11667
11857
|
}
|
|
11668
11858
|
return candidates[0];
|
|
11669
11859
|
}
|
|
11670
|
-
var import_node_fs31, import_node_module3,
|
|
11860
|
+
var import_node_fs31, import_node_module3, import_node_path33, import_node_url2, import_sdk, import_meta2, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
|
|
11671
11861
|
var init_cursor = __esm({
|
|
11672
11862
|
"src/agents/cursor.ts"() {
|
|
11673
11863
|
"use strict";
|
|
11674
11864
|
import_node_fs31 = require("fs");
|
|
11675
11865
|
import_node_module3 = require("module");
|
|
11676
|
-
|
|
11866
|
+
import_node_path33 = require("path");
|
|
11677
11867
|
import_node_url2 = require("url");
|
|
11678
11868
|
import_sdk = require("@cursor/sdk");
|
|
11679
11869
|
init_run();
|
|
@@ -12374,13 +12564,13 @@ var init_claude_usage = __esm({
|
|
|
12374
12564
|
});
|
|
12375
12565
|
|
|
12376
12566
|
// src/agents/claude-usage-client.ts
|
|
12377
|
-
var import_node_fs33, import_node_os13,
|
|
12567
|
+
var import_node_fs33, import_node_os13, import_node_path34, CLAUDE_USAGE_ERROR_TTL_MS, CLAUDE_USAGE_STALE_OK_MS;
|
|
12378
12568
|
var init_claude_usage_client = __esm({
|
|
12379
12569
|
"src/agents/claude-usage-client.ts"() {
|
|
12380
12570
|
"use strict";
|
|
12381
12571
|
import_node_fs33 = require("fs");
|
|
12382
12572
|
import_node_os13 = require("os");
|
|
12383
|
-
|
|
12573
|
+
import_node_path34 = require("path");
|
|
12384
12574
|
init_run();
|
|
12385
12575
|
init_fetch();
|
|
12386
12576
|
init_app_settings();
|
|
@@ -12441,15 +12631,15 @@ var init_agents = __esm({
|
|
|
12441
12631
|
|
|
12442
12632
|
// src/hook/worktree-pkg-cache.ts
|
|
12443
12633
|
function worktreePkgCacheRoot(worktreePath) {
|
|
12444
|
-
return (0,
|
|
12634
|
+
return (0, import_node_path35.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
|
|
12445
12635
|
}
|
|
12446
12636
|
function worktreePkgCacheEnv(worktreePath) {
|
|
12447
12637
|
const root = worktreePkgCacheRoot(worktreePath);
|
|
12448
|
-
const store = (0,
|
|
12449
|
-
const pnpmCache = (0,
|
|
12450
|
-
const npmCache = (0,
|
|
12451
|
-
const nodeGyp = (0,
|
|
12452
|
-
const electron = (0,
|
|
12638
|
+
const store = (0, import_node_path35.join)(root, "pnpm-store");
|
|
12639
|
+
const pnpmCache = (0, import_node_path35.join)(root, "pnpm");
|
|
12640
|
+
const npmCache = (0, import_node_path35.join)(root, "npm");
|
|
12641
|
+
const nodeGyp = (0, import_node_path35.join)(root, "node-gyp");
|
|
12642
|
+
const electron = (0, import_node_path35.join)(root, "electron");
|
|
12453
12643
|
return {
|
|
12454
12644
|
npm_config_store_dir: store,
|
|
12455
12645
|
PNPM_STORE_DIR: store,
|
|
@@ -12485,12 +12675,12 @@ function applyWorktreePkgCacheEnv(env, worktreePath) {
|
|
|
12485
12675
|
fillGroup(env, ["electron_config_cache"], next);
|
|
12486
12676
|
ensureWorktreePkgCacheDirs(cwd);
|
|
12487
12677
|
}
|
|
12488
|
-
var import_node_fs34,
|
|
12678
|
+
var import_node_fs34, import_node_path35, WORKTREE_PKG_CACHE_REL;
|
|
12489
12679
|
var init_worktree_pkg_cache = __esm({
|
|
12490
12680
|
"src/hook/worktree-pkg-cache.ts"() {
|
|
12491
12681
|
"use strict";
|
|
12492
12682
|
import_node_fs34 = require("fs");
|
|
12493
|
-
|
|
12683
|
+
import_node_path35 = require("path");
|
|
12494
12684
|
WORKTREE_PKG_CACHE_REL = ".context/.sideboard/pkg-cache";
|
|
12495
12685
|
}
|
|
12496
12686
|
});
|
|
@@ -13660,12 +13850,12 @@ function readTextIfPresent(abs) {
|
|
|
13660
13850
|
}
|
|
13661
13851
|
}
|
|
13662
13852
|
function readLocalGuidelines(worktreePath) {
|
|
13663
|
-
const localAbs = (0,
|
|
13853
|
+
const localAbs = (0, import_node_path36.join)(worktreePath, REVIEW_REQUEST_PATH);
|
|
13664
13854
|
const localContent = readTextIfPresent(localAbs);
|
|
13665
13855
|
if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
|
|
13666
13856
|
return { path: REVIEW_REQUEST_PATH, content: localContent };
|
|
13667
13857
|
}
|
|
13668
|
-
const legacyAbs = (0,
|
|
13858
|
+
const legacyAbs = (0, import_node_path36.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
|
|
13669
13859
|
const legacyContent = readTextIfPresent(legacyAbs);
|
|
13670
13860
|
if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
|
|
13671
13861
|
return { path: LEGACY_REVIEW_REQUEST_PATH, content: legacyContent };
|
|
@@ -13689,27 +13879,27 @@ function contextGuidelines(content, source) {
|
|
|
13689
13879
|
};
|
|
13690
13880
|
}
|
|
13691
13881
|
function writeContextGuidelines(worktreePath, content) {
|
|
13692
|
-
const abs = (0,
|
|
13693
|
-
(0, import_node_fs35.mkdirSync)((0,
|
|
13882
|
+
const abs = (0, import_node_path36.join)(worktreePath, CONTEXT_REVIEW_PATH);
|
|
13883
|
+
(0, import_node_fs35.mkdirSync)((0, import_node_path36.dirname)(abs), { recursive: true });
|
|
13694
13884
|
const body = content.endsWith("\n") ? content : `${content}
|
|
13695
13885
|
`;
|
|
13696
13886
|
(0, import_node_fs35.writeFileSync)(abs, body, "utf8");
|
|
13697
13887
|
return body;
|
|
13698
13888
|
}
|
|
13699
13889
|
function readSideboardReview(worktreePath, repoPath) {
|
|
13700
|
-
const fromWorktree = readTextIfPresent((0,
|
|
13890
|
+
const fromWorktree = readTextIfPresent((0, import_node_path36.join)(worktreePath, REPO_REVIEW_PATH));
|
|
13701
13891
|
if (fromWorktree) return fromWorktree;
|
|
13702
13892
|
const repo = repoPath?.replace(/\/+$/, "");
|
|
13703
13893
|
const wt = worktreePath.replace(/\/+$/, "");
|
|
13704
13894
|
if (!repo || repo === wt) return null;
|
|
13705
|
-
return readTextIfPresent((0,
|
|
13895
|
+
return readTextIfPresent((0, import_node_path36.join)(repo, REPO_REVIEW_PATH));
|
|
13706
13896
|
}
|
|
13707
13897
|
function ensureReviewGuidelinesFile(worktreePath, repoPath) {
|
|
13708
|
-
const skillContent = readTextIfPresent((0,
|
|
13898
|
+
const skillContent = readTextIfPresent((0, import_node_path36.join)(worktreePath, REVIEW_SKILL_PATH));
|
|
13709
13899
|
if (skillContent) {
|
|
13710
13900
|
return { ...skillGuidelines(skillContent, "skill"), wrote: false };
|
|
13711
13901
|
}
|
|
13712
|
-
const contextContent = readTextIfPresent((0,
|
|
13902
|
+
const contextContent = readTextIfPresent((0, import_node_path36.join)(worktreePath, CONTEXT_REVIEW_PATH));
|
|
13713
13903
|
if (contextContent && !shouldRefreshReviewRequestTemplate(contextContent)) {
|
|
13714
13904
|
return { ...contextGuidelines(contextContent, "local"), wrote: false };
|
|
13715
13905
|
}
|
|
@@ -13764,13 +13954,13 @@ async function requestReview(threadRef, send) {
|
|
|
13764
13954
|
const started = await send(tab.id, REVIEW_REQUEST_PREFILL);
|
|
13765
13955
|
return { tab: started, from };
|
|
13766
13956
|
}
|
|
13767
|
-
var import_node_crypto7, import_node_fs35,
|
|
13957
|
+
var import_node_crypto7, import_node_fs35, import_node_path36, REPO_REVIEW_PATH, REPO_REVIEW_NAME, CONTEXT_REVIEW_PATH, REVIEW_REQUEST_PATH, LEGACY_REVIEW_REQUEST_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PREFILL, LEGACY_REVIEW_TEMPLATE_MARKERS;
|
|
13768
13958
|
var init_request_review = __esm({
|
|
13769
13959
|
"src/review/request-review.ts"() {
|
|
13770
13960
|
"use strict";
|
|
13771
13961
|
import_node_crypto7 = require("crypto");
|
|
13772
13962
|
import_node_fs35 = require("fs");
|
|
13773
|
-
|
|
13963
|
+
import_node_path36 = require("path");
|
|
13774
13964
|
init_global_workspace();
|
|
13775
13965
|
init_chat_tabs();
|
|
13776
13966
|
init_thread_store();
|
|
@@ -13796,7 +13986,7 @@ function matchSimpleGlob(pattern, name) {
|
|
|
13796
13986
|
return new RegExp(`^${escaped}$`).test(name);
|
|
13797
13987
|
}
|
|
13798
13988
|
function readWorktreeInclude(repoPath) {
|
|
13799
|
-
const path = (0,
|
|
13989
|
+
const path = (0, import_node_path37.join)(repoPath, ".worktreeinclude");
|
|
13800
13990
|
if (!(0, import_node_fs36.existsSync)(path)) return [];
|
|
13801
13991
|
return (0, import_node_fs36.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
13802
13992
|
}
|
|
@@ -13811,7 +14001,7 @@ function resolveFilesToCopy(repoPath) {
|
|
|
13811
14001
|
for (const entry of (0, import_node_fs36.readdirSync)(repoPath, { withFileTypes: true })) {
|
|
13812
14002
|
if (!entry.isFile()) continue;
|
|
13813
14003
|
for (const glob of settings.fileIncludeGlobs) {
|
|
13814
|
-
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0,
|
|
14004
|
+
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path37.basename)(glob), entry.name)) {
|
|
13815
14005
|
matched.push(entry.name);
|
|
13816
14006
|
break;
|
|
13817
14007
|
}
|
|
@@ -13837,10 +14027,10 @@ function copyConfiguredFiles(repoPath, worktreePath) {
|
|
|
13837
14027
|
const patterns = resolveFilesToCopy(repoPath);
|
|
13838
14028
|
const copied = [];
|
|
13839
14029
|
for (const rel of patterns) {
|
|
13840
|
-
const src = (0,
|
|
14030
|
+
const src = (0, import_node_path37.join)(repoPath, rel);
|
|
13841
14031
|
if (!(0, import_node_fs36.existsSync)(src)) continue;
|
|
13842
|
-
const dest = (0,
|
|
13843
|
-
(0, import_node_fs36.mkdirSync)((0,
|
|
14032
|
+
const dest = (0, import_node_path37.join)(worktreePath, rel);
|
|
14033
|
+
(0, import_node_fs36.mkdirSync)((0, import_node_path37.dirname)(dest), { recursive: true });
|
|
13844
14034
|
(0, import_node_fs36.copyFileSync)(src, dest);
|
|
13845
14035
|
copied.push(rel);
|
|
13846
14036
|
}
|
|
@@ -13876,7 +14066,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
|
|
|
13876
14066
|
const env = stripNestedElectronEnv({
|
|
13877
14067
|
...baseEnv ?? process.env
|
|
13878
14068
|
});
|
|
13879
|
-
const name = opts.workspaceName ?? (0,
|
|
14069
|
+
const name = opts.workspaceName ?? (0, import_node_path37.basename)(opts.worktreePath);
|
|
13880
14070
|
const ports = opts.ports ?? [];
|
|
13881
14071
|
const primary = ports[0];
|
|
13882
14072
|
env.SIDEBOARD_WORKSPACE_NAME = name;
|
|
@@ -14139,13 +14329,13 @@ async function startDevServer(repoPath, worktreePath, onLine, opts) {
|
|
|
14139
14329
|
done: handle.done
|
|
14140
14330
|
};
|
|
14141
14331
|
}
|
|
14142
|
-
var import_node_fs36, import_node_net,
|
|
14332
|
+
var import_node_fs36, import_node_net, import_node_path37, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
|
|
14143
14333
|
var init_conductor = __esm({
|
|
14144
14334
|
"src/hook/conductor.ts"() {
|
|
14145
14335
|
"use strict";
|
|
14146
14336
|
import_node_fs36 = require("fs");
|
|
14147
14337
|
import_node_net = require("net");
|
|
14148
|
-
|
|
14338
|
+
import_node_path37 = require("path");
|
|
14149
14339
|
import_execa4 = require("execa");
|
|
14150
14340
|
import_node_readline3 = require("readline");
|
|
14151
14341
|
init_settings();
|
|
@@ -14172,7 +14362,7 @@ ${line}` : line;
|
|
|
14172
14362
|
return nl >= 0 && nl < cut.length - 1 ? cut.slice(nl + 1) : cut;
|
|
14173
14363
|
}
|
|
14174
14364
|
function setupLogPath(threadId) {
|
|
14175
|
-
return (0,
|
|
14365
|
+
return (0, import_node_path38.join)(threadsDir(), `${threadId}.setup.log.json`);
|
|
14176
14366
|
}
|
|
14177
14367
|
function setupLogKeyForWorktree(worktreePath) {
|
|
14178
14368
|
const norm = normalizeWorktreePath(worktreePath);
|
|
@@ -14267,13 +14457,13 @@ function finishSetupLog(threadId, exitCode, source) {
|
|
|
14267
14457
|
persistNow(threadId);
|
|
14268
14458
|
return clone(snap);
|
|
14269
14459
|
}
|
|
14270
|
-
var import_node_crypto8, import_node_fs37,
|
|
14460
|
+
var import_node_crypto8, import_node_fs37, import_node_path38, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers;
|
|
14271
14461
|
var init_setup_log = __esm({
|
|
14272
14462
|
"src/store/setup-log.ts"() {
|
|
14273
14463
|
"use strict";
|
|
14274
14464
|
import_node_crypto8 = require("crypto");
|
|
14275
14465
|
import_node_fs37 = require("fs");
|
|
14276
|
-
|
|
14466
|
+
import_node_path38 = require("path");
|
|
14277
14467
|
init_worktree_labels();
|
|
14278
14468
|
init_paths();
|
|
14279
14469
|
EMPTY = {
|
|
@@ -14335,9 +14525,9 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
14335
14525
|
if ((0, import_node_fs38.existsSync)(root)) {
|
|
14336
14526
|
for (const entry of (0, import_node_fs38.readdirSync)(root, { withFileTypes: true })) {
|
|
14337
14527
|
if (!entry.isDirectory()) continue;
|
|
14338
|
-
const path = (0,
|
|
14528
|
+
const path = (0, import_node_path39.join)(root, entry.name).replace(/\/$/, "");
|
|
14339
14529
|
if (known.has(path) || seen.has(path)) continue;
|
|
14340
|
-
if (!(0, import_node_fs38.existsSync)((0,
|
|
14530
|
+
if (!(0, import_node_fs38.existsSync)((0, import_node_path39.join)(path, ".git"))) continue;
|
|
14341
14531
|
seen.add(path);
|
|
14342
14532
|
let mtimeMs = 0;
|
|
14343
14533
|
try {
|
|
@@ -14393,12 +14583,12 @@ function shouldRunWorktreeCleanup(settings = loadAppSettings()) {
|
|
|
14393
14583
|
const elapsed = Date.now() - Date.parse(last);
|
|
14394
14584
|
return elapsed >= intervalHours * 36e5;
|
|
14395
14585
|
}
|
|
14396
|
-
var import_node_fs38,
|
|
14586
|
+
var import_node_fs38, import_node_path39;
|
|
14397
14587
|
var init_orphan_cleanup = __esm({
|
|
14398
14588
|
"src/git/orphan-cleanup.ts"() {
|
|
14399
14589
|
"use strict";
|
|
14400
14590
|
import_node_fs38 = require("fs");
|
|
14401
|
-
|
|
14591
|
+
import_node_path39 = require("path");
|
|
14402
14592
|
init_worktree();
|
|
14403
14593
|
init_thread_store();
|
|
14404
14594
|
init_paths();
|
|
@@ -14406,6 +14596,77 @@ var init_orphan_cleanup = __esm({
|
|
|
14406
14596
|
}
|
|
14407
14597
|
});
|
|
14408
14598
|
|
|
14599
|
+
// src/store/history-cleanup.ts
|
|
14600
|
+
function stripArchivedTranscript(thread) {
|
|
14601
|
+
writeThread(
|
|
14602
|
+
{
|
|
14603
|
+
...thread,
|
|
14604
|
+
attachments: [],
|
|
14605
|
+
pendingTurnAttachments: [],
|
|
14606
|
+
messages: [historyRetentionStubMessage(thread)]
|
|
14607
|
+
},
|
|
14608
|
+
{ touch: false }
|
|
14609
|
+
);
|
|
14610
|
+
}
|
|
14611
|
+
function cleanupArchivedHistory(opts = {}) {
|
|
14612
|
+
const settings = loadAppSettings();
|
|
14613
|
+
if (!opts.force && opts.purgeOlderThanDays == null && !autoCleanupHistoryEnabled(settings)) {
|
|
14614
|
+
return { stripped: [], purged: [] };
|
|
14615
|
+
}
|
|
14616
|
+
const archived = listThreads({ includeArchived: true }).filter((t) => t.status === "archived");
|
|
14617
|
+
const nowMs = opts.nowMs ?? Date.now();
|
|
14618
|
+
const plan = opts.purgeOlderThanDays != null ? { stripIds: [], purgeIds: planHistoryAgePurge(archived, opts.purgeOlderThanDays, nowMs) } : planHistoryRetention(archived, {
|
|
14619
|
+
maxCount: opts.maxCount ?? historyMaxCount(settings),
|
|
14620
|
+
maxDays: opts.maxDays ?? historyMaxDays(settings),
|
|
14621
|
+
nowMs
|
|
14622
|
+
});
|
|
14623
|
+
const stripped = [];
|
|
14624
|
+
const purged = [];
|
|
14625
|
+
if (opts.dryRun) {
|
|
14626
|
+
return { stripped: plan.stripIds, purged: plan.purgeIds };
|
|
14627
|
+
}
|
|
14628
|
+
for (const id of plan.stripIds) {
|
|
14629
|
+
const thread = readThread(id);
|
|
14630
|
+
if (!thread || thread.status !== "archived") continue;
|
|
14631
|
+
try {
|
|
14632
|
+
stripArchivedTranscript(thread);
|
|
14633
|
+
stripped.push(id);
|
|
14634
|
+
} catch {
|
|
14635
|
+
}
|
|
14636
|
+
}
|
|
14637
|
+
for (const id of plan.purgeIds) {
|
|
14638
|
+
const thread = readThread(id);
|
|
14639
|
+
if (!thread || thread.status !== "archived") continue;
|
|
14640
|
+
try {
|
|
14641
|
+
deleteThreadRecord(id);
|
|
14642
|
+
purged.push(id);
|
|
14643
|
+
} catch {
|
|
14644
|
+
}
|
|
14645
|
+
}
|
|
14646
|
+
if (stripped.length > 0 || purged.length > 0) {
|
|
14647
|
+
updateAdvancedSettings({
|
|
14648
|
+
historyLastCleanupAt: new Date(nowMs).toISOString()
|
|
14649
|
+
});
|
|
14650
|
+
}
|
|
14651
|
+
return { stripped, purged };
|
|
14652
|
+
}
|
|
14653
|
+
function shouldRunHistoryCleanup(settings = loadAppSettings()) {
|
|
14654
|
+
if (!autoCleanupHistoryEnabled(settings)) return false;
|
|
14655
|
+
const intervalHours = settings.advanced.historyCleanupIntervalHours ?? HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT;
|
|
14656
|
+
const last = settings.advanced.historyLastCleanupAt;
|
|
14657
|
+
if (!last) return true;
|
|
14658
|
+
const elapsed = Date.now() - Date.parse(last);
|
|
14659
|
+
return Number.isFinite(elapsed) && elapsed >= intervalHours * 36e5;
|
|
14660
|
+
}
|
|
14661
|
+
var init_history_cleanup = __esm({
|
|
14662
|
+
"src/store/history-cleanup.ts"() {
|
|
14663
|
+
"use strict";
|
|
14664
|
+
init_app_settings();
|
|
14665
|
+
init_history_retention();
|
|
14666
|
+
init_thread_store();
|
|
14667
|
+
}
|
|
14668
|
+
});
|
|
14669
|
+
|
|
14409
14670
|
// src/git/apply-into-main.ts
|
|
14410
14671
|
async function applyThreadIntoMain(thread, opts) {
|
|
14411
14672
|
const method = opts?.method ?? "merge";
|
|
@@ -14501,11 +14762,11 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
14501
14762
|
if (!url) throw new Error("Clone URL is required");
|
|
14502
14763
|
let name = opts.name?.trim();
|
|
14503
14764
|
if (!name) {
|
|
14504
|
-
const leaf = (0,
|
|
14765
|
+
const leaf = (0, import_node_path40.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
|
|
14505
14766
|
name = leaf || "repo";
|
|
14506
14767
|
}
|
|
14507
14768
|
name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
|
|
14508
|
-
const dest = (0,
|
|
14769
|
+
const dest = (0, import_node_path40.join)(sideboardReposDir(), name);
|
|
14509
14770
|
if ((0, import_node_fs39.existsSync)(dest)) {
|
|
14510
14771
|
const repoPath2 = await resolveRepoRoot(dest);
|
|
14511
14772
|
const workspace2 = await ensureWorkspace(repoPath2);
|
|
@@ -14521,12 +14782,12 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
14521
14782
|
const workspace = await ensureWorkspace(repoPath);
|
|
14522
14783
|
return { repoPath, workspace };
|
|
14523
14784
|
}
|
|
14524
|
-
var import_node_fs39,
|
|
14785
|
+
var import_node_fs39, import_node_path40, import_execa6;
|
|
14525
14786
|
var init_clone_repo = __esm({
|
|
14526
14787
|
"src/git/clone-repo.ts"() {
|
|
14527
14788
|
"use strict";
|
|
14528
14789
|
import_node_fs39 = require("fs");
|
|
14529
|
-
|
|
14790
|
+
import_node_path40 = require("path");
|
|
14530
14791
|
import_execa6 = require("execa");
|
|
14531
14792
|
init_paths();
|
|
14532
14793
|
init_workspaces2();
|
|
@@ -14536,7 +14797,7 @@ var init_clone_repo = __esm({
|
|
|
14536
14797
|
|
|
14537
14798
|
// src/store/desktop-host.ts
|
|
14538
14799
|
function desktopHostPidPath() {
|
|
14539
|
-
return (0,
|
|
14800
|
+
return (0, import_node_path41.join)(appDataDir(), "desktop-host.pid");
|
|
14540
14801
|
}
|
|
14541
14802
|
function readDesktopHostPid() {
|
|
14542
14803
|
try {
|
|
@@ -14566,12 +14827,12 @@ function thisProcessShouldDrainAgentQueues() {
|
|
|
14566
14827
|
if (isThisProcessDesktopHost()) return true;
|
|
14567
14828
|
return !isDesktopHostAlive();
|
|
14568
14829
|
}
|
|
14569
|
-
var import_node_fs40,
|
|
14830
|
+
var import_node_fs40, import_node_path41;
|
|
14570
14831
|
var init_desktop_host = __esm({
|
|
14571
14832
|
"src/store/desktop-host.ts"() {
|
|
14572
14833
|
"use strict";
|
|
14573
14834
|
import_node_fs40 = require("fs");
|
|
14574
|
-
|
|
14835
|
+
import_node_path41 = require("path");
|
|
14575
14836
|
init_paths();
|
|
14576
14837
|
}
|
|
14577
14838
|
});
|
|
@@ -14694,7 +14955,7 @@ function readIntFile(file) {
|
|
|
14694
14955
|
return Number.isInteger(n) ? n : null;
|
|
14695
14956
|
}
|
|
14696
14957
|
function jobDir(root, id, legacy = false) {
|
|
14697
|
-
return (0,
|
|
14958
|
+
return (0, import_node_path42.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
|
|
14698
14959
|
}
|
|
14699
14960
|
function resolveJobDir(root, id) {
|
|
14700
14961
|
const modern = jobDir(root, id, false);
|
|
@@ -14704,7 +14965,7 @@ function resolveJobDir(root, id) {
|
|
|
14704
14965
|
return modern;
|
|
14705
14966
|
}
|
|
14706
14967
|
function listJobIdsIn(root, rel) {
|
|
14707
|
-
const dir = (0,
|
|
14968
|
+
const dir = (0, import_node_path42.join)(root, rel);
|
|
14708
14969
|
if (!(0, import_node_fs41.existsSync)(dir)) return [];
|
|
14709
14970
|
return (0, import_node_fs41.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
|
|
14710
14971
|
}
|
|
@@ -14718,7 +14979,7 @@ function listRunningDetachedJobs(worktreePath) {
|
|
|
14718
14979
|
const running = [];
|
|
14719
14980
|
for (const id of ids) {
|
|
14720
14981
|
const dir = resolveJobDir(root, id);
|
|
14721
|
-
const pid = readIntFile((0,
|
|
14982
|
+
const pid = readIntFile((0, import_node_path42.join)(dir, "pid"));
|
|
14722
14983
|
if (jobTreeAlive(pid)) running.push(id);
|
|
14723
14984
|
}
|
|
14724
14985
|
return running.sort();
|
|
@@ -14821,15 +15082,15 @@ function takeDelta(logFile, cursorFile) {
|
|
|
14821
15082
|
return { delta: capJobLogDelta(lines.slice(start).join("\n")), nextCursor: lines.length };
|
|
14822
15083
|
}
|
|
14823
15084
|
function snapshotJob(dir) {
|
|
14824
|
-
const pid = readIntFile((0,
|
|
15085
|
+
const pid = readIntFile((0, import_node_path42.join)(dir, "pid"));
|
|
14825
15086
|
const running = jobTreeAlive(pid);
|
|
14826
15087
|
return {
|
|
14827
15088
|
pid,
|
|
14828
15089
|
running,
|
|
14829
|
-
exitCode: readIntFile((0,
|
|
14830
|
-
log: (0,
|
|
14831
|
-
cursor: (0,
|
|
14832
|
-
progress: tailProgress((0,
|
|
15090
|
+
exitCode: readIntFile((0, import_node_path42.join)(dir, "exit")),
|
|
15091
|
+
log: (0, import_node_path42.join)(dir, "log"),
|
|
15092
|
+
cursor: (0, import_node_path42.join)(dir, "present.cursor"),
|
|
15093
|
+
progress: tailProgress((0, import_node_path42.join)(dir, "log"))
|
|
14833
15094
|
};
|
|
14834
15095
|
}
|
|
14835
15096
|
function toResult(id, snap, extra) {
|
|
@@ -14838,7 +15099,7 @@ function toResult(id, snap, extra) {
|
|
|
14838
15099
|
const stillRunning = snap.running && !ok;
|
|
14839
15100
|
const { delta, nextCursor } = takeDelta(snap.log, snap.cursor);
|
|
14840
15101
|
try {
|
|
14841
|
-
(0, import_node_fs41.mkdirSync)((0,
|
|
15102
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path42.dirname)(snap.cursor), { recursive: true });
|
|
14842
15103
|
(0, import_node_fs41.writeFileSync)(snap.cursor, `${nextCursor}
|
|
14843
15104
|
`);
|
|
14844
15105
|
} catch {
|
|
@@ -14914,7 +15175,7 @@ function killProcessTree(pid, signal) {
|
|
|
14914
15175
|
}
|
|
14915
15176
|
function appendJobLog(logFile, line) {
|
|
14916
15177
|
try {
|
|
14917
|
-
(0, import_node_fs41.mkdirSync)((0,
|
|
15178
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path42.dirname)(logFile), { recursive: true });
|
|
14918
15179
|
const body = line.endsWith("\n") ? line : `${line}
|
|
14919
15180
|
`;
|
|
14920
15181
|
(0, import_node_fs41.appendFileSync)(logFile, body);
|
|
@@ -14963,7 +15224,7 @@ async function stopDetachedJob(cwd, id, opts) {
|
|
|
14963
15224
|
killProcessTree(targetPid, "SIGKILL");
|
|
14964
15225
|
await sleep(100);
|
|
14965
15226
|
}
|
|
14966
|
-
const exitFile = (0,
|
|
15227
|
+
const exitFile = (0, import_node_path42.join)(dir, "exit");
|
|
14967
15228
|
if (!(0, import_node_fs41.existsSync)(exitFile)) {
|
|
14968
15229
|
try {
|
|
14969
15230
|
(0, import_node_fs41.writeFileSync)(exitFile, "1\n");
|
|
@@ -14986,12 +15247,12 @@ async function stopDetachedJob(cwd, id, opts) {
|
|
|
14986
15247
|
hint: stopped ? MCP_STOP_JOB_HINT : MCP_WAIT_JOB_STILL_RUNNING_HINT
|
|
14987
15248
|
};
|
|
14988
15249
|
}
|
|
14989
|
-
var import_node_fs41,
|
|
15250
|
+
var import_node_fs41, import_node_path42, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, DEFERRED_DONE_MAX_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
|
|
14990
15251
|
var init_wait_for_job = __esm({
|
|
14991
15252
|
"src/mcp/wait-for-job.ts"() {
|
|
14992
15253
|
"use strict";
|
|
14993
15254
|
import_node_fs41 = require("fs");
|
|
14994
|
-
|
|
15255
|
+
import_node_path42 = require("path");
|
|
14995
15256
|
init_workspace_scratch();
|
|
14996
15257
|
init_wait_for_turn();
|
|
14997
15258
|
MAX_JOB_CONTINUES = 8;
|
|
@@ -17602,7 +17863,7 @@ var init_quota_failover = __esm({
|
|
|
17602
17863
|
// src/threads/adopt.ts
|
|
17603
17864
|
function thisModuleFile() {
|
|
17604
17865
|
const cjsFile = typeof __filename !== "undefined" ? __filename : "";
|
|
17605
|
-
return cjsFile || process.argv[1] || (0,
|
|
17866
|
+
return cjsFile || process.argv[1] || (0, import_node_path43.join)(process.cwd(), "package.json");
|
|
17606
17867
|
}
|
|
17607
17868
|
function openReadonlySqlite(file) {
|
|
17608
17869
|
const req = (0, import_node_module4.createRequire)(thisModuleFile());
|
|
@@ -17630,7 +17891,7 @@ function resolveConductorCursorAgentId(workspacePath) {
|
|
|
17630
17891
|
return null;
|
|
17631
17892
|
}
|
|
17632
17893
|
for (const hash of hashes) {
|
|
17633
|
-
const agentsFile = (0,
|
|
17894
|
+
const agentsFile = (0, import_node_path43.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
|
|
17634
17895
|
if (!(0, import_node_fs44.existsSync)(agentsFile)) continue;
|
|
17635
17896
|
let text7;
|
|
17636
17897
|
try {
|
|
@@ -17687,8 +17948,8 @@ function listConductorWorkspaces() {
|
|
|
17687
17948
|
if (!(0, import_node_fs44.existsSync)(CONDUCTOR_DB)) {
|
|
17688
17949
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
17689
17950
|
}
|
|
17690
|
-
const tmp = (0, import_node_fs44.mkdtempSync)((0,
|
|
17691
|
-
const snapshot = (0,
|
|
17951
|
+
const tmp = (0, import_node_fs44.mkdtempSync)((0, import_node_path43.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
|
|
17952
|
+
const snapshot = (0, import_node_path43.join)(tmp, "conductor.db");
|
|
17692
17953
|
try {
|
|
17693
17954
|
(0, import_node_fs44.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
17694
17955
|
for (const suffix of ["-wal", "-shm"]) {
|
|
@@ -17778,8 +18039,8 @@ function importConductorWorkspace(workspaceId) {
|
|
|
17778
18039
|
if (!(0, import_node_fs44.existsSync)(CONDUCTOR_DB)) {
|
|
17779
18040
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
17780
18041
|
}
|
|
17781
|
-
const tmp = (0, import_node_fs44.mkdtempSync)((0,
|
|
17782
|
-
const snapshot = (0,
|
|
18042
|
+
const tmp = (0, import_node_fs44.mkdtempSync)((0, import_node_path43.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
|
|
18043
|
+
const snapshot = (0, import_node_path43.join)(tmp, "conductor.db");
|
|
17783
18044
|
try {
|
|
17784
18045
|
(0, import_node_fs44.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
17785
18046
|
for (const suffix of ["-wal", "-shm"]) {
|
|
@@ -17873,25 +18134,25 @@ function importConductorWorkspace(workspaceId) {
|
|
|
17873
18134
|
async function importConductorWorkspaceAsync(workspaceId) {
|
|
17874
18135
|
return importConductorWorkspace(workspaceId);
|
|
17875
18136
|
}
|
|
17876
|
-
var import_node_child_process4, import_node_fs44, import_node_os14,
|
|
18137
|
+
var import_node_child_process4, import_node_fs44, import_node_os14, import_node_path43, import_node_module4, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
|
|
17877
18138
|
var init_adopt = __esm({
|
|
17878
18139
|
"src/threads/adopt.ts"() {
|
|
17879
18140
|
"use strict";
|
|
17880
18141
|
import_node_child_process4 = require("child_process");
|
|
17881
18142
|
import_node_fs44 = require("fs");
|
|
17882
18143
|
import_node_os14 = require("os");
|
|
17883
|
-
|
|
18144
|
+
import_node_path43 = require("path");
|
|
17884
18145
|
import_node_module4 = require("module");
|
|
17885
18146
|
init_worktree();
|
|
17886
18147
|
init_thread_store();
|
|
17887
|
-
CONDUCTOR_APP_SUPPORT = (0,
|
|
18148
|
+
CONDUCTOR_APP_SUPPORT = (0, import_node_path43.join)(
|
|
17888
18149
|
process.env.HOME ?? "",
|
|
17889
18150
|
"Library",
|
|
17890
18151
|
"Application Support",
|
|
17891
18152
|
"com.conductor.app"
|
|
17892
18153
|
);
|
|
17893
|
-
CONDUCTOR_DB = (0,
|
|
17894
|
-
CURSOR_SDK_STORE = (0,
|
|
18154
|
+
CONDUCTOR_DB = (0, import_node_path43.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
|
|
18155
|
+
CURSOR_SDK_STORE = (0, import_node_path43.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
|
|
17895
18156
|
}
|
|
17896
18157
|
});
|
|
17897
18158
|
|
|
@@ -18336,7 +18597,7 @@ new file mode 100644
|
|
|
18336
18597
|
};
|
|
18337
18598
|
}
|
|
18338
18599
|
async function untrackedPatch(worktreePath, path, maxHunk) {
|
|
18339
|
-
const abs = (0,
|
|
18600
|
+
const abs = (0, import_node_path44.join)(worktreePath, path);
|
|
18340
18601
|
try {
|
|
18341
18602
|
const st = (0, import_node_fs46.statSync)(abs);
|
|
18342
18603
|
if (st.isFile() && st.size > maxHunk) {
|
|
@@ -18829,7 +19090,7 @@ function isImageRelativePath(relativePath) {
|
|
|
18829
19090
|
function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
18830
19091
|
assertSafeRelativePath(relativePath);
|
|
18831
19092
|
const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
|
|
18832
|
-
const abs = (0,
|
|
19093
|
+
const abs = (0, import_node_path44.join)(worktreePath, relativePath);
|
|
18833
19094
|
const st = (0, import_node_fs46.statSync)(abs);
|
|
18834
19095
|
if (!st.isFile()) {
|
|
18835
19096
|
throw new Error(`Not a file: ${relativePath}`);
|
|
@@ -18849,7 +19110,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
18849
19110
|
function readWorktreeFile(worktreePath, relativePath, opts) {
|
|
18850
19111
|
assertSafeRelativePath(relativePath);
|
|
18851
19112
|
const maxBytes = opts?.maxBytes ?? 2e5;
|
|
18852
|
-
const abs = (0,
|
|
19113
|
+
const abs = (0, import_node_path44.join)(worktreePath, relativePath);
|
|
18853
19114
|
const st = (0, import_node_fs46.statSync)(abs);
|
|
18854
19115
|
if (!st.isFile()) {
|
|
18855
19116
|
throw new Error(`Not a file: ${relativePath}`);
|
|
@@ -18897,8 +19158,8 @@ function assertSafeRelativePath(relativePath) {
|
|
|
18897
19158
|
}
|
|
18898
19159
|
function writeWorktreeFile(worktreePath, relativePath, content) {
|
|
18899
19160
|
assertSafeRelativePath(relativePath);
|
|
18900
|
-
const abs = (0,
|
|
18901
|
-
(0, import_node_fs46.mkdirSync)((0,
|
|
19161
|
+
const abs = (0, import_node_path44.join)(worktreePath, relativePath);
|
|
19162
|
+
(0, import_node_fs46.mkdirSync)((0, import_node_path44.dirname)(abs), { recursive: true });
|
|
18902
19163
|
(0, import_node_fs46.writeFileSync)(abs, content, "utf8");
|
|
18903
19164
|
return { path: relativePath };
|
|
18904
19165
|
}
|
|
@@ -18916,12 +19177,12 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
|
18916
19177
|
truncated: full.files.length > maxFiles
|
|
18917
19178
|
};
|
|
18918
19179
|
}
|
|
18919
|
-
var import_node_fs46,
|
|
19180
|
+
var import_node_fs46, import_node_path44, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
|
|
18920
19181
|
var init_diff = __esm({
|
|
18921
19182
|
"src/diff/diff.ts"() {
|
|
18922
19183
|
"use strict";
|
|
18923
19184
|
import_node_fs46 = require("fs");
|
|
18924
|
-
|
|
19185
|
+
import_node_path44 = require("path");
|
|
18925
19186
|
init_run();
|
|
18926
19187
|
init_worktree();
|
|
18927
19188
|
mergeBaseCache = /* @__PURE__ */ new Map();
|
|
@@ -19306,7 +19567,7 @@ function scanSkillsDir(dir, source, out) {
|
|
|
19306
19567
|
}
|
|
19307
19568
|
for (const entry of entries) {
|
|
19308
19569
|
if (entry.startsWith(".")) continue;
|
|
19309
|
-
const skillMd = (0,
|
|
19570
|
+
const skillMd = (0, import_node_path45.join)(dir, entry, "SKILL.md");
|
|
19310
19571
|
if (!(0, import_node_fs47.existsSync)(skillMd)) continue;
|
|
19311
19572
|
try {
|
|
19312
19573
|
if (!(0, import_node_fs47.statSync)(skillMd).isFile()) continue;
|
|
@@ -19328,12 +19589,12 @@ function scanClaudePluginSkills(pluginsRoot, out) {
|
|
|
19328
19589
|
return;
|
|
19329
19590
|
}
|
|
19330
19591
|
if (lookingForSkillsDir && entries.includes("SKILL.md")) {
|
|
19331
|
-
const skill = readSkill((0,
|
|
19592
|
+
const skill = readSkill((0, import_node_path45.join)(dir, "SKILL.md"), "cli");
|
|
19332
19593
|
if (skill) out.push(skill);
|
|
19333
19594
|
}
|
|
19334
19595
|
for (const entry of entries) {
|
|
19335
19596
|
if (entry === "node_modules" || entry === ".git") continue;
|
|
19336
|
-
const full = (0,
|
|
19597
|
+
const full = (0, import_node_path45.join)(dir, entry);
|
|
19337
19598
|
try {
|
|
19338
19599
|
if (!(0, import_node_fs47.statSync)(full).isDirectory()) continue;
|
|
19339
19600
|
} catch {
|
|
@@ -19353,17 +19614,17 @@ function discoverSkills(worktreePath) {
|
|
|
19353
19614
|
const home = (0, import_node_os15.homedir)();
|
|
19354
19615
|
const collected = [];
|
|
19355
19616
|
for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
|
|
19356
|
-
scanSkillsDir((0,
|
|
19617
|
+
scanSkillsDir((0, import_node_path45.join)(worktreePath, rel), "workspace", collected);
|
|
19357
19618
|
}
|
|
19358
19619
|
for (const abs of [
|
|
19359
|
-
(0,
|
|
19360
|
-
(0,
|
|
19361
|
-
(0,
|
|
19362
|
-
(0,
|
|
19620
|
+
(0, import_node_path45.join)(home, ".claude/skills"),
|
|
19621
|
+
(0, import_node_path45.join)(home, ".cursor/skills"),
|
|
19622
|
+
(0, import_node_path45.join)(home, ".sideboard/skills"),
|
|
19623
|
+
(0, import_node_path45.join)(home, ".brightsy/skills")
|
|
19363
19624
|
]) {
|
|
19364
19625
|
scanSkillsDir(abs, "user", collected);
|
|
19365
19626
|
}
|
|
19366
|
-
scanClaudePluginSkills((0,
|
|
19627
|
+
scanClaudePluginSkills((0, import_node_path45.join)(home, ".claude/plugins"), collected);
|
|
19367
19628
|
collected.push(...bundledSkills());
|
|
19368
19629
|
const rank = {
|
|
19369
19630
|
workspace: 0,
|
|
@@ -19403,13 +19664,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
|
|
|
19403
19664
|
|
|
19404
19665
|
\u2026(truncated)` : raw;
|
|
19405
19666
|
}
|
|
19406
|
-
var import_node_fs47, import_node_os15,
|
|
19667
|
+
var import_node_fs47, import_node_os15, import_node_path45, BUNDLED_SKILL_PREFIX;
|
|
19407
19668
|
var init_discover = __esm({
|
|
19408
19669
|
"src/skills/discover.ts"() {
|
|
19409
19670
|
"use strict";
|
|
19410
19671
|
import_node_fs47 = require("fs");
|
|
19411
19672
|
import_node_os15 = require("os");
|
|
19412
|
-
|
|
19673
|
+
import_node_path45 = require("path");
|
|
19413
19674
|
init_long_running();
|
|
19414
19675
|
BUNDLED_SKILL_PREFIX = "bundled:";
|
|
19415
19676
|
}
|
|
@@ -19530,7 +19791,7 @@ var init_consume_attachments = __esm({
|
|
|
19530
19791
|
// src/skills/detached-job-path.ts
|
|
19531
19792
|
function detachedJobScriptIn(dir) {
|
|
19532
19793
|
for (const name of DETACHED_JOB_FILENAMES) {
|
|
19533
|
-
const script = (0,
|
|
19794
|
+
const script = (0, import_node_path46.join)(dir, "scripts", name);
|
|
19534
19795
|
if ((0, import_node_fs48.existsSync)(script)) return script;
|
|
19535
19796
|
}
|
|
19536
19797
|
return null;
|
|
@@ -19543,11 +19804,11 @@ function packagedDetachedJobPath() {
|
|
|
19543
19804
|
function resolveDetachedJobScript() {
|
|
19544
19805
|
const packaged = packagedDetachedJobPath();
|
|
19545
19806
|
if (packaged) return packaged;
|
|
19546
|
-
let dir = (0,
|
|
19807
|
+
let dir = (0, import_node_path46.dirname)((0, import_node_url3.fileURLToPath)(import_meta3.url));
|
|
19547
19808
|
for (let i = 0; i < 8; i++) {
|
|
19548
19809
|
const candidate = detachedJobScriptIn(dir);
|
|
19549
19810
|
if (candidate) return candidate;
|
|
19550
|
-
const parent = (0,
|
|
19811
|
+
const parent = (0, import_node_path46.dirname)(dir);
|
|
19551
19812
|
if (parent === dir) break;
|
|
19552
19813
|
dir = parent;
|
|
19553
19814
|
}
|
|
@@ -19558,12 +19819,12 @@ function formatDetachedJobInvoke(scriptPath) {
|
|
|
19558
19819
|
if (resolved) return `node ${JSON.stringify(resolved)}`;
|
|
19559
19820
|
return "node scripts/detached-job.cjs";
|
|
19560
19821
|
}
|
|
19561
|
-
var import_node_fs48,
|
|
19822
|
+
var import_node_fs48, import_node_path46, import_node_url3, import_meta3, DETACHED_JOB_FILENAMES;
|
|
19562
19823
|
var init_detached_job_path = __esm({
|
|
19563
19824
|
"src/skills/detached-job-path.ts"() {
|
|
19564
19825
|
"use strict";
|
|
19565
19826
|
import_node_fs48 = require("fs");
|
|
19566
|
-
|
|
19827
|
+
import_node_path46 = require("path");
|
|
19567
19828
|
import_node_url3 = require("url");
|
|
19568
19829
|
init_packaged_runtime();
|
|
19569
19830
|
import_meta3 = {};
|
|
@@ -19723,9 +19984,9 @@ function formatPrGateDirective() {
|
|
|
19723
19984
|
}
|
|
19724
19985
|
function formatProcessGuideDirective(opts) {
|
|
19725
19986
|
const worktree = opts?.worktreePath?.trim();
|
|
19726
|
-
const hasGraphSkill = !!worktree && (0, import_node_fs49.existsSync)((0,
|
|
19727
|
-
const hasReviewSkill = !!worktree && (0, import_node_fs49.existsSync)((0,
|
|
19728
|
-
const hasInstallSkill = !!worktree && (0, import_node_fs49.existsSync)((0,
|
|
19987
|
+
const hasGraphSkill = !!worktree && (0, import_node_fs49.existsSync)((0, import_node_path47.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
|
|
19988
|
+
const hasReviewSkill = !!worktree && (0, import_node_fs49.existsSync)((0, import_node_path47.join)(worktree, ".claude/skills/review/SKILL.md"));
|
|
19989
|
+
const hasInstallSkill = !!worktree && (0, import_node_fs49.existsSync)((0, import_node_path47.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
|
|
19729
19990
|
return [
|
|
19730
19991
|
"Process guides (recurring work only):",
|
|
19731
19992
|
hasGraphSkill ? "- Migrations, ports, batch fixes, and other fan-out: follow `.claude/skills/graph-engineering/SKILL.md` (`/graph-engineering`). Judge first; state on disk; grow the rulebook; do not patch around it." : null,
|
|
@@ -19763,12 +20024,12 @@ function formatArtifactDirective() {
|
|
|
19763
20024
|
function formatUiReminder() {
|
|
19764
20025
|
return "Sideboard UI: markdown table is enough to read data; present_schema if they ask to edit/filter (even after markdown); present_files for the file manager. html fence or present_artifact, not both for the same document. type=log appends (same artifact_id, new lines only). ask_user only for a real multiple-choice (not hellos, \u201Cwhat next?\u201D, or after a review) \u2014 reply in chat. Do not say artifacts/CMS UI are unavailable.";
|
|
19765
20026
|
}
|
|
19766
|
-
var import_node_fs49,
|
|
20027
|
+
var import_node_fs49, import_node_path47, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
|
|
19767
20028
|
var init_instructions = __esm({
|
|
19768
20029
|
"src/agents/instructions.ts"() {
|
|
19769
20030
|
"use strict";
|
|
19770
20031
|
import_node_fs49 = require("fs");
|
|
19771
|
-
|
|
20032
|
+
import_node_path47 = require("path");
|
|
19772
20033
|
init_git_auth_mode();
|
|
19773
20034
|
init_branch_prefix();
|
|
19774
20035
|
init_worktree_labels();
|
|
@@ -19992,13 +20253,13 @@ __export(plan_file_exports, {
|
|
|
19992
20253
|
writePlanFile: () => writePlanFile
|
|
19993
20254
|
});
|
|
19994
20255
|
function ensureAttachmentsGitignore(worktreePath) {
|
|
19995
|
-
const gitignoreAbs = (0,
|
|
20256
|
+
const gitignoreAbs = (0, import_node_path48.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
|
|
19996
20257
|
if ((0, import_node_fs50.existsSync)(gitignoreAbs)) return;
|
|
19997
|
-
(0, import_node_fs50.mkdirSync)((0,
|
|
20258
|
+
(0, import_node_fs50.mkdirSync)((0, import_node_path48.dirname)(gitignoreAbs), { recursive: true });
|
|
19998
20259
|
(0, import_node_fs50.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
|
|
19999
20260
|
}
|
|
20000
20261
|
function planFileAbs(worktreePath) {
|
|
20001
|
-
return (0,
|
|
20262
|
+
return (0, import_node_path48.join)(worktreePath, PLAN_FILE_REL);
|
|
20002
20263
|
}
|
|
20003
20264
|
function readTextIfPresent2(abs) {
|
|
20004
20265
|
if (!(0, import_node_fs50.existsSync)(abs)) return null;
|
|
@@ -20010,22 +20271,22 @@ function readTextIfPresent2(abs) {
|
|
|
20010
20271
|
}
|
|
20011
20272
|
}
|
|
20012
20273
|
function readPlanFile(worktreePath) {
|
|
20013
|
-
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0,
|
|
20274
|
+
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path48.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path48.join)(worktreePath, LEGACY_PLAN_FILE_REL));
|
|
20014
20275
|
}
|
|
20015
20276
|
function writePlanFile(worktreePath, content) {
|
|
20016
20277
|
ensureAttachmentsGitignore(worktreePath);
|
|
20017
20278
|
const abs = planFileAbs(worktreePath);
|
|
20018
|
-
(0, import_node_fs50.mkdirSync)((0,
|
|
20279
|
+
(0, import_node_fs50.mkdirSync)((0, import_node_path48.dirname)(abs), { recursive: true });
|
|
20019
20280
|
const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
|
|
20020
20281
|
(0, import_node_fs50.writeFileSync)(abs, body, "utf8");
|
|
20021
20282
|
return PLAN_FILE_REL;
|
|
20022
20283
|
}
|
|
20023
|
-
var import_node_fs50,
|
|
20284
|
+
var import_node_fs50, import_node_path48;
|
|
20024
20285
|
var init_plan_file = __esm({
|
|
20025
20286
|
"src/plan/plan-file.ts"() {
|
|
20026
20287
|
"use strict";
|
|
20027
20288
|
import_node_fs50 = require("fs");
|
|
20028
|
-
|
|
20289
|
+
import_node_path48 = require("path");
|
|
20029
20290
|
init_workspace_scratch();
|
|
20030
20291
|
init_plan_present();
|
|
20031
20292
|
init_plan_present();
|
|
@@ -20085,7 +20346,7 @@ function setCaffeinateHoldHooks(next) {
|
|
|
20085
20346
|
hooks = next;
|
|
20086
20347
|
}
|
|
20087
20348
|
function caffeinateHoldPath() {
|
|
20088
|
-
return (0,
|
|
20349
|
+
return (0, import_node_path49.join)(appDataDir(), "caffeinate-hold.json");
|
|
20089
20350
|
}
|
|
20090
20351
|
function processAlive(pid) {
|
|
20091
20352
|
if (hooks.processAlive) return hooks.processAlive(pid);
|
|
@@ -20228,13 +20489,13 @@ function releaseCaffeinateHoldForThread(threadId) {
|
|
|
20228
20489
|
}
|
|
20229
20490
|
return setCaffeinateHold(false, { threadId: id });
|
|
20230
20491
|
}
|
|
20231
|
-
var import_node_child_process5, import_node_fs51,
|
|
20492
|
+
var import_node_child_process5, import_node_fs51, import_node_path49, hooks;
|
|
20232
20493
|
var init_caffeinate_hold = __esm({
|
|
20233
20494
|
"src/store/caffeinate-hold.ts"() {
|
|
20234
20495
|
"use strict";
|
|
20235
20496
|
import_node_child_process5 = require("child_process");
|
|
20236
20497
|
import_node_fs51 = require("fs");
|
|
20237
|
-
|
|
20498
|
+
import_node_path49 = require("path");
|
|
20238
20499
|
init_paths();
|
|
20239
20500
|
init_private_file();
|
|
20240
20501
|
hooks = {};
|
|
@@ -20243,7 +20504,7 @@ var init_caffeinate_hold = __esm({
|
|
|
20243
20504
|
|
|
20244
20505
|
// src/store/schedules.ts
|
|
20245
20506
|
function schedulesPath() {
|
|
20246
|
-
return (0,
|
|
20507
|
+
return (0, import_node_path50.join)(appDataDir(), "schedules.json");
|
|
20247
20508
|
}
|
|
20248
20509
|
function parseDurationMs(every) {
|
|
20249
20510
|
const m = every.trim().match(DURATION_RE);
|
|
@@ -20457,13 +20718,13 @@ function recordScheduleRun(id, result) {
|
|
|
20457
20718
|
writeAll2(rows);
|
|
20458
20719
|
return next;
|
|
20459
20720
|
}
|
|
20460
|
-
var import_node_crypto11, import_node_fs52,
|
|
20721
|
+
var import_node_crypto11, import_node_fs52, import_node_path50, import_croner, DURATION_RE, UNIT_MS;
|
|
20461
20722
|
var init_schedules = __esm({
|
|
20462
20723
|
"src/store/schedules.ts"() {
|
|
20463
20724
|
"use strict";
|
|
20464
20725
|
import_node_crypto11 = require("crypto");
|
|
20465
20726
|
import_node_fs52 = require("fs");
|
|
20466
|
-
|
|
20727
|
+
import_node_path50 = require("path");
|
|
20467
20728
|
import_croner = require("croner");
|
|
20468
20729
|
init_orchestrator_capable();
|
|
20469
20730
|
init_paths();
|
|
@@ -20603,37 +20864,6 @@ var init_schedule_runner = __esm({
|
|
|
20603
20864
|
}
|
|
20604
20865
|
});
|
|
20605
20866
|
|
|
20606
|
-
// src/agents/cursor-store.ts
|
|
20607
|
-
function cursorSdkStoreDir(threadId) {
|
|
20608
|
-
const root = (0, import_node_path50.join)(appDataDir(), CURSOR_SDK_STORE_DIR);
|
|
20609
|
-
const id = sanitizeCursorStoreSegment(threadId);
|
|
20610
|
-
if (!id) return root;
|
|
20611
|
-
return (0, import_node_path50.join)(root, "threads", id);
|
|
20612
|
-
}
|
|
20613
|
-
function cursorSdkRunsNdjsonPath(threadId) {
|
|
20614
|
-
return (0, import_node_path50.join)(cursorSdkStoreDir(threadId), "runs.ndjson");
|
|
20615
|
-
}
|
|
20616
|
-
function cursorSdkRunsNdjsonSearchPaths(threadId) {
|
|
20617
|
-
const scoped = cursorSdkRunsNdjsonPath(threadId);
|
|
20618
|
-
const shared = cursorSdkRunsNdjsonPath(null);
|
|
20619
|
-
if (!threadId || !sanitizeCursorStoreSegment(threadId) || scoped === shared) {
|
|
20620
|
-
return [shared];
|
|
20621
|
-
}
|
|
20622
|
-
return [scoped, shared];
|
|
20623
|
-
}
|
|
20624
|
-
function sanitizeCursorStoreSegment(threadId) {
|
|
20625
|
-
return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
20626
|
-
}
|
|
20627
|
-
var import_node_path50, CURSOR_SDK_STORE_DIR;
|
|
20628
|
-
var init_cursor_store = __esm({
|
|
20629
|
-
"src/agents/cursor-store.ts"() {
|
|
20630
|
-
"use strict";
|
|
20631
|
-
import_node_path50 = require("path");
|
|
20632
|
-
init_paths();
|
|
20633
|
-
CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
|
|
20634
|
-
}
|
|
20635
|
-
});
|
|
20636
|
-
|
|
20637
20867
|
// src/agents/cursor-recover.ts
|
|
20638
20868
|
var cursor_recover_exports = {};
|
|
20639
20869
|
__export(cursor_recover_exports, {
|
|
@@ -20843,6 +21073,7 @@ var init_orchestrator = __esm({
|
|
|
20843
21073
|
init_conductor();
|
|
20844
21074
|
init_setup_log();
|
|
20845
21075
|
init_orphan_cleanup();
|
|
21076
|
+
init_history_cleanup();
|
|
20846
21077
|
init_apply_into_main();
|
|
20847
21078
|
init_clone_repo();
|
|
20848
21079
|
init_message_parts();
|
|
@@ -21030,6 +21261,12 @@ var init_orchestrator = __esm({
|
|
|
21030
21261
|
}
|
|
21031
21262
|
} catch {
|
|
21032
21263
|
}
|
|
21264
|
+
try {
|
|
21265
|
+
if (shouldRunHistoryCleanup()) {
|
|
21266
|
+
cleanupArchivedHistory();
|
|
21267
|
+
}
|
|
21268
|
+
} catch {
|
|
21269
|
+
}
|
|
21033
21270
|
if (drainQueues) {
|
|
21034
21271
|
this.adoptPersistedQueues();
|
|
21035
21272
|
}
|
|
@@ -22358,6 +22595,20 @@ var init_orchestrator = __esm({
|
|
|
22358
22595
|
repoPaths
|
|
22359
22596
|
});
|
|
22360
22597
|
}
|
|
22598
|
+
/** Bound Settings → History. After archive always; reconcile is interval-gated. */
|
|
22599
|
+
enforceHistoryRetention() {
|
|
22600
|
+
try {
|
|
22601
|
+
cleanupArchivedHistory();
|
|
22602
|
+
} catch {
|
|
22603
|
+
}
|
|
22604
|
+
}
|
|
22605
|
+
cleanupHistory(opts) {
|
|
22606
|
+
return cleanupArchivedHistory({
|
|
22607
|
+
dryRun: opts?.dryRun,
|
|
22608
|
+
purgeOlderThanDays: opts?.purgeOlderThanDays,
|
|
22609
|
+
force: opts?.force
|
|
22610
|
+
});
|
|
22611
|
+
}
|
|
22361
22612
|
/**
|
|
22362
22613
|
* Best-of-n / fanout: create N threads (one per agent) with the same prompt.
|
|
22363
22614
|
*/
|
|
@@ -22918,6 +23169,7 @@ var init_orchestrator = __esm({
|
|
|
22918
23169
|
if (isGlobalThread(thread)) {
|
|
22919
23170
|
const archived2 = setStatus(thread.id, "archived");
|
|
22920
23171
|
this.emit({ type: "status_changed", threadId: archived2.id, status: "archived" });
|
|
23172
|
+
this.enforceHistoryRetention();
|
|
22921
23173
|
return archived2;
|
|
22922
23174
|
}
|
|
22923
23175
|
const siblings = threadsSharingWorktree(thread.worktreePath).filter((t) => t.id !== thread.id);
|
|
@@ -22939,6 +23191,7 @@ var init_orchestrator = __esm({
|
|
|
22939
23191
|
}
|
|
22940
23192
|
const archived = setStatus(thread.id, "archived");
|
|
22941
23193
|
this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
|
|
23194
|
+
this.enforceHistoryRetention();
|
|
22942
23195
|
if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
|
|
22943
23196
|
try {
|
|
22944
23197
|
const { ensureWorkspace: ensureWorkspace2 } = await Promise.resolve().then(() => (init_workspaces2(), workspaces_exports));
|