claude-code-session-manager 0.144.0 → 0.146.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/dist/assets/{AppSettings-Z68gQiVE.js → AppSettings-BXfkoKQq.js} +2 -2
- package/dist/assets/{History-C3E6y_7t.js → History-l7pBt_vO.js} +1 -1
- package/dist/assets/HomeClaudeConfig-DtFwZxTx.js +5 -0
- package/dist/assets/{Panel-CnfWs46Z.js → Panel-C5hihgUD.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-CP0Wsg-H.js → ProjectClaudeConfig-B3pODrM-.js} +1 -1
- package/dist/assets/{Scheduler-D8un7N3B.js → Scheduler-IU9wo8_u.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-DRtZV1Al.js → SkillReferenceGraph-Bmen0OOC.js} +1 -1
- package/dist/assets/{Skills-Bg5O2Hyn.js → Skills-jYVxqJr2.js} +1 -1
- package/dist/assets/{TiptapBody-BdzoBmqu.js → TiptapBody-Dp2gtbb-.js} +1 -1
- package/dist/assets/{Toggle-Dt5K1OXt.js → Toggle-C_0yUCS5.js} +1 -1
- package/dist/assets/{VoiceButton-CTLyRgdF.js → VoiceButton-BRPzqDa-.js} +1 -1
- package/dist/assets/{historyTotals-B2_KWBga.js → historyTotals-pAv-MFnY.js} +1 -1
- package/dist/assets/{index-446b69rr.js → index-C6nhp7m_.js} +496 -496
- package/dist/index.html +1 -1
- package/dist-web/app.js +427 -427
- package/package.json +1 -1
- package/plugins/session-manager-dev/skills/develop/SKILL.md +11 -6
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +1 -1
- package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +8 -4
- package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +13 -8
- package/scripts/scheduler-mcp-server.cjs +4 -3
- package/src/main/adminRouteRegistry.cjs +1 -1
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +35 -5
- package/src/main/config.cjs +12 -0
- package/src/main/index.cjs +2 -2
- package/src/main/ipcSchemas.cjs +5 -0
- package/src/main/lib/claude/claudeJsonApproval.cjs +129 -0
- package/src/main/lib/claude/headlessMcpServers.cjs +1 -1
- package/src/main/lib/claude/personaToolScope.cjs +23 -8
- package/src/main/lib/demo-video-kit/resumableRun.cjs +36 -15
- package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
- package/src/main/lib/epic/epicOutsideRead.cjs +43 -8
- package/src/main/lib/epic/epicSpawnCwd.cjs +1 -0
- package/src/main/lib/epic/planReviewInput.cjs +5 -6
- package/src/main/lib/epic/scriptStartedBy.cjs +19 -4
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +219 -48
- package/src/main/lib/feedback-remote/localAdminHttp.cjs +5 -1
- package/src/main/lib/feedback-remote/serviceMcpSession.cjs +6 -3
- package/src/main/lib/feedback-remote/serviceMcpTools.cjs +23 -3
- package/src/main/lib/feedback-remote/servicePairings.cjs +48 -0
- package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +11 -6
- package/src/main/lib/git/gitWorktree.cjs +17 -0
- package/src/main/lib/mcpToolCatalog.cjs +6 -3
- package/src/main/lib/opsOwnership.cjs +2 -0
- package/src/main/lib/prd/prdCreate.cjs +2 -1
- package/src/main/lib/prd/prdMcpReachWarnings.cjs +3 -1
- package/src/main/lib/prd/prdSandboxWarnings.cjs +1 -1
- package/src/main/lib/scheduler/planReleaseRoute.cjs +53 -5
- package/src/main/lib/scheduler/planReviewStore.cjs +24 -2
- package/src/main/lib/scheduler/rcaReport.cjs +1 -0
- package/src/main/lib/scheduler/reviewNotice.cjs +3 -1
- package/src/main/lib/scheduler/terminalRunOutcome.cjs +1 -0
- package/src/main/lib/tasks/memoryConsolidation.cjs +21 -12
- package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +131 -11
- package/src/main/runVerify.cjs +107 -3
- package/src/main/scheduler/gitTreeGuard.cjs +6 -0
- package/src/main/scheduler/planReviewHold.cjs +11 -5
- package/src/main/scheduler/prdPaths.cjs +10 -1
- package/src/main/scheduler.cjs +230 -27
- package/src/main/templates/PRD_AUTHORING.md +2 -2
- package/src/main/webRemote.cjs +22 -0
- package/src/preload/api.d.ts +8 -0
- package/src/preload/apiSurface.json +11 -0
- package/src/preload/index.cjs +2 -0
- package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-session-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.146.0",
|
|
4
4
|
"description": "Free desktop app for Claude Code: run many sessions, each in its own git worktree; queue work that runs headless within your usage limits; agents drive it through an MCP server and skills.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main/index.cjs",
|
|
@@ -85,11 +85,13 @@ three failure modes have different fixes:
|
|
|
85
85
|
human to start the app, then retry the same call. Why: a PRD file the API did not write is
|
|
86
86
|
quarantined and never runs.
|
|
87
87
|
- **(b) Create errors with "did not answer" or "Connection closed".** It may still have been written; retry the same call with the same slug (it returns the existing PRD with `alreadyExisted: true`, or per entry `applied`) and never re-issue it under a new slug. `scheduler_get_prd` accepts the bare slug.
|
|
88
|
-
- **(c) Tool ABSENT from your tool list.**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
- **(c) Tool ABSENT from your tool list.** A **misconfiguration**, not an offline app.
|
|
89
|
+
**STOP. Do not write any PRD file.** Diagnose first: run `claude mcp get session-manager-scheduler`.
|
|
90
|
+
If it shows **Connected**, the server is registered and the chat's gear scope hid it: look for
|
|
91
|
+
a `Gear:` notice in the chat and report it to the human as a Session Manager gear bug. Never
|
|
92
|
+
delete the seeded marker or restart for it. Only if it is NOT registered: the app registers it
|
|
93
|
+
at user scope on first start; the human deletes `~/.claude/session-manager/.scheduler-mcp-seeded`,
|
|
94
|
+
restarts the app, and opens a new session.
|
|
93
95
|
Never add a project `.mcp.json` entry yourself. Why: it brings back per-repo drift.
|
|
94
96
|
|
|
95
97
|
### Steps
|
|
@@ -186,7 +188,7 @@ Never pass `parallelGroup`; it is ignored. The API writes the frontmatter, `# Fi
|
|
|
186
188
|
### gate and files rules
|
|
187
189
|
|
|
188
190
|
The syntax rules for `gate` and `files` are in PRD_AUTHORING.md §6, and the API enforces them: it
|
|
189
|
-
refuses a bad gate or path and returns warnings — read them and fix the input.
|
|
191
|
+
refuses a bad gate or path and returns warnings — read them and fix the input. Three rules only you
|
|
190
192
|
can apply, because they depend on the repo at authoring time:
|
|
191
193
|
|
|
192
194
|
1. Before queueing, run each gate command once at the current HEAD in the main checkout. If it
|
|
@@ -198,6 +200,9 @@ can apply, because they depend on the repo at authoring time:
|
|
|
198
200
|
criterion; keep them out of PRDs at authoring time (PRD_AUTHORING.md §14, No human-only gates).
|
|
199
201
|
Live-run steps that need gitignored state follow PRD_AUTHORING.md §7 (absolute main-checkout
|
|
200
202
|
paths, artifact-only).
|
|
203
|
+
3. Never list a path under `.claude/agents`, `commands`, `skills`, `hooks` or `settings*.json` in
|
|
204
|
+
`files`: the job sandbox refuses every write there, so the architect makes that edit inline
|
|
205
|
+
in the Epic chat (PRD_AUTHORING.md#job-sandbox-limits).
|
|
201
206
|
|
|
202
207
|
### What a headless run cannot do
|
|
203
208
|
|
|
@@ -81,6 +81,6 @@ Weekly consolidation
|
|
|
81
81
|
- [ ] Look for a pending weekly Task record; walk it if found (weekly-consolidation.md)
|
|
82
82
|
- [ ] Else gather memory, network, transcripts, Lessons blocks, steering file
|
|
83
83
|
- [ ] Subagents find patterns; keep those seen in 2+ sessions
|
|
84
|
-
- [ ] Write the record: verify, organize, enrich changes plus housekeeping
|
|
84
|
+
- [ ] Write the record: verify, organize, enrich, procedure changes plus housekeeping
|
|
85
85
|
- [ ] Owner accepts or rejects each change; apply only accepted ones, commit the record
|
|
86
86
|
```
|
|
@@ -40,10 +40,13 @@ Each kept pattern becomes ONE change of one kind:
|
|
|
40
40
|
- **verify:** a memory or doc line no longer true is fixed or removed.
|
|
41
41
|
- **organize:** duplicates are merged; a lasting fact moves from memory into the doc that owns it (placement.md).
|
|
42
42
|
- **enrich:** a missing lesson is added.
|
|
43
|
+
- **procedure:** a new skill or small tool is proposed for a multi-step procedure that was worked out by hand (the same steps rebuilt from scratch, not run from a doc) in at least 2 sessions in the window. The proposal names the skill's path, when to use it, its steps, and the files or commands it relies on; a tool instead names its path and the README line that lists it. Before you propose one, search the project's existing skills (`.claude/skills/`, `plugins/*/skills/`), tools and docs for the same procedure. If one already covers it, propose an edit to that file as **organize** instead, never a second skill. A pattern that repeats a single step, or that only produced a lesson, stays enrich.
|
|
43
44
|
|
|
44
45
|
## Keep learnings few
|
|
45
46
|
|
|
46
|
-
- At most 5
|
|
47
|
+
- At most 5 adds per run: enrich and procedure together.
|
|
48
|
+
- At most 1 procedure per run. If more than one qualifies, propose the one seen in the most sessions; the rest produce no change.
|
|
49
|
+
- A run with no procedure rebuilt by hand in 2+ sessions proposes none.
|
|
47
50
|
- Merges and removals are unlimited.
|
|
48
51
|
- Prefer pruning.
|
|
49
52
|
|
|
@@ -70,18 +73,19 @@ Template:
|
|
|
70
73
|
| Id | Kind | Target file | Change | Example sessions | Count |
|
|
71
74
|
| --- | --- | --- | --- | --- | --- |
|
|
72
75
|
| c1 | verify / organize / enrich | <path> | <the change> | <id>, <id> | <N, at least 2> |
|
|
76
|
+
| c2 | procedure | <proposed skill or tool path> | <name; when to use it; steps; files or commands it relies on; README line for a tool> | <id>, <id> | <N, at least 2> |
|
|
73
77
|
```
|
|
74
78
|
|
|
75
|
-
Every row names at least 2 session ids.
|
|
79
|
+
Every row names at least 2 session ids. A procedure row counts as an add in Totals.
|
|
76
80
|
|
|
77
81
|
## Apply
|
|
78
82
|
|
|
79
83
|
1. The owner accepts or rejects each change. Only accepted changes are applied.
|
|
80
|
-
2. The architect applies them in the Epic the owner opened with the macro: memory edits inline; doc changes inline when small and provable, otherwise `/develop`.
|
|
84
|
+
2. The architect applies them in the Epic the owner opened with the macro: memory edits inline; doc changes inline when small and provable, otherwise `/develop`. An accepted procedure row whose path is under `.claude/` (a skill) is written from the Epic chat, never by a PRD: headless job sandboxes mount `.claude/` read-only. A tool outside `.claude/` may go through `/develop`.
|
|
81
85
|
3. Commit the record as session-manager-operations/reviews/docs/<YYYY-MM-DD>-md-network-weekly.md, following the record rules in drift-check.md.
|
|
82
86
|
|
|
83
87
|
When pressed with Mode 'Weekly consolidation', first look for the newest pending weekly Task (`task_list` with pipeline memory-consolidation, then `task_get` for its output) and walk its record. If none is pending, run the pass in the Epic.
|
|
84
88
|
|
|
85
89
|
## Steering file
|
|
86
90
|
|
|
87
|
-
Optional: session-manager-operations/md-network/steering.md. A human writes it and tracks it in git; it says what the owner thinks matters and does not.
|
|
91
|
+
Optional: session-manager-operations/md-network/steering.md. A human writes it and tracks it in git; it says what the owner thinks matters and does not. The app reads it through `opsPath()`; it is declared `tracked` in `GIT_CLASS` with an ops AGENTS.md row. It has no owning writer (human-authored), so it gets no `OWNERS` entry.
|
|
@@ -62,8 +62,10 @@ feedback_list_projects()
|
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
Returns every project on this machine that can receive feedback (each already
|
|
65
|
-
has a `session-manager-operations/` directory)
|
|
66
|
-
|
|
65
|
+
has a `session-manager-operations/` directory), paged (`total`, `hasMore`; pass
|
|
66
|
+
`offset` for the next page). Match the user's name for the project against a
|
|
67
|
+
real `cwd` from that list. When you already have a path, check it with
|
|
68
|
+
`feedback_list_projects({ cwd })` — `lookup.canReceive` is the exact answer.
|
|
67
69
|
|
|
68
70
|
If the project you want is **absent**, it has simply never been opened in
|
|
69
71
|
Session Manager. Do not invent a path and do not create the directory. Tell the
|
|
@@ -241,9 +243,12 @@ Two distinct failure modes — don't conflate them:
|
|
|
241
243
|
`active-index.json` is exactly the racing second writer the single-writer law
|
|
242
244
|
exists to prevent. Tell the human to start the app, and report the finding to
|
|
243
245
|
them in the meantime so it isn't lost.
|
|
244
|
-
- **`feedback_open_session` is absent from your tool list entirely** —
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
- **`feedback_open_session` is absent from your tool list entirely** —
|
|
247
|
+
a misconfiguration, not an offline app. STOP: never hand-write the session.
|
|
248
|
+
Diagnose first: run `claude mcp get session-manager-scheduler`. If it shows
|
|
249
|
+
**Connected**, the server is registered and the chat's gear scope hid it —
|
|
250
|
+
look for a `Gear:` notice in the chat and report it to the human as a Session
|
|
251
|
+
Manager gear bug; never delete the seeded marker or restart for it. Only if it
|
|
252
|
+
is NOT registered: the app registers it at user scope on first start; delete
|
|
253
|
+
`~/.claude/session-manager/.scheduler-mcp-seeded`, restart the app, and open a
|
|
254
|
+
new session. Never add a project `.mcp.json` / MCP entry yourself.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* scheduler_create_prd({ ... }) -> POST /admin/scheduler/create-prd
|
|
10
10
|
*
|
|
11
|
-
* feedback_list_projects()
|
|
11
|
+
* feedback_list_projects({cwd?,limit?,offset?}) -> GET /admin/feedback/targets
|
|
12
12
|
* feedback_open_session({ ... }) -> POST /admin/feedback/open-session
|
|
13
13
|
* feedback_reply({ message, outcome, ... }) -> POST /admin/feedback/reply
|
|
14
14
|
*
|
|
@@ -76,7 +76,7 @@ const { MCP_TOOL_CATALOG, MCP_RECIPES, composeDescription, FIXES_INPUT_SCHEMA }
|
|
|
76
76
|
// Shared with paired services (serviceMcpTools.cjs) so both see the same
|
|
77
77
|
// schemas. Its service-only tools (macro_run, events_read) are never listed here.
|
|
78
78
|
const {
|
|
79
|
-
FEEDBACK_LIST_PROJECTS_INPUT_SCHEMA, FEEDBACK_OPEN_SESSION_INPUT_SCHEMA, MACRO_LIST_INPUT_SCHEMA, EPIC_GET_INPUT_SCHEMA,
|
|
79
|
+
FEEDBACK_LIST_PROJECTS_INPUT_SCHEMA, feedbackListProjectsQuery, FEEDBACK_OPEN_SESSION_INPUT_SCHEMA, MACRO_LIST_INPUT_SCHEMA, EPIC_GET_INPUT_SCHEMA,
|
|
80
80
|
} = require('../src/main/lib/feedback-remote/serviceMcpTools.cjs');
|
|
81
81
|
const { SERVICE_TOOL_NAMES } = require('../src/main/lib/feedback-remote/servicePairings.cjs');
|
|
82
82
|
const { EPIC_OUTSIDE_STATES } = require('../src/main/lib/epic/epicOutsideState.cjs');
|
|
@@ -2133,7 +2133,8 @@ async function handleCallTool(request) {
|
|
|
2133
2133
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
2134
2134
|
}
|
|
2135
2135
|
if (name === 'feedback_list_projects') {
|
|
2136
|
-
const
|
|
2136
|
+
const qs = new URLSearchParams(feedbackListProjectsQuery(args)).toString();
|
|
2137
|
+
const result = await adminRequest('GET', `/admin/feedback/targets${qs ? `?${qs}` : ''}`);
|
|
2137
2138
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
2138
2139
|
}
|
|
2139
2140
|
if (name === 'feedback_open_session') {
|
|
@@ -44,7 +44,7 @@ function registerAppAdminRoutes(adminHttp, deps = {}) {
|
|
|
44
44
|
// Project-to-project feedback conduit — the app is the only process holding
|
|
45
45
|
// several projects' operations roots open, so it performs the cross-folder
|
|
46
46
|
// write (lib/feedback-remote/crossProjectFeedback.cjs).
|
|
47
|
-
require('./lib/feedback-remote/crossProjectFeedback.cjs').registerAdminRoute(adminHttp);
|
|
47
|
+
require('./lib/feedback-remote/crossProjectFeedback.cjs').registerAdminRoute(adminHttp, { warmTargetsAfterMs: 60_000 });
|
|
48
48
|
// POST /admin/projects/create — a paired service's new local (+ private GitHub) project; broadcasts `projects:created`.
|
|
49
49
|
require('./lib/feedback-remote/projectCreate.cjs').registerAdminRoute(adminHttp);
|
|
50
50
|
// POST /admin/services/pair-local[/confirm] — same-machine service pairing with no window step.
|
package/src/main/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"gitSha": "
|
|
4
|
-
"gitShortSha": "
|
|
2
|
+
"version": "0.146.0",
|
|
3
|
+
"gitSha": "c056543b79977edaf33caef22701c57173afb42d",
|
|
4
|
+
"gitShortSha": "c056543b",
|
|
5
5
|
"gitBranch": "HEAD",
|
|
6
|
-
"builtAt": "2026-11-
|
|
6
|
+
"builtAt": "2026-11-28T07:55:22.582Z",
|
|
7
7
|
"dirty": false
|
|
8
8
|
}
|
package/src/main/chatRunner.cjs
CHANGED
|
@@ -56,7 +56,7 @@ 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
|
+
const { buildPersonaToolScope, personaToolScopeArgs, skillDenyArgs, HEADLESS_SCOPE_AGENT_NAME, CHAT_HARNESS_MCP_SERVERS } = require('./lib/claude/personaToolScope.cjs');
|
|
60
60
|
const epicWorktreeMint = require('./lib/epic/epicWorktreeMint.cjs');
|
|
61
61
|
const epicDepsSync = require('./lib/epic/epicDepsSync.cjs');
|
|
62
62
|
const logs = require('./logs.cjs');
|
|
@@ -1689,6 +1689,29 @@ function registerChatHandlers() {
|
|
|
1689
1689
|
|
|
1690
1690
|
const undecidedLogged = new Set();
|
|
1691
1691
|
|
|
1692
|
+
/**
|
|
1693
|
+
* Servers in the argv's --mcp-config that no --agents tools entry (mcp__<s> or mcp__<s>__*) grants.
|
|
1694
|
+
* [] when either flag is absent or unparseable. Pure.
|
|
1695
|
+
* @param {string[]} args
|
|
1696
|
+
* @returns {string[]}
|
|
1697
|
+
*/
|
|
1698
|
+
function ungrantedMcpServers(args) {
|
|
1699
|
+
if (!Array.isArray(args)) return [];
|
|
1700
|
+
const ai = args.indexOf('--agents');
|
|
1701
|
+
const mi = args.indexOf('--mcp-config');
|
|
1702
|
+
if (ai < 0 || mi < 0) return [];
|
|
1703
|
+
let tools; let servers;
|
|
1704
|
+
try {
|
|
1705
|
+
const agents = JSON.parse(args[ai + 1]);
|
|
1706
|
+
const def = agents && agents[HEADLESS_SCOPE_AGENT_NAME];
|
|
1707
|
+
tools = def && Array.isArray(def.tools) ? def.tools.map(String) : null;
|
|
1708
|
+
servers = Object.keys((JSON.parse(args[mi + 1]) || {}).mcpServers || {});
|
|
1709
|
+
} catch { return []; }
|
|
1710
|
+
if (!tools) return [];
|
|
1711
|
+
const granted = new Set(tools.filter((t) => t.startsWith('mcp__')).map((t) => t.slice(5).split('__')[0]));
|
|
1712
|
+
return servers.filter((s) => !granted.has(s));
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1692
1715
|
/**
|
|
1693
1716
|
* Gear for a chat turn (PRD 4768): the argv that gives an Epic whose pinned snapshot carries
|
|
1694
1717
|
* `gearBindsChat` the same scope a job gets — persona tools, strict MCP with the declared servers,
|
|
@@ -1697,7 +1720,7 @@ const undecidedLogged = new Set();
|
|
|
1697
1720
|
* An unknown declared server/pack never crashes the turn: it is dropped and reported in `errors`.
|
|
1698
1721
|
* Pure apart from reading ~/.claude.json and <cwd>/.mcp.json (declared servers), the pack catalog and the seeded MCP entry (injectable for tests).
|
|
1699
1722
|
* `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
|
|
1723
|
+
* @param {{ snapshot: any, cwd?: string, projectRoot?: string, deps?: { home?: string, knownMcpServers?: Record<string, object>, listPacks?: () => { packs: any[] }, listUnpackedSkills?: () => string[], log?: (msg: string) => void, scopeArgs?: typeof personaToolScopeArgs } }} opts
|
|
1701
1724
|
* @returns {{ args: string[], errors: string[] }}
|
|
1702
1725
|
*/
|
|
1703
1726
|
function gearChatArgs({ snapshot, cwd, projectRoot, deps = {} }) {
|
|
@@ -1729,9 +1752,13 @@ function gearChatArgs({ snapshot, cwd, projectRoot, deps = {} }) {
|
|
|
1729
1752
|
try { unpacked = (deps.listUnpackedSkills || require('./lib/packs/packCatalog.cjs').listUnpackedSkills)(); } catch { unpacked = []; }
|
|
1730
1753
|
const packs = Array.isArray(snapshot.packs) ? snapshot.packs.map(String) : [];
|
|
1731
1754
|
const knownPackIds = new Set(catalog.map((p) => String(p.id)));
|
|
1732
|
-
const
|
|
1755
|
+
const personaDeclared = Array.isArray(snapshot.mcpServers) ? snapshot.mcpServers.map(String) : [];
|
|
1756
|
+
// SM's own harness rides every scoped chat; the scheduler is always kept so its absence is reported below.
|
|
1757
|
+
const harness = CHAT_HARNESS_MCP_SERVERS.filter((n) => n === 'session-manager-scheduler' || Object.prototype.hasOwnProperty.call(known || {}, n));
|
|
1758
|
+
const declared = [...new Set([...personaDeclared, ...harness])];
|
|
1733
1759
|
const scope = buildPersonaToolScope(snapshot.tools, { loadout, disallowed: [] });
|
|
1734
|
-
const
|
|
1760
|
+
const scopeFn = deps.scopeArgs || personaToolScopeArgs;
|
|
1761
|
+
const attempt = scopeFn(scope, { mcpServers: known, declaredServers: declared, packs, knownPacks: [...knownPackIds] });
|
|
1735
1762
|
/** @type {string[]} */ const errors = [];
|
|
1736
1763
|
let scopeArgs = attempt.args;
|
|
1737
1764
|
let equipped = packs;
|
|
@@ -1752,12 +1779,14 @@ function gearChatArgs({ snapshot, cwd, projectRoot, deps = {} }) {
|
|
|
1752
1779
|
curDeclared = curDeclared.filter((d) => d !== r.name);
|
|
1753
1780
|
curPacks = curPacks.filter((p) => p !== r.name);
|
|
1754
1781
|
curScope = curScope ? { tools: curScope.tools.filter((t) => !(t.startsWith('mcp__') && t.slice(5).split('__')[0] === r.name) && t !== r.name) } : curScope;
|
|
1755
|
-
cur =
|
|
1782
|
+
cur = scopeFn(curScope, { mcpServers: known, declaredServers: curDeclared, packs: curPacks, knownPacks: [...knownPackIds] });
|
|
1756
1783
|
r = cur.refusal;
|
|
1757
1784
|
}
|
|
1758
1785
|
scopeArgs = cur.args;
|
|
1759
1786
|
equipped = curPacks;
|
|
1760
1787
|
}
|
|
1788
|
+
// A loaded-but-ungranted server is invisible to the CLI (even ToolSearch) — never omit it silently.
|
|
1789
|
+
for (const name of ungrantedMcpServers(scopeArgs)) errors.push(`Gear: "${name}" was loaded but not granted to this chat's tools; its tools are unavailable this turn.`);
|
|
1761
1790
|
const installedSkills = [...new Set([...catalog.flatMap((p) => p.skills || []), ...unpacked].map(String))];
|
|
1762
1791
|
const deny = skillDenyArgs({ installedSkills, equippedPacks: equipped, packCatalog: catalog, loadout });
|
|
1763
1792
|
return { args: [...scopeArgs, ...deny], errors };
|
|
@@ -1775,6 +1804,7 @@ module.exports = {
|
|
|
1775
1804
|
noteChatRunOrigin,
|
|
1776
1805
|
turnInstructionFor,
|
|
1777
1806
|
gearChatArgs,
|
|
1807
|
+
ungrantedMcpServers,
|
|
1778
1808
|
shouldFollowUp,
|
|
1779
1809
|
parseStopSignal,
|
|
1780
1810
|
splitStopSignal,
|
package/src/main/config.cjs
CHANGED
|
@@ -79,6 +79,17 @@ function addAllowedRoot(dir) {
|
|
|
79
79
|
if (dir) allowedRoots.add(pathFor().resolve(dir));
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Remove a root registered via addAllowedRoot (same normalization). Returns
|
|
84
|
+
* true when one was removed; the built-in home root is never removed.
|
|
85
|
+
*/
|
|
86
|
+
function removeAllowedRoot(dir) {
|
|
87
|
+
if (!dir) return false;
|
|
88
|
+
const abs = pathFor().resolve(dir);
|
|
89
|
+
if (abs === pathFor().resolve(os.homedir())) return false;
|
|
90
|
+
return allowedRoots.delete(abs);
|
|
91
|
+
}
|
|
92
|
+
|
|
82
93
|
/** Snapshot of the registered roots (main-process-registered only). */
|
|
83
94
|
function getAllowedRoots() {
|
|
84
95
|
return [...allowedRoots];
|
|
@@ -703,6 +714,7 @@ module.exports = {
|
|
|
703
714
|
listDir,
|
|
704
715
|
exists,
|
|
705
716
|
addAllowedRoot,
|
|
717
|
+
removeAllowedRoot,
|
|
706
718
|
getAllowedRoots,
|
|
707
719
|
registerPromptSessionsRoot,
|
|
708
720
|
transitionEpicArchiveWrite,
|
package/src/main/index.cjs
CHANGED
|
@@ -1598,7 +1598,7 @@ app.whenReady().then(async () => {
|
|
|
1598
1598
|
label: 'Help',
|
|
1599
1599
|
submenu: [
|
|
1600
1600
|
{
|
|
1601
|
-
label: 'Book a Free
|
|
1601
|
+
label: 'Book a Free Consultation',
|
|
1602
1602
|
click: () => {
|
|
1603
1603
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
|
1604
1604
|
sendIfAlive(mainWindow, 'app:open-free-hour');
|
|
@@ -1791,7 +1791,7 @@ app.whenReady().then(async () => {
|
|
|
1791
1791
|
// ~/.claude/projects scan, banned on timer paths); a project with no
|
|
1792
1792
|
// subscriptions is a no-op.
|
|
1793
1793
|
const runWebhookDelivery = () => {
|
|
1794
|
-
scheduler.readQueue()
|
|
1794
|
+
Promise.resolve().then(() => scheduler.readQueue())
|
|
1795
1795
|
.then((q) => require('./lib/telemetry/webhookDelivery.cjs').runDeliveryPass({
|
|
1796
1796
|
cwds: (Array.isArray(q?.jobs) ? q.jobs : []).map((j) => j && j.cwd).filter((c) => typeof c === 'string' && c),
|
|
1797
1797
|
logs,
|
package/src/main/ipcSchemas.cjs
CHANGED
|
@@ -1575,6 +1575,10 @@ const webRemoteServicePairCancel = z.object({
|
|
|
1575
1575
|
const webRemoteServiceRevoke = z.object({
|
|
1576
1576
|
serviceId: z.string().regex(WEB_REMOTE_UUID_RE),
|
|
1577
1577
|
}).strict();
|
|
1578
|
+
const webRemoteServiceSetStartWork = z.object({
|
|
1579
|
+
serviceId: z.string().regex(WEB_REMOTE_UUID_RE),
|
|
1580
|
+
targets: z.array(z.string().min(1).max(4096)).max(200),
|
|
1581
|
+
}).strict();
|
|
1578
1582
|
const webRemoteRelayClientRevoke = z.object({
|
|
1579
1583
|
clientId: z.string().uuid(),
|
|
1580
1584
|
}).strict();
|
|
@@ -1908,6 +1912,7 @@ module.exports = {
|
|
|
1908
1912
|
webRemoteServiceConfirmSas,
|
|
1909
1913
|
webRemoteServicePairCancel,
|
|
1910
1914
|
webRemoteServiceRevoke,
|
|
1915
|
+
webRemoteServiceSetStartWork,
|
|
1911
1916
|
webRemoteRelayClientRevoke,
|
|
1912
1917
|
sessionSubscribe,
|
|
1913
1918
|
ptySpawn,
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* Copy Claude Code's CLAUDE.md external-include approval from a parent project
|
|
4
|
+
* path to a new worktree path in the global config (~/.claude.json).
|
|
5
|
+
*
|
|
6
|
+
* Why: Claude Code (2.1.330) keys `projects[<path>]` by the session's own git
|
|
7
|
+
* root (`git rev-parse --show-toplevel`), so each new Epic/job worktree starts
|
|
8
|
+
* without `hasClaudeMdExternalIncludesApproved` and silently skips @-imports
|
|
9
|
+
* that resolve outside the repo (e.g. symlinked contracts).
|
|
10
|
+
*
|
|
11
|
+
* Concurrency: Claude Code holds the `<file>.lock` directory (proper-lockfile
|
|
12
|
+
* mkdir protocol) while it writes; we take the same lock, re-read fresh under
|
|
13
|
+
* it, and write atomically (tmp + rename) so no concurrent write is lost.
|
|
14
|
+
* hasTrustDialogAccepted is never copied.
|
|
15
|
+
*/
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const os = require('os');
|
|
18
|
+
const path = require('path');
|
|
19
|
+
const { writeTextAtomic, writeTextAtomicSync } = require('../util/atomicFs.cjs');
|
|
20
|
+
|
|
21
|
+
const STALE_MS = 10000;
|
|
22
|
+
const WAIT_MS = 2000;
|
|
23
|
+
const A = 'hasClaudeMdExternalIncludesApproved';
|
|
24
|
+
const W = 'hasClaudeMdExternalIncludesWarningShown';
|
|
25
|
+
|
|
26
|
+
function claudeJsonPath(env = process.env) {
|
|
27
|
+
if (env && env.CLAUDE_CONFIG_DIR) return path.join(env.CLAUDE_CONFIG_DIR, '.claude.json');
|
|
28
|
+
return path.join(os.homedir(), '.claude.json');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parentEntry(projects, fromPath) {
|
|
32
|
+
const key = path.resolve(fromPath);
|
|
33
|
+
if (projects[key]) return projects[key];
|
|
34
|
+
try {
|
|
35
|
+
const real = fs.realpathSync(key);
|
|
36
|
+
return projects[real];
|
|
37
|
+
} catch { return undefined; }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Return `config` with the parent project's external-include approval copied
|
|
42
|
+
* onto `toPath`'s project entry (unchanged `config` when there is nothing to
|
|
43
|
+
* copy). Does not mutate `config` and never writes a file, but it is not pure:
|
|
44
|
+
* when the parent key is absent it may call `fs.realpathSync` to resolve the
|
|
45
|
+
* parent key through symlinks.
|
|
46
|
+
*/
|
|
47
|
+
function applyApproval(config, fromPath, toPath) {
|
|
48
|
+
if (!config || typeof config !== 'object' || !config.projects || typeof config.projects !== 'object') return config;
|
|
49
|
+
const fromKey = path.resolve(fromPath);
|
|
50
|
+
const toKey = path.resolve(toPath);
|
|
51
|
+
if (fromKey === toKey) return config;
|
|
52
|
+
const parent = parentEntry(config.projects, fromPath);
|
|
53
|
+
if (!parent || parent[A] !== true) return config;
|
|
54
|
+
const existing = config.projects[toKey];
|
|
55
|
+
if (existing && existing[A] === true && existing[W] === true) return config;
|
|
56
|
+
const base = existing && typeof existing === 'object' ? existing : {
|
|
57
|
+
allowedTools: [], mcpContextUris: [], mcpServers: {}, enabledMcpjsonServers: [],
|
|
58
|
+
disabledMcpjsonServers: [], hasTrustDialogAccepted: false,
|
|
59
|
+
};
|
|
60
|
+
return { ...config, projects: { ...config.projects, [toKey]: { ...base, [A]: true, [W]: true } } };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** @returns {'ok'|'retry'} */
|
|
64
|
+
function tryLock(lockDir) {
|
|
65
|
+
try { fs.mkdirSync(lockDir); return 'ok'; } catch (e) {
|
|
66
|
+
if (e.code !== 'EEXIST') throw e;
|
|
67
|
+
try {
|
|
68
|
+
if (Date.now() - fs.statSync(lockDir).mtimeMs > STALE_MS) { fs.rmdirSync(lockDir); return tryLock(lockDir); }
|
|
69
|
+
} catch { /* vanished or raced; retry */ }
|
|
70
|
+
return 'retry';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function sleepSync(ms) { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms); }
|
|
75
|
+
const jitter = () => 25 + Math.floor(Math.random() * 25);
|
|
76
|
+
|
|
77
|
+
function prepare(configPath, fromPath, toPath) {
|
|
78
|
+
let raw; let stat;
|
|
79
|
+
try { stat = fs.statSync(configPath); raw = fs.readFileSync(configPath, 'utf8'); } catch (e) {
|
|
80
|
+
if (e.code === 'ENOENT') return { result: { ok: false, reason: 'missing' } };
|
|
81
|
+
return { result: { ok: false, reason: 'unreadable' } };
|
|
82
|
+
}
|
|
83
|
+
let config;
|
|
84
|
+
try { config = JSON.parse(raw); } catch { return { result: { ok: false, reason: 'unparseable' } }; }
|
|
85
|
+
const next = applyApproval(config, fromPath, toPath);
|
|
86
|
+
if (next === config) return { result: { ok: true, changed: false } };
|
|
87
|
+
const text = JSON.stringify(next, null, 2) + (raw.endsWith('\n') ? '\n' : '');
|
|
88
|
+
return { text, mode: stat.mode & 0o777 };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function copyExternalIncludeApproval({ fromPath, toPath, configPath } = {}) {
|
|
92
|
+
const file = configPath || claudeJsonPath();
|
|
93
|
+
const lockDir = `${file}.lock`;
|
|
94
|
+
try {
|
|
95
|
+
if (!fs.existsSync(file)) return { ok: false, reason: 'missing' };
|
|
96
|
+
const t0 = Date.now();
|
|
97
|
+
while (tryLock(lockDir) !== 'ok') {
|
|
98
|
+
if (Date.now() - t0 >= WAIT_MS) return { ok: false, reason: 'lock-timeout' };
|
|
99
|
+
await new Promise((r) => setTimeout(r, jitter()));
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const p = prepare(file, fromPath, toPath);
|
|
103
|
+
if (p.result) return p.result;
|
|
104
|
+
await writeTextAtomic(file, p.text, { mode: p.mode });
|
|
105
|
+
return { ok: true, changed: true };
|
|
106
|
+
} finally { try { fs.rmdirSync(lockDir); } catch { /* already gone */ } }
|
|
107
|
+
} catch (e) { return { ok: false, reason: String((e && e.message) || e) }; }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function copyExternalIncludeApprovalSync({ fromPath, toPath, configPath } = {}) {
|
|
111
|
+
const file = configPath || claudeJsonPath();
|
|
112
|
+
const lockDir = `${file}.lock`;
|
|
113
|
+
try {
|
|
114
|
+
if (!fs.existsSync(file)) return { ok: false, reason: 'missing' };
|
|
115
|
+
const t0 = Date.now();
|
|
116
|
+
while (tryLock(lockDir) !== 'ok') {
|
|
117
|
+
if (Date.now() - t0 >= WAIT_MS) return { ok: false, reason: 'lock-timeout' };
|
|
118
|
+
sleepSync(jitter());
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const p = prepare(file, fromPath, toPath);
|
|
122
|
+
if (p.result) return p.result;
|
|
123
|
+
writeTextAtomicSync(file, p.text, { mode: p.mode });
|
|
124
|
+
return { ok: true, changed: true };
|
|
125
|
+
} finally { try { fs.rmdirSync(lockDir); } catch { /* already gone */ } }
|
|
126
|
+
} catch (e) { return { ok: false, reason: String((e && e.message) || e) }; }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = { claudeJsonPath, applyApproval, copyExternalIncludeApproval, copyExternalIncludeApprovalSync };
|
|
@@ -35,7 +35,7 @@ function serversOf(map) {
|
|
|
35
35
|
const SECRET_FLAG_RE = /^--(api-key|apikey|token|access-token|secret|password|auth|pat)(=|$)/i;
|
|
36
36
|
const EXTRA_KEY_RE = /(^|_)(PAT|CREDENTIALS?|PRIVATE_KEY)$/i;
|
|
37
37
|
const QUERY_KEY_RE = /(token|key|secret|password|sig|signature|auth)/i;
|
|
38
|
-
const USERINFO_RE = /[a-z][a-z0-9+.-]*:\/\/[
|
|
38
|
+
const USERINFO_RE = /[a-z][a-z0-9+.-]*:\/\/[^/?#\s@]+@/i;
|
|
39
39
|
const HINT = 'move the secret to a vault ref (environment profile) or run it outside the job';
|
|
40
40
|
|
|
41
41
|
function secretKey(key) {
|
|
@@ -89,14 +89,6 @@ const hasOwn = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
|
89
89
|
function personaToolScopeArgs(scope, { mcpServers, declaredServers = [], packs = [], knownPacks = [] } = {}) {
|
|
90
90
|
/** @type {string[]} */
|
|
91
91
|
const args = [];
|
|
92
|
-
if (scope) {
|
|
93
|
-
const def = {
|
|
94
|
-
description: 'Headless run with a scheduler-enforced tool scope.',
|
|
95
|
-
prompt: 'Tool scope is enforced by the scheduler.',
|
|
96
|
-
tools: scope.tools,
|
|
97
|
-
};
|
|
98
|
-
args.push('--agents', JSON.stringify({ [HEADLESS_SCOPE_AGENT_NAME]: def }), '--agent', HEADLESS_SCOPE_AGENT_NAME);
|
|
99
|
-
}
|
|
100
92
|
/** @type {null|{ code: 'capability_unknown', name: string }} */
|
|
101
93
|
let refusal = null;
|
|
102
94
|
const refuse = (name) => { if (!refusal) refusal = { code: 'capability_unknown', name }; };
|
|
@@ -123,6 +115,25 @@ function personaToolScopeArgs(scope, { mcpServers, declaredServers = [], packs =
|
|
|
123
115
|
for (const p of Array.isArray(packs) ? packs : []) {
|
|
124
116
|
if (!knownPackSet.has(String(p))) refuse(String(p));
|
|
125
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
|
+
}
|
|
126
137
|
// --mcp-config is variadic: it is followed immediately by --strict-mcp-config.
|
|
127
138
|
// With no server, no --mcp-config at all — strict mode alone boots none.
|
|
128
139
|
if (Object.keys(picked).length) args.push('--mcp-config', JSON.stringify({ mcpServers: picked }));
|
|
@@ -227,7 +238,11 @@ async function resolveSkillDeny({ packs = [], loadout, deps } = {}) {
|
|
|
227
238
|
}
|
|
228
239
|
}
|
|
229
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
|
+
|
|
230
244
|
module.exports = {
|
|
245
|
+
CHAT_HARNESS_MCP_SERVERS,
|
|
231
246
|
resolveSkillDeny,
|
|
232
247
|
JOB_MCP_TOOLS_ENV,
|
|
233
248
|
personaToolScopeEnv,
|
|
@@ -193,6 +193,16 @@ function attachLive(stateDir, key) {
|
|
|
193
193
|
return null;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
// Supervisors this process started -> promise that resolves once node has
|
|
197
|
+
// reaped it (until then kill(pid, 0) still sees the zombie and attachLive would
|
|
198
|
+
// attach to it). The 'exit' listener does not keep the event loop alive (unref).
|
|
199
|
+
const supervisorExits = new Map();
|
|
200
|
+
|
|
201
|
+
/** Promise that resolves when a supervisor this process started has exited and been reaped; null for any other pid. */
|
|
202
|
+
function supervisorExited(pid) {
|
|
203
|
+
return supervisorExits.get(pid) || null;
|
|
204
|
+
}
|
|
205
|
+
|
|
196
206
|
/** Called with start.lock held: re-check, then start a fresh run. */
|
|
197
207
|
function startLocked({ stateDir, key, argv, cwd, leaseMs }) {
|
|
198
208
|
const s = readState(stateDir);
|
|
@@ -216,6 +226,10 @@ function startLocked({ stateDir, key, argv, cwd, leaseMs }) {
|
|
|
216
226
|
env: process.env,
|
|
217
227
|
});
|
|
218
228
|
child.unref();
|
|
229
|
+
supervisorExits.set(child.pid, new Promise((resolve) => {
|
|
230
|
+
child.once('exit', () => { supervisorExits.delete(child.pid); resolve(); });
|
|
231
|
+
child.once('error', () => { supervisorExits.delete(child.pid); resolve(); });
|
|
232
|
+
}));
|
|
219
233
|
} finally {
|
|
220
234
|
fs.closeSync(logFd);
|
|
221
235
|
}
|
|
@@ -263,25 +277,32 @@ function supervise(args) {
|
|
|
263
277
|
// Not detached: the step and anything it spawns stay in this process group.
|
|
264
278
|
const step = spawn(process.execPath, argv, { stdio: ['ignore', 'inherit', 'inherit'], cwd: process.cwd() });
|
|
265
279
|
const every = Math.min(LEASE_CHECK_MAX_MS, Math.max(1, Math.floor(leaseMs / 4)));
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
280
|
+
let timer = null;
|
|
281
|
+
const startLeaseClock = () => {
|
|
282
|
+
// The lease clock starts when the step process actually exists, not when
|
|
283
|
+
// startOrAttach ran: a loaded machine can delay this supervisor past leaseMs.
|
|
284
|
+
refreshLease(stateDir);
|
|
285
|
+
timer = setInterval(() => {
|
|
286
|
+
let age = Infinity;
|
|
287
|
+
try { age = Date.now() - fs.statSync(leasePath(stateDir)).mtimeMs; } catch { /* missing lease = no caller */ }
|
|
288
|
+
if (age <= leaseMs) return;
|
|
289
|
+
clearInterval(timer);
|
|
290
|
+
try {
|
|
291
|
+
writeResult(stateDir, key, { ok: false, error: `abandoned: no caller for ${Math.round(leaseMs / 60000)} min` });
|
|
292
|
+
} catch { /* stateDir gone */ }
|
|
293
|
+
process.stderr.write(`resumableRun supervisor: lease expired, stopping group ${process.pid}\n`);
|
|
294
|
+
killTree(process.pid);
|
|
295
|
+
process.exit(1);
|
|
296
|
+
}, every);
|
|
297
|
+
};
|
|
298
|
+
step.on('spawn', startLeaseClock);
|
|
278
299
|
step.on('error', (err) => {
|
|
279
300
|
process.stderr.write(`resumableRun supervisor: step failed to start: ${err.message}\n`);
|
|
280
|
-
clearInterval(timer);
|
|
301
|
+
if (timer) clearInterval(timer);
|
|
281
302
|
process.exit(1);
|
|
282
303
|
});
|
|
283
304
|
step.on('exit', (code, signal) => {
|
|
284
|
-
clearInterval(timer);
|
|
305
|
+
if (timer) clearInterval(timer);
|
|
285
306
|
// The step wrote its result before exiting; stop whatever it left in this
|
|
286
307
|
// group (e.g. a voice wrapper's grandchildren). The waiter is not in it.
|
|
287
308
|
const exitCode = code ?? (signal ? 1 : 0);
|
|
@@ -295,4 +316,4 @@ if (require.main === module && process.argv[2] === '__supervise') {
|
|
|
295
316
|
supervise(process.argv.slice(3));
|
|
296
317
|
}
|
|
297
318
|
|
|
298
|
-
module.exports = { startOrAttach, waitForResult, writeResult, stopRun, readLogTail, winTreeKillArgv, DEFAULT_LEASE_MS };
|
|
319
|
+
module.exports = { startOrAttach, supervisorExited, waitForResult, writeResult, stopRun, readLogTail, winTreeKillArgv, DEFAULT_LEASE_MS };
|
|
@@ -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 = '
|
|
22
|
+
const KIT_VERSION = '47';
|
|
23
23
|
// sha256 of kitDigest(__dirname). Update together with a KIT_VERSION bump.
|
|
24
|
-
const KIT_DIGEST = '
|
|
24
|
+
const KIT_DIGEST = 'fbd7c7f8fa0e2bf006c0f3f6a0f3d91ca946a3666b42a77448f62f8f544a9300';
|
|
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
|
|