@sideboard-ai/core 0.1.343 → 0.1.345

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 (48) hide show
  1. package/dist/{abletime-ZIYFR4SI.js → abletime-X2TJ6PPK.js} +4 -4
  2. package/dist/{abletime-oauth-IQZ3LOB2.js → abletime-oauth-DEIENLHC.js} +3 -3
  3. package/dist/{abletime-rest-7YAO5B74.js → abletime-rest-HWBUPI4R.js} +3 -3
  4. package/dist/{agents-LNZ465IM.js → agents-7CHZO3K3.js} +2 -2
  5. package/dist/{agents-7DCNOMFP.js → agents-AQM7NLXD.js} +7 -7
  6. package/dist/{app-settings-FS7TM55D.js → app-settings-A6JUT2SF.js} +1 -1
  7. package/dist/{chunk-TKEYXNXY.js → chunk-4PHOJMZI.js} +15 -0
  8. package/dist/{chunk-A4ZI7SA3.js → chunk-4SNEW63T.js} +3 -3
  9. package/dist/{chunk-2BLJ726H.js → chunk-4YGVJRXY.js} +4 -3
  10. package/dist/{chunk-KCZM7WZ3.js → chunk-5IMXA563.js} +10 -10
  11. package/dist/{chunk-O2IRQAFB.js → chunk-AG2RM3DF.js} +3 -3
  12. package/dist/{chunk-DEQLDEYR.js → chunk-BD7KUYJA.js} +2 -2
  13. package/dist/{chunk-SLLTEMIL.js → chunk-FNAP6CCS.js} +2 -2
  14. package/dist/{chunk-6RO2AOE5.js → chunk-GHKJBZW5.js} +2 -2
  15. package/dist/{chunk-NGIGRAZB.js → chunk-IYX53WZY.js} +5 -5
  16. package/dist/{chunk-5BFEHSHO.js → chunk-J3BQHHDZ.js} +1 -0
  17. package/dist/{chunk-EDEYEYU6.js → chunk-JZKNRDKF.js} +24 -24
  18. package/dist/{chunk-4TTTEKNV.js → chunk-MB3GOWB3.js} +2 -2
  19. package/dist/{chunk-LDJT3TLN.js → chunk-MHRU743Z.js} +7 -7
  20. package/dist/{chunk-GUIJMZQG.js → chunk-NQHEEGTH.js} +1 -1
  21. package/dist/{chunk-D7US5R4H.js → chunk-O5WRVQFT.js} +1 -1
  22. package/dist/{chunk-JX3OWNOT.js → chunk-QTDCPMOW.js} +1 -1
  23. package/dist/{chunk-4HELMBYR.js → chunk-TD76ORBJ.js} +2 -2
  24. package/dist/{chunk-S3DTEGMK.js → chunk-TW63CYUA.js} +2 -2
  25. package/dist/{chunk-WO7VF4FG.js → chunk-YFPSTG52.js} +5 -5
  26. package/dist/{chunk-G3UV3GXJ.js → chunk-Z54FI4VL.js} +2 -2
  27. package/dist/{conductor-4SWJM5FS.js → conductor-3A2TNWUW.js} +2 -2
  28. package/dist/{conductor-Q433HU77.js → conductor-DUHRZUQY.js} +5 -5
  29. package/dist/{coordinator-prompt-Z7PPP45X.js → coordinator-prompt-7QALNDIV.js} +1 -1
  30. package/dist/{coordinator-prompt-5QHWCO7V.js → coordinator-prompt-OX6A4MDA.js} +4 -4
  31. package/dist/{global-workspace-VDCZMFCZ.js → global-workspace-6GGS3DWU.js} +4 -4
  32. package/dist/{global-workspace-DL4K4K7O.js → global-workspace-HM2RKBCT.js} +1 -1
  33. package/dist/index.cjs +230 -1
  34. package/dist/index.d.cts +33 -0
  35. package/dist/index.d.ts +33 -0
  36. package/dist/index.js +230 -21
  37. package/dist/{linear-UXMDJAD4.js → linear-WYI64BMX.js} +2 -2
  38. package/dist/{linear-list-KDLU7QWX.js → linear-list-CGUCPWTV.js} +1 -1
  39. package/dist/mcp/run-stdio.cjs +2 -1
  40. package/dist/mcp/run-stdio.js +4 -4
  41. package/dist/{optional-cli-RUUCLNSM.js → optional-cli-YHLVTVRK.js} +4 -4
  42. package/dist/{orchestrator-RLFBFRAG.js → orchestrator-OWO6LQ5U.js} +4 -4
  43. package/dist/{orchestrator-Y5JCAJGV.js → orchestrator-POMFVZLB.js} +10 -10
  44. package/dist/{thread-store-ILM2ZJCB.js → thread-store-V5IDUJ4L.js} +2 -2
  45. package/dist/{workspaces-MX4W4SSB.js → workspaces-DTMPNDPW.js} +4 -4
  46. package/dist/{workspaces-EIIHHH4S.js → workspaces-V6IIBSKA.js} +1 -1
  47. package/dist/{worktree-QBVLKACU.js → worktree-FX5FT6BI.js} +3 -3
  48. package/package.json +1 -1
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-XOEKCE6L.js";
7
7
  import {
8
8
  listAssignedLinearIssues
9
- } from "./chunk-D7US5R4H.js";
9
+ } from "./chunk-O5WRVQFT.js";
10
10
  import {
11
11
  looksLikeConversationSummary,
12
12
  looksLikeSkillBody,
@@ -15,13 +15,13 @@ import {
15
15
  } from "./chunk-BIM24I3O.js";
16
16
  import {
17
17
  isOrchestratorThread
18
- } from "./chunk-2BLJ726H.js";
18
+ } from "./chunk-4YGVJRXY.js";
19
19
  import {
20
20
  codexUnattendedGitConfigArgs,
21
21
  mergeAgentGitAuthEnv,
22
22
  resolveAgentGitAuthEnv,
23
23
  resolveCodexGitWritableRoots
24
- } from "./chunk-G3UV3GXJ.js";
24
+ } from "./chunk-Z54FI4VL.js";
25
25
  import {
26
26
  loadBrightsyConfig
27
27
  } from "./chunk-RSA47QYR.js";
@@ -80,7 +80,7 @@ import {
80
80
  requestOccupancy,
81
81
  resolveAgentExecutable,
82
82
  resolveClaudeExecutable
83
- } from "./chunk-TKEYXNXY.js";
83
+ } from "./chunk-4PHOJMZI.js";
84
84
  import {
85
85
  isElectronLikeCommand,
86
86
  unwrapStrippedElectronLaunch
@@ -2671,7 +2671,7 @@ var claudeAdapter = {
2671
2671
  );
2672
2672
  }
2673
2673
  const mode = permissionMode(thread);
2674
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-VDCZMFCZ.js");
2674
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-6GGS3DWU.js");
2675
2675
  const isOrchestrator = isOrchestratorThread2(thread);
2676
2676
  const rpc = worktreeAgentRpc(isOrchestrator);
2677
2677
  const injectedServers = await buildInjectedMcpServers({
@@ -2898,7 +2898,7 @@ var claudeAdapter = {
2898
2898
  return { file: claude, args, cwd: thread.worktreePath };
2899
2899
  },
2900
2900
  async listLinearIssues(_repoPath) {
2901
- const { listAssignedLinearIssues: listAssignedLinearIssues2 } = await import("./linear-list-KDLU7QWX.js");
2901
+ const { listAssignedLinearIssues: listAssignedLinearIssues2 } = await import("./linear-list-CGUCPWTV.js");
2902
2902
  return listAssignedLinearIssues2();
2903
2903
  }
2904
2904
  };
@@ -3989,7 +3989,7 @@ var opencodeAdapter = {
3989
3989
  };
3990
3990
  },
3991
3991
  async listLinearIssues(_repoPath) {
3992
- const { listAssignedLinearIssues: listAssignedLinearIssues2 } = await import("./linear-list-KDLU7QWX.js");
3992
+ const { listAssignedLinearIssues: listAssignedLinearIssues2 } = await import("./linear-list-CGUCPWTV.js");
3993
3993
  return listAssignedLinearIssues2();
3994
3994
  }
3995
3995
  };
@@ -16,7 +16,7 @@ import {
16
16
  disconnectLinearConnection,
17
17
  loadAppSettings,
18
18
  saveLinearOAuth
19
- } from "./chunk-TKEYXNXY.js";
19
+ } from "./chunk-4PHOJMZI.js";
20
20
 
21
21
  // src/integrations/linear-oauth.ts
22
22
  import { createHash, randomBytes } from "crypto";
@@ -2,7 +2,7 @@
2
2
  var LIST_TIMEOUT_MS = 15e3;
3
3
  async function listAssignedLinearIssues(opts) {
4
4
  try {
5
- const { listLinearIssuesDirect } = await import("./linear-UXMDJAD4.js");
5
+ const { listLinearIssuesDirect } = await import("./linear-WYI64BMX.js");
6
6
  const listed = listLinearIssuesDirect({ limit: 50 }).catch(() => []);
7
7
  let timer;
8
8
  try {
@@ -10,7 +10,7 @@ import {
10
10
  isOrchestratorCapableAgent,
11
11
  normalizeThinkingEffort,
12
12
  updateAdvancedSettings
13
- } from "./chunk-TKEYXNXY.js";
13
+ } from "./chunk-4PHOJMZI.js";
14
14
  import {
15
15
  writePrivateFile
16
16
  } from "./chunk-JT7R45JB.js";
@@ -4,14 +4,14 @@ import {
4
4
  normalizeAbleTimeCredential,
5
5
  normalizeAbleTimeHost,
6
6
  rewriteAbleTimeError
7
- } from "./chunk-WO7VF4FG.js";
7
+ } from "./chunk-YFPSTG52.js";
8
8
  import {
9
9
  httpFetch
10
10
  } from "./chunk-JAT3JFOS.js";
11
11
  import {
12
12
  getAbleTimeAccessToken,
13
13
  getAbleTimeHost
14
- } from "./chunk-TKEYXNXY.js";
14
+ } from "./chunk-4PHOJMZI.js";
15
15
 
16
16
  // src/integrations/abletime-rest.ts
17
17
  var ABLETIME_REST_PREFIX = "/api/public/v2";
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-ORO4ENZR.js";
13
13
  import {
14
14
  isOrchestratorThread
15
- } from "./chunk-5BFEHSHO.js";
15
+ } from "./chunk-J3BQHHDZ.js";
16
16
  import {
17
17
  codexUnattendedGitConfigArgs,
18
18
  mergeAgentGitAuthEnv,
@@ -2978,7 +2978,7 @@ var claudeAdapter = {
2978
2978
  );
2979
2979
  }
2980
2980
  const mode = permissionMode(thread);
2981
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-DL4K4K7O.js");
2981
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-HM2RKBCT.js");
2982
2982
  const isOrchestrator = isOrchestratorThread2(thread);
2983
2983
  const rpc = worktreeAgentRpc(isOrchestrator);
2984
2984
  const injectedServers = await buildInjectedMcpServers({
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  getAbleTimeHost,
6
6
  isAbleTimeConnected
7
- } from "./chunk-TKEYXNXY.js";
7
+ } from "./chunk-4PHOJMZI.js";
8
8
 
9
9
  // src/integrations/abletime-mcp.ts
10
10
  var DEFAULT_ABLETIME_HOST = "https://track.abletime.com";
@@ -153,7 +153,7 @@ function textsFromUnknown(value) {
153
153
  return "";
154
154
  }
155
155
  async function abletimeMcpRequest(method, params, opts) {
156
- const rawToken = opts?.token ?? await import("./abletime-oauth-IQZ3LOB2.js").then((m) => m.ensureAbleTimeAccessToken());
156
+ const rawToken = opts?.token ?? await import("./abletime-oauth-DEIENLHC.js").then((m) => m.ensureAbleTimeAccessToken());
157
157
  if (!rawToken?.trim()) {
158
158
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
159
159
  }
@@ -224,9 +224,9 @@ async function callAbleTimeTool(name, args = {}, opts) {
224
224
  if (!opts?.token && !isAbleTimeConnected()) {
225
225
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
226
226
  }
227
- const rawToken = opts?.token ?? await import("./abletime-oauth-IQZ3LOB2.js").then((m) => m.ensureAbleTimeAccessToken());
227
+ const rawToken = opts?.token ?? await import("./abletime-oauth-DEIENLHC.js").then((m) => m.ensureAbleTimeAccessToken());
228
228
  if (rawToken && ableTimeUsesRest(rawToken)) {
229
- const { callAbleTimeRestTool } = await import("./abletime-rest-7YAO5B74.js");
229
+ const { callAbleTimeRestTool } = await import("./abletime-rest-HWBUPI4R.js");
230
230
  return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
231
231
  }
232
232
  const requestOpts = { ...opts, pm: opts?.pm ?? abletimeToolUsesPm(name) };
@@ -242,7 +242,7 @@ async function callAbleTimeTool(name, args = {}, opts) {
242
242
  return await call();
243
243
  }
244
244
  if (rawToken && ableTimeUsesRest(rawToken) && isAbleTimeRejectedCredential(message)) {
245
- const { callAbleTimeRestTool } = await import("./abletime-rest-7YAO5B74.js");
245
+ const { callAbleTimeRestTool } = await import("./abletime-rest-HWBUPI4R.js");
246
246
  return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
247
247
  }
248
248
  throw err instanceof Error ? new Error(rewriteAbleTimeError(err.message)) : err;
@@ -4,7 +4,7 @@ import {
4
4
  normalizeTakenSlug,
5
5
  normalizeWorktreePath,
6
6
  takenSlugsFromThread
7
- } from "./chunk-JX3OWNOT.js";
7
+ } from "./chunk-QTDCPMOW.js";
8
8
  import {
9
9
  ensureWorktreeSideboardIgnored
10
10
  } from "./chunk-BMRJNRQK.js";
@@ -25,7 +25,7 @@ import {
25
25
  import {
26
26
  getGithubGitAuthMode,
27
27
  getGithubPat
28
- } from "./chunk-TKEYXNXY.js";
28
+ } from "./chunk-4PHOJMZI.js";
29
29
  import {
30
30
  worktreesRoot
31
31
  } from "./chunk-H4UEFJRI.js";
@@ -34,9 +34,9 @@ import {
34
34
  tryReservePort,
35
35
  tryReservePorts,
36
36
  worktreeRunPortsPath
37
- } from "./chunk-DEQLDEYR.js";
37
+ } from "./chunk-BD7KUYJA.js";
38
38
  import "./chunk-ORO4ENZR.js";
39
- import "./chunk-5BFEHSHO.js";
39
+ import "./chunk-J3BQHHDZ.js";
40
40
  import "./chunk-RTZO2YJC.js";
41
41
  import "./chunk-N2WW62LF.js";
42
42
  import "./chunk-GK7H3SY7.js";
@@ -32,11 +32,11 @@ import {
32
32
  tryReservePort,
33
33
  tryReservePorts,
34
34
  worktreeRunPortsPath
35
- } from "./chunk-NGIGRAZB.js";
35
+ } from "./chunk-IYX53WZY.js";
36
36
  import "./chunk-BIM24I3O.js";
37
- import "./chunk-2BLJ726H.js";
38
- import "./chunk-G3UV3GXJ.js";
39
- import "./chunk-JX3OWNOT.js";
37
+ import "./chunk-4YGVJRXY.js";
38
+ import "./chunk-Z54FI4VL.js";
39
+ import "./chunk-QTDCPMOW.js";
40
40
  import "./chunk-BMRJNRQK.js";
41
41
  import "./chunk-NJV5YEKI.js";
42
42
  import "./chunk-N6ZF3XRP.js";
@@ -44,7 +44,7 @@ import "./chunk-OPXEJJBM.js";
44
44
  import "./chunk-6K64FJDD.js";
45
45
  import "./chunk-LG6RJBIY.js";
46
46
  import "./chunk-R4W4VQJZ.js";
47
- import "./chunk-TKEYXNXY.js";
47
+ import "./chunk-4PHOJMZI.js";
48
48
  import {
49
49
  stripNestedElectronEnv
50
50
  } from "./chunk-4TR3HZFT.js";
@@ -9,7 +9,7 @@ import {
9
9
  enrichWorkspacesWithGithub,
10
10
  ensureGlobalCoordinatorCwd,
11
11
  formatWorkspaceInventory
12
- } from "./chunk-5BFEHSHO.js";
12
+ } from "./chunk-J3BQHHDZ.js";
13
13
  import "./chunk-RTZO2YJC.js";
14
14
  import "./chunk-N2WW62LF.js";
15
15
  import "./chunk-GK7H3SY7.js";
@@ -7,15 +7,15 @@ import {
7
7
  enrichWorkspacesWithGithub,
8
8
  ensureGlobalCoordinatorCwd,
9
9
  formatWorkspaceInventory
10
- } from "./chunk-2BLJ726H.js";
11
- import "./chunk-G3UV3GXJ.js";
12
- import "./chunk-JX3OWNOT.js";
10
+ } from "./chunk-4YGVJRXY.js";
11
+ import "./chunk-Z54FI4VL.js";
12
+ import "./chunk-QTDCPMOW.js";
13
13
  import "./chunk-BMRJNRQK.js";
14
14
  import "./chunk-N6ZF3XRP.js";
15
15
  import "./chunk-6K64FJDD.js";
16
16
  import "./chunk-LG6RJBIY.js";
17
17
  import "./chunk-R4W4VQJZ.js";
18
- import "./chunk-TKEYXNXY.js";
18
+ import "./chunk-4PHOJMZI.js";
19
19
  import "./chunk-4TR3HZFT.js";
20
20
  import "./chunk-WDRMZKVB.js";
21
21
  import "./chunk-KI45T4DI.js";
@@ -18,15 +18,15 @@ import {
18
18
  remoteCoordinatorSourceRef,
19
19
  slackCoordinatorSourceRef,
20
20
  takenTeamSlugsForOrchestration
21
- } from "./chunk-2BLJ726H.js";
22
- import "./chunk-G3UV3GXJ.js";
23
- import "./chunk-JX3OWNOT.js";
21
+ } from "./chunk-4YGVJRXY.js";
22
+ import "./chunk-Z54FI4VL.js";
23
+ import "./chunk-QTDCPMOW.js";
24
24
  import "./chunk-BMRJNRQK.js";
25
25
  import "./chunk-N6ZF3XRP.js";
26
26
  import "./chunk-6K64FJDD.js";
27
27
  import "./chunk-LG6RJBIY.js";
28
28
  import "./chunk-R4W4VQJZ.js";
29
- import "./chunk-TKEYXNXY.js";
29
+ import "./chunk-4PHOJMZI.js";
30
30
  import "./chunk-4TR3HZFT.js";
31
31
  import "./chunk-WDRMZKVB.js";
32
32
  import "./chunk-KI45T4DI.js";
@@ -20,7 +20,7 @@ import {
20
20
  remoteCoordinatorSourceRef,
21
21
  slackCoordinatorSourceRef,
22
22
  takenTeamSlugsForOrchestration
23
- } from "./chunk-5BFEHSHO.js";
23
+ } from "./chunk-J3BQHHDZ.js";
24
24
  import "./chunk-RTZO2YJC.js";
25
25
  import "./chunk-N2WW62LF.js";
26
26
  import "./chunk-GK7H3SY7.js";
package/dist/index.cjs CHANGED
@@ -1310,6 +1310,21 @@ function parseRemoteClientMessage(raw) {
1310
1310
  const sessionTokens = raw2.filter((item) => typeof item === "string" && item.trim().length > 0).map((item) => item.trim()).slice(0, 32);
1311
1311
  return { type: "list_hosts", sessionTokens };
1312
1312
  }
1313
+ if (msg.type === "push_register") {
1314
+ const token = str(parsed.token);
1315
+ if (!/^(?:Exponent|Expo)PushToken\[[A-Za-z0-9_-]{8,140}\]$/.test(token)) return null;
1316
+ const raw2 = parsed.sessionTokens;
1317
+ if (!Array.isArray(raw2)) return null;
1318
+ const sessionTokens = raw2.filter((item) => typeof item === "string" && item.trim().length > 0).map((item) => item.trim()).slice(0, 32);
1319
+ return { type: "push_register", token, sessionTokens };
1320
+ }
1321
+ if (msg.type === "push_notify") {
1322
+ const chatId = str(parsed.chatId);
1323
+ const kind = parsed.kind;
1324
+ if (!/^[A-Za-z0-9_-]{8,80}$/.test(chatId)) return null;
1325
+ if (kind !== "needs_you" && kind !== "finished" && kind !== "failed") return null;
1326
+ return { type: "push_notify", chatId, kind };
1327
+ }
1313
1328
  if (msg.type === "prompt") {
1314
1329
  const text7 = str(parsed.text);
1315
1330
  if (!text7) return null;
@@ -13358,6 +13373,7 @@ var init_coordinator_prompt = __esm({
13358
13373
  "- Recurring multi-item / fan-out: if the child worktree has `.claude/skills/graph-engineering/SKILL.md`, tell the worker to follow it (`/graph-engineering`). Judge first; state on disk; grow the rulebook; do not patch three threads.",
13359
13374
  "- Recurring shapes: have the worktree agent write `.claude/skills/<kebab-name>/SKILL.md` (commit it) so later threads and native Claude Code / attach see it. Merge-review sentences go in `.claude/skills/review/SKILL.md` when that skill already exists; otherwise `.context/review.md` (do not create a review skill). Do not use `.sideboard/skills/` (that folder only). Codex/OpenCode: one line in AGENTS.md pointing at that file.",
13360
13375
  "- One-offs: no guide. Same miss across threads: edit the existing skill or `.context/review.md`, then rerun the batch \u2014 do not patch three threads.",
13376
+ "- A miss that will recur (the worker made it twice, or a person told them the rule): if the worktree has `.claude/skills/skill-improver/SKILL.md`, tell the worker to follow it (`/skill-improver`) in that turn \u2014 one sentence in the skill that owns it, in the same change. The worker who heard it writes it down; no Sideboard tool hands that chat to a later run.",
13361
13377
  "Human-only (do not attempt): ready-for-review land (confirm_land), purge_chat.",
13362
13378
  "Chat links in replies: when mentioning a chat/thread for the user, include a markdown link `[Title](sideboard://chat/<id>)` using the full id (or the link field from create_workspace / list_chats). Sideboard renders these as clickable opens.",
13363
13379
  "Bash / Read / etc: allowed for (1) inspecting target worktrees / registered repo paths from MCP, and (2) greenfield setup under ~/sideboard/repos (git clone, gh repo create, git init+remote). Never git init/clone *inside* this synthetic home cwd \u2014 emptiness here is expected, not a bug."
@@ -32069,7 +32085,7 @@ function formatProcessGuideDirective(opts) {
32069
32085
  hasInstallSkill ? "- After merge-from-main / lockfile change, or a hung `pnpm install`: follow `.claude/skills/worktree-install/SKILL.md` (`/worktree-install`). Use the worktree-local store Sideboard already set; do not share `~/.pnpm-store` across concurrent worktrees." : null,
32070
32086
  "- 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 it). Not under `.sideboard/skills/`. Point Codex/OpenCode at it from `AGENTS.md`.",
32071
32087
  hasReviewSkill ? "- Merge-readiness notes go in `.claude/skills/review/SKILL.md` (edit it; do not create another review skill)." : "- Merge-readiness notes go in `.context/review.md` (copied from `.sideboard/review.md` when that file exists). Do not create a review skill.",
32072
- "- 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."
32088
+ !!worktree && (0, import_node_fs68.existsSync)((0, import_node_path68.join)(worktree, ".claude/skills/skill-improver/SKILL.md")) ? "- Skip a guide for a one-off. If a matching skill exists, follow it. A miss that will recur (you made it twice, or a person told you the rule) \u2192 follow `.claude/skills/skill-improver/SKILL.md` (`/skill-improver`): one sentence in the skill that owns it, in this change. Do not patch around it." : "- 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."
32073
32089
  ].filter(Boolean).join("\n");
32074
32090
  }
32075
32091
  function formatLongRunningDirective(opts) {
@@ -42798,6 +42814,131 @@ function startPhoneBoardSync(opts) {
42798
42814
  };
42799
42815
  }
42800
42816
 
42817
+ // src/remote/phone-push-watch.ts
42818
+ init_orchestrator();
42819
+
42820
+ // src/remote/push.ts
42821
+ init_protocol();
42822
+ var EXPO_PUSH_URL = "https://exp.host/--/api/v2/push/send";
42823
+ function hostedPushRelay(url) {
42824
+ try {
42825
+ return new URL(url).hostname === new URL(BAKED_REMOTE_RELAY_URL).hostname;
42826
+ } catch {
42827
+ return false;
42828
+ }
42829
+ }
42830
+ function pushBody(kind) {
42831
+ if (kind === "needs_you") return "A chat needs you";
42832
+ if (kind === "failed") return "A chat failed";
42833
+ return "A turn finished";
42834
+ }
42835
+ function expoPushMessage(input) {
42836
+ return {
42837
+ to: input.to,
42838
+ title: input.deviceLabel,
42839
+ body: pushBody(input.kind),
42840
+ data: { deviceId: input.deviceId, chatId: input.chatId, kind: input.kind },
42841
+ sound: "default",
42842
+ priority: "high"
42843
+ };
42844
+ }
42845
+ function pushNotes(input) {
42846
+ const notes = [];
42847
+ const fresh = /* @__PURE__ */ new Set();
42848
+ for (const id of input.after) {
42849
+ if (input.before.has(id)) continue;
42850
+ fresh.add(id);
42851
+ notes.push({ chatId: id, kind: "needs_you" });
42852
+ }
42853
+ const event = input.event;
42854
+ if (!event || event.type !== "turn_finished" && event.type !== "error") return notes;
42855
+ if (fresh.has(event.threadId)) return notes;
42856
+ const finished = event.type === "turn_finished" && (event.exitCode === 0 || event.exitCode == null);
42857
+ notes.push({ chatId: event.threadId, kind: finished ? "finished" : "failed" });
42858
+ return notes;
42859
+ }
42860
+ var MemoryPushTokens = class {
42861
+ rows = /* @__PURE__ */ new Map();
42862
+ replace(token, deviceIds) {
42863
+ const ids = new Set(deviceIds.filter(Boolean));
42864
+ if (ids.size === 0) this.rows.delete(token);
42865
+ else this.rows.set(token, ids);
42866
+ }
42867
+ tokens(deviceId) {
42868
+ const out = [];
42869
+ for (const [token, ids] of this.rows) {
42870
+ if (ids.has(deviceId)) out.push(token);
42871
+ }
42872
+ return out;
42873
+ }
42874
+ };
42875
+ async function sendExpoPushes(messages, fetchImpl = fetch) {
42876
+ if (messages.length === 0) return;
42877
+ const res = await fetchImpl(EXPO_PUSH_URL, {
42878
+ method: "POST",
42879
+ headers: { "content-type": "application/json", accept: "application/json" },
42880
+ body: JSON.stringify(messages)
42881
+ });
42882
+ if (!res.ok) throw new Error(`Expo push HTTP ${res.status}`);
42883
+ const body = await res.json().catch(() => null);
42884
+ const failed = body?.data?.find((row2) => row2.status === "error");
42885
+ if (failed) throw new Error(failed.message || "Expo push rejected");
42886
+ }
42887
+
42888
+ // src/remote/phone-push-watch.ts
42889
+ function needingChatIds(sidebar) {
42890
+ const ids = [];
42891
+ for (const chat of sidebar.orchestration) {
42892
+ if (chat.needsYou && chat.id) ids.push(chat.id);
42893
+ }
42894
+ for (const project of sidebar.projects) {
42895
+ for (const worktree of project.worktrees) {
42896
+ for (const chat of worktree.chats) {
42897
+ if (chat.needsYou && chat.id) ids.push(chat.id);
42898
+ }
42899
+ }
42900
+ }
42901
+ return ids;
42902
+ }
42903
+ function startPhonePushWatch(opts) {
42904
+ const needsYou = opts.needsYou ?? (() => needingChatIds(listPhoneSidebar()));
42905
+ const read = () => new Set(needsYou());
42906
+ let needing = read();
42907
+ let timer2 = null;
42908
+ const flush2 = (event) => {
42909
+ const after = read();
42910
+ if (!opts.enabled()) {
42911
+ needing = after;
42912
+ return;
42913
+ }
42914
+ for (const note of pushNotes({ event, before: needing, after })) opts.send(note);
42915
+ needing = after;
42916
+ };
42917
+ const schedule = () => {
42918
+ if (timer2) return;
42919
+ timer2 = setTimeout(() => {
42920
+ timer2 = null;
42921
+ flush2(null);
42922
+ }, opts.debounceMs ?? 300);
42923
+ };
42924
+ const onEvent = (event) => {
42925
+ if (event.type === "turn_finished" || event.type === "error") {
42926
+ if (timer2) clearTimeout(timer2);
42927
+ timer2 = null;
42928
+ flush2(event);
42929
+ return;
42930
+ }
42931
+ if (isPhoneBoardEvent(event)) schedule();
42932
+ };
42933
+ const offEvents = (opts.events ?? ((listener) => getOrchestrator().on(listener)))(onEvent);
42934
+ const offFiles = (opts.subscribe ?? subscribePhoneBoard)(() => schedule());
42935
+ return () => {
42936
+ if (timer2) clearTimeout(timer2);
42937
+ offEvents();
42938
+ offFiles();
42939
+ };
42940
+ }
42941
+
42801
42942
  // src/remote/client.ts
42802
42943
  init_protocol();
42803
42944
  var BACKOFF_START_MS = 1e3;
@@ -43083,6 +43224,11 @@ function runRemoteHost(opts) {
43083
43224
  if (getPhoneOpenChat() !== chatId) return;
43084
43225
  emitControl({ onOutbound: emit }, { op: "permission", chatId, prompt });
43085
43226
  });
43227
+ const stopPush = hostedPushRelay(opts.url) ? startPhonePushWatch({
43228
+ enabled: () => Boolean(socket && socket.readyState === socket.OPEN),
43229
+ send: (note) => send3({ type: "push_notify", chatId: note.chatId, kind: note.kind })
43230
+ }) : null;
43231
+ opts.signal?.addEventListener("abort", () => stopPush?.(), { once: true });
43086
43232
  void loop();
43087
43233
  return {
43088
43234
  requestPairingCode() {
@@ -45186,6 +45332,7 @@ function newCode() {
45186
45332
  var RemoteHub = class {
45187
45333
  constructor(opts = {}) {
45188
45334
  this.opts = opts;
45335
+ this.pushTokens = opts.pushTokens ?? new MemoryPushTokens();
45189
45336
  }
45190
45337
  opts;
45191
45338
  hosts = /* @__PURE__ */ new Map();
@@ -45193,6 +45340,8 @@ var RemoteHub = class {
45193
45340
  bySocket = /* @__PURE__ */ new Map();
45194
45341
  codes = /* @__PURE__ */ new Map();
45195
45342
  phonesByToken = /* @__PURE__ */ new Map();
45343
+ pushTokens;
45344
+ pushTokenBySocket = /* @__PURE__ */ new Map();
45196
45345
  handleClientMessage(socket, raw) {
45197
45346
  const msg = parseRemoteClientMessage(raw);
45198
45347
  if (!msg) {
@@ -45221,6 +45370,7 @@ var RemoteHub = class {
45221
45370
  }
45222
45371
  if (bound.role === "phone" && host.phone === socket) {
45223
45372
  host.phone = null;
45373
+ this.pushTokenBySocket.delete(socket);
45224
45374
  send(host.socket, { type: "phone_left" });
45225
45375
  }
45226
45376
  }
@@ -45249,6 +45399,14 @@ var RemoteHub = class {
45249
45399
  this.listHosts(socket, msg.sessionTokens);
45250
45400
  return;
45251
45401
  }
45402
+ if (msg.type === "push_register") {
45403
+ this.registerPush(socket, msg.token, msg.sessionTokens);
45404
+ return;
45405
+ }
45406
+ if (msg.type === "push_notify") {
45407
+ this.notifyPush(socket, msg.chatId, msg.kind);
45408
+ return;
45409
+ }
45252
45410
  if (msg.type === "prompt" || msg.type === "stop") {
45253
45411
  this.fromPhone(socket, msg);
45254
45412
  return;
@@ -45306,6 +45464,7 @@ var RemoteHub = class {
45306
45464
  }
45307
45465
  if (existing.phone) {
45308
45466
  send(existing.phone, { type: "host_offline" });
45467
+ this.pushTokenBySocket.delete(existing.phone);
45309
45468
  this.bySocket.delete(existing.phone);
45310
45469
  }
45311
45470
  }
@@ -45431,6 +45590,7 @@ var RemoteHub = class {
45431
45590
  this.bySocket.delete(socket);
45432
45591
  if (prev?.phone === socket) {
45433
45592
  prev.phone = null;
45593
+ this.pushTokenBySocket.delete(socket);
45434
45594
  send(prev.socket, { type: "phone_left" });
45435
45595
  }
45436
45596
  }
@@ -45441,6 +45601,7 @@ var RemoteHub = class {
45441
45601
  }
45442
45602
  const already = host.phone === socket;
45443
45603
  if (host.phone && host.phone !== socket) {
45604
+ this.pushTokenBySocket.delete(host.phone);
45444
45605
  this.bySocket.delete(host.phone);
45445
45606
  try {
45446
45607
  host.phone.close();
@@ -45496,6 +45657,31 @@ var RemoteHub = class {
45496
45657
  }
45497
45658
  send(host.phone, { type: "ask_user", text: msg.text, questions: msg.questions });
45498
45659
  }
45660
+ registerPush(socket, token, sessionTokens) {
45661
+ const deviceIds = [];
45662
+ for (const sessionToken of sessionTokens) {
45663
+ const known = this.knownSession(sessionToken);
45664
+ if (known && !deviceIds.includes(known.deviceId)) deviceIds.push(known.deviceId);
45665
+ }
45666
+ this.pushTokens.replace(token, deviceIds);
45667
+ this.pushTokenBySocket.set(socket, token);
45668
+ }
45669
+ notifyPush(socket, chatId, kind) {
45670
+ const bound = this.bySocket.get(socket);
45671
+ const host = bound?.role === "host" ? this.hosts.get(bound.deviceId) : null;
45672
+ if (!host || host.socket !== socket) return;
45673
+ const connected = host.phone ? this.pushTokenBySocket.get(host.phone) : void 0;
45674
+ const messages = this.pushTokens.tokens(host.deviceId).filter((token) => token !== connected).map(
45675
+ (to) => expoPushMessage({
45676
+ to,
45677
+ deviceLabel: host.deviceLabel,
45678
+ deviceId: host.deviceId,
45679
+ chatId,
45680
+ kind
45681
+ })
45682
+ );
45683
+ if (messages.length > 0) this.opts.onPush?.(messages);
45684
+ }
45499
45685
  };
45500
45686
 
45501
45687
  // src/relay/server.ts
@@ -45596,6 +45782,15 @@ var RelayAccountStore = class {
45596
45782
  this.db.exec("ALTER TABLE devices ADD COLUMN session_token_hash TEXT");
45597
45783
  }
45598
45784
  this.db.exec("CREATE INDEX IF NOT EXISTS devices_session ON devices(session_token_hash)");
45785
+ this.db.exec(`
45786
+ CREATE TABLE IF NOT EXISTS push_tokens (
45787
+ token TEXT NOT NULL,
45788
+ device_id TEXT NOT NULL,
45789
+ updated_at INTEGER NOT NULL,
45790
+ PRIMARY KEY (token, device_id)
45791
+ );
45792
+ CREATE INDEX IF NOT EXISTS push_tokens_device ON push_tokens(device_id);
45793
+ `);
45599
45794
  }
45600
45795
  close() {
45601
45796
  this.db.close();
@@ -45731,6 +45926,31 @@ var RelayAccountStore = class {
45731
45926
  if (!id || !token) return;
45732
45927
  this.db.prepare("UPDATE devices SET session_token_hash = ? WHERE device_id = ?").run(sha2563(token), id);
45733
45928
  }
45929
+ /** Replace every Mac this Expo token should reach. An empty list forgets it. */
45930
+ replacePushToken(token, deviceIds) {
45931
+ const id = token.trim();
45932
+ if (!id) return;
45933
+ const ids = [...new Set(deviceIds.map((row2) => row2.trim()).filter(Boolean))];
45934
+ const now = Date.now();
45935
+ this.db.exec("BEGIN");
45936
+ try {
45937
+ this.db.prepare("DELETE FROM push_tokens WHERE token = ?").run(id);
45938
+ const insert = this.db.prepare(
45939
+ "INSERT INTO push_tokens (token, device_id, updated_at) VALUES (?, ?, ?)"
45940
+ );
45941
+ for (const deviceId of ids) insert.run(id, deviceId, now);
45942
+ this.db.exec("COMMIT");
45943
+ } catch (err) {
45944
+ this.db.exec("ROLLBACK");
45945
+ throw err;
45946
+ }
45947
+ }
45948
+ pushTokensFor(deviceId) {
45949
+ const id = deviceId.trim();
45950
+ if (!id) return [];
45951
+ const rows = this.db.prepare("SELECT token FROM push_tokens WHERE device_id = ? ORDER BY updated_at").all(id);
45952
+ return rows.map((row2) => row2.token);
45953
+ }
45734
45954
  findPhoneSession(sessionToken) {
45735
45955
  const token = sessionToken.trim();
45736
45956
  if (!token) return null;
@@ -46333,6 +46553,15 @@ async function startRelayServer(opts) {
46333
46553
  find: (sessionToken) => accountStore.findPhoneSession(sessionToken),
46334
46554
  save: (deviceId, sessionToken) => accountStore.savePhoneSession(deviceId, sessionToken)
46335
46555
  } : void 0,
46556
+ pushTokens: accountStore ? {
46557
+ replace: (token, deviceIds) => accountStore.replacePushToken(token, deviceIds),
46558
+ tokens: (deviceId) => accountStore.pushTokensFor(deviceId)
46559
+ } : void 0,
46560
+ onPush: (messages) => {
46561
+ void sendExpoPushes(messages, opts.fetchImpl ?? fetch).catch((err) => {
46562
+ log(`push: ${err instanceof Error ? err.message : err}`);
46563
+ });
46564
+ },
46336
46565
  onAuthorized: (socket) => authMarks.get(socket)?.()
46337
46566
  });
46338
46567
  const publicOrigin = () => opts.relayPublicOrigin?.trim() || process.env.SIDEBOARD_RELAY_PUBLIC_ORIGIN?.trim() || `http://127.0.0.1:${boundPort}`;