@sideboard-ai/core 0.1.229 → 0.1.231
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-B7G4BQTS.js → agents-ENAQHQRZ.js} +4 -4
- package/dist/{agents-ZKP7QNXA.js → agents-TCTEAK6M.js} +4 -4
- package/dist/{chunk-F3GT6DQW.js → chunk-4CZ25DO2.js} +1 -1
- package/dist/{chunk-3IMSQNTS.js → chunk-4VGCG2HV.js} +17 -0
- package/dist/{chunk-T7Y5ULHM.js → chunk-6L25K7BE.js} +3 -3
- package/dist/{chunk-LULHFLPU.js → chunk-FA4CPYCY.js} +3 -3
- package/dist/{chunk-7YKXBFQE.js → chunk-HZFLKVGC.js} +2 -2
- package/dist/{chunk-UHT6OS7V.js → chunk-HZLZ34FK.js} +145 -15
- package/dist/{chunk-6HKGCUDN.js → chunk-JJRRLCCS.js} +143 -14
- package/dist/{chunk-AMMRFFB7.js → chunk-N5TX66CD.js} +1 -1
- package/dist/{chunk-N7UXGM3Y.js → chunk-UNTOZA3C.js} +2 -2
- package/dist/{chunk-HY2GFZ5S.js → chunk-XJETIO4K.js} +17 -0
- package/dist/{coordinator-prompt-DZMMCDRW.js → coordinator-prompt-DFXYTM6D.js} +3 -3
- package/dist/{coordinator-prompt-RL3GKIAQ.js → coordinator-prompt-YKLXQTWH.js} +3 -3
- package/dist/{global-workspace-QW4OXCLJ.js → global-workspace-4SPANNJT.js} +3 -3
- package/dist/{global-workspace-G3QEVRGZ.js → global-workspace-EYZKYHAO.js} +3 -3
- package/dist/index.cjs +174 -17
- package/dist/index.d.cts +53 -5
- package/dist/index.d.ts +53 -5
- package/dist/index.js +10 -6
- package/dist/mcp/run-stdio.cjs +159 -7
- package/dist/mcp/run-stdio.js +6 -6
- package/dist/{orchestrator-GKAHLGXT.js → orchestrator-HMJPNUN5.js} +7 -5
- package/dist/{orchestrator-X4VFA5WW.js → orchestrator-ZT3SJVKF.js} +7 -5
- package/dist/{thread-store-KDPPXJJ3.js → thread-store-FBK5SZ5P.js} +1 -1
- package/dist/{thread-store-N6WQIWZ4.js → thread-store-IKJD4EOK.js} +1 -1
- package/dist/{workspaces-77C5XQEY.js → workspaces-73Y7IJY2.js} +3 -3
- package/dist/{workspaces-WXRPLT2N.js → workspaces-FQCSCTNH.js} +3 -3
- package/dist/{worktree-P67WAJKH.js → worktree-36VEFUJN.js} +2 -2
- package/dist/{worktree-L6FJXFUC.js → worktree-DOPRKG7K.js} +2 -2
- package/package.json +1 -1
|
@@ -50,14 +50,14 @@ import {
|
|
|
50
50
|
resolveQuotaFallbackAgent,
|
|
51
51
|
turnCostUsdFromCursorUsage,
|
|
52
52
|
whichOnPath
|
|
53
|
-
} from "./chunk-
|
|
54
|
-
import "./chunk-
|
|
53
|
+
} from "./chunk-6L25K7BE.js";
|
|
54
|
+
import "./chunk-UNTOZA3C.js";
|
|
55
55
|
import "./chunk-SXFRXNBM.js";
|
|
56
56
|
import "./chunk-P2BSMNHB.js";
|
|
57
57
|
import "./chunk-VKQGAWHY.js";
|
|
58
|
-
import "./chunk-
|
|
58
|
+
import "./chunk-4CZ25DO2.js";
|
|
59
59
|
import "./chunk-D6JWYJ4P.js";
|
|
60
|
-
import "./chunk-
|
|
60
|
+
import "./chunk-XJETIO4K.js";
|
|
61
61
|
import "./chunk-X5B3OS5I.js";
|
|
62
62
|
import "./chunk-SZJZEFTY.js";
|
|
63
63
|
import {
|
|
@@ -44,9 +44,9 @@ import {
|
|
|
44
44
|
resolveLoginCommand,
|
|
45
45
|
resolveQuotaFallbackAgent,
|
|
46
46
|
whichOnPath
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
import "./chunk-
|
|
49
|
-
import "./chunk-
|
|
47
|
+
} from "./chunk-FA4CPYCY.js";
|
|
48
|
+
import "./chunk-HZFLKVGC.js";
|
|
49
|
+
import "./chunk-N5TX66CD.js";
|
|
50
50
|
import "./chunk-6K64FJDD.js";
|
|
51
51
|
import "./chunk-PO4M4JAJ.js";
|
|
52
52
|
import "./chunk-ZXJMAKEP.js";
|
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
} from "./chunk-I5NC7DWO.js";
|
|
67
67
|
import "./chunk-WDRMZKVB.js";
|
|
68
68
|
import "./chunk-JT7R45JB.js";
|
|
69
|
-
import "./chunk-
|
|
69
|
+
import "./chunk-4VGCG2HV.js";
|
|
70
70
|
import "./chunk-7J72QJOM.js";
|
|
71
71
|
import "./chunk-77WWLBCI.js";
|
|
72
72
|
import "./chunk-WFUDY6PC.js";
|
|
@@ -33,6 +33,22 @@ function resolveThreadEffort(raw) {
|
|
|
33
33
|
if (raw.fast) return "low";
|
|
34
34
|
return "high";
|
|
35
35
|
}
|
|
36
|
+
function normalizeRunScriptRequest(raw) {
|
|
37
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
38
|
+
const req = raw;
|
|
39
|
+
if (req.op !== "start" && req.op !== "stop") return void 0;
|
|
40
|
+
if (typeof req.requestId !== "string" || !req.requestId.trim()) return void 0;
|
|
41
|
+
if (typeof req.requestedAt !== "string" || !req.requestedAt.trim()) return void 0;
|
|
42
|
+
return {
|
|
43
|
+
op: req.op,
|
|
44
|
+
scriptName: req.scriptName ?? null,
|
|
45
|
+
requestId: req.requestId,
|
|
46
|
+
requestedAt: req.requestedAt,
|
|
47
|
+
claimedAt: req.claimedAt ?? null,
|
|
48
|
+
fulfilledAt: req.fulfilledAt ?? null,
|
|
49
|
+
error: req.error ?? null
|
|
50
|
+
};
|
|
51
|
+
}
|
|
36
52
|
function normalizeThread(raw) {
|
|
37
53
|
return {
|
|
38
54
|
...raw,
|
|
@@ -56,6 +72,7 @@ function normalizeThread(raw) {
|
|
|
56
72
|
stackLayer: raw.stackLayer ?? null,
|
|
57
73
|
userSetTitle: Boolean(raw.userSetTitle),
|
|
58
74
|
activeRuns: Array.isArray(raw.activeRuns) ? raw.activeRuns : [],
|
|
75
|
+
runScriptRequest: normalizeRunScriptRequest(raw.runScriptRequest),
|
|
59
76
|
quotaResumeAt: raw.quotaResumeAt ?? null,
|
|
60
77
|
quotaContinuedFromId: raw.quotaContinuedFromId ?? null,
|
|
61
78
|
archivedAt: typeof raw.archivedAt === "string" && raw.archivedAt.trim() ? raw.archivedAt.trim() : void 0
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
isOrchestratorThread
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UNTOZA3C.js";
|
|
6
6
|
import {
|
|
7
7
|
applyConnectedTeamToCli,
|
|
8
8
|
brightsyMcpServerName,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
mergeAgentGitAuthEnv,
|
|
21
21
|
resolveAgentGitAuthEnv,
|
|
22
22
|
resolveCodexGitWritableRoots
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-4CZ25DO2.js";
|
|
24
24
|
import {
|
|
25
25
|
enrichPathWithNpmGlobalBin,
|
|
26
26
|
isConductorBundledCli,
|
|
@@ -2548,7 +2548,7 @@ var claudeAdapter = {
|
|
|
2548
2548
|
);
|
|
2549
2549
|
}
|
|
2550
2550
|
const mode = permissionMode(thread);
|
|
2551
|
-
const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-
|
|
2551
|
+
const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-EYZKYHAO.js");
|
|
2552
2552
|
const isOrchestrator = isOrchestratorThread2(thread);
|
|
2553
2553
|
const injectedServers = await buildInjectedMcpServers({
|
|
2554
2554
|
includeSideboard: true,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isOrchestratorThread
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HZFLKVGC.js";
|
|
4
4
|
import {
|
|
5
5
|
codexUnattendedGitConfigArgs,
|
|
6
6
|
mergeAgentGitAuthEnv,
|
|
7
7
|
resolveAgentGitAuthEnv,
|
|
8
8
|
resolveCodexGitWritableRoots
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-N5TX66CD.js";
|
|
10
10
|
import {
|
|
11
11
|
applyConnectedTeamToCli,
|
|
12
12
|
brightsyMcpServerName,
|
|
@@ -2117,7 +2117,7 @@ var claudeAdapter = {
|
|
|
2117
2117
|
);
|
|
2118
2118
|
}
|
|
2119
2119
|
const mode = permissionMode(thread);
|
|
2120
|
-
const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-
|
|
2120
|
+
const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-4SPANNJT.js");
|
|
2121
2121
|
const isOrchestrator = isOrchestratorThread2(thread);
|
|
2122
2122
|
const injectedServers = await buildInjectedMcpServers({
|
|
2123
2123
|
includeSideboard: true,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
resolveRepoRoot,
|
|
7
7
|
takenSlugsFromThread,
|
|
8
8
|
teamSlugFromName
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-N5TX66CD.js";
|
|
10
10
|
import {
|
|
11
11
|
ATTACHMENTS_DIR,
|
|
12
12
|
attachmentsGitignoreBody
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
listThreads,
|
|
30
30
|
updateThread,
|
|
31
31
|
writeThread
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-4VGCG2HV.js";
|
|
33
33
|
import {
|
|
34
34
|
appDataDir,
|
|
35
35
|
globalAgentCwd,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
resolveQuotaFallbackAgent,
|
|
25
25
|
stripBrightsyNdjsonNoise,
|
|
26
26
|
toolDescription
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-FA4CPYCY.js";
|
|
28
28
|
import {
|
|
29
29
|
SLACK_REPLY_FORMATTING,
|
|
30
30
|
addWorkspace,
|
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
stageAbsolutePathsAsAttachments,
|
|
48
48
|
stageBuffersAsAttachments,
|
|
49
49
|
syncWorkspacesFromThreads
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-HZFLKVGC.js";
|
|
51
51
|
import {
|
|
52
52
|
addPrStackLayer,
|
|
53
53
|
allocateTeamName,
|
|
@@ -96,7 +96,7 @@ import {
|
|
|
96
96
|
worktreeDisplayLabelForGroup,
|
|
97
97
|
worktreeNameFromPath,
|
|
98
98
|
worktreeSlugForTicket
|
|
99
|
-
} from "./chunk-
|
|
99
|
+
} from "./chunk-N5TX66CD.js";
|
|
100
100
|
import {
|
|
101
101
|
ATTACHMENTS_DIR,
|
|
102
102
|
DETACHED_JOBS_DIR,
|
|
@@ -185,7 +185,7 @@ import {
|
|
|
185
185
|
updateThread,
|
|
186
186
|
withThreadLock,
|
|
187
187
|
writeThread
|
|
188
|
-
} from "./chunk-
|
|
188
|
+
} from "./chunk-4VGCG2HV.js";
|
|
189
189
|
import {
|
|
190
190
|
appDataDir,
|
|
191
191
|
findConventionSetup,
|
|
@@ -482,7 +482,7 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
482
482
|
await continueOnReply(threadId, prompt);
|
|
483
483
|
return;
|
|
484
484
|
}
|
|
485
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
485
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-ZT3SJVKF.js");
|
|
486
486
|
await getOrchestrator2().send(threadId, prompt);
|
|
487
487
|
} catch {
|
|
488
488
|
}
|
|
@@ -742,6 +742,7 @@ async function pollSlackOutboundWatches(opts) {
|
|
|
742
742
|
}
|
|
743
743
|
|
|
744
744
|
// src/orchestrator/orchestrator.ts
|
|
745
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
745
746
|
import { existsSync as existsSync19 } from "fs";
|
|
746
747
|
|
|
747
748
|
// src/agents/spawn.ts
|
|
@@ -900,9 +901,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
|
|
|
900
901
|
`Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
|
|
901
902
|
);
|
|
902
903
|
}
|
|
903
|
-
const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-
|
|
904
|
+
const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-4SPANNJT.js");
|
|
904
905
|
if (isGlobalThread2(thread)) {
|
|
905
|
-
const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-
|
|
906
|
+
const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-DFXYTM6D.js");
|
|
906
907
|
ensureGlobalCoordinatorCwd2(
|
|
907
908
|
isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
|
|
908
909
|
);
|
|
@@ -2981,6 +2982,11 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
2981
2982
|
return { repoPath, workspace };
|
|
2982
2983
|
}
|
|
2983
2984
|
|
|
2985
|
+
// src/types/thread.ts
|
|
2986
|
+
function isUnclaimedRunScriptRequest(req) {
|
|
2987
|
+
return Boolean(req && !req.claimedAt && !req.fulfilledAt && !req.error);
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2984
2990
|
// src/store/desktop-host.ts
|
|
2985
2991
|
import { readFileSync as readFileSync6, unlinkSync, writeFileSync as writeFileSync3 } from "fs";
|
|
2986
2992
|
import { join as join11 } from "path";
|
|
@@ -4246,7 +4252,7 @@ async function createThread(input, _onSetupLine) {
|
|
|
4246
4252
|
return readThread(thread.id) ?? thread;
|
|
4247
4253
|
}
|
|
4248
4254
|
async function listLinearIssues(agent, repoPath) {
|
|
4249
|
-
const { getAdapter: getAdapter2 } = await import("./agents-
|
|
4255
|
+
const { getAdapter: getAdapter2 } = await import("./agents-TCTEAK6M.js");
|
|
4250
4256
|
await requireAgent(agent, { requireLinear: true });
|
|
4251
4257
|
const adapter = getAdapter2(agent);
|
|
4252
4258
|
if (!adapter.listLinearIssues) {
|
|
@@ -4719,7 +4725,7 @@ async function adoptThread(input) {
|
|
|
4719
4725
|
messages: input.messages ?? []
|
|
4720
4726
|
});
|
|
4721
4727
|
writeThread(thread);
|
|
4722
|
-
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-
|
|
4728
|
+
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-73Y7IJY2.js");
|
|
4723
4729
|
await ensureWorkspace2(repoPath);
|
|
4724
4730
|
const { ensureWorktreeSideboardIgnored: ensureWorktreeSideboardIgnored2 } = await import("./worktree-exclude-L32WEBX6.js");
|
|
4725
4731
|
await ensureWorktreeSideboardIgnored2(input.worktreePath);
|
|
@@ -7401,7 +7407,7 @@ function formatScheduledPrompt(name, prompt) {
|
|
|
7401
7407
|
${prompt}`;
|
|
7402
7408
|
}
|
|
7403
7409
|
async function defaultDeps() {
|
|
7404
|
-
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
7410
|
+
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-ZT3SJVKF.js");
|
|
7405
7411
|
const orch = getOrchestrator2();
|
|
7406
7412
|
return {
|
|
7407
7413
|
findThread: (id) => findThreadByRef(id),
|
|
@@ -7506,6 +7512,7 @@ function armSchedules() {
|
|
|
7506
7512
|
|
|
7507
7513
|
// src/orchestrator/orchestrator.ts
|
|
7508
7514
|
var LIVE_TURN_SPAWN_GRACE_MS = 15e3;
|
|
7515
|
+
var RUN_SCRIPT_DESKTOP_ADOPT_MS = 2e4;
|
|
7509
7516
|
function isPidAlive(pid) {
|
|
7510
7517
|
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
7511
7518
|
try {
|
|
@@ -7584,6 +7591,11 @@ var Orchestrator = class {
|
|
|
7584
7591
|
jobContinueNudged = /* @__PURE__ */ new Set();
|
|
7585
7592
|
/** In-flight startDev per worktree run key — agent MCP + UI Start must not double-spawn. */
|
|
7586
7593
|
startingDev = /* @__PURE__ */ new Map();
|
|
7594
|
+
/**
|
|
7595
|
+
* MCP/CLI poll budget while Electron main adopts `runScriptRequest`.
|
|
7596
|
+
* Tests shorten this so a missing desktop does not wait 20s.
|
|
7597
|
+
*/
|
|
7598
|
+
runScriptAdoptTimeoutMs = RUN_SCRIPT_DESKTOP_ADOPT_MS;
|
|
7587
7599
|
maxConcurrent;
|
|
7588
7600
|
runningCount = 0;
|
|
7589
7601
|
constructor(opts) {
|
|
@@ -7753,6 +7765,58 @@ var Orchestrator = class {
|
|
|
7753
7765
|
this.armDrain(thread.id);
|
|
7754
7766
|
}
|
|
7755
7767
|
}
|
|
7768
|
+
this.adoptPersistedRunScripts();
|
|
7769
|
+
}
|
|
7770
|
+
/**
|
|
7771
|
+
* Adopt run-script start/stop persisted by MCP/CLI while this process owns
|
|
7772
|
+
* live children (desktop host). Spawning in stdio leaves the Run tab on
|
|
7773
|
+
* "Starting…" with no logs — `run_output` never reaches the renderer.
|
|
7774
|
+
*/
|
|
7775
|
+
adoptPersistedRunScripts() {
|
|
7776
|
+
if (!this.shouldOwnRunScripts()) return;
|
|
7777
|
+
for (const thread of listThreads()) {
|
|
7778
|
+
if (thread.status === "archived") continue;
|
|
7779
|
+
const req = thread.runScriptRequest;
|
|
7780
|
+
if (!isUnclaimedRunScriptRequest(req) || !req) continue;
|
|
7781
|
+
const claimedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7782
|
+
const claimed = { ...req, claimedAt };
|
|
7783
|
+
updateThread(thread.id, { runScriptRequest: claimed });
|
|
7784
|
+
void this.applyRunScriptRequest(thread.id, claimed);
|
|
7785
|
+
}
|
|
7786
|
+
}
|
|
7787
|
+
async applyRunScriptRequest(threadId, req) {
|
|
7788
|
+
try {
|
|
7789
|
+
if (req.op === "start") {
|
|
7790
|
+
await this.startDev(threadId, req.scriptName ?? void 0);
|
|
7791
|
+
} else {
|
|
7792
|
+
await this.stopDev(threadId, req.scriptName ?? void 0);
|
|
7793
|
+
}
|
|
7794
|
+
const latest = readThread(threadId);
|
|
7795
|
+
const current = latest?.runScriptRequest;
|
|
7796
|
+
if (current?.requestId === req.requestId && !current.error) {
|
|
7797
|
+
updateThread(threadId, {
|
|
7798
|
+
runScriptRequest: {
|
|
7799
|
+
...current,
|
|
7800
|
+
fulfilledAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
7801
|
+
}
|
|
7802
|
+
});
|
|
7803
|
+
}
|
|
7804
|
+
} catch (err) {
|
|
7805
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
7806
|
+
const latest = readThread(threadId);
|
|
7807
|
+
const current = latest?.runScriptRequest;
|
|
7808
|
+
if (!current || current.requestId !== req.requestId) return;
|
|
7809
|
+
updateThread(threadId, {
|
|
7810
|
+
runScriptRequest: { ...current, error: message }
|
|
7811
|
+
});
|
|
7812
|
+
}
|
|
7813
|
+
}
|
|
7814
|
+
/**
|
|
7815
|
+
* Same rule as agent-queue drain: MCP stdio must not own Electron children
|
|
7816
|
+
* while Sideboard.app is alive.
|
|
7817
|
+
*/
|
|
7818
|
+
shouldOwnRunScripts() {
|
|
7819
|
+
return thisProcessShouldDrainAgentQueues();
|
|
7756
7820
|
}
|
|
7757
7821
|
/**
|
|
7758
7822
|
* Mid-session: a worktree can sit at `running` after the agent process dies
|
|
@@ -8801,6 +8865,13 @@ var Orchestrator = class {
|
|
|
8801
8865
|
"No run script found for this worktree. Add [scripts.run.*] in the worktree\u2019s .sideboard/settings.toml or .conductor/settings.toml (or settings.local.toml on the main repo)."
|
|
8802
8866
|
);
|
|
8803
8867
|
}
|
|
8868
|
+
if (!this.shouldOwnRunScripts()) {
|
|
8869
|
+
const result = await this.requestDesktopRunScript(thread, "start", resolvedName);
|
|
8870
|
+
if (!result) {
|
|
8871
|
+
throw new Error("Desktop did not return a run script port.");
|
|
8872
|
+
}
|
|
8873
|
+
return result;
|
|
8874
|
+
}
|
|
8804
8875
|
const runKey = worktreeRunProcessKey(thread.worktreePath, resolvedName);
|
|
8805
8876
|
const inFlight = this.startingDev.get(runKey);
|
|
8806
8877
|
if (inFlight) return inFlight;
|
|
@@ -8923,8 +8994,65 @@ var Orchestrator = class {
|
|
|
8923
8994
|
});
|
|
8924
8995
|
return { port: handle.port, scriptName: resolvedName, ports: handle.ports };
|
|
8925
8996
|
}
|
|
8926
|
-
|
|
8997
|
+
/**
|
|
8998
|
+
* Persist a run-script intent for the desktop host (MCP/CLI while the board
|
|
8999
|
+
* is alive). Polls until Electron main adopts and fulfills it.
|
|
9000
|
+
*/
|
|
9001
|
+
async requestDesktopRunScript(thread, op, scriptName) {
|
|
9002
|
+
const latest = readThread(thread.id) ?? thread;
|
|
9003
|
+
const pending = latest.runScriptRequest;
|
|
9004
|
+
const claimedAt = pending?.claimedAt;
|
|
9005
|
+
const staleClaim = typeof claimedAt === "string" && Date.now() - Date.parse(claimedAt) > this.runScriptAdoptTimeoutMs;
|
|
9006
|
+
const sameIntent = pending && pending.op === op && (pending.scriptName ?? null) === (scriptName ?? null) && !pending.error && !pending.fulfilledAt && !staleClaim;
|
|
9007
|
+
const request = sameIntent ? pending : {
|
|
9008
|
+
op,
|
|
9009
|
+
scriptName: scriptName ?? null,
|
|
9010
|
+
requestId: randomUUID5(),
|
|
9011
|
+
requestedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
9012
|
+
};
|
|
9013
|
+
if (!sameIntent) {
|
|
9014
|
+
updateThread(thread.id, { runScriptRequest: request });
|
|
9015
|
+
}
|
|
9016
|
+
return this.waitForDesktopRunScript(thread.id, request, op, scriptName);
|
|
9017
|
+
}
|
|
9018
|
+
async waitForDesktopRunScript(threadId, request, op, scriptName) {
|
|
9019
|
+
const deadline = Date.now() + this.runScriptAdoptTimeoutMs;
|
|
9020
|
+
while (Date.now() < deadline) {
|
|
9021
|
+
const latest = readThread(threadId);
|
|
9022
|
+
if (!latest) {
|
|
9023
|
+
throw new Error("Thread disappeared while waiting for the desktop run script.");
|
|
9024
|
+
}
|
|
9025
|
+
const req = latest.runScriptRequest;
|
|
9026
|
+
if (req?.requestId === request.requestId && req.error) {
|
|
9027
|
+
throw new Error(req.error);
|
|
9028
|
+
}
|
|
9029
|
+
const shared = mergeWorktreeActiveRuns(threadsSharingWorktree(latest.worktreePath));
|
|
9030
|
+
const run2 = scriptName ? shared.activeRuns.find((r) => r.scriptName === scriptName) : shared.activeRuns[0];
|
|
9031
|
+
const fulfilled = req?.requestId === request.requestId && Boolean(req.fulfilledAt);
|
|
9032
|
+
const requestGone = !req || req.requestId !== request.requestId;
|
|
9033
|
+
if (op === "start") {
|
|
9034
|
+
if (run2 && (fulfilled || requestGone || run2.startedAt >= request.requestedAt)) {
|
|
9035
|
+
return { port: run2.port, scriptName: run2.scriptName, ports: run2.ports };
|
|
9036
|
+
}
|
|
9037
|
+
if (fulfilled && !run2) {
|
|
9038
|
+
throw new Error("Desktop reported the run script started, but it is not active.");
|
|
9039
|
+
}
|
|
9040
|
+
} else {
|
|
9041
|
+
const gone = scriptName ? !run2 : shared.activeRuns.length === 0;
|
|
9042
|
+
if (fulfilled || gone) return null;
|
|
9043
|
+
}
|
|
9044
|
+
await new Promise((r) => setTimeout(r, 40));
|
|
9045
|
+
}
|
|
9046
|
+
throw new Error(
|
|
9047
|
+
op === "start" ? "Desktop did not start the run script in time. Is Sideboard.app running this worktree?" : "Desktop did not stop the run script in time."
|
|
9048
|
+
);
|
|
9049
|
+
}
|
|
9050
|
+
async stopDev(threadRef, scriptName) {
|
|
8927
9051
|
const thread = this.requireThread(threadRef);
|
|
9052
|
+
if (!this.shouldOwnRunScripts()) {
|
|
9053
|
+
await this.requestDesktopRunScript(thread, "stop", scriptName);
|
|
9054
|
+
return;
|
|
9055
|
+
}
|
|
8928
9056
|
const siblings = threadsSharingWorktree(thread.worktreePath);
|
|
8929
9057
|
const shared = mergeWorktreeActiveRuns(siblings);
|
|
8930
9058
|
if (scriptName) {
|
|
@@ -9787,7 +9915,7 @@ var Orchestrator = class {
|
|
|
9787
9915
|
this.enforceHistoryRetention();
|
|
9788
9916
|
if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
|
|
9789
9917
|
try {
|
|
9790
|
-
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-
|
|
9918
|
+
const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-73Y7IJY2.js");
|
|
9791
9919
|
await ensureWorkspace2(thread.repoPath);
|
|
9792
9920
|
} catch {
|
|
9793
9921
|
}
|
|
@@ -9841,7 +9969,7 @@ var Orchestrator = class {
|
|
|
9841
9969
|
`Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
|
|
9842
9970
|
);
|
|
9843
9971
|
}
|
|
9844
|
-
const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-
|
|
9972
|
+
const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-36VEFUJN.js");
|
|
9845
9973
|
const slug = thread.worktreePath.split("/").pop();
|
|
9846
9974
|
const dest = thread.worktreePath;
|
|
9847
9975
|
await withRepoGitLock(thread.repoPath, async () => {
|
|
@@ -9951,7 +10079,7 @@ async function startOrchestration(opts) {
|
|
|
9951
10079
|
sourceRef: "default",
|
|
9952
10080
|
...createOpts
|
|
9953
10081
|
}).catch(async () => {
|
|
9954
|
-
const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-
|
|
10082
|
+
const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-36VEFUJN.js");
|
|
9955
10083
|
const repo = await resolveRepoRoot2(repoPath);
|
|
9956
10084
|
const def = await resolveDefaultBranch2(repo);
|
|
9957
10085
|
return orch.createThread({
|
|
@@ -9961,7 +10089,7 @@ async function startOrchestration(opts) {
|
|
|
9961
10089
|
repoPath: repo
|
|
9962
10090
|
});
|
|
9963
10091
|
});
|
|
9964
|
-
const { updateThread: upd } = await import("./thread-store-
|
|
10092
|
+
const { updateThread: upd } = await import("./thread-store-IKJD4EOK.js");
|
|
9965
10093
|
const updated = upd(thread.id, {
|
|
9966
10094
|
sourceType: "orchestration",
|
|
9967
10095
|
sourceRef: goal
|
|
@@ -9973,6 +10101,7 @@ async function startOrchestration(opts) {
|
|
|
9973
10101
|
}
|
|
9974
10102
|
|
|
9975
10103
|
export {
|
|
10104
|
+
isUnclaimedRunScriptRequest,
|
|
9976
10105
|
isHomeBoardThread,
|
|
9977
10106
|
BOARD_COLUMN_DEFS,
|
|
9978
10107
|
HOME_BOARD_CACHE_TTL_MS,
|
|
@@ -10221,6 +10350,7 @@ export {
|
|
|
10221
10350
|
formatOptionalServicesDirective,
|
|
10222
10351
|
formatOptionalServicesReminder,
|
|
10223
10352
|
LIVE_TURN_SPAWN_GRACE_MS,
|
|
10353
|
+
RUN_SCRIPT_DESKTOP_ADOPT_MS,
|
|
10224
10354
|
isPidAlive,
|
|
10225
10355
|
waitForPidExit,
|
|
10226
10356
|
resolveSendFollowUp,
|