claude-code-session-manager 0.138.0 → 0.140.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 (194) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +352 -79
  3. package/dist/assets/AppSettings-CMFEM68R.js +2 -0
  4. package/dist/assets/History--JwsFnbn.js +2 -0
  5. package/dist/assets/HomeClaudeConfig-ijEXs--3.js +3 -0
  6. package/dist/assets/{Panel-CeDiyuNn.js → Panel-CALyU0pe.js} +1 -1
  7. package/dist/assets/ProjectClaudeConfig-sdlA-fUb.js +26 -0
  8. package/dist/assets/Scheduler-YT3j8SUa.js +16 -0
  9. package/dist/assets/{SkillReferenceGraph-CFMK8NJh.js → SkillReferenceGraph-CxAuwhNN.js} +1 -1
  10. package/dist/assets/Skills-DtRzghn5.js +67 -0
  11. package/dist/assets/{TiptapBody-D1kTj-tn.js → TiptapBody-DApeu7x8.js} +60 -54
  12. package/dist/assets/ViewTabs-B7qLXRAH.js +1 -0
  13. package/dist/assets/{VoiceButton-CZeyPM31.js → VoiceButton-DtStfv1H.js} +1 -1
  14. package/dist/assets/{historyTotals-B00l64Jw.js → historyTotals-ydfnwepc.js} +1 -1
  15. package/dist/assets/index-CtxruO1L.js +3121 -0
  16. package/dist/assets/{index-62tyjEQB.css → index-DKXdXfka.css} +1 -1
  17. package/dist/index.html +2 -2
  18. package/dist-web/app.css +1 -1
  19. package/dist-web/app.js +467 -451
  20. package/package.json +17 -6
  21. package/plugins/AGENTS.md +60 -0
  22. package/plugins/CLAUDE.md +1 -60
  23. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  24. package/plugins/session-manager-dev/skills/builder/SKILL.md +12 -4
  25. package/plugins/session-manager-dev/skills/builder/scripts/publish-preflight.cjs +255 -0
  26. package/plugins/session-manager-dev/skills/develop/SKILL.md +36 -22
  27. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +5 -4
  28. package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +4 -2
  29. package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +16 -12
  30. package/plugins/session-manager-dev/skills/maintaining-md-network/migrate-to-agents-md.md +15 -0
  31. package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +50 -2
  32. package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +10 -10
  33. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +117 -112
  34. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdDuplicates.cjs +182 -0
  35. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs +340 -0
  36. package/scripts/README.md +2 -0
  37. package/scripts/hooks/guard-tool-risk.cjs +91 -0
  38. package/scripts/hooks/lib/guard-tool-risk-policy.cjs +217 -0
  39. package/scripts/ops-sweep.cjs +53 -23
  40. package/scripts/scheduler-mcp-server.cjs +360 -35
  41. package/src/main/build-info.json +4 -4
  42. package/src/main/chatRunner.cjs +2 -2
  43. package/src/main/config.cjs +112 -8
  44. package/src/main/docEdit.cjs +6 -1
  45. package/src/main/exchanges.cjs +70 -5
  46. package/src/main/files.cjs +7 -27
  47. package/src/main/health.cjs +48 -15
  48. package/src/main/historyAggregator.cjs +172 -63
  49. package/src/main/historyDashboard.cjs +87 -17
  50. package/src/main/index.cjs +78 -4
  51. package/src/main/ipcSchemas.cjs +233 -20
  52. package/src/main/lib/AGENTS.md +54 -0
  53. package/src/main/lib/CLAUDE.md +1 -54
  54. package/src/main/lib/agent-cli/adapters/codex.cjs +5 -2
  55. package/src/main/lib/agent-cli/agentCliIpc.cjs +18 -2
  56. package/src/main/lib/agent-cli/agentCliSessionStore.cjs +1 -0
  57. package/src/main/lib/agent-cli/agentCliTurn.cjs +20 -2
  58. package/src/main/lib/agent-cli/geminiContextDefaults.cjs +94 -0
  59. package/src/main/lib/claude/effectiveModelInfo.cjs +92 -22
  60. package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -0
  61. package/src/main/lib/claude/modelPricing.cjs +148 -0
  62. package/src/main/lib/claude/personaToolScope.cjs +12 -6
  63. package/src/main/lib/claude/rateLimitDetect.cjs +13 -2
  64. package/src/main/lib/claude/runClaudeP.cjs +6 -1
  65. package/src/main/lib/claude/toolRiskIpc.cjs +177 -0
  66. package/src/main/lib/claude/toolRiskMarks.cjs +373 -0
  67. package/src/main/lib/demo-video-kit/seedKit.cjs +27 -6
  68. package/src/main/lib/ephemeralCwd.cjs +37 -2
  69. package/src/main/lib/epic/delegationReadiness.cjs +42 -9
  70. package/src/main/lib/epic/epicAdminRoutes.cjs +121 -0
  71. package/src/main/lib/epic/epicJobReceipt.cjs +87 -0
  72. package/src/main/lib/epic/epicOutsideRead.cjs +423 -0
  73. package/src/main/lib/epic/epicOutsideState.cjs +233 -0
  74. package/src/main/lib/epic/epicSettle.cjs +1 -1
  75. package/src/main/lib/epic/epicStateWatcher.cjs +157 -0
  76. package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
  77. package/src/main/lib/epic/epicValidationHook.cjs +24 -4
  78. package/src/main/lib/epic/externalRef.cjs +37 -0
  79. package/src/main/lib/epic/externalRefIndex.cjs +136 -0
  80. package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
  81. package/src/main/lib/epic/restorableSessions.cjs +151 -17
  82. package/src/main/lib/epic/transcriptUsage.cjs +197 -0
  83. package/src/main/lib/externalContract.cjs +137 -0
  84. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +176 -5
  85. package/src/main/lib/feedback-remote/crossProjectReply.cjs +186 -9
  86. package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +16 -6
  87. package/src/main/lib/feedback-remote/customerFeedbackClient.cjs +50 -8
  88. package/src/main/lib/feedback-remote/customerFeedbackInbox.cjs +218 -4
  89. package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +19 -3
  90. package/src/main/lib/feedback-remote/feedbackImages.cjs +171 -0
  91. package/src/main/lib/feedback-remote/localAdminHttp.cjs +11 -10
  92. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +167 -21
  93. package/src/main/lib/feedback-remote/needsYouAdminRoutes.cjs +133 -0
  94. package/src/main/lib/feedback-remote/needsYouIpc.cjs +50 -0
  95. package/src/main/lib/feedback-remote/needsYouStore.cjs +285 -0
  96. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +98 -1
  97. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +5 -0
  98. package/src/main/lib/git/branchSweep.cjs +209 -4
  99. package/src/main/lib/git/gitWorktree.cjs +41 -5
  100. package/src/main/lib/guardShims.cjs +1 -1
  101. package/src/main/lib/historyRollup.cjs +58 -5
  102. package/src/main/lib/insideHome.cjs +27 -1
  103. package/src/main/lib/mcpToolCatalog.cjs +232 -25
  104. package/src/main/lib/mdDocCensus.cjs +59 -78
  105. package/src/main/lib/mdDocRefs.cjs +71 -93
  106. package/src/main/lib/mdNetworkScan.cjs +245 -250
  107. package/src/main/lib/mdReviewRecord.cjs +22 -9
  108. package/src/main/lib/memoryMdNetwork.cjs +5 -12
  109. package/src/main/lib/opsOwnership.cjs +18 -2
  110. package/src/main/lib/opsRetentionSettings.cjs +28 -4
  111. package/src/main/lib/persona-macro/agentAdminRoutes.cjs +121 -0
  112. package/src/main/lib/persona-macro/macroJobDispatch.cjs +90 -20
  113. package/src/main/lib/persona-macro/macroJobIpc.cjs +144 -46
  114. package/src/main/lib/persona-macro/macroJobStatus.cjs +87 -9
  115. package/src/main/lib/persona-macro/macroLibrary.cjs +95 -5
  116. package/src/main/lib/persona-macro/personaImportHealth.cjs +78 -17
  117. package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +96 -0
  118. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
  119. package/src/main/lib/prd/depSlugResolve.cjs +104 -4
  120. package/src/main/lib/prd/prdAdminRoutes.cjs +35 -2
  121. package/src/main/lib/prd/prdCreate.cjs +351 -23
  122. package/src/main/lib/prd/prdDisposition.cjs +11 -2
  123. package/src/main/lib/prd/prdFrontmatter.cjs +96 -3
  124. package/src/main/lib/process/loginItem.cjs +171 -0
  125. package/src/main/lib/process/loginItemPlan.cjs +193 -0
  126. package/src/main/lib/project-pages/playerBridge.cjs +4 -0
  127. package/src/main/lib/project-pages/videoReview.cjs +268 -0
  128. package/src/main/lib/project-pages/videoReviewIpc.cjs +229 -0
  129. package/src/main/lib/promptSessionSchema.cjs +4 -0
  130. package/src/main/lib/remoteTranscriptTail.cjs +32 -1
  131. package/src/main/lib/scheduler/cpuSample.cjs +131 -4
  132. package/src/main/lib/scheduler/fixPlanSlug.cjs +4 -3
  133. package/src/main/lib/scheduler/loadGate.cjs +24 -6
  134. package/src/main/lib/scheduler/planRecordHarvest.cjs +108 -0
  135. package/src/main/lib/scheduler/planRecordRetention.cjs +144 -0
  136. package/src/main/lib/scheduler/queueStore.cjs +7 -0
  137. package/src/main/lib/scheduler/rcaReport.cjs +21 -1
  138. package/src/main/lib/scheduler/reaperHelpers.cjs +35 -5
  139. package/src/main/lib/scheduler/runLogRetention.cjs +104 -3
  140. package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
  141. package/src/main/lib/scheduler/schedulerBatch.cjs +25 -48
  142. package/src/main/lib/scheduler/schedulerPaths.cjs +12 -0
  143. package/src/main/lib/scheduler/sessionSlots.cjs +176 -21
  144. package/src/main/lib/scheduler/validationQuality.cjs +282 -0
  145. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +254 -0
  146. package/src/main/lib/tasks/taskAdminRoutes.cjs +641 -0
  147. package/src/main/lib/tasks/taskIpc.cjs +80 -0
  148. package/src/main/lib/tasks/taskLedger.cjs +502 -0
  149. package/src/main/lib/tasks/taskRun.cjs +313 -0
  150. package/src/main/lib/tasks/taskSwitch.cjs +120 -0
  151. package/src/main/lib/telemetry/auditEvents.cjs +176 -0
  152. package/src/main/lib/telemetry/eventsAdminRoutes.cjs +45 -0
  153. package/src/main/loginItemIpc.cjs +35 -0
  154. package/src/main/loopEfficiencyHandlers.cjs +11 -2
  155. package/src/main/projectPages.cjs +6 -15
  156. package/src/main/promptSessionEvents.cjs +9 -1
  157. package/src/main/queueOps.cjs +260 -3
  158. package/src/main/runVerify.cjs +53 -25
  159. package/src/main/scheduler/AGENTS.md +26 -0
  160. package/src/main/scheduler/CLAUDE.md +1 -26
  161. package/src/main/scheduler/budget.cjs +239 -9
  162. package/src/main/scheduler/cancelDependents.cjs +154 -0
  163. package/src/main/scheduler/prdParser.cjs +4 -1
  164. package/src/main/scheduler/starvation.cjs +20 -18
  165. package/src/main/scheduler.cjs +774 -64
  166. package/src/main/supervisor.cjs +5 -1
  167. package/src/main/templates/PRD_AUTHORING.md +7 -1
  168. package/src/main/transcripts.cjs +62 -7
  169. package/src/main/validationQualityHandlers.cjs +199 -0
  170. package/src/main/webRemote.cjs +132 -20
  171. package/src/preload/api.d.ts +434 -28
  172. package/src/preload/apiSurface.cjs +7 -0
  173. package/src/preload/apiSurface.json +485 -81
  174. package/src/preload/index.cjs +38 -5
  175. package/src/seed/agents/validator.md +19 -8
  176. package/dist/assets/AgentLibrary-C1d_D7uQ.js +0 -2
  177. package/dist/assets/AppSettings-CgDhqrsU.js +0 -2
  178. package/dist/assets/Button-Bk23rEnZ.js +0 -1
  179. package/dist/assets/DocumentEditorPane-BqY5Nq6W.js +0 -1
  180. package/dist/assets/Extensions-CXem-uwI.js +0 -2
  181. package/dist/assets/History-BwO3coo4.js +0 -2
  182. package/dist/assets/Library-BDV69fSe.js +0 -32
  183. package/dist/assets/ListDetail-CD-Fm6mh.js +0 -1
  184. package/dist/assets/ProjectClaudeConfig-NjdKdwe8.js +0 -25
  185. package/dist/assets/ProvenanceBadge-Bu8NmI_R.js +0 -1
  186. package/dist/assets/Scheduler-CkhTvG7C.js +0 -16
  187. package/dist/assets/Settings-COT34hBF.js +0 -2
  188. package/dist/assets/Skills-BgexoUkQ.js +0 -29
  189. package/dist/assets/SourceChip-BXjcdeb1.js +0 -1
  190. package/dist/assets/SystemPrompt-CeeH3EeW.js +0 -1
  191. package/dist/assets/Toggle-CENi19iK.js +0 -1
  192. package/dist/assets/ViewTabs-DDBb0x96.js +0 -1
  193. package/dist/assets/claude-settings-schema-COigsajx.js +0 -3
  194. package/dist/assets/index-CgCxpunJ.js +0 -3116
@@ -102,6 +102,15 @@ macroAdminRoutes.registerAdminRoute(adminHttp, {
102
102
  isTabBusy: chatRunner.isTabBusy,
103
103
  });
104
104
  chatRunner.registerAdminRoute(adminHttp);
105
+ // Outside apps' "Needs you" items (lib/feedback-remote/needsYouStore.cjs); changes broadcast `needsYou:changed`.
106
+ function broadcastNeedsYouChanged() {
107
+ sendIfAlive(mainWindow, 'needsYou:changed', {});
108
+ }
109
+ require('./lib/feedback-remote/needsYouAdminRoutes.cjs').registerAdminRoute(adminHttp, {
110
+ onChanged: broadcastNeedsYouChanged,
111
+ });
112
+ // The Dashboard's side: list open items + record the owner's answer (same broadcast).
113
+ require('./lib/feedback-remote/needsYouIpc.cjs').registerNeedsYouIpc({ ipcMain, onChanged: broadcastNeedsYouChanged });
105
114
  // Project-to-project feedback conduit — the app is the only process holding
106
115
  // several projects' operations roots open, so it performs the cross-folder
107
116
  // write (lib/feedback-remote/crossProjectFeedback.cjs).
@@ -110,6 +119,21 @@ crossProjectFeedback.registerAdminRoute(adminHttp);
110
119
  // (lib/feedback-remote/crossProjectReply.cjs).
111
120
  require('./lib/feedback-remote/crossProjectReply.cjs').registerAdminRoute(adminHttp);
112
121
  require('./lib/feedback-remote/customerFeedbackAdminRoutes.cjs').registerAdminRoute(adminHttp);
122
+ // Cursor read over the audit log for outside scripts (read-only).
123
+ require('./lib/telemetry/eventsAdminRoutes.cjs').registerAdminRoute(adminHttp);
124
+ // Outside-facing Epic records for scripts/other projects (read-only).
125
+ require('./lib/epic/epicAdminRoutes.cjs').registerAdminRoute(adminHttp, {
126
+ isTabBusy: chatRunner.isTabBusy,
127
+ listJobs: () => scheduler.remote.listJobs(),
128
+ });
129
+ // Validator quality numbers per project for outside callers (read-only).
130
+ require('./validationQualityHandlers.cjs').registerAdminRoute(adminHttp);
131
+ // Persona roster + per-project effective model/effort for outside apps (read-only).
132
+ require('./lib/persona-macro/agentAdminRoutes.cjs').registerAdminRoute(adminHttp);
133
+ // Task primitive: one headless claude -p run for a project, under the slot cap (POST /admin/tasks).
134
+ require('./lib/tasks/taskAdminRoutes.cjs').registerAdminRoute(adminHttp);
135
+ // The scheduler tick turns Epic state changes into epic_state_changed audit rows.
136
+ require('./lib/epic/epicStateWatcher.cjs').configureEpicStateWatcher({ isTabBusy: chatRunner.isTabBusy });
113
137
  const supervisor = require('./supervisor.cjs');
114
138
  const watchers = require('./watchers.cjs');
115
139
  const queueOps = require('./queueOps.cjs');
@@ -126,6 +150,7 @@ const { registerHistoryAggregatorHandlers, finalizeClosedDays, refreshIntradayTo
126
150
  const runLogRetention = require('./lib/scheduler/runLogRetention.cjs');
127
151
  const { registerHistoryDashboardHandlers } = require('./historyDashboard.cjs');
128
152
  const { registerLoopEfficiencyHandlers } = require('./loopEfficiencyHandlers.cjs');
153
+ const { registerValidationQualityHandlers } = require('./validationQualityHandlers.cjs');
129
154
  const { tryAcquireLock, releaseLock, DEFAULT_LOCK_PATH } = require('./lib/scheduler/watchdogHelpers.cjs');
130
155
  const { createIntradayRefresh } = require('./lib/intradayRefresh.cjs');
131
156
  const schedulerConfig = require('./lib/scheduler/schedulerConfig.cjs');
@@ -161,6 +186,7 @@ const webRemote = require('./webRemote.cjs');
161
186
  const { registerAgentsHandlers } = require('./agentsIpc.cjs');
162
187
  const { registerTelemetryHandlers } = require('./telemetryIpc.cjs');
163
188
  const { registerUpdaterIpc } = require('./updaterIpc.cjs');
189
+ const { registerLoginItemIpc } = require('./loginItemIpc.cjs');
164
190
  const { listExchanges } = require('./exchanges.cjs');
165
191
  const { resolveClaudeBin } = require('./lib/claude/claudeBin.cjs');
166
192
  const { checkInsideHome, assertInsideHome } = require('./lib/insideHome.cjs');
@@ -622,7 +648,7 @@ function broadcastMacrosChanged() {
622
648
  ipcMain.handle('macros:list', () => macroLibrary.listMacros());
623
649
  // Background macro jobs: dispatch a built-in macro as a scheduler PRD inside an existing Epic.
624
650
  // createPrd is wired exactly as chat:create-prd (below) so its own reconcile request queues the row.
625
- require('./lib/persona-macro/macroJobIpc.cjs').registerMacroJobIpc(ipcMain, {
651
+ const macroJobIpcDeps = {
626
652
  schemas,
627
653
  validatePath: require('./config.cjs').validatePath,
628
654
  readActiveIndex: require('./lib/epic/epicMint.cjs').readActiveIndex,
@@ -631,7 +657,11 @@ require('./lib/persona-macro/macroJobIpc.cjs').registerMacroJobIpc(ipcMain, {
631
657
  archivePrd: (slug, cwd) => queueOps.archiveMany([slug], cwd),
632
658
  // Durable 'job-not-queued' notice on the Epic when a dispatch fails (PRD 2950).
633
659
  appendResponseEventWithReason: promptSessionEvents.appendResponseEventWithReason,
634
- });
660
+ };
661
+ require('./lib/persona-macro/macroJobIpc.cjs').registerMacroJobIpc(ipcMain, macroJobIpcDeps);
662
+ // Project Video review step: list + human decide (approve / ask for changes). Same deps
663
+ // as macroJobIpc — a decision dispatches through runToolJob. Renderer IPC only.
664
+ require('./lib/project-pages/videoReviewIpc.cjs').registerVideoReviewIpc(ipcMain, macroJobIpcDeps);
635
665
  // claudeConfig (lib/claudeConfig.cjs): key-scoped read/patch of Claude's JSON config files.
636
666
  // A successful patch broadcasts `config:changed` so renderer state refreshes.
637
667
  ipcMain.handle('claudeConfig:read', validated(schemas.claudeConfigRead, async (p) => {
@@ -646,7 +676,27 @@ ipcMain.handle('claudeConfig:patch', validated(schemas.claudeConfigPatch, async
646
676
  sendIfAlive(mainWindow, 'config:changed', { path: result.path, mtimeMs, kind: 'change' });
647
677
  return result;
648
678
  }));
679
+ // toolRisk (lib/claude/toolRiskIpc.cjs): System/Project tool-risk marks + the Project
680
+ // interactive opt-in that installs/removes guard-tool-risk in <cwd>/.claude/settings.json.
681
+ require('./lib/claude/toolRiskIpc.cjs').registerToolRiskIpc(ipcMain, {
682
+ schemas,
683
+ validated,
684
+ validatePath: configMgr.validatePath,
685
+ onChanged: ({ path: changedPath }) => sendIfAlive(mainWindow, 'config:changed', { path: changedPath, mtimeMs: Date.now(), kind: 'change' }),
686
+ });
649
687
  ipcMain.handle('macros:save', validated(schemas.macrosSave, async (payload) => {
688
+ // A Project Video tool with a job must be runnable by its persona (projectVideoToolCheck.cjs);
689
+ // a refusal throws so the editor shows the reason. Every other save is unchanged.
690
+ const existing = payload.id ? (await macroLibrary.listMacros()).find((m) => m.id === payload.id) : undefined;
691
+ const surface = payload.surface ?? existing?.surface;
692
+ const job = payload.job !== undefined ? payload.job : existing?.job;
693
+ const projects = payload.projects ?? existing?.projects;
694
+ if (surface === 'project-video' && job && typeof job === 'object'
695
+ && Array.isArray(projects) && projects.length === 1 && projects[0] !== macroLibrary.ALL_PROJECTS) {
696
+ const { checkProjectVideoToolRunnable } = require('./lib/persona-macro/projectVideoToolCheck.cjs');
697
+ const verdict = await checkProjectVideoToolRunnable({ cwd: projects[0], agentName: payload.agentName, job });
698
+ if (!verdict.ok) throw new Error(verdict.error);
699
+ }
650
700
  const macro = await macroLibrary.saveMacro(payload);
651
701
  broadcastMacrosChanged();
652
702
  return macro;
@@ -1083,6 +1133,7 @@ queueOps.registerQueueOpsHandlers({ retireCompletedSlugs: scheduler.retireComple
1083
1133
  registerHistoryAggregatorHandlers();
1084
1134
  registerHistoryDashboardHandlers();
1085
1135
  registerLoopEfficiencyHandlers();
1136
+ registerValidationQualityHandlers();
1086
1137
  pluginInstall.registerPluginInstallHandlers();
1087
1138
  memoryTool.registerMemoryHandlers();
1088
1139
  activeIndexMerge.registerActiveIndexMergeHandlers();
@@ -1099,6 +1150,7 @@ epicWorktreeProjectConfig.registerEpicWorktreeProjectConfigHandlers();
1099
1150
  registerMemoryAggregateIpc();
1100
1151
  registerProjectBriefIpc();
1101
1152
  registerProjectPagesIpc();
1153
+ require('./lib/tasks/taskIpc.cjs').registerTaskIpc({ ipcMain });
1102
1154
  ipcMain.handle('promptSessionTranscript:append', validated(schemas.promptSessionTranscriptAppend, async ({ cwd, epicId, role, text, at, eventId }) => {
1103
1155
  const ok = await promptSessionTranscript.appendTurn(cwd, epicId, { role, text, at, eventId });
1104
1156
  return { ok };
@@ -1114,8 +1166,8 @@ ipcMain.handle('epicDelegationStats:get', validated(schemas.epicDelegationStatsG
1114
1166
  }));
1115
1167
  // Renderer Epic lifecycle trace (PRD 940) — append-only, no read/list IPC.
1116
1168
  // Kind allowlist enforced by schemas.auditLogAppend, not here.
1117
- ipcMain.handle('auditLog:append', validated(schemas.auditLogAppend, async ({ kind, cwd, epicId, source }) => {
1118
- appendAuditEvent(kind, { cwd, epicId, source });
1169
+ ipcMain.handle('auditLog:append', validated(schemas.auditLogAppend, async ({ kind, cwd, epicId, source, fromEpicId }) => {
1170
+ appendAuditEvent(kind, { cwd, epicId, source, ...(fromEpicId ? { fromEpicId } : {}) });
1119
1171
  return { ok: true };
1120
1172
  }));
1121
1173
  git.register(ipcMain);
@@ -1130,6 +1182,25 @@ try {
1130
1182
  } catch (e) {
1131
1183
  logs.writeLine({ scope: 'main', level: 'error', message: 'updater IPC registration failed', meta: { error: e?.message } });
1132
1184
  }
1185
+ try {
1186
+ const { createLoginItem } = require('./lib/process/loginItem.cjs');
1187
+ const loginItem = createLoginItem({
1188
+ app,
1189
+ platform: process.platform,
1190
+ packaged: isPackagedApp(),
1191
+ dev: process.env.SM_DEV === '1' || process.env.SM_E2E === '1',
1192
+ homeDir: os.homedir(),
1193
+ env: process.env,
1194
+ appId: 'run.bilko.session-manager',
1195
+ resolveNpx,
1196
+ warn: (message, meta) => logs.writeLine({ scope: 'main', level: 'warn', message, meta }),
1197
+ });
1198
+ registerLoginItemIpc({ ipcMain, loginItem });
1199
+ // Bring an enabled login item up to this build's script + entry; not awaited, never throws.
1200
+ void loginItem.refreshIfStale();
1201
+ } catch (e) {
1202
+ logs.writeLine({ scope: 'main', level: 'error', message: 'login item IPC registration failed', meta: { error: e?.message } });
1203
+ }
1133
1204
  try {
1134
1205
  require('./lib/opsRetentionSettings.cjs').registerIpc(ipcMain);
1135
1206
  } catch (e) {
@@ -1259,6 +1330,9 @@ function runRunLogRetentionPass() {
1259
1330
  removedFiles: (result.removedFiles || 0) + tmp.removedFiles + archive.removedFiles,
1260
1331
  freedBytes: (result.freedBytes || 0) + tmp.freedBytes + archive.freedBytes,
1261
1332
  errorCount: (result.errors ? result.errors.length : 0) + tmp.errors.length + archive.errors.length,
1333
+ // plan-records/<epic-id>/ of completed/orphan Epics, pruned inside runBootSweep
1334
+ // for the same project list readMergedSync swept (planRecordsDays knob).
1335
+ planRecords: result.planRecords || null,
1262
1336
  },
1263
1337
  });
1264
1338
  } catch (e) {
@@ -16,6 +16,7 @@ const { AgentPersonaSaveSchema, PersonaNameSchema, ProjectCwdSchema } = require(
16
16
  const { MacroSaveSchema, MacroDeleteSchema, MacroSetProjectSchema, MacroRemoveFromProjectSchema, MacroInputSchema } = require('./lib/persona-macro/macroLibrary.cjs');
17
17
  const { MAX_SLOTS } = require('./lib/scheduler/sessionSlots.cjs');
18
18
  const { PRD_EFFORT_LEVELS } = require('./lib/prd/prdFrontmatter.cjs');
19
+ const { MISS_KINDS } = require('./lib/scheduler/validatorVerdictSchema.cjs');
19
20
  // Aliased: this file already has a looser, exchanges-only SESSION_ID_RE (Exchanges section).
20
21
  const { SESSION_ID_RE: RESTORABLE_SESSION_ID_RE } = require('./lib/epic/restorableSessions.cjs');
21
22
 
@@ -127,10 +128,19 @@ const configWriteJson = z.object({
127
128
  writer: z.string().min(1).max(64).optional(),
128
129
  });
129
130
 
131
+ // `importedBy`: a CLAUDE.md / CLAUDE.local.md whose @-import closure main
132
+ // checks to allow writing an imported instruction file (config.cjs
133
+ // checkInstructionWrite). Main proves the import; the renderer only names it.
130
134
  const configWriteText = z.object({
131
135
  path: z.string().min(1).max(4096),
132
136
  text: z.string(),
133
137
  writer: z.string().min(1).max(64).optional(),
138
+ importedBy: z.string().min(1).max(4096).optional(),
139
+ });
140
+
141
+ const configCanWrite = z.object({
142
+ path: z.string().min(1).max(4096),
143
+ importedBy: z.string().min(1).max(4096).optional(),
134
144
  });
135
145
 
136
146
  const configListDir = z.object({
@@ -425,6 +435,11 @@ const DepSlugSchema = z.string().min(1).max(160).regex(/^[A-Za-z0-9][\w.-]*$/);
425
435
  // large /develop plan depends on every other slug in the plan, so this must
426
436
  // stay well above the largest plan size the PRD authoring flow allows.
427
437
  const MAX_DEPENDS_ON = 100;
438
+ // Tool-risk rule strings a PRD is cleared to call — shared by schedulerCreatePrd
439
+ // and adminPrdFrontmatterPatch so create and update accept the same shape.
440
+ // The rule grammar (toolRiskMarks.parseRule), de-dup and cap are re-checked by
441
+ // prdCreate.cjs's normalizeRiskTools on both paths.
442
+ const RiskToolsSchema = z.array(z.string().min(1).max(200)).max(20);
428
443
  // Wave-authoring decision (scheduler wave-disposition PRD), shared between
429
444
  // schedulerCreatePrd (authoring time) and adminPrdFrontmatterPatch (the
430
445
  // after-the-fact change path) so both can never disagree on what a valid
@@ -450,6 +465,18 @@ const schedulerCreatePrd = z.object({
450
465
  // Explicit ordering (PRD 832): slugs that must complete before this PRD
451
466
  // becomes eligible. Written to frontmatter as `dependsOn: [a, b]`.
452
467
  dependsOn: z.array(DepSlugSchema).max(MAX_DEPENDS_ON).optional(),
468
+ // Deliberate cross-Epic duplicate: exact NN slugs of other Epics' PRDs that
469
+ // share this PRD's bare slug. createPrd refuses such a duplicate (409) unless
470
+ // this lists every one of them (prdCreate.cjs findCrossEpicDuplicates).
471
+ allowDuplicateOf: z.array(z.string().min(1).max(160).regex(/^\d+-[A-Za-z0-9][\w.-]*$/, 'must be an exact NN-prefixed slug')).max(MAX_DEPENDS_ON).optional(),
472
+ // The earlier PRDs this PRD repairs (PRD prd-fixes-field). Bounds mirror
473
+ // prdCreate.cjs FIXES_MAX / FIX_REASON_MAX; createPrd resolves each prd to an
474
+ // existing NN slug and re-checks the shape (validateFixesShape).
475
+ fixes: z.array(z.object({
476
+ prd: z.string().min(1).max(160),
477
+ missKind: z.enum(/** @type {[string, ...string[]]} */ ([...MISS_KINDS])),
478
+ reason: z.string().min(1).max(200),
479
+ })).min(1).max(20).optional(),
453
480
  // Explicit wave-authoring decision (scheduler wave-disposition PRD) — only
454
481
  // meaningful (and only stamped) when this PRD joins an Epic that already
455
482
  // has incomplete PRDs and lands as a wave root (no dependsOn of its own);
@@ -459,6 +486,9 @@ const schedulerCreatePrd = z.object({
459
486
  // Artifact-only PRD declaration — cross-field rules enforced in prdCreate.cjs.
460
487
  deliverable: z.literal('artifact').optional(),
461
488
  artifactPaths: z.array(z.string().min(1).max(1024).regex(NO_NEWLINE_RE, 'must not contain newlines')).max(50).optional(),
489
+ // Tool-risk rule strings this PRD is cleared to call (toolRiskMarks.parseRule
490
+ // grammar, re-checked + de-duplicated in prdCreate.cjs; written as `riskTools`).
491
+ riskTools: RiskToolsSchema.optional(),
462
492
  // An EXISTING Epic's promptSessionId (PRD 748) — NOT a PromptTicket.id.
463
493
  // ensureEpic() (epicMint.cjs) joins the Epic whose active-index.json
464
494
  // sessions key literally equals this value; the renderer only ever sends
@@ -585,11 +615,65 @@ const adminListPrdsQuery = z.object({
585
615
  fields: z.enum(['compact', 'full']).optional().default('compact'),
586
616
  });
587
617
 
618
+ // GET /admin/events (lib/telemetry/eventsAdminRoutes.cjs) — cursor read over the
619
+ // audit log. `after` is checked by readEventsAfter itself (the route maps its
620
+ // rejection to the same 400); `kinds` is a comma-separated list, each entry one
621
+ // of auditEvents.cjs's OUTSIDE_EVENT_KINDS; `limit` 1..500 (default applied by
622
+ // readEventsAfter when absent).
623
+ const OUTSIDE_EVENT_KIND_ENUM = z.enum(/** @type {[string, ...string[]]} */ ([...require('./lib/telemetry/auditEvents.cjs').OUTSIDE_EVENT_KINDS]));
624
+ const adminListEventsQuery = z.object({
625
+ after: z.string().max(200).optional(),
626
+ kinds: z.string().min(1).max(1000)
627
+ .transform((v) => v.split(',').map((k) => k.trim()))
628
+ .pipe(z.array(OUTSIDE_EVENT_KIND_ENUM).min(1))
629
+ .optional(),
630
+ limit: z.coerce.number().int().min(1).max(500).optional(),
631
+ });
632
+
588
633
  const adminGetPrdQuery = z.object({
589
634
  slug: z.string().regex(SCHEDULE_SLUG_RE),
590
635
  cwd: z.string().min(1).max(4096).optional(),
591
636
  });
592
637
 
638
+ // GET /admin/epics + /admin/epic (lib/epic/epicAdminRoutes.cjs) — read-only
639
+ // outside-facing Epic records (lib/epic/epicOutsideRead.cjs). Query strings
640
+ // arrive as text, so limit/offset coerce before the int/range checks.
641
+ const EPIC_OUTSIDE_STATE_ENUM = z.enum(/** @type {[string, ...string[]]} */ ([...require('./lib/epic/epicOutsideState.cjs').EPIC_OUTSIDE_STATES]));
642
+ const adminListEpicsQuery = z.object({
643
+ cwd: z.string().min(1).max(4096),
644
+ state: EPIC_OUTSIDE_STATE_ENUM.optional(),
645
+ limit: z.coerce.number().int().min(1).max(200).optional().default(50),
646
+ offset: z.coerce.number().int().min(0).optional().default(0),
647
+ });
648
+
649
+ // GET /admin/agents (lib/persona-macro/agentAdminRoutes.cjs) — read-only
650
+ // persona roster; an optional cwd adds each persona's effective model/effort.
651
+ const adminListAgentsQuery = z.object({
652
+ cwd: z.string().min(1).max(4096).optional(),
653
+ });
654
+
655
+ // cwd is optional only for a lookup by id: Session Manager then finds the
656
+ // Epic among its registered projects (epicOutsideRead.findEpicProject).
657
+ const adminGetEpicQuery = z.object({
658
+ cwd: z.string().min(1).max(4096).optional(),
659
+ id: z.string().min(1).max(200).optional(),
660
+ externalRef: z.string().max(1000).optional().transform((v, ctx) => {
661
+ if (v === undefined) return undefined;
662
+ const r = require('./lib/epic/externalRef.cjs').normalizeExternalRef(v);
663
+ if (!r.ok) {
664
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: r.error });
665
+ return z.NEVER;
666
+ }
667
+ return r.value;
668
+ }),
669
+ // Opt-in cost receipt: only the query values '1' and 'true' turn it on.
670
+ receipt: z.string().max(10).optional().transform((v) => v === '1' || v === 'true'),
671
+ }).refine((v) => (v.id === undefined) !== (v.externalRef === undefined), {
672
+ message: 'exactly one of id or externalRef is required',
673
+ }).refine((v) => v.externalRef === undefined || v.cwd !== undefined, {
674
+ message: 'externalRef requires cwd',
675
+ });
676
+
593
677
  // Partial frontmatter patch for update-prd — same recognized-key set as
594
678
  // prdFrontmatter.cjs's parsePrdFile/serializePrdFile round-trip pair. Every
595
679
  // field optional; the route refuses an empty patch+no-body request via the
@@ -629,6 +713,10 @@ const adminPrdFrontmatterPatch = z.object({
629
713
  // chain) rewrites this alongside dependsOn via the same
630
714
  // schedule:set-prd-disposition path (see prdDisposition.cjs).
631
715
  disposition: PrdDispositionSchema.optional(),
716
+ // Patchable after creation too, with the SAME shape as create. updatePrd
717
+ // re-checks a non-empty list with normalizeRiskTools; an explicit `[]`
718
+ // removes the key from the PRD file.
719
+ riskTools: RiskToolsSchema.optional(),
632
720
  });
633
721
 
634
722
  const adminUpdatePrd = z.object({
@@ -653,9 +741,15 @@ const adminUpdatePrd = z.object({
653
741
  'body cannot be combined with gate, files or acceptanceCriteria',
654
742
  );
655
743
 
744
+ // `dependents` (PRD 3499): what happens to pending PRDs that depend on the
745
+ // cancelled job — required by remote.cancelJob whenever any exist.
656
746
  const adminCancelJob = z.object({
657
747
  slug: z.string().regex(SCHEDULE_SLUG_RE),
658
748
  cwd: z.string().min(1).max(4096).optional(),
749
+ dependents: z.object({
750
+ action: z.enum(['cascade', 'repoint', 'clear']),
751
+ to: z.string().min(1).max(200).optional(),
752
+ }).strict().refine((d) => d.action !== 'repoint' || d.to !== undefined, 'dependents.to is required for action "repoint"').optional(),
659
753
  });
660
754
 
661
755
  // ──────────────────────────────────────────── Projects
@@ -734,6 +828,19 @@ const claudeConfigPatch = z.object({
734
828
  keyPath: z.array(z.string().min(1).max(256)).min(1).max(8),
735
829
  value: z.unknown().optional(),
736
830
  }).strict();
831
+ // toolRisk:read / toolRisk:write — mirrors ToolRiskReadInput / ToolRiskWriteInput
832
+ // (src/preload/api.d.ts). Rule/mark validity is toolRiskMarks.cjs's job (so its
833
+ // error text reaches the UI); here only the shape is pinned.
834
+ const toolRiskBase = {
835
+ scope: z.enum(['user', 'project']),
836
+ cwd: z.string().min(1).max(4096).nullish(),
837
+ };
838
+ const toolRiskRead = z.object(toolRiskBase).strict();
839
+ const toolRiskWrite = z.object({
840
+ ...toolRiskBase,
841
+ marks: z.record(z.string().max(1024), z.unknown()),
842
+ interactive: z.boolean().optional(),
843
+ }).strict();
737
844
  // mcp:check-server — names WHICH configured server to check, never its config:
738
845
  // main reads that from disk (lib/mcpToolsProbe.cjs checkConfiguredMcpServer), so
739
846
  // the renderer can't make main spawn a command of its choosing. A project server
@@ -752,15 +859,28 @@ const macrosSave = MacroSaveSchema;
752
859
  const macrosDelete = MacroDeleteSchema;
753
860
  const macrosSetProject = MacroSetProjectSchema;
754
861
  const macrosRemoveFromProject = MacroRemoveFromProjectSchema;
755
- // Background macro job (macroJobIpc.cjs): press a built-in macro as a scheduler PRD inside an existing Epic.
862
+ // Background macro job (macroJobIpc.cjs): press a built-in macro or project Video tool as a scheduler PRD inside an existing Epic.
756
863
  const macrosDispatchJob = z.object({
757
864
  cwd: z.string().min(1).max(4096),
758
865
  macroId: z.string().min(1).max(128),
759
866
  epicId: z.string().min(1).max(200),
760
867
  extraInstructions: z.string().max(4000).optional(),
868
+ // A project Video tool's input values. No `review` key: an unknown key is
869
+ // stripped, so only the main-side review-decision IPC can pass a decision.
870
+ inputValues: z.record(z.string().max(128), z.string().max(4000))
871
+ .refine((o) => Object.keys(o).length <= 20, 'at most 20 input values')
872
+ .optional(),
761
873
  effort: z.enum(/** @type {[string, ...string[]]} */ ([...PRD_EFFORT_LEVELS])).optional(),
762
874
  });
763
875
  const macrosJobStatus = z.object({ cwd: z.string().min(1).max(4096) });
876
+ // Dashboard "Needs you" (lib/feedback-remote/needsYouIpc.cjs): list takes no payload; answer
877
+ // names one item + the chosen option. needsYouStore.cjs re-validates app/id and the option.
878
+ const needsYouList = z.object({}).strict().optional();
879
+ const needsYouAnswer = z.object({
880
+ app: z.string().min(1).max(40),
881
+ id: z.string().min(1).max(200),
882
+ answer: z.string().min(1).max(80),
883
+ }).strict();
764
884
 
765
885
  // ──────────────────────────────────────────── Memory tool (Bundle C, cycle 3)
766
886
  // Workspace-scoped markdown store at ~/.claude/projects/<ws>/memory/.
@@ -824,7 +944,7 @@ const memoryStale = z.object({
824
944
  agent: MEMORY_AGENT,
825
945
  }).strict();
826
946
 
827
- // memory:verify/archive/restore/listArchived/ask/proposeFix — Memory Explorer actions.
947
+ // memory:verify/archive/restore/listArchived — Memory Explorer actions (ask/proposeFix wrap memoryNamed below).
828
948
  const memoryNamed = z.object({
829
949
  workspace: z.string().regex(MEMORY_WORKSPACE_RE).optional(),
830
950
  name: z.string().regex(MEMORY_SLUG_RE),
@@ -834,15 +954,38 @@ const memoryNamed = z.object({
834
954
  const memoryVerify = memoryNamed;
835
955
  const memoryArchive = memoryNamed;
836
956
  const memoryRestore = memoryNamed;
837
- const memoryProposeFix = memoryNamed;
838
957
  const memoryListArchived = memoryList;
839
- const memoryAsk = z.object({
958
+
959
+ // memory:ask / memory:proposeFix receive the renderer's raw single object
960
+ // ({ question|name, target, contextName? }) from BOTH the Electron preload and
961
+ // the relay remote (remoteApi.ts forwards positionally). Flatten `target`'s
962
+ // truthy addressing keys onto the top level (target wins) and drop a falsy
963
+ // contextName, so askMemory/proposeFix see the same flat payload as before.
964
+ // A target carrying any other key (or a non-object target) is left in place
965
+ // so the inner .strict() schema rejects it.
966
+ const MEMORY_TARGET_KEYS = ['workspace', 'cwd', 'agent'];
967
+ /** @param {unknown} input */
968
+ function flattenMemoryTarget(input) {
969
+ if (!input || typeof input !== 'object' || Array.isArray(input)) return input;
970
+ const { target, ...rest } = /** @type {Record<string, unknown>} */ (input);
971
+ if (!rest.contextName) delete rest.contextName;
972
+ if (target === undefined || target === null) return rest;
973
+ if (typeof target !== 'object' || Array.isArray(target)
974
+ || Object.keys(target).some((k) => !MEMORY_TARGET_KEYS.includes(k))) {
975
+ return { ...rest, target };
976
+ }
977
+ const t = /** @type {Record<string, unknown>} */ (target);
978
+ for (const k of MEMORY_TARGET_KEYS) if (t[k]) rest[k] = t[k];
979
+ return rest;
980
+ }
981
+ const memoryProposeFix = z.preprocess(flattenMemoryTarget, memoryNamed);
982
+ const memoryAsk = z.preprocess(flattenMemoryTarget, z.object({
840
983
  workspace: z.string().regex(MEMORY_WORKSPACE_RE).optional(),
841
984
  question: z.string().min(1).max(4000),
842
985
  contextName: z.string().regex(MEMORY_SLUG_RE).optional(),
843
986
  cwd: MEMORY_CWD,
844
987
  agent: MEMORY_AGENT,
845
- }).strict();
988
+ }).strict());
846
989
 
847
990
  const memoryAgents = z.object({
848
991
  cwd: MEMORY_CWD,
@@ -921,22 +1064,15 @@ const projectPagesCwd = z.object({
921
1064
  cwd: z.string().min(1).max(4096),
922
1065
  }).strict();
923
1066
 
924
- // project-pages:md-network — cwd plus optional human folder overrides for the
925
- // census. Folders are repo-relative path PREFIXES used only for classification
926
- // (never joined onto the fs), so the shape check here is the whole contract.
927
- const mdNetworkFolder = z.string().min(1).max(512).refine(
928
- (f) => !f.startsWith('/') && !f.includes('\\') && !f.includes('\0') && !f.split('/').includes('..'),
929
- { message: "folder must be repo-relative (no leading '/', backslash, NUL or '..' segment)" },
930
- );
931
- const mdNetworkFolderList = z.array(mdNetworkFolder).max(50);
1067
+ // project-pages:md-network — cwd only. History folders come from the tracked
1068
+ // .session-manager.json mdNetwork.history and the census heuristic; the IPC
1069
+ // carries no folder overrides (.strict() rejects recordFolders/docFolders).
932
1070
  const projectPagesMdNetwork = z.object({
933
1071
  cwd: z.string().min(1).max(4096),
934
- recordFolders: mdNetworkFolderList.optional(),
935
- docFolders: mdNetworkFolderList.optional(),
936
1072
  }).strict();
937
1073
 
938
- // project-pages:md-review — cwd plus optional Review MD network Epic ids whose
939
- // reviews/validation/<id>/ folders to list. Ids are joined onto the fs, so the
1074
+ // project-pages:md-review — cwd plus optional Epic ids whose plan-records/<id>/
1075
+ // + legacy reviews/validation/<id>/ folders to list. Ids are joined onto fs; the
940
1076
  // slug regex (same as lib/mdReviewRecord.cjs EPIC_ID_RE) is load-bearing.
941
1077
  const projectPagesMdReview = z.object({
942
1078
  cwd: z.string().min(1).max(4096),
@@ -963,6 +1099,15 @@ const projectDemoVideoAdminWriteBody = z.object({
963
1099
  // never match.
964
1100
  const ENTRY_ID_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
965
1101
  const entryId = z.string().regex(ENTRY_ID_RE);
1102
+ // Project Video review step (project-pages/videoReviewIpc.cjs): renderer IPC only.
1103
+ const projectVideosReviewList = z.object({ cwd: z.string().min(1).max(4096) }).strict();
1104
+ const projectVideosReviewDecide = z.object({
1105
+ cwd: z.string().min(1).max(4096),
1106
+ entryId,
1107
+ decision: z.enum(['approve', 'changes']),
1108
+ note: z.string().max(2000).optional(),
1109
+ }).strict();
1110
+ const projectVideosReviewRetry = z.object({ cwd: z.string().min(1).max(4096), entryId }).strict();
966
1111
  const projectVideoReportFields = {
967
1112
  lufs: z.number().nullable(),
968
1113
  truePeakDb: z.number().nullable(),
@@ -977,8 +1122,10 @@ const projectVideoReportFields = {
977
1122
  const projectVideoMeta = z.object({
978
1123
  id: entryId,
979
1124
  title: z.string().min(1).max(120),
980
- kind: z.enum(['project-demo', 'blog-post', 'feature']),
1125
+ kind: z.enum(['project-demo', 'blog-post', 'feature', 'episode']),
981
1126
  target: z.string().max(300).optional(),
1127
+ // From the document's sm-demo-aspect tag; absent on older entries (treat as '16:9').
1128
+ aspect: z.enum(['16:9', '9:16']).optional(),
982
1129
  style: z.string().max(40),
983
1130
  lengthS: z.number().int().min(5).max(60),
984
1131
  createdAt: z.string().datetime(),
@@ -1025,7 +1172,7 @@ const projectVideoAdminWriteBody = z.object({
1025
1172
  cwd: z.string().min(1).max(4096).optional(),
1026
1173
  videoId: entryId,
1027
1174
  title: z.string().min(1).max(120),
1028
- kind: z.enum(['project-demo', 'blog-post', 'feature']),
1175
+ kind: z.enum(['project-demo', 'blog-post', 'feature', 'episode']),
1029
1176
  lengthS: z.number().int().min(5).max(60),
1030
1177
  html: z.string(),
1031
1178
  meta: projectVideoMeta.omit({ id: true, createdAt: true }).extend({
@@ -1086,7 +1233,7 @@ const epicDelegationStatsGet = z.object({
1086
1233
 
1087
1234
  // ──────────────────────────────────────────── Audit log (renderer Epic
1088
1235
  // lifecycle trace, PRD 940). Kind allowlist is enforced HERE, main-side — the
1089
- // renderer cannot write arbitrary kinds through this channel, only the six
1236
+ // renderer cannot write arbitrary kinds through this channel, only the
1090
1237
  // Epic lifecycle transitions it emits from promptSessions.ts.
1091
1238
  const AUDIT_LOG_KIND = z.enum([
1092
1239
  'epic_create',
@@ -1096,12 +1243,15 @@ const AUDIT_LOG_KIND = z.enum([
1096
1243
  'epic_resume',
1097
1244
  'epic_duplicate',
1098
1245
  'epic_draft_update',
1246
+ 'epic_continue',
1099
1247
  ]);
1100
1248
  const auditLogAppend = z.object({
1101
1249
  kind: AUDIT_LOG_KIND,
1102
1250
  cwd: z.string().min(1).max(4096),
1103
1251
  epicId: z.string().min(1).max(256),
1104
1252
  source: z.string().min(1).max(256),
1253
+ /** epic_continue only: the Epic the new session continues from. */
1254
+ fromEpicId: z.string().min(1).max(256).optional(),
1105
1255
  }).strict();
1106
1256
 
1107
1257
  // ──────────────────────────────────────────── Exchanges (PRD 324 read path)
@@ -1195,6 +1345,28 @@ const chatExternalSend = z.object({
1195
1345
  ),
1196
1346
  });
1197
1347
 
1348
+ // Phone remote's cmd:chat:send — chatExternalSend plus up to 6 images (saved
1349
+ // as Epic attachments by epicAttachments.cjs). Prompt may be empty when at
1350
+ // least one image is sent. Deep validation (magic bytes, decoded size) is
1351
+ // saveChatImages' job; this bounds the wire shape.
1352
+ const remoteChatImage = z.object({
1353
+ name: z.string().min(1).max(128),
1354
+ mime: z.enum(['image/png', 'image/jpeg', 'image/gif', 'image/webp']),
1355
+ data: z.string().min(1).max(4200000),
1356
+ });
1357
+
1358
+ const remoteChatSend = z.object({
1359
+ tabId: z.string().min(1).max(128),
1360
+ prompt: z.string().refine(
1361
+ (s) => Buffer.byteLength(s, 'utf8') <= CHAT_PROMPT_MAX_BYTES,
1362
+ `prompt must be ≤ ${CHAT_PROMPT_MAX_BYTES} bytes`,
1363
+ ),
1364
+ images: z.array(remoteChatImage).max(6).optional(),
1365
+ }).refine(
1366
+ (v) => v.prompt.trim().length > 0 || (Array.isArray(v.images) && v.images.length > 0),
1367
+ { message: 'prompt or at least one image is required', path: ['prompt'] },
1368
+ );
1369
+
1198
1370
  // Renderer's report of what it did with a `chat:external-send` (mirrors
1199
1371
  // ChatExternalSendResult in preload/api.d.ts).
1200
1372
  const chatExternalSendResult = z.object({
@@ -1280,6 +1452,26 @@ const historyDashboard = z.object({
1280
1452
  rangeDays: z.union([z.literal(30), z.literal(60), z.literal(90), z.literal(0)]),
1281
1453
  }).strict();
1282
1454
 
1455
+ // ──────────────────────────────────────────── Tasks (lib/tasks/taskIpc.cjs)
1456
+ const TaskCwd = z.string().min(1).max(4096).refine((s) => path.isAbsolute(s), 'cwd must be absolute');
1457
+ const TaskFilter = z.string().min(1).max(512).optional();
1458
+ const TaskListQuery = z.object({
1459
+ cwd: TaskCwd,
1460
+ since: TaskFilter,
1461
+ until: TaskFilter,
1462
+ pipeline: TaskFilter,
1463
+ runId: TaskFilter,
1464
+ step: TaskFilter,
1465
+ agent: TaskFilter,
1466
+ status: TaskFilter,
1467
+ source: TaskFilter,
1468
+ limit: z.number().int().min(1).max(200).optional(),
1469
+ offset: z.number().int().min(0).optional(),
1470
+ }).strict();
1471
+ const TaskGetQuery = z.object({ cwd: TaskCwd, id: z.string().min(1).max(200) }).strict();
1472
+ const TaskSwitchQuery = z.object({ cwd: TaskCwd }).strict();
1473
+ const TaskSwitchSet = z.object({ cwd: TaskCwd, enabled: z.boolean() }).strict();
1474
+
1283
1475
  // ──────────────────────────────────────────── Voice (F1/F5/F7/F8)
1284
1476
  // Mirrors voiceSettings.cjs isValidConfig / isValidDevicePref / isValid…
1285
1477
  // validators (ad-hoc on disk). Schemas here gate the IPC boundary so a
@@ -1407,6 +1599,8 @@ const customerFeedbackSubmit = z.object({
1407
1599
  title: z.string().max(120),
1408
1600
  body: z.string().max(4000),
1409
1601
  tag: z.enum(['bug', 'feature', 'discussion']),
1602
+ images: z.array(z.object({ dataUrl: z.string().max(35_000_000) })).max(5).optional(),
1603
+ imagePaths: z.array(z.string().max(4096)).max(5).optional(),
1410
1604
  });
1411
1605
  const customerFeedbackMarkSeen = z.object({ ids: z.array(z.string().max(200)).max(500).optional() });
1412
1606
  const customerFeedbackInboxList = z.object({ includeHidden: z.boolean().optional() });
@@ -1416,6 +1610,7 @@ const customerFeedbackInboxSetStatus = z.object({
1416
1610
  note: z.string().max(500).optional(),
1417
1611
  });
1418
1612
  const customerFeedbackInboxLinkEpic = z.object({ id: z.string().max(200), epicId: z.string().max(200) });
1613
+ const customerFeedbackInboxImage = z.object({ id: z.string().min(1).max(200), index: z.number().int().min(0).max(4) }).strict();
1419
1614
 
1420
1615
  /**
1421
1616
  * Wrap an IPC handler with schema validation. Returns a new handler that
@@ -1533,6 +1728,7 @@ module.exports = {
1533
1728
  configReadText,
1534
1729
  configWriteJson,
1535
1730
  configWriteText,
1731
+ configCanWrite,
1536
1732
  configListDir,
1537
1733
  configWatch,
1538
1734
  configWatchOpts,
@@ -1549,7 +1745,11 @@ module.exports = {
1549
1745
  scheduleArchivePrd,
1550
1746
  scheduleRetagPrd,
1551
1747
  adminListPrdsQuery,
1748
+ adminListEventsQuery,
1552
1749
  adminGetPrdQuery,
1750
+ adminListEpicsQuery,
1751
+ adminGetEpicQuery,
1752
+ adminListAgentsQuery,
1553
1753
  adminUpdatePrd,
1554
1754
  adminCancelJob,
1555
1755
  setConfigSchema,
@@ -1558,6 +1758,10 @@ module.exports = {
1558
1758
  archiveProject,
1559
1759
  historyAggregate,
1560
1760
  historyDashboard,
1761
+ TaskListQuery,
1762
+ TaskGetQuery,
1763
+ TaskSwitchQuery,
1764
+ TaskSwitchSet,
1561
1765
  voiceSetHotkey,
1562
1766
  voiceSetDevicePref,
1563
1767
  voiceSetTurnDetector,
@@ -1630,6 +1834,7 @@ module.exports = {
1630
1834
  chatCancel,
1631
1835
  chatClassifyTicket,
1632
1836
  chatExternalSend,
1837
+ remoteChatSend,
1633
1838
  chatExternalSendResult,
1634
1839
  chatExternalNewSessionResult,
1635
1840
  remoteSessionCreate,
@@ -1642,6 +1847,8 @@ module.exports = {
1642
1847
  agentsDeletePersona,
1643
1848
  claudeConfigRead,
1644
1849
  claudeConfigPatch,
1850
+ toolRiskRead,
1851
+ toolRiskWrite,
1645
1852
  mcpCheckServer,
1646
1853
  macrosSave,
1647
1854
  macrosDelete,
@@ -1649,6 +1856,11 @@ module.exports = {
1649
1856
  macrosRemoveFromProject,
1650
1857
  macrosDispatchJob,
1651
1858
  macrosJobStatus,
1859
+ projectVideosReviewList,
1860
+ projectVideosReviewDecide,
1861
+ projectVideosReviewRetry,
1862
+ needsYouList,
1863
+ needsYouAnswer,
1652
1864
  agentsGetPersonaBody,
1653
1865
  agentsResolveModelInfo,
1654
1866
  modelsCatalog,
@@ -1662,6 +1874,7 @@ module.exports = {
1662
1874
  customerFeedbackInboxList,
1663
1875
  customerFeedbackInboxSetStatus,
1664
1876
  customerFeedbackInboxLinkEpic,
1877
+ customerFeedbackInboxImage,
1665
1878
  },
1666
1879
  validated,
1667
1880
  };