claude-code-session-manager 0.127.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 (76) hide show
  1. package/dist/assets/{AgentLibrary-DKQznr7o.js → AgentLibrary-cNQU5YWy.js} +1 -1
  2. package/dist/assets/{Button-CZXqmIiM.js → Button-9dIPAOBg.js} +1 -1
  3. package/dist/assets/{DataModel-piyV33To.js → DataModel-DrDJ6ysw.js} +1 -1
  4. package/dist/assets/{History-BxwtrKF2.js → History-4rrDdWNP.js} +1 -1
  5. package/dist/assets/{Hooks-DogeSPII.js → Hooks-Bj_jF5Pa.js} +1 -1
  6. package/dist/assets/{Library-BDt6EeQQ.js → Library-D-Wsxrh7.js} +1 -1
  7. package/dist/assets/{ListDetail-CwS-LKar.js → ListDetail-D7Om0H8j.js} +1 -1
  8. package/dist/assets/{McpServers-D2HVljgS.js → McpServers-CbIbSd5o.js} +1 -1
  9. package/dist/assets/{Memory-hNzuOGn8.js → Memory-DgQlvQrO.js} +1 -1
  10. package/dist/assets/{Panel-BLDrsUeq.js → Panel-DZHiD8Ar.js} +1 -1
  11. package/dist/assets/{Permissions-DzZ5vaJW.js → Permissions-CfzduF4B.js} +1 -1
  12. package/dist/assets/{Plugins-Cz9yaxzG.js → Plugins-D-AG5nAo.js} +2 -2
  13. package/dist/assets/{ProvenanceBadge-CCgLO4m9.js → ProvenanceBadge-B9JSEjll.js} +1 -1
  14. package/dist/assets/{SaveBar-Shmn699J.js → SaveBar-mVKig6hL.js} +1 -1
  15. package/dist/assets/{Scheduler-Bqr0WHNd.js → Scheduler-DFTCnh60.js} +1 -1
  16. package/dist/assets/{ScopeSwitcher-CBx1fB5g.js → ScopeSwitcher-s8J-yr7Z.js} +1 -1
  17. package/dist/assets/{Settings-Ci8in-yF.js → Settings-BTmxRMaP.js} +1 -1
  18. package/dist/assets/{SkillReferenceGraph-BWwljba8.js → SkillReferenceGraph-C5lKqf5y.js} +1 -1
  19. package/dist/assets/{Skills-BON6o-c4.js → Skills-CxOacq0k.js} +1 -1
  20. package/dist/assets/{SystemPrompt-D5epIYYs.js → SystemPrompt-BCWg5FAz.js} +1 -1
  21. package/dist/assets/{TagLibrary-C2qDZROJ.js → TagLibrary-BnF0_PkG.js} +1 -1
  22. package/dist/assets/{TiptapBody-SZhI3-bW.js → TiptapBody-C2Iu6rZd.js} +1 -1
  23. package/dist/assets/{Toggle-C_qFDG0g.js → Toggle-C-oD66BG.js} +1 -1
  24. package/dist/assets/{ViewTabs-C9q5WCEd.js → ViewTabs-Cs4v7vLY.js} +1 -1
  25. package/dist/assets/{historyTotals-BCl7IOhY.js → historyTotals-CbRSLD8f.js} +1 -1
  26. package/dist/assets/{index-BnKaYERU.css → index-DtdWBGrI.css} +1 -1
  27. package/dist/assets/index-DzY_GXYY.js +3081 -0
  28. package/dist/assets/{settingsSchema-BBrRBrBr.js → settingsSchema-bSBfHuan.js} +1 -1
  29. package/dist/assets/{skillFrontmatter-B01qJk6N.js → skillFrontmatter-BEseWm8r.js} +1 -1
  30. package/dist/assets/{useAgentsDirWatch-CuR3GSjS.js → useAgentsDirWatch-CdyHxKCI.js} +1 -1
  31. package/dist/index.html +2 -2
  32. package/dist-web/app.css +1 -1
  33. package/dist-web/app.js +343 -341
  34. package/package.json +1 -1
  35. package/scripts/scheduler-mcp-server.cjs +170 -6
  36. package/src/main/build-info.json +4 -4
  37. package/src/main/index.cjs +14 -0
  38. package/src/main/ipcSchemas.cjs +107 -0
  39. package/src/main/lib/claude/agentModelResolve.cjs +26 -7
  40. package/src/main/lib/claude/personaToolScope.cjs +40 -2
  41. package/src/main/lib/demo-video-kit/capture.cjs +113 -0
  42. package/src/main/lib/demo-video-kit/character.cjs +97 -0
  43. package/src/main/lib/demo-video-kit/checks.cjs +150 -0
  44. package/src/main/lib/demo-video-kit/frames.cjs +200 -0
  45. package/src/main/lib/demo-video-kit/seedKit.cjs +52 -0
  46. package/src/main/lib/demo-video-kit/sound.cjs +312 -0
  47. package/src/main/lib/epic/epicValidationHook.cjs +17 -1
  48. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +185 -34
  49. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +15 -0
  50. package/src/main/lib/mcpToolCatalog.cjs +71 -11
  51. package/src/main/lib/opsOwnership.cjs +9 -5
  52. package/src/main/lib/persona-macro/builtinMacros.cjs +19 -5
  53. package/src/main/lib/persona-macro/macroJobDispatch.cjs +116 -0
  54. package/src/main/lib/persona-macro/macroJobIpc.cjs +50 -0
  55. package/src/main/lib/persona-macro/macroJobStatus.cjs +112 -0
  56. package/src/main/lib/persona-macro/macroLibrary.cjs +16 -0
  57. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +89 -0
  58. package/src/main/lib/prd/prdCreate.cjs +12 -1
  59. package/src/main/lib/prd/prdFrontmatter.cjs +7 -2
  60. package/src/main/lib/project-pages/pagesLibrary.cjs +171 -0
  61. package/src/main/lib/project-pages/playerBridge.cjs +129 -0
  62. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  63. package/src/main/lib/smfileHeaders.cjs +11 -3
  64. package/src/main/projectPages.cjs +107 -30
  65. package/src/main/promptSessionsIpc.cjs +131 -0
  66. package/src/main/scheduler/prdParser.cjs +2 -0
  67. package/src/main/scheduler.cjs +26 -9
  68. package/src/main/seedSchedulerMcp.cjs +10 -1
  69. package/src/main/transcripts.cjs +8 -0
  70. package/src/main/webRemote.cjs +3 -1
  71. package/src/preload/api.d.ts +101 -5
  72. package/src/preload/apiSurface.json +70 -0
  73. package/src/preload/index.cjs +13 -0
  74. package/src/seed/agents/demo-video-builder.md +86 -36
  75. package/src/seed/agents/project-home-builder.md +26 -13
  76. package/dist/assets/index-CMIYLbPb.js +0 -3079
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-session-manager",
3
- "version": "0.127.0",
3
+ "version": "0.128.0",
4
4
  "description": "Local cockpit for the Claude Code CLI — multi-tab terminal, full config surface, scheduler, voice dictation, and live observability.",
5
5
  "type": "module",
6
6
  "main": "src/main/index.cjs",
@@ -13,6 +13,9 @@
13
13
  *
14
14
  * project_home_write({ cwd?, html }) -> POST /admin/project-home/write
15
15
  * project_demo_video_write({ cwd?, html? | htmlPath? }) -> POST /admin/project-home/demo-video/write
16
+ * project_page_write({ cwd?, pageId, title, topic?, html? | htmlPath? }) -> POST /admin/project-home/pages/write
17
+ * project_character_write({ cwd?, json, js? | jsPath?, replace? }) -> POST /admin/project-home/character/write
18
+ * project_video_write({ cwd?, videoId, title, kind, lengthS, html? | htmlPath?, meta? }) -> POST /admin/project-home/videos/write
16
19
  *
17
20
  * macro_list({ cwd? }) -> GET /admin/macros?cwd=<encoded>
18
21
  * macro_save({ cwd?, id?, label, agentName, tag, prompt }) -> POST /admin/macros/save
@@ -22,8 +25,11 @@
22
25
  *
23
26
  * This is a separate process from the Electron app — it only ever reaches
24
27
  * it over the token-authed loopback HTTP API in admin-api.json, never by
25
- * requiring scheduler.cjs/localAdminHttp.cjs directly. The admin server IS the
26
- * security boundary; this file stays on the client side of it.
28
+ * requiring scheduler.cjs/localAdminHttp.cjs directly. The admin API (loopback +
29
+ * bearer token) is the boundary against other users and remote callers, not
30
+ * against a job running as the same user (it can read admin-api.json). The env
31
+ * refusals in this file (job tool scope, headless queue, macro delete) are
32
+ * guardrails for agents acting in good faith, not containment.
27
33
  */
28
34
 
29
35
  'use strict';
@@ -57,6 +63,23 @@ function withPointer(text) {
57
63
  }
58
64
 
59
65
  const MAX_DEMO_VIDEO_BYTES = 2 * 1024 * 1024;
66
+ const MAX_CHARACTER_JS_BYTES = 300 * 1024;
67
+
68
+ /** Reads a local .js file for project_character_write; errors carry only the reason, never file contents. */
69
+ async function readCharacterJsFile(p) {
70
+ if (typeof p !== 'string' || !path.isAbsolute(p)) return { error: 'jsPath must be an absolute path' };
71
+ if (!/\.(c|m)?js$/i.test(p)) return { error: 'jsPath must end in .js' };
72
+ try {
73
+ const st = await fsp.stat(p);
74
+ if (!st.isFile()) return { error: 'jsPath is not a regular file' };
75
+ if (st.size > MAX_CHARACTER_JS_BYTES) return { error: `jsPath file exceeds ${MAX_CHARACTER_JS_BYTES} bytes` };
76
+ const js = await fsp.readFile(p, 'utf8');
77
+ if (js.length === 0) return { error: 'jsPath file is empty' };
78
+ return { js };
79
+ } catch (err) {
80
+ return { error: `cannot read jsPath: ${err && err.code ? err.code : 'read failed'}` };
81
+ }
82
+ }
60
83
 
61
84
  /** Reads a local .html/.htm file for project_demo_video_write; errors carry only the reason, never file contents. */
62
85
  async function readDemoVideoHtmlFile(p) {
@@ -74,6 +97,16 @@ async function readDemoVideoHtmlFile(p) {
74
97
  }
75
98
  }
76
99
 
100
+ /** Resolves exactly one of html / htmlPath into { html } or { error }. */
101
+ async function resolveHtmlArg(args) {
102
+ const hasHtml = !!args && args.html !== undefined && args.html !== null && args.html !== '';
103
+ const hasPath = !!args && args.htmlPath !== undefined && args.htmlPath !== null && args.htmlPath !== '';
104
+ if (hasHtml === hasPath) return { error: 'provide exactly one of html or htmlPath' };
105
+ if (hasPath) return readDemoVideoHtmlFile(args.htmlPath);
106
+ if (typeof args.html !== 'string') return { error: 'missing required argument: html' };
107
+ return { html: args.html };
108
+ }
109
+
77
110
  function errorResult(text) {
78
111
  return { content: [{ type: 'text', text: withPointer(text) }], isError: true };
79
112
  }
@@ -477,11 +510,26 @@ const TOOLS = [
477
510
  type: 'object',
478
511
  properties: {
479
512
  cwd: { type: 'string', description: "Optional: absolute path to the target project. Defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted." },
480
- html: { type: 'string', description: 'The complete self-contained HTML document (<= 1MB; no <script src>, <link href=http*>, @import, or url(http*)).' },
513
+ html: { type: 'string', description: 'The complete self-contained HTML document (<= 1MB; inline <style> only — scripts never run in a page; no <script src>, <link href=http*>, @import, or url(http*)).' },
481
514
  },
482
515
  required: ['html'],
483
516
  },
484
517
  },
518
+ {
519
+ name: 'project_character_write',
520
+ description: descriptionFor('project_character_write'),
521
+ inputSchema: {
522
+ type: 'object',
523
+ properties: {
524
+ cwd: { type: 'string', description: "Optional: absolute path to the target project. Defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted." },
525
+ json: { description: 'The character descriptor: a JSON object (or its JSON text).' },
526
+ js: { type: 'string', description: 'The character drawing module source (<= 300KB; no remote references or network-capable APIs). Give exactly one of js / jsPath.' },
527
+ jsPath: { type: 'string', description: 'Absolute path to a local .js file holding the module (same rules as js; <= 300KB). Give exactly one of js / jsPath.' },
528
+ replace: { type: 'boolean', description: 'Overwrite an existing character. Without it an existing character is refused with 409.' },
529
+ },
530
+ required: ['json'],
531
+ },
532
+ },
485
533
  {
486
534
  name: 'project_demo_video_write',
487
535
  description: descriptionFor('project_demo_video_write'),
@@ -491,11 +539,11 @@ const TOOLS = [
491
539
  cwd: { type: 'string', description: "Optional: absolute path to the target project. Defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted." },
492
540
  html: {
493
541
  type: 'string',
494
- description: 'The complete self-contained HTML/JS document for a 30-second-or-less demo video (<= 2MB). '
542
+ description: 'The complete self-contained HTML/JS document for a demo video of 60 seconds or less (<= 2MB). '
495
543
  + 'It is rejected for: being empty; <script src>, <link href=http*>, @import, or url(http*) (no remote references); '
496
544
  + 'fetch/XMLHttpRequest/WebSocket/EventSource/sendBeacon/dynamic import/importScripts/<iframe>/<object>/<embed>/window.open/'
497
545
  + 'any http(s)/// src or href (no network-capable APIs — the document is CSP-fenced after it is written); '
498
- + 'or missing a <meta name="sm-demo-duration" content="N"> tag with 5 <= N <= 30.',
546
+ + 'or missing a <meta name="sm-demo-duration" content="N"> tag with 5 <= N <= 60.',
499
547
  },
500
548
  htmlPath: {
501
549
  type: 'string',
@@ -505,6 +553,40 @@ const TOOLS = [
505
553
  },
506
554
  },
507
555
  },
556
+ {
557
+ name: 'project_page_write',
558
+ description: descriptionFor('project_page_write'),
559
+ inputSchema: {
560
+ type: 'object',
561
+ properties: {
562
+ cwd: { type: 'string', description: "Optional: absolute path to the target project. Defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted." },
563
+ pageId: { type: 'string', description: 'Stable id (kebab-case) of the knowledge page; writing the same id replaces that page.' },
564
+ title: { type: 'string', description: 'Human title shown in the page list.' },
565
+ topic: { type: 'string', description: 'Optional: one-line topic/summary of the page.' },
566
+ html: { type: 'string', description: 'The complete self-contained HTML document (<= 1MB). Inline <style> only; scripts never run in a page. No <script src>, <link href=http*>, @import, or url(http*).' },
567
+ htmlPath: { type: 'string', description: 'Absolute path to a local .html/.htm file holding the document (same rules as html). Give exactly one of html / htmlPath.' },
568
+ },
569
+ required: ['pageId', 'title'],
570
+ },
571
+ },
572
+ {
573
+ name: 'project_video_write',
574
+ description: descriptionFor('project_video_write'),
575
+ inputSchema: {
576
+ type: 'object',
577
+ properties: {
578
+ cwd: { type: 'string', description: "Optional: absolute path to the target project. Defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted." },
579
+ videoId: { type: 'string', description: 'Stable id (kebab-case) of the video; writing the same id replaces that video.' },
580
+ title: { type: 'string', description: 'Human title shown in the video list.' },
581
+ kind: { type: 'string', description: 'What the video is, e.g. project-demo or marketing.' },
582
+ lengthS: { type: 'number', description: 'Length of the video in seconds.' },
583
+ html: { type: 'string', description: 'The complete self-contained HTML/JS video document (<= 2MB; no remote references or network-capable APIs).' },
584
+ htmlPath: { type: 'string', description: 'Absolute path to a local .html/.htm file holding the document (<= 2MB). Prefer this for base64 data URIs. Give exactly one of html / htmlPath.' },
585
+ meta: { type: 'object', description: 'Optional: free-form metadata object stored with the video.' },
586
+ },
587
+ required: ['videoId', 'title', 'kind', 'lengthS'],
588
+ },
589
+ },
508
590
  {
509
591
  name: 'macro_list',
510
592
  description: descriptionFor('macro_list'),
@@ -593,6 +675,36 @@ const TOOLS = [
593
675
  },
594
676
  ];
595
677
 
678
+ // SM_SCHEDULER_JOB_MCP_TOOLS: JSON array of full mcp__<server>__<tool> names a
679
+ // scoped job may use. Unset = no filter. Malformed = fail closed. Guardrail only.
680
+ function jobToolScope() {
681
+ const raw = process.env.SM_SCHEDULER_JOB_MCP_TOOLS;
682
+ if (raw === undefined) return null;
683
+ let parsed;
684
+ try { parsed = JSON.parse(raw); } catch { return { names: new Set(), malformed: true }; }
685
+ if (!Array.isArray(parsed) || !parsed.every((e) => typeof e === 'string')) {
686
+ return { names: new Set(), malformed: true };
687
+ }
688
+ const names = new Set();
689
+ for (const entry of parsed) {
690
+ if (!entry.startsWith('mcp__')) continue;
691
+ const i = entry.indexOf('__', 5);
692
+ if (i > 0) names.add(entry.slice(i + 2));
693
+ }
694
+ return { names, malformed: false };
695
+ }
696
+
697
+ function jobToolScopeRefusal(toolName) {
698
+ const scope = jobToolScope();
699
+ if (!scope || (!scope.malformed && scope.names.has(toolName))) return null;
700
+ const text = scope.malformed
701
+ ? `refused: ${toolName} was not run because SM_SCHEDULER_JOB_MCP_TOOLS is malformed (expected a JSON array of tool-name strings). `
702
+ + 'Say in your final result that the tool scope is malformed and stop.'
703
+ : `refused: ${toolName} is outside the tool scope of headless scheduled job '${process.env.SM_SCHEDULER_JOB_SLUG || '(unknown)'}' — its persona does not list it. `
704
+ + "Starting this server yourself does not widen a job's scope. Say in your final result which tool was missing and stop.";
705
+ return { content: [{ type: 'text', text }], isError: true };
706
+ }
707
+
596
708
  // A macro is a human's button and its delete cannot be undone, so this runs
597
709
  // only in a session a human is attached to. headlessQueueRefusal does not fit:
598
710
  // it lets an architect job through.
@@ -642,6 +754,8 @@ function withCreateOrigin(payload) {
642
754
 
643
755
  async function handleCallTool(request) {
644
756
  const { name, arguments: args } = request.params;
757
+ const scopeRefusal = jobToolScopeRefusal(name);
758
+ if (scopeRefusal) return scopeRefusal;
645
759
  try {
646
760
  if (name === 'scheduler_reset_job') {
647
761
  const slug = args && typeof args.slug === 'string' ? args.slug : null;
@@ -857,6 +971,28 @@ async function handleCallTool(request) {
857
971
  const result = await adminRequest('POST', '/admin/project-home/write', { cwd, html: args.html });
858
972
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
859
973
  }
974
+ if (name === 'project_character_write') {
975
+ if (!args || args.json === undefined || args.json === null || args.json === '') {
976
+ return errorResult('missing required argument: json');
977
+ }
978
+ const hasJs = args.js !== undefined && args.js !== null && args.js !== '';
979
+ const hasJsPath = args.jsPath !== undefined && args.jsPath !== null && args.jsPath !== '';
980
+ if (hasJs === hasJsPath) return errorResult('provide exactly one of js or jsPath');
981
+ let js;
982
+ if (hasJsPath) {
983
+ const loaded = await readCharacterJsFile(args.jsPath);
984
+ if (loaded.error) return errorResult(loaded.error);
985
+ js = loaded.js;
986
+ } else {
987
+ if (typeof args.js !== 'string') return errorResult('missing required argument: js');
988
+ js = args.js;
989
+ }
990
+ const cwd = resolveCwdArg(args);
991
+ const body = { cwd, json: args.json, js };
992
+ if (args.replace === true) body.replace = true;
993
+ const result = await adminRequest('POST', '/admin/project-home/character/write', body);
994
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
995
+ }
860
996
  if (name === 'project_demo_video_write') {
861
997
  const hasHtml = !!args && args.html !== undefined && args.html !== null && args.html !== '';
862
998
  const hasPath = !!args && args.htmlPath !== undefined && args.htmlPath !== null && args.htmlPath !== '';
@@ -876,6 +1012,31 @@ async function handleCallTool(request) {
876
1012
  const result = await adminRequest('POST', '/admin/project-home/demo-video/write', { cwd, html });
877
1013
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
878
1014
  }
1015
+ if (name === 'project_page_write') {
1016
+ if (!args || typeof args.pageId !== 'string' || !args.pageId || typeof args.title !== 'string' || !args.title) {
1017
+ return errorResult('missing required arguments: pageId, title');
1018
+ }
1019
+ const loaded = await resolveHtmlArg(args);
1020
+ if (loaded.error) return errorResult(loaded.error);
1021
+ const cwd = resolveCwdArg(args);
1022
+ const body = { cwd, pageId: args.pageId, title: args.title, html: loaded.html };
1023
+ if (typeof args.topic === 'string' && args.topic) body.topic = args.topic;
1024
+ const result = await adminRequest('POST', '/admin/project-home/pages/write', body);
1025
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
1026
+ }
1027
+ if (name === 'project_video_write') {
1028
+ if (!args || typeof args.videoId !== 'string' || !args.videoId || typeof args.title !== 'string' || !args.title
1029
+ || typeof args.kind !== 'string' || !args.kind || typeof args.lengthS !== 'number' || !Number.isFinite(args.lengthS)) {
1030
+ return errorResult('missing required arguments: videoId, title, kind, lengthS');
1031
+ }
1032
+ const loaded = await resolveHtmlArg(args);
1033
+ if (loaded.error) return errorResult(loaded.error);
1034
+ const cwd = resolveCwdArg(args);
1035
+ const body = { cwd, videoId: args.videoId, title: args.title, kind: args.kind, lengthS: args.lengthS, html: loaded.html };
1036
+ if (args.meta && typeof args.meta === 'object') body.meta = args.meta;
1037
+ const result = await adminRequest('POST', '/admin/project-home/videos/write', body);
1038
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
1039
+ }
879
1040
  if (name === 'macro_list') {
880
1041
  const cwd = resolveCwdArg(args);
881
1042
  const result = await adminRequest('GET', `/admin/macros?cwd=${encodeURIComponent(cwd)}`);
@@ -969,7 +1130,10 @@ async function main() {
969
1130
  createStdioServer({
970
1131
  name: 'session-manager-scheduler',
971
1132
  version: '1.0.0',
972
- listTools: () => TOOLS,
1133
+ listTools: () => {
1134
+ const scope = jobToolScope();
1135
+ return scope ? TOOLS.filter((t) => scope.names.has(t.name)) : TOOLS;
1136
+ },
973
1137
  callTool: (params) => handleCallTool({ params }),
974
1138
  }).start();
975
1139
  }
@@ -1,8 +1,8 @@
1
1
  {
2
- "version": "0.127.0",
3
- "gitSha": "40558ffe7293dc3e982e98ea4eb282c9c72824c9",
4
- "gitShortSha": "40558ffe",
2
+ "version": "0.128.0",
3
+ "gitSha": "649aeb30ca19187ef19b347f5482b984304b4943",
4
+ "gitShortSha": "649aeb30",
5
5
  "gitBranch": "HEAD",
6
- "builtAt": "2026-11-03T03:08:26.011Z",
6
+ "builtAt": "2026-11-06T07:00:20.246Z",
7
7
  "dirty": false
8
8
  }
@@ -103,6 +103,7 @@ const queueOps = require('./queueOps.cjs');
103
103
  const pluginInstall = require('./pluginInstall.cjs');
104
104
  const { seedDevPlugin } = require('./seedDevPlugin.cjs');
105
105
  const { seedAgentPersonas } = require('./seedAgentPersonas.cjs');
106
+ const { seedDemoVideoKit } = require('./lib/demo-video-kit/seedKit.cjs');
106
107
  const { seedSchedulerMcp } = require('./seedSchedulerMcp.cjs');
107
108
  const { runSeedersSerially } = require('./lib/runSeeders.cjs');
108
109
  const { getSeedStatus } = require('./seedStatus.cjs');
@@ -606,6 +607,16 @@ function broadcastMacrosChanged() {
606
607
  sendIfAlive(mainWindow, 'macros:changed', {});
607
608
  }
608
609
  ipcMain.handle('macros:list', () => macroLibrary.listMacros());
610
+ // Background macro jobs: dispatch a built-in macro as a scheduler PRD inside an existing Epic.
611
+ // createPrd is wired exactly as chat:create-prd (below) so its own reconcile request queues the row.
612
+ require('./lib/persona-macro/macroJobIpc.cjs').registerMacroJobIpc(ipcMain, {
613
+ schemas,
614
+ validatePath: require('./config.cjs').validatePath,
615
+ readActiveIndex: require('./lib/epic/epicMint.cjs').readActiveIndex,
616
+ createPrd: (input) => prdCreate.createPrd(input, scheduler.remote),
617
+ loadJobs: async () => (await require('./lib/scheduler/queueStore.cjs').readMerged()).jobs || [],
618
+ archivePrd: (slug, cwd) => queueOps.archiveMany([slug], cwd),
619
+ });
609
620
  ipcMain.handle('macros:save', validated(schemas.macrosSave, async (payload) => {
610
621
  const macro = await macroLibrary.saveMacro(payload);
611
622
  broadcastMacrosChanged();
@@ -1042,6 +1053,7 @@ registerLoopEfficiencyHandlers();
1042
1053
  pluginInstall.registerPluginInstallHandlers();
1043
1054
  memoryTool.registerMemoryHandlers();
1044
1055
  activeIndexMerge.registerActiveIndexMergeHandlers();
1056
+ require('./promptSessionsIpc.cjs').registerPromptSessionsReadHandlers();
1045
1057
  promptSessionsCreateEpic.registerPromptSessionsCreateEpicHandlers();
1046
1058
  require('./lib/epic/archivedTranscript.cjs').registerIpc(ipcMain);
1047
1059
  customerFeedbackIpc.registerCustomerFeedbackHandlers();
@@ -1522,6 +1534,8 @@ app.whenReady().then(async () => {
1522
1534
  bootSeedingPromise = runSeedersSerially([
1523
1535
  { name: 'dev-plugin', run: () => seedDevPlugin({ logger: console, writeLog: logs.writeLine }) },
1524
1536
  { name: 'agent-personas', run: () => seedAgentPersonas({ logger: console, writeLog: logs.writeLine }) },
1537
+ // Demo-video kit -> ~/.claude/session-manager/demo-video-kit/ (stamp-gated). SM_SEED_DEMO_VIDEO_KIT_DISABLE=1 to opt out.
1538
+ { name: 'demo-video-kit', run: () => seedDemoVideoKit({ logger: console, writeLog: logs.writeLine }) },
1525
1539
  { name: 'scheduler-mcp', run: () => seedSchedulerMcp({ logger: console, writeLog: logs.writeLine }) },
1526
1540
  ]).catch((e) => {
1527
1541
  logs.writeLine({ scope: 'seed', level: 'error', message: 'seed chain failed', meta: { error: e?.message } });
@@ -209,6 +209,15 @@ const promptSessionsMergeActiveIndex = z.object({
209
209
  // routes state/promptSessions.ts's createPromptSession through it. `tag`/
210
210
  // `source` reuse promptSessionSchema.cjs's own enums rather than retyping
211
211
  // the value lists a third time.
212
+ // Archive write for markCompleted — main resolves the path via opsPath() and
213
+ // writes as the 'epics' owner, so the renderer (and a remote browser) never
214
+ // hands over a path. `archive` is opaque here; the handler checks its shape.
215
+ const promptSessionsWriteArchive = z.object({
216
+ cwd: z.string().min(1).max(4096),
217
+ epicId: z.string().regex(PROMPT_SESSION_ID_RE),
218
+ archive: z.record(z.string(), z.unknown()),
219
+ }).strict();
220
+
212
221
  const promptSessionsCreateEpic = z.object({
213
222
  cwd: z.string().min(1).max(4096),
214
223
  goalText: z.string().min(1).max(20000),
@@ -233,6 +242,9 @@ const promptSessionsCreateWorktree = z.object({
233
242
  });
234
243
 
235
244
  // Renderer entry point for reopening a completed Epic in place (lib/epic/epicReopen.cjs).
245
+ const promptSessionsCwd = z.object({ cwd: z.string().min(1).max(4096) }).strict();
246
+ const promptSessionsReadArchived = z.object({ cwd: z.string().min(1).max(4096), epicId: z.string().regex(PROMPT_SESSION_ID_RE) }).strict();
247
+ const promptSessionsReadSessionTranscript = z.object({ cwd: z.string().min(1).max(4096), sessionId: z.string().min(1).max(128) }).strict();
236
248
  const promptSessionsReopen = z.object({ cwd: z.string().min(1).max(4096), epicId: z.string().regex(PROMPT_SESSION_ID_RE) }).strict();
237
249
 
238
250
  // Renderer entry point for folding an Epic's isolated git worktree branch
@@ -651,6 +663,14 @@ const agentsSavePersona = AgentPersonaSaveSchema;
651
663
  const macrosSave = MacroSaveSchema;
652
664
  const macrosDelete = MacroDeleteSchema;
653
665
  const macrosSetProject = MacroSetProjectSchema;
666
+ // Background macro job (macroJobIpc.cjs): press a built-in macro as a scheduler PRD inside an existing Epic.
667
+ const macrosDispatchJob = z.object({
668
+ cwd: z.string().min(1).max(4096),
669
+ macroId: z.string().min(1).max(128),
670
+ epicId: z.string().min(1).max(200),
671
+ extraInstructions: z.string().max(4000).optional(),
672
+ });
673
+ const macrosJobStatus = z.object({ cwd: z.string().min(1).max(4096) });
654
674
 
655
675
  // ──────────────────────────────────────────── Memory tool (Bundle C, cycle 3)
656
676
  // Workspace-scoped markdown store at ~/.claude/projects/<ws>/memory/.
@@ -826,6 +846,80 @@ const projectDemoVideoAdminWriteBody = z.object({
826
846
  html: z.string(),
827
847
  }).strict();
828
848
 
849
+ // ──────────────────────────────────────────── Project Home library entries
850
+ // One id rule for every library entry; '_character' starts with '_' so it can
851
+ // never match.
852
+ const ENTRY_ID_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
853
+ const entryId = z.string().regex(ENTRY_ID_RE);
854
+ const projectVideoReportFields = {
855
+ lufs: z.number().nullable(),
856
+ truePeakDb: z.number().nullable(),
857
+ speechS: z.number().nullable(),
858
+ readingGrade: z.number().nullable(),
859
+ checks: z.array(z.object({
860
+ id: z.string().max(60),
861
+ ok: z.boolean(),
862
+ detail: z.string().max(300),
863
+ }).strict()).max(60),
864
+ };
865
+ const projectVideoMeta = z.object({
866
+ id: entryId,
867
+ title: z.string().min(1).max(120),
868
+ kind: z.enum(['project-demo', 'blog-post', 'feature']),
869
+ style: z.string().max(40),
870
+ lengthS: z.number().int().min(5).max(60),
871
+ createdAt: z.string().datetime(),
872
+ character: z.string().max(80).nullable(),
873
+ sources: z.array(z.object({
874
+ claim: z.string().max(300),
875
+ source: z.string().max(600),
876
+ ref: z.string().max(300),
877
+ }).strict()).max(40),
878
+ report: z.object({ ...projectVideoReportFields, bytes: z.number().int() }).strict(),
879
+ macroVersion: z.number().int().min(0),
880
+ seedVersion: z.number().int().min(0),
881
+ model: z.string().max(60),
882
+ effort: z.string().max(60),
883
+ }).strict();
884
+ const projectPagesEntryKind = z.enum(['knowledge', 'video']);
885
+ const projectPagesRename = z.object({
886
+ cwd: z.string().min(1).max(4096),
887
+ kind: projectPagesEntryKind,
888
+ id: entryId,
889
+ title: z.string().min(1).max(120),
890
+ }).strict();
891
+ const projectPagesDelete = z.object({
892
+ cwd: z.string().min(1).max(4096),
893
+ kind: projectPagesEntryKind,
894
+ id: entryId,
895
+ }).strict();
896
+ const projectPageMeta = z.object({
897
+ id: entryId,
898
+ title: z.string().min(1).max(120),
899
+ topic: z.string().max(120),
900
+ createdAt: z.string().datetime(),
901
+ model: z.string().max(60),
902
+ }).strict();
903
+ const projectPageAdminWriteBody = z.object({
904
+ cwd: z.string().min(1).max(4096).optional(),
905
+ pageId: entryId,
906
+ title: z.string().min(1).max(120),
907
+ topic: z.string().max(120).optional(),
908
+ html: z.string(),
909
+ }).strict();
910
+ // Server stamps id, createdAt and report.bytes.
911
+ const projectVideoAdminWriteBody = z.object({
912
+ cwd: z.string().min(1).max(4096).optional(),
913
+ videoId: entryId,
914
+ title: z.string().min(1).max(120),
915
+ kind: z.enum(['project-demo', 'blog-post', 'feature']),
916
+ lengthS: z.number().int().min(5).max(60),
917
+ html: z.string(),
918
+ meta: projectVideoMeta.omit({ id: true, createdAt: true }).extend({
919
+ report: z.object(projectVideoReportFields).strict(),
920
+ }),
921
+ }).strict();
922
+
829
923
  const projectBriefSetPin = z.object({
830
924
  cwd: z.string().min(1).max(4096),
831
925
  block: PROJECT_BRIEF_BLOCK,
@@ -1275,6 +1369,7 @@ module.exports = {
1275
1369
  SCHEDULE_SLUG_RE,
1276
1370
  SCHEDULE_RUN_ID_RE,
1277
1371
  PRD_CREATE_SLUG_RE,
1372
+ ENTRY_ID_RE,
1278
1373
  READ_COMMANDS,
1279
1374
  SAS_GATED_READS,
1280
1375
  MUTATE_COMMANDS,
@@ -1353,17 +1448,27 @@ module.exports = {
1353
1448
  memoryProposeFix,
1354
1449
  projectBriefCwd,
1355
1450
  projectPagesCwd,
1451
+ projectPagesRename,
1452
+ projectPagesDelete,
1356
1453
  projectHomeAdminWriteBody,
1357
1454
  projectDemoVideoAdminWriteBody,
1455
+ projectVideoMeta,
1456
+ projectPageMeta,
1457
+ projectPageAdminWriteBody,
1458
+ projectVideoAdminWriteBody,
1358
1459
  projectBriefSetPin,
1359
1460
  projectBriefUpdate,
1360
1461
  promptSessionTranscriptAppend,
1361
1462
  promptSessionTranscriptRead,
1362
1463
  epicDelegationStatsGet,
1363
1464
  promptSessionsMergeActiveIndex,
1465
+ promptSessionsWriteArchive,
1364
1466
  promptSessionsCreateEpic,
1365
1467
  promptSessionsCreateWorktree,
1366
1468
  promptSessionsReopen,
1469
+ promptSessionsCwd,
1470
+ promptSessionsReadArchived,
1471
+ promptSessionsReadSessionTranscript,
1367
1472
  promptSessionsMergeToMain,
1368
1473
  promptSessionsGetWorktreeDisabled,
1369
1474
  promptSessionsSetWorktreeDisabled,
@@ -1390,6 +1495,8 @@ module.exports = {
1390
1495
  macrosSave,
1391
1496
  macrosDelete,
1392
1497
  macrosSetProject,
1498
+ macrosDispatchJob,
1499
+ macrosJobStatus,
1393
1500
  agentsGetPersonaBody,
1394
1501
  agentsResolveModelInfo,
1395
1502
  modelsCatalog,
@@ -28,11 +28,13 @@
28
28
  */
29
29
 
30
30
  const path = require('node:path');
31
+ const crypto = require('node:crypto');
31
32
  const os = require('node:os');
32
33
  const { splitFrontmatter } = require('../prd/prdFrontmatter.cjs');
33
34
  const { readActiveIndex, resolvePersonaPaths } = require('../epic/epicMint.cjs');
34
35
  const { resolveMergedPersona, PERSONA_NAME_RE } = require('../persona-macro/personaMerge.cjs');
35
36
  const configMgr = require('../../config.cjs');
37
+ const { SHIPPED_PERSONA_SEEDS } = require('../persona-macro/shippedPersonaSeeds.cjs');
36
38
 
37
39
  /** The hardcoded floor every branch of resolveEpicModel falls back to — --model must never be omitted (CLAUDE.md "Automation model pinning"). */
38
40
  const FALLBACK_MODEL = 'sonnet';
@@ -180,17 +182,31 @@ function resolveEpicModel({ cwd, claudeSessionId, fallbackModel = FALLBACK_MODEL
180
182
  /** Mirrors epicIntake.ts's AGENT_BODY_CHAR_CAP — a runaway persona file must
181
183
  * not be able to dominate a spawned job's system prompt either. Duplicated
182
184
  * rather than imported: epicIntake.ts is a renderer module (no ES modules
183
- * in main). */
185
+ * in main).
186
+ *
187
+ * EXEMPTION: a body whose digest matches a version the app itself shipped
188
+ * (SHIPPED_PERSONA_SEEDS) is passed whole — an unedited app-shipped body
189
+ * cannot be a runaway file, and demo-video-builder's style and palette rules
190
+ * sit past 6000 chars, so capping it silently drops them. Every other body
191
+ * (edited, overlay-changed, no manifest entry) stays capped. */
184
192
  const AGENT_BODY_CHAR_CAP = 6000;
185
193
 
194
+ /** sha256 hex of a body (newlines normalized, trimmed). MUST stay the same
195
+ * digest as seedAgentPersonas.cjs's personaBodyHash (not required here: it
196
+ * pulls the seeding writers); the unit test enforces the equality. */
197
+ function shippedBodyHash(body) {
198
+ const normalized = String(body || '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
199
+ return crypto.createHash('sha256').update(normalized.trim()).digest('hex');
200
+ }
201
+
186
202
  /** Trims a persona's frontmatter-stripped body and caps it at
187
- * AGENT_BODY_CHAR_CAP, appending a truncation notice naming `personaPath`
188
- * — same shape as epicIntake.ts's buildPersonaBodyText. Returns null for an
189
- * empty body. */
190
- function buildPersonaBodyText(rawBody, personaPath) {
203
+ * AGENT_BODY_CHAR_CAP (unless `uncapped`), appending a truncation notice
204
+ * naming `personaPath` — same shape as epicIntake.ts's buildPersonaBodyText.
205
+ * Returns null for an empty body. */
206
+ function buildPersonaBodyText(rawBody, personaPath, { uncapped = false } = {}) {
191
207
  const body = (rawBody || '').trim();
192
208
  if (!body) return null;
193
- if (body.length <= AGENT_BODY_CHAR_CAP) return body;
209
+ if (uncapped || body.length <= AGENT_BODY_CHAR_CAP) return body;
194
210
  const truncated = body.slice(0, AGENT_BODY_CHAR_CAP);
195
211
  const pathLabel = personaPath || 'the persona file';
196
212
  return `${truncated}\n\n[Truncated — ${pathLabel} exceeds ${AGENT_BODY_CHAR_CAP} characters; see the file for the full body.]`;
@@ -229,7 +245,9 @@ async function resolvePrdPersonaForSpawn({ cwd, agentType, fallbackModel = FALLB
229
245
  // (older injected reader) is parsed here.
230
246
  const { fm, body } = persona.fm ? persona : splitFrontmatter(persona.text);
231
247
  const model = fm.model && fm.model !== 'inherit' ? fm.model : fallbackModel;
232
- const systemPrompt = buildPersonaBodyText(body, persona.path);
248
+ const digest = shippedBodyHash(body);
249
+ const uncapped = (SHIPPED_PERSONA_SEEDS[agentType] || []).some((e) => e.bodySha256 === digest);
250
+ const systemPrompt = buildPersonaBodyText(body, persona.path, { uncapped });
233
251
  const parseTools = deps.parseTools || require('../../agentLibrary.cjs').parseTools;
234
252
  const list = parseTools(typeof fm.tools === 'string' ? fm.tools : '');
235
253
  return { model, systemPrompt, personaPath: persona.path, tools: list.length ? list : null };
@@ -241,6 +259,7 @@ async function resolvePrdPersonaForSpawn({ cwd, agentType, fallbackModel = FALLB
241
259
  module.exports = {
242
260
  FALLBACK_MODEL,
243
261
  AGENT_BODY_CHAR_CAP,
262
+ shippedBodyHash,
244
263
  resolveEpicModel,
245
264
  findAgentTypeByClaudeSessionId,
246
265
  findEpicByClaudeSessionId,
@@ -11,6 +11,11 @@
11
11
  * prompt, CLAUDE.md, `--append-system-prompt` and `--disallowedTools` keep
12
12
  * working.
13
13
  *
14
+ * Scoping is focus, not containment: the scope decides which tools a job is
15
+ * offered. Every headless job runs as the owner's OS user with
16
+ * --dangerously-skip-permissions, so a job with Bash can still start an MCP
17
+ * server or call the admin API itself.
18
+ *
14
19
  * Pure: no fs, and no require of scheduler.cjs (cycle) — the caller passes its
15
20
  * HEADLESS_DISALLOWED_TOOLS list in.
16
21
  */
@@ -45,9 +50,12 @@ function buildPersonaToolScope(tools, { disallowed = [] } = {}) {
45
50
 
46
51
  /**
47
52
  * @param {{ tools: string[] }|null} scope result of buildPersonaToolScope
53
+ * @param {{ mcpServers?: Record<string, object> }} [opts] known MCP server
54
+ * definitions by name. When EVERY mcp__ tool in scope names a server here,
55
+ * only those servers are passed (--mcp-config <json> --strict-mcp-config).
48
56
  * @returns {string[]} argv fragment ([] when unscoped)
49
57
  */
50
- function personaToolScopeArgs(scope) {
58
+ function personaToolScopeArgs(scope, { mcpServers } = {}) {
51
59
  if (!scope) return [];
52
60
  const def = {
53
61
  description: 'Headless run with a scheduler-enforced tool scope.',
@@ -60,13 +68,43 @@ function personaToolScopeArgs(scope) {
60
68
  ];
61
69
  // A scope naming no MCP tool never uses a server: with --strict-mcp-config and
62
70
  // no --mcp-config (variadic; would swallow later args) the CLI boots none.
63
- if (!scope.tools.some((t) => String(t).startsWith('mcp__'))) {
71
+ const mcpTools = scope.tools.map(String).filter((t) => t.startsWith('mcp__'));
72
+ if (mcpTools.length === 0) {
64
73
  args.push('--strict-mcp-config');
74
+ return args;
75
+ }
76
+ // Server name = the segment between `mcp__` and the next `__`.
77
+ const named = new Set(mcpTools.map((t) => t.slice(5).split('__')[0]));
78
+ const known = mcpServers || {};
79
+ const allKnown = [...named].every((n) => n && Object.prototype.hasOwnProperty.call(known, n));
80
+ if (allKnown) {
81
+ const picked = {};
82
+ for (const n of named) picked[n] = known[n];
83
+ // --mcp-config is variadic: the caller must keep a `--flag` right after.
84
+ args.push('--mcp-config', JSON.stringify({ mcpServers: picked }), '--strict-mcp-config');
65
85
  }
66
86
  return args;
67
87
  }
68
88
 
89
+ const JOB_MCP_TOOLS_ENV = 'SM_SCHEDULER_JOB_MCP_TOOLS';
90
+
91
+ /**
92
+ * Env fragment a scoped job carries so an out-of-process MCP server can tell
93
+ * which MCP tools the scope admits. scripts/scheduler-mcp-server.cjs reads it
94
+ * to list and serve only in-scope tools. The value is always a JSON array
95
+ * string; '[]' means no MCP tool.
96
+ * @param {{ tools: string[] }|null|undefined} scope
97
+ * @returns {Record<string, string>} {} when unscoped
98
+ */
99
+ function personaToolScopeEnv(scope) {
100
+ if (!scope) return {};
101
+ const mcp = scope.tools.map(String).filter((t) => t.startsWith('mcp__'));
102
+ return { [JOB_MCP_TOOLS_ENV]: JSON.stringify(mcp) };
103
+ }
104
+
69
105
  module.exports = {
106
+ JOB_MCP_TOOLS_ENV,
107
+ personaToolScopeEnv,
70
108
  HEADLESS_TOOL_FLOOR,
71
109
  HEADLESS_SCOPE_AGENT_NAME,
72
110
  buildPersonaToolScope,