@unbrained/pm-cli 2026.10.18 → 2026.10.19

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 (146) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +10 -0
  3. package/dist/cli/help-content.js +2 -2
  4. package/dist/cli/register-mutation.js +2 -2
  5. package/dist/cli/register-setup.js +1 -1
  6. package/dist/cli-bundle/bundle-manifest.json +1 -1
  7. package/dist/cli-bundle/chunks/chunk-4CXQSRSP.js +126 -0
  8. package/dist/cli-bundle/chunks/{chunk-AETP4JEM.js → chunk-4ICKT4GH.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-7WIEAGDS.js → chunk-4MJ6WBMA.js} +2 -2
  10. package/dist/cli-bundle/chunks/chunk-4XFVAXA4.js +2 -0
  11. package/dist/cli-bundle/chunks/{chunk-FIJOSX2C.js → chunk-5GZSX5HU.js} +72 -66
  12. package/dist/cli-bundle/chunks/{chunk-4GA4MUTE.js → chunk-6DS5CAN2.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-6VZKYJW7.js → chunk-D3EDNAN7.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-DMFM5R4G.js +3 -0
  15. package/dist/cli-bundle/chunks/chunk-H3XYP24A.js +70 -0
  16. package/dist/cli-bundle/chunks/chunk-LBEMB3BW.js +6 -0
  17. package/dist/cli-bundle/chunks/chunk-NX7Q4LGN.js +8 -0
  18. package/dist/cli-bundle/chunks/chunk-O2ZRRLAP.js +8 -0
  19. package/dist/cli-bundle/chunks/chunk-OEJ3G7XT.js +20 -0
  20. package/dist/cli-bundle/chunks/{chunk-PYRREEUB.js → chunk-QBNEZII5.js} +28 -28
  21. package/dist/cli-bundle/chunks/chunk-QG4LMU7A.js +112 -0
  22. package/dist/cli-bundle/chunks/chunk-QKAAZWGC.js +3 -0
  23. package/dist/cli-bundle/chunks/chunk-RUKSEZE7.js +2 -0
  24. package/dist/cli-bundle/chunks/chunk-TK3G3GAP.js +2 -0
  25. package/dist/cli-bundle/chunks/chunk-VS565KBX.js +2 -0
  26. package/dist/cli-bundle/chunks/{chunk-ZZED447K.js → chunk-XH7C3A5N.js} +2 -2
  27. package/dist/cli-bundle/chunks/indexed-receipt-blobs-BVSHK4WQ.js +4 -0
  28. package/dist/cli-bundle/chunks/{register-list-query-PUCVYYBD.js → register-list-query-WQUVDJIH.js} +2 -2
  29. package/dist/cli-bundle/chunks/register-mutation-IWIBQIO3.js +20 -0
  30. package/dist/cli-bundle/chunks/register-operations-SUWOZNDU.js +2 -0
  31. package/dist/cli-bundle/chunks/register-setup-QGM5YJW7.js +2 -0
  32. package/dist/cli-bundle/chunks/settlement-hook-UNFMCKKQ.js +7 -0
  33. package/dist/cli-bundle/chunks/stage-7DELI4Z5.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-2MPQUMTF.js → chunk-2IEWB6MB.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/chunk-3TEIACFU.js +3 -0
  36. package/dist/cli-bundle/focused-chunks/chunk-5YTOYBTZ.js +65 -0
  37. package/dist/cli-bundle/focused-chunks/chunk-AK2CI2GI.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-BJMPRB7A.js +91 -0
  39. package/dist/cli-bundle/focused-chunks/{chunk-BFEMT5U3.js → chunk-ENZMATOY.js} +3 -3
  40. package/dist/cli-bundle/focused-chunks/chunk-EOQ6W25I.js +8 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-A4ZHHTEX.js → chunk-FEN7WOOP.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/chunk-FOA7XKWP.js +2 -0
  43. package/dist/cli-bundle/focused-chunks/chunk-GWTV45SB.js +2 -0
  44. package/dist/cli-bundle/focused-chunks/{chunk-ZDBS2DCT.js → chunk-H6BVQ63U.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/{chunk-IRVL4UXR.js → chunk-HYMYAGSY.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-JBJJW2WL.js +6 -0
  47. package/dist/cli-bundle/focused-chunks/chunk-JCLC6HKT.js +8 -0
  48. package/dist/cli-bundle/focused-chunks/{chunk-TB7F4FCR.js → chunk-JDBO7SMR.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/{chunk-TZUIBG3P.js → chunk-KLJN44VY.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/chunk-L4PL3GZR.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/chunk-OV2WVLUR.js +2 -0
  52. package/dist/cli-bundle/focused-chunks/chunk-PXDR77TO.js +78 -0
  53. package/dist/cli-bundle/focused-chunks/chunk-RLRMNFLF.js +3 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-Z7YIFCNE.js → chunk-SKYLOPU2.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/chunk-VVRXF4JO.js +2 -0
  56. package/dist/cli-bundle/focused-chunks/chunk-WZTEFFQI.js +3 -0
  57. package/dist/cli-bundle/focused-chunks/chunk-Y54ONBEX.js +25 -0
  58. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-QW2VWWJE.js +4 -0
  59. package/dist/cli-bundle/focused-chunks/settlement-hook-X4FNHTOD.js +7 -0
  60. package/dist/cli-bundle/focused-chunks/stage-MZSVQYO4.js +2 -0
  61. package/dist/cli-bundle/main.js +3 -3
  62. package/dist/cli-bundle/sdk-authoring.js +1 -1
  63. package/dist/cli-bundle/sdk-contracts.js +1 -1
  64. package/dist/cli-bundle/sdk-core.js +28 -22
  65. package/dist/cli-bundle/sdk-governance.js +1 -1
  66. package/dist/cli-bundle/sdk-graph.js +1 -1
  67. package/dist/cli-bundle/sdk-merge.js +66 -53
  68. package/dist/cli-bundle/sdk-query.js +1 -1
  69. package/dist/cli-bundle/sdk-runtime.js +1 -1
  70. package/dist/cli-bundle/sdk-testing.js +1 -1
  71. package/dist/cli-bundle/sdk.js +2 -2
  72. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
  73. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  74. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  75. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +1 -0
  76. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  77. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  78. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  79. package/dist/sdk/extension/install-sources.js +3 -3
  80. package/dist/sdk/extension/shared.js +1 -1
  81. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  82. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  83. package/dist/sdk/governance/health.js +1 -1
  84. package/dist/sdk/history-repair.js +1 -1
  85. package/dist/sdk/merge/driver.js +7 -1
  86. package/dist/sdk/merge/indexed-receipt-blobs.d.ts +2 -0
  87. package/dist/sdk/merge/indexed-receipt-blobs.js +4 -0
  88. package/dist/sdk/merge/install.d.ts +8 -0
  89. package/dist/sdk/merge/install.js +3 -3
  90. package/dist/sdk/merge/receipts.d.ts +6 -0
  91. package/dist/sdk/merge/receipts.js +2 -2
  92. package/dist/sdk/merge/reconcile.d.ts +6 -0
  93. package/dist/sdk/merge/reconcile.js +1 -1
  94. package/dist/sdk/merge/settlement-hook.d.ts +12 -0
  95. package/dist/sdk/merge/settlement-hook.js +7 -0
  96. package/dist/sdk/merge/stage.d.ts +13 -0
  97. package/dist/sdk/merge/stage.js +2 -0
  98. package/dist/sdk/public-surface.json +1 -1
  99. package/dist/sdk/query/list.js +1 -1
  100. package/dist/sdk/runtime-extended-actions.js +1 -1
  101. package/docs/COMMANDS.md +13 -0
  102. package/docs/CONFIGURATION.md +14 -0
  103. package/docs/MERGE_SAFETY.md +88 -5
  104. package/docs/SDK.md +26 -0
  105. package/docs/TESTING.md +7 -0
  106. package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
  107. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +6 -3
  108. package/marketplace.json +1 -1
  109. package/package.json +1 -1
  110. package/packages/pm-beads/package.json +1 -1
  111. package/packages/pm-calendar/package.json +1 -1
  112. package/packages/pm-command-kit/package.json +1 -1
  113. package/packages/pm-digital-twin/package.json +1 -1
  114. package/packages/pm-governance-audit/package.json +1 -1
  115. package/packages/pm-guide-shell/package.json +1 -1
  116. package/packages/pm-kanban/package.json +1 -1
  117. package/packages/pm-lifecycle-hooks/package.json +1 -1
  118. package/packages/pm-linked-test-adapters/package.json +1 -1
  119. package/packages/pm-search-advanced/package.json +1 -1
  120. package/packages/pm-templates/package.json +1 -1
  121. package/packages/pm-todos/package.json +1 -1
  122. package/packages/pm-vcs/package.json +1 -1
  123. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  124. package/plugins/pm-claude/package.json +1 -1
  125. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  126. package/plugins/pm-codex/package.json +1 -1
  127. package/plugins/pm-codex/plugin.json +1 -1
  128. package/runtime-dependencies.json +1 -1
  129. package/dist/cli-bundle/chunks/chunk-4V6ONLI6.js +0 -3
  130. package/dist/cli-bundle/chunks/chunk-7PATQWTH.js +0 -20
  131. package/dist/cli-bundle/chunks/chunk-LUKVNL72.js +0 -2
  132. package/dist/cli-bundle/chunks/chunk-OJ77ZQN3.js +0 -8
  133. package/dist/cli-bundle/chunks/chunk-RHQJ6VWC.js +0 -237
  134. package/dist/cli-bundle/chunks/chunk-RNABUEFB.js +0 -80
  135. package/dist/cli-bundle/chunks/chunk-TO6CIV4C.js +0 -2
  136. package/dist/cli-bundle/chunks/register-mutation-GGGVBXD5.js +0 -20
  137. package/dist/cli-bundle/chunks/register-operations-NRZ6Q4QE.js +0 -2
  138. package/dist/cli-bundle/chunks/register-setup-MV3P3YSF.js +0 -2
  139. package/dist/cli-bundle/focused-chunks/chunk-5UKCSZWT.js +0 -2
  140. package/dist/cli-bundle/focused-chunks/chunk-B4YLP5ZB.js +0 -3
  141. package/dist/cli-bundle/focused-chunks/chunk-FW7CSSKL.js +0 -75
  142. package/dist/cli-bundle/focused-chunks/chunk-HYPRPSYD.js +0 -3
  143. package/dist/cli-bundle/focused-chunks/chunk-L55KQ2KT.js +0 -2
  144. package/dist/cli-bundle/focused-chunks/chunk-MASIOFPG.js +0 -8
  145. package/dist/cli-bundle/focused-chunks/chunk-RJ3EIHDU.js +0 -26
  146. package/dist/cli-bundle/focused-chunks/chunk-SEL4Z2OO.js +0 -167
@@ -0,0 +1,112 @@
1
+ import{A as Tr,B as h,D as g,F as ft,G as ke,H as le,I as ge,J as Gc,K as Ci,L as mt,M as Kc,b as Ce,c as Ti,d as Uc,f as Rn,g as xn,h as Nn,i as Hc,j as Dn,k as Ht,l as qc,n as ze,o as Vc,p as Bc,q as Pn,r as Mn,v as Ir,w as Wc,z as S}from"./chunk-QKAAZWGC.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="451b262c-a9b6-5f1c-b397-2686a5fd953a")}catch{}})();var T_=[["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"})),C_=[...["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"})),R_=[["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"})),x_=[...C_,...R_,...["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,r])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:r}))],Ri=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...T_,...x_,...["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 OI(e){let t;for(let r of Ri)r.canonical_argv.length<=(t?.canonical_argv.length??0)||r.canonical_argv.every((n,o)=>n===(o===0&&e[o]==="ctx"?"context":e[o]))&&(t=r);return t}function N_(e){let t=e.trim().replace(/\s+/gu," ");return Ri.find(r=>r.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function Cr(e){return N_(e)}var $n=[...Ri,...[["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,r])=>({alias:e,canonical:t,canonical_argv:[t,r],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"}))],AI=Object.fromEntries($n.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function II(e){let t=e.trim().toLowerCase();return $n.find(r=>r.alias===t)}function TI(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]="2ea7934f-4751-5245-a5ba-492681aa3794")}catch{}})();var xi=[{kind:"blocked_by",direction:"directed",traversal:"ordering",inverse:"blocks",ordering:!0,precedence:"target_before_source",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["depends_on"],compatibilityVersion:1,allowSelf:!1},{kind:"blocks",direction:"directed",traversal:"ordering",inverse:"blocked_by",ordering:!0,precedence:"source_before_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"parent",direction:"directed",traversal:"hierarchy",outcomeTraversal:"source_to_target",inverse:"child",ordering:!1,hierarchy:!0,hierarchyDirection:"target_parent",outgoing:"one",incoming:"many",lifecycle:"supersedable",aliases:["child_of","epic"],compatibilityVersion:1,allowSelf:!1},{kind:"child",direction:"directed",traversal:"hierarchy",outcomeTraversal:"target_to_source",inverse:"parent",ordering:!1,hierarchy:!0,hierarchyDirection:"source_parent",outgoing:"many",incoming:"one",lifecycle:"supersedable",aliases:["parent_child","task"],compatibilityVersion:1,allowSelf:!1},{kind:"related",direction:"undirected",traversal:"association",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["related_to"],compatibilityVersion:1,allowSelf:!1},{kind:"discovered_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"incident_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"implements",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"recurs_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,temporalOrder:"source_after_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"verifies",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"supersedes",direction:"directed",traversal:"semantic",outcomeTraversal:"both",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"supersedable",compatibilityVersion:1,allowSelf:!1}];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="418b3f7f-6350-5878-a362-3948de287baf")}catch{}})();function Fn(e){return e.trim().toLowerCase().replaceAll("-","_")}function D_(e){if(e===void 0)return;let t=Fn(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function Di(e,t=new Set){if(e===null||typeof e!="object"||t.has(e))return e;if(t.add(e),Array.isArray(e)){for(let r of e)Di(r,t);return Object.freeze(e)}for(let r of Object.values(e))Di(r,t);return Object.freeze(e)}function P_(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 M_(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 $_(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 j_(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=Fn(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 L_(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 F_(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(r=>typeof r!="string")))throw new TypeError(`Invalid relationship aliases for ${t}`)}function z_(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var Pi=class{#e=new Map;#r=new Map;constructor(t=xi){for(let r of t)this.register(r)}register(t){let r=j_(t);if(L_(t,r),F_(t,r),P_(t,r),M_(t,r),$_(t,r),this.#e.has(r)||this.#r.has(r))throw new TypeError(`Relationship kind already registered: ${r}`);let n=D_(t.inverse),o=[...new Set((t.aliases??[]).map(Fn))].sort();for(let s of o){if(!/^[a-z][a-z0-9_]*$/.test(s))throw new TypeError(`Invalid relationship alias: ${s}`);if(s===r||this.#e.has(s)||this.#r.has(s))throw new TypeError(`Relationship alias already registered: ${s}`)}let i=Object.freeze({...t,kind:r,traversal:z_(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:n,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?Di(structuredClone(t.payloadSchema)):void 0});this.#e.set(r,i);for(let s of o)this.#r.set(s,r);return this}resolve(t){if(typeof t!="string")return;let r=Fn(t);return this.#e.get(this.#r.get(r)??r)}require(t){let r=this.resolve(t);if(!r)throw new TypeError(`Unknown relationship kind: ${t}`);return r}list(){return Object.freeze([...this.#e.values()].sort((t,r)=>t.kind.localeCompare(r.kind)))}};function Mi(){return new Pi}var pt=Mi();function DI(e){return pt.require(e).kind}function PI(e){return pt.resolve(e)?.kind}function MI(e,t=pt){return t.resolve(e)?.ordering===!0}function U_(e,t,r,n=pt){let o=Rr(e),i=Rr(t);if(!o||!i)throw new TypeError("Relationship endpoint must not be empty");let s=n.require(r);if(o===i&&!s.allowSelf)throw new TypeError(`Self relationship is not allowed for ${s.kind}`);return s}function jn(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function H_(e,t,r){let n=typeof e.source=="string"?e.source.trim():"",o=typeof e.target=="string"?e.target.trim():"";if(!t.has(n)||!t.has(o))throw new TypeError(`Relationship endpoint not found: ${n} -> ${o}`);let i=U_(n,o,e.kind,r),s=Object.freeze({...e,source:n,target:o,kind:i.kind}),a=i.direction==="undirected"?[n,o].sort().join("\0"):`${n}\0${o}`;return{edge:s,identity:`${i.kind}\0${a}`}}function Ln(e,t,r){let n=e.get(t);n?n.push(r):e.set(t,[r])}function Rr(e){return typeof e=="string"?e.trim():""}function Ni(e,t){let r=Rr(e);return r&&t.has(r)?r:void 0}function q_(e,t,r){let n=[t],o=t;for(;o!==e;)o=r.get(o),n.push(o);return n.reverse()}var Yc=class e{#e;#r;#o;#n;#s=new Map;#a=new Map;constructor(t,r,n=pt){this.#e=n,this.#r=new Set([...t].filter(i=>typeof i=="string").map(i=>i.trim()).filter(Boolean)),this.#o=Object.freeze([...this.#r].sort());let o=new Map;for(let i of r){let{edge:s,identity:a}=H_(i,this.#r,n);o.set(a,s)}this.#n=Object.freeze([...o.values()].sort(jn));for(let i of this.#n)Ln(this.#s,i.source,i),Ln(this.#a,i.target,i),n.require(i.kind).direction==="undirected"&&(Ln(this.#s,i.target,i),Ln(this.#a,i.source,i))}static fromItems(t,r=pt){let n=new Set(t.map(i=>Rr(i.id)).filter(Boolean)),o=[];for(let i of t){let s=Rr(i.id);if(!s)continue;let a=Ni(i.parent,n);a&&o.push({source:s,target:a,kind:"parent"});let c=Ni(i.blocked_by,n);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let d of i.dependencies??[]){let l=Ni(d.id,n);l&&r.resolve(d.kind)&&o.push({source:s,target:l,kind:d.kind,createdAt:d.created_at,author:d.author})}}return new e(n,o,r)}edges(){return this.#n}incidentEdges(t){this.#i(t);let r=this.#s.get(t)??[],n=this.#a.get(t)??[];if(r.length===0)return Object.freeze([...n]);if(n.length===0)return Object.freeze([...r]);let o=[],i=0,s=0;for(;i<r.length||s<n.length;){let a=r[i],c=n[s],d=a===void 0?c:c===void 0||jn(a,c)<=0?a:c;o.at(-1)!==d&&o.push(d),a===d&&(i+=1),c===d&&(s+=1)}return Object.freeze(o)}nodes(){return this.#o}hasNode(t){return this.#r.has(t)}registry(){return this.#e}#i(t){if(!this.#r.has(t))throw new TypeError(`Relationship node not found: ${t}`)}#c(t,r){if(!r)return!0;let n=this.#e.require(t.kind);return r.has(t.kind)||n.inverse!==void 0&&r.has(n.inverse)}#t(t,r,n){let o=[...r==="incoming"?[]:this.#s.get(t)??[],...r==="outgoing"?[]:this.#a.get(t)??[]];return[...new Set(o)].filter(i=>this.#c(i,n)).map(i=>({id:i.source===t?i.target:i.source,edge:i})).sort((i,s)=>i.id.localeCompare(s.id)||jn(i.edge,s.edge))}adjacency(t,r={}){this.#i(t),r.signal?.throwIfAborted();let n=r.kinds?new Set(r.kinds.map(c=>this.#e.require(c).kind)):void 0,o=this.#t(t,r.direction??"outgoing",n),i=r.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,r={}){this.#i(t),r.signal?.throwIfAborted();let n=r.kinds?new Set(r.kinds.map(a=>this.#e.require(a).kind)):void 0,o=this.#t(t,r.direction??"outgoing",n),i=r.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,r={}){this.#i(t);let n=r.kinds?new Set(r.kinds.map(m=>this.#e.require(m).kind)):void 0,o=r.direction??"outgoing",i=r.limit??Number.POSITIVE_INFINITY,s=r.maxDepth??Number.POSITIVE_INFINITY,a=new Set([t]),c=[],d=[{id:t,depth:0}],l=0,u=0,f=!1;e:for(let m=0;m<d.length;m+=1){r.signal?.throwIfAborted();let _=d[m];l+=1;let y=this.#t(_.id,o,n);if(u+=y.length,_.depth>=s){y.some(w=>!a.has(w.id))&&(f=!0);continue}for(let w of y)if(!a.has(w.id)){if(c.length>=i){f=!0;break e}a.add(w.id),c.push(w.id),d.push({id:w.id,depth:_.depth+1})}}return{value:c,meta:{visitedNodes:l,inspectedEdges:u,truncated:f,nextCursor:c.at(-1)}}}shortestPath(t,r,n={}){if(this.#i(t),this.#i(r),t===r)return{value:[t],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}};let o=n.kinds?new Set(n.kinds.map(m=>this.#e.require(m).kind)):void 0,i=n.direction??"outgoing",s=n.maxDepth??Number.POSITIVE_INFINITY,a=[{id:t,depth:0}],c=new Map,d=new Set([t]),l=0,u=0,f=!1;for(let m=0;m<a.length;m+=1){n.signal?.throwIfAborted();let _=a[m];l+=1;let y=this.#t(_.id,i,o);if(u+=y.length,_.depth>=s){y.some(w=>!d.has(w.id))&&(f=!0);continue}for(let w of y)if(!d.has(w.id)){if(c.set(w.id,_.id),w.id===r)return{value:q_(t,r,c),meta:{visitedNodes:l,inspectedEdges:u,truncated:!1}};d.add(w.id),a.push({id:w.id,depth:_.depth+1})}}return{value:[],meta:{visitedNodes:l,inspectedEdges:u,truncated:f}}}subgraph(t,r={}){let n=this.closure(t,r),o=[t,...n.value].sort(),i=new Set(o),s=r.kinds?new Set(r.kinds.map(c=>this.#e.require(c).kind)):void 0,a=new Set;for(let c of o)for(let d of this.#s.get(c)??[])i.has(d.source)&&i.has(d.target)&&this.#c(d,s)&&a.add(d);return{value:{nodes:o,edges:[...a].sort(jn)},meta:n.meta}}};function $I(e,t,r=pt){return{source:e,target:t.id,kind:r.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]="32aa20df-edf7-543d-b733-841130466f00")}catch{}})();var V_="__pm_suppress_host_output",$i="@unbrained/pm-cli:suppress-host-output:v1";function Xc(e){return e===void 0?{__pm_suppress_host_output:$i}:{__pm_suppress_host_output:$i,result:e}}function zn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[V_]===$i}import qt from"node:fs";import Re from"node:path";import{fileURLToPath as B_}from"node:url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="efea1aa1-1ad1-5f53-a3a5-b83803d9deb1")}catch{}})();var W_="@unbrained/pm-cli";function G_(e){try{return JSON.parse(qt.readFileSync(e,"utf8")).name===W_}catch{return!1}}function K_(e){let t=qt.existsSync(e)&&qt.statSync(e).isDirectory()?Re.resolve(e):Re.dirname(Re.resolve(e));for(;;){let r=Re.join(t,"package.json");if(qt.existsSync(r)&&G_(r))return t;let n=Re.dirname(t);if(n===t)return;t=n}}function Un(e,t=[]){let r=B_(e);return K_(r)||Re.resolve(Re.dirname(r),...t)}function HI(e,t=[]){try{let r=Re.join(Un(e,t),"package.json");if(!qt.existsSync(r))return;let n=JSON.parse(qt.readFileSync(r,"utf8"));return typeof n.version=="string"&&n.version.trim().length>0?n.version:void 0}catch{return}}function qI(e=process.env,t="PM_CLI_PACKAGE_ROOT",r,n=[]){let o=e[t];return typeof o=="string"&&o.trim().length>0?Re.resolve(o.trim()):r?Un(r,n):process.cwd()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a797572f-fbc6-5e62-a9b5-5a0bd6ef22b4")}catch{}})();function Y_(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function BI(e){return Y_(e)??void 0}function WI(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 GI(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function Zc(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function Hn(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 KI(e){let t=Hn(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function YI(e,t,r){let n=Hn(e);return n===null||n<t||n>r?null:n}function XI(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function Ue(e){return typeof e!="object"||e===null?null:e}function Jc(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function Qc(e){let t=Jc(e);if(!t)return null;if(typeof t.activate=="function")return t;let r=Jc(t.default);return typeof r?.activate=="function"?r:null}function JI(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e}:{}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c05a5a9e-282c-5ca7-97dc-e48c8df7977e")}catch{}})();var X_=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],ed=X_,Vt=["draft","open","in_progress","blocked","closed","canceled"],qn=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],Bt=["string","number","boolean","string_array","array","object"],Vn=["create","update","update_many","list","search","calendar","context"],Bn=["allow","warn","reject"],QI=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],eT=["project","global"],tT=["low","medium","high","critical"],Wn=["low","medium","high","critical"],Gn=["low","medium","high"];var td=["minimal","default","strict","custom"],rT=["none","warn","strict"],nT=["progressive","strict"],oT=["off","warn","strict"],iT=["off","warn","strict"];var Kn=["daily","weekly","monthly","yearly"],xr=["mon","tue","wed","thu","fri","sat","sun"];function ji(e){return xr.indexOf(e)}var sT=["draft","research","review","approved","executing","paused","completed","superseded"],rd=["pending","in_progress","completed","blocked","skipped","superseded"],aT=["codex","claude-code","cursor","generic"],cT=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],dT=["brief","standard","deep","full"],lT=["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0ca7f52c-fb31-5cd9-b689-a918f4e61816")}catch{}})();import ty from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="75f74db3-9547-5c78-8561-f371c016b90d")}catch{}})();function He(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function J_(e){let t=e.key.trim();if(t.length===0)return null;let r=He(e.aliases),n=e.description?.trim();return{key:t,values:He(e.values),required:e.required===!0?!0:void 0,aliases:r.length>0?r:void 0,description:n&&n.length>0?n:void 0}}var Z_=e=>e,od=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function Q_(e,t){let r=t(e.command);if(r===null)return null;let n=e.option.trim();return n.length===0?null:{command:r,option:n,required:e.required,visible:e.visible,enabled:e.enabled}}function ey(e,t){let r=new Map;for(let n of e??[]){let o=Q_(n,t);o&&r.set(`${o.command}:${o.option.toLowerCase()}`,o)}return[...r.values()].sort((n,o)=>n.command===o.command?n.option.localeCompare(o.option):n.command.localeCompare(o.command))}function nd(e,t){return t?He(e):void 0}function Li(e){let t=e?.trim();return t&&t.length>0?t:void 0}function Fi(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 Yn(e,t={}){let r=t.resolvePolicyCommand??Z_,n=e.name.trim();if(n.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=He(e.aliases),d=(e.options??[]).map(u=>J_(u)).filter(u=>u!==null).sort((u,f)=>u.key.localeCompare(f.key)),l=ey(e.command_option_policies,r);return{name:n,description:Li(e.description),default_status:Li(e.default_status),...e.execution_role===void 0?{}:{execution_role:Fi(e.execution_role)},folder:Li(e.folder),aliases:c.length>0?c:void 0,required_create_fields:nd(e.required_create_fields,o),required_create_repeatables:nd(e.required_create_repeatables,i),options:s?d:void 0,command_option_policies:a?l:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f40ddc8e-1dd5-5f26-b2ba-fbbac30a1781")}catch{}})();var ry=Object.freeze({decision:"human",milestone:"gate"}),ny=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],oy=["dep","comment","note","learning","file","test","doc"],sd=["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"],iy=["title","description","type","status","priority","tags","body",...sd,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],sy=["title","description","body","status","closeReason","priority","type","tags",...sd,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],ad={"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"},ay={...ad},cy={...ad},cd=[["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"]],dd=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function ld(e){return Object.fromEntries(e)}var dy=ld([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...cd,["author","--author"],["message","--message"],["dep","--dep"],...dd]),ly=ld([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...cd,...dd,["author","--author"],["message","--message"],["force","--force"]]);function uy(e){return e.trim().replace(/^--+/,"").toLowerCase()}function fy(e){return e==="create"?iy:sy}function my(e){return e==="create"?ay:cy}function ud(e,t){let r=uy(t);return r.length===0?void 0:my(e)[r]||fy(e).find(n=>n.toLowerCase()===r)}function bT(e,t){return(e==="create"?dy:ly)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function Ui(e){let t=_y(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function py(e){let t=e.trim(),r=t.replaceAll("\\","/").replace(/^\/+/,""),n=ty.posix.normalize(r);if(t.includes("\0")||/^[A-Za-z]:/.test(n)||n==="."||n===".."||n.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return n}function _y(e){let t=e.trim().toLowerCase(),r="",n=!1;for(let o of t){let i=o.charCodeAt(0),s=i>=97&&i<=122,a=i>=48&&i<=57;if(s||a){n&&r.length>0&&(r+="-"),r+=o,n=!1;continue}r.length>0&&(n=!0)}return r}function yy(e){return Yn(e,{resolvePolicyCommand:od})}function Nr(e,t){let r=e[t];return Array.isArray(r)?r.filter(n=>typeof n=="string"):void 0}function hy(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:Nr(t,"values")??[],required:t.required===void 0?void 0:!!t.required,aliases:Nr(t,"aliases"),description:typeof t.description=="string"?t.description:void 0}}function gy(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 r=t.command.trim().toLowerCase();return r!=="create"&&r!=="update"?null:{command:r,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 by(e){if(Array.isArray(e.options))return e.options.map(t=>hy(t)).filter(t=>t!==null)}function wy(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>gy(t)).filter(t=>t!==null)}function vy(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e,r=typeof t.name=="string"?t.name:"";if(r.trim().length===0)return null;let n=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:r,description:o,default_status:i,execution_role:Fi(t.execution_role),folder:n,aliases:Nr(t,"aliases"),required_create_fields:Nr(t,"required_create_fields"),required_create_repeatables:Nr(t,"required_create_repeatables"),options:by(t),command_option_policies:wy(t)}}function Ey(e,t){return e.required_create_fields?He(e.required_create_fields):t?.required_create_fields??[]}function ky(e,t){return e.required_create_repeatables?He(e.required_create_repeatables):t?.required_create_repeatables??[]}function Sy(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function Oy(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function Ay(e,t){let r=t?.name??e.name,n=e.description??t?.description,o=e.default_status??t?.default_status,i=py(e.folder??t?.folder??Ui(r)),s={name:r,execution_role:e.execution_role,folder:i,aliases:He([...t?.aliases??[],...e.aliases??[]]),required_create_fields:Ey(e,t),required_create_repeatables:ky(e,t),options:Sy(e,t),command_option_policies:Oy(e,t)};return n&&(s.description=n),o&&(s.default_status=o),s}function id(e,t){for(let r of e){let n=yy(r);if(!n)continue;let o=n.name.toLowerCase(),i=t.get(o);t.set(o,Ay({...n,execution_role:n.execution_role??i?.execution_role},i))}}function Iy(e){if(!e)return[];let t=[];for(let r of e.item_types??[]){let n=r.types;if(Array.isArray(n))for(let o of n){let i=vy(o);i&&t.push(i)}}return t}function wT(e,t=null){let r=new Map;for(let c of ed)r.set(c.toLowerCase(),{name:c,execution_role:ry[c.toLowerCase()]??"agent",folder:Ir[c],aliases:[],required_create_fields:[...ny],required_create_repeatables:[...oy],options:[],command_option_policies:[]});id(e.item_types?.definitions??[],r),id(Iy(t),r);let n=[...r.values()].sort((c,d)=>c.name.localeCompare(d.name)),o={},i={},s={};for(let c of n){o[c.name]=c,s[c.name]=c.folder,i[c.name.toLowerCase()]=c.name;for(let d of c.aliases)i[d.toLowerCase()]=c.name}let a=[...new Set(n.map(c=>c.folder))].sort((c,d)=>c.localeCompare(d));return{types:n.map(c=>c.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function Ty(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function Cy(e,t){let r=Ty(e,t);if(r)return t.by_type[r]}function Ry(e,t,r,n){for(let o of n){let i=ud(r,o);if(i){e.required.add(i);continue}e.errors.push(`Unsupported base required option "${o}" for command "${r}" on type "${t.name}"`)}}function zi(e,t,r){if(r){e.add(t);return}e.delete(t)}function xy(e,t,r,n){let o=ud(r,n.option);if(!o){e.errors.push(`Unsupported command_option_policies option "${n.option}" for command "${r}" on type "${t.name}"`);return}n.required!==void 0&&zi(e.required,o,n.required),n.visible!==void 0&&zi(e.hidden,o,!n.visible),n.enabled!==void 0&&zi(e.disabled,o,!n.enabled)}function Ny(e,t,r){for(let n of t.command_option_policies)n.command===r&&xy(e,t,r,n)}function Dy(e,t,r){for(let n of e.required)e.disabled.has(n)&&e.errors.push(`Option "${n}" cannot be both required and disabled for command "${r}" on type "${t.name}"`)}function vT(e,t,r){let n=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:n};return Ry(a,e,t,r),Ny(a,e,t),Dy(a,e,t),{required:[...o],hidden:[...i].sort((c,d)=>c.localeCompare(d)),disabled:[...s].sort((c,d)=>c.localeCompare(d)),errors:n}}function Py(e){let t=new Map;for(let r of e.options){t.set(r.key.toLowerCase(),r);for(let n of r.aliases??[])t.set(n.toLowerCase(),r)}return t}function My(e,t,r){let n=e.values;if(n.length===0)return t;let o=new Map(n.map(i=>[i.toLowerCase(),i])).get(t.toLowerCase());if(!o){r.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${n.join(", ")}`);return}return o}function ET(e,t,r){let n=Cy(e,r);if(!n)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=Py(n),s={};for(let[c,d]of Object.entries(t??{})){let l=c.trim(),u=d.trim();if(l.length===0){o.push("type option keys must not be empty");continue}if(u.length===0){o.push(`type option "${l}" must not be empty`);continue}let f=i.get(l.toLowerCase());if(!f){let _=n.options.map(y=>y.key).join(", ");o.push(n.options.length>0?`Unknown type option "${l}" for type "${n.name}". Allowed: ${_}`:`Type "${n.name}" does not define any configurable type options`);continue}let m=My(f,u,o);m!==void 0&&(s[f.key]=m)}for(let c of n.options)c.required&&!(c.key in s)&&o.push(`Missing required type option "${c.key}" for type "${n.name}"`);let a=Object.keys(s).sort((c,d)=>c.localeCompare(d));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(c=>[c,s[c]])),errors:o}}import{readFileSync as $y,readdirSync as jy,realpathSync as fd,statSync as md}from"node:fs";import Ly from"node:os";import C from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7f4b8abe-997c-549c-9791-87c78506c8b5")}catch{}})();var Fy={json_markdown:".md",toon:".toon"},zy={".md":"json_markdown",".toon":"toon"},Uy=new Set([".git","coverage","dist","node_modules"]),xT=[".md",".toon"];function Dr(e){try{return md(e),!0}catch{return!1}}function Hy(e){let t=C.resolve(e),r=[];for(;C.dirname(t)!==t;)try{return C.join(fd(t),...r)}catch(n){if(!ke(n))throw n;r.unshift(C.basename(t)),t=C.dirname(t)}return C.join(fd(t),...r)}function qy(e){try{return md(e),!0}catch(t){if(ke(t))return!1;throw t}}function pd(e){try{let t=JSON.parse($y(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function Vy(e){let t=Hy(e);for(;;){let r=C.join(t,Pn),n=C.join(r,Mn);if(Dr(n))return r;let o=C.join(t,Mn);if(Dr(o)&&pd(o))return t;if(qy(C.join(t,".git")))return r;let i=C.dirname(t);if(i===t)return;t=i}}function By(e){return Vy(e)??C.resolve(e,Pn)}function NT(e,t){let r=t?C.resolve(t):void 0;try{return jy(C.resolve(e),{withFileTypes:!0}).filter(n=>n.isDirectory()&&!Uy.has(n.name)).map(n=>C.join(C.resolve(e),n.name)).filter(n=>n!==r).filter(n=>Dr(Se(n))).filter(n=>pd(Se(n))).sort((n,o)=>n.localeCompare(o))[0]}catch{return}}function DT(e,t){let r=process.env.PM_PATH,n=t?.trim()||r?.trim();if(n){let o=C.resolve(e,n);if(!Dr(Se(o))){let i=C.join(o,Pn);if(Dr(Se(i)))return i}return o}return By(e)}function PT(e){let t=C.resolve(e),r=C.dirname(t);return C.basename(t)==="pm"&&C.basename(r)===".agents"?C.dirname(r):t}function _d(e){let t=process.env.PM_GLOBAL_PATH?.trim(),r=t&&t.length>0?t:C.join(Ly.homedir(),".pm-cli");return C.resolve(e,r)}function Se(e){return C.join(e,Mn)}function Wy(e,t,r=Ir){let n=r[t]??Ui(t);return C.join(e,n)}function MT(e,t,r,n="toon",o=Ir){return C.join(Wy(e,t,o),`${r}${Fy[n]}`)}function $T(e){let t=e.replaceAll("\\","/"),r=C.posix.extname(t).toLowerCase();return zy[r]??null}function jT(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new g("Invalid history item id: expected a single filename.",h.USAGE);return C.join(e,"history",`${t}.jsonl`)}function Hi(e,t){return C.join(e,"locks",`${t}.lock`)}function qi(e){return C.join(e,"runtime")}function Xn(e){return C.join(qi(e),"test-runs")}function Gy(e){return C.join(Xn(e),"runs")}function LT(e,t){return C.join(Gy(e),`${t}.json`)}function Ky(e){return C.join(Xn(e),"stdout")}function Yy(e){return C.join(Xn(e),"stderr")}function FT(e,t){return C.join(Ky(e),`${t}.log`)}function zT(e,t){return C.join(Yy(e),`${t}.log`)}function Xy(e){return C.join(Xn(e),"results")}function UT(e,t){return C.join(Xy(e),`${t}.json`)}import Jy from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="77f9d61e-e78b-5b6a-a769-1ad6e5b91777")}catch{}})();function Zy(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 Qy(e){let t=Object.keys(e).sort(),r={};for(let n of t){let o=e[n];o!==void 0&&(r[n]=Jn(o))}return r}function Jn(e){let t=Zy(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(n=>Jn(n));if(e instanceof Date)return e.toISOString();let r=e;if(typeof r.toJSON=="function"){let n=r.toJSON();if(n!==e)return Jn(n)}return Qy(e)}function R(e){return JSON.stringify(Jn(e))}function yd(e,t,r,n){for(let o=0;o<t.length;o+=1)if(!r.has(o)&&n(e,t[o]))return r.add(o),!0;return!1}function eh(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function th(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function rh(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let r=[...t],n=new Set;for(let o of e)if(!yd(o,r,n,B))return!1;return!0}function nh(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let r=[...t.entries()],n=new Set;for(let[o,i]of e.entries())if(!yd([o,i],r,n,([s,a],[c,d])=>B(s,c)&&B(a,d)))return!1;return!0}function oh(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((r,n)=>B(r,t[n]))}function ih(e,t){let r=Object.keys(e).sort((o,i)=>o.localeCompare(i)),n=Object.keys(t).sort((o,i)=>o.localeCompare(i));if(r.length!==n.length)return!1;for(let o=0;o<r.length;o+=1){let i=r[o];if(i!==n[o]||!B(e[i],t[i]))return!1}return!0}var sh=[eh,th,rh,nh,oh];function B(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let r of sh){let n=r(e,t);if(n!==void 0)return n}return ih(e,t)}function Zn(e){return Jy.createHash("sha256").update(e,"utf8").digest("hex")}function A(e,t){let r={};for(let o of t){let i=e[o];i!==void 0&&(r[o]=i)}let n=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of n){let i=e[o];i!==void 0&&(r[o]=i)}return r}import{createHash as gd}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f675993f-c483-5751-baed-d968b4fd24c0")}catch{}})();var ah=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],hd=256,Vi=64;function se(e){throw new g(`Invalid workflow policy: ${e}`,h.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function xe(e,t,r){if(typeof e!="object"||e===null||Array.isArray(e))return se(`${r} must be an object`);let n=e;return Object.keys(n).some(o=>!t.includes(o))?se(`${r} contains an unknown key`):n}function _t(e,t,r=128){return typeof e!="string"||!e.trim()||e.length>r?se(`${t} must be nonempty text of at most ${r} characters`):e.trim()}function Pr(e,t){if(!Array.isArray(e)||e.length===0||e.length>Vi)return se(`${t} requires 1-${Vi} terms`);let r=e.map(n=>_t(n,t));return t==="fields"&&r.some(n=>!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$/.test(n)||n.split(".").some(o=>["__proto__","constructor","prototype"].includes(o)))?se("fields must be safe metadata paths of at most eight segments"):[...new Set(r)]}function ch(e){let t=xe(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(xe(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>Vi?se("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(r=>!Array.isArray(r)||r.length!==2?se("transition pairs need two statuses"):[_t(r[0],"from"),_t(r[1],"to")])}):t.kind==="authors"?(xe(t,["kind","authors"],"authors rule"),{kind:"authors",authors:Pr(t.authors,"authors")}):t.kind==="require_fields"?(xe(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:Pr(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(xe(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:Pr(t.fields,"fields"),authors:Pr(t.authors,"authors")}):se("unknown rule kind")}function dh(e){let t={},r=xe(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let n of["types","tags","statuses","operations","parents"])r[n]!==void 0&&(t[n]=Pr(r[n],n));if(r.dependency!==void 0){let n=xe(r.dependency,["kind","id"],"dependency");t.dependency={kind:_t(n.kind,"dependency kind"),...n.id===void 0?{}:{id:_t(n.id,"dependency id")}}}return t}function lh(e){let t=xe(e,["id","description","subject","effect","rule"],"policy"),r=_t(t.id,"id");return/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(r)?t.effect!==void 0&&(typeof t.effect!="string"||!["advise","warn","refuse"].includes(t.effect))?se("effect must be advise, warn, or refuse"):{id:r,rule:ch(t.rule),...t.subject===void 0?{}:{subject:dh(t.subject)},...t.description===void 0?{}:{description:_t(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:se("id must be a stable token")}function uh(e){let t=xe(e,["version","enforcement","policies"],"document");if(t.version!==1)return se("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return se("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>hd)return se(`policies must contain at most ${hd} declarations`);let r=t.policies.map(lh);return new Set(r.map(n=>n.id)).size!==r.length?se("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:r}}function Qn(e,t){let r=e;for(let n of t.split(".")){if(typeof r!="object"||r===null||!Object.hasOwn(r,n))return;r=r[n]}return r}function fh(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 bd(e){return gd("sha256").update(R(e)).digest("hex")}function mh(e,t){let r=e.rule.kind==="approval"?e.rule.fields:[];return gd("sha256").update(R({id:t.id,fields:r.map(n=>[n,Qn(t,n)])})).digest("hex")}function ph(e,t){return Array.isArray(t)&&t.some(r=>typeof r=="object"&&r!==null&&"kind"in r&&r.kind===e.kind&&(e.id===void 0||"id"in r&&r.id===e.id))}function _h(e,t,r){return!(e.types&&!e.types.some(n=>n.toLowerCase()===String(t.type).toLowerCase())||e.statuses&&!e.statuses.includes(String(t.status))||e.operations&&!e.operations.includes(r)||e.parents&&!e.parents.includes(String(t.parent))||e.tags&&(!Array.isArray(t.tags)||!e.tags.some(n=>t.tags.includes(n)))||e.dependency&&!ph(e.dependency,t.dependencies))}function yh(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 r=e.subject??{},n=t.after?.status??t.before?.status;return[t.before,t.after].some(o=>o!==null&&_h(r,{...o,status:n},t.operation))}function hh(e,t,r,n){let o=["type","tags","parent","dependencies"].some(i=>!B(t.before?.[i],t.after?.[i]));return t.after&&(t.completeness_only||r||n||o)?e.filter(i=>!fh(Qn(t.after,i))):[]}function gh(e,t,r,n){let o=t.after??t.before,i=mh(e,o);return t.approvals?.some(s=>s.policy_fingerprint===n&&s.content_fingerprint===i&&s.author!==t.author&&r.includes(s.author))??!1}function bh(e,t,r){let n=e.rule,o=t.before?.status!==t.after?.status,i="fields"in n&&n.fields.some(s=>!B(Qn(t.before,s),Qn(t.after,s)));switch(n.kind){case"require_fields":{let s=hh(n.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||n.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:n.authors.includes(t.author),missing_fields:[],remediation:"Have a declared workflow actor perform this operation."};case"field_writers":return{satisfied:!i||n.authors.includes(t.author),missing_fields:[],remediation:"Have a declared field writer change the protected fields."};case"approval":return{satisfied:!o||gh(e,t,n.authors,r),missing_fields:[],remediation:`Record an independent approval with pm schema policy-approve <item-id> --policy ${e.id} after preparing the reviewed fields.`}}}function wd(e,t,r){let n=e.policies.filter(o=>yh(o,t)).map(o=>{let i=o.effect??"advise",s=r(o);return{policy_id:o.id,policy_fingerprint:s,rule:o.rule.kind,effect:i==="refuse"&&e.enforcement!=="refuse"?"warn":i,...bh(o,t,s)}});return{allowed:!n.some(o=>!o.satisfied&&o.effect==="refuse"),decisions:n,warnings:n.filter(o=>!o.satisfied).map(o=>`workflow_policy:${o.effect}:${o.policy_id}:${o.rule}`)}}function YT(e,t){return wd(e,t,bd)}function XT(e){let t=uh(e),r=new Map(t.policies.map(n=>[n,bd(n)]));return n=>wd(t,n,o=>r.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]="432226a6-9df4-5de6-b9af-5c06ec2eed66")}catch{}})();var wh=[...Ce],vh=[...Ht],Eh=[...Rn],tC=[...xn],rC=[...Nn],kh=[...Dn],eo=["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"],nC=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],oC=["install","reconcile","report","driver"],Sh=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],Oh=["upgrade"],Ah=["reopen"],vd={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Wt=Object.freeze(eo.flatMap(e=>e in vd?[]:e==="extension"||e==="package"?[...Sh.map(t=>`${e}-${t}`),...e==="package"?Oh.map(t=>`package-${t}`):[],e]:e==="item"?Ah.map(t=>`item-${t}`):[e])),Ih=Object.freeze($n.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Wt.includes(e.alias)).map(e=>e.alias)),iC=Object.freeze(Wt.filter(e=>!Ih.includes(e)));function sC(e=eo,t=Wt,r=vd){let n=new Set(t),o=new Set(e);return{missing_cli_actions:e.filter(i=>!n.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&r[i]===void 0),waived_cli_actions:e.filter(i=>!n.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&r[i]!==void 0),stale_waivers:Object.keys(r).filter(i=>!o.has(i)||n.has(i)||t.some(s=>s.startsWith(`${i}-`)))}}function aC(e){return Wt.includes(e)}function cC(e){return wh.includes(e)}function dC(e){return vh.includes(e)}function lC(e){return Eh.includes(e)}function uC(e){return kh.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]="53865a81-4c96-51e2-a378-ae0e2781a50f")}catch{}})();var to={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},ro=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),Gt=["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"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f8657910-1392-5fae-afda-614b96dc8320")}catch{}})();function F(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Th(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function ue(e){return e?D(e):{}}function fe(e){return e?D(e):Th()}function D(e){return structuredClone(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="615b4955-a30d-5d45-a86d-4bcf7bd9bd7a")}catch{}})();var Ch=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),Rh=["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 xh(e,t){for(let r of Rh){let n=e[r];if(n===void 0)continue;if(!Array.isArray(n)||n.some(i=>typeof i!="string"))return!1;let o=n.map(i=>Ch.has(r)?F(i):i.trim()).filter(i=>i.length>0);t[r]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function Nh(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="object"||r===null)return null;let n=r;if(n.format!=="json"&&n.format!=="toon"||!Array.isArray(n.commands)||n.commands.some(o=>typeof o!="string")||typeof n.result_discriminator!="boolean")return null;t.push({format:n.format,commands:[...new Set(n.commands.map(o=>F(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:n.result_discriminator})}return t.sort((r,n)=>r.format.localeCompare(n.format))}function Dh(e){if(!Array.isArray(e))return null;let t=[];for(let r of e){if(typeof r!="object"||r===null)return null;let n=r.commands;if(!Array.isArray(n)||n.some(o=>typeof o!="string"))return null;t.push({commands:[...new Set(n.map(o=>F(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return t}function no(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 r={schema_version:1};if(!xh(t,r))return null;let n=t.preflight_overrides;if(n!==void 0&&(!Number.isInteger(n)||n<0))return null;typeof n=="number"&&(r.preflight_overrides=n);let o=t.renderer_ownership;if(o!==void 0){let s=Nh(o);if(s===null)return null;r.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=Dh(i);if(s===null)return null;r.preflight_ownership=s}return r}function yC(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]="628615ea-5be3-5753-a6c5-3eba8400a8da")}catch{}})();function oo(e,t,r){if(e===t)return 0;if(Math.abs(e.length-t.length)>r)return null;let n=t.length+1,o=new Array(n),i=new Array(n),s=new Array(n);for(let c=0;c<n;c+=1)o[c]=0,i[c]=c;for(let c=1;c<=e.length;c+=1){s[0]=c;let d=s[0];for(let l=1;l<=t.length;l+=1){let u=e[c-1]===t[l-1]?0:1,f=i[l-1]+u,m=s[l-1]+1,_=i[l]+1,y=Math.min(f,m,_);c>1&&l>1&&e[c-1]===t[l-2]&&e[c-2]===t[l-1]&&(y=Math.min(y,o[l-2]+1)),s[l]=y,y<d&&(d=y)}if(d>r)return null;for(let l=0;l<n;l+=1)o[l]=i[l],i[l]=s[l]}let a=i[t.length];return a<=r?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]="7359c10a-4c56-57ea-8254-fc26b19e5c84")}catch{}})();function Mr(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function qe(e){return Ce.includes(e)}function Ed(e){let t=e.trim().toLowerCase();return qe(t)?t:null}function kd(e){return e.filter(t=>!qe(t))}function Bi(e){let t=e.trim().toLowerCase();return t.length===0?null:Uc[t]??null}function Sd(e){let t=Mr([...e].map(i=>i.toLowerCase())),r=[],n=[];for(let i of t){let s=Bi(i);if(s){r.push(s),n.push({alias:i,target:s});continue}r.push(i)}let o=[...new Map(n.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:Mr(r),legacy_aliases:o}}function Ph(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let r=Bi(t);if(r)return r;let n=Math.max(1,Math.floor(t.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of Ce){let a=oo(t,s,n);a!==null&&a<i&&(i=a,o=s)}return o}function Od(e,t,r){let n=Ce.join(","),o=Ph(r)??"none";return`extension_capability_unknown:${e}:${t}:${r}:allowed=${n}:suggested=${o}`}function Ad(e,t,r){let n=r.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${n}`}function Mh(e){let t=/^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(e.trim());if(!t)return null;let[,r,n,o,i,s]=t,a=r,c=i.split(",").map(u=>u.trim()).filter(u=>u.length>0),d=Bi(o),l=(s==="none"?void 0:s)??d??void 0;return{layer:a,name:n,capability:o,allowed_capabilities:c,capability_contract_version:Ti,suggested_capability:l,suggestion_source:l?d===l?"legacy_alias":"nearest_match":void 0,legacy_alias_target:d??void 0}}function $h(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,r,n,o]=t,i=r,s=[...Ce],a=[];for(let c of o.split(",")){let[d,l]=c.split(">"),u=d?.trim(),f=l?.trim().toLowerCase();!u||!f||!qe(f)||a.push({layer:i,name:n,capability:u,allowed_capabilities:s,capability_contract_version:Ti,suggested_capability:f,suggestion_source:"legacy_alias",legacy_alias_target:f})}return a}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01116a5e-62d1-591b-9fd0-84ac6e99f8d0")}catch{}})();function $r(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function Wi(){return{overrides:[],handlers:[]}}function Gi(){return{overrides:[]}}function Ki(){return{overrides:[]}}function Yi(){return{overrides:[]}}function Xi(){return{overrides:[]}}function Ji(){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]="67511565-01f8-58a6-ad06-45b5d0ce831b")}catch{}})();var jh=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 Lh(e){return{unknownKeys:Object.keys(e).filter(t=>!jh.has(t)).sort((t,r)=>t>r?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function Fh(e){let t=Lh(e),r=t.unknownKeys.map(n=>({code:"manifest_unknown_key",path:n,...n==="compatibility"?{suggested_key:"pm_min_version"}:{},message:n==="compatibility"?'Manifest key "compatibility" is ignored; declare the canonical pm_min_version and optional pm_max_version fields instead.':`Manifest key "${n}" is not part of the extension manifest contract and will be ignored.`}));return t.missingVersionBounds&&r.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:r.length===0,findings:r}}function Id(e,t,r){return Fh(r).findings.map(n=>n.code==="manifest_unknown_key"?`extension_manifest_unknown_key:${e}:${t.name}:key=${n.path}${n.suggested_key?`:suggested=${n.suggested_key}`:""}`:`extension_manifest_no_version_bounds:${e}:${t.name}:suggested=pm_min_version`)}import{constants as Ve}from"node:os";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="151124a3-cefa-55d3-bf4f-bd8f2553ad72")}catch{}})();var Td=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"}]]),zh=/^[a-z][a-z0-9_]{0,63}$/u,Uh=new Map([[Ve.errno.EACCES,"EACCES"],[Ve.errno.EDQUOT,"EDQUOT"],[Ve.errno.EMFILE,"EMFILE"],[Ve.errno.ENFILE,"ENFILE"],[Ve.errno.ENOMEM,"ENOMEM"],[Ve.errno.ENOSPC,"ENOSPC"],[Ve.errno.EPERM,"EPERM"],[Ve.errno.EROFS,"EROFS"]].filter(([e])=>Number.isInteger(e))),Hh={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function qh(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&Td.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:Uh.get(Math.abs(t.errno))??null}function Vh(e,t,r={}){let n=qh(e);if(n===null)return null;if(!zh.test(t))throw new g("Host environment operation labels must be bounded identifiers.",h.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=Td.get(n);return new g(`Host filesystem operation ${t} ${o.summary}.`,h.GENERIC_FAILURE,{code:r.codes?.[o.category]??Hh[o.category].code,reason:n,required:o.recovery,why:r.why??"The operating system refused a required project filesystem operation.",nextSteps:[o.recovery,...r.nextSteps??[]],...r.suggestedRetry?{recovery:{suggested_retry:r.suggestedRetry}}:{}})}async function Cd(e,t,r={}){try{return await t()}catch(n){throw Vh(n,e,r)??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]="c24357cc-5dad-5cd7-aa89-cddd2945aab7")}catch{}})();var Bh=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"}]),Zi=new Set(Bh.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]="896ebde0-4ca1-50ed-bb8e-2a8c2d978d94")}catch{}})();var Rd=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function Qi(e){if(typeof e!="string")return null;let t=Rd.exec(e.trim());if(!t)return null;let r=t[2];return{name:t[1],valueName:r?r.slice(1,-1):null,optional:r?.startsWith("[")??!1}}function RC(e){let t=Qi(e);return t?t.name:typeof e=="string"&&e.trim()||null}function Wh(e){if(typeof e!="string")return null;let t=e.trim(),r=t.split(/[ =]/,1)[0];return Zi.has(r)?"host_owned_flag_collision":Rd.test(t)?null:"malformed_long_flag"}function xd(e,t){let r=[e,t].find(i=>typeof i=="string"&&Zi.has(i.trim().split(/[ =]/,1)[0]));if(typeof r=="string")return{token:r.trim().split(/[ =]/,1)[0],failure:"host_owned_flag_collision"};if(typeof e!="string")return null;let n=e.trim(),o=Wh(n);return o===null?null:{token:n,failure:o}}function Nd(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]="5c3049c3-1d5a-5e7e-a070-35340737a6ab")}catch{}})();var Dd=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function io(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.hasOwn(Dd,t)?Dd[t]:null}function Gh(e,t,r){return!!(e.value_name?.trim()||t||r||e.required===!0||e.list===!0||e.repeatable===!0)}function Kh(e){return(e.value_type?.trim()||e.type?.trim())?.toLowerCase()}function DC(e){let t=Kh(e),r=io(t),n=Qi(e.long),o=e.value_name?.trim()||null,i=!(r==="boolean"&&t!=="bool")&&Gh(e,n?.valueName,t),s=n?.valueName?n.optional:t==="bool";return{value_type:r,value_arity:i?s?"optional":"required":"none",value_name:i?o??n?.valueName??"value":null}}function Pd(e){let t=[],r=n=>{if(Array.isArray(n)){for(let o of n)r(o);return}if(typeof n=="string"){for(let o of n.split(",")){let i=o.trim();i.length>0&&t.push(i)}return}n!=null&&t.push(n)};return r(e),t}function Md(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 PC(e,t){return t==="number"?typeof e=="number"&&Number.isFinite(e)?null:{kind:t,received:e,expected:"a finite number"}:typeof e=="boolean"?null:{kind:t,received:e,expected:"true, false, 1, or 0"}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1dcf5e56-cb0c-5e4c-b0e8-e4dbd06187dd")}catch{}})();var Yh=5e3;async function jr(e,t,r){let n=[];for(let o of e)try{await o.run(D(r))}catch{n.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return n}async function Xh(e,t){return jr(e.beforeCommand,"beforeCommand",t)}function Jh(e,t,r){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new g(`Extension mutation guard ${t.name} returned an invalid decision.`,h.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 n=e,o=typeof n.code=="string"?n.code.trim():"",i=typeof n.remediation=="string"?n.remediation.trim():"";if(o.length===0||i.length===0)throw new g(`Extension mutation guard ${t.name} returned an invalid denial.`,h.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 n.message=="string"?n.message.trim():"";throw new g(s||`Extension mutation guard ${t.name} denied ${r}.`,h.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function es(e,t){for(let r of e.beforeMutation??[]){let n,o;try{let i=Promise.resolve().then(()=>r.run({pm_root:t.pm_root,operation:t.operation,before:t.before===null?null:D(t.before),after:t.after===null?null:D(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),n=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new g(`Extension mutation guard ${r.name} timed out before ${t.operation}.`,h.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${r.layer}:${r.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},Yh),o.unref?.()})])}catch(i){throw i instanceof g?i:new g(`Extension mutation guard ${r.name} failed before ${t.operation}.`,h.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${r.layer}:${r.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(o)}Jh(n,r,t.operation)}}async function Zh(e,t){return jr(e.afterCommand,"afterCommand",t)}async function ts(e,t){return jr(e.onWrite,"onWrite",t)}async function rs(e,t){return jr(e.onRead,"onRead",t)}async function ns(e,t){return jr(e.onIndex,"onIndex",t)}function Qh(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 r=t.replace(/\s+/gu," ").trim();if(r.length===0)return"";let n=300;return r.length>n?`${r.slice(0,n-1)}\u2026`:r}function so(e,t){if(typeof e!="object"||e===null||typeof e[t]!="string")return;let r=String(e[t]).replace(/\s+/gu," ").trim();return r.length>0?r.slice(0,300):void 0}function eg(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 os(e,t){let r=F(t.command);if(r.length===0)return{handled:!1,result:null,warnings:[]};let n=[...e.handlers].reverse().find(o=>o.command===r);if(!n)return{handled:!1,result:null,warnings:[]};try{let o=await n.run({command:r,args:D(t.args),options:D(t.options),global:D(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",eg(o)],["errorCode",so(o,"code")],["remediation",so(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:${n.layer}:${n.name}:${n.command}`],errorMessage:Qh(o),...Object.fromEntries([["errorCode",so(o,"code")],["remediation",so(o,"remediation")]].filter(s=>s[1]!==void 0))}}}async function is(e,t){let r=F(t.command);if(r.length===0)return{overridden:!1,context:{command:r,args:D(t.args),options:ue(t.options),global:fe(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]};let n=[...e.overrides].reverse().find(o=>o.command===r);if(!n)return{overridden:!1,context:{command:r,args:D(t.args),options:ue(t.options),global:fe(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]};try{let o=await Promise.resolve(n.run({command:r,args:D(t.args),options:ue(t.options),global:fe(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel}))??{},i=Array.isArray(o.args)?D(o.args):D(t.args),s=o.options?ue(o.options):ue(t.options),a=o.global?fe(o.global):fe(t.global);return{overridden:!0,context:{command:r,args:i,options:s,global:a,pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[]}}catch{return{overridden:!1,context:{command:r,args:D(t.args),options:ue(t.options),global:fe(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel},warnings:[`extension_parser_override_failed:${n.layer}:${n.name}:${n.command}`]}}}async function ss(e,t){let r={command:F(t.command),args:D(t.args),options:ue(t.options),global:fe(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},n=D(t.decision),o=[...e.overrides].reverse().find(i=>!i.commands?.length||i.commands.includes(r.command));if(!o)return{overridden:!1,context:r,decision:n,warnings:[]};try{let i=await Promise.resolve(o.run({command:r.command,args:D(r.args),options:ue(r.options),global:fe(r.global),pm_root:r.pm_root,source_workspace_root:r.source_workspace_root,repo_root:r.repo_root,pm_root_rel:r.pm_root_rel,decision:D(n)}))??{},s={command:r.command,args:Array.isArray(i.args)?D(i.args):r.args,options:i.options?ue(i.options):r.options,global:i.global?fe(i.global):r.global,pm_root:r.pm_root,source_workspace_root:r.source_workspace_root,repo_root:r.repo_root,pm_root_rel:r.pm_root_rel},a={enforce_item_format_gate:typeof i.enforce_item_format_gate=="boolean"?i.enforce_item_format_gate:n.enforce_item_format_gate,run_preflight_item_format_sync:typeof i.run_preflight_item_format_sync=="boolean"?i.run_preflight_item_format_sync:n.run_preflight_item_format_sync,run_extension_migrations:typeof i.run_extension_migrations=="boolean"?i.run_extension_migrations:n.run_extension_migrations,enforce_mandatory_migration_gate:typeof i.enforce_mandatory_migration_gate=="boolean"?i.enforce_mandatory_migration_gate:n.enforce_mandatory_migration_gate};return{overridden:!0,context:s,decision:a,warnings:[]}}catch{return{overridden:!1,context:r,decision:n,warnings:[`extension_preflight_override_failed:${o.layer}:${o.name}`]}}}function $d(e){return{handled:!1,result:e.payload,warnings:[]}}function jd(e,t){return[...e.overrides].reverse().filter(r=>r.service===t)}function Ld(e){return{service:e.service,command:e.command?F(e.command):void 0,args:e.args?D(e.args):void 0,options:e.options?ue(e.options):void 0,global:e.global?fe(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:D(e.payload)}}function tg(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 Fd(e,t){return tg(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 zd(e,t,r){return t.service==="output_format"&&typeof e=="object"&&e!==null&&B(e,r.payload)}function Ud(e,t,r){if(t.handled){if(e.passThrough===!0){r.push(`extension_service_pass_through_contract_violated:${e.layer}:${e.name}:${e.service}`);return}return{handled:!0,result:t.result,warnings:r}}}function as(e,t){let r=jd(e,t.service);if(r.length===0)return $d(t);let n=[];for(let o of r)try{let i=Ld(t),s=o.run(i);if(s instanceof Promise){n.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(zd(s,t,i)){n.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Ud(o,Fd(s,t),n);if(a)return a}catch{n.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:n}}async function cs(e,t){let r=jd(e,t.service);if(r.length===0)return $d(t);let n=[];for(let o of r)try{let i=Ld(t),s=await Promise.resolve(o.run(i));if(zd(s,t,i)){n.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Ud(o,Fd(s,t),n);if(a)return a}catch{n.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:n}}function ds(e,t){let r=F(t.command);if(r.length===0)return{overridden:!1,result:t.result,warnings:[]};let n=[...e.overrides].reverse().find(o=>o.command===r);if(!n)return{overridden:!1,result:t.result,warnings:[]};try{let o=ue(t.options),i=fe(t.global),s=n.run({command:r,args:D(t.args),options:o,global:i,pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,result:D(t.result)});return s instanceof Promise?{overridden:!1,result:t.result,warnings:[`extension_command_override_async_unsupported:${n.layer}:${n.name}:${n.command}`]}:{overridden:!0,result:s,warnings:[]}}catch{return{overridden:!1,result:t.result,warnings:[`extension_command_override_failed:${n.layer}:${n.name}:${n.command}`]}}}function rg(e,t,r){if((e.commands?.length??0)>0&&!e.commands?.includes(t))return!1;if(e.resultDiscriminator===void 0)return!0;try{return e.resultDiscriminator(D(r))}catch{return!1}}function ls(e,t){let r=typeof t.command=="string"?F(t.command):"",n=[...e.overrides].reverse().find(o=>o.format===t.format&&rg(o,r,t.result));if(!n)return{overridden:!1,rendered:null,warnings:[]};try{let o=Array.isArray(t.args)?D(t.args):[],i=ue(t.options),s=fe(t.global),a=typeof t.pm_root=="string"?t.pm_root:"",c=n.run({format:t.format,command:r,args:o,options:i,global:s,pm_root:a,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,result:D(t.result)});return c==null?{overridden:!1,rendered:null,warnings:[]}:typeof c!="string"?{overridden:!1,rendered:null,warnings:[`extension_renderer_invalid_result:${n.layer}:${n.name}:${n.format}`]}:{overridden:!0,rendered:c,warnings:[]}}catch{return{overridden:!1,rendered:null,warnings:[`extension_renderer_failed:${n.layer}:${n.name}:${n.format}`]}}}import wt from"node:fs/promises";import bt from"node:path";import{pathToFileURL as Lg}from"node:url";import Hd from"path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01422574-583a-5fd1-bc00-f61f430073cd")}catch{}})();function us(e,t){let r=Hd.relative(e,t);return r.length===0?!0:!r.startsWith("..")&&!Hd.isAbsolute(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]="559b05dc-0290-5a7c-97b9-ef1e5e8670ba")}catch{}})();function qd(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(([r,n])=>[r,n.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[r,n]of Object.entries(t.registrations))e.registrations[r].length=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]="17ae377d-20c2-5e45-825a-48a79c6c7601")}catch{}})();function G(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return t}function Z(e,t){if(t!==void 0&&typeof t!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function H(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 Vd(e,t){if(t===void 0)return;let r=n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean";if(Array.isArray(t)){for(let[n,o]of t.entries())if(!r(o))throw new TypeError(`${e}[${n}] must be a string, number, or boolean`);return}if(!r(t))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function yt(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[r,n]of t.entries())if(typeof n!="string"||n.trim().length===0)throw new TypeError(`${e}[${r}] must be a non-empty string`)}}function Lr(e,t){if(yt(e,t),!Array.isArray(t))return[];let r=[],n=new Set;for(let o of t){let i=o.trim();i.length===0||n.has(i)||(n.add(i),r.push(i))}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]="34536eba-0f92-5599-a807-5b39b000e733")}catch{}})();var fs=Object.freeze(["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"]);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="60fd882d-7c92-5be5-bf46-7e3c128bfb58")}catch{}})();var ng=new Set(fs);function og(e){if(e!==void 0&&!ng.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${fs.join(", ")}`)}function Bd(e){H("registerCommand definition.action",e.action),H("registerCommand definition.family",e.family),H("registerCommand definition.description",e.description),H("registerCommand definition.intent",e.intent),H("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");og(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]="095ea29d-eda3-5287-b54d-8a961658f7bc")}catch{}})();function Wd(e,t="",r=""){if(e===void 0)return;if(Kt(t)||Kt(r))throw new TypeError("Native pm commands and actions cannot declare read_output");let n=G("registerCommand definition.read_output",e);if(Object.keys(n).some(s=>s!=="row_keys")||!Array.isArray(n.row_keys))throw new TypeError("registerCommand definition.read_output requires only row_keys: string[]");let o=Array.from(n.row_keys),i=new Set(["__proto__","constructor","prototype","row_contract","read_output","read_session","omission_receipt","output_budget_truncation"]);if(o.some(s=>typeof s!="string"||!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*$/u.test(s)||s.split(".").some(a=>i.has(a))))throw new TypeError("registerCommand definition.read_output row_keys must be safe dot-delimited property paths");if(new Set(o).size!==o.length||o.some(s=>o.some(a=>a.startsWith(`${s}.`))))throw new TypeError("registerCommand definition.read_output row_keys must be unique and non-overlapping");return Object.freeze({row_keys:Object.freeze([...o])})}function Kt(e){let t=e.trim().toLowerCase().replace(/\s+/gu,"-");return Wt.includes(t)||Gt.includes(t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="07cb237c-3956-5997-85f8-972d2ee490d0")}catch{}})();function ig(e){let t=G("registerExporter options.output",e),r=new Set(["channel","receipt","media_type"]);for(let n of Object.keys(t))if(!r.has(n))throw new TypeError(`registerExporter options.output contains unsupported field ${n}`);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 H("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 Gd(e,t,r){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 n=ig(t.output);return!r&&n.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."),n}function ms(e,t,r){return{registration:t,action:r,command:e.command,args:D(e.args),options:D(e.options),global:D(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,...e.sdk===void 0?{}:{sdk:e.sdk}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fc2e7eac-cd1c-5885-aa27-e98455008a4f")}catch{}})();function Kd(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]="bb1b4879-079c-50d4-afa5-e8a36ead2e5c")}catch{}})();function be(e){return typeof e!="string"?"":e.trim().toLowerCase()}function P(e){return new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))}function sg(e){let t=e.trim().toLowerCase();if(t.length===0)return"";let r=t.split(/[.:/]/).map(n=>n.replace(/[\s_-]+/g,"")).filter(n=>n.length>0);return r.length===0?"":r.length===1?r[0]:`${r[0]}.${r.slice(1).join("")}`}function Yt(e){return new Set((e??[]).map(t=>sg(t)).filter(t=>t.length>0))}function Yd(e){let t=be(e);return Rn.includes(t)?t:"off"}function Xd(e){let t=be(e);return xn.includes(t)?t:"off"}function Fr(e){let t=be(e);return Nn.includes(t)?t:"none"}function ps(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return Hc.includes(t)?t:void 0}function Jd(e){if(typeof e=="string"){let t=ps(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:ps(e.global)??"block",project:ps(e.project)??"block"}:{global:"block",project:"block"}}function ag(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function $(e){return[...new Set(e)].sort((t,r)=>t.localeCompare(r))}function cg(e){let t=be(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?Fr(e.sandbox_profile):void 0,allowedCapabilities:P(e.allowed_capabilities),blockedCapabilities:P(e.blocked_capabilities),allowedSurfaces:Yt(e.allowed_surfaces),blockedSurfaces:Yt(e.blocked_surfaces),allowedCommands:P(e.allowed_commands),blockedCommands:P(e.blocked_commands),allowedActions:P(e.allowed_actions),blockedActions:P(e.blocked_actions),allowedServices:P(e.allowed_services),blockedServices:P(e.blocked_services)}}}function Zd(e){let t=new Map;for(let r of e??[]){let n=cg(r);n&&t.set(n.name,n.normalized)}return t}function dg(e){let t=[],r=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of $([...e.allowedCapabilities,...e.blockedCapabilities]))qe(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of r)for(let i of $([...o.allowedCapabilities,...o.blockedCapabilities]))qe(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let n=new Set(Dn);for(let o of $([...e.allowedSurfaces,...e.blockedSurfaces]))n.has(o)||t.push(`extension_policy_unknown_surface:${o}`);for(let o of r)for(let i of $([...o.allowedSurfaces,...o.blockedSurfaces]))n.has(i)||t.push(`extension_policy_unknown_surface:${o.name}:${i}`);return[...new Set(t)].sort((o,i)=>o.localeCompare(i))}function Qd(e){let t=e.extensions?.policy??{},r=P(t.allowed_capabilities),n=P(t.blocked_capabilities),o=Yt(t.allowed_surfaces),i=Yt(t.blocked_surfaces),s=Zd(t.extension_overrides);return{mode:Yd(t.mode),trustMode:Xd(t.trust_mode),pmMaxVersionExceededMode:Jd(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:P(t.trusted_extensions),defaultSandboxProfile:Fr(t.default_sandbox_profile),allowedExtensions:P(t.allowed_extensions),blockedExtensions:P(t.blocked_extensions),allowedCapabilities:r,blockedCapabilities:n,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:P(t.allowed_commands),blockedCommands:P(t.blocked_commands),allowedActions:P(t.allowed_actions),blockedActions:P(t.blocked_actions),allowedServices:P(t.allowed_services),blockedServices:P(t.blocked_services),overridesByName:s,warnings:dg({allowedCapabilities:r,blockedCapabilities:n,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function el(e){let t=[...e.overridesByName.values()].sort((r,n)=>r.name.localeCompare(n.name)).map(r=>({name:r.name,...r.disabled?{disabled:!0}:{},...r.requireTrusted?{require_trusted:!0}:{},...r.requireProvenance?{require_provenance:!0}:{},...r.sandboxProfile?{sandbox_profile:r.sandboxProfile}:{},...r.allowedCapabilities.size>0?{allowed_capabilities:$(r.allowedCapabilities)}:{},...r.blockedCapabilities.size>0?{blocked_capabilities:$(r.blockedCapabilities)}:{},...r.allowedSurfaces.size>0?{allowed_surfaces:$(r.allowedSurfaces)}:{},...r.blockedSurfaces.size>0?{blocked_surfaces:$(r.blockedSurfaces)}:{},...r.allowedCommands.size>0?{allowed_commands:$(r.allowedCommands)}:{},...r.blockedCommands.size>0?{blocked_commands:$(r.blockedCommands)}:{},...r.allowedActions.size>0?{allowed_actions:$(r.allowedActions)}:{},...r.blockedActions.size>0?{blocked_actions:$(r.blockedActions)}:{},...r.allowedServices.size>0?{allowed_services:$(r.allowedServices)}:{},...r.blockedServices.size>0?{blocked_services:$(r.blockedServices)}:{}}));return{mode:e.mode,trust_mode:e.trustMode,pm_max_version_exceeded_mode:ag(e.pmMaxVersionExceededMode),require_provenance:e.requireProvenance,trusted_extensions:$(e.trustedExtensions),default_sandbox_profile:e.defaultSandboxProfile,allowed_extensions:$(e.allowedExtensions),blocked_extensions:$(e.blockedExtensions),allowed_capabilities:$(e.allowedCapabilities),blocked_capabilities:$(e.blockedCapabilities),allowed_surfaces:$(e.allowedSurfaces),blocked_surfaces:$(e.blockedSurfaces),allowed_commands:$(e.allowedCommands),blocked_commands:$(e.blockedCommands),allowed_actions:$(e.allowedActions),blocked_actions:$(e.blockedActions),allowed_services:$(e.allowedServices),blocked_services:$(e.blockedServices),extension_overrides:t}}function tl(e){let t=Zd(e.extension_overrides);return{mode:Yd(e.mode),trustMode:Xd(e.trust_mode),pmMaxVersionExceededMode:Jd(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:P(e.trusted_extensions),defaultSandboxProfile:Fr(e.default_sandbox_profile),allowedExtensions:P(e.allowed_extensions),blockedExtensions:P(e.blocked_extensions),allowedCapabilities:P(e.allowed_capabilities),blockedCapabilities:P(e.blocked_capabilities),allowedSurfaces:Yt(e.allowed_surfaces),blockedSurfaces:Yt(e.blocked_surfaces),allowedCommands:P(e.allowed_commands),blockedCommands:P(e.blocked_commands),allowedActions:P(e.allowed_actions),blockedActions:P(e.blocked_actions),allowedServices:P(e.allowed_services),blockedServices:P(e.blocked_services),overridesByName:t,warnings:[]}}function Be(e,t){return e.overridesByName.get(be(t))??null}function Xt(e,t,r,n,o){return t.has(r)?o:e.size>0&&!e.has(r)?n:null}function rl(e,t,r){let n=r.trim().toLowerCase(),o=Be(e,t.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return Xt(i,s,n,"capability_not_allowlisted","capability_blocked")}function lg(e,t,r){let n=Be(e,t.name),o=n&&n.allowedSurfaces.size>0?n.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...n?n.blockedSurfaces:[]]);return Xt(o,i,r,"surface_not_allowlisted","surface_blocked")}function ug(e,t,r){let n=F(r);if(n.length===0)return null;let o=Be(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return Xt(i,s,n,"command_not_allowlisted","command_blocked")}function fg(e,t,r){let n=be(r).replace(/\s+/g,"-");if(n.length===0)return null;let o=Be(e,t.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return Xt(i,s,n,"action_not_allowlisted","action_blocked")}function mg(e,t,r){let n=be(r);if(n.length===0)return null;let o=Be(e,t.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return Xt(i,s,n,"service_not_allowlisted","service_blocked")}function pg(e,t){let r=be(t.name);return Be(e,t.name)?.disabled===!0?"extension_override_disabled":Xt(e.allowedExtensions,e.blockedExtensions,r,"extension_not_allowlisted","extension_blocked")}function _g(e,t){if(e.trustMode==="off")return null;let r=Be(e,t.name),n=be(t.name),o=t.trusted===!0,i=t.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(n)?"extension_not_trusted":(r?.requireTrusted===!0||e.trustMode==="warn"||e.trustMode==="enforce")&&!o?"extension_untrusted":(e.requireProvenance||r?.requireProvenance===!0)&&!i?"provenance_missing_or_unverified":null}function yg(e,t){if(e.mode==="off")return null;let r=Be(e,t.name)?.sandboxProfile??t.sandboxProfile??e.defaultSandboxProfile;if(r==="none")return null;let n=t.permissions;if(!n)return"sandbox_permissions_missing";let o=i=>n[i]===!0;return r==="restricted"?o("process_spawn")?"sandbox_restricted_disallows_process_spawn":o("env_write")?"sandbox_restricted_disallows_env_write":null:o("process_spawn")?"sandbox_strict_disallows_process_spawn":o("network")?"sandbox_strict_disallows_network":o("fs_write")?"sandbox_strict_disallows_fs_write":o("env_write")?"sandbox_strict_disallows_env_write":null}function ao(e,t,r,n,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}:${r.layer}:${r.name}:reason=${n}${s}`}function nl(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let r=[],n=pg(e,t);n&&r.push({reason:n,scope:"extension",mode:e.mode});let o=_g(e,t);o&&r.push({reason:o,scope:"trust",mode:e.trustMode});let i=yg(e,t);i&&r.push({reason:i,scope:"extension",mode:e.mode});let s=r.find(c=>c.mode==="enforce");if(s)return{allowed:!1,warning:ao("blocked",s.scope,t,s.reason)};let a=r.find(c=>c.mode==="warn");return a?{allowed:!0,warning:ao("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function ol(e,t,r){if(e.mode==="off")return{allowed:!0,warning:null};let n=rl(e,t,r);return n?{allowed:e.mode==="warn",warning:ao(e.mode==="warn"?"violation":"blocked","capability",t,n,{capability:r.trim().toLowerCase()})}:{allowed:!0,warning:null}}function hg(e,t,r,n,o){let i=typeof n=="string"?rl(e,t,n):null,s=lg(e,t,r),a=o.command?ug(e,t,o.command):null,c=o.action?fg(e,t,o.action):null,d=o.service?mg(e,t,o.service):null;return i??s??a??c??d}function gg(e,t,r,n){let o={method:be(e).replace(/\s+/g,"_"),surface:t};return r&&(o.capability=r),n.command&&(o.command=F(n.command)),n.action&&(o.action=be(n.action).replace(/\s+/g,"-")),n.service&&(o.service=be(n.service)),o}function il(e,t,r,n,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=hg(e,t,r,o,s);if(!a)return{allowed:!0,warning:null};let c=ao(e.mode==="warn"?"violation":"blocked","registration",t,a,gg(n,r,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]="cd1de600-27e4-522b-842e-1993c12e9f0e")}catch{}})();var al=100;function sl(e,t){let r=e[t];if(r!=null)return typeof r!="string"||r.trim().length===0?null:r.trim()}function bg(e){if(e==null)return;let t=Ue(e);if(!t)return null;let r={};for(let n of Object.keys(t).sort((o,i)=>o.localeCompare(i))){if(n.trim().length===0)return null;let o=t[n];if(typeof o!="string"||o.trim().length===0)return null;r[n.trim()]=o.trim()}return Object.keys(r).length>0?r:void 0}function _s(e,t){let r=e[t];return typeof r!="string"||r.trim().length===0?null:r.trim()}function cl(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function ht(e){if(e!=null)return typeof e!="boolean"?null:e}function wg(e){let t=cl(e.priority);return t===void 0?al:t}function vg(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let r=Fr(t);return r!==t.trim().toLowerCase()?null:r}function ys(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Eg(e){if(e==null)return;let t=Ue(e);if(!t)return null;let r=ys(t.source),n=ys(t.signature),o=ys(t.attestation),i=t.verified===void 0||t.verified===null?void 0:typeof t.verified=="boolean"?t.verified:null;return i===null?null:{...r?{source:r}:{},...n?{signature:n}:{},...o?{attestation:o}:{},...typeof i=="boolean"?{verified:i}:{}}}function kg(e){if(e==null)return;let t=Ue(e);if(!t)return null;let r=ht(t.fs_read),n=ht(t.fs_write),o=ht(t.network),i=ht(t.env_read),s=ht(t.env_write),a=ht(t.process_spawn);return[r,n,o,i,s,a].includes(null)?null:{...typeof r=="boolean"?{fs_read:r}:{},...typeof n=="boolean"?{fs_write:n}:{},...typeof o=="boolean"?{network:o}:{},...typeof i=="boolean"?{env_read:i}:{},...typeof s=="boolean"?{env_write:s}:{},...typeof a=="boolean"?{process_spawn:a}:{}}}function Sg(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(r=>typeof r!="string"))return null;let t=Sd(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function Og(e){if(e==null)return;let t=Ue(e);if(!t)return null;let r=t.commands;if(r==null)return;if(!Array.isArray(r)||r.some(o=>typeof o!="string"))return null;let n=[...new Set(r.map(o=>F(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return n.length>0?{commands:n}:void 0}function Ag(e){let t=cl(e.manifest_version);if(t===null)return null;let r=sl(e,"pm_min_version");if(r===null)return null;let n=sl(e,"pm_max_version");if(n===null)return null;let o=bg(e.engines);if(o===null)return null;let i=ht(e.trusted);if(i===null)return null;let s=vg(e);if(s===null)return null;let a=Eg(e.provenance);if(a===null)return null;let c=kg(e.permissions);if(c===null)return null;let d=Sg(e.capabilities);if(d===null)return null;let l=Og(e.activation);if(l===null)return null;let u=no(e.contributions);return u===null?null:{manifest_version:t,pm_min_version:r,pm_max_version:n,engines:o,trusted:i,sandbox_profile:s,provenance:a,permissions:c,capabilities:d.capabilities,legacy_capability_aliases:d.legacy_aliases,activation:l,contributions:u}}function hs(e){if(typeof e!="object"||e===null)return null;let t=e,r=_s(t,"name");if(r===null)return null;let n=_s(t,"version");if(n===null)return null;let o=_s(t,"entry");if(o===null)return null;let i=wg(t);if(i===null)return null;let s=Ag(t);return s===null?null:{name:r,version:n,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 Ig from"node:fs/promises";import zr from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="029e0066-2ef5-5204-92ad-4866321710f4")}catch{}})();async function dl(e,t){let r=zr.dirname(t.manifest_path),n=zr.relative(r,t.entry_path);if(n.startsWith("..")||zr.isAbsolute(n))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=zr.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await Cd("extension_module_graph_snapshot",()=>Ig.cp(r,o,{recursive:!0,force:!0})),zr.join(o,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]="bf5c3834-b388-507e-a13c-3beb5d096abb")}catch{}})();function ll(e){let t=typeof e=="function"?e:e.run;if(typeof t!="function")throw new TypeError("registerPreflight override requires a function handler");let r=[...new Set((typeof e=="function"?[]:e.commands??[]).map(n=>{if(typeof n!="string"||n.trim().length===0)throw new TypeError("registerPreflight ownership.commands must contain non-empty command paths");return F(n)}))];return{run:t,...r.length>0?{commands:r}:{}}}function ul(e){let t=[];for(let r=1;r<e.overrides.length;r+=1){let n=e.overrides[r];for(let o of e.overrides.slice(0,r))n.commands?.length&&o.commands?.length&&!o.commands.some(i=>n.commands.includes(i))||t.push(`extension_preflight_override_collision:${n.layer}:${n.name}:${o.layer}:${o.name}`)}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="47d10c23-88f8-5ba1-bcc2-458f339121a8")}catch{}})();var co=Bt;function fl(e){let t=e.trim().toLowerCase();return co.includes(t)?t:null}function ml(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let r=Math.max(1,Math.floor(t.length*.34));for(let n of co)if(oo(t,n,r)!==null)return n;return null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="355fe619-e6f3-51d9-b88c-0b57267c25be")}catch{}})();function pl(e){return e==="toon"||e==="json"}function _l(e){return Ht.includes(e)}function gt(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var yl=Symbol("extension_registration_trace");function Ne(e,t){let r=new TypeError(e);return Object.defineProperty(r,yl,{value:t,enumerable:!1,configurable:!1,writable:!1}),r}function hl(e){return e instanceof Error?e[yl]:void 0}function Ur(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>Ur(t));if(typeof e=="function")return"[Function]";if(typeof e=="bigint"||typeof e=="symbol")return e.toString();if(typeof e=="object"){let t=e,r={};for(let n of Object.keys(t).sort((o,i)=>o.localeCompare(i)))r[n]=Ur(t[n]);return r}return e}function Hr(e){if(Array.isArray(e))return e.map(t=>Hr(t));if(typeof e=="object"&&e!==null){let t=e,r={};for(let n of Object.keys(t).sort((o,i)=>o.localeCompare(i)))r[n]=Hr(t[n]);return r}return e}function Jt(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Ur(t)}function qr(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Hr(t)}function Vr(e,t){if(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(r=>Jt(e,r))}function ee(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function Br(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function gs(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function bs(e,t){return F(`${e} ${t}`)}function Wr(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var Tg=new Set(["low","medium","high"]),Cg=new Set(["number","string_set"]),Rg=new Set(["string","number","boolean"]);function gl(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function xg(e,t,r){let n=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=G(n,r);if(!Cg.has(String(o.value_type)))throw new TypeError(`${n}.value_type must be number or string_set`);if(H(`${n}.description`,o.description),o.parameters===void 0)return;let i=G(`${n}.parameters`,o.parameters);for(let[s,a]of Object.entries(i)){let c=`${n}.parameters.${s}`;gl(`${c}.name`,s);let d=G(c,a);if(!Rg.has(String(d.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);Z(`${c}.required`,d.required),H(`${c}.description`,d.description)}if(Object.keys(i).length>50)throw new TypeError(`assurance provider ${e} key ${t} exceeds 50 parameters`)}function bl(e){let t=G("registerAssuranceMeasurementProvider provider",e),r=gl("registerAssuranceMeasurementProvider provider.id",t.id);if(!/^[a-z0-9][a-z0-9-]*$/u.test(r))throw new TypeError("registerAssuranceMeasurementProvider provider.id must be a stable lowercase id");if(!Tg.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 n=G("registerAssuranceMeasurementProvider provider.keys",t.keys);if(Object.keys(n).length===0)throw new TypeError("registerAssuranceMeasurementProvider provider.keys requires at least one key");for(let[o,i]of Object.entries(n)){if(!/^[a-z0-9][a-z0-9-]*$/u.test(o))throw new TypeError(`registerAssuranceMeasurementProvider provider key ${o} must be a stable lowercase id`);xg(r,o,i)}if(t.timeout_ms!==void 0&&(typeof t.timeout_ms!="number"||!Number.isInteger(t.timeout_ms)||t.timeout_ms<1||t.timeout_ms>3e5))throw new TypeError("registerAssuranceMeasurementProvider provider.timeout_ms must be an integer from 1 through 300000");if(typeof t.resolve!="function")throw new TypeError("registerAssuranceMeasurementProvider provider.resolve requires a function handler")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4abca948-e9ba-52b5-b63c-a20fc344980a")}catch{}})();var Ng=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","value_validation","visible"]);function lo(e,t){return Vr(e,t).map(r=>(r.repeatable===!0&&(r.list=!0),r))}function Dg(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function ws(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 r=Dg(t);if(r.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return r}function vs(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[n,o]of e.entries()){let i=G(`registerCommand definition.arguments[${n}]`,o),s=ee(`registerCommand definition.arguments[${n}].name`,i.name);if(Z(`registerCommand definition.arguments[${n}].required`,i.required),Z(`registerCommand definition.arguments[${n}].variadic`,i.variadic),H(`registerCommand definition.arguments[${n}].description`,i.description),s.includes(" "))throw new TypeError(`registerCommand definition.arguments[${n}].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 r=t.map((n,o)=>n.variadic?o:-1).filter(n=>n>=0);if(r.length>1)throw new TypeError("registerCommand definition.arguments supports at most one variadic argument");if(r.length===1&&r[0]!==t.length-1)throw new TypeError("registerCommand definition.arguments variadic argument must be the final argument");return t}function uo(e){if(!Array.isArray(e))throw new TypeError("registerFlags flags requires an array of object definitions");for(let[t,r]of e.entries()){let n=G(`registerFlags flags[${t}]`,r),o=Object.keys(n).filter(c=>!Ng.has(c)).sort((c,d)=>c.localeCompare(d));if(o.length>0)throw new TypeError(`registerFlags flags[${t}] contains unknown field(s): ${o.join(", ")}`);let i=n.long,s=n.short;if(i===void 0&&s===void 0)throw new TypeError(`registerFlags flags[${t}] requires at least one of long or short`);H(`registerFlags flags[${t}].long`,i),H(`registerFlags flags[${t}].short`,s);let a=xd(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${Nd(a.token,a.failure)}`);if(H(`registerFlags flags[${t}].value_name`,n.value_name),H(`registerFlags flags[${t}].description`,n.description),Z(`registerFlags flags[${t}].required`,n.required),Z(`registerFlags flags[${t}].enabled`,n.enabled),Z(`registerFlags flags[${t}].visible`,n.visible),Z(`registerFlags flags[${t}].list`,n.list),Z(`registerFlags flags[${t}].repeatable`,n.repeatable),n.list!==void 0&&n.repeatable!==void 0&&n.list!==n.repeatable)throw new TypeError(`registerFlags flags[${t}].list and repeatable must match when both are provided`);if(Vd(`registerFlags flags[${t}].default`,n.default),Array.isArray(n.default)&&n.list!==!0&&n.repeatable!==!0)throw new TypeError(`registerFlags flags[${t}].default cannot be an array unless list is true.`);wl(`registerFlags flags[${t}]`,n),Pg(`registerFlags flags[${t}]`,n)}}function Pg(e,t){if(t.value_validation===void 0)return;if(t.value_validation!=="coerce"&&t.value_validation!=="strict")throw new TypeError(`${e}.value_validation must be "coerce" or "strict" (received ${JSON.stringify(t.value_validation)}).`);if(t.value_validation!=="strict")return;let r=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0),n=r===void 0?null:io(r);if(n!=="number"&&n!=="boolean")throw new TypeError(`${e}.value_validation "strict" requires value_type "number" or "boolean" (string values are never malformed).`)}function wl(e,t){let r=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0);if(r===void 0)return;let n=io(r);if(n===null)throw new TypeError(`${e} value_type "${r}" is not a known flag value type (expected one of: string, number, boolean).`);if(t.default===void 0)return;let o=t.list===!0||t.repeatable===!0?Pd(t.default):[t.default];for(let[i,s]of o.entries())if(!Md(s,n)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${n}.`)}}function vl(e){if(!Array.isArray(e))throw new TypeError("registerItemFields fields requires an array of object definitions");for(let[t,r]of e.entries()){let n=G(`registerItemFields fields[${t}]`,r);ee(`registerItemFields fields[${t}].name`,n.name);let o=ee(`registerItemFields fields[${t}].type`,n.type);if(fl(o)===null){let i=ml(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${co.join(", ")}).${s}`)}Z(`registerItemFields fields[${t}].optional`,n.optional)}}function Mg(e,t){if(t===void 0)return;let r=`registerItemTypes types[${e}].command_option_policies`;if(!Array.isArray(t))throw new TypeError(`${r} must be an array when provided`);for(let[n,o]of t.entries()){let i=`${r}[${n}]`,s=G(i,o);ee(`${i}.command`,s.command),ee(`${i}.option`,s.option),Z(`${i}.enabled`,s.enabled),Z(`${i}.required`,s.required),Z(`${i}.visible`,s.visible)}}function $g(e,t){if(t===void 0)return;let r=`registerItemTypes types[${e}].options`;if(!Array.isArray(t))throw new TypeError(`${r} must be an array when provided`);for(let[n,o]of t.entries()){let i=`${r}[${n}]`,s=G(i,o);ee(`${i}.key`,s.key),yt(`${i}.values`,s.values),Z(`${i}.required`,s.required),yt(`${i}.aliases`,s.aliases)}}function El(e){if(!Array.isArray(e))throw new TypeError("registerItemTypes types requires an array of object definitions");for(let[t,r]of e.entries()){let n=`registerItemTypes types[${t}]`,o=G(n,r);ee(`${n}.name`,o.name),H(`${n}.folder`,o.folder),yt(`${n}.aliases`,o.aliases),yt(`${n}.required_create_fields`,o.required_create_fields),yt(`${n}.required_create_repeatables`,o.required_create_repeatables),Mg(t,o.command_option_policies),$g(t,o.options)}}function kl(e){let t=G("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(Z("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 Sl=["types","statuses","fields","workflows","config","templates","packages"],jg={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[r,n]of t.allowed_transitions.entries())if(!Array.isArray(n))throw new TypeError(`${e}.allowed_transitions[${r}] 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 Ol(e){let t=G("registerProfile profile",e);if(ee("registerProfile profile.name",t.name),ee("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 r of Sl){let n=t[r];if(n!==void 0){if(!Array.isArray(n))throw new TypeError(`registerProfile profile.${r} must be an array when provided`);for(let[o,i]of n.entries()){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError(`registerProfile profile.${r}[${o}] must be an object`);jg[r]?.(`registerProfile profile.${r}[${o}]`,i)}}}}function Al(e){e.summary===void 0&&(e.summary="");for(let t of Sl)e[t]===void 0&&(e[t]=[]);return e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="45ff820c-32af-5bdb-a570-3059684129ce")}catch{}})();function Il(e){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("registerService ownership must be an object");if(Reflect.ownKeys(e).some(t=>t!=="passThrough"))throw new TypeError("registerService ownership supports only passThrough");if(e.passThrough!==void 0&&typeof e.passThrough!="boolean")throw new TypeError("registerService ownership.passThrough must be a boolean when provided");return e.passThrough===!0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b5de5028-f981-599b-8d11-0fc7b07beda4")}catch{}})();function Tl(e){return typeof e=="string"?e:String(e)}function Gr(e){let t=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(t)?t.split(/[.-]/).map(r=>Number(r)):null}function Es(e,t){let r=Gr(e),n=Gr(t);if(!r||!n)return null;let o=Math.max(r.length,n.length);for(let i=0;i<o;i+=1){let s=r[i]??0,a=n[i]??0;if(s>a)return 1;if(s<a)return-1}return 0}function Cl(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let r=Tl(e);if(typeof e!="string"||r.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:r,current:t};if(!Gr(r))return{kind:"pm_min_version",status:"invalid",allowed:!1,required:r,current:t};if(t===null)return{kind:"pm_min_version",status:"unchecked",allowed:!0,required:r,current:null};let n=Es(t,r);return n===null?{kind:"pm_min_version",status:"unchecked",allowed:!0,required:r,current:t}:n<0?{kind:"pm_min_version",status:"unmet",allowed:!1,required:r,current:t}:{kind:"pm_min_version",status:"ok",allowed:!0,required:r,current:t}}function Rl(e,t,r){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let n=Tl(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_max_version",status:"invalid",allowed:!1,required:n,current:t};if(/^[<>=~^]/.test(n.trim())||!Gr(n))return{kind:"pm_max_version",status:"invalid",allowed:!1,required:n,current:t};if(t===null)return{kind:"pm_max_version",status:"unchecked",allowed:!0,required:n,current:null};let o=Es(t,n);return o===null?{kind:"pm_max_version",status:"unchecked",allowed:!0,required:n,current:t}:o>0?r==="warn"?{kind:"pm_max_version",status:"exceeded_warn",allowed:!0,required:n,current:t}:{kind:"pm_max_version",status:"exceeded",allowed:!1,required:n,current:t}:{kind:"pm_max_version",status:"ok",allowed:!0,required:n,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]="187f03b7-1a62-500c-9ebf-4d5a053afa74")}catch{}})();var xl=null,Fg=Object.freeze(qc()),Nl=0;function zg(e=Date.now()){return Nl+=1,`${Nl}-${e}`}function Ug(e,t,r){return r.has(e)?!1:t.size===0?!0:t.has(e)}async function Hg(e,t){let[r,n]=await Promise.all([wt.realpath(e),wt.realpath(t)]);return us(r,n)}function qg(e,t=process.cwd()){return{global:bt.join(_d(t),"extensions"),project:bt.join(e,"extensions")}}async function Vg(e){try{return(await wt.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,r)=>t.localeCompare(r))}catch{return[]}}function Bg(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 Dl(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function Wg(e){let t=new Map;try{let r=JSON.parse(await wt.readFile(bt.join(e,".managed-extensions.json"),"utf8")),n=Ue(r)?.entries;if(!Array.isArray(n))return t;for(let o of n){if(typeof o!="object"||o===null)continue;let i=o,s=Dl(i.source?.package),a=[i.source?.input,i.source?.name,s].map(l=>Dl(l)).filter(l=>l!==void 0),c=no(i.contributions),d={aliases:[...new Set(a)],...s?{package_name:s}:{},...c?{contributions:c}:{}};typeof i.directory=="string"&&i.directory.trim().length>0&&t.set(`directory:${i.directory.trim()}`,d),typeof i.name=="string"&&i.name.trim().length>0&&t.set(`name:${i.name.trim()}`,d)}}catch{return t}return t}function Pl(e){return[...e].sort((t,r)=>{if(t.manifest.priority!==r.manifest.priority)return t.manifest.priority-r.manifest.priority;let n=t.manifest.name.localeCompare(r.manifest.name);return n!==0?n:t.directory.localeCompare(r.directory)})}function Gg(e,t){let r=[...Pl(e),...Pl(t)],n=[];for(let o of r){let i=n.findIndex(s=>s.manifest.name===o.manifest.name);i>=0&&n.splice(i,1),n.push(o)}return n}async function Ml(e,t,r,n,o){let i=[],s=[],a=[],c=await Vg(t),d=await Wg(t);for(let l of c){let u=await Xg(e,t,l,r,n,d,o);i.push(u.diagnostic),s.push(...u.warnings),u.candidate&&a.push(u.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function Kg(){return{diagnostics:[],warnings:[],candidates:[]}}function $l(e,t,r,n){return{diagnostic:{layer:e,directory:t,manifest_path:r,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[n],candidate:null}}function Yg(e,t,r,n,o,i,s){let a=Id(e,t,r);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&a.push(Ad(e,t.name,t.legacy_capability_aliases));for(let c of kd(t.capabilities))a.push(Od(e,t.name,c));return n?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 Xg(e,t,r,n,o,i,s){let a=bt.join(t,r),c=bt.join(a,"manifest.json");if(!await ft(c))return $l(e,r,c,`extension_manifest_missing:${e}:${r}`);let d,l;try{let Ee=JSON.parse(await wt.readFile(c,"utf8"));l=Ue(Ee),d=hs(Ee)}catch{l=null,d=null}if(!d||!l)return $l(e,r,c,`extension_manifest_invalid:${e}:${r}`);let u=bt.resolve(a,d.entry),f=us(a,u),m=f?await ft(u):!1,_=f&&m?await Hg(a,u):f,y=Ug(d.name,n,o),w=await Qg(e,d),v=await eb(e,d,s),T=Yg(e,d,l,_,m,w,v),K=_&&m&&w.allowed&&v.allowed,ve=i.get(`directory:${r}`)??i.get(`name:${d.name}`);return{diagnostic:{layer:e,directory:r,manifest_path:c,name:d.name,version:d.version,entry:d.entry,priority:d.priority,entry_path:u,enabled:y,status:K?"ok":"warn"},warnings:T,candidate:Kd({layer:e,directory:r,manifestPath:c,entryPath:u,manifest:d,sourceIdentity:ve,extensionReady:K,enabledForLoad:y})}}async function Jg(e){let t=qg(e.pmRoot,e.cwd??process.cwd()),r=Mr(e.settings.extensions.enabled),n=Mr(e.settings.extensions.disabled),o=Qd(e.settings),i=el(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:r,configured_disabled:n,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(r),a=new Set(n),c=e.ignoreGlobalExtensions===!0?Kg():await Ml("global",t.global,s,a,o.pmMaxVersionExceededMode.global),d=await Ml("project",t.project,s,a,o.pmMaxVersionExceededMode.project),l=[...o.warnings],u=Gg(c.candidates,d.candidates),f=[];for(let m of u){let _={layer:m.layer,name:m.manifest.name,trusted:m.manifest.trusted===!0,provenanceVerified:m.manifest.provenance?.verified===!0,sandboxProfile:m.manifest.sandbox_profile,permissions:m.manifest.permissions&&typeof m.manifest.permissions=="object"?{fs_read:m.manifest.permissions.fs_read,fs_write:m.manifest.permissions.fs_write,network:m.manifest.permissions.network,env_read:m.manifest.permissions.env_read,env_write:m.manifest.permissions.env_write,process_spawn:m.manifest.permissions.process_spawn}:void 0},y=nl(o,_);if(y.warning&&l.push(y.warning),!!y.allowed){for(let w of m.manifest.capabilities){let v=ol(o,_,w);v.warning&&l.push(v.warning)}f.push(Bg(m))}}return{disabled_by_flag:!1,roots:t,configured_enabled:r,configured_disabled:n,discovered:[...c.diagnostics,...d.diagnostics],effective:f,warnings:[...new Set([...c.warnings,...d.warnings,...l])],policy:i}}function fo(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function Zg(){try{let e=Un(import.meta.url,["../../.."]),t=await wt.readFile(bt.join(e,"package.json"),"utf8"),r=JSON.parse(t);return typeof r.version=="string"&&r.version.trim().length>0?r.version.trim():null}catch{return null}}function Fl(){return xl??=Zg(),xl}function zl(e,t,r){let n=r.current??"unknown";if(r.kind==="pm_min_version")switch(r.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${t.name}:required=${r.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${t.name}:required=${r.required}:current=${n}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${t.name}:required=${r.required}:current=${n}`;default:return}switch(r.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${t.name}:allowed=${r.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${t.name}:allowed=${r.required}:current=${n}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${t.name}:allowed=${r.required}:current=${n}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${t.name}:allowed=${r.required}:current=${n}`;default:return}}async function Qg(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let r=Cl(t.pm_min_version,await Fl()),n=zl(e,t,r);return n?{allowed:r.allowed,warning:n}:{allowed:r.allowed}}async function eb(e,t,r){if(t.pm_max_version===void 0)return{allowed:!0};let n=Rl(t.pm_max_version,await Fl(),r),o=zl(e,t,n);return o?{allowed:n.allowed,warning:o}:{allowed:n.allowed}}async function jl(e){try{let t=await wt.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function tb(e,t){let r=e.entry_path;t.module_graph_snapshot_root&&(r=await dl(t.module_graph_snapshot_root,e));let n=new URL(Lg(r).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return n.href;let[o,i]=await Promise.all([jl(e.entry_path),jl(e.manifest_path)]),s=t.reload_token??zg();return n.searchParams.set("pm_ext_reload",s),n.searchParams.set("pm_ext_entry",o),n.searchParams.set("pm_ext_manifest",i),n.href}async function px(e){let t=await Jg(e),r=[],n=[],o=[...t.warnings];if(t.disabled_by_flag)return{...t,warnings:o,loaded:r,failed:n};let i=typeof e.extensionFilter=="function"?t.effective.filter(e.extensionFilter):t.effective;for(let s of i)try{let a=await import(await tb(s,e));r.push({...s,module:a})}catch(a){o.push(`extension_load_failed:${s.layer}:${s.name}`),n.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:fo(a)})}return{...t,warnings:o,loaded:r,failed:n}}var Ll=5e3,rb=2147483647;function nb(e){let t={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let r=e.deactivate;t.deactivate=r.bind(e)}return t}function Ul(e){let t=Qc(e);return t?nb(t):null}async function _x(e,t,r={}){let n=ob(r?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(l=>`${l.layer}:${l.name}`)),i=[];for(let l of e.loaded){if(o.has(`${l.layer}:${l.name}`))continue;let u=Ul(l.module);!u||typeof u.deactivate!="function"||i.push({extension:l,deactivate:u.deactivate})}let s=await Promise.all(i.map(async({extension:l,deactivate:u})=>{try{return await ib(u,n),{ok:!0}}catch(f){return{ok:!1,layer:l.layer,name:l.name,error:fo(f)}}})),a=[],c=[],d=0;for(let l of s){if(l.ok){d+=1;continue}a.push(`extension_deactivate_failed:${l.layer}:${l.name}`),c.push({layer:l.layer,name:l.name,error:l.error})}return{deactivated:d,warnings:a,failed:c}}function ob(e){return typeof e!="number"||e<0?Ll:e===0||e===1/0?0:Number.isFinite(e)?Math.min(rb,Math.max(1,Math.floor(e))):Ll}async function ib(e,t){if(t===0){await e();return}let r;try{let n=Promise.resolve().then(()=>e());n.catch(()=>{}),await Promise.race([n,new Promise((o,i)=>{r=setTimeout(()=>{i(new Error(`extension deactivate timed out after ${t}ms`))},t),r.unref?.()})])}finally{clearTimeout(r)}}function sb(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let r of e.capabilities){let n=r.trim().toLowerCase();qe(n)&&t.add(n)}return t}function z(e,t,r){let n=sb(e);if(n!==null&&!n.has(t))throw Ne(`${r} requires capability '${t}' in extension manifest capabilities`,{method:r,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 ${r} registration call.`})}function ab(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>Ce.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function cb(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 ks=class{extension;hooks;#e;#r;#o;#n;#s;#a;#i;#c;#t;#d;#l;#u;constructor(t,r,n,o,i,s,a,c,d,l,u){this.#e=t,this.extension=ab(t),this.#r=cb(t),this.#o=r,this.#n=n,this.#s=o,this.#a=i,this.#i=s,this.#c=a,this.#t=c,this.#d=d,this.#l=l,this.#u=u,this.registerCommand=this.registerCommand.bind(this),this.registerParser=this.registerParser.bind(this),this.registerPreflight=this.registerPreflight.bind(this),this.registerService=this.registerService.bind(this),this.registerFlags=this.registerFlags.bind(this),this.registerItemFields=this.registerItemFields.bind(this),this.registerItemTypes=this.registerItemTypes.bind(this),this.registerRelationshipKinds=this.registerRelationshipKinds.bind(this),this.registerMigration=this.registerMigration.bind(this),this.registerProfile=this.registerProfile.bind(this),this.registerRenderer=this.registerRenderer.bind(this),this.registerImporter=this.registerImporter.bind(this),this.registerExporter=this.registerExporter.bind(this),this.registerSearchProvider=this.registerSearchProvider.bind(this),this.registerVectorStoreAdapter=this.registerVectorStoreAdapter.bind(this),this.registerAssuranceMeasurementProvider=this.registerAssuranceMeasurementProvider.bind(this),this.hooks={beforeCommand:f=>this.registerBeforeCommand(f),beforeMutation:f=>this.registerBeforeMutation(f),afterCommand:f=>this.registerAfterCommand(f),onWrite:f=>this.registerOnWrite(f),onRead:f=>this.registerOnRead(f),onIndex:f=>this.registerOnIndex(f)}}allowRegistration(t,r,n,o){let i=il(this.#u,this.#r,t,r,n,o);return i.warning&&this.#d.push(i.warning),i.allowed}registerCommandTrace(t,r,n,o,i){return{method:"registerCommand",registration_index:t==="override"?this.#n.overrides.length:this.#n.handlers.length,command:r,expected_schema:n,received:Ur(o),hint:i}}registerCommandOverride(t,r){let n=F(t);if(n.length===0)throw Ne("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 r!="function"){let o=this.registerCommandTrace("override",n,'registerCommand("<command>", (context) => unknown)',r,"Provide a function as the second registerCommand argument.");throw Ne(`registerCommand requires an override function when command name is provided (command="${n}", registration_index=${o.registration_index})`,o)}this.allowRegistration("commands.override","registerCommand","commands",{command:n})&&this.#n.overrides.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}resolveCommandDefinitionRunHandler(t,r){let n=typeof t.run=="function"?t.run:void 0,o=typeof t.handler=="function"?t.handler:void 0;return!n&&o&&this.#d.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${r}`),n??o}registerCommandDefinition(t){if(typeof t!="object"||t===null)throw Ne("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 Ne("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 r=F(t.name);if(r.length===0)throw Ne("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 n=this.resolveCommandDefinitionRunHandler(t,r);if(typeof n!="function"){let o=this.registerCommandTrace("definition",r,"{ name: string; run: (context) => unknown; }",n,"Define command definition.run as a function.");throw Ne(`registerCommand requires a command definition run handler (command="${r}", registration_index=${o.registration_index})`,o)}try{Bd(t);let o=ws(r,t.action),i=Wd(t.read_output,r,o);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:r,action:o}))return;let s=t.description?.trim(),a=t.intent?.trim(),c=Lr("registerCommand definition.examples",t.examples),d=Lr("registerCommand definition.failure_hints",t.failure_hints),l=vs(t.arguments);t.flags!==void 0&&(z(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(uo(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:lo("registerCommand definition.flags",t.flags)})));let u={read_output:i,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:r,action:o,examples:c,failure_hints:d,arguments:l,tier:t.tier??"standard",family:t.family??"extensions"};s&&(u.description=s),a&&(u.intent=a),this.#t.commands.push(u)}catch(o){let i=fo(o),s=this.registerCommandTrace("definition",r,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=Ne(`registerCommand definition metadata invalid (command="${r}", registration_index=${s.registration_index}): ${i}`,s);this.#d.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${r}`),this.#l.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}registerCommand(t,r){if(z(this.#e,"commands","registerCommand"),typeof t=="string"){this.registerCommandOverride(t,r);return}this.registerCommandDefinition(t)}registerParser(t,r){if(z(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let n=F(ee("registerParser command",t));Br("registerParser override",r),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}registerPreflight(t){if(z(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let r=ll(t);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...r})}registerService(t,r,n={}){z(this.#e,"services","registerService");let o=String(t).trim().toLowerCase();if(!_l(o))throw new TypeError(`registerService service must be one of: ${Ht.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(Br("registerService override",r),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:r,...Il(n)?{passThrough:!0}:{}}))}registerRenderer(t,r,n={}){if(z(this.#e,"renderers","registerRenderer"),!this.allowRegistration("renderers.override","registerRenderer","renderers"))return;if(typeof r!="function")throw new TypeError("registerRenderer requires a renderer function");let o=String(t).trim().toLowerCase();if(!pl(o))throw new Error(`registerRenderer format must be toon|json, received: ${String(t)}`);if(n.resultDiscriminator!==void 0&&typeof n.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");let i=[...new Set((n.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return F(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:o,run:r,commands:i,...n.resultDiscriminator?{resultDiscriminator:n.resultDiscriminator}:{}})}registerFlags(t,r){if(z(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let n=F(ee("registerFlags targetCommand",t));uo(r);let o=lo("registerFlags flags",r);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:n,flags:o})}registerItemFields(t){if(z(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;vl(t);let r=Vr("registerItemFields fields",t);if(r.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:r})}registerItemTypes(t){if(z(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;El(t);let r=Vr("registerItemTypes types",t);if(r.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:r})}registerRelationshipKinds(t){if(z(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 r=Mi();for(let o of this.#t.relationship_kinds)for(let i of o.definitions)r.register(i);let n=t.map(o=>(r.register(o),r.require(o.kind)));this.#t.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:n})}registerMigration(t){if(z(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;kl(t);let r=qr("registerMigration definition",t);this.#t.migrations.push(Wr({layer:this.#e.layer,name:this.#e.name,definition:Jt("registerMigration definition",t)},r))}registerProfile(t){if(z(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let r=Hr(t);Ol(r),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:Al(r)})}registerImportExportCommandFlags(t,r,n){n.flags!==void 0&&(z(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(uo(n.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:lo(`${t} options.flags`,n.flags)})))}applyImportExportCommandMetadata(t,r,n){if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))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={...n,description:n?.description??o,arguments:n?.arguments??i},a=Gd(t,s,n?.description!==void 0);H(`${t} options.action`,s.action),H(`${t} options.description`,s.description),H(`${t} options.intent`,s.intent);let c=ws(r,s.action),d=Lr(`${t} options.examples`,s.examples),l=Lr(`${t} options.failure_hints`,s.failure_hints),u=vs(s.arguments);this.registerImportExportCommandFlags(t,r,s);let f={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:r,action:c,examples:d,failure_hints:l,arguments:u},m=s.description?.trim();m&&(f.description=m);let _=s.intent?.trim();return _&&(f.intent=_),this.#t.commands.push(f),a}registerImporter(t,r,n){if(z(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=gs(ee("registerImporter name",t));Br("registerImporter importer",r);let i=bs(o,"import");this.applyImportExportCommandMetadata("registerImporter",i,n),this.#t.importers.push({layer:this.#e.layer,name:this.#e.name,importer:o}),this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>r(ms(s,o,"import"))})}registerExporter(t,r,n){if(z(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=gs(ee("registerExporter name",t));Br("registerExporter exporter",r);let i=bs(o,"export"),s=this.applyImportExportCommandMetadata("registerExporter",i,n);this.#t.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:o,...s===void 0?{}:{output:s}}),this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async a=>{let c=await r(ms(a,o,"export"));return s?.receipt==="suppress"&&!zn(c)?Xc(c):c}})}registerSearchProvider(t){if(z(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let r=qr("registerSearchProvider provider",t);this.#t.search_providers.push(Wr({layer:this.#e.layer,name:this.#e.name,definition:Jt("registerSearchProvider provider",t)},r))}registerVectorStoreAdapter(t){if(z(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let r=qr("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(Wr({layer:this.#e.layer,name:this.#e.name,definition:Jt("registerVectorStoreAdapter adapter",t)},r))}registerAssuranceMeasurementProvider(t){if(z(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(bl(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let r=qr("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(Wr({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:Jt("registerAssuranceMeasurementProvider provider",t)},r))}registerBeforeCommand(t){z(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(gt("beforeCommand",t),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerBeforeMutation(t){z(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(gt("beforeMutation",t),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerAfterCommand(t){z(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(gt("afterCommand",t),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnWrite(t){z(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(gt("onWrite",t),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnRead(t){z(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(gt("onRead",t),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnIndex(t){z(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(gt("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function db(e,t,r,n,o,i,s,a,c,d,l){return new ks(e,t,r,n,o,i,s,a,c,d,l)}function lb(e){let t=e.commands.length,r=e.flags.reduce((s,a)=>s+a.flags.length,0),n=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:r,item_fields:n,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 ub(e){let t=[],r=(i,s)=>{let a=new Map;for(let c of i){let d=a.get(c.command)??[];d.push(c),a.set(c.command,d)}for(let c of[...a.keys()].sort((d,l)=>d.localeCompare(l))){let d=a.get(c);if(d.length<=1)continue;let l=d[d.length-1];for(let u of d.slice(0,-1))t.push(`${s}:${c}:${l.layer}:${l.name}:${u.layer}:${u.name}`)}};r(e.handlers,"extension_command_handler_collision"),r(e.overrides,"extension_command_override_collision");let n=new Set(e.handlers.map(i=>i.command)),o=[...new Set(e.overrides.map(i=>i.command))].filter(i=>n.has(i));o.sort((i,s)=>i.localeCompare(s));for(let i of o){let s=e.handlers.filter(c=>c.command===i),a=e.overrides.filter(c=>c.command===i);for(let c of a)for(let d of s)t.push(`extension_command_override_handler_overlap:${i}:${c.layer}:${c.name}:${d.layer}:${d.name}`)}return t}function fb(e){let t=new Map;for(let n of e.overrides){let o=t.get(n.format)??[];o.push(n),t.set(n.format,o)}let r=[];for(let n of[...t.keys()].sort((o,i)=>o.localeCompare(i))){let o=t.get(n);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))||r.push(`extension_renderer_collision:${n}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return r}function mb(e){let t=[],r=new Map;for(let n of e.overrides){let o=r.get(n.command)??[];o.push(n),r.set(n.command,o)}for(let n of[...r.keys()].sort((o,i)=>o.localeCompare(i))){let o=r.get(n);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:${n}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}var pb=new Set(["output_format"]);function _b(e){let t=[],r=new Map;for(let n of e.overrides){let o=r.get(n.service)??[];o.push(n),r.set(n.service,o)}for(let n of[...r.keys()].sort((o,i)=>o.localeCompare(i))){let o=r.get(n);if(o.length<=1||pb.has(n))continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_service_override_collision:${n}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}async function yx(e){let t=tl(e.policy??Fg),r=$r(),n=Wi(),o=Gi(),i=Ki(),s=Yi(),a=Xi(),c=Ji(),d=[],l=[];for(let m of e.loaded){let _=Ul(m.module);if(!_)continue;let y=d.length,w=qd({hooks:r,commands:n,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await _.activate(db(m,r,n,o,i,s,a,c,l,d,t)),d.length>y&&(w(),l.push(`extension_activation_rolled_back:${m.layer}:${m.name}`))}catch(v){w(),l.push(`extension_activate_failed:${m.layer}:${m.name}`);let T=hl(v);d.push({layer:m.layer,name:m.name,entry_path:m.entry_path,error:fo(v),trace:T})}}let u=[...ub(n),...mb(o),...ul(i),..._b(s),...fb(a)],f=[...new Set([...l,...u])];return{hooks:r,commands:n,parsers:o,preflight:i,services:s,renderers:a,registrations:c,failed:d,warnings:f,hook_counts:{before_command:r.beforeCommand.length,before_mutation:r.beforeMutation.length,after_command:r.afterCommand.length,on_write:r.onWrite.length,on_read:r.onRead.length,on_index:r.onIndex.length},command_override_count:n.overrides.length,command_handler_count:n.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:lb(c)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b1a38f8c-8f65-59e2-bddf-ed0606a0f0b5")}catch{}})();function wx(e){return{...e,hooks:$r(),profileEnabled:!!e.globalOptions.profile,migrationBlockers:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4da25248-2914-5bc5-aa42-87f677ef4ea8")}catch{}})();function Ex(){let e=Promise.resolve(),t=new Set;return{async read(r){let n=e,o,i=new Promise(s=>{o=s});t.add(i),await n;try{return await r()}finally{t.delete(i),o()}},write(r){let n=Promise.all([e,...t]).then(()=>r());return e=n.then(()=>{},()=>{}),n}}}function yb(){let e=Promise.resolve(),t=0,r=[],n=()=>{if(t!==0)return;let o=r.splice(0);for(let i of o)i()};return{enqueue(o){t++;let i=e.then(()=>o());return e=i.then(()=>{},()=>{}).finally(()=>{t--,n()}),i},idle(){return t===0?Promise.resolve():new Promise(o=>r.push(o))}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d8844150-afb4-5f2e-a005-4cfb8482660c")}catch{}})();var hb={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"]},Hl=":";function ql(e,t){return`${e}${Hl}${Ss(t)}`}function gb(e){return e.slice(e.indexOf(Hl)+1)}function Ss(e){return e.trim().toLowerCase()}function bb(e){if(!Array.isArray(e))return[];let t=new Set;for(let r of e){let n=Ed(r);n!==null&&t.add(n)}return[...t].sort((r,n)=>r.localeCompare(n))}function Vl(e){let t=new Map,r=(l,u)=>{for(let f of l){let m=ql(f.layer,f.name),_=t.get(m);_===void 0&&(_=new Set,t.set(m,_)),_.add(u)}},{registrations:n,commands:o,parsers:i,preflight:s,services:a,renderers:c,hooks:d}=e;return r(n.commands,"commands"),r(o.overrides,"commands"),r(o.handlers,"commands"),r(n.flags,"schema"),r(n.item_fields,"schema"),r(n.item_types,"schema"),r(n.relationship_kinds??[],"schema"),r(n.migrations,"schema"),r(n.profiles,"schema"),r(n.importers,"importers"),r(n.exporters,"importers"),r(n.search_providers,"search"),r(n.vector_store_adapters,"search"),r(i.overrides,"parser"),r(s.overrides,"preflight"),r(a.overrides,"services"),r(n.assurance_providers??[],"services"),r(c.overrides,"renderers"),r(d.beforeCommand,"hooks"),r(d.beforeMutation,"hooks"),r(d.afterCommand,"hooks"),r(d.onWrite,"hooks"),r(d.onRead,"hooks"),r(d.onIndex,"hooks"),t}function wb(e,t={}){let r=Vl(e),n=new Set;t.extensionName!==void 0&&n.add(Ss(t.extensionName));for(let i of t.extensionNames??[])n.add(Ss(i));let o=new Set;for(let[i,s]of r)if(!(n.size>0&&!n.has(gb(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function vb(e,t){let r=Vl(t),n=[];for(let o of e){let i=bb(o.capabilities);if(i.length===0)continue;let s=r.get(ql(o.layer,o.name))??new Set,a=[...s].sort((d,l)=>d.localeCompare(l)),c=i.filter(d=>!s.has(d));n.push({layer:o.layer,name:o.name,declared:i,used:a,unused:c})}return n}import{existsSync as Eb}from"node:fs";import{AsyncLocalStorage as kb}from"node:async_hooks";import De 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]="7c2e7a35-cbf9-5bb6-abfd-f1ae75c6afc2")}catch{}})();var Pe=null,Zt=null,Kr=null,Yr=null,Qt=null,Xr=null,Jr=null,We=null,po,mo=[],Wl=new kb;function M(){return Wl.getStore()}function Rx(e){return Wl.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var Sb=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function Bl(e){let t=De.resolve(e);for(;;){if(Eb(De.join(t,".git")))return t;let r=De.dirname(t);if(r===t)return;t=r}}function _o(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),r=Bl(t)??De.resolve(t),n=Bl(r);if(!e)return{source_workspace_root:r,...n?{repo_root:n}:{}};let o=De.relative(r,De.resolve(e)),i=o.length>0&&!o.startsWith(`..${De.sep}`)&&o!==".."&&!De.isAbsolute(o);return{source_workspace_root:r,...n?{repo_root:n}:{},...i?{pm_root_rel:o.split(De.sep).join("/")}:{}}}function xx(e){let t=M();if(t){t.hooks=e;return}Pe=e}function Nx(e){let t=M();if(t){t.commands=e;return}Zt=e}function Dx(e){let t=M();if(t){t.parsers=e;return}Kr=e}function Px(e){let t=M();if(t){t.preflight=e;return}Yr=e}function Mx(e){let t=M();if(t){t.services=e;return}Qt=e}function $x(e){let t=M();if(t){t.renderers=e;return}Xr=e}function jx(e){let t=M();if(t){t.registrations=e;return}Jr=e}function Gl(){let e=M();return e?e.registrations:Jr}function Lx(){let e=M();if(e){e.hooks=null,e.commands=null,e.parsers=null,e.preflight=null,e.services=null,e.renderers=null,e.registrations=null,e.commandContext=null,e.commandResult=null,e.affectedItems=[];return}Pe=null,Zt=null,Kr=null,Yr=null,Qt=null,Xr=null,Jr=null,We=null,po=null}function Fx(e){let t=e?{...e,..._o(e.pm_root)}:null,r=M();if(r){r.commandContext=t;return}We=t}function Kl(){let e=M(),t=e?e.commandContext:We;return t?{...t,args:[...t.args],options:t.options?{...t.options}:{},global:t.global?{...t.global}:void 0}:null}function zx(e){let t=M()??{commandContext:We,hooks:Pe,commands:Zt,parsers:Kr,preflight:Yr,services:Qt,renderers:Xr,registrations:Jr};return t.commandContext?.command!==e||[t.hooks,t.preflight,t.services,t.renderers].some(r=>Object.values(r??{}).some(n=>n.length>0))||[t.commands,t.parsers].some(r=>Object.values(r??{}).some(n=>n.some(o=>o.command===e)))?!1:!Object.entries(t.registrations??{}).some(([r,n])=>["migrations","search_providers","vector_store_adapters","assurance_providers"].includes(r)&&n.length>0)}function yo(e){let t=M();if(t){t.commandResult=e;return}po=e}function Ux(){let e=M();return e?e.commandResult:po}function Hx(e){if(!e)return;let t=M();t?t.affectedItems.push(e):mo.push(e)}function qx(e,t){if(!e||!e.id)return{};let r={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return r;let n=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"||Sb.has(i)||Object.hasOwn(n,i)&&n[i]!==void 0&&(r[i]=n[i])}return r}function Vx(){let e=M(),t=e?.affectedItems??mo;if(t.length===0)return;let r=t;return e?e.affectedItems=[]:mo=[],r}function Bx(){let e=M();if(e){e.hooks=null,e.commands=null,e.parsers=null,e.preflight=null,e.services=null,e.renderers=null,e.registrations=null,e.commandContext=null,e.commandResult=void 0,e.affectedItems=[];return}Pe=null,Zt=null,Kr=null,Yr=null,Qt=null,Xr=null,Jr=null,We=null,po=void 0,mo=[]}async function ho(e){let t=M(),r=t?t.hooks:Pe;return r?ts(r,e):[]}async function Wx(e){let t=M(),r=t?t.hooks:Pe;r&&await es(r,e)}async function er(e){let t=M(),r=t?t.hooks:Pe;return r?rs(r,e):[]}function Gx(){let e=M();return((e?e.hooks:Pe)?.onRead?.length??0)>0}async function Kx(e){let t=M(),r=t?t.hooks:Pe;return r?ns(r,e):[]}function Yl(e){let t=M(),r=t?t.commands:Zt,n=t?t.commandContext:We;return!r||!n?{overridden:!1,result:e,warnings:[]}:ds(r,{command:n.command,args:[...n.args],options:n.options?{...n.options}:{},global:n.global?{...n.global}:void 0,pm_root:n.pm_root,source_workspace_root:n.source_workspace_root,repo_root:n.repo_root,pm_root_rel:n.pm_root_rel,result:e})}async function Yx(e){let t=M(),r=t?t.commands:Zt;return r?os(r,{...e,..._o(e.pm_root)}):{handled:!1,result:null,warnings:[]}}async function Xx(e){let t=M(),r=t?t.parsers:Kr;return r?is(r,{...e,..._o(e.pm_root)}):{overridden:!1,context:{command:e.command,args:[...e.args],options:{...e.options},global:{...e.global},pm_root:e.pm_root},warnings:[]}}async function Jx(e){let t=M(),r=t?t.preflight:Yr;return r?ss(r,{...e,..._o(e.pm_root)}):{overridden:!1,context:{command:e.command,args:[...e.args],options:{...e.options},global:{...e.global},pm_root:e.pm_root},decision:{...e.decision},warnings:[]}}function Xl(e,t){let r=M(),n=r?r.renderers:Xr,o=r?r.commandContext:We;return n?ls(n,{format:e,command:o?.command,args:o?[...o.args]:[],options:o?.options?{...o.options}:{},global:o?.global?{...o.global}:void 0,pm_root:o?.pm_root,source_workspace_root:o?.source_workspace_root,repo_root:o?.repo_root,pm_root_rel:o?.pm_root_rel,result:t}):{overridden:!1,rendered:null,warnings:[]}}function Jl(e,t){let r=M(),n=r?r.commandContext:We;return{service:e,command:n?.command,args:n?[...n.args]:[],options:n?.options?{...n.options}:{},global:n?.global?{...n.global}:void 0,pm_root:n?.pm_root,source_workspace_root:n?.source_workspace_root,repo_root:n?.repo_root,pm_root_rel:n?.pm_root_rel,payload:t}}async function tr(e,t){let r=M(),n=r?r.services:Qt;return n?cs(n,Jl(e,t)):{handled:!1,result:t,warnings:[]}}function Os(e,t){let r=M(),n=r?r.services:Qt;return n?as(n,Jl(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]="4a7b042c-7fb8-57a5-8f94-de44f82d7589")}catch{}})();function Ob(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function Ge(e,t){let r=e.slice(0,t),n=r.charCodeAt(r.length-1),o=e.charCodeAt(r.length);return n>=55296&&n<=56319&&o>=56320&&o<=57343?r.slice(0,-1):r}function nN(e){return Ob(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function oN(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let r=new Set(e),n=new Set(t),o=0;for(let s of r)n.has(s)&&(o+=1);let i=new Set([...r,...n]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3a66ccfd-51fb-5d4a-b9cd-257c49997d52")}catch{}})();var eu=new WeakMap;function cN(e,t){eu.set(e,new Set(t))}var go='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',Ab={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"}},Ib=[{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 dN(e,t,r){if(e&&t)throw new g(`${r} cannot be combined with --full`,h.USAGE)}function Oe(e,t=new Set){let r=e.filter(n=>!t.has(n.name)).map(n=>({...n}));return{has_omissions:r.length>0,omitted_field_group_count:r.length,omitted_field_groups:r}}function lN(e,t){let r=Ib.find(o=>o.command===e);if(r===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===r.complete_mode)return Oe([]);let n=r.omissions_by_mode[t];if(n===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return Oe(n)}var Tb=[{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 te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Cb=new Set([void 0,"tabular_when_uniform"]),Rb=new Set(["collection","none"]),xb=new Set(["supported","unsupported"]);function Zl(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(r=>typeof r=="string"&&r.length>0)&&new Set(e).size===e.length}function Nb(e){return te(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Rb.has(e.row_kind)&&Zl(e.row_keys,!0)&&(e.continuation_row_keys===void 0||Zl(e.continuation_row_keys,!1))&&xb.has(e.fields)&&Cb.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 Db={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"]},Pb={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 Mb(e,t){let r=e.trim().toLowerCase().split(/\s+/u,1)[0],n=r?.startsWith("list-")?"list":r;if(n==="graph"){let s=typeof t.subcommand=="string"?t.subcommand:"";if(s.length===0)return;let a=Db[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||te(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:go}:{},toon_encoding:"tabular_when_uniform"}}let o=Ab[n],i=Pb[n];return o===void 0||i===void 0||!i.some(s=>Object.hasOwn(t,s))?void 0:(()=>{let s=o.row_keys.filter(a=>{let c=a.split(".").reduce((d,l)=>te(d)?d[l]:void 0,t);return Array.isArray(c)||te(c)});return{command:n,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:go}:{},toon_encoding:"tabular_when_uniform"}})()}function $b(e){if(!te(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;let t=e.projection.declared_field_groups,r=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(r))return;let n=t.filter(s=>te(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=r.filter(s=>typeof s=="string");if(n.length!==t.length||o.length!==r.length)return;let i=new Set(n.map(s=>s.name));if(!(i.size!==n.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return Oe(n,new Set(o))}function jb(e){if(!Array.isArray(e.sections_included))return;let t=Oe(Tb,new Set(e.sections_included.filter(r=>typeof r=="string")));return te(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function Lb(e,t,r){return e==="dependency_provenance"?!1:Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&te(r.schedule)&&Object.hasOwn(r.schedule,e)||["files","tests","docs"].includes(e)&&te(r.linked)&&Array.isArray(r.linked[e])&&r.linked[e].length>0}function Fb(e){if(!te(e.item))return;let t=e.item,r=["comments","notes","learnings","files","tests","docs","reminders","events"],n=["body","children","claim_state","linked","schedule"],o=eu.get(e),i=a=>r.includes(a)||a==="body"||a==="dependency_provenance"?t:e,s=["body",...r,...n.slice(1),...o?.has("dependency_provenance")?["dependency_provenance"]:[],...o?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[]].filter(a=>o===void 0||o.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:a==="blockers"?"--full":a==="dependency_provenance"?"--fields dependencies":`--fields ${a}`}));return Oe(s,new Set(s.flatMap(({name:a})=>Lb(a,i(a),e)?[a]:[])))}function Ql(e){if(te(e.projection))return Oe([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function zb(e){if(!te(e.projection))return Oe([]);if(typeof e.projection.mode=="string")return Oe([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function Ub(e){if(!(!te(e.selected)||typeof e.selected.summary!="boolean"))return Oe([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function Hb(e,t){let r=$b(t);if(r!==void 0)return r;let[n]=e.split(/\s+/u,1);if(n==="context")return jb(t);if(n==="get")return Fb(t);if(n==="list"||n.startsWith("list-"))return Ql(t);if(n==="search")return Ql(t)??Oe([{name:"projection_metadata",restore_with:"--full"}]);if(n==="health")return zb(t);if(n==="contracts")return Ub(t)}function tu(e,t){if(e===void 0||!te(t))return t;let r=Hb(e,t),n=t.row_contract,o=Nb(n)?n:Mb(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 te(i.omission_receipt)||r===void 0?i:{...i,omission_receipt: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]="86412887-5659-5892-beaa-bdd15a02ff4c")}catch{}})();var ru=e=>{let t='"',r=0;for(let n of e){if(n==="\\"){r+=1;continue}t+="\\".repeat(n==='"'?r*2+1:r),t+=n,r=0}return`${t}${"\\".repeat(r*2)}"`},nu=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?ru(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,rr=(e,t=process.platform)=>{let r=e.map(n=>nu(n,t)).join(" ");return r.length>0?`pm ${r}`:"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]="7607f0d2-6e95-5b85-9bc2-18f643a64171")}catch{}})();var ou=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),qb=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function Vb(e){let t=e.indexOf("=");return t>0&&ou.has(e.slice(0,t))}function Bb(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function bo(e){for(let t=0;t<e.length;t+=1){let r=e[t];if(r==="--")return;if(ou.has(r)){t+=Bb(r,e[t+1])?1:0;continue}if(!(Vb(r)||qb.has(r)||r==="--profile"||r==="--id-only"||r==="--explain")&&!r.startsWith("-"))return t}}function mN(e){let t=bo(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]="98cde1d6-d5dd-56b9-89f9-51f5d08221d1")}catch{}})();var Wb=new Set(["--literal","--regex","--replacement"]);function Gb(e){let t=bo(e);if(t===void 0)return!1;if(e[t]==="history-redact")return!0;if(e[t]!=="history")return!1;let r=e.slice(t+1),n=bo(r);return n!==void 0&&r[n]==="redact"}function hN(e){if(!Gb(e))return[...e];let t=[],r=!1;for(let n of e){if(r){t.push("[redacted]"),r=!1;continue}r=!1;let o=n.indexOf("="),i=o>=0?n.slice(0,o):n;if(!Wb.has(i)){t.push(n);continue}if(o>=0){t.push(`${i}=[redacted]`);continue}t.push(i),r=!0}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6db58d1-5d89-56b2-adee-13e985ebc675")}catch{}})();var Kb=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 X(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function iu(e,t){let r=e;for(let n of t.split("."))if(Array.isArray(r)){if(!/^\d+$/u.test(n))return;r=r[Number(n)]}else{if(!X(r))return;r=r[n]}return r}function As(e,t,r){let n=t.split("."),o=(i,s)=>{if(s===n.length)return r;let a=n[s];if(Array.isArray(i)){let d=Number(a),l=[...i];return l[d]=o(i[d],s+1),l}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function su(e,t,r){let n=nr(e).find(s=>s.path===t);if(!n)return e;let o=Array.isArray(n.value)?n.value.slice(r):Object.fromEntries(Object.entries(n.value).slice(r)),i=As(e,t,o);return X(i.summary)&&X(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(r)}}),en(i),i}function vo(e){let t=e.row_contract;return X(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(r=>typeof r=="string"&&r.trim().length>0):Object.entries(e).filter(([,r])=>Array.isArray(r)).map(([r])=>r)}function Yb(e){let t=e.row_contract;return X(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(r=>typeof r=="string"&&r.trim().length>0):vo(e)}function Ke(e){return vo(e).flatMap(t=>{let r=iu(e,t);return Array.isArray(r)||X(r)?[{path:t,value:r}]:[]})}function nr(e){return Yb(e).flatMap(t=>{let r=iu(e,t);return Array.isArray(r)||X(r)?[{path:t,value:r}]:[]})}function Zr(e){let t=Ke(e),r=new Set(t.map(o=>o.path)),n=(o,i)=>{if(Array.isArray(o)){r.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>n(s,`${i}.${a}`));return}if(X(o))for(let[s,a]of Object.entries(o))i.length===0&&Kb.has(s)||n(a,i.length===0?s:`${i}.${s}`)};return n(e,""),t}function Eo(e){return Ke(e).reduce((t,r)=>t+(Array.isArray(r.value)?r.value.length:Object.keys(r.value).length),0)}function Qr(e,t){let r=e;for(let n of Ke(r)){let o=Array.isArray(n.value)?n.value.map((i,s)=>t(i,n.path,s)):Object.fromEntries(Object.entries(n.value).map(([i,s],a)=>[i,t(s,n.path,a)]));r=As(r,n.path,o)}return r}function au(e,t){let r=e,n=!1;for(let o of Ke(r)){let i=Array.isArray(o.value)?o.value:Object.entries(o.value);if(i.length<=t)continue;n=!0;let s=Array.isArray(o.value)?i.slice(0,t):Object.fromEntries(i.slice(0,t));r=As(r,o.path,s)}return{result:r,truncated:n}}var cu=["high_level","low_level","blocked_fallback"];function wo(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function bN(e,t){if(!X(e.summary)||!X(e.summary.returned_focus))return;let r=new Map(t.map(n=>[n.id,n]));e.summary={...e.summary,focus_row_states:Object.fromEntries(cu.map(n=>[n,Array.isArray(e[n])?e[n].filter(X).map(o=>wo(r.get(o.id)??o)).join(""):""]))}}function Xb(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 Jb(e,t,r,n){let o=Array.isArray(t[r])?t[r].filter(X):[],i=Xb(n[r],o.length)??o.map(wo).join(""),s=new Map(o.flatMap((d,l)=>d.id===void 0?[]:[[d.id,i[l]]])),a=Array.isArray(e[r])?e[r].filter(X):[],c=!1;return{states:a.map((d,l)=>{let u=s.get(d.id)??(d.id===void 0?i[l]:void 0)??wo(d);return u!==wo(d)&&(c=!0),u}).join(""),needsStates:c}}function Zb(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 en(e,t=e){if(Zb(e,t),!X(e.summary)||!X(e.summary.returned_focus))return;let r={...e.summary},n=X(t.summary)&&X(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=cu.map(c=>({key:c,...Jb(e,t,c,n)})),i=Object.fromEntries(o.map(({key:c,states:d})=>[c,d])),s=o.some(c=>c.needsStates),a=Object.values(i).join("");typeof r.high_level=="number"&&(r.high_level=Array.isArray(e.high_level)?e.high_level.length:0),typeof r.low_level=="number"&&(r.low_level=Array.isArray(e.low_level)?e.low_level.length:0),r.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?r.focus_row_states=i:delete r.focus_row_states,e.summary=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]="9bdf8ad1-8d1e-5e3e-a23a-ba1d4293402b")}catch{}})();var ko="changed_fields",Qb="changed_field_count",Is="rows",ew=new Set(["apply","rollback"]),fu=new Set(["deleted","would_delete"]),du=256,lu={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function tw(e,t){if(!re(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let r=Object.hasOwn(lu,e.action)?lu[e.action]:void 0;if(!r||!r.every(i=>{let s=e[i];return re(s)&&re(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let n=e[r.at(-1)],o=pu(n);return t.idOnly?o:!t.compactEnvelope&&t.changedFields!=="compact"?null:{...e,...t.compactEnvelope?{...o,changed_field_count:new Set(r.flatMap(i=>e[i].changed_fields)).size}:{},...Object.fromEntries(r.map(i=>[i,tn(e[i],t)]))}}function uu(e){return typeof e!="string"||e.length<=du?e:`${Ge(e,du-1)}\u2026`}function rw(e){if(!re(e))return null;let t={...e};return t.reason=uu(t.reason),re(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([r,n])=>[r,uu(n)]))),t}function re(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function mu(e){let t=e[ko];if(!Array.isArray(t))return null;let r=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[n,o]of Object.entries(e))n!==ko&&(r[n]=o);return r[Qb]=t.length,r}function nw(e){return"item"in e&&Array.isArray(e[ko])}function ow(e){return typeof e.mode=="string"&&ew.has(e.mode)&&Array.isArray(e[Is])}function iw(e,t){let r=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(r,e),r[Is]=t,r}function pu(e){if(!re(e))return null;let t=re(e.item)?e.item:re(e.plan)?e.plan:null;if(t===null)return null;let r=typeof t.id=="string"?t.id:void 0,n=typeof e.outcome=="string"&&fu.has(e.outcome)?e.outcome:typeof t.status=="string"?t.status:void 0;return r?n?{id:r,status:n,...typeof e.deleted=="boolean"?{deleted:e.deleted}:{}}:{id:r}:null}function sw(e,t){if(!re(e))return null;if(re(e.plan)&&re(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||!re(e.item)||typeof e.item.id!="string")return null;let r=e[ko];if(!Array.isArray(r))return null;let n={id:e.item.id,...typeof e.outcome=="string"&&fu.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:r.length};return aw(e,e.item,n),n}function aw(e,t,r){let n=typeof e.close_reason=="string"?e.close_reason:typeof t.close_reason=="string"?t.close_reason:void 0;n!==void 0&&(r.close_reason=n);let o=rw(e.recurrence);o!==null&&(r.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(r.warnings=e.warnings);for(let i of["recovery","follow_up","handoff"])re(e[i])&&(r[i]=e[i]);if(typeof e.claimed_by=="string"||typeof e.released_by=="string")for(let i of["claimed_by","released_by","previous_assignee","forced","skipped","available","attempts","suggestions"])Object.hasOwn(e,i)&&(r[i]=e[i])}function cw(e){let t=ow(e)?e[Is]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let r=!1,n=t.map(o=>{if(!re(o))return o;let i=mu(o);return i?(r=!0,i):o});return r?{projected:iw(e,n),changed:!0}:{projected:e,changed:!1}}function tn(e,t={}){let r=tw(e,t);if(r!==null)return r;if(t.idOnly===!0){let a=pu(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=sw(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!re(e))return e;let n=!1,o=e,i=nw(e)?mu(e):null;i!==null&&(o=i,n=!0);let s=cw(o);return s.changed&&(o=s.projected,n=!0),n?o:e}import{AsyncLocalStorage as SE}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]="1b67272d-8924-5b1b-97cd-74a6a10493be")}catch{}})();function Ts(e){let t=e.trim().toLowerCase().startsWith("extension:"),r=e.trim().toLowerCase().replace(/^extension:/u,"");if(Kt(r))return;let n=Gl()?.commands??[],o=[...n].reverse().find(s=>s.command===r)?.command??(t?void 0:n.find(s=>s.action===r)?.command),i=[...n].reverse().find(s=>s.command===o);return i===void 0||Kt(i.command)||Kt(i.action)?void 0:i}function dw(e){let t=Ts(e);return t?.read_output===void 0?void 0:t}function _u(e,t){let r=dw(e),n=r?.read_output;if(n===void 0)return t;if(typeof t!="object"||t===null||Array.isArray(t))throw new g("Read-only extension commands must return a structured object.",h.USAGE,{code:"extension_read_output_invalid"});for(let o of n.row_keys){let i=t;for(let s of o.split("."))i=typeof i=="object"&&i!==null&&Object.hasOwn(i,s)?Reflect.get(i,s):void 0;if(i===null||typeof i!="object")throw new g(`Read-only extension result is missing declared row collection ${o}.`,h.USAGE,{code:"extension_read_output_invalid"})}return{...t,row_contract:{command:`extension:${r.command}`,row_kind:n.row_keys.length>0?"collection":"none",row_keys:[...n.row_keys],fields:"supported",...n.row_keys.length>0?{jq_selector:go}:{},toon_encoding:"tabular_when_uniform"}}}import{createHash as gv}from"node:crypto";import{createHash as mv}from"node:crypto";import{stripVTControlCharacters as lw}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]="c8a91fc2-57b4-5738-9428-9847ef7afadc")}catch{}})();var uw=["full","compact","brief","summary","counts"],DN=["mutation","read","discovery","governance"],hu=["error","warning","validation_summary","recovery_bundle"],fw=["full","omit_explanation","limit_collections","compact_recovery","action_only"],mw=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"]),pw=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),_w=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),yw={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},hw=3,gw=2,bw=192,ww={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},vw=hu.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:ww[e],minimum_max_estimated_tokens:bw,degradation_ladder:fw,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),Ew=new Map(vw.map(e=>[e.diagnostic_class,e]));function kw(e){let[t=""]=Cr(e).split(/\s+/u);return mw.has(t)?"mutation":pw.has(t)?"discovery":_w.has(t)?"governance":"read"}function gu(e,t=kw(e)){let r=e.trim().replace(/\s+/gu," ");if(r.length===0)throw new TypeError("command must be a non-empty command path");let n=yw[t];return Sw({command:r,budget_class:t,default_max_estimated_tokens:n,default_max_estimated_tokens_by_format:{toon:n,json:Math.ceil(n*hw/gw)},degradation_ladder:uw,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function Sw(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,r]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(r)||r<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var Ow=eo.map(e=>gu(e)),Aw=new Map(Ow.map(e=>[e.command,e]));function bu(e,t={}){let r=e.trim().replace(/\s+/gu," "),[n]=Cr(r).split(" "),o=Aw.get(n);return o?{...o,command:r}:t.generateFallback?gu(r):null}function Et(e){return Math.ceil(Math.max(0,e)/4)}function wu(e){let t=Ew.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${hu.join(", ")}`);return t}function Ye(e){return Et(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function Iw(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Cs(e){if(!Iw(e))return;let t={};for(let r of["suggested_retry","suggested_retry_args","next_best_command","allowed_values","candidate_commands","missing","missing_required_fields","option_scope","retry_after_ms"]){let n=e[r];Array.isArray(n)?t[r]=r==="suggested_retry_args"?n:n.slice(0,3):n!==void 0&&(t[r]=n)}return Object.keys(t).length>0?t:void 0}function Tw(e,t){return typeof e!="string"||e.length<=t?e:`${Ge(e,Math.max(1,t-3))}...`}function vt(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;let r="...",n=Array.from(e),o=0,i=n.length;for(;o<i;){let s=Math.ceil((o+i)/2),a=`${n.slice(0,s).join("")}${r}`;Buffer.byteLength(a,"utf8")<=t?o=s:i=s-1}return`${n.slice(0,o).join("")}${r}`}function vu(e){let t={};for(let r of["code","required","recovery","next_steps","exit_code","type","title","detail","why","examples"])Object.hasOwn(e,r)&&e[r]!==void 0&&(t[r]=e[r]);for(let[r,n]of Object.entries(e))r!=="__proto__"&&!Object.hasOwn(t,r)&&(t[r]=n);return t}var Cw=new Set(["limit_collections","compact_recovery","action_only"]),Rw=new Set(["compact_recovery","action_only"]);function xw(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:Tw(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},r=Cs(e.recovery);return r!==void 0?t.recovery=r: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 Nw(e,t){let r=structuredClone(e);if(t!=="full"&&(delete r.why,delete r.examples),Cw.has(t))for(let[n,o]of Object.entries(r))Array.isArray(o)&&(r[n]=o.slice(0,3));if(Rw.has(t)){let n=Cs(r.recovery);n?r.recovery=n:delete r.recovery}return t!=="action_only"?vu(r):xw(r)}function or(e,t){let r={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let n=0;n<4;n+=1){let o=Ye(r),i=r.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return r}function Dw(e,t,r){let n=or(e,t);for(let i of["recovery","exit_code"])Ye(n)<=r||e[i]===void 0||(delete e[i],n=or(e,t));let o=40;for(;Ye(n)>r&&o>4;)o-=4,e.code=vt(String(e.code),o),e.required=vt(String(e.required),o),n=or(e,t);return n}function Pw(e,t){let r=e.diagnostic_output,{estimated_tokens:n,...o}=r,i=o.omitted_fields.slice(0,8).map(u=>vt(u,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=Cs(e.recovery),c=a&&Ye(a)<=48?a:void 0,d={code:vt(String(e.code),320),required:vt(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},l=or(d,s);for(;Ye(l)>t&&s.omitted_fields.length>0;)s.omitted_fields.pop(),s.omitted_fields_overflow_count=o.omitted_fields.length-s.omitted_fields.length,l=or(d,s);return l=Dw(d,s,t),l}function PN(e,t={}){let r=e,n=t.diagnosticClass??"error",o=wu(n),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=Ye(r),c=Object.keys(r);if(a<=s)return vu(structuredClone(r));let d;for(let[l,u]of o.degradation_ladder.entries()){let f=Nw(r,u),m=c.filter(y=>!Object.hasOwn(f,y)),_=or(f,{diagnostic_class:n,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:l>0,degradation_steps:o.degradation_ladder.slice(0,l+1),omitted_fields:m});if(d=_,Ye(_)<=s)break}return Ye(d)>s&&(d=Pw(d,s)),d}function yu(e){return lw(e).replace(/\r\n/gu,`
2
+ `).replace(/[^\P{Cc}\n]/gu," ")}function MN(e,t,r={}){let n=r.diagnosticClass??"error",o=wu(n),i=r.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=yu(e),c=Et(Buffer.byteLength(a,"utf8")),d=c>s,l=`What is required:
3
+ `,u=`
4
+
5
+ ${vt(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=yu(t).trim()||"Inspect the diagnostic code and retry with corrected input.",m=Math.max(1,s*4-Buffer.byteLength(`${l}${u}`,"utf8")),_=d?`${l}${vt(f,m)}${u}`:a;return{output:_,diagnostic_output:{diagnostic_class:n,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:Et(Buffer.byteLength(_,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}(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]="f7d00f9c-6e95-5426-971d-9b30e2ec1652")}catch{}})();var Rs=256,xs=1e4,Mw=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,Eu=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,$w=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),jw=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&Mw.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=Rs,reason:`token_budget must be a safe integer of at least ${Rs}.`},{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<=xs&&e.seen_item_ids.every(t=>typeof t=="string"&&Eu.test(t)),reason:`seen_item_ids must contain at most ${xs} portable item identifiers.`}];function Oo(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function So(e){throw new g(`--output-session ${e}`,h.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function Ao(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{So("must be a valid JSON object.")}Oo(t)||So("must be a JSON object.");let r=Object.keys(t).filter(i=>!$w.has(i));r.length>0&&So(`contains unknown field "${r.sort()[0]}".`);let n=jw.find(i=>!i.valid(t));n!==void 0&&So(n.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 ku(e){if(Oo(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:Oo(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function Lw(e){let t=new Set,r=0,n=Ke(e),o=new Set(n.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[...n,...i]){let a=Array.isArray(s.value)?s.value:Object.values(s.value);for(let c of a){if(!Oo(c))continue;if(typeof c.context_ref=="string"){r+=1;continue}let d=ku(c);d!==void 0&&Eu.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:r}}function Su(e,t){let r=new Set(t.seen_item_ids);return Qr(e,n=>{let o=ku(n);return o!==void 0&&r.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:n})}function Ns(e,t,r){let{deliveredIds:n,suppressedRepeatCount:o}=Lw(e),i=new Set(t.seen_item_ids),s=[...n].filter(y=>!i.has(y)).sort(),a=s.slice(0,xs-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),d=s.length-a.length,l={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:n.size,...d===0?{}:{seen_item_overflow_count:d},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:c}},u={...e,read_session:l},f=y=>{l.spent_this_call_tokens=y,l.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,y),l.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+l.charged_this_call_tokens),l.remaining_tokens=Math.max(0,t.token_budget-l.spent_total_tokens),l.exhausted=l.remaining_tokens<Rs,l.next_state.spent_tokens=l.spent_total_tokens},m=0,_=0;for(let y=0;y<8;y+=1){f(m);let w=rn(u,r);if(w===m)return u;_=Math.max(_,w),m=w}return f(_),u}function Ou(e){return Math.max(0,e.token_budget-e.spent_tokens)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1cc0fcb7-2aaa-5233-bdfd-4b4d0fb3e9c1")}catch{}})();var nn=Symbol.for("pm.readOutputInvocationProvenance");function HN(e,t){return Reflect.set(e,nn,{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]="d8782989-f417-515e-892a-17ae8ff2b5fa")}catch{}})();var kt=["include","amount","cost","encoding"],Du=["canonical","legacy","intent","default"],sn=to,iD=Object.freeze(kt.map(e=>sn[e])),sD=ro,Pu={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:{}},Mu=new Set(["--collapse","--fields","--section"]),Ps=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded --output-budget unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function Ms(e){return e.slice(2).replaceAll("-","_")}function Fw(e,t){let r=Ps[e];if(r!==void 0)return r;let n=t==="include"?Mu.has(e)?"<csv>":Ms(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${sn[t]} ${n}.`}function $u(e){let t=Pu[e]??{},r=Object.freeze(Object.fromEntries(kt.map(n=>[n,Object.freeze({dimension:n,canonical_option:sn[n],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[n]??[]).map(o=>Object.freeze({flag:o,semantics:Ps[o]===void 0?"replacement":"behavior_preserving",migration_hint:Fw(o,n),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:r,precedence:Du,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...Lu(e).keys()])})}var zw=Object.freeze(Gt.map($u)),Uw=new Map(zw.map(e=>[e.command,e]));function ar(e,t={}){let r=Cr(e.trim().toLowerCase()),n=Ts(r);return n!==void 0?n.read_output===void 0?void 0:`extension:${n.command}`:Hw(r,t)}function Hw(e,t){let r=e==="package catalog"||e==="packages catalog"||e==="package-catalog"||(e==="package"||e==="packages"||e==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":e==="package manage"||e==="package-manage"?"package-manage":e.split(" ")[0],n=r.startsWith("list-")?"list":r==="ctx"?"context":r;return Gt.includes(n)?n:void 0}var qw=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],Vw={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 Bw(e){return qw.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var Ww=[{keys:["outputInclude","output_include"],valid:e=>on(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||sr(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||sr(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(Ao(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 aD(e,t){let r=t.outputFormat??t.output_format;if(r!==void 0&&r!=="json"&&r!=="toon")throw new g("--output-format must be toon or json.",h.USAGE);if(!Bw(t))return;let n=ar(e,t);if(!n)throw new g(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,h.USAGE);if((Vw[n]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new g(`Universal output controls cannot be combined with a ${n} mutation.`,h.USAGE);for(let o of Ww){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new g(o.message,h.USAGE)}}function ju(e){let t=ar(e);return t?Lu(t):new Map}function Lu(e){return new Map((Pu[e]?.include??[]).filter(t=>!Mu.has(t)&&Ps[t]===void 0).map(t=>[Ms(t),Fu(t)]))}function Gw(e,t,r){let n=on(t)??[],o=ju(e),i=[],s=[],a=r,c=a[nn],d=new Set(c?.canonical_include_modes??[]),l=new Set(c?.explicit_legacy_aliases??[]);for(let m of n){let _=o.get(m);if(_===void 0){i.push(m);continue}let y=`--${m.replaceAll("_","-")}`;js($s(r,y))&&l.add(y),r[_]=!0,s.push(m),d.add(m)}let u=ar(e)==="get"?i.filter(m=>m!=="item"):[],f=u.length>0;return f&&(r.fields=[...new Set([...on(r.fields)??[],...u])].join(","),d.add("fields")),(s.length>0||f)&&(a[nn]={canonical_include_modes:[...d],explicit_legacy_aliases:[...l],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function cD(e,t){let r=t.outputInclude??t.output_include;if(r===void 0)return;let{selectors:n,modes:o}=Gw(e,r,t);if(o.length===0)return;let i=n.length>0?n.join(","):void 0;t.outputInclude=i,Object.hasOwn(t,"output_include")&&(t.output_include=i)}function Fu(e){return e.slice(2).replace(/-([a-z])/gu,(t,r)=>r.toUpperCase())}function $s(e,t){let r=Fu(t);if(Object.hasOwn(e,r))return e[r];let n=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,n))return e[n];if(t==="--no-truncate"&&e.truncate===!1)return!0}function js(e){return e!==void 0&&e!==!1&&e!==null}function on(e){let t=(Array.isArray(e)?e:[e]).flatMap(r=>typeof r=="string"?r.split(","):[]).map(r=>r.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function sr(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 Kw(e,t,r,n){for(let o of e.legacy_aliases){if(n(o.flag))continue;let i=$s(t,o.flag),s={value:i,flag:o.flag};if(js(i)&&r(s))return s}}function Au(e,t){let r=on(e);if(r)return{source:"canonical",value:r};if(t)return{source:"legacy",value:on(t.value)??[Ms(t.flag)]}}function Iu(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let r=sr(e);if(r!==void 0)return{source:"canonical",value:r};if(!t)return;if(t.flag==="--no-truncate"||t.flag==="--unbounded")return{source:"legacy",value:"unbounded"};let n=sr(t.value);return n===void 0?void 0:{source:"legacy",value:n}}function Tu(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let r=sr(e);if(r!==void 0)return{source:"canonical",value:r};if(!t)return;let n=sr(t.value);return n===void 0?void 0:{source:"legacy",value:n}}function Cu(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 zu(e,t,r){if(!e)return!1;let n=new Set(e.explicit_legacy_aliases);if(e.cli_invocation_observed===!0||e.sdk_invocation_observed===!0)return!n.has(r);let o=new Set(e.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return t==="include"&&o.has(r)&&!n.has(r)}function Yw(e,t,r,n){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||js($s(n,"--no-truncate"))&&!zu(r,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||r?.canonical_include_modes.includes("full")===!0}function Xw(e,t){return kt.flatMap(r=>e[r]?.source==="canonical"||r==="include"&&(t?.canonical_include_modes.length??0)>0?[sn[r]]:[])}function Uu(e,t){let r=ar(e,t);if(!r)return;let n=Uw.get(r)??$u(r),o=t[nn],i={include:v=>Au(void 0,v),amount:v=>Iu(void 0,v),cost:v=>Tu(void 0,v),encoding:v=>Cu(void 0,v)},s=Object.fromEntries(kt.map(v=>[v,Kw(n.dimensions[v],t,T=>i[v](T)!==void 0,T=>zu(o,v,T))])),a=kt.flatMap(v=>{let T=s[v];return T?[T.flag]:[]}),c=kt.flatMap(v=>{let T=s[v];return T?[n.dimensions[v].legacy_aliases.find(K=>K.flag===T.flag).migration_hint]:[]}),d=Cu(t.outputFormat??t.output_format,s.encoding),l=Au(t.outputInclude??t.output_include,s.include),u=Iu(t.outputLimit??t.output_limit,s.amount),f=Tu(t.outputBudget??t.output_budget,s.cost),m=Yw(e,s,o,t),_=bu(e,{generateFallback:!0}),y=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",w=f??(m?{source:"intent",value:"unbounded"}:{source:"default",value:_.default_max_estimated_tokens_by_format[y]});return{command:r,include:l,amount:u,cost:w,encoding:d,canonical_options_used:Xw({include:l,amount:u,cost:w,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:Du}}function Q(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Ls=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"]),Jw=["collection_counts","notes_count","tests_count"];function Hu(e,t){let r=new Set(t.map(n=>n.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([n])=>r.has(n)))}function Zw(e){let t=Q(e.item)?e.item:{},r=[...new Set([...Object.keys(t),...Jw.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),n=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!Ls.has(o)).sort((o,i)=>o.localeCompare(i));return{item:t,itemFields:r,sections:n,valid:[...r,"item",...r.map(o=>`item.${o}`),...n]}}function Qw(e,t){let r=Zw(e),n=t.filter(l=>!r.valid.includes(l));if(n.length>0)throw new g(`Unknown --output-include selector(s) for get: ${n.join(", ")}. Valid selectors: ${r.valid.join(", ")}.`,h.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:r.itemFields.includes(l)?[l]:[]).filter((l,u,f)=>f.indexOf(l)===u);if(o&&i.length>0)throw new g("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",h.USAGE);let s=new Set(t.filter(l=>r.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>Ls.has(l)||s.has(l)));o?a.item=r.item:i.length>0&&(a.item=Hu(r.item,i));let c=[...o?[]:i.length>0?r.itemFields.filter(l=>!i.includes(l)).map(l=>({name:`item.${l}`,restore_with:`--output-include item.${l}`})):[{name:"item",restore_with:"--output-include item"}],...r.sections.filter(l=>!s.has(l)).map(l=>({name:l,restore_with:`--output-include ${l}`}))],d=[...Q(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 Ru(e){let t=0;return Qr({...e},r=>(Q(r)&&Object.keys(r).length>0&&(t+=1),r)),t}function ev(e,t,r,n){if(Ru(t)===0||Ru(r)>0)return;let o=[...ju(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 g(`Unknown --output-include selector(s) for ${e}: ${n.join(", ")}. No selector matched any returned row field.${i}`,h.USAGE)}function tv(e,t,r){if(e==="get")return Qw(t,r);let n=vo(t),o=r.flatMap(s=>n.flatMap(a=>s.startsWith(`${a}.`)?[s.slice(a.length+1)]:[])),i=r.some(s=>Object.hasOwn(t,s.split(".")[0])&&!n.some(a=>s.startsWith(`${a}.`)));if(n.length>0&&(!i||o.length>0)){let s={...t},a=o.length>0?o:r,c=Qr(s,d=>Q(d)?Hu(d,a):d);return ev(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>r.some(a=>a.split(".")[0]===s)||Ls.has(s)))}function rv(e,t){if(t==="unbounded")return e;let{result:r,truncated:n}=au(e,t);if(!n)return r;if(r.has_more=!0,r.truncated=!0,typeof r.count=="number"){let o=Q(r.projection)?r.projection.row_key:void 0;r.count=typeof o=="string"&&Array.isArray(r[o])?r[o].length:Eo(r)}return r.applied_bound={kind:"output_limit",source:"explicit",value:t},r}function nv(e){return kt.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(sn[t]))}function qu(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function Io(e,t,r,n){let o=Ns(e,t,n);ir(e,o);for(let i=0;i<8;i+=1){let s=r.estimated_tokens,a=o.read_session.spent_this_call_tokens;Xe(o,r,n);let c=o;o=Ns(o,t,n),ir(c,o);let d=o.read_session.spent_this_call_tokens;if(r.estimated_tokens===s&&d===a)return o}return o}function Fs(e,t){if(!Q(e.read_output))return e;let r=qu(t),n=e.read_output,o=Ao(t.outputSession??t.output_session);return o===void 0?(Xe(e,n,r),e):Io(e,o,n,r)}function ov(e,t){if(e!=="validate")return t;let r=Q(t.projection)?t.projection:void 0;if(!(Array.isArray(r?.declared_field_groups)?r.declared_field_groups:[]).some(l=>Q(l)&&l.name==="diagnostic_rows"))return t;let n=[...new Set(Zr(t).map(({path:l})=>l).filter(l=>/^checks\.\d+\.details\./u.test(l)))],o=n.filter(l=>!n.some(u=>u!==l&&l.startsWith(`${u}.`)));if(o.length===0)return t;let i=Q(t.row_contract)?t.row_contract:{},s=Array.isArray(i.row_keys)?i.row_keys.filter(l=>typeof l=="string"):[],a=Array.isArray(i.continuation_row_keys)?i.continuation_row_keys.filter(l=>typeof l=="string"):[],c=s.length>0?s:o,d=[...new Set(o)];return JSON.stringify(c)===JSON.stringify(s)&&JSON.stringify(d)===JSON.stringify(a)?t:{...t,row_contract:{...i,row_keys:c,continuation_row_keys:d,jq_selector:typeof i.jq_selector=="string"?i.jq_selector:".checks[].details"}}}function iv(e,t,r,n,o){let i={...e};if(t.include?.source==="canonical"&&(i=tv(t.command,i,t.include.value)),t.command==="assurance"&&(i=Zu(i)),en(i,e),i=Qu(i,t.command,n),t.command==="history"&&n){let c=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([d])=>!c.includes(d)||d===n.path)),Q(i.projection)&&(i.projection={...i.projection,row_key:n.path}),Q(i.row_contract)){let d=i.row_contract;i.row_contract={...d,row_keys:[n.path],...Array.isArray(d.continuation_row_keys)?{continuation_row_keys:[n.path]}:{}}}i.count=Object.keys(i[n.path]).length}let s=e.count_only===!0?{...i,count_only:!0,count:e.count}:i,a=uv(i,e,t.command,n,o);return t.amount?.source==="canonical"&&(i=rv(i,t.amount.value),a.cursorContinuesExistingPage&&Gu(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),en(i,s),{projected:r===void 0?i:Su(i,r),continuationState:a}}function sv(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default"||e.command==="context"&&e.cost.source==="legacy")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:Ou(t)}]].sort((r,n)=>r.tokens-n.tokens)[0]}function Vu(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function Bu(e,t){return Q(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function Wu(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!Bu(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function av(e,t,r,n,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...Wu(n),precedence:e.precedence,...Vu(e),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...r===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=r===void 0?a:Io(a,r,s,i);if(r===void 0&&Xe(c,s,i),r!==void 0&&s.estimated_tokens>n.tokens)throw new g("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",h.USAGE);return c}function cv(e,t,r){return e.command==="context"&&e.cost?.source==="legacy"&&!Bu(r,e.cost.value)||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 dv(e,t,r,n,o){if(t!==void 0||cv(e,o,r))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(Ke(r).some(({value:s})=>(Array.isArray(s)?s.length:Object.keys(s).length)>i))return!1}return e.cost===void 0||e.cost.value==="unbounded"||e.cost.source==="legacy"&&e.command!=="context"||rn(o.outputRowContract===!1?Object.fromEntries(Object.entries(r).filter(([i])=>i!=="row_contract")):r,n)<=e.cost.value}function lv(e,t,r,n,o,i,s){if(!r.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map(nr(e).map(_=>[_.path,Array.isArray(_.value)?_.value.length:Object.keys(_.value).length])),d=[...s.entries()].flatMap(([_,y])=>{let w=c.get(_);if(w>=y.rows)return[];let v=y.baseOffset+w;return[{path:_,cursor:zs({command:t.command,path:_,offset:v,total_rows:y.totalRows,fingerprint:y.fingerprint}),retained_rows:w,remaining_rows:y.totalRows-v,total_rows:y.totalRows}]}),l=d[0],u=l?"; page --output-cursor":"",f=n.source==="session"?`Truncated by the remaining ${n.tokens}-token session budget; start a new output session with a larger token_budget${u}.`:`${n.tokens}-token: raise --output-budget${u}`;r.migration_hints=[f,...t.migration_hints];let m=Ds({effective_budget_tokens:n.tokens,measured_result_tokens:i});l&&!o&&(typeof e.next_cursor!="string"||e.continuation_kind==="output_cursor")&&(e.next_cursor=l.cursor),e.continuation_kind=o?"producer_cursor":l?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:n.source,budget_tokens:n.tokens,overridden_dimensions:a,compacted_row_paths:r.compacted_row_paths,continuation_cursor_rebased:o,continuation_available:d.length>0,recovery_budget_multiplier:l?1:m.recovery_budget_multiplier,continuations:d,restore_with:l?"recovery":`Retry with --output-budget ${m.output_budget} because no declared row collection can be continued.`,recovery:l?{cursor:l.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${m.output_budget}`,sdk:{outputBudget:m.output_budget},mcp:{outputBudget:m.output_budget}}}}function Gu(e,t,r,n,o){if(typeof r!="string"||!Array.isArray(e.items))return!1;let i=e.items.length,s=t.length;if(i===0||i>=s)return!1;let a;try{a=Us(r)}catch{return!1}let c=a.after_index;if(c===void 0)return!1;let d=t[i-1];if(Object.prototype.toString.call(d)!=="[object Object]")return!1;let l=Reflect.get(d,"id");if(typeof l!="string"||l.length===0)return!1;let u=n?c-(s-i):c+o+i;return u<0?!1:(e.next_cursor=cn(a.fingerprint,l,u,a.snapshot),!0)}function uv(e,t,r,n,o){let i=new Map(nr(e).map(c=>{let d=Array.isArray(c.value)?c.value.length:Object.keys(c.value).length,l=n?.path===c.path;return[c.path,{rows:d,totalRows:l?n.total_rows:d,baseOffset:l?n.offset:0,fingerprint:l?n.fingerprint:To(c.path,c.value,r)}]})),s=typeof e.next_cursor=="string",a=n?.path==="items"?n.offset:0;return{collectionsBeforeBudget:i,originalItems:Array.isArray(t.items)?a>0?t.items.slice(a):t.items:[],originalItemOffset:a,cursorContinuesExistingPage:s,cursorSource:s?e.next_cursor:o.after}}function fv(e,t,r,n,o,i,s,a,c,d){let l={...t,count_only:r},u=n.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(m=>Q(m)&&m.verdict!=="pass").length:0,f=new Map;if(u>0&&f.set("assertions",u),n.command==="history"&&Array.isArray(e.diff))for(let m of Zr(e))m.path.startsWith("diff.")&&f.set(m.path,Object.keys(m.value).length);return Nu(e,o,i.tokens,f,d,m=>{en(m,l);let _=Gu(m,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(lv(m,n,o,i,_,c,a.collectionsBeforeBudget),n.command==="history"&&Q(m.projection)){m.has_more=typeof m.next_cursor=="string"||m.applied_bound?.kind==="output_limit";let y=m.projection.row_key;typeof y=="string"&&Array.isArray(m[y])&&(m.count=m[y].length)}s!==void 0&&Object.assign(m,Io(m,s,o,d))},n.command==="history"&&Array.isArray(e.diff))}function Ku(e,t,r){let n=Uu(e,t);if(!n)return r;let o=qu(t),i=Ao(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?an(s):void 0,c=nv(n),d=ov(n.command,r);if(a===void 0&&dv(n,i,d,o,t))return d;let l=sv(n,i),u=iv(d,n,i,a,t),f=u.projected;ir(f,f,t.outputRowContract===!1);let m={contract_version:1,command:n.command,requested_dimensions:c,...Wu(l,f),precedence:n.precedence,...Vu(n),legacy_aliases_used:n.legacy_aliases_used,migration_hints:n.migration_hints,estimated_tokens:0,within_budget:!0,strings_compacted:!1,rows_compacted:!1,result_omitted:!1};if(f.read_output=m,f=i===void 0?f:Io(f,i,m,o),Xe(f,m,o),l!==void 0&&m.estimated_tokens>l.tokens){let _=xu(n.command,t,f);_!==void 0&&(m.applied_depth="brief",m.degradation_reason="output_budget_reached",ir(f,_),f=Fs(_,t)),m.estimated_tokens>l.tokens&&(f=fv(f,f,d.count_only===!0,n,m,l,i,u.continuationState,m.estimated_tokens,o))}return l!==void 0&&m.estimated_tokens>l.tokens?av(n,c,i,l,m.estimated_tokens,o):f}function Yu(e){return Q(e)&&Q(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function Xu(e,t){let r=t.outputFormat??t.output_format;if(r==="json"||r==="toon")return r;let n=Uu(e,t)?.encoding;return n?.value==="json"||n?.value==="toon"?n.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]="f7f59eaa-9d5d-5797-99de-e672fdfba99d")}catch{}})();var pv=4096,_v=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"]),Ju=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:_v}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function ln(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function dn(e){return Array.isArray(e)?e.map(dn):ln(e)?Object.fromEntries(Object.entries(e).map(([t,r])=>[t,dn(r)])):e}function ef(e,t){if(!ln(e))return dn(e);let r=typeof e.name=="string"?e.name:void 0,n=r!==void 0&&Object.hasOwn(t.ignored_detail_field_names_by_row,r)?t.ignored_detail_field_names_by_row[r]:void 0;return Object.fromEntries(Object.entries(e).map(([o,i])=>o!=="details"||!n||!ln(i)?[o,dn(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!n.includes(s)).map(([s,a])=>[s,dn(a)]))]))}function yv(e,t){return Array.isArray(e)?e.map(r=>ef(r,t)):ef(e,t)}function To(e,t,r){let n=r?Ju[r]:void 0,o=n?.paths.includes(e)===!0;return mv("sha256").update(R({path:e,value:o?yv(t,n):t,...o?{fingerprint_policy_version:n.version}:{}})).digest("base64url").slice(0,16)}function zs(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 hv(e){return typeof e=="string"&&(ar(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function an(e){if(e.length>pv)throw new g("The read-output continuation cursor is malformed or unsupported.",h.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!ln(t)||t.v!==1||!hv(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 g("The read-output continuation cursor is malformed or unsupported.",h.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 Zu(e){if(!Array.isArray(e.assertions))return e;let t=r=>!ln(r)||r.verdict==="pass"?4:r.verdict==="retired"?3:r.enforcement==="block"?0:r.enforcement==="warn"?1:2;return{...e,assertions:e.assertions.map((r,n)=>({row:r,index:n})).sort((r,n)=>t(r.row)-t(n.row)||r.index-n.index).map(({row:r})=>r),budget_retention_policy:"verdict_priority"}}function Qu(e,t,r){if(!r)return e;if(r.command!==t)throw new g(`The read-output cursor belongs to ${r.command}, not ${t}.`,h.USAGE,{code:"read_output_cursor_command_mismatch"});let n=nr(e).find(i=>i.path===r.path),o=n?Array.isArray(n.value)?n.value.length:Object.keys(n.value).length:0;if(!n||o!==r.total_rows||r.offset>o||To(r.path,n.value,t)!==r.fingerprint)throw new g("The read-output continuation no longer matches the declared row collection; restart the bounded read.",h.USAGE,{code:"read_output_cursor_stale"});return su(e,r.path,r.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]="400de68f-104b-5a25-9e79-f69da940832f")}catch{}})();var qs=1,tf=4096,bv=/^[A-Za-z0-9_-]+$/;function Hs(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,r)=>r.toUpperCase())}function kD(e,t){let r=[...Object.values(to),...ro],n=new Set(r.flatMap(o=>[Hs(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){n.add(Hs(o.flag));for(let i of o.aliases??[])n.add(Hs(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!n.has(o)))}function SD(e,t){return gv("sha256").update(e).update("\0").update(R(t)).digest("hex").slice(0,24)}function cn(e,t,r,n){return Buffer.from(JSON.stringify({version:qs,fingerprint:e,after_id:t,...r===void 0?{}:{after_index:r},...n===void 0?{}:{snapshot:n}})).toString("base64url")}function St(e){return new g(e,h.USAGE,{code:"invalid_query_cursor",nextSteps:["Repeat the original query without --after to obtain a fresh cursor."]})}function wv(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===qs&&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 Us(e){if(typeof e!="string")throw St("Query cursor is malformed.");let t=e.trim();if(t.length===0||t.length>tf||!bv.test(t))throw St("Query cursor is malformed.");let r;try{r=JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{throw St("Query cursor is malformed.")}if(!wv(r)){let n=!1;try{an(t),n=!0}catch{}throw n?new g("An output cursor must be continued with --output-cursor, not --after.",h.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing --after with --output-cursor ${t}; retain any producer --after cursor from the original page.`]}):St("Query cursor version or payload is unsupported.")}return r}function Vs(e,t){let r=Us(e);if(r.fingerprint!==t)throw St(`Query cursor does not match the current filters, sort, or query (${r.fingerprint} != ${t}).`);return{after_id:r.after_id,...r.after_index===void 0?{}:{after_index:r.after_index},...r.snapshot===void 0?{}:{snapshot:r.snapshot}}}function OD(e,t){return Vs(e,t).after_id}function vv(e,t,r,n){if(t===void 0)return 0;let o=Vs(t,r),i=e.findIndex(s=>n(s)===o.after_id);if(i<0){if(o.after_index!==void 0)return Math.min(o.after_index,e.length);throw St(`Query cursor item ${o.after_id} is no longer present in this result set.`)}return i+1}function AD(e,t){if(t.cursor!==void 0&&Vs(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw St("Query cursor does not match the requested snapshot.");let r=vv(e,t.cursor,t.fingerprint,t.readId),n=e.slice(r,r+t.limit),o=n.length>0&&r+n.length<e.length,i=n.at(-1);return{rows:n,has_more:o,...o&&i!==void 0?{next_cursor:cn(t.fingerprint,t.readId(i),r+n.length-1,t.snapshot)}:{}}}var ID=Object.freeze({version:qs,max_length:tf});import{randomUUID as pE}from"node:crypto";import{randomUUID as lE}from"node:crypto";import{constants as dr}from"node:fs";import{lstat as bf,mkdir as uE,open as vf,rename as fE,rm as mE}from"node:fs/promises";import xo from"node:path";import{constants as Vv}from"node:fs";import me from"node:fs/promises";import fn from"node:path";import{randomUUID as Xs}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]="92573990-a040-526d-a0b1-b91d2ef401f1")}catch{}})();function Co(e){let t=Math.ceil(e.size/2);for(let r of e.keys()){if(t===0)return;e.delete(r),t-=1}}import Ev from"node:crypto";import{AsyncLocalStorage as kv}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ced47074-06d3-53b9-af75-63586cbd4f6a")}catch{}})();var Bs=new kv,rf=1024;function Sv(e){let t=Date.parse(e.clock);if(!Number.isFinite(t))throw new Error(`Invalid reproducible workspace clock: ${e.clock}`);if(!Number.isSafeInteger(e.tickMs)||e.tickMs<0)throw new Error("Reproducible workspace tickMs must be a non-negative integer");if(e.seed.trim().length===0)throw new Error("Reproducible workspace seed must not be empty");return{...e,clock:new Date(t).toISOString()}}function Ov(e){let t={...Sv(e),clockReads:0,tokenReads:0};return r=>Bs.run(t,r)}async function ND(e,t){return Ov(e)(t)}function nf(){let e=Bs.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 DD(e){let t=Bs.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>rf)throw new Error(`Reproducible token length must be an integer between 0 and ${rf}`);let r="";for(;r.length<e;){let n=Ev.createHash("sha256").update(`${t.seed}\0${t.tokenReads}`).digest();t.tokenReads+=1;for(let o of n)if(r+=(o%36).toString(36),r.length===e)break}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]="0bf155fc-c690-5318-ba1e-275f1787858b")}catch{}})();var Av=/^([+-]?)(\d+)([hdwm])$/i,Iv=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,Tv=/^(\d{4})(\d{2})(\d{2})$/,Cv=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Rv=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,xv=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Nv=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function Me(){return nf()??new Date().toISOString()}function $e(e){return Number.isFinite(Date.parse(e))}function un(e){let t=Nv.exec(e);if(!t||!Number.isFinite(Date.parse(e)))return!1;let[,r,n,o,i,s,a,c,d]=t,[l,u,f,m,_,y]=[r,n,o,i,s,a].map(Number);return u>=1&&u<=12&&f>=1&&f<=Ks(l,u-1)&&m<=23&&_<=59&&y<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function cr(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return un(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var Dv=1e4,Ro=new Map;function of(e){let t=Ro.get(e);if(t!==void 0)return t;let r=Date.parse(e);return Ro.size>=Dv&&Co(Ro),Ro.set(e,r),r}function ne(e,t){let r=of(e),n=of(t);return Number.isFinite(r)&&Number.isFinite(n)&&r!==n?r-n:e.localeCompare(t)}function FD(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 Ws(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function Gs(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 Pv(e,t,r){r&&r!==t&&(e.includes(r)||e.push(r))}function Mv(e){let t=[],r=d=>Pv(t,e,d),n=Tv.exec(e);if(n){let[,d,l,u]=n;r(`${d}-${l}-${u}`)}let o=Cv.exec(e);if(o){let[,d,l,u,f,m,_,y,w]=o,v=_?`:${_}`:"";r(`${d}-${l}-${u}T${f}:${m}${v}${Ws(y)}${Gs(w)}`)}let i=Rv.exec(e);if(i){let[,d,l,u,f,m,_]=i,y=f?`:${f}`:"";r(`${d}T${l}:${u}${y}${Ws(m)}${Gs(_)}`)}let s=xv.exec(e);if(s){let[,d,l,u,f,m,_]=s,y=f?`:${f}`:"";r(`${d}T${l}:${u}${y}${Ws(m)}${Gs(_)}`)}let a=10,c=e.slice(0,a);if(jv(c)){let d=a;for(;d<e.length&&Lv(e[d]);)d+=1;d<e.length&&r(`${c}T${e.slice(d)}`)}return t}function $v(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let r of Mv(e)){let n=Date.parse(r);if(Number.isFinite(n))return n}return Number.NaN}function jv(e){if(e.length!==10)return!1;for(let t=0;t<e.length;t+=1){let r=e[t];if(t===4||t===7){if(r!=="-")return!1;continue}let n=r.charCodeAt(0);if(n<48||n>57)return!1}return!0}function Lv(e){return e?e===" "||e===" "||e===`
8
+ `||e==="\r"||e==="\f"||e==="\v":!1}function Ks(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var Fv=["January","February","March","April","May","June","July","August","September","October","November","December"],zv=/^(\d{4})-(\d{2})-(\d{2})/,Uv=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function Hv(e,t,r){let n=zv.exec(t)??Uv.exec(t);if(!n)return;let o=Number.parseInt(n[1],10),i=Number.parseInt(n[2],10),s=Number.parseInt(n[3],10),a=r?.trim()||"deadline";if(i<1||i>12)throw new g(`Invalid ${a} value "${e}". Month "${n[2]}" is out of range \u2014 use a month between 01 and 12.`,h.USAGE,{field:a,value:e});let c=Ks(o,i-1);if(s<1||s>c)throw new g(`Invalid ${a} value "${e}". ${Fv[i-1]} ${o} has ${c} days, so day "${n[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,h.USAGE,{field:a,value:e})}function qv(e,t){let r=new Date(e.getTime()),n=r.getUTCDate(),o=r.getUTCMonth()+t,i=r.getUTCFullYear()+Math.floor(o/12),s=(o%12+12)%12,a=Math.min(n,Ks(i,s));return r.setUTCFullYear(i,s,a),r}function zD(e,t=new Date,r="deadline"){let n=e.trim();if(n.toLowerCase()==="now")return t.toISOString();let o=Av.exec(n);if(o){let s=o[1]==="-"?-1:1,a=Number.parseInt(o[2],10)*s,c=o[3].toLowerCase();if(c==="m")return qv(t,a).toISOString();let d=c==="h"?3600*1e3:c==="d"?1440*60*1e3:10080*60*1e3;return new Date(t.getTime()+a*d).toISOString()}Hv(e,n,r);let i=$v(n);if(!Number.isFinite(i)){let s=r.trim().length>0?r.trim():"deadline",a=Iv.test(n)?"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 g(`Invalid ${s} value "${e}". ${a}`,h.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]="4a6fa947-cc6f-5e48-8722-3db9a1af36f1")}catch{}})();function Bv(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 r=t,n=r.id,o=r.pid,i=r.owner,s=r.token,a=r.created_at,c=r.ttl_seconds;return typeof n!="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:n,pid:o,owner:i,...typeof s=="string"?{token:s}:{},created_at:a,ttl_seconds:c},warnings:[]}}async function mn(e,t=!0){try{let r=await me.readFile(e,"utf8");return t&&await er({path:e,scope:"project"}),Bv(r)}catch(r){return le(r)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function je(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function Wv(e,t,r=process.platform){if(je(e,"EEXIST"))return!0;if(!je(e,"EPERM")&&!je(e,"EACCES")&&!je(e,"EBUSY"))return!1;try{return await me.lstat(t),!0}catch(n){if(r!=="win32"||!le(n)&&!je(n,"EPERM")&&!je(n,"EACCES")&&!je(n,"EBUSY"))return!1}try{return await me.access(fn.dirname(t),Vv.W_OK),!0}catch{return!1}}async function lf(e,t){await ho({path:e,scope:"project",op:t})}function Gv(e,t,r,n=Xs()){return{id:e,pid:process.pid,owner:t,token:n,created_at:Me(),ttl_seconds:r}}async function Kv(e,t,r,n,o,i){i&&await me.mkdir(fn.dirname(e),{recursive:!0});let s=await na(e,t);if(s===null)throw await me.access(fn.dirname(e)),Object.assign(new Error("Lock initialization is contended"),{code:"EEXIST"});try{let a=await me.open(e,"wx");try{try{await a.writeFile(`${JSON.stringify(Gv(t,r,n,o),null,2)}
9
+ `,"utf8")}finally{await a.close()}}catch(c){throw await Js(e,"lock:release"),c}}finally{await s()}await lf(e,"lock:create")}async function Js(e,t){try{return await me.unlink(e),await lf(e,t),!0}catch{return!1}}async function Yv(e,t,r,n){let o=Date.now(),i=ff;for(;;){let s=await na(e,t);if(s!==null){try{let d=await mn(e,!1);sf(d.info,t,r,n)&&await Js(e,"lock:release")}finally{await s()}return}let a=await mn(e,!1);if(!sf(a.info,t,r,n))return;let c=Date.now()-o;if(c>=af)return;await _f(Math.min(i,af-c)),i=Math.min(i*2,Qs)}}function sf(e,t,r,n){return e?.id===t&&e.pid===process.pid&&e.owner===r&&e.token===n}function Zs(e,t){let r=e?.created_at?Date.parse(e.created_at):Number.NaN;return(Number.isFinite(r)?Date.now()-r:Number.POSITIVE_INFINITY)>t*1e3}async function uf(e,t,r){let{info:n}=await mn(Hi(e,t),!1);return n!==null&&n.owner.startsWith(r)&&!Zs(n,n.ttl_seconds)}function Xv(e){return e?.owner?` (owner ${e.owner})`:""}var ff=25,Qs=200,Jv=250,Zv=3,Qv=".stale-cleanup",mf="owner.json",pf=1e4,af=pf+Qs,eE=60*6e4;function Ys(e){if(typeof e=="string"){let t=e.trim();if(!/^\d+$/.test(t))return;let r=Number(t);return Number.isSafeInteger(r)?r:void 0}if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return Math.trunc(e)}function tE(e){let t=process.env.PM_LOCK_WAIT_MS,r=Ys(t);if(r!==void 0)return r;let n=Ys(e);return n!==void 0?n:0}function rE(e,t){return Math.min(tE(e),t??1/0)}function _f(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(r=>setTimeout(r,t))}function yf(e,t,r){let n=r>0?` after waiting ${r}ms`:"";return new g(`Item ${e} is locked${Xv(t)}${n}`,h.CONFLICT,{code:"lock_conflict",recovery:{retry_after_ms:Jv}})}function nE(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 oE(e,t,r,n){if(!r&&n){let o=t.warnings.length>0?` (${t.warnings.join(",")})`:"";throw new g(`Item ${e} lock is stale${o}; rerun with --force when supported for this command`,h.CONFLICT)}}function iE(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null||Array.isArray(t))return null;let r=t,n=r.pid,o=r.token,i=r.process_start_identity;return typeof n!="number"||!Number.isInteger(n)||n<=0||typeof o!="string"||o.length===0||i!==void 0&&(typeof i!="string"||!/^\d+$/u.test(i))?null:{pid:n,token:o,...typeof i=="string"?{process_start_identity:i}:{}}}async function hf(e){try{return iE(await me.readFile(fn.join(e,mf),"utf8"))}catch{return null}}function sE(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!je(t,"ESRCH")}}function aE(e){let t=e.lastIndexOf(")");if(t<0)return null;let r=e.slice(t+2).trim().split(/\s+/u)[19];return r!==void 0&&/^\d+$/u.test(r)?r:null}async function gf(e){try{return aE(await me.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function ea(e=process.pid){let t=await gf(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function ta(e,t,r){if(!sE(e.pid))return!1;let n=await gf(e.pid);return e.process_start_identity!==void 0&&n!==null?n===e.process_start_identity:t<=r}async function ra(e){try{return await me.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function cf(e,t){let r=await hf(e);r===null||r.token!==t||await ra(e)}async function df(e){try{await me.mkdir(e)}catch(r){return je(r,"EEXIST"),null}let t={...await ea(),token:Xs()};try{await me.writeFile(fn.join(e,mf),`${JSON.stringify(t)}
10
+ `,"utf8")}catch{return await ra(e),null}return t}async function cE(e){let t;try{let n=await me.stat(e);if(t=Date.now()-n.mtimeMs,t<=pf)return!1}catch(n){return le(n)}let r=await hf(e);return r!==null&&await ta(r,t,eE)?!1:ra(e)}async function na(e,t){let r=`${e}${Qv}`,n=await df(r);if(n!==null)return async()=>cf(r,n.token);if(!await cE(r))return null;let o=await df(r);return o===null?null:async()=>cf(r,o.token)}async function dE(e){let t=await na(e.lockPath,e.id);if(t===null)return{lockInfo:e.fallbackLockInfo,shouldRetryCreate:!1,staleRemovalCounted:!1};try{let r=await mn(e.lockPath);if(r.info===null&&r.warnings.length===0)return{lockInfo:r,shouldRetryCreate:!0,staleRemovalCounted:!1};if(!Zs(r.info,e.ttlSeconds))return{lockInfo:r,shouldRetryCreate:!1,staleRemovalCounted:!1};if(oE(e.id,r,e.force,e.forceRequiredForStaleLock),e.staleRemovals>=Zv)throw yf(e.id,r.info,Date.now()-e.startedAtMs);return{lockInfo:r,shouldRetryCreate:await Js(e.lockPath,"lock:stale_remove"),staleRemovalCounted:!0}}finally{await t()}}async function ae(e,t,r,n,o=!1,i=!0,s,a={}){let c=Ys(a.maxWaitMs),d=await tr("lock_acquire",{pm_root:e,id:t,ttl_seconds:r,owner:n,force:o,force_required_for_stale_lock:i,...c===void 0?{}:{max_wait_ms:c}});if(d.handled){let w=nE(d.result);if(w)return async()=>{await Promise.resolve(w()),await tr("lock_release",{pm_root:e,id:t,owner:n})}}let l=Hi(e,t),u=rE(s,c),f=Date.now(),m=0,_=ff,y=Xs();for(;;)try{return await Kv(l,t,n,r,y,a.createParentDirectories!==!1),async()=>{await Yv(l,t,n,y),await tr("lock_release",{pm_root:e,id:t,owner:n})}}catch(w){if(!await Wv(w,l))throw new g(`Failed to acquire lock for ${t}: ${Zc(w)}`,h.GENERIC_FAILURE);let v=await mn(l);if(Zs(v.info,r)){let K=await dE({lockPath:l,id:t,ttlSeconds:r,force:o,forceRequiredForStaleLock:i,staleRemovals:m,waitBudgetMs:u,startedAtMs:f,fallbackLockInfo:v});if(v=K.lockInfo,K.staleRemovalCounted&&(m+=1),K.shouldRetryCreate)continue}let T=Date.now()-f;if(u===0||T>=u)throw yf(t,v.info,u===0?0:T);await _f(Math.min(_,u-T)),_=Math.min(_*2,Qs)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71b65888-baa5-5c5f-a02c-4a0fd818fadb")}catch{}})();var Le={max_serving_rows:256,max_bytes:262144,max_event_bytes:32768,retained_byte_fraction:.5,max_events:2048,retention_days:30},Y=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function Ot(e){let t=Date.parse(e.now??new Date().toISOString());if(!Number.isFinite(t))throw new Y("Context usage now must be a valid timestamp");return{iso:new Date(t).toISOString(),ms:t}}function Ef(e){let t=e.maxBytes??Le.max_bytes,r=e.maxEvents??Le.max_events,n=e.retentionDays??Le.retention_days;if(!Number.isSafeInteger(t)||t<1024||t>Le.max_bytes||!Number.isSafeInteger(r)||r<1||!Number.isFinite(n)||n<=0)throw new Y("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");return{maxBytes:t,maxEvents:r,cutoff:Ot(e).ms-n*864e5}}async function kf(e,t){if(!(await bf(xo.dirname(e))).isDirectory())throw new Y("Context usage runtime must be a real directory");try{if((await bf(e)).isSymbolicLink())throw new Y("Context usage ledger must not be a symbolic link")}catch(n){if(!le(n))throw n}let r=await vf(e,t|dr.O_NOFOLLOW|dr.O_NONBLOCK,384);try{let n=await r.stat();if(!n.isFile()||n.nlink!==1)throw new Y("Context usage ledger must be an unshared regular file");return r}catch(n){throw await r.close(),n}}async function No(e){let t=Ef(e);try{let r=await kf(xo.join(e.pmRoot,"runtime","context-usage.jsonl"),dr.O_RDONLY);try{let n=(await r.stat()).size,o=Math.max(0,n-t.maxBytes),i=Buffer.alloc(Math.min(n,t.maxBytes)),{bytesRead:s}=await r.read(i,0,i.length,o),a=i.subarray(0,s).toString("utf8");return(o>0?a.includes(`
11
+ `)?a.slice(a.indexOf(`
12
+ `)+1):"":a).split(`
13
+ `).flatMap(c=>{try{let d=JSON.parse(c);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await r.close()}}catch{return[]}}function wf(e,t,r){let n=[],o=0;for(let i=e.length-1;i>=0&&n.length<r;i-=1){let s=`${JSON.stringify(e[i])}
14
+ `;if(o+=Buffer.byteLength(s),o>t)break;n.push(s)}return n.reverse().join("")}async function pn(e,t,r){let n=Ef(e),o=xo.join(e.pmRoot,"runtime","context-usage.jsonl"),i=Math.floor(n.maxBytes*Le.retained_byte_fraction),s=Math.min(Le.max_event_bytes,i);if(t.some(f=>Buffer.byteLength(`${JSON.stringify(f)}
15
+ `)>s))throw new Y("Context usage event exceeds the declared byte ceiling");let a=t.filter(f=>Date.parse(f.at)>=n.cutoff),c=wf(a,i,n.maxEvents),d=performance.now(),l=await ae(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),u=performance.now()-d;try{await uE(xo.dirname(o),{recursive:!0});let f=await kf(o,dr.O_WRONLY|dr.O_CREAT|dr.O_APPEND);try{let m=(await f.stat()).size,_=r===void 0?void 0:await No(e);if(_?.some(T=>T.kind==="delivery"&&T.serve_id===r))return{written_bytes:0,ledger_bytes:m,compacted:!1,lock_wait_ms:u};if(!(e.maxEvents!==void 0||e.retentionDays!==void 0)&&m+Buffer.byteLength(c)<=n.maxBytes)return await f.writeFile(c,"utf8"),{written_bytes:Buffer.byteLength(c),ledger_bytes:m+Buffer.byteLength(c),compacted:!1,lock_wait_ms:u};let y=wf([..._??await No(e),...a],i,n.maxEvents),w=`${o}.${process.pid}.${lE()}.tmp`,v=await vf(w,"wx",384);try{try{await v.writeFile(y,"utf8")}finally{await v.close()}return await f.close(),f=void 0,await fE(w,o),{written_bytes:Buffer.byteLength(y),ledger_bytes:Buffer.byteLength(y),compacted:!0,lock_wait_ms:u}}finally{await mE(w,{force:!0})}}finally{await f?.close()}}finally{await l()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e76b38ce-b2aa-589b-9d17-0952eca9e7a2")}catch{}})();var _E=864e5,Do=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function lP(e,t){let r=J(e);r!==null&&t!==null&&(r[Do]=t)}function lr(e,t){let r=J(e),n=J(t),o=r?.[Do];n!==null&&o!==void 0&&(n[Do]=o)}function yE(e){return J(e)?.[Do]??null}function Of(e){let t=J(e);for(let r of["read_output","context_intent"])if(J(t?.[r])?.result_omitted===!0)return!0;return!1}function Je(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function Af(e,t){if(Array.isArray(t))for(let r of t)Je(e,J(r)?.id)}function Sf(e,t){if(Array.isArray(t))for(let r of t)Je(e,r)}function hE(e,t){let r=J(e.recommended)===null?[]:[e.recommended];for(let n of["ready","decision_needed","gate_needed","containers","blocked","held_by_others"])Array.isArray(e[n])&&r.push(...e[n]);for(let n of r){let o=J(n);Je(t,o?.id);for(let i of Array.isArray(o?.blockers)?o.blockers:[])Je(t,J(i)?.id);for(let i of Array.isArray(o?.unblocks)?o.unblocks:[])Je(t,i)}}function gE(e,t){for(let r of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])Af(t,e[r]);for(let r of Array.isArray(e.blockers)?e.blockers:[])Je(t,J(r)?.blocked_by);bE(e,t)}function bE(e,t){for(let o of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=J(o);Je(t,i?.id),Af(t,i?.children)}for(let o of["files","workload"])for(let i of Array.isArray(e[o])?e[o]:[])Sf(t,J(i)?.items);let r=J(e.agenda);for(let o of Array.isArray(r?.events)?r.events:[])Je(t,J(o)?.item_id);let n=J(e.tests);Sf(t,n?.items_failing)}function wE(e,t){let r=J(e);if(r===null||Of(e))return[];let n=new Set;return t==="next"?hE(r,n):gE(r,n),[...n]}async function uP(e){let t=yE(e.result);if(t===null)return!1;let r=Of(e.result);return await vE({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:wE(e.result,t.surface),resultOmitted:r}),!0}async function fP(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 Y("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 Y("Context usage serving requires unique normalized row ids");let r=t.slice(0,Le.max_serving_rows),n={serve_id:pE(),author:e.author.trim(),surface:e.surface,rows:t,recorded_item_ids:r.map(o=>o.id)};return n.storage=await pn(e,[{kind:"serve",schema_version:2,serve_id:n.serve_id,at:Ot(e).iso,author:e.author.trim(),surface:e.surface,profile:e.profile.trim()||"balanced",rows:r,candidate_count:t.length,omitted_row_count:t.length-r.length,result_omitted:!1,packed_item_ids:r.filter(o=>o.included).map(o=>o.id)}]),n}async function vE(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)),r=[...new Set(e.deliveredItemIds.map(i=>i.trim()))];if(r.some(i=>i.length===0||!t.has(i))||e.resultOmitted&&r.length>0)throw new Y("Context usage delivery requires emitted ranked ids and zero ids for an omitted result");let n=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:Ot(e).iso,author:e.receipt.author,surface:e.receipt.surface,result_omitted:e.resultOmitted,delivered_item_ids:r.filter(i=>n.has(i))};await pn(e,[o],o.serve_id)}async function mP(e){if(!(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)){if(!e.author.trim()||!e.itemId.trim()||!e.intent.trim())throw new Y("Context usage touch requires author, itemId, and intent");await pn(e,[{kind:"touch",at:Ot(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function pP(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1||e.itemIds.length===0)return;let t=e.author.trim(),r=e.intent.trim();if(!t||!r)throw new Y("Context usage touch requires author and intent");let n=new Set;for(let s of e.itemIds){if(typeof s!="string")throw new Y("Context usage touch requires string itemIds");let a=s.trim();if(!a)throw new Y("Context usage touch requires non-empty itemId");n.add(a)}let o=Ot(e).iso,i=[...n].map(s=>({kind:"touch",at:o,author:t,item_id:s,intent:r}));await pn(e,i)}function EE(e,t,r,n){return e.find(({entry:o,time:i})=>o.item_id===t&&i>=r&&i-r<=n)?.time}function kE(e,t){let r=new Map;for(let n of e)n.kind==="delivery"&&n.schema_version===2&&n.author===t&&!r.has(n.serve_id)&&r.set(n.serve_id,n);return r}async function _P(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 No(e),r=Ot(e).ms,n=(e.horizonHours??24)*36e5;if(![Number.isFinite(n),n>0].every(Boolean))throw new Y("Context usage horizonHours must be positive");let o=e.author.trim(),i=t.filter(f=>f.kind==="touch").filter(f=>f.author===o).map(f=>({entry:f,time:Date.parse(f.at)})),s=new Map,a=0,c=0,d=0,l=kE(t,o);t.filter(f=>f.kind==="serve").filter(f=>f.author===o).forEach(f=>{if(![f.schema_version===2,!!f.serve_id].every(Boolean)){c+=1;return}a+=1;let m=Date.parse(f.at),_=l.get(f.serve_id),y=new Set(_?.delivered_item_ids??[]);for(let w of f.rows){if(!y.has(w.id))continue;let v=EE(i,w.id,m,n);if(v===void 0)continue;d+=1;let T=Math.max(0,(r-v)/_E);s.set(w.id,(s.get(w.id)??0)+Math.exp(-T/14))}});let u=Math.max(0,...s.values());return{affinity:Object.fromEntries([...s.entries()].map(([f,m])=>[f,u===0?.05:.05+.95*m/u])),positive_judgments:d,serving_events:a,untrusted_serving_events:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6a604d54-5425-5ae7-8f20-9d5f1d33c20c")}catch{}})();var Tf=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"}]),Cf=new SE;function OE(){return Cf.getStore()??Tf}function IP(e,t){return Cf.run(IE(e.workspaceContracts,e.packageContracts),t)}function AE(e,t){let r=e.command.trim().toLowerCase(),n=e.intent.trim().toLowerCase(),o=`${r}:${n}`;if(!/^[a-z0-9][a-z0-9-]*$/.test(r)||!/^[a-z0-9][a-z0-9-]*$/.test(n))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:r,intent:n,description:e.description.trim(),included_field_groups:i,token_budget:e.token_budget,source:t}}function IE(e=[],t=[]){let r=[{source:"core",contracts:Tf,allowOverride:!1},{source:"package",contracts:t,allowOverride:!1},{source:"workspace",contracts:e,allowOverride:!0}],n=new Map,o=new Set;for(let i of r){o.clear();for(let s of i.contracts){let a=AE(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&&n.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);n.set(c,a)}}return[...n.values()].sort((i,s)=>i.command.localeCompare(s.command)||i.intent.localeCompare(s.intent))}function Rf(e,t,r=OE(),n=[]){let o=e.trim().toLowerCase(),i=t.trim().toLowerCase(),s=r.find(f=>f.command===o&&f.intent===i);if(s)return{...s,source:s.source??"core"};let a=r.filter(f=>f.command===o).map(f=>f.intent);if(a.length===0)return;let c=a.map(f=>{let m=Array.from({length:i.length+1},(_,y)=>y);for(let _=1;_<=f.length;_+=1){let y=m[0];m[0]=_;for(let w=1;w<=i.length;w+=1){let v=m[w];m[w]=Math.min(m[w]+1,m[w-1]+1,y+(f[_-1]===i[w-1]?0:1)),y=v}}return{candidate:f,distance:m[i.length]}}).sort((f,m)=>f.distance-m.distance||f.candidate.localeCompare(m.candidate))[0].candidate,d=[o,...n,"--for",i],l=[o,...n,"--for",c],u=rr(l);throw new g(`Unknown context intent "${i}" for ${o}. Did you mean "${c}"?`,h.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:rr(d),allowed_values:[...a].sort(),suggested_retry:u,suggested_retry_args:l}})}var xf={context:(e,t,r)=>{e.section===void 0&&e.depth===void 0&&(e.section=t.intent==="handoff"?["activity","progress","blockers"]:["hierarchy","blockers","activity"]),e.depth===void 0&&(e.depth=t.intent==="handoff"?"deep":"standard");let n=Mo(e.tokenBudget,t.token_budget),o=$o("context",t.intent,n,r),i=At(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,r)=>{e.brief===void 0&&e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");let n=Mo(e.tokenBudget,t.token_budget),o=$o("list",t.intent,n,r),i=At(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,r)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let n=Mo(e.tokenBudget,t.token_budget),o=$o("search",t.intent,n,r),i=At(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))}};function TP(e,t,r=[]){let n=t.tokenBudget??t.token_budget;if(typeof t.for!="string"){if(n!==void 0&&(e==="get"||e==="list"||e==="search"))throw new g("--token-budget requires a declared context intent selected with --for",h.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:n};return delete a.token_budget,a}let o=Rf(e,t.for,void 0,r),i=At(n)!==void 0,s={...t};return s.tokenBudget===void 0&&n!==void 0&&(s.tokenBudget=n),delete s.token_budget,s.tokenBudget===void 0&&(s.tokenBudget=String(o.token_budget)),xf[e](s,o,i),s}var TE={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},Po=256;function oa(e){return Array.isArray(e)?e.map(oa):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,r])=>[t,oa(r)])):typeof e=="string"&&e.length>240?`${Ge(e,240)}\u2026`:e}function At(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 Mo(e,t){let r=At(e);if(r===void 0)return t;if(r<Po)throw new g(`Context intent token budget must be at least ${Po}`,h.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(e),required:`Use an integer token budget of at least ${Po}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${Po} or omit the override.`]});return r}function $o(e,t,r,n){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((r-i)/s));return n?a:Math.min(e==="context"?20:100,a)}function Ze(e,t){let r=t.estimated_tokens;for(;;){t.estimated_tokens=r;let n=Math.ceil(Buffer.byteLength(JSON.stringify(e),"utf8")/4);if(n===r)return;r=n}}var If={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 Nf(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 CE(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 RE(e,t,r){let n=!1;for(;;){if(Ze(e,t),t.estimated_tokens<=t.token_budget||r.length<=1)return n;let o=Buffer.byteLength(JSON.stringify(r),"utf8"),i=(t.estimated_tokens-t.token_budget)*4;r.splice(-Math.min(r.length-1,Math.max(1,Math.ceil(i/Math.max(1,Math.ceil(o/r.length)))))),n=!0}}function xE(e,t,r){let n=e.items,o=typeof e.next_cursor=="string",i=o?e.next_cursor:r.after;if(!Array.isArray(n)||typeof i!="string")return!1;let s=Nf(i);if(s===void 0)return!1;let a=n.length,c=[...n],d=!1;for(;;){if(d=RE(e,t,n)||d,!d)return!1;let l=CE(n.at(-1));if(l===void 0)return n.splice(0,n.length,...c),Ze(e,t),!1;if(e.next_cursor=cn(s.fingerprint,l,o?s.after_index-(a-n.length):s.after_index+n.length,s.snapshot),Ze(e,t),t.estimated_tokens<=t.token_budget||n.length<=1)break}return typeof e.count=="number"&&(e.count=n.length),typeof e.applied_limit=="number"&&(e.applied_limit=n.length),!0}function NE(e,t,r,n){if(e==="list"||e==="search")return xE(t,r,n);if(e!=="next"||typeof t.next_cursor=="string")return!1;let o=!1;for(;;){if(Ze(t,r),r.estimated_tokens<=r.token_budget)return o;let i=If[e].map(f=>({key:f,rows:Array.isArray(t[f])?t[f]:[]})).filter(({rows:f})=>f.length>0).sort((f,m)=>m.rows.length-f.rows.length||f.key.localeCompare(m.key))[0];if(i===void 0)return o;let s=If[e].reduce((f,m)=>f+(Array.isArray(t[m])?t[m].length:0),0);if(s<=1)return o;let a=Math.min(i.rows.length,s-1),c=Buffer.byteLength(JSON.stringify(i.rows),"utf8"),d=Math.max(1,Math.ceil(c/i.rows.length)),l=(r.estimated_tokens-r.token_budget)*4,u=Math.min(a,Math.max(1,Math.ceil(l/d)));i.rows.splice(-u,u),o=!0}}function DE(e,t,r){if(typeof t.for!="string")return r;let n=e.startsWith("list-")?"list":e;if(!(n in xf))return r;let o=n,i=Rf(o,t.for),s=Mo(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:TE[o],declaration_feasible:!0,result_omitted:!1},c={...r},d=$o(o,i.intent,a.token_budget,At(t.tokenBudget??t.token_budget)!==void 0);if(d!==void 0){let u=At(t.limit),f=u!==void 0&&u<d;a.budget_derived_limit=d,a.binding_constraint=f?"explicit_limit":"token_budget",a.limit_reason=f?"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=d}let l={...c,context_intent:a};return Ze(l,a),a.estimated_tokens>a.token_budget&&(a.degradation="recursive_budget_compaction",l={...oa(c),context_intent:a},Ze(l,a)),a.estimated_tokens>a.token_budget&&NE(o,l,a,t)&&(a.degradation="budget_row_compaction",Ze(l,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,l={budget_exceeded:{omitted_result:!0,reason:a.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:ME(e,o,i.intent,a,c)},context_intent:a}),l}function PE(e,t){if(typeof e.after!="string"||e.after.length===0)return t;let r=Nf(e.after)?.fingerprint??"opaque_cursor",n={...t};for(let o of["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"])delete n[o];return n.continuation_contract={fingerprint:r,metadata:"reference",restore_with:"omit --after"},n}function ia(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ME(e,t,r,n,o){let i=t==="get"&&ia(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 ${n.budget_derived_limit??1}`;return`pm ${e}${s} --for ${r} --token-budget ${Math.ceil(n.estimated_tokens/100)*100}${a}`}function ur(e,t){if(ia(e))return typeof e[t]=="number"?e[t]:void 0}function $E(e,t){let r=e;for(let n=0;n<8;n+=1){let o=ur(r.context_intent,"estimated_tokens"),i=ur(r.read_output,"estimated_tokens"),s=ur(r.read_session,"spent_this_call_tokens");if(ia(r.context_intent)&&Ze(r,r.context_intent),r=Fs(r,t),ur(r.context_intent,"estimated_tokens")===o&&ur(r.read_output,"estimated_tokens")===i&&ur(r.read_session,"spent_this_call_tokens")===s)break}return r}function Df(e,t,r){let n=tu(e,_u(e??"",r)),o=typeof n=="object"&&n!==null&&!Array.isArray(n)?Ku(e??"",{...t,outputRowContract:t.outputRowContract===!0||t.output_row_contract===!0},PE(t,DE(e??"",t,n))):n;if(lr(r,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=$E(i,t);return delete s.row_contract,lr(o,s),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cb1266f3-8375-586f-87c6-356cf7843969")}catch{}})();var fr=["result_rows","envelope","diagnostics","hints"],jE=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,LE=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,FE=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,zE=8;function sa(e){return Buffer.byteLength(e,"utf8")}function Pf(e){return sa(JSON.stringify(e)??"null")}function UE(e,t){return LE.test(e)?"diagnostics":FE.test(e)?"hints":jE.test(e)||Array.isArray(t)?"result_rows":"envelope"}function HE(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"]=Pf(e),t;for(let[r,n]of Object.entries(e))t[UE(r,n)]+=Pf({[r]:n});return Object.values(t).every(r=>r===0)&&(t.envelope=1),t}function qE(e,t){let r=fr.reduce((s,a)=>s+t[a],0),n=fr.map(s=>({section:s,value:e*t[s]/r})),o={result_rows:0,envelope:0,diagnostics:0,hints:0};for(let s of n)o[s.section]=Math.floor(s.value);let i=e-fr.reduce((s,a)=>s+o[a],0);for(let s of[...n].sort((a,c)=>c.value-Math.floor(c.value)-(a.value-Math.floor(a.value))||fr.indexOf(a.section)-fr.indexOf(c.section))){if(i===0)break;o[s.section]+=1,i-=1}return o}function Mf(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function $f(e,t){let r=sa(t(e)),n=qE(r,HE(e)),o=Object.fromEntries(fr.map(a=>[a,{bytes:n[a],estimated_tokens:Et(n[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:r,total_estimated_tokens:Et(r),sections:o,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=Mf(e,i);for(let a=0;a<zE;a+=1){let c=sa(t(s))-r;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:Et(c)},s=Mf(e,i)}return s}import{encode as aa}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]="8936e93f-25bf-58cc-ba91-37cc2677c5d2")}catch{}})();function jf(e){let t=[...new Set(e.flatMap(i=>Object.keys(i)))],r=t.filter(i=>e.some(s=>{let a=s[i];return a!==null&&typeof a=="object"})),n=new Set(r),o=[];return{rows:e.map((i,s)=>Object.fromEntries(t.map(a=>{if(!Object.hasOwn(i,a))return o.push([s,a]),[a,null];let c=i[a];return[a,n.has(a)?JSON.stringify(c):c]}))),encoding:{json_columns:r,absent:o}}}function NP(e){let t=new Set(e.encoding.json_columns),r=new Set(e.encoding.absent.map(([n,o])=>JSON.stringify([n,o])));return e.rows.map((n,o)=>Object.fromEntries(Object.entries(n).flatMap(([i,s])=>r.has(JSON.stringify([o,i]))?[]:[[i,t.has(i)?JSON.parse(String(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]="ee7a4cf5-ca04-5ee7-affe-3cc1184e04a0")}catch{}})();var VE=new Set(Object.values(h)),BE=new Map([["notes_count","notes"],["tests_count","tests"]]),ca="__pm_native_output",Lf=!1;function q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fa(e){let t={read_output:{result_omitted:!0}};lr(e,t),yo(t)}function WE(e,t,r){if(r){yo(e);return}fa(t)}function GE(e){if(!q(e)||e[ca]!==!0)return e;let{[ca]:t,...r}=e;return r}function da(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function KE(){(process.exitCode===void 0||process.exitCode===h.SUCCESS)&&(process.exitCode=h.SUCCESS)}function YE(){(process.exitCode===void 0||process.exitCode===h.SUCCESS)&&(process.exitCode=h.GENERIC_FAILURE)}function la(e){if(e==="stdout"){KE();return}YE()}function Ff(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function XE(){Lf||(Lf=!0,process.stdout.on("error",e=>{if(da(e)){la("stdout");return}Ff(e)}),process.stderr.on("error",e=>{if(da(e)){la("stderr");return}Ff(e)}))}function zf(e,t){XE();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(r){if(da(r))return la(e),!1;throw r}}function JE(e){return zf("stdout",e)}function _n(e){return zf("stderr",e)}function Uf(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function ZE(e){let t=Object.keys(e[0]);return t.length>0&&e.every(r=>Object.keys(r).length===t.length&&t.every(n=>{if(!Object.hasOwn(r,n))return!1;let o=r[n];return o===null||typeof o=="string"||typeof o=="number"||typeof o=="boolean"}))}function ua(e,t){let r=" ".repeat(t);return e.split(`
16
+ `).map(n=>`${r}${n}`).join(`
17
+ `)}function QE(e){let t=new Set,r=0;for(let n of e){let o=Object.keys(n);r+=o.length;for(let i of o)t.add(i)}return e.length*t.size<=r*2}function e0(e,t,r,n){let o=" ".repeat(r);if(!q(t)&&!Array.isArray(t))return`${o}${e}: ${Uf(t)}`;if(Array.isArray(t)){if(t.length===0)return`${o}${e}: []`;let i=ua(aa({[e]:t}),r);if(n&&t.length>=2&&t.every(q)&&!ZE(t)&&QE(t)){let s=jf(t),a=ua(aa({[e]:s.rows,[`${e}_encoding`]:s.encoding}),r);if(Buffer.byteLength(a)<Buffer.byteLength(i))return a}return i}return q(t)&&Object.keys(t).length===0?`${o}${e}: {}`:`${o}${e}:
18
+ ${Hf(t,r+1)}`}function jo(e,t=!0){if(e!=null){if(Array.isArray(e)){let r=e.map(n=>jo(n,t)).filter(n=>n!==void 0);return r.length>0?r:void 0}if(q(e)){let r={},n=Object.entries(e).filter(([o,i])=>{let s=BE.get(o);return!t||s===void 0||!q(e.collection_counts)||i!==e.collection_counts[s]});for(let[o,i]of n){if(o==="omitted_field_groups"&&Array.isArray(i)&&i.length===0){r[o]=[];continue}let s=jo(i,t);s!==void 0&&(r[o]=s)}return Object.keys(r).length>0?r:void 0}return e}}function Hf(e,t){let r=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":ua(aa(e),t);if(q(e)){let n=Object.entries(e);return n.length===0?"{}":n.map(([o,i])=>e0(o,i,t,!Object.hasOwn(e,`${o}_encoding`)&&!(o==="checks"&&q(e.verdict)&&e.verdict.authority==="ok"))).join(`
19
+ `)}return`${r}${Uf(e)}`}function t0(e){if(!q(e)||e.output_default!=="markdown"||typeof e.view!="string"||!Array.isArray(e.events)||!Array.isArray(e.days))return null;let t=[`# pm calendar (${e.view})`,""],r=q(e.summary)?e.summary:{};if(t.push(`- events: ${String(r.events??0)}`),t.push(""),e.events.length===0)return t.push("No calendar events matched the selected filters."),`${t.join(`
20
+ `)}
21
+ `;for(let n of e.events){if(!q(n))continue;let o=typeof n.kind=="string"?n.kind:"event",i=typeof n.item_title=="string"?n.item_title:"",s=typeof n.item_id=="string"?n.item_id:"",a=typeof n.reminder_text=="string"&&n.reminder_text.length>0?` ${n.reminder_text}`:"";t.push(`- [${o}] ${s} ${i}${a}`.trim())}return`${t.join(`
22
+ `)}
23
+ `}var r0=new Set(["filters","now","projection","sorting"]);function n0(e){let t=jo(e,!1);if(!q(t)||!Array.isArray(t.items))return t??null;let r=Object.fromEntries(Object.entries(t).filter(([n])=>!r0.has(n)));return r.has_more!==!0&&delete r.next_cursor,r}function o0(e,t){if(!q(e)||!Array.isArray(e.run_results)||!e.run_results.every(q))return e;let r=e.run_results,n=r.map(s=>s.execution_context).filter(s=>s!==void 0),o=n.length===r.length&&n.length>0&&n.every(s=>JSON.stringify(s)===JSON.stringify(n[0]))?n[0]:void 0,i=r.map(s=>{let{execution_context:a,stdout:c,stderr:d,...l}=s;return o===void 0?s:!t||s.status!=="passed"?{...l,stdout:c,stderr:d}:l});return{...e,...o===void 0?{}:{execution_context:o},run_results:i}}function i0(e){if(!q(e)||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!q(e.projection)||e.projection.mode!=="brief"||!q(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||!q(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:r,truncated:n,next_cursor:o,completeness:i,projection:s,now:a,omission_receipt:c,sorting:d,...l}=e;return{...l,...q(d)&&d.sort==="default"?{}:{sorting:d},details:"--full"}}function Lo(e,t){if(t==="json")return`${JSON.stringify(e,null,2)}
24
+ `;let r=jo(i0(e));return r===void 0?`{}
25
+ `:`${Hf(r,0)}
26
+ `}function s0(e,t,r,n){let o=t?{handled:!1,result:e,warnings:[]}:Os("output_format",{command:r.command,args:r.commandArgs,command_options:r.commandOptions,global:{...r},pm_root:r.pmRoot,format:n,options:{...r},result:e}),i=o.warnings.find(s=>s.startsWith("extension_output_format_payload_echo_deprecated:"));return i!==void 0&&_n(`Warning: ${i}. Returning context.payload now declines safely for compatibility; migrate the override to declineServiceOverride() or { handled: false }.
27
+ `),o.handled&&typeof o.result=="string"?{result:o.result,rendered:o.result.endsWith(`
28
+ `)?o.result:`${o.result}
29
+ `,structuredDeliveryPreserved:!1}:{result:o.handled?o.result:e,rendered:null,structuredDeliveryPreserved:!o.handled||q(o.result)}}function a0(e,t,r,n){let o=Kl(),i=r.command??o?.command,s={...o?.options,...r.commandOptions,...Object.fromEntries([["outputInclude",r.outputInclude],["outputLimit",r.outputLimit],["outputBudget",r.outputBudget],["outputFormat",r.outputFormat],["outputSession",r.outputSession],["outputCursor",r.outputCursor],["outputRowContract",r.outputRowContract]].filter(T=>T[1]!==void 0))},a=Xu(i??"",s)??n,c={...s,resolvedOutputFormat:a},d={...r,command:i,commandOptions:c},l=s0(e,t,d,a);if(l.rendered!==null)return fa(e),l.rendered;let u=l.result;lr(e,u);let f=i==="test"?o0(u,r.lean===!0):u,m=Df(i,c,f);Yu(m)&&(process.exitCode||=h.USAGE);let{structuredDeliveryPreserved:_}=l,y=T=>{if(a==="toon"){let ve=t0(T);if(ve!==null)return ve}let K=t?{rendered:null}:Xl(a,T);return K.rendered!==null?(_=!1,K.rendered.endsWith(`
30
+ `)?K.rendered:`${K.rendered}
31
+ `):a==="json"?Lo(r.lean===!0?n0(T):T,"json"):Lo(T,"toon")},w=r.tokenAccounting===!0?$f(m,y):m,v=y(w);return WE(w,e,r.quiet!==!0&&_),v}function c0(e,t){let r=Yl(e),n=zn(r.result)?r.result:null,o=r.result,i=q(o)&&o[ca]===!0,s=n?n.result:GE(r.result);if(yo(s),n)return fa(s),"";let a=t.json===!0||t.json===void 0&&t.defaultOutputFormat==="json"?"json":"toon";return a0(s,i,t,a)}function VP(e,t){q(e)&&Number.isInteger(e.exit_code)&&VE.has(Number(e.exit_code))&&(process.exitCode===void 0||process.exitCode===h.SUCCESS)&&(process.exitCode=Number(e.exit_code));let r=t.idOnly?tn(e,{idOnly:!0}):t.fullChangedFields?e:t.noChangedFields?tn(e,{changedFields:"compact"}):tn(e,{compactEnvelope:!0}),n=c0(r,t);t.quiet||JE(n)}function BP(e){let t=Os("error_format",{message:e}),r=t.handled&&typeof t.result=="string"?t.result:e;_n(r.endsWith(`
32
+ `)?r:`${r}
33
+ `)}(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]="13e57322-501d-5927-8254-f6196854d434")}catch{}})();var d0=8,l0=64,u0=5,f0=4,qf=100;function xu(e,t,r){if(e!=="get"||!ma(r.item)||["fields","outputInclude","output_include","outputCursor","output_cursor"].some(c=>t[c]!==void 0)||t.full===!0||t.tree===!0||t.depth!==void 0&&t.depth!=="standard")return;let n=r.item,o=["linked","claim_state","schedule"],i=o.filter(c=>Object.hasOwn(r,c)),s=Object.fromEntries(Object.entries(r).filter(([c])=>!o.includes(c)));s.item=Object.fromEntries(Object.entries(n).filter(([c])=>c!=="body")),Object.hasOwn(n,"body")&&i.push("body");let a=[...ma(r.omission_receipt)&&Array.isArray(r.omission_receipt.omitted_field_groups)?r.omission_receipt.omitted_field_groups:[],...i.map(c=>({name:c,restore_with:`--fields ${c}`}))];return s.omission_receipt={has_omissions:a.length>0,omitted_field_group_count:a.length,omitted_field_groups:a},s}function Ds(e){let t=Math.trunc(e.effective_budget_tokens),r=Math.trunc(e.measured_result_tokens);if(!Number.isSafeInteger(t)||t<=0||!Number.isSafeInteger(r)||r<=0)return{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"};let n=Math.max(t+1,r),o=Math.ceil(n*u0/f0),i=Math.ceil(o/qf)*qf;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 ir(e,t,r=!1){let n=Object.getOwnPropertyDescriptor(e,"row_contract");n&&(r||n.enumerable===!1)&&Object.defineProperty(t,"row_contract",{...n,enumerable:!1})}function rn(e,t){let r=t===void 0?JSON.stringify(e):Lo(e,t);return Math.ceil(Buffer.byteLength(r,"utf8")/4)}function ma(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function pa(e,t,r=!1){return typeof e=="string"?r||e.length<=240?e:(t.compacted=!0,`${Ge(e,240)}\u2026`):Array.isArray(e)?e.map(n=>pa(n,t,r)):ma(e)?Object.fromEntries(Object.entries(e).map(([n,o])=>[n,pa(o,t,r||n==="focus_row_states")])):e}function Xe(e,t,r){let n=t.estimated_tokens;for(let o=0;o<d0;o+=1){t.estimated_tokens=n;let i=rn(e,r);if(i===n)return;n=i}t.estimated_tokens=n}function m0(e,t){return Zr(e).filter(r=>(Array.isArray(r.value)?r.value.length:Object.keys(r.value).length)>Math.max(1,t.get(r.path)??0)).map(r=>({collection:r,length:Array.isArray(r.value)?r.value.length:Object.keys(r.value).length})).sort((r,n)=>n.length-r.length||r.collection.path.localeCompare(n.collection.path))[0]?.collection}function p0(e,t,r,n,o,i){for(let s=0;s<l0;s+=1){if(i?.(e),Xe(e,t,o),t.estimated_tokens<=r)return;let a=m0(e,n);if(!a)return;let c=Math.max(1,n.get(a.path)??0),d=Array.isArray(a.value)?[...a.value]:Object.entries(a.value),l=_=>{if(Array.isArray(a.value)){a.value.length=_;for(let y=0;y<_;y+=1)a.value[y]=d[y]}else{for(let y of Object.keys(a.value))delete a.value[y];Object.defineProperties(a.value,Object.getOwnPropertyDescriptors(Object.fromEntries(d.slice(0,_))))}typeof e.count=="number"&&(e.count=Eo(e)),a.path==="items"&&(e.applied_limit=_),i?.(e),Xe(e,t,o)};t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],a.path])].sort((_,y)=>_.localeCompare(y)),e.has_more=!0,e.truncated=!0;let u=c,f=d.length-1,m=c;for(;u<=f;){let _=Math.floor((u+f)/2);l(_),t.estimated_tokens<=r?(m=_,u=_+1):f=_-1}l(m)}}function Nu(e,t,r,n=new Map,o,i,s=!1){let a={compacted:!1},c=Object.fromEntries(Object.entries(e).map(([d,l])=>[d,pa(l,a,s&&d==="diff")]));return ir(e,c),t.strings_compacted=a.compacted,c.read_output=t,p0(c,t,r,n,o,i),Xe(c,t,o),c}import ya from"node:fs/promises";import Fo 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]="658ab1c3-da92-5af6-a170-85ed7befaad6")}catch{}})();function Qe(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function ha(e){let t=["--pm-path",e,"init","--defaults","--agent-guidance","skip"];return{suggested_retry:rr(t),suggested_retry_args:t}}function zo(e){return new g(`Tracker root is not a directory at ${e}.`,h.USAGE,{code:"tracker_root_not_directory",reason:"not_a_directory",resolved_path:e,nextSteps:["Pass a tracker directory, usually <workspace>/.agents/pm, rather than a file path."]})}function _a(e){return new g(`Tracker root is not readable at ${e}.`,h.GENERIC_FAILURE,{code:"tracker_root_unreadable",reason:"unreadable",resolved_path:e,nextSteps:["Grant read and directory-search permission to the tracker root, then retry."]})}async function _0(e){let t=Fo.resolve(e),r=Fo.parse(t).root,n=Fo.dirname(t);for(;n!==r;){let o;try{o=await ya.stat(n)}catch(i){if(Qe(i,"ENOTDIR"))throw zo(e);if(!Qe(i,"ENOENT"))throw i;n=Fo.dirname(n);continue}if(!o.isDirectory())throw zo(e);return}}async function Vf(e){let t;try{t=await ya.stat(e)}catch(r){throw Qe(r,"ENOENT")?(await _0(e),new g(`Tracker is not initialized at ${e}. Tracker root does not exist. Run pm init first.`,h.NOT_FOUND,{code:"tracker_root_missing",reason:"missing",resolved_path:e,nextSteps:["Confirm the tracker root path or initialize it with the emitted retry."],recovery:ha(e)})):Qe(r,"ENOTDIR")?zo(e):Qe(r,"EACCES")||Qe(r,"EPERM")?_a(e):r}if(!t.isDirectory())throw zo(e);if(process.platform!=="win32"&&((t.mode&292)===0||(t.mode&73)===0))throw _a(e);try{await(await ya.opendir(e)).close()}catch(r){throw Qe(r,"EACCES")||Qe(r,"EPERM")?_a(e):r}}async function y0(e){if(await Vf(e),!await ft(Se(e)))throw new g(`Tracker is not initialized at ${e}. Run pm init first.`,h.NOT_FOUND,{code:"tracker_not_initialized",reason:"settings_missing",resolved_path:e,nextSteps:["Initialize the selected tracker root with the emitted retry."],recovery:ha(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]="5c8194ff-d877-51b8-bd54-d206f85a979c")}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]="6fd537c2-9d10-5a26-81a9-ac931151017b")}catch{}})();var Bf=["append","cancel","claim","close","comment_add","comment_edit","comment_delete","create","delete","docs_add","docs_remove","files_add","files_remove","files_discover","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","import","improvement_observe","learning_add","learning_edit","learning_delete","normalize","note_add","note_edit","note_delete","plan_create_metadata","plan_create_initial_step","plan_add_step","plan_reorder_step","plan_remove_step","plan_link_step","plan_unlink_step","plan_append_decision","plan_append_discovery","plan_append_validation","plan_resume","plan_approve","plan_materialize","plan_update_step","plan_complete_step","plan_block_step","policy_approve","policy_refused","release","reopen","restore","schema_migration","schema_migration_reference","test_run_track","tests_add","tests_remove","tests_update","update","update_audit","update_ownership_bypass","workspace_snapshot_restore","extension_migrations_apply","merge_reconcile"],Wf=["history:author-acknowledge","settings:write","init:type_preset","templates:save","profile:apply-types","profile:apply-statuses","profile:apply-fields","profile:apply-config","schema:add-type","schema:remove-type","schema:add-status","schema:remove-status","schema:add-field","schema:remove-field","schema:apply-preset","schema:infer-types","schema:policy-put","schema:policy-remove","schema:policy-mode","assurance:bundle:apply","assurance:gate:verdict","telemetry:install_id","telemetry:first_run_prompt","telemetry:clear","item_format:auto_select_default"],ga={"init:type-preset":"init:type_preset"},Gf=["^config:(?:set|unset):[a-z][a-z0-9_.:-]*$","^assurance:(?:measurement|invariant|gate):(?:put|remove)$","^schema_(?:rename_type|rename_status|remap_status|rename_field|remove_type|remove_status|remove_field)(?:_compensate)?$","^extension:[a-z][a-z0-9_-]*:[a-z][a-z0-9_]*$"],a1={version:1,item:Bf,workspace:Wf,aliases:ga,patterns:Gf,read_policy:"preserve_original_operation",custom_operation_grammar:"extension:<package_name>:<snake_case_operation>",legacy_custom_operation_grammar:"lowercase segments separated by underscore, hyphen, colon, or dot; optional opaque colon-suffixed retry key",excluded_surfaces:["json_patch","on_write_hook","telemetry_span"]},h0=new Set([...Bf,...Wf]),g0=Gf.map(e=>new RegExp(e,"u"));function Kf(e){return Object.hasOwn(ga,e)?ga[e]:e}function c1(e){let t=Kf(e);if(h0.has(t)||g0.some(r=>r.test(t)))return t;throw new TypeError("Undeclared history operation; use a native contract identity or extension:<package_name>:<snake_case_operation>.")}function Yf(e){let t=Kf(e),r=t.indexOf(":"),n=r<0?t:t.slice(0,r),o=r<0||r<t.length-1&&!/[\s\p{C}]/u.test(t.slice(r+1));if(/^[a-z][a-z0-9]*(?:[_.-][a-z0-9]+)*$/u.test(n)&&o)return t;throw new TypeError("History operation must use lowercase alphanumeric segments with an optional non-whitespace colon-suffixed retry key.")}import{createHash as b0}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ca5b60a5-80a7-5e7d-917f-4c7649bcbab6")}catch{}})();var u1=["sha256","sha512"],w0="sha256",Xf="sha256";function It(e){if(e===void 0)return w0;if(e==="sha256"||e==="sha512")return e;throw new TypeError(`unsupported_history_hash_algorithm:${String(e)}`)}function et(e,t){return b0(It(t)).update(e,"utf8").digest("hex")}import Zf from"node:path";import{link as v0,mkdir as E0,mkdtemp as k0,rm as S0,writeFile as O0}from"node:fs/promises";import ba from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71c2fed9-81e1-5723-8e34-e6327c07a130")}catch{}})();async function Jf(e,t){let r=ba.dirname(e);await E0(r,{recursive:!0});let n=await k0(ba.join(r,".pm-seed-")),o=ba.join(n,"value");try{await O0(o,t,"utf8");try{return await v0(o,e),!0}catch(i){if(i.code==="EEXIST")return!1;throw i}}finally{await S0(n,{recursive:!0,force:!0})}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2075887b-6d4b-582f-9da2-bab13198f9a5")}catch{}})();var A0=2e3,Uo=new Map;function tt(e){if(typeof e!="string")return"";let t=Uo.get(e);if(t!==void 0)return t;let r=e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return Uo.size>=A0&&Co(Uo),Uo.set(e,r),r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6e07b1b6-1757-54dd-8833-9d3f984ccf79")}catch{}})();var oe=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),tm=Bc,va=Vc,I0=["create","update"],T0=new Set(qn),C0=new Set(Bt),R0=new Set(Vn),x0=new Set(Bn),N0=new Set(["string","number","boolean","array","object"]),D0=16;function rm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var P0=[e=>e.type===void 0||typeof e.type=="string"&&N0.has(e.type),e=>!Object.hasOwn(e,"const")||qo(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>qo(t)),e=>e.min_length===void 0||Number.isInteger(e.min_length)&&e.min_length>=0,e=>e.min_items===void 0||Number.isInteger(e.min_items)&&e.min_items>=0,e=>e.format===void 0||e.format==="date-time",e=>e.required===void 0||Array.isArray(e.required)&&e.required.every(t=>typeof t=="string"&&t.length>0),e=>e.additional_properties===void 0||typeof e.additional_properties=="boolean",e=>e.properties===void 0||rm(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function qo(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return!0;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e))return!1;t.add(e);let r=Array.isArray(e)?e.every(n=>qo(n,t)):Object.values(e).every(n=>qo(n,t));return t.delete(e),r}function Ho(e,t=0,r=new Set){if(!rm(e)||t>D0||r.has(e))return;r.add(e);let n=e,o=n.type,i=n.enum,s=n.one_of,a=n.properties,c=n.items,d=n.required,l=n.min_length,u=n.min_items,f=n.format,m=n.additional_properties;if(!P0.every(v=>v(n))){r.delete(e);return}let _=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([v,T])=>[v,Ho(T,t+1,r)])),y=c===void 0?void 0:Ho(c,t+1,r),w=s===void 0?void 0:s.map(v=>Ho(v,t+1,r));if([...Object.values(_??{}),...c===void 0?[]:[y],...w??[]].some(v=>v===void 0)){r.delete(e);return}return r.delete(e),Object.fromEntries(Object.entries({type:o,const:Object.hasOwn(n,"const")?n.const:void 0,enum:i,min_length:l,min_items:u,format:f,properties:_,required:d===void 0?void 0:[...new Set(d)],additional_properties:m,items:y,one_of:w}).filter(([,v])=>v!==void 0))}function hn(e){let t=Array.isArray(e)?e:[];return[...new Set(t.map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0))].sort((r,n)=>r.localeCompare(n))}function pe(e){if(typeof e!="string"||e.length===0)return;let t=tt(e);return t.length>0?t:void 0}function M0(e){return e.startsWith("--")?e.slice(2):e}function Qf(e){return typeof e=="string"?M0(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function nm(e){return e.replaceAll("_","-")}function $0(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(o=>o.length>0).map(o=>o.toLowerCase());if(t.length===0)return e;let[r,...n]=t;return`${r}${n.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function wa(e,t){let r=pe(e.id);if(!r)return null;let n=[...new Set(hn(e.aliases).map(tt).filter(a=>a.length>0))].sort((a,c)=>a.localeCompare(c)),o=hn(e.roles).filter(a=>T0.has(a)),i=e.description?.trim(),s=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:t;return{id:r,aliases:n,roles:o,description:i&&i.length>0?i:void 0,order:s}}function j0(e){return{draft_status:pe(e?.draft_status),open_status:pe(e?.open_status),in_progress_status:pe(e?.in_progress_status),blocked_status:pe(e?.blocked_status),close_status:pe(e?.close_status),canceled_status:pe(e?.canceled_status)}}function om(e,t){if(!Array.isArray(t)||t.length!==2)return;let r=tt(t[0]),n=tt(t[1]);r.length===0||n.length===0||e.pairs.some(o=>o[0]===r&&o[1]===n)||e.pairs.push([r,n])}function L0(e){let t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;let r={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(let n of e.allowed_transitions)om(r,n);return{typeKey:t.toLowerCase(),record:r}}function F0(e){if(!Array.isArray(e)||e.length===0)return;let t=new Map;for(let n of e){let o=L0(n);if(o===null)continue;let i=t.get(o.typeKey)??o.record;i.denyAll||=o.record.denyAll;for(let s of o.record.pairs)om(i,s);t.set(o.typeKey,i)}let r=[];for(let n of t.values())(n.pairs.length>0||n.denyAll)&&r.push({type:n.type,allowed_transitions:n.pairs});return r.sort((n,o)=>n.type.localeCompare(o.type)),r.length>0?r:void 0}function im(e){let t=tt(e.key??"");if(!t)return null;let r=tt(e.metadata_key??e.front_matter_key??t),n=Qf(e.cli_flag??nm(t));if(!n)return null;let o=hn(e.cli_aliases).map(u=>Qf(u)).filter(u=>u.length>0&&u!==n),i=typeof e.type=="string"?e.type.trim().toLowerCase():"string",s=C0.has(i)?i:"string",a=(()=>{let u=hn(e.commands).filter(f=>R0.has(f));return u.length>0?u:[...I0]})(),c=e.description?.trim(),d=hn(e.required_types),l=e.value_schema===void 0?void 0:Ho(e.value_schema);return e.value_schema!==void 0&&l===void 0?null:{key:t,metadata_key:r,cli_flag:n,cli_aliases:o,description:c&&c.length>0?c:void 0,type:s,commands:a,repeatable:[e.repeatable===!0,s==="string_array"].includes(!0),required:e.required===!0,required_on_create:e.required_on_create===!0,required_types:d,allow_unset:e.allow_unset!==!1,value_schema:l}}function z0(e){let t=new Map;for(let[n,o]of e.entries()){let i=wa(o,n);i&&t.set(i.id,i)}let r=em([...t.values()]);return r.length>0?r:em(va.map((n,o)=>wa(n,o)).filter(n=>n!==null))}function em(e){return e.sort((t,r)=>t.order===r.order?t.id.localeCompare(r.id):t.order-r.order)}function U0(e){let t=new Map;for(let r of e??[]){let n=im(r);n&&t.set(n.key,n)}return[...t.values()].sort((r,n)=>r.key.localeCompare(n.key))}function H0(e){return{id:e.id,aliases:e.aliases.length>0?[...e.aliases]:void 0,roles:e.roles.length>0?[...e.roles]:void 0,description:e.description,order:e.order}}function q0(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==nm(e.key)?e.cli_flag:void 0,cli_aliases:e.cli_aliases.length>0?[...e.cli_aliases]:void 0,description:e.description,type:e.type,commands:[...e.commands],repeatable:e.repeatable===!0?!0:void 0,required:e.required===!0?!0:void 0,required_on_create:e.required_on_create===!0?!0:void 0,required_types:e.required_types.length>0?[...e.required_types]:void 0,allow_unset:e.allow_unset===!1?!1:void 0,value_schema:e.value_schema}}function V0(e){let t=typeof e=="string"?e.trim().toLowerCase():"allow";return x0.has(t)?t:"allow"}function Ae(e){let t={...oe,...e?.files},r=e?.statuses&&e.statuses.length>0?e.statuses:va,n=z0(r),o=U0(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:n.map(H0),fields:o.map(q0),workflow:{...tm,...j0(e?.workflow)},type_workflows:F0(e?.type_workflows),unknown_field_policy:V0(e?.unknown_field_policy)}}function B0(e,t,r){try{return JSON.parse(e)}catch{r.push(t);return}}function W0(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let r=t.item_types;if(Array.isArray(r.definitions))return r.definitions}}function G0(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function K0(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function Y0(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;return typeof t.workflow=="object"&&t.workflow!==null&&!Array.isArray(t.workflow)?t.workflow:typeof t.workflows=="object"&&t.workflows!==null&&!Array.isArray(t.workflows)?t.workflows:t}function X0(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;if(Array.isArray(t.type_workflows))return t.type_workflows}function ce(e,t,r){let n=t?.trim()||r;return Zf.isAbsolute(n)?n:Zf.join(e,n)}function S1(e,t){return ce(e,t.files.types,oe.types)}async function sm(e,t){let r=Ae(t),n=[{path:ce(e,r.files.types,oe.types),seed:{definitions:[]}},{path:ce(e,r.files.statuses,oe.statuses),seed:{statuses:va}},{path:ce(e,r.files.fields,oe.fields),seed:{fields:[]}},{path:ce(e,r.files.workflows,oe.workflows),seed:{workflow:tm}}],o=[];for(let i of n)await ft(i.path)||await Jf(i.path,`${JSON.stringify(i.seed,null,2)}
34
+ `)&&o.push(i.path);return{created_paths:o}}async function am(e,t){let r=Ae(t),n=[],o=ce(e,r.files.types,oe.types),i=ce(e,r.files.statuses,oe.statuses),s=ce(e,r.files.fields,oe.fields),a=ce(e,r.files.workflows,oe.workflows),c,d,l,u,f,m=async(T,K)=>{let ve=await ge(T);if(ve!==null)return B0(ve,K,n)},_=await m(o,"runtime_schema_types_invalid_json");_!==void 0&&(c=W0(_),c===void 0&&n.push("runtime_schema_types_invalid_shape"));let y=await m(i,"runtime_schema_statuses_invalid_json");y!==void 0&&(d=G0(y),d===void 0&&n.push("runtime_schema_statuses_invalid_shape"));let w=await m(s,"runtime_schema_fields_invalid_json");w!==void 0&&(l=K0(w),l===void 0&&n.push("runtime_schema_fields_invalid_shape"));let v=await m(a,"runtime_schema_workflows_invalid_json");return v!==void 0&&(u=Y0(v),u===void 0&&n.push("runtime_schema_workflows_invalid_shape"),f=X0(v)),{schema:Ae({...r,statuses:[...r.statuses,...d??[]],fields:[...r.fields,...l??[]],workflow:{...r.workflow,...u},type_workflows:[...r.type_workflows??[],...f??[]]}),type_definitions_from_file:c,warnings:n,created_paths:[]}}function yn(e,t,r,n=!1){let o=r.map(s=>pe(s)).filter(s=>typeof s=="string").find(s=>e.some(a=>a.id===s));if(n&&o!==void 0)return o;let i=e.find(s=>s.roles.includes(t));return i!==void 0?i.id:o??e[0]?.id}function J0(e){let t=new Map,r=new Map;for(let n of e){r.set(n.id,n),t.set(n.id,n.id),t.set(n.id.replaceAll("_","-"),n.id),t.set(n.id.replaceAll("_"," "),n.id);for(let o of n.aliases)t.set(o,n.id),t.set(o.replaceAll("_","-"),n.id),t.set(o.replaceAll("_"," "),n.id)}return{aliasToId:t,byId:r}}function Z0(e){let t={activeStatuses:new Set,blockedStatuses:new Set,draftStatuses:new Set,terminalCanceledStatuses:new Set,terminalDoneStatuses:new Set,terminalStatuses:new Set};for(let r of e){let n=new Set(r.roles);(n.has("terminal")||n.has("terminal_done")||n.has("terminal_canceled"))&&t.terminalStatuses.add(r.id),n.has("terminal_done")&&t.terminalDoneStatuses.add(r.id),n.has("terminal_canceled")&&t.terminalCanceledStatuses.add(r.id),n.has("active")&&t.activeStatuses.add(r.id),n.has("blocked")&&t.blockedStatuses.add(r.id),n.has("draft")&&t.draftStatuses.add(r.id)}return t}function cm(e){let t=Ae(e),r=t.statuses.map((v,T)=>wa(v,T)).filter(v=>v!==null),{aliasToId:n,byId:o}=J0(r),{activeStatuses:i,blockedStatuses:s,draftStatuses:a,terminalCanceledStatuses:c,terminalDoneStatuses:d,terminalStatuses:l}=Z0(r),u=t.workflow,f=pe(u.open_status)??yn(r,"default_open",["open","in_progress",Vt[0]]),m=pe(u.in_progress_status)??yn(r,"active",["in_progress","in-progress",f],!0),_=pe(u.blocked_status)??yn(r,"blocked",["blocked"]),y=pe(u.close_status)??yn(r,"default_close",["closed","done","complete"]),w=pe(u.canceled_status)??yn(r,"default_cancel",["canceled","cancelled"]);return{definitions:r,by_id:o,alias_to_id:n,terminal_statuses:l,terminal_done_statuses:d,terminal_canceled_statuses:c,active_statuses:i,blocked_statuses:s,draft_statuses:a,open_status:f,in_progress_status:m,blocked_status:_,close_status:y,canceled_status:w}}function Ea(e,t){let r=tt(e);if(r)return t.alias_to_id.get(r)}function dm(e){let t=Ae(e),r=new Map,n=t.fields.map(c=>im(c)).filter(c=>c!==null);for(let c of n)r.set(c.key,c);let o=[...r.values()].sort((c,d)=>c.key.localeCompare(d.key)),i=new Map,s=new Map,a=new Map;for(let c of o){i.set(c.key,c),s.set(c.cli_flag,c);for(let d of c.cli_aliases)s.set(d,c);for(let d of c.commands){let l=a.get(d)??[];l.push(c),a.set(d,l)}}for(let[c,d]of a.entries())d.sort((l,u)=>l.key.localeCompare(u.key)),a.set(c,d);return{definitions:o,by_key:i,by_cli_token:s,command_to_fields:a}}function lm(e){return $0(e.key)}function O1(e,t){let r=Ea(e,t);return r?t.terminal_statuses.has(r):!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]="4d5692ce-ec33-5eb4-bd9b-7497ffe25b0e")}catch{}})();var Q0=16;function ka(e){let t=e.trim().replaceAll(/[^A-Za-z0-9]+/g," ").split(/\s+/).filter(o=>o.length>0).map(o=>o.toLowerCase());if(t.length===0)return e;let[r,...n]=t;return`${r}${n.map(o=>`${o.slice(0,1).toUpperCase()}${o.slice(1)}`).join("")}`}function ek(e){return[...new Set([lm(e),ka(e.key),ka(e.cli_flag),...e.cli_aliases.map(t=>ka(t))])]}function mm(e,t){for(let r of ek(t)){if(!Object.hasOwn(e,r))continue;let n=e[r];if(n!==void 0)return n}}function pm(e){return Array.isArray(e)?e.flatMap(t=>pm(t)).map(t=>t.trim()).filter(t=>t.length>0):typeof e=="string"?e.split(/[,\n|]/).map(t=>t.trim()).filter(t=>t.length>0):e==null?[]:[String(e).trim()].filter(t=>t.length>0)}function um(e,t){if(typeof e=="boolean")return e;if(typeof e=="number"){if(e===1)return!0;if(e===0)return!1}if(typeof e=="string"){let r=e.trim().toLowerCase();if(r==="true"||r==="1"||r==="yes")return!0;if(r==="false"||r==="0"||r==="no")return!1}throw new g(`${t} must be one of true|false|1|0|yes|no`,h.USAGE)}function fm(e,t){if(typeof e=="number"&&Number.isFinite(e))return e;let r=typeof e=="string"?e.trim():String(e),n=Number(r);if(!Number.isFinite(n))throw new g(`${t} must be a number`,h.USAGE);return n}function tk(e,t,r){let n=typeof e=="string"?(()=>{try{return JSON.parse(e)}catch{return}})():e;if(r==="array"&&Array.isArray(n)||r==="object"&&typeof n=="object"&&n!==null&&!Array.isArray(n))return n;throw new g(`${t} must be valid JSON ${r}`,h.USAGE)}function rk(e,t){return t===void 0?!0:t==="array"?Array.isArray(e):t==="object"?typeof e=="object"&&e!==null&&!Array.isArray(e):typeof e===t}function nk(e,t,r){if(t.const!==void 0&&R(e)!==R(t.const))return`${r} must equal ${R(t.const)}`;if(t.enum!==void 0&&!t.enum.some(n=>R(n)===R(e)))return`${r} must be one of ${t.enum.map(n=>R(n)).join("|")}`;if(!rk(e,t.type))return`${r} must match configured type ${String(t.type)}`;if(typeof e=="string"){if(t.min_length!==void 0&&e.length<t.min_length)return`${r} must contain at least ${t.min_length} characters`;if(t.format==="date-time"&&!un(e))return`${r} must be an RFC 3339 date-time`}}function ok(e,t,r,n){if(Array.isArray(e)){if(t.min_items!==void 0&&e.length<t.min_items)return`${r} must contain at least ${t.min_items} items`;if(t.items)for(let[o,i]of e.entries()){let s=Vo(i,t.items,`${r}[${o}]`,n+1);if(s)return s}}}function ik(e,t,r,n){if(typeof e!="object"||e===null||Array.isArray(e))return;let o=e;for(let i of t.required??[])if(!Object.hasOwn(o,i))return`${r}.${i} is required`;for(let[i,s]of Object.entries(o)){let a=t.properties?.[i];if(!a){if(t.additional_properties===!1)return`${r}.${i} is not allowed`;continue}let c=Vo(s,a,`${r}.${i}`,n+1);if(c)return c}}function Vo(e,t,r,n=0){if(n>Q0)return`${r} value schema exceeds maximum depth`;let o=nk(e,t,r);if(o)return o;let i=ok(e,t,r,n);if(i)return i;let s=ik(e,t,r,n);if(s)return s;if(!t.one_of)return;let a=0;for(let c of t.one_of)if(Vo(e,c,r,n+1)===void 0&&(a+=1,a>1))break;return a===1?void 0:`${r} must match exactly one configured schema variant`}function Tt(e,t,r){if(!e.value_schema||t===void 0)return t;let n=Vo(t,e.value_schema,r);if(n)throw new g(n,h.USAGE);return t}function sk(e,t,r,n){let o=n==="option"&&Array.isArray(t)?t[t.length-1]:t;if(o!==void 0)return Tt(e,tk(o,r,e.type),r)}function gn(e,t,r,n="option"){let o=r??`--${e.cli_flag}`;if(e.type==="array"||e.type==="object")return sk(e,t,o,n);if(e.repeatable||e.type==="string_array"){let s=pm(t);return e.type==="number"?Tt(e,s.map(a=>fm(a,o)),o):e.type==="boolean"?Tt(e,s.map(a=>um(a,o)),o):Tt(e,s,o)}let i=Array.isArray(t)?t[t.length-1]:t;if(i!==void 0)return e.type==="number"?Tt(e,fm(i,o),o):e.type==="boolean"?Tt(e,um(i,o),o):Tt(e,typeof i=="string"?i:String(i),o)}function ak(e,t){return!e.required&&!e.required_on_create?!1:e.required_types.length===0?!0:t?e.required_types.map(r=>r.toLowerCase()).includes(t.trim().toLowerCase()):!1}function N1(e,t,r){let n={},o=[];for(let i of t.command_to_fields.get("create")??[]){let s=mm(e,i);if(s===void 0){ak(i,r)&&o.push(`--${i.cli_flag}`);continue}n[i.metadata_key]=gn(i,s)}return{values:n,missing_required_flags:[...new Set(o)].sort((i,s)=>i.localeCompare(s))}}function D1(e,t,r=["update"]){let n={},o=(r??["update"]).flatMap(s=>t.command_to_fields.get(s)??[]),i=new Set;for(let s of o){let a=mm(e,s);a!==void 0&&(i.has(s.metadata_key)||(i.add(s.metadata_key),n[s.metadata_key]=gn(s,a)))}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]="c35d4830-d7d1-5ee4-99bc-ab52cc3e4e09")}catch{}})();var Sa=1,Oa=2;function M1(e){return Math.max(Aa(e),e.tests?.some(t=>t.updated_by!==void 0||t.updated_at!==void 0)?2:1)}function Aa(e){let t=e.pm_format_version;return typeof t=="number"&&Number.isInteger(t)&&t>=1?t:1}function _m(e){if(!(typeof e!="number"||!Number.isInteger(e)||e<=1))return e}function ck(e,t=2,r=t){return e<r?"outdated":e>t?"ahead":"current"}function $1(e,t=2,r=t){let n=[],o=[];for(let i of e){let s=ck(i.version,t,r);s==="outdated"?n.push(i.ref):s==="ahead"&&o.push(i.ref)}return{outdated:n.sort((i,s)=>i.localeCompare(s)),ahead:o.sort((i,s)=>i.localeCompare(s))}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="515840b7-cf86-5d71-8ac1-beac7fd7c8a8")}catch{}})();var dk={"in-progress":"in_progress",cancelled:"canceled"};function Bo(e,t){if(t){let o=Ea(e,t);if(o)return o}if(typeof e!="string")return;let r=e.trim().toLowerCase();if(!r)return;let n=dk[r]??r;if(Vt.includes(n))return n}function lk(e,t){return Bo(e,t)??e}function z1(e,t){return t.terminal_statuses.has(lk(e,t))}import{encode as pk}from"@toon-format/toon";import{isDeepStrictEqual as ym}from"node:util";import{decode as uk}from"@toon-format/toon";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="aaa2be03-9478-5fbe-82e6-e4fc86e3735b")}catch{}})();function Ia(e){return{value:uk(e),usedScalarBracketEscape:!1}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="79626299-17a8-573a-9b66-ce37c65e2f5d")}catch{}})();var fk=/^\s*(<<<<<<<|=======|>>>>>>>)(?:\s.*)?$/;function mk(e){if(e.length===0)return[];let t=e.split(/\r?\n/),r=[];for(let n=0;n<t.length;n+=1){let o=t[n]??"",i=o.match(fk);if(!i)continue;let s=i[1];r.push({line:n+1,marker:s,text:o})}return r}function Wo(e){return mk(e)[0]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2789e87f-0706-52e8-8f4c-3855c65c618c")}catch{}})();var xa=new Set(["schema","tracker","auto","none"]),vm=new Set(["source","isolated","snapshot"]),_k=new Set(["legacy","local_mutation","local_source_ref","acknowledged","invalid_provenance","foreign_source_ref"]),yk=new Set(["passed","failed","stopped","canceled"]),hk=new Set(rd);function _r(e){return e.replaceAll("\\","/")}function Em(e){for(let t of e)if(t!==0)return t;return 0}function Ko(e){for(let[t,r]of Object.entries(e))r===void 0&&delete e[t]}var km=["id","title","description","created_at","updated_at"],gk=new Set(ze);function Sm(e){if(e?.schema)return{statusRegistry:cm(e.schema),fieldRegistry:dm(e.schema),unknownFieldPolicy:e.schema.unknown_field_policy??"allow",extensionFieldNames:new Set(e.extensionFieldNames??[]),onWarning:e.onWarning}}function bk(e,t){return e.required?e.required_types.length===0?!0:e.required_types.map(r=>r.toLowerCase()).includes(t.trim().toLowerCase()):!1}function rt(e){let t=e.match(/^([a-z_][\w.]*)\s/u)?.[1];throw new g(`Invalid item metadata: ${e}`,h.GENERIC_FAILURE,{code:"item_document_invalid",reason:e.includes("required")?"missing_required_field":"schema_validation_error",...t?{field:t}:{},required:"Provide an item document whose metadata satisfies the active runtime schema.",why:e})}function vn(e,t){throw new g(t,h.GENERIC_FAILURE,{code:"item_document_invalid",reason:"syntax_error",format:e,required:`Provide a syntactically valid ${e==="toon"?"TOON":"JSON Markdown"} item document.`,why:"The document could not be decoded far enough to validate item metadata."})}function Om(e,t){if(!t||typeof e!="object"||e===null)return;let r=Aa(e);if(!(r<=Oa))throw new g(`Stored item uses format version ${r}; this runtime supports up to ${Oa}. Upgrade pm before reading or changing this item.`,h.CONFLICT,{code:"item_format_version_unsupported",format_version:r,required:"Upgrade to a pm runtime supporting the stored item format.",nextSteps:["Preserve the original item and history; do not lower pm_format_version to bypass compatibility checks."]})}function Am(e){let t=new Set(gk);for(let r of e.fieldRegistry?.definitions??[])t.add(r.metadata_key);for(let r of e.extensionFieldNames)t.add(r);return t}function O(e,t){e||rt(t)}function En(e,t){return(typeof e!="object"||e===null||Array.isArray(e))&&rt(t),e}function Ta(e,t){let r=e[t];O(typeof r=="string",`${t} must be a string`),O($e(r),`${t} must be a valid ISO timestamp`)}function hm(e,t,r){let n=e[t];n!==void 0&&O(typeof n=="number"&&Number.isInteger(n)&&n>=1,`${r} must be an integer >= 1`)}function Na(e,t,r){let n=e[t];n!==void 0&&(O(typeof n=="string",`${r} must be a string`),O($e(n),`${r} must be a valid ISO timestamp`))}function wk(e){if(e!==void 0){O(Array.isArray(e),"event.recurrence.by_weekday must be an array");for(let t of e){O(typeof t=="string","event.recurrence.by_weekday entries must be strings");let r=t.trim().toLowerCase();O(xr.includes(r),`event.recurrence.by_weekday entries must be one of: ${xr.join(", ")}`)}}}function vk(e){if(e!==void 0){O(Array.isArray(e),"event.recurrence.by_month_day must be an array");for(let t of e)O(typeof t=="number"&&Number.isInteger(t)&&t>=1&&t<=31,"event.recurrence.by_month_day entries must be integers 1..31")}}function Ek(e){if(e!==void 0){O(Array.isArray(e),"event.recurrence.exdates must be an array");for(let t of e)O(typeof t=="string","event.recurrence.exdates entries must be strings"),O($e(t),"event.recurrence.exdates entries must be valid ISO timestamps")}}function kk(e){let t=En(e,"event.recurrence must be an object");O(typeof t.freq=="string","event.recurrence.freq must be a string");let r=t.freq.trim().toLowerCase();O(Kn.includes(r),`event.recurrence.freq must be one of: ${Kn.join(", ")}`),hm(t,"interval","event.recurrence.interval"),hm(t,"count","event.recurrence.count"),Na(t,"until","event.recurrence.until"),wk(t.by_weekday),vk(t.by_month_day),Ek(t.exdates)}function Sk(e){for(let n of km)O(typeof e[n]=="string",`${n} is required and must be a string`);let t=e.type;O(typeof t=="string"&&t.trim().length>0,"type must be a non-empty string");let r=e.pm_format_version;return r!==void 0&&O(typeof r=="number"&&Number.isInteger(r)&&r>=Sa,`pm_format_version must be an integer >= ${Sa}`),t}function Ok(e,t){let r=e.status;O(typeof r=="string"&&r.trim().length>0,"status must be a non-empty string");let n=t?.statusRegistry,o=Bo(r,n),i=n?n.definitions.map(s=>s.id):[...Vt];O(o!==void 0,`status must be one of: ${i.join(", ")}`)}function Ak(e){let t=e.priority;O(typeof t=="number"&&Number.isInteger(t)&&[0,1,2,3,4].includes(t),"priority must be an integer 0..4");let r=e.tags;O(Array.isArray(r),"tags must be an array");for(let n of r)O(typeof n=="string","tags entries must be strings")}function Ik(e){let t=e.confidence;if(t!==void 0){if(typeof t=="number"){O(Number.isInteger(t)&&t>=0&&t<=100,"confidence number value must be an integer 0..100");return}if(typeof t=="string"){let r=t.trim().toLowerCase(),n=r==="med"||Gn.includes(r);O(n,`confidence string value must be one of: ${[...Gn,"med"].join(", ")}`);return}O(!1,"confidence must be a number or string")}}function Tk(e){let t=e.severity;if(t===void 0)return;typeof t!="string"&&rt("severity must be a string");let r=t.trim().toLowerCase(),n=r==="med"||Wn.includes(r);O(n,`severity value must be one of: ${[...Wn,"med"].join(", ")}`)}function Ck(e){e.regression!==void 0&&typeof e.regression!="boolean"&&rt("regression must be a boolean")}function Rk(e){let t=e.reminders;if(t!==void 0){O(Array.isArray(t),"reminders must be an array");for(let r of t){let n=En(r,"reminders entries must be objects");O(typeof n.at=="string","reminder.at must be a string"),O($e(n.at),"reminder.at must be a valid ISO timestamp"),O(typeof n.text=="string","reminder.text must be a string"),O(n.text.trim().length>0,"reminder.text must not be empty")}}}function xk(e){for(let t of["title","description","location","timezone"])e[t]!==void 0&&(O(typeof e[t]=="string",`event.${t} must be a string`),O(e[t].trim().length>0,`event.${t} must not be empty`))}function Nk(e){e.recurrence!==void 0&&(kk(e.recurrence),e.recurrence.until!==void 0&&O(ne(e.recurrence.until,e.start_at)>=0,"event.recurrence.until must be at or after event.start_at"))}function Dk(e){let t=En(e,"events entries must be objects");O(typeof t.start_at=="string","event.start_at must be a string"),O($e(t.start_at),"event.start_at must be a valid ISO timestamp"),t.end_at!==void 0&&(O(typeof t.end_at=="string","event.end_at must be a string"),O($e(t.end_at),"event.end_at must be a valid ISO timestamp"),O(ne(t.end_at,t.start_at)>0,"event.end_at must be after event.start_at")),xk(t),t.all_day!==void 0&&O(typeof t.all_day=="boolean","event.all_day must be a boolean"),Nk(t)}function Pk(e){let t=e.events;if(t!==void 0){O(Array.isArray(t),"events must be an array");for(let r of t)Dk(r)}}function Mk(e){for(let t of["source_type","source_owner","design","external_ref"]){let r=e[t];r!==void 0&&O(typeof r=="string",`${t} must be a string`)}}function $k(e){let t=e.type_options;if(t===void 0)return;let r=En(t,"type_options must be an object");for(let[n,o]of Object.entries(r))O(n.trim().length>0,"type_options keys must be non-empty"),O(typeof o=="string","type_options values must be strings"),O(o.trim().length>0,"type_options values must be non-empty strings")}function jk(e,t,r){if(r?.fieldRegistry)for(let n of r.fieldRegistry.definitions){let o=e[n.metadata_key];if(o===void 0){bk(n,t)&&rt(`missing required schema field: ${n.metadata_key}`);continue}try{e[n.metadata_key]=gn(n,o,`metadata field "${n.metadata_key}"`,"metadata")}catch(i){rt(String(i?.message).replace(/^Invalid\s+/u,""))}}}function Lk(e,t){if(!t||t.unknownFieldPolicy==="allow")return;let r=Am(t),n=Object.keys(e).filter(o=>!r.has(o)).sort((o,i)=>o.localeCompare(i));n.length!==0&&(t.unknownFieldPolicy==="reject"?rt(`unknown schema fields are not allowed: ${n.join(", ")}`):t.onWarning?.(`item_unknown_schema_fields:${n.join(",")}`))}function Da(e,t){let r=En(e,"item metadata must be an object"),n=Sk(r);Ok(r,t),Ak(r),Ik(r),Tk(r),Ck(r),Ta(r,"created_at"),Ta(r,"updated_at"),r.deadline!==void 0&&Ta(r,"deadline"),Rk(r),Pk(r),Na(r,"closed_at","closed_at"),Na(r,"completed_at","completed_at"),Mk(r),$k(r),jk(r,n,t),Lk(r,t)}function Fk(e){if(!(!e||e.length===0))return[...e].map((t,r)=>(O(t.created_at===void 0||typeof t.created_at=="string"&&un(t.created_at),`dependencies.${r}.created_at requires a valid timestamp; restore the dependency timestamp from its source record`),{id:t.id.trim(),kind:t.kind,created_at:t.created_at,author:t.author?.trim()||void 0,source_kind:t.source_kind?.trim()||void 0,author_source:t.author_source})).sort((t,r)=>{let n=ne(t.created_at??"",r.created_at??"");if(n!==0)return n;let o=t.id.localeCompare(r.id);if(o!==0)return o;let i=t.kind.localeCompare(r.kind);return i!==0?i:(t.source_kind??"").localeCompare(r.source_kind??"")})}function Ca(e){if(!(!e||e.length===0))return[...e].sort((t,r)=>{let n=ne(t.created_at,r.created_at);if(n!==0)return n;let o=t.text.localeCompare(r.text);return o!==0?o:t.author.localeCompare(r.author)})}function zk(e){if(!e||e.length===0)return;let t=[...e].map(r=>({at:r.at,text:r.text.trim()})).filter(r=>r.text.length>0).sort((r,n)=>{let o=ne(r.at,n.at);return o!==0?o:r.text.localeCompare(n.text)});return t.length===0?void 0:t}function Uk(e){if(!e)return;let t=e.freq.trim().toLowerCase();if(!Kn.includes(t))return;let r=Array.from(new Set((e.by_weekday??[]).map(s=>s.trim().toLowerCase()).filter(s=>xr.includes(s)))).sort((s,a)=>ji(s)-ji(a)),n=Array.from(new Set((e.by_month_day??[]).filter(s=>Number.isInteger(s)&&s>=1&&s<=31).map(s=>s))).sort((s,a)=>s-a),o=Array.from(new Set((e.exdates??[]).map(s=>s.trim()).filter(s=>$e(s)))).sort((s,a)=>ne(s,a)),i={freq:t,interval:e.interval!==void 0&&e.interval>1?e.interval:void 0,count:e.count,until:e.until?.trim()||void 0,by_weekday:r.length>0?r:void 0,by_month_day:n.length>0?n:void 0,exdates:o.length>0?o:void 0};for(let[s,a]of Object.entries(i))a===void 0&&delete i[s];return i}function Hk(e){return!Array.isArray(e)||e.length===0?void 0:[...e].map(qk).sort(Vk)}function qk(e){let t={start_at:e.start_at,end_at:e.end_at||void 0,title:e.title?.trim()||void 0,description:e.description?.trim()||void 0,location:e.location?.trim()||void 0,all_day:e.all_day,timezone:e.timezone?.trim()||void 0,recurrence:Uk(e.recurrence)};return Ko(t),t}function Vk(e,t){return Em([ne(e.start_at,t.start_at),(e.end_at??"").localeCompare(t.end_at??""),(e.title??"").localeCompare(t.title??""),+!!e.all_day-+!!t.all_day,(e.timezone??"").localeCompare(t.timezone??""),(e.location??"").localeCompare(t.location??""),(e.description??"").localeCompare(t.description??""),JSON.stringify(e.recurrence??{}).localeCompare(JSON.stringify(t.recurrence??{}))])}function Bk(e){if(!(!e||e.length===0))return e.map(t=>({path:_r(t.path),scope:t.scope,note:t.note?.trim()||void 0}))}function Wk(e){if(!e||e.length===0)return;let t=e.map(Xk).filter(r=>r.run_id.length>0&&r.started_at.length>0&&r.finished_at.length>0&&r.recorded_at.length>0).sort((r,n)=>Em([ne(r.recorded_at,n.recorded_at),r.run_id.localeCompare(n.run_id),r.kind.localeCompare(n.kind)]));return t.length>0?t:void 0}function mr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0}function Gk(e){return typeof e=="number"&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0}function Ra(e){return typeof e=="string"?e:""}function Kk(e){if(!Array.isArray(e))return;let t=e.filter(n=>n!==null&&typeof n=="object"&&typeof n.name=="string"&&n.name.trim().length>0&&typeof n.value=="number"&&Number.isFinite(n.value)&&typeof n.recorded_at=="string"&&n.recorded_at.trim().length>0).map(n=>({name:n.name.trim(),value:n.value,unit:typeof n.unit=="string"&&n.unit.trim()||void 0,threshold:typeof n.threshold=="number"&&Number.isFinite(n.threshold)?n.threshold:void 0,recorded_at:n.recorded_at.trim()})),r=[...new Map(t.map(n=>[n.name,n])).values()].sort((n,o)=>n.name.localeCompare(o.name)).slice(0,32);return r.length>0?r:void 0}function Go(e,t){return typeof e=="string"&&t.has(e)?e:void 0}function Yk(e){if(!Array.isArray(e))return;let t=e.filter(r=>r&&typeof r.command=="string"&&r.command.trim().length>0).slice(0,32).map(r=>({command:r.command.trim(),requested_pm_context_mode:Go(r.requested_pm_context_mode,xa),pm_context_mode:Go(r.pm_context_mode,xa),workspace_context_mode:Go(r.workspace_context_mode,vm),trust_reason:Go(r.trust_reason,_k)}));return t.length>0?t:void 0}function Xk(e){let t=typeof e.run_id=="string"?e.run_id.trim():"",r=e.kind==="test"||e.kind==="test-all"?e.kind:"test",n=yk.has(e.status)?e.status:"failed",o={run_id:t,kind:r,status:n,started_at:Ra(e.started_at),finished_at:Ra(e.finished_at),recorded_at:Ra(e.recorded_at),attempt:Gk(e.attempt),resumed_from:e.resumed_from?.trim()||void 0,passed:mr(e.passed)??0,failed:mr(e.failed)??0,skipped:mr(e.skipped)??0,items:mr(e.items),linked_tests:mr(e.linked_tests),fail_on_skipped_triggered:e.fail_on_skipped_triggered===!0?!0:void 0,measurements:Kk(e.measurements),executions:Yk(e.executions)};return Ko(o),o}function Jk(e){if(!(!Array.isArray(e)||e.length===0))return e.map(rS)}function bn(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(r=>typeof r=="string").map(r=>r.trim()).filter(r=>r.length>0))].sort((r,n)=>r.localeCompare(n));return t.length>0?t:void 0}function ja(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function La(e){return e==="__proto__"||e==="constructor"||e==="prototype"}function gm(e){if(!ja(e))return;let t=Object.entries(e).map(([r,n])=>[r.trim(),String(n).trim()]).filter(([r,n])=>r.length>0&&!La(r)&&n.length>0).sort(([r],[n])=>r.localeCompare(n));return t.length>0?Object.fromEntries(t):void 0}function Zk(e){if(!ja(e))return;let t=Object.entries(e).map(([r,n])=>[r.trim(),Number(n)]).filter(([r,n])=>r.length>0&&!La(r)&&Number.isFinite(n)).sort(([r],[n])=>r.localeCompare(n));return t.length>0?Object.fromEntries(t):void 0}function Qk(e){let t=e?.trim().toLowerCase();if(!(!t||!xa.has(t)))return t}function eS(e){let t=e?.trim().toLowerCase();if(!(!t||!vm.has(t)))return t}function tS(e,t){if(t===!0)return{provenance_invalid:!0};if(e===void 0)return{};if(!ja(e))return{provenance_invalid:!0};let r=E(e.author),n=E(e.created_at),o=e.source_kind;return!r||!n||!$e(n)||o!=="local_mutation"&&o!=="merge_union"?{provenance_invalid:!0}:{provenance:{author:r,created_at:n,source_kind:o,source_ref:E(e.source_ref)}}}function rS(e){let t={command:e.command?.trim()||void 0,path:e.path?_r(e.path):void 0,scope:e.scope,timeout_seconds:typeof e.timeout_seconds=="number"&&Number.isFinite(e.timeout_seconds)&&e.timeout_seconds>0?e.timeout_seconds:void 0,pm_context_mode:Qk(e.pm_context_mode),workspace_context_mode:eS(e.workspace_context_mode),...tS(e.provenance,e.provenance_invalid),updated_by:E(e.updated_by),updated_at:E(e.updated_at),env_set:gm(e.env_set),env_clear:bn(e.env_clear),shared_host_safe:e.shared_host_safe===!0?!0:void 0,assert_stdout_contains:bn(e.assert_stdout_contains),assert_stdout_regex:bn(e.assert_stdout_regex),assert_stderr_contains:bn(e.assert_stderr_contains),assert_stderr_regex:bn(e.assert_stderr_regex),assert_stdout_min_lines:mr(e.assert_stdout_min_lines),assert_json_field_equals:gm(e.assert_json_field_equals),assert_json_field_gte:Zk(e.assert_json_field_gte),note:e.note?.trim()||void 0};return Ko(t),t}function nS(e){if(!(!e||e.length===0))return[...e].map(t=>({path:_r(t.path),scope:t.scope,note:t.note?.trim()||void 0})).sort((t,r)=>{let n=t.scope.localeCompare(r.scope);if(n!==0)return n;let o=t.path.localeCompare(r.path);return o!==0?o:(t.note??"").localeCompare(r.note??"")})}function E(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function oS(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=E(n.id),i=E(n.kind);if(!o||!i)continue;let s={id:o,kind:i},a=E(n.note);a&&(s.note=a),n.required_before_step===!0&&(s.required_before_step=!0),t.push(s)}return t.length>0?t:void 0}function iS(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=E(n.path);if(!o)continue;let i={path:_r(o)};(n.scope==="project"||n.scope==="global")&&(i.scope=n.scope);let s=E(n.note);s&&(i.note=s),t.push(i)}return t.length>0?t:void 0}function sS(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=E(n.command),i=E(n.path);if(!o&&!i)continue;let s={};o&&(s.command=o),i&&(s.path=_r(i));let a=E(n.note);a&&(s.note=a),t.push(s)}return t.length>0?t:void 0}function aS(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=E(n.path);if(!o)continue;let i={path:_r(o)};(n.scope==="project"||n.scope==="global")&&(i.scope=n.scope);let s=E(n.note);s&&(i.note=s),t.push(i)}return t.length>0?t:void 0}function cS(e){if(e===null||typeof e!="object")return;let t=e,r=E(t.id),n=E(t.title),o=E(t.status),i=o&&hk.has(o)?o:void 0,s=Hn(t.order)??Number.NaN,a=typeof t.created_at=="string"?t.created_at:"",c=typeof t.updated_at=="string"?t.updated_at:"";if(!r||!n||!i||!Number.isFinite(s)||!a||!c)return;let d={id:r,order:s,title:n,status:i,created_at:a,updated_at:c};return dS(d,t),d}function dS(e,t){let r=[["body","body"],["owner","owner"],["evidence","evidence"],["blocked_reason","blocked_reason"],["superseded_by","superseded_by"]];for(let[i,s]of r){let a=E(t[s]);a&&(e[i]=a)}let n=typeof t.completed_at=="string"?t.completed_at:void 0;n&&n.length>0&&(e.completed_at=n);let o=[["linked_items","linked_items",oS],["files","files",iS],["tests","tests",sS],["docs","docs",aS]];for(let[i,s,a]of o){let c=a(t[s]);c&&(e[i]=c)}}function lS(e){if(!Array.isArray(e))return;let t=e.flatMap(r=>{let n=cS(r);return n?[n]:[]});return t.sort((r,n)=>r.order-n.order),t.length>0?t:void 0}function uS(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=typeof n.ts=="string"?n.ts:"",i=typeof n.author=="string"?n.author:"",s=E(n.decision);if(!o||!i||!s)continue;let a={ts:o,author:i,decision:s},c=E(n.rationale);c&&(a.rationale=c);let d=E(n.evidence);d&&(a.evidence=d);let l=E(n.step_id);l&&(a.step_id=l),t.push(a)}return t.length>0?t:void 0}function fS(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=typeof n.ts=="string"?n.ts:"",i=typeof n.author=="string"?n.author:"",s=E(n.text);if(!o||!i||!s)continue;let a={ts:o,author:i,text:s},c=E(n.step_id);c&&(a.step_id=c),t.push(a)}return t.length>0?t:void 0}function mS(e){if(!Array.isArray(e))return;let t=[];for(let r of e){if(r===null||typeof r!="object")continue;let n=r,o=E(n.text);if(!o)continue;let i={text:o},s=E(n.command);s&&(i.command=s);let a=E(n.expected);a&&(i.expected=a),t.push(i)}return t.length>0?t:void 0}function pS(e){if(!e)return;let t=Object.entries(e).map(([r,n])=>[r.trim(),n.trim()]).filter(([r,n])=>r.length>0&&n.length>0).sort((r,n)=>r[0].localeCompare(n[0]));if(t.length!==0)return Object.fromEntries(t)}function pr(e){let t=0;for(;t<e.length&&e[t]===`
35
+ `;)t+=1;return e.slice(t).trimEnd()}function _S(e){if(e===void 0)return;if(typeof e=="number")return e;let t=e.trim().toLowerCase();if(t==="med")return"medium";if(Gn.includes(t))return t}function yS(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t==="med")return"medium";if(Wn.includes(t))return t}function wn(e){return e||void 0}function hS(e,t){let r=e,n=t;for(let[o,i]of Object.entries(n))La(o)||Object.prototype.hasOwnProperty.call(r,o)||i===void 0||(r[o]=i)}function gS(e,t){if(!t?.fieldRegistry)return;let r=e;for(let n of t.fieldRegistry.definitions){let o=r[n.metadata_key];o!==void 0&&(r[n.metadata_key]=gn(n,o,`metadata field "${n.metadata_key}"`,"metadata"))}}function bS(e,t){if(!t||t.unknownFieldPolicy==="allow")return;let r=Am(t),n=Object.keys(e).filter(o=>!r.has(o)).sort((o,i)=>o.localeCompare(i));n.length>0&&t.unknownFieldPolicy==="reject"&&rt(`unknown schema fields are not allowed: ${n.join(", ")}`),n.length>0&&t.onWarning?.(`item_unknown_schema_fields:${n.join(",")}`)}function Yo(e,t={}){let r=Sm(t),n=Bo(e.status,r?.statusRegistry)??e.status,o=Array.from(new Set((Array.isArray(e.tags)?e.tags:[]).filter(s=>typeof s=="string").map(s=>s.trim().toLowerCase()).filter(Boolean))).sort((s,a)=>s.localeCompare(a)),i={id:e.id,title:e.title,description:e.description,type:e.type,pm_format_version:_m(e.pm_format_version),source_type:E(e.source_type),type_options:pS(e.type_options),status:n,priority:e.priority,tags:o,created_at:e.created_at,updated_at:e.updated_at,dependencies:Fk(e.dependencies),comments:Ca(e.comments),notes:Ca(e.notes),learnings:Ca(e.learnings),files:Bk(e.files),tests:Jk(e.tests),test_runs:Wk(e.test_runs),docs:nS(e.docs),deadline:wn(e.deadline),reminders:zk(e.reminders),events:Hk(e.events),closed_at:wn(e.closed_at),completed_at:wn(e.completed_at),assignee:E(e.assignee),claim_principal:E(e.claim_principal),source_owner:E(e.source_owner),author:wn(e.author),estimated_minutes:e.estimated_minutes,acceptance_criteria:e.acceptance_criteria??void 0,design:e.design??void 0,external_ref:e.external_ref??void 0,definition_of_ready:E(e.definition_of_ready),order:e.order,goal:E(e.goal),objective:E(e.objective),value:E(e.value),impact:E(e.impact),outcome:E(e.outcome),why_now:E(e.why_now),parent:E(e.parent),reviewer:E(e.reviewer),risk:e.risk??void 0,confidence:_S(e.confidence),sprint:E(e.sprint),release:E(e.release),blocked_by:E(e.blocked_by),blocked_reason:E(e.blocked_reason),unblock_note:E(e.unblock_note),reporter:E(e.reporter),severity:yS(e.severity),environment:E(e.environment),repro_steps:E(e.repro_steps),resolution:E(e.resolution),expected_result:E(e.expected_result),actual_result:E(e.actual_result),affected_version:E(e.affected_version),fixed_version:E(e.fixed_version),component:E(e.component),regression:e.regression,customer_impact:E(e.customer_impact),close_reason:wn(e.close_reason),plan_mode:E(e.plan_mode),plan_scope:E(e.plan_scope),plan_harness:E(e.plan_harness),plan_resume_context:E(e.plan_resume_context),plan_steps:lS(e.plan_steps),plan_decisions:uS(e.plan_decisions),plan_discoveries:fS(e.plan_discoveries),plan_validation:mS(e.plan_validation)};return hS(i,e),gS(i,r),bS(i,r),Ko(i),i}function Im(e){return A(e,ze)}function wS(e){let t=0,r=!1,n=!1;for(let o=0;o<e.length;o+=1){let i=e[o];if(r){if(n){n=!1;continue}if(i==="\\"){n=!0;continue}i==='"'&&(r=!1);continue}if(i==='"'){r=!0;continue}if(i==="{"){t+=1;continue}if(i==="}"&&(t-=1,t===0))return o}return-1}function vS(e){if(!e.startsWith("{"))return{frontMatter:"",body:e};let t=wS(e);if(t<0)return{frontMatter:"",body:e};let r=e.slice(0,t+1),n=e.slice(t+1).replace(/^\r?\n+/,"");return{frontMatter:r,body:n}}function ES(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,r=t.match(/^[ \t]*---[ \t]*(?:\r?\n|$)/);if(!r)return{content:t,stripped:!1};let n=r[0].length;for(;n<t.length;){let o=t.indexOf(`
36
+ `,n),i=o===-1?t.length:o,s=t.slice(n,i).replace(/\r$/,""),a=o===-1?i:i+1;if(s.trim()==="---")return{content:t.slice(a).replace(/^\s+/,""),stripped:!0};n=a}return{content:t,stripped:!1}}function Pa(e,t){return Yo(e,{...t,onWarning:void 0})}function kS(e,t,r={}){let n=ES(e);n.stripped&&r.onWarning?.("json_markdown_leading_yaml_frontmatter_ignored");let{frontMatter:o,body:i}=vS(n.content);o||(e.trimStart().startsWith("{")&&vn("json_markdown","JSON front matter is not valid JSON"),vn("json_markdown","JSON Markdown item document is missing JSON front matter"));let s;try{s=JSON.parse(o)}catch{vn("json_markdown","JSON front matter is not valid JSON")}return Om(s,r.requireSupportedFormat),Da(s,t),{metadata:Pa(s,r),body:pr(i)}}function SS(e,t,r={}){let n;try{n=Ia(e).value}catch{vn("toon","TOON item document is not valid TOON")}O(typeof n=="object"&&n!==null&&!Array.isArray(n),"TOON item document must be an object");let o=n;if(Om(Object.prototype.hasOwnProperty.call(o,"front_matter")?o.front_matter:o,r.requireSupportedFormat),!km.some(a=>Object.prototype.hasOwnProperty.call(o,a))&&!Object.prototype.hasOwnProperty.call(o,"front_matter")&&vn("toon","TOON input does not have the shape of an item document"),Object.prototype.hasOwnProperty.call(o,"front_matter"))return Da(o.front_matter,t),O(o.body===void 0||typeof o.body=="string","TOON item document body must be a string"),{metadata:Pa(o.front_matter,r),body:pr(typeof o.body=="string"?o.body:"")};let{body:i,...s}=o;return O(i===void 0||typeof i=="string","TOON item document body must be a string"),Da(s,t),{metadata:Pa(s,r),body:pr(typeof i=="string"?i:"")}}function OS(e,t={}){let r=Yo(e.metadata,t),n=Im(r),o=pr(e.body??"");$a(JSON.parse(JSON.stringify(n))),$a({body:o});let i=JSON.stringify(n,null,2);return o?`${i}
37
+
38
+ ${o}
39
+ `:`${i}
40
+ `}var AS=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u;function Ma(e,t){return typeof e=="string"?bm(e,t):e===null||typeof e!="object"?null:Array.isArray(e)?wm(e.map((r,n)=>()=>Ma(r,`${t}[${n}]`))):wm(Object.entries(e).map(([r,n])=>()=>{let o=t?`${t}.${r}`:r;return bm(r,`${o} (key)`)??Ma(n,o)}))}function bm(e,t){let r=e.search(AS);return r<0?null:{path:t,index:r}}function wm(e){for(let t of e){let r=t();if(r!==null)return r}return null}function $a(e){let t=Ma(e,"");if(t!==null)throw new g(`Item field ${t.path} contains an unpaired surrogate code unit at index ${t.index}; persisted item text requires well-formed Unicode.`,h.USAGE,{code:"text_unpaired_surrogate",field:t.path,required:"Provide well-formed UTF-16 text: keep emoji and other astral characters whole and avoid lone \\uD800-\\uDFFF JSON escapes.",why:"Persisted item text must remain well-formed in every supported format; a lone surrogate can cause an unclassified encoder fault.",nextSteps:[`Repair the ${t.path} value (for example String.prototype.toWellFormed() or re-truncate on a character boundary) and retry.`,"Run pm <command> --help --json to review the text fields the command accepts."]})}function IS(e,t={}){let r=Yo(e.metadata,t),n=Im(r),o=pr(e.body??""),i={...n,body:o},s=JSON.parse(JSON.stringify(i));$a(s);let a=pk(s),c;try{c=Ia(a).value}catch(d){throw new g("Refusing to persist a TOON item document that the configured decoder cannot read back.",h.GENERIC_FAILURE,{code:"item_document_roundtrip_failed",reason:"encode_decode_error",format:"toon",required:"Upgrade or repair the TOON codec before retrying the mutation; no item bytes were written.",why:d instanceof Error?d.message:String(d)})}if(!ym(c,s)){let d=typeof c=="object"&&c!==null&&!Array.isArray(c)?c:{},l=Object.keys(s).find(u=>!ym(s[u],d[u]))??"document";throw new g(`Refusing to persist a lossy TOON item document; round-trip mismatch at field "${l}".`,h.GENERIC_FAILURE,{code:"item_document_roundtrip_failed",reason:"encode_decode_mismatch",format:"toon",field:l,required:"Upgrade or repair the TOON codec before retrying the mutation; no item bytes were written.",why:"The encoded document decoded to a value different from the canonical item payload."})}return`${a}
41
+ `}function iM(e,t={}){let r=Wo(e);if(r)throw new g(`Merge conflict markers detected in item document at line ${r.line} (${r.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,h.GENERIC_FAILURE,{code:"merge_conflict_markers_detected",reason:"merge_conflict",required:"Resolve merge-conflict markers in the item file before parsing or mutation commands.",why:"Partially merged documents can corrupt item metadata and history integrity.",examples:["git status","git add <resolved-file> && git commit"],nextSteps:["Resolve conflicts, save the file, then rerun the pm command."]});let n=t.format??"toon",o=Sm(t);return n==="toon"?SS(e,o,t):kS(e,o,t)}function sM(e,t={}){return(t.format??"toon")==="toon"?IS(e,t):OS(e,t)}function yr(e,t={}){return{metadata:Yo(e.metadata,t),body:pr(e.body??"")}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="82c79093-2a40-5b4c-8d41-637b0ae03c4f")}catch{}})();function Tm(e){return e}import{AsyncLocalStorage as TS}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1fbb183b-c6d8-5834-b4cb-e4fb515572b9")}catch{}})();var Fa=new TS,Cm=/^[A-Za-z0-9](?:[A-Za-z0-9._:-]{0,127})$/u;function Xo(e,t){let r=typeof e=="string"?e.trim():"";return r.length>0?r.slice(0,t):void 0}function Ct(e,t){if(e===void 0)return;let r=typeof e=="object"&&e!==null?e:{},n=Xo(r.id,128),o=Xo(r.parent_id,128);if(n===void 0||!Cm.test(n)||o!==void 0&&!Cm.test(o)){if(t)throw new Error("Agent episode ids must be 1-128 letters, digits, dots, underscores, colons, or hyphens.");return}let i=Xo(r.label,256);return{id:n,...i===void 0?{}:{label:i},...o===void 0?{}:{parent_id:o}}}function hr(e){let t={};for(let[r,n]of Object.entries(e??{}).slice(0,32)){let o=r.trim().toLowerCase().slice(0,64),i=Xo(n,256);/^[a-z][a-z0-9_-]{0,63}$/u.test(o)&&i!==void 0&&(t[o]=i)}return t}function CS(e,t,r){let n=Fa.getStore(),o=hr({role:t.PM_AGENT_SESSION_ROLE,topic:t.PM_AGENT_SESSION_TOPIC}),i=Ct(t.PM_AGENT_EPISODE_ID===void 0?void 0:{id:t.PM_AGENT_EPISODE_ID,label:t.PM_AGENT_EPISODE_LABEL,parent_id:t.PM_AGENT_EPISODE_PARENT_ID},!1),s={...hr(n?.provenance),...o,...hr(e?.provenance)},a=Ct(e?.episode,!1)??Ct(r,!1)??i??Ct(n?.episode,!1);return Object.keys(s).length===0&&a===void 0?void 0:{...Object.keys(s).length===0?{}:{provenance:s},...a===void 0?{}:{episode:a}}}function za(e,t){return CS(e.session_context,t,e.client_info?.episode)??{}}function lM(e,t){let r=Fa.getStore(),n=Ct(e.episode,!0),o=Ct(r?.episode,!1),i=n!==void 0&&n.parent_id===void 0&&o!==void 0?{...n,parent_id:o.id}:n,s={...hr(r?.provenance),...hr(e.provenance)};return Fa.run({...Object.keys(s).length===0?{}:{provenance:s},...i===void 0?o===void 0?{}:{episode:o}:{episode:i}},t)}function uM(e){let t=hr(e.provenance),r=Ct(e.episode,!0);return{...r===void 0?{}:{PM_AGENT_EPISODE_ID:r.id,...r.label===void 0?{}:{PM_AGENT_EPISODE_LABEL:r.label},...r.parent_id===void 0?{}:{PM_AGENT_EPISODE_PARENT_ID:r.parent_id}},...t.role===void 0?{}:{PM_AGENT_SESSION_ROLE:t.role},...t.topic===void 0?{}:{PM_AGENT_SESSION_TOPIC:t.topic}}}import{createHash as Rm}from"node:crypto";import{existsSync as Ua,promises as xm,readFileSync as RS}from"node:fs";import Ie 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]="06c9f6f4-c2f0-549c-9a0f-4f4269cc5f49")}catch{}})();var xS="session.json";function Ha(e,t){return typeof e=="string"&&e.length>0&&e.length<=t}function Nm(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=e,r=["implementer","planner","release-operator"].includes(String(t.role)),n=["high","medium"].includes(String(t.confidence)),o=Ha(t.topic,256),i=Array.isArray(t.evidence)&&t.evidence.length<=32&&t.evidence.every(c=>typeof c=="string"&&c.length<=128),s=Array.isArray(t.active_item_ids)&&t.active_item_ids.length<=64&&t.active_item_ids.every(c=>Ha(c,128)),a=t.focused_item_id===void 0||Ha(t.focused_item_id,128);if([r,n,o,i,s,a,t.rule_version==="v2"].every(Boolean))return t}function NS(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=Object.entries(e).slice(0,128).flatMap(([r,n])=>{let o=Nm(n);return o&&r.length<=128?[[r,o]]:[]});return t.length>0?Object.fromEntries(t):void 0}function qa(e){return Ie.join(qi(e),xS)}async function Dm(e){try{let t=await xm.readFile(qa(e),"utf8"),r=JSON.parse(t);if(r===null||typeof r!="object"||Array.isArray(r))return{};let n=r,o=n.focused_item,i=NS(n.semantic_attribution);return typeof o=="string"&&o.trim().length>0?{focused_item:o,...i?{semantic_attribution:i}:{}}:i?{semantic_attribution:i}:{}}catch{return{}}}async function Va(e,t){let r=await ae(e,"session-state",S.locks.ttl_seconds,"session-state",!1,!0,S.locks.wait_ms);try{let n=await Dm(e);t(n);let o=qa(e);await xm.mkdir(Ie.dirname(o),{recursive:!0}),await mt(o,JSON.stringify(n))}finally{await r()}}function Ba(e){return/#([a-f0-9]{24})$/u.exec(e.trim())?.[1]??`author-${Rm("sha256").update(e).digest("hex").slice(0,24)}`}function Wa(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].slice(0,32).map(t=>t.slice(0,128))}function Ga(e){let t=[...new Set(e)].sort((n,o)=>n.localeCompare(o));if(t.length===1)return t[0];let r=`workset:${t.join("+")}`;return r.length<=256?r:`workset:${t.join("+").slice(0,230)}+${Rm("sha256").update(t.join("\0")).digest("hex").slice(0,12)}`}async function Ka(e,t,r){await Va(e,n=>{let o={...n.semantic_attribution},i=r(o[t]);i===void 0?delete o[t]:o[t]=i,Object.keys(o).length===0?delete n.semantic_attribution:n.semantic_attribution=o})}async function wM(e){let t=Ba(e.principal);await Ka(e.pmRoot,t,r=>{let n=[...new Set([...r?.active_item_ids??[],e.itemId])].slice(-64).sort((i,s)=>i.localeCompare(s)),o=r?.focused_item_id;return{role:"implementer",topic:o??Ga(n),confidence:o?"high":"medium",rule_version:"v2",evidence:Wa([...n.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:n,...o?{focused_item_id:o}:{}}})}async function vM(e){let t=Ba(e.principal);await Ka(e.pmRoot,t,r=>{if(!r)return;let n=r.active_item_ids.filter(i=>i!==e.itemId);if(n.length===0&&!r.focused_item_id)return;let o=r.focused_item_id;return{...r,role:"release-operator",topic:o??Ga(n),confidence:o?"high":"medium",evidence:Wa([...n.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],`release:${e.itemId}`]),active_item_ids:n}})}async function EM(e){let t=Ba(e.principal);await Ka(e.pmRoot,t,r=>{let n=r?.active_item_ids??[];if(!e.itemId&&n.length===0)return;let o=e.itemId;return{role:o?"planner":r.role,topic:o??Ga(n),confidence:o?"high":"medium",rule_version:"v2",evidence:Wa([...n.map(i=>`claim:${i}`),...o?[`focus:${o}`]:[],...(e.lineageIds??[]).map(i=>`lineage:${i}`)]),active_item_ids:n,...o?{focused_item_id:o}:{}}})}function DS(e,t){let r=t.PM_PATH?.trim();if(r){let o=Ie.resolve(e,r);if(Ua(Ie.join(o,"settings.json")))return o;let i=Ie.join(o,".agents","pm");if(Ua(Ie.join(i,"settings.json")))return i}let n=Ie.resolve(e);for(let o=0;o<32;o+=1){let i=Ie.join(n,".agents","pm");if(Ua(Ie.join(i,"settings.json")))return i;let s=Ie.dirname(n);if(s===n)break;n=s}}function Pm(e){if(!e.key)return;let t=DS(e.cwd,e.env);if(t)try{let r=JSON.parse(RS(qa(t),"utf8"));return Nm(r.semantic_attribution?.[e.key])}catch{return}}async function kM(e){return(await Dm(e)).focused_item}async function SM(e,t){await Va(e,r=>{r.focused_item=t})}async function OM(e){await Va(e,t=>{delete t.focused_item})}import{AsyncLocalStorage as Qa}from"node:async_hooks";import{createHash as PS}from"node:crypto";import de from"node:fs";import Lm from"node:os";import Nt 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]="a69b86e2-6633-5abc-81b7-6a54a592d36c")}catch{}})();var ec=["model","effort","role","topic","version"],Qo=new Qa,Fm=new Qa,ei=new Qa,tc=[{harness:"claude-code",environment_keys:["CLAUDE_CODE","CLAUDECODE"],model_environment_keys:["ANTHROPIC_MODEL","CLAUDE_MODEL"],session_environment_keys:["CLAUDE_CODE_SESSION_ID"],provenance_environment_keys:{effort:["CLAUDE_EFFORT"]},provenance_resolvers:{model:"claude_session_file",version:"claude_session_file"},provenance_unavailable_dimensions:["role","topic"],argv_markers:["claude","claude-code"],client_names:["claude","claude-code","claude code"]},{harness:"codex",environment_keys:["CODEX_HOME","CODEX_CI","CODEX_THREAD_ID"],model_environment_keys:["CODEX_MODEL"],session_environment_keys:["CODEX_THREAD_ID"],provenance_environment_keys:{effort:["CODEX_REASONING_EFFORT","CODEX_EFFORT"],role:["CODEX_SESSION_ROLE"]},provenance_resolvers:{model:"codex_session_file",effort:"codex_session_file",version:"ai_agent_version"},provenance_unavailable_dimensions:["topic"],argv_markers:["codex"],client_names:["codex"]},{harness:"pi",environment_keys:["PI_AGENT","PI_CODING_AGENT"],model_environment_keys:["PI_MODEL"],session_environment_keys:["PI_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["pi"],client_names:["pi"]},{harness:"opencode",environment_keys:["OPENCODE","OPENCODE_SESSION_ID"],model_environment_keys:["OPENCODE_MODEL"],session_environment_keys:["OPENCODE_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["opencode"],client_names:["opencode"]},{harness:"cursor",environment_keys:["CURSOR_AGENT","CURSOR_TRACE_ID"],model_environment_keys:["CURSOR_MODEL"],session_environment_keys:["CURSOR_TRACE_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["cursor"],client_names:["cursor"]},{harness:"aider",environment_keys:["AIDER","AIDER_MODEL"],model_environment_keys:["AIDER_MODEL"],session_environment_keys:["AIDER_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["aider"],client_names:["aider"]},{harness:"gemini-cli",environment_keys:["GEMINI_CLI","GEMINI_CLI_HOME"],model_environment_keys:["GEMINI_MODEL"],session_environment_keys:["GEMINI_CLI_SESSION_ID"],provenance_unavailable_dimensions:["effort","role","topic"],argv_markers:["gemini","gemini-cli"],client_names:["gemini","gemini-cli","gemini cli"]},{harness:"ci",environment_keys:["CI","GITHUB_ACTIONS","BUILDKITE","GITLAB_CI"],provenance_unavailable_dimensions:["model","effort","role","topic"],argv_markers:[],client_names:[]}],zm=Object.freeze({max_bytes:1048576,max_lines:4096,network_access:!1,subprocess_access:!1}),MS=Object.freeze({...zm,max_bytes:4194304}),Ya=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function $S(e){let t=ot(e).provenance_unavailable_dimensions,r=new Set(["model","version",...Object.keys(e.provenance_environment_keys??{}),...Object.keys(e.provenance_resolvers??{})]);return Object.freeze({contract_version:1,adapter_version:"v1",priority:0,harness:e.harness,descriptor:e,supported_dimensions:Object.freeze([...r].sort()),native_sources:Object.freeze(["environment","argv","mcp_client",...Object.values(e.provenance_resolvers??{}).some(n=>n?.endsWith("session_file"))?["session_file"]:[]]),probe_policy:e.harness==="codex"?MS:zm,normalization:Object.freeze({model_family:"v1",effort:"v1",preserve_raw:!0}),confidence:"high",waivers:Object.freeze(Object.fromEntries(t.map(n=>[n,"Harness does not expose this dimension."])))})}var Um=Object.freeze(tc.filter(e=>e.harness!=="ci").map($S).sort((e,t)=>e.harness.localeCompare(t.harness))),xt=new Map,gr=new Map;function U(e){let t=typeof e=="string"?e.trim():void 0;return t&&t.length>0?t:void 0}function nt(e){return[...new Set((e??[]).slice(0,64).map(t=>t.trim()).filter(t=>t.length>0).map(t=>t.slice(0,128)))]}function ot(e){let t=e.harness.trim().toLowerCase();if(!Ya.test(t))throw new Error(`Invalid harness signal descriptor namespace: ${e.harness}`);return{harness:t,environment_keys:nt(e.environment_keys),model_environment_keys:nt(e.model_environment_keys),session_environment_keys:nt(e.session_environment_keys),provenance_environment_keys:Object.fromEntries(Object.entries(e.provenance_environment_keys??{}).slice(0,32).map(([r,n])=>[r.trim().toLowerCase().slice(0,64),nt(n)]).filter(([r])=>Ya.test(r))),provenance_resolvers:Object.fromEntries(Object.entries(e.provenance_resolvers??{}).slice(0,32).map(([r,n])=>[r.trim().toLowerCase().slice(0,64),n]).filter(r=>typeof r[0]=="string"&&Ya.test(r[0])&&(r[1]==="ai_agent_version"||r[1]==="claude_session_file"||r[1]==="codex_session_file"))),provenance_unavailable_dimensions:nt(e.provenance_unavailable_dimensions).map(r=>r.toLowerCase()),argv_markers:nt(e.argv_markers).map(r=>r.toLowerCase()),client_names:nt(e.client_names).map(r=>r.toLowerCase())}}var Hm=tc.map(ot);function jS(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Zo(e,t){return e.toLowerCase().slice(0,512).split(/[/\\\s:=]+/u).filter(r=>r.length>0).includes(t)||e.trim().toLowerCase()===t}function rc(e=[]){let t=new Map(tc.filter(o=>o.harness!=="ci").map(o=>[o.harness,ot(o)]));for(let{adapter:o}of xt.values())t.set(o.harness,ot(o.descriptor));let r=[...t.values(),...Hm.filter(o=>o.harness==="ci"),...[...gr.values()].map(o=>o.descriptor),...ei.getStore()?.descriptors??[],...e.map(ot)],n=new Set;for(let o of r){if(n.has(o.harness))throw new Error(`Harness signal descriptor collision for "${o.harness}"`);n.add(o.harness)}return r}function nc(e,t){for(let r of t??[]){let n=U(e[r]);if(n)return n.slice(0,256)}}function LS(e,t){if(t==="role"){let r=e.slice(0,8).map(n=>n.trim().toLowerCase()).find(n=>["claim","create","update","close","release","review"].includes(n));if(r==="review")return"reviewer";if(r)return"implementer"}}function qm(e,t){let r=t==="model"?["--model","--agent-model"]:[`--agent-${t}`],n=e.slice(0,8);for(let o=0;o<n.length;o+=1){let i=n[o].slice(0,512);if(r.includes(i))return U(n[o+1])?.slice(0,256);let s=r.find(a=>i.startsWith(`${a}=`));if(s)return U(i.slice(s.length+1))?.slice(0,256)}}var FS=new Set(["implementation","implementer","investigator","orchestrator","planner","release-operator","reviewer"]);function Rt(e,t){if(e!=="role"||t===void 0)return t;let r=t.trim().toLowerCase().replaceAll(/[_\s]+/gu,"-");return FS.has(r)?r:void 0}function Xa(e,t){return U(e?.[t])?.slice(0,256)}var zS=1048576,Za=4194304,Jo=new Map,Mm=Object.freeze({}),Ja=new Map,$m=Object.freeze({});function jm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function US(e){let t;try{t=JSON.parse(e)}catch{return $m}let r=jm(t);if(!r)return $m;let n=[{value:r,depth:0}],o=0,i,s;for(;n.length>0&&o<64;){let a=n.shift();if(o+=1,i??=U(a.value.model)?.slice(0,256),s??=U(a.value.version)?.slice(0,256),i&&s)break;if(!(a.depth>=4))for(let c of Object.values(a.value)){let d=jm(c);d&&n.push({value:d,depth:a.depth+1})}}return Object.freeze({model:i,version:s})}function Vm(e){try{return de.lstatSync(e).isFile()?"available":"missing"}catch(t){return ke(t)?"missing":"failed"}}function HS(e,t){let r;try{r=de.readdirSync(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).sort((o,i)=>o.name.localeCompare(i.name)).slice(0,512).map(o=>{let i=Nt.join(e,o.name,`${t}.jsonl`);return{candidate:i,status:Vm(i)}})}catch(o){return{status:ke(o)?"missing":"failed"}}let n=r.filter(({status:o})=>o==="available").map(({candidate:o})=>o);return n.length===0?{status:r.some(({status:o})=>o==="failed")?"failed":"missing"}:n.length>1?{status:"ambiguous"}:{status:"available",path:n[0]}}function Bm(e,t){let r=U(t.CLAUDE_CODE_SESSION_ID);if(!r||!/^[A-Za-z0-9_-]{1,128}$/u.test(r))return{status:"unavailable"};let n=Nt.resolve(e.cwd??process.cwd()).replaceAll(/[^A-Za-z0-9-]/gu,"-"),o=Nt.join(e.home_dir??Lm.homedir(),".claude","projects"),i=Nt.join(o,n,`${r}.jsonl`),s=U(e.session_file),a=s&&Nt.basename(s)===`${r}.jsonl`?s:void 0;for(let c of[a,i]){if(!c)continue;let d=Vm(c);if(d==="available")return{status:d,path:c};if(d==="failed")return{status:d}}return HS(o,r)}function qS(e,t,r){let n=Bm(t,r);if(n.status==="available")try{let o=de.openSync(n.path,de.constants.O_RDONLY|de.constants.O_NOFOLLOW);try{let i=de.fstatSync(o),s=`${n.path}\0${i.size}\0${i.mtimeMs}`,a=Ja.get(s);if(a)return a[e];let c=Math.min(i.size,zS),d=Math.min(c,Math.ceil(c/2)),l=Math.min(c-d,i.size-d),u=Buffer.alloc(d);de.readSync(o,u,0,d,0);let f=Buffer.alloc(l);l>0&&de.readSync(o,f,0,l,i.size-l);let m={},_=i.size<=c?Buffer.concat([u,f]).toString("utf8").split(`
42
+ `):[...u.toString("utf8").split(`
43
+ `).slice(0,4096),...f.toString("utf8").split(`
44
+ `).slice(-4096)];for(let w of _){if(w.length===0||w.length>262144)continue;let v=US(w);if(m.model??=v.model,m.version??=v.version,m.model&&m.version)break}let y=Object.freeze(m);return Ja.clear(),Ja.set(s,y),y[e]}finally{de.closeSync(o)}}catch{return}}function VS(e,t){let r=0,n=(o,i)=>{if(i>4||r>=512)return;let s;try{s=de.readdirSync(o,{withFileTypes:!0}).sort((a,c)=>c.name.localeCompare(a.name))}catch{return}for(let a of s){if(r+=1,r>512)return;let c=Nt.join(o,a.name);if(a.isFile()&&a.name.endsWith(`-${t}.jsonl`))return c;if(a.isDirectory()){let d=n(c,i+1);if(d)return d}}};return n(e,0)}function BS(e){if(e<=Za)return[{offset:0,length:e}];let t=Math.floor(Za/2);return[{offset:e-t,length:t},{offset:0,length:t}]}function WS(e,t){if(t.length===0||t.length>262144)return;let r;try{r=JSON.parse(t)}catch{return}if(typeof r!="object"||r===null||Array.isArray(r))return;let n=r;if(n.type!=="turn_context")return;let o=typeof n.payload=="object"&&n.payload!==null?n.payload:void 0;e.model??=U(o?.model)?.slice(0,256),e.effort??=U(o?.effort)?.slice(0,256)}function GS(e,t){let r={},n=4096;for(let o of BS(t)){let i=Buffer.alloc(o.length);de.readSync(e,i,0,o.length,o.offset);let s=i.toString("utf8").split(`
45
+ `).reverse().slice(0,n);n-=s.length;for(let a of s)if(WS(r,a),r.model&&r.effort)break;if(r.model&&r.effort||n<=0)break}return r}function KS(e,t,r){let n=U(r.CODEX_THREAD_ID);if(!n||!/^[A-Za-z0-9_-]{1,128}$/u.test(n))return;let o=Nt.join(t.home_dir??Lm.homedir(),".codex","sessions"),i=`${o}\0${n}`,s=Jo.get(i);if(s)return s[e];let a=VS(o,n);if(!a){Jo.set(i,Mm);return}try{let c=de.openSync(a,"r");try{let d=de.fstatSync(c).size,l=GS(c,d);return Jo.set(i,l),l[e]}finally{de.closeSync(c)}}catch{Jo.set(i,Mm);return}}function YS(e,t,r,n){let o=ei.getStore();if(!(t.probes_enabled!==!1&&o?.probesEnabled!==!1&&!["0","false","off"].includes(U(r.PM_AGENT_PROBES)?.toLowerCase()??"")))return;let i=n?.provenance_resolvers[e];if(i==="claude_session_file")return qS(e,t,r);if(i==="codex_session_file")return KS(e,t,r);if(i==="ai_agent_version"){let s=U(r.AI_AGENT);return!s||!n||!Zo(s,n.harness)?void 0:/(?:^|[@/\s])v?(\d+\.\d+(?:\.\d+)?(?:[-+][A-Za-z0-9.-]+)?)$/u.exec(s)?.[1]?.slice(0,256)}}function XS(e,t,r,n){if(e==="ai_agent_version"){let o=U(n.AI_AGENT);return o!==void 0&&Zo(o,t.harness)?"available":"unavailable"}return e==="codex_session_file"?U(n.CODEX_THREAD_ID)!==void 0?"available":"unavailable":Bm(r,n).status}function oc(e){return e||(Fm.getStore()??{env:process.env,argv:process.argv})}function JS(e,t,r,n){let o=e.environment_keys.some(a=>U(t[a])!==void 0),i=e.argv_markers.some(a=>r.some(c=>{let d=c.replaceAll("\\","/");return Zo(d.slice(d.lastIndexOf("/")+1),a)})),s=e.client_names.some(a=>n===a||Zo(n,a));return o||i||s}function ZS(e,t){if(!t)return;let r;if(e==="topic"&&(r=t.topic),e==="role"&&(r=t.role),!!r)return{value:r,source:"inferred",confidence:t.confidence,rule_version:t.rule_version,evidence:t.evidence}}function QS(e){let t=e.find(([r])=>r!==void 0);return t?.[0]?{value:t[0],source:t[1]}:void 0}function eO(e,t,r,n,o,i){let s=`PM_AGENT_${e.toUpperCase().replaceAll("-","_")}`,a=new Set([...ec,...Object.keys(n?.provenance_environment_keys??{})]),c,d,l;a.has(e)&&(c=Rt(e,U(r[s])?.slice(0,256)),l=Rt(e,qm(t.argv??[],e)),d=Rt(e,LS(t.argv??[],e)));let u={...n?.provenance_environment_keys,model:n?.model_environment_keys},f={...t.client_info?.provenance,model:t.client_info?.model},m=Xa(o?.provenance,e),_=Rt(e,nc(r,u[e])),y=Rt(e,Xa(f,e)),w=Rt(e,Xa(t.provenance,e)),v=YS(e,t,r,n);return QS([[c,"override"],[m,"session"],[l,"argv"],[_,"environment"],[y,"mcp_client"],[w,"host"],[v,"probe"]])??ZS(e,i)??(d?{value:d,source:"argv"}:void 0)}function tO(e,t){if(!(!e||!t))return PS("sha256").update(`pm-agent-instance:v1\0${e}\0${t}`).digest("hex").slice(0,24)}function rO(e,t,r,n,o){let i=Object.keys(r?.provenance_environment_keys??{}),s=new Set([...ec,...i,...Object.keys(r?.provenance_resolvers??{}),...Object.keys(e.provenance??{}),...Object.keys(e.client_info?.provenance??{}),...Object.keys(n?.provenance??{})]),a={};for(let c of s){let d=eO(c,e,t,r,n,o);d?a[c]=d:r&&(c!=="version"||r.provenance_unavailable_dimensions.includes(c))&&(a[c]=null)}return a}function MM(e){let t=e.map(ot),r=new Map(Hm.map(i=>[i.harness,i])),n=new Set;for(let i of t){if(n.has(i.harness)||r.has(i.harness))throw new Error(`Harness signal descriptor collision for "${i.harness}"`);let s=gr.get(i.harness);if(s&&!jS(s.descriptor,i))throw new Error(`Harness signal descriptor collision for "${i.harness}"`);n.add(i.harness)}for(let i of t){let s=gr.get(i.harness);gr.set(i.harness,{descriptor:i,registrations:(s?.registrations??0)+1})}let o=!0;return()=>{if(o){o=!1;for(let i of t){let s=gr.get(i.harness);!s||s.registrations<=1?gr.delete(i.harness):s.registrations-=1}}}}function nO(e){let t=ot(e.descriptor),r=e.harness.trim().toLowerCase();if(e.contract_version!==1)throw new Error(`Unsupported provenance adapter contract for "${r}": ${e.contract_version}`);if(t.harness!==r)throw new Error(`Provenance adapter harness "${r}" does not match descriptor "${t.harness}".`);let n=U(e.adapter_version)?.slice(0,64);if(!n)throw new Error(`Provenance adapter "${r}" requires a version.`);if(!Number.isSafeInteger(e.priority))throw new Error(`Provenance adapter "${r}" requires an integer priority.`);if(e.probe_policy.network_access!==!1||e.probe_policy.subprocess_access!==!1||e.probe_policy.max_bytes>Za||e.probe_policy.max_lines>4096)throw new Error(`Provenance adapter "${r}" exceeds the bounded local probe policy.`);return Object.freeze({...e,adapter_version:n,harness:r,descriptor:t,supported_dimensions:Object.freeze(nt(e.supported_dimensions).map(o=>o.toLowerCase()).sort()),native_sources:Object.freeze([...new Set(e.native_sources)]),probe_policy:Object.freeze({...e.probe_policy}),normalization:Object.freeze({...e.normalization}),...e.waivers?{waivers:Object.freeze(Object.fromEntries(Object.entries(e.waivers).slice(0,32).map(([o,i])=>[o.slice(0,64),i.slice(0,256)])))}:{}})}function $M(){let e=new Map(Um.map(t=>[t.harness,t]));for(let{adapter:t}of xt.values())e.set(t.harness,t);return Object.freeze([...e.values()].sort((t,r)=>t.harness.localeCompare(r.harness)))}function jM(e){let t=e.map(nO),r=new Map(Um.map(i=>[i.harness,i])),n=new Set;for(let i of t){if(n.has(i.harness))throw new Error(`Provenance adapter collision for "${i.harness}".`);let s=r.get(i.harness);if(s&&i.priority<=s.priority)throw new Error(`Provenance adapter override for "${i.harness}" requires priority greater than ${s.priority}.`);let a=xt.get(i.harness);if(a&&JSON.stringify(a.adapter)!==JSON.stringify(i))throw new Error(`Provenance adapter collision for "${i.harness}".`);n.add(i.harness)}for(let i of t){let s=xt.get(i.harness);xt.set(i.harness,{adapter:i,registrations:(s?.registrations??0)+1})}let o=!0;return()=>{if(o){o=!1;for(let i of t){let s=xt.get(i.harness);!s||s.registrations<=1?xt.delete(i.harness):s.registrations-=1}}}}function LM(e,t){let r=t.trim().slice(0,256),n=r.toLowerCase();if(e==="model"){let o=/^(gpt-\d+(?:\.\d+)?)/u.exec(n)?.[1];o&&(n=o)}else n=n.replaceAll(/[_\s-]+/gu,""),n={minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max",ultra:"ultra"}[n]??n;return{raw:r,normalized:n,vocabulary:"v1"}}function FM(e,t){return Fm.run(e,t)}function zM(e,t,r={}){let n=e.map(ot);return rc(n),ei.run({descriptors:n,probesEnabled:r.probesEnabled!==!1},t)}function ic(e){let t=oc(e),r=t.env??{},n=rc(t.descriptors),o=[...(t.argv??[]).slice(0,3),...t.process_labels??[]].slice(0,64).map(_=>_.slice(0,512)),i=t.client_info?.name.trim().toLowerCase()??"",s=n.find(_=>JS(_,r,o,i)),a=za(t,r),c=[nc(r,s?.session_environment_keys),U(t.client_info?.session)?.slice(0,256)].find(_=>_!==void 0),d=tO(s?.harness,c),l=Pm({cwd:t.cwd??process.cwd(),env:r,key:d}),u=rO(t,r,s,a,l),f=u.model,m=[["harness",s?.harness],["model",f?.value],["model_source",f?.source],["session",c],["instance",d],["provenance",Object.keys(u).length>0?u:void 0],["episode",a.episode]];return Object.fromEntries(m.filter(_=>_[1]!==void 0))}function oO(e){return e==="unavailable"?{status:"unavailable",reason:"harness_unavailable"}:e==="missing"?{status:"unavailable",reason:"resolver_input_missing"}:{status:"failed",reason:"resolver_failed"}}function iO(e,t,r,n,o,i,s){let a=r?.provenance_resolvers[e];if(t.provenance?.[e])return{status:"resolved",...a?{resolver:a}:{},rule_version:"v1"};if(s)return{status:"unavailable",reason:"invalid_value",rule_version:"v1"};if(a){if(!i)return{status:"unavailable",reason:"probes_disabled",resolver:a,rule_version:"v1"};let c=XS(a,r,n,o);return{...oO(c),resolver:a,rule_version:"v1"}}return{status:r?.provenance_unavailable_dimensions.includes(e)?"unavailable":"not_configured",reason:r?.provenance_unavailable_dimensions.includes(e)?"harness_unavailable":"resolver_not_configured",rule_version:"v1"}}function Wm(e){let t=oc(e),r=ic(t),n=rc(t.descriptors).find(d=>d.harness===r.harness),o=t.env??{},i=t.probes_enabled!==!1&&ei.getStore()?.probesEnabled!==!1&&!["0","false","off"].includes(U(o.PM_AGENT_PROBES)?.toLowerCase()??""),s=za(t,o),a=[o.PM_AGENT_ROLE,s.provenance?.role,nc(o,n?.provenance_environment_keys.role),t.client_info?.provenance?.role,t.provenance?.role,qm(t.argv??[],"role")].some(d=>{let l=U(d)?.slice(0,256);return l!==void 0&&Rt("role",l)===void 0}),c=Object.fromEntries(ec.map(d=>[d,iO(d,r,n,t,o,i,d==="role"&&a)]));return{...r,provenance_outcomes:c}}function UM(){return process.env.PM_AUTHOR}function HM(e){e===void 0?delete process.env.PM_AUTHOR:process.env.PM_AUTHOR=e}function qM(e){return ic(e).harness}function sO(e,t,r){let n=oc(r),o=ic(n);if(e!==void 0){let s=U(e);return s?{author:s,source:"asserted",...o}:{author:"unknown",source:"unknown",...o}}if(n.env?.PM_AUTHOR!==void 0){let s=U(n.env.PM_AUTHOR);return s?{author:s,source:"asserted",...o}:{author:"unknown",source:"unknown",...o}}let i=U(t);return i?{author:i,source:"configured",...o}:o.harness?{author:`harness:${o.harness}`,source:"detected",...o}:{author:"unknown",source:"unknown",...o}}function Gm(e){let t=Qo.getStore();return t?.author===e?t.source:e.startsWith("harness:")?"detected":e==="unknown"?"unknown":"asserted"}function Km(e){let t=Qo.getStore();return t?.author!==e?e.startsWith("harness:")?{harness:e.slice(8)}:{}:{...t.harness?{harness:t.harness}:{},...t.model?{model:t.model}:{},...t.model_source?{model_source:t.model_source}:{},...t.session?{session:t.session}:{},...t.instance?{instance:t.instance}:{},...t.provenance?{provenance:t.provenance}:{},...t.episode?{episode:t.episode}:{}}}function VM(e){let t=Qo.getStore();return t?.author===e&&t.source==="detected"&&t.instance?`${e}#${t.instance}`:e}function Ym(e,t){let r=sO(e,t);return Qo.enterWith(r),r.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]="cfedb84f-0525-5e02-af0a-d0e5691b5e0a")}catch{}})();async function aO(e,t){let r=await ge(e);if(r===null)return{raw:r,entries:[]};if(await er({path:e,scope:"project"}),r.trim()==="")return{raw:r,entries:[]};let n=Wo(r);if(n)throw new g(`History for ${t} contains merge conflict markers at line ${n.line} (${n.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,h.GENERIC_FAILURE,{code:"history_merge_conflict_markers_detected",required:"Repair the history stream by resolving merge-conflict markers.",why:"Conflict markers break JSONL parsing and invalidate deterministic audit history.",examples:[`pm history ${t}`,`pm restore ${t} <timestamp-or-version>`],nextSteps:["Resolve or restore the history file, then rerun the command."]});let o=[];for(let[i,s]of r.split(/\r?\n/).entries()){let a=s.trim();if(a)try{o.push(JSON.parse(a))}catch{throw new g(`History for ${t} contains invalid JSON at line ${i+1}. Repair or restore the history stream and retry.`,h.GENERIC_FAILURE,{code:"history_json_invalid",nextSteps:[`Run pm history-repair ${t} --salvage-tail --dry-run to check whether only an invalid suffix is damaged.`]})}}return{raw:r,entries:o}}async function Fe(e,t){return(await aO(e,t)).entries}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3c2c29c0-0034-54d4-9dbd-2e9af047784e")}catch{}})();var ZM=1,cO=["docs_add","files_add","history:author-acknowledge","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","normalize","release","test_run_track","tests_add","tests_remove","tests_update","update_audit","update_ownership_bypass"],dO=["append","cancel","claim","close","comment_add","create","learning_add","note_add","reopen"],lO=new Set(cO),uO=new Set(dO),fO=new Set(["actual_result","affected_version","assignee","blocked_by","blocked_reason","close_reason","confidence","customer_impact","definition_of_ready","dependencies","docs","environment","expected_result","files","fixed_version","goal","impact","learnings","notes","objective","order","outcome","parent","release","reminders","reporter","repro_steps","resolution","reviewer","severity","sprint","tests","test_runs","unblock_note","updated_at","value","why_now"]);function mO(e){let t=e.path.split("/").filter(Boolean);return t[0]==="metadata"||t[0]==="front_matter"?t[1]:t[0]==="body"?"body":void 0}function br(e){return e.event_class==="substantive"||e.event_class==="maintenance"?e.event_class:lO.has(e.op)?"maintenance":uO.has(e.op)||e.op!=="update"?"substantive":Array.isArray(e.patch)&&e.patch.length>0&&e.patch.every(t=>{let r=mO(t);return r!==void 0&&fO.has(r)})?"maintenance":"substantive"}import Op from"fast-json-patch";import vp from"node:fs/promises";import zO from"node:path";import j from"node:fs/promises";import V from"node:path";import{randomUUID as dc}from"node:crypto";import{createRequire as pO}from"node:module";import{setImmediate as Zm}from"node:timers/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="812b558d-59f3-58d6-b04e-6a4f8689e866")}catch{}})();function Xm(e){let t=process.emitWarning;process.emitWarning=(r,...n)=>{r==="SQLite is an experimental feature and might change at any time"&&n[0]==="ExperimentalWarning"||Reflect.apply(t,process,[r,...n])};try{return e(["node","sqlite"].join(":")).DatabaseSync??null}catch{return null}finally{process.emitWarning=t}}function Jm(e,t){let r=Number.parseInt(e,10);return Number.isFinite(r)&&r>=22?Xm(t):null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="641c311a-5de1-579a-ba44-b9a49978dfe0")}catch{}})();var _O="history-event-index.sqlite",lc="6",yO=8,sp="history-event-index",hO="history-event-index:append:",gO=5e3,uc=300,ap=3e4,bO="history-event-index-invalidation",wO="history-event-index-invalidations",vO=uc*2*1e3,it=Symbol("history-index-changed"),Dt=new Map;function Pt(e){return V.join(e,"runtime",_O)}function cp(e){return V.join(e,"runtime","history-event-index-repair-deferred")}async function dp(e){try{let t=Number(await j.readFile(cp(e),"utf8")),r=Date.now()-t;return r>=0&&r<gO}catch{return!1}}async function Qm(e){try{await j.writeFile(cp(e),`${Date.now()}
46
+ `)}catch{}}function kn(e){return V.join(e,"runtime",wO)}async function ni(e){let t=await j.readdir(kn(e)).catch(r=>{if(le(r))return[];throw r});return{pending:t.filter(r=>r.endsWith(".pending")).sort(),committed:t.filter(r=>r.endsWith(".committed")).sort()}}async function ep(e){let t=await ni(e);return{pending:(await Promise.all(t.pending.map(async r=>{let n=/^(\d+)-(unknown|\d+)-(\d+)-.+\.pending$/u.exec(r);if(n!==null){let o=n[2];if(await ta({pid:Number(n[1]),...o==="unknown"?{}:{process_start_identity:o}},Math.max(0,Date.now()-Number(n[3])),vO))return r}return await j.rm(V.join(kn(e),r),{force:!0}),null}))).filter(r=>r!==null),committed:t.committed}}async function ac(e,t,r=ap){let n=await ae(e,bO,uc,`history-event-index-invalidation:${process.pid}`,!1,!1,r,r===0?{maxWaitMs:0}:void 0);try{return await t()}finally{await n()}}async function EO(e){let t=kn(e);await j.mkdir(t,{recursive:!0});let r=dc(),n=await ea(),o=V.join(t,`${n.pid}-${n.process_start_identity??"unknown"}-${Date.now()}-${r}.pending`);return await j.writeFile(o,`pending
47
+ `,{flag:"wx"}),{pendingPath:o,committedPath:V.join(t,`${r}.committed`)}}function kO(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}async function oi(e){try{await j.rm(Pt(e),{force:!0})}catch{}}async function tp(e,t){let r=kn(e);await j.mkdir(r,{recursive:!0}),await j.writeFile(V.join(r,`${dc()}${t?".contended":""}.committed`),`committed
48
+ `,{flag:"wx"}),t||await oi(e)}function ii(e){return e.committed.some(t=>t.endsWith(".contended.committed"))}function cc(e,t){let r;try{return r=new t(Pt(e)),r.exec("PRAGMA busy_timeout = 0"),r.exec("BEGIN EXCLUSIVE"),!1}catch(n){return wr(n)}finally{r?.close()}}async function rp(e,t){return t.pending.length>0||await uf(e,sp,hO)}async function lp(e,t,r=ap,n="rebuild"){let o=await ae(e,sp,uc,`history-event-index:${n}:${process.pid}`,!1,!1,r,r===0?{maxWaitMs:0}:void 0);try{return await t()}finally{await o()}}async function up(e){let t=V.join(e,"history"),r=await j.readdir(t,{withFileTypes:!0}).catch(s=>{if(typeof s=="object"&&s!==null&&"code"in s&&s.code==="ENOENT")return[];throw s}),n=Dt.get(e)??{streams:new Map,ordered_events:[]},o=new Set,i=!Dt.has(e);for(let s of r.filter(a=>a.isFile()&&a.name.endsWith(".jsonl")).sort((a,c)=>a.name.localeCompare(c.name))){let a=s.name.slice(0,-6);o.add(a);let c=V.join(t,s.name),d=await j.stat(c,{bigint:!0}),l=[d.dev,d.ino,d.size,d.mtimeNs,d.ctimeNs].join(":");if(n.streams.get(a)?.signature===l)continue;let u=await fp(c,a);n.streams.set(a,{signature:l,byte_size:Number(d.size),events:u.map((f,m)=>({stream_id:a,stream_offset:m,entry:f}))}),i=!0}for(let s of n.streams.keys())o.has(s)||(n.streams.delete(s),i=!0);if(i&&(n.ordered_events=[...n.streams.values()].flatMap(s=>s.events).sort(fc)),Dt.delete(e),Dt.set(e,n),Dt.size>yO){let s=Dt.keys().next().value;Dt.delete(s)}return{events:n.ordered_events,stream_byte_sizes:new Map([...n.streams].map(([s,a])=>[s,a.byte_size]))}}async function fp(e,t){let r=await Fe(e,t);for(let[n,o]of r.entries())if(typeof o.ts!="string"||!cr(o.ts.trim()))throw new g(`History for ${t} contains an invalid or sub-millisecond timestamp at line ${n+1}. Repair or restore the history stream and retry.`,h.GENERIC_FAILURE,{code:"history_timestamp_invalid"});return r.map(n=>({...n,ts:new Date(n.ts.trim()).toISOString()}))}async function SO(e){return(await up(e)).events}var sc;function ai(){return sc!==void 0||(sc=Jm(process.versions.node,pO(import.meta.url))),sc}function OO(e){e.exec(`
49
+ PRAGMA journal_mode = OFF;
50
+ PRAGMA synchronous = OFF;
51
+ CREATE TABLE metadata (
52
+ key TEXT PRIMARY KEY,
53
+ value TEXT NOT NULL
54
+ ) STRICT;
55
+ CREATE TABLE events (
56
+ stream_id TEXT NOT NULL,
57
+ stream_offset INTEGER NOT NULL,
58
+ ts TEXT NOT NULL,
59
+ author TEXT NOT NULL,
60
+ agent_harness TEXT,
61
+ agent_instance TEXT,
62
+ op TEXT NOT NULL,
63
+ event_class TEXT NOT NULL CHECK(event_class IN ('substantive', 'maintenance')),
64
+ entry_json TEXT NOT NULL,
65
+ PRIMARY KEY(stream_id, stream_offset)
66
+ ) STRICT;
67
+ CREATE TABLE streams (
68
+ stream_id TEXT PRIMARY KEY,
69
+ byte_size INTEGER NOT NULL CHECK(byte_size >= 0)
70
+ ) STRICT;
71
+ CREATE INDEX events_order
72
+ ON events(ts, stream_id, stream_offset);
73
+ CREATE INDEX events_op_order
74
+ ON events(op, ts, stream_id, stream_offset);
75
+ CREATE INDEX events_class_stream_order
76
+ ON events(event_class, stream_id, ts, stream_offset);
77
+ CREATE INDEX events_author_order
78
+ ON events(author, ts, stream_id, stream_offset);
79
+ CREATE INDEX events_harness_order
80
+ ON events(agent_harness, ts, stream_id, stream_offset);
81
+ CREATE INDEX events_instance_order
82
+ ON events(agent_instance, ts, stream_id, stream_offset);
83
+ `),e.prepare("INSERT INTO metadata(key, value) VALUES ('version', ?)").run(lc)}function mp(e,t){let r={...t.entry,ts:new Date(t.entry.ts.trim()).toISOString()};e.prepare(`INSERT INTO events(
84
+ stream_id, stream_offset, ts, author, agent_harness,
85
+ agent_instance, op, event_class, entry_json
86
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(t.stream_id,t.stream_offset,r.ts,r.author,r.agent_harness??null,r.agent_instance??null,r.op,br(r),JSON.stringify(r))}function pp(e){let t=JSON.parse(String(e.entry_json));return typeof t.ts!="string"||!cr(t.ts.trim())?null:{stream_id:String(e.stream_id),stream_offset:Number(e.stream_offset),entry:{...t,ts:new Date(t.ts.trim()).toISOString()}}}function _p(e,t,r){e.prepare(`INSERT INTO streams(stream_id, byte_size) VALUES (?, ?)
87
+ ON CONFLICT(stream_id) DO UPDATE SET byte_size = excluded.byte_size`).run(t,r)}async function AO(e,t={}){let r=ai();return r?lp(e,async()=>{let n;try{n=await ac(e,()=>ep(e),t.lockWaitMs)}catch(a){if(a instanceof g&&a.code==="lock_conflict")return!1;throw a}if(n.pending.length>0||ii(n)&&cc(e,r))return!1;let o=Pt(e);await j.mkdir(V.dirname(o),{recursive:!0});let i=`${o}.${dc()}.tmp`,s;try{s=new r(i),OO(s),s.exec("BEGIN IMMEDIATE");let a=await up(e);await IO(s,a),s.exec("COMMIT"),s.close(),s=void 0;let c=await ac(e,async()=>{let d=await ep(e);return d.pending.length>0||!kO(n.committed,d.committed)||ii(d)&&cc(e,r)?!1:(await j.rm(o,{force:!0}),await j.rename(i,o),!0)},t.lockWaitMs);return c&&await Promise.all(n.committed.map(d=>j.rm(V.join(kn(e),d),{force:!0}))),c||(await Qm(e),await j.rm(i,{force:!0})),c}catch(a){throw await Qm(e),s?.close(),await j.rm(i,{force:!0}),a}},t.lockWaitMs):!1}async function IO(e,t){let r=0;for(let n of t.events)mp(e,n),++r%500===0&&await Zm();for(let[n,o]of t.stream_byte_sizes)_p(e,n,o),++r%500===0&&await Zm()}function ti(e,t){return!t||t.length===0||t.includes(e)}function fc(e,t){return e.entry.ts.localeCompare(t.entry.ts)||e.stream_id.localeCompare(t.stream_id)||e.stream_offset-t.stream_offset}function si(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():e}function TO(e,t){if(t.after_ts!==void 0&&t.after_stream_id!==void 0&&t.after_stream_offset!==void 0){if(fc(e,{stream_id:t.after_stream_id,stream_offset:t.after_stream_offset,entry:{...e.entry,ts:si(t.after_ts)}})<=0)return!1}else if(t.since_ts!==void 0&&e.entry.ts<si(t.since_ts))return!1;return!0}function CO(e,t){return!t.harnesses||t.harnesses.length===0||t.harnesses.includes(e.entry.agent_harness??"")?!0:e.entry.agent_harness===void 0&&(t.harness_alias_authors??[]).includes(e.entry.author)}function RO(e,t){return!TO(e,t)||!ti(e.entry.op,t.ops)||!ti(e.entry.author,t.authors)||!ti(e.entry.agent_instance??"",t.agent_instances)||!ti(e.stream_id,t.stream_ids)||!CO(e,t)?!1:(t.provenance??[]).every(r=>{let n=e.entry.agent_provenance?.[r.dimension]?.value;return n!==void 0&&r.values.includes(n)})}async function p$(e,t){let r=Math.max(0,Math.floor(t.limit)),n=(await SO(e)).filter(o=>RO(o,t)).slice(0,r+1);return{events:n.slice(0,t.limit),has_more:n.length>t.limit}}async function xO(e,t){let r=e.prepare("SELECT byte_size FROM streams WHERE stream_id = ?").get(V.basename(t,".jsonl")),n=0;try{n=(await j.stat(t)).size}catch(o){if(!le(o))throw o}return Number(r?.byte_size??0)===n}async function yp(e,t,r){let n=V.dirname(V.dirname(e)),o=ai(),i=!1,s=async()=>{await r(),i=!0};if(!o){await np(n,s);return}try{await lp(n,async()=>{let a=Pt(n);try{await j.access(a)}catch{await s();return}let c;try{if(c=new o(a),c.prepare("SELECT value FROM metadata WHERE key = 'version'").get()?.value!==lc)throw new TypeError("Unsupported history event index version");if(!await xO(c,e))throw new TypeError("Stale history event index append base")}catch(l){if(c?.close(),wr(l))throw l;await tp(n,!0),await s();return}try{c.exec("PRAGMA busy_timeout = 0"),c.exec("BEGIN IMMEDIATE")}catch(l){throw c.close(),l}let d=!1;try{await s(),d=!0;let l=V.basename(e,".jsonl"),u=c.prepare("SELECT COALESCE(MAX(stream_offset), -1) + 1 AS value FROM events WHERE stream_id = ?").get(l);mp(c,{stream_id:l,stream_offset:Number(u.value),entry:t}),_p(c,l,(await j.stat(e)).size),c.exec("COMMIT"),c.close()}catch(l){if(c?.close(),!d)throw l;await tp(n,wr(l))}},0,"append")}catch(a){if(i){await oi(n);return}if(!DO(a))throw a;await np(n,s,wr(a))}}async function np(e,t,r=!1){let n=!1,o;try{await ac(e,async()=>{let i=r||ii(await ni(e)),s=await EO(e);o=s.pendingPath;try{await t(),n=!0}catch(a){throw await j.rm(s.pendingPath,{force:!0}),a}await j.rename(s.pendingPath,i?s.committedPath.replace(/\.committed$/u,".contended.committed"):s.committedPath),i||await oi(e)})}catch(i){if(n){await oi(e);try{await j.rm(o,{force:!0})}catch{}return}throw i}}async function mc(e){await j.rm(Pt(V.dirname(V.dirname(e))),{force:!0})}function ri(e,t,r,n){!n||n.length===0||(e.push(`${r} IN (${n.map(()=>"?").join(", ")})`),t.push(...n))}function NO(e,t,r,n){if(!r||r.length===0)return;let o=r.map(()=>"?").join(", "),i=n??[];if(i.length>0){e.push(`(agent_harness IN (${o}) OR (agent_harness IS NULL AND author IN (${i.map(()=>"?").join(", ")})))`),t.push(...r,...i);return}e.push(`agent_harness IN (${o})`),t.push(...r)}async function hp(e,t,r,n){let o;try{let i=await ni(e);if(await rp(e,i))return it;let s=await op(e);if(i.committed.length>0)return ii(i)&&cc(e,t)?it:null;if(o=new t(Pt(e),{readOnly:!0}),o.exec("BEGIN"),o.prepare("SELECT value FROM metadata WHERE key = 'version'").get()?.value!==lc)return null;let a=n(o);if(a===null)return null;let c=PO(o,r),d=o;o=void 0,d.close();let l=await jO([...c.keys()],e,r),u=await $O(c,e,l),f=await ni(e);return f.committed.length>0||await rp(e,f)||s!==await op(e)?it:u?a:null}catch(i){return wr(i)?it:null}finally{o?.close()}}function wr(e){return typeof e=="object"&&e!==null&&"errcode"in e&&[5,6].includes(e.errcode)}function DO(e){return wr(e)||e instanceof g&&e.code==="lock_conflict"}function PO(e,t){let r=new Map,n=t&&t.length>0?[...new Set(t)]:void 0;if(n===void 0)for(let o of e.prepare("SELECT stream_id, byte_size FROM streams").all())r.set(String(o.stream_id),Number(o.byte_size));else for(let o=0;o<n.length;o+=500){let i=n.slice(o,o+500);for(let s of e.prepare(`SELECT stream_id, byte_size FROM streams WHERE stream_id IN (${i.map(()=>"?").join(", ")})`).all(...i))r.set(String(s.stream_id),Number(s.byte_size))}return r}async function op(e){let t=await j.stat(Pt(e),{bigint:!0});return[t.dev,t.ino,t.size,t.mtimeNs,t.ctimeNs].join(":")}async function _$(e,t){let r=ai();if(!r)return{result:null,repair_needed:!1};let n=[],o=[];if(t.after_ts!==void 0&&t.after_stream_id!==void 0&&t.after_stream_offset!==void 0){n.push("(ts > ? OR (ts = ? AND stream_id > ?) OR (ts = ? AND stream_id = ? AND stream_offset > ?))");let a=si(t.after_ts);o.push(a,a,t.after_stream_id,a,t.after_stream_id,t.after_stream_offset)}else t.since_ts!==void 0&&(n.push("ts >= ?"),o.push(si(t.since_ts)));ri(n,o,"op",t.ops),ri(n,o,"author",t.authors),NO(n,o,t.harnesses,t.harness_alias_authors),ri(n,o,"agent_instance",t.agent_instances);for(let a of t.provenance??[])n.push(`json_extract(entry_json, '$.agent_provenance.${a.dimension}.value') IN (${a.values.map(()=>"?").join(", ")})`),o.push(...a.values);ri(n,o,"stream_id",t.stream_ids);let i=n.length===0?"":` WHERE ${n.join(" AND ")}`,s=await hp(e,r,t.stream_ids,a=>{let c=a.prepare(`SELECT stream_id, stream_offset, entry_json
88
+ FROM events${i}
89
+ ORDER BY ts, stream_id, stream_offset
90
+ LIMIT ?`).all(...o,Math.max(0,Math.floor(t.limit))+1),d=c.slice(0,t.limit).map(pp);return d.includes(null)?null:{events:d,has_more:c.length>t.limit}});return{result:s===it?null:s,repair_needed:s===null&&!await dp(e)}}function gp(e,t){let r=Object.create(null);for(let n of e){if(!t.has(n.stream_id)||br(n.entry)!=="substantive")continue;let o=r[n.stream_id];(o===void 0||fc(o,n)<0)&&(r[n.stream_id]=n)}return r}async function MO(e,t){if(V.basename(t)!==t)return null;try{return(await j.stat(V.join(e,"history",`${t}.jsonl`))).size}catch(r){if(le(r))return 0;throw r}}async function $O(e,t,r){for(let n=0;n<r.length;n+=500){let o=r.slice(n,n+500),i=await Promise.all(o.map(s=>MO(t,s)));for(let[s,a]of i.entries()){if(a===null)return!1;let c=o[s],d=e.get(c);if(!(a===0&&d===void 0)&&a!==d)return!1}}return!0}async function jO(e,t,r){if(r&&r.length>0)return[...new Set(r.filter(o=>o.trim().length>0))];let n=await j.readdir(V.join(t,"history"),{withFileTypes:!0}).then(o=>o.filter(i=>i.isFile()&&i.name.endsWith(".jsonl")).map(i=>i.name.slice(0,-6))).catch(o=>{if(le(o))return[];throw o});return[...new Set([...e,...n])]}async function ip(e,t,r,n){return e?hp(t,e,r,o=>{let i=[];for(let s=0;s<r.length;s+=500){let a=r.slice(s,s+500),c=o.prepare(`SELECT stream_id, stream_offset, entry_json
91
+ FROM (
92
+ SELECT stream_id, stream_offset, entry_json,
93
+ ROW_NUMBER() OVER (
94
+ PARTITION BY stream_id
95
+ ORDER BY ts DESC, stream_offset DESC
96
+ ) AS recency_rank
97
+ FROM events
98
+ WHERE event_class = 'substantive'
99
+ AND stream_id IN (${a.map(()=>"?").join(", ")})
100
+ )
101
+ WHERE recency_rank = 1`).all(...a).map(pp);if(c.includes(null))return null;i.push(...c)}return gp(i,n)}):null}async function y$(e,t){let r=[...new Set(t.filter(a=>a.trim().length>0&&V.basename(a)===a))];if(r.length===0)return{};let n=new Set(r),o=ai(),i=await ip(o,e,r,n);if(i!==null&&i!==it)return i;if(o&&i!==it&&!await dp(e))try{if(await AO(e,{lockWaitMs:0})){let a=await ip(o,e,r,n);if(a!==null&&a!==it)return a}}catch{}let s=[];return await Promise.all(r.map(async a=>{let c=V.join(e,"history",`${a}.jsonl`);(await fp(c,a).catch(d=>{if(d instanceof g&&d.code==="history_timestamp_invalid")return[];throw d})).forEach((d,l)=>{s.push({stream_id:a,stream_offset:l,entry:d})})})),gp(s,n)}import pc from"node:fs/promises";import vr 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]="687cbe24-6d5c-5322-962d-455048eb84b5")}catch{}})();var LO=vr.join("runtime","history-drift-cache.json"),bp={EINVAL:"invalid_cache_path",EISDIR:"cache_path_is_directory",ENOENT:"invalid_cache_path",ENOTDIR:"invalid_cache_path",ERR_FS_EISDIR:"cache_path_is_directory"};function wp(e){return typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"?e.code:void 0}async function FO(e){let t=vr.join(e,LO),r=!1,n="invalid_cache_path";try{r=(await pc.stat(await pc.realpath(e))).isDirectory()}catch(o){let i=wp(o);n=i===void 0?"unknown":bp[i]??"filesystem_error"}if(!r){_n(`[pm] warning: history_drift_cache_invalidation_failed:${n}
102
+ `);return}try{await pc.rm(t,{force:!0})}catch(o){let i=wp(o);if(le(o))return;let s=i===void 0?"unknown":bp[i]??"filesystem_error";_n(`[pm] warning: history_drift_cache_invalidation_failed:${s}
103
+ `)}}async function ci(e){let t=vr.dirname(vr.resolve(e));vr.basename(t)==="history"&&await FO(vr.dirname(t))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4a3c3c82-0398-549c-8910-fdc69d971cb2")}catch{}})();var UO={front_matter:{},body:""},Mt=3,Sn=[1,2,3],HO=1,qO=[1];function Ap(e){return et(R(e),e.hash_algorithm)}function Er(e){return Zn(R(e))}function z$(e){return Zn(R(e))}function gc(e){let t={...e,record_hash_version:HO},{record_hash:r,...n}=t;return{...t,record_hash:Ap(n)}}function ui(e){try{It(e.hash_algorithm)}catch{return{ok:!1,error:"unsupported_history_hash_algorithm"}}if(e.record_hash_version===void 0&&e.record_hash===void 0)return{ok:!0,coverage:"item_state_only"};if(e.record_hash_version===void 0||e.record_hash===void 0)return{ok:!1,error:"incomplete_record_hash_envelope"};if(!qO.includes(e.record_hash_version))return{ok:!1,error:"unsupported_record_hash_version"};let{record_hash:t,...r}=e;return Ap(r)===e.record_hash?{ok:!0,coverage:"record_and_item_state"}:{ok:!1,error:"record_hash_mismatch"}}function VO(e,t){let r={before_hash:e.before_hash,after_hash:e.after_hash,patch_hash:Er(e.patch)};return e.hash_algorithm!==void 0&&(r.hash_algorithm=e.hash_algorithm),e.item_hash_version!==void 0&&(r.item_hash_version=e.item_hash_version),t.retainOriginalPatch&&(r.patch=structuredClone(e.patch)),t.retainPriorRecordHash!==!1&&e.record_hash_version!==void 0&&e.record_hash!==void 0&&(r.record_hash_version=e.record_hash_version,r.record_hash=e.record_hash,r.record=structuredClone(e)),r}function Ip(e,t,r={}){let n=ui(e);if(!n.ok)throw new TypeError(n.error);let o=Er(e.patch),i=r.retainPriorRecord===!0||e.before_hash!==t.before_hash||e.after_hash!==t.after_hash||e.item_hash_version!==t.item_hash_version||e.hash_algorithm!==t.hash_algorithm||o!==Er(t.patch),s=gc({...t,...i?{reanchor_evidence:[...t.reanchor_evidence??[],VO(e,r)]}:{}}),a=bc(s);if(!a.ok)throw new TypeError(a.error);return s}function Tp(e){return!Array.isArray(e)||Object.keys(e).length!==e.length?!1:e.every(t=>!$t(t)||typeof t.path!="string"?!1:t.op==="move"||t.op==="copy"?typeof t.from=="string":["add","replace","test"].includes(t.op)?Object.hasOwn(t,"value"):t.op==="remove")}function BO(e){return $t(e)&&typeof e.ts=="string"&&typeof e.author=="string"&&typeof e.op=="string"&&typeof e.before_hash=="string"&&typeof e.after_hash=="string"&&Tp(e.patch)}function WO(e){let t=e.record_hash_version!==void 0,r=e.record_hash!==void 0;return t===r}function GO(e){return!$t(e)||!WO(e)||typeof e.before_hash!="string"||typeof e.after_hash!="string"||typeof e.patch_hash!="string"||!/^[a-f0-9]{64}$/u.test(e.patch_hash)||e.patch!==void 0&&!Tp(e.patch)||e.record_hash_version!==void 0&&typeof e.record_hash_version!="number"||e.record_hash!==void 0&&(typeof e.record_hash!="string"||!/^(?:[a-f0-9]{64}|[a-f0-9]{128})$/u.test(e.record_hash))?!1:e.record===void 0||BO(e.record)}function KO(e){try{for(let t of e){if(!GO(t))return!1;It(t.hash_algorithm)}return!0}catch{return!1}}function YO(e){let t=e.record;return t!==void 0&&t.before_hash===e.before_hash&&t.after_hash===e.after_hash&&t.item_hash_version===e.item_hash_version&&t.hash_algorithm===e.hash_algorithm&&t.record_hash_version===e.record_hash_version&&t.record_hash===e.record_hash&&Er(t.patch)===e.patch_hash}function XO(e,t,r){if(t.patch&&Er(t.patch)!==t.patch_hash)return{kind:"patch_hash_mismatch"};if(t.record)return YO(t)?{kind:"record",entry:t.record}:{kind:"record_hash_mismatch"};let n=t.patch??e.patch;if(Er(n)!==t.patch_hash)return{kind:"digest_only"};let o={...e,before_hash:t.before_hash,after_hash:t.after_hash,patch:n,hash_algorithm:t.hash_algorithm,...t.item_hash_version===void 0?{}:{item_hash_version:t.item_hash_version},...t.record_hash_version===void 0?{}:{record_hash_version:t.record_hash_version},...t.record_hash===void 0?{}:{record_hash:t.record_hash},...r.length===0?{}:{reanchor_evidence:r}};return t.hash_algorithm===void 0&&delete o.hash_algorithm,r.length===0&&delete o.reanchor_evidence,t.item_hash_version===void 0&&delete o.item_hash_version,t.record_hash_version===void 0||t.record_hash===void 0?{kind:"legacy",entry:o}:{kind:"record",entry:o}}function bc(e){let t=e.reanchor_evidence;if(t===void 0)return{ok:!0,coverage:"none"};if(!Array.isArray(t)||!KO(t))return{ok:!1,error:"rewrite_evidence_invalid"};if(t.length===0)return{ok:!0,coverage:"none"};let r=e;for(let n=t.length-1;n>=0;n-=1){let o=t[n],i=XO(r,o,t.slice(0,n));if(i.kind==="patch_hash_mismatch")return{ok:!1,error:"rewrite_evidence_patch_hash_mismatch"};if(i.kind==="record_hash_mismatch")return{ok:!1,error:"rewrite_evidence_record_hash_mismatch"};if(i.kind==="digest_only")return{ok:!0,coverage:"digest_only"};if(i.kind==="legacy")return{ok:!0,coverage:"legacy_anchor_only"};if(!ui(i.entry).ok)return{ok:!1,error:"rewrite_evidence_record_hash_mismatch"};r=i.entry}return{ok:!0,coverage:"complete"}}function di(e,t){return(e??"").localeCompare(t??"")}function Ep(e,t){return(e??0)-(t??0)}function st(e,t,r){return JSON.stringify(e??r).localeCompare(JSON.stringify(t??r))}function JO(e,t){return[e.scope.localeCompare(t.scope),di(e.path,t.path),di(e.command,t.command),Ep(e.timeout_seconds,t.timeout_seconds),di(e.pm_context_mode,t.pm_context_mode),+!!e.shared_host_safe-+!!t.shared_host_safe,st(e.env_clear,t.env_clear,[]),st(e.env_set,t.env_set,{}),st(e.assert_stdout_contains,t.assert_stdout_contains,[]),st(e.assert_stdout_regex,t.assert_stdout_regex,[]),st(e.assert_stderr_contains,t.assert_stderr_contains,[]),st(e.assert_stderr_regex,t.assert_stderr_regex,[]),Ep(e.assert_stdout_min_lines,t.assert_stdout_min_lines),st(e.assert_json_field_equals,t.assert_json_field_equals,{}),st(e.assert_json_field_gte,t.assert_json_field_gte,{}),di(e.note,t.note)].find(r=>r!==0)??0}function ZO(e){return!e||e==="/"?[]:e.startsWith("/")?e.slice(1).split("/").map(t=>t.replaceAll("~1","/").replaceAll("~0","~")):[]}function QO(e,t){let r=ZO(t);if(r.length===0)return!0;let n=e;for(let o of r){let i=/^(0|[1-9]\d*)$/.test(o)?Number(o):-1,s=Array.isArray(n)?i>=0&&i<n.length?n[i]:void 0:$t(n)&&Object.prototype.hasOwnProperty.call(n,o)?n[o]:void 0;if(s===void 0)return!1;n=s}return!0}function eA(e,t){let r=[],n=structuredClone(e);for(let o of t){let i=o.op==="replace"&&!QO(n,o.path)?{...o,op:"add"}:o;r.push(i),n=Op.applyPatch(n,[i],!0,!0).newDocument}return r}function li(e,t,r=!1){if(!(e.metadata&&Object.keys(e.metadata).length>0))return{front_matter:{},body:e.body??""};let n=yr(e),o=t===1||t===2&&r?{...n.metadata,...n.metadata.dependencies===void 0?{}:{dependencies:n.metadata.dependencies.map(s=>({...s,id:s.id.toLowerCase()}))},...n.metadata.tests===void 0?{}:{tests:n.metadata.tests.map(({workspace_context_mode:s,provenance:a,provenance_invalid:c,...d})=>d)},...n.metadata.test_runs===void 0?{}:{test_runs:n.metadata.test_runs.map(({executions:s,...a})=>a)}}:n.metadata,i=t===1&&o.tests?{...o,tests:[...o.tests].sort(JO)}:o;return{front_matter:A(i,ze),body:n.body}}function kp(e){if(!(e.metadata&&Object.keys(e.metadata).length>0))return{metadata:{},body:e.body??""};let t=yr(e);return{metadata:A(t.metadata,ze),body:t.body}}function U$(e){return Cp(e,Mt)}function Cp(e,t,r){if(!Sn.some(n=>n===t))throw new TypeError(`unsupported_item_hash_version:${String(t)}`);return et(R(li(e,t)),r)}function Rp(e,t,r){let n=Cp(e,t,r);return t===2?[n,et(R(li(e,t,!0)),r)]:[n]}function H$(){return Zn(R(UO))}function On(e){let t=Yf(e.op),r=li(e.before,Mt),n=li(e.after,Mt),o=kp(e.before),i=kp(e.after),s=Op.compare(o,i),a=eA(o,s),c=Km(e.author),d=c.harness?Object.fromEntries(Object.entries(Wm().provenance_outcomes).filter(([m,_])=>_.resolver!==void 0&&(_.status!=="resolved"||c.provenance?.[m]?.source==="probe"))):void 0,l=d===void 0||Object.keys(d).length===0?e.context:{...e.context,agent_provenance_outcomes:d},u=e.hashAlgorithm??Xf,f={hash_algorithm:u,ts:e.nowIso,author:e.author,author_source:e.authorSource??Gm(e.author),...c.harness?{agent_harness:c.harness}:{},...c.model?{agent_model:c.model}:{},...c.model_source?{agent_model_source:c.model_source}:{},...c.instance?{agent_instance:c.instance}:{},...c.provenance?{agent_provenance:c.provenance}:{},...c.episode?{agent_episode:c.episode}:{},op:t,patch:a,before_hash:et(R(r),u),after_hash:et(R(n),u),item_hash_version:Mt,message:e.message===void 0?void 0:e.message,...l===void 0?{}:{context:l}};return gc({...f,event_class:br(f)})}function $t(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _c(e){return new g(e,h.GENERIC_FAILURE,{code:"history_timestamp_invalid"})}function xp(e){let t=e.ts.trim();if(t.length===0)return Me();if(!cr(t))throw _c("History timestamp must be a valid RFC 3339 date-time with millisecond precision");if(t!==e.ts)throw _c("History timestamp must not contain surrounding whitespace");return e.ts}function Sp(e,t){let r=e.ts;if(typeof r=="string"&&r.trim().length>0){if(!cr(r))throw _c("History timestamp must be a valid RFC 3339 date-time with millisecond precision");return e}return{...e,ts:t}}function yc(e,t){let r=xp(t);if(typeof e=="string"){let n;try{n=JSON.parse(e)}catch{return e}return $t(n)?JSON.stringify(Sp(n,r)):e}return $t(e)?JSON.stringify(Sp(e,r)):JSON.stringify(e)}async function tA(e,t,r){if(r===!1)return!0;if(typeof r=="string"){let s=yc(r,t);return await hc(e,s),await ci(e),await mc(e),!0}if(typeof r!="object"||r===null)return!1;let n=r;if(n.skip===!0)return!0;let o=typeof n.history_path=="string"?n.history_path:e,i=yc(typeof n.line=="string"?n.line:n.entry??t,t);return await hc(o,i),await ci(o),await mc(o),!0}async function hc(e,t){let r;try{r=JSON.parse(t)}catch{r=null}if(!$t(r)||r.op!=="create"){await Kc(e,t);return}await vp.mkdir(zO.dirname(e),{recursive:!0});try{await vp.writeFile(e,`${t}
104
+ `,{encoding:"utf8",flag:"wx"})}catch(n){throw n.code!=="EEXIST"?n:new g("This item identity is reserved by an existing history stream.",h.CONFLICT,{code:"item_identity_reserved",required:"Choose a new item ID or restore the original item from its history.",nextSteps:["Run pm history <id> --full, then pm restore <id> <version> to recover the original item."]})}}async function An(e,t){let r=await tr("history_append",{history_path:e,entry:t});if(r.handled&&await tA(e,t,r.result))return;let n=t.ts.trim().length>0?t:{...t,ts:xp(t)},o=gc({...n,hash_algorithm:It(n.hash_algorithm),event_class:br(n)});await yp(e,o,async()=>{await hc(e,yc(o,o))}),await ci(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]="3bfeb8d2-52c2-587a-9611-c4d5817cb47e")}catch{}})();function Np(e){let t=[],r=e[0]?.op==="history_compact_baseline",n=r?1:void 0,o=!1;for(let[i,s]of e.entries())s.op==="delete"&&(o=!0),s.op==="create"&&(n!==void 0&&t.push({prior_genesis_index:n,repeated_create_index:i+1,sequence:o?"delete_then_create":r?"checkpoint_then_create":"multiple_creates"}),n??=i+1,o=!1);return t}import vc from"fast-json-patch";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0c0cb8c7-4d7d-53f8-8ec2-d6dc98fc6dc5")}catch{}})();var rA={metadata:{},body:""};function fi(){return structuredClone(rA)}function Q$(e,t=Mt,r){return wc(e,t,r)[0]}function wc(e,t,r){if(Object.keys(e.metadata).length===0||Array.isArray(e.metadata.tags))try{return Rp(mi(e),t,r)}catch{}let n=et(R({replay_fallback:!0,metadata:e.metadata,body:e.body}),r);return t===2?[n,n]:[n]}function Mp(e,t,r,n,o){let i=It(n.hash_algorithm),s=`${r}:${i}`,a=o?.before.get(s)??wc(e,r,i),c=wc(t,r,i);return o?.after.set(s,c),{beforeHashes:a,afterHashes:c,pairIndex:a.findIndex((d,l)=>d===n.before_hash&&c[l]===n.after_hash),beforeIndex:a.indexOf(n.before_hash),afterIndex:c.indexOf(n.after_hash)}}function mi(e){return{metadata:e.metadata,body:e.body}}function ej(e,t={}){return yr(mi(e),t)}function tj(e){if(!e.metadata||Object.keys(e.metadata).length===0)return{metadata:{},body:e.body??""};let t=yr(e);return{metadata:A(t.metadata,ze),body:t.body}}function Dp(e){return e==="/front_matter"?"/metadata":e.startsWith("/front_matter/")?`/metadata/${e.slice(14)}`:e}function nA(e){return typeof e=="object"&&e!==null&&typeof e.op=="string"&&typeof e.path=="string"}function $p(e){return Array.isArray(e)?e.filter(nA).map(t=>({...t,path:Dp(t.path),from:typeof t.from=="string"?Dp(t.from):void 0})):[]}function oA(e){return typeof e=="object"&&e!==null&&"metadata"in e&&"body"in e&&typeof e.body=="string"&&typeof e.metadata=="object"&&e.metadata!==null}function pi(e,t){try{let r=$p(t),n=vc.applyPatch(structuredClone(e),r,!0,!0).newDocument;return oA(n)?{ok:!0,document:{metadata:n.metadata,body:n.body}}:{ok:!1,error:new Error("history_replay_invalid_document_shape")}}catch(r){return{ok:!1,error:r}}}function iA(e){return[...new Set(e.map(t=>t.item_hash_version).filter(t=>t!==void 0&&Sn.includes(t)))]}function jp(e){return e!==void 0&&!Sn.includes(e)}function sA(e,t){return e!==void 0?[e]:t===void 0?[...Sn]:[t]}function Lp(e){let t=ui(e);if(!t.ok)return t.error;let r=bc(e);return r.ok?void 0:r.error}function aA(e,t){let r=Lp(e);if(r)return{ok:!1,error:r};let n=pi(t,e.patch);return n.ok?{ok:!0,document:n.document}:{ok:!1,error:"patch_apply_failed"}}function cA(e,t){let r=Lp(e);if(r)throw new TypeError(`${r}:entry_${t+1}`)}function dA(e,t,r,n,o){let i=[];for(let s of r){let a=Mp(e,t,s,n,o);if(i.push({version:s,match:a}),a.pairIndex>=0)break}return i}function Fp(e){let t=fi(),r=new Map,n,o,i=Np(e).map(s=>`verify_failed:duplicate_create:entry_${s.repeated_create_index}:prior_${s.prior_genesis_index}`);for(let s=0;s<e.length;s+=1){let a=e[s],c=a.item_hash_version,d=jp(c);d&&i.push(`verify_failed:unsupported_item_hash_version:${String(c)}:entry_${s+1}`);let l=aA(a,t);if(!l.ok)return{ok:!1,errors:[...i,`verify_failed:${l.error}:entry_${s+1}`]};if(d){t=l.document,r=new Map,n=void 0,o=void 0;continue}let u=sA(c,o),f={before:r,after:new Map},m=dA(t,l.document,u,a,f),_=m.find(({match:w})=>w.pairIndex>=0);if(_===void 0){let w=m.some(({match:v})=>v.beforeIndex>=0);return{ok:!1,errors:[...i,`verify_failed:${w?"after":"before"}_hash_mismatch:entry_${s+1}`]}}let y=_.version;t=l.document,r=f.after,n=y,o=c??o}return i.length>0?{ok:!1,errors:i,...n===void 0?{}:{item_hash_version:n}}:{ok:!0,errors:[],...n===void 0?{}:{item_hash_version:n}}}function jt(e){let t=Fp(e);return{ok:t.ok,errors:t.errors}}function Pp(e,t){try{return{ok:!0,document:vc.applyPatch(structuredClone(e),[t],!0,!1).newDocument}}catch{return{ok:!1}}}function lA(e,t){let r=structuredClone(e),n=0,o=0;for(let s of $p(t)){let a=Pp(r,s);if(a.ok){r=a.document;continue}if(s.op==="replace"){let c=Pp(r,{...s,op:"add"});if(c.ok){r=c.document,n+=1;continue}}o+=1}let i=r;return{document:{metadata:typeof i.metadata=="object"&&i.metadata!==null?i.metadata:{},body:typeof i.body=="string"?i.body:e.body},convertedReplaceToAdd:n,skippedOps:o}}function uA(e){let t=iA(e);if(t.length===1)return t[0];let r=Fp(e);return r.ok&&r.item_hash_version!==void 0?r.item_hash_version:t.length===0?1:Mt}function fA(e,t,r=t.patch){let n=pi(e,r);if(n.ok)return{next:n.document,patch:r,repaired:R(r)!==R(t.patch),converted:0,skipped:0};let o=lA(e,r);return{next:o.document,patch:vc.compare(e,o.document),repaired:!0,converted:o.convertedReplaceToAdd,skipped:o.skippedOps}}function mA(e,t,r){return fA(e,t,r.projectPatch?.(t,e))}function rj(e,t=uA(e),r={}){let n=e.findIndex(m=>jp(m.item_hash_version));if(n>=0)throw new TypeError(`unsupported_item_hash_version:${String(e[n]?.item_hash_version)}:entry_${n+1}`);let o=fi(),i=[],s=[],a=0,c=0,d=0,l=0,u,f=t!==1||e.some(m=>m.item_hash_version!==void 0);for(let m=0;m<e.length;m+=1){let _=e[m];cA(_,m);let y=mA(o,_,r),{next:w,patch:v,repaired:T,converted:K,skipped:ve}=y;d+=K,l+=ve,c+=Number(T);let Ee=Mp(o,w,t,_);u===void 0||r.continuousHashSurface!==!0?u=[Ee.pairIndex,Ee.beforeIndex,Ee.afterIndex,Math.min(u??0,Ee.beforeHashes.length-1)].find(I_=>I_>=0):u=Math.min(u,Ee.beforeHashes.length-1);let Fc=Ee.beforeHashes[u],zc=Ee.afterHashes[u],Ii=Fc!==_.before_hash||zc!==_.after_hash;Ii&&(a+=1);let Ut={..._,patch:v,before_hash:Fc,after_hash:zc};f?Ut.item_hash_version=t:delete Ut.item_hash_version;let A_=Ut.item_hash_version!==_.item_hash_version;(Ii||T||A_)&&(Ut=Ip(_,Ut,{retainOriginalPatch:T})),i.push(Ut),s.push({index:m+1,rehashed:Ii,patch_repaired:T,converted_replace_to_add:K,skipped_ops:ve}),o=w}return{entries:i,finalDocument:o,entriesRehashed:a,entriesPatchRepaired:c,convertedReplaceToAdd:d,skippedOps:l,details:s,itemHashVersion:t,explicitItemHashVersion:f}}function nj(e){return e.length===0?"":`${e.map(t=>JSON.stringify(t)).join(`
105
+ `)}
106
+ `}import zp from"node:fs/promises";import kr 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]="af606b47-d071-5724-b1e7-de4e1e5d7385")}catch{}})();var at="_workspace";function Lt(e){return kr.join(e,"history",`${at}.jsonl`)}function Ec(e,t){return{metadata:{id:at,title:"Workspace state",description:"Audited singleton workspace document state.",type:"Chore",status:"open",priority:2,tags:["workspace-history"],created_at:t,updated_at:t,documents:e},body:""}}function Ft(e,t=e.length){let r=fi();for(let n of e.slice(0,t))r=pi(r,n.patch).document;return mi(r)}function Sr(e){return"documents"in e.metadata&&typeof e.metadata.documents=="object"&&e.metadata.documents!==null&&!Array.isArray(e.metadata.documents)?e.metadata.documents:{}}function Or(e){throw new g(`Workspace history verification failed: ${e.join(", ")}`,h.CONFLICT,{code:"workspace_history_chain_invalid",reason:"workspace_history_chain_verification_failed",verification_errors:[...e],required:"Repair the _workspace history chain before reading, reconciling, restoring, or appending audited singleton state.",why:"Continuing against an unverifiable append-only stream could hide or compound workspace state corruption.",examples:["pm history _workspace --verify --json","pm validate --check-history-drift --fix-hints --json"],nextSteps:["Inspect the exact verification_errors and preserve the corrupt stream as evidence.","Use the history-drift remediation returned by validate before retrying the refused operation."],recovery:{recovery_mode:"compact",next_best_command:"pm history _workspace --verify --json"}})}function _i(e,t){let r=kr.resolve(t),n=kr.relative(e,r).replaceAll("\\","/");if(n.length===0||n===".."||n.startsWith("../")||kr.isAbsolute(n))throw new TypeError("Workspace history document path must stay inside the tracker root");return{documentPath:n,absolutePath:r}}async function yj(e){let t=await Fe(Lt(e),at),r=jt(t);r.ok||Or(r.errors);let n=Sr(t.length===0?Tr:Ft(t)),o=[],i=[],s=[],a=[];for(let c of Object.keys(n).sort()){let d;try{let l=_i(e,kr.resolve(e,c));if(d=await ge(l.absolutePath),d===null){s.push(c);continue}let u=JSON.parse(d);(R(u)===R(n[c])?o:i).push(c)}catch{a.push(c)}}return{ok:i.length===0&&s.length===0&&a.length===0,document_count:Object.keys(n).length,matching_documents:o,mismatched_documents:i,missing_documents:s,unreadable_documents:a}}async function Up(e){let t=Lt(e.pmRoot),r=await Fe(t,at),n=jt(r);n.ok||Or(n.errors);let o=e.idempotencyKey===void 0?void 0:r.find(u=>u.op===`${e.op}:${e.idempotencyKey}`);if(o)return{entry:o,historyPath:t};let i=Me(),s=r.length===0?Tr:Ft(r),a=Sr(s),c=a[e.documentPath];if(c!==void 0&&R(c)!==R(e.before))throw new g(`Workspace history state for "${e.documentPath}" changed outside the audited mutation path.`,h.CONFLICT,{code:"workspace_history_state_conflict",reason:"out_of_band_workspace_state",required:"Reconcile the singleton document with its matching _workspace history state before retrying the mutation.",why:"Accepting the write would make the append-only audit stream describe a state that was not actually observed.",examples:["pm history _workspace --verify","pm validate --check-history-drift --fix-hints"],nextSteps:["Review the version-control change that altered the singleton and preserve the intended document plus its matching workspace history.","Rerun the original mutation only after the on-disk singleton agrees with the latest audited workspace state."],recovery:{recovery_mode:"compact",next_best_command:"pm history _workspace --verify"}});let d=Ec({...a,[e.documentPath]:e.after},r.length===0?i:s.metadata.created_at),l=On({nowIso:i,author:e.author,op:e.idempotencyKey===void 0?e.op:`${e.op}:${e.idempotencyKey}`,before:s,after:d,message:e.message});return await An(t,l),{entry:l,historyPath:t}}async function hj(e){let t=await ae(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{return await Up(e)}finally{await t()}}async function gj(e){let t=await ae(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let r=Lt(e.pmRoot),n=await Fe(r,at),o=jt(n);o.ok||Or(o.errors);let i=n.length===0?Tr:Ft(n),s=On({nowIso:Me(),author:e.author,op:e.op,before:i,after:i,message:e.message,context:e.context});return await An(r,s),{entry:s,historyPath:r}}finally{await t()}}async function Hp(e,t){if(t===e.raw)return!1;let r=t===null?null:JSON.parse(t),n=JSON.parse(e.raw);await mt(e.filePath,e.raw);try{(t!==null||e.recordCreation!==!1)&&await Up({pmRoot:e.pmRoot,documentPath:kr.relative(e.pmRoot,e.filePath).replaceAll("\\","/"),before:r,after:n,op:e.op,idempotencyKey:e.idempotencyKey,author:e.author,lockTtlSeconds:e.lockTtlSeconds,lockWaitMs:e.lockWaitMs,message:e.message})}catch(o){throw t===null?await zp.rm(e.filePath,{force:!0}):await mt(e.filePath,t),o}return!0}async function qp(e){let{documentPath:t}=_i(e.pmRoot,e.filePath),r=await ae(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let n=await ge(e.filePath);if(e.dryRun===!0||e.idempotencyKey!==void 0){let i=await Fe(Lt(e.pmRoot),at),s=jt(i);s.ok||Or(s.errors);let a=Sr(i.length===0?Tr:Ft(i))[t];if(a!==void 0&&R(a)!==R(n===null?null:JSON.parse(n)))throw new g(`Workspace history state for "${t}" changed outside the audited mutation path.`,h.CONFLICT,{code:"workspace_history_state_conflict"});if(e.idempotencyKey!==void 0&&i.some(c=>c.op===`${e.op}:${e.idempotencyKey}`))return{changed:!1,result:void 0,replayed:!0}}let o=await e.mutate(n);return JSON.parse(o.raw),e.dryRun===!0?{changed:n!==o.raw,result:o.result}:{changed:await Hp({...e,raw:o.raw},n),result:o.result}}finally{await r()}}async function bj(e){let t=await ae(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{return await Hp(e,await ge(e.filePath))}finally{await t()}}async function wj(e){let t=e.authorizationDecision.trim();if(!t)throw new TypeError("Workspace history reconciliation requires an authorization decision");let r=await ae(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let{documentPath:n,absolutePath:o}=_i(e.pmRoot,e.filePath),i=Lt(e.pmRoot),s=await Fe(i,at),a=jt(s);a.ok||Or(a.errors);let c=Ft(s),d=Sr(c);if(!Object.hasOwn(d,n))throw new TypeError(`Workspace history does not govern document ${n}`);let l=await ge(o);if(l===null)throw new TypeError(`Workspace history document is missing: ${n}`);let u=JSON.parse(l);if(R(d[n])===R(u))return{changed:!1,historyPath:i};let f=Me(),m=On({nowIso:f,author:e.author,op:e.op,before:c,after:Ec({...d,[n]:u},c.metadata.created_at),message:e.message,context:{reason:"out_of_band_workspace_state_reconciliation",document_path:n,authorization_decision:t}});return await An(i,m),{changed:!0,entry:m,historyPath:i}}finally{await r()}}async function vj(e){let t=await ae(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let{documentPath:r,absolutePath:n}=_i(e.pmRoot,e.filePath),o=await Fe(Lt(e.pmRoot),at),i=jt(o);if(i.ok||Or(i.errors),!Number.isInteger(e.targetVersion)||e.targetVersion<1||e.targetVersion>o.length)throw new TypeError(`Invalid workspace history target version: ${String(e.targetVersion)}`);let s=Sr(Ft(o,e.targetVersion))[r];if(s===void 0)throw new TypeError(`Workspace history version ${e.targetVersion} does not contain ${r}`);let a=await ge(n),c=`${JSON.stringify(s,null,2)}
107
+ `;if(a===c)return{document_path:r,restored_from_version:e.targetVersion,changed:!1};let d=Ft(o),l=Me(),u=On({nowIso:l,author:e.author,op:e.op,before:d,after:Ec({...Sr(d),[r]:s},d.metadata.created_at),message:e.message,context:{reason:"workspace_state_restore",document_path:r,restored_from_version:e.targetVersion,replaced_out_of_band_state:!0}});await mt(n,c);try{await An(Lt(e.pmRoot),u)}catch(f){throw a===null?await zp.rm(n,{force:!0}):await mt(n,a),f}return{document_path:r,restored_from_version:e.targetVersion,changed:!0}}finally{await t()}}import{AsyncLocalStorage as DA}from"node:async_hooks";import{lstat as PA,realpath as Qp}from"node:fs/promises";import e_ 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]="f4ae942c-f11f-5d24-95bf-a2abf3c226da")}catch{}})();var _e={ok:!1},b=e=>typeof e=="string"?{ok:!0,value:e}:_e,x=e=>typeof e=="boolean"?{ok:!0,value:e}:_e;function L(e={}){return t=>typeof t!="number"||!Number.isFinite(t)||e.int&&(!Number.isInteger(t)||!Number.isSafeInteger(t))||e.positive&&t<=0||typeof e.min=="number"&&t<e.min||typeof e.max=="number"&&t>e.max?_e:{ok:!0,value:t}}function N(...e){return t=>typeof t=="string"&&e.includes(t)?{ok:!0,value:t}:_e}function k(e,t){return r=>{if(!Array.isArray(r)||t!==void 0&&r.length>t)return _e;let n=[];for(let o of r){let i=e(o);if(!i.ok)return _e;n.push(i.value)}return{ok:!0,value:n}}}function Sc(e,t){return r=>typeof r=="string"&&r.length>0&&r.length<=e&&r===r.trim()&&(t===void 0||t.test(r))?{ok:!0,value:r}:_e}function p(e){return t=>t===void 0?{ok:!0,value:void 0}:e(t)}function yi(e){return t=>{if(typeof t!="object"||t===null||Array.isArray(t))return _e;let r={};for(let[n,o]of Object.entries(t)){let i=e(o);if(!i.ok)return _e;r[n]=i.value}return{ok:!0,value:r}}}function I(e){return t=>{if(typeof t!="object"||t===null||Array.isArray(t))return _e;let r=t,n={};for(let[o,i]of Object.entries(e)){let s=i(r[o]);if(!s.ok)return _e;s.value!==void 0&&(n[o]=s.value)}return{ok:!0,value:n}}}var pA=I({key:b,values:k(b),required:p(x),aliases:p(k(b)),description:p(b)}),_A=I({command:N("create","update"),option:b,required:p(x),visible:p(x),enabled:p(x)}),yA=I({name:b,description:p(b),default_status:p(b),execution_role:p(N("agent","human","gate")),folder:p(b),aliases:p(k(b)),required_create_fields:p(k(b)),required_create_repeatables:p(k(b)),options:p(k(pA)),command_option_policies:p(k(_A))}),hA=I({id:b,aliases:p(k(b)),roles:p(k(N(...qn))),description:p(b),order:p(L())}),gA=I({key:b,metadata_key:p(b),front_matter_key:p(b),cli_flag:p(b),cli_aliases:p(k(b)),description:p(b),type:p(N(...Bt)),commands:p(k(N(...Vn))),repeatable:p(x),required:p(x),required_on_create:p(x),required_types:p(k(b)),allow_unset:p(x)}),bA=e=>{if(!Array.isArray(e)||e.length!==2)return _e;let[t,r]=e;return typeof t!="string"||typeof r!="string"?_e:{ok:!0,value:[t,r]}},wA=I({type:b,allowed_transitions:k(bA)}),vA=p(I({version:p(L({int:!0})),files:p(I({types:p(b),statuses:p(b),fields:p(b),workflows:p(b)})),statuses:p(k(hA)),fields:p(k(gA)),workflow:p(I({draft_status:p(b),open_status:p(b),in_progress_status:p(b),blocked_status:p(b),close_status:p(b),canceled_status:p(b)})),type_workflows:p(k(wA)),unknown_field_policy:p(N(...Bn))})),EA=p(I({preset:p(N(...td)),ownership_enforcement:p(N("none","warn","strict")),create_mode_default:p(N("progressive","strict")),close_validation_default:p(N("off","warn","strict")),require_close_reason:p(x),parent_reference:p(N("warn","strict_error")),metadata_profile:p(N("core","strict","custom")),force_required_for_stale_lock:p(x),create_default_type:p(b),workflow_enforcement:p(N("off","warn","strict")),duplicate_detection_mode:p(N("off","advisory","strict")),duplicate_detection_threshold:p(L({min:0,max:1})),duplicate_detection_limit:p(L({int:!0,min:0,max:20}))})),kA=I({name:b,disabled:p(x),require_trusted:p(x),require_provenance:p(x),sandbox_profile:p(N("none","restricted","strict")),allowed_capabilities:p(k(b)),blocked_capabilities:p(k(b)),allowed_surfaces:p(k(b)),blocked_surfaces:p(k(b)),allowed_commands:p(k(b)),blocked_commands:p(k(b)),allowed_actions:p(k(b)),blocked_actions:p(k(b)),allowed_services:p(k(b)),blocked_services:p(k(b))}),kc=N("block","warn"),SA=e=>typeof e=="string"?kc(e):I({global:p(kc),project:p(kc)})(e),OA=p(I({mode:p(N("off","warn","enforce")),trust_mode:p(N("off","warn","enforce")),pm_max_version_exceeded_mode:p(SA),require_provenance:p(x),trusted_extensions:p(k(b)),default_sandbox_profile:p(N("none","restricted","strict")),allowed_extensions:p(k(b)),blocked_extensions:p(k(b)),allowed_capabilities:p(k(b)),blocked_capabilities:p(k(b)),allowed_surfaces:p(k(b)),blocked_surfaces:p(k(b)),allowed_commands:p(k(b)),blocked_commands:p(k(b)),allowed_actions:p(k(b)),blocked_actions:p(k(b)),allowed_services:p(k(b)),blocked_services:p(k(b)),extension_overrides:p(k(kA))})),zt=Sc(128),AA=I({harness:Sc(128,/^[a-z0-9]+(?:-[a-z0-9]+)*$/u),environment_keys:p(k(zt,64)),model_environment_keys:p(k(zt,64)),session_environment_keys:p(k(zt,64)),provenance_environment_keys:p(yi(k(zt,64))),provenance_resolvers:p(yi(N("ai_agent_version","claude_session_file"))),provenance_unavailable_dimensions:p(k(zt,64)),argv_markers:p(k(zt,64)),client_names:p(k(zt,64))}),IA=I({version:L({int:!0}),id_prefix:b,ids:p(I({token_length:p(L({int:!0,min:4,max:12}))})),author_default:b,agent_identity:p(I({probes_enabled:p(x),identity_vocabulary:p(I({version:L({int:!0,positive:!0}),aliases:yi(Sc(128,/^[a-z0-9]+(?:-[a-z0-9]+)*$/u))})),harness_signals:k(AA)})),mutation_guard:p(I({require_attributed_author:p(x),secret_guard:p(N("off","advise","block")),stale_in_progress_hours:p(L({int:!0,positive:!0}))})),item_format:p(N("toon","json_markdown")),locks:I({ttl_seconds:L({int:!0}),wait_ms:p(L({int:!0,min:0}))}),checkpoints:p(I({retention_days:p(L({int:!0,positive:!0}))})),output:I({default_format:N("toon","json")}),ux:p(I({deprecation_hints:p(x)})),history:p(I({missing_stream:N("auto_create","strict_error"),compact_policy:p(I({enabled:p(x),max_entries:p(L({int:!0,positive:!0})),trigger:p(N("health_warn","auto"))}))})),validation:p(I({sprint_release_format:N("warn","strict_error"),parent_reference:p(N("warn","strict_error")),metadata_profile:p(N("core","strict","custom")),metadata_required_fields:p(k(b)),lifecycle_stale_blocker_reason_patterns:p(k(b)),lifecycle_closure_like_blocked_reason_patterns:p(k(b)),lifecycle_closure_like_resolution_patterns:p(k(b)),lifecycle_closure_like_actual_result_patterns:p(k(b)),estimate_defaults_by_type:p(yi(L({int:!0,positive:!0})))})),governance:EA,workflow:p(I({definition_of_done:k(b)})),testing:p(I({record_results_to_items:x,allow_untrusted_linked_tests:p(x)})),telemetry:p(I({enabled:x,first_run_prompt_completed:p(x),capture_level:p(N("minimal","redacted","max")),endpoint:p(b),installation_id:p(b),retention_days:p(L({int:!0,positive:!0}))})),agent_guidance:p(I({prompt_completed:p(x),declined:p(x),declined_at:p(b),template_version:p(L({int:!0,positive:!0})),last_checked_files:p(k(b))})),item_types:p(I({definitions:k(yA)})),schema:vA,context:p(I({default_depth:p(N("brief","standard","deep")),activity_limit:p(L({int:!0,positive:!0})),stale_threshold_days:p(L({int:!0,positive:!0})),sections:p(I({hierarchy:p(x),activity:p(x),progress:p(x),recently_created:p(x),unparented:p(x),blockers:p(x),files:p(x),workload:p(x),staleness:p(x),tests:p(x)}))})),extensions:I({enabled:k(b),disabled:k(b),policy:OA}),search:I({score_threshold:L(),hybrid_semantic_weight:p(L()),max_results:L({int:!0}),embedding_model:b,embedding_corpus_max_characters:p(L()),embedding_batch_size:L({int:!0}),embedding_timeout_ms:p(L({int:!0})),scanner_max_batch_retries:L({int:!0}),provider:p(b),default_mode:p(N("auto","keyword","semantic","hybrid")),corpus_fields:p(k(b)),mutation_refresh_policy:p(N("cache_only","semantic_configured","semantic_auto")),query_expansion:p(I({enabled:p(x),provider:p(b)})),rerank:p(I({enabled:p(x),model:p(b),top_k:p(L({int:!0,positive:!0}))})),bm25:p(I({k1:p(L()),b:p(L())}))}),providers:I({openai:I({base_url:b,api_key:b,model:b}),ollama:I({base_url:b,model:b})}),vector_store:I({adapter:p(b),collection_name:p(b),qdrant:I({url:b,api_key:b}),lancedb:I({path:b})})});function Oc(e){let t=IA(e);return t.ok?{success:!0,data:t.value}:{success:!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]="a0ca9902-540c-50fe-a4e2-9c234c4a01f3")}catch{}})();function hi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ac(e,t,r,n=[]){if(B(e,t)&&(n.length>0||hi(r)))return r;if(B(e,r)||B(t,r))return t;if((e===void 0||hi(e))&&hi(t)&&hi(r)){let o=e??{},i=new Set([...Object.keys(o),...Object.keys(t),...Object.keys(r)]);return Object.fromEntries([...i].flatMap(s=>{let a=Ac(Object.hasOwn(o,s)?o[s]:void 0,Object.hasOwn(t,s)?t[s]:void 0,Object.hasOwn(r,s)?r[s]:void 0,[...n,s]);return a===void 0?[]:[[s,a]]}))}throw new g(`Settings changed concurrently at ${n.join(".")||"<root>"}; read the latest settings and reapply the intended change.`,h.CONFLICT,{reason:"stale_settings_snapshot",required:"Read a fresh settings snapshot and reapply the intended change.",why:"Another writer changed the same setting after this snapshot was read.",examples:["pm config project export --json"],nextSteps:["Read the current settings, then retry the original config operation."]})}(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]="de43e8e6-d7ef-53cc-94b0-ccdf1c4f94a3")}catch{}})();var TA={Epic:2880,Feature:480,Story:480,Milestone:2880,Task:120,Issue:60,Bug:60,Chore:30,Decision:15,Plan:120},Vp=120;function Ic(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Wp(e){let t=new Map;for(let[r,n]of Object.entries(e))t.set(r.toLowerCase(),n);return t}var CA=Wp(TA),Bp=new WeakMap;function RA(e){let t=Bp.get(e);if(t)return t;let r=Wp(e);return Bp.set(e,r),r}function Cj(e,t){let r=(e??"").trim().toLowerCase();if(r.length===0)return Vp;if(t){let o=RA(t).get(r);if(Ic(o))return Math.floor(o)}let n=CA.get(r);return Ic(n)?Math.floor(n):Vp}function Tc(e){let t={};if(e===null||typeof e!="object"||Array.isArray(e))return t;for(let[r,n]of Object.entries(e)){let o=r.trim();o.length===0||!Ic(n)||(t[o]=Math.floor(n))}return t}import{stat as xA}from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="78c79deb-5cf0-54fe-b98c-a0d5b3671ab2")}catch{}})();var gi=new Map;function Gp(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}async function NA(e){try{let t=await xA(e);return{path:e,mtime_ms:t.mtimeMs,size:t.size}}catch{return{path:e,mtime_ms:null,size:null}}}async function ct(e){let t=Gp(e),r=await Promise.all(t.map(n=>NA(n)));return r.sort((n,o)=>n.path.localeCompare(o.path)),r}function In(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1){let n=e[r],o=t[r];if(n.path!==o.path||n.mtime_ms!==o.mtime_ms||n.size!==o.size)return!1}return!0}function Kp(e){return gi.get(e)}function bi(e,t){let r=Gp(t.tracked_paths),n=[...t.signatures].map(o=>({path:o.path,mtime_ms:o.mtime_ms,size:o.size})).sort((o,i)=>o.path.localeCompare(i.path));gi.set(e,{tracked_paths:r,signatures:n,value:t.value})}function dt(e){if(e){gi.delete(e);return}gi.clear()}(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]="bbb5e299-541d-5fff-8422-855c85cf7a31")}catch{}})();var Nc=new DA;async function Xj(e,t,r=()=>!0){let n=new Set([e_.resolve(e)]);try{n.add(await Qp(e))}catch{}return Nc.run([...Nc.getStore()??[],[n,r]],t)}function MA(e){let t=e_.resolve(e);return Nc.getStore()?.some(([r,n])=>r.has(t)&&n())??!1}var $A="settings:write",t_=Symbol("pm.settings.persist_source"),jA=128,LA=new Set(["off","advisory","strict"]);function Yp(e){return structuredClone(Wc[e])}function FA(e){return e==="minimal"||e==="default"||e==="strict"||e==="custom"?e:S.governance.preset}function Xp(e,t){let r=typeof t.create_default_type=="string"?t.create_default_type.trim():void 0;return r&&r.length>0&&(e.create_default_type=r),(t.workflow_enforcement==="off"||t.workflow_enforcement==="warn"||t.workflow_enforcement==="strict")&&(e.workflow_enforcement=t.workflow_enforcement),t.require_close_reason===!1&&(e.require_close_reason=!1),e.duplicate_detection_mode=t.duplicate_detection_mode,e.duplicate_detection_threshold=t.duplicate_detection_threshold,e.duplicate_detection_limit=t.duplicate_detection_limit,e}function zA(e){return e.preset==="custom"?Xp({preset:"custom",ownership_enforcement:e.ownership_enforcement,create_mode_default:e.create_mode_default,close_validation_default:e.close_validation_default,parent_reference:e.parent_reference,metadata_profile:e.metadata_profile,force_required_for_stale_lock:e.force_required_for_stale_lock},e):Xp({preset:e.preset},e)}function UA(e){let t=typeof e.create_default_type=="string"?e.create_default_type.trim():void 0,r={};t&&t.length>0&&(r.create_default_type=t),(e.workflow_enforcement==="off"||e.workflow_enforcement==="warn"||e.workflow_enforcement==="strict")&&(r.workflow_enforcement=e.workflow_enforcement),typeof e.require_close_reason=="boolean"&&(r.require_close_reason=e.require_close_reason),LA.has(String(e.duplicate_detection_mode))&&(r.duplicate_detection_mode=e.duplicate_detection_mode);let n=e.duplicate_detection_threshold;[typeof n=="number",Number.isFinite(n),Number(n)>=0,Number(n)<=1].every(Boolean)&&(r.duplicate_detection_threshold=n);let o=e.duplicate_detection_limit;return[typeof o=="number",Number.isSafeInteger(o),Number(o)>=0,Number(o)<=20].every(Boolean)&&(r.duplicate_detection_limit=o),r}function r_(e){let t=e.governance??{},r=FA(t.preset),n=UA(t);if(r==="custom"){let s=Yp("default"),a=n.require_close_reason??s.require_close_reason;return{preset:r,ownership_enforcement:t.ownership_enforcement??s.ownership_enforcement,create_mode_default:t.create_mode_default??s.create_mode_default,close_validation_default:t.close_validation_default??s.close_validation_default,parent_reference:t.parent_reference??s.parent_reference,metadata_profile:t.metadata_profile??s.metadata_profile,force_required_for_stale_lock:t.force_required_for_stale_lock??s.force_required_for_stale_lock,...n,require_close_reason:a,duplicate_detection_mode:n.duplicate_detection_mode??s.duplicate_detection_mode,duplicate_detection_threshold:n.duplicate_detection_threshold??s.duplicate_detection_threshold,duplicate_detection_limit:n.duplicate_detection_limit??s.duplicate_detection_limit}}let o=Yp(r),i=n.require_close_reason??o.require_close_reason;return{preset:r,...o,...n,require_close_reason:i}}function n_(){return structuredClone(S)}function o_(e){return e==="cache_only"||e==="semantic_configured"||e==="semantic_auto"?e:S.search.mutation_refresh_policy}function i_(e){return e==="auto"||e==="keyword"||e==="semantic"||e==="hybrid"?e:"auto"}function s_(e){return typeof e=="boolean"?e:S.search.query_expansion.enabled}function a_(e){return typeof e!="string"?S.search.query_expansion.provider:e.trim()}function c_(e){return typeof e=="boolean"?e:S.search.rerank.enabled}function d_(e){return typeof e!="string"?S.search.rerank.model:e.trim()}function l_(e){return typeof e=="number"&&Number.isFinite(e)&&Number.isInteger(e)&&e>0?e:S.search.rerank.top_k}function u_(e){if(typeof e!="string")return S.vector_store.collection_name;let t=e.trim().replaceAll(/[^a-zA-Z0-9_-]/g,"_").slice(0,jA);return t.length>0?t:S.vector_store.collection_name}function Cc(e){return{present:Array.isArray(e),values:Array.isArray(e)?structuredClone(e):[]}}function f_(e,t){let r=e.schema,n=Cc(r?.statuses),o=Cc(r?.fields),i=Cc(r?.type_workflows);return{persisted_settings:structuredClone(e),source_settings:structuredClone(e),has_source_item_type_definitions:Array.isArray(e.item_types?.definitions),source_item_type_definitions:Ar(e.item_types?.definitions),has_source_schema_statuses:n.present,source_schema_statuses:n.values,has_source_schema_fields:o.present,source_schema_fields:o.values,has_source_schema_type_workflows:i.present,source_schema_type_workflows:i.values,runtime_item_type_definitions:Ar(t.item_types?.definitions),runtime_schema_statuses:structuredClone(t.schema.statuses),runtime_schema_fields:structuredClone(t.schema.fields),runtime_schema_type_workflows:structuredClone(t.schema.type_workflows??[])}}function Ei(e,t){Object.defineProperty(e,t_,{value:t,writable:!0,configurable:!0,enumerable:!1})}function Mc(e){let t=e[t_];if(!(!t||typeof t!="object"))return t}function Jj(e){let t=Mc(e);if(t){let r=structuredClone(t);r.source_settings.item_format=e.item_format,Ei(e,r)}}function wi(e){let t=structuredClone(e.settings),r=Mc(e.settings);return r&&Ei(t,r),{settings:t,metadata:{has_explicit_item_format:e.metadata.has_explicit_item_format},warnings:[...e.warnings]}}function HA(e,t,r){let n=Ae(t);return[r,ce(e,n.files.types,oe.types),ce(e,n.files.statuses,oe.statuses),ce(e,n.files.fields,oe.fields),ce(e,n.files.workflows,oe.workflows)]}async function qA(e,t,r){let n=await ct(t);bi(e,{tracked_paths:t,signatures:n,value:wi(r)})}async function VA(e,t,r){try{await qA(e,t,r)}catch{dt(e)}}function Jp(e,t){return e.find(r=>r.path===t)}function BA(e,t,r){for(let n of r){let o=Jp(e,n),i=Jp(t,n);if(!o||!i||!In([o],[i]))return!1}return!0}async function Rc(e,t,r,n,o){try{let i=await ct(t);if(!BA(n,i,o)){dt(e);return}bi(e,{tracked_paths:t,signatures:i,value:wi(r)})}catch{dt(e)}}function WA(e,t){let r=Ae(e.schema),n=Ar(e.item_types?.definitions);if(!t)return{item_type_definitions:n,schema_statuses:r.statuses,schema_fields:r.fields,schema_type_workflows:r.type_workflows};let o=r.type_workflows??[],i=B(n,t.runtime_item_type_definitions),s=B(r.statuses,t.runtime_schema_statuses),a=B(r.fields,t.runtime_schema_fields),c=B(o,t.runtime_schema_type_workflows);return{item_type_definitions:i?t.has_source_item_type_definitions?Ar(t.source_item_type_definitions):[]:n,schema_statuses:s?t.has_source_schema_statuses?structuredClone(t.source_schema_statuses):[]:r.statuses,schema_fields:a?t.has_source_schema_fields?structuredClone(t.source_schema_fields):[]:r.fields,schema_type_workflows:c?t.has_source_schema_type_workflows?structuredClone(t.source_schema_type_workflows):void 0:r.type_workflows}}function Te(e){return{settings:n_(),metadata:{has_explicit_item_format:!1},warnings:e?[e]:[]}}function m_(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e.item_format;return t==="toon"||t==="json_markdown"}function Dc(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function p_(e){let t=S.agent_guidance,r=e?.template_version;return{prompt_completed:e?.prompt_completed===!0,declined:e?.declined===!0,declined_at:typeof e?.declined_at=="string"?e.declined_at:t.declined_at,template_version:typeof r=="number"&&Number.isInteger(r)&&r>0?r:t.template_version,last_checked_files:Dc(e?.last_checked_files??t.last_checked_files)}}function we(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function GA(e){return e==="off"||e==="warn"||e==="enforce"?e:S.extensions.policy.mode}function KA(e){return e==="off"||e==="warn"||e==="enforce"?e:S.extensions.policy.trust_mode}function __(e){return e==="none"||e==="restricted"||e==="strict"?e:S.extensions.policy.default_sandbox_profile}function YA(e){let t=e.name.trim().toLowerCase();if(t.length===0)return null;let r={name:t};e.disabled===!0&&(r.disabled=!0),e.require_trusted===!0&&(r.require_trusted=!0),e.require_provenance===!0&&(r.require_provenance=!0),e.sandbox_profile!==void 0&&(r.sandbox_profile=__(e.sandbox_profile));let n=we(e.allowed_capabilities),o=we(e.blocked_capabilities),i=we(e.allowed_surfaces),s=we(e.blocked_surfaces),a=we(e.allowed_commands),c=we(e.blocked_commands),d=we(e.allowed_actions),l=we(e.blocked_actions),u=we(e.allowed_services),f=we(e.blocked_services);return n.length>0&&(r.allowed_capabilities=n),o.length>0&&(r.blocked_capabilities=o),i.length>0&&(r.allowed_surfaces=i),s.length>0&&(r.blocked_surfaces=s),a.length>0&&(r.allowed_commands=a),c.length>0&&(r.blocked_commands=c),d.length>0&&(r.allowed_actions=d),l.length>0&&(r.blocked_actions=l),u.length>0&&(r.allowed_services=u),f.length>0&&(r.blocked_services=f),r}function XA(e){let t=new Map;for(let r of e??[]){let n=YA(r);n&&t.set(n.name,n)}return[...t.values()].sort((r,n)=>r.name.localeCompare(n.name))}function xc(e){return e==="block"||e==="warn"?e:void 0}function JA(e){if(typeof e=="string")return xc(e);if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=xc(e.global),r=xc(e.project);return t===void 0&&r===void 0?void 0:{...t!==void 0?{global:t}:{},...r!==void 0?{project:r}:{}}}}function ye(e,t){return we(e?.[t]??S.extensions.policy[t])}function y_(e){let t=JA(e?.pm_max_version_exceeded_mode);return{mode:GA(e?.mode),trust_mode:KA(e?.trust_mode),...t!==void 0?{pm_max_version_exceeded_mode:t}:{},require_provenance:e?.require_provenance===!0,trusted_extensions:ye(e,"trusted_extensions"),default_sandbox_profile:__(e?.default_sandbox_profile),allowed_extensions:ye(e,"allowed_extensions"),blocked_extensions:ye(e,"blocked_extensions"),allowed_capabilities:ye(e,"allowed_capabilities"),blocked_capabilities:ye(e,"blocked_capabilities"),allowed_surfaces:ye(e,"allowed_surfaces"),blocked_surfaces:ye(e,"blocked_surfaces"),allowed_commands:ye(e,"allowed_commands"),blocked_commands:ye(e,"blocked_commands"),allowed_actions:ye(e,"allowed_actions"),blocked_actions:ye(e,"blocked_actions"),allowed_services:ye(e,"allowed_services"),blocked_services:ye(e,"blocked_services"),extension_overrides:XA(e?.extension_overrides??S.extensions.policy.extension_overrides)}}function h_(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase().replaceAll("-","_")))].filter(t=>t.length>0).sort((t,r)=>t.localeCompare(r)).filter(t=>["author","acceptance_criteria","estimated_minutes","close_reason","reviewer","risk","confidence","sprint","release"].includes(t))}function lt(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function W(e,t){return e===void 0?t:e}function he(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function Pc(e){return Array.isArray(e)?e:[]}function ZA(e,t,r){return{...t.validation,...e.validation,parent_reference:r.parent_reference,metadata_profile:r.metadata_profile,metadata_required_fields:h_(e.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:lt(e.validation?.lifecycle_stale_blocker_reason_patterns??t.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:lt(e.validation?.lifecycle_closure_like_blocked_reason_patterns??t.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:lt(e.validation?.lifecycle_closure_like_resolution_patterns??t.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:lt(e.validation?.lifecycle_closure_like_actual_result_patterns??t.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:Tc(e.validation?.estimate_defaults_by_type)}}function QA(e,t){return{enabled:e.telemetry?.enabled??t.telemetry.enabled,first_run_prompt_completed:e.telemetry?.first_run_prompt_completed??t.telemetry.first_run_prompt_completed,capture_level:e.telemetry?.capture_level??t.telemetry.capture_level,endpoint:e.telemetry?.endpoint??t.telemetry.endpoint,installation_id:e.telemetry?.installation_id??t.telemetry.installation_id,retention_days:e.telemetry?.retention_days??t.telemetry.retention_days}}function eI(e,t){return{...t.search,...e.search,default_mode:i_(e.search?.default_mode),mutation_refresh_policy:o_(e.search?.mutation_refresh_policy),query_expansion:{...t.search.query_expansion,...e.search?.query_expansion,enabled:s_(e.search?.query_expansion?.enabled),provider:a_(e.search?.query_expansion?.provider)},rerank:{...t.search.rerank,...e.search?.rerank,enabled:c_(e.search?.rerank?.enabled),model:d_(e.search?.rerank?.model),top_k:l_(e.search?.rerank?.top_k)}}}function tI(e,t){return{adapter:e.vector_store.adapter??t.vector_store.adapter,collection_name:u_(e.vector_store.collection_name),qdrant:{...t.vector_store.qdrant,...e.vector_store.qdrant},lancedb:{...t.vector_store.lancedb,...e.vector_store.lancedb}}}function rI(e,t){return e.item_format==="json_markdown"?"toon":e.item_format??t.item_format}function nI(e,t){return{default_depth:e.context?.default_depth??t.context.default_depth,activity_limit:e.context?.activity_limit??t.context.activity_limit,stale_threshold_days:e.context?.stale_threshold_days??t.context.stale_threshold_days,sections:{...t.context.sections,...e.context?.sections}}}function oI(e,t){return{openai:{...t.providers.openai,...e.providers.openai},ollama:{...t.providers.ollama,...e.providers.ollama}}}function Ar(e){let t=(e??[]).map(n=>Yn(n)).filter(n=>n!==null),r=new Map;for(let n of t)r.set(n.name.toLowerCase(),n);return[...r.values()].sort((n,o)=>n.name.localeCompare(o.name))}function vi(e){let t=n_(),r=r_({governance:e.governance??{preset:"default"}});return{...t,...e,item_format:rI(e,t),locks:{...t.locks,...e.locks},ids:{...t.ids,...e.ids},agent_identity:structuredClone(e.agent_identity??t.agent_identity),mutation_guard:{...t.mutation_guard,...e.mutation_guard},checkpoints:{...t.checkpoints,...e.checkpoints},output:{...t.output,...e.output},ux:{...t.ux,...e.ux},history:{...t.history,...e.history,compact_policy:{...t.history.compact_policy,...e.history?.compact_policy}},validation:ZA(e,t,r),governance:r,workflow:{definition_of_done:[...e.workflow?.definition_of_done??t.workflow.definition_of_done]},testing:{record_results_to_items:e.testing?.record_results_to_items??t.testing.record_results_to_items,allow_untrusted_linked_tests:e.testing?.allow_untrusted_linked_tests??t.testing.allow_untrusted_linked_tests},telemetry:QA(e,t),agent_guidance:p_(e.agent_guidance??t.agent_guidance),item_types:{definitions:Ar(e.item_types?.definitions)},schema:Ae(e.schema??t.schema),context:nI(e,t),extensions:{enabled:[...e.extensions.enabled],disabled:[...e.extensions.disabled],policy:y_(e.extensions.policy??t.extensions.policy)},search:eI(e,t),providers:oI(e,t),vector_store:tI(e,t)}}function iI(e){e.agent_identity=A(e.agent_identity,["probes_enabled","identity_vocabulary","harness_signals"]);let t=e.agent_identity;Object.hasOwn(t,"identity_vocabulary")&&(t.identity_vocabulary=A(he(t.identity_vocabulary),["version","aliases"])),e.agent_identity.harness_signals=Pc(e.agent_identity.harness_signals).map(r=>A(he(r),["harness","environment_keys","model_environment_keys","session_environment_keys","provenance_environment_keys","provenance_resolvers","provenance_unavailable_dimensions","argv_markers","client_names"])),e.locks=A(e.locks,["ttl_seconds","wait_ms"]),e.ids=A(e.ids,["token_length"]),e.mutation_guard=A(e.mutation_guard,["require_attributed_author","secret_guard","stale_in_progress_hours"]),e.checkpoints=A(e.checkpoints,["retention_days"]),e.output=A(e.output,["default_format"]),e.ux=A(e.ux,["deprecation_hints"]),e.history=A(e.history,["missing_stream","compact_policy"]),e.validation=A(e.validation,["sprint_release_format","parent_reference","metadata_profile","metadata_required_fields","lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns","estimate_defaults_by_type"]),e.governance=A(e.governance,["preset","ownership_enforcement","create_mode_default","close_validation_default","require_close_reason","parent_reference","metadata_profile","force_required_for_stale_lock","create_default_type","workflow_enforcement","duplicate_detection_mode","duplicate_detection_threshold","duplicate_detection_limit"]),e.workflow=A(e.workflow,["definition_of_done"]),e.testing=A(e.testing,["record_results_to_items","allow_untrusted_linked_tests"]),e.telemetry=A(e.telemetry,["enabled","first_run_prompt_completed","capture_level","endpoint","installation_id","retention_days"]),e.agent_guidance=A(e.agent_guidance,["prompt_completed","declined","declined_at","template_version","last_checked_files"]),e.item_types=A(e.item_types,["definitions"]),e.schema=A(e.schema,["version","files","statuses","fields","workflow","type_workflows","unknown_field_policy"]),e.schema.files=A(he(e.schema.files),["types","statuses","fields","workflows"]),e.schema.workflow=A(he(e.schema.workflow),["draft_status","open_status","in_progress_status","blocked_status","close_status","canceled_status"]),e.context=A(e.context,["default_depth","activity_limit","stale_threshold_days","sections"]),e.context.sections=A(he(e.context.sections),["hierarchy","activity","progress","blockers","files","workload","staleness","tests"]),e.extensions=A(e.extensions,["enabled","disabled","policy"]),e.extensions.policy=A(he(e.extensions.policy),["mode","trust_mode","pm_max_version_exceeded_mode","require_provenance","trusted_extensions","default_sandbox_profile","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"]),e.extensions.policy.extension_overrides=Pc(e.extensions.policy.extension_overrides).map(r=>A(he(r),["name","disabled","require_trusted","require_provenance","sandbox_profile","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services"])),e.search=A(e.search,["score_threshold","hybrid_semantic_weight","max_results","embedding_model","embedding_corpus_max_characters","embedding_batch_size","embedding_timeout_ms","scanner_max_batch_retries","provider","default_mode","mutation_refresh_policy","query_expansion","rerank"]),e.search.query_expansion=A(he(e.search.query_expansion),["enabled","provider"]),e.search.rerank=A(he(e.search.rerank),["enabled","model","top_k"]),e.providers=A(e.providers,["openai","ollama"]),e.providers.openai=A(he(e.providers.openai),["base_url","api_key","model"]),e.providers.ollama=A(he(e.providers.ollama),["base_url","model"]),e.vector_store=A(e.vector_store,["adapter","collection_name","qdrant","lancedb"]),e.vector_store.qdrant=A(he(e.vector_store.qdrant),["url","api_key"]),e.vector_store.lancedb=A(he(e.vector_store.lancedb),["path"])}function sI(e){return{...e,locks:W(e.locks,S.locks),ids:W(e.ids,S.ids),agent_identity:W(e.agent_identity,S.agent_identity),mutation_guard:W(e.mutation_guard,S.mutation_guard),checkpoints:W(e.checkpoints,S.checkpoints),output:W(e.output,S.output),ux:W(e.ux,S.ux),history:W(e.history,S.history),validation:W(e.validation,S.validation),workflow:W(e.workflow,S.workflow),testing:W(e.testing,S.testing),telemetry:W(e.telemetry,S.telemetry),agent_guidance:W(e.agent_guidance,S.agent_guidance),item_types:W(e.item_types,S.item_types),schema:W(e.schema,S.schema),context:W(e.context,S.context),extensions:W(e.extensions,S.extensions),search:W(e.search,S.search),providers:W(e.providers,S.providers),vector_store:W(e.vector_store,S.vector_store)}}function aI(e,t){return{...e.validation,parent_reference:t.parent_reference,metadata_profile:t.metadata_profile,metadata_required_fields:h_(e.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:lt(e.validation?.lifecycle_stale_blocker_reason_patterns??S.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:lt(e.validation?.lifecycle_closure_like_blocked_reason_patterns??S.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:lt(e.validation?.lifecycle_closure_like_resolution_patterns??S.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:lt(e.validation?.lifecycle_closure_like_actual_result_patterns??S.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:Tc(e.validation?.estimate_defaults_by_type)}}function cI(e){return{...S.search,...e.search,default_mode:i_(e.search?.default_mode),mutation_refresh_policy:o_(e.search?.mutation_refresh_policy),query_expansion:{...S.search.query_expansion,...e.search?.query_expansion,enabled:s_(e.search?.query_expansion?.enabled),provider:a_(e.search?.query_expansion?.provider)},rerank:{...S.search.rerank,...e.search?.rerank,enabled:c_(e.search?.rerank?.enabled),model:d_(e.search?.rerank?.model),top_k:l_(e.search?.rerank?.top_k)}}}function dI(e){return{default_depth:e.context?.default_depth??S.context.default_depth,activity_limit:e.context?.activity_limit??S.context.activity_limit,stale_threshold_days:e.context?.stale_threshold_days??S.context.stale_threshold_days,sections:{...S.context.sections,...e.context?.sections}}}function lI(e){return{...e.vector_store,adapter:e.vector_store?.adapter??S.vector_store.adapter,collection_name:u_(e.vector_store?.collection_name),qdrant:{...e.vector_store?.qdrant},lancedb:{...e.vector_store?.lancedb}}}function uI(e,t,r,n){return{...e,item_format:"toon",validation:aI(e,t),governance:t,agent_guidance:p_(e.agent_guidance),item_types:{definitions:n.item_type_definitions},schema:{...r,statuses:n.schema_statuses,fields:n.schema_fields,type_workflows:n.schema_type_workflows},search:cI(e),context:dI(e),extensions:{enabled:Dc(e.extensions?.enabled),disabled:Dc(e.extensions?.disabled),policy:y_(e.extensions?.policy)},vector_store:lI(e)}}function g_(e,t){for(let r of Object.keys(t)){let n=Reflect.get(t,r),o=e[r];typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?g_(o,n):e[r]=structuredClone(n)}}function b_(e,t,r){let n=new Set([...Object.keys(t),...Object.keys(r)]);for(let o of n){let i=t[o],s=r[o];if(!B(i,s)){if(s===void 0){delete e[o];continue}if(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof s=="object"&&s!==null&&!Array.isArray(s)){let a=e[o],c=typeof a=="object"&&a!==null&&!Array.isArray(a)?a:{};b_(c,i,s),Object.keys(c).length>0?e[o]=c:delete e[o];continue}e[o]=structuredClone(s)}}}var $c=["version","id_prefix","ids","author_default","agent_identity","mutation_guard","item_format","locks","checkpoints","output","ux","history","validation","governance","workflow","testing","telemetry","agent_guidance","item_types","schema","context","extensions","search","providers","vector_store"];function Zp(e,t){let r=sI(e),n=r_(r),o=Ae(r.schema),i=WA(r,t),s=uI(r,n,o,i),a=A({...s,governance:zA(n)},$c);return iI(a),a}function fI(e,t={}){let r=t.source===void 0?t.persist_source:f_(t.source.validated,vi(t.source.validated)),n=Zp(e,r);if(r){let o=vi(r.source_settings);o.item_types={definitions:structuredClone(r.runtime_item_type_definitions)},o.schema={...o.schema,statuses:structuredClone(r.runtime_schema_statuses),fields:structuredClone(r.runtime_schema_fields),type_workflows:structuredClone(r.runtime_schema_type_workflows)};let i=Zp(o,r);t.source!==void 0&&g_(i,t.source.validated);let s=structuredClone(t.source===void 0?r.source_settings:t.source.raw);return b_(s,i,n),`${JSON.stringify(A(s,$c),null,2)}
108
+ `}return`${JSON.stringify(n,null,2)}
109
+ `}async function mI(e){let t;try{t=await Qp(e)}catch(a){if(ke(a))return Te();throw a}let r=Se(t),n;try{n=await PA(r)}catch(a){if(ke(a))return Te();throw a}if(!n.isFile())throw Ci();let o;try{o=await Gc(r,Ci())}catch(a){if(ke(a))return Te();throw a}let i;try{i=JSON.parse(o)}catch{return Te("settings_read_invalid_json")}let s=Oc(i);return s.success?{settings:vi(s.data),metadata:{has_explicit_item_format:m_(i)},warnings:s.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[]}:Te("settings_read_invalid_schema")}async function w_(e){if(MA(e))return mI(e);let t=Se(e),r=[t];await er({path:t,scope:"project"});let n=Kp(e);if(n){let d=await ct(n.tracked_paths);if(In(d,n.signatures))return wi(n.value)}let o=await ct([t]),i;try{i=await ge(t)}catch{return Te("settings_read_fs_error")}if(i===null){let d=Te();return await Rc(e,[t],d,o,[t]),d}let s=await ct([t]);if(!In(o,s))return dt(e),w_(e);let a;try{a=JSON.parse(i)}catch{let d=Te("settings_read_invalid_json");return await Rc(e,[t],d,s,[t]),d}let c=Oc(a);if(!c.success){let d=Te("settings_read_invalid_schema");return await Rc(e,[t],d,s,[t]),d}try{let d=vi(c.data),l=HA(e,d.schema,t);r=l;let u=await ct(l),f=await sm(e,d.schema),m=await am(e,d.schema),_=await ct(l),y={...d,item_types:{definitions:Ar([...d.item_types.definitions,...Pc(m.type_definitions_from_file)])},schema:m.schema};Ei(y,f_(c.data,y));let w={settings:y,metadata:{has_explicit_item_format:m_(a)},warnings:[...c.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[],...f.created_paths.map(v=>`runtime_schema_bootstrap_created:${v}`),...m.warnings]};return f.created_paths.length===0?In(u,_)?bi(e,{tracked_paths:l,signatures:_,value:wi(w)}):dt(e):dt(e),w}catch{let d=Te("settings_read_merge_failed");return await VA(e,r,d),d}}async function Zj(e){return(await w_(e)).settings}async function Qj(e,t,r=$A){let n=Se(e),o=Mc(t),i=fI(t,{persist_source:o}),s=JSON.parse(i);try{await qp({pmRoot:e,filePath:n,mutate:a=>{let c=null;if(a!==null)try{c=JSON.parse(a)}catch{throw new g("Existing settings.json is malformed; the settings write was refused.",h.USAGE,{code:"settings_write_invalid_existing_json",reason:"existing_settings_json_malformed",why:"Writing defaults over malformed settings could destroy intended project configuration.",nextSteps:["Repair the syntax in .agents/pm/settings.json, then retry the original command.","Run pm health to confirm the settings warning has cleared."]})}return{raw:o?`${JSON.stringify(A(Ac(o.persisted_settings,s,c),$c),null,2)}
110
+ `:i,result:void 0}},op:r,author:Ym(void 0,t.author_default),lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms,recordCreation:!1}),o&&Ei(t,{...o,persisted_settings:structuredClone(s)}),await ho({path:n,scope:"project",op:r})}finally{dt(e)}}import v_ from"node:fs";import Tn from"node:path";import{createRequire as pI}from"node:module";(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]="19d9b802-1efa-5716-8176-ecbf5b153ff0")}catch{}})();var Cn="@unbrained/pm-cli",_I=new Set(["append","claim","changelog","close","close-many","close-task","comments","config","copy","create","dedupe-merge","delete","deps","docs","extension","event","events","files","focus","gc","history-author-acknowledge","history-compact","history-redact","history-repair","init","install","item","learnings","meet","merge","normalize","notes","package","packages","pause-task","plan","profile","reindex","release","remind","restore","schema","start-task","test","test-all","test-runs","test-runs-worker","telemetry","templates","twin","update","update-many","upgrade","vcs","workspace"]),E_=new Set(["--author","--output-budget","--output-format","--output-include","--output-limit","--output-session","--path","--pm-path"]),Lc=/\b(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?\b/u,Ai="2026.8.31";function ie(e,t){return e.some(r=>t.includes(r.split("=",1)[0]))}function jc(e,t){return["activate","adopt","adopt-all","deactivate","init","install","migrate","reload","uninstall"].includes(t[0]??"")||ie(e,["--activate","--adopt","--adopt-all","--deactivate","--fix-managed-state","--init","--install","--output","--reload","--scaffold","--uninstall"])}var yI={changelog:(e,t)=>{if(t[0]==="generate")return!ie(e,["--check"]);let r=e.indexOf("export");return t[0]==="export"&&(ie(e,["--output"])||r>=0&&e[r+1]!==void 0&&!e[r+1].startsWith("-"))},comments:e=>ie(e,["--add","--delete","--edit","--file","--stdin"]),config:(e,t)=>(t[0]==="project"||t[0]==="global"?t[1]:t[0])==="set",deps:()=>!1,docs:e=>ie(e,["--add","--add-glob","--migrate","--remove"]),duplicates:()=>!1,events:()=>!1,extension:jc,files:(e,t)=>ie(e,["--add","--add-glob","--migrate","--remove"])||t[0]==="discover"&&ie(e,["--apply"]),health:e=>!ie(e,["--check-only","--no-refresh","--skip-vectors"]),learnings:e=>ie(e,["--add","--delete","--edit","--file","--stdin"]),merge:(e,t)=>t[0]!=="report",notes:e=>ie(e,["--add","--delete","--edit","--file","--stdin"]),package:jc,packages:jc,profile:(e,t)=>t[0]==="apply",schema:(e,t)=>["add-field","add-status","add-type","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type"].includes(t[0]??"")&&!(ie(e,["--infer"])&&!ie(e,["--apply"])),telemetry:(e,t)=>t.slice(0,2).some(r=>["clear","flush"].includes(r)),templates:(e,t)=>t[0]==="save",test:e=>ie(e,["--update","--update-index","--add","--add-json","--background","--measure","--remove","--resume","--run","--stop"]),validate:e=>ie(e,["--auto-fix","--prune-missing"]),vcs:(e,t)=>["abandon","create","merge","propose","ref-create"].includes(t[0]??""),workspace:(e,t)=>t[0]==="snapshot"&&["create","delete","restore"].includes(t[1]??"")};function Si(e){let t=e.match(Lc);return t?[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]??0)]:null}function ut(e,t){let r=Si(e),n=Si(t);if(!r||!n)return null;for(let o=0;o<r.length;o+=1){let i=r[o]-n[o];if(i!==0)return Math.sign(i)}return 0}function ki(e){return ut(e,Ai)!==-1?3:2}function hI(e,t){if(t===3)return e.filter(r=>r.history_epoch_compatible===!1).map(r=>({...r,declaration:r.declaration??r.version})).sort((r,n)=>ut(r.version,n.version))[0]}function Oi(e){try{let t=JSON.parse(v_.readFileSync(e,"utf8"));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function gI(e){let t=[...e.matchAll(/(<=|<)\s*v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/gu)].map(n=>({inclusive:n[1]==="<=",version:n[2]})),r=e.match(/\b\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?\s+-\s+v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/u);return r?[...t,{inclusive:!0,version:r[1]}]:t}function bI(e){let t=e.split("||").map(r=>gI(r));return{bounded:t.some(r=>r.length>0),compatible:t.some(r=>r.every(n=>{let o=ut(Ai,n.version);return o!==null&&(n.inclusive?o!==1:o===-1)}))}}function k_(e){return["dependencies","devDependencies","optionalDependencies","peerDependencies"].flatMap(t=>{let r=e[t];if(typeof r!="object"||r===null)return[];let n=r[Cn];return typeof n=="string"?[n.trim()]:[]})}function wI(e){return k_(e).flatMap(t=>{let r=/^[<!]/u.test(t)?void 0:t.match(Lc)?.[0];if(!r)return[];let n=/^(?:=|v)?\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/u.test(t),o=bI(t);return[{version:r,constraint:n?"exact":o.bounded?"range":"minimum",...n?{}:{declaration:t},history_epoch_compatible:n?ut(r,Ai)!==-1:o.compatible}]})}function vI(e){let t=Oi(Tn.join(e,"package-lock.json"))?.packages;if(typeof t!="object"||t===null)return;let r=t["node_modules/@unbrained/pm-cli"];if(typeof r!="object"||r===null)return;let n=r.version;return typeof n=="string"?n:void 0}function EI(e,t){try{let r=v_.readFileSync(Tn.join(e,t),"utf8").split(/\r?\n/u),n=r.findIndex(s=>s.includes(Cn));if(n<0)return;let o=r[n].match(/^\s*/u)[0].length,i=[r[n]];for(let s=n+1;s<r.length;s+=1){let a=r[s],c=a.trim(),d=a.match(/^\s*/u)[0].length;if(c.length>0&&d<=o)break;i.push(a)}return i.join(`
111
+ `).match(/^\s*version(?::\s*|\s+)["']?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/mu)?.[1]??i[0].match(Lc)?.[0]}catch{return}}function S_(e){let t=[],r=Oi(Tn.join(e,"package.json"));r&&t.push(...wI(r).map(i=>({...i,source:"package.json"})));let n=Oi(Tn.join(e,"node_modules","@unbrained","pm-cli","package.json"))?.version;typeof n=="string"&&Si(n)&&t.push({version:n,source:"installed-package",constraint:"exact",history_epoch_compatible:ki(n)===3});let o=vI(e);o&&Si(o)&&t.push({version:o,source:"package-lock.json",constraint:"exact",history_epoch_compatible:ki(o)===3});for(let i of["pnpm-lock.yaml","yarn.lock"]){let s=EI(e,i);s&&t.push({version:s,source:i,constraint:"exact",history_epoch_compatible:ki(s)===3})}return t}function sL(e,t){if(t<=1)return;let{minVersion:r,lt:n}=pI(import.meta.url)("semver"),o=k_(Oi(Tn.join(e,"package.json"))??{}).find(s=>{try{let a=r(s);return a!==null&&n(a,"2026.10.10")}catch{return!1}}),i=o===void 0?S_(e).find(s=>ut(s.version,"2026.10.10")===-1):{version:o,source:"package.json"};if(i)throw new g(`The project selects pm ${i.version}, which cannot safely refuse item format ${t}.`,h.CONFLICT,{code:"project_runtime_item_format_incompatible",reason:i.source,required:"Upgrade project pins, installed SDKs, CI hosts and Git merge drivers before writing guarded item formats.",nextSteps:["Use a pm runtime supporting the required item format throughout the project; preserve original item and history bytes, and never re-anchor history to satisfy an older host."]})}function O_(e){for(let t=0;t<e.length;t+=1){let r=e[t];if(E_.has(r)){t+=1;continue}if(!r.startsWith("-"))return{command:r.toLowerCase(),index:t}}}function kI(e){let t=O_(e);if(!t||ie(e,["--help","-h","--dry-run"]))return!1;let{command:r,index:n}=t,o=[];for(let s=n+1;s<e.length;s+=1){let a=e[s];if(E_.has(a)){s+=1;continue}a.startsWith("-")||o.push(a.toLowerCase())}let i=yI[r];return i?i(e,o):_I.has(r)}function SI(e){let t=O_(e.argv)?.command,r=kI(e.argv),n=S_(e.projectRoot).filter(l=>ut(l.version,e.executingVersion)!==null).sort((l,u)=>ut(u.version,l.version)),o=n[0],i=o!==void 0&&ut(e.executingVersion,o.version)===-1,s=ki(e.executingVersion),a=hI(n,s),c=r&&a!==void 0,d=i&&!r?{code:"project_runtime_stale_read",executing_version:e.executingVersion,project_version:o.version,source:o.source,message:"This read is using an older pm runtime than the project requires.",next_steps:[`Run the command through the project's installed ${Cn} ${o.version}.`,"Install the project dependencies with its declared package manager if the local executable is missing."]}:void 0;return{compatible:!r||!i&&!c||e.allowStale===!0,executing_version:e.executingVersion,...o?{project_version:o.version,source:o.source}:{},...t?{command:t}:{},mutating:r,stale:i,history_epoch_incompatible:c,writer_item_hash_version:s,...a?{incompatible_project_version:a.declaration,incompatible_source:a.source}:{},...d?{warning:d}:{},override_applied:r&&(i||c)&&e.allowStale===!0}}function aL(e){let t=SI(e);if(t.compatible)return t;throw t.history_epoch_incompatible?new g(`pm ${t.executing_version} cannot write item-hash epoch ${t.writer_item_hash_version} into a project pinned to pm ${t.incompatible_project_version}.`,h.CONFLICT,{code:"project_runtime_history_epoch_incompatible",reason:t.incompatible_source,why:`The pinned runtime cannot read item_hash_version ${t.writer_item_hash_version}; allowing the write would break its health and validation gates.`,nextSteps:[`Upgrade the project's ${Cn} pin to ${Ai} or newer before mutating tracker history.`,"For an intentional coordinated migration only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.","Read-only commands remain available without an override."]}):new g(`pm ${t.executing_version} cannot mutate a project pinned to newer pm ${t.project_version}.`,h.CONFLICT,{code:"project_runtime_stale_mutation",reason:t.source,why:"An older runtime can write storage, history, and merge contracts it does not understand.",nextSteps:[`Run this command through the project's installed ${Cn} ${t.project_version}.`,"For an intentional recovery only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.","Read-only commands remain available without an override."]})}export{T_ as a,C_ as b,R_ as c,x_ as d,Ri as e,OI as f,N_ as g,Cr as h,$n as i,AI as j,II as k,TI as l,xi as m,Pi as n,Mi as o,DI as p,PI as q,MI as r,U_ as s,Yc as t,$I as u,us as v,$i as w,Xc as x,zn as y,Un as z,HI as A,qI as B,Y_ as C,BI as D,WI as E,GI as F,Zc as G,KI as H,YI as I,XI as J,Jc as K,Qc as L,JI as M,X_ as N,ed as O,Vt as P,qn as Q,Bt as R,Vn as S,QI as T,eT as U,tT as V,Wn as W,Gn as X,rT as Y,nT as Z,oT as _,iT as $,Kn as aa,xr as ba,ji as ca,sT as da,rd as ea,aT as fa,cT as ga,dT as ha,lT as ia,ry as ja,sd as ka,ud as la,bT as ma,Ui as na,py as oa,wT as pa,Ty as qa,Cy as ra,vT as sa,ET as ta,xT as ua,By as va,NT as wa,DT as xa,PT as ya,_d as za,Se as Aa,MT as Ba,$T as Ca,jT as Da,Hi as Ea,qi as Fa,Xn as Ga,Gy as Ha,LT as Ia,Ky as Ja,Yy as Ka,FT as La,zT as Ma,Xy as Na,UT as Oa,R as Pa,B as Qa,Zn as Ra,ah as Sa,hd as Ta,Vi as Ua,lh as Va,uh as Wa,Qn as Xa,bd as Ya,mh as Za,yh as _a,YT as $a,XT as ab,wh as bb,vh as cb,Eh as db,tC as eb,rC as fb,kh as gb,eo as hb,nC as ib,oC as jb,Sh as kb,Oh as lb,Ah as mb,vd as nb,Wt as ob,Ih as pb,iC as qb,sC as rb,aC as sb,cC as tb,dC as ub,lC as vb,uC as wb,to as xb,ro as yb,Gt as zb,F as Ab,no as Bb,yC as Cb,oo as Db,Ed as Eb,Bi as Fb,Mh as Gb,$h as Hb,$r as Ib,Wi as Jb,Gi as Kb,Ki as Lb,Yi as Mb,Xi as Nb,Ji as Ob,hs as Pb,Lh as Qb,Fh as Rb,qh as Sb,Vh as Tb,Cd as Ub,Bh as Vb,Qi as Wb,RC as Xb,xd as Yb,Nd as Zb,io as _b,DC as $b,Pd as ac,PC as bc,fl as cc,Cl as dc,Rl as ec,Xh as fc,es as gc,Zh as hc,ts as ic,rs as jc,ns as kc,os as lc,is as mc,ss as nc,cs as oc,ds as pc,ls as qc,zg as rc,Hg as sc,qg as tc,Jg as uc,px as vc,_x as wc,yx as xc,wx as yc,Ex as zc,yb as Ac,hb as Bc,Ss as Cc,wb as Dc,vb as Ec,Rx as Fc,_o as Gc,xx as Hc,Nx as Ic,Dx as Jc,Px as Kc,Mx as Lc,$x as Mc,jx as Nc,Gl as Oc,Lx as Pc,Fx as Qc,zx as Rc,yo as Sc,Ux as Tc,Hx as Uc,qx as Vc,Vx as Wc,Bx as Xc,ho as Yc,Wx as Zc,er as _c,Gx as $c,Kx as ad,Yx as bd,Xx as cd,Jx as dd,tr as ed,nN as fd,oN as gd,tn as hd,cN as id,go as jd,Ab as kd,Ib as ld,dN as md,Oe as nd,lN as od,Nb as pd,Mb as qd,Hb as rd,tu as sd,ou as td,qb as ud,Vb as vd,Bb as wd,bo as xd,mN as yd,ru as zd,nu as Ad,rr as Bd,hN as Cd,su as Dd,vo as Ed,Yb as Fd,Ke as Gd,nr as Hd,Zr as Id,Eo as Jd,Qr as Kd,au as Ld,bN as Md,en as Nd,Ds as Od,rn as Pd,uw as Qd,DN as Rd,hu as Sd,fw as Td,vw as Ud,kw as Vd,gu as Wd,Sw as Xd,Ow as Yd,bu as Zd,Et as _d,wu as $d,PN as ae,MN as be,Rs as ce,xs as de,Ao as ee,Su as fe,Ns as ge,Ou as he,HN as ie,kt as je,iD as ke,sD as le,zw as me,ar as ne,aD as oe,ju as pe,Gw as qe,cD as re,Uu as se,Fs as te,Ku as ue,Yu as ve,Xu as we,Ju as xe,To as ye,zs as ze,an as Ae,kD as Be,SD as Ce,cn as De,Us as Ee,Vs as Fe,OD as Ge,vv as He,AD as Ie,ID as Je,Co as Ke,Sv as Le,Ov as Me,ND as Ne,DD as Oe,Me as Pe,$e as Qe,un as Re,cr as Se,ne as Te,FD as Ue,zD as Ve,ae as We,Le as Xe,Y as Ye,lP as Ze,lr as _e,wE as $e,uP as af,fP as bf,vE as cf,mP as df,pP as ef,_P as ff,Tf as gf,OE as hf,IP as if,IE as jf,Rf as kf,TP as lf,Nf as mf,CE as nf,DE as of,Df as pf,$f as qf,jf as rf,NP as sf,JE as tf,_n as uf,Lo as vf,VP as wf,BP as xf,ha as yf,Vf as zf,y0 as Af,Bf,Wf as Cf,ga as Df,Gf as Ef,a1 as Ff,Kf as Gf,c1 as Hf,Yf as If,u1 as Jf,w0 as Kf,Xf as Lf,It as Mf,et as Nf,Jf as Of,tt as Pf,oe as Qf,va as Rf,Ae as Sf,ce as Tf,S1 as Uf,sm as Vf,am as Wf,cm as Xf,Ea as Yf,dm as Zf,lm as _f,O1 as $f,mm as ag,gn as bg,N1 as cg,D1 as dg,Sa as eg,Oa as fg,M1 as gg,Aa as hg,_m as ig,ck as jg,$1 as kg,Bo as lg,lk as mg,z1 as ng,Wo as og,rS as pg,Yo as qg,vS as rg,iM as sg,sM as tg,yr as ug,Tm as vg,Ct as wg,za as xg,lM as yg,uM as zg,qa as Ag,Dm as Bg,Ba as Cg,wM as Dg,vM as Eg,EM as Fg,kM as Gg,SM as Hg,OM as Ig,ec as Jg,tc as Kg,Um as Lg,MM as Mg,$M as Ng,jM as Og,LM as Pg,FM as Qg,zM as Rg,ic as Sg,Wm as Tg,UM as Ug,HM as Vg,qM as Wg,sO as Xg,VM as Yg,Ym as Zg,aO as _g,Fe as $g,ZM as ah,cO as bh,dO as ch,br as dh,Jm as eh,AO as fh,p$ as gh,_$ as hh,y$ as ih,FO as jh,ci as kh,Mt as lh,Sn as mh,HO as nh,qO as oh,Ap as ph,Er as qh,z$ as rh,gc as sh,ui as th,Ip as uh,bc as vh,U$ as wh,Cp as xh,Rp as yh,H$ as zh,On as Ah,An as Bh,Np as Ch,rA as Dh,fi as Eh,Q$ as Fh,wc as Gh,mi as Hh,ej as Ih,tj as Jh,$p as Kh,pi as Lh,Fp as Mh,jt as Nh,uA as Oh,rj as Ph,nj as Qh,at as Rh,Lt as Sh,yj as Th,hj as Uh,gj as Vh,qp as Wh,bj as Xh,wj as Yh,vj as Zh,Oc as _h,Cj as $h,dt as ai,Xj as bi,MA as ci,r_ as di,Jj as ei,vi as fi,fI as gi,w_ as hi,Zj as ii,Qj as ji,Ai as ki,ut as li,ki as mi,S_ as ni,sL as oi,kI as pi,SI as qi,aL as ri};
112
+ //# sourceMappingURL=chunk-QG4LMU7A.js.map