@sideboard-ai/core 0.1.98 → 0.1.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/cursor-runner.cjs +47 -2
- package/dist/agents/cursor-runner.js +47 -2
- package/dist/index.cjs +448 -372
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +165 -98
- package/dist/mcp/run-stdio.cjs +193 -142
- package/dist/mcp/run-stdio.js +113 -63
- package/package.json +1 -1
package/dist/mcp/run-stdio.cjs
CHANGED
|
@@ -8644,40 +8644,40 @@ __export(plan_file_exports, {
|
|
|
8644
8644
|
writePlanFile: () => writePlanFile
|
|
8645
8645
|
});
|
|
8646
8646
|
function ensureAttachmentsGitignore2(worktreePath) {
|
|
8647
|
-
const gitignoreAbs = (0,
|
|
8648
|
-
if ((0,
|
|
8649
|
-
(0,
|
|
8650
|
-
(0,
|
|
8647
|
+
const gitignoreAbs = (0, import_node_path36.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
|
|
8648
|
+
if ((0, import_node_fs39.existsSync)(gitignoreAbs)) return;
|
|
8649
|
+
(0, import_node_fs39.mkdirSync)((0, import_node_path36.dirname)(gitignoreAbs), { recursive: true });
|
|
8650
|
+
(0, import_node_fs39.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
|
|
8651
8651
|
}
|
|
8652
8652
|
function planFileAbs(worktreePath) {
|
|
8653
|
-
return (0,
|
|
8653
|
+
return (0, import_node_path36.join)(worktreePath, PLAN_FILE_REL);
|
|
8654
8654
|
}
|
|
8655
8655
|
function readTextIfPresent2(abs) {
|
|
8656
|
-
if (!(0,
|
|
8656
|
+
if (!(0, import_node_fs39.existsSync)(abs)) return null;
|
|
8657
8657
|
try {
|
|
8658
|
-
const content = (0,
|
|
8658
|
+
const content = (0, import_node_fs39.readFileSync)(abs, "utf8");
|
|
8659
8659
|
return content.trim() ? content : null;
|
|
8660
8660
|
} catch {
|
|
8661
8661
|
return null;
|
|
8662
8662
|
}
|
|
8663
8663
|
}
|
|
8664
8664
|
function readPlanFile(worktreePath) {
|
|
8665
|
-
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0,
|
|
8665
|
+
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path36.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path36.join)(worktreePath, LEGACY_PLAN_FILE_REL));
|
|
8666
8666
|
}
|
|
8667
8667
|
function writePlanFile(worktreePath, content) {
|
|
8668
8668
|
ensureAttachmentsGitignore2(worktreePath);
|
|
8669
8669
|
const abs = planFileAbs(worktreePath);
|
|
8670
|
-
(0,
|
|
8670
|
+
(0, import_node_fs39.mkdirSync)((0, import_node_path36.dirname)(abs), { recursive: true });
|
|
8671
8671
|
const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
|
|
8672
|
-
(0,
|
|
8672
|
+
(0, import_node_fs39.writeFileSync)(abs, body, "utf8");
|
|
8673
8673
|
return PLAN_FILE_REL;
|
|
8674
8674
|
}
|
|
8675
|
-
var
|
|
8675
|
+
var import_node_fs39, import_node_path36;
|
|
8676
8676
|
var init_plan_file = __esm({
|
|
8677
8677
|
"src/plan/plan-file.ts"() {
|
|
8678
8678
|
"use strict";
|
|
8679
|
-
|
|
8680
|
-
|
|
8679
|
+
import_node_fs39 = require("fs");
|
|
8680
|
+
import_node_path36 = require("path");
|
|
8681
8681
|
init_workspace_scratch();
|
|
8682
8682
|
init_plan_present();
|
|
8683
8683
|
init_plan_present();
|
|
@@ -8698,7 +8698,7 @@ function setCaffeinateHoldHooks(next) {
|
|
|
8698
8698
|
hooks = next;
|
|
8699
8699
|
}
|
|
8700
8700
|
function caffeinateHoldPath() {
|
|
8701
|
-
return (0,
|
|
8701
|
+
return (0, import_node_path37.join)(appDataDir(), "caffeinate-hold.json");
|
|
8702
8702
|
}
|
|
8703
8703
|
function processAlive(pid) {
|
|
8704
8704
|
if (hooks.processAlive) return hooks.processAlive(pid);
|
|
@@ -8732,9 +8732,9 @@ function uniqueIds(ids) {
|
|
|
8732
8732
|
}
|
|
8733
8733
|
function readHold() {
|
|
8734
8734
|
const path = caffeinateHoldPath();
|
|
8735
|
-
if (!(0,
|
|
8735
|
+
if (!(0, import_node_fs40.existsSync)(path)) return null;
|
|
8736
8736
|
try {
|
|
8737
|
-
const parsed = JSON.parse((0,
|
|
8737
|
+
const parsed = JSON.parse((0, import_node_fs40.readFileSync)(path, "utf8"));
|
|
8738
8738
|
if (typeof parsed?.pid === "number" && parsed.pid > 0) {
|
|
8739
8739
|
return {
|
|
8740
8740
|
pid: parsed.pid,
|
|
@@ -8756,7 +8756,7 @@ function writeHold(pid, threadIds) {
|
|
|
8756
8756
|
}
|
|
8757
8757
|
function clearHold() {
|
|
8758
8758
|
try {
|
|
8759
|
-
(0,
|
|
8759
|
+
(0, import_node_fs40.unlinkSync)(caffeinateHoldPath());
|
|
8760
8760
|
} catch {
|
|
8761
8761
|
}
|
|
8762
8762
|
}
|
|
@@ -8841,13 +8841,13 @@ function releaseCaffeinateHoldForThread(threadId) {
|
|
|
8841
8841
|
}
|
|
8842
8842
|
return setCaffeinateHold(false, { threadId: id });
|
|
8843
8843
|
}
|
|
8844
|
-
var import_node_child_process4,
|
|
8844
|
+
var import_node_child_process4, import_node_fs40, import_node_path37, hooks;
|
|
8845
8845
|
var init_caffeinate_hold = __esm({
|
|
8846
8846
|
"src/store/caffeinate-hold.ts"() {
|
|
8847
8847
|
"use strict";
|
|
8848
8848
|
import_node_child_process4 = require("child_process");
|
|
8849
|
-
|
|
8850
|
-
|
|
8849
|
+
import_node_fs40 = require("fs");
|
|
8850
|
+
import_node_path37 = require("path");
|
|
8851
8851
|
init_paths();
|
|
8852
8852
|
init_private_file();
|
|
8853
8853
|
hooks = {};
|
|
@@ -8862,10 +8862,10 @@ __export(cursor_recover_exports, {
|
|
|
8862
8862
|
function recoverFinishedCursorRun(opts) {
|
|
8863
8863
|
const agentId = opts.agentId.trim();
|
|
8864
8864
|
if (!agentId) return null;
|
|
8865
|
-
const runsPath = (0,
|
|
8866
|
-
if (!(0,
|
|
8865
|
+
const runsPath = (0, import_node_path38.join)(appDataDir(), "cursor-sdk-store", "runs.ndjson");
|
|
8866
|
+
if (!(0, import_node_fs41.existsSync)(runsPath)) return null;
|
|
8867
8867
|
try {
|
|
8868
|
-
const lines = (0,
|
|
8868
|
+
const lines = (0, import_node_fs41.readFileSync)(runsPath, "utf8").split("\n");
|
|
8869
8869
|
let best = null;
|
|
8870
8870
|
for (const line of lines) {
|
|
8871
8871
|
const trimmed = line.trim();
|
|
@@ -8891,12 +8891,12 @@ function recoverFinishedCursorRun(opts) {
|
|
|
8891
8891
|
return null;
|
|
8892
8892
|
}
|
|
8893
8893
|
}
|
|
8894
|
-
var
|
|
8894
|
+
var import_node_fs41, import_node_path38;
|
|
8895
8895
|
var init_cursor_recover = __esm({
|
|
8896
8896
|
"src/agents/cursor-recover.ts"() {
|
|
8897
8897
|
"use strict";
|
|
8898
|
-
|
|
8899
|
-
|
|
8898
|
+
import_node_fs41 = require("fs");
|
|
8899
|
+
import_node_path38 = require("path");
|
|
8900
8900
|
init_paths();
|
|
8901
8901
|
}
|
|
8902
8902
|
});
|
|
@@ -8908,7 +8908,7 @@ init_nested_electron_env();
|
|
|
8908
8908
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
8909
8909
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
8910
8910
|
var import_zod3 = require("zod");
|
|
8911
|
-
var
|
|
8911
|
+
var import_node_path39 = require("path");
|
|
8912
8912
|
|
|
8913
8913
|
// src/orchestrator/orchestrator.ts
|
|
8914
8914
|
var import_node_events = require("events");
|
|
@@ -9419,7 +9419,7 @@ async function refreshSlackReplyBadges(opts) {
|
|
|
9419
9419
|
}
|
|
9420
9420
|
|
|
9421
9421
|
// src/orchestrator/orchestrator.ts
|
|
9422
|
-
var
|
|
9422
|
+
var import_node_fs42 = require("fs");
|
|
9423
9423
|
init_error_detail();
|
|
9424
9424
|
|
|
9425
9425
|
// src/agents/spawn.ts
|
|
@@ -10536,8 +10536,44 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
10536
10536
|
// src/orchestrator/orchestrator.ts
|
|
10537
10537
|
init_thread_store();
|
|
10538
10538
|
|
|
10539
|
-
// src/
|
|
10539
|
+
// src/store/desktop-host.ts
|
|
10540
10540
|
var import_node_fs30 = require("fs");
|
|
10541
|
+
var import_node_path29 = require("path");
|
|
10542
|
+
init_paths();
|
|
10543
|
+
function desktopHostPidPath() {
|
|
10544
|
+
return (0, import_node_path29.join)(appDataDir(), "desktop-host.pid");
|
|
10545
|
+
}
|
|
10546
|
+
function readDesktopHostPid() {
|
|
10547
|
+
try {
|
|
10548
|
+
const pid = Number.parseInt((0, import_node_fs30.readFileSync)(desktopHostPidPath(), "utf8").trim(), 10);
|
|
10549
|
+
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
10550
|
+
return pid;
|
|
10551
|
+
} catch {
|
|
10552
|
+
return null;
|
|
10553
|
+
}
|
|
10554
|
+
}
|
|
10555
|
+
function pidAlive(pid) {
|
|
10556
|
+
try {
|
|
10557
|
+
process.kill(pid, 0);
|
|
10558
|
+
return true;
|
|
10559
|
+
} catch {
|
|
10560
|
+
return false;
|
|
10561
|
+
}
|
|
10562
|
+
}
|
|
10563
|
+
function isDesktopHostAlive() {
|
|
10564
|
+
const pid = readDesktopHostPid();
|
|
10565
|
+
return pid != null && pidAlive(pid);
|
|
10566
|
+
}
|
|
10567
|
+
function isThisProcessDesktopHost() {
|
|
10568
|
+
return readDesktopHostPid() === process.pid && pidAlive(process.pid);
|
|
10569
|
+
}
|
|
10570
|
+
function thisProcessShouldDrainAgentQueues() {
|
|
10571
|
+
if (isThisProcessDesktopHost()) return true;
|
|
10572
|
+
return !isDesktopHostAlive();
|
|
10573
|
+
}
|
|
10574
|
+
|
|
10575
|
+
// src/threads/create.ts
|
|
10576
|
+
var import_node_fs31 = require("fs");
|
|
10541
10577
|
|
|
10542
10578
|
// src/detect/detect.ts
|
|
10543
10579
|
init_agents();
|
|
@@ -10582,7 +10618,7 @@ async function createThread(input, _onSetupLine) {
|
|
|
10582
10618
|
});
|
|
10583
10619
|
await requireAgent(resolved.agent);
|
|
10584
10620
|
const repoPath = await resolveRepoRoot(input.repoPath);
|
|
10585
|
-
if (!(0,
|
|
10621
|
+
if (!(0, import_node_fs31.existsSync)(repoPath)) {
|
|
10586
10622
|
throw new Error(`Repo not found: ${repoPath}`);
|
|
10587
10623
|
}
|
|
10588
10624
|
let sourceRef = input.sourceRef;
|
|
@@ -11058,8 +11094,8 @@ function forkChatTab(input) {
|
|
|
11058
11094
|
|
|
11059
11095
|
// src/review/request-review.ts
|
|
11060
11096
|
var import_node_crypto5 = require("crypto");
|
|
11061
|
-
var
|
|
11062
|
-
var
|
|
11097
|
+
var import_node_fs32 = require("fs");
|
|
11098
|
+
var import_node_path30 = require("path");
|
|
11063
11099
|
init_global_workspace();
|
|
11064
11100
|
init_thread_store();
|
|
11065
11101
|
|
|
@@ -11207,22 +11243,22 @@ function shouldRefreshReviewRequestTemplate(content) {
|
|
|
11207
11243
|
return LEGACY_REVIEW_TEMPLATE_MARKERS.every((m) => trimmed.includes(m));
|
|
11208
11244
|
}
|
|
11209
11245
|
function readTextIfPresent(abs) {
|
|
11210
|
-
if (!(0,
|
|
11246
|
+
if (!(0, import_node_fs32.existsSync)(abs)) return null;
|
|
11211
11247
|
try {
|
|
11212
|
-
const content = (0,
|
|
11248
|
+
const content = (0, import_node_fs32.readFileSync)(abs, "utf8");
|
|
11213
11249
|
return content.trim() ? content : null;
|
|
11214
11250
|
} catch {
|
|
11215
11251
|
return null;
|
|
11216
11252
|
}
|
|
11217
11253
|
}
|
|
11218
11254
|
function ensureAttachmentsGitignore(worktreePath) {
|
|
11219
|
-
const gitignoreAbs = (0,
|
|
11220
|
-
if ((0,
|
|
11221
|
-
(0,
|
|
11222
|
-
(0,
|
|
11255
|
+
const gitignoreAbs = (0, import_node_path30.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
|
|
11256
|
+
if ((0, import_node_fs32.existsSync)(gitignoreAbs)) return;
|
|
11257
|
+
(0, import_node_fs32.mkdirSync)((0, import_node_path30.dirname)(gitignoreAbs), { recursive: true });
|
|
11258
|
+
(0, import_node_fs32.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
|
|
11223
11259
|
}
|
|
11224
11260
|
function resolveReviewGuidelines(worktreePath) {
|
|
11225
|
-
const repoAbs = (0,
|
|
11261
|
+
const repoAbs = (0, import_node_path30.join)(worktreePath, REPO_REVIEW_PATH);
|
|
11226
11262
|
const repoContent = readTextIfPresent(repoAbs);
|
|
11227
11263
|
if (repoContent) {
|
|
11228
11264
|
return {
|
|
@@ -11232,7 +11268,7 @@ function resolveReviewGuidelines(worktreePath) {
|
|
|
11232
11268
|
source: "repo"
|
|
11233
11269
|
};
|
|
11234
11270
|
}
|
|
11235
|
-
const localAbs = (0,
|
|
11271
|
+
const localAbs = (0, import_node_path30.join)(worktreePath, REVIEW_REQUEST_PATH);
|
|
11236
11272
|
const localContent = readTextIfPresent(localAbs);
|
|
11237
11273
|
if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
|
|
11238
11274
|
return {
|
|
@@ -11242,7 +11278,7 @@ function resolveReviewGuidelines(worktreePath) {
|
|
|
11242
11278
|
source: "local"
|
|
11243
11279
|
};
|
|
11244
11280
|
}
|
|
11245
|
-
const legacyAbs = (0,
|
|
11281
|
+
const legacyAbs = (0, import_node_path30.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
|
|
11246
11282
|
const legacyContent = readTextIfPresent(legacyAbs);
|
|
11247
11283
|
if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
|
|
11248
11284
|
return {
|
|
@@ -11253,8 +11289,8 @@ function resolveReviewGuidelines(worktreePath) {
|
|
|
11253
11289
|
};
|
|
11254
11290
|
}
|
|
11255
11291
|
ensureAttachmentsGitignore(worktreePath);
|
|
11256
|
-
(0,
|
|
11257
|
-
(0,
|
|
11292
|
+
(0, import_node_fs32.mkdirSync)((0, import_node_path30.dirname)(localAbs), { recursive: true });
|
|
11293
|
+
(0, import_node_fs32.writeFileSync)(localAbs, REVIEW_REQUEST_TEMPLATE, "utf8");
|
|
11258
11294
|
return {
|
|
11259
11295
|
path: REVIEW_REQUEST_PATH,
|
|
11260
11296
|
name: REVIEW_REQUEST_NAME,
|
|
@@ -11454,21 +11490,21 @@ function createQuotaFailoverChat(from, fallbackAgent, limitText) {
|
|
|
11454
11490
|
|
|
11455
11491
|
// src/threads/adopt.ts
|
|
11456
11492
|
var import_node_child_process3 = require("child_process");
|
|
11457
|
-
var
|
|
11493
|
+
var import_node_fs33 = require("fs");
|
|
11458
11494
|
var import_node_os10 = require("os");
|
|
11459
|
-
var
|
|
11495
|
+
var import_node_path31 = require("path");
|
|
11460
11496
|
var import_node_module4 = require("module");
|
|
11461
11497
|
init_worktree();
|
|
11462
11498
|
init_thread_store();
|
|
11463
11499
|
var import_meta4 = {};
|
|
11464
|
-
var CONDUCTOR_APP_SUPPORT = (0,
|
|
11500
|
+
var CONDUCTOR_APP_SUPPORT = (0, import_node_path31.join)(
|
|
11465
11501
|
process.env.HOME ?? "",
|
|
11466
11502
|
"Library",
|
|
11467
11503
|
"Application Support",
|
|
11468
11504
|
"com.conductor.app"
|
|
11469
11505
|
);
|
|
11470
|
-
var CONDUCTOR_DB = (0,
|
|
11471
|
-
var CURSOR_SDK_STORE = (0,
|
|
11506
|
+
var CONDUCTOR_DB = (0, import_node_path31.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
|
|
11507
|
+
var CURSOR_SDK_STORE = (0, import_node_path31.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
|
|
11472
11508
|
function openReadonlySqlite(file) {
|
|
11473
11509
|
const req = (0, import_node_module4.createRequire)(import_meta4.url);
|
|
11474
11510
|
const Database = req("better-sqlite3");
|
|
@@ -11485,21 +11521,21 @@ function mapAgentType(raw) {
|
|
|
11485
11521
|
return null;
|
|
11486
11522
|
}
|
|
11487
11523
|
function resolveConductorCursorAgentId(workspacePath) {
|
|
11488
|
-
if (!workspacePath || !(0,
|
|
11524
|
+
if (!workspacePath || !(0, import_node_fs33.existsSync)(CURSOR_SDK_STORE)) return null;
|
|
11489
11525
|
const normalized = workspacePath.replace(/\/$/, "");
|
|
11490
11526
|
let best = null;
|
|
11491
11527
|
let hashes;
|
|
11492
11528
|
try {
|
|
11493
|
-
hashes = (0,
|
|
11529
|
+
hashes = (0, import_node_fs33.readdirSync)(CURSOR_SDK_STORE);
|
|
11494
11530
|
} catch {
|
|
11495
11531
|
return null;
|
|
11496
11532
|
}
|
|
11497
11533
|
for (const hash of hashes) {
|
|
11498
|
-
const agentsFile = (0,
|
|
11499
|
-
if (!(0,
|
|
11534
|
+
const agentsFile = (0, import_node_path31.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
|
|
11535
|
+
if (!(0, import_node_fs33.existsSync)(agentsFile)) continue;
|
|
11500
11536
|
let text3;
|
|
11501
11537
|
try {
|
|
11502
|
-
text3 = (0,
|
|
11538
|
+
text3 = (0, import_node_fs33.readFileSync)(agentsFile, "utf8");
|
|
11503
11539
|
} catch {
|
|
11504
11540
|
continue;
|
|
11505
11541
|
}
|
|
@@ -11523,7 +11559,7 @@ function resolveConductorCursorAgentId(workspacePath) {
|
|
|
11523
11559
|
return best?.agentId ?? null;
|
|
11524
11560
|
}
|
|
11525
11561
|
async function adoptThread(input) {
|
|
11526
|
-
if (!(0,
|
|
11562
|
+
if (!(0, import_node_fs33.existsSync)(input.worktreePath)) {
|
|
11527
11563
|
throw new Error(`Worktree not found: ${input.worktreePath}`);
|
|
11528
11564
|
}
|
|
11529
11565
|
const repoPath = await resolveRepoRoot(input.worktreePath);
|
|
@@ -11547,18 +11583,18 @@ async function adoptThread(input) {
|
|
|
11547
11583
|
return thread;
|
|
11548
11584
|
}
|
|
11549
11585
|
function listConductorWorkspaces() {
|
|
11550
|
-
if (!(0,
|
|
11586
|
+
if (!(0, import_node_fs33.existsSync)(CONDUCTOR_DB)) {
|
|
11551
11587
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
11552
11588
|
}
|
|
11553
|
-
const tmp = (0,
|
|
11554
|
-
const snapshot = (0,
|
|
11589
|
+
const tmp = (0, import_node_fs33.mkdtempSync)((0, import_node_path31.join)((0, import_node_os10.tmpdir)(), "sideboard-conductor-"));
|
|
11590
|
+
const snapshot = (0, import_node_path31.join)(tmp, "conductor.db");
|
|
11555
11591
|
try {
|
|
11556
|
-
(0,
|
|
11592
|
+
(0, import_node_fs33.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
11557
11593
|
for (const suffix of ["-wal", "-shm"]) {
|
|
11558
11594
|
const src = `${CONDUCTOR_DB}${suffix}`;
|
|
11559
|
-
if ((0,
|
|
11595
|
+
if ((0, import_node_fs33.existsSync)(src)) {
|
|
11560
11596
|
try {
|
|
11561
|
-
(0,
|
|
11597
|
+
(0, import_node_fs33.copyFileSync)(src, `${snapshot}${suffix}`);
|
|
11562
11598
|
} catch {
|
|
11563
11599
|
}
|
|
11564
11600
|
}
|
|
@@ -11634,22 +11670,22 @@ function listConductorWorkspaces() {
|
|
|
11634
11670
|
db.close();
|
|
11635
11671
|
}
|
|
11636
11672
|
} finally {
|
|
11637
|
-
(0,
|
|
11673
|
+
(0, import_node_fs33.rmSync)(tmp, { recursive: true, force: true });
|
|
11638
11674
|
}
|
|
11639
11675
|
}
|
|
11640
11676
|
function importConductorWorkspace(workspaceId) {
|
|
11641
|
-
if (!(0,
|
|
11677
|
+
if (!(0, import_node_fs33.existsSync)(CONDUCTOR_DB)) {
|
|
11642
11678
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
11643
11679
|
}
|
|
11644
|
-
const tmp = (0,
|
|
11645
|
-
const snapshot = (0,
|
|
11680
|
+
const tmp = (0, import_node_fs33.mkdtempSync)((0, import_node_path31.join)((0, import_node_os10.tmpdir)(), "sideboard-conductor-"));
|
|
11681
|
+
const snapshot = (0, import_node_path31.join)(tmp, "conductor.db");
|
|
11646
11682
|
try {
|
|
11647
|
-
(0,
|
|
11683
|
+
(0, import_node_fs33.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
11648
11684
|
for (const suffix of ["-wal", "-shm"]) {
|
|
11649
11685
|
const src = `${CONDUCTOR_DB}${suffix}`;
|
|
11650
|
-
if ((0,
|
|
11686
|
+
if ((0, import_node_fs33.existsSync)(src)) {
|
|
11651
11687
|
try {
|
|
11652
|
-
(0,
|
|
11688
|
+
(0, import_node_fs33.copyFileSync)(src, `${snapshot}${suffix}`);
|
|
11653
11689
|
} catch {
|
|
11654
11690
|
}
|
|
11655
11691
|
}
|
|
@@ -11667,7 +11703,7 @@ function importConductorWorkspace(workspaceId) {
|
|
|
11667
11703
|
).get(workspaceId);
|
|
11668
11704
|
if (!row) throw new Error(`Conductor workspace not found: ${workspaceId}`);
|
|
11669
11705
|
const worktreePath = String(row.workspacePath);
|
|
11670
|
-
if (!(0,
|
|
11706
|
+
if (!(0, import_node_fs33.existsSync)(worktreePath)) {
|
|
11671
11707
|
throw new Error(`Conductor worktree missing on disk: ${worktreePath}`);
|
|
11672
11708
|
}
|
|
11673
11709
|
let sessionId = null;
|
|
@@ -11730,7 +11766,7 @@ function importConductorWorkspace(workspaceId) {
|
|
|
11730
11766
|
db.close();
|
|
11731
11767
|
}
|
|
11732
11768
|
} finally {
|
|
11733
|
-
(0,
|
|
11769
|
+
(0, import_node_fs33.rmSync)(tmp, { recursive: true, force: true });
|
|
11734
11770
|
}
|
|
11735
11771
|
}
|
|
11736
11772
|
async function importConductorWorkspaceAsync(workspaceId) {
|
|
@@ -11738,7 +11774,7 @@ async function importConductorWorkspaceAsync(workspaceId) {
|
|
|
11738
11774
|
}
|
|
11739
11775
|
|
|
11740
11776
|
// src/threads/stack-layers.ts
|
|
11741
|
-
var
|
|
11777
|
+
var import_node_fs34 = require("fs");
|
|
11742
11778
|
init_run();
|
|
11743
11779
|
init_stack();
|
|
11744
11780
|
init_worktree();
|
|
@@ -11806,7 +11842,7 @@ async function openStackLayer(input, _onSetupLine) {
|
|
|
11806
11842
|
let createdWorktree = false;
|
|
11807
11843
|
const trees = await listWorktrees(repoPath);
|
|
11808
11844
|
const checkedOut = trees.find((w) => w.branch === branchName);
|
|
11809
|
-
if (checkedOut?.path && (0,
|
|
11845
|
+
if (checkedOut?.path && (0, import_node_fs34.existsSync)(checkedOut.path)) {
|
|
11810
11846
|
if (input.reuseExistingWorktree !== false) {
|
|
11811
11847
|
worktreePath = checkedOut.path;
|
|
11812
11848
|
} else {
|
|
@@ -11948,7 +11984,7 @@ async function initStackFromThread(input, onSetupLine) {
|
|
|
11948
11984
|
async function createPrStack(input, onSetupLine) {
|
|
11949
11985
|
await requireAgent(input.agent);
|
|
11950
11986
|
const repoPath = await resolveRepoRoot(input.repoPath);
|
|
11951
|
-
if (!(0,
|
|
11987
|
+
if (!(0, import_node_fs34.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
|
|
11952
11988
|
if (!input.branches.length) throw new Error("At least one branch name required");
|
|
11953
11989
|
const status = await detectGhStack(repoPath);
|
|
11954
11990
|
if (!status.available) throw new Error(status.reason);
|
|
@@ -12015,7 +12051,7 @@ async function createPrStack(input, onSetupLine) {
|
|
|
12015
12051
|
}
|
|
12016
12052
|
}
|
|
12017
12053
|
const claimed = new Set(threads.map((t) => t.worktreePath));
|
|
12018
|
-
if (!claimed.has(bootstrap.worktreePath) && (0,
|
|
12054
|
+
if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs34.existsSync)(bootstrap.worktreePath)) {
|
|
12019
12055
|
try {
|
|
12020
12056
|
await removeWorktree(repoPath, bootstrap.worktreePath, {
|
|
12021
12057
|
deleteBranch: bootstrap.branchName
|
|
@@ -12030,12 +12066,12 @@ async function createPrStack(input, onSetupLine) {
|
|
|
12030
12066
|
init_worktree();
|
|
12031
12067
|
|
|
12032
12068
|
// src/diff/diff.ts
|
|
12033
|
-
var
|
|
12034
|
-
var
|
|
12069
|
+
var import_node_fs35 = require("fs");
|
|
12070
|
+
var import_node_path32 = require("path");
|
|
12035
12071
|
init_run();
|
|
12036
12072
|
init_worktree();
|
|
12037
12073
|
async function inspectGitWorktree(worktreePath) {
|
|
12038
|
-
if (!worktreePath || !(0,
|
|
12074
|
+
if (!worktreePath || !(0, import_node_fs35.existsSync)(worktreePath)) return "missing_worktree";
|
|
12039
12075
|
const check = await git(["rev-parse", "--is-inside-work-tree"], worktreePath, {
|
|
12040
12076
|
reject: false
|
|
12041
12077
|
});
|
|
@@ -12043,7 +12079,7 @@ async function inspectGitWorktree(worktreePath) {
|
|
|
12043
12079
|
return "ok";
|
|
12044
12080
|
}
|
|
12045
12081
|
async function initializeGitRepository(worktreePath) {
|
|
12046
|
-
if (!worktreePath || !(0,
|
|
12082
|
+
if (!worktreePath || !(0, import_node_fs35.existsSync)(worktreePath)) {
|
|
12047
12083
|
throw new Error("Worktree not found");
|
|
12048
12084
|
}
|
|
12049
12085
|
const status = await inspectGitWorktree(worktreePath);
|
|
@@ -12179,11 +12215,11 @@ new file mode 100644
|
|
|
12179
12215
|
};
|
|
12180
12216
|
}
|
|
12181
12217
|
async function untrackedPatch(worktreePath, path, maxHunk) {
|
|
12182
|
-
const abs = (0,
|
|
12218
|
+
const abs = (0, import_node_path32.join)(worktreePath, path);
|
|
12183
12219
|
try {
|
|
12184
|
-
const st = (0,
|
|
12220
|
+
const st = (0, import_node_fs35.statSync)(abs);
|
|
12185
12221
|
if (st.isFile() && st.size > maxHunk) {
|
|
12186
|
-
const buf = (0,
|
|
12222
|
+
const buf = (0, import_node_fs35.readFileSync)(abs).subarray(0, maxHunk);
|
|
12187
12223
|
return syntheticAddPatch(path, buf.toString("utf8"), maxHunk);
|
|
12188
12224
|
}
|
|
12189
12225
|
} catch {
|
|
@@ -12684,8 +12720,8 @@ var DEFAULT_UPLOAD_MAX_BYTES = 5e7;
|
|
|
12684
12720
|
function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
12685
12721
|
assertSafeRelativePath(relativePath);
|
|
12686
12722
|
const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
|
|
12687
|
-
const abs = (0,
|
|
12688
|
-
const st = (0,
|
|
12723
|
+
const abs = (0, import_node_path32.join)(worktreePath, relativePath);
|
|
12724
|
+
const st = (0, import_node_fs35.statSync)(abs);
|
|
12689
12725
|
if (!st.isFile()) {
|
|
12690
12726
|
throw new Error(`Not a file: ${relativePath}`);
|
|
12691
12727
|
}
|
|
@@ -12694,7 +12730,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
12694
12730
|
`File too large to upload (${st.size} bytes; max ${maxBytes})`
|
|
12695
12731
|
);
|
|
12696
12732
|
}
|
|
12697
|
-
const buf = (0,
|
|
12733
|
+
const buf = (0, import_node_fs35.readFileSync)(abs);
|
|
12698
12734
|
return {
|
|
12699
12735
|
path: relativePath,
|
|
12700
12736
|
contentBase64: buf.toString("base64"),
|
|
@@ -12704,12 +12740,12 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
12704
12740
|
function readWorktreeFile(worktreePath, relativePath, opts) {
|
|
12705
12741
|
assertSafeRelativePath(relativePath);
|
|
12706
12742
|
const maxBytes = opts?.maxBytes ?? 2e5;
|
|
12707
|
-
const abs = (0,
|
|
12708
|
-
const st = (0,
|
|
12743
|
+
const abs = (0, import_node_path32.join)(worktreePath, relativePath);
|
|
12744
|
+
const st = (0, import_node_fs35.statSync)(abs);
|
|
12709
12745
|
if (!st.isFile()) {
|
|
12710
12746
|
throw new Error(`Not a file: ${relativePath}`);
|
|
12711
12747
|
}
|
|
12712
|
-
const buf = (0,
|
|
12748
|
+
const buf = (0, import_node_fs35.readFileSync)(abs);
|
|
12713
12749
|
if (isImageRelativePath(relativePath)) {
|
|
12714
12750
|
const maxImageBytes = Math.max(maxBytes, 15e6);
|
|
12715
12751
|
const truncated2 = buf.length > maxImageBytes;
|
|
@@ -12752,9 +12788,9 @@ function assertSafeRelativePath(relativePath) {
|
|
|
12752
12788
|
}
|
|
12753
12789
|
function writeWorktreeFile(worktreePath, relativePath, content) {
|
|
12754
12790
|
assertSafeRelativePath(relativePath);
|
|
12755
|
-
const abs = (0,
|
|
12756
|
-
(0,
|
|
12757
|
-
(0,
|
|
12791
|
+
const abs = (0, import_node_path32.join)(worktreePath, relativePath);
|
|
12792
|
+
(0, import_node_fs35.mkdirSync)((0, import_node_path32.dirname)(abs), { recursive: true });
|
|
12793
|
+
(0, import_node_fs35.writeFileSync)(abs, content, "utf8");
|
|
12758
12794
|
return { path: relativePath };
|
|
12759
12795
|
}
|
|
12760
12796
|
async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
@@ -12858,9 +12894,9 @@ async function confirmLand(thread, opts) {
|
|
|
12858
12894
|
}
|
|
12859
12895
|
|
|
12860
12896
|
// src/skills/discover.ts
|
|
12861
|
-
var
|
|
12897
|
+
var import_node_fs36 = require("fs");
|
|
12862
12898
|
var import_node_os11 = require("os");
|
|
12863
|
-
var
|
|
12899
|
+
var import_node_path33 = require("path");
|
|
12864
12900
|
function toCommand(name) {
|
|
12865
12901
|
return name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
12866
12902
|
}
|
|
@@ -12892,7 +12928,7 @@ function parseFrontmatter(content) {
|
|
|
12892
12928
|
}
|
|
12893
12929
|
function readSkill(skillMd, source) {
|
|
12894
12930
|
try {
|
|
12895
|
-
const content = (0,
|
|
12931
|
+
const content = (0, import_node_fs36.readFileSync)(skillMd, "utf8");
|
|
12896
12932
|
const { name: fmName, description } = parseFrontmatter(content);
|
|
12897
12933
|
const dirName = skillMd.split("/").slice(-2, -1)[0] || "skill";
|
|
12898
12934
|
const name = fmName || dirName;
|
|
@@ -12911,19 +12947,19 @@ function readSkill(skillMd, source) {
|
|
|
12911
12947
|
}
|
|
12912
12948
|
}
|
|
12913
12949
|
function scanSkillsDir(dir, source, out) {
|
|
12914
|
-
if (!(0,
|
|
12950
|
+
if (!(0, import_node_fs36.existsSync)(dir)) return;
|
|
12915
12951
|
let entries;
|
|
12916
12952
|
try {
|
|
12917
|
-
entries = (0,
|
|
12953
|
+
entries = (0, import_node_fs36.readdirSync)(dir);
|
|
12918
12954
|
} catch {
|
|
12919
12955
|
return;
|
|
12920
12956
|
}
|
|
12921
12957
|
for (const entry of entries) {
|
|
12922
12958
|
if (entry.startsWith(".")) continue;
|
|
12923
|
-
const skillMd = (0,
|
|
12924
|
-
if (!(0,
|
|
12959
|
+
const skillMd = (0, import_node_path33.join)(dir, entry, "SKILL.md");
|
|
12960
|
+
if (!(0, import_node_fs36.existsSync)(skillMd)) continue;
|
|
12925
12961
|
try {
|
|
12926
|
-
if (!(0,
|
|
12962
|
+
if (!(0, import_node_fs36.statSync)(skillMd).isFile()) continue;
|
|
12927
12963
|
} catch {
|
|
12928
12964
|
continue;
|
|
12929
12965
|
}
|
|
@@ -12932,24 +12968,24 @@ function scanSkillsDir(dir, source, out) {
|
|
|
12932
12968
|
}
|
|
12933
12969
|
}
|
|
12934
12970
|
function scanClaudePluginSkills(pluginsRoot, out) {
|
|
12935
|
-
if (!(0,
|
|
12971
|
+
if (!(0, import_node_fs36.existsSync)(pluginsRoot)) return;
|
|
12936
12972
|
const walk = (dir, depth, lookingForSkillsDir) => {
|
|
12937
12973
|
if (depth > 7) return;
|
|
12938
12974
|
let entries;
|
|
12939
12975
|
try {
|
|
12940
|
-
entries = (0,
|
|
12976
|
+
entries = (0, import_node_fs36.readdirSync)(dir);
|
|
12941
12977
|
} catch {
|
|
12942
12978
|
return;
|
|
12943
12979
|
}
|
|
12944
12980
|
if (lookingForSkillsDir && entries.includes("SKILL.md")) {
|
|
12945
|
-
const skill = readSkill((0,
|
|
12981
|
+
const skill = readSkill((0, import_node_path33.join)(dir, "SKILL.md"), "cli");
|
|
12946
12982
|
if (skill) out.push(skill);
|
|
12947
12983
|
}
|
|
12948
12984
|
for (const entry of entries) {
|
|
12949
12985
|
if (entry === "node_modules" || entry === ".git") continue;
|
|
12950
|
-
const full = (0,
|
|
12986
|
+
const full = (0, import_node_path33.join)(dir, entry);
|
|
12951
12987
|
try {
|
|
12952
|
-
if (!(0,
|
|
12988
|
+
if (!(0, import_node_fs36.statSync)(full).isDirectory()) continue;
|
|
12953
12989
|
} catch {
|
|
12954
12990
|
continue;
|
|
12955
12991
|
}
|
|
@@ -12967,17 +13003,17 @@ function discoverSkills(worktreePath) {
|
|
|
12967
13003
|
const home = (0, import_node_os11.homedir)();
|
|
12968
13004
|
const collected = [];
|
|
12969
13005
|
for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
|
|
12970
|
-
scanSkillsDir((0,
|
|
13006
|
+
scanSkillsDir((0, import_node_path33.join)(worktreePath, rel), "workspace", collected);
|
|
12971
13007
|
}
|
|
12972
13008
|
for (const abs of [
|
|
12973
|
-
(0,
|
|
12974
|
-
(0,
|
|
12975
|
-
(0,
|
|
12976
|
-
(0,
|
|
13009
|
+
(0, import_node_path33.join)(home, ".claude/skills"),
|
|
13010
|
+
(0, import_node_path33.join)(home, ".cursor/skills"),
|
|
13011
|
+
(0, import_node_path33.join)(home, ".sideboard/skills"),
|
|
13012
|
+
(0, import_node_path33.join)(home, ".brightsy/skills")
|
|
12977
13013
|
]) {
|
|
12978
13014
|
scanSkillsDir(abs, "user", collected);
|
|
12979
13015
|
}
|
|
12980
|
-
scanClaudePluginSkills((0,
|
|
13016
|
+
scanClaudePluginSkills((0, import_node_path33.join)(home, ".claude/plugins"), collected);
|
|
12981
13017
|
const rank = { workspace: 0, user: 1, cli: 2 };
|
|
12982
13018
|
const byCommand = /* @__PURE__ */ new Map();
|
|
12983
13019
|
for (const skill of collected) {
|
|
@@ -12989,7 +13025,7 @@ function discoverSkills(worktreePath) {
|
|
|
12989
13025
|
return [...byCommand.values()].sort((a, b) => a.command.localeCompare(b.command));
|
|
12990
13026
|
}
|
|
12991
13027
|
function readSkillBody(skillPath, maxChars = 12e3) {
|
|
12992
|
-
const raw = (0,
|
|
13028
|
+
const raw = (0, import_node_fs36.readFileSync)(skillPath, "utf8");
|
|
12993
13029
|
if (raw.startsWith("---")) {
|
|
12994
13030
|
const end = raw.indexOf("\n---", 3);
|
|
12995
13031
|
if (end >= 0) {
|
|
@@ -13082,8 +13118,8 @@ function expandComposerPrompt(worktreePath, prompt, opts) {
|
|
|
13082
13118
|
}
|
|
13083
13119
|
|
|
13084
13120
|
// src/composer/stage-files.ts
|
|
13085
|
-
var
|
|
13086
|
-
var
|
|
13121
|
+
var import_node_fs37 = require("fs");
|
|
13122
|
+
var import_node_path34 = require("path");
|
|
13087
13123
|
var import_node_crypto7 = require("crypto");
|
|
13088
13124
|
init_workspace_scratch();
|
|
13089
13125
|
var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set([
|
|
@@ -13109,7 +13145,7 @@ var IMAGE_MIME_BY_EXT = {
|
|
|
13109
13145
|
var MAX_INLINE_BYTES = 4e5;
|
|
13110
13146
|
var MAX_PREVIEW_BYTES = 5e6;
|
|
13111
13147
|
function fileExtension(filePath) {
|
|
13112
|
-
const base = (0,
|
|
13148
|
+
const base = (0, import_node_path34.basename)(filePath).toLowerCase();
|
|
13113
13149
|
return base.includes(".") ? base.split(".").pop() || "" : "";
|
|
13114
13150
|
}
|
|
13115
13151
|
function isImageFilePath(filePath) {
|
|
@@ -13119,22 +13155,22 @@ function imageMimeType(filePath) {
|
|
|
13119
13155
|
return IMAGE_MIME_BY_EXT[fileExtension(filePath)] || "image/png";
|
|
13120
13156
|
}
|
|
13121
13157
|
function ensureAttachmentsDir(worktreePath) {
|
|
13122
|
-
const dir = (0,
|
|
13123
|
-
(0,
|
|
13124
|
-
const gi = (0,
|
|
13125
|
-
if (!(0,
|
|
13126
|
-
(0,
|
|
13158
|
+
const dir = (0, import_node_path34.join)(worktreePath, ATTACHMENTS_DIR);
|
|
13159
|
+
(0, import_node_fs37.mkdirSync)(dir, { recursive: true });
|
|
13160
|
+
const gi = (0, import_node_path34.join)(dir, ".gitignore");
|
|
13161
|
+
if (!(0, import_node_fs37.existsSync)(gi)) {
|
|
13162
|
+
(0, import_node_fs37.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
|
|
13127
13163
|
}
|
|
13128
13164
|
return dir;
|
|
13129
13165
|
}
|
|
13130
13166
|
function uniqueAttachmentName(dir, originalName) {
|
|
13131
13167
|
const safe = originalName.replace(/[/\\]/g, "_") || "file";
|
|
13132
|
-
if (!(0,
|
|
13133
|
-
const ext = (0,
|
|
13168
|
+
if (!(0, import_node_fs37.existsSync)((0, import_node_path34.join)(dir, safe))) return safe;
|
|
13169
|
+
const ext = (0, import_node_path34.extname)(safe);
|
|
13134
13170
|
const stem = ext ? safe.slice(0, -ext.length) : safe;
|
|
13135
13171
|
for (let i = 1; i < 1e4; i++) {
|
|
13136
13172
|
const candidate = `${stem}-${i}${ext}`;
|
|
13137
|
-
if (!(0,
|
|
13173
|
+
if (!(0, import_node_fs37.existsSync)((0, import_node_path34.join)(dir, candidate))) return candidate;
|
|
13138
13174
|
}
|
|
13139
13175
|
return `${stem}-${(0, import_node_crypto7.randomUUID)()}${ext}`;
|
|
13140
13176
|
}
|
|
@@ -13190,15 +13226,15 @@ function stageAbsolutePathsAsAttachments(worktreePath, absolutePaths) {
|
|
|
13190
13226
|
const dir = ensureAttachmentsDir(worktreePath);
|
|
13191
13227
|
const out = [];
|
|
13192
13228
|
for (const abs of absolutePaths) {
|
|
13193
|
-
const originalName = (0,
|
|
13229
|
+
const originalName = (0, import_node_path34.basename)(abs);
|
|
13194
13230
|
try {
|
|
13195
|
-
const st = (0,
|
|
13231
|
+
const st = (0, import_node_fs37.statSync)(abs);
|
|
13196
13232
|
if (!st.isFile()) continue;
|
|
13197
13233
|
const name = uniqueAttachmentName(dir, originalName);
|
|
13198
|
-
const destAbs = (0,
|
|
13199
|
-
(0,
|
|
13234
|
+
const destAbs = (0, import_node_path34.join)(dir, name);
|
|
13235
|
+
(0, import_node_fs37.copyFileSync)(abs, destAbs);
|
|
13200
13236
|
const rel = `${ATTACHMENTS_DIR}/${name}`;
|
|
13201
|
-
const buf = (0,
|
|
13237
|
+
const buf = (0, import_node_fs37.readFileSync)(destAbs);
|
|
13202
13238
|
out.push(attachmentFromBuffer(name, buf, { path: rel, sourceLabel: abs }));
|
|
13203
13239
|
} catch (err) {
|
|
13204
13240
|
out.push({
|
|
@@ -13220,8 +13256,8 @@ function stageBuffersAsAttachments(worktreePath, buffers) {
|
|
|
13220
13256
|
try {
|
|
13221
13257
|
const buf = Buffer.from(item.dataBase64, "base64");
|
|
13222
13258
|
const name = uniqueAttachmentName(dir, originalName);
|
|
13223
|
-
const destAbs = (0,
|
|
13224
|
-
(0,
|
|
13259
|
+
const destAbs = (0, import_node_path34.join)(dir, name);
|
|
13260
|
+
(0, import_node_fs37.writeFileSync)(destAbs, buf);
|
|
13225
13261
|
const rel = `${ATTACHMENTS_DIR}/${name}`;
|
|
13226
13262
|
out.push(attachmentFromBuffer(name, buf, { path: rel }));
|
|
13227
13263
|
} catch (err) {
|
|
@@ -13241,18 +13277,18 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
|
|
|
13241
13277
|
if (!rel || rel.includes("..") || rel.startsWith("/")) {
|
|
13242
13278
|
out.push({
|
|
13243
13279
|
id: (0, import_node_crypto7.randomUUID)(),
|
|
13244
|
-
name: (0,
|
|
13280
|
+
name: (0, import_node_path34.basename)(rel) || "file",
|
|
13245
13281
|
kind: "file",
|
|
13246
13282
|
content: `(invalid path: ${rel})`
|
|
13247
13283
|
});
|
|
13248
13284
|
continue;
|
|
13249
13285
|
}
|
|
13250
|
-
const name = (0,
|
|
13286
|
+
const name = (0, import_node_path34.basename)(rel);
|
|
13251
13287
|
try {
|
|
13252
|
-
const abs = (0,
|
|
13253
|
-
const st = (0,
|
|
13288
|
+
const abs = (0, import_node_path34.join)(worktreePath, rel);
|
|
13289
|
+
const st = (0, import_node_fs37.statSync)(abs);
|
|
13254
13290
|
if (!st.isFile()) continue;
|
|
13255
|
-
const buf = (0,
|
|
13291
|
+
const buf = (0, import_node_fs37.readFileSync)(abs);
|
|
13256
13292
|
out.push(attachmentFromBuffer(name, buf, { path: rel, sourceLabel: abs }));
|
|
13257
13293
|
} catch (err) {
|
|
13258
13294
|
out.push({
|
|
@@ -13267,8 +13303,8 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
|
|
|
13267
13303
|
}
|
|
13268
13304
|
|
|
13269
13305
|
// src/agents/instructions.ts
|
|
13270
|
-
var
|
|
13271
|
-
var
|
|
13306
|
+
var import_node_fs38 = require("fs");
|
|
13307
|
+
var import_node_path35 = require("path");
|
|
13272
13308
|
init_git_auth_mode();
|
|
13273
13309
|
init_worktree_labels();
|
|
13274
13310
|
function normPath3(p) {
|
|
@@ -13548,7 +13584,7 @@ var Orchestrator = class {
|
|
|
13548
13584
|
}
|
|
13549
13585
|
continue;
|
|
13550
13586
|
}
|
|
13551
|
-
if (!(0,
|
|
13587
|
+
if (!(0, import_node_fs42.existsSync)(thread.worktreePath)) {
|
|
13552
13588
|
setStatus(thread.id, "broken", "Worktree missing on disk");
|
|
13553
13589
|
this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
|
|
13554
13590
|
continue;
|
|
@@ -13799,7 +13835,9 @@ var Orchestrator = class {
|
|
|
13799
13835
|
updateThread(thread.id, patch);
|
|
13800
13836
|
this.emit({ type: "queue_changed", threadId: thread.id, queue });
|
|
13801
13837
|
this.emit({ type: "status_changed", threadId: thread.id, status: "queued" });
|
|
13802
|
-
|
|
13838
|
+
if (thisProcessShouldDrainAgentQueues()) {
|
|
13839
|
+
void this.drainQueue(thread.id);
|
|
13840
|
+
}
|
|
13803
13841
|
return this.requireThread(thread.id);
|
|
13804
13842
|
});
|
|
13805
13843
|
}
|
|
@@ -13852,10 +13890,10 @@ var Orchestrator = class {
|
|
|
13852
13890
|
async sendQueuedMessageNow(threadRef, index) {
|
|
13853
13891
|
const thread = this.requireThread(threadRef);
|
|
13854
13892
|
const promoted = await withThreadLock(thread.id, async () => {
|
|
13855
|
-
const
|
|
13856
|
-
if (index < 0 || index >=
|
|
13857
|
-
const item =
|
|
13858
|
-
const rest =
|
|
13893
|
+
const current2 = this.requireThread(thread.id);
|
|
13894
|
+
if (index < 0 || index >= current2.queue.length) return false;
|
|
13895
|
+
const item = current2.queue[index];
|
|
13896
|
+
const rest = current2.queue.filter((_, i) => i !== index);
|
|
13859
13897
|
const queue = [item, ...rest];
|
|
13860
13898
|
this.haltDrain.delete(thread.id);
|
|
13861
13899
|
updateThread(thread.id, { queue });
|
|
@@ -13863,10 +13901,16 @@ var Orchestrator = class {
|
|
|
13863
13901
|
return true;
|
|
13864
13902
|
});
|
|
13865
13903
|
if (!promoted) return this.requireThread(thread.id);
|
|
13904
|
+
const current = this.requireThread(thread.id);
|
|
13866
13905
|
const inFlight = this.activeTurns.has(thread.id) || this.startingTurns.has(thread.id);
|
|
13906
|
+
const livePid = current.agentPid;
|
|
13907
|
+
const foreignLive = !inFlight && typeof livePid === "number" && livePid > 0 && isPidAlive(livePid);
|
|
13867
13908
|
if (inFlight) {
|
|
13868
13909
|
this.stop(thread.id, { clearQueue: false, continueQueue: true });
|
|
13869
13910
|
} else {
|
|
13911
|
+
if (foreignLive) {
|
|
13912
|
+
this.stop(thread.id, { clearQueue: false, continueQueue: true });
|
|
13913
|
+
}
|
|
13870
13914
|
void this.drainQueue(thread.id);
|
|
13871
13915
|
}
|
|
13872
13916
|
return this.requireThread(thread.id);
|
|
@@ -14301,6 +14345,13 @@ var Orchestrator = class {
|
|
|
14301
14345
|
if (handle) handle.kill();
|
|
14302
14346
|
const proc = this.processes.get(`${thread.id}:agent`);
|
|
14303
14347
|
if (proc) proc.kill();
|
|
14348
|
+
const pid = thread.agentPid;
|
|
14349
|
+
if (typeof pid === "number" && pid > 0 && isPidAlive(pid)) {
|
|
14350
|
+
try {
|
|
14351
|
+
process.kill(pid, "SIGTERM");
|
|
14352
|
+
} catch {
|
|
14353
|
+
}
|
|
14354
|
+
}
|
|
14304
14355
|
const stopped = writeLiveStatus(thread.id, "stopped") ?? readThread(thread.id) ?? thread;
|
|
14305
14356
|
if (stopped.status === "stopped") {
|
|
14306
14357
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
@@ -15081,7 +15132,7 @@ var Orchestrator = class {
|
|
|
15081
15132
|
this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
|
|
15082
15133
|
return restored2;
|
|
15083
15134
|
}
|
|
15084
|
-
if (!(0,
|
|
15135
|
+
if (!(0, import_node_fs42.existsSync)(thread.worktreePath)) {
|
|
15085
15136
|
const { createThreadWorktree: createThreadWorktree2 } = await Promise.resolve().then(() => (init_worktree(), worktree_exports));
|
|
15086
15137
|
const { execa: execa7 } = await import("execa");
|
|
15087
15138
|
const slug = thread.worktreePath.split("/").pop();
|
|
@@ -16321,7 +16372,7 @@ async function startMcpServer() {
|
|
|
16321
16372
|
async () => {
|
|
16322
16373
|
const threads = orch.getThreads(true);
|
|
16323
16374
|
const lines = threads.map((t) => {
|
|
16324
|
-
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0,
|
|
16375
|
+
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path39.basename)(t.repoPath) || t.repoPath;
|
|
16325
16376
|
return `${t.id.slice(0, 8)} ${t.status.padEnd(9)} ${t.agent.padEnd(8)} ${repo} ${t.sourceType}:${t.sourceRef} ${t.title} sideboard://thread/${t.id}${t.devPort ? ` http://localhost:${t.devPort}` : ""}`;
|
|
16326
16377
|
});
|
|
16327
16378
|
return {
|