observability-toolkit-hooks 0.0.0-stage → 1.0.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 (305) hide show
  1. package/CONFIG.md +144 -0
  2. package/README.md +201 -2
  3. package/dist/handlers/compact.js +38 -0
  4. package/dist/handlers/mcp-status.js +66 -0
  5. package/dist/handlers/notification.js +45 -0
  6. package/dist/handlers/post-tool-agent.js +157 -0
  7. package/dist/handlers/post-tool-changelog-sync.js +148 -0
  8. package/dist/handlers/post-tool-code-structure.js +116 -0
  9. package/dist/handlers/post-tool-edit-ledger.js +15 -0
  10. package/dist/handlers/post-tool-failure.js +83 -0
  11. package/dist/handlers/post-tool-git.js +79 -0
  12. package/dist/handlers/post-tool-mcp.js +105 -0
  13. package/dist/handlers/post-tool-outcome.js +48 -0
  14. package/dist/handlers/post-tool-task-state.js +74 -0
  15. package/dist/handlers/post-tool.js +132 -0
  16. package/dist/handlers/pre-tool-agent.js +192 -0
  17. package/dist/handlers/pre-tool.js +218 -0
  18. package/dist/handlers/session-end.js +39 -0
  19. package/dist/handlers/session-start.js +262 -0
  20. package/dist/handlers/stop-error-reminder.js +195 -0
  21. package/dist/handlers/stop-quality-evaluation.js +58 -0
  22. package/dist/handlers/stop-session-summary.js +62 -0
  23. package/dist/handlers/stop-token-metrics.js +83 -0
  24. package/dist/handlers/stop.js +25 -0
  25. package/dist/handlers/subagent.js +105 -0
  26. package/dist/handlers/tool-event-router.js +39 -0
  27. package/dist/handlers/user-prompt.js +218 -0
  28. package/dist/hook-runner.js +10 -0
  29. package/dist/hook-runner.js.map +7 -0
  30. package/dist/lib/agent/agent-context.js +123 -0
  31. package/dist/lib/agent/agent-evaluations.js +155 -0
  32. package/dist/lib/agent/agent-file-budget.js +65 -0
  33. package/dist/lib/agent/agent-sources.js +165 -0
  34. package/dist/lib/agent/synth-spans.js +51 -0
  35. package/dist/lib/core/bounded-label.js +6 -0
  36. package/dist/lib/core/category-rules.js +11 -0
  37. package/dist/lib/core/child-result.js +19 -0
  38. package/dist/lib/core/config-dir-recovery.js +22 -0
  39. package/dist/lib/core/constants.js +171 -0
  40. package/dist/lib/core/detached-runner.js +55 -0
  41. package/dist/lib/core/file-utils.js +353 -0
  42. package/dist/lib/core/format-utils.js +51 -0
  43. package/dist/lib/core/http-utils.js +74 -0
  44. package/dist/lib/core/http1-fetch.js +14 -0
  45. package/dist/lib/core/identity-key-resolver.js +149 -0
  46. package/dist/lib/core/jsonl-tail.js +207 -0
  47. package/dist/lib/core/load-envrc.js +72 -0
  48. package/dist/lib/core/parsers.js +43 -0
  49. package/dist/lib/core/regex.js +27 -0
  50. package/dist/lib/core/settings-env.js +31 -0
  51. package/dist/lib/core/shell-command.js +122 -0
  52. package/dist/lib/core/units.js +97 -0
  53. package/dist/lib/git/git-cache.js +158 -0
  54. package/dist/lib/git/git-commit.js +189 -0
  55. package/dist/lib/git/git-exec.js +30 -0
  56. package/dist/lib/mcp/mcp-completeness.js +40 -0
  57. package/dist/lib/mcp/mcp-config.js +118 -0
  58. package/dist/lib/mcp/mcp-failure-latch.js +22 -0
  59. package/dist/lib/mcp/mcp-identity-launcher.js +43 -0
  60. package/dist/lib/otel/attributes.js +322 -0
  61. package/dist/lib/otel/evaluation-attrs.js +51 -0
  62. package/dist/lib/otel/file-exporters.js +169 -0
  63. package/dist/lib/otel/host-resource.js +61 -0
  64. package/dist/lib/otel/otel-headers-helper.js +26 -0
  65. package/dist/lib/otel/otel-monitor.js +181 -0
  66. package/dist/lib/otel/otel.js +235 -0
  67. package/dist/lib/otel/otlp-headers.js +101 -0
  68. package/dist/lib/otel/otlp-post.js +122 -0
  69. package/dist/lib/otel/otlp-serialize.js +142 -0
  70. package/dist/lib/otel/otlp-signal.js +2 -0
  71. package/dist/lib/otel/remote-spans.js +142 -0
  72. package/dist/lib/otel/service-identity.js +10 -0
  73. package/dist/lib/otel/telemetry-alerts.js +43 -0
  74. package/dist/lib/otel/token-metrics.js +122 -0
  75. package/dist/lib/otel/trace-context.js +81 -0
  76. package/dist/lib/quality/judge-meta-eval.js +70 -0
  77. package/dist/lib/quality/judge-prompts.js +104 -0
  78. package/dist/lib/quality/judge-providers.js +193 -0
  79. package/dist/lib/quality/judge-transport.js +93 -0
  80. package/dist/lib/quality/llm-judge.js +170 -0
  81. package/dist/lib/quality/quality-budget.js +99 -0
  82. package/dist/lib/quality/quality-degradation.js +156 -0
  83. package/dist/lib/quality/quality-eval-handoff.js +74 -0
  84. package/dist/lib/quality/quality-evaluator.js +178 -0
  85. package/dist/lib/quality/quality-sampler.js +43 -0
  86. package/dist/lib/quality/quality-signals.js +150 -0
  87. package/dist/lib/runtime/categorizers.js +101 -0
  88. package/dist/lib/runtime/hook-input.js +16 -0
  89. package/dist/lib/runtime/hook-output.js +50 -0
  90. package/dist/lib/runtime/output-analyzer.js +160 -0
  91. package/dist/lib/runtime/run-handlers.js +32 -0
  92. package/dist/lib/runtime/tool-input.js +111 -0
  93. package/dist/lib/runtime/tool-output.js +44 -0
  94. package/dist/lib/runtime/unknown-tool.js +32 -0
  95. package/dist/lib/session/edit-ledger.js +29 -0
  96. package/dist/lib/session/forked-skill.js +39 -0
  97. package/dist/lib/session/handoffs.js +77 -0
  98. package/dist/lib/session/session-state.js +169 -0
  99. package/dist/lib/session/skill-rules.js +196 -0
  100. package/dist/lib/session/task-tracker.js +83 -0
  101. package/dist/lib/shipper/shipper-credentials.js +38 -0
  102. package/dist/lib/shipper/shipper-cursor.js +89 -0
  103. package/dist/lib/shipper/shipper-status.js +174 -0
  104. package/dist/lib/shipper/span-shipper.js +272 -0
  105. package/dist/lib/shipper/telemetry-shipper.js +39 -0
  106. package/dist/lib/transcript/agent-transcript-metrics.js +34 -0
  107. package/dist/lib/transcript/context-breakdown.js +134 -0
  108. package/dist/lib/transcript/context-history.js +69 -0
  109. package/dist/lib/transcript/context-tracker.js +226 -0
  110. package/dist/lib/transcript/message-count.js +49 -0
  111. package/dist/lib/transcript/model-ids.js +36 -0
  112. package/dist/lib/transcript/model-pricing.js +153 -0
  113. package/dist/lib/transcript/token-metrics-checkpoint.js +152 -0
  114. package/dist/lib/transcript/tool-call-durations.js +64 -0
  115. package/dist/lib/transcript/transcript-entry.js +67 -0
  116. package/dist/lib/transcript/transcript-fold.js +130 -0
  117. package/dist/lib/transcript/transcript-layout.js +39 -0
  118. package/dist/lib/transcript/transcript-parser.js +117 -0
  119. package/dist/runner/agent-context-4XTCLMLZ.js +23 -0
  120. package/dist/runner/agent-context-4XTCLMLZ.js.map +7 -0
  121. package/dist/runner/agent-file-budget-Q33ESBBE.js +68 -0
  122. package/dist/runner/agent-file-budget-Q33ESBBE.js.map +7 -0
  123. package/dist/runner/agent-transcript-metrics-W5CZZFMI.js +39 -0
  124. package/dist/runner/agent-transcript-metrics-W5CZZFMI.js.map +7 -0
  125. package/dist/runner/chunk-2NTNAJZE.js +49 -0
  126. package/dist/runner/chunk-2NTNAJZE.js.map +7 -0
  127. package/dist/runner/chunk-4KWBQTTG.js +78 -0
  128. package/dist/runner/chunk-4KWBQTTG.js.map +7 -0
  129. package/dist/runner/chunk-52RY6LQT.js +699 -0
  130. package/dist/runner/chunk-52RY6LQT.js.map +7 -0
  131. package/dist/runner/chunk-7OM5CYES.js +8695 -0
  132. package/dist/runner/chunk-7OM5CYES.js.map +7 -0
  133. package/dist/runner/chunk-7PEOKGYR.js +1568 -0
  134. package/dist/runner/chunk-7PEOKGYR.js.map +7 -0
  135. package/dist/runner/chunk-AGSGKELQ.js +126 -0
  136. package/dist/runner/chunk-AGSGKELQ.js.map +7 -0
  137. package/dist/runner/chunk-AVM7PJFW.js +12 -0
  138. package/dist/runner/chunk-AVM7PJFW.js.map +7 -0
  139. package/dist/runner/chunk-C3WHUMU5.js +178 -0
  140. package/dist/runner/chunk-C3WHUMU5.js.map +7 -0
  141. package/dist/runner/chunk-DGB4NSSD.js +157 -0
  142. package/dist/runner/chunk-DGB4NSSD.js.map +7 -0
  143. package/dist/runner/chunk-DNSTWC26.js +151 -0
  144. package/dist/runner/chunk-DNSTWC26.js.map +7 -0
  145. package/dist/runner/chunk-FDJJ3TYU.js +449 -0
  146. package/dist/runner/chunk-FDJJ3TYU.js.map +7 -0
  147. package/dist/runner/chunk-FGKYDQHZ.js +137 -0
  148. package/dist/runner/chunk-FGKYDQHZ.js.map +7 -0
  149. package/dist/runner/chunk-GG2I4TGI.js +582 -0
  150. package/dist/runner/chunk-GG2I4TGI.js.map +7 -0
  151. package/dist/runner/chunk-GNNKUMRF.js +60 -0
  152. package/dist/runner/chunk-GNNKUMRF.js.map +7 -0
  153. package/dist/runner/chunk-I7TD2QVR.js +118 -0
  154. package/dist/runner/chunk-I7TD2QVR.js.map +7 -0
  155. package/dist/runner/chunk-IJ4SLUBV.js +78 -0
  156. package/dist/runner/chunk-IJ4SLUBV.js.map +7 -0
  157. package/dist/runner/chunk-IY7AP7NA.js +32 -0
  158. package/dist/runner/chunk-IY7AP7NA.js.map +7 -0
  159. package/dist/runner/chunk-J3F3Z3EQ.js +177 -0
  160. package/dist/runner/chunk-J3F3Z3EQ.js.map +7 -0
  161. package/dist/runner/chunk-JLEO5OHU.js +104 -0
  162. package/dist/runner/chunk-JLEO5OHU.js.map +7 -0
  163. package/dist/runner/chunk-JRNNLOPR.js +168 -0
  164. package/dist/runner/chunk-JRNNLOPR.js.map +7 -0
  165. package/dist/runner/chunk-KGSA5JYP.js +82 -0
  166. package/dist/runner/chunk-KGSA5JYP.js.map +7 -0
  167. package/dist/runner/chunk-LBCZAYFR.js +125 -0
  168. package/dist/runner/chunk-LBCZAYFR.js.map +7 -0
  169. package/dist/runner/chunk-LHWRXY2G.js +41 -0
  170. package/dist/runner/chunk-LHWRXY2G.js.map +7 -0
  171. package/dist/runner/chunk-LQ2LGUYJ.js +41 -0
  172. package/dist/runner/chunk-LQ2LGUYJ.js.map +7 -0
  173. package/dist/runner/chunk-LYY6RCIE.js +158 -0
  174. package/dist/runner/chunk-LYY6RCIE.js.map +7 -0
  175. package/dist/runner/chunk-M4R4QIQH.js +41 -0
  176. package/dist/runner/chunk-M4R4QIQH.js.map +7 -0
  177. package/dist/runner/chunk-MC75VXMX.js +207 -0
  178. package/dist/runner/chunk-MC75VXMX.js.map +7 -0
  179. package/dist/runner/chunk-NKZU4RRG.js +104 -0
  180. package/dist/runner/chunk-NKZU4RRG.js.map +7 -0
  181. package/dist/runner/chunk-PJHWHJ3K.js +56 -0
  182. package/dist/runner/chunk-PJHWHJ3K.js.map +7 -0
  183. package/dist/runner/chunk-RIGVYJ2O.js +114 -0
  184. package/dist/runner/chunk-RIGVYJ2O.js.map +7 -0
  185. package/dist/runner/chunk-RWRGC7ZK.js +93 -0
  186. package/dist/runner/chunk-RWRGC7ZK.js.map +7 -0
  187. package/dist/runner/chunk-SRMAJQMV.js +54 -0
  188. package/dist/runner/chunk-SRMAJQMV.js.map +7 -0
  189. package/dist/runner/chunk-TRMFD36J.js +47 -0
  190. package/dist/runner/chunk-TRMFD36J.js.map +7 -0
  191. package/dist/runner/chunk-U4IOZYQ3.js +21 -0
  192. package/dist/runner/chunk-U4IOZYQ3.js.map +7 -0
  193. package/dist/runner/chunk-UEXDE3WP.js +83 -0
  194. package/dist/runner/chunk-UEXDE3WP.js.map +7 -0
  195. package/dist/runner/chunk-UW3GQZSM.js +50 -0
  196. package/dist/runner/chunk-UW3GQZSM.js.map +7 -0
  197. package/dist/runner/chunk-V2GSP6VR.js +46 -0
  198. package/dist/runner/chunk-V2GSP6VR.js.map +7 -0
  199. package/dist/runner/chunk-VOV4Y5VU.js +81 -0
  200. package/dist/runner/chunk-VOV4Y5VU.js.map +7 -0
  201. package/dist/runner/chunk-VT5T6OEI.js +65 -0
  202. package/dist/runner/chunk-VT5T6OEI.js.map +7 -0
  203. package/dist/runner/chunk-VUYVFWIN.js +12 -0
  204. package/dist/runner/chunk-VUYVFWIN.js.map +7 -0
  205. package/dist/runner/chunk-VVGOPPEN.js +36 -0
  206. package/dist/runner/chunk-VVGOPPEN.js.map +7 -0
  207. package/dist/runner/chunk-VXFSLM6P.js +14 -0
  208. package/dist/runner/chunk-VXFSLM6P.js.map +7 -0
  209. package/dist/runner/chunk-W3EK7JUT.js +26125 -0
  210. package/dist/runner/chunk-W3EK7JUT.js.map +7 -0
  211. package/dist/runner/chunk-WJHNCOUF.js +52 -0
  212. package/dist/runner/chunk-WJHNCOUF.js.map +7 -0
  213. package/dist/runner/chunk-WU7ANGCW.js +269 -0
  214. package/dist/runner/chunk-WU7ANGCW.js.map +7 -0
  215. package/dist/runner/chunk-X7XLMSZX.js +44 -0
  216. package/dist/runner/chunk-X7XLMSZX.js.map +7 -0
  217. package/dist/runner/chunk-XSO3B4QN.js +124 -0
  218. package/dist/runner/chunk-XSO3B4QN.js.map +7 -0
  219. package/dist/runner/chunk-YGFN3LN2.js +174 -0
  220. package/dist/runner/chunk-YGFN3LN2.js.map +7 -0
  221. package/dist/runner/chunk-YHYDBLVB.js +33 -0
  222. package/dist/runner/chunk-YHYDBLVB.js.map +7 -0
  223. package/dist/runner/compact-36NP3PKT.js +60 -0
  224. package/dist/runner/compact-36NP3PKT.js.map +7 -0
  225. package/dist/runner/getMachineId-bsd-AGENNHN6.js +42 -0
  226. package/dist/runner/getMachineId-bsd-AGENNHN6.js.map +7 -0
  227. package/dist/runner/getMachineId-bsd-I5WZGCL4.js +33 -0
  228. package/dist/runner/getMachineId-bsd-I5WZGCL4.js.map +7 -0
  229. package/dist/runner/getMachineId-bsd-ZXK225P7.js +33 -0
  230. package/dist/runner/getMachineId-bsd-ZXK225P7.js.map +7 -0
  231. package/dist/runner/getMachineId-darwin-47GDLEXL.js +42 -0
  232. package/dist/runner/getMachineId-darwin-47GDLEXL.js.map +7 -0
  233. package/dist/runner/getMachineId-darwin-5CRLMDD6.js +33 -0
  234. package/dist/runner/getMachineId-darwin-5CRLMDD6.js.map +7 -0
  235. package/dist/runner/getMachineId-darwin-ADG4I32N.js +33 -0
  236. package/dist/runner/getMachineId-darwin-ADG4I32N.js.map +7 -0
  237. package/dist/runner/getMachineId-linux-5KVS3T2M.js +27 -0
  238. package/dist/runner/getMachineId-linux-5KVS3T2M.js.map +7 -0
  239. package/dist/runner/getMachineId-linux-GDFB5GSO.js +34 -0
  240. package/dist/runner/getMachineId-linux-GDFB5GSO.js.map +7 -0
  241. package/dist/runner/getMachineId-linux-NQMWCRO3.js +27 -0
  242. package/dist/runner/getMachineId-linux-NQMWCRO3.js.map +7 -0
  243. package/dist/runner/getMachineId-unsupported-5PFIGMVX.js +18 -0
  244. package/dist/runner/getMachineId-unsupported-5PFIGMVX.js.map +7 -0
  245. package/dist/runner/getMachineId-unsupported-DW27K3ZX.js +18 -0
  246. package/dist/runner/getMachineId-unsupported-DW27K3ZX.js.map +7 -0
  247. package/dist/runner/getMachineId-unsupported-XV3FHTHD.js +25 -0
  248. package/dist/runner/getMachineId-unsupported-XV3FHTHD.js.map +7 -0
  249. package/dist/runner/getMachineId-win-5JVMW3EI.js +44 -0
  250. package/dist/runner/getMachineId-win-5JVMW3EI.js.map +7 -0
  251. package/dist/runner/getMachineId-win-SNESQF7R.js +35 -0
  252. package/dist/runner/getMachineId-win-SNESQF7R.js.map +7 -0
  253. package/dist/runner/getMachineId-win-UJYHSBM2.js +35 -0
  254. package/dist/runner/getMachineId-win-UJYHSBM2.js.map +7 -0
  255. package/dist/runner/git-commit-BA53DOJQ.js +30 -0
  256. package/dist/runner/git-commit-BA53DOJQ.js.map +7 -0
  257. package/dist/runner/hook-runner-JHH6PGKE.js +220 -0
  258. package/dist/runner/hook-runner-JHH6PGKE.js.map +7 -0
  259. package/dist/runner/judge-transport-R4TF5LEH.js +91 -0
  260. package/dist/runner/judge-transport-R4TF5LEH.js.map +7 -0
  261. package/dist/runner/mcp-status-QEUH2KGX.js +89 -0
  262. package/dist/runner/mcp-status-QEUH2KGX.js.map +7 -0
  263. package/dist/runner/notification-FKMBCSXF.js +69 -0
  264. package/dist/runner/notification-FKMBCSXF.js.map +7 -0
  265. package/dist/runner/post-tool-3MRHTBKH.js +192 -0
  266. package/dist/runner/post-tool-3MRHTBKH.js.map +7 -0
  267. package/dist/runner/post-tool-agent-BB34MNHI.js +370 -0
  268. package/dist/runner/post-tool-agent-BB34MNHI.js.map +7 -0
  269. package/dist/runner/post-tool-changelog-sync-OP2TT2I7.js +147 -0
  270. package/dist/runner/post-tool-changelog-sync-OP2TT2I7.js.map +7 -0
  271. package/dist/runner/post-tool-code-structure-LE7J2SC2.js +130 -0
  272. package/dist/runner/post-tool-code-structure-LE7J2SC2.js.map +7 -0
  273. package/dist/runner/post-tool-edit-ledger-IJMEYHKF.js +30 -0
  274. package/dist/runner/post-tool-edit-ledger-IJMEYHKF.js.map +7 -0
  275. package/dist/runner/post-tool-failure-XTH2I2Z7.js +111 -0
  276. package/dist/runner/post-tool-failure-XTH2I2Z7.js.map +7 -0
  277. package/dist/runner/post-tool-git-E46HZGZO.js +94 -0
  278. package/dist/runner/post-tool-git-E46HZGZO.js.map +7 -0
  279. package/dist/runner/post-tool-mcp-AMCDY5GH.js +144 -0
  280. package/dist/runner/post-tool-mcp-AMCDY5GH.js.map +7 -0
  281. package/dist/runner/post-tool-task-state-TLDOI33H.js +100 -0
  282. package/dist/runner/post-tool-task-state-TLDOI33H.js.map +7 -0
  283. package/dist/runner/pre-tool-SQE2FZQO.js +245 -0
  284. package/dist/runner/pre-tool-SQE2FZQO.js.map +7 -0
  285. package/dist/runner/pre-tool-agent-OZUPVFUI.js +218 -0
  286. package/dist/runner/pre-tool-agent-OZUPVFUI.js.map +7 -0
  287. package/dist/runner/quality-evaluator-XYNDKDRG.js +901 -0
  288. package/dist/runner/quality-evaluator-XYNDKDRG.js.map +7 -0
  289. package/dist/runner/session-end-3MJTDLLA.js +57 -0
  290. package/dist/runner/session-end-3MJTDLLA.js.map +7 -0
  291. package/dist/runner/session-start-5ZMCLKBS.js +352 -0
  292. package/dist/runner/session-start-5ZMCLKBS.js.map +7 -0
  293. package/dist/runner/shipper-status-MADX6SPG.js +37 -0
  294. package/dist/runner/shipper-status-MADX6SPG.js.map +7 -0
  295. package/dist/runner/span-shipper-4HQDHC47.js +3408 -0
  296. package/dist/runner/span-shipper-4HQDHC47.js.map +7 -0
  297. package/dist/runner/stop-RTKSIYJV.js +596 -0
  298. package/dist/runner/stop-RTKSIYJV.js.map +7 -0
  299. package/dist/runner/subagent-CBCG4OLZ.js +116 -0
  300. package/dist/runner/subagent-CBCG4OLZ.js.map +7 -0
  301. package/dist/runner/token-metrics-AD2RAFGM.js +31 -0
  302. package/dist/runner/token-metrics-AD2RAFGM.js.map +7 -0
  303. package/dist/runner/user-prompt-T5NZ2UJD.js +376 -0
  304. package/dist/runner/user-prompt-T5NZ2UJD.js.map +7 -0
  305. package/package.json +68 -5
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../handlers/session-start.ts", "../../../lib/runtime/hook-input.ts", "../../../lib/session/handoffs.ts"],
4
+ "sourcesContent": ["/** SessionStart: trace context, session identity, state reset, and the startup banner. */\n\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { clearSession as clearAgentContext } from '../lib/agent/agent-context.js';\nimport { THRESHOLDS, GIT_TIMEOUT_MS } from '../lib/core/constants.js';\nimport { loadJson } from '../lib/core/file-utils.js';\nimport { writeStderr } from '../lib/core/format-utils.js';\nimport { TRANSCRIPT_PROJECT_SLUG_PATTERN } from '../lib/core/regex.js';\nimport { formatPercent, PERCENT_PER_UNIT, UNITS } from '../lib/core/units.js';\nimport { probeGitStatus, readHeadBranch, splitOwnerRepo, type GitStatus } from '../lib/git/git-cache.js';\nimport { resetFailureTracking } from '../lib/mcp/mcp-failure-latch.js';\nimport {\n SESSION_ATTRIBUTES,\n GIT_ATTRIBUTES,\n PROCESS_ATTRIBUTES,\n VCS_ATTRIBUTES,\n CONTEXT_ATTRIBUTES,\n HOOK_TYPE_ATTR,\n HOOK_NAMES,\n} from '../lib/otel/attributes.js';\nimport { instrumentHook, persistSpanContext, type HookContext } from '../lib/otel/otel-monitor.js';\nimport { saveSessionContext, recordSessionPredecessor } from '../lib/otel/trace-context.js';\nimport { shouldSampleSession } from '../lib/quality/quality-sampler.js';\nimport { SESSION_START_SOURCE, type SessionStartHookInput, type SessionStartSource } from '../lib/runtime/hook-input.js';\nimport { writePlainContext } from '../lib/runtime/hook-output.js';\nimport { findPendingHandoffs, formatHandoffBanner } from '../lib/session/handoffs.js';\nimport {\n CONVERSATION_ID_ENV, conversationIdOf, saveCurrentSessionId, saveSessionStartBranch,\n} from '../lib/session/session-state.js';\nimport { activeTaskCompletion } from '../lib/session/task-tracker.js';\nimport { formatShipperWarning, isShipperHealthy, readShipperStatus } from '../lib/shipper/shipper-status.js';\nimport type { SessionContextData } from '../lib/transcript/context-history.js';\nimport { trackSessionContext, trackSessionContextFast } from '../lib/transcript/context-tracker.js';\n\n/** A fresh session shows its context block only once the estimate passes this */\nconst CONTEXT_BANNER_MIN_TOKENS = 10_000;\n\nconst TOKENS_PER_MILLION = 1_000_000;\nconst TOKENS_PER_THOUSAND = 1_000;\n\nconst FULL_UTILIZATION_PERCENT = PERCENT_PER_UNIT;\n\nconst UTILIZATION_HIGH_PERCENT = 70;\nconst UTILIZATION_WARN_PERCENT = 50;\n\nconst DEFAULT_ACTIVE_TASKS_SUBDIR = path.join('dev', 'active');\n\nconst UNKNOWN_PROJECT_NAME = 'unknown';\n/** Starts that continue an existing transcript: `--resume`, with or without `--fork-session`. */\nconst CONTINUING_SOURCES: ReadonlySet<SessionStartSource> = new Set([SESSION_START_SOURCE.RESUME, SESSION_START_SOURCE.FORK]);\n\n/** The first firing of a conversation; an absent source is an older Claude Code's startup. */\nconst isFreshStart = (source: SessionStartSource | undefined): boolean =>\n source === undefined || source === SESSION_START_SOURCE.STARTUP;\n\nconst continuesTranscript = (source: SessionStartSource | undefined): boolean =>\n source !== undefined && CONTINUING_SOURCES.has(source);\n\n/**\n * Banner lines from one startup check, or null when it did not apply; non-null is what\n * `checks_performed` counts. A check with nothing for Claude to act on returns no lines:\n * the banner reaches the model again on every clear and compaction.\n */\ntype BannerSection = string[] | null;\n\nexport async function handleSessionStart(input: SessionStartHookInput): Promise<void> {\n await instrumentHook(HOOK_NAMES.SESSION_START, async (ctx) => {\n const cwd = process.cwd();\n const sessionId = input.session_id;\n // Awaited below, so the git subprocesses overlap the sync work in between.\n const gitStatus = probeGitStatus(cwd, GIT_TIMEOUT_MS.HOOK_PATH).catch(() => null);\n\n // So later hooks in this session create child spans under the same traceId.\n persistSpanContext(ctx, sessionId, saveSessionContext);\n recordSessionIdentity(ctx, input);\n ctx.logger.info('Session starting', {\n [PROCESS_ATTRIBUTES.WORKING_DIRECTORY]: cwd, [SESSION_ATTRIBUTES.SESSION_ID]: sessionId,\n });\n prepareSessionState(ctx, sessionId);\n\n const isResume = continuesTranscript(input.source);\n const sections: BannerSection[] = [\n reportContext(ctx, input, cwd, isResume),\n isResume ? reportRestoredTasks(ctx, sessionId) : null,\n ];\n const git = await gitStatus;\n sections.push(\n reportEnvironment(ctx, cwd),\n reportProject(ctx, cwd),\n reportActiveTasks(ctx),\n git ? reportGit(ctx, git) : null,\n );\n const notices = [...shipperNotice(ctx), ...handoffNotice(ctx, cwd)];\n\n const checksPerformed = sections.filter((section) => section !== null).length;\n ctx.addAttribute('integritystudio.session.checks_performed', checksPerformed);\n ctx.recordMetric('integritystudio.session.checks', checksPerformed, undefined, {\n description: 'Startup checks performed per session',\n unit: UNITS.CHECK,\n });\n\n const banner = [...sections.flatMap((section) => section ?? []), ...notices];\n if (banner.length === 0) return;\n const bannerText = banner.join('\\n');\n writePlainContext(bannerText);\n ctx.logger.info(bannerText);\n }, { [HOOK_TYPE_ATTR]: 'session' });\n}\n\n/**\n * Grouping attributes, predecessor edge and `session.start` event (OBP3, OBP12).\n * The project slug must not occupy gen_ai.conversation.id: a project holds many\n * conversations, and that key carries a genuine thread id only.\n */\nfunction recordSessionIdentity(ctx: HookContext, input: SessionStartHookInput): void {\n const projectSlug = deriveProjectSlug(input.transcript_path);\n if (projectSlug) ctx.addAttribute(SESSION_ATTRIBUTES.PROJECT_SLUG, projectSlug);\n\n const conversationId = conversationIdOf(input.session_id);\n if (conversationId) ctx.addAttribute(SESSION_ATTRIBUTES.CONVERSATION_ID, conversationId);\n\n const sessionId = input.session_id;\n const previousId = recordPredecessor(input.source, sessionId, process.env[CONVERSATION_ID_ENV] || projectSlug);\n if (previousId) ctx.addAttribute(SESSION_ATTRIBUTES.PREVIOUS_ID, previousId);\n ctx.recordEvent('session.start', {\n [SESSION_ATTRIBUTES.SESSION_ID]: sessionId,\n ...(previousId ? { [SESSION_ATTRIBUTES.PREVIOUS_ID]: previousId } : {}),\n });\n}\n\n/**\n * Only the 'startup' firing (or an absent source) touches the store: 'resume', 'fork',\n * 'clear' and 'compact' re-fire this hook and would record a backwards edge (OTEL5-8).\n */\nfunction recordPredecessor(\n source: SessionStartSource | undefined,\n sessionId: string,\n groupingKey: string | null | undefined,\n): string | null {\n if (!isFreshStart(source) || !groupingKey) return null;\n return distinctPredecessor(recordSessionPredecessor(groupingKey, sessionId), sessionId);\n}\n\nfunction prepareSessionState(ctx: HookContext, sessionId: string): void {\n // Both stores outlive the process, so a session reusing this id would inherit them.\n resetFailureTracking(sessionId);\n clearAgentContext(sessionId);\n\n // GCS1/GCS2: session id and start branch for the git pre-commit scope guard, which\n // runs in every repo; an unset CLAUDE_PROJECT_DIR leaves it warn-only. The branch\n // is read uncached: the git probe's cache is stale precisely in the shared checkout.\n const projectDir = process.env.CLAUDE_PROJECT_DIR;\n if (projectDir) {\n saveCurrentSessionId(sessionId, projectDir);\n const startBranch = readHeadBranch(projectDir);\n if (startBranch) saveSessionStartBranch(sessionId, startBranch);\n }\n\n ctx.addAttribute('integritystudio.quality.eval_sampled', shouldSampleSession(sessionId));\n}\n\n/** The fast path renders the banner with no I/O; the deferred full scan is the sole recorder of metrics (HRV2). Resume scans immediately. */\nfunction reportContext(ctx: HookContext, input: SessionStartHookInput, cwd: string, isResume: boolean): BannerSection {\n const trackParams = {\n sessionId: input.session_id,\n transcriptPath: input.transcript_path,\n isResume,\n attributes: { [PROCESS_ATTRIBUTES.WORKING_DIRECTORY]: cwd },\n };\n const contextData = isResume ? trackSessionContext(trackParams) : trackSessionContextFast(trackParams);\n\n // `clear` and `compact` re-fire mid-run with the transcript already on disk; recording\n // them would add session starts the conversation never had, so only a fresh start scans.\n if (!isResume && isFreshStart(input.source)) {\n setImmediate(() => {\n try {\n trackSessionContext(trackParams);\n } catch {\n // The banner already rendered from the fast path.\n }\n });\n }\n\n ctx.addAttributes(contextSpanAttributes(contextData));\n const headline = {\n [CONTEXT_ATTRIBUTES.UTILIZATION_PERCENT]: contextData.utilizationPercent,\n [CONTEXT_ATTRIBUTES.ESTIMATED_TOKENS]: contextData.estimatedTokens,\n };\n if (contextData.utilizationPercent > FULL_UTILIZATION_PERCENT) {\n ctx.recordEvent('integritystudio.context.overflow', headline);\n writeStderr(`[OVERFLOW] Context utilization exceeded ${FULL_UTILIZATION_PERCENT}%: ${contextData.utilizationPercent.toFixed(1)}%`);\n }\n ctx.logger.debug('Context tracked', { ...headline, [CONTEXT_ATTRIBUTES.FREE_SPACE]: contextData.freeSpace });\n\n if (!contextData.isResume && contextData.estimatedTokens <= CONTEXT_BANNER_MIN_TOKENS) return null;\n const { estimatedTokens, utilizationPercent, freeSpace } = contextData;\n return [\n `Context: ${formatTokens(estimatedTokens)} tokens (${utilizationPercent.toFixed(1)}%, ${utilizationLabel(utilizationPercent)}), ${formatTokens(freeSpace)} free`,\n ];\n}\n\nfunction contextSpanAttributes(contextData: SessionContextData): Record<string, number | boolean> {\n return {\n [CONTEXT_ATTRIBUTES.ESTIMATED_TOKENS]: contextData.estimatedTokens,\n [CONTEXT_ATTRIBUTES.UTILIZATION_PERCENT]: contextData.utilizationPercent,\n [CONTEXT_ATTRIBUTES.FREE_SPACE]: contextData.freeSpace,\n [CONTEXT_ATTRIBUTES.TRANSCRIPT_SIZE]: contextData.transcriptSize,\n [CONTEXT_ATTRIBUTES.MESSAGE_COUNT]: contextData.messageCount,\n [CONTEXT_ATTRIBUTES.IS_RESUME]: contextData.isResume,\n };\n}\n\nfunction reportRestoredTasks(ctx: HookContext, sessionId: string): BannerSection {\n const tasks = activeTaskCompletion(sessionId);\n if (!tasks) return null;\n const { active, ratio } = tasks;\n ctx.addAttributes({\n 'integritystudio.task.restored_count': active.length,\n 'integritystudio.task.completion_ratio': ratio,\n });\n ctx.recordMetric('integritystudio.session.task_completion', ratio, undefined, { unit: UNITS.RATIO });\n const lines = [`Tasks: ${active.length} restored (${formatPercent(ratio)} complete)`];\n if (ratio < THRESHOLDS.TASK_COMPLETION_RATIO) {\n lines.push(` [!] Low completion ratio: ${ratio.toFixed(2)}`);\n }\n return lines;\n}\n\nfunction reportEnvironment(ctx: HookContext, cwd: string): BannerSection {\n ctx.addAttribute(PROCESS_ATTRIBUTES.RUNTIME_VERSION, process.version);\n ctx.logger.debug('Environment check passed', { [PROCESS_ATTRIBUTES.RUNTIME_VERSION]: process.version });\n ctx.addAttribute(PROCESS_ATTRIBUTES.WORKING_DIRECTORY, cwd);\n return [];\n}\n\nfunction reportProject(ctx: HookContext, cwd: string): BannerSection {\n const pkg = loadJson<{ name?: string }>(path.join(cwd, 'package.json'));\n if (!pkg) return null;\n const projectName = pkg.name || UNKNOWN_PROJECT_NAME;\n ctx.addAttribute(SESSION_ATTRIBUTES.PROJECT_NAME, projectName);\n return [];\n}\n\nfunction reportActiveTasks(ctx: HookContext): BannerSection {\n const activeDir = process.env.ACTIVE_TASKS_DIR || path.join(os.homedir(), DEFAULT_ACTIVE_TASKS_SUBDIR);\n if (!fs.existsSync(activeDir)) return null;\n const taskNames = fs.readdirSync(activeDir);\n ctx.addAttribute('integritystudio.tasks.active', taskNames.length);\n ctx.recordMetric('integritystudio.session.active_tasks', taskNames.length, undefined, { unit: UNITS.TASK });\n return taskNames.length > 0 ? [`Active tasks (${taskNames.length}): ${taskNames.join(', ')}`] : [];\n}\n\nfunction reportGit(ctx: HookContext, { branch, uncommitted, repository }: GitStatus): BannerSection {\n ctx.addAttribute(VCS_ATTRIBUTES.REF_HEAD_NAME, branch);\n ctx.addAttribute(GIT_ATTRIBUTES.UNCOMMITTED, uncommitted);\n if (repository) {\n const { owner, name } = splitOwnerRepo(repository);\n ctx.addAttribute(VCS_ATTRIBUTES.REPOSITORY_NAME, name);\n if (owner) ctx.addAttribute(VCS_ATTRIBUTES.OWNER_NAME, owner);\n }\n return [uncommitted > 0 ? `Git: ${branch} (${uncommitted} uncommitted changes)` : `Git: ${branch} (clean)`];\n}\n\n/** The only place the shipper's diagnostics reach a person; printed only when unhealthy so it is not tuned out (CCH6a). */\nfunction shipperNotice(ctx: HookContext): string[] {\n const shipperStatus = readShipperStatus();\n if (!shipperStatus || isShipperHealthy(shipperStatus.outcome)) return [];\n ctx.addAttribute('integritystudio.telemetry.shipper.outcome', shipperStatus.outcome);\n return [formatShipperWarning(shipperStatus)];\n}\n\n/** The previous session's note to this one; silent when docs/handoffs/ is absent. */\nfunction handoffNotice(ctx: HookContext, cwd: string): string[] {\n const handoffs = findPendingHandoffs(cwd);\n if (handoffs.length === 0) return [];\n ctx.addAttribute('integritystudio.session.handoffs_pending', handoffs.length);\n return formatHandoffBanner(handoffs);\n}\n\n/** The directory name above the session JSONL (lib/transcript/transcript-layout.ts). Exported for tests. */\nexport function deriveProjectSlug(transcriptPath: string | undefined): string | null {\n if (!transcriptPath) return null;\n return transcriptPath.match(TRANSCRIPT_PROJECT_SLUG_PATTERN)?.[1] ?? null;\n}\n\n/** The prior session's id when it exists and differs (session.previous_id spec MUST). */\nexport function distinctPredecessor(priorSessionId: string | null, currentSessionId: string): string | null {\n return priorSessionId && priorSessionId !== currentSessionId ? priorSessionId : null;\n}\n\nfunction formatTokens(tokens: number): string {\n if (tokens >= TOKENS_PER_MILLION) {\n return `${(tokens / TOKENS_PER_MILLION).toFixed(1)}M`;\n }\n if (tokens >= TOKENS_PER_THOUSAND) {\n return `${(tokens / TOKENS_PER_THOUSAND).toFixed(0)}K`;\n }\n return String(tokens);\n}\n\n/** Exported for tests. */\nexport function utilizationLabel(percent: number): string {\n const safePct = Number.isFinite(percent) ? percent : 0;\n if (safePct > FULL_UTILIZATION_PERCENT) return 'OVERFLOW';\n if (safePct >= UTILIZATION_HIGH_PERCENT) return 'HIGH';\n if (safePct >= UTILIZATION_WARN_PERCENT) return 'WARN';\n return 'OK';\n}\n", "/**\n * Hook payload types. `HookInput` is the runner's superset; handlers take a\n * per-event `Pick` so they cannot drift from it (HRV13). Every field is optional:\n * handlers degrade, never throw. Shapes verified against Claude Code 2.1.220 (CCH4).\n */\n\n/**\n * SessionStart's lifecycle discriminator; the only resume signal, there is no boolean.\n * `fork` is `--resume --fork-session`: the transcript continues under a new session id.\n */\nexport const SESSION_START_SOURCE = {\n STARTUP: 'startup',\n RESUME: 'resume',\n CLEAR: 'clear',\n COMPACT: 'compact',\n FORK: 'fork',\n} as const;\n\nexport type SessionStartSource = (typeof SESSION_START_SOURCE)[keyof typeof SESSION_START_SOURCE];\n\nexport interface HookInput {\n // ---- Present on every event ----\n session_id?: string;\n transcript_path?: string;\n cwd?: string;\n hook_event_name?: string;\n\n // ---- Not on SessionStart, SessionEnd, SubagentStart, Notification, PreCompact or PostCompact ----\n permission_mode?: string;\n\n // ---- SessionStart ----\n source?: SessionStartSource;\n\n // ---- UserPromptSubmit ----\n prompt?: string;\n\n // ---- PreToolUse / PostToolUse / PostToolUseFailure ----\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n /** Legacy string form of the result; `tool_response` is preferred when present. */\n tool_output?: string;\n /** Object or string result of the tool (PostToolUse). */\n tool_response?: unknown;\n tool_use_id?: string;\n is_error?: boolean;\n /** Present only when the hook fires inside a subagent (Claude Code > 2.1.220). */\n agent_id?: string;\n agent_type?: string;\n\n // ---- PostToolUseFailure ----\n error?: string;\n is_interrupt?: boolean;\n duration_ms?: number;\n\n // ---- SubagentStop (SubagentStart carries agent_id / agent_type above) ----\n agent_transcript_path?: string;\n stop_hook_active?: boolean;\n last_assistant_message?: string;\n\n // ---- PreCompact / PostCompact ----\n trigger?: string;\n custom_instructions?: string | null;\n compact_summary?: string;\n\n // ---- Notification ----\n message?: string;\n level?: string;\n\n // ---- SessionEnd ----\n reason?: string;\n}\n\n/**\n * Fields Claude Code sends on every event or every tool event (CCH4). The runner refuses a payload\n * missing one before dispatch (`normalizeHookInput`), so a handler reads it with no guard.\n */\ntype Always<K extends keyof HookInput> = Required<Pick<HookInput, K>>;\n\n/** The `SessionStart` payload as read by `handlers/session-start.ts`. */\nexport type SessionStartHookInput = Always<'session_id' | 'transcript_path'> & Pick<HookInput, 'source'>;\n\n/** The `UserPromptSubmit` payload as read by `handlers/user-prompt.ts`. */\nexport type UserPromptHookInput = Always<'session_id' | 'transcript_path' | 'cwd'> & Pick<HookInput,\n 'permission_mode' | 'prompt'>;\n\n/** The `PreToolUse` payload as read by `handlers/pre-tool.ts`. */\nexport type PreToolHookInput = Always<'session_id' | 'tool_name' | 'transcript_path' | 'cwd'> & Pick<HookInput,\n 'tool_input' | 'tool_use_id' | 'agent_id' | 'agent_type'>;\n\n/** The `PostToolUse` payload as read by `handlers/post-tool*.ts`. */\nexport type PostToolHookInput = Always<'session_id' | 'tool_name' | 'transcript_path' | 'cwd'> & Pick<HookInput,\n 'tool_input' | 'tool_use_id' | 'tool_output' | 'tool_response'\n | 'is_error' | 'agent_id' | 'agent_type'>;\n\n/** The `PostToolUseFailure` payload as read by `handlers/post-tool-failure.ts`. */\nexport type PostToolFailureHookInput = Always<'session_id' | 'tool_name' | 'hook_event_name'> & Pick<HookInput,\n 'tool_input' | 'tool_use_id' | 'error'\n | 'is_interrupt' | 'duration_ms'>;\n\n/** The `Stop` payload as read by `handlers/stop*.ts`. */\nexport type StopHookInput = Always<'session_id' | 'transcript_path' | 'cwd' | 'hook_event_name'> & Pick<HookInput,\n 'permission_mode' | 'stop_hook_active'>;\n\n/** The `Notification` payload as read by `handlers/notification.ts`. */\nexport type NotificationHookInput = Always<'session_id' | 'hook_event_name'> & Pick<HookInput,\n 'tool_name' | 'tool_output' | 'message' | 'level'>;\n\n/** The `SubagentStart` payload as read by `handlers/subagent.ts`. */\nexport type SubagentStartHookInput = Always<'session_id' | 'transcript_path' | 'hook_event_name'> & Pick<HookInput,\n 'agent_id' | 'agent_type'>;\n\n/** The `SubagentStop` payload as read by `handlers/subagent.ts`. */\nexport type SubagentStopHookInput = SubagentStartHookInput & Pick<HookInput,\n 'agent_transcript_path' | 'stop_hook_active' | 'last_assistant_message'>;\n\n/** The `PreCompact` payload as read by `handlers/compact.ts`. */\nexport type PreCompactHookInput = Always<'session_id' | 'hook_event_name'> & Pick<HookInput,\n 'trigger' | 'custom_instructions'>;\n\n/** The `PostCompact` payload as read by `handlers/compact.ts`. */\nexport type PostCompactHookInput = Always<'session_id' | 'hook_event_name'> & Pick<HookInput,\n 'trigger' | 'compact_summary'>;\n\n/** The `SessionEnd` payload as read by `handlers/session-end.ts`. */\nexport type SessionEndHookInput = Always<'session_id' | 'hook_event_name'> & Pick<HookInput, 'reason'>;\n\n/** `HookInput` after the runner has checked the fields Claude Code sends on every event. */\nexport type NormalizedHookInput = HookInput & Always<\n 'session_id' | 'transcript_path' | 'cwd' | 'hook_event_name'>;\n\n/** A tool event's payload after the runner has checked `tool_name` as well. */\nexport type NormalizedToolHookInput = NormalizedHookInput & Always<'tool_name'>;\n", "/**\n * Pending session-to-session handoffs (`docs/handoffs/*.md`), surfaced at SessionStart.\n * Deliberately a plain directory listing: drop a `.md`, delete it when done.\n * `ageDays` is reported because a stale banner line is the one that gets tuned out (CCH6a).\n */\n\nimport { statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { readdirOrEmpty } from '../core/file-utils.js';\nimport { TIME_MS } from '../core/units.js';\n\n/** Directory, relative to the repo root, that holds handoff documents. */\nexport const HANDOFF_DIR = join('docs', 'handoffs');\n\n/** Parent levels searched above the CWD for the handoff directory. */\nconst MAX_PARENT_LEVELS = 3;\n\n/** Cap on handoffs listed, so a forgotten directory cannot flood the banner. */\nconst MAX_HANDOFFS = 5;\n\n/** Age at which a handoff is called out as possibly abandoned. */\nexport const STALE_HANDOFF_DAYS = 14;\n\ninterface PendingHandoff {\n /** Path as a human should type it, relative to the directory that contains `docs/`. */\n path: string;\n /** Whole days since last modification. */\n ageDays: number;\n}\n\n/** Locate `docs/handoffs` at `startDir` or up to `MAX_PARENT_LEVELS` above it (bounded for SessionStart latency). */\nfunction findHandoffDir(startDir: string): { dir: string; prefix: string } | null {\n let cur = startDir;\n for (let level = 0; level <= MAX_PARENT_LEVELS; level++) {\n const dir = join(cur, HANDOFF_DIR);\n try {\n if (statSync(dir).isDirectory()) {\n // '../' per level climbed, so the printed path pastes from the CWD.\n return { dir, prefix: '../'.repeat(level) };\n }\n } catch {\n // best-effort\n }\n const parent = join(cur, '..');\n if (parent === cur) break;\n cur = parent;\n }\n return null;\n}\n\n/** Pending handoffs, newest first; empty and never throws when the directory is absent or unreadable. */\nexport function findPendingHandoffs(startDir: string, now = Date.now()): PendingHandoff[] {\n const found = findHandoffDir(startDir);\n if (!found) return [];\n\n const handoffs: Array<PendingHandoff & { mtimeMs: number }> = [];\n for (const name of readdirOrEmpty(found.dir)) {\n if (!name.endsWith('.md')) continue;\n try {\n const { mtimeMs } = statSync(join(found.dir, name));\n handoffs.push({\n path: `${found.prefix}${HANDOFF_DIR}/${name}`,\n ageDays: Math.floor((now - mtimeMs) / TIME_MS.DAY),\n mtimeMs,\n });\n } catch {\n // best-effort\n }\n }\n\n return handoffs\n .sort((a, b) => b.mtimeMs - a.mtimeMs)\n .slice(0, MAX_HANDOFFS)\n .map(({ path, ageDays }) => ({ path, ageDays }));\n}\n\n/** Banner lines addressed to Claude (SessionStart stdout is injected). \"Read and propose\", not \"do\": the user may have moved on. */\nexport function formatHandoffBanner(handoffs: PendingHandoff[]): string[] {\n if (handoffs.length === 0) return [];\n\n const lines = ['', `Pending handoff${handoffs.length === 1 ? '' : 's'} from a previous session:`];\n for (const { path, ageDays } of handoffs) {\n const age = ageDays === 0 ? 'today' : `${ageDays}d old`;\n const stale = ageDays >= STALE_HANDOFF_DAYS ? ' \u2014 stale, confirm it is still wanted' : '';\n lines.push(` ${path} (${age})${stale}`);\n }\n lines.push('Read these before other work, then propose next steps and confirm with the user.');\n return lines;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,YAAY,UAAU;;;ACMf,IAAM,uBAAuB;AAAA,EAClC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AACR;;;ACVA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAKd,IAAM,cAAc,KAAK,QAAQ,UAAU;AAGlD,IAAM,oBAAoB;AAG1B,IAAM,eAAe;AAGd,IAAM,qBAAqB;AAUlC,SAAS,eAAe,UAA0D;AAChF,MAAI,MAAM;AACV,WAAS,QAAQ,GAAG,SAAS,mBAAmB,SAAS;AACvD,UAAM,MAAM,KAAK,KAAK,WAAW;AACjC,QAAI;AACF,UAAI,SAAS,GAAG,EAAE,YAAY,GAAG;AAE/B,eAAO,EAAE,KAAK,QAAQ,MAAM,OAAO,KAAK,EAAE;AAAA,MAC5C;AAAA,IACF,QAAQ;AAAA,IAER;AACA,UAAM,SAAS,KAAK,KAAK,IAAI;AAC7B,QAAI,WAAW,IAAK;AACpB,UAAM;AAAA,EACR;AACA,SAAO;AACT;AAGO,SAAS,oBAAoB,UAAkB,MAAM,KAAK,IAAI,GAAqB;AACxF,QAAM,QAAQ,eAAe,QAAQ;AACrC,MAAI,CAAC,MAAO,QAAO,CAAC;AAEpB,QAAM,WAAwD,CAAC;AAC/D,aAAW,QAAQ,eAAe,MAAM,GAAG,GAAG;AAC5C,QAAI,CAAC,KAAK,SAAS,KAAK,EAAG;AAC3B,QAAI;AACF,YAAM,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S,qBAAqB,QAAQ,CAAC,CAAC;AAAA,EACrD;AACA,SAAO,OAAO,MAAM;AACtB;AAGO,SAAS,iBAAiB,SAAyB;AACxD,QAAM,UAAU,OAAO,SAAS,OAAO,IAAI,UAAU;AACrD,MAAI,UAAU,yBAA0B,QAAO;AAC/C,MAAI,WAAW,yBAA0B,QAAO;AAChD,MAAI,WAAW,yBAA0B,QAAO;AAChD,SAAO;AACT;",
6
+ "names": ["path"]
7
+ }
@@ -0,0 +1,37 @@
1
+ import { createRequire as __hookRunnerCreateRequire } from 'node:module';
2
+ const require = __hookRunnerCreateRequire(import.meta.url);
3
+ import {
4
+ SHIPPER_CTX_DIRNAME,
5
+ addCount,
6
+ formatShipperWarning,
7
+ hasCounts,
8
+ isShipperHealthy,
9
+ readShipperStatus,
10
+ recordShipperBusy,
11
+ recordShipperStatus,
12
+ shipPreflight,
13
+ shipperErrorDetail,
14
+ shipperErrorKind,
15
+ shipperStatusPath,
16
+ sumCounts
17
+ } from "./chunk-YGFN3LN2.js";
18
+ import "./chunk-IJ4SLUBV.js";
19
+ import "./chunk-52RY6LQT.js";
20
+ import "./chunk-RWRGC7ZK.js";
21
+ import "./chunk-GNNKUMRF.js";
22
+ export {
23
+ SHIPPER_CTX_DIRNAME,
24
+ addCount,
25
+ formatShipperWarning,
26
+ hasCounts,
27
+ isShipperHealthy,
28
+ readShipperStatus,
29
+ recordShipperBusy,
30
+ recordShipperStatus,
31
+ shipPreflight,
32
+ shipperErrorDetail,
33
+ shipperErrorKind,
34
+ shipperStatusPath,
35
+ sumCounts
36
+ };
37
+ //# sourceMappingURL=shipper-status-MADX6SPG.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }