@unbrained/pm-cli 2026.10.4 → 2026.10.6

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 (751) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +37 -1
  3. package/dist/cli/after-command-context-usage.js +1 -1
  4. package/dist/cli/argv-utils.js +1 -1
  5. package/dist/cli/bootstrap-args.js +1 -1
  6. package/dist/cli/bundle-integrity.js +2 -2
  7. package/dist/cli/command-namespaces.js +1 -1
  8. package/dist/cli/commander-usage.d.ts +1 -1
  9. package/dist/cli/commander-usage.js +7 -4
  10. package/dist/cli/commands/annotations/comments.js +1 -1
  11. package/dist/cli/commands/annotations/docs.js +1 -1
  12. package/dist/cli/commands/annotations/files.js +1 -1
  13. package/dist/cli/commands/annotations/learnings.js +1 -1
  14. package/dist/cli/commands/annotations/notes.js +1 -1
  15. package/dist/cli/commands/extension/describe.js +1 -1
  16. package/dist/cli/commands/extension/extension.js +1 -1
  17. package/dist/cli/commands/extension/scaffold.js +1 -1
  18. package/dist/cli/commands/extension/shared.js +1 -1
  19. package/dist/cli/commands/governance/gc.js +1 -1
  20. package/dist/cli/commands/governance/health.js +1 -1
  21. package/dist/cli/commands/governance/telemetry.js +1 -1
  22. package/dist/cli/commands/governance/validate.js +1 -1
  23. package/dist/cli/commands/history/activity.js +1 -1
  24. package/dist/cli/commands/history/history-compact.js +1 -1
  25. package/dist/cli/commands/history/history-redact.js +1 -1
  26. package/dist/cli/commands/history/history-repair.js +1 -1
  27. package/dist/cli/commands/history/history.js +1 -1
  28. package/dist/cli/commands/history/restore.js +1 -1
  29. package/dist/cli/commands/lifecycle/append.js +1 -1
  30. package/dist/cli/commands/lifecycle/claim.js +1 -1
  31. package/dist/cli/commands/lifecycle/close-many.js +1 -1
  32. package/dist/cli/commands/lifecycle/close.js +1 -1
  33. package/dist/cli/commands/lifecycle/copy.js +1 -1
  34. package/dist/cli/commands/lifecycle/create.js +1 -1
  35. package/dist/cli/commands/lifecycle/delete.js +1 -1
  36. package/dist/cli/commands/lifecycle/focus.js +1 -1
  37. package/dist/cli/commands/lifecycle/plan.js +1 -1
  38. package/dist/cli/commands/lifecycle/update-many.js +1 -1
  39. package/dist/cli/commands/lifecycle/update.js +1 -1
  40. package/dist/cli/commands/query/aggregate.js +1 -1
  41. package/dist/cli/commands/query/context.js +1 -1
  42. package/dist/cli/commands/query/deps.js +1 -1
  43. package/dist/cli/commands/query/duplicates.js +1 -1
  44. package/dist/cli/commands/query/eval.js +1 -1
  45. package/dist/cli/commands/query/get.js +1 -1
  46. package/dist/cli/commands/query/graph.js +1 -1
  47. package/dist/cli/commands/query/list.js +1 -1
  48. package/dist/cli/commands/query/next.js +1 -1
  49. package/dist/cli/commands/query/search.js +1 -1
  50. package/dist/cli/commands/query/stats.js +1 -1
  51. package/dist/cli/commands/test/test-all.js +1 -1
  52. package/dist/cli/commands/test/test-runs.js +1 -1
  53. package/dist/cli/commands/test/test.js +1 -1
  54. package/dist/cli/commands/workspace/config.js +1 -1
  55. package/dist/cli/commands/workspace/contracts.js +1 -1
  56. package/dist/cli/commands/workspace/init.js +1 -1
  57. package/dist/cli/commands/workspace/merge.js +1 -1
  58. package/dist/cli/commands/workspace/profile.js +1 -1
  59. package/dist/cli/commands/workspace/schema.js +1 -1
  60. package/dist/cli/commands/workspace/upgrade.js +1 -1
  61. package/dist/cli/context-intent-invocation.js +1 -1
  62. package/dist/cli/description-stdin.js +1 -1
  63. package/dist/cli/error-guidance.js +3 -1
  64. package/dist/cli/extension-command-help.js +5 -3
  65. package/dist/cli/extension-command-options.js +1 -1
  66. package/dist/cli/extension-recovery.js +1 -1
  67. package/dist/cli/help-content.js +5 -2
  68. package/dist/cli/help-json-payload.js +6 -3
  69. package/dist/cli/invocation-profile.js +2 -2
  70. package/dist/cli/main.js +5 -5
  71. package/dist/cli/migration-gates.js +1 -1
  72. package/dist/cli/option-values.js +1 -1
  73. package/dist/cli/public.js +1 -1
  74. package/dist/cli/register-annotations.js +1 -1
  75. package/dist/cli/register-assurance.js +1 -1
  76. package/dist/cli/register-files-lookup.js +1 -1
  77. package/dist/cli/register-history-activity.js +1 -1
  78. package/dist/cli/register-history-author.js +1 -1
  79. package/dist/cli/register-history-maintenance.js +2 -2
  80. package/dist/cli/register-list-query.js +10 -10
  81. package/dist/cli/register-mutation-options.js +1 -1
  82. package/dist/cli/register-mutation.js +2 -2
  83. package/dist/cli/register-operations.js +1 -1
  84. package/dist/cli/register-setup.js +1 -1
  85. package/dist/cli/register-structured-mutation.js +1 -1
  86. package/dist/cli/registration-helpers.js +1 -1
  87. package/dist/cli/runtime/activation.js +1 -1
  88. package/dist/cli/runtime/invocation-options.js +1 -1
  89. package/dist/cli/runtime/projection-retry.js +1 -1
  90. package/dist/cli/runtime/selection.js +1 -1
  91. package/dist/cli/runtime/telemetry-outcome.js +1 -1
  92. package/dist/cli/runtime-compatibility-boundary.js +4 -4
  93. package/dist/cli/schema/registration.js +2 -2
  94. package/dist/cli/schema-registration-helpers.js +1 -1
  95. package/dist/cli/search-refresh.js +1 -1
  96. package/dist/cli/stats-analytics-json.js +1 -1
  97. package/dist/cli/telemetry-flush.js +1 -1
  98. package/dist/cli-bundle/bundle-manifest.json +163 -163
  99. package/dist/cli-bundle/chunks/{chunk-SMKHR6BM.js → chunk-25EW53VO.js} +89 -88
  100. package/dist/cli-bundle/chunks/chunk-3CCVTV6Q.js +8 -0
  101. package/dist/cli-bundle/chunks/chunk-3REXBTST.js +3 -0
  102. package/dist/cli-bundle/chunks/chunk-4WB55TBC.js +80 -0
  103. package/dist/cli-bundle/chunks/{chunk-7CE2DJMA.js → chunk-6STTPXOC.js} +2 -2
  104. package/dist/cli-bundle/chunks/chunk-ATB4ZZBQ.js +20 -0
  105. package/dist/cli-bundle/chunks/chunk-D4G43LBV.js +238 -0
  106. package/dist/cli-bundle/chunks/chunk-K6D6DMRT.js +31 -0
  107. package/dist/cli-bundle/chunks/chunk-KIRHWPZB.js +2 -0
  108. package/dist/cli-bundle/chunks/chunk-O67BH435.js +6 -0
  109. package/dist/cli-bundle/chunks/chunk-R7CG2DB7.js +2 -0
  110. package/dist/cli-bundle/chunks/chunk-RJHLD64E.js +3 -0
  111. package/dist/cli-bundle/chunks/chunk-TUKO5NF7.js +2 -0
  112. package/dist/cli-bundle/chunks/chunk-UZ7BIUCI.js +2 -0
  113. package/dist/cli-bundle/chunks/{chunk-GZMWISWW.js → chunk-XJD47LUH.js} +3 -3
  114. package/dist/cli-bundle/chunks/{register-list-query-QBGXO5JJ.js → register-list-query-53WYLNZT.js} +11 -11
  115. package/dist/cli-bundle/chunks/register-mutation-34XXUBVI.js +20 -0
  116. package/dist/cli-bundle/chunks/register-operations-WANO6EIM.js +2 -0
  117. package/dist/cli-bundle/chunks/register-setup-WT37UPBQ.js +2 -0
  118. package/dist/cli-bundle/focused-chunks/chunk-6KFKQD2D.js +165 -0
  119. package/dist/cli-bundle/focused-chunks/chunk-FOHRPFIT.js +2 -0
  120. package/dist/cli-bundle/focused-chunks/chunk-GRQXL5G5.js +8 -0
  121. package/dist/cli-bundle/focused-chunks/{chunk-467EW5RL.js → chunk-JZ4WGUVH.js} +3 -3
  122. package/dist/cli-bundle/focused-chunks/chunk-NM3PM6O6.js +3 -0
  123. package/dist/cli-bundle/focused-chunks/chunk-OT7HK7SG.js +2 -0
  124. package/dist/cli-bundle/focused-chunks/{chunk-Q6DJ5DFQ.js → chunk-PCLU34KB.js} +2 -2
  125. package/dist/cli-bundle/focused-chunks/{chunk-HFAW3FJQ.js → chunk-PSXFFQFT.js} +2 -2
  126. package/dist/cli-bundle/focused-chunks/chunk-QQIE4L42.js +2 -0
  127. package/dist/cli-bundle/focused-chunks/chunk-RPUNVKXK.js +2 -0
  128. package/dist/cli-bundle/focused-chunks/chunk-RXSVJPZ7.js +3 -0
  129. package/dist/cli-bundle/focused-chunks/chunk-SPN5QTZ3.js +30 -0
  130. package/dist/cli-bundle/focused-chunks/chunk-SUZJNPGB.js +6 -0
  131. package/dist/cli-bundle/focused-chunks/chunk-W4BG5HHS.js +2 -0
  132. package/dist/cli-bundle/focused-chunks/chunk-Y5HXFDTZ.js +20 -0
  133. package/dist/cli-bundle/focused-chunks/chunk-ZK5SOOPC.js +75 -0
  134. package/dist/cli-bundle/focused-chunks/chunk-ZQK2XUSS.js +12 -0
  135. package/dist/cli-bundle/main.js +25 -25
  136. package/dist/cli-bundle/sdk-authoring.js +1 -1
  137. package/dist/cli-bundle/sdk-contracts.js +2 -2
  138. package/dist/cli-bundle/sdk-core.js +25 -24
  139. package/dist/cli-bundle/sdk-governance.js +1 -1
  140. package/dist/cli-bundle/sdk-graph.js +1 -1
  141. package/dist/cli-bundle/sdk-merge.js +55 -55
  142. package/dist/cli-bundle/sdk-query.js +1 -1
  143. package/dist/cli-bundle/sdk-runtime.js +1 -1
  144. package/dist/cli-bundle/sdk-testing.js +1 -1
  145. package/dist/cli-bundle/sdk.js +10 -10
  146. package/dist/cli.js +1 -1
  147. package/dist/core/checkpoint/checkpoint-gc.js +1 -1
  148. package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
  149. package/dist/core/config/nested-settings.js +1 -1
  150. package/dist/core/config/positional-value.js +1 -1
  151. package/dist/core/diagnostics/remediation.js +1 -1
  152. package/dist/core/extensions/activation-summary-markdown.js +2 -1
  153. package/dist/core/extensions/activation-summary.js +1 -1
  154. package/dist/core/extensions/activation-transaction.js +1 -1
  155. package/dist/core/extensions/capability-usage.js +1 -1
  156. package/dist/core/extensions/command-hook-context.js +1 -1
  157. package/dist/core/extensions/command-metadata-contract.js +1 -1
  158. package/dist/core/extensions/command-visibility-tier.js +1 -1
  159. package/dist/core/extensions/contribution-inventory.js +1 -1
  160. package/dist/core/extensions/exporter-output-contract.js +1 -1
  161. package/dist/core/extensions/extension-candidate.js +1 -1
  162. package/dist/core/extensions/extension-capability-aliases.js +1 -1
  163. package/dist/core/extensions/extension-hook-runtime.js +1 -1
  164. package/dist/core/extensions/extension-policy.js +1 -1
  165. package/dist/core/extensions/extension-registries.js +1 -1
  166. package/dist/core/extensions/extension-runtime-helpers.js +1 -1
  167. package/dist/core/extensions/extension-types.d.ts +2 -0
  168. package/dist/core/extensions/extension-types.js +1 -1
  169. package/dist/core/extensions/flag-definition-validation.js +1 -1
  170. package/dist/core/extensions/flag-value-types.js +1 -1
  171. package/dist/core/extensions/index.js +1 -1
  172. package/dist/core/extensions/item-field-types.js +1 -1
  173. package/dist/core/extensions/item-fields.js +1 -1
  174. package/dist/core/extensions/loader.js +1 -1
  175. package/dist/core/extensions/manifest-parser.js +1 -1
  176. package/dist/core/extensions/manifest-schema.js +1 -1
  177. package/dist/core/extensions/module-graph-snapshot.js +1 -1
  178. package/dist/core/extensions/preflight-ownership.js +1 -1
  179. package/dist/core/extensions/registration-contracts.js +1 -1
  180. package/dist/core/extensions/registration-validation.js +1 -1
  181. package/dist/core/extensions/registration-values.js +1 -1
  182. package/dist/core/extensions/reserved-host-flags.js +1 -1
  183. package/dist/core/extensions/runtime-registrations.js +1 -1
  184. package/dist/core/extensions/service-ownership.js +1 -1
  185. package/dist/core/extensions/version-compat.js +1 -1
  186. package/dist/core/fs/atomic-create.js +1 -1
  187. package/dist/core/fs/fs-utils.js +2 -2
  188. package/dist/core/fs/host-environment-errors.js +1 -1
  189. package/dist/core/fs/index.js +1 -1
  190. package/dist/core/fs/path-utils.js +1 -1
  191. package/dist/core/governance/content-fields.js +1 -1
  192. package/dist/core/governance/issue-codes.js +1 -1
  193. package/dist/core/governance/metadata-coverage.js +1 -1
  194. package/dist/core/history/digest.js +1 -1
  195. package/dist/core/history/drift-cache.js +3 -3
  196. package/dist/core/history/drift-scan.d.ts +4 -0
  197. package/dist/core/history/drift-scan.js +1 -1
  198. package/dist/core/history/event-classification.js +1 -1
  199. package/dist/core/history/event-index.js +8 -7
  200. package/dist/core/history/history-compact-bulk.js +1 -1
  201. package/dist/core/history/history-diff.js +1 -1
  202. package/dist/core/history/history-rewrite.js +1 -1
  203. package/dist/core/history/history-storage-stats.js +1 -1
  204. package/dist/core/history/history-stream-policy.js +1 -1
  205. package/dist/core/history/history.js +2 -2
  206. package/dist/core/history/identity.js +1 -1
  207. package/dist/core/history/index.js +1 -1
  208. package/dist/core/history/operation-contract.js +1 -1
  209. package/dist/core/history/projection.js +1 -1
  210. package/dist/core/history/read.js +1 -1
  211. package/dist/core/history/replay.js +2 -1
  212. package/dist/core/history/tombstone.js +1 -1
  213. package/dist/core/history/version-address.js +1 -1
  214. package/dist/core/history/workspace-history.js +2 -2
  215. package/dist/core/io/body-file.js +1 -1
  216. package/dist/core/io/bulk-ids-input.js +2 -1
  217. package/dist/core/item/actionability.js +1 -1
  218. package/dist/core/item/dependency-reference.js +1 -1
  219. package/dist/core/item/id.js +1 -1
  220. package/dist/core/item/index.js +1 -1
  221. package/dist/core/item/item-format-version.js +1 -1
  222. package/dist/core/item/item-format.js +6 -4
  223. package/dist/core/item/item-record.js +1 -1
  224. package/dist/core/item/item-type-definition.js +1 -1
  225. package/dist/core/item/parent-reference-policy.js +1 -1
  226. package/dist/core/item/parse.js +8 -2
  227. package/dist/core/item/plan-lifecycle.js +1 -1
  228. package/dist/core/item/priority.js +1 -1
  229. package/dist/core/item/sprint-release-format.js +1 -1
  230. package/dist/core/item/status-filter.js +1 -1
  231. package/dist/core/item/status.js +1 -1
  232. package/dist/core/item/toon-decode.js +1 -1
  233. package/dist/core/item/type-registry.js +1 -1
  234. package/dist/core/item/type-synonyms.js +1 -1
  235. package/dist/core/lock/index.js +1 -1
  236. package/dist/core/lock/lock-gc.js +1 -1
  237. package/dist/core/lock/lock.js +3 -3
  238. package/dist/core/output/mutation-projection.js +1 -1
  239. package/dist/core/output/output-control.js +1 -1
  240. package/dist/core/output/output.js +22 -10
  241. package/dist/core/output/query-summary.js +1 -1
  242. package/dist/core/output/tabular.js +3 -1
  243. package/dist/core/packages/manifest.js +1 -1
  244. package/dist/core/packages/root.js +1 -1
  245. package/dist/core/policy/workflow-policy-schema.js +1 -1
  246. package/dist/core/policy/workflow-policy-store.js +1 -1
  247. package/dist/core/policy/workflow-policy.js +1 -1
  248. package/dist/core/profile/profile-describe.js +1 -1
  249. package/dist/core/profile/profile-lint.js +1 -1
  250. package/dist/core/profile/profile-plan.js +1 -1
  251. package/dist/core/profile/profile-presets.js +25 -1
  252. package/dist/core/reproducibility/context.js +1 -1
  253. package/dist/core/schema/fields-file.js +2 -2
  254. package/dist/core/schema/item-types-file.js +2 -2
  255. package/dist/core/schema/runtime-field-filters.js +1 -1
  256. package/dist/core/schema/runtime-field-values.js +1 -1
  257. package/dist/core/schema/runtime-schema.js +2 -2
  258. package/dist/core/schema/status-defs-file.js +2 -2
  259. package/dist/core/schema/status-token.js +1 -1
  260. package/dist/core/schema/type-inference.js +1 -1
  261. package/dist/core/schema/type-presets.js +1 -1
  262. package/dist/core/schema/type-workflows.js +1 -1
  263. package/dist/core/search/background-refresh.js +2 -2
  264. package/dist/core/search/bm25.js +1 -1
  265. package/dist/core/search/cache.js +2 -2
  266. package/dist/core/search/corpus.js +1 -1
  267. package/dist/core/search/embedding-batches.js +1 -1
  268. package/dist/core/search/eval-thresholds.js +1 -1
  269. package/dist/core/search/eval.js +1 -1
  270. package/dist/core/search/http-client.js +1 -1
  271. package/dist/core/search/providers.js +1 -1
  272. package/dist/core/search/relevance.js +1 -1
  273. package/dist/core/search/semantic-defaults.js +1 -1
  274. package/dist/core/search/staleness.js +1 -1
  275. package/dist/core/search/vector-stores.js +2 -2
  276. package/dist/core/search/vectorization-metadata.js +1 -1
  277. package/dist/core/sentry/helpers.js +1 -1
  278. package/dist/core/sentry/instrument.js +1 -1
  279. package/dist/core/session/session-state.js +1 -1
  280. package/dist/core/shared/agent-session-context.js +1 -1
  281. package/dist/core/shared/author.js +5 -1
  282. package/dist/core/shared/command-line.js +1 -1
  283. package/dist/core/shared/command-types.js +1 -1
  284. package/dist/core/shared/conflict-markers.js +1 -1
  285. package/dist/core/shared/constants.js +1 -1
  286. package/dist/core/shared/errors.js +1 -1
  287. package/dist/core/shared/html-entity-decode.js +1 -1
  288. package/dist/core/shared/index.js +1 -1
  289. package/dist/core/shared/item-metadata-contract.js +1 -1
  290. package/dist/core/shared/lazy-module.js +1 -1
  291. package/dist/core/shared/levenshtein.js +1 -1
  292. package/dist/core/shared/memo.js +1 -1
  293. package/dist/core/shared/numeric-parsers.js +1 -1
  294. package/dist/core/shared/option-alias-visibility.js +1 -1
  295. package/dist/core/shared/primitives.js +1 -1
  296. package/dist/core/shared/secret-rules.js +1 -1
  297. package/dist/core/shared/serial-queue.js +1 -1
  298. package/dist/core/shared/serialization.js +1 -1
  299. package/dist/core/shared/split-comma-list.js +1 -1
  300. package/dist/core/shared/text-normalization.js +1 -1
  301. package/dist/core/shared/time.js +2 -1
  302. package/dist/core/store/index.js +1 -1
  303. package/dist/core/store/item-format-migration.js +1 -1
  304. package/dist/core/store/item-metadata-cache.js +1 -1
  305. package/dist/core/store/item-metadata-query-index.js +7 -7
  306. package/dist/core/store/item-metadata-read-work.js +1 -1
  307. package/dist/core/store/item-store.js +1 -1
  308. package/dist/core/store/paths.js +1 -1
  309. package/dist/core/store/settings-concurrency.js +1 -1
  310. package/dist/core/store/settings-read-cache.js +1 -1
  311. package/dist/core/store/settings-validator.js +1 -1
  312. package/dist/core/store/settings.js +3 -3
  313. package/dist/core/store/tracker-preflight.js +1 -1
  314. package/dist/core/telemetry/consent.js +2 -2
  315. package/dist/core/telemetry/observability.js +1 -1
  316. package/dist/core/telemetry/policy.js +1 -1
  317. package/dist/core/telemetry/read-sampling.js +2 -2
  318. package/dist/core/telemetry/runtime.js +9 -5
  319. package/dist/core/test/background-runs.js +3 -3
  320. package/dist/core/test/item-test-run-tracking.js +1 -1
  321. package/dist/core/test/run-selectors.js +1 -1
  322. package/dist/core/validate/estimate-defaults.js +1 -1
  323. package/dist/core/validate/fix-planning.js +1 -1
  324. package/dist/core/validate/linked-artifact-reference.js +1 -1
  325. package/dist/core/validate/missing-by-type.js +1 -1
  326. package/dist/core/validate/missing-link-owners.js +1 -1
  327. package/dist/core/validate/stale-file-classification.js +1 -1
  328. package/dist/mcp/http-server.js +6 -4
  329. package/dist/mcp/legacy-adapter.js +1 -1
  330. package/dist/mcp/runtime-capabilities.js +1 -1
  331. package/dist/mcp/server.js +4 -4
  332. package/dist/mcp/tool-definitions.js +1 -1
  333. package/dist/sdk/actionability.js +1 -1
  334. package/dist/sdk/agent/closed-domain-contracts.js +1 -1
  335. package/dist/sdk/agent/command-recovery.js +1 -1
  336. package/dist/sdk/agent/command-suggestions.js +1 -1
  337. package/dist/sdk/agent/create-option-policy.js +1 -1
  338. package/dist/sdk/agent/identity-config.js +1 -1
  339. package/dist/sdk/agent/item-addressing.js +1 -1
  340. package/dist/sdk/agent/refusal-closure-census.js +2 -1
  341. package/dist/sdk/agent/refusal-closure.js +1 -1
  342. package/dist/sdk/agent/refusal-corpus-contracts.js +1 -1
  343. package/dist/sdk/agent/refusal-reachability.js +3 -1
  344. package/dist/sdk/agent/subcommand-recovery.js +1 -1
  345. package/dist/sdk/agent/task-transcript-contracts.js +1 -1
  346. package/dist/sdk/agent/tracker-preflight-contracts.js +1 -1
  347. package/dist/sdk/agent-capability-contracts.js +3 -1
  348. package/dist/sdk/agent-session-context.js +1 -1
  349. package/dist/sdk/annotations.js +1 -1
  350. package/dist/sdk/author-attribution.js +1 -1
  351. package/dist/sdk/authoring.js +1 -1
  352. package/dist/sdk/cli-bootstrap.d.ts +5 -1
  353. package/dist/sdk/cli-bootstrap.js +1 -1
  354. package/dist/sdk/cli-contracts/agent-output-contracts.js +5 -3
  355. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
  356. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  357. package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -1
  358. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  359. package/dist/sdk/cli-contracts/commander-types.js +1 -1
  360. package/dist/sdk/cli-contracts/completeness.js +1 -1
  361. package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
  362. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  363. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +2 -1
  364. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  365. package/dist/sdk/cli-contracts/registration-helpers.js +7 -7
  366. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  367. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -1
  368. package/dist/sdk/cli-contracts/string-lists.js +1 -1
  369. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
  370. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  371. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  372. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  373. package/dist/sdk/cli-contracts/typed-action-inputs.js +1 -1
  374. package/dist/sdk/cli-contracts.js +1 -1
  375. package/dist/sdk/cli-program.js +1 -1
  376. package/dist/sdk/command-line.js +1 -1
  377. package/dist/sdk/comments.js +1 -1
  378. package/dist/sdk/compile-cache.js +1 -1
  379. package/dist/sdk/completion/bash.js +2 -1
  380. package/dist/sdk/completion/fish.js +13 -7
  381. package/dist/sdk/completion/shared.js +1 -1
  382. package/dist/sdk/completion/zsh.js +14 -8
  383. package/dist/sdk/completion.js +1 -1
  384. package/dist/sdk/compose.js +1 -1
  385. package/dist/sdk/config.js +1 -1
  386. package/dist/sdk/context/recency.js +1 -1
  387. package/dist/sdk/context/semantic-session-attribution.js +1 -1
  388. package/dist/sdk/context/usage-egress.js +1 -1
  389. package/dist/sdk/context/usage-ledger.js +6 -3
  390. package/dist/sdk/context-intent-contracts.js +1 -1
  391. package/dist/sdk/context-intent-runtime.js +1 -1
  392. package/dist/sdk/context-packing.js +1 -1
  393. package/dist/sdk/context-relevance.js +1 -1
  394. package/dist/sdk/context-signal-store.js +2 -2
  395. package/dist/sdk/context-usage.js +1 -1
  396. package/dist/sdk/contracts.js +1 -1
  397. package/dist/sdk/core-governance.js +1 -1
  398. package/dist/sdk/core.js +1 -1
  399. package/dist/sdk/corpus-shape.js +1 -1
  400. package/dist/sdk/define.js +1 -1
  401. package/dist/sdk/dependencies.js +1 -1
  402. package/dist/sdk/dependency-flag-validation.js +1 -1
  403. package/dist/sdk/dependency-provenance.js +1 -1
  404. package/dist/sdk/docs.js +1 -1
  405. package/dist/sdk/duplicates.js +1 -1
  406. package/dist/sdk/environment/agent-environment.js +1 -1
  407. package/dist/sdk/environment/host-environment-errors.js +1 -1
  408. package/dist/sdk/environment/project-runtime-compatibility.js +2 -1
  409. package/dist/sdk/environment/source-context.js +1 -1
  410. package/dist/sdk/environment/tracker-preflight.js +1 -1
  411. package/dist/sdk/error-code-catalog.js +1 -1
  412. package/dist/sdk/error-runtime.js +1 -1
  413. package/dist/sdk/errors.js +1 -1
  414. package/dist/sdk/eval.js +1 -1
  415. package/dist/sdk/extension/author-manifest.js +1 -1
  416. package/dist/sdk/extension/bundled-catalog.js +1 -1
  417. package/dist/sdk/extension/concurrency.js +1 -1
  418. package/dist/sdk/extension/copy-scope.js +1 -1
  419. package/dist/sdk/extension/custom-field-collisions.js +1 -1
  420. package/dist/sdk/extension/describe.js +4 -2
  421. package/dist/sdk/extension/doctor.js +1 -1
  422. package/dist/sdk/extension/install-plan.js +1 -1
  423. package/dist/sdk/extension/install-receipts.js +1 -1
  424. package/dist/sdk/extension/install-runtime.js +3 -3
  425. package/dist/sdk/extension/install-snapshot.js +1 -1
  426. package/dist/sdk/extension/install-sources.js +5 -5
  427. package/dist/sdk/extension/managed-state.d.ts +2 -0
  428. package/dist/sdk/extension/managed-state.js +2 -2
  429. package/dist/sdk/extension/managed-update-status.d.ts +3 -0
  430. package/dist/sdk/extension/managed-update-status.js +2 -0
  431. package/dist/sdk/extension/migrations.js +2 -2
  432. package/dist/sdk/extension/output-ownership.js +1 -1
  433. package/dist/sdk/extension/runtime-summary.js +1 -1
  434. package/dist/sdk/extension/scaffold.js +11 -4
  435. package/dist/sdk/extension/shared.js +1 -1
  436. package/dist/sdk/extension/source-resolution.d.ts +2 -6
  437. package/dist/sdk/extension/source-resolution.js +1 -1
  438. package/dist/sdk/extension/static-inventory.js +1 -1
  439. package/dist/sdk/extension/update-check.d.ts +10 -0
  440. package/dist/sdk/extension/update-check.js +1 -1
  441. package/dist/sdk/extension-command-context.js +2 -1
  442. package/dist/sdk/extension-contracts.js +1 -1
  443. package/dist/sdk/extension.d.ts +4 -0
  444. package/dist/sdk/extension.js +1 -1
  445. package/dist/sdk/files.js +1 -1
  446. package/dist/sdk/flag-invocation-contracts.js +1 -1
  447. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  448. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  449. package/dist/sdk/generated-error-code-catalog.js +1 -1
  450. package/dist/sdk/governance/assurance-action-contracts.js +1 -1
  451. package/dist/sdk/governance/assurance-action.js +1 -1
  452. package/dist/sdk/governance/assurance-limits.js +1 -1
  453. package/dist/sdk/governance/assurance-mutation-error.js +1 -1
  454. package/dist/sdk/governance/assurance-presets.js +1 -1
  455. package/dist/sdk/governance/assurance-runtime.js +1 -1
  456. package/dist/sdk/governance/assurance.js +4 -4
  457. package/dist/sdk/governance/boundary-fixtures.js +1 -1
  458. package/dist/sdk/governance/closure-timestamps.js +1 -1
  459. package/dist/sdk/governance/coverage-assurance.js +1 -1
  460. package/dist/sdk/governance/defect-recurrence-coverage.js +1 -1
  461. package/dist/sdk/governance/defect-recurrence-graph.js +1 -1
  462. package/dist/sdk/governance/defect-recurrence-signals.js +1 -1
  463. package/dist/sdk/governance/defect-recurrence.js +1 -1
  464. package/dist/sdk/governance/extension-host-version.js +1 -1
  465. package/dist/sdk/governance/gc.js +1 -1
  466. package/dist/sdk/governance/health-merge-evidence.js +1 -1
  467. package/dist/sdk/governance/health.js +2 -1
  468. package/dist/sdk/governance/hierarchy-validation.js +1 -1
  469. package/dist/sdk/governance/linked-file-report.js +1 -1
  470. package/dist/sdk/governance/merge-receipt-history.js +1 -1
  471. package/dist/sdk/governance/provenance-health.js +4 -1
  472. package/dist/sdk/governance/reindex.js +5 -4
  473. package/dist/sdk/governance/stale-work.js +1 -1
  474. package/dist/sdk/governance/status-role-diagnostics.js +1 -1
  475. package/dist/sdk/governance/storage-integrity.js +1 -1
  476. package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
  477. package/dist/sdk/governance/upgrade.js +2 -2
  478. package/dist/sdk/governance/validate-history-drift.js +1 -1
  479. package/dist/sdk/governance/validate-item-reader.js +1 -1
  480. package/dist/sdk/governance/validate-normalization.js +1 -1
  481. package/dist/sdk/governance/validate.js +1 -1
  482. package/dist/sdk/governance/workflow-completeness.js +1 -1
  483. package/dist/sdk/governance/workflow-policy.js +3 -3
  484. package/dist/sdk/governance/workspace-position.js +2 -1
  485. package/dist/sdk/governance.js +1 -1
  486. package/dist/sdk/graph/adapter.js +1 -1
  487. package/dist/sdk/graph/analytics.js +1 -1
  488. package/dist/sdk/graph/assembly.js +1 -1
  489. package/dist/sdk/graph/cache.js +1 -1
  490. package/dist/sdk/graph/centrality.js +1 -1
  491. package/dist/sdk/graph/conformance.js +1 -1
  492. package/dist/sdk/graph/deadline-scheduling.js +1 -1
  493. package/dist/sdk/graph/durable-cache.js +1 -1
  494. package/dist/sdk/graph/governance-contracts.js +1 -1
  495. package/dist/sdk/graph/governance.js +1 -1
  496. package/dist/sdk/graph/hierarchy-integrity.js +1 -1
  497. package/dist/sdk/graph/index.js +1 -1
  498. package/dist/sdk/graph/lifecycle-coverage.js +1 -1
  499. package/dist/sdk/graph/mutation-advisory.js +1 -1
  500. package/dist/sdk/graph/query-contracts.js +1 -1
  501. package/dist/sdk/graph/remediation.js +1 -1
  502. package/dist/sdk/graph/run.js +1 -1
  503. package/dist/sdk/graph/scheduling.js +1 -1
  504. package/dist/sdk/graph/traversal.js +1 -1
  505. package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -1
  506. package/dist/sdk/graph.js +1 -1
  507. package/dist/sdk/guide-topics.js +1 -1
  508. package/dist/sdk/guide.js +8 -1
  509. package/dist/sdk/history/attestation-command.js +1 -1
  510. package/dist/sdk/history/attestation-contract.js +1 -1
  511. package/dist/sdk/history/attestation-scan.js +1 -1
  512. package/dist/sdk/history/attestation.js +1 -1
  513. package/dist/sdk/history/maintenance.js +1 -1
  514. package/dist/sdk/history/salvage.js +3 -2
  515. package/dist/sdk/history/subject.js +1 -1
  516. package/dist/sdk/history-analytics.js +1 -1
  517. package/dist/sdk/history-compact.js +1 -1
  518. package/dist/sdk/history-mcp.js +1 -1
  519. package/dist/sdk/history-provenance.js +1 -1
  520. package/dist/sdk/history-read.js +1 -1
  521. package/dist/sdk/history-redact.js +1 -1
  522. package/dist/sdk/history-repair.js +1 -1
  523. package/dist/sdk/improvement-ledger-validation.js +1 -1
  524. package/dist/sdk/improvement-ledger.js +2 -2
  525. package/dist/sdk/index.js +1 -1
  526. package/dist/sdk/init-agent-guidance.js +16 -2
  527. package/dist/sdk/init.js +16 -2
  528. package/dist/sdk/invocation-author.js +1 -1
  529. package/dist/sdk/item-children.js +1 -1
  530. package/dist/sdk/item-metadata-index.js +1 -1
  531. package/dist/sdk/item-schedule.js +1 -1
  532. package/dist/sdk/item-transaction.js +1 -1
  533. package/dist/sdk/learnings.js +1 -1
  534. package/dist/sdk/lifecycle/append.js +4 -2
  535. package/dist/sdk/lifecycle/claim.js +1 -1
  536. package/dist/sdk/lifecycle/close-many.js +1 -1
  537. package/dist/sdk/lifecycle/close.js +1 -1
  538. package/dist/sdk/lifecycle/copy.js +1 -1
  539. package/dist/sdk/lifecycle/create.js +1 -1
  540. package/dist/sdk/lifecycle/delete.js +1 -1
  541. package/dist/sdk/lifecycle/event-validation-messages.js +1 -1
  542. package/dist/sdk/lifecycle/focus.js +1 -1
  543. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
  544. package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -1
  545. package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
  546. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  547. package/dist/sdk/lifecycle/metadata-normalizers.js +1 -1
  548. package/dist/sdk/lifecycle/mutation-command-options.js +1 -1
  549. package/dist/sdk/lifecycle/plan-mutation-receipt.js +1 -1
  550. package/dist/sdk/lifecycle/plan.js +1 -1
  551. package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
  552. package/dist/sdk/lifecycle/reopen.js +1 -1
  553. package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +2 -1
  554. package/dist/sdk/lifecycle/restore.js +1 -1
  555. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
  556. package/dist/sdk/lifecycle/task-composition.js +1 -1
  557. package/dist/sdk/lifecycle/update-many.js +1 -1
  558. package/dist/sdk/lifecycle/update.js +2 -1
  559. package/dist/sdk/lifecycle-completion.js +1 -1
  560. package/dist/sdk/lifecycle-policy.js +1 -1
  561. package/dist/sdk/linked-artifacts.js +2 -1
  562. package/dist/sdk/mcp/apps.js +1 -1
  563. package/dist/sdk/mcp/authorization.js +1 -1
  564. package/dist/sdk/mcp/discovery.js +1 -1
  565. package/dist/sdk/mcp/interactions.js +1 -1
  566. package/dist/sdk/mcp/protocol.js +1 -1
  567. package/dist/sdk/mcp/skills.js +3 -1
  568. package/dist/sdk/mcp/subscriptions.js +1 -1
  569. package/dist/sdk/mcp/tasks.js +2 -2
  570. package/dist/sdk/mcp/transport.js +1 -1
  571. package/dist/sdk/merge/abandoned-receipts.js +1 -1
  572. package/dist/sdk/merge/driver.js +1 -1
  573. package/dist/sdk/merge/index.js +1 -1
  574. package/dist/sdk/merge/install.js +4 -2
  575. package/dist/sdk/merge/receipt-file-boundary.js +1 -1
  576. package/dist/sdk/merge/receipt-operation.js +1 -1
  577. package/dist/sdk/merge/receipt-schema.js +1 -1
  578. package/dist/sdk/merge/receipts.js +4 -4
  579. package/dist/sdk/merge/reconcile.js +1 -1
  580. package/dist/sdk/merge/three-way.js +3 -2
  581. package/dist/sdk/merge/worktree-config.js +1 -1
  582. package/dist/sdk/merge.js +1 -1
  583. package/dist/sdk/mutation-events.js +1 -1
  584. package/dist/sdk/mutation-guard.js +1 -1
  585. package/dist/sdk/notes.js +1 -1
  586. package/dist/sdk/output-contracts.js +1 -1
  587. package/dist/sdk/output-projection.js +1 -1
  588. package/dist/sdk/output-token-accounting.js +1 -1
  589. package/dist/sdk/output.js +2 -1
  590. package/dist/sdk/ownership-source.js +1 -1
  591. package/dist/sdk/package-import-adapters.js +1 -1
  592. package/dist/sdk/package-migrations.js +1 -1
  593. package/dist/sdk/package-runtime-options.js +1 -1
  594. package/dist/sdk/pagination.js +1 -1
  595. package/dist/sdk/profile.js +5 -1
  596. package/dist/sdk/provenance.js +1 -1
  597. package/dist/sdk/public-surface.json +1 -1
  598. package/dist/sdk/query/activity.js +1 -1
  599. package/dist/sdk/query/aggregate.js +1 -1
  600. package/dist/sdk/query/calendar.js +4 -1
  601. package/dist/sdk/query/complete-list.js +1 -1
  602. package/dist/sdk/query/context.js +2 -1
  603. package/dist/sdk/query/duplicate-candidates.js +1 -1
  604. package/dist/sdk/query/get.d.ts +14 -2
  605. package/dist/sdk/query/get.js +1 -1
  606. package/dist/sdk/query/history.js +1 -1
  607. package/dist/sdk/query/item-filter-options.js +1 -1
  608. package/dist/sdk/query/light-metadata.js +1 -1
  609. package/dist/sdk/query/list-filter-shared.js +1 -1
  610. package/dist/sdk/query/list.js +1 -1
  611. package/dist/sdk/query/multi-value-filters.js +1 -1
  612. package/dist/sdk/query/next-ready-budget.js +1 -1
  613. package/dist/sdk/query/next.js +2 -1
  614. package/dist/sdk/query/parsers.js +1 -1
  615. package/dist/sdk/query/projection-contracts.js +1 -1
  616. package/dist/sdk/query/search/corpus.js +2 -1
  617. package/dist/sdk/query/search/filters.js +1 -1
  618. package/dist/sdk/query/search/input.js +1 -1
  619. package/dist/sdk/query/search/lexical.js +1 -1
  620. package/dist/sdk/query/search/response.js +1 -1
  621. package/dist/sdk/query/search/semantic.js +3 -2
  622. package/dist/sdk/query/search/types.js +1 -1
  623. package/dist/sdk/query/search-contracts.js +1 -1
  624. package/dist/sdk/query/search-pagination.js +1 -1
  625. package/dist/sdk/query/search-rendering.js +1 -1
  626. package/dist/sdk/query/search.js +1 -1
  627. package/dist/sdk/query/workspace-contracts.js +1 -1
  628. package/dist/sdk/query.js +1 -1
  629. package/dist/sdk/read-output/continuation.js +1 -1
  630. package/dist/sdk/read-output/options.js +1 -1
  631. package/dist/sdk/read-output/provenance.js +1 -1
  632. package/dist/sdk/read-output-budget.js +1 -1
  633. package/dist/sdk/read-output-contracts.js +1 -1
  634. package/dist/sdk/read-output-rows.js +1 -1
  635. package/dist/sdk/read-output-session.js +1 -1
  636. package/dist/sdk/relationship-analytics.js +1 -1
  637. package/dist/sdk/relationship-context.js +1 -1
  638. package/dist/sdk/relationship-history.js +7 -4
  639. package/dist/sdk/relationship-kinds/contract.js +1 -1
  640. package/dist/sdk/relationship-migration.js +1 -1
  641. package/dist/sdk/relationships.js +1 -1
  642. package/dist/sdk/reproducibility/process.js +1 -1
  643. package/dist/sdk/runtime/actions.js +1 -1
  644. package/dist/sdk/runtime/context.js +1 -1
  645. package/dist/sdk/runtime/schema-preview.js +1 -1
  646. package/dist/sdk/runtime/schema.js +1 -1
  647. package/dist/sdk/runtime-action-aliases.js +1 -1
  648. package/dist/sdk/runtime-extended-actions.js +1 -1
  649. package/dist/sdk/runtime-input.js +1 -1
  650. package/dist/sdk/runtime-primitives.js +1 -1
  651. package/dist/sdk/runtime-public-contracts.js +1 -1
  652. package/dist/sdk/runtime-stats-options.js +1 -1
  653. package/dist/sdk/runtime.js +1 -1
  654. package/dist/sdk/scheduling-shortcuts.js +1 -1
  655. package/dist/sdk/schema-migration.js +4 -3
  656. package/dist/sdk/schema.js +7 -1
  657. package/dist/sdk/search-refresh-worker.js +1 -1
  658. package/dist/sdk/similarity-scoring.js +1 -1
  659. package/dist/sdk/similarity.js +1 -1
  660. package/dist/sdk/start-task-status.js +1 -1
  661. package/dist/sdk/stats.js +1 -1
  662. package/dist/sdk/structured-mutations.js +1 -1
  663. package/dist/sdk/telemetry-flush.js +1 -1
  664. package/dist/sdk/telemetry.js +4 -3
  665. package/dist/sdk/templates.js +26 -2
  666. package/dist/sdk/test/batch.js +2 -2
  667. package/dist/sdk/test/entry.js +1 -1
  668. package/dist/sdk/test/execution.d.ts +2 -1
  669. package/dist/sdk/test/execution.js +6 -5
  670. package/dist/sdk/test/json-path.js +1 -1
  671. package/dist/sdk/test/linked-command-detection.js +1 -1
  672. package/dist/sdk/test/measurements.js +1 -1
  673. package/dist/sdk/test/parsers.js +1 -1
  674. package/dist/sdk/test/runs.js +1 -1
  675. package/dist/sdk/test/trust.js +2 -2
  676. package/dist/sdk/test/workspace-snapshot.js +1 -1
  677. package/dist/sdk/testing.js +7 -4
  678. package/dist/sdk/traceability/runtime-files-lookup.js +1 -1
  679. package/dist/sdk/traceability/source-traceability.js +2 -1
  680. package/dist/sdk/tracker-root-discovery.js +1 -1
  681. package/dist/sdk/workspace-contracts-cache.js +1 -1
  682. package/dist/sdk/workspace-contracts.js +1 -1
  683. package/dist/sdk/workspace-memory.js +2 -2
  684. package/dist/sdk/workspace-recipe.js +1 -1
  685. package/dist/sdk/workspace-snapshot.js +5 -4
  686. package/dist/sdk/workspace-transaction-gc.js +1 -1
  687. package/dist/sdk/workspace-transaction.js +2 -2
  688. package/dist/sdk/workspace.js +3 -2
  689. package/dist/types/index.js +1 -1
  690. package/dist/types.js +1 -1
  691. package/docs/AGENT_EVIDENCE_CONSISTENCY.md +88 -0
  692. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +36 -0
  693. package/docs/GET_READ_EVIDENCE.md +84 -0
  694. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +23 -0
  695. package/docs/PR_REVIEW_LOOP.md +21 -4
  696. package/docs/README.md +3 -0
  697. package/docs/RELEASING.md +18 -0
  698. package/docs/SDK_CONFIGURATION_SAFETY.md +123 -0
  699. package/docs/generated/FLAG_LEXICON_BUDGETS.md +3 -3
  700. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
  701. package/marketplace.json +2 -2
  702. package/package.json +3 -3
  703. package/packages/pm-beads/package.json +1 -1
  704. package/packages/pm-calendar/package.json +1 -1
  705. package/packages/pm-command-kit/package.json +1 -1
  706. package/packages/pm-digital-twin/package.json +1 -1
  707. package/packages/pm-governance-audit/package.json +1 -1
  708. package/packages/pm-guide-shell/package.json +1 -1
  709. package/packages/pm-kanban/package.json +1 -1
  710. package/packages/pm-lifecycle-hooks/package.json +1 -1
  711. package/packages/pm-linked-test-adapters/package.json +1 -1
  712. package/packages/pm-search-advanced/package.json +1 -1
  713. package/packages/pm-templates/package.json +1 -1
  714. package/packages/pm-todos/package.json +1 -1
  715. package/packages/pm-vcs/extensions/vcs/index.ts +4 -2
  716. package/packages/pm-vcs/package.json +1 -1
  717. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  718. package/plugins/pm-claude/package.json +2 -2
  719. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  720. package/plugins/pm-codex/package.json +2 -2
  721. package/plugins/pm-codex/plugin.json +1 -1
  722. package/scripts/finalize-build.mjs +3 -2
  723. package/dist/cli-bundle/chunks/chunk-7UVXKI7K.js +0 -2
  724. package/dist/cli-bundle/chunks/chunk-D7Z2ZMJL.js +0 -3
  725. package/dist/cli-bundle/chunks/chunk-DEZPZOQ7.js +0 -2
  726. package/dist/cli-bundle/chunks/chunk-J52QIRRZ.js +0 -80
  727. package/dist/cli-bundle/chunks/chunk-JDKD3WGG.js +0 -6
  728. package/dist/cli-bundle/chunks/chunk-JQ7DW663.js +0 -2
  729. package/dist/cli-bundle/chunks/chunk-QXIDOOWT.js +0 -20
  730. package/dist/cli-bundle/chunks/chunk-SGFQQXFD.js +0 -2
  731. package/dist/cli-bundle/chunks/chunk-V3U77H3V.js +0 -31
  732. package/dist/cli-bundle/chunks/chunk-XZDWAYJC.js +0 -3
  733. package/dist/cli-bundle/chunks/chunk-Y6VRBTP3.js +0 -238
  734. package/dist/cli-bundle/chunks/chunk-YAAFYFS4.js +0 -8
  735. package/dist/cli-bundle/chunks/register-mutation-53ZLT4RX.js +0 -20
  736. package/dist/cli-bundle/chunks/register-operations-OBK2FXUU.js +0 -2
  737. package/dist/cli-bundle/chunks/register-setup-HM3OCBH2.js +0 -2
  738. package/dist/cli-bundle/focused-chunks/chunk-2JFYR56O.js +0 -2
  739. package/dist/cli-bundle/focused-chunks/chunk-32EVUSS4.js +0 -8
  740. package/dist/cli-bundle/focused-chunks/chunk-5GUSO2P4.js +0 -20
  741. package/dist/cli-bundle/focused-chunks/chunk-6XBRADQQ.js +0 -3
  742. package/dist/cli-bundle/focused-chunks/chunk-7O4NUJVO.js +0 -2
  743. package/dist/cli-bundle/focused-chunks/chunk-CURTIIQT.js +0 -2
  744. package/dist/cli-bundle/focused-chunks/chunk-IJUWEEEB.js +0 -6
  745. package/dist/cli-bundle/focused-chunks/chunk-JCVMOSWQ.js +0 -2
  746. package/dist/cli-bundle/focused-chunks/chunk-JMJK2L4Z.js +0 -3
  747. package/dist/cli-bundle/focused-chunks/chunk-KG3H4UZZ.js +0 -30
  748. package/dist/cli-bundle/focused-chunks/chunk-MHQ2XICU.js +0 -2
  749. package/dist/cli-bundle/focused-chunks/chunk-RJV6QVJE.js +0 -75
  750. package/dist/cli-bundle/focused-chunks/chunk-ZE2JZ7R6.js +0 -12
  751. package/dist/cli-bundle/focused-chunks/chunk-ZLEN4HZD.js +0 -165
@@ -1,30 +0,0 @@
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]="dfa7c914-c0f4-5ce5-ae6e-2078a0c08701")}catch{}})();var V=["commands","renderers","hooks","schema","importers","search","parser","preflight","services"],pt=2,un=Object.freeze({migration:"schema",validation:"schema"}),x_=Object.freeze({version:pt,capabilities:[...V],legacy_aliases:{...un}}),_t=["off","warn","enforce"],gt=["off","warn","enforce"],yt=["none","restricted","strict"],Br=["block","warn"],ht=["commands.override","commands.handler","hooks.beforecommand","hooks.beforemutation","hooks.aftercommand","hooks.onwrite","hooks.onread","hooks.onindex","schema.flags","schema.itemfields","schema.itemtypes","schema.relationshipkinds","schema.migrations","schema.profiles","parser.override","preflight.override","services.override","renderers.override","importers.importer","importers.exporter","search.provider","search.vectorstore","services.assuranceprovider"],Ae=["output_format","error_format","help_format","lock_acquire","lock_release","history_append","item_store_write","item_store_delete","context_relevance","command_result"];function bt(){return{mode:"off",trust_mode:"off",require_provenance:!1,trusted_extensions:[],default_sandbox_profile:"none",allowed_extensions:[],blocked_extensions:[],allowed_capabilities:[],blocked_capabilities:[],allowed_surfaces:[],blocked_surfaces:[],allowed_commands:[],blocked_commands:[],allowed_actions:[],blocked_actions:[],allowed_services:[],blocked_services:[],extension_overrides:[]}}(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]="e33ee377-aae0-5158-9af6-e6081287a85b")}catch{}})();var Ba=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],Vr=Ba,D_=["draft","open","in_progress","blocked","closed","canceled"],P_=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],Gr=["string","number","boolean","string_array","array","object"],M_=["create","update","update_many","list","search","calendar","context"],$_=["allow","warn","reject"],L_=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],j_=["project","global"],F_=["low","medium","high","critical"],U_=["low","medium","high","critical"],z_=["low","medium","high"];var q_=["minimal","default","strict","custom"],B_=["none","warn","strict"],V_=["progressive","strict"],G_=["off","warn","strict"],W_=["off","warn","strict"];var K_=["daily","weekly","monthly","yearly"],Va=["mon","tue","wed","thu","fri","sat","sun"];function H_(e){return Va.indexOf(e)}var Y_=["draft","research","review","approved","executing","paused","completed","superseded"],X_=["pending","in_progress","completed","blocked","skipped","superseded"],J_=["codex","claude-code","cursor","generic"],Q_=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],Z_=["brief","standard","deep","full"],eg=["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]="89d6c349-10d7-596d-90a1-65afcc65eb91")}catch{}})();var Wr=["goal","objective","value","impact","outcome","why_now","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","unblock_note","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result"],Ga=["id","title","description","type","pm_format_version","source_type","type_options","status","priority","tags","created_at","updated_at","deadline","reminders","events","closed_at","completed_at","assignee","claim_principal","source_owner","author","estimated_minutes","acceptance_criteria","design","external_ref","definition_of_ready","order",...Wr,"affected_version","fixed_version","component","regression","customer_impact","dependencies","comments","notes","learnings","files","tests","test_runs","docs","close_reason","duplicate_of","plan_mode","plan_scope","plan_harness","plan_resume_context","plan_validation","plan_decisions","plan_discoveries","plan_steps"],Wa=Ga;(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]="6e329ab1-f22d-5749-b8a4-0a6e7a1c8023")}catch{}})();var Ka=Object.freeze([{id:"draft",roles:["draft"]},{id:"open",roles:["active","default_open"]},{id:"in_progress",aliases:["in-progress"],roles:["active"]},{id:"blocked",roles:["blocked"]},{id:"closed",roles:["terminal","terminal_done","default_close"]},{id:"canceled",aliases:["cancelled"],roles:["terminal","terminal_canceled","default_cancel"]}]),Ha=Object.freeze({draft_status:"draft",open_status:"open",in_progress_status:"in_progress",blocked_status:"blocked",close_status:"closed",canceled_status:"canceled"}),wt=".agents/pm",vt="settings.json";var Ya=["","epics","features","tasks","chores","issues","schema","history","search","extensions","locks"],Xa=["decisions","events","reminders","milestones","meetings","plans"],ig=[...Ya,...Xa],Ue={Epic:"epics",Feature:"features",Task:"tasks",Chore:"chores",Issue:"issues",Decision:"decisions",Event:"events",Reminder:"reminders",Milestone:"milestones",Meeting:"meetings",Plan:"plans"},Ja={minimal:{ownership_enforcement:"none",create_mode_default:"progressive",close_validation_default:"off",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!1,duplicate_detection_mode:"off",duplicate_detection_threshold:.8,duplicate_detection_limit:3},default:{ownership_enforcement:"warn",create_mode_default:"progressive",close_validation_default:"warn",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3},strict:{ownership_enforcement:"strict",create_mode_default:"strict",close_validation_default:"strict",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"strict",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3}},Qa=["no active blocker","ready for planned execution sequencing","work completed","work is closed"],fn={blocked_reason:["no active blocker because work is closed","work is closed"],resolution:["closed with implementation evidence","closed with verification evidence","work completed and recorded","work is closed"],actual_result:["closed and recorded","work completed","work completed and recorded"]};function Kr(e){return e?[...e]:void 0}var sg={version:1,id_prefix:"pm-",ids:{token_length:4},author_default:"",agent_identity:{probes_enabled:!0,identity_vocabulary:{version:1,aliases:{}},harness_signals:[]},mutation_guard:{require_attributed_author:!1,secret_guard:"advise",stale_in_progress_hours:72},item_format:"toon",locks:{ttl_seconds:1800,wait_ms:3e3},checkpoints:{retention_days:14},output:{default_format:"toon"},ux:{deprecation_hints:!0},history:{missing_stream:"auto_create",compact_policy:{enabled:!1,max_entries:500,trigger:"health_warn"}},validation:{sprint_release_format:"warn",parent_reference:"warn",metadata_profile:"core",metadata_required_fields:[],lifecycle_stale_blocker_reason_patterns:[...Qa],lifecycle_closure_like_blocked_reason_patterns:[...fn.blocked_reason],lifecycle_closure_like_resolution_patterns:[...fn.resolution],lifecycle_closure_like_actual_result_patterns:[...fn.actual_result],estimate_defaults_by_type:{}},governance:{preset:"minimal",...Ja.minimal},workflow:{definition_of_done:[]},testing:{record_results_to_items:!1,allow_untrusted_linked_tests:!1},telemetry:{enabled:!0,first_run_prompt_completed:!1,capture_level:"redacted",endpoint:"https://pm-cli.unbrained.dev/v1/events",installation_id:"",retention_days:365},agent_guidance:{prompt_completed:!1,declined:!1,declined_at:"",template_version:1,last_checked_files:[]},item_types:{definitions:[]},schema:{version:1,files:{types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"},statuses:Ka.map(e=>({...e,aliases:Kr(e.aliases),roles:Kr(e.roles)})),fields:[],workflow:{...Ha},unknown_field_policy:"allow"},extensions:{enabled:[],disabled:[],policy:bt()},search:{score_threshold:0,hybrid_semantic_weight:.7,max_results:50,embedding_model:"",embedding_batch_size:32,embedding_timeout_ms:3e4,scanner_max_batch_retries:3,provider:"",default_mode:"auto",mutation_refresh_policy:"semantic_configured",query_expansion:{enabled:!1,provider:""},rerank:{enabled:!1,model:"",top_k:20}},providers:{openai:{base_url:"",api_key:"",model:""},ollama:{base_url:"",model:""}},context:{default_depth:"brief",activity_limit:10,stale_threshold_days:7,sections:{hierarchy:!0,activity:!0,progress:!0,recently_created:!0,unparented:!0,blockers:!0,files:!0,workload:!0,staleness:!0,tests:!0}},vector_store:{adapter:"",collection_name:"pm_items",qdrant:{url:"",api_key:""},lancedb:{path:""}}},ag={metadata:{},body:""},y={SUCCESS:0,GENERIC_FAILURE:1,USAGE:2,NOT_FOUND:3,CONFLICT:4,DEPENDENCY_FAILED:5,NO_EFFECT:6,PARTIAL_EFFECT:7},cg=Object.freeze({unknown_command:"usage",unknown_option:"usage",missing_required_option:"usage",missing_required_argument:"usage",invalid_command_usage:"usage",linked_test_value_not_quoted:"usage",invalid_argument_value:"validation",health_findings:"validation",validation_findings:"validation",close_through_update:"validation",no_update_fields:"validation",unsupported_update_option:"validation",tracker_not_initialized:"validation",item_not_found:"validation",ownership_conflict:"conflict",lock_conflict:"conflict",terminal_state_conflict:"conflict",dependency_failed:"runtime",init_gitignore_unwritable:"runtime",merge_git_config_unwritable:"runtime",command_failed:"runtime",unknown_error:"runtime"});(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]="8f35f236-50cd-5a76-9633-33f836694a5e")}catch{}})();var h=class extends Error{exitCode;code;context;constructor(t,n,r={}){super(t),this.name="PmCliError",this.exitCode=n,this.context=r,this.code=r.code}};(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]="9961b408-ad70-5556-84dd-5ca1b1497c27")}catch{}})();var Za=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 ec(e){return{unknownKeys:Object.keys(e).filter(t=>!Za.has(t)).sort((t,n)=>t>n?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function tc(e){let t=ec(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 Hr(e,t,n){return tc(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`)}(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]="4c00e38a-27df-5315-91e8-d35c03ed6bf3")}catch{}})();var mn=[{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]="b658dc99-fdbb-5d10-9dd6-5f5c263bf48b")}catch{}})();function Ot(e){return e.trim().toLowerCase().replaceAll("-","_")}function nc(e){if(e===void 0)return;let t=Ot(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function _n(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)_n(n,t);return Object.freeze(e)}for(let n of Object.values(e))_n(n,t);return Object.freeze(e)}function rc(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 oc(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 ic(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 sc(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=Ot(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 ac(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 cc(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 lc(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var gn=class{#e=new Map;#n=new Map;constructor(t=mn){for(let n of t)this.register(n)}register(t){let n=sc(t);if(ac(t,n),cc(t,n),rc(t,n),oc(t,n),ic(t,n),this.#e.has(n)||this.#n.has(n))throw new TypeError(`Relationship kind already registered: ${n}`);let r=nc(t.inverse),o=[...new Set((t.aliases??[]).map(Ot))].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:lc(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:r,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?_n(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=Ot(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 yn(){return new gn}var le=yn();function _g(e){return le.require(e).kind}function gg(e){return le.resolve(e)?.kind}function yg(e,t=le){return t.resolve(e)?.ordering===!0}function dc(e,t,n,r=le){let o=ze(e),i=ze(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 Et(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function uc(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=dc(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 kt(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function ze(e){return typeof e=="string"?e.trim():""}function pn(e,t){let n=ze(e);return n&&t.has(n)?n:void 0}function fc(e,t,n){let r=[t],o=t;for(;o!==e;)o=n.get(o),r.push(o);return r.reverse()}var Yr=class e{#e;#n;#o;#r;#s=new Map;#a=new Map;constructor(t,n,r=le){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}=uc(i,this.#n,r);o.set(a,s)}this.#r=Object.freeze([...o.values()].sort(Et));for(let i of this.#r)kt(this.#s,i.source,i),kt(this.#a,i.target,i),r.require(i.kind).direction==="undirected"&&(kt(this.#s,i.target,i),kt(this.#a,i.source,i))}static fromItems(t,n=le){let r=new Set(t.map(i=>ze(i.id)).filter(Boolean)),o=[];for(let i of t){let s=ze(i.id);if(!s)continue;let a=pn(i.parent,r);a&&o.push({source:s,target:a,kind:"parent"});let c=pn(i.blocked_by,r);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let l of i.dependencies??[]){let d=pn(l.id,r);d&&n.resolve(l.kind)&&o.push({source:s,target:d,kind:l.kind,createdAt:l.created_at,author:l.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],l=a===void 0?c:c===void 0||Et(a,c)<=0?a:c;o.at(-1)!==l&&o.push(l),a===l&&(i+=1),c===l&&(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)||Et(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(f=>this.#e.require(f).kind)):void 0,o=n.direction??"outgoing",i=n.limit??Number.POSITIVE_INFINITY,s=n.maxDepth??Number.POSITIVE_INFINITY,a=new Set([t]),c=[],l=[{id:t,depth:0}],d=0,u=0,m=!1;e:for(let f=0;f<l.length;f+=1){n.signal?.throwIfAborted();let p=l[f];d+=1;let _=this.#t(p.id,o,r);if(u+=_.length,p.depth>=s){_.some(g=>!a.has(g.id))&&(m=!0);continue}for(let g of _)if(!a.has(g.id)){if(c.length>=i){m=!0;break e}a.add(g.id),c.push(g.id),l.push({id:g.id,depth:p.depth+1})}}return{value:c,meta:{visitedNodes:d,inspectedEdges:u,truncated:m,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(f=>this.#e.require(f).kind)):void 0,i=r.direction??"outgoing",s=r.maxDepth??Number.POSITIVE_INFINITY,a=[{id:t,depth:0}],c=new Map,l=new Set([t]),d=0,u=0,m=!1;for(let f=0;f<a.length;f+=1){r.signal?.throwIfAborted();let p=a[f];d+=1;let _=this.#t(p.id,i,o);if(u+=_.length,p.depth>=s){_.some(g=>!l.has(g.id))&&(m=!0);continue}for(let g of _)if(!l.has(g.id)){if(c.set(g.id,p.id),g.id===n)return{value:fc(t,n,c),meta:{visitedNodes:d,inspectedEdges:u,truncated:!1}};l.add(g.id),a.push({id:g.id,depth:p.depth+1})}}return{value:[],meta:{visitedNodes:d,inspectedEdges:u,truncated:m}}}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 l of this.#s.get(c)??[])i.has(l.source)&&i.has(l.target)&&this.#c(l,s)&&a.add(l);return{value:{nodes:o,edges:[...a].sort(Et)},meta:r.meta}}};function hg(e,t,n=le){return{source:e,target:t.id,kind:n.require(t.kind).kind,createdAt:t.created_at,author:t.author}}(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]="720821b8-d18d-5a10-a8b9-f16073dc1fc4")}catch{}})();function O(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function mc(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function Xr(e){return e?M(e):{}}function Jr(e){return e?M(e):mc()}function M(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]="7d96fda0-1f2f-5e34-99da-c3c5ad0f53f6")}catch{}})();var pc=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),_c=["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 gc(e,t){for(let n of _c){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=>pc.has(n)?O(i):i.trim()).filter(i=>i.length>0);t[n]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function yc(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=>O(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:r.result_discriminator})}return t.sort((n,r)=>n.format.localeCompare(r.format))}function hc(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=>O(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return t}function At(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(!gc(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=yc(o);if(s===null)return null;n.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=hc(i);if(s===null)return null;n.preflight_ownership=s}return n}function Eg(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]="dd0b1f79-0f4c-5042-8915-23adfc1f3b8d")}catch{}})();var bc=[["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"})),wc=[...["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"})),vc=[["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"})),Ec=[...wc,...vc,...["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}))],hn=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...bc,...Ec,...["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 Og(e){let t;for(let n of hn)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 kc(e){let t=e.trim().replace(/\s+/gu," ");return hn.find(n=>n.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function qe(e){return kc(e)}var St=[...hn,...[["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"}))],Ag=Object.fromEntries(St.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function Sg(e){let t=e.trim().toLowerCase();return St.find(n=>n.alias===t)}function Tg(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]="bfaa3455-3237-5c98-8ef4-b353ce9530fe")}catch{}})();var Ig=Object.freeze({rows:10,paths:5,samples:10,path_depth:8,visited_paths:1e4});import{createHash as eo}from"node:crypto";import Oc 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]="c036d6cf-6a10-5c74-9e2f-e7c953339e2c")}catch{}})();function Ac(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 Sc(e){let t=Object.keys(e).sort(),n={};for(let r of t){let o=e[r];o!==void 0&&(n[r]=Tt(o))}return n}function Tt(e){let t=Ac(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(r=>Tt(r));if(e instanceof Date)return e.toISOString();let n=e;if(typeof n.toJSON=="function"){let r=n.toJSON();if(r!==e)return Tt(r)}return Sc(e)}function de(e){return JSON.stringify(Tt(e))}function Qr(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 Tc(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function Cc(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function Ic(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(!Qr(o,n,r,G))return!1;return!0}function Rc(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(!Qr([o,i],n,r,([a,c],[l,d])=>G(a,l)&&G(c,d)))return!1;return!0}function xc(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)=>G(n,t[r]))}function Nc(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]||!G(e[i],t[i]))return!1}return!0}var Dc=[Tc,Cc,Ic,Rc,xc];function G(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 Dc){let r=n(e,t);if(r!==void 0)return r}return Nc(e,t)}function Ng(e){return Oc.createHash("sha256").update(e,"utf8").digest("hex")}function Dg(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}(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]="8b0d8654-211b-57bf-852f-8a153849e8fd")}catch{}})();var Pc=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],Zr=256,bn=64;function F(e){throw new h(`Invalid workflow policy: ${e}`,y.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function K(e,t,n){if(typeof e!="object"||e===null||Array.isArray(e))return F(`${n} must be an object`);let r=e;return Object.keys(r).some(o=>!t.includes(o))?F(`${n} contains an unknown key`):r}function ue(e,t,n=128){return typeof e!="string"||!e.trim()||e.length>n?F(`${t} must be nonempty text of at most ${n} characters`):e.trim()}function Be(e,t){if(!Array.isArray(e)||e.length===0||e.length>bn)return F(`${t} requires 1-${bn} terms`);let n=e.map(r=>ue(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)))?F("fields must be safe metadata paths of at most eight segments"):[...new Set(n)]}function Mc(e){let t=K(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(K(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>bn?F("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(n=>!Array.isArray(n)||n.length!==2?F("transition pairs need two statuses"):[ue(n[0],"from"),ue(n[1],"to")])}):t.kind==="authors"?(K(t,["kind","authors"],"authors rule"),{kind:"authors",authors:Be(t.authors,"authors")}):t.kind==="require_fields"?(K(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:Be(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(K(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:Be(t.fields,"fields"),authors:Be(t.authors,"authors")}):F("unknown rule kind")}function $c(e){let t={},n=K(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let r of["types","tags","statuses","operations","parents"])n[r]!==void 0&&(t[r]=Be(n[r],r));if(n.dependency!==void 0){let r=K(n.dependency,["kind","id"],"dependency");t.dependency={kind:ue(r.kind,"dependency kind"),...r.id===void 0?{}:{id:ue(r.id,"dependency id")}}}return t}function Lc(e){let t=K(e,["id","description","subject","effect","rule"],"policy"),n=ue(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))?F("effect must be advise, warn, or refuse"):{id:n,rule:Mc(t.rule),...t.subject===void 0?{}:{subject:$c(t.subject)},...t.description===void 0?{}:{description:ue(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:F("id must be a stable token")}function jc(e){let t=K(e,["version","enforcement","policies"],"document");if(t.version!==1)return F("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return F("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>Zr)return F(`policies must contain at most ${Zr} declarations`);let n=t.policies.map(Lc);return new Set(n.map(r=>r.id)).size!==n.length?F("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:n}}function Ct(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 Fc(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 to(e){return eo("sha256").update(de(e)).digest("hex")}function Uc(e,t){let n=e.rule.kind==="approval"?e.rule.fields:[];return eo("sha256").update(de({id:t.id,fields:n.map(r=>[r,Ct(t,r)])})).digest("hex")}function zc(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 qc(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&&!zc(e.dependency,t.dependencies))}function Bc(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&&qc(n,{...o,status:r},t.operation))}function Vc(e,t,n,r){let o=["type","tags","parent","dependencies"].some(s=>!G(t.before?.[s],t.after?.[s]));return t.after&&(t.completeness_only||n||r||o)?e.filter(s=>!Fc(Ct(t.after,s))):[]}function Gc(e,t,n,r){let o=t.after??t.before,i=Uc(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 Wc(e,t,n){let r=e.rule,o=t.before?.status!==t.after?.status,i="fields"in r&&r.fields.some(s=>!G(Ct(t.before,s),Ct(t.after,s)));switch(r.kind){case"require_fields":{let s=Vc(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||Gc(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 no(e,t,n){let r=e.policies.filter(o=>Bc(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,...Wc(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 Fg(e,t){return no(e,t,to)}function Ug(e){let t=jc(e),n=new Map(t.policies.map(r=>[r,to(r)]));return r=>no(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]="1dd71b26-fc38-5304-9156-f32b57cc1cc0")}catch{}})();var Kc=[...V],Hc=[...Ae],Yc=[..._t],Gg=[...gt],Wg=[...yt],Xc=[...ht],It=["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"],Kg=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],Hg=["install","reconcile","report","driver"],Jc=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],Qc=["upgrade"],Zc=["reopen"],ro={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Rt=Object.freeze(It.flatMap(e=>e in ro?[]:e==="extension"||e==="package"?[...Jc.map(t=>`${e}-${t}`),...e==="package"?Qc.map(t=>`package-${t}`):[],e]:e==="item"?Zc.map(t=>`item-${t}`):[e])),el=Object.freeze(St.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Rt.includes(e.alias)).map(e=>e.alias)),Yg=Object.freeze(Rt.filter(e=>!el.includes(e)));function Xg(e=It,t=Rt,n=ro){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 Jg(e){return Rt.includes(e)}function Qg(e){return Kc.includes(e)}function Zg(e){return Hc.includes(e)}function ey(e){return Yc.includes(e)}function ty(e){return Xc.includes(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]="de2a2a0e-8a39-5569-9af9-cbf557bce2a9")}catch{}})();function xt(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 l=s[0];for(let d=1;d<=t.length;d+=1){let u=e[c-1]===t[d-1]?0:1,m=i[d-1]+u,f=s[d-1]+1,p=i[d]+1,_=Math.min(m,f,p);c>1&&d>1&&e[c-1]===t[d-2]&&e[c-2]===t[d-1]&&(_=Math.min(_,o[d-2]+1)),s[d]=_,_<l&&(l=_)}if(l>n)return null;for(let d=0;d<r;d+=1)o[d]=i[d],i[d]=s[d]}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]="1ddb0411-5fdd-56af-a524-0f6830c288a5")}catch{}})();function Ve(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Q(e){return V.includes(e)}function oo(e){let t=e.trim().toLowerCase();return Q(t)?t:null}function io(e){return e.filter(t=>!Q(t))}function wn(e){let t=e.trim().toLowerCase();return t.length===0?null:un[t]??null}function so(e){let t=Ve([...e].map(i=>i.toLowerCase())),n=[],r=[];for(let i of t){let s=wn(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:Ve(n),legacy_aliases:o}}function tl(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=wn(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 V){let a=xt(t,s,r);a!==null&&a<i&&(i=a,o=s)}return o}function ao(e,t,n){let r=V.join(","),o=tl(n)??"none";return`extension_capability_unknown:${e}:${t}:${n}:allowed=${r}:suggested=${o}`}function co(e,t,n){let r=n.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${r}`}function nl(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(f=>f.trim()).filter(f=>f.length>0),l=wn(o),u=(s==="none"?void 0:s)??l??void 0;return{layer:a,name:r,capability:o,allowed_capabilities:c,capability_contract_version:pt,suggested_capability:u,suggestion_source:u?l===u?"legacy_alias":"nearest_match":void 0,legacy_alias_target:l??void 0}}function rl(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,n,r,o]=t,i=n,s=[...V],a=[];for(let c of o.split(",")){let[l,d]=c.split(">"),u=l?.trim(),m=d?.trim().toLowerCase();!u||!m||!Q(m)||a.push({layer:i,name:r,capability:u,allowed_capabilities:s,capability_contract_version:pt,suggested_capability:m,suggestion_source:"legacy_alias",legacy_alias_target:m})}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]="71c44385-0182-50f8-8e05-3aeebfe57ad9")}catch{}})();var ol={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"]},lo=":";function uo(e,t){return`${e}${lo}${vn(t)}`}function il(e){return e.slice(e.indexOf(lo)+1)}function vn(e){return e.trim().toLowerCase()}function sl(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let r=oo(n);r!==null&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function fo(e){let t=new Map,n=(d,u)=>{for(let m of d){let f=uo(m.layer,m.name),p=t.get(f);p===void 0&&(p=new Set,t.set(f,p)),p.add(u)}},{registrations:r,commands:o,parsers:i,preflight:s,services:a,renderers:c,hooks:l}=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(l.beforeCommand,"hooks"),n(l.beforeMutation,"hooks"),n(l.afterCommand,"hooks"),n(l.onWrite,"hooks"),n(l.onRead,"hooks"),n(l.onIndex,"hooks"),t}function al(e,t={}){let n=fo(e),r=new Set;t.extensionName!==void 0&&r.add(vn(t.extensionName));for(let i of t.extensionNames??[])r.add(vn(i));let o=new Set;for(let[i,s]of n)if(!(r.size>0&&!r.has(il(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function cl(e,t){let n=fo(t),r=[];for(let o of e){let i=sl(o.capabilities);if(i.length===0)continue;let s=n.get(uo(o.layer,o.name))??new Set,a=[...s].sort((l,d)=>l.localeCompare(d)),c=i.filter(l=>!s.has(l));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]="d2e9c5c4-d817-511d-b719-1d4eb70d0b42")}catch{}})();var Nt={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},Dt=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]);import{createHash as ll}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]="43f9050c-5daa-57e3-bc5d-529216dd0ee7")}catch{}})();var kn=1,mo=4096,dl=/^[A-Za-z0-9_-]+$/;function En(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function _y(e,t){let n=[...Object.values(Nt),...Dt],r=new Set(n.flatMap(o=>[En(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){r.add(En(o.flag));for(let i of o.aliases??[])r.add(En(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!r.has(o)))}function gy(e,t){return ll("sha256").update(e).update("\0").update(de(t)).digest("hex").slice(0,24)}function Ge(e,t,n,r){return Buffer.from(JSON.stringify({version:kn,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function fe(e){return new h(e,y.USAGE,{code:"invalid_query_cursor",nextSteps:["Repeat the original query without --after to obtain a fresh cursor."]})}function ul(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===kn&&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 On(e){if(typeof e!="string")throw fe("Query cursor is malformed.");let t=e.trim();if(t.length===0||t.length>mo||!dl.test(t))throw fe("Query cursor is malformed.");let n;try{n=JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{throw fe("Query cursor is malformed.")}if(!ul(n))throw fe("Query cursor version or payload is unsupported.");return n}function An(e,t){let n=On(e);if(n.fingerprint!==t)throw fe(`Query cursor does not match the current filters, sort, or query (${n.fingerprint} != ${t}).`);return{after_id:n.after_id,...n.after_index===void 0?{}:{after_index:n.after_index},...n.snapshot===void 0?{}:{snapshot:n.snapshot}}}function yy(e,t){return An(e,t).after_id}function fl(e,t,n,r){if(t===void 0)return 0;let o=An(t,n),i=e.findIndex(s=>r(s)===o.after_id);if(i<0){if(o.after_index!==void 0)return Math.min(o.after_index,e.length);throw fe(`Query cursor item ${o.after_id} is no longer present in this result set.`)}return i+1}function hy(e,t){if(t.cursor!==void 0&&An(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw fe("Query cursor does not match the requested snapshot.");let n=fl(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:Ge(t.fingerprint,t.readId(i),n+r.length-1,t.snapshot)}:{}}}var by=Object.freeze({version:kn,max_length:mo});import{stripVTControlCharacters 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]="b4036040-c0b8-5d01-b490-3405722fd1c5")}catch{}})();var pl=["full","compact","brief","summary","counts"],Oy=["mutation","read","discovery","governance"],_o=["error","warning","validation_summary","recovery_bundle"],_l=["full","omit_explanation","limit_collections","compact_recovery","action_only"],gl=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"]),yl=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),hl=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),bl={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},wl=3,vl=2,El=192,kl={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},Ol=_o.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:kl[e],minimum_max_estimated_tokens:El,degradation_ladder:_l,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),Al=new Map(Ol.map(e=>[e.diagnostic_class,e]));function Sl(e){let[t=""]=qe(e).split(/\s+/u);return gl.has(t)?"mutation":yl.has(t)?"discovery":hl.has(t)?"governance":"read"}function go(e,t=Sl(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=bl[t];return Tl({command:n,budget_class:t,default_max_estimated_tokens:r,default_max_estimated_tokens_by_format:{toon:r,json:Math.ceil(r*wl/vl)},degradation_ladder:pl,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function Tl(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 Cl=It.map(e=>go(e)),Il=new Map(Cl.map(e=>[e.command,e]));function yo(e,t={}){let n=e.trim().replace(/\s+/gu," "),[r]=qe(n).split(" "),o=Il.get(r);return o?{...o,command:n}:t.generateFallback?go(n):null}function pe(e){return Math.ceil(Math.max(0,e)/4)}function ho(e){let t=Al.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${_o.join(", ")}`);return t}function Z(e){return pe(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function Rl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Sn(e){if(!Rl(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"]){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 xl(e,t){return typeof e!="string"||e.length<=t?e:`${e.slice(0,Math.max(1,t-3))}...`}function me(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 bo(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 Nl=new Set(["limit_collections","compact_recovery","action_only"]),Dl=new Set(["compact_recovery","action_only"]);function Pl(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:xl(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},n=Sn(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 Ml(e,t){let n=structuredClone(e);if(t!=="full"&&(delete n.why,delete n.examples),Nl.has(t))for(let[r,o]of Object.entries(n))Array.isArray(o)&&(n[r]=o.slice(0,3));if(Dl.has(t)){let r=Sn(n.recovery);r?n.recovery=r:delete n.recovery}return t!=="action_only"?bo(n):Pl(n)}function Se(e,t){let n={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let r=0;r<4;r+=1){let o=Z(n),i=n.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return n}function $l(e,t,n){let r=Se(e,t);for(let i of["recovery","exit_code"])Z(r)<=n||e[i]===void 0||(delete e[i],r=Se(e,t));let o=40;for(;Z(r)>n&&o>4;)o-=4,e.code=me(String(e.code),o),e.required=me(String(e.required),o),r=Se(e,t);return r}function Ll(e,t){let n=e.diagnostic_output,{estimated_tokens:r,...o}=n,i=o.omitted_fields.slice(0,8).map(u=>me(u,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=Sn(e.recovery),c=a&&Z(a)<=48?a:void 0,l={code:me(String(e.code),320),required:me(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},d=Se(l,s);for(;Z(d)>t&&s.omitted_fields.length>0;)s.omitted_fields.pop(),s.omitted_fields_overflow_count=o.omitted_fields.length-s.omitted_fields.length,d=Se(l,s);return d=$l(l,s,t),d}function Ay(e,t={}){let n=e,r=t.diagnosticClass??"error",o=ho(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=Z(n),c=Object.keys(n);if(a<=s)return bo(structuredClone(n));let l;for(let[d,u]of o.degradation_ladder.entries()){let m=Ml(n,u),f=c.filter(_=>!Object.hasOwn(m,_)),p=Se(m,{diagnostic_class:r,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:d>0,degradation_steps:o.degradation_ladder.slice(0,d+1),omitted_fields:f});if(l=p,Z(p)<=s)break}return Z(l)>s&&(l=Ll(l,s)),l}function po(e){return ml(e).replace(/\r\n/gu,`
2
- `).replace(/[^\P{Cc}\n]/gu," ")}function Sy(e,t,n={}){let r=n.diagnosticClass??"error",o=ho(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=po(e),c=pe(Buffer.byteLength(a,"utf8")),l=c>s,d=`What is required:
3
- `,m=`
4
-
5
- ${me(a.trimStart().split(/\r?\n/u,1)[0].trim(),320)}
6
-
7
- Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,f=po(t).trim()||"Inspect the diagnostic code and retry with corrected input.",p=Math.max(1,s*4-Buffer.byteLength(`${d}${m}`,"utf8")),_=l?`${d}${me(f,p)}${m}`:a;return{output:_,diagnostic_output:{diagnostic_class:r,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:pe(Buffer.byteLength(_,"utf8")),truncated:l,degradation_steps:l?[...o.degradation_ladder]:["full"],omitted_fields:l?["explanation","collections"]:[]}}}import{createHash as T_}from"node:crypto";import{existsSync as hf}from"node:fs";import{AsyncLocalStorage as bf}from"node:async_hooks";import Y from"node:path";import ve from"node:fs/promises";import we from"node:path";import{pathToFileURL as ju}from"node:url";import*as T from"node:fs/promises";import{constants as Tn}from"node:fs";import Pt from"node:path";import jl 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]="a69b18ac-4f93-5b12-ba74-764405961966")}catch{}})();var Fl=[10,25,50,100];async function wo(e){await T.mkdir(e,{recursive:!0})}async function Cn(e){try{return await T.access(e),!0}catch{return!1}}function vo(e){return ge(e)||_e(e,"ENOTDIR")}function ge(e){return _e(e,"ENOENT")}async function xy(e){try{return await T.readFile(e,"utf8")}catch(t){if(vo(t))return null;throw t}}async function Ny(e,t){let n=await T.open(e,Tn.O_RDONLY|Tn.O_NOFOLLOW|Tn.O_NONBLOCK);try{if(!(await n.stat()).isFile())throw new TypeError(t);return await n.readFile("utf8")}finally{await n.close()}}async function Dy(e,t){let n=Pt.dirname(e);await wo(n);let r=Pt.join(n,`.${Pt.basename(e)}.${process.pid}.${Date.now()}.${jl.randomBytes(4).toString("hex")}.tmp`);await T.writeFile(r,t,"utf8");try{await T.rename(r,e)}catch(o){if(process.platform==="win32"&&(_e(o,"EPERM")||_e(o,"EBUSY"))){let i=o;for(let s of Fl){await new Promise(a=>setTimeout(a,s));try{await T.rename(r,e);return}catch(a){if(i=a,!_e(a,"EPERM")&&!_e(a,"EBUSY"))break}}try{await T.unlink(r)}catch{}throw i}if(_e(o,"EXDEV")){try{await T.copyFile(r,e)}finally{try{await T.unlink(r)}catch{}}return}try{await T.unlink(r)}catch{}throw o}}async function Py(e,t){let n=Pt.dirname(e);await wo(n);let r=await T.open(e,"a");try{await r.writeFile(`${t}
8
- `,"utf8")}finally{await r.close()}}async function My(e){try{await T.unlink(e)}catch(t){if(!vo(t))throw t}}function _e(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}import Eo 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]="83a29a06-1b0b-52e6-9617-2fc03861cb18")}catch{}})();function In(e,t){let n=Eo.relative(e,t);return n.length===0?!0:!n.startsWith("..")&&!Eo.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]="de5f8d66-b9dc-555c-a52f-33b1b5368be3")}catch{}})();var Ul="__pm_suppress_host_output",Rn="@unbrained/pm-cli:suppress-host-output:v1";function ko(e){return e===void 0?{__pm_suppress_host_output:Rn}:{__pm_suppress_host_output:Rn,result:e}}function xn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[Ul]===Rn}import Te from"node:fs";import ee from"node:path";import{fileURLToPath as zl}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]="dc77f588-e4ea-59fc-908f-51b41114430a")}catch{}})();var ql="@unbrained/pm-cli";function Bl(e){try{return JSON.parse(Te.readFileSync(e,"utf8")).name===ql}catch{return!1}}function Vl(e){let t=Te.existsSync(e)&&Te.statSync(e).isDirectory()?ee.resolve(e):ee.dirname(ee.resolve(e));for(;;){let n=ee.join(t,"package.json");if(Te.existsSync(n)&&Bl(n))return t;let r=ee.dirname(t);if(r===t)return;t=r}}function Nn(e,t=[]){let n=zl(e),r=Vl(n);return r||ee.resolve(ee.dirname(n),...t)}function By(e,t=[]){try{let n=ee.join(Nn(e,t),"package.json");if(!Te.existsSync(n))return;let r=JSON.parse(Te.readFileSync(n,"utf8"));return typeof r.version=="string"&&r.version.trim().length>0?r.version:void 0}catch{return}}(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]="49fe564d-671f-5425-96fe-517cb323f773")}catch{}})();function Gl(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Gy(e){return Gl(e)??void 0}function Wy(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 Ky(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function Ao(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function So(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 Hy(e){let t=So(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function Yy(e,t,n){let r=So(e);return r===null||r<t||r>n?null:r}function te(e){return typeof e!="object"||e===null?null:e}function Oo(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function To(e){let t=Oo(e);if(!t)return null;if(typeof t.activate=="function")return t;let n=Oo(t.default);return typeof n?.activate=="function"?n:null}function Xy(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e}:{}}import{readFileSync as xd,readdirSync as uh,statSync as Nd}from"node:fs";import Dd from"node:os";import A from"node:path";import Xl 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]="0ca7f52c-fb31-5cd9-b689-a918f4e61816")}catch{}})();(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]="7647d826-e562-5f8e-86b2-2e40d8714b4d")}catch{}})();function ne(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Wl(e){let t=e.key.trim();if(t.length===0)return null;let n=ne(e.aliases),r=e.description?.trim();return{key:t,values:ne(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 Kl=e=>e,Io=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function Hl(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 Yl(e,t){let n=new Map;for(let r of e??[]){let o=Hl(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 Co(e,t){return t?ne(e):void 0}function Dn(e){let t=e?.trim();return t&&t.length>0?t:void 0}function Pn(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 Ro(e,t={}){let n=t.resolvePolicyCommand??Kl,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=ne(e.aliases),l=(e.options??[]).map(u=>Wl(u)).filter(u=>u!==null).sort((u,m)=>u.key.localeCompare(m.key)),d=Yl(e.command_option_policies,n);return{name:r,description:Dn(e.description),default_status:Dn(e.default_status),...e.execution_role===void 0?{}:{execution_role:Pn(e.execution_role)},folder:Dn(e.folder),aliases:c.length>0?c:void 0,required_create_fields:Co(e.required_create_fields,o),required_create_repeatables:Co(e.required_create_repeatables,i),options:s?l:void 0,command_option_policies:a?d: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]="69ea08ca-3793-51d7-a971-95abf442028f")}catch{}})();var Jl=Object.freeze({decision:"human",milestone:"gate"}),Ql=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],Zl=["dep","comment","note","learning","file","test","doc"],No=["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"],ed=["title","description","type","status","priority","tags","body",...No,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],td=["title","description","body","status","closeReason","priority","type","tags",...No,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],Do={"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"},nd={...Do},rd={...Do},Po=[["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"]],Mo=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function $o(e){return Object.fromEntries(e)}var od=$o([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...Po,["author","--author"],["message","--message"],["dep","--dep"],...Mo]),id=$o([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...Po,...Mo,["author","--author"],["message","--message"],["force","--force"]]);function sd(e){return e.trim().replace(/^--+/,"").toLowerCase()}function ad(e){return e==="create"?ed:td}function cd(e){return e==="create"?nd:rd}function Lo(e,t){let n=sd(t);if(n.length===0)return;let r=cd(e)[n];return r||ad(e).find(o=>o.toLowerCase()===n)}function ih(e,t){return(e==="create"?od:id)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function $n(e){let t=dd(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function ld(e){let t=e.trim(),r=t.replaceAll("\\","/").replace(/^\/+/,""),o=Xl.posix.normalize(r);if(t.includes("\0")||/^[A-Za-z]:/.test(o)||o==="."||o===".."||o.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return o}function dd(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 ud(e){return Ro(e,{resolvePolicyCommand:Io})}function We(e,t){let n=e[t];return Array.isArray(n)?n.filter(r=>typeof r=="string"):void 0}function fd(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:We(t,"values")??[],required:t.required===void 0?void 0:!!t.required,aliases:We(t,"aliases"),description:typeof t.description=="string"?t.description:void 0}}function md(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 pd(e){if(Array.isArray(e.options))return e.options.map(t=>fd(t)).filter(t=>t!==null)}function _d(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>md(t)).filter(t=>t!==null)}function gd(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:Pn(t.execution_role),folder:r,aliases:We(t,"aliases"),required_create_fields:We(t,"required_create_fields"),required_create_repeatables:We(t,"required_create_repeatables"),options:pd(t),command_option_policies:_d(t)}}function yd(e,t){return e.required_create_fields?ne(e.required_create_fields):t?.required_create_fields??[]}function hd(e,t){return e.required_create_repeatables?ne(e.required_create_repeatables):t?.required_create_repeatables??[]}function bd(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function wd(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function vd(e,t){let n=t?.name??e.name,r=e.description??t?.description,o=e.default_status??t?.default_status,i=ld(e.folder??t?.folder??$n(n)),s={name:n,execution_role:e.execution_role,folder:i,aliases:ne([...t?.aliases??[],...e.aliases??[]]),required_create_fields:yd(e,t),required_create_repeatables:hd(e,t),options:bd(e,t),command_option_policies:wd(e,t)};return r&&(s.description=r),o&&(s.default_status=o),s}function xo(e,t){for(let n of e){let r=ud(n);if(!r)continue;let o=r.name.toLowerCase(),i=t.get(o);t.set(o,vd({...r,execution_role:r.execution_role??i?.execution_role},i))}}function Ed(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=gd(o);i&&t.push(i)}}return t}function sh(e,t=null){let n=new Map;for(let c of Vr)n.set(c.toLowerCase(),{name:c,execution_role:Jl[c.toLowerCase()]??"agent",folder:Ue[c],aliases:[],required_create_fields:[...Ql],required_create_repeatables:[...Zl],options:[],command_option_policies:[]});xo(e.item_types?.definitions??[],n),xo(Ed(t),n);let r=[...n.values()].sort((c,l)=>c.name.localeCompare(l.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 l of c.aliases)i[l.toLowerCase()]=c.name}let a=[...new Set(r.map(c=>c.folder))].sort((c,l)=>c.localeCompare(l));return{types:r.map(c=>c.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function kd(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function Od(e,t){let n=kd(e,t);if(n)return t.by_type[n]}function Ad(e,t,n,r){for(let o of r){let i=Lo(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 Mn(e,t,n){if(n){e.add(t);return}e.delete(t)}function Sd(e,t,n,r){let o=Lo(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&&Mn(e.required,o,r.required),r.visible!==void 0&&Mn(e.hidden,o,!r.visible),r.enabled!==void 0&&Mn(e.disabled,o,!r.enabled)}function Td(e,t,n){for(let r of t.command_option_policies)r.command===n&&Sd(e,t,n,r)}function Cd(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 ah(e,t,n){let r=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:r};return Ad(a,e,t,n),Td(a,e,t),Cd(a,e,t),{required:[...o],hidden:[...i].sort((c,l)=>c.localeCompare(l)),disabled:[...s].sort((c,l)=>c.localeCompare(l)),errors:r}}function Id(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 Rd(e,t,n){let r=e.values;if(r.length===0)return t;let i=new Map(r.map(s=>[s.toLowerCase(),s])).get(t.toLowerCase());if(!i){n.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${r.join(", ")}`);return}return i}function ch(e,t,n){let r=Od(e,n);if(!r)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=Id(r),s={};for(let[c,l]of Object.entries(t??{})){let d=c.trim(),u=l.trim();if(d.length===0){o.push("type option keys must not be empty");continue}if(u.length===0){o.push(`type option "${d}" must not be empty`);continue}let m=i.get(d.toLowerCase());if(!m){let p=r.options.map(_=>_.key).join(", ");o.push(r.options.length>0?`Unknown type option "${d}" for type "${r.name}". Allowed: ${p}`:`Type "${r.name}" does not define any configurable type options`);continue}let f=Rd(m,u,o);f!==void 0&&(s[m.key]=f)}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,l)=>c.localeCompare(l));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(c=>[c,s[c]])),errors: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]="124443e3-a20b-5fd6-a1d9-e4a09b17dc4a")}catch{}})();var Pd={json_markdown:".md",toon:".toon"},Md={".md":"json_markdown",".toon":"toon"};var yh=[".md",".toon"];function Mt(e){try{return Nd(e),!0}catch{return!1}}function $d(e){try{let t=JSON.parse(xd(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function Ld(e){let t=A.resolve(e);for(;;){let n=A.join(t,wt),r=A.join(n,vt);if(Mt(r))return n;let o=A.join(t,vt);if(Mt(o)&&$d(o))return t;let i=A.dirname(t);if(i===t)return;t=i}}function jd(e){return Ld(e)??A.resolve(e,wt)}function hh(e,t){let n=process.env.PM_PATH,r=t?.trim()||n?.trim();if(r){let o=A.resolve(e,r);if(!Mt(jo(o))){let i=A.join(o,wt);if(Mt(jo(i)))return i}return o}return jd(e)}function bh(e){let t=A.resolve(e),n=A.dirname(t);return A.basename(t)==="pm"&&A.basename(n)===".agents"?A.dirname(n):t}function Fo(e){let t=process.env.PM_GLOBAL_PATH?.trim(),n=t&&t.length>0?t:A.join(Dd.homedir(),".pm-cli");return A.resolve(e,n)}function jo(e){return A.join(e,vt)}function Fd(e,t,n=Ue){let r=n[t]??$n(t);return A.join(e,r)}function wh(e,t,n,r="toon",o=Ue){return A.join(Fd(e,t,o),`${n}${Pd[r]}`)}function vh(e){let t=e.replaceAll("\\","/"),n=A.posix.extname(t).toLowerCase();return Md[n]??null}function Eh(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new h("Invalid history item id: expected a single filename.",y.USAGE);return A.join(e,"history",`${t}.jsonl`)}function Uo(e,t){return A.join(e,"locks",`${t}.lock`)}function kh(e){return A.join(e,"runtime")}(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]="44b86710-2d6f-57fe-912d-1cf7482a4f86")}catch{}})();function zo(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]="aade6230-a71b-5cbc-bc9d-022f20e521bd")}catch{}})();function x(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return t}function P(e,t){if(t!==void 0&&typeof t!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function S(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 qo(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 ye(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 Ke(e,t){if(ye(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]="34536eba-0f92-5599-a807-5b39b000e733")}catch{}})();var Ln=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]="ca48c32a-e4e0-5da5-b9cb-b1f713646bad")}catch{}})();var Ud=new Set(Ln);function zd(e){if(e!==void 0&&!Ud.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${Ln.join(", ")}`)}function Bo(e){S("registerCommand definition.action",e.action),S("registerCommand definition.family",e.family),S("registerCommand definition.description",e.description),S("registerCommand definition.intent",e.intent),S("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");zd(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]="1729c469-5e9c-5d8c-8137-ec506c9fd31b")}catch{}})();function qd(e){let t=x("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 S("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 Vo(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=qd(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 jn(e,t,n){return{registration:t,action:n,command:e.command,args:M(e.args),options:M(e.options),global:M(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]="b35d854e-5025-5999-abe7-507f1a25647f")}catch{}})();function Go(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]="8ea4597b-6a2b-5061-b490-d8aff3fbe7aa")}catch{}})();function z(e){return typeof e!="string"?"":e.trim().toLowerCase()}function b(e){return new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))}function Bd(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 Ce(e){return new Set((e??[]).map(t=>Bd(t)).filter(t=>t.length>0))}function Wo(e){let t=z(e);return _t.includes(t)?t:"off"}function Ko(e){let t=z(e);return gt.includes(t)?t:"off"}function He(e){let t=z(e);return yt.includes(t)?t:"none"}function Fn(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return Br.includes(t)?t:void 0}function Ho(e){if(typeof e=="string"){let t=Fn(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:Fn(e.global)??"block",project:Fn(e.project)??"block"}:{global:"block",project:"block"}}function Vd(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function E(e){return[...new Set(e)].sort((t,n)=>t.localeCompare(n))}function Gd(e){let t=z(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?He(e.sandbox_profile):void 0,allowedCapabilities:b(e.allowed_capabilities),blockedCapabilities:b(e.blocked_capabilities),allowedSurfaces:Ce(e.allowed_surfaces),blockedSurfaces:Ce(e.blocked_surfaces),allowedCommands:b(e.allowed_commands),blockedCommands:b(e.blocked_commands),allowedActions:b(e.allowed_actions),blockedActions:b(e.blocked_actions),allowedServices:b(e.allowed_services),blockedServices:b(e.blocked_services)}}}function Yo(e){let t=new Map;for(let n of e??[]){let r=Gd(n);r&&t.set(r.name,r.normalized)}return t}function Wd(e){let t=[],n=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of E([...e.allowedCapabilities,...e.blockedCapabilities]))Q(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of n)for(let i of E([...o.allowedCapabilities,...o.blockedCapabilities]))Q(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let r=new Set(ht);for(let o of E([...e.allowedSurfaces,...e.blockedSurfaces]))r.has(o)||t.push(`extension_policy_unknown_surface:${o}`);for(let o of n)for(let i of E([...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 Xo(e){let t=e.extensions?.policy??{},n=b(t.allowed_capabilities),r=b(t.blocked_capabilities),o=Ce(t.allowed_surfaces),i=Ce(t.blocked_surfaces),s=Yo(t.extension_overrides);return{mode:Wo(t.mode),trustMode:Ko(t.trust_mode),pmMaxVersionExceededMode:Ho(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:b(t.trusted_extensions),defaultSandboxProfile:He(t.default_sandbox_profile),allowedExtensions:b(t.allowed_extensions),blockedExtensions:b(t.blocked_extensions),allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:b(t.allowed_commands),blockedCommands:b(t.blocked_commands),allowedActions:b(t.allowed_actions),blockedActions:b(t.blocked_actions),allowedServices:b(t.allowed_services),blockedServices:b(t.blocked_services),overridesByName:s,warnings:Wd({allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function Jo(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:E(n.allowedCapabilities)}:{},...n.blockedCapabilities.size>0?{blocked_capabilities:E(n.blockedCapabilities)}:{},...n.allowedSurfaces.size>0?{allowed_surfaces:E(n.allowedSurfaces)}:{},...n.blockedSurfaces.size>0?{blocked_surfaces:E(n.blockedSurfaces)}:{},...n.allowedCommands.size>0?{allowed_commands:E(n.allowedCommands)}:{},...n.blockedCommands.size>0?{blocked_commands:E(n.blockedCommands)}:{},...n.allowedActions.size>0?{allowed_actions:E(n.allowedActions)}:{},...n.blockedActions.size>0?{blocked_actions:E(n.blockedActions)}:{},...n.allowedServices.size>0?{allowed_services:E(n.allowedServices)}:{},...n.blockedServices.size>0?{blocked_services:E(n.blockedServices)}:{}}));return{mode:e.mode,trust_mode:e.trustMode,pm_max_version_exceeded_mode:Vd(e.pmMaxVersionExceededMode),require_provenance:e.requireProvenance,trusted_extensions:E(e.trustedExtensions),default_sandbox_profile:e.defaultSandboxProfile,allowed_extensions:E(e.allowedExtensions),blocked_extensions:E(e.blockedExtensions),allowed_capabilities:E(e.allowedCapabilities),blocked_capabilities:E(e.blockedCapabilities),allowed_surfaces:E(e.allowedSurfaces),blocked_surfaces:E(e.blockedSurfaces),allowed_commands:E(e.allowedCommands),blocked_commands:E(e.blockedCommands),allowed_actions:E(e.allowedActions),blocked_actions:E(e.blockedActions),allowed_services:E(e.allowedServices),blocked_services:E(e.blockedServices),extension_overrides:t}}function Qo(e){let t=Yo(e.extension_overrides);return{mode:Wo(e.mode),trustMode:Ko(e.trust_mode),pmMaxVersionExceededMode:Ho(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:b(e.trusted_extensions),defaultSandboxProfile:He(e.default_sandbox_profile),allowedExtensions:b(e.allowed_extensions),blockedExtensions:b(e.blocked_extensions),allowedCapabilities:b(e.allowed_capabilities),blockedCapabilities:b(e.blocked_capabilities),allowedSurfaces:Ce(e.allowed_surfaces),blockedSurfaces:Ce(e.blocked_surfaces),allowedCommands:b(e.allowed_commands),blockedCommands:b(e.blocked_commands),allowedActions:b(e.allowed_actions),blockedActions:b(e.blocked_actions),allowedServices:b(e.allowed_services),blockedServices:b(e.blocked_services),overridesByName:t,warnings:[]}}function re(e,t){return e.overridesByName.get(z(t))??null}function Ie(e,t,n,r,o){return t.has(n)?o:e.size>0&&!e.has(n)?r:null}function Zo(e,t,n){let r=n.trim().toLowerCase(),o=re(e,t.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return Ie(i,s,r,"capability_not_allowlisted","capability_blocked")}function Kd(e,t,n){let r=re(e,t.name),o=r&&r.allowedSurfaces.size>0?r.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...r?r.blockedSurfaces:[]]);return Ie(o,i,n,"surface_not_allowlisted","surface_blocked")}function Hd(e,t,n){let r=O(n);if(r.length===0)return null;let o=re(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return Ie(i,s,r,"command_not_allowlisted","command_blocked")}function Yd(e,t,n){let r=z(n).replace(/\s+/g,"-");if(r.length===0)return null;let o=re(e,t.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return Ie(i,s,r,"action_not_allowlisted","action_blocked")}function Xd(e,t,n){let r=z(n);if(r.length===0)return null;let o=re(e,t.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return Ie(i,s,r,"service_not_allowlisted","service_blocked")}function Jd(e,t){let n=z(t.name);return re(e,t.name)?.disabled===!0?"extension_override_disabled":Ie(e.allowedExtensions,e.blockedExtensions,n,"extension_not_allowlisted","extension_blocked")}function Qd(e,t){if(e.trustMode==="off")return null;let n=re(e,t.name),r=z(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 Zd(e,t){if(e.mode==="off")return null;let r=re(e,t.name)?.sandboxProfile??t.sandboxProfile??e.defaultSandboxProfile;if(r==="none")return null;let o=t.permissions;if(!o)return"sandbox_permissions_missing";let i=s=>o[s]===!0;return r==="restricted"?i("process_spawn")?"sandbox_restricted_disallows_process_spawn":i("env_write")?"sandbox_restricted_disallows_env_write":null:i("process_spawn")?"sandbox_strict_disallows_process_spawn":i("network")?"sandbox_strict_disallows_network":i("fs_write")?"sandbox_strict_disallows_fs_write":i("env_write")?"sandbox_strict_disallows_env_write":null}function $t(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 ei(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let n=[],r=Jd(e,t);r&&n.push({reason:r,scope:"extension",mode:e.mode});let o=Qd(e,t);o&&n.push({reason:o,scope:"trust",mode:e.trustMode});let i=Zd(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:$t("blocked",s.scope,t,s.reason)};let a=n.find(c=>c.mode==="warn");return a?{allowed:!0,warning:$t("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function ti(e,t,n){if(e.mode==="off")return{allowed:!0,warning:null};let r=Zo(e,t,n);return r?{allowed:e.mode==="warn",warning:$t(e.mode==="warn"?"violation":"blocked","capability",t,r,{capability:n.trim().toLowerCase()})}:{allowed:!0,warning:null}}function eu(e,t,n,r,o){let i=typeof r=="string"?Zo(e,t,r):null,s=Kd(e,t,n),a=o.command?Hd(e,t,o.command):null,c=o.action?Yd(e,t,o.action):null,l=o.service?Xd(e,t,o.service):null;return i??s??a??c??l}function tu(e,t,n,r){let o={method:z(e).replace(/\s+/g,"_"),surface:t};return n&&(o.capability=n),r.command&&(o.command=O(r.command)),r.action&&(o.action=z(r.action).replace(/\s+/g,"-")),r.service&&(o.service=z(r.service)),o}function ni(e,t,n,r,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=eu(e,t,n,o,s);if(!a)return{allowed:!0,warning:null};let c=$t(e.mode==="warn"?"violation":"blocked","registration",t,a,tu(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 Lt(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function Un(){return{overrides:[],handlers:[]}}function zn(){return{overrides:[]}}function qn(){return{overrides:[]}}function Bn(){return{overrides:[]}}function Vn(){return{overrides:[]}}function Gn(){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]="1c944ddd-e05b-5d8c-bdc5-7bc9677fa5d1")}catch{}})();var oi=100;function ri(e,t){let n=e[t];if(n!=null)return typeof n!="string"||n.trim().length===0?null:n.trim()}function nu(e){if(e==null)return;let t=te(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 Wn(e,t){let n=e[t];return typeof n!="string"||n.trim().length===0?null:n.trim()}function ii(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function he(e){if(e!=null)return typeof e!="boolean"?null:e}function ru(e){let t=ii(e.priority);return t===void 0?oi:t}function ou(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let n=He(t);return n!==t.trim().toLowerCase()?null:n}function Kn(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function iu(e){if(e==null)return;let t=te(e);if(!t)return null;let n=Kn(t.source),r=Kn(t.signature),o=Kn(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 su(e){if(e==null)return;let t=te(e);if(!t)return null;let n=he(t.fs_read),r=he(t.fs_write),o=he(t.network),i=he(t.env_read),s=he(t.env_write),a=he(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 au(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(n=>typeof n!="string"))return null;let t=so(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function cu(e){if(e==null)return;let t=te(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=>O(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return r.length>0?{commands:r}:void 0}function lu(e){let t=ii(e.manifest_version);if(t===null)return null;let n=ri(e,"pm_min_version");if(n===null)return null;let r=ri(e,"pm_max_version");if(r===null)return null;let o=nu(e.engines);if(o===null)return null;let i=he(e.trusted);if(i===null)return null;let s=ou(e);if(s===null)return null;let a=iu(e.provenance);if(a===null)return null;let c=su(e.permissions);if(c===null)return null;let l=au(e.capabilities);if(l===null)return null;let d=cu(e.activation);if(d===null)return null;let u=At(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:l.capabilities,legacy_capability_aliases:l.legacy_aliases,activation:d,contributions:u}}function Hn(e){if(typeof e!="object"||e===null)return null;let t=e,n=Wn(t,"name");if(n===null)return null;let r=Wn(t,"version");if(r===null)return null;let o=Wn(t,"entry");if(o===null)return null;let i=ru(t);if(i===null)return null;let s=lu(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}}import{constants as oe}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]="aaf1c6ce-1bc9-5974-a38f-7daf8e4e63cc")}catch{}})();var si=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"}]]),du=/^[a-z][a-z0-9_]{0,63}$/u,uu=new Map([[oe.errno.EACCES,"EACCES"],[oe.errno.EDQUOT,"EDQUOT"],[oe.errno.EMFILE,"EMFILE"],[oe.errno.ENFILE,"ENFILE"],[oe.errno.ENOMEM,"ENOMEM"],[oe.errno.ENOSPC,"ENOSPC"],[oe.errno.EPERM,"EPERM"],[oe.errno.EROFS,"EROFS"]].filter(([e])=>Number.isInteger(e))),fu={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function mu(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&si.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:uu.get(Math.abs(t.errno))??null}function pu(e,t,n={}){let r=mu(e);if(r===null)return null;if(!du.test(t))throw new h("Host environment operation labels must be bounded identifiers.",y.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=si.get(r);return new h(`Host filesystem operation ${t} ${o.summary}.`,y.GENERIC_FAILURE,{code:n.codes?.[o.category]??fu[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 ai(e,t,n={}){try{return await t()}catch(r){throw pu(r,e,n)??r}}import _u from"node:fs/promises";import Ye 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]="6d77d806-1c41-5235-b56b-802089979395")}catch{}})();async function ci(e,t){let n=Ye.dirname(t.manifest_path),r=Ye.relative(n,t.entry_path);if(r.startsWith("..")||Ye.isAbsolute(r))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=Ye.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await ai("extension_module_graph_snapshot",()=>_u.cp(n,o,{recursive:!0,force:!0})),Ye.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]="092f2852-fa07-5f0f-8266-e9e2ca078cb6")}catch{}})();function li(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 O(r)}))];return{run:t,...n.length>0?{commands:n}:{}}}function di(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]="09098e5c-d021-53ae-96b5-c56394c304da")}catch{}})();var gu=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields"},{flag:"--output-limit",value_name:"count"},{flag:"--output-budget",value_name:"tokens"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state"},{flag:"--output-cursor",value_name:"cursor"},{flag:"--output-row-contract"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"]},{flag:"--no-extensions"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"}]),Yn=new Set(gu.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]="f823edae-b035-5547-8d81-2761a9a44034")}catch{}})();var yu=/^--[a-z0-9][a-z0-9_-]*(?:[ =](?:<[^<>]+>|\[[^[\]]+\]))?$/;function hu(e){if(typeof e!="string")return null;let t=e.trim(),n=t.split(/[ =]/,1)[0];return Yn.has(n)?"host_owned_flag_collision":yu.test(t)?null:"malformed_long_flag"}function ui(e,t){let n=[e,t].find(i=>typeof i=="string"&&Yn.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=hu(r);return o===null?null:{token:r,failure:o}}function fi(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]="31da4a5a-1e85-5d77-a09f-2736cc44d850")}catch{}})();var bu=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function mi(e){return typeof e!="string"?null:bu[e.trim().toLowerCase()]??null}function pi(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 _i(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(){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]="99f785c2-7c67-5564-9423-3439c41b4557")}catch{}})();var jt=Gr;function gi(e){let t=e.trim().toLowerCase();return jt.includes(t)?t:null}function yi(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 jt)if(xt(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]="483b4197-5498-568a-bcc4-abd6999a07cc")}catch{}})();function hi(e){return e==="toon"||e==="json"}function bi(e){return Ae.includes(e)}function be(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var wi=Symbol("extension_registration_trace");function H(e,t){let n=new TypeError(e);return Object.defineProperty(n,wi,{value:t,enumerable:!1,configurable:!1,writable:!1}),n}function vi(e){return e instanceof Error?e[wi]:void 0}function Xe(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>Xe(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]=Xe(t[r]);return n}return e}function Je(e){if(Array.isArray(e))return e.map(t=>Je(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]=Je(t[r]);return n}return e}function Re(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Xe(t)}function Qe(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Je(t)}function Ze(e,t){if(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(n=>Re(e,n))}function $(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function et(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function Xn(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Jn(e,t){return O(`${e} ${t}`)}function tt(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var wu=new Set(["low","medium","high"]),vu=new Set(["number","string_set"]),Eu=new Set(["string","number","boolean"]);function Ei(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function ku(e,t,n){let r=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=x(r,n);if(!vu.has(String(o.value_type)))throw new TypeError(`${r}.value_type must be number or string_set`);if(S(`${r}.description`,o.description),o.parameters===void 0)return;let i=x(`${r}.parameters`,o.parameters);for(let[s,a]of Object.entries(i)){let c=`${r}.parameters.${s}`;Ei(`${c}.name`,s);let l=x(c,a);if(!Eu.has(String(l.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);P(`${c}.required`,l.required),S(`${c}.description`,l.description)}if(Object.keys(i).length>50)throw new TypeError(`assurance provider ${e} key ${t} exceeds 50 parameters`)}function ki(e){let t=x("registerAssuranceMeasurementProvider provider",e),n=Ei("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(!wu.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=x("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`);ku(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]="7640f483-6c14-56f1-bccd-cec9ca88e6ea")}catch{}})();var Ou=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","visible"]);function Ft(e,t){return Ze(e,t).map(n=>(n.repeatable===!0&&(n.list=!0),n))}function Au(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function Qn(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=Au(t);if(n.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return n}function Zn(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=x(`registerCommand definition.arguments[${r}]`,o),s=$(`registerCommand definition.arguments[${r}].name`,i.name);if(P(`registerCommand definition.arguments[${r}].required`,i.required),P(`registerCommand definition.arguments[${r}].variadic`,i.variadic),S(`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 Ut(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=x(`registerFlags flags[${t}]`,n),o=Object.keys(r).filter(c=>!Ou.has(c)).sort((c,l)=>c.localeCompare(l));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`);S(`registerFlags flags[${t}].long`,i),S(`registerFlags flags[${t}].short`,s);let a=ui(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${fi(a.token,a.failure)}`);if(S(`registerFlags flags[${t}].value_name`,r.value_name),S(`registerFlags flags[${t}].description`,r.description),P(`registerFlags flags[${t}].required`,r.required),P(`registerFlags flags[${t}].enabled`,r.enabled),P(`registerFlags flags[${t}].visible`,r.visible),P(`registerFlags flags[${t}].list`,r.list),P(`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(qo(`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.`);Oi(`registerFlags flags[${t}]`,r)}}function Oi(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=mi(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?pi(t.default):[t.default];for(let[i,s]of o.entries())if(!_i(s,r)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${r}.`)}}function Ai(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=x(`registerItemFields fields[${t}]`,n);$(`registerItemFields fields[${t}].name`,r.name);let o=$(`registerItemFields fields[${t}].type`,r.type);if(gi(o)===null){let i=yi(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${jt.join(", ")}).${s}`)}P(`registerItemFields fields[${t}].optional`,r.optional)}}function Su(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=x(i,o);$(`${i}.command`,s.command),$(`${i}.option`,s.option),P(`${i}.enabled`,s.enabled),P(`${i}.required`,s.required),P(`${i}.visible`,s.visible)}}function Tu(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=x(i,o);$(`${i}.key`,s.key),ye(`${i}.values`,s.values),P(`${i}.required`,s.required),ye(`${i}.aliases`,s.aliases)}}function Si(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=x(r,n);$(`${r}.name`,o.name),S(`${r}.folder`,o.folder),ye(`${r}.aliases`,o.aliases),ye(`${r}.required_create_fields`,o.required_create_fields),ye(`${r}.required_create_repeatables`,o.required_create_repeatables),Su(t,o.command_option_policies),Tu(t,o.options)}}function Ti(e){let t=x("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(P("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 Ci=["types","statuses","fields","workflows","config","templates","packages"],Cu={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 Ii(e){let t=x("registerProfile profile",e);if($("registerProfile profile.name",t.name),$("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 Ci){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`);Cu[n]?.(`registerProfile profile.${n}[${o}]`,i)}}}}function Ri(e){e.summary===void 0&&(e.summary="");for(let t of Ci)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]="09c95125-68bd-512b-bb09-c9ef0b2f676e")}catch{}})();function xi(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]="d2feae50-9a1e-54fa-98a3-df529be63069")}catch{}})();function Ni(e){return typeof e=="string"?e:String(e)}function nt(e){let n=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(n)?n.split(/[.-]/).map(r=>Number(r)):null}function er(e,t){let n=nt(e),r=nt(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 Di(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let n=Ni(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(!nt(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=er(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 Pi(e,t,n){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let r=Ni(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())||!nt(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=er(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]="736cf7fc-d4da-57ce-90d8-2432085dd2c8")}catch{}})();var Iu=5e3;async function tr(e,t,n){let r=[];for(let o of e)try{await o.run(M(n))}catch{r.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return r}function Ru(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.`,y.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.`,y.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}.`,y.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function nr(e,t){for(let n of e.beforeMutation??[]){let r,o;try{let i=Promise.resolve().then(()=>n.run({pm_root:t.pm_root,operation:t.operation,before:t.before===null?null:M(t.before),after:t.after===null?null:M(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),r=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new h(`Extension mutation guard ${n.name} timed out before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},Iu),o.unref?.()})])}catch(i){throw i instanceof h?i:new h(`Extension mutation guard ${n.name} failed before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(o)}Ru(r,n,t.operation)}}async function rr(e,t){return tr(e.onWrite,"onWrite",t)}async function or(e,t){return tr(e.onRead,"onRead",t)}async function ir(e,t){return tr(e.onIndex,"onIndex",t)}function xu(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?`${n.slice(0,r-1)}\u2026`:n}function zt(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?n.slice(0,300):void 0}function Nu(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 sr(e,t){let n=O(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:M(t.args),options:M(t.options),global:M(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",Nu(o)],["errorCode",zt(o,"code")],["remediation",zt(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{handled:!1,result:null,warnings:[`extension_command_handler_failed:${r.layer}:${r.name}:${r.command}`],errorMessage:xu(o),...Object.fromEntries([["errorCode",zt(o,"code")],["remediation",zt(o,"remediation")]].filter(s=>s[1]!==void 0))}}}function Mi(e){return{handled:!1,result:e.payload,warnings:[]}}function $i(e,t){return[...e.overrides].reverse().filter(n=>n.service===t)}function Li(e){return{service:e.service,command:e.command?O(e.command):void 0,args:e.args?M(e.args):void 0,options:e.options?Xr(e.options):void 0,global:e.global?Jr(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:M(e.payload)}}function Du(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 ji(e,t){return Du(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 Fi(e,t,n){return t.service==="output_format"&&typeof e=="object"&&e!==null&&G(e,n.payload)}function Ui(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 ar(e,t){let n=$i(e,t.service);if(n.length===0)return Mi(t);let r=[];for(let o of n)try{let i=Li(t),s=o.run(i);if(s instanceof Promise){r.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(Fi(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Ui(o,ji(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 cr(e,t){let n=$i(e,t.service);if(n.length===0)return Mi(t);let r=[];for(let o of n)try{let i=Li(t),s=await Promise.resolve(o.run(i));if(Fi(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Ui(o,ji(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(){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]="3ee03fc2-5b71-508c-8524-d22104fa2194")}catch{}})();var zi=null,Fu=Object.freeze(bt()),qi=0;function Uu(e=Date.now()){return qi+=1,`${qi}-${e}`}function zu(e,t,n){return n.has(e)?!1:t.size===0?!0:t.has(e)}async function qu(e,t){let[n,r]=await Promise.all([ve.realpath(e),ve.realpath(t)]);return In(n,r)}function Bu(e,t=process.cwd()){return{global:we.join(Fo(t),"extensions"),project:we.join(e,"extensions")}}async function Vu(e){try{return(await ve.readdir(e,{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>n.name).sort((n,r)=>n.localeCompare(r))}catch{return[]}}function Gu(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 Bi(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function Wu(e){let t=new Map;try{let n=JSON.parse(await ve.readFile(we.join(e,".managed-extensions.json"),"utf8")),o=te(n)?.entries;if(!Array.isArray(o))return t;for(let i of o){if(typeof i!="object"||i===null)continue;let s=i,a=Bi(s.source?.package),c=[s.source?.input,s.source?.name,a].map(u=>Bi(u)).filter(u=>u!==void 0),l=At(s.contributions),d={aliases:[...new Set(c)],...a?{package_name:a}:{},...l?{contributions:l}:{}};typeof s.directory=="string"&&s.directory.trim().length>0&&t.set(`directory:${s.directory.trim()}`,d),typeof s.name=="string"&&s.name.trim().length>0&&t.set(`name:${s.name.trim()}`,d)}}catch{return t}return t}function Vi(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 Ku(e,t){let n=[...Vi(e),...Vi(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 Gi(e,t,n,r,o){let i=[],s=[],a=[],c=await Vu(t),l=await Wu(t);for(let d of c){let u=await Xu(e,t,d,n,r,l,o);i.push(u.diagnostic),s.push(...u.warnings),u.candidate&&a.push(u.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function Hu(){return{diagnostics:[],warnings:[],candidates:[]}}function Wi(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 Yu(e,t,n,r,o,i,s){let a=Hr(e,t,n);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&a.push(co(e,t.name,t.legacy_capability_aliases));for(let c of io(t.capabilities))a.push(ao(e,t.name,c));return r?o||a.push(`extension_entry_missing:${e}:${t.name}`):a.push(`extension_entry_outside_extension:${e}:${t.name}`),i.warning&&a.push(i.warning),s.warning&&a.push(s.warning),a}async function Xu(e,t,n,r,o,i,s){let a=we.join(t,n),c=we.join(a,"manifest.json");if(!await Cn(c))return Wi(e,n,c,`extension_manifest_missing:${e}:${n}`);let l,d;try{let mt=JSON.parse(await ve.readFile(c,"utf8"));d=te(mt),l=Hn(mt)}catch{d=null,l=null}if(!l||!d)return Wi(e,n,c,`extension_manifest_invalid:${e}:${n}`);let u=we.resolve(a,l.entry),m=In(a,u),f=m?await Cn(u):!1,p=m&&f?await qu(a,u):m,_=zu(l.name,r,o),g=await Zu(e,l),w=await ef(e,l,s),v=Yu(e,l,d,p,f,g,w),R=p&&f&&g.allowed&&w.allowed,qr=i.get(`directory:${n}`)??i.get(`name:${l.name}`);return{diagnostic:{layer:e,directory:n,manifest_path:c,name:l.name,version:l.version,entry:l.entry,priority:l.priority,entry_path:u,enabled:_,status:R?"ok":"warn"},warnings:v,candidate:Go({layer:e,directory:n,manifestPath:c,entryPath:u,manifest:l,sourceIdentity:qr,extensionReady:R,enabledForLoad:_})}}async function Ju(e){let t=Bu(e.pmRoot,e.cwd??process.cwd()),n=Ve(e.settings.extensions.enabled),r=Ve(e.settings.extensions.disabled),o=Xo(e.settings),i=Jo(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?Hu():await Gi("global",t.global,s,a,o.pmMaxVersionExceededMode.global),l=await Gi("project",t.project,s,a,o.pmMaxVersionExceededMode.project),d=[...o.warnings],u=Ku(c.candidates,l.candidates),m=[];for(let f of u){let p={layer:f.layer,name:f.manifest.name,trusted:f.manifest.trusted===!0,provenanceVerified:f.manifest.provenance?.verified===!0,sandboxProfile:f.manifest.sandbox_profile,permissions:f.manifest.permissions&&typeof f.manifest.permissions=="object"?{fs_read:f.manifest.permissions.fs_read,fs_write:f.manifest.permissions.fs_write,network:f.manifest.permissions.network,env_read:f.manifest.permissions.env_read,env_write:f.manifest.permissions.env_write,process_spawn:f.manifest.permissions.process_spawn}:void 0},_=ei(o,p);if(_.warning&&d.push(_.warning),!!_.allowed){for(let g of f.manifest.capabilities){let w=ti(o,p,g);w.warning&&d.push(w.warning)}m.push(Gu(f))}}return{disabled_by_flag:!1,roots:t,configured_enabled:n,configured_disabled:r,discovered:[...c.diagnostics,...l.diagnostics],effective:m,warnings:[...new Set([...c.warnings,...l.warnings,...d])],policy:i}}function qt(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function Qu(){try{let e=Nn(import.meta.url,["../../.."]),t=await ve.readFile(we.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 Yi(){return zi??=Qu(),zi}function Xi(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 Zu(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let n=Di(t.pm_min_version,await Yi()),r=Xi(e,t,n);return r?{allowed:n.allowed,warning:r}:{allowed:n.allowed}}async function ef(e,t,n){if(t.pm_max_version===void 0)return{allowed:!0};let r=Pi(t.pm_max_version,await Yi(),n),o=Xi(e,t,r);return o?{allowed:r.allowed,warning:o}:{allowed:r.allowed}}async function Ki(e){try{let t=await ve.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function tf(e,t){let n=e.entry_path;t.module_graph_snapshot_root&&(n=await ci(t.module_graph_snapshot_root,e));let r=new URL(ju(n).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return r.href;let[i,s]=await Promise.all([Ki(e.entry_path),Ki(e.manifest_path)]),a=t.reload_token??Uu();return r.searchParams.set("pm_ext_reload",a),r.searchParams.set("pm_ext_entry",i),r.searchParams.set("pm_ext_manifest",s),r.href}async function aw(e){let t=await Ju(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 c=await import(await tf(s,e));n.push({...s,module:c})}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:qt(a)})}return{...t,warnings:o,loaded:n,failed:r}}var Hi=5e3,nf=2147483647;function rf(e){let n={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let r=e.deactivate;n.deactivate=r.bind(e)}return n}function Ji(e){let t=To(e);return t?rf(t):null}async function cw(e,t,n={}){let r=of(n?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(d=>`${d.layer}:${d.name}`)),i=[];for(let d of e.loaded){if(o.has(`${d.layer}:${d.name}`))continue;let u=Ji(d.module);!u||typeof u.deactivate!="function"||i.push({extension:d,deactivate:u.deactivate})}let s=await Promise.all(i.map(async({extension:d,deactivate:u})=>{try{return await sf(u,r),{ok:!0}}catch(m){return{ok:!1,layer:d.layer,name:d.name,error:qt(m)}}})),a=[],c=[],l=0;for(let d of s){if(d.ok){l+=1;continue}a.push(`extension_deactivate_failed:${d.layer}:${d.name}`),c.push({layer:d.layer,name:d.name,error:d.error})}return{deactivated:l,warnings:a,failed:c}}function of(e){return typeof e!="number"||e<0?Hi:e===0||e===1/0?0:Number.isFinite(e)?Math.min(nf,Math.max(1,Math.floor(e))):Hi}async function sf(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 af(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let n of e.capabilities){let r=n.trim().toLowerCase();Q(r)&&t.add(r)}return t}function k(e,t,n){let r=af(e);if(r!==null&&!r.has(t))throw H(`${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 cf(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>V.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function lf(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 lr=class{extension;hooks;#e;#n;#o;#r;#s;#a;#i;#c;#t;#l;#d;#u;constructor(t,n,r,o,i,s,a,c,l,d,u){this.#e=t,this.extension=cf(t),this.#n=lf(t),this.#o=n,this.#r=r,this.#s=o,this.#a=i,this.#i=s,this.#c=a,this.#t=c,this.#l=l,this.#d=d,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:m=>this.registerBeforeCommand(m),beforeMutation:m=>this.registerBeforeMutation(m),afterCommand:m=>this.registerAfterCommand(m),onWrite:m=>this.registerOnWrite(m),onRead:m=>this.registerOnRead(m),onIndex:m=>this.registerOnIndex(m)}}allowRegistration(t,n,r,o){let i=ni(this.#u,this.#n,t,n,r,o);return i.warning&&this.#l.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:Xe(o),hint:i}}registerCommandOverride(t,n){let r=O(t);if(r.length===0)throw H("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 H(`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.#l.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 H("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 H("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=O(t.name);if(n.length===0)throw H("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 H(`registerCommand requires a command definition run handler (command="${n}", registration_index=${o.registration_index})`,o)}try{Bo(t);let o=Qn(n,t.action);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:n,action:o}))return;let i=t.description?.trim(),s=t.intent?.trim(),a=Ke("registerCommand definition.examples",t.examples),c=Ke("registerCommand definition.failure_hints",t.failure_hints),l=Zn(t.arguments);t.flags!==void 0&&(k(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(Ut(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Ft("registerCommand definition.flags",t.flags)})));let d={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:o,examples:a,failure_hints:c,arguments:l,tier:t.tier??"standard",family:t.family??"extensions"};i&&(d.description=i),s&&(d.intent=s),this.#t.commands.push(d)}catch(o){let i=qt(o),s=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=H(`registerCommand definition metadata invalid (command="${n}", registration_index=${s.registration_index}): ${i}`,s);this.#l.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${n}`),this.#d.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(k(this.#e,"commands","registerCommand"),typeof t=="string"){this.registerCommandOverride(t,n);return}this.registerCommandDefinition(t)}registerParser(t,n){if(k(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let r=O($("registerParser command",t));et("registerParser override",n),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}registerPreflight(t){if(k(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let n=li(t);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...n})}registerService(t,n,r={}){k(this.#e,"services","registerService");let o=String(t).trim().toLowerCase();if(!bi(o))throw new TypeError(`registerService service must be one of: ${Ae.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(et("registerService override",n),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:n,...xi(r)?{passThrough:!0}:{}}))}registerRenderer(t,n,r={}){if(k(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(!hi(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 O(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(k(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let r=O($("registerFlags targetCommand",t));Ut(n);let o=Ft("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(k(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;Ai(t);let n=Ze("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(k(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;Si(t);let n=Ze("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(k(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=yn();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(k(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;Ti(t);let n=Qe("registerMigration definition",t);this.#t.migrations.push(tt({layer:this.#e.layer,name:this.#e.name,definition:Re("registerMigration definition",t)},n))}registerProfile(t){if(k(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let n=Je(t);Ii(n),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:Ri(n)})}registerImportExportCommandFlags(t,n,r){r.flags!==void 0&&(k(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(Ut(r.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Ft(`${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=Vo(t,s,r?.description!==void 0);S(`${t} options.action`,s.action),S(`${t} options.description`,s.description),S(`${t} options.intent`,s.intent);let c=Qn(n,s.action),l=Ke(`${t} options.examples`,s.examples),d=Ke(`${t} options.failure_hints`,s.failure_hints),u=Zn(s.arguments);this.registerImportExportCommandFlags(t,n,s);let m={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:c,examples:l,failure_hints:d,arguments:u},f=s.description?.trim();f&&(m.description=f);let p=s.intent?.trim();return p&&(m.intent=p),this.#t.commands.push(m),a}registerImporter(t,n,r){if(k(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=Xn($("registerImporter name",t));et("registerImporter importer",n);let i=Jn(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(jn(s,o,"import"))})}registerExporter(t,n,r){if(k(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=Xn($("registerExporter name",t));et("registerExporter exporter",n);let i=Jn(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(jn(a,o,"export"));return s?.receipt==="suppress"&&!xn(c)?ko(c):c}})}registerSearchProvider(t){if(k(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let n=Qe("registerSearchProvider provider",t);this.#t.search_providers.push(tt({layer:this.#e.layer,name:this.#e.name,definition:Re("registerSearchProvider provider",t)},n))}registerVectorStoreAdapter(t){if(k(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let n=Qe("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(tt({layer:this.#e.layer,name:this.#e.name,definition:Re("registerVectorStoreAdapter adapter",t)},n))}registerAssuranceMeasurementProvider(t){if(k(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(ki(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let n=Qe("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(tt({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:Re("registerAssuranceMeasurementProvider provider",t)},n))}registerBeforeCommand(t){k(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(be("beforeCommand",t),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerBeforeMutation(t){k(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(be("beforeMutation",t),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerAfterCommand(t){k(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(be("afterCommand",t),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnWrite(t){k(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(be("onWrite",t),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnRead(t){k(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(be("onRead",t),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnIndex(t){k(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(be("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function df(e,t,n,r,o,i,s,a,c,l,d){return new lr(e,t,n,r,o,i,s,a,c,l,d)}function uf(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 ff(e){let t=[],n=(i,s)=>{let a=new Map;for(let c of i){let l=a.get(c.command)??[];l.push(c),a.set(c.command,l)}for(let c of[...a.keys()].sort((l,d)=>l.localeCompare(d))){let l=a.get(c);if(l.length<=1)continue;let d=l[l.length-1];for(let u of l.slice(0,-1))t.push(`${s}:${c}:${d.layer}:${d.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 l of s)t.push(`extension_command_override_handler_overlap:${i}:${c.layer}:${c.name}:${l.layer}:${l.name}`)}return t}function mf(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 pf(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 _f=new Set(["output_format"]);function gf(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||_f.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 lw(e){let t=Qo(e.policy??Fu),n=Lt(),r=Un(),o=zn(),i=qn(),s=Bn(),a=Vn(),c=Gn(),l=[],d=[];for(let f of e.loaded){let p=Ji(f.module);if(!p)continue;let _=l.length,g=zo({hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await p.activate(df(f,n,r,o,i,s,a,c,d,l,t)),l.length>_&&(g(),d.push(`extension_activation_rolled_back:${f.layer}:${f.name}`))}catch(w){g(),d.push(`extension_activate_failed:${f.layer}:${f.name}`);let v=vi(w);l.push({layer:f.layer,name:f.name,entry_path:f.entry_path,error:qt(w),trace:v})}}let u=[...ff(r),...pf(o),...di(i),...gf(s),...mf(a)],m=[...new Set([...d,...u])];return{hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c,failed:l,warnings:m,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:uf(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]="b2cf7f56-432d-5c74-ba0f-248c42a97255")}catch{}})();(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]="07566a0b-2917-5ed8-828a-d811ae48dfaf")}catch{}})();function pw(){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 o=Promise.all([e,...t]).then(()=>n());return e=o.then(()=>{},()=>{}),o}}}function yf(){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]="40b169fc-3c5f-5b2a-8fed-a9388b07d9f7")}catch{}})();var xe=null,Zi=null,wf=null,vf=null,dr=null,Ef=null,es=null,kf=null;var Of=[],ts=new bf;function C(){return ts.getStore()}function ww(e){return ts.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var Af=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function Qi(e){let t=Y.resolve(e);for(;;){if(hf(Y.join(t,".git")))return t;let n=Y.dirname(t);if(n===t)return;t=n}}function Sf(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),n=Qi(t)??Y.resolve(t),r=Qi(n);if(!e)return{source_workspace_root:n,...r?{repo_root:r}:{}};let o=Y.relative(n,Y.resolve(e)),i=o.length>0&&!o.startsWith(`..${Y.sep}`)&&o!==".."&&!Y.isAbsolute(o);return{source_workspace_root:n,...r?{repo_root:r}:{},...i?{pm_root_rel:o.split(Y.sep).join("/")}:{}}}function vw(e){let t=C();if(t){t.hooks=e;return}xe=e}function Ew(e){let t=C();if(t){t.commands=e;return}Zi=e}function kw(e){let t=C();if(t){t.parsers=e;return}wf=e}function Ow(e){let t=C();if(t){t.preflight=e;return}vf=e}function Aw(e){let t=C();if(t){t.services=e;return}dr=e}function Sw(e){let t=C();if(t){t.renderers=e;return}Ef=e}function Tw(e){let t=C();if(t){t.registrations=e;return}es=e}function Cw(){let e=C();return e?e.registrations:es}function Iw(e){if(!e)return;let t=C();t?t.affectedItems.push(e):Of.push(e)}function Rw(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"||Af.has(i)||Object.hasOwn(r,i)&&r[i]!==void 0&&(n[i]=r[i])}return n}async function ns(e){let t=C(),n=t?t.hooks:xe;return n?rr(n,e):[]}async function xw(e){let t=C(),n=t?t.hooks:xe;n&&await nr(n,e)}async function rs(e){let t=C(),n=t?t.hooks:xe;return n?or(n,e):[]}function Nw(){let e=C();return((e?e.hooks:xe)?.onRead?.length??0)>0}async function Dw(e){let t=C(),n=t?t.hooks:xe;return n?ir(n,e):[]}async function Pw(e){let t=C(),n=t?t.commands:Zi;return n?sr(n,{...e,...Sf(e.pm_root)}):{handled:!1,result:null,warnings:[]}}function os(e,t){let n=C(),r=n?n.commandContext:kf;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 Bt(e,t){let n=C(),r=n?n.services:dr;return r?cr(r,os(e,t)):{handled:!1,result:t,warnings:[]}}function is(e,t){let n=C(),r=n?n.services:dr;return r?ar(r,os(e,t)):{handled:!1,result:t,warnings:[]}}(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]="fd8576c5-0011-5aa2-ad8c-f6ec5715e419")}catch{}})();var Vt="changed_fields",Tf="changed_field_count",ur="rows",Cf=new Set(["apply","rollback"]),ls=new Set(["deleted","would_delete"]),ss=256,as={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function If(e,t){if(!L(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(as,e.action)?as[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return L(s)&&L(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=us(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,fs(e[i],t)]))}}function cs(e){return typeof e!="string"||e.length<=ss?e:`${e.slice(0,ss-1)}\u2026`}function Rf(e){if(!L(e))return null;let t={...e};return t.reason=cs(t.reason),L(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,cs(r)]))),t}function L(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function ds(e){let t=e[Vt];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==Vt&&(n[r]=o);return n[Tf]=t.length,n}function xf(e){return"item"in e&&Array.isArray(e[Vt])}function Nf(e){return typeof e.mode=="string"&&Cf.has(e.mode)&&Array.isArray(e[ur])}function Df(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[ur]=t,n}function us(e){if(!L(e))return null;let t=L(e.item)?e.item:L(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"&&ls.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 Pf(e,t){if(!L(e))return null;if(L(e.plan)&&L(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||!L(e.item)||typeof e.item.id!="string")return null;let n=e[Vt];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&ls.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 Mf(e,e.item,r),r}function Mf(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=Rf(e.recurrence);if(o!==null&&(n.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(n.warnings=e.warnings),L(e.recovery)&&(n.recovery=e.recovery),typeof e.claimed_by=="string"||typeof e.released_by=="string")for(let i of["claimed_by","released_by","previous_assignee","forced","skipped","available","attempts","suggestions"])Object.hasOwn(e,i)&&(n[i]=e[i])}function $f(e){let t=Nf(e)?e[ur]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!L(o))return o;let i=ds(o);return i?(n=!0,i):o});return n?{projected:Df(e,r),changed:!0}:{projected:e,changed:!1}}function fs(e,t={}){let n=If(e,t);if(n!==null)return n;if(t.idOnly===!0){let c=us(e);if(c!==null)return c}if(t.compactEnvelope===!0||t.changedFields==="compact"){let c=Pf(e,t.compactEnvelope===!0);if(c!==null)return c}if((t.changedFields??"full")==="full"||!L(e))return e;let o=!1,i=e,s=xf(e)?ds(e):null;s!==null&&(i=s,o=!0);let a=$f(i);return a.changed&&(i=a.projected,o=!0),o?i:e}import{AsyncLocalStorage as op}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]="b18eefc1-0d1d-5c9c-b98a-b96771070301")}catch{}})();var ms=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),Lf=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function jf(e){let t=e.indexOf("=");return t>0&&ms.has(e.slice(0,t))}function Ff(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function ps(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(ms.has(n)){t+=Ff(n,e[t+1])?1:0;continue}if(!(jf(n)||Lf.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function zw(e){let t=ps(e);return t===void 0?void 0:e[t].trim().toLowerCase()}(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]="4f014bd9-39b6-5017-93ed-f0e7fba8497a")}catch{}})();var _s=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)}"`},gs=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?_s(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,Gt=(e,t=process.platform)=>{let n=e.map(r=>gs(r,t)).join(" ");return n.length>0?`pm ${n}`:"pm"};(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]="49de148c-3c60-547b-b3bc-d0a71e013dc6")}catch{}})();(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]="b3353f90-b9b8-5ef5-918c-b56ec8e747c2")}catch{}})();var ws=new WeakMap;function Yw(e,t){ws.set(e,new Set(t))}var ys='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',Uf={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"}},zf=[{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 Xw(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,y.USAGE)}function W(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 Jw(e,t){let n=zf.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return W([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return W(r)}var qf=[{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 U(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Bf=new Set([void 0,"tabular_when_uniform"]),Vf=new Set(["collection","none"]),Gf=new Set(["supported","unsupported"]);function hs(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 Wf(e){return U(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Vf.has(e.row_kind)&&hs(e.row_keys,!0)&&(e.continuation_row_keys===void 0||hs(e.continuation_row_keys,!1))&&Gf.has(e.fields)&&Bf.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 Kf={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"]},Hf={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 Yf(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=Kf[s];if(a===void 0)return;let c=a.filter(l=>Array.isArray(t[l])||U(t[l]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:ys}:{},toon_encoding:"tabular_when_uniform"}}let o=Uf[r],i=Hf[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((l,d)=>U(l)?l[d]:void 0,t);return Array.isArray(c)||U(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:ys}:{},toon_encoding:"tabular_when_uniform"}})()}function Xf(e){if(!U(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=>U(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 W(r,new Set(o))}function Jf(e){if(!Array.isArray(e.sections_included))return;let t=W(qf,new Set(e.sections_included.filter(n=>typeof n=="string")));return U(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function Qf(e){if(!U(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=ws.get(e),i=a=>n.includes(a)||a==="body"?t:e,s=["body",...n,...r.slice(1)].filter(a=>o===void 0||o.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:`--fields ${a}`}));return W(s,new Set(s.flatMap(({name:a})=>Object.hasOwn(i(a),a)?[a]:[])))}function bs(e){if(U(e.projection))return W([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function Zf(e){if(!U(e.projection))return W([]);if(typeof e.projection.mode=="string")return W([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function em(e){if(!(!U(e.selected)||typeof e.selected.summary!="boolean"))return W([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function tm(e,t){let n=Xf(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return Jf(t);if(r==="get")return Qf(t);if(r==="list"||r.startsWith("list-"))return bs(t);if(r==="search")return bs(t)??W([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return Zf(t);if(r==="contracts")return em(t)}function vs(e,t){if(e===void 0||!U(t))return t;let n=tm(e,t),r=t.row_contract,o=Wf(r)?r:Yf(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 U(i.omission_receipt)||n===void 0?i:{...i,omission_receipt:n}}import{randomUUID as Hm}from"node:crypto";import{randomUUID as Vm}from"node:crypto";import{constants as De}from"node:fs";import{lstat as Bs,mkdir as Gm,open as Gs,rename as Wm,rm as Km}from"node:fs/promises";import Yt from"node:path";import{constants as km}from"node:fs";import q from"node:fs/promises";import Ht from"node:path";import{randomUUID as _r}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]="43f7bd27-7874-56f9-a497-e6f67a3ae9be")}catch{}})();function Es(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import nm from"node:crypto";import{AsyncLocalStorage as rm}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]="38ed5847-939e-5846-bc7d-6d257d36a25f")}catch{}})();var Os=new rm,ks=1024;function As(){let e=Os.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 nv(e){let t=Os.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>ks)throw new Error(`Reproducible token length must be an integer between 0 and ${ks}`);let n="";for(;n.length<e;){let r=nm.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]="9f856b31-35f8-50e9-b780-f65fc43a60d9")}catch{}})();var om=/^([+-]?)(\d+)([hdwm])$/i,im=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,sm=/^(\d{4})(\d{2})(\d{2})$/,am=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,cm=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,lm=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,dm=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function Ts(){return As()??new Date().toISOString()}function cv(e){return Number.isFinite(Date.parse(e))}function um(e){let t=dm.exec(e);if(!t||!Number.isFinite(Date.parse(e)))return!1;let[,n,r,o,i,s,a,c,l]=t,[d,u,m,f,p,_]=[n,r,o,i,s,a].map(Number);return u>=1&&u<=12&&m>=1&&m<=pr(d,u-1)&&f<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(l===void 0||Number(l)<=59)}function lv(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return um(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var fm=1e4,Wt=new Map;function Ss(e){let t=Wt.get(e);if(t!==void 0)return t;let n=Date.parse(e);return Wt.size>=fm&&Es(Wt),Wt.set(e,n),n}function Ne(e,t){let n=Ss(e),r=Ss(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function dv(e,t){return!(t.deadlineBefore&&(!e.deadline||Ne(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||Ne(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&Ne(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&Ne(e.updated_at,t.updatedBefore)>0||t.createdAfter&&Ne(e.created_at,t.createdAfter)<0||t.createdBefore&&Ne(e.created_at,t.createdBefore)>0)}function fr(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function mr(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 mm(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function pm(e){let t=[],n=l=>mm(t,e,l),r=sm.exec(e);if(r){let[,l,d,u]=r;n(`${l}-${d}-${u}`)}let o=am.exec(e);if(o){let[,l,d,u,m,f,p,_,g]=o,w=p?`:${p}`:"";n(`${l}-${d}-${u}T${m}:${f}${w}${fr(_)}${mr(g)}`)}let i=cm.exec(e);if(i){let[,l,d,u,m,f,p]=i,_=m?`:${m}`:"";n(`${l}T${d}:${u}${_}${fr(f)}${mr(p)}`)}let s=lm.exec(e);if(s){let[,l,d,u,m,f,p]=s,_=m?`:${m}`:"";n(`${l}T${d}:${u}${_}${fr(f)}${mr(p)}`)}let a=10,c=e.slice(0,a);if(gm(c)){let l=a;for(;l<e.length&&ym(e[l]);)l+=1;l<e.length&&n(`${c}T${e.slice(l)}`)}return t}function _m(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of pm(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function gm(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 ym(e){return e?e===" "||e===" "||e===`
9
- `||e==="\r"||e==="\f"||e==="\v":!1}function pr(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var hm=["January","February","March","April","May","June","July","August","September","October","November","December"],bm=/^(\d{4})-(\d{2})-(\d{2})/,wm=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function vm(e,t,n){let r=bm.exec(t)??wm.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.`,y.USAGE,{field:a,value:e});let c=pr(o,i-1);if(s<1||s>c)throw new h(`Invalid ${a} value "${e}". ${hm[i-1]} ${o} has ${c} days, so day "${r[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,y.USAGE,{field:a,value:e})}function Em(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,pr(i,s));return n.setUTCFullYear(i,s,a),n}function uv(e,t=new Date,n="deadline"){let r=e.trim();if(r.toLowerCase()==="now")return t.toISOString();let o=om.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 Em(t,a).toISOString();let l=c==="h"?3600*1e3:c==="d"?1440*60*1e3:10080*60*1e3;return new Date(t.getTime()+a*l).toISOString()}vm(e,r,n);let i=_m(r);if(!Number.isFinite(i)){let s=n.trim().length>0?n.trim():"deadline",a=im.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}`,y.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]="f0484213-41f9-583e-bd0f-f85e507682b2")}catch{}})();function Om(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},warnings:[]}}async function Kt(e,t=!0){try{let n=await q.readFile(e,"utf8");return t&&await rs({path:e,scope:"project"}),Om(n)}catch(n){return ge(n)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function X(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function Am(e,t,n=process.platform){if(X(e,"EEXIST"))return!0;if(!X(e,"EPERM")&&!X(e,"EACCES")&&!X(e,"EBUSY"))return!1;try{return await q.lstat(t),!0}catch(r){if(n!=="win32"||!ge(r)&&!X(r,"EPERM")&&!X(r,"EACCES")&&!X(r,"EBUSY"))return!1}try{return await q.access(Ht.dirname(t),km.W_OK),!0}catch{return!1}}async function Ds(e,t){await ns({path:e,scope:"project",op:t})}function Sm(e,t,n,r=_r()){return{id:e,pid:process.pid,owner:t,token:r,created_at:Ts(),ttl_seconds:n}}async function Tm(e,t,n,r,o){await q.mkdir(Ht.dirname(e),{recursive:!0});let i=await br(e,t);if(i===null)throw Object.assign(new Error("Lock initialization is contended"),{code:"EEXIST"});try{let s=await q.open(e,"wx");try{try{await s.writeFile(`${JSON.stringify(Sm(t,n,r,o),null,2)}
10
- `,"utf8")}finally{await s.close()}}catch(a){throw await gr(e,"lock:release"),a}}finally{await i()}await Ds(e,"lock:create")}async function gr(e,t){try{return await q.unlink(e),await Ds(e,t),!0}catch{return!1}}async function Cm(e,t,n,r){let o=Date.now(),i=Ms;for(;;){let s=await br(e,t);if(s!==null){try{let l=await Kt(e,!1);Cs(l.info,t,n,r)&&await gr(e,"lock:release")}finally{await s()}return}let a=await Kt(e,!1);if(!Cs(a.info,t,n,r))return;let c=Date.now()-o;if(c>=Is)return;await js(Math.min(i,Is-c)),i=Math.min(i*2,yr)}}function Cs(e,t,n,r){return e?.id===t&&e.pid===process.pid&&e.owner===n&&e.token===r}function Ps(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}function Im(e){return e?.owner?` (owner ${e.owner})`:""}var Ms=25,yr=200,Rm=250,xm=3,Nm=".stale-cleanup",$s="owner.json",Ls=1e4,Is=Ls+yr,Dm=60*6e4;function Rs(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 Pm(e){let t=process.env.PM_LOCK_WAIT_MS,n=Rs(t);if(n!==void 0)return n;let r=Rs(e);return r!==void 0?r:0}function js(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(n=>setTimeout(n,t))}function Fs(e,t,n){let r=n>0?` after waiting ${n}ms`:"";return new h(`Item ${e} is locked${Im(t)}${r}`,y.CONFLICT,{code:"lock_conflict",recovery:{retry_after_ms:Rm}})}function Mm(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}function $m(e,t,n,r){if(!n&&r){let o=t.warnings.length>0?` (${t.warnings.join(",")})`:"";throw new h(`Item ${e} lock is stale${o}; rerun with --force when supported for this command`,y.CONFLICT)}}function Lm(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,...typeof i=="string"?{process_start_identity:i}:{}}}async function Us(e){try{return Lm(await q.readFile(Ht.join(e,$s),"utf8"))}catch{return null}}function jm(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!X(t,"ESRCH")}}function Fm(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 zs(e){try{return Fm(await q.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function Um(e=process.pid){let t=await zs(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function zm(e,t,n){if(!jm(e.pid))return!1;let r=await zs(e.pid);return e.process_start_identity!==void 0&&r!==null?r===e.process_start_identity:t<=n}async function hr(e){try{return await q.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function xs(e,t){let n=await Us(e);n===null||n.token!==t||await hr(e)}async function Ns(e){try{await q.mkdir(e)}catch(n){return X(n,"EEXIST"),null}let t={...await Um(),token:_r()};try{await q.writeFile(Ht.join(e,$s),`${JSON.stringify(t)}
11
- `,"utf8")}catch{return await hr(e),null}return t}async function qm(e){let t;try{let r=await q.stat(e);if(t=Date.now()-r.mtimeMs,t<=Ls)return!1}catch(r){return ge(r)}let n=await Us(e);return n!==null&&await zm(n,t,Dm)?!1:hr(e)}async function br(e,t){let n=`${e}${Nm}`,r=await Ns(n);if(r!==null)return async()=>xs(n,r.token);if(!await qm(n))return null;let o=await Ns(n);return o===null?null:async()=>xs(n,o.token)}async function Bm(e){let t=await br(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};if(!Ps(n.info,e.ttlSeconds))return{lockInfo:n,shouldRetryCreate:!1,staleRemovalCounted:!1};if($m(e.id,n,e.force,e.forceRequiredForStaleLock),e.staleRemovals>=xm)throw Fs(e.id,n.info,Date.now()-e.startedAtMs);return{lockInfo:n,shouldRetryCreate:await gr(e.lockPath,"lock:stale_remove"),staleRemovalCounted:!0}}finally{await t()}}async function qs(e,t,n,r,o=!1,i=!0,s){let a=await Bt("lock_acquire",{pm_root:e,id:t,ttl_seconds:n,owner:r,force:o,force_required_for_stale_lock:i});if(a.handled){let p=Mm(a.result);if(p)return async()=>{await Promise.resolve(p()),await Bt("lock_release",{pm_root:e,id:t,owner:r})}}let c=Uo(e,t),l=Pm(s),d=Date.now(),u=0,m=Ms,f=_r();for(;;)try{return await Tm(c,t,r,n,f),async()=>{await Cm(c,t,r,f),await Bt("lock_release",{pm_root:e,id:t,owner:r})}}catch(p){if(!await Am(p,c))throw new h(`Failed to acquire lock for ${t}: ${Ao(p)}`,y.GENERIC_FAILURE);let _=await Kt(c);if(Ps(_.info,n)){let w=await Bm({lockPath:c,id:t,ttlSeconds:n,force:o,forceRequiredForStaleLock:i,staleRemovals:u,waitBudgetMs:l,startedAtMs:d,fallbackLockInfo:_});if(_=w.lockInfo,w.staleRemovalCounted&&(u+=1),w.shouldRetryCreate)continue}let g=Date.now()-d;if(l===0||g>=l)throw Fs(t,_.info,l===0?0:g);await js(Math.min(m,l-g)),m=Math.min(m*2,yr)}}(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]="72eb01a9-e8b8-59cd-b178-3c594d3faff9")}catch{}})();var J={max_serving_rows:256,max_bytes:262144,max_event_bytes:32768,retained_byte_fraction:.5,max_events:2048,retention_days:30},I=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function Ee(e){let t=Date.parse(e.now??new Date().toISOString());if(!Number.isFinite(t))throw new I("Context usage now must be a valid timestamp");return{iso:new Date(t).toISOString(),ms:t}}function Ws(e){let t=e.maxBytes??J.max_bytes,n=e.maxEvents??J.max_events,r=e.retentionDays??J.retention_days;if(!Number.isSafeInteger(t)||t<1024||t>J.max_bytes||!Number.isSafeInteger(n)||n<1||!Number.isFinite(r)||r<=0)throw new I("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");return{maxBytes:t,maxEvents:n,cutoff:Ee(e).ms-r*864e5}}async function Ks(e,t){if(!(await Bs(Yt.dirname(e))).isDirectory())throw new I("Context usage runtime must be a real directory");try{if((await Bs(e)).isSymbolicLink())throw new I("Context usage ledger must not be a symbolic link")}catch(r){if(!ge(r))throw r}let n=await Gs(e,t|De.O_NOFOLLOW|De.O_NONBLOCK,384);try{let r=await n.stat();if(!r.isFile()||r.nlink!==1)throw new I("Context usage ledger must be an unshared regular file");return n}catch(r){throw await n.close(),r}}async function Xt(e){let t=Ws(e);try{let n=await Ks(Yt.join(e.pmRoot,"runtime","context-usage.jsonl"),De.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(`
12
- `)?a.slice(a.indexOf(`
13
- `)+1):"":a).split(`
14
- `).flatMap(l=>{try{let d=JSON.parse(l);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await n.close()}}catch{return[]}}function Vs(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])}
15
- `;if(o+=Buffer.byteLength(s),o>t)break;r.push(s)}return r.reverse().join("")}async function rt(e,t,n){let r=Ws(e),o=Yt.join(e.pmRoot,"runtime","context-usage.jsonl"),i=Math.floor(r.maxBytes*J.retained_byte_fraction),s=Math.min(J.max_event_bytes,i);if(t.some(m=>Buffer.byteLength(`${JSON.stringify(m)}
16
- `)>s))throw new I("Context usage event exceeds the declared byte ceiling");let a=t.filter(m=>Date.parse(m.at)>=r.cutoff),c=Vs(a,i,r.maxEvents),l=performance.now(),d=await qs(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),u=performance.now()-l;try{await Gm(Yt.dirname(o),{recursive:!0});let m=await Ks(o,De.O_WRONLY|De.O_CREAT|De.O_APPEND);try{let f=(await m.stat()).size,p=n===void 0?void 0:await Xt(e);if(p?.some(R=>R.kind==="delivery"&&R.serve_id===n))return{written_bytes:0,ledger_bytes:f,compacted:!1,lock_wait_ms:u};if(!(e.maxEvents!==void 0||e.retentionDays!==void 0)&&f+Buffer.byteLength(c)<=r.maxBytes)return await m.writeFile(c,"utf8"),{written_bytes:Buffer.byteLength(c),ledger_bytes:f+Buffer.byteLength(c),compacted:!1,lock_wait_ms:u};let g=Vs([...p??await Xt(e),...a],i,r.maxEvents),w=`${o}.${process.pid}.${Vm()}.tmp`,v=await Gs(w,"wx",384);try{try{await v.writeFile(g,"utf8")}finally{await v.close()}return await m.close(),m=void 0,await Wm(w,o),{written_bytes:Buffer.byteLength(g),ledger_bytes:Buffer.byteLength(g),compacted:!0,lock_wait_ms:u}}finally{await Km(w,{force:!0})}}finally{await m?.close()}}finally{await d()}}(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]="3b38d564-6034-54ae-ad24-eddba01a2c5c")}catch{}})();var Ym=864e5,Jt=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function N(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Mv(e,t){let n=N(e);n!==null&&t!==null&&(n[Jt]=t)}function Qt(e,t){let n=N(e),r=N(t),o=n?.[Jt];r!==null&&o!==void 0&&(r[Jt]=o)}function Xm(e){return N(e)?.[Jt]??null}function Ys(e){let t=N(e);for(let n of["read_output","context_intent"])if(N(t?.[n])?.result_omitted===!0)return!0;return!1}function ie(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function Xs(e,t){if(Array.isArray(t))for(let n of t)ie(e,N(n)?.id)}function Hs(e,t){if(Array.isArray(t))for(let n of t)ie(e,n)}function Jm(e,t){let n=N(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=N(r);ie(t,o?.id);for(let i of Array.isArray(o?.blockers)?o.blockers:[])ie(t,N(i)?.id);for(let i of Array.isArray(o?.unblocks)?o.unblocks:[])ie(t,i)}}function Qm(e,t){for(let n of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])Xs(t,e[n]);for(let n of Array.isArray(e.blockers)?e.blockers:[])ie(t,N(n)?.blocked_by);Zm(e,t)}function Zm(e,t){for(let o of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=N(o);ie(t,i?.id),Xs(t,i?.children)}for(let o of["files","workload"])for(let i of Array.isArray(e[o])?e[o]:[])Hs(t,N(i)?.items);let n=N(e.agenda);for(let o of Array.isArray(n?.events)?n.events:[])ie(t,N(o)?.item_id);let r=N(e.tests);Hs(t,r?.items_failing)}function ep(e,t){let n=N(e);if(n===null||Ys(e))return[];let r=new Set;return t==="next"?Jm(n,r):Qm(n,r),[...r]}async function $v(e){let t=Xm(e.result);if(t===null)return!1;let n=Ys(e.result);return await tp({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:ep(e.result,t.surface),resultOmitted:n}),!0}async function Lv(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 I("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 I("Context usage serving requires unique normalized row ids");let n=t.slice(0,J.max_serving_rows),r={serve_id:Hm(),author:e.author.trim(),surface:e.surface,rows:t,recorded_item_ids:n.map(o=>o.id)};return r.storage=await rt(e,[{kind:"serve",schema_version:2,serve_id:r.serve_id,at:Ee(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 tp(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 I("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:Ee(e).iso,author:e.receipt.author,surface:e.receipt.surface,result_omitted:e.resultOmitted,delivered_item_ids:n.filter(i=>r.has(i))};await rt(e,[o],o.serve_id)}async function jv(e){if(!(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)){if(!e.author.trim()||!e.itemId.trim()||!e.intent.trim())throw new I("Context usage touch requires author, itemId, and intent");await rt(e,[{kind:"touch",at:Ee(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function Fv(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 I("Context usage touch requires author and intent");let r=new Set;for(let s of e.itemIds){if(typeof s!="string")throw new I("Context usage touch requires string itemIds");let a=s.trim();if(!a)throw new I("Context usage touch requires non-empty itemId");r.add(a)}let o=Ee(e).iso,i=[...r].map(s=>({kind:"touch",at:o,author:t,item_id:s,intent:n}));await rt(e,i)}function np(e,t,n,r){return e.find(({entry:o,time:i})=>o.item_id===t&&i>=n&&i-n<=r)?.time}function rp(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 Uv(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 Xt(e),n=Ee(e).ms,r=(e.horizonHours??24)*36e5;if(![Number.isFinite(r),r>0].every(Boolean))throw new I("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,l=0,d=rp(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 p=Date.parse(f.at),_=d.get(f.serve_id),g=new Set(_?.delivered_item_ids??[]);for(let w of f.rows){if(!g.has(w.id))continue;let v=np(i,w.id,p,r);if(v===void 0)continue;l+=1;let R=Math.max(0,(n-v)/Ym);s.set(w.id,(s.get(w.id)??0)+Math.exp(-R/14))}});let u=Math.max(0,...s.values());return{affinity:Object.fromEntries([...s.entries()].map(([f,p])=>[f,u===0?.05:.05+.95*p/u])),positive_judgments:l,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]="aa8baa4d-a287-5be7-8429-69bb5ace633f")}catch{}})();var Zs=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"}]),ea=new op;function ip(){return ea.getStore()??Zs}function Xv(e,t){return ea.run(ap(e.workspaceContracts,e.packageContracts),t)}function sp(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 ap(e=[],t=[]){let n=[{source:"core",contracts:Zs,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=sp(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 ta(e,t,n=ip(),r=[]){let o=e.trim().toLowerCase(),i=t.trim().toLowerCase(),s=n.find(m=>m.command===o&&m.intent===i);if(s)return{...s,source:s.source??"core"};let a=n.filter(m=>m.command===o).map(m=>m.intent);if(a.length===0)return;let c=a.map(m=>{let f=Array.from({length:i.length+1},(p,_)=>_);for(let p=1;p<=m.length;p+=1){let _=f[0];f[0]=p;for(let g=1;g<=i.length;g+=1){let w=f[g];f[g]=Math.min(f[g]+1,f[g-1]+1,_+(m[p-1]===i[g-1]?0:1)),_=w}}return{candidate:m,distance:f[i.length]}}).sort((m,f)=>m.distance-f.distance||m.candidate.localeCompare(f.candidate))[0].candidate,l=[o,...r,"--for",i],d=[o,...r,"--for",c],u=Gt(d);throw new h(`Unknown context intent "${i}" for ${o}. Did you mean "${c}"?`,y.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:Gt(l),allowed_values:[...a].sort(),suggested_retry:u,suggested_retry_args:d}})}var na={context:(e,t,n)=>{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 r=en(e.tokenBudget,t.token_budget),o=tn("context",t.intent,r,n),i=ke(e.limit),s=String(i===void 0?o:Math.min(i,o));(e.limit===void 0||i!==void 0)&&(e.limit=s),e.activityLimit===void 0&&(e.activityLimit=s)},get:e=>{e.depth===void 0&&e.fields===void 0&&(e.depth="standard")},list:(e,t,n)=>{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 r=en(e.tokenBudget,t.token_budget),o=tn("list",t.intent,r,n),i=ke(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))},next:e=>{e.readyOnly===void 0&&(e.readyOnly=!0)},search:(e,t,n)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let r=en(e.tokenBudget,t.token_budget),o=tn("search",t.intent,r,n),i=ke(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))}};function Jv(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",y.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 a={...t,tokenBudget:r};return delete a.token_budget,a}let o=ta(e,t.for,void 0,n),i=ke(r)!==void 0,s={...t};return s.tokenBudget===void 0&&r!==void 0&&(s.tokenBudget=r),delete s.token_budget,s.tokenBudget===void 0&&(s.tokenBudget=String(o.token_budget)),na[e](s,o,i),s}var cp={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},Zt=256;function wr(e){return Array.isArray(e)?e.map(wr):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,wr(n)])):typeof e=="string"&&e.length>240?`${e.slice(0,240)}\u2026`:e}function ke(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 en(e,t){let n=ke(e);if(n===void 0)return t;if(n<Zt)throw new h(`Context intent token budget must be at least ${Zt}`,y.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(e),required:`Use an integer token budget of at least ${Zt}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${Zt} or omit the override.`]});return n}function tn(e,t,n,r){if(e==="get"||e==="next")return;let o=e==="context"&&t==="orient",i=e==="context"?o?1200:800:e==="list"?520:480,s=e==="context"?o?600:500:16,a=Math.max(e==="context"?1:2,Math.floor((n-i)/s));return r?a:Math.min(e==="context"?20:100,a)}function se(e,t){let n=t.estimated_tokens;for(;;){t.estimated_tokens=n;let r=Math.ceil(Buffer.byteLength(JSON.stringify(e),"utf8")/4);if(r===n)return;n=r}}var Js={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 ra(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 lp(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 dp(e,t,n){let r=!1;for(;;){if(se(e,t),t.estimated_tokens<=t.token_budget||n.length<=1)return r;let o=Buffer.byteLength(JSON.stringify(n),"utf8"),i=(t.estimated_tokens-t.token_budget)*4;n.splice(-Math.min(n.length-1,Math.max(1,Math.ceil(i/Math.max(1,Math.ceil(o/n.length)))))),r=!0}}function up(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=ra(i);if(s===void 0)return!1;let a=r.length,c=[...r],l=!1;for(;;){if(l=dp(e,t,r)||l,!l)return!1;let d=lp(r.at(-1));if(d===void 0)return r.splice(0,r.length,...c),se(e,t),!1;if(e.next_cursor=Ge(s.fingerprint,d,o?s.after_index-(a-r.length):s.after_index+r.length,s.snapshot),se(e,t),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 fp(e,t,n,r){if(e==="list"||e==="search")return up(t,n,r);if(e!=="next"||typeof t.next_cursor=="string")return!1;let o=!1;for(;;){if(se(t,n),n.estimated_tokens<=n.token_budget)return o;let i=Js[e].map(m=>({key:m,rows:Array.isArray(t[m])?t[m]:[]})).filter(({rows:m})=>m.length>0).sort((m,f)=>f.rows.length-m.rows.length||m.key.localeCompare(f.key))[0];if(i===void 0)return o;let s=Js[e].reduce((m,f)=>m+(Array.isArray(t[f])?t[f].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"),l=Math.max(1,Math.ceil(c/i.rows.length)),d=(n.estimated_tokens-n.token_budget)*4,u=Math.min(a,Math.max(1,Math.ceil(d/l)));i.rows.splice(-u,u),o=!0}}function mp(e,t,n){if(typeof t.for!="string")return n;let r=e.startsWith("list-")?"list":e;if(!(r in na))return n;let o=r,i=ta(o,t.for),s=en(t.tokenBudget??t.token_budget,i.token_budget),a={command:o,intent:i.intent,source:i.source,included_field_groups:[...i.included_field_groups],token_budget:s,declared_token_budget:i.token_budget,token_budget_override:s-i.token_budget,estimated_tokens:0,within_budget:!0,degradation:cp[o],declaration_feasible:!0,result_omitted:!1},c={...n},l=tn(o,i.intent,a.token_budget,ke(t.tokenBudget??t.token_budget)!==void 0);if(l!==void 0){let u=ke(t.limit),m=u!==void 0&&u<l;a.budget_derived_limit=l,a.binding_constraint=m?"explicit_limit":"token_budget",a.limit_reason=m?"The caller supplied a smaller row limit than the budget-derived ceiling.":"The selected intent token budget constrains the effective row ceiling.",c.budget_derived_limit=l}let d={...c,context_intent:a};return se(d,a),a.estimated_tokens>a.token_budget&&(a.degradation="recursive_budget_compaction",d={...wr(c),context_intent:a},se(d,a)),a.estimated_tokens>a.token_budget&&fp(o,d,a,t)&&(a.degradation="budget_row_compaction",se(d,a)),a.declaration_feasible=a.estimated_tokens<=a.declared_token_budget,a.estimated_tokens>a.token_budget&&(a.degradation="budget_receipt_only",a.result_omitted=!0,a.within_budget=!1,d={budget_exceeded:{omitted_result:!0,reason:a.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:_p(e,o,i.intent,a,c)},context_intent:a}),d}function pp(e,t){if(typeof e.after!="string"||e.after.length===0)return t;let n=ra(e.after)?.fingerprint??"opaque_cursor",r={...t};for(let o of["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"])delete r[o];return r.continuation_contract={fingerprint:n,metadata:"reference",restore_with:"omit --after"},r}function Er(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _p(e,t,n,r,o){let i=t==="get"&&Er(o.item)&&typeof o.item.id=="string"?o.item.id:t==="search"&&typeof o.query=="string"?o.query:void 0,s=i===void 0?"":` '${i.replaceAll("'",`'"'"'`)}'`,a=t==="get"?"":` --limit ${r.budget_derived_limit??1}`;return`pm ${e}${s} --for ${n} --token-budget ${Math.ceil(r.estimated_tokens/100)*100}${a}`}function Pe(e,t){if(Er(e))return typeof e[t]=="number"?e[t]:void 0}function gp(e,t){let n=e;for(let r=0;r<8;r+=1){let o=Pe(n.context_intent,"estimated_tokens"),i=Pe(n.read_output,"estimated_tokens"),s=Pe(n.read_session,"spent_this_call_tokens");if(Er(n.context_intent)&&se(n,n.context_intent),n=vr(n,t),Pe(n.context_intent,"estimated_tokens")===o&&Pe(n.read_output,"estimated_tokens")===i&&Pe(n.read_session,"spent_this_call_tokens")===s)break}return n}function yp(e,t,n){let r=vs(e,n),o=typeof r=="object"&&r!==null&&!Array.isArray(r)?Qs(e??"",{...t,outputRowContract:t.outputRowContract===!0||t.output_row_contract===!0},pp(t,mp(e??"",t,r))):r;if(Qt(n,o),t.outputRowContract===!0||t.output_row_contract===!0||typeof o!="object"||o===null||Array.isArray(o)||!Object.hasOwn(o,"row_contract"))return 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=gp(i,t);return delete s.row_contract,Qt(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]="83c82348-64f8-5f10-9396-b03add0b7932")}catch{}})();var Me=["result_rows","envelope","diagnostics","hints"],hp=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,bp=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,wp=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,vp=8;function kr(e){return Buffer.byteLength(e,"utf8")}function oa(e){return kr(JSON.stringify(e)??"null")}function Ep(e,t){return bp.test(e)?"diagnostics":wp.test(e)?"hints":hp.test(e)||Array.isArray(t)?"result_rows":"envelope"}function kp(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"]=oa(e),t;for(let[n,r]of Object.entries(e))t[Ep(n,r)]+=oa({[n]:r});return Object.values(t).every(n=>n===0)&&(t.envelope=1),t}function Op(e,t){let n=Me.reduce((s,a)=>s+t[a],0),r=Me.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-Me.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))||Me.indexOf(a.section)-Me.indexOf(c.section))){if(i===0)break;o[s.section]+=1,i-=1}return o}function ia(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function Ap(e,t){let n=kr(t(e)),r=Op(n,kp(e)),o=Object.fromEntries(Me.map(a=>[a,{bytes:r[a],estimated_tokens:pe(r[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:n,total_estimated_tokens:pe(n),sections:o,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=ia(e,i);for(let a=0;a<vp;a+=1){let c=kr(t(s))-n;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:pe(c)},s=ia(e,i)}return s}import{encode as ca}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]="2ca9480d-0ae4-50e8-887e-c4183501d92c")}catch{}})();var pE=new Set(Object.values(y));var sa=!1;function B(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Or(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function Cp(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.SUCCESS)}function Ip(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.GENERIC_FAILURE)}function Ar(e){if(e==="stdout"){Cp();return}Ip()}function aa(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function Rp(){sa||(sa=!0,process.stdout.on("error",e=>{if(Or(e)){Ar("stdout");return}aa(e)}),process.stderr.on("error",e=>{if(Or(e)){Ar("stderr");return}aa(e)}))}function xp(e,t){Rp();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(n){if(Or(n))return Ar(e),!1;throw n}}function Np(e){return xp("stderr",e)}function Sr(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function Dp(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function la(e){if(e.length===0||!e.every(B))return!1;let t=Object.keys(e[0]);return t.length>0&&e.every(n=>Object.keys(n).length===t.length&&t.every(r=>Object.hasOwn(n,r)&&Dp(n[r])))}function da(e,t){let n=" ".repeat(t);return e.split(`
17
- `).map(r=>`${n}${r}`).join(`
18
- `)}function Pp(e,t,n){let r=" ".repeat(n);return!B(t)&&!Array.isArray(t)?`${r}${e}: ${Sr(t)}`:Array.isArray(t)&&t.length===0?`${r}${e}: []`:Array.isArray(t)&&la(t)?da(ca({[e]:t}),n):B(t)&&Object.keys(t).length===0?`${r}${e}: {}`:`${r}${e}:
19
- ${Cr(t,n+1)}`}function Tr(e){if(e!=null){if(Array.isArray(e)){let t=e.map(n=>Tr(n)).filter(n=>n!==void 0);return t.length>0?t:void 0}if(B(e)){let t={};for(let[n,r]of Object.entries(e)){if(n==="omitted_field_groups"&&Array.isArray(r)&&r.length===0){t[n]=[];continue}let o=Tr(r);o!==void 0&&(t[n]=o)}return Object.keys(t).length>0?t:void 0}return e}}function Cr(e,t){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":la(e)?da(ca(e),t):e.map(r=>{if(!B(r)&&!Array.isArray(r))return`${n}- ${Sr(r)}`;let i=Cr(r,t+1).split(`
20
- `),[s,...a]=i;return a.length===0?`${n}- ${s.trimStart()}`:`${n}- ${s.trimStart()}
21
- ${a.join(`
22
- `)}`}).join(`
23
- `);if(B(e)){let r=Object.entries(e);return r.length===0?"{}":r.map(([o,i])=>Pp(o,i,t)).join(`
24
- `)}return`${n}${Sr(e)}`}function Mp(e){if(!B(e)||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!B(e.projection)||e.projection.mode!=="brief"||!B(e.completeness)||e.completeness.status!=="complete"||[e.completeness.unreadable_item_count,e.completeness.unreadable_directory_count].some(u=>u!==0)||[e.has_more,e.truncated].some(u=>u!==!1)||e.count!==e.items.length||e.total!==e.count||!B(e.omission_receipt)||JSON.stringify(e.omission_receipt.omitted_field_groups)!==JSON.stringify([{name:"full_item_fields",restore_with:"--full"}]))return e;let{total:t,has_more:n,truncated:r,next_cursor:o,completeness:i,projection:s,now:a,omission_receipt:c,sorting:l,...d}=e;return{...d,...B(l)&&l.sort==="default"?{}:{sorting:l},details:"--full"}}function ua(e,t){if(t==="json")return`${JSON.stringify(e,null,2)}
25
- `;let n=Tr(Mp(e));return n===void 0?`{}
26
- `:`${Cr(n,0)}
27
- `}function _E(e){let t=is("error_format",{message:e}),n=t.handled&&typeof t.result=="string"?t.result:e;Np(n.endsWith(`
28
- `)?n:`${n}
29
- `)}(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]="d8631828-9fb8-5cdf-b448-43787147b44e")}catch{}})();var $p=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 D(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function fa(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(!D(n))return;n=n[r]}return n}function Ir(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 l=Number(a),d=[...i];return d[l]=o(i[l],s+1),d}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function ma(e,t,n){let r=$e(e).find(s=>s.path===t);if(!r)return e;let o=Array.isArray(r.value)?r.value.slice(n):Object.fromEntries(Object.entries(r.value).slice(n)),i=Ir(e,t,o);return D(i.summary)&&D(i.summary.focus_row_states)&&typeof i.summary.focus_row_states[t]=="string"&&(i.summary={...i.summary,focus_row_states:{...i.summary.focus_row_states,[t]:i.summary.focus_row_states[t].slice(n)}}),st(i),i}function rn(e){let t=e.row_contract;return D(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 Lp(e){let t=e.row_contract;return D(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):rn(e)}function ae(e){return rn(e).flatMap(t=>{let n=fa(e,t);return Array.isArray(n)||D(n)?[{path:t,value:n}]:[]})}function $e(e){return Lp(e).flatMap(t=>{let n=fa(e,t);return Array.isArray(n)||D(n)?[{path:t,value:n}]:[]})}function ot(e){let t=ae(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(D(o))for(let[s,a]of Object.entries(o))i.length===0&&$p.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function on(e){return ae(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function it(e,t){let n=e;for(let r of ae(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=Ir(n,r.path,o)}return n}function pa(e,t){let n=e,r=!1;for(let o of ae(n)){let i=Array.isArray(o.value)?o.value:Object.entries(o.value);if(i.length<=t)continue;r=!0;let s=Array.isArray(o.value)?i.slice(0,t):Object.fromEntries(i.slice(0,t));n=Ir(n,o.path,s)}return{result:n,truncated:r}}var _a=["high_level","low_level","blocked_fallback"];function nn(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function yE(e,t){if(!D(e.summary)||!D(e.summary.returned_focus))return;let n=new Map(t.map(r=>[r.id,r]));e.summary={...e.summary,focus_row_states:Object.fromEntries(_a.map(r=>[r,Array.isArray(e[r])?e[r].filter(D).map(o=>nn(n.get(o.id)??o)).join(""):""]))}}function jp(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 Fp(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(D):[],i=jp(r[n],o.length)??o.map(nn).join(""),s=new Map(o.flatMap((d,u)=>d.id===void 0?[]:[[d.id,i[u]]])),a=Array.isArray(e[n])?e[n].filter(D):[],c=!1;return{states:a.map((d,u)=>{let m=s.get(d.id)??(d.id===void 0?i[u]:void 0)??nn(d);return m!==nn(d)&&(c=!0),m}).join(""),needsStates:c}}function Up(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 st(e,t=e){if(Up(e,t),!D(e.summary)||!D(e.summary.returned_focus))return;let n={...e.summary},r=D(t.summary)&&D(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=_a.map(c=>({key:c,...Fp(e,t,c,r)})),i=Object.fromEntries(o.map(({key:c,states:l})=>[c,l])),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]="29f010b6-6214-5669-8c2e-0a0833496df3")}catch{}})();var zp=8,qp=64,Bp=5,Vp=4,ga=100;function ya(e,t,n){if(e!=="get"||!Rr(n.item)||["fields","outputInclude","output_include","outputCursor","output_cursor"].some(l=>t[l]!==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(l=>Object.hasOwn(n,l)),s=Object.fromEntries(Object.entries(n).filter(([l])=>!o.includes(l)));s.item=Object.fromEntries(Object.entries(r).filter(([l])=>l!=="body")),Object.hasOwn(r,"body")&&i.push("body");let c=[...Rr(n.omission_receipt)&&Array.isArray(n.omission_receipt.omitted_field_groups)?n.omission_receipt.omitted_field_groups:[],...i.map(l=>({name:l,restore_with:`--fields ${l}`}))];return s.omission_receipt={has_omissions:c.length>0,omitted_field_group_count:c.length,omitted_field_groups:c},s}function Nr(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*Bp/Vp),i=Math.ceil(o/ga)*ga;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 Le(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 at(e,t){let n=t===void 0?JSON.stringify(e):ua(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function Rr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function xr(e,t,n=!1){return typeof e=="string"?n||e.length<=240?e:(t.compacted=!0,`${e.slice(0,240)}\u2026`):Array.isArray(e)?e.map(r=>xr(r,t,n)):Rr(e)?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,xr(o,t,n||r==="focus_row_states")])):e}function ce(e,t,n){let r=t.estimated_tokens;for(let o=0;o<zp;o+=1){t.estimated_tokens=r;let i=at(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function Gp(e,t){return ot(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 Wp(e,t,n,r,o,i){for(let s=0;s<qp;s+=1){if(i?.(e),ce(e,t,o),t.estimated_tokens<=n)return;let a=Gp(e,r);if(!a)return;let c=Math.max(1,r.get(a.path)??0),l=Array.isArray(a.value)?[...a.value]:Object.entries(a.value),d=p=>{if(Array.isArray(a.value)){a.value.length=p;for(let _=0;_<p;_+=1)a.value[_]=l[_]}else{for(let _ of Object.keys(a.value))delete a.value[_];Object.defineProperties(a.value,Object.getOwnPropertyDescriptors(Object.fromEntries(l.slice(0,p))))}typeof e.count=="number"&&(e.count=on(e)),a.path==="items"&&(e.applied_limit=p),i?.(e),ce(e,t,o)};t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],a.path])].sort((p,_)=>p.localeCompare(_)),e.has_more=!0,e.truncated=!0;let u=c,m=l.length-1,f=c;for(;u<=m;){let p=Math.floor((u+m)/2);d(p),t.estimated_tokens<=n?(f=p,u=p+1):m=p-1}d(f)}}function ha(e,t,n,r=new Map,o,i,s=!1){let a={compacted:!1},c=Object.fromEntries(Object.entries(e).map(([l,d])=>[l,xr(d,a,s&&l==="diff")]));return Le(e,c),t.strings_compacted=a.compacted,c.read_output=t,Wp(c,t,n,r,o,i),ce(c,t,o),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]="999accf0-d4e1-5dc4-92a0-4ea7d745ac48")}catch{}})();var Dr=256,Pr=1e4,Kp=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,ba=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Hp=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),Yp=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&Kp.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=Dr,reason:`token_budget must be a safe integer of at least ${Dr}.`},{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<=Pr&&e.seen_item_ids.every(t=>typeof t=="string"&&ba.test(t)),reason:`seen_item_ids must contain at most ${Pr} portable item identifiers.`}];function an(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function sn(e){throw new h(`--output-session ${e}`,y.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function cn(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{sn("must be a valid JSON object.")}an(t)||sn("must be a JSON object.");let n=Object.keys(t).filter(i=>!Hp.has(i));n.length>0&&sn(`contains unknown field "${n.sort()[0]}".`);let r=Yp.find(i=>!i.valid(t));r!==void 0&&sn(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 wa(e){if(an(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:an(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function Xp(e){let t=new Set,n=0,r=ae(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(!an(c))continue;if(typeof c.context_ref=="string"){n+=1;continue}let l=wa(c);l!==void 0&&ba.test(l)&&t.add(l)}}return{deliveredIds:t,suppressedRepeatCount:n}}function va(e,t){let n=new Set(t.seen_item_ids);return it(e,r=>{let o=wa(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function Mr(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=Xp(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,Pr-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),l=s.length-a.length,d={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,...l===0?{}:{seen_item_overflow_count:l},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --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:d},m=_=>{d.spent_this_call_tokens=_,d.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,_),d.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+d.charged_this_call_tokens),d.remaining_tokens=Math.max(0,t.token_budget-d.spent_total_tokens),d.exhausted=d.remaining_tokens<Dr,d.next_state.spent_tokens=d.spent_total_tokens},f=0,p=0;for(let _=0;_<8;_+=1){m(f);let g=at(u,n);if(g===f)return u;p=Math.max(p,g),f=g}return m(p),u}function Ea(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]="c649c902-db30-5a05-982e-46669ca96148")}catch{}})();var ct=Symbol.for("pm.readOutputInvocationProvenance");function TE(e,t){return Reflect.set(e,ct,{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]="d1ed05d5-c83a-555c-95f5-5b2f62b9bc64")}catch{}})();var Oe=["include","amount","cost","encoding"],xa=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","files","docs","stats","aggregate","duplicates","package-catalog","package-manage","comments-audit","assurance"],Na=["canonical","legacy","intent","default"],dt=Nt,qE=Object.freeze(Oe.map(e=>dt[e])),BE=Dt,Da={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"],cost:["--token-budget"],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"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},Pa=new Set(["--collapse","--fields","--section"]),jr=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.","--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 Fr(e){return e.slice(2).replaceAll("-","_")}function Jp(e,t){let n=jr[e];if(n!==void 0)return n;let r=t==="include"?Pa.has(e)?"<csv>":Fr(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${dt[t]} ${r}.`}function Qp(e){let t=Da[e],n=Object.freeze(Object.fromEntries(Oe.map(r=>[r,Object.freeze({dimension:r,canonical_option:dt[r],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[r]??[]).map(o=>Object.freeze({flag:o,semantics:jr[o]===void 0?"replacement":"behavior_preserving",migration_hint:Jp(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:Na,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...Ur(e).keys()])})}var Zp=Object.freeze(xa.map(Qp)),e_=new Map(Zp.map(e=>[e.command,e]));function Fe(e,t={}){let n=qe(e.trim().toLowerCase()),o=n==="package catalog"||n==="packages catalog"||n==="package-catalog"||(n==="package"||n==="packages"||n==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":n==="package manage"||n==="package-manage"?"package-manage":n.split(" ")[0],i=o.startsWith("list-")?"list":o==="ctx"?"context":o;return xa.includes(i)?i:void 0}var t_=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],n_={comments:["add","body","stdin","file","edit","delete"],notes:["add","addJson","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 r_(e){return t_.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var o_=[{keys:["outputInclude","output_include"],valid:e=>lt(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||je(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||je(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(cn(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."}];function VE(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.",y.USAGE);if(!r_(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.`,y.USAGE);if((n_[r]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new h(`Universal output controls cannot be combined with a ${r} mutation.`,y.USAGE);for(let o of o_){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,y.USAGE)}}function Ur(e){let t=Fe(e);return t?new Map((Da[t].include??[]).filter(n=>!Pa.has(n)&&jr[n]===void 0).map(n=>[Fr(n),Ma(n)])):new Map}function i_(e,t,n){let r=lt(t)??[],o=Ur(e),i=[],s=[],a=n,c=a[ct],l=new Set(c?.canonical_include_modes??[]),d=new Set(c?.explicit_legacy_aliases??[]);for(let f of r){let p=o.get(f);if(p===void 0){i.push(f);continue}let _=`--${f.replaceAll("_","-")}`;La($a(n,_))&&d.add(_),n[p]=!0,s.push(f),l.add(f)}let u=Fe(e)==="get"?i.filter(f=>f!=="item"):[],m=u.length>0;return m&&(n.fields=[...new Set([...lt(n.fields)??[],...u])].join(","),l.add("fields")),(s.length>0||m)&&(a[ct]={canonical_include_modes:[...l],explicit_legacy_aliases:[...d],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function GE(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=i_(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 Ma(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}function $a(e,t){let n=Ma(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 La(e){return e!==void 0&&e!==!1&&e!==null}function lt(e){let n=(Array.isArray(e)?e:[e]).flatMap(r=>typeof r=="string"?r.split(","):[]).map(r=>r.trim()).filter(Boolean);return n.length>0?[...new Set(n)]:void 0}function je(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 s_(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=$a(t,o.flag),s={value:i,flag:o.flag};if(La(i)&&n(s))return s}}function ka(e,t){let n=lt(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:lt(t.value)??[Fr(t.flag)]}}function Oa(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=je(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=je(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function Aa(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=je(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let r=je(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function Sa(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 a_(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 c_(e,t,n){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function l_(e,t){return Oe.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[dt[n]]:[])}function ja(e,t){let n=Fe(e,t);if(!n)return;let r=e_.get(n),o=t[ct],i={include:v=>ka(void 0,v),amount:v=>Oa(void 0,v),cost:v=>Aa(void 0,v),encoding:v=>Sa(void 0,v)},s=Object.fromEntries(Oe.map(v=>[v,s_(r.dimensions[v],t,R=>i[v](R)!==void 0,R=>a_(o,v,R))])),a=Oe.flatMap(v=>{let R=s[v];return R?[R.flag]:[]}),c=Oe.flatMap(v=>{let R=s[v];return R?[r.dimensions[v].legacy_aliases.find(mt=>mt.flag===R.flag).migration_hint]:[]}),l=Sa(t.outputFormat??t.output_format,s.encoding),d=ka(t.outputInclude??t.output_include,s.include),u=Oa(t.outputLimit??t.output_limit,s.amount),m=Aa(t.outputBudget??t.output_budget,s.cost),f=c_(e,s,o),p=yo(e,{generateFallback:!0}),_=l?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",g=m??(f?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:d,amount:u,cost:g,encoding:l,canonical_options_used:l_({include:d,amount:u,cost:g,encoding:l},o),legacy_aliases_used:a,migration_hints:c,precedence:Na}}function j(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var zr=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"]),d_=["collection_counts","notes_count","tests_count"];function Fa(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function u_(e){let t=j(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...d_.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!zr.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 f_(e,t){let n=u_(e),r=t.filter(u=>!n.valid.includes(u));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,y.USAGE);let o=t.includes("item"),i=t.flatMap(u=>u.startsWith("item.")?[u.slice(5)]:n.itemFields.includes(u)?[u]:[]).filter((u,m,f)=>f.indexOf(u)===m);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.",y.USAGE);let s=new Set(t.filter(u=>n.sections.includes(u))),a=Object.fromEntries(Object.entries(e).filter(([u])=>zr.has(u)||s.has(u)));o?a.item=n.item:i.length>0&&(a.item=Fa(n.item,i));let c=[...o?[]:i.length>0?n.itemFields.filter(u=>!i.includes(u)).map(u=>({name:`item.${u}`,restore_with:`--output-include item.${u}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(u=>!s.has(u)).map(u=>({name:u,restore_with:`--output-include ${u}`}))],d=[...j(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 Ta(e){let t=0;return it({...e},n=>(j(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function m_(e,t,n,r){if(Ta(t)===0||Ta(n)>0)return;let o=[...Ur(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}`,y.USAGE)}function p_(e,t,n){if(e==="get")return f_(t,n);let r=rn(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=it(s,l=>j(l)?Fa(l,a):l);return m_(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||zr.has(s)))}function __(e,t){if(t==="unbounded")return e;let{result:n,truncated:r}=pa(e,t);if(!r)return n;if(n.has_more=!0,n.truncated=!0,typeof n.count=="number"){let o=j(n.projection)?n.projection.row_key:void 0;n.count=typeof o=="string"&&Array.isArray(n[o])?n[o].length:on(n)}return n.applied_bound={kind:"output_limit",source:"explicit",value:t},n}function g_(e){return Oe.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(dt[t]))}function Ua(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function dn(e,t,n,r){let o=Mr(e,t,r);Le(e,o);for(let i=0;i<8;i+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;ce(o,n,r);let c=o;o=Mr(o,t,r),Le(c,o);let l=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&l===a)return o}return o}function vr(e,t){if(!j(e.read_output))return e;let n=Ua(t),r=e.read_output,o=cn(t.outputSession??t.output_session);return o===void 0?(ce(e,r,n),e):dn(e,o,r,n)}function y_(e,t){if(e!=="validate")return t;let n=j(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(u=>j(u)&&u.name==="diagnostic_rows"))return t;let o=[...new Set(ot(t).map(({path:u})=>u).filter(u=>/^checks\.\d+\.details\./u.test(u)))],i=o.filter(u=>!o.some(m=>m!==u&&u.startsWith(`${m}.`)));if(i.length===0)return t;let s=j(t.row_contract)?t.row_contract:{},a=Array.isArray(s.row_keys)?s.row_keys.filter(u=>typeof u=="string"):[],c=Array.isArray(s.continuation_row_keys)?s.continuation_row_keys.filter(u=>typeof u=="string"):[],l=a.length>0?a:i,d=[...new Set(i)];return JSON.stringify(l)===JSON.stringify(a)&&JSON.stringify(d)===JSON.stringify(c)?t:{...t,row_contract:{...s,row_keys:l,continuation_row_keys:d,jq_selector:typeof s.jq_selector=="string"?s.jq_selector:".checks[].details"}}}function h_(e,t,n,r){let o={...e};if(t.include?.source==="canonical"&&(o=p_(t.command,o,t.include.value)),t.command==="assurance"&&(o=Ia(o)),st(o,e),o=Ra(o,t.command,r),t.command==="history"&&r){let s=["compact_history","provenance_history","history","diff"];if(o=Object.fromEntries(Object.entries(o).filter(([a])=>!s.includes(a)||a===r.path)),j(o.projection)&&(o.projection={...o.projection,row_key:r.path}),j(o.row_contract)){let a=o.row_contract;o.row_contract={...a,row_keys:[r.path],...Array.isArray(a.continuation_row_keys)?{continuation_row_keys:[r.path]}:{}}}o.count=Object.keys(o[r.path]).length}let i=e.count_only===!0?{...o,count_only:!0,count:e.count}:o;return t.amount?.source==="canonical"&&(o=__(o,t.amount.value)),st(o,i),n===void 0?o:va(o,n)}function b_(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:Ea(t)}]].sort((r,o)=>r.tokens-o.tokens)[0]}function za(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function w_(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...r.source==="default"?{budget_source:r.source,budget_tokens:r.tokens}:{},precedence:e.precedence,...za(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:dn(a,n,s,i);if(n===void 0&&ce(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.",y.USAGE);return c}function v_(e,t){return 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 E_(e,t,n,r,o){if(t!==void 0||v_(e,o))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(ae(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"||at(o.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,r)<=e.cost.value}function k_(e,t,n,r,o,i,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map($e(e).map(p=>[p.path,Array.isArray(p.value)?p.value.length:Object.keys(p.value).length])),l=[...s.entries()].flatMap(([p,_])=>{let g=c.get(p);if(g>=_.rows)return[];let w=_.baseOffset+g;return[{path:p,cursor:$r({command:t.command,path:p,offset:w,total_rows:_.totalRows,fingerprint:_.fingerprint}),retained_rows:g,remaining_rows:_.totalRows-w,total_rows:_.totalRows}]}),d=l[0],u=d?"; page --output-cursor":"",m=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=[m,...t.migration_hints];let f=Nr({effective_budget_tokens:r.tokens,measured_result_tokens:i});d&&!o&&(typeof e.next_cursor!="string"||e.continuation_kind==="output_cursor")&&(e.next_cursor=d.cursor),e.continuation_kind=o?"producer_cursor":d?"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:l.length>0,recovery_budget_multiplier:d?1:f.recovery_budget_multiplier,continuations:l,restore_with:d?"recovery":`Retry with --output-budget ${f.output_budget} because no declared row collection can be continued.`,recovery:d?{cursor:d.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${f.output_budget}`,sdk:{outputBudget:f.output_budget},mcp:{outputBudget:f.output_budget}}}}function O_(e,t,n,r){if(typeof n!="string"||!Array.isArray(e.items))return!1;let o=e.items.length;if(o===0||o>=t)return!1;let i;try{i=On(n)}catch{return!1}let s=i.after_index;if(s===void 0)return!1;let a=e.items.at(-1);if(Object.prototype.toString.call(a)!=="[object Object]")return!1;let c=Reflect.get(a,"id");if(typeof c!="string"||c.length===0)return!1;let l=r?s-(t-o):s+o;return l<0?!1:(e.next_cursor=Ge(i.fingerprint,c,l,i.snapshot),!0)}function A_(e,t,n,r){let o=new Map($e(e).map(s=>{let a=Array.isArray(s.value)?s.value.length:Object.keys(s.value).length,c=n?.path===s.path;return[s.path,{rows:a,totalRows:c?n.total_rows:a,baseOffset:c?n.offset:0,fingerprint:c?n.fingerprint:ln(s.path,s.value,t)}]})),i=typeof e.next_cursor=="string";return{collectionsBeforeBudget:o,originalItemCount:Array.isArray(e.items)?e.items.length:0,cursorContinuesExistingPage:i,cursorSource:i?e.next_cursor:r.after}}function S_(e,t,n,r,o,i,s,a,c,l){let d={...t,count_only:n},u=r.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(f=>j(f)&&f.verdict!=="pass").length:0,m=new Map;if(u>0&&m.set("assertions",u),r.command==="history"&&Array.isArray(e.diff))for(let f of ot(e))f.path.startsWith("diff.")&&m.set(f.path,Object.keys(f.value).length);return ha(e,o,i.tokens,m,l,f=>{st(f,d);let p=O_(f,a.originalItemCount,a.cursorSource,a.cursorContinuesExistingPage);if(k_(f,r,o,i,p,c,a.collectionsBeforeBudget),r.command==="history"&&j(f.projection)){f.has_more=typeof f.next_cursor=="string"||f.applied_bound?.kind==="output_limit";let _=f.projection.row_key;typeof _=="string"&&Array.isArray(f[_])&&(f.count=f[_].length)}s!==void 0&&Object.assign(f,dn(f,s,o,l))},r.command==="history"&&Array.isArray(e.diff))}function Qs(e,t,n){let r=ja(e,t);if(!r)return n;let o=Ua(t),i=cn(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?Lr(s):void 0,c=g_(r),l=y_(r.command,n);if(a===void 0&&E_(r,i,l,o,t))return l;let d=b_(r,i),u=h_(l,r,i,a);Le(u,u,t.outputRowContract===!1);let m={contract_version:1,command:r.command,requested_dimensions:c,...d?.source==="default"?{budget_source:d.source,budget_tokens:d.tokens}:{},precedence:r.precedence,...za(r),legacy_aliases_used:r.legacy_aliases_used,migration_hints:r.migration_hints,estimated_tokens:0,within_budget:!0,strings_compacted:!1,rows_compacted:!1,result_omitted:!1};if(u.read_output=m,u=i===void 0?u:dn(u,i,m,o),ce(u,m,o),d!==void 0&&m.estimated_tokens>d.tokens){let f=ya(r.command,t,u);f!==void 0&&(m.applied_depth="brief",m.degradation_reason="output_budget_reached",Le(u,f),u=vr(f,t)),m.estimated_tokens>d.tokens&&(u=S_(u,u,l.count_only===!0,r,m,d,i,A_(u,r.command,a,t),m.estimated_tokens,o))}return d!==void 0&&m.estimated_tokens>d.tokens?w_(r,c,i,d,m.estimated_tokens,o):u}function Sp(e){return j(e)&&j(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function Tp(e,t){let n=t.outputFormat??t.output_format;if(n==="json"||n==="toon")return n;let r=ja(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]="de370088-9285-5b33-8c7f-da8e9bb88286")}catch{}})();var C_=4096,I_=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"]),Ca=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:I_}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function ft(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ut(e){return Array.isArray(e)?e.map(ut):ft(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,ut(n)])):e}function qa(e,t){if(!ft(e))return ut(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||!ft(i)?[o,ut(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!r.includes(s)).map(([s,a])=>[s,ut(a)]))]))}function R_(e,t){return Array.isArray(e)?e.map(n=>qa(n,t)):qa(e,t)}function ln(e,t,n){let r=n?Ca[n]:void 0,o=r?.paths.includes(e)===!0;return T_("sha256").update(de({path:e,value:o?R_(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function $r(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint}),"utf8").toString("base64url")}function Lr(e){if(e.length>C_)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!ft(t)||t.v!==1||Fe(String(t.c??""))!==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)throw new h("The read-output continuation cursor is malformed or unsupported.",y.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}}function Ia(e){if(!Array.isArray(e.assertions))return e;let t=n=>!ft(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 Ra(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,y.USAGE,{code:"read_output_cursor_command_mismatch"});let r=$e(e).find(i=>i.path===n.path),o=r?Array.isArray(r.value)?r.value.length:Object.keys(r.value).length:0;if(!r||o!==n.total_rows||n.offset>o||ln(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.",y.USAGE,{code:"read_output_cursor_stale"});return ma(e,n.path,n.offset)}(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]="e216fd39-09ee-5a04-b0b5-44f518db4f93")}catch{}})();function ek(e){let t=e?.trim()??"";return/^[A-Za-z][A-Za-z0-9+.-]*:\/\//u.test(t)||/^(?:github|gitlab|jira|linear):/iu.test(t)}function tk(e){let t=e?.trim().toLowerCase();return t==="global"||t==="external"}export{V as a,pt as b,un as c,x_ as d,_t as e,gt as f,yt as g,ht as h,xt as i,oo as j,wn as k,nl as l,rl as m,O as n,Ba as o,Vr as p,D_ as q,P_ as r,Gr as s,M_ as t,$_ as u,L_ as v,j_ as w,F_ as x,U_ as y,z_ as z,q_ as A,B_ as B,V_ as C,G_ as D,W_ as E,K_ as F,Va as G,H_ as H,Y_ as I,X_ as J,J_ as K,Q_ as L,Z_ as M,eg as N,gi as O,Wa as P,Ka as Q,Ha as R,wt as S,Ya as T,ig as U,Ue as V,Ja as W,Qa as X,fn as Y,sg as Z,ag as _,y as $,h as aa,gu as ba,ui as ca,fi as da,Di as ea,Pi as fa,ec as ga,tc as ha,mn as ia,gn as ja,yn as ka,_g as la,gg as ma,yg as na,dc as oa,Yr as pa,hg as qa,wo as ra,Cn as sa,vo as ta,ge as ua,xy as va,Ny as wa,Dy as xa,Py as ya,My as za,In as Aa,Nn as Ba,By as Ca,Gl as Da,Gy as Ea,Wy as Fa,Ky as Ga,Ao as Ha,So as Ia,Hy as Ja,Yy as Ka,Xy as La,Ro as Ma,Jl as Na,No as Oa,Lo as Pa,ih as Qa,$n as Ra,ld as Sa,sh as Ta,kd as Ua,Od as Va,ah as Wa,ch as Xa,yh as Ya,hh as Za,bh as _a,Fo as $a,jo as ab,wh as bb,vh as cb,Eh as db,Uo as eb,kh as fb,At as gb,Eg as hb,Lt as ib,Un as jb,zn as kb,qn as lb,Bn as mb,Vn as nb,Gn as ob,Hn as pb,ai as qb,de as rb,G as sb,Ng as tb,Dg as ub,Uu as vb,qu as wb,Bu as xb,Ju as yb,aw as zb,cw as Ab,lw as Bb,bc as Cb,wc as Db,vc as Eb,Ec as Fb,hn as Gb,Og as Hb,kc as Ib,qe as Jb,St as Kb,Ag as Lb,Sg as Mb,Tg as Nb,Ig as Ob,Es as Pb,Pc as Qb,Zr as Rb,bn as Sb,Lc as Tb,jc as Ub,Ct as Vb,to as Wb,Uc as Xb,Bc as Yb,Fg as Zb,Ug as _b,Kc as $b,Hc as ac,Yc as bc,Gg as cc,Wg as dc,Xc as ec,It as fc,Kg as gc,Hg as hc,Jc as ic,Qc as jc,Zc as kc,ro as lc,Rt as mc,el as nc,Yg as oc,Xg as pc,Jg as qc,Qg as rc,Zg as sc,ey as tc,ty as uc,pw as vc,yf as wc,ol as xc,vn as yc,al as zc,cl as Ac,ww as Bc,Sf as Cc,vw as Dc,Ew as Ec,kw as Fc,Ow as Gc,Aw as Hc,Sw as Ic,Tw as Jc,Cw as Kc,Iw as Lc,Rw as Mc,ns as Nc,xw as Oc,rs as Pc,Nw as Qc,Dw as Rc,Pw as Sc,Bt as Tc,fs as Uc,ms as Vc,ps as Wc,zw as Xc,gs as Yc,Gt as Zc,Yw as _c,Xw as $c,Jw as ad,vs as bd,_y as cd,gy as dd,Ge as ed,On as fd,An as gd,yy as hd,fl as id,hy as jd,by as kd,pl as ld,Oy as md,_o as nd,_l as od,Ol as pd,Sl as qd,go as rd,Tl as sd,Cl as td,yo as ud,pe as vd,ho as wd,Ay as xd,Sy as yd,yE as zd,st as Ad,Ca as Bd,ln as Cd,$r as Dd,Lr as Ed,TE as Fd,Oe as Gd,xa as Hd,qE as Id,BE as Jd,Zp as Kd,Fe as Ld,VE as Md,Ur as Nd,i_ as Od,GE as Pd,ja as Qd,vr as Rd,Qs as Sd,Sp as Td,Tp as Ud,nv as Vd,Ts as Wd,cv as Xd,um as Yd,lv as Zd,Ne as _d,dv as $d,uv as ae,Um as be,zm as ce,qs as de,J as ee,I as fe,Mv as ge,Qt as he,ep as ie,$v as je,Lv as ke,tp as le,jv as me,Fv as ne,Uv as oe,Zs as pe,ip as qe,Xv as re,ap as se,ta as te,Jv as ue,ra as ve,lp as we,mp as xe,yp as ye,Ap as ze,Np as Ae,ua as Be,_E as Ce,Nr as De,at as Ee,Pr as Fe,cn as Ge,va as He,Mr as Ie,Ea as Je,ek as Ke,tk as Le};
30
- //# sourceMappingURL=chunk-KG3H4UZZ.js.map