claude-code-session-manager 0.133.1 → 0.135.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 (98) hide show
  1. package/dist/assets/AgentLibrary-DRlcF1YD.js +2 -0
  2. package/dist/assets/{AppSettings-DwnfV9-4.js → AppSettings-CBhYHKGI.js} +2 -2
  3. package/dist/assets/{Button-CObXxw7b.js → Button-DtBUGvGI.js} +1 -1
  4. package/dist/assets/{DocumentEditorPane-CgB5IuOY.js → DocumentEditorPane-C82c7Qtl.js} +1 -1
  5. package/dist/assets/{Extensions-Fuhshcl6.js → Extensions-Kn-oUD2_.js} +2 -2
  6. package/dist/assets/{History-DbUV4jxK.js → History-B4c3Uz9u.js} +2 -2
  7. package/dist/assets/{Library-COr79GyT.js → Library-1RpLT-aH.js} +1 -1
  8. package/dist/assets/{ListDetail-DY53nXya.js → ListDetail-xr0oxNkv.js} +1 -1
  9. package/dist/assets/{Panel-D7NX5iP8.js → Panel-O8XPrpJu.js} +1 -1
  10. package/dist/assets/{ProjectClaudeConfig-DuWzM8qA.js → ProjectClaudeConfig-DBGhhzg2.js} +5 -5
  11. package/dist/assets/{ProvenanceBadge-AnwE1p5X.js → ProvenanceBadge-DSaizfZL.js} +1 -1
  12. package/dist/assets/Scheduler-D2_5NyiR.js +16 -0
  13. package/dist/assets/{Settings-tt0VZCyz.js → Settings-Clgqb3Lq.js} +2 -2
  14. package/dist/assets/{SkillReferenceGraph-D_rxqWgq.js → SkillReferenceGraph-D80RA7kR.js} +1 -1
  15. package/dist/assets/{Skills-BVQPJZaF.js → Skills-DNG7tHSf.js} +10 -10
  16. package/dist/assets/{SourceChip-DC5XD8KC.js → SourceChip-D-Imzszd.js} +1 -1
  17. package/dist/assets/{SystemPrompt-XnvP0_cS.js → SystemPrompt-CGlOpUQA.js} +1 -1
  18. package/dist/assets/{TiptapBody-B_TNEADm.js → TiptapBody-CJFGfBdz.js} +28 -28
  19. package/dist/assets/{Toggle-CxQO8pGN.js → Toggle-0Ff0bPa_.js} +1 -1
  20. package/dist/assets/{ViewTabs-CEjnWPD9.js → ViewTabs-BCMYQwo_.js} +1 -1
  21. package/dist/assets/{VoiceButton-B-6gdmKe.js → VoiceButton-JzyC6DAB.js} +1 -1
  22. package/dist/assets/geist-sans-latin-300-normal-C3kkMBb6.woff2 +0 -0
  23. package/dist/assets/geist-sans-latin-400-normal-gapTbOY8.woff2 +0 -0
  24. package/dist/assets/geist-sans-latin-500-normal-uokXdC-Q.woff2 +0 -0
  25. package/dist/assets/geist-sans-latin-600-normal-DFOURf8L.woff2 +0 -0
  26. package/dist/assets/geist-sans-latin-700-normal-BmN9tIp5.woff2 +0 -0
  27. package/dist/assets/{historyTotals-dT8vcKzX.js → historyTotals-B01WPBwh.js} +1 -1
  28. package/dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  29. package/dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  30. package/dist/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  31. package/dist/assets/{index-5QIl5Kcd.css → index-CjQ_p5y7.css} +1 -1
  32. package/dist/assets/index-rt7pTODX.js +3116 -0
  33. package/dist/assets/newsreader-latin-400-italic-CEihAR-f.woff2 +0 -0
  34. package/dist/assets/newsreader-latin-400-normal-BFBkh4jY.woff2 +0 -0
  35. package/dist/assets/newsreader-latin-500-normal-B66TYsaK.woff2 +0 -0
  36. package/dist/assets/newsreader-latin-600-normal-30OJ_TG_.woff2 +0 -0
  37. package/dist/assets/newsreader-latin-700-normal-rIgV_oaK.woff2 +0 -0
  38. package/dist/index.html +2 -5
  39. package/dist-web/app.css +1 -1
  40. package/dist-web/app.js +409 -404
  41. package/dist-web/index.html +0 -3
  42. package/package.json +1 -1
  43. package/plugins/session-manager-dev/skills/develop/standards.md +1 -1
  44. package/scripts/scheduler-mcp-server.cjs +31 -0
  45. package/src/main/agentLibrary.cjs +27 -4
  46. package/src/main/build-info.json +4 -4
  47. package/src/main/chatRunner.cjs +9 -0
  48. package/src/main/config.cjs +22 -0
  49. package/src/main/crashDiagnostics.cjs +10 -2
  50. package/src/main/index.cjs +34 -25
  51. package/src/main/ipcSchemas.cjs +6 -0
  52. package/src/main/lib/agent-cli/agentCliEvents.cjs +8 -0
  53. package/src/main/lib/demo-video-kit/capture.cjs +4 -37
  54. package/src/main/lib/demo-video-kit/character.cjs +20 -2
  55. package/src/main/lib/demo-video-kit/checks.cjs +82 -1
  56. package/src/main/lib/demo-video-kit/frames.cjs +3 -28
  57. package/src/main/lib/demo-video-kit/playwrightLoader.cjs +67 -0
  58. package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
  59. package/src/main/lib/demo-video-kit/sound.cjs +5 -2
  60. package/src/main/lib/epic/epicMint.cjs +1 -3
  61. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +37 -4
  62. package/src/main/lib/epic/restorableSessions.cjs +88 -0
  63. package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +56 -1
  64. package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +21 -3
  65. package/src/main/lib/feedback-remote/remoteAssets.cjs +25 -1
  66. package/src/main/lib/mcpToolCatalog.cjs +15 -0
  67. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +10 -1
  68. package/src/main/lib/persona-macro/builtinMacros.cjs +3 -2
  69. package/src/main/lib/persona-macro/macroJobDispatch.cjs +3 -2
  70. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +22 -0
  71. package/src/main/lib/prd/listPrdsSingleFlight.cjs +79 -0
  72. package/src/main/lib/prd/prdAgentType.cjs +17 -7
  73. package/src/main/lib/prd/prdFrontmatter.cjs +25 -1
  74. package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
  75. package/src/main/lib/telemetry/crashTelemetry.cjs +10 -5
  76. package/src/main/lib/telemetry/telemetryBoot.cjs +77 -4
  77. package/src/main/lib/telemetry/telemetryClient.cjs +54 -9
  78. package/src/main/lib/telemetry/telemetryConsent.cjs +3 -0
  79. package/src/main/lib/telemetry/telemetryCounters.cjs +7 -2
  80. package/src/main/lib/telemetry/telemetrySettings.cjs +5 -0
  81. package/src/main/promptSessionEvents.cjs +7 -1
  82. package/src/main/pty.cjs +2 -2
  83. package/src/main/runVerify.cjs +2 -2
  84. package/src/main/scheduler/prdParser.cjs +18 -2
  85. package/src/main/scheduler.cjs +156 -18
  86. package/src/main/seedAgentPersonas.cjs +24 -0
  87. package/src/main/seedStatus.cjs +5 -2
  88. package/src/main/telemetryIpc.cjs +1 -5
  89. package/src/main/templates/PRD_AUTHORING.md +2 -2
  90. package/src/preload/api.d.ts +37 -16
  91. package/src/preload/apiSurface.json +7 -0
  92. package/src/preload/index.cjs +3 -1
  93. package/src/seed/agents/demo-video-builder.md +7 -2
  94. package/src/seed/agents/project-home-builder.md +4 -2
  95. package/dist/assets/AgentLibrary-BTIBmZkM.js +0 -2
  96. package/dist/assets/Scheduler-BHfx0rXd.js +0 -16
  97. package/dist/assets/index-BLORXCcT.js +0 -3111
  98. package/src/main/lib/telemetry/telemetryBacklog.cjs +0 -607
@@ -4,6 +4,8 @@
4
4
  // Each check returns {id, ok, detail}. CLI: node checks.cjs <input.json> -> JSON, exit 1 on failure.
5
5
 
6
6
  const fs = require('fs');
7
+ const os = require('os');
8
+ const path = require('path');
7
9
 
8
10
  const BANNED_WORDS = Object.freeze([
9
11
  'MCP', 'API', 'SDK', 'CLI', 'repo', 'cron', 'pipeline', 'automation', 'npm', 'pnpm', 'deploy',
@@ -21,6 +23,9 @@ const MIN_SPEECH_COVERAGE = 0.4;
21
23
  const BLANK_AFTER_S = 0.5;
22
24
  const DEFAULT_BLANK_STDDEV = 3;
23
25
  const HTML_MB_PER_30S = 2 * 1024 * 1024;
26
+ const MIN_SPEECH_MODULATION = 0.2;
27
+ const ENVELOPE_WINDOW_S = 0.02;
28
+ const DECODE_SR = 16000;
24
29
 
25
30
  const result = (id, ok, detail) => ({ id, ok: !!ok, detail });
26
31
  const words = (s) => String(s || '').split(/\s+/).filter(Boolean);
@@ -120,6 +125,81 @@ function checkHtmlLimits({ html, bytes, lengthS } = {}) {
120
125
  return result('htmlLimits', problems.length === 0, problems.length ? problems.join('; ') : `${size} bytes within cap ${cap}`);
121
126
  }
122
127
 
128
+ // Share of the loudness envelope's modulation energy in the 2-8 Hz syllable band.
129
+ // Envelope = RMS over 20 ms windows (50 Hz), mean removed; energy by DFT over 0.5-25 Hz.
130
+ // Speech lands ~0.3+; a steady hum or drone lands well under 0.2.
131
+ function speechModulationShare(samples, sampleRate) {
132
+ const sr = Number(sampleRate) || 0;
133
+ const win = Math.max(1, Math.round(ENVELOPE_WINDOW_S * sr));
134
+ const n = samples && samples.length ? Math.floor(samples.length / win) : 0;
135
+ if (n < 4 || !sr) return 0;
136
+ const env = new Float64Array(n);
137
+ let mean = 0;
138
+ for (let w = 0; w < n; w++) {
139
+ let e = 0;
140
+ for (let i = w * win; i < (w + 1) * win; i++) e += samples[i] * samples[i];
141
+ env[w] = Math.sqrt(e / win);
142
+ mean += env[w];
143
+ }
144
+ mean /= n;
145
+ for (let w = 0; w < n; w++) env[w] -= mean;
146
+ const envSr = sr / win;
147
+ let band = 0;
148
+ let total = 0;
149
+ for (let k = 1; k <= Math.floor(n / 2); k++) {
150
+ const f = (k * envSr) / n;
151
+ if (f < 0.5 || f > 25) continue;
152
+ let re = 0;
153
+ let im = 0;
154
+ const step = (2 * Math.PI * k) / n;
155
+ for (let w = 0; w < n; w++) { re += env[w] * Math.cos(step * w); im -= env[w] * Math.sin(step * w); }
156
+ const p = re * re + im * im;
157
+ total += p;
158
+ if (f >= 2 && f <= 8) band += p;
159
+ }
160
+ return total > 0 ? band / total : 0;
161
+ }
162
+
163
+ function firstAudioDataUri(html) {
164
+ const h = String(html || '');
165
+ const m = /<audio\b[^>]*>/i.exec(h);
166
+ if (!m) return null;
167
+ const src = /\ssrc\s*=\s*["'](data:[^"']*)["']/i.exec(m[0]);
168
+ if (src) return src[1];
169
+ const rest = h.slice(m.index + m[0].length);
170
+ const close = rest.search(/<\/audio>/i);
171
+ const inner = close >= 0 ? rest.slice(0, close) : rest;
172
+ const source = /<source\b[^>]*\ssrc\s*=\s*["'](data:[^"']*)["']/i.exec(inner);
173
+ return source ? source[1] : null;
174
+ }
175
+
176
+ // Decodes the first <audio> data: URI through ffmpeg and fails when it has no speech-like modulation.
177
+ function checkAudioHasSpeech({ html } = {}) {
178
+ const id = 'audio-speech';
179
+ const uri = firstAudioDataUri(html);
180
+ if (!uri) return result(id, false, 'no <audio> data: URI embedded in the HTML');
181
+ const m = /^data:([^;,]*)((?:;[^;,]*)*),(.*)$/s.exec(uri);
182
+ if (!m) return result(id, false, 'embedded <audio> data: URI is malformed');
183
+ const data = /;base64/i.test(m[2]) ? Buffer.from(m[3], 'base64') : Buffer.from(decodeURIComponent(m[3]), 'binary');
184
+ if (!data.length) return result(id, false, 'embedded <audio> data: URI is empty');
185
+ const { runFfmpeg, decodeWavF32 } = require('./sound.cjs');
186
+ let dir = null;
187
+ try {
188
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'dvk-checks-'));
189
+ const input = path.join(dir, 'audio.bin');
190
+ const wav = path.join(dir, 'audio.f32.wav');
191
+ fs.writeFileSync(input, data);
192
+ runFfmpeg(['-hide_banner', '-nostats', '-y', '-i', input, '-vn', '-ac', '1', '-ar', String(DECODE_SR), '-c:a', 'pcm_f32le', wav]);
193
+ const share = speechModulationShare(decodeWavF32(fs.readFileSync(wav)), DECODE_SR);
194
+ return result(id, share >= MIN_SPEECH_MODULATION,
195
+ `speech-band (2-8 Hz) modulation share ${share.toFixed(2)} (min ${MIN_SPEECH_MODULATION})`);
196
+ } catch (e) {
197
+ return result(id, false, `could not decode embedded audio with ffmpeg: ${String((e && e.message) || e).slice(0, 300)}`);
198
+ } finally {
199
+ if (dir) fs.rmSync(dir, { recursive: true, force: true });
200
+ }
201
+ }
202
+
123
203
  // input: {captions, narration (string|string[]), closing, lines, speechS, lengthS, frames, blankThreshold, html, bytes}
124
204
  function runChecks(input = {}) {
125
205
  const out = [];
@@ -130,12 +210,13 @@ function runChecks(input = {}) {
130
210
  if (input.speechS != null) out.push(checkSpeechCoverage(input.speechS, input.lengthS));
131
211
  if (input.frames) out.push(checkBlankFrames(input.frames, input.blankThreshold));
132
212
  if (input.html != null) out.push(checkHtmlLimits({ html: input.html, bytes: input.bytes, lengthS: input.lengthS }));
213
+ if (typeof input.html === 'string') out.push(checkAudioHasSpeech({ html: input.html }));
133
214
  return out;
134
215
  }
135
216
 
136
217
  module.exports = {
137
218
  BANNED_WORDS, countSyllables, checkCaptions, lintLanguage, checkClosing, checkVoiceFit,
138
- checkSpeechCoverage, checkBlankFrames, checkHtmlLimits, runChecks,
219
+ checkSpeechCoverage, checkBlankFrames, checkHtmlLimits, speechModulationShare, checkAudioHasSpeech, runChecks,
139
220
  };
140
221
 
141
222
  if (require.main === module) {
@@ -2,11 +2,11 @@
2
2
  // Demo-video kit frame sampler: open a finished video document in headless Chromium, seek
3
3
  // window.smDemo every stepS seconds, compute per-frame luma stats (input for checkBlankFrames)
4
4
  // and write a contact sheet PNG for the persona to review. Playwright is resolved at runtime
5
- // (same resolution as capture.cjs) and never installed here. Node builtins only.
5
+ // (shared playwrightLoader.cjs) and never installed here. Node builtins only.
6
6
  const fs = require('fs');
7
7
  const path = require('path');
8
8
  const zlib = require('zlib');
9
- const { spawnSync } = require('child_process');
9
+ const { loadPlaywright: defaultLoader } = require('./playwrightLoader.cjs');
10
10
  const { pathToFileURL } = require('url');
11
11
 
12
12
  const MAX_FRAMES = 120;
@@ -15,31 +15,6 @@ const TILE_W = 160;
15
15
  const SHEET_COLS = 8;
16
16
  const PNG_SIG = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
17
17
 
18
- function tryRequire(name, paths) {
19
- try { return require(require.resolve(name, { paths })); } catch { return null; }
20
- }
21
- function globalNpmRoot() {
22
- try {
23
- const r = spawnSync('npm', ['root', '-g'], { encoding: 'utf8', timeout: 15000 });
24
- return r.status === 0 ? String(r.stdout).trim() : '';
25
- } catch { return ''; }
26
- }
27
- /** Same resolution as capture.cjs: process.cwd() first, then the global npm root. */
28
- function defaultLoader() {
29
- for (const name of ['playwright', 'playwright-core']) {
30
- const m = tryRequire(name, [process.cwd()]);
31
- if (m) return m;
32
- }
33
- const root = globalNpmRoot();
34
- if (root) {
35
- for (const name of ['playwright', 'playwright-core']) {
36
- const m = tryRequire(name, [root]);
37
- if (m) return m;
38
- }
39
- }
40
- return null;
41
- }
42
-
43
18
  // ---- minimal PNG codec -------------------------------------------------------------------
44
19
  const CHANNELS = { 0: 1, 2: 3, 4: 2, 6: 4 };
45
20
 
@@ -165,7 +140,7 @@ async function sampleFrames({ htmlPath, lengthS, stepS = 0.5, outDir, loadPlaywr
165
140
  if (!htmlPath || !outDir || !(length > 0) || !(step > 0)) return { error: 'htmlPath, outDir, lengthS > 0 and stepS > 0 are required' };
166
141
  const count = Math.floor(length / step + 1e-9) + 1;
167
142
  if (count > MAX_FRAMES) return { error: `refused: ${count} frames exceeds the ${MAX_FRAMES} frame cap` };
168
- const pw = (loadPlaywright || defaultLoader)();
143
+ const pw = (loadPlaywright || (() => defaultLoader()))();
169
144
  const resolved = pw && typeof pw.then === 'function' ? await pw : pw;
170
145
  const chromium = resolved && resolved.chromium;
171
146
  if (!chromium) return { skipped: 'no-playwright' };
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+ // Demo-video kit Playwright loader, shared by capture.cjs and frames.cjs. Copied standalone into
3
+ // ~/.claude/session-manager/demo-video-kit/, so Node builtins only. Resolution order: cwd, the
4
+ // global npm root, then every <home>/.npm/_npx/<hash>/node_modules/playwright (newest
5
+ // package.json mtime first). Never installs, never throws; returns the module or null.
6
+ const fs = require('fs');
7
+ const os = require('os');
8
+ const path = require('path');
9
+ const { spawnSync } = require('child_process');
10
+
11
+ const NAMES = ['playwright', 'playwright-core'];
12
+ const MAX_NPX_ENTRIES = 50;
13
+
14
+ function tryRequire(name, paths) {
15
+ try { return require(require.resolve(name, { paths })); } catch { return null; }
16
+ }
17
+
18
+ function globalNpmRoot() {
19
+ try {
20
+ const r = spawnSync('npm', ['root', '-g'], { encoding: 'utf8', timeout: 15000 });
21
+ return r.status === 0 ? String(r.stdout).trim() : '';
22
+ } catch { return ''; }
23
+ }
24
+
25
+ function fromRoot(root) {
26
+ if (!root) return null;
27
+ for (const name of NAMES) {
28
+ const m = tryRequire(name, [root]);
29
+ if (m) return m;
30
+ }
31
+ return null;
32
+ }
33
+
34
+ /** npx cache playwright dirs, newest package.json mtime first. */
35
+ function npxCandidates(home) {
36
+ if (!home) return [];
37
+ const npxDir = path.join(home, '.npm', '_npx');
38
+ let entries;
39
+ try { entries = fs.readdirSync(npxDir).slice(0, MAX_NPX_ENTRIES); } catch { return []; }
40
+ const found = [];
41
+ for (const hash of entries) {
42
+ for (const name of NAMES) {
43
+ const dir = path.join(npxDir, hash, 'node_modules', name);
44
+ try {
45
+ found.push({ dir, mtime: fs.statSync(path.join(dir, 'package.json')).mtimeMs });
46
+ } catch { /* not here */ }
47
+ }
48
+ }
49
+ return found.sort((a, b) => b.mtime - a.mtime).map((c) => c.dir);
50
+ }
51
+
52
+ function loadPlaywright({ home, cwd, npmRoot } = {}) {
53
+ try {
54
+ const m = fromRoot(cwd || process.cwd());
55
+ if (m) return m;
56
+ const g = fromRoot(npmRoot === undefined ? globalNpmRoot() : npmRoot);
57
+ if (g) return g;
58
+ let h = home;
59
+ if (h === undefined) { try { h = os.homedir(); } catch { h = ''; } }
60
+ for (const dir of npxCandidates(h)) {
61
+ try { return require(dir); } catch { /* broken copy; try the next */ }
62
+ }
63
+ } catch { /* never throw */ }
64
+ return null;
65
+ }
66
+
67
+ module.exports = { loadPlaywright };
@@ -17,8 +17,8 @@ const path = require('node:path');
17
17
  const { schedulerHome } = require('../scheduler/schedulerPaths.cjs');
18
18
  const { writeTextAtomic } = require('../util/atomicFs.cjs');
19
19
 
20
- const KIT_VERSION = '1';
21
- const KIT_FILES = ['checks.cjs', 'sound.cjs', 'capture.cjs', 'frames.cjs', 'character.cjs'];
20
+ const KIT_VERSION = '2';
21
+ const KIT_FILES = ['checks.cjs', 'sound.cjs', 'capture.cjs', 'frames.cjs', 'character.cjs', 'playwrightLoader.cjs'];
22
22
  const STAMP_FILE = 'KIT_VERSION';
23
23
 
24
24
  function kitDestDir() {
@@ -105,7 +105,8 @@ function bedSamples({ style, lengthS, seed }) {
105
105
  const chord = p.prog[bar % p.prog.length];
106
106
  const tb = t - bar * barS; // time inside bar
107
107
  // Pad: detuned sines with slow swell per bar.
108
- const swell = Math.sin(Math.PI * Math.min(1, tb / barS)) ** 0.5;
108
+ // Clamp: at a bar boundary float rounding can make tb ≈ -1e-15, and a negative base ** 0.5 is NaN.
109
+ const swell = Math.max(0, Math.sin(Math.PI * Math.min(1, tb / barS))) ** 0.5;
109
110
  let v = 0;
110
111
  for (const st of chord) {
111
112
  const f = semi(root, st);
@@ -273,6 +274,8 @@ function mix({ narrationWav, cues = [], style, lengthS, out, seed = 1 }) {
273
274
  const narr = decodeWavF32(fs.readFileSync(narrF32));
274
275
  const n = Math.max(narr.length, Math.round(Number(lengthS) * SR));
275
276
  const bed = bedSamples({ style, lengthS: n / SR, seed });
277
+ // A single NaN in the buffer handed to ffmpeg makes libmp3lame assert (0-byte mp3).
278
+ for (let i = 0; i < bed.length; i++) if (!Number.isFinite(bed[i])) bed[i] = 0;
276
279
  const { gain, speechS } = duckEnvelope(narr);
277
280
  const bedGain = dbToGain(BED_BASE_DB);
278
281
  const mixed = new Float32Array(n);
@@ -296,7 +299,7 @@ function mix({ narrationWav, cues = [], style, lengthS, out, seed = 1 }) {
296
299
  }
297
300
  }
298
301
 
299
- module.exports = { buildMusicBed, buildSfx, mix, measure, parseEbur128, STYLES, SFX_NAMES, TARGET };
302
+ module.exports = { buildMusicBed, buildSfx, mix, measure, parseEbur128, runFfmpeg, decodeWavF32, STYLES, SFX_NAMES, TARGET };
300
303
 
301
304
  if (require.main === module) {
302
305
  try {
@@ -45,9 +45,7 @@ const promptSessionSchema = require('../promptSessionSchema.cjs');
45
45
  // Agent-CLI id helpers come from the shared adapter contract
46
46
  // (lib/agent-cli/agentCliEvents.cjs, which exists in this tree) — not a local
47
47
  // copy of the id list, so the two can never drift.
48
- const { isAgentCliId, isNonClaudeAgentCli } = require('../agent-cli/agentCliEvents.cjs');
49
-
50
- const AGENT_CLI_MODEL_RE = /^[A-Za-z0-9._:/@+\[\]-]{1,128}$/;
48
+ const { isAgentCliId, isNonClaudeAgentCli, AGENT_CLI_MODEL_RE } = require('../agent-cli/agentCliEvents.cjs');
51
49
 
52
50
  /**
53
51
  * agentCliMintFields(agentCli, agentCliModel, restoreSessionId) — validate the
@@ -14,11 +14,12 @@
14
14
  *
15
15
  * Also home to 'promptSessions:list-restorable', the New Session card's
16
16
  * "Restore a session" picker, whose pick comes back as create-epic's
17
- * `restoreSessionId`.
17
+ * `restoreSessionId`, and to 'promptSessions:list-restorable-recent', the
18
+ * cross-project variant (listRecentRestorableSessions).
18
19
  */
19
20
 
20
21
  const { ensureEpic, readActiveIndex, MINT_AUTHORITY_NEW_EPIC_UI } = require('./epicMint.cjs');
21
- const { listRestorableSessions } = require('./restorableSessions.cjs');
22
+ const { listRestorableSessions, listRecentRestorableSessions } = require('./restorableSessions.cjs');
22
23
  const { validatePath } = require('../../config.cjs');
23
24
 
24
25
  /**
@@ -88,7 +89,30 @@ async function listRestorableViaIpc(cwd) {
88
89
  return listRestorableSessions({ cwd });
89
90
  }
90
91
 
91
- function registerPromptSessionsCreateEpicHandlers() {
92
+ /**
93
+ * listRecentRestorableViaIpc({ limit? }, deps?) → Promise<RecentList | { ok: false, error }>
94
+ *
95
+ * Interactive restorable sessions across every known project, newest first
96
+ * (listRecentRestorableSessions). Takes no renderer path — the project list is
97
+ * main's own. Any failure resolves to `{ ok: false, error }` rather than
98
+ * rejecting, so the picker can show it without an unhandled IPC error.
99
+ * `deps.listRecentRestorableSessions` swaps the lister (tests).
100
+ * @param {{ limit?: number }} args
101
+ * @param {{ listRecentRestorableSessions?: Function }} [deps]
102
+ */
103
+ async function listRecentRestorableViaIpc({ limit } = {}, deps = {}) {
104
+ const lister = deps.listRecentRestorableSessions || listRecentRestorableSessions;
105
+ try {
106
+ return await lister({ limit });
107
+ } catch (err) {
108
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
109
+ }
110
+ }
111
+
112
+ /**
113
+ * @param {{ listRecentRestorableSessions?: Function }} [deps] test seam for list-restorable-recent
114
+ */
115
+ function registerPromptSessionsCreateEpicHandlers(deps = {}) {
92
116
  const { ipcMain } = require('electron');
93
117
  const { schemas: s, validated: v } = require('../../ipcSchemas.cjs');
94
118
  ipcMain.handle(
@@ -100,6 +124,15 @@ function registerPromptSessionsCreateEpicHandlers() {
100
124
  'promptSessions:list-restorable',
101
125
  v(s.promptSessionsListRestorable, ({ cwd }) => listRestorableViaIpc(cwd)),
102
126
  );
127
+ // Validation refusals resolve to { ok: false, error } too, like lister errors.
128
+ const listRecent = v(s.promptSessionsListRestorableRecent, (args) => listRecentRestorableViaIpc(args, deps));
129
+ ipcMain.handle('promptSessions:list-restorable-recent', async (/** @type {unknown} */ event, /** @type {unknown} */ payload) => {
130
+ try {
131
+ return await listRecent(event, payload);
132
+ } catch (err) {
133
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
134
+ }
135
+ });
103
136
  }
104
137
 
105
- module.exports = { createEpicViaIpc, listRestorableViaIpc, registerPromptSessionsCreateEpicHandlers };
138
+ module.exports = { createEpicViaIpc, listRestorableViaIpc, listRecentRestorableViaIpc, registerPromptSessionsCreateEpicHandlers };
@@ -660,6 +660,93 @@ async function listRestorableSessions({ cwd, limit = DEFAULT_LIMIT, deps } = { c
660
660
  return result;
661
661
  }
662
662
 
663
+ const RECENT_READ_CONCURRENCY = 4;
664
+
665
+ /**
666
+ * @typedef {object} RecentRestorableDeps
667
+ * @property {(opts?: object) => string[]} [allProjectCwds] Project cwds (default activeSessions' cached allProjectCwds).
668
+ * @property {typeof listRestorableSessions} [listRestorableSessions] Per-project lister (test seam).
669
+ */
670
+
671
+ /**
672
+ * Transcript-folder mtime of each of `cwds`, newest first; a folder that
673
+ * cannot be stat'ed is dropped (no CLI history there).
674
+ * @param {string[]} cwds
675
+ * @param {RestorableDeps} d
676
+ * @returns {Promise<string[]>}
677
+ */
678
+ async function byFolderActivity(cwds, d) {
679
+ const stamped = await Promise.all(cwds.map(async (cwd, i) => {
680
+ try {
681
+ return { cwd, i, mtimeMs: (await fs.promises.stat(projectDirOf(cwd, d))).mtimeMs };
682
+ } catch {
683
+ return null;
684
+ }
685
+ }));
686
+ return /** @type {{ cwd: string, i: number, mtimeMs: number }[]} */ (stamped.filter(Boolean))
687
+ .sort((a, b) => b.mtimeMs - a.mtimeMs || a.i - b.i)
688
+ .map((s) => s.cwd);
689
+ }
690
+
691
+ /**
692
+ * Interactive restorable sessions across this machine's projects, newest
693
+ * first, each tagged with its project `cwd` — for a "continue any session"
694
+ * picker. Bounded like listRestorableSessions: the project list comes from
695
+ * activeSessions' cached allProjectCwds() (never a fresh ~/.claude/projects
696
+ * walk), at most `maxProjects * 2` transcript folders are stat'ed to rank them
697
+ * by activity, at most `maxProjects` are read (4 at a time) through
698
+ * listRestorableSessions({ cwd, limit: perProject }), which also hides
699
+ * Epic-owned sessions. A project whose read fails is skipped. Never throws.
700
+ * @param {{ limit?: number, maxProjects?: number, perProject?: number, deps?: RestorableDeps & RecentRestorableDeps }} [opts]
701
+ * @returns {Promise<{ sessions: (RestorableSession & { cwd: string })[], projectsRead: number, truncated: boolean }>}
702
+ */
703
+ async function listRecentRestorableSessions({ limit = 30, maxProjects = 25, perProject = 5, deps } = {}) {
704
+ /** @type {{ sessions: (RestorableSession & { cwd: string })[], projectsRead: number, truncated: boolean }} */
705
+ const result = { sessions: [], projectsRead: 0, truncated: false };
706
+ const d = deps || {};
707
+ const cap = (/** @type {number} */ n, /** @type {number} */ dflt) => (Number.isInteger(n) && n > 0 ? n : dflt);
708
+ const maxP = cap(maxProjects, 25);
709
+ const max = cap(limit, 30);
710
+ const per = cap(perProject, 5);
711
+ const lister = d.listRestorableSessions || listRestorableSessions;
712
+ /** @type {string[]} */
713
+ let all;
714
+ try {
715
+ const source = d.allProjectCwds || require('../activeSessions.cjs').allProjectCwds;
716
+ const raw = source();
717
+ all = Array.isArray(raw) ? [...new Set(raw.map((c) => normalizeCwd(c)).filter(Boolean))] : [];
718
+ } catch {
719
+ return result;
720
+ }
721
+ const ranked = await byFolderActivity(all.slice(0, maxP * 2), d);
722
+ const picked = ranked.slice(0, maxP);
723
+ if (all.length > maxP * 2 || ranked.length > maxP) result.truncated = true;
724
+
725
+ /** @type {(RestorableSession & { cwd: string })[]} */
726
+ const merged = [];
727
+ let next = 0;
728
+ const worker = async () => {
729
+ while (next < picked.length) {
730
+ const cwd = picked[next];
731
+ next += 1;
732
+ try {
733
+ const r = await lister({ cwd, limit: per, deps: d });
734
+ result.projectsRead += 1;
735
+ if (r.truncated) result.truncated = true;
736
+ for (const s of r.sessions) if (!s.headless) merged.push({ ...s, cwd });
737
+ } catch {
738
+ // unreadable project: skip it
739
+ }
740
+ }
741
+ };
742
+ await Promise.all(Array.from({ length: Math.min(RECENT_READ_CONCURRENCY, picked.length) }, worker));
743
+
744
+ merged.sort((a, b) => b.mtimeMs - a.mtimeMs || (a.sessionId < b.sessionId ? -1 : a.sessionId > b.sessionId ? 1 : 0));
745
+ if (merged.length > max) result.truncated = true;
746
+ result.sessions = merged.slice(0, max);
747
+ return result;
748
+ }
749
+
663
750
  /**
664
751
  * First ≤ 64 KiB of `file`, through a fixed buffer.
665
752
  * @param {string} file
@@ -744,6 +831,7 @@ module.exports = {
744
831
  claimedClaudeSessionIds,
745
832
  claimedClaudeSessionIdsAsync,
746
833
  listRestorableSessions,
834
+ listRecentRestorableSessions,
747
835
  checkRestorableSessionSync,
748
836
  __resetCacheForTests,
749
837
  };
@@ -5,6 +5,13 @@
5
5
  * through customerFeedbackInbox.cjs:
6
6
  * GET /admin/customer-feedback/inbox?pull=1&includeHidden=1 -> { ok, items, pulled? }
7
7
  * POST /admin/customer-feedback/status {id, status, note?} -> { ok, item }
8
+ * POST /admin/customer-feedback/submit {title, body, tag} -> { ok, item } | { ok:false, error }
9
+ *
10
+ * submit is the customer path (no owner token needed): it runs the exact
11
+ * submit the {F} panel's customerFeedback:submit IPC uses
12
+ * (customerFeedbackIpc.submitFeedback -> customerFeedbackClient.submit), so the
13
+ * item + receipt land in the same local mirror. os.homedir() is replaced with
14
+ * `~` in title and body first; the body text is never echoed or logged.
8
15
  *
9
16
  * Deliberately NO route that mints an Epic (SINGLE-CREATOR LAW, epicMint.cjs).
10
17
  * Responses never carry the owner token — the inbox lib redacts it from errors.
@@ -82,13 +89,61 @@ function statusHandler(inboxDep) {
82
89
  };
83
90
  }
84
91
 
92
+ /** Replace every occurrence of the home dir with `~`. @param {string} s */
93
+ function redactHome(s) {
94
+ const home = require('os').homedir();
95
+ return home ? s.split(home).join('~') : s;
96
+ }
97
+
98
+ /** @param {any} submitDep */
99
+ function submitHandler(submitDep) {
100
+ return async (/** @type {any} */ req, /** @type {any} */ res) => {
101
+ try {
102
+ let raw;
103
+ try {
104
+ raw = await readBody(req);
105
+ } catch (/** @type {any} */ e) {
106
+ sendJson(res, 400, { ok: false, error: `request body rejected: ${e?.message ?? 'unreadable'}` });
107
+ return;
108
+ }
109
+ /** @type {any} */
110
+ let body;
111
+ try {
112
+ body = raw ? JSON.parse(raw) : {};
113
+ } catch {
114
+ sendJson(res, 400, { ok: false, error: 'invalid JSON body' });
115
+ return;
116
+ }
117
+ const { schemas } = require('../../ipcSchemas.cjs');
118
+ const parsed = schemas.customerFeedbackSubmit.safeParse(body);
119
+ if (!parsed.success) {
120
+ // Issue paths + messages only — never the submitted values.
121
+ const error = parsed.error.issues.map((i) => `${i.path.join('.') || 'body'}: ${i.message}`).join('; ');
122
+ sendJson(res, 400, { ok: false, error: `invalid submission: ${error}` });
123
+ return;
124
+ }
125
+ const submit = submitDep || require('./customerFeedbackIpc.cjs').submitFeedback;
126
+ const { title, body: text, tag } = parsed.data;
127
+ const result = await submit({ title: redactHome(title), body: redactHome(text), tag });
128
+ if (!result || !result.ok) {
129
+ sendJson(res, 502, { ok: false, error: result && typeof result.error === 'string' ? result.error : 'submit failed' });
130
+ return;
131
+ }
132
+ sendJson(res, 200, { ok: true, item: result.item });
133
+ } catch (/** @type {any} */ e) {
134
+ sendJson(res, 500, { ok: false, error: e && e.message ? String(e.message) : 'submit failed' });
135
+ }
136
+ };
137
+ }
138
+
85
139
  /**
86
140
  * @param {any} adminHttp
87
- * @param {{ inbox?: any }} [opts] test seam
141
+ * @param {{ inbox?: any, submit?: (p: { title: string, body: string, tag: string }) => Promise<any> }} [opts] test seams
88
142
  */
89
143
  function registerAdminRoute(adminHttp, opts = {}) {
90
144
  adminHttp.registerRoute('GET', '/admin/customer-feedback/inbox', inboxHandler(opts.inbox));
91
145
  adminHttp.registerRoute('POST', '/admin/customer-feedback/status', statusHandler(opts.inbox));
146
+ adminHttp.registerRoute('POST', '/admin/customer-feedback/submit', submitHandler(opts.submit));
92
147
  }
93
148
 
94
149
  module.exports = { registerAdminRoute };
@@ -3,6 +3,24 @@
3
3
 
4
4
  const REFRESH_DELAY_MS = 30_000;
5
5
 
6
+ /**
7
+ * The configured customer-feedback client the panel's customerFeedback:submit
8
+ * uses. The admin submit route (customerFeedbackAdminRoutes.cjs) reaches the
9
+ * client through this same getter so an agent submission writes the same
10
+ * mirror + receipt as a panel one.
11
+ */
12
+ function getClient() {
13
+ return require('./customerFeedbackClient.cjs');
14
+ }
15
+
16
+ /**
17
+ * Exactly the panel's submit call. @param {{ title: string, body: string, tag: string }} p
18
+ * @param {any} [client]
19
+ */
20
+ function submitFeedback(p, client = getClient()) {
21
+ return client.submit(p);
22
+ }
23
+
6
24
  /**
7
25
  * Renderer-facing IPC for the customer-feedback client + owner inbox.
8
26
  * Handlers return the libs' `{ ok, ... }` results unchanged.
@@ -11,11 +29,11 @@ const REFRESH_DELAY_MS = 30_000;
11
29
  function registerCustomerFeedbackHandlers(deps = {}) {
12
30
  const ipcMain = deps.ipcMain || require('electron').ipcMain;
13
31
  const { schemas: s, validated: v } = require('../../ipcSchemas.cjs');
14
- const client = deps.client || require('./customerFeedbackClient.cjs');
32
+ const client = deps.client || getClient();
15
33
  const inbox = deps.inbox || require('./customerFeedbackInbox.cjs');
16
34
  const timer = deps.setTimeoutImpl || setTimeout;
17
35
 
18
- ipcMain.handle('customerFeedback:submit', v(s.customerFeedbackSubmit, (p) => client.submit(p)));
36
+ ipcMain.handle('customerFeedback:submit', v(s.customerFeedbackSubmit, (p) => submitFeedback(p, client)));
19
37
  ipcMain.handle('customerFeedback:list', () => client.list());
20
38
  ipcMain.handle('customerFeedback:refresh-status', () => client.refreshStatuses());
21
39
  ipcMain.handle('customerFeedback:mark-seen', v(s.customerFeedbackMarkSeen, ({ ids }) => client.markSeen(ids)));
@@ -40,4 +58,4 @@ function registerCustomerFeedbackHandlers(deps = {}) {
40
58
  }
41
59
  }
42
60
 
43
- module.exports = { registerCustomerFeedbackHandlers, REFRESH_DELAY_MS };
61
+ module.exports = { registerCustomerFeedbackHandlers, getClient, submitFeedback, REFRESH_DELAY_MS };
@@ -116,7 +116,31 @@ function missingEntryFiles() {
116
116
  return missing;
117
117
  }
118
118
 
119
+ /**
120
+ * Off-origin stylesheet/font references in an index.html string: hrefs of
121
+ * <link rel=stylesheet|preconnect|preload> and @import URLs that are http(s) or protocol-relative.
122
+ * The bilko.run iframe silently drops these and falls back to system fonts. Pure string parse.
123
+ */
124
+ function externalStyleRefs(indexHtml) {
125
+ const html = String(indexHtml || '');
126
+ const isExternal = (u) => /^(https?:)?\/\//i.test(u.trim());
127
+ const attr = (tag, name) => {
128
+ const m = new RegExp(`\\b${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, 'i').exec(tag);
129
+ return m ? (m[1] ?? m[2] ?? m[3]) : null;
130
+ };
131
+ const out = [];
132
+ const push = (u) => { if (u && isExternal(u) && !out.includes(u.trim())) out.push(u.trim()); };
133
+ for (const m of html.matchAll(/<link\b[^>]*>/gi)) {
134
+ const rel = (attr(m[0], 'rel') || '').toLowerCase().split(/\s+/);
135
+ if (rel.some((r) => r === 'stylesheet' || r === 'preconnect' || r === 'preload')) push(attr(m[0], 'href'));
136
+ }
137
+ for (const m of html.matchAll(/@import\s+(?:url\(\s*)?(?:"([^"]*)"|'([^']*)'|([^\s)'";]+))/gi)) {
138
+ push(m[1] ?? m[2] ?? m[3]);
139
+ }
140
+ return out;
141
+ }
142
+
119
143
  module.exports = {
120
- assetManifest, readAsset, missingEntryFiles, MAX_ASSET_BYTES,
144
+ assetManifest, readAsset, missingEntryFiles, externalStyleRefs, MAX_ASSET_BYTES,
121
145
  __test: { setRoot: (p) => { _rootOverride = p; } },
122
146
  };
@@ -458,6 +458,21 @@ const MCP_TOOL_CATALOG = [
458
458
  exampleArgs: { id: 'fb_123', status: 'resolved', note: 'Fixed in 0.97.0' },
459
459
  notes: 'The note is shown to the customer; keep it short (the inbox enforces a maximum length).',
460
460
  },
461
+ {
462
+ name: 'customer_feedback_submit',
463
+ group: 'customer-feedback',
464
+ purpose: 'Send one piece of feedback about Session Manager itself (bug | feature | discussion) to its maintainers, '
465
+ + 'the same submission the {F} feedback panel makes, via the session-manager app\'s admin API.',
466
+ whenToUse: 'Use only when the human asks to send feedback about Session Manager itself. Draft a title (max 120 chars) '
467
+ + 'and body (max 4000 chars) from the conversation, show the human the exact title, body and tag, and call only '
468
+ + 'after they agree.',
469
+ whenNotToUse: 'WHEN NOT TO USE IT: a bug in the project being worked on is /develop; a finding for another local '
470
+ + 'project is feedback_open_session. Never call it on your own initiative. Never include secrets, tokens, '
471
+ + 'customer data or private file contents in the title or body.',
472
+ exampleArgs: { title: 'Feedback panel: prefill from the current session', body: 'What happened, what I expected, steps.', tag: 'feature' },
473
+ notes: 'Runs only in a Session Manager chat or terminal session (refused in headless jobs). Returns { ok, item }; '
474
+ + '{ ok:false, error } comes back as an error result. The home directory is redacted to ~ before sending.',
475
+ },
461
476
  {
462
477
  name: 'macro_list',
463
478
  group: 'macros',
@@ -26,6 +26,7 @@ const path = require('node:path');
26
26
  const { z } = require('zod');
27
27
  const { WorkTypeSchema, LEGACY_WORK_TYPES } = require('../prd/workTypeLibrary.cjs');
28
28
  const { PERSONA_NAME_RE, ALL_PROJECTS } = require('../../agentLibrary.cjs');
29
+ const { AGENT_CLI_IDS, isNonClaudeAgentCli, AGENT_CLI_MODEL_RE } = require('../agent-cli/agentCliEvents.cjs');
29
30
 
30
31
  // Bounded free-text fields — generous for legitimate persona authoring while
31
32
  // still blocking a renderer from writing an effectively-unbounded frontmatter
@@ -92,9 +93,17 @@ const AgentPersonaSaveSchema = z.object({
92
93
  seedVersion: z.number().int().optional(),
93
94
  // Executor-only persona (e.g. dev-lead): New Epic warns when picked as the planning Actor. Never blocks.
94
95
  executorOnly: z.boolean().optional(),
96
+ // Persona's default agent CLI for New Session; 'claude' clears it.
97
+ agentCli: z.enum(/** @type {[string, ...string[]]} */ ([...AGENT_CLI_IDS])).optional(),
98
+ // Model handed to that CLI; same rule as epicMint.
99
+ agentCliModel: z.string().regex(AGENT_CLI_MODEL_RE).optional(),
95
100
  // Unbounded — a persona's body is arbitrary system-prompt prose.
96
101
  body: z.string(),
97
- }).strict();
102
+ }).strict().superRefine((p, ctx) => {
103
+ if (p.agentCliModel !== undefined && !isNonClaudeAgentCli(p.agentCli)) {
104
+ ctx.addIssue({ code: 'custom', path: ['agentCliModel'], message: 'agentCliModel requires a non-Claude agentCli' });
105
+ }
106
+ });
98
107
 
99
108
  /**
100
109
  * Throws a clear, descriptive error (not a raw ZodError dump) when `persona`