@unbrained/pm-cli 2026.11.16 → 2026.11.17

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 (399) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/main.js +2 -2
  3. package/dist/cli/register-mutation.js +3 -2
  4. package/dist/cli/runtime/invocation-rewrites.js +2 -0
  5. package/dist/cli-bundle/bundle-manifest.json +1 -1
  6. package/dist/cli-bundle/chunks/{chunk-ERD2RYWM.js → chunk-2WHXFKMY.js} +31 -31
  7. package/dist/cli-bundle/chunks/{chunk-VJLZHOTP.js → chunk-36R3JTAD.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-FZ4XWWLO.js → chunk-3IU2S5UQ.js} +43 -43
  9. package/dist/cli-bundle/chunks/chunk-4FIN2XWC.js +2 -0
  10. package/dist/cli-bundle/chunks/{chunk-NHNM3GIP.js → chunk-5OFMWP3Q.js} +3 -3
  11. package/dist/cli-bundle/chunks/{chunk-2WNORBVN.js → chunk-77MGDTK4.js} +83 -83
  12. package/dist/cli-bundle/chunks/{chunk-F7P42FL5.js → chunk-7K2RUKMK.js} +4 -4
  13. package/dist/cli-bundle/chunks/chunk-7UUPLMCU.js +115 -0
  14. package/dist/cli-bundle/chunks/chunk-ABFHWRLE.js +2 -0
  15. package/dist/cli-bundle/chunks/{chunk-KGOGLKL2.js → chunk-ACLBUVQG.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-DZWRNL6R.js → chunk-ADKDFCVT.js} +2 -2
  17. package/dist/cli-bundle/chunks/chunk-AM26RAG7.js +124 -0
  18. package/dist/cli-bundle/chunks/chunk-CR5GC3VO.js +9 -0
  19. package/dist/cli-bundle/chunks/chunk-DXSZL3T6.js +3 -0
  20. package/dist/cli-bundle/chunks/chunk-FXSLODOK.js +2 -0
  21. package/dist/cli-bundle/chunks/chunk-H64BNM4A.js +8 -0
  22. package/dist/cli-bundle/chunks/{chunk-2D26HRXB.js → chunk-HQYIKAC6.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-I3T2FVUA.js → chunk-KIQNEOKJ.js} +2 -2
  24. package/dist/cli-bundle/chunks/chunk-O4ZSIMNC.js +8 -0
  25. package/dist/cli-bundle/chunks/chunk-QANUQMDL.js +6 -0
  26. package/dist/cli-bundle/chunks/{chunk-4I7YG3VZ.js → chunk-QZNL5XDT.js} +2 -2
  27. package/dist/cli-bundle/chunks/chunk-RXNBNF6O.js +2 -0
  28. package/dist/cli-bundle/chunks/chunk-VLKCFZY6.js +2 -0
  29. package/dist/cli-bundle/chunks/{chunk-J257NZRD.js → chunk-X5TFNFTS.js} +11 -11
  30. package/dist/cli-bundle/chunks/chunk-XP35IEHT.js +2 -0
  31. package/dist/cli-bundle/chunks/chunk-XPBADEUK.js +2 -0
  32. package/dist/cli-bundle/chunks/{chunk-NYN5OR2T.js → chunk-Y4LXVPA5.js} +2 -2
  33. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-HNLN6UXH.js → indexed-receipt-blobs-ELEMA7IW.js} +2 -2
  34. package/dist/cli-bundle/chunks/{item-revision-PSOL5I4H.js → item-revision-7RVMVXTE.js} +2 -2
  35. package/dist/cli-bundle/chunks/item-transaction-NVX6P3FK.js +2 -0
  36. package/dist/cli-bundle/chunks/{mutation-actor-BDBBH3ZS.js → mutation-actor-DDYJW5B4.js} +2 -2
  37. package/dist/cli-bundle/chunks/mutation-admission-3PKQOAYK.js +2 -0
  38. package/dist/cli-bundle/chunks/{register-list-query-AESCVO6H.js → register-list-query-TPZLHFHQ.js} +2 -2
  39. package/dist/cli-bundle/chunks/register-mutation-JG5AEBRJ.js +21 -0
  40. package/dist/cli-bundle/chunks/register-operations-3CNXP46P.js +2 -0
  41. package/dist/cli-bundle/chunks/register-setup-4N56VL2P.js +2 -0
  42. package/dist/cli-bundle/chunks/{settlement-hook-MVVVUIVZ.js → settlement-hook-E5LHZ4RD.js} +2 -2
  43. package/dist/cli-bundle/chunks/{stage-RMU3JAWM.js → stage-XGWW3T64.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-2MQNIDKG.js +2 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-DFBHW7HP.js → chunk-5JVB42Z7.js} +3 -3
  46. package/dist/cli-bundle/focused-chunks/{chunk-SFATIM77.js → chunk-6JQXDGHM.js} +9 -9
  47. package/dist/cli-bundle/focused-chunks/{chunk-HHMMIHZP.js → chunk-7RF2YPZ5.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-7Z2NYAK4.js +2 -0
  49. package/dist/cli-bundle/focused-chunks/chunk-A2CLYPDA.js +102 -0
  50. package/dist/cli-bundle/focused-chunks/chunk-BNLLST32.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/{chunk-7SEPCQV2.js → chunk-DH4DHL6V.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/chunk-EZXLY6S4.js +2 -0
  53. package/dist/cli-bundle/focused-chunks/{chunk-KRNF3WTC.js → chunk-FPPYE6CY.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-ONM2R32I.js → chunk-GD2YWUAD.js} +50 -50
  55. package/dist/cli-bundle/focused-chunks/chunk-HO2YUD4P.js +91 -0
  56. package/dist/cli-bundle/focused-chunks/{chunk-BEHIMEV2.js → chunk-ICEHI4SN.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/{chunk-PDXSMSO5.js → chunk-IXYBN6D2.js} +3 -3
  58. package/dist/cli-bundle/focused-chunks/chunk-MTBC32ZR.js +8 -0
  59. package/dist/cli-bundle/focused-chunks/chunk-OAIAZHRG.js +2 -0
  60. package/dist/cli-bundle/focused-chunks/chunk-OPY43DNJ.js +2 -0
  61. package/dist/cli-bundle/focused-chunks/{chunk-DZMP3VYQ.js → chunk-SESMRMEE.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-PEL4SQXV.js → chunk-VBA4BIHN.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-UBBTBNUY.js → chunk-XJS4COL2.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/chunk-XS2YZCT5.js +2 -0
  65. package/dist/cli-bundle/focused-chunks/chunk-YWPLBFPC.js +44 -0
  66. package/dist/cli-bundle/focused-chunks/{chunk-6E4X7MQA.js → chunk-ZDY5L2C2.js} +7 -7
  67. package/dist/cli-bundle/focused-chunks/chunk-ZFUZ4YYN.js +8 -0
  68. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-ADMQXF3N.js → indexed-receipt-blobs-ZTRFCPH7.js} +2 -2
  69. package/dist/cli-bundle/focused-chunks/item-revision-U7GDVAH7.js +2 -0
  70. package/dist/cli-bundle/focused-chunks/item-transaction-7C4BH47O.js +2 -0
  71. package/dist/cli-bundle/focused-chunks/mutation-actor-2SVBO324.js +2 -0
  72. package/dist/cli-bundle/focused-chunks/mutation-admission-SKXVITP5.js +2 -0
  73. package/dist/cli-bundle/focused-chunks/{settlement-hook-5U2M75BY.js → settlement-hook-OUBUN45C.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/stage-LVAGKCEE.js +2 -0
  75. package/dist/cli-bundle/main.js +27 -27
  76. package/dist/cli-bundle/sdk-authoring.js +1 -1
  77. package/dist/cli-bundle/sdk-contracts.js +2 -2
  78. package/dist/cli-bundle/sdk-core.js +1 -1
  79. package/dist/cli-bundle/sdk-governance.js +1 -1
  80. package/dist/cli-bundle/sdk-graph.js +1 -1
  81. package/dist/cli-bundle/sdk-merge.js +57 -57
  82. package/dist/cli-bundle/sdk-query.js +1 -1
  83. package/dist/cli-bundle/sdk-runtime.js +1 -1
  84. package/dist/cli-bundle/sdk-testing.js +1 -1
  85. package/dist/cli-bundle/sdk.js +4 -4
  86. package/dist/core/extensions/extension-hook-runtime.d.ts +14 -2
  87. package/dist/core/extensions/extension-hook-runtime.js +1 -1
  88. package/dist/core/extensions/extension-types.d.ts +14 -0
  89. package/dist/core/extensions/extension-types.js +1 -1
  90. package/dist/core/extensions/index.d.ts +1 -1
  91. package/dist/core/extensions/index.js +1 -1
  92. package/dist/core/policy/workflow-policy-store.js +1 -1
  93. package/dist/core/store/item-mutation-precondition.d.ts +32 -1
  94. package/dist/core/store/item-mutation-precondition.js +1 -1
  95. package/dist/core/store/item-store.js +1 -1
  96. package/dist/core/store/transaction-coordinator-scope.js +2 -0
  97. package/dist/sdk/authoring.d.ts +1 -1
  98. package/dist/sdk/authoring.js +1 -1
  99. package/dist/sdk/cli-bootstrap.js +1 -1
  100. package/dist/sdk/item-transaction.js +1 -1
  101. package/dist/sdk/lifecycle/copy.js +1 -1
  102. package/dist/sdk/lifecycle/create.js +1 -1
  103. package/dist/sdk/lifecycle/restore.js +1 -1
  104. package/dist/sdk/package-import-adapters.d.ts +14 -1
  105. package/dist/sdk/package-import-adapters.js +1 -1
  106. package/dist/sdk/public-surface.json +1 -1
  107. package/dist/sdk/testing.d.ts +21 -3
  108. package/dist/sdk/testing.js +2 -2
  109. package/dist/sdk/workspace-transaction.js +2 -2
  110. package/docs/EXTENSIONS.md +1 -1
  111. package/docs/MIGRATION_CLI_SIMPLIFICATION.md +1 -1
  112. package/docs/SDK.md +40 -3
  113. package/docs/WORKFLOW_POLICIES.md +23 -0
  114. package/marketplace.json +1 -1
  115. package/node_modules/@opentelemetry/core/build/esm/version.d.ts +1 -1
  116. package/node_modules/@opentelemetry/core/build/esm/version.js +1 -1
  117. package/node_modules/@opentelemetry/core/build/esnext/version.d.ts +1 -1
  118. package/node_modules/@opentelemetry/core/build/esnext/version.js +1 -1
  119. package/node_modules/@opentelemetry/core/build/src/version.d.ts +1 -1
  120. package/node_modules/@opentelemetry/core/build/src/version.js +1 -1
  121. package/node_modules/@opentelemetry/core/package.json +2 -2
  122. package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/execAsync.d.ts +1 -0
  123. package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/execAsync.js +1 -0
  124. package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId-bsd.js +3 -2
  125. package/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/machine-id/getMachineId-darwin.js +3 -2
  126. package/node_modules/@opentelemetry/resources/build/esm/version.d.ts +1 -1
  127. package/node_modules/@opentelemetry/resources/build/esm/version.js +1 -1
  128. package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/execAsync.d.ts +1 -0
  129. package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/execAsync.js +1 -0
  130. package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/getMachineId-bsd.js +3 -2
  131. package/node_modules/@opentelemetry/resources/build/esnext/detectors/platform/node/machine-id/getMachineId-darwin.js +3 -2
  132. package/node_modules/@opentelemetry/resources/build/esnext/version.d.ts +1 -1
  133. package/node_modules/@opentelemetry/resources/build/esnext/version.js +1 -1
  134. package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/execAsync.d.ts +1 -0
  135. package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/execAsync.js +2 -1
  136. package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-bsd.js +2 -1
  137. package/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-darwin.js +2 -1
  138. package/node_modules/@opentelemetry/resources/build/src/version.d.ts +1 -1
  139. package/node_modules/@opentelemetry/resources/build/src/version.js +1 -1
  140. package/node_modules/@opentelemetry/resources/package.json +3 -3
  141. package/node_modules/@opentelemetry/sdk-trace/build/esm/version.d.ts +1 -1
  142. package/node_modules/@opentelemetry/sdk-trace/build/esm/version.js +1 -1
  143. package/node_modules/@opentelemetry/sdk-trace/build/esnext/version.d.ts +1 -1
  144. package/node_modules/@opentelemetry/sdk-trace/build/esnext/version.js +1 -1
  145. package/node_modules/@opentelemetry/sdk-trace/build/src/version.d.ts +1 -1
  146. package/node_modules/@opentelemetry/sdk-trace/build/src/version.js +1 -1
  147. package/node_modules/@opentelemetry/sdk-trace/package.json +5 -5
  148. package/node_modules/@opentelemetry/sdk-trace-base/build/esm/version.d.ts +1 -1
  149. package/node_modules/@opentelemetry/sdk-trace-base/build/esm/version.js +1 -1
  150. package/node_modules/@opentelemetry/sdk-trace-base/build/esnext/version.d.ts +1 -1
  151. package/node_modules/@opentelemetry/sdk-trace-base/build/esnext/version.js +1 -1
  152. package/node_modules/@opentelemetry/sdk-trace-base/build/src/version.d.ts +1 -1
  153. package/node_modules/@opentelemetry/sdk-trace-base/build/src/version.js +1 -1
  154. package/node_modules/@opentelemetry/sdk-trace-base/package.json +7 -7
  155. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_attributes.cjs +18202 -0
  156. package/node_modules/@opentelemetry/semantic-conventions/{build/src/experimental_attributes.js → dist/experimental_attributes.d.cts} +3328 -1993
  157. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/experimental_attributes.js → dist/experimental_attributes.d.mts} +3328 -1935
  158. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_attributes.mjs +16385 -0
  159. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_events.cjs +325 -0
  160. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/experimental_events.js → dist/experimental_events.d.cts} +37 -41
  161. package/node_modules/@opentelemetry/semantic-conventions/{build/esm/experimental_events.js → dist/experimental_events.d.mts} +37 -41
  162. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_events.mjs +295 -0
  163. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_metrics.cjs +4929 -0
  164. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/experimental_metrics.js → dist/experimental_metrics.d.cts} +955 -597
  165. package/node_modules/@opentelemetry/semantic-conventions/{build/esm/experimental_metrics.js → dist/experimental_metrics.d.mts} +955 -597
  166. package/node_modules/@opentelemetry/semantic-conventions/dist/experimental_metrics.mjs +4419 -0
  167. package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.cjs +2619 -0
  168. package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.d.cts +7 -0
  169. package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.d.mts +7 -0
  170. package/node_modules/@opentelemetry/semantic-conventions/dist/index-incubating.mjs +7 -0
  171. package/node_modules/@opentelemetry/semantic-conventions/dist/index.cjs +670 -0
  172. package/node_modules/@opentelemetry/semantic-conventions/dist/index.d.cts +6 -0
  173. package/node_modules/@opentelemetry/semantic-conventions/dist/index.d.mts +6 -0
  174. package/node_modules/@opentelemetry/semantic-conventions/dist/index.mjs +6 -0
  175. package/node_modules/@opentelemetry/semantic-conventions/dist/internal/utils.cjs +20 -0
  176. package/node_modules/@opentelemetry/semantic-conventions/dist/internal/utils.mjs +20 -0
  177. package/node_modules/@opentelemetry/semantic-conventions/dist/resource/SemanticResourceAttributes.cjs +1326 -0
  178. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/resource/SemanticResourceAttributes.d.ts → dist/resource/SemanticResourceAttributes.d.cts} +600 -597
  179. package/node_modules/@opentelemetry/semantic-conventions/{build/src/resource/SemanticResourceAttributes.d.ts → dist/resource/SemanticResourceAttributes.d.mts} +600 -597
  180. package/node_modules/@opentelemetry/semantic-conventions/dist/resource/SemanticResourceAttributes.mjs +1188 -0
  181. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_attributes.cjs +2038 -0
  182. package/node_modules/@opentelemetry/semantic-conventions/{build/esm/stable_attributes.js → dist/stable_attributes.d.cts} +327 -220
  183. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/stable_attributes.js → dist/stable_attributes.d.mts} +327 -220
  184. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_attributes.mjs +1841 -0
  185. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.cjs +9 -0
  186. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.d.cts +8 -0
  187. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.d.mts +8 -0
  188. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_events.mjs +9 -0
  189. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_metrics.cjs +378 -0
  190. package/node_modules/@opentelemetry/semantic-conventions/{build/src/stable_metrics.js → dist/stable_metrics.d.cts} +69 -63
  191. package/node_modules/@opentelemetry/semantic-conventions/{build/esm/stable_metrics.js → dist/stable_metrics.d.mts} +69 -59
  192. package/node_modules/@opentelemetry/semantic-conventions/dist/stable_metrics.mjs +326 -0
  193. package/node_modules/@opentelemetry/semantic-conventions/dist/trace/SemanticAttributes.cjs +2508 -0
  194. package/node_modules/@opentelemetry/semantic-conventions/{build/esnext/trace/SemanticAttributes.d.ts → dist/trace/SemanticAttributes.d.cts} +1097 -1094
  195. package/node_modules/@opentelemetry/semantic-conventions/{build/src/trace/SemanticAttributes.d.ts → dist/trace/SemanticAttributes.d.mts} +1097 -1094
  196. package/node_modules/@opentelemetry/semantic-conventions/dist/trace/SemanticAttributes.mjs +2236 -0
  197. package/node_modules/@opentelemetry/semantic-conventions/package.json +27 -42
  198. package/node_modules/@sentry/core/build/cjs/client.js +14 -5
  199. package/node_modules/@sentry/core/build/cjs/integrations/express/patch-layer.js +15 -1
  200. package/node_modules/@sentry/core/build/cjs/integrations/http/client-subscriptions.js +10 -1
  201. package/node_modules/@sentry/core/build/cjs/scope.js +0 -1
  202. package/node_modules/@sentry/core/build/cjs/tracing/openai/utils.js +1 -7
  203. package/node_modules/@sentry/core/build/cjs/tracing/sentrySpan.js +11 -0
  204. package/node_modules/@sentry/core/build/cjs/utils/envelope.js +1 -1
  205. package/node_modules/@sentry/core/build/cjs/utils/sql.js +1 -1
  206. package/node_modules/@sentry/core/build/cjs/utils/tunnel.js +9 -0
  207. package/node_modules/@sentry/core/build/cjs/utils/version.js +1 -1
  208. package/node_modules/@sentry/core/build/esm/client.js +14 -5
  209. package/node_modules/@sentry/core/build/esm/integrations/express/patch-layer.js +15 -1
  210. package/node_modules/@sentry/core/build/esm/integrations/http/client-subscriptions.js +10 -1
  211. package/node_modules/@sentry/core/build/esm/package.json +1 -1
  212. package/node_modules/@sentry/core/build/esm/scope.js +0 -1
  213. package/node_modules/@sentry/core/build/esm/tracing/openai/utils.js +1 -7
  214. package/node_modules/@sentry/core/build/esm/tracing/sentrySpan.js +11 -0
  215. package/node_modules/@sentry/core/build/esm/utils/envelope.js +1 -1
  216. package/node_modules/@sentry/core/build/esm/utils/sql.js +1 -1
  217. package/node_modules/@sentry/core/build/esm/utils/tunnel.js +9 -1
  218. package/node_modules/@sentry/core/build/esm/utils/version.js +1 -1
  219. package/node_modules/@sentry/core/build/types/types/datacategory.d.ts +1 -1
  220. package/node_modules/@sentry/core/build/types/utils/tunnel.d.ts +1 -0
  221. package/node_modules/@sentry/core/build/types-ts3.8/types/datacategory.d.ts +1 -1
  222. package/node_modules/@sentry/core/build/types-ts3.8/utils/tunnel.d.ts +1 -0
  223. package/node_modules/@sentry/core/package.json +1 -1
  224. package/node_modules/@sentry/node/build/cjs/integrations/tracing/redis/index.js +1 -1
  225. package/node_modules/@sentry/node/build/esm/package.json +1 -1
  226. package/node_modules/@sentry/node/package.json +6 -6
  227. package/node_modules/@sentry/node-core/build/cjs/integrations/anr/index.js +1 -1
  228. package/node_modules/@sentry/node-core/build/cjs/integrations/contextlines.js +6 -4
  229. package/node_modules/@sentry/node-core/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  230. package/node_modules/@sentry/node-core/build/cjs/integrations/modules.js +21 -2
  231. package/node_modules/@sentry/node-core/build/cjs/integrations/node-fetch/undici-instrumentation.js +8 -0
  232. package/node_modules/@sentry/node-core/build/esm/integrations/anr/index.js +1 -1
  233. package/node_modules/@sentry/node-core/build/esm/integrations/anr/worker-script.js +2 -2
  234. package/node_modules/@sentry/node-core/build/esm/integrations/contextlines.js +7 -5
  235. package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  236. package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/worker-script.js +1 -1
  237. package/node_modules/@sentry/node-core/build/esm/integrations/node-fetch/undici-instrumentation.js +8 -0
  238. package/node_modules/@sentry/node-core/build/esm/package.json +1 -1
  239. package/node_modules/@sentry/node-core/package.json +9 -9
  240. package/node_modules/@sentry/opentelemetry/build/esm/package.json +1 -1
  241. package/node_modules/@sentry/opentelemetry/package.json +6 -6
  242. package/node_modules/@sentry/server-utils/build/THIRD-PARTY-LICENSES.txt +32 -32
  243. package/node_modules/@sentry/server-utils/build/cjs/integrations/tracing-channel/express/instrumentation.js +12 -1
  244. package/node_modules/@sentry/server-utils/build/esm/integrations/tracing-channel/express/instrumentation.js +13 -2
  245. package/node_modules/@sentry/server-utils/build/esm/package.json +1 -1
  246. package/node_modules/@sentry/server-utils/build/types/integrations/tracing-channel/express/types.d.ts +1 -1
  247. package/node_modules/@sentry/server-utils/build/types-ts3.8/integrations/tracing-channel/express/types.d.ts +1 -1
  248. package/node_modules/@sentry/server-utils/package.json +2 -2
  249. package/node_modules/debug/package.json +1 -1
  250. package/node_modules/es-module-lexer/dist/lexer.asm.js +2 -2
  251. package/node_modules/es-module-lexer/dist/lexer.cjs +1 -1
  252. package/node_modules/es-module-lexer/dist/lexer.js +2 -2
  253. package/node_modules/es-module-lexer/dist/lexer.minimal.asm.js +2 -2
  254. package/node_modules/es-module-lexer/dist/lexer.minimal.cjs +1 -1
  255. package/node_modules/es-module-lexer/dist/lexer.minimal.js +2 -2
  256. package/node_modules/es-module-lexer/package.json +1 -1
  257. package/node_modules/import-in-the-middle/CHANGELOG.md +35 -0
  258. package/node_modules/import-in-the-middle/README.md +15 -1
  259. package/node_modules/import-in-the-middle/create-hook.mjs +370 -155
  260. package/node_modules/import-in-the-middle/index.d.ts +8 -2
  261. package/node_modules/import-in-the-middle/index.js +80 -53
  262. package/node_modules/import-in-the-middle/lib/get-esm-exports.mjs +37 -3
  263. package/node_modules/import-in-the-middle/lib/get-exports.mjs +33 -40
  264. package/node_modules/import-in-the-middle/lib/register.js +81 -16
  265. package/node_modules/import-in-the-middle/package.json +9 -5
  266. package/node_modules/supports-color/browser.js +21 -2
  267. package/node_modules/supports-color/index.js +41 -24
  268. package/node_modules/supports-color/license +1 -1
  269. package/node_modules/supports-color/package.json +11 -6
  270. package/node_modules/supports-color/readme.md +8 -7
  271. package/package.json +4 -4
  272. package/packages/pm-beads/package.json +1 -1
  273. package/packages/pm-calendar/package.json +1 -1
  274. package/packages/pm-command-kit/package.json +1 -1
  275. package/packages/pm-digital-twin/package.json +1 -1
  276. package/packages/pm-governance-audit/package.json +1 -1
  277. package/packages/pm-guide-shell/package.json +1 -1
  278. package/packages/pm-kanban/package.json +1 -1
  279. package/packages/pm-lifecycle-hooks/package.json +1 -1
  280. package/packages/pm-linked-test-adapters/package.json +1 -1
  281. package/packages/pm-search-advanced/package.json +1 -1
  282. package/packages/pm-templates/package.json +1 -1
  283. package/packages/pm-todos/package.json +1 -1
  284. package/packages/pm-vcs/package.json +1 -1
  285. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  286. package/plugins/pm-claude/package.json +1 -1
  287. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  288. package/plugins/pm-codex/package.json +1 -1
  289. package/plugins/pm-codex/plugin.json +1 -1
  290. package/runtime-dependencies.json +1 -1
  291. package/dist/cli-bundle/chunks/chunk-4WIVCOA7.js +0 -2
  292. package/dist/cli-bundle/chunks/chunk-A3WCP4TU.js +0 -6
  293. package/dist/cli-bundle/chunks/chunk-AB5S6TWE.js +0 -124
  294. package/dist/cli-bundle/chunks/chunk-BV7J3LRH.js +0 -114
  295. package/dist/cli-bundle/chunks/chunk-E4BQRZF2.js +0 -10
  296. package/dist/cli-bundle/chunks/chunk-IGEBFNWE.js +0 -2
  297. package/dist/cli-bundle/chunks/chunk-IYICNCK2.js +0 -2
  298. package/dist/cli-bundle/chunks/chunk-JD3XWF66.js +0 -3
  299. package/dist/cli-bundle/chunks/chunk-JLHD7OQ2.js +0 -2
  300. package/dist/cli-bundle/chunks/chunk-LC4DJVXR.js +0 -2
  301. package/dist/cli-bundle/chunks/chunk-OFZQEQ6X.js +0 -2
  302. package/dist/cli-bundle/chunks/chunk-QGL5IAP4.js +0 -8
  303. package/dist/cli-bundle/chunks/chunk-R24NZ2TB.js +0 -8
  304. package/dist/cli-bundle/chunks/chunk-VO2HSB5F.js +0 -2
  305. package/dist/cli-bundle/chunks/item-transaction-55QTCU2M.js +0 -2
  306. package/dist/cli-bundle/chunks/mutation-admission-WUN7JYVJ.js +0 -2
  307. package/dist/cli-bundle/chunks/register-mutation-SKCEP5QU.js +0 -20
  308. package/dist/cli-bundle/chunks/register-operations-ZT4OYCF3.js +0 -2
  309. package/dist/cli-bundle/chunks/register-setup-JVWNS2TY.js +0 -2
  310. package/dist/cli-bundle/focused-chunks/chunk-3WVMEA2A.js +0 -6
  311. package/dist/cli-bundle/focused-chunks/chunk-5UVJOAUP.js +0 -91
  312. package/dist/cli-bundle/focused-chunks/chunk-5WQ3LNUK.js +0 -78
  313. package/dist/cli-bundle/focused-chunks/chunk-7XHE335U.js +0 -2
  314. package/dist/cli-bundle/focused-chunks/chunk-CZFZCSOX.js +0 -2
  315. package/dist/cli-bundle/focused-chunks/chunk-HPC2M6JD.js +0 -6
  316. package/dist/cli-bundle/focused-chunks/chunk-HR5FEUUL.js +0 -2
  317. package/dist/cli-bundle/focused-chunks/chunk-J7ESCE7M.js +0 -24
  318. package/dist/cli-bundle/focused-chunks/chunk-KWZLY35A.js +0 -2
  319. package/dist/cli-bundle/focused-chunks/chunk-M4IA4LC6.js +0 -8
  320. package/dist/cli-bundle/focused-chunks/chunk-NASE6JC2.js +0 -2
  321. package/dist/cli-bundle/focused-chunks/chunk-QJ647CQE.js +0 -2
  322. package/dist/cli-bundle/focused-chunks/chunk-ZCN35TCK.js +0 -2
  323. package/dist/cli-bundle/focused-chunks/chunk-ZSQ2FT22.js +0 -44
  324. package/dist/cli-bundle/focused-chunks/item-revision-GNKYO6GZ.js +0 -2
  325. package/dist/cli-bundle/focused-chunks/item-transaction-AUUQHR5Z.js +0 -2
  326. package/dist/cli-bundle/focused-chunks/mutation-actor-OBRD7HFZ.js +0 -2
  327. package/dist/cli-bundle/focused-chunks/mutation-admission-6TX3EOJX.js +0 -2
  328. package/dist/cli-bundle/focused-chunks/stage-LERF2YJU.js +0 -2
  329. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.d.ts +0 -14984
  330. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js +0 -14991
  331. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_events.d.ts +0 -291
  332. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.d.ts +0 -4053
  333. package/node_modules/@opentelemetry/semantic-conventions/build/esm/index-incubating.d.ts +0 -7
  334. package/node_modules/@opentelemetry/semantic-conventions/build/esm/index-incubating.js +0 -13
  335. package/node_modules/@opentelemetry/semantic-conventions/build/esm/index.d.ts +0 -6
  336. package/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js +0 -16
  337. package/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.d.ts +0 -7
  338. package/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js +0 -23
  339. package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.d.ts +0 -1453
  340. package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js +0 -1250
  341. package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.d.ts +0 -2
  342. package/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js +0 -10
  343. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.d.ts +0 -1726
  344. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_events.d.ts +0 -5
  345. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_events.js +0 -12
  346. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.d.ts +0 -308
  347. package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.d.ts +0 -2664
  348. package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js +0 -2360
  349. package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.d.ts +0 -2
  350. package/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js +0 -10
  351. package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.d.ts +0 -2
  352. package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js +0 -7
  353. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.d.ts +0 -14984
  354. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_events.d.ts +0 -291
  355. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.d.ts +0 -4053
  356. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index-incubating.d.ts +0 -7
  357. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index-incubating.js +0 -13
  358. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index.d.ts +0 -6
  359. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/index.js +0 -16
  360. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/internal/utils.d.ts +0 -7
  361. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/internal/utils.js +0 -23
  362. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/SemanticResourceAttributes.js +0 -1250
  363. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/index.d.ts +0 -2
  364. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/resource/index.js +0 -10
  365. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.d.ts +0 -1726
  366. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_events.d.ts +0 -5
  367. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_events.js +0 -12
  368. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_metrics.d.ts +0 -308
  369. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_metrics.js +0 -315
  370. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/SemanticAttributes.js +0 -2360
  371. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/index.d.ts +0 -2
  372. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/trace/index.js +0 -10
  373. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.d.ts +0 -2
  374. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js +0 -7
  375. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.d.ts +0 -14984
  376. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_events.d.ts +0 -291
  377. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_events.js +0 -301
  378. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.d.ts +0 -4053
  379. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js +0 -4072
  380. package/node_modules/@opentelemetry/semantic-conventions/build/src/index-incubating.d.ts +0 -7
  381. package/node_modules/@opentelemetry/semantic-conventions/build/src/index-incubating.js +0 -29
  382. package/node_modules/@opentelemetry/semantic-conventions/build/src/index.d.ts +0 -6
  383. package/node_modules/@opentelemetry/semantic-conventions/build/src/index.js +0 -32
  384. package/node_modules/@opentelemetry/semantic-conventions/build/src/internal/utils.d.ts +0 -7
  385. package/node_modules/@opentelemetry/semantic-conventions/build/src/internal/utils.js +0 -27
  386. package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/SemanticResourceAttributes.js +0 -1255
  387. package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/index.d.ts +0 -2
  388. package/node_modules/@opentelemetry/semantic-conventions/build/src/resource/index.js +0 -26
  389. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.d.ts +0 -1726
  390. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js +0 -1759
  391. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_events.d.ts +0 -5
  392. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_events.js +0 -15
  393. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_metrics.d.ts +0 -308
  394. package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/SemanticAttributes.js +0 -2368
  395. package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/index.d.ts +0 -2
  396. package/node_modules/@opentelemetry/semantic-conventions/build/src/trace/index.js +0 -26
  397. package/node_modules/@opentelemetry/semantic-conventions/build/src/version.d.ts +0 -2
  398. package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js +0 -10
  399. /package/node_modules/import-in-the-middle/{register-hooks.d.ts → register-hooks.d.mts} +0 -0
@@ -0,0 +1,115 @@
1
+ import{A as g,C as h,E as un,F as Se,G as q,H as zc,K as Hc,L as Vc,a as pe,b as gi,c as Mc,e as _r,f as yr,g as gr,h as jc,i as hr,j as It,k as Lc,m as Oe,n as Fc,o as Uc,p as br,q as wr,u as ln,y as hi}from"./chunk-5OFMWP3Q.js";import L_ from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="77f9d61e-e78b-5b6a-a769-1ad6e5b91777")}catch{}})();function F_(e){if(e===null)return null;if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="bigint")return e.toString();if(e===void 0)return"undefined";if(typeof e=="symbol")return e.toString();if(typeof e=="function")return`[function:${e.name||"anonymous"}]`}function U_(e){let t=Object.keys(e).sort(),n={};for(let r of t){let o=e[r];o!==void 0&&(n[r]=vr(o))}return n}function vr(e){let t=F_(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(r=>vr(r));if(e instanceof Date)return e.toISOString();let n=e;if(typeof n.toJSON=="function"){let r=n.toJSON();if(r!==e)return vr(r)}return U_(e)}function C(e){return JSON.stringify(vr(e))}function qc(e,t,n,r){for(let o=0;o<t.length;o+=1)if(!n.has(o)&&r(e,t[o]))return n.add(o),!0;return!1}function z_(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function H_(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function V_(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let n=[...t],r=new Set;for(let o of e)if(!qc(o,n,r,ce))return!1;return!0}function q_(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let n=[...t.entries()],r=new Set;for(let[o,i]of e.entries())if(!qc([o,i],n,r,([s,a],[c,d])=>ce(s,c)&&ce(a,d)))return!1;return!0}function B_(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,r)=>ce(n,t[r]))}function W_(e,t){let n=Object.keys(e).sort((o,i)=>o.localeCompare(i)),r=Object.keys(t).sort((o,i)=>o.localeCompare(i));if(n.length!==r.length)return!1;for(let o=0;o<n.length;o+=1){let i=n[o];if(i!==r[o]||!ce(e[i],t[i]))return!1}return!0}var G_=[z_,H_,V_,q_,B_];function ce(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let n of G_){let r=n(e,t);if(r!==void 0)return r}return W_(e,t)}function Tt(e){return L_.createHash("sha256").update(e,"utf8").digest("hex")}function Ke(e,t){let n={};for(let o of t){let i=e[o];i!==void 0&&(n[o]=i)}let r=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of r){let i=e[o];i!==void 0&&(n[o]=i)}return n}import{createHash as Wc}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f675993f-c483-5751-baed-d968b4fd24c0")}catch{}})();var K_=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],Bc=256,bi=64;function Q(e){throw new h(`Invalid workflow policy: ${e}`,g.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function _e(e,t,n){if(typeof e!="object"||e===null||Array.isArray(e))return Q(`${n} must be an object`);let r=e;return Object.keys(r).some(o=>!t.includes(o))?Q(`${n} contains an unknown key`):r}function Ye(e,t,n=128){return typeof e!="string"||!e.trim()||e.length>n?Q(`${t} must be nonempty text of at most ${n} characters`):e.trim()}function fn(e,t){if(!Array.isArray(e)||e.length===0||e.length>bi)return Q(`${t} requires 1-${bi} terms`);let n=e.map(r=>Ye(r,t));return t==="fields"&&n.some(r=>!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$/.test(r)||r.split(".").some(o=>["__proto__","constructor","prototype"].includes(o)))?Q("fields must be safe metadata paths of at most eight segments"):[...new Set(n)]}function Y_(e){let t=_e(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(_e(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>bi?Q("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(n=>!Array.isArray(n)||n.length!==2?Q("transition pairs need two statuses"):[Ye(n[0],"from"),Ye(n[1],"to")])}):t.kind==="authors"?(_e(t,["kind","authors"],"authors rule"),{kind:"authors",authors:fn(t.authors,"authors")}):t.kind==="require_fields"?(_e(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:fn(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(_e(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:fn(t.fields,"fields"),authors:fn(t.authors,"authors")}):Q("unknown rule kind")}function X_(e){let t={},n=_e(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let r of["types","tags","statuses","operations","parents"])n[r]!==void 0&&(t[r]=fn(n[r],r));if(n.dependency!==void 0){let r=_e(n.dependency,["kind","id"],"dependency");t.dependency={kind:Ye(r.kind,"dependency kind"),...r.id===void 0?{}:{id:Ye(r.id,"dependency id")}}}return t}function J_(e){let t=_e(e,["id","description","subject","effect","rule"],"policy"),n=Ye(t.id,"id");return/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(n)?t.effect!==void 0&&(typeof t.effect!="string"||!["advise","warn","refuse"].includes(t.effect))?Q("effect must be advise, warn, or refuse"):{id:n,rule:Y_(t.rule),...t.subject===void 0?{}:{subject:X_(t.subject)},...t.description===void 0?{}:{description:Ye(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:Q("id must be a stable token")}function Q_(e){let t=_e(e,["version","enforcement","policies"],"document");if(t.version!==1)return Q("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return Q("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>Bc)return Q(`policies must contain at most ${Bc} declarations`);let n=t.policies.map(J_);return new Set(n.map(r=>r.id)).size!==n.length?Q("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:n}}function Er(e,t){let n=e;for(let r of t.split(".")){if(typeof n!="object"||n===null||!Object.hasOwn(n,r))return;n=n[r]}return n}function Z_(e){return e==null?!1:typeof e=="string"?e.trim().length>0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0}function Gc(e){return Wc("sha256").update(C(e)).digest("hex")}function ey(e,t){let n=e.rule.kind==="approval"?e.rule.fields:[];return Wc("sha256").update(C({id:t.id,fields:n.map(r=>[r,Er(t,r)])})).digest("hex")}function ty(e,t){return Array.isArray(t)&&t.some(n=>typeof n=="object"&&n!==null&&"kind"in n&&n.kind===e.kind&&(e.id===void 0||"id"in n&&n.id===e.id))}function ny(e,t,n){return!(e.types&&!e.types.some(r=>r.toLowerCase()===String(t.type).toLowerCase())||e.statuses&&!e.statuses.includes(String(t.status))||e.operations&&!e.operations.includes(n)||e.parents&&!e.parents.includes(String(t.parent))||e.tags&&(!Array.isArray(t.tags)||!e.tags.some(r=>t.tags.includes(r)))||e.dependency&&!ty(e.dependency,t.dependencies))}function ry(e,t){if(t.completeness_only&&(e.rule.kind!=="require_fields"||e.subject?.operations!==void 0)||e.rule.kind==="approval"&&t.before===null)return!1;let n=e.subject??{},r=t.after?.status??t.before?.status;return[t.before,t.after].some(o=>o!==null&&ny(n,{...o,status:r},t.operation))}function oy(e,t,n,r){let o=["type","tags","parent","dependencies"].some(i=>!ce(t.before?.[i],t.after?.[i]));return t.after&&(t.completeness_only||n||r||o)?e.filter(i=>!Z_(Er(t.after,i))):[]}function iy(e,t,n,r){let o=t.after??t.before,i=ey(e,o);return t.approvals?.some(s=>s.policy_fingerprint===r&&s.content_fingerprint===i&&s.author!==t.author&&n.includes(s.author))??!1}function sy(e,t,n){let r=e.rule,o=t.before?.status!==t.after?.status,i="fields"in r&&r.fields.some(s=>!ce(Er(t.before,s),Er(t.after,s)));switch(r.kind){case"require_fields":{let s=oy(r.fields,t,o,i);return{satisfied:s.length===0,missing_fields:s,remediation:"Supply the declared required fields before this lifecycle transition."}}case"transition":return{satisfied:!o||r.allowed.some(([s,a])=>s===String(t.before?.status??"$create")&&a===String(t.after?.status??"$delete")),missing_fields:[],remediation:"Choose a declared allowed transition; inspect pm schema policies."};case"authors":return{satisfied:r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared workflow actor perform this operation."};case"field_writers":return{satisfied:!i||r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared field writer change the protected fields."};case"approval":return{satisfied:!o||iy(e,t,r.authors,n),missing_fields:[],remediation:`Record an independent approval with pm schema policy-approve <item-id> --policy ${e.id} after preparing the reviewed fields.`}}}function Kc(e,t,n){let r=e.policies.filter(o=>ry(o,t)).map(o=>{let i=o.effect??"advise",s=n(o);return{policy_id:o.id,policy_fingerprint:s,rule:o.rule.kind,effect:i==="refuse"&&e.enforcement!=="refuse"?"warn":i,...sy(o,t,s)}});return{allowed:!r.some(o=>!o.satisfied&&o.effect==="refuse"),decisions:r,warnings:r.filter(o=>!o.satisfied).map(o=>`workflow_policy:${o.effect}:${o.policy_id}:${o.rule}`)}}function vT(e,t){return Kc(e,t,Gc)}function ET(e){let t=Q_(e),n=new Map(t.policies.map(r=>[r,Gc(r)]));return r=>Kc(t,r,o=>n.get(o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="451b262c-a9b6-5f1c-b397-2686a5fd953a")}catch{}})();var ay=[["history-redact","history redact"],["history-repair","history repair"],["history-compact","history compact"],["activity","history activity"],["restore","history restore"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-tqel"})),cy=[...["next","focus"].map(e=>({alias:e,canonical:`context ${e}`,owner:"pm-kcs4"})),...["stats","health","validate","gc","telemetry","eval","test-all"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-6apl"})),...["normalize","reindex"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-3i9q8g"})),{alias:"events",canonical:"history events",owner:"pm-3i9q8g"}].map(e=>({...e,canonical_argv:e.canonical.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap"})),dy=[["update-many","update many"],["close-many","close many"],["delete","close delete"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-ik19"})),ly=[...cy,...dy,...["init","config","schema","profile"].map(e=>({alias:e,canonical:`workspace ${e}`,canonical_argv:["workspace",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-npr3"})),...[...["comments","notes","learnings","files","docs","deps","append","test"].map(e=>[e,`item ${e}`,"pm-yql1"]),["test-runs-worker","item test worker","pm-lp4j"],...["statuses","tags","types"].map(e=>[`completion-${e}`,`completion ${e}`,"pm-szdc"]),["history-author-acknowledge","history acknowledge","pm-djyvbk"],["copy","item copy","pm-m6g87m"],["merge","workspace merge","pm-m6g87m"],["duplicates","item duplicates","pm-fmy9ih"],["dedupe-audit","item duplicates audit","pm-fmy9ih"],["dedupe-merge","item duplicates merge","pm-fmy9ih"],["comments-audit","item audit-comments","pm-fmy9ih"],["search-advanced","search advanced","pm-wfskfn"],...["meet","event","remind"].map(e=>[e,`calendar ${e}`,"pm-o3fh"])].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:n}))],wi=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...ay,...ly,...["discover","lookup"].map(e=>({alias:`files ${e}`,canonical:`item files ${e}`,canonical_argv:["item","files",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-yql1"}))];function ST(e){let t;for(let n of wi)n.canonical_argv.length<=(t?.canonical_argv.length??0)||n.canonical_argv.every((r,o)=>r===(o===0&&e[o]==="ctx"?"context":e[o]))&&(t=n);return t}function uy(e){let t=e.trim().replace(/\s+/gu," ");return wi.find(n=>n.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function mn(e){return uy(e)}var Or=[...wi,...[["ctx","context"],["packages","package"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:[t],lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-pbyu"})),...[["start-task","claim","--start"],["pause-task","release","--pause"],["close-task","close","--release-assignment"]].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:[t,n],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-eq4x"})),{alias:"tests",canonical:"item test",canonical_argv:["item","test"],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-u4t9gp"},...[["fetch","get"],["read","get"],["show","get"],["view","get"],["comment","comments"],["note","notes"],["learning","learnings"]].map(([e,t])=>({alias:e,canonical:["comments","notes","learnings"].includes(t)?`item ${t}`:t,canonical_argv:["comments","notes","learnings"].includes(t)?["item",t]:[t],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-pbyu"})),...[["extension list","extension catalog"],["extension scaffold","extension init"],["package list","package catalog"],["package scaffold","package init"],["packages list","package catalog"],["packages scaffold","package init"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-ya7x55"})),{alias:"list-all",canonical:"list",canonical_argv:["list","--all"],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"},...[["list-draft","draft"],["list-open","open"],["list-in-progress","in_progress"],["list-blocked","blocked"],["list-closed","closed"],["list-canceled","canceled"]].map(([e,t])=>({alias:e,canonical:"list",canonical_argv:["list","--status",t],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"})),...[["extension","package"],["install","package install"],["upgrade","package upgrade"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-tnud"}))],kT=Object.fromEntries(Or.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function AT(e){let t=e.trim().toLowerCase();return Or.find(n=>n.alias===t)}function IT(e){return`Deprecated command \`${e.alias}\`; use \`pm ${e.canonical_argv.join(" ")}\`.`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3348c61d-a03e-5023-a5dc-fd6149f478c1")}catch{}})();var fy=[...pe],my=[...It],py=[..._r],NT=[...yr],DT=[...gr],_y=[...hr],Sr=["init","config","extension","package","packages","install","upgrade","create","item","copy","focus","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","aggregate","context","ctx","get","graph","search","duplicates","eval","next","history","events","history-redact","history-repair","history-compact","history-attest","history-author-acknowledge","merge","schema","profile","activity","restore","update","update-many","close","close-many","delete","append","comments","notes","learnings","files","docs","deps","plan","test","test-all","telemetry","stats","health","validate","assurance","gc","workspace","contracts","claim","release","start-task","pause-task","close-task","meet","event","remind","help"],PT=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],$T=["install","reconcile","report","driver"],yy=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],gy=["upgrade"],hy=["reopen"],Yc={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Ct=Object.freeze(Sr.flatMap(e=>e in Yc?[]:e==="extension"||e==="package"?[...yy.map(t=>`${e}-${t}`),...e==="package"?gy.map(t=>`package-${t}`):[],e]:e==="item"?hy.map(t=>`item-${t}`):[e])),by=Object.freeze(Or.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Ct.includes(e.alias)).map(e=>e.alias)),MT=Object.freeze(Ct.filter(e=>!by.includes(e)));function jT(e=Sr,t=Ct,n=Yc){let r=new Set(t),o=new Set(e);return{missing_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]===void 0),waived_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]!==void 0),stale_waivers:Object.keys(n).filter(i=>!o.has(i)||r.has(i)||t.some(s=>s.startsWith(`${i}-`)))}}function LT(e){return Ct.includes(e)}function FT(e){return fy.includes(e)}function UT(e){return my.includes(e)}function zT(e){return py.includes(e)}function HT(e){return _y.includes(e)}var VT=new Set(["update","item-reopen","close","claim","release","start-task","pause-task","close-task","restore","append","update-many","close-many","delete","comments","notes","learnings","files","docs","test","test-all","plan","history-redact","history-repair","history-compact","validate"]);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="467196ad-a2fc-5048-bc06-a1d027fb0ae2")}catch{}})();var wy=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],Xc=wy,Rt=["draft","open","in_progress","blocked","closed","canceled"],Jc=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],kr=["string","number","boolean","string_array","array","object"],Qc=["create","update","update_many","list","search","calendar","context"],Zc=["allow","warn","reject"],BT=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],WT=["project","global"],GT=["low","medium","high","critical"],Ar=["low","medium","high","critical"],Ir=["low","medium","high"];var KT=["minimal","default","strict","custom"],YT=["none","warn","strict"],XT=["progressive","strict"],JT=["off","warn","strict"],QT=["off","warn","strict"],ZT=["off","warn","strict"];var Tr=["daily","weekly","monthly","yearly"],pn=["mon","tue","wed","thu","fri","sat","sun"];function vi(e){return pn.indexOf(e)}var eC=["draft","research","review","approved","executing","paused","completed","superseded"],ed=["pending","in_progress","completed","blocked","skipped","superseded"],tC=["codex","claude-code","cursor","generic"],nC=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],rC=["brief","standard","deep","full"],oC=["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0ca7f52c-fb31-5cd9-b689-a918f4e61816")}catch{}})();import ky from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="75f74db3-9547-5c78-8561-f371c016b90d")}catch{}})();function ke(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function vy(e){let t=e.key.trim();if(t.length===0)return null;let n=ke(e.aliases),r=e.description?.trim();return{key:t,values:ke(e.values),required:e.required===!0?!0:void 0,aliases:n.length>0?n:void 0,description:r&&r.length>0?r:void 0}}var Ey=e=>e,nd=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function Oy(e,t){let n=t(e.command);if(n===null)return null;let r=e.option.trim();return r.length===0?null:{command:n,option:r,required:e.required,visible:e.visible,enabled:e.enabled}}function Sy(e,t){let n=new Map;for(let r of e??[]){let o=Oy(r,t);o&&n.set(`${o.command}:${o.option.toLowerCase()}`,o)}return[...n.values()].sort((r,o)=>r.command===o.command?r.option.localeCompare(o.option):r.command.localeCompare(o.command))}function td(e,t){return t?ke(e):void 0}function Ei(e){let t=e?.trim();return t&&t.length>0?t:void 0}function Oi(e){if(e===void 0||e==="agent"||e==="human"||e==="gate")return e;throw new Error("Item type execution_role must be agent, human, or gate.")}function rd(e,t={}){let n=t.resolvePolicyCommand??Ey,r=e.name.trim();if(r.length===0)return null;let o=e.required_create_fields!==void 0,i=e.required_create_repeatables!==void 0,s=e.options!==void 0,a=e.command_option_policies!==void 0,c=ke(e.aliases),d=(e.options??[]).map(u=>vy(u)).filter(u=>u!==null).sort((u,f)=>u.key.localeCompare(f.key)),l=Sy(e.command_option_policies,n);return{name:r,description:Ei(e.description),default_status:Ei(e.default_status),...e.execution_role===void 0?{}:{execution_role:Oi(e.execution_role)},folder:Ei(e.folder),aliases:c.length>0?c:void 0,required_create_fields:td(e.required_create_fields,o),required_create_repeatables:td(e.required_create_repeatables,i),options:s?d:void 0,command_option_policies:a?l:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f40ddc8e-1dd5-5f26-b2ba-fbbac30a1781")}catch{}})();var Ay=Object.freeze({decision:"human",milestone:"gate"}),Iy=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],Ty=["dep","comment","note","learning","file","test","doc"],id=["deadline","estimatedMinutes","acceptanceCriteria","definitionOfReady","order","goal","objective","value","impact","outcome","whyNow","assignee","parent","reviewer","risk","confidence","sprint","release","blockedBy","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact"],Cy=["title","description","type","status","priority","tags","body",...id,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],Ry=["title","description","body","status","closeReason","priority","type","tags",...id,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],sd={"close-reason":"closeReason",close_reason:"closeReason","estimated-minutes":"estimatedMinutes",estimated_minutes:"estimatedMinutes",estimate:"estimatedMinutes","acceptance-criteria":"acceptanceCriteria",acceptance_criteria:"acceptanceCriteria",ac:"acceptanceCriteria","definition-of-ready":"definitionOfReady",definition_of_ready:"definitionOfReady",rank:"order","why-now":"whyNow",why_now:"whyNow","blocked-by":"blockedBy",blocked_by:"blockedBy","blocked-reason":"blockedReason",blocked_reason:"blockedReason","unblock-note":"unblockNote",unblock_note:"unblockNote","repro-steps":"reproSteps",repro_steps:"reproSteps","expected-result":"expectedResult",expected_result:"expectedResult","actual-result":"actualResult",actual_result:"actualResult","affected-version":"affectedVersion",affected_version:"affectedVersion","fixed-version":"fixedVersion",fixed_version:"fixedVersion","customer-impact":"customerImpact",customer_impact:"customerImpact","type-option":"typeOption",type_option:"typeOption",type_options:"typeOption"},xy={...sd},Ny={...sd},ad=[["deadline","--deadline"],["estimatedMinutes","--estimate/--estimated-minutes"],["acceptanceCriteria","--acceptance-criteria/--ac"],["definitionOfReady","--definition-of-ready"],["order","--order/--rank"],["goal","--goal"],["objective","--objective"],["value","--value"],["impact","--impact"],["outcome","--outcome"],["whyNow","--why-now"],["assignee","--assignee"],["parent","--parent"],["reviewer","--reviewer"],["risk","--risk"],["confidence","--confidence"],["sprint","--sprint"],["release","--release"],["blockedBy","--blocked-by"],["blockedReason","--blocked-reason"],["unblockNote","--unblock-note"],["reporter","--reporter"],["severity","--severity"],["environment","--environment"],["reproSteps","--repro-steps"],["resolution","--resolution"],["expectedResult","--expected-result"],["actualResult","--actual-result"],["affectedVersion","--affected-version"],["fixedVersion","--fixed-version"],["component","--component"],["regression","--regression"],["customerImpact","--customer-impact"]],cd=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function dd(e){return Object.fromEntries(e)}var Dy=dd([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...ad,["author","--author"],["message","--message"],["dep","--dep"],...cd]),Py=dd([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...ad,...cd,["author","--author"],["message","--message"],["force","--force"]]);function $y(e){return e.trim().replace(/^--+/,"").toLowerCase()}function My(e){return e==="create"?Cy:Ry}function jy(e){return e==="create"?xy:Ny}function ld(e,t){let n=$y(t);return n.length===0?void 0:jy(e)[n]||My(e).find(r=>r.toLowerCase()===n)}function mC(e,t){return(e==="create"?Dy:Py)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function ki(e){let t=Fy(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function Ly(e){let t=e.trim(),n=t.replaceAll("\\","/").replace(/^\/+/,""),r=ky.posix.normalize(n);if(t.includes("\0")||/^[A-Za-z]:/.test(r)||r==="."||r===".."||r.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return r}function Fy(e){let t=e.trim().toLowerCase(),n="",r=!1;for(let o of t){let i=o.charCodeAt(0),s=i>=97&&i<=122,a=i>=48&&i<=57;if(s||a){r&&n.length>0&&(n+="-"),n+=o,r=!1;continue}n.length>0&&(r=!0)}return n}function Uy(e){return rd(e,{resolvePolicyCommand:nd})}function _n(e,t){let n=e[t];return Array.isArray(n)?n.filter(r=>typeof r=="string"):void 0}function zy(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;return typeof t.key!="string"?null:{key:t.key,values:_n(t,"values")??[],required:t.required===void 0?void 0:!!t.required,aliases:_n(t,"aliases"),description:typeof t.description=="string"?t.description:void 0}}function Hy(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;if(typeof t.command!="string"||typeof t.option!="string")return null;let n=t.command.trim().toLowerCase();return n!=="create"&&n!=="update"?null:{command:n,option:t.option,required:t.required===void 0?void 0:!!t.required,visible:t.visible===void 0?void 0:!!t.visible,enabled:t.enabled===void 0?void 0:!!t.enabled}}function Vy(e){if(Array.isArray(e.options))return e.options.map(t=>zy(t)).filter(t=>t!==null)}function qy(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>Hy(t)).filter(t=>t!==null)}function By(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e,n=typeof t.name=="string"?t.name:"";if(n.trim().length===0)return null;let r=typeof t.folder=="string"?t.folder:void 0,o=typeof t.description=="string"?t.description:void 0,i=typeof t.default_status=="string"?t.default_status:void 0;return{name:n,description:o,default_status:i,execution_role:Oi(t.execution_role),folder:r,aliases:_n(t,"aliases"),required_create_fields:_n(t,"required_create_fields"),required_create_repeatables:_n(t,"required_create_repeatables"),options:Vy(t),command_option_policies:qy(t)}}function Wy(e,t){return e.required_create_fields?ke(e.required_create_fields):t?.required_create_fields??[]}function Gy(e,t){return e.required_create_repeatables?ke(e.required_create_repeatables):t?.required_create_repeatables??[]}function Ky(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function Yy(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function Xy(e,t){let n=t?.name??e.name,r=e.description??t?.description,o=e.default_status??t?.default_status,i=Ly(e.folder??t?.folder??ki(n)),s={name:n,execution_role:e.execution_role,folder:i,aliases:ke([...t?.aliases??[],...e.aliases??[]]),required_create_fields:Wy(e,t),required_create_repeatables:Gy(e,t),options:Ky(e,t),command_option_policies:Yy(e,t)};return r&&(s.description=r),o&&(s.default_status=o),s}function od(e,t){for(let n of e){let r=Uy(n);if(!r)continue;let o=r.name.toLowerCase(),i=t.get(o);t.set(o,Xy({...r,execution_role:r.execution_role??i?.execution_role},i))}}function Jy(e){if(!e)return[];let t=[];for(let n of e.item_types??[]){let r=n.types;if(Array.isArray(r))for(let o of r){let i=By(o);i&&t.push(i)}}return t}function pC(e,t=null){let n=new Map;for(let c of Xc)n.set(c.toLowerCase(),{name:c,execution_role:Ay[c.toLowerCase()]??"agent",folder:ln[c],aliases:[],required_create_fields:[...Iy],required_create_repeatables:[...Ty],options:[],command_option_policies:[]});od(e.item_types?.definitions??[],n),od(Jy(t),n);let r=[...n.values()].sort((c,d)=>c.name.localeCompare(d.name)),o={},i={},s={};for(let c of r){o[c.name]=c,s[c.name]=c.folder,i[c.name.toLowerCase()]=c.name;for(let d of c.aliases)i[d.toLowerCase()]=c.name}let a=[...new Set(r.map(c=>c.folder))].sort((c,d)=>c.localeCompare(d));return{types:r.map(c=>c.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function Qy(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function Zy(e,t){let n=Qy(e,t);if(n)return t.by_type[n]}function eg(e,t,n,r){for(let o of r){let i=ld(n,o);if(i){e.required.add(i);continue}e.errors.push(`Unsupported base required option "${o}" for command "${n}" on type "${t.name}"`)}}function Si(e,t,n){if(n){e.add(t);return}e.delete(t)}function tg(e,t,n,r){let o=ld(n,r.option);if(!o){e.errors.push(`Unsupported command_option_policies option "${r.option}" for command "${n}" on type "${t.name}"`);return}r.required!==void 0&&Si(e.required,o,r.required),r.visible!==void 0&&Si(e.hidden,o,!r.visible),r.enabled!==void 0&&Si(e.disabled,o,!r.enabled)}function ng(e,t,n){for(let r of t.command_option_policies)r.command===n&&tg(e,t,n,r)}function rg(e,t,n){for(let r of e.required)e.disabled.has(r)&&e.errors.push(`Option "${r}" cannot be both required and disabled for command "${n}" on type "${t.name}"`)}function _C(e,t,n){let r=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:r};return eg(a,e,t,n),ng(a,e,t),rg(a,e,t),{required:[...o],hidden:[...i].sort((c,d)=>c.localeCompare(d)),disabled:[...s].sort((c,d)=>c.localeCompare(d)),errors:r}}function og(e){let t=new Map;for(let n of e.options){t.set(n.key.toLowerCase(),n);for(let r of n.aliases??[])t.set(r.toLowerCase(),n)}return t}function ig(e,t,n){let r=e.values;if(r.length===0)return t;let o=new Map(r.map(i=>[i.toLowerCase(),i])).get(t.toLowerCase());if(!o){n.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${r.join(", ")}`);return}return o}function yC(e,t,n){let r=Zy(e,n);if(!r)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=og(r),s={};for(let[c,d]of Object.entries(t??{})){let l=c.trim(),u=d.trim();if(l.length===0){o.push("type option keys must not be empty");continue}if(u.length===0){o.push(`type option "${l}" must not be empty`);continue}let f=i.get(l.toLowerCase());if(!f){let p=r.options.map(_=>_.key).join(", ");o.push(r.options.length>0?`Unknown type option "${l}" for type "${r.name}". Allowed: ${p}`:`Type "${r.name}" does not define any configurable type options`);continue}let m=ig(f,u,o);m!==void 0&&(s[f.key]=m)}for(let c of r.options)c.required&&!(c.key in s)&&o.push(`Missing required type option "${c.key}" for type "${r.name}"`);let a=Object.keys(s).sort((c,d)=>c.localeCompare(d));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(c=>[c,s[c]])),errors:o}}import{readFileSync as sg,readdirSync as ag,realpathSync as ud,statSync as fd}from"node:fs";import cg from"node:os";import O from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7f4b8abe-997c-549c-9791-87c78506c8b5")}catch{}})();var dg={json_markdown:".md",toon:".toon"},lg={".md":"json_markdown",".toon":"toon"},ug=new Set([".git","coverage","dist","node_modules"]),kC=[".md",".toon"];function yn(e){try{return fd(e),!0}catch{return!1}}function fg(e){let t=O.resolve(e),n=[];for(;O.dirname(t)!==t;)try{return O.join(ud(t),...n)}catch(r){if(!Se(r))throw r;n.unshift(O.basename(t)),t=O.dirname(t)}return O.join(ud(t),...n)}function mg(e){try{return fd(e),!0}catch(t){if(Se(t))return!1;throw t}}function md(e){try{let t=JSON.parse(sg(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function pg(e){let t=fg(e);for(;;){let n=O.join(t,br),r=O.join(n,wr);if(yn(r))return n;let o=O.join(t,wr);if(yn(o)&&md(o))return t;if(mg(O.join(t,".git")))return n;let i=O.dirname(t);if(i===t)return;t=i}}function Ai(e){return pg(e)??O.resolve(e,br)}function AC(e,t){let n=t?O.resolve(t):void 0;try{return ag(O.resolve(e),{withFileTypes:!0}).filter(r=>r.isDirectory()&&!ug.has(r.name)).map(r=>O.join(O.resolve(e),r.name)).filter(r=>r!==n).filter(r=>yn(xt(r))).filter(r=>md(xt(r))).sort((r,o)=>r.localeCompare(o))[0]}catch{return}}function Cr(e,t){let n=process.env.PM_PATH,r=t?.trim()||n?.trim();if(r){let o=O.resolve(e,r);if(!yn(xt(o))){let i=O.join(o,br);if(yn(xt(i)))return i}return o}return Ai(e)}function pd(e){let t=O.resolve(e),n=O.dirname(t);return O.basename(t)==="pm"&&O.basename(n)===".agents"?O.dirname(n):t}function _d(e){let t=process.env.PM_GLOBAL_PATH?.trim(),n=t&&t.length>0?t:O.join(cg.homedir(),".pm-cli");return O.resolve(e,n)}function xt(e){return O.join(e,wr)}function _g(e,t,n=ln){let r=n[t]??ki(t);return O.join(e,r)}function IC(e,t,n,r="toon",o=ln){return O.join(_g(e,t,o),`${n}${dg[r]}`)}function TC(e){let t=e.replaceAll("\\","/"),n=O.posix.extname(t).toLowerCase();return lg[n]??null}function CC(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new h("Invalid history item id: expected a single filename.",g.USAGE);return O.join(e,"history",`${t}.jsonl`)}function Ii(e,t){return O.join(e,"locks",`${t}.lock`)}function Ti(e){return O.join(e,"runtime")}function Rr(e){return O.join(Ti(e),"test-runs")}function yg(e){return O.join(Rr(e),"runs")}function RC(e,t){return O.join(yg(e),`${t}.json`)}function gg(e){return O.join(Rr(e),"stdout")}function hg(e){return O.join(Rr(e),"stderr")}function xC(e,t){return O.join(gg(e),`${t}.log`)}function NC(e,t){return O.join(hg(e),`${t}.log`)}function bg(e){return O.join(Rr(e),"results")}function DC(e,t){return O.join(bg(e),`${t}.json`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="86412887-5659-5892-beaa-bdd15a02ff4c")}catch{}})();var xr=e=>{let t='"',n=0;for(let r of e){if(r==="\\"){n+=1;continue}t+="\\".repeat(r==='"'?n*2+1:n),t+=r,n=0}return`${t}${"\\".repeat(n*2)}"`},yd=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?xr(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,se=(e,t=process.platform)=>{let n=e.map(r=>yd(r,t)).join(" ");return n.length>0?`pm ${n}`:"pm"};import{AsyncLocalStorage as wg}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4252fc2e-3190-516e-a34b-0e2f6749be20")}catch{}})();var Ri="[redacted]";function vg(e,t){if(/[\t\n\r]/u.test(e)||!/(?:^|[^A-Za-z0-9+.-])(?:https?|wss?|ftp)$/iu.test(e.slice(0,t)))return!1;let n=t+1;for(;e[n]==="/"||e[n]==="\\";)n+=1;let r=e.indexOf("/",n)-n;if(r<0)return!1;let o=n+r;return!/[:@%]/u.test(e.slice(n,o))&&!/[:%]|[/\\][/\\]/u.test(e.slice(o))}function xi(e){let t=Math.max(e.lastIndexOf("@"),e.toLowerCase().lastIndexOf("%40")),n=e.indexOf(":");if(t<0||n<0||n>t)return;let r=n+1;for(;r<t&&r<n+3&&(e[r]==="/"||e[r]==="\\");)r+=1;return r===t||vg(e,n)?void 0:[r,t]}function Ni(e){let t=xi(e);return t?`${e.slice(0,t[0])}${Ri}${e.slice(t[1])}`:e}function gd(e){return Ni(e)}var hd=["author","assignee","claim_principal"];function UC(e){let t={...e};for(let n of hd)typeof t[n]=="string"&&(t[n]=gd(t[n]));return t}function Nt(e,t){if(!(typeof e!="string"||xi(e.trim())===void 0))throw new h(`${t} must not carry URL credentials: an identity is a name, never a credential.`,g.USAGE,{code:"invalid_argument_value",field:t,required:`Set ${t} to a plain name such as agent-a, without user:password@ or token@ userinfo.`,nextSteps:[`Rerun with ${t} set to a plain name.`]})}function zC(e,t){return Nt(e,t),e}var Eg=[["comments","author"],["notes","author"],["learnings","author"],["dependencies","author"],["plan_decisions","author"],["plan_discoveries","author"],["plan_steps","owner"],["tests","provenance","author"],["tests","updated_by"]],Og=4;function Ci(e,t,n=0){if(typeof e=="string"){Nt(e,t);return}if(!(n>=Og||typeof e!="object"||e===null))for(let r of Object.values(e))Ci(r,t,n+1)}function Sg(e,t){let n=e;for(let r of t){if(typeof n!="object"||n===null||Array.isArray(n))return;n=n[r]}return n}function bd(e){let t=e;for(let n of hd)Ci(t[n],n);for(let[n,...r]of Eg){let o=t[n];Array.isArray(o)&&o.forEach((i,s)=>{Ci(Sg(i,r),`${n}[${s}].${r.join(".")}`)})}}function HC(e){return typeof e=="string"?gd(e):e}var Nr=6,kg=65536,wd={carried:!1,fragments:new Set,fragmentLength:Nr,shortSpellings:[]},Di=new wg;function vd(e){let t=e.toLowerCase();if(t.length===e.length)return t;let n="";for(let r of e){let o=r.toLowerCase();n+=o.length===r.length?o:r}return n}function Ag(e){return[e,e.replaceAll(/(["\\$`])/gu,"\\$1"),xr(`${e}@`).slice(1,-2),JSON.stringify(e).slice(1,-1)]}function Ig(e){let t=e.indexOf(":");return t>=0&&t<e.length-1?e.slice(t+1):e}function Tg(e){let t=new Set,n=!1;for(let d of e){let l=xi(d);if(l){n=!0;for(let u of Ag(Ig(d.slice(l[0],l[1]))))t.add(vd(u))}}let r=[...t],o=r.reduce((d,l)=>d+Math.max(0,l.length-Nr+1)+1,0),i=Math.max(1,Math.ceil(o/kg)),s=Math.max(Nr,i),a=new Set,c=new Set;for(let d of r){if(d.length<s){(d.length>=Nr||/\s/u.test(d))&&c.add(d);continue}for(let l=0;l+s<=d.length;l+=i)a.add(d.slice(l,l+s));a.add(d.slice(-s))}return{carried:n,fragments:a,fragmentLength:s,shortSpellings:[...c]}}function Cg(e,t){let n=vd(e),r=new Uint8Array(e.length),o=!1,i=t.fragmentLength;for(let a=0;a+i<=n.length;a+=1)t.fragments.has(n.slice(a,a+i))&&(r.fill(1,a,a+i),o=!0);for(let a of t.shortSpellings)for(let c=n.indexOf(a);c>=0;c=n.indexOf(a,c+1))r.fill(1,c,c+a.length),o=!0;if(!o)return e;let s="";for(let a=0;a<e.length;a+=1)r[a]?(a===0||!r[a-1])&&(s+=Ri):s+=e[a];return s}function Rg(e,t){return Di.run(Tg(e),t)}function xg(){return(Di.getStore()??wd).carried}function Ng(e){let t=Di.getStore()??wd,n=t.carried?Cg(e,t):e;return/@|%40/iu.test(n)?n.replaceAll(/\S+/gu,Ni):n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9bb3b2ed-c289-5b96-99ce-9df6e202c464")}catch{}})();var Ed=new Set(["--pm-path","--path","--author","--expect-hash","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),Dg=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function Pg(e){let t=e.indexOf("=");return t>0&&Ed.has(e.slice(0,t))}function $g(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function Dr(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(Ed.has(n)){t+=$g(n,e[t+1])?1:0;continue}if(!(Pg(n)||Dg.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function qC(e){let t=Dr(e);return t===void 0?void 0:e[t].trim().toLowerCase()}import Mg from"node:path";import Od from"path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01422574-583a-5fd1-bc00-f61f430073cd")}catch{}})();function gn(e,t){let n=Od.relative(e,t);return n.length===0?!0:!n.startsWith("..")&&!Od.isAbsolute(n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7f08c44a-dfdf-5c23-8f68-0e3ed73582b0")}catch{}})();var Pi=new WeakMap;function eR(e){Pi.set(e,e.path)}function jg(e){if(!process.env.PM_PATH?.trim())return;let t=Cr(e);return gn(pd(t),e)&&t===Ai(e)?void 0:Mg.relative(e,t)||"."}function tR(e,t=process.cwd()){let n=Pi.has(e)?Pi.get(e):e.path,r=n?.trim()?n:jg(t),o=r?["--pm-path",r]:[];return e.noExtensions&&o.push("--no-extensions"),o}var Lg=new Set(["--literal","--regex","--replacement"]);function Fg(e){let t=Dr(e);if(t===void 0)return!1;if(e[t]==="history-redact")return!0;if(e[t]!=="history")return!1;let n=e.slice(t+1),r=Dr(n);return r!==void 0&&n[r]==="redact"}function nR(e){if(!Fg(e))return[...e];let t=[],n=!1;for(let r of e){if(n){t.push("[redacted]"),n=!1;continue}n=!1;let o=r.indexOf("="),i=o>=0?r.slice(0,o):r;if(!Lg.has(i)){t.push(r);continue}if(o>=0){t.push(`${i}=[redacted]`);continue}t.push(i),n=!0}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d4155698-c244-5623-b627-92dd25297125")}catch{}})();var Ug=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields",extension_command_availability:"read_output"},{flag:"--output-limit",value_name:"count",extension_command_availability:"read_output"},{flag:"--output-budget",value_name:"tokens",extension_command_availability:"read_output"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state",extension_command_availability:"read_output"},{flag:"--output-cursor",value_name:"cursor",extension_command_availability:"read_output"},{flag:"--output-row-contract",extension_command_availability:"read_output"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"],discovery_value_name:"path"},{flag:"--no-extensions",extension_command_availability:"never"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"},{flag:"--expect-hash",value_name:"revision"}]),Pr=new Set(Ug.flatMap(e=>[e.flag,...e.aliases??[]]));(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="81054684-60df-57c9-af9d-0996874c1024")}catch{}})();var Sd=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function $i(e){if(typeof e!="string")return null;let t=Sd.exec(e.trim());if(!t)return null;let n=t[2];return{name:t[1],valueName:n?n.slice(1,-1):null,optional:n?.startsWith("[")??!1}}function sR(e){let t=$i(e);return t?t.name:typeof e=="string"&&e.trim()||null}function zg(e){if(typeof e!="string")return null;let t=e.trim(),n=t.split(/[ =]/,1)[0];return Pr.has(n)||Pr.has(`--${n.slice(2).replaceAll("_","-")}`)?"host_owned_flag_collision":Sd.test(t)?null:"malformed_long_flag"}function kd(e,t){let n=[e,t].find(i=>typeof i=="string"&&Pr.has(i.trim().split(/[ =]/,1)[0]));if(typeof n=="string")return{token:n.trim().split(/[ =]/,1)[0],failure:"host_owned_flag_collision"};if(typeof e!="string")return null;let r=e.trim(),o=zg(r);return o===null?null:{token:r,failure:o}}function Ad(e,t){return t==="host_owned_flag_collision"?`cannot shadow host-owned global flag "${e}"; read it from context.global instead`:`long flag "${e}" must start with a double-dash name such as "--my-flag" or "--my-flag <value>"`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a797572f-fbc6-5e62-a9b5-5a0bd6ef22b4")}catch{}})();function Hg(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function cR(e){return Hg(e)??void 0}function dR(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t-=1;return t===e.length?e:e.slice(0,t)}function lR(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function Td(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function $r(e){let t=typeof e=="number"?e:typeof e=="string"&&e.trim().length>0?Number(e.trim()):Number.NaN;return Number.isFinite(t)?t:null}function uR(e){let t=$r(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function fR(e,t,n){let r=$r(e);return r===null||r<t||r>n?null:r}function mR(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function Ae(e){return typeof e!="object"||e===null?null:e}function Id(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function Cd(e){let t=Id(e);if(!t)return null;if(typeof t.activate=="function")return t;let n=Id(t.default);return typeof n?.activate=="function"?n:null}function pR(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e}:{}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="92573990-a040-526d-a0b1-b91d2ef401f1")}catch{}})();function Mr(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import Vg from"node:crypto";import{AsyncLocalStorage as qg}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ced47074-06d3-53b9-af75-63586cbd4f6a")}catch{}})();var Mi=new qg,Rd=1024;function Bg(e){let t=Date.parse(e.clock);if(!Number.isFinite(t))throw new Error(`Invalid reproducible workspace clock: ${e.clock}`);if(!Number.isSafeInteger(e.tickMs)||e.tickMs<0)throw new Error("Reproducible workspace tickMs must be a non-negative integer");if(e.seed.trim().length===0)throw new Error("Reproducible workspace seed must not be empty");return{...e,clock:new Date(t).toISOString()}}function Wg(e){let t={...Bg(e),clockReads:0,tokenReads:0};return n=>Mi.run(t,n)}async function bR(e,t){return Wg(e)(t)}function xd(){let e=Mi.getStore();if(e===void 0)return;let t=new Date(Date.parse(e.clock)+e.clockReads*e.tickMs).toISOString();return e.clockReads+=1,t}function wR(e){let t=Mi.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>Rd)throw new Error(`Reproducible token length must be an integer between 0 and ${Rd}`);let n="";for(;n.length<e;){let r=Vg.createHash("sha256").update(`${t.seed}\0${t.tokenReads}`).digest();t.tokenReads+=1;for(let o of r)if(n+=(o%36).toString(36),n.length===e)break}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0bf155fc-c690-5318-ba1e-275f1787858b")}catch{}})();var Gg=/^([+-]?)(\d+)([hdwm])$/i,Kg=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,Yg=/^(\d{4})(\d{2})(\d{2})$/,Xg=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Jg=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Qg=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Zg=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function hn(){return xd()??new Date().toISOString()}function ye(e){return Number.isFinite(Date.parse(e))}function bn(e){let t=Zg.exec(e);if(!t||!Number.isFinite(Date.parse(e)))return!1;let[,n,r,o,i,s,a,c,d]=t,[l,u,f,m,p,_]=[n,r,o,i,s,a].map(Number);return u>=1&&u<=12&&f>=1&&f<=Fi(l,u-1)&&m<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function Dt(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return bn(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var eh=1e4,jr=new Map;function Nd(e){let t=jr.get(e);if(t!==void 0)return t;let n=Date.parse(e);return jr.size>=eh&&Mr(jr),jr.set(e,n),n}function G(e,t){let n=Nd(e),r=Nd(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function AR(e,t){return!(t.deadlineBefore&&(!e.deadline||G(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||G(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&G(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&G(e.updated_at,t.updatedBefore)>0||t.createdAfter&&G(e.created_at,t.createdAfter)<0||t.createdBefore&&G(e.created_at,t.createdBefore)>0)}function ji(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function Li(e){if(!e)return"";if(e.toUpperCase()==="Z")return"Z";let t=/^([+-]\d{2})(\d{2})$/.exec(e);return t?`${t[1]}:${t[2]}`:e}function th(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function nh(e){let t=[],n=d=>th(t,e,d),r=Yg.exec(e);if(r){let[,d,l,u]=r;n(`${d}-${l}-${u}`)}let o=Xg.exec(e);if(o){let[,d,l,u,f,m,p,_,y]=o,b=p?`:${p}`:"";n(`${d}-${l}-${u}T${f}:${m}${b}${ji(_)}${Li(y)}`)}let i=Jg.exec(e);if(i){let[,d,l,u,f,m,p]=i,_=f?`:${f}`:"";n(`${d}T${l}:${u}${_}${ji(m)}${Li(p)}`)}let s=Qg.exec(e);if(s){let[,d,l,u,f,m,p]=s,_=f?`:${f}`:"";n(`${d}T${l}:${u}${_}${ji(m)}${Li(p)}`)}let a=10,c=e.slice(0,a);if(oh(c)){let d=a;for(;d<e.length&&ih(e[d]);)d+=1;d<e.length&&n(`${c}T${e.slice(d)}`)}return t}function rh(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of nh(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function oh(e){if(e.length!==10)return!1;for(let t=0;t<e.length;t+=1){let n=e[t];if(t===4||t===7){if(n!=="-")return!1;continue}let r=n.charCodeAt(0);if(r<48||r>57)return!1}return!0}function ih(e){return e?e===" "||e===" "||e===`
2
+ `||e==="\r"||e==="\f"||e==="\v":!1}function Fi(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var sh=["January","February","March","April","May","June","July","August","September","October","November","December"],ah=/^(\d{4})-(\d{2})-(\d{2})/,ch=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function dh(e,t,n){let r=ah.exec(t)??ch.exec(t);if(!r)return;let o=Number.parseInt(r[1],10),i=Number.parseInt(r[2],10),s=Number.parseInt(r[3],10),a=n?.trim()||"deadline";if(i<1||i>12)throw new h(`Invalid ${a} value "${e}". Month "${r[2]}" is out of range \u2014 use a month between 01 and 12.`,g.USAGE,{field:a,value:e});let c=Fi(o,i-1);if(s<1||s>c)throw new h(`Invalid ${a} value "${e}". ${sh[i-1]} ${o} has ${c} days, so day "${r[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,g.USAGE,{field:a,value:e})}function lh(e,t){let n=new Date(e.getTime()),r=n.getUTCDate(),o=n.getUTCMonth()+t,i=n.getUTCFullYear()+Math.floor(o/12),s=(o%12+12)%12,a=Math.min(r,Fi(i,s));return n.setUTCFullYear(i,s,a),n}function IR(e,t=new Date,n="deadline"){let r=e.trim();if(r.toLowerCase()==="now")return t.toISOString();let o=Gg.exec(r);if(o){let s=o[1]==="-"?-1:1,a=Number.parseInt(o[2],10)*s,c=o[3].toLowerCase();if(c==="m")return lh(t,a).toISOString();let d=c==="h"?3600*1e3:c==="d"?1440*60*1e3:10080*60*1e3;return new Date(t.getTime()+a*d).toISOString()}dh(e,r,n);let i=rh(r);if(!Number.isFinite(i)){let s=n.trim().length>0?n.trim():"deadline",a=Kg.test(r)?"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.":'Use ISO/date string input, "now", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';throw new h(`Invalid ${s} value "${e}". ${a}`,g.USAGE,{field:s,value:e})}return new Date(i).toISOString()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5c3049c3-1d5a-5e7e-a070-35340737a6ab")}catch{}})();var Dd=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function Lr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.hasOwn(Dd,t)?Dd[t]:null}function uh(e,t,n){return!!(e.value_name?.trim()||t||n||e.required===!0||e.list===!0||e.repeatable===!0)}function fh(e){return(e.value_type?.trim()||e.type?.trim())?.toLowerCase()}function RR(e){let t=fh(e),n=Lr(t),r=$i(e.long),o=e.value_name?.trim()||null,i=!(n==="boolean"&&t!=="bool")&&uh(e,r?.valueName,t),s=r?.valueName?r.optional:t==="bool";return{value_type:n,value_arity:i?s?"optional":"required":"none",value_name:i?o??r?.valueName??"value":null}}function Pd(e){let t=[],n=r=>{if(Array.isArray(r)){for(let o of r)n(o);return}if(typeof r=="string"){for(let o of r.split(",")){let i=o.trim();i.length>0&&t.push(i)}return}r!=null&&t.push(r)};return n(e),t}function $d(e,t){return t==="string"?!0:t==="number"?typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim().length>0&&Number.isFinite(Number(e)):typeof e=="boolean"?!0:typeof e=="string"&&["true","false","1","0"].includes(e.trim().toLowerCase())}function xR(e,t){return t==="number"?typeof e=="number"&&Number.isFinite(e)?null:{kind:t,received:e,expected:"a finite number"}:typeof e=="boolean"?null:{kind:t,received:e,expected:"true, false, 1, or 0"}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="628615ea-5be3-5753-a6c5-3eba8400a8da")}catch{}})();function Fr(e,t,n){if(e===t)return 0;if(Math.abs(e.length-t.length)>n)return null;let r=t.length+1,o=new Array(r),i=new Array(r),s=new Array(r);for(let c=0;c<r;c+=1)o[c]=0,i[c]=c;for(let c=1;c<=e.length;c+=1){s[0]=c;let d=s[0];for(let l=1;l<=t.length;l+=1){let u=e[c-1]===t[l-1]?0:1,f=i[l-1]+u,m=s[l-1]+1,p=i[l]+1,_=Math.min(f,m,p);c>1&&l>1&&e[c-1]===t[l-2]&&e[c-2]===t[l-1]&&(_=Math.min(_,o[l-2]+1)),s[l]=_,_<d&&(d=_)}if(d>n)return null;for(let l=0;l<r;l+=1)o[l]=i[l],i[l]=s[l]}let a=i[t.length];return a<=n?a:null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7e894d1f-fe1a-53f2-9a29-4e9846a9f986")}catch{}})();var Md=["append","cancel","claim","close","comment_add","comment_edit","comment_delete","create","delete","docs_add","docs_remove","files_add","files_remove","files_discover","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","import","improvement_observe","learning_add","learning_edit","learning_delete","normalize","note_add","note_edit","note_delete","plan_create_metadata","plan_create_initial_step","plan_add_step","plan_reorder_step","plan_remove_step","plan_link_step","plan_unlink_step","plan_append_decision","plan_append_discovery","plan_append_validation","plan_resume","plan_approve","plan_materialize","plan_update_step","plan_complete_step","plan_block_step","policy_approve","policy_refused","release","reopen","restore","schema_migration","schema_migration_reference","test_run_track","tests_add","tests_remove","tests_update","update","update_audit","update_ownership_bypass","workspace_snapshot_restore","extension_migrations_apply","merge_reconcile"],jd=["history:author-acknowledge","settings:write","init:type_preset","templates:save","profile:apply-types","profile:apply-statuses","profile:apply-fields","profile:apply-config","schema:add-type","schema:remove-type","schema:add-status","schema:remove-status","schema:add-field","schema:remove-field","schema:apply-preset","schema:infer-types","schema:policy-put","schema:policy-remove","schema:policy-mode","assurance:bundle:apply","assurance:gate:verdict","telemetry:install_id","telemetry:first_run_prompt","telemetry:clear","item_format:auto_select_default","transaction_abandon"],Ui={"init:type-preset":"init:type_preset"},Ld=["^config:(?:set|unset):[a-z][a-z0-9_.:-]*$","^assurance:(?:measurement|invariant|gate):(?:put|remove)$","^schema_(?:rename_type|rename_status|remap_status|rename_field|remove_type|remove_status|remove_field)(?:_compensate)?$","^extension:[a-z][a-z0-9_-]*:[a-z][a-z0-9_]*$"],PR={version:1,item:Md,workspace:jd,aliases:Ui,patterns:Ld,read_policy:"preserve_original_operation",custom_operation_grammar:"extension:<package_name>:<snake_case_operation>",legacy_custom_operation_grammar:"lowercase segments separated by underscore, hyphen, colon, or dot; optional opaque colon-suffixed retry key",excluded_surfaces:["json_patch","on_write_hook","telemetry_span"]},mh=new Set([...Md,...jd]),ph=Ld.map(e=>new RegExp(e,"u"));function Fd(e){return Object.hasOwn(Ui,e)?Ui[e]:e}function $R(e){let t=Fd(e);if(mh.has(t)||ph.some(n=>n.test(t)))return t;throw new TypeError("Undeclared history operation; use a native contract identity or extension:<package_name>:<snake_case_operation>.")}function Ud(e){let t=Fd(e),n=t.indexOf(":"),r=n<0?t:t.slice(0,n),o=n<0||n<t.length-1&&!/[\s\p{C}]/u.test(t.slice(n+1));if(/^[a-z][a-z0-9]*(?:[_.-][a-z0-9]+)*$/u.test(r)&&o)return t;throw new TypeError("History operation must use lowercase alphanumeric segments with an optional non-whitespace colon-suffixed retry key.")}import{createHash as _h}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ca5b60a5-80a7-5e7d-917f-4c7649bcbab6")}catch{}})();var LR=["sha256","sha512"],yh="sha256",zd="sha256";function Xe(e){if(e===void 0)return yh;if(e==="sha256"||e==="sha512")return e;throw new TypeError(`unsupported_history_hash_algorithm:${String(e)}`)}function Ie(e,t){return _h(Xe(t)).update(e,"utf8").digest("hex")}import Vd from"node:path";import{link as gh,mkdir as hh,mkdtemp as bh,rm as wh,writeFile as vh}from"node:fs/promises";import zi from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71c2fed9-81e1-5723-8e34-e6327c07a130")}catch{}})();async function Hd(e,t){let n=zi.dirname(e);await hh(n,{recursive:!0});let r=await bh(zi.join(n,".pm-seed-")),o=zi.join(r,"value");try{await vh(o,t,"utf8");try{return await gh(o,e),!0}catch(i){if(i.code==="EEXIST")return!1;throw i}}finally{await wh(r,{recursive:!0,force:!0})}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2075887b-6d4b-582f-9da2-bab13198f9a5")}catch{}})();var Eh=2e3,Ur=new Map;function Te(e){if(typeof e!="string")return"";let t=Ur.get(e);if(t!==void 0)return t;let n=e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return Ur.size>=Eh&&Mr(Ur),Ur.set(e,n),n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6e07b1b6-1757-54dd-8833-9d3f984ccf79")}catch{}})();var de=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),Wd=Uc,Vi=Fc,Oh=["create","update"],Sh=new Set(Jc),kh=new Set(kr),Ah=new Set(Qc),Ih=new Set(Zc),Th=new Set(["string","number","boolean","array","object"]),Ch=16;function Gd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Rh=[e=>e.type===void 0||typeof e.type=="string"&&Th.has(e.type),e=>!Object.hasOwn(e,"const")||Hr(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>Hr(t)),e=>e.min_length===void 0||Number.isInteger(e.min_length)&&e.min_length>=0,e=>e.min_items===void 0||Number.isInteger(e.min_items)&&e.min_items>=0,e=>e.format===void 0||e.format==="date-time",e=>e.required===void 0||Array.isArray(e.required)&&e.required.every(t=>typeof t=="string"&&t.length>0),e=>e.additional_properties===void 0||typeof e.additional_properties=="boolean",e=>e.properties===void 0||Gd(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function Hr(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return!0;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e))return!1;t.add(e);let n=Array.isArray(e)?e.every(r=>Hr(r,t)):Object.values(e).every(r=>Hr(r,t));return t.delete(e),n}function zr(e,t=0,n=new Set){if(!Gd(e)||t>Ch||n.has(e))return;n.add(e);let r=e,o=r.type,i=r.enum,s=r.one_of,a=r.properties,c=r.items,d=r.required,l=r.min_length,u=r.min_items,f=r.format,m=r.additional_properties;if(!Rh.every(b=>b(r))){n.delete(e);return}let p=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([b,E])=>[b,zr(E,t+1,n)])),_=c===void 0?void 0:zr(c,t+1,n),y=s===void 0?void 0:s.map(b=>zr(b,t+1,n));if([...Object.values(p??{}),...c===void 0?[]:[_],...y??[]].some(b=>b===void 0)){n.delete(e);return}return n.delete(e),Object.fromEntries(Object.entries({type:o,const:Object.hasOwn(r,"const")?r.const:void 0,enum:i,min_length:l,min_items:u,format:f,properties:p,required:d===void 0?void 0:[...new Set(d)],additional_properties:m,items:_,one_of:y}).filter(([,b])=>b!==void 0))}function vn(e){let t=Array.isArray(e)?e:[];return[...new Set(t.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r))}function ee(e){if(typeof e!="string"||e.length===0)return;let t=Te(e);return t.length>0?t:void 0}function xh(e){return e.startsWith("--")?e.slice(2):e}function qd(e){return typeof e=="string"?xh(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function Kd(e){return e.replaceAll("_","-")}function Nh(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(o=>o.length>0).map(o=>o.toLowerCase());if(t.length===0)return e;let[n,...r]=t;return`${n}${r.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function Hi(e,t){let n=ee(e.id);if(!n)return null;let r=[...new Set(vn(e.aliases).map(Te).filter(a=>a.length>0))].sort((a,c)=>a.localeCompare(c)),o=vn(e.roles).filter(a=>Sh.has(a)),i=e.description?.trim(),s=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:t;return{id:n,aliases:r,roles:o,description:i&&i.length>0?i:void 0,order:s}}function Dh(e){return{draft_status:ee(e?.draft_status),open_status:ee(e?.open_status),in_progress_status:ee(e?.in_progress_status),blocked_status:ee(e?.blocked_status),close_status:ee(e?.close_status),canceled_status:ee(e?.canceled_status)}}function Yd(e,t){if(!Array.isArray(t)||t.length!==2)return;let n=Te(t[0]),r=Te(t[1]);n.length===0||r.length===0||e.pairs.some(o=>o[0]===n&&o[1]===r)||e.pairs.push([n,r])}function Ph(e){let t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;let n={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(let r of e.allowed_transitions)Yd(n,r);return{typeKey:t.toLowerCase(),record:n}}function $h(e){if(!Array.isArray(e)||e.length===0)return;let t=new Map;for(let r of e){let o=Ph(r);if(o===null)continue;let i=t.get(o.typeKey)??o.record;i.denyAll||=o.record.denyAll;for(let s of o.record.pairs)Yd(i,s);t.set(o.typeKey,i)}let n=[];for(let r of t.values())(r.pairs.length>0||r.denyAll)&&n.push({type:r.type,allowed_transitions:r.pairs});return n.sort((r,o)=>r.type.localeCompare(o.type)),n.length>0?n:void 0}function Xd(e){let t=Te(e.key??"");if(!t)return null;let n=Te(e.metadata_key??e.front_matter_key??t),r=qd(e.cli_flag??Kd(t));if(!r)return null;let o=vn(e.cli_aliases).map(u=>qd(u)).filter(u=>u.length>0&&u!==r),i=typeof e.type=="string"?e.type.trim().toLowerCase():"string",s=kh.has(i)?i:"string",a=(()=>{let u=vn(e.commands).filter(f=>Ah.has(f));return u.length>0?u:[...Oh]})(),c=e.description?.trim(),d=vn(e.required_types),l=e.value_schema===void 0?void 0:zr(e.value_schema);return e.value_schema!==void 0&&l===void 0?null:{key:t,metadata_key:n,cli_flag:r,cli_aliases:o,description:c&&c.length>0?c:void 0,type:s,commands:a,repeatable:[e.repeatable===!0,s==="string_array"].includes(!0),required:e.required===!0,required_on_create:e.required_on_create===!0,required_types:d,allow_unset:e.allow_unset!==!1,value_schema:l}}function Mh(e){let t=new Map;for(let[r,o]of e.entries()){let i=Hi(o,r);i&&t.set(i.id,i)}let n=Bd([...t.values()]);return n.length>0?n:Bd(Vi.map((r,o)=>Hi(r,o)).filter(r=>r!==null))}function Bd(e){return e.sort((t,n)=>t.order===n.order?t.id.localeCompare(n.id):t.order-n.order)}function jh(e){let t=new Map;for(let n of e??[]){let r=Xd(n);r&&t.set(r.key,r)}return[...t.values()].sort((n,r)=>n.key.localeCompare(r.key))}function Lh(e){return{id:e.id,aliases:e.aliases.length>0?[...e.aliases]:void 0,roles:e.roles.length>0?[...e.roles]:void 0,description:e.description,order:e.order}}function Fh(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==Kd(e.key)?e.cli_flag:void 0,cli_aliases:e.cli_aliases.length>0?[...e.cli_aliases]:void 0,description:e.description,type:e.type,commands:[...e.commands],repeatable:e.repeatable===!0?!0:void 0,required:e.required===!0?!0:void 0,required_on_create:e.required_on_create===!0?!0:void 0,required_types:e.required_types.length>0?[...e.required_types]:void 0,allow_unset:e.allow_unset===!1?!1:void 0,value_schema:e.value_schema}}function Uh(e){let t=typeof e=="string"?e.trim().toLowerCase():"allow";return Ih.has(t)?t:"allow"}function En(e){let t={...de,...e?.files},n=e?.statuses&&e.statuses.length>0?e.statuses:Vi,r=Mh(n),o=jh(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:r.map(Lh),fields:o.map(Fh),workflow:{...Wd,...Dh(e?.workflow)},type_workflows:$h(e?.type_workflows),unknown_field_policy:Uh(e?.unknown_field_policy)}}function zh(e,t,n){try{return JSON.parse(e)}catch{n.push(t);return}}function Hh(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let n=t.item_types;if(Array.isArray(n.definitions))return n.definitions}}function Vh(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function qh(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function Bh(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;return typeof t.workflow=="object"&&t.workflow!==null&&!Array.isArray(t.workflow)?t.workflow:typeof t.workflows=="object"&&t.workflows!==null&&!Array.isArray(t.workflows)?t.workflows:t}function Wh(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;if(Array.isArray(t.type_workflows))return t.type_workflows}function ge(e,t,n){let r=t?.trim()||n;return Vd.isAbsolute(r)?r:Vd.join(e,r)}function JR(e,t){return ge(e,t.files.types,de.types)}async function QR(e,t){let n=En(t),r=[{path:ge(e,n.files.types,de.types),seed:{definitions:[]}},{path:ge(e,n.files.statuses,de.statuses),seed:{statuses:Vi}},{path:ge(e,n.files.fields,de.fields),seed:{fields:[]}},{path:ge(e,n.files.workflows,de.workflows),seed:{workflow:Wd}}],o=[];for(let i of r)await un(i.path)||await Hd(i.path,`${JSON.stringify(i.seed,null,2)}
3
+ `)&&o.push(i.path);return{created_paths:o}}async function ZR(e,t){let n=En(t),r=[],o=ge(e,n.files.types,de.types),i=ge(e,n.files.statuses,de.statuses),s=ge(e,n.files.fields,de.fields),a=ge(e,n.files.workflows,de.workflows),c,d,l,u,f,m=async(E,M)=>{let X=await zc(E);if(X!==null)return zh(X,M,r)},p=await m(o,"runtime_schema_types_invalid_json");p!==void 0&&(c=Hh(p),c===void 0&&r.push("runtime_schema_types_invalid_shape"));let _=await m(i,"runtime_schema_statuses_invalid_json");_!==void 0&&(d=Vh(_),d===void 0&&r.push("runtime_schema_statuses_invalid_shape"));let y=await m(s,"runtime_schema_fields_invalid_json");y!==void 0&&(l=qh(y),l===void 0&&r.push("runtime_schema_fields_invalid_shape"));let b=await m(a,"runtime_schema_workflows_invalid_json");return b!==void 0&&(u=Bh(b),u===void 0&&r.push("runtime_schema_workflows_invalid_shape"),f=Wh(b)),{schema:En({...n,statuses:[...n.statuses,...d??[]],fields:[...n.fields,...l??[]],workflow:{...n.workflow,...u},type_workflows:[...n.type_workflows??[],...f??[]]}),type_definitions_from_file:c,warnings:r,created_paths:[]}}function wn(e,t,n,r=!1){let o=n.map(s=>ee(s)).filter(s=>typeof s=="string").find(s=>e.some(a=>a.id===s));if(r&&o!==void 0)return o;let i=e.find(s=>s.roles.includes(t));return i!==void 0?i.id:o??e[0]?.id}function Gh(e){let t=new Map,n=new Map;for(let r of e){n.set(r.id,r),t.set(r.id,r.id),t.set(r.id.replaceAll("_","-"),r.id),t.set(r.id.replaceAll("_"," "),r.id);for(let o of r.aliases)t.set(o,r.id),t.set(o.replaceAll("_","-"),r.id),t.set(o.replaceAll("_"," "),r.id)}return{aliasToId:t,byId:n}}function Kh(e){let t={activeStatuses:new Set,blockedStatuses:new Set,draftStatuses:new Set,terminalCanceledStatuses:new Set,terminalDoneStatuses:new Set,terminalStatuses:new Set};for(let n of e){let r=new Set(n.roles);(r.has("terminal")||r.has("terminal_done")||r.has("terminal_canceled"))&&t.terminalStatuses.add(n.id),r.has("terminal_done")&&t.terminalDoneStatuses.add(n.id),r.has("terminal_canceled")&&t.terminalCanceledStatuses.add(n.id),r.has("active")&&t.activeStatuses.add(n.id),r.has("blocked")&&t.blockedStatuses.add(n.id),r.has("draft")&&t.draftStatuses.add(n.id)}return t}function Jd(e){let t=En(e),n=t.statuses.map((b,E)=>Hi(b,E)).filter(b=>b!==null),{aliasToId:r,byId:o}=Gh(n),{activeStatuses:i,blockedStatuses:s,draftStatuses:a,terminalCanceledStatuses:c,terminalDoneStatuses:d,terminalStatuses:l}=Kh(n),u=t.workflow,f=ee(u.open_status)??wn(n,"default_open",["open","in_progress",Rt[0]]),m=ee(u.in_progress_status)??wn(n,"active",["in_progress","in-progress",f],!0),p=ee(u.blocked_status)??wn(n,"blocked",["blocked"]),_=ee(u.close_status)??wn(n,"default_close",["closed","done","complete"]),y=ee(u.canceled_status)??wn(n,"default_cancel",["canceled","cancelled"]);return{definitions:n,by_id:o,alias_to_id:r,terminal_statuses:l,terminal_done_statuses:d,terminal_canceled_statuses:c,active_statuses:i,blocked_statuses:s,draft_statuses:a,open_status:f,in_progress_status:m,blocked_status:p,close_status:_,canceled_status:y}}function qi(e,t){let n=Te(e);if(n)return t.alias_to_id.get(n)}function Qd(e){let t=En(e),n=new Map,r=t.fields.map(c=>Xd(c)).filter(c=>c!==null);for(let c of r)n.set(c.key,c);let o=[...n.values()].sort((c,d)=>c.key.localeCompare(d.key)),i=new Map,s=new Map,a=new Map;for(let c of o){i.set(c.key,c),s.set(c.cli_flag,c);for(let d of c.cli_aliases)s.set(d,c);for(let d of c.commands){let l=a.get(d)??[];l.push(c),a.set(d,l)}}for(let[c,d]of a.entries())d.sort((l,u)=>l.key.localeCompare(u.key)),a.set(c,d);return{definitions:o,by_key:i,by_cli_token:s,command_to_fields:a}}function Zd(e){return Nh(e.key)}function ex(e,t){let n=qi(e,t);return n?t.terminal_statuses.has(n):!1}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9b51a9f9-e57f-5998-837e-c6c442ca1c9b")}catch{}})();var Yh=16;function Vr(e){let t=e.trim().replaceAll(/[^A-Za-z0-9]+/g," ").split(/\s+/).filter(o=>o.length>0).map(o=>o.toLowerCase());if(t.length===0)return e;let[n,...r]=t;return`${n}${r.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function cx(e,t,n=new Set,r){if(rl(e,t,r))return;let o=ol(e,t,n,r),i=qr(e);return[Vr(e.cli_flag),...i].find(s=>!o.has(s)&&nl(s,i,o))}function nl(e,t,n){for(let r of t){if(r===e)break;if(n.has(r))return!1}return!0}function rl(e,t,n){return t.definitions.some(r=>r!==e&&r.metadata_key===e.metadata_key&&(n===void 0||r.commands.includes(n)))}function ol(e,t,n,r){return new Set([...n,...t.definitions.filter(o=>o!==e&&(r===void 0||o.commands.includes(r))).flatMap(o=>qr(o))])}function il(e){return e.replace(/^-+/u,"").startsWith("no-")}function Xh(e){return e.startsWith("-")?e:`--${e}`}function dx(e,t,n,r){if(rl(e,t,r))return;let o=ol(e,t,n.options,r),i=qr(e);return[e.cli_flag,...e.cli_aliases].find(s=>{let a=sl(s);return il(s)||n.flags.has(Xh(s))||o.has(a)?!1:nl(a,i,o)})}function sl(e){return e.replace(/^-+/u,"").replace(/^no-/u,"").split("-").reduce((t,n)=>`${t}${n.charAt(0).toUpperCase()}${n.slice(1)}`)}function qr(e){return[...new Set([Zd(e),Vr(e.key),Vr(e.cli_flag),...e.cli_aliases.map(t=>Vr(t)),...[e.cli_flag,...e.cli_aliases].filter(t=>!il(t)).map(t=>sl(t))])]}function al(e,t){for(let n of qr(t)){if(!Object.hasOwn(e,n))continue;let r=e[n];if(r!==void 0)return r}}function cl(e){return Array.isArray(e)?e.flatMap(t=>cl(t)).map(t=>t.trim()).filter(t=>t.length>0):typeof e=="string"?e.split(/[,\n|]/).map(t=>t.trim()).filter(t=>t.length>0):e==null?[]:[String(e).trim()].filter(t=>t.length>0)}function el(e,t){if(typeof e=="boolean")return e;if(typeof e=="number"){if(e===1)return!0;if(e===0)return!1}if(typeof e=="string"){let n=e.trim().toLowerCase();if(n==="true"||n==="1"||n==="yes")return!0;if(n==="false"||n==="0"||n==="no")return!1}throw new h(`${t} must be one of true|false|1|0|yes|no`,g.USAGE)}function tl(e,t){if(typeof e=="number"&&Number.isFinite(e))return e;let n=typeof e=="string"?e.trim():String(e),r=Number(n);if(!Number.isFinite(r))throw new h(`${t} must be a number`,g.USAGE);return r}function Jh(e,t,n){let r=typeof e=="string"?(()=>{try{return JSON.parse(e)}catch{return}})():e;if(n==="array"&&Array.isArray(r)||n==="object"&&typeof r=="object"&&r!==null&&!Array.isArray(r))return r;throw new h(`${t} must be valid JSON ${n}`,g.USAGE)}function Qh(e,t){return t===void 0?!0:t==="array"?Array.isArray(e):t==="object"?typeof e=="object"&&e!==null&&!Array.isArray(e):typeof e===t}function Zh(e,t,n){if(t.const!==void 0&&C(e)!==C(t.const))return`${n} must equal ${C(t.const)}`;if(t.enum!==void 0&&!t.enum.some(r=>C(r)===C(e)))return`${n} must be one of ${t.enum.map(r=>C(r)).join("|")}`;if(!Qh(e,t.type))return`${n} must match configured type ${String(t.type)}`;if(typeof e=="string"){if(t.min_length!==void 0&&e.length<t.min_length)return`${n} must contain at least ${t.min_length} characters`;if(t.format==="date-time"&&!bn(e))return`${n} must be an RFC 3339 date-time`}}function eb(e,t,n,r){if(Array.isArray(e)){if(t.min_items!==void 0&&e.length<t.min_items)return`${n} must contain at least ${t.min_items} items`;if(t.items)for(let[o,i]of e.entries()){let s=Br(i,t.items,`${n}[${o}]`,r+1);if(s)return s}}}function tb(e,t,n,r){if(typeof e!="object"||e===null||Array.isArray(e))return;let o=e;for(let i of t.required??[])if(!Object.hasOwn(o,i))return`${n}.${i} is required`;for(let[i,s]of Object.entries(o)){let a=t.properties?.[i];if(!a){if(t.additional_properties===!1)return`${n}.${i} is not allowed`;continue}let c=Br(s,a,`${n}.${i}`,r+1);if(c)return c}}function Br(e,t,n,r=0){if(r>Yh)return`${n} value schema exceeds maximum depth`;let o=Zh(e,t,n);if(o)return o;let i=eb(e,t,n,r);if(i)return i;let s=tb(e,t,n,r);if(s)return s;if(!t.one_of)return;let a=0;for(let c of t.one_of)if(Br(e,c,n,r+1)===void 0&&(a+=1,a>1))break;return a===1?void 0:`${n} must match exactly one configured schema variant`}function Je(e,t,n){if(!e.value_schema||t===void 0)return t;let r=Br(t,e.value_schema,n);if(r)throw new h(r,g.USAGE);return t}function nb(e,t,n,r){let o=r==="option"&&Array.isArray(t)?t[t.length-1]:t;if(o!==void 0)return Je(e,Jh(o,n,e.type),n)}function On(e,t,n,r="option"){let o=n??`--${e.cli_flag}`;if(e.type==="array"||e.type==="object")return nb(e,t,o,r);if(e.repeatable||e.type==="string_array"){let s=cl(t);return e.type==="number"?Je(e,s.map(a=>tl(a,o)),o):e.type==="boolean"?Je(e,s.map(a=>el(a,o)),o):Je(e,s,o)}let i=Array.isArray(t)?t[t.length-1]:t;if(i!==void 0)return e.type==="number"?Je(e,tl(i,o),o):e.type==="boolean"?Je(e,el(i,o),o):Je(e,typeof i=="string"?i:String(i),o)}function rb(e,t){return!e.required&&!e.required_on_create?!1:e.required_types.length===0?!0:t?e.required_types.map(n=>n.toLowerCase()).includes(t.trim().toLowerCase()):!1}function lx(e,t,n){let r={},o=[];for(let i of t.command_to_fields.get("create")??[]){let s=al(e,i);if(s===void 0){rb(i,n)&&o.push(`--${i.cli_flag}`);continue}r[i.metadata_key]=On(i,s)}return{values:r,missing_required_flags:[...new Set(o)].sort((i,s)=>i.localeCompare(s))}}function ux(e,t,n=["update"]){let r={},o=(n??["update"]).flatMap(s=>t.command_to_fields.get(s)??[]),i=new Set;for(let s of o){let a=al(e,s);a!==void 0&&(i.has(s.metadata_key)||(i.add(s.metadata_key),r[s.metadata_key]=On(s,a)))}return bd(r),r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ec8ac553-25db-5fb1-bf2f-555815d7b283")}catch{}})();var Bi=1,Wi=4;function mx(e){let t=e.tests??[],n=t.some(o=>o.phase==="setup")?3:t.some(o=>o.updated_by!==void 0||o.updated_at!==void 0)?2:1,r=(e.deferred_fields?.length??0)>0?4:1;return Math.max(Gi(e),n,r)}function Gi(e){let t=e.pm_format_version;return typeof t=="number"&&Number.isInteger(t)&&t>=1?t:1}function dl(e){if(!(typeof e!="number"||!Number.isInteger(e)||e<=1))return e}function ob(e,t=4,n=t){return e<n?"outdated":e>t?"ahead":"current"}function px(e,t=4,n=t){let r=[],o=[];for(let i of e){let s=ob(i.version,t,n);s==="outdated"?r.push(i.ref):s==="ahead"&&o.push(i.ref)}return{outdated:r.sort((i,s)=>i.localeCompare(s)),ahead:o.sort((i,s)=>i.localeCompare(s))}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="515840b7-cf86-5d71-8ac1-beac7fd7c8a8")}catch{}})();var ib={"in-progress":"in_progress",cancelled:"canceled"};function Wr(e,t){if(t){let o=qi(e,t);if(o)return o}if(typeof e!="string")return;let n=e.trim().toLowerCase();if(!n)return;let r=ib[n]??n;if(Rt.includes(r))return r}function sb(e,t){return Wr(e,t)??e}function hx(e,t){return t.terminal_statuses.has(sb(e,t))}import{encode as mb}from"@toon-format/toon";import{isDeepStrictEqual as ml}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b24a4ce2-c356-56ee-8a34-f48a78507ac4")}catch{}})();var Ki=[{field:"acceptance_criteria",option:"acceptanceCriteria",flag:"--acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","acceptancecriteria","ac"]},{field:"assignee",option:"assignee",flag:"--assignee",aliases:["assignee"]},{field:"deadline",option:"deadline",flag:"--deadline",aliases:["deadline"]},{field:"estimated_minutes",option:"estimatedMinutes",flag:"--estimate",aliases:["estimated_minutes","estimated-minutes","estimatedminutes","estimate"]}],ll=new Map(Ki.map(e=>[e.field,e])),ab=new Map(Ki.flatMap(e=>e.aliases.map(t=>[t,e])));function wx(e){return ab.get(e.trim().toLowerCase())}function vx(e){return ll.get(e)}function cb(e,t){let n=e[t];return typeof n=="string"?n.trim().length>0:typeof n=="number"?Number.isFinite(n):n!=null}function db(e){return(e.deferred_fields??[]).filter(t=>!cb(e,t.field))}function Ex(e){let t=e.deferred_fields;if(t===void 0||t.length===0)return!1;let n=db(e);return n.length===t.length?!1:(n.length===0?delete e.deferred_fields:e.deferred_fields=n,!0)}function ul(e){if(e===void 0)return;if(!Array.isArray(e))return"deferred_fields must be an array";let t=new Set;for(let[n,r]of e.entries()){if(typeof r!="object"||r===null||Array.isArray(r))return`deferred_fields[${n}] must be an object`;let{field:o,reason:i}=r;if(typeof o!="string"||!ll.has(o))return`deferred_fields[${n}].field must be one of ${Ki.map(s=>s.field).join(", ")}`;if(typeof i!="string"||i.trim().length===0)return`deferred_fields[${n}].reason must be a non-empty string`;if(t.has(o))return`deferred_fields lists ${o} more than once`;t.add(o)}}function fl(e){if(!(e===void 0||e.length===0))return e.map(t=>({field:t.field,reason:t.reason.trim()})).sort((t,n)=>t.field.localeCompare(n.field))}import{decode as lb}from"@toon-format/toon";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="aaa2be03-9478-5fbe-82e6-e4fc86e3735b")}catch{}})();function Yi(e){return{value:lb(e),usedScalarBracketEscape:!1}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="79626299-17a8-573a-9b66-ce37c65e2f5d")}catch{}})();var ub=/^\s*(<<<<<<<|=======|>>>>>>>)(?:\s.*)?$/;function fb(e){if(e.length===0)return[];let t=e.split(/\r?\n/),n=[];for(let r=0;r<t.length;r+=1){let o=t[r]??"",i=o.match(ub);if(!i)continue;let s=i[1];n.push({line:r+1,marker:s,text:o})}return n}function Gr(e){return fb(e)[0]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5eaa8bf7-ef0a-51a2-a206-274e9d4c5f82")}catch{}})();var Zi=new Set(["schema","tracker","auto","none"]),hl=new Set(["source","isolated","snapshot"]),pb=new Set(["legacy","local_mutation","local_source_ref","acknowledged","invalid_provenance","foreign_source_ref"]),_b=new Set(["passed","failed","stopped","canceled"]),yb=new Set(ed);function jt(e){return e.replaceAll("\\","/")}function bl(e){for(let t of e)if(t!==0)return t;return 0}function Yr(e){for(let[t,n]of Object.entries(e))n===void 0&&delete e[t]}var wl=["id","title","description","created_at","updated_at"],gb=new Set(Oe);function vl(e){if(e?.schema)return{statusRegistry:Jd(e.schema),fieldRegistry:Qd(e.schema),unknownFieldPolicy:e.schema.unknown_field_policy??"allow",extensionFieldNames:new Set(e.extensionFieldNames??[]),onWarning:e.onWarning}}function hb(e,t){return e.required?e.required_types.length===0?!0:e.required_types.map(n=>n.toLowerCase()).includes(t.trim().toLowerCase()):!1}function Ce(e){let t=e.match(/^([a-z_][\w.]*)\s/u)?.[1];throw new h(`Invalid item metadata: ${e}`,g.GENERIC_FAILURE,{code:"item_document_invalid",reason:e.includes("required")?"missing_required_field":"schema_validation_error",...t?{field:t}:{},required:"Provide an item document whose metadata satisfies the active runtime schema.",why:e})}function An(e,t){throw new h(t,g.GENERIC_FAILURE,{code:"item_document_invalid",reason:"syntax_error",format:e,required:`Provide a syntactically valid ${e==="toon"?"TOON":"JSON Markdown"} item document.`,why:"The document could not be decoded far enough to validate item metadata."})}function El(e,t){if(!t||typeof e!="object"||e===null)return;let n=Gi(e);if(!(n<=Wi))throw new h(`Stored item uses format version ${n}; this runtime supports up to ${Wi}. Upgrade pm before reading or changing this item.`,g.CONFLICT,{code:"item_format_version_unsupported",format_version:n,required:"Upgrade to a pm runtime supporting the stored item format.",nextSteps:["Preserve the original item and history; do not lower pm_format_version to bypass compatibility checks."]})}function Ol(e){let t=new Set(gb);for(let n of e.fieldRegistry?.definitions??[])t.add(n.metadata_key);for(let n of e.extensionFieldNames)t.add(n);return t}function v(e,t){e||Ce(t)}function In(e,t){return(typeof e!="object"||e===null||Array.isArray(e))&&Ce(t),e}function Xi(e,t){let n=e[t];v(typeof n=="string",`${t} must be a string`),v(ye(n),`${t} must be a valid ISO timestamp`)}function pl(e,t,n){let r=e[t];r!==void 0&&v(typeof r=="number"&&Number.isInteger(r)&&r>=1,`${n} must be an integer >= 1`)}function es(e,t,n){let r=e[t];r!==void 0&&(v(typeof r=="string",`${n} must be a string`),v(ye(r),`${n} must be a valid ISO timestamp`))}function bb(e){if(e!==void 0){v(Array.isArray(e),"event.recurrence.by_weekday must be an array");for(let t of e){v(typeof t=="string","event.recurrence.by_weekday entries must be strings");let n=t.trim().toLowerCase();v(pn.includes(n),`event.recurrence.by_weekday entries must be one of: ${pn.join(", ")}`)}}}function wb(e){if(e!==void 0){v(Array.isArray(e),"event.recurrence.by_month_day must be an array");for(let t of e)v(typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=31,"event.recurrence.by_month_day entries must be integers 1..31")}}function vb(e){if(e!==void 0){v(Array.isArray(e),"event.recurrence.exdates must be an array");for(let t of e)v(typeof t=="string","event.recurrence.exdates entries must be strings"),v(ye(t),"event.recurrence.exdates entries must be valid ISO timestamps")}}function Eb(e){let t=In(e,"event.recurrence must be an object");v(typeof t.freq=="string","event.recurrence.freq must be a string");let n=t.freq.trim().toLowerCase();v(Tr.includes(n),`event.recurrence.freq must be one of: ${Tr.join(", ")}`),pl(t,"interval","event.recurrence.interval"),pl(t,"count","event.recurrence.count"),es(t,"until","event.recurrence.until"),bb(t.by_weekday),wb(t.by_month_day),vb(t.exdates)}function Ob(e){for(let r of wl)v(typeof e[r]=="string",`${r} is required and must be a string`);let t=e.type;v(typeof t=="string"&&t.trim().length>0,"type must be a non-empty string");let n=e.pm_format_version;return n!==void 0&&v(typeof n=="number"&&Number.isInteger(n)&&n>=Bi,`pm_format_version must be an integer >= ${Bi}`),t}function Sb(e,t){let n=e.status;v(typeof n=="string"&&n.trim().length>0,"status must be a non-empty string");let r=t?.statusRegistry,o=Wr(n,r),i=r?r.definitions.map(s=>s.id):[...Rt];v(o!==void 0,`status must be one of: ${i.join(", ")}`)}function kb(e){let t=e.priority;v(typeof t=="number"&&Number.isInteger(t)&&[0,1,2,3,4].includes(t),"priority must be an integer 0..4");let n=e.tags;v(Array.isArray(n),"tags must be an array");for(let r of n)v(typeof r=="string","tags entries must be strings")}function Ab(e){let t=e.confidence;if(t!==void 0){if(typeof t=="number"){v(Number.isInteger(t)&&t>=0&&t<=100,"confidence number value must be an integer 0..100");return}if(typeof t=="string"){let n=t.trim().toLowerCase(),r=n==="med"||Ir.includes(n);v(r,`confidence string value must be one of: ${[...Ir,"med"].join(", ")}`);return}v(!1,"confidence must be a number or string")}}function Ib(e){let t=e.severity;if(t===void 0)return;typeof t!="string"&&Ce("severity must be a string");let n=t.trim().toLowerCase(),r=n==="med"||Ar.includes(n);v(r,`severity value must be one of: ${[...Ar,"med"].join(", ")}`)}function Tb(e){e.regression!==void 0&&typeof e.regression!="boolean"&&Ce("regression must be a boolean")}function Cb(e){let t=e.reminders;if(t!==void 0){v(Array.isArray(t),"reminders must be an array");for(let n of t){let r=In(n,"reminders entries must be objects");v(typeof r.at=="string","reminder.at must be a string"),v(ye(r.at),"reminder.at must be a valid ISO timestamp"),v(typeof r.text=="string","reminder.text must be a string"),v(r.text.trim().length>0,"reminder.text must not be empty")}}}function Rb(e){for(let t of["title","description","location","timezone"])e[t]!==void 0&&(v(typeof e[t]=="string",`event.${t} must be a string`),v(e[t].trim().length>0,`event.${t} must not be empty`))}function xb(e){e.recurrence!==void 0&&(Eb(e.recurrence),e.recurrence.until!==void 0&&v(G(e.recurrence.until,e.start_at)>=0,"event.recurrence.until must be at or after event.start_at"))}function Nb(e){let t=In(e,"events entries must be objects");v(typeof t.start_at=="string","event.start_at must be a string"),v(ye(t.start_at),"event.start_at must be a valid ISO timestamp"),t.end_at!==void 0&&(v(typeof t.end_at=="string","event.end_at must be a string"),v(ye(t.end_at),"event.end_at must be a valid ISO timestamp"),v(G(t.end_at,t.start_at)>0,"event.end_at must be after event.start_at")),Rb(t),t.all_day!==void 0&&v(typeof t.all_day=="boolean","event.all_day must be a boolean"),xb(t)}function Db(e){let t=e.events;if(t!==void 0){v(Array.isArray(t),"events must be an array");for(let n of t)Nb(n)}}function Pb(e){for(let t of["source_type","source_owner","design","external_ref"]){let n=e[t];n!==void 0&&v(typeof n=="string",`${t} must be a string`)}}function $b(e){let t=e.type_options;if(t===void 0)return;let n=In(t,"type_options must be an object");for(let[r,o]of Object.entries(n))v(r.trim().length>0,"type_options keys must be non-empty"),v(typeof o=="string","type_options values must be strings"),v(o.trim().length>0,"type_options values must be non-empty strings")}function Mb(e,t,n){if(n?.fieldRegistry)for(let r of n.fieldRegistry.definitions){let o=e[r.metadata_key];if(o===void 0){hb(r,t)&&Ce(`missing required schema field: ${r.metadata_key}`);continue}try{e[r.metadata_key]=On(r,o,`metadata field "${r.metadata_key}"`,"metadata")}catch(i){Ce(String(i?.message).replace(/^Invalid\s+/u,""))}}}function jb(e,t){if(!t||t.unknownFieldPolicy==="allow")return;let n=Ol(t),r=Object.keys(e).filter(o=>!n.has(o)).sort((o,i)=>o.localeCompare(i));r.length!==0&&(t.unknownFieldPolicy==="reject"?Ce(`unknown schema fields are not allowed: ${r.join(", ")}`):t.onWarning?.(`item_unknown_schema_fields:${r.join(",")}`))}function ts(e,t){let n=In(e,"item metadata must be an object"),r=Ob(n);Sb(n,t),kb(n),Ab(n),Ib(n),Tb(n),Xi(n,"created_at"),Xi(n,"updated_at"),n.deadline!==void 0&&Xi(n,"deadline"),Cb(n),Db(n),es(n,"closed_at","closed_at"),es(n,"completed_at","completed_at"),Pb(n),$b(n);let o=ul(n.deferred_fields);v(o===void 0,o??""),Mb(n,r,t),jb(n,t)}function Lb(e){if(!(!e||e.length===0))return[...e].map((t,n)=>(v(t.created_at===void 0||typeof t.created_at=="string"&&bn(t.created_at),`dependencies.${n}.created_at requires a valid timestamp; restore the dependency timestamp from its source record`),{id:t.id.trim(),kind:t.kind,created_at:t.created_at,author:t.author?.trim()||void 0,source_kind:t.source_kind?.trim()||void 0,author_source:t.author_source})).sort((t,n)=>{let r=G(t.created_at??"",n.created_at??"");if(r!==0)return r;let o=t.id.localeCompare(n.id);if(o!==0)return o;let i=t.kind.localeCompare(n.kind);return i!==0?i:(t.source_kind??"").localeCompare(n.source_kind??"")})}var Hx=new Set(["comments","notes","learnings"]),Fb="[unconvertible]";function Pt(e,t){try{return String(e?.[t])}catch{return Fb}}function Ub(e,t){let n=G(Pt(e,"created_at"),Pt(t,"created_at"));if(n!==0)return n;let r=Pt(e,"text").localeCompare(Pt(t,"text"));return r!==0?r:Pt(e,"author").localeCompare(Pt(t,"author"))}function Ji(e){if(!(!e||e.length===0))return[...e].sort(Ub)}function zb(e){if(!e||e.length===0)return;let t=[...e].map(n=>({at:n.at,text:n.text.trim()})).filter(n=>n.text.length>0).sort((n,r)=>{let o=G(n.at,r.at);return o!==0?o:n.text.localeCompare(r.text)});return t.length===0?void 0:t}function Hb(e){if(!e)return;let t=e.freq.trim().toLowerCase();if(!Tr.includes(t))return;let n=Array.from(new Set((e.by_weekday??[]).map(s=>s.trim().toLowerCase()).filter(s=>pn.includes(s)))).sort((s,a)=>vi(s)-vi(a)),r=Array.from(new Set((e.by_month_day??[]).filter(s=>Number.isInteger(s)&&s>=1&&s<=31).map(s=>s))).sort((s,a)=>s-a),o=Array.from(new Set((e.exdates??[]).map(s=>s.trim()).filter(s=>ye(s)))).sort((s,a)=>G(s,a)),i={freq:t,interval:e.interval!==void 0&&e.interval>1?e.interval:void 0,count:e.count,until:e.until?.trim()||void 0,by_weekday:n.length>0?n:void 0,by_month_day:r.length>0?r:void 0,exdates:o.length>0?o:void 0};for(let[s,a]of Object.entries(i))a===void 0&&delete i[s];return i}function Vb(e){return!Array.isArray(e)||e.length===0?void 0:[...e].map(qb).sort(Bb)}function qb(e){let t={start_at:e.start_at,end_at:e.end_at||void 0,title:e.title?.trim()||void 0,description:e.description?.trim()||void 0,location:e.location?.trim()||void 0,all_day:e.all_day,timezone:e.timezone?.trim()||void 0,recurrence:Hb(e.recurrence)};return Yr(t),t}function Bb(e,t){return bl([G(e.start_at,t.start_at),(e.end_at??"").localeCompare(t.end_at??""),(e.title??"").localeCompare(t.title??""),+!!e.all_day-+!!t.all_day,(e.timezone??"").localeCompare(t.timezone??""),(e.location??"").localeCompare(t.location??""),(e.description??"").localeCompare(t.description??""),JSON.stringify(e.recurrence??{}).localeCompare(JSON.stringify(t.recurrence??{}))])}function Wb(e){if(!(!e||e.length===0))return e.map(t=>({path:jt(t.path),scope:t.scope,note:t.note?.trim()||void 0}))}function Gb(e){if(!e||e.length===0)return;let t=e.map(Jb).filter(n=>n.run_id.length>0&&n.started_at.length>0&&n.finished_at.length>0&&n.recorded_at.length>0).sort((n,r)=>bl([G(n.recorded_at,r.recorded_at),n.run_id.localeCompare(r.run_id),n.kind.localeCompare(r.kind)]));return t.length>0?t:void 0}function $t(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0}function Kb(e){return typeof e=="number"&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0}function Qi(e){return typeof e=="string"?e:""}function Yb(e){if(!Array.isArray(e))return;let t=e.filter(r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&r.name.trim().length>0&&typeof r.value=="number"&&Number.isFinite(r.value)&&typeof r.recorded_at=="string"&&r.recorded_at.trim().length>0).map(r=>({name:r.name.trim(),value:r.value,unit:typeof r.unit=="string"&&r.unit.trim()||void 0,threshold:typeof r.threshold=="number"&&Number.isFinite(r.threshold)?r.threshold:void 0,recorded_at:r.recorded_at.trim()})),n=[...new Map(t.map(r=>[r.name,r])).values()].sort((r,o)=>r.name.localeCompare(o.name)).slice(0,32);return n.length>0?n:void 0}function Kr(e,t){return typeof e=="string"&&t.has(e)?e:void 0}function Xb(e){if(!Array.isArray(e))return;let t=e.filter(n=>n&&typeof n.command=="string"&&n.command.trim().length>0).slice(0,32).map(n=>({command:n.command.trim(),requested_pm_context_mode:Kr(n.requested_pm_context_mode,Zi),pm_context_mode:Kr(n.pm_context_mode,Zi),workspace_context_mode:Kr(n.workspace_context_mode,hl),trust_reason:Kr(n.trust_reason,pb)}));return t.length>0?t:void 0}function Jb(e){let t=typeof e.run_id=="string"?e.run_id.trim():"",n=e.kind==="test"||e.kind==="test-all"?e.kind:"test",r=_b.has(e.status)?e.status:"failed",o={run_id:t,kind:n,status:r,started_at:Qi(e.started_at),finished_at:Qi(e.finished_at),recorded_at:Qi(e.recorded_at),attempt:Kb(e.attempt),resumed_from:e.resumed_from?.trim()||void 0,passed:$t(e.passed)??0,failed:$t(e.failed)??0,skipped:$t(e.skipped)??0,items:$t(e.items),linked_tests:$t(e.linked_tests),fail_on_skipped_triggered:e.fail_on_skipped_triggered===!0?!0:void 0,measurements:Yb(e.measurements),executions:Xb(e.executions)};return Yr(o),o}function Qb(e){if(!(!Array.isArray(e)||e.length===0))return e.map(rw)}function Sn(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r));return t.length>0?t:void 0}function is(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ss(e){return e==="__proto__"||e==="constructor"||e==="prototype"}function _l(e){if(!is(e))return;let t=Object.entries(e).map(([n,r])=>[n.trim(),String(r).trim()]).filter(([n,r])=>n.length>0&&!ss(n)&&r.length>0).sort(([n],[r])=>n.localeCompare(r));return t.length>0?Object.fromEntries(t):void 0}function Zb(e){if(!is(e))return;let t=Object.entries(e).map(([n,r])=>[n.trim(),Number(r)]).filter(([n,r])=>n.length>0&&!ss(n)&&Number.isFinite(r)).sort(([n],[r])=>n.localeCompare(r));return t.length>0?Object.fromEntries(t):void 0}function ew(e){let t=e?.trim().toLowerCase();if(!(!t||!Zi.has(t)))return t}function tw(e){let t=e?.trim().toLowerCase();if(!(!t||!hl.has(t)))return t}function nw(e,t){if(t===!0)return{provenance_invalid:!0};if(e===void 0)return{};if(!is(e))return{provenance_invalid:!0};let n=w(e.author),r=w(e.created_at),o=e.source_kind;return!n||!r||!ye(r)||o!=="local_mutation"&&o!=="merge_union"?{provenance_invalid:!0}:{provenance:{author:n,created_at:r,source_kind:o,source_ref:w(e.source_ref)}}}function rw(e){let t={command:e.command?.trim()||void 0,path:e.path?jt(e.path):void 0,scope:e.scope,timeout_seconds:typeof e.timeout_seconds=="number"&&Number.isFinite(e.timeout_seconds)&&e.timeout_seconds>0?e.timeout_seconds:void 0,pm_context_mode:ew(e.pm_context_mode),workspace_context_mode:tw(e.workspace_context_mode),...nw(e.provenance,e.provenance_invalid),updated_by:w(e.updated_by),updated_at:w(e.updated_at),env_set:_l(e.env_set),env_clear:Sn(e.env_clear),shared_host_safe:e.shared_host_safe===!0?!0:void 0,assert_stdout_contains:Sn(e.assert_stdout_contains),assert_stdout_regex:Sn(e.assert_stdout_regex),assert_stderr_contains:Sn(e.assert_stderr_contains),assert_stderr_regex:Sn(e.assert_stderr_regex),assert_stdout_min_lines:$t(e.assert_stdout_min_lines),assert_json_field_equals:_l(e.assert_json_field_equals),assert_json_field_gte:Zb(e.assert_json_field_gte),note:e.note?.trim()||void 0,phase:e.phase==="setup"?"setup":void 0};return Yr(t),t}function ow(e){if(!(!e||e.length===0))return[...e].map(t=>({path:jt(t.path),scope:t.scope,note:t.note?.trim()||void 0})).sort((t,n)=>{let r=t.scope.localeCompare(n.scope);if(r!==0)return r;let o=t.path.localeCompare(n.path);return o!==0?o:(t.note??"").localeCompare(n.note??"")})}function w(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function iw(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=w(r.id),i=w(r.kind);if(!o||!i)continue;let s={id:o,kind:i},a=w(r.note);a&&(s.note=a),r.required_before_step===!0&&(s.required_before_step=!0),t.push(s)}return t.length>0?t:void 0}function sw(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=w(r.path);if(!o)continue;let i={path:jt(o)};(r.scope==="project"||r.scope==="global")&&(i.scope=r.scope);let s=w(r.note);s&&(i.note=s),t.push(i)}return t.length>0?t:void 0}function aw(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=w(r.command),i=w(r.path);if(!o&&!i)continue;let s={};o&&(s.command=o),i&&(s.path=jt(i));let a=w(r.note);a&&(s.note=a),t.push(s)}return t.length>0?t:void 0}function cw(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=w(r.path);if(!o)continue;let i={path:jt(o)};(r.scope==="project"||r.scope==="global")&&(i.scope=r.scope);let s=w(r.note);s&&(i.note=s),t.push(i)}return t.length>0?t:void 0}function dw(e){if(e===null||typeof e!="object")return;let t=e,n=w(t.id),r=w(t.title),o=w(t.status),i=o&&yb.has(o)?o:void 0,s=$r(t.order)??Number.NaN,a=typeof t.created_at=="string"?t.created_at:"",c=typeof t.updated_at=="string"?t.updated_at:"";if(!n||!r||!i||!Number.isFinite(s)||!a||!c)return;let d={id:n,order:s,title:r,status:i,created_at:a,updated_at:c};return lw(d,t),d}function lw(e,t){let n=[["body","body"],["owner","owner"],["evidence","evidence"],["blocked_reason","blocked_reason"],["superseded_by","superseded_by"]];for(let[i,s]of n){let a=w(t[s]);a&&(e[i]=a)}let r=typeof t.completed_at=="string"?t.completed_at:void 0;r&&r.length>0&&(e.completed_at=r);let o=[["linked_items","linked_items",iw],["files","files",sw],["tests","tests",aw],["docs","docs",cw]];for(let[i,s,a]of o){let c=a(t[s]);c&&(e[i]=c)}}function uw(e){if(!Array.isArray(e))return;let t=e.flatMap(n=>{let r=dw(n);return r?[r]:[]});return t.sort((n,r)=>n.order-r.order),t.length>0?t:void 0}function fw(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=typeof r.ts=="string"?r.ts:"",i=typeof r.author=="string"?r.author:"",s=w(r.decision);if(!o||!i||!s)continue;let a={ts:o,author:i,decision:s},c=w(r.rationale);c&&(a.rationale=c);let d=w(r.evidence);d&&(a.evidence=d);let l=w(r.step_id);l&&(a.step_id=l),t.push(a)}return t.length>0?t:void 0}function mw(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=typeof r.ts=="string"?r.ts:"",i=typeof r.author=="string"?r.author:"",s=w(r.text);if(!o||!i||!s)continue;let a={ts:o,author:i,text:s},c=w(r.step_id);c&&(a.step_id=c),t.push(a)}return t.length>0?t:void 0}function pw(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=w(r.text);if(!o)continue;let i={text:o},s=w(r.command);s&&(i.command=s);let a=w(r.expected);a&&(i.expected=a),t.push(i)}return t.length>0?t:void 0}function _w(e){if(!e)return;let t=Object.entries(e).map(([n,r])=>[n.trim(),r.trim()]).filter(([n,r])=>n.length>0&&r.length>0).sort((n,r)=>n[0].localeCompare(r[0]));if(t.length!==0)return Object.fromEntries(t)}function Mt(e){let t=0;for(;t<e.length&&e[t]===`
4
+ `;)t+=1;return e.slice(t).trimEnd()}function yw(e){if(e===void 0)return;if(typeof e=="number")return e;let t=e.trim().toLowerCase();if(t==="med")return"medium";if(Ir.includes(t))return t}function gw(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t==="med")return"medium";if(Ar.includes(t))return t}function kn(e){return e||void 0}function hw(e,t){let n=e,r=t;for(let[o,i]of Object.entries(r))ss(o)||Object.prototype.hasOwnProperty.call(n,o)||i===void 0||(n[o]=i)}function bw(e,t){if(!t?.fieldRegistry)return;let n=e;for(let r of t.fieldRegistry.definitions){let o=n[r.metadata_key];o!==void 0&&(n[r.metadata_key]=On(r,o,`metadata field "${r.metadata_key}"`,"metadata"))}}function ww(e,t){if(!t||t.unknownFieldPolicy==="allow")return;let n=Ol(t),r=Object.keys(e).filter(o=>!n.has(o)).sort((o,i)=>o.localeCompare(i));r.length>0&&t.unknownFieldPolicy==="reject"&&Ce(`unknown schema fields are not allowed: ${r.join(", ")}`),r.length>0&&t.onWarning?.(`item_unknown_schema_fields:${r.join(",")}`)}function Xr(e,t={}){let n=vl(t),r=Wr(e.status,n?.statusRegistry)??e.status,o=Array.from(new Set((Array.isArray(e.tags)?e.tags:[]).filter(s=>typeof s=="string").map(s=>s.trim().toLowerCase()).filter(Boolean))).sort((s,a)=>s.localeCompare(a)),i={id:e.id,title:e.title,description:e.description,type:e.type,pm_format_version:dl(e.pm_format_version),source_type:w(e.source_type),type_options:_w(e.type_options),status:r,priority:e.priority,tags:o,created_at:e.created_at,updated_at:e.updated_at,dependencies:Lb(e.dependencies),comments:Ji(e.comments),notes:Ji(e.notes),learnings:Ji(e.learnings),files:Wb(e.files),tests:Qb(e.tests),test_runs:Gb(e.test_runs),docs:ow(e.docs),deadline:kn(e.deadline),reminders:zb(e.reminders),events:Vb(e.events),closed_at:kn(e.closed_at),completed_at:kn(e.completed_at),assignee:w(e.assignee),claim_principal:w(e.claim_principal),source_owner:w(e.source_owner),author:kn(e.author),estimated_minutes:e.estimated_minutes,acceptance_criteria:e.acceptance_criteria??void 0,deferred_fields:fl(e.deferred_fields),design:e.design??void 0,external_ref:e.external_ref??void 0,definition_of_ready:w(e.definition_of_ready),order:e.order,goal:w(e.goal),objective:w(e.objective),value:w(e.value),impact:w(e.impact),outcome:w(e.outcome),why_now:w(e.why_now),parent:w(e.parent),reviewer:w(e.reviewer),risk:e.risk??void 0,confidence:yw(e.confidence),sprint:w(e.sprint),release:w(e.release),blocked_by:w(e.blocked_by),blocked_reason:w(e.blocked_reason),unblock_note:w(e.unblock_note),reporter:w(e.reporter),severity:gw(e.severity),environment:w(e.environment),repro_steps:w(e.repro_steps),resolution:w(e.resolution),expected_result:w(e.expected_result),actual_result:w(e.actual_result),affected_version:w(e.affected_version),fixed_version:w(e.fixed_version),component:w(e.component),regression:e.regression,customer_impact:w(e.customer_impact),close_reason:kn(e.close_reason),plan_mode:w(e.plan_mode),plan_scope:w(e.plan_scope),plan_harness:w(e.plan_harness),plan_resume_context:w(e.plan_resume_context),plan_steps:uw(e.plan_steps),plan_decisions:fw(e.plan_decisions),plan_discoveries:mw(e.plan_discoveries),plan_validation:pw(e.plan_validation)};return hw(i,e),bw(i,n),ww(i,n),Yr(i),i}function Sl(e){return Ke(e,Oe)}function vw(e){let t=0,n=!1,r=!1;for(let o=0;o<e.length;o+=1){let i=e[o];if(n){if(r){r=!1;continue}if(i==="\\"){r=!0;continue}i==='"'&&(n=!1);continue}if(i==='"'){n=!0;continue}if(i==="{"){t+=1;continue}if(i==="}"&&(t-=1,t===0))return o}return-1}function Ew(e){if(!e.startsWith("{"))return{frontMatter:"",body:e};let t=vw(e);if(t<0)return{frontMatter:"",body:e};let n=e.slice(0,t+1),r=e.slice(t+1).replace(/^\r?\n+/,"");return{frontMatter:n,body:r}}function Ow(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,n=t.match(/^[ \t]*---[ \t]*(?:\r?\n|$)/);if(!n)return{content:t,stripped:!1};let r=n[0].length;for(;r<t.length;){let o=t.indexOf(`
5
+ `,r),i=o===-1?t.length:o,s=t.slice(r,i).replace(/\r$/,""),a=o===-1?i:i+1;if(s.trim()==="---")return{content:t.slice(a).replace(/^\s+/,""),stripped:!0};r=a}return{content:t,stripped:!1}}function ns(e,t){return Xr(e,{...t,onWarning:void 0})}function Sw(e,t,n={}){let r=Ow(e);r.stripped&&n.onWarning?.("json_markdown_leading_yaml_frontmatter_ignored");let{frontMatter:o,body:i}=Ew(r.content);o||(e.trimStart().startsWith("{")&&An("json_markdown","JSON front matter is not valid JSON"),An("json_markdown","JSON Markdown item document is missing JSON front matter"));let s;try{s=JSON.parse(o)}catch{An("json_markdown","JSON front matter is not valid JSON")}return El(s,n.requireSupportedFormat),ts(s,t),{metadata:ns(s,n),body:Mt(i)}}function kw(e,t,n={}){let r;try{r=Yi(e).value}catch{An("toon","TOON item document is not valid TOON")}v(typeof r=="object"&&r!==null&&!Array.isArray(r),"TOON item document must be an object");let o=r;if(El(Object.prototype.hasOwnProperty.call(o,"front_matter")?o.front_matter:o,n.requireSupportedFormat),!wl.some(a=>Object.prototype.hasOwnProperty.call(o,a))&&!Object.prototype.hasOwnProperty.call(o,"front_matter")&&An("toon","TOON input does not have the shape of an item document"),Object.prototype.hasOwnProperty.call(o,"front_matter"))return ts(o.front_matter,t),v(o.body===void 0||typeof o.body=="string","TOON item document body must be a string"),{metadata:ns(o.front_matter,n),body:Mt(typeof o.body=="string"?o.body:"")};let{body:i,...s}=o;return v(i===void 0||typeof i=="string","TOON item document body must be a string"),ts(s,t),{metadata:ns(s,n),body:Mt(typeof i=="string"?i:"")}}function Aw(e,t={}){let n=Xr(e.metadata,t),r=Sl(n),o=Mt(e.body??"");os(JSON.parse(JSON.stringify(r))),os({body:o});let i=JSON.stringify(r,null,2);return o?`${i}
6
+
7
+ ${o}
8
+ `:`${i}
9
+ `}var Iw=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u;function rs(e,t){return typeof e=="string"?yl(e,t):e===null||typeof e!="object"?null:Array.isArray(e)?gl(e.map((n,r)=>()=>rs(n,`${t}[${r}]`))):gl(Object.entries(e).map(([n,r])=>()=>{let o=t?`${t}.${n}`:n;return yl(n,`${o} (key)`)??rs(r,o)}))}function yl(e,t){let n=e.search(Iw);return n<0?null:{path:t,index:n}}function gl(e){for(let t of e){let n=t();if(n!==null)return n}return null}function os(e){let t=rs(e,"");if(t!==null)throw new h(`Item field ${t.path} contains an unpaired surrogate code unit at index ${t.index}; persisted item text requires well-formed Unicode.`,g.USAGE,{code:"text_unpaired_surrogate",field:t.path,required:"Provide well-formed UTF-16 text: keep emoji and other astral characters whole and avoid lone \\uD800-\\uDFFF JSON escapes.",why:"Persisted item text must remain well-formed in every supported format; a lone surrogate can cause an unclassified encoder fault.",nextSteps:[`Repair the ${t.path} value (for example String.prototype.toWellFormed() or re-truncate on a character boundary) and retry.`,"Run pm <command> --help --json to review the text fields the command accepts."]})}function Tw(e,t={}){let n=Xr(e.metadata,t),r=Sl(n),o=Mt(e.body??""),i={...r,body:o},s=JSON.parse(JSON.stringify(i));os(s);let a=mb(s),c;try{c=Yi(a).value}catch(d){throw new h("Refusing to persist a TOON item document that the configured decoder cannot read back.",g.GENERIC_FAILURE,{code:"item_document_roundtrip_failed",reason:"encode_decode_error",format:"toon",required:"Upgrade or repair the TOON codec before retrying the mutation; no item bytes were written.",why:d instanceof Error?d.message:String(d)})}if(!ml(c,s)){let d=typeof c=="object"&&c!==null&&!Array.isArray(c)?c:{},l=Object.keys(s).find(u=>!ml(s[u],d[u]))??"document";throw new h(`Refusing to persist a lossy TOON item document; round-trip mismatch at field "${l}".`,g.GENERIC_FAILURE,{code:"item_document_roundtrip_failed",reason:"encode_decode_mismatch",format:"toon",field:l,required:"Upgrade or repair the TOON codec before retrying the mutation; no item bytes were written.",why:"The encoded document decoded to a value different from the canonical item payload."})}return`${a}
10
+ `}function Vx(e,t={}){let n=Gr(e);if(n)throw new h(`Merge conflict markers detected in item document at line ${n.line} (${n.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,g.GENERIC_FAILURE,{code:"merge_conflict_markers_detected",reason:"merge_conflict",required:"Resolve merge-conflict markers in the item file before parsing or mutation commands.",why:"Partially merged documents can corrupt item metadata and history integrity.",examples:["git status","git add <resolved-file> && git commit"],nextSteps:["Resolve conflicts, save the file, then rerun the pm command."]});let r=t.format??"toon",o=vl(t);return r==="toon"?kw(e,o,t):Sw(e,o,t)}function qx(e,t={}){return(t.format??"toon")==="toon"?Tw(e,t):Aw(e,t)}function Lt(e,t={}){return{metadata:Xr(e.metadata,t),body:Mt(e.body??"")}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="82c79093-2a40-5b4c-8d41-637b0ae03c4f")}catch{}})();function kl(e){return e}import{AsyncLocalStorage as Cw}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1fbb183b-c6d8-5834-b4cb-e4fb515572b9")}catch{}})();var as=new Cw,Al=/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,127})$/u;function Jr(e,t){let n=typeof e=="string"?e.trim():"";return n.length>0?n.slice(0,t):void 0}function Qe(e,t){if(e===void 0)return;let n=typeof e=="object"&&e!==null?e:{},r=Jr(n.id,128),o=Jr(n.parent_id,128);if(r===void 0||!Al.test(r)||o!==void 0&&!Al.test(o)){if(t)throw new Error("Agent episode ids must be 1-128 letters, digits, dots, underscores, colons, or hyphens.");return}let i=Jr(n.label,256);return{id:r,...i===void 0?{}:{label:i},...o===void 0?{}:{parent_id:o}}}function Ft(e){let t={};for(let[n,r]of Object.entries(e??{}).slice(0,32)){let o=n.trim().toLowerCase().slice(0,64),i=Jr(r,256);/^[a-z][a-z0-9_-]{0,63}$/u.test(o)&&i!==void 0&&(t[o]=i)}return t}function Rw(e,t,n){let r=as.getStore(),o=Ft({role:t.PM_AGENT_SESSION_ROLE,topic:t.PM_AGENT_SESSION_TOPIC}),i=Qe(t.PM_AGENT_EPISODE_ID===void 0?void 0:{id:t.PM_AGENT_EPISODE_ID,label:t.PM_AGENT_EPISODE_LABEL,parent_id:t.PM_AGENT_EPISODE_PARENT_ID},!1),s={...Ft(r?.provenance),...o,...Ft(e?.provenance)},a=Qe(e?.episode,!1)??Qe(n,!1)??i??Qe(r?.episode,!1);return Object.keys(s).length===0&&a===void 0?void 0:{...Object.keys(s).length===0?{}:{provenance:s},...a===void 0?{}:{episode:a}}}function cs(e,t){return Rw(e.session_context,t,e.client_info?.episode)??{}}function Kx(e,t){let n=as.getStore(),r=Qe(e.episode,!0),o=Qe(n?.episode,!1),i=r!==void 0&&r.parent_id===void 0&&o!==void 0?{...r,parent_id:o.id}:r,s={...Ft(n?.provenance),...Ft(e.provenance)};return as.run({...Object.keys(s).length===0?{}:{provenance:s},...i===void 0?o===void 0?{}:{episode:o}:{episode:i}},t)}function Yx(e){let t=Ft(e.provenance),n=Qe(e.episode,!0);return{...n===void 0?{}:{PM_AGENT_EPISODE_ID:n.id,...n.label===void 0?{}:{PM_AGENT_EPISODE_LABEL:n.label},...n.parent_id===void 0?{}:{PM_AGENT_EPISODE_PARENT_ID:n.parent_id}},...t.role===void 0?{}:{PM_AGENT_SESSION_ROLE:t.role},...t.topic===void 0?{}:{PM_AGENT_SESSION_TOPIC:t.topic}}}import{constants as UI}from"node:fs";import V from"node:fs/promises";import U from"node:path";import{createHash as zI,randomUUID as ui}from"node:crypto";import{existsSync as DI}from"node:fs";import{AsyncLocalStorage as m_}from"node:async_hooks";import ve from"node:path";import{AsyncLocalStorage as Wm}from"node:async_hooks";import{realpathSync as mk}from"node:fs";import Ua from"node:path";import zm from"fast-json-patch";import jm from"node:fs/promises";import JS from"node:path";import{AsyncLocalStorage as Es}from"node:async_hooks";import{createHash as $w}from"node:crypto";import Z from"node:fs";import $l from"node:os";import tt from"node:path";import{createHash as Il}from"node:crypto";import{existsSync as ds,promises as Tl,readFileSync as xw}from"node:fs";import le from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b86f3679-07fa-5566-b8cb-fb05ab89dd31")}catch{}})();var Nw="session.json";function ls(e,t){return typeof e=="string"&&e.length>0&&e.length<=t}function Cl(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,n=["implementer","planner","release-operator"].includes(String(t.role)),r=["high","medium"].includes(String(t.confidence)),o=ls(t.topic,256),i=Array.isArray(t.evidence)&&t.evidence.length<=32&&t.evidence.every(c=>typeof c=="string"&&c.length<=128),s=Array.isArray(t.active_item_ids)&&t.active_item_ids.length<=64&&t.active_item_ids.every(c=>ls(c,128)),a=t.focused_item_id===void 0||ls(t.focused_item_id,128);if([n,r,o,i,s,a,t.rule_version==="v2"].every(Boolean))return t}function Dw(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=Object.entries(e).slice(0,128).flatMap(([n,r])=>{let o=Cl(r);return o&&n.length<=128?[[n,o]]:[]});return t.length>0?Object.fromEntries(t):void 0}function fs(e){return le.join(Ti(e),Nw)}async function Rl(e){try{let t=await Tl.readFile(fs(e),"utf8"),n=JSON.parse(t);if(n===null||typeof n!="object"||Array.isArray(n))return{};let r=n,o=r.focused_item,i=Dw(r.semantic_attribution);return typeof o=="string"&&o.trim().length>0?{focused_item:o,...i?{semantic_attribution:i}:{}}:i?{semantic_attribution:i}:{}}catch{return{}}}async function ms(e,t){let n=await us(e,"session-state",hi.locks.ttl_seconds,"session-state",!1,!1,hi.locks.wait_ms);try{let r=await Rl(e);t(r);let o=fs(e);await n.fence(async()=>{await Tl.mkdir(le.dirname(o),{recursive:!0}),await Hc(o,JSON.stringify(r))})}finally{await n.release()}}function ps(e){return/#([a-f0-9]{24})$/u.exec(e.trim())?.[1]??`author-${Il("sha256").update(e).digest("hex").slice(0,24)}`}function _s(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].slice(0,32).map(t=>t.slice(0,128))}function ys(e){let t=[...new Set(e)].sort((r,o)=>r.localeCompare(o));if(t.length===1)return t[0];let n=`workset:${t.join("+")}`;return n.length<=256?n:`workset:${t.join("+").slice(0,230)}+${Il("sha256").update(t.join("\0")).digest("hex").slice(0,12)}`}async function gs(e,t,n){await ms(e,r=>{let o={...r.semantic_attribution},i=n(o[t]);i===void 0?delete o[t]:o[t]=i,Object.keys(o).length===0?delete r.semantic_attribution:r.semantic_attribution=o})}async function oN(e){let t=ps(e.principal);await gs(e.pmRoot,t,n=>{let r=[...new Set([...n?.active_item_ids??[],e.itemId])].slice(-64).sort((i,s)=>i.localeCompare(s)),o=n?.focused_item_id;return{role:"implementer",topic:o??ys(r),confidence:o?"high":"medium",rule_version:"v2",evidence:_s([...r.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:r,...o?{focused_item_id:o}:{}}})}async function iN(e){let t=ps(e.principal);await gs(e.pmRoot,t,n=>{if(!n)return;let r=n.active_item_ids.filter(i=>i!==e.itemId);if(r.length===0&&!n.focused_item_id)return;let o=n.focused_item_id;return{...n,role:"release-operator",topic:o??ys(r),confidence:o?"high":"medium",evidence:_s([...r.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],`release:${e.itemId}`]),active_item_ids:r}})}async function sN(e){let t=ps(e.principal);await gs(e.pmRoot,t,n=>{let r=n?.active_item_ids??[];if(!e.itemId&&r.length===0)return;let o=e.itemId;return{role:o?"planner":n.role,topic:o??ys(r),confidence:o?"high":"medium",rule_version:"v2",evidence:_s([...r.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:r,...o?{focused_item_id:o}:{}}})}function Pw(e,t){let n=t.PM_PATH?.trim();if(n){let o=le.resolve(e,n);if(ds(le.join(o,"settings.json")))return o;let i=le.join(o,".agents","pm");if(ds(le.join(i,"settings.json")))return i}let r=le.resolve(e);for(let o=0;o<32;o+=1){let i=le.join(r,".agents","pm");if(ds(le.join(i,"settings.json")))return i;let s=le.dirname(r);if(s===r)break;r=s}}function xl(e){if(!e.key)return;let t=Pw(e.cwd,e.env);if(t)try{let n=JSON.parse(xw(fs(t),"utf8"));return Cl(n.semantic_attribution?.[e.key])}catch{return}}async function aN(e){return(await Rl(e)).focused_item}async function cN(e,t){await ms(e,n=>{n.focused_item=t})}async function dN(e){await ms(e,t=>{delete t.focused_item})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1ea9ada3-1c97-5787-9b6c-08aeaf825394")}catch{}})();var Os=["model","effort","role","topic","version"],eo=new Es,Ml=new Es,to=new Es,Ss=[{harness:"claude-code",environment_keys:["CLAUDE_CODE","CLAUDECODE"],model_environment_keys:["ANTHROPIC_MODEL","CLAUDE_MODEL"],session_environment_keys:["CLAUDE_CODE_SESSION_ID"],provenance_environment_keys:{effort:["CLAUDE_EFFORT"]},provenance_resolvers:{model:"claude_session_file",version:"claude_session_file"},provenance_unavailable_dimensions:["role","topic"],argv_markers:["claude","claude-code"],client_names:["claude","claude-code","claude code"]},{harness:"codex",environment_keys:["CODEX_HOME","CODEX_CI","CODEX_THREAD_ID"],model_environment_keys:["CODEX_MODEL"],session_environment_keys:["CODEX_THREAD_ID"],provenance_environment_keys:{effort:["CODEX_REASONING_EFFORT","CODEX_EFFORT"],role:["CODEX_SESSION_ROLE"]},provenance_resolvers:{model:"codex_session_file",effort:"codex_session_file",version:"ai_agent_version"},provenance_unavailable_dimensions:["topic"],argv_markers:["codex"],client_names:["codex"]},{harness:"pi",environment_keys:["PI_AGENT","PI_CODING_AGENT"],model_environment_keys:["PI_MODEL"],session_environment_keys:["PI_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["pi"],client_names:["pi"]},{harness:"opencode",environment_keys:["OPENCODE","OPENCODE_SESSION_ID"],model_environment_keys:["OPENCODE_MODEL"],session_environment_keys:["OPENCODE_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["opencode"],client_names:["opencode"]},{harness:"cursor",environment_keys:["CURSOR_AGENT","CURSOR_TRACE_ID"],model_environment_keys:["CURSOR_MODEL"],session_environment_keys:["CURSOR_TRACE_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["cursor"],client_names:["cursor"]},{harness:"aider",environment_keys:["AIDER","AIDER_MODEL"],model_environment_keys:["AIDER_MODEL"],session_environment_keys:["AIDER_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["aider"],client_names:["aider"]},{harness:"gemini-cli",environment_keys:["GEMINI_CLI","GEMINI_CLI_HOME"],model_environment_keys:["GEMINI_MODEL"],session_environment_keys:["GEMINI_CLI_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["gemini","gemini-cli"],client_names:["gemini","gemini-cli","gemini cli"]},{harness:"ci",environment_keys:["CI","GITHUB_ACTIONS","BUILDKITE","GITLAB_CI"],provenance_unavailable_dimensions:["model","effort","role","topic"],argv_markers:[],client_names:[]}],jl=Object.freeze({max_bytes:1048576,max_lines:4096,network_access:!1,subprocess_access:!1}),Mw=Object.freeze({...jl,max_bytes:4194304}),hs=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function jw(e){let t=xe(e).provenance_unavailable_dimensions,n=new Set(["model","version",...Object.keys(e.provenance_environment_keys??{}),...Object.keys(e.provenance_resolvers??{})]);return Object.freeze({contract_version:1,adapter_version:"v1",priority:0,harness:e.harness,descriptor:e,supported_dimensions:Object.freeze([...n].sort()),native_sources:Object.freeze(["environment","argv","mcp_client",...Object.values(e.provenance_resolvers??{}).some(r=>r?.endsWith("session_file"))?["session_file"]:[]]),probe_policy:e.harness==="codex"?Mw:jl,normalization:Object.freeze({model_family:"v1",effort:"v1",preserve_raw:!0}),confidence:"high",waivers:Object.freeze(Object.fromEntries(t.map(r=>[r,"Harness does not expose this dimension."])))})}var Ll=Object.freeze(Ss.filter(e=>e.harness!=="ci").map(jw).sort((e,t)=>e.harness.localeCompare(t.harness))),et=new Map,Ut=new Map;function D(e){let t=typeof e=="string"?e.trim():void 0;return t&&t.length>0?t:void 0}function Re(e){return[...new Set((e??[]).slice(0,64).map(t=>t.trim()).filter(t=>t.length>0).map(t=>t.slice(0,128)))]}function xe(e){let t=e.harness.trim().toLowerCase();if(!hs.test(t))throw new Error(`Invalid harness signal descriptor namespace: ${e.harness}`);return{harness:t,environment_keys:Re(e.environment_keys),model_environment_keys:Re(e.model_environment_keys),session_environment_keys:Re(e.session_environment_keys),provenance_environment_keys:Object.fromEntries(Object.entries(e.provenance_environment_keys??{}).slice(0,32).map(([n,r])=>[n.trim().toLowerCase().slice(0,64),Re(r)]).filter(([n])=>hs.test(n))),provenance_resolvers:Object.fromEntries(Object.entries(e.provenance_resolvers??{}).slice(0,32).map(([n,r])=>[n.trim().toLowerCase().slice(0,64),r]).filter(n=>typeof n[0]=="string"&&hs.test(n[0])&&(n[1]==="ai_agent_version"||n[1]==="claude_session_file"||n[1]==="codex_session_file"))),provenance_unavailable_dimensions:Re(e.provenance_unavailable_dimensions).map(n=>n.toLowerCase()),argv_markers:Re(e.argv_markers).map(n=>n.toLowerCase()),client_names:Re(e.client_names).map(n=>n.toLowerCase())}}var Fl=Ss.map(xe);function Lw(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Zr(e,t){return e.toLowerCase().slice(0,512).split(/[/\\\s:=]+/u).filter(n=>n.length>0).includes(t)||e.trim().toLowerCase()===t}function ks(e=[]){let t=new Map(Ss.filter(o=>o.harness!=="ci").map(o=>[o.harness,xe(o)]));for(let{adapter:o}of et.values())t.set(o.harness,xe(o.descriptor));let n=[...t.values(),...Fl.filter(o=>o.harness==="ci"),...[...Ut.values()].map(o=>o.descriptor),...to.getStore()?.descriptors??[],...e.map(xe)],r=new Set;for(let o of n){if(r.has(o.harness))throw new Error(`Harness signal descriptor collision for "${o.harness}"`);r.add(o.harness)}return n}function As(e,t){for(let n of t??[]){let r=D(e[n]);if(r)return r.slice(0,256)}}function Fw(e,t){if(t==="role"){let n=e.slice(0,8).map(r=>r.trim().toLowerCase()).find(r=>["claim","create","update","close","release","review"].includes(r));if(n==="review")return"reviewer";if(n)return"implementer"}}function Ul(e,t){let n=t==="model"?["--model","--agent-model"]:[`--agent-${t}`],r=e.slice(0,8);for(let o=0;o<r.length;o+=1){let i=r[o].slice(0,512);if(n.includes(i))return D(r[o+1])?.slice(0,256);let s=n.find(a=>i.startsWith(`${a}=`));if(s)return D(i.slice(s.length+1))?.slice(0,256)}}var Uw=new Set(["implementation","implementer","investigator","orchestrator","planner","release-operator","reviewer"]);function Ze(e,t){if(e!=="role"||t===void 0)return t;let n=t.trim().toLowerCase().replaceAll(/[_\s]+/gu,"-");return Uw.has(n)?n:void 0}function bs(e,t){return D(e?.[t])?.slice(0,256)}var zw=1048576,vs=4194304,Qr=new Map,Nl=Object.freeze({}),ws=new Map,Dl=Object.freeze({});function Pl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function Hw(e){let t;try{t=JSON.parse(e)}catch{return Dl}let n=Pl(t);if(!n)return Dl;let r=[{value:n,depth:0}],o=0,i,s;for(;r.length>0&&o<64;){let a=r.shift();if(o+=1,i??=D(a.value.model)?.slice(0,256),s??=D(a.value.version)?.slice(0,256),i&&s)break;if(!(a.depth>=4))for(let c of Object.values(a.value)){let d=Pl(c);d&&r.push({value:d,depth:a.depth+1})}}return Object.freeze({model:i,version:s})}function zl(e){try{return Z.lstatSync(e).isFile()?"available":"missing"}catch(t){return Se(t)?"missing":"failed"}}function Vw(e,t){let n;try{n=Z.readdirSync(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).sort((o,i)=>o.name.localeCompare(i.name)).slice(0,512).map(o=>{let i=tt.join(e,o.name,`${t}.jsonl`);return{candidate:i,status:zl(i)}})}catch(o){return{status:Se(o)?"missing":"failed"}}let r=n.filter(({status:o})=>o==="available").map(({candidate:o})=>o);return r.length===0?{status:n.some(({status:o})=>o==="failed")?"failed":"missing"}:r.length>1?{status:"ambiguous"}:{status:"available",path:r[0]}}function Hl(e,t){let n=D(t.CLAUDE_CODE_SESSION_ID);if(!n||!/^[A-Za-z0-9_-]{1,128}$/u.test(n))return{status:"unavailable"};let r=tt.resolve(e.cwd??process.cwd()).replaceAll(/[^A-Za-z0-9-]/gu,"-"),o=tt.join(e.home_dir??$l.homedir(),".claude","projects"),i=tt.join(o,r,`${n}.jsonl`),s=D(e.session_file),a=s&&tt.basename(s)===`${n}.jsonl`?s:void 0;for(let c of[a,i]){if(!c)continue;let d=zl(c);if(d==="available")return{status:d,path:c};if(d==="failed")return{status:d}}return Vw(o,n)}function qw(e,t,n){let r=Hl(t,n);if(r.status==="available")try{let o=Z.openSync(r.path,Z.constants.O_RDONLY|Z.constants.O_NOFOLLOW);try{let i=Z.fstatSync(o),s=`${r.path}\0${i.size}\0${i.mtimeMs}`,a=ws.get(s);if(a)return a[e];let c=Math.min(i.size,zw),d=Math.min(c,Math.ceil(c/2)),l=Math.min(c-d,i.size-d),u=Buffer.alloc(d);Z.readSync(o,u,0,d,0);let f=Buffer.alloc(l);l>0&&Z.readSync(o,f,0,l,i.size-l);let m={},p=i.size<=c?Buffer.concat([u,f]).toString("utf8").split(`
11
+ `):[...u.toString("utf8").split(`
12
+ `).slice(0,4096),...f.toString("utf8").split(`
13
+ `).slice(-4096)];for(let y of p){if(y.length===0||y.length>262144)continue;let b=Hw(y);if(m.model??=b.model,m.version??=b.version,m.model&&m.version)break}let _=Object.freeze(m);return ws.clear(),ws.set(s,_),_[e]}finally{Z.closeSync(o)}}catch{return}}function Bw(e,t){let n=0,r=(o,i)=>{if(i>4||n>=512)return;let s;try{s=Z.readdirSync(o,{withFileTypes:!0}).sort((a,c)=>c.name.localeCompare(a.name))}catch{return}for(let a of s){if(n+=1,n>512)return;let c=tt.join(o,a.name);if(a.isFile()&&a.name.endsWith(`-${t}.jsonl`))return c;if(a.isDirectory()){let d=r(c,i+1);if(d)return d}}};return r(e,0)}function Ww(e){if(e<=vs)return[{offset:0,length:e}];let t=Math.floor(vs/2);return[{offset:e-t,length:t},{offset:0,length:t}]}function Gw(e,t){if(t.length===0||t.length>262144)return;let n;try{n=JSON.parse(t)}catch{return}if(typeof n!="object"||n===null||Array.isArray(n))return;let r=n;if(r.type!=="turn_context")return;let o=typeof r.payload=="object"&&r.payload!==null?r.payload:void 0;e.model??=D(o?.model)?.slice(0,256),e.effort??=D(o?.effort)?.slice(0,256)}function Kw(e,t){let n={},r=4096;for(let o of Ww(t)){let i=Buffer.alloc(o.length);Z.readSync(e,i,0,o.length,o.offset);let s=i.toString("utf8").split(`
14
+ `).reverse().slice(0,r);r-=s.length;for(let a of s)if(Gw(n,a),n.model&&n.effort)break;if(n.model&&n.effort||r<=0)break}return n}function Yw(e,t,n){let r=D(n.CODEX_THREAD_ID);if(!r||!/^[A-Za-z0-9_-]{1,128}$/u.test(r))return;let o=tt.join(t.home_dir??$l.homedir(),".codex","sessions"),i=`${o}\0${r}`,s=Qr.get(i);if(s)return s[e];let a=Bw(o,r);if(!a){Qr.set(i,Nl);return}try{let c=Z.openSync(a,"r");try{let d=Z.fstatSync(c).size,l=Kw(c,d);return Qr.set(i,l),l[e]}finally{Z.closeSync(c)}}catch{Qr.set(i,Nl);return}}function Xw(e,t,n,r){let o=to.getStore();if(!(t.probes_enabled!==!1&&o?.probesEnabled!==!1&&!["0","false","off"].includes(D(n.PM_AGENT_PROBES)?.toLowerCase()??"")))return;let i=r?.provenance_resolvers[e];if(i==="claude_session_file")return qw(e,t,n);if(i==="codex_session_file")return Yw(e,t,n);if(i==="ai_agent_version"){let s=D(n.AI_AGENT);return!s||!r||!Zr(s,r.harness)?void 0:/(?:^|[@/\s])v?(\d+\.\d+(?:\.\d+)?(?:[-+][A-Za-z0-9.-]+)?)$/u.exec(s)?.[1]?.slice(0,256)}}function Jw(e,t,n,r){if(e==="ai_agent_version"){let o=D(r.AI_AGENT);return o!==void 0&&Zr(o,t.harness)?"available":"unavailable"}return e==="codex_session_file"?D(r.CODEX_THREAD_ID)!==void 0?"available":"unavailable":Hl(n,r).status}function Is(e){return e||(Ml.getStore()??{env:process.env,argv:process.argv})}function Qw(e,t,n,r){let o=e.environment_keys.some(a=>D(t[a])!==void 0),i=e.argv_markers.some(a=>n.some(c=>{let d=c.replaceAll("\\","/");return Zr(d.slice(d.lastIndexOf("/")+1),a)})),s=e.client_names.some(a=>r===a||Zr(r,a));return o||i||s}function Zw(e,t){if(!t)return;let n;if(e==="topic"&&(n=t.topic),e==="role"&&(n=t.role),!!n)return{value:n,source:"inferred",confidence:t.confidence,rule_version:t.rule_version,evidence:t.evidence}}function ev(e){let t=e.find(([n])=>n!==void 0);return t?.[0]?{value:t[0],source:t[1]}:void 0}function tv(e,t,n,r,o,i){let s=`PM_AGENT_${e.toUpperCase().replaceAll("-","_")}`,a=new Set([...Os,...Object.keys(r?.provenance_environment_keys??{})]),c,d,l;a.has(e)&&(c=Ze(e,D(n[s])?.slice(0,256)),l=Ze(e,Ul(t.argv??[],e)),d=Ze(e,Fw(t.argv??[],e)));let u={...r?.provenance_environment_keys,model:r?.model_environment_keys},f={...t.client_info?.provenance,model:t.client_info?.model},m=bs(o?.provenance,e),p=Ze(e,As(n,u[e])),_=Ze(e,bs(f,e)),y=Ze(e,bs(t.provenance,e)),b=Xw(e,t,n,r);return ev([[c,"override"],[m,"session"],[l,"argv"],[p,"environment"],[_,"mcp_client"],[y,"host"],[b,"probe"]])??Zw(e,i)??(d?{value:d,source:"argv"}:void 0)}function nv(e,t){if(!(!e||!t))return $w("sha256").update(`pm-agent-instance:v1\0${e}\0${t}`).digest("hex").slice(0,24)}function rv(e,t,n,r,o){let i=Object.keys(n?.provenance_environment_keys??{}),s=new Set([...Os,...i,...Object.keys(n?.provenance_resolvers??{}),...Object.keys(e.provenance??{}),...Object.keys(e.client_info?.provenance??{}),...Object.keys(r?.provenance??{})]),a={};for(let c of s){let d=tv(c,e,t,n,r,o);d?a[c]=d:n&&(c!=="version"||n.provenance_unavailable_dimensions.includes(c))&&(a[c]=null)}return a}function wN(e){let t=e.map(xe),n=new Map(Fl.map(i=>[i.harness,i])),r=new Set;for(let i of t){if(r.has(i.harness)||n.has(i.harness))throw new Error(`Harness signal descriptor collision for "${i.harness}"`);let s=Ut.get(i.harness);if(s&&!Lw(s.descriptor,i))throw new Error(`Harness signal descriptor collision for "${i.harness}"`);r.add(i.harness)}for(let i of t){let s=Ut.get(i.harness);Ut.set(i.harness,{descriptor:i,registrations:(s?.registrations??0)+1})}let o=!0;return()=>{if(o){o=!1;for(let i of t){let s=Ut.get(i.harness);!s||s.registrations<=1?Ut.delete(i.harness):s.registrations-=1}}}}function ov(e){let t=xe(e.descriptor),n=e.harness.trim().toLowerCase();if(e.contract_version!==1)throw new Error(`Unsupported provenance adapter contract for "${n}": ${e.contract_version}`);if(t.harness!==n)throw new Error(`Provenance adapter harness "${n}" does not match descriptor "${t.harness}".`);let r=D(e.adapter_version)?.slice(0,64);if(!r)throw new Error(`Provenance adapter "${n}" requires a version.`);if(!Number.isSafeInteger(e.priority))throw new Error(`Provenance adapter "${n}" requires an integer priority.`);if(e.probe_policy.network_access!==!1||e.probe_policy.subprocess_access!==!1||e.probe_policy.max_bytes>vs||e.probe_policy.max_lines>4096)throw new Error(`Provenance adapter "${n}" exceeds the bounded local probe policy.`);return Object.freeze({...e,adapter_version:r,harness:n,descriptor:t,supported_dimensions:Object.freeze(Re(e.supported_dimensions).map(o=>o.toLowerCase()).sort()),native_sources:Object.freeze([...new Set(e.native_sources)]),probe_policy:Object.freeze({...e.probe_policy}),normalization:Object.freeze({...e.normalization}),...e.waivers?{waivers:Object.freeze(Object.fromEntries(Object.entries(e.waivers).slice(0,32).map(([o,i])=>[o.slice(0,64),i.slice(0,256)])))}:{}})}function vN(){let e=new Map(Ll.map(t=>[t.harness,t]));for(let{adapter:t}of et.values())e.set(t.harness,t);return Object.freeze([...e.values()].sort((t,n)=>t.harness.localeCompare(n.harness)))}function EN(e){let t=e.map(ov),n=new Map(Ll.map(i=>[i.harness,i])),r=new Set;for(let i of t){if(r.has(i.harness))throw new Error(`Provenance adapter collision for "${i.harness}".`);let s=n.get(i.harness);if(s&&i.priority<=s.priority)throw new Error(`Provenance adapter override for "${i.harness}" requires priority greater than ${s.priority}.`);let a=et.get(i.harness);if(a&&JSON.stringify(a.adapter)!==JSON.stringify(i))throw new Error(`Provenance adapter collision for "${i.harness}".`);r.add(i.harness)}for(let i of t){let s=et.get(i.harness);et.set(i.harness,{adapter:i,registrations:(s?.registrations??0)+1})}let o=!0;return()=>{if(o){o=!1;for(let i of t){let s=et.get(i.harness);!s||s.registrations<=1?et.delete(i.harness):s.registrations-=1}}}}function ON(e,t){let n=t.trim().slice(0,256),r=n.toLowerCase();if(e==="model"){let o=/^(gpt-\d+(?:\.\d+)?)/u.exec(r)?.[1];o&&(r=o)}else r=r.replaceAll(/[_\s-]+/gu,""),r={minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max",ultra:"ultra"}[r]??r;return{raw:n,normalized:r,vocabulary:"v1"}}function SN(e,t){return Ml.run(e,t)}function kN(e,t,n={}){let r=e.map(xe);return ks(r),to.run({descriptors:r,probesEnabled:n.probesEnabled!==!1},t)}function Ts(e){let t=Is(e),n=t.env??{},r=ks(t.descriptors),o=[...(t.argv??[]).slice(0,3),...t.process_labels??[]].slice(0,64).map(p=>p.slice(0,512)),i=t.client_info?.name.trim().toLowerCase()??"",s=r.find(p=>Qw(p,n,o,i)),a=cs(t,n),c=[As(n,s?.session_environment_keys),D(t.client_info?.session)?.slice(0,256)].find(p=>p!==void 0),d=nv(s?.harness,c),l=xl({cwd:t.cwd??process.cwd(),env:n,key:d}),u=rv(t,n,s,a,l),f=u.model,m=[["harness",s?.harness],["model",f?.value],["model_source",f?.source],["session",c],["instance",d],["provenance",Object.keys(u).length>0?u:void 0],["episode",a.episode]];return Object.fromEntries(m.filter(p=>p[1]!==void 0))}function iv(e){return e==="unavailable"?{status:"unavailable",reason:"harness_unavailable"}:e==="missing"?{status:"unavailable",reason:"resolver_input_missing"}:{status:"failed",reason:"resolver_failed"}}function sv(e,t,n,r,o,i,s){let a=n?.provenance_resolvers[e];if(t.provenance?.[e])return{status:"resolved",...a?{resolver:a}:{},rule_version:"v1"};if(s)return{status:"unavailable",reason:"invalid_value",rule_version:"v1"};if(a){if(!i)return{status:"unavailable",reason:"probes_disabled",resolver:a,rule_version:"v1"};let c=Jw(a,n,r,o);return{...iv(c),resolver:a,rule_version:"v1"}}return{status:n?.provenance_unavailable_dimensions.includes(e)?"unavailable":"not_configured",reason:n?.provenance_unavailable_dimensions.includes(e)?"harness_unavailable":"resolver_not_configured",rule_version:"v1"}}function Vl(e){let t=Is(e),n=Ts(t),r=ks(t.descriptors).find(d=>d.harness===n.harness),o=t.env??{},i=t.probes_enabled!==!1&&to.getStore()?.probesEnabled!==!1&&!["0","false","off"].includes(D(o.PM_AGENT_PROBES)?.toLowerCase()??""),s=cs(t,o),a=[o.PM_AGENT_ROLE,s.provenance?.role,As(o,r?.provenance_environment_keys.role),t.client_info?.provenance?.role,t.provenance?.role,Ul(t.argv??[],"role")].some(d=>{let l=D(d)?.slice(0,256);return l!==void 0&&Ze("role",l)===void 0}),c=Object.fromEntries(Os.map(d=>[d,sv(d,n,r,t,o,i,d==="role"&&a)]));return{...n,provenance_outcomes:c}}function AN(){return process.env.PM_AUTHOR}function IN(e){e===void 0?delete process.env.PM_AUTHOR:process.env.PM_AUTHOR=e}function TN(e){return Ts(e).harness}function av(e,t,n){let r=Is(n),o=Ts(r);if(e!==void 0){let s=D(e);return Nt(s,"--author"),s?{author:s,source:"asserted",...o}:{author:"unknown",source:"unknown",...o}}if(r.env?.PM_AUTHOR!==void 0){let s=D(r.env.PM_AUTHOR);return Nt(s,"PM_AUTHOR"),s?{author:s,source:"asserted",...o}:{author:"unknown",source:"unknown",...o}}let i=D(t);return i?(Nt(i,"default_author"),{author:i,source:"configured",...o}):o.harness?{author:`harness:${o.harness}`,source:"detected",...o}:{author:"unknown",source:"unknown",...o}}function ql(e){let t=eo.getStore();return t?.author===e?t.source:e.startsWith("harness:")?"detected":e==="unknown"?"unknown":"asserted"}function Bl(e){let t=eo.getStore();return t?.author!==e?e.startsWith("harness:")?{harness:e.slice(8)}:{}:{...t.harness?{harness:t.harness}:{},...t.model?{model:t.model}:{},...t.model_source?{model_source:t.model_source}:{},...t.session?{session:t.session}:{},...t.instance?{instance:t.instance}:{},...t.provenance?{provenance:t.provenance}:{},...t.episode?{episode:t.episode}:{}}}function CN(e){let t=eo.getStore();return t?.author===e&&t.source==="detected"&&t.instance?`${e}#${t.instance}`:e}function RN(e,t){let n=av(e,t);return eo.enterWith(n),n.author}import T from"node:fs/promises";import N from"node:path";import{createHash as co,randomUUID as js}from"node:crypto";import{createRequire as Iv}from"node:module";import{setImmediate as su}from"node:timers/promises";import cv from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="58661057-fa80-5571-9be7-b949723c274b")}catch{}})();async function no(e,t){let n=await cv.readFile(e).catch(s=>{if(Se(s))return null;throw s}),r=n?.toString("utf8")??null;if(r===null)return{raw:r,raw_bytes:n,entries:[]};if(await ro({path:e,scope:"project"}),r.trim()==="")return{raw:r,raw_bytes:n,entries:[]};let o=Gr(r);if(o)throw new h(`History for ${t} contains merge conflict markers at line ${o.line} (${o.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,g.GENERIC_FAILURE,{code:"history_merge_conflict_markers_detected",required:"Repair the history stream by resolving merge-conflict markers.",why:"Conflict markers break JSONL parsing and invalidate deterministic audit history.",examples:[`pm history ${t}`,`pm restore ${t} <timestamp-or-version>`],nextSteps:["Resolve or restore the history file, then rerun the command."]});let i=[];for(let[s,a]of r.split(/\r?\n/).entries()){let c=a.trim();if(c)try{i.push(JSON.parse(c))}catch{throw new h(`History for ${t} contains invalid JSON at line ${s+1}. Repair or restore the history stream and retry.`,g.GENERIC_FAILURE,{code:"history_json_invalid",nextSteps:[`Run pm history-repair ${t} --salvage-tail --dry-run to check whether only an invalid suffix is damaged.`]})}}return{raw:r,raw_bytes:n,entries:i}}async function LN(e,t){return(await no(e,t)).entries}import Rs from"fast-json-patch";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3bfeb8d2-52c2-587a-9611-c4d5817cb47e")}catch{}})();function Wl(e){let t=[],n=e[0]?.op==="history_compact_baseline",r=n?1:void 0,o=!1;for(let[i,s]of e.entries())s.op==="delete"&&(o=!0),s.op==="create"&&(r!==void 0&&t.push({prior_genesis_index:r,repeated_create_index:i+1,sequence:o?"delete_then_create":n?"checkpoint_then_create":"multiple_creates"}),r??=i+1,o=!1);return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0c0cb8c7-4d7d-53f8-8ec2-d6dc98fc6dc5")}catch{}})();var dv={metadata:{},body:""};function Yl(){return structuredClone(dv)}function YN(e,t=nt,n){return Cs(e,t,n)[0]}function Cs(e,t,n){if(Object.keys(e.metadata).length===0||Array.isArray(e.metadata.tags))try{return ru(Jl(e),t,n)}catch{}let r=Ie(C({replay_fallback:!0,metadata:e.metadata,body:e.body}),n);return t===2?[r,r]:[r]}function Xl(e,t,n,r,o){let i=Xe(r.hash_algorithm),s=`${n}:${i}`,a=o?.before.get(s)??Cs(e,n,i),c=Cs(t,n,i);return o?.after.set(s,c),{beforeHashes:a,afterHashes:c,pairIndex:a.findIndex((d,l)=>d===r.before_hash&&c[l]===r.after_hash),beforeIndex:a.indexOf(r.before_hash),afterIndex:c.indexOf(r.after_hash)}}function Jl(e){return{metadata:e.metadata,body:e.body}}function XN(e,t={}){return Lt(Jl(e),t)}function JN(e){if(!e.metadata||Object.keys(e.metadata).length===0)return{metadata:{},body:e.body??""};let t=Lt(e);return{metadata:Ke(t.metadata,Oe),body:t.body}}function Gl(e){return e==="/front_matter"?"/metadata":e.startsWith("/front_matter/")?`/metadata/${e.slice(14)}`:e}function lv(e){return typeof e=="object"&&e!==null&&typeof e.op=="string"&&typeof e.path=="string"}function Ql(e){return Array.isArray(e)?e.filter(lv).map(t=>({...t,path:Gl(t.path),from:typeof t.from=="string"?Gl(t.from):void 0})):[]}function uv(e){return typeof e=="object"&&e!==null&&"metadata"in e&&"body"in e&&typeof e.body=="string"&&typeof e.metadata=="object"&&e.metadata!==null}function Zl(e,t){try{let n=Ql(t),r=Rs.applyPatch(structuredClone(e),n,!0,!0).newDocument;return uv(r)?{ok:!0,document:{metadata:r.metadata,body:r.body}}:{ok:!1,error:new Error("history_replay_invalid_document_shape")}}catch(n){return{ok:!1,error:n}}}function fv(e){return[...new Set(e.map(t=>t.item_hash_version).filter(t=>t!==void 0&&Tn.includes(t)))]}function eu(e){return e!==void 0&&!Tn.includes(e)}function mv(e,t){return e!==void 0?[e]:t===void 0?[...Tn]:[t]}function tu(e){let t=io(e);if(!t.ok)return t.error;let n=xs(e);return n.ok?void 0:n.error}function pv(e,t){let n=tu(e);if(n)return{ok:!1,error:n};let r=Zl(t,e.patch);return r.ok?{ok:!0,document:r.document}:{ok:!1,error:"patch_apply_failed"}}function _v(e,t){let n=tu(e);if(n)throw new TypeError(`${n}:entry_${t+1}`)}function yv(e,t,n,r,o){let i=[];for(let s of n){let a=Xl(e,t,s,r,o);if(i.push({version:s,match:a}),a.pairIndex>=0)break}return i}function oo(e){let t=Yl(),n=new Map,r,o,i=Wl(e).map(s=>`verify_failed:duplicate_create:entry_${s.repeated_create_index}:prior_${s.prior_genesis_index}`);for(let s=0;s<e.length;s+=1){let a=e[s],c=a.item_hash_version,d=eu(c);d&&i.push(`verify_failed:unsupported_item_hash_version:${String(c)}:entry_${s+1}`);let l=pv(a,t);if(!l.ok)return{ok:!1,errors:[...i,`verify_failed:${l.error}:entry_${s+1}`]};if(d){t=l.document,n=new Map,r=void 0,o=void 0;continue}let u=mv(c,o),f={before:n,after:new Map},m=yv(t,l.document,u,a,f),p=m.find(({match:y})=>y.pairIndex>=0);if(p===void 0){let y=m.some(({match:b})=>b.beforeIndex>=0);return{ok:!1,errors:[...i,`verify_failed:${y?"after":"before"}_hash_mismatch:entry_${s+1}`]}}let _=p.version;t=l.document,n=f.after,r=_,o=c??o}return i.length>0?{ok:!1,errors:i,...r===void 0?{}:{item_hash_version:r}}:{ok:!0,errors:[],...r===void 0?{}:{item_hash_version:r}}}function QN(e){let t=oo(e);return{ok:t.ok,errors:t.errors}}function Kl(e,t){try{return{ok:!0,document:Rs.applyPatch(structuredClone(e),[t],!0,!1).newDocument}}catch{return{ok:!1}}}function gv(e,t){let n=structuredClone(e),r=0,o=0;for(let s of Ql(t)){let a=Kl(n,s);if(a.ok){n=a.document;continue}if(s.op==="replace"){let c=Kl(n,{...s,op:"add"});if(c.ok){n=c.document,r+=1;continue}}o+=1}let i=n;return{document:{metadata:typeof i.metadata=="object"&&i.metadata!==null?i.metadata:{},body:typeof i.body=="string"?i.body:e.body},convertedReplaceToAdd:r,skippedOps:o}}function hv(e){let t=fv(e);if(t.length===1)return t[0];let n=oo(e);return n.ok&&n.item_hash_version!==void 0?n.item_hash_version:t.length===0?1:nt}function bv(e,t,n=t.patch){let r=Zl(e,n);if(r.ok)return{next:r.document,patch:n,repaired:C(n)!==C(t.patch),converted:0,skipped:0};let o=gv(e,n);return{next:o.document,patch:Rs.compare(e,o.document),repaired:!0,converted:o.convertedReplaceToAdd,skipped:o.skippedOps}}function wv(e,t,n){return bv(e,t,n.projectPatch?.(t,e))}function ZN(e,t=hv(e),n={}){let r=e.findIndex(m=>eu(m.item_hash_version));if(r>=0)throw new TypeError(`unsupported_item_hash_version:${String(e[r]?.item_hash_version)}:entry_${r+1}`);let o=Yl(),i=[],s=[],a=0,c=0,d=0,l=0,u,f=t!==1||e.some(m=>m.item_hash_version!==void 0);for(let m=0;m<e.length;m+=1){let p=e[m];_v(p,m);let _=wv(o,p,n),{next:y,patch:b,repaired:E,converted:M,skipped:X}=_;d+=M,l+=X,c+=Number(E);let J=Xl(o,y,t,p);u===void 0||n.continuousHashSurface!==!0?u=[J.pairIndex,J.beforeIndex,J.afterIndex,Math.min(u??0,J.beforeHashes.length-1)].find(j_=>j_>=0):u=Math.min(u,J.beforeHashes.length-1);let Pc=J.beforeHashes[u],$c=J.afterHashes[u],yi=Pc!==p.before_hash||$c!==p.after_hash;yi&&(a+=1);let At={...p,patch:b,before_hash:Pc,after_hash:$c};f?At.item_hash_version=t:delete At.item_hash_version;let M_=At.item_hash_version!==p.item_hash_version;(yi||E||M_)&&(At=nu(p,At,{retainOriginalPatch:E})),i.push(At),s.push({index:m+1,rehashed:yi,patch_repaired:E,converted_replace_to_add:M,skipped_ops:X}),o=y}return{entries:i,finalDocument:o,entriesRehashed:a,entriesPatchRepaired:c,convertedReplaceToAdd:d,skippedOps:l,details:s,itemHashVersion:t,explicitItemHashVersion:f}}function eD(e){return e.length===0?"":`${e.map(t=>JSON.stringify(t)).join(`
15
+ `)}
16
+ `}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3c2c29c0-0034-54d4-9dbd-2e9af047784e")}catch{}})();var nD=1,vv=["docs_add","files_add","history:author-acknowledge","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","normalize","release","test_run_track","tests_add","tests_remove","tests_update","update_audit","update_ownership_bypass"],Ev=["append","cancel","claim","close","comment_add","create","learning_add","note_add","reopen"],Ov=new Set(vv),Sv=new Set(Ev),kv=new Set(["actual_result","affected_version","assignee","blocked_by","blocked_reason","close_reason","confidence","customer_impact","definition_of_ready","dependencies","docs","environment","expected_result","files","fixed_version","goal","impact","learnings","notes","objective","order","outcome","parent","release","reminders","reporter","repro_steps","resolution","reviewer","severity","sprint","tests","test_runs","unblock_note","updated_at","value","why_now"]);function Av(e){let t=e.path.split("/").filter(Boolean);return t[0]==="metadata"||t[0]==="front_matter"?t[1]:t[0]==="body"?"body":void 0}function zt(e){return e.event_class==="substantive"||e.event_class==="maintenance"?e.event_class:Ov.has(e.op)?"maintenance":Sv.has(e.op)||e.op!=="update"?"substantive":Array.isArray(e.patch)&&e.patch.length>0&&e.patch.every(t=>{let n=Av(t);return n!==void 0&&kv.has(n)})?"maintenance":"substantive"}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="812b558d-59f3-58d6-b04e-6a4f8689e866")}catch{}})();function ou(e){let t=process.emitWarning;process.emitWarning=(n,...r)=>{n==="SQLite is an experimental feature and might change at any time"&&r[0]==="ExperimentalWarning"||Reflect.apply(t,process,[n,...r])};try{return e(["node","sqlite"].join(":")).DatabaseSync??null}catch{return null}finally{process.emitWarning=t}}function iu(e,t){let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=22?ou(t):null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c5f096f6-4af4-568e-89ef-1aa0a8718973")}catch{}})();var Tv="history-event-index.sqlite",Ls="7",Cv=8,au=32,_u="history-event-index",Rv="history-event-index:append:",xv=5e3,Fs=300,yu=3e4,Nv="history-event-index-invalidation",Dv="history-event-index-invalidations",Pv=Fs*2*1e3,Ne=Symbol("history-index-changed"),rt=new Map;function it(e){return N.join(e,"runtime",Tv)}function gu(e){return N.join(e,"runtime","history-event-index-repair-deferred")}async function hu(e){try{let t=Number(await T.readFile(gu(e),"utf8")),n=Date.now()-t;return n>=0&&n<xv}catch{return!1}}async function cu(e){try{await T.writeFile(gu(e),`${Date.now()}
17
+ `)}catch{}}function Nn(e){return N.join(e,"runtime",Dv)}async function lo(e){let t=await T.readdir(Nn(e)).catch(n=>{if(q(n))return[];throw n});return{pending:t.filter(n=>n.endsWith(".pending")).sort(),committed:t.filter(n=>n.endsWith(".committed")).sort()}}async function du(e){let t=await lo(e);return{pending:(await Promise.all(t.pending.map(async n=>{let r=/^(\d+)-(unknown|\d+)-(\d+)-.+\.pending$/u.exec(n);if(r!==null){let o=r[2];if(await Rn({pid:Number(r[1]),...o==="unknown"?{}:{process_start_identity:o}},Math.max(0,Date.now()-Number(r[3])),Pv))return n}return await T.rm(N.join(Nn(e),n),{force:!0}),null}))).filter(n=>n!==null),committed:t.committed}}async function $s(e,t,n=yu){let r=await xn(e,Nv,Fs,`history-event-index-invalidation:${process.pid}`,!1,!1,n,n===0?{maxWaitMs:0}:void 0);try{return await t()}finally{await r()}}async function $v(e){let t=Nn(e);await T.mkdir(t,{recursive:!0});let n=js(),r=await Cn(),o=N.join(t,`${r.pid}-${r.process_start_identity??"unknown"}-${Date.now()}-${n}.pending`);return await T.writeFile(o,`pending
18
+ `,{flag:"wx"}),{pendingPath:o,committedPath:N.join(t,`${n}.committed`)}}function Mv(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}async function uo(e){try{await T.rm(it(e),{force:!0})}catch{}}async function Ns(e,t){let n=Nn(e);await T.mkdir(n,{recursive:!0}),await T.writeFile(N.join(n,`${js()}${t?".contended":""}.committed`),`committed
19
+ `,{flag:"wx"}),t||await uo(e)}function fo(e){return e.committed.some(t=>t.endsWith(".contended.committed"))}function Ms(e,t){let n;try{return n=new t(it(e)),n.exec("PRAGMA busy_timeout = 0"),n.exec("BEGIN EXCLUSIVE"),!1}catch(r){return ot(r)}finally{n?.close()}}async function lu(e,t){return t.pending.length>0||await pu(e,_u,Rv)}async function bu(e,t,n=yu,r="rebuild"){let o=await xn(e,_u,Fs,`history-event-index:${r}:${process.pid}`,!1,!1,n,n===0?{maxWaitMs:0}:void 0);try{return await t()}finally{await o()}}async function wu(e,t,n=!1){let r=N.join(e,"history"),o=await T.readdir(r,{withFileTypes:!0}).catch(u=>{if(typeof u=="object"&&u!==null&&"code"in u&&u.code==="ENOENT")return[];throw u}),i=rt.get(e)??{streams:new Map,ordered_events:[]},s=new Map(i.streams),a=i.ordered_events,c=new Set,d=!rt.has(e);for(let u of o.filter(f=>f.isFile()&&f.name.endsWith(".jsonl")).sort((f,m)=>f.name.localeCompare(m.name))){let f=u.name.slice(0,-6);c.add(f);let m=N.join(r,u.name);if(!Ds(f,t))continue;let p=await Lv(m,f,s.get(f),n);p!==void 0&&(s.set(f,p),d=!0)}for(let u of s.keys())c.has(u)||(s.delete(u),d=!0);d&&(a=[...s.values()].flatMap(u=>u.events).sort(Us));let l={streams:s,ordered_events:a};if(rt.delete(e),rt.set(e,l),rt.size>Cv){let u=rt.keys().next().value;rt.delete(u)}return{events:l.ordered_events.filter(u=>Ds(u.stream_id,t)).map(u=>jv(u,n)),stream_receipts:new Map([...l.streams].filter(([u])=>Ds(u,t)).map(([u,f])=>[u,{byte_size:f.byte_size,content_hash:f.signature}]))}}function jv(e,t){return t||e.recorded_entry===void 0?e:{stream_id:e.stream_id,stream_offset:e.stream_offset,entry:e.entry}}function Ds(e,t){return!t?.length||t.includes(e)}async function Lv(e,t,n,r){if(!r&&n!==void 0&&n.byte_size===(await T.stat(e)).size){let o=co("sha256").update(await T.readFile(e)).digest("hex");if(n.signature===o)return}return Fv(e,t,r)}async function Fv(e,t,n){let r=await no(e,t);if(n){let i=oo(r.entries);if(!i.ok)throw new h(`Authoritative history integrity verification failed for ${t}.`,g.GENERIC_FAILURE,{code:"event_history_integrity_failed",why:i.errors.join(", "),nextSteps:[`Run pm history ${t} --verify to inspect the authoritative chain before retrying.`]})}let o=r.raw_bytes??new Uint8Array;return{signature:co("sha256").update(o).digest("hex"),byte_size:o.byteLength,events:vu(r.entries,t).map((i,s)=>({stream_id:t,stream_offset:s,entry:i,...n?{recorded_entry:r.entries[s]}:{}}))}}async function Uv(e,t){return vu((await no(e,t)).entries,t)}function vu(e,t){for(let[n,r]of e.entries())if(typeof r.ts!="string"||!Dt(r.ts.trim()))throw new h(`History for ${t} contains an invalid or sub-millisecond timestamp at line ${n+1}. Repair or restore the history stream and retry.`,g.GENERIC_FAILURE,{code:"history_timestamp_invalid"});return e.map(n=>({...n,ts:new Date(n.ts.trim()).toISOString()}))}var Ps;function po(){return Ps!==void 0||(Ps=iu(process.versions.node,Iv(import.meta.url))),Ps}function zv(e){e.exec(`
20
+ PRAGMA journal_mode = OFF;
21
+ PRAGMA synchronous = OFF;
22
+ CREATE TABLE metadata (
23
+ key TEXT PRIMARY KEY,
24
+ value TEXT NOT NULL
25
+ ) STRICT;
26
+ CREATE TABLE events (
27
+ stream_id TEXT NOT NULL,
28
+ stream_offset INTEGER NOT NULL,
29
+ ts TEXT NOT NULL,
30
+ author TEXT NOT NULL,
31
+ agent_harness TEXT,
32
+ agent_instance TEXT,
33
+ op TEXT NOT NULL,
34
+ event_class TEXT NOT NULL CHECK(event_class IN ('substantive', 'maintenance')),
35
+ entry_json TEXT NOT NULL,
36
+ PRIMARY KEY(stream_id, stream_offset)
37
+ ) STRICT;
38
+ CREATE TABLE streams (
39
+ stream_id TEXT PRIMARY KEY,
40
+ byte_size INTEGER NOT NULL CHECK(byte_size >= 0),
41
+ content_hash TEXT NOT NULL
42
+ ) STRICT;
43
+ CREATE INDEX events_order
44
+ ON events(ts, stream_id, stream_offset);
45
+ CREATE INDEX events_op_order
46
+ ON events(op, ts, stream_id, stream_offset);
47
+ CREATE INDEX events_class_stream_order
48
+ ON events(event_class, stream_id, ts, stream_offset);
49
+ CREATE INDEX events_author_order
50
+ ON events(author, ts, stream_id, stream_offset);
51
+ CREATE INDEX events_harness_order
52
+ ON events(agent_harness, ts, stream_id, stream_offset);
53
+ CREATE INDEX events_instance_order
54
+ ON events(agent_instance, ts, stream_id, stream_offset);
55
+ `),e.prepare("INSERT INTO metadata(key, value) VALUES ('version', ?)").run(Ls)}function Eu(e,t){let n={...t.entry,ts:new Date(t.entry.ts.trim()).toISOString()};e.prepare(`INSERT INTO events(
56
+ stream_id, stream_offset, ts, author, agent_harness,
57
+ agent_instance, op, event_class, entry_json
58
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(t.stream_id,t.stream_offset,n.ts,n.author,n.agent_harness??null,n.agent_instance??null,n.op,zt(n),JSON.stringify(n))}function Ou(e){let t=JSON.parse(String(e.entry_json));return typeof t.ts!="string"||!Dt(t.ts.trim())?null:{stream_id:String(e.stream_id),stream_offset:Number(e.stream_offset),entry:{...t,ts:new Date(t.ts.trim()).toISOString()}}}function Su(e,t,n){e.prepare(`INSERT INTO streams(stream_id, byte_size, content_hash) VALUES (?, ?, ?)
59
+ ON CONFLICT(stream_id) DO UPDATE SET byte_size = excluded.byte_size, content_hash = excluded.content_hash`).run(t,n.byte_size,n.content_hash)}async function Hv(e,t={}){let n=po();return n?bu(e,async()=>{let r;try{r=await $s(e,()=>du(e),t.lockWaitMs)}catch(a){if(a instanceof h&&a.code==="lock_conflict")return!1;throw a}if(r.pending.length>0||fo(r)&&Ms(e,n))return!1;let o=it(e);await T.mkdir(N.dirname(o),{recursive:!0});let i=`${o}.${js()}.tmp`,s;try{s=new n(i),zv(s),s.exec("BEGIN IMMEDIATE");let a=await wu(e);await Vv(s,a),s.exec("COMMIT"),s.close(),s=void 0;let c=await $s(e,async()=>{let d=await du(e);return d.pending.length>0||!Mv(r.committed,d.committed)||fo(d)&&Ms(e,n)?!1:(await T.rm(o,{force:!0}),await T.rename(i,o),!0)},t.lockWaitMs);return c&&await Promise.all(r.committed.map(d=>T.rm(N.join(Nn(e),d),{force:!0}))),c||(await cu(e),await T.rm(i,{force:!0})),c}catch(a){throw await cu(e),s?.close(),await T.rm(i,{force:!0}),a}},t.lockWaitMs):!1}async function Vv(e,t){let n=0;for(let r of t.events)Eu(e,r),++n%500===0&&await su();for(let[r,o]of t.stream_receipts)Su(e,r,o),++n%500===0&&await su()}function so(e,t){return!t||t.length===0||t.includes(e)}function Us(e,t){return e.entry.ts.localeCompare(t.entry.ts)||e.stream_id.localeCompare(t.stream_id)||e.stream_offset-t.stream_offset}function mo(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():e}function qv(e,t){if(t.after_ts!==void 0&&t.after_stream_id!==void 0&&t.after_stream_offset!==void 0){if(Us(e,{stream_id:t.after_stream_id,stream_offset:t.after_stream_offset,entry:{...e.entry,ts:mo(t.after_ts)}})<=0)return!1}else if(t.since_ts!==void 0&&e.entry.ts<mo(t.since_ts))return!1;return!0}function Bv(e,t){return!t.harnesses||t.harnesses.length===0||t.harnesses.includes(e.entry.agent_harness??"")?!0:e.entry.agent_harness===void 0&&(t.harness_alias_authors??[]).includes(e.entry.author)}function Wv(e,t){return!qv(e,t)||!so(e.entry.op,t.ops)||!so(e.entry.author,t.authors)||!so(e.entry.agent_instance??"",t.agent_instances)||!so(e.stream_id,t.stream_ids)||!Bv(e,t)?!1:(t.provenance??[]).every(n=>{let r=e.entry.agent_provenance?.[n.dimension]?.value;return r!==void 0&&n.values.includes(r)})}async function Gv(e,t){let n=Math.max(0,Math.floor(t.limit)),r=await wu(e,t.stream_ids,t.verify),o=r.events.filter(i=>Wv(i,t)).slice(0,n+1);return{events:o.slice(0,t.limit),has_more:o.length>t.limit,...t.verify?{verified_streams:r.stream_receipts.size}:{}}}async function Kv(e,t){let n=e.prepare("SELECT byte_size, content_hash FROM streams WHERE stream_id = ?").get(N.basename(t,".jsonl")),r=0;try{r=(await T.stat(t)).size}catch(i){if(!q(i))throw i}if(Number(n?.byte_size??0)!==r)return!1;let o=await Hs(N.dirname(N.dirname(t)),N.basename(t,".jsonl"));return n===void 0?o?.byte_size===0:o?.content_hash===n.content_hash}async function ku(e,t,n){let r=N.dirname(N.dirname(e)),o=po(),i=!1,s=async()=>{await n(),i=!0};if(!o){await uu(r,s);return}try{await bu(r,async()=>{let a=it(r);try{await T.access(a)}catch{await s();return}let c;try{if(c=new o(a),c.prepare("SELECT value FROM metadata WHERE key = 'version'").get()?.value!==Ls)throw new TypeError("Unsupported history event index version");if(!await Kv(c,e))throw new TypeError("Stale history event index append base")}catch(l){if(c?.close(),ot(l))throw l;await Ns(r,!0),await s();return}try{c.exec("PRAGMA busy_timeout = 0"),c.exec("BEGIN IMMEDIATE")}catch(l){if(c.close(),ot(l)||!(l instanceof Error)||l.code!=="ERR_SQLITE_ERROR")throw l;await Ns(r,!1),await s();return}let d=!1;try{await s(),d=!0;let l=N.basename(e,".jsonl"),u=c.prepare("SELECT COALESCE(MAX(stream_offset), -1) + 1 AS value FROM events WHERE stream_id = ?").get(l);Eu(c,{stream_id:l,stream_offset:Number(u.value),entry:t}),Su(c,l,await Hs(r,l)),c.exec("COMMIT"),c.close()}catch(l){if(c?.close(),!d)throw l;await Ns(r,ot(l))}},0,"append")}catch(a){if(i){await uo(r);return}if(!Xv(a))throw a;await uu(r,s,ot(a))}}async function uu(e,t,n=!1){let r=!1,o;try{await $s(e,async()=>{let i=n||fo(await lo(e)),s=await $v(e);o=s.pendingPath;try{await t(),r=!0}catch(a){throw await T.rm(s.pendingPath,{force:!0}),a}await T.rename(s.pendingPath,i?s.committedPath.replace(/\.committed$/u,".contended.committed"):s.committedPath),i||await uo(e)})}catch(i){if(r){await uo(e);try{await T.rm(o,{force:!0})}catch{}return}throw i}}async function zs(e){await T.rm(it(N.dirname(N.dirname(e))),{force:!0})}function ao(e,t,n,r){!r||r.length===0||(e.push(`${n} IN (${r.map(()=>"?").join(", ")})`),t.push(...r))}function Yv(e,t,n,r){if(!n||n.length===0)return;let o=n.map(()=>"?").join(", "),i=r??[];if(i.length>0){e.push(`(agent_harness IN (${o}) OR (agent_harness IS NULL AND author IN (${i.map(()=>"?").join(", ")})))`),t.push(...n,...i);return}e.push(`agent_harness IN (${o})`),t.push(...n)}async function Au(e,t,n,r){let o;try{let i=await lo(e);if(await lu(e,i))return Ne;let s=await fu(e);if(i.committed.length>0)return fo(i)&&Ms(e,t)?Ne:null;if(o=new t(it(e),{readOnly:!0}),o.exec("BEGIN"),o.prepare("SELECT value FROM metadata WHERE key = 'version'").get()?.value!==Ls)return null;let a=r(o);if(a===null)return null;let c=Jv(o,n),d=o;o=void 0,d.close();let l=await Zv([...c.keys()],e,n),u=await Qv(c,e,l),f=await lo(e);return f.committed.length>0||await lu(e,f)||s!==await fu(e)?Ne:u?a:null}catch(i){return ot(i)?Ne:null}finally{o?.close()}}function ot(e){return typeof e=="object"&&e!==null&&"errcode"in e&&[5,6].includes(e.errcode)}function Xv(e){return ot(e)||e instanceof h&&e.code==="lock_conflict"}function Jv(e,t){let n=new Map,r=t&&t.length>0?[...new Set(t)]:void 0;if(r===void 0)for(let o of e.prepare("SELECT stream_id, byte_size, content_hash FROM streams").all())n.set(String(o.stream_id),{byte_size:Number(o.byte_size),content_hash:String(o.content_hash)});else for(let o=0;o<r.length;o+=500){let i=r.slice(o,o+500);for(let s of e.prepare(`SELECT stream_id, byte_size, content_hash FROM streams WHERE stream_id IN (${i.map(()=>"?").join(", ")})`).all(...i))n.set(String(s.stream_id),{byte_size:Number(s.byte_size),content_hash:String(s.content_hash)})}return n}async function fu(e){let t=await T.stat(it(e),{bigint:!0});return[t.dev,t.ino,t.size,t.mtimeNs,t.ctimeNs].join(":")}async function bD(e,t){if(t.verify)return{result:await Gv(e,t),repair_needed:!1};let n=po();if(!n)return{result:null,repair_needed:!1};let r=[],o=[];if(t.after_ts!==void 0&&t.after_stream_id!==void 0&&t.after_stream_offset!==void 0){r.push("(ts > ? OR (ts = ? AND stream_id > ?) OR (ts = ? AND stream_id = ? AND stream_offset > ?))");let a=mo(t.after_ts);o.push(a,a,t.after_stream_id,a,t.after_stream_id,t.after_stream_offset)}else t.since_ts!==void 0&&(r.push("ts >= ?"),o.push(mo(t.since_ts)));ao(r,o,"op",t.ops),ao(r,o,"author",t.authors),Yv(r,o,t.harnesses,t.harness_alias_authors),ao(r,o,"agent_instance",t.agent_instances);for(let a of t.provenance??[])r.push(`json_extract(entry_json, '$.agent_provenance.${a.dimension}.value') IN (${a.values.map(()=>"?").join(", ")})`),o.push(...a.values);ao(r,o,"stream_id",t.stream_ids);let i=r.length===0?"":` WHERE ${r.join(" AND ")}`,s=await Au(e,n,t.stream_ids,a=>{let c=a.prepare(`SELECT stream_id, stream_offset, entry_json
60
+ FROM events${i}
61
+ ORDER BY ts, stream_id, stream_offset
62
+ LIMIT ?`).all(...o,Math.max(0,Math.floor(t.limit))+1),d=c.slice(0,t.limit).map(Ou);return d.includes(null)?null:{events:d,has_more:c.length>t.limit}});return{result:s===Ne?null:s,repair_needed:s===null&&!await hu(e)}}function Iu(e,t){let n=Object.create(null);for(let r of e){if(!t.has(r.stream_id)||zt(r.entry)!=="substantive")continue;let o=n[r.stream_id];(o===void 0||Us(o,r)<0)&&(n[r.stream_id]=r)}return n}async function Hs(e,t){if(N.basename(t)!==t)return null;try{let n=N.join(e,"history",`${t}.jsonl`),r=await T.stat(n),o=await T.readFile(n);return r.size!==o.length?null:{byte_size:o.length,content_hash:co("sha256").update(o).digest("hex")}}catch(n){if(q(n))return{byte_size:0,content_hash:co("sha256").digest("hex")};throw n}}async function Qv(e,t,n){for(let r=0;r<n.length;r+=au){let o=n.slice(r,r+au),i=await Promise.all(o.map(s=>Hs(t,s)));for(let[s,a]of i.entries()){if(a===null)return!1;let c=o[s],d=e.get(c);if(!(a.byte_size===0&&d===void 0)&&(a.byte_size!==d?.byte_size||a.content_hash!==d.content_hash))return!1}}return!0}async function Zv(e,t,n){if(n&&n.length>0)return[...new Set(n.filter(o=>o.trim().length>0))];let r=await T.readdir(N.join(t,"history"),{withFileTypes:!0}).then(o=>o.filter(i=>i.isFile()&&i.name.endsWith(".jsonl")).map(i=>i.name.slice(0,-6))).catch(o=>{if(q(o))return[];throw o});return[...new Set([...e,...r])]}async function mu(e,t,n,r){return e?Au(t,e,n,o=>{let i=[];for(let s=0;s<n.length;s+=500){let a=n.slice(s,s+500),c=o.prepare(`SELECT stream_id, stream_offset, entry_json
63
+ FROM (
64
+ SELECT stream_id, stream_offset, entry_json,
65
+ ROW_NUMBER() OVER (
66
+ PARTITION BY stream_id
67
+ ORDER BY ts DESC, stream_offset DESC
68
+ ) AS recency_rank
69
+ FROM events
70
+ WHERE event_class = 'substantive'
71
+ AND stream_id IN (${a.map(()=>"?").join(", ")})
72
+ )
73
+ WHERE recency_rank = 1`).all(...a).map(Ou);if(c.includes(null))return null;i.push(...c)}return Iu(i,r)}):null}async function wD(e,t){let n=[...new Set(t.filter(a=>a.trim().length>0&&N.basename(a)===a))];if(n.length===0)return{};let r=new Set(n),o=po(),i=await mu(o,e,n,r);if(i!==null&&i!==Ne)return i;if(o&&i!==Ne&&!await hu(e))try{if(await Hv(e,{lockWaitMs:0})){let a=await mu(o,e,n,r);if(a!==null&&a!==Ne)return a}}catch{}let s=[];return await Promise.all(n.map(async a=>{let c=N.join(e,"history",`${a}.jsonl`);(await Uv(c,a).catch(d=>{if(d instanceof h&&d.code==="history_timestamp_invalid")return[];throw d})).forEach((d,l)=>{s.push({stream_id:a,stream_offset:l,entry:d})})})),Iu(s,r)}import Da from"node:fs/promises";import Qt from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="32aa20df-edf7-543d-b733-841130466f00")}catch{}})();var eE="__pm_suppress_host_output",Vs="@unbrained/pm-cli:suppress-host-output:v1";function Tu(e){return e===void 0?{__pm_suppress_host_output:Vs}:{__pm_suppress_host_output:Vs,result:e}}function _o(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[eE]===Vs}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="21f779fe-fa2c-50d1-893d-8c6d47fbc56a")}catch{}})();function tE(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function De(e,t){let n=e.slice(0,t),r=n.charCodeAt(n.length-1),o=e.charCodeAt(n.length);return r>=55296&&r<=56319&&o>=56320&&o<=57343?n.slice(0,-1):n}var Dn=240,Cu=/\u2026\[\+([1-9]\d*) chars\]$/u;function yo(e){if(e.length<=Dn)return e;let t=Cu.exec(e);if(t!==null&&t.index<=Dn)return e;let n=De(e,Dn);return`${n}\u2026[+${e.length-n.length} chars]`}function OD(e){let t=Cu.exec(e.trimEnd());return t?Number(t[1]):void 0}function Pn(e){return e==="cursor"||e.endsWith("_cursor")}function go(e){return e.includes("\u2026")}function SD(e){return tE(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function kD(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let n=new Set(e),r=new Set(t),o=0;for(let s of n)r.has(s)&&(o+=1);let i=new Set([...n,...r]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="975b7c1d-e398-586a-bd50-b3bf0528d24a")}catch{}})();var ho="changed_fields",nE="changed_field_count",qs="rows",rE=new Set(["apply","rollback"]),Du=new Set(["deleted","would_delete"]),Ru=256,xu={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function oE(e,t){if(!K(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(xu,e.action)?xu[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return K(s)&&K(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let r=e[n.at(-1)],o=$u(r);return t.idOnly?o:!t.compactEnvelope&&t.changedFields!=="compact"?null:{...e,...t.compactEnvelope?{...o,changed_field_count:new Set(n.flatMap(i=>e[i].changed_fields)).size}:{},...Object.fromEntries(n.map(i=>[i,$n(e[i],t)]))}}function Nu(e){return typeof e!="string"||e.length<=Ru?e:`${De(e,Ru-1)}\u2026`}function iE(e){if(!K(e))return null;let t={...e};return t.reason=Nu(t.reason),K(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,Nu(r)]))),t}function K(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Pu(e){let t=e[ho];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==ho&&(n[r]=o);return n[nE]=t.length,n}function sE(e){return"item"in e&&Array.isArray(e[ho])}function aE(e){return typeof e.mode=="string"&&rE.has(e.mode)&&Array.isArray(e[qs])}function cE(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[qs]=t,n}function $u(e){if(!K(e))return null;let t=K(e.item)?e.item:K(e.plan)?e.plan:null;if(t===null)return null;let n=typeof t.id=="string"?t.id:void 0,r=typeof e.outcome=="string"&&Du.has(e.outcome)?e.outcome:typeof t.status=="string"?t.status:void 0;return n?r?{id:n,status:r,...typeof e.deleted=="boolean"?{deleted:e.deleted}:{}}:{id:n}:null}function dE(e,t){if(!K(e))return null;if(K(e.plan)&&K(e.mutation_receipt)&&e.mutation_receipt.kind==="plan_mutation"&&e.mutation_receipt.id===e.plan.id&&e.mutation_receipt.action===e.action)return e.mutation_receipt;if(!t||!K(e.item)||typeof e.item.id!="string")return null;let n=e[ho];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&Du.has(e.outcome)?{status:e.outcome}:typeof e.item.status=="string"?{status:e.item.status}:{},...typeof e.deleted=="boolean"?{deleted:e.deleted}:{},...typeof e.previous_status=="string"?{previous_status:e.previous_status}:{},changed_field_count:n.length};return lE(e,e.item,r),r}function lE(e,t,n){let r=typeof e.close_reason=="string"?e.close_reason:typeof t.close_reason=="string"?t.close_reason:void 0;r!==void 0&&(n.close_reason=r);let o=iE(e.recurrence);o!==null&&(n.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(n.warnings=e.warnings);for(let i of["recovery","follow_up","handoff","completion","start","takeover"])K(e[i])&&(n[i]=e[i]);if(typeof e.claimed_by=="string"||typeof e.released_by=="string")for(let i of["claimed_by","released_by","previous_assignee","forced","skipped","available","attempts","start_refused","suggestions"])Object.hasOwn(e,i)&&(n[i]=e[i])}function uE(e){let t=aE(e)?e[qs]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!K(o))return o;let i=Pu(o);return i?(n=!0,i):o});return n?{projected:cE(e,r),changed:!0}:{projected:e,changed:!1}}function $n(e,t={}){let n=oE(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=$u(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=dE(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!K(e))return e;let r=!1,o=e,i=sE(e)?Pu(e):null;i!==null&&(o=i,r=!0);let s=uE(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{stripVTControlCharacters as fE}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1f8bc22d-02b9-522a-a2cd-0d34bf6e3ec3")}catch{}})();var mE=6,pE=480,_E="--full-output",Mu=["stdout","stderr"];function re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ju(e,t,n){if(e==="test"){let r=new Set;return zu(Lu(t,n,r),r,"run_results")}return e==="test-all"?yE(t,n):t}function yE(e,t){if(!re(e)||!Array.isArray(e.results)||!e.results.every(re))return e;let n=new Set,r=e.results.map(s=>Lu(s,t,n)),o=Fu(r.filter(s=>Array.isArray(s.run_results)&&s.run_results.length>0)),i={...e,...o===void 0?{}:{execution_context:o},results:o===void 0?r:r.map(s=>{let{execution_context:a,...c}=s;return c})};return zu(i,n,"results.run_results")}function Lu(e,t,n){if(!re(e)||!Array.isArray(e.run_results))return e;let r=e.run_results;if(!r.every(re))return e;let o=bE(e,r),i=o&&!t.fullContext,s=o?r.map(u=>gE(u,t,n)):r,a=Fu(s),c=a===void 0?s:s.map(u=>hE(u,t,n)),{failure_categories:d,...l}=e;return{...t.lean&&i?l:e,...a===void 0?{}:{execution_context:a},run_results:c}}function gE(e,t,n){let r=t.fullOutput?e:EE(e,n);return t.fullContext?r:{...r,execution_context:wE(r.execution_context)}}function hE(e,t,n){let{execution_context:r,stdout:o,stderr:i,...s}=e;if(!t.lean||t.fullOutput||e.status!=="passed"||vE(e))return{...s,stdout:o,stderr:i};let{stdout_omitted_bytes:a,stderr_omitted_bytes:c,...d}=s;for(let[l,u]of[["stdout",o],["stderr",i]])typeof u=="string"&&u.length>0&&n.add(l);return d}function Fu(e){let t=e.map(r=>r.execution_context).filter(r=>r!==void 0);if(t.length!==e.length||t.length===0)return;let n=JSON.stringify(t[0]);return t.every(r=>JSON.stringify(r)===n)?t[0]:void 0}function bE(e,t){if(e.ok!==!0||t.length===0)return!1;let n=o=>o.status==="passed"&&re(o.execution_context)&&o.execution_context.mismatch_detected===!1;if(!t.every(n))return!1;let r=e.failure_categories;return!(re(r)&&Object.values(r).some(o=>o!==0))}function wE(e){let t=re(e.trust)?e.trust:{};return{pm_context_mode:e.pm_context_mode,workspace_context_mode:e.workspace_context_mode,mismatch_detected:!1,...typeof t.trusted=="boolean"?{trusted:t.trusted}:{},...t.reason===void 0?{}:{trust_reason:t.reason},restore_with:"not retained; a run with --check-context reports the full context"}}function vE(e){return Uu(e)||re(e.execution_context)&&e.execution_context.mismatch_detected===!0}function Uu(e){let t=e.execution_context;return re(t)?t.trusted===!1||re(t.trust)&&t.trust.trusted===!1:!1}function EE(e,t){if(Uu(e))return e;let n=e;for(let r of Mu){let o=e[r];if(typeof o!="string")continue;let i=OE(o);i!==o&&(t.add(r),n={...n,[r]:i,[`${r}_omitted_bytes`]:Buffer.byteLength(o,"utf8")-Buffer.byteLength(i,"utf8")})}return n}function OE(e){if(e.trim().length===0)return e.length<=2?e:"";let t=fE(e).split(`
74
+ `).map(r=>r.replace(/\r+$/u,"").split("\r").at(-1).trimEnd()).filter(r=>r.trim().length>0).slice(-mE),n=Array.from(t.join(`
75
+ `)).slice(-pE).join("");return e.endsWith(`
76
+ `)&&n.length>0?`${n}
77
+ `:n}function zu(e,t,n){if(t.size===0||!re(e))return e;let r=re(e.omission_receipt)?e.omission_receipt:{},o=[...Array.isArray(r.omitted_field_groups)?r.omitted_field_groups:[],...Mu.filter(i=>t.has(i)).map(i=>({name:`${n}.${i}`,restore_with:_E}))];return{...e,omission_receipt:{...r,has_omissions:!0,omitted_field_group_count:o.length,omitted_field_groups:o}}}import{AsyncLocalStorage as PO}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="447bb510-051a-5dce-8b7d-e27f4ca781f4")}catch{}})();var bo={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},wo=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),st=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","learnings","files","docs","stats","aggregate","duplicates","package-catalog","package-manage","comments-audit","assurance"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="17ae377d-20c2-5e45-825a-48a79c6c7601")}catch{}})();function j(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return t}function B(e,t){if(t!==void 0&&typeof t!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function $(e,t){if(t!==void 0&&(typeof t!="string"||t.trim().length===0))throw new TypeError(`${e} must be a non-empty string when provided`)}function Hu(e,t){if(t===void 0)return;let n=r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean";if(Array.isArray(t)){for(let[r,o]of t.entries())if(!n(o))throw new TypeError(`${e}[${r}] must be a string, number, or boolean`);return}if(!n(t))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function at(e,t){if(t!==void 0){if(!Array.isArray(t))throw new TypeError(`${e} must be an array of non-empty strings when provided`);for(let[n,r]of t.entries())if(typeof r!="string"||r.trim().length===0)throw new TypeError(`${e}[${n}] must be a non-empty string`)}}function Mn(e,t){if(at(e,t),!Array.isArray(t))return[];let n=[],r=new Set;for(let o of t){let i=o.trim();i.length===0||r.has(i)||(r.add(i),n.push(i))}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="095ea29d-eda3-5287-b54d-8a961658f7bc")}catch{}})();function Vu(e,t="",n=""){if(e===void 0)return;if(Ht(t)||Ht(n))throw new TypeError("Native pm commands and actions cannot declare read_output");let r=j("registerCommand definition.read_output",e);if(Object.keys(r).some(s=>s!=="row_keys")||!Array.isArray(r.row_keys))throw new TypeError("registerCommand definition.read_output requires only row_keys: string[]");let o=Array.from(r.row_keys),i=new Set(["__proto__","constructor","prototype","row_contract","read_output","read_session","omission_receipt","output_budget_truncation"]);if(o.some(s=>typeof s!="string"||!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*$/u.test(s)||s.split(".").some(a=>i.has(a))))throw new TypeError("registerCommand definition.read_output row_keys must be safe dot-delimited property paths");if(new Set(o).size!==o.length||o.some(s=>o.some(a=>a.startsWith(`${s}.`))))throw new TypeError("registerCommand definition.read_output row_keys must be unique and non-overlapping");return Object.freeze({row_keys:Object.freeze([...o])})}function Ht(e){let t=e.trim().toLowerCase().replace(/\s+/gu,"-");return Ct.includes(t)||st.includes(t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a65d6520-0e6f-5627-a4dd-bd455c2db0fa")}catch{}})();var Wu=new WeakMap;function FD(e,t){Wu.set(e,new Set(t))}var vo='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',SE={context:{row_keys:["high_level","low_level"],fields:"supported"},get:{row_keys:["children"],fields:"supported"},list:{row_keys:["items"],fields:"supported"},next:{row_keys:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],fields:"unsupported"},search:{row_keys:["items"],fields:"supported"},activity:{row_keys:["activity_digest","compact_activity","provenance_activity","activity"],fields:"unsupported"},history:{row_keys:["compact_history","provenance_history","history","diff"],fields:"unsupported"},deps:{row_keys:["graph.nodes","graph.edges","context.nodes","context.edges"],fields:"unsupported"},health:{row_keys:["checks"],fields:"unsupported"},aggregate:{row_keys:["groups"],fields:"unsupported"},duplicates:{row_keys:["clusters"],fields:"unsupported"},stats:{row_keys:["by_type","by_status"],fields:"unsupported"},comments:{row_keys:["comments"],fields:"unsupported"},notes:{row_keys:["notes"],fields:"unsupported"},learnings:{row_keys:["learnings"],fields:"unsupported"},files:{row_keys:["files"],fields:"unsupported"},docs:{row_keys:["docs"],fields:"unsupported"},validate:{row_keys:["checks","warnings"],fields:"unsupported"},contracts:{row_keys:["command_summaries","commands"],fields:"unsupported"}},kE=[{command:"activity",complete_mode:"full",omissions_by_mode:{digest:[{name:"event_rows",restore_with:"--raw"}],compact:[{name:"provenance",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}},{command:"history",complete_mode:"full",omissions_by_mode:{compact:[{name:"raw_history",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}}];function UD(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,g.USAGE)}function ue(e,t=new Set){let n=e.filter(r=>!t.has(r.name)).map(r=>({...r}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function zD(e,t){let n=kE.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return ue([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return ue(r)}var AE=[{name:"hierarchy",restore_with:"--section hierarchy"},{name:"activity",restore_with:"--section activity"},{name:"progress",restore_with:"--section progress"},{name:"blockers",restore_with:"--section blockers"},{name:"recently_created",restore_with:"--section recently_created"},{name:"unparented",restore_with:"--section unparented"},{name:"files",restore_with:"--section files"},{name:"workload",restore_with:"--section workload"},{name:"staleness",restore_with:"--section staleness"},{name:"tests",restore_with:"--section tests"}];function W(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var IE=new Set([void 0,"tabular_when_uniform"]),TE=new Set(["collection","none"]),CE=new Set(["supported","unsupported"]);function qu(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(n=>typeof n=="string"&&n.length>0)&&new Set(e).size===e.length}function RE(e){return W(e)&&typeof e.command=="string"&&e.command.trim().length>0&&TE.has(e.row_kind)&&qu(e.row_keys,!0)&&(e.continuation_row_keys===void 0||qu(e.continuation_row_keys,!1))&&CE.has(e.fields)&&IE.has(e.toon_encoding)&&(e.row_kind==="collection"?e.row_keys.length>0&&typeof e.jq_selector=="string"&&e.jq_selector.trim().length>0:e.row_keys.length===0&&e.jq_selector===void 0)}var xE={ancestors:["ids"],descendants:["ids"],predecessors:["ids"],successors:["ids"],paths:["paths"],impact:["affected"],audit:["findings"],communities:["communities"],redundancy:["redundant"],dominators:["bottlenecks"],slack:["rows"],centrality:["rows"],articulation:["articulation_points","bridges"],plan:["steps"]},NE={context:["sections_included","high_level","low_level"],get:["item"],list:["items","projection"],next:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items","projection"],activity:["activity_digest","compact_activity","provenance_activity","activity"],history:["compact_history","provenance_history","history","diff"],deps:["tree","graph","projection"],health:["checks"],aggregate:["groups"],duplicates:["clusters"],stats:["totals","by_type","by_status"],comments:["comments"],notes:["notes"],learnings:["learnings"],files:["files"],docs:["docs"],validate:["checks","warnings"],contracts:["command_summaries","commands","selected"]};function DE(e,t){let n=e.trim().toLowerCase().split(/\s+/u,1)[0],r=n?.startsWith("list-")?"list":n;if(r==="graph"){let s=typeof t.subcommand=="string"?t.subcommand:"";if(s.length===0)return;let a=xE[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||W(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:vo}:{},toon_encoding:"tabular_when_uniform"}}let o=SE[r],i=NE[r];return o===void 0||i===void 0||!i.some(s=>Object.hasOwn(t,s))?void 0:(()=>{let s=o.row_keys.filter(a=>{let c=a.split(".").reduce((d,l)=>W(d)?d[l]:void 0,t);return Array.isArray(c)||W(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:vo}:{},toon_encoding:"tabular_when_uniform"}})()}function PE(e){if(!W(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;let t=e.projection.declared_field_groups,n=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(n))return;let r=t.filter(s=>W(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=n.filter(s=>typeof s=="string");if(r.length!==t.length||o.length!==n.length)return;let i=new Set(r.map(s=>s.name));if(!(i.size!==r.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return ue(r,new Set(o))}function $E(e){if(!Array.isArray(e.sections_included))return;let t=ue(AE,new Set(e.sections_included.filter(n=>typeof n=="string")));return W(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function ME(e,t,n){if(e==="dependency_provenance")return!1;let r=Gu(e);if(r!==void 0){let o=n[r.facet];return W(o)&&Object.hasOwn(o,r.member)}return Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&W(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&W(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function Gu(e){let t=e.indexOf(".");return t===-1?void 0:{facet:e.slice(0,t),member:e.slice(t+1)}}function jE(e){if(!W(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=Wu.get(e),i=a=>n.includes(a)||a==="body"||a==="dependency_provenance"?t:e,s=["body",...n,...r.slice(1),...o?.has("dependency_provenance")?["dependency_provenance"]:[],...o?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[],...[...o??[]].filter(a=>Gu(a)!==void 0)].filter(a=>o===void 0||o.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:a==="blockers"?"--full":a==="dependency_provenance"?"--fields dependencies":`--fields ${a}`}));return ue(s,new Set(s.flatMap(({name:a})=>ME(a,i(a),e)?[a]:[])))}function Bu(e){if(W(e.projection))return ue([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function LE(e){if(!W(e.projection))return ue([]);if(typeof e.projection.mode=="string")return ue([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function FE(e){if(!(!W(e.selected)||typeof e.selected.summary!="boolean"))return ue([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function UE(e,t){let n=PE(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return $E(t);if(r==="get")return jE(t);if(r==="list"||r.startsWith("list-"))return Bu(t);if(r==="search")return Bu(t)??ue([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return LE(t);if(r==="contracts")return FE(t)}function Ku(e,t){if(e===void 0||!W(t))return t;let n=UE(e,t),r=t.row_contract,o=RE(r)?r:DE(e,t),i=o!==void 0?{...t,row_contract:o}:Object.hasOwn(t,"row_contract")?Object.fromEntries(Object.entries(t).filter(([s])=>s!=="row_contract")):t;return W(i.omission_receipt)||n===void 0?i:{...i,omission_receipt:n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e1fd9abd-a586-5302-940e-eec2a3eb8641")}catch{}})();function Bs(e){let t=e.trim().toLowerCase().startsWith("extension:"),n=e.trim().toLowerCase().replace(/^extension:/u,"");if(Ht(n))return;let r=Xu()?.commands??[],o=[...r].reverse().find(s=>s.command===n)?.command??(t?void 0:r.find(s=>s.action===n)?.command),i=[...r].reverse().find(s=>s.command===o);return i===void 0||Ht(i.command)||Ht(i.action)?void 0:i}function zE(e){let t=Bs(e);return t?.read_output===void 0?void 0:t}function HE(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new h("Read-only extension commands must return a structured object.",g.USAGE,{code:"extension_read_output_invalid"});for(let n of e.row_keys){let r=t;for(let o of n.split("."))r=typeof r=="object"&&r!==null&&Object.hasOwn(r,o)?Reflect.get(r,o):void 0;if(r===null||typeof r!="object")throw new h(`Read-only extension result is missing declared row collection ${n}.`,g.USAGE,{code:"extension_read_output_invalid",required:`Return ${n} as an object or array (an empty collection is valid); an output_format service renders the compact receipt from it.`,why:"A command that declares read_output.row_keys promises those row collections, and pm checks them before projection, budgeting or custom formatting."})}}function Yu(e,t){let n=zE(e),r=n?.read_output;return r===void 0?t:(HE(r,t),{...t,row_contract:{command:`extension:${n.command}`,row_kind:r.row_keys.length>0?"collection":"none",row_keys:[...r.row_keys],fields:"supported",...r.row_keys.length>0?{jq_selector:vo}:{},toon_encoding:"tabular_when_uniform"}})}import{createHash as _O}from"node:crypto";import{createHash as cO}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="040fff2e-c66f-5091-9ea8-7dcdaf6e203b")}catch{}})();var Ws={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded","--after"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},learnings:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},Gs=new Set(["--collapse","--fields","--section"]),Eo=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded --output-budget unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function Oo(e){return e.slice(2).replaceAll("-","_")}function Ju(e,t={}){let n=e==="package catalog"||e==="packages catalog"||e==="package-catalog"||(e==="package"||e==="packages"||e==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":e==="package manage"||e==="package-manage"?"package-manage":e.split(" ")[0],r=n.startsWith("list-")?"list":n==="ctx"?"context":n;return st.includes(r)?r:void 0}function Ks(e){return new Map((Ws[e]?.include??[]).filter(t=>!Gs.has(t)&&Eo[t]===void 0).map(t=>[Oo(t),Ys(t)]))}function Ys(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f539ecb5-2f49-5867-96c7-48eddb81a628")}catch{}})();var VE=new Set(["applied_bound","completeness","budget_retention_policy","continuation_contract","continuation_kind","continuation_path","filters","omission_receipt","output_budget_truncation","projection","read_output","read_session","row_contract","sorting"]);function z(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Qu(e,t){let n=e;for(let r of t.split("."))if(Array.isArray(n)){if(!/^\d+$/u.test(r))return;n=n[Number(r)]}else{if(!z(n))return;n=n[r]}return n}function Xs(e,t,n){let r=t.split("."),o=(i,s)=>{if(s===r.length)return n;let a=r[s];if(Array.isArray(i)){let d=Number(a),l=[...i];return l[d]=o(i[d],s+1),l}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function Js(e,t,n,r){let o=Vt(e).find(a=>a.path===t);if(!o)return e;let i=Array.isArray(o.value)?o.value.slice(n,r):Object.fromEntries(Object.entries(o.value).slice(n,r)),s=Xs(e,t,i);return z(s.summary)&&z(s.summary.focus_row_states)&&typeof s.summary.focus_row_states[t]=="string"&&(s.summary={...s.summary,focus_row_states:{...s.summary.focus_row_states,[t]:s.summary.focus_row_states[t].slice(n,r)}}),Fn(s),s}function ko(e){let t=e.row_contract;return z(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Object.entries(e).filter(([,n])=>Array.isArray(n)).map(([n])=>n)}function qE(e){let t=e.row_contract;return z(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):ko(e)}function Pe(e){return ko(e).flatMap(t=>{let n=Qu(e,t);return Array.isArray(n)||z(n)?[{path:t,value:n}]:[]})}function Vt(e){return qE(e).flatMap(t=>{let n=Qu(e,t);return Array.isArray(n)||z(n)?[{path:t,value:n}]:[]})}function jn(e){let t=Pe(e),n=new Set(t.map(o=>o.path)),r=(o,i)=>{if(Array.isArray(o)){n.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>r(s,`${i}.${a}`));return}if(z(o))for(let[s,a]of Object.entries(o))i.length===0&&VE.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function qt(e){return Pe(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function Ln(e,t){let n=e;for(let r of Pe(n)){let o=Array.isArray(r.value)?r.value.map((i,s)=>t(i,r.path,s)):Object.fromEntries(Object.entries(r.value).map(([i,s],a)=>[i,t(s,r.path,a)]));n=Xs(n,r.path,o)}return n}function Zu(e,t,n=()=>!1){let r=e,o=!1;for(let i of Pe(r)){let s=Array.isArray(i.value)?i.value:Object.entries(i.value);if(s.length<=t)continue;o=!0;let a=n(i.path)?s.length-t:0,c=s.slice(a,a+t),d=Array.isArray(i.value)?c:Object.fromEntries(c);r=Xs(r,i.path,d)}return{result:r,truncated:o}}var ef=["high_level","low_level","blocked_fallback"];function So(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function JD(e,t){if(!z(e.summary)||!z(e.summary.returned_focus))return;let n=new Map(t.map(r=>[r.id,r]));e.summary={...e.summary,focus_row_states:Object.fromEntries(ef.map(r=>[r,Array.isArray(e[r])?e[r].filter(z).map(o=>So(n.get(o.id)??o)).join(""):""]))}}function BE(e,t){if(e!==void 0){if(typeof e!="string"||e.length!==t||!/^[iIoO]*$/u.test(e))throw new TypeError("Context focus classification receipt must contain one i/I/o/O code per delivered record");return e}}function WE(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(z):[],i=BE(r[n],o.length)??o.map(So).join(""),s=new Map(o.flatMap((d,l)=>d.id===void 0?[]:[[d.id,i[l]]])),a=Array.isArray(e[n])?e[n].filter(z):[],c=!1;return{states:a.map((d,l)=>{let u=s.get(d.id)??(d.id===void 0?i[l]:void 0)??So(d);return u!==So(d)&&(c=!0),u}).join(""),needsStates:c}}function GE(e,t){typeof e.count=="number"&&(e.count_only===!0||t.count_only===!0?typeof t.count=="number"&&(e.count=t.count):Array.isArray(e.items)&&(e.count=e.items.length))}function Fn(e,t=e){if(GE(e,t),!z(e.summary)||!z(e.summary.returned_focus))return;let n={...e.summary},r=z(t.summary)&&z(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=ef.map(c=>({key:c,...WE(e,t,c,r)})),i=Object.fromEntries(o.map(({key:c,states:d})=>[c,d])),s=o.some(c=>c.needsStates),a=Object.values(i).join("");typeof n.high_level=="number"&&(n.high_level=Array.isArray(e.high_level)?e.high_level.length:0),typeof n.low_level=="number"&&(n.low_level=Array.isArray(e.low_level)?e.low_level.length:0),n.returned_focus={active_items:a.length,in_progress:[...a].filter(c=>c.toLowerCase()==="i").length,open:[...a].filter(c=>c.toLowerCase()==="o").length,blocked:[...a].filter(c=>c===c.toUpperCase()).length},s?n.focus_row_states=i:delete n.focus_row_states,e.summary=n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="21a8bc0d-7750-5528-9893-f13d295424fb")}catch{}})();var ea=8,KE=64,YE=5,XE=4,tf=100;function nf(e,t,n){if(e!=="get"||!Qs(n.item)||["fields","outputInclude","output_include","outputCursor","output_cursor"].some(c=>t[c]!==void 0)||t.full===!0||t.tree===!0||t.depth!==void 0&&t.depth!=="standard")return;let r=n.item,o=["linked","claim_state","schedule"],i=o.filter(c=>Object.hasOwn(n,c)),s=Object.fromEntries(Object.entries(n).filter(([c])=>!o.includes(c)));s.item=Object.fromEntries(Object.entries(r).filter(([c])=>c!=="body")),Object.hasOwn(r,"body")&&i.push("body");let a=[...Qs(n.omission_receipt)&&Array.isArray(n.omission_receipt.omitted_field_groups)?n.omission_receipt.omitted_field_groups:[],...i.map(c=>({name:c,restore_with:`--fields ${c}`}))];return s.omission_receipt={has_omissions:a.length>0,omitted_field_group_count:a.length,omitted_field_groups:a},s}function Un(e){let t=Math.trunc(e.effective_budget_tokens),n=Math.trunc(e.measured_result_tokens);if(!Number.isSafeInteger(t)||t<=0||!Number.isSafeInteger(n)||n<=0)return{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"};let r=Math.max(t+1,n),o=Math.ceil(r*YE/XE),i=Math.ceil(o/tf)*tf;return Number.isSafeInteger(i)?{output_budget:i,recovery_budget_multiplier:i/t,rule_version:"v1"}:{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"}}function Bt(e,t,n=!1){let r=Object.getOwnPropertyDescriptor(e,"row_contract");r&&(n||r.enumerable===!1)&&Object.defineProperty(t,"row_contract",{...r,enumerable:!1})}function Wt(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}var $e;function Ao(e,t,n){let r=$e;$e={format:e,render:t};try{return n()}finally{$e=r}}function je(e,t){let n=t===void 0?JSON.stringify(e):$e!==void 0&&$e.format===t?JE($e,e):Io(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function JE(e,t){$e=void 0;try{return e.render(t)}finally{$e=e}}function Qs(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Zs(e,t,n=!1){return typeof e=="string"?n?e:(e.length>Dn&&(t.compacted=!0),yo(e)):Array.isArray(e)?e.map(r=>Zs(r,t,n)):Qs(e)?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,Zs(o,t,n||r==="focus_row_states"||typeof o=="string"&&Pn(r))])):e}function Me(e,t,n){let r=t.estimated_tokens;for(let o=0;o<ea;o+=1){t.estimated_tokens=r;let i=je(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function QE(e,t){return jn(e).filter(n=>(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length)>Math.max(1,t.get(n.path)??0)).map(n=>({collection:n,length:Array.isArray(n.value)?n.value.length:Object.keys(n.value).length})).sort((n,r)=>r.length-n.length||n.collection.path.localeCompare(r.collection.path))[0]?.collection}function ZE(e,t,n,r,o,i,s){for(let a=0;a<KE;a+=1){if(i?.(e),Me(e,t,o),t.estimated_tokens<=n)return;let c=QE(e,r);if(!c)return;let d=Math.max(1,r.get(c.path)??0),l=Array.isArray(c.value)?[...c.value]:Object.entries(c.value),u=s(c.path),f=y=>{let b=u?l.length-y:0;if(Array.isArray(c.value)){c.value.length=y;for(let E=0;E<y;E+=1)c.value[E]=l[b+E]}else{for(let E of Object.keys(c.value))delete c.value[E];Object.defineProperties(c.value,Object.getOwnPropertyDescriptors(Object.fromEntries(l.slice(b,b+y))))}typeof e.count=="number"&&(e.count=qt(e)),typeof e.returned_count=="number"&&(e.returned_count=qt(e)),c.path==="items"&&(e.applied_limit=y),i?.(e),Me(e,t,o)};t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],c.path])].sort((y,b)=>y.localeCompare(b)),e.has_more=!0,e.truncated=!0;let m=d,p=l.length-1,_=d;for(;m<=p;){let y=Math.floor((m+p)/2);f(y),t.estimated_tokens<=n?(_=y,m=y+1):p=y-1}f(_)}}function rf(e,t,n,r=new Map,o,i,s=!1,a=()=>!1){let c={compacted:!1},d=Object.fromEntries(Object.entries(e).map(([l,u])=>[l,Zs(u,c,s&&l==="diff"||typeof u=="string"&&Pn(l))]));return Bt(e,d),t.strings_compacted=c.compacted,d.read_output=t,ZE(d,t,n,r,o,i,a),Me(d,t,o),d}import{stripVTControlCharacters as e0}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="493a0675-0114-5b93-b3b4-5bd895ac691f")}catch{}})();var t0=["full","compact","brief","summary","counts"],aP=["mutation","read","discovery","governance"],sf=["error","warning","validation_summary","recovery_bundle"],n0=["full","omit_explanation","limit_collections","compact_recovery","action_only"],r0=new Set(["append","claim","close","close-many","close-task","comments","config","copy","create","delete","docs","event","files","focus","history-author-acknowledge","history-compact","history-redact","history-repair","init","item","learnings","meet","notes","pause-task","release","remind","restore","schema","start-task","update","update-many"]),o0=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),i0=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),s0={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},a0=3,c0=2,d0=192,l0={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},u0=sf.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:l0[e],minimum_max_estimated_tokens:d0,degradation_ladder:n0,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),f0=new Map(u0.map(e=>[e.diagnostic_class,e]));function m0(e){let[t=""]=mn(e).split(/\s+/u);return r0.has(t)?"mutation":o0.has(t)?"discovery":i0.has(t)?"governance":"read"}function af(e,t=m0(e)){let n=e.trim().replace(/\s+/gu," ");if(n.length===0)throw new TypeError("command must be a non-empty command path");let r=s0[t];return p0({command:n,budget_class:t,default_max_estimated_tokens:r,default_max_estimated_tokens_by_format:{toon:r,json:Math.ceil(r*a0/c0)},degradation_ladder:t0,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function p0(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,n]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var _0=Sr.map(e=>af(e)),y0=new Map(_0.map(e=>[e.command,e]));function cf(e,t={}){let n=e.trim().replace(/\s+/gu," "),[r]=mn(n).split(" "),o=y0.get(r);return o?{...o,command:n}:t.generateFallback?af(n):null}function dt(e){return Math.ceil(Math.max(0,e)/4)}function df(e){let t=f0.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${sf.join(", ")}`);return t}function Le(e){return dt(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function g0(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ta(e){if(!g0(e))return;let t={};for(let n of["suggested_retry","suggested_retry_args","next_best_command","allowed_values","candidate_commands","missing","missing_required_fields","option_scope","retry_after_ms","waited_ms","owner_handoffs"]){let r=e[n];Array.isArray(r)?t[n]=n==="suggested_retry_args"?r:r.slice(0,3):r!==void 0&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}function h0(e,t){return typeof e!="string"||e.length<=t?e:`${De(e,Math.max(1,t-3))}...`}function ct(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;let n="...",r=Array.from(e),o=0,i=r.length;for(;o<i;){let s=Math.ceil((o+i)/2),a=`${r.slice(0,s).join("")}${n}`;Buffer.byteLength(a,"utf8")<=t?o=s:i=s-1}return`${r.slice(0,o).join("")}${n}`}function lf(e){let t={};for(let n of["code","required","recovery","next_steps","exit_code","type","title","detail","why","examples"])Object.hasOwn(e,n)&&e[n]!==void 0&&(t[n]=e[n]);for(let[n,r]of Object.entries(e))n!=="__proto__"&&!Object.hasOwn(t,n)&&(t[n]=r);return t}var b0=new Set(["limit_collections","compact_recovery","action_only"]),w0=new Set(["compact_recovery","action_only"]);function v0(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:h0(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},n=ta(e.recovery);return n!==void 0?t.recovery=n:Array.isArray(e.next_steps)&&(t.next_steps=e.next_steps.slice(0,1)),e.exit_code!==void 0&&(t.exit_code=e.exit_code),e.type!==void 0&&(t.type=e.type),t}function E0(e,t){let n=structuredClone(e);if(t!=="full"&&(delete n.why,delete n.examples),b0.has(t))for(let[r,o]of Object.entries(n))Array.isArray(o)&&(n[r]=o.slice(0,3));if(w0.has(t)){let r=ta(n.recovery);r?n.recovery=r:delete n.recovery}return t!=="action_only"?lf(n):v0(n)}function Gt(e,t){let n={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let r=0;r<4;r+=1){let o=Le(n),i=n.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return n}function O0(e,t,n){let r=Gt(e,t);for(let i of["recovery","exit_code"])Le(r)<=n||e[i]===void 0||(delete e[i],r=Gt(e,t));let o=40;for(;Le(r)>n&&o>4;)o-=4,e.code=ct(String(e.code),o),e.required=ct(String(e.required),o),r=Gt(e,t);return r}function S0(e,t){let n=e.diagnostic_output,{estimated_tokens:r,...o}=n,i=o.omitted_fields.slice(0,8).map(u=>ct(u,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=ta(e.recovery),c=a&&Le(a)<=48?a:void 0,d={code:ct(String(e.code),320),required:ct(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},l=Gt(d,s);for(;Le(l)>t&&s.omitted_fields.length>0;)s.omitted_fields.pop(),s.omitted_fields_overflow_count=o.omitted_fields.length-s.omitted_fields.length,l=Gt(d,s);return l=O0(d,s,t),l}function cP(e,t={}){let n=e,r=t.diagnosticClass??"error",o=df(r),i=t.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.json,a=Le(n),c=Object.keys(n);if(a<=s)return lf(structuredClone(n));let d;for(let[l,u]of o.degradation_ladder.entries()){let f=E0(n,u),m=c.filter(_=>!Object.hasOwn(f,_)),p=Gt(f,{diagnostic_class:r,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:l>0,degradation_steps:o.degradation_ladder.slice(0,l+1),omitted_fields:m});if(d=p,Le(p)<=s)break}return Le(d)>s&&(d=S0(d,s)),d}function of(e){return e0(e).replace(/\r\n/gu,`
78
+ `).replace(/[^\P{Cc}\n]/gu," ")}function dP(e,t,n={}){let r=n.diagnosticClass??"error",o=df(r),i=n.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.text,a=of(e),c=dt(Buffer.byteLength(a,"utf8")),d=c>s,l=`What is required:
79
+ `,u=`
80
+
81
+ ${ct(a.trimStart().split(/\r?\n/u,1)[0].trim(),320)}
82
+
83
+ Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,f=of(t).trim()||"Inspect the diagnostic code and retry with corrected input.",m=Math.max(1,s*4-Buffer.byteLength(`${l}${u}`,"utf8")),p=d?`${l}${ct(f,m)}${u}`:a;return{output:p,diagnostic_output:{diagnostic_class:r,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:dt(Buffer.byteLength(p,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}var na=Object.freeze({required:"Adjust command input or tracker state and retry.",why:Object.freeze(["pm enforces explicit, deterministic contracts for data and command semantics.","Commander validates CLI contracts before execution.","Unexpected runtime failures can occur from environment or extension-level issues.","Validation protects data consistency and deterministic behavior across commands.","Required options define command intent and enforce deterministic write contracts."]),examples:Object.freeze(["pm --help","pm <command> --help"])});function lP(e){return e?.trim()===na.required}function uP(e){let t=e?.trim();return t!==void 0&&na.why.includes(t)}function fP(e){return(e??[]).filter(t=>!na.examples.includes(t.trim()))}var mP=Object.freeze(["attempted_command","normalized_args","provided_fields"]);function pP(e){if(!e)return;let{attempted_command:t,normalized_args:n,provided_fields:r,...o}=e;return Object.values(o).some(i=>i!==void 0)?o:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3a351971-6cfb-55eb-a266-3fec0af9eaa4")}catch{}})();var oe=Object.freeze({comments:Object.freeze({paths:Object.freeze(["comments"]),total_key:"total_count"}),notes:Object.freeze({paths:Object.freeze(["notes"]),total_key:"total_count",delivered_row_counters:Object.freeze([Object.freeze({key:"structured_event_count",field:"format",equals:"json"})])}),learnings:Object.freeze({paths:Object.freeze(["learnings"]),total_key:"total_count"})});function lt(e,t){return e===void 0?!1:(Object.hasOwn(oe,e)?oe[e]:void 0)?.paths.includes(t)===!0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="24a8de41-54f9-5b59-8e58-7ac924ba6e08")}catch{}})();function vP(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"&&"context_ref"in e&&typeof e.context_ref=="string"&&e.context_ref.startsWith("session:")&&e.context_ref.endsWith(`:${e.id}`)}var ra=256,oa=1e4,k0=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,uf=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,A0=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),I0=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&k0.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=ra,reason:`token_budget must be a safe integer of at least ${ra}.`},{valid:e=>Number.isSafeInteger(e.spent_tokens)&&e.spent_tokens>=0&&e.spent_tokens<=e.token_budget,reason:"spent_tokens must be a non-negative safe integer no larger than token_budget."},{valid:e=>Array.isArray(e.seen_item_ids)&&e.seen_item_ids.length<=oa&&e.seen_item_ids.every(t=>typeof t=="string"&&uf.test(t)),reason:`seen_item_ids must contain at most ${oa} portable item identifiers.`}];function Co(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function To(e){throw new h(`--output-session ${e}`,g.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function Ro(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{To("must be a valid JSON object.")}Co(t)||To("must be a JSON object.");let n=Object.keys(t).filter(i=>!A0.has(i));n.length>0&&To(`contains unknown field "${n.sort()[0]}".`);let r=I0.find(i=>!i.valid(t));r!==void 0&&To(r.reason);let o=[...new Set(t.seen_item_ids)].sort();return{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:o}}function ff(e){if(Co(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:Co(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function T0(e){let t=new Set,n=0,r=Pe(e),o=new Set(r.map(({path:s})=>s)),i=Object.entries(e).flatMap(([s,a])=>Array.isArray(a)&&!o.has(s)?[{path:s,value:a}]:[]);for(let s of[...r,...i]){let a=Array.isArray(s.value)?s.value:Object.values(s.value);for(let c of a){if(!Co(c))continue;if(typeof c.context_ref=="string"){n+=1;continue}let d=ff(c);d!==void 0&&uf.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:n}}function mf(e,t){let n=new Set(t.seen_item_ids);return Ln(e,r=>{let o=ff(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function ia(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=T0(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,oa-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),d=s.length-a.length,l={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:r.size,...d===0?{}:{seen_item_overflow_count:d},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --depth brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:c}},u={...e,read_session:l},f=_=>{l.spent_this_call_tokens=_,l.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,_),l.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+l.charged_this_call_tokens),l.remaining_tokens=Math.max(0,t.token_budget-l.spent_total_tokens),l.exhausted=l.remaining_tokens<ra,l.next_state.spent_tokens=l.spent_total_tokens},m=0,p=0;for(let _=0;_<8;_+=1){f(m);let y=je(u,n);if(y===m)return u;p=Math.max(p,y),m=y}return f(p),u}function pf(e){return Math.max(0,e.token_budget-e.spent_tokens)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1cc0fcb7-2aaa-5233-bdfd-4b4d0fb3e9c1")}catch{}})();var zn=Symbol.for("pm.readOutputInvocationProvenance");function OP(e,t){return Reflect.set(e,zn,{canonical_include_modes:[...t],explicit_legacy_aliases:[],sdk_invocation_observed:!0}),e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2a596392-747a-5b55-854d-1e80964468d3")}catch{}})();var ut=["include","amount","cost","encoding"],vf=["canonical","legacy","intent","default"],Vn=bo,VP=Object.freeze(ut.map(e=>Vn[e])),qP=wo;function C0(e,t){let n=Eo[e];if(n!==void 0)return n;let r=t==="include"?Gs.has(e)?"<csv>":Oo(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${Vn[t]} ${r}.`}function Ef(e){let t=Ws[e]??{},n=Object.freeze(Object.fromEntries(ut.map(r=>[r,Object.freeze({dimension:r,canonical_option:Vn[r],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[r]??[]).map(o=>Object.freeze({flag:o,semantics:Eo[o]===void 0?"replacement":"behavior_preserving",migration_hint:C0(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:vf,budget_retention_policy:e==="assurance"?"verdict_priority":Object.hasOwn(oe,e)?"ordered_suffix":"ordered_prefix",projection_modes:Object.freeze([...Ks(e).keys()])})}var R0=Object.freeze(st.map(Ef)),x0=new Map(R0.map(e=>[e.command,e]));function Fe(e,t={}){let n=mn(e.trim().toLowerCase()),r=Bs(n);return r!==void 0?r.read_output===void 0?void 0:`extension:${r.command}`:Ju(n,t)}var N0=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],_f={comments:["add","body","comment","text","stdin","file","edit","delete"],notes:["add","note","text","addJson","stdin","file","edit","delete"],learnings:["add","learning","text","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function D0(e){return N0.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var P0=[{keys:["outputInclude","output_include"],valid:e=>Hn(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||Kt(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||Kt(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(Ro(e),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:e=>typeof e=="string"&&e.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}],BP="read_output_mutation_conflict",Of=[{flag:"--output-include",keys:["outputInclude","output_include"]},{flag:"--output-limit",keys:["outputLimit","output_limit"]},{flag:"--output-budget",keys:["outputBudget","output_budget"]},{flag:"--output-session",keys:["outputSession","output_session"]},{flag:"--output-cursor",keys:["outputCursor","output_cursor"]},{flag:"--output-row-contract",keys:["outputRowContract","output_row_contract"]}],WP=Of.map(({flag:e})=>e);function $0(e,t,n){let r=Of.filter(({keys:a})=>a.some(c=>t[c]!==void 0)),o=r.map(({flag:a})=>a),i=r.flatMap(({keys:a})=>a.filter(c=>t[c]!==void 0)),s=o.join(", ");return new h(`Universal output controls (${s}) cannot be combined with a ${e} mutation; nothing was written.`,g.USAGE,{code:"read_output_mutation_conflict",field:o[0],details:{surface:e,output_controls:o,output_option_keys:i,mutation_options:[...n]},required:`Retry the ${e} mutation without ${s}. To bound or page the result, read it with those controls in a separate call after the write.`,why:"Universal output controls shape a read. A mutation returns its own bounded receipt, so the controls have nothing to shape and the write is refused before it runs.",examples:[...M0[e]]})}var M0={comments:['pm comments <id> --add "<text>"',"pm comments <id> --output-limit 5"],notes:['pm notes <id> --add "<text>"',"pm notes <id> --output-limit 5"],learnings:['pm learnings <id> --add "<text>"',"pm learnings <id> --output-limit 5"],files:["pm files <id> --add path=<path>","pm files <id> --output-limit 5"],docs:["pm docs <id> --add path=<path>","pm docs <id> --output-limit 5"],"package-catalog":["pm package install <source> --project","pm package catalog --output-limit 5"]};function GP(e,t){let n=t.outputFormat??t.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new h("--output-format must be toon or json.",g.USAGE);if(!D0(t))return;let r=Fe(e,t);if(!r)throw new h(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,g.USAGE);if(Object.hasOwn(_f,r)){let o=r,i=_f[o].filter(s=>t[s]!==void 0&&t[s]!==!1);if(i.length>0)throw $0(o,t,i)}for(let o of P0){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new h(o.message,g.USAGE)}}function Sf(e){let t=Fe(e);return t?Ks(t):new Map}function j0(e,t,n){let r=Hn(t)??[],o=Sf(e),i=[],s=[],a=n,c=a[zn],d=new Set(c?.canonical_include_modes??[]),l=new Set(c?.explicit_legacy_aliases??[]);for(let m of r){let p=o.get(m);if(p===void 0){i.push(m);continue}let _=`--${m.replaceAll("_","-")}`;aa(sa(n,_))&&l.add(_),n[p]=!0,s.push(m),d.add(m)}let u=Fe(e)==="get"?i.filter(m=>m!=="item"):[],f=u.length>0;return f&&(n.fields=[...new Set([...Hn(n.fields)??[],...u])].join(","),d.add("fields")),(s.length>0||f)&&(a[zn]={canonical_include_modes:[...d],explicit_legacy_aliases:[...l],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function KP(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=j0(e,n,t);if(o.length===0)return;let i=r.length>0?r.join(","):void 0;t.outputInclude=i,Object.hasOwn(t,"output_include")&&(t.output_include=i)}function sa(e,t){let n=Ys(t);if(Object.hasOwn(e,n))return e[n];let r=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,r))return e[r];if(t==="--no-truncate"&&e.truncate===!1)return!0}function aa(e){return e!==void 0&&e!==!1&&e!==null}function Hn(e){let t=(Array.isArray(e)?e:[e]).flatMap(n=>typeof n=="string"?n.split(","):[]).map(n=>n.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function Kt(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/u.test(e.trim())?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function L0(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=sa(t,o.flag),s={value:i,flag:o.flag};if(aa(i)&&n(s))return s}}function yf(e,t){let n=Hn(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:Hn(t.value)??[Oo(t.flag)]}}function gf(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=Kt(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;if(t.flag==="--no-truncate"||t.flag==="--unbounded")return{source:"legacy",value:"unbounded"};let r=Kt(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function hf(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=Kt(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let r=Kt(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function bf(e,t){if(e==="json"||e==="toon")return{source:"canonical",value:e};if(t)return t.flag==="--stream"||t.flag==="--follow"?{source:"legacy",value:"stream"}:t.value==="json"||t.value==="toon"?{source:"legacy",value:t.value}:void 0}function kf(e,t,n){if(!e)return!1;let r=new Set(e.explicit_legacy_aliases);if(e.cli_invocation_observed===!0||e.sdk_invocation_observed===!0)return!r.has(n);let o=new Set(e.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return t==="include"&&o.has(n)&&!r.has(n)}function F0(e,t,n,r){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||aa(sa(r,"--no-truncate"))&&!kf(n,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function U0(e,t){return ut.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[Vn[n]]:[])}function Af(e,t){let n=Fe(e,t);if(!n)return;let r=x0.get(n)??Ef(n),o=t[zn],i={include:b=>yf(void 0,b),amount:b=>gf(void 0,b),cost:b=>hf(void 0,b),encoding:b=>bf(void 0,b)},s=Object.fromEntries(ut.map(b=>[b,L0(r.dimensions[b],t,E=>i[b](E)!==void 0,E=>kf(o,b,E))])),a=ut.flatMap(b=>{let E=s[b];return E?[E.flag]:[]}),c=ut.flatMap(b=>{let E=s[b];return E?[r.dimensions[b].legacy_aliases.find(M=>M.flag===E.flag).migration_hint]:[]}),d=bf(t.outputFormat??t.output_format,s.encoding),l=yf(t.outputInclude??t.output_include,s.include),u=gf(t.outputLimit??t.output_limit,s.amount),f=hf(t.outputBudget??t.output_budget,s.cost),m=F0(e,s,o,t),p=cf(e,{generateFallback:!0}),_=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",y=f??(m?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:l,amount:u,cost:y,encoding:d,canonical_options_used:U0({include:l,amount:u,cost:y,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:vf}}function L(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var ca=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),z0=["collection_counts","notes_count","tests_count"];function If(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function H0(e){let t=L(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...z0.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!ca.has(o)).sort((o,i)=>o.localeCompare(i));return{item:t,itemFields:n,sections:r,valid:[...n,"item",...n.map(o=>`item.${o}`),...r]}}function V0(e,t){let n=H0(e),r=t.filter(l=>!n.valid.includes(l));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,g.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:n.itemFields.includes(l)?[l]:[]).filter((l,u,f)=>f.indexOf(l)===u);if(o&&i.length>0)throw new h("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",g.USAGE);let s=new Set(t.filter(l=>n.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>ca.has(l)||s.has(l)));o?a.item=n.item:i.length>0&&(a.item=If(n.item,i));let c=[...o?[]:i.length>0?n.itemFields.filter(l=>!i.includes(l)).map(l=>({name:`item.${l}`,restore_with:`--output-include item.${l}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(l=>!s.has(l)).map(l=>({name:l,restore_with:`--output-include ${l}`}))],d=[...L(a.omission_receipt)&&Array.isArray(a.omission_receipt.omitted_field_groups)?a.omission_receipt.omitted_field_groups:[],...c];return a.omission_receipt={has_omissions:d.length>0,omitted_field_group_count:d.length,omitted_field_groups:d},a}function wf(e){let t=0;return Ln({...e},n=>(L(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function q0(e,t,n,r){if(wf(t)===0||wf(n)>0)return;let o=[...Sf(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${r.join(", ")}. No selector matched any returned row field.${i}`,g.USAGE)}function B0(e,t,n){if(e==="get")return V0(t,n);let r=ko(t),o=n.flatMap(s=>r.flatMap(a=>s.startsWith(`${a}.`)?[s.slice(a.length+1)]:[])),i=n.some(s=>Object.hasOwn(t,s.split(".")[0])&&!r.some(a=>s.startsWith(`${a}.`)));if(r.length>0&&(!i||o.length>0)){let s={...t},a=o.length>0?o:n,c=Ln(s,d=>L(d)?If(d,a):d);return q0(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||ca.has(s)))}function W0(e,t,n,r){if(t==="unbounded")return e;let{result:o,truncated:i}=Zu(e,t,s=>lt(n,s));if(!i)return o;if(o.has_more=!0,o.truncated=!0,xf(o,n,[...r.entries()].flatMap(([s,a])=>a.rows>t?[{path:s,total_rows:a.totalRows}]:[])),typeof o.count=="number"){let s=L(o.projection)?o.projection.row_key:void 0;o.count=typeof s=="string"&&Array.isArray(o[s])?o[s].length:qt(o)}return typeof o.returned_count=="number"&&(o.returned_count=qt(o)),o.applied_bound={kind:"output_limit",source:"explicit",value:t},o}function G0(e){return ut.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(Vn[t]))}function xo(e,t,n,r){let o=ia(e,t,r);Bt(e,o);for(let i=0;i<8;i+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;Me(o,n,r);let c=o;o=ia(o,t,r),Bt(c,o);let d=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&d===a)return o}return o}function da(e,t){if(!L(e.read_output))return e;let n=Wt(t),r=e.read_output,o=Ro(t.outputSession??t.output_session);return o===void 0?(Me(e,r,n),e):xo(e,o,r,n)}function K0(e,t){if(e!=="validate")return t;let n=L(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(l=>L(l)&&l.name==="diagnostic_rows"))return t;let r=[...new Set(jn(t).map(({path:l})=>l).filter(l=>/^checks\.\d+\.details\./u.test(l)))],o=r.filter(l=>!r.some(u=>u!==l&&l.startsWith(`${u}.`)));if(o.length===0)return t;let i=L(t.row_contract)?t.row_contract:{},s=Array.isArray(i.row_keys)?i.row_keys.filter(l=>typeof l=="string"):[],a=Array.isArray(i.continuation_row_keys)?i.continuation_row_keys.filter(l=>typeof l=="string"):[],c=s.length>0?s:o,d=[...new Set(o)];return JSON.stringify(c)===JSON.stringify(s)&&JSON.stringify(d)===JSON.stringify(a)?t:{...t,row_contract:{...i,row_keys:c,continuation_row_keys:d,jq_selector:typeof i.jq_selector=="string"?i.jq_selector:".checks[].details"}}}function Y0(e,t){return e.include?.source==="canonical"&&!fe(t)}function X0(e,t,n,r,o){let i={...e};if(Y0(t,e)&&(i=B0(t.command,i,t.include.value)),t.command==="assurance"&&(i=Lf(i)),Fn(i,e),i=Ff(i,t.command,r),t.command==="history"&&r){let c=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([d])=>!c.includes(d)||d===r.path)),L(i.projection)&&(i.projection={...i.projection,row_key:r.path}),L(i.row_contract)){let d=i.row_contract;i.row_contract={...d,row_keys:[r.path],...Array.isArray(d.continuation_row_keys)?{continuation_row_keys:[r.path]}:{}}}i.count=Object.keys(i[r.path]).length}let s=e.count_only===!0?{...i,count_only:!0,count:e.count}:i,a=oO(i,e,t.command,r,o);return t.amount?.source==="canonical"&&(i=W0(i,t.amount.value,t.command,a.collectionsBeforeBudget),a.cursorContinuesExistingPage&&Df(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),Fn(i,s),Nf(i,t.command,a),{projected:n===void 0?i:mf(i,n),continuationState:a}}function J0(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default"||e.command==="context"&&e.cost.source==="legacy")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:pf(t)}]].sort((n,r)=>n.tokens-r.tokens)[0]}function Tf(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function Cf(e,t){return L(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function Q0(e,t,n){return e.command!=="next"||(t.tokenBudget??t.token_budget)===void 0?!1:!(L(n.context_intent)&&n.context_intent.command==="next"&&n.context_intent.within_budget===!0)}function Rf(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!Cf(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function Z0(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...Rf(r),precedence:e.precedence,...Tf(e),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...n===void 0?{omitted_result_estimated_tokens:o}:{}},a={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:s},c=n===void 0?a:xo(a,n,s,i);if(n===void 0&&Me(c,s,i),n!==void 0&&s.estimated_tokens>r.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",g.USAGE);return c}function eO(e,t,n){return e.command==="context"&&e.cost?.source==="legacy"&&!Cf(n,e.cost.value)||Q0(e,t,n)||t.outputRowContract===!0||t.output_row_contract===!0||e.canonical_options_used.includes("--output-include")||e.command==="list"&&e.canonical_options_used.length>0&&e.include?.value.includes("full")===!0}function tO(e,t,n,r,o){if(t!==void 0||fe(n)||eO(e,o,n))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(Pe(n).some(({value:s})=>(Array.isArray(s)?s.length:Object.keys(s).length)>i))return!1}return e.cost===void 0||e.cost.value==="unbounded"||e.cost.source==="legacy"&&e.command!=="context"||je(o.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,r)<=e.cost.value}function xf(e,t,n){let r=Object.hasOwn(oe,t)?oe[t]:void 0,o=n.find(i=>r?.paths.includes(i.path));r!==void 0&&o!==void 0&&typeof e[r.total_key]!="number"&&(e[r.total_key]=o.total_rows)}function Nf(e,t,n){let r=oe[t]?.paths[0];r!==void 0&&jf(e,t,n.producer,n.collectionsBeforeBudget.get(r)?.rows)}function nO(e,t,n,r){let o=n.backward?n.rows-r:n.baseOffset+r;return{path:t,cursor:la({command:e,path:t,offset:o,total_rows:n.totalRows,fingerprint:n.fingerprint,...n.backward?{direction:"backward"}:{}}),retained_rows:r,remaining_rows:n.backward?o:n.totalRows-o,total_rows:n.totalRows}}function rO(e,t,n,r,o,i,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map(Vt(e).map(p=>[p.path,Array.isArray(p.value)?p.value.length:Object.keys(p.value).length])),d=[...s.entries()].flatMap(([p,_])=>{let y=c.get(p);return y>=_.rows?[]:[nO(t.command,p,_,y)]}),l=d[0];xf(e,t.command,d);let u=l?"; page --output-cursor":"",f=r.source==="session"?`Truncated by the remaining ${r.tokens}-token session budget; start a new output session with a larger token_budget${u}.`:`${r.tokens}-token: raise --output-budget${u}`;n.migration_hints=[f,...t.migration_hints];let m=Un({effective_budget_tokens:r.tokens,measured_result_tokens:i});l&&!o&&(typeof e.next_cursor!="string"||e.continuation_kind==="output_cursor")&&(e.next_cursor=l.cursor),e.continuation_kind=o?"producer_cursor":l?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:r.source,budget_tokens:r.tokens,overridden_dimensions:a,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:o,continuation_available:d.length>0,recovery_budget_multiplier:l?1:m.recovery_budget_multiplier,continuations:d,restore_with:l?"recovery":`Retry with --output-budget ${m.output_budget} because no declared row collection can be continued.`,recovery:l?{cursor:l.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${m.output_budget}`,sdk:{outputBudget:m.output_budget},mcp:{outputBudget:m.output_budget}}}}function Df(e,t,n,r,o){if(typeof n!="string"||!Array.isArray(e.items))return!1;let i=e.items.length,s=t.length;if(i===0||i>=s)return!1;let a;try{a=ua(n)}catch{return!1}let c=a.after_index;if(c===void 0)return!1;let d=t[i-1];if(Object.prototype.toString.call(d)!=="[object Object]")return!1;let l=Reflect.get(d,"id");if(typeof l!="string"||l.length===0)return!1;let u=r?c-(s-i):c+o+i;return u<0?!1:(e.next_cursor=Bn(a.fingerprint,l,u,a.snapshot),!0)}function oO(e,t,n,r,o){let i=new Map(Vt(e).map(c=>{let d=Array.isArray(c.value)?c.value.length:Object.keys(c.value).length,l=r?.path===c.path,u=lt(n,c.path);return[c.path,{rows:d,totalRows:l?r.total_rows:d,baseOffset:l&&!u?r.offset:0,backward:u,fingerprint:l?r.fingerprint:No(c.path,c.value,n)}]})),s=typeof e.next_cursor=="string",a=r?.path==="items"?r.offset:0;return{collectionsBeforeBudget:i,originalItems:Array.isArray(t.items)?a>0?t.items.slice(a):t.items:[],originalItemOffset:a,cursorContinuesExistingPage:s,cursorSource:s?e.next_cursor:o.after,producer:t}}function iO(e,t,n,r,o,i,s,a,c,d){let l={...t,count_only:n},u=r.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(m=>L(m)&&m.verdict!=="pass").length:0,f=new Map;if(u>0&&f.set("assertions",u),r.command==="history"&&Array.isArray(e.diff))for(let m of jn(e))m.path.startsWith("diff.")&&f.set(m.path,Object.keys(m.value).length);return rf(e,o,i.tokens,f,d,m=>{Fn(m,l),Nf(m,r.command,a);let p=Df(m,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(rO(m,r,o,i,p,c,a.collectionsBeforeBudget),r.command==="history"&&L(m.projection)){m.has_more=typeof m.next_cursor=="string"||m.applied_bound?.kind==="output_limit";let _=m.projection.row_key;typeof _=="string"&&Array.isArray(m[_])&&(m.count=m[_].length)}s!==void 0&&Object.assign(m,xo(m,s,o,d))},r.command==="history"&&Array.isArray(e.diff),m=>lt(r.command,m))}function Pf(e,t,n){let r=Af(e,t);if(!r)return n;let o=Wt(t),i=Ro(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?qn(s):void 0,c=G0(r),d=K0(r.command,n);if(a===void 0&&tO(r,i,d,o,t))return d;let l=J0(r,i),u=X0(d,r,i,a,t),f=u.projected;Bt(f,f,t.outputRowContract===!1);let m=fe(f),p={contract_version:1,command:r.command,requested_dimensions:c,...Rf(l,f),precedence:r.precedence,...Tf(r),legacy_aliases_used:r.legacy_aliases_used,migration_hints:r.migration_hints,estimated_tokens:0,within_budget:!m,strings_compacted:!1,rows_compacted:!1,result_omitted:m};if(f.read_output=p,f=i===void 0?f:xo(f,i,p,o),Me(f,p,o),l!==void 0&&p.estimated_tokens>l.tokens){let _=nf(r.command,t,f);_!==void 0&&(p.applied_depth="brief",p.degradation_reason="output_budget_reached",Bt(f,_),f=da(_,t)),p.estimated_tokens>l.tokens&&(f=iO(f,f,d.count_only===!0,r,p,l,i,u.continuationState,p.estimated_tokens,o))}return l!==void 0&&p.estimated_tokens>l.tokens?Z0(r,c,i,l,p.estimated_tokens,o):f}function sO(e){return L(e)&&L(e.context_intent)&&e.context_intent.result_omitted===!0}function fe(e){return aO(e)||sO(e)}function aO(e){return L(e)&&L(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function $f(e,t){let n=t.outputFormat??t.output_format;if(n==="json"||n==="toon")return n;let r=Af(e,t)?.encoding;return r?.value==="json"||r?.value==="toon"?r.value:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e8cd9862-6b60-599e-9a19-b97fd7b1ce1f")}catch{}})();var dO=4096,lO=Object.freeze(["queue_draining","queue_entries","queue_exists","queue_high_retry_entries","queue_invalid_rows","queue_max_attempts","queue_rows_total","queue_size_bytes","pending_otel_spans","last_attempted_flush_at","last_failed_flush_at","last_otel_attempt_at","last_otel_failure_at","last_otel_success_at","last_successful_flush_at"]),Mf=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:lO}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function Yt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function jf(e,t,n=e,r){let o=Object.hasOwn(oe,t)?oe[t]:void 0;if(o?.delivered_row_counters===void 0)return;let i=o.paths[0],s=e[i],a=n[i];if(!Array.isArray(s)||!Array.isArray(a))return;let c=r??a.length,d=a.slice(Math.max(0,c-s.length),c);for(let l of o.delivered_row_counters)typeof e[l.key]=="number"&&(e[l.key]=d.filter(u=>Yt(u)&&u[l.field]===l.equals).length)}function Wn(e){return Array.isArray(e)?e.map(Wn):Yt(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Wn(n)])):e}function Uf(e,t){if(!Yt(e))return Wn(e);let n=typeof e.name=="string"?e.name:void 0,r=n!==void 0&&Object.hasOwn(t.ignored_detail_field_names_by_row,n)?t.ignored_detail_field_names_by_row[n]:void 0;return Object.fromEntries(Object.entries(e).map(([o,i])=>o!=="details"||!r||!Yt(i)?[o,Wn(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!r.includes(s)).map(([s,a])=>[s,Wn(a)]))]))}function uO(e,t){return Array.isArray(e)?e.map(n=>Uf(n,t)):Uf(e,t)}function No(e,t,n){let r=n?Mf[n]:void 0,o=r?.paths.includes(e)===!0;return cO("sha256").update(C({path:e,value:o?uO(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function la(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint,...e.direction==="backward"?{d:"b"}:{}}),"utf8").toString("base64url")}function fO(e){return typeof e=="string"&&(Fe(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function mO(e){return e===void 0||e==="b"}function pO(e){if(go(e))throw new h("The read-output continuation cursor was shortened by output compaction: it contains an ellipsis, which no cursor encoder emits.",g.USAGE,{code:"read_output_cursor_invalid",reason:"cursor_compacted",required:"Pass the whole cursor the previous page emitted; a shortened cursor cannot resume the read.",nextSteps:["Re-read the previous page with a larger --output-budget (or --output-budget unbounded) and pass its whole output_cursor to --output-cursor."]})}function qn(e){if(pO(e),e.length>dO)throw new h("The read-output continuation cursor is malformed or unsupported.",g.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!Yt(t)||t.v!==1||!fO(t.c)||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0||!mO(t.d))throw new h("The read-output continuation cursor is malformed or unsupported.",g.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f,...t.d==="b"?{direction:"backward"}:{}}}function Lf(e){if(!Array.isArray(e.assertions))return e;let t=n=>!Yt(n)||n.verdict==="pass"?4:n.verdict==="retired"?3:n.enforcement==="block"?0:n.enforcement==="warn"?1:2;return{...e,assertions:e.assertions.map((n,r)=>({row:n,index:r})).sort((n,r)=>t(n.row)-t(r.row)||n.index-r.index).map(({row:n})=>n),budget_retention_policy:"verdict_priority"}}function Ff(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,g.USAGE,{code:"read_output_cursor_command_mismatch"});let r=Vt(e).find(c=>c.path===n.path),o=r?Array.isArray(r.value)?r.value.length:Object.keys(r.value).length:0,i=lt(t,n.path);if(!r||o!==n.total_rows||n.offset>o||i!==(n.direction==="backward")||No(n.path,r.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",g.USAGE,{code:"read_output_cursor_stale"});if(!i)return Js(e,n.path,n.offset);let s=Js(e,n.path,0,n.offset);for(let c of["count","returned_count"])typeof s[c]=="number"&&(s[c]=n.offset);let a=oe[t].total_key;return typeof s[a]!="number"&&(s[a]=n.total_rows),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9c5d8732-3e10-5224-a558-e870397090f2")}catch{}})();var ma=1,zf=4096,yO=/^[A-Za-z0-9_-]+$/;function fa(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function f1(e,t){let n=[...Object.values(bo),...wo],r=new Set(n.flatMap(o=>[fa(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){r.add(fa(o.flag));for(let i of o.aliases??[])r.add(fa(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!r.has(o)))}function m1(e,t){return _O("sha256").update(e).update("\0").update(C(t)).digest("hex").slice(0,24)}function Bn(e,t,n,r){return Buffer.from(JSON.stringify({version:ma,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function ft(e,t){return new h(e,g.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function gO(e){return new h("Query cursor was shortened by output compaction: it contains an ellipsis, which no cursor encoder emits.",g.USAGE,{code:"invalid_query_cursor",reason:"cursor_compacted",required:"Pass the whole cursor the previous page emitted; a shortened cursor cannot resume the query.",nextSteps:[`Re-read the previous page with a larger --output-budget (or --output-budget unbounded) and pass its whole next_cursor to ${e}.`,`Or repeat the original query without ${e} to obtain a fresh cursor.`]})}function hO(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===ma&&typeof t.fingerprint=="string"&&typeof t.after_id=="string"&&t.after_id.length>0&&(t.after_index===void 0||Number.isSafeInteger(t.after_index)&&t.after_index>=0)&&(t.snapshot===void 0||typeof t.snapshot=="string"&&t.snapshot.length>0)}function ua(e,t="--after"){if(typeof e!="string")throw ft("Query cursor is malformed.",t);let n=e.trim();if(go(n))throw gO(t);if(n.length===0||n.length>zf||!yO.test(n))throw ft("Query cursor is malformed.",t);let r;try{r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"))}catch{throw ft("Query cursor is malformed.",t)}if(!hO(r)){let o=!1;try{qn(n),o=!0}catch{}throw o?new h(`An output cursor must be continued with --output-cursor, not ${t}.`,g.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${n}; retain any producer ${t} cursor from the original page.`]}):ft("Query cursor version or payload is unsupported.",t)}return r}function pa(e,t,n="--after"){let r=ua(e,n);if(r.fingerprint!==t)throw ft(`Query cursor does not match the current filters, sort, or query (${r.fingerprint} != ${t}).`,n);return{after_id:r.after_id,...r.after_index===void 0?{}:{after_index:r.after_index},...r.snapshot===void 0?{}:{snapshot:r.snapshot}}}function p1(e,t){return pa(e,t).after_id}function bO(e,t,n,r,o="--after"){if(t===void 0)return 0;let i=pa(t,n,o),s=e.findIndex(a=>r(a)===i.after_id);if(s<0){if(i.after_index!==void 0)return Math.min(i.after_index,e.length);throw ft(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return s+1}function _1(e,t){if(t.cursor!==void 0&&pa(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw ft("Query cursor does not match the requested snapshot.","--after");let n=bO(e,t.cursor,t.fingerprint,t.readId),r=e.slice(n,n+t.limit),o=r.length>0&&n+r.length<e.length,i=r.at(-1);return{rows:r,has_more:o,...o&&i!==void 0?{next_cursor:Bn(t.fingerprint,t.readId(i),n+r.length-1,t.snapshot)}:{}}}var y1=Object.freeze({version:ma,max_length:zf});import{randomUUID as SO}from"node:crypto";import{randomUUID as wO}from"node:crypto";import{constants as Xt}from"node:fs";import{lstat as Hf,mkdir as vO,open as qf,rename as EO,rm as OO}from"node:fs/promises";import Do from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71b65888-baa5-5c5f-a02c-4a0fd818fadb")}catch{}})();var he={max_serving_rows:256,max_bytes:262144,max_event_bytes:32768,retained_byte_fraction:.5,max_events:2048,retention_days:30},F=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function mt(e){let t=Date.parse(e.now??new Date().toISOString());if(!Number.isFinite(t))throw new F("Context usage now must be a valid timestamp");return{iso:new Date(t).toISOString(),ms:t}}function Bf(e){let t=e.maxBytes??he.max_bytes,n=e.maxEvents??he.max_events,r=e.retentionDays??he.retention_days;if(!Number.isSafeInteger(t)||t<1024||t>he.max_bytes||!Number.isSafeInteger(n)||n<1||!Number.isFinite(r)||r<=0)throw new F("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");return{maxBytes:t,maxEvents:n,cutoff:mt(e).ms-r*864e5}}async function Wf(e,t){if(!(await Hf(Do.dirname(e))).isDirectory())throw new F("Context usage runtime must be a real directory");try{if((await Hf(e)).isSymbolicLink())throw new F("Context usage ledger must not be a symbolic link")}catch(r){if(!q(r))throw r}let n=await qf(e,t|Xt.O_NOFOLLOW|Xt.O_NONBLOCK,384);try{let r=await n.stat();if(!r.isFile()||r.nlink!==1)throw new F("Context usage ledger must be an unshared regular file");return n}catch(r){throw await n.close(),r}}async function Po(e){let t=Bf(e);try{let n=await Wf(Do.join(e.pmRoot,"runtime","context-usage.jsonl"),Xt.O_RDONLY);try{let r=(await n.stat()).size,o=Math.max(0,r-t.maxBytes),i=Buffer.alloc(Math.min(r,t.maxBytes)),{bytesRead:s}=await n.read(i,0,i.length,o),a=i.subarray(0,s).toString("utf8");return(o>0?a.includes(`
84
+ `)?a.slice(a.indexOf(`
85
+ `)+1):"":a).split(`
86
+ `).flatMap(c=>{try{let d=JSON.parse(c);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await n.close()}}catch{return[]}}function Vf(e,t,n){let r=[],o=0;for(let i=e.length-1;i>=0&&r.length<n;i-=1){let s=`${JSON.stringify(e[i])}
87
+ `;if(o+=Buffer.byteLength(s),o>t)break;r.push(s)}return r.reverse().join("")}async function Gn(e,t,n){let r=Bf(e),o=Do.join(e.pmRoot,"runtime","context-usage.jsonl"),i=Math.floor(r.maxBytes*he.retained_byte_fraction),s=Math.min(he.max_event_bytes,i);if(t.some(f=>Buffer.byteLength(`${JSON.stringify(f)}
88
+ `)>s))throw new F("Context usage event exceeds the declared byte ceiling");let a=t.filter(f=>Date.parse(f.at)>=r.cutoff),c=Vf(a,i,r.maxEvents),d=performance.now(),l=await xn(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),u=performance.now()-d;try{await vO(Do.dirname(o),{recursive:!0});let f=await Wf(o,Xt.O_WRONLY|Xt.O_CREAT|Xt.O_APPEND);try{let m=(await f.stat()).size,p=n===void 0?void 0:await Po(e);if(p?.some(E=>E.kind==="delivery"&&E.serve_id===n))return{written_bytes:0,ledger_bytes:m,compacted:!1,lock_wait_ms:u};if(!(e.maxEvents!==void 0||e.retentionDays!==void 0)&&m+Buffer.byteLength(c)<=r.maxBytes)return await f.writeFile(c,"utf8"),{written_bytes:Buffer.byteLength(c),ledger_bytes:m+Buffer.byteLength(c),compacted:!1,lock_wait_ms:u};let _=Vf([...p??await Po(e),...a],i,r.maxEvents),y=`${o}.${process.pid}.${wO()}.tmp`,b=await qf(y,"wx",384);try{try{await b.writeFile(_,"utf8")}finally{await b.close()}return await f.close(),f=void 0,await EO(y,o),{written_bytes:Buffer.byteLength(_),ledger_bytes:Buffer.byteLength(_),compacted:!0,lock_wait_ms:u}}finally{await OO(y,{force:!0})}}finally{await f?.close()}}finally{await l()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e76b38ce-b2aa-589b-9d17-0952eca9e7a2")}catch{}})();var kO=864e5,$o=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function H(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function T1(e,t){let n=H(e);n!==null&&t!==null&&(n[$o]=t)}function pt(e,t){let n=H(e),r=H(t),o=n?.[$o];r!==null&&o!==void 0&&(r[$o]=o)}function AO(e){return H(e)?.[$o]??null}function Kf(e){let t=H(e);for(let n of["read_output","context_intent"])if(H(t?.[n])?.result_omitted===!0)return!0;return!1}function Ue(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function Yf(e,t){if(Array.isArray(t))for(let n of t)Ue(e,H(n)?.id)}function Gf(e,t){if(Array.isArray(t))for(let n of t)Ue(e,n)}function IO(e,t){let n=H(e.recommended)===null?[]:[e.recommended];for(let r of["ready","decision_needed","gate_needed","containers","blocked","held_by_others"])Array.isArray(e[r])&&n.push(...e[r]);for(let r of n){let o=H(r);Ue(t,o?.id);for(let i of Array.isArray(o?.blockers)?o.blockers:[])Ue(t,H(i)?.id);for(let i of Array.isArray(o?.unblocks)?o.unblocks:[])Ue(t,i)}}function TO(e,t){for(let n of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])Yf(t,e[n]);for(let n of Array.isArray(e.blockers)?e.blockers:[])Ue(t,H(n)?.blocked_by);CO(e,t)}function CO(e,t){for(let o of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=H(o);Ue(t,i?.id),Yf(t,i?.children)}for(let o of["files","workload"])for(let i of Array.isArray(e[o])?e[o]:[])Gf(t,H(i)?.items);let n=H(e.agenda);for(let o of Array.isArray(n?.events)?n.events:[])Ue(t,H(o)?.item_id);let r=H(e.tests);Gf(t,r?.items_failing)}function RO(e,t){let n=H(e);if(n===null||Kf(e))return[];let r=new Set;return t==="next"?IO(n,r):TO(n,r),[...r]}async function C1(e){let t=AO(e.result);if(t===null)return!1;let n=Kf(e.result);return await xO({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:RO(e.result,t.surface),resultOmitted:n}),!0}async function R1(e){if([process.env.PM_CONTEXT_USAGE_DISABLED==="1",e.enabled===!1].includes(!0))return null;if(!e.author.trim()||e.rows.some(o=>!o.id.trim()||!Number.isInteger(o.rank)||o.rank<1))throw new F("Context usage serving requires an author and valid ranked rows");let t=e.rows.map(o=>({id:o.id.trim(),rank:o.rank,included:o.included}));if(new Set(t.map(o=>o.id)).size!==t.length)throw new F("Context usage serving requires unique normalized row ids");let n=t.slice(0,he.max_serving_rows),r={serve_id:SO(),author:e.author.trim(),surface:e.surface,rows:t,recorded_item_ids:n.map(o=>o.id)};return r.storage=await Gn(e,[{kind:"serve",schema_version:2,serve_id:r.serve_id,at:mt(e).iso,author:e.author.trim(),surface:e.surface,profile:e.profile.trim()||"balanced",rows:n,candidate_count:t.length,omitted_row_count:t.length-n.length,result_omitted:!1,packed_item_ids:n.filter(o=>o.included).map(o=>o.id)}]),r}async function xO(e){if(e.receipt===null||process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return;let t=new Set(e.receipt.rows.map(i=>i.id)),n=[...new Set(e.deliveredItemIds.map(i=>i.trim()))];if(n.some(i=>i.length===0||!t.has(i))||e.resultOmitted&&n.length>0)throw new F("Context usage delivery requires emitted ranked ids and zero ids for an omitted result");let r=new Set(e.receipt.recorded_item_ids??e.receipt.rows.map(i=>i.id)),o={kind:"delivery",schema_version:2,serve_id:e.receipt.serve_id,at:mt(e).iso,author:e.receipt.author,surface:e.receipt.surface,result_omitted:e.resultOmitted,delivered_item_ids:n.filter(i=>r.has(i))};await Gn(e,[o],o.serve_id)}async function x1(e){if(!(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)){if(!e.author.trim()||!e.itemId.trim()||!e.intent.trim())throw new F("Context usage touch requires author, itemId, and intent");await Gn(e,[{kind:"touch",at:mt(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function N1(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1||e.itemIds.length===0)return;let t=e.author.trim(),n=e.intent.trim();if(!t||!n)throw new F("Context usage touch requires author and intent");let r=new Set;for(let s of e.itemIds){if(typeof s!="string")throw new F("Context usage touch requires string itemIds");let a=s.trim();if(!a)throw new F("Context usage touch requires non-empty itemId");r.add(a)}let o=mt(e).iso,i=[...r].map(s=>({kind:"touch",at:o,author:t,item_id:s,intent:n}));await Gn(e,i)}function NO(e,t,n,r){return e.find(({entry:o,time:i})=>o.item_id===t&&i>=n&&i-n<=r)?.time}function DO(e,t){let n=new Map;for(let r of e)r.kind==="delivery"&&r.schema_version===2&&r.author===t&&!n.has(r.serve_id)&&n.set(r.serve_id,r);return n}async function D1(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return{affinity:{},positive_judgments:0,serving_events:0,untrusted_serving_events:0};let t=await Po(e),n=mt(e).ms,r=(e.horizonHours??24)*36e5;if(![Number.isFinite(r),r>0].every(Boolean))throw new F("Context usage horizonHours must be positive");let o=e.author.trim(),i=t.filter(f=>f.kind==="touch").filter(f=>f.author===o).map(f=>({entry:f,time:Date.parse(f.at)})),s=new Map,a=0,c=0,d=0,l=DO(t,o);t.filter(f=>f.kind==="serve").filter(f=>f.author===o).forEach(f=>{if(![f.schema_version===2,!!f.serve_id].every(Boolean)){c+=1;return}a+=1;let m=Date.parse(f.at),p=l.get(f.serve_id),_=new Set(p?.delivered_item_ids??[]);for(let y of f.rows){if(!_.has(y.id))continue;let b=NO(i,y.id,m,r);if(b===void 0)continue;d+=1;let E=Math.max(0,(n-b)/kO);s.set(y.id,(s.get(y.id)??0)+Math.exp(-E/14))}});let u=Math.max(0,...s.values());return{affinity:Object.fromEntries([...s.entries()].map(([f,m])=>[f,u===0?.05:.05+.95*m/u])),positive_judgments:d,serving_events:a,untrusted_serving_events:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="100048de-2349-5062-b6c2-7176277ec38d")}catch{}})();var $O="limit_overridden_by_intent",em=Object.freeze([{command:"context",intent:"orient",description:"Bounded active hierarchy, ownership, blockers, and recent progress.",included_field_groups:["summary","focus","hierarchy","blockers","activity"],token_budget:3e3,source:"core"},{command:"context",intent:"handoff",description:"Active ownership, evidence, decisions, and immediate continuation context.",included_field_groups:["summary","focus","in_progress","decisions","activity"],token_budget:2200,source:"core"},{command:"get",intent:"inspect",description:"Standard-depth item metadata, relationships, evidence, and lifecycle state.",included_field_groups:["item","children","claim_state","linked"],token_budget:3200,source:"core"},{command:"list",intent:"triage",description:"A budget-derived page of compact governance, ownership, priority, and blocker rows for triage.",included_field_groups:["identity","governance","ownership","dependencies"],token_budget:3200,source:"core"},{command:"next",intent:"execute",description:"The highest-ranked actionable work with concise ranking evidence.",included_field_groups:["recommended"],token_budget:1200,source:"core"},{command:"search",intent:"discover",description:"A budget-derived page of ranked canonical lineage candidates with compact match evidence.",included_field_groups:["identity","status","lineage","match"],token_budget:1800,source:"core"}]),tm=new PO;function MO(){return tm.getStore()??em}function W1(e,t){return tm.run(LO(e.workspaceContracts,e.packageContracts),t)}function jO(e,t){let n=e.command.trim().toLowerCase(),r=e.intent.trim().toLowerCase(),o=`${n}:${r}`;if(!/^[a-z0-9][a-z0-9-]*$/.test(n)||!/^[a-z0-9][a-z0-9-]*$/.test(r))throw new TypeError(`Invalid context intent command or name: ${o}`);if(e.description.trim().length===0)throw new TypeError(`Context intent ${o} requires a non-empty description`);if(!Number.isSafeInteger(e.token_budget)||e.token_budget<=0)throw new TypeError(`Context intent ${o} requires a positive integer token_budget`);let i=[...new Set(e.included_field_groups.map(s=>s.trim()).filter(Boolean))];if(i.length===0)throw new TypeError(`Context intent ${o} requires included_field_groups`);return{command:n,intent:r,description:e.description.trim(),included_field_groups:i,token_budget:e.token_budget,source:t}}function LO(e=[],t=[]){let n=[{source:"core",contracts:em,allowOverride:!1},{source:"package",contracts:t,allowOverride:!1},{source:"workspace",contracts:e,allowOverride:!0}],r=new Map,o=new Set;for(let i of n){o.clear();for(let s of i.contracts){let a=jO(s,i.source),c=`${a.command}:${a.intent}`;if(o.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);if(o.add(c),!i.allowOverride&&r.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);r.set(c,a)}}return[...r.values()].sort((i,s)=>i.command.localeCompare(s.command)||i.intent.localeCompare(s.intent))}function nm(e,t,n=MO(),r=[]){let o=e.trim().toLowerCase(),i=t.trim().toLowerCase(),s=n.find(f=>f.command===o&&f.intent===i);if(s)return{...s,source:s.source??"core"};let a=n.filter(f=>f.command===o).map(f=>f.intent);if(a.length===0)return;let c=a.map(f=>{let m=Array.from({length:i.length+1},(p,_)=>_);for(let p=1;p<=f.length;p+=1){let _=m[0];m[0]=p;for(let y=1;y<=i.length;y+=1){let b=m[y];m[y]=Math.min(m[y]+1,m[y-1]+1,_+(f[p-1]===i[y-1]?0:1)),_=b}}return{candidate:f,distance:m[i.length]}}).sort((f,m)=>f.distance-m.distance||f.candidate.localeCompare(m.candidate))[0].candidate,d=[o,...r,"--for",i],l=[o,...r,"--for",c],u=se(l);throw new h(`Unknown context intent "${i}" for ${o}. Did you mean "${c}"?`,g.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:i,required:`Use a declared ${o} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[u],recovery:{recovery_mode:"compact",attempted_command:se(d),allowed_values:[...a].sort(),suggested_retry:u,suggested_retry_args:l}})}function _a(e,t){let n=yt(e.limit),r=String(n===void 0?t:Math.min(n,t));return(e.limit===void 0||n!==void 0)&&(e.limit=r),r}var rm={context:(e,t,n,r)=>{e.section===void 0&&e.depth===void 0&&(e.section=t.intent==="handoff"?["activity","progress","blockers"]:["hierarchy","blockers","activity"]),e.depth===void 0&&(e.depth=t.intent==="handoff"?"deep":"standard");let o=jo(r,e.tokenBudget,t.token_budget),i=Lo("context",t.intent,o,n),s=_a(e,i);e.activityLimit===void 0&&(e.activityLimit=s)},get:e=>{e.depth===void 0&&e.fields===void 0&&(e.depth="standard")},list:(e,t,n,r)=>{e.brief===void 0&&e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");let o=jo(r,e.tokenBudget,t.token_budget),i=Lo("list",t.intent,o,n);_a(e,i)},next:e=>{e.readyOnly===void 0&&(e.readyOnly=!0)},search:(e,t,n,r)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let o=jo(r,e.tokenBudget,t.token_budget),i=Lo("search",t.intent,o,n);_a(e,i)}};function G1(e,t,n=[]){let r=t.tokenBudget??t.token_budget;if(typeof t.for!="string"){if(r!==void 0&&(e==="get"||e==="list"||e==="search"))throw new h("--token-budget requires a declared context intent selected with --for",g.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(t.tokenBudget!==void 0||t.token_budget===void 0)return t;let c={...t,tokenBudget:r};return delete c.token_budget,c}let o=nm(e,t.for,void 0,n),i=Kn(t),s=yt(r)!==void 0||typeof i=="number",a={...t};return a.tokenBudget===void 0&&r!==void 0&&(a.tokenBudget=r),delete a.token_budget,typeof i=="number"?a.tokenBudget=String(i):a.tokenBudget===void 0&&(a.tokenBudget=String(o.token_budget)),rm[e](a,o,s,i),a}var FO={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},Mo=256;function ga(e){return Array.isArray(e)?e.map(ga):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,typeof n=="string"&&Pn(t)?n:ga(n)])):typeof e=="string"?yo(e):e}function yt(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/u.test(e.trim())?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function Kn(e){let t=e.outputBudget??e.output_budget;return t==="unbounded"?t:yt(t)}function UO(e){return Kn(e)===void 0?"--token-budget":"--output-budget"}function jo(e,t,n){return typeof e=="number"?e:zO(t,n)}function zO(e,t){let n=yt(e);if(n===void 0)return t;if(n<Mo)throw new h(`Context intent token budget must be at least ${Mo}`,g.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(e),required:`Use an integer token budget of at least ${Mo}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${Mo} or omit the override.`]});return n}function om(e,t){return e==="context"?e==="context"&&t==="orient"?{overhead:1200,rowCost:600}:{overhead:800,rowCost:500}:{overhead:e==="list"?520:480,rowCost:16}}function Lo(e,t,n,r){if(e==="get"||e==="next")return;let{overhead:o,rowCost:i}=om(e,t),s=Math.max(e==="context"?1:2,Math.floor((n-o)/i));return r?s:Math.min(e==="context"?20:100,s)}function gt(e,t,n){let r=Wt(n),o=n.outputRowContract===!0||n.output_row_contract===!0,i=t.estimated_tokens,s=i;for(let a=0;a<ea;a+=1){t.estimated_tokens=i;let c=je(o||!Object.hasOwn(e,"row_contract")?e:Object.fromEntries(Object.entries(e).filter(([d])=>d!=="row_contract")),r);if(c===i)return;i=c,s=Math.max(s,i)}t.estimated_tokens=s}var Xf={context:["high_level","low_level","blocked_fallback","recently_created","unparented","hierarchy","activity","blockers"],get:["children"],list:["items"],next:["ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items"]};function im(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof t.fingerprint!="string"||!Number.isSafeInteger(t.after_index)?void 0:{fingerprint:t.fingerprint,after_index:t.after_index,...typeof t.snapshot=="string"?{snapshot:t.snapshot}:{}}}catch{return}}function HO(e){if(e===null||typeof e!="object")return;if(typeof e.id=="string")return e.id;let t=e.item?.id;return typeof t=="string"?t:void 0}function VO(e,t,n,r){let o=!1;for(;;){if(gt(e,t,r),t.estimated_tokens<=t.token_budget||n.length<=1)return o;let i=Buffer.byteLength(JSON.stringify(n),"utf8"),s=(t.estimated_tokens-t.token_budget)*4;n.splice(-Math.min(n.length-1,Math.max(1,Math.ceil(s/Math.max(1,Math.ceil(i/n.length)))))),o=!0}}function qO(e,t,n){let r=e.items,o=typeof e.next_cursor=="string",i=o?e.next_cursor:n.after;if(!Array.isArray(r)||typeof i!="string")return!1;let s=im(i);if(s===void 0)return!1;let a=r.length,c=[...r],d=!1;for(;;){if(d=VO(e,t,r,n)||d,!d)return!1;let l=HO(r.at(-1));if(l===void 0)return r.splice(0,r.length,...c),gt(e,t,n),!1;if(e.next_cursor=Bn(s.fingerprint,l,o?s.after_index-(a-r.length):s.after_index+r.length,s.snapshot),gt(e,t,n),t.estimated_tokens<=t.token_budget||r.length<=1)break}return typeof e.count=="number"&&(e.count=r.length),typeof e.applied_limit=="number"&&(e.applied_limit=r.length),!0}function BO(e,t,n,r){if(e==="list"||e==="search")return qO(t,n,r);if(e!=="next"||typeof t.next_cursor=="string")return!1;let o=!1;for(;;){if(gt(t,n,r),n.estimated_tokens<=n.token_budget)return o;let i=Xf[e].map(f=>({key:f,rows:Array.isArray(t[f])?t[f]:[]})).filter(({rows:f})=>f.length>0).sort((f,m)=>m.rows.length-f.rows.length||f.key.localeCompare(m.key))[0];if(i===void 0)return o;let s=Xf[e].reduce((f,m)=>f+(Array.isArray(t[m])?t[m].length:0),0);if(s<=1)return o;let a=Math.min(i.rows.length,s-1),c=Buffer.byteLength(JSON.stringify(i.rows),"utf8"),d=Math.max(1,Math.ceil(c/i.rows.length)),l=(n.estimated_tokens-n.token_budget)*4,u=Math.min(a,Math.max(1,Math.ceil(l/d)));i.rows.splice(-u,u),o=!0}}function Jf(e,t,n){if(typeof t.for!="string")return n;let r=e.startsWith("list-")?"list":e;if(!(r in rm))return n;let o=r,i=nm(o,t.for),s=Kn(t),a=jo(s,t.tokenBudget??t.token_budget,i.token_budget),c={command:o,intent:i.intent,source:i.source,included_field_groups:[...i.included_field_groups],token_budget:a,declared_token_budget:i.token_budget,token_budget_override:a-i.token_budget,estimated_tokens:0,within_budget:!0,degradation:FO[o],declaration_feasible:!0,result_omitted:!1},d={...n},l=Lo(o,i.intent,c.token_budget,yt(t.tokenBudget??t.token_budget)!==void 0||typeof s=="number");if(l!==void 0){let _=yt(t.limit),y=_!==void 0&&_<l;c.budget_derived_limit=l,c.binding_constraint=y?"explicit_limit":"token_budget",c.limit_reason=y?"The caller supplied a smaller row limit than the budget-derived ceiling.":"The selected intent token budget constrains the effective row ceiling.",d.budget_derived_limit=l,JO({builtInCommand:o,intent:i.intent},c,d,t)}let u=sm.get(t)??0,f=c.token_budget;c.token_budget=f-u;let m=s==="unbounded"?ha(d,c,t):WO(o,d,c,t);c.declaration_feasible=c.estimated_tokens<=c.declared_token_budget;let p=am(s,c,m,()=>dm(e,o,i.intent,{...c,token_budget:f,estimated_tokens:c.estimated_tokens+u},d,t));return c.result_omitted&&(c.estimated_tokens+=u,c.declaration_feasible=c.estimated_tokens<=c.declared_token_budget),c.token_budget=f,p}function ha(e,t,n){let r={...e,context_intent:t};return gt(r,t,n),r}function WO(e,t,n,r){let o=ha(t,n,r);return n.estimated_tokens>n.token_budget&&(n.degradation="recursive_budget_compaction",o=ha(ga(t),n,r)),n.estimated_tokens>n.token_budget&&BO(e,o,n,r)&&(n.degradation="budget_row_compaction",gt(o,n,r)),o}var sm=new WeakMap;function am(e,t,n,r){return t.estimated_tokens<=t.token_budget||(t.within_budget=!1,e==="unbounded")?n:(t.degradation="budget_receipt_only",t.result_omitted=!0,typeof e=="number"?{output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},context_intent:t}:{budget_exceeded:{omitted_result:!0,reason:t.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:r()},context_intent:t})}var GO=["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"];function KO(e,t){if(typeof e.after!="string"||e.after.length===0||fe(t))return t;let n=im(e.after)?.fingerprint??"opaque_cursor",r={...t};for(let o of GO)delete r[o];return r.continuation_contract={fingerprint:n,metadata:"reference",restore_with:"omit --after"},r}function ze(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function YO(e,t){let n=e==="get"&&ze(t.item)&&typeof t.item.id=="string"?t.item.id:e==="search"&&typeof t.query=="string"?t.query:void 0;return n===void 0?"":` ${cm(n)}`}function cm(e){return`'${e.replaceAll("'",`'"'"'`)}'`}function XO(e){return typeof e.fields=="string"&&e.fields.trim()!==""?` --fields ${cm(e.fields)}`:""}function JO(e,t,n,r){let o=yt(r.limit),i=t.budget_derived_limit;if(o===void 0||o<=i)return;let{overhead:s,rowCost:a}=om(e.builtInCommand,e.intent),c=Math.max(t.token_budget,s+a*o);t.limit_reason=`The ${t.token_budget}-token ${e.intent} budget carries ${i} rows, so it reduced the caller's --limit ${o}.`,t.limit_override={flag:"--limit",requested:o,effective:i,...Number.isSafeInteger(c)?{token_budget_for_requested:c,restore_with:`${UO(r)} ${c}`}:{}};let d=`${$O}:--limit ${o}->${i}`;n.warnings=Array.isArray(n.warnings)?[...n.warnings,d]:[d],ze(n.filters)&&(n.filters={...n.filters,requested_limit:String(o)})}function dm(e,t,n,r,o,i){let s=YO(t,o),a=t==="get"?"":` --limit ${r.budget_derived_limit??1}`,{output_budget:c}=Un({effective_budget_tokens:r.token_budget,measured_result_tokens:r.estimated_tokens});return`pm ${e}${s}${XO(i)} --for ${n} --token-budget ${c}${a}`}function _t(e,t){if(ze(e))return typeof e[t]=="number"?e[t]:void 0}function Qf(e,t){let n=e;for(let r=0;r<8;r+=1){QO(n);let o=_t(n.context_intent,"estimated_tokens"),i=_t(n.read_output,"estimated_tokens"),s=_t(n.read_session,"spent_this_call_tokens");if(ze(n.context_intent)&&n.context_intent.result_omitted!==!0&&gt(n,n.context_intent,t),n=da(n,t),_t(n.context_intent,"estimated_tokens")===o&&_t(n.read_output,"estimated_tokens")===i&&_t(n.read_session,"spent_this_call_tokens")===s)break}return n}function QO(e){let t=e.context_intent;ze(t)&&Number(t.estimated_tokens)>Number(t.token_budget)&&(t.within_budget=!1)}function ba(e,t,n){let r=Ku(e,Yu(e??"",n));if(typeof r!="object"||r===null||Array.isArray(r))return pt(n,r),r;let o=e??"",i=r,s=Jf(o,t,i),a=_t(s.context_intent,"estimated_tokens"),c=ya(o,t,n,s),d=Zf(t,c,s.context_intent);if(d===void 0)return c;let l={...t};sm.set(l,d.estimated-Number(a));let u=Jf(o,l,i),f=ya(o,l,n,u),m=Zf(t,f,u.context_intent);if(m===void 0)return f;let p={...m.receipt,estimated_tokens:m.estimated};return ya(o,t,n,am(Kn(t),p,f,()=>dm(o,p.command,p.intent,p,i,t)))}function Zf(e,t,n){let r=ze(t.context_intent),o=r?t.context_intent:n;if(!ze(o)||o.result_omitted===!0||Object.hasOwn(t,"output_budget_exceeded"))return;let i=o,s=r?i.estimated_tokens:je(t,Wt(e));return Kn(e)==="unbounded"||s<=i.token_budget?void 0:{receipt:i,estimated:s}}function ya(e,t,n,r){let o=Pf(e,{...t,outputRowContract:t.outputRowContract===!0||t.output_row_contract===!0},KO(t,r));if(pt(n,o),t.outputRowContract===!0||t.output_row_contract===!0||!Object.hasOwn(o,"row_contract"))return ze(o.context_intent)?Qf(o,t):o;let i=Object.fromEntries(Object.entries(o).filter(([a])=>a!=="row_contract"));Object.defineProperty(i,"row_contract",{value:o.row_contract,enumerable:!1,configurable:!0});let s=Qf(i,t);return delete s.row_contract,pt(o,s),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cb1266f3-8375-586f-87c6-356cf7843969")}catch{}})();var Jt=["result_rows","envelope","diagnostics","hints"],ZO=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,eS=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,tS=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,nS=8;function wa(e){return Buffer.byteLength(e,"utf8")}function lm(e){return wa(JSON.stringify(e)??"null")}function rS(e,t){return eS.test(e)?"diagnostics":tS.test(e)?"hints":ZO.test(e)||Array.isArray(t)?"result_rows":"envelope"}function oS(e){let t={result_rows:0,envelope:0,diagnostics:0,hints:0};if(typeof e!="object"||e===null||Array.isArray(e))return t[Array.isArray(e)?"result_rows":"envelope"]=lm(e),t;for(let[n,r]of Object.entries(e))t[rS(n,r)]+=lm({[n]:r});return Object.values(t).every(n=>n===0)&&(t.envelope=1),t}function iS(e,t){let n=Jt.reduce((s,a)=>s+t[a],0),r=Jt.map(s=>({section:s,value:e*t[s]/n})),o={result_rows:0,envelope:0,diagnostics:0,hints:0};for(let s of r)o[s.section]=Math.floor(s.value);let i=e-Jt.reduce((s,a)=>s+o[a],0);for(let s of[...r].sort((a,c)=>c.value-Math.floor(c.value)-(a.value-Math.floor(a.value))||Jt.indexOf(a.section)-Jt.indexOf(c.section))){if(i===0)break;o[s.section]+=1,i-=1}return o}function um(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function fm(e,t){let n=wa(t(e)),r=iS(n,oS(e)),o=Object.fromEntries(Jt.map(a=>[a,{bytes:r[a],estimated_tokens:dt(r[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:n,total_estimated_tokens:dt(n),sections:o,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=um(e,i);for(let a=0;a<nS;a+=1){let c=wa(t(s))-n;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:dt(c)},s=um(e,i)}return s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="787e6c05-d503-5602-a173-e6a59699cea6")}catch{}})();var mm=Object.freeze({comments:Object.freeze(["comments"]),notes:Object.freeze(["notes"]),learnings:Object.freeze(["learnings"])});function pm(e){return e===void 0||!Object.hasOwn(mm,e)?[]:mm[e]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8e86e884-98ca-5b28-838b-db3543051112")}catch{}})();var _m=new Set(["body","item_hash","linked","claim_state","children","schedule","blockers"]),Q1=new Set(["linked","claim_state","children","schedule"]);import{encode as Sa}from"@toon-format/toon";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bafcd4e4-ec0f-5340-89ce-b85d822b2323")}catch{}})();function ym(e,t={}){let n=[...new Set(e.flatMap(l=>Object.keys(l)))],r=t.compact?n.filter(l=>e.every(u=>Object.hasOwn(u,l)&&u[l]===null)):[],o=t.compact?n.filter(l=>e.every(u=>{if(!Object.hasOwn(u,l))return!0;let f=u[l];return Array.isArray(f)&&f.every(m=>typeof m=="string"&&m!==""&&!m.includes(";"))})):[],i=new Set(o),s=new Set(r),a=n.filter(l=>!i.has(l)&&e.some(u=>{let f=u[l];return f!==null&&typeof f=="object"})),c=new Set(a),d=[];return{rows:e.map((l,u)=>Object.fromEntries(n.filter(f=>!s.has(f)).map(f=>{if(!Object.hasOwn(l,f))return d.push([u,f]),[f,null];let m=l[f];return i.has(f)?[f,m.join(";")]:[f,c.has(f)?JSON.stringify(m):m]}))),encoding:{json_columns:a,absent:d,...o.length?{list_columns:Object.fromEntries(o.map(l=>[l,";"]))}:{},...r.length?{null_columns:r,null_column_index:r.map(l=>n.indexOf(l))}:{}}}}function gm(e){let{json_columns:t,absent:n,...r}=e,o=new Map;for(let[i,s]of n){let a=o.get(s)??[];a.push(i),o.set(s,a)}return{...t.length>0?{json_columns:t}:{},...o.size>0?{absent_rows:Object.fromEntries(o)}:{},...r}}function sS(e,t){let n=t.null_columns??[],r=t.null_column_index??[],o=[...e],i=n.map((s,a)=>({column:s,position:r[a]})).filter(s=>typeof s.position=="number").sort((s,a)=>s.position-a.position);for(let{column:s,position:a}of i)o.splice(Math.min(a,o.length),0,s);for(let s of n)o.includes(s)||o.push(s);return o}function e$(e){let t=new Set(e.encoding.json_columns??[]),n=new Map(Object.entries(e.encoding.list_columns??{})),r=new Set([...(e.encoding.absent??[]).map(([o,i])=>JSON.stringify([o,i])),...Object.entries(e.encoding.absent_rows??{}).flatMap(([o,i])=>i.map(s=>JSON.stringify([s,o])))]);return e.rows.map((o,i)=>{let s=new Map(Object.entries(o).flatMap(([c,d])=>{if(r.has(JSON.stringify([i,c])))return[];let l=n.get(c),u=l!==void 0?d===""?[]:String(d).split(l):t.has(c)?JSON.parse(String(d)):d;return[[c,u]]}));for(let c of e.encoding.null_columns??[])s.set(c,null);let a=e.encoding.column_order??sS(Object.keys(o),e.encoding);return Object.fromEntries(a.filter(c=>s.has(c)).map(c=>[c,s.get(c)]))})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="43d2915b-7301-5e96-89e0-51c8e817789e")}catch{}})();function me(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var aS=new Set(["brief","compact","fields"]);function hm(e){if(!me(e))return!1;let t=e.fields;return aS.has(e.mode)&&Object.keys(e).length===2&&Array.isArray(t)&&t.length>0&&t.every(n=>typeof n=="string"&&n.length>0)}function bm(e,t){return e.every(n=>me(n)&&Object.keys(n).length===t.fields.length&&t.fields.every(r=>Object.hasOwn(n,r)))}function wm(e,t){return e.mode==="fields"&&t===0?{projection:e}:{}}function vm(e,t){return typeof e.has_more=="boolean"&&e.truncated===e.has_more&&e.count===t&&typeof e.total=="number"&&Number.isSafeInteger(e.total)&&(e.has_more?e.total>t&&typeof e.next_cursor=="string"&&e.next_cursor.length>0:e.total===t&&e.next_cursor==null)}function cS(e){return me(e)&&(e.status==="complete"||e.status==="unchecked")&&e.unreadable_item_count===0&&e.unreadable_directory_count===0}function va(e,t="full_item_fields"){if(!me(e)||!Array.isArray(e.omitted_field_groups))return!1;let n=e.omitted_field_groups,r=n[0];return e.has_omissions===!0&&e.omitted_field_group_count===1&&Object.keys(e).length===3&&n.length===1&&me(r)&&Object.keys(r).length===2&&r.name===t&&r.restore_with==="--full"}function Em(e){if(!me(e)||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!hm(e.projection)||!bm(e.items,e.projection)||!cS(e.completeness)||!vm(e,e.items.length)||!va(e.omission_receipt))return e;let{total:t,has_more:n,truncated:r,next_cursor:o,completeness:i,projection:s,now:a,omission_receipt:c,sorting:d,filters:l,...u}=e,f=i.status==="complete"&&!n&&Object.keys(i).length===3,{unreadable_item_count:m,unreadable_directory_count:p,..._}=i;return{...u,...f?{}:{total:t,has_more:n,completeness:_},...n?{next_cursor:o}:{},...uS(d),...Om(l,u.applied_limit,s),...wm(s,e.items.length),details:"--full"}}function dS(e){return me(e)&&e.sort==="default"&&e.order==="asc"&&Object.keys(e).every(t=>t==="sort"||t==="order"||t==="effective_keys")}function lS(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&(e[1]==="asc"||e[1]==="desc")}function uS(e){if(!dS(e))return{sorting:e};let t=e.effective_keys;return t===void 0?{}:!Array.isArray(t)||!t.every(lS)?{sorting:e}:{sorting:{effective_keys:t.map(([n,r])=>`${n} ${r}`).join(", ")}}}function fS(e,t){if(typeof e!="string"||t===void 0)return!1;let n=e.split(",").map(r=>r.trim()).filter(Boolean);return n.length===t.fields.length&&n.every((r,o)=>r===t.fields[o])}function Om(e,t,n){if(!me(e))return e===void 0?{}:{filters:e};let r=Object.fromEntries(Object.entries(e).filter(([o,i])=>!(o==="limit"&&String(i)===String(t))&&!(o==="fields"&&fS(i,n))&&!(o==="runtime_filters"&&me(i)&&Object.keys(i).length===0)));return Object.keys(r).length===0?{}:{filters:r}}function mS(e,t){return e.count===t&&!Object.hasOwn(e,"has_more")&&!Object.hasOwn(e,"truncated")&&e.next_cursor==null&&(e.total===void 0||e.total===t)}function pS(e){if(!Object.hasOwn(e,"projection"))return va(e.omission_receipt,"projection_metadata")?{}:void 0;let t=e.projection;return hm(t)&&t.mode==="fields"&&bm(e.items,t)&&typeof e.now=="string"&&va(e.omission_receipt)?{projection:t}:void 0}function Sm(e){if(!me(e)||typeof e.query!="string"||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!(vm(e,e.items.length)||mS(e,e.items.length)))return e;let t=pS(e);if(t===void 0)return e;let{truncated:n,omission_receipt:r,filters:o,projection:i,now:s,mode_source:a,...c}=e;return{...c,...a==="settings"||t.projection===void 0&&a!==void 0?{mode_source:a}:{},...Om(o,c.applied_limit,t.projection),...t.projection?wm(t.projection,e.items.length):{},details:"--full"}}import{isBoxedPrimitive as _S}from"node:util/types";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b399abd-460a-55a5-9df2-db23537aac0d")}catch{}})();var km=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/gu;function s$(e){return e.replaceAll(km,"\uFFFD")}function yS(e,t,n){return n&&/^\d+$/u.test(t)?`${e}[${t}]`:/^[A-Za-z_$][\w$]*$/u.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function Ea(e,t,n){if(typeof e=="string"){let r=e.search(km);return r<0?void 0:{field:t,index:r}}if(!(e===null||typeof e!="object"||n.has(e))){n.add(e);for(let[r,o]of Object.entries(e)){let i=yS(t,r,Array.isArray(e)),s=Ea(r,`${i} (key)`,n)??Ea(o,i,n);if(s)return s}}}function Am(e,t,n){if(e===null||typeof e!="object")return e;if(_S(e)||typeof e.toJSON=="function")return JSON.parse(JSON.stringify({[t]:e}))[t];if(n.has(e))return n.get(e);let r=Array.isArray(e)?new Array(e.length):{};n.set(e,r);for(let o of Object.keys(e))Object.defineProperty(r,o,{value:Am(e[o],o,n),enumerable:!0,configurable:!0,writable:!0});return r}function Oa(e){let t=Am(e,"",new WeakMap),n=Ea(t,"$",new WeakSet);return n&&gS(n),t}function gS(e){throw new h(`Output field ${e.field} contains an unpaired surrogate code unit at index ${e.index}; structured output requires well-formed Unicode.`,g.USAGE,{code:"text_unpaired_surrogate",field:e.field,required:"Well-formed UTF-16 strings and object keys in both JSON and TOON output.",nextSteps:["Repair the producer's text before returning output; use toWellFormedText from @unbrained/pm-cli/sdk when replacement is intended."]})}function a$(e){Oa(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f33393ac-6b72-5e46-92a5-f276d1fbfff1")}catch{}})();var hS=new Set(Object.values(g)),bS=new Map([["notes_count","notes"],["tests_count","tests"]]),ka="__pm_native_output",Im=!1;function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xa(e){let t={read_output:{result_omitted:!0}};pt(e,t),zo(t)}function Aa(e,t,n){if(n){zo(e);return}xa(t)}function wS(e){if(!S(e)||e[ka]!==!0)return e;let{[ka]:t,...n}=e;return n}function Ia(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function vS(){(process.exitCode===void 0||process.exitCode===g.SUCCESS)&&(process.exitCode=g.SUCCESS)}function ES(){(process.exitCode===void 0||process.exitCode===g.SUCCESS)&&(process.exitCode=g.GENERIC_FAILURE)}function Ta(e){if(e==="stdout"){vS();return}ES()}function Tm(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function OS(){Im||(Im=!0,process.stdout.on("error",e=>{if(Ia(e)){Ta("stdout");return}Tm(e)}),process.stderr.on("error",e=>{if(Ia(e)){Ta("stderr");return}Tm(e)}))}function Cm(e,t){OS();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(n){if(Ia(n))return Ta(e),!1;throw n}}function SS(e){return Cm("stdout",e)}function Yn(e){return Cm("stderr",e)}function Rm(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function Ca(e,t){let n=" ".repeat(t);return e.split(`
89
+ `).map(r=>`${n}${r}`).join(`
90
+ `)}function kS(e){let t=new Set,n=0;for(let r of e){let o=Object.keys(r);n+=o.length;for(let i of o)t.add(i)}return e.length*t.size<=n*2}function AS(e,t,n,r){let o=" ".repeat(n);if(!S(t)&&!Array.isArray(t))return`${o}${e}: ${Rm(t)}`;let i=e==="omission_receipt"?IS(t,n):void 0;if(i!==void 0)return i;if(Array.isArray(t)){if(t.length===0)return`${o}${e}: []`;let s=Ca(Sa({[e]:t}),n);return r&&t.length>=1&&t.every(S)&&kS(t)?[!1,!0].map(a=>{let c=ym(t,{compact:a});return Ca(Sa({[e]:c.rows,[`${e}_encoding`]:gm(c.encoding)}),n)}).reduce((a,c)=>Buffer.byteLength(c)<Buffer.byteLength(a)?c:a,s):s}return S(t)&&Object.keys(t).length===0?`${o}${e}: {}`:`${o}${e}:
91
+ ${Fo(t,n+1)}`}function IS(e,t){let n=" ".repeat(t);if(LS(e))return`${n}omission_receipt: complete`;let r=S(e)?TS(e):void 0;if(r===void 0)return;let o=`${n}omission_receipt:
92
+ ${Fo(e,t+1)}`,i=`${n}omission_receipt:
93
+ ${Fo(r,t+1)}`;return Buffer.byteLength(i)<Buffer.byteLength(o)?i:o}function TS(e){let t=e.omitted_field_groups;if(!Array.isArray(t)||t.length===0||Object.hasOwn(e,"restore_with"))return;let n=[],r;for(let o of t){if(!S(o)||Object.keys(o).length!==2)return;let{name:i,restore_with:s}=o;if(typeof i!="string"||i.length===0||typeof s!="string"||!s.endsWith(i))return;let a=s.slice(0,s.length-i.length);if(r!==void 0&&a!==r)return;r=a,n.push(i)}return Object.fromEntries(Object.entries(e).flatMap(([o,i])=>o==="omitted_field_groups"?[[o,n],["restore_with",`${r}<name>`]]:[[o,i]]))}function CS(e,t,n){let r=e.map(o=>ht(o,t,n||t.preserveRowFacts&&S(o))).filter(o=>o!==void 0);return r.length>0||n?r:void 0}function ht(e,t={omitDuplicateCountAliases:!0,preserveRowFacts:!0},n=!1){if(e===null)return n?null:void 0;if(Array.isArray(e))return CS(e,t,n);if(S(e)){let r=[],o=Object.entries(e).filter(([i,s])=>{let a=bS.get(i);return!t.omitDuplicateCountAliases||a===void 0||!S(e.collection_counts)||s!==e.collection_counts[a]});for(let[i,s]of o){if(i==="omitted_field_groups"&&Array.isArray(s)&&s.length===0){r.push([i,[]]);continue}let a=ht(s,t,n);a!==void 0&&r.push([i,a])}return r.length>0||n?Object.fromEntries(r):void 0}return e}function Fo(e,t){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":Ca(Sa(e),t);if(S(e)){let r=Object.entries(e);return r.length===0?"{}":r.map(([o,i])=>AS(o,i,t,!Object.hasOwn(e,`${o}_encoding`)&&!(o==="checks"&&S(e.verdict)&&e.verdict.authority==="ok"))).join(`
94
+ `)}return`${n}${Rm(e)}`}function RS(e){if(!S(e)||e.output_default!=="markdown"||typeof e.view!="string"||!Array.isArray(e.events)||!Array.isArray(e.days))return null;let t=[`# pm calendar (${e.view})`,""],n=S(e.summary)?e.summary:{};if(t.push(`- events: ${String(n.events??0)}`),t.push(""),e.events.length===0)return t.push("No calendar events matched the selected filters."),`${t.join(`
95
+ `)}
96
+ `;for(let r of e.events){if(!S(r))continue;let o=typeof r.kind=="string"?r.kind:"event",i=typeof r.item_title=="string"?r.item_title:"",s=typeof r.item_id=="string"?r.item_id:"",a=typeof r.reminder_text=="string"&&r.reminder_text.length>0?` ${r.reminder_text}`:"";t.push(`- [${o}] ${s} ${i}${a}`.trim())}return`${t.join(`
97
+ `)}
98
+ `}var xS=new Set(["filters","now","projection","sorting"]);function NS(e){let t=ht(e,{omitDuplicateCountAliases:!1,preserveRowFacts:!1});if(!S(t)||!Array.isArray(t.items))return t??null;let n=Object.fromEntries(Object.entries(t).filter(([r])=>!xS.has(r)));return n.has_more!==!0&&delete n.next_cursor,n}function DS(e){return!S(e)||e.ok!==!0||!S(e.verdict)||e.verdict.authority!=="ok"||!Array.isArray(e.checks)?e:{...e,checks:e.checks.map(PS)}}function PS(e){if(!S(e)||e.ok!==!0||!S(e.details)||Object.keys(e.details).length!==0)return e;let{details:t,...n}=e;return n}function Io(e,t,n=!1,r={}){if(e=Oa(e),t==="json"){let i=n?NS(e):e,s=S(e)&&S(e.projection)&&e.projection.mode==="brief"&&Array.isArray(e.items);return`${JSON.stringify(i,null,s?void 0:2)}
99
+ `}let o=MS(e,$S(e,ht(DS(Sm(Em(e))),Uo),r.preserveEmptyItemCollections===!0),r.positionalRowPaths??[]);return o===void 0?`{}
100
+ `:`${Fo(o,0)}
101
+ `}var Uo={omitDuplicateCountAliases:!0,preserveRowFacts:!0};function Ra(e,t,n=!1){if(Array.isArray(e)){if(e.length===0)return[];let i=Array.isArray(t)?t:[],s=i.length===e.length,a=0,c=e.flatMap(d=>{let l=n||S(d),u=!s&&ht(d,Uo,l)===void 0,f=Ra(d,u?void 0:i[a++],l);return f===void 0?[]:[f]});return c.length>0?c:t}if(!S(e))return t;let r=S(t)?t:{},o=Object.entries(e).flatMap(([i,s])=>{let a=Ra(s,Object.hasOwn(r,i)?r[i]:void 0,n);return a===void 0?[]:[[i,a]]});return o.length>0||Object.keys(e).length===0?Object.fromEntries(o):t}function $S(e,t,n){if(!n||!S(e))return t;let r=S(t)?t:{},o=new Map(Object.keys(e).filter(i=>i==="item"||_m.has(i)).map(i=>[i,Ra(e[i],r[i])]));return xm(e,r,o)}function xm(e,t,n){let r=Object.entries(t).map(([i,s])=>[i,n.has(i)?n.get(i):s]),o=Object.keys(e);for(let[i,s]of n){if(Object.hasOwn(t,i)||s===void 0)continue;let a=new Set(o.slice(o.indexOf(i)+1)),c=r.findIndex(([d])=>a.has(d));r.splice(c===-1?r.length:c,0,[i,s])}return Object.fromEntries(r)}function MS(e,t,n){if(!S(e))return t;let r=n.filter(s=>{let a=e[s];return Array.isArray(a)&&a.some(c=>ht(c,Uo,S(c))===void 0)});if(r.length===0)return t;let o=S(t)?t:{},i=new Map(r.map(s=>[s,e[s].map(a=>ht(a,Uo,!0))]));return xm(e,o,i)}var jS=JSON.stringify({has_omissions:!1,omitted_field_group_count:0,omitted_field_groups:[]});function LS(e){let t=Object.entries(Object(e)).sort(([n],[r])=>n.localeCompare(r));return JSON.stringify(Object.fromEntries(t))===jS}function FS(e,t,n,r){let o=t?{handled:!1,result:e,warnings:[]}:Na("output_format",{command:n.command,args:n.commandArgs,command_options:n.commandOptions,global:{...n},pm_root:n.pmRoot,format:r,options:{...n},result:e}),i=o.warnings.find(s=>s.startsWith("extension_output_format_payload_echo_deprecated:"));return i!==void 0&&Yn(`Warning: ${i}. Returning context.payload now declines safely for compatibility; migrate the override to declineServiceOverride() or { handled: false }.
102
+ `),o.handled&&typeof o.result=="string"?{result:o.result,rendered:o.result.endsWith(`
103
+ `)?o.result:`${o.result}
104
+ `,structuredDeliveryPreserved:!1}:{result:o.handled?o.result:e,rendered:null,structuredDeliveryPreserved:!o.handled||S(o.result)}}function US(e,t,n,r){let o=Nm(),i=n.command??o?.command,s={...o?.options,...n.commandOptions,...Object.fromEntries([["outputInclude",n.outputInclude],["outputLimit",n.outputLimit],["outputBudget",n.outputBudget],["outputFormat",n.outputFormat],["outputSession",n.outputSession],["outputCursor",n.outputCursor],["outputRowContract",n.outputRowContract]].filter(_=>_[1]!==void 0))},a=$f(i??"",s)??r,c={...s,resolvedOutputFormat:a},d={...n,command:i,commandOptions:c},l=FS(e,t,d,a),u=zS(a,i,c,n.lean===!0);if(l.rendered!==null)return HS(l.rendered,{format:a,renderNative:u,contract:()=>ba(i,c,e),effectiveResult:e,quiet:n.quiet===!0});let f=l.result;pt(e,f);let m=ju(i,f,{lean:n.lean===!0,fullContext:s.checkContext===!0,fullOutput:s.fullOutput===!0}),p=!1;return VS({format:a,contract:()=>ba(i,c,m),renderDelivered:_=>{if(a==="toon"){let b=RS(_);if(b!==null)return{text:b,custom:!1}}let y=t||p||fe(_)?{rendered:null}:Pm(a,_);return y.rendered!==null?{text:y.rendered.endsWith(`
105
+ `)?y.rendered:`${y.rendered}
106
+ `,custom:!0}:{text:u(_),custom:!1}},renderNative:u,useNativeRendering:()=>{p=!0},structuredDeliveryPreserved:l.structuredDeliveryPreserved,tokenAccounting:n.tokenAccounting===!0,quiet:n.quiet===!0,effectiveResult:e})}function zS(e,t,n,r){if(e==="json")return a=>Io(a,"json",r);let o=n.fields,i=t==="get"&&typeof o=="string"&&o.trim().length>0,s=pm(t===void 0?void 0:Fe(t,n));return a=>Io(a,"toon",!1,{preserveEmptyItemCollections:i,positionalRowPaths:s})}function HS(e,t){let n=Ao(t.format,r=>fe(r)?t.renderNative(r):e,t.contract);return fe(n)?(process.exitCode||=g.USAGE,Aa(n,t.effectiveResult,!t.quiet),t.renderNative(n)):(xa(t.effectiveResult),e)}function VS(e){let t=Ao(e.format,a=>e.renderDelivered(a).text,e.contract),n=e.renderDelivered(t);n.custom&&BS(t,n.text)&&(e.useNativeRendering(),t=Ao(e.format,e.renderNative,e.contract),n={text:e.renderNative(t),custom:!1}),fe(t)&&(process.exitCode||=g.USAGE);let r=e.structuredDeliveryPreserved&&!n.custom;if(!e.tokenAccounting)return Aa(t,e.effectiveResult,!e.quiet&&r),n.text;let o=a=>{let c=e.renderDelivered(a);return c.custom&&(r=!1),c.text},i=fm(t,o),s=o(i);return Aa(i,e.effectiveResult,!e.quiet&&r),s}var qS=[["read_output","estimated_tokens"],["context_intent","estimated_tokens"],["read_session","spent_this_call_tokens"]];function BS(e,t){let n=Math.ceil(Buffer.byteLength(t,"utf8")/4),r=Object(e);return qS.some(([o,i])=>{let s=r[o],a=S(s)?s[i]:void 0;return typeof a=="number"&&a<n})}function WS(e,t){let n=Dm(e),r=_o(n.result)?n.result:null,o=n.result,i=S(o)&&o[ka]===!0,s=r?r.result:wS(n.result);return zo(s),r?(xa(s),""):US(s,i,t,GS(t))}function GS(e){return e.json===!0||e.json===void 0&&e.defaultOutputFormat==="json"?"json":"toon"}function KS(e,t){return t.idOnly?$n(e,{idOnly:!0}):t.fullChangedFields?e:t.noChangedFields?$n(e,{changedFields:"compact"}):$n(e,{compactEnvelope:!0})}function k$(e,t){S(e)&&Number.isInteger(e.exit_code)&&hS.has(Number(e.exit_code))&&(process.exitCode===void 0||process.exitCode===g.SUCCESS)&&(process.exitCode=Number(e.exit_code));let n=WS(KS(e,t),t);t.quiet||SS(n)}function A$(e){let t=Na("error_format",{message:e}),n=t.handled&&typeof t.result=="string"?t.result:e;Yn(n.endsWith(`
107
+ `)?n:`${n}
108
+ `)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="687cbe24-6d5c-5322-962d-455048eb84b5")}catch{}})();var YS=Qt.join("runtime","history-drift-cache.json"),$m={EINVAL:"invalid_cache_path",EISDIR:"cache_path_is_directory",ENOENT:"invalid_cache_path",ENOTDIR:"invalid_cache_path",ERR_FS_EISDIR:"cache_path_is_directory"};function Mm(e){return typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"?e.code:void 0}async function XS(e){let t=Qt.join(e,YS),n=!1,r="invalid_cache_path";try{n=(await Da.stat(await Da.realpath(e))).isDirectory()}catch(o){let i=Mm(o);r=i===void 0?"unknown":$m[i]??"filesystem_error"}if(!n){Yn(`[pm] warning: history_drift_cache_invalidation_failed:${r}
109
+ `);return}try{await Da.rm(t,{force:!0})}catch(o){let i=Mm(o);if(q(o))return;let s=i===void 0?"unknown":$m[i]??"filesystem_error";Yn(`[pm] warning: history_drift_cache_invalidation_failed:${s}
110
+ `)}}async function Ho(e){let t=Qt.dirname(Qt.resolve(e));Qt.basename(t)==="history"&&await XS(Qt.dirname(t))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4a3c3c82-0398-549c-8910-fdc69d971cb2")}catch{}})();var QS={front_matter:{},body:""},nt=3,Tn=[1,2,3],ZS=1,ek=[1];function Hm(e){return Ie(C(e),e.hash_algorithm)}function Zt(e){return Tt(C(e))}function X$(e){return Tt(C(e))}function ja(e){let t={...e,record_hash_version:ZS},{record_hash:n,...r}=t;return{...t,record_hash:Hm(r)}}function io(e){try{Xe(e.hash_algorithm)}catch{return{ok:!1,error:"unsupported_history_hash_algorithm"}}if(e.record_hash_version===void 0&&e.record_hash===void 0)return{ok:!0,coverage:"item_state_only"};if(e.record_hash_version===void 0||e.record_hash===void 0)return{ok:!1,error:"incomplete_record_hash_envelope"};if(!ek.includes(e.record_hash_version))return{ok:!1,error:"unsupported_record_hash_version"};let{record_hash:t,...n}=e;return Hm(n)===e.record_hash?{ok:!0,coverage:"record_and_item_state"}:{ok:!1,error:"record_hash_mismatch"}}function tk(e,t){let n={before_hash:e.before_hash,after_hash:e.after_hash,patch_hash:Zt(e.patch)};return e.hash_algorithm!==void 0&&(n.hash_algorithm=e.hash_algorithm),e.item_hash_version!==void 0&&(n.item_hash_version=e.item_hash_version),t.retainOriginalPatch&&(n.patch=structuredClone(e.patch)),t.retainPriorRecordHash!==!1&&e.record_hash_version!==void 0&&e.record_hash!==void 0&&(n.record_hash_version=e.record_hash_version,n.record_hash=e.record_hash,n.record=structuredClone(e)),n}function nu(e,t,n={}){let r=io(e);if(!r.ok)throw new TypeError(r.error);let o=Zt(e.patch),i=n.retainPriorRecord===!0||e.before_hash!==t.before_hash||e.after_hash!==t.after_hash||e.item_hash_version!==t.item_hash_version||e.hash_algorithm!==t.hash_algorithm||o!==Zt(t.patch),s=ja({...t,...i?{reanchor_evidence:[...t.reanchor_evidence??[],tk(e,n)]}:{}}),a=xs(s);if(!a.ok)throw new TypeError(a.error);return s}function Vm(e){return!Array.isArray(e)||Object.keys(e).length!==e.length?!1:e.every(t=>!bt(t)||typeof t.path!="string"?!1:t.op==="move"||t.op==="copy"?typeof t.from=="string":["add","replace","test"].includes(t.op)?Object.hasOwn(t,"value"):t.op==="remove")}function nk(e){return bt(e)&&typeof e.ts=="string"&&typeof e.author=="string"&&typeof e.op=="string"&&typeof e.before_hash=="string"&&typeof e.after_hash=="string"&&Vm(e.patch)}function rk(e){let t=e.record_hash_version!==void 0,n=e.record_hash!==void 0;return t===n}function ok(e){return!bt(e)||!rk(e)||typeof e.before_hash!="string"||typeof e.after_hash!="string"||typeof e.patch_hash!="string"||!/^[a-f0-9]{64}$/u.test(e.patch_hash)||e.patch!==void 0&&!Vm(e.patch)||e.record_hash_version!==void 0&&typeof e.record_hash_version!="number"||e.record_hash!==void 0&&(typeof e.record_hash!="string"||!/^(?:[a-f0-9]{64}|[a-f0-9]{128})$/u.test(e.record_hash))?!1:e.record===void 0||nk(e.record)}function ik(e){try{for(let t of e){if(!ok(t))return!1;Xe(t.hash_algorithm)}return!0}catch{return!1}}function sk(e){let t=e.record;return t!==void 0&&t.before_hash===e.before_hash&&t.after_hash===e.after_hash&&t.item_hash_version===e.item_hash_version&&t.hash_algorithm===e.hash_algorithm&&t.record_hash_version===e.record_hash_version&&t.record_hash===e.record_hash&&Zt(t.patch)===e.patch_hash}function ak(e,t,n){if(t.patch&&Zt(t.patch)!==t.patch_hash)return{kind:"patch_hash_mismatch"};if(t.record)return sk(t)?{kind:"record",entry:t.record}:{kind:"record_hash_mismatch"};let r=t.patch??e.patch;if(Zt(r)!==t.patch_hash)return{kind:"digest_only"};let o={...e,before_hash:t.before_hash,after_hash:t.after_hash,patch:r,hash_algorithm:t.hash_algorithm,...t.item_hash_version===void 0?{}:{item_hash_version:t.item_hash_version},...t.record_hash_version===void 0?{}:{record_hash_version:t.record_hash_version},...t.record_hash===void 0?{}:{record_hash:t.record_hash},...n.length===0?{}:{reanchor_evidence:n}};return t.hash_algorithm===void 0&&delete o.hash_algorithm,n.length===0&&delete o.reanchor_evidence,t.item_hash_version===void 0&&delete o.item_hash_version,t.record_hash_version===void 0||t.record_hash===void 0?{kind:"legacy",entry:o}:{kind:"record",entry:o}}function xs(e){let t=e.reanchor_evidence;if(t===void 0)return{ok:!0,coverage:"none"};if(!Array.isArray(t)||!ik(t))return{ok:!1,error:"rewrite_evidence_invalid"};if(t.length===0)return{ok:!0,coverage:"none"};let n=e;for(let r=t.length-1;r>=0;r-=1){let o=t[r],i=ak(n,o,t.slice(0,r));if(i.kind==="patch_hash_mismatch")return{ok:!1,error:"rewrite_evidence_patch_hash_mismatch"};if(i.kind==="record_hash_mismatch")return{ok:!1,error:"rewrite_evidence_record_hash_mismatch"};if(i.kind==="digest_only")return{ok:!0,coverage:"digest_only"};if(i.kind==="legacy")return{ok:!0,coverage:"legacy_anchor_only"};if(!io(i.entry).ok)return{ok:!1,error:"rewrite_evidence_record_hash_mismatch"};n=i.entry}return{ok:!0,coverage:"complete"}}function Vo(e,t){return(e??"").localeCompare(t??"")}function Lm(e,t){return(e??0)-(t??0)}function He(e,t,n){return JSON.stringify(e??n).localeCompare(JSON.stringify(t??n))}function ck(e,t){return[e.scope.localeCompare(t.scope),Vo(e.path,t.path),Vo(e.command,t.command),Lm(e.timeout_seconds,t.timeout_seconds),Vo(e.pm_context_mode,t.pm_context_mode),+!!e.shared_host_safe-+!!t.shared_host_safe,He(e.env_clear,t.env_clear,[]),He(e.env_set,t.env_set,{}),He(e.assert_stdout_contains,t.assert_stdout_contains,[]),He(e.assert_stdout_regex,t.assert_stdout_regex,[]),He(e.assert_stderr_contains,t.assert_stderr_contains,[]),He(e.assert_stderr_regex,t.assert_stderr_regex,[]),Lm(e.assert_stdout_min_lines,t.assert_stdout_min_lines),He(e.assert_json_field_equals,t.assert_json_field_equals,{}),He(e.assert_json_field_gte,t.assert_json_field_gte,{}),Vo(e.note,t.note)].find(n=>n!==0)??0}function dk(e){return!e||e==="/"?[]:e.startsWith("/")?e.slice(1).split("/").map(t=>t.replaceAll("~1","/").replaceAll("~0","~")):[]}function lk(e,t){let n=dk(t);if(n.length===0)return!0;let r=e;for(let o of n){let i=/^(0|[1-9]\d*)$/.test(o)?Number(o):-1,s=Array.isArray(r)?i>=0&&i<r.length?r[i]:void 0:bt(r)&&Object.prototype.hasOwnProperty.call(r,o)?r[o]:void 0;if(s===void 0)return!1;r=s}return!0}function uk(e,t){let n=[],r=structuredClone(e);for(let o of t){let i=o.op==="replace"&&!lk(r,o.path)?{...o,op:"add"}:o;n.push(i),r=zm.applyPatch(r,[i],!0,!0).newDocument}return n}function qo(e,t,n=!1){if(!(e.metadata&&Object.keys(e.metadata).length>0))return{front_matter:{},body:e.body??""};let r=Lt(e),o=t===1||t===2&&n?{...r.metadata,...r.metadata.dependencies===void 0?{}:{dependencies:r.metadata.dependencies.map(s=>({...s,id:s.id.toLowerCase()}))},...r.metadata.tests===void 0?{}:{tests:r.metadata.tests.map(({workspace_context_mode:s,provenance:a,provenance_invalid:c,...d})=>d)},...r.metadata.test_runs===void 0?{}:{test_runs:r.metadata.test_runs.map(({executions:s,...a})=>a)}}:r.metadata,i=t===1&&o.tests?{...o,tests:[...o.tests].sort(ck)}:o;return{front_matter:Ke(i,Oe),body:r.body}}function Fm(e){if(!(e.metadata&&Object.keys(e.metadata).length>0))return{metadata:{},body:e.body??""};let t=Lt(e);return{metadata:Ke(t.metadata,Oe),body:t.body}}function La(e){return qm(e,nt)}function qm(e,t,n){if(!Tn.some(r=>r===t))throw new TypeError(`unsupported_item_hash_version:${String(t)}`);return Ie(C(qo(e,t)),n)}function ru(e,t,n){let r=qm(e,t,n);return t===2?[r,Ie(C(qo(e,t,!0)),n)]:[r]}function J$(){return Tt(C(QS))}function Q$(e){let t=Ud(e.op),n=qo(e.before,nt),r=qo(e.after,nt),o=Fm(e.before),i=Fm(e.after),s=zm.compare(o,i),a=uk(o,s),c=Bl(e.author),d=c.harness?Object.fromEntries(Object.entries(Vl().provenance_outcomes).filter(([m,p])=>p.resolver!==void 0&&(p.status!=="resolved"||c.provenance?.[m]?.source==="probe"))):void 0,l=d===void 0||Object.keys(d).length===0?e.context:{...e.context,agent_provenance_outcomes:d},u=e.hashAlgorithm??zd,f={hash_algorithm:u,ts:e.nowIso,author:e.author,author_source:e.authorSource??ql(e.author),...c.harness?{agent_harness:c.harness}:{},...c.model?{agent_model:c.model}:{},...c.model_source?{agent_model_source:c.model_source}:{},...c.instance?{agent_instance:c.instance}:{},...c.provenance?{agent_provenance:c.provenance}:{},...c.episode?{agent_episode:c.episode}:{},op:t,patch:a,before_hash:Ie(C(n),u),after_hash:Ie(C(r),u),item_hash_version:nt,message:e.message===void 0?void 0:e.message,...l===void 0?{}:{context:l}};return ja({...f,event_class:zt(f)})}function bt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Pa(e){return new h(e,g.GENERIC_FAILURE,{code:"history_timestamp_invalid"})}function Bm(e){let t=e.ts.trim();if(t.length===0)return hn();if(!Dt(t))throw Pa("History timestamp must be a valid RFC 3339 date-time with millisecond precision");if(t!==e.ts)throw Pa("History timestamp must not contain surrounding whitespace");return e.ts}function Um(e,t){let n=e.ts;if(typeof n=="string"&&n.trim().length>0){if(!Dt(n))throw Pa("History timestamp must be a valid RFC 3339 date-time with millisecond precision");return e}return{...e,ts:t}}function $a(e,t){let n=Bm(t);if(typeof e=="string"){let r;try{r=JSON.parse(e)}catch{return e}return bt(r)?JSON.stringify(Um(r,n)):e}return bt(e)?JSON.stringify(Um(e,n)):JSON.stringify(e)}async function fk(e,t,n){if(n===!1)return!0;if(typeof n=="string"){let s=$a(n,t);return await Ma(e,s),await Ho(e),await zs(e),!0}if(typeof n!="object"||n===null)return!1;let r=n;if(r.skip===!0)return!0;let o=typeof r.history_path=="string"?r.history_path:e,i=$a(typeof r.line=="string"?r.line:r.entry??t,t);return await Ma(o,i),await Ho(o),await zs(o),!0}async function Ma(e,t){let n;try{n=JSON.parse(t)}catch{n=null}if(!bt(n)||n.op!=="create"){await Vc(e,t);return}await jm.mkdir(JS.dirname(e),{recursive:!0});try{await jm.writeFile(e,`${t}
111
+ `,{encoding:"utf8",flag:"wx"})}catch(r){throw r.code!=="EEXIST"?r:new h("This item identity is reserved by an existing history stream.",g.CONFLICT,{code:"item_identity_reserved",required:"Choose a new item ID or restore the original item from its history.",nextSteps:["Run pm history <id> --full, then pm restore <id> <version> to recover the original item."]})}}async function Z$(e,t){let n=await en("history_append",{history_path:e,entry:t});if(n.handled&&await fk(e,t,n.result))return;let r=t.ts.trim().length>0?t:{...t,ts:Bm(t)},o=ja({...r,hash_algorithm:Xe(r.hash_algorithm),event_class:zt(r)});await ku(e,o,async()=>{await Ma(e,$a(o,o))}),await Ho(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bc6de6a9-454a-5dda-ab67-8f4a2f5c38d8")}catch{}})();var Fa=new Wm;function dM(e,t){return Fa.run([...Fa.getStore()??[],{...e,pmRoot:Ua.resolve(e.pmRoot)}],t)}var pk=Symbol.for("@unbrained/pm-cli/item-revision-scopes"),_k=globalThis,Xn=_k[pk]??=new Wm;function tn(e){let t=Ua.resolve(e);try{return mk.native(t)}catch{return t}}function lM(){return{entries:new Map}}function uM(e,t){return Xn.run([...Xn.getStore()??[],e],t)}function fM(e,t,n){let r=tn(t);if(e.pmRoot!==void 0&&e.pmRoot!==r)throw new h("An expected-revision scope is already bound to another tracker.",g.USAGE,{code:"expected_revision_scope_conflict",required:"Bind expected item revisions for one tracker per scope."});e.pmRoot=r;for(let{id:o,itemHash:i}of n){let s=e.entries.get(o);if(s!==void 0&&s.declared!==i)throw new h(`Item ${o} has two different expected revisions.`,g.USAGE,{code:"expected_revision_duplicate",item_id:o,required:"Declare at most one expected revision per item."});e.entries.set(o,s??{declared:i,expected:i,checked:!1,committed:!1})}}function mM(e){let t=[...e.entries.entries()];return{checked:t.filter(([,n])=>n.checked).map(([n])=>n),unchecked:t.filter(([,n])=>!n.checked).map(([n])=>n)}}function za(e,t){let n=Xn.getStore()??[];if(n.length===0)return[];let r=tn(e),o=new Set(t.filter(i=>typeof i=="string"));return[...new Set(n.flatMap(i=>i.pmRoot===r?[...o].flatMap(s=>i.entries.get(s)??[]):[]))]}function pM(e){let t=Xn.getStore()??[];if(t.length===0)return[];let n=tn(e),r=new Map;for(let o of t)if(o.pmRoot===n)for(let[i,s]of o.entries){if(s.expected!==s.declared)return;r.set(i,(r.get(i)??new Set).add(s.expected))}if(![...r.values()].some(o=>o.size>1))return[...r].map(([o,i])=>`${o}=${[...i][0]}`)}function _M(e){let t=tn(e);return(Xn.getStore()??[]).some(n=>n.pmRoot===t&&n.entries.size>0)}function yk(e,t,n){let r=za(e,[n,t.metadata.id]);r.length>0&&Ym(r,n,La(t),!1,e)}function yM(e,t,n){let r=za(e,[t]);r.length>0&&Ym(r,t,Tt(n),!0,e)}var gk="revision_changed",hk="document_unreadable";function bk(e,t,n={}){let r=[...n.scopeArgs??[]],o=[...n.outputArgs??["--json"]],i=se([...r,"get",e,...o]),s=se([...r,"history",e,"--limit","5",...o]);return{required:t?`Recover ${e} without --expect-hash (${se([...r,"restore",e,"<version>"])}), since no declared revision describes an unreadable document.`:`Re-read ${e} (${i} reports item_hash), decide again against the current revision, then retry with --expect-hash <item_hash>.`,examples:[se([...r,"get",e,"--fields","item_hash",...o]),s],nextSteps:[i,s]}}var wk=Symbol.for("@unbrained/pm-cli/item-revision-refusal-trackers"),vk=globalThis,Ha=vk[wk]??=new WeakMap,Ek=8;function Gm(e){for(let t of Km(e)){let n=Ha.get(t);if(n!==void 0)return n}}function*Km(e){let t=e;for(let n=0;n<Ek&&typeof t=="object"&&t!==null;n+=1){yield t;try{t=t.cause}catch{return}}}function Ym(e,t,n,r,o){for(let i of e)if(i.checked=!0,!(!r&&i.expected===n))throw Ak(o,new h(`Item ${t} is no longer at the expected revision ${i.expected.slice(0,12)}${r?" (its live document cannot be read)":""}; refusing to write over a revision this decision did not see.${i.committed?" Earlier writes by this same invocation already committed.":" Nothing was written to this item."}`,g.CONFLICT,{code:"item_revision_conflict",item_id:t,expected_revision:i.expected,current_revision:n,reason:r?hk:gk,why:"The caller declared the revision its decision was based on, and another write changed the item before this locked write.",...bk(t,r)}))}function gM(e,t){let n=Gm(e);return n===void 0||n===tn(t)}var Ok=Symbol.for("@unbrained/pm-cli/item-revision-scoped-refusals"),Sk=globalThis,Va=Sk[Ok]??=new WeakSet;function kk(e){for(let t of Km(e))if(Va.has(t))return!0;return!1}function hM(e){return Va.add(e),e}function bM(e,t){let n=Gm(e);return n!==void 0&&Ha.set(t,n),kk(e)&&Va.add(t),t}function Ak(e,t){return Ha.set(t,tn(e)),t}function wM(e,t,n=t.metadata.id){yk(e,t,n);for(let r of Bo(e,[n,t.metadata.id]))r.validate(t),r.compensation!==void 0&&n===r.id&&(r.compensation.validated_storage_id=n)}function Bo(e,t){let n=Ua.resolve(e);return(Fa.getStore()??[]).filter(r=>r.pmRoot===n&&t.includes(r.id))}function vM(e,t,n=t.metadata.id,r=[],o){let i=za(e,[n,t.metadata.id,...r]);if(i.length>0){let s=o??La(t);for(let a of i)a.expected=s,a.committed=!0}for(let s of Bo(e,[n,t.metadata.id,...r]))s.committed?.(t)}function qa(e,t,n){let r=t.filter(o=>o!==void 0);if(!r.some(o=>o!==r[0]))return Bo(e,[r[0]]).find(o=>o.compensation?.operations.includes(n)===!0&&o.compensation.validated_storage_id===o.id)?.compensation}function EM(e,t,n){let r=qa(e,t,n);return r===void 0||r.overrides.length===0?{}:{transaction_compensation:{transaction_id:r.transaction_id,step_id:r.step_id,overridden:structuredClone(r.overrides)}}}function OM(e,t){return Object.assign({},...Bo(e,t).map(n=>n.historyContext))}import St from"node:fs/promises";import Ot from"node:path";import{pathToFileURL as YA}from"node:url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2ea7934f-4751-5245-a5ba-492681aa3794")}catch{}})();var Ba=[{kind:"blocked_by",direction:"directed",traversal:"ordering",inverse:"blocks",ordering:!0,precedence:"target_before_source",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["depends_on"],compatibilityVersion:1,allowSelf:!1},{kind:"blocks",direction:"directed",traversal:"ordering",inverse:"blocked_by",ordering:!0,precedence:"source_before_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"parent",direction:"directed",traversal:"hierarchy",outcomeTraversal:"source_to_target",inverse:"child",ordering:!1,hierarchy:!0,hierarchyDirection:"target_parent",outgoing:"one",incoming:"many",lifecycle:"supersedable",aliases:["child_of","epic"],compatibilityVersion:1,allowSelf:!1},{kind:"child",direction:"directed",traversal:"hierarchy",outcomeTraversal:"target_to_source",inverse:"parent",ordering:!1,hierarchy:!0,hierarchyDirection:"source_parent",outgoing:"many",incoming:"one",lifecycle:"supersedable",aliases:["parent_child","task"],compatibilityVersion:1,allowSelf:!1},{kind:"related",direction:"undirected",traversal:"association",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["related_to"],compatibilityVersion:1,allowSelf:!1},{kind:"discovered_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"incident_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"implements",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"recurs_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,temporalOrder:"source_after_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"verifies",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"supersedes",direction:"directed",traversal:"semantic",outcomeTraversal:"both",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"supersedable",compatibilityVersion:1,allowSelf:!1}];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="418b3f7f-6350-5878-a362-3948de287baf")}catch{}})();function Ko(e){return e.trim().toLowerCase().replaceAll("-","_")}function Ik(e){if(e===void 0)return;let t=Ko(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function Ga(e,t=new Set){if(e===null||typeof e!="object"||t.has(e))return e;if(t.add(e),Array.isArray(e)){for(let n of e)Ga(n,t);return Object.freeze(e)}for(let n of Object.values(e))Ga(n,t);return Object.freeze(e)}function Tk(e,t){if(e.precedence!==void 0&&e.precedence!=="source_before_target"&&e.precedence!=="target_before_source")throw new TypeError(`Invalid relationship precedence for ${t}`);if(!e.ordering&&e.precedence!==void 0)throw new TypeError(`Non-ordering relationship kind cannot declare precedence: ${t}`)}function Ck(e,t){if(e.temporalOrder!==void 0&&e.temporalOrder!=="source_after_target")throw new TypeError(`Invalid relationship temporal order for ${t}`);if(e.direction!=="directed"&&e.temporalOrder!==void 0)throw new TypeError(`Undirected relationship kind cannot declare temporal order: ${t}`)}function Rk(e,t){if(e.hierarchyDirection!==void 0&&e.hierarchyDirection!=="source_parent"&&e.hierarchyDirection!=="target_parent")throw new TypeError(`Invalid relationship hierarchy direction for ${t}`);if(!e.hierarchy&&e.hierarchyDirection!==void 0)throw new TypeError(`Non-hierarchy relationship kind cannot declare hierarchy direction: ${t}`)}function xk(e){if(typeof e!="object"||e===null)throw new TypeError("Relationship kind definition requires an object");if(typeof e.kind!="string")throw new TypeError("Relationship kind requires a string identifier");let t=Ko(e.kind);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid relationship kind: ${e.kind}`);if(!Number.isInteger(e.compatibilityVersion)||e.compatibilityVersion<1)throw new TypeError(`Invalid compatibility version for ${t}`);return t}function Nk(e,t){if(!["directed","undirected"].includes(e.direction))throw new TypeError(`Invalid relationship direction for ${t}`);if(typeof e.ordering!="boolean")throw new TypeError(`Invalid relationship ordering flag for ${t}`);if(![void 0,!0,!1].includes(e.hierarchy))throw new TypeError(`Invalid relationship hierarchy flag for ${t}`);if(!["one","many"].includes(e.outgoing))throw new TypeError(`Invalid outgoing relationship cardinality for ${t}`);if(!["one","many"].includes(e.incoming))throw new TypeError(`Invalid incoming relationship cardinality for ${t}`);if(!["persistent","supersedable","ephemeral"].includes(e.lifecycle))throw new TypeError(`Invalid relationship lifecycle for ${t}`);if(typeof e.allowSelf!="boolean")throw new TypeError(`Invalid relationship self-edge flag for ${t}`);if(e.traversal!==void 0&&!["hierarchy","ordering","semantic","association"].includes(e.traversal))throw new TypeError(`Invalid relationship traversal family for ${t}`);if(e.outcomeTraversal!==void 0&&!["source_to_target","target_to_source","both"].includes(e.outcomeTraversal))throw new TypeError(`Invalid outcome traversal for ${t}`);if(e.direction==="undirected"&&e.outcomeTraversal!==void 0&&e.outcomeTraversal!=="both")throw new TypeError(`Undirected relationship kind cannot declare directional outcome traversal: ${t}`)}function Dk(e,t){if(e.payloadSchema!==void 0&&(typeof e.payloadSchema!="object"||e.payloadSchema===null||Array.isArray(e.payloadSchema)))throw new TypeError(`Invalid relationship payload schema for ${t}`);if(e.aliases!==void 0&&(!Array.isArray(e.aliases)||e.aliases.some(n=>typeof n!="string")))throw new TypeError(`Invalid relationship aliases for ${t}`)}function Pk(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var Ka=class{#e=new Map;#n=new Map;constructor(t=Ba){for(let n of t)this.register(n)}register(t){let n=xk(t);if(Nk(t,n),Dk(t,n),Tk(t,n),Ck(t,n),Rk(t,n),this.#e.has(n)||this.#n.has(n))throw new TypeError(`Relationship kind already registered: ${n}`);let r=Ik(t.inverse),o=[...new Set((t.aliases??[]).map(Ko))].sort();for(let s of o){if(!/^[a-z][a-z0-9_]*$/.test(s))throw new TypeError(`Invalid relationship alias: ${s}`);if(s===n||this.#e.has(s)||this.#n.has(s))throw new TypeError(`Relationship alias already registered: ${s}`)}let i=Object.freeze({...t,kind:n,traversal:Pk(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:r,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?Ga(structuredClone(t.payloadSchema)):void 0});this.#e.set(n,i);for(let s of o)this.#n.set(s,n);return this}resolve(t){if(typeof t!="string")return;let n=Ko(t);return this.#e.get(this.#n.get(n)??n)}require(t){let n=this.resolve(t);if(!n)throw new TypeError(`Unknown relationship kind: ${t}`);return n}list(){return Object.freeze([...this.#e.values()].sort((t,n)=>t.kind.localeCompare(n.kind)))}};function Ya(){return new Ka}var wt=Ya();function TM(e){return wt.require(e).kind}function CM(e){return wt.resolve(e)?.kind}function RM(e,t=wt){return t.resolve(e)?.ordering===!0}function $k(e,t,n,r=wt){let o=Jn(e),i=Jn(t);if(!o||!i)throw new TypeError("Relationship endpoint must not be empty");let s=r.require(n);if(o===i&&!s.allowSelf)throw new TypeError(`Self relationship is not allowed for ${s.kind}`);return s}function Wo(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function Mk(e,t,n){let r=typeof e.source=="string"?e.source.trim():"",o=typeof e.target=="string"?e.target.trim():"";if(!t.has(r)||!t.has(o))throw new TypeError(`Relationship endpoint not found: ${r} -> ${o}`);let i=$k(r,o,e.kind,n),s=Object.freeze({...e,source:r,target:o,kind:i.kind}),a=i.direction==="undirected"?[r,o].sort().join("\0"):`${r}\0${o}`;return{edge:s,identity:`${i.kind}\0${a}`}}function Go(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function Jn(e){return typeof e=="string"?e.trim():""}function Wa(e,t){let n=Jn(e);return n&&t.has(n)?n:void 0}function jk(e,t,n){let r=[t],o=t;for(;o!==e;)o=n.get(o),r.push(o);return r.reverse()}var Xm=class e{#e;#n;#o;#r;#s=new Map;#a=new Map;constructor(t,n,r=wt){this.#e=r,this.#n=new Set([...t].filter(i=>typeof i=="string").map(i=>i.trim()).filter(Boolean)),this.#o=Object.freeze([...this.#n].sort());let o=new Map;for(let i of n){let{edge:s,identity:a}=Mk(i,this.#n,r);o.set(a,s)}this.#r=Object.freeze([...o.values()].sort(Wo));for(let i of this.#r)Go(this.#s,i.source,i),Go(this.#a,i.target,i),r.require(i.kind).direction==="undirected"&&(Go(this.#s,i.target,i),Go(this.#a,i.source,i))}static fromItems(t,n=wt){let r=new Set(t.map(i=>Jn(i.id)).filter(Boolean)),o=[];for(let i of t){let s=Jn(i.id);if(!s)continue;let a=Wa(i.parent,r);a&&o.push({source:s,target:a,kind:"parent"});let c=Wa(i.blocked_by,r);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let d of i.dependencies??[]){let l=Wa(d.id,r);l&&n.resolve(d.kind)&&o.push({source:s,target:l,kind:d.kind,createdAt:d.created_at,author:d.author})}}return new e(r,o,n)}edges(){return this.#r}incidentEdges(t){this.#i(t);let n=this.#s.get(t)??[],r=this.#a.get(t)??[];if(n.length===0)return Object.freeze([...r]);if(r.length===0)return Object.freeze([...n]);let o=[],i=0,s=0;for(;i<n.length||s<r.length;){let a=n[i],c=r[s],d=a===void 0?c:c===void 0||Wo(a,c)<=0?a:c;o.at(-1)!==d&&o.push(d),a===d&&(i+=1),c===d&&(s+=1)}return Object.freeze(o)}nodes(){return this.#o}hasNode(t){return this.#n.has(t)}registry(){return this.#e}#i(t){if(!this.#n.has(t))throw new TypeError(`Relationship node not found: ${t}`)}#c(t,n){if(!n)return!0;let r=this.#e.require(t.kind);return n.has(t.kind)||r.inverse!==void 0&&n.has(r.inverse)}#t(t,n,r){let o=[...n==="incoming"?[]:this.#s.get(t)??[],...n==="outgoing"?[]:this.#a.get(t)??[]];return[...new Set(o)].filter(i=>this.#c(i,r)).map(i=>({id:i.source===t?i.target:i.source,edge:i})).sort((i,s)=>i.id.localeCompare(s.id)||Wo(i.edge,s.edge))}adjacency(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=[...new Set(o.map(c=>c.id))],a=s.slice(0,i);return{value:a,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:a.length<s.length,nextCursor:a.at(-1)}}}neighborEdges(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(a=>this.#e.require(a).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=o.slice(0,i);return{value:s,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:s.length<o.length,nextCursor:s.at(-1)?.id}}}closure(t,n={}){this.#i(t);let r=n.kinds?new Set(n.kinds.map(m=>this.#e.require(m).kind)):void 0,o=n.direction??"outgoing",i=n.limit??Number.POSITIVE_INFINITY,s=n.maxDepth??Number.POSITIVE_INFINITY,a=new Set([t]),c=[],d=[{id:t,depth:0}],l=0,u=0,f=!1;e:for(let m=0;m<d.length;m+=1){n.signal?.throwIfAborted();let p=d[m];l+=1;let _=this.#t(p.id,o,r);if(u+=_.length,p.depth>=s){_.some(y=>!a.has(y.id))&&(f=!0);continue}for(let y of _)if(!a.has(y.id)){if(c.length>=i){f=!0;break e}a.add(y.id),c.push(y.id),d.push({id:y.id,depth:p.depth+1})}}return{value:c,meta:{visitedNodes:l,inspectedEdges:u,truncated:f,nextCursor:c.at(-1)}}}shortestPath(t,n,r={}){if(this.#i(t),this.#i(n),t===n)return{value:[t],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}};let o=r.kinds?new Set(r.kinds.map(m=>this.#e.require(m).kind)):void 0,i=r.direction??"outgoing",s=r.maxDepth??Number.POSITIVE_INFINITY,a=[{id:t,depth:0}],c=new Map,d=new Set([t]),l=0,u=0,f=!1;for(let m=0;m<a.length;m+=1){r.signal?.throwIfAborted();let p=a[m];l+=1;let _=this.#t(p.id,i,o);if(u+=_.length,p.depth>=s){_.some(y=>!d.has(y.id))&&(f=!0);continue}for(let y of _)if(!d.has(y.id)){if(c.set(y.id,p.id),y.id===n)return{value:jk(t,n,c),meta:{visitedNodes:l,inspectedEdges:u,truncated:!1}};d.add(y.id),a.push({id:y.id,depth:p.depth+1})}}return{value:[],meta:{visitedNodes:l,inspectedEdges:u,truncated:f}}}subgraph(t,n={}){let r=this.closure(t,n),o=[t,...r.value].sort(),i=new Set(o),s=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,a=new Set;for(let c of o)for(let d of this.#s.get(c)??[])i.has(d.source)&&i.has(d.target)&&this.#c(d,s)&&a.add(d);return{value:{nodes:o,edges:[...a].sort(Wo)},meta:r.meta}}};function xM(e,t,n=wt){return{source:e,target:t.id,kind:n.require(t.kind).kind,createdAt:t.created_at,author:t.author}}import nn from"node:fs";import be from"node:path";import{fileURLToPath as Lk}from"node:url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="efea1aa1-1ad1-5f53-a3a5-b83803d9deb1")}catch{}})();var Fk="@unbrained/pm-cli";function Uk(e){try{return JSON.parse(nn.readFileSync(e,"utf8")).name===Fk}catch{return!1}}function zk(e){let t=nn.existsSync(e)&&nn.statSync(e).isDirectory()?be.resolve(e):be.dirname(be.resolve(e));for(;;){let n=be.join(t,"package.json");if(nn.existsSync(n)&&Uk(n))return t;let r=be.dirname(t);if(r===t)return;t=r}}function Yo(e,t=[]){let n=Lk(e);return zk(n)||be.resolve(be.dirname(n),...t)}function MM(e,t=[]){try{let n=be.join(Yo(e,t),"package.json");if(!nn.existsSync(n))return;let r=JSON.parse(nn.readFileSync(n,"utf8"));return typeof r.version=="string"&&r.version.trim().length>0?r.version:void 0}catch{return}}function jM(e=process.env,t="PM_CLI_PACKAGE_ROOT",n,r=[]){let o=e[t];return typeof o=="string"&&o.trim().length>0?be.resolve(o.trim()):n?Yo(n,r):process.cwd()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="559b05dc-0290-5a7c-97b9-ef1e5e8670ba")}catch{}})();function Jm(e){let t={beforeCommand:e.hooks.beforeCommand.length,beforeMutation:e.hooks.beforeMutation.length,afterCommand:e.hooks.afterCommand.length,onWrite:e.hooks.onWrite.length,onRead:e.hooks.onRead.length,onIndex:e.hooks.onIndex.length,commandOverrides:e.commands.overrides.length,commandHandlers:e.commands.handlers.length,parserOverrides:e.parsers.overrides.length,preflightOverrides:e.preflight.overrides.length,serviceOverrides:e.services.overrides.length,rendererOverrides:e.renderers.overrides.length,registrations:Object.fromEntries(Object.entries(e.registrations).map(([n,r])=>[n,r.length]))};return()=>{e.hooks.beforeCommand.length=t.beforeCommand,e.hooks.beforeMutation.length=t.beforeMutation,e.hooks.afterCommand.length=t.afterCommand,e.hooks.onWrite.length=t.onWrite,e.hooks.onRead.length=t.onRead,e.hooks.onIndex.length=t.onIndex,e.commands.overrides.length=t.commandOverrides,e.commands.handlers.length=t.commandHandlers,e.parsers.overrides.length=t.parserOverrides,e.preflight.overrides.length=t.preflightOverrides,e.services.overrides.length=t.serviceOverrides,e.renderers.overrides.length=t.rendererOverrides;for(let[n,r]of Object.entries(t.registrations))e.registrations[n].length=r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="34536eba-0f92-5599-a807-5b39b000e733")}catch{}})();var Xa=Object.freeze(["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"]);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="60fd882d-7c92-5be5-bf46-7e3c128bfb58")}catch{}})();var Hk=new Set(Xa);function Vk(e){if(e!==void 0&&!Hk.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${Xa.join(", ")}`)}function Qm(e){$("registerCommand definition.action",e.action),$("registerCommand definition.family",e.family),$("registerCommand definition.description",e.description),$("registerCommand definition.intent",e.intent),$("registerCommand definition.tier",e.tier);let t=e.tier;if(t!==void 0&&t!=="core"&&t!=="standard"&&t!=="full"&&t!=="internal")throw new Error("registerCommand definition.tier must be core, standard, full, or internal");Vk(e.family)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f8657910-1392-5fae-afda-614b96dc8320")}catch{}})();function x(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function qk(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function te(e){return e?k(e):{}}function ne(e){return e?k(e):qk()}function k(e){return structuredClone(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="615b4955-a30d-5d45-a86d-4bcf7bd9bd7a")}catch{}})();var Bk=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),Wk=["commands","command_overrides","command_handlers","hooks","flag_commands","item_types","item_fields","relationship_kinds","migrations","profiles","importers","exporters","search_providers","vector_store_adapters","assurance_providers","parser_overrides","service_overrides","renderer_overrides"];function Gk(e,t){for(let n of Wk){let r=e[n];if(r===void 0)continue;if(!Array.isArray(r)||r.some(i=>typeof i!="string"))return!1;let o=r.map(i=>Bk.has(n)?x(i):i.trim()).filter(i=>i.length>0);t[n]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function Kk(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n;if(r.format!=="json"&&r.format!=="toon"||!Array.isArray(r.commands)||r.commands.some(o=>typeof o!="string")||typeof r.result_discriminator!="boolean")return null;t.push({format:r.format,commands:[...new Set(r.commands.map(o=>x(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:r.result_discriminator})}return t.sort((n,r)=>n.format.localeCompare(r.format))}function Yk(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n.commands;if(!Array.isArray(r)||r.some(o=>typeof o!="string"))return null;t.push({commands:[...new Set(r.map(o=>x(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return t}function Xo(e){if(e==null)return;if(typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.schema_version!==1)return null;let n={schema_version:1};if(!Gk(t,n))return null;let r=t.preflight_overrides;if(r!==void 0&&(!Number.isInteger(r)||r<0))return null;typeof r=="number"&&(n.preflight_overrides=r);let o=t.renderer_ownership;if(o!==void 0){let s=Kk(o);if(s===null)return null;n.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=Yk(i);if(s===null)return null;n.preflight_ownership=s}return n}function WM(e){return{schema_version:1,commands:e.commands,command_overrides:e.command_overrides,command_handlers:e.command_handlers,hooks:e.hooks,flag_commands:e.flag_commands,item_types:e.item_types,item_fields:e.item_fields,...e.relationship_kinds?{relationship_kinds:e.relationship_kinds}:{},migrations:e.migrations,profiles:e.profiles,importers:e.importers,exporters:e.exporters,search_providers:e.search_providers,vector_store_adapters:e.vector_store_adapters,...e.assurance_providers?{assurance_providers:e.assurance_providers}:{},parser_overrides:e.parser_overrides,service_overrides:e.service_overrides,renderer_overrides:e.renderer_overrides,...e.renderer_ownership?{renderer_ownership:e.renderer_ownership}:{},preflight_overrides:e.preflight_overrides,...e.preflight_ownership?{preflight_ownership:e.preflight_ownership}:{}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="07cb237c-3956-5997-85f8-972d2ee490d0")}catch{}})();function Xk(e){let t=j("registerExporter options.output",e),n=new Set(["channel","receipt","media_type"]);for(let r of Object.keys(t))if(!n.has(r))throw new TypeError(`registerExporter options.output contains unsupported field ${r}`);if(t.channel!=="stdout"&&t.channel!=="file")throw new TypeError("registerExporter options.output.channel must be stdout|file");if(t.receipt!==void 0&&t.receipt!=="suppress"&&t.receipt!=="render")throw new TypeError("registerExporter options.output.receipt must be suppress|render");if(t.channel==="stdout"&&t.receipt==="render")throw new TypeError("registerExporter stdout artifacts cannot render a host receipt");return $("registerExporter options.output.media_type",t.media_type),{channel:t.channel,receipt:t.receipt??(t.channel==="stdout"?"suppress":"render"),...typeof t.media_type=="string"?{media_type:t.media_type}:{}}}function Zm(e,t,n){if(e==="registerImporter"&&t.output!==void 0)throw new TypeError("registerImporter options.output is exporter-only");if(e!=="registerExporter"||t.output===void 0)return;let r=Xk(t.output);return!n&&r.channel==="stdout"&&(t.description="Export items with the registered extension adapter. Artifact bytes are written exclusively to stdout and the host receipt is suppressed by default."),r}function Ja(e,t,n){return{registration:t,action:n,command:e.command,args:k(e.args),options:k(e.options),global:k(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,...e.sdk===void 0?{}:{sdk:e.sdk}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fc2e7eac-cd1c-5885-aa27-e98455008a4f")}catch{}})();function ep(e){return!e.extensionReady||!e.enabledForLoad?null:{layer:e.layer,directory:e.directory,manifest_path:e.manifestPath,entry_path:e.entryPath,manifest:e.manifest,source_package:e.sourceIdentity?.package_name,source_aliases:e.sourceIdentity?.aliases,contributions:e.sourceIdentity?.contributions}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7359c10a-4c56-57ea-8254-fc26b19e5c84")}catch{}})();function Qn(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Ve(e){return pe.includes(e)}function tp(e){let t=e.trim().toLowerCase();return Ve(t)?t:null}function np(e){return e.filter(t=>!Ve(t))}function Qa(e){let t=e.trim().toLowerCase();return t.length===0?null:Mc[t]??null}function rp(e){let t=Qn([...e].map(i=>i.toLowerCase())),n=[],r=[];for(let i of t){let s=Qa(i);if(s){n.push(s),r.push({alias:i,target:s});continue}n.push(i)}let o=[...new Map(r.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:Qn(n),legacy_aliases:o}}function Jk(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=Qa(t);if(n)return n;let r=Math.max(1,Math.floor(t.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of pe){let a=Fr(t,s,r);a!==null&&a<i&&(i=a,o=s)}return o}function op(e,t,n){let r=pe.join(","),o=Jk(n)??"none";return`extension_capability_unknown:${e}:${t}:${n}:allowed=${r}:suggested=${o}`}function ip(e,t,n){let r=n.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${r}`}function Qk(e){let t=/^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(e.trim());if(!t)return null;let[,n,r,o,i,s]=t,a=n,c=i.split(",").map(u=>u.trim()).filter(u=>u.length>0),d=Qa(o),l=(s==="none"?void 0:s)??d??void 0;return{layer:a,name:r,capability:o,allowed_capabilities:c,capability_contract_version:gi,suggested_capability:l,suggestion_source:l?d===l?"legacy_alias":"nearest_match":void 0,legacy_alias_target:d??void 0}}function Zk(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,n,r,o]=t,i=n,s=[...pe],a=[];for(let c of o.split(",")){let[d,l]=c.split(">"),u=d?.trim(),f=l?.trim().toLowerCase();!u||!f||!Ve(f)||a.push({layer:i,name:r,capability:u,allowed_capabilities:s,capability_contract_version:gi,suggested_capability:f,suggestion_source:"legacy_alias",legacy_alias_target:f})}return a}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bb1b4879-079c-50d4-afa5-e8a36ead2e5c")}catch{}})();function ie(e){return typeof e!="string"?"":e.trim().toLowerCase()}function A(e){return new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))}function eA(e){let t=e.trim().toLowerCase();if(t.length===0)return"";let n=t.split(/[.:/]/).map(r=>r.replace(/[\s_-]+/g,"")).filter(r=>r.length>0);return n.length===0?"":n.length===1?n[0]:`${n[0]}.${n.slice(1).join("")}`}function rn(e){return new Set((e??[]).map(t=>eA(t)).filter(t=>t.length>0))}function sp(e){let t=ie(e);return _r.includes(t)?t:"off"}function ap(e){let t=ie(e);return yr.includes(t)?t:"off"}function Zn(e){let t=ie(e);return gr.includes(t)?t:"none"}function Za(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return jc.includes(t)?t:void 0}function cp(e){if(typeof e=="string"){let t=Za(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:Za(e.global)??"block",project:Za(e.project)??"block"}:{global:"block",project:"block"}}function tA(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function R(e){return[...new Set(e)].sort((t,n)=>t.localeCompare(n))}function nA(e){let t=ie(e.name);return t.length===0?null:{name:t,normalized:{name:t,disabled:e.disabled===!0,requireTrusted:e.require_trusted===!0,requireProvenance:e.require_provenance===!0,sandboxProfile:e.sandbox_profile!==void 0?Zn(e.sandbox_profile):void 0,allowedCapabilities:A(e.allowed_capabilities),blockedCapabilities:A(e.blocked_capabilities),allowedSurfaces:rn(e.allowed_surfaces),blockedSurfaces:rn(e.blocked_surfaces),allowedCommands:A(e.allowed_commands),blockedCommands:A(e.blocked_commands),allowedActions:A(e.allowed_actions),blockedActions:A(e.blocked_actions),allowedServices:A(e.allowed_services),blockedServices:A(e.blocked_services)}}}function dp(e){let t=new Map;for(let n of e??[]){let r=nA(n);r&&t.set(r.name,r.normalized)}return t}function rA(e){let t=[],n=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of R([...e.allowedCapabilities,...e.blockedCapabilities]))Ve(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of n)for(let i of R([...o.allowedCapabilities,...o.blockedCapabilities]))Ve(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let r=new Set(hr);for(let o of R([...e.allowedSurfaces,...e.blockedSurfaces]))r.has(o)||t.push(`extension_policy_unknown_surface:${o}`);for(let o of n)for(let i of R([...o.allowedSurfaces,...o.blockedSurfaces]))r.has(i)||t.push(`extension_policy_unknown_surface:${o.name}:${i}`);return[...new Set(t)].sort((o,i)=>o.localeCompare(i))}function lp(e){let t=e.extensions?.policy??{},n=A(t.allowed_capabilities),r=A(t.blocked_capabilities),o=rn(t.allowed_surfaces),i=rn(t.blocked_surfaces),s=dp(t.extension_overrides);return{mode:sp(t.mode),trustMode:ap(t.trust_mode),pmMaxVersionExceededMode:cp(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:A(t.trusted_extensions),defaultSandboxProfile:Zn(t.default_sandbox_profile),allowedExtensions:A(t.allowed_extensions),blockedExtensions:A(t.blocked_extensions),allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:A(t.allowed_commands),blockedCommands:A(t.blocked_commands),allowedActions:A(t.allowed_actions),blockedActions:A(t.blocked_actions),allowedServices:A(t.allowed_services),blockedServices:A(t.blocked_services),overridesByName:s,warnings:rA({allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function up(e){let t=[...e.overridesByName.values()].sort((n,r)=>n.name.localeCompare(r.name)).map(n=>({name:n.name,...n.disabled?{disabled:!0}:{},...n.requireTrusted?{require_trusted:!0}:{},...n.requireProvenance?{require_provenance:!0}:{},...n.sandboxProfile?{sandbox_profile:n.sandboxProfile}:{},...n.allowedCapabilities.size>0?{allowed_capabilities:R(n.allowedCapabilities)}:{},...n.blockedCapabilities.size>0?{blocked_capabilities:R(n.blockedCapabilities)}:{},...n.allowedSurfaces.size>0?{allowed_surfaces:R(n.allowedSurfaces)}:{},...n.blockedSurfaces.size>0?{blocked_surfaces:R(n.blockedSurfaces)}:{},...n.allowedCommands.size>0?{allowed_commands:R(n.allowedCommands)}:{},...n.blockedCommands.size>0?{blocked_commands:R(n.blockedCommands)}:{},...n.allowedActions.size>0?{allowed_actions:R(n.allowedActions)}:{},...n.blockedActions.size>0?{blocked_actions:R(n.blockedActions)}:{},...n.allowedServices.size>0?{allowed_services:R(n.allowedServices)}:{},...n.blockedServices.size>0?{blocked_services:R(n.blockedServices)}:{}}));return{mode:e.mode,trust_mode:e.trustMode,pm_max_version_exceeded_mode:tA(e.pmMaxVersionExceededMode),require_provenance:e.requireProvenance,trusted_extensions:R(e.trustedExtensions),default_sandbox_profile:e.defaultSandboxProfile,allowed_extensions:R(e.allowedExtensions),blocked_extensions:R(e.blockedExtensions),allowed_capabilities:R(e.allowedCapabilities),blocked_capabilities:R(e.blockedCapabilities),allowed_surfaces:R(e.allowedSurfaces),blocked_surfaces:R(e.blockedSurfaces),allowed_commands:R(e.allowedCommands),blocked_commands:R(e.blockedCommands),allowed_actions:R(e.allowedActions),blocked_actions:R(e.blockedActions),allowed_services:R(e.allowedServices),blocked_services:R(e.blockedServices),extension_overrides:t}}function fp(e){let t=dp(e.extension_overrides);return{mode:sp(e.mode),trustMode:ap(e.trust_mode),pmMaxVersionExceededMode:cp(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:A(e.trusted_extensions),defaultSandboxProfile:Zn(e.default_sandbox_profile),allowedExtensions:A(e.allowed_extensions),blockedExtensions:A(e.blocked_extensions),allowedCapabilities:A(e.allowed_capabilities),blockedCapabilities:A(e.blocked_capabilities),allowedSurfaces:rn(e.allowed_surfaces),blockedSurfaces:rn(e.blocked_surfaces),allowedCommands:A(e.allowed_commands),blockedCommands:A(e.blocked_commands),allowedActions:A(e.allowed_actions),blockedActions:A(e.blocked_actions),allowedServices:A(e.allowed_services),blockedServices:A(e.blocked_services),overridesByName:t,warnings:[]}}function qe(e,t){return e.overridesByName.get(ie(t))??null}function on(e,t,n,r,o){return t.has(n)?o:e.size>0&&!e.has(n)?r:null}function mp(e,t,n){let r=n.trim().toLowerCase(),o=qe(e,t.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return on(i,s,r,"capability_not_allowlisted","capability_blocked")}function oA(e,t,n){let r=qe(e,t.name),o=r&&r.allowedSurfaces.size>0?r.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...r?r.blockedSurfaces:[]]);return on(o,i,n,"surface_not_allowlisted","surface_blocked")}function iA(e,t,n){let r=x(n);if(r.length===0)return null;let o=qe(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return on(i,s,r,"command_not_allowlisted","command_blocked")}function sA(e,t,n){let r=ie(n).replace(/\s+/g,"-");if(r.length===0)return null;let o=qe(e,t.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return on(i,s,r,"action_not_allowlisted","action_blocked")}function aA(e,t,n){let r=ie(n);if(r.length===0)return null;let o=qe(e,t.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return on(i,s,r,"service_not_allowlisted","service_blocked")}function cA(e,t){let n=ie(t.name);return qe(e,t.name)?.disabled===!0?"extension_override_disabled":on(e.allowedExtensions,e.blockedExtensions,n,"extension_not_allowlisted","extension_blocked")}function dA(e,t){if(e.trustMode==="off")return null;let n=qe(e,t.name),r=ie(t.name),o=t.trusted===!0,i=t.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(r)?"extension_not_trusted":(n?.requireTrusted===!0||e.trustMode==="warn"||e.trustMode==="enforce")&&!o?"extension_untrusted":(e.requireProvenance||n?.requireProvenance===!0)&&!i?"provenance_missing_or_unverified":null}function lA(e,t){if(e.mode==="off")return null;let n=qe(e,t.name)?.sandboxProfile??t.sandboxProfile??e.defaultSandboxProfile;if(n==="none")return null;let r=t.permissions;if(!r)return"sandbox_permissions_missing";let o=i=>r[i]===!0;return n==="restricted"?o("process_spawn")?"sandbox_restricted_disallows_process_spawn":o("env_write")?"sandbox_restricted_disallows_env_write":null:o("process_spawn")?"sandbox_strict_disallows_process_spawn":o("network")?"sandbox_strict_disallows_network":o("fs_write")?"sandbox_strict_disallows_fs_write":o("env_write")?"sandbox_strict_disallows_env_write":null}function Jo(e,t,n,r,o={}){let i=Object.entries(o).sort((a,c)=>a[0].localeCompare(c[0])).map(([a,c])=>`${a}=${c}`).join(":"),s=i.length>0?`:${i}`:"";return`extension_policy_${e}_${t}:${n.layer}:${n.name}:reason=${r}${s}`}function pp(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let n=[],r=cA(e,t);r&&n.push({reason:r,scope:"extension",mode:e.mode});let o=dA(e,t);o&&n.push({reason:o,scope:"trust",mode:e.trustMode});let i=lA(e,t);i&&n.push({reason:i,scope:"extension",mode:e.mode});let s=n.find(c=>c.mode==="enforce");if(s)return{allowed:!1,warning:Jo("blocked",s.scope,t,s.reason)};let a=n.find(c=>c.mode==="warn");return a?{allowed:!0,warning:Jo("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function _p(e,t,n){if(e.mode==="off")return{allowed:!0,warning:null};let r=mp(e,t,n);return r?{allowed:e.mode==="warn",warning:Jo(e.mode==="warn"?"violation":"blocked","capability",t,r,{capability:n.trim().toLowerCase()})}:{allowed:!0,warning:null}}function uA(e,t,n,r,o){let i=typeof r=="string"?mp(e,t,r):null,s=oA(e,t,n),a=o.command?iA(e,t,o.command):null,c=o.action?sA(e,t,o.action):null,d=o.service?aA(e,t,o.service):null;return i??s??a??c??d}function fA(e,t,n,r){let o={method:ie(e).replace(/\s+/g,"_"),surface:t};return n&&(o.capability=n),r.command&&(o.command=x(r.command)),r.action&&(o.action=ie(r.action).replace(/\s+/g,"-")),r.service&&(o.service=ie(r.service)),o}function yp(e,t,n,r,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=uA(e,t,n,o,s);if(!a)return{allowed:!0,warning:null};let c=Jo(e.mode==="warn"?"violation":"blocked","registration",t,a,fA(r,n,o,s));return{allowed:e.mode==="warn",warning:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01116a5e-62d1-591b-9fd0-84ac6e99f8d0")}catch{}})();function er(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function ec(){return{overrides:[],handlers:[]}}function tc(){return{overrides:[]}}function nc(){return{overrides:[]}}function rc(){return{overrides:[]}}function oc(){return{overrides:[]}}function ic(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[],assurance_providers:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cd1de600-27e4-522b-842e-1993c12e9f0e")}catch{}})();var hp=100;function gp(e,t){let n=e[t];if(n!=null)return typeof n!="string"||n.trim().length===0?null:n.trim()}function mA(e){if(e==null)return;let t=Ae(e);if(!t)return null;let n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i))){if(r.trim().length===0)return null;let o=t[r];if(typeof o!="string"||o.trim().length===0)return null;n[r.trim()]=o.trim()}return Object.keys(n).length>0?n:void 0}function sc(e,t){let n=e[t];return typeof n!="string"||n.trim().length===0?null:n.trim()}function bp(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function vt(e){if(e!=null)return typeof e!="boolean"?null:e}function pA(e){let t=bp(e.priority);return t===void 0?hp:t}function _A(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let n=Zn(t);return n!==t.trim().toLowerCase()?null:n}function ac(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function yA(e){if(e==null)return;let t=Ae(e);if(!t)return null;let n=ac(t.source),r=ac(t.signature),o=ac(t.attestation),i=t.verified===void 0||t.verified===null?void 0:typeof t.verified=="boolean"?t.verified:null;return i===null?null:{...n?{source:n}:{},...r?{signature:r}:{},...o?{attestation:o}:{},...typeof i=="boolean"?{verified:i}:{}}}function gA(e){if(e==null)return;let t=Ae(e);if(!t)return null;let n=vt(t.fs_read),r=vt(t.fs_write),o=vt(t.network),i=vt(t.env_read),s=vt(t.env_write),a=vt(t.process_spawn);return[n,r,o,i,s,a].includes(null)?null:{...typeof n=="boolean"?{fs_read:n}:{},...typeof r=="boolean"?{fs_write:r}:{},...typeof o=="boolean"?{network:o}:{},...typeof i=="boolean"?{env_read:i}:{},...typeof s=="boolean"?{env_write:s}:{},...typeof a=="boolean"?{process_spawn:a}:{}}}function hA(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(n=>typeof n!="string"))return null;let t=rp(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function bA(e){if(e==null)return;let t=Ae(e);if(!t)return null;let n=t.commands;if(n==null)return;if(!Array.isArray(n)||n.some(o=>typeof o!="string"))return null;let r=[...new Set(n.map(o=>x(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return r.length>0?{commands:r}:void 0}function wA(e){let t=bp(e.manifest_version);if(t===null)return null;let n=gp(e,"pm_min_version");if(n===null)return null;let r=gp(e,"pm_max_version");if(r===null)return null;let o=mA(e.engines);if(o===null)return null;let i=vt(e.trusted);if(i===null)return null;let s=_A(e);if(s===null)return null;let a=yA(e.provenance);if(a===null)return null;let c=gA(e.permissions);if(c===null)return null;let d=hA(e.capabilities);if(d===null)return null;let l=bA(e.activation);if(l===null)return null;let u=Xo(e.contributions);return u===null?null:{manifest_version:t,pm_min_version:n,pm_max_version:r,engines:o,trusted:i,sandbox_profile:s,provenance:a,permissions:c,capabilities:d.capabilities,legacy_capability_aliases:d.legacy_aliases,activation:l,contributions:u}}function cc(e){if(typeof e!="object"||e===null)return null;let t=e,n=sc(t,"name");if(n===null)return null;let r=sc(t,"version");if(r===null)return null;let o=sc(t,"entry");if(o===null)return null;let i=pA(t);if(i===null)return null;let s=wA(t);return s===null?null:{name:n,version:r,entry:o,priority:i,manifest_version:s.manifest_version,pm_min_version:s.pm_min_version,pm_max_version:s.pm_max_version,engines:s.engines,trusted:s.trusted,provenance:s.provenance,sandbox_profile:s.sandbox_profile,permissions:s.permissions,activation:s.activation,contributions:s.contributions,capabilities:s.capabilities,legacy_capability_aliases:s.legacy_capability_aliases.length>0?s.legacy_capability_aliases:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="67511565-01f8-58a6-ad06-45b5d0ce831b")}catch{}})();var vA=new Set(["name","version","entry","priority","description","author","capabilities","manifest_version","pm_min_version","pm_max_version","engines","trusted","provenance","sandbox_profile","permissions","activation","contributions","legacy_capability_aliases"]);function EA(e){return{unknownKeys:Object.keys(e).filter(t=>!vA.has(t)).sort((t,n)=>t>n?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function OA(e){let t=EA(e),n=t.unknownKeys.map(r=>({code:"manifest_unknown_key",path:r,...r==="compatibility"?{suggested_key:"pm_min_version"}:{},message:r==="compatibility"?'Manifest key "compatibility" is ignored; declare the canonical pm_min_version and optional pm_max_version fields instead.':`Manifest key "${r}" is not part of the extension manifest contract and will be ignored.`}));return t.missingVersionBounds&&n.push({code:"no_version_bounds_declared",path:"$",suggested_key:"pm_min_version",message:"No canonical pm version bounds are declared; add pm_min_version so compatibility intent is explicit."}),{ok:n.length===0,findings:n}}function wp(e,t,n){return OA(n).findings.map(r=>r.code==="manifest_unknown_key"?`extension_manifest_unknown_key:${e}:${t.name}:key=${r.path}${r.suggested_key?`:suggested=${r.suggested_key}`:""}`:`extension_manifest_no_version_bounds:${e}:${t.name}:suggested=pm_min_version`)}import{constants as Be}from"node:os";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="151124a3-cefa-55d3-bf4f-bd8f2553ad72")}catch{}})();var vp=new Map([["EACCES",{summary:"was denied filesystem permission",recovery:"Grant the required filesystem access, then retry.",category:"permission"}],["EDQUOT",{summary:"exceeded the filesystem quota",recovery:"Raise or reclaim the filesystem quota, then retry.",category:"capacity"}],["EMFILE",{summary:"exhausted the process file-descriptor limit",recovery:"Close unused file handles or raise the process limit, then retry.",category:"resource"}],["ENFILE",{summary:"exhausted the host file-descriptor limit",recovery:"Free host file descriptors or raise the host limit, then retry.",category:"resource"}],["ENOMEM",{summary:"ran out of available memory",recovery:"Free memory or reduce concurrent work, then retry.",category:"resource"}],["ENOSPC",{summary:"ran out of storage space",recovery:"Free storage on the filesystem holding the project, then retry.",category:"capacity"}],["EPERM",{summary:"was denied by the host permission policy",recovery:"Grant the required filesystem permission, then retry.",category:"permission"}],["EROFS",{summary:"targeted a read-only filesystem",recovery:"Use a writable project filesystem or remount it read-write, then retry.",category:"permission"}]]),SA=/^[a-z][a-z0-9_]{0,63}$/u,kA=new Map([[Be.errno.EACCES,"EACCES"],[Be.errno.EDQUOT,"EDQUOT"],[Be.errno.EMFILE,"EMFILE"],[Be.errno.ENFILE,"ENFILE"],[Be.errno.ENOMEM,"ENOMEM"],[Be.errno.ENOSPC,"ENOSPC"],[Be.errno.EPERM,"EPERM"],[Be.errno.EROFS,"EROFS"]].filter(([e])=>Number.isInteger(e))),AA={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function IA(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&vp.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:kA.get(Math.abs(t.errno))??null}function TA(e,t,n={}){let r=IA(e);if(r===null)return null;if(!SA.test(t))throw new h("Host environment operation labels must be bounded identifiers.",g.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=vp.get(r);return new h(`Host filesystem operation ${t} ${o.summary}.`,g.GENERIC_FAILURE,{code:n.codes?.[o.category]??AA[o.category].code,reason:r,required:o.recovery,why:n.why??"The operating system refused a required project filesystem operation.",nextSteps:[o.recovery,...n.nextSteps??[]],...n.suggestedRetry?{recovery:{suggested_retry:n.suggestedRetry}}:{}})}async function Ep(e,t,n={}){try{return await t()}catch(r){throw TA(r,e,n)??r}}import CA from"node:fs/promises";import tr from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="029e0066-2ef5-5204-92ad-4866321710f4")}catch{}})();async function Op(e,t){let n=tr.dirname(t.manifest_path),r=tr.relative(n,t.entry_path);if(r.startsWith("..")||tr.isAbsolute(r))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=tr.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await Ep("extension_module_graph_snapshot",()=>CA.cp(n,o,{recursive:!0,force:!0})),tr.join(o,r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bf5c3834-b388-507e-a13c-3beb5d096abb")}catch{}})();function Sp(e){let t=typeof e=="function"?e:e.run;if(typeof t!="function")throw new TypeError("registerPreflight override requires a function handler");let n=[...new Set((typeof e=="function"?[]:e.commands??[]).map(r=>{if(typeof r!="string"||r.trim().length===0)throw new TypeError("registerPreflight ownership.commands must contain non-empty command paths");return x(r)}))];return{run:t,...n.length>0?{commands:n}:{}}}function kp(e){let t=[];for(let n=1;n<e.overrides.length;n+=1){let r=e.overrides[n];for(let o of e.overrides.slice(0,n))r.commands?.length&&o.commands?.length&&!o.commands.some(i=>r.commands.includes(i))||t.push(`extension_preflight_override_collision:${r.layer}:${r.name}:${o.layer}:${o.name}`)}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="47d10c23-88f8-5ba1-bcc2-458f339121a8")}catch{}})();var Qo=kr;function Ap(e){let t=e.trim().toLowerCase();return Qo.includes(t)?t:null}function Ip(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=Math.max(1,Math.floor(t.length*.34));for(let r of Qo)if(Fr(t,r,n)!==null)return r;return null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="355fe619-e6f3-51d9-b88c-0b57267c25be")}catch{}})();function Tp(e){return e==="toon"||e==="json"}function Cp(e){return It.includes(e)}function Et(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var Rp=Symbol("extension_registration_trace");function we(e,t){let n=new TypeError(e);return Object.defineProperty(n,Rp,{value:t,enumerable:!1,configurable:!1,writable:!1}),n}function xp(e){return e instanceof Error?e[Rp]:void 0}function nr(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>nr(t));if(typeof e=="function")return"[Function]";if(typeof e=="bigint"||typeof e=="symbol")return e.toString();if(typeof e=="object"){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=nr(t[r]);return n}return e}function rr(e){if(Array.isArray(e))return e.map(t=>rr(t));if(typeof e=="object"&&e!==null){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=rr(t[r]);return n}return e}function sn(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return nr(t)}function or(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return rr(t)}function ir(e,t){if(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(n=>sn(e,n))}function Y(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function sr(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function dc(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function lc(e,t){return x(`${e} ${t}`)}function ar(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var RA=new Set(["low","medium","high"]),xA=new Set(["number","string_set"]),NA=new Set(["string","number","boolean"]);function Np(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function DA(e,t,n){let r=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=j(r,n);if(!xA.has(String(o.value_type)))throw new TypeError(`${r}.value_type must be number or string_set`);if($(`${r}.description`,o.description),o.parameters===void 0)return;let i=j(`${r}.parameters`,o.parameters);for(let[s,a]of Object.entries(i)){let c=`${r}.parameters.${s}`;Np(`${c}.name`,s);let d=j(c,a);if(!NA.has(String(d.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);B(`${c}.required`,d.required),$(`${c}.description`,d.description)}if(Object.keys(i).length>50)throw new TypeError(`assurance provider ${e} key ${t} exceeds 50 parameters`)}function Dp(e){let t=j("registerAssuranceMeasurementProvider provider",e),n=Np("registerAssuranceMeasurementProvider provider.id",t.id);if(!/^[a-z0-9][a-z0-9-]*$/u.test(n))throw new TypeError("registerAssuranceMeasurementProvider provider.id must be a stable lowercase id");if(!RA.has(String(t.cost_class)))throw new TypeError("registerAssuranceMeasurementProvider provider.cost_class must be low, medium, or high");if(typeof t.network!="boolean")throw new TypeError("registerAssuranceMeasurementProvider provider.network must be boolean");let r=j("registerAssuranceMeasurementProvider provider.keys",t.keys);if(Object.keys(r).length===0)throw new TypeError("registerAssuranceMeasurementProvider provider.keys requires at least one key");for(let[o,i]of Object.entries(r)){if(!/^[a-z0-9][a-z0-9-]*$/u.test(o))throw new TypeError(`registerAssuranceMeasurementProvider provider key ${o} must be a stable lowercase id`);DA(n,o,i)}if(t.timeout_ms!==void 0&&(typeof t.timeout_ms!="number"||!Number.isInteger(t.timeout_ms)||t.timeout_ms<1||t.timeout_ms>3e5))throw new TypeError("registerAssuranceMeasurementProvider provider.timeout_ms must be an integer from 1 through 300000");if(typeof t.resolve!="function")throw new TypeError("registerAssuranceMeasurementProvider provider.resolve requires a function handler")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4abca948-e9ba-52b5-b63c-a20fc344980a")}catch{}})();var PA=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","value_validation","visible"]);function Zo(e,t){return ir(e,t).map(n=>(n.repeatable===!0&&(n.list=!0),n))}function $A(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function uc(e,t){if(t===void 0)return e.replace(/\s+/g,"-");if(typeof t!="string"||t.trim().length===0)throw new TypeError("registerCommand definition.action must be a non-empty string when provided");let n=$A(t);if(n.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return n}function fc(e){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("registerCommand definition.arguments must be an array when provided");let t=[];for(let[r,o]of e.entries()){let i=j(`registerCommand definition.arguments[${r}]`,o),s=Y(`registerCommand definition.arguments[${r}].name`,i.name);if(B(`registerCommand definition.arguments[${r}].required`,i.required),B(`registerCommand definition.arguments[${r}].variadic`,i.variadic),$(`registerCommand definition.arguments[${r}].description`,i.description),s.includes(" "))throw new TypeError(`registerCommand definition.arguments[${r}].name must not contain spaces`);let a={name:s};i.required===!0&&(a.required=!0),i.variadic===!0&&(a.variadic=!0),typeof i.description=="string"&&(a.description=i.description.trim()),t.push(a)}let n=t.map((r,o)=>r.variadic?o:-1).filter(r=>r>=0);if(n.length>1)throw new TypeError("registerCommand definition.arguments supports at most one variadic argument");if(n.length===1&&n[0]!==t.length-1)throw new TypeError("registerCommand definition.arguments variadic argument must be the final argument");return t}function ei(e){if(!Array.isArray(e))throw new TypeError("registerFlags flags requires an array of object definitions");for(let[t,n]of e.entries()){let r=j(`registerFlags flags[${t}]`,n),o=Object.keys(r).filter(c=>!PA.has(c)).sort((c,d)=>c.localeCompare(d));if(o.length>0)throw new TypeError(`registerFlags flags[${t}] contains unknown field(s): ${o.join(", ")}`);let i=r.long,s=r.short;if(i===void 0&&s===void 0)throw new TypeError(`registerFlags flags[${t}] requires at least one of long or short`);$(`registerFlags flags[${t}].long`,i),$(`registerFlags flags[${t}].short`,s);let a=kd(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${Ad(a.token,a.failure)}`);if($(`registerFlags flags[${t}].value_name`,r.value_name),$(`registerFlags flags[${t}].description`,r.description),B(`registerFlags flags[${t}].required`,r.required),B(`registerFlags flags[${t}].enabled`,r.enabled),B(`registerFlags flags[${t}].visible`,r.visible),B(`registerFlags flags[${t}].list`,r.list),B(`registerFlags flags[${t}].repeatable`,r.repeatable),r.list!==void 0&&r.repeatable!==void 0&&r.list!==r.repeatable)throw new TypeError(`registerFlags flags[${t}].list and repeatable must match when both are provided`);if(Hu(`registerFlags flags[${t}].default`,r.default),Array.isArray(r.default)&&r.list!==!0&&r.repeatable!==!0)throw new TypeError(`registerFlags flags[${t}].default cannot be an array unless list is true.`);Pp(`registerFlags flags[${t}]`,r),MA(`registerFlags flags[${t}]`,r)}}function MA(e,t){if(t.value_validation===void 0)return;if(t.value_validation!=="coerce"&&t.value_validation!=="strict")throw new TypeError(`${e}.value_validation must be "coerce" or "strict" (received ${JSON.stringify(t.value_validation)}).`);if(t.value_validation!=="strict")return;let n=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0),r=n===void 0?null:Lr(n);if(r!=="number"&&r!=="boolean")throw new TypeError(`${e}.value_validation "strict" requires value_type "number" or "boolean" (string values are never malformed).`)}function Pp(e,t){let n=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0);if(n===void 0)return;let r=Lr(n);if(r===null)throw new TypeError(`${e} value_type "${n}" is not a known flag value type (expected one of: string, number, boolean).`);if(t.default===void 0)return;let o=t.list===!0||t.repeatable===!0?Pd(t.default):[t.default];for(let[i,s]of o.entries())if(!$d(s,r)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${r}.`)}}function $p(e){if(!Array.isArray(e))throw new TypeError("registerItemFields fields requires an array of object definitions");for(let[t,n]of e.entries()){let r=j(`registerItemFields fields[${t}]`,n);Y(`registerItemFields fields[${t}].name`,r.name);let o=Y(`registerItemFields fields[${t}].type`,r.type);if(Ap(o)===null){let i=Ip(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${Qo.join(", ")}).${s}`)}B(`registerItemFields fields[${t}].optional`,r.optional)}}function jA(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].command_option_policies`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=j(i,o);Y(`${i}.command`,s.command),Y(`${i}.option`,s.option),B(`${i}.enabled`,s.enabled),B(`${i}.required`,s.required),B(`${i}.visible`,s.visible)}}function LA(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].options`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=j(i,o);Y(`${i}.key`,s.key),at(`${i}.values`,s.values),B(`${i}.required`,s.required),at(`${i}.aliases`,s.aliases)}}function Mp(e){if(!Array.isArray(e))throw new TypeError("registerItemTypes types requires an array of object definitions");for(let[t,n]of e.entries()){let r=`registerItemTypes types[${t}]`,o=j(r,n);Y(`${r}.name`,o.name),$(`${r}.folder`,o.folder),at(`${r}.aliases`,o.aliases),at(`${r}.required_create_fields`,o.required_create_fields),at(`${r}.required_create_repeatables`,o.required_create_repeatables),jA(t,o.command_option_policies),LA(t,o.options)}}function jp(e){let t=j("registerMigration definition",e);if(t.id!==void 0&&typeof t.id!="string")throw new TypeError("registerMigration definition.id must be a string when provided");if(t.description!==void 0&&typeof t.description!="string")throw new TypeError("registerMigration definition.description must be a string when provided");if(t.status!==void 0&&typeof t.status!="string")throw new TypeError("registerMigration definition.status must be a string when provided");if(B("registerMigration definition.mandatory",t.mandatory),t.run!==void 0&&typeof t.run!="function")throw new TypeError("registerMigration definition.run must be a function when provided")}var Lp=["types","statuses","fields","workflows","config","templates","packages"],FA={types:(e,t)=>{if(t.name!==void 0&&typeof t.name!="string")throw new TypeError(`${e}.name must be a string when provided`)},workflows:(e,t)=>{if(typeof t.type!="string")throw new TypeError(`${e}.type must be a string`);if(!Array.isArray(t.allowed_transitions))throw new TypeError(`${e}.allowed_transitions must be an array`);for(let[n,r]of t.allowed_transitions.entries())if(!Array.isArray(r))throw new TypeError(`${e}.allowed_transitions[${n}] must be a [from, to] array`)},templates:(e,t)=>{if(typeof t.name!="string")throw new TypeError(`${e}.name must be a string`);if(typeof t.options!="object"||t.options===null||Array.isArray(t.options))throw new TypeError(`${e}.options must be an object`)},packages:(e,t)=>{if(typeof t.spec!="string")throw new TypeError(`${e}.spec must be a string`)}};function Fp(e){let t=j("registerProfile profile",e);if(Y("registerProfile profile.name",t.name),Y("registerProfile profile.title",t.title),t.summary!==void 0&&typeof t.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let n of Lp){let r=t[n];if(r!==void 0){if(!Array.isArray(r))throw new TypeError(`registerProfile profile.${n} must be an array when provided`);for(let[o,i]of r.entries()){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError(`registerProfile profile.${n}[${o}] must be an object`);FA[n]?.(`registerProfile profile.${n}[${o}]`,i)}}}}function Up(e){e.summary===void 0&&(e.summary="");for(let t of Lp)e[t]===void 0&&(e[t]=[]);return e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="45ff820c-32af-5bdb-a570-3059684129ce")}catch{}})();function zp(e){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("registerService ownership must be an object");if(Reflect.ownKeys(e).some(t=>t!=="passThrough"))throw new TypeError("registerService ownership supports only passThrough");if(e.passThrough!==void 0&&typeof e.passThrough!="boolean")throw new TypeError("registerService ownership.passThrough must be a boolean when provided");return e.passThrough===!0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b5de5028-f981-599b-8d11-0fc7b07beda4")}catch{}})();function Hp(e){return typeof e=="string"?e:String(e)}function cr(e){let t=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(t)?t.split(/[.-]/).map(n=>Number(n)):null}function mc(e,t){let n=cr(e),r=cr(t);if(!n||!r)return null;let o=Math.max(n.length,r.length);for(let i=0;i<o;i+=1){let s=n[i]??0,a=r[i]??0;if(s>a)return 1;if(s<a)return-1}return 0}function Vp(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let n=Hp(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(!cr(n))return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(t===null)return{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:null};let r=mc(t,n);return r===null?{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:t}:r<0?{kind:"pm_min_version",status:"unmet",allowed:!1,required:n,current:t}:{kind:"pm_min_version",status:"ok",allowed:!0,required:n,current:t}}function qp(e,t,n){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let r=Hp(e);if(typeof e!="string"||r.trim().length===0)return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(/^[<>=~^]/.test(r.trim())||!cr(r))return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(t===null)return{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:null};let o=mc(t,r);return o===null?{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:t}:o>0?n==="warn"?{kind:"pm_max_version",status:"exceeded_warn",allowed:!0,required:r,current:t}:{kind:"pm_max_version",status:"exceeded",allowed:!1,required:r,current:t}:{kind:"pm_max_version",status:"ok",allowed:!0,required:r,current:t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f1f31504-c958-5bb1-a3b9-5339a09ad876")}catch{}})();function Bp(e){return Object.freeze({author:e.author,author_source:e.author_source,principal:e.principal,...e.agent===void 0?{}:{agent:Object.freeze({...e.agent})}})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="99f2a736-ba4b-57e7-a671-08b30c4aa761")}catch{}})();var UA=5e3;async function dr(e,t,n){let r=[];for(let o of e)try{await o.run(k(n))}catch{r.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return r}async function zA(e,t){return dr(e.beforeCommand,"beforeCommand",t)}function HA(e,t,n){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new h(`Extension mutation guard ${t.name} returned an invalid decision.`,g.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${t.layer}:${t.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let r=e,o=typeof r.code=="string"?r.code.trim():"",i=typeof r.remediation=="string"?r.remediation.trim():"";if(o.length===0||i.length===0)throw new h(`Extension mutation guard ${t.name} returned an invalid denial.`,g.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${t.layer}:${t.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof r.message=="string"?r.message.trim():"";throw new h(s||`Extension mutation guard ${t.name} denied ${n}.`,g.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function pc(e,t){let n=[];for(let r of e.beforeMutation??[])try{await VA(r,t)}catch(o){if(t.compensation===void 0)throw o;n.push({guard:`${r.layer}:${r.name}`,code:o.code??"extension_mutation_guard_failed"})}return n}async function VA(e,t){let n,r;try{let o=Promise.resolve().then(()=>e.run({pm_root:t.pm_root,operation:t.operation,before:t.before===null?null:k(t.before),after:t.after===null?null:k(t.after),changed_fields:[...t.changed_fields],actor:Bp(t.actor),dry_run:t.dry_run,...t.compensation===void 0?{}:{compensation:Object.freeze({transaction_id:t.compensation.transaction_id,step_id:t.compensation.step_id})},sdk:t.sdk}));o.catch(()=>{}),n=await Promise.race([o,new Promise((i,s)=>{r=setTimeout(()=>{s(new h(`Extension mutation guard ${e.name} timed out before ${t.operation}.`,g.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${e.layer}:${e.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},UA),r.unref?.()})]),HA(n,e,t.operation)}catch(o){throw o instanceof h?o:new h(`Extension mutation guard ${e.name} failed before ${t.operation}.`,g.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${e.layer}:${e.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(r)}}async function qA(e,t){return dr(e.afterCommand,"afterCommand",t)}async function _c(e,t){return dr(e.onWrite,"onWrite",t)}async function yc(e,t){return dr(e.onRead,"onRead",t)}async function gc(e,t){return dr(e.onIndex,"onIndex",t)}function BA(e){let t="";e instanceof Error&&typeof e.message=="string"?t=e.message:typeof e=="string"?t=e:typeof e=="object"&&e!==null&&typeof e.message=="string"&&(t=e.message);let n=t.replace(/\s+/gu," ").trim();if(n.length===0)return"";let r=300;return n.length>r?`${De(n,r-1)}\u2026`:n}function ti(e,t){if(typeof e!="object"||e===null||typeof e[t]!="string")return;let n=String(e[t]).replace(/\s+/gu," ").trim();return n.length>0?De(n,300):void 0}function WA(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"exit_code"))return;let t=e.exit_code;if(typeof t!="number"||!Number.isInteger(t)||t<1||t>255)throw new TypeError("Extension command result exit_code must be an integer from 1 to 255.");return t}async function hc(e,t){let n=x(t.command);if(n.length===0)return{handled:!1,result:null,warnings:[]};let r=[...e.handlers].reverse().find(o=>o.command===n);if(!r)return{handled:!1,result:null,warnings:[]};try{let o=await r.run({command:n,args:k(t.args),options:k(t.options),global:k(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,...t.sdk===void 0?{}:{sdk:t.sdk}});return{handled:!0,result:o,warnings:[],...Object.fromEntries([["exitCode",WA(o)],["errorCode",ti(o,"code")],["remediation",ti(o,"remediation")]].filter(i=>i[1]!==void 0))}}catch(o){let i=typeof o=="object"&&o!==null&&"exitCode"in o?o.exitCode:void 0;if(typeof i=="number"&&Number.isFinite(i))throw o;return Object.defineProperty({handled:!1,result:null,warnings:[`extension_command_handler_failed:${r.layer}:${r.name}:${r.command}`],errorMessage:BA(o),...Object.fromEntries([["errorCode",ti(o,"code")],["remediation",ti(o,"remediation")]].filter(s=>s[1]!==void 0))},"cause",{value:o,configurable:!0})}}async function bc(e,t){let n=x(t.command);if(n.length===0)return{overridden:!1,context:{command:n,args:k(t.args),options:te(t.options),global:ne(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]};let r=[...e.overrides].reverse().find(o=>o.command===n);if(!r)return{overridden:!1,context:{command:n,args:k(t.args),options:te(t.options),global:ne(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]};try{let o=await Promise.resolve(r.run({command:n,args:k(t.args),options:te(t.options),global:ne(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel}))??{},i=Array.isArray(o.args)?k(o.args):k(t.args),s=o.options?te(o.options):te(t.options),a=o.global?ne(o.global):ne(t.global);return{overridden:!0,context:{command:n,args:i,options:s,global:a,pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]}}catch{return{overridden:!1,context:{command:n,args:k(t.args),options:te(t.options),global:ne(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[`extension_parser_override_failed:${r.layer}:${r.name}:${r.command}`]}}}async function wc(e,t){let n={command:x(t.command),args:k(t.args),options:te(t.options),global:ne(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},r=k(t.decision),o=[...e.overrides].reverse().find(i=>!i.commands?.length||i.commands.includes(n.command));if(!o)return{overridden:!1,context:n,decision:r,warnings:[]};try{let i=await Promise.resolve(o.run({command:n.command,args:k(n.args),options:te(n.options),global:ne(n.global),pm_root:n.pm_root,source_workspace_root:n.source_workspace_root,repo_root:n.repo_root,pm_root_rel:n.pm_root_rel,decision:k(r)}))??{},s={command:n.command,args:Array.isArray(i.args)?k(i.args):n.args,options:i.options?te(i.options):n.options,global:i.global?ne(i.global):n.global,pm_root:n.pm_root,source_workspace_root:n.source_workspace_root,repo_root:n.repo_root,pm_root_rel:n.pm_root_rel},a={enforce_item_format_gate:typeof i.enforce_item_format_gate=="boolean"?i.enforce_item_format_gate:r.enforce_item_format_gate,run_preflight_item_format_sync:typeof i.run_preflight_item_format_sync=="boolean"?i.run_preflight_item_format_sync:r.run_preflight_item_format_sync,run_extension_migrations:typeof i.run_extension_migrations=="boolean"?i.run_extension_migrations:r.run_extension_migrations,enforce_mandatory_migration_gate:typeof i.enforce_mandatory_migration_gate=="boolean"?i.enforce_mandatory_migration_gate:r.enforce_mandatory_migration_gate};return{overridden:!0,context:s,decision:a,warnings:[]}}catch{return{overridden:!1,context:n,decision:r,warnings:[`extension_preflight_override_failed:${o.layer}:${o.name}`]}}}function Wp(e){return{handled:!1,result:e.payload,warnings:[]}}function Gp(e,t){return[...e.overrides].reverse().filter(n=>n.service===t)}function Kp(e){return{service:e.service,command:e.command?x(e.command):void 0,args:e.args?k(e.args):void 0,options:e.options?te(e.options):void 0,global:e.global?ne(e.global):void 0,pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,payload:k(e.payload)}}function GA(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"handled"))return!1;let t=e.handled;return t===!0?Object.hasOwn(e,"result"):t===!1&&Reflect.ownKeys(e).length===1}function Yp(e,t){return GA(e)?e.handled?{handled:!0,result:e.result}:{handled:!1,result:t.payload}:t.service==="output_format"&&e==null?{handled:!1,result:t.payload}:{handled:!0,result:e}}function Xp(e,t,n){return t.service==="output_format"&&typeof e=="object"&&e!==null&&ce(e,n.payload)}function Jp(e,t,n){if(t.handled){if(e.passThrough===!0){n.push(`extension_service_pass_through_contract_violated:${e.layer}:${e.name}:${e.service}`);return}return{handled:!0,result:t.result,warnings:n}}}function vc(e,t){let n=Gp(e,t.service);if(n.length===0)return Wp(t);let r=[];for(let o of n)try{let i=Kp(t),s=o.run(i);if(s instanceof Promise){r.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(Xp(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Jp(o,Yp(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}async function Ec(e,t){let n=Gp(e,t.service);if(n.length===0)return Wp(t);let r=[];for(let o of n)try{let i=Kp(t),s=await Promise.resolve(o.run(i));if(Xp(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Jp(o,Yp(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}function Oc(e,t){let n=x(t.command);if(n.length===0)return{overridden:!1,result:t.result,warnings:[]};let r=[...e.overrides].reverse().find(o=>o.command===n);if(!r)return{overridden:!1,result:t.result,warnings:[]};try{let o=te(t.options),i=ne(t.global),s=r.run({command:n,args:k(t.args),options:o,global:i,pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,result:k(t.result)});return s instanceof Promise?{overridden:!1,result:t.result,warnings:[`extension_command_override_async_unsupported:${r.layer}:${r.name}:${r.command}`]}:{overridden:!0,result:s,warnings:[]}}catch{return{overridden:!1,result:t.result,warnings:[`extension_command_override_failed:${r.layer}:${r.name}:${r.command}`]}}}function KA(e,t,n){if((e.commands?.length??0)>0&&!e.commands?.includes(t))return!1;if(e.resultDiscriminator===void 0)return!0;try{return e.resultDiscriminator(k(n))}catch{return!1}}function Sc(e,t){let n=typeof t.command=="string"?x(t.command):"",r=[...e.overrides].reverse().find(o=>o.format===t.format&&KA(o,n,t.result));if(!r)return{overridden:!1,rendered:null,warnings:[]};try{let o=Array.isArray(t.args)?k(t.args):[],i=te(t.options),s=ne(t.global),a=typeof t.pm_root=="string"?t.pm_root:"",c=r.run({format:t.format,command:n,args:o,options:i,global:s,pm_root:a,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,result:k(t.result)});return c==null?{overridden:!1,rendered:null,warnings:[]}:typeof c!="string"?{overridden:!1,rendered:null,warnings:[`extension_renderer_invalid_result:${r.layer}:${r.name}:${r.format}`]}:{overridden:!0,rendered:c,warnings:[]}}catch{return{overridden:!1,rendered:null,warnings:[`extension_renderer_failed:${r.layer}:${r.name}:${r.format}`]}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3abe36f7-3c97-58d2-a56d-b4e0ea958461")}catch{}})();var Qp=null,XA=Object.freeze(Lc()),Zp=0;function JA(e=Date.now()){return Zp+=1,`${Zp}-${e}`}function QA(e,t,n){return n.has(e)?!1:t.size===0?!0:t.has(e)}async function ZA(e,t){let[n,r]=await Promise.all([St.realpath(e),St.realpath(t)]);return gn(n,r)}function eI(e,t=process.cwd()){return{global:Ot.join(_d(t),"extensions"),project:Ot.join(e,"extensions")}}async function tI(e){try{return(await St.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,n)=>t.localeCompare(n))}catch{return[]}}function nI(e){let t={layer:e.layer,directory:e.directory,manifest_path:e.manifest_path,name:e.manifest.name,version:e.manifest.version,entry:e.manifest.entry,priority:e.manifest.priority,entry_path:e.entry_path,manifest_version:e.manifest.manifest_version,pm_min_version:e.manifest.pm_min_version,pm_max_version:e.manifest.pm_max_version,engines:e.manifest.engines,trusted:e.manifest.trusted,provenance:e.manifest.provenance,sandbox_profile:e.manifest.sandbox_profile,permissions:e.manifest.permissions,capabilities:[...e.manifest.capabilities],activation:e.manifest.activation?{commands:[...e.manifest.activation.commands]}:void 0,contributions:e.manifest.contributions??e.contributions};return e.source_package&&(t.source_package=e.source_package),e.source_aliases&&(t.source_aliases=[...e.source_aliases]),t}function e_(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function rI(e){let t=new Map;try{let n=JSON.parse(await St.readFile(Ot.join(e,".managed-extensions.json"),"utf8")),r=Ae(n)?.entries;if(!Array.isArray(r))return t;for(let o of r){if(typeof o!="object"||o===null)continue;let i=o,s=e_(i.source?.package),a=[i.source?.input,i.source?.name,s].map(l=>e_(l)).filter(l=>l!==void 0),c=Xo(i.contributions),d={aliases:[...new Set(a)],...s?{package_name:s}:{},...c?{contributions:c}:{}};typeof i.directory=="string"&&i.directory.trim().length>0&&t.set(`directory:${i.directory.trim()}`,d),typeof i.name=="string"&&i.name.trim().length>0&&t.set(`name:${i.name.trim()}`,d)}}catch{return t}return t}function t_(e){return[...e].sort((t,n)=>{if(t.manifest.priority!==n.manifest.priority)return t.manifest.priority-n.manifest.priority;let r=t.manifest.name.localeCompare(n.manifest.name);return r!==0?r:t.directory.localeCompare(n.directory)})}function oI(e,t){let n=[...t_(e),...t_(t)],r=[];for(let o of n){let i=r.findIndex(s=>s.manifest.name===o.manifest.name);i>=0&&r.splice(i,1),r.push(o)}return r}async function n_(e,t,n,r,o){let i=[],s=[],a=[],c=await tI(t),d=await rI(t);for(let l of c){let u=await aI(e,t,l,n,r,d,o);i.push(u.diagnostic),s.push(...u.warnings),u.candidate&&a.push(u.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function iI(){return{diagnostics:[],warnings:[],candidates:[]}}function r_(e,t,n,r){return{diagnostic:{layer:e,directory:t,manifest_path:n,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[r],candidate:null}}function sI(e,t,n,r,o,i,s,a){let c=wp(e,t,n);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&c.push(ip(e,t.name,t.legacy_capability_aliases));for(let d of np(t.capabilities))c.push(op(e,t.name,d));return r?o||c.push(`extension_entry_missing:${e}:${t.name}`):c.push(`extension_entry_outside_extension:${e}:${t.name}`),i.warning&&c.push(a?i.warning:i.warning.replace("extension_pm_","extension_disabled_pm_")),s.warning&&c.push(a?s.warning:s.warning.replace("extension_pm_","extension_disabled_pm_")),c}async function aI(e,t,n,r,o,i,s){let a=Ot.join(t,n),c=Ot.join(a,"manifest.json");if(!await un(c))return r_(e,n,c,`extension_manifest_missing:${e}:${n}`);let d,l;try{let J=JSON.parse(await St.readFile(c,"utf8"));l=Ae(J),d=cc(J)}catch{l=null,d=null}if(!d||!l)return r_(e,n,c,`extension_manifest_invalid:${e}:${n}`);let u=Ot.resolve(a,d.entry),f=gn(a,u),m=f?await un(u):!1,p=f&&m?await ZA(a,u):f,_=QA(d.name,r,o),y=await lI(e,d),b=await uI(e,d,s),E=sI(e,d,l,p,m,y,b,_),M=p&&m&&y.allowed&&b.allowed,X=i.get(`directory:${n}`)??i.get(`name:${d.name}`);return{diagnostic:{layer:e,directory:n,manifest_path:c,name:d.name,version:d.version,entry:d.entry,priority:d.priority,entry_path:u,enabled:_,status:M?"ok":"warn"},warnings:E,candidate:ep({layer:e,directory:n,manifestPath:c,entryPath:u,manifest:d,sourceIdentity:X,extensionReady:M,enabledForLoad:_})}}async function cI(e){let t=eI(e.pmRoot,e.cwd??process.cwd()),n=Qn(e.settings.extensions.enabled),r=Qn(e.settings.extensions.disabled),o=lp(e.settings),i=up(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:n,configured_disabled:r,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(n),a=new Set(r),c=e.ignoreGlobalExtensions===!0?iI():await n_("global",t.global,s,a,o.pmMaxVersionExceededMode.global),d=await n_("project",t.project,s,a,o.pmMaxVersionExceededMode.project),l=[...o.warnings],u=oI(c.candidates,d.candidates),f=[];for(let m of u){let p={layer:m.layer,name:m.manifest.name,trusted:m.manifest.trusted===!0,provenanceVerified:m.manifest.provenance?.verified===!0,sandboxProfile:m.manifest.sandbox_profile,permissions:m.manifest.permissions&&typeof m.manifest.permissions=="object"?{fs_read:m.manifest.permissions.fs_read,fs_write:m.manifest.permissions.fs_write,network:m.manifest.permissions.network,env_read:m.manifest.permissions.env_read,env_write:m.manifest.permissions.env_write,process_spawn:m.manifest.permissions.process_spawn}:void 0},_=pp(o,p);if(_.warning&&l.push(_.warning),!!_.allowed){for(let y of m.manifest.capabilities){let b=_p(o,p,y);b.warning&&l.push(b.warning)}f.push(nI(m))}}return{disabled_by_flag:!1,roots:t,configured_enabled:n,configured_disabled:r,discovered:[...c.diagnostics,...d.diagnostics],effective:f,warnings:[...new Set([...c.warnings,...d.warnings,...l])],policy:i}}function ni(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function dI(){try{let e=Yo(import.meta.url,["../../.."]),t=await St.readFile(Ot.join(e,"package.json"),"utf8"),n=JSON.parse(t);return typeof n.version=="string"&&n.version.trim().length>0?n.version.trim():null}catch{return null}}function s_(){return Qp??=dI(),Qp}function a_(e,t,n){let r=n.current??"unknown";if(n.kind==="pm_min_version")switch(n.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${t.name}:required=${n.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${t.name}:required=${n.required}:current=${r}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${t.name}:required=${n.required}:current=${r}`;default:return}switch(n.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${t.name}:allowed=${n.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${t.name}:allowed=${n.required}:current=${r}`;default:return}}async function lI(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let n=Vp(t.pm_min_version,await s_()),r=a_(e,t,n);return r?{allowed:n.allowed,warning:r}:{allowed:n.allowed}}async function uI(e,t,n){if(t.pm_max_version===void 0)return{allowed:!0};let r=qp(t.pm_max_version,await s_(),n),o=a_(e,t,r);return o?{allowed:r.allowed,warning:o}:{allowed:r.allowed}}async function o_(e){try{let t=await St.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function fI(e,t){let n=e.entry_path;t.module_graph_snapshot_root&&(n=await Op(t.module_graph_snapshot_root,e));let r=new URL(YA(n).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return r.href;let[o,i]=await Promise.all([o_(e.entry_path),o_(e.manifest_path)]),s=t.reload_token??JA();return r.searchParams.set("pm_ext_reload",s),r.searchParams.set("pm_ext_entry",o),r.searchParams.set("pm_ext_manifest",i),r.href}async function AL(e){let t=await cI(e),n=[],r=[],o=[...t.warnings];if(t.disabled_by_flag)return{...t,warnings:o,loaded:n,failed:r};let i=typeof e.extensionFilter=="function"?t.effective.filter(e.extensionFilter):t.effective;for(let s of i)try{let a=await import(await fI(s,e));n.push({...s,module:a})}catch(a){o.push(`extension_load_failed:${s.layer}:${s.name}`),r.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:ni(a)})}return{...t,warnings:o,loaded:n,failed:r}}var i_=5e3,mI=2147483647;function pI(e){let t={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let n=e.deactivate;t.deactivate=n.bind(e)}return t}function c_(e){let t=Cd(e);return t?pI(t):null}async function IL(e,t,n={}){let r=_I(n?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(l=>`${l.layer}:${l.name}`)),i=[];for(let l of e.loaded){if(o.has(`${l.layer}:${l.name}`))continue;let u=c_(l.module);!u||typeof u.deactivate!="function"||i.push({extension:l,deactivate:u.deactivate})}let s=await Promise.all(i.map(async({extension:l,deactivate:u})=>{try{return await yI(u,r),{ok:!0}}catch(f){return{ok:!1,layer:l.layer,name:l.name,error:ni(f)}}})),a=[],c=[],d=0;for(let l of s){if(l.ok){d+=1;continue}a.push(`extension_deactivate_failed:${l.layer}:${l.name}`),c.push({layer:l.layer,name:l.name,error:l.error})}return{deactivated:d,warnings:a,failed:c}}function _I(e){return typeof e!="number"||e<0?i_:e===0||e===1/0?0:Number.isFinite(e)?Math.min(mI,Math.max(1,Math.floor(e))):i_}async function yI(e,t){if(t===0){await e();return}let n;try{let r=Promise.resolve().then(()=>e());r.catch(()=>{}),await Promise.race([r,new Promise((o,i)=>{n=setTimeout(()=>{i(new Error(`extension deactivate timed out after ${t}ms`))},t),n.unref?.()})])}finally{clearTimeout(n)}}function gI(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let n of e.capabilities){let r=n.trim().toLowerCase();Ve(r)&&t.add(r)}return t}function P(e,t,n){let r=gI(e);if(r!==null&&!r.has(t))throw we(`${n} requires capability '${t}' in extension manifest capabilities`,{method:n,registration_index:-1,capability:t,missing_capability:t,expected_schema:`"capabilities": [..., "${t}"]`,received:e.capabilities,hint:`Add "${t}" to ${e.name} manifest capabilities, or remove the ${n} registration call.`})}function hI(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>pe.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function bI(e){return{layer:e.layer,name:e.name,trusted:e.trusted===!0,provenanceVerified:e.provenance?.verified===!0,sandboxProfile:e.sandbox_profile,permissions:e.permissions&&typeof e.permissions=="object"?{fs_read:e.permissions.fs_read,fs_write:e.permissions.fs_write,network:e.permissions.network,env_read:e.permissions.env_read,env_write:e.permissions.env_write,process_spawn:e.permissions.process_spawn}:void 0}}var kc=class{extension;hooks;#e;#n;#o;#r;#s;#a;#i;#c;#t;#d;#l;#u;constructor(t,n,r,o,i,s,a,c,d,l,u){this.#e=t,this.extension=hI(t),this.#n=bI(t),this.#o=n,this.#r=r,this.#s=o,this.#a=i,this.#i=s,this.#c=a,this.#t=c,this.#d=d,this.#l=l,this.#u=u,this.registerCommand=this.registerCommand.bind(this),this.registerParser=this.registerParser.bind(this),this.registerPreflight=this.registerPreflight.bind(this),this.registerService=this.registerService.bind(this),this.registerFlags=this.registerFlags.bind(this),this.registerItemFields=this.registerItemFields.bind(this),this.registerItemTypes=this.registerItemTypes.bind(this),this.registerRelationshipKinds=this.registerRelationshipKinds.bind(this),this.registerMigration=this.registerMigration.bind(this),this.registerProfile=this.registerProfile.bind(this),this.registerRenderer=this.registerRenderer.bind(this),this.registerImporter=this.registerImporter.bind(this),this.registerExporter=this.registerExporter.bind(this),this.registerSearchProvider=this.registerSearchProvider.bind(this),this.registerVectorStoreAdapter=this.registerVectorStoreAdapter.bind(this),this.registerAssuranceMeasurementProvider=this.registerAssuranceMeasurementProvider.bind(this),this.hooks={beforeCommand:f=>this.registerBeforeCommand(f),beforeMutation:f=>this.registerBeforeMutation(f),afterCommand:f=>this.registerAfterCommand(f),onWrite:f=>this.registerOnWrite(f),onRead:f=>this.registerOnRead(f),onIndex:f=>this.registerOnIndex(f)}}allowRegistration(t,n,r,o){let i=yp(this.#u,this.#n,t,n,r,o);return i.warning&&this.#d.push(i.warning),i.allowed}registerCommandTrace(t,n,r,o,i){return{method:"registerCommand",registration_index:t==="override"?this.#r.overrides.length:this.#r.handlers.length,command:n,expected_schema:r,received:nr(o),hint:i}}registerCommandOverride(t,n){let r=x(t);if(r.length===0)throw we("registerCommand requires a non-empty command name",this.registerCommandTrace("override",t,'registerCommand("<command>", (context) => unknown)',t,"Provide a non-empty command path as the first argument."));if(typeof n!="function"){let o=this.registerCommandTrace("override",r,'registerCommand("<command>", (context) => unknown)',n,"Provide a function as the second registerCommand argument.");throw we(`registerCommand requires an override function when command name is provided (command="${r}", registration_index=${o.registration_index})`,o)}this.allowRegistration("commands.override","registerCommand","commands",{command:r})&&this.#r.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}resolveCommandDefinitionRunHandler(t,n){let r=typeof t.run=="function"?t.run:void 0,o=typeof t.handler=="function"?t.handler:void 0;return!r&&o&&this.#d.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${n}`),r??o}registerCommandDefinition(t){if(typeof t!="object"||t===null)throw we("registerCommand requires a command definition object",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,'Use registerCommand({ name: "command path", run: (context) => ... }).'));if(typeof t.name!="string")throw we("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,"Set command definition.name to a non-empty string command path."));let n=x(t.name);if(n.length===0)throw we("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",t.name,"{ name: string; run: (context) => unknown; }",t,"Ensure command definition.name contains a non-empty command path."));let r=this.resolveCommandDefinitionRunHandler(t,n);if(typeof r!="function"){let o=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; }",r,"Define command definition.run as a function.");throw we(`registerCommand requires a command definition run handler (command="${n}", registration_index=${o.registration_index})`,o)}try{Qm(t);let o=uc(n,t.action),i=Vu(t.read_output,n,o);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:n,action:o}))return;let s=t.description?.trim(),a=t.intent?.trim(),c=Mn("registerCommand definition.examples",t.examples),d=Mn("registerCommand definition.failure_hints",t.failure_hints),l=fc(t.arguments);t.flags!==void 0&&(P(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(ei(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Zo("registerCommand definition.flags",t.flags)})));let u={source_version:this.#e.version,read_output:i,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:o,examples:c,failure_hints:d,arguments:l,tier:t.tier??"standard",family:t.family??"extensions"};s&&(u.description=s),a&&(u.intent=a),this.#t.commands.push(u)}catch(o){let i=ni(o),s=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=we(`registerCommand definition metadata invalid (command="${n}", registration_index=${s.registration_index}): ${i}`,s);this.#d.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${n}`),this.#l.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}registerCommand(t,n){if(P(this.#e,"commands","registerCommand"),typeof t=="string"){this.registerCommandOverride(t,n);return}this.registerCommandDefinition(t)}registerParser(t,n){if(P(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let r=x(Y("registerParser command",t));sr("registerParser override",n),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}registerPreflight(t){if(P(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let n=Sp(t);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...n})}registerService(t,n,r={}){P(this.#e,"services","registerService");let o=String(t).trim().toLowerCase();if(!Cp(o))throw new TypeError(`registerService service must be one of: ${It.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(sr("registerService override",n),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:n,...zp(r)?{passThrough:!0}:{}}))}registerRenderer(t,n,r={}){if(P(this.#e,"renderers","registerRenderer"),!this.allowRegistration("renderers.override","registerRenderer","renderers"))return;if(typeof n!="function")throw new TypeError("registerRenderer requires a renderer function");let o=String(t).trim().toLowerCase();if(!Tp(o))throw new Error(`registerRenderer format must be toon|json, received: ${String(t)}`);if(r.resultDiscriminator!==void 0&&typeof r.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");let i=[...new Set((r.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return x(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:o,run:n,commands:i,...r.resultDiscriminator?{resultDiscriminator:r.resultDiscriminator}:{}})}registerFlags(t,n){if(P(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let r=x(Y("registerFlags targetCommand",t));ei(n);let o=Zo("registerFlags flags",n);if(o.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:o})}registerItemFields(t){if(P(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;$p(t);let n=ir("registerItemFields fields",t);if(n.length===0)throw new TypeError("registerItemFields requires at least one field definition");this.#t.item_fields.push({layer:this.#e.layer,name:this.#e.name,fields:n})}registerItemTypes(t){if(P(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;Mp(t);let n=ir("registerItemTypes types",t);if(n.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#t.item_types.push({layer:this.#e.layer,name:this.#e.name,types:n})}registerRelationshipKinds(t){if(P(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(t))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(t.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");let n=Ya();for(let o of this.#t.relationship_kinds)for(let i of o.definitions)n.register(i);let r=t.map(o=>(n.register(o),n.require(o.kind)));this.#t.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:r})}registerMigration(t){if(P(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;jp(t);let n=or("registerMigration definition",t);this.#t.migrations.push(ar({layer:this.#e.layer,name:this.#e.name,definition:sn("registerMigration definition",t)},n))}registerProfile(t){if(P(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let n=rr(t);Fp(n),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:Up(n)})}registerImportExportCommandFlags(t,n,r){r.flags!==void 0&&(P(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(ei(r.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Zo(`${t} options.flags`,r.flags)})))}applyImportExportCommandMetadata(t,n,r){if(r!==void 0&&(typeof r!="object"||r===null||Array.isArray(r)))throw new TypeError(`${t} options must be an object when provided`);let o=`${t==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,i=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...r,description:r?.description??o,arguments:r?.arguments??i},a=Zm(t,s,r?.description!==void 0);$(`${t} options.action`,s.action),$(`${t} options.description`,s.description),$(`${t} options.intent`,s.intent);let c=uc(n,s.action),d=Mn(`${t} options.examples`,s.examples),l=Mn(`${t} options.failure_hints`,s.failure_hints),u=fc(s.arguments);this.registerImportExportCommandFlags(t,n,s);let f={source_version:this.#e.version,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:c,examples:d,failure_hints:l,arguments:u},m=s.description?.trim();m&&(f.description=m);let p=s.intent?.trim();return p&&(f.intent=p),this.#t.commands.push(f),a}registerImporter(t,n,r){if(P(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=dc(Y("registerImporter name",t));sr("registerImporter importer",n);let i=lc(o,"import");this.applyImportExportCommandMetadata("registerImporter",i,r),this.#t.importers.push({layer:this.#e.layer,name:this.#e.name,importer:o}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>n(Ja(s,o,"import"))})}registerExporter(t,n,r){if(P(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=dc(Y("registerExporter name",t));sr("registerExporter exporter",n);let i=lc(o,"export"),s=this.applyImportExportCommandMetadata("registerExporter",i,r);this.#t.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:o,...s===void 0?{}:{output:s}}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async a=>{let c=await n(Ja(a,o,"export"));return s?.receipt==="suppress"&&!_o(c)?Tu(c):c}})}registerSearchProvider(t){if(P(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let n=or("registerSearchProvider provider",t);this.#t.search_providers.push(ar({layer:this.#e.layer,name:this.#e.name,definition:sn("registerSearchProvider provider",t)},n))}registerVectorStoreAdapter(t){if(P(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let n=or("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(ar({layer:this.#e.layer,name:this.#e.name,definition:sn("registerVectorStoreAdapter adapter",t)},n))}registerAssuranceMeasurementProvider(t){if(P(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(Dp(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let n=or("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(ar({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:sn("registerAssuranceMeasurementProvider provider",t)},n))}registerBeforeCommand(t){P(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(Et("beforeCommand",t),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerBeforeMutation(t){P(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(Et("beforeMutation",t),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerAfterCommand(t){P(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(Et("afterCommand",t),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnWrite(t){P(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(Et("onWrite",t),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnRead(t){P(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(Et("onRead",t),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnIndex(t){P(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(Et("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function wI(e,t,n,r,o,i,s,a,c,d,l){return new kc(e,t,n,r,o,i,s,a,c,d,l)}function vI(e){let t=e.commands.length,n=e.flags.reduce((s,a)=>s+a.flags.length,0),r=e.item_fields.reduce((s,a)=>s+a.fields.length,0),o=e.item_types.reduce((s,a)=>s+a.types.length,0),i=(e.relationship_kinds??[]).reduce((s,a)=>s+a.definitions.length,0);return{commands:t,flags:n,item_fields:r,item_types:o,...i>0?{relationship_kinds:i}:{},migrations:e.migrations.length,profiles:e.profiles.length,importers:e.importers.length,exporters:e.exporters.length,search_providers:e.search_providers.length,vector_store_adapters:e.vector_store_adapters.length,...(e.assurance_providers?.length??0)>0?{assurance_providers:e.assurance_providers.length}:{}}}function EI(e){let t=[],n=(i,s)=>{let a=new Map;for(let c of i){let d=a.get(c.command)??[];d.push(c),a.set(c.command,d)}for(let c of[...a.keys()].sort((d,l)=>d.localeCompare(l))){let d=a.get(c);if(d.length<=1)continue;let l=d[d.length-1];for(let u of d.slice(0,-1))t.push(`${s}:${c}:${l.layer}:${l.name}:${u.layer}:${u.name}`)}};n(e.handlers,"extension_command_handler_collision"),n(e.overrides,"extension_command_override_collision");let r=new Set(e.handlers.map(i=>i.command)),o=[...new Set(e.overrides.map(i=>i.command))].filter(i=>r.has(i));o.sort((i,s)=>i.localeCompare(s));for(let i of o){let s=e.handlers.filter(c=>c.command===i),a=e.overrides.filter(c=>c.command===i);for(let c of a)for(let d of s)t.push(`extension_command_override_handler_overlap:${i}:${c.layer}:${c.name}:${d.layer}:${d.name}`)}return t}function OI(e){let t=new Map;for(let r of e.overrides){let o=t.get(r.format)??[];o.push(r),t.set(r.format,o)}let n=[];for(let r of[...t.keys()].sort((o,i)=>o.localeCompare(i))){let o=t.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))i.commands?.length&&s.commands?.length&&!s.commands.some(a=>i.commands?.includes(a))||n.push(`extension_renderer_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return n}function SI(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.command)??[];o.push(r),n.set(r.command,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_parser_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}var kI=new Set(["output_format"]);function AI(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.service)??[];o.push(r),n.set(r.service,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1||kI.has(r))continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_service_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}async function TL(e){let t=fp(e.policy??XA),n=er(),r=ec(),o=tc(),i=nc(),s=rc(),a=oc(),c=ic(),d=[],l=[];for(let m of e.loaded){let p=c_(m.module);if(!p)continue;let _=d.length,y=Jm({hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await p.activate(wI(m,n,r,o,i,s,a,c,l,d,t)),d.length>_&&(y(),l.push(`extension_activation_rolled_back:${m.layer}:${m.name}`))}catch(b){y(),l.push(`extension_activate_failed:${m.layer}:${m.name}`);let E=xp(b);d.push({layer:m.layer,name:m.name,entry_path:m.entry_path,error:ni(b),trace:E})}}let u=[...EI(r),...SI(o),...kp(i),...AI(s),...OI(a)],f=[...new Set([...l,...u])];return{hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c,failed:d,warnings:f,hook_counts:{before_command:n.beforeCommand.length,before_mutation:n.beforeMutation.length,after_command:n.afterCommand.length,on_write:n.onWrite.length,on_read:n.onRead.length,on_index:n.onIndex.length},command_override_count:r.overrides.length,command_handler_count:r.handlers.length,parser_override_count:o.overrides.length,preflight_override_count:i.overrides.length,service_override_count:s.overrides.length,renderer_override_count:a.overrides.length,registration_counts:vI(c)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b1a38f8c-8f65-59e2-bddf-ed0606a0f0b5")}catch{}})();function NL(e){return{...e,hooks:er(),profileEnabled:!!e.globalOptions.profile,migrationBlockers:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4da25248-2914-5bc5-aa42-87f677ef4ea8")}catch{}})();function PL(){let e=Promise.resolve(),t=new Set;return{async read(n){let r=e,o,i=new Promise(s=>{o=s});t.add(i),await r;try{return await n()}finally{t.delete(i),o()}},write(n){let r=Promise.all([e,...t]).then(()=>n());return e=r.then(()=>{},()=>{}),r}}}function II(){let e=Promise.resolve(),t=0,n=[],r=()=>{if(t!==0)return;let o=n.splice(0);for(let i of o)i()};return{enqueue(o){t++;let i=e.then(()=>o());return e=i.then(()=>{},()=>{}).finally(()=>{t--,r()}),i},idle(){return t===0?Promise.resolve():new Promise(o=>n.push(o))}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d8844150-afb4-5f2e-a005-4cfb8482660c")}catch{}})();var TI={commands:["registerCommand","command override","command handler"],renderers:["registerRenderer"],hooks:["hooks.beforeCommand","hooks.beforeMutation","hooks.afterCommand","hooks.onWrite","hooks.onRead","hooks.onIndex"],schema:["registerFlags","registerItemFields","registerItemTypes","registerRelationshipKinds","registerMigration","registerProfile"],importers:["registerImporter","registerExporter"],search:["registerSearchProvider","registerVectorStoreAdapter"],parser:["registerParser"],preflight:["registerPreflight"],services:["registerService","registerAssuranceMeasurementProvider"]},d_=":";function l_(e,t){return`${e}${d_}${Ac(t)}`}function CI(e){return e.slice(e.indexOf(d_)+1)}function Ac(e){return e.trim().toLowerCase()}function RI(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let r=tp(n);r!==null&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function u_(e){let t=new Map,n=(l,u)=>{for(let f of l){let m=l_(f.layer,f.name),p=t.get(m);p===void 0&&(p=new Set,t.set(m,p)),p.add(u)}},{registrations:r,commands:o,parsers:i,preflight:s,services:a,renderers:c,hooks:d}=e;return n(r.commands,"commands"),n(o.overrides,"commands"),n(o.handlers,"commands"),n(r.flags,"schema"),n(r.item_fields,"schema"),n(r.item_types,"schema"),n(r.relationship_kinds??[],"schema"),n(r.migrations,"schema"),n(r.profiles,"schema"),n(r.importers,"importers"),n(r.exporters,"importers"),n(r.search_providers,"search"),n(r.vector_store_adapters,"search"),n(i.overrides,"parser"),n(s.overrides,"preflight"),n(a.overrides,"services"),n(r.assurance_providers??[],"services"),n(c.overrides,"renderers"),n(d.beforeCommand,"hooks"),n(d.beforeMutation,"hooks"),n(d.afterCommand,"hooks"),n(d.onWrite,"hooks"),n(d.onRead,"hooks"),n(d.onIndex,"hooks"),t}function xI(e,t={}){let n=u_(e),r=new Set;t.extensionName!==void 0&&r.add(Ac(t.extensionName));for(let i of t.extensionNames??[])r.add(Ac(i));let o=new Set;for(let[i,s]of n)if(!(r.size>0&&!r.has(CI(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function NI(e,t){let n=u_(t),r=[];for(let o of e){let i=RI(o.capabilities);if(i.length===0)continue;let s=n.get(l_(o.layer,o.name))??new Set,a=[...s].sort((d,l)=>d.localeCompare(l)),c=i.filter(d=>!s.has(d));r.push({layer:o.layer,name:o.name,declared:i,used:a,unused:c})}return r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1ee579e0-2d07-5519-b071-bac39d3ec594")}catch{}})();var Ee=null,an=null,lr=null,ur=null,cn=null,fr=null,mr=null,We=null,oi,ri=[],p_=new m_;function I(){return p_.getStore()}function VL(e){return p_.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var PI=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function f_(e){let t=ve.resolve(e);for(;;){if(DI(ve.join(t,".git")))return t;let n=ve.dirname(t);if(n===t)return;t=n}}function ii(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),n=f_(t)??ve.resolve(t),r=f_(n);if(!e)return{source_workspace_root:n,...r?{repo_root:r}:{}};let o=ve.relative(n,ve.resolve(e)),i=o.length>0&&!o.startsWith(`..${ve.sep}`)&&o!==".."&&!ve.isAbsolute(o);return{source_workspace_root:n,...r?{repo_root:r}:{},...i?{pm_root_rel:o.split(ve.sep).join("/")}:{}}}function qL(e){let t=I();if(t){t.hooks=e;return}Ee=e}function BL(e){let t=I();if(t){t.commands=e;return}an=e}function WL(e){let t=I();if(t){t.parsers=e;return}lr=e}function GL(e){let t=I();if(t){t.preflight=e;return}ur=e}function KL(e){let t=I();if(t){t.services=e;return}cn=e}function YL(e){let t=I();if(t){t.renderers=e;return}fr=e}function XL(e){let t=I();if(t){t.registrations=e;return}mr=e}function Xu(){let e=I();return e?e.registrations:mr}function JL(){let e=I();if(e){e.hooks=null,e.commands=null,e.parsers=null,e.preflight=null,e.services=null,e.renderers=null,e.registrations=null,e.commandContext=null,e.commandResult=null,e.affectedItems=[];return}Ee=null,an=null,lr=null,ur=null,cn=null,fr=null,mr=null,We=null,oi=null}function QL(e){let t=e?{...e,...ii(e.pm_root)}:null,n=I();if(n){n.commandContext=t;return}We=t}function Nm(){let e=I(),t=e?e.commandContext:We;return t?{...t,args:[...t.args],options:t.options?{...t.options}:{},global:t.global?{...t.global}:void 0}:null}function ZL(e){let t=I()??{commandContext:We,hooks:Ee,commands:an,parsers:lr,preflight:ur,services:cn,renderers:fr,registrations:mr};return t.commandContext?.command!==e||[t.hooks,t.preflight,t.services,t.renderers].some(n=>Object.values(n??{}).some(r=>r.length>0))||[t.commands,t.parsers].some(n=>Object.values(n??{}).some(r=>r.some(o=>o.command===e)))?!1:!Object.entries(t.registrations??{}).some(([n,r])=>["migrations","search_providers","vector_store_adapters","assurance_providers"].includes(n)&&r.length>0)}function zo(e){let t=I();if(t){t.commandResult=e;return}oi=e}function eF(){let e=I();return e?e.commandResult:oi}function tF(e){if(!e)return;let t=I();t?t.affectedItems.push(e):ri.push(e)}function nF(e,t){if(!e||!e.id)return{};let n={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return n;let r=e;for(let o of t){if(typeof o!="string")continue;let i=o.startsWith("unset:")?o.slice(6):o;i==="id"||i==="type"||i==="status"||PI.has(i)||Object.hasOwn(r,i)&&r[i]!==void 0&&(n[i]=r[i])}return n}function rF(){let e=I(),t=e?.affectedItems??ri;if(t.length===0)return;let n=t;return e?e.affectedItems=[]:ri=[],n}function oF(){let e=I();if(e){e.hooks=null,e.commands=null,e.parsers=null,e.preflight=null,e.services=null,e.renderers=null,e.registrations=null,e.commandContext=null,e.commandResult=void 0,e.affectedItems=[];return}Ee=null,an=null,lr=null,ur=null,cn=null,fr=null,mr=null,We=null,oi=void 0,ri=[]}async function __(e){let t=I(),n=t?t.hooks:Ee;return n?_c(n,e):[]}var y_=new m_;function iF(e,t){return!e||(e.beforeMutation?.length??0)===0?t():y_.run(e,t)}function $I(){let e=I();return e?e.hooks:Ee}async function sF(e){let t=y_.getStore(),n=t??$I();if(!n)return;let{resolveMutationActor:r}=await import("./mutation-actor-DDYJW5B4.js"),o=t!==void 0||e.dry_run===!0,i=o?void 0:qa(e.pm_root,[e.before?.metadata.id,e.after?.metadata.id],e.operation),s=await pc(n,{pm_root:e.pm_root,operation:e.operation,before:e.before,after:e.after,changed_fields:e.changed_fields,sdk:e.sdk,actor:r(e.author),dry_run:o,...i===void 0?{}:{compensation:{transaction_id:i.transaction_id,step_id:i.step_id}}});i?.overrides.push(...s.map(a=>({source:"mutation_guard",...a})))}async function ro(e){let t=I(),n=t?t.hooks:Ee;return n?yc(n,e):[]}function aF(){let e=I();return((e?e.hooks:Ee)?.onRead?.length??0)>0}async function cF(e){let t=I(),n=t?t.hooks:Ee;return n?gc(n,e):[]}function Dm(e){let t=I(),n=t?t.commands:an,r=t?t.commandContext:We;return!n||!r?{overridden:!1,result:e,warnings:[]}:Oc(n,{command:r.command,args:[...r.args],options:r.options?{...r.options}:{},global:r.global?{...r.global}:void 0,pm_root:r.pm_root,source_workspace_root:r.source_workspace_root,repo_root:r.repo_root,pm_root_rel:r.pm_root_rel,result:e})}async function dF(e){let t=I(),n=t?t.commands:an;return n?hc(n,{...e,...ii(e.pm_root)}):{handled:!1,result:null,warnings:[]}}async function lF(e){let t=I(),n=t?t.parsers:lr;return n?bc(n,{...e,...ii(e.pm_root)}):{overridden:!1,context:{command:e.command,args:[...e.args],options:{...e.options},global:{...e.global},pm_root:e.pm_root},warnings:[]}}async function uF(e){let t=I(),n=t?t.preflight:ur;return n?wc(n,{...e,...ii(e.pm_root)}):{overridden:!1,context:{command:e.command,args:[...e.args],options:{...e.options},global:{...e.global},pm_root:e.pm_root},decision:{...e.decision},warnings:[]}}function Pm(e,t){let n=I(),r=n?n.renderers:fr,o=n?n.commandContext:We;return r?Sc(r,{format:e,command:o?.command,args:o?[...o.args]:[],options:o?.options?{...o.options}:{},global:o?.global?{...o.global}:void 0,pm_root:o?.pm_root,source_workspace_root:o?.source_workspace_root,repo_root:o?.repo_root,pm_root_rel:o?.pm_root_rel,result:t}):{overridden:!1,rendered:null,warnings:[]}}function g_(e,t){let n=I(),r=n?n.commandContext:We;return{service:e,command:r?.command,args:r?[...r.args]:[],options:r?.options?{...r.options}:{},global:r?.global?{...r.global}:void 0,pm_root:r?.pm_root,source_workspace_root:r?.source_workspace_root,repo_root:r?.repo_root,pm_root_rel:r?.pm_root_rel,payload:t}}async function en(e,t){let n=I(),r=n?n.services:cn;return r?Ec(r,g_(e,t)):{handled:!1,result:t,warnings:[]}}function Na(e,t){let n=I(),r=n?n.services:cn;return r?vc(r,g_(e,t)):{handled:!1,result:t,warnings:[]}}import si from"node:fs/promises";import ae from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f1eb25ad-08b8-5826-9ec1-7b0a7a22d277")}catch{}})();var b_="lock_path_unsafe";function MI(e,t){return ae.relative(e,t).split(ae.sep).join("/")}function jI(e,t){return e==="lock_entry_symlink"?`Remove the symlinked lock entry ${t} (pm neither follows nor deletes it), then retry the same operation.`:e==="lock_directory_replaced"?`Restore ${t} as a real directory inside the tracker, then retry the same operation. The lock file created while it was replaced stays where the replacement pointed, because pm never deletes outside the tracker; remove it there if it is not wanted.`:"Replace the symlinked or replaced lock directory with a real directory inside the tracker (for example: remove the link, then let pm recreate locks/), then retry the same operation."}function pr(e){let t=e.component??ae.dirname(e.lockPath),n=MI(e.pmRoot,t);return new h(`Refused to acquire lock ${e.id}: ${n} is not a real directory inside the tracker (${e.reason}). Locks are never created through a symlinked or replaced lock directory.`,g.CONFLICT,{code:"lock_path_unsafe",item_id:e.id,reason:e.reason,lock_component:n,required:jI(e.reason,n)})}function h_(e,t){return e.dev===t.dev&&e.ino===t.ino}async function ai(e,t,n,r=!0){let o=ae.resolve(e),i=ae.dirname(ae.resolve(t)),s=ae.relative(o,i);if(s===".."||s.startsWith(`..${ae.sep}`)||ae.isAbsolute(s))throw pr({pmRoot:o,lockPath:t,id:n,reason:"lock_path_outside_tracker",component:i});let a=o,c=null;for(let l of s===""?[]:s.split(ae.sep)){a=ae.join(a,l);let u;try{u=await si.lstat(a,{bigint:!0})}catch(f){if(r&&q(f))return null;throw f}if(u.isSymbolicLink())throw pr({pmRoot:o,lockPath:t,id:n,reason:"lock_directory_symlink",component:a});if(!u.isDirectory())throw pr({pmRoot:o,lockPath:t,id:n,reason:"lock_directory_not_directory",component:a});c={dev:u.dev,ino:u.ino}}if(c!==null)return c;let d=await si.stat(o,{bigint:!0});return{dev:d.dev,ino:d.ino}}async function w_(e,t,n){let r;try{r=await si.lstat(t)}catch{return}if(r.isSymbolicLink())throw pr({pmRoot:e,lockPath:t,id:n,reason:"lock_entry_symlink",component:t})}async function v_(e){let t=await e.handle.stat({bigint:!0}),n={dev:t.dev,ino:t.ino},r=!1;try{let o=await ai(e.pmRoot,e.lockPath,e.id,!1);if(h_(e.directory,o)){let i=await si.lstat(e.lockPath,{bigint:!0});r=!i.isSymbolicLink()&&h_(n,i)}}catch{r=!1}if(!r)throw pr({pmRoot:e.pmRoot,lockPath:e.lockPath,id:e.id,reason:"lock_directory_replaced"})}import Ic from"node:fs/promises";import{createHash as LI}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d1f829a5-70d6-5096-86f7-717440dd67d5")}catch{}})();function E_(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function FI(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!E_(t,"ESRCH")}}function O_(e){let t=e.lastIndexOf(")");if(t<0)return null;let n=e.slice(t+2).trim().split(/\s+/u)[19];return n!==void 0&&/^\d+$/u.test(n)?n:null}async function dn(e){try{return O_(await Ic.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function Cn(e=process.pid){let t=await dn(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function Rn(e,t,n){if(!FI(e.pid))return!1;let r=await dn(e.pid);return e.process_start_identity!==void 0&&r!==null?r===e.process_start_identity:t<=n}async function S_(){try{let[e,t]=await Promise.all([Ic.readFile("/proc/sys/kernel/random/boot_id","utf8"),Ic.readlink("/proc/self/ns/pid")]);return!/^[a-f0-9-]{36}\s*$/u.test(e)||!/^pid:\[\d+\]$/u.test(t)?null:LI("sha256").update(`${e.trim()}:${t}`).digest("hex")}catch{return null}}async function Tc(){let[e,t]=await Promise.all([S_(),dn(process.pid)]);return e!==null&&t!==null?{host_identity:e,process_start_identity:t}:{}}async function ci(e){if(!e||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0||typeof e.host_identity!="string"||typeof e.process_start_identity!="string"||!/^\d+$/u.test(e.process_start_identity))return"unknown";let t=await S_();if(t===null||t!==e.host_identity)return"unknown";try{process.kill(e.pid,0)}catch(r){return E_(r,"ESRCH")?"dead":"unknown"}let n=await dn(e.pid);return n===null?"unknown":n===e.process_start_identity?"alive":"dead"}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="be5b7a07-492a-5ca6-b607-059251a7cea3")}catch{}})();function HI(e){let t;try{t=JSON.parse(e)}catch{return{info:null,warnings:["lock_info_invalid_json"]}}if(typeof t!="object"||t===null||Array.isArray(t))return{info:null,warnings:["lock_info_invalid_shape"]};let n=t,r=n.id,o=n.pid,i=n.owner,s=n.token,a=n.created_at,c=n.ttl_seconds;return typeof r!="string"||typeof o!="number"||!Number.isFinite(o)||typeof i!="string"||s!==void 0&&(typeof s!="string"||s.trim().length===0)||typeof a!="string"||typeof c!="number"||!Number.isFinite(c)?{info:null,warnings:["lock_info_invalid_shape"]}:{info:{id:r,pid:o,owner:i,...typeof s=="string"?{token:s}:{},created_at:a,ttl_seconds:c,host_identity:n.host_identity,process_start_identity:n.process_start_identity},warnings:[]}}async function kt(e,t=!0){try{let n=await V.readFile(e,"utf8");return t&&await ro({path:e,scope:"project"}),HI(n)}catch(n){return q(n)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function Ge(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function VI(e,t,n=process.platform){if(Ge(e,"EEXIST"))return!0;if(!Ge(e,"EPERM")&&!Ge(e,"EACCES")&&!Ge(e,"EBUSY"))return!1;try{return await V.lstat(t),!0}catch(r){if(n!=="win32"||!q(r)&&!Ge(r,"EPERM")&&!Ge(r,"EACCES")&&!Ge(r,"EBUSY"))return!1}try{return await V.access(U.dirname(t),UI.W_OK),!0}catch{return!1}}async function C_(e,t){await __({path:e,scope:"project",op:t})}async function qI(e,t,n,r=ui()){return{...await Tc(),id:e,pid:process.pid,owner:t,token:r,created_at:hn(),ttl_seconds:n}}async function BI(e,t,n,r,o,i,s){let a=await ai(e,t,n);s&&a===null&&await V.mkdir(U.dirname(t),{recursive:!0});let c=await _i(t,n);if(c===null)throw await V.access(U.dirname(t)),Object.assign(new Error("Lock initialization is contended"),{code:"EEXIST"});let d;try{let l=await ai(e,t,n,!1),u=await V.open(t,"wx");try{await v_({pmRoot:e,lockPath:t,id:n,handle:u,directory:l})}catch(f){throw await u.close(),f}try{try{let f=await qI(n,r,o,i);d=f.created_at,await u.writeFile(`${JSON.stringify(f,null,2)}
112
+ `,"utf8")}finally{await u.close()}}catch(f){throw await xc(t,"lock:release"),f}}finally{await c()}return await C_(t,"lock:create"),d}async function xc(e,t){try{return await V.unlink(e),await C_(e,t),!0}catch{return!1}}async function WI(e,t,n,r){let o=performance.now(),i=fi;for(;;){let s=await _i(e,t);if(s!==null){try{let d=await kt(e,!1);Cc(d.info,t,n,r)&&await xc(e,"lock:release")}finally{await s()}return}let a=await kt(e,!1);if(!Cc(a.info,t,n,r))return;let c=performance.now()-o;if(c>=di)return;await pi(Math.min(i,di-c)),i=Math.min(i*2,mi)}}function Cc(e,t,n,r){return e?.id===t&&e.pid===process.pid&&e.owner===n&&e.token===r}function Nc(e,t){let n=e?.created_at?Date.parse(e.created_at):Number.NaN;return(Number.isFinite(n)?Date.now()-n:Number.POSITIVE_INFINITY)>t*1e3}async function R_(e){return e!==null&&Number.isFinite(Date.parse(e.created_at))&&await ci(e)==="dead"}async function x_(e,t){return Nc(e,t)||await R_(e)}async function pu(e,t,n){let{info:r}=await kt(Ii(e,t),!1);return r!==null&&r.owner.startsWith(n)&&!await x_(r,r.ttl_seconds)}function GI(e){return e?.owner?` (owner ${e.owner})`:""}var fi=25,mi=200,N_=250,KI=12e4,YI=3,XI=".stale-cleanup",D_="owner.json",P_=1e4,di=P_+mi;function Rc(e){if(typeof e=="string"){let t=e.trim();if(!/^\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)?n:void 0}if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return Math.trunc(e)}function JI(e){let t=process.env.PM_LOCK_WAIT_MS,n=Rc(t);if(n!==void 0)return n;let r=Rc(e);return r!==void 0?r:0}function QI(e,t){return Math.min(JI(e),t??1/0)}function pi(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(n=>setTimeout(n,t))}async function $_(e,t,n,r=0){n=Math.floor(n);let o=await ci(t),i=r>0?` across ${r} owner handoff(s)`:"",s=n>0?` after waiting ${n}ms${i}`:"";return new h(`Item ${e} is locked${GI(t)} (owner process ${o})${s}`,g.CONFLICT,{code:"lock_conflict",item_id:e,reason:`lock_owner_${o}`,required:"Wait for the owner to release the lock, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget when contention is expected. Inspect stale receipts with pm gc --scope locks --dry-run.",recovery:{retry_after_ms:N_,...n>0?{waited_ms:n,owner_handoffs:r}:{}}})}function ZI(e,t){let n=performance.now(),r=n,o,i=0;return{startedAtMs:n,observe(s){let a=performance.now(),c=tT(s);o!==void 0&&c!==o&&(i+=1,r=a),o=c;let d=a-n,l=a-r;return{exhausted:e===0||l>=e||d>=t,elapsedMs:d,remainingMs:Math.min(e-l,t-d),ownerHandoffs:i}}}}function eT(e,t,n){return n!=="progress"||t!==void 0?e:Math.max(e,KI)}function tT(e){return e===null?"released":e.token??`${e.pid}:${e.owner}:${e.created_at}`}function nT(e){let t=Date.parse(e.acquiredAt)+e.ttlSeconds*1e3;return{owner:e.owner,acquired_at:e.acquiredAt,ttl_seconds:e.ttlSeconds,expires_at:new Date(t).toISOString()}}function rT(e,t,n,r){let o=`the lease acquired at ${t.acquiredAt} (ttl ${t.ttlSeconds}s)`;if(r==="fence_gate_unavailable")return{summary:`Lock for ${e} could not be verified before commit: ${o} could not enter its commit fence because the stale-cleanup gate stayed held.`,required:"Retry the same operation; this writer's change was not committed. Inspect pm gc --scope locks --dry-run if the stale-cleanup gate stays held."};let i=n===null?"the lock no longer exists":`it is now held by ${n.owner} since ${n.created_at}`;return{summary:`Lock for ${e} was lost before commit: ${o} is no longer owned by this writer, and ${i}.`,required:"Re-read the item and apply the mutation again; this writer's change was not committed and the newer value was kept. Keep mutation work shorter than locks.ttl_seconds, or raise locks.ttl_seconds for long-running callbacks."}}function k_(e,t,n,r){let{summary:o,required:i}=rT(e,t,n,r);return new h(`${o} Nothing was written.`,g.CONFLICT,{code:"lock_lost",item_id:e,reason:r,lease:nT(t),current_owner:n===null?null:{owner:n.owner,pid:n.pid,created_at:n.created_at,ttl_seconds:n.ttl_seconds},required:i,recovery:{retry_after_ms:N_}})}async function oT(e,t){let n=performance.now(),r=fi;for(;;){let o=await _i(e,t);if(o!==null)return o;let i=performance.now()-n;if(i>=di)return null;await pi(Math.min(r,di-i)),r=Math.min(r*2,mi)}}async function iT(e,t,n,r){let o=await oT(e,t);if(o===null){let i=await kt(e,!1);throw k_(t,n,i.info,"fence_gate_unavailable")}try{let i=await kt(e,!1);if(!Cc(i.info,t,n.owner,n.token))throw k_(t,n,i.info,i.info===null?"lease_released":"lease_taken_over");return await r()}finally{await o()}}function sT(e){if(typeof e=="function")return e;if(typeof e=="object"&&e!==null&&"release"in e){let t=e.release;return typeof t=="function"?t:null}return null}async function aT(e,t,n){let r=U.dirname(U.dirname(e)),o=`Remove ${t} under ${U.relative(process.cwd(),r)||"."} once its owner is confirmed gone, then retry the same command.`;if(!n)return`${o} pm gc --scope locks keeps this lock: its metadata cannot be read or dated, or its own TTL has not run out.`;try{await V.access(xt(r))}catch{return o}let i=process.cwd(),s=U.resolve(Cr(i))===U.resolve(r)?[]:["--pm-path",U.relative(i,r)||"."];return`Run ${se([...s,"gc","--scope","locks"])} (add --dry-run to preview), then retry the same command.`}function cT(e){return e.info!==null&&e.warnings.length===0&&Number.isFinite(Date.parse(e.info.created_at))&&Nc(e.info,e.info.ttl_seconds)}async function dT(e,t,n,r,o){if(!r&&o){let i=n.warnings.length>0?` (${n.warnings.join(",")})`:"",s=`locks/${U.basename(t)}`;throw new h(`Lock ${e} is stale${i}; remove the expired lease, or rerun with --force where this command accepts it`,g.CONFLICT,{code:"stale_lock_requires_override",details:{lock_id:e,lock_path:s},why:`The lease in ${s} is past its TTL, and force_required_for_stale_lock keeps an expired lease until it is removed explicitly.`,required:"Remove the expired lease, then retry the same command.",nextSteps:[await aT(t,s,cT(n))]})}}function lT(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null||Array.isArray(t))return null;let n=t,r=n.pid,o=n.token,i=n.process_start_identity;return typeof r!="number"||!Number.isInteger(r)||r<=0||typeof o!="string"||o.length===0||i!==void 0&&(typeof i!="string"||!/^\d+$/u.test(i))?null:{pid:r,token:o,host_identity:n.host_identity,...typeof i=="string"?{process_start_identity:i}:{}}}async function li(e){try{return lT(await V.readFile(U.join(e,D_),"utf8"))}catch(t){return q(t)?null:void 0}}async function Dc(e){try{return await V.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function A_(e,t){let n=await li(e);for(let r=0;n===void 0&&r<3;r+=1)await pi(fi),n=await li(e);!n||n.token!==t||await Dc(e)}async function I_(e){try{await V.mkdir(e)}catch(n){return Ge(n,"EEXIST"),null}let t={...await Cn(),host_identity:(await Tc()).host_identity,token:ui()};try{await V.writeFile(U.join(e,D_),`${JSON.stringify(t)}
113
+ `,"utf8")}catch{return await Dc(e),null}return t}async function T_(e,t){let n=U.join(U.dirname(e),"recoveries"),r=zI("sha256").update(t).digest("hex");try{return await V.mkdir(n,{recursive:!0}),(await li(e))?.token!==t?!1:(await V.rename(e,U.join(n,`gate-${r}`)),!0)}catch{return!1}}async function uT(e){let t;try{let r=await V.stat(e);t=Date.now()-r.mtimeMs}catch(r){return q(r)}let n=await li(e);if(n===void 0)return!1;if(n!==null){if(await ci(n)==="dead")return T_(e,n.token);if(n.host_identity!==void 0)return!1}return t<=P_||n!==null&&await Rn(n,t,Number.POSITIVE_INFINITY)?!1:n!==null?T_(e,n.token):Dc(e)}async function _i(e,t){let n=`${e}${XI}`,r=await I_(n);if(r!==null)return async()=>A_(n,r.token);if(!await uT(n))return null;let o=await I_(n);return o===null?null:async()=>A_(n,o.token)}async function fT(e,t){let n=U.join(U.dirname(e),"recoveries");await V.mkdir(n,{recursive:!0}),await V.writeFile(U.join(n,`${ui()}.json`),`${JSON.stringify({event:"owner_dead_recovery_attempt",recorded_at:hn(),lock:JSON.parse(t)})}
114
+ `,{encoding:"utf8",flag:"wx",mode:384})}async function mT(e){let t=await _i(e.lockPath,e.id);if(t===null)return{lockInfo:e.fallbackLockInfo,shouldRetryCreate:!1,staleRemovalCounted:!1};try{let n=await kt(e.lockPath);if(n.info===null&&n.warnings.length===0)return{lockInfo:n,shouldRetryCreate:!0,staleRemovalCounted:!1};let r=await R_(n.info);if(!Nc(n.info,e.ttlSeconds)&&!r)return{lockInfo:n,shouldRetryCreate:!1,staleRemovalCounted:!1};if(await dT(e.id,e.lockPath,n,e.force||r,e.forceRequiredForStaleLock),e.staleRemovals>=YI)throw await $_(e.id,n.info,performance.now()-e.startedAtMs);return r&&await fT(e.lockPath,JSON.stringify(n.info)),{lockInfo:n,shouldRetryCreate:await xc(e.lockPath,"lock:stale_remove"),staleRemovalCounted:!0}}finally{await t()}}async function pT(e,t,n,r){if(e instanceof h&&e.code===b_)throw e;if(!await VI(e,n))throw new h(`Failed to acquire lock for ${r}: ${Td(e)}`,g.GENERIC_FAILURE);await w_(t,n,r)}async function xn(e,t,n,r,o=!1,i=!0,s,a={}){return(await us(e,t,n,r,o,i,s,a)).release}async function us(e,t,n,r,o=!1,i=!0,s,a={}){let c=Rc(a.maxWaitMs),d=await en("lock_acquire",{pm_root:e,id:t,ttl_seconds:n,owner:r,force:o,force_required_for_stale_lock:i,...c===void 0?{}:{max_wait_ms:c}});if(d.handled){let E=sT(d.result);if(E)return{release:async()=>{await Promise.resolve(E()),await en("lock_release",{pm_root:e,id:t,owner:r})},fence:M=>M()}}let l=Ii(e,t),u=QI(s,c),f=eT(u,c,a.waitPolicy),m=ZI(u,f),p=m.startedAtMs,_=0,y=fi,b=ui();for(;;)try{let E=await BI(e,l,t,r,n,b,a.createParentDirectories!==!1),M={owner:r,token:b,acquiredAt:E,ttlSeconds:n};return{release:async()=>{await WI(l,t,r,b),await en("lock_release",{pm_root:e,id:t,owner:r})},fence:X=>iT(l,t,M,X)}}catch(E){await pT(E,e,l,t);let M=await kt(l);if(await x_(M.info,n)){let J=await mT({lockPath:l,id:t,ttlSeconds:n,force:o,forceRequiredForStaleLock:i,staleRemovals:_,waitBudgetMs:u,startedAtMs:p,fallbackLockInfo:M});if(M=J.lockInfo,J.staleRemovalCounted&&(_+=1),J.shouldRetryCreate)continue}let X=m.observe(M.info);if(X.exhausted)throw await $_(t,M.info,u===0?0:X.elapsedMs,X.ownerHandoffs);await pi(Math.min(y,X.remainingMs)),y=Math.min(y*2,mi)}}export{C as a,ce as b,Tt as c,Ke as d,K_ as e,Bc as f,bi as g,J_ as h,Q_ as i,Er as j,Gc as k,ey as l,ry as m,vT as n,ET as o,ay as p,cy as q,dy as r,ly as s,wi as t,ST as u,uy as v,mn as w,Or as x,kT as y,AT as z,IT as A,fy as B,my as C,py as D,NT as E,DT as F,_y as G,Sr as H,PT as I,$T as J,yy as K,gy as L,hy as M,Yc as N,Ct as O,by as P,MT as Q,jT as R,LT as S,FT as T,UT as U,zT as V,HT as W,VT as X,Ed as Y,Dg as Z,Pg as _,$g as $,Dr as aa,qC as ba,wy as ca,Xc as da,Rt as ea,Jc as fa,kr as ga,Qc as ha,Zc as ia,BT as ja,WT as ka,GT as la,Ar as ma,Ir as na,KT as oa,YT as pa,XT as qa,JT as ra,QT as sa,ZT as ta,Tr as ua,pn as va,vi as wa,eC as xa,ed as ya,tC as za,nC as Aa,rC as Ba,oC as Ca,rd as Da,Ay as Ea,id as Fa,ld as Ga,mC as Ha,ki as Ia,Ly as Ja,pC as Ka,Qy as La,Zy as Ma,_C as Na,yC as Oa,kC as Pa,Ai as Qa,AC as Ra,Cr as Sa,pd as Ta,_d as Ua,xt as Va,IC as Wa,TC as Xa,CC as Ya,Ii as Za,Ti as _a,Rr as $a,yg as ab,RC as bb,gg as cb,hg as db,xC as eb,NC as fb,bg as gb,DC as hb,gn as ib,xr as jb,yd as kb,se as lb,Ri as mb,Ni as nb,gd as ob,UC as pb,Nt as qb,zC as rb,bd as sb,HC as tb,Rg as ub,xg as vb,Ng as wb,eR as xb,tR as yb,nR as zb,Ug as Ab,Pr as Bb,$i as Cb,sR as Db,kd as Eb,Ad as Fb,Hd as Gb,Hg as Hb,cR as Ib,dR as Jb,lR as Kb,Td as Lb,uR as Mb,fR as Nb,mR as Ob,Id as Pb,Cd as Qb,pR as Rb,Mr as Sb,Bg as Tb,Wg as Ub,bR as Vb,wR as Wb,hn as Xb,ye as Yb,bn as Zb,Dt as _b,G as $b,AR as ac,IR as bc,Lr as cc,RR as dc,Pd as ec,xR as fc,Fr as gc,Md as hc,jd as ic,Ui as jc,Ld as kc,PR as lc,Fd as mc,$R as nc,Ud as oc,LR as pc,yh as qc,zd as rc,Xe as sc,Ie as tc,Te as uc,de as vc,Vi as wc,En as xc,ge as yc,JR as zc,QR as Ac,ZR as Bc,Jd as Cc,qi as Dc,Qd as Ec,Zd as Fc,ex as Gc,cx as Hc,Xh as Ic,dx as Jc,sl as Kc,qr as Lc,al as Mc,On as Nc,rb as Oc,lx as Pc,ux as Qc,Bi as Rc,Wi as Sc,mx as Tc,Gi as Uc,dl as Vc,ob as Wc,px as Xc,Wr as Yc,sb as Zc,hx as _c,Ki as $c,wx as ad,vx as bd,cb as cd,db as dd,Ex as ed,fl as fd,Gr as gd,Hx as hd,Ub as id,rw as jd,Xr as kd,Ew as ld,Vx as md,qx as nd,Lt as od,kl as pd,Qe as qd,cs as rd,Kx as sd,Yx as td,ai as ud,ci as vd,oT as wd,_i as xd,fT as yd,xn as zd,us as Ad,fs as Bd,Rl as Cd,ps as Dd,oN as Ed,iN as Fd,sN as Gd,aN as Hd,cN as Id,dN as Jd,Os as Kd,Ss as Ld,Ll as Md,wN as Nd,vN as Od,EN as Pd,ON as Qd,SN as Rd,kN as Sd,Ts as Td,Vl as Ud,AN as Vd,IN as Wd,TN as Xd,av as Yd,ql as Zd,Bl as _d,CN as $d,RN as ae,no as be,LN as ce,Wl as de,dv as ee,Yl as fe,YN as ge,Cs as he,Jl as ie,XN as je,JN as ke,Ql as le,Zl as me,oo as ne,QN as oe,hv as pe,ZN as qe,eD as re,nD as se,vv as te,Ev as ue,zt as ve,iu as we,Hv as xe,Gv as ye,bD as ze,wD as Ae,Vs as Be,Tu as Ce,_o as De,De as Ee,OD as Fe,SD as Ge,kD as He,$n as Ie,bo as Je,wo as Ke,st as Le,FD as Me,vo as Ne,SE as Oe,kE as Pe,UD as Qe,ue as Re,zD as Se,RE as Te,DE as Ue,UE as Ve,Ku as We,Ju as Xe,Ks as Ye,Js as Ze,ko as _e,qE as $e,Pe as af,Vt as bf,jn as cf,qt as df,Ln as ef,Zu as ff,JD as gf,Fn as hf,Un as if,je as jf,t0 as kf,aP as lf,sf as mf,n0 as nf,u0 as of,m0 as pf,af as qf,p0 as rf,_0 as sf,cf as tf,dt as uf,df as vf,cP as wf,dP as xf,na as yf,lP as zf,uP as Af,fP as Bf,mP as Cf,pP as Df,oe as Ef,lt as Ff,vP as Gf,ra as Hf,oa as If,Ro as Jf,mf as Kf,ia as Lf,pf as Mf,zn as Nf,OP as Of,ut as Pf,VP as Qf,qP as Rf,R0 as Sf,Fe as Tf,BP as Uf,WP as Vf,GP as Wf,Sf as Xf,j0 as Yf,KP as Zf,Af as _f,da as $f,Pf as ag,fe as bg,aO as cg,$f as dg,Mf as eg,No as fg,la as gg,qn as hg,f1 as ig,m1 as jg,Bn as kg,ua as lg,pa as mg,p1 as ng,bO as og,_1 as pg,y1 as qg,he as rg,F as sg,T1 as tg,pt as ug,RO as vg,C1 as wg,R1 as xg,xO as yg,x1 as zg,N1 as Ag,D1 as Bg,$O as Cg,em as Dg,MO as Eg,W1 as Fg,LO as Gg,nm as Hg,G1 as Ig,im as Jg,HO as Kg,Jf as Lg,ba as Mg,fm as Ng,_m as Og,Q1 as Pg,ym as Qg,e$ as Rg,Em as Sg,Sm as Tg,s$ as Ug,a$ as Vg,SS as Wg,Yn as Xg,Io as Yg,WS as Zg,KS as _g,k$ as $g,A$ as ah,XS as bh,Ho as ch,nt as dh,Tn as eh,ZS as fh,ek as gh,Hm as hh,Zt as ih,X$ as jh,ja as kh,io as lh,nu as mh,xs as nh,La as oh,qm as ph,ru as qh,J$ as rh,Q$ as sh,Z$ as th,dM as uh,lM as vh,uM as wh,fM as xh,mM as yh,pM as zh,_M as Ah,yM as Bh,gk as Ch,hk as Dh,bk as Eh,gM as Fh,kk as Gh,hM as Hh,bM as Ih,wM as Jh,vM as Kh,qa as Lh,EM as Mh,OM as Nh,Ba as Oh,Ka as Ph,Ya as Qh,TM as Rh,CM as Sh,RM as Th,$k as Uh,Xm as Vh,xM as Wh,Yo as Xh,MM as Yh,jM as Zh,x as _h,Xo as $h,WM as ai,tp as bi,Qa as ci,Qk as di,Zk as ei,er as fi,ec as gi,tc as hi,nc as ii,rc as ji,oc as ki,ic as li,cc as mi,EA as ni,OA as oi,IA as pi,TA as qi,Ep as ri,Ap as si,Vp as ti,qp as ui,zA as vi,pc as wi,qA as xi,_c as yi,yc as zi,gc as Ai,hc as Bi,bc as Ci,wc as Di,Ec as Ei,Oc as Fi,Sc as Gi,JA as Hi,ZA as Ii,eI as Ji,cI as Ki,AL as Li,IL as Mi,TL as Ni,NL as Oi,PL as Pi,II as Qi,TI as Ri,Ac as Si,xI as Ti,NI as Ui,VL as Vi,ii as Wi,qL as Xi,BL as Yi,WL as Zi,GL as _i,KL as $i,YL as aj,XL as bj,Xu as cj,JL as dj,QL as ej,Nm as fj,ZL as gj,zo as hj,eF as ij,tF as jj,nF as kj,rF as lj,oF as mj,__ as nj,iF as oj,$I as pj,sF as qj,ro as rj,aF as sj,cF as tj,dF as uj,lF as vj,uF as wj,en as xj};
115
+ //# sourceMappingURL=chunk-7UUPLMCU.js.map