@sideboard-ai/core 0.1.53 → 0.1.57

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.
Files changed (30) hide show
  1. package/dist/agents/cursor-runner.cjs +83 -7
  2. package/dist/agents/cursor-runner.js +1 -1
  3. package/dist/{agents-KYACODJ3.js → agents-2YYWW723.js} +3 -3
  4. package/dist/{agents-KP7UJEHJ.js → agents-AQFEFKBL.js} +2 -2
  5. package/dist/{app-settings-LZP632KI.js → app-settings-2LQNRTBE.js} +3 -1
  6. package/dist/{app-settings-7XVDQJ7F.js → app-settings-73DI4B6T.js} +3 -1
  7. package/dist/{chunk-VG22SETP.js → chunk-3WJAUKIL.js} +83 -7
  8. package/dist/{chunk-GNML24AW.js → chunk-5DMYULLC.js} +1 -1
  9. package/dist/{chunk-A6HVEMIB.js → chunk-7F454EE2.js} +86 -11
  10. package/dist/{chunk-BZST4HMJ.js → chunk-C3J4GDW4.js} +172 -21
  11. package/dist/{chunk-HBJSHRY2.js → chunk-C4BCC5X5.js} +17 -1
  12. package/dist/{chunk-T5QQVXK3.js → chunk-DIOF73S2.js} +17 -1
  13. package/dist/{chunk-UEAHMGHW.js → chunk-DQJ5D42H.js} +16 -2
  14. package/dist/{chunk-YOWIYAVA.js → chunk-EBWEKG52.js} +36 -11
  15. package/dist/{chunk-XX5BB7NV.js → chunk-S42XDFKF.js} +36 -11
  16. package/dist/{chunk-LRLKJM3O.js → chunk-UA5NDAHL.js} +16 -2
  17. package/dist/{chunk-YDXQ72MD.js → chunk-V2DUTUNC.js} +1 -1
  18. package/dist/{coordinator-prompt-S6JZD5EF.js → coordinator-prompt-ICF36NUQ.js} +2 -1
  19. package/dist/{coordinator-prompt-6FXVTSFN.js → coordinator-prompt-RBKUNRPR.js} +2 -1
  20. package/dist/{global-workspace-EV4G2WMQ.js → global-workspace-667XLBW6.js} +3 -2
  21. package/dist/{global-workspace-MSX2K27Y.js → global-workspace-S7VLWPWG.js} +3 -2
  22. package/dist/index.cjs +338 -55
  23. package/dist/index.d.cts +36 -2
  24. package/dist/index.d.ts +36 -2
  25. package/dist/index.js +121 -40
  26. package/dist/mcp/run-stdio.cjs +332 -51
  27. package/dist/mcp/run-stdio.js +121 -41
  28. package/dist/{workspaces-AYTBR6KQ.js → workspaces-FPJJXXAE.js} +4 -3
  29. package/dist/{workspaces-3RQQZQRO.js → workspaces-LYIDE2VR.js} +4 -3
  30. package/package.json +1 -1
@@ -16,29 +16,19 @@ import {
16
16
  pushTurnStderr,
17
17
  resolveQuotaFallbackAgent,
18
18
  summarizeTurnStderr
19
- } from "../chunk-BZST4HMJ.js";
19
+ } from "../chunk-C3J4GDW4.js";
20
20
  import "../chunk-H6GGDLYS.js";
21
21
  import {
22
22
  addWorkspace,
23
23
  ensureWorkspace,
24
24
  removeWorkspace,
25
25
  syncWorkspacesFromThreads
26
- } from "../chunk-YDXQ72MD.js";
26
+ } from "../chunk-V2DUTUNC.js";
27
27
  import {
28
28
  extractPresentedPlan,
29
29
  readPlanFile,
30
30
  writePlanFile
31
31
  } from "../chunk-N5PM7HGQ.js";
32
- import {
33
- childEnvWithAppSettings,
34
- getLinearApiKey,
35
- isLinearConnected,
36
- loadAppSettings,
37
- orchestrationQuotaFallbackAgent,
38
- orchestrationQuotaOnLimit,
39
- resolveEffectiveIssueSource,
40
- updateAdvancedSettings
41
- } from "../chunk-HBJSHRY2.js";
42
32
  import {
43
33
  GLOBAL_WORKSPACE_ID,
44
34
  healOrchestrationSoccerTitles,
@@ -47,7 +37,7 @@ import {
47
37
  isGlobalThread,
48
38
  isOrchestratorThread,
49
39
  orchestratorSessionPoisonedByBuiltins
50
- } from "../chunk-YOWIYAVA.js";
40
+ } from "../chunk-EBWEKG52.js";
51
41
  import {
52
42
  assertOrchestratorCapableAgent
53
43
  } from "../chunk-S2LL5HA4.js";
@@ -56,7 +46,7 @@ import {
56
46
  coordinatorTurnReminder,
57
47
  enrichWorkspacesWithGithub,
58
48
  ensureGlobalCoordinatorCwd
59
- } from "../chunk-UEAHMGHW.js";
49
+ } from "../chunk-DQJ5D42H.js";
60
50
  import {
61
51
  addPrStackLayer,
62
52
  allocateTeamName,
@@ -117,6 +107,17 @@ import {
117
107
  git,
118
108
  run
119
109
  } from "../chunk-ZNM4MAN4.js";
110
+ import {
111
+ childEnvWithAppSettings,
112
+ getLinearApiKey,
113
+ isLinearConnected,
114
+ loadAppSettings,
115
+ orchestrationQuotaFallbackAgent,
116
+ orchestrationQuotaOnLimit,
117
+ resolveEffectiveIssueSource,
118
+ resolveNewThreadOptions,
119
+ updateAdvancedSettings
120
+ } from "../chunk-C4BCC5X5.js";
120
121
  import "../chunk-KGZBYWZ3.js";
121
122
  import {
122
123
  loadRepoSettings,
@@ -311,9 +312,25 @@ function applyAgentEvent(parts, event) {
311
312
  ];
312
313
  }
313
314
  if (event.type === "tool_result") {
314
- const next = parts.map((p) => {
315
- if (p.type !== "tool" || p.id !== event.id) return p;
316
- const fromResult = parseDiffStat(event.content);
315
+ const existing = parts.findIndex((p) => p.type === "tool" && p.id === event.id);
316
+ const fromResult = parseDiffStat(event.content);
317
+ if (existing < 0) {
318
+ return [
319
+ ...parts,
320
+ {
321
+ type: "tool",
322
+ id: event.id,
323
+ name: "tool",
324
+ description: "tool",
325
+ status: event.isError ? "error" : "done",
326
+ result: event.content,
327
+ ...fromResult.additions != null ? { additions: fromResult.additions } : {},
328
+ ...fromResult.deletions != null ? { deletions: fromResult.deletions } : {}
329
+ }
330
+ ];
331
+ }
332
+ return parts.map((p, i) => {
333
+ if (i !== existing || p.type !== "tool") return p;
317
334
  return {
318
335
  ...p,
319
336
  status: event.isError ? "error" : "done",
@@ -322,7 +339,6 @@ function applyAgentEvent(parts, event) {
322
339
  ...fromResult.deletions != null ? { deletions: fromResult.deletions } : {}
323
340
  };
324
341
  });
325
- return next;
326
342
  }
327
343
  return parts;
328
344
  }
@@ -376,9 +392,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
376
392
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
377
393
  );
378
394
  }
379
- const { isGlobalThread: isGlobalThread2 } = await import("../global-workspace-EV4G2WMQ.js");
395
+ const { isGlobalThread: isGlobalThread2 } = await import("../global-workspace-667XLBW6.js");
380
396
  if (isGlobalThread2(thread)) {
381
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("../coordinator-prompt-6FXVTSFN.js");
397
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("../coordinator-prompt-RBKUNRPR.js");
382
398
  ensureGlobalCoordinatorCwd2();
383
399
  }
384
400
  if (isOrchestratorThread(thread)) {
@@ -1103,7 +1119,13 @@ async function requireAgent(agent, opts) {
1103
1119
 
1104
1120
  // src/threads/create.ts
1105
1121
  async function createThread(input, _onSetupLine) {
1106
- await requireAgent(input.agent);
1122
+ const resolved = resolveNewThreadOptions({
1123
+ agent: input.agent,
1124
+ model: input.model,
1125
+ effort: input.effort,
1126
+ fast: input.fast
1127
+ });
1128
+ await requireAgent(resolved.agent);
1107
1129
  const repoPath = await resolveRepoRoot(input.repoPath);
1108
1130
  if (!existsSync5(repoPath)) {
1109
1131
  throw new Error(`Repo not found: ${repoPath}`);
@@ -1146,11 +1168,11 @@ async function createThread(input, _onSetupLine) {
1146
1168
  branchName,
1147
1169
  worktreePath,
1148
1170
  repoPath,
1149
- agent: input.agent,
1171
+ agent: resolved.agent,
1150
1172
  autonomy: input.autonomy ?? "default",
1151
- model: input.model ?? null,
1152
- effort: input.effort ?? "high",
1153
- fast: Boolean(input.fast),
1173
+ model: resolved.model,
1174
+ effort: resolved.effort,
1175
+ fast: resolved.fast,
1154
1176
  planMode: Boolean(input.planMode),
1155
1177
  attachments: input.attachments ?? [],
1156
1178
  sourceIsFork,
@@ -1163,7 +1185,7 @@ async function createThread(input, _onSetupLine) {
1163
1185
  return readThread(thread.id) ?? thread;
1164
1186
  }
1165
1187
  async function listLinearIssues(agent, repoPath) {
1166
- const { getAdapter: getAdapter2 } = await import("../agents-KP7UJEHJ.js");
1188
+ const { getAdapter: getAdapter2 } = await import("../agents-AQFEFKBL.js");
1167
1189
  await requireAgent(agent, { requireLinear: true });
1168
1190
  const adapter = getAdapter2(agent);
1169
1191
  if (!adapter.listLinearIssues) {
@@ -2025,7 +2047,7 @@ async function adoptThread(input) {
2025
2047
  messages: input.messages ?? []
2026
2048
  });
2027
2049
  writeThread(thread);
2028
- const { ensureWorkspace: ensureWorkspace2 } = await import("../workspaces-3RQQZQRO.js");
2050
+ const { ensureWorkspace: ensureWorkspace2 } = await import("../workspaces-LYIDE2VR.js");
2029
2051
  await ensureWorkspace2(repoPath);
2030
2052
  return thread;
2031
2053
  }
@@ -3872,6 +3894,7 @@ var Orchestrator = class {
3872
3894
  }
3873
3895
  async reconcile(repoPath, opts) {
3874
3896
  const reclaimStaleTurns = opts?.reclaimStaleTurns === true;
3897
+ const drainQueues = opts?.drainQueues !== false;
3875
3898
  healOrchestrationSoccerTitles();
3876
3899
  for (const thread of listThreads({ includeArchived: true })) {
3877
3900
  if (thread.status === "archived") continue;
@@ -3912,18 +3935,42 @@ var Orchestrator = class {
3912
3935
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
3913
3936
  });
3914
3937
  }
3915
- const { autoCleanupOrphansEnabled } = await import("../app-settings-7XVDQJ7F.js");
3938
+ const { autoCleanupOrphansEnabled } = await import("../app-settings-73DI4B6T.js");
3916
3939
  if (autoCleanupOrphansEnabled() && shouldRunWorktreeCleanup() && orphans.length > 0) {
3917
3940
  await cleanupOrphanWorktrees({ repoPaths });
3918
3941
  }
3919
3942
  } catch {
3920
3943
  }
3944
+ if (drainQueues) {
3945
+ this.adoptPersistedQueues();
3946
+ }
3947
+ this.schedulePendingQuotaResumes();
3948
+ }
3949
+ /**
3950
+ * Adopt queues persisted by another process (MCP stdio / CLI) into this
3951
+ * orchestrator's drain loops. Desktop calls this on thread-store changes so
3952
+ * MCP-created review threads don't stay `queued` after the MCP child exits.
3953
+ */
3954
+ adoptPersistedQueues() {
3921
3955
  for (const thread of listThreads()) {
3922
- if (thread.queue.length > 0 && thread.status !== "stopped") {
3956
+ if (thread.status === "stopped" || thread.status === "archived") continue;
3957
+ const pid = thread.agentPid;
3958
+ const deadPid = typeof pid === "number" && pid > 0 && !isPidAlive(pid) ? true : false;
3959
+ if (deadPid) {
3960
+ updateThread(thread.id, { agentPid: null });
3961
+ }
3962
+ if (thread.status === "queued" && thread.queue.length === 0) {
3963
+ if (!this.activeTurns.has(thread.id) && !this.startingTurns.has(thread.id)) {
3964
+ setStatus(thread.id, "idle");
3965
+ this.emit({ type: "status_changed", threadId: thread.id, status: "idle" });
3966
+ }
3967
+ continue;
3968
+ }
3969
+ if (thread.queue.length > 0) {
3970
+ this.haltDrain.delete(thread.id);
3923
3971
  void this.drainQueue(thread.id);
3924
3972
  }
3925
3973
  }
3926
- this.schedulePendingQuotaResumes();
3927
3974
  }
3928
3975
  clearQuotaResumeTimer(threadId) {
3929
3976
  const timer = this.quotaResumeTimers.get(threadId);
@@ -4045,7 +4092,7 @@ var Orchestrator = class {
4045
4092
  }
4046
4093
  async finishCreateThread(threadId, prompt) {
4047
4094
  await this.runSetupAfterCreate(threadId);
4048
- const { autoRunAfterSetupEnabled } = await import("../app-settings-7XVDQJ7F.js");
4095
+ const { autoRunAfterSetupEnabled } = await import("../app-settings-73DI4B6T.js");
4049
4096
  if (autoRunAfterSetupEnabled()) {
4050
4097
  try {
4051
4098
  await this.startDev(threadId);
@@ -4077,7 +4124,7 @@ var Orchestrator = class {
4077
4124
  }
4078
4125
  }
4079
4126
  listWorkspaces() {
4080
- const fromThreads = listThreads({ includeArchived: false }).map((t) => t.repoPath);
4127
+ const fromThreads = listThreads({ includeArchived: true }).map((t) => t.repoPath);
4081
4128
  return syncWorkspacesFromThreads(fromThreads);
4082
4129
  }
4083
4130
  async addWorkspace(repoPath) {
@@ -4105,7 +4152,12 @@ var Orchestrator = class {
4105
4152
  const current = this.requireThread(thread.id);
4106
4153
  const queue = [...current.queue, prompt];
4107
4154
  this.haltDrain.delete(thread.id);
4108
- updateThread(thread.id, { queue, status: "queued" });
4155
+ const patch = { queue, status: "queued" };
4156
+ const pid = current.agentPid;
4157
+ if (typeof pid === "number" && pid > 0 && !isPidAlive(pid)) {
4158
+ patch.agentPid = null;
4159
+ }
4160
+ updateThread(thread.id, patch);
4109
4161
  this.emit({ type: "queue_changed", threadId: thread.id, queue });
4110
4162
  this.emit({ type: "status_changed", threadId: thread.id, status: "queued" });
4111
4163
  void this.drainQueue(thread.id);
@@ -4311,7 +4363,7 @@ var Orchestrator = class {
4311
4363
  });
4312
4364
  const artifactDirective = isBrightsy ? null : formatArtifactDirective();
4313
4365
  const settings = loadWorkspaceSettings(fresh.worktreePath, fresh.repoPath);
4314
- const { autoRenameBranchEnabled } = await import("../app-settings-7XVDQJ7F.js");
4366
+ const { autoRenameBranchEnabled } = await import("../app-settings-73DI4B6T.js");
4315
4367
  const renameBranchDirective = !isBrightsy && !isOrchestration && autoRenameBranchEnabled() ? formatRenameBranchDirective(fresh, {
4316
4368
  customPrompt: settings?.prompts?.renameBranch
4317
4369
  }) : null;
@@ -5177,7 +5229,15 @@ var Orchestrator = class {
5177
5229
  }
5178
5230
  await removeWorktree(thread.repoPath, thread.worktreePath);
5179
5231
  }
5180
- return setStatus(thread.id, "archived");
5232
+ const archived = setStatus(thread.id, "archived");
5233
+ if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
5234
+ try {
5235
+ const { ensureWorkspace: ensureWorkspace2 } = await import("../workspaces-LYIDE2VR.js");
5236
+ await ensureWorkspace2(thread.repoPath);
5237
+ } catch {
5238
+ }
5239
+ }
5240
+ return archived;
5181
5241
  }
5182
5242
  async purge(threadRef, opts) {
5183
5243
  const thread = this.requireThread(threadRef);
@@ -5193,7 +5253,7 @@ var Orchestrator = class {
5193
5253
  await runArchiveScript(thread.repoPath, thread.worktreePath);
5194
5254
  } catch {
5195
5255
  }
5196
- const { deleteBranchOnPurgeEnabled } = await import("../app-settings-7XVDQJ7F.js");
5256
+ const { deleteBranchOnPurgeEnabled } = await import("../app-settings-73DI4B6T.js");
5197
5257
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled();
5198
5258
  await removeWorktree(thread.repoPath, thread.worktreePath, {
5199
5259
  deleteBranch: deleteBranch ? thread.branchName : void 0
@@ -5385,7 +5445,12 @@ function mcpArchiveBlockedReason(thread) {
5385
5445
  var MAX_ORCH_THREADS = 5;
5386
5446
  async function startMcpServer() {
5387
5447
  const orch = getOrchestrator();
5388
- await orch.reconcile(void 0, { reclaimStaleTurns: false });
5448
+ try {
5449
+ const { maxConcurrentAgents } = await import("../app-settings-73DI4B6T.js");
5450
+ orch.setMaxConcurrent(maxConcurrentAgents());
5451
+ } catch {
5452
+ }
5453
+ await orch.reconcile(void 0, { reclaimStaleTurns: false, drainQueues: false });
5389
5454
  const server = new McpServer({
5390
5455
  name: "sideboard",
5391
5456
  version: "0.1.0"
@@ -5585,13 +5650,19 @@ async function startMcpServer() {
5585
5650
  return { content: [{ type: "text", text: JSON.stringify(payload) }] };
5586
5651
  }
5587
5652
  );
5653
+ const { resolveNewThreadOptions: resolveNewThreadOptions2, resolveThreadDefaults } = await import("../app-settings-73DI4B6T.js");
5654
+ const accountDefaults = resolveThreadDefaults();
5655
+ const accountDefaultsHint = `Account defaults: agent=${accountDefaults.agent}, model=${accountDefaults.model?.trim() || "Auto"}, effort=${accountDefaults.effort}`;
5588
5656
  server.tool(
5589
5657
  "create_thread",
5590
- "Create a new worktree thread (chat) from branch, pr, or ticket. Pass repoPath from list_workspaces and parentThreadId when spawning from an orchestrator. Then use send_to_thread to chat.",
5658
+ `Create a new worktree thread (chat) from branch, pr, or ticket. Pass repoPath from list_workspaces and parentThreadId when spawning from an orchestrator. Prefer omitting agent/model so Sideboard applies ${accountDefaultsHint}. Then use send_to_thread to chat.`,
5591
5659
  {
5592
5660
  sourceType: z.enum(["branch", "pr", "ticket"]),
5593
5661
  sourceRef: z.string(),
5594
- agent: z.enum(["claude", "codex", "opencode", "brightsy", "cursor"]),
5662
+ agent: z.enum(["claude", "codex", "opencode", "brightsy", "cursor"]).optional().describe(`Omit to use Account default agent (${accountDefaults.agent})`),
5663
+ model: z.string().nullable().optional().describe(
5664
+ `Usually omit to use Account default model (${accountDefaults.model?.trim() || "Auto"}). Pass null only to force Auto / agent-default.`
5665
+ ),
5595
5666
  repoPath: z.string(),
5596
5667
  title: z.string().optional(),
5597
5668
  parentThreadId: z.string().optional()
@@ -5611,10 +5682,17 @@ async function startMcpServer() {
5611
5682
  };
5612
5683
  }
5613
5684
  }
5685
+ const opts = resolveNewThreadOptions2({
5686
+ agent: args.agent,
5687
+ model: args.model
5688
+ });
5614
5689
  const thread = await orch.createThread({
5615
5690
  sourceType: args.sourceType,
5616
5691
  sourceRef: args.sourceRef,
5617
- agent: args.agent,
5692
+ agent: opts.agent,
5693
+ model: opts.model,
5694
+ effort: opts.effort,
5695
+ fast: opts.fast,
5618
5696
  repoPath: args.repoPath,
5619
5697
  title: args.title,
5620
5698
  parentThreadId: args.parentThreadId ?? null
@@ -5628,6 +5706,8 @@ async function startMcpServer() {
5628
5706
  title: thread.title,
5629
5707
  branchName: thread.branchName,
5630
5708
  worktreePath: thread.worktreePath,
5709
+ agent: thread.agent,
5710
+ model: thread.model,
5631
5711
  status: thread.status,
5632
5712
  link: `sideboard://thread/${thread.id}`
5633
5713
  })
@@ -5872,7 +5952,7 @@ async function startMcpServer() {
5872
5952
  async ({ ref, through_index, agent, model, title }) => {
5873
5953
  try {
5874
5954
  const source = orch.getThread(ref);
5875
- if (source) await orch.reconcile(source.repoPath);
5955
+ if (source) await orch.reconcile(source.repoPath, { drainQueues: false });
5876
5956
  const thread = await orch.forkThreadWorktree({
5877
5957
  threadId: ref,
5878
5958
  throughIndex: through_index,
@@ -4,10 +4,11 @@ import {
4
4
  listWorkspaces,
5
5
  removeWorkspace,
6
6
  syncWorkspacesFromThreads
7
- } from "./chunk-GNML24AW.js";
8
- import "./chunk-XX5BB7NV.js";
7
+ } from "./chunk-5DMYULLC.js";
8
+ import "./chunk-S42XDFKF.js";
9
9
  import "./chunk-GI7E5733.js";
10
- import "./chunk-LRLKJM3O.js";
10
+ import "./chunk-UA5NDAHL.js";
11
+ import "./chunk-DIOF73S2.js";
11
12
  import "./chunk-DZFH2KLT.js";
12
13
  import "./chunk-FKOIHGKV.js";
13
14
  import "./chunk-TSRXOSVD.js";
@@ -6,14 +6,15 @@ import {
6
6
  listWorkspaces,
7
7
  removeWorkspace,
8
8
  syncWorkspacesFromThreads
9
- } from "./chunk-YDXQ72MD.js";
10
- import "./chunk-YOWIYAVA.js";
9
+ } from "./chunk-V2DUTUNC.js";
10
+ import "./chunk-EBWEKG52.js";
11
11
  import "./chunk-S2LL5HA4.js";
12
- import "./chunk-UEAHMGHW.js";
12
+ import "./chunk-DQJ5D42H.js";
13
13
  import "./chunk-XOU6HNQJ.js";
14
14
  import "./chunk-B3SJXYIJ.js";
15
15
  import "./chunk-HLEX5AQ6.js";
16
16
  import "./chunk-ZNM4MAN4.js";
17
+ import "./chunk-C4BCC5X5.js";
17
18
  import "./chunk-KGZBYWZ3.js";
18
19
  import "./chunk-7MV3RXSC.js";
19
20
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sideboard-ai/core",
3
- "version": "0.1.53",
3
+ "version": "0.1.57",
4
4
  "description": "Sideboard core — orchestration, agents, git worktrees, MCP server",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",