@unbrained/pm-cli 2026.11.1 → 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.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +18 -0
- package/CONTRIBUTING.md +1 -1
- package/dist/cli/migration-gates.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-TMPO4CTZ.js → chunk-3A4NVHYS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UUN3WNMQ.js → chunk-3ZQQVJT2.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-TYERATXH.js → chunk-4HW253W2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-F3ECOBKA.js → chunk-4OELCF3O.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-2GK2IVU5.js → chunk-533L6D2N.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-NILQ2ZMV.js → chunk-ABFFRQRO.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-BFZUJ5QP.js +115 -0
- package/dist/cli-bundle/chunks/{chunk-SBVX5CMV.js → chunk-D52QQ7LP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WFBYKDB2.js → chunk-DAZFCSDV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ICT6E4IW.js → chunk-EN27ZQSV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MRUA2Z43.js → chunk-GK2CHAT3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MTRIGD7M.js → chunk-HOGKWJU5.js} +42 -42
- package/dist/cli-bundle/chunks/{chunk-WX25MU4N.js → chunk-J3JM36EH.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-O56O7NIE.js → chunk-JRXD7SIL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5KW4WUAK.js → chunk-K46GDAKX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-N45IXPCA.js → chunk-KJLGBLR3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UEEG47TU.js → chunk-NGRPD3ZO.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-OJR2YGXF.js +31 -0
- package/dist/cli-bundle/chunks/chunk-QHHFXNSQ.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-Y7CKVU56.js → chunk-RGHLQGEX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6PKWKVS6.js → chunk-VEOFWE32.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-ZNWDYDFF.js +129 -0
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-KGMJVFH2.js → indexed-receipt-blobs-IEJ2QOW3.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-JHPBH6N7.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-admission-BOOCJPCU.js → mutation-admission-QUNQZCZ5.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-23OX36Q3.js → register-list-query-NZTK3AXA.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-JPJ5YNDX.js → register-mutation-2OFAMOVH.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-IGR7ERY5.js → register-operations-RFMM5KZ6.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-BMIFKZZP.js → register-setup-6B6Q7M5L.js} +2 -2
- package/dist/cli-bundle/chunks/{settlement-hook-YWSWFOZY.js → settlement-hook-UTCEZBFT.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-ON7CYYPM.js → stage-VLI4OBVX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-5TWS5KOM.js → chunk-3UD6F2KQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-5WCQFH6D.js → chunk-4NVPDZLX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PAT6QF63.js → chunk-4UUE3YXZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2Y77HWIX.js → chunk-5UDDRPYR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RPUDOJVB.js → chunk-745IDMTD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3NYWMUX3.js → chunk-B6OOKKOX.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-JCR32IAO.js → chunk-EJJWOFP5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-FUGYXUUL.js +80 -0
- package/dist/cli-bundle/focused-chunks/{chunk-Z7GIVH6B.js → chunk-HMXVTWIV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UQIBGLDR.js → chunk-I4Z2SCV5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-JLN5CFYM.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-K4FMZB4Y.js +23 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DFUTCKUF.js → chunk-MQVBWFJF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6GMYW42K.js → chunk-NJFMG3IK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6OKPYCLU.js → chunk-PCCZ72C3.js} +54 -54
- package/dist/cli-bundle/focused-chunks/chunk-PF553UVP.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-VFQAZLKO.js → chunk-Q23K6WLV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LVA76N27.js → chunk-QNXXOFLQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-JLXGRDTG.js → chunk-QVFE5LIX.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-VS2ZFPXD.js → chunk-RUCG6UWN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WX2RVS2Y.js → chunk-SGWYNU7T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-TGS5RXBY.js +26 -0
- package/dist/cli-bundle/focused-chunks/{chunk-AL7SOFUL.js → chunk-WD43E7RU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GE755ODZ.js → chunk-YM4AMP7H.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-KHWT44EK.js → indexed-receipt-blobs-FT3KF6VJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-7VLPA2SU.js → item-transaction-F4SN7TXJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-2DH27R5Y.js → mutation-admission-7R2FXJ5O.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{settlement-hook-SJV52ZTV.js → settlement-hook-KMIBD4F2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-FYOBWQA7.js → stage-6B3O2GZ6.js} +2 -2
- package/dist/cli-bundle/main.js +24 -24
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +57 -57
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +9 -9
- package/dist/core/extensions/extension-types.d.ts +5 -0
- package/dist/core/extensions/extension-types.js +1 -1
- package/dist/core/item/parse.js +2 -2
- package/dist/core/lock/lock-confinement.d.ts +55 -0
- package/dist/core/lock/lock-confinement.js +2 -0
- package/dist/core/lock/lock-gc.js +1 -1
- package/dist/core/lock/lock.js +2 -2
- package/dist/core/shared/errors.d.ts +6 -0
- package/dist/core/shared/errors.js +1 -1
- package/dist/core/store/settings-sections.d.ts +61 -0
- package/dist/core/store/settings-sections.js +3 -0
- package/dist/core/store/settings-validator.d.ts +4 -0
- package/dist/core/store/settings-validator.js +1 -1
- package/dist/core/store/settings.d.ts +29 -2
- package/dist/core/store/settings.js +4 -3
- package/dist/core/telemetry/consent.js +2 -2
- package/dist/core/telemetry/runtime.js +2 -2
- package/dist/core/test/background-runs.js +3 -3
- package/dist/sdk/config.js +1 -1
- package/dist/sdk/extension-command-context.js +2 -2
- package/dist/sdk/generated/error-code-catalog-rows.d.ts +39 -0
- package/dist/sdk/generated/error-code-catalog-rows.js +2 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +3 -3
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +3 -3
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/generated-error-code-catalog.js +1 -1
- package/dist/sdk/mcp/discovery.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/runtime-primitives.d.ts +2 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/docs/AGENT_EVIDENCE_CONSISTENCY.md +10 -0
- package/docs/CONFIGURATION.md +9 -0
- package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +9 -6
- package/docs/RELEASING.md +22 -2
- package/docs/SDK.md +28 -1
- package/docs/SDK_CONFIGURATION_SAFETY.md +55 -0
- package/docs/TESTING.md +2 -1
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +12 -3
- package/marketplace.json +1 -1
- package/package.json +9 -3
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-5WVE7XBS.js +0 -114
- package/dist/cli-bundle/chunks/chunk-E74BORFX.js +0 -128
- package/dist/cli-bundle/chunks/chunk-MP2DQJH2.js +0 -3
- package/dist/cli-bundle/chunks/chunk-O6TFUV6M.js +0 -31
- package/dist/cli-bundle/chunks/item-transaction-Q5S5YLEJ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3Z53POXU.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-7WJDRZOR.js +0 -22
- package/dist/cli-bundle/focused-chunks/chunk-CIQ6YWCW.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-M22TI7LP.js +0 -79
- package/dist/cli-bundle/focused-chunks/chunk-SXZM4PSS.js +0 -44
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import{A as h,C as xn,D as Nn,E as fe,a as W,b as Tn,c as bo,e as kt,f as Ot,g as St,h as wo,i as At,j as Te,k as vo,m as Rn,p as Ct,q as It,t as He,z as g}from"./chunk-JLXGRDTG.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="628615ea-5be3-5753-a6c5-3eba8400a8da")}catch{}})();function Tt(e,t,n){if(e===t)return 0;if(Math.abs(e.length-t.length)>n)return null;let r=t.length+1,o=new Array(r),i=new Array(r),s=new Array(r);for(let c=0;c<r;c+=1)o[c]=0,i[c]=c;for(let c=1;c<=e.length;c+=1){s[0]=c;let d=s[0];for(let l=1;l<=t.length;l+=1){let m=e[c-1]===t[l-1]?0:1,u=i[l-1]+m,f=s[l-1]+1,p=i[l]+1,_=Math.min(u,f,p);c>1&&l>1&&e[c-1]===t[l-2]&&e[c-2]===t[l-1]&&(_=Math.min(_,o[l-2]+1)),s[l]=_,_<d&&(d=_)}if(d>n)return null;for(let l=0;l<r;l+=1)o[l]=i[l],i[l]=s[l]}let a=i[t.length];return a<=n?a:null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bc25122b-94e0-510e-bdbd-b10e3c255d68")}catch{}})();var Dc=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],Eo=Dc,Xg=["draft","open","in_progress","blocked","closed","canceled"],Jg=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],ko=["string","number","boolean","string_array","array","object"],Qg=["create","update","update_many","list","search","calendar","context"],Zg=["allow","warn","reject"],ey=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],ty=["project","global"],ny=["low","medium","high","critical"],ry=["low","medium","high","critical"],oy=["low","medium","high"];var iy=["minimal","default","strict","custom"],sy=["none","warn","strict"],ay=["progressive","strict"],cy=["off","warn","strict"],dy=["off","warn","strict"];var ly=["daily","weekly","monthly","yearly"],Pc=["mon","tue","wed","thu","fri","sat","sun"];function uy(e){return Pc.indexOf(e)}var fy=["draft","research","review","approved","executing","paused","completed","superseded"],my=["pending","in_progress","completed","blocked","skipped","superseded"],py=["codex","claude-code","cursor","generic"],_y=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],gy=["brief","standard","deep","full"],yy=["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="67511565-01f8-58a6-ad06-45b5d0ce831b")}catch{}})();var $c=new Set(["name","version","entry","priority","description","author","capabilities","manifest_version","pm_min_version","pm_max_version","engines","trusted","provenance","sandbox_profile","permissions","activation","contributions","legacy_capability_aliases"]);function Mc(e){return{unknownKeys:Object.keys(e).filter(t=>!$c.has(t)).sort((t,n)=>t>n?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function Lc(e){let t=Mc(e),n=t.unknownKeys.map(r=>({code:"manifest_unknown_key",path:r,...r==="compatibility"?{suggested_key:"pm_min_version"}:{},message:r==="compatibility"?'Manifest key "compatibility" is ignored; declare the canonical pm_min_version and optional pm_max_version fields instead.':`Manifest key "${r}" is not part of the extension manifest contract and will be ignored.`}));return t.missingVersionBounds&&n.push({code:"no_version_bounds_declared",path:"$",suggested_key:"pm_min_version",message:"No canonical pm version bounds are declared; add pm_min_version so compatibility intent is explicit."}),{ok:n.length===0,findings:n}}function Oo(e,t,n){return Lc(n).findings.map(r=>r.code==="manifest_unknown_key"?`extension_manifest_unknown_key:${e}:${t.name}:key=${r.path}${r.suggested_key?`:suggested=${r.suggested_key}`:""}`:`extension_manifest_no_version_bounds:${e}:${t.name}:suggested=pm_min_version`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2ea7934f-4751-5245-a5ba-492681aa3794")}catch{}})();var Dn=[{kind:"blocked_by",direction:"directed",traversal:"ordering",inverse:"blocks",ordering:!0,precedence:"target_before_source",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["depends_on"],compatibilityVersion:1,allowSelf:!1},{kind:"blocks",direction:"directed",traversal:"ordering",inverse:"blocked_by",ordering:!0,precedence:"source_before_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"parent",direction:"directed",traversal:"hierarchy",outcomeTraversal:"source_to_target",inverse:"child",ordering:!1,hierarchy:!0,hierarchyDirection:"target_parent",outgoing:"one",incoming:"many",lifecycle:"supersedable",aliases:["child_of","epic"],compatibilityVersion:1,allowSelf:!1},{kind:"child",direction:"directed",traversal:"hierarchy",outcomeTraversal:"target_to_source",inverse:"parent",ordering:!1,hierarchy:!0,hierarchyDirection:"source_parent",outgoing:"many",incoming:"one",lifecycle:"supersedable",aliases:["parent_child","task"],compatibilityVersion:1,allowSelf:!1},{kind:"related",direction:"undirected",traversal:"association",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",aliases:["related_to"],compatibilityVersion:1,allowSelf:!1},{kind:"discovered_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"incident_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"implements",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"recurs_from",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,temporalOrder:"source_after_target",hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"verifies",direction:"directed",traversal:"semantic",outcomeTraversal:"source_to_target",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"persistent",compatibilityVersion:1,allowSelf:!1},{kind:"supersedes",direction:"directed",traversal:"semantic",outcomeTraversal:"both",ordering:!1,hierarchy:!1,outgoing:"many",incoming:"many",lifecycle:"supersedable",compatibilityVersion:1,allowSelf:!1}];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="418b3f7f-6350-5878-a362-3948de287baf")}catch{}})();function Nt(e){return e.trim().toLowerCase().replaceAll("-","_")}function jc(e){if(e===void 0)return;let t=Nt(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function $n(e,t=new Set){if(e===null||typeof e!="object"||t.has(e))return e;if(t.add(e),Array.isArray(e)){for(let n of e)$n(n,t);return Object.freeze(e)}for(let n of Object.values(e))$n(n,t);return Object.freeze(e)}function Fc(e,t){if(e.precedence!==void 0&&e.precedence!=="source_before_target"&&e.precedence!=="target_before_source")throw new TypeError(`Invalid relationship precedence for ${t}`);if(!e.ordering&&e.precedence!==void 0)throw new TypeError(`Non-ordering relationship kind cannot declare precedence: ${t}`)}function Uc(e,t){if(e.temporalOrder!==void 0&&e.temporalOrder!=="source_after_target")throw new TypeError(`Invalid relationship temporal order for ${t}`);if(e.direction!=="directed"&&e.temporalOrder!==void 0)throw new TypeError(`Undirected relationship kind cannot declare temporal order: ${t}`)}function zc(e,t){if(e.hierarchyDirection!==void 0&&e.hierarchyDirection!=="source_parent"&&e.hierarchyDirection!=="target_parent")throw new TypeError(`Invalid relationship hierarchy direction for ${t}`);if(!e.hierarchy&&e.hierarchyDirection!==void 0)throw new TypeError(`Non-hierarchy relationship kind cannot declare hierarchy direction: ${t}`)}function qc(e){if(typeof e!="object"||e===null)throw new TypeError("Relationship kind definition requires an object");if(typeof e.kind!="string")throw new TypeError("Relationship kind requires a string identifier");let t=Nt(e.kind);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid relationship kind: ${e.kind}`);if(!Number.isInteger(e.compatibilityVersion)||e.compatibilityVersion<1)throw new TypeError(`Invalid compatibility version for ${t}`);return t}function Bc(e,t){if(!["directed","undirected"].includes(e.direction))throw new TypeError(`Invalid relationship direction for ${t}`);if(typeof e.ordering!="boolean")throw new TypeError(`Invalid relationship ordering flag for ${t}`);if(![void 0,!0,!1].includes(e.hierarchy))throw new TypeError(`Invalid relationship hierarchy flag for ${t}`);if(!["one","many"].includes(e.outgoing))throw new TypeError(`Invalid outgoing relationship cardinality for ${t}`);if(!["one","many"].includes(e.incoming))throw new TypeError(`Invalid incoming relationship cardinality for ${t}`);if(!["persistent","supersedable","ephemeral"].includes(e.lifecycle))throw new TypeError(`Invalid relationship lifecycle for ${t}`);if(typeof e.allowSelf!="boolean")throw new TypeError(`Invalid relationship self-edge flag for ${t}`);if(e.traversal!==void 0&&!["hierarchy","ordering","semantic","association"].includes(e.traversal))throw new TypeError(`Invalid relationship traversal family for ${t}`);if(e.outcomeTraversal!==void 0&&!["source_to_target","target_to_source","both"].includes(e.outcomeTraversal))throw new TypeError(`Invalid outcome traversal for ${t}`);if(e.direction==="undirected"&&e.outcomeTraversal!==void 0&&e.outcomeTraversal!=="both")throw new TypeError(`Undirected relationship kind cannot declare directional outcome traversal: ${t}`)}function Vc(e,t){if(e.payloadSchema!==void 0&&(typeof e.payloadSchema!="object"||e.payloadSchema===null||Array.isArray(e.payloadSchema)))throw new TypeError(`Invalid relationship payload schema for ${t}`);if(e.aliases!==void 0&&(!Array.isArray(e.aliases)||e.aliases.some(n=>typeof n!="string")))throw new TypeError(`Invalid relationship aliases for ${t}`)}function Gc(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var Mn=class{#e=new Map;#n=new Map;constructor(t=Dn){for(let n of t)this.register(n)}register(t){let n=qc(t);if(Bc(t,n),Vc(t,n),Fc(t,n),Uc(t,n),zc(t,n),this.#e.has(n)||this.#n.has(n))throw new TypeError(`Relationship kind already registered: ${n}`);let r=jc(t.inverse),o=[...new Set((t.aliases??[]).map(Nt))].sort();for(let s of o){if(!/^[a-z][a-z0-9_]*$/.test(s))throw new TypeError(`Invalid relationship alias: ${s}`);if(s===n||this.#e.has(s)||this.#n.has(s))throw new TypeError(`Relationship alias already registered: ${s}`)}let i=Object.freeze({...t,kind:n,traversal:Gc(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:r,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?$n(structuredClone(t.payloadSchema)):void 0});this.#e.set(n,i);for(let s of o)this.#n.set(s,n);return this}resolve(t){if(typeof t!="string")return;let n=Nt(t);return this.#e.get(this.#n.get(n)??n)}require(t){let n=this.resolve(t);if(!n)throw new TypeError(`Unknown relationship kind: ${t}`);return n}list(){return Object.freeze([...this.#e.values()].sort((t,n)=>t.kind.localeCompare(n.kind)))}};function Ln(){return new Mn}var me=Ln();function ky(e){return me.require(e).kind}function Oy(e){return me.resolve(e)?.kind}function Sy(e,t=me){return t.resolve(e)?.ordering===!0}function Wc(e,t,n,r=me){let o=Ye(e),i=Ye(t);if(!o||!i)throw new TypeError("Relationship endpoint must not be empty");let s=r.require(n);if(o===i&&!s.allowSelf)throw new TypeError(`Self relationship is not allowed for ${s.kind}`);return s}function Rt(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function Kc(e,t,n){let r=typeof e.source=="string"?e.source.trim():"",o=typeof e.target=="string"?e.target.trim():"";if(!t.has(r)||!t.has(o))throw new TypeError(`Relationship endpoint not found: ${r} -> ${o}`);let i=Wc(r,o,e.kind,n),s=Object.freeze({...e,source:r,target:o,kind:i.kind}),a=i.direction==="undirected"?[r,o].sort().join("\0"):`${r}\0${o}`;return{edge:s,identity:`${i.kind}\0${a}`}}function xt(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function Ye(e){return typeof e=="string"?e.trim():""}function Pn(e,t){let n=Ye(e);return n&&t.has(n)?n:void 0}function Hc(e,t,n){let r=[t],o=t;for(;o!==e;)o=n.get(o),r.push(o);return r.reverse()}var So=class e{#e;#n;#o;#r;#s=new Map;#a=new Map;constructor(t,n,r=me){this.#e=r,this.#n=new Set([...t].filter(i=>typeof i=="string").map(i=>i.trim()).filter(Boolean)),this.#o=Object.freeze([...this.#n].sort());let o=new Map;for(let i of n){let{edge:s,identity:a}=Kc(i,this.#n,r);o.set(a,s)}this.#r=Object.freeze([...o.values()].sort(Rt));for(let i of this.#r)xt(this.#s,i.source,i),xt(this.#a,i.target,i),r.require(i.kind).direction==="undirected"&&(xt(this.#s,i.target,i),xt(this.#a,i.source,i))}static fromItems(t,n=me){let r=new Set(t.map(i=>Ye(i.id)).filter(Boolean)),o=[];for(let i of t){let s=Ye(i.id);if(!s)continue;let a=Pn(i.parent,r);a&&o.push({source:s,target:a,kind:"parent"});let c=Pn(i.blocked_by,r);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let d of i.dependencies??[]){let l=Pn(d.id,r);l&&n.resolve(d.kind)&&o.push({source:s,target:l,kind:d.kind,createdAt:d.created_at,author:d.author})}}return new e(r,o,n)}edges(){return this.#r}incidentEdges(t){this.#i(t);let n=this.#s.get(t)??[],r=this.#a.get(t)??[];if(n.length===0)return Object.freeze([...r]);if(r.length===0)return Object.freeze([...n]);let o=[],i=0,s=0;for(;i<n.length||s<r.length;){let a=n[i],c=r[s],d=a===void 0?c:c===void 0||Rt(a,c)<=0?a:c;o.at(-1)!==d&&o.push(d),a===d&&(i+=1),c===d&&(s+=1)}return Object.freeze(o)}nodes(){return this.#o}hasNode(t){return this.#n.has(t)}registry(){return this.#e}#i(t){if(!this.#n.has(t))throw new TypeError(`Relationship node not found: ${t}`)}#c(t,n){if(!n)return!0;let r=this.#e.require(t.kind);return n.has(t.kind)||r.inverse!==void 0&&n.has(r.inverse)}#t(t,n,r){let o=[...n==="incoming"?[]:this.#s.get(t)??[],...n==="outgoing"?[]:this.#a.get(t)??[]];return[...new Set(o)].filter(i=>this.#c(i,r)).map(i=>({id:i.source===t?i.target:i.source,edge:i})).sort((i,s)=>i.id.localeCompare(s.id)||Rt(i.edge,s.edge))}adjacency(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=[...new Set(o.map(c=>c.id))],a=s.slice(0,i);return{value:a,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:a.length<s.length,nextCursor:a.at(-1)}}}neighborEdges(t,n={}){this.#i(t),n.signal?.throwIfAborted();let r=n.kinds?new Set(n.kinds.map(a=>this.#e.require(a).kind)):void 0,o=this.#t(t,n.direction??"outgoing",r),i=n.limit??Number.POSITIVE_INFINITY,s=o.slice(0,i);return{value:s,meta:{visitedNodes:1,inspectedEdges:o.length,truncated:s.length<o.length,nextCursor:s.at(-1)?.id}}}closure(t,n={}){this.#i(t);let r=n.kinds?new Set(n.kinds.map(f=>this.#e.require(f).kind)):void 0,o=n.direction??"outgoing",i=n.limit??Number.POSITIVE_INFINITY,s=n.maxDepth??Number.POSITIVE_INFINITY,a=new Set([t]),c=[],d=[{id:t,depth:0}],l=0,m=0,u=!1;e:for(let f=0;f<d.length;f+=1){n.signal?.throwIfAborted();let p=d[f];l+=1;let _=this.#t(p.id,o,r);if(m+=_.length,p.depth>=s){_.some(y=>!a.has(y.id))&&(u=!0);continue}for(let y of _)if(!a.has(y.id)){if(c.length>=i){u=!0;break e}a.add(y.id),c.push(y.id),d.push({id:y.id,depth:p.depth+1})}}return{value:c,meta:{visitedNodes:l,inspectedEdges:m,truncated:u,nextCursor:c.at(-1)}}}shortestPath(t,n,r={}){if(this.#i(t),this.#i(n),t===n)return{value:[t],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}};let o=r.kinds?new Set(r.kinds.map(f=>this.#e.require(f).kind)):void 0,i=r.direction??"outgoing",s=r.maxDepth??Number.POSITIVE_INFINITY,a=[{id:t,depth:0}],c=new Map,d=new Set([t]),l=0,m=0,u=!1;for(let f=0;f<a.length;f+=1){r.signal?.throwIfAborted();let p=a[f];l+=1;let _=this.#t(p.id,i,o);if(m+=_.length,p.depth>=s){_.some(y=>!d.has(y.id))&&(u=!0);continue}for(let y of _)if(!d.has(y.id)){if(c.set(y.id,p.id),y.id===n)return{value:Hc(t,n,c),meta:{visitedNodes:l,inspectedEdges:m,truncated:!1}};d.add(y.id),a.push({id:y.id,depth:p.depth+1})}}return{value:[],meta:{visitedNodes:l,inspectedEdges:m,truncated:u}}}subgraph(t,n={}){let r=this.closure(t,n),o=[t,...r.value].sort(),i=new Set(o),s=n.kinds?new Set(n.kinds.map(c=>this.#e.require(c).kind)):void 0,a=new Set;for(let c of o)for(let d of this.#s.get(c)??[])i.has(d.source)&&i.has(d.target)&&this.#c(d,s)&&a.add(d);return{value:{nodes:o,edges:[...a].sort(Rt)},meta:r.meta}}};function Ay(e,t,n=me){return{source:e,target:t.id,kind:n.require(t.kind).kind,createdAt:t.created_at,author:t.author}}import Zc from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0ca7f52c-fb31-5cd9-b689-a918f4e61816")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="75f74db3-9547-5c78-8561-f371c016b90d")}catch{}})();function Z(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Yc(e){let t=e.key.trim();if(t.length===0)return null;let n=Z(e.aliases),r=e.description?.trim();return{key:t,values:Z(e.values),required:e.required===!0?!0:void 0,aliases:n.length>0?n:void 0,description:r&&r.length>0?r:void 0}}var Xc=e=>e,Co=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function Jc(e,t){let n=t(e.command);if(n===null)return null;let r=e.option.trim();return r.length===0?null:{command:n,option:r,required:e.required,visible:e.visible,enabled:e.enabled}}function Qc(e,t){let n=new Map;for(let r of e??[]){let o=Jc(r,t);o&&n.set(`${o.command}:${o.option.toLowerCase()}`,o)}return[...n.values()].sort((r,o)=>r.command===o.command?r.option.localeCompare(o.option):r.command.localeCompare(o.command))}function Ao(e,t){return t?Z(e):void 0}function jn(e){let t=e?.trim();return t&&t.length>0?t:void 0}function Fn(e){if(e===void 0||e==="agent"||e==="human"||e==="gate")return e;throw new Error("Item type execution_role must be agent, human, or gate.")}function Io(e,t={}){let n=t.resolvePolicyCommand??Xc,r=e.name.trim();if(r.length===0)return null;let o=e.required_create_fields!==void 0,i=e.required_create_repeatables!==void 0,s=e.options!==void 0,a=e.command_option_policies!==void 0,c=Z(e.aliases),d=(e.options??[]).map(m=>Yc(m)).filter(m=>m!==null).sort((m,u)=>m.key.localeCompare(u.key)),l=Qc(e.command_option_policies,n);return{name:r,description:jn(e.description),default_status:jn(e.default_status),...e.execution_role===void 0?{}:{execution_role:Fn(e.execution_role)},folder:jn(e.folder),aliases:c.length>0?c:void 0,required_create_fields:Ao(e.required_create_fields,o),required_create_repeatables:Ao(e.required_create_repeatables,i),options:s?d:void 0,command_option_policies:a?l:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f40ddc8e-1dd5-5f26-b2ba-fbbac30a1781")}catch{}})();var ed=Object.freeze({decision:"human",milestone:"gate"}),td=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],nd=["dep","comment","note","learning","file","test","doc"],Ro=["deadline","estimatedMinutes","acceptanceCriteria","definitionOfReady","order","goal","objective","value","impact","outcome","whyNow","assignee","parent","reviewer","risk","confidence","sprint","release","blockedBy","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact"],rd=["title","description","type","status","priority","tags","body",...Ro,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],od=["title","description","body","status","closeReason","priority","type","tags",...Ro,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],xo={"close-reason":"closeReason",close_reason:"closeReason","estimated-minutes":"estimatedMinutes",estimated_minutes:"estimatedMinutes",estimate:"estimatedMinutes","acceptance-criteria":"acceptanceCriteria",acceptance_criteria:"acceptanceCriteria",ac:"acceptanceCriteria","definition-of-ready":"definitionOfReady",definition_of_ready:"definitionOfReady",rank:"order","why-now":"whyNow",why_now:"whyNow","blocked-by":"blockedBy",blocked_by:"blockedBy","blocked-reason":"blockedReason",blocked_reason:"blockedReason","unblock-note":"unblockNote",unblock_note:"unblockNote","repro-steps":"reproSteps",repro_steps:"reproSteps","expected-result":"expectedResult",expected_result:"expectedResult","actual-result":"actualResult",actual_result:"actualResult","affected-version":"affectedVersion",affected_version:"affectedVersion","fixed-version":"fixedVersion",fixed_version:"fixedVersion","customer-impact":"customerImpact",customer_impact:"customerImpact","type-option":"typeOption",type_option:"typeOption",type_options:"typeOption"},id={...xo},sd={...xo},No=[["deadline","--deadline"],["estimatedMinutes","--estimate/--estimated-minutes"],["acceptanceCriteria","--acceptance-criteria/--ac"],["definitionOfReady","--definition-of-ready"],["order","--order/--rank"],["goal","--goal"],["objective","--objective"],["value","--value"],["impact","--impact"],["outcome","--outcome"],["whyNow","--why-now"],["assignee","--assignee"],["parent","--parent"],["reviewer","--reviewer"],["risk","--risk"],["confidence","--confidence"],["sprint","--sprint"],["release","--release"],["blockedBy","--blocked-by"],["blockedReason","--blocked-reason"],["unblockNote","--unblock-note"],["reporter","--reporter"],["severity","--severity"],["environment","--environment"],["reproSteps","--repro-steps"],["resolution","--resolution"],["expectedResult","--expected-result"],["actualResult","--actual-result"],["affectedVersion","--affected-version"],["fixedVersion","--fixed-version"],["component","--component"],["regression","--regression"],["customerImpact","--customer-impact"]],Do=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function Po(e){return Object.fromEntries(e)}var ad=Po([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...No,["author","--author"],["message","--message"],["dep","--dep"],...Do]),cd=Po([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...No,...Do,["author","--author"],["message","--message"],["force","--force"]]);function dd(e){return e.trim().replace(/^--+/,"").toLowerCase()}function ld(e){return e==="create"?rd:od}function ud(e){return e==="create"?id:sd}function $o(e,t){let n=dd(t);return n.length===0?void 0:ud(e)[n]||ld(e).find(r=>r.toLowerCase()===n)}function $y(e,t){return(e==="create"?ad:cd)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function zn(e){let t=md(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function fd(e){let t=e.trim(),n=t.replaceAll("\\","/").replace(/^\/+/,""),r=Zc.posix.normalize(n);if(t.includes("\0")||/^[A-Za-z]:/.test(r)||r==="."||r===".."||r.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return r}function md(e){let t=e.trim().toLowerCase(),n="",r=!1;for(let o of t){let i=o.charCodeAt(0),s=i>=97&&i<=122,a=i>=48&&i<=57;if(s||a){r&&n.length>0&&(n+="-"),n+=o,r=!1;continue}n.length>0&&(r=!0)}return n}function pd(e){return Io(e,{resolvePolicyCommand:Co})}function Xe(e,t){let n=e[t];return Array.isArray(n)?n.filter(r=>typeof r=="string"):void 0}function _d(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;return typeof t.key!="string"?null:{key:t.key,values:Xe(t,"values")??[],required:t.required===void 0?void 0:!!t.required,aliases:Xe(t,"aliases"),description:typeof t.description=="string"?t.description:void 0}}function gd(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e;if(typeof t.command!="string"||typeof t.option!="string")return null;let n=t.command.trim().toLowerCase();return n!=="create"&&n!=="update"?null:{command:n,option:t.option,required:t.required===void 0?void 0:!!t.required,visible:t.visible===void 0?void 0:!!t.visible,enabled:t.enabled===void 0?void 0:!!t.enabled}}function yd(e){if(Array.isArray(e.options))return e.options.map(t=>_d(t)).filter(t=>t!==null)}function hd(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>gd(t)).filter(t=>t!==null)}function bd(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e,n=typeof t.name=="string"?t.name:"";if(n.trim().length===0)return null;let r=typeof t.folder=="string"?t.folder:void 0,o=typeof t.description=="string"?t.description:void 0,i=typeof t.default_status=="string"?t.default_status:void 0;return{name:n,description:o,default_status:i,execution_role:Fn(t.execution_role),folder:r,aliases:Xe(t,"aliases"),required_create_fields:Xe(t,"required_create_fields"),required_create_repeatables:Xe(t,"required_create_repeatables"),options:yd(t),command_option_policies:hd(t)}}function wd(e,t){return e.required_create_fields?Z(e.required_create_fields):t?.required_create_fields??[]}function vd(e,t){return e.required_create_repeatables?Z(e.required_create_repeatables):t?.required_create_repeatables??[]}function Ed(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function kd(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function Od(e,t){let n=t?.name??e.name,r=e.description??t?.description,o=e.default_status??t?.default_status,i=fd(e.folder??t?.folder??zn(n)),s={name:n,execution_role:e.execution_role,folder:i,aliases:Z([...t?.aliases??[],...e.aliases??[]]),required_create_fields:wd(e,t),required_create_repeatables:vd(e,t),options:Ed(e,t),command_option_policies:kd(e,t)};return r&&(s.description=r),o&&(s.default_status=o),s}function To(e,t){for(let n of e){let r=pd(n);if(!r)continue;let o=r.name.toLowerCase(),i=t.get(o);t.set(o,Od({...r,execution_role:r.execution_role??i?.execution_role},i))}}function Sd(e){if(!e)return[];let t=[];for(let n of e.item_types??[]){let r=n.types;if(Array.isArray(r))for(let o of r){let i=bd(o);i&&t.push(i)}}return t}function My(e,t=null){let n=new Map;for(let c of Eo)n.set(c.toLowerCase(),{name:c,execution_role:ed[c.toLowerCase()]??"agent",folder:He[c],aliases:[],required_create_fields:[...td],required_create_repeatables:[...nd],options:[],command_option_policies:[]});To(e.item_types?.definitions??[],n),To(Sd(t),n);let r=[...n.values()].sort((c,d)=>c.name.localeCompare(d.name)),o={},i={},s={};for(let c of r){o[c.name]=c,s[c.name]=c.folder,i[c.name.toLowerCase()]=c.name;for(let d of c.aliases)i[d.toLowerCase()]=c.name}let a=[...new Set(r.map(c=>c.folder))].sort((c,d)=>c.localeCompare(d));return{types:r.map(c=>c.name),folders:a,type_to_folder:s,by_type:o,alias_to_type:i}}function Ad(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function Cd(e,t){let n=Ad(e,t);if(n)return t.by_type[n]}function Id(e,t,n,r){for(let o of r){let i=$o(n,o);if(i){e.required.add(i);continue}e.errors.push(`Unsupported base required option "${o}" for command "${n}" on type "${t.name}"`)}}function Un(e,t,n){if(n){e.add(t);return}e.delete(t)}function Td(e,t,n,r){let o=$o(n,r.option);if(!o){e.errors.push(`Unsupported command_option_policies option "${r.option}" for command "${n}" on type "${t.name}"`);return}r.required!==void 0&&Un(e.required,o,r.required),r.visible!==void 0&&Un(e.hidden,o,!r.visible),r.enabled!==void 0&&Un(e.disabled,o,!r.enabled)}function Rd(e,t,n){for(let r of t.command_option_policies)r.command===n&&Td(e,t,n,r)}function xd(e,t,n){for(let r of e.required)e.disabled.has(r)&&e.errors.push(`Option "${r}" cannot be both required and disabled for command "${n}" on type "${t.name}"`)}function Ly(e,t,n){let r=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:r};return Id(a,e,t,n),Rd(a,e,t),xd(a,e,t),{required:[...o],hidden:[...i].sort((c,d)=>c.localeCompare(d)),disabled:[...s].sort((c,d)=>c.localeCompare(d)),errors:r}}function Nd(e){let t=new Map;for(let n of e.options){t.set(n.key.toLowerCase(),n);for(let r of n.aliases??[])t.set(r.toLowerCase(),n)}return t}function Dd(e,t,n){let r=e.values;if(r.length===0)return t;let o=new Map(r.map(i=>[i.toLowerCase(),i])).get(t.toLowerCase());if(!o){n.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${r.join(", ")}`);return}return o}function jy(e,t,n){let r=Cd(e,n);if(!r)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=Nd(r),s={};for(let[c,d]of Object.entries(t??{})){let l=c.trim(),m=d.trim();if(l.length===0){o.push("type option keys must not be empty");continue}if(m.length===0){o.push(`type option "${l}" must not be empty`);continue}let u=i.get(l.toLowerCase());if(!u){let p=r.options.map(_=>_.key).join(", ");o.push(r.options.length>0?`Unknown type option "${l}" for type "${r.name}". Allowed: ${p}`:`Type "${r.name}" does not define any configurable type options`);continue}let f=Dd(u,m,o);f!==void 0&&(s[u.key]=f)}for(let c of r.options)c.required&&!(c.key in s)&&o.push(`Missing required type option "${c.key}" for type "${r.name}"`);let a=Object.keys(s).sort((c,d)=>c.localeCompare(d));return a.length===0?{normalized:void 0,errors:o}:{normalized:Object.fromEntries(a.map(c=>[c,s[c]])),errors:o}}import{readFileSync as Pd,readdirSync as zy,realpathSync as Mo,statSync as jo}from"node:fs";import $d from"node:os";import v from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7f4b8abe-997c-549c-9791-87c78506c8b5")}catch{}})();var Md={json_markdown:".md",toon:".toon"},Ld={".md":"json_markdown",".toon":"toon"};var Hy=[".md",".toon"];function Dt(e){try{return jo(e),!0}catch{return!1}}function jd(e){let t=v.resolve(e),n=[];for(;v.dirname(t)!==t;)try{return v.join(Mo(t),...n)}catch(r){if(!Nn(r))throw r;n.unshift(v.basename(t)),t=v.dirname(t)}return v.join(Mo(t),...n)}function Fd(e){try{return jo(e),!0}catch(t){if(Nn(t))return!1;throw t}}function Ud(e){try{let t=JSON.parse(Pd(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function zd(e){let t=jd(e);for(;;){let n=v.join(t,Ct),r=v.join(n,It);if(Dt(r))return n;let o=v.join(t,It);if(Dt(o)&&Ud(o))return t;if(Fd(v.join(t,".git")))return n;let i=v.dirname(t);if(i===t)return;t=i}}function qn(e){return zd(e)??v.resolve(e,Ct)}function Fo(e,t){let n=process.env.PM_PATH,r=t?.trim()||n?.trim();if(r){let o=v.resolve(e,r);if(!Dt(Lo(o))){let i=v.join(o,Ct);if(Dt(Lo(i)))return i}return o}return qn(e)}function Uo(e){let t=v.resolve(e),n=v.dirname(t);return v.basename(t)==="pm"&&v.basename(n)===".agents"?v.dirname(n):t}function zo(e){let t=process.env.PM_GLOBAL_PATH?.trim(),n=t&&t.length>0?t:v.join($d.homedir(),".pm-cli");return v.resolve(e,n)}function Lo(e){return v.join(e,It)}function qd(e,t,n=He){let r=n[t]??zn(t);return v.join(e,r)}function Yy(e,t,n,r="toon",o=He){return v.join(qd(e,t,o),`${n}${Md[r]}`)}function Xy(e){let t=e.replaceAll("\\","/"),n=v.posix.extname(t).toLowerCase();return Ld[n]??null}function Jy(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new h("Invalid history item id: expected a single filename.",g.USAGE);return v.join(e,"history",`${t}.jsonl`)}function Bn(e,t){return v.join(e,"locks",`${t}.lock`)}function Qy(e){return v.join(e,"runtime")}import Bd from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="77f9d61e-e78b-5b6a-a769-1ad6e5b91777")}catch{}})();function Vd(e){if(e===null)return null;if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="bigint")return e.toString();if(e===void 0)return"undefined";if(typeof e=="symbol")return e.toString();if(typeof e=="function")return`[function:${e.name||"anonymous"}]`}function Gd(e){let t=Object.keys(e).sort(),n={};for(let r of t){let o=e[r];o!==void 0&&(n[r]=Pt(o))}return n}function Pt(e){let t=Vd(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(r=>Pt(r));if(e instanceof Date)return e.toISOString();let n=e;if(typeof n.toJSON=="function"){let r=n.toJSON();if(r!==e)return Pt(r)}return Gd(e)}function pe(e){return JSON.stringify(Pt(e))}function qo(e,t,n,r){for(let o=0;o<t.length;o+=1)if(!n.has(o)&&r(e,t[o]))return n.add(o),!0;return!1}function Wd(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function Kd(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function Hd(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let n=[...t],r=new Set;for(let o of e)if(!qo(o,n,r,V))return!1;return!0}function Yd(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let n=[...t.entries()],r=new Set;for(let[o,i]of e.entries())if(!qo([o,i],n,r,([s,a],[c,d])=>V(s,c)&&V(a,d)))return!1;return!0}function Xd(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,r)=>V(n,t[r]))}function Jd(e,t){let n=Object.keys(e).sort((o,i)=>o.localeCompare(i)),r=Object.keys(t).sort((o,i)=>o.localeCompare(i));if(n.length!==r.length)return!1;for(let o=0;o<n.length;o+=1){let i=n[o];if(i!==r[o]||!V(e[i],t[i]))return!1}return!0}var Qd=[Wd,Kd,Hd,Yd,Xd];function V(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let n of Qd){let r=n(e,t);if(r!==void 0)return r}return Jd(e,t)}function th(e){return Bd.createHash("sha256").update(e,"utf8").digest("hex")}function nh(e,t){let n={};for(let o of t){let i=e[o];i!==void 0&&(n[o]=i)}let r=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of r){let i=e[o];i!==void 0&&(n[o]=i)}return n}import{createHash as Vo}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f675993f-c483-5751-baed-d968b4fd24c0")}catch{}})();var Zd=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],Bo=256,Vn=64;function z(e){throw new h(`Invalid workflow policy: ${e}`,g.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function K(e,t,n){if(typeof e!="object"||e===null||Array.isArray(e))return z(`${n} must be an object`);let r=e;return Object.keys(r).some(o=>!t.includes(o))?z(`${n} contains an unknown key`):r}function _e(e,t,n=128){return typeof e!="string"||!e.trim()||e.length>n?z(`${t} must be nonempty text of at most ${n} characters`):e.trim()}function Je(e,t){if(!Array.isArray(e)||e.length===0||e.length>Vn)return z(`${t} requires 1-${Vn} terms`);let n=e.map(r=>_e(r,t));return t==="fields"&&n.some(r=>!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$/.test(r)||r.split(".").some(o=>["__proto__","constructor","prototype"].includes(o)))?z("fields must be safe metadata paths of at most eight segments"):[...new Set(n)]}function el(e){let t=K(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(K(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>Vn?z("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(n=>!Array.isArray(n)||n.length!==2?z("transition pairs need two statuses"):[_e(n[0],"from"),_e(n[1],"to")])}):t.kind==="authors"?(K(t,["kind","authors"],"authors rule"),{kind:"authors",authors:Je(t.authors,"authors")}):t.kind==="require_fields"?(K(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:Je(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(K(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:Je(t.fields,"fields"),authors:Je(t.authors,"authors")}):z("unknown rule kind")}function tl(e){let t={},n=K(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let r of["types","tags","statuses","operations","parents"])n[r]!==void 0&&(t[r]=Je(n[r],r));if(n.dependency!==void 0){let r=K(n.dependency,["kind","id"],"dependency");t.dependency={kind:_e(r.kind,"dependency kind"),...r.id===void 0?{}:{id:_e(r.id,"dependency id")}}}return t}function nl(e){let t=K(e,["id","description","subject","effect","rule"],"policy"),n=_e(t.id,"id");return/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(n)?t.effect!==void 0&&(typeof t.effect!="string"||!["advise","warn","refuse"].includes(t.effect))?z("effect must be advise, warn, or refuse"):{id:n,rule:el(t.rule),...t.subject===void 0?{}:{subject:tl(t.subject)},...t.description===void 0?{}:{description:_e(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:z("id must be a stable token")}function rl(e){let t=K(e,["version","enforcement","policies"],"document");if(t.version!==1)return z("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return z("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>Bo)return z(`policies must contain at most ${Bo} declarations`);let n=t.policies.map(nl);return new Set(n.map(r=>r.id)).size!==n.length?z("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:n}}function $t(e,t){let n=e;for(let r of t.split(".")){if(typeof n!="object"||n===null||!Object.hasOwn(n,r))return;n=n[r]}return n}function ol(e){return e==null?!1:typeof e=="string"?e.trim().length>0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0}function Go(e){return Vo("sha256").update(pe(e)).digest("hex")}function il(e,t){let n=e.rule.kind==="approval"?e.rule.fields:[];return Vo("sha256").update(pe({id:t.id,fields:n.map(r=>[r,$t(t,r)])})).digest("hex")}function sl(e,t){return Array.isArray(t)&&t.some(n=>typeof n=="object"&&n!==null&&"kind"in n&&n.kind===e.kind&&(e.id===void 0||"id"in n&&n.id===e.id))}function al(e,t,n){return!(e.types&&!e.types.some(r=>r.toLowerCase()===String(t.type).toLowerCase())||e.statuses&&!e.statuses.includes(String(t.status))||e.operations&&!e.operations.includes(n)||e.parents&&!e.parents.includes(String(t.parent))||e.tags&&(!Array.isArray(t.tags)||!e.tags.some(r=>t.tags.includes(r)))||e.dependency&&!sl(e.dependency,t.dependencies))}function cl(e,t){if(t.completeness_only&&(e.rule.kind!=="require_fields"||e.subject?.operations!==void 0)||e.rule.kind==="approval"&&t.before===null)return!1;let n=e.subject??{},r=t.after?.status??t.before?.status;return[t.before,t.after].some(o=>o!==null&&al(n,{...o,status:r},t.operation))}function dl(e,t,n,r){let o=["type","tags","parent","dependencies"].some(i=>!V(t.before?.[i],t.after?.[i]));return t.after&&(t.completeness_only||n||r||o)?e.filter(i=>!ol($t(t.after,i))):[]}function ll(e,t,n,r){let o=t.after??t.before,i=il(e,o);return t.approvals?.some(s=>s.policy_fingerprint===r&&s.content_fingerprint===i&&s.author!==t.author&&n.includes(s.author))??!1}function ul(e,t,n){let r=e.rule,o=t.before?.status!==t.after?.status,i="fields"in r&&r.fields.some(s=>!V($t(t.before,s),$t(t.after,s)));switch(r.kind){case"require_fields":{let s=dl(r.fields,t,o,i);return{satisfied:s.length===0,missing_fields:s,remediation:"Supply the declared required fields before this lifecycle transition."}}case"transition":return{satisfied:!o||r.allowed.some(([s,a])=>s===String(t.before?.status??"$create")&&a===String(t.after?.status??"$delete")),missing_fields:[],remediation:"Choose a declared allowed transition; inspect pm schema policies."};case"authors":return{satisfied:r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared workflow actor perform this operation."};case"field_writers":return{satisfied:!i||r.authors.includes(t.author),missing_fields:[],remediation:"Have a declared field writer change the protected fields."};case"approval":return{satisfied:!o||ll(e,t,r.authors,n),missing_fields:[],remediation:`Record an independent approval with pm schema policy-approve <item-id> --policy ${e.id} after preparing the reviewed fields.`}}}function Wo(e,t,n){let r=e.policies.filter(o=>cl(o,t)).map(o=>{let i=o.effect??"advise",s=n(o);return{policy_id:o.id,policy_fingerprint:s,rule:o.rule.kind,effect:i==="refuse"&&e.enforcement!=="refuse"?"warn":i,...ul(o,t,s)}});return{allowed:!r.some(o=>!o.satisfied&&o.effect==="refuse"),decisions:r,warnings:r.filter(o=>!o.satisfied).map(o=>`workflow_policy:${o.effect}:${o.policy_id}:${o.rule}`)}}function ch(e,t){return Wo(e,t,Go)}function dh(e){let t=rl(e),n=new Map(t.policies.map(r=>[r,Go(r)]));return r=>Wo(t,r,o=>n.get(o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="451b262c-a9b6-5f1c-b397-2686a5fd953a")}catch{}})();var fl=[["history-redact","history redact"],["history-repair","history repair"],["history-compact","history compact"],["activity","history activity"],["restore","history restore"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-tqel"})),ml=[...["next","focus"].map(e=>({alias:e,canonical:`context ${e}`,owner:"pm-kcs4"})),...["stats","health","validate","gc","telemetry","eval","test-all"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-6apl"})),...["normalize","reindex"].map(e=>({alias:e,canonical:`ops ${e}`,owner:"pm-3i9q8g"})),{alias:"events",canonical:"history events",owner:"pm-3i9q8g"}].map(e=>({...e,canonical_argv:e.canonical.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap"})),pl=[["update-many","update many"],["close-many","close many"],["delete","close delete"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-ik19"})),_l=[...ml,...pl,...["init","config","schema","profile"].map(e=>({alias:e,canonical:`workspace ${e}`,canonical_argv:["workspace",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-npr3"})),...[...["comments","notes","learnings","files","docs","deps","append","test"].map(e=>[e,`item ${e}`,"pm-yql1"]),["test-runs-worker","item test worker","pm-lp4j"],...["statuses","tags","types"].map(e=>[`completion-${e}`,`completion ${e}`,"pm-szdc"]),["history-author-acknowledge","history acknowledge","pm-djyvbk"],["copy","item copy","pm-m6g87m"],["merge","workspace merge","pm-m6g87m"],["duplicates","item duplicates","pm-fmy9ih"],["dedupe-audit","item duplicates audit","pm-fmy9ih"],["dedupe-merge","item duplicates merge","pm-fmy9ih"],["comments-audit","item audit-comments","pm-fmy9ih"],["search-advanced","search advanced","pm-wfskfn"],...["meet","event","remind"].map(e=>[e,`calendar ${e}`,"pm-o3fh"])].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:n}))],Gn=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...fl,..._l,...["discover","lookup"].map(e=>({alias:`files ${e}`,canonical:`item files ${e}`,canonical_argv:["item","files",e],lifecycle:"permanent",hidden:!0,registration:"bootstrap",owner:"pm-yql1"}))];function uh(e){let t;for(let n of Gn)n.canonical_argv.length<=(t?.canonical_argv.length??0)||n.canonical_argv.every((r,o)=>r===(o===0&&e[o]==="ctx"?"context":e[o]))&&(t=n);return t}function gl(e){let t=e.trim().replace(/\s+/gu," ");return Gn.find(n=>n.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function Qe(e){return gl(e)}var Mt=[...Gn,...[["ctx","context"],["packages","package"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:[t],lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-pbyu"})),...[["start-task","claim","--start"],["pause-task","release","--pause"],["close-task","close","--release-assignment"]].map(([e,t,n])=>({alias:e,canonical:t,canonical_argv:[t,n],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-eq4x"})),{alias:"tests",canonical:"item test",canonical_argv:["item","test"],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-u4t9gp"},...[["fetch","get"],["read","get"],["show","get"],["view","get"],["comment","comments"],["note","notes"],["learning","learnings"]].map(([e,t])=>({alias:e,canonical:["comments","notes","learnings"].includes(t)?`item ${t}`:t,canonical_argv:["comments","notes","learnings"].includes(t)?["item",t]:[t],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-pbyu"})),...[["extension list","extension catalog"],["extension scaffold","extension init"],["package list","package catalog"],["package scaffold","package init"],["packages list","package catalog"],["packages scaffold","package init"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-ya7x55"})),{alias:"list-all",canonical:"list",canonical_argv:["list","--all"],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"},...[["list-draft","draft"],["list-open","open"],["list-in-progress","in_progress"],["list-blocked","blocked"],["list-closed","closed"],["list-canceled","canceled"]].map(([e,t])=>({alias:e,canonical:"list",canonical_argv:["list","--status",t],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"})),...[["extension","package"],["install","package install"],["upgrade","package upgrade"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-tnud"}))],fh=Object.fromEntries(Mt.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function mh(e){let t=e.trim().toLowerCase();return Mt.find(n=>n.alias===t)}function ph(e){return`Deprecated command \`${e.alias}\`; use \`pm ${e.canonical_argv.join(" ")}\`.`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="432226a6-9df4-5de6-b9af-5c06ec2eed66")}catch{}})();var yl=[...W],hl=[...Te],bl=[...kt],bh=[...Ot],wh=[...St],wl=[...At],Lt=["init","config","extension","package","packages","install","upgrade","create","item","copy","focus","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","aggregate","context","ctx","get","graph","search","duplicates","eval","next","history","events","history-redact","history-repair","history-compact","history-attest","history-author-acknowledge","merge","schema","profile","activity","restore","update","update-many","close","close-many","delete","append","comments","notes","learnings","files","docs","deps","plan","test","test-all","telemetry","stats","health","validate","assurance","gc","workspace","contracts","claim","release","start-task","pause-task","close-task","meet","event","remind","help"],vh=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],Eh=["install","reconcile","report","driver"],vl=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],El=["upgrade"],kl=["reopen"],Ko={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Re=Object.freeze(Lt.flatMap(e=>e in Ko?[]:e==="extension"||e==="package"?[...vl.map(t=>`${e}-${t}`),...e==="package"?El.map(t=>`package-${t}`):[],e]:e==="item"?kl.map(t=>`item-${t}`):[e])),Ol=Object.freeze(Mt.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Re.includes(e.alias)).map(e=>e.alias)),kh=Object.freeze(Re.filter(e=>!Ol.includes(e)));function Oh(e=Lt,t=Re,n=Ko){let r=new Set(t),o=new Set(e);return{missing_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]===void 0),waived_cli_actions:e.filter(i=>!r.has(i)&&!t.some(s=>s.startsWith(`${i}-`))&&n[i]!==void 0),stale_waivers:Object.keys(n).filter(i=>!o.has(i)||r.has(i)||t.some(s=>s.startsWith(`${i}-`)))}}function Sh(e){return Re.includes(e)}function Ah(e){return yl.includes(e)}function Ch(e){return hl.includes(e)}function Ih(e){return bl.includes(e)}function Th(e){return wl.includes(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="53865a81-4c96-51e2-a378-ae0e2781a50f")}catch{}})();var jt={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},Ft=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),ge=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","files","docs","stats","aggregate","duplicates","package-catalog","package-manage","comments-audit","assurance"];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f8657910-1392-5fae-afda-614b96dc8320")}catch{}})();function S(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Sl(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function Ho(e){return e?$(e):{}}function Yo(e){return e?$(e):Sl()}function $(e){return structuredClone(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="615b4955-a30d-5d45-a86d-4bcf7bd9bd7a")}catch{}})();var Al=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),Cl=["commands","command_overrides","command_handlers","hooks","flag_commands","item_types","item_fields","relationship_kinds","migrations","profiles","importers","exporters","search_providers","vector_store_adapters","assurance_providers","parser_overrides","service_overrides","renderer_overrides"];function Il(e,t){for(let n of Cl){let r=e[n];if(r===void 0)continue;if(!Array.isArray(r)||r.some(i=>typeof i!="string"))return!1;let o=r.map(i=>Al.has(n)?S(i):i.trim()).filter(i=>i.length>0);t[n]=[...new Set(o)].sort((i,s)=>i.localeCompare(s))}return!0}function Tl(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n;if(r.format!=="json"&&r.format!=="toon"||!Array.isArray(r.commands)||r.commands.some(o=>typeof o!="string")||typeof r.result_discriminator!="boolean")return null;t.push({format:r.format,commands:[...new Set(r.commands.map(o=>S(o)))].sort((o,i)=>o.localeCompare(i)),result_discriminator:r.result_discriminator})}return t.sort((n,r)=>n.format.localeCompare(r.format))}function Rl(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!="object"||n===null)return null;let r=n.commands;if(!Array.isArray(r)||r.some(o=>typeof o!="string"))return null;t.push({commands:[...new Set(r.map(o=>S(o)))].filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i))})}return t}function Ut(e){if(e==null)return;if(typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.schema_version!==1)return null;let n={schema_version:1};if(!Il(t,n))return null;let r=t.preflight_overrides;if(r!==void 0&&(!Number.isInteger(r)||r<0))return null;typeof r=="number"&&(n.preflight_overrides=r);let o=t.renderer_ownership;if(o!==void 0){let s=Tl(o);if(s===null)return null;n.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=Rl(i);if(s===null)return null;n.preflight_ownership=s}return n}function Ph(e){return{schema_version:1,commands:e.commands,command_overrides:e.command_overrides,command_handlers:e.command_handlers,hooks:e.hooks,flag_commands:e.flag_commands,item_types:e.item_types,item_fields:e.item_fields,...e.relationship_kinds?{relationship_kinds:e.relationship_kinds}:{},migrations:e.migrations,profiles:e.profiles,importers:e.importers,exporters:e.exporters,search_providers:e.search_providers,vector_store_adapters:e.vector_store_adapters,...e.assurance_providers?{assurance_providers:e.assurance_providers}:{},parser_overrides:e.parser_overrides,service_overrides:e.service_overrides,renderer_overrides:e.renderer_overrides,...e.renderer_ownership?{renderer_ownership:e.renderer_ownership}:{},preflight_overrides:e.preflight_overrides,...e.preflight_ownership?{preflight_ownership:e.preflight_ownership}:{}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c24357cc-5dad-5cd7-aa89-cddd2945aab7")}catch{}})();var xl=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields"},{flag:"--output-limit",value_name:"count"},{flag:"--output-budget",value_name:"tokens"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state"},{flag:"--output-cursor",value_name:"cursor"},{flag:"--output-row-contract"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"]},{flag:"--no-extensions"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"}]),Wn=new Set(xl.flatMap(e=>[e.flag,...e.aliases??[]]));(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="896ebde0-4ca1-50ed-bb8e-2a8c2d978d94")}catch{}})();var Xo=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function Kn(e){if(typeof e!="string")return null;let t=Xo.exec(e.trim());if(!t)return null;let n=t[2];return{name:t[1],valueName:n?n.slice(1,-1):null,optional:n?.startsWith("[")??!1}}function jh(e){let t=Kn(e);return t?t.name:typeof e=="string"&&e.trim()||null}function Nl(e){if(typeof e!="string")return null;let t=e.trim(),n=t.split(/[ =]/,1)[0];return Wn.has(n)?"host_owned_flag_collision":Xo.test(t)?null:"malformed_long_flag"}function Jo(e,t){let n=[e,t].find(i=>typeof i=="string"&&Wn.has(i.trim().split(/[ =]/,1)[0]));if(typeof n=="string")return{token:n.trim().split(/[ =]/,1)[0],failure:"host_owned_flag_collision"};if(typeof e!="string")return null;let r=e.trim(),o=Nl(r);return o===null?null:{token:r,failure:o}}function Qo(e,t){return t==="host_owned_flag_collision"?`cannot shadow host-owned global flag "${e}"; read it from context.global instead`:`long flag "${e}" must start with a double-dash name such as "--my-flag" or "--my-flag <value>"`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5c3049c3-1d5a-5e7e-a070-35340737a6ab")}catch{}})();var Zo=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function zt(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.hasOwn(Zo,t)?Zo[t]:null}function Dl(e,t,n){return!!(e.value_name?.trim()||t||n||e.required===!0||e.list===!0||e.repeatable===!0)}function Pl(e){return(e.value_type?.trim()||e.type?.trim())?.toLowerCase()}function zh(e){let t=Pl(e),n=zt(t),r=Kn(e.long),o=e.value_name?.trim()||null,i=!(n==="boolean"&&t!=="bool")&&Dl(e,r?.valueName,t),s=r?.valueName?r.optional:t==="bool";return{value_type:n,value_arity:i?s?"optional":"required":"none",value_name:i?o??r?.valueName??"value":null}}function ei(e){let t=[],n=r=>{if(Array.isArray(r)){for(let o of r)n(o);return}if(typeof r=="string"){for(let o of r.split(",")){let i=o.trim();i.length>0&&t.push(i)}return}r!=null&&t.push(r)};return n(e),t}function ti(e,t){return t==="string"?!0:t==="number"?typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim().length>0&&Number.isFinite(Number(e)):typeof e=="boolean"?!0:typeof e=="string"&&["true","false","1","0"].includes(e.trim().toLowerCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="88ed7e44-a3a0-5a23-9d7b-b00087bff331")}catch{}})();var Vh=["id","title","status","type","priority","parent","updated_at"],qt=["id","status","type","title"],Gh={list:"brief","list-all":"full","list-draft":"full","list-open":"brief","list-in-progress":"brief","list-blocked":"brief","list-closed":"brief","list-canceled":"full"},$l=["tree_depth","tree_parent","tree_children","tree_title"];function Wh(e=[]){return[...new Set([...Rn,"body",...$l,...e])].flatMap(t=>[t,`item.${t}`]).sort()}var Ml=["brief","standard","deep"],Kh=[...Ml,"full"],Hh=["brief","standard","deep"],Ll=["body","linked","claim_state","children","schedule","blockers"],jl=["linked.files","linked.tests","linked.docs"],Fl=["claim_state.claimed","claim_state.assignee","claim_state.last_claim","claim_state.last_release"],Ul=["schedule.deadline","schedule.start_at","schedule.end_at","schedule.location","schedule.reminders","schedule.events"];function Yh(e=[]){return[...[...new Set([...Rn,...e,"notes_count","tests_count","collection_counts"])].flatMap(t=>[t,`item.${t}`]),...Ll,...jl,...Fl,...Ul].sort()}var Xh=["id","title","status","type","priority","updated_at","score","matched_fields"],zl=["score","matched_fields","highlights"],ni=["id","title","description","type","status","priority","tags","created_at","updated_at","deadline","assignee","author","estimated_minutes","acceptance_criteria","dependencies","comments","notes","learnings","reminders","events","files","tests","docs","close_reason","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result","affected_version","fixed_version","component","regression","customer_impact","definition_of_ready","order","rank","goal","objective","value","impact","outcome","why_now","plan"];function Jh(e=[]){let t=[...new Set(e)];return[...zl,...ni,...ni.map(n=>`item.${n}`),...t,...t.map(n=>`item.${n}`)].sort()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7359c10a-4c56-57ea-8254-fc26b19e5c84")}catch{}})();function Ze(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function ee(e){return W.includes(e)}function ri(e){let t=e.trim().toLowerCase();return ee(t)?t:null}function oi(e){return e.filter(t=>!ee(t))}function Hn(e){let t=e.trim().toLowerCase();return t.length===0?null:bo[t]??null}function ii(e){let t=Ze([...e].map(i=>i.toLowerCase())),n=[],r=[];for(let i of t){let s=Hn(i);if(s){n.push(s),r.push({alias:i,target:s});continue}n.push(i)}let o=[...new Map(r.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:Ze(n),legacy_aliases:o}}function ql(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=Hn(t);if(n)return n;let r=Math.max(1,Math.floor(t.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of W){let a=Tt(t,s,r);a!==null&&a<i&&(i=a,o=s)}return o}function si(e,t,n){let r=W.join(","),o=ql(n)??"none";return`extension_capability_unknown:${e}:${t}:${n}:allowed=${r}:suggested=${o}`}function ai(e,t,n){let r=n.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${r}`}function Bl(e){let t=/^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(e.trim());if(!t)return null;let[,n,r,o,i,s]=t,a=n,c=i.split(",").map(m=>m.trim()).filter(m=>m.length>0),d=Hn(o),l=(s==="none"?void 0:s)??d??void 0;return{layer:a,name:r,capability:o,allowed_capabilities:c,capability_contract_version:Tn,suggested_capability:l,suggestion_source:l?d===l?"legacy_alias":"nearest_match":void 0,legacy_alias_target:d??void 0}}function Vl(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,n,r,o]=t,i=n,s=[...W],a=[];for(let c of o.split(",")){let[d,l]=c.split(">"),m=d?.trim(),u=l?.trim().toLowerCase();!m||!u||!ee(u)||a.push({layer:i,name:r,capability:m,allowed_capabilities:s,capability_contract_version:Tn,suggested_capability:u,suggestion_source:"legacy_alias",legacy_alias_target:u})}return a}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d8844150-afb4-5f2e-a005-4cfb8482660c")}catch{}})();var Gl={commands:["registerCommand","command override","command handler"],renderers:["registerRenderer"],hooks:["hooks.beforeCommand","hooks.beforeMutation","hooks.afterCommand","hooks.onWrite","hooks.onRead","hooks.onIndex"],schema:["registerFlags","registerItemFields","registerItemTypes","registerRelationshipKinds","registerMigration","registerProfile"],importers:["registerImporter","registerExporter"],search:["registerSearchProvider","registerVectorStoreAdapter"],parser:["registerParser"],preflight:["registerPreflight"],services:["registerService","registerAssuranceMeasurementProvider"]},ci=":";function di(e,t){return`${e}${ci}${Yn(t)}`}function Wl(e){return e.slice(e.indexOf(ci)+1)}function Yn(e){return e.trim().toLowerCase()}function Kl(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let r=ri(n);r!==null&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function li(e){let t=new Map,n=(l,m)=>{for(let u of l){let f=di(u.layer,u.name),p=t.get(f);p===void 0&&(p=new Set,t.set(f,p)),p.add(m)}},{registrations:r,commands:o,parsers:i,preflight:s,services:a,renderers:c,hooks:d}=e;return n(r.commands,"commands"),n(o.overrides,"commands"),n(o.handlers,"commands"),n(r.flags,"schema"),n(r.item_fields,"schema"),n(r.item_types,"schema"),n(r.relationship_kinds??[],"schema"),n(r.migrations,"schema"),n(r.profiles,"schema"),n(r.importers,"importers"),n(r.exporters,"importers"),n(r.search_providers,"search"),n(r.vector_store_adapters,"search"),n(i.overrides,"parser"),n(s.overrides,"preflight"),n(a.overrides,"services"),n(r.assurance_providers??[],"services"),n(c.overrides,"renderers"),n(d.beforeCommand,"hooks"),n(d.beforeMutation,"hooks"),n(d.afterCommand,"hooks"),n(d.onWrite,"hooks"),n(d.onRead,"hooks"),n(d.onIndex,"hooks"),t}function Hl(e,t={}){let n=li(e),r=new Set;t.extensionName!==void 0&&r.add(Yn(t.extensionName));for(let i of t.extensionNames??[])r.add(Yn(i));let o=new Set;for(let[i,s]of n)if(!(r.size>0&&!r.has(Wl(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function Yl(e,t){let n=li(t),r=[];for(let o of e){let i=Kl(o.capabilities);if(i.length===0)continue;let s=n.get(di(o.layer,o.name))??new Set,a=[...s].sort((d,l)=>d.localeCompare(l)),c=i.filter(d=>!s.has(d));r.push({layer:o.layer,name:o.name,declared:i,used:a,unused:c})}return r}import{existsSync as xf}from"node:fs";import{AsyncLocalStorage as Nf}from"node:async_hooks";import Y from"node:path";import ve from"node:fs/promises";import we from"node:path";import{pathToFileURL as Ju}from"node:url";import ui from"path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01422574-583a-5fd1-bc00-f61f430073cd")}catch{}})();function et(e,t){let n=ui.relative(e,t);return n.length===0?!0:!n.startsWith("..")&&!ui.isAbsolute(n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="32aa20df-edf7-543d-b733-841130466f00")}catch{}})();var Xl="__pm_suppress_host_output",Xn="@unbrained/pm-cli:suppress-host-output:v1";function fi(e){return e===void 0?{__pm_suppress_host_output:Xn}:{__pm_suppress_host_output:Xn,result:e}}function Jn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[Xl]===Xn}import xe from"node:fs";import te from"node:path";import{fileURLToPath as Jl}from"node:url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="efea1aa1-1ad1-5f53-a3a5-b83803d9deb1")}catch{}})();var Ql="@unbrained/pm-cli";function Zl(e){try{return JSON.parse(xe.readFileSync(e,"utf8")).name===Ql}catch{return!1}}function eu(e){let t=xe.existsSync(e)&&xe.statSync(e).isDirectory()?te.resolve(e):te.dirname(te.resolve(e));for(;;){let n=te.join(t,"package.json");if(xe.existsSync(n)&&Zl(n))return t;let r=te.dirname(t);if(r===t)return;t=r}}function Qn(e,t=[]){let n=Jl(e);return eu(n)||te.resolve(te.dirname(n),...t)}function lb(e,t=[]){try{let n=te.join(Qn(e,t),"package.json");if(!xe.existsSync(n))return;let r=JSON.parse(xe.readFileSync(n,"utf8"));return typeof r.version=="string"&&r.version.trim().length>0?r.version:void 0}catch{return}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a797572f-fbc6-5e62-a9b5-5a0bd6ef22b4")}catch{}})();function tu(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function fb(e){return tu(e)??void 0}function mb(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t-=1;return t===e.length?e:e.slice(0,t)}function pb(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function pi(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function _i(e){let t=typeof e=="number"?e:typeof e=="string"&&e.trim().length>0?Number(e.trim()):Number.NaN;return Number.isFinite(t)?t:null}function _b(e){let t=_i(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function gb(e,t,n){let r=_i(e);return r===null||r<t||r>n?null:r}function yb(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function ne(e){return typeof e!="object"||e===null?null:e}function mi(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function gi(e){let t=mi(e);if(!t)return null;if(typeof t.activate=="function")return t;let n=mi(t.default);return typeof n?.activate=="function"?n:null}function hb(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e}:{}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="559b05dc-0290-5a7c-97b9-ef1e5e8670ba")}catch{}})();function yi(e){let t={beforeCommand:e.hooks.beforeCommand.length,beforeMutation:e.hooks.beforeMutation.length,afterCommand:e.hooks.afterCommand.length,onWrite:e.hooks.onWrite.length,onRead:e.hooks.onRead.length,onIndex:e.hooks.onIndex.length,commandOverrides:e.commands.overrides.length,commandHandlers:e.commands.handlers.length,parserOverrides:e.parsers.overrides.length,preflightOverrides:e.preflight.overrides.length,serviceOverrides:e.services.overrides.length,rendererOverrides:e.renderers.overrides.length,registrations:Object.fromEntries(Object.entries(e.registrations).map(([n,r])=>[n,r.length]))};return()=>{e.hooks.beforeCommand.length=t.beforeCommand,e.hooks.beforeMutation.length=t.beforeMutation,e.hooks.afterCommand.length=t.afterCommand,e.hooks.onWrite.length=t.onWrite,e.hooks.onRead.length=t.onRead,e.hooks.onIndex.length=t.onIndex,e.commands.overrides.length=t.commandOverrides,e.commands.handlers.length=t.commandHandlers,e.parsers.overrides.length=t.parserOverrides,e.preflight.overrides.length=t.preflightOverrides,e.services.overrides.length=t.serviceOverrides,e.renderers.overrides.length=t.rendererOverrides;for(let[n,r]of Object.entries(t.registrations))e.registrations[n].length=r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="17ae377d-20c2-5e45-825a-48a79c6c7601")}catch{}})();function C(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return t}function D(e,t){if(t!==void 0&&typeof t!="boolean")throw new TypeError(`${e} must be a boolean when provided`)}function A(e,t){if(t!==void 0&&(typeof t!="string"||t.trim().length===0))throw new TypeError(`${e} must be a non-empty string when provided`)}function hi(e,t){if(t===void 0)return;let n=r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean";if(Array.isArray(t)){for(let[r,o]of t.entries())if(!n(o))throw new TypeError(`${e}[${r}] must be a string, number, or boolean`);return}if(!n(t))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function ye(e,t){if(t!==void 0){if(!Array.isArray(t))throw new TypeError(`${e} must be an array of non-empty strings when provided`);for(let[n,r]of t.entries())if(typeof r!="string"||r.trim().length===0)throw new TypeError(`${e}[${n}] must be a non-empty string`)}}function tt(e,t){if(ye(e,t),!Array.isArray(t))return[];let n=[],r=new Set;for(let o of t){let i=o.trim();i.length===0||r.has(i)||(r.add(i),n.push(i))}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="34536eba-0f92-5599-a807-5b39b000e733")}catch{}})();var Zn=Object.freeze(["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"]);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="60fd882d-7c92-5be5-bf46-7e3c128bfb58")}catch{}})();var nu=new Set(Zn);function ru(e){if(e!==void 0&&!nu.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${Zn.join(", ")}`)}function bi(e){A("registerCommand definition.action",e.action),A("registerCommand definition.family",e.family),A("registerCommand definition.description",e.description),A("registerCommand definition.intent",e.intent),A("registerCommand definition.tier",e.tier);let t=e.tier;if(t!==void 0&&t!=="core"&&t!=="standard"&&t!=="full"&&t!=="internal")throw new Error("registerCommand definition.tier must be core, standard, full, or internal");ru(e.family)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="095ea29d-eda3-5287-b54d-8a961658f7bc")}catch{}})();function wi(e,t="",n=""){if(e===void 0)return;if(Ne(t)||Ne(n))throw new TypeError("Native pm commands and actions cannot declare read_output");let r=C("registerCommand definition.read_output",e);if(Object.keys(r).some(s=>s!=="row_keys")||!Array.isArray(r.row_keys))throw new TypeError("registerCommand definition.read_output requires only row_keys: string[]");let o=Array.from(r.row_keys),i=new Set(["__proto__","constructor","prototype","row_contract","read_output","read_session","omission_receipt","output_budget_truncation"]);if(o.some(s=>typeof s!="string"||!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*$/u.test(s)||s.split(".").some(a=>i.has(a))))throw new TypeError("registerCommand definition.read_output row_keys must be safe dot-delimited property paths");if(new Set(o).size!==o.length||o.some(s=>o.some(a=>a.startsWith(`${s}.`))))throw new TypeError("registerCommand definition.read_output row_keys must be unique and non-overlapping");return Object.freeze({row_keys:Object.freeze([...o])})}function Ne(e){let t=e.trim().toLowerCase().replace(/\s+/gu,"-");return Re.includes(t)||ge.includes(t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="07cb237c-3956-5997-85f8-972d2ee490d0")}catch{}})();function ou(e){let t=C("registerExporter options.output",e),n=new Set(["channel","receipt","media_type"]);for(let r of Object.keys(t))if(!n.has(r))throw new TypeError(`registerExporter options.output contains unsupported field ${r}`);if(t.channel!=="stdout"&&t.channel!=="file")throw new TypeError("registerExporter options.output.channel must be stdout|file");if(t.receipt!==void 0&&t.receipt!=="suppress"&&t.receipt!=="render")throw new TypeError("registerExporter options.output.receipt must be suppress|render");if(t.channel==="stdout"&&t.receipt==="render")throw new TypeError("registerExporter stdout artifacts cannot render a host receipt");return A("registerExporter options.output.media_type",t.media_type),{channel:t.channel,receipt:t.receipt??(t.channel==="stdout"?"suppress":"render"),...typeof t.media_type=="string"?{media_type:t.media_type}:{}}}function vi(e,t,n){if(e==="registerImporter"&&t.output!==void 0)throw new TypeError("registerImporter options.output is exporter-only");if(e!=="registerExporter"||t.output===void 0)return;let r=ou(t.output);return!n&&r.channel==="stdout"&&(t.description="Export items with the registered extension adapter. Artifact bytes are written exclusively to stdout and the host receipt is suppressed by default."),r}function er(e,t,n){return{registration:t,action:n,command:e.command,args:$(e.args),options:$(e.options),global:$(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,...e.sdk===void 0?{}:{sdk:e.sdk}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fc2e7eac-cd1c-5885-aa27-e98455008a4f")}catch{}})();function Ei(e){return!e.extensionReady||!e.enabledForLoad?null:{layer:e.layer,directory:e.directory,manifest_path:e.manifestPath,entry_path:e.entryPath,manifest:e.manifest,source_package:e.sourceIdentity?.package_name,source_aliases:e.sourceIdentity?.aliases,contributions:e.sourceIdentity?.contributions}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bb1b4879-079c-50d4-afa5-e8a36ead2e5c")}catch{}})();function q(e){return typeof e!="string"?"":e.trim().toLowerCase()}function w(e){return new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))}function iu(e){let t=e.trim().toLowerCase();if(t.length===0)return"";let n=t.split(/[.:/]/).map(r=>r.replace(/[\s_-]+/g,"")).filter(r=>r.length>0);return n.length===0?"":n.length===1?n[0]:`${n[0]}.${n.slice(1).join("")}`}function De(e){return new Set((e??[]).map(t=>iu(t)).filter(t=>t.length>0))}function ki(e){let t=q(e);return kt.includes(t)?t:"off"}function Oi(e){let t=q(e);return Ot.includes(t)?t:"off"}function nt(e){let t=q(e);return St.includes(t)?t:"none"}function tr(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return wo.includes(t)?t:void 0}function Si(e){if(typeof e=="string"){let t=tr(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:tr(e.global)??"block",project:tr(e.project)??"block"}:{global:"block",project:"block"}}function su(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function E(e){return[...new Set(e)].sort((t,n)=>t.localeCompare(n))}function au(e){let t=q(e.name);return t.length===0?null:{name:t,normalized:{name:t,disabled:e.disabled===!0,requireTrusted:e.require_trusted===!0,requireProvenance:e.require_provenance===!0,sandboxProfile:e.sandbox_profile!==void 0?nt(e.sandbox_profile):void 0,allowedCapabilities:w(e.allowed_capabilities),blockedCapabilities:w(e.blocked_capabilities),allowedSurfaces:De(e.allowed_surfaces),blockedSurfaces:De(e.blocked_surfaces),allowedCommands:w(e.allowed_commands),blockedCommands:w(e.blocked_commands),allowedActions:w(e.allowed_actions),blockedActions:w(e.blocked_actions),allowedServices:w(e.allowed_services),blockedServices:w(e.blocked_services)}}}function Ai(e){let t=new Map;for(let n of e??[]){let r=au(n);r&&t.set(r.name,r.normalized)}return t}function cu(e){let t=[],n=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of E([...e.allowedCapabilities,...e.blockedCapabilities]))ee(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of n)for(let i of E([...o.allowedCapabilities,...o.blockedCapabilities]))ee(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let r=new Set(At);for(let o of E([...e.allowedSurfaces,...e.blockedSurfaces]))r.has(o)||t.push(`extension_policy_unknown_surface:${o}`);for(let o of n)for(let i of E([...o.allowedSurfaces,...o.blockedSurfaces]))r.has(i)||t.push(`extension_policy_unknown_surface:${o.name}:${i}`);return[...new Set(t)].sort((o,i)=>o.localeCompare(i))}function Ci(e){let t=e.extensions?.policy??{},n=w(t.allowed_capabilities),r=w(t.blocked_capabilities),o=De(t.allowed_surfaces),i=De(t.blocked_surfaces),s=Ai(t.extension_overrides);return{mode:ki(t.mode),trustMode:Oi(t.trust_mode),pmMaxVersionExceededMode:Si(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:w(t.trusted_extensions),defaultSandboxProfile:nt(t.default_sandbox_profile),allowedExtensions:w(t.allowed_extensions),blockedExtensions:w(t.blocked_extensions),allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,allowedCommands:w(t.allowed_commands),blockedCommands:w(t.blocked_commands),allowedActions:w(t.allowed_actions),blockedActions:w(t.blocked_actions),allowedServices:w(t.allowed_services),blockedServices:w(t.blocked_services),overridesByName:s,warnings:cu({allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function Ii(e){let t=[...e.overridesByName.values()].sort((n,r)=>n.name.localeCompare(r.name)).map(n=>({name:n.name,...n.disabled?{disabled:!0}:{},...n.requireTrusted?{require_trusted:!0}:{},...n.requireProvenance?{require_provenance:!0}:{},...n.sandboxProfile?{sandbox_profile:n.sandboxProfile}:{},...n.allowedCapabilities.size>0?{allowed_capabilities:E(n.allowedCapabilities)}:{},...n.blockedCapabilities.size>0?{blocked_capabilities:E(n.blockedCapabilities)}:{},...n.allowedSurfaces.size>0?{allowed_surfaces:E(n.allowedSurfaces)}:{},...n.blockedSurfaces.size>0?{blocked_surfaces:E(n.blockedSurfaces)}:{},...n.allowedCommands.size>0?{allowed_commands:E(n.allowedCommands)}:{},...n.blockedCommands.size>0?{blocked_commands:E(n.blockedCommands)}:{},...n.allowedActions.size>0?{allowed_actions:E(n.allowedActions)}:{},...n.blockedActions.size>0?{blocked_actions:E(n.blockedActions)}:{},...n.allowedServices.size>0?{allowed_services:E(n.allowedServices)}:{},...n.blockedServices.size>0?{blocked_services:E(n.blockedServices)}:{}}));return{mode:e.mode,trust_mode:e.trustMode,pm_max_version_exceeded_mode:su(e.pmMaxVersionExceededMode),require_provenance:e.requireProvenance,trusted_extensions:E(e.trustedExtensions),default_sandbox_profile:e.defaultSandboxProfile,allowed_extensions:E(e.allowedExtensions),blocked_extensions:E(e.blockedExtensions),allowed_capabilities:E(e.allowedCapabilities),blocked_capabilities:E(e.blockedCapabilities),allowed_surfaces:E(e.allowedSurfaces),blocked_surfaces:E(e.blockedSurfaces),allowed_commands:E(e.allowedCommands),blocked_commands:E(e.blockedCommands),allowed_actions:E(e.allowedActions),blocked_actions:E(e.blockedActions),allowed_services:E(e.allowedServices),blocked_services:E(e.blockedServices),extension_overrides:t}}function Ti(e){let t=Ai(e.extension_overrides);return{mode:ki(e.mode),trustMode:Oi(e.trust_mode),pmMaxVersionExceededMode:Si(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:w(e.trusted_extensions),defaultSandboxProfile:nt(e.default_sandbox_profile),allowedExtensions:w(e.allowed_extensions),blockedExtensions:w(e.blocked_extensions),allowedCapabilities:w(e.allowed_capabilities),blockedCapabilities:w(e.blocked_capabilities),allowedSurfaces:De(e.allowed_surfaces),blockedSurfaces:De(e.blocked_surfaces),allowedCommands:w(e.allowed_commands),blockedCommands:w(e.blocked_commands),allowedActions:w(e.allowed_actions),blockedActions:w(e.blocked_actions),allowedServices:w(e.allowed_services),blockedServices:w(e.blocked_services),overridesByName:t,warnings:[]}}function re(e,t){return e.overridesByName.get(q(t))??null}function Pe(e,t,n,r,o){return t.has(n)?o:e.size>0&&!e.has(n)?r:null}function Ri(e,t,n){let r=n.trim().toLowerCase(),o=re(e,t.name),i=o&&o.allowedCapabilities.size>0?o.allowedCapabilities:e.allowedCapabilities,s=new Set([...e.blockedCapabilities,...o?o.blockedCapabilities:[]]);return Pe(i,s,r,"capability_not_allowlisted","capability_blocked")}function du(e,t,n){let r=re(e,t.name),o=r&&r.allowedSurfaces.size>0?r.allowedSurfaces:e.allowedSurfaces,i=new Set([...e.blockedSurfaces,...r?r.blockedSurfaces:[]]);return Pe(o,i,n,"surface_not_allowlisted","surface_blocked")}function lu(e,t,n){let r=S(n);if(r.length===0)return null;let o=re(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return Pe(i,s,r,"command_not_allowlisted","command_blocked")}function uu(e,t,n){let r=q(n).replace(/\s+/g,"-");if(r.length===0)return null;let o=re(e,t.name),i=o&&o.allowedActions.size>0?o.allowedActions:e.allowedActions,s=new Set([...e.blockedActions,...o?o.blockedActions:[]]);return Pe(i,s,r,"action_not_allowlisted","action_blocked")}function fu(e,t,n){let r=q(n);if(r.length===0)return null;let o=re(e,t.name),i=o&&o.allowedServices.size>0?o.allowedServices:e.allowedServices,s=new Set([...e.blockedServices,...o?o.blockedServices:[]]);return Pe(i,s,r,"service_not_allowlisted","service_blocked")}function mu(e,t){let n=q(t.name);return re(e,t.name)?.disabled===!0?"extension_override_disabled":Pe(e.allowedExtensions,e.blockedExtensions,n,"extension_not_allowlisted","extension_blocked")}function pu(e,t){if(e.trustMode==="off")return null;let n=re(e,t.name),r=q(t.name),o=t.trusted===!0,i=t.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(r)?"extension_not_trusted":(n?.requireTrusted===!0||e.trustMode==="warn"||e.trustMode==="enforce")&&!o?"extension_untrusted":(e.requireProvenance||n?.requireProvenance===!0)&&!i?"provenance_missing_or_unverified":null}function _u(e,t){if(e.mode==="off")return null;let n=re(e,t.name)?.sandboxProfile??t.sandboxProfile??e.defaultSandboxProfile;if(n==="none")return null;let r=t.permissions;if(!r)return"sandbox_permissions_missing";let o=i=>r[i]===!0;return n==="restricted"?o("process_spawn")?"sandbox_restricted_disallows_process_spawn":o("env_write")?"sandbox_restricted_disallows_env_write":null:o("process_spawn")?"sandbox_strict_disallows_process_spawn":o("network")?"sandbox_strict_disallows_network":o("fs_write")?"sandbox_strict_disallows_fs_write":o("env_write")?"sandbox_strict_disallows_env_write":null}function Bt(e,t,n,r,o={}){let i=Object.entries(o).sort((a,c)=>a[0].localeCompare(c[0])).map(([a,c])=>`${a}=${c}`).join(":"),s=i.length>0?`:${i}`:"";return`extension_policy_${e}_${t}:${n.layer}:${n.name}:reason=${r}${s}`}function xi(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let n=[],r=mu(e,t);r&&n.push({reason:r,scope:"extension",mode:e.mode});let o=pu(e,t);o&&n.push({reason:o,scope:"trust",mode:e.trustMode});let i=_u(e,t);i&&n.push({reason:i,scope:"extension",mode:e.mode});let s=n.find(c=>c.mode==="enforce");if(s)return{allowed:!1,warning:Bt("blocked",s.scope,t,s.reason)};let a=n.find(c=>c.mode==="warn");return a?{allowed:!0,warning:Bt("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function Ni(e,t,n){if(e.mode==="off")return{allowed:!0,warning:null};let r=Ri(e,t,n);return r?{allowed:e.mode==="warn",warning:Bt(e.mode==="warn"?"violation":"blocked","capability",t,r,{capability:n.trim().toLowerCase()})}:{allowed:!0,warning:null}}function gu(e,t,n,r,o){let i=typeof r=="string"?Ri(e,t,r):null,s=du(e,t,n),a=o.command?lu(e,t,o.command):null,c=o.action?uu(e,t,o.action):null,d=o.service?fu(e,t,o.service):null;return i??s??a??c??d}function yu(e,t,n,r){let o={method:q(e).replace(/\s+/g,"_"),surface:t};return n&&(o.capability=n),r.command&&(o.command=S(r.command)),r.action&&(o.action=q(r.action).replace(/\s+/g,"-")),r.service&&(o.service=q(r.service)),o}function Di(e,t,n,r,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=gu(e,t,n,o,s);if(!a)return{allowed:!0,warning:null};let c=Bt(e.mode==="warn"?"violation":"blocked","registration",t,a,yu(r,n,o,s));return{allowed:e.mode==="warn",warning:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01116a5e-62d1-591b-9fd0-84ac6e99f8d0")}catch{}})();function Vt(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function nr(){return{overrides:[],handlers:[]}}function rr(){return{overrides:[]}}function or(){return{overrides:[]}}function ir(){return{overrides:[]}}function sr(){return{overrides:[]}}function ar(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[],assurance_providers:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cd1de600-27e4-522b-842e-1993c12e9f0e")}catch{}})();var $i=100;function Pi(e,t){let n=e[t];if(n!=null)return typeof n!="string"||n.trim().length===0?null:n.trim()}function hu(e){if(e==null)return;let t=ne(e);if(!t)return null;let n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i))){if(r.trim().length===0)return null;let o=t[r];if(typeof o!="string"||o.trim().length===0)return null;n[r.trim()]=o.trim()}return Object.keys(n).length>0?n:void 0}function cr(e,t){let n=e[t];return typeof n!="string"||n.trim().length===0?null:n.trim()}function Mi(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function he(e){if(e!=null)return typeof e!="boolean"?null:e}function bu(e){let t=Mi(e.priority);return t===void 0?$i:t}function wu(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let n=nt(t);return n!==t.trim().toLowerCase()?null:n}function dr(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function vu(e){if(e==null)return;let t=ne(e);if(!t)return null;let n=dr(t.source),r=dr(t.signature),o=dr(t.attestation),i=t.verified===void 0||t.verified===null?void 0:typeof t.verified=="boolean"?t.verified:null;return i===null?null:{...n?{source:n}:{},...r?{signature:r}:{},...o?{attestation:o}:{},...typeof i=="boolean"?{verified:i}:{}}}function Eu(e){if(e==null)return;let t=ne(e);if(!t)return null;let n=he(t.fs_read),r=he(t.fs_write),o=he(t.network),i=he(t.env_read),s=he(t.env_write),a=he(t.process_spawn);return[n,r,o,i,s,a].includes(null)?null:{...typeof n=="boolean"?{fs_read:n}:{},...typeof r=="boolean"?{fs_write:r}:{},...typeof o=="boolean"?{network:o}:{},...typeof i=="boolean"?{env_read:i}:{},...typeof s=="boolean"?{env_write:s}:{},...typeof a=="boolean"?{process_spawn:a}:{}}}function ku(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(n=>typeof n!="string"))return null;let t=ii(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function Ou(e){if(e==null)return;let t=ne(e);if(!t)return null;let n=t.commands;if(n==null)return;if(!Array.isArray(n)||n.some(o=>typeof o!="string"))return null;let r=[...new Set(n.map(o=>S(o)).filter(o=>o.length>0))].sort((o,i)=>o.localeCompare(i));return r.length>0?{commands:r}:void 0}function Su(e){let t=Mi(e.manifest_version);if(t===null)return null;let n=Pi(e,"pm_min_version");if(n===null)return null;let r=Pi(e,"pm_max_version");if(r===null)return null;let o=hu(e.engines);if(o===null)return null;let i=he(e.trusted);if(i===null)return null;let s=wu(e);if(s===null)return null;let a=vu(e.provenance);if(a===null)return null;let c=Eu(e.permissions);if(c===null)return null;let d=ku(e.capabilities);if(d===null)return null;let l=Ou(e.activation);if(l===null)return null;let m=Ut(e.contributions);return m===null?null:{manifest_version:t,pm_min_version:n,pm_max_version:r,engines:o,trusted:i,sandbox_profile:s,provenance:a,permissions:c,capabilities:d.capabilities,legacy_capability_aliases:d.legacy_aliases,activation:l,contributions:m}}function lr(e){if(typeof e!="object"||e===null)return null;let t=e,n=cr(t,"name");if(n===null)return null;let r=cr(t,"version");if(r===null)return null;let o=cr(t,"entry");if(o===null)return null;let i=bu(t);if(i===null)return null;let s=Su(t);return s===null?null:{name:n,version:r,entry:o,priority:i,manifest_version:s.manifest_version,pm_min_version:s.pm_min_version,pm_max_version:s.pm_max_version,engines:s.engines,trusted:s.trusted,provenance:s.provenance,sandbox_profile:s.sandbox_profile,permissions:s.permissions,activation:s.activation,contributions:s.contributions,capabilities:s.capabilities,legacy_capability_aliases:s.legacy_capability_aliases.length>0?s.legacy_capability_aliases:void 0}}import{constants as oe}from"node:os";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="151124a3-cefa-55d3-bf4f-bd8f2553ad72")}catch{}})();var Li=new Map([["EACCES",{summary:"was denied filesystem permission",recovery:"Grant the required filesystem access, then retry.",category:"permission"}],["EDQUOT",{summary:"exceeded the filesystem quota",recovery:"Raise or reclaim the filesystem quota, then retry.",category:"capacity"}],["EMFILE",{summary:"exhausted the process file-descriptor limit",recovery:"Close unused file handles or raise the process limit, then retry.",category:"resource"}],["ENFILE",{summary:"exhausted the host file-descriptor limit",recovery:"Free host file descriptors or raise the host limit, then retry.",category:"resource"}],["ENOMEM",{summary:"ran out of available memory",recovery:"Free memory or reduce concurrent work, then retry.",category:"resource"}],["ENOSPC",{summary:"ran out of storage space",recovery:"Free storage on the filesystem holding the project, then retry.",category:"capacity"}],["EPERM",{summary:"was denied by the host permission policy",recovery:"Grant the required filesystem permission, then retry.",category:"permission"}],["EROFS",{summary:"targeted a read-only filesystem",recovery:"Use a writable project filesystem or remount it read-write, then retry.",category:"permission"}]]),Au=/^[a-z][a-z0-9_]{0,63}$/u,Cu=new Map([[oe.errno.EACCES,"EACCES"],[oe.errno.EDQUOT,"EDQUOT"],[oe.errno.EMFILE,"EMFILE"],[oe.errno.ENFILE,"ENFILE"],[oe.errno.ENOMEM,"ENOMEM"],[oe.errno.ENOSPC,"ENOSPC"],[oe.errno.EPERM,"EPERM"],[oe.errno.EROFS,"EROFS"]].filter(([e])=>Number.isInteger(e))),Iu={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function Tu(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&Li.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:Cu.get(Math.abs(t.errno))??null}function Ru(e,t,n={}){let r=Tu(e);if(r===null)return null;if(!Au.test(t))throw new h("Host environment operation labels must be bounded identifiers.",g.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=Li.get(r);return new h(`Host filesystem operation ${t} ${o.summary}.`,g.GENERIC_FAILURE,{code:n.codes?.[o.category]??Iu[o.category].code,reason:r,required:o.recovery,why:n.why??"The operating system refused a required project filesystem operation.",nextSteps:[o.recovery,...n.nextSteps??[]],...n.suggestedRetry?{recovery:{suggested_retry:n.suggestedRetry}}:{}})}async function ji(e,t,n={}){try{return await t()}catch(r){throw Ru(r,e,n)??r}}import xu from"node:fs/promises";import rt from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="029e0066-2ef5-5204-92ad-4866321710f4")}catch{}})();async function Fi(e,t){let n=rt.dirname(t.manifest_path),r=rt.relative(n,t.entry_path);if(r.startsWith("..")||rt.isAbsolute(r))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=rt.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await ji("extension_module_graph_snapshot",()=>xu.cp(n,o,{recursive:!0,force:!0})),rt.join(o,r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bf5c3834-b388-507e-a13c-3beb5d096abb")}catch{}})();function Ui(e){let t=typeof e=="function"?e:e.run;if(typeof t!="function")throw new TypeError("registerPreflight override requires a function handler");let n=[...new Set((typeof e=="function"?[]:e.commands??[]).map(r=>{if(typeof r!="string"||r.trim().length===0)throw new TypeError("registerPreflight ownership.commands must contain non-empty command paths");return S(r)}))];return{run:t,...n.length>0?{commands:n}:{}}}function zi(e){let t=[];for(let n=1;n<e.overrides.length;n+=1){let r=e.overrides[n];for(let o of e.overrides.slice(0,n))r.commands?.length&&o.commands?.length&&!o.commands.some(i=>r.commands.includes(i))||t.push(`extension_preflight_override_collision:${r.layer}:${r.name}:${o.layer}:${o.name}`)}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="47d10c23-88f8-5ba1-bcc2-458f339121a8")}catch{}})();var Gt=ko;function qi(e){let t=e.trim().toLowerCase();return Gt.includes(t)?t:null}function Bi(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=Math.max(1,Math.floor(t.length*.34));for(let r of Gt)if(Tt(t,r,n)!==null)return r;return null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="355fe619-e6f3-51d9-b88c-0b57267c25be")}catch{}})();function Vi(e){return e==="toon"||e==="json"}function Gi(e){return Te.includes(e)}function be(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var Wi=Symbol("extension_registration_trace");function H(e,t){let n=new TypeError(e);return Object.defineProperty(n,Wi,{value:t,enumerable:!1,configurable:!1,writable:!1}),n}function Ki(e){return e instanceof Error?e[Wi]:void 0}function ot(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>ot(t));if(typeof e=="function")return"[Function]";if(typeof e=="bigint"||typeof e=="symbol")return e.toString();if(typeof e=="object"){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=ot(t[r]);return n}return e}function it(e){if(Array.isArray(e))return e.map(t=>it(t));if(typeof e=="object"&&e!==null){let t=e,n={};for(let r of Object.keys(t).sort((o,i)=>o.localeCompare(i)))n[r]=it(t[r]);return n}return e}function $e(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return ot(t)}function st(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return it(t)}function at(e,t){if(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(n=>$e(e,n))}function M(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function ct(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function ur(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function fr(e,t){return S(`${e} ${t}`)}function dt(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var Nu=new Set(["low","medium","high"]),Du=new Set(["number","string_set"]),Pu=new Set(["string","number","boolean"]);function Hi(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function $u(e,t,n){let r=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=C(r,n);if(!Du.has(String(o.value_type)))throw new TypeError(`${r}.value_type must be number or string_set`);if(A(`${r}.description`,o.description),o.parameters===void 0)return;let i=C(`${r}.parameters`,o.parameters);for(let[s,a]of Object.entries(i)){let c=`${r}.parameters.${s}`;Hi(`${c}.name`,s);let d=C(c,a);if(!Pu.has(String(d.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);D(`${c}.required`,d.required),A(`${c}.description`,d.description)}if(Object.keys(i).length>50)throw new TypeError(`assurance provider ${e} key ${t} exceeds 50 parameters`)}function Yi(e){let t=C("registerAssuranceMeasurementProvider provider",e),n=Hi("registerAssuranceMeasurementProvider provider.id",t.id);if(!/^[a-z0-9][a-z0-9-]*$/u.test(n))throw new TypeError("registerAssuranceMeasurementProvider provider.id must be a stable lowercase id");if(!Nu.has(String(t.cost_class)))throw new TypeError("registerAssuranceMeasurementProvider provider.cost_class must be low, medium, or high");if(typeof t.network!="boolean")throw new TypeError("registerAssuranceMeasurementProvider provider.network must be boolean");let r=C("registerAssuranceMeasurementProvider provider.keys",t.keys);if(Object.keys(r).length===0)throw new TypeError("registerAssuranceMeasurementProvider provider.keys requires at least one key");for(let[o,i]of Object.entries(r)){if(!/^[a-z0-9][a-z0-9-]*$/u.test(o))throw new TypeError(`registerAssuranceMeasurementProvider provider key ${o} must be a stable lowercase id`);$u(n,o,i)}if(t.timeout_ms!==void 0&&(typeof t.timeout_ms!="number"||!Number.isInteger(t.timeout_ms)||t.timeout_ms<1||t.timeout_ms>3e5))throw new TypeError("registerAssuranceMeasurementProvider provider.timeout_ms must be an integer from 1 through 300000");if(typeof t.resolve!="function")throw new TypeError("registerAssuranceMeasurementProvider provider.resolve requires a function handler")}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4abca948-e9ba-52b5-b63c-a20fc344980a")}catch{}})();var Mu=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","value_validation","visible"]);function Wt(e,t){return at(e,t).map(n=>(n.repeatable===!0&&(n.list=!0),n))}function Lu(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function mr(e,t){if(t===void 0)return e.replace(/\s+/g,"-");if(typeof t!="string"||t.trim().length===0)throw new TypeError("registerCommand definition.action must be a non-empty string when provided");let n=Lu(t);if(n.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return n}function pr(e){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("registerCommand definition.arguments must be an array when provided");let t=[];for(let[r,o]of e.entries()){let i=C(`registerCommand definition.arguments[${r}]`,o),s=M(`registerCommand definition.arguments[${r}].name`,i.name);if(D(`registerCommand definition.arguments[${r}].required`,i.required),D(`registerCommand definition.arguments[${r}].variadic`,i.variadic),A(`registerCommand definition.arguments[${r}].description`,i.description),s.includes(" "))throw new TypeError(`registerCommand definition.arguments[${r}].name must not contain spaces`);let a={name:s};i.required===!0&&(a.required=!0),i.variadic===!0&&(a.variadic=!0),typeof i.description=="string"&&(a.description=i.description.trim()),t.push(a)}let n=t.map((r,o)=>r.variadic?o:-1).filter(r=>r>=0);if(n.length>1)throw new TypeError("registerCommand definition.arguments supports at most one variadic argument");if(n.length===1&&n[0]!==t.length-1)throw new TypeError("registerCommand definition.arguments variadic argument must be the final argument");return t}function Kt(e){if(!Array.isArray(e))throw new TypeError("registerFlags flags requires an array of object definitions");for(let[t,n]of e.entries()){let r=C(`registerFlags flags[${t}]`,n),o=Object.keys(r).filter(c=>!Mu.has(c)).sort((c,d)=>c.localeCompare(d));if(o.length>0)throw new TypeError(`registerFlags flags[${t}] contains unknown field(s): ${o.join(", ")}`);let i=r.long,s=r.short;if(i===void 0&&s===void 0)throw new TypeError(`registerFlags flags[${t}] requires at least one of long or short`);A(`registerFlags flags[${t}].long`,i),A(`registerFlags flags[${t}].short`,s);let a=Jo(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${Qo(a.token,a.failure)}`);if(A(`registerFlags flags[${t}].value_name`,r.value_name),A(`registerFlags flags[${t}].description`,r.description),D(`registerFlags flags[${t}].required`,r.required),D(`registerFlags flags[${t}].enabled`,r.enabled),D(`registerFlags flags[${t}].visible`,r.visible),D(`registerFlags flags[${t}].list`,r.list),D(`registerFlags flags[${t}].repeatable`,r.repeatable),r.list!==void 0&&r.repeatable!==void 0&&r.list!==r.repeatable)throw new TypeError(`registerFlags flags[${t}].list and repeatable must match when both are provided`);if(hi(`registerFlags flags[${t}].default`,r.default),Array.isArray(r.default)&&r.list!==!0&&r.repeatable!==!0)throw new TypeError(`registerFlags flags[${t}].default cannot be an array unless list is true.`);Xi(`registerFlags flags[${t}]`,r),ju(`registerFlags flags[${t}]`,r)}}function ju(e,t){if(t.value_validation===void 0)return;if(t.value_validation!=="coerce"&&t.value_validation!=="strict")throw new TypeError(`${e}.value_validation must be "coerce" or "strict" (received ${JSON.stringify(t.value_validation)}).`);if(t.value_validation!=="strict")return;let n=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0),r=n===void 0?null:zt(n);if(r!=="number"&&r!=="boolean")throw new TypeError(`${e}.value_validation "strict" requires value_type "number" or "boolean" (string values are never malformed).`)}function Xi(e,t){let n=(typeof t.value_type=="string"?t.value_type:void 0)??(typeof t.type=="string"?t.type:void 0);if(n===void 0)return;let r=zt(n);if(r===null)throw new TypeError(`${e} value_type "${n}" is not a known flag value type (expected one of: string, number, boolean).`);if(t.default===void 0)return;let o=t.list===!0||t.repeatable===!0?ei(t.default):[t.default];for(let[i,s]of o.entries())if(!ti(s,r)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${r}.`)}}function Ji(e){if(!Array.isArray(e))throw new TypeError("registerItemFields fields requires an array of object definitions");for(let[t,n]of e.entries()){let r=C(`registerItemFields fields[${t}]`,n);M(`registerItemFields fields[${t}].name`,r.name);let o=M(`registerItemFields fields[${t}].type`,r.type);if(qi(o)===null){let i=Bi(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${Gt.join(", ")}).${s}`)}D(`registerItemFields fields[${t}].optional`,r.optional)}}function Fu(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].command_option_policies`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=C(i,o);M(`${i}.command`,s.command),M(`${i}.option`,s.option),D(`${i}.enabled`,s.enabled),D(`${i}.required`,s.required),D(`${i}.visible`,s.visible)}}function Uu(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].options`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=C(i,o);M(`${i}.key`,s.key),ye(`${i}.values`,s.values),D(`${i}.required`,s.required),ye(`${i}.aliases`,s.aliases)}}function Qi(e){if(!Array.isArray(e))throw new TypeError("registerItemTypes types requires an array of object definitions");for(let[t,n]of e.entries()){let r=`registerItemTypes types[${t}]`,o=C(r,n);M(`${r}.name`,o.name),A(`${r}.folder`,o.folder),ye(`${r}.aliases`,o.aliases),ye(`${r}.required_create_fields`,o.required_create_fields),ye(`${r}.required_create_repeatables`,o.required_create_repeatables),Fu(t,o.command_option_policies),Uu(t,o.options)}}function Zi(e){let t=C("registerMigration definition",e);if(t.id!==void 0&&typeof t.id!="string")throw new TypeError("registerMigration definition.id must be a string when provided");if(t.description!==void 0&&typeof t.description!="string")throw new TypeError("registerMigration definition.description must be a string when provided");if(t.status!==void 0&&typeof t.status!="string")throw new TypeError("registerMigration definition.status must be a string when provided");if(D("registerMigration definition.mandatory",t.mandatory),t.run!==void 0&&typeof t.run!="function")throw new TypeError("registerMigration definition.run must be a function when provided")}var es=["types","statuses","fields","workflows","config","templates","packages"],zu={types:(e,t)=>{if(t.name!==void 0&&typeof t.name!="string")throw new TypeError(`${e}.name must be a string when provided`)},workflows:(e,t)=>{if(typeof t.type!="string")throw new TypeError(`${e}.type must be a string`);if(!Array.isArray(t.allowed_transitions))throw new TypeError(`${e}.allowed_transitions must be an array`);for(let[n,r]of t.allowed_transitions.entries())if(!Array.isArray(r))throw new TypeError(`${e}.allowed_transitions[${n}] must be a [from, to] array`)},templates:(e,t)=>{if(typeof t.name!="string")throw new TypeError(`${e}.name must be a string`);if(typeof t.options!="object"||t.options===null||Array.isArray(t.options))throw new TypeError(`${e}.options must be an object`)},packages:(e,t)=>{if(typeof t.spec!="string")throw new TypeError(`${e}.spec must be a string`)}};function ts(e){let t=C("registerProfile profile",e);if(M("registerProfile profile.name",t.name),M("registerProfile profile.title",t.title),t.summary!==void 0&&typeof t.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let n of es){let r=t[n];if(r!==void 0){if(!Array.isArray(r))throw new TypeError(`registerProfile profile.${n} must be an array when provided`);for(let[o,i]of r.entries()){if(typeof i!="object"||i===null||Array.isArray(i))throw new TypeError(`registerProfile profile.${n}[${o}] must be an object`);zu[n]?.(`registerProfile profile.${n}[${o}]`,i)}}}}function ns(e){e.summary===void 0&&(e.summary="");for(let t of es)e[t]===void 0&&(e[t]=[]);return e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="45ff820c-32af-5bdb-a570-3059684129ce")}catch{}})();function rs(e){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("registerService ownership must be an object");if(Reflect.ownKeys(e).some(t=>t!=="passThrough"))throw new TypeError("registerService ownership supports only passThrough");if(e.passThrough!==void 0&&typeof e.passThrough!="boolean")throw new TypeError("registerService ownership.passThrough must be a boolean when provided");return e.passThrough===!0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b5de5028-f981-599b-8d11-0fc7b07beda4")}catch{}})();function os(e){return typeof e=="string"?e:String(e)}function lt(e){let t=e.trim().replace(/^>=\s*/,"").replace(/^v/i,"").split(/[+-]/,1)[0];return/^\d+(?:[.-]\d+)*$/.test(t)?t.split(/[.-]/).map(n=>Number(n)):null}function _r(e,t){let n=lt(e),r=lt(t);if(!n||!r)return null;let o=Math.max(n.length,r.length);for(let i=0;i<o;i+=1){let s=n[i]??0,a=r[i]??0;if(s>a)return 1;if(s<a)return-1}return 0}function is(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let n=os(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(!lt(n))return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(t===null)return{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:null};let r=_r(t,n);return r===null?{kind:"pm_min_version",status:"unchecked",allowed:!0,required:n,current:t}:r<0?{kind:"pm_min_version",status:"unmet",allowed:!1,required:n,current:t}:{kind:"pm_min_version",status:"ok",allowed:!0,required:n,current:t}}function ss(e,t,n){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let r=os(e);if(typeof e!="string"||r.trim().length===0)return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(/^[<>=~^]/.test(r.trim())||!lt(r))return{kind:"pm_max_version",status:"invalid",allowed:!1,required:r,current:t};if(t===null)return{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:null};let o=_r(t,r);return o===null?{kind:"pm_max_version",status:"unchecked",allowed:!0,required:r,current:t}:o>0?n==="warn"?{kind:"pm_max_version",status:"exceeded_warn",allowed:!0,required:r,current:t}:{kind:"pm_max_version",status:"exceeded",allowed:!1,required:r,current:t}:{kind:"pm_max_version",status:"ok",allowed:!0,required:r,current:t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3a15b0ff-f638-5368-95a7-0d5d9abb3f21")}catch{}})();var qu=5e3;async function gr(e,t,n){let r=[];for(let o of e)try{await o.run($(n))}catch{r.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return r}function Bu(e,t,n){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new h(`Extension mutation guard ${t.name} returned an invalid decision.`,g.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${t.layer}:${t.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let r=e,o=typeof r.code=="string"?r.code.trim():"",i=typeof r.remediation=="string"?r.remediation.trim():"";if(o.length===0||i.length===0)throw new h(`Extension mutation guard ${t.name} returned an invalid denial.`,g.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${t.layer}:${t.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof r.message=="string"?r.message.trim():"";throw new h(s||`Extension mutation guard ${t.name} denied ${n}.`,g.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function yr(e,t){for(let n of e.beforeMutation??[]){let r,o;try{let i=Promise.resolve().then(()=>n.run({pm_root:t.pm_root,operation:t.operation,before:t.before===null?null:$(t.before),after:t.after===null?null:$(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),r=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new h(`Extension mutation guard ${n.name} timed out before ${t.operation}.`,g.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},qu),o.unref?.()})])}catch(i){throw i instanceof h?i:new h(`Extension mutation guard ${n.name} failed before ${t.operation}.`,g.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(o)}Bu(r,n,t.operation)}}async function hr(e,t){return gr(e.onWrite,"onWrite",t)}async function br(e,t){return gr(e.onRead,"onRead",t)}async function wr(e,t){return gr(e.onIndex,"onIndex",t)}function Vu(e){let t="";e instanceof Error&&typeof e.message=="string"?t=e.message:typeof e=="string"?t=e:typeof e=="object"&&e!==null&&typeof e.message=="string"&&(t=e.message);let n=t.replace(/\s+/gu," ").trim();if(n.length===0)return"";let r=300;return n.length>r?`${n.slice(0,r-1)}\u2026`:n}function Ht(e,t){if(typeof e!="object"||e===null||typeof e[t]!="string")return;let n=String(e[t]).replace(/\s+/gu," ").trim();return n.length>0?n.slice(0,300):void 0}function Gu(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"exit_code"))return;let t=e.exit_code;if(typeof t!="number"||!Number.isInteger(t)||t<1||t>255)throw new TypeError("Extension command result exit_code must be an integer from 1 to 255.");return t}async function vr(e,t){let n=S(t.command);if(n.length===0)return{handled:!1,result:null,warnings:[]};let r=[...e.handlers].reverse().find(o=>o.command===n);if(!r)return{handled:!1,result:null,warnings:[]};try{let o=await r.run({command:n,args:$(t.args),options:$(t.options),global:$(t.global),pm_root:t.pm_root,source_workspace_root:t.source_workspace_root,repo_root:t.repo_root,pm_root_rel:t.pm_root_rel,...t.sdk===void 0?{}:{sdk:t.sdk}});return{handled:!0,result:o,warnings:[],...Object.fromEntries([["exitCode",Gu(o)],["errorCode",Ht(o,"code")],["remediation",Ht(o,"remediation")]].filter(i=>i[1]!==void 0))}}catch(o){let i=typeof o=="object"&&o!==null&&"exitCode"in o?o.exitCode:void 0;if(typeof i=="number"&&Number.isFinite(i))throw o;return Object.defineProperty({handled:!1,result:null,warnings:[`extension_command_handler_failed:${r.layer}:${r.name}:${r.command}`],errorMessage:Vu(o),...Object.fromEntries([["errorCode",Ht(o,"code")],["remediation",Ht(o,"remediation")]].filter(s=>s[1]!==void 0))},"cause",{value:o,configurable:!0})}}function as(e){return{handled:!1,result:e.payload,warnings:[]}}function cs(e,t){return[...e.overrides].reverse().filter(n=>n.service===t)}function ds(e){return{service:e.service,command:e.command?S(e.command):void 0,args:e.args?$(e.args):void 0,options:e.options?Ho(e.options):void 0,global:e.global?Yo(e.global):void 0,pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,payload:$(e.payload)}}function Wu(e){if(typeof e!="object"||e===null||!Object.hasOwn(e,"handled"))return!1;let t=e.handled;return t===!0?Object.hasOwn(e,"result"):t===!1&&Reflect.ownKeys(e).length===1}function ls(e,t){return Wu(e)?e.handled?{handled:!0,result:e.result}:{handled:!1,result:t.payload}:t.service==="output_format"&&e==null?{handled:!1,result:t.payload}:{handled:!0,result:e}}function us(e,t,n){return t.service==="output_format"&&typeof e=="object"&&e!==null&&V(e,n.payload)}function fs(e,t,n){if(t.handled){if(e.passThrough===!0){n.push(`extension_service_pass_through_contract_violated:${e.layer}:${e.name}:${e.service}`);return}return{handled:!0,result:t.result,warnings:n}}}function Er(e,t){let n=cs(e,t.service);if(n.length===0)return as(t);let r=[];for(let o of n)try{let i=ds(t),s=o.run(i);if(s instanceof Promise){r.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(us(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=fs(o,ls(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}async function kr(e,t){let n=cs(e,t.service);if(n.length===0)return as(t);let r=[];for(let o of n)try{let i=ds(t),s=await Promise.resolve(o.run(i));if(us(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=fs(o,ls(s,t),r);if(a)return a}catch{r.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:t.payload,warnings:r}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3abe36f7-3c97-58d2-a56d-b4e0ea958461")}catch{}})();var ms=null,Qu=Object.freeze(vo()),ps=0;function Zu(e=Date.now()){return ps+=1,`${ps}-${e}`}function ef(e,t,n){return n.has(e)?!1:t.size===0?!0:t.has(e)}async function tf(e,t){let[n,r]=await Promise.all([ve.realpath(e),ve.realpath(t)]);return et(n,r)}function nf(e,t=process.cwd()){return{global:we.join(zo(t),"extensions"),project:we.join(e,"extensions")}}async function rf(e){try{return(await ve.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,n)=>t.localeCompare(n))}catch{return[]}}function of(e){let t={layer:e.layer,directory:e.directory,manifest_path:e.manifest_path,name:e.manifest.name,version:e.manifest.version,entry:e.manifest.entry,priority:e.manifest.priority,entry_path:e.entry_path,manifest_version:e.manifest.manifest_version,pm_min_version:e.manifest.pm_min_version,pm_max_version:e.manifest.pm_max_version,engines:e.manifest.engines,trusted:e.manifest.trusted,provenance:e.manifest.provenance,sandbox_profile:e.manifest.sandbox_profile,permissions:e.manifest.permissions,capabilities:[...e.manifest.capabilities],activation:e.manifest.activation?{commands:[...e.manifest.activation.commands]}:void 0,contributions:e.manifest.contributions??e.contributions};return e.source_package&&(t.source_package=e.source_package),e.source_aliases&&(t.source_aliases=[...e.source_aliases]),t}function _s(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function sf(e){let t=new Map;try{let n=JSON.parse(await ve.readFile(we.join(e,".managed-extensions.json"),"utf8")),r=ne(n)?.entries;if(!Array.isArray(r))return t;for(let o of r){if(typeof o!="object"||o===null)continue;let i=o,s=_s(i.source?.package),a=[i.source?.input,i.source?.name,s].map(l=>_s(l)).filter(l=>l!==void 0),c=Ut(i.contributions),d={aliases:[...new Set(a)],...s?{package_name:s}:{},...c?{contributions:c}:{}};typeof i.directory=="string"&&i.directory.trim().length>0&&t.set(`directory:${i.directory.trim()}`,d),typeof i.name=="string"&&i.name.trim().length>0&&t.set(`name:${i.name.trim()}`,d)}}catch{return t}return t}function gs(e){return[...e].sort((t,n)=>{if(t.manifest.priority!==n.manifest.priority)return t.manifest.priority-n.manifest.priority;let r=t.manifest.name.localeCompare(n.manifest.name);return r!==0?r:t.directory.localeCompare(n.directory)})}function af(e,t){let n=[...gs(e),...gs(t)],r=[];for(let o of n){let i=r.findIndex(s=>s.manifest.name===o.manifest.name);i>=0&&r.splice(i,1),r.push(o)}return r}async function ys(e,t,n,r,o){let i=[],s=[],a=[],c=await rf(t),d=await sf(t);for(let l of c){let m=await lf(e,t,l,n,r,d,o);i.push(m.diagnostic),s.push(...m.warnings),m.candidate&&a.push(m.candidate)}return{diagnostics:i,warnings:s,candidates:a}}function cf(){return{diagnostics:[],warnings:[],candidates:[]}}function hs(e,t,n,r){return{diagnostic:{layer:e,directory:t,manifest_path:n,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[r],candidate:null}}function df(e,t,n,r,o,i,s,a){let c=Oo(e,t,n);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&c.push(ai(e,t.name,t.legacy_capability_aliases));for(let d of oi(t.capabilities))c.push(si(e,t.name,d));return r?o||c.push(`extension_entry_missing:${e}:${t.name}`):c.push(`extension_entry_outside_extension:${e}:${t.name}`),i.warning&&c.push(a?i.warning:i.warning.replace("extension_pm_","extension_disabled_pm_")),s.warning&&c.push(a?s.warning:s.warning.replace("extension_pm_","extension_disabled_pm_")),c}async function lf(e,t,n,r,o,i,s){let a=we.join(t,n),c=we.join(a,"manifest.json");if(!await xn(c))return hs(e,n,c,`extension_manifest_missing:${e}:${n}`);let d,l;try{let Ie=JSON.parse(await ve.readFile(c,"utf8"));l=ne(Ie),d=lr(Ie)}catch{l=null,d=null}if(!d||!l)return hs(e,n,c,`extension_manifest_invalid:${e}:${n}`);let m=we.resolve(a,d.entry),u=et(a,m),f=u?await xn(m):!1,p=u&&f?await tf(a,m):u,_=ef(d.name,r,o),y=await mf(e,d),b=await pf(e,d,s),k=df(e,d,l,p,f,y,b,_),U=p&&f&&y.allowed&&b.allowed,Q=i.get(`directory:${n}`)??i.get(`name:${d.name}`);return{diagnostic:{layer:e,directory:n,manifest_path:c,name:d.name,version:d.version,entry:d.entry,priority:d.priority,entry_path:m,enabled:_,status:U?"ok":"warn"},warnings:k,candidate:Ei({layer:e,directory:n,manifestPath:c,entryPath:m,manifest:d,sourceIdentity:Q,extensionReady:U,enabledForLoad:_})}}async function uf(e){let t=nf(e.pmRoot,e.cwd??process.cwd()),n=Ze(e.settings.extensions.enabled),r=Ze(e.settings.extensions.disabled),o=Ci(e.settings),i=Ii(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:n,configured_disabled:r,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(n),a=new Set(r),c=e.ignoreGlobalExtensions===!0?cf():await ys("global",t.global,s,a,o.pmMaxVersionExceededMode.global),d=await ys("project",t.project,s,a,o.pmMaxVersionExceededMode.project),l=[...o.warnings],m=af(c.candidates,d.candidates),u=[];for(let f of m){let p={layer:f.layer,name:f.manifest.name,trusted:f.manifest.trusted===!0,provenanceVerified:f.manifest.provenance?.verified===!0,sandboxProfile:f.manifest.sandbox_profile,permissions:f.manifest.permissions&&typeof f.manifest.permissions=="object"?{fs_read:f.manifest.permissions.fs_read,fs_write:f.manifest.permissions.fs_write,network:f.manifest.permissions.network,env_read:f.manifest.permissions.env_read,env_write:f.manifest.permissions.env_write,process_spawn:f.manifest.permissions.process_spawn}:void 0},_=xi(o,p);if(_.warning&&l.push(_.warning),!!_.allowed){for(let y of f.manifest.capabilities){let b=Ni(o,p,y);b.warning&&l.push(b.warning)}u.push(of(f))}}return{disabled_by_flag:!1,roots:t,configured_enabled:n,configured_disabled:r,discovered:[...c.diagnostics,...d.diagnostics],effective:u,warnings:[...new Set([...c.warnings,...d.warnings,...l])],policy:i}}function Yt(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function ff(){try{let e=Qn(import.meta.url,["../../.."]),t=await ve.readFile(we.join(e,"package.json"),"utf8"),n=JSON.parse(t);return typeof n.version=="string"&&n.version.trim().length>0?n.version.trim():null}catch{return null}}function vs(){return ms??=ff(),ms}function Es(e,t,n){let r=n.current??"unknown";if(n.kind==="pm_min_version")switch(n.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${t.name}:required=${n.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${t.name}:required=${n.required}:current=${r}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${t.name}:required=${n.required}:current=${r}`;default:return}switch(n.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${t.name}:allowed=${n.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${t.name}:allowed=${n.required}:current=${r}`;default:return}}async function mf(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let n=is(t.pm_min_version,await vs()),r=Es(e,t,n);return r?{allowed:n.allowed,warning:r}:{allowed:n.allowed}}async function pf(e,t,n){if(t.pm_max_version===void 0)return{allowed:!0};let r=ss(t.pm_max_version,await vs(),n),o=Es(e,t,r);return o?{allowed:r.allowed,warning:o}:{allowed:r.allowed}}async function bs(e){try{let t=await ve.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function _f(e,t){let n=e.entry_path;t.module_graph_snapshot_root&&(n=await Fi(t.module_graph_snapshot_root,e));let r=new URL(Ju(n).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return r.href;let[o,i]=await Promise.all([bs(e.entry_path),bs(e.manifest_path)]),s=t.reload_token??Zu();return r.searchParams.set("pm_ext_reload",s),r.searchParams.set("pm_ext_entry",o),r.searchParams.set("pm_ext_manifest",i),r.href}async function rv(e){let t=await uf(e),n=[],r=[],o=[...t.warnings];if(t.disabled_by_flag)return{...t,warnings:o,loaded:n,failed:r};let i=typeof e.extensionFilter=="function"?t.effective.filter(e.extensionFilter):t.effective;for(let s of i)try{let a=await import(await _f(s,e));n.push({...s,module:a})}catch(a){o.push(`extension_load_failed:${s.layer}:${s.name}`),r.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:Yt(a)})}return{...t,warnings:o,loaded:n,failed:r}}var ws=5e3,gf=2147483647;function yf(e){let t={activate:e.activate.bind(e)};if(typeof e.deactivate=="function"){let n=e.deactivate;t.deactivate=n.bind(e)}return t}function ks(e){let t=gi(e);return t?yf(t):null}async function ov(e,t,n={}){let r=hf(n?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(l=>`${l.layer}:${l.name}`)),i=[];for(let l of e.loaded){if(o.has(`${l.layer}:${l.name}`))continue;let m=ks(l.module);!m||typeof m.deactivate!="function"||i.push({extension:l,deactivate:m.deactivate})}let s=await Promise.all(i.map(async({extension:l,deactivate:m})=>{try{return await bf(m,r),{ok:!0}}catch(u){return{ok:!1,layer:l.layer,name:l.name,error:Yt(u)}}})),a=[],c=[],d=0;for(let l of s){if(l.ok){d+=1;continue}a.push(`extension_deactivate_failed:${l.layer}:${l.name}`),c.push({layer:l.layer,name:l.name,error:l.error})}return{deactivated:d,warnings:a,failed:c}}function hf(e){return typeof e!="number"||e<0?ws:e===0||e===1/0?0:Number.isFinite(e)?Math.min(gf,Math.max(1,Math.floor(e))):ws}async function bf(e,t){if(t===0){await e();return}let n;try{let r=Promise.resolve().then(()=>e());r.catch(()=>{}),await Promise.race([r,new Promise((o,i)=>{n=setTimeout(()=>{i(new Error(`extension deactivate timed out after ${t}ms`))},t),n.unref?.()})])}finally{clearTimeout(n)}}function wf(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let n of e.capabilities){let r=n.trim().toLowerCase();ee(r)&&t.add(r)}return t}function O(e,t,n){let r=wf(e);if(r!==null&&!r.has(t))throw H(`${n} requires capability '${t}' in extension manifest capabilities`,{method:n,registration_index:-1,capability:t,missing_capability:t,expected_schema:`"capabilities": [..., "${t}"]`,received:e.capabilities,hint:`Add "${t}" to ${e.name} manifest capabilities, or remove the ${n} registration call.`})}function vf(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>W.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function Ef(e){return{layer:e.layer,name:e.name,trusted:e.trusted===!0,provenanceVerified:e.provenance?.verified===!0,sandboxProfile:e.sandbox_profile,permissions:e.permissions&&typeof e.permissions=="object"?{fs_read:e.permissions.fs_read,fs_write:e.permissions.fs_write,network:e.permissions.network,env_read:e.permissions.env_read,env_write:e.permissions.env_write,process_spawn:e.permissions.process_spawn}:void 0}}var Or=class{extension;hooks;#e;#n;#o;#r;#s;#a;#i;#c;#t;#d;#l;#u;constructor(t,n,r,o,i,s,a,c,d,l,m){this.#e=t,this.extension=vf(t),this.#n=Ef(t),this.#o=n,this.#r=r,this.#s=o,this.#a=i,this.#i=s,this.#c=a,this.#t=c,this.#d=d,this.#l=l,this.#u=m,this.registerCommand=this.registerCommand.bind(this),this.registerParser=this.registerParser.bind(this),this.registerPreflight=this.registerPreflight.bind(this),this.registerService=this.registerService.bind(this),this.registerFlags=this.registerFlags.bind(this),this.registerItemFields=this.registerItemFields.bind(this),this.registerItemTypes=this.registerItemTypes.bind(this),this.registerRelationshipKinds=this.registerRelationshipKinds.bind(this),this.registerMigration=this.registerMigration.bind(this),this.registerProfile=this.registerProfile.bind(this),this.registerRenderer=this.registerRenderer.bind(this),this.registerImporter=this.registerImporter.bind(this),this.registerExporter=this.registerExporter.bind(this),this.registerSearchProvider=this.registerSearchProvider.bind(this),this.registerVectorStoreAdapter=this.registerVectorStoreAdapter.bind(this),this.registerAssuranceMeasurementProvider=this.registerAssuranceMeasurementProvider.bind(this),this.hooks={beforeCommand:u=>this.registerBeforeCommand(u),beforeMutation:u=>this.registerBeforeMutation(u),afterCommand:u=>this.registerAfterCommand(u),onWrite:u=>this.registerOnWrite(u),onRead:u=>this.registerOnRead(u),onIndex:u=>this.registerOnIndex(u)}}allowRegistration(t,n,r,o){let i=Di(this.#u,this.#n,t,n,r,o);return i.warning&&this.#d.push(i.warning),i.allowed}registerCommandTrace(t,n,r,o,i){return{method:"registerCommand",registration_index:t==="override"?this.#r.overrides.length:this.#r.handlers.length,command:n,expected_schema:r,received:ot(o),hint:i}}registerCommandOverride(t,n){let r=S(t);if(r.length===0)throw H("registerCommand requires a non-empty command name",this.registerCommandTrace("override",t,'registerCommand("<command>", (context) => unknown)',t,"Provide a non-empty command path as the first argument."));if(typeof n!="function"){let o=this.registerCommandTrace("override",r,'registerCommand("<command>", (context) => unknown)',n,"Provide a function as the second registerCommand argument.");throw H(`registerCommand requires an override function when command name is provided (command="${r}", registration_index=${o.registration_index})`,o)}this.allowRegistration("commands.override","registerCommand","commands",{command:r})&&this.#r.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}resolveCommandDefinitionRunHandler(t,n){let r=typeof t.run=="function"?t.run:void 0,o=typeof t.handler=="function"?t.handler:void 0;return!r&&o&&this.#d.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${n}`),r??o}registerCommandDefinition(t){if(typeof t!="object"||t===null)throw H("registerCommand requires a command definition object",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,'Use registerCommand({ name: "command path", run: (context) => ... }).'));if(typeof t.name!="string")throw H("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",t,"Set command definition.name to a non-empty string command path."));let n=S(t.name);if(n.length===0)throw H("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",t.name,"{ name: string; run: (context) => unknown; }",t,"Ensure command definition.name contains a non-empty command path."));let r=this.resolveCommandDefinitionRunHandler(t,n);if(typeof r!="function"){let o=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; }",r,"Define command definition.run as a function.");throw H(`registerCommand requires a command definition run handler (command="${n}", registration_index=${o.registration_index})`,o)}try{bi(t);let o=mr(n,t.action),i=wi(t.read_output,n,o);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:n,action:o}))return;let s=t.description?.trim(),a=t.intent?.trim(),c=tt("registerCommand definition.examples",t.examples),d=tt("registerCommand definition.failure_hints",t.failure_hints),l=pr(t.arguments);t.flags!==void 0&&(O(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(Kt(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Wt("registerCommand definition.flags",t.flags)})));let m={source_version:this.#e.version,read_output:i,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:o,examples:c,failure_hints:d,arguments:l,tier:t.tier??"standard",family:t.family??"extensions"};s&&(m.description=s),a&&(m.intent=a),this.#t.commands.push(m)}catch(o){let i=Yt(o),s=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=H(`registerCommand definition metadata invalid (command="${n}", registration_index=${s.registration_index}): ${i}`,s);this.#d.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${n}`),this.#l.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:n,run:r})}registerCommand(t,n){if(O(this.#e,"commands","registerCommand"),typeof t=="string"){this.registerCommandOverride(t,n);return}this.registerCommandDefinition(t)}registerParser(t,n){if(O(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;let r=S(M("registerParser command",t));ct("registerParser override",n),this.#s.overrides.push({layer:this.#e.layer,name:this.#e.name,command:r,run:n})}registerPreflight(t){if(O(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;let n=Ui(t);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...n})}registerService(t,n,r={}){O(this.#e,"services","registerService");let o=String(t).trim().toLowerCase();if(!Gi(o))throw new TypeError(`registerService service must be one of: ${Te.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(ct("registerService override",n),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:n,...rs(r)?{passThrough:!0}:{}}))}registerRenderer(t,n,r={}){if(O(this.#e,"renderers","registerRenderer"),!this.allowRegistration("renderers.override","registerRenderer","renderers"))return;if(typeof n!="function")throw new TypeError("registerRenderer requires a renderer function");let o=String(t).trim().toLowerCase();if(!Vi(o))throw new Error(`registerRenderer format must be toon|json, received: ${String(t)}`);if(r.resultDiscriminator!==void 0&&typeof r.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");let i=[...new Set((r.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return S(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:o,run:n,commands:i,...r.resultDiscriminator?{resultDiscriminator:r.resultDiscriminator}:{}})}registerFlags(t,n){if(O(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;let r=S(M("registerFlags targetCommand",t));Kt(n);let o=Wt("registerFlags flags",n);if(o.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:r,flags:o})}registerItemFields(t){if(O(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;Ji(t);let n=at("registerItemFields fields",t);if(n.length===0)throw new TypeError("registerItemFields requires at least one field definition");this.#t.item_fields.push({layer:this.#e.layer,name:this.#e.name,fields:n})}registerItemTypes(t){if(O(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;Qi(t);let n=at("registerItemTypes types",t);if(n.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#t.item_types.push({layer:this.#e.layer,name:this.#e.name,types:n})}registerRelationshipKinds(t){if(O(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(t))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(t.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");let n=Ln();for(let o of this.#t.relationship_kinds)for(let i of o.definitions)n.register(i);let r=t.map(o=>(n.register(o),n.require(o.kind)));this.#t.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:r})}registerMigration(t){if(O(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;Zi(t);let n=st("registerMigration definition",t);this.#t.migrations.push(dt({layer:this.#e.layer,name:this.#e.name,definition:$e("registerMigration definition",t)},n))}registerProfile(t){if(O(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let n=it(t);ts(n),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:ns(n)})}registerImportExportCommandFlags(t,n,r){r.flags!==void 0&&(O(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(Kt(r.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Wt(`${t} options.flags`,r.flags)})))}applyImportExportCommandMetadata(t,n,r){if(r!==void 0&&(typeof r!="object"||r===null||Array.isArray(r)))throw new TypeError(`${t} options must be an object when provided`);let o=`${t==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,i=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...r,description:r?.description??o,arguments:r?.arguments??i},a=vi(t,s,r?.description!==void 0);A(`${t} options.action`,s.action),A(`${t} options.description`,s.description),A(`${t} options.intent`,s.intent);let c=mr(n,s.action),d=tt(`${t} options.examples`,s.examples),l=tt(`${t} options.failure_hints`,s.failure_hints),m=pr(s.arguments);this.registerImportExportCommandFlags(t,n,s);let u={source_version:this.#e.version,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:n,action:c,examples:d,failure_hints:l,arguments:m},f=s.description?.trim();f&&(u.description=f);let p=s.intent?.trim();return p&&(u.intent=p),this.#t.commands.push(u),a}registerImporter(t,n,r){if(O(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;let o=ur(M("registerImporter name",t));ct("registerImporter importer",n);let i=fr(o,"import");this.applyImportExportCommandMetadata("registerImporter",i,r),this.#t.importers.push({layer:this.#e.layer,name:this.#e.name,importer:o}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async s=>n(er(s,o,"import"))})}registerExporter(t,n,r){if(O(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=ur(M("registerExporter name",t));ct("registerExporter exporter",n);let i=fr(o,"export"),s=this.applyImportExportCommandMetadata("registerExporter",i,r);this.#t.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:o,...s===void 0?{}:{output:s}}),this.#r.handlers.push({layer:this.#e.layer,name:this.#e.name,command:i,run:async a=>{let c=await n(er(a,o,"export"));return s?.receipt==="suppress"&&!Jn(c)?fi(c):c}})}registerSearchProvider(t){if(O(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let n=st("registerSearchProvider provider",t);this.#t.search_providers.push(dt({layer:this.#e.layer,name:this.#e.name,definition:$e("registerSearchProvider provider",t)},n))}registerVectorStoreAdapter(t){if(O(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let n=st("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(dt({layer:this.#e.layer,name:this.#e.name,definition:$e("registerVectorStoreAdapter adapter",t)},n))}registerAssuranceMeasurementProvider(t){if(O(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(Yi(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let n=st("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(dt({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:$e("registerAssuranceMeasurementProvider provider",t)},n))}registerBeforeCommand(t){O(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(be("beforeCommand",t),this.#o.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerBeforeMutation(t){O(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(be("beforeMutation",t),this.#o.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerAfterCommand(t){O(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(be("afterCommand",t),this.#o.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnWrite(t){O(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(be("onWrite",t),this.#o.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnRead(t){O(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(be("onRead",t),this.#o.onRead.push({layer:this.#e.layer,name:this.#e.name,run:t}))}registerOnIndex(t){O(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(be("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function kf(e,t,n,r,o,i,s,a,c,d,l){return new Or(e,t,n,r,o,i,s,a,c,d,l)}function Of(e){let t=e.commands.length,n=e.flags.reduce((s,a)=>s+a.flags.length,0),r=e.item_fields.reduce((s,a)=>s+a.fields.length,0),o=e.item_types.reduce((s,a)=>s+a.types.length,0),i=(e.relationship_kinds??[]).reduce((s,a)=>s+a.definitions.length,0);return{commands:t,flags:n,item_fields:r,item_types:o,...i>0?{relationship_kinds:i}:{},migrations:e.migrations.length,profiles:e.profiles.length,importers:e.importers.length,exporters:e.exporters.length,search_providers:e.search_providers.length,vector_store_adapters:e.vector_store_adapters.length,...(e.assurance_providers?.length??0)>0?{assurance_providers:e.assurance_providers.length}:{}}}function Sf(e){let t=[],n=(i,s)=>{let a=new Map;for(let c of i){let d=a.get(c.command)??[];d.push(c),a.set(c.command,d)}for(let c of[...a.keys()].sort((d,l)=>d.localeCompare(l))){let d=a.get(c);if(d.length<=1)continue;let l=d[d.length-1];for(let m of d.slice(0,-1))t.push(`${s}:${c}:${l.layer}:${l.name}:${m.layer}:${m.name}`)}};n(e.handlers,"extension_command_handler_collision"),n(e.overrides,"extension_command_override_collision");let r=new Set(e.handlers.map(i=>i.command)),o=[...new Set(e.overrides.map(i=>i.command))].filter(i=>r.has(i));o.sort((i,s)=>i.localeCompare(s));for(let i of o){let s=e.handlers.filter(c=>c.command===i),a=e.overrides.filter(c=>c.command===i);for(let c of a)for(let d of s)t.push(`extension_command_override_handler_overlap:${i}:${c.layer}:${c.name}:${d.layer}:${d.name}`)}return t}function Af(e){let t=new Map;for(let r of e.overrides){let o=t.get(r.format)??[];o.push(r),t.set(r.format,o)}let n=[];for(let r of[...t.keys()].sort((o,i)=>o.localeCompare(i))){let o=t.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))i.commands?.length&&s.commands?.length&&!s.commands.some(a=>i.commands?.includes(a))||n.push(`extension_renderer_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return n}function Cf(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.command)??[];o.push(r),n.set(r.command,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1)continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_parser_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}var If=new Set(["output_format"]);function Tf(e){let t=[],n=new Map;for(let r of e.overrides){let o=n.get(r.service)??[];o.push(r),n.set(r.service,o)}for(let r of[...n.keys()].sort((o,i)=>o.localeCompare(i))){let o=n.get(r);if(o.length<=1||If.has(r))continue;let i=o[o.length-1];for(let s of o.slice(0,-1))t.push(`extension_service_override_collision:${r}:${i.layer}:${i.name}:${s.layer}:${s.name}`)}return t}async function iv(e){let t=Ti(e.policy??Qu),n=Vt(),r=nr(),o=rr(),i=or(),s=ir(),a=sr(),c=ar(),d=[],l=[];for(let f of e.loaded){let p=ks(f.module);if(!p)continue;let _=d.length,y=yi({hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await p.activate(kf(f,n,r,o,i,s,a,c,l,d,t)),d.length>_&&(y(),l.push(`extension_activation_rolled_back:${f.layer}:${f.name}`))}catch(b){y(),l.push(`extension_activate_failed:${f.layer}:${f.name}`);let k=Ki(b);d.push({layer:f.layer,name:f.name,entry_path:f.entry_path,error:Yt(b),trace:k})}}let m=[...Sf(r),...Cf(o),...zi(i),...Tf(s),...Af(a)],u=[...new Set([...l,...m])];return{hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c,failed:d,warnings:u,hook_counts:{before_command:n.beforeCommand.length,before_mutation:n.beforeMutation.length,after_command:n.afterCommand.length,on_write:n.onWrite.length,on_read:n.onRead.length,on_index:n.onIndex.length},command_override_count:r.overrides.length,command_handler_count:r.handlers.length,parser_override_count:o.overrides.length,preflight_override_count:i.overrides.length,service_override_count:s.overrides.length,renderer_override_count:a.overrides.length,registration_counts:Of(c)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b1a38f8c-8f65-59e2-bddf-ed0606a0f0b5")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4da25248-2914-5bc5-aa42-87f677ef4ea8")}catch{}})();function lv(){let e=Promise.resolve(),t=new Set;return{async read(n){let r=e,o,i=new Promise(s=>{o=s});t.add(i),await r;try{return await n()}finally{t.delete(i),o()}},write(n){let r=Promise.all([e,...t]).then(()=>n());return e=r.then(()=>{},()=>{}),r}}}function Rf(){let e=Promise.resolve(),t=0,n=[],r=()=>{if(t!==0)return;let o=n.splice(0);for(let i of o)i()};return{enqueue(o){t++;let i=e.then(()=>o());return e=i.then(()=>{},()=>{}).finally(()=>{t--,r()}),i},idle(){return t===0?Promise.resolve():new Promise(o=>n.push(o))}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7c2e7a35-cbf9-5bb6-abfd-f1ae75c6afc2")}catch{}})();var Me=null,Ss=null,Df=null,Pf=null,Sr=null,$f=null,As=null,Cs=null;var Mf=[],Is=new Nf;function I(){return Is.getStore()}function gv(e){return Is.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var Lf=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function Os(e){let t=Y.resolve(e);for(;;){if(xf(Y.join(t,".git")))return t;let n=Y.dirname(t);if(n===t)return;t=n}}function jf(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),n=Os(t)??Y.resolve(t),r=Os(n);if(!e)return{source_workspace_root:n,...r?{repo_root:r}:{}};let o=Y.relative(n,Y.resolve(e)),i=o.length>0&&!o.startsWith(`..${Y.sep}`)&&o!==".."&&!Y.isAbsolute(o);return{source_workspace_root:n,...r?{repo_root:r}:{},...i?{pm_root_rel:o.split(Y.sep).join("/")}:{}}}function yv(e){let t=I();if(t){t.hooks=e;return}Me=e}function hv(e){let t=I();if(t){t.commands=e;return}Ss=e}function bv(e){let t=I();if(t){t.parsers=e;return}Df=e}function wv(e){let t=I();if(t){t.preflight=e;return}Pf=e}function vv(e){let t=I();if(t){t.services=e;return}Sr=e}function Ev(e){let t=I();if(t){t.renderers=e;return}$f=e}function kv(e){let t=I();if(t){t.registrations=e;return}As=e}function Ts(){let e=I();return e?e.registrations:As}function Ff(){let e=I(),t=e?e.commandContext:Cs;return t?{...t,args:[...t.args],options:t.options?{...t.options}:{},global:t.global?{...t.global}:void 0}:null}function Ov(e){if(!e)return;let t=I();t?t.affectedItems.push(e):Mf.push(e)}function Sv(e,t){if(!e||!e.id)return{};let n={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return n;let r=e;for(let o of t){if(typeof o!="string")continue;let i=o.startsWith("unset:")?o.slice(6):o;i==="id"||i==="type"||i==="status"||Lf.has(i)||Object.hasOwn(r,i)&&r[i]!==void 0&&(n[i]=r[i])}return n}async function Rs(e){let t=I(),n=t?t.hooks:Me;return n?hr(n,e):[]}async function Av(e){let t=I(),n=t?t.hooks:Me;n&&await yr(n,e)}async function xs(e){let t=I(),n=t?t.hooks:Me;return n?br(n,e):[]}function Cv(){let e=I();return((e?e.hooks:Me)?.onRead?.length??0)>0}async function Iv(e){let t=I(),n=t?t.hooks:Me;return n?wr(n,e):[]}async function Tv(e){let t=I(),n=t?t.commands:Ss;return n?vr(n,{...e,...jf(e.pm_root)}):{handled:!1,result:null,warnings:[]}}function Ns(e,t){let n=I(),r=n?n.commandContext:Cs;return{service:e,command:r?.command,args:r?[...r.args]:[],options:r?.options?{...r.options}:{},global:r?.global?{...r.global}:void 0,pm_root:r?.pm_root,source_workspace_root:r?.source_workspace_root,repo_root:r?.repo_root,pm_root_rel:r?.pm_root_rel,payload:t}}async function Xt(e,t){let n=I(),r=n?n.services:Sr;return r?kr(r,Ns(e,t)):{handled:!1,result:t,warnings:[]}}function Ds(e,t){let n=I(),r=n?n.services:Sr;return r?Er(r,Ns(e,t)):{handled:!1,result:t,warnings:[]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4a7b042c-7fb8-57a5-8f94-de44f82d7589")}catch{}})();function Uf(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function ie(e,t){let n=e.slice(0,t),r=n.charCodeAt(n.length-1),o=e.charCodeAt(n.length);return r>=55296&&r<=56319&&o>=56320&&o<=57343?n.slice(0,-1):n}function $v(e){return Uf(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function Mv(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let n=new Set(e),r=new Set(t),o=0;for(let s of n)r.has(s)&&(o+=1);let i=new Set([...n,...r]).size;return o/i}import{stripVTControlCharacters as zf}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="493a0675-0114-5b93-b3b4-5bd895ac691f")}catch{}})();var qf=["full","compact","brief","summary","counts"],qv=["mutation","read","discovery","governance"],$s=["error","warning","validation_summary","recovery_bundle"],Bf=["full","omit_explanation","limit_collections","compact_recovery","action_only"],Vf=new Set(["append","claim","close","close-many","close-task","comments","config","copy","create","delete","docs","event","files","focus","history-author-acknowledge","history-compact","history-redact","history-repair","init","item","learnings","meet","notes","pause-task","release","remind","restore","schema","start-task","update","update-many"]),Gf=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),Wf=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),Kf={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},Hf=3,Yf=2,Xf=192,Jf={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},Qf=$s.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:Jf[e],minimum_max_estimated_tokens:Xf,degradation_ladder:Bf,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),Zf=new Map(Qf.map(e=>[e.diagnostic_class,e]));function em(e){let[t=""]=Qe(e).split(/\s+/u);return Vf.has(t)?"mutation":Gf.has(t)?"discovery":Wf.has(t)?"governance":"read"}function Ms(e,t=em(e)){let n=e.trim().replace(/\s+/gu," ");if(n.length===0)throw new TypeError("command must be a non-empty command path");let r=Kf[t];return tm({command:n,budget_class:t,default_max_estimated_tokens:r,default_max_estimated_tokens_by_format:{toon:r,json:Math.ceil(r*Hf/Yf)},degradation_ladder:qf,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function tm(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,n]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var nm=Lt.map(e=>Ms(e)),rm=new Map(nm.map(e=>[e.command,e]));function Ls(e,t={}){let n=e.trim().replace(/\s+/gu," "),[r]=Qe(n).split(" "),o=rm.get(r);return o?{...o,command:n}:t.generateFallback?Ms(n):null}function ke(e){return Math.ceil(Math.max(0,e)/4)}function js(e){let t=Zf.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${$s.join(", ")}`);return t}function se(e){return ke(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function om(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ar(e){if(!om(e))return;let t={};for(let n of["suggested_retry","suggested_retry_args","next_best_command","allowed_values","candidate_commands","missing","missing_required_fields","option_scope","retry_after_ms","waited_ms","owner_handoffs"]){let r=e[n];Array.isArray(r)?t[n]=n==="suggested_retry_args"?r:r.slice(0,3):r!==void 0&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}function im(e,t){return typeof e!="string"||e.length<=t?e:`${ie(e,Math.max(1,t-3))}...`}function Ee(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;let n="...",r=Array.from(e),o=0,i=r.length;for(;o<i;){let s=Math.ceil((o+i)/2),a=`${r.slice(0,s).join("")}${n}`;Buffer.byteLength(a,"utf8")<=t?o=s:i=s-1}return`${r.slice(0,o).join("")}${n}`}function Fs(e){let t={};for(let n of["code","required","recovery","next_steps","exit_code","type","title","detail","why","examples"])Object.hasOwn(e,n)&&e[n]!==void 0&&(t[n]=e[n]);for(let[n,r]of Object.entries(e))n!=="__proto__"&&!Object.hasOwn(t,n)&&(t[n]=r);return t}var sm=new Set(["limit_collections","compact_recovery","action_only"]),am=new Set(["compact_recovery","action_only"]);function cm(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:im(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},n=Ar(e.recovery);return n!==void 0?t.recovery=n:Array.isArray(e.next_steps)&&(t.next_steps=e.next_steps.slice(0,1)),e.exit_code!==void 0&&(t.exit_code=e.exit_code),e.type!==void 0&&(t.type=e.type),t}function dm(e,t){let n=structuredClone(e);if(t!=="full"&&(delete n.why,delete n.examples),sm.has(t))for(let[r,o]of Object.entries(n))Array.isArray(o)&&(n[r]=o.slice(0,3));if(am.has(t)){let r=Ar(n.recovery);r?n.recovery=r:delete n.recovery}return t!=="action_only"?Fs(n):cm(n)}function Le(e,t){let n={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let r=0;r<4;r+=1){let o=se(n),i=n.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return n}function lm(e,t,n){let r=Le(e,t);for(let i of["recovery","exit_code"])se(r)<=n||e[i]===void 0||(delete e[i],r=Le(e,t));let o=40;for(;se(r)>n&&o>4;)o-=4,e.code=Ee(String(e.code),o),e.required=Ee(String(e.required),o),r=Le(e,t);return r}function um(e,t){let n=e.diagnostic_output,{estimated_tokens:r,...o}=n,i=o.omitted_fields.slice(0,8).map(m=>Ee(m,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=Ar(e.recovery),c=a&&se(a)<=48?a:void 0,d={code:Ee(String(e.code),320),required:Ee(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},l=Le(d,s);for(;se(l)>t&&s.omitted_fields.length>0;)s.omitted_fields.pop(),s.omitted_fields_overflow_count=o.omitted_fields.length-s.omitted_fields.length,l=Le(d,s);return l=lm(d,s,t),l}function Bv(e,t={}){let n=e,r=t.diagnosticClass??"error",o=js(r),i=t.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.json,a=se(n),c=Object.keys(n);if(a<=s)return Fs(structuredClone(n));let d;for(let[l,m]of o.degradation_ladder.entries()){let u=dm(n,m),f=c.filter(_=>!Object.hasOwn(u,_)),p=Le(u,{diagnostic_class:r,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:l>0,degradation_steps:o.degradation_ladder.slice(0,l+1),omitted_fields:f});if(d=p,se(p)<=s)break}return se(d)>s&&(d=um(d,s)),d}function Ps(e){return zf(e).replace(/\r\n/gu,`
|
|
2
|
-
`).replace(/[^\P{Cc}\n]/gu," ")}function Vv(e,t,n={}){let r=n.diagnosticClass??"error",o=js(r),i=n.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<o.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${o.minimum_max_estimated_tokens}`);let s=i??o.default_max_estimated_tokens_by_format.text,a=Ps(e),c=ke(Buffer.byteLength(a,"utf8")),d=c>s,l=`What is required:
|
|
3
|
-
`,m=`
|
|
4
|
-
|
|
5
|
-
${Ee(a.trimStart().split(/\r?\n/u,1)[0].trim(),320)}
|
|
6
|
-
|
|
7
|
-
Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,u=Ps(t).trim()||"Inspect the diagnostic code and retry with corrected input.",f=Math.max(1,s*4-Buffer.byteLength(`${l}${m}`,"utf8")),p=d?`${l}${Ee(u,f)}${m}`:a;return{output:p,diagnostic_output:{diagnostic_class:r,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:ke(Buffer.byteLength(p,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}var Cr=Object.freeze({required:"Adjust command input or tracker state and retry.",why:Object.freeze(["pm enforces explicit, deterministic contracts for data and command semantics.","Commander validates CLI contracts before execution.","Unexpected runtime failures can occur from environment or extension-level issues.","Validation protects data consistency and deterministic behavior across commands.","Required options define command intent and enforce deterministic write contracts."]),examples:Object.freeze(["pm --help","pm <command> --help"])});function Gv(e){return e?.trim()===Cr.required}function Wv(e){let t=e?.trim();return t!==void 0&&Cr.why.includes(t)}function Kv(e){return(e??[]).filter(t=>!Cr.examples.includes(t.trim()))}var Hv=Object.freeze(["attempted_command","normalized_args","provided_fields"]);function Yv(e){if(!e)return;let{attempted_command:t,normalized_args:n,provided_fields:r,...o}=e;return Object.values(o).some(i=>i!==void 0)?o:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3a66ccfd-51fb-5d4a-b9cd-257c49997d52")}catch{}})();var qs=new WeakMap;function Zv(e,t){qs.set(e,new Set(t))}var Jt='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',fm={context:{row_keys:["high_level","low_level"],fields:"supported"},get:{row_keys:["children"],fields:"supported"},list:{row_keys:["items"],fields:"supported"},next:{row_keys:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],fields:"unsupported"},search:{row_keys:["items"],fields:"supported"},activity:{row_keys:["activity_digest","compact_activity","provenance_activity","activity"],fields:"unsupported"},history:{row_keys:["compact_history","provenance_history","history","diff"],fields:"unsupported"},deps:{row_keys:["graph.nodes","graph.edges","context.nodes","context.edges"],fields:"unsupported"},health:{row_keys:["checks"],fields:"unsupported"},aggregate:{row_keys:["groups"],fields:"unsupported"},duplicates:{row_keys:["clusters"],fields:"unsupported"},stats:{row_keys:["by_type","by_status"],fields:"unsupported"},comments:{row_keys:["comments"],fields:"unsupported"},notes:{row_keys:["notes"],fields:"unsupported"},learnings:{row_keys:["learnings"],fields:"unsupported"},files:{row_keys:["files"],fields:"unsupported"},docs:{row_keys:["docs"],fields:"unsupported"},validate:{row_keys:["checks","warnings"],fields:"unsupported"},contracts:{row_keys:["command_summaries","commands"],fields:"unsupported"}},mm=[{command:"activity",complete_mode:"full",omissions_by_mode:{digest:[{name:"event_rows",restore_with:"--raw"}],compact:[{name:"provenance",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}},{command:"history",complete_mode:"full",omissions_by_mode:{compact:[{name:"raw_history",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}}];function eE(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,g.USAGE)}function G(e,t=new Set){let n=e.filter(r=>!t.has(r.name)).map(r=>({...r}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function tE(e,t){let n=mm.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return G([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return G(r)}var pm=[{name:"hierarchy",restore_with:"--section hierarchy"},{name:"activity",restore_with:"--section activity"},{name:"progress",restore_with:"--section progress"},{name:"blockers",restore_with:"--section blockers"},{name:"recently_created",restore_with:"--section recently_created"},{name:"unparented",restore_with:"--section unparented"},{name:"files",restore_with:"--section files"},{name:"workload",restore_with:"--section workload"},{name:"staleness",restore_with:"--section staleness"},{name:"tests",restore_with:"--section tests"}];function L(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var _m=new Set([void 0,"tabular_when_uniform"]),gm=new Set(["collection","none"]),ym=new Set(["supported","unsupported"]);function Us(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(n=>typeof n=="string"&&n.length>0)&&new Set(e).size===e.length}function hm(e){return L(e)&&typeof e.command=="string"&&e.command.trim().length>0&&gm.has(e.row_kind)&&Us(e.row_keys,!0)&&(e.continuation_row_keys===void 0||Us(e.continuation_row_keys,!1))&&ym.has(e.fields)&&_m.has(e.toon_encoding)&&(e.row_kind==="collection"?e.row_keys.length>0&&typeof e.jq_selector=="string"&&e.jq_selector.trim().length>0:e.row_keys.length===0&&e.jq_selector===void 0)}var bm={ancestors:["ids"],descendants:["ids"],predecessors:["ids"],successors:["ids"],paths:["paths"],impact:["affected"],audit:["findings"],communities:["communities"],redundancy:["redundant"],dominators:["bottlenecks"],slack:["rows"],centrality:["rows"],articulation:["articulation_points","bridges"],plan:["steps"]},wm={context:["sections_included","high_level","low_level"],get:["item"],list:["items","projection"],next:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items","projection"],activity:["activity_digest","compact_activity","provenance_activity","activity"],history:["compact_history","provenance_history","history","diff"],deps:["tree","graph","projection"],health:["checks"],aggregate:["groups"],duplicates:["clusters"],stats:["totals","by_type","by_status"],comments:["comments"],notes:["notes"],learnings:["learnings"],files:["files"],docs:["docs"],validate:["checks","warnings"],contracts:["command_summaries","commands","selected"]};function vm(e,t){let n=e.trim().toLowerCase().split(/\s+/u,1)[0],r=n?.startsWith("list-")?"list":n;if(r==="graph"){let s=typeof t.subcommand=="string"?t.subcommand:"";if(s.length===0)return;let a=bm[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||L(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Jt}:{},toon_encoding:"tabular_when_uniform"}}let o=fm[r],i=wm[r];return o===void 0||i===void 0||!i.some(s=>Object.hasOwn(t,s))?void 0:(()=>{let s=o.row_keys.filter(a=>{let c=a.split(".").reduce((d,l)=>L(d)?d[l]:void 0,t);return Array.isArray(c)||L(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:Jt}:{},toon_encoding:"tabular_when_uniform"}})()}function Em(e){if(!L(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;let t=e.projection.declared_field_groups,n=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(n))return;let r=t.filter(s=>L(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=n.filter(s=>typeof s=="string");if(r.length!==t.length||o.length!==n.length)return;let i=new Set(r.map(s=>s.name));if(!(i.size!==r.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return G(r,new Set(o))}function km(e){if(!Array.isArray(e.sections_included))return;let t=G(pm,new Set(e.sections_included.filter(n=>typeof n=="string")));return L(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function Om(e,t,n){return e==="dependency_provenance"?!1:Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&L(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&L(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function Sm(e){if(!L(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=qs.get(e),i=a=>n.includes(a)||a==="body"||a==="dependency_provenance"?t:e,s=["body",...n,...r.slice(1),...o?.has("dependency_provenance")?["dependency_provenance"]:[],...o?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[]].filter(a=>o===void 0||o.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:a==="blockers"?"--full":a==="dependency_provenance"?"--fields dependencies":`--fields ${a}`}));return G(s,new Set(s.flatMap(({name:a})=>Om(a,i(a),e)?[a]:[])))}function zs(e){if(L(e.projection))return G([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function Am(e){if(!L(e.projection))return G([]);if(typeof e.projection.mode=="string")return G([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function Cm(e){if(!(!L(e.selected)||typeof e.selected.summary!="boolean"))return G([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function Im(e,t){let n=Em(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return km(t);if(r==="get")return Sm(t);if(r==="list"||r.startsWith("list-"))return zs(t);if(r==="search")return zs(t)??G([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return Am(t);if(r==="contracts")return Cm(t)}function Bs(e,t){if(e===void 0||!L(t))return t;let n=Im(e,t),r=t.row_contract,o=hm(r)?r:vm(e,t),i=o!==void 0?{...t,row_contract:o}:Object.hasOwn(t,"row_contract")?Object.fromEntries(Object.entries(t).filter(([s])=>s!=="row_contract")):t;return L(i.omission_receipt)||n===void 0?i:{...i,omission_receipt:n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b67272d-8924-5b1b-97cd-74a6a10493be")}catch{}})();function Ir(e){let t=e.trim().toLowerCase().startsWith("extension:"),n=e.trim().toLowerCase().replace(/^extension:/u,"");if(Ne(n))return;let r=Ts()?.commands??[],o=[...r].reverse().find(s=>s.command===n)?.command??(t?void 0:r.find(s=>s.action===n)?.command),i=[...r].reverse().find(s=>s.command===o);return i===void 0||Ne(i.command)||Ne(i.action)?void 0:i}function Tm(e){let t=Ir(e);return t?.read_output===void 0?void 0:t}function Vs(e,t){let n=Tm(e),r=n?.read_output;if(r===void 0)return t;if(typeof t!="object"||t===null||Array.isArray(t))throw new h("Read-only extension commands must return a structured object.",g.USAGE,{code:"extension_read_output_invalid"});for(let o of r.row_keys){let i=t;for(let s of o.split("."))i=typeof i=="object"&&i!==null&&Object.hasOwn(i,s)?Reflect.get(i,s):void 0;if(i===null||typeof i!="object")throw new h(`Read-only extension result is missing declared row collection ${o}.`,g.USAGE,{code:"extension_read_output_invalid"})}return{...t,row_contract:{command:`extension:${n.command}`,row_kind:r.row_keys.length>0?"collection":"none",row_keys:[...r.row_keys],fields:"supported",...r.row_keys.length>0?{jq_selector:Jt}:{},toon_encoding:"tabular_when_uniform"}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="03289358-031e-50aa-b94b-644697c4afc7")}catch{}})();var Tr={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded","--after"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},Rr=new Set(["--collapse","--fields","--section"]),Qt=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded --output-budget unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function Zt(e){return e.slice(2).replaceAll("-","_")}function Gs(e,t={}){let n=e==="package catalog"||e==="packages catalog"||e==="package-catalog"||(e==="package"||e==="packages"||e==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":e==="package manage"||e==="package-manage"?"package-manage":e.split(" ")[0],r=n.startsWith("list-")?"list":n==="ctx"?"context":n;return ge.includes(r)?r:void 0}function xr(e){return new Map((Tr[e]?.include??[]).filter(t=>!Rr.has(t)&&Qt[t]===void 0).map(t=>[Zt(t),Nr(t)]))}function Nr(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ea19c980-44aa-54eb-b853-d829335e520e")}catch{}})();var en="changed_fields",Rm="changed_field_count",Dr="rows",xm=new Set(["apply","rollback"]),Ys=new Set(["deleted","would_delete"]),Ws=256,Ks={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function Nm(e,t){if(!j(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(Ks,e.action)?Ks[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return j(s)&&j(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let r=e[n.at(-1)],o=Js(r);return t.idOnly?o:!t.compactEnvelope&&t.changedFields!=="compact"?null:{...e,...t.compactEnvelope?{...o,changed_field_count:new Set(n.flatMap(i=>e[i].changed_fields)).size}:{},...Object.fromEntries(n.map(i=>[i,Qs(e[i],t)]))}}function Hs(e){return typeof e!="string"||e.length<=Ws?e:`${ie(e,Ws-1)}\u2026`}function Dm(e){if(!j(e))return null;let t={...e};return t.reason=Hs(t.reason),j(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,Hs(r)]))),t}function j(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Xs(e){let t=e[en];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==en&&(n[r]=o);return n[Rm]=t.length,n}function Pm(e){return"item"in e&&Array.isArray(e[en])}function $m(e){return typeof e.mode=="string"&&xm.has(e.mode)&&Array.isArray(e[Dr])}function Mm(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[Dr]=t,n}function Js(e){if(!j(e))return null;let t=j(e.item)?e.item:j(e.plan)?e.plan:null;if(t===null)return null;let n=typeof t.id=="string"?t.id:void 0,r=typeof e.outcome=="string"&&Ys.has(e.outcome)?e.outcome:typeof t.status=="string"?t.status:void 0;return n?r?{id:n,status:r,...typeof e.deleted=="boolean"?{deleted:e.deleted}:{}}:{id:n}:null}function Lm(e,t){if(!j(e))return null;if(j(e.plan)&&j(e.mutation_receipt)&&e.mutation_receipt.kind==="plan_mutation"&&e.mutation_receipt.id===e.plan.id&&e.mutation_receipt.action===e.action)return e.mutation_receipt;if(!t||!j(e.item)||typeof e.item.id!="string")return null;let n=e[en];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&Ys.has(e.outcome)?{status:e.outcome}:typeof e.item.status=="string"?{status:e.item.status}:{},...typeof e.deleted=="boolean"?{deleted:e.deleted}:{},...typeof e.previous_status=="string"?{previous_status:e.previous_status}:{},changed_field_count:n.length};return jm(e,e.item,r),r}function jm(e,t,n){let r=typeof e.close_reason=="string"?e.close_reason:typeof t.close_reason=="string"?t.close_reason:void 0;r!==void 0&&(n.close_reason=r);let o=Dm(e.recurrence);o!==null&&(n.recurrence=o),Array.isArray(e.warnings)&&e.warnings.length>0&&(n.warnings=e.warnings);for(let i of["recovery","follow_up","handoff","completion","start"])j(e[i])&&(n[i]=e[i]);if(typeof e.claimed_by=="string"||typeof e.released_by=="string")for(let i of["claimed_by","released_by","previous_assignee","forced","skipped","available","attempts","suggestions"])Object.hasOwn(e,i)&&(n[i]=e[i])}function Fm(e){let t=$m(e)?e[Dr]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!j(o))return o;let i=Xs(o);return i?(n=!0,i):o});return n?{projected:Mm(e,r),changed:!0}:{projected:e,changed:!1}}function Qs(e,t={}){let n=Nm(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=Js(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=Lm(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!j(e))return e;let r=!1,o=e,i=Pm(e)?Xs(e):null;i!==null&&(o=i,r=!0);let s=Fm(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{AsyncLocalStorage as __}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7607f0d2-6e95-5b85-9bc2-18f643a64171")}catch{}})();var Zs=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),Um=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function zm(e){let t=e.indexOf("=");return t>0&&Zs.has(e.slice(0,t))}function qm(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function ea(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(Zs.has(n)){t+=qm(n,e[t+1])?1:0;continue}if(!(zm(n)||Um.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function mE(e){let t=ea(e);return t===void 0?void 0:e[t].trim().toLowerCase()}import Bm from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="86412887-5659-5892-beaa-bdd15a02ff4c")}catch{}})();var ta=e=>{let t='"',n=0;for(let r of e){if(r==="\\"){n+=1;continue}t+="\\".repeat(r==='"'?n*2+1:n),t+=r,n=0}return`${t}${"\\".repeat(n*2)}"`},na=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?ta(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,tn=(e,t=process.platform)=>{let n=e.map(r=>na(r,t)).join(" ");return n.length>0?`pm ${n}`:"pm"};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="08181915-ead8-51bc-a078-9d97b9048f37")}catch{}})();var Pr=new WeakMap;function vE(e){Pr.set(e,e.path)}function Vm(e){if(!process.env.PM_PATH?.trim())return;let t=Fo(e);return et(Uo(t),e)&&t===qn(e)?void 0:Bm.relative(e,t)||"."}function EE(e,t=process.cwd()){let n=(Pr.has(e)?Pr.get(e):e.path)||Vm(t),r=n?["--pm-path",n]:[];return e.noExtensions&&r.push("--no-extensions"),r}import{createHash as tp}from"node:crypto";import{createHash as Xm}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6db58d1-5d89-56b2-adee-13e985ebc675")}catch{}})();var Gm=new Set(["applied_bound","completeness","budget_retention_policy","continuation_contract","continuation_kind","continuation_path","filters","omission_receipt","output_budget_truncation","projection","read_output","read_session","row_contract","sorting"]);function R(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ra(e,t){let n=e;for(let r of t.split("."))if(Array.isArray(n)){if(!/^\d+$/u.test(r))return;n=n[Number(r)]}else{if(!R(n))return;n=n[r]}return n}function $r(e,t,n){let r=t.split("."),o=(i,s)=>{if(s===r.length)return n;let a=r[s];if(Array.isArray(i)){let d=Number(a),l=[...i];return l[d]=o(i[d],s+1),l}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function oa(e,t,n){let r=je(e).find(s=>s.path===t);if(!r)return e;let o=Array.isArray(r.value)?r.value.slice(n):Object.fromEntries(Object.entries(r.value).slice(n)),i=$r(e,t,o);return R(i.summary)&&R(i.summary.focus_row_states)&&typeof i.summary.focus_row_states[t]=="string"&&(i.summary={...i.summary,focus_row_states:{...i.summary.focus_row_states,[t]:i.summary.focus_row_states[t].slice(n)}}),mt(i),i}function rn(e){let t=e.row_contract;return R(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Object.entries(e).filter(([,n])=>Array.isArray(n)).map(([n])=>n)}function Wm(e){let t=e.row_contract;return R(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):rn(e)}function ae(e){return rn(e).flatMap(t=>{let n=ra(e,t);return Array.isArray(n)||R(n)?[{path:t,value:n}]:[]})}function je(e){return Wm(e).flatMap(t=>{let n=ra(e,t);return Array.isArray(n)||R(n)?[{path:t,value:n}]:[]})}function ut(e){let t=ae(e),n=new Set(t.map(o=>o.path)),r=(o,i)=>{if(Array.isArray(o)){n.has(i)||t.push({path:i,value:o}),o.forEach((s,a)=>r(s,`${i}.${a}`));return}if(R(o))for(let[s,a]of Object.entries(o))i.length===0&&Gm.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function on(e){return ae(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function ft(e,t){let n=e;for(let r of ae(n)){let o=Array.isArray(r.value)?r.value.map((i,s)=>t(i,r.path,s)):Object.fromEntries(Object.entries(r.value).map(([i,s],a)=>[i,t(s,r.path,a)]));n=$r(n,r.path,o)}return n}function ia(e,t){let n=e,r=!1;for(let o of ae(n)){let i=Array.isArray(o.value)?o.value:Object.entries(o.value);if(i.length<=t)continue;r=!0;let s=Array.isArray(o.value)?i.slice(0,t):Object.fromEntries(i.slice(0,t));n=$r(n,o.path,s)}return{result:n,truncated:r}}var sa=["high_level","low_level","blocked_fallback"];function nn(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function OE(e,t){if(!R(e.summary)||!R(e.summary.returned_focus))return;let n=new Map(t.map(r=>[r.id,r]));e.summary={...e.summary,focus_row_states:Object.fromEntries(sa.map(r=>[r,Array.isArray(e[r])?e[r].filter(R).map(o=>nn(n.get(o.id)??o)).join(""):""]))}}function Km(e,t){if(e!==void 0){if(typeof e!="string"||e.length!==t||!/^[iIoO]*$/u.test(e))throw new TypeError("Context focus classification receipt must contain one i/I/o/O code per delivered record");return e}}function Hm(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(R):[],i=Km(r[n],o.length)??o.map(nn).join(""),s=new Map(o.flatMap((d,l)=>d.id===void 0?[]:[[d.id,i[l]]])),a=Array.isArray(e[n])?e[n].filter(R):[],c=!1;return{states:a.map((d,l)=>{let m=s.get(d.id)??(d.id===void 0?i[l]:void 0)??nn(d);return m!==nn(d)&&(c=!0),m}).join(""),needsStates:c}}function Ym(e,t){typeof e.count=="number"&&(e.count_only===!0||t.count_only===!0?typeof t.count=="number"&&(e.count=t.count):Array.isArray(e.items)&&(e.count=e.items.length))}function mt(e,t=e){if(Ym(e,t),!R(e.summary)||!R(e.summary.returned_focus))return;let n={...e.summary},r=R(t.summary)&&R(t.summary.focus_row_states)?t.summary.focus_row_states:{},o=sa.map(c=>({key:c,...Hm(e,t,c,r)})),i=Object.fromEntries(o.map(({key:c,states:d})=>[c,d])),s=o.some(c=>c.needsStates),a=Object.values(i).join("");typeof n.high_level=="number"&&(n.high_level=Array.isArray(e.high_level)?e.high_level.length:0),typeof n.low_level=="number"&&(n.low_level=Array.isArray(e.low_level)?e.low_level.length:0),n.returned_focus={active_items:a.length,in_progress:[...a].filter(c=>c.toLowerCase()==="i").length,open:[...a].filter(c=>c.toLowerCase()==="o").length,blocked:[...a].filter(c=>c===c.toUpperCase()).length},s?n.focus_row_states=i:delete n.focus_row_states,e.summary=n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f7f59eaa-9d5d-5797-99de-e672fdfba99d")}catch{}})();var Jm=4096,Qm=Object.freeze(["queue_draining","queue_entries","queue_exists","queue_high_retry_entries","queue_invalid_rows","queue_max_attempts","queue_rows_total","queue_size_bytes","pending_otel_spans","last_attempted_flush_at","last_failed_flush_at","last_otel_attempt_at","last_otel_failure_at","last_otel_success_at","last_successful_flush_at"]),ca=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:Qm}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function _t(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function pt(e){return Array.isArray(e)?e.map(pt):_t(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,pt(n)])):e}function aa(e,t){if(!_t(e))return pt(e);let n=typeof e.name=="string"?e.name:void 0,r=n!==void 0&&Object.hasOwn(t.ignored_detail_field_names_by_row,n)?t.ignored_detail_field_names_by_row[n]:void 0;return Object.fromEntries(Object.entries(e).map(([o,i])=>o!=="details"||!r||!_t(i)?[o,pt(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!r.includes(s)).map(([s,a])=>[s,pt(a)]))]))}function Zm(e,t){return Array.isArray(e)?e.map(n=>aa(n,t)):aa(e,t)}function sn(e,t,n){let r=n?ca[n]:void 0,o=r?.paths.includes(e)===!0;return Xm("sha256").update(pe({path:e,value:o?Zm(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function Mr(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint}),"utf8").toString("base64url")}function ep(e){return typeof e=="string"&&(Fe(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function gt(e){if(e.length>Jm)throw new h("The read-output continuation cursor is malformed or unsupported.",g.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!_t(t)||t.v!==1||!ep(t.c)||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new h("The read-output continuation cursor is malformed or unsupported.",g.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function da(e){if(!Array.isArray(e.assertions))return e;let t=n=>!_t(n)||n.verdict==="pass"?4:n.verdict==="retired"?3:n.enforcement==="block"?0:n.enforcement==="warn"?1:2;return{...e,assertions:e.assertions.map((n,r)=>({row:n,index:r})).sort((n,r)=>t(n.row)-t(r.row)||n.index-r.index).map(({row:n})=>n),budget_retention_policy:"verdict_priority"}}function la(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,g.USAGE,{code:"read_output_cursor_command_mismatch"});let r=je(e).find(i=>i.path===n.path),o=r?Array.isArray(r.value)?r.value.length:Object.keys(r.value).length:0;if(!r||o!==n.total_rows||n.offset>o||sn(n.path,r.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",g.USAGE,{code:"read_output_cursor_stale"});return oa(e,n.path,n.offset)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6a81cf4-3095-5197-8e73-f017d98b1ccf")}catch{}})();var jr=1,ua=4096,np=/^[A-Za-z0-9_-]+$/;function Lr(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function FE(e,t){let n=[...Object.values(jt),...Ft],r=new Set(n.flatMap(o=>[Lr(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){r.add(Lr(o.flag));for(let i of o.aliases??[])r.add(Lr(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!r.has(o)))}function UE(e,t){return tp("sha256").update(e).update("\0").update(pe(t)).digest("hex").slice(0,24)}function yt(e,t,n,r){return Buffer.from(JSON.stringify({version:jr,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function Oe(e,t){return new h(e,g.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function rp(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===jr&&typeof t.fingerprint=="string"&&typeof t.after_id=="string"&&t.after_id.length>0&&(t.after_index===void 0||Number.isSafeInteger(t.after_index)&&t.after_index>=0)&&(t.snapshot===void 0||typeof t.snapshot=="string"&&t.snapshot.length>0)}function Fr(e,t="--after"){if(typeof e!="string")throw Oe("Query cursor is malformed.",t);let n=e.trim();if(n.length===0||n.length>ua||!np.test(n))throw Oe("Query cursor is malformed.",t);let r;try{r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"))}catch{throw Oe("Query cursor is malformed.",t)}if(!rp(r)){let o=!1;try{gt(n),o=!0}catch{}throw o?new h(`An output cursor must be continued with --output-cursor, not ${t}.`,g.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${n}; retain any producer ${t} cursor from the original page.`]}):Oe("Query cursor version or payload is unsupported.",t)}return r}function Ur(e,t,n="--after"){let r=Fr(e,n);if(r.fingerprint!==t)throw Oe(`Query cursor does not match the current filters, sort, or query (${r.fingerprint} != ${t}).`,n);return{after_id:r.after_id,...r.after_index===void 0?{}:{after_index:r.after_index},...r.snapshot===void 0?{}:{snapshot:r.snapshot}}}function zE(e,t){return Ur(e,t).after_id}function op(e,t,n,r,o="--after"){if(t===void 0)return 0;let i=Ur(t,n,o),s=e.findIndex(a=>r(a)===i.after_id);if(s<0){if(i.after_index!==void 0)return Math.min(i.after_index,e.length);throw Oe(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return s+1}function qE(e,t){if(t.cursor!==void 0&&Ur(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw Oe("Query cursor does not match the requested snapshot.","--after");let n=op(e,t.cursor,t.fingerprint,t.readId),r=e.slice(n,n+t.limit),o=r.length>0&&n+r.length<e.length,i=r.at(-1);return{rows:r,has_more:o,...o&&i!==void 0?{next_cursor:yt(t.fingerprint,t.readId(i),n+r.length-1,t.snapshot)}:{}}}var BE=Object.freeze({version:jr,max_length:ua});import{randomUUID as i_}from"node:crypto";import{randomUUID as t_}from"node:crypto";import{constants as qe}from"node:fs";import{lstat as Da,mkdir as n_,open as $a,rename as r_,rm as o_}from"node:fs/promises";import gn from"node:path";import{constants as Ip}from"node:fs";import P from"node:fs/promises";import B from"node:path";import{createHash as Tp,randomUUID as un}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="92573990-a040-526d-a0b1-b91d2ef401f1")}catch{}})();function fa(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import ip from"node:crypto";import{AsyncLocalStorage as sp}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ced47074-06d3-53b9-af75-63586cbd4f6a")}catch{}})();var pa=new sp,ma=1024;function _a(){let e=pa.getStore();if(e===void 0)return;let t=new Date(Date.parse(e.clock)+e.clockReads*e.tickMs).toISOString();return e.clockReads+=1,t}function HE(e){let t=pa.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>ma)throw new Error(`Reproducible token length must be an integer between 0 and ${ma}`);let n="";for(;n.length<e;){let r=ip.createHash("sha256").update(`${t.seed}\0${t.tokenReads}`).digest();t.tokenReads+=1;for(let o of r)if(n+=(o%36).toString(36),n.length===e)break}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0bf155fc-c690-5318-ba1e-275f1787858b")}catch{}})();var ap=/^([+-]?)(\d+)([hdwm])$/i,cp=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,dp=/^(\d{4})(\d{2})(\d{2})$/,lp=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,up=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,fp=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,mp=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function Br(){return _a()??new Date().toISOString()}function ek(e){return Number.isFinite(Date.parse(e))}function pp(e){let t=mp.exec(e);if(!t||!Number.isFinite(Date.parse(e)))return!1;let[,n,r,o,i,s,a,c,d]=t,[l,m,u,f,p,_]=[n,r,o,i,s,a].map(Number);return m>=1&&m<=12&&u>=1&&u<=Vr(l,m-1)&&f<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function tk(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return pp(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var _p=1e4,an=new Map;function ga(e){let t=an.get(e);if(t!==void 0)return t;let n=Date.parse(e);return an.size>=_p&&fa(an),an.set(e,n),n}function Ue(e,t){let n=ga(e),r=ga(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function nk(e,t){return!(t.deadlineBefore&&(!e.deadline||Ue(e.deadline,t.deadlineBefore)>0)||t.deadlineAfter&&(!e.deadline||Ue(e.deadline,t.deadlineAfter)<0)||t.updatedAfter&&Ue(e.updated_at,t.updatedAfter)<0||t.updatedBefore&&Ue(e.updated_at,t.updatedBefore)>0||t.createdAfter&&Ue(e.created_at,t.createdAfter)<0||t.createdBefore&&Ue(e.created_at,t.createdBefore)>0)}function zr(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function qr(e){if(!e)return"";if(e.toUpperCase()==="Z")return"Z";let t=/^([+-]\d{2})(\d{2})$/.exec(e);return t?`${t[1]}:${t[2]}`:e}function gp(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function yp(e){let t=[],n=d=>gp(t,e,d),r=dp.exec(e);if(r){let[,d,l,m]=r;n(`${d}-${l}-${m}`)}let o=lp.exec(e);if(o){let[,d,l,m,u,f,p,_,y]=o,b=p?`:${p}`:"";n(`${d}-${l}-${m}T${u}:${f}${b}${zr(_)}${qr(y)}`)}let i=up.exec(e);if(i){let[,d,l,m,u,f,p]=i,_=u?`:${u}`:"";n(`${d}T${l}:${m}${_}${zr(f)}${qr(p)}`)}let s=fp.exec(e);if(s){let[,d,l,m,u,f,p]=s,_=u?`:${u}`:"";n(`${d}T${l}:${m}${_}${zr(f)}${qr(p)}`)}let a=10,c=e.slice(0,a);if(bp(c)){let d=a;for(;d<e.length&&wp(e[d]);)d+=1;d<e.length&&n(`${c}T${e.slice(d)}`)}return t}function hp(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of yp(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function bp(e){if(e.length!==10)return!1;for(let t=0;t<e.length;t+=1){let n=e[t];if(t===4||t===7){if(n!=="-")return!1;continue}let r=n.charCodeAt(0);if(r<48||r>57)return!1}return!0}function wp(e){return e?e===" "||e===" "||e===`
|
|
8
|
-
`||e==="\r"||e==="\f"||e==="\v":!1}function Vr(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var vp=["January","February","March","April","May","June","July","August","September","October","November","December"],Ep=/^(\d{4})-(\d{2})-(\d{2})/,kp=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function Op(e,t,n){let r=Ep.exec(t)??kp.exec(t);if(!r)return;let o=Number.parseInt(r[1],10),i=Number.parseInt(r[2],10),s=Number.parseInt(r[3],10),a=n?.trim()||"deadline";if(i<1||i>12)throw new h(`Invalid ${a} value "${e}". Month "${r[2]}" is out of range \u2014 use a month between 01 and 12.`,g.USAGE,{field:a,value:e});let c=Vr(o,i-1);if(s<1||s>c)throw new h(`Invalid ${a} value "${e}". ${vp[i-1]} ${o} has ${c} days, so day "${r[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,g.USAGE,{field:a,value:e})}function Sp(e,t){let n=new Date(e.getTime()),r=n.getUTCDate(),o=n.getUTCMonth()+t,i=n.getUTCFullYear()+Math.floor(o/12),s=(o%12+12)%12,a=Math.min(r,Vr(i,s));return n.setUTCFullYear(i,s,a),n}function rk(e,t=new Date,n="deadline"){let r=e.trim();if(r.toLowerCase()==="now")return t.toISOString();let o=ap.exec(r);if(o){let s=o[1]==="-"?-1:1,a=Number.parseInt(o[2],10)*s,c=o[3].toLowerCase();if(c==="m")return Sp(t,a).toISOString();let d=c==="h"?3600*1e3:c==="d"?1440*60*1e3:10080*60*1e3;return new Date(t.getTime()+a*d).toISOString()}Op(e,r,n);let i=hp(r);if(!Number.isFinite(i)){let s=n.trim().length>0?n.trim():"deadline",a=cp.test(r)?"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.":'Use ISO/date string input, "now", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';throw new h(`Invalid ${s} value "${e}". ${a}`,g.USAGE,{field:s,value:e})}return new Date(i).toISOString()}import Gr from"node:fs/promises";import{createHash as Ap}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d1f829a5-70d6-5096-86f7-717440dd67d5")}catch{}})();function ya(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function Cp(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!ya(t,"ESRCH")}}function ha(e){let t=e.lastIndexOf(")");if(t<0)return null;let n=e.slice(t+2).trim().split(/\s+/u)[19];return n!==void 0&&/^\d+$/u.test(n)?n:null}async function ze(e){try{return ha(await Gr.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function Wr(e=process.pid){let t=await ze(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function Kr(e,t,n){if(!Cp(e.pid))return!1;let r=await ze(e.pid);return e.process_start_identity!==void 0&&r!==null?r===e.process_start_identity:t<=n}async function ba(){try{let[e,t]=await Promise.all([Gr.readFile("/proc/sys/kernel/random/boot_id","utf8"),Gr.readlink("/proc/self/ns/pid")]);return!/^[a-f0-9-]{36}\s*$/u.test(e)||!/^pid:\[\d+\]$/u.test(t)?null:Ap("sha256").update(`${e.trim()}:${t}`).digest("hex")}catch{return null}}async function Hr(){let[e,t]=await Promise.all([ba(),ze(process.pid)]);return e!==null&&t!==null?{host_identity:e,process_start_identity:t}:{}}async function cn(e){if(!e||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0||typeof e.host_identity!="string"||typeof e.process_start_identity!="string"||!/^\d+$/u.test(e.process_start_identity))return"unknown";let t=await ba();if(t===null||t!==e.host_identity)return"unknown";try{process.kill(e.pid,0)}catch(r){return ya(r,"ESRCH")?"dead":"unknown"}let n=await ze(e.pid);return n===null?"unknown":n===e.process_start_identity?"alive":"dead"}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fa450dd8-119e-5a50-bdc7-e81c1dfdbd9b")}catch{}})();function Rp(e){let t;try{t=JSON.parse(e)}catch{return{info:null,warnings:["lock_info_invalid_json"]}}if(typeof t!="object"||t===null||Array.isArray(t))return{info:null,warnings:["lock_info_invalid_shape"]};let n=t,r=n.id,o=n.pid,i=n.owner,s=n.token,a=n.created_at,c=n.ttl_seconds;return typeof r!="string"||typeof o!="number"||!Number.isFinite(o)||typeof i!="string"||s!==void 0&&(typeof s!="string"||s.trim().length===0)||typeof a!="string"||typeof c!="number"||!Number.isFinite(c)?{info:null,warnings:["lock_info_invalid_shape"]}:{info:{id:r,pid:o,owner:i,...typeof s=="string"?{token:s}:{},created_at:a,ttl_seconds:c,host_identity:n.host_identity,process_start_identity:n.process_start_identity},warnings:[]}}async function Se(e,t=!0){try{let n=await P.readFile(e,"utf8");return t&&await xs({path:e,scope:"project"}),Rp(n)}catch(n){return fe(n)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function ce(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function xp(e,t,n=process.platform){if(ce(e,"EEXIST"))return!0;if(!ce(e,"EPERM")&&!ce(e,"EACCES")&&!ce(e,"EBUSY"))return!1;try{return await P.lstat(t),!0}catch(r){if(n!=="win32"||!fe(r)&&!ce(r,"EPERM")&&!ce(r,"EACCES")&&!ce(r,"EBUSY"))return!1}try{return await P.access(B.dirname(t),Ip.W_OK),!0}catch{return!1}}async function Oa(e,t){await Rs({path:e,scope:"project",op:t})}async function Np(e,t,n,r=un()){return{...await Hr(),id:e,pid:process.pid,owner:t,token:r,created_at:Br(),ttl_seconds:n}}async function Dp(e,t,n,r,o,i){i&&await P.mkdir(B.dirname(e),{recursive:!0});let s=await _n(e,t);if(s===null)throw await P.access(B.dirname(e)),Object.assign(new Error("Lock initialization is contended"),{code:"EEXIST"});let a;try{let c=await P.open(e,"wx");try{try{let d=await Np(t,n,r,o);a=d.created_at,await c.writeFile(`${JSON.stringify(d,null,2)}
|
|
9
|
-
`,"utf8")}finally{await c.close()}}catch(d){throw await Jr(e,"lock:release"),d}}finally{await s()}return await Oa(e,"lock:create"),a}async function Jr(e,t){try{return await P.unlink(e),await Oa(e,t),!0}catch{return!1}}async function Pp(e,t,n,r){let o=performance.now(),i=fn;for(;;){let s=await _n(e,t);if(s!==null){try{let d=await Se(e,!1);Yr(d.info,t,n,r)&&await Jr(e,"lock:release")}finally{await s()}return}let a=await Se(e,!1);if(!Yr(a.info,t,n,r))return;let c=performance.now()-o;if(c>=dn)return;await pn(Math.min(i,dn-c)),i=Math.min(i*2,mn)}}function Yr(e,t,n,r){return e?.id===t&&e.pid===process.pid&&e.owner===n&&e.token===r}function Sa(e,t){let n=e?.created_at?Date.parse(e.created_at):Number.NaN;return(Number.isFinite(n)?Date.now()-n:Number.POSITIVE_INFINITY)>t*1e3}async function Aa(e){return e!==null&&Number.isFinite(Date.parse(e.created_at))&&await cn(e)==="dead"}async function Ca(e,t){return Sa(e,t)||await Aa(e)}async function vk(e,t,n){let{info:r}=await Se(Bn(e,t),!1);return r!==null&&r.owner.startsWith(n)&&!await Ca(r,r.ttl_seconds)}function $p(e){return e?.owner?` (owner ${e.owner})`:""}var fn=25,mn=200,Ia=250,Mp=12e4,Lp=3,jp=".stale-cleanup",Ta="owner.json",Ra=1e4,dn=Ra+mn;function Xr(e){if(typeof e=="string"){let t=e.trim();if(!/^\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)?n:void 0}if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return Math.trunc(e)}function Fp(e){let t=process.env.PM_LOCK_WAIT_MS,n=Xr(t);if(n!==void 0)return n;let r=Xr(e);return r!==void 0?r:0}function Up(e,t){return Math.min(Fp(e),t??1/0)}function pn(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(n=>setTimeout(n,t))}async function xa(e,t,n,r=0){n=Math.floor(n);let o=await cn(t),i=r>0?` across ${r} owner handoff(s)`:"",s=n>0?` after waiting ${n}ms${i}`:"";return new h(`Item ${e} is locked${$p(t)} (owner process ${o})${s}`,g.CONFLICT,{code:"lock_conflict",item_id:e,reason:`lock_owner_${o}`,required:"Wait for the owner to release the lock, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget when contention is expected. Inspect stale receipts with pm gc --scope locks --dry-run.",recovery:{retry_after_ms:Ia,...n>0?{waited_ms:n,owner_handoffs:r}:{}}})}function zp(e,t){let n=performance.now(),r=n,o,i=0;return{startedAtMs:n,observe(s){let a=performance.now(),c=Bp(s);o!==void 0&&c!==o&&(i+=1,r=a),o=c;let d=a-n,l=a-r;return{exhausted:e===0||l>=e||d>=t,elapsedMs:d,remainingMs:Math.min(e-l,t-d),ownerHandoffs:i}}}}function qp(e,t,n){return n!=="progress"||t!==void 0?e:Math.max(e,Mp)}function Bp(e){return e===null?"released":e.token??`${e.pid}:${e.owner}:${e.created_at}`}function Vp(e){let t=Date.parse(e.acquiredAt)+e.ttlSeconds*1e3;return{owner:e.owner,acquired_at:e.acquiredAt,ttl_seconds:e.ttlSeconds,expires_at:new Date(t).toISOString()}}function Gp(e,t,n,r){let o=`the lease acquired at ${t.acquiredAt} (ttl ${t.ttlSeconds}s)`;if(r==="fence_gate_unavailable")return{summary:`Lock for ${e} could not be verified before commit: ${o} could not enter its commit fence because the stale-cleanup gate stayed held.`,required:"Retry the same operation; this writer's change was not committed. Inspect pm gc --scope locks --dry-run if the stale-cleanup gate stays held."};let i=n===null?"the lock no longer exists":`it is now held by ${n.owner} since ${n.created_at}`;return{summary:`Lock for ${e} was lost before commit: ${o} is no longer owned by this writer, and ${i}.`,required:"Re-read the item and apply the mutation again; this writer's change was not committed and the newer value was kept. Keep mutation work shorter than locks.ttl_seconds, or raise locks.ttl_seconds for long-running callbacks."}}function wa(e,t,n,r){let{summary:o,required:i}=Gp(e,t,n,r);return new h(`${o} Nothing was written.`,g.CONFLICT,{code:"lock_lost",item_id:e,reason:r,lease:Vp(t),current_owner:n===null?null:{owner:n.owner,pid:n.pid,created_at:n.created_at,ttl_seconds:n.ttl_seconds},required:i,recovery:{retry_after_ms:Ia}})}async function Wp(e,t){let n=performance.now(),r=fn;for(;;){let o=await _n(e,t);if(o!==null)return o;let i=performance.now()-n;if(i>=dn)return null;await pn(Math.min(r,dn-i)),r=Math.min(r*2,mn)}}async function Kp(e,t,n,r){let o=await Wp(e,t);if(o===null){let i=await Se(e,!1);throw wa(t,n,i.info,"fence_gate_unavailable")}try{let i=await Se(e,!1);if(!Yr(i.info,t,n.owner,n.token))throw wa(t,n,i.info,i.info===null?"lease_released":"lease_taken_over");return await r()}finally{await o()}}function Hp(e){if(typeof e=="function")return e;if(typeof e=="object"&&e!==null&&"release"in e){let t=e.release;return typeof t=="function"?t:null}return null}function Yp(e,t,n,r){if(!n&&r){let o=t.warnings.length>0?` (${t.warnings.join(",")})`:"";throw new h(`Item ${e} lock is stale${o}; rerun with --force when supported for this command`,g.CONFLICT)}}function Xp(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null||Array.isArray(t))return null;let n=t,r=n.pid,o=n.token,i=n.process_start_identity;return typeof r!="number"||!Number.isInteger(r)||r<=0||typeof o!="string"||o.length===0||i!==void 0&&(typeof i!="string"||!/^\d+$/u.test(i))?null:{pid:r,token:o,host_identity:n.host_identity,...typeof i=="string"?{process_start_identity:i}:{}}}async function ln(e){try{return Xp(await P.readFile(B.join(e,Ta),"utf8"))}catch(t){return fe(t)?null:void 0}}async function Qr(e){try{return await P.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function va(e,t){let n=await ln(e);for(let r=0;n===void 0&&r<3;r+=1)await pn(fn),n=await ln(e);!n||n.token!==t||await Qr(e)}async function Ea(e){try{await P.mkdir(e)}catch(n){return ce(n,"EEXIST"),null}let t={...await Wr(),host_identity:(await Hr()).host_identity,token:un()};try{await P.writeFile(B.join(e,Ta),`${JSON.stringify(t)}
|
|
10
|
-
`,"utf8")}catch{return await Qr(e),null}return t}async function ka(e,t){let n=B.join(B.dirname(e),"recoveries"),r=Tp("sha256").update(t).digest("hex");try{return await P.mkdir(n,{recursive:!0}),(await ln(e))?.token!==t?!1:(await P.rename(e,B.join(n,`gate-${r}`)),!0)}catch{return!1}}async function Jp(e){let t;try{let r=await P.stat(e);t=Date.now()-r.mtimeMs}catch(r){return fe(r)}let n=await ln(e);if(n===void 0)return!1;if(n!==null){if(await cn(n)==="dead")return ka(e,n.token);if(n.host_identity!==void 0)return!1}return t<=Ra||n!==null&&await Kr(n,t,Number.POSITIVE_INFINITY)?!1:n!==null?ka(e,n.token):Qr(e)}async function _n(e,t){let n=`${e}${jp}`,r=await Ea(n);if(r!==null)return async()=>va(n,r.token);if(!await Jp(n))return null;let o=await Ea(n);return o===null?null:async()=>va(n,o.token)}async function Qp(e,t){let n=B.join(B.dirname(e),"recoveries");await P.mkdir(n,{recursive:!0}),await P.writeFile(B.join(n,`${un()}.json`),`${JSON.stringify({event:"owner_dead_recovery_attempt",recorded_at:Br(),lock:JSON.parse(t)})}
|
|
11
|
-
`,{encoding:"utf8",flag:"wx",mode:384})}async function Zp(e){let t=await _n(e.lockPath,e.id);if(t===null)return{lockInfo:e.fallbackLockInfo,shouldRetryCreate:!1,staleRemovalCounted:!1};try{let n=await Se(e.lockPath);if(n.info===null&&n.warnings.length===0)return{lockInfo:n,shouldRetryCreate:!0,staleRemovalCounted:!1};let r=await Aa(n.info);if(!Sa(n.info,e.ttlSeconds)&&!r)return{lockInfo:n,shouldRetryCreate:!1,staleRemovalCounted:!1};if(Yp(e.id,n,e.force||r,e.forceRequiredForStaleLock),e.staleRemovals>=Lp)throw await xa(e.id,n.info,performance.now()-e.startedAtMs);return r&&await Qp(e.lockPath,JSON.stringify(n.info)),{lockInfo:n,shouldRetryCreate:await Jr(e.lockPath,"lock:stale_remove"),staleRemovalCounted:!0}}finally{await t()}}async function Na(e,t,n,r,o=!1,i=!0,s,a={}){return(await e_(e,t,n,r,o,i,s,a)).release}async function e_(e,t,n,r,o=!1,i=!0,s,a={}){let c=Xr(a.maxWaitMs),d=await Xt("lock_acquire",{pm_root:e,id:t,ttl_seconds:n,owner:r,force:o,force_required_for_stale_lock:i,...c===void 0?{}:{max_wait_ms:c}});if(d.handled){let k=Hp(d.result);if(k)return{release:async()=>{await Promise.resolve(k()),await Xt("lock_release",{pm_root:e,id:t,owner:r})},fence:U=>U()}}let l=Bn(e,t),m=Up(s,c),u=qp(m,c,a.waitPolicy),f=zp(m,u),p=f.startedAtMs,_=0,y=fn,b=un();for(;;)try{let k=await Dp(l,t,r,n,b,a.createParentDirectories!==!1),U={owner:r,token:b,acquiredAt:k,ttlSeconds:n};return{release:async()=>{await Pp(l,t,r,b),await Xt("lock_release",{pm_root:e,id:t,owner:r})},fence:Q=>Kp(l,t,U,Q)}}catch(k){if(!await xp(k,l))throw new h(`Failed to acquire lock for ${t}: ${pi(k)}`,g.GENERIC_FAILURE);let U=await Se(l);if(await Ca(U.info,n)){let Ie=await Zp({lockPath:l,id:t,ttlSeconds:n,force:o,forceRequiredForStaleLock:i,staleRemovals:_,waitBudgetMs:m,startedAtMs:p,fallbackLockInfo:U});if(U=Ie.lockInfo,Ie.staleRemovalCounted&&(_+=1),Ie.shouldRetryCreate)continue}let Q=f.observe(U.info);if(Q.exhausted)throw await xa(t,U.info,m===0?0:Q.elapsedMs,Q.ownerHandoffs);await pn(Math.min(y,Q.remainingMs)),y=Math.min(y*2,mn)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71b65888-baa5-5c5f-a02c-4a0fd818fadb")}catch{}})();var X={max_serving_rows:256,max_bytes:262144,max_event_bytes:32768,retained_byte_fraction:.5,max_events:2048,retention_days:30},T=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function Ae(e){let t=Date.parse(e.now??new Date().toISOString());if(!Number.isFinite(t))throw new T("Context usage now must be a valid timestamp");return{iso:new Date(t).toISOString(),ms:t}}function Ma(e){let t=e.maxBytes??X.max_bytes,n=e.maxEvents??X.max_events,r=e.retentionDays??X.retention_days;if(!Number.isSafeInteger(t)||t<1024||t>X.max_bytes||!Number.isSafeInteger(n)||n<1||!Number.isFinite(r)||r<=0)throw new T("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");return{maxBytes:t,maxEvents:n,cutoff:Ae(e).ms-r*864e5}}async function La(e,t){if(!(await Da(gn.dirname(e))).isDirectory())throw new T("Context usage runtime must be a real directory");try{if((await Da(e)).isSymbolicLink())throw new T("Context usage ledger must not be a symbolic link")}catch(r){if(!fe(r))throw r}let n=await $a(e,t|qe.O_NOFOLLOW|qe.O_NONBLOCK,384);try{let r=await n.stat();if(!r.isFile()||r.nlink!==1)throw new T("Context usage ledger must be an unshared regular file");return n}catch(r){throw await n.close(),r}}async function yn(e){let t=Ma(e);try{let n=await La(gn.join(e.pmRoot,"runtime","context-usage.jsonl"),qe.O_RDONLY);try{let r=(await n.stat()).size,o=Math.max(0,r-t.maxBytes),i=Buffer.alloc(Math.min(r,t.maxBytes)),{bytesRead:s}=await n.read(i,0,i.length,o),a=i.subarray(0,s).toString("utf8");return(o>0?a.includes(`
|
|
12
|
-
`)?a.slice(a.indexOf(`
|
|
13
|
-
`)+1):"":a).split(`
|
|
14
|
-
`).flatMap(c=>{try{let d=JSON.parse(c);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await n.close()}}catch{return[]}}function Pa(e,t,n){let r=[],o=0;for(let i=e.length-1;i>=0&&r.length<n;i-=1){let s=`${JSON.stringify(e[i])}
|
|
15
|
-
`;if(o+=Buffer.byteLength(s),o>t)break;r.push(s)}return r.reverse().join("")}async function ht(e,t,n){let r=Ma(e),o=gn.join(e.pmRoot,"runtime","context-usage.jsonl"),i=Math.floor(r.maxBytes*X.retained_byte_fraction),s=Math.min(X.max_event_bytes,i);if(t.some(u=>Buffer.byteLength(`${JSON.stringify(u)}
|
|
16
|
-
`)>s))throw new T("Context usage event exceeds the declared byte ceiling");let a=t.filter(u=>Date.parse(u.at)>=r.cutoff),c=Pa(a,i,r.maxEvents),d=performance.now(),l=await Na(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),m=performance.now()-d;try{await n_(gn.dirname(o),{recursive:!0});let u=await La(o,qe.O_WRONLY|qe.O_CREAT|qe.O_APPEND);try{let f=(await u.stat()).size,p=n===void 0?void 0:await yn(e);if(p?.some(k=>k.kind==="delivery"&&k.serve_id===n))return{written_bytes:0,ledger_bytes:f,compacted:!1,lock_wait_ms:m};if(!(e.maxEvents!==void 0||e.retentionDays!==void 0)&&f+Buffer.byteLength(c)<=r.maxBytes)return await u.writeFile(c,"utf8"),{written_bytes:Buffer.byteLength(c),ledger_bytes:f+Buffer.byteLength(c),compacted:!1,lock_wait_ms:m};let _=Pa([...p??await yn(e),...a],i,r.maxEvents),y=`${o}.${process.pid}.${t_()}.tmp`,b=await $a(y,"wx",384);try{try{await b.writeFile(_,"utf8")}finally{await b.close()}return await u.close(),u=void 0,await r_(y,o),{written_bytes:Buffer.byteLength(_),ledger_bytes:Buffer.byteLength(_),compacted:!0,lock_wait_ms:m}}finally{await o_(y,{force:!0})}}finally{await u?.close()}}finally{await l()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e76b38ce-b2aa-589b-9d17-0952eca9e7a2")}catch{}})();var s_=864e5,hn=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function x(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Dk(e,t){let n=x(e);n!==null&&t!==null&&(n[hn]=t)}function bn(e,t){let n=x(e),r=x(t),o=n?.[hn];r!==null&&o!==void 0&&(r[hn]=o)}function a_(e){return x(e)?.[hn]??null}function Fa(e){let t=x(e);for(let n of["read_output","context_intent"])if(x(t?.[n])?.result_omitted===!0)return!0;return!1}function de(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function Ua(e,t){if(Array.isArray(t))for(let n of t)de(e,x(n)?.id)}function ja(e,t){if(Array.isArray(t))for(let n of t)de(e,n)}function c_(e,t){let n=x(e.recommended)===null?[]:[e.recommended];for(let r of["ready","decision_needed","gate_needed","containers","blocked","held_by_others"])Array.isArray(e[r])&&n.push(...e[r]);for(let r of n){let o=x(r);de(t,o?.id);for(let i of Array.isArray(o?.blockers)?o.blockers:[])de(t,x(i)?.id);for(let i of Array.isArray(o?.unblocks)?o.unblocks:[])de(t,i)}}function d_(e,t){for(let n of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])Ua(t,e[n]);for(let n of Array.isArray(e.blockers)?e.blockers:[])de(t,x(n)?.blocked_by);l_(e,t)}function l_(e,t){for(let o of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=x(o);de(t,i?.id),Ua(t,i?.children)}for(let o of["files","workload"])for(let i of Array.isArray(e[o])?e[o]:[])ja(t,x(i)?.items);let n=x(e.agenda);for(let o of Array.isArray(n?.events)?n.events:[])de(t,x(o)?.item_id);let r=x(e.tests);ja(t,r?.items_failing)}function u_(e,t){let n=x(e);if(n===null||Fa(e))return[];let r=new Set;return t==="next"?c_(n,r):d_(n,r),[...r]}async function Pk(e){let t=a_(e.result);if(t===null)return!1;let n=Fa(e.result);return await f_({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:u_(e.result,t.surface),resultOmitted:n}),!0}async function $k(e){if([process.env.PM_CONTEXT_USAGE_DISABLED==="1",e.enabled===!1].includes(!0))return null;if(!e.author.trim()||e.rows.some(o=>!o.id.trim()||!Number.isInteger(o.rank)||o.rank<1))throw new T("Context usage serving requires an author and valid ranked rows");let t=e.rows.map(o=>({id:o.id.trim(),rank:o.rank,included:o.included}));if(new Set(t.map(o=>o.id)).size!==t.length)throw new T("Context usage serving requires unique normalized row ids");let n=t.slice(0,X.max_serving_rows),r={serve_id:i_(),author:e.author.trim(),surface:e.surface,rows:t,recorded_item_ids:n.map(o=>o.id)};return r.storage=await ht(e,[{kind:"serve",schema_version:2,serve_id:r.serve_id,at:Ae(e).iso,author:e.author.trim(),surface:e.surface,profile:e.profile.trim()||"balanced",rows:n,candidate_count:t.length,omitted_row_count:t.length-n.length,result_omitted:!1,packed_item_ids:n.filter(o=>o.included).map(o=>o.id)}]),r}async function f_(e){if(e.receipt===null||process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return;let t=new Set(e.receipt.rows.map(i=>i.id)),n=[...new Set(e.deliveredItemIds.map(i=>i.trim()))];if(n.some(i=>i.length===0||!t.has(i))||e.resultOmitted&&n.length>0)throw new T("Context usage delivery requires emitted ranked ids and zero ids for an omitted result");let r=new Set(e.receipt.recorded_item_ids??e.receipt.rows.map(i=>i.id)),o={kind:"delivery",schema_version:2,serve_id:e.receipt.serve_id,at:Ae(e).iso,author:e.receipt.author,surface:e.receipt.surface,result_omitted:e.resultOmitted,delivered_item_ids:n.filter(i=>r.has(i))};await ht(e,[o],o.serve_id)}async function Mk(e){if(!(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)){if(!e.author.trim()||!e.itemId.trim()||!e.intent.trim())throw new T("Context usage touch requires author, itemId, and intent");await ht(e,[{kind:"touch",at:Ae(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function Lk(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1||e.itemIds.length===0)return;let t=e.author.trim(),n=e.intent.trim();if(!t||!n)throw new T("Context usage touch requires author and intent");let r=new Set;for(let s of e.itemIds){if(typeof s!="string")throw new T("Context usage touch requires string itemIds");let a=s.trim();if(!a)throw new T("Context usage touch requires non-empty itemId");r.add(a)}let o=Ae(e).iso,i=[...r].map(s=>({kind:"touch",at:o,author:t,item_id:s,intent:n}));await ht(e,i)}function m_(e,t,n,r){return e.find(({entry:o,time:i})=>o.item_id===t&&i>=n&&i-n<=r)?.time}function p_(e,t){let n=new Map;for(let r of e)r.kind==="delivery"&&r.schema_version===2&&r.author===t&&!n.has(r.serve_id)&&n.set(r.serve_id,r);return n}async function jk(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return{affinity:{},positive_judgments:0,serving_events:0,untrusted_serving_events:0};let t=await yn(e),n=Ae(e).ms,r=(e.horizonHours??24)*36e5;if(![Number.isFinite(r),r>0].every(Boolean))throw new T("Context usage horizonHours must be positive");let o=e.author.trim(),i=t.filter(u=>u.kind==="touch").filter(u=>u.author===o).map(u=>({entry:u,time:Date.parse(u.at)})),s=new Map,a=0,c=0,d=0,l=p_(t,o);t.filter(u=>u.kind==="serve").filter(u=>u.author===o).forEach(u=>{if(![u.schema_version===2,!!u.serve_id].every(Boolean)){c+=1;return}a+=1;let f=Date.parse(u.at),p=l.get(u.serve_id),_=new Set(p?.delivered_item_ids??[]);for(let y of u.rows){if(!_.has(y.id))continue;let b=m_(i,y.id,f,r);if(b===void 0)continue;d+=1;let k=Math.max(0,(n-b)/s_);s.set(y.id,(s.get(y.id)??0)+Math.exp(-k/14))}});let m=Math.max(0,...s.values());return{affinity:Object.fromEntries([...s.entries()].map(([u,f])=>[u,m===0?.05:.05+.95*f/m])),positive_judgments:d,serving_events:a,untrusted_serving_events:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4c8b43ab-cada-5adf-8c00-aed8de1a8bc1")}catch{}})();var g_="limit_overridden_by_intent",Ba=Object.freeze([{command:"context",intent:"orient",description:"Bounded active hierarchy, ownership, blockers, and recent progress.",included_field_groups:["summary","focus","hierarchy","blockers","activity"],token_budget:3e3,source:"core"},{command:"context",intent:"handoff",description:"Active ownership, evidence, decisions, and immediate continuation context.",included_field_groups:["summary","focus","in_progress","decisions","activity"],token_budget:2200,source:"core"},{command:"get",intent:"inspect",description:"Standard-depth item metadata, relationships, evidence, and lifecycle state.",included_field_groups:["item","children","claim_state","linked"],token_budget:3200,source:"core"},{command:"list",intent:"triage",description:"A budget-derived page of compact governance, ownership, priority, and blocker rows for triage.",included_field_groups:["identity","governance","ownership","dependencies"],token_budget:3200,source:"core"},{command:"next",intent:"execute",description:"The highest-ranked actionable work with concise ranking evidence.",included_field_groups:["recommended"],token_budget:1200,source:"core"},{command:"search",intent:"discover",description:"A budget-derived page of ranked canonical lineage candidates with compact match evidence.",included_field_groups:["identity","status","lineage","match"],token_budget:1800,source:"core"}]),Va=new __;function y_(){return Va.getStore()??Ba}function Xk(e,t){return Va.run(b_(e.workspaceContracts,e.packageContracts),t)}function h_(e,t){let n=e.command.trim().toLowerCase(),r=e.intent.trim().toLowerCase(),o=`${n}:${r}`;if(!/^[a-z0-9][a-z0-9-]*$/.test(n)||!/^[a-z0-9][a-z0-9-]*$/.test(r))throw new TypeError(`Invalid context intent command or name: ${o}`);if(e.description.trim().length===0)throw new TypeError(`Context intent ${o} requires a non-empty description`);if(!Number.isSafeInteger(e.token_budget)||e.token_budget<=0)throw new TypeError(`Context intent ${o} requires a positive integer token_budget`);let i=[...new Set(e.included_field_groups.map(s=>s.trim()).filter(Boolean))];if(i.length===0)throw new TypeError(`Context intent ${o} requires included_field_groups`);return{command:n,intent:r,description:e.description.trim(),included_field_groups:i,token_budget:e.token_budget,source:t}}function b_(e=[],t=[]){let n=[{source:"core",contracts:Ba,allowOverride:!1},{source:"package",contracts:t,allowOverride:!1},{source:"workspace",contracts:e,allowOverride:!0}],r=new Map,o=new Set;for(let i of n){o.clear();for(let s of i.contracts){let a=h_(s,i.source),c=`${a.command}:${a.intent}`;if(o.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);if(o.add(c),!i.allowOverride&&r.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);r.set(c,a)}}return[...r.values()].sort((i,s)=>i.command.localeCompare(s.command)||i.intent.localeCompare(s.intent))}function Ga(e,t,n=y_(),r=[]){let o=e.trim().toLowerCase(),i=t.trim().toLowerCase(),s=n.find(u=>u.command===o&&u.intent===i);if(s)return{...s,source:s.source??"core"};let a=n.filter(u=>u.command===o).map(u=>u.intent);if(a.length===0)return;let c=a.map(u=>{let f=Array.from({length:i.length+1},(p,_)=>_);for(let p=1;p<=u.length;p+=1){let _=f[0];f[0]=p;for(let y=1;y<=i.length;y+=1){let b=f[y];f[y]=Math.min(f[y]+1,f[y-1]+1,_+(u[p-1]===i[y-1]?0:1)),_=b}}return{candidate:u,distance:f[i.length]}}).sort((u,f)=>u.distance-f.distance||u.candidate.localeCompare(f.candidate))[0].candidate,d=[o,...r,"--for",i],l=[o,...r,"--for",c],m=tn(l);throw new h(`Unknown context intent "${i}" for ${o}. Did you mean "${c}"?`,g.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:i,required:`Use a declared ${o} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[m],recovery:{recovery_mode:"compact",attempted_command:tn(d),allowed_values:[...a].sort(),suggested_retry:m,suggested_retry_args:l}})}function Zr(e,t){let n=Ve(e.limit),r=String(n===void 0?t:Math.min(n,t));return(e.limit===void 0||n!==void 0)&&(e.limit=r),r}var Wa={context:(e,t,n)=>{e.section===void 0&&e.depth===void 0&&(e.section=t.intent==="handoff"?["activity","progress","blockers"]:["hierarchy","blockers","activity"]),e.depth===void 0&&(e.depth=t.intent==="handoff"?"deep":"standard");let r=vn(e.tokenBudget,t.token_budget),o=En("context",t.intent,r,n),i=Zr(e,o);e.activityLimit===void 0&&(e.activityLimit=i)},get:e=>{e.depth===void 0&&e.fields===void 0&&(e.depth="standard")},list:(e,t,n)=>{e.brief===void 0&&e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");let r=vn(e.tokenBudget,t.token_budget),o=En("list",t.intent,r,n);Zr(e,o)},next:e=>{e.readyOnly===void 0&&(e.readyOnly=!0)},search:(e,t,n)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let r=vn(e.tokenBudget,t.token_budget),o=En("search",t.intent,r,n);Zr(e,o)}};function Jk(e,t,n=[]){let r=t.tokenBudget??t.token_budget;if(typeof t.for!="string"){if(r!==void 0&&(e==="get"||e==="list"||e==="search"))throw new h("--token-budget requires a declared context intent selected with --for",g.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(t.tokenBudget!==void 0||t.token_budget===void 0)return t;let a={...t,tokenBudget:r};return delete a.token_budget,a}let o=Ga(e,t.for,void 0,n),i=Ve(r)!==void 0,s={...t};return s.tokenBudget===void 0&&r!==void 0&&(s.tokenBudget=r),delete s.token_budget,s.tokenBudget===void 0&&(s.tokenBudget=String(o.token_budget)),Wa[e](s,o,i),s}var w_={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},wn=256;function eo(e){return Array.isArray(e)?e.map(eo):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,eo(n)])):typeof e=="string"&&e.length>240?`${ie(e,240)}\u2026`:e}function Ve(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/u.test(e.trim())?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function vn(e,t){let n=Ve(e);if(n===void 0)return t;if(n<wn)throw new h(`Context intent token budget must be at least ${wn}`,g.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(e),required:`Use an integer token budget of at least ${wn}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${wn} or omit the override.`]});return n}function Ka(e,t){return e==="context"?e==="context"&&t==="orient"?{overhead:1200,rowCost:600}:{overhead:800,rowCost:500}:{overhead:e==="list"?520:480,rowCost:16}}function En(e,t,n,r){if(e==="get"||e==="next")return;let{overhead:o,rowCost:i}=Ka(e,t),s=Math.max(e==="context"?1:2,Math.floor((n-o)/i));return r?s:Math.min(e==="context"?20:100,s)}function le(e,t){let n=t.estimated_tokens;for(;;){t.estimated_tokens=n;let r=Math.ceil(Buffer.byteLength(JSON.stringify(e),"utf8")/4);if(r===n)return;n=r}}var za={context:["high_level","low_level","blocked_fallback","recently_created","unparented","hierarchy","activity","blockers"],get:["children"],list:["items"],next:["ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items"]};function Ha(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof t.fingerprint!="string"||!Number.isSafeInteger(t.after_index)?void 0:{fingerprint:t.fingerprint,after_index:t.after_index,...typeof t.snapshot=="string"?{snapshot:t.snapshot}:{}}}catch{return}}function v_(e){if(e===null||typeof e!="object")return;if(typeof e.id=="string")return e.id;let t=e.item?.id;return typeof t=="string"?t:void 0}function E_(e,t,n){let r=!1;for(;;){if(le(e,t),t.estimated_tokens<=t.token_budget||n.length<=1)return r;let o=Buffer.byteLength(JSON.stringify(n),"utf8"),i=(t.estimated_tokens-t.token_budget)*4;n.splice(-Math.min(n.length-1,Math.max(1,Math.ceil(i/Math.max(1,Math.ceil(o/n.length)))))),r=!0}}function k_(e,t,n){let r=e.items,o=typeof e.next_cursor=="string",i=o?e.next_cursor:n.after;if(!Array.isArray(r)||typeof i!="string")return!1;let s=Ha(i);if(s===void 0)return!1;let a=r.length,c=[...r],d=!1;for(;;){if(d=E_(e,t,r)||d,!d)return!1;let l=v_(r.at(-1));if(l===void 0)return r.splice(0,r.length,...c),le(e,t),!1;if(e.next_cursor=yt(s.fingerprint,l,o?s.after_index-(a-r.length):s.after_index+r.length,s.snapshot),le(e,t),t.estimated_tokens<=t.token_budget||r.length<=1)break}return typeof e.count=="number"&&(e.count=r.length),typeof e.applied_limit=="number"&&(e.applied_limit=r.length),!0}function O_(e,t,n,r){if(e==="list"||e==="search")return k_(t,n,r);if(e!=="next"||typeof t.next_cursor=="string")return!1;let o=!1;for(;;){if(le(t,n),n.estimated_tokens<=n.token_budget)return o;let i=za[e].map(u=>({key:u,rows:Array.isArray(t[u])?t[u]:[]})).filter(({rows:u})=>u.length>0).sort((u,f)=>f.rows.length-u.rows.length||u.key.localeCompare(f.key))[0];if(i===void 0)return o;let s=za[e].reduce((u,f)=>u+(Array.isArray(t[f])?t[f].length:0),0);if(s<=1)return o;let a=Math.min(i.rows.length,s-1),c=Buffer.byteLength(JSON.stringify(i.rows),"utf8"),d=Math.max(1,Math.ceil(c/i.rows.length)),l=(n.estimated_tokens-n.token_budget)*4,m=Math.min(a,Math.max(1,Math.ceil(l/d)));i.rows.splice(-m,m),o=!0}}function S_(e,t,n){if(typeof t.for!="string")return n;let r=e.startsWith("list-")?"list":e;if(!(r in Wa))return n;let o=r,i=Ga(o,t.for),s=vn(t.tokenBudget??t.token_budget,i.token_budget),a={command:o,intent:i.intent,source:i.source,included_field_groups:[...i.included_field_groups],token_budget:s,declared_token_budget:i.token_budget,token_budget_override:s-i.token_budget,estimated_tokens:0,within_budget:!0,degradation:w_[o],declaration_feasible:!0,result_omitted:!1},c={...n},d=En(o,i.intent,a.token_budget,Ve(t.tokenBudget??t.token_budget)!==void 0);if(d!==void 0){let m=Ve(t.limit),u=m!==void 0&&m<d;a.budget_derived_limit=d,a.binding_constraint=u?"explicit_limit":"token_budget",a.limit_reason=u?"The caller supplied a smaller row limit than the budget-derived ceiling.":"The selected intent token budget constrains the effective row ceiling.",c.budget_derived_limit=d,T_({builtInCommand:o,intent:i.intent},a,c,t)}let l={...c,context_intent:a};return le(l,a),a.estimated_tokens>a.token_budget&&(a.degradation="recursive_budget_compaction",l={...eo(c),context_intent:a},le(l,a)),a.estimated_tokens>a.token_budget&&O_(o,l,a,t)&&(a.degradation="budget_row_compaction",le(l,a)),a.declaration_feasible=a.estimated_tokens<=a.declared_token_budget,a.estimated_tokens>a.token_budget&&(a.degradation="budget_receipt_only",a.result_omitted=!0,a.within_budget=!1,l={budget_exceeded:{omitted_result:!0,reason:a.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:R_(e,o,i.intent,a,c)},context_intent:a}),l}var A_=["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"];function C_(e,t){if(typeof e.after!="string"||e.after.length===0)return t;let n=Ha(e.after)?.fingerprint??"opaque_cursor",r={...t};for(let o of A_)delete r[o];return r.continuation_contract={fingerprint:n,metadata:"reference",restore_with:"omit --after"},r}function kn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function I_(e,t){let n=e==="get"&&kn(t.item)&&typeof t.item.id=="string"?t.item.id:e==="search"&&typeof t.query=="string"?t.query:void 0;return n===void 0?"":` '${n.replaceAll("'",`'"'"'`)}'`}function T_(e,t,n,r){let o=Ve(r.limit),i=t.budget_derived_limit;if(o===void 0||o<=i)return;let{overhead:s,rowCost:a}=Ka(e.builtInCommand,e.intent),c=Math.max(t.token_budget,s+a*o);t.limit_reason=`The ${t.token_budget}-token ${e.intent} budget carries ${i} rows, so it reduced the caller's --limit ${o}.`,t.limit_override={flag:"--limit",requested:o,effective:i,...Number.isSafeInteger(c)?{token_budget_for_requested:c,restore_with:`--token-budget ${c}`}:{}};let d=`${g_}:--limit ${o}->${i}`;n.warnings=Array.isArray(n.warnings)?[...n.warnings,d]:[d],kn(n.filters)&&(n.filters={...n.filters,requested_limit:String(o)})}function R_(e,t,n,r,o){let i=I_(t,o),s=t==="get"?"":` --limit ${r.budget_derived_limit??1}`;return`pm ${e}${i} --for ${n} --token-budget ${Math.ceil(r.estimated_tokens/100)*100}${s}`}function Be(e,t){if(kn(e))return typeof e[t]=="number"?e[t]:void 0}function x_(e,t){let n=e;for(let r=0;r<8;r+=1){let o=Be(n.context_intent,"estimated_tokens"),i=Be(n.read_output,"estimated_tokens"),s=Be(n.read_session,"spent_this_call_tokens");if(kn(n.context_intent)&&le(n,n.context_intent),n=to(n,t),Be(n.context_intent,"estimated_tokens")===o&&Be(n.read_output,"estimated_tokens")===i&&Be(n.read_session,"spent_this_call_tokens")===s)break}return n}function N_(e,t,n){let r=Bs(e,Vs(e??"",n)),o=typeof r=="object"&&r!==null&&!Array.isArray(r)?qa(e??"",{...t,outputRowContract:t.outputRowContract===!0||t.output_row_contract===!0},C_(t,S_(e??"",t,r))):r;if(bn(n,o),t.outputRowContract===!0||t.output_row_contract===!0||typeof o!="object"||o===null||Array.isArray(o)||!Object.hasOwn(o,"row_contract"))return o;let i=Object.fromEntries(Object.entries(o).filter(([a])=>a!=="row_contract"));Object.defineProperty(i,"row_contract",{value:o.row_contract,enumerable:!1,configurable:!0});let s=x_(i,t);return delete s.row_contract,bn(o,s),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cb1266f3-8375-586f-87c6-356cf7843969")}catch{}})();var Ge=["result_rows","envelope","diagnostics","hints"],D_=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,P_=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,$_=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,M_=8;function no(e){return Buffer.byteLength(e,"utf8")}function Ya(e){return no(JSON.stringify(e)??"null")}function L_(e,t){return P_.test(e)?"diagnostics":$_.test(e)?"hints":D_.test(e)||Array.isArray(t)?"result_rows":"envelope"}function j_(e){let t={result_rows:0,envelope:0,diagnostics:0,hints:0};if(typeof e!="object"||e===null||Array.isArray(e))return t[Array.isArray(e)?"result_rows":"envelope"]=Ya(e),t;for(let[n,r]of Object.entries(e))t[L_(n,r)]+=Ya({[n]:r});return Object.values(t).every(n=>n===0)&&(t.envelope=1),t}function F_(e,t){let n=Ge.reduce((s,a)=>s+t[a],0),r=Ge.map(s=>({section:s,value:e*t[s]/n})),o={result_rows:0,envelope:0,diagnostics:0,hints:0};for(let s of r)o[s.section]=Math.floor(s.value);let i=e-Ge.reduce((s,a)=>s+o[a],0);for(let s of[...r].sort((a,c)=>c.value-Math.floor(c.value)-(a.value-Math.floor(a.value))||Ge.indexOf(a.section)-Ge.indexOf(c.section))){if(i===0)break;o[s.section]+=1,i-=1}return o}function Xa(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function U_(e,t){let n=no(t(e)),r=F_(n,j_(e)),o=Object.fromEntries(Ge.map(a=>[a,{bytes:r[a],estimated_tokens:ke(r[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:n,total_estimated_tokens:ke(n),sections:o,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=Xa(e,i);for(let a=0;a<M_;a+=1){let c=no(t(s))-n;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:ke(c)},s=Xa(e,i)}return s}import{encode as io}from"@toon-format/toon";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d3d21124-3c8a-5049-803d-00c63c0c2b61")}catch{}})();function Ja(e,t={}){let n=[...new Set(e.flatMap(l=>Object.keys(l)))],r=t.compact?n.filter(l=>e.every(m=>Object.hasOwn(m,l)&&m[l]===null)):[],o=t.compact?n.filter(l=>e.every(m=>{if(!Object.hasOwn(m,l))return!0;let u=m[l];return Array.isArray(u)&&u.every(f=>typeof f=="string"&&f!==""&&!f.includes(";"))})):[],i=new Set(o),s=new Set(r),a=n.filter(l=>!i.has(l)&&e.some(m=>{let u=m[l];return u!==null&&typeof u=="object"})),c=new Set(a),d=[];return{rows:e.map((l,m)=>Object.fromEntries(n.filter(u=>!s.has(u)).map(u=>{if(!Object.hasOwn(l,u))return d.push([m,u]),[u,null];let f=l[u];return i.has(u)?[u,f.join(";")]:[u,c.has(u)?JSON.stringify(f):f]}))),encoding:{json_columns:a,absent:d,...o.length?{list_columns:Object.fromEntries(o.map(l=>[l,";"]))}:{},...r.length?{null_columns:r,null_column_index:r.map(l=>n.indexOf(l))}:{}}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0841394b-c439-5002-8451-c538a17acf47")}catch{}})();function J(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function z_(e){if(!J(e))return!1;let t=e.fields;return e.mode==="brief"&&Object.keys(e).length===2&&Array.isArray(t)&&(t.length===qt.length||t.length===qt.length+1&&t.at(-1)==="priority")&&qt.every((n,r)=>t[r]===n)}function Qa(e,t){return typeof e.has_more=="boolean"&&e.truncated===e.has_more&&e.count===t&&typeof e.total=="number"&&Number.isSafeInteger(e.total)&&(e.has_more?e.total>t&&typeof e.next_cursor=="string"&&e.next_cursor.length>0:e.total===t&&e.next_cursor==null)}function q_(e){return J(e)&&(e.status==="complete"||e.status==="unchecked")&&e.unreadable_item_count===0&&e.unreadable_directory_count===0}function Za(e,t="full_item_fields"){if(!J(e)||!Array.isArray(e.omitted_field_groups))return!1;let n=e.omitted_field_groups,r=n[0];return e.has_omissions===!0&&e.omitted_field_group_count===1&&Object.keys(e).length===3&&n.length===1&&J(r)&&Object.keys(r).length===2&&r.name===t&&r.restore_with==="--full"}function ec(e){if(!J(e)||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!z_(e.projection)||!q_(e.completeness)||!Qa(e,e.items.length)||!Za(e.omission_receipt))return e;let{total:t,has_more:n,truncated:r,next_cursor:o,completeness:i,projection:s,now:a,omission_receipt:c,sorting:d,filters:l,...m}=e,u=i.status==="complete"&&!n&&Object.keys(i).length===3,{unreadable_item_count:f,unreadable_directory_count:p,..._}=i;return{...m,...u?{}:{total:t,has_more:n,completeness:_},...n?{next_cursor:o}:{},...G_(d),...tc(l,m.applied_limit),details:"--full"}}function B_(e){return J(e)&&e.sort==="default"&&e.order==="asc"&&Object.keys(e).every(t=>t==="sort"||t==="order"||t==="effective_keys")}function V_(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&(e[1]==="asc"||e[1]==="desc")}function G_(e){if(!B_(e))return{sorting:e};let t=e.effective_keys;return t===void 0?{}:!Array.isArray(t)||!t.every(V_)?{sorting:e}:{sorting:{effective_keys:t.map(([n,r])=>`${n} ${r}`).join(", ")}}}function tc(e,t){if(!J(e))return e===void 0?{}:{filters:e};let n=Object.fromEntries(Object.entries(e).filter(([r,o])=>!(r==="limit"&&String(o)===String(t))&&!(r==="runtime_filters"&&J(o)&&Object.keys(o).length===0)));return Object.keys(n).length===0?{}:{filters:n}}function W_(e,t){return e.count===t&&!Object.hasOwn(e,"has_more")&&!Object.hasOwn(e,"truncated")&&e.next_cursor==null&&(e.total===void 0||e.total===t)}function nc(e){if(!J(e)||typeof e.query!="string"||!Array.isArray(e.items)||Object.hasOwn(e,"details")||Object.hasOwn(e,"projection")||!(Qa(e,e.items.length)||W_(e,e.items.length))||!Za(e.omission_receipt,"projection_metadata"))return e;let{truncated:t,omission_receipt:n,filters:r,...o}=e;return{...o,...tc(r,o.applied_limit),details:"--full"}}import{isBoxedPrimitive as K_}from"node:util/types";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b399abd-460a-55a5-9df2-db23537aac0d")}catch{}})();var rc=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/gu;function a0(e){return e.replaceAll(rc,"\uFFFD")}function H_(e,t,n){return n&&/^\d+$/u.test(t)?`${e}[${t}]`:/^[A-Za-z_$][\w$]*$/u.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function ro(e,t,n){if(typeof e=="string"){let r=e.search(rc);return r<0?void 0:{field:t,index:r}}if(!(e===null||typeof e!="object"||n.has(e))){n.add(e);for(let[r,o]of Object.entries(e)){let i=H_(t,r,Array.isArray(e)),s=ro(r,`${i} (key)`,n)??ro(o,i,n);if(s)return s}}}function oc(e,t,n){if(e===null||typeof e!="object")return e;if(K_(e)||typeof e.toJSON=="function")return JSON.parse(JSON.stringify({[t]:e}))[t];if(n.has(e))return n.get(e);let r=Array.isArray(e)?new Array(e.length):{};n.set(e,r);for(let o of Object.keys(e))Object.defineProperty(r,o,{value:oc(e[o],o,n),enumerable:!0,configurable:!0,writable:!0});return r}function oo(e){let t=oc(e,"",new WeakMap),n=ro(t,"$",new WeakSet);return n&&Y_(n),t}function Y_(e){throw new h(`Output field ${e.field} contains an unpaired surrogate code unit at index ${e.index}; structured output requires well-formed Unicode.`,g.USAGE,{code:"text_unpaired_surrogate",field:e.field,required:"Well-formed UTF-16 strings and object keys in both JSON and TOON output.",nextSteps:["Repair the producer's text before returning output; use toWellFormedText from @unbrained/pm-cli/sdk when replacement is intended."]})}function c0(e){oo(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]="d47af602-51bb-592c-8dce-3de5c8a96636")}catch{}})();var S0=new Set(Object.values(g)),Q_=new Map([["notes_count","notes"],["tests_count","tests"]]);var ic=!1;function F(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function so(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function Z_(){(process.exitCode===void 0||process.exitCode===g.SUCCESS)&&(process.exitCode=g.SUCCESS)}function eg(){(process.exitCode===void 0||process.exitCode===g.SUCCESS)&&(process.exitCode=g.GENERIC_FAILURE)}function ao(e){if(e==="stdout"){Z_();return}eg()}function sc(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function tg(){ic||(ic=!0,process.stdout.on("error",e=>{if(so(e)){ao("stdout");return}sc(e)}),process.stderr.on("error",e=>{if(so(e)){ao("stderr");return}sc(e)}))}function ng(e,t){tg();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(n){if(so(n))return ao(e),!1;throw n}}function rg(e){return ng("stderr",e)}function ac(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function co(e,t){let n=" ".repeat(t);return e.split(`
|
|
17
|
-
`).map(r=>`${n}${r}`).join(`
|
|
18
|
-
`)}function og(e){let t=new Set,n=0;for(let r of e){let o=Object.keys(r);n+=o.length;for(let i of o)t.add(i)}return e.length*t.size<=n*2}function ig(e,t,n,r){let o=" ".repeat(n);if(!F(t)&&!Array.isArray(t))return`${o}${e}: ${ac(t)}`;if(Array.isArray(t)){if(t.length===0)return`${o}${e}: []`;let i=co(io({[e]:t}),n);return r&&t.length>=1&&t.every(F)&&og(t)?[!1,!0].map(s=>{let a=Ja(t,{compact:s});return co(io({[e]:a.rows,[`${e}_encoding`]:a.encoding}),n)}).reduce((s,a)=>Buffer.byteLength(a)<Buffer.byteLength(s)?a:s,i):i}return F(t)&&Object.keys(t).length===0?`${o}${e}: {}`:`${o}${e}:
|
|
19
|
-
${cc(t,n+1)}`}function sg(e,t,n){let r=e.map(o=>On(o,t,n||t.preserveRowFacts&&F(o))).filter(o=>o!==void 0);return r.length>0||n?r:void 0}function On(e,t={omitDuplicateCountAliases:!0,preserveRowFacts:!0},n=!1){if(e===null)return n?null:void 0;if(Array.isArray(e))return sg(e,t,n);if(F(e)){let r=[],o=Object.entries(e).filter(([i,s])=>{let a=Q_.get(i);return!t.omitDuplicateCountAliases||a===void 0||!F(e.collection_counts)||s!==e.collection_counts[a]});for(let[i,s]of o){if(i==="omitted_field_groups"&&Array.isArray(s)&&s.length===0){r.push([i,[]]);continue}let a=On(s,t,n);a!==void 0&&r.push([i,a])}return r.length>0||n?Object.fromEntries(r):void 0}return e}function cc(e,t){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":co(io(e),t);if(F(e)){let r=Object.entries(e);return r.length===0?"{}":r.map(([o,i])=>ig(o,i,t,!Object.hasOwn(e,`${o}_encoding`)&&!(o==="checks"&&F(e.verdict)&&e.verdict.authority==="ok"))).join(`
|
|
20
|
-
`)}return`${n}${ac(e)}`}var ag=new Set(["filters","now","projection","sorting"]);function cg(e){let t=On(e,{omitDuplicateCountAliases:!1,preserveRowFacts:!1});if(!F(t)||!Array.isArray(t.items))return t??null;let n=Object.fromEntries(Object.entries(t).filter(([r])=>!ag.has(r)));return n.has_more!==!0&&delete n.next_cursor,n}function dg(e){return!F(e)||e.ok!==!0||!F(e.verdict)||e.verdict.authority!=="ok"||!Array.isArray(e.checks)?e:{...e,checks:e.checks.map(lg)}}function lg(e){if(!F(e)||e.ok!==!0||!F(e.details)||Object.keys(e.details).length!==0)return e;let{details:t,...n}=e;return n}function dc(e,t,n=!1){if(e=oo(e),t==="json"){let o=n?cg(e):e,i=F(e)&&F(e.projection)&&e.projection.mode==="brief"&&Array.isArray(e.items);return`${JSON.stringify(o,null,i?void 0:2)}
|
|
21
|
-
`}let r=On(dg(nc(ec(e))),{omitDuplicateCountAliases:!0,preserveRowFacts:!0});return r===void 0?`{}
|
|
22
|
-
`:`${cc(r,0)}
|
|
23
|
-
`}function A0(e){let t=Ds("error_format",{message:e}),n=t.handled&&typeof t.result=="string"?t.result:e;rg(n.endsWith(`
|
|
24
|
-
`)?n:`${n}
|
|
25
|
-
`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="13e57322-501d-5927-8254-f6196854d434")}catch{}})();var ug=8,fg=64,mg=5,pg=4,lc=100;function uc(e,t,n){if(e!=="get"||!lo(n.item)||["fields","outputInclude","output_include","outputCursor","output_cursor"].some(c=>t[c]!==void 0)||t.full===!0||t.tree===!0||t.depth!==void 0&&t.depth!=="standard")return;let r=n.item,o=["linked","claim_state","schedule"],i=o.filter(c=>Object.hasOwn(n,c)),s=Object.fromEntries(Object.entries(n).filter(([c])=>!o.includes(c)));s.item=Object.fromEntries(Object.entries(r).filter(([c])=>c!=="body")),Object.hasOwn(r,"body")&&i.push("body");let a=[...lo(n.omission_receipt)&&Array.isArray(n.omission_receipt.omitted_field_groups)?n.omission_receipt.omitted_field_groups:[],...i.map(c=>({name:c,restore_with:`--fields ${c}`}))];return s.omission_receipt={has_omissions:a.length>0,omitted_field_group_count:a.length,omitted_field_groups:a},s}function fo(e){let t=Math.trunc(e.effective_budget_tokens),n=Math.trunc(e.measured_result_tokens);if(!Number.isSafeInteger(t)||t<=0||!Number.isSafeInteger(n)||n<=0)return{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"};let r=Math.max(t+1,n),o=Math.ceil(r*mg/pg),i=Math.ceil(o/lc)*lc;return Number.isSafeInteger(i)?{output_budget:i,recovery_budget_multiplier:i/t,rule_version:"v1"}:{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"}}function We(e,t,n=!1){let r=Object.getOwnPropertyDescriptor(e,"row_contract");r&&(n||r.enumerable===!1)&&Object.defineProperty(t,"row_contract",{...r,enumerable:!1})}function bt(e,t){let n=t===void 0?JSON.stringify(e):dc(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function lo(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function uo(e,t,n=!1){return typeof e=="string"?n||e.length<=240?e:(t.compacted=!0,`${ie(e,240)}\u2026`):Array.isArray(e)?e.map(r=>uo(r,t,n)):lo(e)?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,uo(o,t,n||r==="focus_row_states")])):e}function ue(e,t,n){let r=t.estimated_tokens;for(let o=0;o<ug;o+=1){t.estimated_tokens=r;let i=bt(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function _g(e,t){return ut(e).filter(n=>(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length)>Math.max(1,t.get(n.path)??0)).map(n=>({collection:n,length:Array.isArray(n.value)?n.value.length:Object.keys(n.value).length})).sort((n,r)=>r.length-n.length||n.collection.path.localeCompare(r.collection.path))[0]?.collection}function gg(e,t,n,r,o,i){for(let s=0;s<fg;s+=1){if(i?.(e),ue(e,t,o),t.estimated_tokens<=n)return;let a=_g(e,r);if(!a)return;let c=Math.max(1,r.get(a.path)??0),d=Array.isArray(a.value)?[...a.value]:Object.entries(a.value),l=p=>{if(Array.isArray(a.value)){a.value.length=p;for(let _=0;_<p;_+=1)a.value[_]=d[_]}else{for(let _ of Object.keys(a.value))delete a.value[_];Object.defineProperties(a.value,Object.getOwnPropertyDescriptors(Object.fromEntries(d.slice(0,p))))}typeof e.count=="number"&&(e.count=on(e)),a.path==="items"&&(e.applied_limit=p),i?.(e),ue(e,t,o)};t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],a.path])].sort((p,_)=>p.localeCompare(_)),e.has_more=!0,e.truncated=!0;let m=c,u=d.length-1,f=c;for(;m<=u;){let p=Math.floor((m+u)/2);l(p),t.estimated_tokens<=n?(f=p,m=p+1):u=p-1}l(f)}}function fc(e,t,n,r=new Map,o,i,s=!1){let a={compacted:!1},c=Object.fromEntries(Object.entries(e).map(([d,l])=>[d,uo(l,a,s&&d==="diff")]));return We(e,c),t.strings_compacted=a.compacted,c.read_output=t,gg(c,t,n,r,o,i),ue(c,t,o),c}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="24a8de41-54f9-5b59-8e58-7ac924ba6e08")}catch{}})();function M0(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"&&"context_ref"in e&&typeof e.context_ref=="string"&&e.context_ref.startsWith("session:")&&e.context_ref.endsWith(`:${e.id}`)}var mo=256,po=1e4,yg=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,mc=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,hg=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),bg=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&yg.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=mo,reason:`token_budget must be a safe integer of at least ${mo}.`},{valid:e=>Number.isSafeInteger(e.spent_tokens)&&e.spent_tokens>=0&&e.spent_tokens<=e.token_budget,reason:"spent_tokens must be a non-negative safe integer no larger than token_budget."},{valid:e=>Array.isArray(e.seen_item_ids)&&e.seen_item_ids.length<=po&&e.seen_item_ids.every(t=>typeof t=="string"&&mc.test(t)),reason:`seen_item_ids must contain at most ${po} portable item identifiers.`}];function An(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Sn(e){throw new h(`--output-session ${e}`,g.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function Cn(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{Sn("must be a valid JSON object.")}An(t)||Sn("must be a JSON object.");let n=Object.keys(t).filter(i=>!hg.has(i));n.length>0&&Sn(`contains unknown field "${n.sort()[0]}".`);let r=bg.find(i=>!i.valid(t));r!==void 0&&Sn(r.reason);let o=[...new Set(t.seen_item_ids)].sort();return{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:o}}function pc(e){if(An(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:An(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function wg(e){let t=new Set,n=0,r=ae(e),o=new Set(r.map(({path:s})=>s)),i=Object.entries(e).flatMap(([s,a])=>Array.isArray(a)&&!o.has(s)?[{path:s,value:a}]:[]);for(let s of[...r,...i]){let a=Array.isArray(s.value)?s.value:Object.values(s.value);for(let c of a){if(!An(c))continue;if(typeof c.context_ref=="string"){n+=1;continue}let d=pc(c);d!==void 0&&mc.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:n}}function _c(e,t){let n=new Set(t.seen_item_ids);return ft(e,r=>{let o=pc(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function _o(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=wg(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,po-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),d=s.length-a.length,l={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:r.size,...d===0?{}:{seen_item_overflow_count:d},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --depth brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:c}},m={...e,read_session:l},u=_=>{l.spent_this_call_tokens=_,l.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,_),l.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+l.charged_this_call_tokens),l.remaining_tokens=Math.max(0,t.token_budget-l.spent_total_tokens),l.exhausted=l.remaining_tokens<mo,l.next_state.spent_tokens=l.spent_total_tokens},f=0,p=0;for(let _=0;_<8;_+=1){u(f);let y=bt(m,n);if(y===f)return m;p=Math.max(p,y),f=y}return u(p),m}function gc(e){return Math.max(0,e.token_budget-e.spent_tokens)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1cc0fcb7-2aaa-5233-bdfd-4b4d0fb3e9c1")}catch{}})();var wt=Symbol.for("pm.readOutputInvocationProvenance");function j0(e,t){return Reflect.set(e,wt,{canonical_include_modes:[...t],explicit_legacy_aliases:[],sdk_invocation_observed:!0}),e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dd173d3c-f3da-53f3-b24c-118364961db7")}catch{}})();var Ce=["include","amount","cost","encoding"],Ec=["canonical","legacy","intent","default"],Et=jt,nO=Object.freeze(Ce.map(e=>Et[e])),rO=Ft;function vg(e,t){let n=Qt[e];if(n!==void 0)return n;let r=t==="include"?Rr.has(e)?"<csv>":Zt(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${Et[t]} ${r}.`}function kc(e){let t=Tr[e]??{},n=Object.freeze(Object.fromEntries(Ce.map(r=>[r,Object.freeze({dimension:r,canonical_option:Et[r],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[r]??[]).map(o=>Object.freeze({flag:o,semantics:Qt[o]===void 0?"replacement":"behavior_preserving",migration_hint:vg(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:Ec,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...xr(e).keys()])})}var Eg=Object.freeze(ge.map(kc)),kg=new Map(Eg.map(e=>[e.command,e]));function Fe(e,t={}){let n=Qe(e.trim().toLowerCase()),r=Ir(n);return r!==void 0?r.read_output===void 0?void 0:`extension:${r.command}`:Gs(n,t)}var Og=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],Sg={comments:["add","body","stdin","file","edit","delete"],notes:["add","addJson","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function Ag(e){return Og.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var Cg=[{keys:["outputInclude","output_include"],valid:e=>vt(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||Ke(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||Ke(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(Cn(e),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:e=>typeof e=="string"&&e.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}];function oO(e,t){let n=t.outputFormat??t.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new h("--output-format must be toon or json.",g.USAGE);if(!Ag(t))return;let r=Fe(e,t);if(!r)throw new h(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,g.USAGE);if((Sg[r]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new h(`Universal output controls cannot be combined with a ${r} mutation.`,g.USAGE);for(let o of Cg){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new h(o.message,g.USAGE)}}function Oc(e){let t=Fe(e);return t?xr(t):new Map}function Ig(e,t,n){let r=vt(t)??[],o=Oc(e),i=[],s=[],a=n,c=a[wt],d=new Set(c?.canonical_include_modes??[]),l=new Set(c?.explicit_legacy_aliases??[]);for(let f of r){let p=o.get(f);if(p===void 0){i.push(f);continue}let _=`--${f.replaceAll("_","-")}`;yo(go(n,_))&&l.add(_),n[p]=!0,s.push(f),d.add(f)}let m=Fe(e)==="get"?i.filter(f=>f!=="item"):[],u=m.length>0;return u&&(n.fields=[...new Set([...vt(n.fields)??[],...m])].join(","),d.add("fields")),(s.length>0||u)&&(a[wt]={canonical_include_modes:[...d],explicit_legacy_aliases:[...l],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function iO(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=Ig(e,n,t);if(o.length===0)return;let i=r.length>0?r.join(","):void 0;t.outputInclude=i,Object.hasOwn(t,"output_include")&&(t.output_include=i)}function go(e,t){let n=Nr(t);if(Object.hasOwn(e,n))return e[n];let r=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,r))return e[r];if(t==="--no-truncate"&&e.truncate===!1)return!0}function yo(e){return e!==void 0&&e!==!1&&e!==null}function vt(e){let t=(Array.isArray(e)?e:[e]).flatMap(n=>typeof n=="string"?n.split(","):[]).map(n=>n.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function Ke(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/u.test(e.trim())?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function Tg(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=go(t,o.flag),s={value:i,flag:o.flag};if(yo(i)&&n(s))return s}}function yc(e,t){let n=vt(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:vt(t.value)??[Zt(t.flag)]}}function hc(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=Ke(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;if(t.flag==="--no-truncate"||t.flag==="--unbounded")return{source:"legacy",value:"unbounded"};let r=Ke(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function bc(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=Ke(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let r=Ke(t.value);return r===void 0?void 0:{source:"legacy",value:r}}function wc(e,t){if(e==="json"||e==="toon")return{source:"canonical",value:e};if(t)return t.flag==="--stream"||t.flag==="--follow"?{source:"legacy",value:"stream"}:t.value==="json"||t.value==="toon"?{source:"legacy",value:t.value}:void 0}function Sc(e,t,n){if(!e)return!1;let r=new Set(e.explicit_legacy_aliases);if(e.cli_invocation_observed===!0||e.sdk_invocation_observed===!0)return!r.has(n);let o=new Set(e.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return t==="include"&&o.has(n)&&!r.has(n)}function Rg(e,t,n,r){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||yo(go(r,"--no-truncate"))&&!Sc(n,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function xg(e,t){return Ce.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[Et[n]]:[])}function Ac(e,t){let n=Fe(e,t);if(!n)return;let r=kg.get(n)??kc(n),o=t[wt],i={include:b=>yc(void 0,b),amount:b=>hc(void 0,b),cost:b=>bc(void 0,b),encoding:b=>wc(void 0,b)},s=Object.fromEntries(Ce.map(b=>[b,Tg(r.dimensions[b],t,k=>i[b](k)!==void 0,k=>Sc(o,b,k))])),a=Ce.flatMap(b=>{let k=s[b];return k?[k.flag]:[]}),c=Ce.flatMap(b=>{let k=s[b];return k?[r.dimensions[b].legacy_aliases.find(U=>U.flag===k.flag).migration_hint]:[]}),d=wc(t.outputFormat??t.output_format,s.encoding),l=yc(t.outputInclude??t.output_include,s.include),m=hc(t.outputLimit??t.output_limit,s.amount),u=bc(t.outputBudget??t.output_budget,s.cost),f=Rg(e,s,o,t),p=Ls(e,{generateFallback:!0}),_=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",y=u??(f?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:l,amount:m,cost:y,encoding:d,canonical_options_used:xg({include:l,amount:m,cost:y,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:Ec}}function N(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var ho=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),Ng=["collection_counts","notes_count","tests_count"];function Cc(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function Dg(e){let t=N(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...Ng.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!ho.has(o)).sort((o,i)=>o.localeCompare(i));return{item:t,itemFields:n,sections:r,valid:[...n,"item",...n.map(o=>`item.${o}`),...r]}}function Pg(e,t){let n=Dg(e),r=t.filter(l=>!n.valid.includes(l));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,g.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:n.itemFields.includes(l)?[l]:[]).filter((l,m,u)=>u.indexOf(l)===m);if(o&&i.length>0)throw new h("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",g.USAGE);let s=new Set(t.filter(l=>n.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>ho.has(l)||s.has(l)));o?a.item=n.item:i.length>0&&(a.item=Cc(n.item,i));let c=[...o?[]:i.length>0?n.itemFields.filter(l=>!i.includes(l)).map(l=>({name:`item.${l}`,restore_with:`--output-include item.${l}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(l=>!s.has(l)).map(l=>({name:l,restore_with:`--output-include ${l}`}))],d=[...N(a.omission_receipt)&&Array.isArray(a.omission_receipt.omitted_field_groups)?a.omission_receipt.omitted_field_groups:[],...c];return a.omission_receipt={has_omissions:d.length>0,omitted_field_group_count:d.length,omitted_field_groups:d},a}function vc(e){let t=0;return ft({...e},n=>(N(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function $g(e,t,n,r){if(vc(t)===0||vc(n)>0)return;let o=[...Oc(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${r.join(", ")}. No selector matched any returned row field.${i}`,g.USAGE)}function Mg(e,t,n){if(e==="get")return Pg(t,n);let r=rn(t),o=n.flatMap(s=>r.flatMap(a=>s.startsWith(`${a}.`)?[s.slice(a.length+1)]:[])),i=n.some(s=>Object.hasOwn(t,s.split(".")[0])&&!r.some(a=>s.startsWith(`${a}.`)));if(r.length>0&&(!i||o.length>0)){let s={...t},a=o.length>0?o:n,c=ft(s,d=>N(d)?Cc(d,a):d);return $g(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||ho.has(s)))}function Lg(e,t){if(t==="unbounded")return e;let{result:n,truncated:r}=ia(e,t);if(!r)return n;if(n.has_more=!0,n.truncated=!0,typeof n.count=="number"){let o=N(n.projection)?n.projection.row_key:void 0;n.count=typeof o=="string"&&Array.isArray(n[o])?n[o].length:on(n)}return n.applied_bound={kind:"output_limit",source:"explicit",value:t},n}function jg(e){return Ce.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(Et[t]))}function Ic(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function In(e,t,n,r){let o=_o(e,t,r);We(e,o);for(let i=0;i<8;i+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;ue(o,n,r);let c=o;o=_o(o,t,r),We(c,o);let d=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&d===a)return o}return o}function to(e,t){if(!N(e.read_output))return e;let n=Ic(t),r=e.read_output,o=Cn(t.outputSession??t.output_session);return o===void 0?(ue(e,r,n),e):In(e,o,r,n)}function Fg(e,t){if(e!=="validate")return t;let n=N(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(l=>N(l)&&l.name==="diagnostic_rows"))return t;let r=[...new Set(ut(t).map(({path:l})=>l).filter(l=>/^checks\.\d+\.details\./u.test(l)))],o=r.filter(l=>!r.some(m=>m!==l&&l.startsWith(`${m}.`)));if(o.length===0)return t;let i=N(t.row_contract)?t.row_contract:{},s=Array.isArray(i.row_keys)?i.row_keys.filter(l=>typeof l=="string"):[],a=Array.isArray(i.continuation_row_keys)?i.continuation_row_keys.filter(l=>typeof l=="string"):[],c=s.length>0?s:o,d=[...new Set(o)];return JSON.stringify(c)===JSON.stringify(s)&&JSON.stringify(d)===JSON.stringify(a)?t:{...t,row_contract:{...i,row_keys:c,continuation_row_keys:d,jq_selector:typeof i.jq_selector=="string"?i.jq_selector:".checks[].details"}}}function Ug(e,t,n,r,o){let i={...e};if(t.include?.source==="canonical"&&(i=Mg(t.command,i,t.include.value)),t.command==="assurance"&&(i=da(i)),mt(i,e),i=la(i,t.command,r),t.command==="history"&&r){let c=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([d])=>!c.includes(d)||d===r.path)),N(i.projection)&&(i.projection={...i.projection,row_key:r.path}),N(i.row_contract)){let d=i.row_contract;i.row_contract={...d,row_keys:[r.path],...Array.isArray(d.continuation_row_keys)?{continuation_row_keys:[r.path]}:{}}}i.count=Object.keys(i[r.path]).length}let s=e.count_only===!0?{...i,count_only:!0,count:e.count}:i,a=Kg(i,e,t.command,r,o);return t.amount?.source==="canonical"&&(i=Lg(i,t.amount.value),a.cursorContinuesExistingPage&&Nc(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),mt(i,s),{projected:n===void 0?i:_c(i,n),continuationState:a}}function zg(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default"||e.command==="context"&&e.cost.source==="legacy")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:gc(t)}]].sort((n,r)=>n.tokens-r.tokens)[0]}function Tc(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function Rc(e,t){return N(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function qg(e,t,n){return e.command!=="next"||(t.tokenBudget??t.token_budget)===void 0?!1:!(N(n.context_intent)&&n.context_intent.command==="next"&&n.context_intent.within_budget===!0)}function xc(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!Rc(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function Bg(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...xc(r),precedence:e.precedence,...Tc(e),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...n===void 0?{omitted_result_estimated_tokens:o}:{}},a={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:s},c=n===void 0?a:In(a,n,s,i);if(n===void 0&&ue(c,s,i),n!==void 0&&s.estimated_tokens>r.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",g.USAGE);return c}function Vg(e,t,n){return e.command==="context"&&e.cost?.source==="legacy"&&!Rc(n,e.cost.value)||qg(e,t,n)||t.outputRowContract===!0||t.output_row_contract===!0||e.canonical_options_used.includes("--output-include")||e.command==="list"&&e.canonical_options_used.length>0&&e.include?.value.includes("full")===!0}function Gg(e,t,n,r,o){if(t!==void 0||Vg(e,o,n))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(ae(n).some(({value:s})=>(Array.isArray(s)?s.length:Object.keys(s).length)>i))return!1}return e.cost===void 0||e.cost.value==="unbounded"||e.cost.source==="legacy"&&e.command!=="context"||bt(o.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,r)<=e.cost.value}function Wg(e,t,n,r,o,i,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map(je(e).map(p=>[p.path,Array.isArray(p.value)?p.value.length:Object.keys(p.value).length])),d=[...s.entries()].flatMap(([p,_])=>{let y=c.get(p);if(y>=_.rows)return[];let b=_.baseOffset+y;return[{path:p,cursor:Mr({command:t.command,path:p,offset:b,total_rows:_.totalRows,fingerprint:_.fingerprint}),retained_rows:y,remaining_rows:_.totalRows-b,total_rows:_.totalRows}]}),l=d[0],m=l?"; page --output-cursor":"",u=r.source==="session"?`Truncated by the remaining ${r.tokens}-token session budget; start a new output session with a larger token_budget${m}.`:`${r.tokens}-token: raise --output-budget${m}`;n.migration_hints=[u,...t.migration_hints];let f=fo({effective_budget_tokens:r.tokens,measured_result_tokens:i});l&&!o&&(typeof e.next_cursor!="string"||e.continuation_kind==="output_cursor")&&(e.next_cursor=l.cursor),e.continuation_kind=o?"producer_cursor":l?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:r.source,budget_tokens:r.tokens,overridden_dimensions:a,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:o,continuation_available:d.length>0,recovery_budget_multiplier:l?1:f.recovery_budget_multiplier,continuations:d,restore_with:l?"recovery":`Retry with --output-budget ${f.output_budget} because no declared row collection can be continued.`,recovery:l?{cursor:l.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${f.output_budget}`,sdk:{outputBudget:f.output_budget},mcp:{outputBudget:f.output_budget}}}}function Nc(e,t,n,r,o){if(typeof n!="string"||!Array.isArray(e.items))return!1;let i=e.items.length,s=t.length;if(i===0||i>=s)return!1;let a;try{a=Fr(n)}catch{return!1}let c=a.after_index;if(c===void 0)return!1;let d=t[i-1];if(Object.prototype.toString.call(d)!=="[object Object]")return!1;let l=Reflect.get(d,"id");if(typeof l!="string"||l.length===0)return!1;let m=r?c-(s-i):c+o+i;return m<0?!1:(e.next_cursor=yt(a.fingerprint,l,m,a.snapshot),!0)}function Kg(e,t,n,r,o){let i=new Map(je(e).map(c=>{let d=Array.isArray(c.value)?c.value.length:Object.keys(c.value).length,l=r?.path===c.path;return[c.path,{rows:d,totalRows:l?r.total_rows:d,baseOffset:l?r.offset:0,fingerprint:l?r.fingerprint:sn(c.path,c.value,n)}]})),s=typeof e.next_cursor=="string",a=r?.path==="items"?r.offset:0;return{collectionsBeforeBudget:i,originalItems:Array.isArray(t.items)?a>0?t.items.slice(a):t.items:[],originalItemOffset:a,cursorContinuesExistingPage:s,cursorSource:s?e.next_cursor:o.after}}function Hg(e,t,n,r,o,i,s,a,c,d){let l={...t,count_only:n},m=r.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(f=>N(f)&&f.verdict!=="pass").length:0,u=new Map;if(m>0&&u.set("assertions",m),r.command==="history"&&Array.isArray(e.diff))for(let f of ut(e))f.path.startsWith("diff.")&&u.set(f.path,Object.keys(f.value).length);return fc(e,o,i.tokens,u,d,f=>{mt(f,l);let p=Nc(f,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(Wg(f,r,o,i,p,c,a.collectionsBeforeBudget),r.command==="history"&&N(f.projection)){f.has_more=typeof f.next_cursor=="string"||f.applied_bound?.kind==="output_limit";let _=f.projection.row_key;typeof _=="string"&&Array.isArray(f[_])&&(f.count=f[_].length)}s!==void 0&&Object.assign(f,In(f,s,o,d))},r.command==="history"&&Array.isArray(e.diff))}function qa(e,t,n){let r=Ac(e,t);if(!r)return n;let o=Ic(t),i=Cn(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?gt(s):void 0,c=jg(r),d=Fg(r.command,n);if(a===void 0&&Gg(r,i,d,o,t))return d;let l=zg(r,i),m=Ug(d,r,i,a,t),u=m.projected;We(u,u,t.outputRowContract===!1);let f={contract_version:1,command:r.command,requested_dimensions:c,...xc(l,u),precedence:r.precedence,...Tc(r),legacy_aliases_used:r.legacy_aliases_used,migration_hints:r.migration_hints,estimated_tokens:0,within_budget:!0,strings_compacted:!1,rows_compacted:!1,result_omitted:!1};if(u.read_output=f,u=i===void 0?u:In(u,i,f,o),ue(u,f,o),l!==void 0&&f.estimated_tokens>l.tokens){let p=uc(r.command,t,u);p!==void 0&&(f.applied_depth="brief",f.degradation_reason="output_budget_reached",We(u,p),u=to(p,t)),f.estimated_tokens>l.tokens&&(u=Hg(u,u,d.count_only===!0,r,f,l,i,m.continuationState,f.estimated_tokens,o))}return l!==void 0&&f.estimated_tokens>l.tokens?Bg(r,c,i,l,f.estimated_tokens,o):u}function X_(e){return N(e)&&N(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function J_(e,t){let n=t.outputFormat??t.output_format;if(n==="json"||n==="toon")return n;let r=Ac(e,t)?.encoding;return r?.value==="json"||r?.value==="toon"?r.value:void 0}export{Tt as a,ri as b,Hn as c,Bl as d,Vl as e,S as f,Dc as g,Eo as h,Xg as i,Jg as j,ko as k,Qg as l,Zg as m,ey as n,ty as o,ny as p,ry as q,oy as r,iy as s,sy as t,ay as u,cy as v,dy as w,ly as x,Pc as y,uy as z,fy as A,my as B,py as C,_y as D,gy as E,yy as F,qi as G,xl as H,jh as I,Jo as J,Qo as K,is as L,ss as M,Mc as N,Lc as O,Dn as P,Mn as Q,Ln as R,ky as S,Oy as T,Sy as U,Wc as V,So as W,Ay as X,et as Y,Qn as Z,lb as _,tu as $,fb as aa,mb as ba,pb as ca,pi as da,_i as ea,_b as fa,gb as ga,yb as ha,hb as ia,Io as ja,ed as ka,Ro as la,$o as ma,$y as na,zn as oa,fd as pa,My as qa,Ad as ra,Cd as sa,Ly as ta,jy as ua,Hy as va,Fo as wa,Uo as xa,zo as ya,Lo as za,Yy as Aa,Xy as Ba,Jy as Ca,Bn as Da,Qy as Ea,pe as Fa,V as Ga,th as Ha,nh as Ia,Zd as Ja,Bo as Ka,Vn as La,nl as Ma,rl as Na,$t as Oa,Go as Pa,il as Qa,cl as Ra,ch as Sa,dh as Ta,fl as Ua,ml as Va,pl as Wa,_l as Xa,Gn as Ya,uh as Za,gl as _a,Qe as $a,Mt as ab,fh as bb,mh as cb,ph as db,yl as eb,hl as fb,bl as gb,bh as hb,wh as ib,wl as jb,Lt as kb,vh as lb,Eh as mb,vl as nb,El as ob,kl as pb,Ko as qb,Re as rb,Ol as sb,kh as tb,Oh as ub,Sh as vb,Ah as wb,Ch as xb,Ih as yb,Th as zb,ge as Ab,Ut as Bb,Ph as Cb,Vt as Db,nr as Eb,rr as Fb,or as Gb,ir as Hb,sr as Ib,ar as Jb,lr as Kb,ji as Lb,zh as Mb,Zu as Nb,tf as Ob,nf as Pb,uf as Qb,rv as Rb,ov as Sb,iv as Tb,Vh as Ub,qt as Vb,Gh as Wb,Wh as Xb,Ml as Yb,Kh as Zb,Hh as _b,Yh as $b,Xh as ac,Jh as bc,fa as cc,lv as dc,Rf as ec,Gl as fc,Yn as gc,Hl as hc,Yl as ic,gv as jc,jf as kc,yv as lc,hv as mc,bv as nc,wv as oc,vv as pc,Ev as qc,kv as rc,Ts as sc,Ff as tc,Ov as uc,Sv as vc,Rs as wc,Av as xc,xs as yc,Cv as zc,Iv as Ac,Tv as Bc,Xt as Cc,$v as Dc,Mv as Ec,Qs as Fc,Zv as Gc,eE as Hc,tE as Ic,Zs as Jc,ea as Kc,mE as Lc,na as Mc,tn as Nc,vE as Oc,EE as Pc,qf as Qc,qv as Rc,$s as Sc,Bf as Tc,Qf as Uc,em as Vc,Ms as Wc,tm as Xc,nm as Yc,Ls as Zc,ke as _c,js as $c,Bv as ad,Vv as bd,Cr as cd,Gv as dd,Wv as ed,Kv as fd,Hv as gd,Yv as hd,OE as id,mt as jd,wt as kd,j0 as ld,Ce as md,nO as nd,rO as od,Eg as pd,Fe as qd,oO as rd,Oc as sd,Ig as td,iO as ud,Ac as vd,to as wd,qa as xd,X_ as yd,J_ as zd,ca as Ad,sn as Bd,Mr as Cd,gt as Dd,FE as Ed,UE as Fd,yt as Gd,Fr as Hd,Ur as Id,zE as Jd,op as Kd,qE as Ld,BE as Md,HE as Nd,Br as Od,ek as Pd,pp as Qd,tk as Rd,Ue as Sd,nk as Td,rk as Ud,Wr as Vd,Kr as Wd,cn as Xd,vk as Yd,Wp as Zd,_n as _d,Qp as $d,Na as ae,e_ as be,X as ce,T as de,Dk as ee,bn as fe,u_ as ge,Pk as he,$k as ie,f_ as je,Mk as ke,Lk as le,jk as me,g_ as ne,Ba as oe,y_ as pe,Xk as qe,b_ as re,Ga as se,Jk as te,Ha as ue,v_ as ve,S_ as we,N_ as xe,U_ as ye,a0 as ze,c0 as Ae,rg as Be,dc as Ce,A0 as De,fo as Ee,bt as Fe,M0 as Ge,po as He,Cn as Ie,_c as Je,_o as Ke,gc as Le};
|
|
26
|
-
//# sourceMappingURL=chunk-CIQ6YWCW.js.map
|