@unbrained/pm-cli 2026.9.11 → 2026.9.13

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 (165) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +42 -0
  3. package/dist/cli/command-namespaces.js +1 -1
  4. package/dist/cli/commander-usage.js +2 -2
  5. package/dist/cli/error-guidance.d.ts +10 -0
  6. package/dist/cli/error-guidance.js +1 -1
  7. package/dist/cli/main.js +2 -2
  8. package/dist/cli/option-values.d.ts +3 -0
  9. package/dist/cli/option-values.js +2 -0
  10. package/dist/cli/register-mutation.d.ts +5 -0
  11. package/dist/cli/register-mutation.js +2 -16
  12. package/dist/cli/schema/registration.d.ts +4 -0
  13. package/dist/cli/schema/registration.js +16 -0
  14. package/dist/cli-bundle/bundle-manifest.json +160 -152
  15. package/dist/cli-bundle/chunks/{chunk-TDKWJQD7.js → chunk-3DWX3CKN.js} +2 -2
  16. package/dist/cli-bundle/chunks/chunk-6KHYW3FH.js +235 -0
  17. package/dist/cli-bundle/chunks/chunk-AKTBOX6U.js +2 -0
  18. package/dist/cli-bundle/chunks/chunk-GBK5MV6N.js +29 -0
  19. package/dist/cli-bundle/chunks/{chunk-JMQKJ7CJ.js → chunk-GQQR6JAL.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-QER6OSOP.js → chunk-KM4XVZR7.js} +53 -53
  21. package/dist/cli-bundle/chunks/{chunk-VFKBNGF6.js → chunk-LA44JECQ.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-DAWH7TGV.js → chunk-XEZOGC3P.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-TFVKBJJ4.js → chunk-XM7RWQLM.js} +103 -103
  24. package/dist/cli-bundle/chunks/{chunk-RJQSCK74.js → chunk-YDSV4QIQ.js} +6 -6
  25. package/dist/cli-bundle/chunks/chunk-YQTJACN5.js +20 -0
  26. package/dist/cli-bundle/chunks/{chunk-BN5QVWNY.js → chunk-ZZI7IHMM.js} +2 -2
  27. package/dist/cli-bundle/chunks/{register-list-query-U6MY437C.js → register-list-query-WMJTBWNW.js} +2 -2
  28. package/dist/cli-bundle/chunks/register-mutation-EXGOXP3D.js +20 -0
  29. package/dist/cli-bundle/chunks/{register-operations-EHWIZW3X.js → register-operations-2H4CDRGU.js} +2 -2
  30. package/dist/cli-bundle/chunks/{register-setup-BZYL3HBL.js → register-setup-NYBWGPOS.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/{chunk-TWE3GPQM.js → chunk-7JR6M2JR.js} +17 -17
  32. package/dist/cli-bundle/focused-chunks/{chunk-GKUF7TM5.js → chunk-B6JAANOH.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/{chunk-UJCQXUD2.js → chunk-DSJYL4VP.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-VS6MR2HT.js → chunk-F66QJWI4.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-MOT32PR2.js → chunk-FBCLVOBE.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-HM6JS6Q3.js → chunk-FPNI4U2B.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/chunk-HFAW3FJQ.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-KP3N6PVZ.js +164 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-LQ67C7ZO.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/{chunk-TGMSSI3Z.js → chunk-OENAWWP4.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{chunk-7WISPJRZ.js → chunk-SDQCJF4H.js} +53 -53
  42. package/dist/cli-bundle/focused-chunks/chunk-TUHRUFID.js +2 -0
  43. package/dist/cli-bundle/focused-chunks/{chunk-6JF66HAG.js → chunk-V7PSTKHD.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/{chunk-FJDEFA64.js → chunk-XCCM7P7V.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/chunk-YUXBHIUV.js +20 -0
  46. package/dist/cli-bundle/focused-chunks/{chunk-BEQAW7OT.js → chunk-ZAMG7HBB.js} +4 -4
  47. package/dist/cli-bundle/focused-chunks/chunk-ZF5PXK6A.js +2 -0
  48. package/dist/cli-bundle/main.js +20 -20
  49. package/dist/cli-bundle/sdk-authoring.js +1 -1
  50. package/dist/cli-bundle/sdk-contracts.js +2 -2
  51. package/dist/cli-bundle/sdk-core.js +34 -34
  52. package/dist/cli-bundle/sdk-governance.js +1 -1
  53. package/dist/cli-bundle/sdk-graph.js +1 -1
  54. package/dist/cli-bundle/sdk-merge.js +42 -42
  55. package/dist/cli-bundle/sdk-query.js +1 -1
  56. package/dist/cli-bundle/sdk-runtime.js +1 -1
  57. package/dist/cli-bundle/sdk-testing.js +1 -1
  58. package/dist/cli-bundle/sdk.js +8 -8
  59. package/dist/core/history/history.js +1 -1
  60. package/dist/core/history/operation-contract.d.ts +30 -0
  61. package/dist/core/history/operation-contract.js +2 -0
  62. package/dist/core/history/tombstone.d.ts +3 -0
  63. package/dist/core/history/tombstone.js +2 -0
  64. package/dist/core/item/id.d.ts +8 -7
  65. package/dist/core/item/id.js +1 -1
  66. package/dist/core/output/mutation-projection.d.ts +1 -0
  67. package/dist/core/output/mutation-projection.js +1 -1
  68. package/dist/core/sentry/instrument.js +1 -1
  69. package/dist/core/shared/command-line.d.ts +10 -0
  70. package/dist/core/shared/command-line.js +2 -0
  71. package/dist/core/shared/errors.d.ts +13 -0
  72. package/dist/core/shared/errors.js +1 -1
  73. package/dist/core/store/item-store.d.ts +5 -1
  74. package/dist/core/store/item-store.js +1 -1
  75. package/dist/core/telemetry/consent.d.ts +1 -1
  76. package/dist/core/telemetry/consent.js +2 -2
  77. package/dist/core/telemetry/policy.d.ts +10 -0
  78. package/dist/core/telemetry/policy.js +2 -0
  79. package/dist/core/telemetry/runtime.d.ts +11 -9
  80. package/dist/core/telemetry/runtime.js +3 -3
  81. package/dist/sdk/agent/command-suggestions.js +1 -1
  82. package/dist/sdk/agent/item-addressing.js +1 -1
  83. package/dist/sdk/agent-capability-contracts.js +1 -1
  84. package/dist/sdk/cli-bootstrap.js +1 -1
  85. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  86. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  87. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  88. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  89. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +3 -0
  90. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  91. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  92. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  93. package/dist/sdk/command-line.d.ts +1 -6
  94. package/dist/sdk/command-line.js +1 -1
  95. package/dist/sdk/comments.js +1 -1
  96. package/dist/sdk/completion.js +1 -1
  97. package/dist/sdk/contracts.d.ts +1 -0
  98. package/dist/sdk/contracts.js +1 -1
  99. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  100. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  101. package/dist/sdk/governance/health.js +1 -1
  102. package/dist/sdk/governance/storage-integrity.js +1 -1
  103. package/dist/sdk/governance/workflow-completeness.js +1 -1
  104. package/dist/sdk/governance/workflow-policy.js +2 -2
  105. package/dist/sdk/index.d.ts +1 -0
  106. package/dist/sdk/index.js +1 -1
  107. package/dist/sdk/learnings.js +1 -1
  108. package/dist/sdk/lifecycle/claim.d.ts +2 -0
  109. package/dist/sdk/lifecycle/claim.js +1 -1
  110. package/dist/sdk/lifecycle/mcp-actions.d.ts +4 -0
  111. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  112. package/dist/sdk/lifecycle/task-composition.d.ts +2 -0
  113. package/dist/sdk/lifecycle/task-composition.js +1 -1
  114. package/dist/sdk/merge/reconcile.js +1 -1
  115. package/dist/sdk/merge/three-way.js +2 -2
  116. package/dist/sdk/notes.js +1 -1
  117. package/dist/sdk/public-surface.json +1 -1
  118. package/dist/sdk/query/projection-contracts.d.ts +1 -1
  119. package/dist/sdk/query/projection-contracts.js +1 -1
  120. package/dist/sdk/runtime.js +1 -1
  121. package/dist/sdk/telemetry.d.ts +5 -0
  122. package/dist/sdk/telemetry.js +1 -1
  123. package/docs/AGENT_UX_CONTRACTS.md +8 -0
  124. package/docs/ARCHITECTURE.md +7 -0
  125. package/docs/CLI_GRAMMAR.md +31 -0
  126. package/docs/COMMAND_NAMESPACES.md +7 -4
  127. package/docs/CONFIGURATION.md +13 -2
  128. package/docs/HISTORY_OPERATIONS.md +46 -0
  129. package/docs/HISTORY_RECOVERY.md +27 -2
  130. package/docs/LIFECYCLE_COMMANDS.md +19 -2
  131. package/docs/MERGE_SAFETY.md +64 -3
  132. package/docs/WORKFLOW_POLICIES.md +47 -3
  133. package/docs/generated/AGENT_CAPABILITY_ROUTING.md +4 -4
  134. package/docs/generated/AGENT_COMMAND_SURFACE.md +10 -0
  135. package/docs/generated/FLAG_LEXICON_BUDGETS.md +11 -1
  136. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +8 -5
  137. package/marketplace.json +2 -2
  138. package/package.json +1 -1
  139. package/packages/pm-beads/package.json +1 -1
  140. package/packages/pm-calendar/package.json +1 -1
  141. package/packages/pm-command-kit/package.json +1 -1
  142. package/packages/pm-digital-twin/package.json +1 -1
  143. package/packages/pm-governance-audit/README.md +22 -0
  144. package/packages/pm-governance-audit/package.json +1 -1
  145. package/packages/pm-guide-shell/extensions/guide-shell/index.ts +13 -26
  146. package/packages/pm-guide-shell/package.json +1 -1
  147. package/packages/pm-kanban/package.json +1 -1
  148. package/packages/pm-lifecycle-hooks/package.json +1 -1
  149. package/packages/pm-linked-test-adapters/package.json +1 -1
  150. package/packages/pm-search-advanced/package.json +1 -1
  151. package/packages/pm-templates/package.json +1 -1
  152. package/packages/pm-todos/package.json +1 -1
  153. package/packages/pm-vcs/package.json +1 -1
  154. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  155. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  156. package/dist/cli-bundle/chunks/chunk-FBY6PEIR.js +0 -20
  157. package/dist/cli-bundle/chunks/chunk-IRUNFLLG.js +0 -2
  158. package/dist/cli-bundle/chunks/chunk-RJZFAXBW.js +0 -235
  159. package/dist/cli-bundle/chunks/chunk-SGAKQIGQ.js +0 -29
  160. package/dist/cli-bundle/chunks/register-mutation-HAPHD4S7.js +0 -20
  161. package/dist/cli-bundle/focused-chunks/chunk-3JVTLBCW.js +0 -20
  162. package/dist/cli-bundle/focused-chunks/chunk-DZ3ATEFS.js +0 -2
  163. package/dist/cli-bundle/focused-chunks/chunk-M74YW332.js +0 -164
  164. package/dist/cli-bundle/focused-chunks/chunk-ONDKO4EL.js +0 -2
  165. package/dist/cli-bundle/focused-chunks/chunk-YOPNRWSX.js +0 -2
@@ -1,30 +1,30 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9ddd9ea4-8586-5d3d-9ed8-0bf9da49b9a5")}catch{}})();var z=["commands","renderers","hooks","schema","importers","search","parser","preflight","services"],lt=2,en=Object.freeze({migration:"schema",validation:"schema"}),__=Object.freeze({version:lt,capabilities:[...z],legacy_aliases:{...en}}),dt=["off","warn","enforce"],ut=["off","warn","enforce"],ft=["none","restricted","strict"],Ir=["block","warn"],mt=["commands.override","commands.handler","hooks.beforecommand","hooks.beforemutation","hooks.aftercommand","hooks.onwrite","hooks.onread","hooks.onindex","schema.flags","schema.itemfields","schema.itemtypes","schema.relationshipkinds","schema.migrations","schema.profiles","parser.override","preflight.override","services.override","renderers.override","importers.importer","importers.exporter","search.provider","search.vectorstore","services.assuranceprovider"],Ee=["output_format","error_format","help_format","lock_acquire","lock_release","history_append","item_store_write","item_store_delete","context_relevance","command_result"];function pt(){return{mode:"off",trust_mode:"off",require_provenance:!1,trusted_extensions:[],default_sandbox_profile:"none",allowed_extensions:[],blocked_extensions:[],allowed_capabilities:[],blocked_capabilities:[],allowed_surfaces:[],blocked_surfaces:[],allowed_commands:[],blocked_commands:[],allowed_actions:[],blocked_actions:[],allowed_services:[],blocked_services:[],extension_overrides:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a966bb77-c4be-593b-93f5-b6277072160e")}catch{}})();var va=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],Rr=va,y_=["draft","open","in_progress","blocked","closed","canceled"],h_=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],xr=["string","number","boolean","string_array","array","object"],b_=["create","update","update_many","list","search","calendar","context"],w_=["allow","warn","reject"],v_=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],E_=["project","global"],k_=["low","medium","high","critical"],O_=["low","medium","high","critical"],S_=["low","medium","high"];var A_=["minimal","default","strict","custom"],T_=["none","warn","strict"],C_=["progressive","strict"],I_=["off","warn","strict"],R_=["off","warn","strict"];var x_=["daily","weekly","monthly","yearly"],Ea=["mon","tue","wed","thu","fri","sat","sun"];function N_(e){return Ea.indexOf(e)}var D_=["draft","research","review","approved","executing","paused","completed","superseded"],M_=["pending","in_progress","completed","blocked","skipped","superseded"],P_=["codex","claude-code","cursor","generic"],$_=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],L_=["brief","standard","deep","full"],j_=["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0d16c1b3-1bc5-5973-a20d-78ada79d4c9b")}catch{}})();var Nr=["goal","objective","value","impact","outcome","why_now","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","unblock_note","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result"],ka=["id","title","description","type","pm_format_version","source_type","type_options","status","priority","tags","created_at","updated_at","deadline","reminders","events","closed_at","completed_at","assignee","claim_principal","source_owner","author","estimated_minutes","acceptance_criteria","design","external_ref","definition_of_ready","order",...Nr,"affected_version","fixed_version","component","regression","customer_impact","dependencies","comments","notes","learnings","files","tests","test_runs","docs","close_reason","duplicate_of","plan_mode","plan_scope","plan_harness","plan_resume_context","plan_validation","plan_decisions","plan_discoveries","plan_steps"],Oa=ka;(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6e329ab1-f22d-5749-b8a4-0a6e7a1c8023")}catch{}})();var Sa=Object.freeze([{id:"draft",roles:["draft"]},{id:"open",roles:["active","default_open"]},{id:"in_progress",aliases:["in-progress"],roles:["active"]},{id:"blocked",roles:["blocked"]},{id:"closed",roles:["terminal","terminal_done","default_close"]},{id:"canceled",aliases:["cancelled"],roles:["terminal","terminal_canceled","default_cancel"]}]),Aa=Object.freeze({draft_status:"draft",open_status:"open",in_progress_status:"in_progress",blocked_status:"blocked",close_status:"closed",canceled_status:"canceled"}),_t=".agents/pm",gt="settings.json";var Ta=["","epics","features","tasks","chores","issues","schema","history","search","extensions","locks"],Ca=["decisions","events","reminders","milestones","meetings","plans"],B_=[...Ta,...Ca],Fe={Epic:"epics",Feature:"features",Task:"tasks",Chore:"chores",Issue:"issues",Decision:"decisions",Event:"events",Reminder:"reminders",Milestone:"milestones",Meeting:"meetings",Plan:"plans"},Ia={minimal:{ownership_enforcement:"none",create_mode_default:"progressive",close_validation_default:"off",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!1,duplicate_detection_mode:"off",duplicate_detection_threshold:.8,duplicate_detection_limit:3},default:{ownership_enforcement:"warn",create_mode_default:"progressive",close_validation_default:"warn",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3},strict:{ownership_enforcement:"strict",create_mode_default:"strict",close_validation_default:"strict",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"strict",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3}},Ra=["no active blocker","ready for planned execution sequencing","work completed","work is closed"],tn={blocked_reason:["no active blocker because work is closed","work is closed"],resolution:["closed with implementation evidence","closed with verification evidence","work completed and recorded","work is closed"],actual_result:["closed and recorded","work completed","work completed and recorded"]};function Dr(e){return e?[...e]:void 0}var V_={version:1,id_prefix:"pm-",ids:{token_length:4},author_default:"",agent_identity:{probes_enabled:!0,identity_vocabulary:{version:1,aliases:{}},harness_signals:[]},mutation_guard:{require_attributed_author:!1,secret_guard:"advise",stale_in_progress_hours:72},item_format:"toon",locks:{ttl_seconds:1800,wait_ms:3e3},checkpoints:{retention_days:14},output:{default_format:"toon"},ux:{deprecation_hints:!0},history:{missing_stream:"auto_create",compact_policy:{enabled:!1,max_entries:500,trigger:"health_warn"}},validation:{sprint_release_format:"warn",parent_reference:"warn",metadata_profile:"core",metadata_required_fields:[],lifecycle_stale_blocker_reason_patterns:[...Ra],lifecycle_closure_like_blocked_reason_patterns:[...tn.blocked_reason],lifecycle_closure_like_resolution_patterns:[...tn.resolution],lifecycle_closure_like_actual_result_patterns:[...tn.actual_result],estimate_defaults_by_type:{}},governance:{preset:"minimal",...Ia.minimal},workflow:{definition_of_done:[]},testing:{record_results_to_items:!1,allow_untrusted_linked_tests:!1},telemetry:{enabled:!0,first_run_prompt_completed:!1,capture_level:"redacted",endpoint:"https://pm-cli.unbrained.dev/v1/events",installation_id:"",retention_days:365},agent_guidance:{prompt_completed:!1,declined:!1,declined_at:"",template_version:1,last_checked_files:[]},item_types:{definitions:[]},schema:{version:1,files:{types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"},statuses:Sa.map(e=>({...e,aliases:Dr(e.aliases),roles:Dr(e.roles)})),fields:[],workflow:{...Aa},unknown_field_policy:"allow"},extensions:{enabled:[],disabled:[],policy:pt()},search:{score_threshold:0,hybrid_semantic_weight:.7,max_results:50,embedding_model:"",embedding_batch_size:32,embedding_timeout_ms:3e4,scanner_max_batch_retries:3,provider:"",default_mode:"auto",mutation_refresh_policy:"semantic_configured",query_expansion:{enabled:!1,provider:""},rerank:{enabled:!1,model:"",top_k:20}},providers:{openai:{base_url:"",api_key:"",model:""},ollama:{base_url:"",model:""}},context:{default_depth:"brief",activity_limit:10,stale_threshold_days:7,sections:{hierarchy:!0,activity:!0,progress:!0,recently_created:!0,unparented:!0,blockers:!0,files:!0,workload:!0,staleness:!0,tests:!0}},vector_store:{adapter:"",collection_name:"pm_items",qdrant:{url:"",api_key:""},lancedb:{path:""}}},W_={metadata:{},body:""},y={SUCCESS:0,GENERIC_FAILURE:1,USAGE:2,NOT_FOUND:3,CONFLICT:4,DEPENDENCY_FAILED:5,NO_EFFECT:6,PARTIAL_EFFECT:7},G_=Object.freeze({unknown_command:"usage",unknown_option:"usage",missing_required_option:"usage",missing_required_argument:"usage",invalid_command_usage:"usage",linked_test_value_not_quoted:"usage",invalid_argument_value:"validation",health_findings:"validation",validation_findings:"validation",close_through_update:"validation",no_update_fields:"validation",unsupported_update_option:"validation",tracker_not_initialized:"validation",item_not_found:"validation",ownership_conflict:"conflict",lock_conflict:"conflict",terminal_state_conflict:"conflict",dependency_failed:"runtime",init_gitignore_unwritable:"runtime",merge_git_config_unwritable:"runtime",command_failed:"runtime",unknown_error:"runtime"});(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="20b70512-0d72-5ed0-a27c-df849db200a4")}catch{}})();var h=class extends Error{exitCode;code;context;constructor(t,n,r={}){super(t),this.name="PmCliError",this.exitCode=n,this.context=r,this.code=r.code}};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9961b408-ad70-5556-84dd-5ca1b1497c27")}catch{}})();var xa=new Set(["name","version","entry","priority","description","author","capabilities","manifest_version","pm_min_version","pm_max_version","engines","trusted","provenance","sandbox_profile","permissions","activation","contributions","legacy_capability_aliases"]);function Na(e){return{unknownKeys:Object.keys(e).filter(t=>!xa.has(t)).sort((t,n)=>t>n?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function Da(e){let t=Na(e),n=t.unknownKeys.map(r=>({code:"manifest_unknown_key",path:r,...r==="compatibility"?{suggested_key:"pm_min_version"}:{},message:r==="compatibility"?'Manifest key "compatibility" is ignored; declare the canonical pm_min_version and optional pm_max_version fields instead.':`Manifest key "${r}" is not part of the extension manifest contract and will be ignored.`}));return t.missingVersionBounds&&n.push({code:"no_version_bounds_declared",path:"$",suggested_key:"pm_min_version",message:"No canonical pm version bounds are declared; add pm_min_version so compatibility intent is explicit."}),{ok:n.length===0,findings:n}}function Mr(e,t,n){return Da(n).findings.map(r=>r.code==="manifest_unknown_key"?`extension_manifest_unknown_key:${e}:${t.name}:key=${r.path}${r.suggested_key?`:suggested=${r.suggested_key}`:""}`:`extension_manifest_no_version_bounds:${e}:${t.name}:suggested=pm_min_version`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4c00e38a-27df-5315-91e8-d35c03ed6bf3")}catch{}})();var nn=[{kind:"blocked_by",direction:"directed",traversal:"ordering",inverse:"blocks",ordering:!0,precedence:"target_before_source",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["depends_on"],compatibilityVersion:1,allowSelf:!1},{kind:"blocks",direction:"directed",traversal:"ordering",inverse:"blocked_by",ordering:!0,precedence:"source_before_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"parent",direction:"directed",traversal:"hierarchy",outcomeTraversal:"source_to_target",inverse:"child",ordering:!1,hierarchy:!0,hierarchyDirection:"target_parent",outgoing:"one",incoming:"many",lifecycle:"supersedable",aliases:["child_of","epic"],compatibilityVersion:1,allowSelf:!1},{kind:"child",direction:"directed",traversal:"hierarchy",outcomeTraversal:"target_to_source",inverse:"parent",ordering:!1,hierarchy:!0,hierarchyDirection:"source_parent",outgoing:"many",incoming:"one",lifecycle:"supersedable",aliases:["parent_child","task"],compatibilityVersion:1,allowSelf:!1},{kind:"related",direction:"undirected",traversal:"association",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["related_to"],compatibilityVersion:1,allowSelf:!1},{kind:"discovered_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"incident_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"implements",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"recurs_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,temporalOrder:"source_after_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"verifies",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"supersedes",direction:"directed",traversal:"semantic",outcomeTraversal:"both",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"supersedable",compatibilityVersion:1,allowSelf:!1}];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b658dc99-fdbb-5d10-9dd6-5f5c263bf48b")}catch{}})();function bt(e){return e.trim().toLowerCase().replaceAll("-","_")}function Ma(e){if(e===void 0)return;let t=bt(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function on(e,t=new Set){if(e===null||typeof e!="object"||t.has(e))return e;if(t.add(e),Array.isArray(e)){for(let n of e)on(n,t);return Object.freeze(e)}for(let n of Object.values(e))on(n,t);return Object.freeze(e)}function Pa(e,t){if(e.precedence!==void 0&&e.precedence!=="source_before_target"&&e.precedence!=="target_before_source")throw new TypeError(`Invalid relationship precedence for ${t}`);if(!e.ordering&&e.precedence!==void 0)throw new TypeError(`Non-ordering relationship kind cannot declare precedence: ${t}`)}function $a(e,t){if(e.temporalOrder!==void 0&&e.temporalOrder!=="source_after_target")throw new TypeError(`Invalid relationship temporal order for ${t}`);if(e.direction!=="directed"&&e.temporalOrder!==void 0)throw new TypeError(`Undirected relationship kind cannot declare temporal order: ${t}`)}function La(e,t){if(e.hierarchyDirection!==void 0&&e.hierarchyDirection!=="source_parent"&&e.hierarchyDirection!=="target_parent")throw new TypeError(`Invalid relationship hierarchy direction for ${t}`);if(!e.hierarchy&&e.hierarchyDirection!==void 0)throw new TypeError(`Non-hierarchy relationship kind cannot declare hierarchy direction: ${t}`)}function ja(e){if(typeof e!="object"||e===null)throw new TypeError("Relationship kind definition requires an object");if(typeof e.kind!="string")throw new TypeError("Relationship kind requires a string identifier");let t=bt(e.kind);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid relationship kind: ${e.kind}`);if(!Number.isInteger(e.compatibilityVersion)||e.compatibilityVersion<1)throw new TypeError(`Invalid compatibility version for ${t}`);return t}function Fa(e,t){if(!["directed","undirected"].includes(e.direction))throw new TypeError(`Invalid relationship direction for ${t}`);if(typeof e.ordering!="boolean")throw new TypeError(`Invalid relationship ordering flag for ${t}`);if(![void 0,!0,!1].includes(e.hierarchy))throw new TypeError(`Invalid relationship hierarchy flag for ${t}`);if(!["one","many"].includes(e.outgoing))throw new TypeError(`Invalid outgoing relationship cardinality for ${t}`);if(!["one","many"].includes(e.incoming))throw new TypeError(`Invalid incoming relationship cardinality for ${t}`);if(!["persistent","supersedable","ephemeral"].includes(e.lifecycle))throw new TypeError(`Invalid relationship lifecycle for ${t}`);if(typeof e.allowSelf!="boolean")throw new TypeError(`Invalid relationship self-edge flag for ${t}`);if(e.traversal!==void 0&&!["hierarchy","ordering","semantic","association"].includes(e.traversal))throw new TypeError(`Invalid relationship traversal family for ${t}`);if(e.outcomeTraversal!==void 0&&!["source_to_target","target_to_source","both"].includes(e.outcomeTraversal))throw new TypeError(`Invalid outcome traversal for ${t}`);if(e.direction==="undirected"&&e.outcomeTraversal!==void 0&&e.outcomeTraversal!=="both")throw new TypeError(`Undirected relationship kind cannot declare directional outcome traversal: ${t}`)}function Ua(e,t){if(e.payloadSchema!==void 0&&(typeof e.payloadSchema!="object"||e.payloadSchema===null||Array.isArray(e.payloadSchema)))throw new TypeError(`Invalid relationship payload schema for ${t}`);if(e.aliases!==void 0&&(!Array.isArray(e.aliases)||e.aliases.some(n=>typeof n!="string")))throw new TypeError(`Invalid relationship aliases for ${t}`)}function za(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var sn=class{#e=new Map;#n=new Map;constructor(t=nn){for(let n of t)this.register(n)}register(t){let n=ja(t);if(Fa(t,n),Ua(t,n),Pa(t,n),$a(t,n),La(t,n),this.#e.has(n)||this.#n.has(n))throw new TypeError(`Relationship kind already registered: ${n}`);let r=Ma(t.inverse),o=[...new Set((t.aliases??[]).map(bt))].sort();for(let s of o){if(!/^[a-z][a-z0-9_]*$/.test(s))throw new TypeError(`Invalid relationship alias: ${s}`);if(s===n||this.#e.has(s)||this.#n.has(s))throw new TypeError(`Relationship alias already registered: ${s}`)}let i=Object.freeze({...t,kind:n,traversal:za(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:r,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?on(structuredClone(t.payloadSchema)):void 0});this.#e.set(n,i);for(let s of o)this.#n.set(s,n);return this}resolve(t){if(typeof t!="string")return;let n=bt(t);return this.#e.get(this.#n.get(n)??n)}require(t){let n=this.resolve(t);if(!n)throw new TypeError(`Unknown relationship kind: ${t}`);return n}list(){return Object.freeze([...this.#e.values()].sort((t,n)=>t.kind.localeCompare(n.kind)))}};function an(){return new sn}var ie=an();function Z_(e){return ie.require(e).kind}function eg(e){return ie.resolve(e)?.kind}function tg(e,t=ie){return t.resolve(e)?.ordering===!0}function qa(e,t,n,r=ie){let o=Ue(e),i=Ue(t);if(!o||!i)throw new TypeError("Relationship endpoint must not be empty");let s=r.require(n);if(o===i&&!s.allowSelf)throw new TypeError(`Self relationship is not allowed for ${s.kind}`);return s}function yt(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function Ba(e,t,n){let r=typeof e.source=="string"?e.source.trim():"",o=typeof e.target=="string"?e.target.trim():"";if(!t.has(r)||!t.has(o))throw new TypeError(`Relationship endpoint not found: ${r} -> ${o}`);let i=qa(r,o,e.kind,n),s=Object.freeze({...e,source:r,target:o,kind:i.kind}),a=i.direction==="undirected"?[r,o].sort().join("\0"):`${r}\0${o}`;return{edge:s,identity:`${i.kind}\0${a}`}}function ht(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function Ue(e){return typeof e=="string"?e.trim():""}function rn(e,t){let n=Ue(e);return n&&t.has(n)?n:void 0}function Va(e,t,n){let r=[t],o=t;for(;o!==e;)o=n.get(o),r.push(o);return r.reverse()}var Pr=class e{#e;#n;#o;#r;#s=new Map;#a=new Map;constructor(t,n,r=ie){this.#e=r,this.#n=new Set([...t].filter(i=>typeof i=="string").map(i=>i.trim()).filter(Boolean)),this.#o=Object.freeze([...this.#n].sort());let o=new Map;for(let i of n){let{edge:s,identity:a}=Ba(i,this.#n,r);o.set(a,s)}this.#r=Object.freeze([...o.values()].sort(yt));for(let i of this.#r)ht(this.#s,i.source,i),ht(this.#a,i.target,i),r.require(i.kind).direction==="undirected"&&(ht(this.#s,i.target,i),ht(this.#a,i.source,i))}static fromItems(t,n=ie){let r=new Set(t.map(i=>Ue(i.id)).filter(Boolean)),o=[];for(let i of t){let s=Ue(i.id);if(!s)continue;let a=rn(i.parent,r);a&&o.push({source:s,target:a,kind:"parent"});let c=rn(i.blocked_by,r);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let l of i.dependencies??[]){let d=rn(l.id,r);d&&n.resolve(l.kind)&&o.push({source:s,target:d,kind:l.kind,createdAt:l.created_at,author:l.author})}}return new e(r,o,n)}edges(){return this.#r}incidentEdges(t){this.#i(t);let n=this.#s.get(t)??[],r=this.#a.get(t)??[];if(n.length===0)return Object.freeze([...r]);if(r.length===0)return Object.freeze([...n]);let o=[],i=0,s=0;for(;i<n.length||s<r.length;){let a=n[i],c=r[s],l=a===void 0?c:c===void 0||yt(a,c)<=0?a:c;o.at(-1)!==l&&o.push(l),a===l&&(i+=1),c===l&&(s+=1)}return Object.freeze(o)}nodes(){return this.#o}hasNode(t){return this.#n.has(t)}registry(){return this.#e}#i(t){if(!this.#n.has(t))throw new TypeError(`Relationship node not found: ${t}`)}#c(t,n){if(!n)return!0;let r=this.#e.require(t.kind);return n.has(t.kind)||r.inverse!==void 0&&n.has(r.inverse)}#t(t,n,r){let o=[...n==="incoming"?[]:this.#s.get(t)??[],...n==="outgoing"?[]:this.#a.get(t)??[]];return[...new Set(o)].filter(i=>this.#c(i,r)).map(i=>({id:i.source===t?i.target:i.source,edge:i})).sort((i,s)=>i.id.localeCompare(s.id)||yt(i.edge,s.edge))}adjacency(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=[...new Set(o.map(c=>c.id))],a=s.slice(0,i);return{value:a,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:a.length<s.length,nextCursor:a.at(-1)}}}neighborEdges(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(a=>this.#e.require(a).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=o.slice(0,i);return{value:s,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:s.length<o.length,nextCursor:s.at(-1)?.id}}}closure(t,n={}){this.#i(t);let r=n.kinds?new Set(n.kinds.map(f=>this.#e.require(f).kind)):void 0,o=n.direction??"outgoing",i=n.limit??Number.POSITIVE_INFINITY,s=n.maxDepth??Number.POSITIVE_INFINITY,a=new Set([t]),c=[],l=[{id:t,depth:0}],d=0,u=0,m=!1;e:for(let f=0;f<l.length;f+=1){n.signal?.throwIfAborted();let p=l[f];d+=1;let _=this.#t(p.id,o,r);if(u+=_.length,p.depth>=s){_.some(g=>!a.has(g.id))&&(m=!0);continue}for(let g of _)if(!a.has(g.id)){if(c.length>=i){m=!0;break e}a.add(g.id),c.push(g.id),l.push({id:g.id,depth:p.depth+1})}}return{value:c,meta:{visitedNodes:d,inspectedEdges:u,truncated:m,nextCursor:c.at(-1)}}}shortestPath(t,n,r={}){if(this.#i(t),this.#i(n),t===n)return{value:[t],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}};let o=r.kinds?new Set(r.kinds.map(f=>this.#e.require(f).kind)):void 0,i=r.direction??"outgoing",s=r.maxDepth??Number.POSITIVE_INFINITY,a=[{id:t,depth:0}],c=new Map,l=new Set([t]),d=0,u=0,m=!1;for(let f=0;f<a.length;f+=1){r.signal?.throwIfAborted();let p=a[f];d+=1;let _=this.#t(p.id,i,o);if(u+=_.length,p.depth>=s){_.some(g=>!l.has(g.id))&&(m=!0);continue}for(let g of _)if(!l.has(g.id)){if(c.set(g.id,p.id),g.id===n)return{value:Va(t,n,c),meta:{visitedNodes:d,inspectedEdges:u,truncated:!1}};l.add(g.id),a.push({id:g.id,depth:p.depth+1})}}return{value:[],meta:{visitedNodes:d,inspectedEdges:u,truncated:m}}}subgraph(t,n={}){let r=this.closure(t,n),o=[t,...r.value].sort(),i=new Set(o),s=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,a=new Set;for(let c of o)for(let l of this.#s.get(c)??[])i.has(l.source)&&i.has(l.target)&&this.#c(l,s)&&a.add(l);return{value:{nodes:o,edges:[...a].sort(yt)},meta:r.meta}}};function ng(e,t,n=ie){return{source:e,target:t.id,kind:n.require(t.kind).kind,createdAt:t.created_at,author:t.author}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="720821b8-d18d-5a10-a8b9-f16073dc1fc4")}catch{}})();function S(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Wa(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function $r(e){return e?M(e):{}}function Lr(e){return e?M(e):Wa()}function M(e){return structuredClone(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7d96fda0-1f2f-5e34-99da-c3c5ad0f53f6")}catch{}})();var Ga=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),Ka=["commands","command_overrides","command_handlers","hooks","flag_commands","item_types","item_fields","relationship_kinds","migrations","profiles","importers","exporters","search_providers","vector_store_adapters","assurance_providers","parser_overrides","service_overrides","renderer_overrides"];function Ha(e,t){for(let n of Ka){let r=e[n];if(r===void 0)continue;if(!Array.isArray(r)||r.some(i=>typeof i!="string"))return!1;let o=r.map(i=>Ga.has(n)?S(i):i.trim()).filter(i=>i.length>0);t[n]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function Ya(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n;if(r.format!=="json"&&r.format!=="toon"||!Array.isArray(r.commands)||r.commands.some(o=>typeof o!="string")||typeof r.result_discriminator!="boolean")return null;t.push({format:r.format,commands:[...new Set(r.commands.map(o=>S(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:r.result_discriminator})}return t.sort((n,r)=>n.format.localeCompare(r.format))}function Xa(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n.commands;if(!Array.isArray(r)||r.some(o=>typeof o!="string"))return null;t.push({commands:[...new Set(r.map(o=>S(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return t}function cn(e){if(e==null)return;if(typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.schema_version!==1)return null;let n={schema_version:1};if(!Ha(t,n))return null;let r=t.preflight_overrides;if(r!==void 0&&(!Number.isInteger(r)||r<0))return null;typeof r=="number"&&(n.preflight_overrides=r);let o=t.renderer_ownership;if(o!==void 0){let s=Ya(o);if(s===null)return null;n.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=Xa(i);if(s===null)return null;n.preflight_ownership=s}return n}function sg(e){return{schema_version:1,commands:e.commands,command_overrides:e.command_overrides,command_handlers:e.command_handlers,hooks:e.hooks,flag_commands:e.flag_commands,item_types:e.item_types,item_fields:e.item_fields,...e.relationship_kinds?{relationship_kinds:e.relationship_kinds}:{},migrations:e.migrations,profiles:e.profiles,importers:e.importers,exporters:e.exporters,search_providers:e.search_providers,vector_store_adapters:e.vector_store_adapters,...e.assurance_providers?{assurance_providers:e.assurance_providers}:{},parser_overrides:e.parser_overrides,service_overrides:e.service_overrides,renderer_overrides:e.renderer_overrides,...e.renderer_ownership?{renderer_ownership:e.renderer_ownership}:{},preflight_overrides:e.preflight_overrides,...e.preflight_ownership?{preflight_ownership:e.preflight_ownership}:{}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e2f961be-3b2e-520d-8e27-bcc1b450b44d")}catch{}})();var Ja=[["history-redact","history redact"],["history-repair","history repair"],["history-compact","history compact"],["activity","history activity"],["restore","history restore"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-tqel"})),Qa=[...["next","focus"].map(e=>({alias:e,canonical:`context ${e}`,owner:"pm-kcs4"})),...["stats","health","validate","gc","telemetry","eval","test-all"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-6apl"})),...["normalize","reindex"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-3i9q8g"})),{alias:"events",canonical:"history events",owner:"pm-3i9q8g"}].map(e=>({...e,canonical_argv:e.canonical.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap"})),Za=[["update-many","update many"],["close-many","close many"],["delete","close delete"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-ik19"})),ec=[...Qa,...Za,...[["copy","item copy","pm-m6g87m"],["merge","workspace merge","pm-m6g87m"],["duplicates","item duplicates","pm-fmy9ih"],["dedupe-audit","item duplicates audit","pm-fmy9ih"],["dedupe-merge","item duplicates merge","pm-fmy9ih"],["comments-audit","item audit-comments","pm-fmy9ih"],["search-advanced","search advanced","pm-wfskfn"]].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:n}))],ln=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...Ja,...ec];function cg(e){let t;for(let n of ln)n.canonical_argv.length<=(t?.canonical_argv.length??0)||n.canonical_argv.every((r,o)=>r===(o===0&&e[o]==="ctx"?"context":e[o]))&&(t=n);return t}function tc(e){let t=e.trim().replace(/\s+/gu," ");return ln.find(n=>n.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function ze(e){return tc(e)}var wt=[...ln,...[["start-task","claim","--start"],["pause-task","release","--pause"],["close-task","close","--release-assignment"]].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:[t,n],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-eq4x"})),{alias:"tests",canonical:"test",canonical_argv:["test"],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-u4t9gp"},...[["fetch","get"],["read","get"],["show","get"],["view","get"],["comment","comments"],["note","notes"],["learning","learnings"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:[t],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-pbyu"})),...[["extension list","extension catalog"],["extension scaffold","extension init"],["package list","package catalog"],["package scaffold","package init"],["packages list","packages catalog"],["packages scaffold","packages init"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-ya7x55"})),{alias:"list-all",canonical:"list",canonical_argv:["list","--all"],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"},...[["list-draft","draft"],["list-open","open"],["list-in-progress","in_progress"],["list-blocked","blocked"],["list-closed","closed"],["list-canceled","canceled"]].map(([e,t])=>({alias:e,canonical:"list",canonical_argv:["list","--status",t],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"})),...[["extension","package"],["install","package install"],["upgrade","package upgrade"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-tnud"}))],lg=Object.fromEntries(wt.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function dg(e){let t=e.trim().toLowerCase();return wt.find(n=>n.alias===t)}function ug(e){return`Deprecated command \`${e.alias}\`; use \`pm ${e.canonical_argv.join(" ")}\`.`}import{createHash as Ur}from"node:crypto";import nc from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c036d6cf-6a10-5c74-9e2f-e7c953339e2c")}catch{}})();function rc(e){if(e===null)return null;if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="bigint")return e.toString();if(e===void 0)return"undefined";if(typeof e=="symbol")return e.toString();if(typeof e=="function")return`[function:${e.name||"anonymous"}]`}function oc(e){let t=Object.keys(e).sort(),n={};for(let r of t){let o=e[r];o!==void 0&&(n[r]=vt(o))}return n}function vt(e){let t=rc(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(r=>vt(r));if(e instanceof Date)return e.toISOString();let n=e;if(typeof n.toJSON=="function"){let r=n.toJSON();if(r!==e)return vt(r)}return oc(e)}function se(e){return JSON.stringify(vt(e))}function jr(e,t,n,r){for(let o=0;o<t.length;o+=1)if(!n.has(o)&&r(e,t[o]))return n.add(o),!0;return!1}function ic(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function sc(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function ac(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let n=[...t],r=new Set;for(let o of e)if(!jr(o,n,r,q))return!1;return!0}function cc(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let n=[...t.entries()],r=new Set;for(let[o,i]of e.entries())if(!jr([o,i],n,r,([a,c],[l,d])=>q(a,l)&&q(c,d)))return!1;return!0}function lc(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,r)=>q(n,t[r]))}function dc(e,t){let n=Object.keys(e).sort((o,i)=>o.localeCompare(i)),r=Object.keys(t).sort((o,i)=>o.localeCompare(i));if(n.length!==r.length)return!1;for(let o=0;o<n.length;o+=1){let i=n[o];if(i!==r[o]||!q(e[i],t[i]))return!1}return!0}var uc=[ic,sc,ac,cc,lc];function q(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let n of uc){let r=n(e,t);if(r!==void 0)return r}return dc(e,t)}function pg(e){return nc.createHash("sha256").update(e,"utf8").digest("hex")}function _g(e,t){let n={};for(let o of t){let i=e[o];i!==void 0&&(n[o]=i)}let r=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of r){let i=e[o];i!==void 0&&(n[o]=i)}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8b0d8654-211b-57bf-852f-8a153849e8fd")}catch{}})();var fc=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],Fr=256,dn=64;function P(e){throw new h(`Invalid workflow policy: ${e}`,y.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function W(e,t,n){if(typeof e!="object"||e===null||Array.isArray(e))return P(`${n} must be an object`);let r=e;return Object.keys(r).some(o=>!t.includes(o))?P(`${n} contains an unknown key`):r}function ae(e,t,n=128){return typeof e!="string"||!e.trim()||e.length>n?P(`${t} must be nonempty text of at most ${n} characters`):e.trim()}function qe(e,t){if(!Array.isArray(e)||e.length===0||e.length>dn)return P(`${t} requires 1-${dn} terms`);let n=e.map(r=>ae(r,t));return t==="fields"&&n.some(r=>!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$/.test(r)||r.split(".").some(o=>["__proto__","constructor","prototype"].includes(o)))?P("fields must be safe metadata paths of at most eight segments"):[...new Set(n)]}function mc(e){let t=W(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(W(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>dn?P("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(n=>!Array.isArray(n)||n.length!==2?P("transition pairs need two statuses"):[ae(n[0],"from"),ae(n[1],"to")])}):t.kind==="authors"?(W(t,["kind","authors"],"authors rule"),{kind:"authors",authors:qe(t.authors,"authors")}):t.kind==="require_fields"?(W(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:qe(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(W(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:qe(t.fields,"fields"),authors:qe(t.authors,"authors")}):P("unknown rule kind")}function pc(e){let t={},n=W(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let r of["types","tags","statuses","operations","parents"])n[r]!==void 0&&(t[r]=qe(n[r],r));if(n.dependency!==void 0){let r=W(n.dependency,["kind","id"],"dependency");t.dependency={kind:ae(r.kind,"dependency kind"),...r.id===void 0?{}:{id:ae(r.id,"dependency id")}}}return t}function _c(e){let t=W(e,["id","description","subject","effect","rule"],"policy"),n=ae(t.id,"id");return/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(n)?t.effect!==void 0&&(typeof t.effect!="string"||!["advise","warn","refuse"].includes(t.effect))?P("effect must be advise, warn, or refuse"):{id:n,rule:mc(t.rule),...t.subject===void 0?{}:{subject:pc(t.subject)},...t.description===void 0?{}:{description:ae(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:P("id must be a stable token")}function gc(e){let t=W(e,["version","enforcement","policies"],"document");if(t.version!==1)return P("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return P("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>Fr)return P(`policies must contain at most ${Fr} declarations`);let n=t.policies.map(_c);return new Set(n.map(r=>r.id)).size!==n.length?P("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:n}}function Et(e,t){let n=e;for(let r of t.split(".")){if(typeof n!="object"||n===null||!Object.hasOwn(n,r))return;n=n[r]}return n}function yc(e){return e==null?!1:typeof e=="string"?e.trim().length>0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0}function zr(e){return Ur("sha256").update(se(e)).digest("hex")}function hc(e,t){let n=e.rule.kind==="approval"?e.rule.fields:[];return Ur("sha256").update(se({id:t.id,fields:n.map(r=>[r,Et(t,r)])})).digest("hex")}function bc(e,t){return Array.isArray(t)&&t.some(n=>typeof n=="object"&&n!==null&&"kind"in n&&n.kind===e.kind&&(e.id===void 0||"id"in n&&n.id===e.id))}function wc(e,t,n){return!(e.types&&!e.types.some(r=>r.toLowerCase()===String(t.type).toLowerCase())||e.statuses&&!e.statuses.includes(String(t.status))||e.operations&&!e.operations.includes(n)||e.parents&&!e.parents.includes(String(t.parent))||e.tags&&(!Array.isArray(t.tags)||!e.tags.some(r=>t.tags.includes(r)))||e.dependency&&!bc(e.dependency,t.dependencies))}function vc(e,t){if(t.completeness_only&&(e.rule.kind!=="require_fields"||e.subject?.operations!==void 0)||e.rule.kind==="approval"&&t.before===null)return!1;let n=e.subject??{},r=t.after?.status??t.before?.status;return[t.before,t.after].some(o=>o!==null&&wc(n,{...o,status:r},t.operation))}function Ec(e,t,n,r){let o=["type","tags","parent","dependencies"].some(s=>!q(t.before?.[s],t.after?.[s]));return t.after&&(t.completeness_only||n||r||o)?e.filter(s=>!yc(Et(t.after,s))):[]}function kc(e,t,n,r){let o=t.after??t.before,i=hc(e,o);return t.approvals?.some(s=>s.policy_fingerprint===r&&s.content_fingerprint===i&&s.author!==t.author&&n.includes(s.author))??!1}function Oc(e,t,n){let r=e.rule,o=t.before?.status!==t.after?.status,i="fields"in r&&r.fields.some(s=>!q(Et(t.before,s),Et(t.after,s)));switch(r.kind){case"require_fields":{let s=Ec(r.fields,t,o,i);return{satisfied:s.length===0,missing_fields:s,remediation:"Supply the declared required fields before this lifecycle transition."}}case"transition":return{satisfied:!o||r.allowed.some(([s,a])=>s===String(t.before?.status??"$create")&&a===String(t.after?.status??"$delete")),missing_fields:[],remediation:"Choose a declared allowed transition; inspect pm schema policies."};case"authors":return{satisfied:r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared workflow actor perform this operation."};case"field_writers":return{satisfied:!i||r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared field writer change the protected fields."};case"approval":return{satisfied:!o||kc(e,t,r.authors,n),missing_fields:[],remediation:`Record an independent approval with pm schema policy-approve <item-id> --policy ${e.id} after preparing the reviewed fields.`}}}function qr(e,t,n){let r=e.policies.filter(o=>vc(o,t)).map(o=>{let i=o.effect??"advise",s=n(o);return{policy_id:o.id,policy_fingerprint:s,rule:o.rule.kind,effect:i==="refuse"&&e.enforcement!=="refuse"?"warn":i,...Oc(o,t,s)}});return{allowed:!r.some(o=>!o.satisfied&&o.effect==="refuse"),decisions:r,warnings:r.filter(o=>!o.satisfied).map(o=>`workflow_policy:${o.effect}:${o.policy_id}:${o.rule}`)}}function vg(e,t){return qr(e,t,zr)}function Eg(e){let t=gc(e),n=new Map(t.policies.map(r=>[r,zr(r)]));return r=>qr(t,r,o=>n.get(o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1dd71b26-fc38-5304-9156-f32b57cc1cc0")}catch{}})();var Sc=[...z],Ac=[...Ee],Tc=[...dt],Tg=[...ut],Cg=[...ft],Cc=[...mt],kt=["init","config","extension","package","packages","install","upgrade","create","item","copy","focus","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","aggregate","context","ctx","get","graph","search","duplicates","eval","next","history","events","history-redact","history-repair","history-compact","history-attest","history-author-acknowledge","merge","schema","profile","activity","restore","update","update-many","close","close-many","delete","append","comments","notes","learnings","files","docs","deps","plan","test","test-all","telemetry","stats","health","validate","assurance","gc","workspace","contracts","claim","release","start-task","pause-task","close-task","meet","event","remind","help"],Ig=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],Rg=["install","reconcile","report","driver"],Ic=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],Rc=["upgrade"],xc=["reopen"],Br={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Ot=Object.freeze(kt.flatMap(e=>e in Br?[]:e==="extension"||e==="package"?[...Ic.map(t=>`${e}-${t}`),...e==="package"?Rc.map(t=>`package-${t}`):[],e]:e==="item"?xc.map(t=>`item-${t}`):[e])),Nc=Object.freeze(wt.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Ot.includes(e.alias)).map(e=>e.alias)),xg=Object.freeze(Ot.filter(e=>!Nc.includes(e)));function Ng(e=kt,t=Ot,n=Br){let r=new Set(t),o=new Set(e);return{missing_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]===void 0),waived_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]!==void 0),stale_waivers:Object.keys(n).filter(i=>!o.has(i)||r.has(i)||t.some(s=>s.startsWith(`${i}-`)))}}function Dg(e){return Ot.includes(e)}function Mg(e){return Sc.includes(e)}function Pg(e){return Ac.includes(e)}function $g(e){return Tc.includes(e)}function Lg(e){return Cc.includes(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="de2a2a0e-8a39-5569-9af9-cbf557bce2a9")}catch{}})();function St(e,t,n){if(e===t)return 0;if(Math.abs(e.length-t.length)>n)return null;let r=t.length+1,o=new Array(r),i=new Array(r),s=new Array(r);for(let c=0;c<r;c+=1)o[c]=0,i[c]=c;for(let c=1;c<=e.length;c+=1){s[0]=c;let l=s[0];for(let d=1;d<=t.length;d+=1){let u=e[c-1]===t[d-1]?0:1,m=i[d-1]+u,f=s[d-1]+1,p=i[d]+1,_=Math.min(m,f,p);c>1&&d>1&&e[c-1]===t[d-2]&&e[c-2]===t[d-1]&&(_=Math.min(_,o[d-2]+1)),s[d]=_,_<l&&(l=_)}if(l>n)return null;for(let d=0;d<r;d+=1)o[d]=i[d],i[d]=s[d]}let a=i[t.length];return a<=n?a:null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1ddb0411-5fdd-56af-a524-0f6830c288a5")}catch{}})();function Be(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function X(e){return z.includes(e)}function Vr(e){let t=e.trim().toLowerCase();return X(t)?t:null}function Wr(e){return e.filter(t=>!X(t))}function un(e){let t=e.trim().toLowerCase();return t.length===0?null:en[t]??null}function Gr(e){let t=Be([...e].map(i=>i.toLowerCase())),n=[],r=[];for(let i of t){let s=un(i);if(s){n.push(s),r.push({alias:i,target:s});continue}n.push(i)}let o=[...new Map(r.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:Be(n),legacy_aliases:o}}function Dc(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=un(t);if(n)return n;let r=Math.max(1,Math.floor(t.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of z){let a=St(t,s,r);a!==null&&a<i&&(i=a,o=s)}return o}function Kr(e,t,n){let r=z.join(","),o=Dc(n)??"none";return`extension_capability_unknown:${e}:${t}:${n}:allowed=${r}:suggested=${o}`}function Hr(e,t,n){let r=n.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${r}`}function Mc(e){let t=/^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(e.trim());if(!t)return null;let[,n,r,o,i,s]=t,a=n,c=i.split(",").map(f=>f.trim()).filter(f=>f.length>0),l=un(o),u=(s==="none"?void 0:s)??l??void 0;return{layer:a,name:r,capability:o,allowed_capabilities:c,capability_contract_version:lt,suggested_capability:u,suggestion_source:u?l===u?"legacy_alias":"nearest_match":void 0,legacy_alias_target:l??void 0}}function Pc(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,n,r,o]=t,i=n,s=[...z],a=[];for(let c of o.split(",")){let[l,d]=c.split(">"),u=l?.trim(),m=d?.trim().toLowerCase();!u||!m||!X(m)||a.push({layer:i,name:r,capability:u,allowed_capabilities:s,capability_contract_version:lt,suggested_capability:m,suggestion_source:"legacy_alias",legacy_alias_target:m})}return a}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71c44385-0182-50f8-8e05-3aeebfe57ad9")}catch{}})();var $c={commands:["registerCommand","command override","command handler"],renderers:["registerRenderer"],hooks:["hooks.beforeCommand","hooks.beforeMutation","hooks.afterCommand","hooks.onWrite","hooks.onRead","hooks.onIndex"],schema:["registerFlags","registerItemFields","registerItemTypes","registerRelationshipKinds","registerMigration","registerProfile"],importers:["registerImporter","registerExporter"],search:["registerSearchProvider","registerVectorStoreAdapter"],parser:["registerParser"],preflight:["registerPreflight"],services:["registerService","registerAssuranceMeasurementProvider"]},Yr=":";function Xr(e,t){return`${e}${Yr}${fn(t)}`}function Lc(e){return e.slice(e.indexOf(Yr)+1)}function fn(e){return e.trim().toLowerCase()}function jc(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let r=Vr(n);r!==null&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function Jr(e){let t=new Map,n=(d,u)=>{for(let m of d){let f=Xr(m.layer,m.name),p=t.get(f);p===void 0&&(p=new Set,t.set(f,p)),p.add(u)}},{registrations:r,commands:o,parsers:i,preflight:s,services:a,renderers:c,hooks:l}=e;return n(r.commands,"commands"),n(o.overrides,"commands"),n(o.handlers,"commands"),n(r.flags,"schema"),n(r.item_fields,"schema"),n(r.item_types,"schema"),n(r.relationship_kinds??[],"schema"),n(r.migrations,"schema"),n(r.profiles,"schema"),n(r.importers,"importers"),n(r.exporters,"importers"),n(r.search_providers,"search"),n(r.vector_store_adapters,"search"),n(i.overrides,"parser"),n(s.overrides,"preflight"),n(a.overrides,"services"),n(r.assurance_providers??[],"services"),n(c.overrides,"renderers"),n(l.beforeCommand,"hooks"),n(l.beforeMutation,"hooks"),n(l.afterCommand,"hooks"),n(l.onWrite,"hooks"),n(l.onRead,"hooks"),n(l.onIndex,"hooks"),t}function Fc(e,t={}){let n=Jr(e),r=new Set;t.extensionName!==void 0&&r.add(fn(t.extensionName));for(let i of t.extensionNames??[])r.add(fn(i));let o=new Set;for(let[i,s]of n)if(!(r.size>0&&!r.has(Lc(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function Uc(e,t){let n=Jr(t),r=[];for(let o of e){let i=jc(o.capabilities);if(i.length===0)continue;let s=n.get(Xr(o.layer,o.name))??new Set,a=[...s].sort((l,d)=>l.localeCompare(d)),c=i.filter(l=>!s.has(l));r.push({layer:o.layer,name:o.name,declared:i,used:a,unused:c})}return r}import{createHash as zc}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]="15037266-75b7-5f8d-9565-e7848e720a49")}catch{}})();var mn=1,Zr=4096,qc=/^[A-Za-z0-9_-]+$/;function Qr(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function Yg(e,t){let n=new Set;for(let r of t)if(r.cursor_semantics==="presentation"){n.add(Qr(r.flag));for(let o of r.aliases??[])n.add(Qr(o))}return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function Xg(e,t){return zc("sha256").update(e).update("\0").update(se(t)).digest("hex").slice(0,24)}function Ve(e,t,n,r){return Buffer.from(JSON.stringify({version:mn,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function ce(e){return new h(e,y.USAGE,{code:"invalid_query_cursor",nextSteps:["Repeat the original query without --after to obtain a fresh cursor."]})}function Bc(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===mn&&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 pn(e){if(typeof e!="string")throw ce("Query cursor is malformed.");let t=e.trim();if(t.length===0||t.length>Zr||!qc.test(t))throw ce("Query cursor is malformed.");let n;try{n=JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{throw ce("Query cursor is malformed.")}if(!Bc(n))throw ce("Query cursor version or payload is unsupported.");return n}function _n(e,t){let n=pn(e);if(n.fingerprint!==t)throw ce(`Query cursor does not match the current filters, sort, or query (${n.fingerprint} != ${t}).`);return{after_id:n.after_id,...n.after_index===void 0?{}:{after_index:n.after_index},...n.snapshot===void 0?{}:{snapshot:n.snapshot}}}function Jg(e,t){return _n(e,t).after_id}function Vc(e,t,n,r){if(t===void 0)return 0;let o=_n(t,n),i=e.findIndex(s=>r(s)===o.after_id);if(i<0){if(o.after_index!==void 0)return Math.min(o.after_index,e.length);throw ce(`Query cursor item ${o.after_id} is no longer present in this result set.`)}return i+1}function Qg(e,t){if(t.cursor!==void 0&&_n(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw ce("Query cursor does not match the requested snapshot.");let n=Vc(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:Ve(t.fingerprint,t.readId(i),n+r.length-1,t.snapshot)}:{}}}var Zg=Object.freeze({version:mn,max_length:Zr});import{stripVTControlCharacters as Wc}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b4036040-c0b8-5d01-b490-3405722fd1c5")}catch{}})();var Gc=["full","compact","brief","summary","counts"],oy=["mutation","read","discovery","governance"],to=["error","warning","validation_summary","recovery_bundle"],Kc=["full","omit_explanation","limit_collections","compact_recovery","action_only"],Hc=new Set(["append","claim","close","close-many","close-task","comments","config","copy","create","delete","docs","event","files","focus","history-author-acknowledge","history-compact","history-redact","history-repair","init","item","learnings","meet","notes","pause-task","release","remind","restore","schema","start-task","update","update-many"]),Yc=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),Xc=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),Jc={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},Qc=3,Zc=2,el=192,tl={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},nl=to.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:tl[e],minimum_max_estimated_tokens:el,degradation_ladder:Kc,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),rl=new Map(nl.map(e=>[e.diagnostic_class,e]));function ol(e){let[t=""]=ze(e).split(/\s+/u);return Hc.has(t)?"mutation":Yc.has(t)?"discovery":Xc.has(t)?"governance":"read"}function no(e,t=ol(e)){let n=e.trim().replace(/\s+/gu," ");if(n.length===0)throw new TypeError("command must be a non-empty command path");let r=Jc[t];return il({command:n,budget_class:t,default_max_estimated_tokens:r,default_max_estimated_tokens_by_format:{toon:r,json:Math.ceil(r*Qc/Zc)},degradation_ladder:Gc,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function il(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,n]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var sl=kt.map(e=>no(e)),al=new Map(sl.map(e=>[e.command,e]));function ro(e,t={}){let n=e.trim().replace(/\s+/gu," "),[r]=ze(n).split(" "),o=al.get(r);return o?{...o,command:n}:t.generateFallback?no(n):null}function de(e){return Math.ceil(Math.max(0,e)/4)}function oo(e){let t=rl.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${to.join(", ")}`);return t}function J(e){return de(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function cl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gn(e){if(!cl(e))return;let t={};for(let n of["suggested_retry","suggested_retry_args","next_best_command","allowed_values","candidate_commands","missing","missing_required_fields","option_scope","retry_after_ms"]){let r=e[n];Array.isArray(r)?t[n]=n==="suggested_retry_args"?r:r.slice(0,3):r!==void 0&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}function ll(e,t){return typeof e!="string"||e.length<=t?e:`${e.slice(0,Math.max(1,t-3))}...`}function le(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;let n="...",r=Array.from(e),o=0,i=r.length;for(;o<i;){let s=Math.ceil((o+i)/2),a=`${r.slice(0,s).join("")}${n}`;Buffer.byteLength(a,"utf8")<=t?o=s:i=s-1}return`${r.slice(0,o).join("")}${n}`}function io(e){let t={};for(let n of["code","required","recovery","next_steps","exit_code","type","title","detail","why","examples"])Object.hasOwn(e,n)&&e[n]!==void 0&&(t[n]=e[n]);for(let[n,r]of Object.entries(e))n!=="__proto__"&&!Object.hasOwn(t,n)&&(t[n]=r);return t}var dl=new Set(["limit_collections","compact_recovery","action_only"]),ul=new Set(["compact_recovery","action_only"]);function fl(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:ll(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},n=gn(e.recovery);return n!==void 0?t.recovery=n:Array.isArray(e.next_steps)&&(t.next_steps=e.next_steps.slice(0,1)),e.exit_code!==void 0&&(t.exit_code=e.exit_code),e.type!==void 0&&(t.type=e.type),t}function ml(e,t){let n=structuredClone(e);if(t!=="full"&&(delete n.why,delete n.examples),dl.has(t))for(let[r,o]of Object.entries(n))Array.isArray(o)&&(n[r]=o.slice(0,3));if(ul.has(t)){let r=gn(n.recovery);r?n.recovery=r:delete n.recovery}return t!=="action_only"?io(n):fl(n)}function ke(e,t){let n={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let r=0;r<4;r+=1){let o=J(n),i=n.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return n}function pl(e,t,n){let r=ke(e,t);for(let i of["recovery","exit_code"])J(r)<=n||e[i]===void 0||(delete e[i],r=ke(e,t));let o=40;for(;J(r)>n&&o>4;)o-=4,e.code=le(String(e.code),o),e.required=le(String(e.required),o),r=ke(e,t);return r}function _l(e,t){let n=e.diagnostic_output,{estimated_tokens:r,...o}=n,i=o.omitted_fields.slice(0,8).map(u=>le(u,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=gn(e.recovery),c=a&&J(a)<=48?a:void 0,l={code:le(String(e.code),320),required:le(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},d=ke(l,s);for(;J(d)>t&&s.omitted_fields.length>0;)s.omitted_fields.pop(),s.omitted_fields_overflow_count=o.omitted_fields.length-s.omitted_fields.length,d=ke(l,s);return d=pl(l,s,t),d}function iy(e,t={}){let n=e,r=t.diagnosticClass??"error",o=oo(r),i=t.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.json,a=J(n),c=Object.keys(n);if(a<=s)return io(structuredClone(n));let l;for(let[d,u]of o.degradation_ladder.entries()){let m=ml(n,u),f=c.filter(_=>!Object.hasOwn(m,_)),p=ke(m,{diagnostic_class:r,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:d>0,degradation_steps:o.degradation_ladder.slice(0,d+1),omitted_fields:f});if(l=p,J(p)<=s)break}return J(l)>s&&(l=_l(l,s)),l}function eo(e){return Wc(e).replace(/\r\n/gu,`
2
- `).replace(/[^\P{Cc}\n]/gu," ")}function sy(e,t,n={}){let r=n.diagnosticClass??"error",o=oo(r),i=n.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.text,a=eo(e),c=de(Buffer.byteLength(a,"utf8")),l=c>s,d=`What is required:
1
+ (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9ddd9ea4-8586-5d3d-9ed8-0bf9da49b9a5")}catch{}})();var q=["commands","renderers","hooks","schema","importers","search","parser","preflight","services"],lt=2,tn=Object.freeze({migration:"schema",validation:"schema"}),y_=Object.freeze({version:lt,capabilities:[...q],legacy_aliases:{...tn}}),dt=["off","warn","enforce"],ut=["off","warn","enforce"],ft=["none","restricted","strict"],Ir=["block","warn"],mt=["commands.override","commands.handler","hooks.beforecommand","hooks.beforemutation","hooks.aftercommand","hooks.onwrite","hooks.onread","hooks.onindex","schema.flags","schema.itemfields","schema.itemtypes","schema.relationshipkinds","schema.migrations","schema.profiles","parser.override","preflight.override","services.override","renderers.override","importers.importer","importers.exporter","search.provider","search.vectorstore","services.assuranceprovider"],Ee=["output_format","error_format","help_format","lock_acquire","lock_release","history_append","item_store_write","item_store_delete","context_relevance","command_result"];function pt(){return{mode:"off",trust_mode:"off",require_provenance:!1,trusted_extensions:[],default_sandbox_profile:"none",allowed_extensions:[],blocked_extensions:[],allowed_capabilities:[],blocked_capabilities:[],allowed_surfaces:[],blocked_surfaces:[],allowed_commands:[],blocked_commands:[],allowed_actions:[],blocked_actions:[],allowed_services:[],blocked_services:[],extension_overrides:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a966bb77-c4be-593b-93f5-b6277072160e")}catch{}})();var Aa=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],Rr=Aa,b_=["draft","open","in_progress","blocked","closed","canceled"],w_=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],xr=["string","number","boolean","string_array","array","object"],v_=["create","update","update_many","list","search","calendar","context"],E_=["allow","warn","reject"],k_=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],O_=["project","global"],S_=["low","medium","high","critical"],A_=["low","medium","high","critical"],T_=["low","medium","high"];var C_=["minimal","default","strict","custom"],I_=["none","warn","strict"],R_=["progressive","strict"],x_=["off","warn","strict"],N_=["off","warn","strict"];var D_=["daily","weekly","monthly","yearly"],Ta=["mon","tue","wed","thu","fri","sat","sun"];function M_(e){return Ta.indexOf(e)}var P_=["draft","research","review","approved","executing","paused","completed","superseded"],$_=["pending","in_progress","completed","blocked","skipped","superseded"],L_=["codex","claude-code","cursor","generic"],j_=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],F_=["brief","standard","deep","full"],U_=["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0d16c1b3-1bc5-5973-a20d-78ada79d4c9b")}catch{}})();var Nr=["goal","objective","value","impact","outcome","why_now","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","unblock_note","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result"],Ca=["id","title","description","type","pm_format_version","source_type","type_options","status","priority","tags","created_at","updated_at","deadline","reminders","events","closed_at","completed_at","assignee","claim_principal","source_owner","author","estimated_minutes","acceptance_criteria","design","external_ref","definition_of_ready","order",...Nr,"affected_version","fixed_version","component","regression","customer_impact","dependencies","comments","notes","learnings","files","tests","test_runs","docs","close_reason","duplicate_of","plan_mode","plan_scope","plan_harness","plan_resume_context","plan_validation","plan_decisions","plan_discoveries","plan_steps"],Ia=Ca;(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6e329ab1-f22d-5749-b8a4-0a6e7a1c8023")}catch{}})();var Ra=Object.freeze([{id:"draft",roles:["draft"]},{id:"open",roles:["active","default_open"]},{id:"in_progress",aliases:["in-progress"],roles:["active"]},{id:"blocked",roles:["blocked"]},{id:"closed",roles:["terminal","terminal_done","default_close"]},{id:"canceled",aliases:["cancelled"],roles:["terminal","terminal_canceled","default_cancel"]}]),xa=Object.freeze({draft_status:"draft",open_status:"open",in_progress_status:"in_progress",blocked_status:"blocked",close_status:"closed",canceled_status:"canceled"}),_t=".agents/pm",gt="settings.json";var Na=["","epics","features","tasks","chores","issues","schema","history","search","extensions","locks"],Da=["decisions","events","reminders","milestones","meetings","plans"],W_=[...Na,...Da],Fe={Epic:"epics",Feature:"features",Task:"tasks",Chore:"chores",Issue:"issues",Decision:"decisions",Event:"events",Reminder:"reminders",Milestone:"milestones",Meeting:"meetings",Plan:"plans"},Ma={minimal:{ownership_enforcement:"none",create_mode_default:"progressive",close_validation_default:"off",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!1,duplicate_detection_mode:"off",duplicate_detection_threshold:.8,duplicate_detection_limit:3},default:{ownership_enforcement:"warn",create_mode_default:"progressive",close_validation_default:"warn",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3},strict:{ownership_enforcement:"strict",create_mode_default:"strict",close_validation_default:"strict",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"strict",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3}},Pa=["no active blocker","ready for planned execution sequencing","work completed","work is closed"],nn={blocked_reason:["no active blocker because work is closed","work is closed"],resolution:["closed with implementation evidence","closed with verification evidence","work completed and recorded","work is closed"],actual_result:["closed and recorded","work completed","work completed and recorded"]};function Dr(e){return e?[...e]:void 0}var G_={version:1,id_prefix:"pm-",ids:{token_length:4},author_default:"",agent_identity:{probes_enabled:!0,identity_vocabulary:{version:1,aliases:{}},harness_signals:[]},mutation_guard:{require_attributed_author:!1,secret_guard:"advise",stale_in_progress_hours:72},item_format:"toon",locks:{ttl_seconds:1800,wait_ms:3e3},checkpoints:{retention_days:14},output:{default_format:"toon"},ux:{deprecation_hints:!0},history:{missing_stream:"auto_create",compact_policy:{enabled:!1,max_entries:500,trigger:"health_warn"}},validation:{sprint_release_format:"warn",parent_reference:"warn",metadata_profile:"core",metadata_required_fields:[],lifecycle_stale_blocker_reason_patterns:[...Pa],lifecycle_closure_like_blocked_reason_patterns:[...nn.blocked_reason],lifecycle_closure_like_resolution_patterns:[...nn.resolution],lifecycle_closure_like_actual_result_patterns:[...nn.actual_result],estimate_defaults_by_type:{}},governance:{preset:"minimal",...Ma.minimal},workflow:{definition_of_done:[]},testing:{record_results_to_items:!1,allow_untrusted_linked_tests:!1},telemetry:{enabled:!0,first_run_prompt_completed:!1,capture_level:"redacted",endpoint:"https://pm-cli.unbrained.dev/v1/events",installation_id:"",retention_days:365},agent_guidance:{prompt_completed:!1,declined:!1,declined_at:"",template_version:1,last_checked_files:[]},item_types:{definitions:[]},schema:{version:1,files:{types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"},statuses:Ra.map(e=>({...e,aliases:Dr(e.aliases),roles:Dr(e.roles)})),fields:[],workflow:{...xa},unknown_field_policy:"allow"},extensions:{enabled:[],disabled:[],policy:pt()},search:{score_threshold:0,hybrid_semantic_weight:.7,max_results:50,embedding_model:"",embedding_batch_size:32,embedding_timeout_ms:3e4,scanner_max_batch_retries:3,provider:"",default_mode:"auto",mutation_refresh_policy:"semantic_configured",query_expansion:{enabled:!1,provider:""},rerank:{enabled:!1,model:"",top_k:20}},providers:{openai:{base_url:"",api_key:"",model:""},ollama:{base_url:"",model:""}},context:{default_depth:"brief",activity_limit:10,stale_threshold_days:7,sections:{hierarchy:!0,activity:!0,progress:!0,recently_created:!0,unparented:!0,blockers:!0,files:!0,workload:!0,staleness:!0,tests:!0}},vector_store:{adapter:"",collection_name:"pm_items",qdrant:{url:"",api_key:""},lancedb:{path:""}}},K_={metadata:{},body:""},y={SUCCESS:0,GENERIC_FAILURE:1,USAGE:2,NOT_FOUND:3,CONFLICT:4,DEPENDENCY_FAILED:5,NO_EFFECT:6,PARTIAL_EFFECT:7},H_=Object.freeze({unknown_command:"usage",unknown_option:"usage",missing_required_option:"usage",missing_required_argument:"usage",invalid_command_usage:"usage",linked_test_value_not_quoted:"usage",invalid_argument_value:"validation",health_findings:"validation",validation_findings:"validation",close_through_update:"validation",no_update_fields:"validation",unsupported_update_option:"validation",tracker_not_initialized:"validation",item_not_found:"validation",ownership_conflict:"conflict",lock_conflict:"conflict",terminal_state_conflict:"conflict",dependency_failed:"runtime",init_gitignore_unwritable:"runtime",merge_git_config_unwritable:"runtime",command_failed:"runtime",unknown_error:"runtime"});(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0f7e5fb3-86d2-5af5-a189-a40dd223ef26")}catch{}})();var h=class extends Error{exitCode;code;context;constructor(t,n,r={}){super(t),this.name="PmCliError",this.exitCode=n,this.context=r,this.code=r.code}};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9961b408-ad70-5556-84dd-5ca1b1497c27")}catch{}})();var $a=new Set(["name","version","entry","priority","description","author","capabilities","manifest_version","pm_min_version","pm_max_version","engines","trusted","provenance","sandbox_profile","permissions","activation","contributions","legacy_capability_aliases"]);function La(e){return{unknownKeys:Object.keys(e).filter(t=>!$a.has(t)).sort((t,n)=>t>n?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function ja(e){let t=La(e),n=t.unknownKeys.map(r=>({code:"manifest_unknown_key",path:r,...r==="compatibility"?{suggested_key:"pm_min_version"}:{},message:r==="compatibility"?'Manifest key "compatibility" is ignored; declare the canonical pm_min_version and optional pm_max_version fields instead.':`Manifest key "${r}" is not part of the extension manifest contract and will be ignored.`}));return t.missingVersionBounds&&n.push({code:"no_version_bounds_declared",path:"$",suggested_key:"pm_min_version",message:"No canonical pm version bounds are declared; add pm_min_version so compatibility intent is explicit."}),{ok:n.length===0,findings:n}}function Mr(e,t,n){return ja(n).findings.map(r=>r.code==="manifest_unknown_key"?`extension_manifest_unknown_key:${e}:${t.name}:key=${r.path}${r.suggested_key?`:suggested=${r.suggested_key}`:""}`:`extension_manifest_no_version_bounds:${e}:${t.name}:suggested=pm_min_version`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4c00e38a-27df-5315-91e8-d35c03ed6bf3")}catch{}})();var rn=[{kind:"blocked_by",direction:"directed",traversal:"ordering",inverse:"blocks",ordering:!0,precedence:"target_before_source",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["depends_on"],compatibilityVersion:1,allowSelf:!1},{kind:"blocks",direction:"directed",traversal:"ordering",inverse:"blocked_by",ordering:!0,precedence:"source_before_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"parent",direction:"directed",traversal:"hierarchy",outcomeTraversal:"source_to_target",inverse:"child",ordering:!1,hierarchy:!0,hierarchyDirection:"target_parent",outgoing:"one",incoming:"many",lifecycle:"supersedable",aliases:["child_of","epic"],compatibilityVersion:1,allowSelf:!1},{kind:"child",direction:"directed",traversal:"hierarchy",outcomeTraversal:"target_to_source",inverse:"parent",ordering:!1,hierarchy:!0,hierarchyDirection:"source_parent",outgoing:"many",incoming:"one",lifecycle:"supersedable",aliases:["parent_child","task"],compatibilityVersion:1,allowSelf:!1},{kind:"related",direction:"undirected",traversal:"association",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["related_to"],compatibilityVersion:1,allowSelf:!1},{kind:"discovered_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"incident_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"implements",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"recurs_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,temporalOrder:"source_after_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"verifies",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"supersedes",direction:"directed",traversal:"semantic",outcomeTraversal:"both",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"supersedable",compatibilityVersion:1,allowSelf:!1}];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b658dc99-fdbb-5d10-9dd6-5f5c263bf48b")}catch{}})();function bt(e){return e.trim().toLowerCase().replaceAll("-","_")}function Fa(e){if(e===void 0)return;let t=bt(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function sn(e,t=new Set){if(e===null||typeof e!="object"||t.has(e))return e;if(t.add(e),Array.isArray(e)){for(let n of e)sn(n,t);return Object.freeze(e)}for(let n of Object.values(e))sn(n,t);return Object.freeze(e)}function Ua(e,t){if(e.precedence!==void 0&&e.precedence!=="source_before_target"&&e.precedence!=="target_before_source")throw new TypeError(`Invalid relationship precedence for ${t}`);if(!e.ordering&&e.precedence!==void 0)throw new TypeError(`Non-ordering relationship kind cannot declare precedence: ${t}`)}function za(e,t){if(e.temporalOrder!==void 0&&e.temporalOrder!=="source_after_target")throw new TypeError(`Invalid relationship temporal order for ${t}`);if(e.direction!=="directed"&&e.temporalOrder!==void 0)throw new TypeError(`Undirected relationship kind cannot declare temporal order: ${t}`)}function qa(e,t){if(e.hierarchyDirection!==void 0&&e.hierarchyDirection!=="source_parent"&&e.hierarchyDirection!=="target_parent")throw new TypeError(`Invalid relationship hierarchy direction for ${t}`);if(!e.hierarchy&&e.hierarchyDirection!==void 0)throw new TypeError(`Non-hierarchy relationship kind cannot declare hierarchy direction: ${t}`)}function Ba(e){if(typeof e!="object"||e===null)throw new TypeError("Relationship kind definition requires an object");if(typeof e.kind!="string")throw new TypeError("Relationship kind requires a string identifier");let t=bt(e.kind);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid relationship kind: ${e.kind}`);if(!Number.isInteger(e.compatibilityVersion)||e.compatibilityVersion<1)throw new TypeError(`Invalid compatibility version for ${t}`);return t}function Va(e,t){if(!["directed","undirected"].includes(e.direction))throw new TypeError(`Invalid relationship direction for ${t}`);if(typeof e.ordering!="boolean")throw new TypeError(`Invalid relationship ordering flag for ${t}`);if(![void 0,!0,!1].includes(e.hierarchy))throw new TypeError(`Invalid relationship hierarchy flag for ${t}`);if(!["one","many"].includes(e.outgoing))throw new TypeError(`Invalid outgoing relationship cardinality for ${t}`);if(!["one","many"].includes(e.incoming))throw new TypeError(`Invalid incoming relationship cardinality for ${t}`);if(!["persistent","supersedable","ephemeral"].includes(e.lifecycle))throw new TypeError(`Invalid relationship lifecycle for ${t}`);if(typeof e.allowSelf!="boolean")throw new TypeError(`Invalid relationship self-edge flag for ${t}`);if(e.traversal!==void 0&&!["hierarchy","ordering","semantic","association"].includes(e.traversal))throw new TypeError(`Invalid relationship traversal family for ${t}`);if(e.outcomeTraversal!==void 0&&!["source_to_target","target_to_source","both"].includes(e.outcomeTraversal))throw new TypeError(`Invalid outcome traversal for ${t}`);if(e.direction==="undirected"&&e.outcomeTraversal!==void 0&&e.outcomeTraversal!=="both")throw new TypeError(`Undirected relationship kind cannot declare directional outcome traversal: ${t}`)}function Wa(e,t){if(e.payloadSchema!==void 0&&(typeof e.payloadSchema!="object"||e.payloadSchema===null||Array.isArray(e.payloadSchema)))throw new TypeError(`Invalid relationship payload schema for ${t}`);if(e.aliases!==void 0&&(!Array.isArray(e.aliases)||e.aliases.some(n=>typeof n!="string")))throw new TypeError(`Invalid relationship aliases for ${t}`)}function Ga(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var an=class{#e=new Map;#n=new Map;constructor(t=rn){for(let n of t)this.register(n)}register(t){let n=Ba(t);if(Va(t,n),Wa(t,n),Ua(t,n),za(t,n),qa(t,n),this.#e.has(n)||this.#n.has(n))throw new TypeError(`Relationship kind already registered: ${n}`);let r=Fa(t.inverse),o=[...new Set((t.aliases??[]).map(bt))].sort();for(let s of o){if(!/^[a-z][a-z0-9_]*$/.test(s))throw new TypeError(`Invalid relationship alias: ${s}`);if(s===n||this.#e.has(s)||this.#n.has(s))throw new TypeError(`Relationship alias already registered: ${s}`)}let i=Object.freeze({...t,kind:n,traversal:Ga(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:r,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?sn(structuredClone(t.payloadSchema)):void 0});this.#e.set(n,i);for(let s of o)this.#n.set(s,n);return this}resolve(t){if(typeof t!="string")return;let n=bt(t);return this.#e.get(this.#n.get(n)??n)}require(t){let n=this.resolve(t);if(!n)throw new TypeError(`Unknown relationship kind: ${t}`);return n}list(){return Object.freeze([...this.#e.values()].sort((t,n)=>t.kind.localeCompare(n.kind)))}};function cn(){return new an}var ie=cn();function tg(e){return ie.require(e).kind}function ng(e){return ie.resolve(e)?.kind}function rg(e,t=ie){return t.resolve(e)?.ordering===!0}function Ka(e,t,n,r=ie){let o=Ue(e),i=Ue(t);if(!o||!i)throw new TypeError("Relationship endpoint must not be empty");let s=r.require(n);if(o===i&&!s.allowSelf)throw new TypeError(`Self relationship is not allowed for ${s.kind}`);return s}function yt(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function Ha(e,t,n){let r=typeof e.source=="string"?e.source.trim():"",o=typeof e.target=="string"?e.target.trim():"";if(!t.has(r)||!t.has(o))throw new TypeError(`Relationship endpoint not found: ${r} -> ${o}`);let i=Ka(r,o,e.kind,n),s=Object.freeze({...e,source:r,target:o,kind:i.kind}),a=i.direction==="undirected"?[r,o].sort().join("\0"):`${r}\0${o}`;return{edge:s,identity:`${i.kind}\0${a}`}}function ht(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function Ue(e){return typeof e=="string"?e.trim():""}function on(e,t){let n=Ue(e);return n&&t.has(n)?n:void 0}function Ya(e,t,n){let r=[t],o=t;for(;o!==e;)o=n.get(o),r.push(o);return r.reverse()}var Pr=class e{#e;#n;#o;#r;#s=new Map;#a=new Map;constructor(t,n,r=ie){this.#e=r,this.#n=new Set([...t].filter(i=>typeof i=="string").map(i=>i.trim()).filter(Boolean)),this.#o=Object.freeze([...this.#n].sort());let o=new Map;for(let i of n){let{edge:s,identity:a}=Ha(i,this.#n,r);o.set(a,s)}this.#r=Object.freeze([...o.values()].sort(yt));for(let i of this.#r)ht(this.#s,i.source,i),ht(this.#a,i.target,i),r.require(i.kind).direction==="undirected"&&(ht(this.#s,i.target,i),ht(this.#a,i.source,i))}static fromItems(t,n=ie){let r=new Set(t.map(i=>Ue(i.id)).filter(Boolean)),o=[];for(let i of t){let s=Ue(i.id);if(!s)continue;let a=on(i.parent,r);a&&o.push({source:s,target:a,kind:"parent"});let c=on(i.blocked_by,r);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let l of i.dependencies??[]){let d=on(l.id,r);d&&n.resolve(l.kind)&&o.push({source:s,target:d,kind:l.kind,createdAt:l.created_at,author:l.author})}}return new e(r,o,n)}edges(){return this.#r}incidentEdges(t){this.#i(t);let n=this.#s.get(t)??[],r=this.#a.get(t)??[];if(n.length===0)return Object.freeze([...r]);if(r.length===0)return Object.freeze([...n]);let o=[],i=0,s=0;for(;i<n.length||s<r.length;){let a=n[i],c=r[s],l=a===void 0?c:c===void 0||yt(a,c)<=0?a:c;o.at(-1)!==l&&o.push(l),a===l&&(i+=1),c===l&&(s+=1)}return Object.freeze(o)}nodes(){return this.#o}hasNode(t){return this.#n.has(t)}registry(){return this.#e}#i(t){if(!this.#n.has(t))throw new TypeError(`Relationship node not found: ${t}`)}#c(t,n){if(!n)return!0;let r=this.#e.require(t.kind);return n.has(t.kind)||r.inverse!==void 0&&n.has(r.inverse)}#t(t,n,r){let o=[...n==="incoming"?[]:this.#s.get(t)??[],...n==="outgoing"?[]:this.#a.get(t)??[]];return[...new Set(o)].filter(i=>this.#c(i,r)).map(i=>({id:i.source===t?i.target:i.source,edge:i})).sort((i,s)=>i.id.localeCompare(s.id)||yt(i.edge,s.edge))}adjacency(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=[...new Set(o.map(c=>c.id))],a=s.slice(0,i);return{value:a,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:a.length<s.length,nextCursor:a.at(-1)}}}neighborEdges(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(a=>this.#e.require(a).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=o.slice(0,i);return{value:s,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:s.length<o.length,nextCursor:s.at(-1)?.id}}}closure(t,n={}){this.#i(t);let r=n.kinds?new Set(n.kinds.map(f=>this.#e.require(f).kind)):void 0,o=n.direction??"outgoing",i=n.limit??Number.POSITIVE_INFINITY,s=n.maxDepth??Number.POSITIVE_INFINITY,a=new Set([t]),c=[],l=[{id:t,depth:0}],d=0,u=0,m=!1;e:for(let f=0;f<l.length;f+=1){n.signal?.throwIfAborted();let p=l[f];d+=1;let _=this.#t(p.id,o,r);if(u+=_.length,p.depth>=s){_.some(g=>!a.has(g.id))&&(m=!0);continue}for(let g of _)if(!a.has(g.id)){if(c.length>=i){m=!0;break e}a.add(g.id),c.push(g.id),l.push({id:g.id,depth:p.depth+1})}}return{value:c,meta:{visitedNodes:d,inspectedEdges:u,truncated:m,nextCursor:c.at(-1)}}}shortestPath(t,n,r={}){if(this.#i(t),this.#i(n),t===n)return{value:[t],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}};let o=r.kinds?new Set(r.kinds.map(f=>this.#e.require(f).kind)):void 0,i=r.direction??"outgoing",s=r.maxDepth??Number.POSITIVE_INFINITY,a=[{id:t,depth:0}],c=new Map,l=new Set([t]),d=0,u=0,m=!1;for(let f=0;f<a.length;f+=1){r.signal?.throwIfAborted();let p=a[f];d+=1;let _=this.#t(p.id,i,o);if(u+=_.length,p.depth>=s){_.some(g=>!l.has(g.id))&&(m=!0);continue}for(let g of _)if(!l.has(g.id)){if(c.set(g.id,p.id),g.id===n)return{value:Ya(t,n,c),meta:{visitedNodes:d,inspectedEdges:u,truncated:!1}};l.add(g.id),a.push({id:g.id,depth:p.depth+1})}}return{value:[],meta:{visitedNodes:d,inspectedEdges:u,truncated:m}}}subgraph(t,n={}){let r=this.closure(t,n),o=[t,...r.value].sort(),i=new Set(o),s=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,a=new Set;for(let c of o)for(let l of this.#s.get(c)??[])i.has(l.source)&&i.has(l.target)&&this.#c(l,s)&&a.add(l);return{value:{nodes:o,edges:[...a].sort(yt)},meta:r.meta}}};function og(e,t,n=ie){return{source:e,target:t.id,kind:n.require(t.kind).kind,createdAt:t.created_at,author:t.author}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="720821b8-d18d-5a10-a8b9-f16073dc1fc4")}catch{}})();function S(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Xa(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function $r(e){return e?M(e):{}}function Lr(e){return e?M(e):Xa()}function M(e){return structuredClone(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7d96fda0-1f2f-5e34-99da-c3c5ad0f53f6")}catch{}})();var Ja=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),Qa=["commands","command_overrides","command_handlers","hooks","flag_commands","item_types","item_fields","relationship_kinds","migrations","profiles","importers","exporters","search_providers","vector_store_adapters","assurance_providers","parser_overrides","service_overrides","renderer_overrides"];function Za(e,t){for(let n of Qa){let r=e[n];if(r===void 0)continue;if(!Array.isArray(r)||r.some(i=>typeof i!="string"))return!1;let o=r.map(i=>Ja.has(n)?S(i):i.trim()).filter(i=>i.length>0);t[n]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function ec(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n;if(r.format!=="json"&&r.format!=="toon"||!Array.isArray(r.commands)||r.commands.some(o=>typeof o!="string")||typeof r.result_discriminator!="boolean")return null;t.push({format:r.format,commands:[...new Set(r.commands.map(o=>S(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:r.result_discriminator})}return t.sort((n,r)=>n.format.localeCompare(r.format))}function tc(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n.commands;if(!Array.isArray(r)||r.some(o=>typeof o!="string"))return null;t.push({commands:[...new Set(r.map(o=>S(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return t}function ln(e){if(e==null)return;if(typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.schema_version!==1)return null;let n={schema_version:1};if(!Za(t,n))return null;let r=t.preflight_overrides;if(r!==void 0&&(!Number.isInteger(r)||r<0))return null;typeof r=="number"&&(n.preflight_overrides=r);let o=t.renderer_ownership;if(o!==void 0){let s=ec(o);if(s===null)return null;n.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=tc(i);if(s===null)return null;n.preflight_ownership=s}return n}function cg(e){return{schema_version:1,commands:e.commands,command_overrides:e.command_overrides,command_handlers:e.command_handlers,hooks:e.hooks,flag_commands:e.flag_commands,item_types:e.item_types,item_fields:e.item_fields,...e.relationship_kinds?{relationship_kinds:e.relationship_kinds}:{},migrations:e.migrations,profiles:e.profiles,importers:e.importers,exporters:e.exporters,search_providers:e.search_providers,vector_store_adapters:e.vector_store_adapters,...e.assurance_providers?{assurance_providers:e.assurance_providers}:{},parser_overrides:e.parser_overrides,service_overrides:e.service_overrides,renderer_overrides:e.renderer_overrides,...e.renderer_ownership?{renderer_ownership:e.renderer_ownership}:{},preflight_overrides:e.preflight_overrides,...e.preflight_ownership?{preflight_ownership:e.preflight_ownership}:{}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f9a3ff17-949b-55e0-a2ec-18870aa52197")}catch{}})();var nc=[["history-redact","history redact"],["history-repair","history repair"],["history-compact","history compact"],["activity","history activity"],["restore","history restore"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-tqel"})),rc=[...["next","focus"].map(e=>({alias:e,canonical:`context ${e}`,owner:"pm-kcs4"})),...["stats","health","validate","gc","telemetry","eval","test-all"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-6apl"})),...["normalize","reindex"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-3i9q8g"})),{alias:"events",canonical:"history events",owner:"pm-3i9q8g"}].map(e=>({...e,canonical_argv:e.canonical.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap"})),oc=[["update-many","update many"],["close-many","close many"],["delete","close delete"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-ik19"})),ic=[...rc,...oc,...[...["comments","notes","learnings","files","docs","deps","append","test"].map(e=>[e,`item ${e}`,"pm-yql1"]),["test-runs-worker","item test worker","pm-lp4j"],...["statuses","tags","types"].map(e=>[`completion-${e}`,`completion ${e}`,"pm-szdc"]),["copy","item copy","pm-m6g87m"],["merge","workspace merge","pm-m6g87m"],["duplicates","item duplicates","pm-fmy9ih"],["dedupe-audit","item duplicates audit","pm-fmy9ih"],["dedupe-merge","item duplicates merge","pm-fmy9ih"],["comments-audit","item audit-comments","pm-fmy9ih"],["search-advanced","search advanced","pm-wfskfn"]].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:n}))],dn=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...nc,...ic,...["discover","lookup"].map(e=>({alias:`files ${e}`,canonical:`item files ${e}`,canonical_argv:["item","files",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-yql1"}))];function dg(e){let t;for(let n of dn)n.canonical_argv.length<=(t?.canonical_argv.length??0)||n.canonical_argv.every((r,o)=>r===(o===0&&e[o]==="ctx"?"context":e[o]))&&(t=n);return t}function sc(e){let t=e.trim().replace(/\s+/gu," ");return dn.find(n=>n.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function ze(e){return sc(e)}var wt=[...dn,...[["start-task","claim","--start"],["pause-task","release","--pause"],["close-task","close","--release-assignment"]].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:[t,n],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-eq4x"})),{alias:"tests",canonical:"item test",canonical_argv:["item","test"],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-u4t9gp"},...[["fetch","get"],["read","get"],["show","get"],["view","get"],["comment","comments"],["note","notes"],["learning","learnings"]].map(([e,t])=>({alias:e,canonical:["comments","notes","learnings"].includes(t)?`item ${t}`:t,canonical_argv:["comments","notes","learnings"].includes(t)?["item",t]:[t],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-pbyu"})),...[["extension list","extension catalog"],["extension scaffold","extension init"],["package list","package catalog"],["package scaffold","package init"],["packages list","packages catalog"],["packages scaffold","packages init"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-ya7x55"})),{alias:"list-all",canonical:"list",canonical_argv:["list","--all"],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"},...[["list-draft","draft"],["list-open","open"],["list-in-progress","in_progress"],["list-blocked","blocked"],["list-closed","closed"],["list-canceled","canceled"]].map(([e,t])=>({alias:e,canonical:"list",canonical_argv:["list","--status",t],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"})),...[["extension","package"],["install","package install"],["upgrade","package upgrade"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-tnud"}))],ug=Object.fromEntries(wt.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function fg(e){let t=e.trim().toLowerCase();return wt.find(n=>n.alias===t)}function mg(e){return`Deprecated command \`${e.alias}\`; use \`pm ${e.canonical_argv.join(" ")}\`.`}import{createHash as Ur}from"node:crypto";import ac from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c036d6cf-6a10-5c74-9e2f-e7c953339e2c")}catch{}})();function cc(e){if(e===null)return null;if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="bigint")return e.toString();if(e===void 0)return"undefined";if(typeof e=="symbol")return e.toString();if(typeof e=="function")return`[function:${e.name||"anonymous"}]`}function lc(e){let t=Object.keys(e).sort(),n={};for(let r of t){let o=e[r];o!==void 0&&(n[r]=vt(o))}return n}function vt(e){let t=cc(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(r=>vt(r));if(e instanceof Date)return e.toISOString();let n=e;if(typeof n.toJSON=="function"){let r=n.toJSON();if(r!==e)return vt(r)}return lc(e)}function se(e){return JSON.stringify(vt(e))}function jr(e,t,n,r){for(let o=0;o<t.length;o+=1)if(!n.has(o)&&r(e,t[o]))return n.add(o),!0;return!1}function dc(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function uc(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function fc(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let n=[...t],r=new Set;for(let o of e)if(!jr(o,n,r,B))return!1;return!0}function mc(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let n=[...t.entries()],r=new Set;for(let[o,i]of e.entries())if(!jr([o,i],n,r,([a,c],[l,d])=>B(a,l)&&B(c,d)))return!1;return!0}function pc(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,r)=>B(n,t[r]))}function _c(e,t){let n=Object.keys(e).sort((o,i)=>o.localeCompare(i)),r=Object.keys(t).sort((o,i)=>o.localeCompare(i));if(n.length!==r.length)return!1;for(let o=0;o<n.length;o+=1){let i=n[o];if(i!==r[o]||!B(e[i],t[i]))return!1}return!0}var gc=[dc,uc,fc,mc,pc];function B(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let n of gc){let r=n(e,t);if(r!==void 0)return r}return _c(e,t)}function gg(e){return ac.createHash("sha256").update(e,"utf8").digest("hex")}function yg(e,t){let n={};for(let o of t){let i=e[o];i!==void 0&&(n[o]=i)}let r=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of r){let i=e[o];i!==void 0&&(n[o]=i)}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8b0d8654-211b-57bf-852f-8a153849e8fd")}catch{}})();var yc=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],Fr=256,un=64;function P(e){throw new h(`Invalid workflow policy: ${e}`,y.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function W(e,t,n){if(typeof e!="object"||e===null||Array.isArray(e))return P(`${n} must be an object`);let r=e;return Object.keys(r).some(o=>!t.includes(o))?P(`${n} contains an unknown key`):r}function ae(e,t,n=128){return typeof e!="string"||!e.trim()||e.length>n?P(`${t} must be nonempty text of at most ${n} characters`):e.trim()}function qe(e,t){if(!Array.isArray(e)||e.length===0||e.length>un)return P(`${t} requires 1-${un} terms`);let n=e.map(r=>ae(r,t));return t==="fields"&&n.some(r=>!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$/.test(r)||r.split(".").some(o=>["__proto__","constructor","prototype"].includes(o)))?P("fields must be safe metadata paths of at most eight segments"):[...new Set(n)]}function hc(e){let t=W(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(W(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>un?P("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(n=>!Array.isArray(n)||n.length!==2?P("transition pairs need two statuses"):[ae(n[0],"from"),ae(n[1],"to")])}):t.kind==="authors"?(W(t,["kind","authors"],"authors rule"),{kind:"authors",authors:qe(t.authors,"authors")}):t.kind==="require_fields"?(W(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:qe(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(W(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:qe(t.fields,"fields"),authors:qe(t.authors,"authors")}):P("unknown rule kind")}function bc(e){let t={},n=W(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let r of["types","tags","statuses","operations","parents"])n[r]!==void 0&&(t[r]=qe(n[r],r));if(n.dependency!==void 0){let r=W(n.dependency,["kind","id"],"dependency");t.dependency={kind:ae(r.kind,"dependency kind"),...r.id===void 0?{}:{id:ae(r.id,"dependency id")}}}return t}function wc(e){let t=W(e,["id","description","subject","effect","rule"],"policy"),n=ae(t.id,"id");return/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(n)?t.effect!==void 0&&(typeof t.effect!="string"||!["advise","warn","refuse"].includes(t.effect))?P("effect must be advise, warn, or refuse"):{id:n,rule:hc(t.rule),...t.subject===void 0?{}:{subject:bc(t.subject)},...t.description===void 0?{}:{description:ae(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:P("id must be a stable token")}function vc(e){let t=W(e,["version","enforcement","policies"],"document");if(t.version!==1)return P("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return P("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>Fr)return P(`policies must contain at most ${Fr} declarations`);let n=t.policies.map(wc);return new Set(n.map(r=>r.id)).size!==n.length?P("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:n}}function Et(e,t){let n=e;for(let r of t.split(".")){if(typeof n!="object"||n===null||!Object.hasOwn(n,r))return;n=n[r]}return n}function Ec(e){return e==null?!1:typeof e=="string"?e.trim().length>0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0}function zr(e){return Ur("sha256").update(se(e)).digest("hex")}function kc(e,t){let n=e.rule.kind==="approval"?e.rule.fields:[];return Ur("sha256").update(se({id:t.id,fields:n.map(r=>[r,Et(t,r)])})).digest("hex")}function Oc(e,t){return Array.isArray(t)&&t.some(n=>typeof n=="object"&&n!==null&&"kind"in n&&n.kind===e.kind&&(e.id===void 0||"id"in n&&n.id===e.id))}function Sc(e,t,n){return!(e.types&&!e.types.some(r=>r.toLowerCase()===String(t.type).toLowerCase())||e.statuses&&!e.statuses.includes(String(t.status))||e.operations&&!e.operations.includes(n)||e.parents&&!e.parents.includes(String(t.parent))||e.tags&&(!Array.isArray(t.tags)||!e.tags.some(r=>t.tags.includes(r)))||e.dependency&&!Oc(e.dependency,t.dependencies))}function Ac(e,t){if(t.completeness_only&&(e.rule.kind!=="require_fields"||e.subject?.operations!==void 0)||e.rule.kind==="approval"&&t.before===null)return!1;let n=e.subject??{},r=t.after?.status??t.before?.status;return[t.before,t.after].some(o=>o!==null&&Sc(n,{...o,status:r},t.operation))}function Tc(e,t,n,r){let o=["type","tags","parent","dependencies"].some(s=>!B(t.before?.[s],t.after?.[s]));return t.after&&(t.completeness_only||n||r||o)?e.filter(s=>!Ec(Et(t.after,s))):[]}function Cc(e,t,n,r){let o=t.after??t.before,i=kc(e,o);return t.approvals?.some(s=>s.policy_fingerprint===r&&s.content_fingerprint===i&&s.author!==t.author&&n.includes(s.author))??!1}function Ic(e,t,n){let r=e.rule,o=t.before?.status!==t.after?.status,i="fields"in r&&r.fields.some(s=>!B(Et(t.before,s),Et(t.after,s)));switch(r.kind){case"require_fields":{let s=Tc(r.fields,t,o,i);return{satisfied:s.length===0,missing_fields:s,remediation:"Supply the declared required fields before this lifecycle transition."}}case"transition":return{satisfied:!o||r.allowed.some(([s,a])=>s===String(t.before?.status??"$create")&&a===String(t.after?.status??"$delete")),missing_fields:[],remediation:"Choose a declared allowed transition; inspect pm schema policies."};case"authors":return{satisfied:r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared workflow actor perform this operation."};case"field_writers":return{satisfied:!i||r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared field writer change the protected fields."};case"approval":return{satisfied:!o||Cc(e,t,r.authors,n),missing_fields:[],remediation:`Record an independent approval with pm schema policy-approve <item-id> --policy ${e.id} after preparing the reviewed fields.`}}}function qr(e,t,n){let r=e.policies.filter(o=>Ac(o,t)).map(o=>{let i=o.effect??"advise",s=n(o);return{policy_id:o.id,policy_fingerprint:s,rule:o.rule.kind,effect:i==="refuse"&&e.enforcement!=="refuse"?"warn":i,...Ic(o,t,s)}});return{allowed:!r.some(o=>!o.satisfied&&o.effect==="refuse"),decisions:r,warnings:r.filter(o=>!o.satisfied).map(o=>`workflow_policy:${o.effect}:${o.policy_id}:${o.rule}`)}}function kg(e,t){return qr(e,t,zr)}function Og(e){let t=vc(e),n=new Map(t.policies.map(r=>[r,zr(r)]));return r=>qr(t,r,o=>n.get(o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1dd71b26-fc38-5304-9156-f32b57cc1cc0")}catch{}})();var Rc=[...q],xc=[...Ee],Nc=[...dt],Ig=[...ut],Rg=[...ft],Dc=[...mt],kt=["init","config","extension","package","packages","install","upgrade","create","item","copy","focus","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","aggregate","context","ctx","get","graph","search","duplicates","eval","next","history","events","history-redact","history-repair","history-compact","history-attest","history-author-acknowledge","merge","schema","profile","activity","restore","update","update-many","close","close-many","delete","append","comments","notes","learnings","files","docs","deps","plan","test","test-all","telemetry","stats","health","validate","assurance","gc","workspace","contracts","claim","release","start-task","pause-task","close-task","meet","event","remind","help"],xg=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],Ng=["install","reconcile","report","driver"],Mc=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],Pc=["upgrade"],$c=["reopen"],Br={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Ot=Object.freeze(kt.flatMap(e=>e in Br?[]:e==="extension"||e==="package"?[...Mc.map(t=>`${e}-${t}`),...e==="package"?Pc.map(t=>`package-${t}`):[],e]:e==="item"?$c.map(t=>`item-${t}`):[e])),Lc=Object.freeze(wt.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Ot.includes(e.alias)).map(e=>e.alias)),Dg=Object.freeze(Ot.filter(e=>!Lc.includes(e)));function Mg(e=kt,t=Ot,n=Br){let r=new Set(t),o=new Set(e);return{missing_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]===void 0),waived_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]!==void 0),stale_waivers:Object.keys(n).filter(i=>!o.has(i)||r.has(i)||t.some(s=>s.startsWith(`${i}-`)))}}function Pg(e){return Ot.includes(e)}function $g(e){return Rc.includes(e)}function Lg(e){return xc.includes(e)}function jg(e){return Nc.includes(e)}function Fg(e){return Dc.includes(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="de2a2a0e-8a39-5569-9af9-cbf557bce2a9")}catch{}})();function St(e,t,n){if(e===t)return 0;if(Math.abs(e.length-t.length)>n)return null;let r=t.length+1,o=new Array(r),i=new Array(r),s=new Array(r);for(let c=0;c<r;c+=1)o[c]=0,i[c]=c;for(let c=1;c<=e.length;c+=1){s[0]=c;let l=s[0];for(let d=1;d<=t.length;d+=1){let u=e[c-1]===t[d-1]?0:1,m=i[d-1]+u,f=s[d-1]+1,p=i[d]+1,_=Math.min(m,f,p);c>1&&d>1&&e[c-1]===t[d-2]&&e[c-2]===t[d-1]&&(_=Math.min(_,o[d-2]+1)),s[d]=_,_<l&&(l=_)}if(l>n)return null;for(let d=0;d<r;d+=1)o[d]=i[d],i[d]=s[d]}let a=i[t.length];return a<=n?a:null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1ddb0411-5fdd-56af-a524-0f6830c288a5")}catch{}})();function Be(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function X(e){return q.includes(e)}function Vr(e){let t=e.trim().toLowerCase();return X(t)?t:null}function Wr(e){return e.filter(t=>!X(t))}function fn(e){let t=e.trim().toLowerCase();return t.length===0?null:tn[t]??null}function Gr(e){let t=Be([...e].map(i=>i.toLowerCase())),n=[],r=[];for(let i of t){let s=fn(i);if(s){n.push(s),r.push({alias:i,target:s});continue}n.push(i)}let o=[...new Map(r.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:Be(n),legacy_aliases:o}}function jc(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=fn(t);if(n)return n;let r=Math.max(1,Math.floor(t.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of q){let a=St(t,s,r);a!==null&&a<i&&(i=a,o=s)}return o}function Kr(e,t,n){let r=q.join(","),o=jc(n)??"none";return`extension_capability_unknown:${e}:${t}:${n}:allowed=${r}:suggested=${o}`}function Hr(e,t,n){let r=n.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${r}`}function Fc(e){let t=/^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(e.trim());if(!t)return null;let[,n,r,o,i,s]=t,a=n,c=i.split(",").map(f=>f.trim()).filter(f=>f.length>0),l=fn(o),u=(s==="none"?void 0:s)??l??void 0;return{layer:a,name:r,capability:o,allowed_capabilities:c,capability_contract_version:lt,suggested_capability:u,suggestion_source:u?l===u?"legacy_alias":"nearest_match":void 0,legacy_alias_target:l??void 0}}function Uc(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,n,r,o]=t,i=n,s=[...q],a=[];for(let c of o.split(",")){let[l,d]=c.split(">"),u=l?.trim(),m=d?.trim().toLowerCase();!u||!m||!X(m)||a.push({layer:i,name:r,capability:u,allowed_capabilities:s,capability_contract_version:lt,suggested_capability:m,suggestion_source:"legacy_alias",legacy_alias_target:m})}return a}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71c44385-0182-50f8-8e05-3aeebfe57ad9")}catch{}})();var zc={commands:["registerCommand","command override","command handler"],renderers:["registerRenderer"],hooks:["hooks.beforeCommand","hooks.beforeMutation","hooks.afterCommand","hooks.onWrite","hooks.onRead","hooks.onIndex"],schema:["registerFlags","registerItemFields","registerItemTypes","registerRelationshipKinds","registerMigration","registerProfile"],importers:["registerImporter","registerExporter"],search:["registerSearchProvider","registerVectorStoreAdapter"],parser:["registerParser"],preflight:["registerPreflight"],services:["registerService","registerAssuranceMeasurementProvider"]},Yr=":";function Xr(e,t){return`${e}${Yr}${mn(t)}`}function qc(e){return e.slice(e.indexOf(Yr)+1)}function mn(e){return e.trim().toLowerCase()}function Bc(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let r=Vr(n);r!==null&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function Jr(e){let t=new Map,n=(d,u)=>{for(let m of d){let f=Xr(m.layer,m.name),p=t.get(f);p===void 0&&(p=new Set,t.set(f,p)),p.add(u)}},{registrations:r,commands:o,parsers:i,preflight:s,services:a,renderers:c,hooks:l}=e;return n(r.commands,"commands"),n(o.overrides,"commands"),n(o.handlers,"commands"),n(r.flags,"schema"),n(r.item_fields,"schema"),n(r.item_types,"schema"),n(r.relationship_kinds??[],"schema"),n(r.migrations,"schema"),n(r.profiles,"schema"),n(r.importers,"importers"),n(r.exporters,"importers"),n(r.search_providers,"search"),n(r.vector_store_adapters,"search"),n(i.overrides,"parser"),n(s.overrides,"preflight"),n(a.overrides,"services"),n(r.assurance_providers??[],"services"),n(c.overrides,"renderers"),n(l.beforeCommand,"hooks"),n(l.beforeMutation,"hooks"),n(l.afterCommand,"hooks"),n(l.onWrite,"hooks"),n(l.onRead,"hooks"),n(l.onIndex,"hooks"),t}function Vc(e,t={}){let n=Jr(e),r=new Set;t.extensionName!==void 0&&r.add(mn(t.extensionName));for(let i of t.extensionNames??[])r.add(mn(i));let o=new Set;for(let[i,s]of n)if(!(r.size>0&&!r.has(qc(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function Wc(e,t){let n=Jr(t),r=[];for(let o of e){let i=Bc(o.capabilities);if(i.length===0)continue;let s=n.get(Xr(o.layer,o.name))??new Set,a=[...s].sort((l,d)=>l.localeCompare(d)),c=i.filter(l=>!s.has(l));r.push({layer:o.layer,name:o.name,declared:i,used:a,unused:c})}return r}import{createHash as Gc}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]="15037266-75b7-5f8d-9565-e7848e720a49")}catch{}})();var pn=1,Zr=4096,Kc=/^[A-Za-z0-9_-]+$/;function Qr(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function Jg(e,t){let n=new Set;for(let r of t)if(r.cursor_semantics==="presentation"){n.add(Qr(r.flag));for(let o of r.aliases??[])n.add(Qr(o))}return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function Qg(e,t){return Gc("sha256").update(e).update("\0").update(se(t)).digest("hex").slice(0,24)}function Ve(e,t,n,r){return Buffer.from(JSON.stringify({version:pn,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function ce(e){return new h(e,y.USAGE,{code:"invalid_query_cursor",nextSteps:["Repeat the original query without --after to obtain a fresh cursor."]})}function Hc(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===pn&&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 _n(e){if(typeof e!="string")throw ce("Query cursor is malformed.");let t=e.trim();if(t.length===0||t.length>Zr||!Kc.test(t))throw ce("Query cursor is malformed.");let n;try{n=JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{throw ce("Query cursor is malformed.")}if(!Hc(n))throw ce("Query cursor version or payload is unsupported.");return n}function gn(e,t){let n=_n(e);if(n.fingerprint!==t)throw ce(`Query cursor does not match the current filters, sort, or query (${n.fingerprint} != ${t}).`);return{after_id:n.after_id,...n.after_index===void 0?{}:{after_index:n.after_index},...n.snapshot===void 0?{}:{snapshot:n.snapshot}}}function Zg(e,t){return gn(e,t).after_id}function Yc(e,t,n,r){if(t===void 0)return 0;let o=gn(t,n),i=e.findIndex(s=>r(s)===o.after_id);if(i<0){if(o.after_index!==void 0)return Math.min(o.after_index,e.length);throw ce(`Query cursor item ${o.after_id} is no longer present in this result set.`)}return i+1}function ey(e,t){if(t.cursor!==void 0&&gn(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw ce("Query cursor does not match the requested snapshot.");let n=Yc(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:Ve(t.fingerprint,t.readId(i),n+r.length-1,t.snapshot)}:{}}}var ty=Object.freeze({version:pn,max_length:Zr});import{stripVTControlCharacters as Xc}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b4036040-c0b8-5d01-b490-3405722fd1c5")}catch{}})();var Jc=["full","compact","brief","summary","counts"],sy=["mutation","read","discovery","governance"],to=["error","warning","validation_summary","recovery_bundle"],Qc=["full","omit_explanation","limit_collections","compact_recovery","action_only"],Zc=new Set(["append","claim","close","close-many","close-task","comments","config","copy","create","delete","docs","event","files","focus","history-author-acknowledge","history-compact","history-redact","history-repair","init","item","learnings","meet","notes","pause-task","release","remind","restore","schema","start-task","update","update-many"]),el=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),tl=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),nl={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},rl=3,ol=2,il=192,sl={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},al=to.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:sl[e],minimum_max_estimated_tokens:il,degradation_ladder:Qc,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),cl=new Map(al.map(e=>[e.diagnostic_class,e]));function ll(e){let[t=""]=ze(e).split(/\s+/u);return Zc.has(t)?"mutation":el.has(t)?"discovery":tl.has(t)?"governance":"read"}function no(e,t=ll(e)){let n=e.trim().replace(/\s+/gu," ");if(n.length===0)throw new TypeError("command must be a non-empty command path");let r=nl[t];return dl({command:n,budget_class:t,default_max_estimated_tokens:r,default_max_estimated_tokens_by_format:{toon:r,json:Math.ceil(r*rl/ol)},degradation_ladder:Jc,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function dl(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,n]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var ul=kt.map(e=>no(e)),fl=new Map(ul.map(e=>[e.command,e]));function ro(e,t={}){let n=e.trim().replace(/\s+/gu," "),[r]=ze(n).split(" "),o=fl.get(r);return o?{...o,command:n}:t.generateFallback?no(n):null}function de(e){return Math.ceil(Math.max(0,e)/4)}function oo(e){let t=cl.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${to.join(", ")}`);return t}function J(e){return de(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function ml(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function yn(e){if(!ml(e))return;let t={};for(let n of["suggested_retry","suggested_retry_args","next_best_command","allowed_values","candidate_commands","missing","missing_required_fields","option_scope","retry_after_ms"]){let r=e[n];Array.isArray(r)?t[n]=n==="suggested_retry_args"?r:r.slice(0,3):r!==void 0&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}function pl(e,t){return typeof e!="string"||e.length<=t?e:`${e.slice(0,Math.max(1,t-3))}...`}function le(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;let n="...",r=Array.from(e),o=0,i=r.length;for(;o<i;){let s=Math.ceil((o+i)/2),a=`${r.slice(0,s).join("")}${n}`;Buffer.byteLength(a,"utf8")<=t?o=s:i=s-1}return`${r.slice(0,o).join("")}${n}`}function io(e){let t={};for(let n of["code","required","recovery","next_steps","exit_code","type","title","detail","why","examples"])Object.hasOwn(e,n)&&e[n]!==void 0&&(t[n]=e[n]);for(let[n,r]of Object.entries(e))n!=="__proto__"&&!Object.hasOwn(t,n)&&(t[n]=r);return t}var _l=new Set(["limit_collections","compact_recovery","action_only"]),gl=new Set(["compact_recovery","action_only"]);function yl(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:pl(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},n=yn(e.recovery);return n!==void 0?t.recovery=n:Array.isArray(e.next_steps)&&(t.next_steps=e.next_steps.slice(0,1)),e.exit_code!==void 0&&(t.exit_code=e.exit_code),e.type!==void 0&&(t.type=e.type),t}function hl(e,t){let n=structuredClone(e);if(t!=="full"&&(delete n.why,delete n.examples),_l.has(t))for(let[r,o]of Object.entries(n))Array.isArray(o)&&(n[r]=o.slice(0,3));if(gl.has(t)){let r=yn(n.recovery);r?n.recovery=r:delete n.recovery}return t!=="action_only"?io(n):yl(n)}function ke(e,t){let n={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let r=0;r<4;r+=1){let o=J(n),i=n.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return n}function bl(e,t,n){let r=ke(e,t);for(let i of["recovery","exit_code"])J(r)<=n||e[i]===void 0||(delete e[i],r=ke(e,t));let o=40;for(;J(r)>n&&o>4;)o-=4,e.code=le(String(e.code),o),e.required=le(String(e.required),o),r=ke(e,t);return r}function wl(e,t){let n=e.diagnostic_output,{estimated_tokens:r,...o}=n,i=o.omitted_fields.slice(0,8).map(u=>le(u,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=yn(e.recovery),c=a&&J(a)<=48?a:void 0,l={code:le(String(e.code),320),required:le(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},d=ke(l,s);for(;J(d)>t&&s.omitted_fields.length>0;)s.omitted_fields.pop(),s.omitted_fields_overflow_count=o.omitted_fields.length-s.omitted_fields.length,d=ke(l,s);return d=bl(l,s,t),d}function ay(e,t={}){let n=e,r=t.diagnosticClass??"error",o=oo(r),i=t.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.json,a=J(n),c=Object.keys(n);if(a<=s)return io(structuredClone(n));let l;for(let[d,u]of o.degradation_ladder.entries()){let m=hl(n,u),f=c.filter(_=>!Object.hasOwn(m,_)),p=ke(m,{diagnostic_class:r,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:d>0,degradation_steps:o.degradation_ladder.slice(0,d+1),omitted_fields:f});if(l=p,J(p)<=s)break}return J(l)>s&&(l=wl(l,s)),l}function eo(e){return Xc(e).replace(/\r\n/gu,`
2
+ `).replace(/[^\P{Cc}\n]/gu," ")}function cy(e,t,n={}){let r=n.diagnosticClass??"error",o=oo(r),i=n.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.text,a=eo(e),c=de(Buffer.byteLength(a,"utf8")),l=c>s,d=`What is required:
3
3
  `,m=`
4
4
 
5
5
  ${le(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.`,f=eo(t).trim()||"Inspect the diagnostic code and retry with corrected input.",p=Math.max(1,s*4-Buffer.byteLength(`${d}${m}`,"utf8")),_=l?`${d}${le(f,p)}${m}`:a;return{output:_,diagnostic_output:{diagnostic_class:r,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:de(Buffer.byteLength(_,"utf8")),truncated:l,degradation_steps:l?[...o.degradation_ladder]:["full"],omitted_fields:l?["explanation","collections"]:[]}}}import{createHash as u_}from"node:crypto";import{existsSync as rf}from"node:fs";import{AsyncLocalStorage as of}from"node:async_hooks";import K from"node:path";import he from"node:fs/promises";import ye from"node:path";import{pathToFileURL as ru}from"node:url";import*as T from"node:fs/promises";import At from"node:path";import gl 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]="1240aa49-b3fa-57d3-b6e1-7f911005a757")}catch{}})();var yl=[10,25,50,100];async function so(e){await T.mkdir(e,{recursive:!0})}async function yn(e){try{return await T.access(e),!0}catch{return!1}}function ao(e){return fe(e)||ue(e,"ENOTDIR")}function fe(e){return ue(e,"ENOENT")}async function dy(e){try{return await T.readFile(e,"utf8")}catch(t){if(ao(t))return null;throw t}}async function uy(e,t){let n=At.dirname(e);await so(n);let r=At.join(n,`.${At.basename(e)}.${process.pid}.${Date.now()}.${gl.randomBytes(4).toString("hex")}.tmp`);await T.writeFile(r,t,"utf8");try{await T.rename(r,e)}catch(o){if(process.platform==="win32"&&(ue(o,"EPERM")||ue(o,"EBUSY"))){let i=o;for(let s of yl){await new Promise(a=>setTimeout(a,s));try{await T.rename(r,e);return}catch(a){if(i=a,!ue(a,"EPERM")&&!ue(a,"EBUSY"))break}}try{await T.unlink(r)}catch{}throw i}if(ue(o,"EXDEV")){try{await T.copyFile(r,e)}finally{try{await T.unlink(r)}catch{}}return}try{await T.unlink(r)}catch{}throw o}}async function fy(e,t){let n=At.dirname(e);await so(n);let r=await T.open(e,"a");try{await r.writeFile(`${t}
8
- `,"utf8")}finally{await r.close()}}async function my(e){try{await T.unlink(e)}catch(t){if(!ao(t))throw t}}function ue(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}import co from"path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="83a29a06-1b0b-52e6-9617-2fc03861cb18")}catch{}})();function hn(e,t){let n=co.relative(e,t);return n.length===0?!0:!n.startsWith("..")&&!co.isAbsolute(n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="de5f8d66-b9dc-555c-a52f-33b1b5368be3")}catch{}})();var hl="__pm_suppress_host_output",bn="@unbrained/pm-cli:suppress-host-output:v1";function lo(e){return e===void 0?{__pm_suppress_host_output:bn}:{__pm_suppress_host_output:bn,result:e}}function wn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[hl]===bn}import Oe from"node:fs";import Q from"node:path";import{fileURLToPath as bl}from"node:url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dc77f588-e4ea-59fc-908f-51b41114430a")}catch{}})();var wl="@unbrained/pm-cli";function vl(e){try{return JSON.parse(Oe.readFileSync(e,"utf8")).name===wl}catch{return!1}}function El(e){let t=Oe.existsSync(e)&&Oe.statSync(e).isDirectory()?Q.resolve(e):Q.dirname(Q.resolve(e));for(;;){let n=Q.join(t,"package.json");if(Oe.existsSync(n)&&vl(n))return t;let r=Q.dirname(t);if(r===t)return;t=r}}function vn(e,t=[]){let n=bl(e),r=El(n);return r||Q.resolve(Q.dirname(n),...t)}function vy(e,t=[]){try{let n=Q.join(vn(e,t),"package.json");if(!Oe.existsSync(n))return;let r=JSON.parse(Oe.readFileSync(n,"utf8"));return typeof r.version=="string"&&r.version.trim().length>0?r.version:void 0}catch{return}}import{readFileSync as cd,readdirSync as $y,statSync as ld}from"node:fs";import dd from"node:os";import O from"node:path";import Tl from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0ca7f52c-fb31-5cd9-b689-a918f4e61816")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7647d826-e562-5f8e-86b2-2e40d8714b4d")}catch{}})();function Z(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function kl(e){let t=e.key.trim();if(t.length===0)return null;let n=Z(e.aliases),r=e.description?.trim();return{key:t,values:Z(e.values),required:e.required===!0?!0:void 0,aliases:n.length>0?n:void 0,description:r&&r.length>0?r:void 0}}var Ol=e=>e,fo=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function Sl(e,t){let n=t(e.command);if(n===null)return null;let r=e.option.trim();return r.length===0?null:{command:n,option:r,required:e.required,visible:e.visible,enabled:e.enabled}}function Al(e,t){let n=new Map;for(let r of e??[]){let o=Sl(r,t);o&&n.set(`${o.command}:${o.option.toLowerCase()}`,o)}return[...n.values()].sort((r,o)=>r.command===o.command?r.option.localeCompare(o.option):r.command.localeCompare(o.command))}function uo(e,t){return t?Z(e):void 0}function En(e){let t=e?.trim();return t&&t.length>0?t:void 0}function kn(e){if(e===void 0||e==="agent"||e==="human"||e==="gate")return e;throw new Error("Item type execution_role must be agent, human, or gate.")}function mo(e,t={}){let n=t.resolvePolicyCommand??Ol,r=e.name.trim();if(r.length===0)return null;let o=e.required_create_fields!==void 0,i=e.required_create_repeatables!==void 0,s=e.options!==void 0,a=e.command_option_policies!==void 0,c=Z(e.aliases),l=(e.options??[]).map(u=>kl(u)).filter(u=>u!==null).sort((u,m)=>u.key.localeCompare(m.key)),d=Al(e.command_option_policies,n);return{name:r,description:En(e.description),default_status:En(e.default_status),...e.execution_role===void 0?{}:{execution_role:kn(e.execution_role)},folder:En(e.folder),aliases:c.length>0?c:void 0,required_create_fields:uo(e.required_create_fields,o),required_create_repeatables:uo(e.required_create_repeatables,i),options:s?l:void 0,command_option_policies:a?d:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="69ea08ca-3793-51d7-a971-95abf442028f")}catch{}})();var Cl=Object.freeze({decision:"human",milestone:"gate"}),Il=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],Rl=["dep","comment","note","learning","file","test","doc"],_o=["deadline","estimatedMinutes","acceptanceCriteria","definitionOfReady","order","goal","objective","value","impact","outcome","whyNow","assignee","parent","reviewer","risk","confidence","sprint","release","blockedBy","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact"],xl=["title","description","type","status","priority","tags","body",..._o,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],Nl=["title","description","body","status","closeReason","priority","type","tags",..._o,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],go={"close-reason":"closeReason",close_reason:"closeReason","estimated-minutes":"estimatedMinutes",estimated_minutes:"estimatedMinutes",estimate:"estimatedMinutes","acceptance-criteria":"acceptanceCriteria",acceptance_criteria:"acceptanceCriteria",ac:"acceptanceCriteria","definition-of-ready":"definitionOfReady",definition_of_ready:"definitionOfReady",rank:"order","why-now":"whyNow",why_now:"whyNow","blocked-by":"blockedBy",blocked_by:"blockedBy","blocked-reason":"blockedReason",blocked_reason:"blockedReason","unblock-note":"unblockNote",unblock_note:"unblockNote","repro-steps":"reproSteps",repro_steps:"reproSteps","expected-result":"expectedResult",expected_result:"expectedResult","actual-result":"actualResult",actual_result:"actualResult","affected-version":"affectedVersion",affected_version:"affectedVersion","fixed-version":"fixedVersion",fixed_version:"fixedVersion","customer-impact":"customerImpact",customer_impact:"customerImpact","type-option":"typeOption",type_option:"typeOption",type_options:"typeOption"},Dl={...go},Ml={...go},yo=[["deadline","--deadline"],["estimatedMinutes","--estimate/--estimated-minutes"],["acceptanceCriteria","--acceptance-criteria/--ac"],["definitionOfReady","--definition-of-ready"],["order","--order/--rank"],["goal","--goal"],["objective","--objective"],["value","--value"],["impact","--impact"],["outcome","--outcome"],["whyNow","--why-now"],["assignee","--assignee"],["parent","--parent"],["reviewer","--reviewer"],["risk","--risk"],["confidence","--confidence"],["sprint","--sprint"],["release","--release"],["blockedBy","--blocked-by"],["blockedReason","--blocked-reason"],["unblockNote","--unblock-note"],["reporter","--reporter"],["severity","--severity"],["environment","--environment"],["reproSteps","--repro-steps"],["resolution","--resolution"],["expectedResult","--expected-result"],["actualResult","--actual-result"],["affectedVersion","--affected-version"],["fixedVersion","--fixed-version"],["component","--component"],["regression","--regression"],["customerImpact","--customer-impact"]],ho=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function bo(e){return Object.fromEntries(e)}var Pl=bo([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...yo,["author","--author"],["message","--message"],["dep","--dep"],...ho]),$l=bo([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...yo,...ho,["author","--author"],["message","--message"],["force","--force"]]);function Ll(e){return e.trim().replace(/^--+/,"").toLowerCase()}function jl(e){return e==="create"?xl:Nl}function Fl(e){return e==="create"?Dl:Ml}function wo(e,t){let n=Ll(t);if(n.length===0)return;let r=Fl(e)[n];return r||jl(e).find(o=>o.toLowerCase()===n)}function Ry(e,t){return(e==="create"?Pl:$l)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function Sn(e){let t=zl(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function Ul(e){let t=e.trim(),r=t.replaceAll("\\","/").replace(/^\/+/,""),o=Tl.posix.normalize(r);if(t.includes("\0")||/^[A-Za-z]:/.test(o)||o==="."||o===".."||o.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return o}function zl(e){let t=e.trim().toLowerCase(),n="",r=!1;for(let o of t){let i=o.charCodeAt(0),s=i>=97&&i<=122,a=i>=48&&i<=57;if(s||a){r&&n.length>0&&(n+="-"),n+=o,r=!1;continue}n.length>0&&(r=!0)}return n}function ql(e){return mo(e,{resolvePolicyCommand:fo})}function We(e,t){let n=e[t];return Array.isArray(n)?n.filter(r=>typeof r=="string"):void 0}function Bl(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;return typeof t.key!="string"?null:{key:t.key,values:We(t,"values")??[],required:t.required===void 0?void 0:!!t.required,aliases:We(t,"aliases"),description:typeof t.description=="string"?t.description:void 0}}function Vl(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;if(typeof t.command!="string"||typeof t.option!="string")return null;let n=t.command.trim().toLowerCase();return n!=="create"&&n!=="update"?null:{command:n,option:t.option,required:t.required===void 0?void 0:!!t.required,visible:t.visible===void 0?void 0:!!t.visible,enabled:t.enabled===void 0?void 0:!!t.enabled}}function Wl(e){if(Array.isArray(e.options))return e.options.map(t=>Bl(t)).filter(t=>t!==null)}function Gl(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>Vl(t)).filter(t=>t!==null)}function Kl(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e,n=typeof t.name=="string"?t.name:"";if(n.trim().length===0)return null;let r=typeof t.folder=="string"?t.folder:void 0,o=typeof t.description=="string"?t.description:void 0,i=typeof t.default_status=="string"?t.default_status:void 0;return{name:n,description:o,default_status:i,execution_role:kn(t.execution_role),folder:r,aliases:We(t,"aliases"),required_create_fields:We(t,"required_create_fields"),required_create_repeatables:We(t,"required_create_repeatables"),options:Wl(t),command_option_policies:Gl(t)}}function Hl(e,t){return e.required_create_fields?Z(e.required_create_fields):t?.required_create_fields??[]}function Yl(e,t){return e.required_create_repeatables?Z(e.required_create_repeatables):t?.required_create_repeatables??[]}function Xl(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function Jl(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function Ql(e,t){let n=t?.name??e.name,r=e.description??t?.description,o=e.default_status??t?.default_status,i=Ul(e.folder??t?.folder??Sn(n)),s={name:n,execution_role:e.execution_role,folder:i,aliases:Z([...t?.aliases??[],...e.aliases??[]]),required_create_fields:Hl(e,t),required_create_repeatables:Yl(e,t),options:Xl(e,t),command_option_policies:Jl(e,t)};return r&&(s.description=r),o&&(s.default_status=o),s}function po(e,t){for(let n of e){let r=ql(n);if(!r)continue;let o=r.name.toLowerCase(),i=t.get(o);t.set(o,Ql({...r,execution_role:r.execution_role??i?.execution_role},i))}}function Zl(e){if(!e)return[];let t=[];for(let n of e.item_types??[]){let r=n.types;if(Array.isArray(r))for(let o of r){let i=Kl(o);i&&t.push(i)}}return t}function xy(e,t=null){let n=new Map;for(let c of Rr)n.set(c.toLowerCase(),{name:c,execution_role:Cl[c.toLowerCase()]??"agent",folder:Fe[c],aliases:[],required_create_fields:[...Il],required_create_repeatables:[...Rl],options:[],command_option_policies:[]});po(e.item_types?.definitions??[],n),po(Zl(t),n);let r=[...n.values()].sort((c,l)=>c.name.localeCompare(l.name)),o={},i={},s={};for(let c of r){o[c.name]=c,s[c.name]=c.folder,i[c.name.toLowerCase()]=c.name;for(let l of c.aliases)i[l.toLowerCase()]=c.name}let a=[...new Set(r.map(c=>c.folder))].sort((c,l)=>c.localeCompare(l));return{types:r.map(c=>c.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function ed(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function td(e,t){let n=ed(e,t);if(n)return t.by_type[n]}function nd(e,t,n,r){for(let o of r){let i=wo(n,o);if(i){e.required.add(i);continue}e.errors.push(`Unsupported base required option "${o}" for command "${n}" on type "${t.name}"`)}}function On(e,t,n){if(n){e.add(t);return}e.delete(t)}function rd(e,t,n,r){let o=wo(n,r.option);if(!o){e.errors.push(`Unsupported command_option_policies option "${r.option}" for command "${n}" on type "${t.name}"`);return}r.required!==void 0&&On(e.required,o,r.required),r.visible!==void 0&&On(e.hidden,o,!r.visible),r.enabled!==void 0&&On(e.disabled,o,!r.enabled)}function od(e,t,n){for(let r of t.command_option_policies)r.command===n&&rd(e,t,n,r)}function id(e,t,n){for(let r of e.required)e.disabled.has(r)&&e.errors.push(`Option "${r}" cannot be both required and disabled for command "${n}" on type "${t.name}"`)}function Ny(e,t,n){let r=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:r};return nd(a,e,t,n),od(a,e,t),id(a,e,t),{required:[...o],hidden:[...i].sort((c,l)=>c.localeCompare(l)),disabled:[...s].sort((c,l)=>c.localeCompare(l)),errors:r}}function sd(e){let t=new Map;for(let n of e.options){t.set(n.key.toLowerCase(),n);for(let r of n.aliases??[])t.set(r.toLowerCase(),n)}return t}function ad(e,t,n){let r=e.values;if(r.length===0)return t;let i=new Map(r.map(s=>[s.toLowerCase(),s])).get(t.toLowerCase());if(!i){n.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${r.join(", ")}`);return}return i}function Dy(e,t,n){let r=td(e,n);if(!r)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=sd(r),s={};for(let[c,l]of Object.entries(t??{})){let d=c.trim(),u=l.trim();if(d.length===0){o.push("type option keys must not be empty");continue}if(u.length===0){o.push(`type option "${d}" must not be empty`);continue}let m=i.get(d.toLowerCase());if(!m){let p=r.options.map(_=>_.key).join(", ");o.push(r.options.length>0?`Unknown type option "${d}" for type "${r.name}". Allowed: ${p}`:`Type "${r.name}" does not define any configurable type options`);continue}let f=ad(m,u,o);f!==void 0&&(s[m.key]=f)}for(let c of r.options)c.required&&!(c.key in s)&&o.push(`Missing required type option "${c.key}" for type "${r.name}"`);let a=Object.keys(s).sort((c,l)=>c.localeCompare(l));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(c=>[c,s[c]])),errors:o}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="124443e3-a20b-5fd6-a1d9-e4a09b17dc4a")}catch{}})();var ud={json_markdown:".md",toon:".toon"},fd={".md":"json_markdown",".toon":"toon"};var qy=[".md",".toon"];function Tt(e){try{return ld(e),!0}catch{return!1}}function md(e){try{let t=JSON.parse(cd(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function pd(e){let t=O.resolve(e);for(;;){let n=O.join(t,_t),r=O.join(n,gt);if(Tt(r))return n;let o=O.join(t,gt);if(Tt(o)&&md(o))return t;let i=O.dirname(t);if(i===t)return;t=i}}function _d(e){return pd(e)??O.resolve(e,_t)}function By(e,t){let n=process.env.PM_PATH,r=t?.trim()||n?.trim();if(r){let o=O.resolve(e,r);if(!Tt(vo(o))){let i=O.join(o,_t);if(Tt(vo(i)))return i}return o}return _d(e)}function Vy(e){let t=O.resolve(e),n=O.dirname(t);return O.basename(t)==="pm"&&O.basename(n)===".agents"?O.dirname(n):t}function Eo(e){let t=process.env.PM_GLOBAL_PATH?.trim(),n=t&&t.length>0?t:O.join(dd.homedir(),".pm-cli");return O.resolve(e,n)}function vo(e){return O.join(e,gt)}function gd(e,t,n=Fe){let r=n[t]??Sn(t);return O.join(e,r)}function Wy(e,t,n,r="toon",o=Fe){return O.join(gd(e,t,o),`${n}${ud[r]}`)}function Gy(e){let t=e.replaceAll("\\","/"),n=O.posix.extname(t).toLowerCase();return fd[n]??null}function Ky(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new h("Invalid history item id: expected a single filename.",y.USAGE);return O.join(e,"history",`${t}.jsonl`)}function ko(e,t){return O.join(e,"locks",`${t}.lock`)}function Hy(e){return O.join(e,"runtime")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="49fe564d-671f-5425-96fe-517cb323f773")}catch{}})();function yd(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Xy(e){return yd(e)??void 0}function Jy(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t-=1;return t===e.length?e:e.slice(0,t)}function Qy(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function So(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function Ao(e){let t=typeof e=="number"?e:typeof e=="string"&&e.trim().length>0?Number(e.trim()):Number.NaN;return Number.isFinite(t)?t:null}function Zy(e){let t=Ao(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function eh(e,t,n){let r=Ao(e);return r===null||r<t||r>n?null:r}function me(e){return typeof e!="object"||e===null?null:e}function Oo(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function To(e){let t=Oo(e);if(!t)return null;if(typeof t.activate=="function")return t;let n=Oo(t.default);return typeof n?.activate=="function"?n:null}function th(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e}:{}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="31da4a5a-1e85-5d77-a09f-2736cc44d850")}catch{}})();var hd=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function Co(e){return typeof e!="string"?null:hd[e.trim().toLowerCase()]??null}function Io(e){let t=[],n=r=>{if(Array.isArray(r)){for(let o of r)n(o);return}if(typeof r=="string"){for(let o of r.split(",")){let i=o.trim();i.length>0&&t.push(i)}return}r!=null&&t.push(r)};return n(e),t}function Ro(e,t){return t==="string"?!0:t==="number"?typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim().length>0&&Number.isFinite(Number(e)):typeof e=="boolean"?!0:typeof e=="string"&&["true","false","1","0"].includes(e.trim().toLowerCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="99f785c2-7c67-5564-9423-3439c41b4557")}catch{}})();var Ct=xr;function xo(e){let t=e.trim().toLowerCase();return Ct.includes(t)?t:null}function No(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=Math.max(1,Math.floor(t.length*.34));for(let r of Ct)if(St(t,r,n)!==null)return r;return null}import{constants as ee}from"node:os";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="aaf1c6ce-1bc9-5974-a38f-7daf8e4e63cc")}catch{}})();var Do=new Map([["EACCES",{summary:"was denied filesystem permission",recovery:"Grant the required filesystem access, then retry.",category:"permission"}],["EDQUOT",{summary:"exceeded the filesystem quota",recovery:"Raise or reclaim the filesystem quota, then retry.",category:"capacity"}],["EMFILE",{summary:"exhausted the process file-descriptor limit",recovery:"Close unused file handles or raise the process limit, then retry.",category:"resource"}],["ENFILE",{summary:"exhausted the host file-descriptor limit",recovery:"Free host file descriptors or raise the host limit, then retry.",category:"resource"}],["ENOMEM",{summary:"ran out of available memory",recovery:"Free memory or reduce concurrent work, then retry.",category:"resource"}],["ENOSPC",{summary:"ran out of storage space",recovery:"Free storage on the filesystem holding the project, then retry.",category:"capacity"}],["EPERM",{summary:"was denied by the host permission policy",recovery:"Grant the required filesystem permission, then retry.",category:"permission"}],["EROFS",{summary:"targeted a read-only filesystem",recovery:"Use a writable project filesystem or remount it read-write, then retry.",category:"permission"}]]),bd=/^[a-z][a-z0-9_]{0,63}$/u,wd=new Map([[ee.errno.EACCES,"EACCES"],[ee.errno.EDQUOT,"EDQUOT"],[ee.errno.EMFILE,"EMFILE"],[ee.errno.ENFILE,"ENFILE"],[ee.errno.ENOMEM,"ENOMEM"],[ee.errno.ENOSPC,"ENOSPC"],[ee.errno.EPERM,"EPERM"],[ee.errno.EROFS,"EROFS"]].filter(([e])=>Number.isInteger(e))),vd={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function Ed(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&Do.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:wd.get(Math.abs(t.errno))??null}function kd(e,t,n={}){let r=Ed(e);if(r===null)return null;if(!bd.test(t))throw new h("Host environment operation labels must be bounded identifiers.",y.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=Do.get(r);return new h(`Host filesystem operation ${t} ${o.summary}.`,y.GENERIC_FAILURE,{code:n.codes?.[o.category]??vd[o.category].code,reason:r,required:o.recovery,why:n.why??"The operating system refused a required project filesystem operation.",nextSteps:[o.recovery,...n.nextSteps??[]],...n.suggestedRetry?{recovery:{suggested_retry:n.suggestedRetry}}:{}})}async function Mo(e,t,n={}){try{return await t()}catch(r){throw kd(r,e,n)??r}}import Od from"node:fs/promises";import Ge from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6d77d806-1c41-5235-b56b-802089979395")}catch{}})();async function Po(e,t){let n=Ge.dirname(t.manifest_path),r=Ge.relative(n,t.entry_path);if(r.startsWith("..")||Ge.isAbsolute(r))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=Ge.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await Mo("extension_module_graph_snapshot",()=>Od.cp(n,o,{recursive:!0,force:!0})),Ge.join(o,r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="44b86710-2d6f-57fe-912d-1cf7482a4f86")}catch{}})();function $o(e){let t={beforeCommand:e.hooks.beforeCommand.length,beforeMutation:e.hooks.beforeMutation.length,afterCommand:e.hooks.afterCommand.length,onWrite:e.hooks.onWrite.length,onRead:e.hooks.onRead.length,onIndex:e.hooks.onIndex.length,commandOverrides:e.commands.overrides.length,commandHandlers:e.commands.handlers.length,parserOverrides:e.parsers.overrides.length,preflightOverrides:e.preflight.overrides.length,serviceOverrides:e.services.overrides.length,rendererOverrides:e.renderers.overrides.length,registrations:Object.fromEntries(Object.entries(e.registrations).map(([n,r])=>[n,r.length]))};return()=>{e.hooks.beforeCommand.length=t.beforeCommand,e.hooks.beforeMutation.length=t.beforeMutation,e.hooks.afterCommand.length=t.afterCommand,e.hooks.onWrite.length=t.onWrite,e.hooks.onRead.length=t.onRead,e.hooks.onIndex.length=t.onIndex,e.commands.overrides.length=t.commandOverrides,e.commands.handlers.length=t.commandHandlers,e.parsers.overrides.length=t.parserOverrides,e.preflight.overrides.length=t.preflightOverrides,e.services.overrides.length=t.serviceOverrides,e.renderers.overrides.length=t.rendererOverrides;for(let[n,r]of Object.entries(t.registrations))e.registrations[n].length=r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="092f2852-fa07-5f0f-8266-e9e2ca078cb6")}catch{}})();function Lo(e){let t=typeof e=="function"?e:e.run;if(typeof t!="function")throw new TypeError("registerPreflight override requires a function handler");let n=[...new Set((typeof e=="function"?[]:e.commands??[]).map(r=>{if(typeof r!="string"||r.trim().length===0)throw new TypeError("registerPreflight ownership.commands must contain non-empty command paths");return S(r)}))];return{run:t,...n.length>0?{commands:n}:{}}}function jo(e){let t=[];for(let n=1;n<e.overrides.length;n+=1){let r=e.overrides[n];for(let o of e.overrides.slice(0,n))r.commands?.length&&o.commands?.length&&!o.commands.some(i=>r.commands.includes(i))||t.push(`extension_preflight_override_collision:${r.layer}:${r.name}:${o.layer}:${o.name}`)}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="09c95125-68bd-512b-bb09-c9ef0b2f676e")}catch{}})();function Fo(e){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("registerService ownership must be an object");if(Reflect.ownKeys(e).some(t=>t!=="passThrough"))throw new TypeError("registerService ownership supports only passThrough");if(e.passThrough!==void 0&&typeof e.passThrough!="boolean")throw new TypeError("registerService ownership.passThrough must be a boolean when provided");return e.passThrough===!0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="aade6230-a71b-5cbc-bc9d-022f20e521bd")}catch{}})();function x(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return t}function D(e,t){if(t!==void 0&&typeof t!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function A(e,t){if(t!==void 0&&(typeof t!="string"||t.trim().length===0))throw new TypeError(`${e} must be a non-empty string when provided`)}function Uo(e,t){if(t===void 0)return;let n=r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean";if(Array.isArray(t)){for(let[r,o]of t.entries())if(!n(o))throw new TypeError(`${e}[${r}] must be a string, number, or boolean`);return}if(!n(t))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function pe(e,t){if(t!==void 0){if(!Array.isArray(t))throw new TypeError(`${e} must be an array of non-empty strings when provided`);for(let[n,r]of t.entries())if(typeof r!="string"||r.trim().length===0)throw new TypeError(`${e}[${n}] must be a non-empty string`)}}function Ke(e,t){if(pe(e,t),!Array.isArray(t))return[];let n=[],r=new Set;for(let o of t){let i=o.trim();i.length===0||r.has(i)||(r.add(i),n.push(i))}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="34536eba-0f92-5599-a807-5b39b000e733")}catch{}})();var An=Object.freeze(["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"]);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ca48c32a-e4e0-5da5-b9cb-b1f713646bad")}catch{}})();var Sd=new Set(An);function Ad(e){if(e!==void 0&&!Sd.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${An.join(", ")}`)}function zo(e){A("registerCommand definition.action",e.action),A("registerCommand definition.family",e.family),A("registerCommand definition.description",e.description),A("registerCommand definition.intent",e.intent),A("registerCommand definition.tier",e.tier);let t=e.tier;if(t!==void 0&&t!=="core"&&t!=="standard"&&t!=="full"&&t!=="internal")throw new Error("registerCommand definition.tier must be core, standard, full, or internal");Ad(e.family)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1729c469-5e9c-5d8c-8137-ec506c9fd31b")}catch{}})();function Td(e){let t=x("registerExporter options.output",e),n=new Set(["channel","receipt","media_type"]);for(let r of Object.keys(t))if(!n.has(r))throw new TypeError(`registerExporter options.output contains unsupported field ${r}`);if(t.channel!=="stdout"&&t.channel!=="file")throw new TypeError("registerExporter options.output.channel must be stdout|file");if(t.receipt!==void 0&&t.receipt!=="suppress"&&t.receipt!=="render")throw new TypeError("registerExporter options.output.receipt must be suppress|render");if(t.channel==="stdout"&&t.receipt==="render")throw new TypeError("registerExporter stdout artifacts cannot render a host receipt");return A("registerExporter options.output.media_type",t.media_type),{channel:t.channel,receipt:t.receipt??(t.channel==="stdout"?"suppress":"render"),...typeof t.media_type=="string"?{media_type:t.media_type}:{}}}function qo(e,t,n){if(e==="registerImporter"&&t.output!==void 0)throw new TypeError("registerImporter options.output is exporter-only");if(e!=="registerExporter"||t.output===void 0)return;let r=Td(t.output);return!n&&r.channel==="stdout"&&(t.description="Export items with the registered extension adapter. Artifact bytes are written exclusively to stdout and the host receipt is suppressed by default."),r}function Tn(e,t,n){return{registration:t,action:n,command:e.command,args:M(e.args),options:M(e.options),global:M(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,...e.sdk===void 0?{}:{sdk:e.sdk}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="09098e5c-d021-53ae-96b5-c56394c304da")}catch{}})();var Cd=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields"},{flag:"--output-limit",value_name:"count"},{flag:"--output-budget",value_name:"tokens"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state"},{flag:"--output-cursor",value_name:"cursor"},{flag:"--output-row-contract"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"]},{flag:"--no-extensions"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"}]),Cn=new Set(Cd.flatMap(e=>[e.flag,...e.aliases??[]]));(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f823edae-b035-5547-8d81-2761a9a44034")}catch{}})();var Id=/^--[a-z0-9][a-z0-9_-]*(?:[ =](?:<[^<>]+>|\[[^[\]]+\]))?$/;function Rd(e){if(typeof e!="string")return null;let t=e.trim(),n=t.split(/[ =]/,1)[0];return Cn.has(n)?"host_owned_flag_collision":Id.test(t)?null:"malformed_long_flag"}function Bo(e,t){let n=[e,t].find(i=>typeof i=="string"&&Cn.has(i.trim().split(/[ =]/,1)[0]));if(typeof n=="string")return{token:n.trim().split(/[ =]/,1)[0],failure:"host_owned_flag_collision"};if(typeof e!="string")return null;let r=e.trim(),o=Rd(r);return o===null?null:{token:r,failure:o}}function Vo(e,t){return t==="host_owned_flag_collision"?`cannot shadow host-owned global flag "${e}"; read it from context.global instead`:`long flag "${e}" must start with a double-dash name such as "--my-flag" or "--my-flag <value>"`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d2feae50-9a1e-54fa-98a3-df529be63069")}catch{}})();function Wo(e){return typeof e=="string"?e:String(e)}function He(e){let n=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(n)?n.split(/[.-]/).map(r=>Number(r)):null}function In(e,t){let n=He(e),r=He(t);if(!n||!r)return null;let o=Math.max(n.length,r.length);for(let i=0;i<o;i+=1){let s=n[i]??0,a=r[i]??0;if(s>a)return 1;if(s<a)return-1}return 0}function Go(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let n=Wo(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(!He(n))return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(t===null)return{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:null};let r=In(t,n);return r===null?{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:t}:r<0?{kind:"pm_min_version",status:"unmet",allowed:!1,required:n,current:t}:{kind:"pm_min_version",status:"ok",allowed:!0,required:n,current:t}}function Ko(e,t,n){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let r=Wo(e);if(typeof e!="string"||r.trim().length===0)return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(/^[<>=~^]/.test(r.trim())||!He(r))return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(t===null)return{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:null};let o=In(t,r);return o===null?{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:t}:o>0?n==="warn"?{kind:"pm_max_version",status:"exceeded_warn",allowed:!0,required:r,current:t}:{kind:"pm_max_version",status:"exceeded",allowed:!1,required:r,current:t}:{kind:"pm_max_version",status:"ok",allowed:!0,required:r,current:t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8ea4597b-6a2b-5061-b490-d8aff3fbe7aa")}catch{}})();function j(e){return typeof e!="string"?"":e.trim().toLowerCase()}function b(e){return new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))}function xd(e){let t=e.trim().toLowerCase();if(t.length===0)return"";let n=t.split(/[.:/]/).map(r=>r.replace(/[\s_-]+/g,"")).filter(r=>r.length>0);return n.length===0?"":n.length===1?n[0]:`${n[0]}.${n.slice(1).join("")}`}function Se(e){return new Set((e??[]).map(t=>xd(t)).filter(t=>t.length>0))}function Ho(e){let t=j(e);return dt.includes(t)?t:"off"}function Yo(e){let t=j(e);return ut.includes(t)?t:"off"}function Ye(e){let t=j(e);return ft.includes(t)?t:"none"}function Rn(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return Ir.includes(t)?t:void 0}function Xo(e){if(typeof e=="string"){let t=Rn(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:Rn(e.global)??"block",project:Rn(e.project)??"block"}:{global:"block",project:"block"}}function Nd(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function E(e){return[...new Set(e)].sort((t,n)=>t.localeCompare(n))}function Dd(e){let t=j(e.name);return t.length===0?null:{name:t,normalized:{name:t,disabled:e.disabled===!0,requireTrusted:e.require_trusted===!0,requireProvenance:e.require_provenance===!0,sandboxProfile:e.sandbox_profile!==void 0?Ye(e.sandbox_profile):void 0,allowedCapabilities:b(e.allowed_capabilities),blockedCapabilities:b(e.blocked_capabilities),allowedSurfaces:Se(e.allowed_surfaces),blockedSurfaces:Se(e.blocked_surfaces),allowedCommands:b(e.allowed_commands),blockedCommands:b(e.blocked_commands),allowedActions:b(e.allowed_actions),blockedActions:b(e.blocked_actions),allowedServices:b(e.allowed_services),blockedServices:b(e.blocked_services)}}}function Jo(e){let t=new Map;for(let n of e??[]){let r=Dd(n);r&&t.set(r.name,r.normalized)}return t}function Md(e){let t=[],n=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of E([...e.allowedCapabilities,...e.blockedCapabilities]))X(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of n)for(let i of E([...o.allowedCapabilities,...o.blockedCapabilities]))X(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let r=new Set(mt);for(let o of E([...e.allowedSurfaces,...e.blockedSurfaces]))r.has(o)||t.push(`extension_policy_unknown_surface:${o}`);for(let o of n)for(let i of E([...o.allowedSurfaces,...o.blockedSurfaces]))r.has(i)||t.push(`extension_policy_unknown_surface:${o.name}:${i}`);return[...new Set(t)].sort((o,i)=>o.localeCompare(i))}function Qo(e){let t=e.extensions?.policy??{},n=b(t.allowed_capabilities),r=b(t.blocked_capabilities),o=Se(t.allowed_surfaces),i=Se(t.blocked_surfaces),s=Jo(t.extension_overrides);return{mode:Ho(t.mode),trustMode:Yo(t.trust_mode),pmMaxVersionExceededMode:Xo(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:b(t.trusted_extensions),defaultSandboxProfile:Ye(t.default_sandbox_profile),allowedExtensions:b(t.allowed_extensions),blockedExtensions:b(t.blocked_extensions),allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:b(t.allowed_commands),blockedCommands:b(t.blocked_commands),allowedActions:b(t.allowed_actions),blockedActions:b(t.blocked_actions),allowedServices:b(t.allowed_services),blockedServices:b(t.blocked_services),overridesByName:s,warnings:Md({allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function Zo(e){let t=[...e.overridesByName.values()].sort((n,r)=>n.name.localeCompare(r.name)).map(n=>({name:n.name,...n.disabled?{disabled:!0}:{},...n.requireTrusted?{require_trusted:!0}:{},...n.requireProvenance?{require_provenance:!0}:{},...n.sandboxProfile?{sandbox_profile:n.sandboxProfile}:{},...n.allowedCapabilities.size>0?{allowed_capabilities:E(n.allowedCapabilities)}:{},...n.blockedCapabilities.size>0?{blocked_capabilities:E(n.blockedCapabilities)}:{},...n.allowedSurfaces.size>0?{allowed_surfaces:E(n.allowedSurfaces)}:{},...n.blockedSurfaces.size>0?{blocked_surfaces:E(n.blockedSurfaces)}:{},...n.allowedCommands.size>0?{allowed_commands:E(n.allowedCommands)}:{},...n.blockedCommands.size>0?{blocked_commands:E(n.blockedCommands)}:{},...n.allowedActions.size>0?{allowed_actions:E(n.allowedActions)}:{},...n.blockedActions.size>0?{blocked_actions:E(n.blockedActions)}:{},...n.allowedServices.size>0?{allowed_services:E(n.allowedServices)}:{},...n.blockedServices.size>0?{blocked_services:E(n.blockedServices)}:{}}));return{mode:e.mode,trust_mode:e.trustMode,pm_max_version_exceeded_mode:Nd(e.pmMaxVersionExceededMode),require_provenance:e.requireProvenance,trusted_extensions:E(e.trustedExtensions),default_sandbox_profile:e.defaultSandboxProfile,allowed_extensions:E(e.allowedExtensions),blocked_extensions:E(e.blockedExtensions),allowed_capabilities:E(e.allowedCapabilities),blocked_capabilities:E(e.blockedCapabilities),allowed_surfaces:E(e.allowedSurfaces),blocked_surfaces:E(e.blockedSurfaces),allowed_commands:E(e.allowedCommands),blocked_commands:E(e.blockedCommands),allowed_actions:E(e.allowedActions),blocked_actions:E(e.blockedActions),allowed_services:E(e.allowedServices),blocked_services:E(e.blockedServices),extension_overrides:t}}function ei(e){let t=Jo(e.extension_overrides);return{mode:Ho(e.mode),trustMode:Yo(e.trust_mode),pmMaxVersionExceededMode:Xo(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:b(e.trusted_extensions),defaultSandboxProfile:Ye(e.default_sandbox_profile),allowedExtensions:b(e.allowed_extensions),blockedExtensions:b(e.blocked_extensions),allowedCapabilities:b(e.allowed_capabilities),blockedCapabilities:b(e.blocked_capabilities),allowedSurfaces:Se(e.allowed_surfaces),blockedSurfaces:Se(e.blocked_surfaces),allowedCommands:b(e.allowed_commands),blockedCommands:b(e.blocked_commands),allowedActions:b(e.allowed_actions),blockedActions:b(e.blocked_actions),allowedServices:b(e.allowed_services),blockedServices:b(e.blocked_services),overridesByName:t,warnings:[]}}function te(e,t){return e.overridesByName.get(j(t))??null}function Ae(e,t,n,r,o){return t.has(n)?o:e.size>0&&!e.has(n)?r:null}function ti(e,t,n){let r=n.trim().toLowerCase(),o=te(e,t.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return Ae(i,s,r,"capability_not_allowlisted","capability_blocked")}function Pd(e,t,n){let r=te(e,t.name),o=r&&r.allowedSurfaces.size>0?r.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...r?r.blockedSurfaces:[]]);return Ae(o,i,n,"surface_not_allowlisted","surface_blocked")}function $d(e,t,n){let r=S(n);if(r.length===0)return null;let o=te(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return Ae(i,s,r,"command_not_allowlisted","command_blocked")}function Ld(e,t,n){let r=j(n).replace(/\s+/g,"-");if(r.length===0)return null;let o=te(e,t.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return Ae(i,s,r,"action_not_allowlisted","action_blocked")}function jd(e,t,n){let r=j(n);if(r.length===0)return null;let o=te(e,t.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return Ae(i,s,r,"service_not_allowlisted","service_blocked")}function Fd(e,t){let n=j(t.name);return te(e,t.name)?.disabled===!0?"extension_override_disabled":Ae(e.allowedExtensions,e.blockedExtensions,n,"extension_not_allowlisted","extension_blocked")}function Ud(e,t){if(e.trustMode==="off")return null;let n=te(e,t.name),r=j(t.name),o=t.trusted===!0,i=t.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(r)?"extension_not_trusted":(n?.requireTrusted===!0||e.trustMode==="warn"||e.trustMode==="enforce")&&!o?"extension_untrusted":(e.requireProvenance||n?.requireProvenance===!0)&&!i?"provenance_missing_or_unverified":null}function zd(e,t){if(e.mode==="off")return null;let r=te(e,t.name)?.sandboxProfile??t.sandboxProfile??e.defaultSandboxProfile;if(r==="none")return null;let o=t.permissions;if(!o)return"sandbox_permissions_missing";let i=s=>o[s]===!0;return r==="restricted"?i("process_spawn")?"sandbox_restricted_disallows_process_spawn":i("env_write")?"sandbox_restricted_disallows_env_write":null:i("process_spawn")?"sandbox_strict_disallows_process_spawn":i("network")?"sandbox_strict_disallows_network":i("fs_write")?"sandbox_strict_disallows_fs_write":i("env_write")?"sandbox_strict_disallows_env_write":null}function It(e,t,n,r,o={}){let i=Object.entries(o).sort((a,c)=>a[0].localeCompare(c[0])).map(([a,c])=>`${a}=${c}`).join(":"),s=i.length>0?`:${i}`:"";return`extension_policy_${e}_${t}:${n.layer}:${n.name}:reason=${r}${s}`}function ni(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let n=[],r=Fd(e,t);r&&n.push({reason:r,scope:"extension",mode:e.mode});let o=Ud(e,t);o&&n.push({reason:o,scope:"trust",mode:e.trustMode});let i=zd(e,t);i&&n.push({reason:i,scope:"extension",mode:e.mode});let s=n.find(c=>c.mode==="enforce");if(s)return{allowed:!1,warning:It("blocked",s.scope,t,s.reason)};let a=n.find(c=>c.mode==="warn");return a?{allowed:!0,warning:It("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function ri(e,t,n){if(e.mode==="off")return{allowed:!0,warning:null};let r=ti(e,t,n);return r?{allowed:e.mode==="warn",warning:It(e.mode==="warn"?"violation":"blocked","capability",t,r,{capability:n.trim().toLowerCase()})}:{allowed:!0,warning:null}}function qd(e,t,n,r,o){let i=typeof r=="string"?ti(e,t,r):null,s=Pd(e,t,n),a=o.command?$d(e,t,o.command):null,c=o.action?Ld(e,t,o.action):null,l=o.service?jd(e,t,o.service):null;return i??s??a??c??l}function Bd(e,t,n,r){let o={method:j(e).replace(/\s+/g,"_"),surface:t};return n&&(o.capability=n),r.command&&(o.command=S(r.command)),r.action&&(o.action=j(r.action).replace(/\s+/g,"-")),r.service&&(o.service=j(r.service)),o}function oi(e,t,n,r,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=qd(e,t,n,o,s);if(!a)return{allowed:!0,warning:null};let c=It(e.mode==="warn"?"violation":"blocked","registration",t,a,Bd(r,n,o,s));return{allowed:e.mode==="warn",warning:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01116a5e-62d1-591b-9fd0-84ac6e99f8d0")}catch{}})();function Rt(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function xn(){return{overrides:[],handlers:[]}}function Nn(){return{overrides:[]}}function Dn(){return{overrides:[]}}function Mn(){return{overrides:[]}}function Pn(){return{overrides:[]}}function $n(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[],assurance_providers:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="483b4197-5498-568a-bcc4-abd6999a07cc")}catch{}})();function ii(e){return e==="toon"||e==="json"}function si(e){return Ee.includes(e)}function _e(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var ai=Symbol("extension_registration_trace");function G(e,t){let n=new TypeError(e);return Object.defineProperty(n,ai,{value:t,enumerable:!1,configurable:!1,writable:!1}),n}function ci(e){return e instanceof Error?e[ai]:void 0}function Xe(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>Xe(t));if(typeof e=="function")return"[Function]";if(typeof e=="bigint"||typeof e=="symbol")return e.toString();if(typeof e=="object"){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=Xe(t[r]);return n}return e}function Je(e){if(Array.isArray(e))return e.map(t=>Je(t));if(typeof e=="object"&&e!==null){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=Je(t[r]);return n}return e}function Te(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Xe(t)}function Qe(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Je(t)}function xt(e,t){if(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(n=>Te(e,n))}function $(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function Ze(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function Ln(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function jn(e,t){return S(`${e} ${t}`)}function et(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var Vd=new Set(["low","medium","high"]),Wd=new Set(["number","string_set"]),Gd=new Set(["string","number","boolean"]);function li(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function Kd(e,t,n){let r=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=x(r,n);if(!Wd.has(String(o.value_type)))throw new TypeError(`${r}.value_type must be number or string_set`);if(A(`${r}.description`,o.description),o.parameters===void 0)return;let i=x(`${r}.parameters`,o.parameters);for(let[s,a]of Object.entries(i)){let c=`${r}.parameters.${s}`;li(`${c}.name`,s);let l=x(c,a);if(!Gd.has(String(l.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);D(`${c}.required`,l.required),A(`${c}.description`,l.description)}if(Object.keys(i).length>50)throw new TypeError(`assurance provider ${e} key ${t} exceeds 50 parameters`)}function di(e){let t=x("registerAssuranceMeasurementProvider provider",e),n=li("registerAssuranceMeasurementProvider provider.id",t.id);if(!/^[a-z0-9][a-z0-9-]*$/u.test(n))throw new TypeError("registerAssuranceMeasurementProvider provider.id must be a stable lowercase id");if(!Vd.has(String(t.cost_class)))throw new TypeError("registerAssuranceMeasurementProvider provider.cost_class must be low, medium, or high");if(typeof t.network!="boolean")throw new TypeError("registerAssuranceMeasurementProvider provider.network must be boolean");let r=x("registerAssuranceMeasurementProvider provider.keys",t.keys);if(Object.keys(r).length===0)throw new TypeError("registerAssuranceMeasurementProvider provider.keys requires at least one key");for(let[o,i]of Object.entries(r)){if(!/^[a-z0-9][a-z0-9-]*$/u.test(o))throw new TypeError(`registerAssuranceMeasurementProvider provider key ${o} must be a stable lowercase id`);Kd(n,o,i)}if(t.timeout_ms!==void 0&&(typeof t.timeout_ms!="number"||!Number.isInteger(t.timeout_ms)||t.timeout_ms<1||t.timeout_ms>3e5))throw new TypeError("registerAssuranceMeasurementProvider provider.timeout_ms must be an integer from 1 through 300000");if(typeof t.resolve!="function")throw new TypeError("registerAssuranceMeasurementProvider provider.resolve requires a function handler")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b35d854e-5025-5999-abe7-507f1a25647f")}catch{}})();function ui(e){return!e.extensionReady||!e.enabledForLoad?null:{layer:e.layer,directory:e.directory,manifest_path:e.manifestPath,entry_path:e.entryPath,manifest:e.manifest,source_package:e.sourceIdentity?.package_name,source_aliases:e.sourceIdentity?.aliases,contributions:e.sourceIdentity?.contributions}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="736cf7fc-d4da-57ce-90d8-2432085dd2c8")}catch{}})();var Hd=5e3;async function Fn(e,t,n){let r=[];for(let o of e)try{await o.run(M(n))}catch{r.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return r}function Yd(e,t,n){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new h(`Extension mutation guard ${t.name} returned an invalid decision.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${t.layer}:${t.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let r=e,o=typeof r.code=="string"?r.code.trim():"",i=typeof r.remediation=="string"?r.remediation.trim():"";if(o.length===0||i.length===0)throw new h(`Extension mutation guard ${t.name} returned an invalid denial.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${t.layer}:${t.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof r.message=="string"?r.message.trim():"";throw new h(s||`Extension mutation guard ${t.name} denied ${n}.`,y.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function Un(e,t){for(let n of e.beforeMutation??[]){let r,o;try{let i=Promise.resolve().then(()=>n.run({pm_root:t.pm_root,operation:t.operation,before:t.before===null?null:M(t.before),after:t.after===null?null:M(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),r=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new h(`Extension mutation guard ${n.name} timed out before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},Hd),o.unref?.()})])}catch(i){throw i instanceof h?i:new h(`Extension mutation guard ${n.name} failed before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(o)}Yd(r,n,t.operation)}}async function zn(e,t){return Fn(e.onWrite,"onWrite",t)}async function qn(e,t){return Fn(e.onRead,"onRead",t)}async function Bn(e,t){return Fn(e.onIndex,"onIndex",t)}function Xd(e){let t="";e instanceof Error&&typeof e.message=="string"?t=e.message:typeof e=="string"?t=e:typeof e=="object"&&e!==null&&typeof e.message=="string"&&(t=e.message);let n=t.replace(/\s+/gu," ").trim();if(n.length===0)return"";let r=300;return n.length>r?`${n.slice(0,r-1)}\u2026`:n}function Nt(e,t){if(typeof e!="object"||e===null||typeof e[t]!="string")return;let n=String(e[t]).replace(/\s+/gu," ").trim();return n.length>0?n.slice(0,300):void 0}function Jd(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"exit_code"))return;let t=e.exit_code;if(typeof t!="number"||!Number.isInteger(t)||t<1||t>255)throw new TypeError("Extension command result exit_code must be an integer from 1 to 255.");return t}async function Vn(e,t){let n=S(t.command);if(n.length===0)return{handled:!1,result:null,warnings:[]};let r=[...e.handlers].reverse().find(o=>o.command===n);if(!r)return{handled:!1,result:null,warnings:[]};try{let o=await r.run({command:n,args:M(t.args),options:M(t.options),global:M(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,...t.sdk===void 0?{}:{sdk:t.sdk}});return{handled:!0,result:o,warnings:[],...Object.fromEntries([["exitCode",Jd(o)],["errorCode",Nt(o,"code")],["remediation",Nt(o,"remediation")]].filter(i=>i[1]!==void 0))}}catch(o){let i=typeof o=="object"&&o!==null&&"exitCode"in o?o.exitCode:void 0;if(typeof i=="number"&&Number.isFinite(i))throw o;return{handled:!1,result:null,warnings:[`extension_command_handler_failed:${r.layer}:${r.name}:${r.command}`],errorMessage:Xd(o),...Object.fromEntries([["errorCode",Nt(o,"code")],["remediation",Nt(o,"remediation")]].filter(s=>s[1]!==void 0))}}}function fi(e){return{handled:!1,result:e.payload,warnings:[]}}function mi(e,t){return[...e.overrides].reverse().filter(n=>n.service===t)}function pi(e){return{service:e.service,command:e.command?S(e.command):void 0,args:e.args?M(e.args):void 0,options:e.options?$r(e.options):void 0,global:e.global?Lr(e.global):void 0,pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,payload:M(e.payload)}}function Qd(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"handled"))return!1;let t=e.handled;return t===!0?Object.hasOwn(e,"result"):t===!1&&Reflect.ownKeys(e).length===1}function _i(e,t){return Qd(e)?e.handled?{handled:!0,result:e.result}:{handled:!1,result:t.payload}:t.service==="output_format"&&e==null?{handled:!1,result:t.payload}:{handled:!0,result:e}}function gi(e,t,n){return t.service==="output_format"&&typeof e=="object"&&e!==null&&q(e,n.payload)}function yi(e,t,n){if(t.handled){if(e.passThrough===!0){n.push(`extension_service_pass_through_contract_violated:${e.layer}:${e.name}:${e.service}`);return}return{handled:!0,result:t.result,warnings:n}}}function Wn(e,t){let n=mi(e,t.service);if(n.length===0)return fi(t);let r=[];for(let o of n)try{let i=pi(t),s=o.run(i);if(s instanceof Promise){r.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(gi(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=yi(o,_i(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}async function Gn(e,t){let n=mi(e,t.service);if(n.length===0)return fi(t);let r=[];for(let o of n)try{let i=pi(t),s=await Promise.resolve(o.run(i));if(gi(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=yi(o,_i(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2f54ac29-9bf8-51f4-9352-8f57d1b5a798")}catch{}})();var ou=100,hi=null,iu=Object.freeze(pt()),bi=0;function su(e=Date.now()){return bi+=1,`${bi}-${e}`}function wi(e,t){let n=e[t];if(n!=null)return typeof n!="string"||n.trim().length===0?null:n.trim()}function au(e){if(e==null)return;let t=me(e);if(!t)return null;let n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i))){if(r.trim().length===0)return null;let o=t[r];if(typeof o!="string"||o.trim().length===0)return null;n[r.trim()]=o.trim()}return Object.keys(n).length>0?n:void 0}function Kn(e,t){let n=e[t];return typeof n!="string"||n.trim().length===0?null:n.trim()}function Ii(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function ge(e){if(e!=null)return typeof e!="boolean"?null:e}function cu(e){let t=Ii(e.priority);return t===void 0?ou:t}function lu(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let n=Ye(t);return n!==t.trim().toLowerCase()?null:n}function Hn(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function du(e){if(e==null)return;let t=me(e);if(!t)return null;let n=Hn(t.source),r=Hn(t.signature),o=Hn(t.attestation),i=t.verified===void 0||t.verified===null?void 0:typeof t.verified=="boolean"?t.verified:null;return i===null?null:{...n?{source:n}:{},...r?{signature:r}:{},...o?{attestation:o}:{},...typeof i=="boolean"?{verified:i}:{}}}function uu(e){if(e==null)return;let t=me(e);if(!t)return null;let n=ge(t.fs_read),r=ge(t.fs_write),o=ge(t.network),i=ge(t.env_read),s=ge(t.env_write),a=ge(t.process_spawn);return[n,r,o,i,s,a].includes(null)?null:{...typeof n=="boolean"?{fs_read:n}:{},...typeof r=="boolean"?{fs_write:r}:{},...typeof o=="boolean"?{network:o}:{},...typeof i=="boolean"?{env_read:i}:{},...typeof s=="boolean"?{env_write:s}:{},...typeof a=="boolean"?{process_spawn:a}:{}}}function fu(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(n=>typeof n!="string"))return null;let t=Gr(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function mu(e){if(e==null)return;let t=me(e);if(!t)return null;let n=t.commands;if(n==null)return;if(!Array.isArray(n)||n.some(o=>typeof o!="string"))return null;let r=[...new Set(n.map(o=>S(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return r.length>0?{commands:r}:void 0}function pu(e){let t=Ii(e.manifest_version);if(t===null)return null;let n=wi(e,"pm_min_version");if(n===null)return null;let r=wi(e,"pm_max_version");if(r===null)return null;let o=au(e.engines);if(o===null)return null;let i=ge(e.trusted);if(i===null)return null;let s=lu(e);if(s===null)return null;let a=du(e.provenance);if(a===null)return null;let c=uu(e.permissions);if(c===null)return null;let l=fu(e.capabilities);if(l===null)return null;let d=mu(e.activation);if(d===null)return null;let u=cn(e.contributions);return u===null?null:{manifest_version:t,pm_min_version:n,pm_max_version:r,engines:o,trusted:i,sandbox_profile:s,provenance:a,permissions:c,capabilities:l.capabilities,legacy_capability_aliases:l.legacy_aliases,activation:d,contributions:u}}function _u(e){if(typeof e!="object"||e===null)return null;let t=e,n=Kn(t,"name");if(n===null)return null;let r=Kn(t,"version");if(r===null)return null;let o=Kn(t,"entry");if(o===null)return null;let i=cu(t);if(i===null)return null;let s=pu(t);return s===null?null:{name:n,version:r,entry:o,priority:i,manifest_version:s.manifest_version,pm_min_version:s.pm_min_version,pm_max_version:s.pm_max_version,engines:s.engines,trusted:s.trusted,provenance:s.provenance,sandbox_profile:s.sandbox_profile,permissions:s.permissions,activation:s.activation,contributions:s.contributions,capabilities:s.capabilities,legacy_capability_aliases:s.legacy_capability_aliases.length>0?s.legacy_capability_aliases:void 0}}function gu(e,t,n){return n.has(e)?!1:t.size===0?!0:t.has(e)}async function yu(e,t){let[n,r]=await Promise.all([he.realpath(e),he.realpath(t)]);return hn(n,r)}function hu(e,t=process.cwd()){return{global:ye.join(Eo(t),"extensions"),project:ye.join(e,"extensions")}}async function bu(e){try{return(await he.readdir(e,{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>n.name).sort((n,r)=>n.localeCompare(r))}catch{return[]}}function wu(e){let t={layer:e.layer,directory:e.directory,manifest_path:e.manifest_path,name:e.manifest.name,version:e.manifest.version,entry:e.manifest.entry,priority:e.manifest.priority,entry_path:e.entry_path,manifest_version:e.manifest.manifest_version,pm_min_version:e.manifest.pm_min_version,pm_max_version:e.manifest.pm_max_version,engines:e.manifest.engines,trusted:e.manifest.trusted,provenance:e.manifest.provenance,sandbox_profile:e.manifest.sandbox_profile,permissions:e.manifest.permissions,capabilities:[...e.manifest.capabilities],activation:e.manifest.activation?{commands:[...e.manifest.activation.commands]}:void 0,contributions:e.manifest.contributions??e.contributions};return e.source_package&&(t.source_package=e.source_package),e.source_aliases&&(t.source_aliases=[...e.source_aliases]),t}function vi(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function vu(e){let t=new Map;try{let n=JSON.parse(await he.readFile(ye.join(e,".managed-extensions.json"),"utf8")),o=me(n)?.entries;if(!Array.isArray(o))return t;for(let i of o){if(typeof i!="object"||i===null)continue;let s=i,a=vi(s.source?.package),c=[s.source?.input,s.source?.name,a].map(u=>vi(u)).filter(u=>u!==void 0),l=cn(s.contributions),d={aliases:[...new Set(c)],...a?{package_name:a}:{},...l?{contributions:l}:{}};typeof s.directory=="string"&&s.directory.trim().length>0&&t.set(`directory:${s.directory.trim()}`,d),typeof s.name=="string"&&s.name.trim().length>0&&t.set(`name:${s.name.trim()}`,d)}}catch{return t}return t}function Ei(e){return[...e].sort((t,n)=>{if(t.manifest.priority!==n.manifest.priority)return t.manifest.priority-n.manifest.priority;let r=t.manifest.name.localeCompare(n.manifest.name);return r!==0?r:t.directory.localeCompare(n.directory)})}function Eu(e,t){let n=[...Ei(e),...Ei(t)],r=[];for(let o of n){let i=r.findIndex(s=>s.manifest.name===o.manifest.name);i>=0&&r.splice(i,1),r.push(o)}return r}async function ki(e,t,n,r,o){let i=[],s=[],a=[],c=await bu(t),l=await vu(t);for(let d of c){let u=await Su(e,t,d,n,r,l,o);i.push(u.diagnostic),s.push(...u.warnings),u.candidate&&a.push(u.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function ku(){return{diagnostics:[],warnings:[],candidates:[]}}function Oi(e,t,n,r){return{diagnostic:{layer:e,directory:t,manifest_path:n,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[r],candidate:null}}function Ou(e,t,n,r,o,i,s){let a=Mr(e,t,n);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&a.push(Hr(e,t.name,t.legacy_capability_aliases));for(let c of Wr(t.capabilities))a.push(Kr(e,t.name,c));return r?o||a.push(`extension_entry_missing:${e}:${t.name}`):a.push(`extension_entry_outside_extension:${e}:${t.name}`),i.warning&&a.push(i.warning),s.warning&&a.push(s.warning),a}async function Su(e,t,n,r,o,i,s){let a=ye.join(t,n),c=ye.join(a,"manifest.json");if(!await yn(c))return Oi(e,n,c,`extension_manifest_missing:${e}:${n}`);let l,d;try{let ct=JSON.parse(await he.readFile(c,"utf8"));d=me(ct),l=_u(ct)}catch{d=null,l=null}if(!l||!d)return Oi(e,n,c,`extension_manifest_invalid:${e}:${n}`);let u=ye.resolve(a,l.entry),m=hn(a,u),f=m?await yn(u):!1,p=m&&f?await yu(a,u):m,_=gu(l.name,r,o),g=await Cu(e,l),w=await Iu(e,l,s),v=Ou(e,l,d,p,f,g,w),R=p&&f&&g.allowed&&w.allowed,Cr=i.get(`directory:${n}`)??i.get(`name:${l.name}`);return{diagnostic:{layer:e,directory:n,manifest_path:c,name:l.name,version:l.version,entry:l.entry,priority:l.priority,entry_path:u,enabled:_,status:R?"ok":"warn"},warnings:v,candidate:ui({layer:e,directory:n,manifestPath:c,entryPath:u,manifest:l,sourceIdentity:Cr,extensionReady:R,enabledForLoad:_})}}async function Au(e){let t=hu(e.pmRoot,e.cwd??process.cwd()),n=Be(e.settings.extensions.enabled),r=Be(e.settings.extensions.disabled),o=Qo(e.settings),i=Zo(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:n,configured_disabled:r,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(n),a=new Set(r),c=e.ignoreGlobalExtensions===!0?ku():await ki("global",t.global,s,a,o.pmMaxVersionExceededMode.global),l=await ki("project",t.project,s,a,o.pmMaxVersionExceededMode.project),d=[...o.warnings],u=Eu(c.candidates,l.candidates),m=[];for(let f of u){let p={layer:f.layer,name:f.manifest.name,trusted:f.manifest.trusted===!0,provenanceVerified:f.manifest.provenance?.verified===!0,sandboxProfile:f.manifest.sandbox_profile,permissions:f.manifest.permissions&&typeof f.manifest.permissions=="object"?{fs_read:f.manifest.permissions.fs_read,fs_write:f.manifest.permissions.fs_write,network:f.manifest.permissions.network,env_read:f.manifest.permissions.env_read,env_write:f.manifest.permissions.env_write,process_spawn:f.manifest.permissions.process_spawn}:void 0},_=ni(o,p);if(_.warning&&d.push(_.warning),!!_.allowed){for(let g of f.manifest.capabilities){let w=ri(o,p,g);w.warning&&d.push(w.warning)}m.push(wu(f))}}return{disabled_by_flag:!1,roots:t,configured_enabled:n,configured_disabled:r,discovered:[...c.diagnostics,...l.diagnostics],effective:m,warnings:[...new Set([...c.warnings,...l.warnings,...d])],policy:i}}function Dt(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function Tu(){try{let e=vn(import.meta.url,["../../.."]),t=await he.readFile(ye.join(e,"package.json"),"utf8"),n=JSON.parse(t);return typeof n.version=="string"&&n.version.trim().length>0?n.version.trim():null}catch{return null}}function Ri(){return hi??=Tu(),hi}function xi(e,t,n){let r=n.current??"unknown";if(n.kind==="pm_min_version")switch(n.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${t.name}:required=${n.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${t.name}:required=${n.required}:current=${r}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${t.name}:required=${n.required}:current=${r}`;default:return}switch(n.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${t.name}:allowed=${n.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${t.name}:allowed=${n.required}:current=${r}`;default:return}}async function Cu(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let n=Go(t.pm_min_version,await Ri()),r=xi(e,t,n);return r?{allowed:n.allowed,warning:r}:{allowed:n.allowed}}async function Iu(e,t,n){if(t.pm_max_version===void 0)return{allowed:!0};let r=Ko(t.pm_max_version,await Ri(),n),o=xi(e,t,r);return o?{allowed:r.allowed,warning:o}:{allowed:r.allowed}}async function Si(e){try{let t=await he.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function Ru(e,t){let n=e.entry_path;t.module_graph_snapshot_root&&(n=await Po(t.module_graph_snapshot_root,e));let r=new URL(ru(n).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return r.href;let[i,s]=await Promise.all([Si(e.entry_path),Si(e.manifest_path)]),a=t.reload_token??su();return r.searchParams.set("pm_ext_reload",a),r.searchParams.set("pm_ext_entry",i),r.searchParams.set("pm_ext_manifest",s),r.href}async function Tb(e){let t=await Au(e),n=[],r=[],o=[...t.warnings];if(t.disabled_by_flag)return{...t,warnings:o,loaded:n,failed:r};let i=typeof e.extensionFilter=="function"?t.effective.filter(e.extensionFilter):t.effective;for(let s of i)try{let c=await import(await Ru(s,e));n.push({...s,module:c})}catch(a){o.push(`extension_load_failed:${s.layer}:${s.name}`),r.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:Dt(a)})}return{...t,warnings:o,loaded:n,failed:r}}var Ai=5e3,xu=2147483647;function Nu(e){let n={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let r=e.deactivate;n.deactivate=r.bind(e)}return n}function Ni(e){let t=To(e);return t?Nu(t):null}async function Cb(e,t,n={}){let r=Du(n?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(d=>`${d.layer}:${d.name}`)),i=[];for(let d of e.loaded){if(o.has(`${d.layer}:${d.name}`))continue;let u=Ni(d.module);!u||typeof u.deactivate!="function"||i.push({extension:d,deactivate:u.deactivate})}let s=await Promise.all(i.map(async({extension:d,deactivate:u})=>{try{return await Mu(u,r),{ok:!0}}catch(m){return{ok:!1,layer:d.layer,name:d.name,error:Dt(m)}}})),a=[],c=[],l=0;for(let d of s){if(d.ok){l+=1;continue}a.push(`extension_deactivate_failed:${d.layer}:${d.name}`),c.push({layer:d.layer,name:d.name,error:d.error})}return{deactivated:l,warnings:a,failed:c}}function Du(e){return typeof e!="number"||e<0?Ai:e===0||e===1/0?0:Number.isFinite(e)?Math.min(xu,Math.max(1,Math.floor(e))):Ai}async function Mu(e,t){if(t===0){await e();return}let n;try{let r=Promise.resolve().then(()=>e());r.catch(()=>{}),await Promise.race([r,new Promise((o,i)=>{n=setTimeout(()=>{i(new Error(`extension deactivate timed out after ${t}ms`))},t),n.unref?.()})])}finally{clearTimeout(n)}}var Pu=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","visible"]);function Yn(e,t){return xt(e,t).map(n=>(n.repeatable===!0&&(n.list=!0),n))}function $u(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function Ti(e,t){if(t===void 0)return e.replace(/\s+/g,"-");if(typeof t!="string"||t.trim().length===0)throw new TypeError("registerCommand definition.action must be a non-empty string when provided");let n=$u(t);if(n.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return n}function Ci(e){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("registerCommand definition.arguments must be an array when provided");let t=[];for(let[r,o]of e.entries()){let i=x(`registerCommand definition.arguments[${r}]`,o),s=$(`registerCommand definition.arguments[${r}].name`,i.name);if(D(`registerCommand definition.arguments[${r}].required`,i.required),D(`registerCommand definition.arguments[${r}].variadic`,i.variadic),A(`registerCommand definition.arguments[${r}].description`,i.description),s.includes(" "))throw new TypeError(`registerCommand definition.arguments[${r}].name must not contain spaces`);let a={name:s};i.required===!0&&(a.required=!0),i.variadic===!0&&(a.variadic=!0),typeof i.description=="string"&&(a.description=i.description.trim()),t.push(a)}let n=t.map((r,o)=>r.variadic?o:-1).filter(r=>r>=0);if(n.length>1)throw new TypeError("registerCommand definition.arguments supports at most one variadic argument");if(n.length===1&&n[0]!==t.length-1)throw new TypeError("registerCommand definition.arguments variadic argument must be the final argument");return t}function Xn(e){if(!Array.isArray(e))throw new TypeError("registerFlags flags requires an array of object definitions");for(let[t,n]of e.entries()){let r=x(`registerFlags flags[${t}]`,n),o=Object.keys(r).filter(c=>!Pu.has(c)).sort((c,l)=>c.localeCompare(l));if(o.length>0)throw new TypeError(`registerFlags flags[${t}] contains unknown field(s): ${o.join(", ")}`);let i=r.long,s=r.short;if(i===void 0&&s===void 0)throw new TypeError(`registerFlags flags[${t}] requires at least one of long or short`);A(`registerFlags flags[${t}].long`,i),A(`registerFlags flags[${t}].short`,s);let a=Bo(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${Vo(a.token,a.failure)}`);if(A(`registerFlags flags[${t}].value_name`,r.value_name),A(`registerFlags flags[${t}].description`,r.description),D(`registerFlags flags[${t}].required`,r.required),D(`registerFlags flags[${t}].enabled`,r.enabled),D(`registerFlags flags[${t}].visible`,r.visible),D(`registerFlags flags[${t}].list`,r.list),D(`registerFlags flags[${t}].repeatable`,r.repeatable),r.list!==void 0&&r.repeatable!==void 0&&r.list!==r.repeatable)throw new TypeError(`registerFlags flags[${t}].list and repeatable must match when both are provided`);if(Uo(`registerFlags flags[${t}].default`,r.default),Array.isArray(r.default)&&r.list!==!0&&r.repeatable!==!0)throw new TypeError(`registerFlags flags[${t}].default cannot be an array unless list is true.`);Lu(`registerFlags flags[${t}]`,r)}}function Lu(e,t){let n=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0);if(n===void 0)return;let r=Co(n);if(r===null)throw new TypeError(`${e} value_type "${n}" is not a known flag value type (expected one of: string, number, boolean).`);if(t.default===void 0)return;let o=t.list===!0||t.repeatable===!0?Io(t.default):[t.default];for(let[i,s]of o.entries())if(!Ro(s,r)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${r}.`)}}function ju(e){if(!Array.isArray(e))throw new TypeError("registerItemFields fields requires an array of object definitions");for(let[t,n]of e.entries()){let r=x(`registerItemFields fields[${t}]`,n);$(`registerItemFields fields[${t}].name`,r.name);let o=$(`registerItemFields fields[${t}].type`,r.type);if(xo(o)===null){let i=No(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${Ct.join(", ")}).${s}`)}D(`registerItemFields fields[${t}].optional`,r.optional)}}function Fu(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].command_option_policies`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=x(i,o);$(`${i}.command`,s.command),$(`${i}.option`,s.option),D(`${i}.enabled`,s.enabled),D(`${i}.required`,s.required),D(`${i}.visible`,s.visible)}}function Uu(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].options`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=x(i,o);$(`${i}.key`,s.key),pe(`${i}.values`,s.values),D(`${i}.required`,s.required),pe(`${i}.aliases`,s.aliases)}}function zu(e){if(!Array.isArray(e))throw new TypeError("registerItemTypes types requires an array of object definitions");for(let[t,n]of e.entries()){let r=`registerItemTypes types[${t}]`,o=x(r,n);$(`${r}.name`,o.name),A(`${r}.folder`,o.folder),pe(`${r}.aliases`,o.aliases),pe(`${r}.required_create_fields`,o.required_create_fields),pe(`${r}.required_create_repeatables`,o.required_create_repeatables),Fu(t,o.command_option_policies),Uu(t,o.options)}}function qu(e){let t=x("registerMigration definition",e);if(t.id!==void 0&&typeof t.id!="string")throw new TypeError("registerMigration definition.id must be a string when provided");if(t.description!==void 0&&typeof t.description!="string")throw new TypeError("registerMigration definition.description must be a string when provided");if(t.status!==void 0&&typeof t.status!="string")throw new TypeError("registerMigration definition.status must be a string when provided");if(D("registerMigration definition.mandatory",t.mandatory),t.run!==void 0&&typeof t.run!="function")throw new TypeError("registerMigration definition.run must be a function when provided")}var Di=["types","statuses","fields","workflows","config","templates","packages"],Bu={types:(e,t)=>{if(t.name!==void 0&&typeof t.name!="string")throw new TypeError(`${e}.name must be a string when provided`)},workflows:(e,t)=>{if(typeof t.type!="string")throw new TypeError(`${e}.type must be a string`);if(!Array.isArray(t.allowed_transitions))throw new TypeError(`${e}.allowed_transitions must be an array`);for(let[n,r]of t.allowed_transitions.entries())if(!Array.isArray(r))throw new TypeError(`${e}.allowed_transitions[${n}] must be a [from, to] array`)},templates:(e,t)=>{if(typeof t.name!="string")throw new TypeError(`${e}.name must be a string`);if(typeof t.options!="object"||t.options===null||Array.isArray(t.options))throw new TypeError(`${e}.options must be an object`)},packages:(e,t)=>{if(typeof t.spec!="string")throw new TypeError(`${e}.spec must be a string`)}};function Vu(e){let t=x("registerProfile profile",e);if($("registerProfile profile.name",t.name),$("registerProfile profile.title",t.title),t.summary!==void 0&&typeof t.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let n of Di){let r=t[n];if(r!==void 0){if(!Array.isArray(r))throw new TypeError(`registerProfile profile.${n} must be an array when provided`);for(let[o,i]of r.entries()){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError(`registerProfile profile.${n}[${o}] must be an object`);Bu[n]?.(`registerProfile profile.${n}[${o}]`,i)}}}}function Wu(e){e.summary===void 0&&(e.summary="");for(let t of Di)e[t]===void 0&&(e[t]=[]);return e}function Gu(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let n of e.capabilities){let r=n.trim().toLowerCase();X(r)&&t.add(r)}return t}function k(e,t,n){let r=Gu(e);if(r!==null&&!r.has(t))throw G(`${n} requires capability '${t}' in extension manifest capabilities`,{method:n,registration_index:-1,capability:t,missing_capability:t,expected_schema:`"capabilities": [..., "${t}"]`,received:e.capabilities,hint:`Add "${t}" to ${e.name} manifest capabilities, or remove the ${n} registration call.`})}function Ku(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>z.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function Hu(e){return{layer:e.layer,name:e.name,trusted:e.trusted===!0,provenanceVerified:e.provenance?.verified===!0,sandboxProfile:e.sandbox_profile,permissions:e.permissions&&typeof e.permissions=="object"?{fs_read:e.permissions.fs_read,fs_write:e.permissions.fs_write,network:e.permissions.network,env_read:e.permissions.env_read,env_write:e.permissions.env_write,process_spawn:e.permissions.process_spawn}:void 0}}var Jn=class{extension;hooks;#e;#n;#o;#r;#s;#a;#i;#c;#t;#l;#d;#u;constructor(t,n,r,o,i,s,a,c,l,d,u){this.#e=t,this.extension=Ku(t),this.#n=Hu(t),this.#o=n,this.#r=r,this.#s=o,this.#a=i,this.#i=s,this.#c=a,this.#t=c,this.#l=l,this.#d=d,this.#u=u,this.registerCommand=this.registerCommand.bind(this),this.registerParser=this.registerParser.bind(this),this.registerPreflight=this.registerPreflight.bind(this),this.registerService=this.registerService.bind(this),this.registerFlags=this.registerFlags.bind(this),this.registerItemFields=this.registerItemFields.bind(this),this.registerItemTypes=this.registerItemTypes.bind(this),this.registerRelationshipKinds=this.registerRelationshipKinds.bind(this),this.registerMigration=this.registerMigration.bind(this),this.registerProfile=this.registerProfile.bind(this),this.registerRenderer=this.registerRenderer.bind(this),this.registerImporter=this.registerImporter.bind(this),this.registerExporter=this.registerExporter.bind(this),this.registerSearchProvider=this.registerSearchProvider.bind(this),this.registerVectorStoreAdapter=this.registerVectorStoreAdapter.bind(this),this.registerAssuranceMeasurementProvider=this.registerAssuranceMeasurementProvider.bind(this),this.hooks={beforeCommand:m=>this.registerBeforeCommand(m),beforeMutation:m=>this.registerBeforeMutation(m),afterCommand:m=>this.registerAfterCommand(m),onWrite:m=>this.registerOnWrite(m),onRead:m=>this.registerOnRead(m),onIndex:m=>this.registerOnIndex(m)}}allowRegistration(t,n,r,o){let i=oi(this.#u,this.#n,t,n,r,o);return i.warning&&this.#l.push(i.warning),i.allowed}registerCommandTrace(t,n,r,o,i){return{method:"registerCommand",registration_index:t==="override"?this.#r.overrides.length:this.#r.handlers.length,command:n,expected_schema:r,received:Xe(o),hint:i}}registerCommandOverride(t,n){let r=S(t);if(r.length===0)throw G("registerCommand requires a non-empty command name",this.registerCommandTrace("override",t,'registerCommand("<command>", (context) => unknown)',t,"Provide a non-empty command path as the first argument."));if(typeof n!="function"){let o=this.registerCommandTrace("override",r,'registerCommand("<command>", (context) => unknown)',n,"Provide a function as the second registerCommand argument.");throw G(`registerCommand requires an override function when command name is provided (command="${r}", registration_index=${o.registration_index})`,o)}this.allowRegistration("commands.override","registerCommand","commands",{command:r})&&this.#r.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}resolveCommandDefinitionRunHandler(t,n){let r=typeof t.run=="function"?t.run:void 0,o=typeof t.handler=="function"?t.handler:void 0;return!r&&o&&this.#l.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${n}`),r??o}registerCommandDefinition(t){if(typeof t!="object"||t===null)throw G("registerCommand requires a command definition object",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,'Use registerCommand({ name: "command path", run: (context) => ... }).'));if(typeof t.name!="string")throw G("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,"Set command definition.name to a non-empty string command path."));let n=S(t.name);if(n.length===0)throw G("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",t.name,"{ name: string; run: (context) => unknown; }",t,"Ensure command definition.name contains a non-empty command path."));let r=this.resolveCommandDefinitionRunHandler(t,n);if(typeof r!="function"){let o=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; }",r,"Define command definition.run as a function.");throw G(`registerCommand requires a command definition run handler (command="${n}", registration_index=${o.registration_index})`,o)}try{zo(t);let o=Ti(n,t.action);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:n,action:o}))return;let i=t.description?.trim(),s=t.intent?.trim(),a=Ke("registerCommand definition.examples",t.examples),c=Ke("registerCommand definition.failure_hints",t.failure_hints),l=Ci(t.arguments);t.flags!==void 0&&(k(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(Xn(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Yn("registerCommand definition.flags",t.flags)})));let d={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:o,examples:a,failure_hints:c,arguments:l,tier:t.tier??"standard",family:t.family??"extensions"};i&&(d.description=i),s&&(d.intent=s),this.#t.commands.push(d)}catch(o){let i=Dt(o),s=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=G(`registerCommand definition metadata invalid (command="${n}", registration_index=${s.registration_index}): ${i}`,s);this.#l.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${n}`),this.#d.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}registerCommand(t,n){if(k(this.#e,"commands","registerCommand"),typeof t=="string"){this.registerCommandOverride(t,n);return}this.registerCommandDefinition(t)}registerParser(t,n){if(k(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let r=S($("registerParser command",t));Ze("registerParser override",n),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}registerPreflight(t){if(k(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let n=Lo(t);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...n})}registerService(t,n,r={}){k(this.#e,"services","registerService");let o=String(t).trim().toLowerCase();if(!si(o))throw new TypeError(`registerService service must be one of: ${Ee.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(Ze("registerService override",n),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:n,...Fo(r)?{passThrough:!0}:{}}))}registerRenderer(t,n,r={}){if(k(this.#e,"renderers","registerRenderer"),!this.allowRegistration("renderers.override","registerRenderer","renderers"))return;if(typeof n!="function")throw new TypeError("registerRenderer requires a renderer function");let o=String(t).trim().toLowerCase();if(!ii(o))throw new Error(`registerRenderer format must be toon|json, received: ${String(t)}`);if(r.resultDiscriminator!==void 0&&typeof r.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");let i=[...new Set((r.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return S(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:o,run:n,commands:i,...r.resultDiscriminator?{resultDiscriminator:r.resultDiscriminator}:{}})}registerFlags(t,n){if(k(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let r=S($("registerFlags targetCommand",t));Xn(n);let o=Yn("registerFlags flags",n);if(o.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:o})}registerItemFields(t){if(k(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;ju(t);let n=xt("registerItemFields fields",t);if(n.length===0)throw new TypeError("registerItemFields requires at least one field definition");this.#t.item_fields.push({layer:this.#e.layer,name:this.#e.name,fields:n})}registerItemTypes(t){if(k(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;zu(t);let n=xt("registerItemTypes types",t);if(n.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#t.item_types.push({layer:this.#e.layer,name:this.#e.name,types:n})}registerRelationshipKinds(t){if(k(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(t))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(t.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");let n=an();for(let o of this.#t.relationship_kinds)for(let i of o.definitions)n.register(i);let r=t.map(o=>(n.register(o),n.require(o.kind)));this.#t.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:r})}registerMigration(t){if(k(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;qu(t);let n=Qe("registerMigration definition",t);this.#t.migrations.push(et({layer:this.#e.layer,name:this.#e.name,definition:Te("registerMigration definition",t)},n))}registerProfile(t){if(k(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let n=Je(t);Vu(n),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:Wu(n)})}registerImportExportCommandFlags(t,n,r){r.flags!==void 0&&(k(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(Xn(r.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Yn(`${t} options.flags`,r.flags)})))}applyImportExportCommandMetadata(t,n,r){if(r!==void 0&&(typeof r!="object"||r===null||Array.isArray(r)))throw new TypeError(`${t} options must be an object when provided`);let o=`${t==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,i=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...r,description:r?.description??o,arguments:r?.arguments??i},a=qo(t,s,r?.description!==void 0);A(`${t} options.action`,s.action),A(`${t} options.description`,s.description),A(`${t} options.intent`,s.intent);let c=Ti(n,s.action),l=Ke(`${t} options.examples`,s.examples),d=Ke(`${t} options.failure_hints`,s.failure_hints),u=Ci(s.arguments);this.registerImportExportCommandFlags(t,n,s);let m={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:c,examples:l,failure_hints:d,arguments:u},f=s.description?.trim();f&&(m.description=f);let p=s.intent?.trim();return p&&(m.intent=p),this.#t.commands.push(m),a}registerImporter(t,n,r){if(k(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=Ln($("registerImporter name",t));Ze("registerImporter importer",n);let i=jn(o,"import");this.applyImportExportCommandMetadata("registerImporter",i,r),this.#t.importers.push({layer:this.#e.layer,name:this.#e.name,importer:o}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>n(Tn(s,o,"import"))})}registerExporter(t,n,r){if(k(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=Ln($("registerExporter name",t));Ze("registerExporter exporter",n);let i=jn(o,"export"),s=this.applyImportExportCommandMetadata("registerExporter",i,r);this.#t.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:o,...s===void 0?{}:{output:s}}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async a=>{let c=await n(Tn(a,o,"export"));return s?.receipt==="suppress"&&!wn(c)?lo(c):c}})}registerSearchProvider(t){if(k(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let n=Qe("registerSearchProvider provider",t);this.#t.search_providers.push(et({layer:this.#e.layer,name:this.#e.name,definition:Te("registerSearchProvider provider",t)},n))}registerVectorStoreAdapter(t){if(k(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let n=Qe("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(et({layer:this.#e.layer,name:this.#e.name,definition:Te("registerVectorStoreAdapter adapter",t)},n))}registerAssuranceMeasurementProvider(t){if(k(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(di(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let n=Qe("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(et({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:Te("registerAssuranceMeasurementProvider provider",t)},n))}registerBeforeCommand(t){k(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(_e("beforeCommand",t),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerBeforeMutation(t){k(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(_e("beforeMutation",t),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerAfterCommand(t){k(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(_e("afterCommand",t),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnWrite(t){k(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(_e("onWrite",t),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnRead(t){k(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(_e("onRead",t),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnIndex(t){k(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(_e("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function Yu(e,t,n,r,o,i,s,a,c,l,d){return new Jn(e,t,n,r,o,i,s,a,c,l,d)}function Xu(e){let t=e.commands.length,n=e.flags.reduce((s,a)=>s+a.flags.length,0),r=e.item_fields.reduce((s,a)=>s+a.fields.length,0),o=e.item_types.reduce((s,a)=>s+a.types.length,0),i=(e.relationship_kinds??[]).reduce((s,a)=>s+a.definitions.length,0);return{commands:t,flags:n,item_fields:r,item_types:o,...i>0?{relationship_kinds:i}:{},migrations:e.migrations.length,profiles:e.profiles.length,importers:e.importers.length,exporters:e.exporters.length,search_providers:e.search_providers.length,vector_store_adapters:e.vector_store_adapters.length,...(e.assurance_providers?.length??0)>0?{assurance_providers:e.assurance_providers.length}:{}}}function Ju(e){let t=[],n=(i,s)=>{let a=new Map;for(let c of i){let l=a.get(c.command)??[];l.push(c),a.set(c.command,l)}for(let c of[...a.keys()].sort((l,d)=>l.localeCompare(d))){let l=a.get(c);if(l.length<=1)continue;let d=l[l.length-1];for(let u of l.slice(0,-1))t.push(`${s}:${c}:${d.layer}:${d.name}:${u.layer}:${u.name}`)}};n(e.handlers,"extension_command_handler_collision"),n(e.overrides,"extension_command_override_collision");let r=new Set(e.handlers.map(i=>i.command)),o=[...new Set(e.overrides.map(i=>i.command))].filter(i=>r.has(i));o.sort((i,s)=>i.localeCompare(s));for(let i of o){let s=e.handlers.filter(c=>c.command===i),a=e.overrides.filter(c=>c.command===i);for(let c of a)for(let l of s)t.push(`extension_command_override_handler_overlap:${i}:${c.layer}:${c.name}:${l.layer}:${l.name}`)}return t}function Qu(e){let t=new Map;for(let r of e.overrides){let o=t.get(r.format)??[];o.push(r),t.set(r.format,o)}let n=[];for(let r of[...t.keys()].sort((o,i)=>o.localeCompare(i))){let o=t.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))i.commands?.length&&s.commands?.length&&!s.commands.some(a=>i.commands?.includes(a))||n.push(`extension_renderer_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return n}function Zu(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.command)??[];o.push(r),n.set(r.command,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_parser_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}var ef=new Set(["output_format"]);function tf(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.service)??[];o.push(r),n.set(r.service,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1||ef.has(r))continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_service_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}async function Ib(e){let t=ei(e.policy??iu),n=Rt(),r=xn(),o=Nn(),i=Dn(),s=Mn(),a=Pn(),c=$n(),l=[],d=[];for(let f of e.loaded){let p=Ni(f.module);if(!p)continue;let _=l.length,g=$o({hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await p.activate(Yu(f,n,r,o,i,s,a,c,d,l,t)),l.length>_&&(g(),d.push(`extension_activation_rolled_back:${f.layer}:${f.name}`))}catch(w){g(),d.push(`extension_activate_failed:${f.layer}:${f.name}`);let v=ci(w);l.push({layer:f.layer,name:f.name,entry_path:f.entry_path,error:Dt(w),trace:v})}}let u=[...Ju(r),...Zu(o),...jo(i),...tf(s),...Qu(a)],m=[...new Set([...d,...u])];return{hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c,failed:l,warnings:m,hook_counts:{before_command:n.beforeCommand.length,before_mutation:n.beforeMutation.length,after_command:n.afterCommand.length,on_write:n.onWrite.length,on_read:n.onRead.length,on_index:n.onIndex.length},command_override_count:r.overrides.length,command_handler_count:r.handlers.length,parser_override_count:o.overrides.length,preflight_override_count:i.overrides.length,service_override_count:s.overrides.length,renderer_override_count:a.overrides.length,registration_counts:Xu(c)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b2cf7f56-432d-5c74-ba0f-248c42a97255")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="07566a0b-2917-5ed8-828a-d811ae48dfaf")}catch{}})();function Mb(){let e=Promise.resolve(),t=new Set;return{async read(n){let r=e,o,i=new Promise(s=>{o=s});t.add(i),await r;try{return await n()}finally{t.delete(i),o()}},write(n){let o=Promise.all([e,...t]).then(()=>n());return e=o.then(()=>{},()=>{}),o}}}function nf(){let e=Promise.resolve(),t=0,n=[],r=()=>{if(t!==0)return;let o=n.splice(0);for(let i of o)i()};return{enqueue(o){t++;let i=e.then(()=>o());return e=i.then(()=>{},()=>{}).finally(()=>{t--,r()}),i},idle(){return t===0?Promise.resolve():new Promise(o=>n.push(o))}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0989270e-6969-5059-b3df-06411211f701")}catch{}})();var Ce=null,Pi=null,sf=null,af=null,Qn=null,cf=null,$i=null,lf=null;var df=[],Li=new of;function C(){return Li.getStore()}function Ub(e){return Li.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var uf=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function Mi(e){let t=K.resolve(e);for(;;){if(rf(K.join(t,".git")))return t;let n=K.dirname(t);if(n===t)return;t=n}}function ff(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),n=Mi(t)??K.resolve(t),r=Mi(n);if(!e)return{source_workspace_root:n,...r?{repo_root:r}:{}};let o=K.relative(n,K.resolve(e)),i=o.length>0&&!o.startsWith(`..${K.sep}`)&&o!==".."&&!K.isAbsolute(o);return{source_workspace_root:n,...r?{repo_root:r}:{},...i?{pm_root_rel:o.split(K.sep).join("/")}:{}}}function zb(e){let t=C();if(t){t.hooks=e;return}Ce=e}function qb(e){let t=C();if(t){t.commands=e;return}Pi=e}function Bb(e){let t=C();if(t){t.parsers=e;return}sf=e}function Vb(e){let t=C();if(t){t.preflight=e;return}af=e}function Wb(e){let t=C();if(t){t.services=e;return}Qn=e}function Gb(e){let t=C();if(t){t.renderers=e;return}cf=e}function Kb(e){let t=C();if(t){t.registrations=e;return}$i=e}function Hb(){let e=C();return e?e.registrations:$i}function Yb(e){if(!e)return;let t=C();t?t.affectedItems.push(e):df.push(e)}function Xb(e,t){if(!e||!e.id)return{};let n={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return n;let r=e;for(let o of t){if(typeof o!="string")continue;let i=o.startsWith("unset:")?o.slice(6):o;i==="id"||i==="type"||i==="status"||uf.has(i)||Object.hasOwn(r,i)&&r[i]!==void 0&&(n[i]=r[i])}return n}async function ji(e){let t=C(),n=t?t.hooks:Ce;return n?zn(n,e):[]}async function Jb(e){let t=C(),n=t?t.hooks:Ce;n&&await Un(n,e)}async function Fi(e){let t=C(),n=t?t.hooks:Ce;return n?qn(n,e):[]}function Qb(){let e=C();return((e?e.hooks:Ce)?.onRead?.length??0)>0}async function Zb(e){let t=C(),n=t?t.hooks:Ce;return n?Bn(n,e):[]}async function ew(e){let t=C(),n=t?t.commands:Pi;return n?Vn(n,{...e,...ff(e.pm_root)}):{handled:!1,result:null,warnings:[]}}function Ui(e,t){let n=C(),r=n?n.commandContext:lf;return{service:e,command:r?.command,args:r?[...r.args]:[],options:r?.options?{...r.options}:{},global:r?.global?{...r.global}:void 0,pm_root:r?.pm_root,source_workspace_root:r?.source_workspace_root,repo_root:r?.repo_root,pm_root_rel:r?.pm_root_rel,payload:t}}async function Mt(e,t){let n=C(),r=n?n.services:Qn;return r?Gn(r,Ui(e,t)):{handled:!1,result:t,warnings:[]}}function zi(e,t){let n=C(),r=n?n.services:Qn;return r?Wn(r,Ui(e,t)):{handled:!1,result:t,warnings:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3d2360c6-41c1-5527-a53c-38d0590e3f04")}catch{}})();var Pt="changed_fields",mf="changed_field_count",Zn="rows",pf=new Set(["apply","rollback"]),Vi=new Set(["deleted","would_delete"]),qi=256;function Bi(e){return typeof e!="string"||e.length<=qi?e:`${e.slice(0,qi-1)}\u2026`}function _f(e){if(!B(e))return null;let t={...e};return t.reason=Bi(t.reason),B(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,Bi(r)]))),t}function B(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Wi(e){let t=e[Pt];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==Pt&&(n[r]=o);return n[mf]=t.length,n}function gf(e){return"item"in e&&Array.isArray(e[Pt])}function yf(e){return typeof e.mode=="string"&&pf.has(e.mode)&&Array.isArray(e[Zn])}function hf(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[Zn]=t,n}function bf(e){if(!B(e))return null;let t=B(e.item)?e.item:B(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"&&Vi.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 wf(e){if(!B(e)||!B(e.item)||typeof e.item.id!="string")return null;let t=e[Pt];if(!Array.isArray(t))return null;let n={id:e.item.id,...typeof e.outcome=="string"&&Vi.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:t.length};return vf(e,e.item,n),n}function vf(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=_f(e.recurrence);if(o!==null&&(n.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(n.warnings=e.warnings),B(e.recovery)&&(n.recovery=e.recovery),typeof e.claimed_by=="string")for(let i of["claimed_by","previous_assignee","forced","skipped","available","attempts"])Object.hasOwn(e,i)&&(n[i]=e[i])}function Ef(e){let t=yf(e)?e[Zn]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!B(o))return o;let i=Wi(o);return i?(n=!0,i):o});return n?{projected:hf(e,r),changed:!0}:{projected:e,changed:!1}}function kf(e,t={}){if(t.idOnly===!0){let a=bf(e);if(a!==null)return a}if(t.compactEnvelope===!0){let a=wf(e);if(a!==null)return a}if((t.changedFields??"full")==="full"||!B(e))return e;let r=!1,o=e,i=gf(e)?Wi(e):null;i!==null&&(o=i,r=!0);let s=Ef(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{AsyncLocalStorage as Km}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b18eefc1-0d1d-5c9c-b98a-b96771070301")}catch{}})();var Gi=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),Of=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function Sf(e){let t=e.indexOf("=");return t>0&&Gi.has(e.slice(0,t))}function Af(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function Ki(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(Gi.has(n)){t+=Af(n,e[t+1])?1:0;continue}if(!(Sf(n)||Of.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function aw(e){let t=Ki(e);return t===void 0?void 0:e[t].trim().toLowerCase()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4ed3e8a4-97a1-5082-afd3-5942d47bc054")}catch{}})();var Tf=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)}"`},Cf=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?Tf(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,er=(e,t=process.platform)=>{let n=e.map(r=>Cf(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]="6c87b004-3647-531a-9599-d37fd91c2807")}catch{}})();var Ji=new WeakMap;function mw(e,t){Ji.set(e,new Set(t))}var Hi='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',If={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"],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"}},Rf=[{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 pw(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,y.USAGE)}function V(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 _w(e,t){let n=Rf.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return V([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return V(r)}var xf=[{name:"hierarchy",restore_with:"--depth standard"},{name:"activity",restore_with:"--depth standard"},{name:"progress",restore_with:"--depth standard"},{name:"blockers",restore_with:"--depth standard"},{name:"recently_created",restore_with:"--depth standard"},{name:"unparented",restore_with:"--depth standard"},{name:"files",restore_with:"--depth deep"},{name:"workload",restore_with:"--depth standard"},{name:"staleness",restore_with:"--depth deep"},{name:"tests",restore_with:"--depth deep"},{name:"workspace_memory",restore_with:"--depth deep"}];function L(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Nf=new Set([void 0,"tabular_when_uniform"]),Df=new Set(["collection","none"]),Mf=new Set(["supported","unsupported"]);function Yi(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 Pf(e){return L(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Df.has(e.row_kind)&&Yi(e.row_keys,!0)&&(e.continuation_row_keys===void 0||Yi(e.continuation_row_keys,!1))&&Mf.has(e.fields)&&Nf.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 $f={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"]},Lf={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"],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 jf(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=$f[s];if(a===void 0)return;let c=a.filter(l=>Array.isArray(t[l])||L(t[l]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Hi}:{},toon_encoding:"tabular_when_uniform"}}let o=If[r],i=Lf[r];return o===void 0||i===void 0||!i.some(s=>Object.hasOwn(t,s))?void 0:(()=>{let s=o.row_keys.filter(a=>{let c=a.split(".").reduce((l,d)=>L(l)?l[d]: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:Hi}:{},toon_encoding:"tabular_when_uniform"}})()}function Ff(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 V(r,new Set(o))}function Uf(e){if(!Array.isArray(e.sections_included))return;let t=V(xf,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 zf(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=Ji.get(e),i=a=>n.includes(a)||a==="body"?t:e,s=["body",...n,...r.slice(1)].filter(a=>o===void 0||o.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:`--fields ${a}`}));return V(s,new Set(s.flatMap(({name:a})=>Object.hasOwn(i(a),a)?[a]:[])))}function Xi(e){if(L(e.projection))return V([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function qf(e){if(!L(e.projection))return V([]);if(typeof e.projection.mode=="string")return V([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function Bf(e){if(!(!L(e.selected)||typeof e.selected.summary!="boolean"))return V([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function Vf(e,t){let n=Ff(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return Uf(t);if(r==="get")return zf(t);if(r==="list"||r.startsWith("list-"))return Xi(t);if(r==="search")return Xi(t)??V([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return qf(t);if(r==="contracts")return Bf(t)}function Qi(e,t){if(e===void 0||!L(t))return t;let n=Vf(e,t),r=t.row_contract,o=Pf(r)?r:jf(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}}import{randomUUID as Lm}from"node:crypto";import{randomUUID as Dm}from"node:crypto";import{constants as Re}from"node:fs";import{lstat as Es,mkdir as Mm,open as Os,rename as Pm,rm as $m}from"node:fs/promises";import Ft from"node:path";import{constants as fm}from"node:fs";import F from"node:fs/promises";import jt from"node:path";import{randomUUID as or}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="43f7bd27-7874-56f9-a497-e6f67a3ae9be")}catch{}})();function Zi(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import Wf from"node:crypto";import{AsyncLocalStorage as Gf}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="38ed5847-939e-5846-bc7d-6d257d36a25f")}catch{}})();var ts=new Gf,es=1024;function ns(){let e=ts.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 ww(e){let t=ts.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>es)throw new Error(`Reproducible token length must be an integer between 0 and ${es}`);let n="";for(;n.length<e;){let r=Wf.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]="a5bd8db9-cd23-5529-ad78-b7e87bd43b59")}catch{}})();var Kf=/^([+-]?)(\d+)([hdwm])$/i,Hf=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,Yf=/^(\d{4})(\d{2})(\d{2})$/,Xf=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Jf=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Qf=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Zf=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function os(){return ns()??new Date().toISOString()}function Aw(e){return Number.isFinite(Date.parse(e))}function em(e){let t=Zf.exec(e);if(!t||!Number.isFinite(Date.parse(e)))return!1;let[,n,r,o,i,s,a,c,l]=t,[d,u,m,f,p,_]=[n,r,o,i,s,a].map(Number);return u>=1&&u<=12&&m>=1&&m<=rr(d,u-1)&&f<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(l===void 0||Number(l)<=59)}function Tw(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return em(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var tm=1e4,$t=new Map;function rs(e){let t=$t.get(e);if(t!==void 0)return t;let n=Date.parse(e);return $t.size>=tm&&Zi($t),$t.set(e,n),n}function Ie(e,t){let n=rs(e),r=rs(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function Cw(e,t){return!(t.deadlineBefore&&(!e.deadline||Ie(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||Ie(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&Ie(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&Ie(e.updated_at,t.updatedBefore)>0||t.createdAfter&&Ie(e.created_at,t.createdAfter)<0||t.createdBefore&&Ie(e.created_at,t.createdBefore)>0)}function tr(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function nr(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 nm(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function rm(e){let t=[],n=l=>nm(t,e,l),r=Yf.exec(e);if(r){let[,l,d,u]=r;n(`${l}-${d}-${u}`)}let o=Xf.exec(e);if(o){let[,l,d,u,m,f,p,_,g]=o,w=p?`:${p}`:"";n(`${l}-${d}-${u}T${m}:${f}${w}${tr(_)}${nr(g)}`)}let i=Jf.exec(e);if(i){let[,l,d,u,m,f,p]=i,_=m?`:${m}`:"";n(`${l}T${d}:${u}${_}${tr(f)}${nr(p)}`)}let s=Qf.exec(e);if(s){let[,l,d,u,m,f,p]=s,_=m?`:${m}`:"";n(`${l}T${d}:${u}${_}${tr(f)}${nr(p)}`)}let a=10,c=e.slice(0,a);if(im(c)){let l=a;for(;l<e.length&&sm(e[l]);)l+=1;l<e.length&&n(`${c}T${e.slice(l)}`)}return t}function om(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of rm(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function im(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 sm(e){return e?e===" "||e===" "||e===`
9
- `||e==="\r"||e==="\f"||e==="\v":!1}function rr(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var am=["January","February","March","April","May","June","July","August","September","October","November","December"],cm=/^(\d{4})-(\d{2})-(\d{2})/,lm=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function dm(e,t,n){let r=cm.exec(t)??lm.exec(t);if(!r)return;let o=Number.parseInt(r[1],10),i=Number.parseInt(r[2],10),s=Number.parseInt(r[3],10),a=n?.trim()||"deadline";if(i<1||i>12)throw new h(`Invalid ${a} value "${e}". Month "${r[2]}" is out of range \u2014 use a month between 01 and 12.`,y.USAGE);let c=rr(o,i-1);if(s<1||s>c)throw new h(`Invalid ${a} value "${e}". ${am[i-1]} ${o} has ${c} days, so day "${r[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,y.USAGE)}function um(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,rr(i,s));return n.setUTCFullYear(i,s,a),n}function Iw(e,t=new Date,n="deadline"){let r=e.trim();if(r.toLowerCase()==="now")return t.toISOString();let o=Kf.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 um(t,a).toISOString();let l=c==="h"?3600*1e3:c==="d"?1440*60*1e3:10080*60*1e3;return new Date(t.getTime()+a*l).toISOString()}dm(e,r,n);let i=om(r);if(!Number.isFinite(i)){let s=n.trim().length>0?n.trim():"deadline",a=Hf.test(r)?"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.":'Use ISO/date string input, "now", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';throw new h(`Invalid ${s} value "${e}". ${a}`,y.USAGE)}return new Date(i).toISOString()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="962659bb-37dc-52fa-9d07-6216d34c0d53")}catch{}})();function mm(e){let t;try{t=JSON.parse(e)}catch{return{info:null,warnings:["lock_info_invalid_json"]}}if(typeof t!="object"||t===null||Array.isArray(t))return{info:null,warnings:["lock_info_invalid_shape"]};let n=t,r=n.id,o=n.pid,i=n.owner,s=n.token,a=n.created_at,c=n.ttl_seconds;return typeof r!="string"||typeof o!="number"||!Number.isFinite(o)||typeof i!="string"||s!==void 0&&(typeof s!="string"||s.trim().length===0)||typeof a!="string"||typeof c!="number"||!Number.isFinite(c)?{info:null,warnings:["lock_info_invalid_shape"]}:{info:{id:r,pid:o,owner:i,...typeof s=="string"?{token:s}:{},created_at:a,ttl_seconds:c},warnings:[]}}async function Lt(e,t=!0){try{let n=await F.readFile(e,"utf8");return t&&await Fi({path:e,scope:"project"}),mm(n)}catch(n){return fe(n)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function H(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function pm(e,t,n=process.platform){if(H(e,"EEXIST"))return!0;if(!H(e,"EPERM")&&!H(e,"EACCES")&&!H(e,"EBUSY"))return!1;try{return await F.lstat(t),!0}catch(r){if(n!=="win32"||!fe(r)&&!H(r,"EPERM")&&!H(r,"EACCES")&&!H(r,"EBUSY"))return!1}try{return await F.access(jt.dirname(t),fm.W_OK),!0}catch{return!1}}async function ds(e,t){await ji({path:e,scope:"project",op:t})}function _m(e,t,n,r=or()){return{id:e,pid:process.pid,owner:t,token:r,created_at:os(),ttl_seconds:n}}async function gm(e,t,n,r,o){await F.mkdir(jt.dirname(e),{recursive:!0});let i=await F.open(e,"wx");try{await i.writeFile(`${JSON.stringify(_m(t,n,r,o),null,2)}
10
- `,"utf8")}finally{await i.close()}await ds(e,"lock:create")}async function us(e,t){try{return await F.unlink(e),await ds(e,t),!0}catch{return!1}}async function ym(e,t,n,r){let o=Date.now(),i=ms;for(;;){let s=await ws(e,t);if(s!==null){try{let l=await Lt(e,!1);is(l.info,t,n,r)&&await us(e,"lock:release")}finally{await s()}return}let a=await Lt(e,!1);if(!is(a.info,t,n,r))return;let c=Date.now()-o;if(c>=ss)return;await gs(Math.min(i,ss-c)),i=Math.min(i*2,ir)}}function is(e,t,n,r){return e?.id===t&&e.pid===process.pid&&e.owner===n&&e.token===r}function fs(e,t){let n=e?.created_at?Date.parse(e.created_at):Number.NaN;return(Number.isFinite(n)?Date.now()-n:Number.POSITIVE_INFINITY)>t*1e3}function hm(e){return e?.owner?` (owner ${e.owner})`:""}var ms=25,ir=200,bm=250,wm=3,vm=".stale-cleanup",ps="owner.json",_s=1e4,ss=_s+ir,Em=60*6e4;function as(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 km(e){let t=process.env.PM_LOCK_WAIT_MS,n=as(t);if(n!==void 0)return n;let r=as(e);return r!==void 0?r:0}function gs(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(n=>setTimeout(n,t))}function ys(e,t,n){let r=n>0?` after waiting ${n}ms`:"";return new h(`Item ${e} is locked${hm(t)}${r}`,y.CONFLICT,{code:"lock_conflict",recovery:{retry_after_ms:bm}})}function Om(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 Sm(e,t,n,r){if(!n&&r){let o=t.warnings.length>0?` (${t.warnings.join(",")})`:"";throw new h(`Item ${e} lock is stale${o}; rerun with --force when supported for this command`,y.CONFLICT)}}function Am(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null||Array.isArray(t))return null;let n=t,r=n.pid,o=n.token,i=n.process_start_identity;return typeof r!="number"||!Number.isInteger(r)||r<=0||typeof o!="string"||o.length===0||i!==void 0&&(typeof i!="string"||!/^\d+$/u.test(i))?null:{pid:r,token:o,...typeof i=="string"?{process_start_identity:i}:{}}}async function hs(e){try{return Am(await F.readFile(jt.join(e,ps),"utf8"))}catch{return null}}function Tm(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!H(t,"ESRCH")}}function Cm(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 bs(e){try{return Cm(await F.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function Im(e=process.pid){let t=await bs(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function Rm(e,t,n){if(!Tm(e.pid))return!1;let r=await bs(e.pid);return e.process_start_identity!==void 0&&r!==null?r===e.process_start_identity:t<=n}async function sr(e){try{return await F.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function cs(e,t){let n=await hs(e);n===null||n.token!==t||await sr(e)}async function ls(e){try{await F.mkdir(e)}catch(n){return H(n,"EEXIST"),null}let t={...await Im(),token:or()};try{await F.writeFile(jt.join(e,ps),`${JSON.stringify(t)}
11
- `,"utf8")}catch{return await sr(e),null}return t}async function xm(e){let t;try{let r=await F.stat(e);if(t=Date.now()-r.mtimeMs,t<=_s)return!1}catch(r){return fe(r)}let n=await hs(e);return n!==null&&await Rm(n,t,Em)?!1:sr(e)}async function ws(e,t){let n=`${e}${vm}`,r=await ls(n);if(r!==null)return async()=>cs(n,r.token);if(!await xm(n))return null;let o=await ls(n);return o===null?null:async()=>cs(n,o.token)}async function Nm(e){let t=await ws(e.lockPath,e.id);if(t===null)return{lockInfo:e.fallbackLockInfo,shouldRetryCreate:!1,staleRemovalCounted:!1};try{let n=await Lt(e.lockPath);if(n.info===null&&n.warnings.length===0)return{lockInfo:n,shouldRetryCreate:!0,staleRemovalCounted:!1};if(!fs(n.info,e.ttlSeconds))return{lockInfo:n,shouldRetryCreate:!1,staleRemovalCounted:!1};if(Sm(e.id,n,e.force,e.forceRequiredForStaleLock),e.staleRemovals>=wm)throw ys(e.id,n.info,Date.now()-e.startedAtMs);return{lockInfo:n,shouldRetryCreate:await us(e.lockPath,"lock:stale_remove"),staleRemovalCounted:!0}}finally{await t()}}async function vs(e,t,n,r,o=!1,i=!0,s){let a=await Mt("lock_acquire",{pm_root:e,id:t,ttl_seconds:n,owner:r,force:o,force_required_for_stale_lock:i});if(a.handled){let p=Om(a.result);if(p)return async()=>{await Promise.resolve(p()),await Mt("lock_release",{pm_root:e,id:t,owner:r})}}let c=ko(e,t),l=km(s),d=Date.now(),u=0,m=ms,f=or();for(;;)try{return await gm(c,t,r,n,f),async()=>{await ym(c,t,r,f),await Mt("lock_release",{pm_root:e,id:t,owner:r})}}catch(p){if(!await pm(p,c))throw new h(`Failed to acquire lock for ${t}: ${So(p)}`,y.GENERIC_FAILURE);let _=await Lt(c);if(fs(_.info,n)){let w=await Nm({lockPath:c,id:t,ttlSeconds:n,force:o,forceRequiredForStaleLock:i,staleRemovals:u,waitBudgetMs:l,startedAtMs:d,fallbackLockInfo:_});if(_=w.lockInfo,w.staleRemovalCounted&&(u+=1),w.shouldRetryCreate)continue}let g=Date.now()-d;if(l===0||g>=l)throw ys(t,_.info,l===0?0:g);await gs(Math.min(m,l-g)),m=Math.min(m*2,ir)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="72eb01a9-e8b8-59cd-b178-3c594d3faff9")}catch{}})();var Y={max_serving_rows:256,max_bytes:262144,max_event_bytes:32768,retained_byte_fraction:.5,max_events:2048,retention_days:30},I=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function be(e){let t=Date.parse(e.now??new Date().toISOString());if(!Number.isFinite(t))throw new I("Context usage now must be a valid timestamp");return{iso:new Date(t).toISOString(),ms:t}}function Ss(e){let t=e.maxBytes??Y.max_bytes,n=e.maxEvents??Y.max_events,r=e.retentionDays??Y.retention_days;if(!Number.isSafeInteger(t)||t<1024||t>Y.max_bytes||!Number.isSafeInteger(n)||n<1||!Number.isFinite(r)||r<=0)throw new I("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");return{maxBytes:t,maxEvents:n,cutoff:be(e).ms-r*864e5}}async function As(e,t){if(!(await Es(Ft.dirname(e))).isDirectory())throw new I("Context usage runtime must be a real directory");try{if((await Es(e)).isSymbolicLink())throw new I("Context usage ledger must not be a symbolic link")}catch(r){if(!fe(r))throw r}let n=await Os(e,t|Re.O_NOFOLLOW|Re.O_NONBLOCK,384);try{let r=await n.stat();if(!r.isFile()||r.nlink!==1)throw new I("Context usage ledger must be an unshared regular file");return n}catch(r){throw await n.close(),r}}async function Ut(e){let t=Ss(e);try{let n=await As(Ft.join(e.pmRoot,"runtime","context-usage.jsonl"),Re.O_RDONLY);try{let r=(await n.stat()).size,o=Math.max(0,r-t.maxBytes),i=Buffer.alloc(Math.min(r,t.maxBytes)),{bytesRead:s}=await n.read(i,0,i.length,o),a=i.subarray(0,s).toString("utf8");return(o>0?a.includes(`
7
+ Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,f=eo(t).trim()||"Inspect the diagnostic code and retry with corrected input.",p=Math.max(1,s*4-Buffer.byteLength(`${d}${m}`,"utf8")),_=l?`${d}${le(f,p)}${m}`:a;return{output:_,diagnostic_output:{diagnostic_class:r,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:de(Buffer.byteLength(_,"utf8")),truncated:l,degradation_steps:l?[...o.degradation_ladder]:["full"],omitted_fields:l?["explanation","collections"]:[]}}}import{createHash as m_}from"node:crypto";import{existsSync as lf}from"node:fs";import{AsyncLocalStorage as df}from"node:async_hooks";import K from"node:path";import he from"node:fs/promises";import ye from"node:path";import{pathToFileURL as cu}from"node:url";import*as T from"node:fs/promises";import At from"node:path";import vl from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1240aa49-b3fa-57d3-b6e1-7f911005a757")}catch{}})();var El=[10,25,50,100];async function so(e){await T.mkdir(e,{recursive:!0})}async function hn(e){try{return await T.access(e),!0}catch{return!1}}function ao(e){return fe(e)||ue(e,"ENOTDIR")}function fe(e){return ue(e,"ENOENT")}async function fy(e){try{return await T.readFile(e,"utf8")}catch(t){if(ao(t))return null;throw t}}async function my(e,t){let n=At.dirname(e);await so(n);let r=At.join(n,`.${At.basename(e)}.${process.pid}.${Date.now()}.${vl.randomBytes(4).toString("hex")}.tmp`);await T.writeFile(r,t,"utf8");try{await T.rename(r,e)}catch(o){if(process.platform==="win32"&&(ue(o,"EPERM")||ue(o,"EBUSY"))){let i=o;for(let s of El){await new Promise(a=>setTimeout(a,s));try{await T.rename(r,e);return}catch(a){if(i=a,!ue(a,"EPERM")&&!ue(a,"EBUSY"))break}}try{await T.unlink(r)}catch{}throw i}if(ue(o,"EXDEV")){try{await T.copyFile(r,e)}finally{try{await T.unlink(r)}catch{}}return}try{await T.unlink(r)}catch{}throw o}}async function py(e,t){let n=At.dirname(e);await so(n);let r=await T.open(e,"a");try{await r.writeFile(`${t}
8
+ `,"utf8")}finally{await r.close()}}async function _y(e){try{await T.unlink(e)}catch(t){if(!ao(t))throw t}}function ue(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}import co from"path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="83a29a06-1b0b-52e6-9617-2fc03861cb18")}catch{}})();function bn(e,t){let n=co.relative(e,t);return n.length===0?!0:!n.startsWith("..")&&!co.isAbsolute(n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="de5f8d66-b9dc-555c-a52f-33b1b5368be3")}catch{}})();var kl="__pm_suppress_host_output",wn="@unbrained/pm-cli:suppress-host-output:v1";function lo(e){return e===void 0?{__pm_suppress_host_output:wn}:{__pm_suppress_host_output:wn,result:e}}function vn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[kl]===wn}import Oe from"node:fs";import Q from"node:path";import{fileURLToPath as Ol}from"node:url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dc77f588-e4ea-59fc-908f-51b41114430a")}catch{}})();var Sl="@unbrained/pm-cli";function Al(e){try{return JSON.parse(Oe.readFileSync(e,"utf8")).name===Sl}catch{return!1}}function Tl(e){let t=Oe.existsSync(e)&&Oe.statSync(e).isDirectory()?Q.resolve(e):Q.dirname(Q.resolve(e));for(;;){let n=Q.join(t,"package.json");if(Oe.existsSync(n)&&Al(n))return t;let r=Q.dirname(t);if(r===t)return;t=r}}function En(e,t=[]){let n=Ol(e),r=Tl(n);return r||Q.resolve(Q.dirname(n),...t)}function ky(e,t=[]){try{let n=Q.join(En(e,t),"package.json");if(!Oe.existsSync(n))return;let r=JSON.parse(Oe.readFileSync(n,"utf8"));return typeof r.version=="string"&&r.version.trim().length>0?r.version:void 0}catch{return}}import{readFileSync as md,readdirSync as jy,statSync as pd}from"node:fs";import _d from"node:os";import O from"node:path";import Nl from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0ca7f52c-fb31-5cd9-b689-a918f4e61816")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7647d826-e562-5f8e-86b2-2e40d8714b4d")}catch{}})();function Z(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Cl(e){let t=e.key.trim();if(t.length===0)return null;let n=Z(e.aliases),r=e.description?.trim();return{key:t,values:Z(e.values),required:e.required===!0?!0:void 0,aliases:n.length>0?n:void 0,description:r&&r.length>0?r:void 0}}var Il=e=>e,fo=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function Rl(e,t){let n=t(e.command);if(n===null)return null;let r=e.option.trim();return r.length===0?null:{command:n,option:r,required:e.required,visible:e.visible,enabled:e.enabled}}function xl(e,t){let n=new Map;for(let r of e??[]){let o=Rl(r,t);o&&n.set(`${o.command}:${o.option.toLowerCase()}`,o)}return[...n.values()].sort((r,o)=>r.command===o.command?r.option.localeCompare(o.option):r.command.localeCompare(o.command))}function uo(e,t){return t?Z(e):void 0}function kn(e){let t=e?.trim();return t&&t.length>0?t:void 0}function On(e){if(e===void 0||e==="agent"||e==="human"||e==="gate")return e;throw new Error("Item type execution_role must be agent, human, or gate.")}function mo(e,t={}){let n=t.resolvePolicyCommand??Il,r=e.name.trim();if(r.length===0)return null;let o=e.required_create_fields!==void 0,i=e.required_create_repeatables!==void 0,s=e.options!==void 0,a=e.command_option_policies!==void 0,c=Z(e.aliases),l=(e.options??[]).map(u=>Cl(u)).filter(u=>u!==null).sort((u,m)=>u.key.localeCompare(m.key)),d=xl(e.command_option_policies,n);return{name:r,description:kn(e.description),default_status:kn(e.default_status),...e.execution_role===void 0?{}:{execution_role:On(e.execution_role)},folder:kn(e.folder),aliases:c.length>0?c:void 0,required_create_fields:uo(e.required_create_fields,o),required_create_repeatables:uo(e.required_create_repeatables,i),options:s?l:void 0,command_option_policies:a?d:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="69ea08ca-3793-51d7-a971-95abf442028f")}catch{}})();var Dl=Object.freeze({decision:"human",milestone:"gate"}),Ml=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],Pl=["dep","comment","note","learning","file","test","doc"],_o=["deadline","estimatedMinutes","acceptanceCriteria","definitionOfReady","order","goal","objective","value","impact","outcome","whyNow","assignee","parent","reviewer","risk","confidence","sprint","release","blockedBy","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact"],$l=["title","description","type","status","priority","tags","body",..._o,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],Ll=["title","description","body","status","closeReason","priority","type","tags",..._o,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],go={"close-reason":"closeReason",close_reason:"closeReason","estimated-minutes":"estimatedMinutes",estimated_minutes:"estimatedMinutes",estimate:"estimatedMinutes","acceptance-criteria":"acceptanceCriteria",acceptance_criteria:"acceptanceCriteria",ac:"acceptanceCriteria","definition-of-ready":"definitionOfReady",definition_of_ready:"definitionOfReady",rank:"order","why-now":"whyNow",why_now:"whyNow","blocked-by":"blockedBy",blocked_by:"blockedBy","blocked-reason":"blockedReason",blocked_reason:"blockedReason","unblock-note":"unblockNote",unblock_note:"unblockNote","repro-steps":"reproSteps",repro_steps:"reproSteps","expected-result":"expectedResult",expected_result:"expectedResult","actual-result":"actualResult",actual_result:"actualResult","affected-version":"affectedVersion",affected_version:"affectedVersion","fixed-version":"fixedVersion",fixed_version:"fixedVersion","customer-impact":"customerImpact",customer_impact:"customerImpact","type-option":"typeOption",type_option:"typeOption",type_options:"typeOption"},jl={...go},Fl={...go},yo=[["deadline","--deadline"],["estimatedMinutes","--estimate/--estimated-minutes"],["acceptanceCriteria","--acceptance-criteria/--ac"],["definitionOfReady","--definition-of-ready"],["order","--order/--rank"],["goal","--goal"],["objective","--objective"],["value","--value"],["impact","--impact"],["outcome","--outcome"],["whyNow","--why-now"],["assignee","--assignee"],["parent","--parent"],["reviewer","--reviewer"],["risk","--risk"],["confidence","--confidence"],["sprint","--sprint"],["release","--release"],["blockedBy","--blocked-by"],["blockedReason","--blocked-reason"],["unblockNote","--unblock-note"],["reporter","--reporter"],["severity","--severity"],["environment","--environment"],["reproSteps","--repro-steps"],["resolution","--resolution"],["expectedResult","--expected-result"],["actualResult","--actual-result"],["affectedVersion","--affected-version"],["fixedVersion","--fixed-version"],["component","--component"],["regression","--regression"],["customerImpact","--customer-impact"]],ho=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function bo(e){return Object.fromEntries(e)}var Ul=bo([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...yo,["author","--author"],["message","--message"],["dep","--dep"],...ho]),zl=bo([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...yo,...ho,["author","--author"],["message","--message"],["force","--force"]]);function ql(e){return e.trim().replace(/^--+/,"").toLowerCase()}function Bl(e){return e==="create"?$l:Ll}function Vl(e){return e==="create"?jl:Fl}function wo(e,t){let n=ql(t);if(n.length===0)return;let r=Vl(e)[n];return r||Bl(e).find(o=>o.toLowerCase()===n)}function Ny(e,t){return(e==="create"?Ul:zl)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function An(e){let t=Gl(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function Wl(e){let t=e.trim(),r=t.replaceAll("\\","/").replace(/^\/+/,""),o=Nl.posix.normalize(r);if(t.includes("\0")||/^[A-Za-z]:/.test(o)||o==="."||o===".."||o.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return o}function Gl(e){let t=e.trim().toLowerCase(),n="",r=!1;for(let o of t){let i=o.charCodeAt(0),s=i>=97&&i<=122,a=i>=48&&i<=57;if(s||a){r&&n.length>0&&(n+="-"),n+=o,r=!1;continue}n.length>0&&(r=!0)}return n}function Kl(e){return mo(e,{resolvePolicyCommand:fo})}function We(e,t){let n=e[t];return Array.isArray(n)?n.filter(r=>typeof r=="string"):void 0}function Hl(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;return typeof t.key!="string"?null:{key:t.key,values:We(t,"values")??[],required:t.required===void 0?void 0:!!t.required,aliases:We(t,"aliases"),description:typeof t.description=="string"?t.description:void 0}}function Yl(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;if(typeof t.command!="string"||typeof t.option!="string")return null;let n=t.command.trim().toLowerCase();return n!=="create"&&n!=="update"?null:{command:n,option:t.option,required:t.required===void 0?void 0:!!t.required,visible:t.visible===void 0?void 0:!!t.visible,enabled:t.enabled===void 0?void 0:!!t.enabled}}function Xl(e){if(Array.isArray(e.options))return e.options.map(t=>Hl(t)).filter(t=>t!==null)}function Jl(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>Yl(t)).filter(t=>t!==null)}function Ql(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e,n=typeof t.name=="string"?t.name:"";if(n.trim().length===0)return null;let r=typeof t.folder=="string"?t.folder:void 0,o=typeof t.description=="string"?t.description:void 0,i=typeof t.default_status=="string"?t.default_status:void 0;return{name:n,description:o,default_status:i,execution_role:On(t.execution_role),folder:r,aliases:We(t,"aliases"),required_create_fields:We(t,"required_create_fields"),required_create_repeatables:We(t,"required_create_repeatables"),options:Xl(t),command_option_policies:Jl(t)}}function Zl(e,t){return e.required_create_fields?Z(e.required_create_fields):t?.required_create_fields??[]}function ed(e,t){return e.required_create_repeatables?Z(e.required_create_repeatables):t?.required_create_repeatables??[]}function td(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function nd(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function rd(e,t){let n=t?.name??e.name,r=e.description??t?.description,o=e.default_status??t?.default_status,i=Wl(e.folder??t?.folder??An(n)),s={name:n,execution_role:e.execution_role,folder:i,aliases:Z([...t?.aliases??[],...e.aliases??[]]),required_create_fields:Zl(e,t),required_create_repeatables:ed(e,t),options:td(e,t),command_option_policies:nd(e,t)};return r&&(s.description=r),o&&(s.default_status=o),s}function po(e,t){for(let n of e){let r=Kl(n);if(!r)continue;let o=r.name.toLowerCase(),i=t.get(o);t.set(o,rd({...r,execution_role:r.execution_role??i?.execution_role},i))}}function od(e){if(!e)return[];let t=[];for(let n of e.item_types??[]){let r=n.types;if(Array.isArray(r))for(let o of r){let i=Ql(o);i&&t.push(i)}}return t}function Dy(e,t=null){let n=new Map;for(let c of Rr)n.set(c.toLowerCase(),{name:c,execution_role:Dl[c.toLowerCase()]??"agent",folder:Fe[c],aliases:[],required_create_fields:[...Ml],required_create_repeatables:[...Pl],options:[],command_option_policies:[]});po(e.item_types?.definitions??[],n),po(od(t),n);let r=[...n.values()].sort((c,l)=>c.name.localeCompare(l.name)),o={},i={},s={};for(let c of r){o[c.name]=c,s[c.name]=c.folder,i[c.name.toLowerCase()]=c.name;for(let l of c.aliases)i[l.toLowerCase()]=c.name}let a=[...new Set(r.map(c=>c.folder))].sort((c,l)=>c.localeCompare(l));return{types:r.map(c=>c.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function id(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function sd(e,t){let n=id(e,t);if(n)return t.by_type[n]}function ad(e,t,n,r){for(let o of r){let i=wo(n,o);if(i){e.required.add(i);continue}e.errors.push(`Unsupported base required option "${o}" for command "${n}" on type "${t.name}"`)}}function Sn(e,t,n){if(n){e.add(t);return}e.delete(t)}function cd(e,t,n,r){let o=wo(n,r.option);if(!o){e.errors.push(`Unsupported command_option_policies option "${r.option}" for command "${n}" on type "${t.name}"`);return}r.required!==void 0&&Sn(e.required,o,r.required),r.visible!==void 0&&Sn(e.hidden,o,!r.visible),r.enabled!==void 0&&Sn(e.disabled,o,!r.enabled)}function ld(e,t,n){for(let r of t.command_option_policies)r.command===n&&cd(e,t,n,r)}function dd(e,t,n){for(let r of e.required)e.disabled.has(r)&&e.errors.push(`Option "${r}" cannot be both required and disabled for command "${n}" on type "${t.name}"`)}function My(e,t,n){let r=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:r};return ad(a,e,t,n),ld(a,e,t),dd(a,e,t),{required:[...o],hidden:[...i].sort((c,l)=>c.localeCompare(l)),disabled:[...s].sort((c,l)=>c.localeCompare(l)),errors:r}}function ud(e){let t=new Map;for(let n of e.options){t.set(n.key.toLowerCase(),n);for(let r of n.aliases??[])t.set(r.toLowerCase(),n)}return t}function fd(e,t,n){let r=e.values;if(r.length===0)return t;let i=new Map(r.map(s=>[s.toLowerCase(),s])).get(t.toLowerCase());if(!i){n.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${r.join(", ")}`);return}return i}function Py(e,t,n){let r=sd(e,n);if(!r)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=ud(r),s={};for(let[c,l]of Object.entries(t??{})){let d=c.trim(),u=l.trim();if(d.length===0){o.push("type option keys must not be empty");continue}if(u.length===0){o.push(`type option "${d}" must not be empty`);continue}let m=i.get(d.toLowerCase());if(!m){let p=r.options.map(_=>_.key).join(", ");o.push(r.options.length>0?`Unknown type option "${d}" for type "${r.name}". Allowed: ${p}`:`Type "${r.name}" does not define any configurable type options`);continue}let f=fd(m,u,o);f!==void 0&&(s[m.key]=f)}for(let c of r.options)c.required&&!(c.key in s)&&o.push(`Missing required type option "${c.key}" for type "${r.name}"`);let a=Object.keys(s).sort((c,l)=>c.localeCompare(l));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(c=>[c,s[c]])),errors:o}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="124443e3-a20b-5fd6-a1d9-e4a09b17dc4a")}catch{}})();var gd={json_markdown:".md",toon:".toon"},yd={".md":"json_markdown",".toon":"toon"};var Vy=[".md",".toon"];function Tt(e){try{return pd(e),!0}catch{return!1}}function hd(e){try{let t=JSON.parse(md(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function bd(e){let t=O.resolve(e);for(;;){let n=O.join(t,_t),r=O.join(n,gt);if(Tt(r))return n;let o=O.join(t,gt);if(Tt(o)&&hd(o))return t;let i=O.dirname(t);if(i===t)return;t=i}}function wd(e){return bd(e)??O.resolve(e,_t)}function Wy(e,t){let n=process.env.PM_PATH,r=t?.trim()||n?.trim();if(r){let o=O.resolve(e,r);if(!Tt(vo(o))){let i=O.join(o,_t);if(Tt(vo(i)))return i}return o}return wd(e)}function Gy(e){let t=O.resolve(e),n=O.dirname(t);return O.basename(t)==="pm"&&O.basename(n)===".agents"?O.dirname(n):t}function Eo(e){let t=process.env.PM_GLOBAL_PATH?.trim(),n=t&&t.length>0?t:O.join(_d.homedir(),".pm-cli");return O.resolve(e,n)}function vo(e){return O.join(e,gt)}function vd(e,t,n=Fe){let r=n[t]??An(t);return O.join(e,r)}function Ky(e,t,n,r="toon",o=Fe){return O.join(vd(e,t,o),`${n}${gd[r]}`)}function Hy(e){let t=e.replaceAll("\\","/"),n=O.posix.extname(t).toLowerCase();return yd[n]??null}function Yy(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new h("Invalid history item id: expected a single filename.",y.USAGE);return O.join(e,"history",`${t}.jsonl`)}function ko(e,t){return O.join(e,"locks",`${t}.lock`)}function Xy(e){return O.join(e,"runtime")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="49fe564d-671f-5425-96fe-517cb323f773")}catch{}})();function Ed(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Qy(e){return Ed(e)??void 0}function Zy(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t-=1;return t===e.length?e:e.slice(0,t)}function eh(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function So(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function Ao(e){let t=typeof e=="number"?e:typeof e=="string"&&e.trim().length>0?Number(e.trim()):Number.NaN;return Number.isFinite(t)?t:null}function th(e){let t=Ao(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function nh(e,t,n){let r=Ao(e);return r===null||r<t||r>n?null:r}function me(e){return typeof e!="object"||e===null?null:e}function Oo(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function To(e){let t=Oo(e);if(!t)return null;if(typeof t.activate=="function")return t;let n=Oo(t.default);return typeof n?.activate=="function"?n:null}function rh(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e}:{}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="31da4a5a-1e85-5d77-a09f-2736cc44d850")}catch{}})();var kd=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function Co(e){return typeof e!="string"?null:kd[e.trim().toLowerCase()]??null}function Io(e){let t=[],n=r=>{if(Array.isArray(r)){for(let o of r)n(o);return}if(typeof r=="string"){for(let o of r.split(",")){let i=o.trim();i.length>0&&t.push(i)}return}r!=null&&t.push(r)};return n(e),t}function Ro(e,t){return t==="string"?!0:t==="number"?typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim().length>0&&Number.isFinite(Number(e)):typeof e=="boolean"?!0:typeof e=="string"&&["true","false","1","0"].includes(e.trim().toLowerCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="99f785c2-7c67-5564-9423-3439c41b4557")}catch{}})();var Ct=xr;function xo(e){let t=e.trim().toLowerCase();return Ct.includes(t)?t:null}function No(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=Math.max(1,Math.floor(t.length*.34));for(let r of Ct)if(St(t,r,n)!==null)return r;return null}import{constants as ee}from"node:os";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="aaf1c6ce-1bc9-5974-a38f-7daf8e4e63cc")}catch{}})();var Do=new Map([["EACCES",{summary:"was denied filesystem permission",recovery:"Grant the required filesystem access, then retry.",category:"permission"}],["EDQUOT",{summary:"exceeded the filesystem quota",recovery:"Raise or reclaim the filesystem quota, then retry.",category:"capacity"}],["EMFILE",{summary:"exhausted the process file-descriptor limit",recovery:"Close unused file handles or raise the process limit, then retry.",category:"resource"}],["ENFILE",{summary:"exhausted the host file-descriptor limit",recovery:"Free host file descriptors or raise the host limit, then retry.",category:"resource"}],["ENOMEM",{summary:"ran out of available memory",recovery:"Free memory or reduce concurrent work, then retry.",category:"resource"}],["ENOSPC",{summary:"ran out of storage space",recovery:"Free storage on the filesystem holding the project, then retry.",category:"capacity"}],["EPERM",{summary:"was denied by the host permission policy",recovery:"Grant the required filesystem permission, then retry.",category:"permission"}],["EROFS",{summary:"targeted a read-only filesystem",recovery:"Use a writable project filesystem or remount it read-write, then retry.",category:"permission"}]]),Od=/^[a-z][a-z0-9_]{0,63}$/u,Sd=new Map([[ee.errno.EACCES,"EACCES"],[ee.errno.EDQUOT,"EDQUOT"],[ee.errno.EMFILE,"EMFILE"],[ee.errno.ENFILE,"ENFILE"],[ee.errno.ENOMEM,"ENOMEM"],[ee.errno.ENOSPC,"ENOSPC"],[ee.errno.EPERM,"EPERM"],[ee.errno.EROFS,"EROFS"]].filter(([e])=>Number.isInteger(e))),Ad={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function Td(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&Do.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:Sd.get(Math.abs(t.errno))??null}function Cd(e,t,n={}){let r=Td(e);if(r===null)return null;if(!Od.test(t))throw new h("Host environment operation labels must be bounded identifiers.",y.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=Do.get(r);return new h(`Host filesystem operation ${t} ${o.summary}.`,y.GENERIC_FAILURE,{code:n.codes?.[o.category]??Ad[o.category].code,reason:r,required:o.recovery,why:n.why??"The operating system refused a required project filesystem operation.",nextSteps:[o.recovery,...n.nextSteps??[]],...n.suggestedRetry?{recovery:{suggested_retry:n.suggestedRetry}}:{}})}async function Mo(e,t,n={}){try{return await t()}catch(r){throw Cd(r,e,n)??r}}import Id from"node:fs/promises";import Ge from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6d77d806-1c41-5235-b56b-802089979395")}catch{}})();async function Po(e,t){let n=Ge.dirname(t.manifest_path),r=Ge.relative(n,t.entry_path);if(r.startsWith("..")||Ge.isAbsolute(r))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=Ge.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await Mo("extension_module_graph_snapshot",()=>Id.cp(n,o,{recursive:!0,force:!0})),Ge.join(o,r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="44b86710-2d6f-57fe-912d-1cf7482a4f86")}catch{}})();function $o(e){let t={beforeCommand:e.hooks.beforeCommand.length,beforeMutation:e.hooks.beforeMutation.length,afterCommand:e.hooks.afterCommand.length,onWrite:e.hooks.onWrite.length,onRead:e.hooks.onRead.length,onIndex:e.hooks.onIndex.length,commandOverrides:e.commands.overrides.length,commandHandlers:e.commands.handlers.length,parserOverrides:e.parsers.overrides.length,preflightOverrides:e.preflight.overrides.length,serviceOverrides:e.services.overrides.length,rendererOverrides:e.renderers.overrides.length,registrations:Object.fromEntries(Object.entries(e.registrations).map(([n,r])=>[n,r.length]))};return()=>{e.hooks.beforeCommand.length=t.beforeCommand,e.hooks.beforeMutation.length=t.beforeMutation,e.hooks.afterCommand.length=t.afterCommand,e.hooks.onWrite.length=t.onWrite,e.hooks.onRead.length=t.onRead,e.hooks.onIndex.length=t.onIndex,e.commands.overrides.length=t.commandOverrides,e.commands.handlers.length=t.commandHandlers,e.parsers.overrides.length=t.parserOverrides,e.preflight.overrides.length=t.preflightOverrides,e.services.overrides.length=t.serviceOverrides,e.renderers.overrides.length=t.rendererOverrides;for(let[n,r]of Object.entries(t.registrations))e.registrations[n].length=r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="092f2852-fa07-5f0f-8266-e9e2ca078cb6")}catch{}})();function Lo(e){let t=typeof e=="function"?e:e.run;if(typeof t!="function")throw new TypeError("registerPreflight override requires a function handler");let n=[...new Set((typeof e=="function"?[]:e.commands??[]).map(r=>{if(typeof r!="string"||r.trim().length===0)throw new TypeError("registerPreflight ownership.commands must contain non-empty command paths");return S(r)}))];return{run:t,...n.length>0?{commands:n}:{}}}function jo(e){let t=[];for(let n=1;n<e.overrides.length;n+=1){let r=e.overrides[n];for(let o of e.overrides.slice(0,n))r.commands?.length&&o.commands?.length&&!o.commands.some(i=>r.commands.includes(i))||t.push(`extension_preflight_override_collision:${r.layer}:${r.name}:${o.layer}:${o.name}`)}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="09c95125-68bd-512b-bb09-c9ef0b2f676e")}catch{}})();function Fo(e){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("registerService ownership must be an object");if(Reflect.ownKeys(e).some(t=>t!=="passThrough"))throw new TypeError("registerService ownership supports only passThrough");if(e.passThrough!==void 0&&typeof e.passThrough!="boolean")throw new TypeError("registerService ownership.passThrough must be a boolean when provided");return e.passThrough===!0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="aade6230-a71b-5cbc-bc9d-022f20e521bd")}catch{}})();function x(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return t}function D(e,t){if(t!==void 0&&typeof t!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function A(e,t){if(t!==void 0&&(typeof t!="string"||t.trim().length===0))throw new TypeError(`${e} must be a non-empty string when provided`)}function Uo(e,t){if(t===void 0)return;let n=r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean";if(Array.isArray(t)){for(let[r,o]of t.entries())if(!n(o))throw new TypeError(`${e}[${r}] must be a string, number, or boolean`);return}if(!n(t))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function pe(e,t){if(t!==void 0){if(!Array.isArray(t))throw new TypeError(`${e} must be an array of non-empty strings when provided`);for(let[n,r]of t.entries())if(typeof r!="string"||r.trim().length===0)throw new TypeError(`${e}[${n}] must be a non-empty string`)}}function Ke(e,t){if(pe(e,t),!Array.isArray(t))return[];let n=[],r=new Set;for(let o of t){let i=o.trim();i.length===0||r.has(i)||(r.add(i),n.push(i))}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="34536eba-0f92-5599-a807-5b39b000e733")}catch{}})();var Tn=Object.freeze(["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"]);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ca48c32a-e4e0-5da5-b9cb-b1f713646bad")}catch{}})();var Rd=new Set(Tn);function xd(e){if(e!==void 0&&!Rd.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${Tn.join(", ")}`)}function zo(e){A("registerCommand definition.action",e.action),A("registerCommand definition.family",e.family),A("registerCommand definition.description",e.description),A("registerCommand definition.intent",e.intent),A("registerCommand definition.tier",e.tier);let t=e.tier;if(t!==void 0&&t!=="core"&&t!=="standard"&&t!=="full"&&t!=="internal")throw new Error("registerCommand definition.tier must be core, standard, full, or internal");xd(e.family)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1729c469-5e9c-5d8c-8137-ec506c9fd31b")}catch{}})();function Nd(e){let t=x("registerExporter options.output",e),n=new Set(["channel","receipt","media_type"]);for(let r of Object.keys(t))if(!n.has(r))throw new TypeError(`registerExporter options.output contains unsupported field ${r}`);if(t.channel!=="stdout"&&t.channel!=="file")throw new TypeError("registerExporter options.output.channel must be stdout|file");if(t.receipt!==void 0&&t.receipt!=="suppress"&&t.receipt!=="render")throw new TypeError("registerExporter options.output.receipt must be suppress|render");if(t.channel==="stdout"&&t.receipt==="render")throw new TypeError("registerExporter stdout artifacts cannot render a host receipt");return A("registerExporter options.output.media_type",t.media_type),{channel:t.channel,receipt:t.receipt??(t.channel==="stdout"?"suppress":"render"),...typeof t.media_type=="string"?{media_type:t.media_type}:{}}}function qo(e,t,n){if(e==="registerImporter"&&t.output!==void 0)throw new TypeError("registerImporter options.output is exporter-only");if(e!=="registerExporter"||t.output===void 0)return;let r=Nd(t.output);return!n&&r.channel==="stdout"&&(t.description="Export items with the registered extension adapter. Artifact bytes are written exclusively to stdout and the host receipt is suppressed by default."),r}function Cn(e,t,n){return{registration:t,action:n,command:e.command,args:M(e.args),options:M(e.options),global:M(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,...e.sdk===void 0?{}:{sdk:e.sdk}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="09098e5c-d021-53ae-96b5-c56394c304da")}catch{}})();var Dd=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields"},{flag:"--output-limit",value_name:"count"},{flag:"--output-budget",value_name:"tokens"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state"},{flag:"--output-cursor",value_name:"cursor"},{flag:"--output-row-contract"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"]},{flag:"--no-extensions"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"}]),In=new Set(Dd.flatMap(e=>[e.flag,...e.aliases??[]]));(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f823edae-b035-5547-8d81-2761a9a44034")}catch{}})();var Md=/^--[a-z0-9][a-z0-9_-]*(?:[ =](?:<[^<>]+>|\[[^[\]]+\]))?$/;function Pd(e){if(typeof e!="string")return null;let t=e.trim(),n=t.split(/[ =]/,1)[0];return In.has(n)?"host_owned_flag_collision":Md.test(t)?null:"malformed_long_flag"}function Bo(e,t){let n=[e,t].find(i=>typeof i=="string"&&In.has(i.trim().split(/[ =]/,1)[0]));if(typeof n=="string")return{token:n.trim().split(/[ =]/,1)[0],failure:"host_owned_flag_collision"};if(typeof e!="string")return null;let r=e.trim(),o=Pd(r);return o===null?null:{token:r,failure:o}}function Vo(e,t){return t==="host_owned_flag_collision"?`cannot shadow host-owned global flag "${e}"; read it from context.global instead`:`long flag "${e}" must start with a double-dash name such as "--my-flag" or "--my-flag <value>"`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d2feae50-9a1e-54fa-98a3-df529be63069")}catch{}})();function Wo(e){return typeof e=="string"?e:String(e)}function He(e){let n=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(n)?n.split(/[.-]/).map(r=>Number(r)):null}function Rn(e,t){let n=He(e),r=He(t);if(!n||!r)return null;let o=Math.max(n.length,r.length);for(let i=0;i<o;i+=1){let s=n[i]??0,a=r[i]??0;if(s>a)return 1;if(s<a)return-1}return 0}function Go(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let n=Wo(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(!He(n))return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(t===null)return{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:null};let r=Rn(t,n);return r===null?{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:t}:r<0?{kind:"pm_min_version",status:"unmet",allowed:!1,required:n,current:t}:{kind:"pm_min_version",status:"ok",allowed:!0,required:n,current:t}}function Ko(e,t,n){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let r=Wo(e);if(typeof e!="string"||r.trim().length===0)return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(/^[<>=~^]/.test(r.trim())||!He(r))return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(t===null)return{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:null};let o=Rn(t,r);return o===null?{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:t}:o>0?n==="warn"?{kind:"pm_max_version",status:"exceeded_warn",allowed:!0,required:r,current:t}:{kind:"pm_max_version",status:"exceeded",allowed:!1,required:r,current:t}:{kind:"pm_max_version",status:"ok",allowed:!0,required:r,current:t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8ea4597b-6a2b-5061-b490-d8aff3fbe7aa")}catch{}})();function F(e){return typeof e!="string"?"":e.trim().toLowerCase()}function b(e){return new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))}function $d(e){let t=e.trim().toLowerCase();if(t.length===0)return"";let n=t.split(/[.:/]/).map(r=>r.replace(/[\s_-]+/g,"")).filter(r=>r.length>0);return n.length===0?"":n.length===1?n[0]:`${n[0]}.${n.slice(1).join("")}`}function Se(e){return new Set((e??[]).map(t=>$d(t)).filter(t=>t.length>0))}function Ho(e){let t=F(e);return dt.includes(t)?t:"off"}function Yo(e){let t=F(e);return ut.includes(t)?t:"off"}function Ye(e){let t=F(e);return ft.includes(t)?t:"none"}function xn(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return Ir.includes(t)?t:void 0}function Xo(e){if(typeof e=="string"){let t=xn(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:xn(e.global)??"block",project:xn(e.project)??"block"}:{global:"block",project:"block"}}function Ld(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function E(e){return[...new Set(e)].sort((t,n)=>t.localeCompare(n))}function jd(e){let t=F(e.name);return t.length===0?null:{name:t,normalized:{name:t,disabled:e.disabled===!0,requireTrusted:e.require_trusted===!0,requireProvenance:e.require_provenance===!0,sandboxProfile:e.sandbox_profile!==void 0?Ye(e.sandbox_profile):void 0,allowedCapabilities:b(e.allowed_capabilities),blockedCapabilities:b(e.blocked_capabilities),allowedSurfaces:Se(e.allowed_surfaces),blockedSurfaces:Se(e.blocked_surfaces),allowedCommands:b(e.allowed_commands),blockedCommands:b(e.blocked_commands),allowedActions:b(e.allowed_actions),blockedActions:b(e.blocked_actions),allowedServices:b(e.allowed_services),blockedServices:b(e.blocked_services)}}}function Jo(e){let t=new Map;for(let n of e??[]){let r=jd(n);r&&t.set(r.name,r.normalized)}return t}function Fd(e){let t=[],n=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of E([...e.allowedCapabilities,...e.blockedCapabilities]))X(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of n)for(let i of E([...o.allowedCapabilities,...o.blockedCapabilities]))X(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let r=new Set(mt);for(let o of E([...e.allowedSurfaces,...e.blockedSurfaces]))r.has(o)||t.push(`extension_policy_unknown_surface:${o}`);for(let o of n)for(let i of E([...o.allowedSurfaces,...o.blockedSurfaces]))r.has(i)||t.push(`extension_policy_unknown_surface:${o.name}:${i}`);return[...new Set(t)].sort((o,i)=>o.localeCompare(i))}function Qo(e){let t=e.extensions?.policy??{},n=b(t.allowed_capabilities),r=b(t.blocked_capabilities),o=Se(t.allowed_surfaces),i=Se(t.blocked_surfaces),s=Jo(t.extension_overrides);return{mode:Ho(t.mode),trustMode:Yo(t.trust_mode),pmMaxVersionExceededMode:Xo(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:b(t.trusted_extensions),defaultSandboxProfile:Ye(t.default_sandbox_profile),allowedExtensions:b(t.allowed_extensions),blockedExtensions:b(t.blocked_extensions),allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:b(t.allowed_commands),blockedCommands:b(t.blocked_commands),allowedActions:b(t.allowed_actions),blockedActions:b(t.blocked_actions),allowedServices:b(t.allowed_services),blockedServices:b(t.blocked_services),overridesByName:s,warnings:Fd({allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function Zo(e){let t=[...e.overridesByName.values()].sort((n,r)=>n.name.localeCompare(r.name)).map(n=>({name:n.name,...n.disabled?{disabled:!0}:{},...n.requireTrusted?{require_trusted:!0}:{},...n.requireProvenance?{require_provenance:!0}:{},...n.sandboxProfile?{sandbox_profile:n.sandboxProfile}:{},...n.allowedCapabilities.size>0?{allowed_capabilities:E(n.allowedCapabilities)}:{},...n.blockedCapabilities.size>0?{blocked_capabilities:E(n.blockedCapabilities)}:{},...n.allowedSurfaces.size>0?{allowed_surfaces:E(n.allowedSurfaces)}:{},...n.blockedSurfaces.size>0?{blocked_surfaces:E(n.blockedSurfaces)}:{},...n.allowedCommands.size>0?{allowed_commands:E(n.allowedCommands)}:{},...n.blockedCommands.size>0?{blocked_commands:E(n.blockedCommands)}:{},...n.allowedActions.size>0?{allowed_actions:E(n.allowedActions)}:{},...n.blockedActions.size>0?{blocked_actions:E(n.blockedActions)}:{},...n.allowedServices.size>0?{allowed_services:E(n.allowedServices)}:{},...n.blockedServices.size>0?{blocked_services:E(n.blockedServices)}:{}}));return{mode:e.mode,trust_mode:e.trustMode,pm_max_version_exceeded_mode:Ld(e.pmMaxVersionExceededMode),require_provenance:e.requireProvenance,trusted_extensions:E(e.trustedExtensions),default_sandbox_profile:e.defaultSandboxProfile,allowed_extensions:E(e.allowedExtensions),blocked_extensions:E(e.blockedExtensions),allowed_capabilities:E(e.allowedCapabilities),blocked_capabilities:E(e.blockedCapabilities),allowed_surfaces:E(e.allowedSurfaces),blocked_surfaces:E(e.blockedSurfaces),allowed_commands:E(e.allowedCommands),blocked_commands:E(e.blockedCommands),allowed_actions:E(e.allowedActions),blocked_actions:E(e.blockedActions),allowed_services:E(e.allowedServices),blocked_services:E(e.blockedServices),extension_overrides:t}}function ei(e){let t=Jo(e.extension_overrides);return{mode:Ho(e.mode),trustMode:Yo(e.trust_mode),pmMaxVersionExceededMode:Xo(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:b(e.trusted_extensions),defaultSandboxProfile:Ye(e.default_sandbox_profile),allowedExtensions:b(e.allowed_extensions),blockedExtensions:b(e.blocked_extensions),allowedCapabilities:b(e.allowed_capabilities),blockedCapabilities:b(e.blocked_capabilities),allowedSurfaces:Se(e.allowed_surfaces),blockedSurfaces:Se(e.blocked_surfaces),allowedCommands:b(e.allowed_commands),blockedCommands:b(e.blocked_commands),allowedActions:b(e.allowed_actions),blockedActions:b(e.blocked_actions),allowedServices:b(e.allowed_services),blockedServices:b(e.blocked_services),overridesByName:t,warnings:[]}}function te(e,t){return e.overridesByName.get(F(t))??null}function Ae(e,t,n,r,o){return t.has(n)?o:e.size>0&&!e.has(n)?r:null}function ti(e,t,n){let r=n.trim().toLowerCase(),o=te(e,t.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return Ae(i,s,r,"capability_not_allowlisted","capability_blocked")}function Ud(e,t,n){let r=te(e,t.name),o=r&&r.allowedSurfaces.size>0?r.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...r?r.blockedSurfaces:[]]);return Ae(o,i,n,"surface_not_allowlisted","surface_blocked")}function zd(e,t,n){let r=S(n);if(r.length===0)return null;let o=te(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return Ae(i,s,r,"command_not_allowlisted","command_blocked")}function qd(e,t,n){let r=F(n).replace(/\s+/g,"-");if(r.length===0)return null;let o=te(e,t.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return Ae(i,s,r,"action_not_allowlisted","action_blocked")}function Bd(e,t,n){let r=F(n);if(r.length===0)return null;let o=te(e,t.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return Ae(i,s,r,"service_not_allowlisted","service_blocked")}function Vd(e,t){let n=F(t.name);return te(e,t.name)?.disabled===!0?"extension_override_disabled":Ae(e.allowedExtensions,e.blockedExtensions,n,"extension_not_allowlisted","extension_blocked")}function Wd(e,t){if(e.trustMode==="off")return null;let n=te(e,t.name),r=F(t.name),o=t.trusted===!0,i=t.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(r)?"extension_not_trusted":(n?.requireTrusted===!0||e.trustMode==="warn"||e.trustMode==="enforce")&&!o?"extension_untrusted":(e.requireProvenance||n?.requireProvenance===!0)&&!i?"provenance_missing_or_unverified":null}function Gd(e,t){if(e.mode==="off")return null;let r=te(e,t.name)?.sandboxProfile??t.sandboxProfile??e.defaultSandboxProfile;if(r==="none")return null;let o=t.permissions;if(!o)return"sandbox_permissions_missing";let i=s=>o[s]===!0;return r==="restricted"?i("process_spawn")?"sandbox_restricted_disallows_process_spawn":i("env_write")?"sandbox_restricted_disallows_env_write":null:i("process_spawn")?"sandbox_strict_disallows_process_spawn":i("network")?"sandbox_strict_disallows_network":i("fs_write")?"sandbox_strict_disallows_fs_write":i("env_write")?"sandbox_strict_disallows_env_write":null}function It(e,t,n,r,o={}){let i=Object.entries(o).sort((a,c)=>a[0].localeCompare(c[0])).map(([a,c])=>`${a}=${c}`).join(":"),s=i.length>0?`:${i}`:"";return`extension_policy_${e}_${t}:${n.layer}:${n.name}:reason=${r}${s}`}function ni(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let n=[],r=Vd(e,t);r&&n.push({reason:r,scope:"extension",mode:e.mode});let o=Wd(e,t);o&&n.push({reason:o,scope:"trust",mode:e.trustMode});let i=Gd(e,t);i&&n.push({reason:i,scope:"extension",mode:e.mode});let s=n.find(c=>c.mode==="enforce");if(s)return{allowed:!1,warning:It("blocked",s.scope,t,s.reason)};let a=n.find(c=>c.mode==="warn");return a?{allowed:!0,warning:It("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function ri(e,t,n){if(e.mode==="off")return{allowed:!0,warning:null};let r=ti(e,t,n);return r?{allowed:e.mode==="warn",warning:It(e.mode==="warn"?"violation":"blocked","capability",t,r,{capability:n.trim().toLowerCase()})}:{allowed:!0,warning:null}}function Kd(e,t,n,r,o){let i=typeof r=="string"?ti(e,t,r):null,s=Ud(e,t,n),a=o.command?zd(e,t,o.command):null,c=o.action?qd(e,t,o.action):null,l=o.service?Bd(e,t,o.service):null;return i??s??a??c??l}function Hd(e,t,n,r){let o={method:F(e).replace(/\s+/g,"_"),surface:t};return n&&(o.capability=n),r.command&&(o.command=S(r.command)),r.action&&(o.action=F(r.action).replace(/\s+/g,"-")),r.service&&(o.service=F(r.service)),o}function oi(e,t,n,r,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=Kd(e,t,n,o,s);if(!a)return{allowed:!0,warning:null};let c=It(e.mode==="warn"?"violation":"blocked","registration",t,a,Hd(r,n,o,s));return{allowed:e.mode==="warn",warning:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01116a5e-62d1-591b-9fd0-84ac6e99f8d0")}catch{}})();function Rt(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function Nn(){return{overrides:[],handlers:[]}}function Dn(){return{overrides:[]}}function Mn(){return{overrides:[]}}function Pn(){return{overrides:[]}}function $n(){return{overrides:[]}}function Ln(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[],assurance_providers:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="483b4197-5498-568a-bcc4-abd6999a07cc")}catch{}})();function ii(e){return e==="toon"||e==="json"}function si(e){return Ee.includes(e)}function _e(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var ai=Symbol("extension_registration_trace");function G(e,t){let n=new TypeError(e);return Object.defineProperty(n,ai,{value:t,enumerable:!1,configurable:!1,writable:!1}),n}function ci(e){return e instanceof Error?e[ai]:void 0}function Xe(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>Xe(t));if(typeof e=="function")return"[Function]";if(typeof e=="bigint"||typeof e=="symbol")return e.toString();if(typeof e=="object"){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=Xe(t[r]);return n}return e}function Je(e){if(Array.isArray(e))return e.map(t=>Je(t));if(typeof e=="object"&&e!==null){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=Je(t[r]);return n}return e}function Te(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Xe(t)}function Qe(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return Je(t)}function xt(e,t){if(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(n=>Te(e,n))}function $(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function Ze(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function jn(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Fn(e,t){return S(`${e} ${t}`)}function et(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var Yd=new Set(["low","medium","high"]),Xd=new Set(["number","string_set"]),Jd=new Set(["string","number","boolean"]);function li(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function Qd(e,t,n){let r=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=x(r,n);if(!Xd.has(String(o.value_type)))throw new TypeError(`${r}.value_type must be number or string_set`);if(A(`${r}.description`,o.description),o.parameters===void 0)return;let i=x(`${r}.parameters`,o.parameters);for(let[s,a]of Object.entries(i)){let c=`${r}.parameters.${s}`;li(`${c}.name`,s);let l=x(c,a);if(!Jd.has(String(l.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);D(`${c}.required`,l.required),A(`${c}.description`,l.description)}if(Object.keys(i).length>50)throw new TypeError(`assurance provider ${e} key ${t} exceeds 50 parameters`)}function di(e){let t=x("registerAssuranceMeasurementProvider provider",e),n=li("registerAssuranceMeasurementProvider provider.id",t.id);if(!/^[a-z0-9][a-z0-9-]*$/u.test(n))throw new TypeError("registerAssuranceMeasurementProvider provider.id must be a stable lowercase id");if(!Yd.has(String(t.cost_class)))throw new TypeError("registerAssuranceMeasurementProvider provider.cost_class must be low, medium, or high");if(typeof t.network!="boolean")throw new TypeError("registerAssuranceMeasurementProvider provider.network must be boolean");let r=x("registerAssuranceMeasurementProvider provider.keys",t.keys);if(Object.keys(r).length===0)throw new TypeError("registerAssuranceMeasurementProvider provider.keys requires at least one key");for(let[o,i]of Object.entries(r)){if(!/^[a-z0-9][a-z0-9-]*$/u.test(o))throw new TypeError(`registerAssuranceMeasurementProvider provider key ${o} must be a stable lowercase id`);Qd(n,o,i)}if(t.timeout_ms!==void 0&&(typeof t.timeout_ms!="number"||!Number.isInteger(t.timeout_ms)||t.timeout_ms<1||t.timeout_ms>3e5))throw new TypeError("registerAssuranceMeasurementProvider provider.timeout_ms must be an integer from 1 through 300000");if(typeof t.resolve!="function")throw new TypeError("registerAssuranceMeasurementProvider provider.resolve requires a function handler")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b35d854e-5025-5999-abe7-507f1a25647f")}catch{}})();function ui(e){return!e.extensionReady||!e.enabledForLoad?null:{layer:e.layer,directory:e.directory,manifest_path:e.manifestPath,entry_path:e.entryPath,manifest:e.manifest,source_package:e.sourceIdentity?.package_name,source_aliases:e.sourceIdentity?.aliases,contributions:e.sourceIdentity?.contributions}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="736cf7fc-d4da-57ce-90d8-2432085dd2c8")}catch{}})();var Zd=5e3;async function Un(e,t,n){let r=[];for(let o of e)try{await o.run(M(n))}catch{r.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return r}function eu(e,t,n){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new h(`Extension mutation guard ${t.name} returned an invalid decision.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${t.layer}:${t.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let r=e,o=typeof r.code=="string"?r.code.trim():"",i=typeof r.remediation=="string"?r.remediation.trim():"";if(o.length===0||i.length===0)throw new h(`Extension mutation guard ${t.name} returned an invalid denial.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${t.layer}:${t.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof r.message=="string"?r.message.trim():"";throw new h(s||`Extension mutation guard ${t.name} denied ${n}.`,y.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function zn(e,t){for(let n of e.beforeMutation??[]){let r,o;try{let i=Promise.resolve().then(()=>n.run({pm_root:t.pm_root,operation:t.operation,before:t.before===null?null:M(t.before),after:t.after===null?null:M(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),r=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new h(`Extension mutation guard ${n.name} timed out before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},Zd),o.unref?.()})])}catch(i){throw i instanceof h?i:new h(`Extension mutation guard ${n.name} failed before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(o)}eu(r,n,t.operation)}}async function qn(e,t){return Un(e.onWrite,"onWrite",t)}async function Bn(e,t){return Un(e.onRead,"onRead",t)}async function Vn(e,t){return Un(e.onIndex,"onIndex",t)}function tu(e){let t="";e instanceof Error&&typeof e.message=="string"?t=e.message:typeof e=="string"?t=e:typeof e=="object"&&e!==null&&typeof e.message=="string"&&(t=e.message);let n=t.replace(/\s+/gu," ").trim();if(n.length===0)return"";let r=300;return n.length>r?`${n.slice(0,r-1)}\u2026`:n}function Nt(e,t){if(typeof e!="object"||e===null||typeof e[t]!="string")return;let n=String(e[t]).replace(/\s+/gu," ").trim();return n.length>0?n.slice(0,300):void 0}function nu(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"exit_code"))return;let t=e.exit_code;if(typeof t!="number"||!Number.isInteger(t)||t<1||t>255)throw new TypeError("Extension command result exit_code must be an integer from 1 to 255.");return t}async function Wn(e,t){let n=S(t.command);if(n.length===0)return{handled:!1,result:null,warnings:[]};let r=[...e.handlers].reverse().find(o=>o.command===n);if(!r)return{handled:!1,result:null,warnings:[]};try{let o=await r.run({command:n,args:M(t.args),options:M(t.options),global:M(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,...t.sdk===void 0?{}:{sdk:t.sdk}});return{handled:!0,result:o,warnings:[],...Object.fromEntries([["exitCode",nu(o)],["errorCode",Nt(o,"code")],["remediation",Nt(o,"remediation")]].filter(i=>i[1]!==void 0))}}catch(o){let i=typeof o=="object"&&o!==null&&"exitCode"in o?o.exitCode:void 0;if(typeof i=="number"&&Number.isFinite(i))throw o;return{handled:!1,result:null,warnings:[`extension_command_handler_failed:${r.layer}:${r.name}:${r.command}`],errorMessage:tu(o),...Object.fromEntries([["errorCode",Nt(o,"code")],["remediation",Nt(o,"remediation")]].filter(s=>s[1]!==void 0))}}}function fi(e){return{handled:!1,result:e.payload,warnings:[]}}function mi(e,t){return[...e.overrides].reverse().filter(n=>n.service===t)}function pi(e){return{service:e.service,command:e.command?S(e.command):void 0,args:e.args?M(e.args):void 0,options:e.options?$r(e.options):void 0,global:e.global?Lr(e.global):void 0,pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,payload:M(e.payload)}}function ru(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"handled"))return!1;let t=e.handled;return t===!0?Object.hasOwn(e,"result"):t===!1&&Reflect.ownKeys(e).length===1}function _i(e,t){return ru(e)?e.handled?{handled:!0,result:e.result}:{handled:!1,result:t.payload}:t.service==="output_format"&&e==null?{handled:!1,result:t.payload}:{handled:!0,result:e}}function gi(e,t,n){return t.service==="output_format"&&typeof e=="object"&&e!==null&&B(e,n.payload)}function yi(e,t,n){if(t.handled){if(e.passThrough===!0){n.push(`extension_service_pass_through_contract_violated:${e.layer}:${e.name}:${e.service}`);return}return{handled:!0,result:t.result,warnings:n}}}function Gn(e,t){let n=mi(e,t.service);if(n.length===0)return fi(t);let r=[];for(let o of n)try{let i=pi(t),s=o.run(i);if(s instanceof Promise){r.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(gi(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=yi(o,_i(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}async function Kn(e,t){let n=mi(e,t.service);if(n.length===0)return fi(t);let r=[];for(let o of n)try{let i=pi(t),s=await Promise.resolve(o.run(i));if(gi(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=yi(o,_i(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2f54ac29-9bf8-51f4-9352-8f57d1b5a798")}catch{}})();var lu=100,hi=null,du=Object.freeze(pt()),bi=0;function uu(e=Date.now()){return bi+=1,`${bi}-${e}`}function wi(e,t){let n=e[t];if(n!=null)return typeof n!="string"||n.trim().length===0?null:n.trim()}function fu(e){if(e==null)return;let t=me(e);if(!t)return null;let n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i))){if(r.trim().length===0)return null;let o=t[r];if(typeof o!="string"||o.trim().length===0)return null;n[r.trim()]=o.trim()}return Object.keys(n).length>0?n:void 0}function Hn(e,t){let n=e[t];return typeof n!="string"||n.trim().length===0?null:n.trim()}function Ii(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function ge(e){if(e!=null)return typeof e!="boolean"?null:e}function mu(e){let t=Ii(e.priority);return t===void 0?lu:t}function pu(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let n=Ye(t);return n!==t.trim().toLowerCase()?null:n}function Yn(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function _u(e){if(e==null)return;let t=me(e);if(!t)return null;let n=Yn(t.source),r=Yn(t.signature),o=Yn(t.attestation),i=t.verified===void 0||t.verified===null?void 0:typeof t.verified=="boolean"?t.verified:null;return i===null?null:{...n?{source:n}:{},...r?{signature:r}:{},...o?{attestation:o}:{},...typeof i=="boolean"?{verified:i}:{}}}function gu(e){if(e==null)return;let t=me(e);if(!t)return null;let n=ge(t.fs_read),r=ge(t.fs_write),o=ge(t.network),i=ge(t.env_read),s=ge(t.env_write),a=ge(t.process_spawn);return[n,r,o,i,s,a].includes(null)?null:{...typeof n=="boolean"?{fs_read:n}:{},...typeof r=="boolean"?{fs_write:r}:{},...typeof o=="boolean"?{network:o}:{},...typeof i=="boolean"?{env_read:i}:{},...typeof s=="boolean"?{env_write:s}:{},...typeof a=="boolean"?{process_spawn:a}:{}}}function yu(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(n=>typeof n!="string"))return null;let t=Gr(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function hu(e){if(e==null)return;let t=me(e);if(!t)return null;let n=t.commands;if(n==null)return;if(!Array.isArray(n)||n.some(o=>typeof o!="string"))return null;let r=[...new Set(n.map(o=>S(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return r.length>0?{commands:r}:void 0}function bu(e){let t=Ii(e.manifest_version);if(t===null)return null;let n=wi(e,"pm_min_version");if(n===null)return null;let r=wi(e,"pm_max_version");if(r===null)return null;let o=fu(e.engines);if(o===null)return null;let i=ge(e.trusted);if(i===null)return null;let s=pu(e);if(s===null)return null;let a=_u(e.provenance);if(a===null)return null;let c=gu(e.permissions);if(c===null)return null;let l=yu(e.capabilities);if(l===null)return null;let d=hu(e.activation);if(d===null)return null;let u=ln(e.contributions);return u===null?null:{manifest_version:t,pm_min_version:n,pm_max_version:r,engines:o,trusted:i,sandbox_profile:s,provenance:a,permissions:c,capabilities:l.capabilities,legacy_capability_aliases:l.legacy_aliases,activation:d,contributions:u}}function wu(e){if(typeof e!="object"||e===null)return null;let t=e,n=Hn(t,"name");if(n===null)return null;let r=Hn(t,"version");if(r===null)return null;let o=Hn(t,"entry");if(o===null)return null;let i=mu(t);if(i===null)return null;let s=bu(t);return s===null?null:{name:n,version:r,entry:o,priority:i,manifest_version:s.manifest_version,pm_min_version:s.pm_min_version,pm_max_version:s.pm_max_version,engines:s.engines,trusted:s.trusted,provenance:s.provenance,sandbox_profile:s.sandbox_profile,permissions:s.permissions,activation:s.activation,contributions:s.contributions,capabilities:s.capabilities,legacy_capability_aliases:s.legacy_capability_aliases.length>0?s.legacy_capability_aliases:void 0}}function vu(e,t,n){return n.has(e)?!1:t.size===0?!0:t.has(e)}async function Eu(e,t){let[n,r]=await Promise.all([he.realpath(e),he.realpath(t)]);return bn(n,r)}function ku(e,t=process.cwd()){return{global:ye.join(Eo(t),"extensions"),project:ye.join(e,"extensions")}}async function Ou(e){try{return(await he.readdir(e,{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>n.name).sort((n,r)=>n.localeCompare(r))}catch{return[]}}function Su(e){let t={layer:e.layer,directory:e.directory,manifest_path:e.manifest_path,name:e.manifest.name,version:e.manifest.version,entry:e.manifest.entry,priority:e.manifest.priority,entry_path:e.entry_path,manifest_version:e.manifest.manifest_version,pm_min_version:e.manifest.pm_min_version,pm_max_version:e.manifest.pm_max_version,engines:e.manifest.engines,trusted:e.manifest.trusted,provenance:e.manifest.provenance,sandbox_profile:e.manifest.sandbox_profile,permissions:e.manifest.permissions,capabilities:[...e.manifest.capabilities],activation:e.manifest.activation?{commands:[...e.manifest.activation.commands]}:void 0,contributions:e.manifest.contributions??e.contributions};return e.source_package&&(t.source_package=e.source_package),e.source_aliases&&(t.source_aliases=[...e.source_aliases]),t}function vi(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function Au(e){let t=new Map;try{let n=JSON.parse(await he.readFile(ye.join(e,".managed-extensions.json"),"utf8")),o=me(n)?.entries;if(!Array.isArray(o))return t;for(let i of o){if(typeof i!="object"||i===null)continue;let s=i,a=vi(s.source?.package),c=[s.source?.input,s.source?.name,a].map(u=>vi(u)).filter(u=>u!==void 0),l=ln(s.contributions),d={aliases:[...new Set(c)],...a?{package_name:a}:{},...l?{contributions:l}:{}};typeof s.directory=="string"&&s.directory.trim().length>0&&t.set(`directory:${s.directory.trim()}`,d),typeof s.name=="string"&&s.name.trim().length>0&&t.set(`name:${s.name.trim()}`,d)}}catch{return t}return t}function Ei(e){return[...e].sort((t,n)=>{if(t.manifest.priority!==n.manifest.priority)return t.manifest.priority-n.manifest.priority;let r=t.manifest.name.localeCompare(n.manifest.name);return r!==0?r:t.directory.localeCompare(n.directory)})}function Tu(e,t){let n=[...Ei(e),...Ei(t)],r=[];for(let o of n){let i=r.findIndex(s=>s.manifest.name===o.manifest.name);i>=0&&r.splice(i,1),r.push(o)}return r}async function ki(e,t,n,r,o){let i=[],s=[],a=[],c=await Ou(t),l=await Au(t);for(let d of c){let u=await Ru(e,t,d,n,r,l,o);i.push(u.diagnostic),s.push(...u.warnings),u.candidate&&a.push(u.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function Cu(){return{diagnostics:[],warnings:[],candidates:[]}}function Oi(e,t,n,r){return{diagnostic:{layer:e,directory:t,manifest_path:n,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[r],candidate:null}}function Iu(e,t,n,r,o,i,s){let a=Mr(e,t,n);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&a.push(Hr(e,t.name,t.legacy_capability_aliases));for(let c of Wr(t.capabilities))a.push(Kr(e,t.name,c));return r?o||a.push(`extension_entry_missing:${e}:${t.name}`):a.push(`extension_entry_outside_extension:${e}:${t.name}`),i.warning&&a.push(i.warning),s.warning&&a.push(s.warning),a}async function Ru(e,t,n,r,o,i,s){let a=ye.join(t,n),c=ye.join(a,"manifest.json");if(!await hn(c))return Oi(e,n,c,`extension_manifest_missing:${e}:${n}`);let l,d;try{let ct=JSON.parse(await he.readFile(c,"utf8"));d=me(ct),l=wu(ct)}catch{d=null,l=null}if(!l||!d)return Oi(e,n,c,`extension_manifest_invalid:${e}:${n}`);let u=ye.resolve(a,l.entry),m=bn(a,u),f=m?await hn(u):!1,p=m&&f?await Eu(a,u):m,_=vu(l.name,r,o),g=await Du(e,l),w=await Mu(e,l,s),v=Iu(e,l,d,p,f,g,w),R=p&&f&&g.allowed&&w.allowed,Cr=i.get(`directory:${n}`)??i.get(`name:${l.name}`);return{diagnostic:{layer:e,directory:n,manifest_path:c,name:l.name,version:l.version,entry:l.entry,priority:l.priority,entry_path:u,enabled:_,status:R?"ok":"warn"},warnings:v,candidate:ui({layer:e,directory:n,manifestPath:c,entryPath:u,manifest:l,sourceIdentity:Cr,extensionReady:R,enabledForLoad:_})}}async function xu(e){let t=ku(e.pmRoot,e.cwd??process.cwd()),n=Be(e.settings.extensions.enabled),r=Be(e.settings.extensions.disabled),o=Qo(e.settings),i=Zo(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:n,configured_disabled:r,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(n),a=new Set(r),c=e.ignoreGlobalExtensions===!0?Cu():await ki("global",t.global,s,a,o.pmMaxVersionExceededMode.global),l=await ki("project",t.project,s,a,o.pmMaxVersionExceededMode.project),d=[...o.warnings],u=Tu(c.candidates,l.candidates),m=[];for(let f of u){let p={layer:f.layer,name:f.manifest.name,trusted:f.manifest.trusted===!0,provenanceVerified:f.manifest.provenance?.verified===!0,sandboxProfile:f.manifest.sandbox_profile,permissions:f.manifest.permissions&&typeof f.manifest.permissions=="object"?{fs_read:f.manifest.permissions.fs_read,fs_write:f.manifest.permissions.fs_write,network:f.manifest.permissions.network,env_read:f.manifest.permissions.env_read,env_write:f.manifest.permissions.env_write,process_spawn:f.manifest.permissions.process_spawn}:void 0},_=ni(o,p);if(_.warning&&d.push(_.warning),!!_.allowed){for(let g of f.manifest.capabilities){let w=ri(o,p,g);w.warning&&d.push(w.warning)}m.push(Su(f))}}return{disabled_by_flag:!1,roots:t,configured_enabled:n,configured_disabled:r,discovered:[...c.diagnostics,...l.diagnostics],effective:m,warnings:[...new Set([...c.warnings,...l.warnings,...d])],policy:i}}function Dt(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function Nu(){try{let e=En(import.meta.url,["../../.."]),t=await he.readFile(ye.join(e,"package.json"),"utf8"),n=JSON.parse(t);return typeof n.version=="string"&&n.version.trim().length>0?n.version.trim():null}catch{return null}}function Ri(){return hi??=Nu(),hi}function xi(e,t,n){let r=n.current??"unknown";if(n.kind==="pm_min_version")switch(n.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${t.name}:required=${n.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${t.name}:required=${n.required}:current=${r}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${t.name}:required=${n.required}:current=${r}`;default:return}switch(n.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${t.name}:allowed=${n.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${t.name}:allowed=${n.required}:current=${r}`;default:return}}async function Du(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let n=Go(t.pm_min_version,await Ri()),r=xi(e,t,n);return r?{allowed:n.allowed,warning:r}:{allowed:n.allowed}}async function Mu(e,t,n){if(t.pm_max_version===void 0)return{allowed:!0};let r=Ko(t.pm_max_version,await Ri(),n),o=xi(e,t,r);return o?{allowed:r.allowed,warning:o}:{allowed:r.allowed}}async function Si(e){try{let t=await he.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function Pu(e,t){let n=e.entry_path;t.module_graph_snapshot_root&&(n=await Po(t.module_graph_snapshot_root,e));let r=new URL(cu(n).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return r.href;let[i,s]=await Promise.all([Si(e.entry_path),Si(e.manifest_path)]),a=t.reload_token??uu();return r.searchParams.set("pm_ext_reload",a),r.searchParams.set("pm_ext_entry",i),r.searchParams.set("pm_ext_manifest",s),r.href}async function Ib(e){let t=await xu(e),n=[],r=[],o=[...t.warnings];if(t.disabled_by_flag)return{...t,warnings:o,loaded:n,failed:r};let i=typeof e.extensionFilter=="function"?t.effective.filter(e.extensionFilter):t.effective;for(let s of i)try{let c=await import(await Pu(s,e));n.push({...s,module:c})}catch(a){o.push(`extension_load_failed:${s.layer}:${s.name}`),r.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:Dt(a)})}return{...t,warnings:o,loaded:n,failed:r}}var Ai=5e3,$u=2147483647;function Lu(e){let n={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let r=e.deactivate;n.deactivate=r.bind(e)}return n}function Ni(e){let t=To(e);return t?Lu(t):null}async function Rb(e,t,n={}){let r=ju(n?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(d=>`${d.layer}:${d.name}`)),i=[];for(let d of e.loaded){if(o.has(`${d.layer}:${d.name}`))continue;let u=Ni(d.module);!u||typeof u.deactivate!="function"||i.push({extension:d,deactivate:u.deactivate})}let s=await Promise.all(i.map(async({extension:d,deactivate:u})=>{try{return await Fu(u,r),{ok:!0}}catch(m){return{ok:!1,layer:d.layer,name:d.name,error:Dt(m)}}})),a=[],c=[],l=0;for(let d of s){if(d.ok){l+=1;continue}a.push(`extension_deactivate_failed:${d.layer}:${d.name}`),c.push({layer:d.layer,name:d.name,error:d.error})}return{deactivated:l,warnings:a,failed:c}}function ju(e){return typeof e!="number"||e<0?Ai:e===0||e===1/0?0:Number.isFinite(e)?Math.min($u,Math.max(1,Math.floor(e))):Ai}async function Fu(e,t){if(t===0){await e();return}let n;try{let r=Promise.resolve().then(()=>e());r.catch(()=>{}),await Promise.race([r,new Promise((o,i)=>{n=setTimeout(()=>{i(new Error(`extension deactivate timed out after ${t}ms`))},t),n.unref?.()})])}finally{clearTimeout(n)}}var Uu=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","visible"]);function Xn(e,t){return xt(e,t).map(n=>(n.repeatable===!0&&(n.list=!0),n))}function zu(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function Ti(e,t){if(t===void 0)return e.replace(/\s+/g,"-");if(typeof t!="string"||t.trim().length===0)throw new TypeError("registerCommand definition.action must be a non-empty string when provided");let n=zu(t);if(n.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return n}function Ci(e){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("registerCommand definition.arguments must be an array when provided");let t=[];for(let[r,o]of e.entries()){let i=x(`registerCommand definition.arguments[${r}]`,o),s=$(`registerCommand definition.arguments[${r}].name`,i.name);if(D(`registerCommand definition.arguments[${r}].required`,i.required),D(`registerCommand definition.arguments[${r}].variadic`,i.variadic),A(`registerCommand definition.arguments[${r}].description`,i.description),s.includes(" "))throw new TypeError(`registerCommand definition.arguments[${r}].name must not contain spaces`);let a={name:s};i.required===!0&&(a.required=!0),i.variadic===!0&&(a.variadic=!0),typeof i.description=="string"&&(a.description=i.description.trim()),t.push(a)}let n=t.map((r,o)=>r.variadic?o:-1).filter(r=>r>=0);if(n.length>1)throw new TypeError("registerCommand definition.arguments supports at most one variadic argument");if(n.length===1&&n[0]!==t.length-1)throw new TypeError("registerCommand definition.arguments variadic argument must be the final argument");return t}function Jn(e){if(!Array.isArray(e))throw new TypeError("registerFlags flags requires an array of object definitions");for(let[t,n]of e.entries()){let r=x(`registerFlags flags[${t}]`,n),o=Object.keys(r).filter(c=>!Uu.has(c)).sort((c,l)=>c.localeCompare(l));if(o.length>0)throw new TypeError(`registerFlags flags[${t}] contains unknown field(s): ${o.join(", ")}`);let i=r.long,s=r.short;if(i===void 0&&s===void 0)throw new TypeError(`registerFlags flags[${t}] requires at least one of long or short`);A(`registerFlags flags[${t}].long`,i),A(`registerFlags flags[${t}].short`,s);let a=Bo(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${Vo(a.token,a.failure)}`);if(A(`registerFlags flags[${t}].value_name`,r.value_name),A(`registerFlags flags[${t}].description`,r.description),D(`registerFlags flags[${t}].required`,r.required),D(`registerFlags flags[${t}].enabled`,r.enabled),D(`registerFlags flags[${t}].visible`,r.visible),D(`registerFlags flags[${t}].list`,r.list),D(`registerFlags flags[${t}].repeatable`,r.repeatable),r.list!==void 0&&r.repeatable!==void 0&&r.list!==r.repeatable)throw new TypeError(`registerFlags flags[${t}].list and repeatable must match when both are provided`);if(Uo(`registerFlags flags[${t}].default`,r.default),Array.isArray(r.default)&&r.list!==!0&&r.repeatable!==!0)throw new TypeError(`registerFlags flags[${t}].default cannot be an array unless list is true.`);qu(`registerFlags flags[${t}]`,r)}}function qu(e,t){let n=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0);if(n===void 0)return;let r=Co(n);if(r===null)throw new TypeError(`${e} value_type "${n}" is not a known flag value type (expected one of: string, number, boolean).`);if(t.default===void 0)return;let o=t.list===!0||t.repeatable===!0?Io(t.default):[t.default];for(let[i,s]of o.entries())if(!Ro(s,r)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${r}.`)}}function Bu(e){if(!Array.isArray(e))throw new TypeError("registerItemFields fields requires an array of object definitions");for(let[t,n]of e.entries()){let r=x(`registerItemFields fields[${t}]`,n);$(`registerItemFields fields[${t}].name`,r.name);let o=$(`registerItemFields fields[${t}].type`,r.type);if(xo(o)===null){let i=No(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${Ct.join(", ")}).${s}`)}D(`registerItemFields fields[${t}].optional`,r.optional)}}function Vu(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].command_option_policies`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=x(i,o);$(`${i}.command`,s.command),$(`${i}.option`,s.option),D(`${i}.enabled`,s.enabled),D(`${i}.required`,s.required),D(`${i}.visible`,s.visible)}}function Wu(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].options`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=x(i,o);$(`${i}.key`,s.key),pe(`${i}.values`,s.values),D(`${i}.required`,s.required),pe(`${i}.aliases`,s.aliases)}}function Gu(e){if(!Array.isArray(e))throw new TypeError("registerItemTypes types requires an array of object definitions");for(let[t,n]of e.entries()){let r=`registerItemTypes types[${t}]`,o=x(r,n);$(`${r}.name`,o.name),A(`${r}.folder`,o.folder),pe(`${r}.aliases`,o.aliases),pe(`${r}.required_create_fields`,o.required_create_fields),pe(`${r}.required_create_repeatables`,o.required_create_repeatables),Vu(t,o.command_option_policies),Wu(t,o.options)}}function Ku(e){let t=x("registerMigration definition",e);if(t.id!==void 0&&typeof t.id!="string")throw new TypeError("registerMigration definition.id must be a string when provided");if(t.description!==void 0&&typeof t.description!="string")throw new TypeError("registerMigration definition.description must be a string when provided");if(t.status!==void 0&&typeof t.status!="string")throw new TypeError("registerMigration definition.status must be a string when provided");if(D("registerMigration definition.mandatory",t.mandatory),t.run!==void 0&&typeof t.run!="function")throw new TypeError("registerMigration definition.run must be a function when provided")}var Di=["types","statuses","fields","workflows","config","templates","packages"],Hu={types:(e,t)=>{if(t.name!==void 0&&typeof t.name!="string")throw new TypeError(`${e}.name must be a string when provided`)},workflows:(e,t)=>{if(typeof t.type!="string")throw new TypeError(`${e}.type must be a string`);if(!Array.isArray(t.allowed_transitions))throw new TypeError(`${e}.allowed_transitions must be an array`);for(let[n,r]of t.allowed_transitions.entries())if(!Array.isArray(r))throw new TypeError(`${e}.allowed_transitions[${n}] must be a [from, to] array`)},templates:(e,t)=>{if(typeof t.name!="string")throw new TypeError(`${e}.name must be a string`);if(typeof t.options!="object"||t.options===null||Array.isArray(t.options))throw new TypeError(`${e}.options must be an object`)},packages:(e,t)=>{if(typeof t.spec!="string")throw new TypeError(`${e}.spec must be a string`)}};function Yu(e){let t=x("registerProfile profile",e);if($("registerProfile profile.name",t.name),$("registerProfile profile.title",t.title),t.summary!==void 0&&typeof t.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let n of Di){let r=t[n];if(r!==void 0){if(!Array.isArray(r))throw new TypeError(`registerProfile profile.${n} must be an array when provided`);for(let[o,i]of r.entries()){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError(`registerProfile profile.${n}[${o}] must be an object`);Hu[n]?.(`registerProfile profile.${n}[${o}]`,i)}}}}function Xu(e){e.summary===void 0&&(e.summary="");for(let t of Di)e[t]===void 0&&(e[t]=[]);return e}function Ju(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let n of e.capabilities){let r=n.trim().toLowerCase();X(r)&&t.add(r)}return t}function k(e,t,n){let r=Ju(e);if(r!==null&&!r.has(t))throw G(`${n} requires capability '${t}' in extension manifest capabilities`,{method:n,registration_index:-1,capability:t,missing_capability:t,expected_schema:`"capabilities": [..., "${t}"]`,received:e.capabilities,hint:`Add "${t}" to ${e.name} manifest capabilities, or remove the ${n} registration call.`})}function Qu(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>q.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function Zu(e){return{layer:e.layer,name:e.name,trusted:e.trusted===!0,provenanceVerified:e.provenance?.verified===!0,sandboxProfile:e.sandbox_profile,permissions:e.permissions&&typeof e.permissions=="object"?{fs_read:e.permissions.fs_read,fs_write:e.permissions.fs_write,network:e.permissions.network,env_read:e.permissions.env_read,env_write:e.permissions.env_write,process_spawn:e.permissions.process_spawn}:void 0}}var Qn=class{extension;hooks;#e;#n;#o;#r;#s;#a;#i;#c;#t;#l;#d;#u;constructor(t,n,r,o,i,s,a,c,l,d,u){this.#e=t,this.extension=Qu(t),this.#n=Zu(t),this.#o=n,this.#r=r,this.#s=o,this.#a=i,this.#i=s,this.#c=a,this.#t=c,this.#l=l,this.#d=d,this.#u=u,this.registerCommand=this.registerCommand.bind(this),this.registerParser=this.registerParser.bind(this),this.registerPreflight=this.registerPreflight.bind(this),this.registerService=this.registerService.bind(this),this.registerFlags=this.registerFlags.bind(this),this.registerItemFields=this.registerItemFields.bind(this),this.registerItemTypes=this.registerItemTypes.bind(this),this.registerRelationshipKinds=this.registerRelationshipKinds.bind(this),this.registerMigration=this.registerMigration.bind(this),this.registerProfile=this.registerProfile.bind(this),this.registerRenderer=this.registerRenderer.bind(this),this.registerImporter=this.registerImporter.bind(this),this.registerExporter=this.registerExporter.bind(this),this.registerSearchProvider=this.registerSearchProvider.bind(this),this.registerVectorStoreAdapter=this.registerVectorStoreAdapter.bind(this),this.registerAssuranceMeasurementProvider=this.registerAssuranceMeasurementProvider.bind(this),this.hooks={beforeCommand:m=>this.registerBeforeCommand(m),beforeMutation:m=>this.registerBeforeMutation(m),afterCommand:m=>this.registerAfterCommand(m),onWrite:m=>this.registerOnWrite(m),onRead:m=>this.registerOnRead(m),onIndex:m=>this.registerOnIndex(m)}}allowRegistration(t,n,r,o){let i=oi(this.#u,this.#n,t,n,r,o);return i.warning&&this.#l.push(i.warning),i.allowed}registerCommandTrace(t,n,r,o,i){return{method:"registerCommand",registration_index:t==="override"?this.#r.overrides.length:this.#r.handlers.length,command:n,expected_schema:r,received:Xe(o),hint:i}}registerCommandOverride(t,n){let r=S(t);if(r.length===0)throw G("registerCommand requires a non-empty command name",this.registerCommandTrace("override",t,'registerCommand("<command>", (context) => unknown)',t,"Provide a non-empty command path as the first argument."));if(typeof n!="function"){let o=this.registerCommandTrace("override",r,'registerCommand("<command>", (context) => unknown)',n,"Provide a function as the second registerCommand argument.");throw G(`registerCommand requires an override function when command name is provided (command="${r}", registration_index=${o.registration_index})`,o)}this.allowRegistration("commands.override","registerCommand","commands",{command:r})&&this.#r.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}resolveCommandDefinitionRunHandler(t,n){let r=typeof t.run=="function"?t.run:void 0,o=typeof t.handler=="function"?t.handler:void 0;return!r&&o&&this.#l.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${n}`),r??o}registerCommandDefinition(t){if(typeof t!="object"||t===null)throw G("registerCommand requires a command definition object",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,'Use registerCommand({ name: "command path", run: (context) => ... }).'));if(typeof t.name!="string")throw G("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,"Set command definition.name to a non-empty string command path."));let n=S(t.name);if(n.length===0)throw G("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",t.name,"{ name: string; run: (context) => unknown; }",t,"Ensure command definition.name contains a non-empty command path."));let r=this.resolveCommandDefinitionRunHandler(t,n);if(typeof r!="function"){let o=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; }",r,"Define command definition.run as a function.");throw G(`registerCommand requires a command definition run handler (command="${n}", registration_index=${o.registration_index})`,o)}try{zo(t);let o=Ti(n,t.action);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:n,action:o}))return;let i=t.description?.trim(),s=t.intent?.trim(),a=Ke("registerCommand definition.examples",t.examples),c=Ke("registerCommand definition.failure_hints",t.failure_hints),l=Ci(t.arguments);t.flags!==void 0&&(k(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(Jn(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Xn("registerCommand definition.flags",t.flags)})));let d={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:o,examples:a,failure_hints:c,arguments:l,tier:t.tier??"standard",family:t.family??"extensions"};i&&(d.description=i),s&&(d.intent=s),this.#t.commands.push(d)}catch(o){let i=Dt(o),s=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=G(`registerCommand definition metadata invalid (command="${n}", registration_index=${s.registration_index}): ${i}`,s);this.#l.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${n}`),this.#d.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}registerCommand(t,n){if(k(this.#e,"commands","registerCommand"),typeof t=="string"){this.registerCommandOverride(t,n);return}this.registerCommandDefinition(t)}registerParser(t,n){if(k(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let r=S($("registerParser command",t));Ze("registerParser override",n),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}registerPreflight(t){if(k(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let n=Lo(t);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...n})}registerService(t,n,r={}){k(this.#e,"services","registerService");let o=String(t).trim().toLowerCase();if(!si(o))throw new TypeError(`registerService service must be one of: ${Ee.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(Ze("registerService override",n),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:n,...Fo(r)?{passThrough:!0}:{}}))}registerRenderer(t,n,r={}){if(k(this.#e,"renderers","registerRenderer"),!this.allowRegistration("renderers.override","registerRenderer","renderers"))return;if(typeof n!="function")throw new TypeError("registerRenderer requires a renderer function");let o=String(t).trim().toLowerCase();if(!ii(o))throw new Error(`registerRenderer format must be toon|json, received: ${String(t)}`);if(r.resultDiscriminator!==void 0&&typeof r.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");let i=[...new Set((r.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return S(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:o,run:n,commands:i,...r.resultDiscriminator?{resultDiscriminator:r.resultDiscriminator}:{}})}registerFlags(t,n){if(k(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let r=S($("registerFlags targetCommand",t));Jn(n);let o=Xn("registerFlags flags",n);if(o.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:o})}registerItemFields(t){if(k(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;Bu(t);let n=xt("registerItemFields fields",t);if(n.length===0)throw new TypeError("registerItemFields requires at least one field definition");this.#t.item_fields.push({layer:this.#e.layer,name:this.#e.name,fields:n})}registerItemTypes(t){if(k(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;Gu(t);let n=xt("registerItemTypes types",t);if(n.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#t.item_types.push({layer:this.#e.layer,name:this.#e.name,types:n})}registerRelationshipKinds(t){if(k(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(t))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(t.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");let n=cn();for(let o of this.#t.relationship_kinds)for(let i of o.definitions)n.register(i);let r=t.map(o=>(n.register(o),n.require(o.kind)));this.#t.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:r})}registerMigration(t){if(k(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;Ku(t);let n=Qe("registerMigration definition",t);this.#t.migrations.push(et({layer:this.#e.layer,name:this.#e.name,definition:Te("registerMigration definition",t)},n))}registerProfile(t){if(k(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let n=Je(t);Yu(n),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:Xu(n)})}registerImportExportCommandFlags(t,n,r){r.flags!==void 0&&(k(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(Jn(r.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Xn(`${t} options.flags`,r.flags)})))}applyImportExportCommandMetadata(t,n,r){if(r!==void 0&&(typeof r!="object"||r===null||Array.isArray(r)))throw new TypeError(`${t} options must be an object when provided`);let o=`${t==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,i=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...r,description:r?.description??o,arguments:r?.arguments??i},a=qo(t,s,r?.description!==void 0);A(`${t} options.action`,s.action),A(`${t} options.description`,s.description),A(`${t} options.intent`,s.intent);let c=Ti(n,s.action),l=Ke(`${t} options.examples`,s.examples),d=Ke(`${t} options.failure_hints`,s.failure_hints),u=Ci(s.arguments);this.registerImportExportCommandFlags(t,n,s);let m={layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:c,examples:l,failure_hints:d,arguments:u},f=s.description?.trim();f&&(m.description=f);let p=s.intent?.trim();return p&&(m.intent=p),this.#t.commands.push(m),a}registerImporter(t,n,r){if(k(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=jn($("registerImporter name",t));Ze("registerImporter importer",n);let i=Fn(o,"import");this.applyImportExportCommandMetadata("registerImporter",i,r),this.#t.importers.push({layer:this.#e.layer,name:this.#e.name,importer:o}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>n(Cn(s,o,"import"))})}registerExporter(t,n,r){if(k(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=jn($("registerExporter name",t));Ze("registerExporter exporter",n);let i=Fn(o,"export"),s=this.applyImportExportCommandMetadata("registerExporter",i,r);this.#t.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:o,...s===void 0?{}:{output:s}}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async a=>{let c=await n(Cn(a,o,"export"));return s?.receipt==="suppress"&&!vn(c)?lo(c):c}})}registerSearchProvider(t){if(k(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let n=Qe("registerSearchProvider provider",t);this.#t.search_providers.push(et({layer:this.#e.layer,name:this.#e.name,definition:Te("registerSearchProvider provider",t)},n))}registerVectorStoreAdapter(t){if(k(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let n=Qe("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(et({layer:this.#e.layer,name:this.#e.name,definition:Te("registerVectorStoreAdapter adapter",t)},n))}registerAssuranceMeasurementProvider(t){if(k(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(di(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let n=Qe("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(et({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:Te("registerAssuranceMeasurementProvider provider",t)},n))}registerBeforeCommand(t){k(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(_e("beforeCommand",t),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerBeforeMutation(t){k(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(_e("beforeMutation",t),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerAfterCommand(t){k(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(_e("afterCommand",t),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnWrite(t){k(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(_e("onWrite",t),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnRead(t){k(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(_e("onRead",t),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnIndex(t){k(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(_e("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function ef(e,t,n,r,o,i,s,a,c,l,d){return new Qn(e,t,n,r,o,i,s,a,c,l,d)}function tf(e){let t=e.commands.length,n=e.flags.reduce((s,a)=>s+a.flags.length,0),r=e.item_fields.reduce((s,a)=>s+a.fields.length,0),o=e.item_types.reduce((s,a)=>s+a.types.length,0),i=(e.relationship_kinds??[]).reduce((s,a)=>s+a.definitions.length,0);return{commands:t,flags:n,item_fields:r,item_types:o,...i>0?{relationship_kinds:i}:{},migrations:e.migrations.length,profiles:e.profiles.length,importers:e.importers.length,exporters:e.exporters.length,search_providers:e.search_providers.length,vector_store_adapters:e.vector_store_adapters.length,...(e.assurance_providers?.length??0)>0?{assurance_providers:e.assurance_providers.length}:{}}}function nf(e){let t=[],n=(i,s)=>{let a=new Map;for(let c of i){let l=a.get(c.command)??[];l.push(c),a.set(c.command,l)}for(let c of[...a.keys()].sort((l,d)=>l.localeCompare(d))){let l=a.get(c);if(l.length<=1)continue;let d=l[l.length-1];for(let u of l.slice(0,-1))t.push(`${s}:${c}:${d.layer}:${d.name}:${u.layer}:${u.name}`)}};n(e.handlers,"extension_command_handler_collision"),n(e.overrides,"extension_command_override_collision");let r=new Set(e.handlers.map(i=>i.command)),o=[...new Set(e.overrides.map(i=>i.command))].filter(i=>r.has(i));o.sort((i,s)=>i.localeCompare(s));for(let i of o){let s=e.handlers.filter(c=>c.command===i),a=e.overrides.filter(c=>c.command===i);for(let c of a)for(let l of s)t.push(`extension_command_override_handler_overlap:${i}:${c.layer}:${c.name}:${l.layer}:${l.name}`)}return t}function rf(e){let t=new Map;for(let r of e.overrides){let o=t.get(r.format)??[];o.push(r),t.set(r.format,o)}let n=[];for(let r of[...t.keys()].sort((o,i)=>o.localeCompare(i))){let o=t.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))i.commands?.length&&s.commands?.length&&!s.commands.some(a=>i.commands?.includes(a))||n.push(`extension_renderer_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return n}function of(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.command)??[];o.push(r),n.set(r.command,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_parser_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}var sf=new Set(["output_format"]);function af(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.service)??[];o.push(r),n.set(r.service,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1||sf.has(r))continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_service_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}async function xb(e){let t=ei(e.policy??du),n=Rt(),r=Nn(),o=Dn(),i=Mn(),s=Pn(),a=$n(),c=Ln(),l=[],d=[];for(let f of e.loaded){let p=Ni(f.module);if(!p)continue;let _=l.length,g=$o({hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await p.activate(ef(f,n,r,o,i,s,a,c,d,l,t)),l.length>_&&(g(),d.push(`extension_activation_rolled_back:${f.layer}:${f.name}`))}catch(w){g(),d.push(`extension_activate_failed:${f.layer}:${f.name}`);let v=ci(w);l.push({layer:f.layer,name:f.name,entry_path:f.entry_path,error:Dt(w),trace:v})}}let u=[...nf(r),...of(o),...jo(i),...af(s),...rf(a)],m=[...new Set([...d,...u])];return{hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c,failed:l,warnings:m,hook_counts:{before_command:n.beforeCommand.length,before_mutation:n.beforeMutation.length,after_command:n.afterCommand.length,on_write:n.onWrite.length,on_read:n.onRead.length,on_index:n.onIndex.length},command_override_count:r.overrides.length,command_handler_count:r.handlers.length,parser_override_count:o.overrides.length,preflight_override_count:i.overrides.length,service_override_count:s.overrides.length,renderer_override_count:a.overrides.length,registration_counts:tf(c)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b2cf7f56-432d-5c74-ba0f-248c42a97255")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="07566a0b-2917-5ed8-828a-d811ae48dfaf")}catch{}})();function $b(){let e=Promise.resolve(),t=new Set;return{async read(n){let r=e,o,i=new Promise(s=>{o=s});t.add(i),await r;try{return await n()}finally{t.delete(i),o()}},write(n){let o=Promise.all([e,...t]).then(()=>n());return e=o.then(()=>{},()=>{}),o}}}function cf(){let e=Promise.resolve(),t=0,n=[],r=()=>{if(t!==0)return;let o=n.splice(0);for(let i of o)i()};return{enqueue(o){t++;let i=e.then(()=>o());return e=i.then(()=>{},()=>{}).finally(()=>{t--,r()}),i},idle(){return t===0?Promise.resolve():new Promise(o=>n.push(o))}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0989270e-6969-5059-b3df-06411211f701")}catch{}})();var Ce=null,Pi=null,uf=null,ff=null,Zn=null,mf=null,$i=null,pf=null;var _f=[],Li=new df;function C(){return Li.getStore()}function qb(e){return Li.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var gf=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function Mi(e){let t=K.resolve(e);for(;;){if(lf(K.join(t,".git")))return t;let n=K.dirname(t);if(n===t)return;t=n}}function yf(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),n=Mi(t)??K.resolve(t),r=Mi(n);if(!e)return{source_workspace_root:n,...r?{repo_root:r}:{}};let o=K.relative(n,K.resolve(e)),i=o.length>0&&!o.startsWith(`..${K.sep}`)&&o!==".."&&!K.isAbsolute(o);return{source_workspace_root:n,...r?{repo_root:r}:{},...i?{pm_root_rel:o.split(K.sep).join("/")}:{}}}function Bb(e){let t=C();if(t){t.hooks=e;return}Ce=e}function Vb(e){let t=C();if(t){t.commands=e;return}Pi=e}function Wb(e){let t=C();if(t){t.parsers=e;return}uf=e}function Gb(e){let t=C();if(t){t.preflight=e;return}ff=e}function Kb(e){let t=C();if(t){t.services=e;return}Zn=e}function Hb(e){let t=C();if(t){t.renderers=e;return}mf=e}function Yb(e){let t=C();if(t){t.registrations=e;return}$i=e}function Xb(){let e=C();return e?e.registrations:$i}function Jb(e){if(!e)return;let t=C();t?t.affectedItems.push(e):_f.push(e)}function Qb(e,t){if(!e||!e.id)return{};let n={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return n;let r=e;for(let o of t){if(typeof o!="string")continue;let i=o.startsWith("unset:")?o.slice(6):o;i==="id"||i==="type"||i==="status"||gf.has(i)||Object.hasOwn(r,i)&&r[i]!==void 0&&(n[i]=r[i])}return n}async function ji(e){let t=C(),n=t?t.hooks:Ce;return n?qn(n,e):[]}async function Zb(e){let t=C(),n=t?t.hooks:Ce;n&&await zn(n,e)}async function Fi(e){let t=C(),n=t?t.hooks:Ce;return n?Bn(n,e):[]}function ew(){let e=C();return((e?e.hooks:Ce)?.onRead?.length??0)>0}async function tw(e){let t=C(),n=t?t.hooks:Ce;return n?Vn(n,e):[]}async function nw(e){let t=C(),n=t?t.commands:Pi;return n?Wn(n,{...e,...yf(e.pm_root)}):{handled:!1,result:null,warnings:[]}}function Ui(e,t){let n=C(),r=n?n.commandContext:pf;return{service:e,command:r?.command,args:r?[...r.args]:[],options:r?.options?{...r.options}:{},global:r?.global?{...r.global}:void 0,pm_root:r?.pm_root,source_workspace_root:r?.source_workspace_root,repo_root:r?.repo_root,pm_root_rel:r?.pm_root_rel,payload:t}}async function Mt(e,t){let n=C(),r=n?n.services:Zn;return r?Kn(r,Ui(e,t)):{handled:!1,result:t,warnings:[]}}function zi(e,t){let n=C(),r=n?n.services:Zn;return r?Gn(r,Ui(e,t)):{handled:!1,result:t,warnings:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6e88d6b7-aa5f-5515-8ea4-481916b12ef1")}catch{}})();var Pt="changed_fields",hf="changed_field_count",er="rows",bf=new Set(["apply","rollback"]),Wi=new Set(["deleted","would_delete"]),qi=256,Bi={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function wf(e,t){if(!L(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(Bi,e.action)?Bi[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return L(s)&&L(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let r=e[n.at(-1)],o=Ki(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,Hi(e[i],t)]))}}function Vi(e){return typeof e!="string"||e.length<=qi?e:`${e.slice(0,qi-1)}\u2026`}function vf(e){if(!L(e))return null;let t={...e};return t.reason=Vi(t.reason),L(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,Vi(r)]))),t}function L(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Gi(e){let t=e[Pt];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==Pt&&(n[r]=o);return n[hf]=t.length,n}function Ef(e){return"item"in e&&Array.isArray(e[Pt])}function kf(e){return typeof e.mode=="string"&&bf.has(e.mode)&&Array.isArray(e[er])}function Of(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[er]=t,n}function Ki(e){if(!L(e))return null;let t=L(e.item)?e.item:L(e.plan)?e.plan:null;if(t===null)return null;let n=typeof t.id=="string"?t.id:void 0,r=typeof e.outcome=="string"&&Wi.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 Sf(e){if(!L(e)||!L(e.item)||typeof e.item.id!="string")return null;let t=e[Pt];if(!Array.isArray(t))return null;let n={id:e.item.id,...typeof e.outcome=="string"&&Wi.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:t.length};return Af(e,e.item,n),n}function Af(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=vf(e.recurrence);if(o!==null&&(n.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(n.warnings=e.warnings),L(e.recovery)&&(n.recovery=e.recovery),typeof e.claimed_by=="string"||typeof e.released_by=="string")for(let i of["claimed_by","released_by","previous_assignee","forced","skipped","available","attempts","suggestions"])Object.hasOwn(e,i)&&(n[i]=e[i])}function Tf(e){let t=kf(e)?e[er]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!L(o))return o;let i=Gi(o);return i?(n=!0,i):o});return n?{projected:Of(e,r),changed:!0}:{projected:e,changed:!1}}function Hi(e,t={}){let n=wf(e,t);if(n!==null)return n;if(t.idOnly===!0){let c=Ki(e);if(c!==null)return c}if(t.compactEnvelope===!0){let c=Sf(e);if(c!==null)return c}if((t.changedFields??"full")==="full"||!L(e))return e;let o=!1,i=e,s=Ef(e)?Gi(e):null;s!==null&&(i=s,o=!0);let a=Tf(i);return a.changed&&(i=a.projected,o=!0),o?i:e}import{AsyncLocalStorage as Ym}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b18eefc1-0d1d-5c9c-b98a-b96771070301")}catch{}})();var Yi=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),Cf=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function If(e){let t=e.indexOf("=");return t>0&&Yi.has(e.slice(0,t))}function Rf(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function Xi(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(Yi.has(n)){t+=Rf(n,e[t+1])?1:0;continue}if(!(If(n)||Cf.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function lw(e){let t=Xi(e);return t===void 0?void 0:e[t].trim().toLowerCase()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4f014bd9-39b6-5017-93ed-f0e7fba8497a")}catch{}})();var Ji=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)}"`},Qi=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?Ji(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,$t=(e,t=process.platform)=>{let n=e.map(r=>Qi(r,t)).join(" ");return n.length>0?`pm ${n}`:"pm"};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="49de148c-3c60-547b-b3bc-d0a71e013dc6")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6c87b004-3647-531a-9599-d37fd91c2807")}catch{}})();var ns=new WeakMap;function yw(e,t){ns.set(e,new Set(t))}var Zi='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',xf={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"],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"}},Nf=[{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 hw(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,y.USAGE)}function V(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 bw(e,t){let n=Nf.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return V([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return V(r)}var Df=[{name:"hierarchy",restore_with:"--depth standard"},{name:"activity",restore_with:"--depth standard"},{name:"progress",restore_with:"--depth standard"},{name:"blockers",restore_with:"--depth standard"},{name:"recently_created",restore_with:"--depth standard"},{name:"unparented",restore_with:"--depth standard"},{name:"files",restore_with:"--depth deep"},{name:"workload",restore_with:"--depth standard"},{name:"staleness",restore_with:"--depth deep"},{name:"tests",restore_with:"--depth deep"},{name:"workspace_memory",restore_with:"--depth deep"}];function j(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Mf=new Set([void 0,"tabular_when_uniform"]),Pf=new Set(["collection","none"]),$f=new Set(["supported","unsupported"]);function es(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 Lf(e){return j(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Pf.has(e.row_kind)&&es(e.row_keys,!0)&&(e.continuation_row_keys===void 0||es(e.continuation_row_keys,!1))&&$f.has(e.fields)&&Mf.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 jf={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"]},Ff={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"],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 Uf(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=jf[s];if(a===void 0)return;let c=a.filter(l=>Array.isArray(t[l])||j(t[l]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Zi}:{},toon_encoding:"tabular_when_uniform"}}let o=xf[r],i=Ff[r];return o===void 0||i===void 0||!i.some(s=>Object.hasOwn(t,s))?void 0:(()=>{let s=o.row_keys.filter(a=>{let c=a.split(".").reduce((l,d)=>j(l)?l[d]:void 0,t);return Array.isArray(c)||j(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:Zi}:{},toon_encoding:"tabular_when_uniform"}})()}function zf(e){if(!j(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=>j(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 V(r,new Set(o))}function qf(e){if(!Array.isArray(e.sections_included))return;let t=V(Df,new Set(e.sections_included.filter(n=>typeof n=="string")));return j(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function Bf(e){if(!j(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=ns.get(e),i=a=>n.includes(a)||a==="body"?t:e,s=["body",...n,...r.slice(1)].filter(a=>o===void 0||o.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:`--fields ${a}`}));return V(s,new Set(s.flatMap(({name:a})=>Object.hasOwn(i(a),a)?[a]:[])))}function ts(e){if(j(e.projection))return V([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function Vf(e){if(!j(e.projection))return V([]);if(typeof e.projection.mode=="string")return V([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function Wf(e){if(!(!j(e.selected)||typeof e.selected.summary!="boolean"))return V([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function Gf(e,t){let n=zf(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return qf(t);if(r==="get")return Bf(t);if(r==="list"||r.startsWith("list-"))return ts(t);if(r==="search")return ts(t)??V([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return Vf(t);if(r==="contracts")return Wf(t)}function rs(e,t){if(e===void 0||!j(t))return t;let n=Gf(e,t),r=t.row_contract,o=Lf(r)?r:Uf(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 j(i.omission_receipt)||n===void 0?i:{...i,omission_receipt:n}}import{randomUUID as Fm}from"node:crypto";import{randomUUID as Pm}from"node:crypto";import{constants as Re}from"node:fs";import{lstat as Ts,mkdir as $m,open as Is,rename as Lm,rm as jm}from"node:fs/promises";import Ut from"node:path";import{constants as pm}from"node:fs";import U from"node:fs/promises";import Ft from"node:path";import{randomUUID as or}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="43f7bd27-7874-56f9-a497-e6f67a3ae9be")}catch{}})();function os(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import Kf from"node:crypto";import{AsyncLocalStorage as Hf}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="38ed5847-939e-5846-bc7d-6d257d36a25f")}catch{}})();var ss=new Hf,is=1024;function as(){let e=ss.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 Ow(e){let t=ss.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>is)throw new Error(`Reproducible token length must be an integer between 0 and ${is}`);let n="";for(;n.length<e;){let r=Kf.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]="a5bd8db9-cd23-5529-ad78-b7e87bd43b59")}catch{}})();var Yf=/^([+-]?)(\d+)([hdwm])$/i,Xf=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,Jf=/^(\d{4})(\d{2})(\d{2})$/,Qf=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Zf=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,em=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,tm=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function ls(){return as()??new Date().toISOString()}function Rw(e){return Number.isFinite(Date.parse(e))}function nm(e){let t=tm.exec(e);if(!t||!Number.isFinite(Date.parse(e)))return!1;let[,n,r,o,i,s,a,c,l]=t,[d,u,m,f,p,_]=[n,r,o,i,s,a].map(Number);return u>=1&&u<=12&&m>=1&&m<=rr(d,u-1)&&f<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(l===void 0||Number(l)<=59)}function xw(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return nm(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var rm=1e4,Lt=new Map;function cs(e){let t=Lt.get(e);if(t!==void 0)return t;let n=Date.parse(e);return Lt.size>=rm&&os(Lt),Lt.set(e,n),n}function Ie(e,t){let n=cs(e),r=cs(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function Nw(e,t){return!(t.deadlineBefore&&(!e.deadline||Ie(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||Ie(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&Ie(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&Ie(e.updated_at,t.updatedBefore)>0||t.createdAfter&&Ie(e.created_at,t.createdAfter)<0||t.createdBefore&&Ie(e.created_at,t.createdBefore)>0)}function tr(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function nr(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 om(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function im(e){let t=[],n=l=>om(t,e,l),r=Jf.exec(e);if(r){let[,l,d,u]=r;n(`${l}-${d}-${u}`)}let o=Qf.exec(e);if(o){let[,l,d,u,m,f,p,_,g]=o,w=p?`:${p}`:"";n(`${l}-${d}-${u}T${m}:${f}${w}${tr(_)}${nr(g)}`)}let i=Zf.exec(e);if(i){let[,l,d,u,m,f,p]=i,_=m?`:${m}`:"";n(`${l}T${d}:${u}${_}${tr(f)}${nr(p)}`)}let s=em.exec(e);if(s){let[,l,d,u,m,f,p]=s,_=m?`:${m}`:"";n(`${l}T${d}:${u}${_}${tr(f)}${nr(p)}`)}let a=10,c=e.slice(0,a);if(am(c)){let l=a;for(;l<e.length&&cm(e[l]);)l+=1;l<e.length&&n(`${c}T${e.slice(l)}`)}return t}function sm(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of im(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function am(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 cm(e){return e?e===" "||e===" "||e===`
9
+ `||e==="\r"||e==="\f"||e==="\v":!1}function rr(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var lm=["January","February","March","April","May","June","July","August","September","October","November","December"],dm=/^(\d{4})-(\d{2})-(\d{2})/,um=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function fm(e,t,n){let r=dm.exec(t)??um.exec(t);if(!r)return;let o=Number.parseInt(r[1],10),i=Number.parseInt(r[2],10),s=Number.parseInt(r[3],10),a=n?.trim()||"deadline";if(i<1||i>12)throw new h(`Invalid ${a} value "${e}". Month "${r[2]}" is out of range \u2014 use a month between 01 and 12.`,y.USAGE);let c=rr(o,i-1);if(s<1||s>c)throw new h(`Invalid ${a} value "${e}". ${lm[i-1]} ${o} has ${c} days, so day "${r[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,y.USAGE)}function mm(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,rr(i,s));return n.setUTCFullYear(i,s,a),n}function Dw(e,t=new Date,n="deadline"){let r=e.trim();if(r.toLowerCase()==="now")return t.toISOString();let o=Yf.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 mm(t,a).toISOString();let l=c==="h"?3600*1e3:c==="d"?1440*60*1e3:10080*60*1e3;return new Date(t.getTime()+a*l).toISOString()}fm(e,r,n);let i=sm(r);if(!Number.isFinite(i)){let s=n.trim().length>0?n.trim():"deadline",a=Xf.test(r)?"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.":'Use ISO/date string input, "now", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';throw new h(`Invalid ${s} value "${e}". ${a}`,y.USAGE)}return new Date(i).toISOString()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="962659bb-37dc-52fa-9d07-6216d34c0d53")}catch{}})();function _m(e){let t;try{t=JSON.parse(e)}catch{return{info:null,warnings:["lock_info_invalid_json"]}}if(typeof t!="object"||t===null||Array.isArray(t))return{info:null,warnings:["lock_info_invalid_shape"]};let n=t,r=n.id,o=n.pid,i=n.owner,s=n.token,a=n.created_at,c=n.ttl_seconds;return typeof r!="string"||typeof o!="number"||!Number.isFinite(o)||typeof i!="string"||s!==void 0&&(typeof s!="string"||s.trim().length===0)||typeof a!="string"||typeof c!="number"||!Number.isFinite(c)?{info:null,warnings:["lock_info_invalid_shape"]}:{info:{id:r,pid:o,owner:i,...typeof s=="string"?{token:s}:{},created_at:a,ttl_seconds:c},warnings:[]}}async function jt(e,t=!0){try{let n=await U.readFile(e,"utf8");return t&&await Fi({path:e,scope:"project"}),_m(n)}catch(n){return fe(n)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function H(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function gm(e,t,n=process.platform){if(H(e,"EEXIST"))return!0;if(!H(e,"EPERM")&&!H(e,"EACCES")&&!H(e,"EBUSY"))return!1;try{return await U.lstat(t),!0}catch(r){if(n!=="win32"||!fe(r)&&!H(r,"EPERM")&&!H(r,"EACCES")&&!H(r,"EBUSY"))return!1}try{return await U.access(Ft.dirname(t),pm.W_OK),!0}catch{return!1}}async function _s(e,t){await ji({path:e,scope:"project",op:t})}function ym(e,t,n,r=or()){return{id:e,pid:process.pid,owner:t,token:r,created_at:ls(),ttl_seconds:n}}async function hm(e,t,n,r,o){await U.mkdir(Ft.dirname(e),{recursive:!0});let i=await U.open(e,"wx");try{await i.writeFile(`${JSON.stringify(ym(t,n,r,o),null,2)}
10
+ `,"utf8")}finally{await i.close()}await _s(e,"lock:create")}async function gs(e,t){try{return await U.unlink(e),await _s(e,t),!0}catch{return!1}}async function bm(e,t,n,r){let o=Date.now(),i=hs;for(;;){let s=await Ss(e,t);if(s!==null){try{let l=await jt(e,!1);ds(l.info,t,n,r)&&await gs(e,"lock:release")}finally{await s()}return}let a=await jt(e,!1);if(!ds(a.info,t,n,r))return;let c=Date.now()-o;if(c>=us)return;await vs(Math.min(i,us-c)),i=Math.min(i*2,ir)}}function ds(e,t,n,r){return e?.id===t&&e.pid===process.pid&&e.owner===n&&e.token===r}function ys(e,t){let n=e?.created_at?Date.parse(e.created_at):Number.NaN;return(Number.isFinite(n)?Date.now()-n:Number.POSITIVE_INFINITY)>t*1e3}function wm(e){return e?.owner?` (owner ${e.owner})`:""}var hs=25,ir=200,vm=250,Em=3,km=".stale-cleanup",bs="owner.json",ws=1e4,us=ws+ir,Om=60*6e4;function fs(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 Sm(e){let t=process.env.PM_LOCK_WAIT_MS,n=fs(t);if(n!==void 0)return n;let r=fs(e);return r!==void 0?r:0}function vs(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(n=>setTimeout(n,t))}function Es(e,t,n){let r=n>0?` after waiting ${n}ms`:"";return new h(`Item ${e} is locked${wm(t)}${r}`,y.CONFLICT,{code:"lock_conflict",recovery:{retry_after_ms:vm}})}function Am(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 Tm(e,t,n,r){if(!n&&r){let o=t.warnings.length>0?` (${t.warnings.join(",")})`:"";throw new h(`Item ${e} lock is stale${o}; rerun with --force when supported for this command`,y.CONFLICT)}}function Cm(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null||Array.isArray(t))return null;let n=t,r=n.pid,o=n.token,i=n.process_start_identity;return typeof r!="number"||!Number.isInteger(r)||r<=0||typeof o!="string"||o.length===0||i!==void 0&&(typeof i!="string"||!/^\d+$/u.test(i))?null:{pid:r,token:o,...typeof i=="string"?{process_start_identity:i}:{}}}async function ks(e){try{return Cm(await U.readFile(Ft.join(e,bs),"utf8"))}catch{return null}}function Im(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!H(t,"ESRCH")}}function Rm(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 Os(e){try{return Rm(await U.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function xm(e=process.pid){let t=await Os(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function Nm(e,t,n){if(!Im(e.pid))return!1;let r=await Os(e.pid);return e.process_start_identity!==void 0&&r!==null?r===e.process_start_identity:t<=n}async function sr(e){try{return await U.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function ms(e,t){let n=await ks(e);n===null||n.token!==t||await sr(e)}async function ps(e){try{await U.mkdir(e)}catch(n){return H(n,"EEXIST"),null}let t={...await xm(),token:or()};try{await U.writeFile(Ft.join(e,bs),`${JSON.stringify(t)}
11
+ `,"utf8")}catch{return await sr(e),null}return t}async function Dm(e){let t;try{let r=await U.stat(e);if(t=Date.now()-r.mtimeMs,t<=ws)return!1}catch(r){return fe(r)}let n=await ks(e);return n!==null&&await Nm(n,t,Om)?!1:sr(e)}async function Ss(e,t){let n=`${e}${km}`,r=await ps(n);if(r!==null)return async()=>ms(n,r.token);if(!await Dm(n))return null;let o=await ps(n);return o===null?null:async()=>ms(n,o.token)}async function Mm(e){let t=await Ss(e.lockPath,e.id);if(t===null)return{lockInfo:e.fallbackLockInfo,shouldRetryCreate:!1,staleRemovalCounted:!1};try{let n=await jt(e.lockPath);if(n.info===null&&n.warnings.length===0)return{lockInfo:n,shouldRetryCreate:!0,staleRemovalCounted:!1};if(!ys(n.info,e.ttlSeconds))return{lockInfo:n,shouldRetryCreate:!1,staleRemovalCounted:!1};if(Tm(e.id,n,e.force,e.forceRequiredForStaleLock),e.staleRemovals>=Em)throw Es(e.id,n.info,Date.now()-e.startedAtMs);return{lockInfo:n,shouldRetryCreate:await gs(e.lockPath,"lock:stale_remove"),staleRemovalCounted:!0}}finally{await t()}}async function As(e,t,n,r,o=!1,i=!0,s){let a=await Mt("lock_acquire",{pm_root:e,id:t,ttl_seconds:n,owner:r,force:o,force_required_for_stale_lock:i});if(a.handled){let p=Am(a.result);if(p)return async()=>{await Promise.resolve(p()),await Mt("lock_release",{pm_root:e,id:t,owner:r})}}let c=ko(e,t),l=Sm(s),d=Date.now(),u=0,m=hs,f=or();for(;;)try{return await hm(c,t,r,n,f),async()=>{await bm(c,t,r,f),await Mt("lock_release",{pm_root:e,id:t,owner:r})}}catch(p){if(!await gm(p,c))throw new h(`Failed to acquire lock for ${t}: ${So(p)}`,y.GENERIC_FAILURE);let _=await jt(c);if(ys(_.info,n)){let w=await Mm({lockPath:c,id:t,ttlSeconds:n,force:o,forceRequiredForStaleLock:i,staleRemovals:u,waitBudgetMs:l,startedAtMs:d,fallbackLockInfo:_});if(_=w.lockInfo,w.staleRemovalCounted&&(u+=1),w.shouldRetryCreate)continue}let g=Date.now()-d;if(l===0||g>=l)throw Es(t,_.info,l===0?0:g);await vs(Math.min(m,l-g)),m=Math.min(m*2,ir)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="72eb01a9-e8b8-59cd-b178-3c594d3faff9")}catch{}})();var Y={max_serving_rows:256,max_bytes:262144,max_event_bytes:32768,retained_byte_fraction:.5,max_events:2048,retention_days:30},I=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function be(e){let t=Date.parse(e.now??new Date().toISOString());if(!Number.isFinite(t))throw new I("Context usage now must be a valid timestamp");return{iso:new Date(t).toISOString(),ms:t}}function Rs(e){let t=e.maxBytes??Y.max_bytes,n=e.maxEvents??Y.max_events,r=e.retentionDays??Y.retention_days;if(!Number.isSafeInteger(t)||t<1024||t>Y.max_bytes||!Number.isSafeInteger(n)||n<1||!Number.isFinite(r)||r<=0)throw new I("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");return{maxBytes:t,maxEvents:n,cutoff:be(e).ms-r*864e5}}async function xs(e,t){if(!(await Ts(Ut.dirname(e))).isDirectory())throw new I("Context usage runtime must be a real directory");try{if((await Ts(e)).isSymbolicLink())throw new I("Context usage ledger must not be a symbolic link")}catch(r){if(!fe(r))throw r}let n=await Is(e,t|Re.O_NOFOLLOW|Re.O_NONBLOCK,384);try{let r=await n.stat();if(!r.isFile()||r.nlink!==1)throw new I("Context usage ledger must be an unshared regular file");return n}catch(r){throw await n.close(),r}}async function zt(e){let t=Rs(e);try{let n=await xs(Ut.join(e.pmRoot,"runtime","context-usage.jsonl"),Re.O_RDONLY);try{let r=(await n.stat()).size,o=Math.max(0,r-t.maxBytes),i=Buffer.alloc(Math.min(r,t.maxBytes)),{bytesRead:s}=await n.read(i,0,i.length,o),a=i.subarray(0,s).toString("utf8");return(o>0?a.includes(`
12
12
  `)?a.slice(a.indexOf(`
13
13
  `)+1):"":a).split(`
14
- `).flatMap(l=>{try{let d=JSON.parse(l);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await n.close()}}catch{return[]}}function ks(e,t,n){let r=[],o=0;for(let i=e.length-1;i>=0&&r.length<n;i-=1){let s=`${JSON.stringify(e[i])}
15
- `;if(o+=Buffer.byteLength(s),o>t)break;r.push(s)}return r.reverse().join("")}async function tt(e,t,n){let r=Ss(e),o=Ft.join(e.pmRoot,"runtime","context-usage.jsonl"),i=Math.floor(r.maxBytes*Y.retained_byte_fraction),s=Math.min(Y.max_event_bytes,i);if(t.some(m=>Buffer.byteLength(`${JSON.stringify(m)}
16
- `)>s))throw new I("Context usage event exceeds the declared byte ceiling");let a=t.filter(m=>Date.parse(m.at)>=r.cutoff),c=ks(a,i,r.maxEvents),l=performance.now(),d=await vs(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),u=performance.now()-l;try{await Mm(Ft.dirname(o),{recursive:!0});let m=await As(o,Re.O_WRONLY|Re.O_CREAT|Re.O_APPEND);try{let f=(await m.stat()).size,p=n===void 0?void 0:await Ut(e);if(p?.some(R=>R.kind==="delivery"&&R.serve_id===n))return{written_bytes:0,ledger_bytes:f,compacted:!1,lock_wait_ms:u};if(!(e.maxEvents!==void 0||e.retentionDays!==void 0)&&f+Buffer.byteLength(c)<=r.maxBytes)return await m.writeFile(c,"utf8"),{written_bytes:Buffer.byteLength(c),ledger_bytes:f+Buffer.byteLength(c),compacted:!1,lock_wait_ms:u};let g=ks([...p??await Ut(e),...a],i,r.maxEvents),w=`${o}.${process.pid}.${Dm()}.tmp`,v=await Os(w,"wx",384);try{try{await v.writeFile(g,"utf8")}finally{await v.close()}return await m.close(),m=void 0,await Pm(w,o),{written_bytes:Buffer.byteLength(g),ledger_bytes:Buffer.byteLength(g),compacted:!0,lock_wait_ms:u}}finally{await $m(w,{force:!0})}}finally{await m?.close()}}finally{await d()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3b38d564-6034-54ae-ad24-eddba01a2c5c")}catch{}})();var jm=864e5,zt=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function N(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Zw(e,t){let n=N(e);n!==null&&t!==null&&(n[zt]=t)}function qt(e,t){let n=N(e),r=N(t),o=n?.[zt];r!==null&&o!==void 0&&(r[zt]=o)}function Fm(e){return N(e)?.[zt]??null}function Cs(e){let t=N(e);for(let n of["read_output","context_intent"])if(N(t?.[n])?.result_omitted===!0)return!0;return!1}function ne(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function Is(e,t){if(Array.isArray(t))for(let n of t)ne(e,N(n)?.id)}function Ts(e,t){if(Array.isArray(t))for(let n of t)ne(e,n)}function Um(e,t){let n=N(e.recommended)===null?[]:[e.recommended];for(let r of["ready","decision_needed","gate_needed","containers","blocked","held_by_others"])Array.isArray(e[r])&&n.push(...e[r]);for(let r of n){let o=N(r);ne(t,o?.id);for(let i of Array.isArray(o?.blockers)?o.blockers:[])ne(t,N(i)?.id);for(let i of Array.isArray(o?.unblocks)?o.unblocks:[])ne(t,i)}}function zm(e,t){for(let n of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])Is(t,e[n]);for(let n of Array.isArray(e.blockers)?e.blockers:[])ne(t,N(n)?.blocked_by);qm(e,t)}function qm(e,t){for(let o of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=N(o);ne(t,i?.id),Is(t,i?.children)}for(let o of["files","workload"])for(let i of Array.isArray(e[o])?e[o]:[])Ts(t,N(i)?.items);let n=N(e.agenda);for(let o of Array.isArray(n?.events)?n.events:[])ne(t,N(o)?.item_id);let r=N(e.tests);Ts(t,r?.items_failing)}function Bm(e,t){let n=N(e);if(n===null||Cs(e))return[];let r=new Set;return t==="next"?Um(n,r):zm(n,r),[...r]}async function ev(e){let t=Fm(e.result);if(t===null)return!1;let n=Cs(e.result);return await Vm({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:Bm(e.result,t.surface),resultOmitted:n}),!0}async function tv(e){if([process.env.PM_CONTEXT_USAGE_DISABLED==="1",e.enabled===!1].includes(!0))return null;if(!e.author.trim()||e.rows.some(o=>!o.id.trim()||!Number.isInteger(o.rank)||o.rank<1))throw new I("Context usage serving requires an author and valid ranked rows");let t=e.rows.map(o=>({id:o.id.trim(),rank:o.rank,included:o.included}));if(new Set(t.map(o=>o.id)).size!==t.length)throw new I("Context usage serving requires unique normalized row ids");let n=t.slice(0,Y.max_serving_rows),r={serve_id:Lm(),author:e.author.trim(),surface:e.surface,rows:t,recorded_item_ids:n.map(o=>o.id)};return r.storage=await tt(e,[{kind:"serve",schema_version:2,serve_id:r.serve_id,at:be(e).iso,author:e.author.trim(),surface:e.surface,profile:e.profile.trim()||"balanced",rows:n,candidate_count:t.length,omitted_row_count:t.length-n.length,result_omitted:!1,packed_item_ids:n.filter(o=>o.included).map(o=>o.id)}]),r}async function Vm(e){if(e.receipt===null||process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return;let t=new Set(e.receipt.rows.map(i=>i.id)),n=[...new Set(e.deliveredItemIds.map(i=>i.trim()))];if(n.some(i=>i.length===0||!t.has(i))||e.resultOmitted&&n.length>0)throw new I("Context usage delivery requires emitted ranked ids and zero ids for an omitted result");let r=new Set(e.receipt.recorded_item_ids??e.receipt.rows.map(i=>i.id)),o={kind:"delivery",schema_version:2,serve_id:e.receipt.serve_id,at:be(e).iso,author:e.receipt.author,surface:e.receipt.surface,result_omitted:e.resultOmitted,delivered_item_ids:n.filter(i=>r.has(i))};await tt(e,[o],o.serve_id)}async function nv(e){if(!(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)){if(!e.author.trim()||!e.itemId.trim()||!e.intent.trim())throw new I("Context usage touch requires author, itemId, and intent");await tt(e,[{kind:"touch",at:be(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function rv(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1||e.itemIds.length===0)return;let t=e.author.trim(),n=e.intent.trim();if(!t||!n)throw new I("Context usage touch requires author and intent");let r=new Set;for(let s of e.itemIds){if(typeof s!="string")throw new I("Context usage touch requires string itemIds");let a=s.trim();if(!a)throw new I("Context usage touch requires non-empty itemId");r.add(a)}let o=be(e).iso,i=[...r].map(s=>({kind:"touch",at:o,author:t,item_id:s,intent:n}));await tt(e,i)}function Wm(e,t,n,r){return e.find(({entry:o,time:i})=>o.item_id===t&&i>=n&&i-n<=r)?.time}function Gm(e,t){let n=new Map;for(let r of e)r.kind==="delivery"&&r.schema_version===2&&r.author===t&&!n.has(r.serve_id)&&n.set(r.serve_id,r);return n}async function ov(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return{affinity:{},positive_judgments:0,serving_events:0,untrusted_serving_events:0};let t=await Ut(e),n=be(e).ms,r=(e.horizonHours??24)*36e5;if(![Number.isFinite(r),r>0].every(Boolean))throw new I("Context usage horizonHours must be positive");let o=e.author.trim(),i=t.filter(f=>f.kind==="touch").filter(f=>f.author===o).map(f=>({entry:f,time:Date.parse(f.at)})),s=new Map,a=0,c=0,l=0,d=Gm(t,o);t.filter(f=>f.kind==="serve").filter(f=>f.author===o).forEach(f=>{if(![f.schema_version===2,!!f.serve_id].every(Boolean)){c+=1;return}a+=1;let p=Date.parse(f.at),_=d.get(f.serve_id),g=new Set(_?.delivered_item_ids??[]);for(let w of f.rows){if(!g.has(w.id))continue;let v=Wm(i,w.id,p,r);if(v===void 0)continue;l+=1;let R=Math.max(0,(n-v)/jm);s.set(w.id,(s.get(w.id)??0)+Math.exp(-R/14))}});let u=Math.max(0,...s.values());return{affinity:Object.fromEntries([...s.entries()].map(([f,p])=>[f,u===0?.05:.05+.95*p/u])),positive_judgments:l,serving_events:a,untrusted_serving_events:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6436107d-eedc-5c97-9d8f-6f119c9bbe29")}catch{}})();var Ds=Object.freeze([{command:"context",intent:"orient",description:"Bounded active hierarchy, ownership, blockers, and recent progress.",included_field_groups:["summary","focus","hierarchy","blockers","activity"],token_budget:3e3,source:"core"},{command:"context",intent:"handoff",description:"Active ownership, evidence, decisions, and immediate continuation context.",included_field_groups:["summary","focus","in_progress","decisions","activity"],token_budget:2200,source:"core"},{command:"get",intent:"inspect",description:"Standard-depth item metadata, relationships, evidence, and lifecycle state.",included_field_groups:["item","children","claim_state","linked"],token_budget:3200,source:"core"},{command:"list",intent:"triage",description:"A budget-derived page of compact governance, ownership, priority, and blocker rows for triage.",included_field_groups:["identity","governance","ownership","dependencies"],token_budget:3200,source:"core"},{command:"next",intent:"execute",description:"The highest-ranked actionable work with concise ranking evidence.",included_field_groups:["recommended"],token_budget:1200,source:"core"},{command:"search",intent:"discover",description:"A budget-derived page of ranked canonical lineage candidates with compact match evidence.",included_field_groups:["identity","status","lineage","match"],token_budget:1800,source:"core"}]),Ms=new Km;function Hm(){return Ms.getStore()??Ds}function pv(e,t){return Ms.run(Xm(e.workspaceContracts,e.packageContracts),t)}function Ym(e,t){let n=e.command.trim().toLowerCase(),r=e.intent.trim().toLowerCase(),o=`${n}:${r}`;if(!/^[a-z0-9][a-z0-9-]*$/.test(n)||!/^[a-z0-9][a-z0-9-]*$/.test(r))throw new TypeError(`Invalid context intent command or name: ${o}`);if(e.description.trim().length===0)throw new TypeError(`Context intent ${o} requires a non-empty description`);if(!Number.isSafeInteger(e.token_budget)||e.token_budget<=0)throw new TypeError(`Context intent ${o} requires a positive integer token_budget`);let i=[...new Set(e.included_field_groups.map(s=>s.trim()).filter(Boolean))];if(i.length===0)throw new TypeError(`Context intent ${o} requires included_field_groups`);return{command:n,intent:r,description:e.description.trim(),included_field_groups:i,token_budget:e.token_budget,source:t}}function Xm(e=[],t=[]){let n=[{source:"core",contracts:Ds,allowOverride:!1},{source:"package",contracts:t,allowOverride:!1},{source:"workspace",contracts:e,allowOverride:!0}],r=new Map,o=new Set;for(let i of n){o.clear();for(let s of i.contracts){let a=Ym(s,i.source),c=`${a.command}:${a.intent}`;if(o.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);if(o.add(c),!i.allowOverride&&r.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);r.set(c,a)}}return[...r.values()].sort((i,s)=>i.command.localeCompare(s.command)||i.intent.localeCompare(s.intent))}function Ps(e,t,n=Hm(),r=[]){let o=e.trim().toLowerCase(),i=t.trim().toLowerCase(),s=n.find(m=>m.command===o&&m.intent===i);if(s)return{...s,source:s.source??"core"};let a=n.filter(m=>m.command===o).map(m=>m.intent);if(a.length===0)return;let c=a.map(m=>{let f=Array.from({length:i.length+1},(p,_)=>_);for(let p=1;p<=m.length;p+=1){let _=f[0];f[0]=p;for(let g=1;g<=i.length;g+=1){let w=f[g];f[g]=Math.min(f[g]+1,f[g-1]+1,_+(m[p-1]===i[g-1]?0:1)),_=w}}return{candidate:m,distance:f[i.length]}}).sort((m,f)=>m.distance-f.distance||m.candidate.localeCompare(f.candidate))[0].candidate,l=[o,...r,"--for",i],d=[o,...r,"--for",c],u=er(d);throw new h(`Unknown context intent "${i}" for ${o}. Did you mean "${c}"?`,y.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:i,required:`Use a declared ${o} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[u],recovery:{recovery_mode:"compact",attempted_command:er(l),allowed_values:[...a].sort(),suggested_retry:u,suggested_retry_args:d}})}var $s={context:(e,t,n)=>{e.depth===void 0&&(e.depth=t.intent==="handoff"?"deep":"standard"),e.section===void 0&&(e.section=t.intent==="handoff"?["activity","progress","blockers"]:["hierarchy","blockers","activity"]);let r=Vt(e.tokenBudget,t.token_budget),o=Wt("context",t.intent,r,n),i=we(e.limit),s=String(i===void 0?o:Math.min(i,o));(e.limit===void 0||i!==void 0)&&(e.limit=s),e.activityLimit===void 0&&(e.activityLimit=s)},get:e=>{e.depth===void 0&&e.fields===void 0&&(e.depth="standard")},list:(e,t,n)=>{e.brief===void 0&&e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");let r=Vt(e.tokenBudget,t.token_budget),o=Wt("list",t.intent,r,n),i=we(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))},next:e=>{e.readyOnly===void 0&&(e.readyOnly=!0)},search:(e,t,n)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let r=Vt(e.tokenBudget,t.token_budget),o=Wt("search",t.intent,r,n),i=we(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))}};function _v(e,t,n=[]){let r=t.tokenBudget??t.token_budget;if(typeof t.for!="string"){if(r!==void 0&&(e==="get"||e==="list"||e==="search"))throw new h("--token-budget requires a declared context intent selected with --for",y.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(t.tokenBudget!==void 0||t.token_budget===void 0)return t;let a={...t,tokenBudget:r};return delete a.token_budget,a}let o=Ps(e,t.for,void 0,n),i=we(r)!==void 0,s={...t};return s.tokenBudget===void 0&&r!==void 0&&(s.tokenBudget=r),delete s.token_budget,s.tokenBudget===void 0&&(s.tokenBudget=String(o.token_budget)),$s[e](s,o,i),s}var Jm={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},Bt=256;function ar(e){return Array.isArray(e)?e.map(ar):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,ar(n)])):typeof e=="string"&&e.length>240?`${e.slice(0,240)}\u2026`:e}function we(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 Vt(e,t){let n=we(e);if(n===void 0)return t;if(n<Bt)throw new h(`Context intent token budget must be at least ${Bt}`,y.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",required:`Use an integer token budget of at least ${Bt}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${Bt} or omit the override.`]});return n}function Wt(e,t,n,r){if(e==="get"||e==="next")return;let o=e==="context"&&t==="orient",i=e==="context"?o?1200:800:e==="list"?520:480,s=e==="context"?o?600:500:16,a=Math.max(e==="context"?1:2,Math.floor((n-i)/s));return r?a:Math.min(e==="context"?20:100,a)}function re(e,t){let n=t.estimated_tokens;for(;;){t.estimated_tokens=n;let r=Math.ceil(Buffer.byteLength(JSON.stringify(e),"utf8")/4);if(r===n)return;n=r}}var Rs={context:["high_level","low_level","blocked_fallback","recently_created","unparented","hierarchy","activity","blockers"],get:["children"],list:["items"],next:["ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items"]};function Ls(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof t.fingerprint!="string"||!Number.isSafeInteger(t.after_index)?void 0:{fingerprint:t.fingerprint,after_index:t.after_index,...typeof t.snapshot=="string"?{snapshot:t.snapshot}:{}}}catch{return}}function Qm(e){if(e===null||typeof e!="object")return;if(typeof e.id=="string")return e.id;let t=e.item?.id;return typeof t=="string"?t:void 0}function Zm(e,t,n){let r=!1;for(;;){if(re(e,t),t.estimated_tokens<=t.token_budget||n.length<=1)return r;let o=Buffer.byteLength(JSON.stringify(n),"utf8"),i=(t.estimated_tokens-t.token_budget)*4;n.splice(-Math.min(n.length-1,Math.max(1,Math.ceil(i/Math.max(1,Math.ceil(o/n.length)))))),r=!0}}function ep(e,t,n){let r=e.items,o=typeof e.next_cursor=="string",i=o?e.next_cursor:n.after;if(!Array.isArray(r)||typeof i!="string")return!1;let s=Ls(i);if(s===void 0)return!1;let a=r.length,c=[...r],l=!1;for(;;){if(l=Zm(e,t,r)||l,!l)return!1;let d=Qm(r.at(-1));if(d===void 0)return r.splice(0,r.length,...c),re(e,t),!1;if(e.next_cursor=Ve(s.fingerprint,d,o?s.after_index-(a-r.length):s.after_index+r.length,s.snapshot),re(e,t),t.estimated_tokens<=t.token_budget||r.length<=1)break}return typeof e.count=="number"&&(e.count=r.length),typeof e.applied_limit=="number"&&(e.applied_limit=r.length),!0}function tp(e,t,n,r){if(e==="list"||e==="search")return ep(t,n,r);if(e!=="next"||typeof t.next_cursor=="string")return!1;let o=!1;for(;;){if(re(t,n),n.estimated_tokens<=n.token_budget)return o;let i=Rs[e].map(m=>({key:m,rows:Array.isArray(t[m])?t[m]:[]})).filter(({rows:m})=>m.length>0).sort((m,f)=>f.rows.length-m.rows.length||m.key.localeCompare(f.key))[0];if(i===void 0)return o;let s=Rs[e].reduce((m,f)=>m+(Array.isArray(t[f])?t[f].length:0),0);if(s<=1)return o;let a=Math.min(i.rows.length,s-1),c=Buffer.byteLength(JSON.stringify(i.rows),"utf8"),l=Math.max(1,Math.ceil(c/i.rows.length)),d=(n.estimated_tokens-n.token_budget)*4,u=Math.min(a,Math.max(1,Math.ceil(d/l)));i.rows.splice(-u,u),o=!0}}function np(e,t,n){if(typeof t.for!="string")return n;let r=e.startsWith("list-")?"list":e;if(!(r in $s))return n;let o=r,i=Ps(o,t.for),s=Vt(t.tokenBudget??t.token_budget,i.token_budget),a={command:o,intent:i.intent,source:i.source,included_field_groups:[...i.included_field_groups],token_budget:s,declared_token_budget:i.token_budget,token_budget_override:s-i.token_budget,estimated_tokens:0,within_budget:!0,degradation:Jm[o],declaration_feasible:!0,result_omitted:!1},c={...n},l=Wt(o,i.intent,a.token_budget,we(t.tokenBudget??t.token_budget)!==void 0);if(l!==void 0){let u=we(t.limit),m=u!==void 0&&u<l;a.budget_derived_limit=l,a.binding_constraint=m?"explicit_limit":"token_budget",a.limit_reason=m?"The caller supplied a smaller row limit than the budget-derived ceiling.":"The selected intent token budget constrains the effective row ceiling.",c.budget_derived_limit=l}let d={...c,context_intent:a};return re(d,a),a.estimated_tokens>a.token_budget&&(a.degradation="recursive_budget_compaction",d={...ar(c),context_intent:a},re(d,a)),a.estimated_tokens>a.token_budget&&tp(o,d,a,t)&&(a.degradation="budget_row_compaction",re(d,a)),a.declaration_feasible=a.estimated_tokens<=a.declared_token_budget,a.estimated_tokens>a.token_budget&&(a.degradation="budget_receipt_only",a.result_omitted=!0,a.within_budget=!1,d={budget_exceeded:{omitted_result:!0,reason:a.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:op(e,o,i.intent,a,c)},context_intent:a}),d}function rp(e,t){if(typeof e.after!="string"||e.after.length===0)return t;let n=Ls(e.after)?.fingerprint??"opaque_cursor",r={...t};for(let o of["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"])delete r[o];return r.continuation_contract={fingerprint:n,metadata:"reference",restore_with:"omit --after"},r}function cr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function op(e,t,n,r,o){let i=t==="get"&&cr(o.item)&&typeof o.item.id=="string"?o.item.id:t==="search"&&typeof o.query=="string"?o.query:void 0,s=i===void 0?"":` '${i.replaceAll("'",`'"'"'`)}'`,a=t==="get"?"":` --limit ${r.budget_derived_limit??1}`;return`pm ${e}${s} --for ${n} --token-budget ${Math.ceil(r.estimated_tokens/100)*100}${a}`}function xe(e,t){if(cr(e))return typeof e[t]=="number"?e[t]:void 0}function ip(e,t){let n=e;for(let r=0;r<8;r+=1){let o=xe(n.context_intent,"estimated_tokens"),i=xe(n.read_output,"estimated_tokens"),s=xe(n.read_session,"spent_this_call_tokens");if(cr(n.context_intent)&&re(n,n.context_intent),n=xs(n,t),xe(n.context_intent,"estimated_tokens")===o&&xe(n.read_output,"estimated_tokens")===i&&xe(n.read_session,"spent_this_call_tokens")===s)break}return n}function sp(e,t,n){let r=Qi(e,n),o=typeof r=="object"&&r!==null&&!Array.isArray(r)?Ns(e??"",t,rp(t,np(e??"",t,r))):r;if(qt(n,o),t.outputRowContract===!0||t.output_row_contract===!0||typeof o!="object"||o===null||Array.isArray(o)||!Object.hasOwn(o,"row_contract"))return o;let i=ip(Object.fromEntries(Object.entries(o).filter(([s])=>s!=="row_contract")),t);return qt(o,i),i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="83c82348-64f8-5f10-9396-b03add0b7932")}catch{}})();var Ne=["result_rows","envelope","diagnostics","hints"],ap=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,cp=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,lp=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,dp=8;function lr(e){return Buffer.byteLength(e,"utf8")}function js(e){return lr(JSON.stringify(e)??"null")}function up(e,t){return cp.test(e)?"diagnostics":lp.test(e)?"hints":ap.test(e)||Array.isArray(t)?"result_rows":"envelope"}function fp(e){let t={result_rows:0,envelope:0,diagnostics:0,hints:0};if(typeof e!="object"||e===null||Array.isArray(e))return t[Array.isArray(e)?"result_rows":"envelope"]=js(e),t;for(let[n,r]of Object.entries(e))t[up(n,r)]+=js({[n]:r});return Object.values(t).every(n=>n===0)&&(t.envelope=1),t}function mp(e,t){let n=Ne.reduce((s,a)=>s+t[a],0),r=Ne.map(s=>({section:s,value:e*t[s]/n})),o={result_rows:0,envelope:0,diagnostics:0,hints:0};for(let s of r)o[s.section]=Math.floor(s.value);let i=e-Ne.reduce((s,a)=>s+o[a],0);for(let s of[...r].sort((a,c)=>c.value-Math.floor(c.value)-(a.value-Math.floor(a.value))||Ne.indexOf(a.section)-Ne.indexOf(c.section))){if(i===0)break;o[s.section]+=1,i-=1}return o}function Fs(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function pp(e,t){let n=lr(t(e)),r=mp(n,fp(e)),o=Object.fromEntries(Ne.map(a=>[a,{bytes:r[a],estimated_tokens:de(r[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:n,total_estimated_tokens:de(n),sections:o,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=Fs(e,i);for(let a=0;a<dp;a+=1){let c=lr(t(s))-n;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:de(c)},s=Fs(e,i)}return s}import{encode as qs}from"@toon-format/toon";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1a9ff3c9-9c7e-50ec-bb12-8a7f91de757f")}catch{}})();var Nv=new Set(Object.values(y));var Us=!1;function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function dr(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function yp(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.SUCCESS)}function hp(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.GENERIC_FAILURE)}function ur(e){if(e==="stdout"){yp();return}hp()}function zs(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function bp(){Us||(Us=!0,process.stdout.on("error",e=>{if(dr(e)){ur("stdout");return}zs(e)}),process.stderr.on("error",e=>{if(dr(e)){ur("stderr");return}zs(e)}))}function wp(e,t){bp();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(n){if(dr(n))return ur(e),!1;throw n}}function vp(e){return wp("stderr",e)}function fr(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function Ep(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Bs(e){if(e.length===0||!e.every(De))return!1;let t=Object.keys(e[0]);return t.length>0&&e.every(n=>Object.keys(n).length===t.length&&t.every(r=>Object.hasOwn(n,r)&&Ep(n[r])))}function Vs(e,t){let n=" ".repeat(t);return e.split(`
14
+ `).flatMap(l=>{try{let d=JSON.parse(l);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await n.close()}}catch{return[]}}function Cs(e,t,n){let r=[],o=0;for(let i=e.length-1;i>=0&&r.length<n;i-=1){let s=`${JSON.stringify(e[i])}
15
+ `;if(o+=Buffer.byteLength(s),o>t)break;r.push(s)}return r.reverse().join("")}async function tt(e,t,n){let r=Rs(e),o=Ut.join(e.pmRoot,"runtime","context-usage.jsonl"),i=Math.floor(r.maxBytes*Y.retained_byte_fraction),s=Math.min(Y.max_event_bytes,i);if(t.some(m=>Buffer.byteLength(`${JSON.stringify(m)}
16
+ `)>s))throw new I("Context usage event exceeds the declared byte ceiling");let a=t.filter(m=>Date.parse(m.at)>=r.cutoff),c=Cs(a,i,r.maxEvents),l=performance.now(),d=await As(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),u=performance.now()-l;try{await $m(Ut.dirname(o),{recursive:!0});let m=await xs(o,Re.O_WRONLY|Re.O_CREAT|Re.O_APPEND);try{let f=(await m.stat()).size,p=n===void 0?void 0:await zt(e);if(p?.some(R=>R.kind==="delivery"&&R.serve_id===n))return{written_bytes:0,ledger_bytes:f,compacted:!1,lock_wait_ms:u};if(!(e.maxEvents!==void 0||e.retentionDays!==void 0)&&f+Buffer.byteLength(c)<=r.maxBytes)return await m.writeFile(c,"utf8"),{written_bytes:Buffer.byteLength(c),ledger_bytes:f+Buffer.byteLength(c),compacted:!1,lock_wait_ms:u};let g=Cs([...p??await zt(e),...a],i,r.maxEvents),w=`${o}.${process.pid}.${Pm()}.tmp`,v=await Is(w,"wx",384);try{try{await v.writeFile(g,"utf8")}finally{await v.close()}return await m.close(),m=void 0,await Lm(w,o),{written_bytes:Buffer.byteLength(g),ledger_bytes:Buffer.byteLength(g),compacted:!0,lock_wait_ms:u}}finally{await jm(w,{force:!0})}}finally{await m?.close()}}finally{await d()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3b38d564-6034-54ae-ad24-eddba01a2c5c")}catch{}})();var Um=864e5,qt=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function N(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function rv(e,t){let n=N(e);n!==null&&t!==null&&(n[qt]=t)}function Bt(e,t){let n=N(e),r=N(t),o=n?.[qt];r!==null&&o!==void 0&&(r[qt]=o)}function zm(e){return N(e)?.[qt]??null}function Ds(e){let t=N(e);for(let n of["read_output","context_intent"])if(N(t?.[n])?.result_omitted===!0)return!0;return!1}function ne(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function Ms(e,t){if(Array.isArray(t))for(let n of t)ne(e,N(n)?.id)}function Ns(e,t){if(Array.isArray(t))for(let n of t)ne(e,n)}function qm(e,t){let n=N(e.recommended)===null?[]:[e.recommended];for(let r of["ready","decision_needed","gate_needed","containers","blocked","held_by_others"])Array.isArray(e[r])&&n.push(...e[r]);for(let r of n){let o=N(r);ne(t,o?.id);for(let i of Array.isArray(o?.blockers)?o.blockers:[])ne(t,N(i)?.id);for(let i of Array.isArray(o?.unblocks)?o.unblocks:[])ne(t,i)}}function Bm(e,t){for(let n of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])Ms(t,e[n]);for(let n of Array.isArray(e.blockers)?e.blockers:[])ne(t,N(n)?.blocked_by);Vm(e,t)}function Vm(e,t){for(let o of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=N(o);ne(t,i?.id),Ms(t,i?.children)}for(let o of["files","workload"])for(let i of Array.isArray(e[o])?e[o]:[])Ns(t,N(i)?.items);let n=N(e.agenda);for(let o of Array.isArray(n?.events)?n.events:[])ne(t,N(o)?.item_id);let r=N(e.tests);Ns(t,r?.items_failing)}function Wm(e,t){let n=N(e);if(n===null||Ds(e))return[];let r=new Set;return t==="next"?qm(n,r):Bm(n,r),[...r]}async function ov(e){let t=zm(e.result);if(t===null)return!1;let n=Ds(e.result);return await Gm({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:Wm(e.result,t.surface),resultOmitted:n}),!0}async function iv(e){if([process.env.PM_CONTEXT_USAGE_DISABLED==="1",e.enabled===!1].includes(!0))return null;if(!e.author.trim()||e.rows.some(o=>!o.id.trim()||!Number.isInteger(o.rank)||o.rank<1))throw new I("Context usage serving requires an author and valid ranked rows");let t=e.rows.map(o=>({id:o.id.trim(),rank:o.rank,included:o.included}));if(new Set(t.map(o=>o.id)).size!==t.length)throw new I("Context usage serving requires unique normalized row ids");let n=t.slice(0,Y.max_serving_rows),r={serve_id:Fm(),author:e.author.trim(),surface:e.surface,rows:t,recorded_item_ids:n.map(o=>o.id)};return r.storage=await tt(e,[{kind:"serve",schema_version:2,serve_id:r.serve_id,at:be(e).iso,author:e.author.trim(),surface:e.surface,profile:e.profile.trim()||"balanced",rows:n,candidate_count:t.length,omitted_row_count:t.length-n.length,result_omitted:!1,packed_item_ids:n.filter(o=>o.included).map(o=>o.id)}]),r}async function Gm(e){if(e.receipt===null||process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return;let t=new Set(e.receipt.rows.map(i=>i.id)),n=[...new Set(e.deliveredItemIds.map(i=>i.trim()))];if(n.some(i=>i.length===0||!t.has(i))||e.resultOmitted&&n.length>0)throw new I("Context usage delivery requires emitted ranked ids and zero ids for an omitted result");let r=new Set(e.receipt.recorded_item_ids??e.receipt.rows.map(i=>i.id)),o={kind:"delivery",schema_version:2,serve_id:e.receipt.serve_id,at:be(e).iso,author:e.receipt.author,surface:e.receipt.surface,result_omitted:e.resultOmitted,delivered_item_ids:n.filter(i=>r.has(i))};await tt(e,[o],o.serve_id)}async function sv(e){if(!(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)){if(!e.author.trim()||!e.itemId.trim()||!e.intent.trim())throw new I("Context usage touch requires author, itemId, and intent");await tt(e,[{kind:"touch",at:be(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function av(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1||e.itemIds.length===0)return;let t=e.author.trim(),n=e.intent.trim();if(!t||!n)throw new I("Context usage touch requires author and intent");let r=new Set;for(let s of e.itemIds){if(typeof s!="string")throw new I("Context usage touch requires string itemIds");let a=s.trim();if(!a)throw new I("Context usage touch requires non-empty itemId");r.add(a)}let o=be(e).iso,i=[...r].map(s=>({kind:"touch",at:o,author:t,item_id:s,intent:n}));await tt(e,i)}function Km(e,t,n,r){return e.find(({entry:o,time:i})=>o.item_id===t&&i>=n&&i-n<=r)?.time}function Hm(e,t){let n=new Map;for(let r of e)r.kind==="delivery"&&r.schema_version===2&&r.author===t&&!n.has(r.serve_id)&&n.set(r.serve_id,r);return n}async function cv(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return{affinity:{},positive_judgments:0,serving_events:0,untrusted_serving_events:0};let t=await zt(e),n=be(e).ms,r=(e.horizonHours??24)*36e5;if(![Number.isFinite(r),r>0].every(Boolean))throw new I("Context usage horizonHours must be positive");let o=e.author.trim(),i=t.filter(f=>f.kind==="touch").filter(f=>f.author===o).map(f=>({entry:f,time:Date.parse(f.at)})),s=new Map,a=0,c=0,l=0,d=Hm(t,o);t.filter(f=>f.kind==="serve").filter(f=>f.author===o).forEach(f=>{if(![f.schema_version===2,!!f.serve_id].every(Boolean)){c+=1;return}a+=1;let p=Date.parse(f.at),_=d.get(f.serve_id),g=new Set(_?.delivered_item_ids??[]);for(let w of f.rows){if(!g.has(w.id))continue;let v=Km(i,w.id,p,r);if(v===void 0)continue;l+=1;let R=Math.max(0,(n-v)/Um);s.set(w.id,(s.get(w.id)??0)+Math.exp(-R/14))}});let u=Math.max(0,...s.values());return{affinity:Object.fromEntries([...s.entries()].map(([f,p])=>[f,u===0?.05:.05+.95*p/u])),positive_judgments:l,serving_events:a,untrusted_serving_events:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6436107d-eedc-5c97-9d8f-6f119c9bbe29")}catch{}})();var js=Object.freeze([{command:"context",intent:"orient",description:"Bounded active hierarchy, ownership, blockers, and recent progress.",included_field_groups:["summary","focus","hierarchy","blockers","activity"],token_budget:3e3,source:"core"},{command:"context",intent:"handoff",description:"Active ownership, evidence, decisions, and immediate continuation context.",included_field_groups:["summary","focus","in_progress","decisions","activity"],token_budget:2200,source:"core"},{command:"get",intent:"inspect",description:"Standard-depth item metadata, relationships, evidence, and lifecycle state.",included_field_groups:["item","children","claim_state","linked"],token_budget:3200,source:"core"},{command:"list",intent:"triage",description:"A budget-derived page of compact governance, ownership, priority, and blocker rows for triage.",included_field_groups:["identity","governance","ownership","dependencies"],token_budget:3200,source:"core"},{command:"next",intent:"execute",description:"The highest-ranked actionable work with concise ranking evidence.",included_field_groups:["recommended"],token_budget:1200,source:"core"},{command:"search",intent:"discover",description:"A budget-derived page of ranked canonical lineage candidates with compact match evidence.",included_field_groups:["identity","status","lineage","match"],token_budget:1800,source:"core"}]),Fs=new Ym;function Xm(){return Fs.getStore()??js}function hv(e,t){return Fs.run(Qm(e.workspaceContracts,e.packageContracts),t)}function Jm(e,t){let n=e.command.trim().toLowerCase(),r=e.intent.trim().toLowerCase(),o=`${n}:${r}`;if(!/^[a-z0-9][a-z0-9-]*$/.test(n)||!/^[a-z0-9][a-z0-9-]*$/.test(r))throw new TypeError(`Invalid context intent command or name: ${o}`);if(e.description.trim().length===0)throw new TypeError(`Context intent ${o} requires a non-empty description`);if(!Number.isSafeInteger(e.token_budget)||e.token_budget<=0)throw new TypeError(`Context intent ${o} requires a positive integer token_budget`);let i=[...new Set(e.included_field_groups.map(s=>s.trim()).filter(Boolean))];if(i.length===0)throw new TypeError(`Context intent ${o} requires included_field_groups`);return{command:n,intent:r,description:e.description.trim(),included_field_groups:i,token_budget:e.token_budget,source:t}}function Qm(e=[],t=[]){let n=[{source:"core",contracts:js,allowOverride:!1},{source:"package",contracts:t,allowOverride:!1},{source:"workspace",contracts:e,allowOverride:!0}],r=new Map,o=new Set;for(let i of n){o.clear();for(let s of i.contracts){let a=Jm(s,i.source),c=`${a.command}:${a.intent}`;if(o.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);if(o.add(c),!i.allowOverride&&r.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);r.set(c,a)}}return[...r.values()].sort((i,s)=>i.command.localeCompare(s.command)||i.intent.localeCompare(s.intent))}function Us(e,t,n=Xm(),r=[]){let o=e.trim().toLowerCase(),i=t.trim().toLowerCase(),s=n.find(m=>m.command===o&&m.intent===i);if(s)return{...s,source:s.source??"core"};let a=n.filter(m=>m.command===o).map(m=>m.intent);if(a.length===0)return;let c=a.map(m=>{let f=Array.from({length:i.length+1},(p,_)=>_);for(let p=1;p<=m.length;p+=1){let _=f[0];f[0]=p;for(let g=1;g<=i.length;g+=1){let w=f[g];f[g]=Math.min(f[g]+1,f[g-1]+1,_+(m[p-1]===i[g-1]?0:1)),_=w}}return{candidate:m,distance:f[i.length]}}).sort((m,f)=>m.distance-f.distance||m.candidate.localeCompare(f.candidate))[0].candidate,l=[o,...r,"--for",i],d=[o,...r,"--for",c],u=$t(d);throw new h(`Unknown context intent "${i}" for ${o}. Did you mean "${c}"?`,y.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:i,required:`Use a declared ${o} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[u],recovery:{recovery_mode:"compact",attempted_command:$t(l),allowed_values:[...a].sort(),suggested_retry:u,suggested_retry_args:d}})}var zs={context:(e,t,n)=>{e.depth===void 0&&(e.depth=t.intent==="handoff"?"deep":"standard"),e.section===void 0&&(e.section=t.intent==="handoff"?["activity","progress","blockers"]:["hierarchy","blockers","activity"]);let r=Wt(e.tokenBudget,t.token_budget),o=Gt("context",t.intent,r,n),i=we(e.limit),s=String(i===void 0?o:Math.min(i,o));(e.limit===void 0||i!==void 0)&&(e.limit=s),e.activityLimit===void 0&&(e.activityLimit=s)},get:e=>{e.depth===void 0&&e.fields===void 0&&(e.depth="standard")},list:(e,t,n)=>{e.brief===void 0&&e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");let r=Wt(e.tokenBudget,t.token_budget),o=Gt("list",t.intent,r,n),i=we(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))},next:e=>{e.readyOnly===void 0&&(e.readyOnly=!0)},search:(e,t,n)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let r=Wt(e.tokenBudget,t.token_budget),o=Gt("search",t.intent,r,n),i=we(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))}};function bv(e,t,n=[]){let r=t.tokenBudget??t.token_budget;if(typeof t.for!="string"){if(r!==void 0&&(e==="get"||e==="list"||e==="search"))throw new h("--token-budget requires a declared context intent selected with --for",y.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(t.tokenBudget!==void 0||t.token_budget===void 0)return t;let a={...t,tokenBudget:r};return delete a.token_budget,a}let o=Us(e,t.for,void 0,n),i=we(r)!==void 0,s={...t};return s.tokenBudget===void 0&&r!==void 0&&(s.tokenBudget=r),delete s.token_budget,s.tokenBudget===void 0&&(s.tokenBudget=String(o.token_budget)),zs[e](s,o,i),s}var Zm={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},Vt=256;function ar(e){return Array.isArray(e)?e.map(ar):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,ar(n)])):typeof e=="string"&&e.length>240?`${e.slice(0,240)}\u2026`:e}function we(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 Wt(e,t){let n=we(e);if(n===void 0)return t;if(n<Vt)throw new h(`Context intent token budget must be at least ${Vt}`,y.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",required:`Use an integer token budget of at least ${Vt}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${Vt} or omit the override.`]});return n}function Gt(e,t,n,r){if(e==="get"||e==="next")return;let o=e==="context"&&t==="orient",i=e==="context"?o?1200:800:e==="list"?520:480,s=e==="context"?o?600:500:16,a=Math.max(e==="context"?1:2,Math.floor((n-i)/s));return r?a:Math.min(e==="context"?20:100,a)}function re(e,t){let n=t.estimated_tokens;for(;;){t.estimated_tokens=n;let r=Math.ceil(Buffer.byteLength(JSON.stringify(e),"utf8")/4);if(r===n)return;n=r}}var Ps={context:["high_level","low_level","blocked_fallback","recently_created","unparented","hierarchy","activity","blockers"],get:["children"],list:["items"],next:["ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items"]};function qs(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof t.fingerprint!="string"||!Number.isSafeInteger(t.after_index)?void 0:{fingerprint:t.fingerprint,after_index:t.after_index,...typeof t.snapshot=="string"?{snapshot:t.snapshot}:{}}}catch{return}}function ep(e){if(e===null||typeof e!="object")return;if(typeof e.id=="string")return e.id;let t=e.item?.id;return typeof t=="string"?t:void 0}function tp(e,t,n){let r=!1;for(;;){if(re(e,t),t.estimated_tokens<=t.token_budget||n.length<=1)return r;let o=Buffer.byteLength(JSON.stringify(n),"utf8"),i=(t.estimated_tokens-t.token_budget)*4;n.splice(-Math.min(n.length-1,Math.max(1,Math.ceil(i/Math.max(1,Math.ceil(o/n.length)))))),r=!0}}function np(e,t,n){let r=e.items,o=typeof e.next_cursor=="string",i=o?e.next_cursor:n.after;if(!Array.isArray(r)||typeof i!="string")return!1;let s=qs(i);if(s===void 0)return!1;let a=r.length,c=[...r],l=!1;for(;;){if(l=tp(e,t,r)||l,!l)return!1;let d=ep(r.at(-1));if(d===void 0)return r.splice(0,r.length,...c),re(e,t),!1;if(e.next_cursor=Ve(s.fingerprint,d,o?s.after_index-(a-r.length):s.after_index+r.length,s.snapshot),re(e,t),t.estimated_tokens<=t.token_budget||r.length<=1)break}return typeof e.count=="number"&&(e.count=r.length),typeof e.applied_limit=="number"&&(e.applied_limit=r.length),!0}function rp(e,t,n,r){if(e==="list"||e==="search")return np(t,n,r);if(e!=="next"||typeof t.next_cursor=="string")return!1;let o=!1;for(;;){if(re(t,n),n.estimated_tokens<=n.token_budget)return o;let i=Ps[e].map(m=>({key:m,rows:Array.isArray(t[m])?t[m]:[]})).filter(({rows:m})=>m.length>0).sort((m,f)=>f.rows.length-m.rows.length||m.key.localeCompare(f.key))[0];if(i===void 0)return o;let s=Ps[e].reduce((m,f)=>m+(Array.isArray(t[f])?t[f].length:0),0);if(s<=1)return o;let a=Math.min(i.rows.length,s-1),c=Buffer.byteLength(JSON.stringify(i.rows),"utf8"),l=Math.max(1,Math.ceil(c/i.rows.length)),d=(n.estimated_tokens-n.token_budget)*4,u=Math.min(a,Math.max(1,Math.ceil(d/l)));i.rows.splice(-u,u),o=!0}}function op(e,t,n){if(typeof t.for!="string")return n;let r=e.startsWith("list-")?"list":e;if(!(r in zs))return n;let o=r,i=Us(o,t.for),s=Wt(t.tokenBudget??t.token_budget,i.token_budget),a={command:o,intent:i.intent,source:i.source,included_field_groups:[...i.included_field_groups],token_budget:s,declared_token_budget:i.token_budget,token_budget_override:s-i.token_budget,estimated_tokens:0,within_budget:!0,degradation:Zm[o],declaration_feasible:!0,result_omitted:!1},c={...n},l=Gt(o,i.intent,a.token_budget,we(t.tokenBudget??t.token_budget)!==void 0);if(l!==void 0){let u=we(t.limit),m=u!==void 0&&u<l;a.budget_derived_limit=l,a.binding_constraint=m?"explicit_limit":"token_budget",a.limit_reason=m?"The caller supplied a smaller row limit than the budget-derived ceiling.":"The selected intent token budget constrains the effective row ceiling.",c.budget_derived_limit=l}let d={...c,context_intent:a};return re(d,a),a.estimated_tokens>a.token_budget&&(a.degradation="recursive_budget_compaction",d={...ar(c),context_intent:a},re(d,a)),a.estimated_tokens>a.token_budget&&rp(o,d,a,t)&&(a.degradation="budget_row_compaction",re(d,a)),a.declaration_feasible=a.estimated_tokens<=a.declared_token_budget,a.estimated_tokens>a.token_budget&&(a.degradation="budget_receipt_only",a.result_omitted=!0,a.within_budget=!1,d={budget_exceeded:{omitted_result:!0,reason:a.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:sp(e,o,i.intent,a,c)},context_intent:a}),d}function ip(e,t){if(typeof e.after!="string"||e.after.length===0)return t;let n=qs(e.after)?.fingerprint??"opaque_cursor",r={...t};for(let o of["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"])delete r[o];return r.continuation_contract={fingerprint:n,metadata:"reference",restore_with:"omit --after"},r}function cr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function sp(e,t,n,r,o){let i=t==="get"&&cr(o.item)&&typeof o.item.id=="string"?o.item.id:t==="search"&&typeof o.query=="string"?o.query:void 0,s=i===void 0?"":` '${i.replaceAll("'",`'"'"'`)}'`,a=t==="get"?"":` --limit ${r.budget_derived_limit??1}`;return`pm ${e}${s} --for ${n} --token-budget ${Math.ceil(r.estimated_tokens/100)*100}${a}`}function xe(e,t){if(cr(e))return typeof e[t]=="number"?e[t]:void 0}function ap(e,t){let n=e;for(let r=0;r<8;r+=1){let o=xe(n.context_intent,"estimated_tokens"),i=xe(n.read_output,"estimated_tokens"),s=xe(n.read_session,"spent_this_call_tokens");if(cr(n.context_intent)&&re(n,n.context_intent),n=$s(n,t),xe(n.context_intent,"estimated_tokens")===o&&xe(n.read_output,"estimated_tokens")===i&&xe(n.read_session,"spent_this_call_tokens")===s)break}return n}function cp(e,t,n){let r=rs(e,n),o=typeof r=="object"&&r!==null&&!Array.isArray(r)?Ls(e??"",t,ip(t,op(e??"",t,r))):r;if(Bt(n,o),t.outputRowContract===!0||t.output_row_contract===!0||typeof o!="object"||o===null||Array.isArray(o)||!Object.hasOwn(o,"row_contract"))return o;let i=ap(Object.fromEntries(Object.entries(o).filter(([s])=>s!=="row_contract")),t);return Bt(o,i),i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="83c82348-64f8-5f10-9396-b03add0b7932")}catch{}})();var Ne=["result_rows","envelope","diagnostics","hints"],lp=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,dp=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,up=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,fp=8;function lr(e){return Buffer.byteLength(e,"utf8")}function Bs(e){return lr(JSON.stringify(e)??"null")}function mp(e,t){return dp.test(e)?"diagnostics":up.test(e)?"hints":lp.test(e)||Array.isArray(t)?"result_rows":"envelope"}function pp(e){let t={result_rows:0,envelope:0,diagnostics:0,hints:0};if(typeof e!="object"||e===null||Array.isArray(e))return t[Array.isArray(e)?"result_rows":"envelope"]=Bs(e),t;for(let[n,r]of Object.entries(e))t[mp(n,r)]+=Bs({[n]:r});return Object.values(t).every(n=>n===0)&&(t.envelope=1),t}function _p(e,t){let n=Ne.reduce((s,a)=>s+t[a],0),r=Ne.map(s=>({section:s,value:e*t[s]/n})),o={result_rows:0,envelope:0,diagnostics:0,hints:0};for(let s of r)o[s.section]=Math.floor(s.value);let i=e-Ne.reduce((s,a)=>s+o[a],0);for(let s of[...r].sort((a,c)=>c.value-Math.floor(c.value)-(a.value-Math.floor(a.value))||Ne.indexOf(a.section)-Ne.indexOf(c.section))){if(i===0)break;o[s.section]+=1,i-=1}return o}function Vs(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function gp(e,t){let n=lr(t(e)),r=_p(n,pp(e)),o=Object.fromEntries(Ne.map(a=>[a,{bytes:r[a],estimated_tokens:de(r[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:n,total_estimated_tokens:de(n),sections:o,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=Vs(e,i);for(let a=0;a<fp;a+=1){let c=lr(t(s))-n;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:de(c)},s=Vs(e,i)}return s}import{encode as Ks}from"@toon-format/toon";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1a9ff3c9-9c7e-50ec-bb12-8a7f91de757f")}catch{}})();var $v=new Set(Object.values(y));var Ws=!1;function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function dr(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function bp(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.SUCCESS)}function wp(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.GENERIC_FAILURE)}function ur(e){if(e==="stdout"){bp();return}wp()}function Gs(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function vp(){Ws||(Ws=!0,process.stdout.on("error",e=>{if(dr(e)){ur("stdout");return}Gs(e)}),process.stderr.on("error",e=>{if(dr(e)){ur("stderr");return}Gs(e)}))}function Ep(e,t){vp();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(n){if(dr(n))return ur(e),!1;throw n}}function kp(e){return Ep("stderr",e)}function fr(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function Op(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Hs(e){if(e.length===0||!e.every(De))return!1;let t=Object.keys(e[0]);return t.length>0&&e.every(n=>Object.keys(n).length===t.length&&t.every(r=>Object.hasOwn(n,r)&&Op(n[r])))}function Ys(e,t){let n=" ".repeat(t);return e.split(`
17
17
  `).map(r=>`${n}${r}`).join(`
18
- `)}function kp(e,t,n){let r=" ".repeat(n);return!De(t)&&!Array.isArray(t)?`${r}${e}: ${fr(t)}`:Array.isArray(t)&&t.length===0?`${r}${e}: []`:Array.isArray(t)&&Bs(t)?Vs(qs({[e]:t}),n):De(t)&&Object.keys(t).length===0?`${r}${e}: {}`:`${r}${e}:
19
- ${pr(t,n+1)}`}function mr(e){if(e!=null){if(Array.isArray(e)){let t=e.map(n=>mr(n)).filter(n=>n!==void 0);return t.length>0?t:void 0}if(De(e)){let t={};for(let[n,r]of Object.entries(e)){if(n==="omitted_field_groups"&&Array.isArray(r)&&r.length===0){t[n]=[];continue}let o=mr(r);o!==void 0&&(t[n]=o)}return Object.keys(t).length>0?t:void 0}return e}}function pr(e,t){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":Bs(e)?Vs(qs(e),t):e.map(r=>{if(!De(r)&&!Array.isArray(r))return`${n}- ${fr(r)}`;let i=pr(r,t+1).split(`
18
+ `)}function Sp(e,t,n){let r=" ".repeat(n);return!De(t)&&!Array.isArray(t)?`${r}${e}: ${fr(t)}`:Array.isArray(t)&&t.length===0?`${r}${e}: []`:Array.isArray(t)&&Hs(t)?Ys(Ks({[e]:t}),n):De(t)&&Object.keys(t).length===0?`${r}${e}: {}`:`${r}${e}:
19
+ ${pr(t,n+1)}`}function mr(e){if(e!=null){if(Array.isArray(e)){let t=e.map(n=>mr(n)).filter(n=>n!==void 0);return t.length>0?t:void 0}if(De(e)){let t={};for(let[n,r]of Object.entries(e)){if(n==="omitted_field_groups"&&Array.isArray(r)&&r.length===0){t[n]=[];continue}let o=mr(r);o!==void 0&&(t[n]=o)}return Object.keys(t).length>0?t:void 0}return e}}function pr(e,t){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":Hs(e)?Ys(Ks(e),t):e.map(r=>{if(!De(r)&&!Array.isArray(r))return`${n}- ${fr(r)}`;let i=pr(r,t+1).split(`
20
20
  `),[s,...a]=i;return a.length===0?`${n}- ${s.trimStart()}`:`${n}- ${s.trimStart()}
21
21
  ${a.join(`
22
22
  `)}`}).join(`
23
- `);if(De(e)){let r=Object.entries(e);return r.length===0?"{}":r.map(([o,i])=>kp(o,i,t)).join(`
24
- `)}return`${n}${fr(e)}`}function Ws(e,t){if(t==="json")return`${JSON.stringify(e,null,2)}
23
+ `);if(De(e)){let r=Object.entries(e);return r.length===0?"{}":r.map(([o,i])=>Sp(o,i,t)).join(`
24
+ `)}return`${n}${fr(e)}`}function Xs(e,t){if(t==="json")return`${JSON.stringify(e,null,2)}
25
25
  `;let n=mr(e);return n===void 0?`{}
26
26
  `:`${pr(n,0)}
27
- `}function Dv(e){let t=zi("error_format",{message:e}),n=t.handled&&typeof t.result=="string"?t.result:e;vp(n.endsWith(`
27
+ `}function Lv(e){let t=zi("error_format",{message:e}),n=t.handled&&typeof t.result=="string"?t.result:e;kp(n.endsWith(`
28
28
  `)?n:`${n}
29
- `)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="85bc6b10-700a-5d06-970f-d544833dd059")}catch{}})();var Op=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 Me(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Gs(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(!Me(n))return;n=n[r]}return n}function _r(e,t,n){let r=t.split("."),o=(i,s)=>{if(s===r.length)return n;let a=r[s];if(Array.isArray(i)){let l=Number(a),d=[...i];return d[l]=o(i[l],s+1),d}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function Ks(e,t,n){let r=$e(e).find(i=>i.path===t);if(!r)return e;let o=Array.isArray(r.value)?r.value.slice(n):Object.fromEntries(Object.entries(r.value).slice(n));return _r(e,t,o)}function Gt(e){let t=e.row_contract;return Me(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 Sp(e){let t=e.row_contract;return Me(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Gt(e)}function Pe(e){return Gt(e).flatMap(t=>{let n=Gs(e,t);return Array.isArray(n)||Me(n)?[{path:t,value:n}]:[]})}function $e(e){return Sp(e).flatMap(t=>{let n=Gs(e,t);return Array.isArray(n)||Me(n)?[{path:t,value:n}]:[]})}function Kt(e){let t=Pe(e),n=new Set(t.map(o=>o.path)),r=(o,i)=>{if(Array.isArray(o)){n.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>r(s,`${i}.${a}`));return}if(Me(o))for(let[s,a]of Object.entries(o))i.length===0&&Op.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function Ht(e){return Pe(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function nt(e,t){let n=e;for(let r of Pe(n)){let o=Array.isArray(r.value)?r.value.map((i,s)=>t(i,r.path,s)):Object.fromEntries(Object.entries(r.value).map(([i,s],a)=>[i,t(s,r.path,a)]));n=_r(n,r.path,o)}return n}function Hs(e,t){let n=e,r=!1;for(let o of Pe(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=_r(n,o.path,s)}return{result:n,truncated:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f3d917c2-7ae0-5ea8-b589-dd31af712ad9")}catch{}})();var Ap=8,Tp=64,Cp=5,Ip=4,Ys=100;function yr(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*Cp/Ip),i=Math.ceil(o/Ys)*Ys;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 rt(e,t){let n=t===void 0?JSON.stringify(e):Ws(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function Rp(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function gr(e,t){return typeof e=="string"?e.length<=240?e:(t.compacted=!0,`${e.slice(0,240)}\u2026`):Array.isArray(e)?e.map(n=>gr(n,t)):Rp(e)?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,gr(r,t)])):e}function oe(e,t,n){let r=t.estimated_tokens;for(let o=0;o<Ap;o+=1){t.estimated_tokens=r;let i=rt(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function xp(e,t,n,r,o){for(let i=0;i<Tp;i+=1){if(oe(e,t,o),t.estimated_tokens<=n)return;let s=Kt(e).filter(c=>(Array.isArray(c.value)?c.value.length:Object.keys(c.value).length)>Math.max(1,r.get(c.path)??0)).map(c=>({collection:c,length:Array.isArray(c.value)?c.value.length:Object.keys(c.value).length})).sort((c,l)=>l.length-c.length||c.collection.path.localeCompare(l.collection.path))[0]?.collection;if(!s)return;let a=Math.max(1,r.get(s.path)??0);if(Array.isArray(s.value))s.value.splice(-Math.min(s.value.length-a,Math.max(1,Math.ceil(s.value.length/2))));else{let c=Object.keys(s.value);for(let l of c.slice(-Math.min(c.length-a,Math.max(1,Math.ceil(c.length/2)))))delete s.value[l]}t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],s.path])].sort((c,l)=>c.localeCompare(l)),e.has_more=!0,e.truncated=!0,typeof e.count=="number"&&(e.count=Ht(e))}}function Xs(e,t,n,r=new Map,o){let i={compacted:!1},s=gr(e,i);return t.strings_compacted=i.compacted,s.read_output=t,xp(s,t,n,r,o),oe(s,t,o),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="844b0c44-fc1a-52e7-9d88-2c58e1ab4542")}catch{}})();var hr=256,br=1e4,Np=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,Js=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Dp=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),Mp=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&Np.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=hr,reason:`token_budget must be a safe integer of at least ${hr}.`},{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<=br&&e.seen_item_ids.every(t=>typeof t=="string"&&Js.test(t)),reason:`seen_item_ids must contain at most ${br} portable item identifiers.`}];function Xt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Yt(e){throw new h(`--output-session ${e}`,y.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function Jt(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{Yt("must be a valid JSON object.")}Xt(t)||Yt("must be a JSON object.");let n=Object.keys(t).filter(i=>!Dp.has(i));n.length>0&&Yt(`contains unknown field "${n.sort()[0]}".`);let r=Mp.find(i=>!i.valid(t));r!==void 0&&Yt(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 Qs(e){if(Xt(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:Xt(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function Pp(e){let t=new Set,n=0;for(let r of Pe(e)){let o=Array.isArray(r.value)?r.value:Object.values(r.value);for(let i of o){if(!Xt(i))continue;if(typeof i.context_ref=="string"){n+=1;continue}let s=Qs(i);s!==void 0&&Js.test(s)&&t.add(s)}}return{deliveredIds:t,suppressedRepeatCount:n}}function Zs(e,t){let n=new Set(t.seen_item_ids);return nt(e,r=>{let o=Qs(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function wr(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=Pp(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,br-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),l=s.length-a.length,d={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:r.size,...l===0?{}:{seen_item_overflow_count:l},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:c}},u={...e,read_session:d},m=_=>{d.spent_this_call_tokens=_,d.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,_),d.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+d.charged_this_call_tokens),d.remaining_tokens=Math.max(0,t.token_budget-d.spent_total_tokens),d.exhausted=d.remaining_tokens<hr,d.next_state.spent_tokens=d.spent_total_tokens},f=0,p=0;for(let _=0;_<8;_+=1){m(f);let g=rt(u,n);if(g===f)return u;p=Math.max(p,g),f=g}return m(p),u}function ea(e){return Math.max(0,e.token_budget-e.spent_tokens)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8e488707-02ae-54ce-b30b-24371975b98e")}catch{}})();var ve=["include","amount","cost","encoding"],la=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","files","docs","stats","aggregate","duplicates","package-catalog","package-manage","comments-audit","assurance"],da=["canonical","legacy","intent","default"],it={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},vr=Symbol.for("pm.readOutputInvocationProvenance"),tE=Object.freeze(ve.map(e=>it[e])),nE=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),ua={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],cost:["--token-budget"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},fa=new Set(["--collapse","--fields","--section"]),Or=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function Sr(e){return e.slice(2).replaceAll("-","_")}function $p(e,t){let n=Or[e];if(n!==void 0)return n;let r=t==="include"?fa.has(e)?"<csv>":Sr(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${it[t]} ${r}.`}function Lp(e){let t=ua[e],n=Object.freeze(Object.fromEntries(ve.map(r=>[r,Object.freeze({dimension:r,canonical_option:it[r],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[r]??[]).map(o=>Object.freeze({flag:o,semantics:Or[o]===void 0?"replacement":"behavior_preserving",migration_hint:$p(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:da,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...Ar(e).keys()])})}var jp=Object.freeze(la.map(Lp)),Fp=new Map(jp.map(e=>[e.command,e]));function je(e,t={}){let n=ze(e.trim().toLowerCase()),o=n==="package catalog"||n==="packages catalog"||n==="package-catalog"||(n==="package"||n==="packages"||n==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":n==="package manage"||n==="package-manage"?"package-manage":n.split(" ")[0],i=o.startsWith("list-")?"list":o==="ctx"?"context":o;return la.includes(i)?i:void 0}var Up=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],zp={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 qp(e){return Up.some(t=>e[t]!==void 0)}var Bp=[{keys:["outputInclude","output_include"],valid:e=>ot(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||Le(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||Le(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputFormat","output_format"],valid:e=>e==="toon"||e==="json",message:"--output-format must be toon or json."},{keys:["outputSession","output_session"],valid:e=>(Jt(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 rE(e,t){if(!qp(t))return;let n=je(e,t);if(!n)throw new h(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,y.USAGE);if((zp[n]??[]).some(r=>t[r]!==void 0&&t[r]!==!1))throw new h(`Universal output controls cannot be combined with a ${n} mutation.`,y.USAGE);for(let r of Bp){let o=r.keys.map(i=>t[i]).find(i=>i!==void 0);if(o!==void 0&&!r.valid(o))throw new h(r.message,y.USAGE)}}function Ar(e){let t=je(e);return t?new Map((ua[t].include??[]).filter(n=>!fa.has(n)&&Or[n]===void 0).map(n=>[Sr(n),ma(n)])):new Map}function Vp(e,t,n){let r=ot(t)??[],o=Ar(e),i=[],s=[],a=n,c=a[vr],l=new Set(c?.canonical_include_modes??[]),d=new Set(c?.explicit_legacy_aliases??[]);for(let f of r){let p=o.get(f);if(p===void 0){i.push(f);continue}let _=`--${f.replaceAll("_","-")}`;_a(pa(n,_))&&d.add(_),n[p]=!0,s.push(f),l.add(f)}let u=je(e)==="get"?i.filter(f=>f!=="item"):[],m=u.length>0;return m&&(n.fields=[...new Set([...ot(n.fields)??[],...u])].join(","),l.add("fields")),(s.length>0||m)&&(a[vr]={canonical_include_modes:[...l],explicit_legacy_aliases:[...d],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function oE(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=Vp(e,n,t);if(o.length===0)return;let i=r.length>0?r.join(","):void 0;t.outputInclude=i,Object.hasOwn(t,"output_include")&&(t.output_include=i)}function ma(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}function pa(e,t){let n=ma(t);if(Object.hasOwn(e,n))return e[n];let r=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,r))return e[r];if(t==="--no-truncate"&&e.truncate===!1)return!0}function _a(e){return e!==void 0&&e!==!1&&e!==null}function ot(e){let n=(Array.isArray(e)?e:[e]).flatMap(r=>typeof r=="string"?r.split(","):[]).map(r=>r.trim()).filter(Boolean);return n.length>0?[...new Set(n)]:void 0}function Le(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 Wp(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=pa(t,o.flag),s={value:i,flag:o.flag};if(_a(i)&&n(s))return s}}function ta(e,t){let n=ot(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:ot(t.value)??[Sr(t.flag)]}}function na(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=Le(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=Le(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function ra(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=Le(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let r=Le(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function oa(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 Gp(e,t,n){if(!e)return!1;let r=new Set(e.explicit_legacy_aliases);if(e.cli_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 Kp(e,t,n){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function Hp(e,t){return ve.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[it[n]]:[])}function ga(e,t){let n=je(e,t);if(!n)return;let r=Fp.get(n),o=t[vr],i={include:v=>ta(void 0,v),amount:v=>na(void 0,v),cost:v=>ra(void 0,v),encoding:v=>oa(void 0,v)},s=Object.fromEntries(ve.map(v=>[v,Wp(r.dimensions[v],t,R=>i[v](R)!==void 0,R=>Gp(o,v,R))])),a=ve.flatMap(v=>{let R=s[v];return R?[R.flag]:[]}),c=ve.flatMap(v=>{let R=s[v];return R?[r.dimensions[v].legacy_aliases.find(ct=>ct.flag===R.flag).migration_hint]:[]}),l=oa(t.outputFormat??t.output_format,s.encoding),d=ta(t.outputInclude??t.output_include,s.include),u=na(t.outputLimit??t.output_limit,s.amount),m=ra(t.outputBudget??t.output_budget,s.cost),f=Kp(e,s,o),p=ro(e,{generateFallback:!0}),_=l?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",g=m??(f?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:d,amount:u,cost:g,encoding:l,canonical_options_used:Hp({include:d,amount:u,cost:g,encoding:l},o),legacy_aliases_used:a,migration_hints:c,precedence:da}}function U(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Tr=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"]),Yp=["collection_counts","notes_count","tests_count"];function ya(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function Xp(e){let t=U(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...Yp.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!Tr.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 Jp(e,t){let n=Xp(e),r=t.filter(u=>!n.valid.includes(u));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,y.USAGE);let o=t.includes("item"),i=t.flatMap(u=>u.startsWith("item.")?[u.slice(5)]:n.itemFields.includes(u)?[u]:[]).filter((u,m,f)=>f.indexOf(u)===m);if(o&&i.length>0)throw new h("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",y.USAGE);let s=new Set(t.filter(u=>n.sections.includes(u))),a=Object.fromEntries(Object.entries(e).filter(([u])=>Tr.has(u)||s.has(u)));o?a.item=n.item:i.length>0&&(a.item=ya(n.item,i));let c=[...o?[]:i.length>0?n.itemFields.filter(u=>!i.includes(u)).map(u=>({name:`item.${u}`,restore_with:`--output-include item.${u}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(u=>!s.has(u)).map(u=>({name:u,restore_with:`--output-include ${u}`}))],d=[...U(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 ia(e){let t=0;return nt({...e},n=>(U(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function Qp(e,t,n,r){if(ia(t)===0||ia(n)>0)return;let o=[...Ar(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${r.join(", ")}. No selector matched any returned row field.${i}`,y.USAGE)}function Zp(e,t,n){if(e==="get")return Jp(t,n);let r=Gt(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=nt(s,l=>U(l)?ya(l,a):l);return Qp(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||Tr.has(s)))}function e_(e,t){if(t==="unbounded")return e;let{result:n,truncated:r}=Hs(e,t);return r&&(n.has_more=!0,n.truncated=!0,typeof n.count=="number"&&(n.count=Ht(n)),n.applied_bound={kind:"output_limit",source:"explicit",value:t}),n}function t_(e){return ve.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(it[t]))}function ha(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function Zt(e,t,n,r){let o=wr(e,t,r);for(let i=0;i<8;i+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;oe(o,n,r),o=wr(o,t,r);let c=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&c===a)return o}return o}function xs(e,t){if(!U(e.read_output))return e;let n=ha(t),r=e.read_output,o=Jt(t.outputSession??t.output_session);return o===void 0?(oe(e,r,n),e):Zt(e,o,r,n)}function n_(e,t){if(e!=="validate")return t;let n=U(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(u=>U(u)&&u.name==="diagnostic_rows"))return t;let o=[...new Set(Kt(t).map(({path:u})=>u).filter(u=>/^checks\.\d+\.details\./u.test(u)))],i=o.filter(u=>!o.some(m=>m!==u&&u.startsWith(`${m}.`)));if(i.length===0)return t;let s=U(t.row_contract)?t.row_contract:{},a=Array.isArray(s.row_keys)?s.row_keys.filter(u=>typeof u=="string"):[],c=Array.isArray(s.continuation_row_keys)?s.continuation_row_keys.filter(u=>typeof u=="string"):[],l=a.length>0?a:i,d=[...new Set(i)];return JSON.stringify(l)===JSON.stringify(a)&&JSON.stringify(d)===JSON.stringify(c)?t:{...t,row_contract:{...s,row_keys:l,continuation_row_keys:d,jq_selector:typeof s.jq_selector=="string"?s.jq_selector:".checks[].details"}}}function r_(e,t,n,r){let o={...e};return t.include?.source==="canonical"&&(o=Zp(t.command,o,t.include.value)),t.command==="assurance"&&(o=aa(o)),o=ca(o,t.command,r),t.amount?.source==="canonical"&&(o=e_(o,t.amount.value)),n===void 0?o:Zs(o,n)}function o_(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:ea(t)}]].sort((r,o)=>r.tokens-o.tokens)[0]}function ba(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function i_(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...r.source==="default"?{budget_source:r.source,budget_tokens:r.tokens}:{},precedence:e.precedence,...ba(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:Zt(a,n,s,i);if(n===void 0&&oe(c,s,i),n!==void 0&&s.estimated_tokens>r.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",y.USAGE);return c}function s_(e,t,n,r){if(t!==void 0)return!1;let o=e.canonical_options_used.length;return e.cost?.value==="unbounded"?o===(e.cost.source==="canonical"?1:0):e.cost?.source==="legacy"&&o===0?!0:o===0&&(e.cost===void 0||rt(n,r)<=e.cost.value)}function a_(e,t,n,r,o,i,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map($e(e).map(p=>[p.path,Array.isArray(p.value)?p.value.length:Object.keys(p.value).length])),l=[...s.entries()].flatMap(([p,_])=>{let g=c.get(p);if(g>=_.rows)return[];let w=_.baseOffset+g;return[{path:p,cursor:Er({command:t.command,path:p,offset:w,total_rows:_.totalRows,fingerprint:_.fingerprint}),retained_rows:g,remaining_rows:_.totalRows-w,total_rows:_.totalRows}]}),d=l[0],u=d?"; page --output-cursor":"",m=r.source==="session"?`Truncated by the remaining ${r.tokens}-token session budget; start a new output session with a larger token_budget${u}.`:`${r.tokens}-token: raise --output-budget${u}`;n.migration_hints=[m,...t.migration_hints];let f=yr({effective_budget_tokens:r.tokens,measured_result_tokens:i});d&&typeof e.next_cursor!="string"&&(e.next_cursor=d.cursor),e.continuation_kind=o?"producer_cursor":d?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:r.source,budget_tokens:r.tokens,overridden_dimensions:a,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:o,continuation_available:l.length>0,recovery_budget_multiplier:d?1:f.recovery_budget_multiplier,continuations:l,restore_with:d?"recovery":`Retry with --output-budget ${f.output_budget} because no declared row collection can be continued.`,recovery:d?{cursor:d.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${f.output_budget}`,sdk:{outputBudget:f.output_budget},mcp:{outputBudget:f.output_budget}}}}function c_(e,t,n,r){if(typeof n!="string"||!Array.isArray(e.items))return!1;let o=e.items.length;if(o===0||o>=t)return!1;let i;try{i=pn(n)}catch{return!1}let s=i.after_index;if(s===void 0)return!1;let a=e.items.at(-1);if(Object.prototype.toString.call(a)!=="[object Object]")return!1;let c=Reflect.get(a,"id");if(typeof c!="string"||c.length===0)return!1;let l=r?s-(t-o):s+o;return l<0?!1:(e.next_cursor=Ve(i.fingerprint,c,l,i.snapshot),typeof e.applied_limit=="number"&&(e.applied_limit=o),!0)}function l_(e,t,n,r){let o=new Map($e(e).map(s=>{let a=Array.isArray(s.value)?s.value.length:Object.keys(s.value).length,c=n?.path===s.path;return[s.path,{rows:a,totalRows:c?n.total_rows:a,baseOffset:c?n.offset:0,fingerprint:c?n.fingerprint:Qt(s.path,s.value,t)}]})),i=typeof e.next_cursor=="string";return{collectionsBeforeBudget:o,originalItemCount:Array.isArray(e.items)?e.items.length:0,cursorContinuesExistingPage:i,cursorSource:i?e.next_cursor:r.after}}function d_(e,t,n,r,o,i,s,a){let c=t.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(u=>U(u)&&u.verdict!=="pass").length:0,l=r.tokens,d=e;for(let u=0;u<8;u+=1){d=Xs(e,n,l,c>0?new Map([["assertions",c]]):new Map,a);let m=c_(d,i.originalItemCount,i.cursorSource,i.cursorContinuesExistingPage);a_(d,t,n,r,m,s,i.collectionsBeforeBudget),o!==void 0&&(d=Zt(d,o,n,a)),oe(d,n,a);let f=n.estimated_tokens-r.tokens;if(f<=0||l<=0)return d;l=Math.max(0,l-f)}return d}function Ns(e,t,n){let r=ga(e,t);if(!r)return n;let o=ha(t),i=Jt(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?kr(s):void 0,c=t_(r);if(a===void 0&&s_(r,i,n,o))return n;let l=n_(r.command,n),d=o_(r,i),u=r_(l,r,i,a),m=l_(u,r.command,a,t),f={contract_version:1,command:r.command,requested_dimensions:c,...d?.source==="default"?{budget_source:d.source,budget_tokens:d.tokens}:{},precedence:r.precedence,...ba(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=f,u=i===void 0?u:Zt(u,i,f,o),oe(u,f,o),d!==void 0&&f.estimated_tokens>d.tokens){let p=f.estimated_tokens;u=d_(u,r,f,d,i,m,p,o)}return d!==void 0&&f.estimated_tokens>d.tokens?i_(r,c,i,d,f.estimated_tokens,o):u}function _p(e){return U(e)&&U(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function gp(e,t){let n=ga(e,t)?.encoding;return n?.value==="json"||n?.value==="toon"?n.value:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="de370088-9285-5b33-8c7f-da8e9bb88286")}catch{}})();var f_=4096,m_=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"]),sa=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:m_}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function at(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function st(e){return Array.isArray(e)?e.map(st):at(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,st(n)])):e}function wa(e,t){if(!at(e))return st(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||!at(i)?[o,st(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!r.includes(s)).map(([s,a])=>[s,st(a)]))]))}function p_(e,t){return Array.isArray(e)?e.map(n=>wa(n,t)):wa(e,t)}function Qt(e,t,n){let r=n?sa[n]:void 0,o=r?.paths.includes(e)===!0;return u_("sha256").update(se({path:e,value:o?p_(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function Er(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 kr(e){if(e.length>f_)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!at(t)||t.v!==1||je(String(t.c??""))!==t.c||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function aa(e){if(!Array.isArray(e.assertions))return e;let t=n=>!at(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 ca(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,y.USAGE,{code:"read_output_cursor_command_mismatch"});let r=$e(e).find(i=>i.path===n.path),o=r?Array.isArray(r.value)?r.value.length:Object.keys(r.value).length:0;if(!r||o!==n.total_rows||n.offset>o||Qt(n.path,r.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",y.USAGE,{code:"read_output_cursor_stale"});return Ks(e,n.path,n.offset)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e216fd39-09ee-5a04-b0b5-44f518db4f93")}catch{}})();function mE(e){let t=e?.trim()??"";return/^[A-Za-z][A-Za-z0-9+.-]*:\/\//u.test(t)||/^(?:github|gitlab|jira|linear):/iu.test(t)}function pE(e){let t=e?.trim().toLowerCase();return t==="global"||t==="external"}export{z as a,lt as b,en as c,__ as d,dt as e,ut as f,ft as g,mt as h,St as i,Vr as j,un as k,Mc as l,Pc as m,S as n,va as o,Rr as p,y_ as q,h_ as r,xr as s,b_ as t,w_ as u,v_ as v,E_ as w,k_ as x,O_ as y,S_ as z,A_ as A,T_ as B,C_ as C,I_ as D,R_ as E,x_ as F,Ea as G,N_ as H,D_ as I,M_ as J,P_ as K,$_ as L,L_ as M,j_ as N,xo as O,Oa as P,Sa as Q,Aa as R,_t as S,Ta as T,B_ as U,Fe as V,Ia as W,Ra as X,tn as Y,V_ as Z,W_ as _,y as $,h as aa,Cd as ba,Bo as ca,Vo as da,Go as ea,Ko as fa,Na as ga,Da as ha,so as ia,yn as ja,ao as ka,fe as la,dy as ma,uy as na,fy as oa,my as pa,hn as qa,vn as ra,vy as sa,mo as ta,Cl as ua,_o as va,wo as wa,Ry as xa,Sn as ya,Ul as za,xy as Aa,ed as Ba,td as Ca,Ny as Da,Dy as Ea,qy as Fa,By as Ga,Vy as Ha,Eo as Ia,vo as Ja,Wy as Ka,Gy as La,Ky as Ma,ko as Na,Hy as Oa,yd as Pa,Xy as Qa,Jy as Ra,Qy as Sa,So as Ta,Ao as Ua,Zy as Va,eh as Wa,th as Xa,Mo as Ya,nn as Za,sn as _a,an as $a,Z_ as ab,eg as bb,tg as cb,qa as db,Pr as eb,ng as fb,Rt as gb,xn as hb,Nn as ib,Dn as jb,Mn as kb,Pn as lb,$n as mb,cn as nb,sg as ob,se as pb,q as qb,pg as rb,_g as sb,su as tb,_u as ub,yu as vb,hu as wb,Au as xb,Tb as yb,Cb as zb,Ib as Ab,Ja as Bb,Qa as Cb,Za as Db,ec as Eb,ln as Fb,cg as Gb,tc as Hb,ze as Ib,wt as Jb,lg as Kb,dg as Lb,ug as Mb,Zi as Nb,fc as Ob,Fr as Pb,dn as Qb,_c as Rb,gc as Sb,Et as Tb,zr as Ub,hc as Vb,vc as Wb,vg as Xb,Eg as Yb,Sc as Zb,Ac as _b,Tc as $b,Tg as ac,Cg as bc,Cc as cc,kt as dc,Ig as ec,Rg as fc,Ic as gc,Rc as hc,xc as ic,Br as jc,Ot as kc,Nc as lc,xg as mc,Ng as nc,Dg as oc,Mg as pc,Pg as qc,$g as rc,Lg as sc,Mb as tc,nf as uc,$c as vc,fn as wc,Fc as xc,Uc as yc,Ub as zc,ff as Ac,zb as Bc,qb as Cc,Bb as Dc,Vb as Ec,Wb as Fc,Gb as Gc,Kb as Hc,Hb as Ic,Yb as Jc,Xb as Kc,ji as Lc,Jb as Mc,Fi as Nc,Qb as Oc,Zb as Pc,ew as Qc,Mt as Rc,kf as Sc,Gi as Tc,Ki as Uc,aw as Vc,Cf as Wc,er as Xc,mw as Yc,pw as Zc,_w as _c,Qi as $c,Yg as ad,Xg as bd,Ve as cd,pn as dd,_n as ed,Jg as fd,Vc as gd,Qg as hd,Zg as id,Gc as jd,oy as kd,to as ld,Kc as md,nl as nd,ol as od,no as pd,il as qd,sl as rd,ro as sd,de as td,oo as ud,iy as vd,sy as wd,sa as xd,Qt as yd,Er as zd,kr as Ad,ve as Bd,la as Cd,tE as Dd,nE as Ed,jp as Fd,je as Gd,rE as Hd,Ar as Id,Vp as Jd,oE as Kd,ga as Ld,xs as Md,Ns as Nd,_p as Od,gp as Pd,ww as Qd,os as Rd,Aw as Sd,em as Td,Tw as Ud,Ie as Vd,Cw as Wd,Iw as Xd,Im as Yd,Rm as Zd,vs as _d,Y as $d,I as ae,Zw as be,qt as ce,Bm as de,ev as ee,tv as fe,Vm as ge,nv as he,rv as ie,ov as je,Ds as ke,Hm as le,pv as me,Xm as ne,Ps as oe,_v as pe,Ls as qe,Qm as re,np as se,sp as te,pp as ue,vp as ve,Ws as we,Dv as xe,yr as ye,br as ze,Jt as Ae,Zs as Be,wr as Ce,ea as De,mE as Ee,pE as Fe};
30
- //# sourceMappingURL=chunk-TWE3GPQM.js.map
29
+ `)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="85bc6b10-700a-5d06-970f-d544833dd059")}catch{}})();var Ap=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 Me(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Js(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(!Me(n))return;n=n[r]}return n}function _r(e,t,n){let r=t.split("."),o=(i,s)=>{if(s===r.length)return n;let a=r[s];if(Array.isArray(i)){let l=Number(a),d=[...i];return d[l]=o(i[l],s+1),d}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function Qs(e,t,n){let r=$e(e).find(i=>i.path===t);if(!r)return e;let o=Array.isArray(r.value)?r.value.slice(n):Object.fromEntries(Object.entries(r.value).slice(n));return _r(e,t,o)}function Kt(e){let t=e.row_contract;return Me(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 Tp(e){let t=e.row_contract;return Me(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Kt(e)}function Pe(e){return Kt(e).flatMap(t=>{let n=Js(e,t);return Array.isArray(n)||Me(n)?[{path:t,value:n}]:[]})}function $e(e){return Tp(e).flatMap(t=>{let n=Js(e,t);return Array.isArray(n)||Me(n)?[{path:t,value:n}]:[]})}function Ht(e){let t=Pe(e),n=new Set(t.map(o=>o.path)),r=(o,i)=>{if(Array.isArray(o)){n.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>r(s,`${i}.${a}`));return}if(Me(o))for(let[s,a]of Object.entries(o))i.length===0&&Ap.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function Yt(e){return Pe(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function nt(e,t){let n=e;for(let r of Pe(n)){let o=Array.isArray(r.value)?r.value.map((i,s)=>t(i,r.path,s)):Object.fromEntries(Object.entries(r.value).map(([i,s],a)=>[i,t(s,r.path,a)]));n=_r(n,r.path,o)}return n}function Zs(e,t){let n=e,r=!1;for(let o of Pe(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=_r(n,o.path,s)}return{result:n,truncated:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f3d917c2-7ae0-5ea8-b589-dd31af712ad9")}catch{}})();var Cp=8,Ip=64,Rp=5,xp=4,ea=100;function yr(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*Rp/xp),i=Math.ceil(o/ea)*ea;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 rt(e,t){let n=t===void 0?JSON.stringify(e):Xs(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function Np(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function gr(e,t){return typeof e=="string"?e.length<=240?e:(t.compacted=!0,`${e.slice(0,240)}\u2026`):Array.isArray(e)?e.map(n=>gr(n,t)):Np(e)?Object.fromEntries(Object.entries(e).map(([n,r])=>[n,gr(r,t)])):e}function oe(e,t,n){let r=t.estimated_tokens;for(let o=0;o<Cp;o+=1){t.estimated_tokens=r;let i=rt(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function Dp(e,t,n,r,o){for(let i=0;i<Ip;i+=1){if(oe(e,t,o),t.estimated_tokens<=n)return;let s=Ht(e).filter(c=>(Array.isArray(c.value)?c.value.length:Object.keys(c.value).length)>Math.max(1,r.get(c.path)??0)).map(c=>({collection:c,length:Array.isArray(c.value)?c.value.length:Object.keys(c.value).length})).sort((c,l)=>l.length-c.length||c.collection.path.localeCompare(l.collection.path))[0]?.collection;if(!s)return;let a=Math.max(1,r.get(s.path)??0);if(Array.isArray(s.value))s.value.splice(-Math.min(s.value.length-a,Math.max(1,Math.ceil(s.value.length/2))));else{let c=Object.keys(s.value);for(let l of c.slice(-Math.min(c.length-a,Math.max(1,Math.ceil(c.length/2)))))delete s.value[l]}t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],s.path])].sort((c,l)=>c.localeCompare(l)),e.has_more=!0,e.truncated=!0,typeof e.count=="number"&&(e.count=Yt(e))}}function ta(e,t,n,r=new Map,o){let i={compacted:!1},s=gr(e,i);return t.strings_compacted=i.compacted,s.read_output=t,Dp(s,t,n,r,o),oe(s,t,o),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="844b0c44-fc1a-52e7-9d88-2c58e1ab4542")}catch{}})();var hr=256,br=1e4,Mp=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,na=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Pp=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),$p=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&Mp.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=hr,reason:`token_budget must be a safe integer of at least ${hr}.`},{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<=br&&e.seen_item_ids.every(t=>typeof t=="string"&&na.test(t)),reason:`seen_item_ids must contain at most ${br} portable item identifiers.`}];function Jt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Xt(e){throw new h(`--output-session ${e}`,y.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function Qt(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{Xt("must be a valid JSON object.")}Jt(t)||Xt("must be a JSON object.");let n=Object.keys(t).filter(i=>!Pp.has(i));n.length>0&&Xt(`contains unknown field "${n.sort()[0]}".`);let r=$p.find(i=>!i.valid(t));r!==void 0&&Xt(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 ra(e){if(Jt(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:Jt(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function Lp(e){let t=new Set,n=0;for(let r of Pe(e)){let o=Array.isArray(r.value)?r.value:Object.values(r.value);for(let i of o){if(!Jt(i))continue;if(typeof i.context_ref=="string"){n+=1;continue}let s=ra(i);s!==void 0&&na.test(s)&&t.add(s)}}return{deliveredIds:t,suppressedRepeatCount:n}}function oa(e,t){let n=new Set(t.seen_item_ids);return nt(e,r=>{let o=ra(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function wr(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=Lp(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,br-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),l=s.length-a.length,d={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:r.size,...l===0?{}:{seen_item_overflow_count:l},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:c}},u={...e,read_session:d},m=_=>{d.spent_this_call_tokens=_,d.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,_),d.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+d.charged_this_call_tokens),d.remaining_tokens=Math.max(0,t.token_budget-d.spent_total_tokens),d.exhausted=d.remaining_tokens<hr,d.next_state.spent_tokens=d.spent_total_tokens},f=0,p=0;for(let _=0;_<8;_+=1){m(f);let g=rt(u,n);if(g===f)return u;p=Math.max(p,g),f=g}return m(p),u}function ia(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]="8e488707-02ae-54ce-b30b-24371975b98e")}catch{}})();var ve=["include","amount","cost","encoding"],pa=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","files","docs","stats","aggregate","duplicates","package-catalog","package-manage","comments-audit","assurance"],_a=["canonical","legacy","intent","default"],it={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},vr=Symbol.for("pm.readOutputInvocationProvenance"),iE=Object.freeze(ve.map(e=>it[e])),sE=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),ga={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],cost:["--token-budget"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},ya=new Set(["--collapse","--fields","--section"]),Or=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function Sr(e){return e.slice(2).replaceAll("-","_")}function jp(e,t){let n=Or[e];if(n!==void 0)return n;let r=t==="include"?ya.has(e)?"<csv>":Sr(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${it[t]} ${r}.`}function Fp(e){let t=ga[e],n=Object.freeze(Object.fromEntries(ve.map(r=>[r,Object.freeze({dimension:r,canonical_option:it[r],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[r]??[]).map(o=>Object.freeze({flag:o,semantics:Or[o]===void 0?"replacement":"behavior_preserving",migration_hint:jp(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:_a,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...Ar(e).keys()])})}var Up=Object.freeze(pa.map(Fp)),zp=new Map(Up.map(e=>[e.command,e]));function je(e,t={}){let n=ze(e.trim().toLowerCase()),o=n==="package catalog"||n==="packages catalog"||n==="package-catalog"||(n==="package"||n==="packages"||n==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":n==="package manage"||n==="package-manage"?"package-manage":n.split(" ")[0],i=o.startsWith("list-")?"list":o==="ctx"?"context":o;return pa.includes(i)?i:void 0}var qp=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],Bp={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 Vp(e){return qp.some(t=>e[t]!==void 0)}var Wp=[{keys:["outputInclude","output_include"],valid:e=>ot(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||Le(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||Le(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputFormat","output_format"],valid:e=>e==="toon"||e==="json",message:"--output-format must be toon or json."},{keys:["outputSession","output_session"],valid:e=>(Qt(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 aE(e,t){if(!Vp(t))return;let n=je(e,t);if(!n)throw new h(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,y.USAGE);if((Bp[n]??[]).some(r=>t[r]!==void 0&&t[r]!==!1))throw new h(`Universal output controls cannot be combined with a ${n} mutation.`,y.USAGE);for(let r of Wp){let o=r.keys.map(i=>t[i]).find(i=>i!==void 0);if(o!==void 0&&!r.valid(o))throw new h(r.message,y.USAGE)}}function Ar(e){let t=je(e);return t?new Map((ga[t].include??[]).filter(n=>!ya.has(n)&&Or[n]===void 0).map(n=>[Sr(n),ha(n)])):new Map}function Gp(e,t,n){let r=ot(t)??[],o=Ar(e),i=[],s=[],a=n,c=a[vr],l=new Set(c?.canonical_include_modes??[]),d=new Set(c?.explicit_legacy_aliases??[]);for(let f of r){let p=o.get(f);if(p===void 0){i.push(f);continue}let _=`--${f.replaceAll("_","-")}`;wa(ba(n,_))&&d.add(_),n[p]=!0,s.push(f),l.add(f)}let u=je(e)==="get"?i.filter(f=>f!=="item"):[],m=u.length>0;return m&&(n.fields=[...new Set([...ot(n.fields)??[],...u])].join(","),l.add("fields")),(s.length>0||m)&&(a[vr]={canonical_include_modes:[...l],explicit_legacy_aliases:[...d],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function cE(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=Gp(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 ha(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}function ba(e,t){let n=ha(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 wa(e){return e!==void 0&&e!==!1&&e!==null}function ot(e){let n=(Array.isArray(e)?e:[e]).flatMap(r=>typeof r=="string"?r.split(","):[]).map(r=>r.trim()).filter(Boolean);return n.length>0?[...new Set(n)]:void 0}function Le(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 Kp(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=ba(t,o.flag),s={value:i,flag:o.flag};if(wa(i)&&n(s))return s}}function sa(e,t){let n=ot(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:ot(t.value)??[Sr(t.flag)]}}function aa(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=Le(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=Le(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function ca(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=Le(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let r=Le(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function la(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 Hp(e,t,n){if(!e)return!1;let r=new Set(e.explicit_legacy_aliases);if(e.cli_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 Yp(e,t,n){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function Xp(e,t){return ve.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[it[n]]:[])}function va(e,t){let n=je(e,t);if(!n)return;let r=zp.get(n),o=t[vr],i={include:v=>sa(void 0,v),amount:v=>aa(void 0,v),cost:v=>ca(void 0,v),encoding:v=>la(void 0,v)},s=Object.fromEntries(ve.map(v=>[v,Kp(r.dimensions[v],t,R=>i[v](R)!==void 0,R=>Hp(o,v,R))])),a=ve.flatMap(v=>{let R=s[v];return R?[R.flag]:[]}),c=ve.flatMap(v=>{let R=s[v];return R?[r.dimensions[v].legacy_aliases.find(ct=>ct.flag===R.flag).migration_hint]:[]}),l=la(t.outputFormat??t.output_format,s.encoding),d=sa(t.outputInclude??t.output_include,s.include),u=aa(t.outputLimit??t.output_limit,s.amount),m=ca(t.outputBudget??t.output_budget,s.cost),f=Yp(e,s,o),p=ro(e,{generateFallback:!0}),_=l?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",g=m??(f?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:d,amount:u,cost:g,encoding:l,canonical_options_used:Xp({include:d,amount:u,cost:g,encoding:l},o),legacy_aliases_used:a,migration_hints:c,precedence:_a}}function z(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Tr=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"]),Jp=["collection_counts","notes_count","tests_count"];function Ea(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function Qp(e){let t=z(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...Jp.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!Tr.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 Zp(e,t){let n=Qp(e),r=t.filter(u=>!n.valid.includes(u));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,y.USAGE);let o=t.includes("item"),i=t.flatMap(u=>u.startsWith("item.")?[u.slice(5)]:n.itemFields.includes(u)?[u]:[]).filter((u,m,f)=>f.indexOf(u)===m);if(o&&i.length>0)throw new h("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",y.USAGE);let s=new Set(t.filter(u=>n.sections.includes(u))),a=Object.fromEntries(Object.entries(e).filter(([u])=>Tr.has(u)||s.has(u)));o?a.item=n.item:i.length>0&&(a.item=Ea(n.item,i));let c=[...o?[]:i.length>0?n.itemFields.filter(u=>!i.includes(u)).map(u=>({name:`item.${u}`,restore_with:`--output-include item.${u}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(u=>!s.has(u)).map(u=>({name:u,restore_with:`--output-include ${u}`}))],d=[...z(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 da(e){let t=0;return nt({...e},n=>(z(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function e_(e,t,n,r){if(da(t)===0||da(n)>0)return;let o=[...Ar(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${r.join(", ")}. No selector matched any returned row field.${i}`,y.USAGE)}function t_(e,t,n){if(e==="get")return Zp(t,n);let r=Kt(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=nt(s,l=>z(l)?Ea(l,a):l);return e_(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||Tr.has(s)))}function n_(e,t){if(t==="unbounded")return e;let{result:n,truncated:r}=Zs(e,t);return r&&(n.has_more=!0,n.truncated=!0,typeof n.count=="number"&&(n.count=Yt(n)),n.applied_bound={kind:"output_limit",source:"explicit",value:t}),n}function r_(e){return ve.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(it[t]))}function ka(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function en(e,t,n,r){let o=wr(e,t,r);for(let i=0;i<8;i+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;oe(o,n,r),o=wr(o,t,r);let c=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&c===a)return o}return o}function $s(e,t){if(!z(e.read_output))return e;let n=ka(t),r=e.read_output,o=Qt(t.outputSession??t.output_session);return o===void 0?(oe(e,r,n),e):en(e,o,r,n)}function o_(e,t){if(e!=="validate")return t;let n=z(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(u=>z(u)&&u.name==="diagnostic_rows"))return t;let o=[...new Set(Ht(t).map(({path:u})=>u).filter(u=>/^checks\.\d+\.details\./u.test(u)))],i=o.filter(u=>!o.some(m=>m!==u&&u.startsWith(`${m}.`)));if(i.length===0)return t;let s=z(t.row_contract)?t.row_contract:{},a=Array.isArray(s.row_keys)?s.row_keys.filter(u=>typeof u=="string"):[],c=Array.isArray(s.continuation_row_keys)?s.continuation_row_keys.filter(u=>typeof u=="string"):[],l=a.length>0?a:i,d=[...new Set(i)];return JSON.stringify(l)===JSON.stringify(a)&&JSON.stringify(d)===JSON.stringify(c)?t:{...t,row_contract:{...s,row_keys:l,continuation_row_keys:d,jq_selector:typeof s.jq_selector=="string"?s.jq_selector:".checks[].details"}}}function i_(e,t,n,r){let o={...e};return t.include?.source==="canonical"&&(o=t_(t.command,o,t.include.value)),t.command==="assurance"&&(o=fa(o)),o=ma(o,t.command,r),t.amount?.source==="canonical"&&(o=n_(o,t.amount.value)),n===void 0?o:oa(o,n)}function s_(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:ia(t)}]].sort((r,o)=>r.tokens-o.tokens)[0]}function Oa(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function a_(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...r.source==="default"?{budget_source:r.source,budget_tokens:r.tokens}:{},precedence:e.precedence,...Oa(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:en(a,n,s,i);if(n===void 0&&oe(c,s,i),n!==void 0&&s.estimated_tokens>r.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",y.USAGE);return c}function c_(e,t,n,r){if(t!==void 0)return!1;let o=e.canonical_options_used.length;return e.cost?.value==="unbounded"?o===(e.cost.source==="canonical"?1:0):e.cost?.source==="legacy"&&o===0?!0:o===0&&(e.cost===void 0||rt(n,r)<=e.cost.value)}function l_(e,t,n,r,o,i,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map($e(e).map(p=>[p.path,Array.isArray(p.value)?p.value.length:Object.keys(p.value).length])),l=[...s.entries()].flatMap(([p,_])=>{let g=c.get(p);if(g>=_.rows)return[];let w=_.baseOffset+g;return[{path:p,cursor:Er({command:t.command,path:p,offset:w,total_rows:_.totalRows,fingerprint:_.fingerprint}),retained_rows:g,remaining_rows:_.totalRows-w,total_rows:_.totalRows}]}),d=l[0],u=d?"; page --output-cursor":"",m=r.source==="session"?`Truncated by the remaining ${r.tokens}-token session budget; start a new output session with a larger token_budget${u}.`:`${r.tokens}-token: raise --output-budget${u}`;n.migration_hints=[m,...t.migration_hints];let f=yr({effective_budget_tokens:r.tokens,measured_result_tokens:i});d&&typeof e.next_cursor!="string"&&(e.next_cursor=d.cursor),e.continuation_kind=o?"producer_cursor":d?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:r.source,budget_tokens:r.tokens,overridden_dimensions:a,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:o,continuation_available:l.length>0,recovery_budget_multiplier:d?1:f.recovery_budget_multiplier,continuations:l,restore_with:d?"recovery":`Retry with --output-budget ${f.output_budget} because no declared row collection can be continued.`,recovery:d?{cursor:d.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${f.output_budget}`,sdk:{outputBudget:f.output_budget},mcp:{outputBudget:f.output_budget}}}}function d_(e,t,n,r){if(typeof n!="string"||!Array.isArray(e.items))return!1;let o=e.items.length;if(o===0||o>=t)return!1;let i;try{i=_n(n)}catch{return!1}let s=i.after_index;if(s===void 0)return!1;let a=e.items.at(-1);if(Object.prototype.toString.call(a)!=="[object Object]")return!1;let c=Reflect.get(a,"id");if(typeof c!="string"||c.length===0)return!1;let l=r?s-(t-o):s+o;return l<0?!1:(e.next_cursor=Ve(i.fingerprint,c,l,i.snapshot),typeof e.applied_limit=="number"&&(e.applied_limit=o),!0)}function u_(e,t,n,r){let o=new Map($e(e).map(s=>{let a=Array.isArray(s.value)?s.value.length:Object.keys(s.value).length,c=n?.path===s.path;return[s.path,{rows:a,totalRows:c?n.total_rows:a,baseOffset:c?n.offset:0,fingerprint:c?n.fingerprint:Zt(s.path,s.value,t)}]})),i=typeof e.next_cursor=="string";return{collectionsBeforeBudget:o,originalItemCount:Array.isArray(e.items)?e.items.length:0,cursorContinuesExistingPage:i,cursorSource:i?e.next_cursor:r.after}}function f_(e,t,n,r,o,i,s,a){let c=t.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(u=>z(u)&&u.verdict!=="pass").length:0,l=r.tokens,d=e;for(let u=0;u<8;u+=1){d=ta(e,n,l,c>0?new Map([["assertions",c]]):new Map,a);let m=d_(d,i.originalItemCount,i.cursorSource,i.cursorContinuesExistingPage);l_(d,t,n,r,m,s,i.collectionsBeforeBudget),o!==void 0&&(d=en(d,o,n,a)),oe(d,n,a);let f=n.estimated_tokens-r.tokens;if(f<=0||l<=0)return d;l=Math.max(0,l-f)}return d}function Ls(e,t,n){let r=va(e,t);if(!r)return n;let o=ka(t),i=Qt(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?kr(s):void 0,c=r_(r);if(a===void 0&&c_(r,i,n,o))return n;let l=o_(r.command,n),d=s_(r,i),u=i_(l,r,i,a),m=u_(u,r.command,a,t),f={contract_version:1,command:r.command,requested_dimensions:c,...d?.source==="default"?{budget_source:d.source,budget_tokens:d.tokens}:{},precedence:r.precedence,...Oa(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=f,u=i===void 0?u:en(u,i,f,o),oe(u,f,o),d!==void 0&&f.estimated_tokens>d.tokens){let p=f.estimated_tokens;u=f_(u,r,f,d,i,m,p,o)}return d!==void 0&&f.estimated_tokens>d.tokens?a_(r,c,i,d,f.estimated_tokens,o):u}function yp(e){return z(e)&&z(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function hp(e,t){let n=va(e,t)?.encoding;return n?.value==="json"||n?.value==="toon"?n.value:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="de370088-9285-5b33-8c7f-da8e9bb88286")}catch{}})();var p_=4096,__=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"]),ua=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:__}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function at(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function st(e){return Array.isArray(e)?e.map(st):at(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,st(n)])):e}function Sa(e,t){if(!at(e))return st(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||!at(i)?[o,st(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!r.includes(s)).map(([s,a])=>[s,st(a)]))]))}function g_(e,t){return Array.isArray(e)?e.map(n=>Sa(n,t)):Sa(e,t)}function Zt(e,t,n){let r=n?ua[n]:void 0,o=r?.paths.includes(e)===!0;return m_("sha256").update(se({path:e,value:o?g_(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function Er(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 kr(e){if(e.length>p_)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!at(t)||t.v!==1||je(String(t.c??""))!==t.c||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function fa(e){if(!Array.isArray(e.assertions))return e;let t=n=>!at(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 ma(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,y.USAGE,{code:"read_output_cursor_command_mismatch"});let r=$e(e).find(i=>i.path===n.path),o=r?Array.isArray(r.value)?r.value.length:Object.keys(r.value).length:0;if(!r||o!==n.total_rows||n.offset>o||Zt(n.path,r.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",y.USAGE,{code:"read_output_cursor_stale"});return Qs(e,n.path,n.offset)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e216fd39-09ee-5a04-b0b5-44f518db4f93")}catch{}})();function yE(e){let t=e?.trim()??"";return/^[A-Za-z][A-Za-z0-9+.-]*:\/\//u.test(t)||/^(?:github|gitlab|jira|linear):/iu.test(t)}function hE(e){let t=e?.trim().toLowerCase();return t==="global"||t==="external"}export{q as a,lt as b,tn as c,y_ as d,dt as e,ut as f,ft as g,mt as h,St as i,Vr as j,fn as k,Fc as l,Uc as m,S as n,Aa as o,Rr as p,b_ as q,w_ as r,xr as s,v_ as t,E_ as u,k_ as v,O_ as w,S_ as x,A_ as y,T_ as z,C_ as A,I_ as B,R_ as C,x_ as D,N_ as E,D_ as F,Ta as G,M_ as H,P_ as I,$_ as J,L_ as K,j_ as L,F_ as M,U_ as N,xo as O,Ia as P,Ra as Q,xa as R,_t as S,Na as T,W_ as U,Fe as V,Ma as W,Pa as X,nn as Y,G_ as Z,K_ as _,y as $,h as aa,Dd as ba,Bo as ca,Vo as da,Go as ea,Ko as fa,La as ga,ja as ha,so as ia,hn as ja,ao as ka,fe as la,fy as ma,my as na,py as oa,_y as pa,bn as qa,En as ra,ky as sa,mo as ta,Dl as ua,_o as va,wo as wa,Ny as xa,An as ya,Wl as za,Dy as Aa,id as Ba,sd as Ca,My as Da,Py as Ea,Vy as Fa,Wy as Ga,Gy as Ha,Eo as Ia,vo as Ja,Ky as Ka,Hy as La,Yy as Ma,ko as Na,Xy as Oa,Ed as Pa,Qy as Qa,Zy as Ra,eh as Sa,So as Ta,Ao as Ua,th as Va,nh as Wa,rh as Xa,Mo as Ya,rn as Za,an as _a,cn as $a,tg as ab,ng as bb,rg as cb,Ka as db,Pr as eb,og as fb,Rt as gb,Nn as hb,Dn as ib,Mn as jb,Pn as kb,$n as lb,Ln as mb,ln as nb,cg as ob,se as pb,B as qb,gg as rb,yg as sb,uu as tb,wu as ub,Eu as vb,ku as wb,xu as xb,Ib as yb,Rb as zb,xb as Ab,nc as Bb,rc as Cb,oc as Db,ic as Eb,dn as Fb,dg as Gb,sc as Hb,ze as Ib,wt as Jb,ug as Kb,fg as Lb,mg as Mb,os as Nb,yc as Ob,Fr as Pb,un as Qb,wc as Rb,vc as Sb,Et as Tb,zr as Ub,kc as Vb,Ac as Wb,kg as Xb,Og as Yb,Rc as Zb,xc as _b,Nc as $b,Ig as ac,Rg as bc,Dc as cc,kt as dc,xg as ec,Ng as fc,Mc as gc,Pc as hc,$c as ic,Br as jc,Ot as kc,Lc as lc,Dg as mc,Mg as nc,Pg as oc,$g as pc,Lg as qc,jg as rc,Fg as sc,$b as tc,cf as uc,zc as vc,mn as wc,Vc as xc,Wc as yc,qb as zc,yf as Ac,Bb as Bc,Vb as Cc,Wb as Dc,Gb as Ec,Kb as Fc,Hb as Gc,Yb as Hc,Xb as Ic,Jb as Jc,Qb as Kc,ji as Lc,Zb as Mc,Fi as Nc,ew as Oc,tw as Pc,nw as Qc,Mt as Rc,Hi as Sc,Yi as Tc,Xi as Uc,lw as Vc,Qi as Wc,$t as Xc,yw as Yc,hw as Zc,bw as _c,rs as $c,Jg as ad,Qg as bd,Ve as cd,_n as dd,gn as ed,Zg as fd,Yc as gd,ey as hd,ty as id,Jc as jd,sy as kd,to as ld,Qc as md,al as nd,ll as od,no as pd,dl as qd,ul as rd,ro as sd,de as td,oo as ud,ay as vd,cy as wd,ua as xd,Zt as yd,Er as zd,kr as Ad,ve as Bd,pa as Cd,iE as Dd,sE as Ed,Up as Fd,je as Gd,aE as Hd,Ar as Id,Gp as Jd,cE as Kd,va as Ld,$s as Md,Ls as Nd,yp as Od,hp as Pd,Ow as Qd,ls as Rd,Rw as Sd,nm as Td,xw as Ud,Ie as Vd,Nw as Wd,Dw as Xd,xm as Yd,Nm as Zd,As as _d,Y as $d,I as ae,rv as be,Bt as ce,Wm as de,ov as ee,iv as fe,Gm as ge,sv as he,av as ie,cv as je,js as ke,Xm as le,hv as me,Qm as ne,Us as oe,bv as pe,qs as qe,ep as re,op as se,cp as te,gp as ue,kp as ve,Xs as we,Lv as xe,yr as ye,br as ze,Qt as Ae,oa as Be,wr as Ce,ia as De,yE as Ee,hE as Fe};
30
+ //# sourceMappingURL=chunk-7JR6M2JR.js.map