claude-code-session-manager 0.133.1 → 0.134.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 (90) hide show
  1. package/dist/assets/AgentLibrary-C9KFGJQq.js +2 -0
  2. package/dist/assets/{AppSettings-DwnfV9-4.js → AppSettings-CvVQ6ot5.js} +2 -2
  3. package/dist/assets/{Button-CObXxw7b.js → Button-BHvploNk.js} +1 -1
  4. package/dist/assets/{DocumentEditorPane-CgB5IuOY.js → DocumentEditorPane-DaX4xag_.js} +1 -1
  5. package/dist/assets/{Extensions-Fuhshcl6.js → Extensions-DbRY-KEz.js} +2 -2
  6. package/dist/assets/{History-DbUV4jxK.js → History-BE_mjM24.js} +2 -2
  7. package/dist/assets/{Library-COr79GyT.js → Library-I37dQ6pB.js} +1 -1
  8. package/dist/assets/{ListDetail-DY53nXya.js → ListDetail-DJYMWYQd.js} +1 -1
  9. package/dist/assets/{Panel-D7NX5iP8.js → Panel-DP8eSKSs.js} +1 -1
  10. package/dist/assets/{ProjectClaudeConfig-DuWzM8qA.js → ProjectClaudeConfig-Cw8lc3Qi.js} +5 -5
  11. package/dist/assets/{ProvenanceBadge-AnwE1p5X.js → ProvenanceBadge-DUwhsmdA.js} +1 -1
  12. package/dist/assets/Scheduler-B9D2gZqs.js +16 -0
  13. package/dist/assets/{Settings-tt0VZCyz.js → Settings-DSk7bn-1.js} +2 -2
  14. package/dist/assets/{SkillReferenceGraph-D_rxqWgq.js → SkillReferenceGraph-DtJcJJHR.js} +1 -1
  15. package/dist/assets/{Skills-BVQPJZaF.js → Skills-BPZnSjsB.js} +10 -10
  16. package/dist/assets/{SourceChip-DC5XD8KC.js → SourceChip-DUxulNOp.js} +1 -1
  17. package/dist/assets/{SystemPrompt-XnvP0_cS.js → SystemPrompt-BXAugVle.js} +1 -1
  18. package/dist/assets/{TiptapBody-B_TNEADm.js → TiptapBody-CDC1vrOo.js} +28 -28
  19. package/dist/assets/{Toggle-CxQO8pGN.js → Toggle-CrgM7OTR.js} +1 -1
  20. package/dist/assets/{ViewTabs-CEjnWPD9.js → ViewTabs-DLwaU9RB.js} +1 -1
  21. package/dist/assets/{VoiceButton-B-6gdmKe.js → VoiceButton-C4hIBxIP.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-itA00dXm.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-Cjt8B7H9.css} +1 -1
  32. package/dist/assets/index-Cznhnxhq.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 +407 -402
  41. package/dist-web/index.html +0 -3
  42. package/package.json +1 -1
  43. package/scripts/scheduler-mcp-server.cjs +31 -0
  44. package/src/main/agentLibrary.cjs +27 -4
  45. package/src/main/build-info.json +4 -4
  46. package/src/main/chatRunner.cjs +9 -0
  47. package/src/main/config.cjs +22 -0
  48. package/src/main/crashDiagnostics.cjs +10 -2
  49. package/src/main/index.cjs +34 -25
  50. package/src/main/ipcSchemas.cjs +6 -0
  51. package/src/main/lib/agent-cli/agentCliEvents.cjs +8 -0
  52. package/src/main/lib/demo-video-kit/capture.cjs +4 -37
  53. package/src/main/lib/demo-video-kit/character.cjs +20 -2
  54. package/src/main/lib/demo-video-kit/checks.cjs +82 -1
  55. package/src/main/lib/demo-video-kit/frames.cjs +3 -28
  56. package/src/main/lib/demo-video-kit/playwrightLoader.cjs +67 -0
  57. package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
  58. package/src/main/lib/demo-video-kit/sound.cjs +5 -2
  59. package/src/main/lib/epic/epicMint.cjs +1 -3
  60. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +37 -4
  61. package/src/main/lib/epic/restorableSessions.cjs +88 -0
  62. package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +56 -1
  63. package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +21 -3
  64. package/src/main/lib/feedback-remote/remoteAssets.cjs +25 -1
  65. package/src/main/lib/mcpToolCatalog.cjs +15 -0
  66. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +10 -1
  67. package/src/main/lib/persona-macro/builtinMacros.cjs +3 -2
  68. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
  69. package/src/main/lib/prd/listPrdsSingleFlight.cjs +79 -0
  70. package/src/main/lib/prd/prdAgentType.cjs +17 -7
  71. package/src/main/lib/telemetry/crashTelemetry.cjs +10 -5
  72. package/src/main/lib/telemetry/telemetryBoot.cjs +77 -4
  73. package/src/main/lib/telemetry/telemetryClient.cjs +54 -9
  74. package/src/main/lib/telemetry/telemetryConsent.cjs +3 -0
  75. package/src/main/lib/telemetry/telemetryCounters.cjs +7 -2
  76. package/src/main/lib/telemetry/telemetrySettings.cjs +5 -0
  77. package/src/main/pty.cjs +2 -2
  78. package/src/main/scheduler/prdParser.cjs +1 -1
  79. package/src/main/scheduler.cjs +19 -3
  80. package/src/main/seedAgentPersonas.cjs +24 -0
  81. package/src/main/seedStatus.cjs +5 -2
  82. package/src/main/telemetryIpc.cjs +1 -5
  83. package/src/preload/api.d.ts +29 -14
  84. package/src/preload/apiSurface.json +7 -0
  85. package/src/preload/index.cjs +3 -1
  86. package/src/seed/agents/demo-video-builder.md +7 -2
  87. package/dist/assets/AgentLibrary-BTIBmZkM.js +0 -2
  88. package/dist/assets/Scheduler-BHfx0rXd.js +0 -16
  89. package/dist/assets/index-BLORXCcT.js +0 -3111
  90. package/src/main/lib/telemetry/telemetryBacklog.cjs +0 -607
@@ -70,6 +70,7 @@ const { decideVerifyDowngrade } = require('./lib/scheduler/refireCap.cjs');
70
70
  const { finalizeReasonFor } = require('./lib/scheduler/finalizeReason.cjs');
71
71
  const { shouldRunFlatSweep, FLAT_SWEEP_INTERVAL_MS } = require('./lib/scheduler/flatSweepThrottle.cjs');
72
72
  const { appendError } = require('./lib/telemetry/opsErrorLog.cjs');
73
+ const { createSingleFlight, listKeyFor, flatString, flattenPrdEntry } = require('./lib/prd/listPrdsSingleFlight.cjs');
73
74
  const { readTail } = require('./lib/util/fileTail.cjs');
74
75
  const {
75
76
  claudePidAlive, classifyRunOutcome, resolveReapGateOutcome, ORPHAN_REQUEUE_CAP, selectReapableJobs,
@@ -10999,7 +11000,9 @@ function registerScheduleHandlers() {
10999
11000
  }
11000
11001
  }));
11001
11002
 
11002
- ipcMain.handle('schedule:list-prds', async () => listPrdsInternal());
11003
+ // Optional { cwd } scopes the scan to one project; concurrent calls with the
11004
+ // same cwd key share one in-flight scan (PRD 3063 — heap OOM loop).
11005
+ ipcMain.handle('schedule:list-prds', async (_e, payload) => listPrdsShared({ cwd: payload?.cwd }));
11003
11006
 
11004
11007
  // Return last N completed/failed jobs from queue.json, newest first.
11005
11008
  // Purely additive: no schema change, no archive-folder read needed.
@@ -11613,6 +11616,9 @@ async function listPrdsInternal({ cwd: rawCwd } = {}) {
11613
11616
  mtimeMs: stat.mtimeMs,
11614
11617
  archived,
11615
11618
  };
11619
+ // Flat copies only: sliced strings into the parsed file text kept
11620
+ // every scanned PRD body alive (2026-11-08 heap snapshot, PRD 3063).
11621
+ flattenPrdEntry(entry);
11616
11622
  out.push(entry);
11617
11623
  } catch (e) {
11618
11624
  logs.writeLine({ level: 'warn', scope: 'scheduler', message: 'list-prds: skipping unparseable file', meta: { name, error: e?.message } });
@@ -11662,7 +11668,7 @@ async function listPrdsInternal({ cwd: rawCwd } = {}) {
11662
11668
  if (i < archivedStart) {
11663
11669
  entry.status = liveStatusBySlug.get(entry.slug) ?? null;
11664
11670
  } else {
11665
- entry.archivedStatus = prdPaths.resolveArchivedPrdStatus(entry.slug, liveStatusBySlug, histBySlug);
11671
+ entry.archivedStatus = flatString(prdPaths.resolveArchivedPrdStatus(entry.slug, liveStatusBySlug, histBySlug));
11666
11672
  entry.status = entry.archivedStatus;
11667
11673
  }
11668
11674
  }
@@ -11671,6 +11677,15 @@ async function listPrdsInternal({ cwd: rawCwd } = {}) {
11671
11677
  return out;
11672
11678
  }
11673
11679
 
11680
+ // Single-flight front door for listPrdsInternal (PRD 3063): concurrent calls
11681
+ // with the same normalized cwd (absent cwd = one machine-wide key) await ONE
11682
+ // in-flight scan; the slot clears on settle, so a later call rescans and a
11683
+ // rejected scan is retried by the next caller.
11684
+ const listPrdsShared = createSingleFlight(
11685
+ (arg) => listPrdsInternal(arg),
11686
+ (arg) => listKeyFor(normalizeListCwd(arg?.cwd)),
11687
+ );
11688
+
11674
11689
  // remote — in-process (non-IPC) scheduler accessors, used by prdCreate.cjs
11675
11690
  // and other main-process callers. (Named for the retired web-remote relay,
11676
11691
  // its original consumer; kept because it still has in-process callers.)
@@ -11881,7 +11896,7 @@ const remote = {
11881
11896
  // long as the underlying PRD set doesn't change mid-page.
11882
11897
  async listPrds(filter = {}) {
11883
11898
  const filterCwd = normalizeListCwd(filter.cwd);
11884
- const all = await listPrdsInternal({ cwd: filterCwd });
11899
+ const all = await listPrdsShared({ cwd: filterCwd });
11885
11900
  const filtered = all.filter((entry) => {
11886
11901
  if (filterCwd && entry.cwd !== filterCwd) return false;
11887
11902
  if (filter.epicId && entry.epicId !== filter.epicId) return false;
@@ -12379,6 +12394,7 @@ module.exports = {
12379
12394
  prdArchivedSkipResult,
12380
12395
  spawnJob,
12381
12396
  listPrdsInternal,
12397
+ listPrdsShared,
12382
12398
  heartbeatTick,
12383
12399
  appendHeartbeat,
12384
12400
  QUARANTINE_ESCALATE_MS,
@@ -127,6 +127,29 @@ function readMarker() {
127
127
  }
128
128
  }
129
129
 
130
+ /**
131
+ * This seeder's own marker → 'done' | 'pending' | 'failed' | 'exhausted', read by
132
+ * seedStatus.cjs. Owned here because only this file knows its marker format: done means
133
+ * every name in PERSONAS is in `seeded`, whatever `attempts` is. A legacy `{ done: true }`
134
+ * marker (no `seeded` array) still reads as done. Parses the raw file itself rather than
135
+ * going through readMarker(), which maps legacy done to LEGACY_DONE_PERSONAS and would
136
+ * report it as not done. Never throws — absent or unparseable reads as 'pending'.
137
+ */
138
+ function markerStatus() {
139
+ try {
140
+ const m = JSON.parse(fs.readFileSync(markerPath(), 'utf8').trim());
141
+ const done = Array.isArray(m.seeded)
142
+ ? PERSONAS.every((n) => m.seeded.includes(n))
143
+ : Boolean(m.done);
144
+ if (done) return 'done';
145
+ const attempts = Number(m.attempts) || 0;
146
+ if (attempts >= MAX_ATTEMPTS) return 'exhausted';
147
+ return attempts > 0 ? 'failed' : 'pending';
148
+ } catch {
149
+ return 'pending';
150
+ }
151
+ }
152
+
130
153
  function writeMarker(state) {
131
154
  try {
132
155
  writeJsonSync(markerPath(), { ...state, ts: new Date().toISOString() });
@@ -383,6 +406,7 @@ module.exports = {
383
406
  normalizeNewlines,
384
407
  sameFmValue,
385
408
  markerPath,
409
+ markerStatus,
386
410
  MAX_ATTEMPTS,
387
411
  PERSONAS,
388
412
  };
@@ -22,7 +22,10 @@ const SEEDERS = {
22
22
  'agent-personas': seedAgentPersonas,
23
23
  };
24
24
 
25
- /** One seeder's marker → 'done' | 'pending' | 'failed' | 'exhausted'. */
25
+ /**
26
+ * Default reader for `{ done, attempts }` markers → 'done' | 'pending' | 'failed' | 'exhausted'.
27
+ * A seeder whose marker has another shape exports its own `markerStatus()` instead.
28
+ */
26
29
  function statusFromMarker(mod) {
27
30
  try {
28
31
  const raw = fs.readFileSync(mod.markerPath(), 'utf8').trim();
@@ -52,7 +55,7 @@ function getSeedStatus() {
52
55
  const out = {};
53
56
  for (const [id, mod] of Object.entries(SEEDERS)) {
54
57
  const fix = FIXES[id];
55
- out[id] = { status: statusFromMarker(mod), fix: typeof fix === 'function' ? fix() : fix };
58
+ out[id] = { status: typeof mod.markerStatus === 'function' ? mod.markerStatus() : statusFromMarker(mod), fix: typeof fix === 'function' ? fix() : fix };
56
59
  }
57
60
  return out;
58
61
  }
@@ -10,7 +10,6 @@ const otel = require('./otel.cjs');
10
10
  const otelSettings = require('./otelSettings.cjs');
11
11
  const telemetrySettings = require('./lib/telemetry/telemetrySettings.cjs');
12
12
  const telemetryClient = require('./lib/telemetry/telemetryClient.cjs');
13
- const telemetryBacklog = require('./lib/telemetry/telemetryBacklog.cjs');
14
13
  const telemetryConsent = require('./lib/telemetry/telemetryConsent.cjs');
15
14
 
16
15
  /**
@@ -39,10 +38,7 @@ function registerTelemetryHandlers({ ipcMain }) {
39
38
  const saved = await telemetryConsent.applyConsentUpdate(cfg, { telemetrySettings, telemetryClient });
40
39
  return { ok: true, config: saved, status: telemetryClient.status() };
41
40
  }));
42
- ipcMain.handle('telemetry:status', () => ({
43
- ...telemetryClient.status(),
44
- backlog: telemetryBacklog.lastRunSummary(),
45
- }));
41
+ ipcMain.handle('telemetry:status', () => telemetryClient.status());
46
42
  ipcMain.handle('telemetry:config-path', () => telemetrySettings.storePath());
47
43
  ipcMain.handle('telemetry:recent-records', () => telemetryClient.recentRecords());
48
44
  ipcMain.handle('telemetry:flush-now', () => telemetryClient.flush('manual'));
@@ -456,6 +456,10 @@ export interface AgentPersona {
456
456
  model: string | null;
457
457
  /** Per-Epic reasoning effort (`effort:` frontmatter; a `models.catalog` effort level). Null = inherit. Passed to the claude spawn as `--effort` (never `auto`). */
458
458
  effort: string | null;
459
+ /** Default agent CLI for New Session (`agentCli:` frontmatter); null = Claude Code (or an unknown on-disk value). */
460
+ agentCli?: AgentCliDetectRow['id'] | null;
461
+ /** Default model for that CLI (`agentCliModel:` frontmatter); null when unset or agentCli is null. */
462
+ agentCliModel?: string | null;
459
463
  color: string | null;
460
464
  /** Epic intent tags (tagLibrary.ts's TAG_LIBRARY) this persona is associated with. */
461
465
  tags: AgentPersonaTag[];
@@ -495,6 +499,10 @@ export interface AgentPersonaSaveInput {
495
499
  model: string;
496
500
  /** Effort level, or `'inherit'`/omitted to write no `effort:` line. */
497
501
  effort?: string;
502
+ /** Default agent CLI for New Session. Omit to keep the existing file's value; `'claude'` removes it (and the model). */
503
+ agentCli?: 'claude' | AgentCliDetectRow['id'];
504
+ /** Model for a non-Claude agentCli; ignored otherwise. Carried over with agentCli when agentCli is omitted. */
505
+ agentCliModel?: string;
498
506
  color: string;
499
507
  tags: AgentPersonaTag[];
500
508
  /** Project cwds (or the `'*'` sentinel) this persona's Action button appears in. Omit to keep the existing file's value; `[]` clears it. */
@@ -715,18 +723,6 @@ export interface TelemetryLastError {
715
723
  at: number;
716
724
  }
717
725
 
718
- export interface TelemetryBacklogSummary {
719
- projectsScanned: number;
720
- filesScanned: number;
721
- linesEnqueued: number;
722
- linesConfirmed: number;
723
- linesSkipped: number;
724
- filesCompleted: number;
725
- watermarksRewound: number;
726
- reason: string;
727
- ranAt: string;
728
- }
729
-
730
726
  export interface TelemetryStatus {
731
727
  pendingCount: number;
732
728
  sentCount: number;
@@ -739,7 +735,6 @@ export interface TelemetryStatus {
739
735
  lastError: TelemetryLastError | null;
740
736
  lastFlushAt: number | null;
741
737
  lastFlushReason: string | null;
742
- backlog: TelemetryBacklogSummary | null;
743
738
  }
744
739
 
745
740
  export interface TelemetrySetConfigResult {
@@ -2544,7 +2539,8 @@ export interface SessionManagerAPI {
2544
2539
  readPrd: (slug: string) => Promise<{ ok: boolean; text?: string; error?: string }>;
2545
2540
  readLog: (runId: string, slug: string) => Promise<{ ok: boolean; text?: string; error?: string }>;
2546
2541
  writePrd: (slug: string, body: string) => Promise<{ ok: true; bytesWritten: number } | { ok: false; error: string }>;
2547
- listPrds: () => Promise<PrdListItem[]>;
2542
+ /** Omit `cwd` for the machine-wide list; pass a project cwd to scope it. */
2543
+ listPrds: (cwd?: string) => Promise<PrdListItem[]>;
2548
2544
  health: () => Promise<ScheduleHealthSnapshot>;
2549
2545
  /** Queue-health header verdict — reuses classifyQueueHealth so this can
2550
2546
  * never disagree with the starvation watchdog. `cwd` null/omitted =
@@ -2810,6 +2806,9 @@ export interface SessionManagerAPI {
2810
2806
  listArchived: (payload: { cwd: string }) => Promise<{ ok: boolean; ids: string[]; error?: string }>;
2811
2807
  /** This project's earlier Claude Code sessions no Epic owns yet, newest first (restore-as-new-Epic picker). */
2812
2808
  listRestorable: (payload: { cwd: string }) => Promise<PromptSessionsListRestorableResult>;
2809
+ /** Interactive (non-headless) restorable sessions across every known project, newest first.
2810
+ * Resolves `{ ok: false, error }` on a refused `limit` or a lister failure — never rejects. */
2811
+ listRestorableRecent: (opts?: { limit?: number }) => Promise<PromptSessionsListRestorableRecentResult | { ok: false; error: string }>;
2813
2812
  readArchived: (payload: { cwd: string; epicId: string }) => Promise<{ exists: boolean; data: unknown; error?: string }>;
2814
2813
  readSessionTranscript: (payload: { cwd: string; sessionId: string }) => Promise<{ exists: boolean; text: string; error?: string }>;
2815
2814
  writeArchive: (payload: { cwd: string; epicId: string; archive: Record<string, unknown> }) => Promise<{ ok: true }>;
@@ -2932,6 +2931,22 @@ export interface PromptSessionsListRestorableResult {
2932
2931
  truncated: boolean;
2933
2932
  }
2934
2933
 
2934
+ // ─────────────────────────────────── PromptSessions list-restorable-recent (restorableSessions.cjs listRecentRestorableSessions)
2935
+ /** A RestorableSession from any known project, tagged with the project it belongs to. */
2936
+ export type RecentRestorableSession = RestorableSession & {
2937
+ /** Project root the transcript belongs to. */
2938
+ cwd: string;
2939
+ };
2940
+
2941
+ export interface PromptSessionsListRestorableRecentResult {
2942
+ /** Newest first by mtime, across projects. */
2943
+ sessions: RecentRestorableSession[];
2944
+ /** Projects whose transcripts were read by this call. */
2945
+ projectsRead: number;
2946
+ /** Some project's walk, or the project list, stopped with candidates left. */
2947
+ truncated: boolean;
2948
+ }
2949
+
2935
2950
  // ─────────────────────────────────── PromptSessions create-worktree (main-side createEpicWorktree)
2936
2951
  export interface PromptSessionsCreateWorktreePayload {
2937
2952
  cwd: string;
@@ -1847,6 +1847,13 @@
1847
1847
  "kind": "invoke",
1848
1848
  "remote": "read"
1849
1849
  },
1850
+ {
1851
+ "ns": "promptSessions",
1852
+ "method": "listRestorableRecent",
1853
+ "channel": "promptSessions:list-restorable-recent",
1854
+ "kind": "invoke",
1855
+ "remote": "read"
1856
+ },
1850
1857
  {
1851
1858
  "ns": "promptSessions",
1852
1859
  "method": "readArchived",
@@ -329,7 +329,7 @@ contextBridge.exposeInMainWorld('api', {
329
329
  readPrd: (slug) => ipcRenderer.invoke('schedule:read-prd', { slug }),
330
330
  readLog: (runId, slug) => ipcRenderer.invoke('schedule:read-log', { runId, slug }),
331
331
  writePrd: (slug, body) => ipcRenderer.invoke('schedule:write-prd', { slug, body }),
332
- listPrds: () => ipcRenderer.invoke('schedule:list-prds'),
332
+ listPrds: (cwd) => ipcRenderer.invoke('schedule:list-prds', cwd ? { cwd } : undefined),
333
333
  health: () => ipcRenderer.invoke('schedule:health'),
334
334
  // Queue-health header: one honest verdict for "why does the queue look
335
335
  // stale" (saturated/blocked/idle/stalled/paused/launch-blocked), scoped
@@ -637,6 +637,8 @@ contextBridge.exposeInMainWorld('api', {
637
637
  listArchived: (payload) => ipcRenderer.invoke('promptSessions:list-archived', payload),
638
638
  /** This project's earlier Claude Code sessions no Epic owns yet (restore-as-new-Epic picker). */
639
639
  listRestorable: (payload) => ipcRenderer.invoke('promptSessions:list-restorable', payload),
640
+ /** Interactive restorable sessions across every known project, newest first; each row carries its cwd. */
641
+ listRestorableRecent: (opts) => ipcRenderer.invoke('promptSessions:list-restorable-recent', opts),
640
642
  readArchived: (payload) => ipcRenderer.invoke('promptSessions:read-archived', payload),
641
643
  readSessionTranscript: (payload) => ipcRenderer.invoke('promptSessions:read-session-transcript', payload),
642
644
  /** Mutate-tier archive write for markCompleted (main builds the path; single-writer 'epics'). */
@@ -5,7 +5,7 @@ tools: Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__proj
5
5
  title: 'Project Home — Demo Video'
6
6
  model: opus
7
7
  effort: max
8
- seedVersion: 10
8
+ seedVersion: 11
9
9
  ---
10
10
 
11
11
  You are the demo-video-builder. You make a short animated demo, 30 seconds or 1 minute long per `<length_and_pacing>`, that shows someone what this
@@ -101,7 +101,8 @@ Use the shared kit in `~/.claude/session-manager/demo-video-kit/`. It needs only
101
101
  - `frames.cjs`: `sampleFrames({ htmlPath, lengthS })` seeks the finished document and returns per-frame stats plus a contact sheet. Look at the sheet; no blank frame may last past 0.5 s.
102
102
  - `checks.cjs`: `node checks.cjs input.json` with `{ captions, narration, closing, lines, speechS, lengthS, frames, html }` must exit 0 before you save. Fix every failing check and run it again.
103
103
  - `_character`: reuse the mascot in the project's session-manager-operations/project-pages/videos/_character/ when it exists (read `character.json` and `character.js`). Otherwise design one per `<character>` and save it once with `project_character_write`.
104
- If a kit tool fails, report its exact command and error; do not skip the check silently.
104
+ The soundtrack must come from sound.cjs's mix. Never hand-write ffmpeg mixing, ducking, sidechain or filter graphs for the soundtrack.
105
+ If any kit tool (capture.cjs, sound.cjs, frames.cjs, checks.cjs) fails, the run stops. Report the exact command and its error, and save nothing. Never build a replacement for a failed kit tool.
105
106
  </kit>
106
107
 
107
108
  <character>
@@ -284,4 +285,8 @@ all, that is a Session Manager launch bug, not an obstacle to route around: say
284
285
  the absolute path of the HTML file you built in your final result, and stop. Don't start Session
285
286
  Manager's MCP server yourself, call its admin API, write the saved file by hand, or build any
286
287
  other workaround or tooling, in the target project or anywhere else.
288
+ If a kit tool (capture.cjs, sound.cjs, frames.cjs, checks.cjs) fails, the run fails. Report the
289
+ exact command and its error, save nothing, and stop. Do not call `project_video_write`. Do not
290
+ hand-write an ffmpeg mixer or filter graph for the soundtrack; the soundtrack comes only from
291
+ sound.cjs's mix.
287
292
  </when_things_fail>
@@ -1,2 +0,0 @@
1
- import{bf as J,ba as Ne,aN as v,Z as A,b7 as ne,b5 as C,ax as e,l as H,b4 as Y,a7 as Ce,aC as M,bq as $e,b as I,aD as ke,aK as Se,b2 as Le,bi as se,M as De,d as U,E as Ee,a9 as Te}from"./index-BLORXCcT.js";import{P as ae}from"./Panel-D7NX5iP8.js";import{L as oe}from"./ListDetail-DY53nXya.js";import{V as Oe}from"./ViewTabs-CEjnWPD9.js";import{S as re}from"./SourceChip-DC5XD8KC.js";import{B as R}from"./Button-CObXxw7b.js";import{r as Pe}from"./claude-settings-schema-COigsajx.js";import"./monaco-editor-BsIlgG7c.js";function ie(t,a){const s=J();Ne([s?`${s}/.claude/agents`:null,...t.map(i=>`${i}/.claude/agents`)],a)}function Re({onOpenPersona:t}){const[a,s]=v.useState(A[0].tag),{personas:i,refresh:d}=ne(r=>C.error(r.message||"failed to load agent personas"));ie([],()=>{d()});const f=A.find(r=>r.tag===a)??null;return e.jsx(ae,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[A.length," tag",A.length===1?"":"s"]}),children:e.jsx(oe,{sidebar:e.jsx("div",{className:"py-1",children:A.map(r=>{const p=Y(r.tag),y=a===r.tag,m=(i==null?void 0:i.filter(h=>h.tags.includes(r.tag)).length)??0;return e.jsxs("button",{onClick:()=>{s(r.tag)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${y?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold ${p.bg} ${p.text} ${p.border?"border border-current/30":""}`,children:["#",r.tag]}),e.jsx("span",{className:"truncate",children:r.label}),m>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:m})]},r.tag)})}),detail:f?e.jsx(Fe,{entry:f,personas:i,onOpenPersona:t}):e.jsx(H,{title:"select a tag"})})})}const Ae=v.memo(Re);function Fe({entry:t,personas:a,onOpenPersona:s}){const i=Y(t.tag),d=Ce(t.tag),f=(a==null?void 0:a.filter(r=>r.tags.includes(t.tag)))??[];return e.jsxs("div",{className:"p-4 space-y-4 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:`px-2 py-1 rounded text-xs font-mono font-semibold ${i.bg} ${i.text} ${i.border?"border border-current/30":""}`,children:["#",t.tag]}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:t.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:t.description}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"/develop eagerness"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:t.developEagerness})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"develops via"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:t.developsVia})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"agents carrying this tag"}),a===null?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"loading…"}):e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.map(r=>e.jsx("button",{onClick:()=>s==null?void 0:s(r.name),title:`Open ${r.name} in Personas`,className:"inline-flex items-center bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim hover:text-fg hover:bg-bg-hi",children:r.name},r.name)),f.length===0&&e.jsx("span",{className:"text-xs text-fg-faint italic mr-1",children:"no agent carries this tag yet."})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"opening framing — sent before the human's goal"}),e.jsx("pre",{className:"text-xs text-fg-dim whitespace-pre-wrap bg-bg-elev border border-line rounded p-3 leading-relaxed font-sans",children:d.initialPromptTemplate})]})]})}const Be=new Set(A.map(t=>t.tag));function le(t){return t.filter(a=>Be.has(a))}function Me(t,a={}){return{name:t.name,originalName:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",effort:t.effort??void 0,color:t.color??"",tags:le(t.tags),projects:t.projects,action:t.action??void 0,actionLabel:t.actionLabel??void 0,title:t.title??void 0,body:t.body,...a}}const Ve=t=>{const[a,s]=t.split(".");return Number(a)+(s?Number(s)/100:0)};function We(t){const a=/Effort is supported on ([^.]*?)(?:, with|\.|$)/.exec(t);if(!a)return[];const s=[];for(const i of a[1].split(/,\s*|\s+and\s+/)){const d=/^(\w+)\s+(\d+(?:\.\d+)?)$/.exec(i.trim());d&&s.push({family:d[1].toLowerCase(),version:Ve(d[2])})}return s}var ee,te;const Ie=We(String(((te=(ee=Pe.properties)==null?void 0:ee.effortLevel)==null?void 0:te.description)??""));function Ke(t,a){const s=new RegExp(`${a}-(\\d+)(?:-(\\d{1,2})(?!\\d))?`,"i").exec(t);if(s)return Number(s[1])+(s[2]?Number(s[2])/100:0);const i=new RegExp(`claude-(\\d+)(?:-(\\d{1,2}))?-${a}`,"i").exec(t);return i?Number(i[1])+(i[2]?Number(i[2])/100:0):null}function _e(t,a=Ie){if(!t||t==="inherit"||a.length===0)return null;const s=M(t);if(!s)return null;const i=a.filter(f=>f.family===s);if(i.length===0)return!1;const d=Ke(t,s);return d===null?null:d>=Math.min(...i.map(f=>f.version))}const Z=["Read","Grep","Glob","Bash","Write","Edit","WebFetch","WebSearch","Task"],Ge=["","red","orange","yellow","green","cyan","blue","purple","pink"],de={red:"#c0392b",orange:"#b85c34",yellow:"#c9a227",green:"#6f7d52",cyan:"#3f8f8a",blue:"#4a6fa5",purple:"#7a6a8a",pink:"#b45a80"};function G(t){return{name:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",effort:t.effort??"inherit",color:t.color??"",tags:t.tags,body:t.body}}const Q={name:"new-agent",description:"",tools:["Read","Grep"],model:"inherit",effort:"inherit",color:"",tags:[],body:""};function ze(t){const a=new Map;for(const s of t){const i=typeof s.cwd=="string"?ke(s.cwd):"";i&&!a.has(i)&&a.set(i,{cwd:i,name:Se(i)})}return[...a.values()].sort((s,i)=>s.name.localeCompare(i.name)||s.cwd.localeCompare(i.cwd))}function ce(t){return[...t.fields.filter(a=>a!=="name"),...t.bodyOverridden?["full body"]:[]]}function He(t){return(t.overrideDetails??[]).map(a=>`${a.project}: ${ce(a).join(", ")||"overlay"}`).join(`
2
- `)}function Ue(){const[t,a]=v.useState("personas"),{personas:s,refresh:i}=ne(n=>C.error(n.message||"failed to load agent personas")),[d,f]=v.useState(null),[r,p]=v.useState(""),[y,m]=v.useState(null),[h,x]=v.useState(!1),[N,L]=v.useState(!1),[j,S]=v.useState(null),[D,w]=v.useState(!1),c=v.useRef(!0);v.useEffect(()=>()=>{c.current=!1},[]);const b=$e(n=>n.tabs),o=v.useMemo(()=>ze(b),[b]),[$,k]=v.useState(null),T=o.find(n=>n.cwd===$)??null,O=async n=>{await i()&&n&&f(n)};ie(o.map(n=>n.cwd),()=>O()),v.useEffect(()=>{const n=Le();n&&f(n);const u=E=>f(E.detail);return window.addEventListener("sm:select-persona",u),()=>window.removeEventListener("sm:select-persona",u)},[]);const V=e.jsx(Oe,{options:[{key:"personas",label:"Personas"},{key:"tags",label:"Tags"}],active:t,onChange:a});if(t==="tags")return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx("div",{className:"px-3 py-1.5 border-b border-line",children:V}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ae,{onOpenPersona:n=>{f(n),m(null),x(!1),a("personas")}})})]});if(s===null)return e.jsx(H,{title:"loading…"});const F=r.toLowerCase(),W=s.filter(n=>!F||n.name.toLowerCase().includes(F)||(n.description??"").toLowerCase().includes(F)),l=s.find(n=>n.name===d)??s[0]??null,g=y??(l?G(l):null),q=!!y&&!!l&&JSON.stringify(y)!==JSON.stringify(G(l)),B=h,xe=n=>{m(null),x(!1),L(!1),S(null),f(n)},ge=n=>m(u=>({...u??(l?G(l):Q),...n})),he=()=>{m({...Q}),x(!0),L(!1)},pe=()=>{g&&(m({...g,name:g.name+"-copy"}),x(!0))},ue=()=>{m(null),x(!1)},be=async()=>{if(g){if(!/^[a-z][a-z0-9-]*$/.test(g.name)){C.error('agent name must be lowercase, hyphenated (e.g. "my-agent")');return}w(!0);try{const n=B?null:l,u={name:g.name,originalName:n==null?void 0:n.name,description:g.description,tools:g.tools,model:g.model,effort:g.effort,color:g.color,tags:le(g.tags),body:g.body},E=n?Me(n,u):u;await window.api.agents.savePersona(E),C.info(B?`created ${g.name}`:`saved ${g.name}`),m(null),x(!1),await O(g.name)}catch(n){C.error(n.message||"failed to save agent persona")}finally{w(!1)}}},ve=async()=>{if(l){w(!0);try{await window.api.agents.deletePersona({name:l.name}),C.info(`deleted ${l.name}`),L(!1),m(null),x(!1),await O()}catch(n){C.error(n.message||"failed to delete agent persona")}finally{w(!1)}}},je=async n=>{w(!0);try{await window.api.agents.deletePersona({name:n}),C.info(`deleted ${n}`),S(null),d===n&&(m(null),x(!1)),await O()}catch(u){C.error(u.message||"failed to delete agent persona")}finally{w(!1)}},we=async(n,u)=>{if(l)try{await window.api.agents.removeOverride({name:l.name,projectCwd:n}),C.info(`removed ${u}'s override of ${l.name}`),await O(l.name)}catch(E){C.error(E.message||"failed to remove override")}},ye=async n=>{if(!l||!T)return;const{cwd:u,name:E}=T;w(!0);try{n.model==="inherit"&&n.effort==="inherit"?(await window.api.agents.removeOverride({name:l.name,projectCwd:u}),C.info(`cleared ${E}'s override of ${l.name}`)):(await window.api.agents.savePersona({name:l.name,projectCwd:u,description:"",tools:[],color:"",tags:[],body:"",model:n.model,effort:n.effort}),C.info(`saved ${E}'s override of ${l.name}`)),await O(l.name)}catch(K){C.error(K.message||"failed to save project override")}finally{w(!1)}};return e.jsx(ae,{toolbar:e.jsxs(e.Fragment,{children:[V,e.jsxs("span",{className:"text-fg-faint",children:[s.length," persona",s.length===1?"":"s"]}),e.jsx("input",{value:r,onChange:n=>p(n.target.value),placeholder:"filter…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-40"}),e.jsx("div",{className:"flex-1"}),e.jsx(R,{variant:"primary",onClick:he,children:"+ New agent"})]}),children:e.jsx(oe,{sidebar:e.jsxs("div",{className:"py-1",children:[B&&e.jsx("div",{className:"w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 bg-bg-hi text-fg border-l-2 border-accent",children:e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsx("span",{className:"truncate font-mono",children:g==null?void 0:g.name}),e.jsx("span",{className:"shrink-0 text-[10px] font-semibold text-accent",children:"new"})]})}),W.length===0&&!B?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no agent personas found"}):W.map(n=>{const u=!B&&n.name===d,E=u&&q,K=j===n.name;return e.jsxs("div",{"data-agent-row":n.name,className:`group w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 border-l-2 cursor-pointer ${u?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,onClick:()=>xe(n.name),children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:n.color?de[n.color]??n.color:"var(--fg-faint, #999)",opacity:n.color?1:.35}}),e.jsx("span",{className:"truncate font-mono",children:n.name})]}),e.jsxs("span",{className:"shrink-0 flex items-center gap-1.5",children:[E&&e.jsx("span",{className:"text-[10px] font-semibold text-accent",children:"unsaved"}),!E&&n.overridingProjects.length>0&&e.jsx("span",{title:He(n),children:e.jsxs(I,{tone:"dim",children:[n.overridingProjects.length," override",n.overridingProjects.length>1?"s":""]})}),K?e.jsxs("span",{className:"flex items-center gap-1",onClick:_=>_.stopPropagation(),children:[e.jsx("button",{onClick:()=>je(n.name),disabled:D,title:`Delete ${n.name}`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),e.jsx("button",{onClick:()=>S(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):e.jsx("button",{onClick:_=>{_.stopPropagation(),S(n.name)},title:`Delete ${n.name}`,className:"opacity-0 group-hover:opacity-100 text-fg-faint hover:text-red-400 transition-opacity",children:"×"})]})]}),n.description&&e.jsx("span",{className:"truncate text-fg-faint",children:n.description})]},n.name)})]}),detail:g?e.jsx(Je,{obj:g,set:ge,saved:l,dirty:q,isNew:B,busy:D,confirmDelete:N,setConfirmDelete:L,onDuplicate:pe,onRevert:ue,onSave:be,onDelete:ve,onDropOverride:we,projects:o,selected:T,onSelect:k,onSaveOverride:ye}):e.jsx(H,{title:"select an agent"})})})}const at=v.memo(Ue);function Je({obj:t,set:a,saved:s,dirty:i,isNew:d,busy:f,confirmDelete:r,setConfirmDelete:p,onDuplicate:y,onRevert:m,onSave:h,onDelete:x,onDropOverride:N,projects:L,selected:j,onSelect:S,onSaveOverride:D}){const w=J(),c=!d&&s?s.path:`${w??"~"}/.claude/agents/${t.name}.md`,b=i||d;return e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-line flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-semibold text-fg font-mono",children:t.name}),d?e.jsx(I,{tone:"accent",children:"unsaved draft"}):i?e.jsx(I,{tone:"warn",children:"edited"}):e.jsx(I,{tone:"good",children:"saved"}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(re,{path:c})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(P,{label:"name",hint:"Filename on disk — lowercase, hyphenated.",children:e.jsx("input",{value:t.name,onChange:o=>a({name:o.target.value.toLowerCase()}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"})}),e.jsx(P,{label:"description",hint:"Shown in the list and in agent pickers.",children:e.jsx("input",{value:t.description,onChange:o=>a({description:o.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg"})}),e.jsx(fe,{value:t.model,onChange:o=>a({model:o})}),e.jsx(me,{value:t.effort,model:t.model,onChange:o=>a({effort:o})}),!d&&s&&e.jsx(Ye,{saved:s,projects:L,selected:j,onSelect:S,busy:f,onSave:D}),e.jsx(P,{label:"tools",hint:`${t.tools.length} of ${Z.length} granted. Anything not ticked is refused at call time.`,children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Z.map(o=>{const $=t.tools.includes(o);return e.jsx("button",{onClick:()=>a({tools:$?t.tools.filter(k=>k!==o):[...t.tools,o]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${$?"bg-sage/15 text-sage-dark border-sage/30":"bg-bg-hi text-fg-faint border-line"}`,children:o},o)})})}),e.jsx(P,{label:"color",children:e.jsx("div",{className:"flex gap-1.5",children:Ge.map(o=>e.jsx("button",{title:o||"none",onClick:()=>a({color:o}),className:"w-5 h-5 rounded",style:{background:o?de[o]:"transparent",border:t.color===o?"2px solid var(--accent, #b85c34)":"1px solid var(--line, #555)"}},o||"none"))})}),e.jsx(P,{label:"tags",hint:"Session mission tags this persona is associated with — shown as the default agent on the Tags tab.",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(o=>{const $=t.tags.includes(o.tag),k=Y(o.tag);return e.jsxs("button",{onClick:()=>a({tags:$?t.tags.filter(T=>T!==o.tag):[...t.tags,o.tag]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${$?`${k.bg} ${k.text} ${k.border?"border-current/30":"border-transparent"}`:"bg-bg-hi text-fg-faint border-line"}`,children:["#",o.tag]},o.tag)})})}),e.jsx(P,{label:"definition",hint:"The system prompt this persona runs under.",children:e.jsx("textarea",{rows:9,value:t.body,onChange:o=>a({body:o.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg font-mono leading-relaxed resize-y"})}),e.jsx(P,{label:"project overrides",hint:"Open projects that shadow this definition with a local copy.",children:s&&(s.overrideDetails??[]).length>0?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:(s.overrideDetails??[]).map(o=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim",children:[o.project,e.jsx("button",{onClick:()=>N(o.cwd,o.project),title:"Drop the local copy",className:"text-fg-faint hover:text-fg",children:"×"})]},o.cwd))}):e.jsx("div",{className:"text-xs text-fg-faint italic",children:d?"save first to see project overrides.":"no open project overlays this agent — the global definition applies everywhere."})})]}),e.jsx("div",{className:"px-4 py-2.5 border-t border-line flex items-center gap-2 flex-wrap",children:r?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-xs text-fg-dim",children:["Delete ",e.jsx("strong",{className:"font-mono",children:t.name})," and its file?"]}),e.jsx(R,{variant:"danger",onClick:x,disabled:f,children:"Delete"}),e.jsx(R,{onClick:()=>p(!1),children:"Keep"})]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{onClick:y,disabled:f,children:"Duplicate"}),!d&&e.jsx(R,{variant:"danger",onClick:()=>p(!0),disabled:f,children:"Delete"}),e.jsx("div",{className:"flex-1"}),b&&e.jsx("span",{className:"text-[11px] text-fg-faint",children:"unsaved changes"}),e.jsx(R,{onClick:m,disabled:!b||f,children:"Revert"}),e.jsx(R,{variant:"primary",onClick:h,disabled:!b||f,children:f?"Saving…":d?"Create":"Save"})]})})]})}function P({label:t,hint:a,children:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:t}),s,a&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:a})]})}const z="latest",X="Blocked by the availableModels allowlist in your Claude settings";function fe({value:t,onChange:a,label:s="default model",hint:i,testIdPrefix:d="",inheritLabel:f}){var F,W;const{catalog:r,loading:p,degraded:y,refresh:m}=se(null),h=r?["inherit",...r.aliases]:[...De],x=(r==null?void 0:r.availableModels)??null,N=l=>!!x&&l!=="inherit"&&!x.includes(l),L=(l,g)=>!!x&&!x.includes(l)&&!(g&&x.includes(g)),j=t||"inherit",S=((F=/\[[^\]]*\]$/.exec(j))==null?void 0:F[0])??"",D=h.includes(j),w=!D&&r&&M(j)&&h.includes(M(j)+S)?M(j)+S:null,c=D?j:w??j,b=M(c),o=((W=/\[[^\]]*\]$/.exec(c))==null?void 0:W[0])??"",$=!!r&&j!=="inherit"&&!!b&&h.includes(c),k=$?r.models.filter(l=>M(l)===b).map(l=>l+o):[],T=D?z:j,O={};if(r)for(const l of h)N(l)&&(O[l]=X);const V={};for(const l of k)L(l,b)&&(V[l]=X);return e.jsxs(P,{label:s,hint:i??"This persona's default model for its Epics — sets the --model an Epic launches with (Terminal + Chat both honor it). 'inherit' falls back to each view's own default, not this Settings page. Cheap models for read-only personas; opus for judgement calls.",children:[e.jsx("div",{"data-testid":`${d}model-row`,children:e.jsx(U,{options:h,value:c,onChange:a,mono:!0,blocked:O,labels:f?{inherit:f}:void 0})}),$&&e.jsxs("div",{className:"mt-2","data-testid":`${d}model-version-row`,children:[e.jsx("div",{className:"text-[10.5px] text-fg-faint mb-1 font-mono",children:"version"}),e.jsx(U,{options:[z,...k],value:T,onChange:l=>a(l===z?c:l),mono:!0,blocked:V})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug flex items-center gap-2",children:[e.jsx("span",{children:r?`Models are live-read from the installed claude CLI${y?" (cached — CLI probe unavailable)":""}. "latest" keeps the floating alias.`:p?"Loading model catalog…":"catalog unavailable — showing the standard list."}),e.jsx("button",{"data-testid":`${d}model-catalog-refresh`,onClick:()=>{m()},disabled:p,className:"underline text-fg-dim disabled:opacity-40",children:"refresh"})]})]})}function me({value:t,model:a,onChange:s,label:i="effort",testIdPrefix:d="",inheritLabel:f}){const{catalog:r}=se(null),p=r&&r.effortLevels.length?["inherit",...r.effortLevels]:[...Ee],y=(r==null?void 0:r.settingsEffortLevels)??[],m=r?p.filter(N=>N!=="inherit"&&!y.includes(N)):[],h=t||"inherit",x=h!=="inherit"&&_e(a)===!1;return e.jsxs(P,{label:i,hint:r?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${m.length?`${m.join(", ")} ${m.length>1?"are":"is"} session-only — settings.json accepts ${y.join(", ")}. `:""}'inherit' writes no effort: line.`:"catalog unavailable — showing the standard list. 'inherit' writes no effort: line.",children:[e.jsx("div",{"data-testid":`${d}effort-row`,children:e.jsx(U,{options:p,value:h,onChange:s,mono:!0,labels:f?{inherit:f}:void 0})}),m.length>0&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 font-mono","data-testid":`${d}effort-session-only`,children:m.map(N=>`${N} (session-only)`).join(" · ")}),x&&e.jsx("div",{className:"text-[11px] text-amber-400 mt-1 leading-snug","data-testid":`${d}effort-unsupported-note`,children:"The selected model does not support effort — the CLI will ignore this setting."})]})}function Ye({saved:t,projects:a,selected:s,onSelect:i,busy:d,onSave:f}){var S,D,w;const r=J(),p=new Map;for(const c of a)p.set(c.name,(p.get(c.name)??0)+1);const y=c=>{var k;const b=(p.get(c.name)??0)>1?Te(c.cwd,r):c.name,o=(k=t.overrideDetails)==null?void 0:k.find(T=>T.cwd===c.cwd);if(!o)return b;const $=ce(o);return`${b} — ${$.length?`overrides ${$.join(", ")}`:"overlay"}`},m=s?(S=t.overrideDetails)==null?void 0:S.find(c=>c.cwd===s.cwd):void 0,h=!!(m!=null&&m.bodyOverridden),x=((D=m==null?void 0:m.values)==null?void 0:D.model)??"inherit",N=((w=m==null?void 0:m.values)==null?void 0:w.effort)??"inherit",L=t.model??"inherit",j=t.effort??"inherit";return e.jsxs("div",{"data-testid":"project-override-block",className:s?"border border-accent/40 rounded p-3 space-y-3 bg-accent/5":"border border-dashed border-line rounded p-3 space-y-3",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:`text-[10.5px] font-semibold uppercase tracking-wide font-mono ${s?"text-accent":"text-fg-faint"}`,children:"project override"}),e.jsxs("select",{"data-testid":"override-project-select",value:(s==null?void 0:s.cwd)??"",onChange:c=>i(c.target.value||null),disabled:d||a.length===0,className:"rounded-md border border-line bg-bg px-2 py-1.5 font-mono text-[12.5px] text-fg disabled:opacity-60",children:[e.jsx("option",{value:"",children:"Choose a project…"}),a.map(c=>e.jsx("option",{value:c.cwd,children:y(c)},c.cwd))]})]}),a.length===0?e.jsx("div",{"data-testid":"project-override-none",className:"text-[11px] text-fg-faint leading-snug",children:"No open project tabs — open a project tab to override this persona's model or effort for it."}):s?e.jsxs("div",{"data-testid":"project-override",className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(I,{tone:"accent",children:[s.name," only"]}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(re,{path:`${s.cwd}/.claude/agents/${t.name}.md`})})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint leading-snug",children:["Changes what the SCHEDULER (and new Epics) spawn for ",e.jsx("strong",{children:s.name})," only — a frontmatter-only overlay with just the keys you set; the persona's body stays the global one. The global model/effort rows edit the machine-wide persona and are never touched here."]}),h&&e.jsxs("div",{"data-testid":"project-override-fullbody",className:"text-[11px] text-amber-400 leading-snug",children:[s.name,' already has a FULL-BODY override of this persona (its own definition text). It is shown as-is and not converted to a frontmatter-only overlay — edit that file directly, or drop it with × under "project overrides" below.']}),e.jsxs("fieldset",{disabled:d||h,className:"space-y-3 border-0 p-0 m-0 min-w-0",children:[e.jsx(fe,{value:x,onChange:c=>{h||f({model:c,effort:N})},label:"project model",hint:"'use global' writes no model: line in the overlay.",testIdPrefix:"override-",inheritLabel:"use global"}),e.jsx(me,{value:N,model:x!=="inherit"?x:L,onChange:c=>{h||f({model:x,effort:c})},label:"project effort",testIdPrefix:"override-",inheritLabel:"use global"})]}),e.jsx("div",{"data-testid":"override-provenance",className:"text-[11px] font-mono text-fg-dim space-y-0.5",children:[["model",L,x],["effort",j,N]].map(([c,b,o])=>e.jsxs("div",{"data-testid":`override-provenance-${c}`,children:[c,": ",o!=="inherit"?e.jsxs(e.Fragment,{children:[b," ",e.jsx("span",{className:"text-fg-faint",children:"(global)"})," → ",e.jsx("span",{className:"text-accent",children:o})," ",e.jsx("span",{className:"text-fg-faint",children:"(this project)"})]}):e.jsxs(e.Fragment,{children:[b," ",e.jsx("span",{className:"text-fg-faint",children:"(global — not overridden)"})]})]},c))})]}):e.jsx("div",{"data-testid":"project-override-unselected",className:"text-[11px] text-fg-faint leading-snug",children:"Pick an open project to see or set this persona's model and effort for that project only. A project that already overrides this persona says what it overrides."})]})}export{at as AgentLibrary};