@unbrained/pm-cli 2026.11.8 → 2026.11.9

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 (127) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +15 -0
  3. package/dist/cli/main.js +1 -1
  4. package/dist/cli/runtime/projection-retry.js +1 -1
  5. package/dist/cli/runtime/read-output-mutation-retry.js +2 -0
  6. package/dist/cli-bundle/bundle-manifest.json +1 -1
  7. package/dist/cli-bundle/chunks/{chunk-NH7QX2M2.js → chunk-3BMIAI4P.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-RC6SSFOF.js → chunk-5VRJPPUC.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-XBUZENP4.js → chunk-6V4PGJBZ.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-YUTFMHSG.js → chunk-ASJZMYKM.js} +33 -33
  11. package/dist/cli-bundle/chunks/chunk-BLUCQ4T4.js +2 -0
  12. package/dist/cli-bundle/chunks/{chunk-4BMPGUTG.js → chunk-ELNWRSGZ.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-7GC6WIDR.js → chunk-EZRLW4R6.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-NKO42JMT.js → chunk-G6Q4VQSI.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-3A5DJZCC.js → chunk-GCPP37N6.js} +48 -48
  16. package/dist/cli-bundle/chunks/{chunk-C4MQFWCM.js → chunk-GDQ2T2OR.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-L5BU5FYN.js → chunk-GZVOOHTO.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-LI2HP5OX.js → chunk-IGT252ES.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-CP43BHX3.js → chunk-JK7O7MFO.js} +29 -29
  20. package/dist/cli-bundle/chunks/{chunk-AFZS6WFV.js → chunk-JYQXIC6C.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-PE6CZ3PE.js → chunk-LVDFPGD7.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-Z3LWNF7C.js → chunk-MSJ7IHMJ.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-MKW5LGVQ.js → chunk-O2M3TNFY.js} +6 -6
  24. package/dist/cli-bundle/chunks/chunk-UFIM5ZC5.js +6 -0
  25. package/dist/cli-bundle/chunks/{chunk-YGUUJHSR.js → chunk-VATZTJE3.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-DOHZKPPC.js → chunk-XKY4LUXN.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-7V6I6X4G.js → chunk-YK5GAWOT.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-S4IZIMAO.js → chunk-YV5ALMG2.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-HESIRIVX.js → chunk-Z3QEEOAM.js} +2 -2
  30. package/dist/cli-bundle/chunks/item-revision-Y5CE3EIN.js +2 -0
  31. package/dist/cli-bundle/chunks/item-transaction-XBIN4KYM.js +2 -0
  32. package/dist/cli-bundle/chunks/{mutation-admission-FJ3D66PV.js → mutation-admission-TAQN2AKK.js} +2 -2
  33. package/dist/cli-bundle/chunks/{register-list-query-GXP77CX7.js → register-list-query-XMQYFUFI.js} +2 -2
  34. package/dist/cli-bundle/chunks/{register-mutation-XJ2DROUM.js → register-mutation-OBVCFLDK.js} +2 -2
  35. package/dist/cli-bundle/chunks/{register-operations-O5LERXM7.js → register-operations-CGNFZ6DR.js} +2 -2
  36. package/dist/cli-bundle/chunks/{register-setup-4VOTYLL2.js → register-setup-LFB5ERXH.js} +2 -2
  37. package/dist/cli-bundle/chunks/{stage-ZDJL3FGL.js → stage-NQHF6JPC.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-Z2QWZRSL.js → chunk-2SQUWQP3.js} +18 -18
  39. package/dist/cli-bundle/focused-chunks/chunk-4FWMXQN3.js +12 -0
  40. package/dist/cli-bundle/focused-chunks/{chunk-4UOXVFJZ.js → chunk-AH5IST3V.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{chunk-6U5HP6L3.js → chunk-ALLOWZSH.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/{chunk-KNF2QTEZ.js → chunk-C3DO4ZGZ.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/{chunk-LTPT5TE7.js → chunk-CUGJ2DY2.js} +20 -20
  44. package/dist/cli-bundle/focused-chunks/{chunk-2A3QZELL.js → chunk-HLQOGAWG.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/{chunk-P4EHEH4C.js → chunk-HNFY3XLC.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-IB6TCE7N.js +2 -0
  47. package/dist/cli-bundle/focused-chunks/{chunk-5YPX3QKU.js → chunk-IS5FLEZW.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/{chunk-ULTSMJYF.js → chunk-J7PWHKZK.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/{chunk-P6TG33FV.js → chunk-JU62TKJP.js} +26 -26
  50. package/dist/cli-bundle/focused-chunks/{chunk-TSHRBPTI.js → chunk-LDMBNTOG.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-UUVRYIKA.js → chunk-LWMPQRJT.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/chunk-MYBKRV5R.js +2 -0
  53. package/dist/cli-bundle/focused-chunks/{chunk-KBRSA4OK.js → chunk-NUFO3OR6.js} +25 -25
  54. package/dist/cli-bundle/focused-chunks/{chunk-DIEBSC76.js → chunk-NZQYHPUN.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-3HFENALW.js → chunk-Q45LDP7P.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-O7K3X4LH.js → chunk-QWUWNFQO.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/{chunk-SZ2BKK3M.js → chunk-RNZUORGI.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{chunk-WPXMPGTY.js → chunk-UIKLNSW3.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{chunk-I4YUZW3J.js → chunk-XLSTFUXM.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/item-revision-M6FOLME2.js +2 -0
  61. package/dist/cli-bundle/focused-chunks/{item-transaction-Q2Z7DDCR.js → item-transaction-H6VA5JGB.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{mutation-admission-QWC6MLTZ.js → mutation-admission-PRTQWQK6.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{stage-NKH5SKSZ.js → stage-7T77PSJD.js} +2 -2
  64. package/dist/cli-bundle/main.js +26 -26
  65. package/dist/cli-bundle/sdk-authoring.js +1 -1
  66. package/dist/cli-bundle/sdk-contracts.js +4 -4
  67. package/dist/cli-bundle/sdk-core.js +1 -1
  68. package/dist/cli-bundle/sdk-governance.js +1 -1
  69. package/dist/cli-bundle/sdk-graph.js +1 -1
  70. package/dist/cli-bundle/sdk-merge.js +57 -57
  71. package/dist/cli-bundle/sdk-query.js +1 -1
  72. package/dist/cli-bundle/sdk-runtime.js +1 -1
  73. package/dist/cli-bundle/sdk-testing.js +1 -1
  74. package/dist/cli-bundle/sdk.js +9 -9
  75. package/dist/core/item/item-format.d.ts +9 -1
  76. package/dist/core/item/item-format.js +1 -1
  77. package/dist/core/output/output.d.ts +9 -2
  78. package/dist/core/output/output.js +4 -4
  79. package/dist/core/search/corpus.js +1 -1
  80. package/dist/mcp/tool-definitions.js +1 -1
  81. package/dist/sdk/annotations.js +1 -1
  82. package/dist/sdk/generated/error-code-catalog-rows.js +1 -1
  83. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  84. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  85. package/dist/sdk/lifecycle/item-revision.d.ts +6 -0
  86. package/dist/sdk/lifecycle/item-revision.js +1 -1
  87. package/dist/sdk/public-surface.json +1 -1
  88. package/dist/sdk/query/get-facet-roots.js +2 -0
  89. package/dist/sdk/query/get.js +1 -1
  90. package/dist/sdk/read-output/positional-rows.js +2 -0
  91. package/dist/sdk/read-output-contracts.d.ts +4 -0
  92. package/dist/sdk/read-output-contracts.js +1 -1
  93. package/dist/sdk/runtime/actions.js +1 -1
  94. package/docs/AGENT_OUTPUT_ENCODINGS.md +16 -0
  95. package/docs/README.md +1 -1
  96. package/docs/READ_OUTPUT_CONTRACTS.md +21 -0
  97. package/docs/RELEASING.md +27 -5
  98. package/marketplace.json +1 -1
  99. package/package.json +2 -1
  100. package/packages/pm-beads/package.json +1 -1
  101. package/packages/pm-calendar/package.json +1 -1
  102. package/packages/pm-command-kit/package.json +1 -1
  103. package/packages/pm-digital-twin/package.json +1 -1
  104. package/packages/pm-governance-audit/package.json +1 -1
  105. package/packages/pm-guide-shell/package.json +1 -1
  106. package/packages/pm-kanban/package.json +1 -1
  107. package/packages/pm-lifecycle-hooks/package.json +1 -1
  108. package/packages/pm-linked-test-adapters/package.json +1 -1
  109. package/packages/pm-search-advanced/package.json +1 -1
  110. package/packages/pm-templates/package.json +1 -1
  111. package/packages/pm-todos/package.json +1 -1
  112. package/packages/pm-vcs/package.json +1 -1
  113. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  114. package/plugins/pm-claude/package.json +1 -1
  115. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  116. package/plugins/pm-codex/package.json +1 -1
  117. package/plugins/pm-codex/plugin.json +1 -1
  118. package/runtime-dependencies.json +1 -1
  119. package/dist/cli-bundle/chunks/chunk-JAE5MWLX.js +0 -2
  120. package/dist/cli-bundle/chunks/chunk-LLTRUVKK.js +0 -6
  121. package/dist/cli-bundle/chunks/item-revision-TUGZYYXX.js +0 -2
  122. package/dist/cli-bundle/chunks/item-transaction-2RRBAQN3.js +0 -2
  123. package/dist/cli-bundle/focused-chunks/chunk-PL6EO4GJ.js +0 -2
  124. package/dist/cli-bundle/focused-chunks/chunk-PSLDGAEY.js +0 -12
  125. package/dist/cli-bundle/focused-chunks/chunk-UNNLBJRI.js +0 -2
  126. package/dist/cli-bundle/focused-chunks/item-revision-XNSRDTFB.js +0 -2
  127. package/docs/ECOSYSTEM_PLANNING_REVIEW.md +0 -274
@@ -1,26 +1,26 @@
1
- import{A as h,C as zn,D as qn,E as J,a as X,b as Un,c as Do,e as $t,f as Mt,g as jt,h as Po,i as Lt,j as Me,k as $o,p as Ft,q as Ut,t as rt,z as y}from"./chunk-G6ERMFJ5.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]="628615ea-5be3-5753-a6c5-3eba8400a8da")}catch{}})();function zt(e,t,n){if(e===t)return 0;if(Math.abs(e.length-t.length)>n)return null;let r=t.length+1,o=new Array(r),i=new Array(r),s=new Array(r);for(let c=0;c<r;c+=1)o[c]=0,i[c]=c;for(let c=1;c<=e.length;c+=1){s[0]=c;let d=s[0];for(let l=1;l<=t.length;l+=1){let f=e[c-1]===t[l-1]?0:1,u=i[l-1]+f,m=s[l-1]+1,p=i[l]+1,_=Math.min(u,m,p);c>1&&l>1&&e[c-1]===t[l-2]&&e[c-2]===t[l-1]&&(_=Math.min(_,o[l-2]+1)),s[l]=_,_<d&&(d=_)}if(d>n)return null;for(let l=0;l<r;l+=1)o[l]=i[l],i[l]=s[l]}let a=i[t.length];return a<=n?a:null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b181d38e-7120-5d34-98d9-fd9b4619b9d9")}catch{}})();var ud=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],Mo=ud,jy=["draft","open","in_progress","blocked","closed","canceled"],Ly=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],jo=["string","number","boolean","string_array","array","object"],Fy=["create","update","update_many","list","search","calendar","context"],Uy=["allow","warn","reject"],zy=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],qy=["project","global"],By=["low","medium","high","critical"],Vy=["low","medium","high","critical"],Gy=["low","medium","high"];var Wy=["minimal","default","strict","custom"],Ky=["none","warn","strict"],Hy=["progressive","strict"],Yy=["off","warn","strict"],Xy=["off","warn","strict"],Jy=["off","warn","strict"];var Qy=["daily","weekly","monthly","yearly"],fd=["mon","tue","wed","thu","fri","sat","sun"];function Zy(e){return fd.indexOf(e)}var eh=["draft","research","review","approved","executing","paused","completed","superseded"],th=["pending","in_progress","completed","blocked","skipped","superseded"],nh=["codex","claude-code","cursor","generic"],rh=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],oh=["brief","standard","deep","full"],ih=["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]="67511565-01f8-58a6-ad06-45b5d0ce831b")}catch{}})();var md=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 pd(e){return{unknownKeys:Object.keys(e).filter(t=>!md.has(t)).sort((t,n)=>t>n?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function _d(e){let t=pd(e),n=t.unknownKeys.map(r=>({code:"manifest_unknown_key",path:r,...r==="compatibility"?{suggested_key:"pm_min_version"}:{},message:r==="compatibility"?'Manifest key "compatibility" is ignored; declare the canonical pm_min_version and optional pm_max_version fields instead.':`Manifest key "${r}" is not part of the extension manifest contract and will be ignored.`}));return t.missingVersionBounds&&n.push({code:"no_version_bounds_declared",path:"$",suggested_key:"pm_min_version",message:"No canonical pm version bounds are declared; add pm_min_version so compatibility intent is explicit."}),{ok:n.length===0,findings:n}}function Lo(e,t,n){return _d(n).findings.map(r=>r.code==="manifest_unknown_key"?`extension_manifest_unknown_key:${e}:${t.name}:key=${r.path}${r.suggested_key?`:suggested=${r.suggested_key}`:""}`:`extension_manifest_no_version_bounds:${e}:${t.name}:suggested=pm_min_version`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2ea7934f-4751-5245-a5ba-492681aa3794")}catch{}})();var Bn=[{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 Vt(e){return e.trim().toLowerCase().replaceAll("-","_")}function gd(e){if(e===void 0)return;let t=Vt(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function Gn(e,t=new Set){if(e===null||typeof e!="object"||t.has(e))return e;if(t.add(e),Array.isArray(e)){for(let n of e)Gn(n,t);return Object.freeze(e)}for(let n of Object.values(e))Gn(n,t);return Object.freeze(e)}function yd(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 hd(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 bd(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 wd(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=Vt(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 vd(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 Ed(e,t){if(e.payloadSchema!==void 0&&(typeof e.payloadSchema!="object"||e.payloadSchema===null||Array.isArray(e.payloadSchema)))throw new TypeError(`Invalid relationship payload schema for ${t}`);if(e.aliases!==void 0&&(!Array.isArray(e.aliases)||e.aliases.some(n=>typeof n!="string")))throw new TypeError(`Invalid relationship aliases for ${t}`)}function kd(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var Wn=class{#e=new Map;#n=new Map;constructor(t=Bn){for(let n of t)this.register(n)}register(t){let n=wd(t);if(vd(t,n),Ed(t,n),yd(t,n),hd(t,n),bd(t,n),this.#e.has(n)||this.#n.has(n))throw new TypeError(`Relationship kind already registered: ${n}`);let r=gd(t.inverse),o=[...new Set((t.aliases??[]).map(Vt))].sort();for(let s of o){if(!/^[a-z][a-z0-9_]*$/.test(s))throw new TypeError(`Invalid relationship alias: ${s}`);if(s===n||this.#e.has(s)||this.#n.has(s))throw new TypeError(`Relationship alias already registered: ${s}`)}let i=Object.freeze({...t,kind:n,traversal:kd(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:r,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?Gn(structuredClone(t.payloadSchema)):void 0});this.#e.set(n,i);for(let s of o)this.#n.set(s,n);return this}resolve(t){if(typeof t!="string")return;let n=Vt(t);return this.#e.get(this.#n.get(n)??n)}require(t){let n=this.resolve(t);if(!n)throw new TypeError(`Unknown relationship kind: ${t}`);return n}list(){return Object.freeze([...this.#e.values()].sort((t,n)=>t.kind.localeCompare(n.kind)))}};function Kn(){return new Wn}var ge=Kn();function uh(e){return ge.require(e).kind}function fh(e){return ge.resolve(e)?.kind}function mh(e,t=ge){return t.resolve(e)?.ordering===!0}function Od(e,t,n,r=ge){let o=ot(e),i=ot(t);if(!o||!i)throw new TypeError("Relationship endpoint must not be empty");let s=r.require(n);if(o===i&&!s.allowSelf)throw new TypeError(`Self relationship is not allowed for ${s.kind}`);return s}function qt(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function Sd(e,t,n){let r=typeof e.source=="string"?e.source.trim():"",o=typeof e.target=="string"?e.target.trim():"";if(!t.has(r)||!t.has(o))throw new TypeError(`Relationship endpoint not found: ${r} -> ${o}`);let i=Od(r,o,e.kind,n),s=Object.freeze({...e,source:r,target:o,kind:i.kind}),a=i.direction==="undirected"?[r,o].sort().join("\0"):`${r}\0${o}`;return{edge:s,identity:`${i.kind}\0${a}`}}function Bt(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function ot(e){return typeof e=="string"?e.trim():""}function Vn(e,t){let n=ot(e);return n&&t.has(n)?n:void 0}function Ad(e,t,n){let r=[t],o=t;for(;o!==e;)o=n.get(o),r.push(o);return r.reverse()}var Fo=class e{#e;#n;#o;#r;#s=new Map;#a=new Map;constructor(t,n,r=ge){this.#e=r,this.#n=new Set([...t].filter(i=>typeof i=="string").map(i=>i.trim()).filter(Boolean)),this.#o=Object.freeze([...this.#n].sort());let o=new Map;for(let i of n){let{edge:s,identity:a}=Sd(i,this.#n,r);o.set(a,s)}this.#r=Object.freeze([...o.values()].sort(qt));for(let i of this.#r)Bt(this.#s,i.source,i),Bt(this.#a,i.target,i),r.require(i.kind).direction==="undirected"&&(Bt(this.#s,i.target,i),Bt(this.#a,i.source,i))}static fromItems(t,n=ge){let r=new Set(t.map(i=>ot(i.id)).filter(Boolean)),o=[];for(let i of t){let s=ot(i.id);if(!s)continue;let a=Vn(i.parent,r);a&&o.push({source:s,target:a,kind:"parent"});let c=Vn(i.blocked_by,r);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let d of i.dependencies??[]){let l=Vn(d.id,r);l&&n.resolve(d.kind)&&o.push({source:s,target:l,kind:d.kind,createdAt:d.created_at,author:d.author})}}return new e(r,o,n)}edges(){return this.#r}incidentEdges(t){this.#i(t);let n=this.#s.get(t)??[],r=this.#a.get(t)??[];if(n.length===0)return Object.freeze([...r]);if(r.length===0)return Object.freeze([...n]);let o=[],i=0,s=0;for(;i<n.length||s<r.length;){let a=n[i],c=r[s],d=a===void 0?c:c===void 0||qt(a,c)<=0?a:c;o.at(-1)!==d&&o.push(d),a===d&&(i+=1),c===d&&(s+=1)}return Object.freeze(o)}nodes(){return this.#o}hasNode(t){return this.#n.has(t)}registry(){return this.#e}#i(t){if(!this.#n.has(t))throw new TypeError(`Relationship node not found: ${t}`)}#c(t,n){if(!n)return!0;let r=this.#e.require(t.kind);return n.has(t.kind)||r.inverse!==void 0&&n.has(r.inverse)}#t(t,n,r){let o=[...n==="incoming"?[]:this.#s.get(t)??[],...n==="outgoing"?[]:this.#a.get(t)??[]];return[...new Set(o)].filter(i=>this.#c(i,r)).map(i=>({id:i.source===t?i.target:i.source,edge:i})).sort((i,s)=>i.id.localeCompare(s.id)||qt(i.edge,s.edge))}adjacency(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=[...new Set(o.map(c=>c.id))],a=s.slice(0,i);return{value:a,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:a.length<s.length,nextCursor:a.at(-1)}}}neighborEdges(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(a=>this.#e.require(a).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=o.slice(0,i);return{value:s,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:s.length<o.length,nextCursor:s.at(-1)?.id}}}closure(t,n={}){this.#i(t);let r=n.kinds?new Set(n.kinds.map(m=>this.#e.require(m).kind)):void 0,o=n.direction??"outgoing",i=n.limit??Number.POSITIVE_INFINITY,s=n.maxDepth??Number.POSITIVE_INFINITY,a=new Set([t]),c=[],d=[{id:t,depth:0}],l=0,f=0,u=!1;e:for(let m=0;m<d.length;m+=1){n.signal?.throwIfAborted();let p=d[m];l+=1;let _=this.#t(p.id,o,r);if(f+=_.length,p.depth>=s){_.some(g=>!a.has(g.id))&&(u=!0);continue}for(let g of _)if(!a.has(g.id)){if(c.length>=i){u=!0;break e}a.add(g.id),c.push(g.id),d.push({id:g.id,depth:p.depth+1})}}return{value:c,meta:{visitedNodes:l,inspectedEdges:f,truncated:u,nextCursor:c.at(-1)}}}shortestPath(t,n,r={}){if(this.#i(t),this.#i(n),t===n)return{value:[t],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}};let o=r.kinds?new Set(r.kinds.map(m=>this.#e.require(m).kind)):void 0,i=r.direction??"outgoing",s=r.maxDepth??Number.POSITIVE_INFINITY,a=[{id:t,depth:0}],c=new Map,d=new Set([t]),l=0,f=0,u=!1;for(let m=0;m<a.length;m+=1){r.signal?.throwIfAborted();let p=a[m];l+=1;let _=this.#t(p.id,i,o);if(f+=_.length,p.depth>=s){_.some(g=>!d.has(g.id))&&(u=!0);continue}for(let g of _)if(!d.has(g.id)){if(c.set(g.id,p.id),g.id===n)return{value:Ad(t,n,c),meta:{visitedNodes:l,inspectedEdges:f,truncated:!1}};d.add(g.id),a.push({id:g.id,depth:p.depth+1})}}return{value:[],meta:{visitedNodes:l,inspectedEdges:f,truncated:u}}}subgraph(t,n={}){let r=this.closure(t,n),o=[t,...r.value].sort(),i=new Set(o),s=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,a=new Set;for(let c of o)for(let d of this.#s.get(c)??[])i.has(d.source)&&i.has(d.target)&&this.#c(d,s)&&a.add(d);return{value:{nodes:o,edges:[...a].sort(qt)},meta:r.meta}}};function ph(e,t,n=ge){return{source:e,target:t.id,kind:n.require(t.kind).kind,createdAt:t.created_at,author:t.author}}import xd from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0ca7f52c-fb31-5cd9-b689-a918f4e61816")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="75f74db3-9547-5c78-8561-f371c016b90d")}catch{}})();function re(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Cd(e){let t=e.key.trim();if(t.length===0)return null;let n=re(e.aliases),r=e.description?.trim();return{key:t,values:re(e.values),required:e.required===!0?!0:void 0,aliases:n.length>0?n:void 0,description:r&&r.length>0?r:void 0}}var Td=e=>e,zo=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function Id(e,t){let n=t(e.command);if(n===null)return null;let r=e.option.trim();return r.length===0?null:{command:n,option:r,required:e.required,visible:e.visible,enabled:e.enabled}}function Rd(e,t){let n=new Map;for(let r of e??[]){let o=Id(r,t);o&&n.set(`${o.command}:${o.option.toLowerCase()}`,o)}return[...n.values()].sort((r,o)=>r.command===o.command?r.option.localeCompare(o.option):r.command.localeCompare(o.command))}function Uo(e,t){return t?re(e):void 0}function Hn(e){let t=e?.trim();return t&&t.length>0?t:void 0}function Yn(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 qo(e,t={}){let n=t.resolvePolicyCommand??Td,r=e.name.trim();if(r.length===0)return null;let o=e.required_create_fields!==void 0,i=e.required_create_repeatables!==void 0,s=e.options!==void 0,a=e.command_option_policies!==void 0,c=re(e.aliases),d=(e.options??[]).map(f=>Cd(f)).filter(f=>f!==null).sort((f,u)=>f.key.localeCompare(u.key)),l=Rd(e.command_option_policies,n);return{name:r,description:Hn(e.description),default_status:Hn(e.default_status),...e.execution_role===void 0?{}:{execution_role:Yn(e.execution_role)},folder:Hn(e.folder),aliases:c.length>0?c:void 0,required_create_fields:Uo(e.required_create_fields,o),required_create_repeatables:Uo(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 Nd=Object.freeze({decision:"human",milestone:"gate"}),Dd=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],Pd=["dep","comment","note","learning","file","test","doc"],Vo=["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"],$d=["title","description","type","status","priority","tags","body",...Vo,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],Md=["title","description","body","status","closeReason","priority","type","tags",...Vo,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],Go={"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"},jd={...Go},Ld={...Go},Wo=[["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"]],Ko=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function Ho(e){return Object.fromEntries(e)}var Fd=Ho([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...Wo,["author","--author"],["message","--message"],["dep","--dep"],...Ko]),Ud=Ho([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...Wo,...Ko,["author","--author"],["message","--message"],["force","--force"]]);function zd(e){return e.trim().replace(/^--+/,"").toLowerCase()}function qd(e){return e==="create"?$d:Md}function Bd(e){return e==="create"?jd:Ld}function Yo(e,t){let n=zd(t);return n.length===0?void 0:Bd(e)[n]||qd(e).find(r=>r.toLowerCase()===n)}function kh(e,t){return(e==="create"?Fd:Ud)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function Jn(e){let t=Gd(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function Vd(e){let t=e.trim(),n=t.replaceAll("\\","/").replace(/^\/+/,""),r=xd.posix.normalize(n);if(t.includes("\0")||/^[A-Za-z]:/.test(r)||r==="."||r===".."||r.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return r}function Gd(e){let t=e.trim().toLowerCase(),n="",r=!1;for(let o of t){let i=o.charCodeAt(0),s=i>=97&&i<=122,a=i>=48&&i<=57;if(s||a){r&&n.length>0&&(n+="-"),n+=o,r=!1;continue}n.length>0&&(r=!0)}return n}function Wd(e){return qo(e,{resolvePolicyCommand:zo})}function it(e,t){let n=e[t];return Array.isArray(n)?n.filter(r=>typeof r=="string"):void 0}function Kd(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:it(t,"values")??[],required:t.required===void 0?void 0:!!t.required,aliases:it(t,"aliases"),description:typeof t.description=="string"?t.description:void 0}}function Hd(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;if(typeof t.command!="string"||typeof t.option!="string")return null;let n=t.command.trim().toLowerCase();return n!=="create"&&n!=="update"?null:{command:n,option:t.option,required:t.required===void 0?void 0:!!t.required,visible:t.visible===void 0?void 0:!!t.visible,enabled:t.enabled===void 0?void 0:!!t.enabled}}function Yd(e){if(Array.isArray(e.options))return e.options.map(t=>Kd(t)).filter(t=>t!==null)}function Xd(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>Hd(t)).filter(t=>t!==null)}function Jd(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e,n=typeof t.name=="string"?t.name:"";if(n.trim().length===0)return null;let r=typeof t.folder=="string"?t.folder:void 0,o=typeof t.description=="string"?t.description:void 0,i=typeof t.default_status=="string"?t.default_status:void 0;return{name:n,description:o,default_status:i,execution_role:Yn(t.execution_role),folder:r,aliases:it(t,"aliases"),required_create_fields:it(t,"required_create_fields"),required_create_repeatables:it(t,"required_create_repeatables"),options:Yd(t),command_option_policies:Xd(t)}}function Qd(e,t){return e.required_create_fields?re(e.required_create_fields):t?.required_create_fields??[]}function Zd(e,t){return e.required_create_repeatables?re(e.required_create_repeatables):t?.required_create_repeatables??[]}function el(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function tl(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function nl(e,t){let n=t?.name??e.name,r=e.description??t?.description,o=e.default_status??t?.default_status,i=Vd(e.folder??t?.folder??Jn(n)),s={name:n,execution_role:e.execution_role,folder:i,aliases:re([...t?.aliases??[],...e.aliases??[]]),required_create_fields:Qd(e,t),required_create_repeatables:Zd(e,t),options:el(e,t),command_option_policies:tl(e,t)};return r&&(s.description=r),o&&(s.default_status=o),s}function Bo(e,t){for(let n of e){let r=Wd(n);if(!r)continue;let o=r.name.toLowerCase(),i=t.get(o);t.set(o,nl({...r,execution_role:r.execution_role??i?.execution_role},i))}}function rl(e){if(!e)return[];let t=[];for(let n of e.item_types??[]){let r=n.types;if(Array.isArray(r))for(let o of r){let i=Jd(o);i&&t.push(i)}}return t}function Oh(e,t=null){let n=new Map;for(let c of Mo)n.set(c.toLowerCase(),{name:c,execution_role:Nd[c.toLowerCase()]??"agent",folder:rt[c],aliases:[],required_create_fields:[...Dd],required_create_repeatables:[...Pd],options:[],command_option_policies:[]});Bo(e.item_types?.definitions??[],n),Bo(rl(t),n);let r=[...n.values()].sort((c,d)=>c.name.localeCompare(d.name)),o={},i={},s={};for(let c of r){o[c.name]=c,s[c.name]=c.folder,i[c.name.toLowerCase()]=c.name;for(let d of c.aliases)i[d.toLowerCase()]=c.name}let a=[...new Set(r.map(c=>c.folder))].sort((c,d)=>c.localeCompare(d));return{types:r.map(c=>c.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function ol(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function il(e,t){let n=ol(e,t);if(n)return t.by_type[n]}function sl(e,t,n,r){for(let o of r){let i=Yo(n,o);if(i){e.required.add(i);continue}e.errors.push(`Unsupported base required option "${o}" for command "${n}" on type "${t.name}"`)}}function Xn(e,t,n){if(n){e.add(t);return}e.delete(t)}function al(e,t,n,r){let o=Yo(n,r.option);if(!o){e.errors.push(`Unsupported command_option_policies option "${r.option}" for command "${n}" on type "${t.name}"`);return}r.required!==void 0&&Xn(e.required,o,r.required),r.visible!==void 0&&Xn(e.hidden,o,!r.visible),r.enabled!==void 0&&Xn(e.disabled,o,!r.enabled)}function cl(e,t,n){for(let r of t.command_option_policies)r.command===n&&al(e,t,n,r)}function dl(e,t,n){for(let r of e.required)e.disabled.has(r)&&e.errors.push(`Option "${r}" cannot be both required and disabled for command "${n}" on type "${t.name}"`)}function Sh(e,t,n){let r=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:r};return sl(a,e,t,n),cl(a,e,t),dl(a,e,t),{required:[...o],hidden:[...i].sort((c,d)=>c.localeCompare(d)),disabled:[...s].sort((c,d)=>c.localeCompare(d)),errors:r}}function ll(e){let t=new Map;for(let n of e.options){t.set(n.key.toLowerCase(),n);for(let r of n.aliases??[])t.set(r.toLowerCase(),n)}return t}function ul(e,t,n){let r=e.values;if(r.length===0)return t;let o=new Map(r.map(i=>[i.toLowerCase(),i])).get(t.toLowerCase());if(!o){n.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${r.join(", ")}`);return}return o}function Ah(e,t,n){let r=il(e,n);if(!r)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=ll(r),s={};for(let[c,d]of Object.entries(t??{})){let l=c.trim(),f=d.trim();if(l.length===0){o.push("type option keys must not be empty");continue}if(f.length===0){o.push(`type option "${l}" must not be empty`);continue}let u=i.get(l.toLowerCase());if(!u){let p=r.options.map(_=>_.key).join(", ");o.push(r.options.length>0?`Unknown type option "${l}" for type "${r.name}". Allowed: ${p}`:`Type "${r.name}" does not define any configurable type options`);continue}let m=ul(u,f,o);m!==void 0&&(s[u.key]=m)}for(let c of r.options)c.required&&!(c.key in s)&&o.push(`Missing required type option "${c.key}" for type "${r.name}"`);let a=Object.keys(s).sort((c,d)=>c.localeCompare(d));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(c=>[c,s[c]])),errors:o}}import{readFileSync as fl,readdirSync as Ih,realpathSync as Xo,statSync as Qo}from"node:fs";import ml from"node:os";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]="7f4b8abe-997c-549c-9791-87c78506c8b5")}catch{}})();var pl={json_markdown:".md",toon:".toon"},_l={".md":"json_markdown",".toon":"toon"};var Mh=[".md",".toon"];function Gt(e){try{return Qo(e),!0}catch{return!1}}function gl(e){let t=E.resolve(e),n=[];for(;E.dirname(t)!==t;)try{return E.join(Xo(t),...n)}catch(r){if(!qn(r))throw r;n.unshift(E.basename(t)),t=E.dirname(t)}return E.join(Xo(t),...n)}function yl(e){try{return Qo(e),!0}catch(t){if(qn(t))return!1;throw t}}function hl(e){try{let t=JSON.parse(fl(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function bl(e){let t=gl(e);for(;;){let n=E.join(t,Ft),r=E.join(n,Ut);if(Gt(r))return n;let o=E.join(t,Ut);if(Gt(o)&&hl(o))return t;if(yl(E.join(t,".git")))return n;let i=E.dirname(t);if(i===t)return;t=i}}function Qn(e){return bl(e)??E.resolve(e,Ft)}function Zo(e,t){let n=process.env.PM_PATH,r=t?.trim()||n?.trim();if(r){let o=E.resolve(e,r);if(!Gt(Jo(o))){let i=E.join(o,Ft);if(Gt(Jo(i)))return i}return o}return Qn(e)}function ei(e){let t=E.resolve(e),n=E.dirname(t);return E.basename(t)==="pm"&&E.basename(n)===".agents"?E.dirname(n):t}function ti(e){let t=process.env.PM_GLOBAL_PATH?.trim(),n=t&&t.length>0?t:E.join(ml.homedir(),".pm-cli");return E.resolve(e,n)}function Jo(e){return E.join(e,Ut)}function wl(e,t,n=rt){let r=n[t]??Jn(t);return E.join(e,r)}function jh(e,t,n,r="toon",o=rt){return E.join(wl(e,t,o),`${n}${pl[r]}`)}function Lh(e){let t=e.replaceAll("\\","/"),n=E.posix.extname(t).toLowerCase();return _l[n]??null}function Fh(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new h("Invalid history item id: expected a single filename.",y.USAGE);return E.join(e,"history",`${t}.jsonl`)}function Zn(e,t){return E.join(e,"locks",`${t}.lock`)}function Uh(e){return E.join(e,"runtime")}import vl 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 El(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 kl(e){let t=Object.keys(e).sort(),n={};for(let r of t){let o=e[r];o!==void 0&&(n[r]=Wt(o))}return n}function Wt(e){let t=El(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(r=>Wt(r));if(e instanceof Date)return e.toISOString();let n=e;if(typeof n.toJSON=="function"){let r=n.toJSON();if(r!==e)return Wt(r)}return kl(e)}function ye(e){return JSON.stringify(Wt(e))}function ni(e,t,n,r){for(let o=0;o<t.length;o+=1)if(!n.has(o)&&r(e,t[o]))return n.add(o),!0;return!1}function Ol(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function Sl(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function Al(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let n=[...t],r=new Set;for(let o of e)if(!ni(o,n,r,K))return!1;return!0}function Cl(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let n=[...t.entries()],r=new Set;for(let[o,i]of e.entries())if(!ni([o,i],n,r,([s,a],[c,d])=>K(s,c)&&K(a,d)))return!1;return!0}function Tl(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,r)=>K(n,t[r]))}function Il(e,t){let n=Object.keys(e).sort((o,i)=>o.localeCompare(i)),r=Object.keys(t).sort((o,i)=>o.localeCompare(i));if(n.length!==r.length)return!1;for(let o=0;o<n.length;o+=1){let i=n[o];if(i!==r[o]||!K(e[i],t[i]))return!1}return!0}var Rl=[Ol,Sl,Al,Cl,Tl];function K(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let n of Rl){let r=n(e,t);if(r!==void 0)return r}return Il(e,t)}function Bh(e){return vl.createHash("sha256").update(e,"utf8").digest("hex")}function Vh(e,t){let n={};for(let o of t){let i=e[o];i!==void 0&&(n[o]=i)}let r=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of r){let i=e[o];i!==void 0&&(n[o]=i)}return n}import{createHash as oi}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 xl=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],ri=256,er=64;function z(e){throw new h(`Invalid workflow policy: ${e}`,y.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function Q(e,t,n){if(typeof e!="object"||e===null||Array.isArray(e))return z(`${n} must be an object`);let r=e;return Object.keys(r).some(o=>!t.includes(o))?z(`${n} contains an unknown key`):r}function he(e,t,n=128){return typeof e!="string"||!e.trim()||e.length>n?z(`${t} must be nonempty text of at most ${n} characters`):e.trim()}function st(e,t){if(!Array.isArray(e)||e.length===0||e.length>er)return z(`${t} requires 1-${er} terms`);let n=e.map(r=>he(r,t));return t==="fields"&&n.some(r=>!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$/.test(r)||r.split(".").some(o=>["__proto__","constructor","prototype"].includes(o)))?z("fields must be safe metadata paths of at most eight segments"):[...new Set(n)]}function Nl(e){let t=Q(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(Q(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>er?z("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(n=>!Array.isArray(n)||n.length!==2?z("transition pairs need two statuses"):[he(n[0],"from"),he(n[1],"to")])}):t.kind==="authors"?(Q(t,["kind","authors"],"authors rule"),{kind:"authors",authors:st(t.authors,"authors")}):t.kind==="require_fields"?(Q(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:st(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(Q(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:st(t.fields,"fields"),authors:st(t.authors,"authors")}):z("unknown rule kind")}function Dl(e){let t={},n=Q(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let r of["types","tags","statuses","operations","parents"])n[r]!==void 0&&(t[r]=st(n[r],r));if(n.dependency!==void 0){let r=Q(n.dependency,["kind","id"],"dependency");t.dependency={kind:he(r.kind,"dependency kind"),...r.id===void 0?{}:{id:he(r.id,"dependency id")}}}return t}function Pl(e){let t=Q(e,["id","description","subject","effect","rule"],"policy"),n=he(t.id,"id");return/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(n)?t.effect!==void 0&&(typeof t.effect!="string"||!["advise","warn","refuse"].includes(t.effect))?z("effect must be advise, warn, or refuse"):{id:n,rule:Nl(t.rule),...t.subject===void 0?{}:{subject:Dl(t.subject)},...t.description===void 0?{}:{description:he(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:z("id must be a stable token")}function $l(e){let t=Q(e,["version","enforcement","policies"],"document");if(t.version!==1)return z("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return z("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>ri)return z(`policies must contain at most ${ri} declarations`);let n=t.policies.map(Pl);return new Set(n.map(r=>r.id)).size!==n.length?z("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:n}}function Kt(e,t){let n=e;for(let r of t.split(".")){if(typeof n!="object"||n===null||!Object.hasOwn(n,r))return;n=n[r]}return n}function Ml(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 ii(e){return oi("sha256").update(ye(e)).digest("hex")}function jl(e,t){let n=e.rule.kind==="approval"?e.rule.fields:[];return oi("sha256").update(ye({id:t.id,fields:n.map(r=>[r,Kt(t,r)])})).digest("hex")}function Ll(e,t){return Array.isArray(t)&&t.some(n=>typeof n=="object"&&n!==null&&"kind"in n&&n.kind===e.kind&&(e.id===void 0||"id"in n&&n.id===e.id))}function Fl(e,t,n){return!(e.types&&!e.types.some(r=>r.toLowerCase()===String(t.type).toLowerCase())||e.statuses&&!e.statuses.includes(String(t.status))||e.operations&&!e.operations.includes(n)||e.parents&&!e.parents.includes(String(t.parent))||e.tags&&(!Array.isArray(t.tags)||!e.tags.some(r=>t.tags.includes(r)))||e.dependency&&!Ll(e.dependency,t.dependencies))}function Ul(e,t){if(t.completeness_only&&(e.rule.kind!=="require_fields"||e.subject?.operations!==void 0)||e.rule.kind==="approval"&&t.before===null)return!1;let n=e.subject??{},r=t.after?.status??t.before?.status;return[t.before,t.after].some(o=>o!==null&&Fl(n,{...o,status:r},t.operation))}function zl(e,t,n,r){let o=["type","tags","parent","dependencies"].some(i=>!K(t.before?.[i],t.after?.[i]));return t.after&&(t.completeness_only||n||r||o)?e.filter(i=>!Ml(Kt(t.after,i))):[]}function ql(e,t,n,r){let o=t.after??t.before,i=jl(e,o);return t.approvals?.some(s=>s.policy_fingerprint===r&&s.content_fingerprint===i&&s.author!==t.author&&n.includes(s.author))??!1}function Bl(e,t,n){let r=e.rule,o=t.before?.status!==t.after?.status,i="fields"in r&&r.fields.some(s=>!K(Kt(t.before,s),Kt(t.after,s)));switch(r.kind){case"require_fields":{let s=zl(r.fields,t,o,i);return{satisfied:s.length===0,missing_fields:s,remediation:"Supply the declared required fields before this lifecycle transition."}}case"transition":return{satisfied:!o||r.allowed.some(([s,a])=>s===String(t.before?.status??"$create")&&a===String(t.after?.status??"$delete")),missing_fields:[],remediation:"Choose a declared allowed transition; inspect pm schema policies."};case"authors":return{satisfied:r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared workflow actor perform this operation."};case"field_writers":return{satisfied:!i||r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared field writer change the protected fields."};case"approval":return{satisfied:!o||ql(e,t,r.authors,n),missing_fields:[],remediation:`Record an independent approval with pm schema policy-approve <item-id> --policy ${e.id} after preparing the reviewed fields.`}}}function si(e,t,n){let r=e.policies.filter(o=>Ul(o,t)).map(o=>{let i=o.effect??"advise",s=n(o);return{policy_id:o.id,policy_fingerprint:s,rule:o.rule.kind,effect:i==="refuse"&&e.enforcement!=="refuse"?"warn":i,...Bl(o,t,s)}});return{allowed:!r.some(o=>!o.satisfied&&o.effect==="refuse"),decisions:r,warnings:r.filter(o=>!o.satisfied).map(o=>`workflow_policy:${o.effect}:${o.policy_id}:${o.rule}`)}}function Xh(e,t){return si(e,t,ii)}function Jh(e){let t=$l(e),n=new Map(t.policies.map(r=>[r,ii(r)]));return r=>si(t,r,o=>n.get(o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="451b262c-a9b6-5f1c-b397-2686a5fd953a")}catch{}})();var Vl=[["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"})),Gl=[...["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"})),Wl=[["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"})),Kl=[...Gl,...Wl,...["init","config","schema","profile"].map(e=>({alias:e,canonical:`workspace ${e}`,canonical_argv:["workspace",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-npr3"})),...[...["comments","notes","learnings","files","docs","deps","append","test"].map(e=>[e,`item ${e}`,"pm-yql1"]),["test-runs-worker","item test worker","pm-lp4j"],...["statuses","tags","types"].map(e=>[`completion-${e}`,`completion ${e}`,"pm-szdc"]),["history-author-acknowledge","history acknowledge","pm-djyvbk"],["copy","item copy","pm-m6g87m"],["merge","workspace merge","pm-m6g87m"],["duplicates","item duplicates","pm-fmy9ih"],["dedupe-audit","item duplicates audit","pm-fmy9ih"],["dedupe-merge","item duplicates merge","pm-fmy9ih"],["comments-audit","item audit-comments","pm-fmy9ih"],["search-advanced","search advanced","pm-wfskfn"],...["meet","event","remind"].map(e=>[e,`calendar ${e}`,"pm-o3fh"])].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:n}))],tr=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...Vl,...Kl,...["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 Zh(e){let t;for(let n of tr)n.canonical_argv.length<=(t?.canonical_argv.length??0)||n.canonical_argv.every((r,o)=>r===(o===0&&e[o]==="ctx"?"context":e[o]))&&(t=n);return t}function Hl(e){let t=e.trim().replace(/\s+/gu," ");return tr.find(n=>n.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function at(e){return Hl(e)}var Ht=[...tr,...[["ctx","context"],["packages","package"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:[t],lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-pbyu"})),...[["start-task","claim","--start"],["pause-task","release","--pause"],["close-task","close","--release-assignment"]].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:[t,n],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-eq4x"})),{alias:"tests",canonical:"item test",canonical_argv:["item","test"],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-u4t9gp"},...[["fetch","get"],["read","get"],["show","get"],["view","get"],["comment","comments"],["note","notes"],["learning","learnings"]].map(([e,t])=>({alias:e,canonical:["comments","notes","learnings"].includes(t)?`item ${t}`:t,canonical_argv:["comments","notes","learnings"].includes(t)?["item",t]:[t],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-pbyu"})),...[["extension list","extension catalog"],["extension scaffold","extension init"],["package list","package catalog"],["package scaffold","package init"],["packages list","package catalog"],["packages scaffold","package init"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-ya7x55"})),{alias:"list-all",canonical:"list",canonical_argv:["list","--all"],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"},...[["list-draft","draft"],["list-open","open"],["list-in-progress","in_progress"],["list-blocked","blocked"],["list-closed","closed"],["list-canceled","canceled"]].map(([e,t])=>({alias:e,canonical:"list",canonical_argv:["list","--status",t],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"})),...[["extension","package"],["install","package install"],["upgrade","package upgrade"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-tnud"}))],eb=Object.fromEntries(Ht.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function tb(e){let t=e.trim().toLowerCase();return Ht.find(n=>n.alias===t)}function nb(e){return`Deprecated command \`${e.alias}\`; use \`pm ${e.canonical_argv.join(" ")}\`.`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3348c61d-a03e-5023-a5dc-fd6149f478c1")}catch{}})();var Yl=[...X],Xl=[...Me],Jl=[...$t],ab=[...Mt],cb=[...jt],Ql=[...Lt],Yt=["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"],db=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],lb=["install","reconcile","report","driver"],Zl=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],eu=["upgrade"],tu=["reopen"],ai={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},je=Object.freeze(Yt.flatMap(e=>e in ai?[]:e==="extension"||e==="package"?[...Zl.map(t=>`${e}-${t}`),...e==="package"?eu.map(t=>`package-${t}`):[],e]:e==="item"?tu.map(t=>`item-${t}`):[e])),nu=Object.freeze(Ht.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&je.includes(e.alias)).map(e=>e.alias)),ub=Object.freeze(je.filter(e=>!nu.includes(e)));function fb(e=Yt,t=je,n=ai){let r=new Set(t),o=new Set(e);return{missing_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]===void 0),waived_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]!==void 0),stale_waivers:Object.keys(n).filter(i=>!o.has(i)||r.has(i)||t.some(s=>s.startsWith(`${i}-`)))}}function mb(e){return je.includes(e)}function pb(e){return Yl.includes(e)}function _b(e){return Xl.includes(e)}function gb(e){return Jl.includes(e)}function yb(e){return Ql.includes(e)}var hb=new Set(["update","item-reopen","close","claim","release","start-task","pause-task","close-task","restore","append","update-many","close-many","delete","comments","notes","learnings","files","docs","test","test-all","plan","history-redact","history-repair","history-compact","validate"]);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="447bb510-051a-5dce-8b7d-e27f4ca781f4")}catch{}})();var Xt={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},Jt=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),be=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","learnings","files","docs","stats","aggregate","duplicates","package-catalog","package-manage","comments-audit","assurance"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f8657910-1392-5fae-afda-614b96dc8320")}catch{}})();function S(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function ru(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function ci(e){return e?j(e):{}}function di(e){return e?j(e):ru()}function j(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 ou=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),iu=["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 su(e,t){for(let n of iu){let r=e[n];if(r===void 0)continue;if(!Array.isArray(r)||r.some(i=>typeof i!="string"))return!1;let o=r.map(i=>ou.has(n)?S(i):i.trim()).filter(i=>i.length>0);t[n]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function au(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n;if(r.format!=="json"&&r.format!=="toon"||!Array.isArray(r.commands)||r.commands.some(o=>typeof o!="string")||typeof r.result_discriminator!="boolean")return null;t.push({format:r.format,commands:[...new Set(r.commands.map(o=>S(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:r.result_discriminator})}return t.sort((n,r)=>n.format.localeCompare(r.format))}function cu(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n.commands;if(!Array.isArray(r)||r.some(o=>typeof o!="string"))return null;t.push({commands:[...new Set(r.map(o=>S(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return t}function Qt(e){if(e==null)return;if(typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.schema_version!==1)return null;let n={schema_version:1};if(!su(t,n))return null;let r=t.preflight_overrides;if(r!==void 0&&(!Number.isInteger(r)||r<0))return null;typeof r=="number"&&(n.preflight_overrides=r);let o=t.renderer_ownership;if(o!==void 0){let s=au(o);if(s===null)return null;n.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=cu(i);if(s===null)return null;n.preflight_ownership=s}return n}function kb(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]="d4155698-c244-5623-b627-92dd25297125")}catch{}})();var du=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields",extension_command_availability:"read_output"},{flag:"--output-limit",value_name:"count",extension_command_availability:"read_output"},{flag:"--output-budget",value_name:"tokens",extension_command_availability:"read_output"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state",extension_command_availability:"read_output"},{flag:"--output-cursor",value_name:"cursor",extension_command_availability:"read_output"},{flag:"--output-row-contract",extension_command_availability:"read_output"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"],discovery_value_name:"path"},{flag:"--no-extensions",extension_command_availability:"never"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"},{flag:"--expect-hash",value_name:"revision"}]),Zt=new Set(du.flatMap(e=>[e.flag,...e.aliases??[]]));(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="81054684-60df-57c9-af9d-0996874c1024")}catch{}})();var li=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function nr(e){if(typeof e!="string")return null;let t=li.exec(e.trim());if(!t)return null;let n=t[2];return{name:t[1],valueName:n?n.slice(1,-1):null,optional:n?.startsWith("[")??!1}}function Cb(e){let t=nr(e);return t?t.name:typeof e=="string"&&e.trim()||null}function lu(e){if(typeof e!="string")return null;let t=e.trim(),n=t.split(/[ =]/,1)[0];return Zt.has(n)||Zt.has(`--${n.slice(2).replaceAll("_","-")}`)?"host_owned_flag_collision":li.test(t)?null:"malformed_long_flag"}function ui(e,t){let n=[e,t].find(i=>typeof i=="string"&&Zt.has(i.trim().split(/[ =]/,1)[0]));if(typeof n=="string")return{token:n.trim().split(/[ =]/,1)[0],failure:"host_owned_flag_collision"};if(typeof e!="string")return null;let r=e.trim(),o=lu(r);return o===null?null:{token:r,failure:o}}function fi(e,t){return t==="host_owned_flag_collision"?`cannot shadow host-owned global flag "${e}"; read it from context.global instead`:`long flag "${e}" must start with a double-dash name such as "--my-flag" or "--my-flag <value>"`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5c3049c3-1d5a-5e7e-a070-35340737a6ab")}catch{}})();var mi=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function en(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.hasOwn(mi,t)?mi[t]:null}function uu(e,t,n){return!!(e.value_name?.trim()||t||n||e.required===!0||e.list===!0||e.repeatable===!0)}function fu(e){return(e.value_type?.trim()||e.type?.trim())?.toLowerCase()}function Rb(e){let t=fu(e),n=en(t),r=nr(e.long),o=e.value_name?.trim()||null,i=!(n==="boolean"&&t!=="bool")&&uu(e,r?.valueName,t),s=r?.valueName?r.optional:t==="bool";return{value_type:n,value_arity:i?s?"optional":"required":"none",value_name:i?o??r?.valueName??"value":null}}function pi(e){let t=[],n=r=>{if(Array.isArray(r)){for(let o of r)n(o);return}if(typeof r=="string"){for(let o of r.split(",")){let i=o.trim();i.length>0&&t.push(i)}return}r!=null&&t.push(r)};return n(e),t}function _i(e,t){return t==="string"?!0:t==="number"?typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim().length>0&&Number.isFinite(Number(e)):typeof e=="boolean"?!0:typeof e=="string"&&["true","false","1","0"].includes(e.trim().toLowerCase())}function xb(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]="4a7b042c-7fb8-57a5-8f94-de44f82d7589")}catch{}})();function mu(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function V(e,t){let n=e.slice(0,t),r=n.charCodeAt(n.length-1),o=e.charCodeAt(n.length);return r>=55296&&r<=56319&&o>=56320&&o<=57343?n.slice(0,-1):n}function Db(e){return mu(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function Pb(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let n=new Set(e),r=new Set(t),o=0;for(let s of n)r.has(s)&&(o+=1);let i=new Set([...n,...r]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7359c10a-4c56-57ea-8254-fc26b19e5c84")}catch{}})();function ct(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function oe(e){return X.includes(e)}function gi(e){let t=e.trim().toLowerCase();return oe(t)?t:null}function yi(e){return e.filter(t=>!oe(t))}function rr(e){let t=e.trim().toLowerCase();return t.length===0?null:Do[t]??null}function hi(e){let t=ct([...e].map(i=>i.toLowerCase())),n=[],r=[];for(let i of t){let s=rr(i);if(s){n.push(s),r.push({alias:i,target:s});continue}n.push(i)}let o=[...new Map(r.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:ct(n),legacy_aliases:o}}function pu(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=rr(t);if(n)return n;let r=Math.max(1,Math.floor(t.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of X){let a=zt(t,s,r);a!==null&&a<i&&(i=a,o=s)}return o}function bi(e,t,n){let r=X.join(","),o=pu(n)??"none";return`extension_capability_unknown:${e}:${t}:${n}:allowed=${r}:suggested=${o}`}function wi(e,t,n){let r=n.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${r}`}function _u(e){let t=/^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(e.trim());if(!t)return null;let[,n,r,o,i,s]=t,a=n,c=i.split(",").map(f=>f.trim()).filter(f=>f.length>0),d=rr(o),l=(s==="none"?void 0:s)??d??void 0;return{layer:a,name:r,capability:o,allowed_capabilities:c,capability_contract_version:Un,suggested_capability:l,suggestion_source:l?d===l?"legacy_alias":"nearest_match":void 0,legacy_alias_target:d??void 0}}function gu(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,n,r,o]=t,i=n,s=[...X],a=[];for(let c of o.split(",")){let[d,l]=c.split(">"),f=d?.trim(),u=l?.trim().toLowerCase();!f||!u||!oe(u)||a.push({layer:i,name:r,capability:f,allowed_capabilities:s,capability_contract_version:Un,suggested_capability:u,suggestion_source:"legacy_alias",legacy_alias_target:u})}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]="d8844150-afb4-5f2e-a005-4cfb8482660c")}catch{}})();var yu={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"]},vi=":";function Ei(e,t){return`${e}${vi}${or(t)}`}function hu(e){return e.slice(e.indexOf(vi)+1)}function or(e){return e.trim().toLowerCase()}function bu(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let r=gi(n);r!==null&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function ki(e){let t=new Map,n=(l,f)=>{for(let u of l){let m=Ei(u.layer,u.name),p=t.get(m);p===void 0&&(p=new Set,t.set(m,p)),p.add(f)}},{registrations:r,commands:o,parsers:i,preflight:s,services:a,renderers:c,hooks:d}=e;return n(r.commands,"commands"),n(o.overrides,"commands"),n(o.handlers,"commands"),n(r.flags,"schema"),n(r.item_fields,"schema"),n(r.item_types,"schema"),n(r.relationship_kinds??[],"schema"),n(r.migrations,"schema"),n(r.profiles,"schema"),n(r.importers,"importers"),n(r.exporters,"importers"),n(r.search_providers,"search"),n(r.vector_store_adapters,"search"),n(i.overrides,"parser"),n(s.overrides,"preflight"),n(a.overrides,"services"),n(r.assurance_providers??[],"services"),n(c.overrides,"renderers"),n(d.beforeCommand,"hooks"),n(d.beforeMutation,"hooks"),n(d.afterCommand,"hooks"),n(d.onWrite,"hooks"),n(d.onRead,"hooks"),n(d.onIndex,"hooks"),t}function wu(e,t={}){let n=ki(e),r=new Set;t.extensionName!==void 0&&r.add(or(t.extensionName));for(let i of t.extensionNames??[])r.add(or(i));let o=new Set;for(let[i,s]of n)if(!(r.size>0&&!r.has(hu(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function vu(e,t){let n=ki(t),r=[];for(let o of e){let i=bu(o.capabilities);if(i.length===0)continue;let s=n.get(Ei(o.layer,o.name))??new Set,a=[...s].sort((d,l)=>d.localeCompare(l)),c=i.filter(d=>!s.has(d));r.push({layer:o.layer,name:o.name,declared:i,used:a,unused:c})}return r}import{existsSync as rm}from"node:fs";import{AsyncLocalStorage as om}from"node:async_hooks";import ee from"node:path";import Oe from"node:fs/promises";import ke from"node:path";import{pathToFileURL as Of}from"node:url";import Oi 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 dt(e,t){let n=Oi.relative(e,t);return n.length===0?!0:!n.startsWith("..")&&!Oi.isAbsolute(n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="32aa20df-edf7-543d-b733-841130466f00")}catch{}})();var Eu="__pm_suppress_host_output",ir="@unbrained/pm-cli:suppress-host-output:v1";function Si(e){return e===void 0?{__pm_suppress_host_output:ir}:{__pm_suppress_host_output:ir,result:e}}function sr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[Eu]===ir}import Le from"node:fs";import ie from"node:path";import{fileURLToPath as ku}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 Ou="@unbrained/pm-cli";function Su(e){try{return JSON.parse(Le.readFileSync(e,"utf8")).name===Ou}catch{return!1}}function Au(e){let t=Le.existsSync(e)&&Le.statSync(e).isDirectory()?ie.resolve(e):ie.dirname(ie.resolve(e));for(;;){let n=ie.join(t,"package.json");if(Le.existsSync(n)&&Su(n))return t;let r=ie.dirname(t);if(r===t)return;t=r}}function ar(e,t=[]){let n=ku(e);return Au(n)||ie.resolve(ie.dirname(n),...t)}function Kb(e,t=[]){try{let n=ie.join(ar(e,t),"package.json");if(!Le.existsSync(n))return;let r=JSON.parse(Le.readFileSync(n,"utf8"));return typeof r.version=="string"&&r.version.trim().length>0?r.version:void 0}catch{return}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a797572f-fbc6-5e62-a9b5-5a0bd6ef22b4")}catch{}})();function Cu(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Yb(e){return Cu(e)??void 0}function Xb(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 Jb(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function Ci(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function Ti(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 Qb(e){let t=Ti(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function Zb(e,t,n){let r=Ti(e);return r===null||r<t||r>n?null:r}function ew(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function se(e){return typeof e!="object"||e===null?null:e}function Ai(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function Ii(e){let t=Ai(e);if(!t)return null;if(typeof t.activate=="function")return t;let n=Ai(t.default);return typeof n?.activate=="function"?n:null}function tw(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]="559b05dc-0290-5a7c-97b9-ef1e5e8670ba")}catch{}})();function Ri(e){let t={beforeCommand:e.hooks.beforeCommand.length,beforeMutation:e.hooks.beforeMutation.length,afterCommand:e.hooks.afterCommand.length,onWrite:e.hooks.onWrite.length,onRead:e.hooks.onRead.length,onIndex:e.hooks.onIndex.length,commandOverrides:e.commands.overrides.length,commandHandlers:e.commands.handlers.length,parserOverrides:e.parsers.overrides.length,preflightOverrides:e.preflight.overrides.length,serviceOverrides:e.services.overrides.length,rendererOverrides:e.renderers.overrides.length,registrations:Object.fromEntries(Object.entries(e.registrations).map(([n,r])=>[n,r.length]))};return()=>{e.hooks.beforeCommand.length=t.beforeCommand,e.hooks.beforeMutation.length=t.beforeMutation,e.hooks.afterCommand.length=t.afterCommand,e.hooks.onWrite.length=t.onWrite,e.hooks.onRead.length=t.onRead,e.hooks.onIndex.length=t.onIndex,e.commands.overrides.length=t.commandOverrides,e.commands.handlers.length=t.commandHandlers,e.parsers.overrides.length=t.parserOverrides,e.preflight.overrides.length=t.preflightOverrides,e.services.overrides.length=t.serviceOverrides,e.renderers.overrides.length=t.rendererOverrides;for(let[n,r]of Object.entries(t.registrations))e.registrations[n].length=r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="17ae377d-20c2-5e45-825a-48a79c6c7601")}catch{}})();function T(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return t}function P(e,t){if(t!==void 0&&typeof t!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function A(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 xi(e,t){if(t===void 0)return;let n=r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean";if(Array.isArray(t)){for(let[r,o]of t.entries())if(!n(o))throw new TypeError(`${e}[${r}] must be a string, number, or boolean`);return}if(!n(t))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function we(e,t){if(t!==void 0){if(!Array.isArray(t))throw new TypeError(`${e} must be an array of non-empty strings when provided`);for(let[n,r]of t.entries())if(typeof r!="string"||r.trim().length===0)throw new TypeError(`${e}[${n}] must be a non-empty string`)}}function lt(e,t){if(we(e,t),!Array.isArray(t))return[];let n=[],r=new Set;for(let o of t){let i=o.trim();i.length===0||r.has(i)||(r.add(i),n.push(i))}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="34536eba-0f92-5599-a807-5b39b000e733")}catch{}})();var cr=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 Tu=new Set(cr);function Iu(e){if(e!==void 0&&!Tu.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${cr.join(", ")}`)}function Ni(e){A("registerCommand definition.action",e.action),A("registerCommand definition.family",e.family),A("registerCommand definition.description",e.description),A("registerCommand definition.intent",e.intent),A("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");Iu(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 Di(e,t="",n=""){if(e===void 0)return;if(Fe(t)||Fe(n))throw new TypeError("Native pm commands and actions cannot declare read_output");let r=T("registerCommand definition.read_output",e);if(Object.keys(r).some(s=>s!=="row_keys")||!Array.isArray(r.row_keys))throw new TypeError("registerCommand definition.read_output requires only row_keys: string[]");let o=Array.from(r.row_keys),i=new Set(["__proto__","constructor","prototype","row_contract","read_output","read_session","omission_receipt","output_budget_truncation"]);if(o.some(s=>typeof s!="string"||!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*$/u.test(s)||s.split(".").some(a=>i.has(a))))throw new TypeError("registerCommand definition.read_output row_keys must be safe dot-delimited property paths");if(new Set(o).size!==o.length||o.some(s=>o.some(a=>a.startsWith(`${s}.`))))throw new TypeError("registerCommand definition.read_output row_keys must be unique and non-overlapping");return Object.freeze({row_keys:Object.freeze([...o])})}function Fe(e){let t=e.trim().toLowerCase().replace(/\s+/gu,"-");return je.includes(t)||be.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 Ru(e){let t=T("registerExporter options.output",e),n=new Set(["channel","receipt","media_type"]);for(let r of Object.keys(t))if(!n.has(r))throw new TypeError(`registerExporter options.output contains unsupported field ${r}`);if(t.channel!=="stdout"&&t.channel!=="file")throw new TypeError("registerExporter options.output.channel must be stdout|file");if(t.receipt!==void 0&&t.receipt!=="suppress"&&t.receipt!=="render")throw new TypeError("registerExporter options.output.receipt must be suppress|render");if(t.channel==="stdout"&&t.receipt==="render")throw new TypeError("registerExporter stdout artifacts cannot render a host receipt");return A("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 Pi(e,t,n){if(e==="registerImporter"&&t.output!==void 0)throw new TypeError("registerImporter options.output is exporter-only");if(e!=="registerExporter"||t.output===void 0)return;let r=Ru(t.output);return!n&&r.channel==="stdout"&&(t.description="Export items with the registered extension adapter. Artifact bytes are written exclusively to stdout and the host receipt is suppressed by default."),r}function dr(e,t,n){return{registration:t,action:n,command:e.command,args:j(e.args),options:j(e.options),global:j(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 $i(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 q(e){return typeof e!="string"?"":e.trim().toLowerCase()}function v(e){return new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))}function xu(e){let t=e.trim().toLowerCase();if(t.length===0)return"";let n=t.split(/[.:/]/).map(r=>r.replace(/[\s_-]+/g,"")).filter(r=>r.length>0);return n.length===0?"":n.length===1?n[0]:`${n[0]}.${n.slice(1).join("")}`}function Ue(e){return new Set((e??[]).map(t=>xu(t)).filter(t=>t.length>0))}function Mi(e){let t=q(e);return $t.includes(t)?t:"off"}function ji(e){let t=q(e);return Mt.includes(t)?t:"off"}function ut(e){let t=q(e);return jt.includes(t)?t:"none"}function lr(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return Po.includes(t)?t:void 0}function Li(e){if(typeof e=="string"){let t=lr(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:lr(e.global)??"block",project:lr(e.project)??"block"}:{global:"block",project:"block"}}function Nu(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function k(e){return[...new Set(e)].sort((t,n)=>t.localeCompare(n))}function Du(e){let t=q(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?ut(e.sandbox_profile):void 0,allowedCapabilities:v(e.allowed_capabilities),blockedCapabilities:v(e.blocked_capabilities),allowedSurfaces:Ue(e.allowed_surfaces),blockedSurfaces:Ue(e.blocked_surfaces),allowedCommands:v(e.allowed_commands),blockedCommands:v(e.blocked_commands),allowedActions:v(e.allowed_actions),blockedActions:v(e.blocked_actions),allowedServices:v(e.allowed_services),blockedServices:v(e.blocked_services)}}}function Fi(e){let t=new Map;for(let n of e??[]){let r=Du(n);r&&t.set(r.name,r.normalized)}return t}function Pu(e){let t=[],n=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of k([...e.allowedCapabilities,...e.blockedCapabilities]))oe(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of n)for(let i of k([...o.allowedCapabilities,...o.blockedCapabilities]))oe(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let r=new Set(Lt);for(let o of k([...e.allowedSurfaces,...e.blockedSurfaces]))r.has(o)||t.push(`extension_policy_unknown_surface:${o}`);for(let o of n)for(let i of k([...o.allowedSurfaces,...o.blockedSurfaces]))r.has(i)||t.push(`extension_policy_unknown_surface:${o.name}:${i}`);return[...new Set(t)].sort((o,i)=>o.localeCompare(i))}function Ui(e){let t=e.extensions?.policy??{},n=v(t.allowed_capabilities),r=v(t.blocked_capabilities),o=Ue(t.allowed_surfaces),i=Ue(t.blocked_surfaces),s=Fi(t.extension_overrides);return{mode:Mi(t.mode),trustMode:ji(t.trust_mode),pmMaxVersionExceededMode:Li(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:v(t.trusted_extensions),defaultSandboxProfile:ut(t.default_sandbox_profile),allowedExtensions:v(t.allowed_extensions),blockedExtensions:v(t.blocked_extensions),allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:v(t.allowed_commands),blockedCommands:v(t.blocked_commands),allowedActions:v(t.allowed_actions),blockedActions:v(t.blocked_actions),allowedServices:v(t.allowed_services),blockedServices:v(t.blocked_services),overridesByName:s,warnings:Pu({allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function zi(e){let t=[...e.overridesByName.values()].sort((n,r)=>n.name.localeCompare(r.name)).map(n=>({name:n.name,...n.disabled?{disabled:!0}:{},...n.requireTrusted?{require_trusted:!0}:{},...n.requireProvenance?{require_provenance:!0}:{},...n.sandboxProfile?{sandbox_profile:n.sandboxProfile}:{},...n.allowedCapabilities.size>0?{allowed_capabilities:k(n.allowedCapabilities)}:{},...n.blockedCapabilities.size>0?{blocked_capabilities:k(n.blockedCapabilities)}:{},...n.allowedSurfaces.size>0?{allowed_surfaces:k(n.allowedSurfaces)}:{},...n.blockedSurfaces.size>0?{blocked_surfaces:k(n.blockedSurfaces)}:{},...n.allowedCommands.size>0?{allowed_commands:k(n.allowedCommands)}:{},...n.blockedCommands.size>0?{blocked_commands:k(n.blockedCommands)}:{},...n.allowedActions.size>0?{allowed_actions:k(n.allowedActions)}:{},...n.blockedActions.size>0?{blocked_actions:k(n.blockedActions)}:{},...n.allowedServices.size>0?{allowed_services:k(n.allowedServices)}:{},...n.blockedServices.size>0?{blocked_services:k(n.blockedServices)}:{}}));return{mode:e.mode,trust_mode:e.trustMode,pm_max_version_exceeded_mode:Nu(e.pmMaxVersionExceededMode),require_provenance:e.requireProvenance,trusted_extensions:k(e.trustedExtensions),default_sandbox_profile:e.defaultSandboxProfile,allowed_extensions:k(e.allowedExtensions),blocked_extensions:k(e.blockedExtensions),allowed_capabilities:k(e.allowedCapabilities),blocked_capabilities:k(e.blockedCapabilities),allowed_surfaces:k(e.allowedSurfaces),blocked_surfaces:k(e.blockedSurfaces),allowed_commands:k(e.allowedCommands),blocked_commands:k(e.blockedCommands),allowed_actions:k(e.allowedActions),blocked_actions:k(e.blockedActions),allowed_services:k(e.allowedServices),blocked_services:k(e.blockedServices),extension_overrides:t}}function qi(e){let t=Fi(e.extension_overrides);return{mode:Mi(e.mode),trustMode:ji(e.trust_mode),pmMaxVersionExceededMode:Li(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:v(e.trusted_extensions),defaultSandboxProfile:ut(e.default_sandbox_profile),allowedExtensions:v(e.allowed_extensions),blockedExtensions:v(e.blocked_extensions),allowedCapabilities:v(e.allowed_capabilities),blockedCapabilities:v(e.blocked_capabilities),allowedSurfaces:Ue(e.allowed_surfaces),blockedSurfaces:Ue(e.blocked_surfaces),allowedCommands:v(e.allowed_commands),blockedCommands:v(e.blocked_commands),allowedActions:v(e.allowed_actions),blockedActions:v(e.blocked_actions),allowedServices:v(e.allowed_services),blockedServices:v(e.blocked_services),overridesByName:t,warnings:[]}}function ae(e,t){return e.overridesByName.get(q(t))??null}function ze(e,t,n,r,o){return t.has(n)?o:e.size>0&&!e.has(n)?r:null}function Bi(e,t,n){let r=n.trim().toLowerCase(),o=ae(e,t.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return ze(i,s,r,"capability_not_allowlisted","capability_blocked")}function $u(e,t,n){let r=ae(e,t.name),o=r&&r.allowedSurfaces.size>0?r.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...r?r.blockedSurfaces:[]]);return ze(o,i,n,"surface_not_allowlisted","surface_blocked")}function Mu(e,t,n){let r=S(n);if(r.length===0)return null;let o=ae(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return ze(i,s,r,"command_not_allowlisted","command_blocked")}function ju(e,t,n){let r=q(n).replace(/\s+/g,"-");if(r.length===0)return null;let o=ae(e,t.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return ze(i,s,r,"action_not_allowlisted","action_blocked")}function Lu(e,t,n){let r=q(n);if(r.length===0)return null;let o=ae(e,t.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return ze(i,s,r,"service_not_allowlisted","service_blocked")}function Fu(e,t){let n=q(t.name);return ae(e,t.name)?.disabled===!0?"extension_override_disabled":ze(e.allowedExtensions,e.blockedExtensions,n,"extension_not_allowlisted","extension_blocked")}function Uu(e,t){if(e.trustMode==="off")return null;let n=ae(e,t.name),r=q(t.name),o=t.trusted===!0,i=t.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(r)?"extension_not_trusted":(n?.requireTrusted===!0||e.trustMode==="warn"||e.trustMode==="enforce")&&!o?"extension_untrusted":(e.requireProvenance||n?.requireProvenance===!0)&&!i?"provenance_missing_or_unverified":null}function zu(e,t){if(e.mode==="off")return null;let n=ae(e,t.name)?.sandboxProfile??t.sandboxProfile??e.defaultSandboxProfile;if(n==="none")return null;let r=t.permissions;if(!r)return"sandbox_permissions_missing";let o=i=>r[i]===!0;return n==="restricted"?o("process_spawn")?"sandbox_restricted_disallows_process_spawn":o("env_write")?"sandbox_restricted_disallows_env_write":null:o("process_spawn")?"sandbox_strict_disallows_process_spawn":o("network")?"sandbox_strict_disallows_network":o("fs_write")?"sandbox_strict_disallows_fs_write":o("env_write")?"sandbox_strict_disallows_env_write":null}function tn(e,t,n,r,o={}){let i=Object.entries(o).sort((a,c)=>a[0].localeCompare(c[0])).map(([a,c])=>`${a}=${c}`).join(":"),s=i.length>0?`:${i}`:"";return`extension_policy_${e}_${t}:${n.layer}:${n.name}:reason=${r}${s}`}function Vi(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let n=[],r=Fu(e,t);r&&n.push({reason:r,scope:"extension",mode:e.mode});let o=Uu(e,t);o&&n.push({reason:o,scope:"trust",mode:e.trustMode});let i=zu(e,t);i&&n.push({reason:i,scope:"extension",mode:e.mode});let s=n.find(c=>c.mode==="enforce");if(s)return{allowed:!1,warning:tn("blocked",s.scope,t,s.reason)};let a=n.find(c=>c.mode==="warn");return a?{allowed:!0,warning:tn("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function Gi(e,t,n){if(e.mode==="off")return{allowed:!0,warning:null};let r=Bi(e,t,n);return r?{allowed:e.mode==="warn",warning:tn(e.mode==="warn"?"violation":"blocked","capability",t,r,{capability:n.trim().toLowerCase()})}:{allowed:!0,warning:null}}function qu(e,t,n,r,o){let i=typeof r=="string"?Bi(e,t,r):null,s=$u(e,t,n),a=o.command?Mu(e,t,o.command):null,c=o.action?ju(e,t,o.action):null,d=o.service?Lu(e,t,o.service):null;return i??s??a??c??d}function Bu(e,t,n,r){let o={method:q(e).replace(/\s+/g,"_"),surface:t};return n&&(o.capability=n),r.command&&(o.command=S(r.command)),r.action&&(o.action=q(r.action).replace(/\s+/g,"-")),r.service&&(o.service=q(r.service)),o}function Wi(e,t,n,r,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=qu(e,t,n,o,s);if(!a)return{allowed:!0,warning:null};let c=tn(e.mode==="warn"?"violation":"blocked","registration",t,a,Bu(r,n,o,s));return{allowed:e.mode==="warn",warning:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01116a5e-62d1-591b-9fd0-84ac6e99f8d0")}catch{}})();function nn(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function ur(){return{overrides:[],handlers:[]}}function fr(){return{overrides:[]}}function mr(){return{overrides:[]}}function pr(){return{overrides:[]}}function _r(){return{overrides:[]}}function gr(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[],assurance_providers:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cd1de600-27e4-522b-842e-1993c12e9f0e")}catch{}})();var Hi=100;function Ki(e,t){let n=e[t];if(n!=null)return typeof n!="string"||n.trim().length===0?null:n.trim()}function Vu(e){if(e==null)return;let t=se(e);if(!t)return null;let n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i))){if(r.trim().length===0)return null;let o=t[r];if(typeof o!="string"||o.trim().length===0)return null;n[r.trim()]=o.trim()}return Object.keys(n).length>0?n:void 0}function yr(e,t){let n=e[t];return typeof n!="string"||n.trim().length===0?null:n.trim()}function Yi(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function ve(e){if(e!=null)return typeof e!="boolean"?null:e}function Gu(e){let t=Yi(e.priority);return t===void 0?Hi:t}function Wu(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let n=ut(t);return n!==t.trim().toLowerCase()?null:n}function hr(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Ku(e){if(e==null)return;let t=se(e);if(!t)return null;let n=hr(t.source),r=hr(t.signature),o=hr(t.attestation),i=t.verified===void 0||t.verified===null?void 0:typeof t.verified=="boolean"?t.verified:null;return i===null?null:{...n?{source:n}:{},...r?{signature:r}:{},...o?{attestation:o}:{},...typeof i=="boolean"?{verified:i}:{}}}function Hu(e){if(e==null)return;let t=se(e);if(!t)return null;let n=ve(t.fs_read),r=ve(t.fs_write),o=ve(t.network),i=ve(t.env_read),s=ve(t.env_write),a=ve(t.process_spawn);return[n,r,o,i,s,a].includes(null)?null:{...typeof n=="boolean"?{fs_read:n}:{},...typeof r=="boolean"?{fs_write:r}:{},...typeof o=="boolean"?{network:o}:{},...typeof i=="boolean"?{env_read:i}:{},...typeof s=="boolean"?{env_write:s}:{},...typeof a=="boolean"?{process_spawn:a}:{}}}function Yu(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(n=>typeof n!="string"))return null;let t=hi(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function Xu(e){if(e==null)return;let t=se(e);if(!t)return null;let n=t.commands;if(n==null)return;if(!Array.isArray(n)||n.some(o=>typeof o!="string"))return null;let r=[...new Set(n.map(o=>S(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return r.length>0?{commands:r}:void 0}function Ju(e){let t=Yi(e.manifest_version);if(t===null)return null;let n=Ki(e,"pm_min_version");if(n===null)return null;let r=Ki(e,"pm_max_version");if(r===null)return null;let o=Vu(e.engines);if(o===null)return null;let i=ve(e.trusted);if(i===null)return null;let s=Wu(e);if(s===null)return null;let a=Ku(e.provenance);if(a===null)return null;let c=Hu(e.permissions);if(c===null)return null;let d=Yu(e.capabilities);if(d===null)return null;let l=Xu(e.activation);if(l===null)return null;let f=Qt(e.contributions);return f===null?null:{manifest_version:t,pm_min_version:n,pm_max_version:r,engines:o,trusted:i,sandbox_profile:s,provenance:a,permissions:c,capabilities:d.capabilities,legacy_capability_aliases:d.legacy_aliases,activation:l,contributions:f}}function br(e){if(typeof e!="object"||e===null)return null;let t=e,n=yr(t,"name");if(n===null)return null;let r=yr(t,"version");if(r===null)return null;let o=yr(t,"entry");if(o===null)return null;let i=Gu(t);if(i===null)return null;let s=Ju(t);return s===null?null:{name:n,version:r,entry:o,priority:i,manifest_version:s.manifest_version,pm_min_version:s.pm_min_version,pm_max_version:s.pm_max_version,engines:s.engines,trusted:s.trusted,provenance:s.provenance,sandbox_profile:s.sandbox_profile,permissions:s.permissions,activation:s.activation,contributions:s.contributions,capabilities:s.capabilities,legacy_capability_aliases:s.legacy_capability_aliases.length>0?s.legacy_capability_aliases:void 0}}import{constants as ce}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 Xi=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"}]]),Qu=/^[a-z][a-z0-9_]{0,63}$/u,Zu=new Map([[ce.errno.EACCES,"EACCES"],[ce.errno.EDQUOT,"EDQUOT"],[ce.errno.EMFILE,"EMFILE"],[ce.errno.ENFILE,"ENFILE"],[ce.errno.ENOMEM,"ENOMEM"],[ce.errno.ENOSPC,"ENOSPC"],[ce.errno.EPERM,"EPERM"],[ce.errno.EROFS,"EROFS"]].filter(([e])=>Number.isInteger(e))),ef={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function tf(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&Xi.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:Zu.get(Math.abs(t.errno))??null}function nf(e,t,n={}){let r=tf(e);if(r===null)return null;if(!Qu.test(t))throw new h("Host environment operation labels must be bounded identifiers.",y.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=Xi.get(r);return new h(`Host filesystem operation ${t} ${o.summary}.`,y.GENERIC_FAILURE,{code:n.codes?.[o.category]??ef[o.category].code,reason:r,required:o.recovery,why:n.why??"The operating system refused a required project filesystem operation.",nextSteps:[o.recovery,...n.nextSteps??[]],...n.suggestedRetry?{recovery:{suggested_retry:n.suggestedRetry}}:{}})}async function Ji(e,t,n={}){try{return await t()}catch(r){throw nf(r,e,n)??r}}import rf from"node:fs/promises";import ft 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 Qi(e,t){let n=ft.dirname(t.manifest_path),r=ft.relative(n,t.entry_path);if(r.startsWith("..")||ft.isAbsolute(r))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=ft.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await Ji("extension_module_graph_snapshot",()=>rf.cp(n,o,{recursive:!0,force:!0})),ft.join(o,r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bf5c3834-b388-507e-a13c-3beb5d096abb")}catch{}})();function Zi(e){let t=typeof e=="function"?e:e.run;if(typeof t!="function")throw new TypeError("registerPreflight override requires a function handler");let n=[...new Set((typeof e=="function"?[]:e.commands??[]).map(r=>{if(typeof r!="string"||r.trim().length===0)throw new TypeError("registerPreflight ownership.commands must contain non-empty command paths");return S(r)}))];return{run:t,...n.length>0?{commands:n}:{}}}function es(e){let t=[];for(let n=1;n<e.overrides.length;n+=1){let r=e.overrides[n];for(let o of e.overrides.slice(0,n))r.commands?.length&&o.commands?.length&&!o.commands.some(i=>r.commands.includes(i))||t.push(`extension_preflight_override_collision:${r.layer}:${r.name}:${o.layer}:${o.name}`)}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="47d10c23-88f8-5ba1-bcc2-458f339121a8")}catch{}})();var rn=jo;function ts(e){let t=e.trim().toLowerCase();return rn.includes(t)?t:null}function ns(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=Math.max(1,Math.floor(t.length*.34));for(let r of rn)if(zt(t,r,n)!==null)return r;return null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="355fe619-e6f3-51d9-b88c-0b57267c25be")}catch{}})();function rs(e){return e==="toon"||e==="json"}function os(e){return Me.includes(e)}function Ee(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var is=Symbol("extension_registration_trace");function Z(e,t){let n=new TypeError(e);return Object.defineProperty(n,is,{value:t,enumerable:!1,configurable:!1,writable:!1}),n}function ss(e){return e instanceof Error?e[is]:void 0}function mt(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>mt(t));if(typeof e=="function")return"[Function]";if(typeof e=="bigint"||typeof e=="symbol")return e.toString();if(typeof e=="object"){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=mt(t[r]);return n}return e}function pt(e){if(Array.isArray(e))return e.map(t=>pt(t));if(typeof e=="object"&&e!==null){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=pt(t[r]);return n}return e}function qe(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return mt(t)}function _t(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return pt(t)}function gt(e,t){if(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(n=>qe(e,n))}function L(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function yt(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function wr(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function vr(e,t){return S(`${e} ${t}`)}function ht(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var of=new Set(["low","medium","high"]),sf=new Set(["number","string_set"]),af=new Set(["string","number","boolean"]);function as(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function cf(e,t,n){let r=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=T(r,n);if(!sf.has(String(o.value_type)))throw new TypeError(`${r}.value_type must be number or string_set`);if(A(`${r}.description`,o.description),o.parameters===void 0)return;let i=T(`${r}.parameters`,o.parameters);for(let[s,a]of Object.entries(i)){let c=`${r}.parameters.${s}`;as(`${c}.name`,s);let d=T(c,a);if(!af.has(String(d.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);P(`${c}.required`,d.required),A(`${c}.description`,d.description)}if(Object.keys(i).length>50)throw new TypeError(`assurance provider ${e} key ${t} exceeds 50 parameters`)}function cs(e){let t=T("registerAssuranceMeasurementProvider provider",e),n=as("registerAssuranceMeasurementProvider provider.id",t.id);if(!/^[a-z0-9][a-z0-9-]*$/u.test(n))throw new TypeError("registerAssuranceMeasurementProvider provider.id must be a stable lowercase id");if(!of.has(String(t.cost_class)))throw new TypeError("registerAssuranceMeasurementProvider provider.cost_class must be low, medium, or high");if(typeof t.network!="boolean")throw new TypeError("registerAssuranceMeasurementProvider provider.network must be boolean");let r=T("registerAssuranceMeasurementProvider provider.keys",t.keys);if(Object.keys(r).length===0)throw new TypeError("registerAssuranceMeasurementProvider provider.keys requires at least one key");for(let[o,i]of Object.entries(r)){if(!/^[a-z0-9][a-z0-9-]*$/u.test(o))throw new TypeError(`registerAssuranceMeasurementProvider provider key ${o} must be a stable lowercase id`);cf(n,o,i)}if(t.timeout_ms!==void 0&&(typeof t.timeout_ms!="number"||!Number.isInteger(t.timeout_ms)||t.timeout_ms<1||t.timeout_ms>3e5))throw new TypeError("registerAssuranceMeasurementProvider provider.timeout_ms must be an integer from 1 through 300000");if(typeof t.resolve!="function")throw new TypeError("registerAssuranceMeasurementProvider provider.resolve requires a function handler")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4abca948-e9ba-52b5-b63c-a20fc344980a")}catch{}})();var df=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","value_validation","visible"]);function on(e,t){return gt(e,t).map(n=>(n.repeatable===!0&&(n.list=!0),n))}function lf(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function Er(e,t){if(t===void 0)return e.replace(/\s+/g,"-");if(typeof t!="string"||t.trim().length===0)throw new TypeError("registerCommand definition.action must be a non-empty string when provided");let n=lf(t);if(n.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return n}function kr(e){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("registerCommand definition.arguments must be an array when provided");let t=[];for(let[r,o]of e.entries()){let i=T(`registerCommand definition.arguments[${r}]`,o),s=L(`registerCommand definition.arguments[${r}].name`,i.name);if(P(`registerCommand definition.arguments[${r}].required`,i.required),P(`registerCommand definition.arguments[${r}].variadic`,i.variadic),A(`registerCommand definition.arguments[${r}].description`,i.description),s.includes(" "))throw new TypeError(`registerCommand definition.arguments[${r}].name must not contain spaces`);let a={name:s};i.required===!0&&(a.required=!0),i.variadic===!0&&(a.variadic=!0),typeof i.description=="string"&&(a.description=i.description.trim()),t.push(a)}let n=t.map((r,o)=>r.variadic?o:-1).filter(r=>r>=0);if(n.length>1)throw new TypeError("registerCommand definition.arguments supports at most one variadic argument");if(n.length===1&&n[0]!==t.length-1)throw new TypeError("registerCommand definition.arguments variadic argument must be the final argument");return t}function sn(e){if(!Array.isArray(e))throw new TypeError("registerFlags flags requires an array of object definitions");for(let[t,n]of e.entries()){let r=T(`registerFlags flags[${t}]`,n),o=Object.keys(r).filter(c=>!df.has(c)).sort((c,d)=>c.localeCompare(d));if(o.length>0)throw new TypeError(`registerFlags flags[${t}] contains unknown field(s): ${o.join(", ")}`);let i=r.long,s=r.short;if(i===void 0&&s===void 0)throw new TypeError(`registerFlags flags[${t}] requires at least one of long or short`);A(`registerFlags flags[${t}].long`,i),A(`registerFlags flags[${t}].short`,s);let a=ui(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${fi(a.token,a.failure)}`);if(A(`registerFlags flags[${t}].value_name`,r.value_name),A(`registerFlags flags[${t}].description`,r.description),P(`registerFlags flags[${t}].required`,r.required),P(`registerFlags flags[${t}].enabled`,r.enabled),P(`registerFlags flags[${t}].visible`,r.visible),P(`registerFlags flags[${t}].list`,r.list),P(`registerFlags flags[${t}].repeatable`,r.repeatable),r.list!==void 0&&r.repeatable!==void 0&&r.list!==r.repeatable)throw new TypeError(`registerFlags flags[${t}].list and repeatable must match when both are provided`);if(xi(`registerFlags flags[${t}].default`,r.default),Array.isArray(r.default)&&r.list!==!0&&r.repeatable!==!0)throw new TypeError(`registerFlags flags[${t}].default cannot be an array unless list is true.`);ds(`registerFlags flags[${t}]`,r),uf(`registerFlags flags[${t}]`,r)}}function uf(e,t){if(t.value_validation===void 0)return;if(t.value_validation!=="coerce"&&t.value_validation!=="strict")throw new TypeError(`${e}.value_validation must be "coerce" or "strict" (received ${JSON.stringify(t.value_validation)}).`);if(t.value_validation!=="strict")return;let n=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0),r=n===void 0?null:en(n);if(r!=="number"&&r!=="boolean")throw new TypeError(`${e}.value_validation "strict" requires value_type "number" or "boolean" (string values are never malformed).`)}function ds(e,t){let n=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0);if(n===void 0)return;let r=en(n);if(r===null)throw new TypeError(`${e} value_type "${n}" is not a known flag value type (expected one of: string, number, boolean).`);if(t.default===void 0)return;let o=t.list===!0||t.repeatable===!0?pi(t.default):[t.default];for(let[i,s]of o.entries())if(!_i(s,r)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${r}.`)}}function ls(e){if(!Array.isArray(e))throw new TypeError("registerItemFields fields requires an array of object definitions");for(let[t,n]of e.entries()){let r=T(`registerItemFields fields[${t}]`,n);L(`registerItemFields fields[${t}].name`,r.name);let o=L(`registerItemFields fields[${t}].type`,r.type);if(ts(o)===null){let i=ns(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${rn.join(", ")}).${s}`)}P(`registerItemFields fields[${t}].optional`,r.optional)}}function ff(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].command_option_policies`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=T(i,o);L(`${i}.command`,s.command),L(`${i}.option`,s.option),P(`${i}.enabled`,s.enabled),P(`${i}.required`,s.required),P(`${i}.visible`,s.visible)}}function mf(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].options`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=T(i,o);L(`${i}.key`,s.key),we(`${i}.values`,s.values),P(`${i}.required`,s.required),we(`${i}.aliases`,s.aliases)}}function us(e){if(!Array.isArray(e))throw new TypeError("registerItemTypes types requires an array of object definitions");for(let[t,n]of e.entries()){let r=`registerItemTypes types[${t}]`,o=T(r,n);L(`${r}.name`,o.name),A(`${r}.folder`,o.folder),we(`${r}.aliases`,o.aliases),we(`${r}.required_create_fields`,o.required_create_fields),we(`${r}.required_create_repeatables`,o.required_create_repeatables),ff(t,o.command_option_policies),mf(t,o.options)}}function fs(e){let t=T("registerMigration definition",e);if(t.id!==void 0&&typeof t.id!="string")throw new TypeError("registerMigration definition.id must be a string when provided");if(t.description!==void 0&&typeof t.description!="string")throw new TypeError("registerMigration definition.description must be a string when provided");if(t.status!==void 0&&typeof t.status!="string")throw new TypeError("registerMigration definition.status must be a string when provided");if(P("registerMigration definition.mandatory",t.mandatory),t.run!==void 0&&typeof t.run!="function")throw new TypeError("registerMigration definition.run must be a function when provided")}var ms=["types","statuses","fields","workflows","config","templates","packages"],pf={types:(e,t)=>{if(t.name!==void 0&&typeof t.name!="string")throw new TypeError(`${e}.name must be a string when provided`)},workflows:(e,t)=>{if(typeof t.type!="string")throw new TypeError(`${e}.type must be a string`);if(!Array.isArray(t.allowed_transitions))throw new TypeError(`${e}.allowed_transitions must be an array`);for(let[n,r]of t.allowed_transitions.entries())if(!Array.isArray(r))throw new TypeError(`${e}.allowed_transitions[${n}] must be a [from, to] array`)},templates:(e,t)=>{if(typeof t.name!="string")throw new TypeError(`${e}.name must be a string`);if(typeof t.options!="object"||t.options===null||Array.isArray(t.options))throw new TypeError(`${e}.options must be an object`)},packages:(e,t)=>{if(typeof t.spec!="string")throw new TypeError(`${e}.spec must be a string`)}};function ps(e){let t=T("registerProfile profile",e);if(L("registerProfile profile.name",t.name),L("registerProfile profile.title",t.title),t.summary!==void 0&&typeof t.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let n of ms){let r=t[n];if(r!==void 0){if(!Array.isArray(r))throw new TypeError(`registerProfile profile.${n} must be an array when provided`);for(let[o,i]of r.entries()){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError(`registerProfile profile.${n}[${o}] must be an object`);pf[n]?.(`registerProfile profile.${n}[${o}]`,i)}}}}function _s(e){e.summary===void 0&&(e.summary="");for(let t of ms)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 gs(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 ys(e){return typeof e=="string"?e:String(e)}function bt(e){let t=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(t)?t.split(/[.-]/).map(n=>Number(n)):null}function Or(e,t){let n=bt(e),r=bt(t);if(!n||!r)return null;let o=Math.max(n.length,r.length);for(let i=0;i<o;i+=1){let s=n[i]??0,a=r[i]??0;if(s>a)return 1;if(s<a)return-1}return 0}function hs(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let n=ys(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(!bt(n))return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(t===null)return{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:null};let r=Or(t,n);return r===null?{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:t}:r<0?{kind:"pm_min_version",status:"unmet",allowed:!1,required:n,current:t}:{kind:"pm_min_version",status:"ok",allowed:!0,required:n,current:t}}function bs(e,t,n){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let r=ys(e);if(typeof e!="string"||r.trim().length===0)return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(/^[<>=~^]/.test(r.trim())||!bt(r))return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(t===null)return{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:null};let o=Or(t,r);return o===null?{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:t}:o>0?n==="warn"?{kind:"pm_max_version",status:"exceeded_warn",allowed:!0,required:r,current:t}:{kind:"pm_max_version",status:"exceeded",allowed:!1,required:r,current:t}:{kind:"pm_max_version",status:"ok",allowed:!0,required:r,current:t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f49bad80-c246-59b3-950d-7143585fbdb5")}catch{}})();var _f=5e3;async function Sr(e,t,n){let r=[];for(let o of e)try{await o.run(j(n))}catch{r.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return r}function gf(e,t,n){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new h(`Extension mutation guard ${t.name} returned an invalid decision.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${t.layer}:${t.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let r=e,o=typeof r.code=="string"?r.code.trim():"",i=typeof r.remediation=="string"?r.remediation.trim():"";if(o.length===0||i.length===0)throw new h(`Extension mutation guard ${t.name} returned an invalid denial.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${t.layer}:${t.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof r.message=="string"?r.message.trim():"";throw new h(s||`Extension mutation guard ${t.name} denied ${n}.`,y.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function Ar(e,t){for(let n of e.beforeMutation??[]){let r,o;try{let i=Promise.resolve().then(()=>n.run({pm_root:t.pm_root,operation:t.operation,before:t.before===null?null:j(t.before),after:t.after===null?null:j(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),r=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new h(`Extension mutation guard ${n.name} timed out before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},_f),o.unref?.()})])}catch(i){throw i instanceof h?i:new h(`Extension mutation guard ${n.name} failed before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(o)}gf(r,n,t.operation)}}async function Cr(e,t){return Sr(e.onWrite,"onWrite",t)}async function Tr(e,t){return Sr(e.onRead,"onRead",t)}async function Ir(e,t){return Sr(e.onIndex,"onIndex",t)}function yf(e){let t="";e instanceof Error&&typeof e.message=="string"?t=e.message:typeof e=="string"?t=e:typeof e=="object"&&e!==null&&typeof e.message=="string"&&(t=e.message);let n=t.replace(/\s+/gu," ").trim();if(n.length===0)return"";let r=300;return n.length>r?`${V(n,r-1)}\u2026`:n}function an(e,t){if(typeof e!="object"||e===null||typeof e[t]!="string")return;let n=String(e[t]).replace(/\s+/gu," ").trim();return n.length>0?V(n,300):void 0}function hf(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 Rr(e,t){let n=S(t.command);if(n.length===0)return{handled:!1,result:null,warnings:[]};let r=[...e.handlers].reverse().find(o=>o.command===n);if(!r)return{handled:!1,result:null,warnings:[]};try{let o=await r.run({command:n,args:j(t.args),options:j(t.options),global:j(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",hf(o)],["errorCode",an(o,"code")],["remediation",an(o,"remediation")]].filter(i=>i[1]!==void 0))}}catch(o){let i=typeof o=="object"&&o!==null&&"exitCode"in o?o.exitCode:void 0;if(typeof i=="number"&&Number.isFinite(i))throw o;return Object.defineProperty({handled:!1,result:null,warnings:[`extension_command_handler_failed:${r.layer}:${r.name}:${r.command}`],errorMessage:yf(o),...Object.fromEntries([["errorCode",an(o,"code")],["remediation",an(o,"remediation")]].filter(s=>s[1]!==void 0))},"cause",{value:o,configurable:!0})}}function ws(e){return{handled:!1,result:e.payload,warnings:[]}}function vs(e,t){return[...e.overrides].reverse().filter(n=>n.service===t)}function Es(e){return{service:e.service,command:e.command?S(e.command):void 0,args:e.args?j(e.args):void 0,options:e.options?ci(e.options):void 0,global:e.global?di(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:j(e.payload)}}function bf(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 ks(e,t){return bf(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 Os(e,t,n){return t.service==="output_format"&&typeof e=="object"&&e!==null&&K(e,n.payload)}function Ss(e,t,n){if(t.handled){if(e.passThrough===!0){n.push(`extension_service_pass_through_contract_violated:${e.layer}:${e.name}:${e.service}`);return}return{handled:!0,result:t.result,warnings:n}}}function xr(e,t){let n=vs(e,t.service);if(n.length===0)return ws(t);let r=[];for(let o of n)try{let i=Es(t),s=o.run(i);if(s instanceof Promise){r.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(Os(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Ss(o,ks(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}async function Nr(e,t){let n=vs(e,t.service);if(n.length===0)return ws(t);let r=[];for(let o of n)try{let i=Es(t),s=await Promise.resolve(o.run(i));if(Os(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Ss(o,ks(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3abe36f7-3c97-58d2-a56d-b4e0ea958461")}catch{}})();var As=null,Sf=Object.freeze($o()),Cs=0;function Af(e=Date.now()){return Cs+=1,`${Cs}-${e}`}function Cf(e,t,n){return n.has(e)?!1:t.size===0?!0:t.has(e)}async function Tf(e,t){let[n,r]=await Promise.all([Oe.realpath(e),Oe.realpath(t)]);return dt(n,r)}function If(e,t=process.cwd()){return{global:ke.join(ti(t),"extensions"),project:ke.join(e,"extensions")}}async function Rf(e){try{return(await Oe.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,n)=>t.localeCompare(n))}catch{return[]}}function xf(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 Ts(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function Nf(e){let t=new Map;try{let n=JSON.parse(await Oe.readFile(ke.join(e,".managed-extensions.json"),"utf8")),r=se(n)?.entries;if(!Array.isArray(r))return t;for(let o of r){if(typeof o!="object"||o===null)continue;let i=o,s=Ts(i.source?.package),a=[i.source?.input,i.source?.name,s].map(l=>Ts(l)).filter(l=>l!==void 0),c=Qt(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 Is(e){return[...e].sort((t,n)=>{if(t.manifest.priority!==n.manifest.priority)return t.manifest.priority-n.manifest.priority;let r=t.manifest.name.localeCompare(n.manifest.name);return r!==0?r:t.directory.localeCompare(n.directory)})}function Df(e,t){let n=[...Is(e),...Is(t)],r=[];for(let o of n){let i=r.findIndex(s=>s.manifest.name===o.manifest.name);i>=0&&r.splice(i,1),r.push(o)}return r}async function Rs(e,t,n,r,o){let i=[],s=[],a=[],c=await Rf(t),d=await Nf(t);for(let l of c){let f=await Mf(e,t,l,n,r,d,o);i.push(f.diagnostic),s.push(...f.warnings),f.candidate&&a.push(f.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function Pf(){return{diagnostics:[],warnings:[],candidates:[]}}function xs(e,t,n,r){return{diagnostic:{layer:e,directory:t,manifest_path:n,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[r],candidate:null}}function $f(e,t,n,r,o,i,s,a){let c=Lo(e,t,n);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&c.push(wi(e,t.name,t.legacy_capability_aliases));for(let d of yi(t.capabilities))c.push(bi(e,t.name,d));return r?o||c.push(`extension_entry_missing:${e}:${t.name}`):c.push(`extension_entry_outside_extension:${e}:${t.name}`),i.warning&&c.push(a?i.warning:i.warning.replace("extension_pm_","extension_disabled_pm_")),s.warning&&c.push(a?s.warning:s.warning.replace("extension_pm_","extension_disabled_pm_")),c}async function Mf(e,t,n,r,o,i,s){let a=ke.join(t,n),c=ke.join(a,"manifest.json");if(!await zn(c))return xs(e,n,c,`extension_manifest_missing:${e}:${n}`);let d,l;try{let $e=JSON.parse(await Oe.readFile(c,"utf8"));l=se($e),d=br($e)}catch{l=null,d=null}if(!d||!l)return xs(e,n,c,`extension_manifest_invalid:${e}:${n}`);let f=ke.resolve(a,d.entry),u=dt(a,f),m=u?await zn(f):!1,p=u&&m?await Tf(a,f):u,_=Cf(d.name,r,o),g=await Ff(e,d),b=await Uf(e,d,s),w=$f(e,d,l,p,m,g,b,_),U=p&&m&&g.allowed&&b.allowed,ne=i.get(`directory:${n}`)??i.get(`name:${d.name}`);return{diagnostic:{layer:e,directory:n,manifest_path:c,name:d.name,version:d.version,entry:d.entry,priority:d.priority,entry_path:f,enabled:_,status:U?"ok":"warn"},warnings:w,candidate:$i({layer:e,directory:n,manifestPath:c,entryPath:f,manifest:d,sourceIdentity:ne,extensionReady:U,enabledForLoad:_})}}async function jf(e){let t=If(e.pmRoot,e.cwd??process.cwd()),n=ct(e.settings.extensions.enabled),r=ct(e.settings.extensions.disabled),o=Ui(e.settings),i=zi(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:n,configured_disabled:r,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(n),a=new Set(r),c=e.ignoreGlobalExtensions===!0?Pf():await Rs("global",t.global,s,a,o.pmMaxVersionExceededMode.global),d=await Rs("project",t.project,s,a,o.pmMaxVersionExceededMode.project),l=[...o.warnings],f=Df(c.candidates,d.candidates),u=[];for(let m of f){let p={layer:m.layer,name:m.manifest.name,trusted:m.manifest.trusted===!0,provenanceVerified:m.manifest.provenance?.verified===!0,sandboxProfile:m.manifest.sandbox_profile,permissions:m.manifest.permissions&&typeof m.manifest.permissions=="object"?{fs_read:m.manifest.permissions.fs_read,fs_write:m.manifest.permissions.fs_write,network:m.manifest.permissions.network,env_read:m.manifest.permissions.env_read,env_write:m.manifest.permissions.env_write,process_spawn:m.manifest.permissions.process_spawn}:void 0},_=Vi(o,p);if(_.warning&&l.push(_.warning),!!_.allowed){for(let g of m.manifest.capabilities){let b=Gi(o,p,g);b.warning&&l.push(b.warning)}u.push(xf(m))}}return{disabled_by_flag:!1,roots:t,configured_enabled:n,configured_disabled:r,discovered:[...c.diagnostics,...d.diagnostics],effective:u,warnings:[...new Set([...c.warnings,...d.warnings,...l])],policy:i}}function cn(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function Lf(){try{let e=ar(import.meta.url,["../../.."]),t=await Oe.readFile(ke.join(e,"package.json"),"utf8"),n=JSON.parse(t);return typeof n.version=="string"&&n.version.trim().length>0?n.version.trim():null}catch{return null}}function Ps(){return As??=Lf(),As}function $s(e,t,n){let r=n.current??"unknown";if(n.kind==="pm_min_version")switch(n.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${t.name}:required=${n.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${t.name}:required=${n.required}:current=${r}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${t.name}:required=${n.required}:current=${r}`;default:return}switch(n.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${t.name}:allowed=${n.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${t.name}:allowed=${n.required}:current=${r}`;default:return}}async function Ff(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let n=hs(t.pm_min_version,await Ps()),r=$s(e,t,n);return r?{allowed:n.allowed,warning:r}:{allowed:n.allowed}}async function Uf(e,t,n){if(t.pm_max_version===void 0)return{allowed:!0};let r=bs(t.pm_max_version,await Ps(),n),o=$s(e,t,r);return o?{allowed:r.allowed,warning:o}:{allowed:r.allowed}}async function Ns(e){try{let t=await Oe.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function zf(e,t){let n=e.entry_path;t.module_graph_snapshot_root&&(n=await Qi(t.module_graph_snapshot_root,e));let r=new URL(Of(n).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return r.href;let[o,i]=await Promise.all([Ns(e.entry_path),Ns(e.manifest_path)]),s=t.reload_token??Af();return r.searchParams.set("pm_ext_reload",s),r.searchParams.set("pm_ext_entry",o),r.searchParams.set("pm_ext_manifest",i),r.href}async function zv(e){let t=await jf(e),n=[],r=[],o=[...t.warnings];if(t.disabled_by_flag)return{...t,warnings:o,loaded:n,failed:r};let i=typeof e.extensionFilter=="function"?t.effective.filter(e.extensionFilter):t.effective;for(let s of i)try{let a=await import(await zf(s,e));n.push({...s,module:a})}catch(a){o.push(`extension_load_failed:${s.layer}:${s.name}`),r.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:cn(a)})}return{...t,warnings:o,loaded:n,failed:r}}var Ds=5e3,qf=2147483647;function Bf(e){let t={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let n=e.deactivate;t.deactivate=n.bind(e)}return t}function Ms(e){let t=Ii(e);return t?Bf(t):null}async function qv(e,t,n={}){let r=Vf(n?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(l=>`${l.layer}:${l.name}`)),i=[];for(let l of e.loaded){if(o.has(`${l.layer}:${l.name}`))continue;let f=Ms(l.module);!f||typeof f.deactivate!="function"||i.push({extension:l,deactivate:f.deactivate})}let s=await Promise.all(i.map(async({extension:l,deactivate:f})=>{try{return await Gf(f,r),{ok:!0}}catch(u){return{ok:!1,layer:l.layer,name:l.name,error:cn(u)}}})),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 Vf(e){return typeof e!="number"||e<0?Ds:e===0||e===1/0?0:Number.isFinite(e)?Math.min(qf,Math.max(1,Math.floor(e))):Ds}async function Gf(e,t){if(t===0){await e();return}let n;try{let r=Promise.resolve().then(()=>e());r.catch(()=>{}),await Promise.race([r,new Promise((o,i)=>{n=setTimeout(()=>{i(new Error(`extension deactivate timed out after ${t}ms`))},t),n.unref?.()})])}finally{clearTimeout(n)}}function Wf(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let n of e.capabilities){let r=n.trim().toLowerCase();oe(r)&&t.add(r)}return t}function O(e,t,n){let r=Wf(e);if(r!==null&&!r.has(t))throw Z(`${n} requires capability '${t}' in extension manifest capabilities`,{method:n,registration_index:-1,capability:t,missing_capability:t,expected_schema:`"capabilities": [..., "${t}"]`,received:e.capabilities,hint:`Add "${t}" to ${e.name} manifest capabilities, or remove the ${n} registration call.`})}function Kf(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>X.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function Hf(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 Dr=class{extension;hooks;#e;#n;#o;#r;#s;#a;#i;#c;#t;#d;#l;#u;constructor(t,n,r,o,i,s,a,c,d,l,f){this.#e=t,this.extension=Kf(t),this.#n=Hf(t),this.#o=n,this.#r=r,this.#s=o,this.#a=i,this.#i=s,this.#c=a,this.#t=c,this.#d=d,this.#l=l,this.#u=f,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:u=>this.registerBeforeCommand(u),beforeMutation:u=>this.registerBeforeMutation(u),afterCommand:u=>this.registerAfterCommand(u),onWrite:u=>this.registerOnWrite(u),onRead:u=>this.registerOnRead(u),onIndex:u=>this.registerOnIndex(u)}}allowRegistration(t,n,r,o){let i=Wi(this.#u,this.#n,t,n,r,o);return i.warning&&this.#d.push(i.warning),i.allowed}registerCommandTrace(t,n,r,o,i){return{method:"registerCommand",registration_index:t==="override"?this.#r.overrides.length:this.#r.handlers.length,command:n,expected_schema:r,received:mt(o),hint:i}}registerCommandOverride(t,n){let r=S(t);if(r.length===0)throw Z("registerCommand requires a non-empty command name",this.registerCommandTrace("override",t,'registerCommand("<command>", (context) => unknown)',t,"Provide a non-empty command path as the first argument."));if(typeof n!="function"){let o=this.registerCommandTrace("override",r,'registerCommand("<command>", (context) => unknown)',n,"Provide a function as the second registerCommand argument.");throw Z(`registerCommand requires an override function when command name is provided (command="${r}", registration_index=${o.registration_index})`,o)}this.allowRegistration("commands.override","registerCommand","commands",{command:r})&&this.#r.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}resolveCommandDefinitionRunHandler(t,n){let r=typeof t.run=="function"?t.run:void 0,o=typeof t.handler=="function"?t.handler:void 0;return!r&&o&&this.#d.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${n}`),r??o}registerCommandDefinition(t){if(typeof t!="object"||t===null)throw Z("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 Z("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,"Set command definition.name to a non-empty string command path."));let n=S(t.name);if(n.length===0)throw Z("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",t.name,"{ name: string; run: (context) => unknown; }",t,"Ensure command definition.name contains a non-empty command path."));let r=this.resolveCommandDefinitionRunHandler(t,n);if(typeof r!="function"){let o=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; }",r,"Define command definition.run as a function.");throw Z(`registerCommand requires a command definition run handler (command="${n}", registration_index=${o.registration_index})`,o)}try{Ni(t);let o=Er(n,t.action),i=Di(t.read_output,n,o);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:n,action:o}))return;let s=t.description?.trim(),a=t.intent?.trim(),c=lt("registerCommand definition.examples",t.examples),d=lt("registerCommand definition.failure_hints",t.failure_hints),l=kr(t.arguments);t.flags!==void 0&&(O(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(sn(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:on("registerCommand definition.flags",t.flags)})));let f={source_version:this.#e.version,read_output:i,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:o,examples:c,failure_hints:d,arguments:l,tier:t.tier??"standard",family:t.family??"extensions"};s&&(f.description=s),a&&(f.intent=a),this.#t.commands.push(f)}catch(o){let i=cn(o),s=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=Z(`registerCommand definition metadata invalid (command="${n}", registration_index=${s.registration_index}): ${i}`,s);this.#d.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${n}`),this.#l.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}registerCommand(t,n){if(O(this.#e,"commands","registerCommand"),typeof t=="string"){this.registerCommandOverride(t,n);return}this.registerCommandDefinition(t)}registerParser(t,n){if(O(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let r=S(L("registerParser command",t));yt("registerParser override",n),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}registerPreflight(t){if(O(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let n=Zi(t);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...n})}registerService(t,n,r={}){O(this.#e,"services","registerService");let o=String(t).trim().toLowerCase();if(!os(o))throw new TypeError(`registerService service must be one of: ${Me.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(yt("registerService override",n),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:n,...gs(r)?{passThrough:!0}:{}}))}registerRenderer(t,n,r={}){if(O(this.#e,"renderers","registerRenderer"),!this.allowRegistration("renderers.override","registerRenderer","renderers"))return;if(typeof n!="function")throw new TypeError("registerRenderer requires a renderer function");let o=String(t).trim().toLowerCase();if(!rs(o))throw new Error(`registerRenderer format must be toon|json, received: ${String(t)}`);if(r.resultDiscriminator!==void 0&&typeof r.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");let i=[...new Set((r.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return S(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:o,run:n,commands:i,...r.resultDiscriminator?{resultDiscriminator:r.resultDiscriminator}:{}})}registerFlags(t,n){if(O(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let r=S(L("registerFlags targetCommand",t));sn(n);let o=on("registerFlags flags",n);if(o.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:o})}registerItemFields(t){if(O(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;ls(t);let n=gt("registerItemFields fields",t);if(n.length===0)throw new TypeError("registerItemFields requires at least one field definition");this.#t.item_fields.push({layer:this.#e.layer,name:this.#e.name,fields:n})}registerItemTypes(t){if(O(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;us(t);let n=gt("registerItemTypes types",t);if(n.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#t.item_types.push({layer:this.#e.layer,name:this.#e.name,types:n})}registerRelationshipKinds(t){if(O(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(t))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(t.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");let n=Kn();for(let o of this.#t.relationship_kinds)for(let i of o.definitions)n.register(i);let r=t.map(o=>(n.register(o),n.require(o.kind)));this.#t.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:r})}registerMigration(t){if(O(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;fs(t);let n=_t("registerMigration definition",t);this.#t.migrations.push(ht({layer:this.#e.layer,name:this.#e.name,definition:qe("registerMigration definition",t)},n))}registerProfile(t){if(O(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let n=pt(t);ps(n),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:_s(n)})}registerImportExportCommandFlags(t,n,r){r.flags!==void 0&&(O(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(sn(r.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:on(`${t} options.flags`,r.flags)})))}applyImportExportCommandMetadata(t,n,r){if(r!==void 0&&(typeof r!="object"||r===null||Array.isArray(r)))throw new TypeError(`${t} options must be an object when provided`);let o=`${t==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,i=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...r,description:r?.description??o,arguments:r?.arguments??i},a=Pi(t,s,r?.description!==void 0);A(`${t} options.action`,s.action),A(`${t} options.description`,s.description),A(`${t} options.intent`,s.intent);let c=Er(n,s.action),d=lt(`${t} options.examples`,s.examples),l=lt(`${t} options.failure_hints`,s.failure_hints),f=kr(s.arguments);this.registerImportExportCommandFlags(t,n,s);let u={source_version:this.#e.version,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:c,examples:d,failure_hints:l,arguments:f},m=s.description?.trim();m&&(u.description=m);let p=s.intent?.trim();return p&&(u.intent=p),this.#t.commands.push(u),a}registerImporter(t,n,r){if(O(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=wr(L("registerImporter name",t));yt("registerImporter importer",n);let i=vr(o,"import");this.applyImportExportCommandMetadata("registerImporter",i,r),this.#t.importers.push({layer:this.#e.layer,name:this.#e.name,importer:o}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>n(dr(s,o,"import"))})}registerExporter(t,n,r){if(O(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=wr(L("registerExporter name",t));yt("registerExporter exporter",n);let i=vr(o,"export"),s=this.applyImportExportCommandMetadata("registerExporter",i,r);this.#t.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:o,...s===void 0?{}:{output:s}}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async a=>{let c=await n(dr(a,o,"export"));return s?.receipt==="suppress"&&!sr(c)?Si(c):c}})}registerSearchProvider(t){if(O(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let n=_t("registerSearchProvider provider",t);this.#t.search_providers.push(ht({layer:this.#e.layer,name:this.#e.name,definition:qe("registerSearchProvider provider",t)},n))}registerVectorStoreAdapter(t){if(O(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let n=_t("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(ht({layer:this.#e.layer,name:this.#e.name,definition:qe("registerVectorStoreAdapter adapter",t)},n))}registerAssuranceMeasurementProvider(t){if(O(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(cs(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let n=_t("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(ht({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:qe("registerAssuranceMeasurementProvider provider",t)},n))}registerBeforeCommand(t){O(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(Ee("beforeCommand",t),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerBeforeMutation(t){O(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(Ee("beforeMutation",t),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerAfterCommand(t){O(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(Ee("afterCommand",t),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnWrite(t){O(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(Ee("onWrite",t),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnRead(t){O(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(Ee("onRead",t),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnIndex(t){O(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(Ee("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function Yf(e,t,n,r,o,i,s,a,c,d,l){return new Dr(e,t,n,r,o,i,s,a,c,d,l)}function Xf(e){let t=e.commands.length,n=e.flags.reduce((s,a)=>s+a.flags.length,0),r=e.item_fields.reduce((s,a)=>s+a.fields.length,0),o=e.item_types.reduce((s,a)=>s+a.types.length,0),i=(e.relationship_kinds??[]).reduce((s,a)=>s+a.definitions.length,0);return{commands:t,flags:n,item_fields:r,item_types:o,...i>0?{relationship_kinds:i}:{},migrations:e.migrations.length,profiles:e.profiles.length,importers:e.importers.length,exporters:e.exporters.length,search_providers:e.search_providers.length,vector_store_adapters:e.vector_store_adapters.length,...(e.assurance_providers?.length??0)>0?{assurance_providers:e.assurance_providers.length}:{}}}function Jf(e){let t=[],n=(i,s)=>{let a=new Map;for(let c of i){let d=a.get(c.command)??[];d.push(c),a.set(c.command,d)}for(let c of[...a.keys()].sort((d,l)=>d.localeCompare(l))){let d=a.get(c);if(d.length<=1)continue;let l=d[d.length-1];for(let f of d.slice(0,-1))t.push(`${s}:${c}:${l.layer}:${l.name}:${f.layer}:${f.name}`)}};n(e.handlers,"extension_command_handler_collision"),n(e.overrides,"extension_command_override_collision");let r=new Set(e.handlers.map(i=>i.command)),o=[...new Set(e.overrides.map(i=>i.command))].filter(i=>r.has(i));o.sort((i,s)=>i.localeCompare(s));for(let i of o){let s=e.handlers.filter(c=>c.command===i),a=e.overrides.filter(c=>c.command===i);for(let c of a)for(let d of s)t.push(`extension_command_override_handler_overlap:${i}:${c.layer}:${c.name}:${d.layer}:${d.name}`)}return t}function Qf(e){let t=new Map;for(let r of e.overrides){let o=t.get(r.format)??[];o.push(r),t.set(r.format,o)}let n=[];for(let r of[...t.keys()].sort((o,i)=>o.localeCompare(i))){let o=t.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))i.commands?.length&&s.commands?.length&&!s.commands.some(a=>i.commands?.includes(a))||n.push(`extension_renderer_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return n}function Zf(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.command)??[];o.push(r),n.set(r.command,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_parser_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}var em=new Set(["output_format"]);function tm(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.service)??[];o.push(r),n.set(r.service,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1||em.has(r))continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_service_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}async function Bv(e){let t=qi(e.policy??Sf),n=nn(),r=ur(),o=fr(),i=mr(),s=pr(),a=_r(),c=gr(),d=[],l=[];for(let m of e.loaded){let p=Ms(m.module);if(!p)continue;let _=d.length,g=Ri({hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await p.activate(Yf(m,n,r,o,i,s,a,c,l,d,t)),d.length>_&&(g(),l.push(`extension_activation_rolled_back:${m.layer}:${m.name}`))}catch(b){g(),l.push(`extension_activate_failed:${m.layer}:${m.name}`);let w=ss(b);d.push({layer:m.layer,name:m.name,entry_path:m.entry_path,error:cn(b),trace:w})}}let f=[...Jf(r),...Zf(o),...es(i),...tm(s),...Qf(a)],u=[...new Set([...l,...f])];return{hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c,failed:d,warnings:u,hook_counts:{before_command:n.beforeCommand.length,before_mutation:n.beforeMutation.length,after_command:n.afterCommand.length,on_write:n.onWrite.length,on_read:n.onRead.length,on_index:n.onIndex.length},command_override_count:r.overrides.length,command_handler_count:r.handlers.length,parser_override_count:o.overrides.length,preflight_override_count:i.overrides.length,service_override_count:s.overrides.length,renderer_override_count:a.overrides.length,registration_counts:Xf(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(){try{var e=typeof window<"u"?window:typeof 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 Hv(){let e=Promise.resolve(),t=new Set;return{async read(n){let r=e,o,i=new Promise(s=>{o=s});t.add(i),await r;try{return await n()}finally{t.delete(i),o()}},write(n){let r=Promise.all([e,...t]).then(()=>n());return e=r.then(()=>{},()=>{}),r}}}function nm(){let e=Promise.resolve(),t=0,n=[],r=()=>{if(t!==0)return;let o=n.splice(0);for(let i of o)i()};return{enqueue(o){t++;let i=e.then(()=>o());return e=i.then(()=>{},()=>{}).finally(()=>{t--,r()}),i},idle(){return t===0?Promise.resolve():new Promise(o=>n.push(o))}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7c2e7a35-cbf9-5bb6-abfd-f1ae75c6afc2")}catch{}})();var Be=null,Ls=null,im=null,sm=null,Pr=null,am=null,Fs=null,Us=null;var cm=[],zs=new om;function I(){return zs.getStore()}function eE(e){return zs.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var dm=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function js(e){let t=ee.resolve(e);for(;;){if(rm(ee.join(t,".git")))return t;let n=ee.dirname(t);if(n===t)return;t=n}}function lm(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),n=js(t)??ee.resolve(t),r=js(n);if(!e)return{source_workspace_root:n,...r?{repo_root:r}:{}};let o=ee.relative(n,ee.resolve(e)),i=o.length>0&&!o.startsWith(`..${ee.sep}`)&&o!==".."&&!ee.isAbsolute(o);return{source_workspace_root:n,...r?{repo_root:r}:{},...i?{pm_root_rel:o.split(ee.sep).join("/")}:{}}}function tE(e){let t=I();if(t){t.hooks=e;return}Be=e}function nE(e){let t=I();if(t){t.commands=e;return}Ls=e}function rE(e){let t=I();if(t){t.parsers=e;return}im=e}function oE(e){let t=I();if(t){t.preflight=e;return}sm=e}function iE(e){let t=I();if(t){t.services=e;return}Pr=e}function sE(e){let t=I();if(t){t.renderers=e;return}am=e}function aE(e){let t=I();if(t){t.registrations=e;return}Fs=e}function qs(){let e=I();return e?e.registrations:Fs}function um(){let e=I(),t=e?e.commandContext:Us;return t?{...t,args:[...t.args],options:t.options?{...t.options}:{},global:t.global?{...t.global}:void 0}:null}function cE(e){if(!e)return;let t=I();t?t.affectedItems.push(e):cm.push(e)}function dE(e,t){if(!e||!e.id)return{};let n={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return n;let r=e;for(let o of t){if(typeof o!="string")continue;let i=o.startsWith("unset:")?o.slice(6):o;i==="id"||i==="type"||i==="status"||dm.has(i)||Object.hasOwn(r,i)&&r[i]!==void 0&&(n[i]=r[i])}return n}async function Bs(e){let t=I(),n=t?t.hooks:Be;return n?Cr(n,e):[]}async function lE(e){let t=I(),n=t?t.hooks:Be;n&&await Ar(n,e)}async function Vs(e){let t=I(),n=t?t.hooks:Be;return n?Tr(n,e):[]}function uE(){let e=I();return((e?e.hooks:Be)?.onRead?.length??0)>0}async function fE(e){let t=I(),n=t?t.hooks:Be;return n?Ir(n,e):[]}async function mE(e){let t=I(),n=t?t.commands:Ls;return n?Rr(n,{...e,...lm(e.pm_root)}):{handled:!1,result:null,warnings:[]}}function Gs(e,t){let n=I(),r=n?n.commandContext:Us;return{service:e,command:r?.command,args:r?[...r.args]:[],options:r?.options?{...r.options}:{},global:r?.global?{...r.global}:void 0,pm_root:r?.pm_root,source_workspace_root:r?.source_workspace_root,repo_root:r?.repo_root,pm_root_rel:r?.pm_root_rel,payload:t}}async function dn(e,t){let n=I(),r=n?n.services:Pr;return r?Nr(r,Gs(e,t)):{handled:!1,result:t,warnings:[]}}function Ws(e,t){let n=I(),r=n?n.services:Pr;return r?xr(r,Gs(e,t)):{handled:!1,result:t,warnings:[]}}import{stripVTControlCharacters as fm}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="493a0675-0114-5b93-b3b4-5bd895ac691f")}catch{}})();var mm=["full","compact","brief","summary","counts"],kE=["mutation","read","discovery","governance"],Hs=["error","warning","validation_summary","recovery_bundle"],pm=["full","omit_explanation","limit_collections","compact_recovery","action_only"],_m=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"]),gm=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),ym=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),hm={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},bm=3,wm=2,vm=192,Em={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},km=Hs.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:Em[e],minimum_max_estimated_tokens:vm,degradation_ladder:pm,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),Om=new Map(km.map(e=>[e.diagnostic_class,e]));function Sm(e){let[t=""]=at(e).split(/\s+/u);return _m.has(t)?"mutation":gm.has(t)?"discovery":ym.has(t)?"governance":"read"}function Ys(e,t=Sm(e)){let n=e.trim().replace(/\s+/gu," ");if(n.length===0)throw new TypeError("command must be a non-empty command path");let r=hm[t];return Am({command:n,budget_class:t,default_max_estimated_tokens:r,default_max_estimated_tokens_by_format:{toon:r,json:Math.ceil(r*bm/wm)},degradation_ladder:mm,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function Am(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,n]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var Cm=Yt.map(e=>Ys(e)),Tm=new Map(Cm.map(e=>[e.command,e]));function Xs(e,t={}){let n=e.trim().replace(/\s+/gu," "),[r]=at(n).split(" "),o=Tm.get(r);return o?{...o,command:n}:t.generateFallback?Ys(n):null}function Ae(e){return Math.ceil(Math.max(0,e)/4)}function Js(e){let t=Om.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${Hs.join(", ")}`);return t}function de(e){return Ae(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function Im(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $r(e){if(!Im(e))return;let t={};for(let n of["suggested_retry","suggested_retry_args","next_best_command","allowed_values","candidate_commands","missing","missing_required_fields","option_scope","retry_after_ms","waited_ms","owner_handoffs"]){let r=e[n];Array.isArray(r)?t[n]=n==="suggested_retry_args"?r:r.slice(0,3):r!==void 0&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}function Rm(e,t){return typeof e!="string"||e.length<=t?e:`${V(e,Math.max(1,t-3))}...`}function Se(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;let n="...",r=Array.from(e),o=0,i=r.length;for(;o<i;){let s=Math.ceil((o+i)/2),a=`${r.slice(0,s).join("")}${n}`;Buffer.byteLength(a,"utf8")<=t?o=s:i=s-1}return`${r.slice(0,o).join("")}${n}`}function Qs(e){let t={};for(let n of["code","required","recovery","next_steps","exit_code","type","title","detail","why","examples"])Object.hasOwn(e,n)&&e[n]!==void 0&&(t[n]=e[n]);for(let[n,r]of Object.entries(e))n!=="__proto__"&&!Object.hasOwn(t,n)&&(t[n]=r);return t}var xm=new Set(["limit_collections","compact_recovery","action_only"]),Nm=new Set(["compact_recovery","action_only"]);function Dm(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:Rm(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},n=$r(e.recovery);return n!==void 0?t.recovery=n:Array.isArray(e.next_steps)&&(t.next_steps=e.next_steps.slice(0,1)),e.exit_code!==void 0&&(t.exit_code=e.exit_code),e.type!==void 0&&(t.type=e.type),t}function Pm(e,t){let n=structuredClone(e);if(t!=="full"&&(delete n.why,delete n.examples),xm.has(t))for(let[r,o]of Object.entries(n))Array.isArray(o)&&(n[r]=o.slice(0,3));if(Nm.has(t)){let r=$r(n.recovery);r?n.recovery=r:delete n.recovery}return t!=="action_only"?Qs(n):Dm(n)}function Ve(e,t){let n={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let r=0;r<4;r+=1){let o=de(n),i=n.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return n}function $m(e,t,n){let r=Ve(e,t);for(let i of["recovery","exit_code"])de(r)<=n||e[i]===void 0||(delete e[i],r=Ve(e,t));let o=40;for(;de(r)>n&&o>4;)o-=4,e.code=Se(String(e.code),o),e.required=Se(String(e.required),o),r=Ve(e,t);return r}function Mm(e,t){let n=e.diagnostic_output,{estimated_tokens:r,...o}=n,i=o.omitted_fields.slice(0,8).map(f=>Se(f,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=$r(e.recovery),c=a&&de(a)<=48?a:void 0,d={code:Se(String(e.code),320),required:Se(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},l=Ve(d,s);for(;de(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=Ve(d,s);return l=$m(d,s,t),l}function OE(e,t={}){let n=e,r=t.diagnosticClass??"error",o=Js(r),i=t.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.json,a=de(n),c=Object.keys(n);if(a<=s)return Qs(structuredClone(n));let d;for(let[l,f]of o.degradation_ladder.entries()){let u=Pm(n,f),m=c.filter(_=>!Object.hasOwn(u,_)),p=Ve(u,{diagnostic_class:r,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:l>0,degradation_steps:o.degradation_ladder.slice(0,l+1),omitted_fields:m});if(d=p,de(p)<=s)break}return de(d)>s&&(d=Mm(d,s)),d}function Ks(e){return fm(e).replace(/\r\n/gu,`
2
- `).replace(/[^\P{Cc}\n]/gu," ")}function SE(e,t,n={}){let r=n.diagnosticClass??"error",o=Js(r),i=n.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.text,a=Ks(e),c=Ae(Buffer.byteLength(a,"utf8")),d=c>s,l=`What is required:
1
+ import{A as h,C as qn,D as Bn,E as J,a as X,b as zn,c as $o,e as Mt,f as jt,g as Lt,h as Mo,i as Ft,j as Le,k as jo,p as Ut,q as zt,t as ot,z as y}from"./chunk-G6ERMFJ5.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]="628615ea-5be3-5753-a6c5-3eba8400a8da")}catch{}})();function qt(e,t,n){if(e===t)return 0;if(Math.abs(e.length-t.length)>n)return null;let r=t.length+1,o=new Array(r),i=new Array(r),s=new Array(r);for(let c=0;c<r;c+=1)o[c]=0,i[c]=c;for(let c=1;c<=e.length;c+=1){s[0]=c;let d=s[0];for(let l=1;l<=t.length;l+=1){let f=e[c-1]===t[l-1]?0:1,u=i[l-1]+f,m=s[l-1]+1,p=i[l]+1,_=Math.min(u,m,p);c>1&&l>1&&e[c-1]===t[l-2]&&e[c-2]===t[l-1]&&(_=Math.min(_,o[l-2]+1)),s[l]=_,_<d&&(d=_)}if(d>n)return null;for(let l=0;l<r;l+=1)o[l]=i[l],i[l]=s[l]}let a=i[t.length];return a<=n?a:null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b181d38e-7120-5d34-98d9-fd9b4619b9d9")}catch{}})();var yd=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],Lo=yd,Gy=["draft","open","in_progress","blocked","closed","canceled"],Wy=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],Fo=["string","number","boolean","string_array","array","object"],Ky=["create","update","update_many","list","search","calendar","context"],Hy=["allow","warn","reject"],Yy=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],Xy=["project","global"],Jy=["low","medium","high","critical"],Qy=["low","medium","high","critical"],Zy=["low","medium","high"];var eh=["minimal","default","strict","custom"],th=["none","warn","strict"],nh=["progressive","strict"],rh=["off","warn","strict"],oh=["off","warn","strict"],ih=["off","warn","strict"];var sh=["daily","weekly","monthly","yearly"],hd=["mon","tue","wed","thu","fri","sat","sun"];function ah(e){return hd.indexOf(e)}var ch=["draft","research","review","approved","executing","paused","completed","superseded"],dh=["pending","in_progress","completed","blocked","skipped","superseded"],lh=["codex","claude-code","cursor","generic"],uh=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],fh=["brief","standard","deep","full"],mh=["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]="67511565-01f8-58a6-ad06-45b5d0ce831b")}catch{}})();var bd=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 wd(e){return{unknownKeys:Object.keys(e).filter(t=>!bd.has(t)).sort((t,n)=>t>n?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function vd(e){let t=wd(e),n=t.unknownKeys.map(r=>({code:"manifest_unknown_key",path:r,...r==="compatibility"?{suggested_key:"pm_min_version"}:{},message:r==="compatibility"?'Manifest key "compatibility" is ignored; declare the canonical pm_min_version and optional pm_max_version fields instead.':`Manifest key "${r}" is not part of the extension manifest contract and will be ignored.`}));return t.missingVersionBounds&&n.push({code:"no_version_bounds_declared",path:"$",suggested_key:"pm_min_version",message:"No canonical pm version bounds are declared; add pm_min_version so compatibility intent is explicit."}),{ok:n.length===0,findings:n}}function Uo(e,t,n){return vd(n).findings.map(r=>r.code==="manifest_unknown_key"?`extension_manifest_unknown_key:${e}:${t.name}:key=${r.path}${r.suggested_key?`:suggested=${r.suggested_key}`:""}`:`extension_manifest_no_version_bounds:${e}:${t.name}:suggested=pm_min_version`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2ea7934f-4751-5245-a5ba-492681aa3794")}catch{}})();var Vn=[{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 Gt(e){return e.trim().toLowerCase().replaceAll("-","_")}function Ed(e){if(e===void 0)return;let t=Gt(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function Wn(e,t=new Set){if(e===null||typeof e!="object"||t.has(e))return e;if(t.add(e),Array.isArray(e)){for(let n of e)Wn(n,t);return Object.freeze(e)}for(let n of Object.values(e))Wn(n,t);return Object.freeze(e)}function kd(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 Od(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 Sd(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 Ad(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=Gt(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 Td(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 Cd(e,t){if(e.payloadSchema!==void 0&&(typeof e.payloadSchema!="object"||e.payloadSchema===null||Array.isArray(e.payloadSchema)))throw new TypeError(`Invalid relationship payload schema for ${t}`);if(e.aliases!==void 0&&(!Array.isArray(e.aliases)||e.aliases.some(n=>typeof n!="string")))throw new TypeError(`Invalid relationship aliases for ${t}`)}function Id(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var Kn=class{#e=new Map;#n=new Map;constructor(t=Vn){for(let n of t)this.register(n)}register(t){let n=Ad(t);if(Td(t,n),Cd(t,n),kd(t,n),Od(t,n),Sd(t,n),this.#e.has(n)||this.#n.has(n))throw new TypeError(`Relationship kind already registered: ${n}`);let r=Ed(t.inverse),o=[...new Set((t.aliases??[]).map(Gt))].sort();for(let s of o){if(!/^[a-z][a-z0-9_]*$/.test(s))throw new TypeError(`Invalid relationship alias: ${s}`);if(s===n||this.#e.has(s)||this.#n.has(s))throw new TypeError(`Relationship alias already registered: ${s}`)}let i=Object.freeze({...t,kind:n,traversal:Id(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:r,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?Wn(structuredClone(t.payloadSchema)):void 0});this.#e.set(n,i);for(let s of o)this.#n.set(s,n);return this}resolve(t){if(typeof t!="string")return;let n=Gt(t);return this.#e.get(this.#n.get(n)??n)}require(t){let n=this.resolve(t);if(!n)throw new TypeError(`Unknown relationship kind: ${t}`);return n}list(){return Object.freeze([...this.#e.values()].sort((t,n)=>t.kind.localeCompare(n.kind)))}};function Hn(){return new Kn}var ge=Hn();function bh(e){return ge.require(e).kind}function wh(e){return ge.resolve(e)?.kind}function vh(e,t=ge){return t.resolve(e)?.ordering===!0}function Rd(e,t,n,r=ge){let o=it(e),i=it(t);if(!o||!i)throw new TypeError("Relationship endpoint must not be empty");let s=r.require(n);if(o===i&&!s.allowSelf)throw new TypeError(`Self relationship is not allowed for ${s.kind}`);return s}function Bt(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function xd(e,t,n){let r=typeof e.source=="string"?e.source.trim():"",o=typeof e.target=="string"?e.target.trim():"";if(!t.has(r)||!t.has(o))throw new TypeError(`Relationship endpoint not found: ${r} -> ${o}`);let i=Rd(r,o,e.kind,n),s=Object.freeze({...e,source:r,target:o,kind:i.kind}),a=i.direction==="undirected"?[r,o].sort().join("\0"):`${r}\0${o}`;return{edge:s,identity:`${i.kind}\0${a}`}}function Vt(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function it(e){return typeof e=="string"?e.trim():""}function Gn(e,t){let n=it(e);return n&&t.has(n)?n:void 0}function Nd(e,t,n){let r=[t],o=t;for(;o!==e;)o=n.get(o),r.push(o);return r.reverse()}var zo=class e{#e;#n;#o;#r;#s=new Map;#a=new Map;constructor(t,n,r=ge){this.#e=r,this.#n=new Set([...t].filter(i=>typeof i=="string").map(i=>i.trim()).filter(Boolean)),this.#o=Object.freeze([...this.#n].sort());let o=new Map;for(let i of n){let{edge:s,identity:a}=xd(i,this.#n,r);o.set(a,s)}this.#r=Object.freeze([...o.values()].sort(Bt));for(let i of this.#r)Vt(this.#s,i.source,i),Vt(this.#a,i.target,i),r.require(i.kind).direction==="undirected"&&(Vt(this.#s,i.target,i),Vt(this.#a,i.source,i))}static fromItems(t,n=ge){let r=new Set(t.map(i=>it(i.id)).filter(Boolean)),o=[];for(let i of t){let s=it(i.id);if(!s)continue;let a=Gn(i.parent,r);a&&o.push({source:s,target:a,kind:"parent"});let c=Gn(i.blocked_by,r);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let d of i.dependencies??[]){let l=Gn(d.id,r);l&&n.resolve(d.kind)&&o.push({source:s,target:l,kind:d.kind,createdAt:d.created_at,author:d.author})}}return new e(r,o,n)}edges(){return this.#r}incidentEdges(t){this.#i(t);let n=this.#s.get(t)??[],r=this.#a.get(t)??[];if(n.length===0)return Object.freeze([...r]);if(r.length===0)return Object.freeze([...n]);let o=[],i=0,s=0;for(;i<n.length||s<r.length;){let a=n[i],c=r[s],d=a===void 0?c:c===void 0||Bt(a,c)<=0?a:c;o.at(-1)!==d&&o.push(d),a===d&&(i+=1),c===d&&(s+=1)}return Object.freeze(o)}nodes(){return this.#o}hasNode(t){return this.#n.has(t)}registry(){return this.#e}#i(t){if(!this.#n.has(t))throw new TypeError(`Relationship node not found: ${t}`)}#c(t,n){if(!n)return!0;let r=this.#e.require(t.kind);return n.has(t.kind)||r.inverse!==void 0&&n.has(r.inverse)}#t(t,n,r){let o=[...n==="incoming"?[]:this.#s.get(t)??[],...n==="outgoing"?[]:this.#a.get(t)??[]];return[...new Set(o)].filter(i=>this.#c(i,r)).map(i=>({id:i.source===t?i.target:i.source,edge:i})).sort((i,s)=>i.id.localeCompare(s.id)||Bt(i.edge,s.edge))}adjacency(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=[...new Set(o.map(c=>c.id))],a=s.slice(0,i);return{value:a,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:a.length<s.length,nextCursor:a.at(-1)}}}neighborEdges(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(a=>this.#e.require(a).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=o.slice(0,i);return{value:s,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:s.length<o.length,nextCursor:s.at(-1)?.id}}}closure(t,n={}){this.#i(t);let r=n.kinds?new Set(n.kinds.map(m=>this.#e.require(m).kind)):void 0,o=n.direction??"outgoing",i=n.limit??Number.POSITIVE_INFINITY,s=n.maxDepth??Number.POSITIVE_INFINITY,a=new Set([t]),c=[],d=[{id:t,depth:0}],l=0,f=0,u=!1;e:for(let m=0;m<d.length;m+=1){n.signal?.throwIfAborted();let p=d[m];l+=1;let _=this.#t(p.id,o,r);if(f+=_.length,p.depth>=s){_.some(g=>!a.has(g.id))&&(u=!0);continue}for(let g of _)if(!a.has(g.id)){if(c.length>=i){u=!0;break e}a.add(g.id),c.push(g.id),d.push({id:g.id,depth:p.depth+1})}}return{value:c,meta:{visitedNodes:l,inspectedEdges:f,truncated:u,nextCursor:c.at(-1)}}}shortestPath(t,n,r={}){if(this.#i(t),this.#i(n),t===n)return{value:[t],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}};let o=r.kinds?new Set(r.kinds.map(m=>this.#e.require(m).kind)):void 0,i=r.direction??"outgoing",s=r.maxDepth??Number.POSITIVE_INFINITY,a=[{id:t,depth:0}],c=new Map,d=new Set([t]),l=0,f=0,u=!1;for(let m=0;m<a.length;m+=1){r.signal?.throwIfAborted();let p=a[m];l+=1;let _=this.#t(p.id,i,o);if(f+=_.length,p.depth>=s){_.some(g=>!d.has(g.id))&&(u=!0);continue}for(let g of _)if(!d.has(g.id)){if(c.set(g.id,p.id),g.id===n)return{value:Nd(t,n,c),meta:{visitedNodes:l,inspectedEdges:f,truncated:!1}};d.add(g.id),a.push({id:g.id,depth:p.depth+1})}}return{value:[],meta:{visitedNodes:l,inspectedEdges:f,truncated:u}}}subgraph(t,n={}){let r=this.closure(t,n),o=[t,...r.value].sort(),i=new Set(o),s=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,a=new Set;for(let c of o)for(let d of this.#s.get(c)??[])i.has(d.source)&&i.has(d.target)&&this.#c(d,s)&&a.add(d);return{value:{nodes:o,edges:[...a].sort(Bt)},meta:r.meta}}};function Eh(e,t,n=ge){return{source:e,target:t.id,kind:n.require(t.kind).kind,createdAt:t.created_at,author:t.author}}import jd from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0ca7f52c-fb31-5cd9-b689-a918f4e61816")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="75f74db3-9547-5c78-8561-f371c016b90d")}catch{}})();function re(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Dd(e){let t=e.key.trim();if(t.length===0)return null;let n=re(e.aliases),r=e.description?.trim();return{key:t,values:re(e.values),required:e.required===!0?!0:void 0,aliases:n.length>0?n:void 0,description:r&&r.length>0?r:void 0}}var Pd=e=>e,Bo=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function $d(e,t){let n=t(e.command);if(n===null)return null;let r=e.option.trim();return r.length===0?null:{command:n,option:r,required:e.required,visible:e.visible,enabled:e.enabled}}function Md(e,t){let n=new Map;for(let r of e??[]){let o=$d(r,t);o&&n.set(`${o.command}:${o.option.toLowerCase()}`,o)}return[...n.values()].sort((r,o)=>r.command===o.command?r.option.localeCompare(o.option):r.command.localeCompare(o.command))}function qo(e,t){return t?re(e):void 0}function Yn(e){let t=e?.trim();return t&&t.length>0?t:void 0}function Xn(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 Vo(e,t={}){let n=t.resolvePolicyCommand??Pd,r=e.name.trim();if(r.length===0)return null;let o=e.required_create_fields!==void 0,i=e.required_create_repeatables!==void 0,s=e.options!==void 0,a=e.command_option_policies!==void 0,c=re(e.aliases),d=(e.options??[]).map(f=>Dd(f)).filter(f=>f!==null).sort((f,u)=>f.key.localeCompare(u.key)),l=Md(e.command_option_policies,n);return{name:r,description:Yn(e.description),default_status:Yn(e.default_status),...e.execution_role===void 0?{}:{execution_role:Xn(e.execution_role)},folder:Yn(e.folder),aliases:c.length>0?c:void 0,required_create_fields:qo(e.required_create_fields,o),required_create_repeatables:qo(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 Ld=Object.freeze({decision:"human",milestone:"gate"}),Fd=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],Ud=["dep","comment","note","learning","file","test","doc"],Wo=["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"],zd=["title","description","type","status","priority","tags","body",...Wo,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],qd=["title","description","body","status","closeReason","priority","type","tags",...Wo,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],Ko={"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"},Bd={...Ko},Vd={...Ko},Ho=[["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"]],Yo=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function Xo(e){return Object.fromEntries(e)}var Gd=Xo([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...Ho,["author","--author"],["message","--message"],["dep","--dep"],...Yo]),Wd=Xo([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...Ho,...Yo,["author","--author"],["message","--message"],["force","--force"]]);function Kd(e){return e.trim().replace(/^--+/,"").toLowerCase()}function Hd(e){return e==="create"?zd:qd}function Yd(e){return e==="create"?Bd:Vd}function Jo(e,t){let n=Kd(t);return n.length===0?void 0:Yd(e)[n]||Hd(e).find(r=>r.toLowerCase()===n)}function xh(e,t){return(e==="create"?Gd:Wd)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function Qn(e){let t=Jd(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function Xd(e){let t=e.trim(),n=t.replaceAll("\\","/").replace(/^\/+/,""),r=jd.posix.normalize(n);if(t.includes("\0")||/^[A-Za-z]:/.test(r)||r==="."||r===".."||r.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return r}function Jd(e){let t=e.trim().toLowerCase(),n="",r=!1;for(let o of t){let i=o.charCodeAt(0),s=i>=97&&i<=122,a=i>=48&&i<=57;if(s||a){r&&n.length>0&&(n+="-"),n+=o,r=!1;continue}n.length>0&&(r=!0)}return n}function Qd(e){return Vo(e,{resolvePolicyCommand:Bo})}function st(e,t){let n=e[t];return Array.isArray(n)?n.filter(r=>typeof r=="string"):void 0}function Zd(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:st(t,"values")??[],required:t.required===void 0?void 0:!!t.required,aliases:st(t,"aliases"),description:typeof t.description=="string"?t.description:void 0}}function el(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;if(typeof t.command!="string"||typeof t.option!="string")return null;let n=t.command.trim().toLowerCase();return n!=="create"&&n!=="update"?null:{command:n,option:t.option,required:t.required===void 0?void 0:!!t.required,visible:t.visible===void 0?void 0:!!t.visible,enabled:t.enabled===void 0?void 0:!!t.enabled}}function tl(e){if(Array.isArray(e.options))return e.options.map(t=>Zd(t)).filter(t=>t!==null)}function nl(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>el(t)).filter(t=>t!==null)}function rl(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e,n=typeof t.name=="string"?t.name:"";if(n.trim().length===0)return null;let r=typeof t.folder=="string"?t.folder:void 0,o=typeof t.description=="string"?t.description:void 0,i=typeof t.default_status=="string"?t.default_status:void 0;return{name:n,description:o,default_status:i,execution_role:Xn(t.execution_role),folder:r,aliases:st(t,"aliases"),required_create_fields:st(t,"required_create_fields"),required_create_repeatables:st(t,"required_create_repeatables"),options:tl(t),command_option_policies:nl(t)}}function ol(e,t){return e.required_create_fields?re(e.required_create_fields):t?.required_create_fields??[]}function il(e,t){return e.required_create_repeatables?re(e.required_create_repeatables):t?.required_create_repeatables??[]}function sl(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function al(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function cl(e,t){let n=t?.name??e.name,r=e.description??t?.description,o=e.default_status??t?.default_status,i=Xd(e.folder??t?.folder??Qn(n)),s={name:n,execution_role:e.execution_role,folder:i,aliases:re([...t?.aliases??[],...e.aliases??[]]),required_create_fields:ol(e,t),required_create_repeatables:il(e,t),options:sl(e,t),command_option_policies:al(e,t)};return r&&(s.description=r),o&&(s.default_status=o),s}function Go(e,t){for(let n of e){let r=Qd(n);if(!r)continue;let o=r.name.toLowerCase(),i=t.get(o);t.set(o,cl({...r,execution_role:r.execution_role??i?.execution_role},i))}}function dl(e){if(!e)return[];let t=[];for(let n of e.item_types??[]){let r=n.types;if(Array.isArray(r))for(let o of r){let i=rl(o);i&&t.push(i)}}return t}function Nh(e,t=null){let n=new Map;for(let c of Lo)n.set(c.toLowerCase(),{name:c,execution_role:Ld[c.toLowerCase()]??"agent",folder:ot[c],aliases:[],required_create_fields:[...Fd],required_create_repeatables:[...Ud],options:[],command_option_policies:[]});Go(e.item_types?.definitions??[],n),Go(dl(t),n);let r=[...n.values()].sort((c,d)=>c.name.localeCompare(d.name)),o={},i={},s={};for(let c of r){o[c.name]=c,s[c.name]=c.folder,i[c.name.toLowerCase()]=c.name;for(let d of c.aliases)i[d.toLowerCase()]=c.name}let a=[...new Set(r.map(c=>c.folder))].sort((c,d)=>c.localeCompare(d));return{types:r.map(c=>c.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function ll(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function ul(e,t){let n=ll(e,t);if(n)return t.by_type[n]}function fl(e,t,n,r){for(let o of r){let i=Jo(n,o);if(i){e.required.add(i);continue}e.errors.push(`Unsupported base required option "${o}" for command "${n}" on type "${t.name}"`)}}function Jn(e,t,n){if(n){e.add(t);return}e.delete(t)}function ml(e,t,n,r){let o=Jo(n,r.option);if(!o){e.errors.push(`Unsupported command_option_policies option "${r.option}" for command "${n}" on type "${t.name}"`);return}r.required!==void 0&&Jn(e.required,o,r.required),r.visible!==void 0&&Jn(e.hidden,o,!r.visible),r.enabled!==void 0&&Jn(e.disabled,o,!r.enabled)}function pl(e,t,n){for(let r of t.command_option_policies)r.command===n&&ml(e,t,n,r)}function _l(e,t,n){for(let r of e.required)e.disabled.has(r)&&e.errors.push(`Option "${r}" cannot be both required and disabled for command "${n}" on type "${t.name}"`)}function Dh(e,t,n){let r=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:r};return fl(a,e,t,n),pl(a,e,t),_l(a,e,t),{required:[...o],hidden:[...i].sort((c,d)=>c.localeCompare(d)),disabled:[...s].sort((c,d)=>c.localeCompare(d)),errors:r}}function gl(e){let t=new Map;for(let n of e.options){t.set(n.key.toLowerCase(),n);for(let r of n.aliases??[])t.set(r.toLowerCase(),n)}return t}function yl(e,t,n){let r=e.values;if(r.length===0)return t;let o=new Map(r.map(i=>[i.toLowerCase(),i])).get(t.toLowerCase());if(!o){n.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${r.join(", ")}`);return}return o}function Ph(e,t,n){let r=ul(e,n);if(!r)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=gl(r),s={};for(let[c,d]of Object.entries(t??{})){let l=c.trim(),f=d.trim();if(l.length===0){o.push("type option keys must not be empty");continue}if(f.length===0){o.push(`type option "${l}" must not be empty`);continue}let u=i.get(l.toLowerCase());if(!u){let p=r.options.map(_=>_.key).join(", ");o.push(r.options.length>0?`Unknown type option "${l}" for type "${r.name}". Allowed: ${p}`:`Type "${r.name}" does not define any configurable type options`);continue}let m=yl(u,f,o);m!==void 0&&(s[u.key]=m)}for(let c of r.options)c.required&&!(c.key in s)&&o.push(`Missing required type option "${c.key}" for type "${r.name}"`);let a=Object.keys(s).sort((c,d)=>c.localeCompare(d));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(c=>[c,s[c]])),errors:o}}import{readFileSync as hl,readdirSync as jh,realpathSync as Qo,statSync as ei}from"node:fs";import bl from"node:os";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]="7f4b8abe-997c-549c-9791-87c78506c8b5")}catch{}})();var wl={json_markdown:".md",toon:".toon"},vl={".md":"json_markdown",".toon":"toon"};var Vh=[".md",".toon"];function Wt(e){try{return ei(e),!0}catch{return!1}}function El(e){let t=E.resolve(e),n=[];for(;E.dirname(t)!==t;)try{return E.join(Qo(t),...n)}catch(r){if(!Bn(r))throw r;n.unshift(E.basename(t)),t=E.dirname(t)}return E.join(Qo(t),...n)}function kl(e){try{return ei(e),!0}catch(t){if(Bn(t))return!1;throw t}}function Ol(e){try{let t=JSON.parse(hl(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function Sl(e){let t=El(e);for(;;){let n=E.join(t,Ut),r=E.join(n,zt);if(Wt(r))return n;let o=E.join(t,zt);if(Wt(o)&&Ol(o))return t;if(kl(E.join(t,".git")))return n;let i=E.dirname(t);if(i===t)return;t=i}}function Zn(e){return Sl(e)??E.resolve(e,Ut)}function ti(e,t){let n=process.env.PM_PATH,r=t?.trim()||n?.trim();if(r){let o=E.resolve(e,r);if(!Wt(Zo(o))){let i=E.join(o,Ut);if(Wt(Zo(i)))return i}return o}return Zn(e)}function ni(e){let t=E.resolve(e),n=E.dirname(t);return E.basename(t)==="pm"&&E.basename(n)===".agents"?E.dirname(n):t}function ri(e){let t=process.env.PM_GLOBAL_PATH?.trim(),n=t&&t.length>0?t:E.join(bl.homedir(),".pm-cli");return E.resolve(e,n)}function Zo(e){return E.join(e,zt)}function Al(e,t,n=ot){let r=n[t]??Qn(t);return E.join(e,r)}function Gh(e,t,n,r="toon",o=ot){return E.join(Al(e,t,o),`${n}${wl[r]}`)}function Wh(e){let t=e.replaceAll("\\","/"),n=E.posix.extname(t).toLowerCase();return vl[n]??null}function Kh(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new h("Invalid history item id: expected a single filename.",y.USAGE);return E.join(e,"history",`${t}.jsonl`)}function er(e,t){return E.join(e,"locks",`${t}.lock`)}function Hh(e){return E.join(e,"runtime")}import Tl 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 Cl(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 Il(e){let t=Object.keys(e).sort(),n={};for(let r of t){let o=e[r];o!==void 0&&(n[r]=Kt(o))}return n}function Kt(e){let t=Cl(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(r=>Kt(r));if(e instanceof Date)return e.toISOString();let n=e;if(typeof n.toJSON=="function"){let r=n.toJSON();if(r!==e)return Kt(r)}return Il(e)}function ye(e){return JSON.stringify(Kt(e))}function oi(e,t,n,r){for(let o=0;o<t.length;o+=1)if(!n.has(o)&&r(e,t[o]))return n.add(o),!0;return!1}function Rl(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function xl(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function Nl(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let n=[...t],r=new Set;for(let o of e)if(!oi(o,n,r,K))return!1;return!0}function Dl(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let n=[...t.entries()],r=new Set;for(let[o,i]of e.entries())if(!oi([o,i],n,r,([s,a],[c,d])=>K(s,c)&&K(a,d)))return!1;return!0}function Pl(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,r)=>K(n,t[r]))}function $l(e,t){let n=Object.keys(e).sort((o,i)=>o.localeCompare(i)),r=Object.keys(t).sort((o,i)=>o.localeCompare(i));if(n.length!==r.length)return!1;for(let o=0;o<n.length;o+=1){let i=n[o];if(i!==r[o]||!K(e[i],t[i]))return!1}return!0}var Ml=[Rl,xl,Nl,Dl,Pl];function K(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let n of Ml){let r=n(e,t);if(r!==void 0)return r}return $l(e,t)}function Jh(e){return Tl.createHash("sha256").update(e,"utf8").digest("hex")}function Qh(e,t){let n={};for(let o of t){let i=e[o];i!==void 0&&(n[o]=i)}let r=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of r){let i=e[o];i!==void 0&&(n[o]=i)}return n}import{createHash as si}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 jl=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],ii=256,tr=64;function z(e){throw new h(`Invalid workflow policy: ${e}`,y.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function Q(e,t,n){if(typeof e!="object"||e===null||Array.isArray(e))return z(`${n} must be an object`);let r=e;return Object.keys(r).some(o=>!t.includes(o))?z(`${n} contains an unknown key`):r}function he(e,t,n=128){return typeof e!="string"||!e.trim()||e.length>n?z(`${t} must be nonempty text of at most ${n} characters`):e.trim()}function at(e,t){if(!Array.isArray(e)||e.length===0||e.length>tr)return z(`${t} requires 1-${tr} terms`);let n=e.map(r=>he(r,t));return t==="fields"&&n.some(r=>!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$/.test(r)||r.split(".").some(o=>["__proto__","constructor","prototype"].includes(o)))?z("fields must be safe metadata paths of at most eight segments"):[...new Set(n)]}function Ll(e){let t=Q(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(Q(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>tr?z("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(n=>!Array.isArray(n)||n.length!==2?z("transition pairs need two statuses"):[he(n[0],"from"),he(n[1],"to")])}):t.kind==="authors"?(Q(t,["kind","authors"],"authors rule"),{kind:"authors",authors:at(t.authors,"authors")}):t.kind==="require_fields"?(Q(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:at(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(Q(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:at(t.fields,"fields"),authors:at(t.authors,"authors")}):z("unknown rule kind")}function Fl(e){let t={},n=Q(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let r of["types","tags","statuses","operations","parents"])n[r]!==void 0&&(t[r]=at(n[r],r));if(n.dependency!==void 0){let r=Q(n.dependency,["kind","id"],"dependency");t.dependency={kind:he(r.kind,"dependency kind"),...r.id===void 0?{}:{id:he(r.id,"dependency id")}}}return t}function Ul(e){let t=Q(e,["id","description","subject","effect","rule"],"policy"),n=he(t.id,"id");return/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(n)?t.effect!==void 0&&(typeof t.effect!="string"||!["advise","warn","refuse"].includes(t.effect))?z("effect must be advise, warn, or refuse"):{id:n,rule:Ll(t.rule),...t.subject===void 0?{}:{subject:Fl(t.subject)},...t.description===void 0?{}:{description:he(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:z("id must be a stable token")}function zl(e){let t=Q(e,["version","enforcement","policies"],"document");if(t.version!==1)return z("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return z("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>ii)return z(`policies must contain at most ${ii} declarations`);let n=t.policies.map(Ul);return new Set(n.map(r=>r.id)).size!==n.length?z("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:n}}function Ht(e,t){let n=e;for(let r of t.split(".")){if(typeof n!="object"||n===null||!Object.hasOwn(n,r))return;n=n[r]}return n}function ql(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 ai(e){return si("sha256").update(ye(e)).digest("hex")}function Bl(e,t){let n=e.rule.kind==="approval"?e.rule.fields:[];return si("sha256").update(ye({id:t.id,fields:n.map(r=>[r,Ht(t,r)])})).digest("hex")}function Vl(e,t){return Array.isArray(t)&&t.some(n=>typeof n=="object"&&n!==null&&"kind"in n&&n.kind===e.kind&&(e.id===void 0||"id"in n&&n.id===e.id))}function Gl(e,t,n){return!(e.types&&!e.types.some(r=>r.toLowerCase()===String(t.type).toLowerCase())||e.statuses&&!e.statuses.includes(String(t.status))||e.operations&&!e.operations.includes(n)||e.parents&&!e.parents.includes(String(t.parent))||e.tags&&(!Array.isArray(t.tags)||!e.tags.some(r=>t.tags.includes(r)))||e.dependency&&!Vl(e.dependency,t.dependencies))}function Wl(e,t){if(t.completeness_only&&(e.rule.kind!=="require_fields"||e.subject?.operations!==void 0)||e.rule.kind==="approval"&&t.before===null)return!1;let n=e.subject??{},r=t.after?.status??t.before?.status;return[t.before,t.after].some(o=>o!==null&&Gl(n,{...o,status:r},t.operation))}function Kl(e,t,n,r){let o=["type","tags","parent","dependencies"].some(i=>!K(t.before?.[i],t.after?.[i]));return t.after&&(t.completeness_only||n||r||o)?e.filter(i=>!ql(Ht(t.after,i))):[]}function Hl(e,t,n,r){let o=t.after??t.before,i=Bl(e,o);return t.approvals?.some(s=>s.policy_fingerprint===r&&s.content_fingerprint===i&&s.author!==t.author&&n.includes(s.author))??!1}function Yl(e,t,n){let r=e.rule,o=t.before?.status!==t.after?.status,i="fields"in r&&r.fields.some(s=>!K(Ht(t.before,s),Ht(t.after,s)));switch(r.kind){case"require_fields":{let s=Kl(r.fields,t,o,i);return{satisfied:s.length===0,missing_fields:s,remediation:"Supply the declared required fields before this lifecycle transition."}}case"transition":return{satisfied:!o||r.allowed.some(([s,a])=>s===String(t.before?.status??"$create")&&a===String(t.after?.status??"$delete")),missing_fields:[],remediation:"Choose a declared allowed transition; inspect pm schema policies."};case"authors":return{satisfied:r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared workflow actor perform this operation."};case"field_writers":return{satisfied:!i||r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared field writer change the protected fields."};case"approval":return{satisfied:!o||Hl(e,t,r.authors,n),missing_fields:[],remediation:`Record an independent approval with pm schema policy-approve <item-id> --policy ${e.id} after preparing the reviewed fields.`}}}function ci(e,t,n){let r=e.policies.filter(o=>Wl(o,t)).map(o=>{let i=o.effect??"advise",s=n(o);return{policy_id:o.id,policy_fingerprint:s,rule:o.rule.kind,effect:i==="refuse"&&e.enforcement!=="refuse"?"warn":i,...Yl(o,t,s)}});return{allowed:!r.some(o=>!o.satisfied&&o.effect==="refuse"),decisions:r,warnings:r.filter(o=>!o.satisfied).map(o=>`workflow_policy:${o.effect}:${o.policy_id}:${o.rule}`)}}function ob(e,t){return ci(e,t,ai)}function ib(e){let t=zl(e),n=new Map(t.policies.map(r=>[r,ai(r)]));return r=>ci(t,r,o=>n.get(o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="451b262c-a9b6-5f1c-b397-2686a5fd953a")}catch{}})();var Xl=[["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"})),Jl=[...["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"})),Ql=[["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"})),Zl=[...Jl,...Ql,...["init","config","schema","profile"].map(e=>({alias:e,canonical:`workspace ${e}`,canonical_argv:["workspace",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-npr3"})),...[...["comments","notes","learnings","files","docs","deps","append","test"].map(e=>[e,`item ${e}`,"pm-yql1"]),["test-runs-worker","item test worker","pm-lp4j"],...["statuses","tags","types"].map(e=>[`completion-${e}`,`completion ${e}`,"pm-szdc"]),["history-author-acknowledge","history acknowledge","pm-djyvbk"],["copy","item copy","pm-m6g87m"],["merge","workspace merge","pm-m6g87m"],["duplicates","item duplicates","pm-fmy9ih"],["dedupe-audit","item duplicates audit","pm-fmy9ih"],["dedupe-merge","item duplicates merge","pm-fmy9ih"],["comments-audit","item audit-comments","pm-fmy9ih"],["search-advanced","search advanced","pm-wfskfn"],...["meet","event","remind"].map(e=>[e,`calendar ${e}`,"pm-o3fh"])].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:n}))],nr=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...Xl,...Zl,...["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 ab(e){let t;for(let n of nr)n.canonical_argv.length<=(t?.canonical_argv.length??0)||n.canonical_argv.every((r,o)=>r===(o===0&&e[o]==="ctx"?"context":e[o]))&&(t=n);return t}function eu(e){let t=e.trim().replace(/\s+/gu," ");return nr.find(n=>n.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function ct(e){return eu(e)}var Yt=[...nr,...[["ctx","context"],["packages","package"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:[t],lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-pbyu"})),...[["start-task","claim","--start"],["pause-task","release","--pause"],["close-task","close","--release-assignment"]].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:[t,n],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-eq4x"})),{alias:"tests",canonical:"item test",canonical_argv:["item","test"],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-u4t9gp"},...[["fetch","get"],["read","get"],["show","get"],["view","get"],["comment","comments"],["note","notes"],["learning","learnings"]].map(([e,t])=>({alias:e,canonical:["comments","notes","learnings"].includes(t)?`item ${t}`:t,canonical_argv:["comments","notes","learnings"].includes(t)?["item",t]:[t],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-pbyu"})),...[["extension list","extension catalog"],["extension scaffold","extension init"],["package list","package catalog"],["package scaffold","package init"],["packages list","package catalog"],["packages scaffold","package init"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-ya7x55"})),{alias:"list-all",canonical:"list",canonical_argv:["list","--all"],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"},...[["list-draft","draft"],["list-open","open"],["list-in-progress","in_progress"],["list-blocked","blocked"],["list-closed","closed"],["list-canceled","canceled"]].map(([e,t])=>({alias:e,canonical:"list",canonical_argv:["list","--status",t],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"})),...[["extension","package"],["install","package install"],["upgrade","package upgrade"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-tnud"}))],cb=Object.fromEntries(Yt.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function db(e){let t=e.trim().toLowerCase();return Yt.find(n=>n.alias===t)}function lb(e){return`Deprecated command \`${e.alias}\`; use \`pm ${e.canonical_argv.join(" ")}\`.`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3348c61d-a03e-5023-a5dc-fd6149f478c1")}catch{}})();var tu=[...X],nu=[...Le],ru=[...Mt],_b=[...jt],gb=[...Lt],ou=[...Ft],Xt=["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"],yb=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],hb=["install","reconcile","report","driver"],iu=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],su=["upgrade"],au=["reopen"],di={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Fe=Object.freeze(Xt.flatMap(e=>e in di?[]:e==="extension"||e==="package"?[...iu.map(t=>`${e}-${t}`),...e==="package"?su.map(t=>`package-${t}`):[],e]:e==="item"?au.map(t=>`item-${t}`):[e])),cu=Object.freeze(Yt.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Fe.includes(e.alias)).map(e=>e.alias)),bb=Object.freeze(Fe.filter(e=>!cu.includes(e)));function wb(e=Xt,t=Fe,n=di){let r=new Set(t),o=new Set(e);return{missing_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]===void 0),waived_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]!==void 0),stale_waivers:Object.keys(n).filter(i=>!o.has(i)||r.has(i)||t.some(s=>s.startsWith(`${i}-`)))}}function vb(e){return Fe.includes(e)}function Eb(e){return tu.includes(e)}function kb(e){return nu.includes(e)}function Ob(e){return ru.includes(e)}function Sb(e){return ou.includes(e)}var Ab=new Set(["update","item-reopen","close","claim","release","start-task","pause-task","close-task","restore","append","update-many","close-many","delete","comments","notes","learnings","files","docs","test","test-all","plan","history-redact","history-repair","history-compact","validate"]);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="447bb510-051a-5dce-8b7d-e27f4ca781f4")}catch{}})();var Jt={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},Qt=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),be=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","learnings","files","docs","stats","aggregate","duplicates","package-catalog","package-manage","comments-audit","assurance"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f8657910-1392-5fae-afda-614b96dc8320")}catch{}})();function A(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function du(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function li(e){return e?j(e):{}}function ui(e){return e?j(e):du()}function j(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 lu=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),uu=["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 fu(e,t){for(let n of uu){let r=e[n];if(r===void 0)continue;if(!Array.isArray(r)||r.some(i=>typeof i!="string"))return!1;let o=r.map(i=>lu.has(n)?A(i):i.trim()).filter(i=>i.length>0);t[n]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function mu(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n;if(r.format!=="json"&&r.format!=="toon"||!Array.isArray(r.commands)||r.commands.some(o=>typeof o!="string")||typeof r.result_discriminator!="boolean")return null;t.push({format:r.format,commands:[...new Set(r.commands.map(o=>A(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:r.result_discriminator})}return t.sort((n,r)=>n.format.localeCompare(r.format))}function pu(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n.commands;if(!Array.isArray(r)||r.some(o=>typeof o!="string"))return null;t.push({commands:[...new Set(r.map(o=>A(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return t}function Zt(e){if(e==null)return;if(typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.schema_version!==1)return null;let n={schema_version:1};if(!fu(t,n))return null;let r=t.preflight_overrides;if(r!==void 0&&(!Number.isInteger(r)||r<0))return null;typeof r=="number"&&(n.preflight_overrides=r);let o=t.renderer_ownership;if(o!==void 0){let s=mu(o);if(s===null)return null;n.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=pu(i);if(s===null)return null;n.preflight_ownership=s}return n}function xb(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]="d4155698-c244-5623-b627-92dd25297125")}catch{}})();var _u=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields",extension_command_availability:"read_output"},{flag:"--output-limit",value_name:"count",extension_command_availability:"read_output"},{flag:"--output-budget",value_name:"tokens",extension_command_availability:"read_output"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state",extension_command_availability:"read_output"},{flag:"--output-cursor",value_name:"cursor",extension_command_availability:"read_output"},{flag:"--output-row-contract",extension_command_availability:"read_output"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"],discovery_value_name:"path"},{flag:"--no-extensions",extension_command_availability:"never"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"},{flag:"--expect-hash",value_name:"revision"}]),en=new Set(_u.flatMap(e=>[e.flag,...e.aliases??[]]));(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="81054684-60df-57c9-af9d-0996874c1024")}catch{}})();var fi=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function rr(e){if(typeof e!="string")return null;let t=fi.exec(e.trim());if(!t)return null;let n=t[2];return{name:t[1],valueName:n?n.slice(1,-1):null,optional:n?.startsWith("[")??!1}}function $b(e){let t=rr(e);return t?t.name:typeof e=="string"&&e.trim()||null}function gu(e){if(typeof e!="string")return null;let t=e.trim(),n=t.split(/[ =]/,1)[0];return en.has(n)||en.has(`--${n.slice(2).replaceAll("_","-")}`)?"host_owned_flag_collision":fi.test(t)?null:"malformed_long_flag"}function mi(e,t){let n=[e,t].find(i=>typeof i=="string"&&en.has(i.trim().split(/[ =]/,1)[0]));if(typeof n=="string")return{token:n.trim().split(/[ =]/,1)[0],failure:"host_owned_flag_collision"};if(typeof e!="string")return null;let r=e.trim(),o=gu(r);return o===null?null:{token:r,failure:o}}function pi(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 _i=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function tn(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.hasOwn(_i,t)?_i[t]:null}function yu(e,t,n){return!!(e.value_name?.trim()||t||n||e.required===!0||e.list===!0||e.repeatable===!0)}function hu(e){return(e.value_type?.trim()||e.type?.trim())?.toLowerCase()}function Lb(e){let t=hu(e),n=tn(t),r=rr(e.long),o=e.value_name?.trim()||null,i=!(n==="boolean"&&t!=="bool")&&yu(e,r?.valueName,t),s=r?.valueName?r.optional:t==="bool";return{value_type:n,value_arity:i?s?"optional":"required":"none",value_name:i?o??r?.valueName??"value":null}}function gi(e){let t=[],n=r=>{if(Array.isArray(r)){for(let o of r)n(o);return}if(typeof r=="string"){for(let o of r.split(",")){let i=o.trim();i.length>0&&t.push(i)}return}r!=null&&t.push(r)};return n(e),t}function yi(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 Fb(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]="4a7b042c-7fb8-57a5-8f94-de44f82d7589")}catch{}})();function bu(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function V(e,t){let n=e.slice(0,t),r=n.charCodeAt(n.length-1),o=e.charCodeAt(n.length);return r>=55296&&r<=56319&&o>=56320&&o<=57343?n.slice(0,-1):n}function zb(e){return bu(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function qb(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let n=new Set(e),r=new Set(t),o=0;for(let s of n)r.has(s)&&(o+=1);let i=new Set([...n,...r]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7359c10a-4c56-57ea-8254-fc26b19e5c84")}catch{}})();function dt(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function oe(e){return X.includes(e)}function hi(e){let t=e.trim().toLowerCase();return oe(t)?t:null}function bi(e){return e.filter(t=>!oe(t))}function or(e){let t=e.trim().toLowerCase();return t.length===0?null:$o[t]??null}function wi(e){let t=dt([...e].map(i=>i.toLowerCase())),n=[],r=[];for(let i of t){let s=or(i);if(s){n.push(s),r.push({alias:i,target:s});continue}n.push(i)}let o=[...new Map(r.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:dt(n),legacy_aliases:o}}function wu(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=or(t);if(n)return n;let r=Math.max(1,Math.floor(t.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of X){let a=qt(t,s,r);a!==null&&a<i&&(i=a,o=s)}return o}function vi(e,t,n){let r=X.join(","),o=wu(n)??"none";return`extension_capability_unknown:${e}:${t}:${n}:allowed=${r}:suggested=${o}`}function Ei(e,t,n){let r=n.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${r}`}function vu(e){let t=/^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(e.trim());if(!t)return null;let[,n,r,o,i,s]=t,a=n,c=i.split(",").map(f=>f.trim()).filter(f=>f.length>0),d=or(o),l=(s==="none"?void 0:s)??d??void 0;return{layer:a,name:r,capability:o,allowed_capabilities:c,capability_contract_version:zn,suggested_capability:l,suggestion_source:l?d===l?"legacy_alias":"nearest_match":void 0,legacy_alias_target:d??void 0}}function Eu(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,n,r,o]=t,i=n,s=[...X],a=[];for(let c of o.split(",")){let[d,l]=c.split(">"),f=d?.trim(),u=l?.trim().toLowerCase();!f||!u||!oe(u)||a.push({layer:i,name:r,capability:f,allowed_capabilities:s,capability_contract_version:zn,suggested_capability:u,suggestion_source:"legacy_alias",legacy_alias_target:u})}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]="d8844150-afb4-5f2e-a005-4cfb8482660c")}catch{}})();var ku={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"]},ki=":";function Oi(e,t){return`${e}${ki}${ir(t)}`}function Ou(e){return e.slice(e.indexOf(ki)+1)}function ir(e){return e.trim().toLowerCase()}function Su(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let r=hi(n);r!==null&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function Si(e){let t=new Map,n=(l,f)=>{for(let u of l){let m=Oi(u.layer,u.name),p=t.get(m);p===void 0&&(p=new Set,t.set(m,p)),p.add(f)}},{registrations:r,commands:o,parsers:i,preflight:s,services:a,renderers:c,hooks:d}=e;return n(r.commands,"commands"),n(o.overrides,"commands"),n(o.handlers,"commands"),n(r.flags,"schema"),n(r.item_fields,"schema"),n(r.item_types,"schema"),n(r.relationship_kinds??[],"schema"),n(r.migrations,"schema"),n(r.profiles,"schema"),n(r.importers,"importers"),n(r.exporters,"importers"),n(r.search_providers,"search"),n(r.vector_store_adapters,"search"),n(i.overrides,"parser"),n(s.overrides,"preflight"),n(a.overrides,"services"),n(r.assurance_providers??[],"services"),n(c.overrides,"renderers"),n(d.beforeCommand,"hooks"),n(d.beforeMutation,"hooks"),n(d.afterCommand,"hooks"),n(d.onWrite,"hooks"),n(d.onRead,"hooks"),n(d.onIndex,"hooks"),t}function Au(e,t={}){let n=Si(e),r=new Set;t.extensionName!==void 0&&r.add(ir(t.extensionName));for(let i of t.extensionNames??[])r.add(ir(i));let o=new Set;for(let[i,s]of n)if(!(r.size>0&&!r.has(Ou(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function Tu(e,t){let n=Si(t),r=[];for(let o of e){let i=Su(o.capabilities);if(i.length===0)continue;let s=n.get(Oi(o.layer,o.name))??new Set,a=[...s].sort((d,l)=>d.localeCompare(l)),c=i.filter(d=>!s.has(d));r.push({layer:o.layer,name:o.name,declared:i,used:a,unused:c})}return r}import{existsSync as dm}from"node:fs";import{AsyncLocalStorage as lm}from"node:async_hooks";import ee from"node:path";import Oe from"node:fs/promises";import ke from"node:path";import{pathToFileURL as Rf}from"node:url";import Ai 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 lt(e,t){let n=Ai.relative(e,t);return n.length===0?!0:!n.startsWith("..")&&!Ai.isAbsolute(n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="32aa20df-edf7-543d-b733-841130466f00")}catch{}})();var Cu="__pm_suppress_host_output",sr="@unbrained/pm-cli:suppress-host-output:v1";function Ti(e){return e===void 0?{__pm_suppress_host_output:sr}:{__pm_suppress_host_output:sr,result:e}}function ar(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[Cu]===sr}import Ue from"node:fs";import ie from"node:path";import{fileURLToPath as Iu}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 Ru="@unbrained/pm-cli";function xu(e){try{return JSON.parse(Ue.readFileSync(e,"utf8")).name===Ru}catch{return!1}}function Nu(e){let t=Ue.existsSync(e)&&Ue.statSync(e).isDirectory()?ie.resolve(e):ie.dirname(ie.resolve(e));for(;;){let n=ie.join(t,"package.json");if(Ue.existsSync(n)&&xu(n))return t;let r=ie.dirname(t);if(r===t)return;t=r}}function cr(e,t=[]){let n=Iu(e);return Nu(n)||ie.resolve(ie.dirname(n),...t)}function tw(e,t=[]){try{let n=ie.join(cr(e,t),"package.json");if(!Ue.existsSync(n))return;let r=JSON.parse(Ue.readFileSync(n,"utf8"));return typeof r.version=="string"&&r.version.trim().length>0?r.version:void 0}catch{return}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a797572f-fbc6-5e62-a9b5-5a0bd6ef22b4")}catch{}})();function Du(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function rw(e){return Du(e)??void 0}function ow(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 iw(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function Ii(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function Ri(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 sw(e){let t=Ri(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function aw(e,t,n){let r=Ri(e);return r===null||r<t||r>n?null:r}function cw(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function se(e){return typeof e!="object"||e===null?null:e}function Ci(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function xi(e){let t=Ci(e);if(!t)return null;if(typeof t.activate=="function")return t;let n=Ci(t.default);return typeof n?.activate=="function"?n:null}function dw(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]="559b05dc-0290-5a7c-97b9-ef1e5e8670ba")}catch{}})();function Ni(e){let t={beforeCommand:e.hooks.beforeCommand.length,beforeMutation:e.hooks.beforeMutation.length,afterCommand:e.hooks.afterCommand.length,onWrite:e.hooks.onWrite.length,onRead:e.hooks.onRead.length,onIndex:e.hooks.onIndex.length,commandOverrides:e.commands.overrides.length,commandHandlers:e.commands.handlers.length,parserOverrides:e.parsers.overrides.length,preflightOverrides:e.preflight.overrides.length,serviceOverrides:e.services.overrides.length,rendererOverrides:e.renderers.overrides.length,registrations:Object.fromEntries(Object.entries(e.registrations).map(([n,r])=>[n,r.length]))};return()=>{e.hooks.beforeCommand.length=t.beforeCommand,e.hooks.beforeMutation.length=t.beforeMutation,e.hooks.afterCommand.length=t.afterCommand,e.hooks.onWrite.length=t.onWrite,e.hooks.onRead.length=t.onRead,e.hooks.onIndex.length=t.onIndex,e.commands.overrides.length=t.commandOverrides,e.commands.handlers.length=t.commandHandlers,e.parsers.overrides.length=t.parserOverrides,e.preflight.overrides.length=t.preflightOverrides,e.services.overrides.length=t.serviceOverrides,e.renderers.overrides.length=t.rendererOverrides;for(let[n,r]of Object.entries(t.registrations))e.registrations[n].length=r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="17ae377d-20c2-5e45-825a-48a79c6c7601")}catch{}})();function C(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return t}function P(e,t){if(t!==void 0&&typeof t!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function T(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 Di(e,t){if(t===void 0)return;let n=r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean";if(Array.isArray(t)){for(let[r,o]of t.entries())if(!n(o))throw new TypeError(`${e}[${r}] must be a string, number, or boolean`);return}if(!n(t))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function we(e,t){if(t!==void 0){if(!Array.isArray(t))throw new TypeError(`${e} must be an array of non-empty strings when provided`);for(let[n,r]of t.entries())if(typeof r!="string"||r.trim().length===0)throw new TypeError(`${e}[${n}] must be a non-empty string`)}}function ut(e,t){if(we(e,t),!Array.isArray(t))return[];let n=[],r=new Set;for(let o of t){let i=o.trim();i.length===0||r.has(i)||(r.add(i),n.push(i))}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="34536eba-0f92-5599-a807-5b39b000e733")}catch{}})();var dr=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 Pu=new Set(dr);function $u(e){if(e!==void 0&&!Pu.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${dr.join(", ")}`)}function Pi(e){T("registerCommand definition.action",e.action),T("registerCommand definition.family",e.family),T("registerCommand definition.description",e.description),T("registerCommand definition.intent",e.intent),T("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");$u(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 $i(e,t="",n=""){if(e===void 0)return;if(ze(t)||ze(n))throw new TypeError("Native pm commands and actions cannot declare read_output");let r=C("registerCommand definition.read_output",e);if(Object.keys(r).some(s=>s!=="row_keys")||!Array.isArray(r.row_keys))throw new TypeError("registerCommand definition.read_output requires only row_keys: string[]");let o=Array.from(r.row_keys),i=new Set(["__proto__","constructor","prototype","row_contract","read_output","read_session","omission_receipt","output_budget_truncation"]);if(o.some(s=>typeof s!="string"||!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*$/u.test(s)||s.split(".").some(a=>i.has(a))))throw new TypeError("registerCommand definition.read_output row_keys must be safe dot-delimited property paths");if(new Set(o).size!==o.length||o.some(s=>o.some(a=>a.startsWith(`${s}.`))))throw new TypeError("registerCommand definition.read_output row_keys must be unique and non-overlapping");return Object.freeze({row_keys:Object.freeze([...o])})}function ze(e){let t=e.trim().toLowerCase().replace(/\s+/gu,"-");return Fe.includes(t)||be.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 Mu(e){let t=C("registerExporter options.output",e),n=new Set(["channel","receipt","media_type"]);for(let r of Object.keys(t))if(!n.has(r))throw new TypeError(`registerExporter options.output contains unsupported field ${r}`);if(t.channel!=="stdout"&&t.channel!=="file")throw new TypeError("registerExporter options.output.channel must be stdout|file");if(t.receipt!==void 0&&t.receipt!=="suppress"&&t.receipt!=="render")throw new TypeError("registerExporter options.output.receipt must be suppress|render");if(t.channel==="stdout"&&t.receipt==="render")throw new TypeError("registerExporter stdout artifacts cannot render a host receipt");return T("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 Mi(e,t,n){if(e==="registerImporter"&&t.output!==void 0)throw new TypeError("registerImporter options.output is exporter-only");if(e!=="registerExporter"||t.output===void 0)return;let r=Mu(t.output);return!n&&r.channel==="stdout"&&(t.description="Export items with the registered extension adapter. Artifact bytes are written exclusively to stdout and the host receipt is suppressed by default."),r}function lr(e,t,n){return{registration:t,action:n,command:e.command,args:j(e.args),options:j(e.options),global:j(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 ji(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 q(e){return typeof e!="string"?"":e.trim().toLowerCase()}function v(e){return new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))}function ju(e){let t=e.trim().toLowerCase();if(t.length===0)return"";let n=t.split(/[.:/]/).map(r=>r.replace(/[\s_-]+/g,"")).filter(r=>r.length>0);return n.length===0?"":n.length===1?n[0]:`${n[0]}.${n.slice(1).join("")}`}function qe(e){return new Set((e??[]).map(t=>ju(t)).filter(t=>t.length>0))}function Li(e){let t=q(e);return Mt.includes(t)?t:"off"}function Fi(e){let t=q(e);return jt.includes(t)?t:"off"}function ft(e){let t=q(e);return Lt.includes(t)?t:"none"}function ur(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return Mo.includes(t)?t:void 0}function Ui(e){if(typeof e=="string"){let t=ur(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:ur(e.global)??"block",project:ur(e.project)??"block"}:{global:"block",project:"block"}}function Lu(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function k(e){return[...new Set(e)].sort((t,n)=>t.localeCompare(n))}function Fu(e){let t=q(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?ft(e.sandbox_profile):void 0,allowedCapabilities:v(e.allowed_capabilities),blockedCapabilities:v(e.blocked_capabilities),allowedSurfaces:qe(e.allowed_surfaces),blockedSurfaces:qe(e.blocked_surfaces),allowedCommands:v(e.allowed_commands),blockedCommands:v(e.blocked_commands),allowedActions:v(e.allowed_actions),blockedActions:v(e.blocked_actions),allowedServices:v(e.allowed_services),blockedServices:v(e.blocked_services)}}}function zi(e){let t=new Map;for(let n of e??[]){let r=Fu(n);r&&t.set(r.name,r.normalized)}return t}function Uu(e){let t=[],n=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of k([...e.allowedCapabilities,...e.blockedCapabilities]))oe(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of n)for(let i of k([...o.allowedCapabilities,...o.blockedCapabilities]))oe(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let r=new Set(Ft);for(let o of k([...e.allowedSurfaces,...e.blockedSurfaces]))r.has(o)||t.push(`extension_policy_unknown_surface:${o}`);for(let o of n)for(let i of k([...o.allowedSurfaces,...o.blockedSurfaces]))r.has(i)||t.push(`extension_policy_unknown_surface:${o.name}:${i}`);return[...new Set(t)].sort((o,i)=>o.localeCompare(i))}function qi(e){let t=e.extensions?.policy??{},n=v(t.allowed_capabilities),r=v(t.blocked_capabilities),o=qe(t.allowed_surfaces),i=qe(t.blocked_surfaces),s=zi(t.extension_overrides);return{mode:Li(t.mode),trustMode:Fi(t.trust_mode),pmMaxVersionExceededMode:Ui(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:v(t.trusted_extensions),defaultSandboxProfile:ft(t.default_sandbox_profile),allowedExtensions:v(t.allowed_extensions),blockedExtensions:v(t.blocked_extensions),allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:v(t.allowed_commands),blockedCommands:v(t.blocked_commands),allowedActions:v(t.allowed_actions),blockedActions:v(t.blocked_actions),allowedServices:v(t.allowed_services),blockedServices:v(t.blocked_services),overridesByName:s,warnings:Uu({allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function Bi(e){let t=[...e.overridesByName.values()].sort((n,r)=>n.name.localeCompare(r.name)).map(n=>({name:n.name,...n.disabled?{disabled:!0}:{},...n.requireTrusted?{require_trusted:!0}:{},...n.requireProvenance?{require_provenance:!0}:{},...n.sandboxProfile?{sandbox_profile:n.sandboxProfile}:{},...n.allowedCapabilities.size>0?{allowed_capabilities:k(n.allowedCapabilities)}:{},...n.blockedCapabilities.size>0?{blocked_capabilities:k(n.blockedCapabilities)}:{},...n.allowedSurfaces.size>0?{allowed_surfaces:k(n.allowedSurfaces)}:{},...n.blockedSurfaces.size>0?{blocked_surfaces:k(n.blockedSurfaces)}:{},...n.allowedCommands.size>0?{allowed_commands:k(n.allowedCommands)}:{},...n.blockedCommands.size>0?{blocked_commands:k(n.blockedCommands)}:{},...n.allowedActions.size>0?{allowed_actions:k(n.allowedActions)}:{},...n.blockedActions.size>0?{blocked_actions:k(n.blockedActions)}:{},...n.allowedServices.size>0?{allowed_services:k(n.allowedServices)}:{},...n.blockedServices.size>0?{blocked_services:k(n.blockedServices)}:{}}));return{mode:e.mode,trust_mode:e.trustMode,pm_max_version_exceeded_mode:Lu(e.pmMaxVersionExceededMode),require_provenance:e.requireProvenance,trusted_extensions:k(e.trustedExtensions),default_sandbox_profile:e.defaultSandboxProfile,allowed_extensions:k(e.allowedExtensions),blocked_extensions:k(e.blockedExtensions),allowed_capabilities:k(e.allowedCapabilities),blocked_capabilities:k(e.blockedCapabilities),allowed_surfaces:k(e.allowedSurfaces),blocked_surfaces:k(e.blockedSurfaces),allowed_commands:k(e.allowedCommands),blocked_commands:k(e.blockedCommands),allowed_actions:k(e.allowedActions),blocked_actions:k(e.blockedActions),allowed_services:k(e.allowedServices),blocked_services:k(e.blockedServices),extension_overrides:t}}function Vi(e){let t=zi(e.extension_overrides);return{mode:Li(e.mode),trustMode:Fi(e.trust_mode),pmMaxVersionExceededMode:Ui(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:v(e.trusted_extensions),defaultSandboxProfile:ft(e.default_sandbox_profile),allowedExtensions:v(e.allowed_extensions),blockedExtensions:v(e.blocked_extensions),allowedCapabilities:v(e.allowed_capabilities),blockedCapabilities:v(e.blocked_capabilities),allowedSurfaces:qe(e.allowed_surfaces),blockedSurfaces:qe(e.blocked_surfaces),allowedCommands:v(e.allowed_commands),blockedCommands:v(e.blocked_commands),allowedActions:v(e.allowed_actions),blockedActions:v(e.blocked_actions),allowedServices:v(e.allowed_services),blockedServices:v(e.blocked_services),overridesByName:t,warnings:[]}}function ae(e,t){return e.overridesByName.get(q(t))??null}function Be(e,t,n,r,o){return t.has(n)?o:e.size>0&&!e.has(n)?r:null}function Gi(e,t,n){let r=n.trim().toLowerCase(),o=ae(e,t.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return Be(i,s,r,"capability_not_allowlisted","capability_blocked")}function zu(e,t,n){let r=ae(e,t.name),o=r&&r.allowedSurfaces.size>0?r.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...r?r.blockedSurfaces:[]]);return Be(o,i,n,"surface_not_allowlisted","surface_blocked")}function qu(e,t,n){let r=A(n);if(r.length===0)return null;let o=ae(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return Be(i,s,r,"command_not_allowlisted","command_blocked")}function Bu(e,t,n){let r=q(n).replace(/\s+/g,"-");if(r.length===0)return null;let o=ae(e,t.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return Be(i,s,r,"action_not_allowlisted","action_blocked")}function Vu(e,t,n){let r=q(n);if(r.length===0)return null;let o=ae(e,t.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return Be(i,s,r,"service_not_allowlisted","service_blocked")}function Gu(e,t){let n=q(t.name);return ae(e,t.name)?.disabled===!0?"extension_override_disabled":Be(e.allowedExtensions,e.blockedExtensions,n,"extension_not_allowlisted","extension_blocked")}function Wu(e,t){if(e.trustMode==="off")return null;let n=ae(e,t.name),r=q(t.name),o=t.trusted===!0,i=t.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(r)?"extension_not_trusted":(n?.requireTrusted===!0||e.trustMode==="warn"||e.trustMode==="enforce")&&!o?"extension_untrusted":(e.requireProvenance||n?.requireProvenance===!0)&&!i?"provenance_missing_or_unverified":null}function Ku(e,t){if(e.mode==="off")return null;let n=ae(e,t.name)?.sandboxProfile??t.sandboxProfile??e.defaultSandboxProfile;if(n==="none")return null;let r=t.permissions;if(!r)return"sandbox_permissions_missing";let o=i=>r[i]===!0;return n==="restricted"?o("process_spawn")?"sandbox_restricted_disallows_process_spawn":o("env_write")?"sandbox_restricted_disallows_env_write":null:o("process_spawn")?"sandbox_strict_disallows_process_spawn":o("network")?"sandbox_strict_disallows_network":o("fs_write")?"sandbox_strict_disallows_fs_write":o("env_write")?"sandbox_strict_disallows_env_write":null}function nn(e,t,n,r,o={}){let i=Object.entries(o).sort((a,c)=>a[0].localeCompare(c[0])).map(([a,c])=>`${a}=${c}`).join(":"),s=i.length>0?`:${i}`:"";return`extension_policy_${e}_${t}:${n.layer}:${n.name}:reason=${r}${s}`}function Wi(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let n=[],r=Gu(e,t);r&&n.push({reason:r,scope:"extension",mode:e.mode});let o=Wu(e,t);o&&n.push({reason:o,scope:"trust",mode:e.trustMode});let i=Ku(e,t);i&&n.push({reason:i,scope:"extension",mode:e.mode});let s=n.find(c=>c.mode==="enforce");if(s)return{allowed:!1,warning:nn("blocked",s.scope,t,s.reason)};let a=n.find(c=>c.mode==="warn");return a?{allowed:!0,warning:nn("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function Ki(e,t,n){if(e.mode==="off")return{allowed:!0,warning:null};let r=Gi(e,t,n);return r?{allowed:e.mode==="warn",warning:nn(e.mode==="warn"?"violation":"blocked","capability",t,r,{capability:n.trim().toLowerCase()})}:{allowed:!0,warning:null}}function Hu(e,t,n,r,o){let i=typeof r=="string"?Gi(e,t,r):null,s=zu(e,t,n),a=o.command?qu(e,t,o.command):null,c=o.action?Bu(e,t,o.action):null,d=o.service?Vu(e,t,o.service):null;return i??s??a??c??d}function Yu(e,t,n,r){let o={method:q(e).replace(/\s+/g,"_"),surface:t};return n&&(o.capability=n),r.command&&(o.command=A(r.command)),r.action&&(o.action=q(r.action).replace(/\s+/g,"-")),r.service&&(o.service=q(r.service)),o}function Hi(e,t,n,r,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=Hu(e,t,n,o,s);if(!a)return{allowed:!0,warning:null};let c=nn(e.mode==="warn"?"violation":"blocked","registration",t,a,Yu(r,n,o,s));return{allowed:e.mode==="warn",warning:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01116a5e-62d1-591b-9fd0-84ac6e99f8d0")}catch{}})();function rn(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function fr(){return{overrides:[],handlers:[]}}function mr(){return{overrides:[]}}function pr(){return{overrides:[]}}function _r(){return{overrides:[]}}function gr(){return{overrides:[]}}function yr(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[],assurance_providers:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cd1de600-27e4-522b-842e-1993c12e9f0e")}catch{}})();var Xi=100;function Yi(e,t){let n=e[t];if(n!=null)return typeof n!="string"||n.trim().length===0?null:n.trim()}function Xu(e){if(e==null)return;let t=se(e);if(!t)return null;let n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i))){if(r.trim().length===0)return null;let o=t[r];if(typeof o!="string"||o.trim().length===0)return null;n[r.trim()]=o.trim()}return Object.keys(n).length>0?n:void 0}function hr(e,t){let n=e[t];return typeof n!="string"||n.trim().length===0?null:n.trim()}function Ji(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function ve(e){if(e!=null)return typeof e!="boolean"?null:e}function Ju(e){let t=Ji(e.priority);return t===void 0?Xi:t}function Qu(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let n=ft(t);return n!==t.trim().toLowerCase()?null:n}function br(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Zu(e){if(e==null)return;let t=se(e);if(!t)return null;let n=br(t.source),r=br(t.signature),o=br(t.attestation),i=t.verified===void 0||t.verified===null?void 0:typeof t.verified=="boolean"?t.verified:null;return i===null?null:{...n?{source:n}:{},...r?{signature:r}:{},...o?{attestation:o}:{},...typeof i=="boolean"?{verified:i}:{}}}function ef(e){if(e==null)return;let t=se(e);if(!t)return null;let n=ve(t.fs_read),r=ve(t.fs_write),o=ve(t.network),i=ve(t.env_read),s=ve(t.env_write),a=ve(t.process_spawn);return[n,r,o,i,s,a].includes(null)?null:{...typeof n=="boolean"?{fs_read:n}:{},...typeof r=="boolean"?{fs_write:r}:{},...typeof o=="boolean"?{network:o}:{},...typeof i=="boolean"?{env_read:i}:{},...typeof s=="boolean"?{env_write:s}:{},...typeof a=="boolean"?{process_spawn:a}:{}}}function tf(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(n=>typeof n!="string"))return null;let t=wi(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function nf(e){if(e==null)return;let t=se(e);if(!t)return null;let n=t.commands;if(n==null)return;if(!Array.isArray(n)||n.some(o=>typeof o!="string"))return null;let r=[...new Set(n.map(o=>A(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return r.length>0?{commands:r}:void 0}function rf(e){let t=Ji(e.manifest_version);if(t===null)return null;let n=Yi(e,"pm_min_version");if(n===null)return null;let r=Yi(e,"pm_max_version");if(r===null)return null;let o=Xu(e.engines);if(o===null)return null;let i=ve(e.trusted);if(i===null)return null;let s=Qu(e);if(s===null)return null;let a=Zu(e.provenance);if(a===null)return null;let c=ef(e.permissions);if(c===null)return null;let d=tf(e.capabilities);if(d===null)return null;let l=nf(e.activation);if(l===null)return null;let f=Zt(e.contributions);return f===null?null:{manifest_version:t,pm_min_version:n,pm_max_version:r,engines:o,trusted:i,sandbox_profile:s,provenance:a,permissions:c,capabilities:d.capabilities,legacy_capability_aliases:d.legacy_aliases,activation:l,contributions:f}}function wr(e){if(typeof e!="object"||e===null)return null;let t=e,n=hr(t,"name");if(n===null)return null;let r=hr(t,"version");if(r===null)return null;let o=hr(t,"entry");if(o===null)return null;let i=Ju(t);if(i===null)return null;let s=rf(t);return s===null?null:{name:n,version:r,entry:o,priority:i,manifest_version:s.manifest_version,pm_min_version:s.pm_min_version,pm_max_version:s.pm_max_version,engines:s.engines,trusted:s.trusted,provenance:s.provenance,sandbox_profile:s.sandbox_profile,permissions:s.permissions,activation:s.activation,contributions:s.contributions,capabilities:s.capabilities,legacy_capability_aliases:s.legacy_capability_aliases.length>0?s.legacy_capability_aliases:void 0}}import{constants as ce}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 Qi=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"}]]),of=/^[a-z][a-z0-9_]{0,63}$/u,sf=new Map([[ce.errno.EACCES,"EACCES"],[ce.errno.EDQUOT,"EDQUOT"],[ce.errno.EMFILE,"EMFILE"],[ce.errno.ENFILE,"ENFILE"],[ce.errno.ENOMEM,"ENOMEM"],[ce.errno.ENOSPC,"ENOSPC"],[ce.errno.EPERM,"EPERM"],[ce.errno.EROFS,"EROFS"]].filter(([e])=>Number.isInteger(e))),af={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function cf(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&Qi.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:sf.get(Math.abs(t.errno))??null}function df(e,t,n={}){let r=cf(e);if(r===null)return null;if(!of.test(t))throw new h("Host environment operation labels must be bounded identifiers.",y.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=Qi.get(r);return new h(`Host filesystem operation ${t} ${o.summary}.`,y.GENERIC_FAILURE,{code:n.codes?.[o.category]??af[o.category].code,reason:r,required:o.recovery,why:n.why??"The operating system refused a required project filesystem operation.",nextSteps:[o.recovery,...n.nextSteps??[]],...n.suggestedRetry?{recovery:{suggested_retry:n.suggestedRetry}}:{}})}async function Zi(e,t,n={}){try{return await t()}catch(r){throw df(r,e,n)??r}}import lf from"node:fs/promises";import mt 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 es(e,t){let n=mt.dirname(t.manifest_path),r=mt.relative(n,t.entry_path);if(r.startsWith("..")||mt.isAbsolute(r))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=mt.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await Zi("extension_module_graph_snapshot",()=>lf.cp(n,o,{recursive:!0,force:!0})),mt.join(o,r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bf5c3834-b388-507e-a13c-3beb5d096abb")}catch{}})();function ts(e){let t=typeof e=="function"?e:e.run;if(typeof t!="function")throw new TypeError("registerPreflight override requires a function handler");let n=[...new Set((typeof e=="function"?[]:e.commands??[]).map(r=>{if(typeof r!="string"||r.trim().length===0)throw new TypeError("registerPreflight ownership.commands must contain non-empty command paths");return A(r)}))];return{run:t,...n.length>0?{commands:n}:{}}}function ns(e){let t=[];for(let n=1;n<e.overrides.length;n+=1){let r=e.overrides[n];for(let o of e.overrides.slice(0,n))r.commands?.length&&o.commands?.length&&!o.commands.some(i=>r.commands.includes(i))||t.push(`extension_preflight_override_collision:${r.layer}:${r.name}:${o.layer}:${o.name}`)}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="47d10c23-88f8-5ba1-bcc2-458f339121a8")}catch{}})();var on=Fo;function rs(e){let t=e.trim().toLowerCase();return on.includes(t)?t:null}function os(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=Math.max(1,Math.floor(t.length*.34));for(let r of on)if(qt(t,r,n)!==null)return r;return null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="355fe619-e6f3-51d9-b88c-0b57267c25be")}catch{}})();function is(e){return e==="toon"||e==="json"}function ss(e){return Le.includes(e)}function Ee(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var as=Symbol("extension_registration_trace");function Z(e,t){let n=new TypeError(e);return Object.defineProperty(n,as,{value:t,enumerable:!1,configurable:!1,writable:!1}),n}function cs(e){return e instanceof Error?e[as]:void 0}function pt(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>pt(t));if(typeof e=="function")return"[Function]";if(typeof e=="bigint"||typeof e=="symbol")return e.toString();if(typeof e=="object"){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=pt(t[r]);return n}return e}function _t(e){if(Array.isArray(e))return e.map(t=>_t(t));if(typeof e=="object"&&e!==null){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=_t(t[r]);return n}return e}function Ve(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return pt(t)}function gt(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return _t(t)}function yt(e,t){if(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(n=>Ve(e,n))}function L(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function ht(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function vr(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Er(e,t){return A(`${e} ${t}`)}function bt(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var uf=new Set(["low","medium","high"]),ff=new Set(["number","string_set"]),mf=new Set(["string","number","boolean"]);function ds(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function pf(e,t,n){let r=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=C(r,n);if(!ff.has(String(o.value_type)))throw new TypeError(`${r}.value_type must be number or string_set`);if(T(`${r}.description`,o.description),o.parameters===void 0)return;let i=C(`${r}.parameters`,o.parameters);for(let[s,a]of Object.entries(i)){let c=`${r}.parameters.${s}`;ds(`${c}.name`,s);let d=C(c,a);if(!mf.has(String(d.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);P(`${c}.required`,d.required),T(`${c}.description`,d.description)}if(Object.keys(i).length>50)throw new TypeError(`assurance provider ${e} key ${t} exceeds 50 parameters`)}function ls(e){let t=C("registerAssuranceMeasurementProvider provider",e),n=ds("registerAssuranceMeasurementProvider provider.id",t.id);if(!/^[a-z0-9][a-z0-9-]*$/u.test(n))throw new TypeError("registerAssuranceMeasurementProvider provider.id must be a stable lowercase id");if(!uf.has(String(t.cost_class)))throw new TypeError("registerAssuranceMeasurementProvider provider.cost_class must be low, medium, or high");if(typeof t.network!="boolean")throw new TypeError("registerAssuranceMeasurementProvider provider.network must be boolean");let r=C("registerAssuranceMeasurementProvider provider.keys",t.keys);if(Object.keys(r).length===0)throw new TypeError("registerAssuranceMeasurementProvider provider.keys requires at least one key");for(let[o,i]of Object.entries(r)){if(!/^[a-z0-9][a-z0-9-]*$/u.test(o))throw new TypeError(`registerAssuranceMeasurementProvider provider key ${o} must be a stable lowercase id`);pf(n,o,i)}if(t.timeout_ms!==void 0&&(typeof t.timeout_ms!="number"||!Number.isInteger(t.timeout_ms)||t.timeout_ms<1||t.timeout_ms>3e5))throw new TypeError("registerAssuranceMeasurementProvider provider.timeout_ms must be an integer from 1 through 300000");if(typeof t.resolve!="function")throw new TypeError("registerAssuranceMeasurementProvider provider.resolve requires a function handler")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4abca948-e9ba-52b5-b63c-a20fc344980a")}catch{}})();var _f=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","value_validation","visible"]);function sn(e,t){return yt(e,t).map(n=>(n.repeatable===!0&&(n.list=!0),n))}function gf(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function kr(e,t){if(t===void 0)return e.replace(/\s+/g,"-");if(typeof t!="string"||t.trim().length===0)throw new TypeError("registerCommand definition.action must be a non-empty string when provided");let n=gf(t);if(n.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return n}function Or(e){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("registerCommand definition.arguments must be an array when provided");let t=[];for(let[r,o]of e.entries()){let i=C(`registerCommand definition.arguments[${r}]`,o),s=L(`registerCommand definition.arguments[${r}].name`,i.name);if(P(`registerCommand definition.arguments[${r}].required`,i.required),P(`registerCommand definition.arguments[${r}].variadic`,i.variadic),T(`registerCommand definition.arguments[${r}].description`,i.description),s.includes(" "))throw new TypeError(`registerCommand definition.arguments[${r}].name must not contain spaces`);let a={name:s};i.required===!0&&(a.required=!0),i.variadic===!0&&(a.variadic=!0),typeof i.description=="string"&&(a.description=i.description.trim()),t.push(a)}let n=t.map((r,o)=>r.variadic?o:-1).filter(r=>r>=0);if(n.length>1)throw new TypeError("registerCommand definition.arguments supports at most one variadic argument");if(n.length===1&&n[0]!==t.length-1)throw new TypeError("registerCommand definition.arguments variadic argument must be the final argument");return t}function an(e){if(!Array.isArray(e))throw new TypeError("registerFlags flags requires an array of object definitions");for(let[t,n]of e.entries()){let r=C(`registerFlags flags[${t}]`,n),o=Object.keys(r).filter(c=>!_f.has(c)).sort((c,d)=>c.localeCompare(d));if(o.length>0)throw new TypeError(`registerFlags flags[${t}] contains unknown field(s): ${o.join(", ")}`);let i=r.long,s=r.short;if(i===void 0&&s===void 0)throw new TypeError(`registerFlags flags[${t}] requires at least one of long or short`);T(`registerFlags flags[${t}].long`,i),T(`registerFlags flags[${t}].short`,s);let a=mi(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${pi(a.token,a.failure)}`);if(T(`registerFlags flags[${t}].value_name`,r.value_name),T(`registerFlags flags[${t}].description`,r.description),P(`registerFlags flags[${t}].required`,r.required),P(`registerFlags flags[${t}].enabled`,r.enabled),P(`registerFlags flags[${t}].visible`,r.visible),P(`registerFlags flags[${t}].list`,r.list),P(`registerFlags flags[${t}].repeatable`,r.repeatable),r.list!==void 0&&r.repeatable!==void 0&&r.list!==r.repeatable)throw new TypeError(`registerFlags flags[${t}].list and repeatable must match when both are provided`);if(Di(`registerFlags flags[${t}].default`,r.default),Array.isArray(r.default)&&r.list!==!0&&r.repeatable!==!0)throw new TypeError(`registerFlags flags[${t}].default cannot be an array unless list is true.`);us(`registerFlags flags[${t}]`,r),yf(`registerFlags flags[${t}]`,r)}}function yf(e,t){if(t.value_validation===void 0)return;if(t.value_validation!=="coerce"&&t.value_validation!=="strict")throw new TypeError(`${e}.value_validation must be "coerce" or "strict" (received ${JSON.stringify(t.value_validation)}).`);if(t.value_validation!=="strict")return;let n=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0),r=n===void 0?null:tn(n);if(r!=="number"&&r!=="boolean")throw new TypeError(`${e}.value_validation "strict" requires value_type "number" or "boolean" (string values are never malformed).`)}function us(e,t){let n=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0);if(n===void 0)return;let r=tn(n);if(r===null)throw new TypeError(`${e} value_type "${n}" is not a known flag value type (expected one of: string, number, boolean).`);if(t.default===void 0)return;let o=t.list===!0||t.repeatable===!0?gi(t.default):[t.default];for(let[i,s]of o.entries())if(!yi(s,r)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${r}.`)}}function fs(e){if(!Array.isArray(e))throw new TypeError("registerItemFields fields requires an array of object definitions");for(let[t,n]of e.entries()){let r=C(`registerItemFields fields[${t}]`,n);L(`registerItemFields fields[${t}].name`,r.name);let o=L(`registerItemFields fields[${t}].type`,r.type);if(rs(o)===null){let i=os(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${on.join(", ")}).${s}`)}P(`registerItemFields fields[${t}].optional`,r.optional)}}function hf(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].command_option_policies`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=C(i,o);L(`${i}.command`,s.command),L(`${i}.option`,s.option),P(`${i}.enabled`,s.enabled),P(`${i}.required`,s.required),P(`${i}.visible`,s.visible)}}function bf(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].options`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=C(i,o);L(`${i}.key`,s.key),we(`${i}.values`,s.values),P(`${i}.required`,s.required),we(`${i}.aliases`,s.aliases)}}function ms(e){if(!Array.isArray(e))throw new TypeError("registerItemTypes types requires an array of object definitions");for(let[t,n]of e.entries()){let r=`registerItemTypes types[${t}]`,o=C(r,n);L(`${r}.name`,o.name),T(`${r}.folder`,o.folder),we(`${r}.aliases`,o.aliases),we(`${r}.required_create_fields`,o.required_create_fields),we(`${r}.required_create_repeatables`,o.required_create_repeatables),hf(t,o.command_option_policies),bf(t,o.options)}}function ps(e){let t=C("registerMigration definition",e);if(t.id!==void 0&&typeof t.id!="string")throw new TypeError("registerMigration definition.id must be a string when provided");if(t.description!==void 0&&typeof t.description!="string")throw new TypeError("registerMigration definition.description must be a string when provided");if(t.status!==void 0&&typeof t.status!="string")throw new TypeError("registerMigration definition.status must be a string when provided");if(P("registerMigration definition.mandatory",t.mandatory),t.run!==void 0&&typeof t.run!="function")throw new TypeError("registerMigration definition.run must be a function when provided")}var _s=["types","statuses","fields","workflows","config","templates","packages"],wf={types:(e,t)=>{if(t.name!==void 0&&typeof t.name!="string")throw new TypeError(`${e}.name must be a string when provided`)},workflows:(e,t)=>{if(typeof t.type!="string")throw new TypeError(`${e}.type must be a string`);if(!Array.isArray(t.allowed_transitions))throw new TypeError(`${e}.allowed_transitions must be an array`);for(let[n,r]of t.allowed_transitions.entries())if(!Array.isArray(r))throw new TypeError(`${e}.allowed_transitions[${n}] must be a [from, to] array`)},templates:(e,t)=>{if(typeof t.name!="string")throw new TypeError(`${e}.name must be a string`);if(typeof t.options!="object"||t.options===null||Array.isArray(t.options))throw new TypeError(`${e}.options must be an object`)},packages:(e,t)=>{if(typeof t.spec!="string")throw new TypeError(`${e}.spec must be a string`)}};function gs(e){let t=C("registerProfile profile",e);if(L("registerProfile profile.name",t.name),L("registerProfile profile.title",t.title),t.summary!==void 0&&typeof t.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let n of _s){let r=t[n];if(r!==void 0){if(!Array.isArray(r))throw new TypeError(`registerProfile profile.${n} must be an array when provided`);for(let[o,i]of r.entries()){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError(`registerProfile profile.${n}[${o}] must be an object`);wf[n]?.(`registerProfile profile.${n}[${o}]`,i)}}}}function ys(e){e.summary===void 0&&(e.summary="");for(let t of _s)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 hs(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 bs(e){return typeof e=="string"?e:String(e)}function wt(e){let t=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(t)?t.split(/[.-]/).map(n=>Number(n)):null}function Sr(e,t){let n=wt(e),r=wt(t);if(!n||!r)return null;let o=Math.max(n.length,r.length);for(let i=0;i<o;i+=1){let s=n[i]??0,a=r[i]??0;if(s>a)return 1;if(s<a)return-1}return 0}function ws(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let n=bs(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(!wt(n))return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(t===null)return{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:null};let r=Sr(t,n);return r===null?{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:t}:r<0?{kind:"pm_min_version",status:"unmet",allowed:!1,required:n,current:t}:{kind:"pm_min_version",status:"ok",allowed:!0,required:n,current:t}}function vs(e,t,n){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let r=bs(e);if(typeof e!="string"||r.trim().length===0)return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(/^[<>=~^]/.test(r.trim())||!wt(r))return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(t===null)return{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:null};let o=Sr(t,r);return o===null?{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:t}:o>0?n==="warn"?{kind:"pm_max_version",status:"exceeded_warn",allowed:!0,required:r,current:t}:{kind:"pm_max_version",status:"exceeded",allowed:!1,required:r,current:t}:{kind:"pm_max_version",status:"ok",allowed:!0,required:r,current:t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f49bad80-c246-59b3-950d-7143585fbdb5")}catch{}})();var vf=5e3;async function Ar(e,t,n){let r=[];for(let o of e)try{await o.run(j(n))}catch{r.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return r}function Ef(e,t,n){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new h(`Extension mutation guard ${t.name} returned an invalid decision.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${t.layer}:${t.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let r=e,o=typeof r.code=="string"?r.code.trim():"",i=typeof r.remediation=="string"?r.remediation.trim():"";if(o.length===0||i.length===0)throw new h(`Extension mutation guard ${t.name} returned an invalid denial.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${t.layer}:${t.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof r.message=="string"?r.message.trim():"";throw new h(s||`Extension mutation guard ${t.name} denied ${n}.`,y.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function Tr(e,t){for(let n of e.beforeMutation??[]){let r,o;try{let i=Promise.resolve().then(()=>n.run({pm_root:t.pm_root,operation:t.operation,before:t.before===null?null:j(t.before),after:t.after===null?null:j(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),r=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new h(`Extension mutation guard ${n.name} timed out before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},vf),o.unref?.()})])}catch(i){throw i instanceof h?i:new h(`Extension mutation guard ${n.name} failed before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(o)}Ef(r,n,t.operation)}}async function Cr(e,t){return Ar(e.onWrite,"onWrite",t)}async function Ir(e,t){return Ar(e.onRead,"onRead",t)}async function Rr(e,t){return Ar(e.onIndex,"onIndex",t)}function kf(e){let t="";e instanceof Error&&typeof e.message=="string"?t=e.message:typeof e=="string"?t=e:typeof e=="object"&&e!==null&&typeof e.message=="string"&&(t=e.message);let n=t.replace(/\s+/gu," ").trim();if(n.length===0)return"";let r=300;return n.length>r?`${V(n,r-1)}\u2026`:n}function cn(e,t){if(typeof e!="object"||e===null||typeof e[t]!="string")return;let n=String(e[t]).replace(/\s+/gu," ").trim();return n.length>0?V(n,300):void 0}function Of(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 xr(e,t){let n=A(t.command);if(n.length===0)return{handled:!1,result:null,warnings:[]};let r=[...e.handlers].reverse().find(o=>o.command===n);if(!r)return{handled:!1,result:null,warnings:[]};try{let o=await r.run({command:n,args:j(t.args),options:j(t.options),global:j(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",Of(o)],["errorCode",cn(o,"code")],["remediation",cn(o,"remediation")]].filter(i=>i[1]!==void 0))}}catch(o){let i=typeof o=="object"&&o!==null&&"exitCode"in o?o.exitCode:void 0;if(typeof i=="number"&&Number.isFinite(i))throw o;return Object.defineProperty({handled:!1,result:null,warnings:[`extension_command_handler_failed:${r.layer}:${r.name}:${r.command}`],errorMessage:kf(o),...Object.fromEntries([["errorCode",cn(o,"code")],["remediation",cn(o,"remediation")]].filter(s=>s[1]!==void 0))},"cause",{value:o,configurable:!0})}}function Es(e){return{handled:!1,result:e.payload,warnings:[]}}function ks(e,t){return[...e.overrides].reverse().filter(n=>n.service===t)}function Os(e){return{service:e.service,command:e.command?A(e.command):void 0,args:e.args?j(e.args):void 0,options:e.options?li(e.options):void 0,global:e.global?ui(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:j(e.payload)}}function Sf(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 Ss(e,t){return Sf(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 As(e,t,n){return t.service==="output_format"&&typeof e=="object"&&e!==null&&K(e,n.payload)}function Ts(e,t,n){if(t.handled){if(e.passThrough===!0){n.push(`extension_service_pass_through_contract_violated:${e.layer}:${e.name}:${e.service}`);return}return{handled:!0,result:t.result,warnings:n}}}function Nr(e,t){let n=ks(e,t.service);if(n.length===0)return Es(t);let r=[];for(let o of n)try{let i=Os(t),s=o.run(i);if(s instanceof Promise){r.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(As(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Ts(o,Ss(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}async function Dr(e,t){let n=ks(e,t.service);if(n.length===0)return Es(t);let r=[];for(let o of n)try{let i=Os(t),s=await Promise.resolve(o.run(i));if(As(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=Ts(o,Ss(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3abe36f7-3c97-58d2-a56d-b4e0ea958461")}catch{}})();var Cs=null,xf=Object.freeze(jo()),Is=0;function Nf(e=Date.now()){return Is+=1,`${Is}-${e}`}function Df(e,t,n){return n.has(e)?!1:t.size===0?!0:t.has(e)}async function Pf(e,t){let[n,r]=await Promise.all([Oe.realpath(e),Oe.realpath(t)]);return lt(n,r)}function $f(e,t=process.cwd()){return{global:ke.join(ri(t),"extensions"),project:ke.join(e,"extensions")}}async function Mf(e){try{return(await Oe.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,n)=>t.localeCompare(n))}catch{return[]}}function jf(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 Rs(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function Lf(e){let t=new Map;try{let n=JSON.parse(await Oe.readFile(ke.join(e,".managed-extensions.json"),"utf8")),r=se(n)?.entries;if(!Array.isArray(r))return t;for(let o of r){if(typeof o!="object"||o===null)continue;let i=o,s=Rs(i.source?.package),a=[i.source?.input,i.source?.name,s].map(l=>Rs(l)).filter(l=>l!==void 0),c=Zt(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 xs(e){return[...e].sort((t,n)=>{if(t.manifest.priority!==n.manifest.priority)return t.manifest.priority-n.manifest.priority;let r=t.manifest.name.localeCompare(n.manifest.name);return r!==0?r:t.directory.localeCompare(n.directory)})}function Ff(e,t){let n=[...xs(e),...xs(t)],r=[];for(let o of n){let i=r.findIndex(s=>s.manifest.name===o.manifest.name);i>=0&&r.splice(i,1),r.push(o)}return r}async function Ns(e,t,n,r,o){let i=[],s=[],a=[],c=await Mf(t),d=await Lf(t);for(let l of c){let f=await qf(e,t,l,n,r,d,o);i.push(f.diagnostic),s.push(...f.warnings),f.candidate&&a.push(f.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function Uf(){return{diagnostics:[],warnings:[],candidates:[]}}function Ds(e,t,n,r){return{diagnostic:{layer:e,directory:t,manifest_path:n,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[r],candidate:null}}function zf(e,t,n,r,o,i,s,a){let c=Uo(e,t,n);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&c.push(Ei(e,t.name,t.legacy_capability_aliases));for(let d of bi(t.capabilities))c.push(vi(e,t.name,d));return r?o||c.push(`extension_entry_missing:${e}:${t.name}`):c.push(`extension_entry_outside_extension:${e}:${t.name}`),i.warning&&c.push(a?i.warning:i.warning.replace("extension_pm_","extension_disabled_pm_")),s.warning&&c.push(a?s.warning:s.warning.replace("extension_pm_","extension_disabled_pm_")),c}async function qf(e,t,n,r,o,i,s){let a=ke.join(t,n),c=ke.join(a,"manifest.json");if(!await qn(c))return Ds(e,n,c,`extension_manifest_missing:${e}:${n}`);let d,l;try{let je=JSON.parse(await Oe.readFile(c,"utf8"));l=se(je),d=wr(je)}catch{l=null,d=null}if(!d||!l)return Ds(e,n,c,`extension_manifest_invalid:${e}:${n}`);let f=ke.resolve(a,d.entry),u=lt(a,f),m=u?await qn(f):!1,p=u&&m?await Pf(a,f):u,_=Df(d.name,r,o),g=await Gf(e,d),b=await Wf(e,d,s),w=zf(e,d,l,p,m,g,b,_),U=p&&m&&g.allowed&&b.allowed,ne=i.get(`directory:${n}`)??i.get(`name:${d.name}`);return{diagnostic:{layer:e,directory:n,manifest_path:c,name:d.name,version:d.version,entry:d.entry,priority:d.priority,entry_path:f,enabled:_,status:U?"ok":"warn"},warnings:w,candidate:ji({layer:e,directory:n,manifestPath:c,entryPath:f,manifest:d,sourceIdentity:ne,extensionReady:U,enabledForLoad:_})}}async function Bf(e){let t=$f(e.pmRoot,e.cwd??process.cwd()),n=dt(e.settings.extensions.enabled),r=dt(e.settings.extensions.disabled),o=qi(e.settings),i=Bi(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:n,configured_disabled:r,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(n),a=new Set(r),c=e.ignoreGlobalExtensions===!0?Uf():await Ns("global",t.global,s,a,o.pmMaxVersionExceededMode.global),d=await Ns("project",t.project,s,a,o.pmMaxVersionExceededMode.project),l=[...o.warnings],f=Ff(c.candidates,d.candidates),u=[];for(let m of f){let p={layer:m.layer,name:m.manifest.name,trusted:m.manifest.trusted===!0,provenanceVerified:m.manifest.provenance?.verified===!0,sandboxProfile:m.manifest.sandbox_profile,permissions:m.manifest.permissions&&typeof m.manifest.permissions=="object"?{fs_read:m.manifest.permissions.fs_read,fs_write:m.manifest.permissions.fs_write,network:m.manifest.permissions.network,env_read:m.manifest.permissions.env_read,env_write:m.manifest.permissions.env_write,process_spawn:m.manifest.permissions.process_spawn}:void 0},_=Wi(o,p);if(_.warning&&l.push(_.warning),!!_.allowed){for(let g of m.manifest.capabilities){let b=Ki(o,p,g);b.warning&&l.push(b.warning)}u.push(jf(m))}}return{disabled_by_flag:!1,roots:t,configured_enabled:n,configured_disabled:r,discovered:[...c.diagnostics,...d.diagnostics],effective:u,warnings:[...new Set([...c.warnings,...d.warnings,...l])],policy:i}}function dn(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function Vf(){try{let e=cr(import.meta.url,["../../.."]),t=await Oe.readFile(ke.join(e,"package.json"),"utf8"),n=JSON.parse(t);return typeof n.version=="string"&&n.version.trim().length>0?n.version.trim():null}catch{return null}}function Ms(){return Cs??=Vf(),Cs}function js(e,t,n){let r=n.current??"unknown";if(n.kind==="pm_min_version")switch(n.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${t.name}:required=${n.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${t.name}:required=${n.required}:current=${r}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${t.name}:required=${n.required}:current=${r}`;default:return}switch(n.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${t.name}:allowed=${n.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${t.name}:allowed=${n.required}:current=${r}`;default:return}}async function Gf(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let n=ws(t.pm_min_version,await Ms()),r=js(e,t,n);return r?{allowed:n.allowed,warning:r}:{allowed:n.allowed}}async function Wf(e,t,n){if(t.pm_max_version===void 0)return{allowed:!0};let r=vs(t.pm_max_version,await Ms(),n),o=js(e,t,r);return o?{allowed:r.allowed,warning:o}:{allowed:r.allowed}}async function Ps(e){try{let t=await Oe.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function Kf(e,t){let n=e.entry_path;t.module_graph_snapshot_root&&(n=await es(t.module_graph_snapshot_root,e));let r=new URL(Rf(n).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return r.href;let[o,i]=await Promise.all([Ps(e.entry_path),Ps(e.manifest_path)]),s=t.reload_token??Nf();return r.searchParams.set("pm_ext_reload",s),r.searchParams.set("pm_ext_entry",o),r.searchParams.set("pm_ext_manifest",i),r.href}async function Yv(e){let t=await Bf(e),n=[],r=[],o=[...t.warnings];if(t.disabled_by_flag)return{...t,warnings:o,loaded:n,failed:r};let i=typeof e.extensionFilter=="function"?t.effective.filter(e.extensionFilter):t.effective;for(let s of i)try{let a=await import(await Kf(s,e));n.push({...s,module:a})}catch(a){o.push(`extension_load_failed:${s.layer}:${s.name}`),r.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:dn(a)})}return{...t,warnings:o,loaded:n,failed:r}}var $s=5e3,Hf=2147483647;function Yf(e){let t={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let n=e.deactivate;t.deactivate=n.bind(e)}return t}function Ls(e){let t=xi(e);return t?Yf(t):null}async function Xv(e,t,n={}){let r=Xf(n?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(l=>`${l.layer}:${l.name}`)),i=[];for(let l of e.loaded){if(o.has(`${l.layer}:${l.name}`))continue;let f=Ls(l.module);!f||typeof f.deactivate!="function"||i.push({extension:l,deactivate:f.deactivate})}let s=await Promise.all(i.map(async({extension:l,deactivate:f})=>{try{return await Jf(f,r),{ok:!0}}catch(u){return{ok:!1,layer:l.layer,name:l.name,error:dn(u)}}})),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 Xf(e){return typeof e!="number"||e<0?$s:e===0||e===1/0?0:Number.isFinite(e)?Math.min(Hf,Math.max(1,Math.floor(e))):$s}async function Jf(e,t){if(t===0){await e();return}let n;try{let r=Promise.resolve().then(()=>e());r.catch(()=>{}),await Promise.race([r,new Promise((o,i)=>{n=setTimeout(()=>{i(new Error(`extension deactivate timed out after ${t}ms`))},t),n.unref?.()})])}finally{clearTimeout(n)}}function Qf(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let n of e.capabilities){let r=n.trim().toLowerCase();oe(r)&&t.add(r)}return t}function O(e,t,n){let r=Qf(e);if(r!==null&&!r.has(t))throw Z(`${n} requires capability '${t}' in extension manifest capabilities`,{method:n,registration_index:-1,capability:t,missing_capability:t,expected_schema:`"capabilities": [..., "${t}"]`,received:e.capabilities,hint:`Add "${t}" to ${e.name} manifest capabilities, or remove the ${n} registration call.`})}function Zf(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>X.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function em(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 Pr=class{extension;hooks;#e;#n;#o;#r;#s;#a;#i;#c;#t;#d;#l;#u;constructor(t,n,r,o,i,s,a,c,d,l,f){this.#e=t,this.extension=Zf(t),this.#n=em(t),this.#o=n,this.#r=r,this.#s=o,this.#a=i,this.#i=s,this.#c=a,this.#t=c,this.#d=d,this.#l=l,this.#u=f,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:u=>this.registerBeforeCommand(u),beforeMutation:u=>this.registerBeforeMutation(u),afterCommand:u=>this.registerAfterCommand(u),onWrite:u=>this.registerOnWrite(u),onRead:u=>this.registerOnRead(u),onIndex:u=>this.registerOnIndex(u)}}allowRegistration(t,n,r,o){let i=Hi(this.#u,this.#n,t,n,r,o);return i.warning&&this.#d.push(i.warning),i.allowed}registerCommandTrace(t,n,r,o,i){return{method:"registerCommand",registration_index:t==="override"?this.#r.overrides.length:this.#r.handlers.length,command:n,expected_schema:r,received:pt(o),hint:i}}registerCommandOverride(t,n){let r=A(t);if(r.length===0)throw Z("registerCommand requires a non-empty command name",this.registerCommandTrace("override",t,'registerCommand("<command>", (context) => unknown)',t,"Provide a non-empty command path as the first argument."));if(typeof n!="function"){let o=this.registerCommandTrace("override",r,'registerCommand("<command>", (context) => unknown)',n,"Provide a function as the second registerCommand argument.");throw Z(`registerCommand requires an override function when command name is provided (command="${r}", registration_index=${o.registration_index})`,o)}this.allowRegistration("commands.override","registerCommand","commands",{command:r})&&this.#r.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}resolveCommandDefinitionRunHandler(t,n){let r=typeof t.run=="function"?t.run:void 0,o=typeof t.handler=="function"?t.handler:void 0;return!r&&o&&this.#d.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${n}`),r??o}registerCommandDefinition(t){if(typeof t!="object"||t===null)throw Z("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 Z("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,"Set command definition.name to a non-empty string command path."));let n=A(t.name);if(n.length===0)throw Z("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",t.name,"{ name: string; run: (context) => unknown; }",t,"Ensure command definition.name contains a non-empty command path."));let r=this.resolveCommandDefinitionRunHandler(t,n);if(typeof r!="function"){let o=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; }",r,"Define command definition.run as a function.");throw Z(`registerCommand requires a command definition run handler (command="${n}", registration_index=${o.registration_index})`,o)}try{Pi(t);let o=kr(n,t.action),i=$i(t.read_output,n,o);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:n,action:o}))return;let s=t.description?.trim(),a=t.intent?.trim(),c=ut("registerCommand definition.examples",t.examples),d=ut("registerCommand definition.failure_hints",t.failure_hints),l=Or(t.arguments);t.flags!==void 0&&(O(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(an(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:sn("registerCommand definition.flags",t.flags)})));let f={source_version:this.#e.version,read_output:i,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:o,examples:c,failure_hints:d,arguments:l,tier:t.tier??"standard",family:t.family??"extensions"};s&&(f.description=s),a&&(f.intent=a),this.#t.commands.push(f)}catch(o){let i=dn(o),s=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=Z(`registerCommand definition metadata invalid (command="${n}", registration_index=${s.registration_index}): ${i}`,s);this.#d.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${n}`),this.#l.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}registerCommand(t,n){if(O(this.#e,"commands","registerCommand"),typeof t=="string"){this.registerCommandOverride(t,n);return}this.registerCommandDefinition(t)}registerParser(t,n){if(O(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let r=A(L("registerParser command",t));ht("registerParser override",n),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}registerPreflight(t){if(O(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let n=ts(t);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...n})}registerService(t,n,r={}){O(this.#e,"services","registerService");let o=String(t).trim().toLowerCase();if(!ss(o))throw new TypeError(`registerService service must be one of: ${Le.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(ht("registerService override",n),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:n,...hs(r)?{passThrough:!0}:{}}))}registerRenderer(t,n,r={}){if(O(this.#e,"renderers","registerRenderer"),!this.allowRegistration("renderers.override","registerRenderer","renderers"))return;if(typeof n!="function")throw new TypeError("registerRenderer requires a renderer function");let o=String(t).trim().toLowerCase();if(!is(o))throw new Error(`registerRenderer format must be toon|json, received: ${String(t)}`);if(r.resultDiscriminator!==void 0&&typeof r.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");let i=[...new Set((r.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return A(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:o,run:n,commands:i,...r.resultDiscriminator?{resultDiscriminator:r.resultDiscriminator}:{}})}registerFlags(t,n){if(O(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let r=A(L("registerFlags targetCommand",t));an(n);let o=sn("registerFlags flags",n);if(o.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:o})}registerItemFields(t){if(O(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;fs(t);let n=yt("registerItemFields fields",t);if(n.length===0)throw new TypeError("registerItemFields requires at least one field definition");this.#t.item_fields.push({layer:this.#e.layer,name:this.#e.name,fields:n})}registerItemTypes(t){if(O(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;ms(t);let n=yt("registerItemTypes types",t);if(n.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#t.item_types.push({layer:this.#e.layer,name:this.#e.name,types:n})}registerRelationshipKinds(t){if(O(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(t))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(t.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");let n=Hn();for(let o of this.#t.relationship_kinds)for(let i of o.definitions)n.register(i);let r=t.map(o=>(n.register(o),n.require(o.kind)));this.#t.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:r})}registerMigration(t){if(O(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;ps(t);let n=gt("registerMigration definition",t);this.#t.migrations.push(bt({layer:this.#e.layer,name:this.#e.name,definition:Ve("registerMigration definition",t)},n))}registerProfile(t){if(O(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let n=_t(t);gs(n),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:ys(n)})}registerImportExportCommandFlags(t,n,r){r.flags!==void 0&&(O(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(an(r.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:sn(`${t} options.flags`,r.flags)})))}applyImportExportCommandMetadata(t,n,r){if(r!==void 0&&(typeof r!="object"||r===null||Array.isArray(r)))throw new TypeError(`${t} options must be an object when provided`);let o=`${t==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,i=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...r,description:r?.description??o,arguments:r?.arguments??i},a=Mi(t,s,r?.description!==void 0);T(`${t} options.action`,s.action),T(`${t} options.description`,s.description),T(`${t} options.intent`,s.intent);let c=kr(n,s.action),d=ut(`${t} options.examples`,s.examples),l=ut(`${t} options.failure_hints`,s.failure_hints),f=Or(s.arguments);this.registerImportExportCommandFlags(t,n,s);let u={source_version:this.#e.version,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:c,examples:d,failure_hints:l,arguments:f},m=s.description?.trim();m&&(u.description=m);let p=s.intent?.trim();return p&&(u.intent=p),this.#t.commands.push(u),a}registerImporter(t,n,r){if(O(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=vr(L("registerImporter name",t));ht("registerImporter importer",n);let i=Er(o,"import");this.applyImportExportCommandMetadata("registerImporter",i,r),this.#t.importers.push({layer:this.#e.layer,name:this.#e.name,importer:o}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>n(lr(s,o,"import"))})}registerExporter(t,n,r){if(O(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=vr(L("registerExporter name",t));ht("registerExporter exporter",n);let i=Er(o,"export"),s=this.applyImportExportCommandMetadata("registerExporter",i,r);this.#t.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:o,...s===void 0?{}:{output:s}}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async a=>{let c=await n(lr(a,o,"export"));return s?.receipt==="suppress"&&!ar(c)?Ti(c):c}})}registerSearchProvider(t){if(O(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let n=gt("registerSearchProvider provider",t);this.#t.search_providers.push(bt({layer:this.#e.layer,name:this.#e.name,definition:Ve("registerSearchProvider provider",t)},n))}registerVectorStoreAdapter(t){if(O(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let n=gt("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(bt({layer:this.#e.layer,name:this.#e.name,definition:Ve("registerVectorStoreAdapter adapter",t)},n))}registerAssuranceMeasurementProvider(t){if(O(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(ls(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let n=gt("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(bt({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:Ve("registerAssuranceMeasurementProvider provider",t)},n))}registerBeforeCommand(t){O(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(Ee("beforeCommand",t),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerBeforeMutation(t){O(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(Ee("beforeMutation",t),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerAfterCommand(t){O(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(Ee("afterCommand",t),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnWrite(t){O(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(Ee("onWrite",t),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnRead(t){O(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(Ee("onRead",t),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnIndex(t){O(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(Ee("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function tm(e,t,n,r,o,i,s,a,c,d,l){return new Pr(e,t,n,r,o,i,s,a,c,d,l)}function nm(e){let t=e.commands.length,n=e.flags.reduce((s,a)=>s+a.flags.length,0),r=e.item_fields.reduce((s,a)=>s+a.fields.length,0),o=e.item_types.reduce((s,a)=>s+a.types.length,0),i=(e.relationship_kinds??[]).reduce((s,a)=>s+a.definitions.length,0);return{commands:t,flags:n,item_fields:r,item_types:o,...i>0?{relationship_kinds:i}:{},migrations:e.migrations.length,profiles:e.profiles.length,importers:e.importers.length,exporters:e.exporters.length,search_providers:e.search_providers.length,vector_store_adapters:e.vector_store_adapters.length,...(e.assurance_providers?.length??0)>0?{assurance_providers:e.assurance_providers.length}:{}}}function rm(e){let t=[],n=(i,s)=>{let a=new Map;for(let c of i){let d=a.get(c.command)??[];d.push(c),a.set(c.command,d)}for(let c of[...a.keys()].sort((d,l)=>d.localeCompare(l))){let d=a.get(c);if(d.length<=1)continue;let l=d[d.length-1];for(let f of d.slice(0,-1))t.push(`${s}:${c}:${l.layer}:${l.name}:${f.layer}:${f.name}`)}};n(e.handlers,"extension_command_handler_collision"),n(e.overrides,"extension_command_override_collision");let r=new Set(e.handlers.map(i=>i.command)),o=[...new Set(e.overrides.map(i=>i.command))].filter(i=>r.has(i));o.sort((i,s)=>i.localeCompare(s));for(let i of o){let s=e.handlers.filter(c=>c.command===i),a=e.overrides.filter(c=>c.command===i);for(let c of a)for(let d of s)t.push(`extension_command_override_handler_overlap:${i}:${c.layer}:${c.name}:${d.layer}:${d.name}`)}return t}function om(e){let t=new Map;for(let r of e.overrides){let o=t.get(r.format)??[];o.push(r),t.set(r.format,o)}let n=[];for(let r of[...t.keys()].sort((o,i)=>o.localeCompare(i))){let o=t.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))i.commands?.length&&s.commands?.length&&!s.commands.some(a=>i.commands?.includes(a))||n.push(`extension_renderer_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return n}function im(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.command)??[];o.push(r),n.set(r.command,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_parser_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}var sm=new Set(["output_format"]);function am(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.service)??[];o.push(r),n.set(r.service,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1||sm.has(r))continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_service_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}async function Jv(e){let t=Vi(e.policy??xf),n=rn(),r=fr(),o=mr(),i=pr(),s=_r(),a=gr(),c=yr(),d=[],l=[];for(let m of e.loaded){let p=Ls(m.module);if(!p)continue;let _=d.length,g=Ni({hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await p.activate(tm(m,n,r,o,i,s,a,c,l,d,t)),d.length>_&&(g(),l.push(`extension_activation_rolled_back:${m.layer}:${m.name}`))}catch(b){g(),l.push(`extension_activate_failed:${m.layer}:${m.name}`);let w=cs(b);d.push({layer:m.layer,name:m.name,entry_path:m.entry_path,error:dn(b),trace:w})}}let f=[...rm(r),...im(o),...ns(i),...am(s),...om(a)],u=[...new Set([...l,...f])];return{hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c,failed:d,warnings:u,hook_counts:{before_command:n.beforeCommand.length,before_mutation:n.beforeMutation.length,after_command:n.afterCommand.length,on_write:n.onWrite.length,on_read:n.onRead.length,on_index:n.onIndex.length},command_override_count:r.overrides.length,command_handler_count:r.handlers.length,parser_override_count:o.overrides.length,preflight_override_count:i.overrides.length,service_override_count:s.overrides.length,renderer_override_count:a.overrides.length,registration_counts:nm(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(){try{var e=typeof window<"u"?window:typeof 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 nE(){let e=Promise.resolve(),t=new Set;return{async read(n){let r=e,o,i=new Promise(s=>{o=s});t.add(i),await r;try{return await n()}finally{t.delete(i),o()}},write(n){let r=Promise.all([e,...t]).then(()=>n());return e=r.then(()=>{},()=>{}),r}}}function cm(){let e=Promise.resolve(),t=0,n=[],r=()=>{if(t!==0)return;let o=n.splice(0);for(let i of o)i()};return{enqueue(o){t++;let i=e.then(()=>o());return e=i.then(()=>{},()=>{}).finally(()=>{t--,r()}),i},idle(){return t===0?Promise.resolve():new Promise(o=>n.push(o))}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7c2e7a35-cbf9-5bb6-abfd-f1ae75c6afc2")}catch{}})();var Ge=null,Us=null,um=null,fm=null,$r=null,mm=null,zs=null,qs=null;var pm=[],Bs=new lm;function I(){return Bs.getStore()}function cE(e){return Bs.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var _m=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function Fs(e){let t=ee.resolve(e);for(;;){if(dm(ee.join(t,".git")))return t;let n=ee.dirname(t);if(n===t)return;t=n}}function gm(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),n=Fs(t)??ee.resolve(t),r=Fs(n);if(!e)return{source_workspace_root:n,...r?{repo_root:r}:{}};let o=ee.relative(n,ee.resolve(e)),i=o.length>0&&!o.startsWith(`..${ee.sep}`)&&o!==".."&&!ee.isAbsolute(o);return{source_workspace_root:n,...r?{repo_root:r}:{},...i?{pm_root_rel:o.split(ee.sep).join("/")}:{}}}function dE(e){let t=I();if(t){t.hooks=e;return}Ge=e}function lE(e){let t=I();if(t){t.commands=e;return}Us=e}function uE(e){let t=I();if(t){t.parsers=e;return}um=e}function fE(e){let t=I();if(t){t.preflight=e;return}fm=e}function mE(e){let t=I();if(t){t.services=e;return}$r=e}function pE(e){let t=I();if(t){t.renderers=e;return}mm=e}function _E(e){let t=I();if(t){t.registrations=e;return}zs=e}function Vs(){let e=I();return e?e.registrations:zs}function ym(){let e=I(),t=e?e.commandContext:qs;return t?{...t,args:[...t.args],options:t.options?{...t.options}:{},global:t.global?{...t.global}:void 0}:null}function gE(e){if(!e)return;let t=I();t?t.affectedItems.push(e):pm.push(e)}function yE(e,t){if(!e||!e.id)return{};let n={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return n;let r=e;for(let o of t){if(typeof o!="string")continue;let i=o.startsWith("unset:")?o.slice(6):o;i==="id"||i==="type"||i==="status"||_m.has(i)||Object.hasOwn(r,i)&&r[i]!==void 0&&(n[i]=r[i])}return n}async function Gs(e){let t=I(),n=t?t.hooks:Ge;return n?Cr(n,e):[]}async function hE(e){let t=I(),n=t?t.hooks:Ge;n&&await Tr(n,e)}async function Ws(e){let t=I(),n=t?t.hooks:Ge;return n?Ir(n,e):[]}function bE(){let e=I();return((e?e.hooks:Ge)?.onRead?.length??0)>0}async function wE(e){let t=I(),n=t?t.hooks:Ge;return n?Rr(n,e):[]}async function vE(e){let t=I(),n=t?t.commands:Us;return n?xr(n,{...e,...gm(e.pm_root)}):{handled:!1,result:null,warnings:[]}}function Ks(e,t){let n=I(),r=n?n.commandContext:qs;return{service:e,command:r?.command,args:r?[...r.args]:[],options:r?.options?{...r.options}:{},global:r?.global?{...r.global}:void 0,pm_root:r?.pm_root,source_workspace_root:r?.source_workspace_root,repo_root:r?.repo_root,pm_root_rel:r?.pm_root_rel,payload:t}}async function ln(e,t){let n=I(),r=n?n.services:$r;return r?Dr(r,Ks(e,t)):{handled:!1,result:t,warnings:[]}}function Hs(e,t){let n=I(),r=n?n.services:$r;return r?Nr(r,Ks(e,t)):{handled:!1,result:t,warnings:[]}}import{stripVTControlCharacters as hm}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="493a0675-0114-5b93-b3b4-5bd895ac691f")}catch{}})();var bm=["full","compact","brief","summary","counts"],xE=["mutation","read","discovery","governance"],Xs=["error","warning","validation_summary","recovery_bundle"],wm=["full","omit_explanation","limit_collections","compact_recovery","action_only"],vm=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"]),Em=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),km=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),Om={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},Sm=3,Am=2,Tm=192,Cm={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},Im=Xs.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:Cm[e],minimum_max_estimated_tokens:Tm,degradation_ladder:wm,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),Rm=new Map(Im.map(e=>[e.diagnostic_class,e]));function xm(e){let[t=""]=ct(e).split(/\s+/u);return vm.has(t)?"mutation":Em.has(t)?"discovery":km.has(t)?"governance":"read"}function Js(e,t=xm(e)){let n=e.trim().replace(/\s+/gu," ");if(n.length===0)throw new TypeError("command must be a non-empty command path");let r=Om[t];return Nm({command:n,budget_class:t,default_max_estimated_tokens:r,default_max_estimated_tokens_by_format:{toon:r,json:Math.ceil(r*Sm/Am)},degradation_ladder:bm,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function Nm(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,n]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var Dm=Xt.map(e=>Js(e)),Pm=new Map(Dm.map(e=>[e.command,e]));function Qs(e,t={}){let n=e.trim().replace(/\s+/gu," "),[r]=ct(n).split(" "),o=Pm.get(r);return o?{...o,command:n}:t.generateFallback?Js(n):null}function Ae(e){return Math.ceil(Math.max(0,e)/4)}function Zs(e){let t=Rm.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${Xs.join(", ")}`);return t}function de(e){return Ae(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function $m(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mr(e){if(!$m(e))return;let t={};for(let n of["suggested_retry","suggested_retry_args","next_best_command","allowed_values","candidate_commands","missing","missing_required_fields","option_scope","retry_after_ms","waited_ms","owner_handoffs"]){let r=e[n];Array.isArray(r)?t[n]=n==="suggested_retry_args"?r:r.slice(0,3):r!==void 0&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}function Mm(e,t){return typeof e!="string"||e.length<=t?e:`${V(e,Math.max(1,t-3))}...`}function Se(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;let n="...",r=Array.from(e),o=0,i=r.length;for(;o<i;){let s=Math.ceil((o+i)/2),a=`${r.slice(0,s).join("")}${n}`;Buffer.byteLength(a,"utf8")<=t?o=s:i=s-1}return`${r.slice(0,o).join("")}${n}`}function ea(e){let t={};for(let n of["code","required","recovery","next_steps","exit_code","type","title","detail","why","examples"])Object.hasOwn(e,n)&&e[n]!==void 0&&(t[n]=e[n]);for(let[n,r]of Object.entries(e))n!=="__proto__"&&!Object.hasOwn(t,n)&&(t[n]=r);return t}var jm=new Set(["limit_collections","compact_recovery","action_only"]),Lm=new Set(["compact_recovery","action_only"]);function Fm(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:Mm(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},n=Mr(e.recovery);return n!==void 0?t.recovery=n:Array.isArray(e.next_steps)&&(t.next_steps=e.next_steps.slice(0,1)),e.exit_code!==void 0&&(t.exit_code=e.exit_code),e.type!==void 0&&(t.type=e.type),t}function Um(e,t){let n=structuredClone(e);if(t!=="full"&&(delete n.why,delete n.examples),jm.has(t))for(let[r,o]of Object.entries(n))Array.isArray(o)&&(n[r]=o.slice(0,3));if(Lm.has(t)){let r=Mr(n.recovery);r?n.recovery=r:delete n.recovery}return t!=="action_only"?ea(n):Fm(n)}function We(e,t){let n={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let r=0;r<4;r+=1){let o=de(n),i=n.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return n}function zm(e,t,n){let r=We(e,t);for(let i of["recovery","exit_code"])de(r)<=n||e[i]===void 0||(delete e[i],r=We(e,t));let o=40;for(;de(r)>n&&o>4;)o-=4,e.code=Se(String(e.code),o),e.required=Se(String(e.required),o),r=We(e,t);return r}function qm(e,t){let n=e.diagnostic_output,{estimated_tokens:r,...o}=n,i=o.omitted_fields.slice(0,8).map(f=>Se(f,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=Mr(e.recovery),c=a&&de(a)<=48?a:void 0,d={code:Se(String(e.code),320),required:Se(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},l=We(d,s);for(;de(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=We(d,s);return l=zm(d,s,t),l}function NE(e,t={}){let n=e,r=t.diagnosticClass??"error",o=Zs(r),i=t.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.json,a=de(n),c=Object.keys(n);if(a<=s)return ea(structuredClone(n));let d;for(let[l,f]of o.degradation_ladder.entries()){let u=Um(n,f),m=c.filter(_=>!Object.hasOwn(u,_)),p=We(u,{diagnostic_class:r,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:l>0,degradation_steps:o.degradation_ladder.slice(0,l+1),omitted_fields:m});if(d=p,de(p)<=s)break}return de(d)>s&&(d=qm(d,s)),d}function Ys(e){return hm(e).replace(/\r\n/gu,`
2
+ `).replace(/[^\P{Cc}\n]/gu," ")}function DE(e,t,n={}){let r=n.diagnosticClass??"error",o=Zs(r),i=n.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.text,a=Ys(e),c=Ae(Buffer.byteLength(a,"utf8")),d=c>s,l=`What is required:
3
3
  `,f=`
4
4
 
5
5
  ${Se(a.trimStart().split(/\r?\n/u,1)[0].trim(),320)}
6
6
 
7
- Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,u=Ks(t).trim()||"Inspect the diagnostic code and retry with corrected input.",m=Math.max(1,s*4-Buffer.byteLength(`${l}${f}`,"utf8")),p=d?`${l}${Se(u,m)}${f}`:a;return{output:p,diagnostic_output:{diagnostic_class:r,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:Ae(Buffer.byteLength(p,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}var Mr=Object.freeze({required:"Adjust command input or tracker state and retry.",why:Object.freeze(["pm enforces explicit, deterministic contracts for data and command semantics.","Commander validates CLI contracts before execution.","Unexpected runtime failures can occur from environment or extension-level issues.","Validation protects data consistency and deterministic behavior across commands.","Required options define command intent and enforce deterministic write contracts."]),examples:Object.freeze(["pm --help","pm <command> --help"])});function AE(e){return e?.trim()===Mr.required}function CE(e){let t=e?.trim();return t!==void 0&&Mr.why.includes(t)}function TE(e){return(e??[]).filter(t=>!Mr.examples.includes(t.trim()))}var IE=Object.freeze(["attempted_command","normalized_args","provided_fields"]);function RE(e){if(!e)return;let{attempted_command:t,normalized_args:n,provided_fields:r,...o}=e;return Object.values(o).some(i=>i!==void 0)?o:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3a351971-6cfb-55eb-a266-3fec0af9eaa4")}catch{}})();var B=Object.freeze({comments:Object.freeze({paths:Object.freeze(["comments"]),total_key:"total_count"}),notes:Object.freeze({paths:Object.freeze(["notes"]),total_key:"total_count",delivered_row_counters:Object.freeze([Object.freeze({key:"structured_event_count",field:"format",equals:"json"})])}),learnings:Object.freeze({paths:Object.freeze(["learnings"]),total_key:"total_count"})});function Ce(e,t){return e===void 0?!1:(Object.hasOwn(B,e)?B[e]:void 0)?.paths.includes(t)===!0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a65d6520-0e6f-5627-a4dd-bd455c2db0fa")}catch{}})();var ta=new WeakMap;function $E(e,t){ta.set(e,new Set(t))}var ln='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',jm={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"}},Lm=[{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 ME(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,y.USAGE)}function H(e,t=new Set){let n=e.filter(r=>!t.has(r.name)).map(r=>({...r}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function jE(e,t){let n=Lm.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return H([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return H(r)}var Fm=[{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 $(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Um=new Set([void 0,"tabular_when_uniform"]),zm=new Set(["collection","none"]),qm=new Set(["supported","unsupported"]);function Zs(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(n=>typeof n=="string"&&n.length>0)&&new Set(e).size===e.length}function Bm(e){return $(e)&&typeof e.command=="string"&&e.command.trim().length>0&&zm.has(e.row_kind)&&Zs(e.row_keys,!0)&&(e.continuation_row_keys===void 0||Zs(e.continuation_row_keys,!1))&&qm.has(e.fields)&&Um.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 Vm={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"]},Gm={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 Wm(e,t){let n=e.trim().toLowerCase().split(/\s+/u,1)[0],r=n?.startsWith("list-")?"list":n;if(r==="graph"){let s=typeof t.subcommand=="string"?t.subcommand:"";if(s.length===0)return;let a=Vm[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||$(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:ln}:{},toon_encoding:"tabular_when_uniform"}}let o=jm[r],i=Gm[r];return o===void 0||i===void 0||!i.some(s=>Object.hasOwn(t,s))?void 0:(()=>{let s=o.row_keys.filter(a=>{let c=a.split(".").reduce((d,l)=>$(d)?d[l]:void 0,t);return Array.isArray(c)||$(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:ln}:{},toon_encoding:"tabular_when_uniform"}})()}function Km(e){if(!$(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;let t=e.projection.declared_field_groups,n=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(n))return;let r=t.filter(s=>$(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=n.filter(s=>typeof s=="string");if(r.length!==t.length||o.length!==n.length)return;let i=new Set(r.map(s=>s.name));if(!(i.size!==r.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return H(r,new Set(o))}function Hm(e){if(!Array.isArray(e.sections_included))return;let t=H(Fm,new Set(e.sections_included.filter(n=>typeof n=="string")));return $(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function Ym(e,t,n){if(e==="dependency_provenance")return!1;let r=na(e);if(r!==void 0){let o=n[r.facet];return $(o)&&Object.hasOwn(o,r.member)}return Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&$(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&$(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function na(e){let t=e.indexOf(".");return t===-1?void 0:{facet:e.slice(0,t),member:e.slice(t+1)}}function Xm(e){if(!$(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=ta.get(e),i=a=>n.includes(a)||a==="body"||a==="dependency_provenance"?t:e,s=["body",...n,...r.slice(1),...o?.has("dependency_provenance")?["dependency_provenance"]:[],...o?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[],...[...o??[]].filter(a=>na(a)!==void 0)].filter(a=>o===void 0||o.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:a==="blockers"?"--full":a==="dependency_provenance"?"--fields dependencies":`--fields ${a}`}));return H(s,new Set(s.flatMap(({name:a})=>Ym(a,i(a),e)?[a]:[])))}function ea(e){if($(e.projection))return H([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function Jm(e){if(!$(e.projection))return H([]);if(typeof e.projection.mode=="string")return H([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function Qm(e){if(!(!$(e.selected)||typeof e.selected.summary!="boolean"))return H([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function Zm(e,t){let n=Km(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return Hm(t);if(r==="get")return Xm(t);if(r==="list"||r.startsWith("list-"))return ea(t);if(r==="search")return ea(t)??H([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return Jm(t);if(r==="contracts")return Qm(t)}function ra(e,t){if(e===void 0||!$(t))return t;let n=Zm(e,t),r=t.row_contract,o=Bm(r)?r:Wm(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 $(i.omission_receipt)||n===void 0?i:{...i,omission_receipt:n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b67272d-8924-5b1b-97cd-74a6a10493be")}catch{}})();function jr(e){let t=e.trim().toLowerCase().startsWith("extension:"),n=e.trim().toLowerCase().replace(/^extension:/u,"");if(Fe(n))return;let r=qs()?.commands??[],o=[...r].reverse().find(s=>s.command===n)?.command??(t?void 0:r.find(s=>s.action===n)?.command),i=[...r].reverse().find(s=>s.command===o);return i===void 0||Fe(i.command)||Fe(i.action)?void 0:i}function ep(e){let t=jr(e);return t?.read_output===void 0?void 0:t}function oa(e,t){let n=ep(e),r=n?.read_output;if(r===void 0)return t;if(typeof t!="object"||t===null||Array.isArray(t))throw new h("Read-only extension commands must return a structured object.",y.USAGE,{code:"extension_read_output_invalid"});for(let o of r.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 h(`Read-only extension result is missing declared row collection ${o}.`,y.USAGE,{code:"extension_read_output_invalid"})}return{...t,row_contract:{command:`extension:${n.command}`,row_kind:r.row_keys.length>0?"collection":"none",row_keys:[...r.row_keys],fields:"supported",...r.row_keys.length>0?{jq_selector:ln}:{},toon_encoding:"tabular_when_uniform"}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="040fff2e-c66f-5091-9ea8-7dcdaf6e203b")}catch{}})();var Lr={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded","--after"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},learnings:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},Fr=new Set(["--collapse","--fields","--section"]),un=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 fn(e){return e.slice(2).replaceAll("-","_")}function ia(e,t={}){let n=e==="package catalog"||e==="packages catalog"||e==="package-catalog"||(e==="package"||e==="packages"||e==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":e==="package manage"||e==="package-manage"?"package-manage":e.split(" ")[0],r=n.startsWith("list-")?"list":n==="ctx"?"context":n;return be.includes(r)?r:void 0}function Ur(e){return new Map((Lr[e]?.include??[]).filter(t=>!Fr.has(t)&&un[t]===void 0).map(t=>[fn(t),zr(t)]))}function zr(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2335ae7f-c7aa-5bdd-ac2e-e6d7a74be2e1")}catch{}})();var mn="changed_fields",tp="changed_field_count",qr="rows",np=new Set(["apply","rollback"]),da=new Set(["deleted","would_delete"]),sa=256,aa={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function rp(e,t){if(!F(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(aa,e.action)?aa[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return F(s)&&F(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let r=e[n.at(-1)],o=ua(r);return t.idOnly?o:!t.compactEnvelope&&t.changedFields!=="compact"?null:{...e,...t.compactEnvelope?{...o,changed_field_count:new Set(n.flatMap(i=>e[i].changed_fields)).size}:{},...Object.fromEntries(n.map(i=>[i,fa(e[i],t)]))}}function ca(e){return typeof e!="string"||e.length<=sa?e:`${V(e,sa-1)}\u2026`}function op(e){if(!F(e))return null;let t={...e};return t.reason=ca(t.reason),F(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,ca(r)]))),t}function F(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function la(e){let t=e[mn];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==mn&&(n[r]=o);return n[tp]=t.length,n}function ip(e){return"item"in e&&Array.isArray(e[mn])}function sp(e){return typeof e.mode=="string"&&np.has(e.mode)&&Array.isArray(e[qr])}function ap(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[qr]=t,n}function ua(e){if(!F(e))return null;let t=F(e.item)?e.item:F(e.plan)?e.plan:null;if(t===null)return null;let n=typeof t.id=="string"?t.id:void 0,r=typeof e.outcome=="string"&&da.has(e.outcome)?e.outcome:typeof t.status=="string"?t.status:void 0;return n?r?{id:n,status:r,...typeof e.deleted=="boolean"?{deleted:e.deleted}:{}}:{id:n}:null}function cp(e,t){if(!F(e))return null;if(F(e.plan)&&F(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||!F(e.item)||typeof e.item.id!="string")return null;let n=e[mn];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&da.has(e.outcome)?{status:e.outcome}:typeof e.item.status=="string"?{status:e.item.status}:{},...typeof e.deleted=="boolean"?{deleted:e.deleted}:{},...typeof e.previous_status=="string"?{previous_status:e.previous_status}:{},changed_field_count:n.length};return dp(e,e.item,r),r}function dp(e,t,n){let r=typeof e.close_reason=="string"?e.close_reason:typeof t.close_reason=="string"?t.close_reason:void 0;r!==void 0&&(n.close_reason=r);let o=op(e.recurrence);o!==null&&(n.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(n.warnings=e.warnings);for(let i of["recovery","follow_up","handoff","completion","start"])F(e[i])&&(n[i]=e[i]);if(typeof e.claimed_by=="string"||typeof e.released_by=="string")for(let i of["claimed_by","released_by","previous_assignee","forced","skipped","available","attempts","start_refused","suggestions"])Object.hasOwn(e,i)&&(n[i]=e[i])}function lp(e){let t=sp(e)?e[qr]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!F(o))return o;let i=la(o);return i?(n=!0,i):o});return n?{projected:ap(e,r),changed:!0}:{projected:e,changed:!1}}function fa(e,t={}){let n=rp(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=ua(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=cp(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!F(e))return e;let r=!1,o=e,i=ip(e)?la(e):null;i!==null&&(o=i,r=!0);let s=lp(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{AsyncLocalStorage as V_}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]="9bb3b2ed-c289-5b96-99ce-9df6e202c464")}catch{}})();var ma=new Set(["--pm-path","--path","--author","--expect-hash","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),up=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function fp(e){let t=e.indexOf("=");return t>0&&ma.has(e.slice(0,t))}function mp(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function pa(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(ma.has(n)){t+=mp(n,e[t+1])?1:0;continue}if(!(fp(n)||up.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function YE(e){let t=pa(e);return t===void 0?void 0:e[t].trim().toLowerCase()}import pp 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]="86412887-5659-5892-beaa-bdd15a02ff4c")}catch{}})();var _a=e=>{let t='"',n=0;for(let r of e){if(r==="\\"){n+=1;continue}t+="\\".repeat(r==='"'?n*2+1:n),t+=r,n=0}return`${t}${"\\".repeat(n*2)}"`},ga=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?_a(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,pn=(e,t=process.platform)=>{let n=e.map(r=>ga(r,t)).join(" ");return n.length>0?`pm ${n}`:"pm"};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="97ad2370-83bf-5a93-b893-144c87d0ae18")}catch{}})();var Br=new WeakMap;function rk(e){Br.set(e,e.path)}function _p(e){if(!process.env.PM_PATH?.trim())return;let t=Zo(e);return dt(ei(t),e)&&t===Qn(e)?void 0:pp.relative(e,t)||"."}function ok(e,t=process.cwd()){let n=Br.has(e)?Br.get(e):e.path,r=n?.trim()?n:_p(t),o=r?["--pm-path",r]:[];return e.noExtensions&&o.push("--no-extensions"),o}import{createHash as Cp}from"node:crypto";import{createHash as vp}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]="f539ecb5-2f49-5867-96c7-48eddb81a628")}catch{}})();var gp=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 N(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ya(e,t){let n=e;for(let r of t.split("."))if(Array.isArray(n)){if(!/^\d+$/u.test(r))return;n=n[Number(r)]}else{if(!N(n))return;n=n[r]}return n}function Vr(e,t,n){let r=t.split("."),o=(i,s)=>{if(s===r.length)return n;let a=r[s];if(Array.isArray(i)){let d=Number(a),l=[...i];return l[d]=o(i[d],s+1),l}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function Gr(e,t,n,r){let o=Ge(e).find(a=>a.path===t);if(!o)return e;let i=Array.isArray(o.value)?o.value.slice(n,r):Object.fromEntries(Object.entries(o.value).slice(n,r)),s=Vr(e,t,i);return N(s.summary)&&N(s.summary.focus_row_states)&&typeof s.summary.focus_row_states[t]=="string"&&(s.summary={...s.summary,focus_row_states:{...s.summary.focus_row_states,[t]:s.summary.focus_row_states[t].slice(n,r)}}),Et(s),s}function gn(e){let t=e.row_contract;return N(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Object.entries(e).filter(([,n])=>Array.isArray(n)).map(([n])=>n)}function yp(e){let t=e.row_contract;return N(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):gn(e)}function le(e){return gn(e).flatMap(t=>{let n=ya(e,t);return Array.isArray(n)||N(n)?[{path:t,value:n}]:[]})}function Ge(e){return yp(e).flatMap(t=>{let n=ya(e,t);return Array.isArray(n)||N(n)?[{path:t,value:n}]:[]})}function wt(e){let t=le(e),n=new Set(t.map(o=>o.path)),r=(o,i)=>{if(Array.isArray(o)){n.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>r(s,`${i}.${a}`));return}if(N(o))for(let[s,a]of Object.entries(o))i.length===0&&gp.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function We(e){return le(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function vt(e,t){let n=e;for(let r of le(n)){let o=Array.isArray(r.value)?r.value.map((i,s)=>t(i,r.path,s)):Object.fromEntries(Object.entries(r.value).map(([i,s],a)=>[i,t(s,r.path,a)]));n=Vr(n,r.path,o)}return n}function ha(e,t,n=()=>!1){let r=e,o=!1;for(let i of le(r)){let s=Array.isArray(i.value)?i.value:Object.entries(i.value);if(s.length<=t)continue;o=!0;let a=n(i.path)?s.length-t:0,c=s.slice(a,a+t),d=Array.isArray(i.value)?c:Object.fromEntries(c);r=Vr(r,i.path,d)}return{result:r,truncated:o}}var ba=["high_level","low_level","blocked_fallback"];function _n(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function sk(e,t){if(!N(e.summary)||!N(e.summary.returned_focus))return;let n=new Map(t.map(r=>[r.id,r]));e.summary={...e.summary,focus_row_states:Object.fromEntries(ba.map(r=>[r,Array.isArray(e[r])?e[r].filter(N).map(o=>_n(n.get(o.id)??o)).join(""):""]))}}function hp(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 bp(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(N):[],i=hp(r[n],o.length)??o.map(_n).join(""),s=new Map(o.flatMap((d,l)=>d.id===void 0?[]:[[d.id,i[l]]])),a=Array.isArray(e[n])?e[n].filter(N):[],c=!1;return{states:a.map((d,l)=>{let f=s.get(d.id)??(d.id===void 0?i[l]:void 0)??_n(d);return f!==_n(d)&&(c=!0),f}).join(""),needsStates:c}}function wp(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 Et(e,t=e){if(wp(e,t),!N(e.summary)||!N(e.summary.returned_focus))return;let n={...e.summary},r=N(t.summary)&&N(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=ba.map(c=>({key:c,...bp(e,t,c,r)})),i=Object.fromEntries(o.map(({key:c,states:d})=>[c,d])),s=o.some(c=>c.needsStates),a=Object.values(i).join("");typeof n.high_level=="number"&&(n.high_level=Array.isArray(e.high_level)?e.high_level.length:0),typeof n.low_level=="number"&&(n.low_level=Array.isArray(e.low_level)?e.low_level.length:0),n.returned_focus={active_items:a.length,in_progress:[...a].filter(c=>c.toLowerCase()==="i").length,open:[...a].filter(c=>c.toLowerCase()==="o").length,blocked:[...a].filter(c=>c===c.toUpperCase()).length},s?n.focus_row_states=i:delete n.focus_row_states,e.summary=n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="83f3f6fd-bd97-54a4-b39e-c66ec8e333b2")}catch{}})();var Ep=4096,kp=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"]),va=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:kp}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function Ke(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ea(e,t,n=e,r){let o=Object.hasOwn(B,t)?B[t]:void 0;if(o?.delivered_row_counters===void 0)return;let i=o.paths[0],s=e[i],a=n[i];if(!Array.isArray(s)||!Array.isArray(a))return;let c=r??a.length,d=a.slice(Math.max(0,c-s.length),c);for(let l of o.delivered_row_counters)typeof e[l.key]=="number"&&(e[l.key]=d.filter(f=>Ke(f)&&f[l.field]===l.equals).length)}function kt(e){return Array.isArray(e)?e.map(kt):Ke(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,kt(n)])):e}function wa(e,t){if(!Ke(e))return kt(e);let n=typeof e.name=="string"?e.name:void 0,r=n!==void 0&&Object.hasOwn(t.ignored_detail_field_names_by_row,n)?t.ignored_detail_field_names_by_row[n]:void 0;return Object.fromEntries(Object.entries(e).map(([o,i])=>o!=="details"||!r||!Ke(i)?[o,kt(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!r.includes(s)).map(([s,a])=>[s,kt(a)]))]))}function Op(e,t){return Array.isArray(e)?e.map(n=>wa(n,t)):wa(e,t)}function yn(e,t,n){let r=n?va[n]:void 0,o=r?.paths.includes(e)===!0;return vp("sha256").update(ye({path:e,value:o?Op(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function Wr(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint,...e.direction==="backward"?{d:"b"}:{}}),"utf8").toString("base64url")}function Sp(e){return typeof e=="string"&&(He(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function Ap(e){return e===void 0||e==="b"}function Ot(e){if(e.length>Ep)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!Ke(t)||t.v!==1||!Sp(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||!Ap(t.d))throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f,...t.d==="b"?{direction:"backward"}:{}}}function ka(e){if(!Array.isArray(e.assertions))return e;let t=n=>!Ke(n)||n.verdict==="pass"?4:n.verdict==="retired"?3:n.enforcement==="block"?0:n.enforcement==="warn"?1:2;return{...e,assertions:e.assertions.map((n,r)=>({row:n,index:r})).sort((n,r)=>t(n.row)-t(r.row)||n.index-r.index).map(({row:n})=>n),budget_retention_policy:"verdict_priority"}}function Oa(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,y.USAGE,{code:"read_output_cursor_command_mismatch"});let r=Ge(e).find(c=>c.path===n.path),o=r?Array.isArray(r.value)?r.value.length:Object.keys(r.value).length:0,i=Ce(t,n.path);if(!r||o!==n.total_rows||n.offset>o||i!==(n.direction==="backward")||yn(n.path,r.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",y.USAGE,{code:"read_output_cursor_stale"});if(!i)return Gr(e,n.path,n.offset);let s=Gr(e,n.path,0,n.offset);for(let c of["count","returned_count"])typeof s[c]=="number"&&(s[c]=n.offset);let a=B[t].total_key;return typeof s[a]!="number"&&(s[a]=n.total_rows),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6a81cf4-3095-5197-8e73-f017d98b1ccf")}catch{}})();var Hr=1,Sa=4096,Tp=/^[A-Za-z0-9_-]+$/;function Kr(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function Ek(e,t){let n=[...Object.values(Xt),...Jt],r=new Set(n.flatMap(o=>[Kr(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){r.add(Kr(o.flag));for(let i of o.aliases??[])r.add(Kr(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!r.has(o)))}function kk(e,t){return Cp("sha256").update(e).update("\0").update(ye(t)).digest("hex").slice(0,24)}function St(e,t,n,r){return Buffer.from(JSON.stringify({version:Hr,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function Te(e,t){return new h(e,y.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function Ip(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===Hr&&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 Yr(e,t="--after"){if(typeof e!="string")throw Te("Query cursor is malformed.",t);let n=e.trim();if(n.length===0||n.length>Sa||!Tp.test(n))throw Te("Query cursor is malformed.",t);let r;try{r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"))}catch{throw Te("Query cursor is malformed.",t)}if(!Ip(r)){let o=!1;try{Ot(n),o=!0}catch{}throw o?new h(`An output cursor must be continued with --output-cursor, not ${t}.`,y.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${n}; retain any producer ${t} cursor from the original page.`]}):Te("Query cursor version or payload is unsupported.",t)}return r}function Xr(e,t,n="--after"){let r=Yr(e,n);if(r.fingerprint!==t)throw Te(`Query cursor does not match the current filters, sort, or query (${r.fingerprint} != ${t}).`,n);return{after_id:r.after_id,...r.after_index===void 0?{}:{after_index:r.after_index},...r.snapshot===void 0?{}:{snapshot:r.snapshot}}}function Ok(e,t){return Xr(e,t).after_id}function Rp(e,t,n,r,o="--after"){if(t===void 0)return 0;let i=Xr(t,n,o),s=e.findIndex(a=>r(a)===i.after_id);if(s<0){if(i.after_index!==void 0)return Math.min(i.after_index,e.length);throw Te(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return s+1}function Sk(e,t){if(t.cursor!==void 0&&Xr(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw Te("Query cursor does not match the requested snapshot.","--after");let n=Rp(e,t.cursor,t.fingerprint,t.readId),r=e.slice(n,n+t.limit),o=r.length>0&&n+r.length<e.length,i=r.at(-1);return{rows:r,has_more:o,...o&&i!==void 0?{next_cursor:St(t.fingerprint,t.readId(i),n+r.length-1,t.snapshot)}:{}}}var Ak=Object.freeze({version:Hr,max_length:Sa});import{randomUUID as P_}from"node:crypto";import{randomUUID as R_}from"node:crypto";import{constants as Je}from"node:fs";import{lstat as Ja,mkdir as x_,open as Za,rename as N_,rm as D_}from"node:fs/promises";import In from"node:path";import{constants as n_}from"node:fs";import M from"node:fs/promises";import W from"node:path";import{createHash as r_,randomUUID as On}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 Aa(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import xp from"node:crypto";import{AsyncLocalStorage as Np}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 Ta=new Np,Ca=1024;function Ia(){let e=Ta.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 xk(e){let t=Ta.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>Ca)throw new Error(`Reproducible token length must be an integer between 0 and ${Ca}`);let n="";for(;n.length<e;){let r=xp.createHash("sha256").update(`${t.seed}\0${t.tokenReads}`).digest();t.tokenReads+=1;for(let o of r)if(n+=(o%36).toString(36),n.length===e)break}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0bf155fc-c690-5318-ba1e-275f1787858b")}catch{}})();var Dp=/^([+-]?)(\d+)([hdwm])$/i,Pp=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,$p=/^(\d{4})(\d{2})(\d{2})$/,Mp=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,jp=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Lp=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Fp=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function Zr(){return Ia()??new Date().toISOString()}function jk(e){return Number.isFinite(Date.parse(e))}function Up(e){let t=Fp.exec(e);if(!t||!Number.isFinite(Date.parse(e)))return!1;let[,n,r,o,i,s,a,c,d]=t,[l,f,u,m,p,_]=[n,r,o,i,s,a].map(Number);return f>=1&&f<=12&&u>=1&&u<=eo(l,f-1)&&m<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function Lk(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return Up(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var zp=1e4,hn=new Map;function Ra(e){let t=hn.get(e);if(t!==void 0)return t;let n=Date.parse(e);return hn.size>=zp&&Aa(hn),hn.set(e,n),n}function Ye(e,t){let n=Ra(e),r=Ra(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function Fk(e,t){return!(t.deadlineBefore&&(!e.deadline||Ye(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||Ye(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&Ye(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&Ye(e.updated_at,t.updatedBefore)>0||t.createdAfter&&Ye(e.created_at,t.createdAfter)<0||t.createdBefore&&Ye(e.created_at,t.createdBefore)>0)}function Jr(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function Qr(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 qp(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function Bp(e){let t=[],n=d=>qp(t,e,d),r=$p.exec(e);if(r){let[,d,l,f]=r;n(`${d}-${l}-${f}`)}let o=Mp.exec(e);if(o){let[,d,l,f,u,m,p,_,g]=o,b=p?`:${p}`:"";n(`${d}-${l}-${f}T${u}:${m}${b}${Jr(_)}${Qr(g)}`)}let i=jp.exec(e);if(i){let[,d,l,f,u,m,p]=i,_=u?`:${u}`:"";n(`${d}T${l}:${f}${_}${Jr(m)}${Qr(p)}`)}let s=Lp.exec(e);if(s){let[,d,l,f,u,m,p]=s,_=u?`:${u}`:"";n(`${d}T${l}:${f}${_}${Jr(m)}${Qr(p)}`)}let a=10,c=e.slice(0,a);if(Gp(c)){let d=a;for(;d<e.length&&Wp(e[d]);)d+=1;d<e.length&&n(`${c}T${e.slice(d)}`)}return t}function Vp(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of Bp(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function Gp(e){if(e.length!==10)return!1;for(let t=0;t<e.length;t+=1){let n=e[t];if(t===4||t===7){if(n!=="-")return!1;continue}let r=n.charCodeAt(0);if(r<48||r>57)return!1}return!0}function Wp(e){return e?e===" "||e===" "||e===`
8
- `||e==="\r"||e==="\f"||e==="\v":!1}function eo(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var Kp=["January","February","March","April","May","June","July","August","September","October","November","December"],Hp=/^(\d{4})-(\d{2})-(\d{2})/,Yp=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function Xp(e,t,n){let r=Hp.exec(t)??Yp.exec(t);if(!r)return;let o=Number.parseInt(r[1],10),i=Number.parseInt(r[2],10),s=Number.parseInt(r[3],10),a=n?.trim()||"deadline";if(i<1||i>12)throw new h(`Invalid ${a} value "${e}". Month "${r[2]}" is out of range \u2014 use a month between 01 and 12.`,y.USAGE,{field:a,value:e});let c=eo(o,i-1);if(s<1||s>c)throw new h(`Invalid ${a} value "${e}". ${Kp[i-1]} ${o} has ${c} days, so day "${r[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,y.USAGE,{field:a,value:e})}function Jp(e,t){let n=new Date(e.getTime()),r=n.getUTCDate(),o=n.getUTCMonth()+t,i=n.getUTCFullYear()+Math.floor(o/12),s=(o%12+12)%12,a=Math.min(r,eo(i,s));return n.setUTCFullYear(i,s,a),n}function Uk(e,t=new Date,n="deadline"){let r=e.trim();if(r.toLowerCase()==="now")return t.toISOString();let o=Dp.exec(r);if(o){let s=o[1]==="-"?-1:1,a=Number.parseInt(o[2],10)*s,c=o[3].toLowerCase();if(c==="m")return Jp(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()}Xp(e,r,n);let i=Vp(r);if(!Number.isFinite(i)){let s=n.trim().length>0?n.trim():"deadline",a=Pp.test(r)?"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.":'Use ISO/date string input, "now", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';throw new h(`Invalid ${s} value "${e}". ${a}`,y.USAGE,{field:s,value:e})}return new Date(i).toISOString()}import bn from"node:fs/promises";import G from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f1eb25ad-08b8-5826-9ec1-7b0a7a22d277")}catch{}})();var Na="lock_path_unsafe";function Qp(e,t){return G.relative(e,t).split(G.sep).join("/")}function Zp(e,t){return e==="lock_entry_symlink"?`Remove the symlinked lock entry ${t} (pm neither follows nor deletes it), then retry the same operation.`:e==="lock_directory_replaced"?`Restore ${t} as a real directory inside the tracker, then retry the same operation. The lock file created while it was replaced stays where the replacement pointed, because pm never deletes outside the tracker; remove it there if it is not wanted.`:"Replace the symlinked or replaced lock directory with a real directory inside the tracker (for example: remove the link, then let pm recreate locks/), then retry the same operation."}function At(e){let t=e.component??G.dirname(e.lockPath),n=Qp(e.pmRoot,t);return new h(`Refused to acquire lock ${e.id}: ${n} is not a real directory inside the tracker (${e.reason}). Locks are never created through a symlinked or replaced lock directory.`,y.CONFLICT,{code:"lock_path_unsafe",item_id:e.id,reason:e.reason,lock_component:n,required:Zp(e.reason,n)})}function xa(e,t){return e.dev===t.dev&&e.ino===t.ino}async function wn(e,t,n,r=!0){let o=G.resolve(e),i=G.dirname(G.resolve(t)),s=G.relative(o,i);if(s===".."||s.startsWith(`..${G.sep}`)||G.isAbsolute(s))throw At({pmRoot:o,lockPath:t,id:n,reason:"lock_path_outside_tracker",component:i});let a=o,c=null;for(let l of s===""?[]:s.split(G.sep)){a=G.join(a,l);let f;try{f=await bn.lstat(a,{bigint:!0})}catch(u){if(r&&J(u))return null;throw u}if(f.isSymbolicLink())throw At({pmRoot:o,lockPath:t,id:n,reason:"lock_directory_symlink",component:a});if(!f.isDirectory())throw At({pmRoot:o,lockPath:t,id:n,reason:"lock_directory_not_directory",component:a});c={dev:f.dev,ino:f.ino}}if(c!==null)return c;let d=await bn.stat(o,{bigint:!0});return{dev:d.dev,ino:d.ino}}async function Da(e,t,n){let r;try{r=await bn.lstat(t)}catch{return}if(r.isSymbolicLink())throw At({pmRoot:e,lockPath:t,id:n,reason:"lock_entry_symlink",component:t})}async function Pa(e){let t=await e.handle.stat({bigint:!0}),n={dev:t.dev,ino:t.ino},r=!1;try{let o=await wn(e.pmRoot,e.lockPath,e.id,!1);if(xa(e.directory,o)){let i=await bn.lstat(e.lockPath,{bigint:!0});r=!i.isSymbolicLink()&&xa(n,i)}}catch{r=!1}if(!r)throw At({pmRoot:e.pmRoot,lockPath:e.lockPath,id:e.id,reason:"lock_directory_replaced"})}import to from"node:fs/promises";import{createHash as e_}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d1f829a5-70d6-5096-86f7-717440dd67d5")}catch{}})();function $a(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function t_(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!$a(t,"ESRCH")}}function Ma(e){let t=e.lastIndexOf(")");if(t<0)return null;let n=e.slice(t+2).trim().split(/\s+/u)[19];return n!==void 0&&/^\d+$/u.test(n)?n:null}async function Xe(e){try{return Ma(await to.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function no(e=process.pid){let t=await Xe(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function ro(e,t,n){if(!t_(e.pid))return!1;let r=await Xe(e.pid);return e.process_start_identity!==void 0&&r!==null?r===e.process_start_identity:t<=n}async function ja(){try{let[e,t]=await Promise.all([to.readFile("/proc/sys/kernel/random/boot_id","utf8"),to.readlink("/proc/self/ns/pid")]);return!/^[a-f0-9-]{36}\s*$/u.test(e)||!/^pid:\[\d+\]$/u.test(t)?null:e_("sha256").update(`${e.trim()}:${t}`).digest("hex")}catch{return null}}async function oo(){let[e,t]=await Promise.all([ja(),Xe(process.pid)]);return e!==null&&t!==null?{host_identity:e,process_start_identity:t}:{}}async function vn(e){if(!e||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0||typeof e.host_identity!="string"||typeof e.process_start_identity!="string"||!/^\d+$/u.test(e.process_start_identity))return"unknown";let t=await ja();if(t===null||t!==e.host_identity)return"unknown";try{process.kill(e.pid,0)}catch(r){return $a(r,"ESRCH")?"dead":"unknown"}let n=await Xe(e.pid);return n===null?"unknown":n===e.process_start_identity?"alive":"dead"}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="54aee8ec-9ef4-54d4-92fa-f4104b3ec4cc")}catch{}})();function o_(e){let t;try{t=JSON.parse(e)}catch{return{info:null,warnings:["lock_info_invalid_json"]}}if(typeof t!="object"||t===null||Array.isArray(t))return{info:null,warnings:["lock_info_invalid_shape"]};let n=t,r=n.id,o=n.pid,i=n.owner,s=n.token,a=n.created_at,c=n.ttl_seconds;return typeof r!="string"||typeof o!="number"||!Number.isFinite(o)||typeof i!="string"||s!==void 0&&(typeof s!="string"||s.trim().length===0)||typeof a!="string"||typeof c!="number"||!Number.isFinite(c)?{info:null,warnings:["lock_info_invalid_shape"]}:{info:{id:r,pid:o,owner:i,...typeof s=="string"?{token:s}:{},created_at:a,ttl_seconds:c,host_identity:n.host_identity,process_start_identity:n.process_start_identity},warnings:[]}}async function Ie(e,t=!0){try{let n=await M.readFile(e,"utf8");return t&&await Vs({path:e,scope:"project"}),o_(n)}catch(n){return J(n)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function ue(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function i_(e,t,n=process.platform){if(ue(e,"EEXIST"))return!0;if(!ue(e,"EPERM")&&!ue(e,"EACCES")&&!ue(e,"EBUSY"))return!1;try{return await M.lstat(t),!0}catch(r){if(n!=="win32"||!J(r)&&!ue(r,"EPERM")&&!ue(r,"EACCES")&&!ue(r,"EBUSY"))return!1}try{return await M.access(W.dirname(t),n_.W_OK),!0}catch{return!1}}async function qa(e,t){await Bs({path:e,scope:"project",op:t})}async function s_(e,t,n,r=On()){return{...await oo(),id:e,pid:process.pid,owner:t,token:r,created_at:Zr(),ttl_seconds:n}}async function a_(e,t,n,r,o,i,s){let a=await wn(e,t,n);s&&a===null&&await M.mkdir(W.dirname(t),{recursive:!0});let c=await Tn(t,n);if(c===null)throw await M.access(W.dirname(t)),Object.assign(new Error("Lock initialization is contended"),{code:"EEXIST"});let d;try{let l=await wn(e,t,n,!1),f=await M.open(t,"wx");try{await Pa({pmRoot:e,lockPath:t,id:n,handle:f,directory:l})}catch(u){throw await f.close(),u}try{try{let u=await s_(n,r,o,i);d=u.created_at,await f.writeFile(`${JSON.stringify(u,null,2)}
9
- `,"utf8")}finally{await f.close()}}catch(u){throw await ao(t,"lock:release"),u}}finally{await c()}return await qa(t,"lock:create"),d}async function ao(e,t){try{return await M.unlink(e),await qa(e,t),!0}catch{return!1}}async function c_(e,t,n,r){let o=performance.now(),i=Sn;for(;;){let s=await Tn(e,t);if(s!==null){try{let d=await Ie(e,!1);io(d.info,t,n,r)&&await ao(e,"lock:release")}finally{await s()}return}let a=await Ie(e,!1);if(!io(a.info,t,n,r))return;let c=performance.now()-o;if(c>=En)return;await Cn(Math.min(i,En-c)),i=Math.min(i*2,An)}}function io(e,t,n,r){return e?.id===t&&e.pid===process.pid&&e.owner===n&&e.token===r}function Ba(e,t){let n=e?.created_at?Date.parse(e.created_at):Number.NaN;return(Number.isFinite(n)?Date.now()-n:Number.POSITIVE_INFINITY)>t*1e3}async function Va(e){return e!==null&&Number.isFinite(Date.parse(e.created_at))&&await vn(e)==="dead"}async function Ga(e,t){return Ba(e,t)||await Va(e)}async function uO(e,t,n){let{info:r}=await Ie(Zn(e,t),!1);return r!==null&&r.owner.startsWith(n)&&!await Ga(r,r.ttl_seconds)}function d_(e){return e?.owner?` (owner ${e.owner})`:""}var Sn=25,An=200,Wa=250,l_=12e4,u_=3,f_=".stale-cleanup",Ka="owner.json",Ha=1e4,En=Ha+An;function so(e){if(typeof e=="string"){let t=e.trim();if(!/^\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)?n:void 0}if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return Math.trunc(e)}function m_(e){let t=process.env.PM_LOCK_WAIT_MS,n=so(t);if(n!==void 0)return n;let r=so(e);return r!==void 0?r:0}function p_(e,t){return Math.min(m_(e),t??1/0)}function Cn(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(n=>setTimeout(n,t))}async function Ya(e,t,n,r=0){n=Math.floor(n);let o=await vn(t),i=r>0?` across ${r} owner handoff(s)`:"",s=n>0?` after waiting ${n}ms${i}`:"";return new h(`Item ${e} is locked${d_(t)} (owner process ${o})${s}`,y.CONFLICT,{code:"lock_conflict",item_id:e,reason:`lock_owner_${o}`,required:"Wait for the owner to release the lock, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget when contention is expected. Inspect stale receipts with pm gc --scope locks --dry-run.",recovery:{retry_after_ms:Wa,...n>0?{waited_ms:n,owner_handoffs:r}:{}}})}function __(e,t){let n=performance.now(),r=n,o,i=0;return{startedAtMs:n,observe(s){let a=performance.now(),c=y_(s);o!==void 0&&c!==o&&(i+=1,r=a),o=c;let d=a-n,l=a-r;return{exhausted:e===0||l>=e||d>=t,elapsedMs:d,remainingMs:Math.min(e-l,t-d),ownerHandoffs:i}}}}function g_(e,t,n){return n!=="progress"||t!==void 0?e:Math.max(e,l_)}function y_(e){return e===null?"released":e.token??`${e.pid}:${e.owner}:${e.created_at}`}function h_(e){let t=Date.parse(e.acquiredAt)+e.ttlSeconds*1e3;return{owner:e.owner,acquired_at:e.acquiredAt,ttl_seconds:e.ttlSeconds,expires_at:new Date(t).toISOString()}}function b_(e,t,n,r){let o=`the lease acquired at ${t.acquiredAt} (ttl ${t.ttlSeconds}s)`;if(r==="fence_gate_unavailable")return{summary:`Lock for ${e} could not be verified before commit: ${o} could not enter its commit fence because the stale-cleanup gate stayed held.`,required:"Retry the same operation; this writer's change was not committed. Inspect pm gc --scope locks --dry-run if the stale-cleanup gate stays held."};let i=n===null?"the lock no longer exists":`it is now held by ${n.owner} since ${n.created_at}`;return{summary:`Lock for ${e} was lost before commit: ${o} is no longer owned by this writer, and ${i}.`,required:"Re-read the item and apply the mutation again; this writer's change was not committed and the newer value was kept. Keep mutation work shorter than locks.ttl_seconds, or raise locks.ttl_seconds for long-running callbacks."}}function La(e,t,n,r){let{summary:o,required:i}=b_(e,t,n,r);return new h(`${o} Nothing was written.`,y.CONFLICT,{code:"lock_lost",item_id:e,reason:r,lease:h_(t),current_owner:n===null?null:{owner:n.owner,pid:n.pid,created_at:n.created_at,ttl_seconds:n.ttl_seconds},required:i,recovery:{retry_after_ms:Wa}})}async function w_(e,t){let n=performance.now(),r=Sn;for(;;){let o=await Tn(e,t);if(o!==null)return o;let i=performance.now()-n;if(i>=En)return null;await Cn(Math.min(r,En-i)),r=Math.min(r*2,An)}}async function v_(e,t,n,r){let o=await w_(e,t);if(o===null){let i=await Ie(e,!1);throw La(t,n,i.info,"fence_gate_unavailable")}try{let i=await Ie(e,!1);if(!io(i.info,t,n.owner,n.token))throw La(t,n,i.info,i.info===null?"lease_released":"lease_taken_over");return await r()}finally{await o()}}function E_(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 k_(e,t,n,r){if(!n&&r){let o=t.warnings.length>0?` (${t.warnings.join(",")})`:"";throw new h(`Item ${e} lock is stale${o}; rerun with --force when supported for this command`,y.CONFLICT)}}function O_(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null||Array.isArray(t))return null;let n=t,r=n.pid,o=n.token,i=n.process_start_identity;return typeof r!="number"||!Number.isInteger(r)||r<=0||typeof o!="string"||o.length===0||i!==void 0&&(typeof i!="string"||!/^\d+$/u.test(i))?null:{pid:r,token:o,host_identity:n.host_identity,...typeof i=="string"?{process_start_identity:i}:{}}}async function kn(e){try{return O_(await M.readFile(W.join(e,Ka),"utf8"))}catch(t){return J(t)?null:void 0}}async function co(e){try{return await M.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function Fa(e,t){let n=await kn(e);for(let r=0;n===void 0&&r<3;r+=1)await Cn(Sn),n=await kn(e);!n||n.token!==t||await co(e)}async function Ua(e){try{await M.mkdir(e)}catch(n){return ue(n,"EEXIST"),null}let t={...await no(),host_identity:(await oo()).host_identity,token:On()};try{await M.writeFile(W.join(e,Ka),`${JSON.stringify(t)}
10
- `,"utf8")}catch{return await co(e),null}return t}async function za(e,t){let n=W.join(W.dirname(e),"recoveries"),r=r_("sha256").update(t).digest("hex");try{return await M.mkdir(n,{recursive:!0}),(await kn(e))?.token!==t?!1:(await M.rename(e,W.join(n,`gate-${r}`)),!0)}catch{return!1}}async function S_(e){let t;try{let r=await M.stat(e);t=Date.now()-r.mtimeMs}catch(r){return J(r)}let n=await kn(e);if(n===void 0)return!1;if(n!==null){if(await vn(n)==="dead")return za(e,n.token);if(n.host_identity!==void 0)return!1}return t<=Ha||n!==null&&await ro(n,t,Number.POSITIVE_INFINITY)?!1:n!==null?za(e,n.token):co(e)}async function Tn(e,t){let n=`${e}${f_}`,r=await Ua(n);if(r!==null)return async()=>Fa(n,r.token);if(!await S_(n))return null;let o=await Ua(n);return o===null?null:async()=>Fa(n,o.token)}async function A_(e,t){let n=W.join(W.dirname(e),"recoveries");await M.mkdir(n,{recursive:!0}),await M.writeFile(W.join(n,`${On()}.json`),`${JSON.stringify({event:"owner_dead_recovery_attempt",recorded_at:Zr(),lock:JSON.parse(t)})}
11
- `,{encoding:"utf8",flag:"wx",mode:384})}async function C_(e){let t=await Tn(e.lockPath,e.id);if(t===null)return{lockInfo:e.fallbackLockInfo,shouldRetryCreate:!1,staleRemovalCounted:!1};try{let n=await Ie(e.lockPath);if(n.info===null&&n.warnings.length===0)return{lockInfo:n,shouldRetryCreate:!0,staleRemovalCounted:!1};let r=await Va(n.info);if(!Ba(n.info,e.ttlSeconds)&&!r)return{lockInfo:n,shouldRetryCreate:!1,staleRemovalCounted:!1};if(k_(e.id,n,e.force||r,e.forceRequiredForStaleLock),e.staleRemovals>=u_)throw await Ya(e.id,n.info,performance.now()-e.startedAtMs);return r&&await A_(e.lockPath,JSON.stringify(n.info)),{lockInfo:n,shouldRetryCreate:await ao(e.lockPath,"lock:stale_remove"),staleRemovalCounted:!0}}finally{await t()}}async function T_(e,t,n,r){if(e instanceof h&&e.code===Na)throw e;if(!await i_(e,n))throw new h(`Failed to acquire lock for ${r}: ${Ci(e)}`,y.GENERIC_FAILURE);await Da(t,n,r)}async function Xa(e,t,n,r,o=!1,i=!0,s,a={}){return(await I_(e,t,n,r,o,i,s,a)).release}async function I_(e,t,n,r,o=!1,i=!0,s,a={}){let c=so(a.maxWaitMs),d=await dn("lock_acquire",{pm_root:e,id:t,ttl_seconds:n,owner:r,force:o,force_required_for_stale_lock:i,...c===void 0?{}:{max_wait_ms:c}});if(d.handled){let w=E_(d.result);if(w)return{release:async()=>{await Promise.resolve(w()),await dn("lock_release",{pm_root:e,id:t,owner:r})},fence:U=>U()}}let l=Zn(e,t),f=p_(s,c),u=g_(f,c,a.waitPolicy),m=__(f,u),p=m.startedAtMs,_=0,g=Sn,b=On();for(;;)try{let w=await a_(e,l,t,r,n,b,a.createParentDirectories!==!1),U={owner:r,token:b,acquiredAt:w,ttlSeconds:n};return{release:async()=>{await c_(l,t,r,b),await dn("lock_release",{pm_root:e,id:t,owner:r})},fence:ne=>v_(l,t,U,ne)}}catch(w){await T_(w,e,l,t);let U=await Ie(l);if(await Ga(U.info,n)){let $e=await C_({lockPath:l,id:t,ttlSeconds:n,force:o,forceRequiredForStaleLock:i,staleRemovals:_,waitBudgetMs:f,startedAtMs:p,fallbackLockInfo:U});if(U=$e.lockInfo,$e.staleRemovalCounted&&(_+=1),$e.shouldRetryCreate)continue}let ne=m.observe(U.info);if(ne.exhausted)throw await Ya(t,U.info,f===0?0:ne.elapsedMs,ne.ownerHandoffs);await Cn(Math.min(g,ne.remainingMs)),g=Math.min(g*2,An)}}(function(){try{var e=typeof window<"u"?window:typeof 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 te={max_serving_rows:256,max_bytes:262144,max_event_bytes:32768,retained_byte_fraction:.5,max_events:2048,retention_days:30},x=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function Re(e){let t=Date.parse(e.now??new Date().toISOString());if(!Number.isFinite(t))throw new x("Context usage now must be a valid timestamp");return{iso:new Date(t).toISOString(),ms:t}}function ec(e){let t=e.maxBytes??te.max_bytes,n=e.maxEvents??te.max_events,r=e.retentionDays??te.retention_days;if(!Number.isSafeInteger(t)||t<1024||t>te.max_bytes||!Number.isSafeInteger(n)||n<1||!Number.isFinite(r)||r<=0)throw new x("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");return{maxBytes:t,maxEvents:n,cutoff:Re(e).ms-r*864e5}}async function tc(e,t){if(!(await Ja(In.dirname(e))).isDirectory())throw new x("Context usage runtime must be a real directory");try{if((await Ja(e)).isSymbolicLink())throw new x("Context usage ledger must not be a symbolic link")}catch(r){if(!J(r))throw r}let n=await Za(e,t|Je.O_NOFOLLOW|Je.O_NONBLOCK,384);try{let r=await n.stat();if(!r.isFile()||r.nlink!==1)throw new x("Context usage ledger must be an unshared regular file");return n}catch(r){throw await n.close(),r}}async function Rn(e){let t=ec(e);try{let n=await tc(In.join(e.pmRoot,"runtime","context-usage.jsonl"),Je.O_RDONLY);try{let r=(await n.stat()).size,o=Math.max(0,r-t.maxBytes),i=Buffer.alloc(Math.min(r,t.maxBytes)),{bytesRead:s}=await n.read(i,0,i.length,o),a=i.subarray(0,s).toString("utf8");return(o>0?a.includes(`
7
+ Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,u=Ys(t).trim()||"Inspect the diagnostic code and retry with corrected input.",m=Math.max(1,s*4-Buffer.byteLength(`${l}${f}`,"utf8")),p=d?`${l}${Se(u,m)}${f}`:a;return{output:p,diagnostic_output:{diagnostic_class:r,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:Ae(Buffer.byteLength(p,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}var jr=Object.freeze({required:"Adjust command input or tracker state and retry.",why:Object.freeze(["pm enforces explicit, deterministic contracts for data and command semantics.","Commander validates CLI contracts before execution.","Unexpected runtime failures can occur from environment or extension-level issues.","Validation protects data consistency and deterministic behavior across commands.","Required options define command intent and enforce deterministic write contracts."]),examples:Object.freeze(["pm --help","pm <command> --help"])});function PE(e){return e?.trim()===jr.required}function $E(e){let t=e?.trim();return t!==void 0&&jr.why.includes(t)}function ME(e){return(e??[]).filter(t=>!jr.examples.includes(t.trim()))}var jE=Object.freeze(["attempted_command","normalized_args","provided_fields"]);function LE(e){if(!e)return;let{attempted_command:t,normalized_args:n,provided_fields:r,...o}=e;return Object.values(o).some(i=>i!==void 0)?o:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3a351971-6cfb-55eb-a266-3fec0af9eaa4")}catch{}})();var B=Object.freeze({comments:Object.freeze({paths:Object.freeze(["comments"]),total_key:"total_count"}),notes:Object.freeze({paths:Object.freeze(["notes"]),total_key:"total_count",delivered_row_counters:Object.freeze([Object.freeze({key:"structured_event_count",field:"format",equals:"json"})])}),learnings:Object.freeze({paths:Object.freeze(["learnings"]),total_key:"total_count"})});function Te(e,t){return e===void 0?!1:(Object.hasOwn(B,e)?B[e]:void 0)?.paths.includes(t)===!0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a65d6520-0e6f-5627-a4dd-bd455c2db0fa")}catch{}})();var ra=new WeakMap;function BE(e,t){ra.set(e,new Set(t))}var un='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',Bm={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"}},Vm=[{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 VE(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,y.USAGE)}function H(e,t=new Set){let n=e.filter(r=>!t.has(r.name)).map(r=>({...r}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function GE(e,t){let n=Vm.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return H([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return H(r)}var Gm=[{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 $(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Wm=new Set([void 0,"tabular_when_uniform"]),Km=new Set(["collection","none"]),Hm=new Set(["supported","unsupported"]);function ta(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(n=>typeof n=="string"&&n.length>0)&&new Set(e).size===e.length}function Ym(e){return $(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Km.has(e.row_kind)&&ta(e.row_keys,!0)&&(e.continuation_row_keys===void 0||ta(e.continuation_row_keys,!1))&&Hm.has(e.fields)&&Wm.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 Xm={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"]},Jm={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 Qm(e,t){let n=e.trim().toLowerCase().split(/\s+/u,1)[0],r=n?.startsWith("list-")?"list":n;if(r==="graph"){let s=typeof t.subcommand=="string"?t.subcommand:"";if(s.length===0)return;let a=Xm[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||$(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:un}:{},toon_encoding:"tabular_when_uniform"}}let o=Bm[r],i=Jm[r];return o===void 0||i===void 0||!i.some(s=>Object.hasOwn(t,s))?void 0:(()=>{let s=o.row_keys.filter(a=>{let c=a.split(".").reduce((d,l)=>$(d)?d[l]:void 0,t);return Array.isArray(c)||$(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:un}:{},toon_encoding:"tabular_when_uniform"}})()}function Zm(e){if(!$(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;let t=e.projection.declared_field_groups,n=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(n))return;let r=t.filter(s=>$(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=n.filter(s=>typeof s=="string");if(r.length!==t.length||o.length!==n.length)return;let i=new Set(r.map(s=>s.name));if(!(i.size!==r.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return H(r,new Set(o))}function ep(e){if(!Array.isArray(e.sections_included))return;let t=H(Gm,new Set(e.sections_included.filter(n=>typeof n=="string")));return $(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function tp(e,t,n){if(e==="dependency_provenance")return!1;let r=oa(e);if(r!==void 0){let o=n[r.facet];return $(o)&&Object.hasOwn(o,r.member)}return Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&$(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&$(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function oa(e){let t=e.indexOf(".");return t===-1?void 0:{facet:e.slice(0,t),member:e.slice(t+1)}}function np(e){if(!$(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=ra.get(e),i=a=>n.includes(a)||a==="body"||a==="dependency_provenance"?t:e,s=["body",...n,...r.slice(1),...o?.has("dependency_provenance")?["dependency_provenance"]:[],...o?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[],...[...o??[]].filter(a=>oa(a)!==void 0)].filter(a=>o===void 0||o.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:a==="blockers"?"--full":a==="dependency_provenance"?"--fields dependencies":`--fields ${a}`}));return H(s,new Set(s.flatMap(({name:a})=>tp(a,i(a),e)?[a]:[])))}function na(e){if($(e.projection))return H([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function rp(e){if(!$(e.projection))return H([]);if(typeof e.projection.mode=="string")return H([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function op(e){if(!(!$(e.selected)||typeof e.selected.summary!="boolean"))return H([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function ip(e,t){let n=Zm(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return ep(t);if(r==="get")return np(t);if(r==="list"||r.startsWith("list-"))return na(t);if(r==="search")return na(t)??H([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return rp(t);if(r==="contracts")return op(t)}function ia(e,t){if(e===void 0||!$(t))return t;let n=ip(e,t),r=t.row_contract,o=Ym(r)?r:Qm(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 $(i.omission_receipt)||n===void 0?i:{...i,omission_receipt:n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b67272d-8924-5b1b-97cd-74a6a10493be")}catch{}})();function Lr(e){let t=e.trim().toLowerCase().startsWith("extension:"),n=e.trim().toLowerCase().replace(/^extension:/u,"");if(ze(n))return;let r=Vs()?.commands??[],o=[...r].reverse().find(s=>s.command===n)?.command??(t?void 0:r.find(s=>s.action===n)?.command),i=[...r].reverse().find(s=>s.command===o);return i===void 0||ze(i.command)||ze(i.action)?void 0:i}function sp(e){let t=Lr(e);return t?.read_output===void 0?void 0:t}function sa(e,t){let n=sp(e),r=n?.read_output;if(r===void 0)return t;if(typeof t!="object"||t===null||Array.isArray(t))throw new h("Read-only extension commands must return a structured object.",y.USAGE,{code:"extension_read_output_invalid"});for(let o of r.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 h(`Read-only extension result is missing declared row collection ${o}.`,y.USAGE,{code:"extension_read_output_invalid"})}return{...t,row_contract:{command:`extension:${n.command}`,row_kind:r.row_keys.length>0?"collection":"none",row_keys:[...r.row_keys],fields:"supported",...r.row_keys.length>0?{jq_selector:un}:{},toon_encoding:"tabular_when_uniform"}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="040fff2e-c66f-5091-9ea8-7dcdaf6e203b")}catch{}})();var Fr={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded","--after"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},learnings:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},Ur=new Set(["--collapse","--fields","--section"]),fn=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 mn(e){return e.slice(2).replaceAll("-","_")}function aa(e,t={}){let n=e==="package catalog"||e==="packages catalog"||e==="package-catalog"||(e==="package"||e==="packages"||e==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":e==="package manage"||e==="package-manage"?"package-manage":e.split(" ")[0],r=n.startsWith("list-")?"list":n==="ctx"?"context":n;return be.includes(r)?r:void 0}function zr(e){return new Map((Fr[e]?.include??[]).filter(t=>!Ur.has(t)&&fn[t]===void 0).map(t=>[mn(t),qr(t)]))}function qr(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2335ae7f-c7aa-5bdd-ac2e-e6d7a74be2e1")}catch{}})();var pn="changed_fields",ap="changed_field_count",Br="rows",cp=new Set(["apply","rollback"]),ua=new Set(["deleted","would_delete"]),ca=256,da={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function dp(e,t){if(!F(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(da,e.action)?da[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return F(s)&&F(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let r=e[n.at(-1)],o=ma(r);return t.idOnly?o:!t.compactEnvelope&&t.changedFields!=="compact"?null:{...e,...t.compactEnvelope?{...o,changed_field_count:new Set(n.flatMap(i=>e[i].changed_fields)).size}:{},...Object.fromEntries(n.map(i=>[i,pa(e[i],t)]))}}function la(e){return typeof e!="string"||e.length<=ca?e:`${V(e,ca-1)}\u2026`}function lp(e){if(!F(e))return null;let t={...e};return t.reason=la(t.reason),F(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,la(r)]))),t}function F(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function fa(e){let t=e[pn];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==pn&&(n[r]=o);return n[ap]=t.length,n}function up(e){return"item"in e&&Array.isArray(e[pn])}function fp(e){return typeof e.mode=="string"&&cp.has(e.mode)&&Array.isArray(e[Br])}function mp(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[Br]=t,n}function ma(e){if(!F(e))return null;let t=F(e.item)?e.item:F(e.plan)?e.plan:null;if(t===null)return null;let n=typeof t.id=="string"?t.id:void 0,r=typeof e.outcome=="string"&&ua.has(e.outcome)?e.outcome:typeof t.status=="string"?t.status:void 0;return n?r?{id:n,status:r,...typeof e.deleted=="boolean"?{deleted:e.deleted}:{}}:{id:n}:null}function pp(e,t){if(!F(e))return null;if(F(e.plan)&&F(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||!F(e.item)||typeof e.item.id!="string")return null;let n=e[pn];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&ua.has(e.outcome)?{status:e.outcome}:typeof e.item.status=="string"?{status:e.item.status}:{},...typeof e.deleted=="boolean"?{deleted:e.deleted}:{},...typeof e.previous_status=="string"?{previous_status:e.previous_status}:{},changed_field_count:n.length};return _p(e,e.item,r),r}function _p(e,t,n){let r=typeof e.close_reason=="string"?e.close_reason:typeof t.close_reason=="string"?t.close_reason:void 0;r!==void 0&&(n.close_reason=r);let o=lp(e.recurrence);o!==null&&(n.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(n.warnings=e.warnings);for(let i of["recovery","follow_up","handoff","completion","start"])F(e[i])&&(n[i]=e[i]);if(typeof e.claimed_by=="string"||typeof e.released_by=="string")for(let i of["claimed_by","released_by","previous_assignee","forced","skipped","available","attempts","start_refused","suggestions"])Object.hasOwn(e,i)&&(n[i]=e[i])}function gp(e){let t=fp(e)?e[Br]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!F(o))return o;let i=fa(o);return i?(n=!0,i):o});return n?{projected:mp(e,r),changed:!0}:{projected:e,changed:!1}}function pa(e,t={}){let n=dp(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=ma(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=pp(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!F(e))return e;let r=!1,o=e,i=up(e)?fa(e):null;i!==null&&(o=i,r=!0);let s=gp(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{AsyncLocalStorage as X_}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]="9bb3b2ed-c289-5b96-99ce-9df6e202c464")}catch{}})();var _a=new Set(["--pm-path","--path","--author","--expect-hash","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),yp=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function hp(e){let t=e.indexOf("=");return t>0&&_a.has(e.slice(0,t))}function bp(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function ga(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(_a.has(n)){t+=bp(n,e[t+1])?1:0;continue}if(!(hp(n)||yp.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function rk(e){let t=ga(e);return t===void 0?void 0:e[t].trim().toLowerCase()}import wp 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]="86412887-5659-5892-beaa-bdd15a02ff4c")}catch{}})();var ya=e=>{let t='"',n=0;for(let r of e){if(r==="\\"){n+=1;continue}t+="\\".repeat(r==='"'?n*2+1:n),t+=r,n=0}return`${t}${"\\".repeat(n*2)}"`},ha=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?ya(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,_n=(e,t=process.platform)=>{let n=e.map(r=>ha(r,t)).join(" ");return n.length>0?`pm ${n}`:"pm"};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="97ad2370-83bf-5a93-b893-144c87d0ae18")}catch{}})();var Vr=new WeakMap;function uk(e){Vr.set(e,e.path)}function vp(e){if(!process.env.PM_PATH?.trim())return;let t=ti(e);return lt(ni(t),e)&&t===Zn(e)?void 0:wp.relative(e,t)||"."}function fk(e,t=process.cwd()){let n=Vr.has(e)?Vr.get(e):e.path,r=n?.trim()?n:vp(t),o=r?["--pm-path",r]:[];return e.noExtensions&&o.push("--no-extensions"),o}import{createHash as Dp}from"node:crypto";import{createHash as Tp}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]="f539ecb5-2f49-5867-96c7-48eddb81a628")}catch{}})();var Ep=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 N(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ba(e,t){let n=e;for(let r of t.split("."))if(Array.isArray(n)){if(!/^\d+$/u.test(r))return;n=n[Number(r)]}else{if(!N(n))return;n=n[r]}return n}function Gr(e,t,n){let r=t.split("."),o=(i,s)=>{if(s===r.length)return n;let a=r[s];if(Array.isArray(i)){let d=Number(a),l=[...i];return l[d]=o(i[d],s+1),l}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function Wr(e,t,n,r){let o=Ke(e).find(a=>a.path===t);if(!o)return e;let i=Array.isArray(o.value)?o.value.slice(n,r):Object.fromEntries(Object.entries(o.value).slice(n,r)),s=Gr(e,t,i);return N(s.summary)&&N(s.summary.focus_row_states)&&typeof s.summary.focus_row_states[t]=="string"&&(s.summary={...s.summary,focus_row_states:{...s.summary.focus_row_states,[t]:s.summary.focus_row_states[t].slice(n,r)}}),kt(s),s}function yn(e){let t=e.row_contract;return N(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Object.entries(e).filter(([,n])=>Array.isArray(n)).map(([n])=>n)}function kp(e){let t=e.row_contract;return N(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):yn(e)}function le(e){return yn(e).flatMap(t=>{let n=ba(e,t);return Array.isArray(n)||N(n)?[{path:t,value:n}]:[]})}function Ke(e){return kp(e).flatMap(t=>{let n=ba(e,t);return Array.isArray(n)||N(n)?[{path:t,value:n}]:[]})}function vt(e){let t=le(e),n=new Set(t.map(o=>o.path)),r=(o,i)=>{if(Array.isArray(o)){n.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>r(s,`${i}.${a}`));return}if(N(o))for(let[s,a]of Object.entries(o))i.length===0&&Ep.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function He(e){return le(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function Et(e,t){let n=e;for(let r of le(n)){let o=Array.isArray(r.value)?r.value.map((i,s)=>t(i,r.path,s)):Object.fromEntries(Object.entries(r.value).map(([i,s],a)=>[i,t(s,r.path,a)]));n=Gr(n,r.path,o)}return n}function wa(e,t,n=()=>!1){let r=e,o=!1;for(let i of le(r)){let s=Array.isArray(i.value)?i.value:Object.entries(i.value);if(s.length<=t)continue;o=!0;let a=n(i.path)?s.length-t:0,c=s.slice(a,a+t),d=Array.isArray(i.value)?c:Object.fromEntries(c);r=Gr(r,i.path,d)}return{result:r,truncated:o}}var va=["high_level","low_level","blocked_fallback"];function gn(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function pk(e,t){if(!N(e.summary)||!N(e.summary.returned_focus))return;let n=new Map(t.map(r=>[r.id,r]));e.summary={...e.summary,focus_row_states:Object.fromEntries(va.map(r=>[r,Array.isArray(e[r])?e[r].filter(N).map(o=>gn(n.get(o.id)??o)).join(""):""]))}}function Op(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 Sp(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(N):[],i=Op(r[n],o.length)??o.map(gn).join(""),s=new Map(o.flatMap((d,l)=>d.id===void 0?[]:[[d.id,i[l]]])),a=Array.isArray(e[n])?e[n].filter(N):[],c=!1;return{states:a.map((d,l)=>{let f=s.get(d.id)??(d.id===void 0?i[l]:void 0)??gn(d);return f!==gn(d)&&(c=!0),f}).join(""),needsStates:c}}function Ap(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 kt(e,t=e){if(Ap(e,t),!N(e.summary)||!N(e.summary.returned_focus))return;let n={...e.summary},r=N(t.summary)&&N(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=va.map(c=>({key:c,...Sp(e,t,c,r)})),i=Object.fromEntries(o.map(({key:c,states:d})=>[c,d])),s=o.some(c=>c.needsStates),a=Object.values(i).join("");typeof n.high_level=="number"&&(n.high_level=Array.isArray(e.high_level)?e.high_level.length:0),typeof n.low_level=="number"&&(n.low_level=Array.isArray(e.low_level)?e.low_level.length:0),n.returned_focus={active_items:a.length,in_progress:[...a].filter(c=>c.toLowerCase()==="i").length,open:[...a].filter(c=>c.toLowerCase()==="o").length,blocked:[...a].filter(c=>c===c.toUpperCase()).length},s?n.focus_row_states=i:delete n.focus_row_states,e.summary=n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="83f3f6fd-bd97-54a4-b39e-c66ec8e333b2")}catch{}})();var Cp=4096,Ip=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"]),ka=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:Ip}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function Ye(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Oa(e,t,n=e,r){let o=Object.hasOwn(B,t)?B[t]:void 0;if(o?.delivered_row_counters===void 0)return;let i=o.paths[0],s=e[i],a=n[i];if(!Array.isArray(s)||!Array.isArray(a))return;let c=r??a.length,d=a.slice(Math.max(0,c-s.length),c);for(let l of o.delivered_row_counters)typeof e[l.key]=="number"&&(e[l.key]=d.filter(f=>Ye(f)&&f[l.field]===l.equals).length)}function Ot(e){return Array.isArray(e)?e.map(Ot):Ye(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Ot(n)])):e}function Ea(e,t){if(!Ye(e))return Ot(e);let n=typeof e.name=="string"?e.name:void 0,r=n!==void 0&&Object.hasOwn(t.ignored_detail_field_names_by_row,n)?t.ignored_detail_field_names_by_row[n]:void 0;return Object.fromEntries(Object.entries(e).map(([o,i])=>o!=="details"||!r||!Ye(i)?[o,Ot(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!r.includes(s)).map(([s,a])=>[s,Ot(a)]))]))}function Rp(e,t){return Array.isArray(e)?e.map(n=>Ea(n,t)):Ea(e,t)}function hn(e,t,n){let r=n?ka[n]:void 0,o=r?.paths.includes(e)===!0;return Tp("sha256").update(ye({path:e,value:o?Rp(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function Kr(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint,...e.direction==="backward"?{d:"b"}:{}}),"utf8").toString("base64url")}function xp(e){return typeof e=="string"&&(Ce(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function Np(e){return e===void 0||e==="b"}function St(e){if(e.length>Cp)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!Ye(t)||t.v!==1||!xp(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||!Np(t.d))throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f,...t.d==="b"?{direction:"backward"}:{}}}function Sa(e){if(!Array.isArray(e.assertions))return e;let t=n=>!Ye(n)||n.verdict==="pass"?4:n.verdict==="retired"?3:n.enforcement==="block"?0:n.enforcement==="warn"?1:2;return{...e,assertions:e.assertions.map((n,r)=>({row:n,index:r})).sort((n,r)=>t(n.row)-t(r.row)||n.index-r.index).map(({row:n})=>n),budget_retention_policy:"verdict_priority"}}function Aa(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,y.USAGE,{code:"read_output_cursor_command_mismatch"});let r=Ke(e).find(c=>c.path===n.path),o=r?Array.isArray(r.value)?r.value.length:Object.keys(r.value).length:0,i=Te(t,n.path);if(!r||o!==n.total_rows||n.offset>o||i!==(n.direction==="backward")||hn(n.path,r.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",y.USAGE,{code:"read_output_cursor_stale"});if(!i)return Wr(e,n.path,n.offset);let s=Wr(e,n.path,0,n.offset);for(let c of["count","returned_count"])typeof s[c]=="number"&&(s[c]=n.offset);let a=B[t].total_key;return typeof s[a]!="number"&&(s[a]=n.total_rows),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6a81cf4-3095-5197-8e73-f017d98b1ccf")}catch{}})();var Yr=1,Ta=4096,Pp=/^[A-Za-z0-9_-]+$/;function Hr(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function Rk(e,t){let n=[...Object.values(Jt),...Qt],r=new Set(n.flatMap(o=>[Hr(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){r.add(Hr(o.flag));for(let i of o.aliases??[])r.add(Hr(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!r.has(o)))}function xk(e,t){return Dp("sha256").update(e).update("\0").update(ye(t)).digest("hex").slice(0,24)}function At(e,t,n,r){return Buffer.from(JSON.stringify({version:Yr,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function Ie(e,t){return new h(e,y.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function $p(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===Yr&&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 Xr(e,t="--after"){if(typeof e!="string")throw Ie("Query cursor is malformed.",t);let n=e.trim();if(n.length===0||n.length>Ta||!Pp.test(n))throw Ie("Query cursor is malformed.",t);let r;try{r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"))}catch{throw Ie("Query cursor is malformed.",t)}if(!$p(r)){let o=!1;try{St(n),o=!0}catch{}throw o?new h(`An output cursor must be continued with --output-cursor, not ${t}.`,y.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${n}; retain any producer ${t} cursor from the original page.`]}):Ie("Query cursor version or payload is unsupported.",t)}return r}function Jr(e,t,n="--after"){let r=Xr(e,n);if(r.fingerprint!==t)throw Ie(`Query cursor does not match the current filters, sort, or query (${r.fingerprint} != ${t}).`,n);return{after_id:r.after_id,...r.after_index===void 0?{}:{after_index:r.after_index},...r.snapshot===void 0?{}:{snapshot:r.snapshot}}}function Nk(e,t){return Jr(e,t).after_id}function Mp(e,t,n,r,o="--after"){if(t===void 0)return 0;let i=Jr(t,n,o),s=e.findIndex(a=>r(a)===i.after_id);if(s<0){if(i.after_index!==void 0)return Math.min(i.after_index,e.length);throw Ie(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return s+1}function Dk(e,t){if(t.cursor!==void 0&&Jr(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw Ie("Query cursor does not match the requested snapshot.","--after");let n=Mp(e,t.cursor,t.fingerprint,t.readId),r=e.slice(n,n+t.limit),o=r.length>0&&n+r.length<e.length,i=r.at(-1);return{rows:r,has_more:o,...o&&i!==void 0?{next_cursor:At(t.fingerprint,t.readId(i),n+r.length-1,t.snapshot)}:{}}}var Pk=Object.freeze({version:Yr,max_length:Ta});import{randomUUID as U_}from"node:crypto";import{randomUUID as M_}from"node:crypto";import{constants as Qe}from"node:fs";import{lstat as Za,mkdir as j_,open as tc,rename as L_,rm as F_}from"node:fs/promises";import Rn from"node:path";import{constants as c_}from"node:fs";import M from"node:fs/promises";import W from"node:path";import{createHash as d_,randomUUID as Sn}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 Ca(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import jp from"node:crypto";import{AsyncLocalStorage as Lp}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 Ra=new Lp,Ia=1024;function xa(){let e=Ra.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 Fk(e){let t=Ra.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>Ia)throw new Error(`Reproducible token length must be an integer between 0 and ${Ia}`);let n="";for(;n.length<e;){let r=jp.createHash("sha256").update(`${t.seed}\0${t.tokenReads}`).digest();t.tokenReads+=1;for(let o of r)if(n+=(o%36).toString(36),n.length===e)break}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0bf155fc-c690-5318-ba1e-275f1787858b")}catch{}})();var Fp=/^([+-]?)(\d+)([hdwm])$/i,Up=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,zp=/^(\d{4})(\d{2})(\d{2})$/,qp=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Bp=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Vp=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Gp=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function eo(){return xa()??new Date().toISOString()}function Gk(e){return Number.isFinite(Date.parse(e))}function Wp(e){let t=Gp.exec(e);if(!t||!Number.isFinite(Date.parse(e)))return!1;let[,n,r,o,i,s,a,c,d]=t,[l,f,u,m,p,_]=[n,r,o,i,s,a].map(Number);return f>=1&&f<=12&&u>=1&&u<=to(l,f-1)&&m<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function Wk(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return Wp(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var Kp=1e4,bn=new Map;function Na(e){let t=bn.get(e);if(t!==void 0)return t;let n=Date.parse(e);return bn.size>=Kp&&Ca(bn),bn.set(e,n),n}function Xe(e,t){let n=Na(e),r=Na(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function Kk(e,t){return!(t.deadlineBefore&&(!e.deadline||Xe(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||Xe(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&Xe(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&Xe(e.updated_at,t.updatedBefore)>0||t.createdAfter&&Xe(e.created_at,t.createdAfter)<0||t.createdBefore&&Xe(e.created_at,t.createdBefore)>0)}function Qr(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function Zr(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 Hp(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function Yp(e){let t=[],n=d=>Hp(t,e,d),r=zp.exec(e);if(r){let[,d,l,f]=r;n(`${d}-${l}-${f}`)}let o=qp.exec(e);if(o){let[,d,l,f,u,m,p,_,g]=o,b=p?`:${p}`:"";n(`${d}-${l}-${f}T${u}:${m}${b}${Qr(_)}${Zr(g)}`)}let i=Bp.exec(e);if(i){let[,d,l,f,u,m,p]=i,_=u?`:${u}`:"";n(`${d}T${l}:${f}${_}${Qr(m)}${Zr(p)}`)}let s=Vp.exec(e);if(s){let[,d,l,f,u,m,p]=s,_=u?`:${u}`:"";n(`${d}T${l}:${f}${_}${Qr(m)}${Zr(p)}`)}let a=10,c=e.slice(0,a);if(Jp(c)){let d=a;for(;d<e.length&&Qp(e[d]);)d+=1;d<e.length&&n(`${c}T${e.slice(d)}`)}return t}function Xp(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of Yp(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function Jp(e){if(e.length!==10)return!1;for(let t=0;t<e.length;t+=1){let n=e[t];if(t===4||t===7){if(n!=="-")return!1;continue}let r=n.charCodeAt(0);if(r<48||r>57)return!1}return!0}function Qp(e){return e?e===" "||e===" "||e===`
8
+ `||e==="\r"||e==="\f"||e==="\v":!1}function to(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var Zp=["January","February","March","April","May","June","July","August","September","October","November","December"],e_=/^(\d{4})-(\d{2})-(\d{2})/,t_=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function n_(e,t,n){let r=e_.exec(t)??t_.exec(t);if(!r)return;let o=Number.parseInt(r[1],10),i=Number.parseInt(r[2],10),s=Number.parseInt(r[3],10),a=n?.trim()||"deadline";if(i<1||i>12)throw new h(`Invalid ${a} value "${e}". Month "${r[2]}" is out of range \u2014 use a month between 01 and 12.`,y.USAGE,{field:a,value:e});let c=to(o,i-1);if(s<1||s>c)throw new h(`Invalid ${a} value "${e}". ${Zp[i-1]} ${o} has ${c} days, so day "${r[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,y.USAGE,{field:a,value:e})}function r_(e,t){let n=new Date(e.getTime()),r=n.getUTCDate(),o=n.getUTCMonth()+t,i=n.getUTCFullYear()+Math.floor(o/12),s=(o%12+12)%12,a=Math.min(r,to(i,s));return n.setUTCFullYear(i,s,a),n}function Hk(e,t=new Date,n="deadline"){let r=e.trim();if(r.toLowerCase()==="now")return t.toISOString();let o=Fp.exec(r);if(o){let s=o[1]==="-"?-1:1,a=Number.parseInt(o[2],10)*s,c=o[3].toLowerCase();if(c==="m")return r_(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()}n_(e,r,n);let i=Xp(r);if(!Number.isFinite(i)){let s=n.trim().length>0?n.trim():"deadline",a=Up.test(r)?"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.":'Use ISO/date string input, "now", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';throw new h(`Invalid ${s} value "${e}". ${a}`,y.USAGE,{field:s,value:e})}return new Date(i).toISOString()}import wn from"node:fs/promises";import G from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f1eb25ad-08b8-5826-9ec1-7b0a7a22d277")}catch{}})();var Pa="lock_path_unsafe";function o_(e,t){return G.relative(e,t).split(G.sep).join("/")}function i_(e,t){return e==="lock_entry_symlink"?`Remove the symlinked lock entry ${t} (pm neither follows nor deletes it), then retry the same operation.`:e==="lock_directory_replaced"?`Restore ${t} as a real directory inside the tracker, then retry the same operation. The lock file created while it was replaced stays where the replacement pointed, because pm never deletes outside the tracker; remove it there if it is not wanted.`:"Replace the symlinked or replaced lock directory with a real directory inside the tracker (for example: remove the link, then let pm recreate locks/), then retry the same operation."}function Tt(e){let t=e.component??G.dirname(e.lockPath),n=o_(e.pmRoot,t);return new h(`Refused to acquire lock ${e.id}: ${n} is not a real directory inside the tracker (${e.reason}). Locks are never created through a symlinked or replaced lock directory.`,y.CONFLICT,{code:"lock_path_unsafe",item_id:e.id,reason:e.reason,lock_component:n,required:i_(e.reason,n)})}function Da(e,t){return e.dev===t.dev&&e.ino===t.ino}async function vn(e,t,n,r=!0){let o=G.resolve(e),i=G.dirname(G.resolve(t)),s=G.relative(o,i);if(s===".."||s.startsWith(`..${G.sep}`)||G.isAbsolute(s))throw Tt({pmRoot:o,lockPath:t,id:n,reason:"lock_path_outside_tracker",component:i});let a=o,c=null;for(let l of s===""?[]:s.split(G.sep)){a=G.join(a,l);let f;try{f=await wn.lstat(a,{bigint:!0})}catch(u){if(r&&J(u))return null;throw u}if(f.isSymbolicLink())throw Tt({pmRoot:o,lockPath:t,id:n,reason:"lock_directory_symlink",component:a});if(!f.isDirectory())throw Tt({pmRoot:o,lockPath:t,id:n,reason:"lock_directory_not_directory",component:a});c={dev:f.dev,ino:f.ino}}if(c!==null)return c;let d=await wn.stat(o,{bigint:!0});return{dev:d.dev,ino:d.ino}}async function $a(e,t,n){let r;try{r=await wn.lstat(t)}catch{return}if(r.isSymbolicLink())throw Tt({pmRoot:e,lockPath:t,id:n,reason:"lock_entry_symlink",component:t})}async function Ma(e){let t=await e.handle.stat({bigint:!0}),n={dev:t.dev,ino:t.ino},r=!1;try{let o=await vn(e.pmRoot,e.lockPath,e.id,!1);if(Da(e.directory,o)){let i=await wn.lstat(e.lockPath,{bigint:!0});r=!i.isSymbolicLink()&&Da(n,i)}}catch{r=!1}if(!r)throw Tt({pmRoot:e.pmRoot,lockPath:e.lockPath,id:e.id,reason:"lock_directory_replaced"})}import no from"node:fs/promises";import{createHash as s_}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d1f829a5-70d6-5096-86f7-717440dd67d5")}catch{}})();function ja(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function a_(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!ja(t,"ESRCH")}}function La(e){let t=e.lastIndexOf(")");if(t<0)return null;let n=e.slice(t+2).trim().split(/\s+/u)[19];return n!==void 0&&/^\d+$/u.test(n)?n:null}async function Je(e){try{return La(await no.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function ro(e=process.pid){let t=await Je(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function oo(e,t,n){if(!a_(e.pid))return!1;let r=await Je(e.pid);return e.process_start_identity!==void 0&&r!==null?r===e.process_start_identity:t<=n}async function Fa(){try{let[e,t]=await Promise.all([no.readFile("/proc/sys/kernel/random/boot_id","utf8"),no.readlink("/proc/self/ns/pid")]);return!/^[a-f0-9-]{36}\s*$/u.test(e)||!/^pid:\[\d+\]$/u.test(t)?null:s_("sha256").update(`${e.trim()}:${t}`).digest("hex")}catch{return null}}async function io(){let[e,t]=await Promise.all([Fa(),Je(process.pid)]);return e!==null&&t!==null?{host_identity:e,process_start_identity:t}:{}}async function En(e){if(!e||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0||typeof e.host_identity!="string"||typeof e.process_start_identity!="string"||!/^\d+$/u.test(e.process_start_identity))return"unknown";let t=await Fa();if(t===null||t!==e.host_identity)return"unknown";try{process.kill(e.pid,0)}catch(r){return ja(r,"ESRCH")?"dead":"unknown"}let n=await Je(e.pid);return n===null?"unknown":n===e.process_start_identity?"alive":"dead"}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="54aee8ec-9ef4-54d4-92fa-f4104b3ec4cc")}catch{}})();function l_(e){let t;try{t=JSON.parse(e)}catch{return{info:null,warnings:["lock_info_invalid_json"]}}if(typeof t!="object"||t===null||Array.isArray(t))return{info:null,warnings:["lock_info_invalid_shape"]};let n=t,r=n.id,o=n.pid,i=n.owner,s=n.token,a=n.created_at,c=n.ttl_seconds;return typeof r!="string"||typeof o!="number"||!Number.isFinite(o)||typeof i!="string"||s!==void 0&&(typeof s!="string"||s.trim().length===0)||typeof a!="string"||typeof c!="number"||!Number.isFinite(c)?{info:null,warnings:["lock_info_invalid_shape"]}:{info:{id:r,pid:o,owner:i,...typeof s=="string"?{token:s}:{},created_at:a,ttl_seconds:c,host_identity:n.host_identity,process_start_identity:n.process_start_identity},warnings:[]}}async function Re(e,t=!0){try{let n=await M.readFile(e,"utf8");return t&&await Ws({path:e,scope:"project"}),l_(n)}catch(n){return J(n)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function ue(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function u_(e,t,n=process.platform){if(ue(e,"EEXIST"))return!0;if(!ue(e,"EPERM")&&!ue(e,"EACCES")&&!ue(e,"EBUSY"))return!1;try{return await M.lstat(t),!0}catch(r){if(n!=="win32"||!J(r)&&!ue(r,"EPERM")&&!ue(r,"EACCES")&&!ue(r,"EBUSY"))return!1}try{return await M.access(W.dirname(t),c_.W_OK),!0}catch{return!1}}async function Va(e,t){await Gs({path:e,scope:"project",op:t})}async function f_(e,t,n,r=Sn()){return{...await io(),id:e,pid:process.pid,owner:t,token:r,created_at:eo(),ttl_seconds:n}}async function m_(e,t,n,r,o,i,s){let a=await vn(e,t,n);s&&a===null&&await M.mkdir(W.dirname(t),{recursive:!0});let c=await In(t,n);if(c===null)throw await M.access(W.dirname(t)),Object.assign(new Error("Lock initialization is contended"),{code:"EEXIST"});let d;try{let l=await vn(e,t,n,!1),f=await M.open(t,"wx");try{await Ma({pmRoot:e,lockPath:t,id:n,handle:f,directory:l})}catch(u){throw await f.close(),u}try{try{let u=await f_(n,r,o,i);d=u.created_at,await f.writeFile(`${JSON.stringify(u,null,2)}
9
+ `,"utf8")}finally{await f.close()}}catch(u){throw await co(t,"lock:release"),u}}finally{await c()}return await Va(t,"lock:create"),d}async function co(e,t){try{return await M.unlink(e),await Va(e,t),!0}catch{return!1}}async function p_(e,t,n,r){let o=performance.now(),i=An;for(;;){let s=await In(e,t);if(s!==null){try{let d=await Re(e,!1);so(d.info,t,n,r)&&await co(e,"lock:release")}finally{await s()}return}let a=await Re(e,!1);if(!so(a.info,t,n,r))return;let c=performance.now()-o;if(c>=kn)return;await Cn(Math.min(i,kn-c)),i=Math.min(i*2,Tn)}}function so(e,t,n,r){return e?.id===t&&e.pid===process.pid&&e.owner===n&&e.token===r}function Ga(e,t){let n=e?.created_at?Date.parse(e.created_at):Number.NaN;return(Number.isFinite(n)?Date.now()-n:Number.POSITIVE_INFINITY)>t*1e3}async function Wa(e){return e!==null&&Number.isFinite(Date.parse(e.created_at))&&await En(e)==="dead"}async function Ka(e,t){return Ga(e,t)||await Wa(e)}async function bO(e,t,n){let{info:r}=await Re(er(e,t),!1);return r!==null&&r.owner.startsWith(n)&&!await Ka(r,r.ttl_seconds)}function __(e){return e?.owner?` (owner ${e.owner})`:""}var An=25,Tn=200,Ha=250,g_=12e4,y_=3,h_=".stale-cleanup",Ya="owner.json",Xa=1e4,kn=Xa+Tn;function ao(e){if(typeof e=="string"){let t=e.trim();if(!/^\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)?n:void 0}if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return Math.trunc(e)}function b_(e){let t=process.env.PM_LOCK_WAIT_MS,n=ao(t);if(n!==void 0)return n;let r=ao(e);return r!==void 0?r:0}function w_(e,t){return Math.min(b_(e),t??1/0)}function Cn(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(n=>setTimeout(n,t))}async function Ja(e,t,n,r=0){n=Math.floor(n);let o=await En(t),i=r>0?` across ${r} owner handoff(s)`:"",s=n>0?` after waiting ${n}ms${i}`:"";return new h(`Item ${e} is locked${__(t)} (owner process ${o})${s}`,y.CONFLICT,{code:"lock_conflict",item_id:e,reason:`lock_owner_${o}`,required:"Wait for the owner to release the lock, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget when contention is expected. Inspect stale receipts with pm gc --scope locks --dry-run.",recovery:{retry_after_ms:Ha,...n>0?{waited_ms:n,owner_handoffs:r}:{}}})}function v_(e,t){let n=performance.now(),r=n,o,i=0;return{startedAtMs:n,observe(s){let a=performance.now(),c=k_(s);o!==void 0&&c!==o&&(i+=1,r=a),o=c;let d=a-n,l=a-r;return{exhausted:e===0||l>=e||d>=t,elapsedMs:d,remainingMs:Math.min(e-l,t-d),ownerHandoffs:i}}}}function E_(e,t,n){return n!=="progress"||t!==void 0?e:Math.max(e,g_)}function k_(e){return e===null?"released":e.token??`${e.pid}:${e.owner}:${e.created_at}`}function O_(e){let t=Date.parse(e.acquiredAt)+e.ttlSeconds*1e3;return{owner:e.owner,acquired_at:e.acquiredAt,ttl_seconds:e.ttlSeconds,expires_at:new Date(t).toISOString()}}function S_(e,t,n,r){let o=`the lease acquired at ${t.acquiredAt} (ttl ${t.ttlSeconds}s)`;if(r==="fence_gate_unavailable")return{summary:`Lock for ${e} could not be verified before commit: ${o} could not enter its commit fence because the stale-cleanup gate stayed held.`,required:"Retry the same operation; this writer's change was not committed. Inspect pm gc --scope locks --dry-run if the stale-cleanup gate stays held."};let i=n===null?"the lock no longer exists":`it is now held by ${n.owner} since ${n.created_at}`;return{summary:`Lock for ${e} was lost before commit: ${o} is no longer owned by this writer, and ${i}.`,required:"Re-read the item and apply the mutation again; this writer's change was not committed and the newer value was kept. Keep mutation work shorter than locks.ttl_seconds, or raise locks.ttl_seconds for long-running callbacks."}}function Ua(e,t,n,r){let{summary:o,required:i}=S_(e,t,n,r);return new h(`${o} Nothing was written.`,y.CONFLICT,{code:"lock_lost",item_id:e,reason:r,lease:O_(t),current_owner:n===null?null:{owner:n.owner,pid:n.pid,created_at:n.created_at,ttl_seconds:n.ttl_seconds},required:i,recovery:{retry_after_ms:Ha}})}async function A_(e,t){let n=performance.now(),r=An;for(;;){let o=await In(e,t);if(o!==null)return o;let i=performance.now()-n;if(i>=kn)return null;await Cn(Math.min(r,kn-i)),r=Math.min(r*2,Tn)}}async function T_(e,t,n,r){let o=await A_(e,t);if(o===null){let i=await Re(e,!1);throw Ua(t,n,i.info,"fence_gate_unavailable")}try{let i=await Re(e,!1);if(!so(i.info,t,n.owner,n.token))throw Ua(t,n,i.info,i.info===null?"lease_released":"lease_taken_over");return await r()}finally{await o()}}function C_(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 I_(e,t,n,r){if(!n&&r){let o=t.warnings.length>0?` (${t.warnings.join(",")})`:"";throw new h(`Item ${e} lock is stale${o}; rerun with --force when supported for this command`,y.CONFLICT)}}function R_(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null||Array.isArray(t))return null;let n=t,r=n.pid,o=n.token,i=n.process_start_identity;return typeof r!="number"||!Number.isInteger(r)||r<=0||typeof o!="string"||o.length===0||i!==void 0&&(typeof i!="string"||!/^\d+$/u.test(i))?null:{pid:r,token:o,host_identity:n.host_identity,...typeof i=="string"?{process_start_identity:i}:{}}}async function On(e){try{return R_(await M.readFile(W.join(e,Ya),"utf8"))}catch(t){return J(t)?null:void 0}}async function lo(e){try{return await M.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function za(e,t){let n=await On(e);for(let r=0;n===void 0&&r<3;r+=1)await Cn(An),n=await On(e);!n||n.token!==t||await lo(e)}async function qa(e){try{await M.mkdir(e)}catch(n){return ue(n,"EEXIST"),null}let t={...await ro(),host_identity:(await io()).host_identity,token:Sn()};try{await M.writeFile(W.join(e,Ya),`${JSON.stringify(t)}
10
+ `,"utf8")}catch{return await lo(e),null}return t}async function Ba(e,t){let n=W.join(W.dirname(e),"recoveries"),r=d_("sha256").update(t).digest("hex");try{return await M.mkdir(n,{recursive:!0}),(await On(e))?.token!==t?!1:(await M.rename(e,W.join(n,`gate-${r}`)),!0)}catch{return!1}}async function x_(e){let t;try{let r=await M.stat(e);t=Date.now()-r.mtimeMs}catch(r){return J(r)}let n=await On(e);if(n===void 0)return!1;if(n!==null){if(await En(n)==="dead")return Ba(e,n.token);if(n.host_identity!==void 0)return!1}return t<=Xa||n!==null&&await oo(n,t,Number.POSITIVE_INFINITY)?!1:n!==null?Ba(e,n.token):lo(e)}async function In(e,t){let n=`${e}${h_}`,r=await qa(n);if(r!==null)return async()=>za(n,r.token);if(!await x_(n))return null;let o=await qa(n);return o===null?null:async()=>za(n,o.token)}async function N_(e,t){let n=W.join(W.dirname(e),"recoveries");await M.mkdir(n,{recursive:!0}),await M.writeFile(W.join(n,`${Sn()}.json`),`${JSON.stringify({event:"owner_dead_recovery_attempt",recorded_at:eo(),lock:JSON.parse(t)})}
11
+ `,{encoding:"utf8",flag:"wx",mode:384})}async function D_(e){let t=await In(e.lockPath,e.id);if(t===null)return{lockInfo:e.fallbackLockInfo,shouldRetryCreate:!1,staleRemovalCounted:!1};try{let n=await Re(e.lockPath);if(n.info===null&&n.warnings.length===0)return{lockInfo:n,shouldRetryCreate:!0,staleRemovalCounted:!1};let r=await Wa(n.info);if(!Ga(n.info,e.ttlSeconds)&&!r)return{lockInfo:n,shouldRetryCreate:!1,staleRemovalCounted:!1};if(I_(e.id,n,e.force||r,e.forceRequiredForStaleLock),e.staleRemovals>=y_)throw await Ja(e.id,n.info,performance.now()-e.startedAtMs);return r&&await N_(e.lockPath,JSON.stringify(n.info)),{lockInfo:n,shouldRetryCreate:await co(e.lockPath,"lock:stale_remove"),staleRemovalCounted:!0}}finally{await t()}}async function P_(e,t,n,r){if(e instanceof h&&e.code===Pa)throw e;if(!await u_(e,n))throw new h(`Failed to acquire lock for ${r}: ${Ii(e)}`,y.GENERIC_FAILURE);await $a(t,n,r)}async function Qa(e,t,n,r,o=!1,i=!0,s,a={}){return(await $_(e,t,n,r,o,i,s,a)).release}async function $_(e,t,n,r,o=!1,i=!0,s,a={}){let c=ao(a.maxWaitMs),d=await ln("lock_acquire",{pm_root:e,id:t,ttl_seconds:n,owner:r,force:o,force_required_for_stale_lock:i,...c===void 0?{}:{max_wait_ms:c}});if(d.handled){let w=C_(d.result);if(w)return{release:async()=>{await Promise.resolve(w()),await ln("lock_release",{pm_root:e,id:t,owner:r})},fence:U=>U()}}let l=er(e,t),f=w_(s,c),u=E_(f,c,a.waitPolicy),m=v_(f,u),p=m.startedAtMs,_=0,g=An,b=Sn();for(;;)try{let w=await m_(e,l,t,r,n,b,a.createParentDirectories!==!1),U={owner:r,token:b,acquiredAt:w,ttlSeconds:n};return{release:async()=>{await p_(l,t,r,b),await ln("lock_release",{pm_root:e,id:t,owner:r})},fence:ne=>T_(l,t,U,ne)}}catch(w){await P_(w,e,l,t);let U=await Re(l);if(await Ka(U.info,n)){let je=await D_({lockPath:l,id:t,ttlSeconds:n,force:o,forceRequiredForStaleLock:i,staleRemovals:_,waitBudgetMs:f,startedAtMs:p,fallbackLockInfo:U});if(U=je.lockInfo,je.staleRemovalCounted&&(_+=1),je.shouldRetryCreate)continue}let ne=m.observe(U.info);if(ne.exhausted)throw await Ja(t,U.info,f===0?0:ne.elapsedMs,ne.ownerHandoffs);await Cn(Math.min(g,ne.remainingMs)),g=Math.min(g*2,Tn)}}(function(){try{var e=typeof window<"u"?window:typeof 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 te={max_serving_rows:256,max_bytes:262144,max_event_bytes:32768,retained_byte_fraction:.5,max_events:2048,retention_days:30},x=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function xe(e){let t=Date.parse(e.now??new Date().toISOString());if(!Number.isFinite(t))throw new x("Context usage now must be a valid timestamp");return{iso:new Date(t).toISOString(),ms:t}}function nc(e){let t=e.maxBytes??te.max_bytes,n=e.maxEvents??te.max_events,r=e.retentionDays??te.retention_days;if(!Number.isSafeInteger(t)||t<1024||t>te.max_bytes||!Number.isSafeInteger(n)||n<1||!Number.isFinite(r)||r<=0)throw new x("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");return{maxBytes:t,maxEvents:n,cutoff:xe(e).ms-r*864e5}}async function rc(e,t){if(!(await Za(Rn.dirname(e))).isDirectory())throw new x("Context usage runtime must be a real directory");try{if((await Za(e)).isSymbolicLink())throw new x("Context usage ledger must not be a symbolic link")}catch(r){if(!J(r))throw r}let n=await tc(e,t|Qe.O_NOFOLLOW|Qe.O_NONBLOCK,384);try{let r=await n.stat();if(!r.isFile()||r.nlink!==1)throw new x("Context usage ledger must be an unshared regular file");return n}catch(r){throw await n.close(),r}}async function xn(e){let t=nc(e);try{let n=await rc(Rn.join(e.pmRoot,"runtime","context-usage.jsonl"),Qe.O_RDONLY);try{let r=(await n.stat()).size,o=Math.max(0,r-t.maxBytes),i=Buffer.alloc(Math.min(r,t.maxBytes)),{bytesRead:s}=await n.read(i,0,i.length,o),a=i.subarray(0,s).toString("utf8");return(o>0?a.includes(`
12
12
  `)?a.slice(a.indexOf(`
13
13
  `)+1):"":a).split(`
14
- `).flatMap(c=>{try{let d=JSON.parse(c);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await n.close()}}catch{return[]}}function Qa(e,t,n){let r=[],o=0;for(let i=e.length-1;i>=0&&r.length<n;i-=1){let s=`${JSON.stringify(e[i])}
15
- `;if(o+=Buffer.byteLength(s),o>t)break;r.push(s)}return r.reverse().join("")}async function Ct(e,t,n){let r=ec(e),o=In.join(e.pmRoot,"runtime","context-usage.jsonl"),i=Math.floor(r.maxBytes*te.retained_byte_fraction),s=Math.min(te.max_event_bytes,i);if(t.some(u=>Buffer.byteLength(`${JSON.stringify(u)}
16
- `)>s))throw new x("Context usage event exceeds the declared byte ceiling");let a=t.filter(u=>Date.parse(u.at)>=r.cutoff),c=Qa(a,i,r.maxEvents),d=performance.now(),l=await Xa(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),f=performance.now()-d;try{await x_(In.dirname(o),{recursive:!0});let u=await tc(o,Je.O_WRONLY|Je.O_CREAT|Je.O_APPEND);try{let m=(await u.stat()).size,p=n===void 0?void 0:await Rn(e);if(p?.some(w=>w.kind==="delivery"&&w.serve_id===n))return{written_bytes:0,ledger_bytes:m,compacted:!1,lock_wait_ms:f};if(!(e.maxEvents!==void 0||e.retentionDays!==void 0)&&m+Buffer.byteLength(c)<=r.maxBytes)return await u.writeFile(c,"utf8"),{written_bytes:Buffer.byteLength(c),ledger_bytes:m+Buffer.byteLength(c),compacted:!1,lock_wait_ms:f};let _=Qa([...p??await Rn(e),...a],i,r.maxEvents),g=`${o}.${process.pid}.${R_()}.tmp`,b=await Za(g,"wx",384);try{try{await b.writeFile(_,"utf8")}finally{await b.close()}return await u.close(),u=void 0,await N_(g,o),{written_bytes:Buffer.byteLength(_),ledger_bytes:Buffer.byteLength(_),compacted:!0,lock_wait_ms:f}}finally{await D_(g,{force:!0})}}finally{await u?.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 $_=864e5,xn=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function kO(e,t){let n=D(e);n!==null&&t!==null&&(n[xn]=t)}function Tt(e,t){let n=D(e),r=D(t),o=n?.[xn];r!==null&&o!==void 0&&(r[xn]=o)}function M_(e){return D(e)?.[xn]??null}function rc(e){let t=D(e);for(let n of["read_output","context_intent"])if(D(t?.[n])?.result_omitted===!0)return!0;return!1}function fe(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function oc(e,t){if(Array.isArray(t))for(let n of t)fe(e,D(n)?.id)}function nc(e,t){if(Array.isArray(t))for(let n of t)fe(e,n)}function j_(e,t){let n=D(e.recommended)===null?[]:[e.recommended];for(let r of["ready","decision_needed","gate_needed","containers","blocked","held_by_others"])Array.isArray(e[r])&&n.push(...e[r]);for(let r of n){let o=D(r);fe(t,o?.id);for(let i of Array.isArray(o?.blockers)?o.blockers:[])fe(t,D(i)?.id);for(let i of Array.isArray(o?.unblocks)?o.unblocks:[])fe(t,i)}}function L_(e,t){for(let n of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])oc(t,e[n]);for(let n of Array.isArray(e.blockers)?e.blockers:[])fe(t,D(n)?.blocked_by);F_(e,t)}function F_(e,t){for(let o of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=D(o);fe(t,i?.id),oc(t,i?.children)}for(let o of["files","workload"])for(let i of Array.isArray(e[o])?e[o]:[])nc(t,D(i)?.items);let n=D(e.agenda);for(let o of Array.isArray(n?.events)?n.events:[])fe(t,D(o)?.item_id);let r=D(e.tests);nc(t,r?.items_failing)}function U_(e,t){let n=D(e);if(n===null||rc(e))return[];let r=new Set;return t==="next"?j_(n,r):L_(n,r),[...r]}async function OO(e){let t=M_(e.result);if(t===null)return!1;let n=rc(e.result);return await z_({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:U_(e.result,t.surface),resultOmitted:n}),!0}async function SO(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 x("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 x("Context usage serving requires unique normalized row ids");let n=t.slice(0,te.max_serving_rows),r={serve_id:P_(),author:e.author.trim(),surface:e.surface,rows:t,recorded_item_ids:n.map(o=>o.id)};return r.storage=await Ct(e,[{kind:"serve",schema_version:2,serve_id:r.serve_id,at:Re(e).iso,author:e.author.trim(),surface:e.surface,profile:e.profile.trim()||"balanced",rows:n,candidate_count:t.length,omitted_row_count:t.length-n.length,result_omitted:!1,packed_item_ids:n.filter(o=>o.included).map(o=>o.id)}]),r}async function z_(e){if(e.receipt===null||process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return;let t=new Set(e.receipt.rows.map(i=>i.id)),n=[...new Set(e.deliveredItemIds.map(i=>i.trim()))];if(n.some(i=>i.length===0||!t.has(i))||e.resultOmitted&&n.length>0)throw new x("Context usage delivery requires emitted ranked ids and zero ids for an omitted result");let r=new Set(e.receipt.recorded_item_ids??e.receipt.rows.map(i=>i.id)),o={kind:"delivery",schema_version:2,serve_id:e.receipt.serve_id,at:Re(e).iso,author:e.receipt.author,surface:e.receipt.surface,result_omitted:e.resultOmitted,delivered_item_ids:n.filter(i=>r.has(i))};await Ct(e,[o],o.serve_id)}async function AO(e){if(!(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)){if(!e.author.trim()||!e.itemId.trim()||!e.intent.trim())throw new x("Context usage touch requires author, itemId, and intent");await Ct(e,[{kind:"touch",at:Re(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function CO(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1||e.itemIds.length===0)return;let t=e.author.trim(),n=e.intent.trim();if(!t||!n)throw new x("Context usage touch requires author and intent");let r=new Set;for(let s of e.itemIds){if(typeof s!="string")throw new x("Context usage touch requires string itemIds");let a=s.trim();if(!a)throw new x("Context usage touch requires non-empty itemId");r.add(a)}let o=Re(e).iso,i=[...r].map(s=>({kind:"touch",at:o,author:t,item_id:s,intent:n}));await Ct(e,i)}function q_(e,t,n,r){return e.find(({entry:o,time:i})=>o.item_id===t&&i>=n&&i-n<=r)?.time}function B_(e,t){let n=new Map;for(let r of e)r.kind==="delivery"&&r.schema_version===2&&r.author===t&&!n.has(r.serve_id)&&n.set(r.serve_id,r);return n}async function TO(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 Rn(e),n=Re(e).ms,r=(e.horizonHours??24)*36e5;if(![Number.isFinite(r),r>0].every(Boolean))throw new x("Context usage horizonHours must be positive");let o=e.author.trim(),i=t.filter(u=>u.kind==="touch").filter(u=>u.author===o).map(u=>({entry:u,time:Date.parse(u.at)})),s=new Map,a=0,c=0,d=0,l=B_(t,o);t.filter(u=>u.kind==="serve").filter(u=>u.author===o).forEach(u=>{if(![u.schema_version===2,!!u.serve_id].every(Boolean)){c+=1;return}a+=1;let m=Date.parse(u.at),p=l.get(u.serve_id),_=new Set(p?.delivered_item_ids??[]);for(let g of u.rows){if(!_.has(g.id))continue;let b=q_(i,g.id,m,r);if(b===void 0)continue;d+=1;let w=Math.max(0,(n-b)/$_);s.set(g.id,(s.get(g.id)??0)+Math.exp(-w/14))}});let f=Math.max(0,...s.values());return{affinity:Object.fromEntries([...s.entries()].map(([u,m])=>[u,f===0?.05:.05+.95*m/f])),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]="b9a7ec77-c0da-589a-823e-dc1acae42797")}catch{}})();var G_="limit_overridden_by_intent",lc=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"}]),uc=new V_;function W_(){return uc.getStore()??lc}function zO(e,t){return uc.run(H_(e.workspaceContracts,e.packageContracts),t)}function K_(e,t){let n=e.command.trim().toLowerCase(),r=e.intent.trim().toLowerCase(),o=`${n}:${r}`;if(!/^[a-z0-9][a-z0-9-]*$/.test(n)||!/^[a-z0-9][a-z0-9-]*$/.test(r))throw new TypeError(`Invalid context intent command or name: ${o}`);if(e.description.trim().length===0)throw new TypeError(`Context intent ${o} requires a non-empty description`);if(!Number.isSafeInteger(e.token_budget)||e.token_budget<=0)throw new TypeError(`Context intent ${o} requires a positive integer token_budget`);let i=[...new Set(e.included_field_groups.map(s=>s.trim()).filter(Boolean))];if(i.length===0)throw new TypeError(`Context intent ${o} requires included_field_groups`);return{command:n,intent:r,description:e.description.trim(),included_field_groups:i,token_budget:e.token_budget,source:t}}function H_(e=[],t=[]){let n=[{source:"core",contracts:lc,allowOverride:!1},{source:"package",contracts:t,allowOverride:!1},{source:"workspace",contracts:e,allowOverride:!0}],r=new Map,o=new Set;for(let i of n){o.clear();for(let s of i.contracts){let a=K_(s,i.source),c=`${a.command}:${a.intent}`;if(o.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);if(o.add(c),!i.allowOverride&&r.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);r.set(c,a)}}return[...r.values()].sort((i,s)=>i.command.localeCompare(s.command)||i.intent.localeCompare(s.intent))}function fc(e,t,n=W_(),r=[]){let o=e.trim().toLowerCase(),i=t.trim().toLowerCase(),s=n.find(u=>u.command===o&&u.intent===i);if(s)return{...s,source:s.source??"core"};let a=n.filter(u=>u.command===o).map(u=>u.intent);if(a.length===0)return;let c=a.map(u=>{let m=Array.from({length:i.length+1},(p,_)=>_);for(let p=1;p<=u.length;p+=1){let _=m[0];m[0]=p;for(let g=1;g<=i.length;g+=1){let b=m[g];m[g]=Math.min(m[g]+1,m[g-1]+1,_+(u[p-1]===i[g-1]?0:1)),_=b}}return{candidate:u,distance:m[i.length]}}).sort((u,m)=>u.distance-m.distance||u.candidate.localeCompare(m.candidate))[0].candidate,d=[o,...r,"--for",i],l=[o,...r,"--for",c],f=pn(l);throw new h(`Unknown context intent "${i}" for ${o}. Did you mean "${c}"?`,y.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:i,required:`Use a declared ${o} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[f],recovery:{recovery_mode:"compact",attempted_command:pn(d),allowed_values:[...a].sort(),suggested_retry:f,suggested_retry_args:l}})}function lo(e,t){let n=Ne(e.limit),r=String(n===void 0?t:Math.min(n,t));return(e.limit===void 0||n!==void 0)&&(e.limit=r),r}var mc={context:(e,t,n,r)=>{e.section===void 0&&e.depth===void 0&&(e.section=t.intent==="handoff"?["activity","progress","blockers"]:["hierarchy","blockers","activity"]),e.depth===void 0&&(e.depth=t.intent==="handoff"?"deep":"standard");let o=Dn(r,e.tokenBudget,t.token_budget),i=Pn("context",t.intent,o,n),s=lo(e,i);e.activityLimit===void 0&&(e.activityLimit=s)},get:e=>{e.depth===void 0&&e.fields===void 0&&(e.depth="standard")},list:(e,t,n,r)=>{e.brief===void 0&&e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");let o=Dn(r,e.tokenBudget,t.token_budget),i=Pn("list",t.intent,o,n);lo(e,i)},next:e=>{e.readyOnly===void 0&&(e.readyOnly=!0)},search:(e,t,n,r)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let o=Dn(r,e.tokenBudget,t.token_budget),i=Pn("search",t.intent,o,n);lo(e,i)}};function qO(e,t,n=[]){let r=t.tokenBudget??t.token_budget;if(typeof t.for!="string"){if(r!==void 0&&(e==="get"||e==="list"||e==="search"))throw new h("--token-budget requires a declared context intent selected with --for",y.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(t.tokenBudget!==void 0||t.token_budget===void 0)return t;let c={...t,tokenBudget:r};return delete c.token_budget,c}let o=fc(e,t.for,void 0,n),i=It(t),s=Ne(r)!==void 0||typeof i=="number",a={...t};return a.tokenBudget===void 0&&r!==void 0&&(a.tokenBudget=r),delete a.token_budget,typeof i=="number"?a.tokenBudget=String(i):a.tokenBudget===void 0&&(a.tokenBudget=String(o.token_budget)),mc[e](a,o,s,i),a}var Y_={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},Nn=256;function fo(e){return Array.isArray(e)?e.map(fo):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,fo(n)])):typeof e=="string"&&e.length>240?`${V(e,240)}\u2026`:e}function Ne(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 It(e){let t=e.outputBudget??e.output_budget;return t==="unbounded"?t:Ne(t)}function X_(e){return It(e)===void 0?"--token-budget":"--output-budget"}function Dn(e,t,n){return typeof e=="number"?e:J_(t,n)}function J_(e,t){let n=Ne(e);if(n===void 0)return t;if(n<Nn)throw new h(`Context intent token budget must be at least ${Nn}`,y.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(e),required:`Use an integer token budget of at least ${Nn}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${Nn} or omit the override.`]});return n}function pc(e,t){return e==="context"?e==="context"&&t==="orient"?{overhead:1200,rowCost:600}:{overhead:800,rowCost:500}:{overhead:e==="list"?520:480,rowCost:16}}function Pn(e,t,n,r){if(e==="get"||e==="next")return;let{overhead:o,rowCost:i}=pc(e,t),s=Math.max(e==="context"?1:2,Math.floor((n-o)/i));return r?s:Math.min(e==="context"?20:100,s)}function De(e,t,n){let r=Ze(n),o=n.outputRowContract===!0||n.output_row_contract===!0,i=t.estimated_tokens,s=i;for(let a=0;a<_o;a+=1){t.estimated_tokens=i;let c=pe(o||!Object.hasOwn(e,"row_contract")?e:Object.fromEntries(Object.entries(e).filter(([d])=>d!=="row_contract")),r);if(c===i)return;i=c,s=Math.max(s,i)}t.estimated_tokens=s}var ic={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 _c(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 Q_(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 Z_(e,t,n,r){let o=!1;for(;;){if(De(e,t,r),t.estimated_tokens<=t.token_budget||n.length<=1)return o;let i=Buffer.byteLength(JSON.stringify(n),"utf8"),s=(t.estimated_tokens-t.token_budget)*4;n.splice(-Math.min(n.length-1,Math.max(1,Math.ceil(s/Math.max(1,Math.ceil(i/n.length)))))),o=!0}}function eg(e,t,n){let r=e.items,o=typeof e.next_cursor=="string",i=o?e.next_cursor:n.after;if(!Array.isArray(r)||typeof i!="string")return!1;let s=_c(i);if(s===void 0)return!1;let a=r.length,c=[...r],d=!1;for(;;){if(d=Z_(e,t,r,n)||d,!d)return!1;let l=Q_(r.at(-1));if(l===void 0)return r.splice(0,r.length,...c),De(e,t,n),!1;if(e.next_cursor=St(s.fingerprint,l,o?s.after_index-(a-r.length):s.after_index+r.length,s.snapshot),De(e,t,n),t.estimated_tokens<=t.token_budget||r.length<=1)break}return typeof e.count=="number"&&(e.count=r.length),typeof e.applied_limit=="number"&&(e.applied_limit=r.length),!0}function tg(e,t,n,r){if(e==="list"||e==="search")return eg(t,n,r);if(e!=="next"||typeof t.next_cursor=="string")return!1;let o=!1;for(;;){if(De(t,n,r),n.estimated_tokens<=n.token_budget)return o;let i=ic[e].map(u=>({key:u,rows:Array.isArray(t[u])?t[u]:[]})).filter(({rows:u})=>u.length>0).sort((u,m)=>m.rows.length-u.rows.length||u.key.localeCompare(m.key))[0];if(i===void 0)return o;let s=ic[e].reduce((u,m)=>u+(Array.isArray(t[m])?t[m].length:0),0);if(s<=1)return o;let a=Math.min(i.rows.length,s-1),c=Buffer.byteLength(JSON.stringify(i.rows),"utf8"),d=Math.max(1,Math.ceil(c/i.rows.length)),l=(n.estimated_tokens-n.token_budget)*4,f=Math.min(a,Math.max(1,Math.ceil(l/d)));i.rows.splice(-f,f),o=!0}}function sc(e,t,n){if(typeof t.for!="string")return n;let r=e.startsWith("list-")?"list":e;if(!(r in mc))return n;let o=r,i=fc(o,t.for),s=It(t),a=Dn(s,t.tokenBudget??t.token_budget,i.token_budget),c={command:o,intent:i.intent,source:i.source,included_field_groups:[...i.included_field_groups],token_budget:a,declared_token_budget:i.token_budget,token_budget_override:a-i.token_budget,estimated_tokens:0,within_budget:!0,degradation:Y_[o],declaration_feasible:!0,result_omitted:!1},d={...n},l=Pn(o,i.intent,c.token_budget,Ne(t.tokenBudget??t.token_budget)!==void 0||typeof s=="number");if(l!==void 0){let _=Ne(t.limit),g=_!==void 0&&_<l;c.budget_derived_limit=l,c.binding_constraint=g?"explicit_limit":"token_budget",c.limit_reason=g?"The caller supplied a smaller row limit than the budget-derived ceiling.":"The selected intent token budget constrains the effective row ceiling.",d.budget_derived_limit=l,ag({builtInCommand:o,intent:i.intent},c,d,t)}let f=gc.get(t)??0,u=c.token_budget;c.token_budget=u-f;let m=s==="unbounded"?mo(d,c,t):ng(o,d,c,t);c.declaration_feasible=c.estimated_tokens<=c.declared_token_budget;let p=yc(s,c,m,()=>bc(e,o,i.intent,{...c,token_budget:u,estimated_tokens:c.estimated_tokens+f},d,t));return c.result_omitted&&(c.estimated_tokens+=f,c.declaration_feasible=c.estimated_tokens<=c.declared_token_budget),c.token_budget=u,p}function mo(e,t,n){let r={...e,context_intent:t};return De(r,t,n),r}function ng(e,t,n,r){let o=mo(t,n,r);return n.estimated_tokens>n.token_budget&&(n.degradation="recursive_budget_compaction",o=mo(fo(t),n,r)),n.estimated_tokens>n.token_budget&&tg(e,o,n,r)&&(n.degradation="budget_row_compaction",De(o,n,r)),o}var gc=new WeakMap;function yc(e,t,n,r){return t.estimated_tokens<=t.token_budget||(t.within_budget=!1,e==="unbounded")?n:(t.degradation="budget_receipt_only",t.result_omitted=!0,typeof e=="number"?{output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},context_intent:t}:{budget_exceeded:{omitted_result:!0,reason:t.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:r()},context_intent:t})}var rg=["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"];function og(e,t){if(typeof e.after!="string"||e.after.length===0||Qe(t))return t;let n=_c(e.after)?.fingerprint??"opaque_cursor",r={...t};for(let o of rg)delete r[o];return r.continuation_contract={fingerprint:n,metadata:"reference",restore_with:"omit --after"},r}function me(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ig(e,t){let n=e==="get"&&me(t.item)&&typeof t.item.id=="string"?t.item.id:e==="search"&&typeof t.query=="string"?t.query:void 0;return n===void 0?"":` ${hc(n)}`}function hc(e){return`'${e.replaceAll("'",`'"'"'`)}'`}function sg(e){return typeof e.fields=="string"&&e.fields.trim()!==""?` --fields ${hc(e.fields)}`:""}function ag(e,t,n,r){let o=Ne(r.limit),i=t.budget_derived_limit;if(o===void 0||o<=i)return;let{overhead:s,rowCost:a}=pc(e.builtInCommand,e.intent),c=Math.max(t.token_budget,s+a*o);t.limit_reason=`The ${t.token_budget}-token ${e.intent} budget carries ${i} rows, so it reduced the caller's --limit ${o}.`,t.limit_override={flag:"--limit",requested:o,effective:i,...Number.isSafeInteger(c)?{token_budget_for_requested:c,restore_with:`${X_(r)} ${c}`}:{}};let d=`${G_}:--limit ${o}->${i}`;n.warnings=Array.isArray(n.warnings)?[...n.warnings,d]:[d],me(n.filters)&&(n.filters={...n.filters,requested_limit:String(o)})}function bc(e,t,n,r,o,i){let s=ig(t,o),a=t==="get"?"":` --limit ${r.budget_derived_limit??1}`,{output_budget:c}=Rt({effective_budget_tokens:r.token_budget,measured_result_tokens:r.estimated_tokens});return`pm ${e}${s}${sg(i)} --for ${n} --token-budget ${c}${a}`}function xe(e,t){if(me(e))return typeof e[t]=="number"?e[t]:void 0}function ac(e,t){let n=e;for(let r=0;r<8;r+=1){cg(n);let o=xe(n.context_intent,"estimated_tokens"),i=xe(n.read_output,"estimated_tokens"),s=xe(n.read_session,"spent_this_call_tokens");if(me(n.context_intent)&&n.context_intent.result_omitted!==!0&&De(n,n.context_intent,t),n=po(n,t),xe(n.context_intent,"estimated_tokens")===o&&xe(n.read_output,"estimated_tokens")===i&&xe(n.read_session,"spent_this_call_tokens")===s)break}return n}function cg(e){let t=e.context_intent;me(t)&&Number(t.estimated_tokens)>Number(t.token_budget)&&(t.within_budget=!1)}function dg(e,t,n){let r=ra(e,oa(e??"",n));if(typeof r!="object"||r===null||Array.isArray(r))return Tt(n,r),r;let o=e??"",i=r,s=sc(o,t,i),a=xe(s.context_intent,"estimated_tokens"),c=uo(o,t,n,s),d=cc(t,c,s.context_intent);if(d===void 0)return c;let l={...t};gc.set(l,d.estimated-Number(a));let f=sc(o,l,i),u=uo(o,l,n,f),m=cc(t,u,f.context_intent);if(m===void 0)return u;let p={...m.receipt,estimated_tokens:m.estimated};return uo(o,t,n,yc(It(t),p,u,()=>bc(o,p.command,p.intent,p,i,t)))}function cc(e,t,n){let r=me(t.context_intent),o=r?t.context_intent:n;if(!me(o)||o.result_omitted===!0||Object.hasOwn(t,"output_budget_exceeded"))return;let i=o,s=r?i.estimated_tokens:pe(t,Ze(e));return It(e)==="unbounded"||s<=i.token_budget?void 0:{receipt:i,estimated:s}}function uo(e,t,n,r){let o=dc(e,{...t,outputRowContract:t.outputRowContract===!0||t.output_row_contract===!0},og(t,r));if(Tt(n,o),t.outputRowContract===!0||t.output_row_contract===!0||!Object.hasOwn(o,"row_contract"))return me(o.context_intent)?ac(o,t):o;let i=Object.fromEntries(Object.entries(o).filter(([a])=>a!=="row_contract"));Object.defineProperty(i,"row_contract",{value:o.row_contract,enumerable:!1,configurable:!0});let s=ac(i,t);return delete s.row_contract,Tt(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 et=["result_rows","envelope","diagnostics","hints"],lg=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,ug=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,fg=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,mg=8;function go(e){return Buffer.byteLength(e,"utf8")}function wc(e){return go(JSON.stringify(e)??"null")}function pg(e,t){return ug.test(e)?"diagnostics":fg.test(e)?"hints":lg.test(e)||Array.isArray(t)?"result_rows":"envelope"}function _g(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"]=wc(e),t;for(let[n,r]of Object.entries(e))t[pg(n,r)]+=wc({[n]:r});return Object.values(t).every(n=>n===0)&&(t.envelope=1),t}function gg(e,t){let n=et.reduce((s,a)=>s+t[a],0),r=et.map(s=>({section:s,value:e*t[s]/n})),o={result_rows:0,envelope:0,diagnostics:0,hints:0};for(let s of r)o[s.section]=Math.floor(s.value);let i=e-et.reduce((s,a)=>s+o[a],0);for(let s of[...r].sort((a,c)=>c.value-Math.floor(c.value)-(a.value-Math.floor(a.value))||et.indexOf(a.section)-et.indexOf(c.section))){if(i===0)break;o[s.section]+=1,i-=1}return o}function vc(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function yg(e,t){let n=go(t(e)),r=gg(n,_g(e)),o=Object.fromEntries(et.map(a=>[a,{bytes:r[a],estimated_tokens:Ae(r[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:n,total_estimated_tokens:Ae(n),sections:o,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=vc(e,i);for(let a=0;a<mg;a+=1){let c=go(t(s))-n;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:Ae(c)},s=vc(e,i)}return s}import{encode as wo}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]="d3d21124-3c8a-5049-803d-00c63c0c2b61")}catch{}})();function Ec(e,t={}){let n=[...new Set(e.flatMap(l=>Object.keys(l)))],r=t.compact?n.filter(l=>e.every(f=>Object.hasOwn(f,l)&&f[l]===null)):[],o=t.compact?n.filter(l=>e.every(f=>{if(!Object.hasOwn(f,l))return!0;let u=f[l];return Array.isArray(u)&&u.every(m=>typeof m=="string"&&m!==""&&!m.includes(";"))})):[],i=new Set(o),s=new Set(r),a=n.filter(l=>!i.has(l)&&e.some(f=>{let u=f[l];return u!==null&&typeof u=="object"})),c=new Set(a),d=[];return{rows:e.map((l,f)=>Object.fromEntries(n.filter(u=>!s.has(u)).map(u=>{if(!Object.hasOwn(l,u))return d.push([f,u]),[u,null];let m=l[u];return i.has(u)?[u,m.join(";")]:[u,c.has(u)?JSON.stringify(m):m]}))),encoding:{json_columns:a,absent:d,...o.length?{list_columns:Object.fromEntries(o.map(l=>[l,";"]))}:{},...r.length?{null_columns:r,null_column_index:r.map(l=>n.indexOf(l))}:{}}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="43d2915b-7301-5e96-89e0-51c8e817789e")}catch{}})();function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var hg=new Set(["brief","compact","fields"]);function kc(e){if(!Y(e))return!1;let t=e.fields;return hg.has(e.mode)&&Object.keys(e).length===2&&Array.isArray(t)&&t.length>0&&t.every(n=>typeof n=="string"&&n.length>0)}function Oc(e,t){return e.every(n=>Y(n)&&Object.keys(n).length===t.fields.length&&t.fields.every(r=>Object.hasOwn(n,r)))}function Sc(e,t){return e.mode==="fields"&&t===0?{projection:e}:{}}function Ac(e,t){return typeof e.has_more=="boolean"&&e.truncated===e.has_more&&e.count===t&&typeof e.total=="number"&&Number.isSafeInteger(e.total)&&(e.has_more?e.total>t&&typeof e.next_cursor=="string"&&e.next_cursor.length>0:e.total===t&&e.next_cursor==null)}function bg(e){return Y(e)&&(e.status==="complete"||e.status==="unchecked")&&e.unreadable_item_count===0&&e.unreadable_directory_count===0}function yo(e,t="full_item_fields"){if(!Y(e)||!Array.isArray(e.omitted_field_groups))return!1;let n=e.omitted_field_groups,r=n[0];return e.has_omissions===!0&&e.omitted_field_group_count===1&&Object.keys(e).length===3&&n.length===1&&Y(r)&&Object.keys(r).length===2&&r.name===t&&r.restore_with==="--full"}function Cc(e){if(!Y(e)||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!kc(e.projection)||!Oc(e.items,e.projection)||!bg(e.completeness)||!Ac(e,e.items.length)||!yo(e.omission_receipt))return e;let{total:t,has_more:n,truncated:r,next_cursor:o,completeness:i,projection:s,now:a,omission_receipt:c,sorting:d,filters:l,...f}=e,u=i.status==="complete"&&!n&&Object.keys(i).length===3,{unreadable_item_count:m,unreadable_directory_count:p,..._}=i;return{...f,...u?{}:{total:t,has_more:n,completeness:_},...n?{next_cursor:o}:{},...Eg(d),...Tc(l,f.applied_limit,s),...Sc(s,e.items.length),details:"--full"}}function wg(e){return Y(e)&&e.sort==="default"&&e.order==="asc"&&Object.keys(e).every(t=>t==="sort"||t==="order"||t==="effective_keys")}function vg(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&(e[1]==="asc"||e[1]==="desc")}function Eg(e){if(!wg(e))return{sorting:e};let t=e.effective_keys;return t===void 0?{}:!Array.isArray(t)||!t.every(vg)?{sorting:e}:{sorting:{effective_keys:t.map(([n,r])=>`${n} ${r}`).join(", ")}}}function kg(e,t){if(typeof e!="string"||t===void 0)return!1;let n=e.split(",").map(r=>r.trim()).filter(Boolean);return n.length===t.fields.length&&n.every((r,o)=>r===t.fields[o])}function Tc(e,t,n){if(!Y(e))return e===void 0?{}:{filters:e};let r=Object.fromEntries(Object.entries(e).filter(([o,i])=>!(o==="limit"&&String(i)===String(t))&&!(o==="fields"&&kg(i,n))&&!(o==="runtime_filters"&&Y(i)&&Object.keys(i).length===0)));return Object.keys(r).length===0?{}:{filters:r}}function Og(e,t){return e.count===t&&!Object.hasOwn(e,"has_more")&&!Object.hasOwn(e,"truncated")&&e.next_cursor==null&&(e.total===void 0||e.total===t)}function Sg(e){if(!Object.hasOwn(e,"projection"))return yo(e.omission_receipt,"projection_metadata")?{}:void 0;let t=e.projection;return kc(t)&&t.mode==="fields"&&Oc(e.items,t)&&typeof e.now=="string"&&yo(e.omission_receipt)?{projection:t}:void 0}function Ic(e){if(!Y(e)||typeof e.query!="string"||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!(Ac(e,e.items.length)||Og(e,e.items.length)))return e;let t=Sg(e);if(t===void 0)return e;let{truncated:n,omission_receipt:r,filters:o,projection:i,now:s,mode_source:a,...c}=e;return{...c,...a==="settings"||t.projection===void 0&&a!==void 0?{mode_source:a}:{},...Tc(o,c.applied_limit,t.projection),...t.projection?Sc(t.projection,e.items.length):{},details:"--full"}}import{isBoxedPrimitive as Ag}from"node:util/types";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b399abd-460a-55a5-9df2-db23537aac0d")}catch{}})();var Rc=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/gu;function JO(e){return e.replaceAll(Rc,"\uFFFD")}function Cg(e,t,n){return n&&/^\d+$/u.test(t)?`${e}[${t}]`:/^[A-Za-z_$][\w$]*$/u.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function ho(e,t,n){if(typeof e=="string"){let r=e.search(Rc);return r<0?void 0:{field:t,index:r}}if(!(e===null||typeof e!="object"||n.has(e))){n.add(e);for(let[r,o]of Object.entries(e)){let i=Cg(t,r,Array.isArray(e)),s=ho(r,`${i} (key)`,n)??ho(o,i,n);if(s)return s}}}function xc(e,t,n){if(e===null||typeof e!="object")return e;if(Ag(e)||typeof e.toJSON=="function")return JSON.parse(JSON.stringify({[t]:e}))[t];if(n.has(e))return n.get(e);let r=Array.isArray(e)?new Array(e.length):{};n.set(e,r);for(let o of Object.keys(e))Object.defineProperty(r,o,{value:xc(e[o],o,n),enumerable:!0,configurable:!0,writable:!0});return r}function bo(e){let t=xc(e,"",new WeakMap),n=ho(t,"$",new WeakSet);return n&&Tg(n),t}function Tg(e){throw new h(`Output field ${e.field} contains an unpaired surrogate code unit at index ${e.index}; structured output requires well-formed Unicode.`,y.USAGE,{code:"text_unpaired_surrogate",field:e.field,required:"Well-formed UTF-16 strings and object keys in both JSON and TOON output.",nextSteps:["Repair the producer's text before returning output; use toWellFormedText from @unbrained/pm-cli/sdk when replacement is intended."]})}function QO(e){bo(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]="d32618bf-cced-5ea6-8741-ca596a643789")}catch{}})();var g0=new Set(Object.values(y)),Rg=new Map([["notes_count","notes"],["tests_count","tests"]]);var Nc=!1;function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function vo(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function xg(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.SUCCESS)}function Ng(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.GENERIC_FAILURE)}function Eo(e){if(e==="stdout"){xg();return}Ng()}function Dc(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function Dg(){Nc||(Nc=!0,process.stdout.on("error",e=>{if(vo(e)){Eo("stdout");return}Dc(e)}),process.stderr.on("error",e=>{if(vo(e)){Eo("stderr");return}Dc(e)}))}function Pg(e,t){Dg();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(n){if(vo(n))return Eo(e),!1;throw n}}function $g(e){return Pg("stderr",e)}function Pc(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function ko(e,t){let n=" ".repeat(t);return e.split(`
14
+ `).flatMap(c=>{try{let d=JSON.parse(c);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await n.close()}}catch{return[]}}function ec(e,t,n){let r=[],o=0;for(let i=e.length-1;i>=0&&r.length<n;i-=1){let s=`${JSON.stringify(e[i])}
15
+ `;if(o+=Buffer.byteLength(s),o>t)break;r.push(s)}return r.reverse().join("")}async function Ct(e,t,n){let r=nc(e),o=Rn.join(e.pmRoot,"runtime","context-usage.jsonl"),i=Math.floor(r.maxBytes*te.retained_byte_fraction),s=Math.min(te.max_event_bytes,i);if(t.some(u=>Buffer.byteLength(`${JSON.stringify(u)}
16
+ `)>s))throw new x("Context usage event exceeds the declared byte ceiling");let a=t.filter(u=>Date.parse(u.at)>=r.cutoff),c=ec(a,i,r.maxEvents),d=performance.now(),l=await Qa(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),f=performance.now()-d;try{await j_(Rn.dirname(o),{recursive:!0});let u=await rc(o,Qe.O_WRONLY|Qe.O_CREAT|Qe.O_APPEND);try{let m=(await u.stat()).size,p=n===void 0?void 0:await xn(e);if(p?.some(w=>w.kind==="delivery"&&w.serve_id===n))return{written_bytes:0,ledger_bytes:m,compacted:!1,lock_wait_ms:f};if(!(e.maxEvents!==void 0||e.retentionDays!==void 0)&&m+Buffer.byteLength(c)<=r.maxBytes)return await u.writeFile(c,"utf8"),{written_bytes:Buffer.byteLength(c),ledger_bytes:m+Buffer.byteLength(c),compacted:!1,lock_wait_ms:f};let _=ec([...p??await xn(e),...a],i,r.maxEvents),g=`${o}.${process.pid}.${M_()}.tmp`,b=await tc(g,"wx",384);try{try{await b.writeFile(_,"utf8")}finally{await b.close()}return await u.close(),u=void 0,await L_(g,o),{written_bytes:Buffer.byteLength(_),ledger_bytes:Buffer.byteLength(_),compacted:!0,lock_wait_ms:f}}finally{await F_(g,{force:!0})}}finally{await u?.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 z_=864e5,Nn=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function xO(e,t){let n=D(e);n!==null&&t!==null&&(n[Nn]=t)}function It(e,t){let n=D(e),r=D(t),o=n?.[Nn];r!==null&&o!==void 0&&(r[Nn]=o)}function q_(e){return D(e)?.[Nn]??null}function ic(e){let t=D(e);for(let n of["read_output","context_intent"])if(D(t?.[n])?.result_omitted===!0)return!0;return!1}function fe(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function sc(e,t){if(Array.isArray(t))for(let n of t)fe(e,D(n)?.id)}function oc(e,t){if(Array.isArray(t))for(let n of t)fe(e,n)}function B_(e,t){let n=D(e.recommended)===null?[]:[e.recommended];for(let r of["ready","decision_needed","gate_needed","containers","blocked","held_by_others"])Array.isArray(e[r])&&n.push(...e[r]);for(let r of n){let o=D(r);fe(t,o?.id);for(let i of Array.isArray(o?.blockers)?o.blockers:[])fe(t,D(i)?.id);for(let i of Array.isArray(o?.unblocks)?o.unblocks:[])fe(t,i)}}function V_(e,t){for(let n of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])sc(t,e[n]);for(let n of Array.isArray(e.blockers)?e.blockers:[])fe(t,D(n)?.blocked_by);G_(e,t)}function G_(e,t){for(let o of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=D(o);fe(t,i?.id),sc(t,i?.children)}for(let o of["files","workload"])for(let i of Array.isArray(e[o])?e[o]:[])oc(t,D(i)?.items);let n=D(e.agenda);for(let o of Array.isArray(n?.events)?n.events:[])fe(t,D(o)?.item_id);let r=D(e.tests);oc(t,r?.items_failing)}function W_(e,t){let n=D(e);if(n===null||ic(e))return[];let r=new Set;return t==="next"?B_(n,r):V_(n,r),[...r]}async function NO(e){let t=q_(e.result);if(t===null)return!1;let n=ic(e.result);return await K_({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:W_(e.result,t.surface),resultOmitted:n}),!0}async function DO(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 x("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 x("Context usage serving requires unique normalized row ids");let n=t.slice(0,te.max_serving_rows),r={serve_id:U_(),author:e.author.trim(),surface:e.surface,rows:t,recorded_item_ids:n.map(o=>o.id)};return r.storage=await Ct(e,[{kind:"serve",schema_version:2,serve_id:r.serve_id,at:xe(e).iso,author:e.author.trim(),surface:e.surface,profile:e.profile.trim()||"balanced",rows:n,candidate_count:t.length,omitted_row_count:t.length-n.length,result_omitted:!1,packed_item_ids:n.filter(o=>o.included).map(o=>o.id)}]),r}async function K_(e){if(e.receipt===null||process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return;let t=new Set(e.receipt.rows.map(i=>i.id)),n=[...new Set(e.deliveredItemIds.map(i=>i.trim()))];if(n.some(i=>i.length===0||!t.has(i))||e.resultOmitted&&n.length>0)throw new x("Context usage delivery requires emitted ranked ids and zero ids for an omitted result");let r=new Set(e.receipt.recorded_item_ids??e.receipt.rows.map(i=>i.id)),o={kind:"delivery",schema_version:2,serve_id:e.receipt.serve_id,at:xe(e).iso,author:e.receipt.author,surface:e.receipt.surface,result_omitted:e.resultOmitted,delivered_item_ids:n.filter(i=>r.has(i))};await Ct(e,[o],o.serve_id)}async function PO(e){if(!(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)){if(!e.author.trim()||!e.itemId.trim()||!e.intent.trim())throw new x("Context usage touch requires author, itemId, and intent");await Ct(e,[{kind:"touch",at:xe(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function $O(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1||e.itemIds.length===0)return;let t=e.author.trim(),n=e.intent.trim();if(!t||!n)throw new x("Context usage touch requires author and intent");let r=new Set;for(let s of e.itemIds){if(typeof s!="string")throw new x("Context usage touch requires string itemIds");let a=s.trim();if(!a)throw new x("Context usage touch requires non-empty itemId");r.add(a)}let o=xe(e).iso,i=[...r].map(s=>({kind:"touch",at:o,author:t,item_id:s,intent:n}));await Ct(e,i)}function H_(e,t,n,r){return e.find(({entry:o,time:i})=>o.item_id===t&&i>=n&&i-n<=r)?.time}function Y_(e,t){let n=new Map;for(let r of e)r.kind==="delivery"&&r.schema_version===2&&r.author===t&&!n.has(r.serve_id)&&n.set(r.serve_id,r);return n}async function MO(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 xn(e),n=xe(e).ms,r=(e.horizonHours??24)*36e5;if(![Number.isFinite(r),r>0].every(Boolean))throw new x("Context usage horizonHours must be positive");let o=e.author.trim(),i=t.filter(u=>u.kind==="touch").filter(u=>u.author===o).map(u=>({entry:u,time:Date.parse(u.at)})),s=new Map,a=0,c=0,d=0,l=Y_(t,o);t.filter(u=>u.kind==="serve").filter(u=>u.author===o).forEach(u=>{if(![u.schema_version===2,!!u.serve_id].every(Boolean)){c+=1;return}a+=1;let m=Date.parse(u.at),p=l.get(u.serve_id),_=new Set(p?.delivered_item_ids??[]);for(let g of u.rows){if(!_.has(g.id))continue;let b=H_(i,g.id,m,r);if(b===void 0)continue;d+=1;let w=Math.max(0,(n-b)/z_);s.set(g.id,(s.get(g.id)??0)+Math.exp(-w/14))}});let f=Math.max(0,...s.values());return{affinity:Object.fromEntries([...s.entries()].map(([u,m])=>[u,f===0?.05:.05+.95*m/f])),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]="b9a7ec77-c0da-589a-823e-dc1acae42797")}catch{}})();var J_="limit_overridden_by_intent",fc=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"}]),mc=new X_;function Q_(){return mc.getStore()??fc}function YO(e,t){return mc.run(eg(e.workspaceContracts,e.packageContracts),t)}function Z_(e,t){let n=e.command.trim().toLowerCase(),r=e.intent.trim().toLowerCase(),o=`${n}:${r}`;if(!/^[a-z0-9][a-z0-9-]*$/.test(n)||!/^[a-z0-9][a-z0-9-]*$/.test(r))throw new TypeError(`Invalid context intent command or name: ${o}`);if(e.description.trim().length===0)throw new TypeError(`Context intent ${o} requires a non-empty description`);if(!Number.isSafeInteger(e.token_budget)||e.token_budget<=0)throw new TypeError(`Context intent ${o} requires a positive integer token_budget`);let i=[...new Set(e.included_field_groups.map(s=>s.trim()).filter(Boolean))];if(i.length===0)throw new TypeError(`Context intent ${o} requires included_field_groups`);return{command:n,intent:r,description:e.description.trim(),included_field_groups:i,token_budget:e.token_budget,source:t}}function eg(e=[],t=[]){let n=[{source:"core",contracts:fc,allowOverride:!1},{source:"package",contracts:t,allowOverride:!1},{source:"workspace",contracts:e,allowOverride:!0}],r=new Map,o=new Set;for(let i of n){o.clear();for(let s of i.contracts){let a=Z_(s,i.source),c=`${a.command}:${a.intent}`;if(o.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);if(o.add(c),!i.allowOverride&&r.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);r.set(c,a)}}return[...r.values()].sort((i,s)=>i.command.localeCompare(s.command)||i.intent.localeCompare(s.intent))}function pc(e,t,n=Q_(),r=[]){let o=e.trim().toLowerCase(),i=t.trim().toLowerCase(),s=n.find(u=>u.command===o&&u.intent===i);if(s)return{...s,source:s.source??"core"};let a=n.filter(u=>u.command===o).map(u=>u.intent);if(a.length===0)return;let c=a.map(u=>{let m=Array.from({length:i.length+1},(p,_)=>_);for(let p=1;p<=u.length;p+=1){let _=m[0];m[0]=p;for(let g=1;g<=i.length;g+=1){let b=m[g];m[g]=Math.min(m[g]+1,m[g-1]+1,_+(u[p-1]===i[g-1]?0:1)),_=b}}return{candidate:u,distance:m[i.length]}}).sort((u,m)=>u.distance-m.distance||u.candidate.localeCompare(m.candidate))[0].candidate,d=[o,...r,"--for",i],l=[o,...r,"--for",c],f=_n(l);throw new h(`Unknown context intent "${i}" for ${o}. Did you mean "${c}"?`,y.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:i,required:`Use a declared ${o} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[f],recovery:{recovery_mode:"compact",attempted_command:_n(d),allowed_values:[...a].sort(),suggested_retry:f,suggested_retry_args:l}})}function uo(e,t){let n=De(e.limit),r=String(n===void 0?t:Math.min(n,t));return(e.limit===void 0||n!==void 0)&&(e.limit=r),r}var _c={context:(e,t,n,r)=>{e.section===void 0&&e.depth===void 0&&(e.section=t.intent==="handoff"?["activity","progress","blockers"]:["hierarchy","blockers","activity"]),e.depth===void 0&&(e.depth=t.intent==="handoff"?"deep":"standard");let o=Pn(r,e.tokenBudget,t.token_budget),i=$n("context",t.intent,o,n),s=uo(e,i);e.activityLimit===void 0&&(e.activityLimit=s)},get:e=>{e.depth===void 0&&e.fields===void 0&&(e.depth="standard")},list:(e,t,n,r)=>{e.brief===void 0&&e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");let o=Pn(r,e.tokenBudget,t.token_budget),i=$n("list",t.intent,o,n);uo(e,i)},next:e=>{e.readyOnly===void 0&&(e.readyOnly=!0)},search:(e,t,n,r)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let o=Pn(r,e.tokenBudget,t.token_budget),i=$n("search",t.intent,o,n);uo(e,i)}};function XO(e,t,n=[]){let r=t.tokenBudget??t.token_budget;if(typeof t.for!="string"){if(r!==void 0&&(e==="get"||e==="list"||e==="search"))throw new h("--token-budget requires a declared context intent selected with --for",y.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(t.tokenBudget!==void 0||t.token_budget===void 0)return t;let c={...t,tokenBudget:r};return delete c.token_budget,c}let o=pc(e,t.for,void 0,n),i=Rt(t),s=De(r)!==void 0||typeof i=="number",a={...t};return a.tokenBudget===void 0&&r!==void 0&&(a.tokenBudget=r),delete a.token_budget,typeof i=="number"?a.tokenBudget=String(i):a.tokenBudget===void 0&&(a.tokenBudget=String(o.token_budget)),_c[e](a,o,s,i),a}var tg={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},Dn=256;function mo(e){return Array.isArray(e)?e.map(mo):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,mo(n)])):typeof e=="string"&&e.length>240?`${V(e,240)}\u2026`:e}function De(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 Rt(e){let t=e.outputBudget??e.output_budget;return t==="unbounded"?t:De(t)}function ng(e){return Rt(e)===void 0?"--token-budget":"--output-budget"}function Pn(e,t,n){return typeof e=="number"?e:rg(t,n)}function rg(e,t){let n=De(e);if(n===void 0)return t;if(n<Dn)throw new h(`Context intent token budget must be at least ${Dn}`,y.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(e),required:`Use an integer token budget of at least ${Dn}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${Dn} or omit the override.`]});return n}function gc(e,t){return e==="context"?e==="context"&&t==="orient"?{overhead:1200,rowCost:600}:{overhead:800,rowCost:500}:{overhead:e==="list"?520:480,rowCost:16}}function $n(e,t,n,r){if(e==="get"||e==="next")return;let{overhead:o,rowCost:i}=gc(e,t),s=Math.max(e==="context"?1:2,Math.floor((n-o)/i));return r?s:Math.min(e==="context"?20:100,s)}function Pe(e,t,n){let r=et(n),o=n.outputRowContract===!0||n.output_row_contract===!0,i=t.estimated_tokens,s=i;for(let a=0;a<go;a+=1){t.estimated_tokens=i;let c=pe(o||!Object.hasOwn(e,"row_contract")?e:Object.fromEntries(Object.entries(e).filter(([d])=>d!=="row_contract")),r);if(c===i)return;i=c,s=Math.max(s,i)}t.estimated_tokens=s}var ac={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 yc(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 og(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 ig(e,t,n,r){let o=!1;for(;;){if(Pe(e,t,r),t.estimated_tokens<=t.token_budget||n.length<=1)return o;let i=Buffer.byteLength(JSON.stringify(n),"utf8"),s=(t.estimated_tokens-t.token_budget)*4;n.splice(-Math.min(n.length-1,Math.max(1,Math.ceil(s/Math.max(1,Math.ceil(i/n.length)))))),o=!0}}function sg(e,t,n){let r=e.items,o=typeof e.next_cursor=="string",i=o?e.next_cursor:n.after;if(!Array.isArray(r)||typeof i!="string")return!1;let s=yc(i);if(s===void 0)return!1;let a=r.length,c=[...r],d=!1;for(;;){if(d=ig(e,t,r,n)||d,!d)return!1;let l=og(r.at(-1));if(l===void 0)return r.splice(0,r.length,...c),Pe(e,t,n),!1;if(e.next_cursor=At(s.fingerprint,l,o?s.after_index-(a-r.length):s.after_index+r.length,s.snapshot),Pe(e,t,n),t.estimated_tokens<=t.token_budget||r.length<=1)break}return typeof e.count=="number"&&(e.count=r.length),typeof e.applied_limit=="number"&&(e.applied_limit=r.length),!0}function ag(e,t,n,r){if(e==="list"||e==="search")return sg(t,n,r);if(e!=="next"||typeof t.next_cursor=="string")return!1;let o=!1;for(;;){if(Pe(t,n,r),n.estimated_tokens<=n.token_budget)return o;let i=ac[e].map(u=>({key:u,rows:Array.isArray(t[u])?t[u]:[]})).filter(({rows:u})=>u.length>0).sort((u,m)=>m.rows.length-u.rows.length||u.key.localeCompare(m.key))[0];if(i===void 0)return o;let s=ac[e].reduce((u,m)=>u+(Array.isArray(t[m])?t[m].length:0),0);if(s<=1)return o;let a=Math.min(i.rows.length,s-1),c=Buffer.byteLength(JSON.stringify(i.rows),"utf8"),d=Math.max(1,Math.ceil(c/i.rows.length)),l=(n.estimated_tokens-n.token_budget)*4,f=Math.min(a,Math.max(1,Math.ceil(l/d)));i.rows.splice(-f,f),o=!0}}function cc(e,t,n){if(typeof t.for!="string")return n;let r=e.startsWith("list-")?"list":e;if(!(r in _c))return n;let o=r,i=pc(o,t.for),s=Rt(t),a=Pn(s,t.tokenBudget??t.token_budget,i.token_budget),c={command:o,intent:i.intent,source:i.source,included_field_groups:[...i.included_field_groups],token_budget:a,declared_token_budget:i.token_budget,token_budget_override:a-i.token_budget,estimated_tokens:0,within_budget:!0,degradation:tg[o],declaration_feasible:!0,result_omitted:!1},d={...n},l=$n(o,i.intent,c.token_budget,De(t.tokenBudget??t.token_budget)!==void 0||typeof s=="number");if(l!==void 0){let _=De(t.limit),g=_!==void 0&&_<l;c.budget_derived_limit=l,c.binding_constraint=g?"explicit_limit":"token_budget",c.limit_reason=g?"The caller supplied a smaller row limit than the budget-derived ceiling.":"The selected intent token budget constrains the effective row ceiling.",d.budget_derived_limit=l,mg({builtInCommand:o,intent:i.intent},c,d,t)}let f=hc.get(t)??0,u=c.token_budget;c.token_budget=u-f;let m=s==="unbounded"?po(d,c,t):cg(o,d,c,t);c.declaration_feasible=c.estimated_tokens<=c.declared_token_budget;let p=bc(s,c,m,()=>vc(e,o,i.intent,{...c,token_budget:u,estimated_tokens:c.estimated_tokens+f},d,t));return c.result_omitted&&(c.estimated_tokens+=f,c.declaration_feasible=c.estimated_tokens<=c.declared_token_budget),c.token_budget=u,p}function po(e,t,n){let r={...e,context_intent:t};return Pe(r,t,n),r}function cg(e,t,n,r){let o=po(t,n,r);return n.estimated_tokens>n.token_budget&&(n.degradation="recursive_budget_compaction",o=po(mo(t),n,r)),n.estimated_tokens>n.token_budget&&ag(e,o,n,r)&&(n.degradation="budget_row_compaction",Pe(o,n,r)),o}var hc=new WeakMap;function bc(e,t,n,r){return t.estimated_tokens<=t.token_budget||(t.within_budget=!1,e==="unbounded")?n:(t.degradation="budget_receipt_only",t.result_omitted=!0,typeof e=="number"?{output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},context_intent:t}:{budget_exceeded:{omitted_result:!0,reason:t.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:r()},context_intent:t})}var dg=["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"];function lg(e,t){if(typeof e.after!="string"||e.after.length===0||Ze(t))return t;let n=yc(e.after)?.fingerprint??"opaque_cursor",r={...t};for(let o of dg)delete r[o];return r.continuation_contract={fingerprint:n,metadata:"reference",restore_with:"omit --after"},r}function me(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ug(e,t){let n=e==="get"&&me(t.item)&&typeof t.item.id=="string"?t.item.id:e==="search"&&typeof t.query=="string"?t.query:void 0;return n===void 0?"":` ${wc(n)}`}function wc(e){return`'${e.replaceAll("'",`'"'"'`)}'`}function fg(e){return typeof e.fields=="string"&&e.fields.trim()!==""?` --fields ${wc(e.fields)}`:""}function mg(e,t,n,r){let o=De(r.limit),i=t.budget_derived_limit;if(o===void 0||o<=i)return;let{overhead:s,rowCost:a}=gc(e.builtInCommand,e.intent),c=Math.max(t.token_budget,s+a*o);t.limit_reason=`The ${t.token_budget}-token ${e.intent} budget carries ${i} rows, so it reduced the caller's --limit ${o}.`,t.limit_override={flag:"--limit",requested:o,effective:i,...Number.isSafeInteger(c)?{token_budget_for_requested:c,restore_with:`${ng(r)} ${c}`}:{}};let d=`${J_}:--limit ${o}->${i}`;n.warnings=Array.isArray(n.warnings)?[...n.warnings,d]:[d],me(n.filters)&&(n.filters={...n.filters,requested_limit:String(o)})}function vc(e,t,n,r,o,i){let s=ug(t,o),a=t==="get"?"":` --limit ${r.budget_derived_limit??1}`,{output_budget:c}=xt({effective_budget_tokens:r.token_budget,measured_result_tokens:r.estimated_tokens});return`pm ${e}${s}${fg(i)} --for ${n} --token-budget ${c}${a}`}function Ne(e,t){if(me(e))return typeof e[t]=="number"?e[t]:void 0}function dc(e,t){let n=e;for(let r=0;r<8;r+=1){pg(n);let o=Ne(n.context_intent,"estimated_tokens"),i=Ne(n.read_output,"estimated_tokens"),s=Ne(n.read_session,"spent_this_call_tokens");if(me(n.context_intent)&&n.context_intent.result_omitted!==!0&&Pe(n,n.context_intent,t),n=_o(n,t),Ne(n.context_intent,"estimated_tokens")===o&&Ne(n.read_output,"estimated_tokens")===i&&Ne(n.read_session,"spent_this_call_tokens")===s)break}return n}function pg(e){let t=e.context_intent;me(t)&&Number(t.estimated_tokens)>Number(t.token_budget)&&(t.within_budget=!1)}function _g(e,t,n){let r=ia(e,sa(e??"",n));if(typeof r!="object"||r===null||Array.isArray(r))return It(n,r),r;let o=e??"",i=r,s=cc(o,t,i),a=Ne(s.context_intent,"estimated_tokens"),c=fo(o,t,n,s),d=lc(t,c,s.context_intent);if(d===void 0)return c;let l={...t};hc.set(l,d.estimated-Number(a));let f=cc(o,l,i),u=fo(o,l,n,f),m=lc(t,u,f.context_intent);if(m===void 0)return u;let p={...m.receipt,estimated_tokens:m.estimated};return fo(o,t,n,bc(Rt(t),p,u,()=>vc(o,p.command,p.intent,p,i,t)))}function lc(e,t,n){let r=me(t.context_intent),o=r?t.context_intent:n;if(!me(o)||o.result_omitted===!0||Object.hasOwn(t,"output_budget_exceeded"))return;let i=o,s=r?i.estimated_tokens:pe(t,et(e));return Rt(e)==="unbounded"||s<=i.token_budget?void 0:{receipt:i,estimated:s}}function fo(e,t,n,r){let o=uc(e,{...t,outputRowContract:t.outputRowContract===!0||t.output_row_contract===!0},lg(t,r));if(It(n,o),t.outputRowContract===!0||t.output_row_contract===!0||!Object.hasOwn(o,"row_contract"))return me(o.context_intent)?dc(o,t):o;let i=Object.fromEntries(Object.entries(o).filter(([a])=>a!=="row_contract"));Object.defineProperty(i,"row_contract",{value:o.row_contract,enumerable:!1,configurable:!0});let s=dc(i,t);return delete s.row_contract,It(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 tt=["result_rows","envelope","diagnostics","hints"],gg=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,yg=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,hg=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,bg=8;function yo(e){return Buffer.byteLength(e,"utf8")}function Ec(e){return yo(JSON.stringify(e)??"null")}function wg(e,t){return yg.test(e)?"diagnostics":hg.test(e)?"hints":gg.test(e)||Array.isArray(t)?"result_rows":"envelope"}function vg(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"]=Ec(e),t;for(let[n,r]of Object.entries(e))t[wg(n,r)]+=Ec({[n]:r});return Object.values(t).every(n=>n===0)&&(t.envelope=1),t}function Eg(e,t){let n=tt.reduce((s,a)=>s+t[a],0),r=tt.map(s=>({section:s,value:e*t[s]/n})),o={result_rows:0,envelope:0,diagnostics:0,hints:0};for(let s of r)o[s.section]=Math.floor(s.value);let i=e-tt.reduce((s,a)=>s+o[a],0);for(let s of[...r].sort((a,c)=>c.value-Math.floor(c.value)-(a.value-Math.floor(a.value))||tt.indexOf(a.section)-tt.indexOf(c.section))){if(i===0)break;o[s.section]+=1,i-=1}return o}function kc(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function kg(e,t){let n=yo(t(e)),r=Eg(n,vg(e)),o=Object.fromEntries(tt.map(a=>[a,{bytes:r[a],estimated_tokens:Ae(r[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:n,total_estimated_tokens:Ae(n),sections:o,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=kc(e,i);for(let a=0;a<bg;a+=1){let c=yo(t(s))-n;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:Ae(c)},s=kc(e,i)}return s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="787e6c05-d503-5602-a173-e6a59699cea6")}catch{}})();var e0=Object.freeze({comments:Object.freeze(["comments"]),notes:Object.freeze(["notes"]),learnings:Object.freeze(["learnings"])});(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8e86e884-98ca-5b28-838b-db3543051112")}catch{}})();var Oc=new Set(["body","item_hash","linked","claim_state","children","schedule","blockers"]),n0=new Set(["linked","claim_state","children","schedule"]);import{encode as vo}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]="d3d21124-3c8a-5049-803d-00c63c0c2b61")}catch{}})();function Sc(e,t={}){let n=[...new Set(e.flatMap(l=>Object.keys(l)))],r=t.compact?n.filter(l=>e.every(f=>Object.hasOwn(f,l)&&f[l]===null)):[],o=t.compact?n.filter(l=>e.every(f=>{if(!Object.hasOwn(f,l))return!0;let u=f[l];return Array.isArray(u)&&u.every(m=>typeof m=="string"&&m!==""&&!m.includes(";"))})):[],i=new Set(o),s=new Set(r),a=n.filter(l=>!i.has(l)&&e.some(f=>{let u=f[l];return u!==null&&typeof u=="object"})),c=new Set(a),d=[];return{rows:e.map((l,f)=>Object.fromEntries(n.filter(u=>!s.has(u)).map(u=>{if(!Object.hasOwn(l,u))return d.push([f,u]),[u,null];let m=l[u];return i.has(u)?[u,m.join(";")]:[u,c.has(u)?JSON.stringify(m):m]}))),encoding:{json_columns:a,absent:d,...o.length?{list_columns:Object.fromEntries(o.map(l=>[l,";"]))}:{},...r.length?{null_columns:r,null_column_index:r.map(l=>n.indexOf(l))}:{}}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="43d2915b-7301-5e96-89e0-51c8e817789e")}catch{}})();function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Og=new Set(["brief","compact","fields"]);function Ac(e){if(!Y(e))return!1;let t=e.fields;return Og.has(e.mode)&&Object.keys(e).length===2&&Array.isArray(t)&&t.length>0&&t.every(n=>typeof n=="string"&&n.length>0)}function Tc(e,t){return e.every(n=>Y(n)&&Object.keys(n).length===t.fields.length&&t.fields.every(r=>Object.hasOwn(n,r)))}function Cc(e,t){return e.mode==="fields"&&t===0?{projection:e}:{}}function Ic(e,t){return typeof e.has_more=="boolean"&&e.truncated===e.has_more&&e.count===t&&typeof e.total=="number"&&Number.isSafeInteger(e.total)&&(e.has_more?e.total>t&&typeof e.next_cursor=="string"&&e.next_cursor.length>0:e.total===t&&e.next_cursor==null)}function Sg(e){return Y(e)&&(e.status==="complete"||e.status==="unchecked")&&e.unreadable_item_count===0&&e.unreadable_directory_count===0}function ho(e,t="full_item_fields"){if(!Y(e)||!Array.isArray(e.omitted_field_groups))return!1;let n=e.omitted_field_groups,r=n[0];return e.has_omissions===!0&&e.omitted_field_group_count===1&&Object.keys(e).length===3&&n.length===1&&Y(r)&&Object.keys(r).length===2&&r.name===t&&r.restore_with==="--full"}function Rc(e){if(!Y(e)||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!Ac(e.projection)||!Tc(e.items,e.projection)||!Sg(e.completeness)||!Ic(e,e.items.length)||!ho(e.omission_receipt))return e;let{total:t,has_more:n,truncated:r,next_cursor:o,completeness:i,projection:s,now:a,omission_receipt:c,sorting:d,filters:l,...f}=e,u=i.status==="complete"&&!n&&Object.keys(i).length===3,{unreadable_item_count:m,unreadable_directory_count:p,..._}=i;return{...f,...u?{}:{total:t,has_more:n,completeness:_},...n?{next_cursor:o}:{},...Cg(d),...xc(l,f.applied_limit,s),...Cc(s,e.items.length),details:"--full"}}function Ag(e){return Y(e)&&e.sort==="default"&&e.order==="asc"&&Object.keys(e).every(t=>t==="sort"||t==="order"||t==="effective_keys")}function Tg(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&(e[1]==="asc"||e[1]==="desc")}function Cg(e){if(!Ag(e))return{sorting:e};let t=e.effective_keys;return t===void 0?{}:!Array.isArray(t)||!t.every(Tg)?{sorting:e}:{sorting:{effective_keys:t.map(([n,r])=>`${n} ${r}`).join(", ")}}}function Ig(e,t){if(typeof e!="string"||t===void 0)return!1;let n=e.split(",").map(r=>r.trim()).filter(Boolean);return n.length===t.fields.length&&n.every((r,o)=>r===t.fields[o])}function xc(e,t,n){if(!Y(e))return e===void 0?{}:{filters:e};let r=Object.fromEntries(Object.entries(e).filter(([o,i])=>!(o==="limit"&&String(i)===String(t))&&!(o==="fields"&&Ig(i,n))&&!(o==="runtime_filters"&&Y(i)&&Object.keys(i).length===0)));return Object.keys(r).length===0?{}:{filters:r}}function Rg(e,t){return e.count===t&&!Object.hasOwn(e,"has_more")&&!Object.hasOwn(e,"truncated")&&e.next_cursor==null&&(e.total===void 0||e.total===t)}function xg(e){if(!Object.hasOwn(e,"projection"))return ho(e.omission_receipt,"projection_metadata")?{}:void 0;let t=e.projection;return Ac(t)&&t.mode==="fields"&&Tc(e.items,t)&&typeof e.now=="string"&&ho(e.omission_receipt)?{projection:t}:void 0}function Nc(e){if(!Y(e)||typeof e.query!="string"||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!(Ic(e,e.items.length)||Rg(e,e.items.length)))return e;let t=xg(e);if(t===void 0)return e;let{truncated:n,omission_receipt:r,filters:o,projection:i,now:s,mode_source:a,...c}=e;return{...c,...a==="settings"||t.projection===void 0&&a!==void 0?{mode_source:a}:{},...xc(o,c.applied_limit,t.projection),...t.projection?Cc(t.projection,e.items.length):{},details:"--full"}}import{isBoxedPrimitive as Ng}from"node:util/types";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b399abd-460a-55a5-9df2-db23537aac0d")}catch{}})();var Dc=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/gu;function d0(e){return e.replaceAll(Dc,"\uFFFD")}function Dg(e,t,n){return n&&/^\d+$/u.test(t)?`${e}[${t}]`:/^[A-Za-z_$][\w$]*$/u.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function bo(e,t,n){if(typeof e=="string"){let r=e.search(Dc);return r<0?void 0:{field:t,index:r}}if(!(e===null||typeof e!="object"||n.has(e))){n.add(e);for(let[r,o]of Object.entries(e)){let i=Dg(t,r,Array.isArray(e)),s=bo(r,`${i} (key)`,n)??bo(o,i,n);if(s)return s}}}function Pc(e,t,n){if(e===null||typeof e!="object")return e;if(Ng(e)||typeof e.toJSON=="function")return JSON.parse(JSON.stringify({[t]:e}))[t];if(n.has(e))return n.get(e);let r=Array.isArray(e)?new Array(e.length):{};n.set(e,r);for(let o of Object.keys(e))Object.defineProperty(r,o,{value:Pc(e[o],o,n),enumerable:!0,configurable:!0,writable:!0});return r}function wo(e){let t=Pc(e,"",new WeakMap),n=bo(t,"$",new WeakSet);return n&&Pg(n),t}function Pg(e){throw new h(`Output field ${e.field} contains an unpaired surrogate code unit at index ${e.index}; structured output requires well-formed Unicode.`,y.USAGE,{code:"text_unpaired_surrogate",field:e.field,required:"Well-formed UTF-16 strings and object keys in both JSON and TOON output.",nextSteps:["Repair the producer's text before returning output; use toWellFormedText from @unbrained/pm-cli/sdk when replacement is intended."]})}function l0(e){wo(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]="a378018f-b981-5e5e-98a4-45d190039473")}catch{}})();var x0=new Set(Object.values(y)),Mg=new Map([["notes_count","notes"],["tests_count","tests"]]);var $c=!1;function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Eo(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function jg(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.SUCCESS)}function Lg(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.GENERIC_FAILURE)}function ko(e){if(e==="stdout"){jg();return}Lg()}function Mc(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function Fg(){$c||($c=!0,process.stdout.on("error",e=>{if(Eo(e)){ko("stdout");return}Mc(e)}),process.stderr.on("error",e=>{if(Eo(e)){ko("stderr");return}Mc(e)}))}function Ug(e,t){Fg();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(n){if(Eo(n))return ko(e),!1;throw n}}function zg(e){return Ug("stderr",e)}function jc(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function Oo(e,t){let n=" ".repeat(t);return e.split(`
17
17
  `).map(r=>`${n}${r}`).join(`
18
- `)}function Mg(e){let t=new Set,n=0;for(let r of e){let o=Object.keys(r);n+=o.length;for(let i of o)t.add(i)}return e.length*t.size<=n*2}function jg(e,t,n,r){let o=" ".repeat(n);if(!C(t)&&!Array.isArray(t))return`${o}${e}: ${Pc(t)}`;if(e==="omission_receipt"&&Gg(t))return`${o}${e}: complete`;if(Array.isArray(t)){if(t.length===0)return`${o}${e}: []`;let i=ko(wo({[e]:t}),n);return r&&t.length>=1&&t.every(C)&&Mg(t)?[!1,!0].map(s=>{let a=Ec(t,{compact:s});return ko(wo({[e]:a.rows,[`${e}_encoding`]:a.encoding}),n)}).reduce((s,a)=>Buffer.byteLength(a)<Buffer.byteLength(s)?a:s,i):i}return C(t)&&Object.keys(t).length===0?`${o}${e}: {}`:`${o}${e}:
19
- ${$c(t,n+1)}`}function Lg(e,t,n){let r=e.map(o=>$n(o,t,n||t.preserveRowFacts&&C(o))).filter(o=>o!==void 0);return r.length>0||n?r:void 0}function $n(e,t={omitDuplicateCountAliases:!0,preserveRowFacts:!0},n=!1){if(e===null)return n?null:void 0;if(Array.isArray(e))return Lg(e,t,n);if(C(e)){let r=[],o=Object.entries(e).filter(([i,s])=>{let a=Rg.get(i);return!t.omitDuplicateCountAliases||a===void 0||!C(e.collection_counts)||s!==e.collection_counts[a]});for(let[i,s]of o){if(i==="omitted_field_groups"&&Array.isArray(s)&&s.length===0){r.push([i,[]]);continue}let a=$n(s,t,n);a!==void 0&&r.push([i,a])}return r.length>0||n?Object.fromEntries(r):void 0}return e}function $c(e,t){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":ko(wo(e),t);if(C(e)){let r=Object.entries(e);return r.length===0?"{}":r.map(([o,i])=>jg(o,i,t,!Object.hasOwn(e,`${o}_encoding`)&&!(o==="checks"&&C(e.verdict)&&e.verdict.authority==="ok"))).join(`
20
- `)}return`${n}${Pc(e)}`}var Fg=new Set(["filters","now","projection","sorting"]);function Ug(e){let t=$n(e,{omitDuplicateCountAliases:!1,preserveRowFacts:!1});if(!C(t)||!Array.isArray(t.items))return t??null;let n=Object.fromEntries(Object.entries(t).filter(([r])=>!Fg.has(r)));return n.has_more!==!0&&delete n.next_cursor,n}function zg(e){return!C(e)||e.ok!==!0||!C(e.verdict)||e.verdict.authority!=="ok"||!Array.isArray(e.checks)?e:{...e,checks:e.checks.map(qg)}}function qg(e){if(!C(e)||e.ok!==!0||!C(e.details)||Object.keys(e.details).length!==0)return e;let{details:t,...n}=e;return n}function Mc(e,t,n=!1,r={}){if(e=bo(e),t==="json"){let i=n?Ug(e):e,s=C(e)&&C(e.projection)&&e.projection.mode==="brief"&&Array.isArray(e.items);return`${JSON.stringify(i,null,s?void 0:2)}
21
- `}let o=Bg(e,$n(zg(Ic(Cc(e))),{omitDuplicateCountAliases:!0,preserveRowFacts:!0}),r.preserveEmptyItemCollections===!0);return o===void 0?`{}
22
- `:`${$c(o,0)}
23
- `}function Bg(e,t,n){if(!n||!C(e)||!C(e.item))return t;let r=C(t)?t:{},o=C(r.item)?r.item:{},i=Object.fromEntries(Object.entries(e.item).flatMap(([s,a])=>Object.hasOwn(o,s)?[[s,o[s]]]:Array.isArray(a)&&a.length===0?[[s,[]]]:C(a)&&Object.keys(a).length===0?[[s,{}]]:[]));return Object.hasOwn(r,"item")?{...r,item:i}:{item:i,...r}}var Vg=JSON.stringify({has_omissions:!1,omitted_field_group_count:0,omitted_field_groups:[]});function Gg(e){let t=Object.entries(Object(e)).sort(([n],[r])=>n.localeCompare(r));return JSON.stringify(Object.fromEntries(t))===Vg}function y0(e){let t=Ws("error_format",{message:e}),n=t.handled&&typeof t.result=="string"?t.result:e;$g(n.endsWith(`
18
+ `)}function qg(e){let t=new Set,n=0;for(let r of e){let o=Object.keys(r);n+=o.length;for(let i of o)t.add(i)}return e.length*t.size<=n*2}function Bg(e,t,n,r){let o=" ".repeat(n);if(!S(t)&&!Array.isArray(t))return`${o}${e}: ${jc(t)}`;if(e==="omission_receipt"&&Qg(t))return`${o}${e}: complete`;if(Array.isArray(t)){if(t.length===0)return`${o}${e}: []`;let i=Oo(vo({[e]:t}),n);return r&&t.length>=1&&t.every(S)&&qg(t)?[!1,!0].map(s=>{let a=Sc(t,{compact:s});return Oo(vo({[e]:a.rows,[`${e}_encoding`]:a.encoding}),n)}).reduce((s,a)=>Buffer.byteLength(a)<Buffer.byteLength(s)?a:s,i):i}return S(t)&&Object.keys(t).length===0?`${o}${e}: {}`:`${o}${e}:
19
+ ${Lc(t,n+1)}`}function Vg(e,t,n){let r=e.map(o=>$e(o,t,n||t.preserveRowFacts&&S(o))).filter(o=>o!==void 0);return r.length>0||n?r:void 0}function $e(e,t={omitDuplicateCountAliases:!0,preserveRowFacts:!0},n=!1){if(e===null)return n?null:void 0;if(Array.isArray(e))return Vg(e,t,n);if(S(e)){let r=[],o=Object.entries(e).filter(([i,s])=>{let a=Mg.get(i);return!t.omitDuplicateCountAliases||a===void 0||!S(e.collection_counts)||s!==e.collection_counts[a]});for(let[i,s]of o){if(i==="omitted_field_groups"&&Array.isArray(s)&&s.length===0){r.push([i,[]]);continue}let a=$e(s,t,n);a!==void 0&&r.push([i,a])}return r.length>0||n?Object.fromEntries(r):void 0}return e}function Lc(e,t){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":Oo(vo(e),t);if(S(e)){let r=Object.entries(e);return r.length===0?"{}":r.map(([o,i])=>Bg(o,i,t,!Object.hasOwn(e,`${o}_encoding`)&&!(o==="checks"&&S(e.verdict)&&e.verdict.authority==="ok"))).join(`
20
+ `)}return`${n}${jc(e)}`}var Gg=new Set(["filters","now","projection","sorting"]);function Wg(e){let t=$e(e,{omitDuplicateCountAliases:!1,preserveRowFacts:!1});if(!S(t)||!Array.isArray(t.items))return t??null;let n=Object.fromEntries(Object.entries(t).filter(([r])=>!Gg.has(r)));return n.has_more!==!0&&delete n.next_cursor,n}function Kg(e){return!S(e)||e.ok!==!0||!S(e.verdict)||e.verdict.authority!=="ok"||!Array.isArray(e.checks)?e:{...e,checks:e.checks.map(Hg)}}function Hg(e){if(!S(e)||e.ok!==!0||!S(e.details)||Object.keys(e.details).length!==0)return e;let{details:t,...n}=e;return n}function Fc(e,t,n=!1,r={}){if(e=wo(e),t==="json"){let i=n?Wg(e):e,s=S(e)&&S(e.projection)&&e.projection.mode==="brief"&&Array.isArray(e.items);return`${JSON.stringify(i,null,s?void 0:2)}
21
+ `}let o=Xg(e,Yg(e,$e(Kg(Nc(Rc(e))),Mn),r.preserveEmptyItemCollections===!0),r.positionalRowPaths??[]);return o===void 0?`{}
22
+ `:`${Lc(o,0)}
23
+ `}var Mn={omitDuplicateCountAliases:!0,preserveRowFacts:!0};function So(e,t,n=!1){if(Array.isArray(e)){if(e.length===0)return[];let i=Array.isArray(t)?t:[],s=i.length===e.length,a=0,c=e.flatMap(d=>{let l=n||S(d),f=!s&&$e(d,Mn,l)===void 0,u=So(d,f?void 0:i[a++],l);return u===void 0?[]:[u]});return c.length>0?c:t}if(!S(e))return t;let r=S(t)?t:{},o=Object.entries(e).flatMap(([i,s])=>{let a=So(s,Object.hasOwn(r,i)?r[i]:void 0,n);return a===void 0?[]:[[i,a]]});return o.length>0||Object.keys(e).length===0?Object.fromEntries(o):t}function Yg(e,t,n){if(!n||!S(e))return t;let r=S(t)?t:{},o=new Map(Object.keys(e).filter(i=>i==="item"||Oc.has(i)).map(i=>[i,So(e[i],r[i])]));return Uc(e,r,o)}function Uc(e,t,n){let r=Object.entries(t).map(([i,s])=>[i,n.has(i)?n.get(i):s]),o=Object.keys(e);for(let[i,s]of n){if(Object.hasOwn(t,i)||s===void 0)continue;let a=new Set(o.slice(o.indexOf(i)+1)),c=r.findIndex(([d])=>a.has(d));r.splice(c===-1?r.length:c,0,[i,s])}return Object.fromEntries(r)}function Xg(e,t,n){if(!S(e))return t;let r=n.filter(s=>{let a=e[s];return Array.isArray(a)&&a.some(c=>$e(c,Mn,S(c))===void 0)});if(r.length===0)return t;let o=S(t)?t:{},i=new Map(r.map(s=>[s,e[s].map(a=>$e(a,Mn,!0))]));return Uc(e,o,i)}var Jg=JSON.stringify({has_omissions:!1,omitted_field_group_count:0,omitted_field_groups:[]});function Qg(e){let t=Object.entries(Object(e)).sort(([n],[r])=>n.localeCompare(r));return JSON.stringify(Object.fromEntries(t))===Jg}function N0(e){let t=Hs("error_format",{message:e}),n=t.handled&&typeof t.result=="string"?t.result:e;zg(n.endsWith(`
24
24
  `)?n:`${n}
25
- `)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cc4233e3-6eda-535f-a31b-e4c7b2d29404")}catch{}})();var _o=8,Wg=64,Kg=5,Hg=4,jc=100;function Lc(e,t,n){if(e!=="get"||!Oo(n.item)||["fields","outputInclude","output_include","outputCursor","output_cursor"].some(c=>t[c]!==void 0)||t.full===!0||t.tree===!0||t.depth!==void 0&&t.depth!=="standard")return;let r=n.item,o=["linked","claim_state","schedule"],i=o.filter(c=>Object.hasOwn(n,c)),s=Object.fromEntries(Object.entries(n).filter(([c])=>!o.includes(c)));s.item=Object.fromEntries(Object.entries(r).filter(([c])=>c!=="body")),Object.hasOwn(r,"body")&&i.push("body");let a=[...Oo(n.omission_receipt)&&Array.isArray(n.omission_receipt.omitted_field_groups)?n.omission_receipt.omitted_field_groups:[],...i.map(c=>({name:c,restore_with:`--fields ${c}`}))];return s.omission_receipt={has_omissions:a.length>0,omitted_field_group_count:a.length,omitted_field_groups:a},s}function Rt(e){let t=Math.trunc(e.effective_budget_tokens),n=Math.trunc(e.measured_result_tokens);if(!Number.isSafeInteger(t)||t<=0||!Number.isSafeInteger(n)||n<=0)return{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"};let r=Math.max(t+1,n),o=Math.ceil(r*Kg/Hg),i=Math.ceil(o/jc)*jc;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 tt(e,t,n=!1){let r=Object.getOwnPropertyDescriptor(e,"row_contract");r&&(n||r.enumerable===!1)&&Object.defineProperty(t,"row_contract",{...r,enumerable:!1})}function Ze(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}var xt;function pe(e,t){let n=t===void 0?JSON.stringify(e):xt!==void 0&&xt.format===t?Yg(xt,e):Mc(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function Yg(e,t){xt=void 0;try{return e.render(t)}finally{xt=e}}function Oo(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function So(e,t,n=!1){return typeof e=="string"?n||e.length<=240?e:(t.compacted=!0,`${V(e,240)}\u2026`):Array.isArray(e)?e.map(r=>So(r,t,n)):Oo(e)?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,So(o,t,n||r==="focus_row_states")])):e}function _e(e,t,n){let r=t.estimated_tokens;for(let o=0;o<_o;o+=1){t.estimated_tokens=r;let i=pe(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function Xg(e,t){return wt(e).filter(n=>(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length)>Math.max(1,t.get(n.path)??0)).map(n=>({collection:n,length:Array.isArray(n.value)?n.value.length:Object.keys(n.value).length})).sort((n,r)=>r.length-n.length||n.collection.path.localeCompare(r.collection.path))[0]?.collection}function Jg(e,t,n,r,o,i,s){for(let a=0;a<Wg;a+=1){if(i?.(e),_e(e,t,o),t.estimated_tokens<=n)return;let c=Xg(e,r);if(!c)return;let d=Math.max(1,r.get(c.path)??0),l=Array.isArray(c.value)?[...c.value]:Object.entries(c.value),f=s(c.path),u=g=>{let b=f?l.length-g:0;if(Array.isArray(c.value)){c.value.length=g;for(let w=0;w<g;w+=1)c.value[w]=l[b+w]}else{for(let w of Object.keys(c.value))delete c.value[w];Object.defineProperties(c.value,Object.getOwnPropertyDescriptors(Object.fromEntries(l.slice(b,b+g))))}typeof e.count=="number"&&(e.count=We(e)),typeof e.returned_count=="number"&&(e.returned_count=We(e)),c.path==="items"&&(e.applied_limit=g),i?.(e),_e(e,t,o)};t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],c.path])].sort((g,b)=>g.localeCompare(b)),e.has_more=!0,e.truncated=!0;let m=d,p=l.length-1,_=d;for(;m<=p;){let g=Math.floor((m+p)/2);u(g),t.estimated_tokens<=n?(_=g,m=g+1):p=g-1}u(_)}}function Fc(e,t,n,r=new Map,o,i,s=!1,a=()=>!1){let c={compacted:!1},d=Object.fromEntries(Object.entries(e).map(([l,f])=>[l,So(f,c,s&&l==="diff")]));return tt(e,d),t.strings_compacted=c.compacted,d.read_output=t,Jg(d,t,n,r,o,i,a),_e(d,t,o),d}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="24a8de41-54f9-5b59-8e58-7ac924ba6e08")}catch{}})();function T0(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"&&"context_ref"in e&&typeof e.context_ref=="string"&&e.context_ref.startsWith("session:")&&e.context_ref.endsWith(`:${e.id}`)}var Ao=256,Co=1e4,Qg=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,Uc=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Zg=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),ey=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&Qg.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=Ao,reason:`token_budget must be a safe integer of at least ${Ao}.`},{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<=Co&&e.seen_item_ids.every(t=>typeof t=="string"&&Uc.test(t)),reason:`seen_item_ids must contain at most ${Co} portable item identifiers.`}];function jn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Mn(e){throw new h(`--output-session ${e}`,y.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function Ln(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{Mn("must be a valid JSON object.")}jn(t)||Mn("must be a JSON object.");let n=Object.keys(t).filter(i=>!Zg.has(i));n.length>0&&Mn(`contains unknown field "${n.sort()[0]}".`);let r=ey.find(i=>!i.valid(t));r!==void 0&&Mn(r.reason);let o=[...new Set(t.seen_item_ids)].sort();return{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:o}}function zc(e){if(jn(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:jn(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function ty(e){let t=new Set,n=0,r=le(e),o=new Set(r.map(({path:s})=>s)),i=Object.entries(e).flatMap(([s,a])=>Array.isArray(a)&&!o.has(s)?[{path:s,value:a}]:[]);for(let s of[...r,...i]){let a=Array.isArray(s.value)?s.value:Object.values(s.value);for(let c of a){if(!jn(c))continue;if(typeof c.context_ref=="string"){n+=1;continue}let d=zc(c);d!==void 0&&Uc.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:n}}function qc(e,t){let n=new Set(t.seen_item_ids);return vt(e,r=>{let o=zc(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function To(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=ty(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,Co-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),d=s.length-a.length,l={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:r.size,...d===0?{}:{seen_item_overflow_count:d},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --depth brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:c}},f={...e,read_session:l},u=_=>{l.spent_this_call_tokens=_,l.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,_),l.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+l.charged_this_call_tokens),l.remaining_tokens=Math.max(0,t.token_budget-l.spent_total_tokens),l.exhausted=l.remaining_tokens<Ao,l.next_state.spent_tokens=l.spent_total_tokens},m=0,p=0;for(let _=0;_<8;_+=1){u(m);let g=pe(f,n);if(g===m)return f;p=Math.max(p,g),m=g}return u(p),f}function Bc(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 Nt=Symbol.for("pm.readOutputInvocationProvenance");function R0(e,t){return Reflect.set(e,Nt,{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]="3da33507-a551-5aee-9bc5-68b0de2384d5")}catch{}})();var Pe=["include","amount","cost","encoding"],Yc=["canonical","legacy","intent","default"],Pt=Xt,X0=Object.freeze(Pe.map(e=>Pt[e])),J0=Jt;function ny(e,t){let n=un[e];if(n!==void 0)return n;let r=t==="include"?Fr.has(e)?"<csv>":fn(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${Pt[t]} ${r}.`}function Xc(e){let t=Lr[e]??{},n=Object.freeze(Object.fromEntries(Pe.map(r=>[r,Object.freeze({dimension:r,canonical_option:Pt[r],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[r]??[]).map(o=>Object.freeze({flag:o,semantics:un[o]===void 0?"replacement":"behavior_preserving",migration_hint:ny(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:Yc,budget_retention_policy:e==="assurance"?"verdict_priority":Object.hasOwn(B,e)?"ordered_suffix":"ordered_prefix",projection_modes:Object.freeze([...Ur(e).keys()])})}var ry=Object.freeze(be.map(Xc)),oy=new Map(ry.map(e=>[e.command,e]));function He(e,t={}){let n=at(e.trim().toLowerCase()),r=jr(n);return r!==void 0?r.read_output===void 0?void 0:`extension:${r.command}`:ia(n,t)}var iy=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],sy={comments:["add","body","comment","text","stdin","file","edit","delete"],notes:["add","note","text","addJson","stdin","file","edit","delete"],learnings:["add","learning","text","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function ay(e){return iy.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var cy=[{keys:["outputInclude","output_include"],valid:e=>Dt(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||nt(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||nt(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(Ln(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 Q0(e,t){let n=t.outputFormat??t.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new h("--output-format must be toon or json.",y.USAGE);if(!ay(t))return;let r=He(e,t);if(!r)throw new h(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,y.USAGE);if((sy[r]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new h(`Universal output controls cannot be combined with a ${r} mutation.`,y.USAGE);for(let o of cy){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new h(o.message,y.USAGE)}}function Jc(e){let t=He(e);return t?Ur(t):new Map}function dy(e,t,n){let r=Dt(t)??[],o=Jc(e),i=[],s=[],a=n,c=a[Nt],d=new Set(c?.canonical_include_modes??[]),l=new Set(c?.explicit_legacy_aliases??[]);for(let m of r){let p=o.get(m);if(p===void 0){i.push(m);continue}let _=`--${m.replaceAll("_","-")}`;Ro(Io(n,_))&&l.add(_),n[p]=!0,s.push(m),d.add(m)}let f=He(e)==="get"?i.filter(m=>m!=="item"):[],u=f.length>0;return u&&(n.fields=[...new Set([...Dt(n.fields)??[],...f])].join(","),d.add("fields")),(s.length>0||u)&&(a[Nt]={canonical_include_modes:[...d],explicit_legacy_aliases:[...l],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function Z0(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=dy(e,n,t);if(o.length===0)return;let i=r.length>0?r.join(","):void 0;t.outputInclude=i,Object.hasOwn(t,"output_include")&&(t.output_include=i)}function Io(e,t){let n=zr(t);if(Object.hasOwn(e,n))return e[n];let r=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,r))return e[r];if(t==="--no-truncate"&&e.truncate===!1)return!0}function Ro(e){return e!==void 0&&e!==!1&&e!==null}function Dt(e){let t=(Array.isArray(e)?e:[e]).flatMap(n=>typeof n=="string"?n.split(","):[]).map(n=>n.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function nt(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 ly(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=Io(t,o.flag),s={value:i,flag:o.flag};if(Ro(i)&&n(s))return s}}function Vc(e,t){let n=Dt(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:Dt(t.value)??[fn(t.flag)]}}function Gc(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=nt(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;if(t.flag==="--no-truncate"||t.flag==="--unbounded")return{source:"legacy",value:"unbounded"};let r=nt(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function Wc(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=nt(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let r=nt(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function Kc(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 Qc(e,t,n){if(!e)return!1;let r=new Set(e.explicit_legacy_aliases);if(e.cli_invocation_observed===!0||e.sdk_invocation_observed===!0)return!r.has(n);let o=new Set(e.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return t==="include"&&o.has(n)&&!r.has(n)}function uy(e,t,n,r){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||Ro(Io(r,"--no-truncate"))&&!Qc(n,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function fy(e,t){return Pe.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[Pt[n]]:[])}function Zc(e,t){let n=He(e,t);if(!n)return;let r=oy.get(n)??Xc(n),o=t[Nt],i={include:b=>Vc(void 0,b),amount:b=>Gc(void 0,b),cost:b=>Wc(void 0,b),encoding:b=>Kc(void 0,b)},s=Object.fromEntries(Pe.map(b=>[b,ly(r.dimensions[b],t,w=>i[b](w)!==void 0,w=>Qc(o,b,w))])),a=Pe.flatMap(b=>{let w=s[b];return w?[w.flag]:[]}),c=Pe.flatMap(b=>{let w=s[b];return w?[r.dimensions[b].legacy_aliases.find(U=>U.flag===w.flag).migration_hint]:[]}),d=Kc(t.outputFormat??t.output_format,s.encoding),l=Vc(t.outputInclude??t.output_include,s.include),f=Gc(t.outputLimit??t.output_limit,s.amount),u=Wc(t.outputBudget??t.output_budget,s.cost),m=uy(e,s,o,t),p=Xs(e,{generateFallback:!0}),_=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",g=u??(m?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:l,amount:f,cost:g,encoding:d,canonical_options_used:fy({include:l,amount:f,cost:g,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:Yc}}function R(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var xo=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"]),my=["collection_counts","notes_count","tests_count"];function ed(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function py(e){let t=R(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...my.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!xo.has(o)).sort((o,i)=>o.localeCompare(i));return{item:t,itemFields:n,sections:r,valid:[...n,"item",...n.map(o=>`item.${o}`),...r]}}function _y(e,t){let n=py(e),r=t.filter(l=>!n.valid.includes(l));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,y.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:n.itemFields.includes(l)?[l]:[]).filter((l,f,u)=>u.indexOf(l)===f);if(o&&i.length>0)throw new h("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",y.USAGE);let s=new Set(t.filter(l=>n.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>xo.has(l)||s.has(l)));o?a.item=n.item:i.length>0&&(a.item=ed(n.item,i));let c=[...o?[]:i.length>0?n.itemFields.filter(l=>!i.includes(l)).map(l=>({name:`item.${l}`,restore_with:`--output-include item.${l}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(l=>!s.has(l)).map(l=>({name:l,restore_with:`--output-include ${l}`}))],d=[...R(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 Hc(e){let t=0;return vt({...e},n=>(R(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function gy(e,t,n,r){if(Hc(t)===0||Hc(n)>0)return;let o=[...Jc(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${r.join(", ")}. No selector matched any returned row field.${i}`,y.USAGE)}function yy(e,t,n){if(e==="get")return _y(t,n);let r=gn(t),o=n.flatMap(s=>r.flatMap(a=>s.startsWith(`${a}.`)?[s.slice(a.length+1)]:[])),i=n.some(s=>Object.hasOwn(t,s.split(".")[0])&&!r.some(a=>s.startsWith(`${a}.`)));if(r.length>0&&(!i||o.length>0)){let s={...t},a=o.length>0?o:n,c=vt(s,d=>R(d)?ed(d,a):d);return gy(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||xo.has(s)))}function hy(e,t,n,r){if(t==="unbounded")return e;let{result:o,truncated:i}=ha(e,t,s=>Ce(n,s));if(!i)return o;if(o.has_more=!0,o.truncated=!0,od(o,n,[...r.entries()].flatMap(([s,a])=>a.rows>t?[{path:s,total_rows:a.totalRows}]:[])),typeof o.count=="number"){let s=R(o.projection)?o.projection.row_key:void 0;o.count=typeof s=="string"&&Array.isArray(o[s])?o[s].length:We(o)}return typeof o.returned_count=="number"&&(o.returned_count=We(o)),o.applied_bound={kind:"output_limit",source:"explicit",value:t},o}function by(e){return Pe.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(Pt[t]))}function Fn(e,t,n,r){let o=To(e,t,r);tt(e,o);for(let i=0;i<8;i+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;_e(o,n,r);let c=o;o=To(o,t,r),tt(c,o);let d=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&d===a)return o}return o}function po(e,t){if(!R(e.read_output))return e;let n=Ze(t),r=e.read_output,o=Ln(t.outputSession??t.output_session);return o===void 0?(_e(e,r,n),e):Fn(e,o,r,n)}function wy(e,t){if(e!=="validate")return t;let n=R(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(l=>R(l)&&l.name==="diagnostic_rows"))return t;let r=[...new Set(wt(t).map(({path:l})=>l).filter(l=>/^checks\.\d+\.details\./u.test(l)))],o=r.filter(l=>!r.some(f=>f!==l&&l.startsWith(`${f}.`)));if(o.length===0)return t;let i=R(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 vy(e,t){return e.include?.source==="canonical"&&!Qe(t)}function Ey(e,t,n,r,o){let i={...e};if(vy(t,e)&&(i=yy(t.command,i,t.include.value)),t.command==="assurance"&&(i=ka(i)),Et(i,e),i=Oa(i,t.command,r),t.command==="history"&&r){let c=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([d])=>!c.includes(d)||d===r.path)),R(i.projection)&&(i.projection={...i.projection,row_key:r.path}),R(i.row_contract)){let d=i.row_contract;i.row_contract={...d,row_keys:[r.path],...Array.isArray(d.continuation_row_keys)?{continuation_row_keys:[r.path]}:{}}}i.count=Object.keys(i[r.path]).length}let s=e.count_only===!0?{...i,count_only:!0,count:e.count}:i,a=Ry(i,e,t.command,r,o);return t.amount?.source==="canonical"&&(i=hy(i,t.amount.value,t.command,a.collectionsBeforeBudget),a.cursorContinuesExistingPage&&sd(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),Et(i,s),id(i,t.command,a),{projected:n===void 0?i:qc(i,n),continuationState:a}}function ky(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:Bc(t)}]].sort((n,r)=>n.tokens-r.tokens)[0]}function td(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function nd(e,t){return R(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function Oy(e,t,n){return e.command!=="next"||(t.tokenBudget??t.token_budget)===void 0?!1:!(R(n.context_intent)&&n.context_intent.command==="next"&&n.context_intent.within_budget===!0)}function rd(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!nd(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function Sy(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...rd(r),precedence:e.precedence,...td(e),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...n===void 0?{omitted_result_estimated_tokens:o}:{}},a={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:s},c=n===void 0?a:Fn(a,n,s,i);if(n===void 0&&_e(c,s,i),n!==void 0&&s.estimated_tokens>r.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",y.USAGE);return c}function Ay(e,t,n){return e.command==="context"&&e.cost?.source==="legacy"&&!nd(n,e.cost.value)||Oy(e,t,n)||t.outputRowContract===!0||t.output_row_contract===!0||e.canonical_options_used.includes("--output-include")||e.command==="list"&&e.canonical_options_used.length>0&&e.include?.value.includes("full")===!0}function Cy(e,t,n,r,o){if(t!==void 0||Qe(n)||Ay(e,o,n))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(le(n).some(({value:s})=>(Array.isArray(s)?s.length:Object.keys(s).length)>i))return!1}return e.cost===void 0||e.cost.value==="unbounded"||e.cost.source==="legacy"&&e.command!=="context"||pe(o.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,r)<=e.cost.value}function od(e,t,n){let r=Object.hasOwn(B,t)?B[t]:void 0,o=n.find(i=>r?.paths.includes(i.path));r!==void 0&&o!==void 0&&typeof e[r.total_key]!="number"&&(e[r.total_key]=o.total_rows)}function id(e,t,n){let r=B[t]?.paths[0];r!==void 0&&Ea(e,t,n.producer,n.collectionsBeforeBudget.get(r)?.rows)}function Ty(e,t,n,r){let o=n.backward?n.rows-r:n.baseOffset+r;return{path:t,cursor:Wr({command:e,path:t,offset:o,total_rows:n.totalRows,fingerprint:n.fingerprint,...n.backward?{direction:"backward"}:{}}),retained_rows:r,remaining_rows:n.backward?o:n.totalRows-o,total_rows:n.totalRows}}function Iy(e,t,n,r,o,i,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map(Ge(e).map(p=>[p.path,Array.isArray(p.value)?p.value.length:Object.keys(p.value).length])),d=[...s.entries()].flatMap(([p,_])=>{let g=c.get(p);return g>=_.rows?[]:[Ty(t.command,p,_,g)]}),l=d[0];od(e,t.command,d);let f=l?"; page --output-cursor":"",u=r.source==="session"?`Truncated by the remaining ${r.tokens}-token session budget; start a new output session with a larger token_budget${f}.`:`${r.tokens}-token: raise --output-budget${f}`;n.migration_hints=[u,...t.migration_hints];let m=Rt({effective_budget_tokens:r.tokens,measured_result_tokens:i});l&&!o&&(typeof e.next_cursor!="string"||e.continuation_kind==="output_cursor")&&(e.next_cursor=l.cursor),e.continuation_kind=o?"producer_cursor":l?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:r.source,budget_tokens:r.tokens,overridden_dimensions:a,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:o,continuation_available:d.length>0,recovery_budget_multiplier:l?1:m.recovery_budget_multiplier,continuations:d,restore_with:l?"recovery":`Retry with --output-budget ${m.output_budget} because no declared row collection can be continued.`,recovery:l?{cursor:l.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${m.output_budget}`,sdk:{outputBudget:m.output_budget},mcp:{outputBudget:m.output_budget}}}}function sd(e,t,n,r,o){if(typeof n!="string"||!Array.isArray(e.items))return!1;let i=e.items.length,s=t.length;if(i===0||i>=s)return!1;let a;try{a=Yr(n)}catch{return!1}let c=a.after_index;if(c===void 0)return!1;let d=t[i-1];if(Object.prototype.toString.call(d)!=="[object Object]")return!1;let l=Reflect.get(d,"id");if(typeof l!="string"||l.length===0)return!1;let f=r?c-(s-i):c+o+i;return f<0?!1:(e.next_cursor=St(a.fingerprint,l,f,a.snapshot),!0)}function Ry(e,t,n,r,o){let i=new Map(Ge(e).map(c=>{let d=Array.isArray(c.value)?c.value.length:Object.keys(c.value).length,l=r?.path===c.path,f=Ce(n,c.path);return[c.path,{rows:d,totalRows:l?r.total_rows:d,baseOffset:l&&!f?r.offset:0,backward:f,fingerprint:l?r.fingerprint:yn(c.path,c.value,n)}]})),s=typeof e.next_cursor=="string",a=r?.path==="items"?r.offset:0;return{collectionsBeforeBudget:i,originalItems:Array.isArray(t.items)?a>0?t.items.slice(a):t.items:[],originalItemOffset:a,cursorContinuesExistingPage:s,cursorSource:s?e.next_cursor:o.after,producer:t}}function xy(e,t,n,r,o,i,s,a,c,d){let l={...t,count_only:n},f=r.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(m=>R(m)&&m.verdict!=="pass").length:0,u=new Map;if(f>0&&u.set("assertions",f),r.command==="history"&&Array.isArray(e.diff))for(let m of wt(e))m.path.startsWith("diff.")&&u.set(m.path,Object.keys(m.value).length);return Fc(e,o,i.tokens,u,d,m=>{Et(m,l),id(m,r.command,a);let p=sd(m,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(Iy(m,r,o,i,p,c,a.collectionsBeforeBudget),r.command==="history"&&R(m.projection)){m.has_more=typeof m.next_cursor=="string"||m.applied_bound?.kind==="output_limit";let _=m.projection.row_key;typeof _=="string"&&Array.isArray(m[_])&&(m.count=m[_].length)}s!==void 0&&Object.assign(m,Fn(m,s,o,d))},r.command==="history"&&Array.isArray(e.diff),m=>Ce(r.command,m))}function dc(e,t,n){let r=Zc(e,t);if(!r)return n;let o=Ze(t),i=Ln(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?Ot(s):void 0,c=by(r),d=wy(r.command,n);if(a===void 0&&Cy(r,i,d,o,t))return d;let l=ky(r,i),f=Ey(d,r,i,a,t),u=f.projected;tt(u,u,t.outputRowContract===!1);let m=Qe(u),p={contract_version:1,command:r.command,requested_dimensions:c,...rd(l,u),precedence:r.precedence,...td(r),legacy_aliases_used:r.legacy_aliases_used,migration_hints:r.migration_hints,estimated_tokens:0,within_budget:!m,strings_compacted:!1,rows_compacted:!1,result_omitted:m};if(u.read_output=p,u=i===void 0?u:Fn(u,i,p,o),_e(u,p,o),l!==void 0&&p.estimated_tokens>l.tokens){let _=Lc(r.command,t,u);_!==void 0&&(p.applied_depth="brief",p.degradation_reason="output_budget_reached",tt(u,_),u=po(_,t)),p.estimated_tokens>l.tokens&&(u=xy(u,u,d.count_only===!0,r,p,l,i,f.continuationState,p.estimated_tokens,o))}return l!==void 0&&p.estimated_tokens>l.tokens?Sy(r,c,i,l,p.estimated_tokens,o):u}function Ny(e){return R(e)&&R(e.context_intent)&&e.context_intent.result_omitted===!0}function Qe(e){return Dy(e)||Ny(e)}function Dy(e){return R(e)&&R(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function Ig(e,t){let n=t.outputFormat??t.output_format;if(n==="json"||n==="toon")return n;let r=Zc(e,t)?.encoding;return r?.value==="json"||r?.value==="toon"?r.value:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7e894d1f-fe1a-53f2-9a29-4e9846a9f986")}catch{}})();var ad=["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"],cd=["history:author-acknowledge","settings:write","init:type_preset","templates:save","profile:apply-types","profile:apply-statuses","profile:apply-fields","profile:apply-config","schema:add-type","schema:remove-type","schema:add-status","schema:remove-status","schema:add-field","schema:remove-field","schema:apply-preset","schema:infer-types","schema:policy-put","schema:policy-remove","schema:policy-mode","assurance:bundle:apply","assurance:gate:verdict","telemetry:install_id","telemetry:first_run_prompt","telemetry:clear","item_format:auto_select_default","transaction_abandon"],No={"init:type-preset":"init:type_preset"},dd=["^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_]*$"],tS={version:1,item:ad,workspace:cd,aliases:No,patterns:dd,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"]},Py=new Set([...ad,...cd]),$y=dd.map(e=>new RegExp(e,"u"));function ld(e){return Object.hasOwn(No,e)?No[e]:e}function nS(e){let t=ld(e);if(Py.has(t)||$y.some(n=>n.test(t)))return t;throw new TypeError("Undeclared history operation; use a native contract identity or extension:<package_name>:<snake_case_operation>.")}function rS(e){let t=ld(e),n=t.indexOf(":"),r=n<0?t:t.slice(0,n),o=n<0||n<t.length-1&&!/[\s\p{C}]/u.test(t.slice(n+1));if(/^[a-z][a-z0-9]*(?:[_.-][a-z0-9]+)*$/u.test(r)&&o)return t;throw new TypeError("History operation must use lowercase alphanumeric segments with an optional non-whitespace colon-suffixed retry key.")}export{zt as a,gi as b,rr as c,_u as d,gu as e,S as f,ud as g,Mo as h,jy as i,Ly as j,jo as k,Fy as l,Uy as m,zy as n,qy as o,By as p,Vy as q,Gy as r,Wy as s,Ky as t,Hy as u,Yy as v,Xy as w,Jy as x,Qy as y,fd as z,Zy as A,eh as B,th as C,nh as D,rh as E,oh as F,ih as G,ts as H,du as I,Cb as J,ui as K,fi as L,hs as M,bs as N,pd as O,_d as P,Bn as Q,Wn as R,Kn as S,uh as T,fh as U,mh as V,Od as W,Fo as X,ph as Y,dt as Z,ar as _,Kb as $,Cu as aa,Yb as ba,Xb as ca,Jb as da,Ci as ea,Ti as fa,Qb as ga,Zb as ha,ew as ia,tw as ja,qo as ka,Nd as la,Vo as ma,Yo as na,kh as oa,Jn as pa,Vd as qa,Oh as ra,ol as sa,il as ta,Sh as ua,Ah as va,Mh as wa,Zo as xa,ei as ya,ti as za,Jo as Aa,jh as Ba,Lh as Ca,Fh as Da,Zn as Ea,Uh as Fa,ye as Ga,K as Ha,Bh as Ia,Vh as Ja,xl as Ka,ri as La,er as Ma,Pl as Na,$l as Oa,Kt as Pa,ii as Qa,jl as Ra,Ul as Sa,Xh as Ta,Jh as Ua,Vl as Va,Gl as Wa,Wl as Xa,Kl as Ya,tr as Za,Zh as _a,Hl as $a,at as ab,Ht as bb,eb as cb,tb as db,nb as eb,Yl as fb,Xl as gb,Jl as hb,ab as ib,cb as jb,Ql as kb,Yt as lb,db as mb,lb as nb,Zl as ob,eu as pb,tu as qb,ai as rb,je as sb,nu as tb,ub,fb as vb,mb as wb,pb as xb,_b as yb,gb as zb,yb as Ab,hb as Bb,be as Cb,Qt as Db,kb as Eb,nn as Fb,ur as Gb,fr as Hb,mr as Ib,pr as Jb,_r as Kb,gr as Lb,br as Mb,Ji as Nb,en as Ob,Rb as Pb,pi as Qb,xb as Rb,V as Sb,Db as Tb,Pb as Ub,Af as Vb,Tf as Wb,If as Xb,jf as Yb,zv as Zb,qv as _b,Bv as $b,Aa as ac,Hv as bc,nm as cc,yu as dc,or as ec,wu as fc,vu as gc,eE as hc,lm as ic,tE as jc,nE as kc,rE as lc,oE as mc,iE as nc,sE as oc,aE as pc,qs as qc,um as rc,cE as sc,dE as tc,Bs as uc,lE as vc,Vs as wc,uE as xc,fE as yc,mE as zc,dn as Ac,fa as Bc,$E as Cc,ME as Dc,jE as Ec,ma as Fc,pa as Gc,YE as Hc,ga as Ic,pn as Jc,rk as Kc,ok as Lc,mm as Mc,kE as Nc,Hs as Oc,pm as Pc,km as Qc,Sm as Rc,Ys as Sc,Am as Tc,Cm as Uc,Xs as Vc,Ae as Wc,Js as Xc,OE as Yc,SE as Zc,Mr as _c,AE as $c,CE as ad,TE as bd,IE as cd,RE as dd,sk as ed,Et as fd,B as gd,Ce as hd,Nt as id,R0 as jd,Pe as kd,X0 as ld,J0 as md,ry as nd,He as od,Q0 as pd,Jc as qd,dy as rd,Z0 as sd,Zc as td,po as ud,dc as vd,Qe as wd,Dy as xd,Ig as yd,va as zd,yn as Ad,Wr as Bd,Ot as Cd,Ek as Dd,kk as Ed,St as Fd,Yr as Gd,Xr as Hd,Ok as Id,Rp as Jd,Sk as Kd,Ak as Ld,xk as Md,Zr as Nd,jk as Od,Up as Pd,Lk as Qd,Ye as Rd,Fk as Sd,Uk as Td,wn as Ud,no as Vd,ro as Wd,vn as Xd,uO as Yd,w_ as Zd,Tn as _d,A_ as $d,Xa as ae,I_ as be,te as ce,x as de,kO as ee,Tt as fe,U_ as ge,OO as he,SO as ie,z_ as je,AO as ke,CO as le,TO as me,G_ as ne,lc as oe,W_ as pe,zO as qe,H_ as re,fc as se,qO as te,_c as ue,Q_ as ve,sc as we,dg as xe,yg as ye,JO as ze,QO as Ae,$g as Be,Mc as Ce,y0 as De,Rt as Ee,pe as Fe,T0 as Ge,Co as He,Ln as Ie,qc as Je,To as Ke,Bc as Le,ad as Me,cd as Ne,No as Oe,dd as Pe,tS as Qe,ld as Re,nS as Se,rS as Te};
26
- //# sourceMappingURL=chunk-Z2QWZRSL.js.map
25
+ `)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cc4233e3-6eda-535f-a31b-e4c7b2d29404")}catch{}})();var go=8,Zg=64,ey=5,ty=4,zc=100;function qc(e,t,n){if(e!=="get"||!Ao(n.item)||["fields","outputInclude","output_include","outputCursor","output_cursor"].some(c=>t[c]!==void 0)||t.full===!0||t.tree===!0||t.depth!==void 0&&t.depth!=="standard")return;let r=n.item,o=["linked","claim_state","schedule"],i=o.filter(c=>Object.hasOwn(n,c)),s=Object.fromEntries(Object.entries(n).filter(([c])=>!o.includes(c)));s.item=Object.fromEntries(Object.entries(r).filter(([c])=>c!=="body")),Object.hasOwn(r,"body")&&i.push("body");let a=[...Ao(n.omission_receipt)&&Array.isArray(n.omission_receipt.omitted_field_groups)?n.omission_receipt.omitted_field_groups:[],...i.map(c=>({name:c,restore_with:`--fields ${c}`}))];return s.omission_receipt={has_omissions:a.length>0,omitted_field_group_count:a.length,omitted_field_groups:a},s}function xt(e){let t=Math.trunc(e.effective_budget_tokens),n=Math.trunc(e.measured_result_tokens);if(!Number.isSafeInteger(t)||t<=0||!Number.isSafeInteger(n)||n<=0)return{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"};let r=Math.max(t+1,n),o=Math.ceil(r*ey/ty),i=Math.ceil(o/zc)*zc;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 nt(e,t,n=!1){let r=Object.getOwnPropertyDescriptor(e,"row_contract");r&&(n||r.enumerable===!1)&&Object.defineProperty(t,"row_contract",{...r,enumerable:!1})}function et(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}var Nt;function pe(e,t){let n=t===void 0?JSON.stringify(e):Nt!==void 0&&Nt.format===t?ny(Nt,e):Fc(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function ny(e,t){Nt=void 0;try{return e.render(t)}finally{Nt=e}}function Ao(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function To(e,t,n=!1){return typeof e=="string"?n||e.length<=240?e:(t.compacted=!0,`${V(e,240)}\u2026`):Array.isArray(e)?e.map(r=>To(r,t,n)):Ao(e)?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,To(o,t,n||r==="focus_row_states")])):e}function _e(e,t,n){let r=t.estimated_tokens;for(let o=0;o<go;o+=1){t.estimated_tokens=r;let i=pe(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function ry(e,t){return vt(e).filter(n=>(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length)>Math.max(1,t.get(n.path)??0)).map(n=>({collection:n,length:Array.isArray(n.value)?n.value.length:Object.keys(n.value).length})).sort((n,r)=>r.length-n.length||n.collection.path.localeCompare(r.collection.path))[0]?.collection}function oy(e,t,n,r,o,i,s){for(let a=0;a<Zg;a+=1){if(i?.(e),_e(e,t,o),t.estimated_tokens<=n)return;let c=ry(e,r);if(!c)return;let d=Math.max(1,r.get(c.path)??0),l=Array.isArray(c.value)?[...c.value]:Object.entries(c.value),f=s(c.path),u=g=>{let b=f?l.length-g:0;if(Array.isArray(c.value)){c.value.length=g;for(let w=0;w<g;w+=1)c.value[w]=l[b+w]}else{for(let w of Object.keys(c.value))delete c.value[w];Object.defineProperties(c.value,Object.getOwnPropertyDescriptors(Object.fromEntries(l.slice(b,b+g))))}typeof e.count=="number"&&(e.count=He(e)),typeof e.returned_count=="number"&&(e.returned_count=He(e)),c.path==="items"&&(e.applied_limit=g),i?.(e),_e(e,t,o)};t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],c.path])].sort((g,b)=>g.localeCompare(b)),e.has_more=!0,e.truncated=!0;let m=d,p=l.length-1,_=d;for(;m<=p;){let g=Math.floor((m+p)/2);u(g),t.estimated_tokens<=n?(_=g,m=g+1):p=g-1}u(_)}}function Bc(e,t,n,r=new Map,o,i,s=!1,a=()=>!1){let c={compacted:!1},d=Object.fromEntries(Object.entries(e).map(([l,f])=>[l,To(f,c,s&&l==="diff")]));return nt(e,d),t.strings_compacted=c.compacted,d.read_output=t,oy(d,t,n,r,o,i,a),_e(d,t,o),d}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="24a8de41-54f9-5b59-8e58-7ac924ba6e08")}catch{}})();function B0(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"&&"context_ref"in e&&typeof e.context_ref=="string"&&e.context_ref.startsWith("session:")&&e.context_ref.endsWith(`:${e.id}`)}var Co=256,Io=1e4,iy=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,Vc=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,sy=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),ay=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&iy.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=Co,reason:`token_budget must be a safe integer of at least ${Co}.`},{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<=Io&&e.seen_item_ids.every(t=>typeof t=="string"&&Vc.test(t)),reason:`seen_item_ids must contain at most ${Io} portable item identifiers.`}];function Ln(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function jn(e){throw new h(`--output-session ${e}`,y.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function Fn(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{jn("must be a valid JSON object.")}Ln(t)||jn("must be a JSON object.");let n=Object.keys(t).filter(i=>!sy.has(i));n.length>0&&jn(`contains unknown field "${n.sort()[0]}".`);let r=ay.find(i=>!i.valid(t));r!==void 0&&jn(r.reason);let o=[...new Set(t.seen_item_ids)].sort();return{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:o}}function Gc(e){if(Ln(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:Ln(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function cy(e){let t=new Set,n=0,r=le(e),o=new Set(r.map(({path:s})=>s)),i=Object.entries(e).flatMap(([s,a])=>Array.isArray(a)&&!o.has(s)?[{path:s,value:a}]:[]);for(let s of[...r,...i]){let a=Array.isArray(s.value)?s.value:Object.values(s.value);for(let c of a){if(!Ln(c))continue;if(typeof c.context_ref=="string"){n+=1;continue}let d=Gc(c);d!==void 0&&Vc.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:n}}function Wc(e,t){let n=new Set(t.seen_item_ids);return Et(e,r=>{let o=Gc(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function Ro(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=cy(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,Io-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),d=s.length-a.length,l={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:r.size,...d===0?{}:{seen_item_overflow_count:d},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --depth brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:c}},f={...e,read_session:l},u=_=>{l.spent_this_call_tokens=_,l.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,_),l.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+l.charged_this_call_tokens),l.remaining_tokens=Math.max(0,t.token_budget-l.spent_total_tokens),l.exhausted=l.remaining_tokens<Co,l.next_state.spent_tokens=l.spent_total_tokens},m=0,p=0;for(let _=0;_<8;_+=1){u(m);let g=pe(f,n);if(g===m)return f;p=Math.max(p,g),m=g}return u(p),f}function Kc(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 Dt=Symbol.for("pm.readOutputInvocationProvenance");function G0(e,t){return Reflect.set(e,Dt,{canonical_include_modes:[...t],explicit_legacy_aliases:[],sdk_invocation_observed:!0}),e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2a596392-747a-5b55-854d-1e80964468d3")}catch{}})();var Me=["include","amount","cost","encoding"],ed=["canonical","legacy","intent","default"],$t=Jt,uS=Object.freeze(Me.map(e=>$t[e])),fS=Qt;function dy(e,t){let n=fn[e];if(n!==void 0)return n;let r=t==="include"?Ur.has(e)?"<csv>":mn(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${$t[t]} ${r}.`}function td(e){let t=Fr[e]??{},n=Object.freeze(Object.fromEntries(Me.map(r=>[r,Object.freeze({dimension:r,canonical_option:$t[r],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[r]??[]).map(o=>Object.freeze({flag:o,semantics:fn[o]===void 0?"replacement":"behavior_preserving",migration_hint:dy(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:ed,budget_retention_policy:e==="assurance"?"verdict_priority":Object.hasOwn(B,e)?"ordered_suffix":"ordered_prefix",projection_modes:Object.freeze([...zr(e).keys()])})}var ly=Object.freeze(be.map(td)),uy=new Map(ly.map(e=>[e.command,e]));function Ce(e,t={}){let n=ct(e.trim().toLowerCase()),r=Lr(n);return r!==void 0?r.read_output===void 0?void 0:`extension:${r.command}`:aa(n,t)}var fy=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],Hc={comments:["add","body","comment","text","stdin","file","edit","delete"],notes:["add","note","text","addJson","stdin","file","edit","delete"],learnings:["add","learning","text","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function my(e){return fy.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var py=[{keys:["outputInclude","output_include"],valid:e=>Pt(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||rt(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||rt(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(Fn(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."}],mS="read_output_mutation_conflict",nd=[{flag:"--output-include",keys:["outputInclude","output_include"]},{flag:"--output-limit",keys:["outputLimit","output_limit"]},{flag:"--output-budget",keys:["outputBudget","output_budget"]},{flag:"--output-session",keys:["outputSession","output_session"]},{flag:"--output-cursor",keys:["outputCursor","output_cursor"]},{flag:"--output-row-contract",keys:["outputRowContract","output_row_contract"]}],pS=nd.map(({flag:e})=>e);function _y(e,t,n){let r=nd.filter(({keys:a})=>a.some(c=>t[c]!==void 0)),o=r.map(({flag:a})=>a),i=r.flatMap(({keys:a})=>a.filter(c=>t[c]!==void 0)),s=o.join(", ");return new h(`Universal output controls (${s}) cannot be combined with a ${e} mutation; nothing was written.`,y.USAGE,{code:"read_output_mutation_conflict",field:o[0],details:{surface:e,output_controls:o,output_option_keys:i,mutation_options:[...n]},required:`Retry the ${e} mutation without ${s}. To bound or page the result, read it with those controls in a separate call after the write.`,why:"Universal output controls shape a read. A mutation returns its own bounded receipt, so the controls have nothing to shape and the write is refused before it runs.",examples:[...gy[e]]})}var gy={comments:['pm comments <id> --add "<text>"',"pm comments <id> --output-limit 5"],notes:['pm notes <id> --add "<text>"',"pm notes <id> --output-limit 5"],learnings:['pm learnings <id> --add "<text>"',"pm learnings <id> --output-limit 5"],files:["pm files <id> --add path=<path>","pm files <id> --output-limit 5"],docs:["pm docs <id> --add path=<path>","pm docs <id> --output-limit 5"],"package-catalog":["pm package install <source> --project","pm package catalog --output-limit 5"]};function _S(e,t){let n=t.outputFormat??t.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new h("--output-format must be toon or json.",y.USAGE);if(!my(t))return;let r=Ce(e,t);if(!r)throw new h(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,y.USAGE);if(Object.hasOwn(Hc,r)){let o=r,i=Hc[o].filter(s=>t[s]!==void 0&&t[s]!==!1);if(i.length>0)throw _y(o,t,i)}for(let o of py){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new h(o.message,y.USAGE)}}function rd(e){let t=Ce(e);return t?zr(t):new Map}function yy(e,t,n){let r=Pt(t)??[],o=rd(e),i=[],s=[],a=n,c=a[Dt],d=new Set(c?.canonical_include_modes??[]),l=new Set(c?.explicit_legacy_aliases??[]);for(let m of r){let p=o.get(m);if(p===void 0){i.push(m);continue}let _=`--${m.replaceAll("_","-")}`;No(xo(n,_))&&l.add(_),n[p]=!0,s.push(m),d.add(m)}let f=Ce(e)==="get"?i.filter(m=>m!=="item"):[],u=f.length>0;return u&&(n.fields=[...new Set([...Pt(n.fields)??[],...f])].join(","),d.add("fields")),(s.length>0||u)&&(a[Dt]={canonical_include_modes:[...d],explicit_legacy_aliases:[...l],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function gS(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=yy(e,n,t);if(o.length===0)return;let i=r.length>0?r.join(","):void 0;t.outputInclude=i,Object.hasOwn(t,"output_include")&&(t.output_include=i)}function xo(e,t){let n=qr(t);if(Object.hasOwn(e,n))return e[n];let r=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,r))return e[r];if(t==="--no-truncate"&&e.truncate===!1)return!0}function No(e){return e!==void 0&&e!==!1&&e!==null}function Pt(e){let t=(Array.isArray(e)?e:[e]).flatMap(n=>typeof n=="string"?n.split(","):[]).map(n=>n.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function rt(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 hy(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=xo(t,o.flag),s={value:i,flag:o.flag};if(No(i)&&n(s))return s}}function Yc(e,t){let n=Pt(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:Pt(t.value)??[mn(t.flag)]}}function Xc(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=rt(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;if(t.flag==="--no-truncate"||t.flag==="--unbounded")return{source:"legacy",value:"unbounded"};let r=rt(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function Jc(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=rt(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let r=rt(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function Qc(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 od(e,t,n){if(!e)return!1;let r=new Set(e.explicit_legacy_aliases);if(e.cli_invocation_observed===!0||e.sdk_invocation_observed===!0)return!r.has(n);let o=new Set(e.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return t==="include"&&o.has(n)&&!r.has(n)}function by(e,t,n,r){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||No(xo(r,"--no-truncate"))&&!od(n,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function wy(e,t){return Me.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[$t[n]]:[])}function id(e,t){let n=Ce(e,t);if(!n)return;let r=uy.get(n)??td(n),o=t[Dt],i={include:b=>Yc(void 0,b),amount:b=>Xc(void 0,b),cost:b=>Jc(void 0,b),encoding:b=>Qc(void 0,b)},s=Object.fromEntries(Me.map(b=>[b,hy(r.dimensions[b],t,w=>i[b](w)!==void 0,w=>od(o,b,w))])),a=Me.flatMap(b=>{let w=s[b];return w?[w.flag]:[]}),c=Me.flatMap(b=>{let w=s[b];return w?[r.dimensions[b].legacy_aliases.find(U=>U.flag===w.flag).migration_hint]:[]}),d=Qc(t.outputFormat??t.output_format,s.encoding),l=Yc(t.outputInclude??t.output_include,s.include),f=Xc(t.outputLimit??t.output_limit,s.amount),u=Jc(t.outputBudget??t.output_budget,s.cost),m=by(e,s,o,t),p=Qs(e,{generateFallback:!0}),_=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",g=u??(m?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:l,amount:f,cost:g,encoding:d,canonical_options_used:wy({include:l,amount:f,cost:g,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:ed}}function R(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Do=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"]),vy=["collection_counts","notes_count","tests_count"];function sd(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function Ey(e){let t=R(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...vy.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!Do.has(o)).sort((o,i)=>o.localeCompare(i));return{item:t,itemFields:n,sections:r,valid:[...n,"item",...n.map(o=>`item.${o}`),...r]}}function ky(e,t){let n=Ey(e),r=t.filter(l=>!n.valid.includes(l));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,y.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:n.itemFields.includes(l)?[l]:[]).filter((l,f,u)=>u.indexOf(l)===f);if(o&&i.length>0)throw new h("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",y.USAGE);let s=new Set(t.filter(l=>n.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>Do.has(l)||s.has(l)));o?a.item=n.item:i.length>0&&(a.item=sd(n.item,i));let c=[...o?[]:i.length>0?n.itemFields.filter(l=>!i.includes(l)).map(l=>({name:`item.${l}`,restore_with:`--output-include item.${l}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(l=>!s.has(l)).map(l=>({name:l,restore_with:`--output-include ${l}`}))],d=[...R(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 Zc(e){let t=0;return Et({...e},n=>(R(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function Oy(e,t,n,r){if(Zc(t)===0||Zc(n)>0)return;let o=[...rd(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${r.join(", ")}. No selector matched any returned row field.${i}`,y.USAGE)}function Sy(e,t,n){if(e==="get")return ky(t,n);let r=yn(t),o=n.flatMap(s=>r.flatMap(a=>s.startsWith(`${a}.`)?[s.slice(a.length+1)]:[])),i=n.some(s=>Object.hasOwn(t,s.split(".")[0])&&!r.some(a=>s.startsWith(`${a}.`)));if(r.length>0&&(!i||o.length>0)){let s={...t},a=o.length>0?o:n,c=Et(s,d=>R(d)?sd(d,a):d);return Oy(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||Do.has(s)))}function Ay(e,t,n,r){if(t==="unbounded")return e;let{result:o,truncated:i}=wa(e,t,s=>Te(n,s));if(!i)return o;if(o.has_more=!0,o.truncated=!0,ld(o,n,[...r.entries()].flatMap(([s,a])=>a.rows>t?[{path:s,total_rows:a.totalRows}]:[])),typeof o.count=="number"){let s=R(o.projection)?o.projection.row_key:void 0;o.count=typeof s=="string"&&Array.isArray(o[s])?o[s].length:He(o)}return typeof o.returned_count=="number"&&(o.returned_count=He(o)),o.applied_bound={kind:"output_limit",source:"explicit",value:t},o}function Ty(e){return Me.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes($t[t]))}function Un(e,t,n,r){let o=Ro(e,t,r);nt(e,o);for(let i=0;i<8;i+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;_e(o,n,r);let c=o;o=Ro(o,t,r),nt(c,o);let d=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&d===a)return o}return o}function _o(e,t){if(!R(e.read_output))return e;let n=et(t),r=e.read_output,o=Fn(t.outputSession??t.output_session);return o===void 0?(_e(e,r,n),e):Un(e,o,r,n)}function Cy(e,t){if(e!=="validate")return t;let n=R(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(l=>R(l)&&l.name==="diagnostic_rows"))return t;let r=[...new Set(vt(t).map(({path:l})=>l).filter(l=>/^checks\.\d+\.details\./u.test(l)))],o=r.filter(l=>!r.some(f=>f!==l&&l.startsWith(`${f}.`)));if(o.length===0)return t;let i=R(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 Iy(e,t){return e.include?.source==="canonical"&&!Ze(t)}function Ry(e,t,n,r,o){let i={...e};if(Iy(t,e)&&(i=Sy(t.command,i,t.include.value)),t.command==="assurance"&&(i=Sa(i)),kt(i,e),i=Aa(i,t.command,r),t.command==="history"&&r){let c=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([d])=>!c.includes(d)||d===r.path)),R(i.projection)&&(i.projection={...i.projection,row_key:r.path}),R(i.row_contract)){let d=i.row_contract;i.row_contract={...d,row_keys:[r.path],...Array.isArray(d.continuation_row_keys)?{continuation_row_keys:[r.path]}:{}}}i.count=Object.keys(i[r.path]).length}let s=e.count_only===!0?{...i,count_only:!0,count:e.count}:i,a=Ly(i,e,t.command,r,o);return t.amount?.source==="canonical"&&(i=Ay(i,t.amount.value,t.command,a.collectionsBeforeBudget),a.cursorContinuesExistingPage&&fd(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),kt(i,s),ud(i,t.command,a),{projected:n===void 0?i:Wc(i,n),continuationState:a}}function xy(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:Kc(t)}]].sort((n,r)=>n.tokens-r.tokens)[0]}function ad(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function cd(e,t){return R(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function Ny(e,t,n){return e.command!=="next"||(t.tokenBudget??t.token_budget)===void 0?!1:!(R(n.context_intent)&&n.context_intent.command==="next"&&n.context_intent.within_budget===!0)}function dd(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!cd(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function Dy(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...dd(r),precedence:e.precedence,...ad(e),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...n===void 0?{omitted_result_estimated_tokens:o}:{}},a={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:s},c=n===void 0?a:Un(a,n,s,i);if(n===void 0&&_e(c,s,i),n!==void 0&&s.estimated_tokens>r.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",y.USAGE);return c}function Py(e,t,n){return e.command==="context"&&e.cost?.source==="legacy"&&!cd(n,e.cost.value)||Ny(e,t,n)||t.outputRowContract===!0||t.output_row_contract===!0||e.canonical_options_used.includes("--output-include")||e.command==="list"&&e.canonical_options_used.length>0&&e.include?.value.includes("full")===!0}function $y(e,t,n,r,o){if(t!==void 0||Ze(n)||Py(e,o,n))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(le(n).some(({value:s})=>(Array.isArray(s)?s.length:Object.keys(s).length)>i))return!1}return e.cost===void 0||e.cost.value==="unbounded"||e.cost.source==="legacy"&&e.command!=="context"||pe(o.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,r)<=e.cost.value}function ld(e,t,n){let r=Object.hasOwn(B,t)?B[t]:void 0,o=n.find(i=>r?.paths.includes(i.path));r!==void 0&&o!==void 0&&typeof e[r.total_key]!="number"&&(e[r.total_key]=o.total_rows)}function ud(e,t,n){let r=B[t]?.paths[0];r!==void 0&&Oa(e,t,n.producer,n.collectionsBeforeBudget.get(r)?.rows)}function My(e,t,n,r){let o=n.backward?n.rows-r:n.baseOffset+r;return{path:t,cursor:Kr({command:e,path:t,offset:o,total_rows:n.totalRows,fingerprint:n.fingerprint,...n.backward?{direction:"backward"}:{}}),retained_rows:r,remaining_rows:n.backward?o:n.totalRows-o,total_rows:n.totalRows}}function jy(e,t,n,r,o,i,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map(Ke(e).map(p=>[p.path,Array.isArray(p.value)?p.value.length:Object.keys(p.value).length])),d=[...s.entries()].flatMap(([p,_])=>{let g=c.get(p);return g>=_.rows?[]:[My(t.command,p,_,g)]}),l=d[0];ld(e,t.command,d);let f=l?"; page --output-cursor":"",u=r.source==="session"?`Truncated by the remaining ${r.tokens}-token session budget; start a new output session with a larger token_budget${f}.`:`${r.tokens}-token: raise --output-budget${f}`;n.migration_hints=[u,...t.migration_hints];let m=xt({effective_budget_tokens:r.tokens,measured_result_tokens:i});l&&!o&&(typeof e.next_cursor!="string"||e.continuation_kind==="output_cursor")&&(e.next_cursor=l.cursor),e.continuation_kind=o?"producer_cursor":l?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:r.source,budget_tokens:r.tokens,overridden_dimensions:a,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:o,continuation_available:d.length>0,recovery_budget_multiplier:l?1:m.recovery_budget_multiplier,continuations:d,restore_with:l?"recovery":`Retry with --output-budget ${m.output_budget} because no declared row collection can be continued.`,recovery:l?{cursor:l.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${m.output_budget}`,sdk:{outputBudget:m.output_budget},mcp:{outputBudget:m.output_budget}}}}function fd(e,t,n,r,o){if(typeof n!="string"||!Array.isArray(e.items))return!1;let i=e.items.length,s=t.length;if(i===0||i>=s)return!1;let a;try{a=Xr(n)}catch{return!1}let c=a.after_index;if(c===void 0)return!1;let d=t[i-1];if(Object.prototype.toString.call(d)!=="[object Object]")return!1;let l=Reflect.get(d,"id");if(typeof l!="string"||l.length===0)return!1;let f=r?c-(s-i):c+o+i;return f<0?!1:(e.next_cursor=At(a.fingerprint,l,f,a.snapshot),!0)}function Ly(e,t,n,r,o){let i=new Map(Ke(e).map(c=>{let d=Array.isArray(c.value)?c.value.length:Object.keys(c.value).length,l=r?.path===c.path,f=Te(n,c.path);return[c.path,{rows:d,totalRows:l?r.total_rows:d,baseOffset:l&&!f?r.offset:0,backward:f,fingerprint:l?r.fingerprint:hn(c.path,c.value,n)}]})),s=typeof e.next_cursor=="string",a=r?.path==="items"?r.offset:0;return{collectionsBeforeBudget:i,originalItems:Array.isArray(t.items)?a>0?t.items.slice(a):t.items:[],originalItemOffset:a,cursorContinuesExistingPage:s,cursorSource:s?e.next_cursor:o.after,producer:t}}function Fy(e,t,n,r,o,i,s,a,c,d){let l={...t,count_only:n},f=r.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(m=>R(m)&&m.verdict!=="pass").length:0,u=new Map;if(f>0&&u.set("assertions",f),r.command==="history"&&Array.isArray(e.diff))for(let m of vt(e))m.path.startsWith("diff.")&&u.set(m.path,Object.keys(m.value).length);return Bc(e,o,i.tokens,u,d,m=>{kt(m,l),ud(m,r.command,a);let p=fd(m,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(jy(m,r,o,i,p,c,a.collectionsBeforeBudget),r.command==="history"&&R(m.projection)){m.has_more=typeof m.next_cursor=="string"||m.applied_bound?.kind==="output_limit";let _=m.projection.row_key;typeof _=="string"&&Array.isArray(m[_])&&(m.count=m[_].length)}s!==void 0&&Object.assign(m,Un(m,s,o,d))},r.command==="history"&&Array.isArray(e.diff),m=>Te(r.command,m))}function uc(e,t,n){let r=id(e,t);if(!r)return n;let o=et(t),i=Fn(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?St(s):void 0,c=Ty(r),d=Cy(r.command,n);if(a===void 0&&$y(r,i,d,o,t))return d;let l=xy(r,i),f=Ry(d,r,i,a,t),u=f.projected;nt(u,u,t.outputRowContract===!1);let m=Ze(u),p={contract_version:1,command:r.command,requested_dimensions:c,...dd(l,u),precedence:r.precedence,...ad(r),legacy_aliases_used:r.legacy_aliases_used,migration_hints:r.migration_hints,estimated_tokens:0,within_budget:!m,strings_compacted:!1,rows_compacted:!1,result_omitted:m};if(u.read_output=p,u=i===void 0?u:Un(u,i,p,o),_e(u,p,o),l!==void 0&&p.estimated_tokens>l.tokens){let _=qc(r.command,t,u);_!==void 0&&(p.applied_depth="brief",p.degradation_reason="output_budget_reached",nt(u,_),u=_o(_,t)),p.estimated_tokens>l.tokens&&(u=Fy(u,u,d.count_only===!0,r,p,l,i,f.continuationState,p.estimated_tokens,o))}return l!==void 0&&p.estimated_tokens>l.tokens?Dy(r,c,i,l,p.estimated_tokens,o):u}function Uy(e){return R(e)&&R(e.context_intent)&&e.context_intent.result_omitted===!0}function Ze(e){return zy(e)||Uy(e)}function zy(e){return R(e)&&R(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function $g(e,t){let n=t.outputFormat??t.output_format;if(n==="json"||n==="toon")return n;let r=id(e,t)?.encoding;return r?.value==="json"||r?.value==="toon"?r.value:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7e894d1f-fe1a-53f2-9a29-4e9846a9f986")}catch{}})();var md=["append","cancel","claim","close","comment_add","comment_edit","comment_delete","create","delete","docs_add","docs_remove","files_add","files_remove","files_discover","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","import","improvement_observe","learning_add","learning_edit","learning_delete","normalize","note_add","note_edit","note_delete","plan_create_metadata","plan_create_initial_step","plan_add_step","plan_reorder_step","plan_remove_step","plan_link_step","plan_unlink_step","plan_append_decision","plan_append_discovery","plan_append_validation","plan_resume","plan_approve","plan_materialize","plan_update_step","plan_complete_step","plan_block_step","policy_approve","policy_refused","release","reopen","restore","schema_migration","schema_migration_reference","test_run_track","tests_add","tests_remove","tests_update","update","update_audit","update_ownership_bypass","workspace_snapshot_restore","extension_migrations_apply","merge_reconcile"],pd=["history:author-acknowledge","settings:write","init:type_preset","templates:save","profile:apply-types","profile:apply-statuses","profile:apply-fields","profile:apply-config","schema:add-type","schema:remove-type","schema:add-status","schema:remove-status","schema:add-field","schema:remove-field","schema:apply-preset","schema:infer-types","schema:policy-put","schema:policy-remove","schema:policy-mode","assurance:bundle:apply","assurance:gate:verdict","telemetry:install_id","telemetry:first_run_prompt","telemetry:clear","item_format:auto_select_default","transaction_abandon"],Po={"init:type-preset":"init:type_preset"},_d=["^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_]*$"],hS={version:1,item:md,workspace:pd,aliases:Po,patterns:_d,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"]},qy=new Set([...md,...pd]),By=_d.map(e=>new RegExp(e,"u"));function gd(e){return Object.hasOwn(Po,e)?Po[e]:e}function bS(e){let t=gd(e);if(qy.has(t)||By.some(n=>n.test(t)))return t;throw new TypeError("Undeclared history operation; use a native contract identity or extension:<package_name>:<snake_case_operation>.")}function wS(e){let t=gd(e),n=t.indexOf(":"),r=n<0?t:t.slice(0,n),o=n<0||n<t.length-1&&!/[\s\p{C}]/u.test(t.slice(n+1));if(/^[a-z][a-z0-9]*(?:[_.-][a-z0-9]+)*$/u.test(r)&&o)return t;throw new TypeError("History operation must use lowercase alphanumeric segments with an optional non-whitespace colon-suffixed retry key.")}export{qt as a,hi as b,or as c,vu as d,Eu as e,A as f,yd as g,Lo as h,Gy as i,Wy as j,Fo as k,Ky as l,Hy as m,Yy as n,Xy as o,Jy as p,Qy as q,Zy as r,eh as s,th as t,nh as u,rh as v,oh as w,ih as x,sh as y,hd as z,ah as A,ch as B,dh as C,lh as D,uh as E,fh as F,mh as G,rs as H,_u as I,$b as J,mi as K,pi as L,ws as M,vs as N,wd as O,vd as P,Vn as Q,Kn as R,Hn as S,bh as T,wh as U,vh as V,Rd as W,zo as X,Eh as Y,lt as Z,cr as _,tw as $,Du as aa,rw as ba,ow as ca,iw as da,Ii as ea,Ri as fa,sw as ga,aw as ha,cw as ia,dw as ja,Vo as ka,Ld as la,Wo as ma,Jo as na,xh as oa,Qn as pa,Xd as qa,Nh as ra,ll as sa,ul as ta,Dh as ua,Ph as va,Vh as wa,ti as xa,ni as ya,ri as za,Zo as Aa,Gh as Ba,Wh as Ca,Kh as Da,er as Ea,Hh as Fa,ye as Ga,K as Ha,Jh as Ia,Qh as Ja,jl as Ka,ii as La,tr as Ma,Ul as Na,zl as Oa,Ht as Pa,ai as Qa,Bl as Ra,Wl as Sa,ob as Ta,ib as Ua,Xl as Va,Jl as Wa,Ql as Xa,Zl as Ya,nr as Za,ab as _a,eu as $a,ct as ab,Yt as bb,cb,db,lb as eb,tu as fb,nu as gb,ru as hb,_b as ib,gb as jb,ou as kb,Xt as lb,yb as mb,hb as nb,iu as ob,su as pb,au as qb,di as rb,Fe as sb,cu as tb,bb as ub,wb as vb,vb as wb,Eb as xb,kb as yb,Ob as zb,Sb as Ab,Ab as Bb,be as Cb,Zt as Db,xb as Eb,rn as Fb,fr as Gb,mr as Hb,pr as Ib,_r as Jb,gr as Kb,yr as Lb,wr as Mb,Zi as Nb,tn as Ob,Lb as Pb,gi as Qb,Fb as Rb,V as Sb,zb as Tb,qb as Ub,Nf as Vb,Pf as Wb,$f as Xb,Bf as Yb,Yv as Zb,Xv as _b,Jv as $b,Ca as ac,nE as bc,cm as cc,ku as dc,ir as ec,Au as fc,Tu as gc,cE as hc,gm as ic,dE as jc,lE as kc,uE as lc,fE as mc,mE as nc,pE as oc,_E as pc,Vs as qc,ym as rc,gE as sc,yE as tc,Gs as uc,hE as vc,Ws as wc,bE as xc,wE as yc,vE as zc,ln as Ac,pa as Bc,BE as Cc,VE as Dc,GE as Ec,_a as Fc,ga as Gc,rk as Hc,ha as Ic,_n as Jc,uk as Kc,fk as Lc,bm as Mc,xE as Nc,Xs as Oc,wm as Pc,Im as Qc,xm as Rc,Js as Sc,Nm as Tc,Dm as Uc,Qs as Vc,Ae as Wc,Zs as Xc,NE as Yc,DE as Zc,jr as _c,PE as $c,$E as ad,ME as bd,jE as cd,LE as dd,pk as ed,kt as fd,B as gd,Te as hd,Dt as id,G0 as jd,Me as kd,uS as ld,fS as md,ly as nd,Ce as od,mS as pd,pS as qd,_S as rd,rd as sd,yy as td,gS as ud,id as vd,_o as wd,uc as xd,Ze as yd,zy as zd,$g as Ad,ka as Bd,hn as Cd,Kr as Dd,St as Ed,Rk as Fd,xk as Gd,At as Hd,Xr as Id,Jr as Jd,Nk as Kd,Mp as Ld,Dk as Md,Pk as Nd,Fk as Od,eo as Pd,Gk as Qd,Wp as Rd,Wk as Sd,Xe as Td,Kk as Ud,Hk as Vd,vn as Wd,ro as Xd,oo as Yd,En as Zd,bO as _d,A_ as $d,In as ae,N_ as be,Qa as ce,$_ as de,te as ee,x as fe,xO as ge,It as he,W_ as ie,NO as je,DO as ke,K_ as le,PO as me,$O as ne,MO as oe,J_ as pe,fc as qe,Q_ as re,YO as se,eg as te,pc as ue,XO as ve,yc as we,og as xe,cc as ye,_g as ze,kg as Ae,Oc as Be,n0 as Ce,d0 as De,l0 as Ee,zg as Fe,Fc as Ge,N0 as He,xt as Ie,pe as Je,B0 as Ke,Io as Le,Fn as Me,Wc as Ne,Ro as Oe,Kc as Pe,md as Qe,pd as Re,Po as Se,_d as Te,hS as Ue,gd as Ve,bS as We,wS as Xe};
26
+ //# sourceMappingURL=chunk-2SQUWQP3.js.map