@unbrained/pm-cli 2026.10.31 → 2026.11.2

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 (187) hide show
  1. package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/AGENTS.md +3 -3
  4. package/CHANGELOG.md +27 -0
  5. package/CONTRIBUTING.md +1 -1
  6. package/README.md +1 -1
  7. package/dist/cli/migration-gates.js +1 -1
  8. package/dist/cli/register-operations.d.ts +3 -3
  9. package/dist/cli/register-operations.js +1 -1
  10. package/dist/cli-bundle/bundle-manifest.json +1 -1
  11. package/dist/cli-bundle/chunks/{chunk-GMBDZID5.js → chunk-3A4NVHYS.js} +3 -3
  12. package/dist/cli-bundle/chunks/{chunk-VC7TA67O.js → chunk-3ZQQVJT2.js} +19 -19
  13. package/dist/cli-bundle/chunks/{chunk-XDDPSWIW.js → chunk-4HW253W2.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-4OELCF3O.js +2 -0
  15. package/dist/cli-bundle/chunks/{chunk-6PSDQ7T7.js → chunk-533L6D2N.js} +3 -3
  16. package/dist/cli-bundle/chunks/{chunk-35Q2B2GJ.js → chunk-ABFFRQRO.js} +2 -2
  17. package/dist/cli-bundle/chunks/chunk-BFZUJ5QP.js +115 -0
  18. package/dist/cli-bundle/chunks/{chunk-SBVX5CMV.js → chunk-D52QQ7LP.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-P3LNMWL2.js → chunk-DAZFCSDV.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-43R7UTWV.js → chunk-EN27ZQSV.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-MRUA2Z43.js → chunk-GK2CHAT3.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-BS2KXT24.js → chunk-HOGKWJU5.js} +42 -42
  23. package/dist/cli-bundle/chunks/{chunk-WX25MU4N.js → chunk-J3JM36EH.js} +3 -3
  24. package/dist/cli-bundle/chunks/{chunk-V6EWBTNH.js → chunk-JRXD7SIL.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-U7JXZMU5.js → chunk-K46GDAKX.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-PT7TS6E7.js → chunk-KJLGBLR3.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-2AHSPMKJ.js → chunk-NGRPD3ZO.js} +2 -2
  28. package/dist/cli-bundle/chunks/chunk-OJR2YGXF.js +31 -0
  29. package/dist/cli-bundle/chunks/chunk-QHHFXNSQ.js +3 -0
  30. package/dist/cli-bundle/chunks/{chunk-TL3O5GZA.js → chunk-RGHLQGEX.js} +4 -4
  31. package/dist/cli-bundle/chunks/{chunk-24J6TNYE.js → chunk-VEOFWE32.js} +2 -2
  32. package/dist/cli-bundle/chunks/chunk-ZNWDYDFF.js +129 -0
  33. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-KGMJVFH2.js → indexed-receipt-blobs-IEJ2QOW3.js} +2 -2
  34. package/dist/cli-bundle/chunks/item-transaction-JHPBH6N7.js +2 -0
  35. package/dist/cli-bundle/chunks/{mutation-admission-I4RHIT3Q.js → mutation-admission-QUNQZCZ5.js} +2 -2
  36. package/dist/cli-bundle/chunks/{register-list-query-MVDL5EXG.js → register-list-query-NZTK3AXA.js} +2 -2
  37. package/dist/cli-bundle/chunks/{register-mutation-GAF7LXRB.js → register-mutation-2OFAMOVH.js} +2 -2
  38. package/dist/cli-bundle/chunks/register-operations-RFMM5KZ6.js +2 -0
  39. package/dist/cli-bundle/chunks/{register-setup-MZN6ONB3.js → register-setup-6B6Q7M5L.js} +2 -2
  40. package/dist/cli-bundle/chunks/{settlement-hook-YWSWFOZY.js → settlement-hook-UTCEZBFT.js} +2 -2
  41. package/dist/cli-bundle/chunks/{stage-2ZORTOF6.js → stage-VLI4OBVX.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/{chunk-4QPGJO2G.js → chunk-3UD6F2KQ.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/{chunk-EA65HVBO.js → chunk-4NVPDZLX.js} +12 -12
  44. package/dist/cli-bundle/focused-chunks/{chunk-KKRIFBSL.js → chunk-4UUE3YXZ.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/{chunk-NRBUMDLF.js → chunk-5UDDRPYR.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-SFQKCA5K.js → chunk-745IDMTD.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-QFMJGQGO.js → chunk-B6OOKKOX.js} +3 -3
  48. package/dist/cli-bundle/focused-chunks/{chunk-5MCGYBOQ.js → chunk-EJJWOFP5.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/chunk-FUGYXUUL.js +80 -0
  50. package/dist/cli-bundle/focused-chunks/{chunk-6F6APBCX.js → chunk-HMXVTWIV.js} +3 -3
  51. package/dist/cli-bundle/focused-chunks/{chunk-HSAEEWSI.js → chunk-I4Z2SCV5.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/chunk-JLN5CFYM.js +2 -0
  53. package/dist/cli-bundle/focused-chunks/chunk-K4FMZB4Y.js +23 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-DFUTCKUF.js → chunk-MQVBWFJF.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-2J7T2UCH.js → chunk-NJFMG3IK.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-HPWT3RBG.js → chunk-PCCZ72C3.js} +54 -54
  57. package/dist/cli-bundle/focused-chunks/chunk-PF553UVP.js +44 -0
  58. package/dist/cli-bundle/focused-chunks/{chunk-MW77Q3AQ.js → chunk-Q23K6WLV.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{chunk-Y6UYRMVG.js → chunk-QNXXOFLQ.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-JLXGRDTG.js → chunk-QVFE5LIX.js} +3 -3
  61. package/dist/cli-bundle/focused-chunks/{chunk-KH5QJXY7.js → chunk-RUCG6UWN.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-JNKRUCVZ.js → chunk-SGWYNU7T.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/chunk-TGS5RXBY.js +26 -0
  64. package/dist/cli-bundle/focused-chunks/{chunk-PC3R5CJV.js → chunk-WD43E7RU.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-PFBQOZPK.js → chunk-YM4AMP7H.js} +2 -2
  66. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-KHWT44EK.js → indexed-receipt-blobs-FT3KF6VJ.js} +2 -2
  67. package/dist/cli-bundle/focused-chunks/{item-transaction-LU75EG7D.js → item-transaction-F4SN7TXJ.js} +2 -2
  68. package/dist/cli-bundle/focused-chunks/{mutation-admission-KDJ7SCPA.js → mutation-admission-7R2FXJ5O.js} +2 -2
  69. package/dist/cli-bundle/focused-chunks/{settlement-hook-SJV52ZTV.js → settlement-hook-KMIBD4F2.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/{stage-R4KEBO37.js → stage-6B3O2GZ6.js} +2 -2
  71. package/dist/cli-bundle/main.js +24 -24
  72. package/dist/cli-bundle/sdk-authoring.js +1 -1
  73. package/dist/cli-bundle/sdk-contracts.js +4 -4
  74. package/dist/cli-bundle/sdk-core.js +1 -1
  75. package/dist/cli-bundle/sdk-governance.js +1 -1
  76. package/dist/cli-bundle/sdk-graph.js +1 -1
  77. package/dist/cli-bundle/sdk-merge.js +57 -57
  78. package/dist/cli-bundle/sdk-query.js +1 -1
  79. package/dist/cli-bundle/sdk-runtime.js +1 -1
  80. package/dist/cli-bundle/sdk-testing.js +1 -1
  81. package/dist/cli-bundle/sdk.js +9 -9
  82. package/dist/core/extensions/extension-types.d.ts +5 -0
  83. package/dist/core/extensions/extension-types.js +1 -1
  84. package/dist/core/item/parse.js +2 -2
  85. package/dist/core/lock/lock-confinement.d.ts +55 -0
  86. package/dist/core/lock/lock-confinement.js +2 -0
  87. package/dist/core/lock/lock-gc.js +1 -1
  88. package/dist/core/lock/lock.js +2 -2
  89. package/dist/core/output/mutation-projection.js +1 -1
  90. package/dist/core/output/output.js +2 -2
  91. package/dist/core/shared/errors.d.ts +6 -0
  92. package/dist/core/shared/errors.js +1 -1
  93. package/dist/core/store/settings-sections.d.ts +61 -0
  94. package/dist/core/store/settings-sections.js +3 -0
  95. package/dist/core/store/settings-validator.d.ts +4 -0
  96. package/dist/core/store/settings-validator.js +1 -1
  97. package/dist/core/store/settings.d.ts +29 -2
  98. package/dist/core/store/settings.js +4 -3
  99. package/dist/core/telemetry/consent.js +2 -2
  100. package/dist/core/telemetry/runtime.js +2 -2
  101. package/dist/core/test/background-runs.js +3 -3
  102. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  103. package/dist/sdk/config.js +1 -1
  104. package/dist/sdk/context-intent-contracts.d.ts +17 -0
  105. package/dist/sdk/context-intent-contracts.js +1 -1
  106. package/dist/sdk/core.d.ts +1 -1
  107. package/dist/sdk/core.js +1 -1
  108. package/dist/sdk/extension-command-context.js +2 -2
  109. package/dist/sdk/generated/error-code-catalog-rows.d.ts +39 -0
  110. package/dist/sdk/generated/error-code-catalog-rows.js +2 -0
  111. package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +3 -3
  112. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  113. package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +3 -3
  114. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  115. package/dist/sdk/generated-error-code-catalog.js +1 -1
  116. package/dist/sdk/index.d.ts +1 -1
  117. package/dist/sdk/index.js +1 -1
  118. package/dist/sdk/init-agent-guidance.js +2 -2
  119. package/dist/sdk/lifecycle/claim.d.ts +27 -0
  120. package/dist/sdk/lifecycle/claim.js +1 -1
  121. package/dist/sdk/lifecycle/mcp-actions.d.ts +1 -1
  122. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  123. package/dist/sdk/lifecycle/task-composition.js +1 -1
  124. package/dist/sdk/mcp/discovery.js +1 -1
  125. package/dist/sdk/output/list-envelope.d.ts +8 -0
  126. package/dist/sdk/output/list-envelope.js +1 -1
  127. package/dist/sdk/output.d.ts +1 -1
  128. package/dist/sdk/output.js +2 -2
  129. package/dist/sdk/public-surface.json +1 -1
  130. package/dist/sdk/query/context.js +2 -2
  131. package/dist/sdk/runtime/actions.js +1 -1
  132. package/dist/sdk/runtime-input.js +1 -1
  133. package/dist/sdk/runtime-primitives.d.ts +2 -1
  134. package/dist/sdk/runtime-primitives.js +1 -1
  135. package/dist/sdk/runtime-public-contracts.d.ts +2 -0
  136. package/dist/sdk/runtime.d.ts +2 -2
  137. package/dist/sdk/runtime.js +1 -1
  138. package/dist/sdk/start-task-status.d.ts +1 -1
  139. package/dist/sdk/start-task-status.js +1 -1
  140. package/docs/AGENT_EVIDENCE_CONSISTENCY.md +10 -0
  141. package/docs/AGENT_GUIDE.md +3 -3
  142. package/docs/COMMANDS.md +1 -0
  143. package/docs/COMMAND_NAMESPACES.md +1 -1
  144. package/docs/CONFIGURATION.md +9 -0
  145. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +9 -6
  146. package/docs/LIFECYCLE_COMMANDS.md +19 -4
  147. package/docs/RELEASING.md +22 -2
  148. package/docs/SDK.md +37 -2
  149. package/docs/SDK_ACTION_CONFORMANCE.md +21 -0
  150. package/docs/SDK_CONFIGURATION_SAFETY.md +55 -0
  151. package/docs/TESTING.md +2 -1
  152. package/docs/agent-task-token-baseline.json +1 -1
  153. package/docs/agent-task-transcripts.json +1 -1
  154. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +12 -3
  155. package/marketplace.json +1 -1
  156. package/package.json +9 -3
  157. package/packages/pm-beads/package.json +1 -1
  158. package/packages/pm-calendar/package.json +1 -1
  159. package/packages/pm-command-kit/package.json +1 -1
  160. package/packages/pm-digital-twin/package.json +1 -1
  161. package/packages/pm-governance-audit/package.json +1 -1
  162. package/packages/pm-guide-shell/package.json +1 -1
  163. package/packages/pm-kanban/package.json +1 -1
  164. package/packages/pm-lifecycle-hooks/package.json +1 -1
  165. package/packages/pm-linked-test-adapters/package.json +1 -1
  166. package/packages/pm-search-advanced/package.json +1 -1
  167. package/packages/pm-templates/package.json +1 -1
  168. package/packages/pm-todos/package.json +1 -1
  169. package/packages/pm-vcs/package.json +1 -1
  170. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  171. package/plugins/pm-claude/package.json +1 -1
  172. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  173. package/plugins/pm-codex/package.json +1 -1
  174. package/plugins/pm-codex/plugin.json +1 -1
  175. package/runtime-dependencies.json +1 -1
  176. package/dist/cli-bundle/chunks/chunk-HSBTITO4.js +0 -3
  177. package/dist/cli-bundle/chunks/chunk-WNF6FOL7.js +0 -31
  178. package/dist/cli-bundle/chunks/chunk-WRXQAW7Q.js +0 -114
  179. package/dist/cli-bundle/chunks/chunk-YT5D5HNG.js +0 -2
  180. package/dist/cli-bundle/chunks/chunk-ZTJVOBDU.js +0 -128
  181. package/dist/cli-bundle/chunks/item-transaction-UWV6UNSV.js +0 -2
  182. package/dist/cli-bundle/chunks/register-operations-JLFRL36Q.js +0 -2
  183. package/dist/cli-bundle/focused-chunks/chunk-57HPXGOQ.js +0 -79
  184. package/dist/cli-bundle/focused-chunks/chunk-AFVN2KCP.js +0 -44
  185. package/dist/cli-bundle/focused-chunks/chunk-GP2WU43K.js +0 -26
  186. package/dist/cli-bundle/focused-chunks/chunk-NOKG4RFN.js +0 -22
  187. package/dist/cli-bundle/focused-chunks/chunk-WHIE2C6Q.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{$a as g,Ya as b,_a as m,ab as k,kb as u}from"./chunk-TGS5RXBY.js";import{z as a}from"./chunk-QVFE5LIX.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7c95b311-b408-50f7-87e8-2c2fa2323092")}catch{}})();var D=[{exit_code:a.SUCCESS,outcome:"effect",success:!0,meaning:"The requested operation completed with its intended effect."},{exit_code:a.GENERIC_FAILURE,outcome:"internal_failure",success:!1,meaning:"An unexpected runtime or internal failure prevented completion."},{exit_code:a.USAGE,outcome:"refused_input",success:!1,meaning:"The invocation was refused because its input or composition was invalid."},{exit_code:a.NOT_FOUND,outcome:"refused_tracker_state",success:!1,meaning:"The requested tracker, item, or resource was not present."},{exit_code:a.CONFLICT,outcome:"conflict",success:!1,meaning:"Current state or concurrency prevented the requested effect."},{exit_code:a.DEPENDENCY_FAILED,outcome:"dependency_failed",success:!1,meaning:"A required dependency operation failed."},{exit_code:a.NO_EFFECT,outcome:"no_effect",success:!0,meaning:"The request was valid and completed, but matched nothing to change."},{exit_code:a.PARTIAL_EFFECT,outcome:"partial_effect",success:!0,meaning:"The request completed and changed some, but not all, selected targets."}],h=[a.SUCCESS,a.GENERIC_FAILURE,a.USAGE,a.NOT_FOUND,a.CONFLICT,a.DEPENDENCY_FAILED],P=new Set(["close-many","update-many"]),w=u.map(e=>({command:e,exit_codes:P.has(e)?[...h,a.NO_EFFECT,a.PARTIAL_EFFECT]:[...h]})),v=new Map(w.map(e=>[e.command,e])),R=[a.SUCCESS,a.NO_EFFECT,a.PARTIAL_EFFECT];function Ee(e){return R.includes(e)}function Te(e){return D.some(t=>t.exit_code===e)}function Ae(e){let t=e.trim().toLowerCase().split(/\s+/u).filter(Boolean).join(" ");return v.get(t)??v.get(t.split(" ")[0])}function Oe(e,t=u,s=w){let o=new Map(s.map(c=>[c.command,c])),i=t.filter(c=>!o.has(c)),r=e.filter(c=>{let n=o.get(c.command)??o.get(c.command.split(" ")[0]);return n===void 0||!n.exit_codes.includes(c.exit_code)}),d=new Set(e.map(c=>c.exit_code)),_=[...new Set(s.flatMap(c=>c.exit_codes))].filter(c=>!d.has(c)).sort((c,n)=>c-n);return{ok:i.length===0&&r.length===0&&_.length===0,missing_commands:i,undeclared_observations:r,unreachable_exit_codes:_}}function Se(e){return e.applied===0&&e.failed>0?{outcome:"dependency_failed",exit_code:a.DEPENDENCY_FAILED}:e.applied===0?{outcome:"no_effect",exit_code:a.NO_EFFECT}:e.skipped>0||e.failed>0||e.unmatched>0?{outcome:"partial_effect",exit_code:a.PARTIAL_EFFECT}:{outcome:"effect",exit_code:a.SUCCESS}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7df4fe91-e8a4-540f-8737-c67f2efa460e")}catch{}})();var x=[{exit_code:1,class:"generic_failure"},{exit_code:2,class:"usage"},{exit_code:3,class:"not_found"},{exit_code:4,class:"conflict"},{exit_code:5,class:"dependency_failed"}],L=new Map(x.map(e=>[e.exit_code,e.class]));function f(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].sort()}function q(e){if(!e)return[];let t=new Set,s=new Set;return e.map(o=>{let i=o.state.trim(),r=o.probe_id.trim(),d=f(o.entrypoints);if(!/^[a-z][a-z0-9_]*$/.test(i)||!/^[a-z][a-z0-9-]*$/.test(r)||d.length===0||t.has(i)||s.has(r))throw new TypeError("Invalid pm refusal state contract");return t.add(i),s.add(r),{state:i,probe_id:r,entrypoints:d,expected_exit_class:o.expected_exit_class}}).sort((o,i)=>o.state.localeCompare(i.state))}function F(e,t,s,o,i){return![[1,2,3,4,5].includes(e.exit_code),e.meaning.trim().length>0,e.recovery.trim().length>0,t.length>0,s.length>0,/^[a-z][a-z0-9_]*$/.test(o),i.every(r=>/^[a-z][a-z0-9_]*$/.test(r)),L.get(e.exit_code)===e.class].includes(!1)}function j(e,t){let s=e,o=new Set;for(;s.canonical_code!==s.code;){if(o.has(s.code))throw new TypeError(`Alias cycle in pm error code catalog: ${e.code}`);o.add(s.code);let i=t.get(s.canonical_code);if(!i)throw new TypeError(`Invalid pm error code contract: ${e.code}`);s=i}return s}function $(e){let t=new Map(e.map(s=>[s.code,s]));for(let s of e){let o=j(s,t);if(o.exit_code!==s.exit_code||o.class!==s.class)throw new TypeError(`Alias transport mismatch for pm error code: ${s.code}`);let i=e.filter(r=>r.code!==o.code&&r.canonical_code===o.code).map(r=>r.code).sort();if(s.code===o.code?JSON.stringify(s.aliases)!==JSON.stringify(i):s.aliases.length>0)throw new TypeError(`Invalid pm error code contract: ${s.code}`)}}function E(e){let t=new Set,s=e.map(o=>{let i=o.code.trim();if(!/^[a-z][a-z0-9_]*$/.test(i))throw new TypeError(`Invalid pm error code: ${JSON.stringify(o.code)}`);if(t.has(i))throw new TypeError(`Duplicate pm error code: ${i}`);t.add(i);let r=f(o.sources),d=f(o.emitting_commands),_=(o.canonical_code??i).trim(),c=f(o.aliases??[]),n=q(o.owned_states);if(!F(o,r,d,_,c))throw new TypeError(`Invalid pm error code contract: ${i}`);if(n.some(l=>l.expected_exit_class!==o.class))throw new TypeError(`Invalid pm refusal state exit class: ${i}`);return Object.freeze({...o,code:i,meaning:o.meaning.trim(),recovery:o.recovery.trim(),sources:r,emitting_commands:d,canonical_code:_,aliases:c,owned_states:n})});return $(s),Object.freeze(s.sort((o,i)=>o.code.localeCompare(i.code)))}function Ne(e,t){let s=C(e,t);return C(s.canonical_code??s.code,t)}function C(e,t){let s=e.trim(),o=t.find(i=>i.code===s);if(!o)throw new TypeError(`Unknown pm error code "${s}"`);return 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]="1e8c03e6-149a-5819-a000-65e7e3b12f6d")}catch{}})();var z="Inspect the structured error guidance and retry the suggested command.",U=new Map(x.map(e=>[e.exit_code,e.class]));function T(e){return e.map(t=>{let s=`${t.code.replaceAll("_"," ")} condition.`,o={code:t.code,meaning:`${s.charAt(0).toUpperCase()}${s.slice(1)}`,stability:t.stable?"stable":"provisional",exit_code:t.exit_code,class:U.get(t.exit_code),recovery:z,sources:t.sources,emitting_commands:t.emitting_commands??["*"],canonical_code:t.canonical_code??t.code,aliases:t.aliases??[]};return t.owned_states&&(o.owned_states=t.owned_states),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]="6141e2c8-bf6f-5170-a0ae-9675dcc53949")}catch{}})();var A=[{code:"acceptance_criteria_mutation_conflict",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_remove_unmatched",exit_code:3,sources:["sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_semicolon_forbidden",exit_code:2,stable:!0,sources:["core/item/parse.ts"]},{code:"accepted_rejected_value",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"alias_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"alias_target_missing",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"already_claimed_by",exit_code:4,stable:!0,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"ambiguous_option_combination",exit_code:2,stable:!0,sources:["sdk/lifecycle/claim.ts","sdk/lifecycle/plan.ts"],emitting_commands:["claim","plan"]},{code:"annotation_alias_conflict",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"annotation_flag_like_value",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_if_absent_without_append",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_message_without_text",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_transposed_subcommand",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"append_empty_body",exit_code:2,stable:!0,sources:["sdk/lifecycle/append.ts"],emitting_commands:["append"]},{code:"assurance_registry_invalid",exit_code:1,sources:["sdk/governance/assurance.ts"]},{code:"bare_comma_entry_ambiguous",exit_code:2,sources:["core/item/parse.ts"]},{code:"blocker_identity_read_failed",exit_code:1,sources:["sdk/query/get.ts"],emitting_commands:["get"]},{code:"body_file_conflicts_with_body",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_missing_path",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_unreadable",exit_code:3,stable:!0,sources:["core/io/body-file.ts"]},{code:"budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"bulk_create_route",exit_code:2,sources:["cli/register-mutation.ts"]},{code:"bulk_ids_input_empty",exit_code:2,sources:["core/io/bulk-ids-input.ts","sdk/history-compact.ts","sdk/history-mcp.ts"],owned_states:[{state:"bulk_ids_stdin_contains_no_nonempty_ids",probe_id:"bulk-ids-stdin-empty",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_missing_path",exit_code:2,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_token_omits_its_path",probe_id:"bulk-ids-file-path-missing",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_unreadable",exit_code:3,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_path_cannot_be_read",probe_id:"bulk-ids-file-unreadable",entrypoints:["update-many"],expected_exit_class:"not_found"}]},{code:"bundle_integrity_torn_install",exit_code:1,stable:!0,sources:["cli/bundle-integrity.ts"]},{code:"capability_undeclared",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"capability_unused",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"child_projection_item_bound_exceeded",exit_code:1,stable:!0,sources:["sdk/item-children.ts"]},{code:"close_reason_required",exit_code:2,stable:!0,sources:["sdk/lifecycle-policy.ts","sdk/lifecycle/close-many.ts"],emitting_commands:["*","close-many"]},{code:"close_through_update",exit_code:1,stable:!0,sources:["core/telemetry/observability.ts"]},{code:"close_validation_missing_fields",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"collected_zero_items",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"collection_transposed_subcommand",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"command_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"command_namespace",exit_code:2,stable:!0,sources:["sdk/cli-contracts/runtime-contracts.ts"]},{code:"command_override_conflict",exit_code:4,stable:!0,sources:["sdk/compose.ts"]},{code:"config_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"config_key_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"config_value_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"conflicting_lifecycle_owner",exit_code:2,stable:!0,sources:["cli/register-operations.ts"]},{code:"context_evaluation_read_incomplete",exit_code:2,sources:["sdk/context-relevance.ts"]},{code:"context_signal_store_invalid",exit_code:2,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_stale",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_write_failed",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_takes_no_item_argument",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"core_item_field_requires_dedicated_flag",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"create_positional_type_without_title",exit_code:2,stable:!0,sources:["cli/register-mutation.ts"]},{code:"dependency_cardinality_created",exit_code:2,sources:["sdk/graph/cardinality-integrity.ts"]},{code:"dependency_edge_not_allowed",exit_code:2,stable:!0,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_flag_value_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_remove_no_match",exit_code:3,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"dependency_target_not_found",exit_code:3,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_temporal_order_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"duplicate_canonical_flag",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"duplicate_command",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"duplicate_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"duplicate_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"duplicate_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"duplicate_probe",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"duplicate_sweep_cost_limit",exit_code:4,stable:!0,sources:["sdk/query/duplicate-candidates.ts"],emitting_commands:["duplicate-candidates"]},{code:"duplicate_target_circular",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_is_duplicate",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_missing",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_self",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"empty_corpus",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"empty_surface",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"event_cursor_query_mismatch",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"event_history_integrity_failed",exit_code:1,sources:["core/history/event-index.ts"]},{code:"event_index_unavailable",exit_code:1,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"exit_code_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"extension_command_activation_failed",exit_code:1,stable:!0,sources:["cli/commander-usage.ts"]},{code:"extension_dependency_name_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_spec_invalid",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_version_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_flag_value_invalid",exit_code:2,sources:["cli/extension-command-options.ts"]},{code:"extension_install_incomplete_source_scan",exit_code:2,sources:["sdk/extension/install-plan.ts"]},{code:"extension_install_rollback_failed",exit_code:1,sources:["sdk/extension/install-snapshot.ts"]},{code:"extension_install_soft_failed",exit_code:1,stable:!0,sources:["cli/register-setup.ts"]},{code:"extension_install_source_contains_destination",exit_code:2,stable:!0,sources:["sdk/extension/install-runtime.ts"]},{code:"extension_item_field_reserved",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_type_conflict",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_unknown",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_mutation_guard_failed",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_decision",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_denial",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_timed_out",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_read_output_invalid",exit_code:2,sources:["sdk/read-output/extension.ts"]},{code:"extension_update_health_partial_coverage",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"extensions_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"field_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_mcp_input_collision",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"github_source_entry_unbuilt",exit_code:2,stable:!0,sources:["sdk/extension/shared.ts"]},{code:"hierarchy_cardinality_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_cycle_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_parent_divergence_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"history_author_acknowledge_plan_conflict",exit_code:4,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_plan_fingerprint_required",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_preview_limit_invalid",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_required_values_missing",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_conflict",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_required",exit_code:2,stable:!0,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_not_actionable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_unreadable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_baseline_unavailable",exit_code:1,sources:["core/history/projection.ts"]},{code:"history_drift_chain_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_chain_mismatches"]},{code:"history_drift_hash_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_hash_mismatches"]},{code:"history_drift_merge_receipt",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_missing_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_missing_streams"]},{code:"history_drift_unreadable_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_unreadable_streams"]},{code:"history_drift_version_skew",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_version_skews"]},{code:"history_json_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/history/read.ts"],canonical_code:"merge_conflict_markers_detected"},{code:"history_replay_invalid",exit_code:1,sources:["core/history/projection.ts","core/history/tombstone.ts"]},{code:"history_salvage_refused",exit_code:4,sources:["sdk/history/salvage.ts"]},{code:"history_stream_over_compact_threshold",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"history_target_out_of_range",exit_code:1,stable:!0,sources:["core/history/projection.ts"]},{code:"history_timestamp_invalid",exit_code:1,sources:["core/history/event-index.ts","core/history/history.ts"]},{code:"history_union_rebase_conflict",exit_code:4,sources:["sdk/merge/history-scalar-rebase.ts"]},{code:"history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_unknown_author_events"]},{code:"history_version_mapping_unavailable",exit_code:2,sources:["core/history/version-address.ts"]},{code:"history_version_pruned",exit_code:2,sources:["core/history/projection.ts"]},{code:"host_environment_capacity_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_operation_invalid",exit_code:2,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_permission_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_resource_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"improvement_metric_contract_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"improvement_observation_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"incomplete_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"inconsistent_concept_kind",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"init_existing_settings_requires_force",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_gitignore_unwritable",exit_code:1,stable:!0,sources:["sdk/workspace.ts"]},{code:"init_id_prefix_conflict",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_id_prefix_path_like",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"integrity_history_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_history_conflict_markers"]},{code:"integrity_history_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_history_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_ahead_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_ahead_items"]},{code:"integrity_item_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_outdated_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_outdated_items"]},{code:"integrity_item_parse_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"invalid_argument_value",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/item/priority.ts","core/telemetry/observability.ts","sdk/context-intent-contracts.ts","sdk/dependencies.ts","sdk/governance/assurance-mutation-error.ts","sdk/lifecycle/create.ts","sdk/lifecycle/task-composition.ts","sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts","sdk/query/next.ts","sdk/runtime-input.ts","sdk/runtime/mutation-admission.ts","sdk/runtime/mutation-value-validation.ts","sdk/runtime/schema-preview.ts","sdk/workspace.ts"],emitting_commands:["*","create","next","task-composition","update","update-many"]},{code:"invalid_command_usage",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"invalid_event_cursor",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_cursor_mode",exit_code:2,sources:["cli/register-list-query.ts","sdk/mutation-events.ts","sdk/runtime-extended-actions.ts"]},{code:"invalid_event_follow_interval",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_limit",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_since",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_history_analytics_limit",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_minimum_sample",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_since",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_improvement_ledger",exit_code:1,sources:["sdk/improvement-ledger-validation.ts"]},{code:"invalid_improvement_metric",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_limit",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_timestamp",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_provenance_predicate",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"invalid_query_cursor",exit_code:2,stable:!0,sources:["sdk/pagination.ts","sdk/query/window-pagination.ts"]},{code:"invalid_read_output_session",exit_code:2,sources:["sdk/read-output-session.ts"]},{code:"invalid_reproducible_process_environment",exit_code:2,sources:["sdk/reproducibility/process.ts"]},{code:"invalid_workspace_snapshot_target",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"item_already_active",exit_code:4,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"item_already_exists",exit_code:4,stable:!0,sources:["sdk/lifecycle/create.ts"],emitting_commands:["create"]},{code:"item_deleted",exit_code:3,sources:["core/history/tombstone.ts"]},{code:"item_document_encoding_invalid",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_document_invalid",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_document_roundtrip_failed",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_format_version_unsupported",exit_code:4,sources:["core/item/item-format.ts"]},{code:"item_id_collision",exit_code:4,stable:!0,sources:["sdk/lifecycle/copy.ts"],emitting_commands:["copy"]},{code:"item_identity_ambiguous",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_identity_conflict",exit_code:4,sources:["sdk/governance/validate-history-drift.ts","sdk/merge/three-way.ts","sdk/query/get.ts"],emitting_commands:["*","get"]},{code:"item_identity_reserved",exit_code:4,sources:["core/history/history.ts"]},{code:"item_not_found",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/item-store.ts","core/telemetry/observability.ts","sdk/governance/validate-history-drift.ts"]},{code:"likely_duplicate",exit_code:4,stable:!0,sources:["sdk/similarity.ts"]},{code:"linked_artifact_mutation_conflict",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_resource_positional_value",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"linked_test_command_not_executable",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_context_invalid",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_remove_no_match",exit_code:3,sources:["sdk/test/execution.ts"]},{code:"linked_test_update_ambiguous",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_update_no_match",exit_code:3,sources:["sdk/test/update.ts"]},{code:"linked_test_value_not_quoted",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"list_source_incomplete",exit_code:1,stable:!0,sources:["sdk/query/list.ts"],emitting_commands:["list"]},{code:"local_package_archive_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"local_source_not_found_bare_name",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"lock_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/lock/lock.ts","core/telemetry/observability.ts"]},{code:"lock_lost",exit_code:4,sources:["core/lock/lock.ts"]},{code:"lock_path_unsafe",exit_code:4,sources:["core/lock/lock-confinement.ts"]},{code:"locks_stale_count",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"locks_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"malformed_plan_step_evidence",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"managed_state_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"managed_state_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_capabilities_absent",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"manifest_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_unknown_key",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_declares_an_unknown_top_level_key",probe_id:"author-manifest-unknown-key",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"manifest_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"mcp_annotation_file_unavailable",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"mcp_stdin_unavailable",exit_code:2,sources:["sdk/annotations.ts"]},{code:"mcp_task_not_found_or_not_authorized",exit_code:3,sources:["sdk/mcp/tasks.ts"]},{code:"merge_artifacts_ignored",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_bun_launcher_unavailable",exit_code:5,sources:["sdk/merge/install.ts"]},{code:"merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/item/item-format.ts"],aliases:["history_merge_conflict_markers_detected"]},{code:"merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_git_config_unwritable",exit_code:5,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_receipt_evidence_invalid",exit_code:4,sources:["core/diagnostics/remediation.ts","sdk/merge/reconcile.ts"]},{code:"merge_receipt_history_reference_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_receipt_not_portable",exit_code:4,sources:["sdk/merge/receipts.ts"]},{code:"merge_receipts_pending",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_reconcile_receipt_evidence_untrusted",exit_code:4,sources:["sdk/history-repair.ts"]},{code:"merge_root_not_found",exit_code:3,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_settlement_hook_conflict",exit_code:4,sources:["sdk/merge/settlement-hook.ts"]},{code:"merge_settlement_review_required",exit_code:4,sources:["sdk/merge/ignored-artifacts.ts","sdk/merge/reconcile.ts","sdk/merge/stage.ts"]},{code:"missing_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"missing_budget",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]}];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="174d109b-2b19-5cd7-a10b-0787747c662d")}catch{}})();var O=[{code:"missing_cli_flag",exit_code:1,sources:["sdk/cli-contracts/tool-option-contracts.ts"]},{code:"missing_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"missing_directory",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"missing_init_recovery",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"missing_lifecycle_target",exit_code:2,stable:!0,sources:["sdk/extension.ts"]},{code:"missing_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"missing_observed_signature",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"missing_parameter_alias",exit_code:1,sources:["sdk/cli-contracts/tool-option-contracts.ts"]},{code:"missing_positive_execution_receipt",exit_code:1,sources:["sdk/test/execution.ts"]},{code:"missing_probe",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"missing_required_argument",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","cli/main.ts","cli/register-mutation.ts","cli/schema/registration.ts","core/telemetry/observability.ts","sdk/governance/assurance-action.ts","sdk/history-redact.ts","sdk/invocation-author.ts","sdk/lifecycle/claim.ts"],emitting_commands:["*","claim"]},{code:"missing_required_option",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/context-intent-contracts.ts","sdk/lifecycle/create.ts","sdk/lifecycle/plan.ts"],emitting_commands:["*","create","plan"]},{code:"missing_suggested_retry",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"missing_suggested_retry_args",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"module_import_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"multi_target_github_install_ambiguous",exit_code:2,stable:!0,sources:["cli/register-setup.ts"]},{code:"mutation_author_required",exit_code:2,stable:!0,sources:["sdk/mutation-guard.ts"]},{code:"mutation_document_unreadable",exit_code:2,sources:["cli/register-structured-mutation.ts"]},{code:"mutation_option_value_invalid",exit_code:2,sources:["sdk/lifecycle/mutation-option-validation.ts"],emitting_commands:["item mutate"]},{code:"mutation_secret_guard_blocked",exit_code:4,stable:!0,sources:["sdk/mutation-guard.ts"]},{code:"no_matching_tests",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_projects_matched_filters",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_test_files_found",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_tests_found",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_update_fields",exit_code:1,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"no_version_bounds_declared",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_omits_canonical_pm_version_bounds",probe_id:"author-manifest-version-bounds-missing",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"non_refusal_exit",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"npm_pack_json_shape_unsupported",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_archive_missing",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_archive_unsafe",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_not_found",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"ownership_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/annotations.ts"]},{code:"ownership_dependency_bypass_restricted_options",exit_code:1,stable:!0,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"ownership_metadata_bypass_restricted_options",exit_code:1,stable:!0,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"package_spec_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"package_upgrade_modes_mutually_exclusive",exit_code:2,sources:["sdk/governance/upgrade.ts"]},{code:"positional_shape_budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"positional_signature_mismatch",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"profile_name_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_name_not_normalized",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_summary_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_title_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"project_runtime_history_epoch_incompatible",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_item_format_incompatible",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_stale_mutation",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_stale_read",exit_code:1,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"projection_options_mutually_exclusive",exit_code:2,sources:["sdk/query/get.ts","sdk/query/list.ts","sdk/query/search-contracts.ts"],emitting_commands:["get","list","search"]},{code:"provenance_value_domain_invalid",exit_code:2,sources:["core/diagnostics/remediation.ts"]},{code:"read_output_cursor_command_mismatch",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_cursor_invalid",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_cursor_stale",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"recovery_kind_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"redundant_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"refusal_allowed_values_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_exit_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_mutated_state",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_probe_missing",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_recovery_failed",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"reindex_already_running",exit_code:4,stable:!0,sources:["sdk/governance/reindex.ts"]},{code:"removed_canonical_spelling",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"removed_compatibility_spelling",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"reopen_reason_required",exit_code:2,sources:["sdk/lifecycle/reopen.ts"],emitting_commands:["item reopen"]},{code:"reopen_receipt_missing",exit_code:1,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"reopen_target_status_invalid",exit_code:2,sources:["sdk/lifecycle/reopen.ts"],emitting_commands:["item reopen"]},{code:"reported_zero_passes",exit_code:1,sources:["sdk/test/execution-receipts.ts"]},{code:"reported_zero_tests",exit_code:1,sources:["sdk/test/execution-receipts.ts"]},{code:"reserved_item_field",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"retry_failed",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"schema_migration_input_required",exit_code:2,stable:!0,sources:["cli/migration-gates.ts"]},{code:"semantic_spelling_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"settings_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"settings_read_fs_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_invalid_schema",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_merge_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_section_document_malformed",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_document_missing",exit_code:3,sources:["core/store/settings-sections.ts"]},{code:"settings_section_invalid",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_name_invalid",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_reserved",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_revision_conflict",exit_code:4,sources:["core/store/settings-sections.ts"]},{code:"settings_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"settings_write_assigned_path_invalid",exit_code:2,sources:["core/store/settings.ts"]},{code:"settings_write_invalid_existing_json",exit_code:2,sources:["core/store/settings.ts"]},{code:"settings_write_invalid_existing_schema",exit_code:2,sources:["core/store/settings.ts"]},{code:"stale_budget",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"stale_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_observed_signature",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_revision",exit_code:4,sources:["core/store/item-store.ts"]},{code:"status_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"status_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"status_lifecycle_role_required",exit_code:2,sources:["sdk/schema.ts"]},{code:"stdin_json_invalid",exit_code:2,stable:!0,sources:["sdk/structured-mutations.ts"]},{code:"stdin_json_persisted_annotation_changed",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"stdin_json_unknown_key",exit_code:2,stable:!0,sources:["sdk/structured-mutations.ts"]},{code:"structured_event_immutable",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"structured_event_input_conflict",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_json_empty",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_json_invalid",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_since_invalid",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"suggested_retry_args_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"telemetry_endpoint_probe_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_endpoint_probe_http_status",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_otel_export_failing",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_high_retries",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_invalid_rows",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_pending",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_schema_version_behind",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_state_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"template_type_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"terminal_plan_mutation",exit_code:4,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"terminal_state_conflict",exit_code:4,stable:!0,sources:["core/telemetry/observability.ts","sdk/lifecycle/claim.ts"],emitting_commands:["*","claim"]},{code:"test_measure_requires_execution",exit_code:2,sources:["sdk/test/prerequisites.ts"]},{code:"test_measure_requires_run",exit_code:2,sources:["sdk/test/prerequisites.ts"]},{code:"text_unpaired_surrogate",exit_code:2,sources:["core/item/item-format.ts","core/shared/output-unicode.ts"]},{code:"tracked_runtime_cache_files",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_tracked_runtime_cache_files"]},{code:"tracker_not_initialized",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/tracker-preflight.ts","core/telemetry/observability.ts"],owned_states:[{state:"selected_tracker_root_exists_without_settings",probe_id:"tracker-root-settings-missing",entrypoints:["list"],expected_exit_class:"not_found"}]},{code:"tracker_root_missing",exit_code:3,stable:!0,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_does_not_exist",probe_id:"tracker-root-missing",entrypoints:["list"],expected_exit_class:"not_found"}]},{code:"tracker_root_not_directory",exit_code:2,stable:!0,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_is_a_regular_file",probe_id:"tracker-root-not-directory",entrypoints:["list"],expected_exit_class:"usage"}]},{code:"tracker_root_unreadable",exit_code:1,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_is_not_readable",probe_id:"tracker-root-unreadable",entrypoints:["list"],expected_exit_class:"generic_failure"}]},{code:"transaction_abandoned",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_committed",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_create_compensated",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_journal_invalid",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_partial_mutation",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_plan_mismatch",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_preview_external_schema",exit_code:2,sources:["sdk/item-transaction.ts"]},{code:"transaction_preview_non_regular_file",exit_code:2,sources:["core/fs/fs-utils.ts"]},{code:"transaction_preview_snapshot_changed",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_recovery_plan_missing",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"type_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"type_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"undeclared_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"unexpected_refusal_probe",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"unknown_command",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/cli-contracts/runtime-contracts.ts"]},{code:"unknown_context_intent",exit_code:2,stable:!0,sources:["sdk/context-intent-contracts.ts"]},{code:"unknown_error",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"unknown_field",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_field_projection",exit_code:2,stable:!0,sources:["sdk/query/get.ts","sdk/query/list.ts","sdk/query/search-contracts.ts"],emitting_commands:["get","list","search"]},{code:"unknown_item_type",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_lifecycle_action",exit_code:2,stable:!0,sources:["sdk/agent/subcommand-recovery.ts"],canonical_code:"unknown_subcommand"},{code:"unknown_noun",exit_code:2,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"unknown_option",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","cli/runtime/invocation-options.ts","core/telemetry/observability.ts"],owned_states:[{state:"declared_option_is_rejected_on_the_selected_command_path",probe_id:"cross-command-unknown-option",entrypoints:["deps"],expected_exit_class:"usage"}]},{code:"unknown_plan_template",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"unknown_provenance_dimension",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"unknown_status",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_subcommand",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","sdk/agent/subcommand-recovery.ts"],aliases:["unknown_lifecycle_action"],owned_states:[{state:"config_action_token_is_not_declared",probe_id:"config-unknown-action",entrypoints:["config"],expected_exit_class:"usage"},{state:"graph_command_token_is_not_declared",probe_id:"graph-unknown-subcommand",entrypoints:["graph"],expected_exit_class:"usage"},{state:"nested_command_token_is_not_declared_by_its_family",probe_id:"schema-unknown-subcommand",entrypoints:["schema"],expected_exit_class:"usage"},{state:"package_lifecycle_token_is_not_declared",probe_id:"package-unknown-action",entrypoints:["package"],expected_exit_class:"usage"}]},{code:"unsafe_init_recovery",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"unsupported_update_option",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"upsert_key_ambiguous",exit_code:4,sources:["sdk/structured-mutations.ts"]},{code:"upsert_key_conflict",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"upsert_key_duplicate",exit_code:2,sources:["sdk/item-transaction.ts","sdk/structured-mutations.ts"]},{code:"upsert_key_missing",exit_code:2,sources:["sdk/structured-mutations.ts"]},{code:"upsert_match_changed",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"validate_command_references_stale_pm_ids",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_missing_linked_paths",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_orphaned_paths",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_tracked_all_strict_forces_pm_internals",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_format_version_ahead_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_item_ahead_format_version"},{code:"validate_format_version_outdated_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_item_outdated_format_version"},{code:"validate_hierarchy_parent_cycle",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_hierarchy_parent_cycle_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_history_drift_chain_mismatches",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_chain_mismatch"},{code:"validate_history_drift_hash_mismatches",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_hash_mismatch"},{code:"validate_history_drift_missing_streams",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_missing_stream"},{code:"validate_history_drift_unreadable_streams",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_unreadable_stream"},{code:"validate_history_drift_version_skews",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_version_skew"},{code:"validate_history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_unknown_author_events"},{code:"validate_lifecycle_active_closure_like_metadata",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_active_terminal_parent",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_dependency_cycles",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_dependency_cycles_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_stale_blockers",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_driver_configuration",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_fence_drift",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_custom_profile_missing_required_fields",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_duplicate_issue_codes",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_acceptance_criteria",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_close_reason",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_closed_at",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_confidence",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_estimate",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_release",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_reviewer",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_risk",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_sprint",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_resolution_missing_fields",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_duplicate_item_ids",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_history_conflict_markers",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_history_conflict_marker"},{code:"validate_storage_resurrected_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_tracked_runtime_cache_files",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"tracked_runtime_cache_files"},{code:"validate_storage_unparseable_config",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_unparseable_history",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_unreadable_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"vectorization_embedding_identity_changed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"vectorization_stale_items_remaining",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"visible_surface_ceiling_exceeded",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"workflow_duplicate_type",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_policy_approval_history_invalid",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_audit_failed",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_input_unreadable",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_invalid",exit_code:2,sources:["core/policy/workflow-policy.ts"]},{code:"workflow_policy_refused",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_registry_invalid",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_status_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_transition_malformed",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_type_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_type_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workspace_history_chain_invalid",exit_code:4,sources:["core/history/workspace-history.ts"]},{code:"workspace_history_state_conflict",exit_code:4,stable:!0,sources:["core/history/workspace-history.ts"]},{code:"workspace_root_pm_path",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"workspace_snapshot_force_required",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_manifest_mismatch",exit_code:4,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_name_reserved_fingerprint",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_not_found",exit_code:3,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_permission_denied",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_resource_exhausted",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_storage_exhausted",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"wrong_item_type",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]}];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b525d8c8-3a70-52bd-83db-c956aba0c6fb")}catch{}})();var ze=E(T([...A,...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]="c2e89d3c-9abc-5ca7-a290-69a54dd694ab")}catch{}})();var G=Object.freeze({"--body":"Set the item body.","--body-file":"Read the item body from a file, or from stdin when set to -.","--description":"Set the item description.","--stdin":"Read the value from stdin.","--stdin-json":"Read a complete JSON document from stdin."}),B=new Set(["--add","--body","--comment","--dep","--dep-remove","--description","--doc","--event","--field","--file","--learning","--note","--remove","--reminder","--test","--type-option"]),V=new Set(["append","comments","create","docs","files","learnings","notes","test","update","update-many"]),Y=new Set(["close-many:--ids","comments:--file","create:--body-file","history-compact:--ids","learnings:--file","notes:--file","update:--body-file","update-many:--ids"]),X=new Set(["close-many:--ids","history-compact:--ids","update-many:--ids"]),W=["--allow-","--check-","--dry-run","--explain","--fail-","--fix-","--full","--has-","--include-","--json","--no-","--prune-","--quiet","--refresh-","--require-","--runtime-only","--schema-only","--skip-","--stream","--strict-","--summary","--today","--verbose"],H=new Set(["--activate","--active-only","--adopt","--adopt-all","--all","--all-actionable","--all-affected-ids","--all-day","--all-streams","--acknowledge-linked-tests","--append-stable","--auto-fix","--auto-pm-context","--availability-only","--background","--brief","--by-assignee","--by-priority","--by-tag","--catalog","--claim","--clear","--clear-comments","--clear-criteria","--clear-deps","--clear-docs","--clear-events","--clear-files","--clear-learnings","--clear-notes","--clear-reminders","--clear-tests","--clear-type-options","--cli-only","--closed","--compact","--completion","--count","--counts","--deactivate","--declarative","--defaults","--describe","--diff","--doctor","--empty-body","--explore","--field-utilization","--filter-empty-body","--flags-only","--follow","--force","--global","--highlight","--hybrid","--id-only","--if-available","--ignore-global","--include_unparented","--infer","--init","--install","--isolated","--lean","--list","--local","--manage","--markdown","--metadata-coverage","--next","--normalize-provenance","--only","--only-last","--output-row-contract","--override-linked-pm-context","--override-linked-workspace-context","--packages-only","--past","--phrase-exact","--profile","--progress","--project","--promote-to-item-dep","--provenance","--provenance-summary","--raw","--ready-only","--ready_only","--rebuild","--recent","--reload","--repair","--replace-deps","--replace-docs","--replace-files","--replace-tests","--required","--required-on-create","--run","--runtime-probe","--save-baseline","--scaffold","--semantic","--shared-host-safe","--storage","--title-exact","--token-accounting","--trace","--tree","--unbounded","--uninstall","--validate-paths","--verify","--watch","--with-packages"]),J=new Set(["--only-index"]),K=new Set(["activity:--stream","eval:--fail-under","validate:--fix-scope"]),Q=new Set(["activity:--stream","close:--validate-close","close-many:--validate-close","comments:--author","learnings:--author","notes:--author"]),Z=new Set(["--regression"]);function ee(e,t){return t==="--stdin"||t==="--stdin-json"?["stdin"]:Y.has(`${e}:${t}`)?["argv","file","stdin"]:t.endsWith("-file")?["argv","file"]:B.has(t)&&V.has(e)?["argv","stdin"]:["argv"]}function te(e,t){let s=K.has(`${e}:${t.flag}`)||t.value_name!==void 0||t.value_type==="string"||t.value_type==="number"||t.list===!0||t.repeatable===!0,o=t.value_type==="boolean"||t.flag==="--stdin"||t.flag==="--stdin-json"||t.flag.startsWith("--filter-")&&(t.flag.endsWith("-missing")||t.flag.startsWith("--filter-has-")||t.flag.startsWith("--filter-no-"))||W.some(i=>t.flag.startsWith(i));return s||J.has(t.flag)||!H.has(t.flag)&&!o}function se(e,t){return t.value_arity!==void 0?t.value_arity:te(e,t)?Z.has(t.flag)||Q.has(`${e}:${t.flag}`)?"optional":"required":"none"}function oe(e,t){let s=g(e),o=se(s,t),i=o!=="none",r=ee(s,t.flag),d=t.description??G[t.flag]??`${i?"Set":"Enable"} ${t.flag.slice(2).replaceAll("-"," ")}.`;return{...t,description:d,takes_value:i,value_required:o==="required",...i?{value_name:t.value_name??"value"}:{},value_type:i?t.value_type??"string":"boolean",required:t.required===!0,repeatable:t.repeatable===!0||t.list===!0,input_sources:r,...r.includes("stdin")&&t.flag!=="--stdin"&&t.flag!=="--stdin-json"?{stdin_token:"-"}:{},...X.has(`${s}:${t.flag}`)?{file_token_prefix:"@"}:{}}}function Be(e,t){return t.map(s=>oe(e,s))}function Ve(e,t,s){let o=e.trim().toLowerCase(),i=[],r=new Map,d=0;for(let c of s)if(c.command.trim().toLowerCase()===o){if(d+=1,r.has(c.flag)){i.push({code:"duplicate_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} was observed more than once.`});continue}r.set(c.flag,c)}let _=new Set(t.map(({flag:c})=>c));for(let c of t){let n=r.get(c.flag);if(!n){i.push({code:"missing_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} has no executable option observation.`});continue}for(let[l,I]of[["takes_value","takes_value_mismatch"],["value_required","value_required_mismatch"],["repeatable","repeatable_mismatch"]])c[l]!==n[l]&&i.push({code:I,command:o,flag:c.flag,detail:`${o} ${c.flag} declares ${l}=${String(c[l])} but the executable option reports ${String(n[l])}.`})}for(let c of r.values())_.has(c.flag)||i.push({code:"undeclared_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} is executable but absent from invocation contracts.`});return i.sort((c,n)=>c.flag.localeCompare(n.flag)||c.code.localeCompare(n.code)),{ok:i.length===0,declared_count:t.length,observed_count:d,findings: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]="76c420db-b520-5fde-bd43-16a7324feb0a")}catch{}})();var ie=["mutation_receipt","entity","collection","diagnostic","stream"],ce=new Set(["append","claim","close","close-task","copy","create","delete","focus","pause-task","release","restore","start-task","update"]),re=new Set(["close-many","update-many"]),ae=new Set(["activity","comments","contracts","events","history","learnings","list","notes","search"]),ne=new Set(["aggregate","deps","graph","health","history-redact","history-repair","history-compact","stats","validate"]);function p(e){if(e.command.trim().length===0)throw new TypeError("command must be a non-empty command path");if(!ie.includes(e.kind))throw new TypeError(`Unsupported output envelope kind: ${e.kind}`);return e}function S(e){let t=e.trim().replace(/\s+/gu," "),[s=t]=t.split(" ");return re.has(s)?p({command:t,kind:"collection",wrapper_key:"rows",cardinality:"many",format_flag:"--json"}):ce.has(s)?p({command:t,kind:"mutation_receipt",wrapper_key:null,cardinality:"one",format_flag:"--json"}):ae.has(s)?p({command:t,kind:"collection",wrapper_key:s==="contracts"?null:"items",cardinality:"many",format_flag:"--json"}):ne.has(s)?p({command:t,kind:"diagnostic",wrapper_key:null,cardinality:"none",format_flag:"--json"}):p({command:t,kind:s==="get"?"entity":"diagnostic",wrapper_key:s==="get"?"item":null,cardinality:s==="get"?"one":"none",format_flag:"--json"})}var de=u.map(e=>S(e)),_e=new Map(de.map(e=>[e.command,e]));function He(e){let t=e.trim().replace(/\s+/gu," ");if(t.length===0)throw new TypeError("command must be a non-empty command path");let[s=t]=g(t).split(" "),o=_e.get(s);return o?{...o,command:t}:S(t)}function le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ue(e){return le(e)&&typeof e.id=="string"&&e.id.length>0&&typeof e.status=="string"&&e.status.length>0&&Number.isSafeInteger(e.changed_field_count)&&Number(e.changed_field_count)>=0&&(e.close_reason===void 0||typeof e.close_reason=="string")&&(e.deleted===void 0||typeof e.deleted=="boolean")&&(e.previous_status===void 0||typeof e.previous_status=="string")&&(e.warnings===void 0||Array.isArray(e.warnings))}function Je(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){throw new TypeError(`Mutation receipt must be valid JSON: ${String(s)}`,{cause:s})}if(!ue(t))throw new TypeError("Mutation receipt must be a flat object with top-level id, status, and changed_field_count fields");return{id:t.id,status:t.status,changedFieldCount:t.changed_field_count,...typeof t.close_reason=="string"?{closeReason:t.close_reason}:{},...typeof t.deleted=="boolean"?{deleted:t.deleted}:{},...typeof t.previous_status=="string"?{previousStatus:t.previous_status}:{},...Array.isArray(t.warnings)?{warnings: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]="0c0bb7ab-6157-5861-ad7e-a63ae62220f4")}catch{}})();var me=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]),pe=new Set(["append","comments","config","contracts","deps","docs","events","files","focus","graph","health","history","learnings","list-all","list-blocked","list-closed","list-in-progress","list-open","notes","profile","schema","test"]),ge=Object.freeze({workspace:new Set(["config","gc","health","init","merge","profile","schema","telemetry","workspace"]),intake:new Set(["copy","create","focus","item","restore"]),context:new Set(["activity","aggregate","context","ctx","duplicates","eval","get","help","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","next","search","stats"]),lifecycle:new Set(["claim","close","close-many","close-task","delete","pause-task","item-reopen","release","start-task","update","update-many"]),evidence:new Set(["append","comments","docs","events","files","history","history-attest","history-author-acknowledge","history-compact","history-redact","history-repair","learnings","notes"]),graph:new Set(["deps","graph","plan"]),quality:new Set(["assurance","contracts","test","test-all","validate"]),automation:new Set(["event","meet","remind"])}),fe=new Set(["extension","install","package","packages","upgrade"]);function xe(e){let t=m(e.trim().toLowerCase());if(t==="ops")return"quality";for(let[s,o]of Object.entries(ge))if(o.has(t))return s;return fe.has(t)?"extensions":"internal"}var y=Object.freeze([...u.flatMap(e=>e==="item"?["item","item-reopen"]:[e,...b.filter(t=>t.alias===e).map(t=>t.canonical)]).map(e=>({command:e,tier:me.has(m(e))?"core":pe.has(m(e))?"standard":"full",family:xe(e)})),{command:"ops",tier:"core",family:"quality"},{command:"completion-statuses",tier:"internal",family:"internal"},{command:"completion-tags",tier:"internal",family:"internal"},{command:"completion-types",tier:"internal",family:"internal"},{command:"test-runs-worker",tier:"internal",family:"internal"},{command:"item test worker",tier:"internal",family:"internal"}]),ye=y,et=Object.freeze({max_lines:50,max_utf8_bytes:6e3}),tt=Object.freeze(["-V, --version","--all","--json","--output-include <fields>","--output-limit <count>","--output-budget <tokens|unbounded>","--output-cursor <cursor>","--pm-path <dir>","--no-extensions","--no-pager","--explain","-h, --help"]);var M={core:0,standard:1,full:2,internal:3},N=new Map(ye.map(({command:e,tier:t})=>[e,t]));function st(e,t="standard"){return N.get(e.trim().toLowerCase())??N.get(m(e.trim().toLowerCase()))??t}function ot(e){return be(e,y)}function be(e,t){let s=M[e];return t.filter(o=>o.tier!=="internal"&&M[o.tier]<=s).map(o=>o.command)}function ke(e,t){return t.filter(s=>s.family===e).map(s=>s.command)}var he=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"],ve=new Set([...k.filter(e=>e.hidden).map(e=>e.alias),"ctx","extension","install","item-reopen","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","packages","upgrade"]);function it(e=y){return he.map(t=>({family:t,commands:ke(t,e).filter(s=>e.find(o=>o.command===s)?.tier!=="internal"&&!ve.has(s))})).filter(({commands:t})=>t.length>0)}var ct=Object.freeze({pm_append:"append",pm_claim:"claim",pm_close:"close",pm_comments:"comments",pm_config:"config",pm_context:"context",pm_contracts:"contracts",pm_copy:"copy",pm_create:"create",pm_deps:"deps",pm_discover:"help",pm_docs:"docs",pm_events:"history",pm_files:"files",pm_focus:"focus",pm_get:"get",pm_graph:"graph",pm_health:"health",pm_learnings:"learnings",pm_list:"list",pm_mutate:"update",pm_next:"next",pm_notes:"notes",pm_plan:"plan",pm_profile:"profile",pm_release:"release",pm_run:"package",pm_schema:"schema",pm_search:"search",pm_test:"test",pm_update:"update",pm_validate:"validate"});var rt=Object.freeze([{uri:"pm://workspace/context",name:"Workspace context",description:"Bounded project context for orientation, including active hierarchy and progress.",mimeType:"application/json"},{uri:"pm://workspace/focus",name:"Active focus",description:"The session focus that supplies the default create parent.",mimeType:"application/json"},{uri:"pm://workspace/claims",name:"Active claims",description:"Bounded in-progress work and active ownership context.",mimeType:"application/json"},{uri:"pm://workspace/agent-guide",name:"Agent guidance",description:"Repository-local AGENTS.md instructions, bounded for safe host attachment.",mimeType:"text/markdown"}]),at=Object.freeze([{name:"orient",description:"Build bounded live context, search all statuses, and select canonical work without creating duplicates.",arguments:[{name:"request",description:"The user's requested outcome or topic.",required:!0},{name:"scope",description:"Optional bounded workspace or subsystem scope.",required:!1}],template:"Orient to the live pm workspace for: {{request}}. Scope hint: {{scope}}. Read context, search all statuses, inspect full metadata for relevant items, and select canonical lineage before any mutation."},{name:"claim-and-start",description:"Claim one canonical item and begin implementation with linked context.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0}],template:"Read {{id}} in full, claim it, set it in_progress, then implement only its acceptance scope while linking files, docs, tests, and evidence."},{name:"record-evidence-and-close",description:"Record exact verification evidence, close the item, and release ownership.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0},{name:"evidence",description:"Exact verification and outcome evidence.",required:!0}],template:"For {{id}}, record this evidence: {{evidence}}. Verify linked tests, close only if acceptance is met, then release the claim."}]);export{D as a,w as b,R as c,Ee as d,Te as e,Ae as f,Oe as g,Se as h,x as i,E as j,Ne as k,C as l,ze as m,oe as n,Be as o,Ve as p,y as q,st as r,ot as s,it as t,ie as u,p as v,de as w,He as x,ue as y,Je as z};
2
+ //# sourceMappingURL=chunk-JLN5CFYM.js.map
@@ -0,0 +1,23 @@
1
+ import{F as dt,G as lt,f as Ee}from"./chunk-EJJWOFP5.js";import{Fa as ln,Qa as at,Sa as un,Va as be,Wa as ct,Xa as mn,Za as we,ab as Se,ba as ye,bb as P,cb as Te,da as st,g as rt,h as cn,r as ot,x as ge,y as it,ya as dn}from"./chunk-FUGYXUUL.js";import{b as on}from"./chunk-Q23K6WLV.js";import{$ as E,Aa as et,Ba as nn,Ec as _e,Ga as oe,Ja as rn,Nc as an,Od as M,a as Xe,ba as ne,be as he,ca as J,da as b,fa as tn,jc as sn,qa as Ze,sc as tt,wc as Q,ya as re,yc as nt,za as X}from"./chunk-TGS5RXBY.js";import{A as m,C as W,E as K,F as T,I as v,K as pe,t as Qe,z as l}from"./chunk-QVFE5LIX.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cef883fa-81be-5092-a07b-7a5ca961fbc7")}catch{}})();var ve=new WeakSet,ut=new WeakMap,fn=new WeakSet;function pn(e){return fn.add(e),e}function mt(e){return fn.has(e)}function ie(e){ve.add(e);for(let[t,n]of Object.entries(e)){if(!Array.isArray(n))continue;let r=[...n];Reflect.set(e,t,r),ve.add(r)}return e}function eo(e,t){return ve.has(e)||t!==void 0&&ut.get(e)?.has(t)===!0}function to(e,t){let n=new Set(t);ut.set(e,n);for(let r of n){let o=Reflect.get(e,r);if(!Array.isArray(o))continue;let i=[...o];Reflect.set(e,r,i),ve.add(i)}return e}function _n(e,t){if(mt(e)&&pn(t),eo(e))return ie(t);let n=ut.get(e);return n?to(t,n):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]="e35626b8-0818-5b4b-8fc2-57426b51a2d1")}catch{}})();var L="-",no=/^[A-Za-z0-9_.-]+$/u,ft=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function gn(e,t){if(e.startsWith("```")||e.includes(`
2
+ `))return!0;let n=t.map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`^(?:[-*+]\\s+)?(?:${n})\\s*[:=]`,"i").test(e)}function yn(e){let t=e.trim();if(t==="")return[];let n=(ao(t)??t.split(",")).map(r=>r.trim()).filter(Boolean).map(r=>r.toLowerCase());return Array.from(new Set(n)).sort((r,o)=>r.localeCompare(o))}function En(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let n of e)if(typeof n=="string")for(let r of yn(n))t.push(r);return Array.from(new Set(t)).sort((n,r)=>n.localeCompare(r))}function bn(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function ro(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function oo(e,t,n){let r=e.map(s=>s.trim()).filter(Boolean);for(let s of t??[]){let a=s.trim();if(a.includes(";"))throw new m('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',l.USAGE,{code:"acceptance_criteria_semicolon_forbidden",required:"Pass one semicolon-free criterion per --add-ac value",why:"A semicolon inside one criterion would be re-read as multiple criteria",nextSteps:["Split the text into repeated --add-ac values, or replace the semicolon with punctuation that is not the storage delimiter"]});a.length>0&&!r.includes(a)&&r.push(a)}let o=[],i=r;for(let s of n??[]){let a=s.trim();if(a.length!==0){if(!i.includes(a)){o.push(a);continue}i=i.filter(c=>c!==a)}}return{criteria:i,unmatchedRemovals:o}}function io(e,t){let n=bn(e);if(!t||t.length===0)return Array.from(new Set(n)).sort((o,i)=>o.localeCompare(i));let r=new Set(n);for(let o of En(t))r.add(o);return Array.from(r).sort((o,i)=>o.localeCompare(i))}function so(e,t){let n=Array.from(new Set(bn(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return n;let r=new Set(En(t));return r.size===0?n:n.filter(o=>!r.has(o))}function ao(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):"").filter(n=>n.length>0)}function pt(e){return e.replace(/\r\n/g,`
3
+ `)}function wn(e){let t=pt(e).trim();if(!t.startsWith("```"))return e;let n=t.split(`
4
+ `);return n.length<2||n.at(-1)?.trim()!=="```"?e:n.slice(1,-1).join(`
5
+ `)}function co(e){let t=[],n="",r=!1;for(let o=0;o<e.length;o+=1){let i=e[o];if(i==="\\"&&e[o+1]===","){n+=",",o+=1;continue}if(i==="\\"&&e[o+1]!==void 0){n+=`${i}${e[o+1]}`,o+=1;continue}if(i==='"'){r=!r,n+=i;continue}if(i===","&&!r){t.push(n),n="";continue}n+=i}return n.trim()&&t.push(n),t}function Sn(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"')){try{let n=JSON.parse(t);if(typeof n=="string")return n}catch{}return t.slice(1,-1).replace(/\\"/g,'"')}return e}function lo(e){let t=e.indexOf("="),n=e.indexOf(":"),r=t>=0,o=n>=0;return r&&o?Math.min(t,n):r?t:o?n:-1}function uo(e,t){if((t==="--add"||t==="--add-glob")&&(/[./\\]/.test(e)||/\.[a-z]{1,6}$/i.test(e.trim())))return"For file/doc paths use: path=<file-path>[,scope=project|global]. The scope field is optional and defaults to project (example: path=src/api.ts or path=README.md,scope=project). ";if(t!=="--event")return"";let n=e.toLowerCase(),r=n.includes("recur_")||n.includes("recurrence")?' Recurrence list values must stay in one field and use "|" delimiters (for example recur_by_weekday=mon|wed or recur_by_month_day=1|15).':"",o=n.includes("recur_byweekday")?" Use recur_by_weekday (with underscores) for weekday recurrence filters.":"";return`${r}${o}`}function hn(e,t){let n=e.replaceAll(/\s+/g," ").trim(),r=n.length>160?`${n.slice(0,157)}...`:n,o=uo(e,t);return`Invalid ${t} value "${r}". Expected key=value entries separated by commas. `+o+`Also accepts markdown-style key/value lines (for example "- path: README.md"). Use ${t} ${L} to read piped stdin input.`}function mo(e){let t=wn(e).trim();if(t.length===0||!t.includes(`
6
+ `)&&!t.startsWith("-")&&!t.startsWith("*")&&!t.startsWith("+"))return null;let n={},r,o=pt(t).split(`
7
+ `).map(i=>i.trim()).filter(i=>i.length>0);for(let i of o){let s=i.match(/^(?:[-*+]\s+)?([a-zA-Z0-9_.-]+)\s*(=|:)\s*(.*)$/);if(s){let a=s[1].trim();n[a]=Sn(s[3].trim()),r=a;continue}if(r&&ft.has(r.toLowerCase())){n[r]=`${n[r]}
8
+ ${i}`;continue}return null}return n}function Tn(e,t){let n=wn(e).trim();if(!n)throw new m(`${t} cannot be empty`,l.USAGE);let r=mo(n);if(r)return r;let o={},i,s=co(n);for(let a of s){let c=lo(a),d=a.slice(0,Math.max(c,0)).trim();if(d!==""&&i!==void 0&&ft.has(i.toLowerCase())&&!no.test(d)){o[i]=`${o[i]},${a}`;continue}if(c>=0){let u=a.slice(0,c).trim();if(!u)throw new m(hn(e,t),l.USAGE);let f=Sn(a.slice(c+1).trim());o[u]=f,i=u;continue}if(i&&ft.has(i.toLowerCase())){o[i]=`${o[i]},${a}`;continue}throw new m(hn(e,t),l.USAGE)}return o}var fo=/^[A-Za-z]:[\\/]/,po=/^(?:[-*+]\s+)?[A-Za-z_][A-Za-z0-9_.-]*\s*=/;function _o(e){let t=e.trim();return fo.test(t)?!1:po.test(t)}function Mc(e,t,n,r){if(!(r||!e.includes(",")))throw new m(`${t} received an ambiguous comma-bearing bare ${n}. Repeat ${t} for multiple values, or quote or escape literal commas in a structured key=<value> entry.`,l.USAGE,{code:"bare_comma_entry_ambiguous",required:`Use one ${t} per bare ${n}, or quote or escape literal commas in a structured key=<value> entry.`})}function ho(e,t,n){let r=new Set(n.map(i=>i.toLowerCase())),o=Object.keys(e).filter(i=>!r.has(i.toLowerCase()));if(o.length>0)throw new m(`${t} does not recognize key${o.length>1?"s":""} ${o.map(i=>`"${i}"`).join(", ")}. Allowed keys: ${n.join(", ")}.`,l.USAGE);for(let i of Object.keys(e)){let s=i.toLowerCase();if(s!==i){if(Object.hasOwn(e,s))throw new m(`${t} provides key "${i}" more than once after case normalization.`,l.USAGE);e[s]=e[i],delete e[i]}}}async function go(e){if(process.stdin.isTTY===!0)throw new m(`${e} value "${L}" requires piped stdin input. Pipe content into the command, or end manual stdin with Ctrl+D (Unix/macOS) or Ctrl+Z then Enter (Windows).`,l.USAGE);return process.stdin.setEncoding("utf8"),await new Promise((t,n)=>{let r="";process.stdin.on("data",o=>{r+=o}),process.stdin.on("end",()=>{t(pt(r))}),process.stdin.on("error",o=>{n(o)})})}var $=Symbol("all-mutation-stdin-fields"),I=new WeakMap;function Nc(e){return mt(e)?e:ie(se({...e}))}function se(e){return I.set(e,$),e}function yo(e,t){let n=I.get(e);return n===$||I.set(e,new Set([...n??[],...t])),e}function Ae(e,t){_n(e,t);let n=I.get(e);return n===void 0||I.set(t,n===$?n:new Set(n)),t}function Pc(e,t){let n=I.get(e),r=I.get(t);return n===void 0||r===$?t:n===$?(I.set(t,n),t):(I.set(t,new Set([...r??[],...n])),t)}function Eo(e){return I.get(e)!==$}function Ie(e,t){let n=I.get(e);return n!==$&&!n?.has(t)}function bo(e){let t;for(let n of e){if(n.resolveToken===!1||n.value===void 0)continue;let r=(Array.isArray(n.value)?n.value:[n.value]).filter(o=>o.trim()===L).length;if(r>1)throw new m(`${n.optionName} accepts "${L}" stdin token at most once per command invocation`,l.USAGE);if(r!==0){if(t!==void 0&&t!==n.optionName)throw new m(`Only one option may use "${L}" stdin token per command invocation. Already used by ${t}.`,l.USAGE);t=n.optionName}}}async function $c(e,t,n){let r=e,o=[...t,...n];bo(o.map(([a,c])=>({value:r[a],optionName:c,resolveToken:Ie(e,a)})));let i=Ce(),s={...r};for(let[a,c]of t)s[a]=await i.resolveValue(r[a],c,Ie(e,a));for(let[a,c]of n)s[a]=await i.resolveList(r[a],c,Ie(e,a));return se(Ae(e,s))}function Ce(){let e,t,n=async r=>{if(t&&t!==r)throw new m(`Only one option may use "${L}" stdin token per command invocation. Already used by ${t}.`,l.USAGE);return t=r,e||(e=go(r)),await e};return{resolveValue:async(r,o,i=!0)=>{if(!i)return r;if(r!==void 0)return r.trim()!==L?r:await n(o)},resolveList:async(r,o,i=!0)=>{if(!i)return r;if(!r)return;let s=r.map((d,u)=>d.trim()===L?u:-1).filter(d=>d>=0);if(s.length===0)return r;if(s.length>1)throw new m(`${o} accepts "${L}" stdin token at most once per command invocation`,l.USAGE);let a=await n(o),c=[...r];return c[s[0]]=a,c}}}function wo(e,t){let n=Number(e);if(!Number.isFinite(n))throw new m(`Invalid ${t} value "${e}"`,l.USAGE);return n}function So(e,t){let n=e.trim(),r=Number(n);if(n===""||!Number.isInteger(r)||r<0)throw new m(`Invalid ${t} value "${e}". Expected a non-negative integer.`,l.USAGE);return r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b84fee06-5bbd-57f9-9643-f283d6c87afa")}catch{}})();function To(e,t="--limit"){if(e===void 0)return;let n=Number(e);if(!Number.isFinite(n)||n<0)throw new m(`${t} must be a non-negative number`,l.USAGE);return Math.floor(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]="9b58b44d-819c-5115-b011-f9dfa8e2ab41")}catch{}})();var vo=3e4,ae=class extends Error{status;constructor(t,n){super(t),this.name="SearchHttpError",this.status=n}};function z(e,t,n=vo){let r=e??n;if(!Number.isFinite(r)||r<=0)throw new Error(`${t} timeout must be a positive finite number`);return Math.floor(r)}function F(e,t){if(e)return e;if(typeof globalThis.fetch=="function")return globalThis.fetch.bind(globalThis);throw new Error(`${t} execution requires a fetch implementation`)}async function Io(e){try{return(await e.text()).replaceAll(/\s+/g," ").trim()}catch(t){return`(failed to read response body: ${b(t)})`}}async function xe(e){let t=new AbortController,n=setTimeout(()=>{t.abort()},e.timeoutMs);try{let r;try{r=await e.fetcher(e.endpoint,{method:e.method,headers:e.headers,body:JSON.stringify(e.body),signal:t.signal})}catch(o){throw o instanceof Error&&o.name==="AbortError"?new Error(`${e.requestLabel} timed out after ${e.timeoutMs}ms`):new Error(`${e.requestLabel} execution failed: ${b(o)}`)}if(!r.ok){let o=await Io(r),i=o.length>0?`: ${o}`:"";throw new ae(`${e.requestLabel} failed with status ${r.status} ${r.statusText}${i}`,r.status)}try{return await r.json()}catch(o){throw new Error(`${e.responseLabel} JSON parse failed: ${b(o)}`)}}finally{clearTimeout(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]="8e3bb919-c8f9-50b5-8e41-b6719d17bd21")}catch{}})();function Bc(e,t){let n=E(e);if(!n)return"unconfigured";let r=E(t);return r&&r.toLowerCase()===n.toLowerCase()?"configured":"auto-detected"}function Ao(e){let t=ne(e),n=t.toLowerCase();return n.endsWith("/embeddings")?t:n.endsWith("/v1")?`${t}/embeddings`:`${t}/v1/embeddings`}function In(e){let t=e.search?.embedding_model;return E(t)||null}function Co(e){let t=E(e.providers?.openai?.base_url),n=E(e.providers?.openai?.model);if(!t||!n)return null;let r=In(e),o=E(e.providers?.openai?.api_key);return{name:"openai",base_url:t,model:r??n,...o?{api_key:o}:{}}}function xo(e){let t=E(e.providers?.ollama?.base_url),n=E(e.providers?.ollama?.model);if(!t||!n)return null;let r=In(e);return{name:"ollama",base_url:t,model:r??n}}function An(e){let t=(Array.isArray(e)?e:[e]).map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)throw new Error("Embedding input must include at least one non-empty string");return t}function ko(e){let t=[],n=[],r=new Map;for(let o of e){let i=r.get(o);if(i===void 0){let s=t.length;t.push(o),r.set(o,s),n.push(s);continue}n.push(i)}return{uniqueInputs:t,originalToUniqueIndex:n}}function Ro(e){let t=e.map((n,r)=>({embedding:n.embedding,index:n.index,position:r}));if(t.some(n=>n.index!==void 0)){for(let n of t)if(!Number.isInteger(n.index))throw new TypeError(`OpenAI embedding response entry at position ${n.position} is missing a valid integer index`);return[...t].sort((n,r)=>{let o=n.index-r.index;return o!==0?o:n.position-r.position})}return t}function _t(e){let t=Co(e),n=xo(e),r=[t,n].filter(s=>s!==null),o=E(e.search?.provider),i=o?o.toLowerCase():null;return{active:(i?r.find(s=>s.name===i):void 0)??r[0]??null,available:r}}function vn(e){let t=ne(e.base_url);return e.name==="openai"?{provider:"openai",endpoint:Ao(t),model:e.model}:{provider:"ollama",endpoint:`${t}/api/embed`,model:e.model}}function Oo(e,t){let n=An(t);return e.name==="openai"?{target:vn(e),method:"POST",headers:{"content-type":"application/json",...e.api_key?{authorization:`Bearer ${e.api_key}`}:{}},body:{model:e.model,input:n.length===1?n[0]:n}}:{target:vn(e),method:"POST",headers:{"content-type":"application/json"},body:{model:e.model,input:n}}}function Lo(e,t){if(e.name==="openai"){let o=t.data;if(!Array.isArray(o)||o.length===0)throw new Error("OpenAI embedding response must include a non-empty data array");return Ro(o).map((i,s)=>{let a=i.embedding;if(!J(a))throw new Error(`OpenAI embedding response entry at index ${s} is missing a numeric embedding vector`);return[...a]})}let n=t.embedding;if(J(n))return[[...n]];let r=t.embeddings;if(Array.isArray(r)&&r.length>0)return r.map((o,i)=>{if(!J(o))throw new Error(`Ollama embedding response entry at index ${i} is missing a numeric embedding vector`);return[...o]});throw new Error("Ollama embedding response must include embedding or embeddings vectors")}async function Cn(e,t,n={}){let r=z(n.timeout_ms,"Embedding request"),o=F(n.fetcher,"Embedding request"),i=An(t),s=ko(i),a=Oo(e,s.uniqueInputs),c=await xe({endpoint:a.target.endpoint,method:a.method,headers:a.headers,body:a.body,timeoutMs:r,fetcher:o,requestLabel:"Embedding request",responseLabel:"Embedding response"}),d=Lo(e,c);if(d.length!==s.uniqueInputs.length)throw new Error(`Embedding response cardinality mismatch: expected ${s.uniqueInputs.length} vector(s), received ${d.length}`);return s.originalToUniqueIndex.map(u=>[...d[u]])}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5c86afdf-6d8d-5851-82c1-ae5bcc9f0196")}catch{}})();var ke=["title","description","tags","status","type","priority","assignee","parent","goal","value","why_now","risk","confidence","estimated_minutes","acceptance_criteria","resolution","expected_result","actual_result","body","comments","notes","learnings","reminders","events","dependencies","plan"];function ht(e){let t=e?.search?.corpus_fields;if(!Array.isArray(t))return[...ke];let n=new Set(ke),r=Array.from(new Set(t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o.length>0&&n.has(o))));return r.length>0?r:[...ke]}var Do=8e3,Mo=3200,U="...[semantic corpus truncated]",No="search_embedding_corpus_max_characters_invalid:using_provider_default";function x(e){return e.map(t=>t==null?"":String(t).trim()).filter(t=>t.length>0).join(" ")}function Po(e){return(e.reminders??[]).map(t=>x([t.at,t.text]))}function $o(e){return(e.events??[]).map(t=>x([t.start_at,t.end_at,t.title,t.description,t.location,t.all_day===!0?"all day":void 0,t.timezone,t.recurrence?.freq,t.recurrence?.interval,t.recurrence?.count,t.recurrence?.until,t.recurrence?.by_weekday?.join(" "),t.recurrence?.by_month_day?.join(" "),t.recurrence?.exdates?.join(" ")]))}function zo(e,t){e.push(t.title,t.body,t.status,t.owner,t.evidence,t.blocked_reason,t.superseded_by);for(let n of t.linked_items??[])e.push(`${n.kind} ${n.id}`,n.note);for(let n of t.files??[])e.push(n.path,n.note);for(let n of t.tests??[])e.push(n.command,n.path,n.note);for(let n of t.docs??[])e.push(n.path,n.note)}function Fo(e,t){for(let n of t.plan_decisions??[])e.push(n.decision,n.rationale,n.evidence);for(let n of t.plan_discoveries??[])e.push(n.text);for(let n of t.plan_validation??[])e.push(n.text,n.command,n.expected)}function Kc(e){let t=[];t.push(e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context);for(let n of e.plan_steps??[])zo(t,n);return Fo(t,e),t.filter(n=>typeof n=="string"&&n.length>0).join(" ")}function Uo(e){let t=(e.plan_steps??[]).map(i=>x([i.order,i.id,i.title,i.body,i.status,i.owner,i.evidence,i.blocked_reason,i.superseded_by,(i.linked_items??[]).map(s=>x([s.kind,s.id,s.note])).join(" "),(i.files??[]).map(s=>x([s.path,s.note])).join(" "),(i.tests??[]).map(s=>x([s.command,s.path,s.note])).join(" "),(i.docs??[]).map(s=>x([s.path,s.note])).join(" ")])),n=(e.plan_decisions??[]).map(i=>x([i.decision,i.rationale,i.evidence,i.step_id])),r=(e.plan_discoveries??[]).map(i=>x([i.text,i.step_id])),o=(e.plan_validation??[]).map(i=>x([i.text,i.command,i.expected]));if([e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context,...t,...n,...r,...o].some(i=>i!==void 0))return{mode:e.plan_mode,scope:e.plan_scope,harness:e.plan_harness,resume_context:e.plan_resume_context,steps:t,decisions:n,discoveries:r,validation:o}}function C(e){return typeof e=="string"&&e.trim().length>0}var Vo={title:e=>e.metadata.title,description:e=>e.metadata.description,tags:e=>e.metadata.tags,status:e=>e.metadata.status,type:e=>e.metadata.type,priority:e=>typeof e.metadata.priority=="number"?e.metadata.priority:void 0,assignee:e=>C(e.metadata.assignee)?e.metadata.assignee:void 0,parent:e=>C(e.metadata.parent)?e.metadata.parent:void 0,goal:e=>C(e.metadata.goal)?e.metadata.goal:void 0,value:e=>C(e.metadata.value)?e.metadata.value:void 0,why_now:e=>C(e.metadata.why_now)?e.metadata.why_now:void 0,risk:e=>C(e.metadata.risk)?e.metadata.risk:void 0,confidence:e=>e.metadata.confidence!==void 0&&e.metadata.confidence!==null?e.metadata.confidence:void 0,estimated_minutes:e=>typeof e.metadata.estimated_minutes=="number"?e.metadata.estimated_minutes:void 0,acceptance_criteria:e=>C(e.metadata.acceptance_criteria)?e.metadata.acceptance_criteria:void 0,resolution:e=>C(e.metadata.resolution)?e.metadata.resolution:void 0,expected_result:e=>C(e.metadata.expected_result)?e.metadata.expected_result:void 0,actual_result:e=>C(e.metadata.actual_result)?e.metadata.actual_result:void 0,body:e=>e.body,comments:e=>(e.metadata.comments??[]).map(t=>t.text),notes:e=>(e.metadata.notes??[]).map(t=>t.text),learnings:e=>(e.metadata.learnings??[]).map(t=>t.text),reminders:e=>Po(e.metadata),events:e=>$o(e.metadata),dependencies:e=>(e.metadata.dependencies??[]).map(t=>({id:t.id,kind:t.kind})),plan:e=>Uo(e.metadata)};function xn(e,t={}){let n=t.fields??ke,r={};for(let o of n){let i=Vo[o];if(!i)continue;let s=i(e);s!==void 0&&(r[o]=s)}return r}function jo(e){return e?.trim().toLowerCase()==="ollama"?Mo:Do}function Z(e,t){let n=jo(e),r=tn(t);return r!==null?{maxCharacters:r,warning:null}:{maxCharacters:n,warning:t==null?null:No}}function gt(e,t={}){let n=JSON.stringify(xn(e,{fields:t.fields})),r=Z(t.providerName,t.maxCharacters).maxCharacters;if(n.length<=r)return n;if(r<=U.length)return U.slice(0,r);let o=Math.max(0,r-U.length);return`${n.slice(0,o)}${U}`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="67bae1a1-19d1-50ea-816f-4b68e6bb69d9")}catch{}})();function qo(e,t,n){let r=e.search.embedding_batch_size,o=e.search.embedding_timeout_ms,i=e.search.scanner_max_batch_retries,s=Number.isFinite(r)&&r>0?Math.max(1,Math.floor(r)):1,a=Number.isFinite(o)&&o>0?Math.max(1,Math.floor(o)):3e4,c=Number.isFinite(i)&&i>=0?Math.floor(i):0;return{batchSize:s,timeoutMs:a,maxRetries:c,maxRequestBytes:n,maxInputCharacters:t}}function Ho(e,t,n,r){let o=[],i=[],s=Buffer.byteLength(JSON.stringify({model:e.model,input:[]})),a=s;for(let c of t){let d=Buffer.byteLength(JSON.stringify(c.trim()));if(s+d>r)throw new RangeError(`Embedding input exceeds request byte ceiling ${r}; lower search.embedding_corpus_max_characters or raise maxRequestBytes`);let u=i.length>0?1:0;(i.length>=n||a+u+d>r)&&(o.push(i),i=[],a=s),a+=d+(i.length>0?1:0),i.push(c)}return o.push(i),o}function Yo(e,t){if(!Number.isFinite(t)||t<=0||e.length<=t)return e;let n=Math.max(0,t-U.length);return`${e.slice(0,n)}${U}`.slice(0,t)}function kn(e){let t=b(e).toLowerCase();return t.includes("timed out")||t.includes("timeout")}function Bo(e,t,n,r,o,i){let s=`Embedding batch ${t} failed after ${o} attempt(s): ${b(i)}`,a=`provider=${e.name} model=${e.model} batch_size=${n} timeout_ms=${r}`;return kn(i)?`${s} (${a}; guidance=check provider availability or lower search.embedding_batch_size, raise search.embedding_timeout_ms, or run keyword search while semantic indexing catches up)`:`${s} (${a})`}function Go(e){return e instanceof ae?e.status===413?"payload_too_large":null:kn(e)?"timeout":null}async function yt(e,t,n,r,o,i,s){let a=null;for(let c=0;c<=o;c+=1)try{s.requests+=1;let d=await Cn(e,t,{timeout_ms:r});return c>0&&i.push(`search_embedding_batch_retry_succeeded:batch=${n}:attempt=${c+1}:size=${t.length}`),s.successful_batches+=1,s.batch_size_histogram[t.length]=(s.batch_size_histogram[t.length]??0)+1,d}catch(d){a=d;let u=Go(d);if(u!==null&&t.length>1){s.split_batches+=1;let f=Math.ceil(t.length/2),_=t.slice(0,f),p=t.slice(f);return i.push(`search_embedding_batch_split_after_${u}:batch=${n}:size=${t.length}:parts=${_.length}|${p.length}`),[...await yt(e,_,`${n}.1`,r,o,i,s),...await yt(e,p,`${n}.2`,r,o,i,s)]}if(c<o){s.retries+=1;let f=Math.min(1e3*2**c,8e3);await new Promise(_=>setTimeout(_,f))}}throw new Error(Bo(e,n,t.length,r,o+1,a))}async function Et(e,t,n,r={}){if(n.length===0)return{vectors:[],warnings:[]};let o=performance.now(),i=r.maxRequestBytes??262144;if(!Number.isSafeInteger(i)||i<=0)throw new RangeError("maxRequestBytes must be a positive safe integer");let s={provider:e.name,model:e.model,max_request_bytes:i,limit_source:r.maxRequestBytes===void 0?"default":"caller",planned_batches:0,requests:0,successful_batches:0,split_batches:0,retries:0,batch_size_histogram:{},elapsed_ms:0,inputs_per_second:0},a=[],c=Z(e.name,t.search.embedding_corpus_max_characters);c.warning&&a.push(c.warning);let d=qo(t,c.maxCharacters,i),u=0,f=n.map(h=>{if(h.trim().length===0)throw new TypeError("Embedding inputs must be non-empty strings");let y=Yo(h,d.maxInputCharacters);return y.length<h.length&&(u+=1),y});u>0&&a.push(`search_embedding_input_truncated:count=${u}:max_characters=${d.maxInputCharacters}`);let _=Ho(e,f,d.batchSize,d.maxRequestBytes);s.planned_batches=_.length;let p=[],g=0;for(let h=0;h<_.length;h+=1){let y=_[h];r.onProgress?.({batch_index:h+1,batch_total:_.length,batch_size:y.length,completed_inputs:g,total_inputs:f.length,phase:"start"}),p.push(...await yt(e,y,String(h+1),d.timeoutMs,d.maxRetries,a,s)),g+=y.length,r.onProgress?.({batch_index:h+1,batch_total:_.length,batch_size:y.length,completed_inputs:g,total_inputs:f.length,phase:"complete"})}return s.elapsed_ms=Math.max(1,performance.now()-o),s.inputs_per_second=n.length*1e3/s.elapsed_ms,{vectors:p,warnings:a,receipt: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]="88eb8555-e098-5279-801e-3b76d0dd0eae")}catch{}})();var V=`[^\\s/\\\\<>"'\\x60()\\[\\]{},;?=:#*]+`,S="[/\\\\]+",Wo="[\\p{L}\\p{N}._@-]+",j=Wo+"(?:"+S+V+")*",Re="(?:(?:home|users)"+S+j+"|root"+S+j+")",Ko="[/\\\\]"+Re,Jo="[/\\\\]{2,}"+Re,Xo="/?[a-z]:"+S+"users"+S+j,Qo=V+"(?: +"+V+")*",bt="(?:"+Qo+S+")?users"+S+j,Zo="[/\\\\]{2,}"+V+S+bt,ei="(?:[a-z]:|volume\\{[a-f0-9-]+\\}|"+V+")",On="[/\\\\]{2}[?.]"+S+"(?:unc"+S+V+S+bt+"|"+ei+S+"users"+S+j+")",ti="file:(?:"+On+"|(?:[/\\\\](?![/\\\\])|[/\\\\]{3,}|[/\\\\]{2}localhost"+S+")(?:"+Re+"|[a-z]:"+S+"users"+S+j+")|[/\\\\]{2}(?:[a-z]:"+S+"users"+S+j+"|"+V+S+"(?:"+Re+"|"+bt+")))",ni=new RegExp("(?:^|[^\\p{L}\\p{N}_./\\\\~])(?:"+Ko+"|"+Xo+"|"+ti+")|(?:^|[^\\p{L}\\p{N}_:./\\\\~])(?:"+Jo+"|"+Zo+"|"+On+")","giu"),Rn=4,ri=/%[a-f0-9]{2}|\\(?:u[a-f0-9]{4}|x[a-f0-9]{2}|\/)/iu,oi=new TextDecoder("utf-8");function ii(e){return e.replace(/(?:%[a-f0-9]{2})+/giu,t=>oi.decode(Uint8Array.from(t.matchAll(/%([a-f0-9]{2})/giu),n=>Number.parseInt(n[1],16)))).replace(/%(?![a-f0-9]{2})[a-z0-9]{0,2}/giu,"\uFFFD")}function si(e){return e.replace(/\\+(?:u([a-f0-9]{4})|x([a-f0-9]{2})|(\/))?/giu,(t,n,r,o)=>{let i=n??r;return i===void 0?o??t:String.fromCharCode(Number.parseInt(i,16))})}function ai(e){return e.normalize("NFKC").replace(/[\p{Bidi_Control}\u200b-\u200f\u2060-\u206f\ufeff]/gu,"").replace(/[\u2215\u2044]/gu,"/").replace(/[\u043e\u041e]/gu,"o").replace(/[\u0455\u0405]/gu,"s")}function ci(e,t){for(let[n,r]of[["percent_decode",ii],["json_unescape",si],["unicode_fold",ai]]){let o=r(e);o!==e&&!t.includes(n)&&t.push(n),e=o}return e}function*di(e,t,n){let r=e,o=[];for(let i=0;i<Rn;i+=1){let s=r;if(r=ci(r,o),!n){t.lastIndex=0;for(let a of r.matchAll(t))n=!0,yield{index:0,normalizations:[...o]}}if(r===s)break;i===Rn-1&&ri.test(r)&&(yield{index:0,normalizations:[...o],normalization_incomplete:!0})}}function*li(e,t){let n=0;for(let r of e.split(`
9
+ `)){t.lastIndex=0;let o=!1;for(let i of r.matchAll(t))o=!0,yield{index:n+i.index};for(let i of di(r,t,o))yield{...i,index:n};n+=r.length+1}}var Ln=[{name:"private-key",mutationRule:"private_key",regex:/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/g},{name:"github-token",mutationRule:"github_token",regex:/\b(?:gh[opsru]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/g},{name:"npm-token",mutationRule:"npm_token",regex:/\bnpm_[A-Za-z0-9]{20,}\b/g},{name:"aws-access-key",mutationRule:"aws_access_key",regex:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g},{name:"google-api-key",mutationRule:"google_api_key",regex:/\bAIza[0-9A-Za-z_-]{35}\b/g},{name:"slack-token",mutationRule:"slack_token",regex:/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g},{name:"anthropic-api-key",mutationRule:"anthropic_api_key",regex:/\bsk-ant-[A-Za-z0-9_-]{20,}\b/g},{name:"openai-api-key",mutationRule:"openai_api_key",regex:/\bsk-(?!ant-)[A-Za-z0-9_-]{20,}\b/g},{name:"gitlab-token",mutationRule:"gitlab_token",regex:/\bglpat-[A-Za-z0-9_.-]{20,}\b/g},{name:"jwt-like-token",mutationRule:"jwt_like_token",regex:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g},{name:"npm-auth-token-assignment",mutationRule:"npm_auth_token_assignment",regex:/_authToken\s*=\s*\S+/g},{name:"sentry-user-token",mutationRule:"sentry_user_token",regex:/\bsntryu_[A-Za-z0-9]{20,}\b/g},{name:"sentry-org-token",mutationRule:"sentry_org_token",regex:/\bsntrys_[A-Za-z0-9_-]{20,}\b/g},{name:"private-ip",mutationRule:"private_ip",regex:/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g},{name:"private-ssh-target",mutationRule:"private_ssh_target",regex:/\b(?:ssh|scp|rsync)\s+[A-Za-z0-9._-]+@(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g},{name:"sshpass-inline-password",mutationRule:"sshpass_inline_password",regex:/\bsshpass\s+-p\s+["'][^"']{6,}["']/g},{name:"password-assignment",mutationRule:"password_assignment",regex:/\b(?:password|passphrase)\s*[:=]\s*(?:(?!<|\$\{|\$\(|config\.auth\.password\s*(?:\|\|\s*(?:''|"")|\?\s*unescape\(encodeURIComponent\(config\.auth\.password\)\)\s*:\s*(?:''|""))(?=[ \t]*(?:\/\*(?:[^*]|\*(?!\/))*\*\/[ \t]*)*(?:;|$|\/\/[^\r\n\u2028\u2029]*(?:\r\n)?$)))[A-Za-z0-9!@#$%^&*._+\-=]{8,}|"(?!<|\$\{|\$\()[^"]{8,}"|'(?!<|\$\{|\$\()[^']{8,}')/gi},{name:"absolute-home-path",mutationRule:"absolute_home_path",regex:ni,excludeFiles:/^(?:tests\/|examples\/)/},{name:"user-at-private-host",mutationRule:"user_at_private_host",regex:/\b[A-Za-z0-9._-]+@(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g,excludeFiles:/^(?:tests\/|examples\/)/},{name:"high-entropy-assignment",mutationRule:"high_entropy_assignment",regex:/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,mutationOnlyReason:"Generic assignments in source code are not credentials; preserve the existing mutation heuristic without treating source identifiers as secrets.",minimumEntropy:3.5}];function*Dn(e,t){if(e.mutationRule==="absolute_home_path"){yield*li(t,e.regex);return}e.regex.lastIndex=0;for(let n of t.matchAll(e.regex))ui(e,n)&&(yield{index:n.index})}function ui(e,t){if(e.minimumEntropy===void 0)return!0;let n=t[1],r=new Map;for(let i of n)r.set(i,(r.get(i)??0)+1);let o=0;for(let i of r.values()){let s=i/n.length;o-=s*Math.log2(s)}return o>=e.minimumEntropy}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d6059407-bf03-5ae8-8b01-e3e7c5b28030")}catch{}})();var mi=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],St=new Map(mi.map(e=>[e.action,e]));function wt(e,t="$",n=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:n.has(e)?[]:(n.add(e),Array.isArray(e)?e.flatMap((r,o)=>wt(r,`${t}[${o}]`,n)):Object.entries(e).flatMap(([r,o])=>wt(o,`${t}.${r}`,n)))}function fi(e,t){let n=Dn(e,t),r=n.next().value;if(!r||e.mutationRule!=="absolute_home_path"||r.normalization_incomplete)return r;for(let o of n)if(o.normalization_incomplete)return{...r,normalizations:[...new Set([r.normalizations,o.normalizations].flatMap(i=>i??[]))],normalization_incomplete:!0};return r}function Mn(e){let t=[];for(let n of wt(e))for(let r of Ln){let o=fi(r,n.value);if(o){let i={rule:r.mutationRule,path:n.path};o.normalizations&&(i.normalizations=o.normalizations),o.normalization_incomplete&&(i.normalization_incomplete=!0),t.push(i)}}return t.filter((n,r,o)=>o.findIndex(i=>i.rule===n.rule&&i.path===n.path)===r)}function pi(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new m("Mutation author is required by workspace policy.",l.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let n;try{n=Mn(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(n.length===0)return{author:t,findings:n,warnings:[],override_applied:!1};let r=[...new Set(n.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new m(`Mutation blocked by secret guard (${r}). No detected value was logged.`,l.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:n,warnings:[`secret_guard_detected:${n.length}:rules=${r}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function _i(e){return St.has(e.trim().toLowerCase())}function hi(){return[...St.keys()].sort((e,t)=>e.localeCompare(t))}function sd(e){return St.get(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]="5767332d-8094-55cd-96e9-47c5d20cd7df")}catch{}})();var gi=/\b([a-z][a-z0-9]*)-(\d+)(?:-[a-z0-9]+)*\b/giu,yi=/^(?:utf|iso|sha|tls|http|covid|match)$/iu;function Tt(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function Pn(e){return[...new Set(Tt(e).match(/[\p{L}\p{N}]+/gu)??[])]}function Nn(e){let t=Tt(e);return{normalized:t,tokens:Pn(t),issueCodes:[...new Set([...e.matchAll(gi)].filter(n=>{let r=n[1],o=n.index,i=e.slice(o+n[0].length);return!yi.test(r)&&(r===r.toUpperCase()||r.length<=2||o===0&&/^\s*(?::|—|–|\])/u.test(i))}).map(n=>n[0].toLowerCase()))]}}function Ei(e,t){return bi(Nn(e),Nn(t))}function bi(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let n=new Set(e.issueCodes);return t.issueCodes.some(r=>n.has(r))?{score:.99,reason:"issue_code"}:{score:_e(e.tokens,t.tokens),reason:"title_token_jaccard"}}import wi 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]="a7cd1d62-16fe-5e5b-b382-64335fc5e403")}catch{}})();function Oe(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Si(e,t){return[e.updated_at,t].map(n=>({value:n,time:Date.parse(n??"")})).filter(n=>typeof n.value=="string"&&Number.isFinite(n.time)).sort((n,r)=>r.time-n.time)[0]?.value??e.updated_at}function $n(e,t){let n=Math.max(1,Math.trunc(t.threshold_hours)),r=(t.now??new Date).getTime(),o=Oe(t.in_progress_status),i=[];for(let s of e){if(Oe(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=Si(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((r-c)/36e5));d>=n&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:n,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function Ti(e,t,n){let r=new Map;return await Promise.all(t.filter(o=>Oe(String(o.status))===Oe(n.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await st(wi.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&r.set(o.id,s)})),$n(t,{...n,last_history_activity:o=>r.get(o.id)})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="42b217a3-31c0-561a-b7cb-b1a584b2edd5")}catch{}})();var vi=new Set(["rename-type","rename-field","remap-status",...rn]);function Ii(e,t){if(t&&!vi.has(e))throw new m(`schema ${e} does not support --dry-run. Preview is supported for rename-type, rename-field, remap-status and workflow-policy actions. Remove --dry-run only when you intend to apply changes.`,l.USAGE,{code:"invalid_argument_value",examples:["pm schema rename-type Spike --to Experiment --dry-run"]})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8d14cb04-d740-5fb7-ad97-f9a39490eb87")}catch{}})();function Sd(e){try{return e()}catch(t){throw!(t instanceof m)||t.exitCode!==l.USAGE?t:new m(`${t.message} No changes were made.`,l.USAGE,{...t.context,code:t.code==="linked_test_command_not_executable"?t.code:"invalid_argument_value",reason:"test_option_invalid",changed:!1,required:t.context.required??t.message})}}function Ai(e,t){if(e[t]==="'"){let n=e.indexOf("'",t+1);return n<0?void 0:n+1}for(let n=t+1;n<e.length;n+=1){if(e[n]==='"')return n+1;if(e[n]==="\\"){n+=1;continue}if(e[n]==="`"||e.startsWith("$(",n))return}}function Ci(e,t){let n=t;for(;n<e.length;){let r=e[n];if(/\s/u.test(r)||";&|".includes(r))return n;if(r==="\\"){n+=2;continue}if(r==="'"||r==='"'){let o=Ai(e,n);if(o===void 0)return;n=o;continue}if("<>()`".includes(r))return;n+=1}return n===e.length?n:void 0}function vt(e,t){let n=t;for(;n<e.length;){if(/\s/u.test(e[n])){n+=1;continue}if(e[n]!=="#")return n;let r=e.indexOf(`
10
+ `,n);if(r<0)return e.length;n=r+1}return n}function xi(e,t){let n=vt(e,t),r=e[n];return r===void 0||!";&|".includes(r)?n:(n+=1,r!==";"&&e[n]===r&&(n+=1),vt(e,n))}function ki(e){let t=e.trim(),n=vt(t,0);if(t.length===0)return!1;for(;n<t.length;){if(!/[A-Za-z_]/u.test(t[n]))return!1;let r=n+1;for(;r<t.length&&/[A-Za-z0-9_]/u.test(t[r]);)r+=1;if(t[r]!=="=")return!1;let o=Ci(t,r+1);if(o===void 0)return!1;n=xi(t,o)}return!0}function zn(e){if(!(e===void 0||!ki(e)))throw new m("Linked-test command contains only variable assignments or comments and has no executable command.",l.USAGE,{code:"linked_test_command_not_executable",required:'Supply an actual test command with --add "command=<actual command>" or --add-json. Environment assignments may precede that command.',examples:['pm test <id> --add "command=node --version"'],nextSteps:["Remove any already-stored assignment-only entry with --remove-index, then register the actual test command."]})}function Td(e){if(zn(e.command),!(e.pm_context_mode!=="none"||e.workspace_context_mode==="isolated"||e.workspace_context_mode==="snapshot"))throw new m("pm_context_mode=none requires workspace_context_mode=isolated or snapshot so implicit tracker discovery cannot reach the source workspace.",l.USAGE,{code:"linked_test_context_invalid",required:"Set workspace_context_mode to isolated or snapshot when pm_context_mode is none.",examples:[an(["test","<id>","--add-json",JSON.stringify({command:e.command,pm_context_mode:"none",workspace_context_mode:"isolated"})])]})}var Le=["command","cmd","path","scope","timeout","timeout_seconds","pm_context_mode","workspace_context_mode","env_set","env_clear","shared_host_safe","assert_stdout_contains","assert_stdout_regex","assert_stderr_contains","assert_stderr_regex","assert_stdout_min_lines","assert_json_field_equals","assert_json_field_gte","note"],Ri=new Set(Le);function vd(e){return gn(e,Le)}function Oi(e,t){let n={},r=[];for(let[o,i]of Object.entries(e)){let s=o.toLowerCase();if(!Ri.has(s)){r.push(o);continue}if(Object.hasOwn(n,s))throw new m(`${t} provides key "${o}" more than once after case normalization`,l.USAGE);n[s]=i}if(r.length>0)throw new m(`${t} does not recognize key${r.length>1?"s":""} ${r.map(o=>`"${o}"`).join(", ")}. Allowed keys: ${Le.join(", ")}.`,l.USAGE);if(n.cmd!==void 0){if(n.command!==void 0&&n.command.trim()!==n.cmd.trim())throw new m(`${t} command and cmd must match when both are provided`,l.USAGE);let{cmd:o,...i}=n;return{...i,command:i.command??o}}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]="b58016fa-9817-5421-a4a3-78d1b1d22937")}catch{}})();import{readFile as Li}from"node:fs/promises";import Fn 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]="7cc00705-c03e-5a18-9bec-af2585939ed8")}catch{}})();function qd(e){if(e!==void 0){if(typeof e!="string")throw new m("--rollback requires a non-empty checkpoint ID string",l.USAGE);return Un(e)}}function Un(e){let t=e.trim();if(!t)throw new m("--rollback requires a non-empty checkpoint ID",l.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new m("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",l.USAGE);return t}function Di(e,t){let n=t.replace(/[-:.TZ]/g,"").slice(0,14),r=Math.random().toString(36).slice(2,8);return`${e}-${n}-${r}`}function Mi(e,t){return Fn.join(e,"checkpoints",t)}function Vn(e,t,n){return Fn.join(Mi(e,t),`${n}.json`)}async function Ni(e,t,n,r){let o=Vn(e,t,n),i=`${JSON.stringify(r,null,2)}
11
+ `;if(!await on(o,i)&&await T(o)!==i)throw new m(`Checkpoint ${n} already exists with different contents; use a new checkpoint ID.`,l.CONFLICT);return o}function Pi(e,t){if(!Array.isArray(e.items))throw new m(`Checkpoint ${t} is missing items`,l.GENERIC_FAILURE);return e.items.map(n=>{if(!n||typeof n!="object")throw new m(`Checkpoint ${t} contains an invalid item entry`,l.GENERIC_FAILURE);let r=n;if(typeof r.id!="string"||r.id.trim().length===0)throw new m(`Checkpoint ${t} contains an item entry without ID`,l.GENERIC_FAILURE);if(typeof r.target_updated_at!="string"||r.target_updated_at.trim().length===0)throw new m(`Checkpoint ${t} contains an item entry without target_updated_at`,l.GENERIC_FAILURE);return{id:r.id.trim(),target_updated_at:r.target_updated_at.trim()}})}async function $i(e,t,n,r){let o=Un(n),i=Vn(e,t,o);if(!await W(i))throw new m(`Checkpoint ${o} not found`,l.NOT_FOUND);let s=await Li(i,"utf8"),a;try{a=JSON.parse(s)}catch(u){throw new m(`Checkpoint ${o} contains invalid JSON: ${b(u)}`,l.GENERIC_FAILURE)}if(!a||typeof a!="object")throw new m(`Checkpoint ${o} is invalid`,l.GENERIC_FAILURE);let c=a;if(c.schema_version!==r)throw new m(`Checkpoint ${o} has unsupported schema version. Inspect pm history and use an explicit pm restore only after reviewing later edits.`,l.GENERIC_FAILURE);let d=Pi(c,o);return{record:c,items:d,path:i,id:typeof c.id=="string"?c.id:o,created_at:typeof c.created_at=="string"?c.created_at:M(),author:typeof c.author=="string"?c.author:"unknown"}}async function zi(e,t){let n=[],r=[];for(let o of e)try{let i=await t(o.id,o.target_updated_at);n.push({id:o.id,status:i.skipped?"skipped":"restored",changed_fields:i.changed_fields,warnings:i.warnings}),i.skipped||r.push(o.id)}catch(i){n.push({id:o.id,status:"failed",error:b(i)})}return{rows:n,restored_ids:r,failed_count:n.filter(o=>o.status==="failed").length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cb883ffc-c431-5bf9-a973-931a8a0a940c")}catch{}})();function N(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t.length>0?t:null}function Yd(e,t){let n=N(t);return!e||!n?null:[...e.assurance_providers??[]].reverse().find(r=>N(r.definition.id)===n)??null}function Fi(e,t){let n=N(t);return!e||!n?null:[...e.search_providers].reverse().find(r=>(N(r.runtime_definition?.name)??N(r.definition?.name))===n)??null}function Ui(e,t){let n=N(t);return!e||!n?null:[...e.vector_store_adapters].reverse().find(r=>(N(r.runtime_definition?.name)??N(r.definition?.name))===n)??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]="4441095d-0acd-5780-8758-7df94396cb8e")}catch{}})();function It(e){return[...new Set(e.split(/[,\r\n]+/).map(t=>t.trim()).filter(t=>t.length>0))]}function Vi(e){let t=[];for(let r of e)if(typeof r=="string")t.push(r);else if(typeof r=="number"&&Number.isFinite(r))t.push(String(r));else return"";let n=It(t.join(`
12
+ `));return n.length>0?n.join(","):""}function ji(e){if(e===void 0)return;if(typeof e=="number")return Number.isFinite(e)?String(e):"";if(Array.isArray(e))return Vi(e);if(typeof e!="string")return"";let t=It(e);return t.length>0?t.join(","):""}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1dcf0d72-10da-51b6-b9f6-ab47bebcbf64")}catch{}})();function jn(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function At(e){if(e==="/body"||e.startsWith("/body/"))return"body";if(e==="/metadata"||e.startsWith("/metadata/")||e==="/front_matter"||e.startsWith("/front_matter/")){let n=e.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];return n?jn(n):"metadata"}let t=e.replace(/^\//,"").split("/")[0];return t?jn(t):"root"}function De(e,t){return t==="body"?e.body:t==="metadata"?e.metadata:t==="root"?e:e.metadata[t]}function qi(e,t){let n=t?.windowStartIndex??0,r=t?.field;if(e.length===0||n>=e.length)return[];let o=dn(),i=[];for(let s=0;s<e.length;s+=1){let a=e[s],c=o,d=ln(o,a.patch),u;d.ok?(u=d.document,o=u):u=c;let f=new Set;for(let p of a.patch)f.add(At(p.path)),p.from!==void 0&&f.add(At(p.from));let _=[...f].sort((p,g)=>p.localeCompare(g));if(s>=n)if(r!==void 0){if(!f.has(r))continue;let p={field:r,before:De(c,r),after:De(u,r)};i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:[r],changes:[p]})}else{let p=_.map(g=>({field:g,before:De(c,g),after:De(u,g)}));i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:_,changes:p})}}return 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]="80805c6b-9b9a-5dad-b94b-d7dbd365fe5e")}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]="2fd342e6-06cc-56d4-aa0e-2af269234b59")}catch{}})();var Hi=new Set(["none","null","undefined"]);function sl(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new m("Config set parent-reference-policy requires --policy with one of: warn, strict_error (alias: strict)",l.USAGE)}function Yi(e){if(typeof e!="string")throw new m("--parent must be a string. Use --unset parent to clear this field.",l.USAGE);let t=e.trim();if(t.length===0)throw new m("--parent must not be empty. Use --parent none to unset.",l.USAGE);if(qn(t))throw new m(`--parent must not use placeholder token "${t}". Use --unset parent to clear this field.`,l.USAGE);return t}function qn(e){return Hi.has(e.trim().toLowerCase())}function Bi(e,t){if(t==="strict_error")throw new m(`Parent item "${e}" was not found. Create it first or use --parent none.`,l.USAGE);return{warnings:[`validation_warning:parent_reference_missing:${e}`]}}function Gi(e,t,n){let r=Ee(e,n),o=Ee(t,n);if(r!==o)return;let i=t!==o||e!==r?` (normalized from parent "${t}" and item "${e}")`:"";throw new m(`Parent item "${o}" cannot be the same as item "${r}"${i}. Use --unset parent to clear this field.`,l.USAGE)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a59d5b7f-9764-53c5-a014-1119868be8ea")}catch{}})();var Ct={critical:0,high:1,medium:2,low:3,minimal:4},Hn=Object.keys(Ct),Wi=`numbers 0..4 (0=critical, 1=high, 2=medium, 3=low, 4=minimal) or names (${Hn.join(", ")}), case-insensitive`;function Me(e){return new m(`Invalid priority "${e}". Accepted values: ${Wi}.`,l.USAGE,{code:"invalid_argument_value",field:"priority",value:e,allowed:["0","1","2","3","4",...Hn]})}function Ki(e){if(typeof e=="number"){if(Number.isInteger(e)&&e>=0&&e<=4)return e;throw Me(String(e))}if(typeof e!="string")throw Me(String(e));let t=e.trim();if(t.length===0)throw Me(e);let n=t.toLowerCase();if(Object.prototype.hasOwnProperty.call(Ct,n))return Ct[n];if(/^[0-4]$/.test(t))return Number(t);throw Me(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]="e363ee89-b438-5c8e-bb06-f4d05cc814cc")}catch{}})();function Ji(e){return ie(se(Ae(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]="b6206b0e-0cd8-5827-acbd-6ac064dbcad7")}catch{}})();var Xi=/^[A-Za-z0-9][A-Za-z0-9._/-]*$/,Qi=64;function hl(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new m("Config set sprint-release-format-policy requires --policy with one of: warn, strict_error (alias: strict)",l.USAGE)}function Zi(e,t,n){let r=t.trim();if(r.length===0)throw new m(`--${e} must not be empty. Use --${e} none to unset.`,l.USAGE);if(r.length<=Qi&&Xi.test(r))return{value:r,warnings:[]};let o="Expected 1-64 characters matching [A-Za-z0-9][A-Za-z0-9._/-]* (no spaces).";if(n==="strict_error")throw new m(`Invalid --${e} value "${r}". ${o}`,l.USAGE);return{value:r,warnings:[`validation_warning:${e}_format:${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]="14e6c7b4-3161-5f82-b797-f06a879d1370")}catch{}})();var Yn={open:"open_status",closed:"close_status",canceled:"canceled_status",cancelled:"canceled_status"},Bn="all";function Sl(e){if(typeof e!="string")return!1;let t=e.split(",").map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return t.length===1&&t[0]===Bn}function es(e,t){let n=e.trim().toLowerCase();if(n.length===0)return;let r=Yn[n];return r?t[r]:ot(e,t)}function ts(e){let t=new Set(Object.keys(Yn));for(let n of e.definitions){t.add(n.id);for(let r of n.aliases)t.add(r)}return[...t]}function ns(e,t){let n=e.trim().toLowerCase(),r,o=Number.POSITIVE_INFINITY;for(let i of ts(t)){let s=Xe(n,i.toLowerCase(),2);s!==null&&s<o&&(r=i,o=s)}return r}function rs(e,t,n){if(typeof e!="string")return;let r=n?.strict===!0,o=n?.flagLabel??"--status",i=e.split(",").map(a=>a.trim()).filter(a=>a.length>0);if(i.length===0)return;if(i.filter(a=>a.trim().toLowerCase()===Bn).length>0){if(i.length===1)return;throw new m(`Invalid ${o} value "all". Use it by itself, or omit ${o} to search every status.`,l.USAGE)}let s=[];for(let a of i){let c=es(a,t);if(c===void 0){if(r){let d=ns(a,t);throw new m(`Invalid ${o} value "${a}". Use open|closed|canceled or a configured status id${d?`. Did you mean "${d}"?`:"."}`,l.USAGE)}s.push(a);continue}s.push(c)}return[...new Set(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]="50f77f3f-b2b0-5ae2-b669-6ed50bbdd530")}catch{}})();var os={bug:"Issue",bugfix:"Issue",defect:"Issue",incident:"Issue",enhancement:"Feature",story:"Feature",userstory:"Feature","user-story":"Feature","user story":"Feature",change:"Chore",ticket:"Task",todo:"Task"};function is(e){if(e!==void 0)return os[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]="c628dcf9-d98f-566e-9f93-cc81e737691c")}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]="4b79bd02-51ae-5c46-be4c-2f41dd8c9486")}catch{}})();function Gn(e,t){return oe(e,t)}function ss(e,t,n){let r={};for(let o of t.command_to_fields.get(n)??[]){let i=rt(e,o);i!==void 0&&(r[o.metadata_key]=cn(o,i))}return r}function as(e,t){for(let[n,r]of Object.entries(t)){let o=e[n];if(Array.isArray(r)){if(Array.isArray(o)){let i=o.map(s=>String(s));if(!r.map(s=>String(s)).every(s=>i.includes(s)))return!1;continue}if(!Gn(o,r[r.length-1]))return!1;continue}if(!Gn(o,r))return!1}return!0}import{spawnSync as Kn}from"node:child_process";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7889f11f-36f9-5384-8429-58d951c342da")}catch{}})();var cs="PM_DISABLE_OLLAMA_AUTO_DEFAULTS",ds="PM_OLLAMA_MODEL",ls="http://localhost:11434",us="qwen3-embedding:0.6b",ms=".agents/pm/search/lancedb/",fs=1500,ps=2500,_s=/qwen.*(?:embed|embedding)|(?:embed|embedding).*qwen/i,hs=/embed|embedding/i,k=E;function gs(){let e=k(process.env[cs]);if(!e)return!1;let t=e.toLowerCase();return t==="1"||t==="true"||t==="yes"}function Wn(e){return e.some(t=>k(t)!==null)}function ys(e){let t=k(e);return!!(t&&t.toLowerCase()!=="ollama")}function Es(e){let t=k(e);return!!(t&&t.toLowerCase()!=="lancedb")}function bs(e){return ys(e.search?.provider)||Es(e.vector_store?.adapter)||Wn([e.providers?.openai?.base_url,e.providers?.openai?.model,e.providers?.openai?.api_key])?!0:Wn([e.vector_store?.qdrant?.url,e.vector_store?.qdrant?.api_key])}function ws(){let e=Kn("ollama",["--version"],{encoding:"utf8",timeout:fs});return e.error?!1:e.status===0}function Ss(e){let t=e.split(/\r?\n/).map(r=>r.trim()).filter(r=>r.length>0);if(t.length===0)return null;let n=t.map(r=>r.split(/\s+/)[0]?.trim()).filter(r=>!!(r&&r.length>0)).filter(r=>r.toUpperCase()!=="NAME");return n.length===0?null:n.find(r=>_s.test(r))||(n.find(r=>hs.test(r))??null)}function Ts(e){let t=k(e.providers?.ollama?.model);if(t)return t;let n=k(process.env[ds]);if(n)return n;let r=Kn("ollama",["list"],{encoding:"utf8",timeout:ps});if(!r.error&&r.status===0){let o=Ss(typeof r.stdout=="string"?r.stdout:"");if(o)return o}return null}function vs(e){return{baseUrl:k(e.providers?.ollama?.base_url)===null,model:k(e.providers?.ollama?.model)===null,lancedbPath:k(e.vector_store?.lancedb?.path)===null,embeddingModel:k(e.search?.embedding_model)===null}}function Is(e){return e.baseUrl||e.model||e.lancedbPath||e.embeddingModel}function As(e,t,n){if(!t.baseUrl&&!t.model)return;let r=e.providers??={},o=r.ollama??={};t.baseUrl&&(o.base_url=ls),t.model&&(o.model=n)}function Cs(e,t){if(!t.lancedbPath)return;let n=e.vector_store??={},r=n.lancedb??={};r.path=ms}function xs(e,t,n){if(!t.embeddingModel)return;let r=e.search??={};r.embedding_model=n}function Ne(e){let t={settings:e,auto_ollama_defaults_applied:!1};if(gs()||bs(e))return t;let n=vs(e);if(!Is(n)||n.model&&!ws())return t;let r=structuredClone(e),o=Ts(r);return o?(As(r,n,o),Cs(r,n),xs(r,n,o),{settings:r,auto_ollama_defaults_applied:!0}):{...t,auto_ollama_defaults_skipped_reason:"no_installed_embedding_model",auto_ollama_defaults_remediation:`Run ollama pull ${us} or configure providers.ollama.model explicitly (and search.embedding_model if you need an override).`}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9ecff496-8afa-5cfc-9178-2be8bd403978")}catch{}})();var ks="reindex";import or from"node:path";import{mkdir as Rs,readFile as Os,stat as Rt,unlink as Ls}from"node:fs/promises";import{basename as Xn,dirname as xt,isAbsolute as Ds,join as Ms,resolve as Ot}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]="b5f2e49a-fb72-554b-b0a8-dca0adee71f4")}catch{}})();var Lt="pm_items",Ns=/[^a-zA-Z0-9_-]/g,Ps=128,$s=".pm-cli-local-vectors",kt=1,q=new Map;function de(e){return(E(e.collection_name)??Lt).replaceAll(Ns,"_").slice(0,Ps)}function Pe(e){if(!J(e)||e.length===0)throw new Error("Vector values must be a non-empty numeric array");return[...e]}function Zn(e){if(!Number.isFinite(e)||e<=0)throw new Error("Vector query limit must be a positive number");return Math.floor(e)}function zs(e){let t=e.result;if(!Array.isArray(t))throw new TypeError("Qdrant query response must include a result array");let n=t.map((r,o)=>{let i=r.id,s=typeof i=="number"?String(i):i,a=E(s);if(!a)throw new Error(`Qdrant query response entry at index ${o} is missing a non-empty id`);let c=r.score;if(typeof c!="number"||!Number.isFinite(c))throw new TypeError(`Qdrant query response entry at index ${o} is missing a finite numeric score`);let d=r.payload;if(d!==void 0&&(typeof d!="object"||d===null||Array.isArray(d)))throw new Error(`Qdrant query response entry at index ${o} must provide payload as an object when set`);return{id:a,score:c,...d?{payload:d}:{}}});return n.sort((r,o)=>r.score!==o.score?o.score-r.score:r.id.localeCompare(o.id)),n}function Dt(e){let t=E(e.result?.status);if(t)return{status:t};let n=E(e.status);if(n)return{status:n};throw new Error("Qdrant upsert response must include status metadata")}async function ce(e,t,n,r,o){return await xe({endpoint:e,method:t.method,headers:t.headers,body:t.body,timeoutMs:n,fetcher:r,requestLabel:`Vector ${o} request`,responseLabel:`Vector ${o} response`})}function Fs(e){let t=E(e.vector_store?.qdrant?.url);if(!t)return null;let n=E(e.vector_store?.collection_name),r=E(e.vector_store?.qdrant?.api_key);return{name:"qdrant",url:t,...n&&n!==Lt?{collection_name:n}:{},...r?{api_key:r}:{}}}function Us(e){let t=Ot(e),n=xt(t);return Xn(t)==="pm"&&Xn(n)===".agents"?xt(n):t}function Vs(e,t){return!t||Ds(e)?e:Ot(Us(t),e)}function js(e,t){let n=E(e.vector_store?.lancedb?.path);if(!n)return null;let r=E(e.vector_store?.collection_name);return{name:"lancedb",path:Vs(n,t),...r&&r!==Lt?{collection_name:r}:{}}}function qs(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector upsert records must include at least one entry");return e.map((t,n)=>{let r=E(t.id);if(!r)throw new Error(`Vector upsert record at index ${n} is missing a non-empty id`);let o=Pe(t.vector),i=t.payload;if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error(`Vector upsert record at index ${n} must provide payload as an object when set`);return{id:r,vector:o,...i?{payload:i}:{}}})}function Hs(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector delete ids must include at least one entry");let t=e.map((r,o)=>{let i=E(r);if(!i)throw new Error(`Vector delete id at index ${o} is missing a non-empty value`);return i}).sort((r,o)=>r.localeCompare(o)),n=[];for(let r of t)n.at(-1)!==r&&n.push(r);return n}function Ys(e){return e.replace(/\/points\?wait=true$/,"/points/delete?wait=true")}function Bs(e){return e.replace(/\/points\?wait=true$/,"")}function $e(e){return{"content-type":"application/json",...e.api_key?{"api-key":e.api_key}:{}}}function ze(e,t){return ee(e,t)}function ee(e,t){return Ms(Ot(e),$s,`${t}.json`)}function Gs(e,t,n){let r=E(e.id);if(!r)throw new Error(`LanceDB local snapshot '${n}' record at index ${t} is missing a non-empty id`);let o=Pe(e.vector),i=e.payload;if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error(`LanceDB local snapshot '${n}' record '${r}' must provide payload as an object when set`);return{id:r,vector:o,...i?{payload:i}:{}}}function Ws(e,t,n){let r;try{r=JSON.parse(n)}catch(a){throw new Error(`LanceDB local snapshot at '${e}' is not valid JSON: ${b(a)}`)}if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`LanceDB local snapshot at '${e}' must be a JSON object`);if(r.version!==kt)throw new Error(`LanceDB local snapshot at '${e}' must include version=${kt}`);let o=E(r.table);if(!o)throw new Error(`LanceDB local snapshot at '${e}' must include a non-empty table value`);if(o!==t)throw new Error(`LanceDB local snapshot at '${e}' table mismatch: expected '${t}', received '${o}'`);let i=r.records;if(!Array.isArray(i))throw new TypeError(`LanceDB local snapshot at '${e}' must include a records array`);let s=new Map;for(let a=0;a<i.length;a+=1){let c=Gs(i[a],a,e);s.set(c.id,c)}return s}async function Ks(e){try{let t=await Rt(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch(t){if(!K(t))throw t;return null}}function Js(e,t){if(!t)return null;if(t.mtimeMs===null&&t.size===null&&t.records.size===0)return t.records;let n=new Map;return q.set(e,{records:n,mtimeMs:null,size:null}),n}function Xs(e,t){return e!==void 0&&t!==null&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Mt(e,t){let n=ze(e,t),r=ee(e,t),o=await Ks(r),i=q.get(n);if(!o){let a=Js(n,i);if(a)return a}if(Xs(i,o))return i.records;let s=new Map;try{let a=await Os(r,"utf8");s=Ws(r,t,a)}catch(a){if(!K(a))throw a}return q.set(n,{records:s,mtimeMs:o?.mtimeMs??null,size:o?.size??null}),s}function Qs(e){let t=[...e.values()];return t.sort((n,r)=>n.id.localeCompare(r.id)),t.map(n=>({id:n.id,vector:[...n.vector],...n.payload?{payload:n.payload}:{}}))}async function er(e){try{await Ls(e)}catch(t){if(!K(t))throw new Error(`LanceDB local snapshot delete failed at '${e}': ${b(t)}`)}}async function tr(e,t,n){let r=ee(e,t);if(n.size===0){await er(r);return}let o=xt(r);try{await Rs(o,{recursive:!0})}catch(s){throw new Error(`LanceDB local snapshot directory create failed at '${o}': ${b(s)}`)}let i=`${JSON.stringify({version:kt,table:t,records:Qs(n)})}
13
+ `;try{await v(r,i)}catch(s){throw new Error(`LanceDB local snapshot write failed at '${r}': ${b(s)}`)}}async function Zs(e,t){let n=ze(e,t),r=ee(e,t);await er(r),q.delete(n)}function Qn(e){let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];return Math.sqrt(t)}function ea(e,t){let n=0;for(let i=0;i<e.length;i+=1)n+=e[i]*t[i];let r=Qn(e),o=Qn(t);return r===0||o===0?0:n/(r*o)}function Nt(e,t){let n=Fs(e),r=js(e,t),o=[n,r].filter(a=>a!==null),i=E(e.vector_store?.adapter),s=i?i.toLowerCase():null;return{active:(s?o.find(a=>a.name===s):void 0)??o[0]??null,available:o}}function Fe(e){let t=de(e);if(e.name==="qdrant"){let o=ne(e.url),i=encodeURIComponent(t);return{store:"qdrant",query_target:`${o}/collections/${i}/points/search`,upsert_target:`${o}/collections/${i}/points?wait=true`}}let n=encodeURIComponent(e.path),r=encodeURIComponent(t);return{store:"lancedb",query_target:`lancedb://${n}#${r}`,upsert_target:`lancedb://${n}#${r}`}}function ta(e,t,n){let r=Fe(e),o=Pe(t),i=Zn(n);return e.name==="qdrant"?{target:r,method:"POST",headers:$e(e),body:{vector:o,limit:i,with_payload:!0}}:{target:r,method:"LOCAL",headers:{},body:{table:de(e),vector:o,limit:i}}}function na(e,t){let n=Fe(e),r=qs(t);return e.name==="qdrant"?{target:n,method:"POST",headers:$e(e),body:{points:r}}:{target:n,method:"LOCAL",headers:{},body:{table:de(e),records:r}}}function ra(e,t){let n=Fe(e),r=Hs(t);return e.name==="qdrant"?{target:n,method:"POST",headers:$e(e),body:{points:r}}:{target:n,method:"LOCAL",headers:{},body:{table:de(e),ids:r}}}async function Yl(e,t,n,r={}){let o=ta(e,t,n);if(o.method==="LOCAL"){let c=e,d=o.body,u=await Mt(c.path,d.table);if(u.size===0)return[];let f=Pe(d.vector),_=Zn(d.limit),p=[],g=0;for(let h of u.values()){if(h.vector.length!==f.length){g++;continue}p.push({id:h.id,score:ea(f,h.vector),...h.payload?{payload:h.payload}:{}})}return g>0&&r.warnings&&r.warnings.push(`vector_dimension_mismatch:${g} records skipped (expected ${f.length} dimensions)`),p.sort((h,y)=>h.score!==y.score?y.score-h.score:h.id.localeCompare(y.id)),p.slice(0,_)}let i=z(r.timeout_ms,"Vector request"),s=F(r.fetcher,"Vector request"),a=await ce(o.target.query_target,{method:"POST",headers:o.headers,body:o.body},i,s,"query");return zs(a)}async function Pt(e,t,n={}){let r=na(e,t);if(r.method==="LOCAL"){let a=e,c=r.body,d=ze(a.path,c.table),u=await Mt(a.path,c.table);for(let p of c.records)u.set(p.id,p);await tr(a.path,c.table,u);let f=ee(a.path,c.table),_=await Rt(f);return q.set(d,{records:u,mtimeMs:_.mtimeMs,size:_.size}),{status:"ok"}}let o=z(n.timeout_ms,"Vector request"),i=F(n.fetcher,"Vector request"),s=await ce(r.target.upsert_target,{method:"POST",headers:r.headers,body:r.body},o,i,"upsert");return Dt(s)}async function Ue(e,t,n={}){let r=ra(e,t);if(r.method==="LOCAL"){let a=e,c=r.body,d=ze(a.path,c.table),u=await Mt(a.path,c.table);if(u.size===0)return{status:"ok"};for(let f of c.ids)u.delete(f);if(await tr(a.path,c.table,u),u.size===0)q.delete(d);else{let f=ee(a.path,c.table),_=await Rt(f);q.set(d,{records:u,mtimeMs:_.mtimeMs,size:_.size})}return{status:"ok"}}let o=z(n.timeout_ms,"Vector request"),i=F(n.fetcher,"Vector request"),s=await ce(Ys(r.target.upsert_target),{method:"POST",headers:r.headers,body:r.body},o,i,"delete");return Dt(s)}async function nr(e,t=[],n={},r){if(e.name==="lancedb")return await Zs(e.path,de(e)),{status:"ok"};if(r!==void 0){if(!Number.isInteger(r)||r<=0)throw new Error("Vector reset dimension must be a positive integer when provided");let i=Fe(e),s=Bs(i.upsert_target),a=z(n.timeout_ms,"Vector request"),c=F(n.fetcher,"Vector request"),d=$e(e);try{await ce(s,{method:"DELETE",headers:d,body:{}},a,c,"delete")}catch(f){if(!b(f).includes("failed with status 404"))throw f}let u=await ce(s,{method:"PUT",headers:d,body:{vectors:{size:r,distance:"Cosine"}}},a,c,"upsert");return Dt(u)}let o=t.map(i=>i.trim()).filter(i=>i.length>0);return o.length===0?{status:"ok"}:await Ue(e,o,n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f8acaac5-64f7-5e22-987e-4eb12a1aa1cf")}catch{}})();function Ve(e,t){let n=E(e),r=E(t);return!n||!r?null:{provider:n,model:r}}function rr(e){if(e==null)return null;if(typeof e!="object"||Array.isArray(e))throw new Error("Vectorization embedding metadata must be an object when set");let t=Ve(e.provider,e.model),n=e.vector_dimension;if(!t||typeof n!="number"||!Number.isInteger(n)||n<=0)throw new Error("Vectorization embedding metadata must include provider, model, and positive vector_dimension");return{...t,vector_dimension:n}}function $t(e,t){if(!Number.isInteger(t)||t<=0)throw new Error("Vectorization embedding metadata requires a positive vector dimension");return{provider:e.provider,model:e.model,vector_dimension:t}}function zt(e,t){return!e||e.provider!==t.provider||e.model!==t.model}function Ft(e,t){return!!(e&&e.vector_dimension!==t)}function Ut(e,t){if(e.length===0)throw new Error(`${t} returned no vectors`);let n=e[0].length;if(!Number.isInteger(n)||n<=0)throw new Error(`${t} returned an empty vector`);for(let r=1;r<e.length;r+=1)if(e[r]?.length!==n)throw new Error(`${t} returned mixed vector dimensions`);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]="7113dff5-c8e0-5ba6-b0ae-2ff849ed94df")}catch{}})();var ir="search/vectorization-status.json";function ue(e){return[...new Set([...e].map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function sr(e){return typeof e=="string"&&e.trim().length>0&&Number.isFinite(Date.parse(e))}function ar(e){let t=new Map;for(let[n,r]of Object.entries(e)){let o=n.trim();o.length===0||!sr(r)||t.set(o,r)}return Object.fromEntries([...t.entries()].sort((n,r)=>n[0].localeCompare(r[0])))}async function cr(e){let t=or.join(e,ir),n=await T(t);if(n===null||n.trim().length===0)return{entries:{},embedding:null,warnings:[]};let r;try{r=JSON.parse(n)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}if(typeof r!="object"||r===null||r.version!==1||!Array.isArray(r.items))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};let o=new Map;for(let s of r.items){if(typeof s!="object"||s===null)return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};let a=s.id,c=s.updated_at;if(typeof a!="string"||a.trim().length===0||!sr(c))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};o.set(a.trim(),c)}let i=null;try{i=rr(r.embedding)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}return{entries:Object.fromEntries([...o.entries()].sort((s,a)=>s[0].localeCompare(a[0]))),embedding:i,warnings:[]}}async function dr(e,t,n){let r=ar(t),o=or.join(e,ir),i=`${JSON.stringify({version:1,generated_at:M(),...n?{embedding:n}:{},items:Object.entries(r).map(([s,a])=>({id:s,updated_at:a}))},null,2)}
14
+ `;await v(o,i)}function oa(e){return{id:e.id,type:e.type,status:e.status,priority:e.priority,updated_at:e.updated_at}}function ia(e){let t=Ve(e.name,e.model);if(!t)throw new Error("Embedding provider must include a provider name and model");return t}function le(e,t){return{refreshed:[],skipped:e,warnings:[t]}}async function sa(e,t,n){if(!n.settings&&!await W(X(e)))return le(t,"search_semantic_refresh_skipped:settings_not_initialized");let r;try{if(n.settings)r=n.settings;else{let a=await Se(e),c=a.warnings.find(d=>d.startsWith("settings_read_"));if(c)return le(t,`search_semantic_refresh_skipped:settings_read_failed:${c}`);r=a.settings}}catch(a){return le(t,`search_semantic_refresh_skipped:settings_read_failed:${b(a)}`)}let o=n.apply_runtime_defaults?Ne(r).settings:r,i=_t(o).active;if(!i)return le(t,"search_semantic_refresh_skipped:provider_unconfigured");let s=Nt(o,e).active;return s?{settings:o,provider:i,vectorStore:s}:le(t,"search_semantic_refresh_skipped:vector_store_unconfigured")}async function aa(e,t,n,r,o,i){let s=[],a=new Set,c=new Set,d=[];for(let u of r){let f=await dt(e,u,t,n,o);if(!f){c.add(u);continue}try{let _=await lt(f,{schema:i});d.push({id:_.document.metadata.id,document:_.document})}catch(_){a.add(f.id),s.push(`search_semantic_refresh_item_read_failed:${f.id}:${b(_)}`)}}return d.sort((u,f)=>u.id.localeCompare(f.id)),{documents:d,missingIds:ue(c),skippedIds:ue(a),warnings:s}}async function ca(e,t,n){let r=Z(t.name,e.search.embedding_corpus_max_characters).maxCharacters,o=ht(e),i=n.map(a=>gt(a.document,{providerName:t.name,maxCharacters:r,fields:o})),s=await Et(t,e,i);return{vectors:s.vectors,vector_dimension:Ut(s.vectors,"Semantic refresh embedding"),warnings:s.warnings}}async function da(e,t,n){return await Pt(e,t.map((r,o)=>({id:r.id,vector:n[o],payload:oa(r.document.metadata)}))),{refreshed:t.map(r=>r.id),skipped:[],warnings:[]}}async function la(e,t){if(t.length===0)return{refreshed:[],skipped:[],warnings:[]};try{return await Ue(e,t),{refreshed:[],skipped:[],warnings:[]}}catch(n){return{refreshed:[],skipped:t,warnings:[`search_semantic_refresh_delete_failed:${b(n)}`]}}}async function mu(e,t,n={}){let r=ue(t);if(r.length===0)return{refreshed:[],skipped:[],warnings:[]};let o=await sa(e,r,n);if(!("settings"in o))return o;let i=Ze(o.settings,tt()),s=await aa(e,o.settings.id_prefix,o.settings.item_format,r,i.type_to_folder,o.settings.schema),a=s.documents.length>0||s.missingIds.length>0?await cr(e):{entries:{},embedding:null,warnings:[]},c=ia(o.provider),d=a.entries,u={refreshed:[],skipped:[],warnings:[]},f=a.embedding;if(s.documents.length>0)if(a.embedding&&zt(a.embedding,c))u={refreshed:[],skipped:s.documents.map(y=>y.id),warnings:["search_semantic_refresh_requires_reindex:embedding_identity_changed"]};else try{let y=await ca(o.settings,o.provider,s.documents);if(Ft(a.embedding,y.vector_dimension))u={refreshed:[],skipped:s.documents.map(w=>w.id),warnings:[...y.warnings,"search_semantic_refresh_requires_reindex:vector_dimension_changed"]};else{f=$t(c,y.vector_dimension);let w=await da(o.vectorStore,s.documents,y.vectors);u={refreshed:w.refreshed,skipped:w.skipped,warnings:[...y.warnings,...w.warnings]}}}catch(y){u={refreshed:[],skipped:s.documents.map(w=>w.id),warnings:[`search_semantic_refresh_failed:${b(y)}`]}}let _=await la(o.vectorStore,s.missingIds),p=new Set(u.refreshed),g=Object.fromEntries(s.documents.filter(y=>p.has(y.id)).map(y=>[y.id,y.document.metadata.updated_at])),h=[];if(Object.keys(g).length>0||s.missingIds.length>0){let y={...d,...ar(g)};for(let w of s.missingIds)delete y[w];try{await dr(e,y,f)}catch(w){h.push(`search_vectorization_status_ledger_write_failed:${b(w)}`)}h.push(...a.warnings)}return{refreshed:ue([...u.refreshed,..._.refreshed]),skipped:ue([...s.skippedIds,...u.skipped,..._.skipped]),warnings:[...s.warnings,...u.warnings,..._.warnings,...h]}}import{createRequire as _a}from"node:module";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ac3b0f55-7faf-5fa6-b01d-304e87acb9a2")}catch{}})();var ua=new Set(["1","true","yes","on"]),Vt=["user","automation","test","dogfood"],ma=new Set(Vt);function lr(e=process.env){return typeof e.VITEST=="string"||typeof e.VITEST_WORKER_ID=="string"||typeof e.NODE_TEST_CONTEXT=="string"||(e.NODE_ENV??"").trim().toLowerCase()==="test"}function je(e,t){return ua.has((t[e]??"").trim().toLowerCase())}function me(e=process.env){let t=je("DO_NOT_TRACK",e),n=(e.PM_TELEMETRY_SOURCE_CONTEXT??"").trim().toLowerCase(),r=lr(e)&&!ma.has(n)&&!je("PM_TELEMETRY_SEND_TEST_EVENTS",e);return{telemetry_disabled:t||r||je("PM_TELEMETRY_DISABLED",e)||je("PM_NO_TELEMETRY",e),do_not_track:t,test_suppressed: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]="64589e00-25ef-5d74-a94a-7d40455e1929")}catch{}})();var mr=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i,_u=new RegExp(`(?:\\b|(?<=_))(${mr.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu");var ur="(?:\\s|\\\\+u(?:0009|000a|000d|0020))*",hu=new RegExp("^"+ur+"(?::|=|\\\\+u(?:003a|003d))"+ur,"iu");(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="16379104-dc20-5034-95ab-ebeb63f54952")}catch{}})();var vu=_a(import.meta.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]="9e8ad404-2f8d-5d9b-9046-60178a70e5b2")}catch{}})();var qe=class extends m{constructor(t,n,r){super(t,l.GENERIC_FAILURE,n),this.name="ExtensionCommandError",Object.defineProperty(this,"cause",{value:r,configurable:!0,writable:!0})}};function xu(e,t){let n=t.warnings[0]??"extension_command_handler_failed",r=t.errorMessage?.trim();return new qe(`Command "${e}" failed in extension handler (${n}).${r?` ${r}`:""}`,{code:t.errorCode??"command_failed",nextSteps:t.remediation?[t.remediation]:void 0},t.cause)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bd65294f-dfa5-53d2-9691-c630884f2a5f")}catch{}})();var Ou=new Map([[l.USAGE,"invalid_command_usage"],[l.NOT_FOUND,"item_not_found"],[l.CONFLICT,"lock_conflict"],[l.DEPENDENCY_FAILED,"dependency_failed"]]);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fc213d81-bf8a-50a2-b1a8-1b2a69721855")}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]="ab644545-f072-53c0-9ebf-72a62c237a2f")}catch{}})();var Vu=Object.freeze({"&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&amp;":"&"});(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e7deff0d-d9c9-5250-b172-ab752ddd64a4")}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]="bc9e1b59-21cb-5dda-91c0-36e123734cd3")}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]="4b566486-120f-5aed-8d92-9e62ed996210")}catch{}})();function ga(e,t){if(e==null)return[];let n=t?.separators??/,/,r=e.split(n).map(i=>i.trim()).filter(i=>i.length>0),o=t?.unique!==!1?Array.from(new Set(r)):r;return t?.sort===!0?[...o].sort():o}import jt from"node:fs/promises";import He 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]="12ee7de1-dff4-53f1-8d0d-d8b1c1ebea42")}catch{}})();function ya(e){return"json_markdown"}function _r(e,t){return He.relative(e,t).replaceAll("\\","/")}function Ea(e){return String(e).replaceAll(/[^a-zA-Z0-9._-]+/g,"_").slice(0,120)}async function ba(e,t,n){e!==t&&ge(await jt.readFile(t,"utf8"),{format:"json_markdown",requireSupportedFormat:!0,schema:n})}async function wa(e,t,n="item_format:migrate",r=Qe,o){if(t!=="toon")throw new Error("Only toon item-format migration targets are supported. Markdown item files are legacy read-only input.");let i=new Set,s=new Set,a=[],c=0,d=ya(t),u=Object.entries(r);for(let[f,_]of u){let p=He.join(e,_),g=[];try{g=await jt.readdir(p)}catch{continue}let h=new Map;for(let w of g){let D=He.join(p,w),O=nn(D);if(!O)continue;let B=He.extname(w),te=w.slice(0,w.length-B.length).trim();if(te.length===0)continue;let G=h.get(te)??{};G[O]=D,h.set(te,G)}let y=[...h.keys()].sort((w,D)=>w.localeCompare(D));for(let w of y){let D=h.get(w);c+=1;let O=D[d];if(!O)continue;let B=D[t]??O,te=B===D[t]?t:d;try{let G=await jt.readFile(B,"utf8"),Qr=ge(G,{format:te,requireSupportedFormat:!0,schema:o,onWarning:Zr=>a.push(`item_format_migration_parse_warning:${w}:${Zr}`)});await ba(B,O,o);let Je=et(e,f,w,t,r),en=it(Qr,{format:t,schema:o});await T(Je)!==en&&(await v(Je,en),a.push(...await Q({path:Je,scope:"project",op:n})),i.add(w)),await pe(O),s.add(_r(e,O)),a.push(...await Q({path:O,scope:"project",op:`${n}:remove`})),i.add(w)}catch(G){a.push(`item_format_migration_skipped:${_r(e,B)}:${Ea(G)}`)}}}return{target_format:t,scanned:c,migrated:[...i].sort((f,_)=>f.localeCompare(_)),removed:[...s].sort((f,_)=>f.localeCompare(_)),warnings: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]="12c59406-7e00-5fe1-bd93-c1f9d8537f01")}catch{}})();var Sa=new Set(["completed","superseded"]);function Ta(e){return e!==void 0&&Sa.has(e)}function va(e){if(e.type.trim().toLowerCase()!=="plan")return!1;let t=e.plan_steps??[];return t.length>0&&t.every(n=>n.status==="completed")}import{createHash as Ia}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]="7cbbb50d-e9bc-5940-9ae6-6270e9c2fcbf")}catch{}})();var Aa=/^[a-z][a-z0-9_-]{0,63}$/u,Ca=new Set(["constructor","prototype"]),hr="settings:section:write",xa=240;function Ye(e){return`sha256:${Ia("sha256").update(qt(e)).digest("hex")}`}function qt(e){return Array.isArray(e)?`[${e.map(t=>qt(t)).join(",")}]`:typeof e=="object"&&e!==null?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${qt(Object.getOwnPropertyDescriptor(e,t)?.value)}`).join(",")}}`:String(JSON.stringify(e))}function yr(e){if(!Aa.test(e)||Ca.has(e))throw new m(`Invalid settings section name "${e.slice(0,80)}". Use 1-64 lowercase letters, digits, underscores or hyphens, starting with a letter.`,l.USAGE,{code:"settings_section_name_invalid",field:"section",required:"Name the section after the package, for example lint or jev."});if(un.includes(e))throw new m(`Settings section "${e}" is owned by core settings; extension sections must use another name.`,l.USAGE,{code:"settings_section_reserved",field:"section",value:e,required:"Read core settings with readSettings and change them with writeSettings or pm config."})}function Er(e){let t;try{t=JSON.parse(e)}catch{t=void 0}if(typeof t!="object"||t===null||Array.isArray(t))throw new m("settings.json is not a JSON object, so no settings section can be read or written.",l.USAGE,{code:"settings_section_document_malformed",reason:t===void 0?"settings_json_malformed":"settings_json_not_object",nextSteps:["Repair .agents/pm/settings.json so it is a JSON object, then retry.","Run pm health to confirm the settings warning has cleared."]});return t}function Ht(e,t,n){let r;try{r=n===void 0?t:n(t)}catch(o){throw new m(`Settings section "${e}" is invalid: ${b(o).slice(0,xa)}`,l.USAGE,{code:"settings_section_invalid",field:e,required:`Fix the "${e}" section of .agents/pm/settings.json so the owning package accepts it, then retry.`})}return r}function br(e){return typeof Reflect.get(e,"toJSON")=="function"}function Yt(e){return e.length===0?"the value":e.join(".")}function wr(e,t){return Object.values(Object.getOwnPropertyDescriptors(e)).every(n=>"value"in n&&(!t||n.enumerable===!0))}function ka(e){if(Object.getPrototypeOf(e)!==Array.prototype||!wr(e,!1))return!1;let t=Object.keys(e);return t.length===e.length&&t.every((n,r)=>n===String(r))&&Object.getOwnPropertyNames(e).length===e.length+1&&Object.getOwnPropertySymbols(e).length===0&&!br(e)}function Ra(e){let t=Object.getPrototypeOf(e);return(t===Object.prototype||t===null)&&wr(e,!0)&&Object.getOwnPropertySymbols(e).length===0&&!br(e)}function Oa(e,t){if(e===null||typeof e=="string"||typeof e=="boolean")return null;let n=Yt(t);return typeof e=="number"?Number.isFinite(e)?null:{detail:`${n} is a non-finite number`,representable:!0}:{detail:`${n} is ${typeof e}`,representable:typeof e!="bigint"&&t.length>0}}function Sr(e,t=[],n=new Set){if(typeof e!="object"||e===null)return Oa(e,t);let r=Yt(t);if(n.has(e))return{detail:`${r} is a circular reference`,representable:!1};if(!(Array.isArray(e)?ka(e):Ra(e)))return{detail:`${r} is not a plain JSON ${Array.isArray(e)?"array":"object"}`,representable:!0};n.add(e);for(let[o,i]of Object.entries(e)){let s=Sr(i,[...t,o],n);if(s!==null)return s}return n.delete(e),null}function Tr(e,t=[]){if(typeof e!="object"||e===null)return null;for(let[n,r]of Object.entries(e)){let o=[...t,n];if(n==="__proto__"||n==="prototype"&&t.at(-1)==="constructor")return Yt(o);let i=Tr(r,o);if(i!==null)return i}return null}function gr(e,t,n){return Ht(e,t,()=>{throw new Error(n)})}function La(e,t){let n=Sr(t);if(n!==null){let o=n.representable?`the value would change when stored as JSON: ${n.detail}`:`the value is not representable as JSON: ${n.detail}`;return gr(e,t,o)}let r=Tr(t);return r!==null?gr(e,t,`${r} is a reserved key that settings history cannot record`):JSON.parse(JSON.stringify(t))}function vr(e,t){return Object.hasOwn(e,t)?e[t]:void 0}async function Da(e,t,n={}){yr(t);let r=X(e);await nt({path:r,scope:"project"});let o=await T(r),i=o===null?void 0:vr(Er(o),t);if(i===void 0)return{section:t,source:"default",value:n.defaultValue,revision:null};let s=Ye(i);return{section:t,source:"stored",value:Ht(t,structuredClone(i),n.validate),revision:s}}async function Ma(e,t,n,r={}){yr(t);let o=n===void 0?void 0:La(t,Ht(t,n,r.validate)),i=X(e),s=await P(e);try{let a=await at({pmRoot:e,filePath:i,op:hr,author:ye(r.author,s.author_default),lockTtlSeconds:s.locks.ttl_seconds,lockWaitMs:s.locks.wait_ms,recordCreation:!1,mutate:c=>{if(c===null)throw new m("settings.json does not exist, so no settings section can be written.",l.NOT_FOUND,{code:"settings_section_document_missing",required:"Initialize the tracker with pm init, then retry."});let d=Er(c),u=vr(d,t),f=u===void 0?null:Ye(u);if(r.expectedRevision!==void 0&&r.expectedRevision!==f)throw new m(`Settings section "${t}" changed since it was read; read it again and reapply the change.`,l.CONFLICT,{code:"settings_section_revision_conflict",field:t,expected_revision:r.expectedRevision,current_revision:f,required:"Read the section again with readSettingsSection, then retry with its current revision."});let _={section:t,changed:!1,previous_revision:f,revision:o===void 0?null:Ye(o)};return oe(u,o)?{raw:c,result:_}:(o===void 0?delete d[t]:d[t]=o,{raw:`${JSON.stringify(d,null,2)}
15
+ `,result:{..._,changed:!0}})}});return a.changed&&await Q({path:i,scope:"project",op:hr}),a.result}finally{be(e)}}import hm from"node:readline/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="88db9929-8e1d-56ad-9a5f-6cc0febadfb3")}catch{}})();import Kt from"node:crypto";import{mkdirSync as Dm,rmSync as $a,statSync as Mm}from"node:fs";import{mkdir as Bt,readdir as za,rm as Jt,stat as Or}from"node:fs/promises";import{request as Fa}from"node:http";import{request as Ua}from"node:https";import A 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]="4f455b67-536a-59be-8f25-1dc9c9c0b917")}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]="cbcb519e-1348-5974-bd16-ea5905c468a4")}catch{}})();var Va=A.join("runtime","telemetry","events.jsonl"),ja=A.join("runtime","telemetry","state.json"),qa=A.join("runtime","telemetry","otel-spans.jsonl"),Ha=8,Ir=500,Ya=1;var Ba=100,Ga=36e5,Wa=3e4,Ar=2e4,Ka=1e3,Ja=25e3;var Xa=864e5,Lr=65536;var Dr=15;var Mr=[25,50,100,200],Qa=3600*1e3,Za=6e4;var H="PM_TELEMETRY_FLUSH_CHILD",ec="PM_TELEMETRY_HTTP_TIMEOUT_MS",tc=globalThis.fetch;var Zm=Promise.resolve(),Cr=Promise.resolve();var nc=new Set(["1","true","yes","on"]);var ef=Kt.randomUUID();var Nr="(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer|literals?|regex(?:es)?|replacements?)",rc=new RegExp(`\\b(${Nr})\\s*([:=])\\s*([^\\s,;]+)`,"giu"),oc=new RegExp(`(--${Nr})(=|\\s+)([^\\s,;]+)`,"giu"),ic=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g,sc=/bearer\s+[a-z0-9._=-]+/giu,ac=/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g;function Be(e){return A.join(e,Va)}function Ge(e){return A.join(e,qa)}function cc(e){return A.dirname(Be(e))}function Pr(e){return A.join(e,ja)}function $r(e){return A.join(e,"runtime","telemetry","flush.lock")}function dc(e){return A.join(e,"runtime","telemetry","flush.spawn.lock")}async function lc(e){let t=await T(Pr(e));if(!t||t.trim().length===0)return{};try{let n=JSON.parse(t);return typeof n!="object"||n===null||Array.isArray(n)?{}:n}catch{return{}}}async function R(e,t){try{await fe(async()=>{let n={...await lc(e),...t},r=Object.fromEntries(Object.entries(n).filter(([,o])=>o!==void 0).sort((o,i)=>o[0].localeCompare(i[0])));await v(Pr(e),`${JSON.stringify(r,null,2)}
16
+ `,{createParentDirectories:!Y(process.env[H])})},e)}catch{}}function zr(e){return e.replaceAll(rc,(t,n,r)=>`${n}${r}[redacted]`).replaceAll(oc,(t,n,r)=>`${n}${r}[redacted]`)}function Fr(e){return e.replaceAll(ic,(t,n)=>`${n}[redacted_path]`)}function Ur(e){let t=e>=65&&e<=90,n=e>=97&&e<=122,r=e>=48&&e<=57;return t||n||r}function Vr(e){if(!e)return!1;let t=e.charCodeAt(0);return Ur(t)?!0:e==="."||e==="_"||e==="%"||e==="+"||e==="-"}function jr(e){if(!e)return!1;let t=e.charCodeAt(0);return Ur(t)?!0:e==="."||e==="-"}function uc(e){let t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@")||t===e.length-1)return!1;let n=e.slice(0,t),r=e.slice(t+1),o=r.lastIndexOf(".");if(o<=0||o===r.length-1||r.length-(o+1)<2)return!1;for(let i of n)if(!Vr(i))return!1;for(let i of r)if(!jr(i))return!1;return!0}function mc(e){let t="",n=0;for(;n<e.length;){let r=e.indexOf("@",n);if(r<0){t+=e.slice(n);break}let o=r-1;for(;o>=n&&Vr(e[o]);)o-=1;o+=1;let i=r+1;for(;i<e.length&&jr(e[i]);)i+=1;let s=e.slice(o,i);if(uc(s)){t+=e.slice(n,o),t+="[redacted_email]",n=i;continue}t+=e.slice(n,r+1),n=r+1}return t}function qr(e){return mc(e).replaceAll(sc,"bearer [redacted_token]").replaceAll(ac,"[redacted_ip]")}function fc(e){let t=qr(e),n=zr(t),r=Fr(n),o=r.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":r.length>512?`${r.slice(0,509)}...`:r}function pc(e){let t=qr(e),n=zr(t),r=Fr(n),o=r.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":r.length>2048?`${r.slice(0,2045)}...`:r}function Wt(e,t="redacted"){return t==="max"?pc(e):fc(e)}function _c(e){let t=e?.trim().toLowerCase();return t==="minimal"||t==="redacted"||t==="max"?t:"redacted"}function Y(e){return nc.has((e??"").trim().toLowerCase())}function xr(){let e=process.env[ec]?.trim();if(!e)return Ar;let t=Number(e);return Number.isFinite(t)?Math.min(Ja,Math.max(Ka,Math.trunc(t))):Ar}async function Hr(e,t,n){let r=new URL(e);if(globalThis.fetch!==tc){let i=new AbortController,s,a=new Promise((c,d)=>{s=setTimeout(()=>{i.abort(),d(new Error("telemetry_http_timeout"))},xr())});try{return(await Promise.race([globalThis.fetch(e,{method:"POST",headers:t,body:n,signal:i.signal}),a])).status}finally{clearTimeout(s)}}let o=r.protocol==="https:"?Ua:r.protocol==="http:"?Fa:void 0;if(!o)throw new Error(`telemetry_http_protocol_unsupported_${r.protocol}`);return new Promise((i,s)=>{let a=xr(),c={method:"POST",headers:{...t,"content-length":Buffer.byteLength(n)},signal:AbortSignal.timeout(a),autoSelectFamilyAttemptTimeout:Math.min(5e3,a)},d=o(r,c,u=>{u.once("error",s),u.once("end",()=>i(u.statusCode)),u.resume()});d.once("error",s),d.end(n)})}async function hc(e){let t=await P(e);if(!t.telemetry.enabled||me().telemetry_disabled)return null;if(t.telemetry.installation_id.trim().length===0){if(mn(e)||we(t))return null;t.telemetry.installation_id=Kt.randomUUID(),await Te(e,t,"telemetry:install_id")}return{installationId:t.telemetry.installation_id,endpoint:t.telemetry.endpoint,retentionDays:Math.max(1,Math.trunc(t.telemetry.retention_days)),captureLevel:_c(t.telemetry.capture_level)}}function Yr(e){let t=[];for(let n of e.split(`
17
+ `)){let r=n.trim();if(r.length!==0)try{let o=JSON.parse(r);o&&typeof o=="object"&&o.event&&typeof o.event=="object"&&typeof o.attempts=="number"&&(o.client_schema_version===void 0||typeof o.client_schema_version=="number"&&Number.isFinite(o.client_schema_version))&&t.push(o)}catch{}}return t}function Br(e){let t=Math.min(Wa*2**Math.max(e-1,0),Ga);return new Date(Date.now()+t).toISOString()}function Xt(e){if(typeof e!="string"||e.trim().length===0)return!0;let t=Date.parse(e);return Number.isNaN(t)?!0:t<=Date.now()}function Gr(e){return Xt(e.next_attempt_after)}function Wr(e){let t=Number.isFinite(e)?Math.max(1,Math.trunc(e)):1;return Date.now()-t*Xa}function gc(e,t){let n=e.event?.occurred_at;if(typeof n!="string"||n.trim().length===0)return!1;let r=Date.parse(n);return Number.isNaN(r)?!1:r<t}function We(e,t){let n=Wr(t),r=[],o=0;for(let i of e){if(JSON.stringify(i).length>Lr||gc(i,n)||i.attempts>=Dr){o+=1;continue}r.push(i)}return{entries:r,prunedCount:o}}async function Kr(e,t){let n=t.map(o=>JSON.stringify(o)).join(`
18
+ `),r=n.length>0?`${n}
19
+ `:"";for(let o=0;;o+=1)try{await v(Be(e),r,{createParentDirectories:!Y(process.env[H])});return}catch(i){let s=Mr[o];if(s===void 0||!Jr(i))throw i;await Xr(s)}}function Jr(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return t==="EACCES"||t==="EBUSY"||t==="EPERM"}function Xr(e){return new Promise(t=>{setTimeout(t,e)})}function yc(e){let t=JSON.stringify([e.endpoint,e.enqueued_at,e.payload]);return Kt.createHash("sha256").update(t).digest("hex").slice(0,32)}function Qt(e){let t=[];for(let n of e.split(`
20
+ `)){let r=n.trim();if(r.length!==0)try{let o=JSON.parse(r);o&&typeof o=="object"&&typeof o.endpoint=="string"&&o.endpoint.trim().length>0&&"payload"in o&&typeof o.attempts=="number"&&Number.isFinite(o.attempts)&&((typeof o.id!="string"||o.id.length===0)&&(o.id=yc(o)),t.push(o))}catch{}}return t}function Ec(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let n=Date.parse(e.enqueued_at);return Number.isNaN(n)?!1:n<t}function Zt(e,t){let n=Wr(t),r=[],o=0;for(let i of e){if(JSON.stringify(i).length>Lr||Ec(i,n)||i.attempts>=Dr){o+=1;continue}r.push(i)}if(r.length>Ir){let i=r.length-Ir;return o+=i,{entries:r.slice(i),prunedCount:o}}return{entries:r,prunedCount:o}}async function bc(e,t){let n=t.map(o=>JSON.stringify(o)).join(`
21
+ `),r=n.length>0?`${n}
22
+ `:"";for(let o=0;;o+=1)try{await v(Ge(e),r,{createParentDirectories:!Y(process.env[H])});return}catch(i){let s=Mr[o];if(s===void 0||!Jr(i))throw i;await Xr(s)}}async function kr(e,t,n,r){return fe(async()=>{let o=await T(Ge(e)),i=o===null?[]:Qt(o),s=[];for(let c of i){if(n.has(c.id))continue;let d=r.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=Zt(s,t);return await bc(e,a),a.length},e)}async function wc(e,t){let n=await T(Ge(e));if(n===null||n.trim().length===0){await R(e,{pending_otel_spans:0});return}let r=Qt(n),{entries:o,prunedCount:i}=Zt(r,t),s=o.filter(g=>Xt(g.next_attempt_after)).slice(0,Ha);if(s.length===0){let g=i>0?await kr(e,t,new Set,new Map):o.length;await R(e,{pending_otel_spans:g});return}let a=M(),c=new Set,d=new Map,u=0,f;await Promise.all(s.map(async g=>{try{let h=await Hr(g.endpoint,{"content-type":"application/json"},JSON.stringify(g.payload));if(h<200||h>=300)throw new Error(`local_otel_export_http_${h}`);c.add(g.id),u+=1}catch(h){f=h instanceof Error?Wt(h.message,"redacted"):"local_otel_export_failed";let y=g.attempts+1;d.set(g.id,{attempts:y,next_attempt_after:Br(y)})}}));let _=await kr(e,t,c,d),p={pending_otel_spans:_,last_otel_attempt_at:a};u>0&&(p.last_otel_success_at=a),f!==void 0?(p.last_otel_failure_at=a,p.last_otel_failure_error=f):_===0&&(p.last_otel_failure_at=void 0,p.last_otel_failure_error=void 0),await R(e,p)}async function Sc(e,t,n){try{await Ic(e,t,n)}catch{}try{await wc(e,n)}catch{}}async function Tc(e,t=Qa){try{let n=cc(e),r=await za(n,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(r.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=A.join(n,i.name);(await Or(s)).mtimeMs<o&&await Jt(s,{force:!0})}))}catch{}}async function fe(e,t=re(process.cwd()),n=5e3){let r=Cr.catch(()=>{}).then(()=>sn(async()=>{let o=await he(t,"telemetry-queue",60,"telemetry",!1,!1,n,{createParentDirectories:!Y(process.env[H])});try{return be(t),await e()}finally{await o()}}));return Cr=r.catch(()=>{}),r}async function Ke(e){let t=await T(Be(e));return t===null||t.trim().length===0?[]:Yr(t)}async function Gt(e,t,n){return fe(async()=>{let r=await Ke(e),{entries:o}=We(r,n),i=o.filter(s=>!t.has(s.event.event_id));return await Kr(e,i),i},e)}async function vc(e,t,n,r){return fe(async()=>{let o=await Ke(e),{entries:i}=We(o,r),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:n,next_attempt_after:Br(c)}});return await Kr(e,s),s},e)}async function Ic(e,t,n){await Tc(e);let r=t.trim();if(r.length===0)return;let o=await T(Be(e));if(o===null||o.trim().length===0){await R(e,{endpoint:r,queue_entries:0});return}let i=Yr(o);if(i.length===0){await R(e,{endpoint:r,queue_entries:0});return}let{entries:s,prunedCount:a}=We(i,n);if(s.length===0){let p=await Gt(e,new Set,n);await R(e,{endpoint:r,queue_entries:p.length});return}let c=s.filter(p=>Gr(p)).slice(0,Ba);if(c.length===0){let p=a>0?await Gt(e,new Set,n):s;await R(e,{endpoint:r,queue_entries:p.length});return}let d=new Set(c.map(p=>p.event.event_id)),u=M(),f={"content-type":"application/json"},_=process.env.PM_TELEMETRY_INGEST_KEY?.trim();_&&(f["x-pm-telemetry-key"]=_);try{let p=await Hr(r,f,JSON.stringify({schema_version:Ya,events:c.map(g=>g.event)}));if(p<200||p>=300)throw new Error(`telemetry_flush_http_${p}`)}catch(p){let g=await vc(e,d,u,n),h=p instanceof Error?Wt(p.message,"redacted"):"telemetry_flush_failed";await R(e,{endpoint:r,queue_entries:g.length,last_attempted_flush_at:u,last_failed_flush_at:u,last_failed_flush_error:h});return}try{let p=await Gt(e,d,n);await R(e,{endpoint:r,queue_entries:p.length,last_attempted_flush_at:u,last_successful_flush_at:u,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(p){let g=p instanceof Error?Wt(p.message,"redacted"):"telemetry_flush_failed",h=await Ke(e).catch(()=>s);await R(e,{endpoint:r,queue_entries:h.length,last_attempted_flush_at:u,last_failed_flush_at:u,last_failed_flush_error:g})}}async function Ac(e){let t=$r(e);Y(process.env[H])||await Bt(A.dirname(t),{recursive:!0});try{return await Bt(t),!0}catch(n){if(typeof n!="object"||n===null||!("code"in n)||n.code!=="EEXIST")throw n}try{let n=await Or(t);return Date.now()-n.mtimeMs<Za?!1:(await Jt(t,{recursive:!0,force:!0}),await Bt(t),!0)}catch{return!1}}function Cc(e){try{$a(e,{recursive:!0,force:!0})}catch{}}function xc(e){Cc(dc(e))}async function kc(e,t,n){let r=await Ac(e);if(xc(e),!r)return!1;try{await Sc(e,t,n)}finally{try{await Jt($r(e),{recursive:!0,force:!0})}catch{}}return!0}async function Rr(e,t){let n=new Set;try{let{entries:r}=We(await Ke(e),t);for(let o of r.filter(Gr))n.add(`event:${o.event.event_id}`)}catch{}try{let r=await T(Ge(e));if(r!==null)for(let o of Zt(Qt(r),t).entries)Xt(o.next_attempt_after)&&n.add(`span:${o.id}`)}catch{}return n}async function tf(e=re(process.cwd())){if(!me().telemetry_disabled)try{await ct(e,async()=>{let t=Y(process.env[H]),n=!0;for(;n;){if(!(await P(e)).telemetry.enabled)return;let r=await fe(()=>hc(e),e);if(!r)return;let o=t?await Rr(e,r.retentionDays):new Set;if(!await kc(e,r.endpoint,r.retentionDays)||!t)return;let i=await Rr(e,r.retentionDays);n=i.size>0&&(i.size!==o.size||[...i].some(s=>!o.has(s)))}},()=>Y(process.env[H]))}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]="1e571c5b-0ebf-578a-8a53-398eab70d71e")}catch{}})();export{xu as a,qd as b,Di as c,Ni as d,$i as e,zi as f,mt as g,eo as h,gn as i,yn as j,ro as k,oo as l,io as m,so as n,Tn as o,_o as p,Mc as q,ho as r,Nc as s,se as t,yo as u,Ae as v,Pc as w,Eo as x,Ie as y,$c as z,Ce as A,wo as B,So as C,Ji as D,Ii as E,Sd as F,zn as G,Td as H,Le as I,vd as J,Oi as K,Yd as L,Fi as M,Ui as N,It as O,ji as P,At as Q,qi as R,sl as S,Yi as T,qn as U,Bi as V,Gi as W,Ki as X,hl as Y,Zi as Z,Sl as _,rs as $,is as aa,To as ba,ss as ca,as as da,Ne as ea,ks as fa,Bc as ga,_t as ha,Cn as ia,ht as ja,Po as ka,$o as la,Kc as ma,xn as na,Z as oa,gt as pa,Et as qa,Nt as ra,Yl as sa,Pt as ta,Ue as ua,nr as va,Ve as wa,$t as xa,zt as ya,Ft as za,Ut as Aa,cr as Ba,dr as Ca,mu as Da,Vt as Ea,me as Fa,mi as Ga,Mn as Ha,pi as Ia,_i as Ja,hi as Ka,sd as La,Tt as Ma,Pn as Na,Nn as Oa,Ei as Pa,bi as Qa,$n as Ra,Ti as Sa,ga as Ta,wa as Ua,Ta as Va,va as Wa,Da as Xa,Ma as Ya,Ya as Za,Dr as _a,fe as $a,tf as ab};
23
+ //# sourceMappingURL=chunk-K4FMZB4Y.js.map
@@ -1,4 +1,4 @@
1
- import{A as u,E as p,z as h}from"./chunk-JLXGRDTG.js";import{readFile as b,realpath as y,stat as _,writeFile as $}from"node:fs/promises";import l from"node:path";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="38df9536-d87a-52ac-958d-091a17c9da9c")}catch{}})();var d="# pm-cli:runtime-cache:start",f="# pm-cli:runtime-cache:end",E=".agents/pm";async function m(n){let e=l.resolve(n),t=[];for(;;)try{let i=await y(e);if(!(await _(i)).isDirectory())throw Object.assign(new Error("Initialization path ancestry must be a directory."),{code:"ENOTDIR"});return l.join(i,...t)}catch(i){if(!p(i)||l.dirname(e)===e)throw i;t.unshift(l.basename(e)),e=l.dirname(e)}}var R=["runtime/","search/","locks/","transactions/","checkpoints/"],T=["search/eval-queries.json"];async function w(n){try{return await n()}catch(e){throw e instanceof Error&&"code"in e&&typeof e.code=="string"&&["EACCES","EPERM","EROFS"].includes(e.code)?new u("The workspace .gitignore is not writable.",h.GENERIC_FAILURE,{code:"init_gitignore_unwritable",reason:e.code.toLowerCase(),required:"Grant the current user read and write access to the workspace .gitignore before initialization.",why:"pm init must publish its managed runtime-cache ignore fence without replacing unrelated entries.",nextSteps:["Grant read and write access to the workspace .gitignore and rerun pm init.","If the workspace is intentionally read-only, initialize pm in a writable workspace or clone."]}):e}}function I(n){let e=n.split(l.sep).join("/").replace(/^\.\/+/,""),t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}function k(n){let e=n.replaceAll("\\","/");return l.isAbsolute(n)||e===".."||e.startsWith("../")}function G(n=E){let e=I(n);if(/[\r\n]/u.test(e))throw new u("A tracker path containing a line break cannot be represented safely in .gitignore.",h.USAGE,{code:"invalid_argument_value",required:"a tracker path without line breaks",nextSteps:["Choose a tracker path without carriage returns or newlines and rerun pm init."]});let t=e.replace(/[\\*?[\]#! \t]/gu,"\\$&");return[d,...R.map(i=>i==="search/"?`${t}/${i}*`:`${t}/${i}`),...T.map(i=>`!${t}/${i}`),f].join(`
1
+ import{A as u,E as p,z as h}from"./chunk-QVFE5LIX.js";import{readFile as b,realpath as y,stat as _,writeFile as $}from"node:fs/promises";import l from"node:path";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="38df9536-d87a-52ac-958d-091a17c9da9c")}catch{}})();var d="# pm-cli:runtime-cache:start",f="# pm-cli:runtime-cache:end",E=".agents/pm";async function m(n){let e=l.resolve(n),t=[];for(;;)try{let i=await y(e);if(!(await _(i)).isDirectory())throw Object.assign(new Error("Initialization path ancestry must be a directory."),{code:"ENOTDIR"});return l.join(i,...t)}catch(i){if(!p(i)||l.dirname(e)===e)throw i;t.unshift(l.basename(e)),e=l.dirname(e)}}var R=["runtime/","search/","locks/","transactions/","checkpoints/"],T=["search/eval-queries.json"];async function w(n){try{return await n()}catch(e){throw e instanceof Error&&"code"in e&&typeof e.code=="string"&&["EACCES","EPERM","EROFS"].includes(e.code)?new u("The workspace .gitignore is not writable.",h.GENERIC_FAILURE,{code:"init_gitignore_unwritable",reason:e.code.toLowerCase(),required:"Grant the current user read and write access to the workspace .gitignore before initialization.",why:"pm init must publish its managed runtime-cache ignore fence without replacing unrelated entries.",nextSteps:["Grant read and write access to the workspace .gitignore and rerun pm init.","If the workspace is intentionally read-only, initialize pm in a writable workspace or clone."]}):e}}function I(n){let e=n.split(l.sep).join("/").replace(/^\.\/+/,""),t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}function k(n){let e=n.replaceAll("\\","/");return l.isAbsolute(n)||e===".."||e.startsWith("../")}function G(n=E){let e=I(n);if(/[\r\n]/u.test(e))throw new u("A tracker path containing a line break cannot be represented safely in .gitignore.",h.USAGE,{code:"invalid_argument_value",required:"a tracker path without line breaks",nextSteps:["Choose a tracker path without carriage returns or newlines and rerun pm init."]});let t=e.replace(/[\\*?[\]#! \t]/gu,"\\$&");return[d,...R.map(i=>i==="search/"?`${t}/${i}*`:`${t}/${i}`),...T.map(i=>`!${t}/${i}`),f].join(`
2
2
  `)}function O(n,e,t){let i=e.replace(/[\\*?[\]#! \t]/gu,"\\$&"),o=[...new Set([e,i])].flatMap(s=>R.flatMap(c=>[`${s}/${c}`,`!${s}/${c}`])),a=[],r=!1;for(let s of n)o.some(c=>s.startsWith(c))?(r||a.push(...t),r=!0):a.push(s);return r||a.push(...t),a}function P(n){let e=[],t=-1,i=0,o=0;for(let a of n.split(`
3
3
  `)){let r=a.endsWith("\r")?a.slice(0,-1):a;r===d?(t=o,i=o+a.length+1):r===f&&t>=0&&(e.push({index:t,end:o+r.length,lines:n.slice(i,o).split(/\r?\n/u).filter(s=>s.length>0)}),t=-1),o+=a.length+1}return e}function v(n,e){let t=n.includes(`\r
4
4
  `)?`\r
@@ -6,4 +6,4 @@ import{A as u,E as p,z as h}from"./chunk-JLXGRDTG.js";import{readFile as b,realp
6
6
  `,i=G(e).split(`
7
7
  `).slice(1,-1),o=P(n),a=o.flatMap(c=>c.lines),r=[d,...O(a,e,i),f].join(t);if(o.length===0){let c=n.length===0?"":n.endsWith(`
8
8
  `)?t:`${t}${t}`;return`${n}${c}${r}${t}`}let s=n;for(let[c,g]of[...o.entries()].reverse())s=`${s.slice(0,g.index)}${c===0?r:""}${s.slice(g.end)}`;return s}async function S(n,e={}){let t=l.join(n,".gitignore"),i=E;if(e.pmRoot!==void 0){let r=I(l.relative(await m(n),await m(e.pmRoot)));if(k(r))return{path:t,changed:!1};i=r}let o="";try{o=await w(()=>b(t,"utf8"))}catch(r){if(!(r instanceof Error&&"code"in r&&p(r)))throw r}let a=v(o,i);return a===o?{path:t,changed:!1}:(await w(()=>$(t,a,"utf8")),{path:t,changed:!0})}export{R as a,k as b,S as c};
9
- //# sourceMappingURL=chunk-DFUTCKUF.js.map
9
+ //# sourceMappingURL=chunk-MQVBWFJF.js.map
@@ -1,3 +1,3 @@
1
- import{a as c}from"./chunk-MW77Q3AQ.js";import{g as d,oa as w,pa as u}from"./chunk-GP2WU43K.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="158d5065-075c-5355-a65c-f3edc9c5f1f0")}catch{}})();var _=new Map(d.map(e=>[e.toLowerCase(),e])),$=/^[A-Za-z][A-Za-z0-9_-]*$/;function g(e,t){if(!$.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function y(e){return _.get(e.trim().toLowerCase())}function A(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function I(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function b(e){let t=new Map;for(let o of e){let n=o.trim();if(n.length===0)continue;let i=n.toLowerCase();t.has(i)||t.set(i,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function S(e){let t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");g(t,"Type name");let o=y(t);if(o)throw new Error(`Cannot redefine built-in item type "${o}". Built-in types are reserved: ${d.join(", ")}.`);let n=e.description?.trim(),i=e.defaultStatus?.trim(),r=e.folder?.trim(),a=r&&r.length>0?u(r):void 0,s=b(e.aliases??[]);for(let l of s){g(l,"Alias");let f=y(l);if(f)throw new Error(`Alias "${l}" collides with built-in item type "${f}". Built-in types are reserved: ${d.join(", ")}.`)}return{name:t,description:n&&n.length>0?n:void 0,defaultStatus:i&&i.length>0?i:void 0,folder:a,aliases:s}}function x(e,t){let o=e.name.toLowerCase(),n=new Map;for(let r of t.definitions){if(typeof r.name!="string")continue;let a=r.name.trim();if(!(a.length===0||a.toLowerCase()===o)){n.set(a.toLowerCase(),a);for(let s of A(r.aliases))s.trim().length>0&&n.set(s.trim().toLowerCase(),a)}}let i=n.get(o);if(i)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${i}".`);for(let r of e.aliases){let a=n.get(r.toLowerCase());if(a)throw new Error(`Alias "${r}" already maps to existing item type "${a}".`)}}function h(e,t){return typeof t=="string"&&t.trim().length>0?u(t).toLowerCase():w(e).toLowerCase()}function D(e,t,o){let n=e.name.toLowerCase(),i=h(e.name,e.folder),r=s=>{throw new Error(`Item type "${e.name}" would store items in folder "${i}", which already belongs to existing item type "${s}". Pass a distinct --folder to keep their storage separate.`)};for(let s of t.definitions){if(typeof s.name!="string")continue;let l=s.name.trim();l.length===0||l.toLowerCase()===n||h(l,s.folder)===i&&r(l)}let a=o?.get(i);a!==void 0&&a.toLowerCase()!==n&&r(a)}function j(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:L(t)}}function L(e){let t=C(e);if(!t)return[];let o=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.name!="string"||i.name.trim().length===0||o.push(i)}return o}function C(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let o=t.item_types;if(Array.isArray(o.definitions))return o.definitions}}function z(e,t){let o=t.name.toLowerCase(),n=e.definitions.slice(),i=n.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===o),r=i>=0?n[i]:void 0,a=b([...A(r?.aliases),...t.aliases]),s={...r,name:t.name};return t.folder!==void 0&&(s.folder=t.folder),a.length>0?s.aliases=a:s.aliases!==void 0&&delete s.aliases,T(s,"description",t.description),T(s,"default_status",t.defaultStatus),i>=0?n[i]=s:n.push(s),n.sort((l,f)=>l.name.localeCompare(f.name)),{file:{definitions:n},definition:s,replaced:i>=0,...r&&typeof r.name=="string"?{previousName:r.name}:{}}}function F(e,t){let o=(t??"").trim();if(o.length===0)throw new Error("Type name must not be empty.");let n=y(o);if(n)throw new Error(`Cannot remove built-in item type "${n}". Built-in types are reserved: ${d.join(", ")}.`);let i=o.toLowerCase(),r=e.definitions.slice(),a=r.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===i);if(a<0)return{file:{definitions:r},removed:!1};let[s]=r.splice(a,1);return{file:{definitions:r},removed:!0,definition:s}}function T(e,t,o){let n=e;o!==void 0&&(n[t]=o)}function M(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
1
+ import{a as c}from"./chunk-Q23K6WLV.js";import{g as d,oa as w,pa as u}from"./chunk-TGS5RXBY.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="158d5065-075c-5355-a65c-f3edc9c5f1f0")}catch{}})();var _=new Map(d.map(e=>[e.toLowerCase(),e])),$=/^[A-Za-z][A-Za-z0-9_-]*$/;function g(e,t){if(!$.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function y(e){return _.get(e.trim().toLowerCase())}function A(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function I(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function b(e){let t=new Map;for(let o of e){let n=o.trim();if(n.length===0)continue;let i=n.toLowerCase();t.has(i)||t.set(i,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function S(e){let t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");g(t,"Type name");let o=y(t);if(o)throw new Error(`Cannot redefine built-in item type "${o}". Built-in types are reserved: ${d.join(", ")}.`);let n=e.description?.trim(),i=e.defaultStatus?.trim(),r=e.folder?.trim(),a=r&&r.length>0?u(r):void 0,s=b(e.aliases??[]);for(let l of s){g(l,"Alias");let f=y(l);if(f)throw new Error(`Alias "${l}" collides with built-in item type "${f}". Built-in types are reserved: ${d.join(", ")}.`)}return{name:t,description:n&&n.length>0?n:void 0,defaultStatus:i&&i.length>0?i:void 0,folder:a,aliases:s}}function x(e,t){let o=e.name.toLowerCase(),n=new Map;for(let r of t.definitions){if(typeof r.name!="string")continue;let a=r.name.trim();if(!(a.length===0||a.toLowerCase()===o)){n.set(a.toLowerCase(),a);for(let s of A(r.aliases))s.trim().length>0&&n.set(s.trim().toLowerCase(),a)}}let i=n.get(o);if(i)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${i}".`);for(let r of e.aliases){let a=n.get(r.toLowerCase());if(a)throw new Error(`Alias "${r}" already maps to existing item type "${a}".`)}}function h(e,t){return typeof t=="string"&&t.trim().length>0?u(t).toLowerCase():w(e).toLowerCase()}function D(e,t,o){let n=e.name.toLowerCase(),i=h(e.name,e.folder),r=s=>{throw new Error(`Item type "${e.name}" would store items in folder "${i}", which already belongs to existing item type "${s}". Pass a distinct --folder to keep their storage separate.`)};for(let s of t.definitions){if(typeof s.name!="string")continue;let l=s.name.trim();l.length===0||l.toLowerCase()===n||h(l,s.folder)===i&&r(l)}let a=o?.get(i);a!==void 0&&a.toLowerCase()!==n&&r(a)}function j(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:L(t)}}function L(e){let t=C(e);if(!t)return[];let o=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.name!="string"||i.name.trim().length===0||o.push(i)}return o}function C(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let o=t.item_types;if(Array.isArray(o.definitions))return o.definitions}}function z(e,t){let o=t.name.toLowerCase(),n=e.definitions.slice(),i=n.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===o),r=i>=0?n[i]:void 0,a=b([...A(r?.aliases),...t.aliases]),s={...r,name:t.name};return t.folder!==void 0&&(s.folder=t.folder),a.length>0?s.aliases=a:s.aliases!==void 0&&delete s.aliases,T(s,"description",t.description),T(s,"default_status",t.defaultStatus),i>=0?n[i]=s:n.push(s),n.sort((l,f)=>l.name.localeCompare(f.name)),{file:{definitions:n},definition:s,replaced:i>=0,...r&&typeof r.name=="string"?{previousName:r.name}:{}}}function F(e,t){let o=(t??"").trim();if(o.length===0)throw new Error("Type name must not be empty.");let n=y(o);if(n)throw new Error(`Cannot remove built-in item type "${n}". Built-in types are reserved: ${d.join(", ")}.`);let i=o.toLowerCase(),r=e.definitions.slice(),a=r.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===i);if(a<0)return{file:{definitions:r},removed:!1};let[s]=r.splice(a,1);return{file:{definitions:r},removed:!0,definition:s}}function T(e,t,o){let n=e;o!==void 0&&(n[t]=o)}function M(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
2
2
  `}function E(e,t){let o=e.trim().length>0?e.trim():e,n=t?.trim()||".agents/pm/schema/types.json";return`To register a custom type, run: pm schema add-type "${I(o)}" (writes ${n}).`}function O(e,t,o){return`Invalid type value "${e}". Allowed: ${t.join(", ")}. ${E(e,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]="77a7b77a-907c-541d-ac55-e06174dbbf11")}catch{}})();function v(e){return typeof e=="string"?e.trim().toLowerCase():""}function m(e,t){let o=c(e);return o.length===0?"":t?.alias_to_id?.get(o)??o}function U(e){let t=Array.isArray(e?.type_workflows)?e.type_workflows:[],o=new Map;for(let n of t){let i=v(n?.type);if(i.length===0||!Array.isArray(n?.allowed_transitions))continue;let r=n.allowed_transitions,a=o.get(i)??{pairs:[],denyAll:!1};r.length===0&&(a.denyAll=!0);for(let s of r){if(!Array.isArray(s)||s.length!==2)continue;let l=c(s[0]),f=c(s[1]);l.length===0||f.length===0||a.pairs.some(p=>p[0]===l&&p[1]===f)||a.pairs.push([l,f])}o.set(i,a)}return[...o.entries()].filter(([,n])=>n.pairs.length>0||n.denyAll).map(([n,i])=>({type:n,allowed_transitions:i.pairs})).sort((n,i)=>n.type.localeCompare(i.type))}function J(e){let t=v(e.typeName),o=e.typeWorkflows.find(r=>r.type===t);if(!o)return{allowed:!0,hasRule:!1,allowedTransitions:[]};let n=m(e.fromStatus,e.statusRegistry),i=m(e.toStatus,e.statusRegistry);return n.length>0&&n===i?{allowed:!0,hasRule:!0,allowedTransitions:o.allowed_transitions}:{allowed:o.allowed_transitions.some(r=>{let a=m(r[0],e.statusRegistry),s=m(r[1],e.statusRegistry);return a===n&&s===i}),hasRule:!0,allowedTransitions:o.allowed_transitions}}function W(e){return e.length===0?"(no transitions allowed)":e.map(t=>`${t[0]} -> ${t[1]}`).join(", ")}export{y as a,I as b,S as c,x as d,D as e,j as f,z as g,F as h,M as i,O as j,U as k,J as l,W as m};
3
- //# sourceMappingURL=chunk-2J7T2UCH.js.map
3
+ //# sourceMappingURL=chunk-NJFMG3IK.js.map