claude-code-session-manager 0.126.0 → 0.128.0

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 (107) hide show
  1. package/bin/cli.cjs +71 -9
  2. package/bin/supervise.cjs +84 -0
  3. package/dist/assets/{AgentLibrary-bzeuZN4F.js → AgentLibrary-cNQU5YWy.js} +1 -1
  4. package/dist/assets/{Button-8dWfDDuQ.js → Button-9dIPAOBg.js} +1 -1
  5. package/dist/assets/{DataModel-D4ybBPZN.js → DataModel-DrDJ6ysw.js} +1 -1
  6. package/dist/assets/{History-hsztE6yh.js → History-4rrDdWNP.js} +1 -1
  7. package/dist/assets/{Hooks-CRmZMQaW.js → Hooks-Bj_jF5Pa.js} +1 -1
  8. package/dist/assets/{Library-Czt3Bojd.js → Library-D-Wsxrh7.js} +1 -1
  9. package/dist/assets/{ListDetail-Cr6Ct_WX.js → ListDetail-D7Om0H8j.js} +1 -1
  10. package/dist/assets/{McpServers-CeXJ2bng.js → McpServers-CbIbSd5o.js} +1 -1
  11. package/dist/assets/{Memory-caujO8O3.js → Memory-DgQlvQrO.js} +1 -1
  12. package/dist/assets/{Panel-D64i9tGz.js → Panel-DZHiD8Ar.js} +1 -1
  13. package/dist/assets/{Permissions-DpWOIrvr.js → Permissions-CfzduF4B.js} +1 -1
  14. package/dist/assets/{Plugins-Bd1ekP5P.js → Plugins-D-AG5nAo.js} +2 -2
  15. package/dist/assets/{ProvenanceBadge-B96A_uZf.js → ProvenanceBadge-B9JSEjll.js} +1 -1
  16. package/dist/assets/{SaveBar-D0Y2t-Ao.js → SaveBar-mVKig6hL.js} +1 -1
  17. package/dist/assets/{Scheduler-Y5_YbNrC.js → Scheduler-DFTCnh60.js} +1 -1
  18. package/dist/assets/{ScopeSwitcher-BmWA_dP9.js → ScopeSwitcher-s8J-yr7Z.js} +1 -1
  19. package/dist/assets/{Settings-Bcf65bpL.js → Settings-BTmxRMaP.js} +1 -1
  20. package/dist/assets/{SkillReferenceGraph-BeSNXloA.js → SkillReferenceGraph-C5lKqf5y.js} +1 -1
  21. package/dist/assets/{Skills-DwnQKJVc.js → Skills-CxOacq0k.js} +1 -1
  22. package/dist/assets/{SystemPrompt-Dih6SCmL.js → SystemPrompt-BCWg5FAz.js} +1 -1
  23. package/dist/assets/{TagLibrary-BZ-Kp10P.js → TagLibrary-BnF0_PkG.js} +1 -1
  24. package/dist/assets/{TiptapBody-C2nEUmF7.js → TiptapBody-C2Iu6rZd.js} +1 -1
  25. package/dist/assets/{Toggle-Dw8-zNQo.js → Toggle-C-oD66BG.js} +1 -1
  26. package/dist/assets/{ViewTabs-CoYPKGN-.js → ViewTabs-Cs4v7vLY.js} +1 -1
  27. package/dist/assets/{historyTotals-BbKcNpV7.js → historyTotals-CbRSLD8f.js} +1 -1
  28. package/dist/assets/{index-BnKaYERU.css → index-DtdWBGrI.css} +1 -1
  29. package/dist/assets/index-DzY_GXYY.js +3081 -0
  30. package/dist/assets/{settingsSchema-6doG_61l.js → settingsSchema-bSBfHuan.js} +1 -1
  31. package/dist/assets/{skillFrontmatter-BYMYWDfb.js → skillFrontmatter-BEseWm8r.js} +1 -1
  32. package/dist/assets/{useAgentsDirWatch-Cqabjieh.js → useAgentsDirWatch-CdyHxKCI.js} +1 -1
  33. package/dist/index.html +2 -2
  34. package/dist-web/app.css +1 -1
  35. package/dist-web/app.js +343 -341
  36. package/package.json +1 -1
  37. package/plugins/session-manager-dev/skills/develop/SKILL.md +3 -2
  38. package/scripts/scheduler-mcp-server.cjs +209 -7
  39. package/src/main/build-info.json +4 -4
  40. package/src/main/chatRunner.cjs +37 -4
  41. package/src/main/crashDiagnostics.cjs +83 -8
  42. package/src/main/health.cjs +16 -5
  43. package/src/main/index.cjs +46 -0
  44. package/src/main/ipcSchemas.cjs +107 -0
  45. package/src/main/lib/chatBootRecovery.cjs +136 -0
  46. package/src/main/lib/chatInflight.cjs +88 -0
  47. package/src/main/lib/claude/agentModelResolve.cjs +26 -7
  48. package/src/main/lib/claude/personaToolScope.cjs +40 -2
  49. package/src/main/lib/demo-video-kit/capture.cjs +113 -0
  50. package/src/main/lib/demo-video-kit/character.cjs +97 -0
  51. package/src/main/lib/demo-video-kit/checks.cjs +150 -0
  52. package/src/main/lib/demo-video-kit/frames.cjs +200 -0
  53. package/src/main/lib/demo-video-kit/seedKit.cjs +52 -0
  54. package/src/main/lib/demo-video-kit/sound.cjs +312 -0
  55. package/src/main/lib/epic/epicDelegationStats.cjs +1 -0
  56. package/src/main/lib/epic/epicSweepValidator.cjs +60 -6
  57. package/src/main/lib/epic/epicValidationHook.cjs +31 -3
  58. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +71 -15
  59. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +185 -34
  60. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +15 -0
  61. package/src/main/lib/mcpToolCatalog.cjs +93 -14
  62. package/src/main/lib/opsOwnership.cjs +9 -5
  63. package/src/main/lib/persona-macro/builtinMacros.cjs +30 -5
  64. package/src/main/lib/persona-macro/macroJobDispatch.cjs +116 -0
  65. package/src/main/lib/persona-macro/macroJobIpc.cjs +50 -0
  66. package/src/main/lib/persona-macro/macroJobStatus.cjs +112 -0
  67. package/src/main/lib/persona-macro/macroLibrary.cjs +73 -3
  68. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +100 -0
  69. package/src/main/lib/prd/prdCreate.cjs +17 -2
  70. package/src/main/lib/prd/prdFrontmatter.cjs +7 -2
  71. package/src/main/lib/process/childWithLog.cjs +38 -95
  72. package/src/main/lib/process/memoryScope.cjs +140 -0
  73. package/src/main/lib/process/ozonePlatform.cjs +15 -0
  74. package/src/main/lib/process/procIdentity.cjs +10 -3
  75. package/src/main/lib/process/scopeOomPolicy.cjs +69 -0
  76. package/src/main/lib/project-pages/pagesLibrary.cjs +171 -0
  77. package/src/main/lib/project-pages/playerBridge.cjs +129 -0
  78. package/src/main/lib/scheduler/cpuSample.cjs +147 -0
  79. package/src/main/lib/scheduler/definitionOfDone.cjs +40 -0
  80. package/src/main/lib/scheduler/jobLeftovers.cjs +204 -0
  81. package/src/main/lib/scheduler/jobSupervisorRecord.cjs +2 -1
  82. package/src/main/lib/scheduler/loadGate.cjs +116 -45
  83. package/src/main/lib/scheduler/queueStore.cjs +5 -2
  84. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  85. package/src/main/lib/scheduler/schedulerBatch.cjs +10 -3
  86. package/src/main/lib/scheduler/schedulerConfig.cjs +7 -2
  87. package/src/main/lib/smfileHeaders.cjs +11 -3
  88. package/src/main/lib/telemetry/crashTelemetry.cjs +8 -4
  89. package/src/main/projectPages.cjs +107 -30
  90. package/src/main/promptSessionsIpc.cjs +131 -0
  91. package/src/main/scheduler/budget.cjs +31 -0
  92. package/src/main/scheduler/prdParser.cjs +2 -0
  93. package/src/main/scheduler/prdPaths.cjs +54 -0
  94. package/src/main/scheduler/reviewLadder.cjs +17 -0
  95. package/src/main/scheduler/starvation.cjs +22 -0
  96. package/src/main/scheduler.cjs +548 -77
  97. package/src/main/seedSchedulerMcp.cjs +10 -1
  98. package/src/main/templates/PRD_AUTHORING.md +5 -2
  99. package/src/main/transcripts.cjs +8 -0
  100. package/src/main/usage.cjs +4 -2
  101. package/src/main/webRemote.cjs +3 -1
  102. package/src/preload/api.d.ts +113 -7
  103. package/src/preload/apiSurface.json +70 -0
  104. package/src/preload/index.cjs +13 -0
  105. package/src/seed/agents/demo-video-builder.md +141 -43
  106. package/src/seed/agents/project-home-builder.md +26 -13
  107. package/dist/assets/index-DgPUERhe.js +0 -3079
@@ -111,6 +111,15 @@ function mcpAddArgv(serverPath) {
111
111
  return ['mcp', 'add', SERVER_NAME, '--scope', 'user', ...envFlags, '--', spec.command, ...spec.args];
112
112
  }
113
113
 
114
+ /** The server definition (`{command,args,env?}`) shared by the seed and by
115
+ * scheduler job spawns (--mcp-config). Same nodeSpawnSpec as mcpAddArgv. */
116
+ function schedulerServerEntry(serverPath = serverScriptPath()) {
117
+ const spec = nodeSpawnSpec(serverPath);
118
+ const entry = { command: spec.command, args: [...spec.args] };
119
+ if (Object.keys(spec.env).length) entry.env = { ...spec.env };
120
+ return entry;
121
+ }
122
+
114
123
  /** Run `claude mcp add session-manager-scheduler --scope user -- node <serverPath>`.
115
124
  * No shell:true — argv array passed directly to spawn. */
116
125
  function runClaudeMcpAdd(serverPath) {
@@ -209,4 +218,4 @@ async function seedSchedulerMcp({ logger = console, addFn = runClaudeMcpAdd, rem
209
218
  }
210
219
  }
211
220
 
212
- module.exports = { seedSchedulerMcp, writeMarker, runClaudeMcpAdd, runClaudeMcpRemove, mcpAddArgv, markerPath, MAX_ATTEMPTS, serverScriptPath, SERVER_NAME };
221
+ module.exports = { seedSchedulerMcp, writeMarker, runClaudeMcpAdd, runClaudeMcpRemove, mcpAddArgv, markerPath, MAX_ATTEMPTS, serverScriptPath, SERVER_NAME, schedulerServerEntry };
@@ -1,4 +1,4 @@
1
- <!-- PRD_AUTHORING.md v16 -->
1
+ <!-- PRD_AUTHORING.md v18 -->
2
2
  # PRD Authoring Guide — Scheduler Safety Rules
3
3
 
4
4
  Rule: every PRD you queue follows the rules below.
@@ -69,7 +69,7 @@ if (!found) {
69
69
  Rule: every PRD needs these fields.
70
70
  1. `title` — one line, plain English.
71
71
  2. `cwd` — the Epic's project root, as an absolute path or `~/…`. The API always sets it to the Epic's project, whatever you pass. To work in another project, open an Epic in that project. The folder must exist when you queue.
72
- 3. `estimateMinutes` — optional; omit it. A run without one gets its persona's `defaultEstimateMinutes`, else the 45-minute floor. Pass one only if the run legitimately needs longer. Most PRDs take 5–10 minutes (§8).
72
+ 3. `estimateMinutes` — optional; omit it. A run without one gets its persona's `defaultEstimateMinutes`, else the 45-minute floor. Pass one only if the run legitimately needs longer. A validator with no estimate is sized from the gates it must re-run. Most PRDs take 5–10 minutes (§8).
73
73
 
74
74
  `parallelGroup` is deprecated and ignored. `dependsOn: [<slug>, ...]` is the only ordering primitive.
75
75
 
@@ -132,6 +132,9 @@ The executor can't ask you anything: no `ScheduleWakeup`, Cron, Monitor, `AskUse
132
132
  Worktree reach: every PRD runs in an isolated git worktree holding tracked files plus `node_modules` and non-uv `.venv`/`venv` symlinked from the main checkout; pnpm projects (pnpm-lock.yaml) get a worktree-local `node_modules` installed offline from the store, and uv projects (uv.lock) get a worktree-local env built by an offline frozen `uv sync`, not a symlink. Why: a pnpm install through the symlink purged the main checkout's node_modules (Bilko-Game-Academy 2026-10-18). A step that needs gitignored runtime state (databases, `downloads/`, browser profiles, logs) or a live side effect must address the main checkout by absolute path (e.g. `$HOME/Projects/<repo>/...`), be artifact-only (a deliverable artifact + `artifactPaths`, no tracked edits), and `dependsOn` the PRD that lands its tracked edits. A project may declare `worktreeSetup` gate-syntax commands in a tracked `.session-manager.json` at the repo root; they run once per fresh job worktree and baseline scratch worktree, before the executor starts, with cwd = the worktree root (a project in a subfolder names it, e.g. `timeout 600 godot --headless --path game --import`). Setups run one at a time per project and are never skipped; they must write only inside the worktree (node_modules and non-uv venvs are symlinks into the main checkout). The outcome is the `[scheduler] worktree setup:` lines at the top of the run log plus `worktreeSetup` in the run's meta.json. Host crontab installs stay human-only (see §14).
133
133
  Why: burrow PRD 1516 halted because its relative `.venv` python against `downloads/fb-tracker.db`, `scripts/install-cron.sh` and `pipeline-cron.sh --now` resolved inside the worktree (no runtime state; install-cron would bake a temporary worktree path into crontab), while sibling 1494 succeeded the same day using an absolute main-checkout path and artifact-only output. `scheduler_create_prd` warns on relative gitignored paths.
134
134
 
135
+ Rule: a job's processes never outlive it — the group sweep at exit, the job scope stop (systemd) and the 5-minute leftover sweep (Linux) stop anything it started, so `nohup` or `&` does not daemonize. Anything that must keep running goes to a service manager (systemd unit, cron), never `nohup` or `&`.
136
+ Why: finished jobs left dev servers running for days, holding memory and ports.
137
+
135
138
  ---
136
139
 
137
140
  ## §8 Scope sizing — target ≤10 min, ceiling 15
@@ -57,6 +57,12 @@ function transcriptPath(cwd, sessionUuid) {
57
57
  return resolveTranscript(cwd, sessionUuid).filePath;
58
58
  }
59
59
 
60
+ /** True when the session's JSONL exists on disk (project or Epic-worktree encoding). */
61
+ function transcriptExists(cwd, sessionUuid) {
62
+ const { filePath, existsAnywhere } = resolveTranscript(cwd, sessionUuid);
63
+ return existsAnywhere || fs.existsSync(filePath);
64
+ }
65
+
60
66
  // Cap bytes read per readDelta pass. Bounds memory on first attach to a very
61
67
  // large transcript (hundreds of MB) — see readDelta's seek-to-tail branch.
62
68
  const MAX_DELTA_BYTES = 8 * 1024 * 1024;
@@ -577,12 +583,14 @@ function registerTranscriptHandlers() {
577
583
  }));
578
584
  ipcMain.handle('transcript:buffer', v(s.transcriptTabId, ({ tabId }) => getBuffer(tabId)));
579
585
  ipcMain.handle('transcript:path', v(s.transcriptPath, ({ cwd, sessionUuid }) => transcriptPath(cwd, sessionUuid)));
586
+ ipcMain.handle('transcript:exists', v(s.transcriptPath, ({ cwd, sessionUuid }) => transcriptExists(cwd, sessionUuid)));
580
587
  ipcMain.handle('transcript:usageFor', v(s.transcriptUsageFor, ({ cwd, sessionIds }) => usageFor(cwd, sessionIds)));
581
588
  ipcMain.handle('transcript:page', v(s.transcriptPage, ({ tabId, startLine, endLine }) => pageEvents(tabId, startLine, endLine)));
582
589
  ipcMain.handle('transcript:readRef', v(s.transcriptReadRef, (ref) => readRef(ref)));
583
590
  }
584
591
 
585
592
  module.exports = {
593
+ transcriptExists,
586
594
  attachWindow,
587
595
  registerTranscriptHandlers,
588
596
  closeAll,
@@ -310,8 +310,10 @@ async function fetchUsage() {
310
310
 
311
311
  /** Attaches the last good payload (+ its age anchor) to a 429 so callers can keep using it. */
312
312
  function withCachedPayload(r) {
313
- if (r && r.kind === 'meter_rate_limited' && cache && cache.data) {
314
- return { ...r, cached: cache.data, staleSince: cache.fetchedAt };
313
+ // cache.data is the wrapper { usage, subscriptionType, ... }; meterFailureBudget
314
+ // needs the inner usage object. No usage object -> attach nothing.
315
+ if (r && r.kind === 'meter_rate_limited' && cache && cache.data && cache.data.usage) {
316
+ return { ...r, cached: cache.data.usage, staleSince: cache.fetchedAt };
315
317
  }
316
318
  return r;
317
319
  }
@@ -923,7 +923,9 @@ function sendIpcResult(callId, frame, client) {
923
923
  try {
924
924
  const inner = { type: 'ipc:result', id: callId, seq: frame.seq, total: frame.total, data: frame.data, ts: Date.now() };
925
925
  const { nonce, ciphertext } = encryptBox(JSON.stringify(inner), client.e2e.sessionKey);
926
- const out = { type: 'e2e:box', id: callId, payload: { nonce, ciphertext }, ts: Date.now() };
926
+ // The relay's envelope schema requires a UUID `id` and DROPS anything else (invalid_envelope), so the
927
+ // outer id is always a fresh UUID. Batched replies are keyed `<uuid>.<n>`; that key rides inside the box.
928
+ const out = { type: 'e2e:box', id: crypto.randomUUID(), payload: { nonce, ciphertext }, ts: Date.now() };
927
929
  if (client.key !== LEGACY_CLIENT_KEY) out.toConn = client.key;
928
930
  _ws.send(JSON.stringify(out));
929
931
  } catch (e) {
@@ -286,6 +286,36 @@ export interface MacroInput {
286
286
  options?: string[];
287
287
  }
288
288
 
289
+ /** Background-build descriptor on a built-in macro. */
290
+ export interface MacroJob {
291
+ estimateMinutes: number;
292
+ artifactPaths: string[];
293
+ }
294
+
295
+ export interface MacroJobDispatchInput {
296
+ cwd: string;
297
+ macroId: string;
298
+ epicId: string;
299
+ extraInstructions?: string;
300
+ }
301
+
302
+ export type MacroJobDispatchResult =
303
+ | { ok: true; slug: string; epicId: string }
304
+ | { ok: false; error: string; activeSlug?: string };
305
+
306
+ export type MacroJobState = 'queued' | 'running' | 'done' | 'failed';
307
+
308
+ export interface MacroJobStatus {
309
+ macroId: string;
310
+ epicId: string | null;
311
+ slug: string;
312
+ state: MacroJobState;
313
+ status: string;
314
+ reason: string | null;
315
+ startedAt: string | null;
316
+ finishedAt: string | null;
317
+ }
318
+
289
319
  /** One user-defined sidebar HOT KEYS macro (macroLibrary.cjs). `projects` = absolute cwds or `'*'` (every project). */
290
320
  export interface Macro {
291
321
  id: string;
@@ -305,6 +335,8 @@ export interface Macro {
305
335
  inputs?: MacroInput[];
306
336
  /** Projects ('*' or absolute cwds) this macro's session may start work in without approval. */
307
337
  autoStartTargets?: string[];
338
+ /** Set only on built-ins whose press builds in the background. */
339
+ job?: MacroJob;
308
340
  }
309
341
 
310
342
  /** Omit `id` to create; set it to update an existing macro. */
@@ -667,6 +699,7 @@ export interface ScheduleJobRuntime {
667
699
  }
668
700
 
669
701
  export interface ScheduleJob {
702
+ macroId?: string | null;
670
703
  slug: string;
671
704
  title: string;
672
705
  cwd: string | null;
@@ -1025,8 +1058,18 @@ export interface ScheduleLoadGate {
1025
1058
  threshold: number;
1026
1059
  loadavg1: number | null;
1027
1060
  cores: number;
1028
- /** How long the current gated stretch has lasted, 0 when not gated. */
1029
- gatedSinceMs: number;
1061
+ /** Measured machine-wide CPU busy fraction (0..1) over cpuWindowMs, or null with no sample. */
1062
+ cpuBusy: number | null;
1063
+ /** Machine-wide iowait fraction (0..1) over the same window (not counted as busy), or null with no sample. */
1064
+ cpuIowait: number | null;
1065
+ /** Length of the CPU sample window in ms, or null with no sample. */
1066
+ cpuWindowMs: number | null;
1067
+ /** True when loadavg was over threshold but the CPU sample showed it mostly idle, so launches proceed. */
1068
+ standDown: boolean;
1069
+ /** Time this gate itself held a batch that slots and memory admitted; 0 when not holding */
1070
+ heldMs: number;
1071
+ /** True on the tick where a long hold reached its limit with the CPU not saturated (or no sample) and one job was let through. A saturated CPU keeps holding instead. */
1072
+ yielded: boolean;
1030
1073
  at: string;
1031
1074
  }
1032
1075
 
@@ -1478,12 +1521,57 @@ export type ProjectBriefUpdateResult =
1478
1521
  | { ok: false; error: string };
1479
1522
 
1480
1523
  // ────────────────────────────────────────────── Project Pages (single home.html)
1524
+ export interface ProjectPageMeta {
1525
+ id: string;
1526
+ title: string;
1527
+ topic: string;
1528
+ createdAt: string;
1529
+ model: string;
1530
+ }
1531
+
1532
+ export interface ProjectVideoMeta {
1533
+ id: string;
1534
+ title: string;
1535
+ kind: 'project-demo' | 'blog-post' | 'feature';
1536
+ style: string;
1537
+ lengthS: number;
1538
+ createdAt: string;
1539
+ character: string | null;
1540
+ sources: { claim: string; source: string; ref: string }[];
1541
+ report: {
1542
+ lufs: number | null;
1543
+ truePeakDb: number | null;
1544
+ speechS: number | null;
1545
+ readingGrade: number | null;
1546
+ checks: { id: string; ok: boolean; detail: string }[];
1547
+ bytes: number;
1548
+ };
1549
+ macroVersion: number;
1550
+ seedVersion: number;
1551
+ model: string;
1552
+ effort: string;
1553
+ }
1554
+
1555
+ /** One library folder (knowledge/<id>/ or videos/<id>/); `meta` is null when meta.json is missing/invalid (see `error`). */
1556
+ export interface ProjectLibraryEntry<M> {
1557
+ id: string;
1558
+ /** Absolute path of the entry's index.html — load via smfile://. */
1559
+ path: string;
1560
+ mtimeMs: number;
1561
+ meta: M | null;
1562
+ error: string | null;
1563
+ }
1564
+
1481
1565
  export interface ProjectPagesGetResult {
1482
- /** Contents of session-manager-operations/project-pages/home.html, or null when it has not been generated. */
1566
+ /** Knowledge pages, newest first. */
1567
+ knowledge: ProjectLibraryEntry<ProjectPageMeta>[];
1568
+ /** Videos, newest first. */
1569
+ videos: ProjectLibraryEntry<ProjectVideoMeta>[];
1570
+ /** Contents of the `overview` knowledge page, or null when there is none. */
1483
1571
  html: string | null;
1484
- /** home.html's mtime, or null when `html` is null. */
1572
+ /** The overview page's mtime, or null when `html` is null. */
1485
1573
  mtimeMs: number | null;
1486
- /** project-pages/demo-video/index.html's absolute path + mtime, or null when it does not exist. Load it via smfile:// — never pass its HTML across IPC. */
1574
+ /** The newest video's absolute path + mtime, or null when there is none. Load it via smfile:// — never pass its HTML across IPC. */
1487
1575
  demoVideo: { path: string; mtimeMs: number } | null;
1488
1576
  }
1489
1577
 
@@ -1790,6 +1878,8 @@ export interface SessionManagerAPI {
1790
1878
  /** Full untruncated single-line read via a classifier byte reference (expand-to-full path). */
1791
1879
  readRef: (ref: TranscriptEventRef) => Promise<{ ok: boolean; text?: string; error?: string }>;
1792
1880
  pathFor: (cwd: string, sessionUuid: string) => Promise<string>;
1881
+ /** Does the claude JSONL transcript for this session exist? Remote-readable. */
1882
+ exists: (cwd: string, sessionUuid: string) => Promise<boolean>;
1793
1883
  /** Batched token-usage totals, one map entry per requested sessionId. A
1794
1884
  * session with no transcript file yet (or one over the main-process size
1795
1885
  * cap) maps to null. */
@@ -1868,6 +1958,10 @@ export interface SessionManagerAPI {
1868
1958
  delete: (payload: { id: string }) => Promise<{ ok: boolean }>;
1869
1959
  /** Add/remove one project cwd. A macro shown in every project (`'*'`) cannot be narrowed: `{ ok: false, error: 'macro is shown in every project' }`. */
1870
1960
  setProject: (payload: { id: string; cwd: string; enabled: boolean }) => Promise<{ ok: true; macro: Macro } | { ok: false; error: string }>;
1961
+ /** Dispatch a built-in macro's background build as a scheduler job. */
1962
+ dispatchJob: (payload: MacroJobDispatchInput) => Promise<MacroJobDispatchResult>;
1963
+ /** Status of this project's macro background builds. */
1964
+ jobStatus: (payload: { cwd: string }) => Promise<MacroJobStatus[]>;
1871
1965
  /** Fires after any save/delete/setProject — re-fetch list(). */
1872
1966
  onChanged: (handler: () => void) => () => void;
1873
1967
  };
@@ -2168,13 +2262,17 @@ export interface SessionManagerAPI {
2168
2262
  update: (cwd: string, patch: ProjectBriefPatch) => Promise<ProjectBriefUpdateResult>;
2169
2263
  };
2170
2264
  projectPages: {
2171
- /** Read project-pages/home.html (`{html: null, mtimeMs: null}` if it does not exist yet). Never fires an LLM call. */
2265
+ /** Read the project-pages library (knowledge/<id>/ pages and videos/<id>/ videos, each with its meta) as a `ProjectPagesGetResult`; empty lists if nothing exists yet. Never fires an LLM call. */
2172
2266
  get: (cwd: string) => Promise<ProjectPagesGetResult>;
2173
2267
  /** Start pushing `onChanged` events for this cwd's output dir. Refcounted per cwd; `ok:false` (reason 'ephemeral'|'invalid-cwd') means no live updates are possible, not an error. */
2174
2268
  watch: (cwd: string) => Promise<{ ok: boolean; reason?: 'ephemeral' | 'invalid-cwd' }>;
2175
2269
  /** Stop pushing `onChanged` events for this cwd — must be paired 1:1 with a prior `watch` call. */
2176
2270
  unwatch: (cwd: string) => Promise<{ ok: boolean }>;
2177
- /** Fires whenever a watched cwd's home.html is added/changed/removed, carrying the freshly read result. */
2271
+ /** Rewrite one library entry's meta.json title. Rejects on a bad id, missing entry or invalid meta. */
2272
+ rename: (cwd: string, kind: 'knowledge' | 'video', id: string, title: string) => Promise<{ ok: true; title: string }>;
2273
+ /** Remove exactly one library entry folder. Rejects on a bad id or missing entry. */
2274
+ delete: (cwd: string, kind: 'knowledge' | 'video', id: string) => Promise<{ ok: true }>;
2275
+ /** Fires whenever a watched cwd's knowledge/videos library is added/changed/removed, carrying the freshly read library result. */
2178
2276
  onChanged: (handler: (payload: { cwd: string } & ProjectPagesGetResult) => void) => () => void;
2179
2277
  };
2180
2278
  promptSessionTranscript: {
@@ -2302,6 +2400,14 @@ export interface SessionManagerAPI {
2302
2400
  * (lib/epic/activeIndexMerge.cjs) — persistActiveIndex sends only its own
2303
2401
  * in-memory contribution for the cwd; disk stays main's truth, merged
2304
2402
  * inside the same lock epicMint.cjs's ensureEpic serializes through. */
2403
+ /** Read-tier (remote-safe) Sessions reads, fenced to a registered project's
2404
+ * prompt-sessions ops dir (main/promptSessionsIpc.cjs). Reject on a cwd
2405
+ * that is not a registered project root. */
2406
+ loadActiveIndex: (payload: { cwd: string }) => Promise<{ exists: boolean; data: unknown; error?: string }>;
2407
+ listArchived: (payload: { cwd: string }) => Promise<{ ok: boolean; ids: string[]; error?: string }>;
2408
+ readArchived: (payload: { cwd: string; epicId: string }) => Promise<{ exists: boolean; data: unknown; error?: string }>;
2409
+ readSessionTranscript: (payload: { cwd: string; sessionId: string }) => Promise<{ exists: boolean; text: string; error?: string }>;
2410
+ writeArchive: (payload: { cwd: string; epicId: string; archive: Record<string, unknown> }) => Promise<{ ok: true }>;
2305
2411
  mergeActiveIndex: (payload: PromptSessionsMergeActiveIndexPayload) => Promise<PromptSessionsMergeActiveIndexResult>;
2306
2412
  /** Mints a brand-new 'proposed' Epic through main's own ensureEpic()
2307
2413
  * (lib/epic/promptSessionsCreateEpic.cjs) instead of the renderer
@@ -279,6 +279,13 @@
279
279
  "kind": "invoke",
280
280
  "remote": "read"
281
281
  },
282
+ {
283
+ "ns": "transcripts",
284
+ "method": "exists",
285
+ "channel": "transcript:exists",
286
+ "kind": "invoke",
287
+ "remote": "read"
288
+ },
282
289
  {
283
290
  "ns": "transcripts",
284
291
  "method": "usageFor",
@@ -433,6 +440,20 @@
433
440
  "kind": "invoke",
434
441
  "remote": "mutate"
435
442
  },
443
+ {
444
+ "ns": "macros",
445
+ "method": "dispatchJob",
446
+ "channel": "macros:dispatch-job",
447
+ "kind": "invoke",
448
+ "remote": "mutate"
449
+ },
450
+ {
451
+ "ns": "macros",
452
+ "method": "jobStatus",
453
+ "channel": "macros:job-status",
454
+ "kind": "invoke",
455
+ "remote": "read"
456
+ },
436
457
  {
437
458
  "ns": "macros",
438
459
  "method": "onChanged",
@@ -1301,6 +1322,20 @@
1301
1322
  "kind": "invoke",
1302
1323
  "remote": "mutate"
1303
1324
  },
1325
+ {
1326
+ "ns": "projectPages",
1327
+ "method": "rename",
1328
+ "channel": "project-pages:rename",
1329
+ "kind": "invoke",
1330
+ "remote": "mutate"
1331
+ },
1332
+ {
1333
+ "ns": "projectPages",
1334
+ "method": "delete",
1335
+ "channel": "project-pages:delete",
1336
+ "kind": "invoke",
1337
+ "remote": "mutate"
1338
+ },
1304
1339
  {
1305
1340
  "ns": "projectPages",
1306
1341
  "method": "onChanged",
@@ -1651,6 +1686,41 @@
1651
1686
  "kind": "invoke",
1652
1687
  "remote": "mutate"
1653
1688
  },
1689
+ {
1690
+ "ns": "promptSessions",
1691
+ "method": "loadActiveIndex",
1692
+ "channel": "promptSessions:load-active-index",
1693
+ "kind": "invoke",
1694
+ "remote": "read"
1695
+ },
1696
+ {
1697
+ "ns": "promptSessions",
1698
+ "method": "listArchived",
1699
+ "channel": "promptSessions:list-archived",
1700
+ "kind": "invoke",
1701
+ "remote": "read"
1702
+ },
1703
+ {
1704
+ "ns": "promptSessions",
1705
+ "method": "readArchived",
1706
+ "channel": "promptSessions:read-archived",
1707
+ "kind": "invoke",
1708
+ "remote": "read"
1709
+ },
1710
+ {
1711
+ "ns": "promptSessions",
1712
+ "method": "readSessionTranscript",
1713
+ "channel": "promptSessions:read-session-transcript",
1714
+ "kind": "invoke",
1715
+ "remote": "read"
1716
+ },
1717
+ {
1718
+ "ns": "promptSessions",
1719
+ "method": "writeArchive",
1720
+ "channel": "promptSessions:write-archive",
1721
+ "kind": "invoke",
1722
+ "remote": "mutate"
1723
+ },
1654
1724
  {
1655
1725
  "ns": "promptSessions",
1656
1726
  "method": "createWorktree",
@@ -85,6 +85,8 @@ contextBridge.exposeInMainWorld('api', {
85
85
  readRef: (ref) => ipcRenderer.invoke('transcript:readRef', ref),
86
86
  pathFor: (cwd, sessionUuid) =>
87
87
  ipcRenderer.invoke('transcript:path', { cwd, sessionUuid }),
88
+ exists: (cwd, sessionUuid) =>
89
+ ipcRenderer.invoke('transcript:exists', { cwd, sessionUuid }),
88
90
  usageFor: (cwd, sessionIds) =>
89
91
  ipcRenderer.invoke('transcript:usageFor', { cwd, sessionIds }),
90
92
  // Main sends one batch (array) per flush — see transcripts.cjs's doFlush —
@@ -135,6 +137,8 @@ contextBridge.exposeInMainWorld('api', {
135
137
  save: (payload) => ipcRenderer.invoke('macros:save', payload),
136
138
  delete: (payload) => ipcRenderer.invoke('macros:delete', payload),
137
139
  setProject: (payload) => ipcRenderer.invoke('macros:set-project', payload),
140
+ dispatchJob: (payload) => ipcRenderer.invoke('macros:dispatch-job', payload),
141
+ jobStatus: (payload) => ipcRenderer.invoke('macros:job-status', payload),
138
142
  // Fired after any save/delete/set-project so every subscriber re-fetches list().
139
143
  onChanged: (handler) => {
140
144
  const listener = () => handler();
@@ -378,6 +382,8 @@ contextBridge.exposeInMainWorld('api', {
378
382
  get: (cwd) => ipcRenderer.invoke('project-pages:get', { cwd }),
379
383
  watch: (cwd) => ipcRenderer.invoke('project-pages:watch', { cwd }),
380
384
  unwatch: (cwd) => ipcRenderer.invoke('project-pages:unwatch', { cwd }),
385
+ rename: (cwd, kind, id, title) => ipcRenderer.invoke('project-pages:rename', { cwd, kind, id, title }),
386
+ delete: (cwd, kind, id) => ipcRenderer.invoke('project-pages:delete', { cwd, kind, id }),
381
387
  onChanged: (handler) => {
382
388
  const listener = (_e, payload) => handler(payload);
383
389
  ipcRenderer.on('project-pages:changed', listener);
@@ -584,5 +590,12 @@ contextBridge.exposeInMainWorld('api', {
584
590
  archiveTranscript: (payload) => ipcRenderer.invoke('promptSessions:archiveTranscript', payload),
585
591
  /** Reopens a completed Epic in place (same id + claudeSessionId); never mints an Epic. */
586
592
  reopen: (payload) => ipcRenderer.invoke('promptSessions:reopen', payload),
593
+ /** Read-tier (remote-safe) Sessions reads — see main/promptSessionsIpc.cjs. */
594
+ loadActiveIndex: (payload) => ipcRenderer.invoke('promptSessions:load-active-index', payload),
595
+ listArchived: (payload) => ipcRenderer.invoke('promptSessions:list-archived', payload),
596
+ readArchived: (payload) => ipcRenderer.invoke('promptSessions:read-archived', payload),
597
+ readSessionTranscript: (payload) => ipcRenderer.invoke('promptSessions:read-session-transcript', payload),
598
+ /** Mutate-tier archive write for markCompleted (main builds the path; single-writer 'epics'). */
599
+ writeArchive: (payload) => ipcRenderer.invoke('promptSessions:write-archive', payload),
587
600
  },
588
601
  });