@sideboard-ai/core 0.1.208 → 0.1.210
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-GDZLZRMY.js} +4 -4
- package/dist/{abletime-UWSSLXH3.js → abletime-QGGYL2G4.js} +4 -4
- package/dist/{abletime-oauth-C3BQXKW3.js → abletime-oauth-3X3BAPTF.js} +3 -3
- package/dist/{abletime-oauth-UZHPB3W2.js → abletime-oauth-F335TWKY.js} +3 -3
- package/dist/{abletime-rest-HYNYDYK3.js → abletime-rest-LAGTPAJL.js} +3 -3
- package/dist/{abletime-rest-5YPPEOKK.js → abletime-rest-PLJVY3H3.js} +3 -3
- package/dist/agents/cursor-runner.js +3 -3
- package/dist/{agents-QHQXR55O.js → agents-G3TFVFBQ.js} +6 -5
- package/dist/{agents-CCS5IEBV.js → agents-IQZUN47D.js} +6 -5
- package/dist/{app-settings-GJ6KDYEF.js → app-settings-2TN3WLZV.js} +7 -1
- package/dist/{app-settings-R2KNCT37.js → app-settings-XCRNCEEE.js} +7 -1
- package/dist/{chunk-F4LZUEIO.js → chunk-2M5B7YNY.js} +2 -2
- package/dist/{chunk-C6ZNQV5W.js → chunk-2R6BZRRB.js} +117 -25
- package/dist/{chunk-HA4EZKFY.js → chunk-3S2LDD2F.js} +3 -3
- package/dist/{chunk-6YZLSZLK.js → chunk-42IULNIY.js} +3 -3
- package/dist/{chunk-C5MNMITQ.js → chunk-AOQZZA3M.js} +119 -25
- package/dist/{chunk-4EGK47WV.js → chunk-BTC2D6LS.js} +217 -0
- package/dist/{chunk-7DKX5JLT.js → chunk-FGTPRMPS.js} +18 -3
- package/dist/{chunk-X45BV4VX.js → chunk-G4TANQC3.js} +5 -5
- package/dist/{chunk-Y4CF7LHH.js → chunk-L5CIEBLR.js} +232 -0
- package/dist/{chunk-WXWJ5MJ4.js → chunk-LS6TSOCE.js} +5 -5
- package/dist/{chunk-6J4OQ6TF.js → chunk-MN6YUD4O.js} +3 -3
- package/dist/{chunk-7PEIIN7P.js → chunk-NDE5RKZP.js} +24 -87
- package/dist/{chunk-W6X4GZJG.js → chunk-REZRGCKV.js} +3 -3
- package/dist/{chunk-NJ2CCLV6.js → chunk-WX4S775K.js} +2 -2
- package/dist/chunk-X5B3OS5I.js +34 -0
- package/dist/{chunk-ZHCB4CKR.js → chunk-X5PUFYDJ.js} +18 -3
- package/dist/{chunk-TEDEVD4O.js → chunk-YVE4PXCJ.js} +2 -2
- package/dist/{chunk-A6SOSLUV.js → chunk-YYELAUKP.js} +24 -94
- package/dist/{chunk-DNTPX6HV.js → chunk-ZC664YBJ.js} +3 -3
- package/dist/{chunk-OP6CFVTB.js → chunk-ZZNZX2QW.js} +2 -2
- package/dist/{coordinator-prompt-WOTJQMD5.js → coordinator-prompt-GCITY3Q5.js} +5 -4
- package/dist/{coordinator-prompt-TUHB6ZFA.js → coordinator-prompt-PONGPWIP.js} +5 -4
- package/dist/{cursor-recover-TXVTLAMA.js → cursor-recover-4PQAADAU.js} +3 -28
- package/dist/{global-workspace-V6G2KH2V.js → global-workspace-LIZHU4GM.js} +5 -4
- package/dist/{global-workspace-5UUUNA4A.js → global-workspace-LQZLTGFL.js} +5 -4
- package/dist/index.cjs +681 -385
- package/dist/index.d.cts +96 -5
- package/dist/index.d.ts +96 -5
- package/dist/index.js +52 -19
- package/dist/mcp/run-stdio.cjs +647 -385
- package/dist/mcp/run-stdio.js +12 -11
- package/dist/{orchestrator-4IGHVRAF.js → orchestrator-G5HELCVT.js} +7 -6
- package/dist/{orchestrator-D4AQNF25.js → orchestrator-ZBUXJCII.js} +7 -6
- package/dist/{thread-store-FMWDFAO5.js → thread-store-FCWU7Y3X.js} +2 -1
- package/dist/{thread-store-ESZYZSVC.js → thread-store-KMZRQEPY.js} +2 -1
- package/dist/{workspaces-PZ36M7EQ.js → workspaces-2XW2DMRG.js} +5 -4
- package/dist/{workspaces-CLNANACI.js → workspaces-T6PMQZYQ.js} +5 -4
- package/dist/{worktree-JKTM47K5.js → worktree-2OEMMFRT.js} +4 -3
- package/dist/{worktree-NC4XQNQI.js → worktree-5ZGWKKZ6.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, {
|
|
@@ -852,7 +883,8 @@ function normalizeThread(raw) {
|
|
|
852
883
|
userSetTitle: Boolean(raw.userSetTitle),
|
|
853
884
|
activeRuns: Array.isArray(raw.activeRuns) ? raw.activeRuns : [],
|
|
854
885
|
quotaResumeAt: raw.quotaResumeAt ?? null,
|
|
855
|
-
quotaContinuedFromId: raw.quotaContinuedFromId ?? null
|
|
886
|
+
quotaContinuedFromId: raw.quotaContinuedFromId ?? null,
|
|
887
|
+
archivedAt: typeof raw.archivedAt === "string" && raw.archivedAt.trim() ? raw.archivedAt.trim() : void 0
|
|
856
888
|
};
|
|
857
889
|
}
|
|
858
890
|
function createEmptyThread(partial) {
|
|
@@ -887,6 +919,7 @@ function createEmptyThread(partial) {
|
|
|
887
919
|
pendingTurnAttachments: partial.pendingTurnAttachments ?? [],
|
|
888
920
|
createdAt: ts,
|
|
889
921
|
updatedAt: ts,
|
|
922
|
+
archivedAt: typeof partial.archivedAt === "string" && partial.archivedAt.trim() ? partial.archivedAt.trim() : void 0,
|
|
890
923
|
title: partial.title,
|
|
891
924
|
sourceType: partial.sourceType,
|
|
892
925
|
sourceRef: partial.sourceRef,
|
|
@@ -958,10 +991,10 @@ function readThread(id) {
|
|
|
958
991
|
rememberThread(thread, mtimeMs);
|
|
959
992
|
return thread;
|
|
960
993
|
}
|
|
961
|
-
function writeThread(thread) {
|
|
994
|
+
function writeThread(thread, opts) {
|
|
962
995
|
const path = threadFilePath(idPath(thread.id));
|
|
963
996
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
964
|
-
const next = { ...thread, updatedAt: nowIso() };
|
|
997
|
+
const next = opts?.touch === false ? { ...thread } : { ...thread, updatedAt: nowIso() };
|
|
965
998
|
(0, import_node_fs8.writeFileSync)(tmp, JSON.stringify(next, null, 2), "utf8");
|
|
966
999
|
(0, import_node_fs8.renameSync)(tmp, path);
|
|
967
1000
|
rememberThread(next, fileMtimeMs(path) ?? Date.now());
|
|
@@ -970,7 +1003,7 @@ function idPath(id) {
|
|
|
970
1003
|
return id;
|
|
971
1004
|
}
|
|
972
1005
|
function isThreadRecordFile(nameOrPath) {
|
|
973
|
-
const name = (0,
|
|
1006
|
+
const name = (0, import_node_path9.basename)(nameOrPath);
|
|
974
1007
|
return name.endsWith(".json") && !name.endsWith(".live.json");
|
|
975
1008
|
}
|
|
976
1009
|
function listThreads(opts) {
|
|
@@ -1006,11 +1039,20 @@ function deleteThreadRecord(id) {
|
|
|
1006
1039
|
} catch {
|
|
1007
1040
|
}
|
|
1008
1041
|
}
|
|
1042
|
+
try {
|
|
1043
|
+
(0, import_node_fs8.rmSync)(cursorSdkStoreDir(id), { recursive: true, force: true });
|
|
1044
|
+
} catch {
|
|
1045
|
+
}
|
|
1009
1046
|
}
|
|
1010
1047
|
function updateThread(id, patch) {
|
|
1011
1048
|
const current = readThread(id);
|
|
1012
1049
|
if (!current) throw new Error(`Thread not found: ${id}`);
|
|
1013
1050
|
const next = { ...current, ...patch, id: current.id, updatedAt: nowIso() };
|
|
1051
|
+
if (next.status === "archived") {
|
|
1052
|
+
next.archivedAt = typeof next.archivedAt === "string" && next.archivedAt.trim() || current.archivedAt || nowIso();
|
|
1053
|
+
} else {
|
|
1054
|
+
delete next.archivedAt;
|
|
1055
|
+
}
|
|
1014
1056
|
writeThread(next);
|
|
1015
1057
|
return next;
|
|
1016
1058
|
}
|
|
@@ -1028,15 +1070,16 @@ function findThreadByRef(ref) {
|
|
|
1028
1070
|
(t) => t.id === ref || t.id.startsWith(ref) || t.branchName === ref || t.title === ref
|
|
1029
1071
|
) ?? null;
|
|
1030
1072
|
}
|
|
1031
|
-
var import_node_crypto2, import_node_fs8,
|
|
1073
|
+
var import_node_crypto2, import_node_fs8, import_node_path9, import_proper_lockfile, listCache;
|
|
1032
1074
|
var init_thread_store = __esm({
|
|
1033
1075
|
"src/store/thread-store.ts"() {
|
|
1034
1076
|
"use strict";
|
|
1035
1077
|
import_node_crypto2 = require("crypto");
|
|
1036
1078
|
import_node_fs8 = require("fs");
|
|
1037
|
-
|
|
1079
|
+
import_node_path9 = require("path");
|
|
1038
1080
|
import_proper_lockfile = __toESM(require("proper-lockfile"), 1);
|
|
1039
1081
|
init_thinking_effort();
|
|
1082
|
+
init_cursor_store();
|
|
1040
1083
|
init_paths();
|
|
1041
1084
|
listCache = null;
|
|
1042
1085
|
}
|
|
@@ -1086,7 +1129,7 @@ var init_api = __esm({
|
|
|
1086
1129
|
|
|
1087
1130
|
// src/slack/reply-target.ts
|
|
1088
1131
|
function storePath() {
|
|
1089
|
-
return (0,
|
|
1132
|
+
return (0, import_node_path10.join)(appDataDir(), "slack-reply-to.json");
|
|
1090
1133
|
}
|
|
1091
1134
|
function readStore() {
|
|
1092
1135
|
const path = storePath();
|
|
@@ -1101,12 +1144,12 @@ function readStore() {
|
|
|
1101
1144
|
function getSlackReplyTarget(threadId) {
|
|
1102
1145
|
return readStore()[threadId] ?? null;
|
|
1103
1146
|
}
|
|
1104
|
-
var import_node_fs9,
|
|
1147
|
+
var import_node_fs9, import_node_path10;
|
|
1105
1148
|
var init_reply_target = __esm({
|
|
1106
1149
|
"src/slack/reply-target.ts"() {
|
|
1107
1150
|
"use strict";
|
|
1108
1151
|
import_node_fs9 = require("fs");
|
|
1109
|
-
|
|
1152
|
+
import_node_path10 = require("path");
|
|
1110
1153
|
init_paths();
|
|
1111
1154
|
init_private_file();
|
|
1112
1155
|
init_secure_file();
|
|
@@ -1115,7 +1158,7 @@ var init_reply_target = __esm({
|
|
|
1115
1158
|
|
|
1116
1159
|
// src/slack/workspaces.ts
|
|
1117
1160
|
function storePath2() {
|
|
1118
|
-
return (0,
|
|
1161
|
+
return (0, import_node_path11.join)(appDataDir(), "slack-workspaces.json");
|
|
1119
1162
|
}
|
|
1120
1163
|
function readStore2() {
|
|
1121
1164
|
try {
|
|
@@ -1176,11 +1219,11 @@ function requireSlackWorkspace(teamId) {
|
|
|
1176
1219
|
}
|
|
1177
1220
|
return ws;
|
|
1178
1221
|
}
|
|
1179
|
-
var
|
|
1222
|
+
var import_node_path11;
|
|
1180
1223
|
var init_workspaces = __esm({
|
|
1181
1224
|
"src/slack/workspaces.ts"() {
|
|
1182
1225
|
"use strict";
|
|
1183
|
-
|
|
1226
|
+
import_node_path11 = require("path");
|
|
1184
1227
|
init_paths();
|
|
1185
1228
|
init_secure_file();
|
|
1186
1229
|
init_api();
|
|
@@ -1189,7 +1232,7 @@ var init_workspaces = __esm({
|
|
|
1189
1232
|
|
|
1190
1233
|
// src/slack/outbound-watch.ts
|
|
1191
1234
|
function storePath3() {
|
|
1192
|
-
return (0,
|
|
1235
|
+
return (0, import_node_path12.join)(appDataDir(), "slack-outbound-watch.json");
|
|
1193
1236
|
}
|
|
1194
1237
|
function watchId(teamId, channelId, ts) {
|
|
1195
1238
|
return `${teamId}:${channelId}:${ts}`;
|
|
@@ -1526,12 +1569,12 @@ async function pollSlackOutboundWatches(opts) {
|
|
|
1526
1569
|
}
|
|
1527
1570
|
if (changed) writeStore(watches);
|
|
1528
1571
|
}
|
|
1529
|
-
var import_node_fs10,
|
|
1572
|
+
var import_node_fs10, import_node_path12, MAX_WATCHES, MAX_REPLIES_PER_WATCH, WATCH_TTL_MS, POLL_INTERVAL_MS, lastPollMs, nameCache, continueOnReply;
|
|
1530
1573
|
var init_outbound_watch = __esm({
|
|
1531
1574
|
"src/slack/outbound-watch.ts"() {
|
|
1532
1575
|
"use strict";
|
|
1533
1576
|
import_node_fs10 = require("fs");
|
|
1534
|
-
|
|
1577
|
+
import_node_path12 = require("path");
|
|
1535
1578
|
init_paths();
|
|
1536
1579
|
init_private_file();
|
|
1537
1580
|
init_secure_file();
|
|
@@ -1929,23 +1972,23 @@ var init_error_detail = __esm({
|
|
|
1929
1972
|
function prependPathDir(env, dir) {
|
|
1930
1973
|
if (!dir || !(0, import_node_fs11.existsSync)(dir)) return;
|
|
1931
1974
|
const current = env.PATH ?? "";
|
|
1932
|
-
const parts = current.split(
|
|
1975
|
+
const parts = current.split(import_node_path13.delimiter).filter(Boolean);
|
|
1933
1976
|
if (parts.includes(dir)) {
|
|
1934
1977
|
env.PATH = current;
|
|
1935
1978
|
return;
|
|
1936
1979
|
}
|
|
1937
|
-
env.PATH = [dir, ...parts].join(
|
|
1980
|
+
env.PATH = [dir, ...parts].join(import_node_path13.delimiter);
|
|
1938
1981
|
}
|
|
1939
1982
|
function conductorBundledBinDir(home = process.env.HOME || process.env.USERPROFILE || (0, import_node_os3.homedir)()) {
|
|
1940
|
-
return (0,
|
|
1983
|
+
return (0, import_node_path13.join)(home, "Library", "Application Support", "com.conductor.app", "bin");
|
|
1941
1984
|
}
|
|
1942
1985
|
function ensureAgentPath(env = process.env) {
|
|
1943
1986
|
const home = env.HOME || env.USERPROFILE || (0, import_node_os3.homedir)();
|
|
1944
1987
|
const current = env.PATH ?? "";
|
|
1945
|
-
const parts = current.split(
|
|
1988
|
+
const parts = current.split(import_node_path13.delimiter).filter(Boolean);
|
|
1946
1989
|
const seen = new Set(parts);
|
|
1947
1990
|
const extras = [
|
|
1948
|
-
...EXTRA_BIN_DIRS.map((rel) => (0,
|
|
1991
|
+
...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path13.join)(home, rel)),
|
|
1949
1992
|
"/opt/homebrew/bin",
|
|
1950
1993
|
"/usr/local/bin",
|
|
1951
1994
|
// Keep after Homebrew/npm so a user-installed CLI still wins.
|
|
@@ -1956,7 +1999,7 @@ function ensureAgentPath(env = process.env) {
|
|
|
1956
1999
|
parts.unshift(dir);
|
|
1957
2000
|
seen.add(dir);
|
|
1958
2001
|
}
|
|
1959
|
-
const next = parts.join(
|
|
2002
|
+
const next = parts.join(import_node_path13.delimiter);
|
|
1960
2003
|
env.PATH = next;
|
|
1961
2004
|
return next;
|
|
1962
2005
|
}
|
|
@@ -1970,21 +2013,21 @@ function enrichPathWithNpmGlobalBin(env = process.env) {
|
|
|
1970
2013
|
stdio: ["ignore", "pipe", "ignore"]
|
|
1971
2014
|
}).trim().split(/\r?\n/).find(Boolean);
|
|
1972
2015
|
if (prefix) {
|
|
1973
|
-
const binDir = process.platform === "win32" ? prefix : (0,
|
|
2016
|
+
const binDir = process.platform === "win32" ? prefix : (0, import_node_path13.join)(prefix, "bin");
|
|
1974
2017
|
prependPathDir(env, binDir);
|
|
1975
2018
|
}
|
|
1976
2019
|
} catch {
|
|
1977
2020
|
}
|
|
1978
2021
|
return env.PATH ?? "";
|
|
1979
2022
|
}
|
|
1980
|
-
var import_node_fs11, import_node_child_process3, import_node_os3,
|
|
2023
|
+
var import_node_fs11, import_node_child_process3, import_node_os3, import_node_path13, EXTRA_BIN_DIRS;
|
|
1981
2024
|
var init_path = __esm({
|
|
1982
2025
|
"src/agents/path.ts"() {
|
|
1983
2026
|
"use strict";
|
|
1984
2027
|
import_node_fs11 = require("fs");
|
|
1985
2028
|
import_node_child_process3 = require("child_process");
|
|
1986
2029
|
import_node_os3 = require("os");
|
|
1987
|
-
|
|
2030
|
+
import_node_path13 = require("path");
|
|
1988
2031
|
EXTRA_BIN_DIRS = [
|
|
1989
2032
|
".local/bin",
|
|
1990
2033
|
".cargo/bin",
|
|
@@ -2005,18 +2048,18 @@ var init_path = __esm({
|
|
|
2005
2048
|
function githubAgentAuthDir() {
|
|
2006
2049
|
const override = process.env.SIDEBOARD_GIT_AUTH_DIR?.trim();
|
|
2007
2050
|
if (override) return override;
|
|
2008
|
-
return (0,
|
|
2051
|
+
return (0, import_node_path14.join)((0, import_node_os4.homedir)(), ".sideboard-git-auth");
|
|
2009
2052
|
}
|
|
2010
2053
|
function githubCredentialStorePath() {
|
|
2011
|
-
return (0,
|
|
2054
|
+
return (0, import_node_path14.join)(githubAgentAuthDir(), "git-credentials");
|
|
2012
2055
|
}
|
|
2013
2056
|
function githubGhConfigDir() {
|
|
2014
|
-
return (0,
|
|
2057
|
+
return (0, import_node_path14.join)(githubAgentAuthDir(), "gh");
|
|
2015
2058
|
}
|
|
2016
2059
|
function writePrivateFile2(file, body) {
|
|
2017
|
-
(0, import_node_fs12.mkdirSync)((0,
|
|
2060
|
+
(0, import_node_fs12.mkdirSync)((0, import_node_path14.dirname)(file), { recursive: true, mode: 448 });
|
|
2018
2061
|
try {
|
|
2019
|
-
(0, import_node_fs12.chmodSync)((0,
|
|
2062
|
+
(0, import_node_fs12.chmodSync)((0, import_node_path14.dirname)(file), 448);
|
|
2020
2063
|
} catch {
|
|
2021
2064
|
}
|
|
2022
2065
|
(0, import_node_fs12.writeFileSync)(file, body, { encoding: "utf8", mode: 384 });
|
|
@@ -2054,11 +2097,11 @@ function materializeGithubAgentAuth(token, user) {
|
|
|
2054
2097
|
writePrivateFile2(githubCredentialStorePath(), gitCredentialStoreContents(trimmed));
|
|
2055
2098
|
const ghDir = githubGhConfigDir();
|
|
2056
2099
|
(0, import_node_fs12.mkdirSync)(ghDir, { recursive: true, mode: 448 });
|
|
2057
|
-
writePrivateFile2((0,
|
|
2058
|
-
writePrivateFile2((0,
|
|
2100
|
+
writePrivateFile2((0, import_node_path14.join)(ghDir, "hosts.yml"), ghHostsYml(trimmed, user));
|
|
2101
|
+
writePrivateFile2((0, import_node_path14.join)(ghDir, "config.yml"), "git_protocol: https\nprompt: disabled\n");
|
|
2059
2102
|
}
|
|
2060
2103
|
function githubAgentAuthReady() {
|
|
2061
|
-
return (0, import_node_fs12.existsSync)(githubCredentialStorePath()) && (0, import_node_fs12.existsSync)((0,
|
|
2104
|
+
return (0, import_node_fs12.existsSync)(githubCredentialStorePath()) && (0, import_node_fs12.existsSync)((0, import_node_path14.join)(githubGhConfigDir(), "hosts.yml"));
|
|
2062
2105
|
}
|
|
2063
2106
|
function githubCredentialHelperGitConfig() {
|
|
2064
2107
|
const file = githubCredentialStorePath();
|
|
@@ -2073,13 +2116,13 @@ function githubGhConfigEnv() {
|
|
|
2073
2116
|
GH_PROMPT_DISABLED: "1"
|
|
2074
2117
|
};
|
|
2075
2118
|
}
|
|
2076
|
-
var import_node_fs12, import_node_os4,
|
|
2119
|
+
var import_node_fs12, import_node_os4, import_node_path14;
|
|
2077
2120
|
var init_github_agent_auth = __esm({
|
|
2078
2121
|
"src/git/github-agent-auth.ts"() {
|
|
2079
2122
|
"use strict";
|
|
2080
2123
|
import_node_fs12 = require("fs");
|
|
2081
2124
|
import_node_os4 = require("os");
|
|
2082
|
-
|
|
2125
|
+
import_node_path14 = require("path");
|
|
2083
2126
|
}
|
|
2084
2127
|
});
|
|
2085
2128
|
|
|
@@ -2088,7 +2131,7 @@ function isIndexLockError(text7) {
|
|
|
2088
2131
|
return /Unable to create ['"][^'"]*index\.lock['"]: File exists/i.test(text7);
|
|
2089
2132
|
}
|
|
2090
2133
|
function clearStaleIndexLock(gitDir, maxAgeMs = STALE_INDEX_LOCK_MS, now = Date.now()) {
|
|
2091
|
-
const lockPath = (0,
|
|
2134
|
+
const lockPath = (0, import_node_path15.join)(gitDir, "index.lock");
|
|
2092
2135
|
try {
|
|
2093
2136
|
if (!(0, import_node_fs13.existsSync)(lockPath)) return null;
|
|
2094
2137
|
if (now - (0, import_node_fs13.statSync)(lockPath).mtimeMs < maxAgeMs) return null;
|
|
@@ -2107,12 +2150,12 @@ function clearStaleIndexLocks(gitDirs, maxAgeMs = STALE_INDEX_LOCK_MS) {
|
|
|
2107
2150
|
}
|
|
2108
2151
|
return removed;
|
|
2109
2152
|
}
|
|
2110
|
-
var import_node_fs13,
|
|
2153
|
+
var import_node_fs13, import_node_path15, STALE_INDEX_LOCK_MS;
|
|
2111
2154
|
var init_stale_lock = __esm({
|
|
2112
2155
|
"src/git/stale-lock.ts"() {
|
|
2113
2156
|
"use strict";
|
|
2114
2157
|
import_node_fs13 = require("fs");
|
|
2115
|
-
|
|
2158
|
+
import_node_path15 = require("path");
|
|
2116
2159
|
STALE_INDEX_LOCK_MS = 2e4;
|
|
2117
2160
|
}
|
|
2118
2161
|
});
|
|
@@ -3222,8 +3265,8 @@ async function ensureWorktreeSideboardIgnored(worktreePath) {
|
|
|
3222
3265
|
if (gitDir.exitCode !== 0) return;
|
|
3223
3266
|
const dir = gitDir.stdout.trim();
|
|
3224
3267
|
if (!dir) return;
|
|
3225
|
-
const excludePath = (0,
|
|
3226
|
-
(0, import_node_fs14.mkdirSync)((0,
|
|
3268
|
+
const excludePath = (0, import_node_path16.join)(dir, "info", "exclude");
|
|
3269
|
+
(0, import_node_fs14.mkdirSync)((0, import_node_path16.dirname)(excludePath), { recursive: true });
|
|
3227
3270
|
let body = "";
|
|
3228
3271
|
try {
|
|
3229
3272
|
body = (0, import_node_fs14.readFileSync)(excludePath, "utf8");
|
|
@@ -3257,12 +3300,12 @@ async function ensureWorktreeSideboardIgnored(worktreePath) {
|
|
|
3257
3300
|
timeoutMs: 8e3
|
|
3258
3301
|
});
|
|
3259
3302
|
}
|
|
3260
|
-
var import_node_fs14,
|
|
3303
|
+
var import_node_fs14, import_node_path16, WORKTREE_SIDEBOARD_EXCLUDE, WORKTREE_CONTEXT_EXCLUDE, EXCLUDE_COMMENT;
|
|
3261
3304
|
var init_worktree_exclude = __esm({
|
|
3262
3305
|
"src/git/worktree-exclude.ts"() {
|
|
3263
3306
|
"use strict";
|
|
3264
3307
|
import_node_fs14 = require("fs");
|
|
3265
|
-
|
|
3308
|
+
import_node_path16 = require("path");
|
|
3266
3309
|
init_run();
|
|
3267
3310
|
WORKTREE_SIDEBOARD_EXCLUDE = ".sideboard/";
|
|
3268
3311
|
WORKTREE_CONTEXT_EXCLUDE = ".context/";
|
|
@@ -3413,7 +3456,7 @@ var init_account_profile = __esm({
|
|
|
3413
3456
|
|
|
3414
3457
|
// src/store/secret-vault.ts
|
|
3415
3458
|
function secretVaultPath() {
|
|
3416
|
-
return (0,
|
|
3459
|
+
return (0, import_node_path17.join)(appDataDir(), "secrets.json");
|
|
3417
3460
|
}
|
|
3418
3461
|
function loadSecretVault() {
|
|
3419
3462
|
const parsed = readSecureJson(secretVaultPath());
|
|
@@ -3475,11 +3518,11 @@ function normalizeVault(raw) {
|
|
|
3475
3518
|
}
|
|
3476
3519
|
return out;
|
|
3477
3520
|
}
|
|
3478
|
-
var
|
|
3521
|
+
var import_node_path17;
|
|
3479
3522
|
var init_secret_vault = __esm({
|
|
3480
3523
|
"src/store/secret-vault.ts"() {
|
|
3481
3524
|
"use strict";
|
|
3482
|
-
|
|
3525
|
+
import_node_path17 = require("path");
|
|
3483
3526
|
init_paths();
|
|
3484
3527
|
init_secure_file();
|
|
3485
3528
|
}
|
|
@@ -3511,6 +3554,179 @@ var init_branch_prefix = __esm({
|
|
|
3511
3554
|
}
|
|
3512
3555
|
});
|
|
3513
3556
|
|
|
3557
|
+
// src/agents/usage.ts
|
|
3558
|
+
function sumOptional(a, b) {
|
|
3559
|
+
if (a == null && b == null) return void 0;
|
|
3560
|
+
return (a ?? 0) + (b ?? 0);
|
|
3561
|
+
}
|
|
3562
|
+
function fromInclusiveInputUsage(opts) {
|
|
3563
|
+
const totalInput = Number(opts.inputTokens) || 0;
|
|
3564
|
+
const outputTokens = Number(opts.outputTokens) || 0;
|
|
3565
|
+
const cached = Number(opts.cachedInputTokens) || 0;
|
|
3566
|
+
if (!totalInput && !outputTokens) return null;
|
|
3567
|
+
const cacheReadTokens = cached > 0 ? Math.min(cached, totalInput) : 0;
|
|
3568
|
+
return {
|
|
3569
|
+
inputTokens: Math.max(0, totalInput - cacheReadTokens),
|
|
3570
|
+
outputTokens,
|
|
3571
|
+
cacheReadTokens: cacheReadTokens || void 0
|
|
3572
|
+
};
|
|
3573
|
+
}
|
|
3574
|
+
function requestOccupancy(u) {
|
|
3575
|
+
return u.inputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
|
|
3576
|
+
}
|
|
3577
|
+
function mergeUsage(a, b) {
|
|
3578
|
+
return {
|
|
3579
|
+
inputTokens: (a?.inputTokens ?? 0) + b.inputTokens,
|
|
3580
|
+
outputTokens: (a?.outputTokens ?? 0) + b.outputTokens,
|
|
3581
|
+
cacheReadTokens: sumOptional(a?.cacheReadTokens, b.cacheReadTokens),
|
|
3582
|
+
cacheWriteTokens: sumOptional(a?.cacheWriteTokens, b.cacheWriteTokens),
|
|
3583
|
+
costUsd: sumOptional(a?.costUsd, b.costUsd),
|
|
3584
|
+
lastRequestTokens: b.lastRequestTokens ?? a?.lastRequestTokens
|
|
3585
|
+
};
|
|
3586
|
+
}
|
|
3587
|
+
function sumUsageList(list) {
|
|
3588
|
+
let acc = null;
|
|
3589
|
+
for (const u of list) {
|
|
3590
|
+
if (!u) continue;
|
|
3591
|
+
acc = mergeUsage(acc, {
|
|
3592
|
+
inputTokens: u.inputTokens,
|
|
3593
|
+
outputTokens: u.outputTokens,
|
|
3594
|
+
cacheReadTokens: u.cacheReadTokens,
|
|
3595
|
+
cacheWriteTokens: u.cacheWriteTokens,
|
|
3596
|
+
costUsd: u.costUsd
|
|
3597
|
+
});
|
|
3598
|
+
}
|
|
3599
|
+
if (!acc) return null;
|
|
3600
|
+
return {
|
|
3601
|
+
inputTokens: acc.inputTokens,
|
|
3602
|
+
outputTokens: acc.outputTokens,
|
|
3603
|
+
...acc.cacheReadTokens != null ? { cacheReadTokens: acc.cacheReadTokens } : {},
|
|
3604
|
+
...acc.cacheWriteTokens != null ? { cacheWriteTokens: acc.cacheWriteTokens } : {},
|
|
3605
|
+
...acc.costUsd != null ? { costUsd: acc.costUsd } : {}
|
|
3606
|
+
};
|
|
3607
|
+
}
|
|
3608
|
+
function hasBilledTokens(u) {
|
|
3609
|
+
return Boolean(
|
|
3610
|
+
u.inputTokens || u.outputTokens || u.cacheReadTokens || u.cacheWriteTokens
|
|
3611
|
+
);
|
|
3612
|
+
}
|
|
3613
|
+
function applyTurnUsage(current, incoming, scope = "request") {
|
|
3614
|
+
if (scope === "turn") {
|
|
3615
|
+
if (!hasBilledTokens(incoming) && current && incoming.costUsd != null) {
|
|
3616
|
+
return { ...current, costUsd: incoming.costUsd };
|
|
3617
|
+
}
|
|
3618
|
+
return {
|
|
3619
|
+
...incoming,
|
|
3620
|
+
costUsd: incoming.costUsd ?? current?.costUsd,
|
|
3621
|
+
lastRequestTokens: current?.lastRequestTokens ?? requestOccupancy(incoming)
|
|
3622
|
+
};
|
|
3623
|
+
}
|
|
3624
|
+
const merged = mergeUsage(current, incoming);
|
|
3625
|
+
const occ = incoming.lastRequestTokens != null && incoming.lastRequestTokens > 0 ? incoming.lastRequestTokens : requestOccupancy(incoming);
|
|
3626
|
+
return {
|
|
3627
|
+
...merged,
|
|
3628
|
+
lastRequestTokens: occ > 0 ? occ : current?.lastRequestTokens ?? occ
|
|
3629
|
+
};
|
|
3630
|
+
}
|
|
3631
|
+
function contextTokens(u) {
|
|
3632
|
+
if (u.lastRequestTokens != null && u.lastRequestTokens > 0) return u.lastRequestTokens;
|
|
3633
|
+
return requestOccupancy(u);
|
|
3634
|
+
}
|
|
3635
|
+
var init_usage = __esm({
|
|
3636
|
+
"src/agents/usage.ts"() {
|
|
3637
|
+
"use strict";
|
|
3638
|
+
}
|
|
3639
|
+
});
|
|
3640
|
+
|
|
3641
|
+
// src/store/history-retention.ts
|
|
3642
|
+
function clampHistoryMaxCount(value) {
|
|
3643
|
+
return Math.max(HISTORY_MAX_COUNT_MIN, Math.min(HISTORY_MAX_COUNT_MAX, Math.floor(value)));
|
|
3644
|
+
}
|
|
3645
|
+
function clampHistoryMaxDays(value) {
|
|
3646
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
3647
|
+
return Math.min(HISTORY_MAX_DAYS_MAX, Math.floor(value));
|
|
3648
|
+
}
|
|
3649
|
+
function archivedUpdatedMs(thread) {
|
|
3650
|
+
const stamped = thread.archivedAt ? Date.parse(thread.archivedAt) : NaN;
|
|
3651
|
+
if (Number.isFinite(stamped)) return stamped;
|
|
3652
|
+
const updated = Date.parse(thread.updatedAt);
|
|
3653
|
+
if (Number.isFinite(updated)) return updated;
|
|
3654
|
+
const created = Date.parse(thread.createdAt);
|
|
3655
|
+
return Number.isFinite(created) ? created : 0;
|
|
3656
|
+
}
|
|
3657
|
+
function isHistoryRetentionStub(thread) {
|
|
3658
|
+
if ((thread.attachments?.length ?? 0) > 0) return false;
|
|
3659
|
+
const messages = thread.messages ?? [];
|
|
3660
|
+
if (messages.length === 0) return true;
|
|
3661
|
+
if (messages.length > 1) return false;
|
|
3662
|
+
const only = messages[0];
|
|
3663
|
+
if (only.parts?.length) return false;
|
|
3664
|
+
if ((only.attachments?.length ?? 0) > 0) return false;
|
|
3665
|
+
const text7 = (only.text ?? "").trim();
|
|
3666
|
+
return text7 === "" || text7 === HISTORY_DISCARDED_TEXT;
|
|
3667
|
+
}
|
|
3668
|
+
function historyRetentionStubMessage(thread) {
|
|
3669
|
+
const usage = sumUsageList((thread.messages ?? []).map((m) => m.usage));
|
|
3670
|
+
return {
|
|
3671
|
+
role: "summary",
|
|
3672
|
+
text: HISTORY_DISCARDED_TEXT,
|
|
3673
|
+
ts: thread.updatedAt,
|
|
3674
|
+
...usage ? { usage } : {}
|
|
3675
|
+
};
|
|
3676
|
+
}
|
|
3677
|
+
function sortArchivedOldestFirst(threads) {
|
|
3678
|
+
return [...threads].sort((a, b) => archivedUpdatedMs(a) - archivedUpdatedMs(b));
|
|
3679
|
+
}
|
|
3680
|
+
function planHistoryRetention(archived, thresholds = {}) {
|
|
3681
|
+
const maxCount = clampHistoryMaxCount(thresholds.maxCount ?? HISTORY_MAX_COUNT_DEFAULT);
|
|
3682
|
+
const maxDays = clampHistoryMaxDays(thresholds.maxDays ?? HISTORY_MAX_DAYS_DEFAULT);
|
|
3683
|
+
const nowMs = thresholds.nowMs ?? Date.now();
|
|
3684
|
+
const oldestFirst = sortArchivedOldestFirst(archived);
|
|
3685
|
+
const expiredIds = /* @__PURE__ */ new Set();
|
|
3686
|
+
if (maxDays > 0) {
|
|
3687
|
+
const cutoff = nowMs - maxDays * 864e5;
|
|
3688
|
+
for (const thread of oldestFirst) {
|
|
3689
|
+
if (archivedUpdatedMs(thread) < cutoff) expiredIds.add(thread.id);
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
const remaining = oldestFirst.filter((t) => !expiredIds.has(t.id));
|
|
3693
|
+
const overflow = remaining.length > maxCount ? remaining.slice(0, remaining.length - maxCount) : [];
|
|
3694
|
+
const stripIds = [];
|
|
3695
|
+
const purgeIds = [...expiredIds];
|
|
3696
|
+
const seenPurge = new Set(purgeIds);
|
|
3697
|
+
for (const thread of overflow) {
|
|
3698
|
+
if (isHistoryRetentionStub(thread)) {
|
|
3699
|
+
if (!seenPurge.has(thread.id)) {
|
|
3700
|
+
seenPurge.add(thread.id);
|
|
3701
|
+
purgeIds.push(thread.id);
|
|
3702
|
+
}
|
|
3703
|
+
} else {
|
|
3704
|
+
stripIds.push(thread.id);
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
return { stripIds, purgeIds };
|
|
3708
|
+
}
|
|
3709
|
+
function planHistoryAgePurge(archived, olderThanDays, nowMs = Date.now()) {
|
|
3710
|
+
const days = clampHistoryMaxDays(olderThanDays);
|
|
3711
|
+
if (days <= 0) return [];
|
|
3712
|
+
const cutoff = nowMs - days * 864e5;
|
|
3713
|
+
return sortArchivedOldestFirst(archived).filter((t) => archivedUpdatedMs(t) < cutoff).map((t) => t.id);
|
|
3714
|
+
}
|
|
3715
|
+
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;
|
|
3716
|
+
var init_history_retention = __esm({
|
|
3717
|
+
"src/store/history-retention.ts"() {
|
|
3718
|
+
"use strict";
|
|
3719
|
+
init_usage();
|
|
3720
|
+
HISTORY_MAX_COUNT_DEFAULT = 200;
|
|
3721
|
+
HISTORY_MAX_COUNT_MIN = 1;
|
|
3722
|
+
HISTORY_MAX_COUNT_MAX = 2e3;
|
|
3723
|
+
HISTORY_MAX_DAYS_DEFAULT = 0;
|
|
3724
|
+
HISTORY_MAX_DAYS_MAX = 3650;
|
|
3725
|
+
HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT = 6;
|
|
3726
|
+
HISTORY_DISCARDED_TEXT = "Transcript discarded by History retention.";
|
|
3727
|
+
}
|
|
3728
|
+
});
|
|
3729
|
+
|
|
3514
3730
|
// src/store/usage-on-limit.ts
|
|
3515
3731
|
function isUsageOnLimit(value) {
|
|
3516
3732
|
return value === "keep_going" || value === "confirm" || value === "switch_agent" || value === "wait_reset";
|
|
@@ -3567,6 +3783,7 @@ __export(app_settings_exports, {
|
|
|
3567
3783
|
appSettingsPath: () => appSettingsPath,
|
|
3568
3784
|
applyAppEnvironment: () => applyAppEnvironment,
|
|
3569
3785
|
autoArchiveOnMergeEnabled: () => autoArchiveOnMergeEnabled,
|
|
3786
|
+
autoCleanupHistoryEnabled: () => autoCleanupHistoryEnabled,
|
|
3570
3787
|
autoCleanupOrphansEnabled: () => autoCleanupOrphansEnabled,
|
|
3571
3788
|
autoRenameBranchEnabled: () => autoRenameBranchEnabled,
|
|
3572
3789
|
autoRunAfterSetupEnabled: () => autoRunAfterSetupEnabled,
|
|
@@ -3607,6 +3824,8 @@ __export(app_settings_exports, {
|
|
|
3607
3824
|
getLinearApiKey: () => getLinearApiKey,
|
|
3608
3825
|
gitBranchPrefixSetting: () => gitBranchPrefixSetting,
|
|
3609
3826
|
harnessEnvKey: () => harnessEnvKey,
|
|
3827
|
+
historyMaxCount: () => historyMaxCount,
|
|
3828
|
+
historyMaxDays: () => historyMaxDays,
|
|
3610
3829
|
isAbleTimeConnected: () => isAbleTimeConnected,
|
|
3611
3830
|
isIssueSourceConnected: () => isIssueSourceConnected,
|
|
3612
3831
|
isLinearConnected: () => isLinearConnected,
|
|
@@ -3720,10 +3939,10 @@ function toPublicAppSettings(settings) {
|
|
|
3720
3939
|
};
|
|
3721
3940
|
}
|
|
3722
3941
|
function appSettingsPath() {
|
|
3723
|
-
return (0,
|
|
3942
|
+
return (0, import_node_path18.join)(appDataDir(), "settings.json");
|
|
3724
3943
|
}
|
|
3725
3944
|
function claudeUserSettingsPath() {
|
|
3726
|
-
return (0,
|
|
3945
|
+
return (0, import_node_path18.join)((0, import_node_os5.homedir)(), ".claude", "settings.json");
|
|
3727
3946
|
}
|
|
3728
3947
|
function normalizeClaude(raw) {
|
|
3729
3948
|
if (!raw || typeof raw !== "object") return {};
|
|
@@ -3731,7 +3950,7 @@ function normalizeClaude(raw) {
|
|
|
3731
3950
|
const out = {};
|
|
3732
3951
|
if (typeof source.executablePath === "string") {
|
|
3733
3952
|
const path = source.executablePath.trim();
|
|
3734
|
-
if (path && (0,
|
|
3953
|
+
if (path && (0, import_node_path18.isAbsolute)(path)) out.executablePath = path;
|
|
3735
3954
|
}
|
|
3736
3955
|
if (typeof source.chromeEnabled === "boolean") {
|
|
3737
3956
|
out.chromeEnabled = source.chromeEnabled;
|
|
@@ -3744,13 +3963,13 @@ function normalizeCliExecutable(raw) {
|
|
|
3744
3963
|
const out = {};
|
|
3745
3964
|
if (typeof source.executablePath === "string") {
|
|
3746
3965
|
const path = source.executablePath.trim();
|
|
3747
|
-
if (path && (0,
|
|
3966
|
+
if (path && (0, import_node_path18.isAbsolute)(path)) out.executablePath = path;
|
|
3748
3967
|
}
|
|
3749
3968
|
return out;
|
|
3750
3969
|
}
|
|
3751
3970
|
function absoluteExecutablePath(value) {
|
|
3752
3971
|
const path = value.trim();
|
|
3753
|
-
if (!(0,
|
|
3972
|
+
if (!(0, import_node_path18.isAbsolute)(path)) {
|
|
3754
3973
|
throw new Error("Executable path must be absolute. Leave it empty to use the system CLI.");
|
|
3755
3974
|
}
|
|
3756
3975
|
return path;
|
|
@@ -3761,7 +3980,7 @@ function normalizeBrightsy(raw) {
|
|
|
3761
3980
|
const out = {};
|
|
3762
3981
|
if (typeof source.executablePath === "string") {
|
|
3763
3982
|
const path = source.executablePath.trim();
|
|
3764
|
-
if (path && (0,
|
|
3983
|
+
if (path && (0, import_node_path18.isAbsolute)(path)) out.executablePath = path;
|
|
3765
3984
|
}
|
|
3766
3985
|
if (typeof source.cloudConnectEnabled === "boolean") {
|
|
3767
3986
|
out.cloudConnectEnabled = source.cloudConnectEnabled;
|
|
@@ -4052,6 +4271,24 @@ function normalizeAdvanced(raw) {
|
|
|
4052
4271
|
if (typeof source.autoCleanupOrphans === "boolean") {
|
|
4053
4272
|
out.autoCleanupOrphans = source.autoCleanupOrphans;
|
|
4054
4273
|
}
|
|
4274
|
+
if (typeof source.autoCleanupHistory === "boolean") {
|
|
4275
|
+
out.autoCleanupHistory = source.autoCleanupHistory;
|
|
4276
|
+
}
|
|
4277
|
+
if (typeof source.historyMaxCount === "number" && Number.isFinite(source.historyMaxCount)) {
|
|
4278
|
+
out.historyMaxCount = clampHistoryMaxCount(source.historyMaxCount);
|
|
4279
|
+
}
|
|
4280
|
+
if (typeof source.historyMaxDays === "number" && Number.isFinite(source.historyMaxDays)) {
|
|
4281
|
+
out.historyMaxDays = clampHistoryMaxDays(source.historyMaxDays);
|
|
4282
|
+
}
|
|
4283
|
+
if (typeof source.historyCleanupIntervalHours === "number" && Number.isFinite(source.historyCleanupIntervalHours)) {
|
|
4284
|
+
out.historyCleanupIntervalHours = Math.max(
|
|
4285
|
+
1,
|
|
4286
|
+
Math.min(168, Math.floor(source.historyCleanupIntervalHours))
|
|
4287
|
+
);
|
|
4288
|
+
}
|
|
4289
|
+
if (typeof source.historyLastCleanupAt === "string" && source.historyLastCleanupAt.trim()) {
|
|
4290
|
+
out.historyLastCleanupAt = source.historyLastCleanupAt.trim();
|
|
4291
|
+
}
|
|
4055
4292
|
if (source.orchestrationQuotaOnLimit === "switch_agent" || source.orchestrationQuotaOnLimit === "wait_reset") {
|
|
4056
4293
|
out.orchestrationQuotaOnLimit = source.orchestrationQuotaOnLimit;
|
|
4057
4294
|
}
|
|
@@ -4944,6 +5181,24 @@ function updateAdvancedSettings(patch) {
|
|
|
4944
5181
|
if (typeof patch.autoCleanupOrphans === "boolean") {
|
|
4945
5182
|
advanced.autoCleanupOrphans = patch.autoCleanupOrphans;
|
|
4946
5183
|
}
|
|
5184
|
+
if (typeof patch.autoCleanupHistory === "boolean") {
|
|
5185
|
+
advanced.autoCleanupHistory = patch.autoCleanupHistory;
|
|
5186
|
+
}
|
|
5187
|
+
if (typeof patch.historyMaxCount === "number" && Number.isFinite(patch.historyMaxCount)) {
|
|
5188
|
+
advanced.historyMaxCount = clampHistoryMaxCount(patch.historyMaxCount);
|
|
5189
|
+
}
|
|
5190
|
+
if (typeof patch.historyMaxDays === "number" && Number.isFinite(patch.historyMaxDays)) {
|
|
5191
|
+
advanced.historyMaxDays = clampHistoryMaxDays(patch.historyMaxDays);
|
|
5192
|
+
}
|
|
5193
|
+
if (typeof patch.historyCleanupIntervalHours === "number" && Number.isFinite(patch.historyCleanupIntervalHours)) {
|
|
5194
|
+
advanced.historyCleanupIntervalHours = Math.max(
|
|
5195
|
+
1,
|
|
5196
|
+
Math.min(168, Math.floor(patch.historyCleanupIntervalHours))
|
|
5197
|
+
);
|
|
5198
|
+
}
|
|
5199
|
+
if (typeof patch.historyLastCleanupAt === "string") {
|
|
5200
|
+
advanced.historyLastCleanupAt = patch.historyLastCleanupAt;
|
|
5201
|
+
}
|
|
4947
5202
|
if (patch.orchestrationQuotaOnLimit === "switch_agent" || patch.orchestrationQuotaOnLimit === "wait_reset") {
|
|
4948
5203
|
advanced.orchestrationQuotaOnLimit = patch.orchestrationQuotaOnLimit;
|
|
4949
5204
|
}
|
|
@@ -4994,6 +5249,15 @@ function autoArchiveOnMergeEnabled(settings = loadAppSettings()) {
|
|
|
4994
5249
|
function autoCleanupOrphansEnabled(settings = loadAppSettings()) {
|
|
4995
5250
|
return Boolean(settings.advanced.autoCleanupOrphans);
|
|
4996
5251
|
}
|
|
5252
|
+
function autoCleanupHistoryEnabled(settings = loadAppSettings()) {
|
|
5253
|
+
return settings.advanced.autoCleanupHistory !== false;
|
|
5254
|
+
}
|
|
5255
|
+
function historyMaxCount(settings = loadAppSettings()) {
|
|
5256
|
+
return clampHistoryMaxCount(settings.advanced.historyMaxCount ?? HISTORY_MAX_COUNT_DEFAULT);
|
|
5257
|
+
}
|
|
5258
|
+
function historyMaxDays(settings = loadAppSettings()) {
|
|
5259
|
+
return clampHistoryMaxDays(settings.advanced.historyMaxDays ?? HISTORY_MAX_DAYS_DEFAULT);
|
|
5260
|
+
}
|
|
4997
5261
|
function usageOnLimit(settings = loadAppSettings()) {
|
|
4998
5262
|
return resolveUsageOnLimit(settings.advanced);
|
|
4999
5263
|
}
|
|
@@ -5098,14 +5362,14 @@ function childEnvWithAppSettings(extra) {
|
|
|
5098
5362
|
function harnessEnvKey(harness) {
|
|
5099
5363
|
return HARNESS_ENV_KEYS[harness];
|
|
5100
5364
|
}
|
|
5101
|
-
var import_node_crypto3, import_node_fs15, import_node_os5,
|
|
5365
|
+
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
5366
|
var init_app_settings = __esm({
|
|
5103
5367
|
"src/store/app-settings.ts"() {
|
|
5104
5368
|
"use strict";
|
|
5105
5369
|
import_node_crypto3 = require("crypto");
|
|
5106
5370
|
import_node_fs15 = require("fs");
|
|
5107
5371
|
import_node_os5 = require("os");
|
|
5108
|
-
|
|
5372
|
+
import_node_path18 = require("path");
|
|
5109
5373
|
init_orchestrator_capable();
|
|
5110
5374
|
init_thinking_effort();
|
|
5111
5375
|
init_nested_electron_env();
|
|
@@ -5114,6 +5378,7 @@ var init_app_settings = __esm({
|
|
|
5114
5378
|
init_private_file();
|
|
5115
5379
|
init_secret_vault();
|
|
5116
5380
|
init_branch_prefix();
|
|
5381
|
+
init_history_retention();
|
|
5117
5382
|
init_usage_on_limit();
|
|
5118
5383
|
init_usage_on_limit();
|
|
5119
5384
|
init_issue_source_labels();
|
|
@@ -5274,7 +5539,7 @@ async function warmGithubAgentAuth(opts) {
|
|
|
5274
5539
|
}
|
|
5275
5540
|
function normalizeWritableRoot(raw) {
|
|
5276
5541
|
const trimmed = raw.trim().replace(/\/+$/, "");
|
|
5277
|
-
return trimmed && (0,
|
|
5542
|
+
return trimmed && (0, import_node_path19.isAbsolute)(trimmed) ? trimmed : null;
|
|
5278
5543
|
}
|
|
5279
5544
|
async function resolveCodexGitWritableRoots(cwd) {
|
|
5280
5545
|
const roots = /* @__PURE__ */ new Set();
|
|
@@ -5352,11 +5617,11 @@ function formatGitAuthModeDirective(mode) {
|
|
|
5352
5617
|
].join("\n");
|
|
5353
5618
|
}
|
|
5354
5619
|
}
|
|
5355
|
-
var
|
|
5620
|
+
var import_node_path19, HTTPS_REWRITE, TOKEN_TTL_MS, tokenMemo, GITHUB_CHILD_TOKEN_KEYS;
|
|
5356
5621
|
var init_git_auth_mode = __esm({
|
|
5357
5622
|
"src/git/git-auth-mode.ts"() {
|
|
5358
5623
|
"use strict";
|
|
5359
|
-
|
|
5624
|
+
import_node_path19 = require("path");
|
|
5360
5625
|
init_app_settings();
|
|
5361
5626
|
init_github_agent_auth();
|
|
5362
5627
|
init_run();
|
|
@@ -7041,7 +7306,7 @@ async function refreshOriginAndMaybeFastForwardMain(repoPath, sourceRef) {
|
|
|
7041
7306
|
}
|
|
7042
7307
|
async function createThreadWorktree(opts) {
|
|
7043
7308
|
let branchName = `thread/${opts.slug}`;
|
|
7044
|
-
const worktreePath = (0,
|
|
7309
|
+
const worktreePath = (0, import_node_path20.join)(worktreesRoot(opts.repoPath), opts.slug);
|
|
7045
7310
|
if ((0, import_node_fs16.existsSync)(worktreePath)) {
|
|
7046
7311
|
throw new Error(`Worktree already exists at ${worktreePath}`);
|
|
7047
7312
|
}
|
|
@@ -7083,7 +7348,7 @@ ${add.stdout}`;
|
|
|
7083
7348
|
async function createExistingBranchWorktree(opts) {
|
|
7084
7349
|
const branchName = opts.branchName.trim();
|
|
7085
7350
|
if (!branchName) throw new Error("branch name required");
|
|
7086
|
-
const worktreePath = (0,
|
|
7351
|
+
const worktreePath = (0, import_node_path20.join)(worktreesRoot(opts.repoPath), opts.slug);
|
|
7087
7352
|
if ((0, import_node_fs16.existsSync)(worktreePath)) {
|
|
7088
7353
|
throw new Error(`Worktree already exists at ${worktreePath}`);
|
|
7089
7354
|
}
|
|
@@ -7365,7 +7630,7 @@ async function createOrUpdatePr(worktreePath, opts) {
|
|
|
7365
7630
|
const headRef = ghHeadRef(slug, opts.head);
|
|
7366
7631
|
const branchOnly = opts.head.trim().replace(/^refs\/heads\//, "");
|
|
7367
7632
|
const bodyText = clampGithubPrBody(opts.body ?? opts.title);
|
|
7368
|
-
const bodyFile = (0,
|
|
7633
|
+
const bodyFile = (0, import_node_path20.join)(
|
|
7369
7634
|
(0, import_node_os6.tmpdir)(),
|
|
7370
7635
|
`sideboard-pr-body-${process.pid}-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}.md`
|
|
7371
7636
|
);
|
|
@@ -7465,7 +7730,7 @@ function sameRepoPath(a, b) {
|
|
|
7465
7730
|
return normalizeWorktreePath(a) === normalizeWorktreePath(b);
|
|
7466
7731
|
}
|
|
7467
7732
|
function listLocalThreadBranchSlugs(repoPath) {
|
|
7468
|
-
const refsDir = (0,
|
|
7733
|
+
const refsDir = (0, import_node_path20.join)(repoPath, ".git", "refs", "heads", "thread");
|
|
7469
7734
|
if (!(0, import_node_fs16.existsSync)(refsDir)) return [];
|
|
7470
7735
|
try {
|
|
7471
7736
|
return (0, import_node_fs16.readdirSync)(refsDir).filter((name) => !name.startsWith(".")).map((name) => normalizeTakenSlug(name));
|
|
@@ -7502,20 +7767,20 @@ function allocateTeamSlug(repoPath) {
|
|
|
7502
7767
|
const taken = collectTakenTeamSlugs(repoPath);
|
|
7503
7768
|
for (let attempt = 0; attempt < 32; attempt++) {
|
|
7504
7769
|
const team = allocateTeamName(taken);
|
|
7505
|
-
const path = (0,
|
|
7770
|
+
const path = (0, import_node_path20.join)(worktreesRoot(repoPath), team.slug);
|
|
7506
7771
|
if (!(0, import_node_fs16.existsSync)(path)) return team;
|
|
7507
7772
|
taken.add(team.slug);
|
|
7508
7773
|
}
|
|
7509
7774
|
throw new Error("No available soccer team worktree directories left");
|
|
7510
7775
|
}
|
|
7511
|
-
var import_node_crypto4, import_node_fs16, import_node_os6,
|
|
7776
|
+
var import_node_crypto4, import_node_fs16, import_node_os6, import_node_path20, PR_DETAILS_JSON_FIELDS;
|
|
7512
7777
|
var init_worktree = __esm({
|
|
7513
7778
|
"src/git/worktree.ts"() {
|
|
7514
7779
|
"use strict";
|
|
7515
7780
|
import_node_crypto4 = require("crypto");
|
|
7516
7781
|
import_node_fs16 = require("fs");
|
|
7517
7782
|
import_node_os6 = require("os");
|
|
7518
|
-
|
|
7783
|
+
import_node_path20 = require("path");
|
|
7519
7784
|
init_paths();
|
|
7520
7785
|
init_thread_store();
|
|
7521
7786
|
init_teams();
|
|
@@ -7587,7 +7852,7 @@ var init_cloud_connect_constants = __esm({
|
|
|
7587
7852
|
|
|
7588
7853
|
// src/composer/stage-files.ts
|
|
7589
7854
|
function fileExtension(filePath) {
|
|
7590
|
-
const base = (0,
|
|
7855
|
+
const base = (0, import_node_path21.basename)(filePath).toLowerCase();
|
|
7591
7856
|
return base.includes(".") ? base.split(".").pop() || "" : "";
|
|
7592
7857
|
}
|
|
7593
7858
|
function isImageFilePath(filePath) {
|
|
@@ -7597,9 +7862,9 @@ function imageMimeType(filePath) {
|
|
|
7597
7862
|
return IMAGE_MIME_BY_EXT[fileExtension(filePath)] || "image/png";
|
|
7598
7863
|
}
|
|
7599
7864
|
function ensureAttachmentsDir(worktreePath) {
|
|
7600
|
-
const dir = (0,
|
|
7865
|
+
const dir = (0, import_node_path21.join)(worktreePath, ATTACHMENTS_DIR);
|
|
7601
7866
|
(0, import_node_fs17.mkdirSync)(dir, { recursive: true });
|
|
7602
|
-
const gi = (0,
|
|
7867
|
+
const gi = (0, import_node_path21.join)(dir, ".gitignore");
|
|
7603
7868
|
if (!(0, import_node_fs17.existsSync)(gi)) {
|
|
7604
7869
|
(0, import_node_fs17.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
|
|
7605
7870
|
}
|
|
@@ -7607,12 +7872,12 @@ function ensureAttachmentsDir(worktreePath) {
|
|
|
7607
7872
|
}
|
|
7608
7873
|
function uniqueAttachmentName(dir, originalName) {
|
|
7609
7874
|
const safe = originalName.replace(/[/\\]/g, "_") || "file";
|
|
7610
|
-
if (!(0, import_node_fs17.existsSync)((0,
|
|
7611
|
-
const ext = (0,
|
|
7875
|
+
if (!(0, import_node_fs17.existsSync)((0, import_node_path21.join)(dir, safe))) return safe;
|
|
7876
|
+
const ext = (0, import_node_path21.extname)(safe);
|
|
7612
7877
|
const stem = ext ? safe.slice(0, -ext.length) : safe;
|
|
7613
7878
|
for (let i = 1; i < 1e4; i++) {
|
|
7614
7879
|
const candidate = `${stem}-${i}${ext}`;
|
|
7615
|
-
if (!(0, import_node_fs17.existsSync)((0,
|
|
7880
|
+
if (!(0, import_node_fs17.existsSync)((0, import_node_path21.join)(dir, candidate))) return candidate;
|
|
7616
7881
|
}
|
|
7617
7882
|
return `${stem}-${(0, import_node_crypto5.randomUUID)()}${ext}`;
|
|
7618
7883
|
}
|
|
@@ -7668,12 +7933,12 @@ function stageAbsolutePathsAsAttachments(worktreePath, absolutePaths) {
|
|
|
7668
7933
|
const dir = ensureAttachmentsDir(worktreePath);
|
|
7669
7934
|
const out = [];
|
|
7670
7935
|
for (const abs of absolutePaths) {
|
|
7671
|
-
const originalName = (0,
|
|
7936
|
+
const originalName = (0, import_node_path21.basename)(abs);
|
|
7672
7937
|
try {
|
|
7673
7938
|
const st = (0, import_node_fs17.statSync)(abs);
|
|
7674
7939
|
if (!st.isFile()) continue;
|
|
7675
7940
|
const name = uniqueAttachmentName(dir, originalName);
|
|
7676
|
-
const destAbs = (0,
|
|
7941
|
+
const destAbs = (0, import_node_path21.join)(dir, name);
|
|
7677
7942
|
(0, import_node_fs17.copyFileSync)(abs, destAbs);
|
|
7678
7943
|
const rel = `${ATTACHMENTS_DIR}/${name}`;
|
|
7679
7944
|
const buf = (0, import_node_fs17.readFileSync)(destAbs);
|
|
@@ -7698,7 +7963,7 @@ function stageBuffersAsAttachments(worktreePath, buffers2) {
|
|
|
7698
7963
|
try {
|
|
7699
7964
|
const buf = Buffer.from(item.dataBase64, "base64");
|
|
7700
7965
|
const name = uniqueAttachmentName(dir, originalName);
|
|
7701
|
-
const destAbs = (0,
|
|
7966
|
+
const destAbs = (0, import_node_path21.join)(dir, name);
|
|
7702
7967
|
(0, import_node_fs17.writeFileSync)(destAbs, buf);
|
|
7703
7968
|
const rel = `${ATTACHMENTS_DIR}/${name}`;
|
|
7704
7969
|
out.push(attachmentFromBuffer(name, buf, { path: rel }));
|
|
@@ -7760,15 +8025,15 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
|
|
|
7760
8025
|
if (!rel || rel.includes("..") || rel.startsWith("/")) {
|
|
7761
8026
|
out.push({
|
|
7762
8027
|
id: (0, import_node_crypto5.randomUUID)(),
|
|
7763
|
-
name: (0,
|
|
8028
|
+
name: (0, import_node_path21.basename)(rel) || "file",
|
|
7764
8029
|
kind: "file",
|
|
7765
8030
|
content: `(invalid path: ${rel})`
|
|
7766
8031
|
});
|
|
7767
8032
|
continue;
|
|
7768
8033
|
}
|
|
7769
|
-
const name = (0,
|
|
8034
|
+
const name = (0, import_node_path21.basename)(rel);
|
|
7770
8035
|
try {
|
|
7771
|
-
const abs = (0,
|
|
8036
|
+
const abs = (0, import_node_path21.join)(worktreePath, rel);
|
|
7772
8037
|
const st = (0, import_node_fs17.statSync)(abs);
|
|
7773
8038
|
if (!st.isFile()) continue;
|
|
7774
8039
|
const buf = (0, import_node_fs17.readFileSync)(abs);
|
|
@@ -7784,12 +8049,12 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
|
|
|
7784
8049
|
}
|
|
7785
8050
|
return out;
|
|
7786
8051
|
}
|
|
7787
|
-
var import_node_fs17,
|
|
8052
|
+
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
8053
|
var init_stage_files = __esm({
|
|
7789
8054
|
"src/composer/stage-files.ts"() {
|
|
7790
8055
|
"use strict";
|
|
7791
8056
|
import_node_fs17 = require("fs");
|
|
7792
|
-
|
|
8057
|
+
import_node_path21 = require("path");
|
|
7793
8058
|
import_node_crypto5 = require("crypto");
|
|
7794
8059
|
init_workspace_scratch();
|
|
7795
8060
|
IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
@@ -7829,10 +8094,10 @@ __export(workspaces_exports, {
|
|
|
7829
8094
|
syncWorkspacesFromThreads: () => syncWorkspacesFromThreads
|
|
7830
8095
|
});
|
|
7831
8096
|
function workspacesFile() {
|
|
7832
|
-
return (0,
|
|
8097
|
+
return (0, import_node_path22.join)(appDataDir(), "workspaces.json");
|
|
7833
8098
|
}
|
|
7834
8099
|
function removedWorkspacesFile() {
|
|
7835
|
-
return (0,
|
|
8100
|
+
return (0, import_node_path22.join)(appDataDir(), "removed-workspaces.json");
|
|
7836
8101
|
}
|
|
7837
8102
|
function readAll() {
|
|
7838
8103
|
const path = workspacesFile();
|
|
@@ -7891,7 +8156,7 @@ async function addWorkspace(repoPath) {
|
|
|
7891
8156
|
if (existing) return existing;
|
|
7892
8157
|
const next = {
|
|
7893
8158
|
path: root,
|
|
7894
|
-
name: (0,
|
|
8159
|
+
name: (0, import_node_path22.basename)(root),
|
|
7895
8160
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
7896
8161
|
};
|
|
7897
8162
|
writeAll([...current, next]);
|
|
@@ -7916,7 +8181,7 @@ function syncWorkspacesFromThreads(repoPaths) {
|
|
|
7916
8181
|
if (!(0, import_node_fs18.existsSync)(path)) continue;
|
|
7917
8182
|
const ws = {
|
|
7918
8183
|
path,
|
|
7919
|
-
name: (0,
|
|
8184
|
+
name: (0, import_node_path22.basename)(path),
|
|
7920
8185
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
7921
8186
|
};
|
|
7922
8187
|
byPath.set(path, ws);
|
|
@@ -7926,12 +8191,12 @@ function syncWorkspacesFromThreads(repoPaths) {
|
|
|
7926
8191
|
if (dirty) writeAll(next);
|
|
7927
8192
|
return next.sort((a, b) => a.name.localeCompare(b.name));
|
|
7928
8193
|
}
|
|
7929
|
-
var import_node_fs18,
|
|
8194
|
+
var import_node_fs18, import_node_path22;
|
|
7930
8195
|
var init_workspaces2 = __esm({
|
|
7931
8196
|
"src/store/workspaces.ts"() {
|
|
7932
8197
|
"use strict";
|
|
7933
8198
|
import_node_fs18 = require("fs");
|
|
7934
|
-
|
|
8199
|
+
import_node_path22 = require("path");
|
|
7935
8200
|
init_paths();
|
|
7936
8201
|
init_global_workspace();
|
|
7937
8202
|
init_worktree();
|
|
@@ -8050,7 +8315,7 @@ function ensureGlobalCoordinatorCwd(opts) {
|
|
|
8050
8315
|
let orchId = opts?.orchestratorThreadId?.trim() || "";
|
|
8051
8316
|
if (!orchId) {
|
|
8052
8317
|
try {
|
|
8053
|
-
const existing = (0, import_node_fs19.readFileSync)((0,
|
|
8318
|
+
const existing = (0, import_node_fs19.readFileSync)((0, import_node_path23.join)(dir, "AGENTS.md"), "utf8");
|
|
8054
8319
|
const m = existing.match(
|
|
8055
8320
|
/YOUR orchestration thread id is `([0-9a-f-]{36})`/i
|
|
8056
8321
|
);
|
|
@@ -8095,9 +8360,9 @@ function ensureGlobalCoordinatorCwd(opts) {
|
|
|
8095
8360
|
"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
8361
|
].join("\n");
|
|
8097
8362
|
try {
|
|
8098
|
-
(0, import_node_fs19.writeFileSync)((0,
|
|
8363
|
+
(0, import_node_fs19.writeFileSync)((0, import_node_path23.join)(dir, "CLAUDE.md"), `${body}
|
|
8099
8364
|
`, "utf8");
|
|
8100
|
-
(0, import_node_fs19.writeFileSync)((0,
|
|
8365
|
+
(0, import_node_fs19.writeFileSync)((0, import_node_path23.join)(dir, "AGENTS.md"), `${body}
|
|
8101
8366
|
`, "utf8");
|
|
8102
8367
|
} catch {
|
|
8103
8368
|
}
|
|
@@ -8129,12 +8394,12 @@ function coordinatorSystemPrompt(opts) {
|
|
|
8129
8394
|
formatWorkspaceInventory(opts.workspaces)
|
|
8130
8395
|
].join("\n");
|
|
8131
8396
|
}
|
|
8132
|
-
var import_node_fs19,
|
|
8397
|
+
var import_node_fs19, import_node_path23, COORDINATOR_TOOL_PLAYBOOK, SLACK_REPLY_FORMATTING;
|
|
8133
8398
|
var init_coordinator_prompt = __esm({
|
|
8134
8399
|
"src/orchestrator/coordinator-prompt.ts"() {
|
|
8135
8400
|
"use strict";
|
|
8136
8401
|
import_node_fs19 = require("fs");
|
|
8137
|
-
|
|
8402
|
+
import_node_path23 = require("path");
|
|
8138
8403
|
init_worktree();
|
|
8139
8404
|
init_app_settings();
|
|
8140
8405
|
init_paths();
|
|
@@ -8450,7 +8715,7 @@ var init_global_workspace = __esm({
|
|
|
8450
8715
|
function brightsyConfigPath() {
|
|
8451
8716
|
const override = process.env.BRIGHTSY_CONFIG?.trim();
|
|
8452
8717
|
if (override) return override;
|
|
8453
|
-
return (0,
|
|
8718
|
+
return (0, import_node_path24.join)((0, import_node_os7.homedir)(), ".brightsy", "config.json");
|
|
8454
8719
|
}
|
|
8455
8720
|
function loadBrightsyConfig() {
|
|
8456
8721
|
const path = brightsyConfigPath();
|
|
@@ -8469,13 +8734,13 @@ function saveBrightsyConfig(cfg) {
|
|
|
8469
8734
|
mode: 384
|
|
8470
8735
|
});
|
|
8471
8736
|
}
|
|
8472
|
-
var import_node_fs20, import_node_os7,
|
|
8737
|
+
var import_node_fs20, import_node_os7, import_node_path24;
|
|
8473
8738
|
var init_config = __esm({
|
|
8474
8739
|
"src/brightsy/config.ts"() {
|
|
8475
8740
|
"use strict";
|
|
8476
8741
|
import_node_fs20 = require("fs");
|
|
8477
8742
|
import_node_os7 = require("os");
|
|
8478
|
-
|
|
8743
|
+
import_node_path24 = require("path");
|
|
8479
8744
|
}
|
|
8480
8745
|
});
|
|
8481
8746
|
|
|
@@ -8601,7 +8866,7 @@ var init_oauth = __esm({
|
|
|
8601
8866
|
|
|
8602
8867
|
// src/brightsy/connected-teams.ts
|
|
8603
8868
|
function storePath4() {
|
|
8604
|
-
return (0,
|
|
8869
|
+
return (0, import_node_path25.join)(appDataDir(), "brightsy-teams.json");
|
|
8605
8870
|
}
|
|
8606
8871
|
function readStore4() {
|
|
8607
8872
|
const path = storePath4();
|
|
@@ -8722,12 +8987,12 @@ function brightsyMcpServerName(slug) {
|
|
|
8722
8987
|
const cleaned = slug.replace(/[^A-Za-z0-9_-]/g, "_").replace(/^_+|_+$/g, "");
|
|
8723
8988
|
return `brightsy_${cleaned || "team"}`;
|
|
8724
8989
|
}
|
|
8725
|
-
var import_node_fs21,
|
|
8990
|
+
var import_node_fs21, import_node_path25;
|
|
8726
8991
|
var init_connected_teams = __esm({
|
|
8727
8992
|
"src/brightsy/connected-teams.ts"() {
|
|
8728
8993
|
"use strict";
|
|
8729
8994
|
import_node_fs21 = require("fs");
|
|
8730
|
-
|
|
8995
|
+
import_node_path25 = require("path");
|
|
8731
8996
|
init_paths();
|
|
8732
8997
|
init_accounts();
|
|
8733
8998
|
init_config();
|
|
@@ -8735,90 +9000,6 @@ var init_connected_teams = __esm({
|
|
|
8735
9000
|
}
|
|
8736
9001
|
});
|
|
8737
9002
|
|
|
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
9003
|
// src/agents/brightsy-targets.ts
|
|
8823
9004
|
function encodeBrightsyTarget(type, id, accountId) {
|
|
8824
9005
|
if (accountId) return `team:${accountId}:${type}:${id}`;
|
|
@@ -9780,43 +9961,43 @@ function electronResourcesPath() {
|
|
|
9780
9961
|
function packagedCursorRuntimeDir() {
|
|
9781
9962
|
const resources = electronResourcesPath();
|
|
9782
9963
|
if (!resources) return null;
|
|
9783
|
-
const dir = (0,
|
|
9784
|
-
if (!(0, import_node_fs23.existsSync)((0,
|
|
9964
|
+
const dir = (0, import_node_path26.join)(resources, "cursor-runtime");
|
|
9965
|
+
if (!(0, import_node_fs23.existsSync)((0, import_node_path26.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
|
|
9785
9966
|
return dir;
|
|
9786
9967
|
}
|
|
9787
9968
|
function packagedCursorRunnerPath() {
|
|
9788
9969
|
const dir = packagedCursorRuntimeDir();
|
|
9789
|
-
return dir ? (0,
|
|
9970
|
+
return dir ? (0, import_node_path26.join)(dir, "core-dist", "agents", "cursor-runner.js") : null;
|
|
9790
9971
|
}
|
|
9791
9972
|
function packagedMcpDir() {
|
|
9792
9973
|
const resources = electronResourcesPath();
|
|
9793
9974
|
if (!resources) return null;
|
|
9794
|
-
const dir = (0,
|
|
9795
|
-
if (!(0, import_node_fs23.existsSync)((0,
|
|
9975
|
+
const dir = (0, import_node_path26.join)(resources, "sideboard-mcp");
|
|
9976
|
+
if (!(0, import_node_fs23.existsSync)((0, import_node_path26.join)(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
|
|
9796
9977
|
return dir;
|
|
9797
9978
|
}
|
|
9798
9979
|
function packagedMcpStdioPath() {
|
|
9799
9980
|
const dir = packagedMcpDir();
|
|
9800
|
-
return dir ? (0,
|
|
9981
|
+
return dir ? (0, import_node_path26.join)(dir, "core-dist", "mcp", "run-stdio.js") : null;
|
|
9801
9982
|
}
|
|
9802
9983
|
function packagedBundledNodePath() {
|
|
9803
9984
|
const resources = electronResourcesPath();
|
|
9804
9985
|
if (!resources) return null;
|
|
9805
|
-
const bin = (0,
|
|
9986
|
+
const bin = (0, import_node_path26.join)(resources, "node", "bin", "node");
|
|
9806
9987
|
if (!(0, import_node_fs23.existsSync)(bin)) return null;
|
|
9807
9988
|
return bin;
|
|
9808
9989
|
}
|
|
9809
9990
|
function packagedCursorRipgrepCandidate(platformPkg, binName) {
|
|
9810
9991
|
const dir = packagedCursorRuntimeDir();
|
|
9811
9992
|
if (!dir) return null;
|
|
9812
|
-
return (0,
|
|
9993
|
+
return (0, import_node_path26.join)(dir, "node_modules", platformPkg, "bin", binName);
|
|
9813
9994
|
}
|
|
9814
|
-
var import_node_fs23,
|
|
9995
|
+
var import_node_fs23, import_node_path26;
|
|
9815
9996
|
var init_packaged_runtime = __esm({
|
|
9816
9997
|
"src/agents/packaged-runtime.ts"() {
|
|
9817
9998
|
"use strict";
|
|
9818
9999
|
import_node_fs23 = require("fs");
|
|
9819
|
-
|
|
10000
|
+
import_node_path26 = require("path");
|
|
9820
10001
|
}
|
|
9821
10002
|
});
|
|
9822
10003
|
|
|
@@ -9900,28 +10081,28 @@ function versionDirNodeBins(root, toBin) {
|
|
|
9900
10081
|
}
|
|
9901
10082
|
function defaultNodeBinCandidates(home = (0, import_node_os8.homedir)()) {
|
|
9902
10083
|
const kegs = ["/opt/homebrew", "/usr/local"].flatMap(
|
|
9903
|
-
(prefix) => PREFERRED_LTS_MAJORS.map((major) => (0,
|
|
10084
|
+
(prefix) => PREFERRED_LTS_MAJORS.map((major) => (0, import_node_path27.join)(prefix, "opt", `node@${major}`, "bin", "node"))
|
|
9904
10085
|
);
|
|
9905
10086
|
return [
|
|
9906
10087
|
...kegs,
|
|
9907
10088
|
"/opt/homebrew/bin/node",
|
|
9908
10089
|
"/usr/local/bin/node",
|
|
9909
|
-
(0,
|
|
9910
|
-
(0,
|
|
9911
|
-
(0,
|
|
9912
|
-
(0,
|
|
9913
|
-
(0,
|
|
10090
|
+
(0, import_node_path27.join)(home, ".local/share/fnm/aliases/default/bin/node"),
|
|
10091
|
+
(0, import_node_path27.join)(home, ".nvm/current/bin/node"),
|
|
10092
|
+
(0, import_node_path27.join)(home, ".volta/bin/node"),
|
|
10093
|
+
(0, import_node_path27.join)(home, ".asdf/shims/node"),
|
|
10094
|
+
(0, import_node_path27.join)(home, ".local/share/mise/shims/node"),
|
|
9914
10095
|
...versionDirNodeBins(
|
|
9915
|
-
(0,
|
|
9916
|
-
(name) => (0,
|
|
10096
|
+
(0, import_node_path27.join)(home, ".nvm", "versions", "node"),
|
|
10097
|
+
(name) => (0, import_node_path27.join)(home, ".nvm", "versions", "node", name, "bin", "node")
|
|
9917
10098
|
),
|
|
9918
10099
|
...versionDirNodeBins(
|
|
9919
|
-
(0,
|
|
9920
|
-
(name) => (0,
|
|
10100
|
+
(0, import_node_path27.join)(home, ".local/share/fnm", "node-versions"),
|
|
10101
|
+
(name) => (0, import_node_path27.join)(home, ".local/share/fnm", "node-versions", name, "installation", "bin", "node")
|
|
9921
10102
|
),
|
|
9922
10103
|
...versionDirNodeBins(
|
|
9923
|
-
(0,
|
|
9924
|
-
(name) => (0,
|
|
10104
|
+
(0, import_node_path27.join)(home, ".volta", "tools", "image", "node"),
|
|
10105
|
+
(name) => (0, import_node_path27.join)(home, ".volta", "tools", "image", "node", name, "bin", "node")
|
|
9925
10106
|
)
|
|
9926
10107
|
];
|
|
9927
10108
|
}
|
|
@@ -10013,13 +10194,13 @@ async function resolveNodeLaunch(scriptPath) {
|
|
|
10013
10194
|
env: { ELECTRON_RUN_AS_NODE: "1" }
|
|
10014
10195
|
};
|
|
10015
10196
|
}
|
|
10016
|
-
var import_node_fs24, import_node_os8,
|
|
10197
|
+
var import_node_fs24, import_node_os8, import_node_path27, AGENT_RUNNER_MAX_OLD_SPACE_MB, MAX_OLD_SPACE_FLAG, PREFERRED_LTS_MAJORS;
|
|
10017
10198
|
var init_node_launch = __esm({
|
|
10018
10199
|
"src/agents/node-launch.ts"() {
|
|
10019
10200
|
"use strict";
|
|
10020
10201
|
import_node_fs24 = require("fs");
|
|
10021
10202
|
import_node_os8 = require("os");
|
|
10022
|
-
|
|
10203
|
+
import_node_path27 = require("path");
|
|
10023
10204
|
init_nested_electron_env();
|
|
10024
10205
|
init_system_ca();
|
|
10025
10206
|
init_run();
|
|
@@ -10121,13 +10302,13 @@ function corePackageDir() {
|
|
|
10121
10302
|
try {
|
|
10122
10303
|
const url = import_meta.url;
|
|
10123
10304
|
if (typeof url === "string" && url.length > 0) {
|
|
10124
|
-
return (0,
|
|
10305
|
+
return (0, import_node_path28.dirname)((0, import_node_url.fileURLToPath)(url));
|
|
10125
10306
|
}
|
|
10126
10307
|
} catch {
|
|
10127
10308
|
}
|
|
10128
10309
|
try {
|
|
10129
|
-
const req = (0, import_node_module.createRequire)((0,
|
|
10130
|
-
return (0,
|
|
10310
|
+
const req = (0, import_node_module.createRequire)((0, import_node_path28.join)(process.cwd(), "package.json"));
|
|
10311
|
+
return (0, import_node_path28.dirname)(req.resolve("@sideboard-ai/core"));
|
|
10131
10312
|
} catch {
|
|
10132
10313
|
return process.cwd();
|
|
10133
10314
|
}
|
|
@@ -10140,18 +10321,18 @@ function findSideboardMcpJsEntry() {
|
|
|
10140
10321
|
let dir = corePackageDir();
|
|
10141
10322
|
for (let i = 0; i < 10; i++) {
|
|
10142
10323
|
const candidates = [
|
|
10143
|
-
(0,
|
|
10144
|
-
(0,
|
|
10145
|
-
(0,
|
|
10146
|
-
(0,
|
|
10147
|
-
(0,
|
|
10148
|
-
(0,
|
|
10149
|
-
(0,
|
|
10324
|
+
(0, import_node_path28.join)(dir, "mcp/run-stdio.js"),
|
|
10325
|
+
(0, import_node_path28.join)(dir, "mcp/run-stdio.cjs"),
|
|
10326
|
+
(0, import_node_path28.join)(dir, "dist/mcp/run-stdio.js"),
|
|
10327
|
+
(0, import_node_path28.join)(dir, "dist/mcp/run-stdio.cjs"),
|
|
10328
|
+
(0, import_node_path28.join)(dir, "packages/core/dist/mcp/run-stdio.js"),
|
|
10329
|
+
(0, import_node_path28.join)(dir, "packages/cli/dist/index.js"),
|
|
10330
|
+
(0, import_node_path28.join)(dir, "cli/dist/index.js")
|
|
10150
10331
|
];
|
|
10151
10332
|
for (const p of candidates) {
|
|
10152
10333
|
if ((0, import_node_fs25.existsSync)(p) && !isAsarPath(p)) return p;
|
|
10153
10334
|
}
|
|
10154
|
-
const parent = (0,
|
|
10335
|
+
const parent = (0, import_node_path28.dirname)(dir);
|
|
10155
10336
|
if (parent === dir) break;
|
|
10156
10337
|
dir = parent;
|
|
10157
10338
|
}
|
|
@@ -10298,19 +10479,19 @@ function writeMcpServersConfig(servers) {
|
|
|
10298
10479
|
...env ? { env } : {}
|
|
10299
10480
|
};
|
|
10300
10481
|
}
|
|
10301
|
-
const dir = (0, import_node_fs25.mkdtempSync)((0,
|
|
10302
|
-
const cfgPath = (0,
|
|
10482
|
+
const dir = (0, import_node_fs25.mkdtempSync)((0, import_node_path28.join)((0, import_node_os9.tmpdir)(), "sideboard-mcp-"));
|
|
10483
|
+
const cfgPath = (0, import_node_path28.join)(dir, "mcp.json");
|
|
10303
10484
|
(0, import_node_fs25.writeFileSync)(cfgPath, JSON.stringify({ mcpServers }, null, 2));
|
|
10304
10485
|
return cfgPath;
|
|
10305
10486
|
}
|
|
10306
|
-
var import_node_fs25, import_node_module, import_node_os9,
|
|
10487
|
+
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
10488
|
var init_injected_mcp = __esm({
|
|
10308
10489
|
"src/agents/injected-mcp.ts"() {
|
|
10309
10490
|
"use strict";
|
|
10310
10491
|
import_node_fs25 = require("fs");
|
|
10311
10492
|
import_node_module = require("module");
|
|
10312
10493
|
import_node_os9 = require("os");
|
|
10313
|
-
|
|
10494
|
+
import_node_path28 = require("path");
|
|
10314
10495
|
import_node_url = require("url");
|
|
10315
10496
|
init_run();
|
|
10316
10497
|
init_config();
|
|
@@ -10547,13 +10728,31 @@ function mcpStatusThinkingFromClaudeInit(obj) {
|
|
|
10547
10728
|
}
|
|
10548
10729
|
}
|
|
10549
10730
|
}
|
|
10550
|
-
const notable = servers.filter(
|
|
10731
|
+
const notable = servers.filter(isNotableMcpInitStatus);
|
|
10551
10732
|
if (notable.length === 0) return null;
|
|
10552
10733
|
return `MCP: ${notable.map((s) => `${s.name} ${s.status}`).join(", ")}`;
|
|
10553
10734
|
}
|
|
10554
10735
|
function isCleanMcpConnect(status) {
|
|
10555
10736
|
return /^(connected|ok|ready|success)$/i.test(status.trim());
|
|
10556
10737
|
}
|
|
10738
|
+
function isMcpAuthStatus(status) {
|
|
10739
|
+
return /needs[_-]?auth|needs authentication|unauthorized|not authenticated|authrequired/i.test(
|
|
10740
|
+
status
|
|
10741
|
+
);
|
|
10742
|
+
}
|
|
10743
|
+
function isSideboardMcpName(name) {
|
|
10744
|
+
return /^sideboard$/i.test(name.trim()) || /^mcp__sideboard$/i.test(name.trim());
|
|
10745
|
+
}
|
|
10746
|
+
function isVendorClaudeAiMcpName(name) {
|
|
10747
|
+
return /^claude\.ai\b/i.test(name.trim()) || /^mcp__claude_ai_/i.test(name.trim());
|
|
10748
|
+
}
|
|
10749
|
+
function isNotableMcpInitStatus(server) {
|
|
10750
|
+
if (isCleanMcpConnect(server.status)) return false;
|
|
10751
|
+
if (isSideboardMcpName(server.name)) return true;
|
|
10752
|
+
if (isVendorClaudeAiMcpName(server.name)) return false;
|
|
10753
|
+
if (isMcpAuthStatus(server.status)) return false;
|
|
10754
|
+
return true;
|
|
10755
|
+
}
|
|
10557
10756
|
function eventsFromClaudeSystem(obj) {
|
|
10558
10757
|
const subtype = claudeString(obj, "subtype") ?? "";
|
|
10559
10758
|
const parentId = claudeParentToolUseId(obj);
|
|
@@ -10996,13 +11195,13 @@ var init_claude = __esm({
|
|
|
10996
11195
|
});
|
|
10997
11196
|
|
|
10998
11197
|
// src/agents/user-mcp-config.ts
|
|
10999
|
-
var import_node_fs27, import_node_os10,
|
|
11198
|
+
var import_node_fs27, import_node_os10, import_node_path29;
|
|
11000
11199
|
var init_user_mcp_config = __esm({
|
|
11001
11200
|
"src/agents/user-mcp-config.ts"() {
|
|
11002
11201
|
"use strict";
|
|
11003
11202
|
import_node_fs27 = require("fs");
|
|
11004
11203
|
import_node_os10 = require("os");
|
|
11005
|
-
|
|
11204
|
+
import_node_path29 = require("path");
|
|
11006
11205
|
init_paths();
|
|
11007
11206
|
init_injected_mcp();
|
|
11008
11207
|
}
|
|
@@ -11043,12 +11242,12 @@ function readText(path) {
|
|
|
11043
11242
|
}
|
|
11044
11243
|
}
|
|
11045
11244
|
function userCodexConfigPaths(home = (0, import_node_os11.homedir)()) {
|
|
11046
|
-
return [(0,
|
|
11245
|
+
return [(0, import_node_path30.join)(home, ".codex", "config.toml"), (0, import_node_path30.join)(home, ".config", "codex", "config.toml")];
|
|
11047
11246
|
}
|
|
11048
11247
|
function userOpencodeConfigPaths(home = (0, import_node_os11.homedir)()) {
|
|
11049
11248
|
return [
|
|
11050
|
-
(0,
|
|
11051
|
-
(0,
|
|
11249
|
+
(0, import_node_path30.join)(home, ".config", "opencode", "opencode.json"),
|
|
11250
|
+
(0, import_node_path30.join)(home, ".config", "opencode", "opencode.jsonc")
|
|
11052
11251
|
];
|
|
11053
11252
|
}
|
|
11054
11253
|
function userMcpNamesToDisable(opts) {
|
|
@@ -11103,13 +11302,13 @@ function toCodexUnattendedAppsArgs() {
|
|
|
11103
11302
|
"features.plugins=false"
|
|
11104
11303
|
];
|
|
11105
11304
|
}
|
|
11106
|
-
var import_node_fs28, import_node_os11,
|
|
11305
|
+
var import_node_fs28, import_node_os11, import_node_path30, import_smol_toml2;
|
|
11107
11306
|
var init_orch_mcp_isolation = __esm({
|
|
11108
11307
|
"src/agents/orch-mcp-isolation.ts"() {
|
|
11109
11308
|
"use strict";
|
|
11110
11309
|
import_node_fs28 = require("fs");
|
|
11111
11310
|
import_node_os11 = require("os");
|
|
11112
|
-
|
|
11311
|
+
import_node_path30 = require("path");
|
|
11113
11312
|
import_smol_toml2 = require("smol-toml");
|
|
11114
11313
|
init_user_mcp_config();
|
|
11115
11314
|
}
|
|
@@ -11160,8 +11359,8 @@ function usageFromCodex(usage) {
|
|
|
11160
11359
|
}
|
|
11161
11360
|
function codexConfigHasNetworkAccess() {
|
|
11162
11361
|
const candidates = [
|
|
11163
|
-
(0,
|
|
11164
|
-
(0,
|
|
11362
|
+
(0, import_node_path31.join)((0, import_node_os12.homedir)(), ".codex", "config.toml"),
|
|
11363
|
+
(0, import_node_path31.join)((0, import_node_os12.homedir)(), ".config", "codex", "config.toml")
|
|
11165
11364
|
];
|
|
11166
11365
|
for (const path of candidates) {
|
|
11167
11366
|
if (!(0, import_node_fs29.existsSync)(path)) continue;
|
|
@@ -11197,7 +11396,7 @@ function asRecord2(value) {
|
|
|
11197
11396
|
return void 0;
|
|
11198
11397
|
}
|
|
11199
11398
|
function codexLooksAuthenticated() {
|
|
11200
|
-
const authPath = (0,
|
|
11399
|
+
const authPath = (0, import_node_path31.join)((0, import_node_os12.homedir)(), ".codex", "auth.json");
|
|
11201
11400
|
if (!(0, import_node_fs29.existsSync)(authPath)) return false;
|
|
11202
11401
|
try {
|
|
11203
11402
|
return (0, import_node_fs29.statSync)(authPath).size > 2;
|
|
@@ -11205,13 +11404,13 @@ function codexLooksAuthenticated() {
|
|
|
11205
11404
|
return false;
|
|
11206
11405
|
}
|
|
11207
11406
|
}
|
|
11208
|
-
var import_node_fs29, import_node_os12,
|
|
11407
|
+
var import_node_fs29, import_node_os12, import_node_path31, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
|
|
11209
11408
|
var init_codex = __esm({
|
|
11210
11409
|
"src/agents/codex.ts"() {
|
|
11211
11410
|
"use strict";
|
|
11212
11411
|
import_node_fs29 = require("fs");
|
|
11213
11412
|
import_node_os12 = require("os");
|
|
11214
|
-
|
|
11413
|
+
import_node_path31 = require("path");
|
|
11215
11414
|
init_run();
|
|
11216
11415
|
init_app_settings();
|
|
11217
11416
|
init_global_workspace();
|
|
@@ -11545,7 +11744,7 @@ function platformRipgrepPackage() {
|
|
|
11545
11744
|
}
|
|
11546
11745
|
function usableRipgrepPath(candidate) {
|
|
11547
11746
|
const raw = candidate?.trim();
|
|
11548
|
-
if (!raw || !(0,
|
|
11747
|
+
if (!raw || !(0, import_node_path32.isAbsolute)(raw)) return null;
|
|
11549
11748
|
const readable = nodeReadableScriptPath(raw);
|
|
11550
11749
|
if (!(0, import_node_fs30.existsSync)(readable) || isAsarPath(readable)) return null;
|
|
11551
11750
|
return readable;
|
|
@@ -11554,12 +11753,12 @@ function walkForBundledRipgrep(startFile) {
|
|
|
11554
11753
|
if (!startFile) return null;
|
|
11555
11754
|
const pkg = platformRipgrepPackage();
|
|
11556
11755
|
const name = rgBinaryName();
|
|
11557
|
-
let dir = (0,
|
|
11558
|
-
const root = (0,
|
|
11756
|
+
let dir = (0, import_node_path32.dirname)((0, import_node_path32.resolve)(startFile));
|
|
11757
|
+
const root = (0, import_node_path32.parse)(dir).root;
|
|
11559
11758
|
while (dir !== root) {
|
|
11560
|
-
const hit = usableRipgrepPath((0,
|
|
11759
|
+
const hit = usableRipgrepPath((0, import_node_path32.join)(dir, "node_modules", pkg, "bin", name));
|
|
11561
11760
|
if (hit) return hit;
|
|
11562
|
-
const next = (0,
|
|
11761
|
+
const next = (0, import_node_path32.dirname)(dir);
|
|
11563
11762
|
if (next === dir) break;
|
|
11564
11763
|
dir = next;
|
|
11565
11764
|
}
|
|
@@ -11569,7 +11768,7 @@ function requireResolveBundledRipgrep(fromFile) {
|
|
|
11569
11768
|
try {
|
|
11570
11769
|
const req = (0, import_node_module2.createRequire)(fromFile);
|
|
11571
11770
|
const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
|
|
11572
|
-
return usableRipgrepPath((0,
|
|
11771
|
+
return usableRipgrepPath((0, import_node_path32.join)((0, import_node_path32.dirname)(pkgJson), "bin", rgBinaryName()));
|
|
11573
11772
|
} catch {
|
|
11574
11773
|
return null;
|
|
11575
11774
|
}
|
|
@@ -11591,13 +11790,13 @@ function cursorRipgrepEnv(opts) {
|
|
|
11591
11790
|
const path = resolveCursorRipgrepPath(opts);
|
|
11592
11791
|
return path ? { [RIPGREP_ENV]: path } : {};
|
|
11593
11792
|
}
|
|
11594
|
-
var import_node_fs30, import_node_module2,
|
|
11793
|
+
var import_node_fs30, import_node_module2, import_node_path32, RIPGREP_ENV;
|
|
11595
11794
|
var init_cursor_ripgrep = __esm({
|
|
11596
11795
|
"src/agents/cursor-ripgrep.ts"() {
|
|
11597
11796
|
"use strict";
|
|
11598
11797
|
import_node_fs30 = require("fs");
|
|
11599
11798
|
import_node_module2 = require("module");
|
|
11600
|
-
|
|
11799
|
+
import_node_path32 = require("path");
|
|
11601
11800
|
init_node_launch();
|
|
11602
11801
|
init_packaged_runtime();
|
|
11603
11802
|
RIPGREP_ENV = "CURSOR_RIPGREP_PATH";
|
|
@@ -11638,11 +11837,11 @@ function entryDir() {
|
|
|
11638
11837
|
const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
|
|
11639
11838
|
if (cjsDir) return cjsDir;
|
|
11640
11839
|
try {
|
|
11641
|
-
return (0,
|
|
11840
|
+
return (0, import_node_path33.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
|
|
11642
11841
|
} catch {
|
|
11643
11842
|
try {
|
|
11644
11843
|
const req = (0, import_node_module3.createRequire)(process.cwd() + "/");
|
|
11645
|
-
return (0,
|
|
11844
|
+
return (0, import_node_path33.dirname)(req.resolve("@sideboard-ai/core"));
|
|
11646
11845
|
} catch {
|
|
11647
11846
|
return process.cwd();
|
|
11648
11847
|
}
|
|
@@ -11653,27 +11852,27 @@ function cursorRunnerPath() {
|
|
|
11653
11852
|
if (packaged) return packaged;
|
|
11654
11853
|
const root = entryDir();
|
|
11655
11854
|
const candidates = [
|
|
11656
|
-
(0,
|
|
11657
|
-
(0,
|
|
11855
|
+
(0, import_node_path33.join)(root, "agents", "cursor-runner.js"),
|
|
11856
|
+
(0, import_node_path33.join)(root, "agents", "cursor-runner.cjs"),
|
|
11658
11857
|
// If somehow resolved from package root instead of dist/
|
|
11659
|
-
(0,
|
|
11660
|
-
(0,
|
|
11858
|
+
(0, import_node_path33.join)(root, "dist", "agents", "cursor-runner.js"),
|
|
11859
|
+
(0, import_node_path33.join)(root, "dist", "agents", "cursor-runner.cjs"),
|
|
11661
11860
|
// Source tree (dev): packages/core/src/agents/cursor-runner.ts
|
|
11662
|
-
(0,
|
|
11663
|
-
(0,
|
|
11861
|
+
(0, import_node_path33.join)(root, "cursor-runner.ts"),
|
|
11862
|
+
(0, import_node_path33.join)(root, "src", "agents", "cursor-runner.ts")
|
|
11664
11863
|
];
|
|
11665
11864
|
for (const candidate of candidates) {
|
|
11666
11865
|
if ((0, import_node_fs31.existsSync)(candidate)) return candidate;
|
|
11667
11866
|
}
|
|
11668
11867
|
return candidates[0];
|
|
11669
11868
|
}
|
|
11670
|
-
var import_node_fs31, import_node_module3,
|
|
11869
|
+
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
11870
|
var init_cursor = __esm({
|
|
11672
11871
|
"src/agents/cursor.ts"() {
|
|
11673
11872
|
"use strict";
|
|
11674
11873
|
import_node_fs31 = require("fs");
|
|
11675
11874
|
import_node_module3 = require("module");
|
|
11676
|
-
|
|
11875
|
+
import_node_path33 = require("path");
|
|
11677
11876
|
import_node_url2 = require("url");
|
|
11678
11877
|
import_sdk = require("@cursor/sdk");
|
|
11679
11878
|
init_run();
|
|
@@ -12374,13 +12573,13 @@ var init_claude_usage = __esm({
|
|
|
12374
12573
|
});
|
|
12375
12574
|
|
|
12376
12575
|
// src/agents/claude-usage-client.ts
|
|
12377
|
-
var import_node_fs33, import_node_os13,
|
|
12576
|
+
var import_node_fs33, import_node_os13, import_node_path34, CLAUDE_USAGE_ERROR_TTL_MS, CLAUDE_USAGE_STALE_OK_MS;
|
|
12378
12577
|
var init_claude_usage_client = __esm({
|
|
12379
12578
|
"src/agents/claude-usage-client.ts"() {
|
|
12380
12579
|
"use strict";
|
|
12381
12580
|
import_node_fs33 = require("fs");
|
|
12382
12581
|
import_node_os13 = require("os");
|
|
12383
|
-
|
|
12582
|
+
import_node_path34 = require("path");
|
|
12384
12583
|
init_run();
|
|
12385
12584
|
init_fetch();
|
|
12386
12585
|
init_app_settings();
|
|
@@ -12441,15 +12640,15 @@ var init_agents = __esm({
|
|
|
12441
12640
|
|
|
12442
12641
|
// src/hook/worktree-pkg-cache.ts
|
|
12443
12642
|
function worktreePkgCacheRoot(worktreePath) {
|
|
12444
|
-
return (0,
|
|
12643
|
+
return (0, import_node_path35.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
|
|
12445
12644
|
}
|
|
12446
12645
|
function worktreePkgCacheEnv(worktreePath) {
|
|
12447
12646
|
const root = worktreePkgCacheRoot(worktreePath);
|
|
12448
|
-
const store = (0,
|
|
12449
|
-
const pnpmCache = (0,
|
|
12450
|
-
const npmCache = (0,
|
|
12451
|
-
const nodeGyp = (0,
|
|
12452
|
-
const electron = (0,
|
|
12647
|
+
const store = (0, import_node_path35.join)(root, "pnpm-store");
|
|
12648
|
+
const pnpmCache = (0, import_node_path35.join)(root, "pnpm");
|
|
12649
|
+
const npmCache = (0, import_node_path35.join)(root, "npm");
|
|
12650
|
+
const nodeGyp = (0, import_node_path35.join)(root, "node-gyp");
|
|
12651
|
+
const electron = (0, import_node_path35.join)(root, "electron");
|
|
12453
12652
|
return {
|
|
12454
12653
|
npm_config_store_dir: store,
|
|
12455
12654
|
PNPM_STORE_DIR: store,
|
|
@@ -12485,12 +12684,12 @@ function applyWorktreePkgCacheEnv(env, worktreePath) {
|
|
|
12485
12684
|
fillGroup(env, ["electron_config_cache"], next);
|
|
12486
12685
|
ensureWorktreePkgCacheDirs(cwd);
|
|
12487
12686
|
}
|
|
12488
|
-
var import_node_fs34,
|
|
12687
|
+
var import_node_fs34, import_node_path35, WORKTREE_PKG_CACHE_REL;
|
|
12489
12688
|
var init_worktree_pkg_cache = __esm({
|
|
12490
12689
|
"src/hook/worktree-pkg-cache.ts"() {
|
|
12491
12690
|
"use strict";
|
|
12492
12691
|
import_node_fs34 = require("fs");
|
|
12493
|
-
|
|
12692
|
+
import_node_path35 = require("path");
|
|
12494
12693
|
WORKTREE_PKG_CACHE_REL = ".context/.sideboard/pkg-cache";
|
|
12495
12694
|
}
|
|
12496
12695
|
});
|
|
@@ -13660,12 +13859,12 @@ function readTextIfPresent(abs) {
|
|
|
13660
13859
|
}
|
|
13661
13860
|
}
|
|
13662
13861
|
function readLocalGuidelines(worktreePath) {
|
|
13663
|
-
const localAbs = (0,
|
|
13862
|
+
const localAbs = (0, import_node_path36.join)(worktreePath, REVIEW_REQUEST_PATH);
|
|
13664
13863
|
const localContent = readTextIfPresent(localAbs);
|
|
13665
13864
|
if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
|
|
13666
13865
|
return { path: REVIEW_REQUEST_PATH, content: localContent };
|
|
13667
13866
|
}
|
|
13668
|
-
const legacyAbs = (0,
|
|
13867
|
+
const legacyAbs = (0, import_node_path36.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
|
|
13669
13868
|
const legacyContent = readTextIfPresent(legacyAbs);
|
|
13670
13869
|
if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
|
|
13671
13870
|
return { path: LEGACY_REVIEW_REQUEST_PATH, content: legacyContent };
|
|
@@ -13689,27 +13888,27 @@ function contextGuidelines(content, source) {
|
|
|
13689
13888
|
};
|
|
13690
13889
|
}
|
|
13691
13890
|
function writeContextGuidelines(worktreePath, content) {
|
|
13692
|
-
const abs = (0,
|
|
13693
|
-
(0, import_node_fs35.mkdirSync)((0,
|
|
13891
|
+
const abs = (0, import_node_path36.join)(worktreePath, CONTEXT_REVIEW_PATH);
|
|
13892
|
+
(0, import_node_fs35.mkdirSync)((0, import_node_path36.dirname)(abs), { recursive: true });
|
|
13694
13893
|
const body = content.endsWith("\n") ? content : `${content}
|
|
13695
13894
|
`;
|
|
13696
13895
|
(0, import_node_fs35.writeFileSync)(abs, body, "utf8");
|
|
13697
13896
|
return body;
|
|
13698
13897
|
}
|
|
13699
13898
|
function readSideboardReview(worktreePath, repoPath) {
|
|
13700
|
-
const fromWorktree = readTextIfPresent((0,
|
|
13899
|
+
const fromWorktree = readTextIfPresent((0, import_node_path36.join)(worktreePath, REPO_REVIEW_PATH));
|
|
13701
13900
|
if (fromWorktree) return fromWorktree;
|
|
13702
13901
|
const repo = repoPath?.replace(/\/+$/, "");
|
|
13703
13902
|
const wt = worktreePath.replace(/\/+$/, "");
|
|
13704
13903
|
if (!repo || repo === wt) return null;
|
|
13705
|
-
return readTextIfPresent((0,
|
|
13904
|
+
return readTextIfPresent((0, import_node_path36.join)(repo, REPO_REVIEW_PATH));
|
|
13706
13905
|
}
|
|
13707
13906
|
function ensureReviewGuidelinesFile(worktreePath, repoPath) {
|
|
13708
|
-
const skillContent = readTextIfPresent((0,
|
|
13907
|
+
const skillContent = readTextIfPresent((0, import_node_path36.join)(worktreePath, REVIEW_SKILL_PATH));
|
|
13709
13908
|
if (skillContent) {
|
|
13710
13909
|
return { ...skillGuidelines(skillContent, "skill"), wrote: false };
|
|
13711
13910
|
}
|
|
13712
|
-
const contextContent = readTextIfPresent((0,
|
|
13911
|
+
const contextContent = readTextIfPresent((0, import_node_path36.join)(worktreePath, CONTEXT_REVIEW_PATH));
|
|
13713
13912
|
if (contextContent && !shouldRefreshReviewRequestTemplate(contextContent)) {
|
|
13714
13913
|
return { ...contextGuidelines(contextContent, "local"), wrote: false };
|
|
13715
13914
|
}
|
|
@@ -13764,13 +13963,13 @@ async function requestReview(threadRef, send) {
|
|
|
13764
13963
|
const started = await send(tab.id, REVIEW_REQUEST_PREFILL);
|
|
13765
13964
|
return { tab: started, from };
|
|
13766
13965
|
}
|
|
13767
|
-
var import_node_crypto7, import_node_fs35,
|
|
13966
|
+
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
13967
|
var init_request_review = __esm({
|
|
13769
13968
|
"src/review/request-review.ts"() {
|
|
13770
13969
|
"use strict";
|
|
13771
13970
|
import_node_crypto7 = require("crypto");
|
|
13772
13971
|
import_node_fs35 = require("fs");
|
|
13773
|
-
|
|
13972
|
+
import_node_path36 = require("path");
|
|
13774
13973
|
init_global_workspace();
|
|
13775
13974
|
init_chat_tabs();
|
|
13776
13975
|
init_thread_store();
|
|
@@ -13796,7 +13995,7 @@ function matchSimpleGlob(pattern, name) {
|
|
|
13796
13995
|
return new RegExp(`^${escaped}$`).test(name);
|
|
13797
13996
|
}
|
|
13798
13997
|
function readWorktreeInclude(repoPath) {
|
|
13799
|
-
const path = (0,
|
|
13998
|
+
const path = (0, import_node_path37.join)(repoPath, ".worktreeinclude");
|
|
13800
13999
|
if (!(0, import_node_fs36.existsSync)(path)) return [];
|
|
13801
14000
|
return (0, import_node_fs36.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
13802
14001
|
}
|
|
@@ -13811,7 +14010,7 @@ function resolveFilesToCopy(repoPath) {
|
|
|
13811
14010
|
for (const entry of (0, import_node_fs36.readdirSync)(repoPath, { withFileTypes: true })) {
|
|
13812
14011
|
if (!entry.isFile()) continue;
|
|
13813
14012
|
for (const glob of settings.fileIncludeGlobs) {
|
|
13814
|
-
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0,
|
|
14013
|
+
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path37.basename)(glob), entry.name)) {
|
|
13815
14014
|
matched.push(entry.name);
|
|
13816
14015
|
break;
|
|
13817
14016
|
}
|
|
@@ -13837,10 +14036,10 @@ function copyConfiguredFiles(repoPath, worktreePath) {
|
|
|
13837
14036
|
const patterns = resolveFilesToCopy(repoPath);
|
|
13838
14037
|
const copied = [];
|
|
13839
14038
|
for (const rel of patterns) {
|
|
13840
|
-
const src = (0,
|
|
14039
|
+
const src = (0, import_node_path37.join)(repoPath, rel);
|
|
13841
14040
|
if (!(0, import_node_fs36.existsSync)(src)) continue;
|
|
13842
|
-
const dest = (0,
|
|
13843
|
-
(0, import_node_fs36.mkdirSync)((0,
|
|
14041
|
+
const dest = (0, import_node_path37.join)(worktreePath, rel);
|
|
14042
|
+
(0, import_node_fs36.mkdirSync)((0, import_node_path37.dirname)(dest), { recursive: true });
|
|
13844
14043
|
(0, import_node_fs36.copyFileSync)(src, dest);
|
|
13845
14044
|
copied.push(rel);
|
|
13846
14045
|
}
|
|
@@ -13876,7 +14075,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
|
|
|
13876
14075
|
const env = stripNestedElectronEnv({
|
|
13877
14076
|
...baseEnv ?? process.env
|
|
13878
14077
|
});
|
|
13879
|
-
const name = opts.workspaceName ?? (0,
|
|
14078
|
+
const name = opts.workspaceName ?? (0, import_node_path37.basename)(opts.worktreePath);
|
|
13880
14079
|
const ports = opts.ports ?? [];
|
|
13881
14080
|
const primary = ports[0];
|
|
13882
14081
|
env.SIDEBOARD_WORKSPACE_NAME = name;
|
|
@@ -14139,13 +14338,13 @@ async function startDevServer(repoPath, worktreePath, onLine, opts) {
|
|
|
14139
14338
|
done: handle.done
|
|
14140
14339
|
};
|
|
14141
14340
|
}
|
|
14142
|
-
var import_node_fs36, import_node_net,
|
|
14341
|
+
var import_node_fs36, import_node_net, import_node_path37, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
|
|
14143
14342
|
var init_conductor = __esm({
|
|
14144
14343
|
"src/hook/conductor.ts"() {
|
|
14145
14344
|
"use strict";
|
|
14146
14345
|
import_node_fs36 = require("fs");
|
|
14147
14346
|
import_node_net = require("net");
|
|
14148
|
-
|
|
14347
|
+
import_node_path37 = require("path");
|
|
14149
14348
|
import_execa4 = require("execa");
|
|
14150
14349
|
import_node_readline3 = require("readline");
|
|
14151
14350
|
init_settings();
|
|
@@ -14172,7 +14371,7 @@ ${line}` : line;
|
|
|
14172
14371
|
return nl >= 0 && nl < cut.length - 1 ? cut.slice(nl + 1) : cut;
|
|
14173
14372
|
}
|
|
14174
14373
|
function setupLogPath(threadId) {
|
|
14175
|
-
return (0,
|
|
14374
|
+
return (0, import_node_path38.join)(threadsDir(), `${threadId}.setup.log.json`);
|
|
14176
14375
|
}
|
|
14177
14376
|
function setupLogKeyForWorktree(worktreePath) {
|
|
14178
14377
|
const norm = normalizeWorktreePath(worktreePath);
|
|
@@ -14267,13 +14466,13 @@ function finishSetupLog(threadId, exitCode, source) {
|
|
|
14267
14466
|
persistNow(threadId);
|
|
14268
14467
|
return clone(snap);
|
|
14269
14468
|
}
|
|
14270
|
-
var import_node_crypto8, import_node_fs37,
|
|
14469
|
+
var import_node_crypto8, import_node_fs37, import_node_path38, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers;
|
|
14271
14470
|
var init_setup_log = __esm({
|
|
14272
14471
|
"src/store/setup-log.ts"() {
|
|
14273
14472
|
"use strict";
|
|
14274
14473
|
import_node_crypto8 = require("crypto");
|
|
14275
14474
|
import_node_fs37 = require("fs");
|
|
14276
|
-
|
|
14475
|
+
import_node_path38 = require("path");
|
|
14277
14476
|
init_worktree_labels();
|
|
14278
14477
|
init_paths();
|
|
14279
14478
|
EMPTY = {
|
|
@@ -14335,9 +14534,9 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
14335
14534
|
if ((0, import_node_fs38.existsSync)(root)) {
|
|
14336
14535
|
for (const entry of (0, import_node_fs38.readdirSync)(root, { withFileTypes: true })) {
|
|
14337
14536
|
if (!entry.isDirectory()) continue;
|
|
14338
|
-
const path = (0,
|
|
14537
|
+
const path = (0, import_node_path39.join)(root, entry.name).replace(/\/$/, "");
|
|
14339
14538
|
if (known.has(path) || seen.has(path)) continue;
|
|
14340
|
-
if (!(0, import_node_fs38.existsSync)((0,
|
|
14539
|
+
if (!(0, import_node_fs38.existsSync)((0, import_node_path39.join)(path, ".git"))) continue;
|
|
14341
14540
|
seen.add(path);
|
|
14342
14541
|
let mtimeMs = 0;
|
|
14343
14542
|
try {
|
|
@@ -14393,12 +14592,12 @@ function shouldRunWorktreeCleanup(settings = loadAppSettings()) {
|
|
|
14393
14592
|
const elapsed = Date.now() - Date.parse(last);
|
|
14394
14593
|
return elapsed >= intervalHours * 36e5;
|
|
14395
14594
|
}
|
|
14396
|
-
var import_node_fs38,
|
|
14595
|
+
var import_node_fs38, import_node_path39;
|
|
14397
14596
|
var init_orphan_cleanup = __esm({
|
|
14398
14597
|
"src/git/orphan-cleanup.ts"() {
|
|
14399
14598
|
"use strict";
|
|
14400
14599
|
import_node_fs38 = require("fs");
|
|
14401
|
-
|
|
14600
|
+
import_node_path39 = require("path");
|
|
14402
14601
|
init_worktree();
|
|
14403
14602
|
init_thread_store();
|
|
14404
14603
|
init_paths();
|
|
@@ -14406,6 +14605,77 @@ var init_orphan_cleanup = __esm({
|
|
|
14406
14605
|
}
|
|
14407
14606
|
});
|
|
14408
14607
|
|
|
14608
|
+
// src/store/history-cleanup.ts
|
|
14609
|
+
function stripArchivedTranscript(thread) {
|
|
14610
|
+
writeThread(
|
|
14611
|
+
{
|
|
14612
|
+
...thread,
|
|
14613
|
+
attachments: [],
|
|
14614
|
+
pendingTurnAttachments: [],
|
|
14615
|
+
messages: [historyRetentionStubMessage(thread)]
|
|
14616
|
+
},
|
|
14617
|
+
{ touch: false }
|
|
14618
|
+
);
|
|
14619
|
+
}
|
|
14620
|
+
function cleanupArchivedHistory(opts = {}) {
|
|
14621
|
+
const settings = loadAppSettings();
|
|
14622
|
+
if (!opts.force && opts.purgeOlderThanDays == null && !autoCleanupHistoryEnabled(settings)) {
|
|
14623
|
+
return { stripped: [], purged: [] };
|
|
14624
|
+
}
|
|
14625
|
+
const archived = listThreads({ includeArchived: true }).filter((t) => t.status === "archived");
|
|
14626
|
+
const nowMs = opts.nowMs ?? Date.now();
|
|
14627
|
+
const plan = opts.purgeOlderThanDays != null ? { stripIds: [], purgeIds: planHistoryAgePurge(archived, opts.purgeOlderThanDays, nowMs) } : planHistoryRetention(archived, {
|
|
14628
|
+
maxCount: opts.maxCount ?? historyMaxCount(settings),
|
|
14629
|
+
maxDays: opts.maxDays ?? historyMaxDays(settings),
|
|
14630
|
+
nowMs
|
|
14631
|
+
});
|
|
14632
|
+
const stripped = [];
|
|
14633
|
+
const purged = [];
|
|
14634
|
+
if (opts.dryRun) {
|
|
14635
|
+
return { stripped: plan.stripIds, purged: plan.purgeIds };
|
|
14636
|
+
}
|
|
14637
|
+
for (const id of plan.stripIds) {
|
|
14638
|
+
const thread = readThread(id);
|
|
14639
|
+
if (!thread || thread.status !== "archived") continue;
|
|
14640
|
+
try {
|
|
14641
|
+
stripArchivedTranscript(thread);
|
|
14642
|
+
stripped.push(id);
|
|
14643
|
+
} catch {
|
|
14644
|
+
}
|
|
14645
|
+
}
|
|
14646
|
+
for (const id of plan.purgeIds) {
|
|
14647
|
+
const thread = readThread(id);
|
|
14648
|
+
if (!thread || thread.status !== "archived") continue;
|
|
14649
|
+
try {
|
|
14650
|
+
deleteThreadRecord(id);
|
|
14651
|
+
purged.push(id);
|
|
14652
|
+
} catch {
|
|
14653
|
+
}
|
|
14654
|
+
}
|
|
14655
|
+
if (stripped.length > 0 || purged.length > 0) {
|
|
14656
|
+
updateAdvancedSettings({
|
|
14657
|
+
historyLastCleanupAt: new Date(nowMs).toISOString()
|
|
14658
|
+
});
|
|
14659
|
+
}
|
|
14660
|
+
return { stripped, purged };
|
|
14661
|
+
}
|
|
14662
|
+
function shouldRunHistoryCleanup(settings = loadAppSettings()) {
|
|
14663
|
+
if (!autoCleanupHistoryEnabled(settings)) return false;
|
|
14664
|
+
const intervalHours = settings.advanced.historyCleanupIntervalHours ?? HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT;
|
|
14665
|
+
const last = settings.advanced.historyLastCleanupAt;
|
|
14666
|
+
if (!last) return true;
|
|
14667
|
+
const elapsed = Date.now() - Date.parse(last);
|
|
14668
|
+
return Number.isFinite(elapsed) && elapsed >= intervalHours * 36e5;
|
|
14669
|
+
}
|
|
14670
|
+
var init_history_cleanup = __esm({
|
|
14671
|
+
"src/store/history-cleanup.ts"() {
|
|
14672
|
+
"use strict";
|
|
14673
|
+
init_app_settings();
|
|
14674
|
+
init_history_retention();
|
|
14675
|
+
init_thread_store();
|
|
14676
|
+
}
|
|
14677
|
+
});
|
|
14678
|
+
|
|
14409
14679
|
// src/git/apply-into-main.ts
|
|
14410
14680
|
async function applyThreadIntoMain(thread, opts) {
|
|
14411
14681
|
const method = opts?.method ?? "merge";
|
|
@@ -14501,11 +14771,11 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
14501
14771
|
if (!url) throw new Error("Clone URL is required");
|
|
14502
14772
|
let name = opts.name?.trim();
|
|
14503
14773
|
if (!name) {
|
|
14504
|
-
const leaf = (0,
|
|
14774
|
+
const leaf = (0, import_node_path40.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
|
|
14505
14775
|
name = leaf || "repo";
|
|
14506
14776
|
}
|
|
14507
14777
|
name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
|
|
14508
|
-
const dest = (0,
|
|
14778
|
+
const dest = (0, import_node_path40.join)(sideboardReposDir(), name);
|
|
14509
14779
|
if ((0, import_node_fs39.existsSync)(dest)) {
|
|
14510
14780
|
const repoPath2 = await resolveRepoRoot(dest);
|
|
14511
14781
|
const workspace2 = await ensureWorkspace(repoPath2);
|
|
@@ -14521,12 +14791,12 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
14521
14791
|
const workspace = await ensureWorkspace(repoPath);
|
|
14522
14792
|
return { repoPath, workspace };
|
|
14523
14793
|
}
|
|
14524
|
-
var import_node_fs39,
|
|
14794
|
+
var import_node_fs39, import_node_path40, import_execa6;
|
|
14525
14795
|
var init_clone_repo = __esm({
|
|
14526
14796
|
"src/git/clone-repo.ts"() {
|
|
14527
14797
|
"use strict";
|
|
14528
14798
|
import_node_fs39 = require("fs");
|
|
14529
|
-
|
|
14799
|
+
import_node_path40 = require("path");
|
|
14530
14800
|
import_execa6 = require("execa");
|
|
14531
14801
|
init_paths();
|
|
14532
14802
|
init_workspaces2();
|
|
@@ -14536,7 +14806,7 @@ var init_clone_repo = __esm({
|
|
|
14536
14806
|
|
|
14537
14807
|
// src/store/desktop-host.ts
|
|
14538
14808
|
function desktopHostPidPath() {
|
|
14539
|
-
return (0,
|
|
14809
|
+
return (0, import_node_path41.join)(appDataDir(), "desktop-host.pid");
|
|
14540
14810
|
}
|
|
14541
14811
|
function readDesktopHostPid() {
|
|
14542
14812
|
try {
|
|
@@ -14566,12 +14836,12 @@ function thisProcessShouldDrainAgentQueues() {
|
|
|
14566
14836
|
if (isThisProcessDesktopHost()) return true;
|
|
14567
14837
|
return !isDesktopHostAlive();
|
|
14568
14838
|
}
|
|
14569
|
-
var import_node_fs40,
|
|
14839
|
+
var import_node_fs40, import_node_path41;
|
|
14570
14840
|
var init_desktop_host = __esm({
|
|
14571
14841
|
"src/store/desktop-host.ts"() {
|
|
14572
14842
|
"use strict";
|
|
14573
14843
|
import_node_fs40 = require("fs");
|
|
14574
|
-
|
|
14844
|
+
import_node_path41 = require("path");
|
|
14575
14845
|
init_paths();
|
|
14576
14846
|
}
|
|
14577
14847
|
});
|
|
@@ -14694,7 +14964,7 @@ function readIntFile(file) {
|
|
|
14694
14964
|
return Number.isInteger(n) ? n : null;
|
|
14695
14965
|
}
|
|
14696
14966
|
function jobDir(root, id, legacy = false) {
|
|
14697
|
-
return (0,
|
|
14967
|
+
return (0, import_node_path42.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
|
|
14698
14968
|
}
|
|
14699
14969
|
function resolveJobDir(root, id) {
|
|
14700
14970
|
const modern = jobDir(root, id, false);
|
|
@@ -14704,7 +14974,7 @@ function resolveJobDir(root, id) {
|
|
|
14704
14974
|
return modern;
|
|
14705
14975
|
}
|
|
14706
14976
|
function listJobIdsIn(root, rel) {
|
|
14707
|
-
const dir = (0,
|
|
14977
|
+
const dir = (0, import_node_path42.join)(root, rel);
|
|
14708
14978
|
if (!(0, import_node_fs41.existsSync)(dir)) return [];
|
|
14709
14979
|
return (0, import_node_fs41.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
|
|
14710
14980
|
}
|
|
@@ -14718,7 +14988,7 @@ function listRunningDetachedJobs(worktreePath) {
|
|
|
14718
14988
|
const running = [];
|
|
14719
14989
|
for (const id of ids) {
|
|
14720
14990
|
const dir = resolveJobDir(root, id);
|
|
14721
|
-
const pid = readIntFile((0,
|
|
14991
|
+
const pid = readIntFile((0, import_node_path42.join)(dir, "pid"));
|
|
14722
14992
|
if (jobTreeAlive(pid)) running.push(id);
|
|
14723
14993
|
}
|
|
14724
14994
|
return running.sort();
|
|
@@ -14821,15 +15091,15 @@ function takeDelta(logFile, cursorFile) {
|
|
|
14821
15091
|
return { delta: capJobLogDelta(lines.slice(start).join("\n")), nextCursor: lines.length };
|
|
14822
15092
|
}
|
|
14823
15093
|
function snapshotJob(dir) {
|
|
14824
|
-
const pid = readIntFile((0,
|
|
15094
|
+
const pid = readIntFile((0, import_node_path42.join)(dir, "pid"));
|
|
14825
15095
|
const running = jobTreeAlive(pid);
|
|
14826
15096
|
return {
|
|
14827
15097
|
pid,
|
|
14828
15098
|
running,
|
|
14829
|
-
exitCode: readIntFile((0,
|
|
14830
|
-
log: (0,
|
|
14831
|
-
cursor: (0,
|
|
14832
|
-
progress: tailProgress((0,
|
|
15099
|
+
exitCode: readIntFile((0, import_node_path42.join)(dir, "exit")),
|
|
15100
|
+
log: (0, import_node_path42.join)(dir, "log"),
|
|
15101
|
+
cursor: (0, import_node_path42.join)(dir, "present.cursor"),
|
|
15102
|
+
progress: tailProgress((0, import_node_path42.join)(dir, "log"))
|
|
14833
15103
|
};
|
|
14834
15104
|
}
|
|
14835
15105
|
function toResult(id, snap, extra) {
|
|
@@ -14838,7 +15108,7 @@ function toResult(id, snap, extra) {
|
|
|
14838
15108
|
const stillRunning = snap.running && !ok;
|
|
14839
15109
|
const { delta, nextCursor } = takeDelta(snap.log, snap.cursor);
|
|
14840
15110
|
try {
|
|
14841
|
-
(0, import_node_fs41.mkdirSync)((0,
|
|
15111
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path42.dirname)(snap.cursor), { recursive: true });
|
|
14842
15112
|
(0, import_node_fs41.writeFileSync)(snap.cursor, `${nextCursor}
|
|
14843
15113
|
`);
|
|
14844
15114
|
} catch {
|
|
@@ -14914,7 +15184,7 @@ function killProcessTree(pid, signal) {
|
|
|
14914
15184
|
}
|
|
14915
15185
|
function appendJobLog(logFile, line) {
|
|
14916
15186
|
try {
|
|
14917
|
-
(0, import_node_fs41.mkdirSync)((0,
|
|
15187
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path42.dirname)(logFile), { recursive: true });
|
|
14918
15188
|
const body = line.endsWith("\n") ? line : `${line}
|
|
14919
15189
|
`;
|
|
14920
15190
|
(0, import_node_fs41.appendFileSync)(logFile, body);
|
|
@@ -14963,7 +15233,7 @@ async function stopDetachedJob(cwd, id, opts) {
|
|
|
14963
15233
|
killProcessTree(targetPid, "SIGKILL");
|
|
14964
15234
|
await sleep(100);
|
|
14965
15235
|
}
|
|
14966
|
-
const exitFile = (0,
|
|
15236
|
+
const exitFile = (0, import_node_path42.join)(dir, "exit");
|
|
14967
15237
|
if (!(0, import_node_fs41.existsSync)(exitFile)) {
|
|
14968
15238
|
try {
|
|
14969
15239
|
(0, import_node_fs41.writeFileSync)(exitFile, "1\n");
|
|
@@ -14986,12 +15256,12 @@ async function stopDetachedJob(cwd, id, opts) {
|
|
|
14986
15256
|
hint: stopped ? MCP_STOP_JOB_HINT : MCP_WAIT_JOB_STILL_RUNNING_HINT
|
|
14987
15257
|
};
|
|
14988
15258
|
}
|
|
14989
|
-
var import_node_fs41,
|
|
15259
|
+
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
15260
|
var init_wait_for_job = __esm({
|
|
14991
15261
|
"src/mcp/wait-for-job.ts"() {
|
|
14992
15262
|
"use strict";
|
|
14993
15263
|
import_node_fs41 = require("fs");
|
|
14994
|
-
|
|
15264
|
+
import_node_path42 = require("path");
|
|
14995
15265
|
init_workspace_scratch();
|
|
14996
15266
|
init_wait_for_turn();
|
|
14997
15267
|
MAX_JOB_CONTINUES = 8;
|
|
@@ -17602,7 +17872,7 @@ var init_quota_failover = __esm({
|
|
|
17602
17872
|
// src/threads/adopt.ts
|
|
17603
17873
|
function thisModuleFile() {
|
|
17604
17874
|
const cjsFile = typeof __filename !== "undefined" ? __filename : "";
|
|
17605
|
-
return cjsFile || process.argv[1] || (0,
|
|
17875
|
+
return cjsFile || process.argv[1] || (0, import_node_path43.join)(process.cwd(), "package.json");
|
|
17606
17876
|
}
|
|
17607
17877
|
function openReadonlySqlite(file) {
|
|
17608
17878
|
const req = (0, import_node_module4.createRequire)(thisModuleFile());
|
|
@@ -17630,7 +17900,7 @@ function resolveConductorCursorAgentId(workspacePath) {
|
|
|
17630
17900
|
return null;
|
|
17631
17901
|
}
|
|
17632
17902
|
for (const hash of hashes) {
|
|
17633
|
-
const agentsFile = (0,
|
|
17903
|
+
const agentsFile = (0, import_node_path43.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
|
|
17634
17904
|
if (!(0, import_node_fs44.existsSync)(agentsFile)) continue;
|
|
17635
17905
|
let text7;
|
|
17636
17906
|
try {
|
|
@@ -17687,8 +17957,8 @@ function listConductorWorkspaces() {
|
|
|
17687
17957
|
if (!(0, import_node_fs44.existsSync)(CONDUCTOR_DB)) {
|
|
17688
17958
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
17689
17959
|
}
|
|
17690
|
-
const tmp = (0, import_node_fs44.mkdtempSync)((0,
|
|
17691
|
-
const snapshot = (0,
|
|
17960
|
+
const tmp = (0, import_node_fs44.mkdtempSync)((0, import_node_path43.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
|
|
17961
|
+
const snapshot = (0, import_node_path43.join)(tmp, "conductor.db");
|
|
17692
17962
|
try {
|
|
17693
17963
|
(0, import_node_fs44.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
17694
17964
|
for (const suffix of ["-wal", "-shm"]) {
|
|
@@ -17778,8 +18048,8 @@ function importConductorWorkspace(workspaceId) {
|
|
|
17778
18048
|
if (!(0, import_node_fs44.existsSync)(CONDUCTOR_DB)) {
|
|
17779
18049
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
17780
18050
|
}
|
|
17781
|
-
const tmp = (0, import_node_fs44.mkdtempSync)((0,
|
|
17782
|
-
const snapshot = (0,
|
|
18051
|
+
const tmp = (0, import_node_fs44.mkdtempSync)((0, import_node_path43.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
|
|
18052
|
+
const snapshot = (0, import_node_path43.join)(tmp, "conductor.db");
|
|
17783
18053
|
try {
|
|
17784
18054
|
(0, import_node_fs44.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
17785
18055
|
for (const suffix of ["-wal", "-shm"]) {
|
|
@@ -17873,25 +18143,25 @@ function importConductorWorkspace(workspaceId) {
|
|
|
17873
18143
|
async function importConductorWorkspaceAsync(workspaceId) {
|
|
17874
18144
|
return importConductorWorkspace(workspaceId);
|
|
17875
18145
|
}
|
|
17876
|
-
var import_node_child_process4, import_node_fs44, import_node_os14,
|
|
18146
|
+
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
18147
|
var init_adopt = __esm({
|
|
17878
18148
|
"src/threads/adopt.ts"() {
|
|
17879
18149
|
"use strict";
|
|
17880
18150
|
import_node_child_process4 = require("child_process");
|
|
17881
18151
|
import_node_fs44 = require("fs");
|
|
17882
18152
|
import_node_os14 = require("os");
|
|
17883
|
-
|
|
18153
|
+
import_node_path43 = require("path");
|
|
17884
18154
|
import_node_module4 = require("module");
|
|
17885
18155
|
init_worktree();
|
|
17886
18156
|
init_thread_store();
|
|
17887
|
-
CONDUCTOR_APP_SUPPORT = (0,
|
|
18157
|
+
CONDUCTOR_APP_SUPPORT = (0, import_node_path43.join)(
|
|
17888
18158
|
process.env.HOME ?? "",
|
|
17889
18159
|
"Library",
|
|
17890
18160
|
"Application Support",
|
|
17891
18161
|
"com.conductor.app"
|
|
17892
18162
|
);
|
|
17893
|
-
CONDUCTOR_DB = (0,
|
|
17894
|
-
CURSOR_SDK_STORE = (0,
|
|
18163
|
+
CONDUCTOR_DB = (0, import_node_path43.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
|
|
18164
|
+
CURSOR_SDK_STORE = (0, import_node_path43.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
|
|
17895
18165
|
}
|
|
17896
18166
|
});
|
|
17897
18167
|
|
|
@@ -18336,7 +18606,7 @@ new file mode 100644
|
|
|
18336
18606
|
};
|
|
18337
18607
|
}
|
|
18338
18608
|
async function untrackedPatch(worktreePath, path, maxHunk) {
|
|
18339
|
-
const abs = (0,
|
|
18609
|
+
const abs = (0, import_node_path44.join)(worktreePath, path);
|
|
18340
18610
|
try {
|
|
18341
18611
|
const st = (0, import_node_fs46.statSync)(abs);
|
|
18342
18612
|
if (st.isFile() && st.size > maxHunk) {
|
|
@@ -18829,7 +19099,7 @@ function isImageRelativePath(relativePath) {
|
|
|
18829
19099
|
function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
18830
19100
|
assertSafeRelativePath(relativePath);
|
|
18831
19101
|
const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
|
|
18832
|
-
const abs = (0,
|
|
19102
|
+
const abs = (0, import_node_path44.join)(worktreePath, relativePath);
|
|
18833
19103
|
const st = (0, import_node_fs46.statSync)(abs);
|
|
18834
19104
|
if (!st.isFile()) {
|
|
18835
19105
|
throw new Error(`Not a file: ${relativePath}`);
|
|
@@ -18849,7 +19119,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
18849
19119
|
function readWorktreeFile(worktreePath, relativePath, opts) {
|
|
18850
19120
|
assertSafeRelativePath(relativePath);
|
|
18851
19121
|
const maxBytes = opts?.maxBytes ?? 2e5;
|
|
18852
|
-
const abs = (0,
|
|
19122
|
+
const abs = (0, import_node_path44.join)(worktreePath, relativePath);
|
|
18853
19123
|
const st = (0, import_node_fs46.statSync)(abs);
|
|
18854
19124
|
if (!st.isFile()) {
|
|
18855
19125
|
throw new Error(`Not a file: ${relativePath}`);
|
|
@@ -18897,8 +19167,8 @@ function assertSafeRelativePath(relativePath) {
|
|
|
18897
19167
|
}
|
|
18898
19168
|
function writeWorktreeFile(worktreePath, relativePath, content) {
|
|
18899
19169
|
assertSafeRelativePath(relativePath);
|
|
18900
|
-
const abs = (0,
|
|
18901
|
-
(0, import_node_fs46.mkdirSync)((0,
|
|
19170
|
+
const abs = (0, import_node_path44.join)(worktreePath, relativePath);
|
|
19171
|
+
(0, import_node_fs46.mkdirSync)((0, import_node_path44.dirname)(abs), { recursive: true });
|
|
18902
19172
|
(0, import_node_fs46.writeFileSync)(abs, content, "utf8");
|
|
18903
19173
|
return { path: relativePath };
|
|
18904
19174
|
}
|
|
@@ -18916,12 +19186,12 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
|
18916
19186
|
truncated: full.files.length > maxFiles
|
|
18917
19187
|
};
|
|
18918
19188
|
}
|
|
18919
|
-
var import_node_fs46,
|
|
19189
|
+
var import_node_fs46, import_node_path44, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
|
|
18920
19190
|
var init_diff = __esm({
|
|
18921
19191
|
"src/diff/diff.ts"() {
|
|
18922
19192
|
"use strict";
|
|
18923
19193
|
import_node_fs46 = require("fs");
|
|
18924
|
-
|
|
19194
|
+
import_node_path44 = require("path");
|
|
18925
19195
|
init_run();
|
|
18926
19196
|
init_worktree();
|
|
18927
19197
|
mergeBaseCache = /* @__PURE__ */ new Map();
|
|
@@ -19306,7 +19576,7 @@ function scanSkillsDir(dir, source, out) {
|
|
|
19306
19576
|
}
|
|
19307
19577
|
for (const entry of entries) {
|
|
19308
19578
|
if (entry.startsWith(".")) continue;
|
|
19309
|
-
const skillMd = (0,
|
|
19579
|
+
const skillMd = (0, import_node_path45.join)(dir, entry, "SKILL.md");
|
|
19310
19580
|
if (!(0, import_node_fs47.existsSync)(skillMd)) continue;
|
|
19311
19581
|
try {
|
|
19312
19582
|
if (!(0, import_node_fs47.statSync)(skillMd).isFile()) continue;
|
|
@@ -19328,12 +19598,12 @@ function scanClaudePluginSkills(pluginsRoot, out) {
|
|
|
19328
19598
|
return;
|
|
19329
19599
|
}
|
|
19330
19600
|
if (lookingForSkillsDir && entries.includes("SKILL.md")) {
|
|
19331
|
-
const skill = readSkill((0,
|
|
19601
|
+
const skill = readSkill((0, import_node_path45.join)(dir, "SKILL.md"), "cli");
|
|
19332
19602
|
if (skill) out.push(skill);
|
|
19333
19603
|
}
|
|
19334
19604
|
for (const entry of entries) {
|
|
19335
19605
|
if (entry === "node_modules" || entry === ".git") continue;
|
|
19336
|
-
const full = (0,
|
|
19606
|
+
const full = (0, import_node_path45.join)(dir, entry);
|
|
19337
19607
|
try {
|
|
19338
19608
|
if (!(0, import_node_fs47.statSync)(full).isDirectory()) continue;
|
|
19339
19609
|
} catch {
|
|
@@ -19353,17 +19623,17 @@ function discoverSkills(worktreePath) {
|
|
|
19353
19623
|
const home = (0, import_node_os15.homedir)();
|
|
19354
19624
|
const collected = [];
|
|
19355
19625
|
for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
|
|
19356
|
-
scanSkillsDir((0,
|
|
19626
|
+
scanSkillsDir((0, import_node_path45.join)(worktreePath, rel), "workspace", collected);
|
|
19357
19627
|
}
|
|
19358
19628
|
for (const abs of [
|
|
19359
|
-
(0,
|
|
19360
|
-
(0,
|
|
19361
|
-
(0,
|
|
19362
|
-
(0,
|
|
19629
|
+
(0, import_node_path45.join)(home, ".claude/skills"),
|
|
19630
|
+
(0, import_node_path45.join)(home, ".cursor/skills"),
|
|
19631
|
+
(0, import_node_path45.join)(home, ".sideboard/skills"),
|
|
19632
|
+
(0, import_node_path45.join)(home, ".brightsy/skills")
|
|
19363
19633
|
]) {
|
|
19364
19634
|
scanSkillsDir(abs, "user", collected);
|
|
19365
19635
|
}
|
|
19366
|
-
scanClaudePluginSkills((0,
|
|
19636
|
+
scanClaudePluginSkills((0, import_node_path45.join)(home, ".claude/plugins"), collected);
|
|
19367
19637
|
collected.push(...bundledSkills());
|
|
19368
19638
|
const rank = {
|
|
19369
19639
|
workspace: 0,
|
|
@@ -19403,13 +19673,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
|
|
|
19403
19673
|
|
|
19404
19674
|
\u2026(truncated)` : raw;
|
|
19405
19675
|
}
|
|
19406
|
-
var import_node_fs47, import_node_os15,
|
|
19676
|
+
var import_node_fs47, import_node_os15, import_node_path45, BUNDLED_SKILL_PREFIX;
|
|
19407
19677
|
var init_discover = __esm({
|
|
19408
19678
|
"src/skills/discover.ts"() {
|
|
19409
19679
|
"use strict";
|
|
19410
19680
|
import_node_fs47 = require("fs");
|
|
19411
19681
|
import_node_os15 = require("os");
|
|
19412
|
-
|
|
19682
|
+
import_node_path45 = require("path");
|
|
19413
19683
|
init_long_running();
|
|
19414
19684
|
BUNDLED_SKILL_PREFIX = "bundled:";
|
|
19415
19685
|
}
|
|
@@ -19530,7 +19800,7 @@ var init_consume_attachments = __esm({
|
|
|
19530
19800
|
// src/skills/detached-job-path.ts
|
|
19531
19801
|
function detachedJobScriptIn(dir) {
|
|
19532
19802
|
for (const name of DETACHED_JOB_FILENAMES) {
|
|
19533
|
-
const script = (0,
|
|
19803
|
+
const script = (0, import_node_path46.join)(dir, "scripts", name);
|
|
19534
19804
|
if ((0, import_node_fs48.existsSync)(script)) return script;
|
|
19535
19805
|
}
|
|
19536
19806
|
return null;
|
|
@@ -19543,11 +19813,11 @@ function packagedDetachedJobPath() {
|
|
|
19543
19813
|
function resolveDetachedJobScript() {
|
|
19544
19814
|
const packaged = packagedDetachedJobPath();
|
|
19545
19815
|
if (packaged) return packaged;
|
|
19546
|
-
let dir = (0,
|
|
19816
|
+
let dir = (0, import_node_path46.dirname)((0, import_node_url3.fileURLToPath)(import_meta3.url));
|
|
19547
19817
|
for (let i = 0; i < 8; i++) {
|
|
19548
19818
|
const candidate = detachedJobScriptIn(dir);
|
|
19549
19819
|
if (candidate) return candidate;
|
|
19550
|
-
const parent = (0,
|
|
19820
|
+
const parent = (0, import_node_path46.dirname)(dir);
|
|
19551
19821
|
if (parent === dir) break;
|
|
19552
19822
|
dir = parent;
|
|
19553
19823
|
}
|
|
@@ -19558,12 +19828,12 @@ function formatDetachedJobInvoke(scriptPath) {
|
|
|
19558
19828
|
if (resolved) return `node ${JSON.stringify(resolved)}`;
|
|
19559
19829
|
return "node scripts/detached-job.cjs";
|
|
19560
19830
|
}
|
|
19561
|
-
var import_node_fs48,
|
|
19831
|
+
var import_node_fs48, import_node_path46, import_node_url3, import_meta3, DETACHED_JOB_FILENAMES;
|
|
19562
19832
|
var init_detached_job_path = __esm({
|
|
19563
19833
|
"src/skills/detached-job-path.ts"() {
|
|
19564
19834
|
"use strict";
|
|
19565
19835
|
import_node_fs48 = require("fs");
|
|
19566
|
-
|
|
19836
|
+
import_node_path46 = require("path");
|
|
19567
19837
|
import_node_url3 = require("url");
|
|
19568
19838
|
init_packaged_runtime();
|
|
19569
19839
|
import_meta3 = {};
|
|
@@ -19723,9 +19993,9 @@ function formatPrGateDirective() {
|
|
|
19723
19993
|
}
|
|
19724
19994
|
function formatProcessGuideDirective(opts) {
|
|
19725
19995
|
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,
|
|
19996
|
+
const hasGraphSkill = !!worktree && (0, import_node_fs49.existsSync)((0, import_node_path47.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
|
|
19997
|
+
const hasReviewSkill = !!worktree && (0, import_node_fs49.existsSync)((0, import_node_path47.join)(worktree, ".claude/skills/review/SKILL.md"));
|
|
19998
|
+
const hasInstallSkill = !!worktree && (0, import_node_fs49.existsSync)((0, import_node_path47.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
|
|
19729
19999
|
return [
|
|
19730
20000
|
"Process guides (recurring work only):",
|
|
19731
20001
|
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 +20033,12 @@ function formatArtifactDirective() {
|
|
|
19763
20033
|
function formatUiReminder() {
|
|
19764
20034
|
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
20035
|
}
|
|
19766
|
-
var import_node_fs49,
|
|
20036
|
+
var import_node_fs49, import_node_path47, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
|
|
19767
20037
|
var init_instructions = __esm({
|
|
19768
20038
|
"src/agents/instructions.ts"() {
|
|
19769
20039
|
"use strict";
|
|
19770
20040
|
import_node_fs49 = require("fs");
|
|
19771
|
-
|
|
20041
|
+
import_node_path47 = require("path");
|
|
19772
20042
|
init_git_auth_mode();
|
|
19773
20043
|
init_branch_prefix();
|
|
19774
20044
|
init_worktree_labels();
|
|
@@ -19992,13 +20262,13 @@ __export(plan_file_exports, {
|
|
|
19992
20262
|
writePlanFile: () => writePlanFile
|
|
19993
20263
|
});
|
|
19994
20264
|
function ensureAttachmentsGitignore(worktreePath) {
|
|
19995
|
-
const gitignoreAbs = (0,
|
|
20265
|
+
const gitignoreAbs = (0, import_node_path48.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
|
|
19996
20266
|
if ((0, import_node_fs50.existsSync)(gitignoreAbs)) return;
|
|
19997
|
-
(0, import_node_fs50.mkdirSync)((0,
|
|
20267
|
+
(0, import_node_fs50.mkdirSync)((0, import_node_path48.dirname)(gitignoreAbs), { recursive: true });
|
|
19998
20268
|
(0, import_node_fs50.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
|
|
19999
20269
|
}
|
|
20000
20270
|
function planFileAbs(worktreePath) {
|
|
20001
|
-
return (0,
|
|
20271
|
+
return (0, import_node_path48.join)(worktreePath, PLAN_FILE_REL);
|
|
20002
20272
|
}
|
|
20003
20273
|
function readTextIfPresent2(abs) {
|
|
20004
20274
|
if (!(0, import_node_fs50.existsSync)(abs)) return null;
|
|
@@ -20010,22 +20280,22 @@ function readTextIfPresent2(abs) {
|
|
|
20010
20280
|
}
|
|
20011
20281
|
}
|
|
20012
20282
|
function readPlanFile(worktreePath) {
|
|
20013
|
-
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0,
|
|
20283
|
+
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
20284
|
}
|
|
20015
20285
|
function writePlanFile(worktreePath, content) {
|
|
20016
20286
|
ensureAttachmentsGitignore(worktreePath);
|
|
20017
20287
|
const abs = planFileAbs(worktreePath);
|
|
20018
|
-
(0, import_node_fs50.mkdirSync)((0,
|
|
20288
|
+
(0, import_node_fs50.mkdirSync)((0, import_node_path48.dirname)(abs), { recursive: true });
|
|
20019
20289
|
const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
|
|
20020
20290
|
(0, import_node_fs50.writeFileSync)(abs, body, "utf8");
|
|
20021
20291
|
return PLAN_FILE_REL;
|
|
20022
20292
|
}
|
|
20023
|
-
var import_node_fs50,
|
|
20293
|
+
var import_node_fs50, import_node_path48;
|
|
20024
20294
|
var init_plan_file = __esm({
|
|
20025
20295
|
"src/plan/plan-file.ts"() {
|
|
20026
20296
|
"use strict";
|
|
20027
20297
|
import_node_fs50 = require("fs");
|
|
20028
|
-
|
|
20298
|
+
import_node_path48 = require("path");
|
|
20029
20299
|
init_workspace_scratch();
|
|
20030
20300
|
init_plan_present();
|
|
20031
20301
|
init_plan_present();
|
|
@@ -20085,7 +20355,7 @@ function setCaffeinateHoldHooks(next) {
|
|
|
20085
20355
|
hooks = next;
|
|
20086
20356
|
}
|
|
20087
20357
|
function caffeinateHoldPath() {
|
|
20088
|
-
return (0,
|
|
20358
|
+
return (0, import_node_path49.join)(appDataDir(), "caffeinate-hold.json");
|
|
20089
20359
|
}
|
|
20090
20360
|
function processAlive(pid) {
|
|
20091
20361
|
if (hooks.processAlive) return hooks.processAlive(pid);
|
|
@@ -20228,13 +20498,13 @@ function releaseCaffeinateHoldForThread(threadId) {
|
|
|
20228
20498
|
}
|
|
20229
20499
|
return setCaffeinateHold(false, { threadId: id });
|
|
20230
20500
|
}
|
|
20231
|
-
var import_node_child_process5, import_node_fs51,
|
|
20501
|
+
var import_node_child_process5, import_node_fs51, import_node_path49, hooks;
|
|
20232
20502
|
var init_caffeinate_hold = __esm({
|
|
20233
20503
|
"src/store/caffeinate-hold.ts"() {
|
|
20234
20504
|
"use strict";
|
|
20235
20505
|
import_node_child_process5 = require("child_process");
|
|
20236
20506
|
import_node_fs51 = require("fs");
|
|
20237
|
-
|
|
20507
|
+
import_node_path49 = require("path");
|
|
20238
20508
|
init_paths();
|
|
20239
20509
|
init_private_file();
|
|
20240
20510
|
hooks = {};
|
|
@@ -20243,7 +20513,7 @@ var init_caffeinate_hold = __esm({
|
|
|
20243
20513
|
|
|
20244
20514
|
// src/store/schedules.ts
|
|
20245
20515
|
function schedulesPath() {
|
|
20246
|
-
return (0,
|
|
20516
|
+
return (0, import_node_path50.join)(appDataDir(), "schedules.json");
|
|
20247
20517
|
}
|
|
20248
20518
|
function parseDurationMs(every) {
|
|
20249
20519
|
const m = every.trim().match(DURATION_RE);
|
|
@@ -20457,13 +20727,13 @@ function recordScheduleRun(id, result) {
|
|
|
20457
20727
|
writeAll2(rows);
|
|
20458
20728
|
return next;
|
|
20459
20729
|
}
|
|
20460
|
-
var import_node_crypto11, import_node_fs52,
|
|
20730
|
+
var import_node_crypto11, import_node_fs52, import_node_path50, import_croner, DURATION_RE, UNIT_MS;
|
|
20461
20731
|
var init_schedules = __esm({
|
|
20462
20732
|
"src/store/schedules.ts"() {
|
|
20463
20733
|
"use strict";
|
|
20464
20734
|
import_node_crypto11 = require("crypto");
|
|
20465
20735
|
import_node_fs52 = require("fs");
|
|
20466
|
-
|
|
20736
|
+
import_node_path50 = require("path");
|
|
20467
20737
|
import_croner = require("croner");
|
|
20468
20738
|
init_orchestrator_capable();
|
|
20469
20739
|
init_paths();
|
|
@@ -20603,37 +20873,6 @@ var init_schedule_runner = __esm({
|
|
|
20603
20873
|
}
|
|
20604
20874
|
});
|
|
20605
20875
|
|
|
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
20876
|
// src/agents/cursor-recover.ts
|
|
20638
20877
|
var cursor_recover_exports = {};
|
|
20639
20878
|
__export(cursor_recover_exports, {
|
|
@@ -20843,6 +21082,7 @@ var init_orchestrator = __esm({
|
|
|
20843
21082
|
init_conductor();
|
|
20844
21083
|
init_setup_log();
|
|
20845
21084
|
init_orphan_cleanup();
|
|
21085
|
+
init_history_cleanup();
|
|
20846
21086
|
init_apply_into_main();
|
|
20847
21087
|
init_clone_repo();
|
|
20848
21088
|
init_message_parts();
|
|
@@ -21030,6 +21270,12 @@ var init_orchestrator = __esm({
|
|
|
21030
21270
|
}
|
|
21031
21271
|
} catch {
|
|
21032
21272
|
}
|
|
21273
|
+
try {
|
|
21274
|
+
if (shouldRunHistoryCleanup()) {
|
|
21275
|
+
cleanupArchivedHistory();
|
|
21276
|
+
}
|
|
21277
|
+
} catch {
|
|
21278
|
+
}
|
|
21033
21279
|
if (drainQueues) {
|
|
21034
21280
|
this.adoptPersistedQueues();
|
|
21035
21281
|
}
|
|
@@ -22358,6 +22604,20 @@ var init_orchestrator = __esm({
|
|
|
22358
22604
|
repoPaths
|
|
22359
22605
|
});
|
|
22360
22606
|
}
|
|
22607
|
+
/** Bound Settings → History. After archive always; reconcile is interval-gated. */
|
|
22608
|
+
enforceHistoryRetention() {
|
|
22609
|
+
try {
|
|
22610
|
+
cleanupArchivedHistory();
|
|
22611
|
+
} catch {
|
|
22612
|
+
}
|
|
22613
|
+
}
|
|
22614
|
+
cleanupHistory(opts) {
|
|
22615
|
+
return cleanupArchivedHistory({
|
|
22616
|
+
dryRun: opts?.dryRun,
|
|
22617
|
+
purgeOlderThanDays: opts?.purgeOlderThanDays,
|
|
22618
|
+
force: opts?.force
|
|
22619
|
+
});
|
|
22620
|
+
}
|
|
22361
22621
|
/**
|
|
22362
22622
|
* Best-of-n / fanout: create N threads (one per agent) with the same prompt.
|
|
22363
22623
|
*/
|
|
@@ -22918,6 +23178,7 @@ var init_orchestrator = __esm({
|
|
|
22918
23178
|
if (isGlobalThread(thread)) {
|
|
22919
23179
|
const archived2 = setStatus(thread.id, "archived");
|
|
22920
23180
|
this.emit({ type: "status_changed", threadId: archived2.id, status: "archived" });
|
|
23181
|
+
this.enforceHistoryRetention();
|
|
22921
23182
|
return archived2;
|
|
22922
23183
|
}
|
|
22923
23184
|
const siblings = threadsSharingWorktree(thread.worktreePath).filter((t) => t.id !== thread.id);
|
|
@@ -22939,6 +23200,7 @@ var init_orchestrator = __esm({
|
|
|
22939
23200
|
}
|
|
22940
23201
|
const archived = setStatus(thread.id, "archived");
|
|
22941
23202
|
this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
|
|
23203
|
+
this.enforceHistoryRetention();
|
|
22942
23204
|
if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
|
|
22943
23205
|
try {
|
|
22944
23206
|
const { ensureWorkspace: ensureWorkspace2 } = await Promise.resolve().then(() => (init_workspaces2(), workspaces_exports));
|