claude-code-session-manager 0.139.0 → 0.141.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/README.md +20 -4
- package/dist/assets/AppSettings-DExeJhqQ.js +2 -0
- package/dist/assets/History-DJMiuXyK.js +2 -0
- package/dist/assets/{HomeClaudeConfig-CGD2Onjv.js → HomeClaudeConfig-CTp2tkZ4.js} +2 -2
- package/dist/assets/{Panel-Csyd9HbD.js → Panel-Bf1Cf8UL.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-C-jlYpC_.js → ProjectClaudeConfig-BWPpypf9.js} +1 -1
- package/dist/assets/Scheduler-cyr61UAC.js +16 -0
- package/dist/assets/{SkillReferenceGraph-DcscPXAG.js → SkillReferenceGraph-Ba4TkX2C.js} +1 -1
- package/dist/assets/{Skills-BpGRKOcY.js → Skills-C1v91GEO.js} +26 -26
- package/dist/assets/{TiptapBody-DSU3769X.js → TiptapBody-BrcWVpiW.js} +1 -1
- package/dist/assets/{ViewTabs-C0PRZx4_.js → ViewTabs-DXhOWFG0.js} +1 -1
- package/dist/assets/{VoiceButton-D2rMurNg.js → VoiceButton-qivnDV6K.js} +1 -1
- package/dist/assets/{historyTotals-TcIQs2sh.js → historyTotals-CMCPTKqC.js} +1 -1
- package/dist/assets/index-B2TQz3nd.js +3121 -0
- package/dist/assets/{index-BCySPdtU.css → index-DKXdXfka.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +423 -426
- package/package.json +5 -2
- package/plugins/AGENTS.md +60 -0
- package/plugins/CLAUDE.md +1 -60
- package/plugins/session-manager-dev/skills/builder/SKILL.md +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +29 -19
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +5 -4
- package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +4 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +16 -12
- package/plugins/session-manager-dev/skills/maintaining-md-network/migrate-to-agents-md.md +15 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +50 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +10 -10
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +117 -112
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdDuplicates.cjs +182 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs +340 -0
- package/scripts/README.md +1 -0
- package/scripts/hooks/guard-tool-risk.cjs +91 -0
- package/scripts/hooks/lib/guard-tool-risk-policy.cjs +217 -0
- package/scripts/ops-sweep.cjs +53 -23
- package/scripts/scheduler-mcp-server.cjs +205 -18
- package/src/main/build-info.json +4 -4
- package/src/main/config.cjs +112 -8
- package/src/main/docEdit.cjs +6 -1
- package/src/main/files.cjs +7 -27
- package/src/main/health.cjs +48 -15
- package/src/main/historyAggregator.cjs +88 -5
- package/src/main/historyDashboard.cjs +69 -4
- package/src/main/index.cjs +56 -2
- package/src/main/ipcSchemas.cjs +122 -16
- package/src/main/lib/AGENTS.md +54 -0
- package/src/main/lib/CLAUDE.md +1 -54
- package/src/main/lib/agent-cli/adapters/codex.cjs +5 -2
- package/src/main/lib/agent-cli/agentCliIpc.cjs +18 -2
- package/src/main/lib/agent-cli/agentCliSessionStore.cjs +1 -0
- package/src/main/lib/agent-cli/agentCliTurn.cjs +20 -2
- package/src/main/lib/agent-cli/geminiContextDefaults.cjs +94 -0
- package/src/main/lib/claude/effectiveModelInfo.cjs +90 -20
- package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -0
- package/src/main/lib/claude/personaToolScope.cjs +12 -6
- package/src/main/lib/claude/rateLimitDetect.cjs +13 -2
- package/src/main/lib/claude/runClaudeP.cjs +6 -1
- package/src/main/lib/claude/toolRiskIpc.cjs +177 -0
- package/src/main/lib/claude/toolRiskMarks.cjs +373 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +27 -6
- package/src/main/lib/ephemeralCwd.cjs +37 -2
- package/src/main/lib/epic/delegationReadiness.cjs +42 -9
- package/src/main/lib/epic/epicAdminRoutes.cjs +25 -5
- package/src/main/lib/epic/epicOutsideRead.cjs +118 -1
- package/src/main/lib/epic/epicOutsideState.cjs +2 -2
- package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
- package/src/main/lib/epic/epicValidationHook.cjs +24 -4
- package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
- package/src/main/lib/externalContract.cjs +31 -5
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +55 -1
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +106 -11
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +47 -19
- package/src/main/lib/feedback-remote/needsYouStore.cjs +6 -2
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +98 -1
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +5 -0
- package/src/main/lib/git/branchSweep.cjs +209 -4
- package/src/main/lib/git/gitWorktree.cjs +41 -5
- package/src/main/lib/guardShims.cjs +1 -1
- package/src/main/lib/historyRollup.cjs +26 -0
- package/src/main/lib/insideHome.cjs +27 -1
- package/src/main/lib/mcpToolCatalog.cjs +132 -13
- package/src/main/lib/mdDocCensus.cjs +59 -78
- package/src/main/lib/mdDocRefs.cjs +71 -93
- package/src/main/lib/mdNetworkScan.cjs +245 -250
- package/src/main/lib/mdReviewRecord.cjs +22 -9
- package/src/main/lib/memoryMdNetwork.cjs +5 -12
- package/src/main/lib/opsOwnership.cjs +18 -2
- package/src/main/lib/opsRetentionSettings.cjs +28 -4
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +90 -20
- package/src/main/lib/persona-macro/macroJobIpc.cjs +144 -46
- package/src/main/lib/persona-macro/macroJobStatus.cjs +87 -9
- package/src/main/lib/persona-macro/macroLibrary.cjs +95 -5
- package/src/main/lib/persona-macro/personaImportHealth.cjs +78 -17
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +96 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
- package/src/main/lib/prd/depSlugResolve.cjs +104 -4
- package/src/main/lib/prd/prdAdminRoutes.cjs +35 -2
- package/src/main/lib/prd/prdCreate.cjs +377 -23
- package/src/main/lib/prd/prdDisposition.cjs +11 -2
- package/src/main/lib/prd/prdFrontmatter.cjs +121 -3
- package/src/main/lib/process/loginItem.cjs +171 -0
- package/src/main/lib/process/loginItemPlan.cjs +193 -0
- package/src/main/lib/project-pages/playerBridge.cjs +4 -0
- package/src/main/lib/project-pages/videoReview.cjs +268 -0
- package/src/main/lib/project-pages/videoReviewIpc.cjs +229 -0
- package/src/main/lib/scheduler/cpuSample.cjs +131 -4
- package/src/main/lib/scheduler/fixPlanSlug.cjs +4 -3
- package/src/main/lib/scheduler/loadGate.cjs +24 -6
- package/src/main/lib/scheduler/planRecordHarvest.cjs +108 -0
- package/src/main/lib/scheduler/planRecordRetention.cjs +144 -0
- package/src/main/lib/scheduler/preflightCheck.cjs +97 -0
- package/src/main/lib/scheduler/queueStore.cjs +7 -0
- package/src/main/lib/scheduler/rcaReport.cjs +21 -1
- package/src/main/lib/scheduler/reaperHelpers.cjs +35 -5
- package/src/main/lib/scheduler/reviewNotice.cjs +39 -0
- package/src/main/lib/scheduler/runLogRetention.cjs +104 -3
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
- package/src/main/lib/scheduler/schedulerBatch.cjs +25 -48
- package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
- package/src/main/lib/scheduler/sessionSlots.cjs +176 -21
- package/src/main/lib/scheduler/validationQuality.cjs +282 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +254 -0
- package/src/main/lib/tasks/taskAdminRoutes.cjs +641 -0
- package/src/main/lib/tasks/taskIpc.cjs +80 -0
- package/src/main/lib/tasks/taskLedger.cjs +502 -0
- package/src/main/lib/tasks/taskRun.cjs +313 -0
- package/src/main/lib/tasks/taskSwitch.cjs +120 -0
- package/src/main/loginItemIpc.cjs +35 -0
- package/src/main/loopEfficiencyHandlers.cjs +10 -1
- package/src/main/projectPages.cjs +6 -15
- package/src/main/promptSessionEvents.cjs +9 -1
- package/src/main/queueOps.cjs +260 -3
- package/src/main/runVerify.cjs +53 -25
- package/src/main/scheduler/AGENTS.md +26 -0
- package/src/main/scheduler/CLAUDE.md +1 -26
- package/src/main/scheduler/budget.cjs +239 -9
- package/src/main/scheduler/cancelDependents.cjs +154 -0
- package/src/main/scheduler/prdParser.cjs +19 -1
- package/src/main/scheduler/reviewLadder.cjs +36 -3
- package/src/main/scheduler/starvation.cjs +89 -18
- package/src/main/scheduler.cjs +1080 -89
- package/src/main/supervisor.cjs +5 -1
- package/src/main/templates/PRD_AUTHORING.md +14 -1
- package/src/main/validationQualityHandlers.cjs +199 -0
- package/src/main/webRemote.cjs +10 -2
- package/src/preload/api.d.ts +364 -21
- package/src/preload/apiSurface.json +89 -10
- package/src/preload/index.cjs +23 -2
- package/src/seed/agents/validator.md +19 -8
- package/dist/assets/AppSettings-CUfWY9vN.js +0 -2
- package/dist/assets/History-DDnqaLyw.js +0 -2
- package/dist/assets/Scheduler-NLs08fx7.js +0 -16
- package/dist/assets/index-C-d0DCre.js +0 -3124
|
@@ -28,6 +28,13 @@
|
|
|
28
28
|
* (cwd) resolves back to cwd unchanged, which is not a redirect and must
|
|
29
29
|
* not be refused.)
|
|
30
30
|
*
|
|
31
|
+
* Plus one for a MISSING cwd: a path that does not exist and lies lexically
|
|
32
|
+
* inside os.tmpdir() (resolved or realpath'd) is ephemeral. Verified live
|
|
33
|
+
* 2026-11-22: a reconcile pass recreated queue.json inside
|
|
34
|
+
* /tmp/sm-sbx-probe-LrKw/work, deleted half an hour earlier and remembered
|
|
35
|
+
* only as a ~/.claude/projects transcript dir — classifyCwd cannot inspect a
|
|
36
|
+
* path that is gone, so it looked like an ordinary project.
|
|
37
|
+
*
|
|
31
38
|
* Deliberately NOT a blanket "anywhere under os.tmpdir()" prefix match: this
|
|
32
39
|
* codebase's own scheduler test suite routinely mkdtemp()s a fake project cwd
|
|
33
40
|
* under os.tmpdir() (documented convention — see e.g.
|
|
@@ -35,6 +42,8 @@
|
|
|
35
42
|
* unrelated use that a blanket match would wrongly refuse.
|
|
36
43
|
*/
|
|
37
44
|
|
|
45
|
+
const fs = require('node:fs');
|
|
46
|
+
const os = require('node:os');
|
|
38
47
|
const path = require('node:path');
|
|
39
48
|
const { classifyCwd } = require('./cwdClassify.cjs');
|
|
40
49
|
|
|
@@ -48,9 +57,35 @@ const { classifyCwd } = require('./cwdClassify.cjs');
|
|
|
48
57
|
* opsOwnership.assertOpsWrite refuses separately (writes only — dispatch and
|
|
49
58
|
* reads stay open).
|
|
50
59
|
*/
|
|
51
|
-
function
|
|
60
|
+
function isInside(child, parent) {
|
|
61
|
+
const rel = path.relative(parent, child);
|
|
62
|
+
return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function tmpRoots() {
|
|
66
|
+
const roots = [path.resolve(os.tmpdir())];
|
|
67
|
+
try { roots.push(fs.realpathSync(os.tmpdir())); } catch { /* tmpdir unresolvable — lexical root only */ }
|
|
68
|
+
return roots;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* `refuseMissingInTmp` (default true) applies the MISSING-under-tmpdir rule.
|
|
73
|
+
* opsOwnership.resolveProjectRoot passes false: it is a path resolver shared
|
|
74
|
+
* by readers (fix-plan flat-dir fallback, drill-down transcript lookups) and
|
|
75
|
+
* by callers that run their own existence check first (delegationReadiness's
|
|
76
|
+
* "does not exist on disk"); refusing there broke them all (7071526a). The
|
|
77
|
+
* writers that must never recreate a deleted tmp cwd call this predicate
|
|
78
|
+
* directly (opsErrorLog) or check existence themselves (queueStore.writeSplit).
|
|
79
|
+
*/
|
|
80
|
+
function isEphemeralCwd(cwd, { refuseMissingInTmp = true } = {}) {
|
|
52
81
|
if (!cwd || typeof cwd !== 'string' || !path.isAbsolute(cwd)) return false;
|
|
53
|
-
const
|
|
82
|
+
const abs = path.resolve(cwd);
|
|
83
|
+
if (refuseMissingInTmp) {
|
|
84
|
+
let exists = true;
|
|
85
|
+
try { exists = fs.existsSync(abs); } catch { exists = true; }
|
|
86
|
+
if (!exists && tmpRoots().some((root) => isInside(abs, root))) return true;
|
|
87
|
+
}
|
|
88
|
+
const { kind } = classifyCwd(abs);
|
|
54
89
|
return kind === 'ephemeral' || kind === 'worktree';
|
|
55
90
|
}
|
|
56
91
|
|
|
@@ -325,6 +325,23 @@ function readDevMarketplacePath(homeDir) {
|
|
|
325
325
|
return typeof p === 'string' && p ? p : null;
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
+
const DEV_PLUGIN_NAME = 'session-manager-dev';
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Folder Claude Code actually loads the dev plugin from: the 'session-manager-dev'
|
|
332
|
+
* entry's source in <marketplacePath>/.claude-plugin/marketplace.json, resolved
|
|
333
|
+
* against marketplacePath. Null when the manifest is missing/malformed or the
|
|
334
|
+
* entry has no non-empty string source.
|
|
335
|
+
*/
|
|
336
|
+
function readDevPluginSourceDir(marketplacePath) {
|
|
337
|
+
const manifest = readJsonOrSync(path.join(marketplacePath, '.claude-plugin', 'marketplace.json'), null);
|
|
338
|
+
const plugins = Array.isArray(manifest?.plugins) ? manifest.plugins : [];
|
|
339
|
+
const entry = plugins.find((p) => p && p.name === DEV_PLUGIN_NAME);
|
|
340
|
+
return entry && typeof entry.source === 'string' && entry.source
|
|
341
|
+
? path.resolve(marketplacePath, entry.source)
|
|
342
|
+
: null;
|
|
343
|
+
}
|
|
344
|
+
|
|
328
345
|
function checkDevPlugin({ homeDir }) {
|
|
329
346
|
const settings = readJsonOrSync(path.join(homeDir, '.claude', 'settings.json'), null);
|
|
330
347
|
const enabled = settings?.enabledPlugins?.[DEV_PLUGIN_ENABLED_KEY] === true;
|
|
@@ -348,30 +365,44 @@ function checkDevPlugin({ homeDir }) {
|
|
|
348
365
|
fix: DEV_PLUGIN_REINSTALL_FIX,
|
|
349
366
|
};
|
|
350
367
|
}
|
|
351
|
-
|
|
352
|
-
|
|
368
|
+
|
|
369
|
+
const marketplacePath = readDevMarketplacePath(homeDir);
|
|
370
|
+
if (!marketplacePath) {
|
|
371
|
+
return {
|
|
372
|
+
...base,
|
|
373
|
+
ok: false,
|
|
374
|
+
detail: `'${DEV_PLUGIN_MARKETPLACE}' marketplace not registered in ~/.claude/plugins/known_marketplaces.json`,
|
|
375
|
+
fix: DEV_PLUGIN_REINSTALL_FIX,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
if (!fs.existsSync(marketplacePath)) {
|
|
353
379
|
return {
|
|
354
380
|
...base,
|
|
355
381
|
ok: false,
|
|
356
|
-
detail:
|
|
382
|
+
detail: `'${DEV_PLUGIN_MARKETPLACE}' marketplace folder ${marketplacePath} no longer exists`,
|
|
357
383
|
fix: DEV_PLUGIN_REINSTALL_FIX,
|
|
358
384
|
};
|
|
359
385
|
}
|
|
360
386
|
|
|
361
|
-
|
|
362
|
-
|
|
387
|
+
// The install record's installPath (a ~/.claude/plugins/cache/ snapshot) is
|
|
388
|
+
// never read by Claude Code for a directory marketplace — it loads the
|
|
389
|
+
// plugin in place from the manifest's source folder, so check THAT copy.
|
|
390
|
+
const manifestFile = path.join(marketplacePath, '.claude-plugin', 'marketplace.json');
|
|
391
|
+
const sourceDir = readDevPluginSourceDir(marketplacePath);
|
|
392
|
+
if (!sourceDir) {
|
|
363
393
|
return {
|
|
364
394
|
...base,
|
|
365
395
|
ok: false,
|
|
366
|
-
detail:
|
|
396
|
+
detail: `${manifestFile} is missing, malformed, or has no '${DEV_PLUGIN_NAME}' entry with a string source`,
|
|
367
397
|
fix: DEV_PLUGIN_REINSTALL_FIX,
|
|
368
398
|
};
|
|
369
399
|
}
|
|
370
|
-
|
|
400
|
+
const skillFile = path.join(sourceDir, 'skills', 'develop', 'SKILL.md');
|
|
401
|
+
if (!fs.existsSync(skillFile)) {
|
|
371
402
|
return {
|
|
372
403
|
...base,
|
|
373
404
|
ok: false,
|
|
374
|
-
detail:
|
|
405
|
+
detail: `${DEV_PLUGIN_ENABLED_KEY} enabled but ${skillFile} (the copy sessions load) is missing`,
|
|
375
406
|
fix: DEV_PLUGIN_REINSTALL_FIX,
|
|
376
407
|
};
|
|
377
408
|
}
|
|
@@ -379,7 +410,7 @@ function checkDevPlugin({ homeDir }) {
|
|
|
379
410
|
return {
|
|
380
411
|
...base,
|
|
381
412
|
ok: true,
|
|
382
|
-
detail: `${DEV_PLUGIN_ENABLED_KEY} enabled
|
|
413
|
+
detail: `${DEV_PLUGIN_ENABLED_KEY} enabled; sessions load it from ${sourceDir}`,
|
|
383
414
|
fix: null,
|
|
384
415
|
};
|
|
385
416
|
}
|
|
@@ -862,6 +893,7 @@ async function ensureGuardsInstalled(cwd, { homeDir = os.homedir() } = {}) {
|
|
|
862
893
|
|
|
863
894
|
module.exports = {
|
|
864
895
|
checkDevPlugin,
|
|
896
|
+
DEV_PLUGIN_REINSTALL_FIX,
|
|
865
897
|
checkDelegationReadiness,
|
|
866
898
|
ensureGuardsInstalled,
|
|
867
899
|
logAutoInstallEvent,
|
|
@@ -882,4 +914,5 @@ module.exports = {
|
|
|
882
914
|
SELF_SCHEDULE_GUARD_MATCHER,
|
|
883
915
|
GUARD_DEFS,
|
|
884
916
|
checkGuard,
|
|
917
|
+
installGuard,
|
|
885
918
|
};
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* → 200 { ok: true, epics, total, limit, offset, hasMore }
|
|
8
8
|
* GET /admin/epic?cwd=<abs>&(id=<epicId> | externalRef=<ref>)[&receipt=1|true]
|
|
9
9
|
* → 200 { ok: true, epic } (epic.receipt = { jobs, chat } only when receipt was asked for) | 404 { ok: false, error: 'not found' }
|
|
10
|
+
* GET /admin/epic?id=<epicId>[&receipt=1|true] (no cwd)
|
|
11
|
+
* → the Epic is found among the registered projects (findEpicProject):
|
|
12
|
+
* one → as above; none → 404; several → 409 { ok: false, error: 'ambiguous epic id', cwds }
|
|
10
13
|
*
|
|
11
14
|
* A query the schema rejects → 400 { ok: false, error: 'invalid query', details }.
|
|
12
15
|
* A cwd that is not absolute or has no session-manager-operations folder →
|
|
@@ -22,7 +25,7 @@ const path = require('node:path');
|
|
|
22
25
|
const { schemas } = require('../../ipcSchemas.cjs');
|
|
23
26
|
const { sendJson } = require('../feedback-remote/localAdminHttp.cjs');
|
|
24
27
|
const { opsPath } = require('../opsOwnership.cjs');
|
|
25
|
-
const { listOpenEpicRecords, getEpicRecord } = require('./epicOutsideRead.cjs');
|
|
28
|
+
const { listOpenEpicRecords, getEpicRecord, findEpicProject } = require('./epicOutsideRead.cjs');
|
|
26
29
|
|
|
27
30
|
/** @param {unknown} cwd @returns {string | null} the reason this cwd is not a project, or null. */
|
|
28
31
|
function projectProblem(cwd) {
|
|
@@ -52,8 +55,11 @@ function registerAdminRoute(adminHttp, deps = {}) {
|
|
|
52
55
|
if (typeof deps.listJobs === 'function') readOpts.listJobs = deps.listJobs;
|
|
53
56
|
if (typeof deps.projectRoots === 'function') readOpts.projectRoots = deps.projectRoots;
|
|
54
57
|
|
|
55
|
-
/**
|
|
56
|
-
|
|
58
|
+
/**
|
|
59
|
+
* @param {any} schema @param {any} query @param {any} res
|
|
60
|
+
* @param {(input: any) => boolean} [cwdOptional] true when this input may omit cwd
|
|
61
|
+
*/
|
|
62
|
+
function parseQuery(schema, query, res, cwdOptional) {
|
|
57
63
|
let input;
|
|
58
64
|
try {
|
|
59
65
|
input = schema.parse(Object.fromEntries(query ?? []));
|
|
@@ -61,6 +67,7 @@ function registerAdminRoute(adminHttp, deps = {}) {
|
|
|
61
67
|
sendJson(res, 400, { ok: false, error: 'invalid query', details: e?.issues ?? e?.message });
|
|
62
68
|
return null;
|
|
63
69
|
}
|
|
70
|
+
if (input.cwd === undefined && cwdOptional && cwdOptional(input)) return input;
|
|
64
71
|
const problem = projectProblem(input.cwd);
|
|
65
72
|
if (problem) {
|
|
66
73
|
sendJson(res, 400, { ok: false, error: problem });
|
|
@@ -82,9 +89,22 @@ function registerAdminRoute(adminHttp, deps = {}) {
|
|
|
82
89
|
});
|
|
83
90
|
|
|
84
91
|
adminHttp.registerRoute('GET', '/admin/epic', async (/** @type {any} */ req, /** @type {any} */ res, /** @type {any} */ query) => {
|
|
85
|
-
const input = parseQuery(schemas.adminGetEpicQuery, query, res);
|
|
92
|
+
const input = parseQuery(schemas.adminGetEpicQuery, query, res, (v) => v.id !== undefined);
|
|
86
93
|
if (!input) return;
|
|
87
|
-
|
|
94
|
+
let cwd = input.cwd;
|
|
95
|
+
if (cwd === undefined) {
|
|
96
|
+
const found = findEpicProject(input.id, readOpts.projectRoots ? { projectRoots: /** @type {() => string[]} */ (readOpts.projectRoots) } : {});
|
|
97
|
+
if (found && 'ambiguous' in found) {
|
|
98
|
+
sendJson(res, 409, { ok: false, error: 'ambiguous epic id', cwds: found.ambiguous });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (!found) {
|
|
102
|
+
sendJson(res, 404, { ok: false, error: 'not found' });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
cwd = found.cwd;
|
|
106
|
+
}
|
|
107
|
+
const epic = await getEpicRecord(cwd, {
|
|
88
108
|
...readOpts,
|
|
89
109
|
id: input.id,
|
|
90
110
|
externalRef: input.externalRef,
|
|
@@ -25,6 +25,12 @@ const { readArchived, defaultProjectRoots, makeRegisteredRootsCache } = require(
|
|
|
25
25
|
const { gatherEpicJobReceipt } = require('./epicJobReceipt.cjs');
|
|
26
26
|
const { summarizeTranscriptFile } = require('./transcriptUsage.cjs');
|
|
27
27
|
const { resolveEpicTranscriptPath } = require('./epicTranscriptPath.cjs');
|
|
28
|
+
const { isSafeEpicId } = require('../prd/prdLocations.cjs');
|
|
29
|
+
const fs = require('node:fs');
|
|
30
|
+
const { opsPath } = require('../opsOwnership.cjs');
|
|
31
|
+
const { readJsonOrSync } = require('../util/atomicFs.cjs');
|
|
32
|
+
const { parseValidatorVerdict } = require('../scheduler/validatorVerdictSchema.cjs');
|
|
33
|
+
const { bareSlug } = require('../prd/depSlugResolve.cjs');
|
|
28
34
|
|
|
29
35
|
const DEFAULT_LIMIT = 50;
|
|
30
36
|
const MAX_LIMIT = 200;
|
|
@@ -56,6 +62,59 @@ function isRegistered(cwd, projectRoots) {
|
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
const DEFAULT_ROOTS_TTL_MS = 10000;
|
|
66
|
+
let defaultRootsList = null;
|
|
67
|
+
let defaultRootsListAt = 0;
|
|
68
|
+
|
|
69
|
+
/** The registered roots, each folded to its project root and de-duplicated. */
|
|
70
|
+
function registeredRoots(projectRoots) {
|
|
71
|
+
let raw;
|
|
72
|
+
if (projectRoots === defaultProjectRoots) {
|
|
73
|
+
if (!defaultRootsList || Date.now() - defaultRootsListAt >= DEFAULT_ROOTS_TTL_MS) {
|
|
74
|
+
defaultRootsList = defaultProjectRoots() || [];
|
|
75
|
+
defaultRootsListAt = Date.now();
|
|
76
|
+
}
|
|
77
|
+
raw = defaultRootsList;
|
|
78
|
+
} else {
|
|
79
|
+
raw = projectRoots() || [];
|
|
80
|
+
}
|
|
81
|
+
const { projectRootOf } = require('../activeSessions.cjs');
|
|
82
|
+
const out = new Set();
|
|
83
|
+
for (const r of raw) {
|
|
84
|
+
if (typeof r !== 'string' || !r || !path.isAbsolute(r)) continue;
|
|
85
|
+
out.add(norm(projectRootOf(r) || r));
|
|
86
|
+
}
|
|
87
|
+
return [...out];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Which registered project holds this Epic — open in its active index, or
|
|
92
|
+
* completed in its per-Epic archive. { cwd } on one match, { ambiguous: cwds }
|
|
93
|
+
* on several, null on none or an unsafe id. Reads only each root's
|
|
94
|
+
* prompt-sessions/ folder; never throws.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} epicId
|
|
97
|
+
* @param {{ projectRoots?: () => string[] }} [opts]
|
|
98
|
+
* @returns {{ cwd: string } | { ambiguous: string[] } | null}
|
|
99
|
+
*/
|
|
100
|
+
function findEpicProject(epicId, opts = {}) {
|
|
101
|
+
try {
|
|
102
|
+
if (!isSafeEpicId(epicId)) return null;
|
|
103
|
+
const { projectRoots = defaultProjectRoots } = isObj(opts) ? opts : {};
|
|
104
|
+
const hits = [];
|
|
105
|
+
for (const root of registeredRoots(projectRoots)) {
|
|
106
|
+
try {
|
|
107
|
+
if (openSession(readActiveIndex(root), epicId) || archivedEntry(root, epicId, projectRoots)) hits.push(root);
|
|
108
|
+
} catch { /* this root holds nothing readable */ }
|
|
109
|
+
}
|
|
110
|
+
if (hits.length === 0) return null;
|
|
111
|
+
if (hits.length === 1) return { cwd: hits[0] };
|
|
112
|
+
return { ambiguous: hits.sort() };
|
|
113
|
+
} catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
59
118
|
async function loadJobs(listJobs) {
|
|
60
119
|
try {
|
|
61
120
|
const out = await listJobs();
|
|
@@ -91,6 +150,63 @@ function splitGoal(goalText) {
|
|
|
91
150
|
return { title: head || null, goal: tail || null };
|
|
92
151
|
}
|
|
93
152
|
|
|
153
|
+
const atMs = (v) => (typeof v === 'string' ? Date.parse(v) : NaN);
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Checked validator verdicts for an Epic, from the scheduler's
|
|
157
|
+
* plan-records/<epicId>/*.verdicts.json files ({ validator, runId, at,
|
|
158
|
+
* schedulerVerdict, verdicts }). Newest `at` per bare PRD slug wins (a file
|
|
159
|
+
* with no parseable `at` loses to any dated one; later file name wins a tie);
|
|
160
|
+
* sorted by prd. Unreadable or invalid files are skipped; a missing folder
|
|
161
|
+
* gives []. Read-only; never throws.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} cwd
|
|
164
|
+
* @param {string} epicId
|
|
165
|
+
* @returns {{ prd: string, verdict: string, reason: string, criteria: any[], findings: any[], validator: string|null, at: string|null }[]}
|
|
166
|
+
*/
|
|
167
|
+
function readVerdictFiles(cwd, epicId) {
|
|
168
|
+
try {
|
|
169
|
+
if (!isSafeEpicId(epicId)) return [];
|
|
170
|
+
const dir = opsPath(cwd, 'plan-records', epicId);
|
|
171
|
+
let names;
|
|
172
|
+
try { names = fs.readdirSync(dir); } catch { return []; }
|
|
173
|
+
const best = new Map(); // bare -> { entry, t }
|
|
174
|
+
for (const name of names.filter((n) => n.endsWith('.verdicts.json')).sort()) {
|
|
175
|
+
const data = readJsonOrSync(path.join(dir, name), null);
|
|
176
|
+
if (!isObj(data)) continue;
|
|
177
|
+
const input = { schedulerVerdict: data.schedulerVerdict, verdicts: data.verdicts };
|
|
178
|
+
if (typeof data.failReason === 'string') input.failReason = data.failReason;
|
|
179
|
+
const parsed = parseValidatorVerdict(input);
|
|
180
|
+
if (!parsed.ok) continue;
|
|
181
|
+
const fileAt = str(data.at);
|
|
182
|
+
const t = atMs(fileAt);
|
|
183
|
+
for (const v of parsed.value.verdicts) {
|
|
184
|
+
const bare = bareSlug(v.prd);
|
|
185
|
+
const prev = best.get(bare);
|
|
186
|
+
const newer = !prev
|
|
187
|
+
|| (Number.isFinite(t) && (!Number.isFinite(prev.t) || t >= prev.t))
|
|
188
|
+
|| (!Number.isFinite(t) && !Number.isFinite(prev.t));
|
|
189
|
+
if (!newer) continue;
|
|
190
|
+
best.set(bare, {
|
|
191
|
+
t,
|
|
192
|
+
entry: {
|
|
193
|
+
prd: bare,
|
|
194
|
+
verdict: v.verdict,
|
|
195
|
+
reason: v.reason,
|
|
196
|
+
criteria: v.criteria,
|
|
197
|
+
findings: v.findings,
|
|
198
|
+
validator: str(data.validator),
|
|
199
|
+
at: fileAt,
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return [...best.values()].map((b) => b.entry).sort((a, b) => (a.prd < b.prd ? -1 : a.prd > b.prd ? 1 : 0));
|
|
205
|
+
} catch {
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
94
210
|
function buildRecord(cwd, epicId, session, events, jobs, needsInput, chatBusy) {
|
|
95
211
|
const computed = computeEpicOutsideState({ session: { ...session, id: epicId }, events, jobs, needsInput, chatBusy });
|
|
96
212
|
const source = isObj(session.source) ? session.source : {};
|
|
@@ -118,6 +234,7 @@ function buildRecord(cwd, epicId, session, events, jobs, needsInput, chatBusy) {
|
|
|
118
234
|
},
|
|
119
235
|
createdAt: str(session.createdAt),
|
|
120
236
|
completedAt: str(session.completedAt),
|
|
237
|
+
verdicts: readVerdictFiles(cwd, epicId),
|
|
121
238
|
};
|
|
122
239
|
}
|
|
123
240
|
|
|
@@ -303,4 +420,4 @@ async function listOpenEpicRecords(cwd, opts = {}) {
|
|
|
303
420
|
}
|
|
304
421
|
}
|
|
305
422
|
|
|
306
|
-
module.exports = { listOpenEpicRecords, getEpicRecord };
|
|
423
|
+
module.exports = { readVerdictFiles, listOpenEpicRecords, getEpicRecord, findEpicProject };
|
|
@@ -181,7 +181,7 @@ function computeEpicOutsideState(args) {
|
|
|
181
181
|
const refuted = [];
|
|
182
182
|
for (const [bare, { event }] of verdicts) {
|
|
183
183
|
if (event.validation === 'verified') verified.push(bare);
|
|
184
|
-
else refuted.push({ slug: bare, reason: cut(refutedReason(event.text)) });
|
|
184
|
+
else refuted.push({ slug: bare, reason: cut(typeof event.reason === 'string' ? event.reason : refutedReason(event.text)) });
|
|
185
185
|
}
|
|
186
186
|
verified.sort();
|
|
187
187
|
refuted.sort(bySlug);
|
|
@@ -230,4 +230,4 @@ function computeEpicOutsideState(args) {
|
|
|
230
230
|
return result('open');
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
module.exports = { computeEpicOutsideState, knownPrdSlugs, EPIC_OUTSIDE_STATES };
|
|
233
|
+
module.exports = { computeEpicOutsideState, knownPrdSlugs, refutedReason, EPIC_OUTSIDE_STATES };
|
|
@@ -79,12 +79,15 @@ function buildSweepValidatorInput({ epicId, cwd, uncovered, baseSha, now, jobBud
|
|
|
79
79
|
|
|
80
80
|
const stamp = new Date(now).toISOString().replace(/\D/g, '').slice(0, 14);
|
|
81
81
|
const slug = `${SWEEP_SLUG_PREFIX}-${stamp}`;
|
|
82
|
-
|
|
82
|
+
// Plan records are a gitignored runtime namespace: the job writes the record
|
|
83
|
+
// in its worktree and the scheduler copies it to the main checkout, so the
|
|
84
|
+
// PRD is artifact-only and never commits it.
|
|
85
|
+
const recordPath = `session-manager-operations/plan-records/${epicId}/${slug}.md`;
|
|
83
86
|
|
|
84
87
|
const acceptanceCriteria = names.map(
|
|
85
88
|
(name) => `${name} verified against its PRD file (find it by slug under $SM_PROJECT_ROOT/session-manager-operations/scheduler/epics/${epicId}/prds/ or prds-archived/, possibly in a timestamped subfolder)`,
|
|
86
89
|
);
|
|
87
|
-
acceptanceCriteria.push(`Record written
|
|
90
|
+
acceptanceCriteria.push(`Record written at ${recordPath}, relative to the job worktree's repository root (git rev-parse --show-toplevel), never relative to a subdirectory you cd'd into. Do not git add or commit it — the scheduler copies it to the main checkout`);
|
|
88
91
|
|
|
89
92
|
const base = baseSha
|
|
90
93
|
? `Base: ${baseSha}`
|
|
@@ -103,6 +106,8 @@ function buildSweepValidatorInput({ epicId, cwd, uncovered, baseSha, now, jobBud
|
|
|
103
106
|
outOfScope: ['Editing product code', 'Queuing fix PRDs'],
|
|
104
107
|
gate: ['none'],
|
|
105
108
|
files: [recordPath],
|
|
109
|
+
deliverable: 'artifact',
|
|
110
|
+
artifactPaths: [recordPath],
|
|
106
111
|
estimateMinutes: validatorEstimateMinutes(covered.map((e) => e.gateMs), { factor }),
|
|
107
112
|
agentType: 'validator',
|
|
108
113
|
tag: 'build',
|
|
@@ -43,12 +43,32 @@ function defaultReadActiveIndex(cwd) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/** The digest's record-folder lines: absolute main-checkout paths when cwd resolves. */
|
|
47
|
+
function recordFolderLines(cwd, epicId) {
|
|
48
|
+
try {
|
|
49
|
+
if (typeof cwd === 'string' && cwd) {
|
|
50
|
+
const { opsPath } = require('../opsOwnership.cjs');
|
|
51
|
+
return [
|
|
52
|
+
`Plan record folder (on disk in the main checkout, not committed): ${opsPath(cwd, 'plan-records', epicId)}${path.sep}`,
|
|
53
|
+
`Legacy validation record folder: ${opsPath(cwd, 'reviews', 'validation', epicId)}${path.sep}`,
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
} catch { /* fall through to the relative form */ }
|
|
57
|
+
return [
|
|
58
|
+
`Plan record folder (relative to the project root): session-manager-operations/plan-records/${epicId}/`,
|
|
59
|
+
`Legacy validation record folder: session-manager-operations/reviews/validation/${epicId}/`,
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
|
|
46
63
|
/**
|
|
47
64
|
* buildSettledDigest — pure builder for the ONE plan-digest prompt.
|
|
48
65
|
* Empty sections are omitted. `notValidatedReason` explains why the
|
|
49
|
-
* settle.uncovered slugs were not sent to a sweep validator.
|
|
66
|
+
* settle.uncovered slugs were not sent to a sweep validator. `cwd` is the
|
|
67
|
+
* project root: plan records live on disk in its main checkout
|
|
68
|
+
* (plan-records/<epicId>/, never committed), so the digest names that
|
|
69
|
+
* absolute folder plus the legacy reviews/validation/<epicId>/ one.
|
|
50
70
|
*/
|
|
51
|
-
function buildSettledDigest(settle, { epicId, notValidatedReason } = {}) {
|
|
71
|
+
function buildSettledDigest(settle, { epicId, notValidatedReason, cwd } = {}) {
|
|
52
72
|
const s = settle || {};
|
|
53
73
|
const verified = s.verified || [];
|
|
54
74
|
const refuted = s.refuted || [];
|
|
@@ -58,7 +78,7 @@ function buildSettledDigest(settle, { epicId, notValidatedReason } = {}) {
|
|
|
58
78
|
const notValidated = (s.uncovered || []).map((u) => (typeof u === 'string' ? u : u.slug));
|
|
59
79
|
const lines = [
|
|
60
80
|
`PLAN SETTLED — no PRD of this session is pending or running. This is ONE digest, not a per-PRD request.`,
|
|
61
|
-
|
|
81
|
+
...recordFolderLines(cwd, epicId),
|
|
62
82
|
'Do NOT re-verify VERIFIED PRDs — a validator already checked them.',
|
|
63
83
|
];
|
|
64
84
|
if (verified.length) {
|
|
@@ -200,7 +220,7 @@ async function runEpicSettle({ cwd, epicId } = {}, deps = {}) {
|
|
|
200
220
|
}
|
|
201
221
|
}
|
|
202
222
|
|
|
203
|
-
const prompt = buildSettledDigest(digestSettle, { epicId, notValidatedReason });
|
|
223
|
+
const prompt = buildSettledDigest(digestSettle, { epicId, notValidatedReason, cwd });
|
|
204
224
|
sendPrompt(epicId, prompt, { origin: 'scheduler' });
|
|
205
225
|
await appendResponseEvent(
|
|
206
226
|
cwd, epicId,
|
|
@@ -73,4 +73,60 @@ async function writeGuardSpawnSettingsFile({ spawnCwd, homeDir = os.homedir(), d
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
/** Every tool class guard-tool-risk.cjs can mark: Bash rules, file writes, MCP calls. */
|
|
77
|
+
const TOOL_RISK_MATCHER = 'Bash|Write|Edit|NotebookEdit|mcp__.*';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Settings carrying ONLY the guard-tool-risk PreToolUse hook, for headless
|
|
81
|
+
* spawns (scheduler jobs, Tasks) whose worktree never sees the project's
|
|
82
|
+
* untracked .claude/settings.json.
|
|
83
|
+
* @param {{ homeDir?: string }} [opts]
|
|
84
|
+
*/
|
|
85
|
+
function buildToolRiskGuardSettings({ homeDir = os.homedir() } = {}) {
|
|
86
|
+
return {
|
|
87
|
+
hooks: {
|
|
88
|
+
PreToolUse: [{
|
|
89
|
+
matcher: TOOL_RISK_MATCHER,
|
|
90
|
+
hooks: [{ type: 'command', command: nodeShellCommand(guardShimPath('guard-tool-risk.cjs', homeDir)) }],
|
|
91
|
+
}],
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Write buildToolRiskGuardSettings() content-addressed to
|
|
98
|
+
* <homeDir>/.claude/session-manager/spawn-settings/tool-risk-<sha1[0..12]>.json
|
|
99
|
+
* after the shims are ensured. Returns its path, or null (logged, never thrown).
|
|
100
|
+
*
|
|
101
|
+
* @param {{ homeDir?: string, deps?: { ensureShims?: (homeDir: string) => Promise<any> } }} [opts]
|
|
102
|
+
* @returns {Promise<string | null>}
|
|
103
|
+
*/
|
|
104
|
+
async function writeToolRiskGuardSettingsFile({ homeDir = os.homedir(), deps = {} } = {}) {
|
|
105
|
+
const ensureShims = deps.ensureShims || ensureGuardShimsOrError;
|
|
106
|
+
try {
|
|
107
|
+
const shimError = await ensureShims(homeDir);
|
|
108
|
+
if (shimError) {
|
|
109
|
+
console.warn(`[guardSpawnSettings] tool-risk guard shim unavailable: ${shimError.error ?? shimError}`);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const content = `${JSON.stringify(buildToolRiskGuardSettings({ homeDir }), null, 2)}\n`;
|
|
113
|
+
const hash = crypto.createHash('sha1').update(content).digest('hex').slice(0, 12);
|
|
114
|
+
const dir = path.join(homeDir, '.claude', 'session-manager', 'spawn-settings');
|
|
115
|
+
const file = path.join(dir, `tool-risk-${hash}.json`);
|
|
116
|
+
if (fs.existsSync(file)) return file;
|
|
117
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
118
|
+
await writeTextAtomic(file, content);
|
|
119
|
+
return file;
|
|
120
|
+
} catch (err) {
|
|
121
|
+
console.warn(`[guardSpawnSettings] could not write tool-risk spawn settings: ${err?.message ?? err}`);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = {
|
|
127
|
+
buildGuardSpawnSettings,
|
|
128
|
+
writeGuardSpawnSettingsFile,
|
|
129
|
+
TOOL_RISK_MATCHER,
|
|
130
|
+
buildToolRiskGuardSettings,
|
|
131
|
+
writeToolRiskGuardSettingsFile,
|
|
132
|
+
};
|
|
@@ -38,7 +38,7 @@ function deepFreeze(v) {
|
|
|
38
38
|
* The outside contract — what an outside app may depend on. Every list here
|
|
39
39
|
* is checked against the code by src/main/__tests__/externalContract.shape.test.cjs;
|
|
40
40
|
* changing one changes contractFingerprint(), which must then be recorded
|
|
41
|
-
*
|
|
41
|
+
* in CONTRACT_FINGERPRINTS (see the rule there).
|
|
42
42
|
*/
|
|
43
43
|
const CONTRACT = deepFreeze({
|
|
44
44
|
routes: [
|
|
@@ -52,6 +52,11 @@ const CONTRACT = deepFreeze({
|
|
|
52
52
|
{ method: 'POST', path: '/admin/needs-you' },
|
|
53
53
|
{ method: 'POST', path: '/admin/needs-you/withdraw' },
|
|
54
54
|
{ method: 'GET', path: '/admin/needs-you' },
|
|
55
|
+
{ method: 'POST', path: '/admin/tasks' },
|
|
56
|
+
{ method: 'GET', path: '/admin/tasks' },
|
|
57
|
+
{ method: 'GET', path: '/admin/task' },
|
|
58
|
+
{ method: 'POST', path: '/admin/tasks/import' },
|
|
59
|
+
{ method: 'GET', path: '/admin/validation-quality' },
|
|
55
60
|
],
|
|
56
61
|
tools: {
|
|
57
62
|
feedback_open_session: { required: ['toCwd', 'fromCwd', 'title', 'motivation', 'acceptanceCriteria', 'body'] },
|
|
@@ -59,11 +64,13 @@ const CONTRACT = deepFreeze({
|
|
|
59
64
|
epic_get: { required: ['cwd'], requiredOneOf: [['id', 'externalRef']] },
|
|
60
65
|
feedback_reply: { required: ['message', 'outcome'] },
|
|
61
66
|
agent_list: { required: [] },
|
|
67
|
+
task_list: { required: ['cwd'] },
|
|
68
|
+
task_get: { required: ['cwd', 'id'] },
|
|
62
69
|
},
|
|
63
70
|
epicStates: ['closed', 'awaiting_approval', 'needs_input', 'blocked', 'working', 'in_review', 'verified', 'open'],
|
|
64
71
|
epicRecordFields: [
|
|
65
72
|
'epicId', 'cwd', 'title', 'goal', 'tag', 'agentType', 'status', 'state', 'blocked', 'prds',
|
|
66
|
-
'verified', 'refuted', 'unvalidated', 'externalRef', 'source', 'createdAt', 'completedAt',
|
|
73
|
+
'verified', 'refuted', 'unvalidated', 'externalRef', 'source', 'createdAt', 'completedAt', 'verdicts',
|
|
67
74
|
],
|
|
68
75
|
receiptFields: ['jobs', 'chat'],
|
|
69
76
|
epicStateChangedFields: ['at', 'kind', 'cwd', 'epicId', 'from', 'to', 'blockedKind', 'externalRef'],
|
|
@@ -84,6 +91,13 @@ const CONTRACT = deepFreeze({
|
|
|
84
91
|
],
|
|
85
92
|
// Keys of a needs_you_answered row (feedback-remote/needsYouIpc.cjs) as readEventsAfter returns it; externalRef only when the item has one.
|
|
86
93
|
needsYouAnsweredFields: ['at', 'kind', 'app', 'id', 'answer', 'externalRef'],
|
|
94
|
+
// Keys of one Task in GET /admin/tasks (tasks/taskAdminRoutes.cjs TASK_FIELDS); GET /admin/task adds the text fields.
|
|
95
|
+
taskFields: [
|
|
96
|
+
'taskId', 'source', 'importId', 'importedAt', 'agent', 'missionId', 'model', 'effort', 'priority', 'caller',
|
|
97
|
+
'outputFormat', 'timeoutSec', 'slotWaitSec', 'sessionId', 'persisted', 'startedAt', 'endedAt', 'status',
|
|
98
|
+
'exitCode', 'signal', 'durationMs', 'slotWaitMs', 'usage', 'costUsd', 'cliCostUsd', 'numTurns', 'quota',
|
|
99
|
+
'promptBytes', 'promptSha256', 'outputBytes', 'outputSha256',
|
|
100
|
+
],
|
|
87
101
|
eventKinds: ['epic_state_changed', 'job_transition', 'epic_cross_project_reply', 'needs_you_answered'],
|
|
88
102
|
adminApiFields: ['port', 'token', 'appVersion', 'contractVersion'],
|
|
89
103
|
});
|
|
@@ -102,10 +116,22 @@ function contractFingerprint() {
|
|
|
102
116
|
return require('node:crypto').createHash('sha256').update(stableStringify(CONTRACT)).digest('hex');
|
|
103
117
|
}
|
|
104
118
|
|
|
105
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Accepted fingerprints for each contract version, oldest first; the last
|
|
121
|
+
* entry of CONTRACT_FINGERPRINTS[CONTRACT_VERSION] is the current manifest.
|
|
122
|
+
* - An additive change (a new route, a new optional field) appends its
|
|
123
|
+
* fingerprint to the current version's array; contractVersion stays.
|
|
124
|
+
* - A breaking change increments CONTRACT_VERSION and starts a new array.
|
|
125
|
+
*/
|
|
106
126
|
const CONTRACT_FINGERPRINTS = Object.freeze({
|
|
107
|
-
// v1 was unreleased when the manifest was completed (at/kind, epic_get requiredOneOf, then epic_cross_project_reply + feedback_reply + replyEventFields, then GET /admin/agents + agent_list + agentFields, then the Needs you routes + needsYouItemFields + needsYouAnsweredFields + needs_you_answered), so its fingerprint was replaced, not
|
|
108
|
-
|
|
127
|
+
// v1 was unreleased when the manifest was completed (at/kind, epic_get requiredOneOf, then epic_cross_project_reply + feedback_reply + replyEventFields, then GET /admin/agents + agent_list + agentFields, then the Needs you routes + needsYouItemFields + needsYouAnsweredFields + needs_you_answered, then POST /admin/tasks, then GET /admin/tasks + GET /admin/task + POST /admin/tasks/import + taskFields, then task_list + task_get), so its first fingerprint was replaced, not appended.
|
|
128
|
+
// Additive since: epicRecordFields + 'verdicts' (checked validator verdicts from plan-records/*.verdicts.json),
|
|
129
|
+
// then GET /admin/validation-quality (validationQualityHandlers.cjs).
|
|
130
|
+
1: Object.freeze([
|
|
131
|
+
'5a56abbb70184ff4a34346a5c6da4c5e6edbd756b54573c199b812d3f5a04101',
|
|
132
|
+
'7383ff32c80561b1b2c505a78a1e8313ae2851bdc6e8fce6c6a88e1ab119bf5a',
|
|
133
|
+
'b8af6788f3c5022346278194a8113455c47f3ab7a565e51d47c5e79c7f36fbd7',
|
|
134
|
+
]),
|
|
109
135
|
});
|
|
110
136
|
|
|
111
137
|
module.exports = { CONTRACT_VERSION, contractInfo, CONTRACT, contractFingerprint, CONTRACT_FINGERPRINTS };
|