@sideboard-ai/core 0.1.346 → 0.1.348

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 (67) hide show
  1. package/dist/{abletime-MSIMJKKQ.js → abletime-3HRWLQZJ.js} +4 -4
  2. package/dist/{abletime-X2TJ6PPK.js → abletime-CGFJZB7L.js} +4 -4
  3. package/dist/{abletime-oauth-DEIENLHC.js → abletime-oauth-JQDSH5OL.js} +3 -3
  4. package/dist/{abletime-oauth-2RUKRZYZ.js → abletime-oauth-QNJQLHR4.js} +3 -3
  5. package/dist/{abletime-rest-UBLSGMSA.js → abletime-rest-TANL5TMY.js} +3 -3
  6. package/dist/{abletime-rest-HWBUPI4R.js → abletime-rest-UQA2CRZN.js} +3 -3
  7. package/dist/{agents-AQM7NLXD.js → agents-5MFGVK7C.js} +7 -7
  8. package/dist/{agents-7CHZO3K3.js → agents-T4XBZZDA.js} +7 -7
  9. package/dist/{app-settings-Q2F57NVK.js → app-settings-PPIMYJKS.js} +3 -1
  10. package/dist/{app-settings-A6JUT2SF.js → app-settings-SNOPJ7P5.js} +3 -1
  11. package/dist/{chunk-RTZO2YJC.js → chunk-2HPVGTHF.js} +2 -2
  12. package/dist/{chunk-GHKJBZW5.js → chunk-4NXGVJA6.js} +2 -2
  13. package/dist/{chunk-O5WRVQFT.js → chunk-5FUAOU3G.js} +1 -1
  14. package/dist/{chunk-3J3XOIHF.js → chunk-62ALWH3T.js} +3 -3
  15. package/dist/{chunk-J3BQHHDZ.js → chunk-6TV6L2DD.js} +4 -4
  16. package/dist/{chunk-4PHOJMZI.js → chunk-6WMNIX2U.js} +35 -2
  17. package/dist/{chunk-4PXHJA5K.js → chunk-7B2OUQON.js} +2 -2
  18. package/dist/{chunk-TD76ORBJ.js → chunk-AJMERXZP.js} +2 -2
  19. package/dist/{chunk-QTDCPMOW.js → chunk-ATS7SYHG.js} +1 -1
  20. package/dist/{chunk-AG2RM3DF.js → chunk-CEQ4Z32M.js} +3 -3
  21. package/dist/{chunk-5TS3KVGI.js → chunk-E77SRVVO.js} +1 -1
  22. package/dist/{chunk-5SJGR3VS.js → chunk-F7WP2U5I.js} +12 -9
  23. package/dist/{chunk-YFPSTG52.js → chunk-FDYMVJFU.js} +5 -5
  24. package/dist/{chunk-IYX53WZY.js → chunk-GAGTEI6B.js} +5 -5
  25. package/dist/{chunk-MB3GOWB3.js → chunk-IVRWRYTH.js} +19 -10
  26. package/dist/{chunk-3DMRQB4Y.js → chunk-JCYGQKER.js} +1 -1
  27. package/dist/{chunk-JHT3CYLT.js → chunk-MOUAM6ZC.js} +1 -1
  28. package/dist/{chunk-Z54FI4VL.js → chunk-NTY5WGRD.js} +2 -2
  29. package/dist/{chunk-5IMXA563.js → chunk-OH3BAUMC.js} +46 -33
  30. package/dist/{chunk-LHU6ZBFB.js → chunk-OHUAAX3O.js} +2 -2
  31. package/dist/{chunk-NQHEEGTH.js → chunk-PVCECFJK.js} +1 -1
  32. package/dist/{chunk-MHRU743Z.js → chunk-Q4TZA4MN.js} +2247 -2155
  33. package/dist/{chunk-4SNEW63T.js → chunk-RUIHNWRV.js} +3 -3
  34. package/dist/{chunk-NDBMDHQ5.js → chunk-RYPD7XWV.js} +5 -5
  35. package/dist/{chunk-FNAP6CCS.js → chunk-UJMCTGV7.js} +2 -2
  36. package/dist/{chunk-JZKNRDKF.js → chunk-WMD77UCY.js} +47 -34
  37. package/dist/{chunk-S3UGLMGE.js → chunk-WWU4SYZR.js} +35 -2
  38. package/dist/{chunk-4YGVJRXY.js → chunk-XNGW4OYD.js} +4 -4
  39. package/dist/{chunk-TW63CYUA.js → chunk-Y6VQX2LY.js} +2679 -2587
  40. package/dist/{chunk-BD7KUYJA.js → chunk-ZJMYCDYQ.js} +5 -5
  41. package/dist/{conductor-DUHRZUQY.js → conductor-EMGMDNHL.js} +5 -5
  42. package/dist/{conductor-3A2TNWUW.js → conductor-LYQKONSA.js} +5 -5
  43. package/dist/{coordinator-prompt-OX6A4MDA.js → coordinator-prompt-DLY3FS2L.js} +4 -4
  44. package/dist/{coordinator-prompt-7QALNDIV.js → coordinator-prompt-WALVMGKI.js} +4 -4
  45. package/dist/{global-workspace-HM2RKBCT.js → global-workspace-7OQ5O6JT.js} +4 -4
  46. package/dist/{global-workspace-6GGS3DWU.js → global-workspace-UG2A3CEM.js} +4 -4
  47. package/dist/index.cjs +1115 -651
  48. package/dist/index.d.cts +61 -6
  49. package/dist/index.d.ts +61 -6
  50. package/dist/index.js +326 -32
  51. package/dist/{linear-WYI64BMX.js → linear-MIJO6DCV.js} +2 -2
  52. package/dist/{linear-JE4WAZ3W.js → linear-PKYJH4WK.js} +2 -2
  53. package/dist/{linear-list-I4NAOWPN.js → linear-list-JPQ27RXG.js} +1 -1
  54. package/dist/{linear-list-CGUCPWTV.js → linear-list-N57PR6JM.js} +1 -1
  55. package/dist/mcp/run-stdio.cjs +524 -235
  56. package/dist/mcp/run-stdio.js +106 -21
  57. package/dist/{optional-cli-7QXXPEN6.js → optional-cli-4GTEDEYJ.js} +3 -3
  58. package/dist/{optional-cli-YHLVTVRK.js → optional-cli-RPJIQBDX.js} +4 -4
  59. package/dist/{orchestrator-OWO6LQ5U.js → orchestrator-4SXTORD2.js} +10 -10
  60. package/dist/{orchestrator-POMFVZLB.js → orchestrator-KNOMW5CZ.js} +10 -10
  61. package/dist/{thread-store-HETUMDVA.js → thread-store-MEUWZDVV.js} +2 -2
  62. package/dist/{thread-store-V5IDUJ4L.js → thread-store-R3G5VBII.js} +2 -2
  63. package/dist/{workspaces-DTMPNDPW.js → workspaces-35T6FW57.js} +4 -4
  64. package/dist/{workspaces-V6IIBSKA.js → workspaces-KWGTP7DI.js} +4 -4
  65. package/dist/{worktree-FX5FT6BI.js → worktree-5P7SCST3.js} +3 -3
  66. package/dist/{worktree-BD3EJE24.js → worktree-ROJXGBWS.js} +3 -3
  67. package/package.json +1 -1
@@ -10,13 +10,13 @@ import {
10
10
  import {
11
11
  abletimeRestUrl,
12
12
  textFromAbleTimeDoc
13
- } from "./chunk-TD76ORBJ.js";
13
+ } from "./chunk-AJMERXZP.js";
14
14
  import {
15
15
  assertAbleTimeCredential,
16
16
  callAbleTimeTool,
17
17
  normalizeAbleTimeHost,
18
18
  rewriteAbleTimeError
19
- } from "./chunk-YFPSTG52.js";
19
+ } from "./chunk-FDYMVJFU.js";
20
20
  import {
21
21
  httpFetch
22
22
  } from "./chunk-JAT3JFOS.js";
@@ -25,7 +25,7 @@ import {
25
25
  getAbleTimeHost,
26
26
  isAbleTimeConnected,
27
27
  saveAbleTimeConnection
28
- } from "./chunk-4PHOJMZI.js";
28
+ } from "./chunk-6WMNIX2U.js";
29
29
 
30
30
  // src/integrations/abletime-attachments.ts
31
31
  function asRecord(value) {
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  getAbleTimeHost,
8
8
  isAbleTimeConnected
9
- } from "./chunk-S3UGLMGE.js";
9
+ } from "./chunk-WWU4SYZR.js";
10
10
 
11
11
  // src/integrations/abletime-mcp.ts
12
12
  var DEFAULT_ABLETIME_HOST = "https://track.abletime.com";
@@ -155,7 +155,7 @@ function textsFromUnknown(value) {
155
155
  return "";
156
156
  }
157
157
  async function abletimeMcpRequest(method, params, opts) {
158
- const rawToken = opts?.token ?? await import("./abletime-oauth-2RUKRZYZ.js").then((m) => m.ensureAbleTimeAccessToken());
158
+ const rawToken = opts?.token ?? await import("./abletime-oauth-QNJQLHR4.js").then((m) => m.ensureAbleTimeAccessToken());
159
159
  if (!rawToken?.trim()) {
160
160
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
161
161
  }
@@ -226,9 +226,9 @@ async function callAbleTimeTool(name, args = {}, opts) {
226
226
  if (!opts?.token && !isAbleTimeConnected()) {
227
227
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
228
228
  }
229
- const rawToken = opts?.token ?? await import("./abletime-oauth-2RUKRZYZ.js").then((m) => m.ensureAbleTimeAccessToken());
229
+ const rawToken = opts?.token ?? await import("./abletime-oauth-QNJQLHR4.js").then((m) => m.ensureAbleTimeAccessToken());
230
230
  if (rawToken && ableTimeUsesRest(rawToken)) {
231
- const { callAbleTimeRestTool } = await import("./abletime-rest-UBLSGMSA.js");
231
+ const { callAbleTimeRestTool } = await import("./abletime-rest-TANL5TMY.js");
232
232
  return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
233
233
  }
234
234
  const requestOpts = { ...opts, pm: opts?.pm ?? abletimeToolUsesPm(name) };
@@ -244,7 +244,7 @@ async function callAbleTimeTool(name, args = {}, opts) {
244
244
  return await call();
245
245
  }
246
246
  if (rawToken && ableTimeUsesRest(rawToken) && isAbleTimeRejectedCredential(message)) {
247
- const { callAbleTimeRestTool } = await import("./abletime-rest-UBLSGMSA.js");
247
+ const { callAbleTimeRestTool } = await import("./abletime-rest-TANL5TMY.js");
248
248
  return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
249
249
  }
250
250
  throw err instanceof Error ? new Error(rewriteAbleTimeError(err.message)) : err;
@@ -2,11 +2,11 @@ import {
2
2
  OPTIONAL_SERVICES,
3
3
  isOptionalServiceId,
4
4
  optionalServiceSpec
5
- } from "./chunk-MB3GOWB3.js";
5
+ } from "./chunk-IVRWRYTH.js";
6
6
  import {
7
7
  installNpmGlobalPackage,
8
8
  whichOnPath
9
- } from "./chunk-GHKJBZW5.js";
9
+ } from "./chunk-4NXGVJA6.js";
10
10
  import {
11
11
  enrichPathWithNpmGlobalBin
12
12
  } from "./chunk-R4W4VQJZ.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  formatOptionalServicesDirectiveForTurn,
3
3
  formatOptionalServicesReminderForTurn
4
- } from "./chunk-MB3GOWB3.js";
4
+ } from "./chunk-IVRWRYTH.js";
5
5
  import {
6
6
  extractPresentedPlan,
7
7
  isPresentPlanToolName,
@@ -21,7 +21,7 @@ import {
21
21
  parseSessionQuotaResetAt,
22
22
  planModeTurnInstruction,
23
23
  resolveQuotaFallbackAgent
24
- } from "./chunk-MHRU743Z.js";
24
+ } from "./chunk-Q4TZA4MN.js";
25
25
  import {
26
26
  applyWorktreePkgCacheEnv,
27
27
  buildBrightsySessionSeed,
@@ -56,7 +56,7 @@ import {
56
56
  worktreeDevProcessKey,
57
57
  worktreeRunProcessKey,
58
58
  worktreeSetupProcessKey
59
- } from "./chunk-IYX53WZY.js";
59
+ } from "./chunk-GAGTEI6B.js";
60
60
  import {
61
61
  applyAgentEvent,
62
62
  clipAgentEventForPaint,
@@ -101,7 +101,7 @@ import {
101
101
  stageAbsolutePathsAsAttachments,
102
102
  stageBuffersAsAttachments,
103
103
  syncWorkspacesFromThreads
104
- } from "./chunk-4YGVJRXY.js";
104
+ } from "./chunk-XNGW4OYD.js";
105
105
  import {
106
106
  addPrStackLayer,
107
107
  allocateTeamSlug,
@@ -154,7 +154,7 @@ import {
154
154
  resolveRepoRoot,
155
155
  switchWorktreeBranch,
156
156
  withRepoGitLock
157
- } from "./chunk-Z54FI4VL.js";
157
+ } from "./chunk-NTY5WGRD.js";
158
158
  import {
159
159
  REVIEW_TAB_TITLE,
160
160
  agentNicknameFromWorktreePath,
@@ -186,7 +186,7 @@ import {
186
186
  worktreeNameFromPath,
187
187
  worktreeSlugForTicket,
188
188
  writeThread
189
- } from "./chunk-QTDCPMOW.js";
189
+ } from "./chunk-ATS7SYHG.js";
190
190
  import {
191
191
  askBlockStillWaiting,
192
192
  extractPendingPlanQuestions,
@@ -264,7 +264,7 @@ import {
264
264
  wakeOrchestratorOnGithubEdgesEnabled,
265
265
  withTurnScopedCost,
266
266
  writeViewerContext
267
- } from "./chunk-4PHOJMZI.js";
267
+ } from "./chunk-6WMNIX2U.js";
268
268
  import {
269
269
  examplePrefixedBranch,
270
270
  sanitizeGitBranchPrefix
@@ -527,9 +527,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
527
527
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
528
528
  );
529
529
  }
530
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-6GGS3DWU.js");
530
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-UG2A3CEM.js");
531
531
  if (isGlobalThread2(thread)) {
532
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-OX6A4MDA.js");
532
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-DLY3FS2L.js");
533
533
  ensureGlobalCoordinatorCwd2(
534
534
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
535
535
  );
@@ -2339,6 +2339,10 @@ function resolveStopReason(opts) {
2339
2339
  if (opts?.clearQueue === false) return "Stopped by the user";
2340
2340
  return "Stopped (queue cleared)";
2341
2341
  }
2342
+ function isRoutineStopNote(err) {
2343
+ const text3 = err?.trim() ?? "";
2344
+ return text3 === "Stopped" || text3 === "Stopped by the user" || text3 === "Stopped (queue cleared)" || text3 === "Stopped to send the next prompt";
2345
+ }
2342
2346
  function reasonToKeepOnStop(existing, incoming) {
2343
2347
  const next = incoming?.trim();
2344
2348
  if (next) return next.slice(0, STOP_REASON_MAX);
@@ -2346,6 +2350,16 @@ function reasonToKeepOnStop(existing, incoming) {
2346
2350
  if (prior) return prior.slice(0, STOP_REASON_MAX);
2347
2351
  return "Stopped";
2348
2352
  }
2353
+ function turnFinishedEvent(threadId, exitCode, userStopped, lastError) {
2354
+ const note = lastError?.trim() ?? "";
2355
+ const routineStop = userStopped && (note.length === 0 || isRoutineStopNote(note));
2356
+ return {
2357
+ type: "turn_finished",
2358
+ threadId,
2359
+ exitCode,
2360
+ ...routineStop ? { routineStop: true } : {}
2361
+ };
2362
+ }
2349
2363
  function writeStoppedStatus(threadId, reason) {
2350
2364
  const latest = readThread(threadId);
2351
2365
  if (!latest || latest.status === "archived") return latest;
@@ -3299,7 +3313,7 @@ async function createThread(input, _onSetupLine) {
3299
3313
  });
3300
3314
  await requireAgent(resolved.agent);
3301
3315
  if (input.cowboy) {
3302
- const { cowboyModeEnabled } = await import("./app-settings-A6JUT2SF.js");
3316
+ const { cowboyModeEnabled } = await import("./app-settings-SNOPJ7P5.js");
3303
3317
  if (!cowboyModeEnabled()) {
3304
3318
  throw new Error(
3305
3319
  "Cowboy mode is off. Enable it in Settings \u2192 Advanced."
@@ -3358,7 +3372,7 @@ async function createThread(input, _onSetupLine) {
3358
3372
  let sourceIsFork = false;
3359
3373
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
3360
3374
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
3361
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-X2TJ6PPK.js");
3375
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-CGFJZB7L.js");
3362
3376
  const task = await ensureAbleTimeTask({
3363
3377
  title: title?.trim() || "Untitled work",
3364
3378
  description: input.prompt?.trim() || void 0
@@ -3469,7 +3483,7 @@ async function createThread(input, _onSetupLine) {
3469
3483
  return readThread(thread.id) ?? thread;
3470
3484
  }
3471
3485
  async function listLinearIssues(agent, repoPath) {
3472
- const { getAdapter: getAdapter2 } = await import("./agents-AQM7NLXD.js");
3486
+ const { getAdapter: getAdapter2 } = await import("./agents-5MFGVK7C.js");
3473
3487
  await requireAgent(agent, { requireLinear: true });
3474
3488
  const adapter = getAdapter2(agent);
3475
3489
  if (!adapter.listLinearIssues) {
@@ -4252,7 +4266,7 @@ async function adoptThread(input) {
4252
4266
  messages: input.messages ?? []
4253
4267
  });
4254
4268
  writeThread(thread);
4255
- const { addWorkspace: addWorkspace2 } = await import("./workspaces-DTMPNDPW.js");
4269
+ const { addWorkspace: addWorkspace2 } = await import("./workspaces-35T6FW57.js");
4256
4270
  await addWorkspace2(repoPath);
4257
4271
  const { ensureWorktreeSideboardIgnored } = await import("./worktree-exclude-YQBN43QD.js");
4258
4272
  await ensureWorktreeSideboardIgnored(input.worktreePath);
@@ -7877,11 +7891,11 @@ function realDeps() {
7877
7891
  parentIdForThread,
7878
7892
  designatedId: designatedOrchestratorId,
7879
7893
  send: async (threadId, prompt) => {
7880
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-POMFVZLB.js");
7894
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-KNOMW5CZ.js");
7881
7895
  await getOrchestrator2().send(threadId, prompt, { followUp: "queue" });
7882
7896
  },
7883
7897
  startOrchestration: async (prompt) => {
7884
- const { startOrchestration: startOrchestration2 } = await import("./orchestrator-POMFVZLB.js");
7898
+ const { startOrchestration: startOrchestration2 } = await import("./orchestrator-KNOMW5CZ.js");
7885
7899
  const defaults = resolveOrchestratorDefaults();
7886
7900
  await startOrchestration2({
7887
7901
  goal: prompt,
@@ -7908,7 +7922,7 @@ function formatScheduledPrompt(name, prompt) {
7908
7922
  ${prompt}`;
7909
7923
  }
7910
7924
  async function defaultDeps() {
7911
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-POMFVZLB.js");
7925
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-KNOMW5CZ.js");
7912
7926
  const orch = getOrchestrator2();
7913
7927
  return {
7914
7928
  findThread: (id) => findThreadByRef(id),
@@ -8264,7 +8278,7 @@ var Orchestrator = class {
8264
8278
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
8265
8279
  });
8266
8280
  }
8267
- const { autoCleanupOrphansEnabled } = await import("./app-settings-A6JUT2SF.js");
8281
+ const { autoCleanupOrphansEnabled } = await import("./app-settings-SNOPJ7P5.js");
8268
8282
  if (autoCleanupOrphansEnabled() && shouldRunWorktreeCleanup() && orphans.length > 0) {
8269
8283
  await cleanupOrphanWorktrees({ repoPaths });
8270
8284
  }
@@ -8383,7 +8397,7 @@ var Orchestrator = class {
8383
8397
  if (!this.shouldReclaimRunningThread(thread)) continue;
8384
8398
  setStatus(thread.id, "stopped", "Process died (agent exited)");
8385
8399
  this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
8386
- this.emit({ type: "turn_finished", threadId: thread.id, exitCode: 1 });
8400
+ this.emit(turnFinishedEvent(thread.id, 1, this.stoppedTurns.has(thread.id), readThread(thread.id)?.lastError));
8387
8401
  const latest = readThread(thread.id);
8388
8402
  if (latest) {
8389
8403
  notifyParentOfChildHalt(latest, "stopped", (id, prompt) => this.send(id, prompt));
@@ -8654,7 +8668,7 @@ var Orchestrator = class {
8654
8668
  }
8655
8669
  await setup;
8656
8670
  if (skipSetup) return;
8657
- const { autoRunAfterSetupEnabled } = await import("./app-settings-A6JUT2SF.js");
8671
+ const { autoRunAfterSetupEnabled } = await import("./app-settings-SNOPJ7P5.js");
8658
8672
  if (autoRunAfterSetupEnabled()) {
8659
8673
  try {
8660
8674
  await this.startDev(threadId);
@@ -8948,7 +8962,7 @@ var Orchestrator = class {
8948
8962
  if (stopped?.status === "stopped") {
8949
8963
  this.emit({ type: "status_changed", threadId, status: "stopped" });
8950
8964
  }
8951
- this.emit({ type: "turn_finished", threadId, exitCode: 1 });
8965
+ this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
8952
8966
  return;
8953
8967
  }
8954
8968
  thread = this.requireThread(threadId);
@@ -9038,7 +9052,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9038
9052
  }
9039
9053
  const isBrightsy = fresh.agent === "brightsy";
9040
9054
  const isOrchestration = isOrchestratorThread(fresh);
9041
- const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-A6JUT2SF.js");
9055
+ const { autoRenameBranchEnabled, getGithubGitAuthMode, gitBranchPrefixSetting } = await import("./app-settings-SNOPJ7P5.js");
9042
9056
  const gitAuthMode = getGithubGitAuthMode();
9043
9057
  const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh, {
9044
9058
  githubSlug: turnOrigin?.forge === "github" ? turnOrigin.slug : await withTimeout(resolveGithubRepoSlug(fresh.worktreePath), 8e3, "resolveGithubRepoSlug").catch(() => null),
@@ -9356,7 +9370,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9356
9370
  if (stopped?.status === "stopped") {
9357
9371
  this.emit({ type: "status_changed", threadId, status: "stopped" });
9358
9372
  }
9359
- this.emit({ type: "turn_finished", threadId, exitCode });
9373
+ this.emit(turnFinishedEvent(threadId, exitCode, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
9360
9374
  } else {
9361
9375
  const failDetail = formatTurnExitError(exitCode, detail);
9362
9376
  const explainedInChat = exitCode !== 0 && Boolean(chatText) && (looksLikeAgentFailureMessage(chatText) || failDetail && chatText.includes(failDetail.replace(/^exit\s*\d+:\s*/i, "").trim()));
@@ -9373,7 +9387,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9373
9387
  status: written.status
9374
9388
  });
9375
9389
  }
9376
- this.emit({ type: "turn_finished", threadId, exitCode });
9390
+ this.emit(turnFinishedEvent(threadId, exitCode, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
9377
9391
  if (exitCode === 0) {
9378
9392
  this.crashContinued.delete(threadId);
9379
9393
  this.maybeEnqueueJobContinue(threadId, chatText, parts);
@@ -9408,14 +9422,14 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9408
9422
  if (stopped?.status === "stopped") {
9409
9423
  this.emit({ type: "status_changed", threadId, status: "stopped" });
9410
9424
  }
9411
- this.emit({ type: "turn_finished", threadId, exitCode: 1 });
9425
+ this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
9412
9426
  } else {
9413
9427
  const written = writeLiveStatus(threadId, "error", message);
9414
9428
  if (written?.status === "error") {
9415
9429
  this.emit({ type: "error", threadId, message });
9416
9430
  this.emit({ type: "status_changed", threadId, status: "error" });
9417
9431
  }
9418
- this.emit({ type: "turn_finished", threadId, exitCode: 1 });
9432
+ this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
9419
9433
  const failedOver = await isolateQuotaFailover(
9420
9434
  () => this.maybeHandleOrchestrationQuotaFailover(threadId, message)
9421
9435
  );
@@ -9463,9 +9477,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9463
9477
  const continueQueue = opts?.continueQueue === true;
9464
9478
  const thread = this.requireThread(threadRef);
9465
9479
  const inFlight = this.activeTurns.has(thread.id) || this.startingTurns.has(thread.id);
9466
- if (inFlight) {
9467
- this.stoppedTurns.add(thread.id);
9468
- }
9480
+ if (inFlight) this.stoppedTurns.add(thread.id);
9469
9481
  if (clearQueue && thread.queue.length > 0) {
9470
9482
  this.haltDrain.delete(thread.id);
9471
9483
  updateThread(thread.id, { queue: [], queueAttachments: [] });
@@ -9475,6 +9487,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9475
9487
  } else if (continueQueue) {
9476
9488
  this.haltDrain.delete(thread.id);
9477
9489
  }
9490
+ let stopped = writeStoppedStatus(thread.id, resolveStopReason(opts)) ?? readThread(thread.id) ?? thread;
9478
9491
  const handle = this.activeTurns.get(thread.id);
9479
9492
  if (handle) handle.kill();
9480
9493
  const proc = this.processes.get(`${thread.id}:agent`);
@@ -9493,10 +9506,10 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
9493
9506
  }
9494
9507
  }
9495
9508
  }
9496
- const stopped = writeStoppedStatus(thread.id, resolveStopReason(opts)) ?? readThread(thread.id) ?? thread;
9509
+ stopped = readThread(thread.id) ?? stopped;
9497
9510
  if (stopped.status === "stopped") {
9498
9511
  this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
9499
- if (inFlight && opts?.notifyParent !== false) {
9512
+ if (inFlight && opts?.notifyParent !== false && !continueQueue) {
9500
9513
  notifyParentOfChildHalt(stopped, "stopped", (id, prompt) => this.send(id, prompt));
9501
9514
  }
9502
9515
  }
@@ -10380,7 +10393,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10380
10393
  if (Object.keys(patch).length === 0) continue;
10381
10394
  updateThread(t.id, patch);
10382
10395
  }
10383
- const { autoArchiveOnMergeEnabled } = await import("./app-settings-A6JUT2SF.js");
10396
+ const { autoArchiveOnMergeEnabled } = await import("./app-settings-SNOPJ7P5.js");
10384
10397
  const latest = this.requireThread(thread.id);
10385
10398
  if (!shouldAutoArchiveOnPrMerge({
10386
10399
  previousPrState: prevState || null,
@@ -10704,7 +10717,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
10704
10717
  await runArchiveScript(thread.repoPath, thread.worktreePath);
10705
10718
  } catch {
10706
10719
  }
10707
- const { deleteBranchOnPurgeEnabled } = await import("./app-settings-A6JUT2SF.js");
10720
+ const { deleteBranchOnPurgeEnabled } = await import("./app-settings-SNOPJ7P5.js");
10708
10721
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled();
10709
10722
  await removeWorktree(thread.repoPath, thread.worktreePath, {
10710
10723
  deleteBranch: deleteBranch ? thread.branchName : void 0
@@ -10842,7 +10855,7 @@ async function startOrchestration(opts) {
10842
10855
  sourceRef: "default",
10843
10856
  ...createOpts
10844
10857
  }).catch(async () => {
10845
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-FX5FT6BI.js");
10858
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-5P7SCST3.js");
10846
10859
  const repo = await resolveRepoRoot2(repoPath);
10847
10860
  const def = await resolveDefaultBranch2(repo);
10848
10861
  return orch.createThread({
@@ -10852,7 +10865,7 @@ async function startOrchestration(opts) {
10852
10865
  repoPath: repo
10853
10866
  });
10854
10867
  });
10855
- const { updateThread: upd } = await import("./thread-store-V5IDUJ4L.js");
10868
+ const { updateThread: upd } = await import("./thread-store-R3G5VBII.js");
10856
10869
  const updated = upd(thread.id, {
10857
10870
  sourceType: "orchestration",
10858
10871
  sourceRef: goal
@@ -462,6 +462,12 @@ function normalizeVault(raw) {
462
462
  if (typeof raw.posthogPersonalApiKey === "string" && raw.posthogPersonalApiKey.trim()) {
463
463
  out.posthogPersonalApiKey = raw.posthogPersonalApiKey.trim();
464
464
  }
465
+ if (typeof raw.posthogAccessToken === "string" && raw.posthogAccessToken.trim()) {
466
+ out.posthogAccessToken = raw.posthogAccessToken.trim();
467
+ }
468
+ if (typeof raw.posthogRefreshToken === "string" && raw.posthogRefreshToken.trim()) {
469
+ out.posthogRefreshToken = raw.posthogRefreshToken.trim();
470
+ }
465
471
  if (typeof raw.sentryAuthToken === "string" && raw.sentryAuthToken.trim()) {
466
472
  out.sentryAuthToken = raw.sentryAuthToken.trim();
467
473
  }
@@ -870,6 +876,8 @@ var INTEGRATION_VAULT_KEYS = [
870
876
  "vercelToken",
871
877
  "supabaseAccessToken",
872
878
  "posthogPersonalApiKey",
879
+ "posthogAccessToken",
880
+ "posthogRefreshToken",
873
881
  "sentryAuthToken"
874
882
  ];
875
883
  function hasLinearOAuth(integrations) {
@@ -903,7 +911,7 @@ function toPublicAppSettings(settings) {
903
911
  hasAbleTimeOAuth: Boolean(settings.integrations.abletimeRefreshToken?.trim()),
904
912
  hasVercelToken: Boolean(settings.integrations.vercelToken?.trim()),
905
913
  hasSupabaseToken: Boolean(settings.integrations.supabaseAccessToken?.trim()),
906
- hasPosthogToken: Boolean(settings.integrations.posthogPersonalApiKey?.trim()),
914
+ hasPosthogToken: hasPosthogCredentials(settings.integrations),
907
915
  hasSentryToken: Boolean(settings.integrations.sentryAuthToken?.trim()),
908
916
  hasRemoteAccount: Boolean(settings.integrations.remoteAccountToken?.trim())
909
917
  }
@@ -1107,6 +1115,12 @@ function normalizeIntegrations(raw) {
1107
1115
  const key = source.posthogPersonalApiKey.trim();
1108
1116
  if (key) out.posthogPersonalApiKey = key;
1109
1117
  }
1118
+ for (const key of ["posthogAccessToken", "posthogRefreshToken"]) {
1119
+ const token = typeof source[key] === "string" ? source[key].trim() : "";
1120
+ if (token) out[key] = token;
1121
+ }
1122
+ const posthogExp = Number(source.posthogTokenExpiresAt);
1123
+ if (Number.isFinite(posthogExp)) out.posthogTokenExpiresAt = posthogExp;
1110
1124
  if (typeof source.posthogHost === "string") {
1111
1125
  const host = source.posthogHost.trim();
1112
1126
  if (host) out.posthogHost = host;
@@ -2040,8 +2054,26 @@ function disconnectLinearConnection() {
2040
2054
  delete integrations.linearOrganizationName;
2041
2055
  return saveAppSettings({ ...current, integrations });
2042
2056
  }
2057
+ function hasPosthogCredentials(integrations) {
2058
+ return Boolean(
2059
+ integrations.posthogAccessToken?.trim() || integrations.posthogRefreshToken?.trim() || integrations.posthogPersonalApiKey?.trim()
2060
+ );
2061
+ }
2043
2062
  function isPosthogConnected(settings = loadAppSettings()) {
2044
- return Boolean(settings.integrations.posthogPersonalApiKey?.trim());
2063
+ return hasPosthogCredentials(settings.integrations);
2064
+ }
2065
+ function savePosthogOAuth(input) {
2066
+ const current = loadAppSettings();
2067
+ const integrations = { ...current.integrations };
2068
+ integrations.posthogAccessToken = input.accessToken.trim();
2069
+ if (input.refreshToken?.trim()) integrations.posthogRefreshToken = input.refreshToken.trim();
2070
+ if (typeof input.expiresIn === "number" && Number.isFinite(input.expiresIn)) {
2071
+ integrations.posthogTokenExpiresAt = Date.now() + Math.max(0, input.expiresIn) * 1e3;
2072
+ }
2073
+ if (input.host?.trim()) integrations.posthogHost = input.host.trim();
2074
+ if (input.viewerName?.trim()) integrations.posthogViewerName = input.viewerName.trim().slice(0, 120);
2075
+ delete integrations.posthogPersonalApiKey;
2076
+ return saveAppSettings({ ...current, integrations });
2045
2077
  }
2046
2078
  function isAbleTimeConnected(settings = loadAppSettings()) {
2047
2079
  return Boolean(
@@ -2509,6 +2541,7 @@ export {
2509
2541
  saveLinearOAuth,
2510
2542
  disconnectLinearConnection,
2511
2543
  isPosthogConnected,
2544
+ savePosthogOAuth,
2512
2545
  isAbleTimeConnected,
2513
2546
  getAbleTimeAccessToken,
2514
2547
  getAbleTimeHost,
@@ -5,7 +5,7 @@ import {
5
5
  resolveGithubRepoSlug,
6
6
  resolveOriginRemote,
7
7
  resolveRepoRoot
8
- } from "./chunk-Z54FI4VL.js";
8
+ } from "./chunk-NTY5WGRD.js";
9
9
  import {
10
10
  allocateTeamName,
11
11
  createEmptyThread,
@@ -14,7 +14,7 @@ import {
14
14
  teamSlugFromName,
15
15
  updateThread,
16
16
  writeThread
17
- } from "./chunk-QTDCPMOW.js";
17
+ } from "./chunk-ATS7SYHG.js";
18
18
  import {
19
19
  ATTACHMENTS_DIR,
20
20
  attachmentsGitignoreBody
@@ -31,7 +31,7 @@ import {
31
31
  resolveThreadDefaults,
32
32
  resolveViewerProfile,
33
33
  resolveViewerProfileForRepo
34
- } from "./chunk-4PHOJMZI.js";
34
+ } from "./chunk-6WMNIX2U.js";
35
35
  import {
36
36
  appDataDir,
37
37
  globalAgentCwd,
@@ -394,7 +394,7 @@ var COORDINATOR_TOOL_PLAYBOOK = [
394
394
  "- linear_* (when Linear is connected) \u2014 list_teams for team key/states; linear_list_projects for project names; get/search include the project a ticket is on; get/create/update/comment with ENG-123. Worktree agents have the same Account tools \u2014 prefer they comment, update status, and create spin-offs (parent=) on their own ticket when they were asked to do the work. When reviewing a PR or ticket, do not comment or update until the user types a next step \u2014 they should work through the feedback in chat first. Do not tell the child to ask_user after the review. Scope errors: reconnect Linear in Account settings. Prefer these over any Linear MCP the CLI may still list. Worktree agents use the Claude Linear connector only when Account Linear is not set or the Sideboard call fails, and they do not mention that connector startup failure when Sideboard works.",
395
395
  "- github_* \u2014 get/comment/update/create GitHub issues via Account `gh` (#123). github_list_projects and get/search include GitHub Projects. projectsError or a missing read:project scope \u2192 `gh auth refresh -s read:project`. Worktree agents have these too. Prefer Sideboard `github_*` while Account `gh` works. A failed Claude GitHub connector (`mcp_github_github`) is not a Sideboard outage \u2014 do not mention it. Use that connector only when `gh` is not set up or the Sideboard call fails. Pass parent= for spin-offs. When reviewing a PR or ticket, do not comment, submit `gh pr review`, or update the PR/ticket until the user types a next step.",
396
396
  "- abletime_* (when AbleTime is connected) \u2014 orientation first; abletime_list_projects lists projects; get/list include the project a task is on; get/comment/update/create (parent= for spin-offs); ensure_task when work has no ticket (or create_workspace from the default branch auto-creates one). Worktree agents have the same Account tools. Same review-write gate as Linear/GitHub.",
397
- "- Optional connectors (Vercel, Supabase, Sentry) in Settings \u2192 Connectors inject tokens into worktree agent env when connected. Prefer official CLIs (`vercel`, `supabase`, `sentry-cli`). When Settings \u2192 Connectors has a PostHog personal API key, PostHog is the Sideboard tool `posthog_api` (GET by default; POST `/api/projects/:id/query/` or `/api/environments/:id/query/` is a read and does not need write=true; other POST and PATCH need write=true only when the user asked to change data). The PostHog key stays in the vault \u2014 do not read it from the environment, and do not sign in to a PostHog MCP. When no PostHog API key is set, use the Claude PostHog connector. When a key is set, ignore a failed Claude PostHog connector and do not sign in to a PostHog MCP. If a Vercel, Supabase, or Sentry MCP needsAuth or is unauthorized while that Sideboard token is set, do not sign in \u2014 use the native CLI. When that token is not set or the CLI call fails, the Claude connector is the fallback. Do not mention a Claude connector startup failure when the Sideboard connection works. Tell any worktree agent (Claude / Cursor / Codex / OpenCode) to write CLI output to `.context/cli/` and read a slice. If a CLI is missing, the user presses Install CLI on that row. Do not add vendor MCPs. Git (`gh`) stays Settings \u2192 Git; issue tracking stays Settings \u2192 Issues. The phone remote is Settings \u2192 Remote \u2014 do not look up Slack users.",
397
+ "- Optional connectors (Vercel, Supabase, Sentry) in Settings \u2192 Connectors inject tokens into worktree agent env when connected. Prefer official CLIs (`vercel`, `supabase`, `sentry-cli`). When Settings \u2192 Connectors is signed in to PostHog, PostHog is the Sideboard tool `posthog_api` (GET by default; POST `/api/projects/:id/query/` or `/api/environments/:id/query/` is a read and does not need write=true; other POST and PATCH need write=true only when the user asked to change data). The PostHog token stays in the vault \u2014 do not read it from the environment, and do not sign in to a PostHog MCP. When PostHog is not signed in, Claude worktree turns load the signed-in PostHog connector as server claude.ai PostHog (tools mcp__claude_ai_PostHog__*) inside --mcp-config. --strict-mcp-config does not load claude.ai connectors, and --allowedTools only skips prompts. Cursor, Codex, and OpenCode do not have those tools. When PostHog is signed in, ignore a failed Claude PostHog connector and do not sign in to a PostHog MCP. If a Vercel, Supabase, or Sentry MCP needsAuth or is unauthorized while that Sideboard token is set, do not sign in \u2014 use the native CLI. When that token is not set or the CLI call fails, the Claude connector is the fallback. Do not mention a Claude connector startup failure when the Sideboard connection works. Tell any worktree agent (Claude / Cursor / Codex / OpenCode) to write CLI output to `.context/cli/` and read a slice. If a CLI is missing, the user presses Install CLI on that row. Do not add vendor MCPs. Git (`gh`) stays Settings \u2192 Git; issue tracking stays Settings \u2192 Issues. The phone remote is Settings \u2192 Remote \u2014 do not look up Slack users.",
398
398
  "- get_pr_stack / open_pr_stack_layers / add_stack_layer / create_pr_stack \u2014 GitHub stacked PRs (`gh stack`); one worktree per layer",
399
399
  "- list_models \u2014 only when you need a specific model (rare); otherwise omit model so Account defaults apply",
400
400
  "- list_chats / get_chat \u2014 live thread list (parent id + last message preview). get_chat on this orchestration chat lists child worktree agents (status + lastText). blockedReason is why that agent is waiting on a person. Also includes usage / lastTurnUsage. Archived workspaces and agents are list_archive, not this list.",