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.
Files changed (66) hide show
  1. package/dist/assets/{AppSettings-Z68gQiVE.js → AppSettings-BXfkoKQq.js} +2 -2
  2. package/dist/assets/{History-C3E6y_7t.js → History-l7pBt_vO.js} +1 -1
  3. package/dist/assets/HomeClaudeConfig-DtFwZxTx.js +5 -0
  4. package/dist/assets/{Panel-CnfWs46Z.js → Panel-C5hihgUD.js} +1 -1
  5. package/dist/assets/{ProjectClaudeConfig-CP0Wsg-H.js → ProjectClaudeConfig-B3pODrM-.js} +1 -1
  6. package/dist/assets/{Scheduler-D8un7N3B.js → Scheduler-IU9wo8_u.js} +1 -1
  7. package/dist/assets/{SkillReferenceGraph-DRtZV1Al.js → SkillReferenceGraph-Bmen0OOC.js} +1 -1
  8. package/dist/assets/{Skills-Bg5O2Hyn.js → Skills-jYVxqJr2.js} +1 -1
  9. package/dist/assets/{TiptapBody-BdzoBmqu.js → TiptapBody-Dp2gtbb-.js} +1 -1
  10. package/dist/assets/{Toggle-Dt5K1OXt.js → Toggle-C_0yUCS5.js} +1 -1
  11. package/dist/assets/{VoiceButton-CTLyRgdF.js → VoiceButton-BRPzqDa-.js} +1 -1
  12. package/dist/assets/{historyTotals-B2_KWBga.js → historyTotals-pAv-MFnY.js} +1 -1
  13. package/dist/assets/{index-446b69rr.js → index-C6nhp7m_.js} +496 -496
  14. package/dist/index.html +1 -1
  15. package/dist-web/app.js +427 -427
  16. package/package.json +1 -1
  17. package/plugins/session-manager-dev/skills/develop/SKILL.md +11 -6
  18. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +1 -1
  19. package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +8 -4
  20. package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +13 -8
  21. package/scripts/scheduler-mcp-server.cjs +4 -3
  22. package/src/main/adminRouteRegistry.cjs +1 -1
  23. package/src/main/build-info.json +4 -4
  24. package/src/main/chatRunner.cjs +35 -5
  25. package/src/main/config.cjs +12 -0
  26. package/src/main/index.cjs +2 -2
  27. package/src/main/ipcSchemas.cjs +5 -0
  28. package/src/main/lib/claude/claudeJsonApproval.cjs +129 -0
  29. package/src/main/lib/claude/headlessMcpServers.cjs +1 -1
  30. package/src/main/lib/claude/personaToolScope.cjs +23 -8
  31. package/src/main/lib/demo-video-kit/resumableRun.cjs +36 -15
  32. package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
  33. package/src/main/lib/epic/epicOutsideRead.cjs +43 -8
  34. package/src/main/lib/epic/epicSpawnCwd.cjs +1 -0
  35. package/src/main/lib/epic/planReviewInput.cjs +5 -6
  36. package/src/main/lib/epic/scriptStartedBy.cjs +19 -4
  37. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +219 -48
  38. package/src/main/lib/feedback-remote/localAdminHttp.cjs +5 -1
  39. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +6 -3
  40. package/src/main/lib/feedback-remote/serviceMcpTools.cjs +23 -3
  41. package/src/main/lib/feedback-remote/servicePairings.cjs +48 -0
  42. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +11 -6
  43. package/src/main/lib/git/gitWorktree.cjs +17 -0
  44. package/src/main/lib/mcpToolCatalog.cjs +6 -3
  45. package/src/main/lib/opsOwnership.cjs +2 -0
  46. package/src/main/lib/prd/prdCreate.cjs +2 -1
  47. package/src/main/lib/prd/prdMcpReachWarnings.cjs +3 -1
  48. package/src/main/lib/prd/prdSandboxWarnings.cjs +1 -1
  49. package/src/main/lib/scheduler/planReleaseRoute.cjs +53 -5
  50. package/src/main/lib/scheduler/planReviewStore.cjs +24 -2
  51. package/src/main/lib/scheduler/rcaReport.cjs +1 -0
  52. package/src/main/lib/scheduler/reviewNotice.cjs +3 -1
  53. package/src/main/lib/scheduler/terminalRunOutcome.cjs +1 -0
  54. package/src/main/lib/tasks/memoryConsolidation.cjs +21 -12
  55. package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +131 -11
  56. package/src/main/runVerify.cjs +107 -3
  57. package/src/main/scheduler/gitTreeGuard.cjs +6 -0
  58. package/src/main/scheduler/planReviewHold.cjs +11 -5
  59. package/src/main/scheduler/prdPaths.cjs +10 -1
  60. package/src/main/scheduler.cjs +230 -27
  61. package/src/main/templates/PRD_AUTHORING.md +2 -2
  62. package/src/main/webRemote.cjs +22 -0
  63. package/src/preload/api.d.ts +8 -0
  64. package/src/preload/apiSurface.json +11 -0
  65. package/src/preload/index.cjs +2 -0
  66. package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +0 -5
@@ -69,6 +69,7 @@ const { headlessPermissionArgs, ensureCliCapsProbed } = require('./lib/claude/cl
69
69
  // as the authoritative guarantee.
70
70
  ensureCliCapsProbed().catch(() => {});
71
71
  const launchFailure = require('./lib/scheduler/launchFailure.cjs');
72
+ const { isProtectedClaudePath, sandboxWarnings } = require('./lib/prd/prdSandboxWarnings.cjs');
72
73
  const { sandboxLimitFromStreamJson, environmentLimitStamp, ENVIRONMENT_LIMIT_MESSAGE } = require('./lib/scheduler/sandboxEnvironmentLimit.cjs');
73
74
  const { decideVerifyDowngrade } = require('./lib/scheduler/refireCap.cjs');
74
75
  const { finalizeReasonFor } = require('./lib/scheduler/finalizeReason.cjs');
@@ -140,7 +141,8 @@ const { verifyRun, captureArtifactEvidence, parseLog, scanSentinel, scanForeignW
140
141
  const { latestTerminalOutcomeForSlug, COMPLETED_EQUIVALENT_VERDICTS } = require('./lib/scheduler/terminalRunOutcome.cjs');
141
142
  const { isFixPlanSlug, classifyDiscoveredFixPlan, resolveIsFixPlan, fixPlanRecordPath } = require('./lib/scheduler/fixPlanSlug.cjs');
142
143
  const { landedSinceRun, landedOnMainSince } = require('./lib/scheduler/landedSinceRun.cjs');
143
- const { declaredPathsForPrd, issuedAtForPrd } = require('./lib/prd/prdDeclaredPaths.cjs');
144
+ const { declaredPathsForPrd, issuedAtForPrd, extractDeclaredPaths } = require('./lib/prd/prdDeclaredPaths.cjs');
145
+ const { extractSection: extractPrdSection } = require('./lib/scheduler/definitionOfDone.cjs');
144
146
  const { identity: procIdentityOf, isDifferentProcess } = require('./lib/process/procIdentity.cjs');
145
147
  const jobLeftovers = require('./lib/scheduler/jobLeftovers.cjs');
146
148
  const planReviewHold = require('./scheduler/planReviewHold.cjs');
@@ -195,7 +197,8 @@ const { resolveEpicEffort, effortArgs } = require('./lib/claude/agentEffortResol
195
197
  const { transitionJob, emitJobEvent, STATUS_HISTORY_CAP, LEGAL_TRANSITIONS } = require('./lib/scheduler/scheduleJobTransitions.cjs');
196
198
  const { buildContextDigest, composeExecutorPrompt } = require('./lib/epic/epicContextDigest.cjs');
197
199
  const { JOB_STATUSES } = require('./lib/scheduler/scheduleJobSchema.cjs');
198
- const { appendAuditEvent } = require('./lib/telemetry/auditLog.cjs');
200
+ const auditLogModule = require('./lib/telemetry/auditLog.cjs');
201
+ const { appendAuditEvent } = auditLogModule;
199
202
  const heldSchedulerTurns = require('./lib/scheduler/heldSchedulerTurns.cjs');
200
203
  const autoStartedSession = require('./lib/feedback-remote/autoStartedSession.cjs');
201
204
  const preflightCheck = require('./lib/scheduler/preflightCheck.cjs');
@@ -557,6 +560,12 @@ const FINISH_VALIDATOR_VERDICT_LINE = `
557
560
 
558
561
  // Plan-reviewer jobs (`--json-schema` PLAN_REVIEW_SCHEMA): the structured
559
562
  // object is the whole deliverable; there is nothing to commit.
563
+ // Plan-reviewer COMMIT sentence: the reviewer is not artifact-only (its PRD
564
+ // declares no deliverable: artifact), but it still commits nothing — say so in
565
+ // the COMMIT step too, not only in the VERDICT bullet below.
566
+ const FINISH_PLAN_REVIEWER_COMMIT_LINE = `
567
+ PLAN REVIEWER: you edit no files, so there is nothing to stage. Skip the commit and go to the next step.`;
568
+
560
569
  const FINISH_PLAN_REVIEWER_LINE = `
561
570
  - PLAN REVIEWER: your deliverable is the structured output object (PLAN_REVIEW_SCHEMA) ONLY. Do not commit, do not edit files; the scheduler reads the object, not this verdict line.`;
562
571
 
@@ -586,7 +595,7 @@ ${commitStepNum}. COMMIT — stage only the exact paths you created or changed f
586
595
  Never commit any file under these folders (except each folder's top-level README.md, the layout contract), even when the PRD names it:
587
596
  ${FINISH_RUNTIME_FOLDERS}
588
597
  Why: those folders hold the app's live state. A commit of them breaks the
589
- running scheduler for every checkout that pulls it.${isArtifactOnly ? FINISH_ARTIFACT_ONLY_COMMIT_LINE : ''}
598
+ running scheduler for every checkout that pulls it.${isArtifactOnly ? FINISH_ARTIFACT_ONLY_COMMIT_LINE : ''}${isPlanReviewer ? FINISH_PLAN_REVIEWER_COMMIT_LINE : ''}
590
599
  ${verdictStepNum}. VERDICT LINE — end your final report with exactly one of these lines.
591
600
  Put nothing after it, except the FOREIGN_WIP_PATHS line described below.
592
601
  SCHEDULER_VERDICT: PASS
@@ -651,6 +660,11 @@ function buildFinishProtocol({ reviewInRun = true, isFixPlan = false, isArtifact
651
660
  + buildFinishTail({ verifyStepNum: 2, commitStepNum: 3, verdictStepNum: 4, isFixPlan, isArtifactOnly, isValidator, isPlanReviewer });
652
661
  }
653
662
 
663
+ /** Pure: role flags for buildFinishProtocol. isArtifactOnly comes from the PRD only. */
664
+ function finishProtocolFlagsFor(job, isArtifactOnly) {
665
+ return { isArtifactOnly: !!isArtifactOnly, isValidator: job.agentType === 'validator', isPlanReviewer: job.agentType === 'plan-reviewer' };
666
+ }
667
+
654
668
  const FINISH_PROTOCOL = buildFinishProtocol({ reviewInRun: true });
655
669
 
656
670
  // Machine-wide roots resolve lazily via lib/scheduler/schedulerPaths.cjs (SM_SCHEDULER_HOME
@@ -2662,6 +2676,29 @@ async function reconcilePass(state) {
2662
2676
  const parent = healTargetForFix(slug, state.jobs);
2663
2677
  entry.investigationDepth = parent ? (parent.investigationDepth ?? 1) + 1 : 2;
2664
2678
  }
2679
+ // A scheduler-authored fix plan whose # Files names a protected .claude path can never pass: the job
2680
+ // sandbox refuses every write there. Minted parked (born directly, like quarantine — not a transition)
2681
+ // with an environment limit so reviewLadder never auto-fixes it.
2682
+ if (entry.isFixPlan && Array.isArray(p.files)) {
2683
+ const protectedFiles = p.files.filter(isProtectedClaudePath);
2684
+ if (protectedFiles.length > 0) {
2685
+ const joined = protectedFiles.join(', ');
2686
+ const bornAt = new Date().toISOString();
2687
+ entry.status = 'needs_review';
2688
+ entry.environmentLimit = { kind: 'claude-dir-write', evidence: `${joined} in # Files` };
2689
+ entry.error = ENVIRONMENT_LIMIT_MESSAGE;
2690
+ entry.statusHistory = [{
2691
+ from: null,
2692
+ to: 'needs_review',
2693
+ reason: `fix plan lists protected path ${joined}; the job sandbox refuses writes there — architect-inline work`,
2694
+ source: 'reconcile',
2695
+ at: bornAt,
2696
+ }];
2697
+ entry.reviewNotice = buildReviewNotice({ job: entry, report: null, epicId: entry.sourcePromptId ?? null, now: bornAt });
2698
+ console.warn(`[scheduler] reconcile: parking fix plan ${slug} — # Files lists protected .claude path(s) ${joined}`);
2699
+ appendAuditEvent('fix_plan_sandbox_refused', { slug, cwd: p.cwd, path: p.path, files: protectedFiles });
2700
+ }
2701
+ }
2665
2702
  // Provenance gate (PRD-authoring lockdown): a PRD discovered with no
2666
2703
  // `createdVia` stamp was never written through scheduler_create_prd/
2667
2704
  // chat:create-prd (prdCreate.cjs always stamps 'scheduler-api') or the
@@ -4793,7 +4830,7 @@ async function notifyOriginatingTab(job, {
4793
4830
  console.error('[scheduler] notifyOriginatingTab verdicts file write error', job?.slug, e);
4794
4831
  }
4795
4832
  }
4796
- if (job.agentType === 'plan-reviewer' && (job.status === 'completed' || job.status === 'failed')) {
4833
+ if (job.agentType === 'plan-reviewer' && (job.status === 'completed' || job.status === 'failed' || job.status === 'needs_review')) {
4797
4834
  await harvestPlanReview(job, epicId, logPath, { readStructured: readStructuredFromLog, sendPrompt, rows: planReviewRows, store: planReviewStoreImpl });
4798
4835
  }
4799
4836
  if (epicId) {
@@ -4855,7 +4892,22 @@ async function notifyOriginatingTab(job, {
4855
4892
 
4856
4893
  /** Digest text for one harvested plan review (pure). */
4857
4894
  function buildPlanReviewDigest({ validateSlug, round, outcome, review, error }) {
4858
- const head = `PLAN REVIEWED: ${validateSlug} (round ${round})`;
4895
+ const head = `PLAN REVIEWED${outcome === 'late' ? ' (late)' : ''}: ${validateSlug} (round ${round})`;
4896
+ if (outcome === 'late') {
4897
+ const lines = [head, 'The reviewer was healed after this round was released as review-failed. The plan stays released; apply what still matters with scheduler_update_prd.'];
4898
+ for (const p of review.prds) {
4899
+ lines.push('', `${p.prd}: ${p.decision}`);
4900
+ for (const f of p.findings) {
4901
+ lines.push(` - [${f.severity}] ${f.check}: ${f.text}`);
4902
+ if (f.suggestedEdit) lines.push(` suggested edit: ${f.suggestedEdit}`);
4903
+ }
4904
+ }
4905
+ if (review.planFindings.length) {
4906
+ lines.push('', 'Plan findings:');
4907
+ for (const f of review.planFindings) lines.push(` - [${f.severity}] ${f.check}: ${f.text}`);
4908
+ }
4909
+ return lines.join('\n');
4910
+ }
4859
4911
  if (outcome === 'failed') {
4860
4912
  return `${head}\nThe independent review failed (${error || 'no structured output'}) — the plan was released without review (review-failed). Its PRDs are free to dispatch.`;
4861
4913
  }
@@ -4882,7 +4934,10 @@ function buildPlanReviewDigest({ validateSlug, round, outcome, review, error })
4882
4934
  * harvestPlanReview — a finished plan-reviewer job: parse its structured output,
4883
4935
  * save the round, auto-release an all-ok plan (an unusable review releases as
4884
4936
  * 'review-failed'), and send the planner's Epic ONE digest per (validateSlug,
4885
- * round). The sent round is persisted in the record (`digestSent`) so a restart
4937
+ * round). Late path: a round whose digest was 'review-failed' may later get a
4938
+ * completed run with valid output; that run saves the review and sends ONE
4939
+ * second 'PLAN REVIEWED (late)' digest (no release — the plan already released).
4940
+ * The sent round + kind is persisted in the record (`digestSent`) so a restart
4886
4941
  * does not resend. Never throws.
4887
4942
  */
4888
4943
  async function harvestPlanReview(job, epicId, logPath, deps = {}) {
@@ -4901,22 +4956,37 @@ async function harvestPlanReview(job, epicId, logPath, deps = {}) {
4901
4956
  }
4902
4957
  const validateSlug = validator.slug;
4903
4958
  const prior = store.readPlanReview(job.cwd, epicId, validateSlug);
4904
- const sentBefore = prior && Array.isArray(prior.digestSent) ? prior.digestSent.slice() : [];
4905
- if (sentBefore.includes(round)) return;
4959
+ // digestSent entries: { round, kind: 'review-failed' | 'reviewed' | 'late' };
4960
+ // a bare number (old shape) reads as kind 'reviewed'.
4961
+ const sentBefore = (prior && Array.isArray(prior.digestSent) ? prior.digestSent : [])
4962
+ .map((e) => (typeof e === 'number' ? { round: e, kind: 'reviewed' } : e))
4963
+ .filter((e) => e && typeof e.round === 'number');
4964
+ const sentEntry = sentBefore.find((e) => e.round === round);
4965
+ if (sentEntry && sentEntry.kind !== 'review-failed') return;
4966
+ const late = !!sentEntry;
4906
4967
 
4907
4968
  const members = planReviewHold.planMembers(validator, rows).map((r) => r.slug);
4908
4969
  let structured = null;
4909
4970
  try { structured = (deps.readStructured || extractStructuredOutputFromLog)(logPath); } catch { structured = null; }
4971
+ // Only a completed reviewer's output is parsed. A failed or needs_review
4972
+ // reviewer takes the review-failed branch below, which releases the plan
4973
+ // and sends the digest now instead of waiting for the hold timeout.
4910
4974
  const checked = job.status === 'completed' && structured
4911
4975
  ? parsePlanReview(structured, { expected: members })
4912
4976
  : { ok: false, error: job.status === 'completed' ? 'no structured output' : `reviewer ${job.status}` };
4913
4977
 
4978
+ // A review-failed round accepts only a later completed run with valid output.
4979
+ if (late && !checked.ok) return;
4914
4980
  let outcome;
4915
- if (checked.ok) {
4981
+ if (late || checked.ok) {
4916
4982
  await store.savePlanReviewResult({
4917
4983
  cwd: job.cwd, epicId, validateSlug, round, reviewer: job.slug,
4918
4984
  runId: job.runId || null, model: job.model || null, review: checked.value,
4919
4985
  });
4986
+ }
4987
+ if (late) {
4988
+ outcome = 'late';
4989
+ } else if (checked.ok) {
4920
4990
  if (isAllOkPlanReview(checked.value)) {
4921
4991
  outcome = 'ok';
4922
4992
  await store.recordPlanRelease({ cwd: job.cwd, epicId, validateSlug, by: 'auto', accepted: 0 });
@@ -4937,7 +5007,10 @@ async function harvestPlanReview(job, epicId, logPath, deps = {}) {
4937
5007
  if (rec) {
4938
5008
  const file = store.planReviewPath(job.cwd, epicId, validateSlug);
4939
5009
  assertOpsWrite(file, 'scheduler');
4940
- await writeJsonAtomic(file, { ...rec, digestSent: [...new Set([...sentBefore, round])] });
5010
+ await writeJsonAtomic(file, { ...rec, digestSent: [
5011
+ ...sentBefore.filter((e) => e.round !== round),
5012
+ { round, kind: late ? 'late' : (checked.ok ? 'reviewed' : 'review-failed') },
5013
+ ] });
4941
5014
  }
4942
5015
  const text = buildPlanReviewDigest({
4943
5016
  validateSlug, round, outcome,
@@ -6513,7 +6586,7 @@ async function executeJob(job, runDir, defaultCwd, onPid, execCwd, resumeTarget
6513
6586
  job.validatorCriteriaExpected = expected;
6514
6587
  if (section) prompt = `${prompt}\n\n${section}`;
6515
6588
  }
6516
- prompt = composeExecutorPrompt({ prdBody: prompt, digestText, finishProtocol: buildFinishProtocol({ reviewInRun, isFixPlan: resolveIsFixPlan(job.slug, job.isFixPlan), isArtifactOnly: isArtifactOnly || job.agentType === 'plan-reviewer', isValidator: job.agentType === 'validator', isPlanReviewer: job.agentType === 'plan-reviewer' }) });
6589
+ prompt = composeExecutorPrompt({ prdBody: prompt, digestText, finishProtocol: buildFinishProtocol({ reviewInRun, isFixPlan: resolveIsFixPlan(job.slug, job.isFixPlan), ...finishProtocolFlagsFor(job, isArtifactOnly) }) });
6517
6590
 
6518
6591
  // Foreign-WIP manifest (starry-night-ships PRD 148 postmortem): the
6519
6592
  // scheduler already knows, at spawn time, which dirty paths this job did
@@ -7417,6 +7490,7 @@ ${logTail}
7417
7490
  the scheduler's commit guard and post-run verifier read git state from this path, and a
7418
7491
  non-repo cwd parks even a fully green, committed run in \`needs_review\`.
7419
7492
  List each file under \`# Files\` as \`- <repo-relative path>\` with nothing else on the line; put any note about a file in the Implementation notes, never on its path line.
7493
+ The job sandbox refuses every write under \`.claude/agents\`, \`.claude/commands\`, \`.claude/skills\`, \`.claude/hooks\` and \`.claude/settings*.json\` (Edit and Write too), so the fix plan must NEVER list such a path in \`# Files\`. If the only fix is there, write no fix plan and report that the edit is architect-inline work in the Epic chat (see PRD_AUTHORING.md #job-sandbox-limits).
7420
7494
  6. The PRD body MUST be self-contained — \`claude -p\` runs it on a fresh Sonnet session with NO conversation context. Include:
7421
7495
  - Root-cause analysis (what went wrong and why)
7422
7496
  - Concrete fix steps (specific files / commands / edits)
@@ -7491,7 +7565,9 @@ function readRunOutcomeSidecars(runDir, slug) {
7491
7565
  */
7492
7566
  const INVESTIGATION_LAUNCH_KEY = 'investigation';
7493
7567
 
7494
- async function spawnInvestigation(failedJob, runDir, { deadChild = null } = {}) {
7568
+ function spawnInvestigation(failedJob, runDir, opts) { return trackInFlight(spawnInvestigationUntracked(failedJob, runDir, opts)); }
7569
+
7570
+ async function spawnInvestigationUntracked(failedJob, runDir, { deadChild = null } = {}) {
7495
7571
  // Auto-dispatch hold first — before anything below can spawn a process
7496
7572
  // (probeClaudeVersion included). A held needs_review row stays eligible for
7497
7573
  // the periodic auto-fix pass; a plain 'failed' row (never a
@@ -8291,24 +8367,38 @@ async function applyPlanReviewHolds(state, deps = {}) {
8291
8367
  const recordRelease = deps.recordRelease || ((a) => planReviewStore.recordPlanRelease(a));
8292
8368
  const notify = deps.notify || ((cwd, epicId, text, extra) => appendResponseEventIfKnown(cwd, epicId, text, extra));
8293
8369
  const gitHead = deps.gitHead || (async (cwd) => { try { return String(await execGitAt(cwd, ['rev-parse', 'HEAD'])).trim() || null; } catch { return null; } });
8294
- const readPrdTexts = deps.readPrdTexts || ((cwd, epicId, slugs) => prdPaths.readEpicPrdTexts(cwd, epicId, slugs));
8295
- const audit = deps.audit || ((k, d) => { try { appendAuditEvent(k, d); } catch { /* audit never breaks dispatch */ } });
8370
+ const readPrdFiles = deps.readPrdFiles || ((cwd, epicId, slugs) => prdPaths.readEpicPrdFiles(cwd, epicId, slugs));
8371
+ const readPrdTexts = deps.readPrdTexts || (async (cwd, epicId, slugs) => {
8372
+ const files = await readPrdFiles(cwd, epicId, slugs);
8373
+ return new Map([...files].map(([k, v]) => [k, v.text]));
8374
+ });
8375
+ const audit = deps.audit || ((k, d) => { try { auditLogModule.appendAuditEvent(k, d); } catch { /* audit never breaks dispatch */ } });
8296
8376
  const readEpicGoal = deps.readEpicGoal || ((cwd, epicId) => {
8297
8377
  try {
8298
8378
  const sessions = readActiveIndex(cwd).sessions;
8299
8379
  const sess = sessions && Object.prototype.hasOwnProperty.call(sessions, epicId) ? sessions[epicId] : null;
8300
- const t = sess && typeof sess.goalText === 'string' ? sess.goalText.trim() : '';
8301
- return t;
8380
+ if (!sess) return '';
8381
+ const title = typeof sess.title === 'string' && sess.title.trim() ? sess.title.trim()
8382
+ : (typeof sess.goalText === 'string' ? sess.goalText.trim().split(/\n\s*\n/)[0].trim() : '');
8383
+ const objective = typeof sess.openingPrompt === 'string' ? sess.openingPrompt.trim().slice(0, 2000) : '';
8384
+ return [title, objective].filter(Boolean).join('\n\n');
8302
8385
  } catch { return ''; }
8303
8386
  });
8304
8387
  const resolvePrdPath = deps.resolvePrdPath || (async (m, cwd, epicId) => {
8305
8388
  try {
8306
- const dir = await prdPaths.findPrdDirForJob({ ...m, cwd: m.cwd || cwd, epicId: m.epicId || epicId });
8307
- if (dir) return path.join(dir, `${m.slug}.md`);
8308
- } catch { /* fall through to the canonical live path */ }
8389
+ const files = await readPrdFiles(m.cwd || cwd, m.epicId || epicId, [m.slug]);
8390
+ const hit = files.get(m.slug);
8391
+ if (hit && hit.path) return path.resolve(hit.path);
8392
+ } catch { /* fall through */ }
8309
8393
  return opsPath(cwd, 'scheduler', 'epics', epicId, 'prds', `${m.slug}.md`);
8310
8394
  });
8395
+ const markCreateRefused = deps.markCreateRefused || ((cwd, epicId, slug, round) => planReviewStore.markCreateRefused(cwd, epicId, slug, round));
8311
8396
  const heldReasons = new Map();
8397
+ const notifyCreateFailed = async (v, epicId, vslug, err) => {
8398
+ try {
8399
+ await notify(v.cwd, epicId, `PLAN REVIEW NOT STARTED — the independent review job for plan ${bareSlug(vslug)} could not be created: ${err}. Its PRDs stay held until the review lands, you release it with scheduler_release_plan, or the hold times out.`, { prdSlug: v.slug, notice: 'plan-review-create-failed', allowInactive: true });
8400
+ } catch { /* notice never breaks the tick */ }
8401
+ };
8312
8402
 
8313
8403
  const reviews = {};
8314
8404
  const validators = rows.filter((r) => r && r.status === 'pending' && r.agentType === 'validator' && r.planReview === 'required');
@@ -8316,7 +8406,7 @@ async function applyPlanReviewHolds(state, deps = {}) {
8316
8406
  const epicId = v.sourcePromptId || v.epicId;
8317
8407
  if (!epicId || !v.cwd) continue;
8318
8408
  const rec = readReview(v.cwd, epicId, v.slug);
8319
- if (rec) reviews[bareSlug(v.slug)] = { ...rec, released: !!rec.release || rec.released === true };
8409
+ if (rec) reviews[bareSlug(v.slug)] = rec;
8320
8410
  }
8321
8411
  const { held: holds, needsReview, expired } = planReviewHold.computePlanReviewHolds(rows, reviews, { now, holdMs });
8322
8412
  const expiredSet = new Set(expired);
@@ -8372,21 +8462,41 @@ async function applyPlanReviewHolds(state, deps = {}) {
8372
8462
  const baseSha = await gitHead(v.cwd);
8373
8463
  const input = buildPlanReviewInput({ epicId, cwd: v.cwd, epicGoal, validateSlug: v.slug, members, baseSha, round });
8374
8464
  const res = await createPrd(input);
8375
- if (res && res.ok === false) console.warn('[scheduler] plan review PRD not created', reviewSlug, res.error || res.reason || '');
8465
+ if (res && res.ok === false) {
8466
+ const err = String(res.error || res.reason || '');
8467
+ console.warn('[scheduler] plan review PRD not created', reviewSlug, err);
8468
+ if (await markCreateRefused(v.cwd, epicId, v.slug, round)) {
8469
+ audit('plan_review_create_refused', { validateSlug: vslug, round, error: err });
8470
+ await notifyCreateFailed(v, epicId, vslug, err);
8471
+ }
8472
+ }
8376
8473
  } catch (e) {
8377
8474
  console.error('[scheduler] plan review PRD create failed', reviewSlug, e?.message || e);
8475
+ try {
8476
+ const err = String(e?.message || e);
8477
+ if (await markCreateRefused(v.cwd, epicId, v.slug, round)) {
8478
+ audit('plan_review_create_refused', { validateSlug: vslug, round, error: err });
8479
+ await notifyCreateFailed(v, epicId, vslug, err);
8480
+ }
8481
+ } catch { /* never breaks the tick */ }
8378
8482
  }
8379
8483
  }
8380
8484
 
8381
8485
  // Stamp / clear heldReason on pending rows so settle + starvation see a known wait.
8382
8486
  const mutateRows = deps.mutateRows || ((fn) => mutate((s) => fn(s.jobs)));
8383
- const dirty = rows.some((r) => r && r.status === 'pending' && (
8487
+ const stampSlugs = new Set();
8488
+ for (const v of validators) {
8489
+ if (expiredSet.has(v.slug) || v.queuedAt || v.createdAt || v.planReviewHeldAt) continue;
8490
+ if (needsReview.includes(v.slug) || planReviewHold.planMembers(v, rows).some((m) => held.has(m.slug))) stampSlugs.add(v.slug);
8491
+ }
8492
+ const dirty = stampSlugs.size > 0 || rows.some((r) => r && r.status === 'pending' && (
8384
8493
  (heldReasons.has(r.slug) && !r.preflightHold && r.heldReason !== heldReasons.get(r.slug))
8385
8494
  || (!heldReasons.has(r.slug) && typeof r.heldReason === 'string' && r.heldReason.startsWith(PLAN_REVIEW_HELD_PREFIX))));
8386
8495
  if (dirty) {
8387
8496
  await mutateRows((list) => {
8388
8497
  for (const r of list) {
8389
8498
  if (!r || r.status !== 'pending') continue;
8499
+ if (stampSlugs.has(r.slug) && !r.queuedAt && !r.createdAt && !r.planReviewHeldAt) r.planReviewHeldAt = new Date(now).toISOString();
8390
8500
  if (heldReasons.has(r.slug) && !r.preflightHold) r.heldReason = heldReasons.get(r.slug);
8391
8501
  else if (typeof r.heldReason === 'string' && r.heldReason.startsWith(PLAN_REVIEW_HELD_PREFIX)) delete r.heldReason;
8392
8502
  }
@@ -8537,7 +8647,28 @@ function auditPreflightHold(slug, command, result, hold, extra = {}) {
8537
8647
  } catch { /* audit must not break dispatch */ }
8538
8648
  }
8539
8649
 
8540
- async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, siblingJobs = null) {
8650
+ // In-flight launch tracker: every spawnJob / spawnResumeRecovery / spawnInvestigation
8651
+ // run is registered here until it settles, so whenIdle() is a deterministic
8652
+ // "nothing this module launched is still running" signal (no polling, no clock).
8653
+ const inFlightLaunches = new Set();
8654
+ function trackInFlight(promise) {
8655
+ inFlightLaunches.add(promise);
8656
+ const done = () => { inFlightLaunches.delete(promise); };
8657
+ promise.then(done, done);
8658
+ return promise;
8659
+ }
8660
+
8661
+ /** Resolves once every tracked launch has settled, including launches that a
8662
+ * settling launch's own finally-tick started. Never rejects. */
8663
+ async function whenIdle() {
8664
+ while (inFlightLaunches.size > 0) {
8665
+ await Promise.allSettled([...inFlightLaunches]);
8666
+ }
8667
+ }
8668
+
8669
+ function spawnJob(...args) { return trackInFlight(spawnJobUntracked(...args)); }
8670
+
8671
+ async function spawnJobUntracked(job, runId, runDir, defaultCwd, resumeTarget = null, siblingJobs = null) {
8541
8672
  // PRD 1408: the queue rows in scope at dispatch (tickQueue's own
8542
8673
  // state.jobs, threaded straight down — never re-read here or inside
8543
8674
  // executeJob) decide whether this job's own finish protocol still needs to
@@ -9221,7 +9352,13 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
9221
9352
  let siblingOverlap = false;
9222
9353
  if (!worktree.ok) {
9223
9354
  rangeCommits = await gitTreeGuard.gitRangeCommits(guardCwd, guardHeadBefore, headAtExit);
9224
- transcriptCommitShas = parseLog(path.join(runDir, `${job.slug}.log`)).transcriptCommitShas || [];
9355
+ // One parseLog call: harness-reported shas plus shas git printed for the run's own
9356
+ // `git commit` Bash call. Both are claims; resolveRunCommitAttribution only credits one inside rangeCommits.
9357
+ const parsedRunLog = parseLog(path.join(runDir, `${job.slug}.log`));
9358
+ transcriptCommitShas = [...new Set([
9359
+ ...(parsedRunLog.transcriptCommitShas || []),
9360
+ ...(parsedRunLog.transcriptCommitOutputShas || []),
9361
+ ])];
9225
9362
  const overlapState = await readQueue().catch(() => ({ jobs: [] }));
9226
9363
  const myStart = Date.parse(dispatchStartedAt) || 0;
9227
9364
  const myEnd = Date.now();
@@ -10320,7 +10457,9 @@ async function reclaimTerminalJobOrphansThrottled(state) {
10320
10457
  * own dispatch mutate is what stamps resumeRecoveryAttempted, atomically
10321
10458
  * with the 'running' transition).
10322
10459
  */
10323
- async function spawnResumeRecovery(job, resumeTarget) {
10460
+ function spawnResumeRecovery(job, resumeTarget) { return trackInFlight(spawnResumeRecoveryUntracked(job, resumeTarget)); }
10461
+
10462
+ async function spawnResumeRecoveryUntracked(job, resumeTarget) {
10324
10463
  // No queue rows in scope here (unlike tickQueue's own dispatch loop) — read
10325
10464
  // once, before delegating to spawnJob, so hasDownstreamValidator still
10326
10465
  // never runs inside executeJob itself. Its config also feeds the hold below.
@@ -12678,6 +12817,42 @@ async function attributeLandedCommits(job, pathCommits, cwd) {
12678
12817
  return null;
12679
12818
  }
12680
12819
 
12820
+ /**
12821
+ * Resolve a commit this job's own transcript names that actually landed on HEAD
12822
+ * during its run. Rule: the transcript SHA resolves to a commit, is an ancestor
12823
+ * of HEAD, and its committer date is within [startedAt, finishedAt + 60s].
12824
+ * Fails closed per candidate and never throws.
12825
+ *
12826
+ * @param {{cwd?: string, logPath?: string, startedAt?: string, finishedAt?: string}} [opts]
12827
+ * @returns {Promise<string|null>}
12828
+ */
12829
+ async function ownTranscriptCommitOnHead({ cwd, logPath, startedAt, finishedAt } = {}) {
12830
+ try {
12831
+ if (!cwd || !logPath) return null;
12832
+ const start = Date.parse(startedAt);
12833
+ const end = Date.parse(finishedAt);
12834
+ if (!Number.isFinite(start) || !Number.isFinite(end)) return null;
12835
+ const parsed = parseLog(logPath);
12836
+ const candidates = [...new Set([
12837
+ ...(parsed.transcriptCommitShas || []),
12838
+ ...(parsed.transcriptCommitOutputShas || []),
12839
+ ])];
12840
+ for (const cand of candidates) {
12841
+ try {
12842
+ if (typeof cand !== 'string' || !/^[0-9a-f]{4,64}$/i.test(cand)) continue;
12843
+ const full = String(await execGitAt(cwd, ['rev-parse', '--verify', `${cand}^{commit}`])).trim();
12844
+ if (!/^[0-9a-f]{40,64}$/i.test(full)) continue;
12845
+ await execGitAt(cwd, ['merge-base', '--is-ancestor', full, 'HEAD']);
12846
+ const cIso = String(await execGitAt(cwd, ['show', '-s', '--format=%cI', full])).trim();
12847
+ const ct = Date.parse(cIso);
12848
+ if (!Number.isFinite(ct) || ct < start || ct > end + 60_000) continue;
12849
+ return full;
12850
+ } catch { /* this candidate fails closed */ }
12851
+ }
12852
+ } catch { /* never throws */ }
12853
+ return null;
12854
+ }
12855
+
12681
12856
  /**
12682
12857
  * Widened evidence check (PRD 1102, narrowed to per-job attribution by a
12683
12858
  * later PRD): does at least one commit ATTRIBUTABLE TO THIS JOB land AFTER
@@ -13154,6 +13329,7 @@ async function reverifyNeedsReview() {
13154
13329
  // rescan) rather than through the isRescanCandidate machinery.
13155
13330
  const candidates = snap.jobs.filter((j) => reviewLadder.isRescanCandidate(j) || reviewLadder.isGuardParkedWithoutAutoFix(j) || reviewLadder.isStaleSharedTreeRevertedPark(j));
13156
13331
  const healed = [];
13332
+ const transcriptHealed = new Map();
13157
13333
  const leftForReview = [];
13158
13334
  const looksDoneUpdates = [];
13159
13335
  // Shared across every computeLooksDone call in this one pass — dedupes
@@ -13223,6 +13399,9 @@ async function reverifyNeedsReview() {
13223
13399
  const hist = await queueHistory.historyTerminalBySlug().catch(() => null);
13224
13400
  priorLandedCommit = hist?.get(job.slug)?.landedCommit ?? null;
13225
13401
  }
13402
+ const transcriptOwn = !job.landedCommit && reviewLadder.NO_ATTRIBUTABLE_COMMIT_VERDICTS.has(job.verifierVerdict)
13403
+ ? await ownTranscriptCommitOnHead({ cwd: job.cwd, logPath: path.join(runDir, `${job.slug}.log`), startedAt: job.startedAt, finishedAt: job.finishedAt })
13404
+ : null;
13226
13405
  let v = null;
13227
13406
  try {
13228
13407
  v = await verifyRun({
@@ -13241,16 +13420,17 @@ async function reverifyNeedsReview() {
13241
13420
  // ground-truth-outranks-heuristics evidence spawnJob passes live,
13242
13421
  // just read back post-hoc since there is no in-flight guardHeadBefore/
13243
13422
  // headAtExit pair to recompute for an already-terminal row.
13244
- jobLandedCommitThisRun: job.landedCommit ?? null,
13423
+ jobLandedCommitThisRun: job.landedCommit ?? transcriptOwn,
13245
13424
  exitCode: job.exitCode ?? null,
13246
13425
  });
13247
13426
  } catch { leftForReview.push({ slug: job.slug, reason: 'verifyRun threw' }); continue; }
13248
- const refusal = reviewLadder.healRefusalReason(job, v, committedDuringRun);
13427
+ const refusal = reviewLadder.healRefusalReason(transcriptOwn ? { ...job, landedCommit: transcriptOwn } : job, v, committedDuringRun);
13249
13428
  let stillOpen = true;
13250
13429
  if (refusal) {
13251
13430
  leftForReview.push({ slug: job.slug, reason: refusal });
13252
13431
  } else if (v && COMPLETED_EQUIVALENT_VERDICTS.has(v.verdict)) {
13253
13432
  healed.push(job.slug);
13433
+ if (transcriptOwn) transcriptHealed.set(job.slug, transcriptOwn);
13254
13434
  stillOpen = false;
13255
13435
  } else {
13256
13436
  leftForReview.push({ slug: job.slug, reason: v ? `${v.verdict}: ${v.reason}` : 'null verdict' });
@@ -13356,6 +13536,10 @@ async function reverifyNeedsReview() {
13356
13536
  j.error = null;
13357
13537
  delete j.verifierVerdict;
13358
13538
  delete j.looksDone;
13539
+ if (transcriptHealed.has(j.slug) && !j.landedCommit) {
13540
+ j.landedCommit = transcriptHealed.get(j.slug);
13541
+ j.landedCommitSource = 'transcript-output';
13542
+ }
13359
13543
  healedPrds.push({ slug: j.slug, cwd: j.cwd });
13360
13544
  }
13361
13545
  }
@@ -15170,6 +15354,18 @@ const remote = {
15170
15354
  prdCreate.mcpReachDeps,
15171
15355
  ));
15172
15356
  } catch { /* advisory only — never fails the update */ }
15357
+ try {
15358
+ const effFiles = Array.isArray(files) ? files : extractDeclaredPaths(newBody);
15359
+ const crit = Array.isArray(fm.criteria) && fm.criteria.length
15360
+ ? fm.criteria.map((c) => (typeof c === 'string' ? c : c?.statement))
15361
+ : [extractPrdSection(newBody, 'Acceptance criteria')];
15362
+ patchWarnings = patchWarnings.concat(sandboxWarnings({
15363
+ files: effFiles,
15364
+ goal: extractPrdSection(newBody, 'Goal'),
15365
+ implementationNotes: extractPrdSection(newBody, 'Implementation notes'),
15366
+ acceptanceCriteria: crit.filter((c) => typeof c === 'string'),
15367
+ }));
15368
+ } catch { /* advisory only — never fails the update */ }
15173
15369
  return patchWarnings.length
15174
15370
  ? { ok: true, slug, bytesWritten: stat.size, warnings: patchWarnings }
15175
15371
  : { ok: true, slug, bytesWritten: stat.size };
@@ -15569,6 +15765,11 @@ queueOps.bindQueueAccess({
15569
15765
  });
15570
15766
 
15571
15767
  module.exports = {
15768
+ finishProtocolFlagsFor,
15769
+ FINISH_PLAN_REVIEWER_LINE,
15770
+ FINISH_ARTIFACT_ONLY_VERDICT_LINE,
15771
+ FINISH_PLAN_REVIEWER_COMMIT_LINE,
15772
+ readQueue,
15572
15773
  PARK_ERRORS,
15573
15774
  applyPlanReviewHolds,
15574
15775
  starveRootFor,
@@ -15659,6 +15860,7 @@ module.exports = {
15659
15860
  applyNeedsReviewAutoResolve,
15660
15861
  applyStuckFailedAutoSkip,
15661
15862
  computeLooksDone,
15863
+ ownTranscriptCommitOnHead,
15662
15864
  attributeLandedCommits,
15663
15865
  isPromotableOriginal,
15664
15866
  applyRcaClassification,
@@ -15748,6 +15950,7 @@ module.exports = {
15748
15950
  driveUpgradeDrain,
15749
15951
  clearStaleDrainAtBoot,
15750
15952
  stop,
15953
+ whenIdle,
15751
15954
  runDueJobs,
15752
15955
  pollLoop,
15753
15956
  maybeLaunchWhenAvailable,
@@ -1,4 +1,4 @@
1
- <!-- PRD_AUTHORING.md v36 -->
1
+ <!-- PRD_AUTHORING.md v37 -->
2
2
  # PRD Authoring Guide — Scheduler Safety Rules
3
3
 
4
4
  Rule: every PRD you queue follows the rules below.
@@ -239,7 +239,7 @@ Why: those verdicts mean the run ended without a clean verdict line, not that th
239
239
 
240
240
  Rule: a park caused by a DIFFERENT actor already finishing the same objective (a sibling PRD, a human) does not self-heal this way. Why: the job has no landed commit of its own. Confirm in the tree that the work is really done, then call `scheduler_archive_prd` with the slug. Archiving marks the job completed and frees the PRDs that depend on it. Never hand-edit `queue.json`: the scheduler and the watchdog both write it. Archiving clears a stale label; it does not fix a real bug.
241
241
 
242
- Rule: a no-commit PASS (`pass_no_commit`) completes only with a prior landed commit of the same slug, or when every path in the Files list landed on the base branch since the PRD was written. Otherwise it parks.
242
+ Rule: a no-commit PASS (`pass_no_commit`) completes only when the run's own commit is found (in its HEAD range, CLI-recorded, or named in its transcript and on HEAD), a prior commit of the same slug landed, or a commit on a Files path is attributable to this job (its branch or slug in the message); path overlap alone never counts. Otherwise it parks.
243
243
  Why: a tracked path existing is not proof this PRD's work shipped.
244
244
 
245
245
  ---
@@ -1478,6 +1478,24 @@ async function serviceRevoke(serviceId) {
1478
1478
  return { ok: true, relayRevoked };
1479
1479
  }
1480
1480
 
1481
+ /** Owner grant: set (or with [] revoke) where work a service opens auto-starts. Audited. */
1482
+ async function serviceSetStartWork(serviceId, targets) {
1483
+ const store = getServiceStore();
1484
+ if (!store.list().some((s) => s.serviceId === serviceId)) return { ok: false, error: 'no_such_service' };
1485
+ let service;
1486
+ try {
1487
+ service = await store.setStartWork(serviceId, targets);
1488
+ } catch (e) {
1489
+ return { ok: false, error: e?.message || 'invalid_targets' };
1490
+ }
1491
+ const granted = service.startWork ? service.startWork.targets : [];
1492
+ const detail = granted.length === 0
1493
+ ? `ok:revoked:service=${auditToken(serviceId)}`
1494
+ : `ok:granted:service=${auditToken(serviceId)}:targets=${granted.map((t) => String(t).replace(/[^\x20-\x7e]/g, '_').replace(/[,\s]/g, '_')).join(',').slice(0, 1000)}`;
1495
+ await auditLog(new Date().toISOString(), 'service:set-start-work', undefined, undefined, detail, null);
1496
+ return { ok: true, service: redactService(service) };
1497
+ }
1498
+
1481
1499
  /**
1482
1500
  * Owner denied a pending pairing: drop it from the store and fail + tear down
1483
1501
  * any service client waiting on it, so a later hello for it is refused.
@@ -2155,6 +2173,10 @@ function registerRemoteHandlers() {
2155
2173
  return serviceRevoke(serviceId);
2156
2174
  }));
2157
2175
 
2176
+ ipcMain.handle('webRemote:service-set-start-work', validated(schemas.webRemoteServiceSetStartWork, async ({ serviceId, targets }) => {
2177
+ return serviceSetStartWork(serviceId, targets);
2178
+ }));
2179
+
2158
2180
  ipcMain.handle('webRemote:relay-client-revoke', validated(schemas.webRemoteRelayClientRevoke, async ({ clientId }) => {
2159
2181
  return relayClientRevoke(clientId);
2160
2182
  }));
@@ -2992,6 +2992,8 @@ export interface WebRemoteService {
2992
2992
  lastSeenAt: number;
2993
2993
  /** How the pairing was approved: owner window (default) or the loopback admin API. */
2994
2994
  pairedVia?: 'window' | 'local';
2995
+ /** Owner grant: work this service opens in these projects ('*' = all) starts without a second approval. null = off. */
2996
+ startWork?: { targets: string[] } | null;
2995
2997
  }
2996
2998
 
2997
2999
  export interface WebRemotePendingService {
@@ -3043,6 +3045,10 @@ export type WebRemoteServicePairCancelResult =
3043
3045
  | { ok: true; cancelled: boolean; dropped: number }
3044
3046
  | { ok: false; error: string };
3045
3047
 
3048
+ export type WebRemoteServiceSetStartWorkResult =
3049
+ | { ok: true; service: WebRemoteService }
3050
+ | { ok: false; error: string };
3051
+
3046
3052
  export type WebRemoteServiceRevokeResult =
3047
3053
  | { ok: true; relayRevoked: boolean }
3048
3054
  | { ok: false; error: string };
@@ -3772,6 +3778,8 @@ export interface SessionManagerAPI {
3772
3778
  servicePairCancel: (pairingId: string) => Promise<WebRemoteServicePairCancelResult>;
3773
3779
  /** Revoke a paired service locally and at the relay (relay failure still revokes locally). */
3774
3780
  serviceRevoke: (serviceId: string) => Promise<WebRemoteServiceRevokeResult>;
3781
+ /** Set (or with [] revoke) the owner's startWork grant: projects ('*' = all) where work this service opens auto-starts. */
3782
+ serviceSetStartWork: (serviceId: string, targets: string[]) => Promise<WebRemoteServiceSetStartWorkResult>;
3775
3783
  /** Revoke an orphaned relay client. */
3776
3784
  relayClientRevoke: (clientId: string) => Promise<WebRemoteMutationResult>;
3777
3785
  };
@@ -2314,6 +2314,17 @@
2314
2314
  "serviceId"
2315
2315
  ]
2316
2316
  },
2317
+ {
2318
+ "ns": "webRemote",
2319
+ "method": "serviceSetStartWork",
2320
+ "channel": "webRemote:service-set-start-work",
2321
+ "kind": "invoke",
2322
+ "remote": "deny",
2323
+ "pack": [
2324
+ "serviceId",
2325
+ "targets"
2326
+ ]
2327
+ },
2317
2328
  {
2318
2329
  "ns": "webRemote",
2319
2330
  "method": "relayClientRevoke",
@@ -591,6 +591,8 @@ contextBridge.exposeInMainWorld('api', {
591
591
  servicePairCancel: (pairingId) => ipcRenderer.invoke('webRemote:service-pair-cancel', { pairingId }),
592
592
  /** Revoke a paired service locally and at the relay. */
593
593
  serviceRevoke: (serviceId) => ipcRenderer.invoke('webRemote:service-revoke', { serviceId }),
594
+ /** Owner grant: auto-start work this service opens in `targets` (cwds or '*'); [] revokes. */
595
+ serviceSetStartWork: (serviceId, targets) => ipcRenderer.invoke('webRemote:service-set-start-work', { serviceId, targets }),
594
596
  /** Revoke a relay client no local service owns (an orphan). */
595
597
  relayClientRevoke: (clientId) => ipcRenderer.invoke('webRemote:relay-client-revoke', { clientId }),
596
598
  /** Push event when revokeAll completes (main broadcasts webRemote:revoked-all). */