@sideboard-ai/core 0.1.339 → 0.1.341
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-TNONAVJG.js → abletime-AYYRRDT2.js} +4 -4
- package/dist/{abletime-OGOHNRVB.js → abletime-MK4T5FZY.js} +4 -4
- package/dist/{abletime-oauth-TYDQ73GK.js → abletime-oauth-7TOEFRWH.js} +3 -3
- package/dist/{abletime-oauth-DAZEUQJI.js → abletime-oauth-NB34M4X4.js} +3 -3
- package/dist/{abletime-rest-3FWZGTX6.js → abletime-rest-7M3QXAXY.js} +3 -3
- package/dist/{abletime-rest-B4VI46MI.js → abletime-rest-IF7IMJGU.js} +3 -3
- package/dist/{agents-QFXIBIKJ.js → agents-4WL4U5WD.js} +8 -8
- package/dist/{agents-6MSZHZOM.js → agents-FH5NVVCJ.js} +8 -8
- package/dist/{app-settings-KOSVLMO5.js → app-settings-377375BJ.js} +3 -1
- package/dist/{app-settings-YS5AUJTF.js → app-settings-YTOPIRDH.js} +3 -1
- package/dist/{chunk-W6J3ZWLJ.js → chunk-2IA556KV.js} +2 -2
- package/dist/{chunk-SYTTUNX6.js → chunk-3HJ2USRA.js} +1 -1
- package/dist/{chunk-5FGQTB2Z.js → chunk-43BOPWFV.js} +2 -2
- package/dist/{chunk-4BRO5LNX.js → chunk-47UDPUVZ.js} +3 -3
- package/dist/{chunk-FCBUDWP6.js → chunk-4BUTF5LN.js} +2 -2
- package/dist/{chunk-NHLTTT5G.js → chunk-4RIKHUKB.js} +7 -6
- package/dist/{chunk-HNW5KMGK.js → chunk-5MHENWO5.js} +2 -2
- package/dist/{chunk-6ABL7HZN.js → chunk-5VXE4ZI4.js} +10 -8
- package/dist/{chunk-DYUAVL5S.js → chunk-BIM24I3O.js} +1 -0
- package/dist/{chunk-VHHEQP5V.js → chunk-CMYGUGGZ.js} +11 -9
- package/dist/{chunk-5TVRPOVS.js → chunk-CN7GSNEL.js} +1 -1
- package/dist/{chunk-EZZY3EAZ.js → chunk-COFHTNQU.js} +666 -62
- package/dist/{chunk-N6TGSJVC.js → chunk-DF34F3QR.js} +10 -0
- package/dist/{chunk-PEJ3N5VE.js → chunk-DF3S5X3H.js} +7 -6
- package/dist/{chunk-LYJ5AVK4.js → chunk-FVX7JWFW.js} +2 -2
- package/dist/{chunk-4SP26Z6H.js → chunk-HNIEEKKR.js} +5 -5
- package/dist/{chunk-4OVQGZEI.js → chunk-HZRYQ27Z.js} +48 -26
- package/dist/{chunk-OMKTX7ZW.js → chunk-I5C42O2M.js} +3 -3
- package/dist/{chunk-Q73I6I2K.js → chunk-IY4YNHYD.js} +1 -1
- package/dist/{chunk-EVYOONTE.js → chunk-K355SYYX.js} +5 -5
- package/dist/{chunk-BD7QARIJ.js → chunk-MGV6JFDY.js} +5 -5
- package/dist/{chunk-KAIOL2M5.js → chunk-NF3KRZXV.js} +1 -1
- package/dist/{chunk-AFSLMWQK.js → chunk-O6UAW76V.js} +42 -3
- package/dist/{chunk-5KH3EQ2C.js → chunk-ORO4ENZR.js} +1 -0
- package/dist/{chunk-ELDHERAD.js → chunk-PHLFFV2M.js} +661 -56
- package/dist/{chunk-ERCYQTJU.js → chunk-QBUX2EDG.js} +48 -26
- package/dist/{chunk-FEGRY7NL.js → chunk-QULOUTDQ.js} +3 -3
- package/dist/{chunk-23KYDM2U.js → chunk-RZUZU5KD.js} +10 -0
- package/dist/{chunk-BDQFZAE6.js → chunk-SLTWZRBN.js} +43 -3
- package/dist/{chunk-QWFNKOGA.js → chunk-TZFYBQAD.js} +2 -2
- package/dist/{chunk-I2C5ZRVO.js → chunk-WSW27W5R.js} +1 -1
- package/dist/{chunk-WSZIJNAR.js → chunk-ZS7AY6DS.js} +5 -5
- package/dist/{conductor-AUUXCJZT.js → conductor-QZKG7YPO.js} +6 -6
- package/dist/{conductor-LEPTWN2U.js → conductor-RGVRIOTZ.js} +6 -6
- package/dist/{coordinator-prompt-CIWWP2P6.js → coordinator-prompt-66UHVADL.js} +4 -4
- package/dist/{coordinator-prompt-VO42IZWS.js → coordinator-prompt-CDVIFBYS.js} +4 -4
- package/dist/{global-workspace-MCAREQI7.js → global-workspace-FNDRAJLF.js} +4 -4
- package/dist/{global-workspace-FKXLFKYX.js → global-workspace-KMQSUF2G.js} +4 -4
- package/dist/index.cjs +965 -182
- package/dist/index.d.cts +45 -7
- package/dist/index.d.ts +45 -7
- package/dist/index.js +107 -25
- package/dist/{linear-5E2WI4QQ.js → linear-6DM4FJWT.js} +2 -2
- package/dist/{linear-P3LP455O.js → linear-ZJQM5IGJ.js} +2 -2
- package/dist/{linear-list-AXK62DPW.js → linear-list-4EPKZTYE.js} +1 -1
- package/dist/{linear-list-Y3INIBYH.js → linear-list-POPBU2VC.js} +1 -1
- package/dist/mcp/run-stdio.cjs +877 -108
- package/dist/mcp/run-stdio.js +97 -22
- package/dist/{optional-cli-6J6C4I3X.js → optional-cli-3G2274LT.js} +3 -3
- package/dist/{optional-cli-X6I35UNI.js → optional-cli-CZF2ZFU5.js} +4 -4
- package/dist/{orchestrator-JTFCNXVR.js → orchestrator-BKCQUMLB.js} +11 -11
- package/dist/{orchestrator-NOQDMYLB.js → orchestrator-SCFWTIE7.js} +11 -11
- package/dist/{thread-store-DCO5MZWJ.js → thread-store-OARQT6DL.js} +2 -2
- package/dist/{thread-store-QGBPSZU2.js → thread-store-W2SSO6IQ.js} +2 -2
- package/dist/{workspaces-D6FQCZRK.js → workspaces-6GB56LMJ.js} +4 -4
- package/dist/{workspaces-Y25L2EPV.js → workspaces-EWWLVSZ5.js} +4 -4
- package/dist/{worktree-S4YOAYRA.js → worktree-BRKMPZMJ.js} +5 -3
- package/dist/{worktree-GWS77LWX.js → worktree-OB5ABI22.js} +5 -3
- package/package.json +1 -1
package/dist/mcp/run-stdio.cjs
CHANGED
|
@@ -1404,6 +1404,7 @@ function toolDescription(name, input) {
|
|
|
1404
1404
|
if (/get_orchestrator$/i.test(name)) return "Get orchestrator";
|
|
1405
1405
|
else if (/notify_orchestrator$/i.test(name)) return "Notify orchestrator";
|
|
1406
1406
|
else if (/set_workspace_tags$/i.test(name)) return "Set workspace tags";
|
|
1407
|
+
else if (/set_wake_on_github_edges$/i.test(name)) return "Wake on CI / review";
|
|
1407
1408
|
if (/(?:list|set|delete)_env$/i.test(name)) return /list_env$/i.test(name) ? "List env vars" : /set_env$/i.test(name) ? "Set env var" : "Delete env var";
|
|
1408
1409
|
if (/list_schedules$/i.test(name)) return "List automations";
|
|
1409
1410
|
if (/create_schedule$/i.test(name)) {
|
|
@@ -4979,6 +4980,7 @@ __export(app_settings_exports, {
|
|
|
4979
4980
|
updateOpencodeSettings: () => updateOpencodeSettings,
|
|
4980
4981
|
updateProjectProfileSettings: () => updateProjectProfileSettings,
|
|
4981
4982
|
usageOnLimit: () => usageOnLimit,
|
|
4983
|
+
wakeOrchestratorOnGithubEdgesEnabled: () => wakeOrchestratorOnGithubEdgesEnabled,
|
|
4982
4984
|
writeViewerContext: () => writeViewerContext
|
|
4983
4985
|
});
|
|
4984
4986
|
function isAgentDoneSound(value) {
|
|
@@ -5381,6 +5383,9 @@ function normalizeAdvanced(raw) {
|
|
|
5381
5383
|
if (typeof source.cowboyMode === "boolean") {
|
|
5382
5384
|
out.cowboyMode = source.cowboyMode;
|
|
5383
5385
|
}
|
|
5386
|
+
if (typeof source.wakeOrchestratorOnGithubEdges === "boolean") {
|
|
5387
|
+
out.wakeOrchestratorOnGithubEdges = source.wakeOrchestratorOnGithubEdges;
|
|
5388
|
+
}
|
|
5384
5389
|
if (typeof source.showCost === "boolean") {
|
|
5385
5390
|
out.showCost = source.showCost;
|
|
5386
5391
|
}
|
|
@@ -6269,6 +6274,9 @@ function updateAdvancedSettings(patch) {
|
|
|
6269
6274
|
if (typeof patch.cowboyMode === "boolean") {
|
|
6270
6275
|
advanced.cowboyMode = patch.cowboyMode;
|
|
6271
6276
|
}
|
|
6277
|
+
if (typeof patch.wakeOrchestratorOnGithubEdges === "boolean") {
|
|
6278
|
+
advanced.wakeOrchestratorOnGithubEdges = patch.wakeOrchestratorOnGithubEdges;
|
|
6279
|
+
}
|
|
6272
6280
|
if (typeof patch.showCost === "boolean") {
|
|
6273
6281
|
advanced.showCost = patch.showCost;
|
|
6274
6282
|
}
|
|
@@ -6374,6 +6382,9 @@ function deleteBranchOnPurgeEnabled(settings = loadAppSettings()) {
|
|
|
6374
6382
|
function cowboyModeEnabled(settings = loadAppSettings()) {
|
|
6375
6383
|
return Boolean(settings.advanced.cowboyMode);
|
|
6376
6384
|
}
|
|
6385
|
+
function wakeOrchestratorOnGithubEdgesEnabled(settings = loadAppSettings()) {
|
|
6386
|
+
return Boolean(settings.advanced.wakeOrchestratorOnGithubEdges);
|
|
6387
|
+
}
|
|
6377
6388
|
function showCostEnabled(settings = loadAppSettings()) {
|
|
6378
6389
|
return Boolean(settings.advanced.showCost);
|
|
6379
6390
|
}
|
|
@@ -7550,11 +7561,16 @@ async function listCursorPrs(repoPath, slug, opts, head) {
|
|
|
7550
7561
|
}
|
|
7551
7562
|
}
|
|
7552
7563
|
const { stdout, exitCode } = await originCli(args, repoPath, { reject: false, timeoutMs: 2e4 });
|
|
7553
|
-
if (exitCode !== 0
|
|
7564
|
+
if (exitCode !== 0) {
|
|
7565
|
+
if (opts?.strict) throw new Error(`origin pr list failed (${exitCode})`);
|
|
7566
|
+
return [];
|
|
7567
|
+
}
|
|
7568
|
+
if (!stdout.trim()) return [];
|
|
7554
7569
|
let parsed;
|
|
7555
7570
|
try {
|
|
7556
7571
|
parsed = JSON.parse(stdout);
|
|
7557
7572
|
} catch {
|
|
7573
|
+
if (opts?.strict) throw new Error("origin pr list returned invalid JSON");
|
|
7558
7574
|
return [];
|
|
7559
7575
|
}
|
|
7560
7576
|
if (!Array.isArray(parsed)) return [];
|
|
@@ -7656,21 +7672,23 @@ async function fetchCursorPrHead(repoPath, slug, number, localBranch) {
|
|
|
7656
7672
|
throw new Error((result.stderr || result.stdout).trim() || `git fetch origin ${head} failed`);
|
|
7657
7673
|
}
|
|
7658
7674
|
}
|
|
7659
|
-
async function
|
|
7675
|
+
async function cursorPrCiChecks(repoPath, slug, selector) {
|
|
7660
7676
|
const { stdout, exitCode, stderr } = await originCli(
|
|
7661
7677
|
["pr", "checks", selector, ...repoArgs(slug), "--json", "name,status,conclusion,detailsUrl,startedAt,completedAt,summary,group,link"],
|
|
7662
7678
|
repoPath,
|
|
7663
7679
|
{ reject: false, timeoutMs: 2e4 }
|
|
7664
7680
|
);
|
|
7665
7681
|
const err = stderr.trim();
|
|
7666
|
-
let ci;
|
|
7667
7682
|
if (!stdout.trim()) {
|
|
7668
7683
|
if (/no pull request|not found|no change/i.test(err)) return null;
|
|
7669
7684
|
if (exitCode !== 0 && err) throw new Error(err);
|
|
7670
|
-
|
|
7671
|
-
} else {
|
|
7672
|
-
ci = originChecksToRuns(stdout);
|
|
7685
|
+
return [];
|
|
7673
7686
|
}
|
|
7687
|
+
return originChecksToRuns(stdout);
|
|
7688
|
+
}
|
|
7689
|
+
async function cursorPrChecks(repoPath, slug, selector) {
|
|
7690
|
+
const ci = await cursorPrCiChecks(repoPath, slug, selector);
|
|
7691
|
+
if (!ci) return null;
|
|
7674
7692
|
const view = await viewCursorPr(
|
|
7675
7693
|
repoPath,
|
|
7676
7694
|
slug,
|
|
@@ -8232,6 +8250,35 @@ function normalizeAttachments(raw) {
|
|
|
8232
8250
|
}
|
|
8233
8251
|
return out;
|
|
8234
8252
|
}
|
|
8253
|
+
function normalizeRunList(raw) {
|
|
8254
|
+
if (!Array.isArray(raw)) return [];
|
|
8255
|
+
const out = [];
|
|
8256
|
+
for (const item of raw) {
|
|
8257
|
+
if (!item || typeof item !== "object") continue;
|
|
8258
|
+
const row = item;
|
|
8259
|
+
if (typeof row.at !== "string" || !row.at.trim()) continue;
|
|
8260
|
+
const next = {
|
|
8261
|
+
at: row.at,
|
|
8262
|
+
threadId: typeof row.threadId === "string" && row.threadId.trim() ? row.threadId.trim() : null
|
|
8263
|
+
};
|
|
8264
|
+
if (typeof row.error === "string" && row.error.trim()) next.error = row.error;
|
|
8265
|
+
out.push(next);
|
|
8266
|
+
if (out.length >= SCHEDULE_RUN_HISTORY_LIMIT) break;
|
|
8267
|
+
}
|
|
8268
|
+
return out;
|
|
8269
|
+
}
|
|
8270
|
+
function runsFromStored(raw) {
|
|
8271
|
+
if (Array.isArray(raw.runs)) return normalizeRunList(raw.runs);
|
|
8272
|
+
if (typeof raw.lastRunAt === "string" && raw.lastRunAt.trim()) {
|
|
8273
|
+
const one = {
|
|
8274
|
+
at: raw.lastRunAt,
|
|
8275
|
+
threadId: raw.lastThreadId?.trim() || null
|
|
8276
|
+
};
|
|
8277
|
+
if (typeof raw.lastError === "string" && raw.lastError.trim()) one.error = raw.lastError;
|
|
8278
|
+
return [one];
|
|
8279
|
+
}
|
|
8280
|
+
return [];
|
|
8281
|
+
}
|
|
8235
8282
|
function normalizeTask(raw) {
|
|
8236
8283
|
const when = normalizeWhen(raw.when);
|
|
8237
8284
|
const agent = raw.agent && isOrchestratorCapableAgent(raw.agent) ? raw.agent : null;
|
|
@@ -8254,6 +8301,7 @@ function normalizeTask(raw) {
|
|
|
8254
8301
|
lastRunAt: raw.lastRunAt ?? null,
|
|
8255
8302
|
lastThreadId: raw.lastThreadId ?? null,
|
|
8256
8303
|
lastError: raw.lastError ?? null,
|
|
8304
|
+
runs: runsFromStored(raw),
|
|
8257
8305
|
createdBy: raw.createdBy === "mcp" || raw.createdBy === "cli" || raw.createdBy === "ui" ? raw.createdBy : "ui",
|
|
8258
8306
|
createdAt: raw.createdAt,
|
|
8259
8307
|
updatedAt: raw.updatedAt
|
|
@@ -8306,6 +8354,7 @@ function buildTask(input, now) {
|
|
|
8306
8354
|
lastRunAt: null,
|
|
8307
8355
|
lastThreadId: null,
|
|
8308
8356
|
lastError: null,
|
|
8357
|
+
runs: [],
|
|
8309
8358
|
createdBy: input.createdBy,
|
|
8310
8359
|
createdAt: ts,
|
|
8311
8360
|
updatedAt: ts
|
|
@@ -8395,20 +8444,25 @@ function recordScheduleRun(id, result) {
|
|
|
8395
8444
|
if (idx < 0) throw new Error(`Automation not found: ${id}`);
|
|
8396
8445
|
const prev = rows[idx];
|
|
8397
8446
|
const firedAt = result.firedAt ?? /* @__PURE__ */ new Date();
|
|
8447
|
+
const at = nowIso(firedAt);
|
|
8448
|
+
const threadId = result.lastThreadId !== void 0 ? result.lastThreadId?.trim() || null : null;
|
|
8449
|
+
const entry = { at, threadId };
|
|
8450
|
+
if (result.lastError?.trim()) entry.error = result.lastError;
|
|
8398
8451
|
const next = {
|
|
8399
8452
|
...prev,
|
|
8400
8453
|
enabled: prev.when.kind === "once" ? false : prev.enabled,
|
|
8401
8454
|
nextRunAt: prev.when.kind === "once" ? prev.nextRunAt : computeNextRunAt(prev.when, firedAt).toISOString(),
|
|
8402
|
-
lastRunAt:
|
|
8455
|
+
lastRunAt: at,
|
|
8403
8456
|
lastThreadId: result.lastThreadId !== void 0 ? result.lastThreadId : prev.lastThreadId,
|
|
8404
8457
|
lastError: result.lastError ?? null,
|
|
8405
|
-
|
|
8458
|
+
runs: [entry, ...prev.runs].slice(0, SCHEDULE_RUN_HISTORY_LIMIT),
|
|
8459
|
+
updatedAt: at
|
|
8406
8460
|
};
|
|
8407
8461
|
rows[idx] = next;
|
|
8408
8462
|
writeAll(rows);
|
|
8409
8463
|
return next;
|
|
8410
8464
|
}
|
|
8411
|
-
var import_node_crypto3, import_node_fs16, import_node_path19, ATTACHMENT_KINDS;
|
|
8465
|
+
var import_node_crypto3, import_node_fs16, import_node_path19, SCHEDULE_RUN_HISTORY_LIMIT, ATTACHMENT_KINDS;
|
|
8412
8466
|
var init_schedules = __esm({
|
|
8413
8467
|
"src/store/schedules.ts"() {
|
|
8414
8468
|
"use strict";
|
|
@@ -8422,6 +8476,7 @@ var init_schedules = __esm({
|
|
|
8422
8476
|
init_private_file();
|
|
8423
8477
|
init_app_settings();
|
|
8424
8478
|
init_schedule_when();
|
|
8479
|
+
SCHEDULE_RUN_HISTORY_LIMIT = 10;
|
|
8425
8480
|
ATTACHMENT_KINDS = /* @__PURE__ */ new Set([
|
|
8426
8481
|
"transcript",
|
|
8427
8482
|
"file",
|
|
@@ -8525,6 +8580,7 @@ function normalizeThread(raw) {
|
|
|
8525
8580
|
prIsInMergeQueue: Boolean(raw.prIsInMergeQueue),
|
|
8526
8581
|
prLabels: Array.isArray(raw.prLabels) ? raw.prLabels : [],
|
|
8527
8582
|
prChecksFailed: typeof raw.prChecksFailed === "boolean" ? raw.prChecksFailed : void 0,
|
|
8583
|
+
wakeOnGithubEdges: raw.wakeOnGithubEdges === true ? true : void 0,
|
|
8528
8584
|
issueBlockedBy: sanitizeIssueBlockedBy(raw.issueBlockedBy),
|
|
8529
8585
|
skipAutoArchiveOnMerge: Boolean(raw.skipAutoArchiveOnMerge),
|
|
8530
8586
|
cowboy: Boolean(raw.cowboy),
|
|
@@ -8569,6 +8625,7 @@ function createEmptyThread(partial) {
|
|
|
8569
8625
|
prIsInMergeQueue: Boolean(partial.prIsInMergeQueue),
|
|
8570
8626
|
prLabels: partial.prLabels ?? [],
|
|
8571
8627
|
prChecksFailed: partial.prChecksFailed,
|
|
8628
|
+
...partial.wakeOnGithubEdges === true ? { wakeOnGithubEdges: true } : {},
|
|
8572
8629
|
skipAutoArchiveOnMerge: partial.skipAutoArchiveOnMerge ?? false,
|
|
8573
8630
|
cowboy: Boolean(partial.cowboy),
|
|
8574
8631
|
stackId: partial.stackId ?? null,
|
|
@@ -8859,6 +8916,7 @@ __export(worktree_exports, {
|
|
|
8859
8916
|
fetchPrHead: () => fetchPrHead,
|
|
8860
8917
|
getPr: () => getPr,
|
|
8861
8918
|
getPrChecks: () => getPrChecks,
|
|
8919
|
+
getPrCiChecks: () => getPrCiChecks,
|
|
8862
8920
|
getPrDetails: () => getPrDetails,
|
|
8863
8921
|
getPrForHeadBranch: () => getPrForHeadBranch,
|
|
8864
8922
|
getPrMeta: () => getPrMeta,
|
|
@@ -9146,7 +9204,11 @@ async function listPrs(repoPath, opts) {
|
|
|
9146
9204
|
limit: fetchLimit
|
|
9147
9205
|
});
|
|
9148
9206
|
const { stdout, exitCode } = await gh(args, repoPath, { reject: false });
|
|
9149
|
-
if (exitCode !== 0
|
|
9207
|
+
if (exitCode !== 0) {
|
|
9208
|
+
if (opts?.strict) throw new Error(`gh pr list failed (${exitCode})`);
|
|
9209
|
+
return [];
|
|
9210
|
+
}
|
|
9211
|
+
if (!stdout.trim()) return [];
|
|
9150
9212
|
return applyPrListResponse(stdout, { ...resolved, limit, viewerTeams });
|
|
9151
9213
|
}
|
|
9152
9214
|
function prInfoFromGhView(view) {
|
|
@@ -9408,12 +9470,7 @@ async function probeLocalMergeGate(cwd, gate) {
|
|
|
9408
9470
|
}
|
|
9409
9471
|
return { gate, files: [] };
|
|
9410
9472
|
}
|
|
9411
|
-
async function
|
|
9412
|
-
const origin = await resolveOriginRemote(cwd);
|
|
9413
|
-
if (origin?.forge === "entire") return null;
|
|
9414
|
-
const cursorSlug = origin?.forge === "cursor" ? origin.slug : null;
|
|
9415
|
-
if (cursorSlug) return cursorPrChecks(cwd, cursorSlug, selector);
|
|
9416
|
-
const slug = await resolveGithubRepoSlug(cwd);
|
|
9473
|
+
async function readGhPrChecks(cwd, selector, slug) {
|
|
9417
9474
|
const args = [
|
|
9418
9475
|
"pr",
|
|
9419
9476
|
"checks",
|
|
@@ -9424,7 +9481,6 @@ async function getPrChecks(cwd, selector) {
|
|
|
9424
9481
|
if (slug) args.push("--repo", slug);
|
|
9425
9482
|
const { stdout, exitCode, stderr } = await gh(args, cwd, { reject: false });
|
|
9426
9483
|
const errText2 = stderr.trim();
|
|
9427
|
-
let ciChecks;
|
|
9428
9484
|
if (!stdout.trim()) {
|
|
9429
9485
|
if (/no pull requests found/i.test(errText2)) return null;
|
|
9430
9486
|
if (/auth|login|HTTP\s*401|credentials|token/i.test(errText2)) {
|
|
@@ -9434,18 +9490,34 @@ async function getPrChecks(cwd, selector) {
|
|
|
9434
9490
|
if (exitCode === 1 && errText2 && !/fail|check/i.test(errText2)) {
|
|
9435
9491
|
throw new Error(errText2);
|
|
9436
9492
|
}
|
|
9437
|
-
|
|
9438
|
-
} else {
|
|
9439
|
-
throw new Error(errText2 || `gh pr checks failed (${exitCode})`);
|
|
9440
|
-
}
|
|
9441
|
-
} else {
|
|
9442
|
-
try {
|
|
9443
|
-
const parsed = JSON.parse(stdout);
|
|
9444
|
-
ciChecks = parsed.map(normalizeCheck);
|
|
9445
|
-
} catch {
|
|
9446
|
-
throw new Error(errText2 || "gh pr checks returned invalid JSON");
|
|
9493
|
+
return [];
|
|
9447
9494
|
}
|
|
9495
|
+
throw new Error(errText2 || `gh pr checks failed (${exitCode})`);
|
|
9496
|
+
}
|
|
9497
|
+
try {
|
|
9498
|
+
const parsed = JSON.parse(stdout);
|
|
9499
|
+
return parsed.map(normalizeCheck);
|
|
9500
|
+
} catch {
|
|
9501
|
+
throw new Error(errText2 || "gh pr checks returned invalid JSON");
|
|
9502
|
+
}
|
|
9503
|
+
}
|
|
9504
|
+
async function getPrCiChecks(cwd, selector) {
|
|
9505
|
+
const origin = await resolveOriginRemote(cwd);
|
|
9506
|
+
if (origin?.forge === "entire") return null;
|
|
9507
|
+
if (origin?.forge === "cursor" && origin.slug) {
|
|
9508
|
+
return cursorPrCiChecks(cwd, origin.slug, selector);
|
|
9448
9509
|
}
|
|
9510
|
+
const slug = await resolveGithubRepoSlug(cwd);
|
|
9511
|
+
return readGhPrChecks(cwd, selector, slug);
|
|
9512
|
+
}
|
|
9513
|
+
async function getPrChecks(cwd, selector) {
|
|
9514
|
+
const origin = await resolveOriginRemote(cwd);
|
|
9515
|
+
if (origin?.forge === "entire") return null;
|
|
9516
|
+
const cursorSlug = origin?.forge === "cursor" ? origin.slug : null;
|
|
9517
|
+
if (cursorSlug) return cursorPrChecks(cwd, cursorSlug, selector);
|
|
9518
|
+
const slug = await resolveGithubRepoSlug(cwd);
|
|
9519
|
+
const ciChecks = await readGhPrChecks(cwd, selector, slug);
|
|
9520
|
+
if (!ciChecks) return null;
|
|
9449
9521
|
let gate = await fetchPrMergeGate(cwd, selector, slug);
|
|
9450
9522
|
const probed = await probeLocalMergeGate(cwd, gate);
|
|
9451
9523
|
gate = probed.gate;
|
|
@@ -11136,12 +11208,12 @@ var init_coordinator_prompt = __esm({
|
|
|
11136
11208
|
"- get_viewer_context / update_viewer_context \u2014 read or replace Settings \u2192 Agents (account) and Settings \u2192 Projects (per-repo) context. You can update a project: pass scope=project and repoPath from list_projects (this cwd is not a project). update_viewer_context requires confirmed=true after ask_user. Never write context unprompted.",
|
|
11137
11209
|
"- list_env / set_env / delete_env \u2014 Settings \u2192 Environment. scope=project requires repoPath from list_projects and stores the key under that project prefix (the project name, uppercased, plus _). APPLE_ID for sideboard is SIDEBOARD_APPLE_ID. scope=account is shared by every project and is not prefixed. list_env returns names only.",
|
|
11138
11210
|
"- set_caffeinate \u2014 keep this Mac awake across turns (macOS caffeinate). A connected phone already holds caffeinate (lid can close on power), so do not turn this on just because they are on the phone. Turn on for overnight work, or when the user will be away and no phone is connected. Turn OFF when they say they are done, wrapping up, going to sleep, or no longer need the machine awake. Closing this chat also releases it.",
|
|
11139
|
-
"- list_schedules / create_schedule / update_schedule / delete_schedule / run_schedule \u2014 automations that send a prompt to a chat (chatId or self) or start a new Global chat (omit chatId). A job bound to a chat is removed when that chat is archived. Omit chatId only for a Global automation that should outlive the chat. One-shot `at`, interval `every` (15m/1h/6h/1d), clock time `time` + `days` (07:30 and weekdays, or mon,wed), or 5-field `cron`. Recurring jobs without chatId open a new chat each run and archive it when that run finishes unless archiveChat is false (leave the chat open to keep talking). History keeps the last 5 archived
|
|
11211
|
+
"- list_schedules / create_schedule / update_schedule / delete_schedule / run_schedule \u2014 automations that send a prompt to a chat (chatId or self) or start a new Global chat (omit chatId). A job bound to a chat is removed when that chat is archived. Omit chatId only for a Global automation that should outlive the chat. One-shot `at`, interval `every` (15m/1h/6h/1d), clock time `time` + `days` (07:30 and weekdays, or mon,wed), or 5-field `cron`. Recurring jobs without chatId open a new chat each run and archive it when that run finishes unless archiveChat is false (leave the chat open to keep talking). History keeps the last 5 archived chats for that automation. list_schedules includes runs, the last 10 fires (at, threadId, error). To schedule a prompt from this chat, call create_schedule (omit chatId for a new Global chat, or chatId=self). Worktree agents have the same tools (`chatId=self` continues that coding chat and is removed when that chat is archived). Jobs fire only while Sideboard.app is running; sleep skips until wake. Creating or enabling a future job turns on Settings \u2192 Advanced \u2192 Caffeinate while automations are enabled (or call set_caffeinate). The desktop lists them in the sidebar after Board.",
|
|
11140
11212
|
"Projects:",
|
|
11141
11213
|
"- add_project / remove_project \u2014 register or unregister a git repo",
|
|
11142
11214
|
"Workspaces and chats:",
|
|
11143
11215
|
'- create_workspace \u2014 create a workspace (isolated checkout + first chat) from branch | pr | ticket (appears on Home). A ticket, PR, or named branch has one checkout: a second call returns that workspace (alreadyStarted=true) and chats for every agent already on it. That is not one agent. To put another agent on that checkout, fork_chat. send_to_chat only the chat that should do this job. Creating from the default branch still opens a new isolated workspace. Pass repoPath + parentChatId; omit agent and model so Sideboard applies Settings \u2192 Default agent, model & effort (never pass your own agent or agent=cursor). Pass the same tags (short labels, e.g. "phone-sync") on every workspace you open for one task so they group in the sidebar; reusing a checkout adds those tags. If the repo has a setup script, Sideboard runs it in the background (does not block send_to_chat). Nested Codex (you are Codex and the child would be Codex) can deadlock on ~/.codex locks \u2014 omit agent; Sideboard switches the child to Cursor when a CURSOR_API_KEY is set, otherwise keeps the Account default',
|
|
11144
|
-
"- set_workspace_tags \u2014 set, add, or remove labels on a workspace after create. Pass any chat id on that checkout. Same tags on every workspace from one task. Worktree agents can update tags on their own checkout (they omit ref).",
|
|
11216
|
+
"- set_workspace_tags \u2014 set, add, or remove labels on a workspace after create. Pass any chat id on that checkout. Same tags on every workspace from one task. Worktree agents can update tags on their own checkout (they omit ref). set_wake_on_github_edges opts a workspace into CI and review-request wakes once Settings \u2192 Advanced is on. Pass a child chat id. Do not flip the Advanced switch.",
|
|
11145
11217
|
"- set_plan / show_plan / list_order / set_dependency / clear_dependency / satisfy_dependency / execute_plan \u2014 This chat owns one plan. show_plan opens it in the side column, the same way a worktree agent does. The Orchestration row in the sidebar opens that chat. Draft with set_plan (title, summary, and goal) and set_dependency. A step may loop back to an earlier step. This is a plan, not a one-way waterfall. Call show_plan after you draft or change the plan. Do not paste the diagram in chat. Do not create workspaces or send_to_chat for that work while the plan is draft. execute_plan with agreed: true only after they tell you to run it. It marks the plan active and returns ready vs waiting. Start ready steps with create_workspace or send_to_chat. Leave waiting steps alone. Merge only if they asked. Worktree agents show_plan to open the diagram and this checkout's implementation plan when plan.md exists. set_dependency / clear_dependency only for a step they are part of. A dependency says one PR, issue, or workspace must reach a gate before another can start or merge. gate=in-main is met when that PR is merged; gate=in-prod stays waiting until satisfy_dependency (Sideboard cannot see production). hold=start blocks starting the subject; hold=merge blocks merging it. Example: PR 1 in prod before PR 2 can merge; PR 3 in main before issue 4 can start. Pass waitsOnKind (pr|issue|workspace), waitsOnRef, gate, subjectKind, subjectRef, hold. Pass repoPath when the same number exists in more than one project. A step can name another orchestration chat (kind orchestration, ref that chat id). That chat drafts its own plan. Each orchestration chat opens its own plan with show_plan. Worktree agents set their own checkout and omit subject. Plan mode on a workspace agent stays a separate plan for that checkout. Do not tell a child to merge or start while list_order still marks that step waiting.",
|
|
11146
11218
|
"- start_board_card \u2014 same as create_workspace for a ticket/PR/named branch (attaches issue text when resolvable). Then send_to_chat.",
|
|
11147
11219
|
"- fork_workspace \u2014 fork a worktree chat into a NEW git worktree + chat (transcript attached); optional agent; leave model unset (Auto) unless you have a reason. Not for orchestration chats.",
|
|
@@ -11516,19 +11588,19 @@ function traceTurn(phase, extra) {
|
|
|
11516
11588
|
}
|
|
11517
11589
|
}
|
|
11518
11590
|
async function withTimeout(promise, ms, label) {
|
|
11519
|
-
let
|
|
11591
|
+
let timer2;
|
|
11520
11592
|
try {
|
|
11521
11593
|
return await Promise.race([
|
|
11522
11594
|
promise,
|
|
11523
11595
|
new Promise((_, reject) => {
|
|
11524
|
-
|
|
11596
|
+
timer2 = setTimeout(
|
|
11525
11597
|
() => reject(new Error(`${label} timed out after ${ms}ms`)),
|
|
11526
11598
|
ms
|
|
11527
11599
|
);
|
|
11528
11600
|
})
|
|
11529
11601
|
]);
|
|
11530
11602
|
} finally {
|
|
11531
|
-
if (
|
|
11603
|
+
if (timer2) clearTimeout(timer2);
|
|
11532
11604
|
}
|
|
11533
11605
|
}
|
|
11534
11606
|
var import_node_fs23, import_node_path26;
|
|
@@ -12964,6 +13036,7 @@ var init_profile = __esm({
|
|
|
12964
13036
|
"get_orchestrator",
|
|
12965
13037
|
"notify_orchestrator",
|
|
12966
13038
|
"set_workspace_tags",
|
|
13039
|
+
"set_wake_on_github_edges",
|
|
12967
13040
|
"get_viewer_context",
|
|
12968
13041
|
"update_viewer_context",
|
|
12969
13042
|
"list_env",
|
|
@@ -13617,6 +13690,7 @@ var init_injected_mcp = __esm({
|
|
|
13617
13690
|
"mcp__sideboard__get_orchestrator",
|
|
13618
13691
|
"mcp__sideboard__notify_orchestrator",
|
|
13619
13692
|
"mcp__sideboard__set_workspace_tags",
|
|
13693
|
+
"mcp__sideboard__set_wake_on_github_edges",
|
|
13620
13694
|
"mcp__sideboard__get_viewer_context",
|
|
13621
13695
|
"mcp__sideboard__update_viewer_context",
|
|
13622
13696
|
"mcp__sideboard__list_env",
|
|
@@ -16112,16 +16186,16 @@ async function listAssignedLinearIssues(opts) {
|
|
|
16112
16186
|
try {
|
|
16113
16187
|
const { listLinearIssuesDirect: listLinearIssuesDirect2 } = await Promise.resolve().then(() => (init_linear(), linear_exports));
|
|
16114
16188
|
const listed = listLinearIssuesDirect2({ limit: 50 }).catch(() => []);
|
|
16115
|
-
let
|
|
16189
|
+
let timer2;
|
|
16116
16190
|
try {
|
|
16117
16191
|
return await Promise.race([
|
|
16118
16192
|
listed,
|
|
16119
16193
|
new Promise((resolve3) => {
|
|
16120
|
-
|
|
16194
|
+
timer2 = setTimeout(() => resolve3([]), opts?.timeoutMs ?? LIST_TIMEOUT_MS);
|
|
16121
16195
|
})
|
|
16122
16196
|
]);
|
|
16123
16197
|
} finally {
|
|
16124
|
-
if (
|
|
16198
|
+
if (timer2) clearTimeout(timer2);
|
|
16125
16199
|
}
|
|
16126
16200
|
} catch {
|
|
16127
16201
|
return [];
|
|
@@ -18719,11 +18793,11 @@ function parentKey(event) {
|
|
|
18719
18793
|
function createAgentStreamCoalescer(emit, opts) {
|
|
18720
18794
|
const intervalMs = opts?.intervalMs ?? 32;
|
|
18721
18795
|
let pending = null;
|
|
18722
|
-
let
|
|
18796
|
+
let timer2 = null;
|
|
18723
18797
|
const flush2 = () => {
|
|
18724
|
-
if (
|
|
18725
|
-
clearTimeout(
|
|
18726
|
-
|
|
18798
|
+
if (timer2) {
|
|
18799
|
+
clearTimeout(timer2);
|
|
18800
|
+
timer2 = null;
|
|
18727
18801
|
}
|
|
18728
18802
|
if (!pending) return;
|
|
18729
18803
|
const event = pending;
|
|
@@ -18735,9 +18809,9 @@ function createAgentStreamCoalescer(emit, opts) {
|
|
|
18735
18809
|
});
|
|
18736
18810
|
};
|
|
18737
18811
|
const schedule = () => {
|
|
18738
|
-
if (
|
|
18739
|
-
|
|
18740
|
-
|
|
18812
|
+
if (timer2) return;
|
|
18813
|
+
timer2 = setTimeout(flush2, intervalMs);
|
|
18814
|
+
timer2.unref?.();
|
|
18741
18815
|
};
|
|
18742
18816
|
return {
|
|
18743
18817
|
push(event) {
|
|
@@ -18991,9 +19065,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
|
|
|
18991
19065
|
}
|
|
18992
19066
|
};
|
|
18993
19067
|
signal("SIGTERM");
|
|
18994
|
-
const
|
|
18995
|
-
|
|
18996
|
-
child.once("exit", () => clearTimeout(
|
|
19068
|
+
const timer2 = setTimeout(() => signal("SIGKILL"), 5e3);
|
|
19069
|
+
timer2.unref?.();
|
|
19070
|
+
child.once("exit", () => clearTimeout(timer2));
|
|
18997
19071
|
},
|
|
18998
19072
|
done
|
|
18999
19073
|
};
|
|
@@ -19892,6 +19966,7 @@ function worktreeBindingFrom(from) {
|
|
|
19892
19966
|
prIsInMergeQueue: from.prIsInMergeQueue,
|
|
19893
19967
|
prLabels: from.prLabels,
|
|
19894
19968
|
prChecksFailed: from.prChecksFailed,
|
|
19969
|
+
wakeOnGithubEdges: from.wakeOnGithubEdges,
|
|
19895
19970
|
issueBlockedBy: from.issueBlockedBy,
|
|
19896
19971
|
skipAutoArchiveOnMerge: from.skipAutoArchiveOnMerge,
|
|
19897
19972
|
stackId: from.stackId,
|
|
@@ -21603,9 +21678,9 @@ function emptySetupLog() {
|
|
|
21603
21678
|
return { ...EMPTY };
|
|
21604
21679
|
}
|
|
21605
21680
|
function persistNow(threadId) {
|
|
21606
|
-
const
|
|
21607
|
-
if (
|
|
21608
|
-
clearTimeout(
|
|
21681
|
+
const timer2 = persistTimers.get(threadId);
|
|
21682
|
+
if (timer2) {
|
|
21683
|
+
clearTimeout(timer2);
|
|
21609
21684
|
persistTimers.delete(threadId);
|
|
21610
21685
|
}
|
|
21611
21686
|
const mem = memory.get(threadId);
|
|
@@ -21761,9 +21836,9 @@ function sliceRunLogOutput(output, tailChars = DEFAULT_RUN_LOG_TAIL_CHARS) {
|
|
|
21761
21836
|
return { output: text7, truncated: true, outputChars };
|
|
21762
21837
|
}
|
|
21763
21838
|
function persistNow2(key) {
|
|
21764
|
-
const
|
|
21765
|
-
if (
|
|
21766
|
-
clearTimeout(
|
|
21839
|
+
const timer2 = persistTimers2.get(key);
|
|
21840
|
+
if (timer2) {
|
|
21841
|
+
clearTimeout(timer2);
|
|
21767
21842
|
persistTimers2.delete(key);
|
|
21768
21843
|
}
|
|
21769
21844
|
const mem = memory2.get(key);
|
|
@@ -23982,12 +24057,12 @@ async function startAbleTimeOAuth(opts) {
|
|
|
23982
24057
|
finish(e instanceof Error ? e : new Error(String(e)));
|
|
23983
24058
|
}
|
|
23984
24059
|
});
|
|
23985
|
-
const
|
|
24060
|
+
const timer2 = setTimeout(() => {
|
|
23986
24061
|
finish(new Error("AbleTime sign-in timed out \u2014 try again"));
|
|
23987
24062
|
}, timeoutMs);
|
|
23988
24063
|
const onAbort = () => finish(new AbleTimeOAuthCancelledError());
|
|
23989
24064
|
const cleanup = () => {
|
|
23990
|
-
clearTimeout(
|
|
24065
|
+
clearTimeout(timer2);
|
|
23991
24066
|
opts?.signal?.removeEventListener("abort", onAbort);
|
|
23992
24067
|
server.close();
|
|
23993
24068
|
};
|
|
@@ -25966,11 +26041,11 @@ function createLineCoalescer(onChunk, opts) {
|
|
|
25966
26041
|
const delayMs = opts?.delayMs ?? 50;
|
|
25967
26042
|
const maxLines = opts?.maxLines ?? 200;
|
|
25968
26043
|
let buffer = [];
|
|
25969
|
-
let
|
|
26044
|
+
let timer2 = null;
|
|
25970
26045
|
const flush2 = () => {
|
|
25971
|
-
if (
|
|
25972
|
-
clearTimeout(
|
|
25973
|
-
|
|
26046
|
+
if (timer2) {
|
|
26047
|
+
clearTimeout(timer2);
|
|
26048
|
+
timer2 = null;
|
|
25974
26049
|
}
|
|
25975
26050
|
if (buffer.length === 0) return;
|
|
25976
26051
|
const chunk = buffer.join("\n");
|
|
@@ -25983,7 +26058,7 @@ function createLineCoalescer(onChunk, opts) {
|
|
|
25983
26058
|
flush2();
|
|
25984
26059
|
return;
|
|
25985
26060
|
}
|
|
25986
|
-
if (!
|
|
26061
|
+
if (!timer2) timer2 = setTimeout(flush2, delayMs);
|
|
25987
26062
|
};
|
|
25988
26063
|
return { push: push2, flush: flush2 };
|
|
25989
26064
|
}
|
|
@@ -28989,7 +29064,7 @@ function formatWorktreeDirective(thread, opts) {
|
|
|
28989
29064
|
);
|
|
28990
29065
|
}
|
|
28991
29066
|
lines.push(
|
|
28992
|
-
'- Sideboard git buttons send short phrases ("Commit and push.", "Ready for review.", "Merge PR.", \u2026) with their meaning attached \u2014 act on them without asking
|
|
29067
|
+
'- Sideboard git buttons send short phrases ("Commit and push.", "Ready for review.", "Merge PR.", \u2026) with their meaning attached \u2014 act on them without asking. A named goal includes the watch-fix-push playbook.'
|
|
28993
29068
|
);
|
|
28994
29069
|
lines.push("");
|
|
28995
29070
|
lines.push(formatDevAccessHint(opts?.activeRuns));
|
|
@@ -28998,7 +29073,7 @@ function formatWorktreeDirective(thread, opts) {
|
|
|
28998
29073
|
"Automations (sidebar, after Board): `create_schedule` / `list_schedules` (`at` / `every` / `cron` / `time`+`days`). `archiveChat=false` keeps the new chat. `chatId=self` is removed when this chat is archived. Fires only while Sideboard.app is running. Future jobs turn on Caffeinate."
|
|
28999
29074
|
);
|
|
29000
29075
|
lines.push(
|
|
29001
|
-
"`set_workspace_tags` labels this checkout (omit ref
|
|
29076
|
+
"`set_workspace_tags` labels this checkout (omit ref). `set_wake_on_github_edges` opts this checkout in when Advanced is already on (omit ref)."
|
|
29002
29077
|
);
|
|
29003
29078
|
lines.push(
|
|
29004
29079
|
"Orchestration: `show_plan` opens the diagram and plan.md. `list_order` / `set_dependency`"
|
|
@@ -30053,6 +30128,622 @@ var init_caffeinate_hold = __esm({
|
|
|
30053
30128
|
}
|
|
30054
30129
|
});
|
|
30055
30130
|
|
|
30131
|
+
// src/orchestrator/github-edge.ts
|
|
30132
|
+
function emptyGithubEdgeSnapshot() {
|
|
30133
|
+
return { primed: false, ciFailed: [], reviewRequested: [], lastFiredAt: {} };
|
|
30134
|
+
}
|
|
30135
|
+
function normalizePrUrl(raw) {
|
|
30136
|
+
const trimmed = (raw ?? "").trim();
|
|
30137
|
+
if (!trimmed) return "";
|
|
30138
|
+
try {
|
|
30139
|
+
const url = new URL(trimmed);
|
|
30140
|
+
url.hash = "";
|
|
30141
|
+
url.search = "";
|
|
30142
|
+
const path = url.pathname.replace(/\/+$/, "");
|
|
30143
|
+
return `${url.protocol}//${url.host.toLowerCase()}${path}`;
|
|
30144
|
+
} catch {
|
|
30145
|
+
return trimmed.replace(/\/+$/, "");
|
|
30146
|
+
}
|
|
30147
|
+
}
|
|
30148
|
+
function githubEdgeKey(kind, prUrl) {
|
|
30149
|
+
return `${kind}:${normalizePrUrl(prUrl)}`;
|
|
30150
|
+
}
|
|
30151
|
+
function acceptOpenReadyPr(row) {
|
|
30152
|
+
if (!normalizePrUrl(row.prUrl)) return false;
|
|
30153
|
+
if (row.draft === true) return false;
|
|
30154
|
+
const state = (row.state ?? "").trim().toUpperCase();
|
|
30155
|
+
return state !== "MERGED" && state !== "CLOSED";
|
|
30156
|
+
}
|
|
30157
|
+
function mergeCiLatch(prev, failing, unknown) {
|
|
30158
|
+
const out = /* @__PURE__ */ new Set();
|
|
30159
|
+
for (const url of failing) {
|
|
30160
|
+
const normalized = normalizePrUrl(url);
|
|
30161
|
+
if (normalized) out.add(normalized);
|
|
30162
|
+
}
|
|
30163
|
+
const unknownSet = new Set(unknown.map((url) => normalizePrUrl(url)).filter(Boolean));
|
|
30164
|
+
for (const url of prev) {
|
|
30165
|
+
const normalized = normalizePrUrl(url);
|
|
30166
|
+
if (normalized && unknownSet.has(normalized)) out.add(normalized);
|
|
30167
|
+
}
|
|
30168
|
+
return [...out];
|
|
30169
|
+
}
|
|
30170
|
+
function mergeReviewLatch(prev, fetched, successfulRepos) {
|
|
30171
|
+
const ok = new Set(successfulRepos);
|
|
30172
|
+
const map = /* @__PURE__ */ new Map();
|
|
30173
|
+
for (const row of prev) {
|
|
30174
|
+
const prUrl = normalizePrUrl(row.prUrl);
|
|
30175
|
+
if (!prUrl) continue;
|
|
30176
|
+
if (row.repoPath && ok.has(row.repoPath)) continue;
|
|
30177
|
+
if (!row.repoPath) continue;
|
|
30178
|
+
map.set(prUrl, { prUrl, repoPath: row.repoPath });
|
|
30179
|
+
}
|
|
30180
|
+
for (const row of fetched) {
|
|
30181
|
+
const prUrl = normalizePrUrl(row.prUrl);
|
|
30182
|
+
if (!prUrl) continue;
|
|
30183
|
+
map.set(prUrl, { prUrl, repoPath: row.repoPath });
|
|
30184
|
+
}
|
|
30185
|
+
return [...map.values()];
|
|
30186
|
+
}
|
|
30187
|
+
function coerceGithubEdgeSnapshot(raw) {
|
|
30188
|
+
if (!raw || typeof raw !== "object") return emptyGithubEdgeSnapshot();
|
|
30189
|
+
const row = raw;
|
|
30190
|
+
const ciFailed = [];
|
|
30191
|
+
const seenCi = /* @__PURE__ */ new Set();
|
|
30192
|
+
if (Array.isArray(row.ciFailed)) {
|
|
30193
|
+
for (const item of row.ciFailed) {
|
|
30194
|
+
const prUrl = normalizePrUrl(typeof item === "string" ? item : "");
|
|
30195
|
+
if (!prUrl || seenCi.has(prUrl)) continue;
|
|
30196
|
+
seenCi.add(prUrl);
|
|
30197
|
+
ciFailed.push(prUrl);
|
|
30198
|
+
}
|
|
30199
|
+
}
|
|
30200
|
+
const reviewRequested = [];
|
|
30201
|
+
const seenReview = /* @__PURE__ */ new Set();
|
|
30202
|
+
if (Array.isArray(row.reviewRequested)) {
|
|
30203
|
+
for (const item of row.reviewRequested) {
|
|
30204
|
+
if (!item || typeof item !== "object") continue;
|
|
30205
|
+
const record = item;
|
|
30206
|
+
const prUrl = normalizePrUrl(typeof record.prUrl === "string" ? record.prUrl : "");
|
|
30207
|
+
const repoPath = typeof record.repoPath === "string" ? record.repoPath.trim() : "";
|
|
30208
|
+
if (!prUrl || !repoPath || seenReview.has(prUrl)) continue;
|
|
30209
|
+
seenReview.add(prUrl);
|
|
30210
|
+
reviewRequested.push({ prUrl, repoPath });
|
|
30211
|
+
}
|
|
30212
|
+
}
|
|
30213
|
+
const ciSeen = [];
|
|
30214
|
+
const seenCiUrls = /* @__PURE__ */ new Set();
|
|
30215
|
+
if (Array.isArray(row.ciSeen)) {
|
|
30216
|
+
for (const item of row.ciSeen) {
|
|
30217
|
+
const prUrl = normalizePrUrl(typeof item === "string" ? item : "");
|
|
30218
|
+
if (!prUrl || seenCiUrls.has(prUrl)) continue;
|
|
30219
|
+
seenCiUrls.add(prUrl);
|
|
30220
|
+
ciSeen.push(prUrl);
|
|
30221
|
+
}
|
|
30222
|
+
}
|
|
30223
|
+
const reviewReposSeen = [];
|
|
30224
|
+
const seenRepos = /* @__PURE__ */ new Set();
|
|
30225
|
+
if (Array.isArray(row.reviewReposSeen)) {
|
|
30226
|
+
for (const item of row.reviewReposSeen) {
|
|
30227
|
+
const repo = typeof item === "string" ? item.trim() : "";
|
|
30228
|
+
if (!repo || seenRepos.has(repo)) continue;
|
|
30229
|
+
seenRepos.add(repo);
|
|
30230
|
+
reviewReposSeen.push(repo);
|
|
30231
|
+
}
|
|
30232
|
+
}
|
|
30233
|
+
const lastFiredAt = {};
|
|
30234
|
+
if (row.lastFiredAt && typeof row.lastFiredAt === "object") {
|
|
30235
|
+
for (const [key, value] of Object.entries(row.lastFiredAt)) {
|
|
30236
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) {
|
|
30237
|
+
lastFiredAt[key] = value;
|
|
30238
|
+
}
|
|
30239
|
+
}
|
|
30240
|
+
}
|
|
30241
|
+
return {
|
|
30242
|
+
primed: row.primed === true,
|
|
30243
|
+
ciFailed,
|
|
30244
|
+
reviewRequested,
|
|
30245
|
+
lastFiredAt,
|
|
30246
|
+
...reviewReposSeen.length ? { reviewReposSeen } : {},
|
|
30247
|
+
...ciSeen.length ? { ciSeen } : {}
|
|
30248
|
+
};
|
|
30249
|
+
}
|
|
30250
|
+
function dedupeSubjects(items) {
|
|
30251
|
+
const map = /* @__PURE__ */ new Map();
|
|
30252
|
+
for (const item of items) {
|
|
30253
|
+
if (!acceptOpenReadyPr(item)) continue;
|
|
30254
|
+
const prUrl = normalizePrUrl(item.prUrl);
|
|
30255
|
+
if (!prUrl) continue;
|
|
30256
|
+
const next = { ...item, prUrl };
|
|
30257
|
+
const prev = map.get(prUrl);
|
|
30258
|
+
if (!prev) {
|
|
30259
|
+
map.set(prUrl, next);
|
|
30260
|
+
continue;
|
|
30261
|
+
}
|
|
30262
|
+
if (!prev.threadId && next.threadId) {
|
|
30263
|
+
map.set(prUrl, {
|
|
30264
|
+
...prev,
|
|
30265
|
+
...next,
|
|
30266
|
+
prUrl,
|
|
30267
|
+
title: next.title.trim() || prev.title
|
|
30268
|
+
});
|
|
30269
|
+
}
|
|
30270
|
+
}
|
|
30271
|
+
return [...map.values()];
|
|
30272
|
+
}
|
|
30273
|
+
function diffGithubEdges(input) {
|
|
30274
|
+
if (!input.prev.primed) return [];
|
|
30275
|
+
const cooldown = input.cooldownMs ?? GITHUB_EDGE_COOLDOWN_MS;
|
|
30276
|
+
const edges = [];
|
|
30277
|
+
const consider = (kind, items, latched) => {
|
|
30278
|
+
for (const item of dedupeSubjects(items)) {
|
|
30279
|
+
if (latched.has(item.prUrl)) continue;
|
|
30280
|
+
const firedAt = input.prev.lastFiredAt[githubEdgeKey(kind, item.prUrl)] ?? 0;
|
|
30281
|
+
if (firedAt && input.now - firedAt < cooldown) continue;
|
|
30282
|
+
edges.push({ ...item, kind });
|
|
30283
|
+
}
|
|
30284
|
+
};
|
|
30285
|
+
consider("ci-failed", input.ciFailed, new Set(input.prev.ciFailed.map((url) => normalizePrUrl(url))));
|
|
30286
|
+
consider(
|
|
30287
|
+
"review-requested",
|
|
30288
|
+
input.reviewRequested,
|
|
30289
|
+
new Set(input.prev.reviewRequested.map((row) => normalizePrUrl(row.prUrl)))
|
|
30290
|
+
);
|
|
30291
|
+
return edges;
|
|
30292
|
+
}
|
|
30293
|
+
function commitGithubEdgeSnapshot(input) {
|
|
30294
|
+
const deliveredCi = new Set(
|
|
30295
|
+
input.delivered.filter((edge) => edge.kind === "ci-failed").map((edge) => normalizePrUrl(edge.prUrl)).filter(Boolean)
|
|
30296
|
+
);
|
|
30297
|
+
const deliveredReview = new Set(
|
|
30298
|
+
input.delivered.filter((edge) => edge.kind === "review-requested").map((edge) => normalizePrUrl(edge.prUrl)).filter(Boolean)
|
|
30299
|
+
);
|
|
30300
|
+
const ciObserved = dedupeSubjects(input.ciFailed).map((item) => item.prUrl);
|
|
30301
|
+
const ciFailed = nextUrls(input.prev.primed, input.prev.ciFailed, ciObserved, deliveredCi);
|
|
30302
|
+
const reviewRequested = nextReviewLatch(
|
|
30303
|
+
input.prev.primed,
|
|
30304
|
+
input.reviewRequested,
|
|
30305
|
+
input.prev.reviewRequested,
|
|
30306
|
+
deliveredReview
|
|
30307
|
+
);
|
|
30308
|
+
const lastFiredAt = {};
|
|
30309
|
+
for (const [key, at] of Object.entries(input.prev.lastFiredAt)) {
|
|
30310
|
+
if (input.now - at <= LAST_FIRED_KEEP_MS) lastFiredAt[key] = at;
|
|
30311
|
+
}
|
|
30312
|
+
for (const edge of input.delivered) {
|
|
30313
|
+
const prUrl = normalizePrUrl(edge.prUrl);
|
|
30314
|
+
if (!prUrl) continue;
|
|
30315
|
+
lastFiredAt[githubEdgeKey(edge.kind, prUrl)] = input.now;
|
|
30316
|
+
}
|
|
30317
|
+
return { primed: true, ciFailed, reviewRequested, lastFiredAt };
|
|
30318
|
+
}
|
|
30319
|
+
function nextUrls(primed, prev, observed, delivered) {
|
|
30320
|
+
const prevSet = new Set(prev.map((url) => normalizePrUrl(url)).filter(Boolean));
|
|
30321
|
+
const out = [];
|
|
30322
|
+
const seen = /* @__PURE__ */ new Set();
|
|
30323
|
+
for (const url of observed) {
|
|
30324
|
+
if (!url || seen.has(url)) continue;
|
|
30325
|
+
seen.add(url);
|
|
30326
|
+
if (!primed || prevSet.has(url) || delivered.has(url)) out.push(url);
|
|
30327
|
+
}
|
|
30328
|
+
return out;
|
|
30329
|
+
}
|
|
30330
|
+
function nextReviewLatch(primed, observed, prev, delivered) {
|
|
30331
|
+
const prevSet = new Set(prev.map((row) => normalizePrUrl(row.prUrl)).filter(Boolean));
|
|
30332
|
+
const out = [];
|
|
30333
|
+
const seen = /* @__PURE__ */ new Set();
|
|
30334
|
+
for (const row of observed) {
|
|
30335
|
+
const prUrl = normalizePrUrl(row.prUrl);
|
|
30336
|
+
const repoPath = row.repoPath.trim();
|
|
30337
|
+
if (!prUrl || !repoPath || seen.has(prUrl)) continue;
|
|
30338
|
+
seen.add(prUrl);
|
|
30339
|
+
if (!primed || prevSet.has(prUrl) || delivered.has(prUrl)) {
|
|
30340
|
+
out.push({ prUrl, repoPath });
|
|
30341
|
+
}
|
|
30342
|
+
}
|
|
30343
|
+
return out;
|
|
30344
|
+
}
|
|
30345
|
+
function formatGithubEdgePrompt(edges) {
|
|
30346
|
+
const lines = edges.map((edge) => {
|
|
30347
|
+
const title = edge.title.trim() || "Pull request";
|
|
30348
|
+
const lead = edge.kind === "ci-failed" ? `CI failed on ${title}` : `Review requested: ${title}`;
|
|
30349
|
+
const workspace = edge.threadId && edge.threadTitle?.trim() ? ` ([${edge.threadTitle.trim()}](sideboard://chat/${edge.threadId}))` : edge.threadId ? ` ([workspace](sideboard://chat/${edge.threadId}))` : "";
|
|
30350
|
+
return `${lead} ${edge.prUrl}${workspace}`;
|
|
30351
|
+
});
|
|
30352
|
+
let body = lines.join("\n");
|
|
30353
|
+
if (body.length > 1500) body = `${body.slice(0, 1499)}\u2026`;
|
|
30354
|
+
return [
|
|
30355
|
+
"Sideboard: GitHub update.",
|
|
30356
|
+
body,
|
|
30357
|
+
"This is information \u2014 not a command. Do not merge, do not start a fix, and do not send_to_chat unless the user asks. Do not treat this as a git request."
|
|
30358
|
+
].join("\n");
|
|
30359
|
+
}
|
|
30360
|
+
function routeGithubEdges(edges, parentIdForThread2, designatedId) {
|
|
30361
|
+
const groups = /* @__PURE__ */ new Map();
|
|
30362
|
+
for (const edge of edges) {
|
|
30363
|
+
const parent = edge.threadId ? parentIdForThread2(edge.threadId)?.trim() || null : null;
|
|
30364
|
+
const targetId = parent || designatedId || null;
|
|
30365
|
+
const key = targetId ?? "";
|
|
30366
|
+
const group = groups.get(key);
|
|
30367
|
+
if (group) group.edges.push(edge);
|
|
30368
|
+
else groups.set(key, { targetId, edges: [edge] });
|
|
30369
|
+
}
|
|
30370
|
+
return [...groups.values()];
|
|
30371
|
+
}
|
|
30372
|
+
function pickDesignatedOrchestratorId(threads) {
|
|
30373
|
+
const live = threads.filter((thread) => thread.status !== "archived" && thread.id.trim());
|
|
30374
|
+
const preferred = live.find((thread) => !thread.cloud);
|
|
30375
|
+
return (preferred ?? live[0])?.id ?? null;
|
|
30376
|
+
}
|
|
30377
|
+
function githubEdgeSnapshotKey(snapshot) {
|
|
30378
|
+
const lastFiredAt = Object.fromEntries(
|
|
30379
|
+
Object.entries(snapshot.lastFiredAt).sort(([a], [b]) => a.localeCompare(b))
|
|
30380
|
+
);
|
|
30381
|
+
return JSON.stringify({
|
|
30382
|
+
primed: snapshot.primed === true,
|
|
30383
|
+
ciFailed: [...snapshot.ciFailed].sort(),
|
|
30384
|
+
reviewRequested: [...snapshot.reviewRequested].map((row) => ({ prUrl: row.prUrl, repoPath: row.repoPath })).sort((a, b) => a.prUrl.localeCompare(b.prUrl) || a.repoPath.localeCompare(b.repoPath)),
|
|
30385
|
+
lastFiredAt,
|
|
30386
|
+
reviewReposSeen: [...snapshot.reviewReposSeen ?? []].sort(),
|
|
30387
|
+
ciSeen: [...snapshot.ciSeen ?? []].sort()
|
|
30388
|
+
});
|
|
30389
|
+
}
|
|
30390
|
+
var GITHUB_EDGE_COOLDOWN_MS, GITHUB_EDGE_POLL_MS, LAST_FIRED_KEEP_MS;
|
|
30391
|
+
var init_github_edge = __esm({
|
|
30392
|
+
"src/orchestrator/github-edge.ts"() {
|
|
30393
|
+
"use strict";
|
|
30394
|
+
GITHUB_EDGE_COOLDOWN_MS = 30 * 6e4;
|
|
30395
|
+
GITHUB_EDGE_POLL_MS = 6e4;
|
|
30396
|
+
LAST_FIRED_KEEP_MS = 7 * 24 * 60 * 6e4;
|
|
30397
|
+
}
|
|
30398
|
+
});
|
|
30399
|
+
|
|
30400
|
+
// src/orchestrator/github-edge-watch.ts
|
|
30401
|
+
function githubEdgeSnapshotPath() {
|
|
30402
|
+
return (0, import_node_path69.join)(appDataDir(), "github-edge-watch.json");
|
|
30403
|
+
}
|
|
30404
|
+
function loadGithubEdgeSnapshot() {
|
|
30405
|
+
try {
|
|
30406
|
+
const path = githubEdgeSnapshotPath();
|
|
30407
|
+
if (!(0, import_node_fs69.existsSync)(path)) return emptyGithubEdgeSnapshot();
|
|
30408
|
+
return coerceGithubEdgeSnapshot(JSON.parse((0, import_node_fs69.readFileSync)(path, "utf8")));
|
|
30409
|
+
} catch {
|
|
30410
|
+
return emptyGithubEdgeSnapshot();
|
|
30411
|
+
}
|
|
30412
|
+
}
|
|
30413
|
+
function saveGithubEdgeSnapshot(snapshot) {
|
|
30414
|
+
writePrivateFile2(githubEdgeSnapshotPath(), `${JSON.stringify(snapshot, null, 2)}
|
|
30415
|
+
`);
|
|
30416
|
+
}
|
|
30417
|
+
function stopGithubEdgeWatch() {
|
|
30418
|
+
if (timer) clearInterval(timer);
|
|
30419
|
+
timer = null;
|
|
30420
|
+
}
|
|
30421
|
+
function armGithubEdgeWatch() {
|
|
30422
|
+
if (!isThisProcessDesktopHost()) return;
|
|
30423
|
+
if (!wakeOrchestratorOnGithubEdgesEnabled()) {
|
|
30424
|
+
stopGithubEdgeWatch();
|
|
30425
|
+
needsBaseline = true;
|
|
30426
|
+
return;
|
|
30427
|
+
}
|
|
30428
|
+
if (timer) return;
|
|
30429
|
+
const tick = () => {
|
|
30430
|
+
if (polling) return;
|
|
30431
|
+
polling = true;
|
|
30432
|
+
const baseline = needsBaseline;
|
|
30433
|
+
needsBaseline = false;
|
|
30434
|
+
void pollGithubEdges(realDeps(), { baseline }).catch(() => {
|
|
30435
|
+
if (baseline) needsBaseline = true;
|
|
30436
|
+
}).finally(() => {
|
|
30437
|
+
polling = false;
|
|
30438
|
+
});
|
|
30439
|
+
};
|
|
30440
|
+
timer = setInterval(tick, GITHUB_EDGE_POLL_MS);
|
|
30441
|
+
timer.unref?.();
|
|
30442
|
+
tick();
|
|
30443
|
+
}
|
|
30444
|
+
async function pollGithubEdges(deps = realDeps(), opts) {
|
|
30445
|
+
if (!deps.enabled()) return { fired: 0, primed: false, skipped: "disabled" };
|
|
30446
|
+
const loaded = deps.load();
|
|
30447
|
+
const prev = opts?.baseline ? { ...loaded, primed: false } : loaded;
|
|
30448
|
+
const now = deps.now();
|
|
30449
|
+
const cards = indexCiCards(deps.listCiCards(), (threadId) => deps.parentIdForThread(threadId));
|
|
30450
|
+
const failing = [];
|
|
30451
|
+
const unknown = [];
|
|
30452
|
+
const observed = [];
|
|
30453
|
+
const failingSubjects = /* @__PURE__ */ new Map();
|
|
30454
|
+
for (const card of cards.values()) {
|
|
30455
|
+
const prUrl = normalizePrUrl(card.prUrl);
|
|
30456
|
+
let failed;
|
|
30457
|
+
try {
|
|
30458
|
+
failed = await deps.fetchCiFailed(card);
|
|
30459
|
+
} catch {
|
|
30460
|
+
failed = null;
|
|
30461
|
+
}
|
|
30462
|
+
if (failed == null) {
|
|
30463
|
+
unknown.push(prUrl);
|
|
30464
|
+
continue;
|
|
30465
|
+
}
|
|
30466
|
+
observed.push(prUrl);
|
|
30467
|
+
if (!failed) continue;
|
|
30468
|
+
failing.push(prUrl);
|
|
30469
|
+
failingSubjects.set(prUrl, subjectFromCard(card, prUrl));
|
|
30470
|
+
}
|
|
30471
|
+
const ciUrls = mergeCiLatch(
|
|
30472
|
+
prev.ciFailed,
|
|
30473
|
+
prev.primed ? failing : [...failing, ...unknown],
|
|
30474
|
+
unknown
|
|
30475
|
+
);
|
|
30476
|
+
const ciFailed = ciUrls.map(
|
|
30477
|
+
(prUrl) => failingSubjects.get(prUrl) ?? { prUrl, title: prUrl }
|
|
30478
|
+
);
|
|
30479
|
+
const repos = [...new Set(deps.listRepoPaths().map((path) => path.trim()).filter(Boolean))].sort();
|
|
30480
|
+
const fetchedReviews = [];
|
|
30481
|
+
const reviewSubjects = /* @__PURE__ */ new Map();
|
|
30482
|
+
const successfulRepos = [];
|
|
30483
|
+
for (const repoPath of repos) {
|
|
30484
|
+
let rows;
|
|
30485
|
+
try {
|
|
30486
|
+
rows = await deps.listReviewRequested(repoPath);
|
|
30487
|
+
} catch {
|
|
30488
|
+
rows = null;
|
|
30489
|
+
}
|
|
30490
|
+
if (!rows) continue;
|
|
30491
|
+
successfulRepos.push(repoPath);
|
|
30492
|
+
for (const row of rows) {
|
|
30493
|
+
if (!acceptOpenReadyPr(row)) continue;
|
|
30494
|
+
const prUrl = normalizePrUrl(row.prUrl);
|
|
30495
|
+
if (!prUrl) continue;
|
|
30496
|
+
const card = cards.get(prUrl);
|
|
30497
|
+
fetchedReviews.push({ prUrl, repoPath });
|
|
30498
|
+
reviewSubjects.set(prUrl, {
|
|
30499
|
+
prUrl,
|
|
30500
|
+
title: row.title.trim() || card?.prTitle || prUrl,
|
|
30501
|
+
threadId: card?.threadId,
|
|
30502
|
+
threadTitle: card?.threadTitle,
|
|
30503
|
+
repoPath
|
|
30504
|
+
});
|
|
30505
|
+
}
|
|
30506
|
+
}
|
|
30507
|
+
const seenRepos = new Set(prev.reviewReposSeen ?? []);
|
|
30508
|
+
const freshRepos = new Set(
|
|
30509
|
+
prev.primed ? successfulRepos.filter((repo) => !seenRepos.has(repo)) : []
|
|
30510
|
+
);
|
|
30511
|
+
const reviewLatch = repos.length ? mergeReviewLatch(prev.reviewRequested, fetchedReviews, successfulRepos) : prev.reviewRequested;
|
|
30512
|
+
const reviewRequested = reviewLatch.filter((row) => !freshRepos.has(row.repoPath)).map(
|
|
30513
|
+
(row) => reviewSubjects.get(row.prUrl) ?? {
|
|
30514
|
+
prUrl: row.prUrl,
|
|
30515
|
+
title: row.prUrl,
|
|
30516
|
+
repoPath: row.repoPath
|
|
30517
|
+
}
|
|
30518
|
+
);
|
|
30519
|
+
const baseline = reviewLatch.filter((row) => freshRepos.has(row.repoPath));
|
|
30520
|
+
const seenCi = new Set((prev.ciSeen ?? []).map((url) => normalizePrUrl(url)).filter(Boolean));
|
|
30521
|
+
const freshCi = new Set(prev.primed ? observed.filter((url) => !seenCi.has(url)) : []);
|
|
30522
|
+
const ciForDiff = ciFailed.filter((subject) => !freshCi.has(subject.prUrl));
|
|
30523
|
+
const edges = diffGithubEdges({ prev, ciFailed: ciForDiff, reviewRequested, now });
|
|
30524
|
+
const delivered = prev.primed && edges.length ? await deliverGithubEdges(edges, deps) : [];
|
|
30525
|
+
const freshFailing = [...freshCi].filter((url) => failing.includes(url));
|
|
30526
|
+
const prevForCommit = freshFailing.length || baseline.length ? {
|
|
30527
|
+
...prev,
|
|
30528
|
+
...freshFailing.length ? {
|
|
30529
|
+
ciFailed: [
|
|
30530
|
+
.../* @__PURE__ */ new Set([
|
|
30531
|
+
...prev.ciFailed.map((url) => normalizePrUrl(url)).filter(Boolean),
|
|
30532
|
+
...freshFailing
|
|
30533
|
+
])
|
|
30534
|
+
]
|
|
30535
|
+
} : {},
|
|
30536
|
+
...baseline.length ? { reviewRequested: mergeReviewLatch(prev.reviewRequested, baseline, [...freshRepos]) } : {}
|
|
30537
|
+
} : prev;
|
|
30538
|
+
const committed = commitGithubEdgeSnapshot({
|
|
30539
|
+
prev: prevForCommit,
|
|
30540
|
+
ciFailed,
|
|
30541
|
+
reviewRequested: reviewLatch,
|
|
30542
|
+
delivered,
|
|
30543
|
+
now
|
|
30544
|
+
});
|
|
30545
|
+
const watched = new Set(repos);
|
|
30546
|
+
const reviewReposSeen = [
|
|
30547
|
+
.../* @__PURE__ */ new Set([
|
|
30548
|
+
...(prev.reviewReposSeen ?? []).filter((repo) => watched.has(repo)),
|
|
30549
|
+
...successfulRepos
|
|
30550
|
+
])
|
|
30551
|
+
].sort();
|
|
30552
|
+
const cardUrls = new Set(cards.keys());
|
|
30553
|
+
const ciSeen = [
|
|
30554
|
+
.../* @__PURE__ */ new Set([
|
|
30555
|
+
...(prev.ciSeen ?? []).map((url) => normalizePrUrl(url)).filter((url) => url && cardUrls.has(url)),
|
|
30556
|
+
...observed
|
|
30557
|
+
])
|
|
30558
|
+
].sort();
|
|
30559
|
+
const next = {
|
|
30560
|
+
...committed,
|
|
30561
|
+
...reviewReposSeen.length ? { reviewReposSeen } : {},
|
|
30562
|
+
...ciSeen.length ? { ciSeen } : {}
|
|
30563
|
+
};
|
|
30564
|
+
if (githubEdgeSnapshotKey(prev) !== githubEdgeSnapshotKey(next)) deps.save(next);
|
|
30565
|
+
return { fired: delivered.length, primed: next.primed };
|
|
30566
|
+
}
|
|
30567
|
+
async function deliverGithubEdges(edges, deps) {
|
|
30568
|
+
const delivered = [];
|
|
30569
|
+
for (const group of routeGithubEdges(edges, (threadId) => deps.parentIdForThread(threadId), deps.designatedId())) {
|
|
30570
|
+
const prompt = formatGithubEdgePrompt(group.edges);
|
|
30571
|
+
try {
|
|
30572
|
+
if (group.targetId) await deps.send(group.targetId, prompt);
|
|
30573
|
+
else await deps.startOrchestration(prompt);
|
|
30574
|
+
delivered.push(...group.edges);
|
|
30575
|
+
} catch {
|
|
30576
|
+
}
|
|
30577
|
+
}
|
|
30578
|
+
return delivered;
|
|
30579
|
+
}
|
|
30580
|
+
function indexCiCards(cards, parentIdForThread2) {
|
|
30581
|
+
const byUrl = /* @__PURE__ */ new Map();
|
|
30582
|
+
for (const card of cards) {
|
|
30583
|
+
if (!acceptOpenReadyPr(card)) continue;
|
|
30584
|
+
const prUrl = normalizePrUrl(card.prUrl);
|
|
30585
|
+
if (!prUrl) continue;
|
|
30586
|
+
const existing = byUrl.get(prUrl);
|
|
30587
|
+
if (!existing) {
|
|
30588
|
+
byUrl.set(prUrl, card);
|
|
30589
|
+
continue;
|
|
30590
|
+
}
|
|
30591
|
+
const existingParent = parentIdForThread2(existing.threadId);
|
|
30592
|
+
const nextParent = parentIdForThread2(card.threadId);
|
|
30593
|
+
if (!existingParent && nextParent) byUrl.set(prUrl, card);
|
|
30594
|
+
}
|
|
30595
|
+
return byUrl;
|
|
30596
|
+
}
|
|
30597
|
+
function subjectFromCard(card, prUrl) {
|
|
30598
|
+
return {
|
|
30599
|
+
prUrl,
|
|
30600
|
+
title: card.prTitle.trim() || card.threadTitle.trim() || prUrl,
|
|
30601
|
+
threadId: card.threadId,
|
|
30602
|
+
threadTitle: card.threadTitle,
|
|
30603
|
+
repoPath: card.repoPath,
|
|
30604
|
+
draft: card.draft,
|
|
30605
|
+
state: card.state
|
|
30606
|
+
};
|
|
30607
|
+
}
|
|
30608
|
+
function liveWorktreeThreads() {
|
|
30609
|
+
return listThreads().filter(
|
|
30610
|
+
(thread) => !isGlobalThread(thread) && !isOrchestratorThread(thread) && thread.wakeOnGithubEdges === true && Boolean(thread.worktreePath?.trim()) && Boolean(thread.repoPath?.trim())
|
|
30611
|
+
);
|
|
30612
|
+
}
|
|
30613
|
+
function listCiCardsFromStore() {
|
|
30614
|
+
const cards = [];
|
|
30615
|
+
for (const thread of liveWorktreeThreads()) {
|
|
30616
|
+
const prUrl = thread.prUrl?.trim() ?? "";
|
|
30617
|
+
if (!prUrl) continue;
|
|
30618
|
+
cards.push({
|
|
30619
|
+
threadId: thread.id,
|
|
30620
|
+
threadTitle: thread.title?.trim() || "Workspace",
|
|
30621
|
+
worktreePath: thread.worktreePath,
|
|
30622
|
+
repoPath: thread.repoPath,
|
|
30623
|
+
prUrl,
|
|
30624
|
+
prTitle: thread.prTitle?.trim() || thread.title?.trim() || prUrl,
|
|
30625
|
+
draft: thread.prIsDraft,
|
|
30626
|
+
state: thread.prState
|
|
30627
|
+
});
|
|
30628
|
+
}
|
|
30629
|
+
return cards;
|
|
30630
|
+
}
|
|
30631
|
+
function listLiveRepoPaths() {
|
|
30632
|
+
return [...new Set(liveWorktreeThreads().map((thread) => thread.repoPath.trim()).filter(Boolean))];
|
|
30633
|
+
}
|
|
30634
|
+
async function fetchCiFailedFromGh(card) {
|
|
30635
|
+
try {
|
|
30636
|
+
const checks = await getPrCiChecks(card.worktreePath, card.prUrl);
|
|
30637
|
+
if (!checks) return null;
|
|
30638
|
+
const failed = ciChecksFailed(checks);
|
|
30639
|
+
persistChecksFailed(card, failed);
|
|
30640
|
+
return failed;
|
|
30641
|
+
} catch {
|
|
30642
|
+
return null;
|
|
30643
|
+
}
|
|
30644
|
+
}
|
|
30645
|
+
function persistChecksFailed(card, failed) {
|
|
30646
|
+
const siblings = threadsSharingWorktree(card.worktreePath);
|
|
30647
|
+
const self = readThread(card.threadId);
|
|
30648
|
+
const targets = siblings.length > 0 ? siblings : self ? [self] : [];
|
|
30649
|
+
for (const thread of targets) {
|
|
30650
|
+
const patch = threadPrChecksFailedPatch(thread, failed);
|
|
30651
|
+
if (Object.keys(patch).length === 0) continue;
|
|
30652
|
+
try {
|
|
30653
|
+
updateThread(thread.id, patch);
|
|
30654
|
+
} catch {
|
|
30655
|
+
}
|
|
30656
|
+
}
|
|
30657
|
+
}
|
|
30658
|
+
async function listMineFromGh(repoPath) {
|
|
30659
|
+
try {
|
|
30660
|
+
const reviewLabel = resolveProjectReviewLabel(loadAppSettings(), repoPath);
|
|
30661
|
+
const rows = await listPrs(repoPath, {
|
|
30662
|
+
queue: "mine",
|
|
30663
|
+
limit: 30,
|
|
30664
|
+
strict: true,
|
|
30665
|
+
...reviewLabel ? { reviewLabel } : {}
|
|
30666
|
+
});
|
|
30667
|
+
return rows.map((row) => ({
|
|
30668
|
+
prUrl: row.url,
|
|
30669
|
+
title: row.title,
|
|
30670
|
+
draft: row.isDraft,
|
|
30671
|
+
state: row.state
|
|
30672
|
+
}));
|
|
30673
|
+
} catch {
|
|
30674
|
+
return null;
|
|
30675
|
+
}
|
|
30676
|
+
}
|
|
30677
|
+
function parentIdForThread(threadId) {
|
|
30678
|
+
const thread = readThread(threadId);
|
|
30679
|
+
if (!thread || thread.status === "archived") return null;
|
|
30680
|
+
const parent = connectedOrchestrator(thread, (id) => readThread(id));
|
|
30681
|
+
if (!parent || parent.status === "archived") return null;
|
|
30682
|
+
return parent.id;
|
|
30683
|
+
}
|
|
30684
|
+
function designatedOrchestratorId() {
|
|
30685
|
+
return pickDesignatedOrchestratorId(
|
|
30686
|
+
listGlobalThreads().map((thread) => ({
|
|
30687
|
+
id: thread.id,
|
|
30688
|
+
status: thread.status,
|
|
30689
|
+
cloud: isCloudCoordinatorThread(thread)
|
|
30690
|
+
}))
|
|
30691
|
+
);
|
|
30692
|
+
}
|
|
30693
|
+
function realDeps() {
|
|
30694
|
+
return {
|
|
30695
|
+
enabled: () => wakeOrchestratorOnGithubEdgesEnabled(),
|
|
30696
|
+
listCiCards: listCiCardsFromStore,
|
|
30697
|
+
fetchCiFailed: fetchCiFailedFromGh,
|
|
30698
|
+
listRepoPaths: listLiveRepoPaths,
|
|
30699
|
+
listReviewRequested: listMineFromGh,
|
|
30700
|
+
parentIdForThread,
|
|
30701
|
+
designatedId: designatedOrchestratorId,
|
|
30702
|
+
send: async (threadId, prompt) => {
|
|
30703
|
+
const { getOrchestrator: getOrchestrator2 } = await Promise.resolve().then(() => (init_orchestrator(), orchestrator_exports));
|
|
30704
|
+
await getOrchestrator2().send(threadId, prompt, { followUp: "queue" });
|
|
30705
|
+
},
|
|
30706
|
+
startOrchestration: async (prompt) => {
|
|
30707
|
+
const { startOrchestration: startOrchestration2 } = await Promise.resolve().then(() => (init_orchestrator(), orchestrator_exports));
|
|
30708
|
+
const defaults = resolveOrchestratorDefaults();
|
|
30709
|
+
await startOrchestration2({
|
|
30710
|
+
goal: prompt,
|
|
30711
|
+
agent: defaults.agent,
|
|
30712
|
+
model: defaults.model,
|
|
30713
|
+
effort: defaults.effort,
|
|
30714
|
+
fast: defaults.fast,
|
|
30715
|
+
autonomy: defaults.autonomy
|
|
30716
|
+
});
|
|
30717
|
+
},
|
|
30718
|
+
load: loadGithubEdgeSnapshot,
|
|
30719
|
+
save: saveGithubEdgeSnapshot,
|
|
30720
|
+
now: () => Date.now()
|
|
30721
|
+
};
|
|
30722
|
+
}
|
|
30723
|
+
var import_node_fs69, import_node_path69, timer, polling, needsBaseline;
|
|
30724
|
+
var init_github_edge_watch = __esm({
|
|
30725
|
+
"src/orchestrator/github-edge-watch.ts"() {
|
|
30726
|
+
"use strict";
|
|
30727
|
+
import_node_fs69 = require("fs");
|
|
30728
|
+
import_node_path69 = require("path");
|
|
30729
|
+
init_pr_gates();
|
|
30730
|
+
init_pr_merge_archive();
|
|
30731
|
+
init_worktree();
|
|
30732
|
+
init_desktop_host();
|
|
30733
|
+
init_app_settings();
|
|
30734
|
+
init_global_workspace();
|
|
30735
|
+
init_paths();
|
|
30736
|
+
init_private_file();
|
|
30737
|
+
init_thread_store();
|
|
30738
|
+
init_chat_tabs();
|
|
30739
|
+
init_connected_orchestrator();
|
|
30740
|
+
init_github_edge();
|
|
30741
|
+
timer = null;
|
|
30742
|
+
polling = false;
|
|
30743
|
+
needsBaseline = true;
|
|
30744
|
+
}
|
|
30745
|
+
});
|
|
30746
|
+
|
|
30056
30747
|
// src/orchestrator/schedule-runner.ts
|
|
30057
30748
|
function formatScheduledPrompt(name, prompt) {
|
|
30058
30749
|
return `[Scheduled: ${name}]
|
|
@@ -30159,8 +30850,8 @@ async function fireSchedule(id) {
|
|
|
30159
30850
|
}
|
|
30160
30851
|
}
|
|
30161
30852
|
function clearTimer(id) {
|
|
30162
|
-
const
|
|
30163
|
-
if (
|
|
30853
|
+
const timer2 = timers.get(id);
|
|
30854
|
+
if (timer2) clearTimeout(timer2);
|
|
30164
30855
|
timers.delete(id);
|
|
30165
30856
|
}
|
|
30166
30857
|
function armOne(schedule) {
|
|
@@ -30176,7 +30867,7 @@ function armOne(schedule) {
|
|
|
30176
30867
|
return;
|
|
30177
30868
|
}
|
|
30178
30869
|
const capped = Math.min(delay2, SET_TIMEOUT_MAX);
|
|
30179
|
-
const
|
|
30870
|
+
const timer2 = setTimeout(() => {
|
|
30180
30871
|
timers.delete(schedule.id);
|
|
30181
30872
|
const live = getSchedule(schedule.id);
|
|
30182
30873
|
if (!live?.enabled) return;
|
|
@@ -30189,7 +30880,7 @@ function armOne(schedule) {
|
|
|
30189
30880
|
if (isThisProcessDesktopHost()) armSchedules();
|
|
30190
30881
|
});
|
|
30191
30882
|
}, capped);
|
|
30192
|
-
timers.set(schedule.id,
|
|
30883
|
+
timers.set(schedule.id, timer2);
|
|
30193
30884
|
}
|
|
30194
30885
|
function armSchedules() {
|
|
30195
30886
|
if (!isThisProcessDesktopHost()) return;
|
|
@@ -30238,9 +30929,9 @@ function recoverFinishedCursorRun(opts) {
|
|
|
30238
30929
|
return best;
|
|
30239
30930
|
}
|
|
30240
30931
|
function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
|
|
30241
|
-
if (!(0,
|
|
30932
|
+
if (!(0, import_node_fs70.existsSync)(runsPath)) return null;
|
|
30242
30933
|
try {
|
|
30243
|
-
const lines = (0,
|
|
30934
|
+
const lines = (0, import_node_fs70.readFileSync)(runsPath, "utf8").split("\n");
|
|
30244
30935
|
let best = null;
|
|
30245
30936
|
for (const line of lines) {
|
|
30246
30937
|
const trimmed = line.trim();
|
|
@@ -30266,11 +30957,11 @@ function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
|
|
|
30266
30957
|
return null;
|
|
30267
30958
|
}
|
|
30268
30959
|
}
|
|
30269
|
-
var
|
|
30960
|
+
var import_node_fs70;
|
|
30270
30961
|
var init_cursor_recover = __esm({
|
|
30271
30962
|
"src/agents/cursor-recover.ts"() {
|
|
30272
30963
|
"use strict";
|
|
30273
|
-
|
|
30964
|
+
import_node_fs70 = require("fs");
|
|
30274
30965
|
init_cursor_store();
|
|
30275
30966
|
}
|
|
30276
30967
|
});
|
|
@@ -30374,7 +31065,7 @@ async function startOrchestration(opts) {
|
|
|
30374
31065
|
}
|
|
30375
31066
|
return ready;
|
|
30376
31067
|
}
|
|
30377
|
-
var import_node_events, import_node_crypto20,
|
|
31068
|
+
var import_node_events, import_node_crypto20, import_node_fs71, LIVE_TURN_SPAWN_GRACE_MS, RUN_SCRIPT_DESKTOP_ADOPT_MS, STALE_AGENT_PID_WAIT_MS, LIGHT_RECONCILE_THROTTLE_MS, Orchestrator, singleton2;
|
|
30378
31069
|
var init_orchestrator = __esm({
|
|
30379
31070
|
"src/orchestrator/orchestrator.ts"() {
|
|
30380
31071
|
"use strict";
|
|
@@ -30383,7 +31074,7 @@ var init_orchestrator = __esm({
|
|
|
30383
31074
|
init_task_state();
|
|
30384
31075
|
init_wait_for_turn();
|
|
30385
31076
|
import_node_crypto20 = require("crypto");
|
|
30386
|
-
|
|
31077
|
+
import_node_fs71 = require("fs");
|
|
30387
31078
|
init_error_detail();
|
|
30388
31079
|
init_run();
|
|
30389
31080
|
init_stale_lock();
|
|
@@ -30459,6 +31150,7 @@ var init_orchestrator = __esm({
|
|
|
30459
31150
|
init_workspaces();
|
|
30460
31151
|
init_global_workspace();
|
|
30461
31152
|
init_caffeinate_hold();
|
|
31153
|
+
init_github_edge_watch();
|
|
30462
31154
|
init_schedule_runner();
|
|
30463
31155
|
init_coordinator_prompt();
|
|
30464
31156
|
init_enqueue_thread_send();
|
|
@@ -30584,7 +31276,7 @@ var init_orchestrator = __esm({
|
|
|
30584
31276
|
this.lightReconcileAt.set(repoPath, Date.now());
|
|
30585
31277
|
for (const thread of listThreads()) {
|
|
30586
31278
|
if (isGlobalThread(thread) || thread.repoPath !== repoPath) continue;
|
|
30587
|
-
if (!(0,
|
|
31279
|
+
if (!(0, import_node_fs71.existsSync)(thread.worktreePath)) {
|
|
30588
31280
|
setStatus(thread.id, "broken", "Worktree missing on disk");
|
|
30589
31281
|
this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
|
|
30590
31282
|
}
|
|
@@ -30613,7 +31305,7 @@ var init_orchestrator = __esm({
|
|
|
30613
31305
|
}
|
|
30614
31306
|
continue;
|
|
30615
31307
|
}
|
|
30616
|
-
if (!(0,
|
|
31308
|
+
if (!(0, import_node_fs71.existsSync)(thread.worktreePath)) {
|
|
30617
31309
|
setStatus(thread.id, "broken", "Worktree missing on disk");
|
|
30618
31310
|
this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
|
|
30619
31311
|
continue;
|
|
@@ -30639,6 +31331,7 @@ var init_orchestrator = __esm({
|
|
|
30639
31331
|
}
|
|
30640
31332
|
this.schedulePendingQuotaResumes();
|
|
30641
31333
|
armSchedules();
|
|
31334
|
+
armGithubEdgeWatch();
|
|
30642
31335
|
}
|
|
30643
31336
|
/** Surface (and, when enabled, clean up) worktrees git knows about but no thread owns. */
|
|
30644
31337
|
async reconcileOrphans(repoPaths) {
|
|
@@ -30777,8 +31470,8 @@ var init_orchestrator = __esm({
|
|
|
30777
31470
|
}
|
|
30778
31471
|
}
|
|
30779
31472
|
clearQuotaResumeTimer(threadId) {
|
|
30780
|
-
const
|
|
30781
|
-
if (
|
|
31473
|
+
const timer2 = this.quotaResumeTimers.get(threadId);
|
|
31474
|
+
if (timer2) clearTimeout(timer2);
|
|
30782
31475
|
this.quotaResumeTimers.delete(threadId);
|
|
30783
31476
|
}
|
|
30784
31477
|
/** Schedule (or fire) auto-retry after a provider session/usage limit reset. */
|
|
@@ -30787,11 +31480,11 @@ var init_orchestrator = __esm({
|
|
|
30787
31480
|
updateThread(threadId, { quotaResumeAt: resumeAt.toISOString() });
|
|
30788
31481
|
const delay2 = Math.max(5e3, resumeAt.getTime() - Date.now());
|
|
30789
31482
|
const capped = Math.min(delay2, 2147483647);
|
|
30790
|
-
const
|
|
31483
|
+
const timer2 = setTimeout(() => {
|
|
30791
31484
|
this.quotaResumeTimers.delete(threadId);
|
|
30792
31485
|
void this.resumeAfterQuotaWait(threadId);
|
|
30793
31486
|
}, capped);
|
|
30794
|
-
this.quotaResumeTimers.set(threadId,
|
|
31487
|
+
this.quotaResumeTimers.set(threadId, timer2);
|
|
30795
31488
|
}
|
|
30796
31489
|
schedulePendingQuotaResumes() {
|
|
30797
31490
|
for (const thread of listThreads({ includeArchived: false })) {
|
|
@@ -32439,11 +33132,11 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
32439
33132
|
const start = Date.now();
|
|
32440
33133
|
return new Promise((resolve3, reject) => {
|
|
32441
33134
|
let settled = false;
|
|
32442
|
-
let
|
|
33135
|
+
let timer2;
|
|
32443
33136
|
const finish = (fn) => {
|
|
32444
33137
|
if (settled) return;
|
|
32445
33138
|
settled = true;
|
|
32446
|
-
if (
|
|
33139
|
+
if (timer2) clearInterval(timer2);
|
|
32447
33140
|
off();
|
|
32448
33141
|
fn();
|
|
32449
33142
|
};
|
|
@@ -32469,7 +33162,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
32469
33162
|
}
|
|
32470
33163
|
}
|
|
32471
33164
|
});
|
|
32472
|
-
|
|
33165
|
+
timer2 = setInterval(() => {
|
|
32473
33166
|
const raw = readThread(thread.id);
|
|
32474
33167
|
if (!raw) {
|
|
32475
33168
|
finish(() => reject(new Error(`Thread not found: ${thread.id}`)));
|
|
@@ -33114,7 +33807,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
33114
33807
|
this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
|
|
33115
33808
|
return restored2;
|
|
33116
33809
|
}
|
|
33117
|
-
if (!(0,
|
|
33810
|
+
if (!(0, import_node_fs71.existsSync)(thread.worktreePath)) {
|
|
33118
33811
|
if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
|
|
33119
33812
|
throw new Error(
|
|
33120
33813
|
`Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
|
|
@@ -33305,7 +33998,7 @@ function createClippedMcpServer() {
|
|
|
33305
33998
|
// src/mcp/server.ts
|
|
33306
33999
|
var import_zod12 = require("zod");
|
|
33307
34000
|
var import_node_crypto24 = require("crypto");
|
|
33308
|
-
var
|
|
34001
|
+
var import_node_path74 = require("path");
|
|
33309
34002
|
init_orchestrator();
|
|
33310
34003
|
init_task_state();
|
|
33311
34004
|
init_worktree();
|
|
@@ -34059,6 +34752,52 @@ init_chat_tabs();
|
|
|
34059
34752
|
init_connected_orchestrator();
|
|
34060
34753
|
init_workspace_tags();
|
|
34061
34754
|
|
|
34755
|
+
// src/threads/wake-on-github-edges.ts
|
|
34756
|
+
init_global_workspace();
|
|
34757
|
+
init_app_settings();
|
|
34758
|
+
init_thread_store();
|
|
34759
|
+
init_worktree_labels();
|
|
34760
|
+
init_chat_tabs();
|
|
34761
|
+
function wakeOnGithubEdgesTargetRef(opts) {
|
|
34762
|
+
const requested = opts.requestedRef?.trim() || "";
|
|
34763
|
+
if (!opts.ownWorktreeOnly) {
|
|
34764
|
+
if (!requested) throw new Error("Pass a chat id on the workspace.");
|
|
34765
|
+
return requested;
|
|
34766
|
+
}
|
|
34767
|
+
const caller = opts.caller;
|
|
34768
|
+
if (!caller || isGlobalThread(caller) || caller.sourceType === "orchestration") {
|
|
34769
|
+
throw new Error("CI and review wakes belong on a project workspace. This chat is not one.");
|
|
34770
|
+
}
|
|
34771
|
+
if (!requested || requested === caller.id) return caller.id;
|
|
34772
|
+
const other = opts.find(requested);
|
|
34773
|
+
if (!other || normalizeWorktreePath(other.worktreePath) !== normalizeWorktreePath(caller.worktreePath)) {
|
|
34774
|
+
throw new Error("You can only change this switch on this workspace.");
|
|
34775
|
+
}
|
|
34776
|
+
return other.id;
|
|
34777
|
+
}
|
|
34778
|
+
function applyWakeOnGithubEdges(threadRef, enabled) {
|
|
34779
|
+
if (!wakeOrchestratorOnGithubEdgesEnabled()) {
|
|
34780
|
+
throw new Error(
|
|
34781
|
+
"Settings \u2192 Advanced \u2192 Wake orchestrator on CI / review-requested is off. Turn that on in Settings. Do not change it from this chat."
|
|
34782
|
+
);
|
|
34783
|
+
}
|
|
34784
|
+
const thread = findThreadByRef(threadRef);
|
|
34785
|
+
if (!thread) throw new Error(`Thread not found: ${threadRef}`);
|
|
34786
|
+
if (isGlobalThread(thread) || thread.sourceType === "orchestration") {
|
|
34787
|
+
throw new Error("CI and review wakes belong on a project workspace. Pass a worktree chat id.");
|
|
34788
|
+
}
|
|
34789
|
+
const on = enabled === true;
|
|
34790
|
+
const siblings = threadsSharingWorktree(thread.worktreePath);
|
|
34791
|
+
const targets = siblings.length > 0 ? siblings : [thread];
|
|
34792
|
+
let updated = thread;
|
|
34793
|
+
for (const row of targets) {
|
|
34794
|
+
const written = updateThread(row.id, { wakeOnGithubEdges: on ? true : void 0 });
|
|
34795
|
+
if (!on) delete written.wakeOnGithubEdges;
|
|
34796
|
+
if (written.id === thread.id) updated = written;
|
|
34797
|
+
}
|
|
34798
|
+
return updated;
|
|
34799
|
+
}
|
|
34800
|
+
|
|
34062
34801
|
// src/mcp/create-orch-child.ts
|
|
34063
34802
|
init_chat_tabs();
|
|
34064
34803
|
init_worktree_labels();
|
|
@@ -34114,16 +34853,16 @@ var MAX_ORCH_THREADS = 5;
|
|
|
34114
34853
|
var CREATE_THREAD_TIMEOUT_MS = 9e4;
|
|
34115
34854
|
function withTimeout2(promise, ms, label) {
|
|
34116
34855
|
return new Promise((resolve3, reject) => {
|
|
34117
|
-
const
|
|
34856
|
+
const timer2 = setTimeout(() => {
|
|
34118
34857
|
reject(new Error(`${label} timed out after ${Math.round(ms / 1e3)}s`));
|
|
34119
34858
|
}, ms);
|
|
34120
34859
|
promise.then(
|
|
34121
34860
|
(value) => {
|
|
34122
|
-
clearTimeout(
|
|
34861
|
+
clearTimeout(timer2);
|
|
34123
34862
|
resolve3(value);
|
|
34124
34863
|
},
|
|
34125
34864
|
(err) => {
|
|
34126
|
-
clearTimeout(
|
|
34865
|
+
clearTimeout(timer2);
|
|
34127
34866
|
reject(err);
|
|
34128
34867
|
}
|
|
34129
34868
|
);
|
|
@@ -35557,13 +36296,13 @@ function whenFromUpdate(id, args) {
|
|
|
35557
36296
|
}
|
|
35558
36297
|
function createdHint(schedule) {
|
|
35559
36298
|
const awake = scheduleNeedsCaffeinate(schedule) ? " Caffeinate while automations are enabled is now on so the Mac can stay awake until this job is due." : "";
|
|
35560
|
-
const fresh = schedule.threadId ? " This job is removed when that chat is archived." : schedule.archiveChat === false ? " This job leaves the new chat open so you can keep talking." : " A new Global chat is archived when the run finishes (History keeps the last 5 runs). Pass archiveChat=false to leave it open.";
|
|
36299
|
+
const fresh = schedule.threadId ? " This job is removed when that chat is archived." : schedule.archiveChat === false ? " This job leaves the new chat open so you can keep talking." : " A new Global chat is archived when the run finishes (History keeps the last 5 archived chats; the schedule keeps the last 10 runs). Pass archiveChat=false to leave it open.";
|
|
35561
36300
|
return `Fires while Sideboard.app is running.${fresh}${awake}`;
|
|
35562
36301
|
}
|
|
35563
36302
|
function registerScheduleTools(server) {
|
|
35564
36303
|
server.tool(
|
|
35565
36304
|
"list_schedules",
|
|
35566
|
-
"List local Sideboard automations that trigger a chat when due. Jobs fire only while Sideboard.app is running on this Mac (sleep skips until wake). Shown in the sidebar after Board.",
|
|
36305
|
+
"List local Sideboard automations that trigger a chat when due. Each row includes runs, the last 10 fires ({at, threadId, error}), newest first. Jobs fire only while Sideboard.app is running on this Mac (sleep skips until wake; a skip is not a failed run). Shown in the sidebar after Board.",
|
|
35567
36306
|
{},
|
|
35568
36307
|
async () => {
|
|
35569
36308
|
try {
|
|
@@ -35575,7 +36314,7 @@ function registerScheduleTools(server) {
|
|
|
35575
36314
|
);
|
|
35576
36315
|
server.tool(
|
|
35577
36316
|
"create_schedule",
|
|
35578
|
-
"Create a local automation that, when due, sends a prompt to an existing chat (chatId) or starts a new Global orchestration chat (omit chatId). Pass chatId=self to continue this chat. A job bound to a chat is removed when that chat is archived or gone; it does not start a new Global chat. Omit chatId only for a Global automation that should outlive this chat. Exactly one of at (ISO datetime), every (15m/1h/6h/1d), time (HH:mm, with days such as weekdays or mon,wed), or cron (5-field). Recurring jobs without chatId open a new Global chat each run and archive it when that run finishes unless archiveChat is false (leave the chat open to keep talking, for example a morning start-my-day run). History keeps the last 5 archived
|
|
36317
|
+
"Create a local automation that, when due, sends a prompt to an existing chat (chatId) or starts a new Global orchestration chat (omit chatId). Pass chatId=self to continue this chat. A job bound to a chat is removed when that chat is archived or gone; it does not start a new Global chat. Omit chatId only for a Global automation that should outlive this chat. Exactly one of at (ISO datetime), every (15m/1h/6h/1d), time (HH:mm, with days such as weekdays or mon,wed), or cron (5-field). Recurring jobs without chatId open a new Global chat each run and archive it when that run finishes unless archiveChat is false (leave the chat open to keep talking, for example a morning start-my-day run). History keeps the last 5 archived chats for that automation, and the schedule keeps the last 10 runs. To schedule a prompt from this chat, call this tool with that prompt (omit chatId for a new Global chat, or chatId=self). Creating or enabling a future job turns on Settings \u2192 Advanced \u2192 Caffeinate while automations are enabled so the Mac stays awake until due. Sideboard.app must be running for the job to fire.",
|
|
35579
36318
|
{
|
|
35580
36319
|
prompt: import_zod10.z.string().describe("User message / goal queued when the automation fires"),
|
|
35581
36320
|
name: import_zod10.z.string().optional(),
|
|
@@ -35715,8 +36454,8 @@ var import_zod11 = require("zod");
|
|
|
35715
36454
|
|
|
35716
36455
|
// src/order/order.ts
|
|
35717
36456
|
var import_node_crypto21 = require("crypto");
|
|
35718
|
-
var
|
|
35719
|
-
var
|
|
36457
|
+
var import_node_fs72 = require("fs");
|
|
36458
|
+
var import_node_path70 = require("path");
|
|
35720
36459
|
init_paths();
|
|
35721
36460
|
init_private_file();
|
|
35722
36461
|
init_thread_store();
|
|
@@ -36295,7 +37034,7 @@ function showPlanMessage(docs, worktree) {
|
|
|
36295
37034
|
|
|
36296
37035
|
// src/order/order.ts
|
|
36297
37036
|
function orderPath() {
|
|
36298
|
-
return (0,
|
|
37037
|
+
return (0, import_node_path70.join)(appDataDir(), "order.json");
|
|
36299
37038
|
}
|
|
36300
37039
|
function emptyFile() {
|
|
36301
37040
|
return { plans: [], edges: [], marks: [] };
|
|
@@ -36358,9 +37097,9 @@ function asMark(value) {
|
|
|
36358
37097
|
}
|
|
36359
37098
|
function readFile() {
|
|
36360
37099
|
const path = orderPath();
|
|
36361
|
-
if (!(0,
|
|
37100
|
+
if (!(0, import_node_fs72.existsSync)(path)) return emptyFile();
|
|
36362
37101
|
try {
|
|
36363
|
-
const parsed = JSON.parse((0,
|
|
37102
|
+
const parsed = JSON.parse((0, import_node_fs72.readFileSync)(path, "utf8"));
|
|
36364
37103
|
if (!parsed || typeof parsed !== "object") return emptyFile();
|
|
36365
37104
|
const raw = parsed;
|
|
36366
37105
|
const edges = Array.isArray(raw.edges) ? raw.edges.map(asEdge).filter((row) => Boolean(row)) : [];
|
|
@@ -36857,7 +37596,7 @@ function registerOrderTools(server) {
|
|
|
36857
37596
|
|
|
36858
37597
|
// src/agent-rpc/handlers.ts
|
|
36859
37598
|
var import_node_crypto22 = require("crypto");
|
|
36860
|
-
var
|
|
37599
|
+
var import_node_path71 = require("path");
|
|
36861
37600
|
init_wait_for_job();
|
|
36862
37601
|
init_wait_for_turn();
|
|
36863
37602
|
|
|
@@ -36922,27 +37661,27 @@ init_gh_errors();
|
|
|
36922
37661
|
init_git_auth_mode();
|
|
36923
37662
|
|
|
36924
37663
|
// src/board/load-home-board.ts
|
|
36925
|
-
var
|
|
36926
|
-
var
|
|
37664
|
+
var import_node_fs74 = require("fs");
|
|
37665
|
+
var import_node_path73 = require("path");
|
|
36927
37666
|
init_worktree();
|
|
36928
37667
|
init_paths();
|
|
36929
37668
|
|
|
36930
37669
|
// src/board/board-pins.ts
|
|
36931
37670
|
var import_node_crypto23 = require("crypto");
|
|
36932
|
-
var
|
|
36933
|
-
var
|
|
37671
|
+
var import_node_fs73 = require("fs");
|
|
37672
|
+
var import_node_path72 = require("path");
|
|
36934
37673
|
init_paths();
|
|
36935
37674
|
init_home_board();
|
|
36936
37675
|
var FILE = "home-board-pins.json";
|
|
36937
37676
|
var VERSION = 1;
|
|
36938
37677
|
function pinsFile() {
|
|
36939
|
-
return (0,
|
|
37678
|
+
return (0, import_node_path72.join)(appDataDir(), FILE);
|
|
36940
37679
|
}
|
|
36941
37680
|
function readDisk() {
|
|
36942
37681
|
const path = pinsFile();
|
|
36943
|
-
if (!(0,
|
|
37682
|
+
if (!(0, import_node_fs73.existsSync)(path)) return [];
|
|
36944
37683
|
try {
|
|
36945
|
-
const raw = JSON.parse((0,
|
|
37684
|
+
const raw = JSON.parse((0, import_node_fs73.readFileSync)(path, "utf8"));
|
|
36946
37685
|
if (raw?.version !== VERSION || !Array.isArray(raw.items)) return [];
|
|
36947
37686
|
return raw.items.filter((item) => item?.id && item.kind && item.ref);
|
|
36948
37687
|
} catch {
|
|
@@ -36950,8 +37689,8 @@ function readDisk() {
|
|
|
36950
37689
|
}
|
|
36951
37690
|
}
|
|
36952
37691
|
function writeDisk(items) {
|
|
36953
|
-
(0,
|
|
36954
|
-
(0,
|
|
37692
|
+
(0, import_node_fs73.mkdirSync)(appDataDir(), { recursive: true });
|
|
37693
|
+
(0, import_node_fs73.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
|
|
36955
37694
|
}
|
|
36956
37695
|
function listBoardPins() {
|
|
36957
37696
|
return readDisk();
|
|
@@ -36972,7 +37711,7 @@ function homeBoardWorkspaceKey(workspaces) {
|
|
|
36972
37711
|
return workspaces.map((w) => w.path).filter(Boolean).sort().join("\n");
|
|
36973
37712
|
}
|
|
36974
37713
|
function cacheFile() {
|
|
36975
|
-
return (0,
|
|
37714
|
+
return (0, import_node_path73.join)(appDataDir(), "home-board-cache.json");
|
|
36976
37715
|
}
|
|
36977
37716
|
function emptyInputs() {
|
|
36978
37717
|
return {
|
|
@@ -36998,9 +37737,9 @@ function shouldCacheHomeBoardInputs(inputs) {
|
|
|
36998
37737
|
}
|
|
36999
37738
|
function readDiskCache() {
|
|
37000
37739
|
const path = cacheFile();
|
|
37001
|
-
if (!(0,
|
|
37740
|
+
if (!(0, import_node_fs74.existsSync)(path)) return null;
|
|
37002
37741
|
try {
|
|
37003
|
-
const raw = JSON.parse((0,
|
|
37742
|
+
const raw = JSON.parse((0, import_node_fs74.readFileSync)(path, "utf8"));
|
|
37004
37743
|
if (raw?.version !== CACHE_VERSION || typeof raw.fetchedAt !== "number") {
|
|
37005
37744
|
return null;
|
|
37006
37745
|
}
|
|
@@ -37014,8 +37753,8 @@ function readDiskCache() {
|
|
|
37014
37753
|
}
|
|
37015
37754
|
function writeDiskCache(entry) {
|
|
37016
37755
|
try {
|
|
37017
|
-
(0,
|
|
37018
|
-
(0,
|
|
37756
|
+
(0, import_node_fs74.mkdirSync)(appDataDir(), { recursive: true });
|
|
37757
|
+
(0, import_node_fs74.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
|
|
37019
37758
|
} catch {
|
|
37020
37759
|
}
|
|
37021
37760
|
}
|
|
@@ -37270,7 +38009,7 @@ async function startMcpServer() {
|
|
|
37270
38009
|
async () => {
|
|
37271
38010
|
const threads = orch.getThreads();
|
|
37272
38011
|
const lines = threads.map((t) => {
|
|
37273
|
-
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0,
|
|
38012
|
+
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path74.basename)(t.repoPath) || t.repoPath;
|
|
37274
38013
|
const live = orch.threadLooksLive(t) ? readTurnLive(t.id) : null;
|
|
37275
38014
|
const parent = t.parentThreadId ? ` parent:${t.parentThreadId.slice(0, 8)}` : "";
|
|
37276
38015
|
const preview = lastMessagePreview(t.messages, 80);
|
|
@@ -37750,6 +38489,36 @@ async function startMcpServer() {
|
|
|
37750
38489
|
}
|
|
37751
38490
|
}
|
|
37752
38491
|
);
|
|
38492
|
+
server.tool(
|
|
38493
|
+
"set_wake_on_github_edges",
|
|
38494
|
+
worktreeProfile ? "Opt this checkout into orchestrator wakes when CI starts failing or GitHub requests a review. Omit ref. Only works after Settings \u2192 Advanced \u2192 Wake orchestrator on CI / review-requested is on. Do not change that Advanced switch." : "Opt a project workspace into CI and review-request wakes. Pass any chat id on that checkout. Only works after Settings \u2192 Advanced \u2192 Wake orchestrator on CI / review-requested is already on. Do not change that Advanced switch. Not for orchestration chats.",
|
|
38495
|
+
{
|
|
38496
|
+
ref: import_zod12.z.string().optional().describe(
|
|
38497
|
+
worktreeProfile ? "Omit for this chat. Another chat id only if it is on this same checkout." : "Chat id on the workspace."
|
|
38498
|
+
),
|
|
38499
|
+
enabled: import_zod12.z.boolean().describe("True opts the checkout in. False turns it off.")
|
|
38500
|
+
},
|
|
38501
|
+
async ({ ref, enabled }) => {
|
|
38502
|
+
try {
|
|
38503
|
+
const callerId = process.env[SIDEBOARD_THREAD_ID_ENV]?.trim() || "";
|
|
38504
|
+
const target = wakeOnGithubEdgesTargetRef({
|
|
38505
|
+
ownWorktreeOnly: worktreeProfile,
|
|
38506
|
+
caller: callerId ? orch.getThread(callerId) : null,
|
|
38507
|
+
requestedRef: ref,
|
|
38508
|
+
find: (id) => orch.getThread(id)
|
|
38509
|
+
});
|
|
38510
|
+
const thread = applyWakeOnGithubEdges(target, enabled);
|
|
38511
|
+
return mcpJson({
|
|
38512
|
+
id: thread.id,
|
|
38513
|
+
worktreePath: thread.worktreePath,
|
|
38514
|
+
wakeOnGithubEdges: thread.wakeOnGithubEdges === true
|
|
38515
|
+
});
|
|
38516
|
+
} catch (err) {
|
|
38517
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
38518
|
+
return mcpJson({ ok: false, message }, true);
|
|
38519
|
+
}
|
|
38520
|
+
}
|
|
38521
|
+
);
|
|
37753
38522
|
if (!worktreeProfile) {
|
|
37754
38523
|
registerConnectedIssueVendorTools(server);
|
|
37755
38524
|
const { getCaffeinateHold: getCaffeinateHold2, setCaffeinateHold: setCaffeinateHold2 } = await Promise.resolve().then(() => (init_caffeinate_hold(), caffeinate_hold_exports));
|