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
|
@@ -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:@]+:[^/\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)
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
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.
|
|
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
|
}
|
|
@@ -158,12 +164,77 @@ function personaToolScopeEnv(scope) {
|
|
|
158
164
|
return { [JOB_MCP_TOOLS_ENV]: JSON.stringify(mcp) };
|
|
159
165
|
}
|
|
160
166
|
|
|
167
|
+
/**
|
|
168
|
+
* The `--disallowedTools=Skill(<name>)` argv that refuses every installed
|
|
169
|
+
* skill a persona's equipped packs do not carry. Skills ride only inside packs.
|
|
170
|
+
* Verified on CLI 2.1.330: a denied Skill call fails with 'Skill execution
|
|
171
|
+
* blocked by permission rules'. Always the --flag=value form (only the first
|
|
172
|
+
* value after a variadic flag is literal). Pure: the caller passes the catalog.
|
|
173
|
+
*
|
|
174
|
+
* Unbound/undecided loadouts deny nothing; Bare ignores equipped packs. CLI-bundled
|
|
175
|
+
* skills follow the built-in tool decision and are never denied; `alwaysAllowed`
|
|
176
|
+
* (finish protocol: code-review, security-review) never are either.
|
|
177
|
+
*
|
|
178
|
+
* @param {{ installedSkills?: readonly string[], equippedPacks?: readonly string[],
|
|
179
|
+
* packCatalog?: readonly { id: string, skills?: readonly string[] }[],
|
|
180
|
+
* bundledSkills?: readonly string[], loadout?: string,
|
|
181
|
+
* alwaysAllowed?: readonly string[] }} [opts]
|
|
182
|
+
* @returns {string[]}
|
|
183
|
+
*/
|
|
184
|
+
function skillDenyArgs({
|
|
185
|
+
installedSkills = [], equippedPacks = [], packCatalog = [], bundledSkills = [],
|
|
186
|
+
loadout, alwaysAllowed = ['code-review', 'security-review'],
|
|
187
|
+
} = {}) {
|
|
188
|
+
if (loadout === 'unbound' || loadout === 'undecided') return [];
|
|
189
|
+
const allowed = new Set([...bundledSkills, ...alwaysAllowed].map(String));
|
|
190
|
+
if (loadout !== 'bare') {
|
|
191
|
+
const equipped = new Set(equippedPacks.map(String));
|
|
192
|
+
for (const pack of packCatalog) {
|
|
193
|
+
if (!pack || !equipped.has(String(pack.id))) continue;
|
|
194
|
+
for (const s of pack.skills || []) allowed.add(String(s));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const out = [];
|
|
198
|
+
for (const raw of installedSkills) {
|
|
199
|
+
const name = String(raw).trim();
|
|
200
|
+
if (!name || allowed.has(name) || out.includes(`--disallowedTools=Skill(${name})`)) continue;
|
|
201
|
+
out.push(`--disallowedTools=Skill(${name})`);
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The skill-deny argv for one unattended spawn (job or Task): the real catalogs
|
|
208
|
+
* (packs, loose skills, CLI-bundled skills) fed to skillDenyArgs. Never throws;
|
|
209
|
+
* a catalog failure denies nothing (same as an unbound loadout).
|
|
210
|
+
* @param {{ packs?: readonly string[], loadout?: string|null, deps?: Record<string, any> }} [o]
|
|
211
|
+
* @returns {Promise<{ args: string[], denied: number }>}
|
|
212
|
+
*/
|
|
213
|
+
async function resolveSkillDeny({ packs = [], loadout, deps } = {}) {
|
|
214
|
+
const d = deps || {};
|
|
215
|
+
try {
|
|
216
|
+
if (!loadout) return { args: [], denied: 0 };
|
|
217
|
+
const catalog = require('../packs/packCatalog.cjs');
|
|
218
|
+
const packCatalog = (d.listPacks || catalog.listPacks)().packs || [];
|
|
219
|
+
const unpacked = [...(d.listUnpackedSkills || catalog.listUnpackedSkills)()];
|
|
220
|
+
const builtin = await (d.getBuiltinTools || require('./builtinTools.cjs').getBuiltinTools)();
|
|
221
|
+
const bundledSkills = (builtin && builtin.skills) || [];
|
|
222
|
+
const installedSkills = [...new Set([...packCatalog.flatMap((p) => p.skills || []), ...unpacked])];
|
|
223
|
+
const args = skillDenyArgs({ installedSkills, equippedPacks: packs, packCatalog, bundledSkills, loadout });
|
|
224
|
+
return { args, denied: args.length };
|
|
225
|
+
} catch {
|
|
226
|
+
return { args: [], denied: 0 };
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
161
230
|
module.exports = {
|
|
231
|
+
resolveSkillDeny,
|
|
162
232
|
JOB_MCP_TOOLS_ENV,
|
|
163
233
|
personaToolScopeEnv,
|
|
164
234
|
HEADLESS_TOOL_FLOOR,
|
|
165
235
|
HEADLESS_SCOPE_AGENT_NAME,
|
|
166
236
|
buildPersonaToolScope,
|
|
237
|
+
skillDenyArgs,
|
|
167
238
|
personaToolScopeArgs,
|
|
168
239
|
resolvedMcpServerNames,
|
|
169
240
|
};
|
|
@@ -24,7 +24,16 @@ persona still holds.
|
|
|
24
24
|
## A member without a voice
|
|
25
25
|
|
|
26
26
|
- A member without `voice` never speaks. Give it no lines.
|
|
27
|
-
- It
|
|
27
|
+
- It is heard only through sound effects on its moments, never words: cue one of its `sfx` with
|
|
28
|
+
sound.cjs, or a built-in effect that fits its `note` when it has no `sfx`.
|
|
29
|
+
|
|
30
|
+
## Sounds
|
|
31
|
+
|
|
32
|
+
- A member's `sfx` names its signature sounds: built-in effects or the persona's own.
|
|
33
|
+
- character.json `sounds` lists the project's own effects (`sfx`) and music beds (`beds`) by
|
|
34
|
+
`name`, each with a `note` on what it is. Use them by name: a sound.cjs cue for an effect, the
|
|
35
|
+
spec's `bed` for a music bed. They are mixed like the built-in ones.
|
|
36
|
+
- An unknown sound name fails the run with sound.cjs's error. Never swap in another sound.
|
|
28
37
|
|
|
29
38
|
## Captions
|
|
30
39
|
|
|
@@ -14,6 +14,8 @@ const fs = require('node:fs');
|
|
|
14
14
|
const os = require('node:os');
|
|
15
15
|
const path = require('node:path');
|
|
16
16
|
const { spawnSync } = require('node:child_process');
|
|
17
|
+
// projectSounds.cjs requires this file only lazily, so this top-level require has no load cycle.
|
|
18
|
+
const { validateSounds, validateMemberSfx } = require('./projectSounds.cjs');
|
|
17
19
|
// Kit files are seeded to ~/.claude/session-manager/demo-video-kit/ and must
|
|
18
20
|
// load standalone: node built-ins and this folder only (no ../opsOwnership.cjs).
|
|
19
21
|
// Allowlisted for this literal in scripts/check-ops-path-literals.cjs ALLOWLIST.
|
|
@@ -75,7 +77,11 @@ function validateCharacterJson(c) {
|
|
|
75
77
|
if (!v || typeof v !== 'object') return 'voice is required';
|
|
76
78
|
const vErr = validateVoiceOrRef(v, 'voice');
|
|
77
79
|
if (vErr) return vErr;
|
|
78
|
-
if ('
|
|
80
|
+
if ('sounds' in c) {
|
|
81
|
+
const sErr = validateSounds(c.sounds);
|
|
82
|
+
if (sErr) return sErr;
|
|
83
|
+
}
|
|
84
|
+
if ('cast' in c) return validateCast(c.cast, c.name, c.sounds);
|
|
79
85
|
return null;
|
|
80
86
|
}
|
|
81
87
|
|
|
@@ -135,11 +141,13 @@ function voiceIdRefsOf(c) {
|
|
|
135
141
|
return refs;
|
|
136
142
|
}
|
|
137
143
|
|
|
138
|
-
const CAST_KEYS = Object.freeze(['name', 'voice', 'note']);
|
|
144
|
+
const CAST_KEYS = Object.freeze(['name', 'voice', 'note', 'sfx']);
|
|
139
145
|
|
|
140
146
|
/** -> null when `cast` is a valid supporting cast for host `hostName`, else a reason.
|
|
141
|
-
* A member without `voice` is valid: it never speaks
|
|
142
|
-
|
|
147
|
+
* A member without `voice` is valid: it never speaks, and is heard only through sound
|
|
148
|
+
* effects. A member's optional `sfx` names its signature sounds (built-in effects or the
|
|
149
|
+
* persona's `sounds.sfx`, passed as `sounds`). */
|
|
150
|
+
function validateCast(cast, hostName, sounds) {
|
|
143
151
|
if (!Array.isArray(cast) || cast.length > MAX_CAST_MEMBERS) {
|
|
144
152
|
return `cast must be an array of at most ${MAX_CAST_MEMBERS} members`;
|
|
145
153
|
}
|
|
@@ -165,6 +173,10 @@ function validateCast(cast, hostName) {
|
|
|
165
173
|
if ('note' in m && (typeof m.note !== 'string' || m.note.length < 1 || m.note.length > CAST_NOTE_MAX)) {
|
|
166
174
|
return `${at}.note must be a 1-${CAST_NOTE_MAX} char string`;
|
|
167
175
|
}
|
|
176
|
+
if ('sfx' in m) {
|
|
177
|
+
const fErr = validateMemberSfx(m.sfx, `${at}.sfx`, sounds);
|
|
178
|
+
if (fErr) return fErr;
|
|
179
|
+
}
|
|
168
180
|
}
|
|
169
181
|
return null;
|
|
170
182
|
}
|
|
@@ -313,15 +325,50 @@ function wavSeconds(file) {
|
|
|
313
325
|
}
|
|
314
326
|
}
|
|
315
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Time kept back from speaking for mixing and saving the video, given `leftMs` before the
|
|
330
|
+
* job deadline: a quarter of it, at most SPEAK_DEADLINE_MARGIN_MS (45 min). Short jobs still
|
|
331
|
+
* get three quarters of their time to speak; long jobs keep the full 45 minutes.
|
|
332
|
+
*/
|
|
333
|
+
function speakReserveMs(leftMs) {
|
|
334
|
+
return Math.min(SPEAK_DEADLINE_MARGIN_MS, Math.floor(leftMs / 4));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** env.SM_SCHEDULER_JOB_DEADLINE_MS as a finite number, else null. */
|
|
338
|
+
function jobDeadline(env) {
|
|
339
|
+
const raw = env && env.SM_SCHEDULER_JOB_DEADLINE_MS;
|
|
340
|
+
const deadline = Number(raw);
|
|
341
|
+
return raw !== undefined && raw !== null && raw !== '' && Number.isFinite(deadline) ? deadline : null;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** Minutes with one decimal, for error messages. */
|
|
345
|
+
function fmtMin(ms) {
|
|
346
|
+
return Math.round(Math.max(0, ms) / 6000) / 10;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* ' (<N> min left before the job deadline, <M> min kept in reserve)' when
|
|
351
|
+
* env.SM_SCHEDULER_JOB_DEADLINE_MS is set, else ''. The one suffix both the batch time-limit
|
|
352
|
+
* error and the voice-lane timeout use, so the two messages say the same thing. reserveMs,
|
|
353
|
+
* when given, is printed as the reserve kept (the lane fixes it when its wait starts) instead
|
|
354
|
+
* of speakReserveMs(time left).
|
|
355
|
+
*/
|
|
356
|
+
function deadlineContext({ now = Date.now(), env = process.env, reserveMs } = {}) {
|
|
357
|
+
const deadline = jobDeadline(env);
|
|
358
|
+
if (deadline === null) return '';
|
|
359
|
+
const leftMs = deadline - now;
|
|
360
|
+
const kept = reserveMs === undefined || reserveMs === null ? speakReserveMs(leftMs) : reserveMs;
|
|
361
|
+
return ` (${fmtMin(leftMs)} min left before the job deadline, ${fmtMin(kept)} min kept in reserve)`;
|
|
362
|
+
}
|
|
363
|
+
|
|
316
364
|
/**
|
|
317
365
|
* How long one synthesis call may wait for its voice lane: the time left before
|
|
318
|
-
* env.SM_SCHEDULER_JOB_DEADLINE_MS minus
|
|
366
|
+
* env.SM_SCHEDULER_JOB_DEADLINE_MS minus speakReserveMs(time left) when that is set
|
|
319
367
|
* (may be <= 0: no time left), else LANE_WAIT_DEFAULT_MS (6 h).
|
|
320
368
|
*/
|
|
321
369
|
function laneWaitMs({ now = Date.now(), env = process.env } = {}) {
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
if (raw !== undefined && raw !== null && raw !== '' && Number.isFinite(deadline)) return deadline - now - SPEAK_DEADLINE_MARGIN_MS;
|
|
370
|
+
const deadline = jobDeadline(env);
|
|
371
|
+
if (deadline !== null) return deadline - now - speakReserveMs(deadline - now);
|
|
325
372
|
return LANE_WAIT_DEFAULT_MS;
|
|
326
373
|
}
|
|
327
374
|
|
|
@@ -334,8 +381,10 @@ function lanePositionLine(pos) {
|
|
|
334
381
|
|
|
335
382
|
/**
|
|
336
383
|
* Run one synthesis call `fn` (-> {ok, error?}) inside the voice lane of rv's voice.
|
|
337
|
-
* ctx: {root, kind, label, onLanePosition?}
|
|
338
|
-
*
|
|
384
|
+
* ctx: {root, kind, label, onLanePosition?, clock?, waitTurn?} (clock / waitTurn are test
|
|
385
|
+
* seams, default Date.now / voiceLane.waitTurn). Always leaves the lane; the usage line
|
|
386
|
+
* carries ok, audioSeconds (sum over `outs`' WAV headers) and wallMs. A lane-wait failure
|
|
387
|
+
* names the minutes left when it failed and the reserve fixed when the wait started.
|
|
339
388
|
*/
|
|
340
389
|
function inLane(ctx, rv, outs, fn) {
|
|
341
390
|
const lane = require('./voiceLane.cjs');
|
|
@@ -344,8 +393,14 @@ function inLane(ctx, rv, outs, fn) {
|
|
|
344
393
|
let granted = false;
|
|
345
394
|
let ok = false;
|
|
346
395
|
try {
|
|
347
|
-
const
|
|
348
|
-
const
|
|
396
|
+
const clock = typeof ctx.clock === 'function' ? ctx.clock : Date.now;
|
|
397
|
+
const waitTurn = typeof ctx.waitTurn === 'function' ? ctx.waitTurn : lane.waitTurn;
|
|
398
|
+
const now = clock();
|
|
399
|
+
const env = process.env;
|
|
400
|
+
const left = laneWaitMs({ now, env });
|
|
401
|
+
const deadline = jobDeadline(env);
|
|
402
|
+
const reserveMs = deadline === null ? undefined : speakReserveMs(deadline - now);
|
|
403
|
+
const w = waitTurn(ticket, {
|
|
349
404
|
timeoutMs: Math.max(1, left),
|
|
350
405
|
onPosition: (pos) => {
|
|
351
406
|
if (pos.position > 0) process.stderr.write(`${lanePositionLine(pos)}\n`);
|
|
@@ -353,8 +408,7 @@ function inLane(ctx, rv, outs, fn) {
|
|
|
353
408
|
},
|
|
354
409
|
});
|
|
355
410
|
if (!w.ok) {
|
|
356
|
-
|
|
357
|
-
return { ok: false, error: `${w.error}${why}` };
|
|
411
|
+
return { ok: false, error: `${w.error}${deadlineContext({ now: clock(), env, reserveMs })}` };
|
|
358
412
|
}
|
|
359
413
|
granted = true;
|
|
360
414
|
const r = fn();
|
|
@@ -408,21 +462,20 @@ function speakWithCommand(voice, text, out, { cwd } = {}) {
|
|
|
408
462
|
/**
|
|
409
463
|
* Time limit for one batch voice call over `lineCount` lines -> {ok: true, ms} | {ok: false, error}.
|
|
410
464
|
* ms = min(lineCount * COMMAND_TIMEOUT_MS, BATCH_TIMEOUT_CEILING_MS), capped at the scheduler's
|
|
411
|
-
* job deadline (env.SM_SCHEDULER_JOB_DEADLINE_MS) minus
|
|
465
|
+
* job deadline (env.SM_SCHEDULER_JOB_DEADLINE_MS) minus speakReserveMs(time left) when that is a
|
|
412
466
|
* finite number: the voice runs first, so the whole video is still to be built after it.
|
|
413
467
|
*/
|
|
414
468
|
function batchTimeoutMs(lineCount, { now = Date.now(), env = process.env } = {}) {
|
|
415
469
|
let ms = Math.min(lineCount * COMMAND_TIMEOUT_MS, BATCH_TIMEOUT_CEILING_MS);
|
|
416
|
-
const deadline =
|
|
417
|
-
const
|
|
418
|
-
if (
|
|
419
|
-
ms = Math.min(ms, deadline - now - SPEAK_DEADLINE_MARGIN_MS);
|
|
420
|
-
}
|
|
470
|
+
const deadline = jobDeadline(env);
|
|
471
|
+
const leftMs = deadline === null ? null : deadline - now;
|
|
472
|
+
if (leftMs !== null) ms = Math.min(ms, leftMs - speakReserveMs(leftMs));
|
|
421
473
|
if (ms < MIN_BATCH_TIMEOUT_MS) {
|
|
422
474
|
const left = Math.max(0, Math.floor(ms / 1000));
|
|
475
|
+
const ctx = deadlineContext({ now, env });
|
|
423
476
|
return {
|
|
424
477
|
ok: false,
|
|
425
|
-
error: `only ${left}s left
|
|
478
|
+
error: `only ${left}s left to speak for ${lineCount} lines${ctx}; need at least ${MIN_BATCH_TIMEOUT_MS / 1000}s`,
|
|
426
479
|
};
|
|
427
480
|
}
|
|
428
481
|
return { ok: true, ms };
|
|
@@ -649,7 +702,10 @@ module.exports = {
|
|
|
649
702
|
isBatchVoice,
|
|
650
703
|
wavSeconds,
|
|
651
704
|
laneWaitMs,
|
|
705
|
+
deadlineContext,
|
|
706
|
+
speakReserveMs,
|
|
652
707
|
lanePositionLine,
|
|
708
|
+
inLane,
|
|
653
709
|
LANE_WAIT_DEFAULT_MS,
|
|
654
710
|
validateCharacterJson,
|
|
655
711
|
validateCharacterJs,
|
|
@@ -62,7 +62,9 @@ Run the kit from `~/.claude/session-manager/demo-video-kit/` exactly as the pers
|
|
|
62
62
|
post-caption checks must all pass before you save.
|
|
63
63
|
- sound.cjs: mix the narration over the music bed; the bed is ducked under speech and the mix is
|
|
64
64
|
normalised to -14 LUFS. When the project has a saved character with a command voice, speak its
|
|
65
|
-
lines with `node character.cjs speak spec.json` first.
|
|
65
|
+
lines with `node character.cjs speak spec.json` first. Pass `projectRoot` (`$SM_PROJECT_ROOT`) in
|
|
66
|
+
its spec: a cue or the spec's `bed` may name one of the persona's own `sounds`, and an unknown name
|
|
67
|
+
fails the run; never swap in another sound.
|
|
66
68
|
- export.cjs: `node export.cjs spec.json` with `{ htmlPath, lengthS, audioPath, outDir }` writes
|
|
67
69
|
`video.mp4` (1080x1920, H.264/AAC) and `poster.png` in `outDir`. It must exit 0.
|
|
68
70
|
|
|
@@ -89,6 +91,8 @@ When the `Video target:` line names a series brief file:
|
|
|
89
91
|
1. Read the brief, then every season, canon and ledger file it names.
|
|
90
92
|
2. Make the next episode exactly as they say: its premise, cast, topic and beats. Follow the
|
|
91
93
|
brief's topic; never invent a premise, never pick an episode the files do not schedule.
|
|
94
|
+
Keep its sound too: every sound cue at its time and its music as the sound.cjs `bed`,
|
|
95
|
+
by the names the files use.
|
|
92
96
|
3. Use the project persona for the host and voice; never borrow another project's characters.
|
|
93
97
|
4. When the files have no next episode left, in the review stage or the final stage alike,
|
|
94
98
|
call `project_video_outcome_write` once with `{ videoId: <the Entry id>, outcome:
|