@event4u/agent-config 14.19.0 → 14.21.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 (161) hide show
  1. package/.augment-plugin/marketplace.json +3 -3
  2. package/.augment-plugin/plugin.json +1 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/CHANGELOG.md +351 -156
  5. package/README.md +1 -1
  6. package/agents/templates/.ai-council.yml.example +10 -0
  7. package/dist/agent-src/commands/agent-handoff.md +42 -41
  8. package/dist/agent-src/commands/analyze/inbox.md +1 -1
  9. package/dist/agent-src/commands/analyze/{reference-repo.md → repo.md} +247 -32
  10. package/dist/agent-src/commands/analyze/roadmap-repos.md +129 -0
  11. package/dist/agent-src/commands/analyze.md +12 -7
  12. package/dist/agent-src/commands/feature/plan.md +55 -16
  13. package/dist/agent-src/commands/feature/refactor.md +8 -3
  14. package/dist/agent-src/commands/humanize.md +48 -4
  15. package/dist/agent-src/contexts/execution/contract-decision-sheet.md +22 -1
  16. package/dist/agent-src/contexts/execution/host-capability-manifest.md +11 -2
  17. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +35 -2
  18. package/dist/agent-src/contexts/execution/terminal-states.md +4 -1
  19. package/dist/agent-src/rules/evaluator-independence.md +4 -4
  20. package/dist/agent-src/rules/external-reference-deep-dive.md +2 -2
  21. package/dist/agent-src/rules/untrusted-input-defense.md +0 -2
  22. package/dist/agent-src/skills/competitive-positioning/SKILL.md +2 -2
  23. package/dist/agent-src/skills/evaluate-llm-feature/SKILL.md +1 -1
  24. package/dist/agent-src/skills/humanizer/references/anti-aiisms.md +27 -11
  25. package/dist/agent-src/skills/learning-to-rule-or-skill/SKILL.md +1 -1
  26. package/dist/agent-src/skills/markitdown/SKILL.md +2 -2
  27. package/dist/agent-src/skills/repomix-packer/SKILL.md +1 -1
  28. package/dist/agent-src/skills/skill-improvement-pipeline/SKILL.md +28 -6
  29. package/dist/agent-src/skills/technical-specification/SKILL.md +4 -0
  30. package/dist/agent-src/skills/test-driven-development/SKILL.md +1 -3
  31. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  32. package/dist/agent-src/templates/features.md +5 -0
  33. package/dist/agent-src/templates/roadmaps.md +29 -1
  34. package/dist/agent-src/templates/scripts/telemetry/mcp_lite.ts +213 -0
  35. package/dist/agent-src/templates/scripts/telemetry/report_renderer.ts +16 -0
  36. package/dist/agent-src/templates/scripts/telemetry_report.ts +22 -2
  37. package/dist/cli/mcp/dispatch.js +10 -0
  38. package/dist/cli/mcp/stdio.js +33 -2
  39. package/dist/cli/mcp/telemetry.js +227 -0
  40. package/dist/cli-delegate/{chunk-KPBWFOPZ.js → chunk-2FTMENJL.js} +194 -37
  41. package/dist/cli-delegate/{chunk-PMEKGDED.js → chunk-2TAQ2K4V.js} +166 -1
  42. package/dist/cli-delegate/{chunk-GZTMRYCN.js → chunk-643Z7FIC.js} +79 -12
  43. package/dist/cli-delegate/{chunk-CYH5SP6M.js → chunk-I6RHFQEG.js} +151 -16
  44. package/dist/cli-delegate/{chunk-IDHUQIXP.js → chunk-J3RFNKG4.js} +41 -5
  45. package/dist/cli-delegate/{chunk-7PRE6ZV2.js → chunk-YS6XTLEK.js} +199 -4
  46. package/dist/cli-delegate/chunk-ZVBOHSVF.js +1109 -0
  47. package/dist/cli-delegate/cmd_conformance.js +88 -110
  48. package/dist/cli-delegate/cmd_doctor.js +3 -3
  49. package/dist/cli-delegate/cmd_export.js +2 -2
  50. package/dist/cli-delegate/cmd_handoff.js +42 -12
  51. package/dist/cli-delegate/cmd_memory_get.js +1 -1
  52. package/dist/cli-delegate/cmd_prune.js +2 -2
  53. package/dist/cli-delegate/cmd_route_audit.js +1 -1
  54. package/dist/cli-delegate/cmd_session_recycle.js +59 -902
  55. package/dist/cli-delegate/cmd_settings_migrate.js +2 -2
  56. package/dist/cli-delegate/cmd_sync.js +2 -2
  57. package/dist/cli-delegate/cmd_uninstall.js +2 -2
  58. package/dist/cli-delegate/cmd_validate.js +2 -2
  59. package/dist/discovery/deprecation-report.md +1 -1
  60. package/dist/discovery/discovery-manifest.json +62 -31
  61. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  62. package/dist/discovery/discovery-manifest.summary.md +3 -3
  63. package/dist/discovery/dormancy-report.md +1 -1
  64. package/dist/discovery/orphan-report.md +1 -1
  65. package/dist/discovery/packs.json +7 -6
  66. package/dist/discovery/trust-report.md +2 -2
  67. package/dist/discovery/workspaces.json +6 -5
  68. package/dist/hooks/dispatch.js +3801 -2803
  69. package/dist/install/install.mjs +396 -168
  70. package/dist/mcp/registry-manifest.json +3 -3
  71. package/dist/mcp/server.json +2 -2
  72. package/dist/mcp/server.mjs +809 -180
  73. package/dist/scripts/ai_council/content_ceiling.js +63 -0
  74. package/dist/scripts/ai_council/seat_policy.js +106 -0
  75. package/dist/scripts/ai_council/transport_resolver.js +21 -0
  76. package/dist/scripts/mcp_server/telemetry.js +148 -0
  77. package/docs/guidelines/agent-infra/naming.md +1 -1
  78. package/docs/guidelines/agent-infra/security-lint-containment.md +46 -6
  79. package/docs/guidelines/agent-infra/self-improvement-pipeline.md +4 -4
  80. package/docs/guidelines/agent-infra/untrusted-input-spotlighting.md +1 -1
  81. package/docs/guidelines/redundancy-taxonomy.md +28 -0
  82. package/llms.txt +14 -14
  83. package/package.json +1 -1
  84. package/src/agent-src/templates/scripts/telemetry/mcp_lite.ts +213 -0
  85. package/src/agent-src/templates/scripts/telemetry/report_renderer.ts +16 -0
  86. package/src/agent-src/templates/scripts/telemetry_report.ts +22 -2
  87. package/src/config/assurance-capability-registry.json +9 -0
  88. package/src/config/gate-coverage.yml +55 -0
  89. package/src/config/gate-violation-baselines.json +18 -6
  90. package/src/config/release-gate-locality.yml +4 -3
  91. package/src/scripts/_cli/cmd_session_recycle.ts +51 -3
  92. package/src/scripts/_lib/audit_field_provenance.ts +44 -3
  93. package/src/scripts/_lib/blocked_by_marker.ts +189 -0
  94. package/src/scripts/_lib/host_capability.ts +76 -1
  95. package/src/scripts/_lib/install_reach_checks.ts +33 -1
  96. package/src/scripts/_lib/mcp_bridge.ts +222 -10
  97. package/src/scripts/_lib/mcp_consent_residual.ts +173 -0
  98. package/src/scripts/_lib/orchestration_record.ts +23 -1
  99. package/src/scripts/_lib/recycle_envelope_paths.ts +190 -0
  100. package/src/scripts/_lib/release_highlights.ts +19 -211
  101. package/src/scripts/_lib/release_material.ts +27 -77
  102. package/src/scripts/_lib/release_position.ts +96 -0
  103. package/src/scripts/_lib/review_skipped_record.ts +17 -1
  104. package/src/scripts/_lib/security_lint.ts +179 -7
  105. package/src/scripts/_lib/self_repair.ts +141 -6
  106. package/src/scripts/_lib/self_repair_store.ts +273 -7
  107. package/src/scripts/_lib/structured_ask.ts +117 -0
  108. package/src/scripts/_lib/subagent_capsule.ts +155 -3
  109. package/src/scripts/_lib/tty_prompt.ts +76 -0
  110. package/src/scripts/ai_council/api_transport.ts +163 -0
  111. package/src/scripts/ai_council/clients.ts +58 -63
  112. package/src/scripts/ai_council/config.ts +13 -0
  113. package/src/scripts/ai_council/content_ceiling.ts +79 -0
  114. package/src/scripts/ai_council/jury_aggregate.ts +178 -0
  115. package/src/scripts/ai_council/seat_policy.ts +137 -0
  116. package/src/scripts/ai_council/status_surface.ts +79 -0
  117. package/src/scripts/ai_council/transport_resolver.ts +59 -1
  118. package/src/scripts/ai_tells_rules.ts +446 -5
  119. package/src/scripts/ask_block_census.ts +499 -0
  120. package/src/scripts/bench_humanizer_eval.ts +264 -40
  121. package/src/scripts/bench_prose_tells_fp.ts +198 -0
  122. package/src/scripts/build_rule_trigger_matrix.ts +5 -0
  123. package/src/scripts/check_branch_work_committed.ts +234 -0
  124. package/src/scripts/check_mcp_doc_drift.ts +217 -0
  125. package/src/scripts/check_pack_size.ts +321 -3
  126. package/src/scripts/check_release_highlights.ts +0 -157
  127. package/src/scripts/council_cli.ts +18 -27
  128. package/src/scripts/detect_ai_tells.ts +142 -20
  129. package/src/scripts/handoff_context_hook.ts +54 -7
  130. package/src/scripts/harvest_reference_tokens.ts +698 -0
  131. package/src/scripts/hook_manifest.json +1 -1
  132. package/src/scripts/hook_manifest.yaml +31 -1
  133. package/src/scripts/hooks/concern_registry.ts +2 -0
  134. package/src/scripts/hooks/delegation_nudge_hook.ts +45 -1
  135. package/src/scripts/hooks/one_question_per_ask_hook.ts +191 -0
  136. package/src/scripts/hooks/session_eol_hook.ts +18 -7
  137. package/src/scripts/install-hooks.sh +52 -0
  138. package/src/scripts/install.ts +4 -4
  139. package/src/scripts/lint_agent_security.ts +316 -25
  140. package/src/scripts/lint_confusables.ts +42 -6
  141. package/src/scripts/lint_handoffs.ts +0 -132
  142. package/src/scripts/lint_hidden_unicode.ts +49 -7
  143. package/src/scripts/lint_instruction_smuggling.ts +42 -6
  144. package/src/scripts/lint_mcp_config_security.ts +42 -6
  145. package/src/scripts/lint_roadmap_blockers.ts +51 -1
  146. package/src/scripts/lint_roadmap_later_disposition.ts +217 -27
  147. package/src/scripts/lint_skill_frontmatter_safety.ts +43 -7
  148. package/src/scripts/mcp_server/resources.ts +41 -0
  149. package/src/scripts/mcp_server/telemetry.ts +19 -4
  150. package/src/scripts/migrate_command_suggestions.ts +1 -1
  151. package/src/scripts/orchestration_record.ts +12 -1
  152. package/src/scripts/probe_unblocked_ask.ts +135 -2
  153. package/src/scripts/release.ts +50 -95
  154. package/src/scripts/release_drill.ts +6 -10
  155. package/src/scripts/release_env.ts +1 -0
  156. package/src/scripts/release_publication.ts +40 -31
  157. package/src/scripts/self_repair_cli.ts +31 -1
  158. package/src/scripts/self_review_gate.ts +409 -15
  159. package/src/scripts/skill_scout.ts +69 -0
  160. package/dist/cli-delegate/chunk-2GNWGMAL.js +0 -172
  161. package/dist/cli-delegate/chunk-LPPWO5CE.js +0 -161
@@ -17,16 +17,19 @@ import {
17
17
  } from "./chunk-M2DPGFZ4.js";
18
18
  import {
19
19
  DEFAULT_PROJECTS_ROOT,
20
+ DEFAULT_SEAT_CEILING,
21
+ admitsContent,
20
22
  aggregateByBucket,
21
23
  billableInputTokens,
22
24
  clients_exports,
23
25
  config_exports,
24
26
  hardenedSpawnEnv,
25
27
  load_cli_call_counts,
28
+ policyExclusionReason,
26
29
  projectStoreSlug,
27
30
  scanTranscripts,
28
31
  weightedInputUnits
29
- } from "./chunk-KPBWFOPZ.js";
32
+ } from "./chunk-2FTMENJL.js";
30
33
  import {
31
34
  git_common_dir
32
35
  } from "./chunk-E4XIZDIB.js";
@@ -34,11 +37,13 @@ import {
34
37
  DEFAULT_DEPLOY_ROOTS,
35
38
  MANAGED_SIGNATURE,
36
39
  SCHEMA_VERSIONS_SUPPORTED,
40
+ TOOL_TO_HOST,
37
41
  build_claude_hook_matrix,
38
42
  global_deploy_inventory_exports,
39
43
  manifest_path,
40
- read_manifest
41
- } from "./chunk-PMEKGDED.js";
44
+ read_manifest,
45
+ residualReport
46
+ } from "./chunk-2TAQ2K4V.js";
42
47
  import {
43
48
  read_lockfile
44
49
  } from "./chunk-T7L2QK3K.js";
@@ -2779,12 +2784,27 @@ function checkOverrideSet(projectRoot) {
2779
2784
  remedy: "route it through the upstream-contribution path, never by changing a shipped default on one install"
2780
2785
  };
2781
2786
  }
2782
- var REACH_CHECK_IDS = ["instruction-path-reach", "version-axis", "override-set"];
2787
+ function checkMcpConsentResidual() {
2788
+ const id = "mcp-consent-residual";
2789
+ const lines = residualReport(Object.keys(TOOL_TO_HOST));
2790
+ if (lines.length === 0) {
2791
+ return { id, status: "ok", message: "no MCP consent residual recorded for any known host", remedy: "" };
2792
+ }
2793
+ const actionable = lines.filter((l) => l.state === "residual");
2794
+ return {
2795
+ id,
2796
+ status: "warn",
2797
+ message: lines.map((l) => l.text).join(" \xB7 "),
2798
+ remedy: actionable.length > 0 ? "complete the step named above on each host you use" : "record an observation for the unchecked hosts, or ignore if you do not use them"
2799
+ };
2800
+ }
2801
+ var REACH_CHECK_IDS = ["instruction-path-reach", "version-axis", "override-set", "mcp-consent-residual"];
2783
2802
  function reachRunners(opts) {
2784
2803
  return {
2785
2804
  "instruction-path-reach": () => checkInstructionPaths(opts.projectRoot),
2786
2805
  "version-axis": () => checkVersionAxis(opts.projectRoot, opts.resolvableVersion),
2787
- "override-set": () => checkOverrideSet(opts.projectRoot)
2806
+ "override-set": () => checkOverrideSet(opts.projectRoot),
2807
+ "mcp-consent-residual": () => checkMcpConsentResidual()
2788
2808
  };
2789
2809
  }
2790
2810
 
@@ -3151,6 +3171,22 @@ function resolveTransport(opts) {
3151
3171
  const auth = strongestAuth(report, provider);
3152
3172
  const authSource = auth?.source ?? null;
3153
3173
  const billing = classifyBilling(provider, authSource);
3174
+ const exclusion = opts.policyExclusion ?? null;
3175
+ if (exclusion !== null) {
3176
+ return unavailable(provider, billing, policyExclusionReason(exclusion, provider), exclusion);
3177
+ }
3178
+ const contentClass = opts.contentClass ?? null;
3179
+ if (contentClass !== null) {
3180
+ const verdict = admitsContent(opts.seatCeiling ?? DEFAULT_SEAT_CEILING, contentClass);
3181
+ if (!verdict.admitted) {
3182
+ return unavailable(
3183
+ provider,
3184
+ billing,
3185
+ `${provider}: ${verdict.reason ?? "content ceiling refused the payload"}`,
3186
+ "policy_content_ceiling"
3187
+ );
3188
+ }
3189
+ }
3154
3190
  if (mode === "manual") {
3155
3191
  return {
3156
3192
  available: true,
@@ -9,6 +9,9 @@ import {
9
9
  session_state_file,
10
10
  update_json_under_lock
11
11
  } from "./chunk-E4XIZDIB.js";
12
+ import {
13
+ read_lockfile
14
+ } from "./chunk-T7L2QK3K.js";
12
15
 
13
16
  // src/scripts/_lib/secret_detector.ts
14
17
  var ENTROPY_MIN_TOKEN_LENGTH = 20;
@@ -219,7 +222,8 @@ var EPISTEMIC = new Set(EPISTEMIC_STATES);
219
222
  var MAX_REF_CHARS = 200;
220
223
  var MAX_LINE_CHARS = 240;
221
224
  var MAX_ENTRIES = 40;
222
- var CAPSULE_SCHEMA_VERSION = 3;
225
+ var CAPSULE_SCHEMA_VERSION = 4;
226
+ var ACCEPTED_CAPSULE_VERSIONS = [3, 4];
223
227
  function isShortLine(value, max) {
224
228
  return typeof value === "string" && value.length > 0 && value.length <= max && !value.includes("\n");
225
229
  }
@@ -378,6 +382,10 @@ var RECYCLE_ENVELOPE_KEYS = /* @__PURE__ */ new Set([
378
382
  "next_task",
379
383
  "suggested_skills",
380
384
  "failed_approaches",
385
+ "successful_approaches",
386
+ "open_questions",
387
+ "predecessor",
388
+ "session_id",
381
389
  "repo_identity",
382
390
  "branch",
383
391
  "head",
@@ -398,9 +406,11 @@ function validateRecycleEnvelope(input) {
398
406
  );
399
407
  }
400
408
  }
401
- if (e["capsule_version"] !== CAPSULE_SCHEMA_VERSION) {
402
- errors.push(`capsule_version must be ${CAPSULE_SCHEMA_VERSION}`);
409
+ const version = e["capsule_version"];
410
+ if (typeof version !== "number" || !ACCEPTED_CAPSULE_VERSIONS.includes(version)) {
411
+ errors.push(`capsule_version must be one of ${ACCEPTED_CAPSULE_VERSIONS.join(" | ")}`);
403
412
  }
413
+ const atV4 = version === 4;
404
414
  if (e["variant"] !== "main_session") {
405
415
  errors.push("variant must be 'main_session'");
406
416
  }
@@ -439,6 +449,26 @@ function validateRecycleEnvelope(input) {
439
449
  'failed_approaches must carry at least one entry \u2014 write "none" explicitly, so silence and "nothing was abandoned" stay distinguishable'
440
450
  );
441
451
  }
452
+ checkList(errors, "successful_approaches", e["successful_approaches"], MAX_LINE_CHARS, atV4);
453
+ if (Array.isArray(e["successful_approaches"]) && e["successful_approaches"].length === 0) {
454
+ errors.push(
455
+ 'successful_approaches must carry at least one entry \u2014 write "none" explicitly, so silence and "nothing worked" stay distinguishable'
456
+ );
457
+ }
458
+ checkList(errors, "open_questions", e["open_questions"], MAX_LINE_CHARS, false);
459
+ const predecessor = e["predecessor"];
460
+ if (predecessor === void 0) {
461
+ if (atV4) {
462
+ errors.push(
463
+ 'predecessor is required \u2014 name the session this one continues, or write "none" explicitly for the first session in a workspace'
464
+ );
465
+ }
466
+ } else if (!isShortLine(predecessor, MAX_REF_CHARS)) {
467
+ errors.push(`predecessor must be a single line of 1\u2013${MAX_REF_CHARS} chars ("none" when there is no predecessor)`);
468
+ }
469
+ if (e["session_id"] !== void 0 && !isShortLine(e["session_id"], MAX_REF_CHARS)) {
470
+ errors.push(`session_id must be a single line of 1\u2013${MAX_REF_CHARS} chars`);
471
+ }
442
472
  for (const field of ["repo_identity", "branch", "head", "status_summary", "last_verify"]) {
443
473
  if (e[field] !== void 0 && !isShortLine(e[field], MAX_REF_CHARS)) {
444
474
  errors.push(`${field} must be a single line of 1\u2013${MAX_REF_CHARS} chars`);
@@ -803,6 +833,164 @@ if (isCliEntry) {
803
833
  process.exit(main(process.argv.slice(2)));
804
834
  }
805
835
 
836
+ // src/scripts/_lib/turn_end_refusals.ts
837
+ import * as crypto from "node:crypto";
838
+ import * as fs2 from "node:fs";
839
+ import * as path2 from "node:path";
840
+ var DETECTOR_IDS = [
841
+ "promissory",
842
+ "language",
843
+ "verification",
844
+ "completion"
845
+ ];
846
+ var REFUSAL_STATE_REL = path2.join("agents", "runtime", "state", "turn-end-gate");
847
+ function refusalStateDir(workspaceRoot) {
848
+ return path2.join(workspaceRoot, REFUSAL_STATE_REL);
849
+ }
850
+ function deriveSessionKey(sessionId) {
851
+ return crypto.createHash("sha256").update(sessionId).digest("hex").slice(0, 32);
852
+ }
853
+ function sessionRefusalFile(workspaceRoot, sessionKey) {
854
+ return path2.join(refusalStateDir(workspaceRoot), `${sessionKey}.json`);
855
+ }
856
+ function readSessionCounts(workspaceRoot, sessionId) {
857
+ try {
858
+ const raw = fs2.readFileSync(
859
+ sessionRefusalFile(workspaceRoot, deriveSessionKey(sessionId)),
860
+ "utf-8"
861
+ );
862
+ const rec = parseRecord(raw);
863
+ return rec === null ? null : countsOf(rec);
864
+ } catch {
865
+ return null;
866
+ }
867
+ }
868
+ function emptyCounts() {
869
+ return { promissory: 0, language: 0, verification: 0, completion: 0 };
870
+ }
871
+ function isDetector(v) {
872
+ return typeof v === "string" && DETECTOR_IDS.includes(v);
873
+ }
874
+ function parseRecord(raw) {
875
+ let decoded;
876
+ try {
877
+ decoded = JSON.parse(raw);
878
+ } catch {
879
+ return null;
880
+ }
881
+ if (typeof decoded !== "object" || decoded === null || Array.isArray(decoded)) return null;
882
+ const o = decoded;
883
+ if (typeof o["refused_at"] !== "string") return null;
884
+ if (typeof o["refused_turn"] !== "number") return null;
885
+ if (!isDetector(o["detector"])) return null;
886
+ const rec = {
887
+ refused_at: o["refused_at"],
888
+ refused_turn: o["refused_turn"],
889
+ detector: o["detector"]
890
+ };
891
+ if (typeof o["first_refused_at"] === "string") rec.first_refused_at = o["first_refused_at"];
892
+ if (typeof o["agent_config_version"] === "string") {
893
+ rec.agent_config_version = o["agent_config_version"];
894
+ }
895
+ const counts = o["counts"];
896
+ if (typeof counts === "object" && counts !== null && !Array.isArray(counts)) {
897
+ const parsed = {};
898
+ for (const id of DETECTOR_IDS) {
899
+ const n = counts[id];
900
+ if (typeof n === "number" && Number.isFinite(n) && n >= 0) parsed[id] = n;
901
+ }
902
+ rec.counts = parsed;
903
+ }
904
+ return rec;
905
+ }
906
+ function countsOf(rec) {
907
+ const out = emptyCounts();
908
+ if (rec.counts === void 0) {
909
+ out[rec.detector] = 1;
910
+ return out;
911
+ }
912
+ let any = false;
913
+ for (const id of DETECTOR_IDS) {
914
+ const n = rec.counts[id];
915
+ if (typeof n === "number" && n > 0) {
916
+ out[id] = n;
917
+ any = true;
918
+ }
919
+ }
920
+ if (!any) out[rec.detector] = 1;
921
+ return out;
922
+ }
923
+ function foldRefusal(prev, input) {
924
+ const counts = prev === null ? emptyCounts() : countsOf(prev);
925
+ for (const d of input.detectors) counts[d] += 1;
926
+ const primary = input.detectors[0] ?? prev?.detector ?? "verification";
927
+ const rec = {
928
+ refused_at: input.at,
929
+ refused_turn: input.turnOrdinal,
930
+ detector: primary,
931
+ first_refused_at: prev?.first_refused_at ?? prev?.refused_at ?? input.at,
932
+ counts
933
+ };
934
+ if (input.version !== void 0) rec.agent_config_version = input.version;
935
+ else if (prev?.agent_config_version !== void 0) {
936
+ rec.agent_config_version = prev.agent_config_version;
937
+ }
938
+ return rec;
939
+ }
940
+ function readInstallBoundary() {
941
+ try {
942
+ const lock = read_lockfile();
943
+ if (lock === null) return { version: null, installed_at: null };
944
+ return {
945
+ version: lock.agent_config_version ?? null,
946
+ installed_at: lock.installed_at ?? null
947
+ };
948
+ } catch {
949
+ return { version: null, installed_at: null };
950
+ }
951
+ }
952
+ var REFUSAL_STATE_MAX_AGE_DAYS = 90;
953
+ function pruneAgedRefusalState(workspaceRoot, opts = {}) {
954
+ const maxAgeDays = opts.maxAgeDays ?? REFUSAL_STATE_MAX_AGE_DAYS;
955
+ const now = opts.now ?? /* @__PURE__ */ new Date();
956
+ const dir = refusalStateDir(workspaceRoot);
957
+ const result = { scanned: 0, pruned: 0, kept: 0 };
958
+ let entries;
959
+ try {
960
+ entries = fs2.readdirSync(dir);
961
+ } catch {
962
+ return result;
963
+ }
964
+ const cutoffMs = now.getTime() - maxAgeDays * 24 * 60 * 60 * 1e3;
965
+ for (const name of entries) {
966
+ if (!name.endsWith(".json")) continue;
967
+ result.scanned += 1;
968
+ const file = path2.join(dir, name);
969
+ let rec = null;
970
+ try {
971
+ rec = parseRecord(fs2.readFileSync(file, "utf-8"));
972
+ } catch {
973
+ rec = null;
974
+ }
975
+ if (rec === null) {
976
+ result.kept += 1;
977
+ continue;
978
+ }
979
+ const at = Date.parse(rec.refused_at);
980
+ if (!Number.isFinite(at) || at >= cutoffMs) {
981
+ result.kept += 1;
982
+ continue;
983
+ }
984
+ try {
985
+ fs2.unlinkSync(file);
986
+ result.pruned += 1;
987
+ } catch {
988
+ result.kept += 1;
989
+ }
990
+ }
991
+ return result;
992
+ }
993
+
806
994
  export {
807
995
  statePathFor,
808
996
  isVacuousOutput,
@@ -813,5 +1001,12 @@ export {
813
1001
  wrapAsPriorSessionData,
814
1002
  hasBoundaryMarker,
815
1003
  validateRecycleEnvelope,
816
- validateAssumption
1004
+ validateAssumption,
1005
+ deriveSessionKey,
1006
+ sessionRefusalFile,
1007
+ readSessionCounts,
1008
+ parseRecord,
1009
+ foldRefusal,
1010
+ readInstallBoundary,
1011
+ pruneAgedRefusalState
817
1012
  };