claude-code-session-manager 0.142.0 → 0.144.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/README.md +22 -107
- package/dist/assets/AppSettings-Z68gQiVE.js +2 -0
- package/dist/assets/{History-DpZuJXi1.js → History-C3E6y_7t.js} +2 -2
- package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +5 -0
- package/dist/assets/{Panel-BjdJjhqt.js → Panel-CnfWs46Z.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-CP0Wsg-H.js +26 -0
- package/dist/assets/Scheduler-D8un7N3B.js +16 -0
- package/dist/assets/{SkillReferenceGraph-Cqyu4mef.js → SkillReferenceGraph-DRtZV1Al.js} +1 -1
- package/dist/assets/{Skills-vv0noNVI.js → Skills-Bg5O2Hyn.js} +23 -23
- package/dist/assets/{TiptapBody-CXi8Pvut.js → TiptapBody-BdzoBmqu.js} +27 -27
- package/dist/assets/{Toggle-CiYCWLjh.js → Toggle-Dt5K1OXt.js} +1 -1
- package/dist/assets/{VoiceButton-4NKKd1sC.js → VoiceButton-CTLyRgdF.js} +1 -1
- package/dist/assets/{historyTotals-DDunb8Ch.js → historyTotals-B2_KWBga.js} +1 -1
- package/dist/assets/{index-Cn5E9958.js → index-446b69rr.js} +715 -714
- package/dist/assets/{index-DVHIHoJf.css → index-BJ5TJvmz.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +438 -435
- package/package.json +6 -4
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/builder/SKILL.md +5 -0
- package/plugins/session-manager-dev/skills/develop/SKILL.md +23 -16
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +16 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +87 -0
- package/scripts/README.md +1 -0
- package/scripts/scheduler-mcp-server.cjs +381 -6
- package/src/main/adminRouteRegistry.cjs +16 -0
- package/src/main/agentLibrary.cjs +60 -11
- package/src/main/agentsIpc.cjs +19 -0
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +214 -7
- package/src/main/config.cjs +5 -1
- package/src/main/health.cjs +92 -14
- package/src/main/index.cjs +16 -4
- package/src/main/ipcSchemas.cjs +61 -1
- package/src/main/lib/claude/agentArmory.cjs +128 -0
- package/src/main/lib/claude/agentModelResolve.cjs +3 -2
- package/src/main/lib/claude/agentSnapshot.cjs +24 -3
- package/src/main/lib/claude/builtinTools.cjs +110 -0
- package/src/main/lib/claude/environmentProfiles.cjs +1 -1
- package/src/main/lib/claude/headlessMcpServers.cjs +138 -0
- package/src/main/lib/claude/jobSandboxPolicy.cjs +8 -2
- package/src/main/lib/claude/personaToolScope.cjs +77 -6
- package/src/main/lib/demo-video-kit/cast.md +10 -1
- package/src/main/lib/demo-video-kit/character.cjs +77 -21
- package/src/main/lib/demo-video-kit/kind-tiktok.md +5 -1
- package/src/main/lib/demo-video-kit/projectSounds.cjs +191 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +3 -3
- package/src/main/lib/demo-video-kit/sound.cjs +166 -9
- package/src/main/lib/demo-video-kit/standalone.cjs +231 -0
- package/src/main/lib/epic/activeIndexMerge.cjs +5 -0
- package/src/main/lib/epic/artifactRetention.cjs +55 -9
- package/src/main/lib/epic/artifactStore.cjs +78 -35
- package/src/main/lib/epic/delegationReadiness.cjs +10 -3
- package/src/main/lib/epic/epicDepsSync.cjs +66 -0
- package/src/main/lib/epic/epicEventLog.cjs +45 -1
- package/src/main/lib/epic/epicOutsideRead.cjs +38 -1
- package/src/main/lib/epic/epicSettle.cjs +48 -4
- package/src/main/lib/epic/epicSpawnPlan.cjs +3 -1
- package/src/main/lib/epic/epicStateEmitter.cjs +248 -0
- package/src/main/lib/epic/epicValidationHook.cjs +22 -3
- package/src/main/lib/epic/planReviewInput.cjs +123 -0
- package/src/main/lib/epic/restorableSessions.cjs +1 -0
- package/src/main/lib/epic/scriptStartedBy.cjs +71 -0
- package/src/main/lib/externalContract.cjs +24 -1
- package/src/main/lib/feedback-remote/autoStartedSession.cjs +1 -1
- package/src/main/lib/feedback-remote/createdProjects.cjs +291 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +24 -2
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +96 -8
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +54 -3
- package/src/main/lib/feedback-remote/pendingReplies.cjs +22 -0
- package/src/main/lib/feedback-remote/projectCreate.cjs +415 -0
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +94 -4
- package/src/main/lib/feedback-remote/replyClaims.cjs +168 -0
- package/src/main/lib/feedback-remote/serviceMcpSession.cjs +29 -1
- package/src/main/lib/feedback-remote/serviceMcpTools.cjs +43 -2
- package/src/main/lib/feedback-remote/servicePairLocalRoutes.cjs +91 -0
- package/src/main/lib/feedback-remote/servicePairings.cjs +47 -7
- package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +99 -1
- package/src/main/lib/git/gitWorktree.cjs +8 -0
- package/src/main/lib/git/runtimeStateUntrack.cjs +15 -1
- package/src/main/lib/git/worktreeDeps.cjs +119 -10
- package/src/main/lib/mcpToolCatalog.cjs +144 -12
- package/src/main/lib/mcpToolsProbe.cjs +19 -2
- package/src/main/lib/opsOwnership.cjs +113 -28
- package/src/main/lib/packs/packCatalog.cjs +98 -5
- package/src/main/lib/persona-macro/agentPersonaSchema.cjs +6 -0
- package/src/main/lib/persona-macro/builtinMacros.cjs +6 -4
- package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +9 -0
- package/src/main/lib/persona-macro/personaLoadout.cjs +58 -0
- package/src/main/lib/persona-macro/personaMerge.cjs +11 -3
- package/src/main/lib/persona-macro/personaUpgrade.cjs +96 -0
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +1 -1
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +140 -0
- package/src/main/lib/prd/prdCreate.cjs +395 -229
- package/src/main/lib/prd/prdCriteria.cjs +7 -4
- package/src/main/lib/prd/prdFrontmatter.cjs +5 -2
- package/src/main/lib/prd/prdMcpReachWarnings.cjs +44 -0
- package/src/main/lib/prd/prdSandboxWarnings.cjs +49 -0
- package/src/main/lib/process/peerChatSession.cjs +165 -0
- package/src/main/lib/project-pages/videoPressLines.cjs +145 -0
- package/src/main/lib/project-pages/videoScriptPress.cjs +266 -0
- package/src/main/lib/project-pages/videoScriptRunRoute.cjs +371 -0
- package/src/main/lib/project-pages/videoScriptSwitchIpc.cjs +49 -0
- package/src/main/lib/project-pages/videoScriptSwitchRoute.cjs +173 -0
- package/src/main/lib/promptSessionSchema.cjs +2 -0
- package/src/main/lib/scheduler/baselineGate.cjs +31 -2
- package/src/main/lib/scheduler/criteriaChecks.cjs +164 -20
- package/src/main/lib/scheduler/heldSchedulerTurns.cjs +238 -0
- package/src/main/lib/scheduler/jobMemoryStats.cjs +13 -2
- package/src/main/lib/scheduler/planRecordHarvest.cjs +215 -55
- package/src/main/lib/scheduler/planReleaseRoute.cjs +110 -0
- package/src/main/lib/scheduler/planReviewSchema.cjs +182 -0
- package/src/main/lib/scheduler/planReviewStats.cjs +63 -0
- package/src/main/lib/scheduler/planReviewStore.cjs +128 -0
- package/src/main/lib/scheduler/prdOutcomeRecord.cjs +60 -2
- package/src/main/lib/scheduler/queueStore.cjs +16 -0
- package/src/main/lib/scheduler/rcaReport.cjs +79 -15
- package/src/main/lib/scheduler/sandboxEnvironmentLimit.cjs +141 -0
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +15 -0
- package/src/main/lib/scheduler/schedulerPaths.cjs +9 -0
- package/src/main/lib/scheduler/slotsRoute.cjs +101 -87
- package/src/main/lib/scheduler/upgradeDrain.cjs +32 -5
- package/src/main/lib/scheduler/usageHoldRoute.cjs +97 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +28 -7
- package/src/main/lib/tasks/memoryConsolidation.cjs +123 -39
- package/src/main/lib/tasks/mitigationReview.cjs +21 -1
- package/src/main/lib/tasks/taskAdminRoutes.cjs +104 -17
- package/src/main/lib/tasks/taskLedger.cjs +2 -2
- package/src/main/lib/tasks/taskRun.cjs +3 -1
- package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +178 -0
- package/src/main/lib/telemetry/auditEvents.cjs +21 -24
- package/src/main/lib/telemetry/auditLog.cjs +6 -2
- package/src/main/lib/util/atomicFs.cjs +2 -2
- package/src/main/projectPages.cjs +22 -14
- package/src/main/promptSessionEvents.cjs +16 -1
- package/src/main/pty.cjs +14 -2
- package/src/main/queueOps.cjs +1 -1
- package/src/main/runVerify.cjs +4 -3
- package/src/main/scheduler/planReviewHold.cjs +140 -0
- package/src/main/scheduler/prdParser.cjs +1 -0
- package/src/main/scheduler/reviewLadder.cjs +2 -0
- package/src/main/scheduler/utilizationHold.cjs +101 -6
- package/src/main/scheduler.cjs +1055 -107
- package/src/main/seedAgentPersonas.cjs +11 -6
- package/src/main/seedStatus.cjs +1 -1
- package/src/main/templates/PRD_AUTHORING.md +22 -2
- package/src/main/webRemote.cjs +47 -7
- package/src/preload/api.d.ts +118 -2
- package/src/preload/apiSurface.json +42 -0
- package/src/preload/index.cjs +11 -0
- package/src/seed/agents/architect.md +28 -43
- package/src/seed/agents/demo-video-builder.md +15 -8
- package/src/seed/agents/dev-lead.md +3 -1
- package/src/seed/agents/md-network-curator.md +27 -0
- package/src/seed/agents/plan-reviewer.md +47 -0
- package/src/seed/agents/validator.md +21 -19
- package/dist/assets/AppSettings-BcZgIvvY.js +0 -2
- package/dist/assets/HomeClaudeConfig-D32ZJtU-.js +0 -3
- package/dist/assets/ProjectClaudeConfig-BTClYV6i.js +0 -26
- package/dist/assets/Scheduler-DPobKx1Z.js +0 -16
|
@@ -24,15 +24,21 @@ const os = require('node:os');
|
|
|
24
24
|
const { splitFrontmatter } = require('./lib/prd/prdFrontmatter.cjs');
|
|
25
25
|
const { resolveMergedPersona, PERSONA_NAME_RE } = require('./lib/persona-macro/personaMerge.cjs');
|
|
26
26
|
const { isNonClaudeAgentCli, isAgentCliModel } = require('./lib/agent-cli/agentCliEvents.cjs');
|
|
27
|
+
const { loadoutState, encodeLoadout } = require('./lib/persona-macro/personaLoadout.cjs');
|
|
28
|
+
const { mcpServersFromTools } = require('./lib/claude/agentSnapshot.cjs');
|
|
29
|
+
const { personaUpgradeFor, readDismissals } = require('./lib/persona-macro/personaUpgrade.cjs');
|
|
27
30
|
const configMgr = require('./config.cjs');
|
|
28
31
|
const sessionsStore = require('./sessionsStore.cjs');
|
|
29
32
|
|
|
30
33
|
/** Parses the frontmatter `tools` field ("Read, Grep, Glob, Bash") into a list. */
|
|
31
34
|
function parseTools(raw) {
|
|
32
35
|
if (!raw) return [];
|
|
33
|
-
return raw.split(',').map((t) => t.trim()).filter(
|
|
36
|
+
return raw.split(',').map((t) => t.trim()).filter((t) => t && t !== '[]');
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
/** Explicit-empty marker for a gear list: `mcpServers: []` / `packs: []` = replace with none. */
|
|
40
|
+
const EMPTY_LIST_ENCODING = '[]';
|
|
41
|
+
|
|
36
42
|
/**
|
|
37
43
|
* A declared-capability frontmatter value (`mcpServers:` / `packs:`) as a
|
|
38
44
|
* list: a comma string ("a, b") or a string list (structured callers).
|
|
@@ -46,7 +52,7 @@ function parseCapabilityList(raw) {
|
|
|
46
52
|
for (const it of items) {
|
|
47
53
|
if (typeof it !== 'string') continue;
|
|
48
54
|
const v = it.trim();
|
|
49
|
-
if (v && !out.includes(v)) out.push(v);
|
|
55
|
+
if (v && v !== EMPTY_LIST_ENCODING && !out.includes(v)) out.push(v);
|
|
50
56
|
}
|
|
51
57
|
return out;
|
|
52
58
|
}
|
|
@@ -125,10 +131,12 @@ function extractUnmanagedLines(raw, managed) {
|
|
|
125
131
|
return out;
|
|
126
132
|
}
|
|
127
133
|
|
|
128
|
-
function serializePersona({ name, description, tools, model, effort, color, tags, projects, action, actionLabel, title, seedVersion, executorOnly, agentCli, agentCliModel, mcpServers, packs, environment, body, preservedLines }) {
|
|
134
|
+
function serializePersona({ name, description, tools, loadout, model, effort, color, tags, projects, action, actionLabel, title, seedVersion, executorOnly, agentCli, agentCliModel, mcpServers, packs, environment, body, preservedLines }) {
|
|
129
135
|
const lines = ['---', `name: ${name}`];
|
|
130
136
|
if (description) lines.push(`description: ${description}`);
|
|
131
|
-
|
|
137
|
+
// `loadout` (bare/unbound/equipped/undecided) wins; absent, `tools` is the decision (['*'] = unbound).
|
|
138
|
+
const toolsValue = loadout ? encodeLoadout(loadout, tools) : (tools && tools.length ? tools.join(', ') : null);
|
|
139
|
+
if (toolsValue) lines.push(`tools: ${toolsValue}`);
|
|
132
140
|
if (model && model !== 'inherit') lines.push(`model: ${model}`);
|
|
133
141
|
if (effort && effort !== 'inherit') lines.push(`effort: ${effort}`);
|
|
134
142
|
if (isNonClaudeAgentCli(agentCli)) {
|
|
@@ -144,8 +152,8 @@ function serializePersona({ name, description, tools, model, effort, color, tags
|
|
|
144
152
|
if (title) lines.push(`title: ${title}`);
|
|
145
153
|
if (typeof seedVersion === 'number' && Number.isFinite(seedVersion)) lines.push(`seedVersion: ${seedVersion}`);
|
|
146
154
|
if (executorOnly === true) lines.push('executorOnly: true');
|
|
147
|
-
if (Array.isArray(mcpServers)
|
|
148
|
-
if (Array.isArray(packs)
|
|
155
|
+
if (Array.isArray(mcpServers)) lines.push(`mcpServers: ${mcpServers.length ? mcpServers.join(', ') : EMPTY_LIST_ENCODING}`);
|
|
156
|
+
if (Array.isArray(packs)) lines.push(`packs: ${packs.length ? packs.join(', ') : EMPTY_LIST_ENCODING}`);
|
|
149
157
|
if (typeof environment === 'string' && environment.trim()) lines.push(`environment: ${environment.trim()}`);
|
|
150
158
|
if (Array.isArray(preservedLines) && preservedLines.length) lines.push(...preservedLines);
|
|
151
159
|
lines.push('---', '');
|
|
@@ -179,10 +187,22 @@ async function findOpenProject(projectCwd, loadSessions) {
|
|
|
179
187
|
return project;
|
|
180
188
|
}
|
|
181
189
|
|
|
190
|
+
/** Frontmatter keys a project overlay may carry (everything else in an overlay is preserved verbatim). */
|
|
191
|
+
const OVERLAY_KEYS = new Set(['model', 'effort', 'tools', 'mcpServers', 'packs', 'environment']);
|
|
192
|
+
|
|
193
|
+
/** Throws when an overlay's managed lines fail the persona schema's per-key rules (a placeholder model stands in for the global one). */
|
|
194
|
+
function assertValidOverlayKeys(name, managedLines) {
|
|
195
|
+
const { validatePersonaFrontmatter } = require('./lib/persona-macro/personaFrontmatterSchema.cjs');
|
|
196
|
+
const fm = { ...splitFrontmatter(['---', ...managedLines, '---', ''].join('\n')).fm };
|
|
197
|
+
if (!('model' in fm) || fm.model === undefined) fm.model = 'sonnet';
|
|
198
|
+
const result = validatePersonaFrontmatter(fm);
|
|
199
|
+
if (!result.ok) throw new Error(`invalid project override for ${name}: ${result.errors.join('; ')}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
182
202
|
/**
|
|
183
203
|
* Project OVERRIDE write: a frontmatter-only overlay at
|
|
184
204
|
* `<projectCwd>/.claude/agents/<name>.md` carrying ONLY the overridden `model` /
|
|
185
|
-
* `effort` keys and no body (lib/persona-macro/personaMerge.cjs inherits everything else
|
|
205
|
+
* `effort` / `tools` / `mcpServers` / `packs` / `environment` keys and no body (lib/persona-macro/personaMerge.cjs inherits everything else
|
|
186
206
|
* from the global persona). `projectCwd` must be an OPEN project's cwd (see
|
|
187
207
|
* findOpenProject). Keys already in an existing frontmatter-only
|
|
188
208
|
* overlay are preserved; an existing overlay that has a BODY is refused so a
|
|
@@ -198,7 +218,7 @@ async function findOpenProject(projectCwd, loadSessions) {
|
|
|
198
218
|
* unknown or empty `projectCwd` throws in findOpenProject first, so nothing is
|
|
199
219
|
* registered for it.
|
|
200
220
|
*/
|
|
201
|
-
async function saveOverlay({ name, projectCwd, model, effort, loadSessions, validatePath, writeTextAtomic, addAllowedRoot }) {
|
|
221
|
+
async function saveOverlay({ name, projectCwd, model, effort, tools, loadout, mcpServers, packs, environment, loadSessions, validatePath, writeTextAtomic, addAllowedRoot }) {
|
|
202
222
|
const project = await findOpenProject(projectCwd, loadSessions);
|
|
203
223
|
// Dormant tab = no pty-registered root; see JSDoc + projectBrief.cjs allowBriefWrites.
|
|
204
224
|
addAllowedRoot(validatePath(project.cwd));
|
|
@@ -210,7 +230,7 @@ async function saveOverlay({ name, projectCwd, model, effort, loadSessions, vali
|
|
|
210
230
|
if (existing.body.trim() !== '') {
|
|
211
231
|
throw new Error(`${name} has a full-body override in ${project.name} — edit ${target} directly; it is not converted to a frontmatter-only override`);
|
|
212
232
|
}
|
|
213
|
-
preserved = extractUnmanagedLines(rawExisting,
|
|
233
|
+
preserved = extractUnmanagedLines(rawExisting, OVERLAY_KEYS);
|
|
214
234
|
} catch (e) {
|
|
215
235
|
if (e.code !== 'ENOENT') throw e;
|
|
216
236
|
}
|
|
@@ -218,6 +238,15 @@ async function saveOverlay({ name, projectCwd, model, effort, loadSessions, vali
|
|
|
218
238
|
for (const [k, v] of [['model', model], ['effort', effort]]) {
|
|
219
239
|
if (v && v !== 'inherit') managedLines.push(`${k}: ${v}`);
|
|
220
240
|
}
|
|
241
|
+
// Gear keys REPLACE the global value for this project (personaMerge.cjs). Unset = no line = inherit.
|
|
242
|
+
// `tools: []` alone is the override call's dummy value, so Bare/Unbound need an explicit `loadout`.
|
|
243
|
+
const toolsValue = loadout ? encodeLoadout(loadout, tools) : (Array.isArray(tools) && tools.length ? encodeLoadout('equipped', tools) : null);
|
|
244
|
+
if (toolsValue) managedLines.push(`tools: ${toolsValue}`);
|
|
245
|
+
// An explicit [] is written as `[]` = replace the global value with none (personaMerge); undefined = inherit.
|
|
246
|
+
if (Array.isArray(mcpServers)) managedLines.push(`mcpServers: ${mcpServers.length ? mcpServers.join(', ') : EMPTY_LIST_ENCODING}`);
|
|
247
|
+
if (Array.isArray(packs)) managedLines.push(`packs: ${packs.length ? packs.join(', ') : EMPTY_LIST_ENCODING}`);
|
|
248
|
+
if (typeof environment === 'string' && environment.trim()) managedLines.push(`environment: ${environment.trim()}`);
|
|
249
|
+
if (managedLines.length) assertValidOverlayKeys(name, managedLines);
|
|
221
250
|
if (managedLines.length === 0 && preserved.length === 0) {
|
|
222
251
|
await removeOverride({ name, projectCwd: project.cwd, loadSessions, validatePath });
|
|
223
252
|
return { ok: true, path: target, removed: true };
|
|
@@ -283,6 +312,7 @@ async function savePersona({
|
|
|
283
312
|
mcpServers,
|
|
284
313
|
packs,
|
|
285
314
|
environment,
|
|
315
|
+
loadout,
|
|
286
316
|
body,
|
|
287
317
|
projectCwd,
|
|
288
318
|
globalDir = path.join(os.homedir(), '.claude', 'agents'),
|
|
@@ -295,7 +325,7 @@ async function savePersona({
|
|
|
295
325
|
throw new Error('agent name must be lowercase, hyphenated (e.g. "my-agent")');
|
|
296
326
|
}
|
|
297
327
|
if (projectCwd !== undefined) {
|
|
298
|
-
return saveOverlay({ name, projectCwd, model, effort, loadSessions, validatePath, writeTextAtomic, addAllowedRoot });
|
|
328
|
+
return saveOverlay({ name, projectCwd, model, effort, tools, loadout, mcpServers, packs, environment, loadSessions, validatePath, writeTextAtomic, addAllowedRoot });
|
|
299
329
|
}
|
|
300
330
|
const target = validatePath(path.join(globalDir, `${name}.md`));
|
|
301
331
|
// A caller that omits seedVersion/title/projects/action/actionLabel (the
|
|
@@ -341,7 +371,13 @@ async function savePersona({
|
|
|
341
371
|
if (resolvedEnvironment === undefined && typeof fm.environment === 'string' && fm.environment.trim()) resolvedEnvironment = fm.environment.trim();
|
|
342
372
|
} catch { /* no existing file (or unreadable) — nothing to carry over */ }
|
|
343
373
|
}
|
|
344
|
-
|
|
374
|
+
// One write: mcpServers = caller's/carried servers ∪ servers named by mcp__<server>__<tool> tools
|
|
375
|
+
// (a server with no tool of its own is a whole-server grant and is kept).
|
|
376
|
+
const derivedServers = mcpServersFromTools(tools);
|
|
377
|
+
if (derivedServers.length) {
|
|
378
|
+
resolvedMcpServers = [...new Set([...(Array.isArray(resolvedMcpServers) ? resolvedMcpServers : []), ...derivedServers])];
|
|
379
|
+
}
|
|
380
|
+
const text = serializePersona({ name, description, tools, loadout, model, effort, color, tags, projects: resolvedProjects, action: resolvedAction, actionLabel: resolvedActionLabel, title: resolvedTitle, seedVersion: resolvedSeedVersion, executorOnly: resolvedExecutorOnly, agentCli: resolvedAgentCli, agentCliModel: resolvedAgentCliModel, mcpServers: resolvedMcpServers, packs: resolvedPacks, environment: resolvedEnvironment, body, preservedLines });
|
|
345
381
|
assertValidPersonaText(name, text, preservedLines);
|
|
346
382
|
await writeTextAtomic(target, text);
|
|
347
383
|
if (originalName && originalName !== name) {
|
|
@@ -432,6 +468,7 @@ async function listPersonas({
|
|
|
432
468
|
globalDir = path.join(os.homedir(), '.claude', 'agents'),
|
|
433
469
|
loadSessions = sessionsStore.load,
|
|
434
470
|
validatePath = configMgr.validatePath,
|
|
471
|
+
upgradeDeps,
|
|
435
472
|
} = {}) {
|
|
436
473
|
let files;
|
|
437
474
|
try {
|
|
@@ -443,6 +480,7 @@ async function listPersonas({
|
|
|
443
480
|
|
|
444
481
|
const projects = await openProjects({ loadSessions });
|
|
445
482
|
const personas = [];
|
|
483
|
+
const dismissals = upgradeDeps?.dismissals ?? readDismissals();
|
|
446
484
|
|
|
447
485
|
for (const file of files.sort()) {
|
|
448
486
|
const fallbackName = file.replace(/\.md$/, '');
|
|
@@ -488,10 +526,20 @@ async function listPersonas({
|
|
|
488
526
|
|
|
489
527
|
const trimmedCli = typeof fm.agentCli === 'string' ? fm.agentCli.trim() : '';
|
|
490
528
|
const listedCli = isNonClaudeAgentCli(trimmedCli) ? trimmedCli : null;
|
|
529
|
+
let upgrade = null;
|
|
530
|
+
try {
|
|
531
|
+
upgrade = personaUpgradeFor(fallbackName, text, { ...upgradeDeps, dismissals }) ?? null;
|
|
532
|
+
} catch {
|
|
533
|
+
upgrade = null;
|
|
534
|
+
}
|
|
491
535
|
personas.push({
|
|
492
536
|
name: fm.name || fallbackName,
|
|
493
537
|
description: fm.description || null,
|
|
494
538
|
tools: parseTools(fm.tools),
|
|
539
|
+
loadout: loadoutState(fm),
|
|
540
|
+
mcpServers: parseCapabilityList(fm.mcpServers),
|
|
541
|
+
packs: parseCapabilityList(fm.packs),
|
|
542
|
+
environment: typeof fm.environment === 'string' && fm.environment.trim() ? fm.environment.trim() : null,
|
|
495
543
|
model: fm.model || null,
|
|
496
544
|
effort: fm.effort || null,
|
|
497
545
|
color: fm.color || null,
|
|
@@ -508,6 +556,7 @@ async function listPersonas({
|
|
|
508
556
|
body: body.trim(),
|
|
509
557
|
overridingProjects,
|
|
510
558
|
overrideDetails,
|
|
559
|
+
upgrade,
|
|
511
560
|
});
|
|
512
561
|
}
|
|
513
562
|
|
package/src/main/agentsIpc.cjs
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
const { schemas, validated } = require('./ipcSchemas.cjs');
|
|
10
10
|
const agentLibrary = require('./agentLibrary.cjs');
|
|
11
|
+
const personaUpgrade = require('./lib/persona-macro/personaUpgrade.cjs');
|
|
11
12
|
const agentModelResolve = require('./lib/claude/agentModelResolve.cjs');
|
|
12
13
|
const agentEffortResolve = require('./lib/claude/agentEffortResolve.cjs');
|
|
13
14
|
const { resolveEffectiveModelInfo } = require('./lib/claude/effectiveModelInfo.cjs');
|
|
@@ -51,6 +52,16 @@ function registerAgentsHandlers({ ipcMain, getWindow }) {
|
|
|
51
52
|
broadcastAgentsChanged();
|
|
52
53
|
return result;
|
|
53
54
|
}));
|
|
55
|
+
ipcMain.handle('agents:take-bundled-persona', validated(schemas.agentsTakeBundledPersona, async ({ name }) => {
|
|
56
|
+
const result = await personaUpgrade.takeBundledPersona(name);
|
|
57
|
+
broadcastAgentsChanged();
|
|
58
|
+
return result;
|
|
59
|
+
}));
|
|
60
|
+
ipcMain.handle('agents:dismiss-persona-upgrade', validated(schemas.agentsDismissPersonaUpgrade, async ({ name, bundledVersion }) => {
|
|
61
|
+
const result = await personaUpgrade.dismissPersonaUpgrade(name, bundledVersion);
|
|
62
|
+
broadcastAgentsChanged();
|
|
63
|
+
return result;
|
|
64
|
+
}));
|
|
54
65
|
// New Epic AIM composer (epicIntake.ts's `agentBody`/`agentPath`): unlike
|
|
55
66
|
// list-personas above (global dir only), this honors the project-overlay-
|
|
56
67
|
// then-global precedence so an Epic's opening prompt carries the persona
|
|
@@ -77,6 +88,14 @@ function registerAgentsHandlers({ ipcMain, getWindow }) {
|
|
|
77
88
|
// (cwd, agentType). Read-only observer; never affects what a launch resolves.
|
|
78
89
|
ipcMain.handle('agents:resolve-model-info', validated(schemas.agentsResolveModelInfo, (payload) =>
|
|
79
90
|
resolveEffectiveModelInfo(payload)));
|
|
91
|
+
|
|
92
|
+
// Gear armory read model (agentArmory.cjs) for the character sheet. Read-only;
|
|
93
|
+
// bannedTools is the scheduler's headless disallow list (lazy-required: scheduler.cjs is heavy).
|
|
94
|
+
ipcMain.handle('agents:armory', validated(schemas.agentsArmory, (payload) =>
|
|
95
|
+
require('./lib/claude/agentArmory.cjs').buildArmory({
|
|
96
|
+
cwd: payload.cwd,
|
|
97
|
+
deps: { bannedTools: [...require('./scheduler.cjs').HEADLESS_DISALLOWED_TOOLS] },
|
|
98
|
+
})));
|
|
80
99
|
}
|
|
81
100
|
|
|
82
101
|
module.exports = { registerAgentsHandlers };
|
package/src/main/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"gitSha": "
|
|
4
|
-
"gitShortSha": "
|
|
2
|
+
"version": "0.144.0",
|
|
3
|
+
"gitSha": "4760ce98481d63f0e842bcdfb9277d6eabb45c60",
|
|
4
|
+
"gitShortSha": "4760ce98",
|
|
5
5
|
"gitBranch": "HEAD",
|
|
6
|
-
"builtAt": "2026-11-
|
|
6
|
+
"builtAt": "2026-11-27T02:32:59.091Z",
|
|
7
7
|
"dirty": false
|
|
8
8
|
}
|
package/src/main/chatRunner.cjs
CHANGED
|
@@ -56,7 +56,9 @@ const { developLoopOffSettingsArgs } = require('./lib/epic/developLoopSpawn.cjs'
|
|
|
56
56
|
const packSpawnArgs = require('./lib/packs/packSpawnArgs.cjs');
|
|
57
57
|
const { resolveEpicEffort, effortArgs } = require('./lib/claude/agentEffortResolve.cjs');
|
|
58
58
|
const { planEpicSpawn, resolveEpicTurnModel } = require('./lib/epic/epicSpawnPlan.cjs');
|
|
59
|
+
const { buildPersonaToolScope, personaToolScopeArgs, skillDenyArgs } = require('./lib/claude/personaToolScope.cjs');
|
|
59
60
|
const epicWorktreeMint = require('./lib/epic/epicWorktreeMint.cjs');
|
|
61
|
+
const epicDepsSync = require('./lib/epic/epicDepsSync.cjs');
|
|
60
62
|
const logs = require('./logs.cjs');
|
|
61
63
|
const chatInflight = require('./lib/chatInflight.cjs');
|
|
62
64
|
const { feedChildStdin } = require('./lib/process/childStdin.cjs');
|
|
@@ -465,6 +467,20 @@ function appendChatEpicEvent(cwd, epicId, event) {
|
|
|
465
467
|
});
|
|
466
468
|
}
|
|
467
469
|
|
|
470
|
+
/**
|
|
471
|
+
* Poke the Epic outside-state emitter (lib/epic/epicStateEmitter.cjs) at a
|
|
472
|
+
* turn's acceptance and settle — the only moments that time the 'working' and
|
|
473
|
+
* 'needs_input' outside states. Lazy require; never throws, never alters a turn.
|
|
474
|
+
*/
|
|
475
|
+
function pokeState(cwd, sessionId) {
|
|
476
|
+
if (typeof cwd !== 'string' || !cwd || typeof sessionId !== 'string' || !sessionId) return;
|
|
477
|
+
try {
|
|
478
|
+
require('./lib/epic/epicStateEmitter.cjs').pokeEpicState(cwd, sessionId);
|
|
479
|
+
} catch (err) {
|
|
480
|
+
console.error('[chatRunner] epic state poke failed', sessionId, err?.message ?? err);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
468
484
|
/** Staging folder for a chat session's artifacts, or null (unsafe id / mkdir failure — logged). */
|
|
469
485
|
function chatArtifactsDir(sessionId) {
|
|
470
486
|
try {
|
|
@@ -658,11 +674,13 @@ function run(opts) {
|
|
|
658
674
|
pendingStart.delete(opts.tabId);
|
|
659
675
|
run({ ...opts, worktreeDirHint: wt && wt.dir ? wt.dir : undefined });
|
|
660
676
|
});
|
|
677
|
+
if (!opts.silent) pokeState(opts.cwd, opts.sessionId);
|
|
661
678
|
return { accepted: true, queued: tabBusy };
|
|
662
679
|
}
|
|
663
680
|
|
|
664
681
|
waiting.push(opts);
|
|
665
682
|
pump();
|
|
683
|
+
if (!opts.silent) pokeState(opts.cwd, opts.sessionId);
|
|
666
684
|
return { accepted: true, queued: tabBusy };
|
|
667
685
|
}
|
|
668
686
|
|
|
@@ -702,6 +720,7 @@ function pump() {
|
|
|
702
720
|
liveSessions.delete(job.sessionId);
|
|
703
721
|
sessionSlots.release(slotToken);
|
|
704
722
|
pump();
|
|
723
|
+
if (!job.silent) pokeState(job.cwd, job.sessionId);
|
|
705
724
|
});
|
|
706
725
|
}
|
|
707
726
|
// Anyone still waiting gets a 1-based position update. Silent (automated
|
|
@@ -886,6 +905,12 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
886
905
|
settle();
|
|
887
906
|
return;
|
|
888
907
|
}
|
|
908
|
+
// Long-lived Epic worktree: refresh its node_modules links from the project checkout
|
|
909
|
+
// (fire-and-forget, throttled). The sync runs after the CLI is spawned, so it normally
|
|
910
|
+
// lands before the agent's first tool call but is not awaited; the next turn guarantees it.
|
|
911
|
+
if (plan.execCwd && plan.execCwd !== cwd) {
|
|
912
|
+
epicDepsSync.syncEpicWorktreeDeps({ projectCwd: cwd, worktreeCwd: plan.execCwd });
|
|
913
|
+
}
|
|
889
914
|
// Agent-CLI turn plan (agentCliTurn.cjs): command, argv, stdin, auth env, parser, transcript.
|
|
890
915
|
let agentPlan = null;
|
|
891
916
|
if (isAgentCli) {
|
|
@@ -903,6 +928,29 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
903
928
|
? cleanChildEnv({ PATH: pathWithUserBins(), SM_CHAT_SESSION_ID: sessionId, SM_PROJECT_ROOT: cwd, ...artifactsEnv, ...agentPlan.envExtra })
|
|
904
929
|
: null;
|
|
905
930
|
|
|
931
|
+
// Gear binds chat (stamped snapshots only): same tool/MCP/pack/skill scope a job gets.
|
|
932
|
+
let gearArgs = [];
|
|
933
|
+
if (!isAgentCli && plan.persona && plan.persona.snapshot) {
|
|
934
|
+
try {
|
|
935
|
+
const gear = gearChatArgs({ snapshot: plan.persona.snapshot, cwd: plan.execCwd || cwd, projectRoot: cwd });
|
|
936
|
+
gearArgs = gear.args;
|
|
937
|
+
// Persona-declared packs load with the Epic's (as for jobs); known ones only.
|
|
938
|
+
const snapPacks = (Array.isArray(plan.persona.snapshot.packs) ? plan.persona.snapshot.packs.map(String) : [])
|
|
939
|
+
.filter((p) => !(agentEpic?.packs || []).map(String).includes(p));
|
|
940
|
+
if (gear.args.length && snapPacks.length) {
|
|
941
|
+
const extra = packSpawnArgs.composePackSpawnArgs({ packIds: snapPacks });
|
|
942
|
+
packPluginDirArgs = [...packPluginDirArgs, ...(Array.isArray(extra.pluginDirArgs) ? extra.pluginDirArgs : [])];
|
|
943
|
+
if (extra.laws) packLaws = packLaws ? `${packLaws}\n\n${extra.laws}` : extra.laws;
|
|
944
|
+
}
|
|
945
|
+
for (const message of gear.errors) {
|
|
946
|
+
try {
|
|
947
|
+
opsErrorLog.appendError({ cwd, scope: 'chatRunner', level: 'warn', code: 'capability_unknown', tabId, tags: [], message, meta: { sessionId } });
|
|
948
|
+
} catch { /* logging must never fail a turn */ }
|
|
949
|
+
if (!silent) broadcast('chat:run:notice', { tabId, sessionId, message });
|
|
950
|
+
}
|
|
951
|
+
} catch { gearArgs = []; }
|
|
952
|
+
}
|
|
953
|
+
|
|
906
954
|
const useResume = plan.useResume;
|
|
907
955
|
if (!agentPlan && useResume !== !!resume) {
|
|
908
956
|
try {
|
|
@@ -925,6 +973,7 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
925
973
|
'--dangerously-skip-permissions',
|
|
926
974
|
...loopOffArgs,
|
|
927
975
|
...packPluginDirArgs,
|
|
976
|
+
...gearArgs,
|
|
928
977
|
...(packLaws ? ['--append-system-prompt', packLaws] : []),
|
|
929
978
|
'--output-format', 'stream-json',
|
|
930
979
|
'--verbose',
|
|
@@ -1374,6 +1423,16 @@ function cancel(tabId) {
|
|
|
1374
1423
|
// than duplicating it here.
|
|
1375
1424
|
|
|
1376
1425
|
const pendingExternalSends = new Map(); // requestId -> { resolve, timer }
|
|
1426
|
+
// requestId -> expiry timer. A send that timed out may still be acked by the
|
|
1427
|
+
// renderer; a late ack that produced a run confirms the held-turn entries it carried.
|
|
1428
|
+
const timedOutExternalSends = new Map();
|
|
1429
|
+
const TIMED_OUT_SEND_TTL_MS = 10 * 60 * 1000;
|
|
1430
|
+
|
|
1431
|
+
function rememberTimedOutSend(requestId) {
|
|
1432
|
+
const t = setTimeout(() => { timedOutExternalSends.delete(requestId); }, TIMED_OUT_SEND_TTL_MS);
|
|
1433
|
+
t.unref?.();
|
|
1434
|
+
timedOutExternalSends.set(requestId, t);
|
|
1435
|
+
}
|
|
1377
1436
|
|
|
1378
1437
|
function hasLiveWindow() {
|
|
1379
1438
|
try {
|
|
@@ -1383,10 +1442,57 @@ function hasLiveWindow() {
|
|
|
1383
1442
|
|
|
1384
1443
|
/**
|
|
1385
1444
|
* Resolves { disposition, reason? } once the renderer reports what it did, or
|
|
1386
|
-
* { disposition: 'unconfirmed', reason: '
|
|
1445
|
+
* { disposition: 'unconfirmed', reason: 'no-window' } / { disposition: 'unconfirmed',
|
|
1446
|
+
* reason: 'timeout', requestId } (a late ack may still confirm a held batch). Never rejects.
|
|
1387
1447
|
*/
|
|
1448
|
+
// tabId -> identity key of the usage hold last audited for it (one audit per tab per hold).
|
|
1449
|
+
const heldTurnAuditKeys = new Map();
|
|
1450
|
+
|
|
1451
|
+
function schedulerHoldKey(hold) {
|
|
1452
|
+
try {
|
|
1453
|
+
const { holdIdentityKey } = require('./scheduler/utilizationHold.cjs');
|
|
1454
|
+
if (typeof holdIdentityKey === 'function') return holdIdentityKey(hold);
|
|
1455
|
+
} catch { /* fall through to the local key */ }
|
|
1456
|
+
return `${hold.reason}|${hold.window ?? ''}|${hold.resetsAt ?? ''}`;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* Usage-hold seam: a scheduler-started turn under an active hold is deferred to the
|
|
1461
|
+
* held store (no broadcast, no claude process). Returns the disposition, or null
|
|
1462
|
+
* when the turn may run now. Required lazily to keep load order safe.
|
|
1463
|
+
*/
|
|
1464
|
+
function holdSchedulerTurn(tabId, prompt, extra) {
|
|
1465
|
+
const heldSchedulerTurns = require('./lib/scheduler/heldSchedulerTurns.cjs');
|
|
1466
|
+
const hold = heldSchedulerTurns.currentHold();
|
|
1467
|
+
if (!hold) return null;
|
|
1468
|
+
// A drain batch held again keeps its original entries; re-deferring it would
|
|
1469
|
+
// nest coalesced headers on the next delivery.
|
|
1470
|
+
if (extra.heldBatch === true) return { disposition: 'held', reason: hold.reason };
|
|
1471
|
+
const { sessionId, cwd, heldKind } = extra;
|
|
1472
|
+
const entry = heldSchedulerTurns.defer({ tabId, prompt, kind: heldKind || 'scheduler-notice', sessionId, cwd, hold });
|
|
1473
|
+
const key = schedulerHoldKey(hold);
|
|
1474
|
+
if (heldTurnAuditKeys.get(tabId) !== key) {
|
|
1475
|
+
heldTurnAuditKeys.set(tabId, key);
|
|
1476
|
+
// The turn kind is `heldKind`: appendAuditEvent spreads fields over the record,
|
|
1477
|
+
// so a `kind` field would overwrite the event kind itself.
|
|
1478
|
+
require('./lib/telemetry/auditLog.cjs').appendAuditEvent('scheduler_turn_held', {
|
|
1479
|
+
tabId,
|
|
1480
|
+
heldKind: entry.kind,
|
|
1481
|
+
reason: hold.reason ?? null,
|
|
1482
|
+
window: hold.window ?? null,
|
|
1483
|
+
percent: hold.percent ?? null,
|
|
1484
|
+
threshold: hold.threshold ?? null,
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
return { disposition: 'held', reason: hold.reason };
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1388
1490
|
function enqueueExternalPrompt(tabId, prompt, extra = {}) {
|
|
1389
1491
|
const { sessionId, cwd, origin, relay } = extra ?? {};
|
|
1492
|
+
if (origin === 'scheduler') {
|
|
1493
|
+
const heldResult = holdSchedulerTurn(tabId, prompt, extra ?? {});
|
|
1494
|
+
if (heldResult) return Promise.resolve(heldResult);
|
|
1495
|
+
}
|
|
1390
1496
|
if (!hasLiveWindow()) return Promise.resolve({ disposition: 'unconfirmed', reason: 'no-window' });
|
|
1391
1497
|
if (origin === 'scheduler') noteSchedulerPrompt(tabId, prompt);
|
|
1392
1498
|
const note = origin !== 'scheduler' && relay !== undefined ? noteRelayPrompt(tabId, prompt, relay) : null;
|
|
@@ -1401,7 +1507,8 @@ function enqueueExternalPrompt(tabId, prompt, extra = {}) {
|
|
|
1401
1507
|
};
|
|
1402
1508
|
const timer = setTimeout(() => {
|
|
1403
1509
|
pendingExternalSends.delete(requestId);
|
|
1404
|
-
|
|
1510
|
+
rememberTimedOutSend(requestId);
|
|
1511
|
+
resolve({ disposition: 'unconfirmed', reason: 'timeout', requestId });
|
|
1405
1512
|
}, EXTERNAL_SEND_ACK_TIMEOUT_MS);
|
|
1406
1513
|
timer.unref?.();
|
|
1407
1514
|
pendingExternalSends.set(requestId, { resolve, timer });
|
|
@@ -1417,7 +1524,20 @@ function enqueueExternalPrompt(tabId, prompt, extra = {}) {
|
|
|
1417
1524
|
|
|
1418
1525
|
function settleExternalSend({ requestId, disposition, reason }) {
|
|
1419
1526
|
const entry = pendingExternalSends.get(requestId);
|
|
1420
|
-
if (!entry)
|
|
1527
|
+
if (!entry) {
|
|
1528
|
+
const late = timedOutExternalSends.get(requestId);
|
|
1529
|
+
if (late === undefined) return;
|
|
1530
|
+
clearTimeout(late);
|
|
1531
|
+
timedOutExternalSends.delete(requestId);
|
|
1532
|
+
if (disposition !== 'refused' && disposition !== 'unconfirmed') {
|
|
1533
|
+
try {
|
|
1534
|
+
require('./lib/scheduler/heldSchedulerTurns.cjs').confirmLateDelivery(requestId);
|
|
1535
|
+
} catch (err) {
|
|
1536
|
+
console.error('[chatRunner] confirmLateDelivery failed:', err);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1421
1541
|
clearTimeout(entry.timer);
|
|
1422
1542
|
pendingExternalSends.delete(requestId);
|
|
1423
1543
|
entry.resolve({ disposition, ...(reason !== undefined ? { reason } : {}) });
|
|
@@ -1436,7 +1556,8 @@ const EXTERNAL_NEW_SESSION_TIMEOUT_MS = 30000;
|
|
|
1436
1556
|
const pendingExternalNewSessions = new Map(); // requestId -> { resolve, timer }
|
|
1437
1557
|
|
|
1438
1558
|
/**
|
|
1439
|
-
*
|
|
1559
|
+
* Every payload key (incl. a boolean `reviewStage`) is broadcast unchanged.
|
|
1560
|
+
* @returns {Promise<{ ok: true, epicId: string, entryId?: string, slug?: string, stage?: 'review'|'final'|null } | { ok: false, reason: 'no-window'|'timeout'|'launch-failed', error: string }>}
|
|
1440
1561
|
*/
|
|
1441
1562
|
function startExternalNewSession(payload) {
|
|
1442
1563
|
if (!hasLiveWindow()) {
|
|
@@ -1454,13 +1575,20 @@ function startExternalNewSession(payload) {
|
|
|
1454
1575
|
});
|
|
1455
1576
|
}
|
|
1456
1577
|
|
|
1457
|
-
function settleExternalNewSession({ requestId, ok, epicId, error }) {
|
|
1578
|
+
function settleExternalNewSession({ requestId, ok, epicId, error, entryId, slug, stage }) {
|
|
1458
1579
|
const entry = pendingExternalNewSessions.get(requestId);
|
|
1459
1580
|
if (!entry) return;
|
|
1460
1581
|
clearTimeout(entry.timer);
|
|
1461
1582
|
pendingExternalNewSessions.delete(requestId);
|
|
1462
|
-
if (ok && epicId)
|
|
1463
|
-
|
|
1583
|
+
if (ok && epicId) {
|
|
1584
|
+
entry.resolve({
|
|
1585
|
+
ok: true,
|
|
1586
|
+
epicId,
|
|
1587
|
+
...(entryId !== undefined ? { entryId } : {}),
|
|
1588
|
+
...(slug !== undefined ? { slug } : {}),
|
|
1589
|
+
...(stage !== undefined ? { stage } : {}),
|
|
1590
|
+
});
|
|
1591
|
+
} else entry.resolve({ ok: false, reason: 'launch-failed', error: error || 'renderer could not start the session' });
|
|
1464
1592
|
}
|
|
1465
1593
|
|
|
1466
1594
|
// Read-only: is a chat turn for this tab running, being dispatched, parked
|
|
@@ -1559,6 +1687,82 @@ function registerChatHandlers() {
|
|
|
1559
1687
|
|
|
1560
1688
|
}
|
|
1561
1689
|
|
|
1690
|
+
const undecidedLogged = new Set();
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* Gear for a chat turn (PRD 4768): the argv that gives an Epic whose pinned snapshot carries
|
|
1694
|
+
* `gearBindsChat` the same scope a job gets — persona tools, strict MCP with the declared servers,
|
|
1695
|
+
* packs' skill allow-list. HEADLESS_DISALLOWED_TOOLS is deliberately NOT applied to chat.
|
|
1696
|
+
* Unstamped (older) snapshots and Unbound personas add nothing; Undecided runs unscoped.
|
|
1697
|
+
* An unknown declared server/pack never crashes the turn: it is dropped and reported in `errors`.
|
|
1698
|
+
* Pure apart from reading ~/.claude.json and <cwd>/.mcp.json (declared servers), the pack catalog and the seeded MCP entry (injectable for tests).
|
|
1699
|
+
* `projectRoot` is the Epic's main project cwd: a worktree `cwd` still sees servers under projects[<main root>].
|
|
1700
|
+
* @param {{ snapshot: any, cwd?: string, projectRoot?: string, deps?: { home?: string, knownMcpServers?: Record<string, object>, listPacks?: () => { packs: any[] }, listUnpackedSkills?: () => string[], log?: (msg: string) => void } }} opts
|
|
1701
|
+
* @returns {{ args: string[], errors: string[] }}
|
|
1702
|
+
*/
|
|
1703
|
+
function gearChatArgs({ snapshot, cwd, projectRoot, deps = {} }) {
|
|
1704
|
+
const none = { args: [], errors: [] };
|
|
1705
|
+
if (!snapshot || snapshot.gearBindsChat !== true) return none;
|
|
1706
|
+
const loadout = snapshot.loadout;
|
|
1707
|
+
if (loadout === 'unbound') return none;
|
|
1708
|
+
if (loadout === 'undecided') {
|
|
1709
|
+
const key = String(snapshot.name || '');
|
|
1710
|
+
if (!undecidedLogged.has(key)) {
|
|
1711
|
+
undecidedLogged.add(key);
|
|
1712
|
+
try { (deps.log || ((m) => logs.writeLine({ scope: 'chatRunner', level: 'info', message: m })))(`persona "${key}" is undecided about gear; chat runs unscoped`); } catch { /* logging must never fail a turn */ }
|
|
1713
|
+
}
|
|
1714
|
+
return none;
|
|
1715
|
+
}
|
|
1716
|
+
let known = deps.knownMcpServers;
|
|
1717
|
+
/** @type {Record<string, string>} */
|
|
1718
|
+
let credentialed = {};
|
|
1719
|
+
if (!known) {
|
|
1720
|
+
try {
|
|
1721
|
+
const r = require('./lib/claude/headlessMcpServers.cjs').resolveHeadlessMcpServers({ cwd, projectRoot, ...(deps.home ? { home: deps.home } : {}) });
|
|
1722
|
+
known = r.known;
|
|
1723
|
+
credentialed = r.credentialed;
|
|
1724
|
+
} catch { known = {}; }
|
|
1725
|
+
}
|
|
1726
|
+
let catalog = [];
|
|
1727
|
+
try { catalog = (deps.listPacks || require('./lib/packs/packCatalog.cjs').listPacks)().packs || []; } catch { catalog = []; }
|
|
1728
|
+
let unpacked = [];
|
|
1729
|
+
try { unpacked = (deps.listUnpackedSkills || require('./lib/packs/packCatalog.cjs').listUnpackedSkills)(); } catch { unpacked = []; }
|
|
1730
|
+
const packs = Array.isArray(snapshot.packs) ? snapshot.packs.map(String) : [];
|
|
1731
|
+
const knownPackIds = new Set(catalog.map((p) => String(p.id)));
|
|
1732
|
+
const declared = Array.isArray(snapshot.mcpServers) ? snapshot.mcpServers.map(String) : [];
|
|
1733
|
+
const scope = buildPersonaToolScope(snapshot.tools, { loadout, disallowed: [] });
|
|
1734
|
+
const attempt = personaToolScopeArgs(scope, { mcpServers: known, declaredServers: declared, packs, knownPacks: [...knownPackIds] });
|
|
1735
|
+
/** @type {string[]} */ const errors = [];
|
|
1736
|
+
let scopeArgs = attempt.args;
|
|
1737
|
+
let equipped = packs;
|
|
1738
|
+
if (attempt.refusal) {
|
|
1739
|
+
// Run without the unknown capability instead of failing the turn: drop it and re-derive.
|
|
1740
|
+
const bad = new Set();
|
|
1741
|
+
let r = attempt.refusal;
|
|
1742
|
+
let guard = 0;
|
|
1743
|
+
let curDeclared = declared;
|
|
1744
|
+
let curPacks = packs;
|
|
1745
|
+
let curScope = scope;
|
|
1746
|
+
let cur = attempt;
|
|
1747
|
+
while (r && guard++ < 50) {
|
|
1748
|
+
bad.add(r.name);
|
|
1749
|
+
errors.push(Object.prototype.hasOwnProperty.call(credentialed, r.name)
|
|
1750
|
+
? `Gear: "${r.name}" is not available (${credentialed[r.name]}); this turn runs without it.`
|
|
1751
|
+
: `Gear: "${r.name}" is not available; this turn runs without it.`);
|
|
1752
|
+
curDeclared = curDeclared.filter((d) => d !== r.name);
|
|
1753
|
+
curPacks = curPacks.filter((p) => p !== r.name);
|
|
1754
|
+
curScope = curScope ? { tools: curScope.tools.filter((t) => !(t.startsWith('mcp__') && t.slice(5).split('__')[0] === r.name) && t !== r.name) } : curScope;
|
|
1755
|
+
cur = personaToolScopeArgs(curScope, { mcpServers: known, declaredServers: curDeclared, packs: curPacks, knownPacks: [...knownPackIds] });
|
|
1756
|
+
r = cur.refusal;
|
|
1757
|
+
}
|
|
1758
|
+
scopeArgs = cur.args;
|
|
1759
|
+
equipped = curPacks;
|
|
1760
|
+
}
|
|
1761
|
+
const installedSkills = [...new Set([...catalog.flatMap((p) => p.skills || []), ...unpacked].map(String))];
|
|
1762
|
+
const deny = skillDenyArgs({ installedSkills, equippedPacks: equipped, packCatalog: catalog, loadout });
|
|
1763
|
+
return { args: [...scopeArgs, ...deny], errors };
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1562
1766
|
module.exports = {
|
|
1563
1767
|
run,
|
|
1564
1768
|
cancel,
|
|
@@ -1570,6 +1774,7 @@ module.exports = {
|
|
|
1570
1774
|
registerChatHandlers,
|
|
1571
1775
|
noteChatRunOrigin,
|
|
1572
1776
|
turnInstructionFor,
|
|
1777
|
+
gearChatArgs,
|
|
1573
1778
|
shouldFollowUp,
|
|
1574
1779
|
parseStopSignal,
|
|
1575
1780
|
splitStopSignal,
|
|
@@ -1599,4 +1804,6 @@ module.exports = {
|
|
|
1599
1804
|
isTabBusy,
|
|
1600
1805
|
EXTERNAL_NEW_SESSION_TIMEOUT_MS,
|
|
1601
1806
|
registerAdminRoute,
|
|
1807
|
+
// test-only: the chat turn-end artifact ingest (chatRunnerArtifactNotice.test.cjs)
|
|
1808
|
+
__ingestChatArtifacts: ingestChatArtifacts,
|
|
1602
1809
|
};
|
package/src/main/config.cjs
CHANGED
|
@@ -19,7 +19,7 @@ const fs = require('node:fs');
|
|
|
19
19
|
const fsp = require('node:fs/promises');
|
|
20
20
|
const path = require('node:path');
|
|
21
21
|
const os = require('node:os');
|
|
22
|
-
const { assertOpsWrite, opsPath, OWNERS, OPS_ROOT_DIR } = require('./lib/opsOwnership.cjs');
|
|
22
|
+
const { assertOpsWrite, ensureRuntimeIgnoreForPath, opsPath, OWNERS, OPS_ROOT_DIR } = require('./lib/opsOwnership.cjs');
|
|
23
23
|
const { walkImports } = require('./lib/persona-macro/personaImportHealth.cjs');
|
|
24
24
|
const chokidar = require('chokidar');
|
|
25
25
|
const logs = require('./logs.cjs');
|
|
@@ -293,6 +293,7 @@ async function writeRendererText(abs, text, { writer, importedBy } = {}) {
|
|
|
293
293
|
throw new Error(`Write outside allowed write boundaries: ${real}`);
|
|
294
294
|
}
|
|
295
295
|
assertOpsWrite(real, writer);
|
|
296
|
+
ensureRuntimeIgnoreForPath(real);
|
|
296
297
|
await atomicFs.writeTextAtomic(real, text, {});
|
|
297
298
|
const stat = await fsp.stat(real);
|
|
298
299
|
return { ok: true, mtimeMs: stat.mtimeMs };
|
|
@@ -368,6 +369,7 @@ async function writeTextAtomic(abs, text, opts = {}) {
|
|
|
368
369
|
const real = validatePath(expandHome(abs));
|
|
369
370
|
validateWrite(real);
|
|
370
371
|
assertOpsWrite(real, opts.writer);
|
|
372
|
+
ensureRuntimeIgnoreForPath(real);
|
|
371
373
|
await atomicFs.writeTextAtomic(real, text, opts);
|
|
372
374
|
const stat = await fsp.stat(real);
|
|
373
375
|
return { ok: true, mtimeMs: stat.mtimeMs };
|
|
@@ -381,6 +383,7 @@ async function writeBinaryAtomic(abs, buffer, opts = {}) {
|
|
|
381
383
|
const real = validatePath(expandHome(abs));
|
|
382
384
|
validateWrite(real);
|
|
383
385
|
assertOpsWrite(real, opts.writer);
|
|
386
|
+
ensureRuntimeIgnoreForPath(real);
|
|
384
387
|
const dir = path.dirname(real);
|
|
385
388
|
await fsp.mkdir(dir, { recursive: true });
|
|
386
389
|
const tmp = `${real}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -409,6 +412,7 @@ function writeJsonSync(abs, data, opts = {}) {
|
|
|
409
412
|
const real = validatePath(expandHome(abs));
|
|
410
413
|
validateWrite(real);
|
|
411
414
|
assertOpsWrite(real, opts.writer);
|
|
415
|
+
ensureRuntimeIgnoreForPath(real);
|
|
412
416
|
atomicFs.writeJsonAtomicSync(real, data, opts);
|
|
413
417
|
const stat = fs.statSync(real);
|
|
414
418
|
return { ok: true, mtimeMs: stat.mtimeMs };
|