@sideboard-ai/core 0.1.326 → 0.1.327

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 (73) hide show
  1. package/dist/{abletime-RYYFGKMU.js → abletime-NW4PJGHN.js} +4 -5
  2. package/dist/{abletime-RDHYSZL2.js → abletime-OW7LTFQD.js} +4 -5
  3. package/dist/{abletime-oauth-OYGS2DAU.js → abletime-oauth-KWQQRHOQ.js} +3 -4
  4. package/dist/{abletime-oauth-QR2QDVMK.js → abletime-oauth-TPR2QDRI.js} +3 -4
  5. package/dist/{abletime-rest-QDPTWNS4.js → abletime-rest-5DCWN3P4.js} +3 -4
  6. package/dist/{abletime-rest-BKYKNPTC.js → abletime-rest-UJ6SXDBN.js} +3 -4
  7. package/dist/agents/claude-runner.cjs +11 -0
  8. package/dist/agents/claude-runner.js +7 -1
  9. package/dist/{agents-QO7GKBYT.js → agents-IYBY3JT5.js} +8 -9
  10. package/dist/{agents-HANWZNI6.js → agents-XWIPONJR.js} +8 -9
  11. package/dist/{app-settings-RXBH7KY4.js → app-settings-A5D364JD.js} +1 -2
  12. package/dist/{app-settings-TUVLZNDE.js → app-settings-SA4HX3ZQ.js} +1 -2
  13. package/dist/{chunk-3Q4XNYHY.js → chunk-2GEUFPQQ.js} +1 -1
  14. package/dist/{chunk-MAW7DIG7.js → chunk-4F7THWIO.js} +2 -2
  15. package/dist/{chunk-K7M7MIWL.js → chunk-4G3W23X3.js} +3 -3
  16. package/dist/{chunk-Q3FHTGIW.js → chunk-5Y2C7Q55.js} +441 -20
  17. package/dist/{chunk-TMCK5TLA.js → chunk-ATQLP22S.js} +1 -1
  18. package/dist/{chunk-PB6HW7SA.js → chunk-CHYUUETG.js} +3 -3
  19. package/dist/{chunk-QPSKQP6E.js → chunk-D446IWPP.js} +48 -3
  20. package/dist/{chunk-C7HUCBX7.js → chunk-DACWFN4O.js} +5 -5
  21. package/dist/{chunk-GP3RLZ6A.js → chunk-DEB47BII.js} +51 -487
  22. package/dist/{chunk-B244TJWC.js → chunk-ECY7WL6T.js} +2 -2
  23. package/dist/{chunk-D744HOI5.js → chunk-EJRCHCXM.js} +18 -3
  24. package/dist/{chunk-KXRF6RNL.js → chunk-EUIVQAPK.js} +2 -2
  25. package/dist/{chunk-46FECFZU.js → chunk-IXWPCOLQ.js} +8 -195
  26. package/dist/{chunk-75RPUXJS.js → chunk-JKHCADKB.js} +5 -5
  27. package/dist/{chunk-4H5MWZ6J.js → chunk-KLVW3J2B.js} +2 -2
  28. package/dist/{chunk-QG4CYRA3.js → chunk-MO46K6WK.js} +14 -14
  29. package/dist/{chunk-F2PVRF3B.js → chunk-N6ZF3XRP.js} +2 -1
  30. package/dist/{chunk-BBNWKL4I.js → chunk-NQGLDQYB.js} +8 -8
  31. package/dist/{chunk-YGVGXQA7.js → chunk-Q4UPRQOS.js} +12 -12
  32. package/dist/{chunk-ZUAYA57W.js → chunk-QMLDR63X.js} +2 -2
  33. package/dist/{chunk-KECHK3ZT.js → chunk-R2C45NHT.js} +2 -2
  34. package/dist/{chunk-FWVUGLBG.js → chunk-RDXODLEN.js} +4 -4
  35. package/dist/{chunk-XLVLMQKN.js → chunk-RZJ3QJZT.js} +11 -11
  36. package/dist/{chunk-JM2TGOHP.js → chunk-SB5ADEZZ.js} +5 -5
  37. package/dist/{chunk-SO7G6O24.js → chunk-SFXGD5KJ.js} +1 -1
  38. package/dist/{chunk-LRHUBGEM.js → chunk-TUH4ICHQ.js} +1 -1
  39. package/dist/chunk-ULWPSBAB.js +192 -0
  40. package/dist/{chunk-WUCAVIIP.js → chunk-UMXBH344.js} +1 -1
  41. package/dist/{chunk-RZVOX2MT.js → chunk-XBBZZHJY.js} +3 -3
  42. package/dist/{chunk-ZSHS46V5.js → chunk-Y6OHM672.js} +476 -20
  43. package/dist/{chunk-2EOLWHXH.js → chunk-YUHZEIVG.js} +69 -473
  44. package/dist/{chunk-YWQF7WAG.js → chunk-ZPBOWO64.js} +2 -2
  45. package/dist/{conductor-4GVTHUUB.js → conductor-CP7TW6TN.js} +7 -7
  46. package/dist/{conductor-TGWI6ETZ.js → conductor-D62Q2XJC.js} +6 -7
  47. package/dist/{coordinator-prompt-3E6SIDTM.js → coordinator-prompt-3PJLU3UH.js} +5 -6
  48. package/dist/{coordinator-prompt-WEYJREV6.js → coordinator-prompt-J7O7JB26.js} +5 -6
  49. package/dist/{global-workspace-UIEXAG2B.js → global-workspace-4CTLU2BV.js} +5 -6
  50. package/dist/{global-workspace-FPDZKUPF.js → global-workspace-Y3UDZYJX.js} +5 -6
  51. package/dist/index.cjs +507 -492
  52. package/dist/index.d.cts +5 -2
  53. package/dist/index.d.ts +5 -2
  54. package/dist/index.js +67 -65
  55. package/dist/{linear-6S7MK5YK.js → linear-CXWGH2TW.js} +2 -3
  56. package/dist/{linear-Z2T4KUAQ.js → linear-WLDCJ3AF.js} +2 -3
  57. package/dist/{linear-list-Q4M7AZO2.js → linear-list-52LEDEWO.js} +1 -1
  58. package/dist/{linear-list-A37WLUBO.js → linear-list-FGVN65JU.js} +1 -1
  59. package/dist/mcp/run-stdio.cjs +19654 -19641
  60. package/dist/mcp/run-stdio.js +33 -34
  61. package/dist/{optional-cli-CA4LL322.js → optional-cli-FN4MGB6W.js} +4 -5
  62. package/dist/{optional-cli-AANBL4U5.js → optional-cli-INRVBBBG.js} +3 -4
  63. package/dist/{orchestrator-7FVDBE7Y.js → orchestrator-EN3ZKD73.js} +12 -12
  64. package/dist/{orchestrator-RQXRZW7Z.js → orchestrator-W4TZBBDO.js} +11 -12
  65. package/dist/{thread-store-4ZN3DS2W.js → thread-store-4WE24XA2.js} +6 -2
  66. package/dist/{thread-store-IC4BQXDW.js → thread-store-K2ZNGUSM.js} +7 -3
  67. package/dist/{workspaces-LEW4UP56.js → workspaces-MM7CQYR6.js} +5 -6
  68. package/dist/{workspaces-QONNLHNR.js → workspaces-WYCVZ6XH.js} +5 -6
  69. package/dist/{worktree-KFEJAQ2H.js → worktree-JBNEMJ5Z.js} +7 -8
  70. package/dist/{worktree-6GIONDQO.js → worktree-NNVRGPP4.js} +4 -5
  71. package/package.json +1 -1
  72. package/dist/chunk-77WWLBCI.js +0 -50
  73. package/dist/chunk-KGZBYWZ3.js +0 -23
@@ -14,7 +14,7 @@ import {
14
14
  parseSessionQuotaResetAt,
15
15
  planModeTurnInstruction,
16
16
  resolveQuotaFallbackAgent
17
- } from "./chunk-QG4CYRA3.js";
17
+ } from "./chunk-MO46K6WK.js";
18
18
  import {
19
19
  applyWorktreePkgCacheEnv,
20
20
  askBlockStillWaiting,
@@ -52,7 +52,7 @@ import {
52
52
  worktreeDevProcessKey,
53
53
  worktreeRunProcessKey,
54
54
  worktreeSetupProcessKey
55
- } from "./chunk-XLVLMQKN.js";
55
+ } from "./chunk-RZJ3QJZT.js";
56
56
  import {
57
57
  applyAgentEvent,
58
58
  clipAgentEventForPaint,
@@ -86,7 +86,7 @@ import {
86
86
  import {
87
87
  formatOptionalServicesDirectiveForTurn,
88
88
  formatOptionalServicesReminderForTurn
89
- } from "./chunk-3Q4XNYHY.js";
89
+ } from "./chunk-2GEUFPQQ.js";
90
90
  import {
91
91
  extractPresentedPlan,
92
92
  isPresentPlanToolName,
@@ -117,7 +117,7 @@ import {
117
117
  stageAbsolutePathsAsAttachments,
118
118
  stageBuffersAsAttachments,
119
119
  syncWorkspacesFromThreads
120
- } from "./chunk-YGVGXQA7.js";
120
+ } from "./chunk-Q4UPRQOS.js";
121
121
  import {
122
122
  addPrStackLayer,
123
123
  allocateTeamSlug,
@@ -166,7 +166,7 @@ import {
166
166
  resolveRepoRoot,
167
167
  switchWorktreeBranch,
168
168
  withRepoGitLock
169
- } from "./chunk-75RPUXJS.js";
169
+ } from "./chunk-JKHCADKB.js";
170
170
  import {
171
171
  issueActivityKind
172
172
  } from "./chunk-OYRN356W.js";
@@ -178,13 +178,44 @@ import {
178
178
  git,
179
179
  resolveGitDirsForLockRecovery
180
180
  } from "./chunk-YBTSZ2SW.js";
181
+ import {
182
+ REVIEW_TAB_TITLE,
183
+ agentNicknameFromWorktreePath,
184
+ appendMessage,
185
+ createEmptyThread,
186
+ deleteSchedule,
187
+ deleteThreadRecord,
188
+ findThreadByRef,
189
+ formatReviewWriteGateDirective,
190
+ formatReviewWriteGateReminder,
191
+ getSchedule,
192
+ isPlaceholderBranch,
193
+ isReviewWriteGatedThread,
194
+ isWorktreeIdentityTitle,
195
+ listSchedules,
196
+ listThreads,
197
+ normalizeWorkspaceTags,
198
+ normalizeWorktreePath,
199
+ readThread,
200
+ recordScheduleRun,
201
+ setStatus,
202
+ teamSlugFromName,
203
+ ticketSlugForBranch,
204
+ updateThread,
205
+ withThreadLock,
206
+ workspaceTagsFromGroup,
207
+ worktreeDisplayLabelForGroup,
208
+ worktreeIdentityTitles,
209
+ worktreeNameFromPath,
210
+ worktreeSlugForTicket,
211
+ writeThread
212
+ } from "./chunk-5Y2C7Q55.js";
181
213
  import {
182
214
  HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT,
183
215
  applyTurnUsage,
184
216
  archivedUpdatedMs,
185
217
  assertOrchestratorCapableAgent,
186
218
  autoCleanupHistoryEnabled,
187
- caffeinateWhileSchedulesEnabled,
188
219
  childEnvWithAppSettings,
189
220
  coerceOrchestratorAgent,
190
221
  followUpBehavior,
@@ -197,7 +228,6 @@ import {
197
228
  historyRetentionStubMessage,
198
229
  isAbleTimeConnected,
199
230
  isLinearConnected,
200
- isOrchestratorCapableAgent,
201
231
  loadAppSettings,
202
232
  orchestrationQuotaFallbackAgent,
203
233
  planHistoryAgePurge,
@@ -214,10 +244,7 @@ import {
214
244
  usageOnLimit,
215
245
  withTurnScopedCost,
216
246
  writeViewerContext
217
- } from "./chunk-D744HOI5.js";
218
- import {
219
- writePrivateFile
220
- } from "./chunk-NSTQ6QKD.js";
247
+ } from "./chunk-EJRCHCXM.js";
221
248
  import {
222
249
  examplePrefixedBranch,
223
250
  sanitizeGitBranchPrefix
@@ -228,37 +255,6 @@ import {
228
255
  nextManagedAccount,
229
256
  resolveAccountForThread
230
257
  } from "./chunk-J2LNLI4S.js";
231
- import {
232
- REVIEW_TAB_TITLE,
233
- agentNicknameFromWorktreePath,
234
- appendMessage,
235
- createEmptyThread,
236
- deleteThreadRecord,
237
- findThreadByRef,
238
- formatReviewWriteGateDirective,
239
- formatReviewWriteGateReminder,
240
- isPlaceholderBranch,
241
- isReviewWriteGatedThread,
242
- isWorktreeIdentityTitle,
243
- listThreads,
244
- normalizeWorkspaceTags,
245
- normalizeWorktreePath,
246
- readThread,
247
- setStatus,
248
- teamSlugFromName,
249
- ticketSlugForBranch,
250
- updateThread,
251
- withThreadLock,
252
- workspaceTagsFromGroup,
253
- worktreeDisplayLabelForGroup,
254
- worktreeIdentityTitles,
255
- worktreeNameFromPath,
256
- worktreeSlugForTicket,
257
- writeThread
258
- } from "./chunk-Q3FHTGIW.js";
259
- import {
260
- normalizeThinkingEffort
261
- } from "./chunk-KGZBYWZ3.js";
262
258
  import {
263
259
  annotateDevAccessRuns,
264
260
  appDataDir,
@@ -312,8 +308,8 @@ function formatInjectedNoticesForTurn(notices) {
312
308
  }
313
309
 
314
310
  // src/orchestrator/orchestrator.ts
315
- import { randomUUID as randomUUID5 } from "crypto";
316
- import { existsSync as existsSync14 } from "fs";
311
+ import { randomUUID as randomUUID4 } from "crypto";
312
+ import { existsSync as existsSync13 } from "fs";
317
313
 
318
314
  // src/agents/spawn.ts
319
315
  import { rmSync } from "fs";
@@ -564,9 +560,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
564
560
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
565
561
  );
566
562
  }
567
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-FPDZKUPF.js");
563
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-Y3UDZYJX.js");
568
564
  if (isGlobalThread2(thread)) {
569
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-WEYJREV6.js");
565
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-J7O7JB26.js");
570
566
  ensureGlobalCoordinatorCwd2(
571
567
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
572
568
  );
@@ -2862,7 +2858,7 @@ async function createThread(input, _onSetupLine) {
2862
2858
  });
2863
2859
  await requireAgent(resolved.agent);
2864
2860
  if (input.cowboy) {
2865
- const { cowboyModeEnabled } = await import("./app-settings-TUVLZNDE.js");
2861
+ const { cowboyModeEnabled } = await import("./app-settings-SA4HX3ZQ.js");
2866
2862
  if (!cowboyModeEnabled()) {
2867
2863
  throw new Error(
2868
2864
  "Cowboy mode is off. Enable it in Settings \u2192 Advanced."
@@ -2921,7 +2917,7 @@ async function createThread(input, _onSetupLine) {
2921
2917
  let sourceIsFork = false;
2922
2918
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
2923
2919
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
2924
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-RYYFGKMU.js");
2920
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-NW4PJGHN.js");
2925
2921
  const task = await ensureAbleTimeTask({
2926
2922
  title: title?.trim() || "Untitled work",
2927
2923
  description: input.prompt?.trim() || void 0
@@ -3803,7 +3799,7 @@ async function adoptThread(input) {
3803
3799
  messages: input.messages ?? []
3804
3800
  });
3805
3801
  writeThread(thread);
3806
- const { addWorkspace: addWorkspace2 } = await import("./workspaces-LEW4UP56.js");
3802
+ const { addWorkspace: addWorkspace2 } = await import("./workspaces-MM7CQYR6.js");
3807
3803
  await addWorkspace2(repoPath);
3808
3804
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-P5NJODWP.js");
3809
3805
  await ensureWorktreeSideboardIgnored(input.worktreePath);
@@ -6193,7 +6189,7 @@ function formatWorktreeDirective(thread, opts) {
6193
6189
  lines.push(formatDevAccessHint(opts?.activeRuns));
6194
6190
  lines.push("");
6195
6191
  lines.push(
6196
- "Automations (sidebar, after Board): `create_schedule` / `list_schedules` (`at` / `every` / `cron` / `time`+`days`). `archiveChat=false` keeps the new chat. `chatId=self` continues this chat; omit chatId for a new Global chat. Fires only while Sideboard.app is running. A future job turns on Settings \u2192 Advanced \u2192 Caffeinate while automations are enabled."
6192
+ "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. A future job turns on Settings \u2192 Advanced \u2192 Caffeinate while automations are enabled."
6197
6193
  );
6198
6194
  lines.push(
6199
6195
  "`set_workspace_tags` labels this checkout (omit ref; replace, add, or remove). Not another checkout."
@@ -6213,7 +6209,7 @@ function connectedOrchestratorTurnReminder(thread, find) {
6213
6209
  return formatConnectedOrchestratorReminder(connectedOrchestrator(thread, find));
6214
6210
  }
6215
6211
  function formatWorktreeReminder() {
6216
- return "Sideboard workspace: stay in this cwd for all file and git work. Push and open PRs against origin, never upstream. Do not edit the main repo checkout. If a goal is given (Greptile 5/5, CI green), watch-fix-push until it lands \u2014 do not watch after every push. Automations: create_schedule (at / every / cron, or time + days such as weekdays at 07:30; archiveChat=false leaves the new chat open; chatId=self for this chat). set_workspace_tags updates labels on this workspace (omit ref).";
6212
+ return "Sideboard workspace: stay in this cwd for all file and git work. Push and open PRs against origin, never upstream. Do not edit the main repo checkout. If a goal is given (Greptile 5/5, CI green), watch-fix-push until it lands \u2014 do not watch after every push. Automations: create_schedule (at / every / cron, or time + days such as weekdays at 07:30; archiveChat=false leaves the new chat open; chatId=self ends with the chat). set_workspace_tags updates labels on this workspace (omit ref).";
6217
6213
  }
6218
6214
  function formatClaudeSubagentReminder() {
6219
6215
  return 'Claude subagents: if Task/Agent workers will edit files, write a short plan in this chat and continue in the same turn. Do not ask the user whether to isolate, and do not set worktree.bgIsolation to none. One writer may edit this workspace. Every other writer is an Agent with isolation "worktree" and a disjoint file list (read-only explore agents may overlap). While those agents run, leave their files alone. Merge each returned branch into this workspace, then remove the temporary worktree. You stay in this cwd. If Claude says another write-capable agent is in this directory, or that writes to the shared checkout are blocked, re-spawn that agent with isolation "worktree" or make the edit yourself. That note is another worker in this chat, or a worker Claude still has marked running. Do not mention it to the user.';
@@ -6735,402 +6731,6 @@ async function syncThreadBranchFromGit(threadId) {
6735
6731
  }
6736
6732
  }
6737
6733
 
6738
- // src/store/schedules.ts
6739
- import { randomUUID as randomUUID4 } from "crypto";
6740
- import { existsSync as existsSync13, readFileSync as readFileSync8 } from "fs";
6741
- import { join as join14 } from "path";
6742
-
6743
- // src/store/schedule-when.ts
6744
- import { Cron } from "croner";
6745
- var DURATION_RE = /^(\d+)(s|m|h|d)$/i;
6746
- var UNIT_MS = {
6747
- s: 1e3,
6748
- m: 6e4,
6749
- h: 36e5,
6750
- d: 864e5
6751
- };
6752
- var DAY_ALIASES = {
6753
- sun: 0,
6754
- sunday: 0,
6755
- mon: 1,
6756
- monday: 1,
6757
- tue: 2,
6758
- tues: 2,
6759
- tuesday: 2,
6760
- wed: 3,
6761
- wednesday: 3,
6762
- thu: 4,
6763
- thur: 4,
6764
- thurs: 4,
6765
- thursday: 4,
6766
- fri: 5,
6767
- friday: 5,
6768
- sat: 6,
6769
- saturday: 6
6770
- };
6771
- var TIME_RE = /^([01]\d|2[0-3]):([0-5]\d)(?::[0-5]\d)?$/;
6772
- function parseDurationMs(every) {
6773
- const m = every.trim().match(DURATION_RE);
6774
- if (!m) return null;
6775
- const n = Number.parseInt(m[1], 10);
6776
- if (!Number.isFinite(n) || n <= 0) return null;
6777
- const unit = m[2].toLowerCase();
6778
- return n * UNIT_MS[unit];
6779
- }
6780
- function dayIndex(token) {
6781
- const text3 = token.trim().toLowerCase();
6782
- if (/^[0-6]$/.test(text3)) return Number(text3);
6783
- return DAY_ALIASES[text3];
6784
- }
6785
- function normalizeWeekdays(days) {
6786
- const set = /* @__PURE__ */ new Set();
6787
- for (const day of days) {
6788
- if (!Number.isInteger(day) || day < 0 || day > 6) {
6789
- throw new Error("Days must be 0 (Sunday) through 6 (Saturday)");
6790
- }
6791
- set.add(day);
6792
- }
6793
- if (set.size === 0) throw new Error("Pick at least one day");
6794
- return [...set].sort((a, b) => a - b);
6795
- }
6796
- function parseWeeklyDays(raw) {
6797
- const text3 = raw.trim().toLowerCase();
6798
- if (!text3) throw new Error("Pick at least one day");
6799
- if (text3 === "daily" || text3 === "all" || text3 === "every day" || text3 === "everyday") {
6800
- return [0, 1, 2, 3, 4, 5, 6];
6801
- }
6802
- if (text3 === "weekdays" || text3 === "weekday") return [1, 2, 3, 4, 5];
6803
- if (text3 === "weekends" || text3 === "weekend") return [0, 6];
6804
- const days = [];
6805
- for (const part of text3.split(/[\s,]+/).filter(Boolean)) {
6806
- const range = part.split("-");
6807
- if (range.length === 2 && range[0] && range[1]) {
6808
- const start = dayIndex(range[0]);
6809
- const end = dayIndex(range[1]);
6810
- if (start === void 0 || end === void 0) {
6811
- throw new Error(`Unknown day: ${part} (use mon,tue, weekdays, weekends, or daily)`);
6812
- }
6813
- if (start <= end) {
6814
- for (let d = start; d <= end; d++) days.push(d);
6815
- } else {
6816
- for (let d = start; d <= 6; d++) days.push(d);
6817
- for (let d = 0; d <= end; d++) days.push(d);
6818
- }
6819
- continue;
6820
- }
6821
- const n = dayIndex(part);
6822
- if (n === void 0) {
6823
- throw new Error(`Unknown day: ${part} (use mon,tue, weekdays, weekends, or daily)`);
6824
- }
6825
- days.push(n);
6826
- }
6827
- return normalizeWeekdays(days);
6828
- }
6829
- function normalizeWeeklyTime(raw) {
6830
- const m = raw.trim().match(TIME_RE);
6831
- if (!m) throw new Error(`Invalid time: ${raw} (use HH:mm, 24-hour)`);
6832
- return `${m[1]}:${m[2]}`;
6833
- }
6834
- function weeklyCronExpr(when) {
6835
- const time = normalizeWeeklyTime(when.time);
6836
- const [hh, mm] = time.split(":");
6837
- const days = normalizeWeekdays(when.days);
6838
- return `${Number(mm)} ${Number(hh)} * * ${days.join(",")}`;
6839
- }
6840
- function computeNextRunAt(when, from = /* @__PURE__ */ new Date()) {
6841
- if (when.kind === "once") {
6842
- const at = new Date(when.at);
6843
- if (Number.isNaN(at.getTime())) {
6844
- throw new Error(`Invalid once-at datetime: ${when.at}`);
6845
- }
6846
- return at;
6847
- }
6848
- if (when.kind === "every") {
6849
- const ms = parseDurationMs(when.every);
6850
- if (!ms) {
6851
- throw new Error(`Invalid interval: ${when.every} (use 15m, 1h, 6h, 1d)`);
6852
- }
6853
- return new Date(from.getTime() + ms);
6854
- }
6855
- if (when.kind === "weekly") {
6856
- return computeNextRunAt(
6857
- { kind: "cron", expr: weeklyCronExpr(when), tz: when.tz },
6858
- from
6859
- );
6860
- }
6861
- try {
6862
- const job = new Cron(when.expr, {
6863
- timezone: when.tz?.trim() || void 0,
6864
- paused: true
6865
- });
6866
- const next = job.nextRun(from);
6867
- if (!next) {
6868
- throw new Error(`Cron expression has no next run: ${when.expr}`);
6869
- }
6870
- return next;
6871
- } catch (err) {
6872
- const message = err instanceof Error ? err.message : String(err);
6873
- throw new Error(`Invalid cron: ${message}`);
6874
- }
6875
- }
6876
- function normalizeWhen(raw) {
6877
- if (!raw || typeof raw !== "object") {
6878
- throw new Error("Schedule is missing `when`");
6879
- }
6880
- const rec = raw;
6881
- const kind = rec.kind;
6882
- if (kind === "once" && typeof rec.at === "string") {
6883
- return { kind: "once", at: rec.at };
6884
- }
6885
- if (kind === "every" && typeof rec.every === "string") {
6886
- return { kind: "every", every: rec.every };
6887
- }
6888
- if (kind === "cron" && typeof rec.expr === "string") {
6889
- return {
6890
- kind: "cron",
6891
- expr: rec.expr,
6892
- tz: typeof rec.tz === "string" && rec.tz.trim() ? rec.tz.trim() : void 0
6893
- };
6894
- }
6895
- if (kind === "weekly" && Array.isArray(rec.days) && typeof rec.time === "string") {
6896
- return {
6897
- kind: "weekly",
6898
- days: normalizeWeekdays(rec.days.map((day) => Number(day))),
6899
- time: normalizeWeeklyTime(rec.time),
6900
- tz: typeof rec.tz === "string" && rec.tz.trim() ? rec.tz.trim() : void 0
6901
- };
6902
- }
6903
- throw new Error("Schedule `when` must be once, every, weekly, or cron");
6904
- }
6905
-
6906
- // src/store/schedules.ts
6907
- function schedulesPath() {
6908
- return join14(appDataDir(), "schedules.json");
6909
- }
6910
- function defaultScheduleName(prompt) {
6911
- const line = prompt.trim().split(/\r?\n/, 1)[0]?.trim() ?? "";
6912
- if (!line) return "Untitled automation";
6913
- return line.length > 60 ? `${line.slice(0, 57).trimEnd()}\u2026` : line;
6914
- }
6915
- function resolveScheduleThreadId(raw, env = process.env) {
6916
- const value = raw?.trim() || "";
6917
- if (!value) return null;
6918
- if (value.toLowerCase() === "self") {
6919
- return env.SIDEBOARD_ORCHESTRATOR_THREAD_ID?.trim() || env.SIDEBOARD_THREAD_ID?.trim() || null;
6920
- }
6921
- return value;
6922
- }
6923
- function nowIso(d = /* @__PURE__ */ new Date()) {
6924
- return d.toISOString();
6925
- }
6926
- var ATTACHMENT_KINDS = /* @__PURE__ */ new Set([
6927
- "transcript",
6928
- "file",
6929
- "issue",
6930
- "workspace",
6931
- "diff-comment",
6932
- "code-ref"
6933
- ]);
6934
- function normalizeOptionalBool(raw) {
6935
- if (raw === true || raw === false) return raw;
6936
- return null;
6937
- }
6938
- function normalizeAutonomy(raw) {
6939
- return raw === "default" || raw === "full" ? raw : null;
6940
- }
6941
- function normalizeAttachments(raw) {
6942
- if (!Array.isArray(raw)) return [];
6943
- const out = [];
6944
- for (const item of raw) {
6945
- if (!item || typeof item !== "object") continue;
6946
- const row = item;
6947
- if (typeof row.id !== "string" || !row.id.trim()) continue;
6948
- if (typeof row.name !== "string" || !row.name) continue;
6949
- if (typeof row.content !== "string") continue;
6950
- if (!ATTACHMENT_KINDS.has(row.kind)) continue;
6951
- const next = {
6952
- id: row.id,
6953
- name: row.name,
6954
- kind: row.kind,
6955
- content: row.content
6956
- };
6957
- if (typeof row.path === "string" && row.path) next.path = row.path;
6958
- if (typeof row.previewDataUrl === "string" && row.previewDataUrl) {
6959
- next.previewDataUrl = row.previewDataUrl;
6960
- }
6961
- out.push(next);
6962
- }
6963
- return out;
6964
- }
6965
- function normalizeTask(raw) {
6966
- const when = normalizeWhen(raw.when);
6967
- const agent = raw.agent && isOrchestratorCapableAgent(raw.agent) ? raw.agent : null;
6968
- return {
6969
- id: raw.id,
6970
- name: typeof raw.name === "string" && raw.name.trim() ? raw.name.trim() : defaultScheduleName(raw.prompt),
6971
- prompt: String(raw.prompt ?? ""),
6972
- enabled: Boolean(raw.enabled),
6973
- when,
6974
- threadId: raw.threadId?.trim() || null,
6975
- agent,
6976
- model: raw.model?.trim() || null,
6977
- effort: normalizeThinkingEffort(raw.effort),
6978
- fast: normalizeOptionalBool(raw.fast),
6979
- planMode: normalizeOptionalBool(raw.planMode),
6980
- autonomy: normalizeAutonomy(raw.autonomy),
6981
- attachments: normalizeAttachments(raw.attachments),
6982
- archiveChat: raw.archiveChat !== false,
6983
- nextRunAt: raw.nextRunAt,
6984
- lastRunAt: raw.lastRunAt ?? null,
6985
- lastThreadId: raw.lastThreadId ?? null,
6986
- lastError: raw.lastError ?? null,
6987
- createdBy: raw.createdBy === "mcp" || raw.createdBy === "cli" || raw.createdBy === "ui" ? raw.createdBy : "ui",
6988
- createdAt: raw.createdAt,
6989
- updatedAt: raw.updatedAt
6990
- };
6991
- }
6992
- function readAll() {
6993
- const path = schedulesPath();
6994
- if (!existsSync13(path)) return [];
6995
- try {
6996
- const parsed = JSON.parse(readFileSync8(path, "utf8"));
6997
- if (!Array.isArray(parsed)) return [];
6998
- return parsed.map((row) => {
6999
- try {
7000
- return normalizeTask(row);
7001
- } catch {
7002
- return null;
7003
- }
7004
- }).filter((row) => Boolean(row?.id && row.prompt));
7005
- } catch {
7006
- return [];
7007
- }
7008
- }
7009
- function writeAll(rows) {
7010
- writePrivateFile(schedulesPath(), `${JSON.stringify(rows, null, 2)}
7011
- `);
7012
- }
7013
- function buildTask(input, now) {
7014
- const prompt = input.prompt.trim();
7015
- if (!prompt) throw new Error("Schedule prompt is required");
7016
- const when = normalizeWhen(input.when);
7017
- const nextRunAt = computeNextRunAt(when, now).toISOString();
7018
- const ts = nowIso(now);
7019
- const agent = input.agent ? coerceOrchestratorAgent(input.agent) : null;
7020
- return {
7021
- id: randomUUID4(),
7022
- name: input.name?.trim() || defaultScheduleName(prompt),
7023
- prompt,
7024
- enabled: input.enabled !== false,
7025
- when,
7026
- threadId: input.threadId?.trim() || null,
7027
- agent,
7028
- model: input.model?.trim() || null,
7029
- effort: input.effort != null ? normalizeThinkingEffort(input.effort) : null,
7030
- fast: normalizeOptionalBool(input.fast),
7031
- planMode: normalizeOptionalBool(input.planMode),
7032
- autonomy: normalizeAutonomy(input.autonomy),
7033
- attachments: normalizeAttachments(input.attachments),
7034
- archiveChat: input.archiveChat !== false,
7035
- nextRunAt,
7036
- lastRunAt: null,
7037
- lastThreadId: null,
7038
- lastError: null,
7039
- createdBy: input.createdBy,
7040
- createdAt: ts,
7041
- updatedAt: ts
7042
- };
7043
- }
7044
- function listSchedules() {
7045
- return readAll().sort((a, b) => a.nextRunAt.localeCompare(b.nextRunAt));
7046
- }
7047
- function scheduleNeedsCaffeinate(task, now = /* @__PURE__ */ new Date()) {
7048
- if (!task.enabled) return false;
7049
- const at = new Date(task.nextRunAt);
7050
- if (Number.isNaN(at.getTime())) return false;
7051
- return at.getTime() > now.getTime();
7052
- }
7053
- function ensureCaffeinateForFutureSchedule(task) {
7054
- if (!scheduleNeedsCaffeinate(task)) return;
7055
- if (caffeinateWhileSchedulesEnabled()) return;
7056
- updateAdvancedSettings({ caffeinateWhileSchedules: true });
7057
- }
7058
- function getSchedule(id) {
7059
- const key = id.trim();
7060
- if (!key) return null;
7061
- return readAll().find(
7062
- (row) => row.id === key || row.id.startsWith(key) && key.length >= 8
7063
- ) ?? null;
7064
- }
7065
- function createSchedule(input) {
7066
- const task = buildTask(input, /* @__PURE__ */ new Date());
7067
- const rows = readAll();
7068
- rows.push(task);
7069
- writeAll(rows);
7070
- ensureCaffeinateForFutureSchedule(task);
7071
- return task;
7072
- }
7073
- function updateSchedule(id, patch) {
7074
- const rows = readAll();
7075
- const idx = rows.findIndex((row) => row.id === id || id.length >= 8 && row.id.startsWith(id));
7076
- if (idx < 0) throw new Error(`Automation not found: ${id}`);
7077
- const prev = rows[idx];
7078
- const when = patch.when ? normalizeWhen(patch.when) : prev.when;
7079
- const prompt = patch.prompt !== void 0 ? patch.prompt.trim() : prev.prompt;
7080
- if (!prompt) throw new Error("Schedule prompt is required");
7081
- const whenChanged = patch.when !== void 0;
7082
- const next = {
7083
- ...prev,
7084
- name: patch.name !== void 0 ? patch.name.trim() || defaultScheduleName(prompt) : prev.name,
7085
- prompt,
7086
- enabled: patch.enabled ?? prev.enabled,
7087
- when,
7088
- threadId: patch.threadId !== void 0 ? patch.threadId?.trim() || null : prev.threadId,
7089
- agent: patch.agent !== void 0 ? patch.agent ? coerceOrchestratorAgent(patch.agent) : null : prev.agent,
7090
- model: patch.model !== void 0 ? patch.model?.trim() || null : prev.model,
7091
- effort: patch.effort !== void 0 ? normalizeThinkingEffort(patch.effort) : prev.effort,
7092
- fast: patch.fast !== void 0 ? normalizeOptionalBool(patch.fast) : prev.fast,
7093
- planMode: patch.planMode !== void 0 ? normalizeOptionalBool(patch.planMode) : prev.planMode,
7094
- autonomy: patch.autonomy !== void 0 ? normalizeAutonomy(patch.autonomy) : prev.autonomy,
7095
- attachments: patch.attachments !== void 0 ? normalizeAttachments(patch.attachments) : prev.attachments,
7096
- archiveChat: patch.archiveChat !== void 0 ? patch.archiveChat !== false : prev.archiveChat,
7097
- nextRunAt: whenChanged ? computeNextRunAt(when).toISOString() : prev.nextRunAt,
7098
- lastError: whenChanged ? null : prev.lastError,
7099
- updatedAt: nowIso()
7100
- };
7101
- rows[idx] = next;
7102
- writeAll(rows);
7103
- ensureCaffeinateForFutureSchedule(next);
7104
- return next;
7105
- }
7106
- function deleteSchedule(id) {
7107
- const rows = readAll();
7108
- const next = rows.filter(
7109
- (row) => row.id !== id && !(id.length >= 8 && row.id.startsWith(id))
7110
- );
7111
- if (next.length === rows.length) throw new Error(`Automation not found: ${id}`);
7112
- writeAll(next);
7113
- }
7114
- function recordScheduleRun(id, result) {
7115
- const rows = readAll();
7116
- const idx = rows.findIndex((row) => row.id === id);
7117
- if (idx < 0) throw new Error(`Automation not found: ${id}`);
7118
- const prev = rows[idx];
7119
- const firedAt = result.firedAt ?? /* @__PURE__ */ new Date();
7120
- const next = {
7121
- ...prev,
7122
- enabled: prev.when.kind === "once" ? false : prev.enabled,
7123
- nextRunAt: prev.when.kind === "once" ? prev.nextRunAt : computeNextRunAt(prev.when, firedAt).toISOString(),
7124
- lastRunAt: nowIso(firedAt),
7125
- lastThreadId: result.lastThreadId !== void 0 ? result.lastThreadId : prev.lastThreadId,
7126
- lastError: result.lastError ?? null,
7127
- updatedAt: nowIso(firedAt)
7128
- };
7129
- rows[idx] = next;
7130
- writeAll(rows);
7131
- return next;
7132
- }
7133
-
7134
6734
  // src/orchestrator/schedule-runner.ts
7135
6735
  var SET_TIMEOUT_MAX = 2147483647;
7136
6736
  var fireHooks = null;
@@ -7141,7 +6741,7 @@ function formatScheduledPrompt(name, prompt) {
7141
6741
  ${prompt}`;
7142
6742
  }
7143
6743
  async function defaultDeps() {
7144
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-RQXRZW7Z.js");
6744
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-W4TZBBDO.js");
7145
6745
  const orch = getOrchestrator2();
7146
6746
  return {
7147
6747
  findThread: (id) => findThreadByRef(id),
@@ -7197,7 +6797,15 @@ async function fireSchedule(id) {
7197
6797
  const deps = fireHooks ?? await defaultDeps();
7198
6798
  const prompt = formatScheduledPrompt(schedule.name, schedule.prompt);
7199
6799
  const target = schedule.threadId ? deps.findThread(schedule.threadId) : null;
7200
- if (target && target.status !== "archived") {
6800
+ if (schedule.threadId && (!target || target.status === "archived")) {
6801
+ deleteSchedule(schedule.id);
6802
+ return {
6803
+ ...schedule,
6804
+ enabled: false,
6805
+ lastError: "Removed because its chat is archived or gone."
6806
+ };
6807
+ }
6808
+ if (target) {
7201
6809
  const sent = await deps.send(target.id, prompt, {
7202
6810
  attachments: schedule.attachments,
7203
6811
  options: scheduleSendOptions(schedule)
@@ -7207,8 +6815,7 @@ async function fireSchedule(id) {
7207
6815
  lastError: null
7208
6816
  });
7209
6817
  }
7210
- const pinReplacement = Boolean(schedule.threadId) && schedule.when.kind !== "once";
7211
- const archiveFresh = schedule.archiveChat !== false && !pinReplacement;
6818
+ const archiveFresh = schedule.archiveChat !== false;
7212
6819
  const created = await deps.startOrchestration({
7213
6820
  goal: prompt,
7214
6821
  agent: pickAgent(schedule),
@@ -7221,9 +6828,6 @@ async function fireSchedule(id) {
7221
6828
  ...archiveFresh ? { ephemeralAutomationId: schedule.id } : {},
7222
6829
  ephemeralTitle: schedule.name
7223
6830
  });
7224
- if (pinReplacement) {
7225
- updateSchedule(schedule.id, { threadId: created.id });
7226
- }
7227
6831
  return recordScheduleRun(schedule.id, {
7228
6832
  lastThreadId: created.id,
7229
6833
  lastError: null
@@ -7426,7 +7030,7 @@ var Orchestrator = class {
7426
7030
  this.lightReconcileAt.set(repoPath, Date.now());
7427
7031
  for (const thread of listThreads()) {
7428
7032
  if (isGlobalThread(thread) || thread.repoPath !== repoPath) continue;
7429
- if (!existsSync14(thread.worktreePath)) {
7033
+ if (!existsSync13(thread.worktreePath)) {
7430
7034
  setStatus(thread.id, "broken", "Worktree missing on disk");
7431
7035
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
7432
7036
  }
@@ -7455,7 +7059,7 @@ var Orchestrator = class {
7455
7059
  }
7456
7060
  continue;
7457
7061
  }
7458
- if (!existsSync14(thread.worktreePath)) {
7062
+ if (!existsSync13(thread.worktreePath)) {
7459
7063
  setStatus(thread.id, "broken", "Worktree missing on disk");
7460
7064
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
7461
7065
  continue;
@@ -7492,7 +7096,7 @@ var Orchestrator = class {
7492
7096
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
7493
7097
  });
7494
7098
  }
7495
- const { autoCleanupOrphansEnabled } = await import("./app-settings-TUVLZNDE.js");
7099
+ const { autoCleanupOrphansEnabled } = await import("./app-settings-SA4HX3ZQ.js");
7496
7100
  if (autoCleanupOrphansEnabled() && shouldRunWorktreeCleanup() && orphans.length > 0) {
7497
7101
  await cleanupOrphanWorktrees({ repoPaths });
7498
7102
  }
@@ -7886,7 +7490,7 @@ var Orchestrator = class {
7886
7490
  }
7887
7491
  await setup;
7888
7492
  if (skipSetup) return;
7889
- const { autoRunAfterSetupEnabled } = await import("./app-settings-TUVLZNDE.js");
7493
+ const { autoRunAfterSetupEnabled } = await import("./app-settings-SA4HX3ZQ.js");
7890
7494
  if (autoRunAfterSetupEnabled()) {
7891
7495
  try {
7892
7496
  await this.startDev(threadId);
@@ -8271,7 +7875,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8271
7875
  }
8272
7876
  const isBrightsy = fresh.agent === "brightsy";
8273
7877
  const isOrchestration = isOrchestratorThread(fresh);
8274
- const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-TUVLZNDE.js");
7878
+ const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-SA4HX3ZQ.js");
8275
7879
  const gitAuthMode = getGithubGitAuthMode();
8276
7880
  const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh, {
8277
7881
  githubSlug: turnOrigin?.forge === "github" ? turnOrigin.slug : await withTimeout(resolveGithubRepoSlug(fresh.worktreePath), 8e3, "resolveGithubRepoSlug").catch(() => null),
@@ -8905,7 +8509,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
8905
8509
  const request = sameIntent ? pending : {
8906
8510
  op,
8907
8511
  scriptName: scriptName ?? null,
8908
- requestId: randomUUID5(),
8512
+ requestId: randomUUID4(),
8909
8513
  requestedAt: (/* @__PURE__ */ new Date()).toISOString()
8910
8514
  };
8911
8515
  if (!sameIntent) {
@@ -9611,7 +9215,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9611
9215
  if (Object.keys(patch).length === 0) continue;
9612
9216
  updateThread(t.id, patch);
9613
9217
  }
9614
- const { autoArchiveOnMergeEnabled } = await import("./app-settings-TUVLZNDE.js");
9218
+ const { autoArchiveOnMergeEnabled } = await import("./app-settings-SA4HX3ZQ.js");
9615
9219
  const latest = this.requireThread(thread.id);
9616
9220
  if (!shouldAutoArchiveOnPrMerge({
9617
9221
  previousPrState: prevState || null,
@@ -9935,7 +9539,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9935
9539
  await runArchiveScript(thread.repoPath, thread.worktreePath);
9936
9540
  } catch {
9937
9541
  }
9938
- const { deleteBranchOnPurgeEnabled } = await import("./app-settings-TUVLZNDE.js");
9542
+ const { deleteBranchOnPurgeEnabled } = await import("./app-settings-SA4HX3ZQ.js");
9939
9543
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled();
9940
9544
  await removeWorktree(thread.repoPath, thread.worktreePath, {
9941
9545
  deleteBranch: deleteBranch ? thread.branchName : void 0
@@ -9957,7 +9561,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9957
9561
  this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
9958
9562
  return restored2;
9959
9563
  }
9960
- if (!existsSync14(thread.worktreePath)) {
9564
+ if (!existsSync13(thread.worktreePath)) {
9961
9565
  if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
9962
9566
  throw new Error(
9963
9567
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
@@ -10073,7 +9677,7 @@ async function startOrchestration(opts) {
10073
9677
  sourceRef: "default",
10074
9678
  ...createOpts
10075
9679
  }).catch(async () => {
10076
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-KFEJAQ2H.js");
9680
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-JBNEMJ5Z.js");
10077
9681
  const repo = await resolveRepoRoot2(repoPath);
10078
9682
  const def = await resolveDefaultBranch2(repo);
10079
9683
  return orch.createThread({
@@ -10083,7 +9687,7 @@ async function startOrchestration(opts) {
10083
9687
  repoPath: repo
10084
9688
  });
10085
9689
  });
10086
- const { updateThread: upd } = await import("./thread-store-4ZN3DS2W.js");
9690
+ const { updateThread: upd } = await import("./thread-store-4WE24XA2.js");
10087
9691
  const updated = upd(thread.id, {
10088
9692
  sourceType: "orchestration",
10089
9693
  sourceRef: goal
@@ -10140,14 +9744,6 @@ export {
10140
9744
  formatListedIssuesForMcp,
10141
9745
  mcpJson,
10142
9746
  registerViewerContextTools,
10143
- parseWeeklyDays,
10144
- resolveScheduleThreadId,
10145
- listSchedules,
10146
- scheduleNeedsCaffeinate,
10147
- getSchedule,
10148
- createSchedule,
10149
- updateSchedule,
10150
- deleteSchedule,
10151
9747
  fireSchedule,
10152
9748
  LIVE_TURN_SPAWN_GRACE_MS,
10153
9749
  RUN_SCRIPT_DESKTOP_ADOPT_MS,