claude-code-session-manager 0.143.0 → 0.145.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 (128) hide show
  1. package/README.md +3 -1
  2. package/dist/assets/AppSettings-BR5b6oof.js +2 -0
  3. package/dist/assets/{History-DTttbvPb.js → History-B4U0mCdK.js} +2 -2
  4. package/dist/assets/HomeClaudeConfig-DQqG7lFE.js +5 -0
  5. package/dist/assets/{Panel-B_D4Bg7L.js → Panel-CwsOJ0nI.js} +1 -1
  6. package/dist/assets/ProjectClaudeConfig-BzRowu8x.js +26 -0
  7. package/dist/assets/Scheduler-dr7CNOcL.js +16 -0
  8. package/dist/assets/{SkillReferenceGraph-D1b2aiol.js → SkillReferenceGraph-CroBPY4C.js} +1 -1
  9. package/dist/assets/{Skills-cfV7sgk6.js → Skills-BiW2lCnD.js} +23 -23
  10. package/dist/assets/{TiptapBody-DVXtEIVy.js → TiptapBody-CYTkQiva.js} +27 -27
  11. package/dist/assets/{Toggle-CYajnSdx.js → Toggle-WFBYo8JI.js} +1 -1
  12. package/dist/assets/{VoiceButton-DJ4gGRuE.js → VoiceButton-DZu8dTpO.js} +1 -1
  13. package/dist/assets/{historyTotals-D3MoHY2U.js → historyTotals-B7KeXLSE.js} +1 -1
  14. package/dist/assets/{index-DVHIHoJf.css → index-BJ5TJvmz.css} +1 -1
  15. package/dist/assets/{index-CdTppjKR.js → index-hXRNm0UJ.js} +698 -697
  16. package/dist/index.html +2 -2
  17. package/dist-web/app.css +1 -1
  18. package/dist-web/app.js +442 -439
  19. package/package.json +4 -2
  20. package/plugins/session-manager-dev/skills/develop/SKILL.md +25 -19
  21. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +16 -2
  22. package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +91 -0
  23. package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +9 -6
  24. package/scripts/README.md +1 -1
  25. package/scripts/scheduler-mcp-server.cjs +77 -0
  26. package/src/main/adminRouteRegistry.cjs +6 -0
  27. package/src/main/agentLibrary.cjs +60 -11
  28. package/src/main/agentsIpc.cjs +19 -0
  29. package/src/main/build-info.json +4 -4
  30. package/src/main/chatRunner.cjs +139 -0
  31. package/src/main/config.cjs +12 -0
  32. package/src/main/health.cjs +59 -17
  33. package/src/main/index.cjs +6 -2
  34. package/src/main/ipcSchemas.cjs +55 -1
  35. package/src/main/lib/claude/agentArmory.cjs +128 -0
  36. package/src/main/lib/claude/agentModelResolve.cjs +3 -2
  37. package/src/main/lib/claude/agentSnapshot.cjs +24 -3
  38. package/src/main/lib/claude/builtinTools.cjs +110 -0
  39. package/src/main/lib/claude/environmentProfiles.cjs +1 -1
  40. package/src/main/lib/claude/headlessMcpServers.cjs +138 -0
  41. package/src/main/lib/claude/jobSandboxPolicy.cjs +8 -2
  42. package/src/main/lib/claude/personaToolScope.cjs +100 -14
  43. package/src/main/lib/demo-video-kit/resumableRun.cjs +21 -14
  44. package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
  45. package/src/main/lib/epic/epicDepsSync.cjs +66 -0
  46. package/src/main/lib/epic/epicOutsideRead.cjs +74 -2
  47. package/src/main/lib/epic/epicSettle.cjs +48 -4
  48. package/src/main/lib/epic/epicSpawnPlan.cjs +3 -1
  49. package/src/main/lib/epic/epicValidationHook.cjs +9 -1
  50. package/src/main/lib/epic/planReviewInput.cjs +125 -0
  51. package/src/main/lib/epic/restorableSessions.cjs +1 -0
  52. package/src/main/lib/epic/scriptStartedBy.cjs +86 -0
  53. package/src/main/lib/externalContract.cjs +12 -0
  54. package/src/main/lib/feedback-remote/createdProjects.cjs +291 -0
  55. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +108 -14
  56. package/src/main/lib/feedback-remote/localAdminHttp.cjs +5 -1
  57. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +24 -3
  58. package/src/main/lib/feedback-remote/pendingReplies.cjs +8 -4
  59. package/src/main/lib/feedback-remote/projectCreate.cjs +415 -0
  60. package/src/main/lib/feedback-remote/replyClaims.cjs +15 -6
  61. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +35 -4
  62. package/src/main/lib/feedback-remote/serviceMcpTools.cjs +43 -2
  63. package/src/main/lib/feedback-remote/servicePairLocalRoutes.cjs +91 -0
  64. package/src/main/lib/feedback-remote/servicePairings.cjs +95 -7
  65. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +104 -1
  66. package/src/main/lib/git/gitWorktree.cjs +1 -1
  67. package/src/main/lib/git/worktreeDeps.cjs +9 -3
  68. package/src/main/lib/mcpToolCatalog.cjs +47 -7
  69. package/src/main/lib/mcpToolsProbe.cjs +19 -2
  70. package/src/main/lib/opsOwnership.cjs +2 -0
  71. package/src/main/lib/packs/packCatalog.cjs +98 -5
  72. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +6 -0
  73. package/src/main/lib/persona-macro/builtinMacros.cjs +6 -4
  74. package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +9 -0
  75. package/src/main/lib/persona-macro/personaLoadout.cjs +58 -0
  76. package/src/main/lib/persona-macro/personaMerge.cjs +11 -3
  77. package/src/main/lib/persona-macro/personaUpgrade.cjs +96 -0
  78. package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +1 -1
  79. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +94 -0
  80. package/src/main/lib/prd/prdCreate.cjs +49 -5
  81. package/src/main/lib/prd/prdFrontmatter.cjs +5 -2
  82. package/src/main/lib/prd/prdMcpReachWarnings.cjs +46 -0
  83. package/src/main/lib/prd/prdSandboxWarnings.cjs +49 -0
  84. package/src/main/lib/process/peerChatSession.cjs +165 -0
  85. package/src/main/lib/project-pages/videoScriptPress.cjs +6 -0
  86. package/src/main/lib/project-pages/videoScriptRunRoute.cjs +24 -4
  87. package/src/main/lib/promptSessionSchema.cjs +2 -0
  88. package/src/main/lib/scheduler/baselineGate.cjs +31 -2
  89. package/src/main/lib/scheduler/planRecordHarvest.cjs +104 -12
  90. package/src/main/lib/scheduler/planReleaseRoute.cjs +110 -0
  91. package/src/main/lib/scheduler/planReviewSchema.cjs +182 -0
  92. package/src/main/lib/scheduler/planReviewStats.cjs +63 -0
  93. package/src/main/lib/scheduler/planReviewStore.cjs +150 -0
  94. package/src/main/lib/scheduler/reviewNotice.cjs +3 -1
  95. package/src/main/lib/scheduler/sandboxEnvironmentLimit.cjs +141 -0
  96. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  97. package/src/main/lib/scheduler/upgradeDrain.cjs +32 -5
  98. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +12 -2
  99. package/src/main/lib/tasks/memoryConsolidation.cjs +118 -37
  100. package/src/main/lib/tasks/taskAdminRoutes.cjs +26 -14
  101. package/src/main/lib/tasks/taskRun.cjs +3 -1
  102. package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +298 -0
  103. package/src/main/projectPages.cjs +22 -14
  104. package/src/main/pty.cjs +3 -0
  105. package/src/main/runVerify.cjs +80 -5
  106. package/src/main/scheduler/gitTreeGuard.cjs +6 -0
  107. package/src/main/scheduler/planReviewHold.cjs +146 -0
  108. package/src/main/scheduler/prdParser.cjs +1 -0
  109. package/src/main/scheduler/prdPaths.cjs +10 -1
  110. package/src/main/scheduler/reviewLadder.cjs +2 -0
  111. package/src/main/scheduler/utilizationHold.cjs +7 -2
  112. package/src/main/scheduler.cjs +692 -86
  113. package/src/main/seedAgentPersonas.cjs +11 -6
  114. package/src/main/seedStatus.cjs +1 -1
  115. package/src/main/templates/PRD_AUTHORING.md +17 -2
  116. package/src/main/webRemote.cjs +69 -7
  117. package/src/preload/api.d.ts +79 -1
  118. package/src/preload/apiSurface.json +39 -0
  119. package/src/preload/index.cjs +11 -0
  120. package/src/seed/agents/architect.md +28 -43
  121. package/src/seed/agents/dev-lead.md +3 -1
  122. package/src/seed/agents/md-network-curator.md +27 -0
  123. package/src/seed/agents/plan-reviewer.md +47 -0
  124. package/src/seed/agents/validator.md +2 -1
  125. package/dist/assets/AppSettings-BO4jDVGO.js +0 -2
  126. package/dist/assets/HomeClaudeConfig-DADP5bfn.js +0 -3
  127. package/dist/assets/ProjectClaudeConfig-DPnDJKcr.js +0 -26
  128. package/dist/assets/Scheduler-CNLjn90m.js +0 -16
@@ -5,7 +5,7 @@
5
5
  * agent), stored locally and content-addressed.
6
6
  *
7
7
  * A snapshot freezes exactly the agent definition a run used:
8
- * { name, bodySha256, body, model, effort, tools, mcpServers, packs, seedVersion, environment }
8
+ * { name, bodySha256, body, model, effort, tools, mcpServers, packs, seedVersion, environment, gearBindsChat, loadout }
9
9
  * Its id is the sha256 of its canonical JSON (keys sorted at every depth), so
10
10
  * equal definitions share one id and any edit (body, model, tools, ...) mints
11
11
  * a new one. A resume can therefore re-run precisely the definition it pinned.
@@ -36,6 +36,7 @@ const crypto = require('node:crypto');
36
36
  const fsp = require('node:fs/promises');
37
37
  const { opsPath, assertOpsWrite } = require('../opsOwnership.cjs');
38
38
  const atomicFs = require('../util/atomicFs.cjs');
39
+ const { loadoutState } = require('../persona-macro/personaLoadout.cjs');
39
40
 
40
41
  const WRITER = 'agents';
41
42
  const ID_RE = /^[0-9a-f]{64}$/;
@@ -107,6 +108,23 @@ async function buildAgentSnapshot({ cwd, agentType, packs, deps = {} } = {}) {
107
108
  return { id: null, snapshot: null, refusal: { code: env.code, detail } };
108
109
  }
109
110
 
111
+ // Persona-declared capabilities (`mcpServers:` / `packs:`) are part of the snapshot, so every
112
+ // caller (epicMint, epicAgentRefresh, scheduler) records the same resolved set.
113
+ let declaredServers = [];
114
+ let declaredPacks = [];
115
+ if (fm) {
116
+ try {
117
+ const { parseCapabilityList } = require('../../agentLibrary.cjs');
118
+ declaredServers = parseCapabilityList(fm.mcpServers);
119
+ declaredPacks = parseCapabilityList(fm.packs);
120
+ } catch { /* no declared capabilities */ }
121
+ }
122
+ const mergedPacks = [];
123
+ for (const p of [...declaredPacks, ...(Array.isArray(packs) ? packs : [])]) {
124
+ const id = String(p);
125
+ if (!mergedPacks.includes(id)) mergedPacks.push(id);
126
+ }
127
+
110
128
  const body = resolved.systemPrompt || '';
111
129
  const tools = Array.isArray(resolved.tools) ? resolved.tools.map(String) : null;
112
130
  const snapshot = {
@@ -116,10 +134,13 @@ async function buildAgentSnapshot({ cwd, agentType, packs, deps = {} } = {}) {
116
134
  model: resolved.model || null,
117
135
  effort: effort || null,
118
136
  tools,
119
- mcpServers: mcpServersFromTools(tools),
120
- packs: Array.isArray(packs) ? packs.map(String) : [],
137
+ mcpServers: [...new Set([...declaredServers.map((d) => String(d).trim()).filter(Boolean), ...mcpServersFromTools(tools)])].sort(),
138
+ packs: mergedPacks,
121
139
  seedVersion,
122
140
  environment: { id: env.id, hash: env.hash },
141
+ // Gear applies to chat turns only for snapshots stamped true; older snapshots lack the key (falsy).
142
+ gearBindsChat: true,
143
+ loadout: loadoutState(fm),
123
144
  };
124
145
  return { id: snapshotId(snapshot), snapshot, refusal: null };
125
146
  }
@@ -0,0 +1,110 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * builtinTools.cjs — learns the claude CLI's real built-in tool and bundled-skill
5
+ * names from the stream-json `system`/`init` event of a minimal run. The init
6
+ * event is emitted before the first API call, so the child is killed on init and
7
+ * no model tokens are spent. Cached in memory per CLI version; any failure
8
+ * returns FALLBACK_TOOLS (source 'fallback') and never throws.
9
+ */
10
+
11
+ const os = require('node:os');
12
+ const { resolveClaudeBin, probeClaudeVersion } = require('./claudeBin.cjs');
13
+ const { killTree, detachedSpawnOpts } = require('../process/killTree.cjs');
14
+ const { cleanChildEnv } = require('../process/cleanEnv.cjs');
15
+
16
+ const FALLBACK_TOOLS = ['Read', 'Grep', 'Glob', 'Bash', 'Write', 'Edit', 'WebFetch', 'WebSearch', 'Task', 'Agent', 'Skill', 'NotebookEdit', 'TodoWrite'];
17
+ const PROBE_TIMEOUT_MS = 20_000;
18
+ const OUTPUT_CAP_BYTES = 2 * 1024 * 1024;
19
+
20
+ /** @type {Map<string, { tools: string[], skills: string[], source: 'cli' | 'fallback', cliVersion: string | null }>} */
21
+ const cache = new Map();
22
+
23
+ const strings = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === 'string' && x) : []);
24
+
25
+ /** Probe argv: pinned model, no user MCP, no user/project/local settings or plugins. */
26
+ function probeArgs() {
27
+ return ['--model', 'haiku', '-p', 'hi', '--output-format', 'stream-json', '--verbose', '--strict-mcp-config', '--setting-sources', 'project'];
28
+ }
29
+
30
+ /**
31
+ * Spawn the probe; resolve with the parsed init event or null. Never rejects.
32
+ * @returns {Promise<Record<string, any> | null>}
33
+ */
34
+ function runProbe(spawn, claudeBin) {
35
+ return new Promise((resolve) => {
36
+ let child = null;
37
+ let settled = false;
38
+ let buf = '';
39
+ let bytes = 0;
40
+ let timer = null;
41
+ const finish = (value) => {
42
+ if (settled) return;
43
+ settled = true;
44
+ if (timer) clearTimeout(timer);
45
+ if (child && child.pid) { try { killTree(child.pid, 'SIGKILL'); } catch { /* */ } }
46
+ else if (child && typeof child.kill === 'function') { try { child.kill('SIGKILL'); } catch { /* */ } }
47
+ resolve(value);
48
+ };
49
+ const feed = (chunk) => {
50
+ if (settled) return;
51
+ bytes += chunk.length;
52
+ buf += chunk.toString();
53
+ let nl;
54
+ while ((nl = buf.indexOf('\n')) >= 0) {
55
+ const line = buf.slice(0, nl).trim();
56
+ buf = buf.slice(nl + 1);
57
+ if (!line) continue;
58
+ let evt;
59
+ try { evt = JSON.parse(line); } catch { return finish(null); }
60
+ if (evt && evt.type === 'system' && evt.subtype === 'init') return finish(evt);
61
+ }
62
+ if (bytes > OUTPUT_CAP_BYTES) finish(null);
63
+ };
64
+ try {
65
+ child = spawn(claudeBin, probeArgs(), {
66
+ cwd: os.tmpdir(),
67
+ env: cleanChildEnv(),
68
+ stdio: ['ignore', 'pipe', 'ignore'],
69
+ windowsHide: true,
70
+ ...detachedSpawnOpts(),
71
+ });
72
+ timer = setTimeout(() => finish(null), PROBE_TIMEOUT_MS);
73
+ if (child.stdout) child.stdout.on('data', feed);
74
+ child.on('error', () => finish(null));
75
+ child.on('close', () => finish(null));
76
+ } catch {
77
+ finish(null);
78
+ }
79
+ });
80
+ }
81
+
82
+ /**
83
+ * @param {{ spawn?: Function, claudeBin?: string, cliVersion?: string | null }} [opts]
84
+ * @returns {Promise<{ tools: string[], skills: string[], source: 'cli' | 'fallback', cliVersion: string | null }>}
85
+ */
86
+ async function getBuiltinTools({ spawn, claudeBin, cliVersion } = {}) {
87
+ let version = cliVersion || null;
88
+ try {
89
+ if (!version) version = await probeClaudeVersion();
90
+ } catch { /* version stays null */ }
91
+ const key = version || 'unknown';
92
+ const hit = cache.get(key);
93
+ if (hit) return { ...hit, tools: [...hit.tools], skills: [...hit.skills] };
94
+ try {
95
+ const doSpawn = spawn || require('node:child_process').spawn;
96
+ const init = await runProbe(doSpawn, claudeBin || resolveClaudeBin());
97
+ const tools = init ? strings(init.tools).filter((t) => !t.startsWith('mcp__')) : [];
98
+ if (init && tools.length) {
99
+ const result = { tools, skills: strings(init.skills), source: /** @type {const} */ ('cli'), cliVersion: version };
100
+ cache.set(key, result);
101
+ return { ...result, tools: [...tools], skills: [...result.skills] };
102
+ }
103
+ } catch { /* fall through */ }
104
+ return { tools: [...FALLBACK_TOOLS], skills: [], source: 'fallback', cliVersion: version };
105
+ }
106
+
107
+ /** Test hook — forget cached probes. */
108
+ function __resetForTests() { cache.clear(); }
109
+
110
+ module.exports = { getBuiltinTools, FALLBACK_TOOLS, __resetForTests };
@@ -116,7 +116,7 @@ const BUILTIN_ENVIRONMENTS = deepFreeze({
116
116
  osSandboxRequired: true,
117
117
  permissionMode: 'acceptEdits',
118
118
  writeRoots: [...JOB_WRITE_ROOTS],
119
- network: { mode: 'allowlist', hosts: ['registry.npmjs.org'] },
119
+ network: { mode: 'allowlist', hosts: ['registry.npmjs.org', 'api.github.com'] },
120
120
  secretDenyPaths: [...SANDBOX_SECRET_PATHS],
121
121
  webFetch: false,
122
122
  webSearch: false,
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+
3
+ // The one map of MCP server definitions a headless job, Task or geared chat
4
+ // turn may load. Reads the same scopes the CLI does (user < project < local)
5
+ // and refuses credential-bearing entries so no secret reaches a job's argv.
6
+
7
+ const fs = require('node:fs');
8
+ const os = require('node:os');
9
+ const path = require('node:path');
10
+ const seed = require('../../seedSchedulerMcp.cjs');
11
+ const { SECRET_KEY_RE } = require('../process/cleanEnv.cjs');
12
+
13
+ const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
14
+ const isPlain = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
15
+
16
+ function readJson(file) {
17
+ try {
18
+ const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
19
+ return isPlain(parsed) ? parsed : null;
20
+ } catch {
21
+ return null;
22
+ }
23
+ }
24
+
25
+ /** Plain-object entries of a plain-object mcpServers map; else {}. */
26
+ function serversOf(map) {
27
+ const out = {};
28
+ if (!isPlain(map)) return out;
29
+ for (const name of Object.keys(map)) {
30
+ if (has(map, name) && isPlain(map[name])) out[name] = map[name];
31
+ }
32
+ return out;
33
+ }
34
+
35
+ const SECRET_FLAG_RE = /^--(api-key|apikey|token|access-token|secret|password|auth|pat)(=|$)/i;
36
+ const EXTRA_KEY_RE = /(^|_)(PAT|CREDENTIALS?|PRIVATE_KEY)$/i;
37
+ const QUERY_KEY_RE = /(token|key|secret|password|sig|signature|auth)/i;
38
+ const USERINFO_RE = /[a-z][a-z0-9+.-]*:\/\/[^/?#\s@]+@/i;
39
+ const HINT = 'move the secret to a vault ref (environment profile) or run it outside the job';
40
+
41
+ function secretKey(key) {
42
+ return SECRET_KEY_RE.test(key) || EXTRA_KEY_RE.test(key) || /authorization/i.test(key);
43
+ }
44
+
45
+ function argsReason(name, args) {
46
+ if (!Array.isArray(args)) return null;
47
+ for (let i = 0; i < args.length; i++) {
48
+ const a = args[i];
49
+ if (typeof a !== 'string') continue;
50
+ const m = SECRET_FLAG_RE.exec(a);
51
+ if (m) {
52
+ const flag = `--${m[1].toLowerCase()}`;
53
+ if (m[2] === '=' || i + 1 < args.length) {
54
+ return `${name} carries secret flag ${flag} in its args; ${HINT}`;
55
+ }
56
+ }
57
+ if (USERINFO_RE.test(a)) {
58
+ return `${name} carries URL userinfo in its args; ${HINT}`;
59
+ }
60
+ }
61
+ return null;
62
+ }
63
+
64
+ function urlReason(name, url) {
65
+ if (typeof url !== 'string') return null;
66
+ if (USERINFO_RE.test(url)) return `${name} carries URL userinfo in its url; ${HINT}`;
67
+ let parsed;
68
+ try {
69
+ parsed = new URL(url);
70
+ } catch {
71
+ return null;
72
+ }
73
+ if (parsed.username || parsed.password) return `${name} carries URL userinfo in its url; ${HINT}`;
74
+ for (const key of parsed.searchParams.keys()) {
75
+ if (QUERY_KEY_RE.test(key)) return `${name} carries credential query key ${key} in its url; ${HINT}`;
76
+ }
77
+ return null;
78
+ }
79
+
80
+ function credentialReason(name, entry) {
81
+ for (const field of ['env', 'headers']) {
82
+ const obj = entry[field];
83
+ if (!isPlain(obj)) continue;
84
+ for (const key of Object.keys(obj)) {
85
+ if (secretKey(key)) {
86
+ return `${name} carries credential key ${key} in its ${field}; ${HINT}`;
87
+ }
88
+ if (typeof obj[key] === 'string' && USERINFO_RE.test(obj[key])) {
89
+ return `${name} carries URL userinfo in ${field} value ${key}; ${HINT}`;
90
+ }
91
+ }
92
+ }
93
+ return argsReason(name, entry.args) || urlReason(name, entry.url);
94
+ }
95
+
96
+ /**
97
+ * @param {{ cwd?: string, projectRoot?: string, home?: string }} [opts]
98
+ * @returns {{ known: Record<string, object>, credentialed: Record<string, string> }}
99
+ */
100
+ function resolveHeadlessMcpServers({ cwd, projectRoot, home = os.homedir() } = {}) {
101
+ /** @type {Record<string, any>} */
102
+ const merged = {};
103
+ try {
104
+ const absCwd = typeof cwd === 'string' && path.isAbsolute(cwd);
105
+ const userCfg = readJson(path.join(home, '.claude.json'));
106
+ Object.assign(merged, serversOf(userCfg && userCfg.mcpServers));
107
+ if (absCwd) {
108
+ const proj = readJson(path.join(cwd, '.mcp.json'));
109
+ Object.assign(merged, serversOf(proj && proj.mcpServers));
110
+ const projects = userCfg && userCfg.projects;
111
+ const scopes = [];
112
+ if (typeof projectRoot === 'string' && path.isAbsolute(projectRoot) && projectRoot !== cwd) scopes.push(projectRoot);
113
+ scopes.push(cwd);
114
+ for (const key of scopes) {
115
+ if (isPlain(projects) && has(projects, key) && isPlain(projects[key])) {
116
+ Object.assign(merged, serversOf(projects[key].mcpServers));
117
+ }
118
+ }
119
+ }
120
+ } catch {
121
+ /* contribute nothing */
122
+ }
123
+
124
+ /** @type {Record<string, object>} */
125
+ const known = {};
126
+ /** @type {Record<string, string>} */
127
+ const credentialed = {};
128
+ for (const name of Object.keys(merged)) {
129
+ const reason = credentialReason(name, merged[name]);
130
+ if (reason) credentialed[name] = reason;
131
+ else known[name] = merged[name];
132
+ }
133
+ known[seed.SERVER_NAME] = seed.schedulerServerEntry();
134
+ delete credentialed[seed.SERVER_NAME];
135
+ return { known, credentialed };
136
+ }
137
+
138
+ module.exports = { resolveHeadlessMcpServers };
@@ -383,7 +383,8 @@ function wouldBlockRecord({ slug, persona, environment, what, detail, mode }) {
383
383
  /**
384
384
  * Env vars a job's child process needs for its sandbox level. An os-sandbox
385
385
  * job gets TMPDIR/TMP/TEMP pointed at its private temp dir (the only tmp
386
- * write root its settings declare); tool-rules jobs get no env change.
386
+ * write root its settings declare) and, with an allowlist network,
387
+ * NODE_USE_ENV_PROXY=1; tool-rules jobs get no env change.
387
388
  *
388
389
  * @param {{ level?: string }|null|undefined} policy
389
390
  * @param {string} tmpDir
@@ -391,7 +392,12 @@ function wouldBlockRecord({ slug, persona, environment, what, detail, mode }) {
391
392
  */
392
393
  function sandboxChildEnv(policy, tmpDir) {
393
394
  if (!policy || policy.level !== 'os-sandbox') return {};
394
- return { TMPDIR: tmpDir, TMP: tmpDir, TEMP: tmpDir };
395
+ const env = { TMPDIR: tmpDir, TMP: tmpDir, TEMP: tmpDir };
396
+ // Node's https ignores HTTPS_PROXY unless asked; inside the sandbox the proxy
397
+ // is the only route to an allow-listed host.
398
+ const hosts = policy.summary && policy.summary.network;
399
+ if (Array.isArray(hosts) && hosts.length > 0) env.NODE_USE_ENV_PROXY = '1';
400
+ return env;
395
401
  }
396
402
 
397
403
  module.exports = {
@@ -31,23 +31,29 @@ const HEADLESS_SCOPE_AGENT_NAME = 'sm-headless-scoped';
31
31
 
32
32
  /**
33
33
  * @param {readonly string[]|null|undefined} tools persona `tools:` list
34
- * @param {{ disallowed?: readonly string[], structuredOutput?: boolean }} [opts]
34
+ * @param {{ loadout?: 'undecided'|'bare'|'equipped'|'unbound', disallowed?: readonly string[], structuredOutput?: boolean }} [opts]
35
35
  * structuredOutput: also grant the CLI's StructuredOutput tool (a --json-schema
36
36
  * run). Probe 2026-11-22 (CLI 2.1.325): a scoped run without it ends
37
37
  * 'success' with structured_output null — the schema is silently skipped.
38
38
  * @returns {{ tools: string[] }|null} null = persona declares no restriction
39
39
  */
40
- function buildPersonaToolScope(tools, { disallowed = [], structuredOutput = false } = {}) {
41
- if (!Array.isArray(tools) || tools.length === 0) return null;
42
- const names = tools
40
+ function buildPersonaToolScope(tools, { loadout, disallowed = [], structuredOutput = false } = {}) {
41
+ // `loadout` (personaLoadout.cjs) wins when given: Bare = floor only even for
42
+ // an empty list; Unbound/Undecided = unscoped.
43
+ if (loadout === 'unbound' || loadout === 'undecided') return null;
44
+ const bare = loadout === 'bare';
45
+ const list = Array.isArray(tools) ? tools : [];
46
+ if (!bare && list.length === 0) return null;
47
+ const names = list
43
48
  .filter((t) => typeof t === 'string')
44
49
  .map((t) => t.trim())
45
50
  .filter(Boolean);
46
- if (names.length === 0 || names.includes('*')) return null;
51
+ if (names.includes('*')) return null;
52
+ if (!bare && names.length === 0) return null;
47
53
  const blocked = new Set(disallowed);
48
54
  const out = [];
49
55
  const extra = structuredOutput === true ? ['StructuredOutput'] : [];
50
- for (const name of [...names, ...HEADLESS_TOOL_FLOOR, ...extra]) {
56
+ for (const name of [...(bare ? [] : names), ...HEADLESS_TOOL_FLOOR, ...extra]) {
51
57
  if (blocked.has(name) || out.includes(name)) continue;
52
58
  out.push(name);
53
59
  }
@@ -83,14 +89,6 @@ const hasOwn = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
83
89
  function personaToolScopeArgs(scope, { mcpServers, declaredServers = [], packs = [], knownPacks = [] } = {}) {
84
90
  /** @type {string[]} */
85
91
  const args = [];
86
- if (scope) {
87
- const def = {
88
- description: 'Headless run with a scheduler-enforced tool scope.',
89
- prompt: 'Tool scope is enforced by the scheduler.',
90
- tools: scope.tools,
91
- };
92
- args.push('--agents', JSON.stringify({ [HEADLESS_SCOPE_AGENT_NAME]: def }), '--agent', HEADLESS_SCOPE_AGENT_NAME);
93
- }
94
92
  /** @type {null|{ code: 'capability_unknown', name: string }} */
95
93
  let refusal = null;
96
94
  const refuse = (name) => { if (!refusal) refusal = { code: 'capability_unknown', name }; };
@@ -117,6 +115,25 @@ function personaToolScopeArgs(scope, { mcpServers, declaredServers = [], packs =
117
115
  for (const p of Array.isArray(packs) ? packs : []) {
118
116
  if (!knownPackSet.has(String(p))) refuse(String(p));
119
117
  }
118
+ if (scope) {
119
+ // The --agents tools array scopes MCP tools too (probe 2026-11-27, CLI
120
+ // 2.1.330): a loaded server whose tools the array never names is invisible,
121
+ // even to ToolSearch. A server the persona DECLARES (mcpServers:) and names
122
+ // no single tool of is granted whole via the server-level `mcp__<server>`.
123
+ const tools = [...scope.tools];
124
+ for (const d of Array.isArray(declaredServers) ? declaredServers : []) {
125
+ const n = String(d).trim();
126
+ if (!n || !hasOwn(picked, n) || mcpTools.some((t) => mcpServerOf(t) === n)) continue;
127
+ const whole = `mcp__${n}`;
128
+ if (!tools.includes(whole)) tools.push(whole);
129
+ }
130
+ const def = {
131
+ description: 'Headless run with a scheduler-enforced tool scope.',
132
+ prompt: 'Tool scope is enforced by the scheduler.',
133
+ tools,
134
+ };
135
+ args.push('--agents', JSON.stringify({ [HEADLESS_SCOPE_AGENT_NAME]: def }), '--agent', HEADLESS_SCOPE_AGENT_NAME);
136
+ }
120
137
  // --mcp-config is variadic: it is followed immediately by --strict-mcp-config.
121
138
  // With no server, no --mcp-config at all — strict mode alone boots none.
122
139
  if (Object.keys(picked).length) args.push('--mcp-config', JSON.stringify({ mcpServers: picked }));
@@ -158,12 +175,81 @@ function personaToolScopeEnv(scope) {
158
175
  return { [JOB_MCP_TOOLS_ENV]: JSON.stringify(mcp) };
159
176
  }
160
177
 
178
+ /**
179
+ * The `--disallowedTools=Skill(<name>)` argv that refuses every installed
180
+ * skill a persona's equipped packs do not carry. Skills ride only inside packs.
181
+ * Verified on CLI 2.1.330: a denied Skill call fails with 'Skill execution
182
+ * blocked by permission rules'. Always the --flag=value form (only the first
183
+ * value after a variadic flag is literal). Pure: the caller passes the catalog.
184
+ *
185
+ * Unbound/undecided loadouts deny nothing; Bare ignores equipped packs. CLI-bundled
186
+ * skills follow the built-in tool decision and are never denied; `alwaysAllowed`
187
+ * (finish protocol: code-review, security-review) never are either.
188
+ *
189
+ * @param {{ installedSkills?: readonly string[], equippedPacks?: readonly string[],
190
+ * packCatalog?: readonly { id: string, skills?: readonly string[] }[],
191
+ * bundledSkills?: readonly string[], loadout?: string,
192
+ * alwaysAllowed?: readonly string[] }} [opts]
193
+ * @returns {string[]}
194
+ */
195
+ function skillDenyArgs({
196
+ installedSkills = [], equippedPacks = [], packCatalog = [], bundledSkills = [],
197
+ loadout, alwaysAllowed = ['code-review', 'security-review'],
198
+ } = {}) {
199
+ if (loadout === 'unbound' || loadout === 'undecided') return [];
200
+ const allowed = new Set([...bundledSkills, ...alwaysAllowed].map(String));
201
+ if (loadout !== 'bare') {
202
+ const equipped = new Set(equippedPacks.map(String));
203
+ for (const pack of packCatalog) {
204
+ if (!pack || !equipped.has(String(pack.id))) continue;
205
+ for (const s of pack.skills || []) allowed.add(String(s));
206
+ }
207
+ }
208
+ const out = [];
209
+ for (const raw of installedSkills) {
210
+ const name = String(raw).trim();
211
+ if (!name || allowed.has(name) || out.includes(`--disallowedTools=Skill(${name})`)) continue;
212
+ out.push(`--disallowedTools=Skill(${name})`);
213
+ }
214
+ return out;
215
+ }
216
+
217
+ /**
218
+ * The skill-deny argv for one unattended spawn (job or Task): the real catalogs
219
+ * (packs, loose skills, CLI-bundled skills) fed to skillDenyArgs. Never throws;
220
+ * a catalog failure denies nothing (same as an unbound loadout).
221
+ * @param {{ packs?: readonly string[], loadout?: string|null, deps?: Record<string, any> }} [o]
222
+ * @returns {Promise<{ args: string[], denied: number }>}
223
+ */
224
+ async function resolveSkillDeny({ packs = [], loadout, deps } = {}) {
225
+ const d = deps || {};
226
+ try {
227
+ if (!loadout) return { args: [], denied: 0 };
228
+ const catalog = require('../packs/packCatalog.cjs');
229
+ const packCatalog = (d.listPacks || catalog.listPacks)().packs || [];
230
+ const unpacked = [...(d.listUnpackedSkills || catalog.listUnpackedSkills)()];
231
+ const builtin = await (d.getBuiltinTools || require('./builtinTools.cjs').getBuiltinTools)();
232
+ const bundledSkills = (builtin && builtin.skills) || [];
233
+ const installedSkills = [...new Set([...packCatalog.flatMap((p) => p.skills || []), ...unpacked])];
234
+ const args = skillDenyArgs({ installedSkills, equippedPacks: packs, packCatalog, bundledSkills, loadout });
235
+ return { args, denied: args.length };
236
+ } catch {
237
+ return { args: [], denied: 0 };
238
+ }
239
+ }
240
+
241
+ /** Session Manager's own MCP harness, added to every scoped chat's declared servers (scheduler required, bilko-host optional). */
242
+ const CHAT_HARNESS_MCP_SERVERS = Object.freeze(['session-manager-scheduler', 'bilko-host']);
243
+
161
244
  module.exports = {
245
+ CHAT_HARNESS_MCP_SERVERS,
246
+ resolveSkillDeny,
162
247
  JOB_MCP_TOOLS_ENV,
163
248
  personaToolScopeEnv,
164
249
  HEADLESS_TOOL_FLOOR,
165
250
  HEADLESS_SCOPE_AGENT_NAME,
166
251
  buildPersonaToolScope,
252
+ skillDenyArgs,
167
253
  personaToolScopeArgs,
168
254
  resolvedMcpServerNames,
169
255
  };
@@ -263,25 +263,32 @@ function supervise(args) {
263
263
  // Not detached: the step and anything it spawns stay in this process group.
264
264
  const step = spawn(process.execPath, argv, { stdio: ['ignore', 'inherit', 'inherit'], cwd: process.cwd() });
265
265
  const every = Math.min(LEASE_CHECK_MAX_MS, Math.max(1, Math.floor(leaseMs / 4)));
266
- const timer = setInterval(() => {
267
- let age = Infinity;
268
- try { age = Date.now() - fs.statSync(leasePath(stateDir)).mtimeMs; } catch { /* missing lease = no caller */ }
269
- if (age <= leaseMs) return;
270
- clearInterval(timer);
271
- try {
272
- writeResult(stateDir, key, { ok: false, error: `abandoned: no caller for ${Math.round(leaseMs / 60000)} min` });
273
- } catch { /* stateDir gone */ }
274
- process.stderr.write(`resumableRun supervisor: lease expired, stopping group ${process.pid}\n`);
275
- killTree(process.pid);
276
- process.exit(1);
277
- }, every);
266
+ let timer = null;
267
+ const startLeaseClock = () => {
268
+ // The lease clock starts when the step process actually exists, not when
269
+ // startOrAttach ran: a loaded machine can delay this supervisor past leaseMs.
270
+ refreshLease(stateDir);
271
+ timer = setInterval(() => {
272
+ let age = Infinity;
273
+ try { age = Date.now() - fs.statSync(leasePath(stateDir)).mtimeMs; } catch { /* missing lease = no caller */ }
274
+ if (age <= leaseMs) return;
275
+ clearInterval(timer);
276
+ try {
277
+ writeResult(stateDir, key, { ok: false, error: `abandoned: no caller for ${Math.round(leaseMs / 60000)} min` });
278
+ } catch { /* stateDir gone */ }
279
+ process.stderr.write(`resumableRun supervisor: lease expired, stopping group ${process.pid}\n`);
280
+ killTree(process.pid);
281
+ process.exit(1);
282
+ }, every);
283
+ };
284
+ step.on('spawn', startLeaseClock);
278
285
  step.on('error', (err) => {
279
286
  process.stderr.write(`resumableRun supervisor: step failed to start: ${err.message}\n`);
280
- clearInterval(timer);
287
+ if (timer) clearInterval(timer);
281
288
  process.exit(1);
282
289
  });
283
290
  step.on('exit', (code, signal) => {
284
- clearInterval(timer);
291
+ if (timer) clearInterval(timer);
285
292
  // The step wrote its result before exiting; stop whatever it left in this
286
293
  // group (e.g. a voice wrapper's grandchildren). The waiter is not in it.
287
294
  const exitCode = code ?? (signal ? 1 : 0);
@@ -19,9 +19,9 @@ const path = require('node:path');
19
19
  const { schedulerHome } = require('../scheduler/schedulerPaths.cjs');
20
20
  const { writeTextAtomic } = require('../util/atomicFs.cjs');
21
21
 
22
- const KIT_VERSION = '45';
22
+ const KIT_VERSION = '46';
23
23
  // sha256 of kitDigest(__dirname). Update together with a KIT_VERSION bump.
24
- const KIT_DIGEST = 'd1735e9ad8044d68d81ba52fd4d95f5b80f763f2811a8674211d25ef5d49f482';
24
+ const KIT_DIGEST = '95029c2c1d26c80570102c6138ab3473536a56ddff5830802ca678e2b0fcd98d';
25
25
  const KIT_FILES = Object.freeze(['checks.cjs', 'sound.cjs', 'capture.cjs', 'frames.cjs', 'character.cjs', 'playwrightLoader.cjs', 'export.cjs', 'kind-tiktok.md', 'kind-marketing.md', 'cast.md', 'project-home-html.md', 'resumableRun.cjs', 'voiceLibrary.cjs', 'voiceLane.cjs', 'kokoroSay.cjs', 'projectSounds.cjs', 'standalone.cjs']);
26
26
  const STAMP_FILE = 'KIT_VERSION';
27
27
 
@@ -0,0 +1,66 @@
1
+ /**
2
+ * epicDepsSync.cjs — refresh an Epic worktree's per-entry node_modules links each
3
+ * time its CLI is spawned there (Chat: chatRunner executeRun; Terminal: pty spawn).
4
+ *
5
+ * Why: syncNodeModulesLinks otherwise runs only when createWorktree reuses the
6
+ * worktree (approve / reopen), so a long-lived Epic never sees a package added to
7
+ * the main checkout later. Both spawn paths are synchronous, so this is
8
+ * fire-and-forget: the sync runs on a later tick and its result is never awaited.
9
+ * Throttled to once per worktree per THROTTLE_MS so rapid turns don't rescan.
10
+ * Never throws; failures are logged.
11
+ */
12
+ 'use strict';
13
+
14
+ const worktreeDeps = require('../git/worktreeDeps.cjs');
15
+
16
+ const THROTTLE_MS = 30_000;
17
+
18
+ /** @type {Map<string, number>} worktreeCwd → last sync start (ms) */
19
+ const lastSyncAt = new Map();
20
+
21
+ function logFailure(worktreeCwd, err) {
22
+ try {
23
+ require('../../logs.cjs').writeLine({
24
+ scope: 'epicDepsSync',
25
+ level: 'warn',
26
+ message: `node_modules link sync failed for ${worktreeCwd}: ${err?.message || String(err)}`,
27
+ meta: { worktreeCwd },
28
+ });
29
+ } catch {
30
+ try { console.warn(`[epicDepsSync] sync failed for ${worktreeCwd}:`, err?.message || err); } catch { /* never throw */ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Fire-and-forget refresh of a worktree's node_modules links from the project checkout.
36
+ * @param {{ projectCwd: string, worktreeCwd: string, now?: number }} opts
37
+ * @returns {boolean} true when a sync was scheduled
38
+ */
39
+ function syncEpicWorktreeDeps({ projectCwd, worktreeCwd, now } = /** @type {any} */ ({})) {
40
+ try {
41
+ if (process.env.SM_WORKTREE_DEP_LINK_DISABLE === '1') return false;
42
+ if (!projectCwd || !worktreeCwd || worktreeCwd === projectCwd) return false;
43
+ const t = typeof now === 'number' ? now : Date.now();
44
+ const prev = lastSyncAt.get(worktreeCwd);
45
+ if (prev !== undefined && t - prev < THROTTLE_MS) return false;
46
+ lastSyncAt.set(worktreeCwd, t);
47
+ setImmediate(() => {
48
+ let p;
49
+ try {
50
+ p = worktreeDeps.syncNodeModulesLinks({ mainCwd: projectCwd, worktreeCwd });
51
+ } catch (e) {
52
+ logFailure(worktreeCwd, e);
53
+ return;
54
+ }
55
+ Promise.resolve(p).catch((e) => logFailure(worktreeCwd, e));
56
+ });
57
+ return true;
58
+ } catch (e) {
59
+ logFailure(worktreeCwd, e);
60
+ return false;
61
+ }
62
+ }
63
+
64
+ function __resetForTests() { lastSyncAt.clear(); }
65
+
66
+ module.exports = { syncEpicWorktreeDeps, THROTTLE_MS, __resetForTests };