@sideboard-ai/core 0.1.139 → 0.1.143

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 (63) hide show
  1. package/dist/{abletime-VTP4JR63.js → abletime-DI55AJX3.js} +2 -2
  2. package/dist/{abletime-DDTV7WO3.js → abletime-QEVAE67D.js} +2 -2
  3. package/dist/agents/cursor-runner.cjs +0 -0
  4. package/dist/agents/cursor-runner.js +1 -1
  5. package/dist/{agents-665S7Z3R.js → agents-E5AAMHDY.js} +11 -7
  6. package/dist/{agents-OC3XM7UE.js → agents-OEEOIKUB.js} +10 -6
  7. package/dist/{app-settings-U5RZKUXG.js → app-settings-WJDCJFSY.js} +3 -1
  8. package/dist/{app-settings-YQ7YX2CC.js → app-settings-ZCN632OJ.js} +3 -1
  9. package/dist/caffeinate-hold-NBRUWYXO.js +0 -0
  10. package/dist/{chunk-HLIHBGVO.js → chunk-4D4PEBGB.js} +2 -2
  11. package/dist/{chunk-DJJ3DTT4.js → chunk-4Q45TLZ5.js} +7 -7
  12. package/dist/chunk-6GN5WPYZ.js +0 -0
  13. package/dist/chunk-B3SJXYIJ.js +0 -0
  14. package/dist/chunk-BD2ICC4D.js +0 -0
  15. package/dist/{chunk-GKKHXZCT.js → chunk-BGQBELGJ.js} +201 -2
  16. package/dist/{chunk-2XXAAIN3.js → chunk-BOD5V52W.js} +1 -1
  17. package/dist/{chunk-23KCPND2.js → chunk-CG25RYQQ.js} +47 -40
  18. package/dist/{chunk-YZQEJOAU.js → chunk-EAP4SMR3.js} +342 -36
  19. package/dist/chunk-ED4UPEJX.js +0 -0
  20. package/dist/chunk-EUXOHTUK.js +0 -0
  21. package/dist/{chunk-5XH5M6RA.js → chunk-FADNFPZO.js} +3 -3
  22. package/dist/{chunk-SSBM4GZX.js → chunk-HC5N3BDL.js} +2 -2
  23. package/dist/{chunk-GJBHOJCZ.js → chunk-I77RYPOH.js} +201 -2
  24. package/dist/chunk-KGZBYWZ3.js +0 -0
  25. package/dist/chunk-KLBOWJ74.js +0 -0
  26. package/dist/{chunk-ZCLHAOFR.js → chunk-KP4OJUPH.js} +551 -39
  27. package/dist/chunk-KPIYENTF.js +0 -0
  28. package/dist/chunk-N5PM7HGQ.js +0 -0
  29. package/dist/chunk-NSTQ6QKD.js +0 -0
  30. package/dist/{chunk-DKXZCIB2.js → chunk-O3JEC2UJ.js} +7 -7
  31. package/dist/{chunk-RTX3AY42.js → chunk-OHWN4JEL.js} +5 -3
  32. package/dist/{chunk-E2RE7P2S.js → chunk-R2W7A2UO.js} +3 -3
  33. package/dist/chunk-S42XV45P.js +0 -0
  34. package/dist/{chunk-7SYFWPOZ.js → chunk-UG5N7ET3.js} +5 -3
  35. package/dist/{chunk-CDJISVKN.js → chunk-VHTIHOHE.js} +47 -41
  36. package/dist/{chunk-AT346U23.js → chunk-VZJVKQHH.js} +1 -1
  37. package/dist/{chunk-FSCQXMGI.js → chunk-WT5HSFOU.js} +1 -0
  38. package/dist/connected-teams-IJUJQ7R6.js +0 -0
  39. package/dist/{coordinator-prompt-43O6EPA2.js → coordinator-prompt-2LD3C74O.js} +3 -3
  40. package/dist/{coordinator-prompt-4TXU6Q3R.js → coordinator-prompt-FBX7Y4EM.js} +3 -3
  41. package/dist/cursor-recover-NOQYOFRF.js +0 -0
  42. package/dist/{global-workspace-ZDYKHQ4O.js → global-workspace-NG7SU3GV.js} +4 -4
  43. package/dist/{global-workspace-VIU57E3Y.js → global-workspace-OCV77UYF.js} +4 -4
  44. package/dist/index.cjs +945 -129
  45. package/dist/index.d.cts +249 -62
  46. package/dist/index.d.ts +249 -62
  47. package/dist/index.js +110 -14
  48. package/dist/mcp/run-stdio.cjs +646 -112
  49. package/dist/mcp/run-stdio.js +12 -12
  50. package/dist/oauth-YJBAURIJ.js +0 -0
  51. package/dist/{orchestrator-ZCMYSDTC.js → orchestrator-TDJZKQPT.js} +7 -7
  52. package/dist/{orchestrator-WEFXUHFX.js → orchestrator-VIFXOHF4.js} +8 -8
  53. package/dist/paths-QCI3MTO5.js +0 -0
  54. package/dist/plan-file-PHVKUAEE.js +0 -0
  55. package/dist/run-USF6FRKV.js +0 -0
  56. package/dist/thread-store-57ZLHR3A.js +0 -0
  57. package/dist/title-4WAKWZRF.js +0 -0
  58. package/dist/{workspaces-4HYGNH4B.js → workspaces-4FUQW5LD.js} +5 -5
  59. package/dist/{workspaces-ALCTB65T.js → workspaces-PU5YHQ7Z.js} +5 -5
  60. package/dist/{worktree-GXD2NGOZ.js → worktree-GKLPPNWR.js} +2 -2
  61. package/dist/{worktree-NSNZODAM.js → worktree-Z22HTSCU.js} +2 -2
  62. package/package.json +9 -8
  63. package/LICENSE +0 -190
@@ -19,6 +19,7 @@ import {
19
19
  looksLikeInvalidAgentSession,
20
20
  looksLikeV8Oom,
21
21
  normalizeParseResult,
22
+ packagedMcpDir,
22
23
  parseBrightsyCliLine,
23
24
  parseSessionQuotaResetAt,
24
25
  partsToAssistantText,
@@ -31,13 +32,13 @@ import {
31
32
  summarizeTurnStderr,
32
33
  toolDescription,
33
34
  turnFailChatText
34
- } from "./chunk-23KCPND2.js";
35
+ } from "./chunk-CG25RYQQ.js";
35
36
  import {
36
37
  addWorkspace,
37
38
  ensureWorkspace,
38
39
  removeWorkspace,
39
40
  syncWorkspacesFromThreads
40
- } from "./chunk-HLIHBGVO.js";
41
+ } from "./chunk-4D4PEBGB.js";
41
42
  import {
42
43
  extractPresentedPlan,
43
44
  readPlanFile,
@@ -62,14 +63,14 @@ import {
62
63
  persistPendingFileAttachments,
63
64
  stageAbsolutePathsAsAttachments,
64
65
  stageBuffersAsAttachments
65
- } from "./chunk-5XH5M6RA.js";
66
+ } from "./chunk-FADNFPZO.js";
66
67
  import {
67
68
  SLACK_REPLY_FORMATTING,
68
69
  coordinatorSystemPrompt,
69
70
  coordinatorTurnReminder,
70
71
  enrichWorkspacesWithGithub,
71
72
  ensureGlobalCoordinatorCwd
72
- } from "./chunk-RTX3AY42.js";
73
+ } from "./chunk-OHWN4JEL.js";
73
74
  import {
74
75
  addPrStackLayer,
75
76
  allocateTeamName,
@@ -114,7 +115,7 @@ import {
114
115
  withRepoGitLock,
115
116
  worktreeDisplayLabelForGroup,
116
117
  worktreeNameFromPath
117
- } from "./chunk-DJJ3DTT4.js";
118
+ } from "./chunk-4Q45TLZ5.js";
118
119
  import {
119
120
  ATTACHMENTS_DIR,
120
121
  LEGACY_ATTACHMENTS_DIR
@@ -154,7 +155,7 @@ import {
154
155
  stripNestedElectronEnv,
155
156
  updateAdvancedSettings,
156
157
  writeSecureJson
157
- } from "./chunk-GKKHXZCT.js";
158
+ } from "./chunk-BGQBELGJ.js";
158
159
  import {
159
160
  writePrivateFile
160
161
  } from "./chunk-NSTQ6QKD.js";
@@ -278,7 +279,7 @@ function slackTokenFor(ws, kind = "read") {
278
279
  const token2 = ws.user_token?.trim();
279
280
  if (!token2) {
280
281
  throw new Error(
281
- `Slack search needs a user token for ${ws.team_name}. Reconnect via Account \u2192 Slack (browser) or paste an xoxp- token.`
282
+ `Slack search needs a user token for ${ws.team_name}. Reconnect via Settings \u2192 Remote \u2192 Slack (browser) or paste an xoxp- token.`
282
283
  );
283
284
  }
284
285
  return token2;
@@ -293,7 +294,7 @@ function requireSlackWorkspace(teamId) {
293
294
  const ws = getSlackWorkspace(teamId);
294
295
  if (!ws) {
295
296
  const connected = listSlackWorkspaces();
296
- const hint = connected.length === 0 ? "Connect a workspace in Account \u2192 Slack workspaces." : `Connected: ${connected.map((t) => `${t.team_name} (${t.team_id})`).join(", ")}`;
297
+ const hint = connected.length === 0 ? "Connect a workspace in Settings \u2192 Remote \u2192 Slack." : `Connected: ${connected.map((t) => `${t.team_name} (${t.team_id})`).join(", ")}`;
297
298
  throw new Error(`Unknown Slack team_id "${teamId}". ${hint}`);
298
299
  }
299
300
  return ws;
@@ -387,7 +388,7 @@ async function continueSourceThread(threadId, prompt) {
387
388
  await continueOnReply(threadId, prompt);
388
389
  return;
389
390
  }
390
- const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-ZCMYSDTC.js");
391
+ const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-TDJZKQPT.js");
391
392
  await getOrchestrator2().send(threadId, prompt);
392
393
  } catch {
393
394
  }
@@ -647,7 +648,7 @@ async function pollSlackOutboundWatches(opts) {
647
648
  }
648
649
 
649
650
  // src/orchestrator/orchestrator.ts
650
- import { existsSync as existsSync15 } from "fs";
651
+ import { existsSync as existsSync16 } from "fs";
651
652
 
652
653
  // src/agents/spawn.ts
653
654
  import { createInterface } from "readline";
@@ -728,9 +729,9 @@ async function spawnAgentTurn(thread, input, onEvent) {
728
729
  `Cannot spawn ${thread.agent}: thread ${thread.id} has no worktreePath`
729
730
  );
730
731
  }
731
- const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-VIU57E3Y.js");
732
+ const { isGlobalThread: isGlobalThread2 } = await import("./global-workspace-OCV77UYF.js");
732
733
  if (isGlobalThread2(thread)) {
733
- const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-4TXU6Q3R.js");
734
+ const { ensureGlobalCoordinatorCwd: ensureGlobalCoordinatorCwd2 } = await import("./coordinator-prompt-FBX7Y4EM.js");
734
735
  ensureGlobalCoordinatorCwd2(
735
736
  isOrchestratorThread(thread) ? { orchestratorThreadId: thread.id } : void 0
736
737
  );
@@ -1232,6 +1233,66 @@ function buildSessionSeed(messages, opts) {
1232
1233
  "Continue from this context. Do not repeat the summary unless asked."
1233
1234
  ].join("\n");
1234
1235
  }
1236
+ var BRIGHTSY_SUMMARIZE_CONTEXT_TOOL = "summarize_context";
1237
+ function extractBrightsyContextSummary(result) {
1238
+ if (!result?.trim()) return null;
1239
+ const trimmed = result.trim();
1240
+ const lower = trimmed.toLowerCase();
1241
+ if (lower.startsWith("context summarization failed") || lower.startsWith("nothing to summarize") || lower.startsWith("no messages found") || lower.startsWith("messages are required") || lower.startsWith("agent id is required")) {
1242
+ return null;
1243
+ }
1244
+ try {
1245
+ const parsed = JSON.parse(trimmed);
1246
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
1247
+ if (parsed.error != null && typeof parsed.context_summary !== "string") {
1248
+ return null;
1249
+ }
1250
+ if (typeof parsed.context_summary === "string" && parsed.context_summary.trim()) {
1251
+ return parsed.context_summary.trim();
1252
+ }
1253
+ return null;
1254
+ }
1255
+ } catch {
1256
+ }
1257
+ if (trimmed.includes('"error"') && !trimmed.includes("context_summary")) {
1258
+ return null;
1259
+ }
1260
+ return trimmed;
1261
+ }
1262
+ function findLastBrightsyContextSummary(messages) {
1263
+ for (let i = messages.length - 1; i >= 0; i--) {
1264
+ const message = messages[i];
1265
+ if (message?.role !== "agent") continue;
1266
+ for (const part of message.parts ?? []) {
1267
+ if (part.type !== "tool" || part.name !== BRIGHTSY_SUMMARIZE_CONTEXT_TOOL) {
1268
+ continue;
1269
+ }
1270
+ if (part.status === "error") continue;
1271
+ const text = extractBrightsyContextSummary(part.result);
1272
+ if (text) return { index: i, text };
1273
+ }
1274
+ }
1275
+ return null;
1276
+ }
1277
+ function buildBrightsySessionSeed(messages) {
1278
+ const match = findLastBrightsyContextSummary(messages);
1279
+ const tail = match ? messages.slice(match.index + 1) : messages;
1280
+ const body = formatMessagesAsTranscript(tail, { tools: "none" });
1281
+ if (!match && !body.trim()) return null;
1282
+ const blocks = [
1283
+ "Sideboard conversation context (restored after compaction or a new session):",
1284
+ ""
1285
+ ];
1286
+ if (match) {
1287
+ blocks.push(`## Prior summary
1288
+ ${match.text}`, "");
1289
+ }
1290
+ if (body.trim()) {
1291
+ blocks.push(body, "");
1292
+ }
1293
+ blocks.push("Continue from this context. Do not repeat the summary unless asked.");
1294
+ return blocks.join("\n");
1295
+ }
1235
1296
  function applyCompaction(messages, summaryText, thresholds = {}) {
1236
1297
  const { older, recent } = splitForCompaction(messages, thresholds);
1237
1298
  if (older.length === 0) return messages;
@@ -2810,7 +2871,7 @@ async function createThread(input, _onSetupLine) {
2810
2871
  });
2811
2872
  await requireAgent(resolved.agent);
2812
2873
  if (input.cowboy) {
2813
- const { cowboyModeEnabled } = await import("./app-settings-YQ7YX2CC.js");
2874
+ const { cowboyModeEnabled } = await import("./app-settings-ZCN632OJ.js");
2814
2875
  if (!cowboyModeEnabled()) {
2815
2876
  throw new Error(
2816
2877
  "Cowboy mode is off. Enable it in Settings \u2192 Advanced."
@@ -2866,7 +2927,7 @@ async function createThread(input, _onSetupLine) {
2866
2927
  let sourceIsFork = false;
2867
2928
  if (!input.cowboy && sourceType === "branch" && (!sourceRef || sourceRef === "HEAD" || sourceRef === "default")) {
2868
2929
  if (isAbleTimeConnected() && getIssueSource() === "abletime") {
2869
- const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-VTP4JR63.js");
2930
+ const { ensureAbleTimeTask, issueAttachmentForAbleTimeTask } = await import("./abletime-DI55AJX3.js");
2870
2931
  const task = await ensureAbleTimeTask({
2871
2932
  title: title?.trim() || "Untitled work",
2872
2933
  description: input.prompt?.trim() || void 0
@@ -2939,7 +3000,7 @@ async function createThread(input, _onSetupLine) {
2939
3000
  return readThread(thread.id) ?? thread;
2940
3001
  }
2941
3002
  async function listLinearIssues(agent, repoPath) {
2942
- const { getAdapter: getAdapter2 } = await import("./agents-OC3XM7UE.js");
3003
+ const { getAdapter: getAdapter2 } = await import("./agents-OEEOIKUB.js");
2943
3004
  await requireAgent(agent, { requireLinear: true });
2944
3005
  const adapter = getAdapter2(agent);
2945
3006
  if (!adapter.listLinearIssues) {
@@ -3336,7 +3397,7 @@ async function adoptThread(input) {
3336
3397
  messages: input.messages ?? []
3337
3398
  });
3338
3399
  writeThread(thread);
3339
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-4HYGNH4B.js");
3400
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-4FUQW5LD.js");
3340
3401
  await ensureWorkspace2(repoPath);
3341
3402
  return thread;
3342
3403
  }
@@ -4666,6 +4727,93 @@ async function confirmLand(thread, opts) {
4666
4727
  import { existsSync as existsSync12, readdirSync as readdirSync4, readFileSync as readFileSync9, statSync as statSync3 } from "fs";
4667
4728
  import { homedir } from "os";
4668
4729
  import { join as join11 } from "path";
4730
+
4731
+ // src/skills/bundled/long-running.ts
4732
+ var LONG_RUNNING_SKILL_COMMAND = "long-running";
4733
+ var LONG_RUNNING_SKILL_NAME = "long-running";
4734
+ var BUNDLED_LONG_RUNNING_PATH = "bundled:long-running";
4735
+ var LONG_RUNNING_SKILL_DESCRIPTION = "Detach and wait on any long worktree job (pack, test, deploy) so a new chat turn does not SIGTERM it, and the human does not have to poll. Use when a command may run more than ~30s, or the user mentions wait / status / aborted builds.";
4736
+ var LONG_RUNNING_SKILL_BODY = `# Long-running jobs
4737
+
4738
+ A Sideboard or Cursor **worktree turn** SIGTERMs the agent shell (and its process group) when the user sends another message or the turn is interrupted. \`block_until_ms: 0\` is not enough \u2014 the child stays in that group.
4739
+
4740
+ Do **not** ask the human to check back. Detach, then **wait** in 45s slices (same idea as MCP \`wait_for_turn\`) until \`stillRunning\` is false.
4741
+
4742
+ ## Tool
4743
+
4744
+ Use the helper from the Sideboard playbook \u2014 an absolute \`node "\u2026" start\` path injected each turn. If this worktree has \`scripts/detached-job.js\`, that is the same tool.
4745
+
4746
+ \`\`\`bash
4747
+ # Start (exits in ~1s; job survives this turn)
4748
+ node <detached-job.js> start <id> -- <command> [args...]
4749
+
4750
+ # Wait \u2014 returns within ~45s even if the job is still going
4751
+ node <detached-job.js> wait <id>
4752
+
4753
+ # Block until the process exits (humans / a turn that will not be interrupted)
4754
+ node <detached-job.js> wait <id> --until-done
4755
+
4756
+ node <detached-job.js> status <id>
4757
+ \`\`\`
4758
+
4759
+ \`<id>\` is kebab-case (\`mac-release\`, \`core-test\`, \`fly-deploy\`). State is \`.sideboard/detached-jobs/<id>/\` (local scratch).
4760
+
4761
+ Wait JSON:
4762
+
4763
+ - \`stillRunning: true\` \u2192 exit 2 \u2192 **call wait again**. Progress is in \`progress\` / \`phase\`. Do not start a second job. Do not ping the user.
4764
+ - \`ok: true\` \u2192 exit 0 \u2192 continue the rest of the task.
4765
+ - \`failed: true\` \u2192 exit 1 \u2192 read \`progress\`, fix, start **once**.
4766
+
4767
+ ## Sideboard UI (append-only log)
4768
+
4769
+ The side column **is** the live view. Use \`present_artifact\` **\`type=log\`** with a stable \`artifact_id\` (the job id). Each call **appends** \u2014 send only \`delta\` from wait JSON, not the full log and not HTML.
4770
+
4771
+ \`\`\`
4772
+ present_artifact
4773
+ title: <short title>
4774
+ type: log
4775
+ artifact_id: <id>
4776
+ content: <wait.delta> # new lines only; empty is ok
4777
+ status: running | ok | failed # from wait.status
4778
+ phase: <wait.phase>
4779
+ \`\`\`
4780
+
4781
+ After **start**, present once (\`status=running\`, empty or first lines). After **every wait**, present the same id with \`content=delta\`. Do **not** dump the log in chat. Do **not** also fence HTML.
4782
+
4783
+ Ad-hoc pid/log (legacy or another tool\u2019s files):
4784
+
4785
+ \`\`\`bash
4786
+ node <detached-job.js> wait --pid-file FILE --log-file FILE [--ok-pattern TEXT]
4787
+ \`\`\`
4788
+
4789
+ ## Agent loop
4790
+
4791
+ 1. \`start\` once. If JSON says \`already-running\`, do not start again.
4792
+ 2. Immediately \`present_artifact\` \`type=log\` (same \`artifact_id\`, \`status=running\`) \u2014 the human should see **working** in the side column, not a \u201Ccheck back later\u201D message.
4793
+ 3. Loop \`wait\` (use \`--timeout-ms 15000\` for a livelier pane). After each slice, \`present_artifact\` the same id with \`content=delta\` only.
4794
+ 4. On \`ok\`, present once more (\`status=ok\`, last \`delta\`) and finish the task. On \`failed\`, fix from the log.
4795
+
4796
+ Never tell the user \u201Csay status when it\u2019s done.\u201D You wait.
4797
+ `;
4798
+
4799
+ // src/skills/discover.ts
4800
+ var BUNDLED_SKILL_PREFIX = "bundled:";
4801
+ function bundledSkills() {
4802
+ return [
4803
+ {
4804
+ id: BUNDLED_LONG_RUNNING_PATH,
4805
+ name: LONG_RUNNING_SKILL_NAME,
4806
+ command: LONG_RUNNING_SKILL_COMMAND,
4807
+ description: LONG_RUNNING_SKILL_DESCRIPTION.slice(0, 240),
4808
+ path: BUNDLED_LONG_RUNNING_PATH,
4809
+ source: "bundled"
4810
+ }
4811
+ ];
4812
+ }
4813
+ function bundledSkillBody(id) {
4814
+ if (id === LONG_RUNNING_SKILL_COMMAND) return LONG_RUNNING_SKILL_BODY;
4815
+ return null;
4816
+ }
4669
4817
  function toCommand(name) {
4670
4818
  return name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
4671
4819
  }
@@ -4783,7 +4931,13 @@ function discoverSkills(worktreePath) {
4783
4931
  scanSkillsDir(abs, "user", collected);
4784
4932
  }
4785
4933
  scanClaudePluginSkills(join11(home, ".claude/plugins"), collected);
4786
- const rank = { workspace: 0, user: 1, cli: 2 };
4934
+ collected.push(...bundledSkills());
4935
+ const rank = {
4936
+ workspace: 0,
4937
+ user: 1,
4938
+ cli: 2,
4939
+ bundled: 3
4940
+ };
4787
4941
  const byCommand = /* @__PURE__ */ new Map();
4788
4942
  for (const skill of collected) {
4789
4943
  const prev = byCommand.get(skill.command);
@@ -4794,6 +4948,14 @@ function discoverSkills(worktreePath) {
4794
4948
  return [...byCommand.values()].sort((a, b) => a.command.localeCompare(b.command));
4795
4949
  }
4796
4950
  function readSkillBody(skillPath, maxChars = 12e3) {
4951
+ if (skillPath.startsWith(BUNDLED_SKILL_PREFIX)) {
4952
+ const body = bundledSkillBody(skillPath.slice(BUNDLED_SKILL_PREFIX.length));
4953
+ if (body) {
4954
+ return body.length > maxChars ? `${body.slice(0, maxChars)}
4955
+
4956
+ \u2026(truncated)` : body;
4957
+ }
4958
+ }
4797
4959
  const raw = readFileSync9(skillPath, "utf8");
4798
4960
  if (raw.startsWith("---")) {
4799
4961
  const end = raw.indexOf("\n---", 3);
@@ -4887,8 +5049,39 @@ function expandComposerPrompt(worktreePath, prompt, opts) {
4887
5049
  }
4888
5050
 
4889
5051
  // src/agents/instructions.ts
4890
- import { existsSync as existsSync13, readFileSync as readFileSync10, statSync as statSync4 } from "fs";
4891
- import { join as join12 } from "path";
5052
+ import { existsSync as existsSync14, readFileSync as readFileSync10, statSync as statSync4 } from "fs";
5053
+ import { join as join13 } from "path";
5054
+
5055
+ // src/skills/detached-job-path.ts
5056
+ import { existsSync as existsSync13 } from "fs";
5057
+ import { dirname as dirname4, join as join12 } from "path";
5058
+ import { fileURLToPath } from "url";
5059
+ function packagedDetachedJobPath() {
5060
+ const dir = packagedMcpDir();
5061
+ if (!dir) return null;
5062
+ const script = join12(dir, "scripts", "detached-job.js");
5063
+ return existsSync13(script) ? script : null;
5064
+ }
5065
+ function resolveDetachedJobScript() {
5066
+ const packaged = packagedDetachedJobPath();
5067
+ if (packaged) return packaged;
5068
+ let dir = dirname4(fileURLToPath(import.meta.url));
5069
+ for (let i = 0; i < 8; i++) {
5070
+ const candidate = join12(dir, "scripts", "detached-job.js");
5071
+ if (existsSync13(candidate)) return candidate;
5072
+ const parent = dirname4(dir);
5073
+ if (parent === dir) break;
5074
+ dir = parent;
5075
+ }
5076
+ return null;
5077
+ }
5078
+ function formatDetachedJobInvoke(scriptPath) {
5079
+ const resolved = scriptPath === void 0 ? resolveDetachedJobScript() : scriptPath;
5080
+ if (resolved) return `node ${JSON.stringify(resolved)}`;
5081
+ return "node scripts/detached-job.js";
5082
+ }
5083
+
5084
+ // src/agents/instructions.ts
4892
5085
  function normPath(p) {
4893
5086
  return p.replace(/\/+$/, "");
4894
5087
  }
@@ -4996,6 +5189,7 @@ function formatWorktreeReminder() {
4996
5189
  function formatProcessGuideDirective() {
4997
5190
  return [
4998
5191
  "Process guides (recurring work only):",
5192
+ "- Long jobs (pack, test, deploy, anything that may run more than ~30s): Sideboard always provides `/long-running`. Detach and wait \u2014 do not ask the human to poll.",
4999
5193
  "- If `.claude/skills/graph-engineering/SKILL.md` exists, follow it (`/graph-engineering`) for migrations, ports, batch fixes, and other fan-out. Judge first; state on disk; grow the rulebook; do not patch around it.",
5000
5194
  "- If this same shape of work will happen again, write `.claude/skills/<kebab-name>/SKILL.md` in this worktree (Claude Code project skill). Sideboard `/name`, Claude Code, and `attach` all load that path. Do not leave the method only in chat.",
5001
5195
  "- Merge-readiness notes: create or edit `.claude/skills/review/SKILL.md` and commit it. That file is allowed. Do not use `.sideboard/review.md` for new notes (legacy; setup copies it into the skill).",
@@ -5003,6 +5197,23 @@ function formatProcessGuideDirective() {
5003
5197
  "- Skip a guide for a one-off. If a matching skill exists, follow it. Same miss twice \u2192 edit the skill, do not patch around it."
5004
5198
  ].join("\n");
5005
5199
  }
5200
+ function formatLongRunningDirective(opts) {
5201
+ const invoke = formatDetachedJobInvoke(opts?.scriptPath);
5202
+ return [
5203
+ "Long-running jobs (mandatory when a command may run more than ~30s):",
5204
+ "A Sideboard worktree turn SIGTERMs the agent shell (and its process group) when the user sends another message or the turn is interrupted. `block_until_ms: 0` is not enough. Do not ask the human to poll.",
5205
+ `Helper (same tool as \`scripts/detached-job.js\` when that file exists in the worktree): \`${invoke}\``,
5206
+ `- Start once: \`${invoke} start <id> -- <command> [args...]\` (cwd = this worktree). If JSON says already-running, do not start again.`,
5207
+ "- Immediately `present_artifact` `type=log` with `artifact_id=<id>` and `status=running` \u2014 the side column is the live view.",
5208
+ `- Loop \`${invoke} wait <id>\` (returns in ~45s). stillRunning \u2192 present the same id with \`content=delta\` only \u2192 wait again. Do not resend the full log or HTML.`,
5209
+ "- ok \u2192 finish the task. failed \u2192 read the log, fix, start once.",
5210
+ "State: `.sideboard/detached-jobs/<id>/` (local scratch). Full guide: `/long-running` (always available)."
5211
+ ].join("\n");
5212
+ }
5213
+ function formatLongRunningReminder(opts) {
5214
+ const invoke = formatDetachedJobInvoke(opts?.scriptPath);
5215
+ return `Long jobs: \`${invoke} start <id> -- <cmd>\`, loop wait, present_artifact type=log (delta). Do not ask the human to poll.`;
5216
+ }
5006
5217
  function formatArtifactDirective() {
5007
5218
  return [
5008
5219
  "Sideboard side column (desktop UI):",
@@ -5032,6 +5243,91 @@ function formatUiReminder() {
5032
5243
  return "Sideboard UI: markdown table is enough to read data; present_schema if they ask to edit/filter (even after markdown); present_files for the file manager. html fence or present_artifact, not both for the same document. type=log appends (same artifact_id, new lines only). ask_user only for a real multiple-choice (not hellos or \u201Cwhat next?\u201D) \u2014 reply in chat. Do not say artifacts/CMS UI are unavailable.";
5033
5244
  }
5034
5245
 
5246
+ // src/integrations/optional-services.ts
5247
+ var OPTIONAL_SERVICES = [
5248
+ {
5249
+ id: "vercel",
5250
+ label: "Vercel",
5251
+ hint: "Deploys and project settings. Agents use the `vercel` CLI (`VERCEL_TOKEN`).",
5252
+ tokenPlaceholder: "token from vercel.com/account/tokens",
5253
+ tokenDocs: "https://vercel.com/account/tokens",
5254
+ envKey: "VERCEL_TOKEN",
5255
+ cli: "vercel",
5256
+ npmPackage: "vercel"
5257
+ },
5258
+ {
5259
+ id: "supabase",
5260
+ label: "Supabase",
5261
+ hint: "Database and project management. Agents use the `supabase` CLI (`SUPABASE_ACCESS_TOKEN`).",
5262
+ tokenPlaceholder: "sbp_\u2026",
5263
+ tokenDocs: "https://supabase.com/dashboard/account/tokens",
5264
+ envKey: "SUPABASE_ACCESS_TOKEN",
5265
+ cli: "supabase",
5266
+ npmPackage: "supabase"
5267
+ },
5268
+ {
5269
+ id: "posthog",
5270
+ label: "PostHog",
5271
+ hint: "Product analytics. No first-class CLI \u2014 agents use the HTTP API (`POSTHOG_PERSONAL_API_KEY`).",
5272
+ tokenPlaceholder: "phx_\u2026",
5273
+ tokenDocs: "https://app.posthog.com/settings/user-api-keys",
5274
+ envKey: "POSTHOG_PERSONAL_API_KEY",
5275
+ hostEnvKey: "POSTHOG_HOST",
5276
+ defaultHost: "https://us.posthog.com",
5277
+ hostPlaceholder: "https://us.posthog.com"
5278
+ },
5279
+ {
5280
+ id: "sentry",
5281
+ label: "Sentry",
5282
+ hint: "Error tracking. Agents use `sentry-cli` (`SENTRY_AUTH_TOKEN`).",
5283
+ tokenPlaceholder: "sntrys_\u2026 or auth token",
5284
+ tokenDocs: "https://sentry.io/settings/account/api/auth-tokens/",
5285
+ envKey: "SENTRY_AUTH_TOKEN",
5286
+ cli: "sentry-cli",
5287
+ npmPackage: "@sentry/cli",
5288
+ hostEnvKey: "SENTRY_URL",
5289
+ defaultHost: "https://sentry.io",
5290
+ hostPlaceholder: "https://sentry.io"
5291
+ }
5292
+ ];
5293
+ function optionalServiceConnected(id, integrations) {
5294
+ if (id === "vercel") return Boolean(integrations.vercelToken?.trim());
5295
+ if (id === "supabase") return Boolean(integrations.supabaseAccessToken?.trim());
5296
+ if (id === "posthog") return Boolean(integrations.posthogPersonalApiKey?.trim());
5297
+ return Boolean(integrations.sentryAuthToken?.trim());
5298
+ }
5299
+ function connectedOptionalServices(integrations) {
5300
+ return OPTIONAL_SERVICES.filter((spec) => optionalServiceConnected(spec.id, integrations));
5301
+ }
5302
+ function formatOptionalServicesDirective(integrations) {
5303
+ const connected = connectedOptionalServices(integrations);
5304
+ if (connected.length === 0) return null;
5305
+ const lines = [
5306
+ "Optional connectors (connected \u2014 tokens are already in this process env):"
5307
+ ];
5308
+ for (const spec of connected) {
5309
+ if (spec.cli) {
5310
+ const extras = spec.hostEnvKey ? ` / \`${spec.hostEnvKey}\`` : "";
5311
+ lines.push(
5312
+ `- ${spec.label}: use the \`${spec.cli}\` CLI (\`${spec.envKey}\`${extras}). Do not add a ${spec.label} MCP.`
5313
+ );
5314
+ } else {
5315
+ const extras = spec.hostEnvKey ? ` / \`${spec.hostEnvKey}\`` : "";
5316
+ lines.push(
5317
+ `- ${spec.label}: no first-class CLI \u2014 call the HTTP API with \`${spec.envKey}\`${extras}. Do not add a ${spec.label} MCP.`
5318
+ );
5319
+ }
5320
+ }
5321
+ lines.push(
5322
+ "If a CLI is missing, say so or use the HTTP API with the same token. The user can Install CLI from Settings \u2192 Connectors. Do not ask the user to install a vendor MCP."
5323
+ );
5324
+ return lines.join("\n");
5325
+ }
5326
+ function formatOptionalServicesReminder(integrations) {
5327
+ if (connectedOptionalServices(integrations).length === 0) return null;
5328
+ return "Settings \u2192 Connectors: prefer official CLIs (`vercel`, `supabase`, `sentry-cli`) or the PostHog HTTP API with injected env. Do not add vendor MCPs.";
5329
+ }
5330
+
5035
5331
  // src/threads/sync-branch.ts
5036
5332
  async function syncThreadBranchFromGit(threadId) {
5037
5333
  const thread = readThread(threadId);
@@ -5064,8 +5360,8 @@ async function syncThreadBranchFromGit(threadId) {
5064
5360
 
5065
5361
  // src/store/schedules.ts
5066
5362
  import { randomUUID as randomUUID4 } from "crypto";
5067
- import { existsSync as existsSync14, readFileSync as readFileSync11 } from "fs";
5068
- import { join as join13 } from "path";
5363
+ import { existsSync as existsSync15, readFileSync as readFileSync11 } from "fs";
5364
+ import { join as join14 } from "path";
5069
5365
  import { Cron } from "croner";
5070
5366
  var DURATION_RE = /^(\d+)(s|m|h|d)$/i;
5071
5367
  var UNIT_MS = {
@@ -5075,7 +5371,7 @@ var UNIT_MS = {
5075
5371
  d: 864e5
5076
5372
  };
5077
5373
  function schedulesPath() {
5078
- return join13(appDataDir(), "schedules.json");
5374
+ return join14(appDataDir(), "schedules.json");
5079
5375
  }
5080
5376
  function parseDurationMs(every) {
5081
5377
  const m = every.trim().match(DURATION_RE);
@@ -5175,7 +5471,7 @@ function normalizeTask(raw) {
5175
5471
  }
5176
5472
  function readAll() {
5177
5473
  const path = schedulesPath();
5178
- if (!existsSync14(path)) return [];
5474
+ if (!existsSync15(path)) return [];
5179
5475
  try {
5180
5476
  const parsed = JSON.parse(readFileSync11(path, "utf8"));
5181
5477
  if (!Array.isArray(parsed)) return [];
@@ -5300,7 +5596,7 @@ function formatScheduledPrompt(name, prompt) {
5300
5596
  ${prompt}`;
5301
5597
  }
5302
5598
  async function defaultDeps() {
5303
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-ZCMYSDTC.js");
5599
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-TDJZKQPT.js");
5304
5600
  const orch = getOrchestrator2();
5305
5601
  return {
5306
5602
  findThread: (id) => findThreadByRef(id),
@@ -5506,7 +5802,7 @@ var Orchestrator = class {
5506
5802
  }
5507
5803
  continue;
5508
5804
  }
5509
- if (!existsSync15(thread.worktreePath)) {
5805
+ if (!existsSync16(thread.worktreePath)) {
5510
5806
  setStatus(thread.id, "broken", "Worktree missing on disk");
5511
5807
  this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
5512
5808
  continue;
@@ -5525,7 +5821,7 @@ var Orchestrator = class {
5525
5821
  orphans: orphans.map((o) => ({ path: o.path, repoPath: o.repoPath }))
5526
5822
  });
5527
5823
  }
5528
- const { autoCleanupOrphansEnabled } = await import("./app-settings-YQ7YX2CC.js");
5824
+ const { autoCleanupOrphansEnabled } = await import("./app-settings-ZCN632OJ.js");
5529
5825
  if (autoCleanupOrphansEnabled() && shouldRunWorktreeCleanup() && orphans.length > 0) {
5530
5826
  await cleanupOrphanWorktrees({ repoPaths });
5531
5827
  }
@@ -5765,7 +6061,7 @@ var Orchestrator = class {
5765
6061
  }
5766
6062
  await setup;
5767
6063
  if (skipSetup) return;
5768
- const { autoRunAfterSetupEnabled } = await import("./app-settings-YQ7YX2CC.js");
6064
+ const { autoRunAfterSetupEnabled } = await import("./app-settings-ZCN632OJ.js");
5769
6065
  if (autoRunAfterSetupEnabled()) {
5770
6066
  try {
5771
6067
  await this.startDev(threadId);
@@ -6027,7 +6323,9 @@ var Orchestrator = class {
6027
6323
  ].join("\n") : null
6028
6324
  ].filter(Boolean).join("\n") : null;
6029
6325
  const artifactReminder = thread.agent !== "brightsy" ? formatUiReminder() : null;
6326
+ const longRunningReminder = thread.agent !== "brightsy" && !isOrchestratorThread(thread) ? formatLongRunningReminder() : null;
6030
6327
  const worktreeReminder = thread.agent !== "brightsy" && !isOrchestratorThread(thread) ? formatWorktreeReminder() : null;
6328
+ const optionalServicesReminder = thread.agent !== "brightsy" && !isOrchestratorThread(thread) ? formatOptionalServicesReminder(loadAppSettings().integrations) : null;
6031
6329
  const slackReplyContext = formatSlackRepliesForTurn(
6032
6330
  pendingSlackExternalReplies(thread.messages)
6033
6331
  );
@@ -6035,7 +6333,9 @@ var Orchestrator = class {
6035
6333
  thread.planMode ? PLAN_MODE_INSTRUCTION : null,
6036
6334
  orchestrationReminder,
6037
6335
  worktreeReminder,
6336
+ optionalServicesReminder,
6038
6337
  artifactReminder,
6338
+ longRunningReminder,
6039
6339
  slackReplyContext,
6040
6340
  expandedPrompt
6041
6341
  ].filter(Boolean).join("\n\n");
@@ -6055,7 +6355,7 @@ var Orchestrator = class {
6055
6355
  }
6056
6356
  const isBrightsy = fresh.agent === "brightsy";
6057
6357
  const isOrchestration = isOrchestratorThread(fresh);
6058
- const { autoRenameBranchEnabled, getGithubGitAuthMode } = await import("./app-settings-YQ7YX2CC.js");
6358
+ const { autoRenameBranchEnabled, getGithubGitAuthMode } = await import("./app-settings-ZCN632OJ.js");
6059
6359
  const gitAuthMode = getGithubGitAuthMode();
6060
6360
  const worktreeDirective = isBrightsy || isOrchestration ? null : formatWorktreeDirective(fresh, {
6061
6361
  githubSlug: await resolveGithubRepoSlug(fresh.worktreePath).catch(
@@ -6064,6 +6364,8 @@ var Orchestrator = class {
6064
6364
  gitAuthMode
6065
6365
  });
6066
6366
  const artifactDirective = isBrightsy ? null : formatArtifactDirective();
6367
+ const longRunningDirective = isBrightsy || isOrchestration ? null : formatLongRunningDirective();
6368
+ const optionalServicesDirective = isBrightsy || isOrchestration ? null : formatOptionalServicesDirective(loadAppSettings().integrations);
6067
6369
  const settings = loadWorkspaceSettings(fresh.worktreePath, fresh.repoPath);
6068
6370
  const renameBranchDirective = !isBrightsy && !isOrchestration && autoRenameBranchEnabled() ? formatRenameBranchDirective(fresh, {
6069
6371
  customPrompt: settings?.prompts?.renameBranch
@@ -6071,7 +6373,7 @@ var Orchestrator = class {
6071
6373
  let seed = null;
6072
6374
  if (!fresh.sessionId) {
6073
6375
  const prior = fresh.messages.slice(0, -1);
6074
- seed = isBrightsy ? buildSessionSeed(prior.slice(-6), { tools: "none" }) : buildSessionSeed(prior);
6376
+ seed = isBrightsy ? buildBrightsySessionSeed(prior) : buildSessionSeed(prior);
6075
6377
  }
6076
6378
  let coordinatorDirective = null;
6077
6379
  if (isOrchestration) {
@@ -6093,7 +6395,9 @@ var Orchestrator = class {
6093
6395
  const cachedPrefix = fresh.sessionId ? "" : [
6094
6396
  coordinatorDirective,
6095
6397
  worktreeDirective,
6398
+ optionalServicesDirective,
6096
6399
  artifactDirective,
6400
+ longRunningDirective,
6097
6401
  renameBranchDirective,
6098
6402
  seed
6099
6403
  ].filter(Boolean).join("\n\n---\n\n");
@@ -6196,11 +6500,13 @@ var Orchestrator = class {
6196
6500
  });
6197
6501
  const retryThread = this.requireThread(threadId);
6198
6502
  const prior = retryThread.messages.slice(0, -1);
6199
- const retrySeed = buildSessionSeed(prior);
6503
+ const retrySeed = isBrightsy ? buildBrightsySessionSeed(prior) : buildSessionSeed(prior);
6200
6504
  const retryPrefix = [
6201
6505
  coordinatorDirective,
6202
6506
  worktreeDirective,
6507
+ optionalServicesDirective,
6203
6508
  artifactDirective,
6509
+ longRunningDirective,
6204
6510
  renameBranchDirective,
6205
6511
  retrySeed
6206
6512
  ].filter(Boolean).join("\n\n---\n\n");
@@ -6877,7 +7183,7 @@ var Orchestrator = class {
6877
7183
  updateThread(thread.id, { title: meta.title });
6878
7184
  }
6879
7185
  }
6880
- const { autoArchiveOnMergeEnabled } = await import("./app-settings-YQ7YX2CC.js");
7186
+ const { autoArchiveOnMergeEnabled } = await import("./app-settings-ZCN632OJ.js");
6881
7187
  const latest = this.requireThread(thread.id);
6882
7188
  if (!shouldAutoArchiveOnPrMerge({
6883
7189
  previousPrState: prevState || null,
@@ -7187,7 +7493,7 @@ var Orchestrator = class {
7187
7493
  this.emit({ type: "status_changed", threadId: archived.id, status: "archived" });
7188
7494
  if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
7189
7495
  try {
7190
- const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-4HYGNH4B.js");
7496
+ const { ensureWorkspace: ensureWorkspace2 } = await import("./workspaces-4FUQW5LD.js");
7191
7497
  await ensureWorkspace2(thread.repoPath);
7192
7498
  } catch {
7193
7499
  }
@@ -7214,7 +7520,7 @@ var Orchestrator = class {
7214
7520
  await runArchiveScript(thread.repoPath, thread.worktreePath);
7215
7521
  } catch {
7216
7522
  }
7217
- const { deleteBranchOnPurgeEnabled } = await import("./app-settings-YQ7YX2CC.js");
7523
+ const { deleteBranchOnPurgeEnabled } = await import("./app-settings-ZCN632OJ.js");
7218
7524
  const deleteBranch = opts?.deleteBranch ?? deleteBranchOnPurgeEnabled();
7219
7525
  await removeWorktree(thread.repoPath, thread.worktreePath, {
7220
7526
  deleteBranch: deleteBranch ? thread.branchName : void 0
@@ -7235,13 +7541,13 @@ var Orchestrator = class {
7235
7541
  this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
7236
7542
  return restored2;
7237
7543
  }
7238
- if (!existsSync15(thread.worktreePath)) {
7544
+ if (!existsSync16(thread.worktreePath)) {
7239
7545
  if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
7240
7546
  throw new Error(
7241
7547
  `Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
7242
7548
  );
7243
7549
  }
7244
- const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-NSNZODAM.js");
7550
+ const { createThreadWorktree: createThreadWorktree2 } = await import("./worktree-Z22HTSCU.js");
7245
7551
  const slug = thread.worktreePath.split("/").pop();
7246
7552
  const dest = thread.worktreePath;
7247
7553
  await withRepoGitLock(thread.repoPath, async () => {
@@ -7349,7 +7655,7 @@ async function startOrchestration(opts) {
7349
7655
  sourceRef: "default",
7350
7656
  ...createOpts
7351
7657
  }).catch(async () => {
7352
- const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-NSNZODAM.js");
7658
+ const { resolveDefaultBranch: resolveDefaultBranch2, resolveRepoRoot: resolveRepoRoot2 } = await import("./worktree-Z22HTSCU.js");
7353
7659
  const repo = await resolveRepoRoot2(repoPath);
7354
7660
  const def = await resolveDefaultBranch2(repo);
7355
7661
  return orch.createThread({
File without changes
File without changes