@unbrained/pm-cli 2026.11.4 → 2026.11.5

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 (219) hide show
  1. package/.agents/skills/HARNESS_COMPATIBILITY.md +1 -1
  2. package/.agents/skills/README.md +14 -14
  3. package/.agents/skills/pm-developer/SKILL.md +16 -16
  4. package/.agents/skills/pm-developer/references/GRAPH_AND_RELATIONSHIPS.md +14 -14
  5. package/.agents/skills/pm-developer/references/SCRIPTING_COMPOSITION.md +10 -10
  6. package/.agents/skills/pm-extensions/SKILL.md +13 -13
  7. package/.agents/skills/pm-extensions/references/AUTHORING.md +12 -12
  8. package/.agents/skills/pm-sdk/SKILL.md +27 -27
  9. package/.agents/skills/pm-sdk/references/SURFACE_MAP.md +32 -32
  10. package/.agents/skills/pm-test-audit/references/AUDIT.md +1 -1
  11. package/.agents/skills/pm-user/SKILL.md +35 -35
  12. package/.claude-plugin/marketplace.json +1 -1
  13. package/AGENTS.md +9 -9
  14. package/CHANGELOG.md +9 -0
  15. package/README.md +13 -13
  16. package/dist/cli/register-setup.js +1 -1
  17. package/dist/cli-bundle/bundle-manifest.json +1 -1
  18. package/dist/cli-bundle/chunks/chunk-2RPORE7M.js +31 -0
  19. package/dist/cli-bundle/chunks/{chunk-NPEDFOVQ.js → chunk-335BZ75D.js} +2 -2
  20. package/dist/cli-bundle/chunks/chunk-5GWEY4P6.js +122 -0
  21. package/dist/cli-bundle/chunks/chunk-6VRX2CM7.js +2 -0
  22. package/dist/cli-bundle/chunks/{chunk-7PGNAHNW.js → chunk-7DEKAXVA.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-3OXQGGRD.js → chunk-7ZRCYESH.js} +42 -41
  24. package/dist/cli-bundle/chunks/{chunk-BWAXA6S4.js → chunk-AUEKTX7V.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-SRDO2NJU.js → chunk-D7KYPRK4.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-ODMJ3HIB.js → chunk-DAX3AOFI.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-L4BKTPJ6.js → chunk-F6NDMKZ4.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-T56MB6SF.js → chunk-FRNMQM45.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-5S6RT5LX.js → chunk-HNGLDMSZ.js} +3 -3
  30. package/dist/cli-bundle/chunks/{chunk-QN7VCOUU.js → chunk-HRCMORE7.js} +2 -2
  31. package/dist/cli-bundle/chunks/{chunk-BK2XAQVC.js → chunk-HRFGFIYU.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-CERNIZLB.js → chunk-JI2GDE4I.js} +42 -42
  33. package/dist/cli-bundle/chunks/{chunk-6T2V3UIK.js → chunk-LS3GI3H4.js} +53 -53
  34. package/dist/cli-bundle/chunks/chunk-OH6WQ7VT.js +3 -0
  35. package/dist/cli-bundle/chunks/{chunk-BRIPGUAO.js → chunk-OJDMJT7Y.js} +2 -2
  36. package/dist/cli-bundle/chunks/{chunk-7RCI7AAA.js → chunk-S4LPZ4TN.js} +2 -2
  37. package/dist/cli-bundle/chunks/{chunk-AQ5UHHQS.js → chunk-UEGXWXUZ.js} +2 -2
  38. package/dist/cli-bundle/chunks/{chunk-5BVZ32G7.js → chunk-XLSHFYXZ.js} +2 -2
  39. package/dist/cli-bundle/chunks/{chunk-2GW662DP.js → chunk-YKXATU2G.js} +2 -2
  40. package/dist/cli-bundle/chunks/{item-revision-UAZOBP2Q.js → item-revision-OJJVPQY7.js} +2 -2
  41. package/dist/cli-bundle/chunks/item-transaction-QEPBUCMY.js +2 -0
  42. package/dist/cli-bundle/chunks/{mutation-admission-QZQI2NN5.js → mutation-admission-INMM3HHG.js} +2 -2
  43. package/dist/cli-bundle/chunks/{register-list-query-P3NOKQUA.js → register-list-query-5Y5JKWU5.js} +2 -2
  44. package/dist/cli-bundle/chunks/{register-mutation-A6I5K5N6.js → register-mutation-WC7OSQID.js} +2 -2
  45. package/dist/cli-bundle/chunks/{register-operations-SPKB3TNM.js → register-operations-PO63DBZH.js} +2 -2
  46. package/dist/cli-bundle/chunks/register-setup-RRFOS7IT.js +2 -0
  47. package/dist/cli-bundle/chunks/{stage-L3T725DS.js → stage-E3MMV4TV.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-5PMJOJCZ.js +44 -0
  49. package/dist/cli-bundle/focused-chunks/{chunk-TFYTTDAK.js → chunk-7KK66ISG.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-Y5GOUUYJ.js → chunk-AHWJPZSJ.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-C7UX2ZI3.js → chunk-C6P6HPCX.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-Q4OIRSKL.js → chunk-CPMSL4HS.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/chunk-CZM75DE3.js +2 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-CO2DNPH7.js → chunk-D2TBEBNW.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/chunk-E56OXRYH.js +2 -0
  56. package/dist/cli-bundle/focused-chunks/{chunk-FXFDVM5O.js → chunk-F62XGAAY.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/chunk-G4QP365K.js +2 -0
  58. package/dist/cli-bundle/focused-chunks/{chunk-J7M52SCZ.js → chunk-G5PJCR7R.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/chunk-GS3JC5UU.js +23 -0
  60. package/dist/cli-bundle/focused-chunks/{chunk-W3CSX6GI.js → chunk-LW64TINU.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{chunk-MEJKELWC.js → chunk-M6V7UMWL.js} +3 -3
  62. package/dist/cli-bundle/focused-chunks/{chunk-CXTDEQ3N.js → chunk-MC7IE7D7.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/chunk-MG7C3JUY.js +2 -0
  64. package/dist/cli-bundle/focused-chunks/{chunk-QEVJ3Y67.js → chunk-MK4HV4JO.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-A2246ZM7.js → chunk-NQ7GYFOX.js} +54 -54
  66. package/dist/cli-bundle/focused-chunks/chunk-O7EI33NP.js +91 -0
  67. package/dist/cli-bundle/focused-chunks/{chunk-FFO7RBLN.js → chunk-RFTJZ5VB.js} +2 -2
  68. package/dist/cli-bundle/focused-chunks/{chunk-PNPYQDHU.js → chunk-SNOXXRSJ.js} +2 -2
  69. package/dist/cli-bundle/focused-chunks/{chunk-JQS7TYQ6.js → chunk-UPJUTP2V.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/{chunk-SDLIUZEL.js → chunk-VWWTIX5L.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/{chunk-J6FDCAMH.js → chunk-XHOBYCVE.js} +2 -2
  72. package/dist/cli-bundle/focused-chunks/{chunk-J3YOATXR.js → chunk-YMGB2O4E.js} +25 -24
  73. package/dist/cli-bundle/focused-chunks/{item-revision-L6GVT42D.js → item-revision-CTDO4H3I.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/{item-transaction-GYGP264N.js → item-transaction-AEAYVVHA.js} +2 -2
  75. package/dist/cli-bundle/focused-chunks/{mutation-admission-UWTH56OD.js → mutation-admission-4WM7TNHZ.js} +2 -2
  76. package/dist/cli-bundle/focused-chunks/{stage-WRSNJ7VI.js → stage-WV7QXR4C.js} +2 -2
  77. package/dist/cli-bundle/main.js +2 -2
  78. package/dist/cli-bundle/sdk-authoring.js +1 -1
  79. package/dist/cli-bundle/sdk-contracts.js +1 -1
  80. package/dist/cli-bundle/sdk-core.js +1 -1
  81. package/dist/cli-bundle/sdk-governance.js +1 -1
  82. package/dist/cli-bundle/sdk-graph.js +1 -1
  83. package/dist/cli-bundle/sdk-merge.js +57 -57
  84. package/dist/cli-bundle/sdk-query.js +1 -1
  85. package/dist/cli-bundle/sdk-runtime.js +1 -1
  86. package/dist/cli-bundle/sdk-testing.js +1 -1
  87. package/dist/cli-bundle/sdk.js +9 -9
  88. package/dist/core/config/positional-value.d.ts +6 -0
  89. package/dist/core/config/positional-value.js +1 -1
  90. package/dist/core/item/literal-mutation-input.d.ts +17 -0
  91. package/dist/core/item/literal-mutation-input.js +1 -1
  92. package/dist/core/item/parent-reference-policy.d.ts +8 -4
  93. package/dist/core/item/parent-reference-policy.js +1 -1
  94. package/dist/core/item/sprint-release-format.d.ts +2 -1
  95. package/dist/core/item/sprint-release-format.js +1 -1
  96. package/dist/core/output/mutation-projection.js +1 -1
  97. package/dist/core/store/item-mutation-precondition.d.ts +3 -1
  98. package/dist/core/store/item-mutation-precondition.js +1 -1
  99. package/dist/core/store/item-store.js +1 -1
  100. package/dist/core/store/settings.d.ts +14 -0
  101. package/dist/core/store/settings.js +5 -4
  102. package/dist/core/telemetry/policy.d.ts +27 -1
  103. package/dist/core/telemetry/policy.js +1 -1
  104. package/dist/core/telemetry/runtime.d.ts +18 -7
  105. package/dist/core/telemetry/runtime.js +4 -4
  106. package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +8 -5
  107. package/dist/sdk/cli-contracts.d.ts +1 -1
  108. package/dist/sdk/cli-contracts.js +1 -1
  109. package/dist/sdk/config.d.ts +2 -2
  110. package/dist/sdk/config.js +1 -1
  111. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  112. package/dist/sdk/governance/health.d.ts +2 -2
  113. package/dist/sdk/governance/health.js +2 -2
  114. package/dist/sdk/index.d.ts +4 -2
  115. package/dist/sdk/index.js +1 -1
  116. package/dist/sdk/init.d.ts +4 -4
  117. package/dist/sdk/init.js +8 -8
  118. package/dist/sdk/lifecycle/claim.d.ts +4 -0
  119. package/dist/sdk/lifecycle/claim.js +1 -1
  120. package/dist/sdk/lifecycle/close.d.ts +10 -0
  121. package/dist/sdk/lifecycle/close.js +1 -1
  122. package/dist/sdk/lifecycle/create.d.ts +7 -5
  123. package/dist/sdk/lifecycle/create.js +1 -1
  124. package/dist/sdk/lifecycle/shared-unset-fields.d.ts +628 -4
  125. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
  126. package/dist/sdk/lifecycle/update.d.ts +5 -4
  127. package/dist/sdk/lifecycle/update.js +2 -2
  128. package/dist/sdk/public-surface.json +1 -1
  129. package/dist/sdk/runtime/actions.js +1 -1
  130. package/dist/sdk/runtime/mutation-value-validation.js +1 -1
  131. package/dist/sdk/runtime-input.js +1 -1
  132. package/dist/sdk/runtime-primitives.d.ts +1 -0
  133. package/dist/sdk/runtime-primitives.js +1 -1
  134. package/dist/sdk/telemetry.d.ts +1 -1
  135. package/dist/sdk/telemetry.js +2 -2
  136. package/docs/AGENT_GUIDE.md +48 -48
  137. package/docs/AGENT_OUTPUT_ENCODINGS.md +20 -20
  138. package/docs/ASSURANCE.md +10 -10
  139. package/docs/BOUNDED_CONTEXT_READS.md +3 -3
  140. package/docs/CLAUDE_CODE_PLUGIN.md +1 -1
  141. package/docs/CLI_GRAMMAR.md +2 -2
  142. package/docs/COMMANDS.md +56 -35
  143. package/docs/COMMAND_NAMESPACES.md +1 -1
  144. package/docs/CONFIGURATION.md +82 -71
  145. package/docs/CONTEXT_ALGORITHM_PORTFOLIO.md +2 -2
  146. package/docs/CONTEXT_INTEGRITY_CONTRACTS.md +5 -5
  147. package/docs/CORPUS_SHAPES.md +1 -1
  148. package/docs/DEPENDENCY_KIND_CONTRACT.md +6 -6
  149. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +5 -5
  150. package/docs/ECOSYSTEM_PLANNING_REVIEW.md +3 -3
  151. package/docs/EXTENSION_AUTHOR_CONTRACTS.md +4 -4
  152. package/docs/HISTORY_ATTESTATION.md +1 -1
  153. package/docs/HISTORY_MAINTENANCE.md +1 -1
  154. package/docs/LIFECYCLE_COMMANDS.md +1 -1
  155. package/docs/MCP_2026_07_28.md +16 -16
  156. package/docs/MCP_2026_07_28_CONFORMANCE.md +19 -19
  157. package/docs/MCP_REMOTE_TRANSPORT_SECURITY.md +22 -22
  158. package/docs/MCP_SKILLS_AND_APPS.md +1 -1
  159. package/docs/MERGE_SAFETY.md +6 -6
  160. package/docs/MUTATION_INTEGRITY.md +5 -5
  161. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +14 -14
  162. package/docs/PACKED_FIRST_RUN.md +1 -1
  163. package/docs/QUICKSTART.md +10 -10
  164. package/docs/README.md +21 -21
  165. package/docs/READ_OUTPUT_CONTRACTS.md +9 -9
  166. package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +1 -1
  167. package/docs/RELEASING.md +19 -10
  168. package/docs/SCRIPTING.md +10 -10
  169. package/docs/SDK.md +74 -38
  170. package/docs/SDK_ARTIFACT_OUTPUT.md +1 -1
  171. package/docs/SDK_PRIMITIVE_INVENTORY.md +2 -2
  172. package/docs/SELF_DESCRIBING_CONTEXT_CONTRACTS.md +7 -7
  173. package/docs/TESTING.md +1 -1
  174. package/docs/WORKFLOW_POLICIES.md +2 -2
  175. package/docs/WORKSPACE_POSITION_AND_LIFECYCLE.md +8 -8
  176. package/docs/generated/AGENT_CAPABILITY_ROUTING.md +1 -1
  177. package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -1
  178. package/docs/generated/FLAG_LEXICON_BUDGETS.md +1 -1
  179. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +1 -1
  180. package/docs/performance/cli-transport-overhead.md +7 -7
  181. package/marketplace.json +1 -1
  182. package/package.json +1 -1
  183. package/packages/pm-beads/package.json +1 -1
  184. package/packages/pm-calendar/package.json +1 -1
  185. package/packages/pm-command-kit/README.md +5 -5
  186. package/packages/pm-command-kit/package.json +1 -1
  187. package/packages/pm-digital-twin/GAP_REPORT.md +16 -16
  188. package/packages/pm-digital-twin/package.json +1 -1
  189. package/packages/pm-governance-audit/package.json +1 -1
  190. package/packages/pm-guide-shell/package.json +1 -1
  191. package/packages/pm-kanban/README.md +1 -1
  192. package/packages/pm-kanban/package.json +1 -1
  193. package/packages/pm-lifecycle-hooks/package.json +1 -1
  194. package/packages/pm-linked-test-adapters/package.json +1 -1
  195. package/packages/pm-search-advanced/package.json +1 -1
  196. package/packages/pm-templates/package.json +1 -1
  197. package/packages/pm-todos/package.json +1 -1
  198. package/packages/pm-vcs/GAP_REPORT.md +1 -1
  199. package/packages/pm-vcs/package.json +1 -1
  200. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  201. package/plugins/pm-claude/README.md +6 -6
  202. package/plugins/pm-claude/package.json +1 -1
  203. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  204. package/plugins/pm-codex/package.json +1 -1
  205. package/plugins/pm-codex/plugin.json +1 -1
  206. package/runtime-dependencies.json +1 -1
  207. package/dist/cli-bundle/chunks/chunk-5Z6LWFDL.js +0 -31
  208. package/dist/cli-bundle/chunks/chunk-DSCFJTHB.js +0 -122
  209. package/dist/cli-bundle/chunks/chunk-QQHMNUZT.js +0 -2
  210. package/dist/cli-bundle/chunks/chunk-TX2W6G37.js +0 -3
  211. package/dist/cli-bundle/chunks/item-transaction-N5F4LXYV.js +0 -2
  212. package/dist/cli-bundle/chunks/register-setup-ZZRHJ4IS.js +0 -2
  213. package/dist/cli-bundle/focused-chunks/chunk-5NGNO54M.js +0 -44
  214. package/dist/cli-bundle/focused-chunks/chunk-B6U44WPW.js +0 -2
  215. package/dist/cli-bundle/focused-chunks/chunk-BAW3DGQO.js +0 -91
  216. package/dist/cli-bundle/focused-chunks/chunk-BHNY3KPJ.js +0 -2
  217. package/dist/cli-bundle/focused-chunks/chunk-CBG67HUP.js +0 -23
  218. package/dist/cli-bundle/focused-chunks/chunk-FEPE2CE4.js +0 -2
  219. package/dist/cli-bundle/focused-chunks/chunk-PMKR4MJI.js +0 -2
@@ -4,7 +4,7 @@ import{A as h,C as $n,D as Mn,E as Y,a as H,b as Dn,c as ko,e as St,f as At,g as
4
4
 
5
5
  ${ke(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=js(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}${ke(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:Oe(Buffer.byteLength(p,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}var xr=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 iE(e){return e?.trim()===xr.required}function sE(e){let t=e?.trim();return t!==void 0&&xr.why.includes(t)}function aE(e){return(e??[]).filter(t=>!xr.examples.includes(t.trim()))}var cE=Object.freeze(["attempted_command","normalized_args","provided_fields"]);function dE(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]="3a66ccfd-51fb-5d4a-b9cd-257c49997d52")}catch{}})();var Ws=new WeakMap;function mE(e,t){Ws.set(e,new Set(t))}var Zt='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',wm={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 pE(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,g.USAGE)}function K(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 _E(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 K([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return K(r)}var Em=[{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 L(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var km=new Set([void 0,"tabular_when_uniform"]),Om=new Set(["collection","none"]),Sm=new Set(["supported","unsupported"]);function Vs(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 Am(e){return L(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Om.has(e.row_kind)&&Vs(e.row_keys,!0)&&(e.continuation_row_keys===void 0||Vs(e.continuation_row_keys,!1))&&Sm.has(e.fields)&&km.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 Cm={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"]},Tm={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 Im(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=Cm[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||L(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Zt}:{},toon_encoding:"tabular_when_uniform"}}let o=wm[r],i=Tm[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)=>L(d)?d[l]:void 0,t);return Array.isArray(c)||L(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:Zt}:{},toon_encoding:"tabular_when_uniform"}})()}function Rm(e){if(!L(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=>L(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 K(r,new Set(o))}function xm(e){if(!Array.isArray(e.sections_included))return;let t=K(Em,new Set(e.sections_included.filter(n=>typeof n=="string")));return L(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function Nm(e,t,n){return e==="dependency_provenance"?!1:Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&L(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&L(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function Dm(e){if(!L(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=Ws.get(e),i=a=>n.includes(a)||a==="body"||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"]:[]].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 K(s,new Set(s.flatMap(({name:a})=>Nm(a,i(a),e)?[a]:[])))}function Gs(e){if(L(e.projection))return K([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function Pm(e){if(!L(e.projection))return K([]);if(typeof e.projection.mode=="string")return K([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function $m(e){if(!(!L(e.selected)||typeof e.selected.summary!="boolean"))return K([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function Mm(e,t){let n=Rm(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return xm(t);if(r==="get")return Dm(t);if(r==="list"||r.startsWith("list-"))return Gs(t);if(r==="search")return Gs(t)??K([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return Pm(t);if(r==="contracts")return $m(t)}function Ks(e,t){if(e===void 0||!L(t))return t;let n=Mm(e,t),r=t.row_contract,o=Am(r)?r:Im(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 L(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 Nr(e){let t=e.trim().toLowerCase().startsWith("extension:"),n=e.trim().toLowerCase().replace(/^extension:/u,"");if(De(n))return;let r=Ds()?.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||De(i.command)||De(i.action)?void 0:i}function Lm(e){let t=Nr(e);return t?.read_output===void 0?void 0:t}function Hs(e,t){let n=Lm(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.",g.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}.`,g.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:Zt}:{},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]="03289358-031e-50aa-b94b-644697c4afc7")}catch{}})();var Dr={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"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},Pr=new Set(["--collapse","--fields","--section"]),en=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 tn(e){return e.slice(2).replaceAll("-","_")}function Ys(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 ye.includes(r)?r:void 0}function $r(e){return new Map((Dr[e]?.include??[]).filter(t=>!Pr.has(t)&&en[t]===void 0).map(t=>[tn(t),Mr(t)]))}function Mr(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]="ea19c980-44aa-54eb-b853-d829335e520e")}catch{}})();var nn="changed_fields",jm="changed_field_count",Lr="rows",Fm=new Set(["apply","rollback"]),Zs=new Set(["deleted","would_delete"]),Xs=256,Js={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function Um(e,t){if(!j(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(Js,e.action)?Js[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return j(s)&&j(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=ta(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,na(e[i],t)]))}}function Qs(e){return typeof e!="string"||e.length<=Xs?e:`${B(e,Xs-1)}\u2026`}function zm(e){if(!j(e))return null;let t={...e};return t.reason=Qs(t.reason),j(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,Qs(r)]))),t}function j(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function ea(e){let t=e[nn];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==nn&&(n[r]=o);return n[jm]=t.length,n}function qm(e){return"item"in e&&Array.isArray(e[nn])}function Bm(e){return typeof e.mode=="string"&&Fm.has(e.mode)&&Array.isArray(e[Lr])}function Vm(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[Lr]=t,n}function ta(e){if(!j(e))return null;let t=j(e.item)?e.item:j(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"&&Zs.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 Gm(e,t){if(!j(e))return null;if(j(e.plan)&&j(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||!j(e.item)||typeof e.item.id!="string")return null;let n=e[nn];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&Zs.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 Wm(e,e.item,r),r}function Wm(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=zm(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"])j(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","suggestions"])Object.hasOwn(e,i)&&(n[i]=e[i])}function Km(e){let t=Bm(e)?e[Lr]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!j(o))return o;let i=ea(o);return i?(n=!0,i):o});return n?{projected:Vm(e,r),changed:!0}:{projected:e,changed:!1}}function na(e,t={}){let n=Um(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=ta(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=Gm(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!j(e))return e;let r=!1,o=e,i=qm(e)?ea(e):null;i!==null&&(o=i,r=!0);let s=Km(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{AsyncLocalStorage as A_}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 ra=new Set(["--pm-path","--path","--author","--expect-hash","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),Hm=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function Ym(e){let t=e.indexOf("=");return t>0&&ra.has(e.slice(0,t))}function Xm(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function oa(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(ra.has(n)){t+=Xm(n,e[t+1])?1:0;continue}if(!(Ym(n)||Hm.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function CE(e){let t=oa(e);return t===void 0?void 0:e[t].trim().toLowerCase()}import Jm 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 ia=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)}"`},sa=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?ia(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,rn=(e,t=process.platform)=>{let n=e.map(r=>sa(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]="08181915-ead8-51bc-a078-9d97b9048f37")}catch{}})();var jr=new WeakMap;function $E(e){jr.set(e,e.path)}function Qm(e){if(!process.env.PM_PATH?.trim())return;let t=Bo(e);return tt(Vo(t),e)&&t===Wn(e)?void 0:Jm.relative(e,t)||"."}function ME(e,t=process.cwd()){let n=(jr.has(e)?jr.get(e):e.path)||Qm(t),r=n?["--pm-path",n]:[];return e.noExtensions&&r.push("--no-extensions"),r}import{createHash as dp}from"node:crypto";import{createHash as op}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]="b6db58d1-5d89-56b2-adee-13e985ebc675")}catch{}})();var Zm=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 R(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function aa(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(!R(n))return;n=n[r]}return n}function Fr(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 ca(e,t,n){let r=Fe(e).find(s=>s.path===t);if(!r)return e;let o=Array.isArray(r.value)?r.value.slice(n):Object.fromEntries(Object.entries(r.value).slice(n)),i=Fr(e,t,o);return R(i.summary)&&R(i.summary.focus_row_states)&&typeof i.summary.focus_row_states[t]=="string"&&(i.summary={...i.summary,focus_row_states:{...i.summary.focus_row_states,[t]:i.summary.focus_row_states[t].slice(n)}}),pt(i),i}function sn(e){let t=e.row_contract;return R(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 ep(e){let t=e.row_contract;return R(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):sn(e)}function de(e){return sn(e).flatMap(t=>{let n=aa(e,t);return Array.isArray(n)||R(n)?[{path:t,value:n}]:[]})}function Fe(e){return ep(e).flatMap(t=>{let n=aa(e,t);return Array.isArray(n)||R(n)?[{path:t,value:n}]:[]})}function ft(e){let t=de(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(R(o))for(let[s,a]of Object.entries(o))i.length===0&&Zm.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function an(e){return de(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function mt(e,t){let n=e;for(let r of de(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=Fr(n,r.path,o)}return n}function da(e,t){let n=e,r=!1;for(let o of de(n)){let i=Array.isArray(o.value)?o.value:Object.entries(o.value);if(i.length<=t)continue;r=!0;let s=Array.isArray(o.value)?i.slice(0,t):Object.fromEntries(i.slice(0,t));n=Fr(n,o.path,s)}return{result:n,truncated:r}}var la=["high_level","low_level","blocked_fallback"];function on(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function jE(e,t){if(!R(e.summary)||!R(e.summary.returned_focus))return;let n=new Map(t.map(r=>[r.id,r]));e.summary={...e.summary,focus_row_states:Object.fromEntries(la.map(r=>[r,Array.isArray(e[r])?e[r].filter(R).map(o=>on(n.get(o.id)??o)).join(""):""]))}}function tp(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 np(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(R):[],i=tp(r[n],o.length)??o.map(on).join(""),s=new Map(o.flatMap((d,l)=>d.id===void 0?[]:[[d.id,i[l]]])),a=Array.isArray(e[n])?e[n].filter(R):[],c=!1;return{states:a.map((d,l)=>{let f=s.get(d.id)??(d.id===void 0?i[l]:void 0)??on(d);return f!==on(d)&&(c=!0),f}).join(""),needsStates:c}}function rp(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 pt(e,t=e){if(rp(e,t),!R(e.summary)||!R(e.summary.returned_focus))return;let n={...e.summary},r=R(t.summary)&&R(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=la.map(c=>({key:c,...np(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]="f7f59eaa-9d5d-5797-99de-e672fdfba99d")}catch{}})();var ip=4096,sp=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"]),fa=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:sp}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function gt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _t(e){return Array.isArray(e)?e.map(_t):gt(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,_t(n)])):e}function ua(e,t){if(!gt(e))return _t(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||!gt(i)?[o,_t(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!r.includes(s)).map(([s,a])=>[s,_t(a)]))]))}function ap(e,t){return Array.isArray(e)?e.map(n=>ua(n,t)):ua(e,t)}function cn(e,t,n){let r=n?fa[n]:void 0,o=r?.paths.includes(e)===!0;return op("sha256").update(_e({path:e,value:o?ap(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function Ur(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint}),"utf8").toString("base64url")}function cp(e){return typeof e=="string"&&(Ue(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function yt(e){if(e.length>ip)throw new h("The read-output continuation cursor is malformed or unsupported.",g.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!gt(t)||t.v!==1||!cp(t.c)||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new h("The read-output continuation cursor is malformed or unsupported.",g.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function ma(e){if(!Array.isArray(e.assertions))return e;let t=n=>!gt(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 pa(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,g.USAGE,{code:"read_output_cursor_command_mismatch"});let r=Fe(e).find(i=>i.path===n.path),o=r?Array.isArray(r.value)?r.value.length:Object.keys(r.value).length:0;if(!r||o!==n.total_rows||n.offset>o||cn(n.path,r.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",g.USAGE,{code:"read_output_cursor_stale"});return ca(e,n.path,n.offset)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6a81cf4-3095-5197-8e73-f017d98b1ccf")}catch{}})();var qr=1,_a=4096,lp=/^[A-Za-z0-9_-]+$/;function zr(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function ZE(e,t){let n=[...Object.values(Ut),...zt],r=new Set(n.flatMap(o=>[zr(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){r.add(zr(o.flag));for(let i of o.aliases??[])r.add(zr(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!r.has(o)))}function ek(e,t){return dp("sha256").update(e).update("\0").update(_e(t)).digest("hex").slice(0,24)}function ht(e,t,n,r){return Buffer.from(JSON.stringify({version:qr,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function Se(e,t){return new h(e,g.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function up(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===qr&&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 Br(e,t="--after"){if(typeof e!="string")throw Se("Query cursor is malformed.",t);let n=e.trim();if(n.length===0||n.length>_a||!lp.test(n))throw Se("Query cursor is malformed.",t);let r;try{r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"))}catch{throw Se("Query cursor is malformed.",t)}if(!up(r)){let o=!1;try{yt(n),o=!0}catch{}throw o?new h(`An output cursor must be continued with --output-cursor, not ${t}.`,g.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${n}; retain any producer ${t} cursor from the original page.`]}):Se("Query cursor version or payload is unsupported.",t)}return r}function Vr(e,t,n="--after"){let r=Br(e,n);if(r.fingerprint!==t)throw Se(`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 tk(e,t){return Vr(e,t).after_id}function fp(e,t,n,r,o="--after"){if(t===void 0)return 0;let i=Vr(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 Se(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return s+1}function nk(e,t){if(t.cursor!==void 0&&Vr(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw Se("Query cursor does not match the requested snapshot.","--after");let n=fp(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:ht(t.fingerprint,t.readId(i),n+r.length-1,t.snapshot)}:{}}}var rk=Object.freeze({version:qr,max_length:_a});import{randomUUID as g_}from"node:crypto";import{randomUUID as f_}from"node:crypto";import{constants as Be}from"node:fs";import{lstat as za,mkdir as m_,open as Ba,rename as p_,rm as __}from"node:fs/promises";import wn from"node:path";import{constants as jp}from"node:fs";import P from"node:fs/promises";import G from"node:path";import{createHash as Fp,randomUUID as _n}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 ga(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import mp from"node:crypto";import{AsyncLocalStorage as pp}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 ha=new pp,ya=1024;function ba(){let e=ha.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 ck(e){let t=ha.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>ya)throw new Error(`Reproducible token length must be an integer between 0 and ${ya}`);let n="";for(;n.length<e;){let r=mp.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 _p=/^([+-]?)(\d+)([hdwm])$/i,gp=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,yp=/^(\d{4})(\d{2})(\d{2})$/,hp=/^(\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,wp=/^(\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(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function Kr(){return ba()??new Date().toISOString()}function pk(e){return Number.isFinite(Date.parse(e))}function Ep(e){let t=vp.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<=Hr(l,f-1)&&m<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function _k(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return Ep(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var kp=1e4,dn=new Map;function wa(e){let t=dn.get(e);if(t!==void 0)return t;let n=Date.parse(e);return dn.size>=kp&&ga(dn),dn.set(e,n),n}function ze(e,t){let n=wa(e),r=wa(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function gk(e,t){return!(t.deadlineBefore&&(!e.deadline||ze(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||ze(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&ze(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&ze(e.updated_at,t.updatedBefore)>0||t.createdAfter&&ze(e.created_at,t.createdAfter)<0||t.createdBefore&&ze(e.created_at,t.createdBefore)>0)}function Gr(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function Wr(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 Op(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function Sp(e){let t=[],n=d=>Op(t,e,d),r=yp.exec(e);if(r){let[,d,l,f]=r;n(`${d}-${l}-${f}`)}let o=hp.exec(e);if(o){let[,d,l,f,u,m,p,_,y]=o,b=p?`:${p}`:"";n(`${d}-${l}-${f}T${u}:${m}${b}${Gr(_)}${Wr(y)}`)}let i=bp.exec(e);if(i){let[,d,l,f,u,m,p]=i,_=u?`:${u}`:"";n(`${d}T${l}:${f}${_}${Gr(m)}${Wr(p)}`)}let s=wp.exec(e);if(s){let[,d,l,f,u,m,p]=s,_=u?`:${u}`:"";n(`${d}T${l}:${f}${_}${Gr(m)}${Wr(p)}`)}let a=10,c=e.slice(0,a);if(Cp(c)){let d=a;for(;d<e.length&&Tp(e[d]);)d+=1;d<e.length&&n(`${c}T${e.slice(d)}`)}return t}function Ap(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of Sp(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function Cp(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 Tp(e){return e?e===" "||e===" "||e===`
7
+ Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,u=js(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}${ke(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:Oe(Buffer.byteLength(p,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}var xr=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 iE(e){return e?.trim()===xr.required}function sE(e){let t=e?.trim();return t!==void 0&&xr.why.includes(t)}function aE(e){return(e??[]).filter(t=>!xr.examples.includes(t.trim()))}var cE=Object.freeze(["attempted_command","normalized_args","provided_fields"]);function dE(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]="3a66ccfd-51fb-5d4a-b9cd-257c49997d52")}catch{}})();var Ws=new WeakMap;function mE(e,t){Ws.set(e,new Set(t))}var Zt='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',wm={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 pE(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,g.USAGE)}function K(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 _E(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 K([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return K(r)}var Em=[{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 L(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var km=new Set([void 0,"tabular_when_uniform"]),Om=new Set(["collection","none"]),Sm=new Set(["supported","unsupported"]);function Vs(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 Am(e){return L(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Om.has(e.row_kind)&&Vs(e.row_keys,!0)&&(e.continuation_row_keys===void 0||Vs(e.continuation_row_keys,!1))&&Sm.has(e.fields)&&km.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 Cm={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"]},Tm={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 Im(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=Cm[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||L(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Zt}:{},toon_encoding:"tabular_when_uniform"}}let o=wm[r],i=Tm[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)=>L(d)?d[l]:void 0,t);return Array.isArray(c)||L(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:Zt}:{},toon_encoding:"tabular_when_uniform"}})()}function Rm(e){if(!L(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=>L(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 K(r,new Set(o))}function xm(e){if(!Array.isArray(e.sections_included))return;let t=K(Em,new Set(e.sections_included.filter(n=>typeof n=="string")));return L(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function Nm(e,t,n){return e==="dependency_provenance"?!1:Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&L(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&L(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function Dm(e){if(!L(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=Ws.get(e),i=a=>n.includes(a)||a==="body"||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"]:[]].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 K(s,new Set(s.flatMap(({name:a})=>Nm(a,i(a),e)?[a]:[])))}function Gs(e){if(L(e.projection))return K([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function Pm(e){if(!L(e.projection))return K([]);if(typeof e.projection.mode=="string")return K([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function $m(e){if(!(!L(e.selected)||typeof e.selected.summary!="boolean"))return K([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function Mm(e,t){let n=Rm(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return xm(t);if(r==="get")return Dm(t);if(r==="list"||r.startsWith("list-"))return Gs(t);if(r==="search")return Gs(t)??K([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return Pm(t);if(r==="contracts")return $m(t)}function Ks(e,t){if(e===void 0||!L(t))return t;let n=Mm(e,t),r=t.row_contract,o=Am(r)?r:Im(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 L(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 Nr(e){let t=e.trim().toLowerCase().startsWith("extension:"),n=e.trim().toLowerCase().replace(/^extension:/u,"");if(De(n))return;let r=Ds()?.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||De(i.command)||De(i.action)?void 0:i}function Lm(e){let t=Nr(e);return t?.read_output===void 0?void 0:t}function Hs(e,t){let n=Lm(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.",g.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}.`,g.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:Zt}:{},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]="03289358-031e-50aa-b94b-644697c4afc7")}catch{}})();var Dr={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"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},Pr=new Set(["--collapse","--fields","--section"]),en=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 tn(e){return e.slice(2).replaceAll("-","_")}function Ys(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 ye.includes(r)?r:void 0}function $r(e){return new Map((Dr[e]?.include??[]).filter(t=>!Pr.has(t)&&en[t]===void 0).map(t=>[tn(t),Mr(t)]))}function Mr(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 nn="changed_fields",jm="changed_field_count",Lr="rows",Fm=new Set(["apply","rollback"]),Zs=new Set(["deleted","would_delete"]),Xs=256,Js={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function Um(e,t){if(!j(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(Js,e.action)?Js[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return j(s)&&j(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=ta(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,na(e[i],t)]))}}function Qs(e){return typeof e!="string"||e.length<=Xs?e:`${B(e,Xs-1)}\u2026`}function zm(e){if(!j(e))return null;let t={...e};return t.reason=Qs(t.reason),j(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,Qs(r)]))),t}function j(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function ea(e){let t=e[nn];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==nn&&(n[r]=o);return n[jm]=t.length,n}function qm(e){return"item"in e&&Array.isArray(e[nn])}function Bm(e){return typeof e.mode=="string"&&Fm.has(e.mode)&&Array.isArray(e[Lr])}function Vm(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[Lr]=t,n}function ta(e){if(!j(e))return null;let t=j(e.item)?e.item:j(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"&&Zs.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 Gm(e,t){if(!j(e))return null;if(j(e.plan)&&j(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||!j(e.item)||typeof e.item.id!="string")return null;let n=e[nn];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&Zs.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 Wm(e,e.item,r),r}function Wm(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=zm(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"])j(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 Km(e){let t=Bm(e)?e[Lr]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!j(o))return o;let i=ea(o);return i?(n=!0,i):o});return n?{projected:Vm(e,r),changed:!0}:{projected:e,changed:!1}}function na(e,t={}){let n=Um(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=ta(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=Gm(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!j(e))return e;let r=!1,o=e,i=qm(e)?ea(e):null;i!==null&&(o=i,r=!0);let s=Km(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{AsyncLocalStorage as A_}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 ra=new Set(["--pm-path","--path","--author","--expect-hash","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),Hm=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function Ym(e){let t=e.indexOf("=");return t>0&&ra.has(e.slice(0,t))}function Xm(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function oa(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(ra.has(n)){t+=Xm(n,e[t+1])?1:0;continue}if(!(Ym(n)||Hm.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function CE(e){let t=oa(e);return t===void 0?void 0:e[t].trim().toLowerCase()}import Jm 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 ia=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)}"`},sa=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?ia(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,rn=(e,t=process.platform)=>{let n=e.map(r=>sa(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]="08181915-ead8-51bc-a078-9d97b9048f37")}catch{}})();var jr=new WeakMap;function $E(e){jr.set(e,e.path)}function Qm(e){if(!process.env.PM_PATH?.trim())return;let t=Bo(e);return tt(Vo(t),e)&&t===Wn(e)?void 0:Jm.relative(e,t)||"."}function ME(e,t=process.cwd()){let n=(jr.has(e)?jr.get(e):e.path)||Qm(t),r=n?["--pm-path",n]:[];return e.noExtensions&&r.push("--no-extensions"),r}import{createHash as dp}from"node:crypto";import{createHash as op}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]="b6db58d1-5d89-56b2-adee-13e985ebc675")}catch{}})();var Zm=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 R(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function aa(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(!R(n))return;n=n[r]}return n}function Fr(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 ca(e,t,n){let r=Fe(e).find(s=>s.path===t);if(!r)return e;let o=Array.isArray(r.value)?r.value.slice(n):Object.fromEntries(Object.entries(r.value).slice(n)),i=Fr(e,t,o);return R(i.summary)&&R(i.summary.focus_row_states)&&typeof i.summary.focus_row_states[t]=="string"&&(i.summary={...i.summary,focus_row_states:{...i.summary.focus_row_states,[t]:i.summary.focus_row_states[t].slice(n)}}),pt(i),i}function sn(e){let t=e.row_contract;return R(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 ep(e){let t=e.row_contract;return R(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):sn(e)}function de(e){return sn(e).flatMap(t=>{let n=aa(e,t);return Array.isArray(n)||R(n)?[{path:t,value:n}]:[]})}function Fe(e){return ep(e).flatMap(t=>{let n=aa(e,t);return Array.isArray(n)||R(n)?[{path:t,value:n}]:[]})}function ft(e){let t=de(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(R(o))for(let[s,a]of Object.entries(o))i.length===0&&Zm.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function an(e){return de(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function mt(e,t){let n=e;for(let r of de(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=Fr(n,r.path,o)}return n}function da(e,t){let n=e,r=!1;for(let o of de(n)){let i=Array.isArray(o.value)?o.value:Object.entries(o.value);if(i.length<=t)continue;r=!0;let s=Array.isArray(o.value)?i.slice(0,t):Object.fromEntries(i.slice(0,t));n=Fr(n,o.path,s)}return{result:n,truncated:r}}var la=["high_level","low_level","blocked_fallback"];function on(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function jE(e,t){if(!R(e.summary)||!R(e.summary.returned_focus))return;let n=new Map(t.map(r=>[r.id,r]));e.summary={...e.summary,focus_row_states:Object.fromEntries(la.map(r=>[r,Array.isArray(e[r])?e[r].filter(R).map(o=>on(n.get(o.id)??o)).join(""):""]))}}function tp(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 np(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(R):[],i=tp(r[n],o.length)??o.map(on).join(""),s=new Map(o.flatMap((d,l)=>d.id===void 0?[]:[[d.id,i[l]]])),a=Array.isArray(e[n])?e[n].filter(R):[],c=!1;return{states:a.map((d,l)=>{let f=s.get(d.id)??(d.id===void 0?i[l]:void 0)??on(d);return f!==on(d)&&(c=!0),f}).join(""),needsStates:c}}function rp(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 pt(e,t=e){if(rp(e,t),!R(e.summary)||!R(e.summary.returned_focus))return;let n={...e.summary},r=R(t.summary)&&R(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=la.map(c=>({key:c,...np(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]="f7f59eaa-9d5d-5797-99de-e672fdfba99d")}catch{}})();var ip=4096,sp=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"]),fa=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:sp}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function gt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _t(e){return Array.isArray(e)?e.map(_t):gt(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,_t(n)])):e}function ua(e,t){if(!gt(e))return _t(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||!gt(i)?[o,_t(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!r.includes(s)).map(([s,a])=>[s,_t(a)]))]))}function ap(e,t){return Array.isArray(e)?e.map(n=>ua(n,t)):ua(e,t)}function cn(e,t,n){let r=n?fa[n]:void 0,o=r?.paths.includes(e)===!0;return op("sha256").update(_e({path:e,value:o?ap(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function Ur(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint}),"utf8").toString("base64url")}function cp(e){return typeof e=="string"&&(Ue(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function yt(e){if(e.length>ip)throw new h("The read-output continuation cursor is malformed or unsupported.",g.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!gt(t)||t.v!==1||!cp(t.c)||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new h("The read-output continuation cursor is malformed or unsupported.",g.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function ma(e){if(!Array.isArray(e.assertions))return e;let t=n=>!gt(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 pa(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,g.USAGE,{code:"read_output_cursor_command_mismatch"});let r=Fe(e).find(i=>i.path===n.path),o=r?Array.isArray(r.value)?r.value.length:Object.keys(r.value).length:0;if(!r||o!==n.total_rows||n.offset>o||cn(n.path,r.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",g.USAGE,{code:"read_output_cursor_stale"});return ca(e,n.path,n.offset)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6a81cf4-3095-5197-8e73-f017d98b1ccf")}catch{}})();var qr=1,_a=4096,lp=/^[A-Za-z0-9_-]+$/;function zr(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function ZE(e,t){let n=[...Object.values(Ut),...zt],r=new Set(n.flatMap(o=>[zr(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){r.add(zr(o.flag));for(let i of o.aliases??[])r.add(zr(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!r.has(o)))}function ek(e,t){return dp("sha256").update(e).update("\0").update(_e(t)).digest("hex").slice(0,24)}function ht(e,t,n,r){return Buffer.from(JSON.stringify({version:qr,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function Se(e,t){return new h(e,g.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function up(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===qr&&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 Br(e,t="--after"){if(typeof e!="string")throw Se("Query cursor is malformed.",t);let n=e.trim();if(n.length===0||n.length>_a||!lp.test(n))throw Se("Query cursor is malformed.",t);let r;try{r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"))}catch{throw Se("Query cursor is malformed.",t)}if(!up(r)){let o=!1;try{yt(n),o=!0}catch{}throw o?new h(`An output cursor must be continued with --output-cursor, not ${t}.`,g.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${n}; retain any producer ${t} cursor from the original page.`]}):Se("Query cursor version or payload is unsupported.",t)}return r}function Vr(e,t,n="--after"){let r=Br(e,n);if(r.fingerprint!==t)throw Se(`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 tk(e,t){return Vr(e,t).after_id}function fp(e,t,n,r,o="--after"){if(t===void 0)return 0;let i=Vr(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 Se(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return s+1}function nk(e,t){if(t.cursor!==void 0&&Vr(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw Se("Query cursor does not match the requested snapshot.","--after");let n=fp(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:ht(t.fingerprint,t.readId(i),n+r.length-1,t.snapshot)}:{}}}var rk=Object.freeze({version:qr,max_length:_a});import{randomUUID as g_}from"node:crypto";import{randomUUID as f_}from"node:crypto";import{constants as Be}from"node:fs";import{lstat as za,mkdir as m_,open as Ba,rename as p_,rm as __}from"node:fs/promises";import wn from"node:path";import{constants as jp}from"node:fs";import P from"node:fs/promises";import G from"node:path";import{createHash as Fp,randomUUID as _n}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 ga(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import mp from"node:crypto";import{AsyncLocalStorage as pp}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 ha=new pp,ya=1024;function ba(){let e=ha.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 ck(e){let t=ha.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>ya)throw new Error(`Reproducible token length must be an integer between 0 and ${ya}`);let n="";for(;n.length<e;){let r=mp.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 _p=/^([+-]?)(\d+)([hdwm])$/i,gp=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,yp=/^(\d{4})(\d{2})(\d{2})$/,hp=/^(\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,wp=/^(\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(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function Kr(){return ba()??new Date().toISOString()}function pk(e){return Number.isFinite(Date.parse(e))}function Ep(e){let t=vp.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<=Hr(l,f-1)&&m<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function _k(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return Ep(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var kp=1e4,dn=new Map;function wa(e){let t=dn.get(e);if(t!==void 0)return t;let n=Date.parse(e);return dn.size>=kp&&ga(dn),dn.set(e,n),n}function ze(e,t){let n=wa(e),r=wa(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function gk(e,t){return!(t.deadlineBefore&&(!e.deadline||ze(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||ze(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&ze(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&ze(e.updated_at,t.updatedBefore)>0||t.createdAfter&&ze(e.created_at,t.createdAfter)<0||t.createdBefore&&ze(e.created_at,t.createdBefore)>0)}function Gr(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function Wr(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 Op(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function Sp(e){let t=[],n=d=>Op(t,e,d),r=yp.exec(e);if(r){let[,d,l,f]=r;n(`${d}-${l}-${f}`)}let o=hp.exec(e);if(o){let[,d,l,f,u,m,p,_,y]=o,b=p?`:${p}`:"";n(`${d}-${l}-${f}T${u}:${m}${b}${Gr(_)}${Wr(y)}`)}let i=bp.exec(e);if(i){let[,d,l,f,u,m,p]=i,_=u?`:${u}`:"";n(`${d}T${l}:${f}${_}${Gr(m)}${Wr(p)}`)}let s=wp.exec(e);if(s){let[,d,l,f,u,m,p]=s,_=u?`:${u}`:"";n(`${d}T${l}:${f}${_}${Gr(m)}${Wr(p)}`)}let a=10,c=e.slice(0,a);if(Cp(c)){let d=a;for(;d<e.length&&Tp(e[d]);)d+=1;d<e.length&&n(`${c}T${e.slice(d)}`)}return t}function Ap(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of Sp(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function Cp(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 Tp(e){return e?e===" "||e===" "||e===`
8
8
  `||e==="\r"||e==="\f"||e==="\v":!1}function Hr(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var Ip=["January","February","March","April","May","June","July","August","September","October","November","December"],Rp=/^(\d{4})-(\d{2})-(\d{2})/,xp=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function Np(e,t,n){let r=Rp.exec(t)??xp.exec(t);if(!r)return;let o=Number.parseInt(r[1],10),i=Number.parseInt(r[2],10),s=Number.parseInt(r[3],10),a=n?.trim()||"deadline";if(i<1||i>12)throw new h(`Invalid ${a} value "${e}". Month "${r[2]}" is out of range \u2014 use a month between 01 and 12.`,g.USAGE,{field:a,value:e});let c=Hr(o,i-1);if(s<1||s>c)throw new h(`Invalid ${a} value "${e}". ${Ip[i-1]} ${o} has ${c} days, so day "${r[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,g.USAGE,{field:a,value:e})}function Dp(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,Hr(i,s));return n.setUTCFullYear(i,s,a),n}function yk(e,t=new Date,n="deadline"){let r=e.trim();if(r.toLowerCase()==="now")return t.toISOString();let o=_p.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 Dp(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()}Np(e,r,n);let i=Ap(r);if(!Number.isFinite(i)){let s=n.trim().length>0?n.trim():"deadline",a=gp.test(r)?"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.":'Use ISO/date string input, "now", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';throw new h(`Invalid ${s} value "${e}". ${a}`,g.USAGE,{field:s,value:e})}return new Date(i).toISOString()}import ln from"node:fs/promises";import V 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 Ea="lock_path_unsafe";function Pp(e,t){return V.relative(e,t).split(V.sep).join("/")}function $p(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 bt(e){let t=e.component??V.dirname(e.lockPath),n=Pp(e.pmRoot,t);return new h(`Refused to acquire lock ${e.id}: ${n} is not a real directory inside the tracker (${e.reason}). Locks are never created through a symlinked or replaced lock directory.`,g.CONFLICT,{code:"lock_path_unsafe",item_id:e.id,reason:e.reason,lock_component:n,required:$p(e.reason,n)})}function va(e,t){return e.dev===t.dev&&e.ino===t.ino}async function un(e,t,n,r=!0){let o=V.resolve(e),i=V.dirname(V.resolve(t)),s=V.relative(o,i);if(s===".."||s.startsWith(`..${V.sep}`)||V.isAbsolute(s))throw bt({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(V.sep)){a=V.join(a,l);let f;try{f=await ln.lstat(a,{bigint:!0})}catch(u){if(r&&Y(u))return null;throw u}if(f.isSymbolicLink())throw bt({pmRoot:o,lockPath:t,id:n,reason:"lock_directory_symlink",component:a});if(!f.isDirectory())throw bt({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 ln.stat(o,{bigint:!0});return{dev:d.dev,ino:d.ino}}async function ka(e,t,n){let r;try{r=await ln.lstat(t)}catch{return}if(r.isSymbolicLink())throw bt({pmRoot:e,lockPath:t,id:n,reason:"lock_entry_symlink",component:t})}async function Oa(e){let t=await e.handle.stat({bigint:!0}),n={dev:t.dev,ino:t.ino},r=!1;try{let o=await un(e.pmRoot,e.lockPath,e.id,!1);if(va(e.directory,o)){let i=await ln.lstat(e.lockPath,{bigint:!0});r=!i.isSymbolicLink()&&va(n,i)}}catch{r=!1}if(!r)throw bt({pmRoot:e.pmRoot,lockPath:e.lockPath,id:e.id,reason:"lock_directory_replaced"})}import Yr from"node:fs/promises";import{createHash as Mp}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 Sa(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function Lp(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!Sa(t,"ESRCH")}}function Aa(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 qe(e){try{return Aa(await Yr.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function Xr(e=process.pid){let t=await qe(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function Jr(e,t,n){if(!Lp(e.pid))return!1;let r=await qe(e.pid);return e.process_start_identity!==void 0&&r!==null?r===e.process_start_identity:t<=n}async function Ca(){try{let[e,t]=await Promise.all([Yr.readFile("/proc/sys/kernel/random/boot_id","utf8"),Yr.readlink("/proc/self/ns/pid")]);return!/^[a-f0-9-]{36}\s*$/u.test(e)||!/^pid:\[\d+\]$/u.test(t)?null:Mp("sha256").update(`${e.trim()}:${t}`).digest("hex")}catch{return null}}async function Qr(){let[e,t]=await Promise.all([Ca(),qe(process.pid)]);return e!==null&&t!==null?{host_identity:e,process_start_identity:t}:{}}async function fn(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 Ca();if(t===null||t!==e.host_identity)return"unknown";try{process.kill(e.pid,0)}catch(r){return Sa(r,"ESRCH")?"dead":"unknown"}let n=await qe(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]="7f116073-a02b-568b-a408-17c0fcc8b4a4")}catch{}})();function Up(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 Ae(e,t=!0){try{let n=await P.readFile(e,"utf8");return t&&await $s({path:e,scope:"project"}),Up(n)}catch(n){return Y(n)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function le(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function zp(e,t,n=process.platform){if(le(e,"EEXIST"))return!0;if(!le(e,"EPERM")&&!le(e,"EACCES")&&!le(e,"EBUSY"))return!1;try{return await P.lstat(t),!0}catch(r){if(n!=="win32"||!Y(r)&&!le(r,"EPERM")&&!le(r,"EACCES")&&!le(r,"EBUSY"))return!1}try{return await P.access(G.dirname(t),jp.W_OK),!0}catch{return!1}}async function Na(e,t){await Ps({path:e,scope:"project",op:t})}async function qp(e,t,n,r=_n()){return{...await Qr(),id:e,pid:process.pid,owner:t,token:r,created_at:Kr(),ttl_seconds:n}}async function Bp(e,t,n,r,o,i,s){let a=await un(e,t,n);s&&a===null&&await P.mkdir(G.dirname(t),{recursive:!0});let c=await bn(t,n);if(c===null)throw await P.access(G.dirname(t)),Object.assign(new Error("Lock initialization is contended"),{code:"EEXIST"});let d;try{let l=await un(e,t,n,!1),f=await P.open(t,"wx");try{await Oa({pmRoot:e,lockPath:t,id:n,handle:f,directory:l})}catch(u){throw await f.close(),u}try{try{let u=await qp(n,r,o,i);d=u.created_at,await f.writeFile(`${JSON.stringify(u,null,2)}
9
9
  `,"utf8")}finally{await f.close()}}catch(u){throw await to(t,"lock:release"),u}}finally{await c()}return await Na(t,"lock:create"),d}async function to(e,t){try{return await P.unlink(e),await Na(e,t),!0}catch{return!1}}async function Vp(e,t,n,r){let o=performance.now(),i=gn;for(;;){let s=await bn(e,t);if(s!==null){try{let d=await Ae(e,!1);Zr(d.info,t,n,r)&&await to(e,"lock:release")}finally{await s()}return}let a=await Ae(e,!1);if(!Zr(a.info,t,n,r))return;let c=performance.now()-o;if(c>=mn)return;await hn(Math.min(i,mn-c)),i=Math.min(i*2,yn)}}function Zr(e,t,n,r){return e?.id===t&&e.pid===process.pid&&e.owner===n&&e.token===r}function Da(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 Pa(e){return e!==null&&Number.isFinite(Date.parse(e.created_at))&&await fn(e)==="dead"}async function $a(e,t){return Da(e,t)||await Pa(e)}async function qk(e,t,n){let{info:r}=await Ae(Kn(e,t),!1);return r!==null&&r.owner.startsWith(n)&&!await $a(r,r.ttl_seconds)}function Gp(e){return e?.owner?` (owner ${e.owner})`:""}var gn=25,yn=200,Ma=250,Wp=12e4,Kp=3,Hp=".stale-cleanup",La="owner.json",ja=1e4,mn=ja+yn;function eo(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 Yp(e){let t=process.env.PM_LOCK_WAIT_MS,n=eo(t);if(n!==void 0)return n;let r=eo(e);return r!==void 0?r:0}function Xp(e,t){return Math.min(Yp(e),t??1/0)}function hn(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(n=>setTimeout(n,t))}async function Fa(e,t,n,r=0){n=Math.floor(n);let o=await fn(t),i=r>0?` across ${r} owner handoff(s)`:"",s=n>0?` after waiting ${n}ms${i}`:"";return new h(`Item ${e} is locked${Gp(t)} (owner process ${o})${s}`,g.CONFLICT,{code:"lock_conflict",item_id:e,reason:`lock_owner_${o}`,required:"Wait for the owner to release the lock, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget when contention is expected. Inspect stale receipts with pm gc --scope locks --dry-run.",recovery:{retry_after_ms:Ma,...n>0?{waited_ms:n,owner_handoffs:r}:{}}})}function Jp(e,t){let n=performance.now(),r=n,o,i=0;return{startedAtMs:n,observe(s){let a=performance.now(),c=Zp(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 Qp(e,t,n){return n!=="progress"||t!==void 0?e:Math.max(e,Wp)}function Zp(e){return e===null?"released":e.token??`${e.pid}:${e.owner}:${e.created_at}`}function e_(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 t_(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 Ta(e,t,n,r){let{summary:o,required:i}=t_(e,t,n,r);return new h(`${o} Nothing was written.`,g.CONFLICT,{code:"lock_lost",item_id:e,reason:r,lease:e_(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:Ma}})}async function n_(e,t){let n=performance.now(),r=gn;for(;;){let o=await bn(e,t);if(o!==null)return o;let i=performance.now()-n;if(i>=mn)return null;await hn(Math.min(r,mn-i)),r=Math.min(r*2,yn)}}async function r_(e,t,n,r){let o=await n_(e,t);if(o===null){let i=await Ae(e,!1);throw Ta(t,n,i.info,"fence_gate_unavailable")}try{let i=await Ae(e,!1);if(!Zr(i.info,t,n.owner,n.token))throw Ta(t,n,i.info,i.info===null?"lease_released":"lease_taken_over");return await r()}finally{await o()}}function o_(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`,g.CONFLICT)}}function s_(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 pn(e){try{return s_(await P.readFile(G.join(e,La),"utf8"))}catch(t){return Y(t)?null:void 0}}async function no(e){try{return await P.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function Ia(e,t){let n=await pn(e);for(let r=0;n===void 0&&r<3;r+=1)await hn(gn),n=await pn(e);!n||n.token!==t||await no(e)}async function Ra(e){try{await P.mkdir(e)}catch(n){return le(n,"EEXIST"),null}let t={...await Xr(),host_identity:(await Qr()).host_identity,token:_n()};try{await P.writeFile(G.join(e,La),`${JSON.stringify(t)}
10
10
  `,"utf8")}catch{return await no(e),null}return t}async function xa(e,t){let n=G.join(G.dirname(e),"recoveries"),r=Fp("sha256").update(t).digest("hex");try{return await P.mkdir(n,{recursive:!0}),(await pn(e))?.token!==t?!1:(await P.rename(e,G.join(n,`gate-${r}`)),!0)}catch{return!1}}async function a_(e){let t;try{let r=await P.stat(e);t=Date.now()-r.mtimeMs}catch(r){return Y(r)}let n=await pn(e);if(n===void 0)return!1;if(n!==null){if(await fn(n)==="dead")return xa(e,n.token);if(n.host_identity!==void 0)return!1}return t<=ja||n!==null&&await Jr(n,t,Number.POSITIVE_INFINITY)?!1:n!==null?xa(e,n.token):no(e)}async function bn(e,t){let n=`${e}${Hp}`,r=await Ra(n);if(r!==null)return async()=>Ia(n,r.token);if(!await a_(n))return null;let o=await Ra(n);return o===null?null:async()=>Ia(n,o.token)}async function c_(e,t){let n=G.join(G.dirname(e),"recoveries");await P.mkdir(n,{recursive:!0}),await P.writeFile(G.join(n,`${_n()}.json`),`${JSON.stringify({event:"owner_dead_recovery_attempt",recorded_at:Kr(),lock:JSON.parse(t)})}
@@ -22,5 +22,5 @@ ${gc(t,n+1)}`}function yg(e,t,n){let r=e.map(o=>Tn(o,t,n||t.preserveRowFacts&&F(
22
22
  `:`${gc(r,0)}
23
23
  `}function K0(e){let t=Ls("error_format",{message:e}),n=t.handled&&typeof t.result=="string"?t.result:e;pg(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]="13e57322-501d-5927-8254-f6196854d434")}catch{}})();var Eg=8,kg=64,Og=5,Sg=4,hc=100;function bc(e,t,n){if(e!=="get"||!po(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=[...po(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 go(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*Og/Sg),i=Math.ceil(o/hc)*hc;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 Ke(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 vt(e,t){let n=t===void 0?JSON.stringify(e):yc(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function po(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _o(e,t,n=!1){return typeof e=="string"?n||e.length<=240?e:(t.compacted=!0,`${B(e,240)}\u2026`):Array.isArray(e)?e.map(r=>_o(r,t,n)):po(e)?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,_o(o,t,n||r==="focus_row_states")])):e}function me(e,t,n){let r=t.estimated_tokens;for(let o=0;o<Eg;o+=1){t.estimated_tokens=r;let i=vt(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function Ag(e,t){return ft(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 Cg(e,t,n,r,o,i){for(let s=0;s<kg;s+=1){if(i?.(e),me(e,t,o),t.estimated_tokens<=n)return;let a=Ag(e,r);if(!a)return;let c=Math.max(1,r.get(a.path)??0),d=Array.isArray(a.value)?[...a.value]:Object.entries(a.value),l=p=>{if(Array.isArray(a.value)){a.value.length=p;for(let _=0;_<p;_+=1)a.value[_]=d[_]}else{for(let _ of Object.keys(a.value))delete a.value[_];Object.defineProperties(a.value,Object.getOwnPropertyDescriptors(Object.fromEntries(d.slice(0,p))))}typeof e.count=="number"&&(e.count=an(e)),a.path==="items"&&(e.applied_limit=p),i?.(e),me(e,t,o)};t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],a.path])].sort((p,_)=>p.localeCompare(_)),e.has_more=!0,e.truncated=!0;let f=c,u=d.length-1,m=c;for(;f<=u;){let p=Math.floor((f+u)/2);l(p),t.estimated_tokens<=n?(m=p,f=p+1):u=p-1}l(m)}}function wc(e,t,n,r=new Map,o,i,s=!1){let a={compacted:!1},c=Object.fromEntries(Object.entries(e).map(([d,l])=>[d,_o(l,a,s&&d==="diff")]));return Ke(e,c),t.strings_compacted=a.compacted,c.read_output=t,Cg(c,t,n,r,o,i),me(c,t,o),c}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="24a8de41-54f9-5b59-8e58-7ac924ba6e08")}catch{}})();function rO(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 yo=256,ho=1e4,Tg=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,vc=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Ig=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),Rg=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&Tg.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=yo,reason:`token_budget must be a safe integer of at least ${yo}.`},{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<=ho&&e.seen_item_ids.every(t=>typeof t=="string"&&vc.test(t)),reason:`seen_item_ids must contain at most ${ho} portable item identifiers.`}];function Rn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function In(e){throw new h(`--output-session ${e}`,g.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function xn(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{In("must be a valid JSON object.")}Rn(t)||In("must be a JSON object.");let n=Object.keys(t).filter(i=>!Ig.has(i));n.length>0&&In(`contains unknown field "${n.sort()[0]}".`);let r=Rg.find(i=>!i.valid(t));r!==void 0&&In(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 Ec(e){if(Rn(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:Rn(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function xg(e){let t=new Set,n=0,r=de(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(!Rn(c))continue;if(typeof c.context_ref=="string"){n+=1;continue}let d=Ec(c);d!==void 0&&vc.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:n}}function kc(e,t){let n=new Set(t.seen_item_ids);return mt(e,r=>{let o=Ec(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function bo(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=xg(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,ho-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<yo,l.next_state.spent_tokens=l.spent_total_tokens},m=0,p=0;for(let _=0;_<8;_+=1){u(m);let y=vt(f,n);if(y===m)return f;p=Math.max(p,y),m=y}return u(p),f}function Oc(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 Et=Symbol.for("pm.readOutputInvocationProvenance");function iO(e,t){return Reflect.set(e,Et,{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]="dd173d3c-f3da-53f3-b24c-118364961db7")}catch{}})();var Te=["include","amount","cost","encoding"],Rc=["canonical","legacy","intent","default"],Ot=Ut,kO=Object.freeze(Te.map(e=>Ot[e])),OO=zt;function Ng(e,t){let n=en[e];if(n!==void 0)return n;let r=t==="include"?Pr.has(e)?"<csv>":tn(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${Ot[t]} ${r}.`}function xc(e){let t=Dr[e]??{},n=Object.freeze(Object.fromEntries(Te.map(r=>[r,Object.freeze({dimension:r,canonical_option:Ot[r],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[r]??[]).map(o=>Object.freeze({flag:o,semantics:en[o]===void 0?"replacement":"behavior_preserving",migration_hint:Ng(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:Rc,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...$r(e).keys()])})}var Dg=Object.freeze(ye.map(xc)),Pg=new Map(Dg.map(e=>[e.command,e]));function Ue(e,t={}){let n=Ze(e.trim().toLowerCase()),r=Nr(n);return r!==void 0?r.read_output===void 0?void 0:`extension:${r.command}`:Ys(n,t)}var $g=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],Mg={comments:["add","body","stdin","file","edit","delete"],notes:["add","addJson","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function Lg(e){return $g.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var jg=[{keys:["outputInclude","output_include"],valid:e=>kt(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||He(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||He(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(xn(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 SO(e,t){let n=t.outputFormat??t.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new h("--output-format must be toon or json.",g.USAGE);if(!Lg(t))return;let r=Ue(e,t);if(!r)throw new h(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,g.USAGE);if((Mg[r]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new h(`Universal output controls cannot be combined with a ${r} mutation.`,g.USAGE);for(let o of jg){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new h(o.message,g.USAGE)}}function Nc(e){let t=Ue(e);return t?$r(t):new Map}function Fg(e,t,n){let r=kt(t)??[],o=Nc(e),i=[],s=[],a=n,c=a[Et],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("_","-")}`;vo(wo(n,_))&&l.add(_),n[p]=!0,s.push(m),d.add(m)}let f=Ue(e)==="get"?i.filter(m=>m!=="item"):[],u=f.length>0;return u&&(n.fields=[...new Set([...kt(n.fields)??[],...f])].join(","),d.add("fields")),(s.length>0||u)&&(a[Et]={canonical_include_modes:[...d],explicit_legacy_aliases:[...l],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function AO(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=Fg(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 wo(e,t){let n=Mr(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 vo(e){return e!==void 0&&e!==!1&&e!==null}function kt(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 He(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 Ug(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=wo(t,o.flag),s={value:i,flag:o.flag};if(vo(i)&&n(s))return s}}function Sc(e,t){let n=kt(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:kt(t.value)??[tn(t.flag)]}}function Ac(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=He(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=He(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function Cc(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=He(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let r=He(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function Tc(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 Dc(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 zg(e,t,n,r){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||vo(wo(r,"--no-truncate"))&&!Dc(n,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function qg(e,t){return Te.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[Ot[n]]:[])}function Pc(e,t){let n=Ue(e,t);if(!n)return;let r=Pg.get(n)??xc(n),o=t[Et],i={include:b=>Sc(void 0,b),amount:b=>Ac(void 0,b),cost:b=>Cc(void 0,b),encoding:b=>Tc(void 0,b)},s=Object.fromEntries(Te.map(b=>[b,Ug(r.dimensions[b],t,k=>i[b](k)!==void 0,k=>Dc(o,b,k))])),a=Te.flatMap(b=>{let k=s[b];return k?[k.flag]:[]}),c=Te.flatMap(b=>{let k=s[b];return k?[r.dimensions[b].legacy_aliases.find(U=>U.flag===k.flag).migration_hint]:[]}),d=Tc(t.outputFormat??t.output_format,s.encoding),l=Sc(t.outputInclude??t.output_include,s.include),f=Ac(t.outputLimit??t.output_limit,s.amount),u=Cc(t.outputBudget??t.output_budget,s.cost),m=zg(e,s,o,t),p=zs(e,{generateFallback:!0}),_=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",y=u??(m?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:l,amount:f,cost:y,encoding:d,canonical_options_used:qg({include:l,amount:f,cost:y,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:Rc}}function N(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Eo=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"]),Bg=["collection_counts","notes_count","tests_count"];function $c(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function Vg(e){let t=N(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...Bg.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!Eo.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 Gg(e,t){let n=Vg(e),r=t.filter(l=>!n.valid.includes(l));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,g.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:n.itemFields.includes(l)?[l]:[]).filter((l,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.",g.USAGE);let s=new Set(t.filter(l=>n.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>Eo.has(l)||s.has(l)));o?a.item=n.item:i.length>0&&(a.item=$c(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=[...N(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 Ic(e){let t=0;return mt({...e},n=>(N(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function Wg(e,t,n,r){if(Ic(t)===0||Ic(n)>0)return;let o=[...Nc(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${r.join(", ")}. No selector matched any returned row field.${i}`,g.USAGE)}function Kg(e,t,n){if(e==="get")return Gg(t,n);let r=sn(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=mt(s,d=>N(d)?$c(d,a):d);return Wg(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||Eo.has(s)))}function Hg(e,t){if(t==="unbounded")return e;let{result:n,truncated:r}=da(e,t);if(!r)return n;if(n.has_more=!0,n.truncated=!0,typeof n.count=="number"){let o=N(n.projection)?n.projection.row_key:void 0;n.count=typeof o=="string"&&Array.isArray(n[o])?n[o].length:an(n)}return n.applied_bound={kind:"output_limit",source:"explicit",value:t},n}function Yg(e){return Te.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(Ot[t]))}function Mc(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function Nn(e,t,n,r){let o=bo(e,t,r);Ke(e,o);for(let i=0;i<8;i+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;me(o,n,r);let c=o;o=bo(o,t,r),Ke(c,o);let d=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&d===a)return o}return o}function io(e,t){if(!N(e.read_output))return e;let n=Mc(t),r=e.read_output,o=xn(t.outputSession??t.output_session);return o===void 0?(me(e,r,n),e):Nn(e,o,r,n)}function Xg(e,t){if(e!=="validate")return t;let n=N(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(l=>N(l)&&l.name==="diagnostic_rows"))return t;let r=[...new Set(ft(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=N(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 Jg(e,t,n,r,o){let i={...e};if(t.include?.source==="canonical"&&(i=Kg(t.command,i,t.include.value)),t.command==="assurance"&&(i=ma(i)),pt(i,e),i=pa(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)),N(i.projection)&&(i.projection={...i.projection,row_key:r.path}),N(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=oy(i,e,t.command,r,o);return t.amount?.source==="canonical"&&(i=Hg(i,t.amount.value),a.cursorContinuesExistingPage&&Uc(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),pt(i,s),{projected:n===void 0?i:kc(i,n),continuationState:a}}function Qg(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:Oc(t)}]].sort((n,r)=>n.tokens-r.tokens)[0]}function Lc(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function jc(e,t){return N(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function Zg(e,t,n){return e.command!=="next"||(t.tokenBudget??t.token_budget)===void 0?!1:!(N(n.context_intent)&&n.context_intent.command==="next"&&n.context_intent.within_budget===!0)}function Fc(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!jc(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function ey(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...Fc(r),precedence:e.precedence,...Lc(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:Nn(a,n,s,i);if(n===void 0&&me(c,s,i),n!==void 0&&s.estimated_tokens>r.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",g.USAGE);return c}function ty(e,t,n){return e.command==="context"&&e.cost?.source==="legacy"&&!jc(n,e.cost.value)||Zg(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 ny(e,t,n,r,o){if(t!==void 0||ty(e,o,n))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(de(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"||vt(o.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,r)<=e.cost.value}function ry(e,t,n,r,o,i,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map(Fe(e).map(p=>[p.path,Array.isArray(p.value)?p.value.length:Object.keys(p.value).length])),d=[...s.entries()].flatMap(([p,_])=>{let y=c.get(p);if(y>=_.rows)return[];let b=_.baseOffset+y;return[{path:p,cursor:Ur({command:t.command,path:p,offset:b,total_rows:_.totalRows,fingerprint:_.fingerprint}),retained_rows:y,remaining_rows:_.totalRows-b,total_rows:_.totalRows}]}),l=d[0],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=go({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 Uc(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=Br(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=ht(a.fingerprint,l,f,a.snapshot),!0)}function oy(e,t,n,r,o){let i=new Map(Fe(e).map(c=>{let d=Array.isArray(c.value)?c.value.length:Object.keys(c.value).length,l=r?.path===c.path;return[c.path,{rows:d,totalRows:l?r.total_rows:d,baseOffset:l?r.offset:0,fingerprint:l?r.fingerprint:cn(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}}function iy(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=>N(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 ft(e))m.path.startsWith("diff.")&&u.set(m.path,Object.keys(m.value).length);return wc(e,o,i.tokens,u,d,m=>{pt(m,l);let p=Uc(m,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(ry(m,r,o,i,p,c,a.collectionsBeforeBudget),r.command==="history"&&N(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,Nn(m,s,o,d))},r.command==="history"&&Array.isArray(e.diff))}function Xa(e,t,n){let r=Pc(e,t);if(!r)return n;let o=Mc(t),i=xn(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?yt(s):void 0,c=Yg(r),d=Xg(r.command,n);if(a===void 0&&ny(r,i,d,o,t))return d;let l=Qg(r,i),f=Jg(d,r,i,a,t),u=f.projected;Ke(u,u,t.outputRowContract===!1);let m={contract_version:1,command:r.command,requested_dimensions:c,...Fc(l,u),precedence:r.precedence,...Lc(r),legacy_aliases_used:r.legacy_aliases_used,migration_hints:r.migration_hints,estimated_tokens:0,within_budget:!0,strings_compacted:!1,rows_compacted:!1,result_omitted:!1};if(u.read_output=m,u=i===void 0?u:Nn(u,i,m,o),me(u,m,o),l!==void 0&&m.estimated_tokens>l.tokens){let p=bc(r.command,t,u);p!==void 0&&(m.applied_depth="brief",m.degradation_reason="output_budget_reached",Ke(u,p),u=io(p,t)),m.estimated_tokens>l.tokens&&(u=iy(u,u,d.count_only===!0,r,m,l,i,f.continuationState,m.estimated_tokens,o))}return l!==void 0&&m.estimated_tokens>l.tokens?ey(r,c,i,l,m.estimated_tokens,o):u}function ag(e){return N(e)&&N(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function cg(e,t){let n=t.outputFormat??t.output_format;if(n==="json"||n==="toon")return n;let r=Pc(e,t)?.encoding;return r?.value==="json"||r?.value==="toon"?r.value:void 0}export{xt as a,ai as b,Qn as c,Ql as d,Zl as e,S as f,zc as g,Ao as h,ay as i,cy as j,Co as k,dy as l,ly as m,uy as n,fy as o,my as p,py as q,_y as r,gy as s,yy as t,hy as u,by as v,wy as w,vy as x,Ey as y,qc as z,ky as A,Oy as B,Sy as C,Ay as D,Cy as E,Ty as F,Iy as G,Wi as H,Fl as I,Jh as J,ti as K,ni as L,ds as M,ls as N,Vc as O,Gc as P,Ln as Q,Un as R,zn as S,$y as T,My as U,Ly as V,ed as W,Io as X,jy as Y,tt as Z,nr as _,Ab as $,lu as aa,Tb as ba,Ib as ca,Rb as da,hi as ea,bi as fa,xb as ga,Nb as ha,Db as ia,Pb as ja,No as ka,cd as la,Po as ma,Fo as na,Ky as oa,Gn as pa,wd as qa,Hy as ra,Pd as sa,$d as ta,Yy as ua,Xy as va,sh as wa,Bo as xa,Vo as ya,Go as za,zo as Aa,ah as Ba,ch as Ca,dh as Da,Kn as Ea,lh as Fa,_e as Ga,W as Ha,mh as Ia,ph as Ja,al as Ka,Ko as La,Hn as Ma,ll as Na,ul as Oa,Lt as Pa,Yo as Qa,ml as Ra,gl as Sa,wh as Ta,vh as Ua,wl as Va,vl as Wa,El as Xa,kl as Ya,Yn as Za,kh as _a,Ol as $a,Ze as ab,jt as bb,Oh as cb,Sh as db,Ah as eb,Sl as fb,Al as gb,Cl as hb,xh as ib,Nh as jb,Tl as kb,Ft as lb,Dh as mb,Ph as nb,Il as ob,Rl as pb,xl as qb,Jo as rb,xe as sb,Nl as tb,$h as ub,Mh as vb,Lh as wb,jh as xb,Fh as yb,Uh as zb,zh as Ab,qh as Bb,ye as Cb,qt as Db,Kh as Eb,Wt as Fb,sr as Gb,ar as Hb,cr as Ib,dr as Jb,lr as Kb,ur as Lb,pr as Mb,qi as Nb,eb as Ob,nb as Pb,rb as Qb,df as Rb,uf as Sb,ff as Tb,wf as Ub,wv as Vb,vv as Wb,Ev as Xb,sb as Yb,Vt as Zb,ab as _b,cb as $b,Gl as ac,db as bc,lb as cc,ub as dc,fb as ec,mb as fc,ga as gc,Cv as hc,Ff as ic,eu as jc,Zn as kc,ru as lc,ou as mc,Dv as nc,Kf as oc,Pv as pc,$v as qc,Mv as rc,Lv as sc,jv as tc,Fv as uc,Uv as vc,Ds as wc,Hf as xc,zv as yc,qv as zc,Ps as Ac,Bv as Bc,$s as Cc,Vv as Dc,Gv as Ec,Wv as Fc,Qt as Gc,na as Hc,mE as Ic,pE as Jc,_E as Kc,ra as Lc,oa as Mc,CE as Nc,sa as Oc,rn as Pc,$E as Qc,ME as Rc,Xf as Sc,nE as Tc,Fs as Uc,Jf as Vc,sm as Wc,cm as Xc,Us as Yc,dm as Zc,lm as _c,zs as $c,Oe as ad,qs as bd,rE as cd,oE as dd,xr as ed,iE as fd,sE as gd,aE as hd,cE as id,dE as jd,jE as kd,pt as ld,Et as md,iO as nd,Te as od,kO as pd,OO as qd,Dg as rd,Ue as sd,SO as td,Nc as ud,Fg as vd,AO as wd,Pc as xd,io as yd,Xa as zd,ag as Ad,cg as Bd,fa as Cd,cn as Dd,Ur as Ed,yt as Fd,ZE as Gd,ek as Hd,ht as Id,Br as Jd,Vr as Kd,tk as Ld,fp as Md,nk as Nd,rk as Od,ck as Pd,Kr as Qd,pk as Rd,Ep as Sd,_k as Td,ze as Ud,gk as Vd,yk as Wd,un as Xd,Xr as Yd,Jr as Zd,fn as _d,qk as $d,n_ as ae,bn as be,c_ as ce,Ua as de,u_ as ee,Z as fe,I as ge,e0 as he,kn as ie,E_ as je,t0 as ke,n0 as le,k_ as me,r0 as ne,o0 as oe,i0 as pe,C_ as qe,Ja as re,T_ as se,y0 as te,R_ as ue,Za as ve,h0 as we,nc as xe,N_ as ye,M_ as ze,B_ as Ae,J_ as Be,T0 as Ce,I0 as De,pg as Ee,yc as Fe,K0 as Ge,go as He,vt as Ie,rO as Je,ho as Ke,xn as Le,kc as Me,bo as Ne,Oc as Oe};
26
- //# sourceMappingURL=chunk-MEJKELWC.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]="13e57322-501d-5927-8254-f6196854d434")}catch{}})();var Eg=8,kg=64,Og=5,Sg=4,hc=100;function bc(e,t,n){if(e!=="get"||!po(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=[...po(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 go(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*Og/Sg),i=Math.ceil(o/hc)*hc;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 Ke(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 vt(e,t){let n=t===void 0?JSON.stringify(e):yc(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function po(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _o(e,t,n=!1){return typeof e=="string"?n||e.length<=240?e:(t.compacted=!0,`${B(e,240)}\u2026`):Array.isArray(e)?e.map(r=>_o(r,t,n)):po(e)?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,_o(o,t,n||r==="focus_row_states")])):e}function me(e,t,n){let r=t.estimated_tokens;for(let o=0;o<Eg;o+=1){t.estimated_tokens=r;let i=vt(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function Ag(e,t){return ft(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 Cg(e,t,n,r,o,i){for(let s=0;s<kg;s+=1){if(i?.(e),me(e,t,o),t.estimated_tokens<=n)return;let a=Ag(e,r);if(!a)return;let c=Math.max(1,r.get(a.path)??0),d=Array.isArray(a.value)?[...a.value]:Object.entries(a.value),l=p=>{if(Array.isArray(a.value)){a.value.length=p;for(let _=0;_<p;_+=1)a.value[_]=d[_]}else{for(let _ of Object.keys(a.value))delete a.value[_];Object.defineProperties(a.value,Object.getOwnPropertyDescriptors(Object.fromEntries(d.slice(0,p))))}typeof e.count=="number"&&(e.count=an(e)),a.path==="items"&&(e.applied_limit=p),i?.(e),me(e,t,o)};t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],a.path])].sort((p,_)=>p.localeCompare(_)),e.has_more=!0,e.truncated=!0;let f=c,u=d.length-1,m=c;for(;f<=u;){let p=Math.floor((f+u)/2);l(p),t.estimated_tokens<=n?(m=p,f=p+1):u=p-1}l(m)}}function wc(e,t,n,r=new Map,o,i,s=!1){let a={compacted:!1},c=Object.fromEntries(Object.entries(e).map(([d,l])=>[d,_o(l,a,s&&d==="diff")]));return Ke(e,c),t.strings_compacted=a.compacted,c.read_output=t,Cg(c,t,n,r,o,i),me(c,t,o),c}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="24a8de41-54f9-5b59-8e58-7ac924ba6e08")}catch{}})();function rO(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 yo=256,ho=1e4,Tg=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,vc=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Ig=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),Rg=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&Tg.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=yo,reason:`token_budget must be a safe integer of at least ${yo}.`},{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<=ho&&e.seen_item_ids.every(t=>typeof t=="string"&&vc.test(t)),reason:`seen_item_ids must contain at most ${ho} portable item identifiers.`}];function Rn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function In(e){throw new h(`--output-session ${e}`,g.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function xn(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{In("must be a valid JSON object.")}Rn(t)||In("must be a JSON object.");let n=Object.keys(t).filter(i=>!Ig.has(i));n.length>0&&In(`contains unknown field "${n.sort()[0]}".`);let r=Rg.find(i=>!i.valid(t));r!==void 0&&In(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 Ec(e){if(Rn(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:Rn(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function xg(e){let t=new Set,n=0,r=de(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(!Rn(c))continue;if(typeof c.context_ref=="string"){n+=1;continue}let d=Ec(c);d!==void 0&&vc.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:n}}function kc(e,t){let n=new Set(t.seen_item_ids);return mt(e,r=>{let o=Ec(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function bo(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=xg(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,ho-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<yo,l.next_state.spent_tokens=l.spent_total_tokens},m=0,p=0;for(let _=0;_<8;_+=1){u(m);let y=vt(f,n);if(y===m)return f;p=Math.max(p,y),m=y}return u(p),f}function Oc(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 Et=Symbol.for("pm.readOutputInvocationProvenance");function iO(e,t){return Reflect.set(e,Et,{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]="dd173d3c-f3da-53f3-b24c-118364961db7")}catch{}})();var Te=["include","amount","cost","encoding"],Rc=["canonical","legacy","intent","default"],Ot=Ut,kO=Object.freeze(Te.map(e=>Ot[e])),OO=zt;function Ng(e,t){let n=en[e];if(n!==void 0)return n;let r=t==="include"?Pr.has(e)?"<csv>":tn(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${Ot[t]} ${r}.`}function xc(e){let t=Dr[e]??{},n=Object.freeze(Object.fromEntries(Te.map(r=>[r,Object.freeze({dimension:r,canonical_option:Ot[r],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[r]??[]).map(o=>Object.freeze({flag:o,semantics:en[o]===void 0?"replacement":"behavior_preserving",migration_hint:Ng(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:Rc,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...$r(e).keys()])})}var Dg=Object.freeze(ye.map(xc)),Pg=new Map(Dg.map(e=>[e.command,e]));function Ue(e,t={}){let n=Ze(e.trim().toLowerCase()),r=Nr(n);return r!==void 0?r.read_output===void 0?void 0:`extension:${r.command}`:Ys(n,t)}var $g=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],Mg={comments:["add","body","stdin","file","edit","delete"],notes:["add","addJson","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function Lg(e){return $g.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var jg=[{keys:["outputInclude","output_include"],valid:e=>kt(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||He(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||He(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(xn(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 SO(e,t){let n=t.outputFormat??t.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new h("--output-format must be toon or json.",g.USAGE);if(!Lg(t))return;let r=Ue(e,t);if(!r)throw new h(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,g.USAGE);if((Mg[r]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new h(`Universal output controls cannot be combined with a ${r} mutation.`,g.USAGE);for(let o of jg){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new h(o.message,g.USAGE)}}function Nc(e){let t=Ue(e);return t?$r(t):new Map}function Fg(e,t,n){let r=kt(t)??[],o=Nc(e),i=[],s=[],a=n,c=a[Et],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("_","-")}`;vo(wo(n,_))&&l.add(_),n[p]=!0,s.push(m),d.add(m)}let f=Ue(e)==="get"?i.filter(m=>m!=="item"):[],u=f.length>0;return u&&(n.fields=[...new Set([...kt(n.fields)??[],...f])].join(","),d.add("fields")),(s.length>0||u)&&(a[Et]={canonical_include_modes:[...d],explicit_legacy_aliases:[...l],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function AO(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=Fg(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 wo(e,t){let n=Mr(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 vo(e){return e!==void 0&&e!==!1&&e!==null}function kt(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 He(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 Ug(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=wo(t,o.flag),s={value:i,flag:o.flag};if(vo(i)&&n(s))return s}}function Sc(e,t){let n=kt(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:kt(t.value)??[tn(t.flag)]}}function Ac(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=He(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=He(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function Cc(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=He(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let r=He(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function Tc(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 Dc(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 zg(e,t,n,r){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||vo(wo(r,"--no-truncate"))&&!Dc(n,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function qg(e,t){return Te.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[Ot[n]]:[])}function Pc(e,t){let n=Ue(e,t);if(!n)return;let r=Pg.get(n)??xc(n),o=t[Et],i={include:b=>Sc(void 0,b),amount:b=>Ac(void 0,b),cost:b=>Cc(void 0,b),encoding:b=>Tc(void 0,b)},s=Object.fromEntries(Te.map(b=>[b,Ug(r.dimensions[b],t,k=>i[b](k)!==void 0,k=>Dc(o,b,k))])),a=Te.flatMap(b=>{let k=s[b];return k?[k.flag]:[]}),c=Te.flatMap(b=>{let k=s[b];return k?[r.dimensions[b].legacy_aliases.find(U=>U.flag===k.flag).migration_hint]:[]}),d=Tc(t.outputFormat??t.output_format,s.encoding),l=Sc(t.outputInclude??t.output_include,s.include),f=Ac(t.outputLimit??t.output_limit,s.amount),u=Cc(t.outputBudget??t.output_budget,s.cost),m=zg(e,s,o,t),p=zs(e,{generateFallback:!0}),_=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",y=u??(m?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:l,amount:f,cost:y,encoding:d,canonical_options_used:qg({include:l,amount:f,cost:y,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:Rc}}function N(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Eo=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"]),Bg=["collection_counts","notes_count","tests_count"];function $c(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function Vg(e){let t=N(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...Bg.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!Eo.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 Gg(e,t){let n=Vg(e),r=t.filter(l=>!n.valid.includes(l));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,g.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:n.itemFields.includes(l)?[l]:[]).filter((l,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.",g.USAGE);let s=new Set(t.filter(l=>n.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>Eo.has(l)||s.has(l)));o?a.item=n.item:i.length>0&&(a.item=$c(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=[...N(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 Ic(e){let t=0;return mt({...e},n=>(N(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function Wg(e,t,n,r){if(Ic(t)===0||Ic(n)>0)return;let o=[...Nc(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${r.join(", ")}. No selector matched any returned row field.${i}`,g.USAGE)}function Kg(e,t,n){if(e==="get")return Gg(t,n);let r=sn(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=mt(s,d=>N(d)?$c(d,a):d);return Wg(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||Eo.has(s)))}function Hg(e,t){if(t==="unbounded")return e;let{result:n,truncated:r}=da(e,t);if(!r)return n;if(n.has_more=!0,n.truncated=!0,typeof n.count=="number"){let o=N(n.projection)?n.projection.row_key:void 0;n.count=typeof o=="string"&&Array.isArray(n[o])?n[o].length:an(n)}return n.applied_bound={kind:"output_limit",source:"explicit",value:t},n}function Yg(e){return Te.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(Ot[t]))}function Mc(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function Nn(e,t,n,r){let o=bo(e,t,r);Ke(e,o);for(let i=0;i<8;i+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;me(o,n,r);let c=o;o=bo(o,t,r),Ke(c,o);let d=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&d===a)return o}return o}function io(e,t){if(!N(e.read_output))return e;let n=Mc(t),r=e.read_output,o=xn(t.outputSession??t.output_session);return o===void 0?(me(e,r,n),e):Nn(e,o,r,n)}function Xg(e,t){if(e!=="validate")return t;let n=N(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(l=>N(l)&&l.name==="diagnostic_rows"))return t;let r=[...new Set(ft(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=N(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 Jg(e,t,n,r,o){let i={...e};if(t.include?.source==="canonical"&&(i=Kg(t.command,i,t.include.value)),t.command==="assurance"&&(i=ma(i)),pt(i,e),i=pa(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)),N(i.projection)&&(i.projection={...i.projection,row_key:r.path}),N(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=oy(i,e,t.command,r,o);return t.amount?.source==="canonical"&&(i=Hg(i,t.amount.value),a.cursorContinuesExistingPage&&Uc(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),pt(i,s),{projected:n===void 0?i:kc(i,n),continuationState:a}}function Qg(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:Oc(t)}]].sort((n,r)=>n.tokens-r.tokens)[0]}function Lc(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function jc(e,t){return N(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function Zg(e,t,n){return e.command!=="next"||(t.tokenBudget??t.token_budget)===void 0?!1:!(N(n.context_intent)&&n.context_intent.command==="next"&&n.context_intent.within_budget===!0)}function Fc(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!jc(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function ey(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...Fc(r),precedence:e.precedence,...Lc(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:Nn(a,n,s,i);if(n===void 0&&me(c,s,i),n!==void 0&&s.estimated_tokens>r.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",g.USAGE);return c}function ty(e,t,n){return e.command==="context"&&e.cost?.source==="legacy"&&!jc(n,e.cost.value)||Zg(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 ny(e,t,n,r,o){if(t!==void 0||ty(e,o,n))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(de(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"||vt(o.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,r)<=e.cost.value}function ry(e,t,n,r,o,i,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map(Fe(e).map(p=>[p.path,Array.isArray(p.value)?p.value.length:Object.keys(p.value).length])),d=[...s.entries()].flatMap(([p,_])=>{let y=c.get(p);if(y>=_.rows)return[];let b=_.baseOffset+y;return[{path:p,cursor:Ur({command:t.command,path:p,offset:b,total_rows:_.totalRows,fingerprint:_.fingerprint}),retained_rows:y,remaining_rows:_.totalRows-b,total_rows:_.totalRows}]}),l=d[0],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=go({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 Uc(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=Br(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=ht(a.fingerprint,l,f,a.snapshot),!0)}function oy(e,t,n,r,o){let i=new Map(Fe(e).map(c=>{let d=Array.isArray(c.value)?c.value.length:Object.keys(c.value).length,l=r?.path===c.path;return[c.path,{rows:d,totalRows:l?r.total_rows:d,baseOffset:l?r.offset:0,fingerprint:l?r.fingerprint:cn(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}}function iy(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=>N(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 ft(e))m.path.startsWith("diff.")&&u.set(m.path,Object.keys(m.value).length);return wc(e,o,i.tokens,u,d,m=>{pt(m,l);let p=Uc(m,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(ry(m,r,o,i,p,c,a.collectionsBeforeBudget),r.command==="history"&&N(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,Nn(m,s,o,d))},r.command==="history"&&Array.isArray(e.diff))}function Xa(e,t,n){let r=Pc(e,t);if(!r)return n;let o=Mc(t),i=xn(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?yt(s):void 0,c=Yg(r),d=Xg(r.command,n);if(a===void 0&&ny(r,i,d,o,t))return d;let l=Qg(r,i),f=Jg(d,r,i,a,t),u=f.projected;Ke(u,u,t.outputRowContract===!1);let m={contract_version:1,command:r.command,requested_dimensions:c,...Fc(l,u),precedence:r.precedence,...Lc(r),legacy_aliases_used:r.legacy_aliases_used,migration_hints:r.migration_hints,estimated_tokens:0,within_budget:!0,strings_compacted:!1,rows_compacted:!1,result_omitted:!1};if(u.read_output=m,u=i===void 0?u:Nn(u,i,m,o),me(u,m,o),l!==void 0&&m.estimated_tokens>l.tokens){let p=bc(r.command,t,u);p!==void 0&&(m.applied_depth="brief",m.degradation_reason="output_budget_reached",Ke(u,p),u=io(p,t)),m.estimated_tokens>l.tokens&&(u=iy(u,u,d.count_only===!0,r,m,l,i,f.continuationState,m.estimated_tokens,o))}return l!==void 0&&m.estimated_tokens>l.tokens?ey(r,c,i,l,m.estimated_tokens,o):u}function ag(e){return N(e)&&N(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function cg(e,t){let n=t.outputFormat??t.output_format;if(n==="json"||n==="toon")return n;let r=Pc(e,t)?.encoding;return r?.value==="json"||r?.value==="toon"?r.value:void 0}export{xt as a,ai as b,Qn as c,Ql as d,Zl as e,S as f,zc as g,Ao as h,ay as i,cy as j,Co as k,dy as l,ly as m,uy as n,fy as o,my as p,py as q,_y as r,gy as s,yy as t,hy as u,by as v,wy as w,vy as x,Ey as y,qc as z,ky as A,Oy as B,Sy as C,Ay as D,Cy as E,Ty as F,Iy as G,Wi as H,Fl as I,Jh as J,ti as K,ni as L,ds as M,ls as N,Vc as O,Gc as P,Ln as Q,Un as R,zn as S,$y as T,My as U,Ly as V,ed as W,Io as X,jy as Y,tt as Z,nr as _,Ab as $,lu as aa,Tb as ba,Ib as ca,Rb as da,hi as ea,bi as fa,xb as ga,Nb as ha,Db as ia,Pb as ja,No as ka,cd as la,Po as ma,Fo as na,Ky as oa,Gn as pa,wd as qa,Hy as ra,Pd as sa,$d as ta,Yy as ua,Xy as va,sh as wa,Bo as xa,Vo as ya,Go as za,zo as Aa,ah as Ba,ch as Ca,dh as Da,Kn as Ea,lh as Fa,_e as Ga,W as Ha,mh as Ia,ph as Ja,al as Ka,Ko as La,Hn as Ma,ll as Na,ul as Oa,Lt as Pa,Yo as Qa,ml as Ra,gl as Sa,wh as Ta,vh as Ua,wl as Va,vl as Wa,El as Xa,kl as Ya,Yn as Za,kh as _a,Ol as $a,Ze as ab,jt as bb,Oh as cb,Sh as db,Ah as eb,Sl as fb,Al as gb,Cl as hb,xh as ib,Nh as jb,Tl as kb,Ft as lb,Dh as mb,Ph as nb,Il as ob,Rl as pb,xl as qb,Jo as rb,xe as sb,Nl as tb,$h as ub,Mh as vb,Lh as wb,jh as xb,Fh as yb,Uh as zb,zh as Ab,qh as Bb,ye as Cb,qt as Db,Kh as Eb,Wt as Fb,sr as Gb,ar as Hb,cr as Ib,dr as Jb,lr as Kb,ur as Lb,pr as Mb,qi as Nb,eb as Ob,B as Pb,nb as Qb,rb as Rb,df as Sb,uf as Tb,ff as Ub,wf as Vb,wv as Wb,vv as Xb,Ev as Yb,sb as Zb,Vt as _b,ab as $b,cb as ac,Gl as bc,db as cc,lb as dc,ub as ec,fb as fc,mb as gc,ga as hc,Cv as ic,Ff as jc,eu as kc,Zn as lc,ru as mc,ou as nc,Dv as oc,Kf as pc,Pv as qc,$v as rc,Mv as sc,Lv as tc,jv as uc,Fv as vc,Uv as wc,Ds as xc,Hf as yc,zv as zc,qv as Ac,Ps as Bc,Bv as Cc,$s as Dc,Vv as Ec,Gv as Fc,Wv as Gc,Qt as Hc,na as Ic,mE as Jc,pE as Kc,_E as Lc,ra as Mc,oa as Nc,CE as Oc,sa as Pc,rn as Qc,$E as Rc,ME as Sc,Xf as Tc,nE as Uc,Fs as Vc,Jf as Wc,sm as Xc,cm as Yc,Us as Zc,dm as _c,lm as $c,zs as ad,Oe as bd,qs as cd,rE as dd,oE as ed,xr as fd,iE as gd,sE as hd,aE as id,cE as jd,dE as kd,jE as ld,pt as md,Et as nd,iO as od,Te as pd,kO as qd,OO as rd,Dg as sd,Ue as td,SO as ud,Nc as vd,Fg as wd,AO as xd,Pc as yd,io as zd,Xa as Ad,ag as Bd,cg as Cd,fa as Dd,cn as Ed,Ur as Fd,yt as Gd,ZE as Hd,ek as Id,ht as Jd,Br as Kd,Vr as Ld,tk as Md,fp as Nd,nk as Od,rk as Pd,ck as Qd,Kr as Rd,pk as Sd,Ep as Td,_k as Ud,ze as Vd,gk as Wd,yk as Xd,un as Yd,Xr as Zd,Jr as _d,fn as $d,qk as ae,n_ as be,bn as ce,c_ as de,Ua as ee,u_ as fe,Z as ge,I as he,e0 as ie,kn as je,E_ as ke,t0 as le,n0 as me,k_ as ne,r0 as oe,o0 as pe,i0 as qe,C_ as re,Ja as se,T_ as te,y0 as ue,R_ as ve,Za as we,h0 as xe,nc as ye,N_ as ze,M_ as Ae,B_ as Be,J_ as Ce,T0 as De,I0 as Ee,pg as Fe,yc as Ge,K0 as He,go as Ie,vt as Je,rO as Ke,ho as Le,xn as Me,kc as Ne,bo as Oe,Oc as Pe};
26
+ //# sourceMappingURL=chunk-M6V7UMWL.js.map
@@ -1,8 +1,8 @@
1
- import{r as q,s as V}from"./chunk-C7UX2ZI3.js";import{d as m,j as M,l as k}from"./chunk-BHNY3KPJ.js";import{Ga as O,Hd as N,Kd as D,Nd as j,S as x,X as g,de as z}from"./chunk-MEJKELWC.js";import{A as C,E as _,I as L,z as S}from"./chunk-G6ERMFJ5.js";import{constants as p}from"node:fs";import{lstat as A,mkdir as I,open as P}from"node:fs/promises";import h from"node:path";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="5434ff6f-95af-5983-88cb-fd360d95cb9e")}catch{}})();function E(i,e){if(typeof i!="string"||i.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return i.trim()}function $(i,e){let t=e.require(i.kind),n=t.direction==="undirected"?[i.source,i.target].sort().join("\0"):`${i.source}\0${i.target}`;return`${t.kind}\0${n}`}function Q(i){return Object.freeze({...i,...i.payload===void 0?{}:{payload:Object.freeze(structuredClone(i.payload))}})}function U(i,e,t,n){let r=t.require(i.kind),o=n.outgoingOne.get(`${r.kind}\0${i.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let s=n.incomingOne.get(`${r.kind}\0${i.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let c=$(i,t),a=n.identities.get(c);if(a!==void 0&&a!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function Y(i){let e=new Map;for(let t of i)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function X(i,e,t){if(i.expectedVersion!==void 0&&i.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${i.expectedVersion}, current ${e}`);let n=E(i.eventId,"eventId");if(t.has(n))throw new TypeError(`Relationship event already exists: ${n}`);if(i.action!=="add"&&i.action!=="remove"&&i.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${i.action}`);if(!Number.isFinite(Date.parse(i.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:n,relationshipId:E(i.relationshipId,"relationshipId"),author:E(i.author,"author"),timestamp:new Date(i.timestamp).toISOString()}}function Z(i,e,t,n,r,o){let s=t.has(e);if(i.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(i.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(i.action==="remove")return;if(!i.edge)throw new TypeError(`Relationship ${i.action} event requires an edge`);let c=typeof i.edge.source=="string"?i.edge.source.trim():"",a=typeof i.edge.target=="string"?i.edge.target.trim():"";if(!n.has(c)||!n.has(a))throw new TypeError(`Relationship endpoint not found: ${c} -> ${a}`);let d=new g([c,a],[i.edge],r).edges()[0];return U(d,e,r,o),Q(d)}var T=class{#t;#i;#n=[];#o=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean)),this.#i=t.registry??x()}get version(){return this.#n.length}events(){return Object.freeze([...this.#n])}*stream(e={}){let t=e.fromVersion??1,n=e.toVersion??this.version,r=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(n)||n<0||n>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${n}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>n+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<n;o+=r)yield Object.freeze(this.#n.slice(o,Math.min(o+r,n)))}project(e,t,n={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let r=e,o=0,s;for(let c of this.stream({...n,batchSize:256}))for(let a of c)r=t(r,a),o+=1,s=a;return Object.freeze({state:r,version:s?.sequence??Math.max(0,(n.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let n=this.#i.require(t.kind);this.#r.identities.set($(t,this.#i),e),n.outgoing==="one"&&this.#r.outgoingOne.set(`${n.kind}\0${t.source}`,e),n.incoming==="one"&&this.#r.incomingOne.set(`${n.kind}\0${t.target}`,e)}#a(e){let t=this.#i.require(e.kind);this.#r.identities.delete($(e,this.#i)),t.outgoing==="one"&&this.#r.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#r.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=X(e,this.version,this.#o),n=this.#e.get(t.relationshipId),r=Z(e,t.relationshipId,this.#e,this.#t,this.#i,this.#r),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...r===void 0?{}:{edge:r},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#n.push(o),this.#o.add(t.eventId),n&&this.#a(n),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,r),this.#s(t.relationshipId,r)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#n.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#n.slice(0,o)}let n=Y(t),r=new g(this.#t,n.values(),this.#i);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=N("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(D(e.cursor,t).snapshot);if(!Number.isSafeInteger(n)||n<0||n>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=j(this.#n.slice(0,n),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(n)});return{version:n,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},ee="relationship-event-store",W=p.O_NOFOLLOW;function w(i){return z(i,ee,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function f(i,e="relationships/events.jsonl"){let t=h.resolve(i),n=h.resolve(t,e),r=h.relative(t,n);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${h.sep}`)||h.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await I(t,{recursive:!0}),(await A(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let o=t;for(let s of r.split(h.sep)){o=h.join(o,s);try{if((await A(o)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(c){if(_(c))break;throw c}}return n}async function y(i,e,t){let n=new T(e,{registry:t}),r,o;try{o=await P(i,p.O_RDONLY|W),r=await o.readFile("utf8")}catch(c){if(_(c))return{log:n,raw:""};throw c}finally{await o?.close()}let s=r.split(`
1
+ import{r as q,s as V}from"./chunk-C6P6HPCX.js";import{d as m,j as M,l as k}from"./chunk-G4QP365K.js";import{Ga as O,Id as N,Ld as D,Od as j,S as x,X as g,ee as z}from"./chunk-M6V7UMWL.js";import{A as C,E as _,I as L,z as S}from"./chunk-G6ERMFJ5.js";import{constants as p}from"node:fs";import{lstat as A,mkdir as I,open as P}from"node:fs/promises";import h from"node:path";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="5434ff6f-95af-5983-88cb-fd360d95cb9e")}catch{}})();function E(i,e){if(typeof i!="string"||i.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return i.trim()}function $(i,e){let t=e.require(i.kind),n=t.direction==="undirected"?[i.source,i.target].sort().join("\0"):`${i.source}\0${i.target}`;return`${t.kind}\0${n}`}function Q(i){return Object.freeze({...i,...i.payload===void 0?{}:{payload:Object.freeze(structuredClone(i.payload))}})}function U(i,e,t,n){let r=t.require(i.kind),o=n.outgoingOne.get(`${r.kind}\0${i.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let s=n.incomingOne.get(`${r.kind}\0${i.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let c=$(i,t),a=n.identities.get(c);if(a!==void 0&&a!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function Y(i){let e=new Map;for(let t of i)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function X(i,e,t){if(i.expectedVersion!==void 0&&i.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${i.expectedVersion}, current ${e}`);let n=E(i.eventId,"eventId");if(t.has(n))throw new TypeError(`Relationship event already exists: ${n}`);if(i.action!=="add"&&i.action!=="remove"&&i.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${i.action}`);if(!Number.isFinite(Date.parse(i.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:n,relationshipId:E(i.relationshipId,"relationshipId"),author:E(i.author,"author"),timestamp:new Date(i.timestamp).toISOString()}}function Z(i,e,t,n,r,o){let s=t.has(e);if(i.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(i.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(i.action==="remove")return;if(!i.edge)throw new TypeError(`Relationship ${i.action} event requires an edge`);let c=typeof i.edge.source=="string"?i.edge.source.trim():"",a=typeof i.edge.target=="string"?i.edge.target.trim():"";if(!n.has(c)||!n.has(a))throw new TypeError(`Relationship endpoint not found: ${c} -> ${a}`);let d=new g([c,a],[i.edge],r).edges()[0];return U(d,e,r,o),Q(d)}var T=class{#t;#i;#n=[];#o=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean)),this.#i=t.registry??x()}get version(){return this.#n.length}events(){return Object.freeze([...this.#n])}*stream(e={}){let t=e.fromVersion??1,n=e.toVersion??this.version,r=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(n)||n<0||n>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${n}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>n+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<n;o+=r)yield Object.freeze(this.#n.slice(o,Math.min(o+r,n)))}project(e,t,n={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let r=e,o=0,s;for(let c of this.stream({...n,batchSize:256}))for(let a of c)r=t(r,a),o+=1,s=a;return Object.freeze({state:r,version:s?.sequence??Math.max(0,(n.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let n=this.#i.require(t.kind);this.#r.identities.set($(t,this.#i),e),n.outgoing==="one"&&this.#r.outgoingOne.set(`${n.kind}\0${t.source}`,e),n.incoming==="one"&&this.#r.incomingOne.set(`${n.kind}\0${t.target}`,e)}#a(e){let t=this.#i.require(e.kind);this.#r.identities.delete($(e,this.#i)),t.outgoing==="one"&&this.#r.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#r.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=X(e,this.version,this.#o),n=this.#e.get(t.relationshipId),r=Z(e,t.relationshipId,this.#e,this.#t,this.#i,this.#r),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...r===void 0?{}:{edge:r},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#n.push(o),this.#o.add(t.eventId),n&&this.#a(n),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,r),this.#s(t.relationshipId,r)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#n.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#n.slice(0,o)}let n=Y(t),r=new g(this.#t,n.values(),this.#i);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=N("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(D(e.cursor,t).snapshot);if(!Number.isSafeInteger(n)||n<0||n>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=j(this.#n.slice(0,n),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(n)});return{version:n,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},ee="relationship-event-store",W=p.O_NOFOLLOW;function w(i){return z(i,ee,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function f(i,e="relationships/events.jsonl"){let t=h.resolve(i),n=h.resolve(t,e),r=h.relative(t,n);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${h.sep}`)||h.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await I(t,{recursive:!0}),(await A(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let o=t;for(let s of r.split(h.sep)){o=h.join(o,s);try{if((await A(o)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(c){if(_(c))break;throw c}}return n}async function y(i,e,t){let n=new T(e,{registry:t}),r,o;try{o=await P(i,p.O_RDONLY|W),r=await o.readFile("utf8")}catch(c){if(_(c))return{log:n,raw:""};throw c}finally{await o?.close()}let s=r.split(`
2
2
  `);for(let c=0;c<s.length;c+=1){let a=s[c].trim();if(!a)continue;let d;try{d=JSON.parse(a)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${c+1}`)}if(d.sequence!==n.version+1)throw new TypeError(`Invalid relationship event sequence at line ${c+1}`);n.append({eventId:d.eventId,relationshipId:d.relationshipId,action:d.action,...d.edge===void 0?{}:{edge:d.edge},author:d.author,timestamp:d.timestamp,...d.reason===void 0?{}:{reason:d.reason},expectedVersion:n.version})}return{log:n,raw:r}}function te(i,e,t,n){let r=Date.parse(e.timestamp),o;return e.action!=="remove"&&e.edge!==void 0&&(o=new g(t,[e.edge],n).edges()[0]),i.eventId===e.eventId.trim()&&i.relationshipId===e.relationshipId.trim()&&i.action===e.action&&i.author===e.author.trim()&&Number.isFinite(r)&&i.timestamp===new Date(r).toISOString()&&i.reason===(e.reason?.trim()||void 0)&&O(i.edge)===O(o)}var F=class i{#t;#i;#n;#o;#e;constructor(e,t,n,r){this.#t=e.pmRoot,this.#i=t,this.#n=e.registry,this.#o=n,this.#e=r}static async open(e){let t=Object.freeze([...e.nodes]),n=await f(e.pmRoot,e.relativePath),r=await w(e.pmRoot);try{await f(e.pmRoot,n);let{log:o}=await y(n,t,e.registry);return new i(e,t,n,o)}finally{await r()}}get path(){return this.#o}async currentVersion(){return this.#e=await this.#r(),this.#e.version}async append(e){let t=await w(this.#t);try{let n=await f(this.#t,this.#o),{log:r}=await y(n,this.#i,this.#n),o=r.append(e);await I(h.dirname(n),{recursive:!0}),await f(this.#t,n);let s=await P(n,p.O_APPEND|p.O_CREAT|p.O_WRONLY|W);try{await s.appendFile(`${JSON.stringify(o)}
3
3
  `,"utf8")}finally{await s.close()}return this.#e=r,o}finally{await t()}}async appendBatch(e,t={}){let n=await w(this.#t);try{let r=await f(this.#t,this.#o),{log:o,raw:s}=await y(r,this.#i,this.#n),c=o.version,a=new Map(o.events().map(l=>[l.eventId,l])),d=[],R=[];for(let l of e){let u=l.eventId.trim(),v=a.get(u);if(v!==void 0){if(t.existingEventPolicy==="skip_identical"&&te(v,l,this.#i,this.#n)){R.push(v.eventId);continue}if(t.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${u}`)}let b=o.append(l);a.set(b.eventId,b),d.push(b)}if(d.length>0){let l=s.length===0||s.endsWith(`
4
4
  `)?s:`${s}
5
5
  `;await I(h.dirname(r),{recursive:!0}),await f(this.#t,r),await L(r,`${l}${d.map(u=>JSON.stringify(u)).join(`
6
6
  `)}
7
7
  `)}return this.#e=o,Object.freeze({version_before:c,version_after:o.version,appended:Object.freeze(d),skipped_event_ids:Object.freeze(R)})}finally{await n()}}async snapshot(e={}){return this.#e=await this.#r(),this.#e.snapshot(e)}async page(e){return this.#e=await this.#r(),this.#e.page(e)}async*stream(e={}){this.#e=await this.#r(),yield*this.#e.stream(e)}async project(e,t,n={}){return this.#e=await this.#r(),this.#e.project(e,t,n)}async#r(){let e=await w(this.#t);try{let t=await f(this.#t,this.#o);return(await y(t,this.#i,this.#n)).log}finally{await e()}}};(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="73852fdf-f072-51ab-9449-d7922712eeb4")}catch{}})();function K(i){return[...i].sort().join("\0")}function ie(i,e,t){let n=i.successors.get(e);n?n.push(t):i.successors.set(e,[t]);let r=i.predecessors.get(t);r?r.push(e):i.predecessors.set(t,[e])}function G(i,e,t,n,r){let o=e.resolve(r);if(o?.ordering!==!0)return;let s=M(n),c=s===void 0?void 0:i.canonicalIds.get(s.toLowerCase());if(c===void 0)return;let a=(o.precedence??"source_before_target")==="source_before_target";ie(i,a?t:c,a?c:t)}function ne(i,e){let t={successors:new Map,predecessors:new Map,canonicalIds:new Map},n=i.filter(r=>typeof r?.id=="string"&&r.id.trim().length>0);for(let r of n){let o=r.id.trim();t.canonicalIds.set(o.toLowerCase(),o)}for(let r of n){let o=r.id.trim();G(t,e,o,r.blocked_by,"blocked_by");for(let s of r.dependencies??[])typeof s!="object"||s===null||G(t,e,o,s.id,typeof s.kind=="string"?s.kind:"related")}for(let r of[t.successors,t.predecessors])for(let o of r.values())o.sort();return t}function re(i,e){let t=new Set([e]),n=[e];for(;n.length>0;){let r=n.pop();for(let o of[i.successors,i.predecessors])for(let s of o.get(r)??[])t.has(s)||(t.add(s),n.push(s))}return t}function oe(i,e){let t=new Map;for(let n of e){let r=(i.successors.get(n)??[]).filter(o=>e.has(o));r.length>0&&t.set(n,r)}return t}function H(i,e,t){let n=ne(i,e),r=n.canonicalIds.get(t.trim().toLowerCase());if(r===void 0)return{cycles:[],successors:new Map,canonical:t};let o=oe(n,re(n,r));return{cycles:q(o).filter(s=>s.includes(r)),successors:o,canonical:r}}function se(i,e,t){let n=new Set(e),r=n.has(t)?t:e[0];if(i.get(r)?.includes(r))return[r,r];for(let o of i.get(r)??[]){if(!n.has(o))continue;let s=ae(i,n,r,o);if(s)return s}return[...e,e[0]]}function ae(i,e,t,n){let r=[[n]],o=new Set([t,n]);for(;r.length>0;){let s=r.shift(),c=s.at(-1);for(let a of i.get(c)??[]){if(a===t)return[t,...s,t];!e.has(a)||o.has(a)||(o.add(a),r.push([...s,a]))}}}function ve(i,e,t){let n=m(),r=H(i,n,t),o=H(e,n,t),s=new Set(r.cycles.map(K)),c=new Set(k(i,void 0,n).map(a=>`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`));return[...k(e,void 0,n).filter(a=>a.holder_id.toLowerCase()===t.trim().toLowerCase()&&!c.has(`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`)).map(a=>`ordering_storage_contradiction_created:${V(a)}:remove_contradicting_dependency_row:run_pm_graph_audit`),...o.cycles.filter(a=>!s.has(K(a))).map(a=>`ordering_cycle_created:${se(o.successors,a,o.canonical).join(" -> ")}:items_will_not_be_ready:run_pm_graph_audit`)]}(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="5f2ca18e-450d-5b6e-9e07-7bbf080764f9")}catch{}})();function Ee(i,e){let t=e.resolve(i);return t?.hierarchy===!0||t?.outgoing==="one"||t?.incoming==="one"}function J(i,e,t,n,r){let o=JSON.stringify([e,t,n]),s=i.get(o);s===void 0&&(s={kind:e,direction:t,node_id:n,endpoints:new Set},i.set(o,s)),s.endpoints.add(r)}function B(i,e){let t=new Map;for(let n of i)for(let r of n.dependencies??[]){let o=e.resolve(r.kind);o===void 0||o.hierarchy||(o.outgoing==="one"&&J(t,o.kind,"outgoing",n.id,r.id),o.incoming==="one"&&J(t,o.kind,"incoming",r.id,n.id))}return t}function Ie(i,e,t=m()){let n=B(i,t),r=B(e,t);for(let o of[...r.keys()].sort()){let s=r.get(o);if(s.endpoints.size<=1)continue;let c=n.get(o);if(![...s.endpoints].every(a=>c?.endpoints.has(a)))throw new C(`Relationship ${s.kind} permits only one ${s.direction} endpoint for ${s.node_id}.`,S.USAGE,{code:"dependency_cardinality_created",field:"dependencies",value:s.kind,relationship_cardinality:{kind:s.kind,direction:s.direction,node_id:s.node_id,endpoint_ids:[...s.endpoints].sort()},required:"The final dependency set must satisfy the active relationship kind's one-edge cardinality.",nextSteps:["Drop extra --dep seeds, or remove conflicting rows with update --dep-remove before adding another edge.","Choose another kind only when its declared semantics match the intended relationship."]})}}export{T as a,F as b,ve as c,Ee as d,Ie as e};
8
- //# sourceMappingURL=chunk-CXTDEQ3N.js.map
8
+ //# sourceMappingURL=chunk-MC7IE7D7.js.map