claude-code-session-manager 0.127.0 → 0.129.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 (91) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +2 -0
  3. package/dist/assets/{AgentLibrary-DKQznr7o.js → AgentLibrary-Cp250YHF.js} +1 -1
  4. package/dist/assets/{Button-CZXqmIiM.js → Button-DU5UF-6L.js} +1 -1
  5. package/dist/assets/{DataModel-piyV33To.js → DataModel-CPf6f17e.js} +1 -1
  6. package/dist/assets/{History-BxwtrKF2.js → History-B2x-LMlT.js} +1 -1
  7. package/dist/assets/{Hooks-DogeSPII.js → Hooks-BWr33C4Q.js} +1 -1
  8. package/dist/assets/{Library-BDt6EeQQ.js → Library-DBNLTAa8.js} +1 -1
  9. package/dist/assets/{ListDetail-CwS-LKar.js → ListDetail-BGBw6egp.js} +1 -1
  10. package/dist/assets/{McpServers-D2HVljgS.js → McpServers-DywZ50Ec.js} +1 -1
  11. package/dist/assets/{Memory-hNzuOGn8.js → Memory-CnalwnFf.js} +1 -1
  12. package/dist/assets/{Panel-BLDrsUeq.js → Panel-BzIklgKf.js} +1 -1
  13. package/dist/assets/{Permissions-DzZ5vaJW.js → Permissions-mgRifwQc.js} +1 -1
  14. package/dist/assets/{Plugins-Cz9yaxzG.js → Plugins-CV42zfid.js} +2 -2
  15. package/dist/assets/{ProvenanceBadge-CCgLO4m9.js → ProvenanceBadge-DYmX4xgB.js} +1 -1
  16. package/dist/assets/{SaveBar-Shmn699J.js → SaveBar-DxrAfnlC.js} +1 -1
  17. package/dist/assets/{Scheduler-Bqr0WHNd.js → Scheduler-iyUl1NDl.js} +1 -1
  18. package/dist/assets/{ScopeSwitcher-CBx1fB5g.js → ScopeSwitcher-CC8BDPgf.js} +1 -1
  19. package/dist/assets/{Settings-Ci8in-yF.js → Settings-CWBnQghD.js} +1 -1
  20. package/dist/assets/{SkillReferenceGraph-BWwljba8.js → SkillReferenceGraph-DOhiCxuL.js} +1 -1
  21. package/dist/assets/{Skills-BON6o-c4.js → Skills-3Er-9YA9.js} +1 -1
  22. package/dist/assets/{SystemPrompt-D5epIYYs.js → SystemPrompt-BLxdvZ9K.js} +1 -1
  23. package/dist/assets/{TagLibrary-C2qDZROJ.js → TagLibrary-BZ6QHYMQ.js} +1 -1
  24. package/dist/assets/{TiptapBody-SZhI3-bW.js → TiptapBody-Du6jRBoW.js} +1 -1
  25. package/dist/assets/{Toggle-C_qFDG0g.js → Toggle-Qdi2Z7VD.js} +1 -1
  26. package/dist/assets/{ViewTabs-C9q5WCEd.js → ViewTabs-BKfFsziD.js} +1 -1
  27. package/dist/assets/{historyTotals-BCl7IOhY.js → historyTotals-8ecP_6wF.js} +1 -1
  28. package/dist/assets/{index-BnKaYERU.css → index-DtdWBGrI.css} +1 -1
  29. package/dist/assets/index-GI6F_j41.js +3083 -0
  30. package/dist/assets/{settingsSchema-BBrRBrBr.js → settingsSchema-lHTHAabD.js} +1 -1
  31. package/dist/assets/{skillFrontmatter-B01qJk6N.js → skillFrontmatter-8X1Uc282.js} +1 -1
  32. package/dist/assets/{useAgentsDirWatch-CuR3GSjS.js → useAgentsDirWatch-CcsoD1bp.js} +1 -1
  33. package/dist/index.html +2 -2
  34. package/dist-web/app.css +1 -1
  35. package/dist-web/app.js +373 -369
  36. package/package.json +1 -1
  37. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  38. package/plugins/session-manager-dev/skills/develop/SKILL.md +4 -2
  39. package/scripts/hooks/lib/guard-inline-implementation-policy.cjs +10 -0
  40. package/scripts/scheduler-mcp-server.cjs +170 -6
  41. package/src/main/build-info.json +4 -4
  42. package/src/main/chatRunner.cjs +8 -0
  43. package/src/main/index.cjs +27 -0
  44. package/src/main/ipcSchemas.cjs +110 -1
  45. package/src/main/lib/claude/agentModelResolve.cjs +31 -10
  46. package/src/main/lib/claude/effectiveModelInfo.cjs +14 -4
  47. package/src/main/lib/claude/modelCatalog.cjs +28 -1
  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/developLoopSpawn.cjs +18 -0
  56. package/src/main/lib/epic/epicMint.cjs +4 -2
  57. package/src/main/lib/epic/epicValidationHook.cjs +17 -1
  58. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +4 -3
  59. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +21 -21
  60. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +185 -34
  61. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +15 -0
  62. package/src/main/lib/mcpToolCatalog.cjs +71 -11
  63. package/src/main/lib/opsOwnership.cjs +9 -5
  64. package/src/main/lib/persona-macro/builtinMacros.cjs +19 -5
  65. package/src/main/lib/persona-macro/macroJobDispatch.cjs +116 -0
  66. package/src/main/lib/persona-macro/macroJobIpc.cjs +50 -0
  67. package/src/main/lib/persona-macro/macroJobStatus.cjs +112 -0
  68. package/src/main/lib/persona-macro/macroLibrary.cjs +16 -0
  69. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +113 -0
  70. package/src/main/lib/prd/prdCreate.cjs +27 -1
  71. package/src/main/lib/prd/prdFrontmatter.cjs +7 -2
  72. package/src/main/lib/project-pages/pagesLibrary.cjs +171 -0
  73. package/src/main/lib/project-pages/playerBridge.cjs +129 -0
  74. package/src/main/lib/promptSessionSchema.cjs +8 -0
  75. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  76. package/src/main/lib/smfileHeaders.cjs +11 -3
  77. package/src/main/projectPages.cjs +107 -30
  78. package/src/main/promptSessionsIpc.cjs +131 -0
  79. package/src/main/scheduler/prdParser.cjs +2 -0
  80. package/src/main/scheduler.cjs +26 -9
  81. package/src/main/seedSchedulerMcp.cjs +10 -1
  82. package/src/main/transcripts.cjs +8 -0
  83. package/src/main/webRemote.cjs +3 -1
  84. package/src/preload/api.d.ts +107 -6
  85. package/src/preload/apiSurface.json +77 -0
  86. package/src/preload/index.cjs +18 -0
  87. package/src/seed/agents/architect.md +8 -8
  88. package/src/seed/agents/demo-video-builder.md +86 -36
  89. package/src/seed/agents/project-home-builder.md +26 -13
  90. package/dist/assets/index-CMIYLbPb.js +0 -3079
  91. package/src/main/lib/epic/epicStandingInstructions.cjs +0 -73
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Read-tier IPC for the Sessions (Epics) list/detail path. The renderer used to
5
+ * read active-index.json, per-Epic archives and the Claude session JSONL via
6
+ * config:readJson/listDir/readText — all `deny` for a remote (web) browser, so
7
+ * the remote UI could never list or open a Session. These channels are the
8
+ * dedicated, fenced replacement: every handler reads ONLY under
9
+ * `<cwd>/session-manager-operations/prompt-sessions` (via opsPath()) — except
10
+ * read-session-transcript, which resolves the project's own Claude JSONL via
11
+ * transcripts.cjs — and refuses a cwd that is not a registered project root.
12
+ * Reads only: the single-writer law (opsOwnership.cjs) is untouched.
13
+ */
14
+
15
+ const fs = require('node:fs');
16
+ const path = require('node:path');
17
+
18
+ const ID_RE = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/;
19
+ const MAX_TRANSCRIPT_BYTES = 64 * 1024 * 1024;
20
+
21
+ function norm(p) {
22
+ return path.resolve(String(p)).replace(/[\\/]+$/, '');
23
+ }
24
+
25
+ /** Default registered-project source: persisted tabs plus every project Claude has seen. */
26
+ function defaultProjectRoots() {
27
+ const roots = [];
28
+ try {
29
+ const sessionsStore = require('./sessionsStore.cjs');
30
+ const data = JSON.parse(fs.readFileSync(sessionsStore.storePath(), 'utf8'));
31
+ for (const t of data.tabs || []) if (t && typeof t.cwd === 'string' && t.cwd) roots.push(t.cwd);
32
+ } catch { /* none */ }
33
+ try {
34
+ for (const c of require('./lib/activeSessions.cjs').allProjectCwds()) roots.push(c);
35
+ } catch { /* none */ }
36
+ return roots;
37
+ }
38
+
39
+ function assertRegistered(cwd, projectRoots) {
40
+ if (typeof cwd !== 'string' || !cwd || !path.isAbsolute(cwd)) throw new Error('cwd must be an absolute project path');
41
+ const { projectRootOf } = require('./lib/activeSessions.cjs');
42
+ const want = norm(projectRootOf(cwd) || cwd);
43
+ for (const r of projectRoots() || []) {
44
+ if (typeof r !== 'string' || !r) continue;
45
+ if (norm(r) === want || norm(projectRootOf(r) || r) === want) return;
46
+ }
47
+ throw new Error('cwd is not a registered project root');
48
+ }
49
+
50
+ function promptSessionsDir(cwd) {
51
+ return require('./lib/opsOwnership.cjs').opsPath(cwd, 'prompt-sessions');
52
+ }
53
+
54
+ function loadActiveIndex(cwd, { projectRoots = defaultProjectRoots } = {}) {
55
+ assertRegistered(cwd, projectRoots);
56
+ const file = path.join(promptSessionsDir(cwd), 'active-index.json');
57
+ try {
58
+ return { exists: true, data: JSON.parse(fs.readFileSync(file, 'utf8')) };
59
+ } catch (err) {
60
+ if (err && err.code === 'ENOENT') return { exists: false, data: null };
61
+ return { exists: false, data: null, error: String(err && err.message ? err.message : err) };
62
+ }
63
+ }
64
+
65
+ function listArchived(cwd, { projectRoots = defaultProjectRoots } = {}) {
66
+ assertRegistered(cwd, projectRoots);
67
+ try {
68
+ const ids = fs.readdirSync(promptSessionsDir(cwd), { withFileTypes: true })
69
+ .filter((e) => e.isFile() && e.name.endsWith('.json') && e.name !== 'active-index.json')
70
+ .map((e) => e.name.slice(0, -'.json'.length))
71
+ .filter((id) => ID_RE.test(id));
72
+ return { ok: true, ids };
73
+ } catch (err) {
74
+ return { ok: false, ids: [], error: String(err && err.message ? err.message : err) };
75
+ }
76
+ }
77
+
78
+ function readArchived(cwd, epicId, { projectRoots = defaultProjectRoots } = {}) {
79
+ assertRegistered(cwd, projectRoots);
80
+ if (typeof epicId !== 'string' || !ID_RE.test(epicId) || epicId === 'active-index') throw new Error('invalid epicId');
81
+ try {
82
+ return { exists: true, data: JSON.parse(fs.readFileSync(path.join(promptSessionsDir(cwd), `${epicId}.json`), 'utf8')) };
83
+ } catch (err) {
84
+ if (err && err.code === 'ENOENT') return { exists: false, data: null };
85
+ return { exists: false, data: null, error: String(err && err.message ? err.message : err) };
86
+ }
87
+ }
88
+
89
+ function readSessionTranscript(cwd, sessionId, { projectRoots = defaultProjectRoots, resolvePath } = {}) {
90
+ assertRegistered(cwd, projectRoots);
91
+ if (typeof sessionId !== 'string' || !ID_RE.test(sessionId)) throw new Error('invalid sessionId');
92
+ const file = (resolvePath || ((c, s) => require('./transcripts.cjs').transcriptPath(c, s)))(cwd, sessionId);
93
+ try {
94
+ if (fs.statSync(file).size > MAX_TRANSCRIPT_BYTES) return { exists: true, text: '', error: 'transcript too large' };
95
+ return { exists: true, text: fs.readFileSync(file, 'utf8') };
96
+ } catch (err) {
97
+ if (err && err.code === 'ENOENT') return { exists: false, text: '' };
98
+ return { exists: false, text: '', error: String(err && err.message ? err.message : err) };
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Write one completed Epic's archive (<cwd>/…/prompt-sessions/<id>.json).
104
+ * Path is built here from opsPath(); the writer id is hardcoded 'epics'
105
+ * (single-writer law). Refuses a non-registered cwd and an archive whose
106
+ * session.id does not match the named epicId.
107
+ */
108
+ async function writeArchive(cwd, epicId, archive, { projectRoots = defaultProjectRoots, writeJson } = {}) {
109
+ assertRegistered(cwd, projectRoots);
110
+ if (typeof epicId !== 'string' || !ID_RE.test(epicId) || epicId === 'active-index') throw new Error('invalid epicId');
111
+ if (!archive || typeof archive !== 'object' || !archive.session || archive.session.id !== epicId) {
112
+ throw new Error('archive.session.id must match epicId');
113
+ }
114
+ const config = require('./config.cjs');
115
+ config.addAllowedRoot(norm(cwd));
116
+ const file = path.join(promptSessionsDir(cwd), `${epicId}.json`);
117
+ await (writeJson || config.writeJson)(file, archive, { writer: 'epics' });
118
+ return { ok: true };
119
+ }
120
+
121
+ function registerPromptSessionsReadHandlers() {
122
+ const { ipcMain } = require('electron');
123
+ const { schemas: s, validated: v } = require('./ipcSchemas.cjs');
124
+ ipcMain.handle('promptSessions:load-active-index', v(s.promptSessionsCwd, ({ cwd }) => loadActiveIndex(cwd)));
125
+ ipcMain.handle('promptSessions:list-archived', v(s.promptSessionsCwd, ({ cwd }) => listArchived(cwd)));
126
+ ipcMain.handle('promptSessions:read-archived', v(s.promptSessionsReadArchived, ({ cwd, epicId }) => readArchived(cwd, epicId)));
127
+ ipcMain.handle('promptSessions:write-archive', v(s.promptSessionsWriteArchive, ({ cwd, epicId, archive }) => writeArchive(cwd, epicId, archive)));
128
+ ipcMain.handle('promptSessions:read-session-transcript', v(s.promptSessionsReadSessionTranscript, ({ cwd, sessionId }) => readSessionTranscript(cwd, sessionId)));
129
+ }
130
+
131
+ module.exports = { loadActiveIndex, listArchived, readArchived, readSessionTranscript, writeArchive, registerPromptSessionsReadHandlers };
@@ -131,6 +131,8 @@ async function parsePrdRaw(filePath) {
131
131
  disposition: (fm.disposition === 'append' || fm.disposition === 'new-head') ? fm.disposition : null,
132
132
  // Durable wave identity (createPrd-stamped); malformed values read as absent.
133
133
  planId: (typeof fm.planId === 'string' && /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(fm.planId)) ? fm.planId : null,
134
+ // Macro press that minted this PRD (prdFrontmatter.cjs MACRO_ID_RE); malformed reads as absent.
135
+ macroId: (typeof fm.macroId === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(fm.macroId.trim())) ? fm.macroId.trim() : null,
134
136
  // Opt-in exclusive-lease flag (PRD 1107, quietMachineLease.cjs +
135
137
  // schedulerBatch.cjs's pickNextBatch). Only a literal `true` opts in —
136
138
  // matches prdFrontmatter.cjs's applyKey semantics for this field.
@@ -154,7 +154,7 @@ const queueOps = require('./queueOps.cjs');
154
154
  const { listEpicPrdDirs, listArchivedPrdDirs, deriveProjectCwdFromPrdPath } = require('./lib/prd/prdLocations.cjs');
155
155
  const { ensureEpic, appendPrdCreatedEvent, readActiveIndex } = require('./lib/epic/epicMint.cjs');
156
156
  const agentModelResolve = require('./lib/claude/agentModelResolve.cjs');
157
- const { buildPersonaToolScope, personaToolScopeArgs } = require('./lib/claude/personaToolScope.cjs');
157
+ const { buildPersonaToolScope, personaToolScopeArgs, personaToolScopeEnv } = require('./lib/claude/personaToolScope.cjs');
158
158
  const { resolveEpicEffort, effortArgs } = require('./lib/claude/agentEffortResolve.cjs');
159
159
  const { transitionJob, STATUS_HISTORY_CAP, LEGAL_TRANSITIONS } = require('./lib/scheduler/scheduleJobTransitions.cjs');
160
160
  const { buildContextDigest, composeExecutorPrompt } = require('./lib/epic/epicContextDigest.cjs');
@@ -1802,6 +1802,7 @@ async function reconcilePass(state) {
1802
1802
  ?? resolveOriginSessionId(refreshedCwd, p.epicId ?? reconcileSourcePromptId(job, p.sourcePromptId)),
1803
1803
  bodyPreview: p.body.split('\n').slice(0, 6).join('\n'),
1804
1804
  agentType: p.agentType ?? job.agentType ?? null,
1805
+ macroId: p.macroId ?? job.macroId ?? null,
1805
1806
  };
1806
1807
  // Adopt path: a row parked 'quarantined' (no createdVia provenance when
1807
1808
  // discovered) whose PRD file now carries a stamp — written via the
@@ -1925,6 +1926,7 @@ async function reconcilePass(state) {
1925
1926
  originSessionId: inv.row?.originSessionId ?? resolveOriginSessionId(repairedCwd, p.epicId ?? p.sourcePromptId),
1926
1927
  bodyPreview: p.body.split('\n').slice(0, 6).join('\n'),
1927
1928
  agentType: p.agentType ?? inv.row?.agentType ?? null,
1929
+ macroId: p.macroId ?? inv.row?.macroId ?? null,
1928
1930
  };
1929
1931
  const reason = `reconcile: repaired invalid status ${JSON.stringify(oldStatus)}`;
1930
1932
  // A repair is not a lifecycle transition — the corrupted `status` was
@@ -2076,6 +2078,7 @@ async function reconcilePass(state) {
2076
2078
  originSessionId: resolveOriginSessionId(discoveredCwd, p.epicId ?? p.sourcePromptId),
2077
2079
  bodyPreview: p.body.split('\n').slice(0, 6).join('\n'),
2078
2080
  agentType: p.agentType ?? null,
2081
+ macroId: p.macroId ?? null,
2079
2082
  status: 'pending',
2080
2083
  // Enqueue time (PRD 1086/1087): the cross-project fairness tiebreak and
2081
2084
  // the starvation escalation both need a provable age for a pending row;
@@ -4498,13 +4501,20 @@ const HEADLESS_DISALLOWED_TOOLS = Object.freeze([
4498
4501
  * and a large prompt failed with spawn E2BIG before the job started (the
4499
4502
  * 2026-10-26 incident). `claude -p` with no positional prompt reads stdin.
4500
4503
  */
4504
+ // MCP servers whose definition the scheduler knows. Lazy require: avoids a
4505
+ // load-order cycle with seedSchedulerMcp.cjs.
4506
+ function knownMcpServers() {
4507
+ const seed = require('./seedSchedulerMcp.cjs');
4508
+ return { [seed.SERVER_NAME]: seed.schedulerServerEntry() };
4509
+ }
4510
+
4501
4511
  function buildClaudeSpawnArgs({ model, effort, sessionId, resume, systemPrompt, toolScope }) {
4502
4512
  return [
4503
4513
  '-p',
4504
4514
  '--model', model,
4505
4515
  ...effortArgs(effort),
4506
4516
  ...(systemPrompt ? ['--append-system-prompt', systemPrompt] : []),
4507
- ...personaToolScopeArgs(toolScope),
4517
+ ...personaToolScopeArgs(toolScope, { mcpServers: knownMcpServers() }),
4508
4518
  '--dangerously-skip-permissions',
4509
4519
  ...headlessPermissionArgs(),
4510
4520
  '--disallowedTools', HEADLESS_DISALLOWED_TOOLS.join(','),
@@ -4851,6 +4861,8 @@ async function executeJob(job, runDir, defaultCwd, onPid, execCwd, resumeTarget
4851
4861
  // scheduler-mcp-server.cjs can refuse scheduler_create_prd from inside a
4852
4862
  // run (issue #11 list C1 — the PRD 460 self-queue incident). Only a
4853
4863
  // persona whose whole job is decomposition may still queue.
4864
+ // SM_SCHEDULER_JOB_MCP_TOOLS tells scheduler-mcp-server.cjs which of its tools this job's
4865
+ // persona admits (see personaToolScope.cjs).
4854
4866
  // `launchEnv` is the launch circuit breaker's degraded-mode env (e.g.
4855
4867
  // MAX_THINKING_TOKENS=0 while an outdated CLI's thinking parameter is
4856
4868
  // being rejected — lib/scheduler/launchFailure.cjs); applied last so it wins.
@@ -4859,6 +4871,7 @@ async function executeJob(job, runDir, defaultCwd, onPid, execCwd, resumeTarget
4859
4871
  SM_PROJECT_ROOT: cwd,
4860
4872
  SM_SCHEDULER_JOB_SLUG: job.slug,
4861
4873
  SM_SCHEDULER_JOB_MAY_QUEUE: job.agentType === 'architect' ? '1' : '0',
4874
+ ...personaToolScopeEnv(personaToolScope),
4862
4875
  BASH_DEFAULT_TIMEOUT_MS: String(BASH_DEFAULT_TIMEOUT_MS),
4863
4876
  BASH_MAX_TIMEOUT_MS: String(BASH_MAX_TIMEOUT_MS),
4864
4877
  ...(launchEnv && typeof launchEnv === 'object' ? launchEnv : {}),
@@ -6257,8 +6270,10 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
6257
6270
  // branch below has this run's OWN start time — the freshness check
6258
6271
  // (isCooldownSuppressed) needs to know whether this specific dispatch
6259
6272
  // started after the manual clear, not whatever startedAt this row
6260
- // carried from a prior run.
6273
+ // carried from a prior run. The same stamped start (ISO form, below)
6274
+ // also feeds verifyRun's queueEntry so artifact-only PRDs get a real window.
6261
6275
  let dispatchStartedAtMs = null;
6276
+ let dispatchStartedAt = null;
6262
6277
  let dispatchSkippedAlreadyCompleted = false;
6263
6278
  await mutate((s) => {
6264
6279
  const idx = s.jobs.findIndex((x) => x.slug === job.slug);
@@ -6341,6 +6356,7 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
6341
6356
  s.jobs[idx].dispatchPhase = 'running-stamped';
6342
6357
  s.jobs[idx].dispatchPhaseAt = s.jobs[idx].startedAt;
6343
6358
  dispatchStartedAtMs = Date.parse(s.jobs[idx].startedAt);
6359
+ dispatchStartedAt = s.jobs[idx].startedAt;
6344
6360
  if (job.quietMachine === true) {
6345
6361
  s.jobs[idx].quietMachine = true;
6346
6362
  s.jobs[idx].quietLeaseDegraded = job.quietLeaseDegraded === true;
@@ -6735,7 +6751,7 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
6735
6751
  guardCwd,
6736
6752
  guardHeadBefore,
6737
6753
  headAtExit,
6738
- job.startedAt,
6754
+ dispatchStartedAt,
6739
6755
  new Date().toISOString(),
6740
6756
  );
6741
6757
  let rangeCommits = [];
@@ -6745,7 +6761,7 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
6745
6761
  rangeCommits = await gitTreeGuard.gitRangeCommits(guardCwd, guardHeadBefore, headAtExit);
6746
6762
  transcriptCommitShas = parseLog(path.join(runDir, `${job.slug}.log`)).transcriptCommitShas || [];
6747
6763
  const overlapState = await readQueue().catch(() => ({ jobs: [] }));
6748
- const myStart = Date.parse(job.startedAt) || 0;
6764
+ const myStart = Date.parse(dispatchStartedAt) || 0;
6749
6765
  const myEnd = Date.now();
6750
6766
  siblingOverlap = (overlapState.jobs || []).some((j) => {
6751
6767
  if (j.slug === job.slug || (j.cwd || defaultCwd) !== guardCwd) return false;
@@ -6789,7 +6805,7 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
6789
6805
  verifyResult = await verifyRun({
6790
6806
  runDir,
6791
6807
  prdPath,
6792
- queueEntry: job,
6808
+ queueEntry: { ...job, startedAt: dispatchStartedAt, finishedAt: null },
6793
6809
  allJobs: stateForDeps.jobs,
6794
6810
  committedDuringRun,
6795
6811
  priorLandedCommit,
@@ -6952,11 +6968,11 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
6952
6968
  guardCwd,
6953
6969
  guardHeadBefore,
6954
6970
  guardHeadAtSigterm,
6955
- job.startedAt,
6971
+ dispatchStartedAt,
6956
6972
  new Date().toISOString(),
6957
6973
  );
6958
6974
  if (guardHeadBefore && guardHeadAtSigterm && guardHeadAtSigterm !== guardHeadBefore) {
6959
- const verified = await resolveLandedCommitEvidence(guardCwd, guardHeadAtSigterm, job.startedAt);
6975
+ const verified = await resolveLandedCommitEvidence(guardCwd, guardHeadAtSigterm, dispatchStartedAt);
6960
6976
  if (verified) sigtermLandedCommitEvidence = guardHeadAtSigterm;
6961
6977
  }
6962
6978
  }
@@ -6996,7 +7012,7 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
6996
7012
  if (res.exitCode !== 0 && res.exitCode !== 143 && !res.rateLimited) {
6997
7013
  const headAtPlainExit = await gitTreeGuard.gitHead(guardCwd);
6998
7014
  if (guardHeadBefore && headAtPlainExit && headAtPlainExit !== guardHeadBefore) {
6999
- const verified = await resolveLandedCommitEvidence(guardCwd, headAtPlainExit, job.startedAt);
7015
+ const verified = await resolveLandedCommitEvidence(guardCwd, headAtPlainExit, dispatchStartedAt);
7000
7016
  if (verified) plainExitLandedCommitEvidence = headAtPlainExit;
7001
7017
  }
7002
7018
  }
@@ -11153,6 +11169,7 @@ async function listPrdsInternal({ cwd: rawCwd } = {}) {
11153
11169
  epicId: parsed.epicId ?? null,
11154
11170
  dependsOn: parsed.dependsOn ?? null,
11155
11171
  agentType: parsed.agentType ?? null,
11172
+ macroId: parsed.macroId ?? null,
11156
11173
  disposition: parsed.disposition ?? null,
11157
11174
  planId: parsed.planId ?? null,
11158
11175
  mtimeMs: stat.mtimeMs,
@@ -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 };
@@ -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,
@@ -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;
@@ -1488,12 +1521,57 @@ export type ProjectBriefUpdateResult =
1488
1521
  | { ok: false; error: string };
1489
1522
 
1490
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
+
1491
1565
  export interface ProjectPagesGetResult {
1492
- /** 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. */
1493
1571
  html: string | null;
1494
- /** home.html's mtime, or null when `html` is null. */
1572
+ /** The overview page's mtime, or null when `html` is null. */
1495
1573
  mtimeMs: number | null;
1496
- /** 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. */
1497
1575
  demoVideo: { path: string; mtimeMs: number } | null;
1498
1576
  }
1499
1577
 
@@ -1772,6 +1850,7 @@ export interface SessionManagerAPI {
1772
1850
  installSelfScheduleGuard: (cwd: string) => Promise<InstallGuardResult>;
1773
1851
  onNewSession: (handler: () => void) => () => void;
1774
1852
  onRebootSession: (handler: () => void) => () => void;
1853
+ onOpenFreeHour: (handler: () => void) => () => void;
1775
1854
  archiveProject: (encoded: string) => Promise<{ ok: boolean; error?: string }>;
1776
1855
  };
1777
1856
  pty: {
@@ -1800,6 +1879,8 @@ export interface SessionManagerAPI {
1800
1879
  /** Full untruncated single-line read via a classifier byte reference (expand-to-full path). */
1801
1880
  readRef: (ref: TranscriptEventRef) => Promise<{ ok: boolean; text?: string; error?: string }>;
1802
1881
  pathFor: (cwd: string, sessionUuid: string) => Promise<string>;
1882
+ /** Does the claude JSONL transcript for this session exist? Remote-readable. */
1883
+ exists: (cwd: string, sessionUuid: string) => Promise<boolean>;
1803
1884
  /** Batched token-usage totals, one map entry per requested sessionId. A
1804
1885
  * session with no transcript file yet (or one over the main-process size
1805
1886
  * cap) maps to null. */
@@ -1841,7 +1922,7 @@ export interface SessionManagerAPI {
1841
1922
  * with the renderer's `useEffectiveSettings.ts` scope-chain reader for
1842
1923
  * the effortLevel/effortSource half — this call only covers the parts
1843
1924
  * that need main-process filesystem access. */
1844
- resolveModelInfo: (payload: { cwd: string; agentType: string }) => Promise<{
1925
+ resolveModelInfo: (payload: { cwd: string; agentType?: string }) => Promise<{
1845
1926
  agentType: string;
1846
1927
  modelAlias: string | null;
1847
1928
  modelSource: 'persona' | 'persona-overlay' | 'inherit' | 'fallback';
@@ -1878,6 +1959,10 @@ export interface SessionManagerAPI {
1878
1959
  delete: (payload: { id: string }) => Promise<{ ok: boolean }>;
1879
1960
  /** Add/remove one project cwd. A macro shown in every project (`'*'`) cannot be narrowed: `{ ok: false, error: 'macro is shown in every project' }`. */
1880
1961
  setProject: (payload: { id: string; cwd: string; enabled: boolean }) => Promise<{ ok: true; macro: Macro } | { ok: false; error: string }>;
1962
+ /** Dispatch a built-in macro's background build as a scheduler job. */
1963
+ dispatchJob: (payload: MacroJobDispatchInput) => Promise<MacroJobDispatchResult>;
1964
+ /** Status of this project's macro background builds. */
1965
+ jobStatus: (payload: { cwd: string }) => Promise<MacroJobStatus[]>;
1881
1966
  /** Fires after any save/delete/setProject — re-fetch list(). */
1882
1967
  onChanged: (handler: () => void) => () => void;
1883
1968
  };
@@ -2178,13 +2263,17 @@ export interface SessionManagerAPI {
2178
2263
  update: (cwd: string, patch: ProjectBriefPatch) => Promise<ProjectBriefUpdateResult>;
2179
2264
  };
2180
2265
  projectPages: {
2181
- /** Read project-pages/home.html (`{html: null, mtimeMs: null}` if it does not exist yet). Never fires an LLM call. */
2266
+ /** 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. */
2182
2267
  get: (cwd: string) => Promise<ProjectPagesGetResult>;
2183
2268
  /** 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. */
2184
2269
  watch: (cwd: string) => Promise<{ ok: boolean; reason?: 'ephemeral' | 'invalid-cwd' }>;
2185
2270
  /** Stop pushing `onChanged` events for this cwd — must be paired 1:1 with a prior `watch` call. */
2186
2271
  unwatch: (cwd: string) => Promise<{ ok: boolean }>;
2187
- /** Fires whenever a watched cwd's home.html is added/changed/removed, carrying the freshly read result. */
2272
+ /** Rewrite one library entry's meta.json title. Rejects on a bad id, missing entry or invalid meta. */
2273
+ rename: (cwd: string, kind: 'knowledge' | 'video', id: string, title: string) => Promise<{ ok: true; title: string }>;
2274
+ /** Remove exactly one library entry folder. Rejects on a bad id or missing entry. */
2275
+ delete: (cwd: string, kind: 'knowledge' | 'video', id: string) => Promise<{ ok: true }>;
2276
+ /** Fires whenever a watched cwd's knowledge/videos library is added/changed/removed, carrying the freshly read library result. */
2188
2277
  onChanged: (handler: (payload: { cwd: string } & ProjectPagesGetResult) => void) => () => void;
2189
2278
  };
2190
2279
  promptSessionTranscript: {
@@ -2312,6 +2401,14 @@ export interface SessionManagerAPI {
2312
2401
  * (lib/epic/activeIndexMerge.cjs) — persistActiveIndex sends only its own
2313
2402
  * in-memory contribution for the cwd; disk stays main's truth, merged
2314
2403
  * inside the same lock epicMint.cjs's ensureEpic serializes through. */
2404
+ /** Read-tier (remote-safe) Sessions reads, fenced to a registered project's
2405
+ * prompt-sessions ops dir (main/promptSessionsIpc.cjs). Reject on a cwd
2406
+ * that is not a registered project root. */
2407
+ loadActiveIndex: (payload: { cwd: string }) => Promise<{ exists: boolean; data: unknown; error?: string }>;
2408
+ listArchived: (payload: { cwd: string }) => Promise<{ ok: boolean; ids: string[]; error?: string }>;
2409
+ readArchived: (payload: { cwd: string; epicId: string }) => Promise<{ exists: boolean; data: unknown; error?: string }>;
2410
+ readSessionTranscript: (payload: { cwd: string; sessionId: string }) => Promise<{ exists: boolean; text: string; error?: string }>;
2411
+ writeArchive: (payload: { cwd: string; epicId: string; archive: Record<string, unknown> }) => Promise<{ ok: true }>;
2315
2412
  mergeActiveIndex: (payload: PromptSessionsMergeActiveIndexPayload) => Promise<PromptSessionsMergeActiveIndexResult>;
2316
2413
  /** Mints a brand-new 'proposed' Epic through main's own ensureEpic()
2317
2414
  * (lib/epic/promptSessionsCreateEpic.cjs) instead of the renderer
@@ -2367,6 +2464,8 @@ export interface PromptSessionsCreateEpicPayload {
2367
2464
  /** Per-Epic model/effort overrides (New Session card); omitted = the persona's own. */
2368
2465
  model?: string;
2369
2466
  effort?: string;
2467
+ /** Absent = develop loop on; false = started without it, fixed for the life of the session. */
2468
+ developLoop?: boolean;
2370
2469
  source?: {
2371
2470
  producer: 'new-epic-ui' | 'scheduler-dispatch';
2372
2471
  prdSlug?: string;
@@ -2384,6 +2483,8 @@ export interface PromptSessionsCreateEpicPayload {
2384
2483
  label: string;
2385
2484
  text: string;
2386
2485
  source?: string;
2486
+ /** Which part of its AIM slot this entry is; absent on Epics minted before AIM sections. */
2487
+ part?: 'persona' | 'grounding' | 'injection' | 'reference' | 'job-type' | 'goal';
2387
2488
  }>;
2388
2489
  }
2389
2490
 
@@ -174,6 +174,13 @@
174
174
  "kind": "on",
175
175
  "remote": "read"
176
176
  },
177
+ {
178
+ "ns": "app",
179
+ "method": "onOpenFreeHour",
180
+ "channel": "app:open-free-hour",
181
+ "kind": "on",
182
+ "remote": "deny"
183
+ },
177
184
  {
178
185
  "ns": "pty",
179
186
  "method": "spawn",
@@ -279,6 +286,13 @@
279
286
  "kind": "invoke",
280
287
  "remote": "read"
281
288
  },
289
+ {
290
+ "ns": "transcripts",
291
+ "method": "exists",
292
+ "channel": "transcript:exists",
293
+ "kind": "invoke",
294
+ "remote": "read"
295
+ },
282
296
  {
283
297
  "ns": "transcripts",
284
298
  "method": "usageFor",
@@ -433,6 +447,20 @@
433
447
  "kind": "invoke",
434
448
  "remote": "mutate"
435
449
  },
450
+ {
451
+ "ns": "macros",
452
+ "method": "dispatchJob",
453
+ "channel": "macros:dispatch-job",
454
+ "kind": "invoke",
455
+ "remote": "mutate"
456
+ },
457
+ {
458
+ "ns": "macros",
459
+ "method": "jobStatus",
460
+ "channel": "macros:job-status",
461
+ "kind": "invoke",
462
+ "remote": "read"
463
+ },
436
464
  {
437
465
  "ns": "macros",
438
466
  "method": "onChanged",
@@ -1301,6 +1329,20 @@
1301
1329
  "kind": "invoke",
1302
1330
  "remote": "mutate"
1303
1331
  },
1332
+ {
1333
+ "ns": "projectPages",
1334
+ "method": "rename",
1335
+ "channel": "project-pages:rename",
1336
+ "kind": "invoke",
1337
+ "remote": "mutate"
1338
+ },
1339
+ {
1340
+ "ns": "projectPages",
1341
+ "method": "delete",
1342
+ "channel": "project-pages:delete",
1343
+ "kind": "invoke",
1344
+ "remote": "mutate"
1345
+ },
1304
1346
  {
1305
1347
  "ns": "projectPages",
1306
1348
  "method": "onChanged",
@@ -1651,6 +1693,41 @@
1651
1693
  "kind": "invoke",
1652
1694
  "remote": "mutate"
1653
1695
  },
1696
+ {
1697
+ "ns": "promptSessions",
1698
+ "method": "loadActiveIndex",
1699
+ "channel": "promptSessions:load-active-index",
1700
+ "kind": "invoke",
1701
+ "remote": "read"
1702
+ },
1703
+ {
1704
+ "ns": "promptSessions",
1705
+ "method": "listArchived",
1706
+ "channel": "promptSessions:list-archived",
1707
+ "kind": "invoke",
1708
+ "remote": "read"
1709
+ },
1710
+ {
1711
+ "ns": "promptSessions",
1712
+ "method": "readArchived",
1713
+ "channel": "promptSessions:read-archived",
1714
+ "kind": "invoke",
1715
+ "remote": "read"
1716
+ },
1717
+ {
1718
+ "ns": "promptSessions",
1719
+ "method": "readSessionTranscript",
1720
+ "channel": "promptSessions:read-session-transcript",
1721
+ "kind": "invoke",
1722
+ "remote": "read"
1723
+ },
1724
+ {
1725
+ "ns": "promptSessions",
1726
+ "method": "writeArchive",
1727
+ "channel": "promptSessions:write-archive",
1728
+ "kind": "invoke",
1729
+ "remote": "mutate"
1730
+ },
1654
1731
  {
1655
1732
  "ns": "promptSessions",
1656
1733
  "method": "createWorktree",