@unbrained/pm-cli 2026.10.26 → 2026.10.28
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 +39 -1
- package/dist/cli/commander-usage.js +2 -2
- package/dist/cli/error-guidance.js +2 -2
- package/dist/cli/register-list-query.js +5 -5
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-2J7I54MQ.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-25MTQAHX.js → chunk-3KMYHYJV.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-7V37RC2L.js +114 -0
- package/dist/cli-bundle/chunks/chunk-AHVN4GHF.js +31 -0
- package/dist/cli-bundle/chunks/{chunk-VS2IIV3F.js → chunk-CS7QDSUX.js} +28 -28
- package/dist/cli-bundle/chunks/{chunk-T7T4WLUY.js → chunk-CXUQEZDX.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-ZT64RDMF.js → chunk-D3AIQZXF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7UDQAINZ.js → chunk-D6P6IBPN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TGOG5BFM.js → chunk-DKLEDWVW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MWCG25PO.js → chunk-DM3PICGU.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Y42DYMZX.js → chunk-E5QBZ4HI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XAIR53QZ.js → chunk-JESLOJD7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-57YPOOED.js → chunk-LWW4F4G2.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-PQLRKFPZ.js +20 -0
- package/dist/cli-bundle/chunks/{chunk-ONC4BBQP.js → chunk-RZQNFHXO.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-SPPHDVZE.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ER7RLJW5.js → chunk-TH5KPAN4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OCDRHIVQ.js → chunk-XHONSCLJ.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-NGKTROAO.js → chunk-YUBUNECD.js} +42 -42
- package/dist/cli-bundle/chunks/{chunk-Z35XAHUN.js → chunk-YYD5MNAV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UF6EXZSP.js → chunk-ZX3XMTZG.js} +2 -2
- package/dist/cli-bundle/chunks/indexed-receipt-blobs-LHLE7PSG.js +4 -0
- package/dist/cli-bundle/chunks/{mutation-admission-VTNV6JV2.js → mutation-admission-GKDKHRTZ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-LZDWUZS4.js → register-list-query-MHJJUM6M.js} +9 -9
- package/dist/cli-bundle/chunks/{register-mutation-M2A7PH42.js → register-mutation-SN425O3R.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-E7P2JTXM.js → register-operations-EYUIUGPW.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-DOV7KGSH.js → register-setup-WUZ2ZSMY.js} +2 -2
- package/dist/cli-bundle/chunks/{settlement-hook-SVD6CO7U.js → settlement-hook-MN3Y7LVX.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-LYLEOAQB.js → stage-2FYJGGG3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-3EHVI673.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-46WLWK73.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-E5C24MCV.js → chunk-4GN2ZPT5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NLZUI234.js → chunk-6L4KKRK7.js} +18 -18
- package/dist/cli-bundle/focused-chunks/{chunk-D5YQ4KAE.js → chunk-6VDRAJYX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KTXU5WU6.js → chunk-7SZPZOIC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YQKLKRMW.js → chunk-B4ZQJEMT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NE27VCU7.js → chunk-BZSACRVX.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-ADSBGYLW.js → chunk-C2GLO7HU.js} +55 -55
- package/dist/cli-bundle/focused-chunks/{chunk-UP765R2V.js → chunk-DRN4W3YJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-EGN2HFRU.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-CSCZYSNZ.js → chunk-F6UQJJYB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-I7H3XF25.js → chunk-I4X6AKOO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-IQKLJFJE.js +79 -0
- package/dist/cli-bundle/focused-chunks/{chunk-KERJNFXY.js → chunk-JTCGDODH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-IF6C43IP.js → chunk-L5GX2FGZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PK5FJIVA.js → chunk-LPWZERVD.js} +11 -11
- package/dist/cli-bundle/focused-chunks/{chunk-YW5GHQN2.js → chunk-ML5JIUM6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BL77VCRB.js → chunk-OASYSUOH.js} +16 -16
- package/dist/cli-bundle/focused-chunks/{chunk-BH7RE2ZY.js → chunk-ON5WFDCG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WDWHUJQW.js → chunk-QUPGBO2L.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-226XKW3W.js → chunk-R3EA3SDW.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-B266DDBJ.js → chunk-TUN4M757.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YTEC2EPM.js → chunk-Z26ZPQH6.js} +3 -3
- package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-5H6RMRTK.js +4 -0
- package/dist/cli-bundle/focused-chunks/{mutation-admission-L42E3U5U.js → mutation-admission-TM3SVU2O.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{settlement-hook-3CADO4XZ.js → settlement-hook-LBVWWSCF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-TUQHWU7N.js → stage-7ZBRX2Q2.js} +2 -2
- package/dist/cli-bundle/main.js +21 -21
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +34 -33
- 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 +11 -11
- package/dist/core/history/event-index.d.ts +6 -0
- package/dist/core/history/event-index.js +7 -6
- package/dist/core/history/read.d.ts +3 -1
- package/dist/core/history/read.js +1 -1
- package/dist/core/item/priority.js +1 -1
- package/dist/core/shared/errors.d.ts +2 -0
- package/dist/core/shared/errors.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/mcp/tool-definitions.js +1 -1
- package/dist/sdk/agent/command-recovery.d.ts +5 -0
- package/dist/sdk/agent/command-recovery.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/command-line.d.ts +6 -0
- package/dist/sdk/command-line.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/lifecycle/close.js +1 -1
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/update-many.js +1 -1
- package/dist/sdk/lifecycle/update.js +1 -1
- package/dist/sdk/merge/indexed-receipt-blobs.d.ts +3 -1
- package/dist/sdk/merge/indexed-receipt-blobs.js +2 -2
- package/dist/sdk/merge/receipt-file-boundary.d.ts +2 -0
- package/dist/sdk/merge/receipt-file-boundary.js +1 -1
- package/dist/sdk/merge/receipts.js +2 -2
- package/dist/sdk/mutation-events.d.ts +6 -0
- package/dist/sdk/mutation-events.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/history.d.ts +4 -0
- package/dist/sdk/query/history.js +1 -1
- package/dist/sdk/runtime/actions.js +1 -1
- package/dist/sdk/runtime-extended-actions.js +1 -1
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/test/command-resolution.d.ts +5 -0
- package/dist/sdk/test/command-resolution.js +3 -0
- package/dist/sdk/test/execution.js +3 -3
- package/dist/sdk/test/receipt-index-snapshot.d.ts +2 -0
- package/dist/sdk/test/receipt-index-snapshot.js +2 -0
- package/dist/sdk/test/workspace-snapshot.d.ts +1 -1
- package/dist/sdk/test/workspace-snapshot.js +1 -1
- package/docs/COMMANDS.md +28 -1
- package/docs/PERFORMANCE.md +21 -6
- package/docs/RELEASING.md +11 -0
- package/docs/SDK.md +40 -0
- package/docs/SDK_CONTEXT_COORDINATION.md +35 -4
- package/docs/TESTING.md +42 -3
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
- package/marketplace.json +1 -1
- package/package.json +1 -1
- 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-N6FTEILW.js +0 -20
- package/dist/cli-bundle/chunks/chunk-OUDR2HWR.js +0 -113
- package/dist/cli-bundle/chunks/chunk-RUKSEZE7.js +0 -2
- package/dist/cli-bundle/chunks/chunk-YJBIPNDL.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ZLVFUZI4.js +0 -30
- package/dist/cli-bundle/chunks/indexed-receipt-blobs-NWQIDTH7.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-ABMNYWV6.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-NFN2P4TW.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-UHWTPOM4.js +0 -78
- package/dist/cli-bundle/focused-chunks/chunk-VVRXF4JO.js +0 -2
- package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-YFDNGHCM.js +0 -4
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import{B as kn,C as On,D as Ie,a as G,b as vn,c as so,e as Et,f as kt,g as Ot,h as ao,i as St,j as Ce,k as co,l as En,o as At,p as Ct,s as He,y,z as h}from"./chunk-KTXU5WU6.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 It(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]="c05a5a9e-282c-5ca7-97dc-e48c8df7977e")}catch{}})();var gc=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],lo=gc,Og=["draft","open","in_progress","blocked","closed","canceled"],Sg=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],uo=["string","number","boolean","string_array","array","object"],Ag=["create","update","update_many","list","search","calendar","context"],Cg=["allow","warn","reject"],Ig=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],Tg=["project","global"],Rg=["low","medium","high","critical"],xg=["low","medium","high","critical"],Ng=["low","medium","high"];var Dg=["minimal","default","strict","custom"],Pg=["none","warn","strict"],$g=["progressive","strict"],Mg=["off","warn","strict"],Lg=["off","warn","strict"];var jg=["daily","weekly","monthly","yearly"],yc=["mon","tue","wed","thu","fri","sat","sun"];function Fg(e){return yc.indexOf(e)}var Ug=["draft","research","review","approved","executing","paused","completed","superseded"],zg=["pending","in_progress","completed","blocked","skipped","superseded"],qg=["codex","claude-code","cursor","generic"],Bg=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],Vg=["brief","standard","deep","full"],Gg=["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 hc=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 bc(e){return{unknownKeys:Object.keys(e).filter(t=>!hc.has(t)).sort((t,n)=>t>n?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function wc(e){let t=bc(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 fo(e,t,n){return wc(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 Sn=[{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 xt(e){return e.trim().toLowerCase().replaceAll("-","_")}function vc(e){if(e===void 0)return;let t=xt(e);if(!/^[a-z][a-z0-9_]*$/.test(t))throw new TypeError(`Invalid inverse relationship kind: ${e}`);return t}function Cn(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)Cn(n,t);return Object.freeze(e)}for(let n of Object.values(e))Cn(n,t);return Object.freeze(e)}function Ec(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 kc(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 Oc(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 Sc(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=xt(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 Ac(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 Cc(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 Ic(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var In=class{#e=new Map;#n=new Map;constructor(t=Sn){for(let n of t)this.register(n)}register(t){let n=Sc(t);if(Ac(t,n),Cc(t,n),Ec(t,n),kc(t,n),Oc(t,n),this.#e.has(n)||this.#n.has(n))throw new TypeError(`Relationship kind already registered: ${n}`);let r=vc(t.inverse),o=[...new Set((t.aliases??[]).map(xt))].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:Ic(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:r,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?Cn(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=xt(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 Tn(){return new In}var ue=Tn();function Jg(e){return ue.require(e).kind}function Qg(e){return ue.resolve(e)?.kind}function Zg(e,t=ue){return t.resolve(e)?.ordering===!0}function Tc(e,t,n,r=ue){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 Tt(e,t){return e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||e.kind.localeCompare(t.kind)}function Rc(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=Tc(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 Rt(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 An(e,t){let n=Ye(e);return n&&t.has(n)?n:void 0}function xc(e,t,n){let r=[t],o=t;for(;o!==e;)o=n.get(o),r.push(o);return r.reverse()}var mo=class e{#e;#n;#o;#r;#s=new Map;#a=new Map;constructor(t,n,r=ue){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}=Rc(i,this.#n,r);o.set(a,s)}this.#r=Object.freeze([...o.values()].sort(Tt));for(let i of this.#r)Rt(this.#s,i.source,i),Rt(this.#a,i.target,i),r.require(i.kind).direction==="undirected"&&(Rt(this.#s,i.target,i),Rt(this.#a,i.source,i))}static fromItems(t,n=ue){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=An(i.parent,r);a&&o.push({source:s,target:a,kind:"parent"});let c=An(i.blocked_by,r);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let d of i.dependencies??[]){let l=An(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||Tt(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)||Tt(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(g=>!a.has(g.id))&&(u=!0);continue}for(let g of _)if(!a.has(g.id)){if(c.length>=i){u=!0;break e}a.add(g.id),c.push(g.id),d.push({id:g.id,depth:p.depth+1})}}return{value:c,meta:{visitedNodes:l,inspectedEdges: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(g=>!d.has(g.id))&&(u=!0);continue}for(let g of _)if(!d.has(g.id)){if(c.set(g.id,p.id),g.id===n)return{value:xc(t,n,c),meta:{visitedNodes:l,inspectedEdges:m,truncated:!1}};d.add(g.id),a.push({id:g.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(Tt)},meta:r.meta}}};function ey(e,t,n=ue){return{source:e,target:t.id,kind:n.require(t.kind).kind,createdAt:t.created_at,author:t.author}}import{readFileSync as yd,readdirSync as _y,realpathSync as Oo,statSync as Ao}from"node:fs";import hd from"node:os";import v from"node:path";import Mc 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 J(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Nc(e){let t=e.key.trim();if(t.length===0)return null;let n=J(e.aliases),r=e.description?.trim();return{key:t,values:J(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 Dc=e=>e,_o=e=>{let t=e.trim().toLowerCase();return t==="create"||t==="update"?t:null};function Pc(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 $c(e,t){let n=new Map;for(let r of e??[]){let o=Pc(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 po(e,t){return t?J(e):void 0}function Rn(e){let t=e?.trim();return t&&t.length>0?t:void 0}function xn(e){if(e===void 0||e==="agent"||e==="human"||e==="gate")return e;throw new Error("Item type execution_role must be agent, human, or gate.")}function go(e,t={}){let n=t.resolvePolicyCommand??Dc,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=J(e.aliases),d=(e.options??[]).map(m=>Nc(m)).filter(m=>m!==null).sort((m,u)=>m.key.localeCompare(u.key)),l=$c(e.command_option_policies,n);return{name:r,description:Rn(e.description),default_status:Rn(e.default_status),...e.execution_role===void 0?{}:{execution_role:xn(e.execution_role)},folder:Rn(e.folder),aliases:c.length>0?c:void 0,required_create_fields:po(e.required_create_fields,o),required_create_repeatables:po(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 Lc=Object.freeze({decision:"human",milestone:"gate"}),jc=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],Fc=["dep","comment","note","learning","file","test","doc"],ho=["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"],Uc=["title","description","type","status","priority","tags","body",...ho,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],zc=["title","description","body","status","closeReason","priority","type","tags",...ho,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],bo={"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"},qc={...bo},Bc={...bo},wo=[["deadline","--deadline"],["estimatedMinutes","--estimate/--estimated-minutes"],["acceptanceCriteria","--acceptance-criteria/--ac"],["definitionOfReady","--definition-of-ready"],["order","--order/--rank"],["goal","--goal"],["objective","--objective"],["value","--value"],["impact","--impact"],["outcome","--outcome"],["whyNow","--why-now"],["assignee","--assignee"],["parent","--parent"],["reviewer","--reviewer"],["risk","--risk"],["confidence","--confidence"],["sprint","--sprint"],["release","--release"],["blockedBy","--blocked-by"],["blockedReason","--blocked-reason"],["unblockNote","--unblock-note"],["reporter","--reporter"],["severity","--severity"],["environment","--environment"],["reproSteps","--repro-steps"],["resolution","--resolution"],["expectedResult","--expected-result"],["actualResult","--actual-result"],["affectedVersion","--affected-version"],["fixedVersion","--fixed-version"],["component","--component"],["regression","--regression"],["customerImpact","--customer-impact"]],vo=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function Eo(e){return Object.fromEntries(e)}var Vc=Eo([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...wo,["author","--author"],["message","--message"],["dep","--dep"],...vo]),Gc=Eo([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...wo,...vo,["author","--author"],["message","--message"],["force","--force"]]);function Wc(e){return e.trim().replace(/^--+/,"").toLowerCase()}function Kc(e){return e==="create"?Uc:zc}function Hc(e){return e==="create"?qc:Bc}function ko(e,t){let n=Wc(t);return n.length===0?void 0:Hc(e)[n]||Kc(e).find(r=>r.toLowerCase()===n)}function dy(e,t){return(e==="create"?Vc:Gc)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function Dn(e){let t=Xc(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function Yc(e){let t=e.trim(),n=t.replaceAll("\\","/").replace(/^\/+/,""),r=Mc.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 Xc(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 Jc(e){return go(e,{resolvePolicyCommand:_o})}function Xe(e,t){let n=e[t];return Array.isArray(n)?n.filter(r=>typeof r=="string"):void 0}function Qc(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 Zc(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 ed(e){if(Array.isArray(e.options))return e.options.map(t=>Qc(t)).filter(t=>t!==null)}function td(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>Zc(t)).filter(t=>t!==null)}function nd(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=e,n=typeof t.name=="string"?t.name:"";if(n.trim().length===0)return null;let r=typeof t.folder=="string"?t.folder:void 0,o=typeof t.description=="string"?t.description:void 0,i=typeof t.default_status=="string"?t.default_status:void 0;return{name:n,description:o,default_status:i,execution_role:xn(t.execution_role),folder:r,aliases:Xe(t,"aliases"),required_create_fields:Xe(t,"required_create_fields"),required_create_repeatables:Xe(t,"required_create_repeatables"),options:ed(t),command_option_policies:td(t)}}function rd(e,t){return e.required_create_fields?J(e.required_create_fields):t?.required_create_fields??[]}function od(e,t){return e.required_create_repeatables?J(e.required_create_repeatables):t?.required_create_repeatables??[]}function id(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function sd(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function ad(e,t){let n=t?.name??e.name,r=e.description??t?.description,o=e.default_status??t?.default_status,i=Yc(e.folder??t?.folder??Dn(n)),s={name:n,execution_role:e.execution_role,folder:i,aliases:J([...t?.aliases??[],...e.aliases??[]]),required_create_fields:rd(e,t),required_create_repeatables:od(e,t),options:id(e,t),command_option_policies:sd(e,t)};return r&&(s.description=r),o&&(s.default_status=o),s}function yo(e,t){for(let n of e){let r=Jc(n);if(!r)continue;let o=r.name.toLowerCase(),i=t.get(o);t.set(o,ad({...r,execution_role:r.execution_role??i?.execution_role},i))}}function cd(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=nd(o);i&&t.push(i)}}return t}function ly(e,t=null){let n=new Map;for(let c of lo)n.set(c.toLowerCase(),{name:c,execution_role:Lc[c.toLowerCase()]??"agent",folder:He[c],aliases:[],required_create_fields:[...jc],required_create_repeatables:[...Fc],options:[],command_option_policies:[]});yo(e.item_types?.definitions??[],n),yo(cd(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 dd(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function ld(e,t){let n=dd(e,t);if(n)return t.by_type[n]}function ud(e,t,n,r){for(let o of r){let i=ko(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 Nn(e,t,n){if(n){e.add(t);return}e.delete(t)}function fd(e,t,n,r){let o=ko(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&&Nn(e.required,o,r.required),r.visible!==void 0&&Nn(e.hidden,o,!r.visible),r.enabled!==void 0&&Nn(e.disabled,o,!r.enabled)}function md(e,t,n){for(let r of t.command_option_policies)r.command===n&&fd(e,t,n,r)}function pd(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 uy(e,t,n){let r=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:r};return ud(a,e,t,n),md(a,e,t),pd(a,e,t),{required:[...o],hidden:[...i].sort((c,d)=>c.localeCompare(d)),disabled:[...s].sort((c,d)=>c.localeCompare(d)),errors:r}}function _d(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 gd(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 fy(e,t,n){let r=ld(e,n);if(!r)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=_d(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=gd(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}}(function(){try{var e=typeof window<"u"?window:typeof 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 bd={json_markdown:".md",toon:".toon"},wd={".md":"json_markdown",".toon":"toon"};var Ey=[".md",".toon"];function Nt(e){try{return Ao(e),!0}catch{return!1}}function vd(e){let t=v.resolve(e),n=[];for(;v.dirname(t)!==t;)try{return v.join(Oo(t),...n)}catch(r){if(!On(r))throw r;n.unshift(v.basename(t)),t=v.dirname(t)}return v.join(Oo(t),...n)}function Ed(e){try{return Ao(e),!0}catch(t){if(On(t))return!1;throw t}}function kd(e){try{let t=JSON.parse(yd(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function Od(e){let t=vd(e);for(;;){let n=v.join(t,At),r=v.join(n,Ct);if(Nt(r))return n;let o=v.join(t,Ct);if(Nt(o)&&kd(o))return t;if(Ed(v.join(t,".git")))return n;let i=v.dirname(t);if(i===t)return;t=i}}function Sd(e){return Od(e)??v.resolve(e,At)}function ky(e,t){let n=process.env.PM_PATH,r=t?.trim()||n?.trim();if(r){let o=v.resolve(e,r);if(!Nt(So(o))){let i=v.join(o,At);if(Nt(So(i)))return i}return o}return Sd(e)}function Oy(e){let t=v.resolve(e),n=v.dirname(t);return v.basename(t)==="pm"&&v.basename(n)===".agents"?v.dirname(n):t}function Co(e){let t=process.env.PM_GLOBAL_PATH?.trim(),n=t&&t.length>0?t:v.join(hd.homedir(),".pm-cli");return v.resolve(e,n)}function So(e){return v.join(e,Ct)}function Ad(e,t,n=He){let r=n[t]??Dn(t);return v.join(e,r)}function Sy(e,t,n,r="toon",o=He){return v.join(Ad(e,t,o),`${n}${bd[r]}`)}function Ay(e){let t=e.replaceAll("\\","/"),n=v.posix.extname(t).toLowerCase();return wd[n]??null}function Cy(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new h("Invalid history item id: expected a single filename.",y.USAGE);return v.join(e,"history",`${t}.jsonl`)}function Pn(e,t){return v.join(e,"locks",`${t}.lock`)}function Iy(e){return v.join(e,"runtime")}import{createHash as Ro}from"node:crypto";import Cd 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 Id(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 Td(e){let t=Object.keys(e).sort(),n={};for(let r of t){let o=e[r];o!==void 0&&(n[r]=Dt(o))}return n}function Dt(e){let t=Id(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(r=>Dt(r));if(e instanceof Date)return e.toISOString();let n=e;if(typeof n.toJSON=="function"){let r=n.toJSON();if(r!==e)return Dt(r)}return Td(e)}function fe(e){return JSON.stringify(Dt(e))}function Io(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 Rd(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function xd(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function Nd(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(!Io(o,n,r,B))return!1;return!0}function Dd(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(!Io([o,i],n,r,([s,a],[c,d])=>B(s,c)&&B(a,d)))return!1;return!0}function Pd(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,r)=>B(n,t[r]))}function $d(e,t){let n=Object.keys(e).sort((o,i)=>o.localeCompare(i)),r=Object.keys(t).sort((o,i)=>o.localeCompare(i));if(n.length!==r.length)return!1;for(let o=0;o<n.length;o+=1){let i=n[o];if(i!==r[o]||!B(e[i],t[i]))return!1}return!0}var Md=[Rd,xd,Nd,Dd,Pd];function B(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let n of Md){let r=n(e,t);if(r!==void 0)return r}return $d(e,t)}function xy(e){return Cd.createHash("sha256").update(e,"utf8").digest("hex")}function Ny(e,t){let n={};for(let o of t){let i=e[o];i!==void 0&&(n[o]=i)}let r=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of r){let i=e[o];i!==void 0&&(n[o]=i)}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f675993f-c483-5751-baed-d968b4fd24c0")}catch{}})();var Ld=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],To=256,$n=64;function U(e){throw new h(`Invalid workflow policy: ${e}`,y.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function W(e,t,n){if(typeof e!="object"||e===null||Array.isArray(e))return U(`${n} must be an object`);let r=e;return Object.keys(r).some(o=>!t.includes(o))?U(`${n} contains an unknown key`):r}function me(e,t,n=128){return typeof e!="string"||!e.trim()||e.length>n?U(`${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>$n)return U(`${t} requires 1-${$n} terms`);let n=e.map(r=>me(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)))?U("fields must be safe metadata paths of at most eight segments"):[...new Set(n)]}function jd(e){let t=W(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(W(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>$n?U("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(n=>!Array.isArray(n)||n.length!==2?U("transition pairs need two statuses"):[me(n[0],"from"),me(n[1],"to")])}):t.kind==="authors"?(W(t,["kind","authors"],"authors rule"),{kind:"authors",authors:Je(t.authors,"authors")}):t.kind==="require_fields"?(W(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:Je(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(W(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:Je(t.fields,"fields"),authors:Je(t.authors,"authors")}):U("unknown rule kind")}function Fd(e){let t={},n=W(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let r of["types","tags","statuses","operations","parents"])n[r]!==void 0&&(t[r]=Je(n[r],r));if(n.dependency!==void 0){let r=W(n.dependency,["kind","id"],"dependency");t.dependency={kind:me(r.kind,"dependency kind"),...r.id===void 0?{}:{id:me(r.id,"dependency id")}}}return t}function Ud(e){let t=W(e,["id","description","subject","effect","rule"],"policy"),n=me(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))?U("effect must be advise, warn, or refuse"):{id:n,rule:jd(t.rule),...t.subject===void 0?{}:{subject:Fd(t.subject)},...t.description===void 0?{}:{description:me(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:U("id must be a stable token")}function zd(e){let t=W(e,["version","enforcement","policies"],"document");if(t.version!==1)return U("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return U("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>To)return U(`policies must contain at most ${To} declarations`);let n=t.policies.map(Ud);return new Set(n.map(r=>r.id)).size!==n.length?U("duplicate policy id"):{version:1,enforcement:t.enforcement??"advise",policies:n}}function Pt(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 qd(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 xo(e){return Ro("sha256").update(fe(e)).digest("hex")}function Bd(e,t){let n=e.rule.kind==="approval"?e.rule.fields:[];return Ro("sha256").update(fe({id:t.id,fields:n.map(r=>[r,Pt(t,r)])})).digest("hex")}function Vd(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 Gd(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&&!Vd(e.dependency,t.dependencies))}function Wd(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&&Gd(n,{...o,status:r},t.operation))}function Kd(e,t,n,r){let o=["type","tags","parent","dependencies"].some(i=>!B(t.before?.[i],t.after?.[i]));return t.after&&(t.completeness_only||n||r||o)?e.filter(i=>!qd(Pt(t.after,i))):[]}function Hd(e,t,n,r){let o=t.after??t.before,i=Bd(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 Yd(e,t,n){let r=e.rule,o=t.before?.status!==t.after?.status,i="fields"in r&&r.fields.some(s=>!B(Pt(t.before,s),Pt(t.after,s)));switch(r.kind){case"require_fields":{let s=Kd(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||Hd(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 No(e,t,n){let r=e.policies.filter(o=>Wd(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,...Yd(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 jy(e,t){return No(e,t,xo)}function Fy(e){let t=zd(e),n=new Map(t.policies.map(r=>[r,xo(r)]));return r=>No(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 Xd=[["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"})),Jd=[...["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"})),Qd=[["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"})),Zd=[...Jd,...Qd,...["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}))],Mn=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...Xd,...Zd,...["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 zy(e){let t;for(let n of Mn)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 el(e){let t=e.trim().replace(/\s+/gu," ");return Mn.find(n=>n.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function Qe(e){return el(e)}var $t=[...Mn,...[["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"}))],qy=Object.fromEntries($t.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function By(e){let t=e.trim().toLowerCase();return $t.find(n=>n.alias===t)}function Vy(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 tl=[...G],nl=[...Ce],rl=[...Et],Yy=[...kt],Xy=[...Ot],ol=[...St],Mt=["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"],Jy=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],Qy=["install","reconcile","report","driver"],il=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],sl=["upgrade"],al=["reopen"],Do={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Te=Object.freeze(Mt.flatMap(e=>e in Do?[]:e==="extension"||e==="package"?[...il.map(t=>`${e}-${t}`),...e==="package"?sl.map(t=>`package-${t}`):[],e]:e==="item"?al.map(t=>`item-${t}`):[e])),cl=Object.freeze($t.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Te.includes(e.alias)).map(e=>e.alias)),Zy=Object.freeze(Te.filter(e=>!cl.includes(e)));function eh(e=Mt,t=Te,n=Do){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 th(e){return Te.includes(e)}function nh(e){return tl.includes(e)}function rh(e){return nl.includes(e)}function oh(e){return rl.includes(e)}function ih(e){return ol.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 Lt={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},jt=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),Re=["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 dl(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function Po(e){return e?P(e):{}}function $o(e){return e?P(e):dl()}function P(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 ll=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),ul=["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 fl(e,t){for(let n of ul){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=>ll.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 ml(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 pl(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 Ft(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(!fl(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=ml(o);if(s===null)return null;n.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=pl(i);if(s===null)return null;n.preflight_ownership=s}return n}function lh(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 _l=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"}]),Ln=new Set(_l.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 Mo=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function jn(e){if(typeof e!="string")return null;let t=Mo.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 ph(e){let t=jn(e);return t?t.name:typeof e=="string"&&e.trim()||null}function gl(e){if(typeof e!="string")return null;let t=e.trim(),n=t.split(/[ =]/,1)[0];return Ln.has(n)?"host_owned_flag_collision":Mo.test(t)?null:"malformed_long_flag"}function Lo(e,t){let n=[e,t].find(i=>typeof i=="string"&&Ln.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=gl(r);return o===null?null:{token:r,failure:o}}function jo(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 Fo=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function Ut(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Object.hasOwn(Fo,t)?Fo[t]:null}function yl(e,t,n){return!!(e.value_name?.trim()||t||n||e.required===!0||e.list===!0||e.repeatable===!0)}function hl(e){return(e.value_type?.trim()||e.type?.trim())?.toLowerCase()}function yh(e){let t=hl(e),n=Ut(t),r=jn(e.long),o=e.value_name?.trim()||null,i=!(n==="boolean"&&t!=="bool")&&yl(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 Uo(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 zo(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]="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 Q(e){return G.includes(e)}function qo(e){let t=e.trim().toLowerCase();return Q(t)?t:null}function Bo(e){return e.filter(t=>!Q(t))}function Fn(e){let t=e.trim().toLowerCase();return t.length===0?null:so[t]??null}function Vo(e){let t=Ze([...e].map(i=>i.toLowerCase())),n=[],r=[];for(let i of t){let s=Fn(i);if(s){n.push(s),r.push({alias:i,target:s});continue}n.push(i)}let o=[...new Map(r.map(i=>[`${i.alias}>${i.target}`,i])).values()].sort((i,s)=>i.alias.localeCompare(s.alias));return{capabilities:Ze(n),legacy_aliases:o}}function bl(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=Fn(t);if(n)return n;let r=Math.max(1,Math.floor(t.length*.34)),o=null,i=Number.POSITIVE_INFINITY;for(let s of G){let a=It(t,s,r);a!==null&&a<i&&(i=a,o=s)}return o}function Go(e,t,n){let r=G.join(","),o=bl(n)??"none";return`extension_capability_unknown:${e}:${t}:${n}:allowed=${r}:suggested=${o}`}function Wo(e,t,n){let r=n.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${r}`}function wl(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=Fn(o),l=(s==="none"?void 0:s)??d??void 0;return{layer:a,name:r,capability:o,allowed_capabilities:c,capability_contract_version:vn,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=[...G],a=[];for(let c of o.split(",")){let[d,l]=c.split(">"),m=d?.trim(),u=l?.trim().toLowerCase();!m||!u||!Q(u)||a.push({layer:i,name:r,capability:m,allowed_capabilities:s,capability_contract_version:vn,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 El={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"]},Ko=":";function Ho(e,t){return`${e}${Ko}${Un(t)}`}function kl(e){return e.slice(e.indexOf(Ko)+1)}function Un(e){return e.trim().toLowerCase()}function Ol(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let r=qo(n);r!==null&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function Yo(e){let t=new Map,n=(l,m)=>{for(let u of l){let f=Ho(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 Sl(e,t={}){let n=Yo(e),r=new Set;t.extensionName!==void 0&&r.add(Un(t.extensionName));for(let i of t.extensionNames??[])r.add(Un(i));let o=new Set;for(let[i,s]of n)if(!(r.size>0&&!r.has(kl(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function Al(e,t){let n=Yo(t),r=[];for(let o of e){let i=Ol(o.capabilities);if(i.length===0)continue;let s=n.get(Ho(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}(function(){try{var e=typeof window<"u"?window:typeof 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 Cl(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function Z(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 Oh(e){return Cl(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function Sh(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 Il}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]="1a14ce9e-1074-5434-9646-dd5e25e34814")}catch{}})();var Tl=["full","compact","brief","summary","counts"],xh=["mutation","read","discovery","governance"],Jo=["error","warning","validation_summary","recovery_bundle"],Rl=["full","omit_explanation","limit_collections","compact_recovery","action_only"],xl=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"]),Nl=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),Dl=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),Pl={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},$l=3,Ml=2,Ll=192,jl={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},Fl=Jo.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:jl[e],minimum_max_estimated_tokens:Ll,degradation_ladder:Rl,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),Ul=new Map(Fl.map(e=>[e.diagnostic_class,e]));function zl(e){let[t=""]=Qe(e).split(/\s+/u);return xl.has(t)?"mutation":Nl.has(t)?"discovery":Dl.has(t)?"governance":"read"}function Qo(e,t=zl(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=Pl[t];return ql({command:n,budget_class:t,default_max_estimated_tokens:r,default_max_estimated_tokens_by_format:{toon:r,json:Math.ceil(r*$l/Ml)},degradation_ladder:Tl,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function ql(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 Bl=Mt.map(e=>Qo(e)),Vl=new Map(Bl.map(e=>[e.command,e]));function Zo(e,t={}){let n=e.trim().replace(/\s+/gu," "),[r]=Qe(n).split(" "),o=Vl.get(r);return o?{...o,command:n}:t.generateFallback?Qo(n):null}function _e(e){return Math.ceil(Math.max(0,e)/4)}function ei(e){let t=Ul.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${Jo.join(", ")}`);return t}function ee(e){return _e(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function Gl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zn(e){if(!Gl(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 Wl(e,t){return typeof e!="string"||e.length<=t?e:`${Z(e,Math.max(1,t-3))}...`}function pe(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 ti(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 Kl=new Set(["limit_collections","compact_recovery","action_only"]),Hl=new Set(["compact_recovery","action_only"]);function Yl(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:Wl(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},n=zn(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 Xl(e,t){let n=structuredClone(e);if(t!=="full"&&(delete n.why,delete n.examples),Kl.has(t))for(let[r,o]of Object.entries(n))Array.isArray(o)&&(n[r]=o.slice(0,3));if(Hl.has(t)){let r=zn(n.recovery);r?n.recovery=r:delete n.recovery}return t!=="action_only"?ti(n):Yl(n)}function xe(e,t){let n={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let r=0;r<4;r+=1){let o=ee(n),i=n.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return n}function Jl(e,t,n){let r=xe(e,t);for(let i of["recovery","exit_code"])ee(r)<=n||e[i]===void 0||(delete e[i],r=xe(e,t));let o=40;for(;ee(r)>n&&o>4;)o-=4,e.code=pe(String(e.code),o),e.required=pe(String(e.required),o),r=xe(e,t);return r}function Ql(e,t){let n=e.diagnostic_output,{estimated_tokens:r,...o}=n,i=o.omitted_fields.slice(0,8).map(m=>pe(m,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=zn(e.recovery),c=a&&ee(a)<=48?a:void 0,d={code:pe(String(e.code),320),required:pe(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},l=xe(d,s);for(;ee(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=xe(d,s);return l=Jl(d,s,t),l}function Nh(e,t={}){let n=e,r=t.diagnosticClass??"error",o=ei(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=ee(n),c=Object.keys(n);if(a<=s)return ti(structuredClone(n));let d;for(let[l,m]of o.degradation_ladder.entries()){let u=Xl(n,m),f=c.filter(_=>!Object.hasOwn(u,_)),p=xe(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,ee(p)<=s)break}return ee(d)>s&&(d=Ql(d,s)),d}function Xo(e){return Il(e).replace(/\r\n/gu,`
|
|
2
|
-
`).replace(/[^\P{Cc}\n]/gu," ")}function
|
|
1
|
+
import{B as On,C as Sn,D as Ie,a as G,b as En,c as co,e as kt,f as Ot,g as St,h as lo,i as At,j as Ce,k as uo,l as kn,o as Ct,p as It,s as He,y,z as h}from"./chunk-7SZPZOIC.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]="c05a5a9e-282c-5ca7-97dc-e48c8df7977e")}catch{}})();var wc=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],fo=wc,Tg=["draft","open","in_progress","blocked","closed","canceled"],Rg=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],mo=["string","number","boolean","string_array","array","object"],xg=["create","update","update_many","list","search","calendar","context"],Ng=["allow","warn","reject"],Dg=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],Pg=["project","global"],$g=["low","medium","high","critical"],Mg=["low","medium","high","critical"],Lg=["low","medium","high"];var jg=["minimal","default","strict","custom"],Fg=["none","warn","strict"],Ug=["progressive","strict"],zg=["off","warn","strict"],qg=["off","warn","strict"];var Bg=["daily","weekly","monthly","yearly"],vc=["mon","tue","wed","thu","fri","sat","sun"];function Vg(e){return vc.indexOf(e)}var Gg=["draft","research","review","approved","executing","paused","completed","superseded"],Wg=["pending","in_progress","completed","blocked","skipped","superseded"],Kg=["codex","claude-code","cursor","generic"],Hg=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],Yg=["brief","standard","deep","full"],Xg=["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 Ec=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 kc(e){return{unknownKeys:Object.keys(e).filter(t=>!Ec.has(t)).sort((t,n)=>t>n?1:-1),missingVersionBounds:e.pm_min_version===void 0&&e.pm_max_version===void 0}}function Oc(e){let t=kc(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 po(e,t,n){return Oc(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 An=[{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 Sc(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 In(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)In(n,t);return Object.freeze(e)}for(let n of Object.values(e))In(n,t);return Object.freeze(e)}function Ac(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 Cc(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 Ic(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 Tc(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 Rc(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 xc(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 Nc(e){return e.traversal?e.traversal:e.ordering?"ordering":e.hierarchy?"hierarchy":e.direction==="undirected"?"association":"semantic"}var Tn=class{#e=new Map;#n=new Map;constructor(t=An){for(let n of t)this.register(n)}register(t){let n=Tc(t);if(Rc(t,n),xc(t,n),Ac(t,n),Cc(t,n),Ic(t,n),this.#e.has(n)||this.#n.has(n))throw new TypeError(`Relationship kind already registered: ${n}`);let r=Sc(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:Nc(t),hierarchy:t.hierarchy??!1,hierarchyDirection:t.hierarchy?t.hierarchyDirection??"source_parent":void 0,inverse:r,aliases:Object.freeze(o),payloadSchema:t.payloadSchema?In(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 Rn(){return new Tn}var ue=Rn();function ny(e){return ue.require(e).kind}function ry(e){return ue.resolve(e)?.kind}function oy(e,t=ue){return t.resolve(e)?.ordering===!0}function Dc(e,t,n,r=ue){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 Pc(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=Dc(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 Cn(e,t){let n=Ye(e);return n&&t.has(n)?n:void 0}function $c(e,t,n){let r=[t],o=t;for(;o!==e;)o=n.get(o),r.push(o);return r.reverse()}var _o=class e{#e;#n;#o;#r;#s=new Map;#a=new Map;constructor(t,n,r=ue){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}=Pc(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=ue){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=Cn(i.parent,r);a&&o.push({source:s,target:a,kind:"parent"});let c=Cn(i.blocked_by,r);c&&o.push({source:s,target:c,kind:"blocked_by"});for(let d of i.dependencies??[]){let l=Cn(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(g=>!a.has(g.id))&&(u=!0);continue}for(let g of _)if(!a.has(g.id)){if(c.length>=i){u=!0;break e}a.add(g.id),c.push(g.id),d.push({id:g.id,depth:p.depth+1})}}return{value:c,meta:{visitedNodes:l,inspectedEdges: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(g=>!d.has(g.id))&&(u=!0);continue}for(let g of _)if(!d.has(g.id)){if(c.set(g.id,p.id),g.id===n)return{value:$c(t,n,c),meta:{visitedNodes:l,inspectedEdges:m,truncated:!1}};d.add(g.id),a.push({id:g.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 iy(e,t,n=ue){return{source:e,target:t.id,kind:n.require(t.kind).kind,createdAt:t.created_at,author:t.author}}import{readFileSync as vd,readdirSync as wy,realpathSync as Ao,statSync as Io}from"node:fs";import Ed from"node:os";import v from"node:path";import Uc 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 J(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Mc(e){let t=e.key.trim();if(t.length===0)return null;let n=J(e.aliases),r=e.description?.trim();return{key:t,values:J(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 Lc=e=>e,yo=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 Fc(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 go(e,t){return t?J(e):void 0}function xn(e){let t=e?.trim();return t&&t.length>0?t:void 0}function Nn(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 ho(e,t={}){let n=t.resolvePolicyCommand??Lc,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=J(e.aliases),d=(e.options??[]).map(m=>Mc(m)).filter(m=>m!==null).sort((m,u)=>m.key.localeCompare(u.key)),l=Fc(e.command_option_policies,n);return{name:r,description:xn(e.description),default_status:xn(e.default_status),...e.execution_role===void 0?{}:{execution_role:Nn(e.execution_role)},folder:xn(e.folder),aliases:c.length>0?c:void 0,required_create_fields:go(e.required_create_fields,o),required_create_repeatables:go(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 zc=Object.freeze({decision:"human",milestone:"gate"}),qc=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],Bc=["dep","comment","note","learning","file","test","doc"],wo=["deadline","estimatedMinutes","acceptanceCriteria","definitionOfReady","order","goal","objective","value","impact","outcome","whyNow","assignee","parent","reviewer","risk","confidence","sprint","release","blockedBy","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact"],Vc=["title","description","type","status","priority","tags","body",...wo,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],Gc=["title","description","body","status","closeReason","priority","type","tags",...wo,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],vo={"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"},Wc={...vo},Kc={...vo},Eo=[["deadline","--deadline"],["estimatedMinutes","--estimate/--estimated-minutes"],["acceptanceCriteria","--acceptance-criteria/--ac"],["definitionOfReady","--definition-of-ready"],["order","--order/--rank"],["goal","--goal"],["objective","--objective"],["value","--value"],["impact","--impact"],["outcome","--outcome"],["whyNow","--why-now"],["assignee","--assignee"],["parent","--parent"],["reviewer","--reviewer"],["risk","--risk"],["confidence","--confidence"],["sprint","--sprint"],["release","--release"],["blockedBy","--blocked-by"],["blockedReason","--blocked-reason"],["unblockNote","--unblock-note"],["reporter","--reporter"],["severity","--severity"],["environment","--environment"],["reproSteps","--repro-steps"],["resolution","--resolution"],["expectedResult","--expected-result"],["actualResult","--actual-result"],["affectedVersion","--affected-version"],["fixedVersion","--fixed-version"],["component","--component"],["regression","--regression"],["customerImpact","--customer-impact"]],ko=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function Oo(e){return Object.fromEntries(e)}var Hc=Oo([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...Eo,["author","--author"],["message","--message"],["dep","--dep"],...ko]),Yc=Oo([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...Eo,...ko,["author","--author"],["message","--message"],["force","--force"]]);function Xc(e){return e.trim().replace(/^--+/,"").toLowerCase()}function Jc(e){return e==="create"?Vc:Gc}function Qc(e){return e==="create"?Wc:Kc}function So(e,t){let n=Xc(t);return n.length===0?void 0:Qc(e)[n]||Jc(e).find(r=>r.toLowerCase()===n)}function py(e,t){return(e==="create"?Hc:Yc)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function Pn(e){let t=ed(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function Zc(e){let t=e.trim(),n=t.replaceAll("\\","/").replace(/^\/+/,""),r=Uc.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 ed(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 td(e){return ho(e,{resolvePolicyCommand:yo})}function Xe(e,t){let n=e[t];return Array.isArray(n)?n.filter(r=>typeof r=="string"):void 0}function nd(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 rd(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 od(e){if(Array.isArray(e.options))return e.options.map(t=>nd(t)).filter(t=>t!==null)}function id(e){if(Array.isArray(e.command_option_policies))return e.command_option_policies.map(t=>rd(t)).filter(t=>t!==null)}function sd(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:Nn(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:od(t),command_option_policies:id(t)}}function ad(e,t){return e.required_create_fields?J(e.required_create_fields):t?.required_create_fields??[]}function cd(e,t){return e.required_create_repeatables?J(e.required_create_repeatables):t?.required_create_repeatables??[]}function dd(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function ld(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function ud(e,t){let n=t?.name??e.name,r=e.description??t?.description,o=e.default_status??t?.default_status,i=Zc(e.folder??t?.folder??Pn(n)),s={name:n,execution_role:e.execution_role,folder:i,aliases:J([...t?.aliases??[],...e.aliases??[]]),required_create_fields:ad(e,t),required_create_repeatables:cd(e,t),options:dd(e,t),command_option_policies:ld(e,t)};return r&&(s.description=r),o&&(s.default_status=o),s}function bo(e,t){for(let n of e){let r=td(n);if(!r)continue;let o=r.name.toLowerCase(),i=t.get(o);t.set(o,ud({...r,execution_role:r.execution_role??i?.execution_role},i))}}function fd(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=sd(o);i&&t.push(i)}}return t}function _y(e,t=null){let n=new Map;for(let c of fo)n.set(c.toLowerCase(),{name:c,execution_role:zc[c.toLowerCase()]??"agent",folder:He[c],aliases:[],required_create_fields:[...qc],required_create_repeatables:[...Bc],options:[],command_option_policies:[]});bo(e.item_types?.definitions??[],n),bo(fd(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 md(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function pd(e,t){let n=md(e,t);if(n)return t.by_type[n]}function _d(e,t,n,r){for(let o of r){let i=So(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 Dn(e,t,n){if(n){e.add(t);return}e.delete(t)}function gd(e,t,n,r){let o=So(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&&Dn(e.required,o,r.required),r.visible!==void 0&&Dn(e.hidden,o,!r.visible),r.enabled!==void 0&&Dn(e.disabled,o,!r.enabled)}function yd(e,t,n){for(let r of t.command_option_policies)r.command===n&&gd(e,t,n,r)}function hd(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 gy(e,t,n){let r=[],o=new Set,i=new Set,s=new Set,a={required:o,hidden:i,disabled:s,errors:r};return _d(a,e,t,n),yd(a,e,t),hd(a,e,t),{required:[...o],hidden:[...i].sort((c,d)=>c.localeCompare(d)),disabled:[...s].sort((c,d)=>c.localeCompare(d)),errors:r}}function bd(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 wd(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 yy(e,t,n){let r=pd(e,n);if(!r)return{normalized:void 0,errors:[`Unknown type "${e}"`]};let o=[],i=bd(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=wd(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}}(function(){try{var e=typeof window<"u"?window:typeof 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 kd={json_markdown:".md",toon:".toon"},Od={".md":"json_markdown",".toon":"toon"};var Cy=[".md",".toon"];function Dt(e){try{return Io(e),!0}catch{return!1}}function Sd(e){let t=v.resolve(e),n=[];for(;v.dirname(t)!==t;)try{return v.join(Ao(t),...n)}catch(r){if(!Sn(r))throw r;n.unshift(v.basename(t)),t=v.dirname(t)}return v.join(Ao(t),...n)}function Ad(e){try{return Io(e),!0}catch(t){if(Sn(t))return!1;throw t}}function Cd(e){try{let t=JSON.parse(vd(e,"utf8"));return typeof t!="object"||t===null||Array.isArray(t)?!1:"id_prefix"in t||"item_format"in t}catch{return!1}}function Id(e){let t=Sd(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)&&Cd(o))return t;if(Ad(v.join(t,".git")))return n;let i=v.dirname(t);if(i===t)return;t=i}}function $n(e){return Id(e)??v.resolve(e,Ct)}function To(e,t){let n=process.env.PM_PATH,r=t?.trim()||n?.trim();if(r){let o=v.resolve(e,r);if(!Dt(Co(o))){let i=v.join(o,Ct);if(Dt(Co(i)))return i}return o}return $n(e)}function Ro(e){let t=v.resolve(e),n=v.dirname(t);return v.basename(t)==="pm"&&v.basename(n)===".agents"?v.dirname(n):t}function xo(e){let t=process.env.PM_GLOBAL_PATH?.trim(),n=t&&t.length>0?t:v.join(Ed.homedir(),".pm-cli");return v.resolve(e,n)}function Co(e){return v.join(e,It)}function Td(e,t,n=He){let r=n[t]??Pn(t);return v.join(e,r)}function Iy(e,t,n,r="toon",o=He){return v.join(Td(e,t,o),`${n}${kd[r]}`)}function Ty(e){let t=e.replaceAll("\\","/"),n=v.posix.extname(t).toLowerCase();return Od[n]??null}function Ry(e,t){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(t))throw new h("Invalid history item id: expected a single filename.",y.USAGE);return v.join(e,"history",`${t}.jsonl`)}function Mn(e,t){return v.join(e,"locks",`${t}.lock`)}function xy(e){return v.join(e,"runtime")}import{createHash as Po}from"node:crypto";import Rd 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 xd(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 Nd(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=xd(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 Nd(e)}function fe(e){return JSON.stringify(Pt(e))}function No(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 Dd(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function Pd(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function $d(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(!No(o,n,r,B))return!1;return!0}function Md(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(!No([o,i],n,r,([s,a],[c,d])=>B(s,c)&&B(a,d)))return!1;return!0}function Ld(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,r)=>B(n,t[r]))}function 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]||!B(e[i],t[i]))return!1}return!0}var Fd=[Dd,Pd,$d,Md,Ld];function B(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let n of Fd){let r=n(e,t);if(r!==void 0)return r}return jd(e,t)}function Py(e){return Rd.createHash("sha256").update(e,"utf8").digest("hex")}function $y(e,t){let n={};for(let o of t){let i=e[o];i!==void 0&&(n[o]=i)}let r=Object.keys(e).filter(o=>!t.includes(o)).sort((o,i)=>o.localeCompare(i));for(let o of r){let i=e[o];i!==void 0&&(n[o]=i)}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f675993f-c483-5751-baed-d968b4fd24c0")}catch{}})();var Ud=["policies","policy-put","policy-remove","policy-mode","policy-check","policy-approve","policy-presets"],Do=256,Ln=64;function U(e){throw new h(`Invalid workflow policy: ${e}`,y.USAGE,{code:"workflow_policy_invalid",nextSteps:["Inspect pm schema policies and correct the declaration using pm schema policy-put."]})}function W(e,t,n){if(typeof e!="object"||e===null||Array.isArray(e))return U(`${n} must be an object`);let r=e;return Object.keys(r).some(o=>!t.includes(o))?U(`${n} contains an unknown key`):r}function me(e,t,n=128){return typeof e!="string"||!e.trim()||e.length>n?U(`${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>Ln)return U(`${t} requires 1-${Ln} terms`);let n=e.map(r=>me(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)))?U("fields must be safe metadata paths of at most eight segments"):[...new Set(n)]}function zd(e){let t=W(e,["kind","fields","authors","allowed"],"rule");return t.kind==="transition"?(W(t,["kind","allowed"],"transition rule"),!Array.isArray(t.allowed)||t.allowed.length>Ln?U("transition.allowed must be a bounded array"):{kind:"transition",allowed:t.allowed.map(n=>!Array.isArray(n)||n.length!==2?U("transition pairs need two statuses"):[me(n[0],"from"),me(n[1],"to")])}):t.kind==="authors"?(W(t,["kind","authors"],"authors rule"),{kind:"authors",authors:Je(t.authors,"authors")}):t.kind==="require_fields"?(W(t,["kind","fields"],"require_fields rule"),{kind:"require_fields",fields:Je(t.fields,"fields")}):t.kind==="field_writers"||t.kind==="approval"?(W(t,["kind","fields","authors"],"field rule"),{kind:t.kind,fields:Je(t.fields,"fields"),authors:Je(t.authors,"authors")}):U("unknown rule kind")}function qd(e){let t={},n=W(e,["types","tags","statuses","operations","parents","dependency"],"subject");for(let r of["types","tags","statuses","operations","parents"])n[r]!==void 0&&(t[r]=Je(n[r],r));if(n.dependency!==void 0){let r=W(n.dependency,["kind","id"],"dependency");t.dependency={kind:me(r.kind,"dependency kind"),...r.id===void 0?{}:{id:me(r.id,"dependency id")}}}return t}function Bd(e){let t=W(e,["id","description","subject","effect","rule"],"policy"),n=me(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))?U("effect must be advise, warn, or refuse"):{id:n,rule:zd(t.rule),...t.subject===void 0?{}:{subject:qd(t.subject)},...t.description===void 0?{}:{description:me(t.description,"description",500)},...t.effect===void 0?{}:{effect:t.effect}}:U("id must be a stable token")}function Vd(e){let t=W(e,["version","enforcement","policies"],"document");if(t.version!==1)return U("unsupported version");if(t.enforcement!==void 0&&t.enforcement!=="advise"&&t.enforcement!=="refuse")return U("enforcement must be advise or refuse");if(!Array.isArray(t.policies)||t.policies.length>Do)return U(`policies must contain at most ${Do} declarations`);let n=t.policies.map(Bd);return new Set(n.map(r=>r.id)).size!==n.length?U("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 Gd(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 $o(e){return Po("sha256").update(fe(e)).digest("hex")}function Wd(e,t){let n=e.rule.kind==="approval"?e.rule.fields:[];return Po("sha256").update(fe({id:t.id,fields:n.map(r=>[r,$t(t,r)])})).digest("hex")}function Kd(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 Hd(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&&!Kd(e.dependency,t.dependencies))}function Yd(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&&Hd(n,{...o,status:r},t.operation))}function Xd(e,t,n,r){let o=["type","tags","parent","dependencies"].some(i=>!B(t.before?.[i],t.after?.[i]));return t.after&&(t.completeness_only||n||r||o)?e.filter(i=>!Gd($t(t.after,i))):[]}function Jd(e,t,n,r){let o=t.after??t.before,i=Wd(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 Qd(e,t,n){let r=e.rule,o=t.before?.status!==t.after?.status,i="fields"in r&&r.fields.some(s=>!B($t(t.before,s),$t(t.after,s)));switch(r.kind){case"require_fields":{let s=Xd(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||Jd(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 Mo(e,t,n){let r=e.policies.filter(o=>Yd(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,...Qd(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 zy(e,t){return Mo(e,t,$o)}function qy(e){let t=Vd(e),n=new Map(t.policies.map(r=>[r,$o(r)]));return r=>Mo(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 Zd=[["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"})),el=[...["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"})),tl=[["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"})),nl=[...el,...tl,...["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}))],jn=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:!0,registration:"commander",owner:"pm-3z0k"},...Zd,...nl,...["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 Vy(e){let t;for(let n of jn)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 rl(e){let t=e.trim().replace(/\s+/gu," ");return jn.find(n=>n.canonical===t.replace(/^ctx /u,"context "))?.alias??t}function Qe(e){return rl(e)}var Mt=[...jn,...[["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"}))],Gy=Object.fromEntries(Mt.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function Wy(e){let t=e.trim().toLowerCase();return Mt.find(n=>n.alias===t)}function Ky(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 ol=[...G],il=[...Ce],sl=[...kt],Qy=[...Ot],Zy=[...St],al=[...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"],eh=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],th=["install","reconcile","report","driver"],cl=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],dl=["upgrade"],ll=["reopen"],Lo={help:"Commander help rendering has no SDK operation result.",packages:"The plural package alias only renders package-oriented help."},Te=Object.freeze(Lt.flatMap(e=>e in Lo?[]:e==="extension"||e==="package"?[...cl.map(t=>`${e}-${t}`),...e==="package"?dl.map(t=>`package-${t}`):[],e]:e==="item"?ll.map(t=>`item-${t}`):[e])),ul=Object.freeze(Mt.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&Te.includes(e.alias)).map(e=>e.alias)),nh=Object.freeze(Te.filter(e=>!ul.includes(e)));function rh(e=Lt,t=Te,n=Lo){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 oh(e){return Te.includes(e)}function ih(e){return ol.includes(e)}function sh(e){return il.includes(e)}function ah(e){return sl.includes(e)}function ch(e){return al.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"]),Re=["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 fl(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function jo(e){return e?P(e):{}}function Fo(e){return e?P(e):fl()}function P(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 ml=new Set(["commands","command_overrides","command_handlers","flag_commands","parser_overrides"]),pl=["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 _l(e,t){for(let n of pl){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=>ml.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 gl(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 yl(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(!_l(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=gl(o);if(s===null)return null;n.renderer_ownership=s}let i=t.preflight_ownership;if(i!==void 0){let s=yl(i);if(s===null)return null;n.preflight_ownership=s}return n}function mh(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 hl=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"}]),Fn=new Set(hl.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 Uo=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function Un(e){if(typeof e!="string")return null;let t=Uo.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 yh(e){let t=Un(e);return t?t.name:typeof e=="string"&&e.trim()||null}function bl(e){if(typeof e!="string")return null;let t=e.trim(),n=t.split(/[ =]/,1)[0];return Fn.has(n)?"host_owned_flag_collision":Uo.test(t)?null:"malformed_long_flag"}function zo(e,t){let n=[e,t].find(i=>typeof i=="string"&&Fn.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=bl(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 Bo=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(Bo,t)?Bo[t]:null}function wl(e,t,n){return!!(e.value_name?.trim()||t||n||e.required===!0||e.list===!0||e.repeatable===!0)}function vl(e){return(e.value_type?.trim()||e.type?.trim())?.toLowerCase()}function wh(e){let t=vl(e),n=zt(t),r=Un(e.long),o=e.value_name?.trim()||null,i=!(n==="boolean"&&t!=="bool")&&wl(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 Vo(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 Go(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]="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 Q(e){return G.includes(e)}function Wo(e){let t=e.trim().toLowerCase();return Q(t)?t:null}function Ko(e){return e.filter(t=>!Q(t))}function zn(e){let t=e.trim().toLowerCase();return t.length===0?null:co[t]??null}function Ho(e){let t=Ze([...e].map(i=>i.toLowerCase())),n=[],r=[];for(let i of t){let s=zn(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 El(e){let t=e.trim().toLowerCase();if(t.length===0)return null;let n=zn(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 G){let a=Tt(t,s,r);a!==null&&a<i&&(i=a,o=s)}return o}function Yo(e,t,n){let r=G.join(","),o=El(n)??"none";return`extension_capability_unknown:${e}:${t}:${n}:allowed=${r}:suggested=${o}`}function Xo(e,t,n){let r=n.map(o=>`${o.alias}>${o.target}`).join(",");return`extension_capability_legacy_alias:${e}:${t}:aliases=${r}`}function kl(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=zn(o),l=(s==="none"?void 0:s)??d??void 0;return{layer:a,name:r,capability:o,allowed_capabilities:c,capability_contract_version:En,suggested_capability:l,suggestion_source:l?d===l?"legacy_alias":"nearest_match":void 0,legacy_alias_target:d??void 0}}function Ol(e){let t=/^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(e.trim());if(!t)return[];let[,n,r,o]=t,i=n,s=[...G],a=[];for(let c of o.split(",")){let[d,l]=c.split(">"),m=d?.trim(),u=l?.trim().toLowerCase();!m||!u||!Q(u)||a.push({layer:i,name:r,capability:m,allowed_capabilities:s,capability_contract_version:En,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 Sl={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"]},Jo=":";function Qo(e,t){return`${e}${Jo}${qn(t)}`}function Al(e){return e.slice(e.indexOf(Jo)+1)}function qn(e){return e.trim().toLowerCase()}function Cl(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let r=Wo(n);r!==null&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function Zo(e){let t=new Map,n=(l,m)=>{for(let u of l){let f=Qo(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 Il(e,t={}){let n=Zo(e),r=new Set;t.extensionName!==void 0&&r.add(qn(t.extensionName));for(let i of t.extensionNames??[])r.add(qn(i));let o=new Set;for(let[i,s]of n)if(!(r.size>0&&!r.has(Al(i))))for(let a of s)o.add(a);return[...o].sort((i,s)=>i.localeCompare(s))}function Tl(e,t){let n=Zo(t),r=[];for(let o of e){let i=Cl(o.capabilities);if(i.length===0)continue;let s=n.get(Qo(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}(function(){try{var e=typeof window<"u"?window:typeof 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 Rl(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function Z(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 Ch(e){return Rl(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function Ih(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 xl}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]="1a14ce9e-1074-5434-9646-dd5e25e34814")}catch{}})();var Nl=["full","compact","brief","summary","counts"],Ph=["mutation","read","discovery","governance"],ti=["error","warning","validation_summary","recovery_bundle"],Dl=["full","omit_explanation","limit_collections","compact_recovery","action_only"],Pl=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"]),$l=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),Ml=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),Ll={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},jl=3,Fl=2,Ul=192,zl={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},ql=ti.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:zl[e],minimum_max_estimated_tokens:Ul,degradation_ladder:Dl,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),Bl=new Map(ql.map(e=>[e.diagnostic_class,e]));function Vl(e){let[t=""]=Qe(e).split(/\s+/u);return Pl.has(t)?"mutation":$l.has(t)?"discovery":Ml.has(t)?"governance":"read"}function ni(e,t=Vl(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=Ll[t];return Gl({command:n,budget_class:t,default_max_estimated_tokens:r,default_max_estimated_tokens_by_format:{toon:r,json:Math.ceil(r*jl/Fl)},degradation_ladder:Nl,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function Gl(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 Wl=Lt.map(e=>ni(e)),Kl=new Map(Wl.map(e=>[e.command,e]));function ri(e,t={}){let n=e.trim().replace(/\s+/gu," "),[r]=Qe(n).split(" "),o=Kl.get(r);return o?{...o,command:n}:t.generateFallback?ni(n):null}function _e(e){return Math.ceil(Math.max(0,e)/4)}function oi(e){let t=Bl.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${ti.join(", ")}`);return t}function ee(e){return _e(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function Hl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Bn(e){if(!Hl(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 Yl(e,t){return typeof e!="string"||e.length<=t?e:`${Z(e,Math.max(1,t-3))}...`}function pe(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 ii(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 Xl=new Set(["limit_collections","compact_recovery","action_only"]),Jl=new Set(["compact_recovery","action_only"]);function Ql(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:Yl(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},n=Bn(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 Zl(e,t){let n=structuredClone(e);if(t!=="full"&&(delete n.why,delete n.examples),Xl.has(t))for(let[r,o]of Object.entries(n))Array.isArray(o)&&(n[r]=o.slice(0,3));if(Jl.has(t)){let r=Bn(n.recovery);r?n.recovery=r:delete n.recovery}return t!=="action_only"?ii(n):Ql(n)}function xe(e,t){let n={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let r=0;r<4;r+=1){let o=ee(n),i=n.diagnostic_output;if(i.estimated_tokens===o)break;i.estimated_tokens=o}return n}function eu(e,t,n){let r=xe(e,t);for(let i of["recovery","exit_code"])ee(r)<=n||e[i]===void 0||(delete e[i],r=xe(e,t));let o=40;for(;ee(r)>n&&o>4;)o-=4,e.code=pe(String(e.code),o),e.required=pe(String(e.required),o),r=xe(e,t);return r}function tu(e,t){let n=e.diagnostic_output,{estimated_tokens:r,...o}=n,i=o.omitted_fields.slice(0,8).map(m=>pe(m,32)),s={...o,omitted_fields:i,...o.omitted_fields.length>i.length?{omitted_fields_overflow_count:o.omitted_fields.length-i.length}:{}},a=Bn(e.recovery),c=a&&ee(a)<=48?a:void 0,d={code:pe(String(e.code),320),required:pe(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},l=xe(d,s);for(;ee(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=xe(d,s);return l=eu(d,s,t),l}function $h(e,t={}){let n=e,r=t.diagnosticClass??"error",o=oi(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=ee(n),c=Object.keys(n);if(a<=s)return ii(structuredClone(n));let d;for(let[l,m]of o.degradation_ladder.entries()){let u=Zl(n,m),f=c.filter(_=>!Object.hasOwn(u,_)),p=xe(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,ee(p)<=s)break}return ee(d)>s&&(d=tu(d,s)),d}function ei(e){return xl(e).replace(/\r\n/gu,`
|
|
2
|
+
`).replace(/[^\P{Cc}\n]/gu," ")}function Mh(e,t,n={}){let r=n.diagnosticClass??"error",o=oi(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=ei(e),c=_e(Buffer.byteLength(a,"utf8")),d=c>s,l=`What is required:
|
|
3
3
|
`,m=`
|
|
4
4
|
|
|
5
5
|
${pe(a.trimStart().split(/\r?\n/u,1)[0].trim(),320)}
|
|
6
6
|
|
|
7
|
-
Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,u=Xo(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}${pe(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:_e(Buffer.byteLength(p,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}import{existsSync as Pf}from"node:fs";import{AsyncLocalStorage as $f}from"node:async_hooks";import H from"node:path";import we from"node:fs/promises";import be from"node:path";import{pathToFileURL as ef}from"node:url";import ni 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 qn(e,t){let n=ni.relative(e,t);return n.length===0?!0:!n.startsWith("..")&&!ni.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 Zl="__pm_suppress_host_output",Bn="@unbrained/pm-cli:suppress-host-output:v1";function ri(e){return e===void 0?{__pm_suppress_host_output:Bn}:{__pm_suppress_host_output:Bn,result:e}}function Vn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[Zl]===Bn}import Ne from"node:fs";import te from"node:path";import{fileURLToPath as eu}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 tu="@unbrained/pm-cli";function nu(e){try{return JSON.parse(Ne.readFileSync(e,"utf8")).name===tu}catch{return!1}}function ru(e){let t=Ne.existsSync(e)&&Ne.statSync(e).isDirectory()?te.resolve(e):te.dirname(te.resolve(e));for(;;){let n=te.join(t,"package.json");if(Ne.existsSync(n)&&nu(n))return t;let r=te.dirname(t);if(r===t)return;t=r}}function Gn(e,t=[]){let n=eu(e);return ru(n)||te.resolve(te.dirname(n),...t)}function zh(e,t=[]){try{let n=te.join(Gn(e,t),"package.json");if(!Ne.existsSync(n))return;let r=JSON.parse(Ne.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 ou(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Bh(e){return ou(e)??void 0}function Vh(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 Gh(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function ii(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function si(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 Wh(e){let t=si(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function Kh(e,t,n){let r=si(e);return r===null||r<t||r>n?null:r}function Hh(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function ne(e){return typeof e!="object"||e===null?null:e}function oi(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function ai(e){let t=oi(e);if(!t)return null;if(typeof t.activate=="function")return t;let n=oi(t.default);return typeof n?.activate=="function"?n:null}function Yh(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 ci(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 N(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 di(e,t){if(t===void 0)return;let n=r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean";if(Array.isArray(t)){for(let[r,o]of t.entries())if(!n(o))throw new TypeError(`${e}[${r}] must be a string, number, or boolean`);return}if(!n(t))throw new TypeError(`${e} must be a string, number, or boolean, or an array of these when provided`)}function ge(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 et(e,t){if(ge(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 Wn=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 iu=new Set(Wn);function su(e){if(e!==void 0&&!iu.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${Wn.join(", ")}`)}function li(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");su(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 ui(e,t="",n=""){if(e===void 0)return;if(De(t)||De(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 De(e){let t=e.trim().toLowerCase().replace(/\s+/gu,"-");return Te.includes(t)||Re.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 au(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 fi(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=au(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 Kn(e,t,n){return{registration:t,action:n,command:e.command,args:P(e.args),options:P(e.options),global:P(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 mi(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 cu(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 Pe(e){return new Set((e??[]).map(t=>cu(t)).filter(t=>t.length>0))}function pi(e){let t=q(e);return Et.includes(t)?t:"off"}function _i(e){let t=q(e);return kt.includes(t)?t:"off"}function tt(e){let t=q(e);return Ot.includes(t)?t:"none"}function Hn(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return ao.includes(t)?t:void 0}function gi(e){if(typeof e=="string"){let t=Hn(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:Hn(e.global)??"block",project:Hn(e.project)??"block"}:{global:"block",project:"block"}}function du(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 lu(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?tt(e.sandbox_profile):void 0,allowedCapabilities:w(e.allowed_capabilities),blockedCapabilities:w(e.blocked_capabilities),allowedSurfaces:Pe(e.allowed_surfaces),blockedSurfaces:Pe(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 yi(e){let t=new Map;for(let n of e??[]){let r=lu(n);r&&t.set(r.name,r.normalized)}return t}function uu(e){let t=[],n=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of E([...e.allowedCapabilities,...e.blockedCapabilities]))Q(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of n)for(let i of E([...o.allowedCapabilities,...o.blockedCapabilities]))Q(i)||t.push(`extension_policy_unknown_capability:${o.name}:${i}`);let r=new Set(St);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 hi(e){let t=e.extensions?.policy??{},n=w(t.allowed_capabilities),r=w(t.blocked_capabilities),o=Pe(t.allowed_surfaces),i=Pe(t.blocked_surfaces),s=yi(t.extension_overrides);return{mode:pi(t.mode),trustMode:_i(t.trust_mode),pmMaxVersionExceededMode:gi(t.pm_max_version_exceeded_mode),requireProvenance:t.require_provenance===!0,trustedExtensions:w(t.trusted_extensions),defaultSandboxProfile:tt(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:uu({allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function bi(e){let t=[...e.overridesByName.values()].sort((n,r)=>n.name.localeCompare(r.name)).map(n=>({name:n.name,...n.disabled?{disabled:!0}:{},...n.requireTrusted?{require_trusted:!0}:{},...n.requireProvenance?{require_provenance:!0}:{},...n.sandboxProfile?{sandbox_profile:n.sandboxProfile}:{},...n.allowedCapabilities.size>0?{allowed_capabilities: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:du(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 wi(e){let t=yi(e.extension_overrides);return{mode:pi(e.mode),trustMode:_i(e.trust_mode),pmMaxVersionExceededMode:gi(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:w(e.trusted_extensions),defaultSandboxProfile:tt(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:Pe(e.allowed_surfaces),blockedSurfaces:Pe(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 $e(e,t,n,r,o){return t.has(n)?o:e.size>0&&!e.has(n)?r:null}function vi(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 $e(i,s,r,"capability_not_allowlisted","capability_blocked")}function fu(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 $e(o,i,n,"surface_not_allowlisted","surface_blocked")}function mu(e,t,n){let r=S(n);if(r.length===0)return null;let o=re(e,t.name),i=o&&o.allowedCommands.size>0?o.allowedCommands:e.allowedCommands,s=new Set([...e.blockedCommands,...o?o.blockedCommands:[]]);return $e(i,s,r,"command_not_allowlisted","command_blocked")}function pu(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 $e(i,s,r,"action_not_allowlisted","action_blocked")}function _u(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 $e(i,s,r,"service_not_allowlisted","service_blocked")}function gu(e,t){let n=q(t.name);return re(e,t.name)?.disabled===!0?"extension_override_disabled":$e(e.allowedExtensions,e.blockedExtensions,n,"extension_not_allowlisted","extension_blocked")}function yu(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 hu(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 zt(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 Ei(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let n=[],r=gu(e,t);r&&n.push({reason:r,scope:"extension",mode:e.mode});let o=yu(e,t);o&&n.push({reason:o,scope:"trust",mode:e.trustMode});let i=hu(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:zt("blocked",s.scope,t,s.reason)};let a=n.find(c=>c.mode==="warn");return a?{allowed:!0,warning:zt("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function ki(e,t,n){if(e.mode==="off")return{allowed:!0,warning:null};let r=vi(e,t,n);return r?{allowed:e.mode==="warn",warning:zt(e.mode==="warn"?"violation":"blocked","capability",t,r,{capability:n.trim().toLowerCase()})}:{allowed:!0,warning:null}}function bu(e,t,n,r,o){let i=typeof r=="string"?vi(e,t,r):null,s=fu(e,t,n),a=o.command?mu(e,t,o.command):null,c=o.action?pu(e,t,o.action):null,d=o.service?_u(e,t,o.service):null;return i??s??a??c??d}function wu(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 Oi(e,t,n,r,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=bu(e,t,n,o,s);if(!a)return{allowed:!0,warning:null};let c=zt(e.mode==="warn"?"violation":"blocked","registration",t,a,wu(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 qt(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function Yn(){return{overrides:[],handlers:[]}}function Xn(){return{overrides:[]}}function Jn(){return{overrides:[]}}function Qn(){return{overrides:[]}}function Zn(){return{overrides:[]}}function er(){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 Ai=100;function Si(e,t){let n=e[t];if(n!=null)return typeof n!="string"||n.trim().length===0?null:n.trim()}function vu(e){if(e==null)return;let t=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 tr(e,t){let n=e[t];return typeof n!="string"||n.trim().length===0?null:n.trim()}function Ci(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function ye(e){if(e!=null)return typeof e!="boolean"?null:e}function Eu(e){let t=Ci(e.priority);return t===void 0?Ai:t}function ku(e){let t=e.sandbox_profile;if(t==null)return;if(typeof t!="string")return null;let n=tt(t);return n!==t.trim().toLowerCase()?null:n}function nr(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Ou(e){if(e==null)return;let t=ne(e);if(!t)return null;let n=nr(t.source),r=nr(t.signature),o=nr(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 Su(e){if(e==null)return;let t=ne(e);if(!t)return null;let n=ye(t.fs_read),r=ye(t.fs_write),o=ye(t.network),i=ye(t.env_read),s=ye(t.env_write),a=ye(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 Au(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(n=>typeof n!="string"))return null;let t=Vo(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function Cu(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 Iu(e){let t=Ci(e.manifest_version);if(t===null)return null;let n=Si(e,"pm_min_version");if(n===null)return null;let r=Si(e,"pm_max_version");if(r===null)return null;let o=vu(e.engines);if(o===null)return null;let i=ye(e.trusted);if(i===null)return null;let s=ku(e);if(s===null)return null;let a=Ou(e.provenance);if(a===null)return null;let c=Su(e.permissions);if(c===null)return null;let d=Au(e.capabilities);if(d===null)return null;let l=Cu(e.activation);if(l===null)return null;let m=Ft(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 rr(e){if(typeof e!="object"||e===null)return null;let t=e,n=tr(t,"name");if(n===null)return null;let r=tr(t,"version");if(r===null)return null;let o=tr(t,"entry");if(o===null)return null;let i=Eu(t);if(i===null)return null;let s=Iu(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 Ii=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"}]]),Tu=/^[a-z][a-z0-9_]{0,63}$/u,Ru=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))),xu={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function Nu(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&Ii.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:Ru.get(Math.abs(t.errno))??null}function Du(e,t,n={}){let r=Nu(e);if(r===null)return null;if(!Tu.test(t))throw new h("Host environment operation labels must be bounded identifiers.",y.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=Ii.get(r);return new h(`Host filesystem operation ${t} ${o.summary}.`,y.GENERIC_FAILURE,{code:n.codes?.[o.category]??xu[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 Ti(e,t,n={}){try{return await t()}catch(r){throw Du(r,e,n)??r}}import Pu from"node:fs/promises";import nt 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 Ri(e,t){let n=nt.dirname(t.manifest_path),r=nt.relative(n,t.entry_path);if(r.startsWith("..")||nt.isAbsolute(r))throw new Error(`Cannot snapshot extension entry outside its package directory: ${t.entry_path}`);let o=nt.join(e,`${t.layer}-${t.directory.replace(/[^a-zA-Z0-9._-]/gu,"_")}`);return await Ti("extension_module_graph_snapshot",()=>Pu.cp(n,o,{recursive:!0,force:!0})),nt.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 xi(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 Ni(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 Bt=uo;function Di(e){let t=e.trim().toLowerCase();return Bt.includes(t)?t:null}function Pi(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 Bt)if(It(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 $i(e){return e==="toon"||e==="json"}function Mi(e){return Ce.includes(e)}function he(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var Li=Symbol("extension_registration_trace");function K(e,t){let n=new TypeError(e);return Object.defineProperty(n,Li,{value:t,enumerable:!1,configurable:!1,writable:!1}),n}function ji(e){return e instanceof Error?e[Li]:void 0}function rt(e){if(e===null)return null;if(Array.isArray(e))return e.map(t=>rt(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]=rt(t[r]);return n}return e}function ot(e){if(Array.isArray(e))return e.map(t=>ot(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]=ot(t[r]);return n}return e}function Me(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError(`${e} requires an object definition`);return rt(t)}function it(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(!Array.isArray(t))throw new TypeError(`${e} requires an array of object definitions`);return t.map(n=>Me(e,n))}function $(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function at(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function or(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function ir(e,t){return S(`${e} ${t}`)}function ct(e,t){return Object.defineProperty(e,"runtime_definition",{value:t,enumerable:!1,writable:!1,configurable:!1}),e}var $u=new Set(["low","medium","high"]),Mu=new Set(["number","string_set"]),Lu=new Set(["string","number","boolean"]);function Fi(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function ju(e,t,n){let r=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=C(r,n);if(!Mu.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}`;Fi(`${c}.name`,s);let d=C(c,a);if(!Lu.has(String(d.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);N(`${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 Ui(e){let t=C("registerAssuranceMeasurementProvider provider",e),n=Fi("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(!$u.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`);ju(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 Fu=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","value_validation","visible"]);function Vt(e,t){return st(e,t).map(n=>(n.repeatable===!0&&(n.list=!0),n))}function Uu(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function sr(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=Uu(t);if(n.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return n}function ar(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=$(`registerCommand definition.arguments[${r}].name`,i.name);if(N(`registerCommand definition.arguments[${r}].required`,i.required),N(`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 Gt(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=>!Fu.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=Lo(i,s);if(a!==null)throw new TypeError(`registerFlags flags[${t}] ${jo(a.token,a.failure)}`);if(A(`registerFlags flags[${t}].value_name`,r.value_name),A(`registerFlags flags[${t}].description`,r.description),N(`registerFlags flags[${t}].required`,r.required),N(`registerFlags flags[${t}].enabled`,r.enabled),N(`registerFlags flags[${t}].visible`,r.visible),N(`registerFlags flags[${t}].list`,r.list),N(`registerFlags flags[${t}].repeatable`,r.repeatable),r.list!==void 0&&r.repeatable!==void 0&&r.list!==r.repeatable)throw new TypeError(`registerFlags flags[${t}].list and repeatable must match when both are provided`);if(di(`registerFlags flags[${t}].default`,r.default),Array.isArray(r.default)&&r.list!==!0&&r.repeatable!==!0)throw new TypeError(`registerFlags flags[${t}].default cannot be an array unless list is true.`);zi(`registerFlags flags[${t}]`,r),zu(`registerFlags flags[${t}]`,r)}}function zu(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:Ut(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 zi(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=Ut(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?Uo(t.default):[t.default];for(let[i,s]of o.entries())if(!zo(s,r)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${r}.`)}}function qi(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);$(`registerItemFields fields[${t}].name`,r.name);let o=$(`registerItemFields fields[${t}].type`,r.type);if(Di(o)===null){let i=Pi(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${Bt.join(", ")}).${s}`)}N(`registerItemFields fields[${t}].optional`,r.optional)}}function qu(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);$(`${i}.command`,s.command),$(`${i}.option`,s.option),N(`${i}.enabled`,s.enabled),N(`${i}.required`,s.required),N(`${i}.visible`,s.visible)}}function Bu(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);$(`${i}.key`,s.key),ge(`${i}.values`,s.values),N(`${i}.required`,s.required),ge(`${i}.aliases`,s.aliases)}}function Bi(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);$(`${r}.name`,o.name),A(`${r}.folder`,o.folder),ge(`${r}.aliases`,o.aliases),ge(`${r}.required_create_fields`,o.required_create_fields),ge(`${r}.required_create_repeatables`,o.required_create_repeatables),qu(t,o.command_option_policies),Bu(t,o.options)}}function Vi(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(N("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 Gi=["types","statuses","fields","workflows","config","templates","packages"],Vu={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 Wi(e){let t=C("registerProfile profile",e);if($("registerProfile profile.name",t.name),$("registerProfile profile.title",t.title),t.summary!==void 0&&typeof t.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let n of Gi){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`);Vu[n]?.(`registerProfile profile.${n}[${o}]`,i)}}}}function Ki(e){e.summary===void 0&&(e.summary="");for(let t of Gi)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 Hi(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 Yi(e){return typeof e=="string"?e:String(e)}function dt(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 cr(e,t){let n=dt(e),r=dt(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 Xi(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let n=Yi(e);if(typeof e!="string"||n.trim().length===0)return{kind:"pm_min_version",status:"invalid",allowed:!1,required:n,current:t};if(!dt(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=cr(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 Ji(e,t,n){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let r=Yi(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())||!dt(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=cr(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]="1dcf5e56-cb0c-5e4c-b0e8-e4dbd06187dd")}catch{}})();var Gu=5e3;async function dr(e,t,n){let r=[];for(let o of e)try{await o.run(P(n))}catch{r.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return r}function Wu(e,t,n){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new h(`Extension mutation guard ${t.name} returned an invalid decision.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${t.layer}:${t.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let r=e,o=typeof r.code=="string"?r.code.trim():"",i=typeof r.remediation=="string"?r.remediation.trim():"";if(o.length===0||i.length===0)throw new h(`Extension mutation guard ${t.name} returned an invalid denial.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${t.layer}:${t.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof r.message=="string"?r.message.trim():"";throw new h(s||`Extension mutation guard ${t.name} denied ${n}.`,y.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function lr(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:P(t.before),after:t.after===null?null:P(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),r=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new h(`Extension mutation guard ${n.name} timed out before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},Gu),o.unref?.()})])}catch(i){throw i instanceof h?i:new h(`Extension mutation guard ${n.name} failed before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(o)}Wu(r,n,t.operation)}}async function ur(e,t){return dr(e.onWrite,"onWrite",t)}async function fr(e,t){return dr(e.onRead,"onRead",t)}async function mr(e,t){return dr(e.onIndex,"onIndex",t)}function Ku(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 Wt(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 Hu(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 pr(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:P(t.args),options:P(t.options),global:P(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",Hu(o)],["errorCode",Wt(o,"code")],["remediation",Wt(o,"remediation")]].filter(i=>i[1]!==void 0))}}catch(o){let i=typeof o=="object"&&o!==null&&"exitCode"in o?o.exitCode:void 0;if(typeof i=="number"&&Number.isFinite(i))throw o;return{handled:!1,result:null,warnings:[`extension_command_handler_failed:${r.layer}:${r.name}:${r.command}`],errorMessage:Ku(o),...Object.fromEntries([["errorCode",Wt(o,"code")],["remediation",Wt(o,"remediation")]].filter(s=>s[1]!==void 0))}}}function Qi(e){return{handled:!1,result:e.payload,warnings:[]}}function Zi(e,t){return[...e.overrides].reverse().filter(n=>n.service===t)}function es(e){return{service:e.service,command:e.command?S(e.command):void 0,args:e.args?P(e.args):void 0,options:e.options?Po(e.options):void 0,global:e.global?$o(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:P(e.payload)}}function Yu(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 ts(e,t){return Yu(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 ns(e,t,n){return t.service==="output_format"&&typeof e=="object"&&e!==null&&B(e,n.payload)}function rs(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 _r(e,t){let n=Zi(e,t.service);if(n.length===0)return Qi(t);let r=[];for(let o of n)try{let i=es(t),s=o.run(i);if(s instanceof Promise){r.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(ns(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=rs(o,ts(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 gr(e,t){let n=Zi(e,t.service);if(n.length===0)return Qi(t);let r=[];for(let o of n)try{let i=es(t),s=await Promise.resolve(o.run(i));if(ns(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=rs(o,ts(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]="d3066947-0087-5732-8511-74a31056b6e1")}catch{}})();var os=null,tf=Object.freeze(co()),is=0;function nf(e=Date.now()){return is+=1,`${is}-${e}`}function rf(e,t,n){return n.has(e)?!1:t.size===0?!0:t.has(e)}async function of(e,t){let[n,r]=await Promise.all([we.realpath(e),we.realpath(t)]);return qn(n,r)}function sf(e,t=process.cwd()){return{global:be.join(Co(t),"extensions"),project:be.join(e,"extensions")}}async function af(e){try{return(await we.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,n)=>t.localeCompare(n))}catch{return[]}}function cf(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 ss(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function df(e){let t=new Map;try{let n=JSON.parse(await we.readFile(be.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=ss(i.source?.package),a=[i.source?.input,i.source?.name,s].map(l=>ss(l)).filter(l=>l!==void 0),c=Ft(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 as(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 lf(e,t){let n=[...as(e),...as(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 cs(e,t,n,r,o){let i=[],s=[],a=[],c=await af(t),d=await df(t);for(let l of c){let m=await mf(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 uf(){return{diagnostics:[],warnings:[],candidates:[]}}function ds(e,t,n,r){return{diagnostic:{layer:e,directory:t,manifest_path:n,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[r],candidate:null}}function ff(e,t,n,r,o,i,s,a){let c=fo(e,t,n);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&c.push(Wo(e,t.name,t.legacy_capability_aliases));for(let d of Bo(t.capabilities))c.push(Go(e,t.name,d));return r?o||c.push(`extension_entry_missing:${e}:${t.name}`):c.push(`extension_entry_outside_extension:${e}:${t.name}`),i.warning&&c.push(a?i.warning:i.warning.replace("extension_pm_","extension_disabled_pm_")),s.warning&&c.push(a?s.warning:s.warning.replace("extension_pm_","extension_disabled_pm_")),c}async function mf(e,t,n,r,o,i,s){let a=be.join(t,n),c=be.join(a,"manifest.json");if(!await kn(c))return ds(e,n,c,`extension_manifest_missing:${e}:${n}`);let d,l;try{let Ae=JSON.parse(await we.readFile(c,"utf8"));l=ne(Ae),d=rr(Ae)}catch{l=null,d=null}if(!d||!l)return ds(e,n,c,`extension_manifest_invalid:${e}:${n}`);let m=be.resolve(a,d.entry),u=qn(a,m),f=u?await kn(m):!1,p=u&&f?await of(a,m):u,_=rf(d.name,r,o),g=await gf(e,d),b=await yf(e,d,s),k=ff(e,d,l,p,f,g,b,_),F=p&&f&&g.allowed&&b.allowed,X=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:F?"ok":"warn"},warnings:k,candidate:mi({layer:e,directory:n,manifestPath:c,entryPath:m,manifest:d,sourceIdentity:X,extensionReady:F,enabledForLoad:_})}}async function pf(e){let t=sf(e.pmRoot,e.cwd??process.cwd()),n=Ze(e.settings.extensions.enabled),r=Ze(e.settings.extensions.disabled),o=hi(e.settings),i=bi(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:n,configured_disabled:r,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(n),a=new Set(r),c=e.ignoreGlobalExtensions===!0?uf():await cs("global",t.global,s,a,o.pmMaxVersionExceededMode.global),d=await cs("project",t.project,s,a,o.pmMaxVersionExceededMode.project),l=[...o.warnings],m=lf(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},_=Ei(o,p);if(_.warning&&l.push(_.warning),!!_.allowed){for(let g of f.manifest.capabilities){let b=ki(o,p,g);b.warning&&l.push(b.warning)}u.push(cf(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 Kt(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function _f(){try{let e=Gn(import.meta.url,["../../.."]),t=await we.readFile(be.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 fs(){return os??=_f(),os}function ms(e,t,n){let r=n.current??"unknown";if(n.kind==="pm_min_version")switch(n.status){case"invalid":return`extension_pm_min_version_invalid:${e}:${t.name}:required=${n.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${e}:${t.name}:required=${n.required}:current=${r}`;case"unmet":return`extension_pm_min_version_unmet:${e}:${t.name}:required=${n.required}:current=${r}`;default:return}switch(n.status){case"invalid":return`extension_pm_max_version_invalid:${e}:${t.name}:allowed=${n.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${e}:${t.name}:allowed=${n.required}:current=${r}`;case"exceeded":return`extension_pm_max_version_exceeded:${e}:${t.name}:allowed=${n.required}:current=${r}`;default:return}}async function gf(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let n=Xi(t.pm_min_version,await fs()),r=ms(e,t,n);return r?{allowed:n.allowed,warning:r}:{allowed:n.allowed}}async function yf(e,t,n){if(t.pm_max_version===void 0)return{allowed:!0};let r=Ji(t.pm_max_version,await fs(),n),o=ms(e,t,r);return o?{allowed:r.allowed,warning:o}:{allowed:r.allowed}}async function ls(e){try{let t=await we.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function hf(e,t){let n=e.entry_path;t.module_graph_snapshot_root&&(n=await Ri(t.module_graph_snapshot_root,e));let r=new URL(ef(n).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return r.href;let[o,i]=await Promise.all([ls(e.entry_path),ls(e.manifest_path)]),s=t.reload_token??nf();return r.searchParams.set("pm_ext_reload",s),r.searchParams.set("pm_ext_entry",o),r.searchParams.set("pm_ext_manifest",i),r.href}async function Pw(e){let t=await pf(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 hf(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:Kt(a)})}return{...t,warnings:o,loaded:n,failed:r}}var us=5e3,bf=2147483647;function wf(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 ps(e){let t=ai(e);return t?wf(t):null}async function $w(e,t,n={}){let r=vf(n?.deactivate_timeout_ms),o=new Set((t?.failed??[]).map(l=>`${l.layer}:${l.name}`)),i=[];for(let l of e.loaded){if(o.has(`${l.layer}:${l.name}`))continue;let m=ps(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 Ef(m,r),{ok:!0}}catch(u){return{ok:!1,layer:l.layer,name:l.name,error:Kt(u)}}})),a=[],c=[],d=0;for(let l of s){if(l.ok){d+=1;continue}a.push(`extension_deactivate_failed:${l.layer}:${l.name}`),c.push({layer:l.layer,name:l.name,error:l.error})}return{deactivated:d,warnings:a,failed:c}}function vf(e){return typeof e!="number"||e<0?us:e===0||e===1/0?0:Number.isFinite(e)?Math.min(bf,Math.max(1,Math.floor(e))):us}async function Ef(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 kf(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let n of e.capabilities){let r=n.trim().toLowerCase();Q(r)&&t.add(r)}return t}function O(e,t,n){let r=kf(e);if(r!==null&&!r.has(t))throw K(`${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 Of(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>G.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function Sf(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 yr=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=Of(t),this.#n=Sf(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=Oi(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:rt(o),hint:i}}registerCommandOverride(t,n){let r=S(t);if(r.length===0)throw K("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 K(`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 K("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 K("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 K("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 K(`registerCommand requires a command definition run handler (command="${n}", registration_index=${o.registration_index})`,o)}try{li(t);let o=sr(n,t.action),i=ui(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=et("registerCommand definition.examples",t.examples),d=et("registerCommand definition.failure_hints",t.failure_hints),l=ar(t.arguments);t.flags!==void 0&&(O(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(Gt(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Vt("registerCommand definition.flags",t.flags)})));let m={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=Kt(o),s=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=K(`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($("registerParser command",t));at("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=xi(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(!Mi(o))throw new TypeError(`registerService service must be one of: ${Ce.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:o})&&(at("registerService override",n),this.#i.overrides.push({layer:this.#e.layer,name:this.#e.name,service:o,run:n,...Hi(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(!$i(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($("registerFlags targetCommand",t));Gt(n);let o=Vt("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;qi(t);let n=st("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;Bi(t);let n=st("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=Tn();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;Vi(t);let n=it("registerMigration definition",t);this.#t.migrations.push(ct({layer:this.#e.layer,name:this.#e.name,definition:Me("registerMigration definition",t)},n))}registerProfile(t){if(O(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let n=ot(t);Wi(n),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:Ki(n)})}registerImportExportCommandFlags(t,n,r){r.flags!==void 0&&(O(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(Gt(r.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Vt(`${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=fi(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=sr(n,s.action),d=et(`${t} options.examples`,s.examples),l=et(`${t} options.failure_hints`,s.failure_hints),m=ar(s.arguments);this.registerImportExportCommandFlags(t,n,s);let u={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=or($("registerImporter name",t));at("registerImporter importer",n);let i=ir(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(Kn(s,o,"import"))})}registerExporter(t,n,r){if(O(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=or($("registerExporter name",t));at("registerExporter exporter",n);let i=ir(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(Kn(a,o,"export"));return s?.receipt==="suppress"&&!Vn(c)?ri(c):c}})}registerSearchProvider(t){if(O(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;let n=it("registerSearchProvider provider",t);this.#t.search_providers.push(ct({layer:this.#e.layer,name:this.#e.name,definition:Me("registerSearchProvider provider",t)},n))}registerVectorStoreAdapter(t){if(O(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;let n=it("registerVectorStoreAdapter adapter",t);this.#t.vector_store_adapters.push(ct({layer:this.#e.layer,name:this.#e.name,definition:Me("registerVectorStoreAdapter adapter",t)},n))}registerAssuranceMeasurementProvider(t){if(O(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(Ui(t),t.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");let n=it("registerAssuranceMeasurementProvider provider",t);this.#t.assurance_providers.push(ct({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:Me("registerAssuranceMeasurementProvider provider",t)},n))}registerBeforeCommand(t){O(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(he("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")&&(he("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")&&(he("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")&&(he("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")&&(he("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")&&(he("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function Af(e,t,n,r,o,i,s,a,c,d,l){return new yr(e,t,n,r,o,i,s,a,c,d,l)}function Cf(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 If(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 Tf(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 Rf(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 xf=new Set(["output_format"]);function Nf(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||xf.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 Mw(e){let t=wi(e.policy??tf),n=qt(),r=Yn(),o=Xn(),i=Jn(),s=Qn(),a=Zn(),c=er(),d=[],l=[];for(let f of e.loaded){let p=ps(f.module);if(!p)continue;let _=d.length,g=ci({hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await p.activate(Af(f,n,r,o,i,s,a,c,l,d,t)),d.length>_&&(g(),l.push(`extension_activation_rolled_back:${f.layer}:${f.name}`))}catch(b){g(),l.push(`extension_activate_failed:${f.layer}:${f.name}`);let k=ji(b);d.push({layer:f.layer,name:f.name,entry_path:f.entry_path,error:Kt(b),trace:k})}}let m=[...If(r),...Rf(o),...Ni(i),...Nf(s),...Tf(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:Cf(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 zw(){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 Df(){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 Le=null,gs=null,Mf=null,Lf=null,hr=null,jf=null,ys=null,hs=null;var Ff=[],bs=new $f;function I(){return bs.getStore()}function Kw(e){return bs.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var Uf=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function _s(e){let t=H.resolve(e);for(;;){if(Pf(H.join(t,".git")))return t;let n=H.dirname(t);if(n===t)return;t=n}}function zf(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),n=_s(t)??H.resolve(t),r=_s(n);if(!e)return{source_workspace_root:n,...r?{repo_root:r}:{}};let o=H.relative(n,H.resolve(e)),i=o.length>0&&!o.startsWith(`..${H.sep}`)&&o!==".."&&!H.isAbsolute(o);return{source_workspace_root:n,...r?{repo_root:r}:{},...i?{pm_root_rel:o.split(H.sep).join("/")}:{}}}function Hw(e){let t=I();if(t){t.hooks=e;return}Le=e}function Yw(e){let t=I();if(t){t.commands=e;return}gs=e}function Xw(e){let t=I();if(t){t.parsers=e;return}Mf=e}function Jw(e){let t=I();if(t){t.preflight=e;return}Lf=e}function Qw(e){let t=I();if(t){t.services=e;return}hr=e}function Zw(e){let t=I();if(t){t.renderers=e;return}jf=e}function ev(e){let t=I();if(t){t.registrations=e;return}ys=e}function ws(){let e=I();return e?e.registrations:ys}function qf(){let e=I(),t=e?e.commandContext:hs;return t?{...t,args:[...t.args],options:t.options?{...t.options}:{},global:t.global?{...t.global}:void 0}:null}function tv(e){if(!e)return;let t=I();t?t.affectedItems.push(e):Ff.push(e)}function nv(e,t){if(!e||!e.id)return{};let n={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return n;let r=e;for(let o of t){if(typeof o!="string")continue;let i=o.startsWith("unset:")?o.slice(6):o;i==="id"||i==="type"||i==="status"||Uf.has(i)||Object.hasOwn(r,i)&&r[i]!==void 0&&(n[i]=r[i])}return n}async function vs(e){let t=I(),n=t?t.hooks:Le;return n?ur(n,e):[]}async function rv(e){let t=I(),n=t?t.hooks:Le;n&&await lr(n,e)}async function Es(e){let t=I(),n=t?t.hooks:Le;return n?fr(n,e):[]}function ov(){let e=I();return((e?e.hooks:Le)?.onRead?.length??0)>0}async function iv(e){let t=I(),n=t?t.hooks:Le;return n?mr(n,e):[]}async function sv(e){let t=I(),n=t?t.commands:gs;return n?pr(n,{...e,...zf(e.pm_root)}):{handled:!1,result:null,warnings:[]}}function ks(e,t){let n=I(),r=n?n.commandContext:hs;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 Ht(e,t){let n=I(),r=n?n.services:hr;return r?gr(r,ks(e,t)):{handled:!1,result:t,warnings:[]}}function Os(e,t){let n=I(),r=n?n.services:hr;return r?_r(r,ks(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]="3a66ccfd-51fb-5d4a-b9cd-257c49997d52")}catch{}})();var Cs=new WeakMap;function pv(e,t){Cs.set(e,new Set(t))}var Yt='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',Bf={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"}},Vf=[{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 _v(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,y.USAGE)}function V(e,t=new Set){let n=e.filter(r=>!t.has(r.name)).map(r=>({...r}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function gv(e,t){let n=Vf.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return V([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return V(r)}var Gf=[{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 M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Wf=new Set([void 0,"tabular_when_uniform"]),Kf=new Set(["collection","none"]),Hf=new Set(["supported","unsupported"]);function Ss(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 Yf(e){return M(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Kf.has(e.row_kind)&&Ss(e.row_keys,!0)&&(e.continuation_row_keys===void 0||Ss(e.continuation_row_keys,!1))&&Hf.has(e.fields)&&Wf.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 Xf={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"]},Jf={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 Qf(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=Xf[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||M(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Yt}:{},toon_encoding:"tabular_when_uniform"}}let o=Bf[r],i=Jf[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)=>M(d)?d[l]:void 0,t);return Array.isArray(c)||M(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:Yt}:{},toon_encoding:"tabular_when_uniform"}})()}function Zf(e){if(!M(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=>M(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=n.filter(s=>typeof s=="string");if(r.length!==t.length||o.length!==n.length)return;let i=new Set(r.map(s=>s.name));if(!(i.size!==r.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return V(r,new Set(o))}function em(e){if(!Array.isArray(e.sections_included))return;let t=V(Gf,new Set(e.sections_included.filter(n=>typeof n=="string")));return M(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function tm(e,t,n){return e==="dependency_provenance"?!1:Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&M(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&M(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function nm(e){if(!M(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=Cs.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 V(s,new Set(s.flatMap(({name:a})=>tm(a,i(a),e)?[a]:[])))}function As(e){if(M(e.projection))return V([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function rm(e){if(!M(e.projection))return V([]);if(typeof e.projection.mode=="string")return V([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function om(e){if(!(!M(e.selected)||typeof e.selected.summary!="boolean"))return V([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function im(e,t){let n=Zf(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return em(t);if(r==="get")return nm(t);if(r==="list"||r.startsWith("list-"))return As(t);if(r==="search")return As(t)??V([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return rm(t);if(r==="contracts")return om(t)}function Is(e,t){if(e===void 0||!M(t))return t;let n=im(e,t),r=t.row_contract,o=Yf(r)?r:Qf(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 M(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 br(e){let t=e.trim().toLowerCase().startsWith("extension:"),n=e.trim().toLowerCase().replace(/^extension:/u,"");if(De(n))return;let r=ws()?.commands??[],o=[...r].reverse().find(s=>s.command===n)?.command??(t?void 0:r.find(s=>s.action===n)?.command),i=[...r].reverse().find(s=>s.command===o);return i===void 0||De(i.command)||De(i.action)?void 0:i}function sm(e){let t=br(e);return t?.read_output===void 0?void 0:t}function Ts(e,t){let n=sm(e),r=n?.read_output;if(r===void 0)return t;if(typeof t!="object"||t===null||Array.isArray(t))throw new h("Read-only extension commands must return a structured object.",y.USAGE,{code:"extension_read_output_invalid"});for(let o of r.row_keys){let i=t;for(let s of o.split("."))i=typeof i=="object"&&i!==null&&Object.hasOwn(i,s)?Reflect.get(i,s):void 0;if(i===null||typeof i!="object")throw new h(`Read-only extension result is missing declared row collection ${o}.`,y.USAGE,{code:"extension_read_output_invalid"})}return{...t,row_contract:{command:`extension:${n.command}`,row_kind:r.row_keys.length>0?"collection":"none",row_keys:[...r.row_keys],fields:"supported",...r.row_keys.length>0?{jq_selector:Yt}:{},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]="439cf503-a832-58a3-ba19-db44de57b573")}catch{}})();var Xt="changed_fields",am="changed_field_count",wr="rows",cm=new Set(["apply","rollback"]),Ds=new Set(["deleted","would_delete"]),Rs=256,xs={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function dm(e,t){if(!L(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(xs,e.action)?xs[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return L(s)&&L(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let r=e[n.at(-1)],o=$s(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,Ms(e[i],t)]))}}function Ns(e){return typeof e!="string"||e.length<=Rs?e:`${Z(e,Rs-1)}\u2026`}function lm(e){if(!L(e))return null;let t={...e};return t.reason=Ns(t.reason),L(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,Ns(r)]))),t}function L(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Ps(e){let t=e[Xt];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==Xt&&(n[r]=o);return n[am]=t.length,n}function um(e){return"item"in e&&Array.isArray(e[Xt])}function fm(e){return typeof e.mode=="string"&&cm.has(e.mode)&&Array.isArray(e[wr])}function mm(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[wr]=t,n}function $s(e){if(!L(e))return null;let t=L(e.item)?e.item:L(e.plan)?e.plan:null;if(t===null)return null;let n=typeof t.id=="string"?t.id:void 0,r=typeof e.outcome=="string"&&Ds.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 pm(e,t){if(!L(e))return null;if(L(e.plan)&&L(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||!L(e.item)||typeof e.item.id!="string")return null;let n=e[Xt];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&Ds.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 _m(e,e.item,r),r}function _m(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=lm(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"])L(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 gm(e){let t=fm(e)?e[wr]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!L(o))return o;let i=Ps(o);return i?(n=!0,i):o});return n?{projected:mm(e,r),changed:!0}:{projected:e,changed:!1}}function Ms(e,t={}){let n=dm(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=$s(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=pm(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!L(e))return e;let r=!1,o=e,i=um(e)?Ps(e):null;i!==null&&(o=i,r=!0);let s=gm(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{AsyncLocalStorage as Vp}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 Ls=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),ym=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function hm(e){let t=e.indexOf("=");return t>0&&Ls.has(e.slice(0,t))}function bm(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function js(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(Ls.has(n)){t+=bm(n,e[t+1])?1:0;continue}if(!(hm(n)||ym.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function Av(e){let t=js(e);return t===void 0?void 0:e[t].trim().toLowerCase()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="86412887-5659-5892-beaa-bdd15a02ff4c")}catch{}})();var Fs=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)}"`},Us=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?Fs(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,Jt=(e,t=process.platform)=>{let n=e.map(r=>Us(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]="98cde1d6-d5dd-56b9-89f9-51f5d08221d1")}catch{}})();import{createHash as Rm}from"node:crypto";import{createHash as Sm}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 wm=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 zs(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 vr(e,t,n){let r=t.split("."),o=(i,s)=>{if(s===r.length)return n;let a=r[s];if(Array.isArray(i)){let d=Number(a),l=[...i];return l[d]=o(i[d],s+1),l}let c=i;return{...c,[a]:o(c[a],s+1)}};return o(e,0)}function qs(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=vr(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)}}),ft(i),i}function Zt(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 vm(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):Zt(e)}function ie(e){return Zt(e).flatMap(t=>{let n=zs(e,t);return Array.isArray(n)||R(n)?[{path:t,value:n}]:[]})}function je(e){return vm(e).flatMap(t=>{let n=zs(e,t);return Array.isArray(n)||R(n)?[{path:t,value:n}]:[]})}function lt(e){let t=ie(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&&wm.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function en(e){return ie(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function ut(e,t){let n=e;for(let r of ie(n)){let o=Array.isArray(r.value)?r.value.map((i,s)=>t(i,r.path,s)):Object.fromEntries(Object.entries(r.value).map(([i,s],a)=>[i,t(s,r.path,a)]));n=vr(n,r.path,o)}return n}function Bs(e,t){let n=e,r=!1;for(let o of ie(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=vr(n,o.path,s)}return{result:n,truncated:r}}var Vs=["high_level","low_level","blocked_fallback"];function Qt(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function Nv(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(Vs.map(r=>[r,Array.isArray(e[r])?e[r].filter(R).map(o=>Qt(n.get(o.id)??o)).join(""):""]))}}function Em(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 km(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(R):[],i=Em(r[n],o.length)??o.map(Qt).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)??Qt(d);return m!==Qt(d)&&(c=!0),m}).join(""),needsStates:c}}function Om(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 ft(e,t=e){if(Om(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=Vs.map(c=>({key:c,...km(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 Am=4096,Cm=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"]),Ws=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:Cm}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function pt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mt(e){return Array.isArray(e)?e.map(mt):pt(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,mt(n)])):e}function Gs(e,t){if(!pt(e))return mt(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||!pt(i)?[o,mt(i)]:[o,Object.fromEntries(Object.entries(i).filter(([s])=>!r.includes(s)).map(([s,a])=>[s,mt(a)]))]))}function Im(e,t){return Array.isArray(e)?e.map(n=>Gs(n,t)):Gs(e,t)}function tn(e,t,n){let r=n?Ws[n]:void 0,o=r?.paths.includes(e)===!0;return Sm("sha256").update(fe({path:e,value:o?Im(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function Er(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint}),"utf8").toString("base64url")}function Tm(e){return typeof e=="string"&&(Fe(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function _t(e){if(e.length>Am)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!pt(t)||t.v!==1||!Tm(t.c)||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function Ks(e){if(!Array.isArray(e.assertions))return e;let t=n=>!pt(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 Hs(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,y.USAGE,{code:"read_output_cursor_command_mismatch"});let r=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||tn(n.path,r.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",y.USAGE,{code:"read_output_cursor_stale"});return qs(e,n.path,n.offset)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6a81cf4-3095-5197-8e73-f017d98b1ccf")}catch{}})();var Or=1,Ys=4096,xm=/^[A-Za-z0-9_-]+$/;function kr(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function Kv(e,t){let n=[...Object.values(Lt),...jt],r=new Set(n.flatMap(o=>[kr(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){r.add(kr(o.flag));for(let i of o.aliases??[])r.add(kr(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!r.has(o)))}function Hv(e,t){return Rm("sha256").update(e).update("\0").update(fe(t)).digest("hex").slice(0,24)}function gt(e,t,n,r){return Buffer.from(JSON.stringify({version:Or,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function ve(e,t){return new h(e,y.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function Nm(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===Or&&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 Sr(e,t="--after"){if(typeof e!="string")throw ve("Query cursor is malformed.",t);let n=e.trim();if(n.length===0||n.length>Ys||!xm.test(n))throw ve("Query cursor is malformed.",t);let r;try{r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"))}catch{throw ve("Query cursor is malformed.",t)}if(!Nm(r)){let o=!1;try{_t(n),o=!0}catch{}throw o?new h(`An output cursor must be continued with --output-cursor, not ${t}.`,y.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${n}; retain any producer ${t} cursor from the original page.`]}):ve("Query cursor version or payload is unsupported.",t)}return r}function Ar(e,t,n="--after"){let r=Sr(e,n);if(r.fingerprint!==t)throw ve(`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 Yv(e,t){return Ar(e,t).after_id}function Dm(e,t,n,r,o="--after"){if(t===void 0)return 0;let i=Ar(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 ve(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return s+1}function Xv(e,t){if(t.cursor!==void 0&&Ar(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw ve("Query cursor does not match the requested snapshot.","--after");let n=Dm(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:gt(t.fingerprint,t.readId(i),n+r.length-1,t.snapshot)}:{}}}var Jv=Object.freeze({version:Or,max_length:Ys});import{randomUUID as Pp}from"node:crypto";import{randomUUID as Rp}from"node:crypto";import{constants as qe}from"node:fs";import{lstat as ha,mkdir as xp,open as wa,rename as Np,rm as Dp}from"node:fs/promises";import cn from"node:path";import{constants as rp}from"node:fs";import z from"node:fs/promises";import ae from"node:path";import{randomUUID as on}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="92573990-a040-526d-a0b1-b91d2ef401f1")}catch{}})();function Xs(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import Pm from"node:crypto";import{AsyncLocalStorage as $m}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 Qs=new $m,Js=1024;function Zs(){let e=Qs.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 nE(e){let t=Qs.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>Js)throw new Error(`Reproducible token length must be an integer between 0 and ${Js}`);let n="";for(;n.length<e;){let r=Pm.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 Mm=/^([+-]?)(\d+)([hdwm])$/i,Lm=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,jm=/^(\d{4})(\d{2})(\d{2})$/,Fm=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Um=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,zm=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,qm=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function Tr(){return Zs()??new Date().toISOString()}function cE(e){return Number.isFinite(Date.parse(e))}function Bm(e){let t=qm.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<=Rr(l,m-1)&&f<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function dE(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return Bm(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var Vm=1e4,nn=new Map;function ea(e){let t=nn.get(e);if(t!==void 0)return t;let n=Date.parse(e);return nn.size>=Vm&&Xs(nn),nn.set(e,n),n}function Ue(e,t){let n=ea(e),r=ea(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function lE(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 Cr(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function Ir(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 Gm(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function Wm(e){let t=[],n=d=>Gm(t,e,d),r=jm.exec(e);if(r){let[,d,l,m]=r;n(`${d}-${l}-${m}`)}let o=Fm.exec(e);if(o){let[,d,l,m,u,f,p,_,g]=o,b=p?`:${p}`:"";n(`${d}-${l}-${m}T${u}:${f}${b}${Cr(_)}${Ir(g)}`)}let i=Um.exec(e);if(i){let[,d,l,m,u,f,p]=i,_=u?`:${u}`:"";n(`${d}T${l}:${m}${_}${Cr(f)}${Ir(p)}`)}let s=zm.exec(e);if(s){let[,d,l,m,u,f,p]=s,_=u?`:${u}`:"";n(`${d}T${l}:${m}${_}${Cr(f)}${Ir(p)}`)}let a=10,c=e.slice(0,a);if(Hm(c)){let d=a;for(;d<e.length&&Ym(e[d]);)d+=1;d<e.length&&n(`${c}T${e.slice(d)}`)}return t}function Km(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of Wm(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function Hm(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 Ym(e){return e?e===" "||e===" "||e===`
|
|
8
|
-
`||e==="\r"||e==="\f"||e==="\v":!1}function
|
|
9
|
-
`,"utf8")}finally{await c.close()}}catch(d){throw await
|
|
10
|
-
`,"utf8")}catch{return await
|
|
11
|
-
`,{encoding:"utf8",flag:"wx",mode:384})}async function
|
|
7
|
+
Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,u=ei(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}${pe(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:_e(Buffer.byteLength(p,"utf8")),truncated:d,degradation_steps:d?[...o.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}import{existsSync as Lf}from"node:fs";import{AsyncLocalStorage as jf}from"node:async_hooks";import H from"node:path";import we from"node:fs/promises";import be from"node:path";import{pathToFileURL as rf}from"node:url";import si 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=si.relative(e,t);return n.length===0?!0:!n.startsWith("..")&&!si.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 nu="__pm_suppress_host_output",Vn="@unbrained/pm-cli:suppress-host-output:v1";function ai(e){return e===void 0?{__pm_suppress_host_output:Vn}:{__pm_suppress_host_output:Vn,result:e}}function Gn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&e[nu]===Vn}import Ne from"node:fs";import te from"node:path";import{fileURLToPath as ru}from"node:url";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="efea1aa1-1ad1-5f53-a3a5-b83803d9deb1")}catch{}})();var ou="@unbrained/pm-cli";function iu(e){try{return JSON.parse(Ne.readFileSync(e,"utf8")).name===ou}catch{return!1}}function su(e){let t=Ne.existsSync(e)&&Ne.statSync(e).isDirectory()?te.resolve(e):te.dirname(te.resolve(e));for(;;){let n=te.join(t,"package.json");if(Ne.existsSync(n)&&iu(n))return t;let r=te.dirname(t);if(r===t)return;t=r}}function Wn(e,t=[]){let n=ru(e);return su(n)||te.resolve(te.dirname(n),...t)}function Vh(e,t=[]){try{let n=te.join(Wn(e,t),"package.json");if(!Ne.existsSync(n))return;let r=JSON.parse(Ne.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 au(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Wh(e){return au(e)??void 0}function Kh(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 Hh(e){return Array.isArray(e)&&e.every(t=>typeof t=="number"&&Number.isFinite(t))}function di(e){if(e instanceof Error){let t=e.message.trim();return t.length>0?t:e.name}return String(e)}function li(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 Yh(e){let t=li(e);return t===null||t<=0||!Number.isInteger(t)?null:t}function Xh(e,t,n){let r=li(e);return r===null||r<t||r>n?null:r}function Jh(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function ne(e){return typeof e!="object"||e===null?null:e}function ci(e){return typeof e!="object"&&typeof e!="function"||e===null?null:e}function ui(e){let t=ci(e);if(!t)return null;if(typeof t.activate=="function")return t;let n=ci(t.default);return typeof n?.activate=="function"?n:null}function Qh(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 fi(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 N(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 mi(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 ge(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(ge(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 Kn=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 cu=new Set(Kn);function du(e){if(e!==void 0&&!cu.has(String(e)))throw new Error(`registerCommand definition.family must be one of: ${Kn.join(", ")}`)}function pi(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");du(e.family)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="095ea29d-eda3-5287-b54d-8a961658f7bc")}catch{}})();function _i(e,t="",n=""){if(e===void 0)return;if(De(t)||De(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 De(e){let t=e.trim().toLowerCase().replace(/\s+/gu,"-");return Te.includes(t)||Re.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 lu(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 gi(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=lu(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 Hn(e,t,n){return{registration:t,action:n,command:e.command,args:P(e.args),options:P(e.options),global:P(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 yi(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 uu(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 Pe(e){return new Set((e??[]).map(t=>uu(t)).filter(t=>t.length>0))}function hi(e){let t=q(e);return kt.includes(t)?t:"off"}function bi(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 Yn(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return lo.includes(t)?t:void 0}function wi(e){if(typeof e=="string"){let t=Yn(e)??"block";return{global:t,project:t}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:Yn(e.global)??"block",project:Yn(e.project)??"block"}:{global:"block",project:"block"}}function fu(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 mu(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:Pe(e.allowed_surfaces),blockedSurfaces:Pe(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 vi(e){let t=new Map;for(let n of e??[]){let r=mu(n);r&&t.set(r.name,r.normalized)}return t}function pu(e){let t=[],n=[...e.overridesByName.values()].sort((o,i)=>o.name.localeCompare(i.name));for(let o of E([...e.allowedCapabilities,...e.blockedCapabilities]))Q(o)||t.push(`extension_policy_unknown_capability:${o}`);for(let o of n)for(let i of E([...o.allowedCapabilities,...o.blockedCapabilities]))Q(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 Ei(e){let t=e.extensions?.policy??{},n=w(t.allowed_capabilities),r=w(t.blocked_capabilities),o=Pe(t.allowed_surfaces),i=Pe(t.blocked_surfaces),s=vi(t.extension_overrides);return{mode:hi(t.mode),trustMode:bi(t.trust_mode),pmMaxVersionExceededMode:wi(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:pu({allowedCapabilities:n,blockedCapabilities:r,allowedSurfaces:o,blockedSurfaces:i,overridesByName:s})}}function ki(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:fu(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 Oi(e){let t=vi(e.extension_overrides);return{mode:hi(e.mode),trustMode:bi(e.trust_mode),pmMaxVersionExceededMode:wi(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:Pe(e.allowed_surfaces),blockedSurfaces:Pe(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 $e(e,t,n,r,o){return t.has(n)?o:e.size>0&&!e.has(n)?r:null}function Si(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 $e(i,s,r,"capability_not_allowlisted","capability_blocked")}function _u(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 $e(o,i,n,"surface_not_allowlisted","surface_blocked")}function gu(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 $e(i,s,r,"command_not_allowlisted","command_blocked")}function yu(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 $e(i,s,r,"action_not_allowlisted","action_blocked")}function hu(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 $e(i,s,r,"service_not_allowlisted","service_blocked")}function bu(e,t){let n=q(t.name);return re(e,t.name)?.disabled===!0?"extension_override_disabled":$e(e.allowedExtensions,e.blockedExtensions,n,"extension_not_allowlisted","extension_blocked")}function wu(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 vu(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 qt(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 Ai(e,t){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};let n=[],r=bu(e,t);r&&n.push({reason:r,scope:"extension",mode:e.mode});let o=wu(e,t);o&&n.push({reason:o,scope:"trust",mode:e.trustMode});let i=vu(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:qt("blocked",s.scope,t,s.reason)};let a=n.find(c=>c.mode==="warn");return a?{allowed:!0,warning:qt("violation",a.scope,t,a.reason)}:{allowed:!0,warning:null}}function Ci(e,t,n){if(e.mode==="off")return{allowed:!0,warning:null};let r=Si(e,t,n);return r?{allowed:e.mode==="warn",warning:qt(e.mode==="warn"?"violation":"blocked","capability",t,r,{capability:n.trim().toLowerCase()})}:{allowed:!0,warning:null}}function Eu(e,t,n,r,o){let i=typeof r=="string"?Si(e,t,r):null,s=_u(e,t,n),a=o.command?gu(e,t,o.command):null,c=o.action?yu(e,t,o.action):null,d=o.service?hu(e,t,o.service):null;return i??s??a??c??d}function ku(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 Ii(e,t,n,r,o,i){if(e.mode==="off")return{allowed:!0,warning:null};let s=i??{},a=Eu(e,t,n,o,s);if(!a)return{allowed:!0,warning:null};let c=qt(e.mode==="warn"?"violation":"blocked","registration",t,a,ku(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 Bt(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function Xn(){return{overrides:[],handlers:[]}}function Jn(){return{overrides:[]}}function Qn(){return{overrides:[]}}function Zn(){return{overrides:[]}}function er(){return{overrides:[]}}function tr(){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 Ri=100;function Ti(e,t){let n=e[t];if(n!=null)return typeof n!="string"||n.trim().length===0?null:n.trim()}function Ou(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 nr(e,t){let n=e[t];return typeof n!="string"||n.trim().length===0?null:n.trim()}function xi(e){if(e!=null)return typeof e!="number"||!Number.isInteger(e)?null:e}function ye(e){if(e!=null)return typeof e!="boolean"?null:e}function Su(e){let t=xi(e.priority);return t===void 0?Ri:t}function Au(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 rr(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Cu(e){if(e==null)return;let t=ne(e);if(!t)return null;let n=rr(t.source),r=rr(t.signature),o=rr(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 Iu(e){if(e==null)return;let t=ne(e);if(!t)return null;let n=ye(t.fs_read),r=ye(t.fs_write),o=ye(t.network),i=ye(t.env_read),s=ye(t.env_write),a=ye(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 Tu(e){if(e==null)return{capabilities:[],legacy_aliases:[]};if(!Array.isArray(e)||e.some(n=>typeof n!="string"))return null;let t=Ho(e);return{capabilities:t.capabilities,legacy_aliases:t.legacy_aliases}}function Ru(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 xu(e){let t=xi(e.manifest_version);if(t===null)return null;let n=Ti(e,"pm_min_version");if(n===null)return null;let r=Ti(e,"pm_max_version");if(r===null)return null;let o=Ou(e.engines);if(o===null)return null;let i=ye(e.trusted);if(i===null)return null;let s=Au(e);if(s===null)return null;let a=Cu(e.provenance);if(a===null)return null;let c=Iu(e.permissions);if(c===null)return null;let d=Tu(e.capabilities);if(d===null)return null;let l=Ru(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 or(e){if(typeof e!="object"||e===null)return null;let t=e,n=nr(t,"name");if(n===null)return null;let r=nr(t,"version");if(r===null)return null;let o=nr(t,"entry");if(o===null)return null;let i=Su(t);if(i===null)return null;let s=xu(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 Ni=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"}]]),Nu=/^[a-z][a-z0-9_]{0,63}$/u,Du=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))),Pu={capacity:{code:"host_environment_capacity_fault"},permission:{code:"host_environment_permission_fault"},resource:{code:"host_environment_resource_fault"}};function $u(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.code=="string"&&Ni.has(t.code)?t.code:typeof t.errno!="number"||!Number.isInteger(t.errno)?null:Du.get(Math.abs(t.errno))??null}function Mu(e,t,n={}){let r=$u(e);if(r===null)return null;if(!Nu.test(t))throw new h("Host environment operation labels must be bounded identifiers.",y.USAGE,{code:"host_environment_operation_invalid",field:"operation"});let o=Ni.get(r);return new h(`Host filesystem operation ${t} ${o.summary}.`,y.GENERIC_FAILURE,{code:n.codes?.[o.category]??Pu[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 Di(e,t,n={}){try{return await t()}catch(r){throw Mu(r,e,n)??r}}import Lu 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 Pi(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 Di("extension_module_graph_snapshot",()=>Lu.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 $i(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 Mi(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 Vt=mo;function Li(e){let t=e.trim().toLowerCase();return Vt.includes(t)?t:null}function ji(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 Vt)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 Fi(e){return e==="toon"||e==="json"}function Ui(e){return Ce.includes(e)}function he(e,t){if(typeof t!="function")throw new TypeError(`api.hooks.${e} requires a function handler`)}var zi=Symbol("extension_registration_trace");function K(e,t){let n=new TypeError(e);return Object.defineProperty(n,zi,{value:t,enumerable:!1,configurable:!1,writable:!1}),n}function qi(e){return e instanceof Error?e[zi]: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 Me(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=>Me(e,n))}function $(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function ct(e,t){if(typeof t!="function")throw new TypeError(`${e} requires a function handler`)}function ir(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function sr(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 ju=new Set(["low","medium","high"]),Fu=new Set(["number","string_set"]),Uu=new Set(["string","number","boolean"]);function Bi(e,t){if(typeof t!="string"||t.trim().length===0)throw new TypeError(`${e} requires a non-empty string`);return t.trim()}function zu(e,t,n){let r=`registerAssuranceMeasurementProvider provider.keys.${t}`,o=C(r,n);if(!Fu.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}`;Bi(`${c}.name`,s);let d=C(c,a);if(!Uu.has(String(d.type)))throw new TypeError(`${c}.type must be string, number, or boolean`);N(`${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 Vi(e){let t=C("registerAssuranceMeasurementProvider provider",e),n=Bi("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(!ju.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`);zu(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 qu=new Set(["default","description","enabled","list","long","repeatable","required","short","type","value_name","value_type","value_validation","visible"]);function Gt(e,t){return at(e,t).map(n=>(n.repeatable===!0&&(n.list=!0),n))}function Bu(e){return e.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function ar(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=Bu(t);if(n.length===0)throw new TypeError("registerCommand definition.action must contain alphanumeric characters");return n}function cr(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=$(`registerCommand definition.arguments[${r}].name`,i.name);if(N(`registerCommand definition.arguments[${r}].required`,i.required),N(`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 Wt(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=>!qu.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=zo(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),N(`registerFlags flags[${t}].required`,r.required),N(`registerFlags flags[${t}].enabled`,r.enabled),N(`registerFlags flags[${t}].visible`,r.visible),N(`registerFlags flags[${t}].list`,r.list),N(`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(mi(`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.`);Gi(`registerFlags flags[${t}]`,r),Vu(`registerFlags flags[${t}]`,r)}}function Vu(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 Gi(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?Vo(t.default):[t.default];for(let[i,s]of o.entries())if(!Go(s,r)){let a=o.length>1?`default[${i}]`:"default";throw new TypeError(`${e}.${a} (${JSON.stringify(s)}) is not coercible to ${r}.`)}}function Wi(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);$(`registerItemFields fields[${t}].name`,r.name);let o=$(`registerItemFields fields[${t}].type`,r.type);if(Li(o)===null){let i=ji(o),s=i?` Did you mean "${i}"?`:"";throw new TypeError(`registerItemFields fields[${t}].type "${o}" is not a known field type (expected one of: ${Vt.join(", ")}).${s}`)}N(`registerItemFields fields[${t}].optional`,r.optional)}}function Gu(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);$(`${i}.command`,s.command),$(`${i}.option`,s.option),N(`${i}.enabled`,s.enabled),N(`${i}.required`,s.required),N(`${i}.visible`,s.visible)}}function Wu(e,t){if(t===void 0)return;let n=`registerItemTypes types[${e}].options`;if(!Array.isArray(t))throw new TypeError(`${n} must be an array when provided`);for(let[r,o]of t.entries()){let i=`${n}[${r}]`,s=C(i,o);$(`${i}.key`,s.key),ge(`${i}.values`,s.values),N(`${i}.required`,s.required),ge(`${i}.aliases`,s.aliases)}}function Ki(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);$(`${r}.name`,o.name),A(`${r}.folder`,o.folder),ge(`${r}.aliases`,o.aliases),ge(`${r}.required_create_fields`,o.required_create_fields),ge(`${r}.required_create_repeatables`,o.required_create_repeatables),Gu(t,o.command_option_policies),Wu(t,o.options)}}function Hi(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(N("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 Yi=["types","statuses","fields","workflows","config","templates","packages"],Ku={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 Xi(e){let t=C("registerProfile profile",e);if($("registerProfile profile.name",t.name),$("registerProfile profile.title",t.title),t.summary!==void 0&&typeof t.summary!="string")throw new TypeError("registerProfile profile.summary must be a string when provided");for(let n of Yi){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`);Ku[n]?.(`registerProfile profile.${n}[${o}]`,i)}}}}function Ji(e){e.summary===void 0&&(e.summary="");for(let t of Yi)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 Qi(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 Zi(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 dr(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 es(e,t){if(e==null)return{kind:"pm_min_version",status:"absent",allowed:!0,required:"",current:t};let n=Zi(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=dr(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 ts(e,t,n){if(e==null)return{kind:"pm_max_version",status:"absent",allowed:!0,required:"",current:t};let r=Zi(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=dr(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]="1dcf5e56-cb0c-5e4c-b0e8-e4dbd06187dd")}catch{}})();var Hu=5e3;async function lr(e,t,n){let r=[];for(let o of e)try{await o.run(P(n))}catch{r.push(`extension_hook_failed:${o.layer}:${o.name}:${t}`)}return r}function Yu(e,t,n){if(e===void 0)return;if(typeof e!="object"||e===null||!("allow"in e)||e.allow!==!0&&e.allow!==!1)throw new h(`Extension mutation guard ${t.name} returned an invalid decision.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${t.layer}:${t.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(e.allow)return;let r=e,o=typeof r.code=="string"?r.code.trim():"",i=typeof r.remediation=="string"?r.remediation.trim():"";if(o.length===0||i.length===0)throw new h(`Extension mutation guard ${t.name} returned an invalid denial.`,y.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${t.layer}:${t.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});let s=typeof r.message=="string"?r.message.trim():"";throw new h(s||`Extension mutation guard ${t.name} denied ${n}.`,y.CONFLICT,{code:o,reason:`${t.layer}:${t.name}`,nextSteps:[i]})}async function ur(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:P(t.before),after:t.after===null?null:P(t.after),changed_fields:[...t.changed_fields],sdk:t.sdk}));i.catch(()=>{}),r=await Promise.race([i,new Promise((s,a)=>{o=setTimeout(()=>{a(new h(`Extension mutation guard ${n.name} timed out before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},Hu),o.unref?.()})])}catch(i){throw i instanceof h?i:new h(`Extension mutation guard ${n.name} failed before ${t.operation}.`,y.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${n.layer}:${n.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(o)}Yu(r,n,t.operation)}}async function fr(e,t){return lr(e.onWrite,"onWrite",t)}async function mr(e,t){return lr(e.onRead,"onRead",t)}async function pr(e,t){return lr(e.onIndex,"onIndex",t)}function Xu(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 Kt(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 Ju(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 _r(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:P(t.args),options:P(t.options),global:P(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",Ju(o)],["errorCode",Kt(o,"code")],["remediation",Kt(o,"remediation")]].filter(i=>i[1]!==void 0))}}catch(o){let i=typeof o=="object"&&o!==null&&"exitCode"in o?o.exitCode:void 0;if(typeof i=="number"&&Number.isFinite(i))throw o;return{handled:!1,result:null,warnings:[`extension_command_handler_failed:${r.layer}:${r.name}:${r.command}`],errorMessage:Xu(o),...Object.fromEntries([["errorCode",Kt(o,"code")],["remediation",Kt(o,"remediation")]].filter(s=>s[1]!==void 0))}}}function ns(e){return{handled:!1,result:e.payload,warnings:[]}}function rs(e,t){return[...e.overrides].reverse().filter(n=>n.service===t)}function os(e){return{service:e.service,command:e.command?S(e.command):void 0,args:e.args?P(e.args):void 0,options:e.options?jo(e.options):void 0,global:e.global?Fo(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:P(e.payload)}}function Qu(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 is(e,t){return Qu(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 ss(e,t,n){return t.service==="output_format"&&typeof e=="object"&&e!==null&&B(e,n.payload)}function as(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 gr(e,t){let n=rs(e,t.service);if(n.length===0)return ns(t);let r=[];for(let o of n)try{let i=os(t),s=o.run(i);if(s instanceof Promise){r.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if(ss(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=as(o,is(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 yr(e,t){let n=rs(e,t.service);if(n.length===0)return ns(t);let r=[];for(let o of n)try{let i=os(t),s=await Promise.resolve(o.run(i));if(ss(s,t,i)){r.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}let a=as(o,is(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]="d3066947-0087-5732-8511-74a31056b6e1")}catch{}})();var cs=null,of=Object.freeze(uo()),ds=0;function sf(e=Date.now()){return ds+=1,`${ds}-${e}`}function af(e,t,n){return n.has(e)?!1:t.size===0?!0:t.has(e)}async function cf(e,t){let[n,r]=await Promise.all([we.realpath(e),we.realpath(t)]);return et(n,r)}function df(e,t=process.cwd()){return{global:be.join(xo(t),"extensions"),project:be.join(e,"extensions")}}async function lf(e){try{return(await we.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,n)=>t.localeCompare(n))}catch{return[]}}function uf(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 ls(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}async function ff(e){let t=new Map;try{let n=JSON.parse(await we.readFile(be.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=ls(i.source?.package),a=[i.source?.input,i.source?.name,s].map(l=>ls(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 us(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 mf(e,t){let n=[...us(e),...us(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 fs(e,t,n,r,o){let i=[],s=[],a=[],c=await lf(t),d=await ff(t);for(let l of c){let m=await gf(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 pf(){return{diagnostics:[],warnings:[],candidates:[]}}function ms(e,t,n,r){return{diagnostic:{layer:e,directory:t,manifest_path:n,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[r],candidate:null}}function _f(e,t,n,r,o,i,s,a){let c=po(e,t,n);Array.isArray(t.legacy_capability_aliases)&&t.legacy_capability_aliases.length>0&&c.push(Xo(e,t.name,t.legacy_capability_aliases));for(let d of Ko(t.capabilities))c.push(Yo(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 gf(e,t,n,r,o,i,s){let a=be.join(t,n),c=be.join(a,"manifest.json");if(!await On(c))return ms(e,n,c,`extension_manifest_missing:${e}:${n}`);let d,l;try{let Ae=JSON.parse(await we.readFile(c,"utf8"));l=ne(Ae),d=or(Ae)}catch{l=null,d=null}if(!d||!l)return ms(e,n,c,`extension_manifest_invalid:${e}:${n}`);let m=be.resolve(a,d.entry),u=et(a,m),f=u?await On(m):!1,p=u&&f?await cf(a,m):u,_=af(d.name,r,o),g=await bf(e,d),b=await wf(e,d,s),k=_f(e,d,l,p,f,g,b,_),F=p&&f&&g.allowed&&b.allowed,X=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:F?"ok":"warn"},warnings:k,candidate:yi({layer:e,directory:n,manifestPath:c,entryPath:m,manifest:d,sourceIdentity:X,extensionReady:F,enabledForLoad:_})}}async function yf(e){let t=df(e.pmRoot,e.cwd??process.cwd()),n=Ze(e.settings.extensions.enabled),r=Ze(e.settings.extensions.disabled),o=Ei(e.settings),i=ki(o);if(e.noExtensions)return{disabled_by_flag:!0,roots:t,configured_enabled:n,configured_disabled:r,discovered:[],effective:[],warnings:[...o.warnings],policy:i};let s=new Set(n),a=new Set(r),c=e.ignoreGlobalExtensions===!0?pf():await fs("global",t.global,s,a,o.pmMaxVersionExceededMode.global),d=await fs("project",t.project,s,a,o.pmMaxVersionExceededMode.project),l=[...o.warnings],m=mf(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},_=Ai(o,p);if(_.warning&&l.push(_.warning),!!_.allowed){for(let g of f.manifest.capabilities){let b=Ci(o,p,g);b.warning&&l.push(b.warning)}u.push(uf(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 Ht(e){return e instanceof Error&&e.message.trim().length>0?e.message:String(e)}async function hf(){try{let e=Wn(import.meta.url,["../../.."]),t=await we.readFile(be.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 gs(){return cs??=hf(),cs}function ys(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 bf(e,t){if(t.pm_min_version===void 0)return{allowed:!0};let n=es(t.pm_min_version,await gs()),r=ys(e,t,n);return r?{allowed:n.allowed,warning:r}:{allowed:n.allowed}}async function wf(e,t,n){if(t.pm_max_version===void 0)return{allowed:!0};let r=ts(t.pm_max_version,await gs(),n),o=ys(e,t,r);return o?{allowed:r.allowed,warning:o}:{allowed:r.allowed}}async function ps(e){try{let t=await we.stat(e);return`${Math.trunc(t.mtimeMs)}-${t.size}`}catch{return"missing"}}async function vf(e,t){let n=e.entry_path;t.module_graph_snapshot_root&&(n=await Pi(t.module_graph_snapshot_root,e));let r=new URL(rf(n).href);if(!(t.cache_bust===!0||typeof t.reload_token=="string"))return r.href;let[o,i]=await Promise.all([ps(e.entry_path),ps(e.manifest_path)]),s=t.reload_token??sf();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 Lw(e){let t=await yf(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 vf(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:Ht(a)})}return{...t,warnings:o,loaded:n,failed:r}}var _s=5e3,Ef=2147483647;function kf(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 hs(e){let t=ui(e);return t?kf(t):null}async function jw(e,t,n={}){let r=Of(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=hs(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 Sf(m,r),{ok:!0}}catch(u){return{ok:!1,layer:l.layer,name:l.name,error:Ht(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 Of(e){return typeof e!="number"||e<0?_s:e===0||e===1/0?0:Number.isFinite(e)?Math.min(Ef,Math.max(1,Math.floor(e))):_s}async function Sf(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 Af(e){if(!Array.isArray(e.capabilities))return null;let t=new Set;for(let n of e.capabilities){let r=n.trim().toLowerCase();Q(r)&&t.add(r)}return t}function O(e,t,n){let r=Af(e);if(r!==null&&!r.has(t))throw K(`${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 Cf(e){return Object.freeze({name:e.name,layer:e.layer,version:e.version,capabilities:Object.freeze((e.capabilities??[]).filter(t=>G.includes(t))),pm_min_version:e.pm_min_version,pm_max_version:e.pm_max_version,source_package:e.source_package})}function If(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 hr=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=Cf(t),this.#n=If(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=Ii(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 K("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 K(`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 K("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 K("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 K("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 K(`registerCommand requires a command definition run handler (command="${n}", registration_index=${o.registration_index})`,o)}try{pi(t);let o=ar(n,t.action),i=_i(t.read_output,n,o);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:n,action:o}))return;let s=t.description?.trim(),a=t.intent?.trim(),c=tt("registerCommand definition.examples",t.examples),d=tt("registerCommand definition.failure_hints",t.failure_hints),l=cr(t.arguments);t.flags!==void 0&&(O(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(Wt(t.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Gt("registerCommand definition.flags",t.flags)})));let m={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=Ht(o),s=this.registerCommandTrace("definition",n,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",t,i),a=K(`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($("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=$i(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(!Ui(o))throw new TypeError(`registerService service must be one of: ${Ce.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,...Qi(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(!Fi(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($("registerFlags targetCommand",t));Wt(n);let o=Gt("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;Wi(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;Ki(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=Rn();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;Hi(t);let n=st("registerMigration definition",t);this.#t.migrations.push(dt({layer:this.#e.layer,name:this.#e.name,definition:Me("registerMigration definition",t)},n))}registerProfile(t){if(O(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;let n=it(t);Xi(n),this.#t.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:Ji(n)})}registerImportExportCommandFlags(t,n,r){r.flags!==void 0&&(O(this.#e,"schema",`${t} options.flags`),this.allowRegistration("schema.flags",`${t} options.flags`,"schema")&&(Wt(r.flags),this.#t.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:Gt(`${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=gi(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=ar(n,s.action),d=tt(`${t} options.examples`,s.examples),l=tt(`${t} options.failure_hints`,s.failure_hints),m=cr(s.arguments);this.registerImportExportCommandFlags(t,n,s);let u={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=ir($("registerImporter name",t));ct("registerImporter importer",n);let i=sr(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(Hn(s,o,"import"))})}registerExporter(t,n,r){if(O(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;let o=ir($("registerExporter name",t));ct("registerExporter exporter",n);let i=sr(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(Hn(a,o,"export"));return s?.receipt==="suppress"&&!Gn(c)?ai(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:Me("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:Me("registerVectorStoreAdapter adapter",t)},n))}registerAssuranceMeasurementProvider(t){if(O(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(Vi(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:Me("registerAssuranceMeasurementProvider provider",t)},n))}registerBeforeCommand(t){O(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(he("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")&&(he("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")&&(he("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")&&(he("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")&&(he("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")&&(he("onIndex",t),this.#o.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:t}))}};function Tf(e,t,n,r,o,i,s,a,c,d,l){return new hr(e,t,n,r,o,i,s,a,c,d,l)}function Rf(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 xf(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 Nf(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 Df(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 Pf=new Set(["output_format"]);function $f(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||Pf.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 Fw(e){let t=Oi(e.policy??of),n=Bt(),r=Xn(),o=Jn(),i=Qn(),s=Zn(),a=er(),c=tr(),d=[],l=[];for(let f of e.loaded){let p=hs(f.module);if(!p)continue;let _=d.length,g=fi({hooks:n,commands:r,parsers:o,preflight:i,services:s,renderers:a,registrations:c});try{await p.activate(Tf(f,n,r,o,i,s,a,c,l,d,t)),d.length>_&&(g(),l.push(`extension_activation_rolled_back:${f.layer}:${f.name}`))}catch(b){g(),l.push(`extension_activate_failed:${f.layer}:${f.name}`);let k=qi(b);d.push({layer:f.layer,name:f.name,entry_path:f.entry_path,error:Ht(b),trace:k})}}let m=[...xf(r),...Df(o),...Mi(i),...$f(s),...Nf(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:Rf(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 Vw(){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 Mf(){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 Le=null,ws=null,Ff=null,Uf=null,br=null,zf=null,vs=null,Es=null;var qf=[],ks=new jf;function I(){return ks.getStore()}function Xw(e){return ks.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}var Bf=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function bs(e){let t=H.resolve(e);for(;;){if(Lf(H.join(t,".git")))return t;let n=H.dirname(t);if(n===t)return;t=n}}function Vf(e){let t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),n=bs(t)??H.resolve(t),r=bs(n);if(!e)return{source_workspace_root:n,...r?{repo_root:r}:{}};let o=H.relative(n,H.resolve(e)),i=o.length>0&&!o.startsWith(`..${H.sep}`)&&o!==".."&&!H.isAbsolute(o);return{source_workspace_root:n,...r?{repo_root:r}:{},...i?{pm_root_rel:o.split(H.sep).join("/")}:{}}}function Jw(e){let t=I();if(t){t.hooks=e;return}Le=e}function Qw(e){let t=I();if(t){t.commands=e;return}ws=e}function Zw(e){let t=I();if(t){t.parsers=e;return}Ff=e}function ev(e){let t=I();if(t){t.preflight=e;return}Uf=e}function tv(e){let t=I();if(t){t.services=e;return}br=e}function nv(e){let t=I();if(t){t.renderers=e;return}zf=e}function rv(e){let t=I();if(t){t.registrations=e;return}vs=e}function Os(){let e=I();return e?e.registrations:vs}function Gf(){let e=I(),t=e?e.commandContext:Es;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):qf.push(e)}function iv(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"||Bf.has(i)||Object.hasOwn(r,i)&&r[i]!==void 0&&(n[i]=r[i])}return n}async function Ss(e){let t=I(),n=t?t.hooks:Le;return n?fr(n,e):[]}async function sv(e){let t=I(),n=t?t.hooks:Le;n&&await ur(n,e)}async function As(e){let t=I(),n=t?t.hooks:Le;return n?mr(n,e):[]}function av(){let e=I();return((e?e.hooks:Le)?.onRead?.length??0)>0}async function cv(e){let t=I(),n=t?t.hooks:Le;return n?pr(n,e):[]}async function dv(e){let t=I(),n=t?t.commands:ws;return n?_r(n,{...e,...Vf(e.pm_root)}):{handled:!1,result:null,warnings:[]}}function Cs(e,t){let n=I(),r=n?n.commandContext:Es;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 Yt(e,t){let n=I(),r=n?n.services:br;return r?yr(r,Cs(e,t)):{handled:!1,result:t,warnings:[]}}function Is(e,t){let n=I(),r=n?n.services:br;return r?gr(r,Cs(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]="3a66ccfd-51fb-5d4a-b9cd-257c49997d52")}catch{}})();var xs=new WeakMap;function yv(e,t){xs.set(e,new Set(t))}var Xt='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',Wf={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"}},Kf=[{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 hv(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,y.USAGE)}function V(e,t=new Set){let n=e.filter(r=>!t.has(r.name)).map(r=>({...r}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function bv(e,t){let n=Kf.find(o=>o.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return V([]);let r=n.omissions_by_mode[t];if(r===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return V(r)}var Hf=[{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 M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Yf=new Set([void 0,"tabular_when_uniform"]),Xf=new Set(["collection","none"]),Jf=new Set(["supported","unsupported"]);function Ts(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 Qf(e){return M(e)&&typeof e.command=="string"&&e.command.trim().length>0&&Xf.has(e.row_kind)&&Ts(e.row_keys,!0)&&(e.continuation_row_keys===void 0||Ts(e.continuation_row_keys,!1))&&Jf.has(e.fields)&&Yf.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 Zf={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"]},em={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 tm(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=Zf[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||M(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Xt}:{},toon_encoding:"tabular_when_uniform"}}let o=Wf[r],i=em[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)=>M(d)?d[l]:void 0,t);return Array.isArray(c)||M(c)});return{command:r,row_kind:s.length>0?"collection":"none",row_keys:s,fields:o.fields,...s.length>0?{jq_selector:Xt}:{},toon_encoding:"tabular_when_uniform"}})()}function nm(e){if(!M(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=>M(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),o=n.filter(s=>typeof s=="string");if(r.length!==t.length||o.length!==n.length)return;let i=new Set(r.map(s=>s.name));if(!(i.size!==r.length||new Set(o).size!==o.length||o.some(s=>!i.has(s))))return V(r,new Set(o))}function rm(e){if(!Array.isArray(e.sections_included))return;let t=V(Hf,new Set(e.sections_included.filter(n=>typeof n=="string")));return M(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")&&M(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&M(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function im(e){if(!M(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],r=["body","children","claim_state","linked","schedule"],o=xs.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 V(s,new Set(s.flatMap(({name:a})=>om(a,i(a),e)?[a]:[])))}function Rs(e){if(M(e.projection))return V([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function sm(e){if(!M(e.projection))return V([]);if(typeof e.projection.mode=="string")return V([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function am(e){if(!(!M(e.selected)||typeof e.selected.summary!="boolean"))return V([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function cm(e,t){let n=nm(t);if(n!==void 0)return n;let[r]=e.split(/\s+/u,1);if(r==="context")return rm(t);if(r==="get")return im(t);if(r==="list"||r.startsWith("list-"))return Rs(t);if(r==="search")return Rs(t)??V([{name:"projection_metadata",restore_with:"--full"}]);if(r==="health")return sm(t);if(r==="contracts")return am(t)}function Ns(e,t){if(e===void 0||!M(t))return t;let n=cm(e,t),r=t.row_contract,o=Qf(r)?r:tm(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 M(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 wr(e){let t=e.trim().toLowerCase().startsWith("extension:"),n=e.trim().toLowerCase().replace(/^extension:/u,"");if(De(n))return;let r=Os()?.commands??[],o=[...r].reverse().find(s=>s.command===n)?.command??(t?void 0:r.find(s=>s.action===n)?.command),i=[...r].reverse().find(s=>s.command===o);return i===void 0||De(i.command)||De(i.action)?void 0:i}function dm(e){let t=wr(e);return t?.read_output===void 0?void 0:t}function Ds(e,t){let n=dm(e),r=n?.read_output;if(r===void 0)return t;if(typeof t!="object"||t===null||Array.isArray(t))throw new h("Read-only extension commands must return a structured object.",y.USAGE,{code:"extension_read_output_invalid"});for(let o of r.row_keys){let i=t;for(let s of o.split("."))i=typeof i=="object"&&i!==null&&Object.hasOwn(i,s)?Reflect.get(i,s):void 0;if(i===null||typeof i!="object")throw new h(`Read-only extension result is missing declared row collection ${o}.`,y.USAGE,{code:"extension_read_output_invalid"})}return{...t,row_contract:{command:`extension:${n.command}`,row_kind:r.row_keys.length>0?"collection":"none",row_keys:[...r.row_keys],fields:"supported",...r.row_keys.length>0?{jq_selector:Xt}:{},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]="439cf503-a832-58a3-ba19-db44de57b573")}catch{}})();var Jt="changed_fields",lm="changed_field_count",vr="rows",um=new Set(["apply","rollback"]),Ls=new Set(["deleted","would_delete"]),Ps=256,$s={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function fm(e,t){if(!L(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn($s,e.action)?$s[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return L(s)&&L(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let r=e[n.at(-1)],o=Fs(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,Us(e[i],t)]))}}function Ms(e){return typeof e!="string"||e.length<=Ps?e:`${Z(e,Ps-1)}\u2026`}function mm(e){if(!L(e))return null;let t={...e};return t.reason=Ms(t.reason),L(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,r])=>[n,Ms(r)]))),t}function L(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function js(e){let t=e[Jt];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[r,o]of Object.entries(e))r!==Jt&&(n[r]=o);return n[lm]=t.length,n}function pm(e){return"item"in e&&Array.isArray(e[Jt])}function _m(e){return typeof e.mode=="string"&&um.has(e.mode)&&Array.isArray(e[vr])}function gm(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[vr]=t,n}function Fs(e){if(!L(e))return null;let t=L(e.item)?e.item:L(e.plan)?e.plan:null;if(t===null)return null;let n=typeof t.id=="string"?t.id:void 0,r=typeof e.outcome=="string"&&Ls.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 ym(e,t){if(!L(e))return null;if(L(e.plan)&&L(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||!L(e.item)||typeof e.item.id!="string")return null;let n=e[Jt];if(!Array.isArray(n))return null;let r={id:e.item.id,...typeof e.outcome=="string"&&Ls.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 hm(e,e.item,r),r}function hm(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=mm(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"])L(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 bm(e){let t=_m(e)?e[vr]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,r=t.map(o=>{if(!L(o))return o;let i=js(o);return i?(n=!0,i):o});return n?{projected:gm(e,r),changed:!0}:{projected:e,changed:!1}}function Us(e,t={}){let n=fm(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=Fs(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=ym(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!L(e))return e;let r=!1,o=e,i=pm(e)?js(e):null;i!==null&&(o=i,r=!0);let s=bm(o);return s.changed&&(o=s.projected,r=!0),r?o:e}import{AsyncLocalStorage as Yp}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"]),wm=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function vm(e){let t=e.indexOf("=");return t>0&&zs.has(e.slice(0,t))}function Em(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function qs(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(zs.has(n)){t+=Em(n,e[t+1])?1:0;continue}if(!(vm(n)||wm.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function Tv(e){let t=qs(e);return t===void 0?void 0:e[t].trim().toLowerCase()}import km 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 Bs=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)}"`},Vs=(e,t=process.platform)=>(t==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(e)?e:t==="win32"?Bs(e):`"${e.replace(/(["\\$`])/g,"\\$1")}"`,Qt=(e,t=process.platform)=>{let n=e.map(r=>Vs(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 Er=new WeakMap;function Lv(e){Er.set(e,e.path)}function Om(e){if(!process.env.PM_PATH?.trim())return;let t=To(e);return et(Ro(t),e)&&t===$n(e)?void 0:km.relative(e,t)||"."}function jv(e,t=process.cwd()){let n=(Er.has(e)?Er.get(e):e.path)||Om(t),r=n?["--pm-path",n]:[];return e.noExtensions&&r.push("--no-extensions"),r}import{createHash as $m}from"node:crypto";import{createHash as Rm}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 Sm=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 Gs(e,t){let n=e;for(let r of t.split("."))if(Array.isArray(n)){if(!/^\d+$/u.test(r))return;n=n[Number(r)]}else{if(!R(n))return;n=n[r]}return n}function kr(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 Ws(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=kr(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 en(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 Am(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):en(e)}function ie(e){return en(e).flatMap(t=>{let n=Gs(e,t);return Array.isArray(n)||R(n)?[{path:t,value:n}]:[]})}function je(e){return Am(e).flatMap(t=>{let n=Gs(e,t);return Array.isArray(n)||R(n)?[{path:t,value:n}]:[]})}function ut(e){let t=ie(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&&Sm.has(s)||r(a,i.length===0?s:`${i}.${s}`)};return r(e,""),t}function tn(e){return ie(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 ie(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=kr(n,r.path,o)}return n}function Ks(e,t){let n=e,r=!1;for(let o of ie(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=kr(n,o.path,s)}return{result:n,truncated:r}}var Hs=["high_level","low_level","blocked_fallback"];function Zt(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function Uv(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(Hs.map(r=>[r,Array.isArray(e[r])?e[r].filter(R).map(o=>Zt(n.get(o.id)??o)).join(""):""]))}}function Cm(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 Im(e,t,n,r){let o=Array.isArray(t[n])?t[n].filter(R):[],i=Cm(r[n],o.length)??o.map(Zt).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)??Zt(d);return m!==Zt(d)&&(c=!0),m}).join(""),needsStates:c}}function Tm(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(Tm(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=Hs.map(c=>({key:c,...Im(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 xm=4096,Nm=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"]),Xs=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:Nm}),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 Ys(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 Dm(e,t){return Array.isArray(e)?e.map(n=>Ys(n,t)):Ys(e,t)}function nn(e,t,n){let r=n?Xs[n]:void 0,o=r?.paths.includes(e)===!0;return Rm("sha256").update(fe({path:e,value:o?Dm(t,r):t,...o?{fingerprint_policy_version:r.version}:{}})).digest("base64url").slice(0,16)}function Or(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 Pm(e){return typeof e=="string"&&(Fe(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function gt(e){if(e.length>xm)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!_t(t)||t.v!==1||!Pm(t.c)||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function Js(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 Qs(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,y.USAGE,{code:"read_output_cursor_command_mismatch"});let r=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||nn(n.path,r.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",y.USAGE,{code:"read_output_cursor_stale"});return Ws(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 Ar=1,Zs=4096,Mm=/^[A-Za-z0-9_-]+$/;function Sr(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function tE(e,t){let n=[...Object.values(jt),...Ft],r=new Set(n.flatMap(o=>[Sr(o),o.slice(2).replaceAll("-","_")]));for(let o of t)if(o.cursor_semantics==="presentation"){r.add(Sr(o.flag));for(let i of o.aliases??[])r.add(Sr(i))}return Object.fromEntries(Object.entries(e).filter(([o])=>!r.has(o)))}function nE(e,t){return $m("sha256").update(e).update("\0").update(fe(t)).digest("hex").slice(0,24)}function yt(e,t,n,r){return Buffer.from(JSON.stringify({version:Ar,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...r===void 0?{}:{snapshot:r}})).toString("base64url")}function ve(e,t){return new h(e,y.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function Lm(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===Ar&&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 Cr(e,t="--after"){if(typeof e!="string")throw ve("Query cursor is malformed.",t);let n=e.trim();if(n.length===0||n.length>Zs||!Mm.test(n))throw ve("Query cursor is malformed.",t);let r;try{r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"))}catch{throw ve("Query cursor is malformed.",t)}if(!Lm(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}.`,y.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${n}; retain any producer ${t} cursor from the original page.`]}):ve("Query cursor version or payload is unsupported.",t)}return r}function Ir(e,t,n="--after"){let r=Cr(e,n);if(r.fingerprint!==t)throw ve(`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 rE(e,t){return Ir(e,t).after_id}function jm(e,t,n,r,o="--after"){if(t===void 0)return 0;let i=Ir(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 ve(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return s+1}function oE(e,t){if(t.cursor!==void 0&&Ir(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw ve("Query cursor does not match the requested snapshot.","--after");let n=jm(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 iE=Object.freeze({version:Ar,max_length:Zs});import{randomUUID as Fp}from"node:crypto";import{randomUUID as $p}from"node:crypto";import{constants as qe}from"node:fs";import{lstat as Ea,mkdir as Mp,open as Oa,rename as Lp,rm as jp}from"node:fs/promises";import dn from"node:path";import{constants as cp}from"node:fs";import z from"node:fs/promises";import ae from"node:path";import{randomUUID as sn}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="92573990-a040-526d-a0b1-b91d2ef401f1")}catch{}})();function ea(e){let t=Math.ceil(e.size/2);for(let n of e.keys()){if(t===0)return;e.delete(n),t-=1}}import Fm from"node:crypto";import{AsyncLocalStorage as Um}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 na=new Um,ta=1024;function ra(){let e=na.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 lE(e){let t=na.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>ta)throw new Error(`Reproducible token length must be an integer between 0 and ${ta}`);let n="";for(;n.length<e;){let r=Fm.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 zm=/^([+-]?)(\d+)([hdwm])$/i,qm=/^[+-]?\d+[hdwm](?:[+-]\d+[hdwm])+$/i,Bm=/^(\d{4})(\d{2})(\d{2})$/,Vm=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Gm=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})-(\d{2})(?:-(\d{2}))?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Wm=/^(\d{4}-\d{2}-\d{2})[T\s](\d{2})(\d{2})(\d{2})?([.,]\d{1,3})?(Z|[+-]\d{2}:?\d{2})?$/i,Km=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))$/i;function xr(){return ra()??new Date().toISOString()}function gE(e){return Number.isFinite(Date.parse(e))}function Hm(e){let t=Km.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<=Nr(l,m-1)&&f<=23&&p<=59&&_<=59&&(c===void 0||Number(c)<=23)&&(d===void 0||Number(d)<=59)}function yE(e){let t=/\.(\d+)(?:Z|[+-]\d{2}:\d{2})$/iu.exec(e)?.[1];return Hm(e)&&(t===void 0||/^\d{0,3}0*$/u.test(t))}var Ym=1e4,rn=new Map;function oa(e){let t=rn.get(e);if(t!==void 0)return t;let n=Date.parse(e);return rn.size>=Ym&&ea(rn),rn.set(e,n),n}function Ue(e,t){let n=oa(e),r=oa(t);return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?n-r:e.localeCompare(t)}function hE(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 Tr(e){return e?`.${e.slice(1).padEnd(3,"0").slice(0,3)}`:""}function Rr(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 Xm(e,t,n){n&&n!==t&&(e.includes(n)||e.push(n))}function Jm(e){let t=[],n=d=>Xm(t,e,d),r=Bm.exec(e);if(r){let[,d,l,m]=r;n(`${d}-${l}-${m}`)}let o=Vm.exec(e);if(o){let[,d,l,m,u,f,p,_,g]=o,b=p?`:${p}`:"";n(`${d}-${l}-${m}T${u}:${f}${b}${Tr(_)}${Rr(g)}`)}let i=Gm.exec(e);if(i){let[,d,l,m,u,f,p]=i,_=u?`:${u}`:"";n(`${d}T${l}:${m}${_}${Tr(f)}${Rr(p)}`)}let s=Wm.exec(e);if(s){let[,d,l,m,u,f,p]=s,_=u?`:${u}`:"";n(`${d}T${l}:${m}${_}${Tr(f)}${Rr(p)}`)}let a=10,c=e.slice(0,a);if(Zm(c)){let d=a;for(;d<e.length&&ep(e[d]);)d+=1;d<e.length&&n(`${c}T${e.slice(d)}`)}return t}function Qm(e){let t=Date.parse(e);if(Number.isFinite(t))return t;for(let n of Jm(e)){let r=Date.parse(n);if(Number.isFinite(r))return r}return Number.NaN}function Zm(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 ep(e){return e?e===" "||e===" "||e===`
|
|
8
|
+
`||e==="\r"||e==="\f"||e==="\v":!1}function Nr(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}var tp=["January","February","March","April","May","June","July","August","September","October","November","December"],np=/^(\d{4})-(\d{2})-(\d{2})/,rp=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;function op(e,t,n){let r=np.exec(t)??rp.exec(t);if(!r)return;let o=Number.parseInt(r[1],10),i=Number.parseInt(r[2],10),s=Number.parseInt(r[3],10),a=n?.trim()||"deadline";if(i<1||i>12)throw new h(`Invalid ${a} value "${e}". Month "${r[2]}" is out of range \u2014 use a month between 01 and 12.`,y.USAGE,{field:a,value:e});let c=Nr(o,i-1);if(s<1||s>c)throw new h(`Invalid ${a} value "${e}". ${tp[i-1]} ${o} has ${c} days, so day "${r[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`,y.USAGE,{field:a,value:e})}function ip(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,Nr(i,s));return n.setUTCFullYear(i,s,a),n}function bE(e,t=new Date,n="deadline"){let r=e.trim();if(r.toLowerCase()==="now")return t.toISOString();let o=zm.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 ip(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=Qm(r);if(!Number.isFinite(i)){let s=n.trim().length>0?n.trim():"deadline",a=qm.test(r)?"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.":'Use ISO/date string input, "now", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';throw new h(`Invalid ${s} value "${e}". ${a}`,y.USAGE,{field:s,value:e})}return new Date(i).toISOString()}import Dr from"node:fs/promises";import{createHash as sp}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 ia(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function ap(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return!ia(t,"ESRCH")}}function sa(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 sa(await Dr.readFile(`/proc/${e}/stat`,"utf8"))}catch{return null}}async function Pr(e=process.pid){let t=await ze(e);return{pid:e,...t===null?{}:{process_start_identity:t}}}async function $r(e,t,n){if(!ap(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 aa(){try{let[e,t]=await Promise.all([Dr.readFile("/proc/sys/kernel/random/boot_id","utf8"),Dr.readlink("/proc/self/ns/pid")]);return!/^[a-f0-9-]{36}\s*$/u.test(e)||!/^pid:\[\d+\]$/u.test(t)?null:sp("sha256").update(`${e.trim()}:${t}`).digest("hex")}catch{return null}}async function ca(){let[e,t]=await Promise.all([aa(),ze(process.pid)]);return e!==null&&t!==null?{host_identity:e,process_start_identity:t}:{}}async function Mr(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 aa();if(t===null||t!==e.host_identity)return"unknown";try{process.kill(e.pid,0)}catch(r){return ia(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]="c1ee0cca-ae03-50eb-8158-46510be6f43d")}catch{}})();function dp(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 Ee(e,t=!0){try{let n=await z.readFile(e,"utf8");return t&&await As({path:e,scope:"project"}),dp(n)}catch(n){return Ie(n)?{info:null,warnings:[]}:{info:null,warnings:["lock_info_read_failed"]}}}function se(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}async function lp(e,t,n=process.platform){if(se(e,"EEXIST"))return!0;if(!se(e,"EPERM")&&!se(e,"EACCES")&&!se(e,"EBUSY"))return!1;try{return await z.lstat(t),!0}catch(r){if(n!=="win32"||!Ie(r)&&!se(r,"EPERM")&&!se(r,"EACCES")&&!se(r,"EBUSY"))return!1}try{return await z.access(ae.dirname(t),cp.W_OK),!0}catch{return!1}}async function fa(e,t){await Ss({path:e,scope:"project",op:t})}async function up(e,t,n,r=sn()){return{...await ca(),id:e,pid:process.pid,owner:t,token:r,created_at:xr(),ttl_seconds:n}}async function fp(e,t,n,r,o,i){i&&await z.mkdir(ae.dirname(e),{recursive:!0});let s=await cn(e,t);if(s===null)throw await z.access(ae.dirname(e)),Object.assign(new Error("Lock initialization is contended"),{code:"EEXIST"});let a;try{let c=await z.open(e,"wx");try{try{let d=await up(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 Fr(e,"lock:release"),d}}finally{await s()}return await fa(e,"lock:create"),a}async function Fr(e,t){try{return await z.unlink(e),await fa(e,t),!0}catch{return!1}}async function mp(e,t,n,r){let o=Date.now(),i=Ur;for(;;){let s=await cn(e,t);if(s!==null){try{let d=await Ee(e,!1);Lr(d.info,t,n,r)&&await Fr(e,"lock:release")}finally{await s()}return}let a=await Ee(e,!1);if(!Lr(a.info,t,n,r))return;let c=Date.now()-o;if(c>=on)return;await zr(Math.min(i,on-c)),i=Math.min(i*2,an)}}function Lr(e,t,n,r){return e?.id===t&&e.pid===process.pid&&e.owner===n&&e.token===r}function ma(e,t){let n=e?.created_at?Date.parse(e.created_at):Number.NaN;return(Number.isFinite(n)?Date.now()-n:Number.POSITIVE_INFINITY)>t*1e3}async function pa(e){return e!==null&&Number.isFinite(Date.parse(e.created_at))&&await Mr(e)==="dead"}async function _a(e,t){return ma(e,t)||await pa(e)}async function LE(e,t,n){let{info:r}=await Ee(Mn(e,t),!1);return r!==null&&r.owner.startsWith(n)&&!await _a(r,r.ttl_seconds)}function pp(e){return e?.owner?` (owner ${e.owner})`:""}var Ur=25,an=200,ga=250,_p=12e4,gp=3,yp=".stale-cleanup",ya="owner.json",ha=1e4,on=ha+an,hp=60*6e4;function jr(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 bp(e){let t=process.env.PM_LOCK_WAIT_MS,n=jr(t);if(n!==void 0)return n;let r=jr(e);return r!==void 0?r:0}function wp(e,t){return Math.min(bp(e),t??1/0)}function zr(e){let t=Math.max(1,Math.round(e*(.5+Math.random())));return new Promise(n=>setTimeout(n,t))}async function ba(e,t,n,r=0){let o=await Mr(t),i=r>0?` across ${r} owner handoff(s)`:"",s=n>0?` after waiting ${n}ms${i}`:"";return new h(`Item ${e} is locked${pp(t)} (owner process ${o})${s}`,y.CONFLICT,{code:"lock_conflict",item_id:e,reason:`lock_owner_${o}`,required:"Wait for the owner to release the lock, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget when contention is expected. Inspect stale receipts with pm gc --scope locks --dry-run.",recovery:{retry_after_ms:ga,...n>0?{waited_ms:n,owner_handoffs:r}:{}}})}function vp(e,t){let n=Date.now(),r=n,o,i=0;return{startedAtMs:n,observe(s){let a=Date.now(),c=kp(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 Ep(e,t,n){return n!=="progress"||t!==void 0?e:Math.max(e,_p)}function kp(e){return e===null?"released":e.token??`${e.pid}:${e.owner}:${e.created_at}`}function Op(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 Sp(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 da(e,t,n,r){let{summary:o,required:i}=Sp(e,t,n,r);return new h(`${o} Nothing was written.`,y.CONFLICT,{code:"lock_lost",item_id:e,reason:r,lease:Op(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:ga}})}async function Ap(e,t){let n=Date.now(),r=Ur;for(;;){let o=await cn(e,t);if(o!==null)return o;let i=Date.now()-n;if(i>=on)return null;await zr(Math.min(r,on-i)),r=Math.min(r*2,an)}}async function Cp(e,t,n,r){let o=await Ap(e,t);if(o===null){let i=await Ee(e,!1);throw da(t,n,i.info,"fence_gate_unavailable")}try{let i=await Ee(e,!1);if(!Lr(i.info,t,n.owner,n.token))throw da(t,n,i.info,i.info===null?"lease_released":"lease_taken_over");return await r()}finally{await o()}}function Ip(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 Tp(e,t,n,r){if(!n&&r){let o=t.warnings.length>0?` (${t.warnings.join(",")})`:"";throw new h(`Item ${e} lock is stale${o}; rerun with --force when supported for this command`,y.CONFLICT)}}function Rp(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null||Array.isArray(t))return null;let n=t,r=n.pid,o=n.token,i=n.process_start_identity;return typeof r!="number"||!Number.isInteger(r)||r<=0||typeof o!="string"||o.length===0||i!==void 0&&(typeof i!="string"||!/^\d+$/u.test(i))?null:{pid:r,token:o,...typeof i=="string"?{process_start_identity:i}:{}}}async function wa(e){try{return Rp(await z.readFile(ae.join(e,ya),"utf8"))}catch{return null}}async function qr(e){try{return await z.rm(e,{recursive:!0,force:!0}),!0}catch{return!1}}async function la(e,t){let n=await wa(e);n===null||n.token!==t||await qr(e)}async function ua(e){try{await z.mkdir(e)}catch(n){return se(n,"EEXIST"),null}let t={...await Pr(),token:sn()};try{await z.writeFile(ae.join(e,ya),`${JSON.stringify(t)}
|
|
10
|
+
`,"utf8")}catch{return await qr(e),null}return t}async function xp(e){let t;try{let r=await z.stat(e);if(t=Date.now()-r.mtimeMs,t<=ha)return!1}catch(r){return Ie(r)}let n=await wa(e);return n!==null&&await $r(n,t,hp)?!1:qr(e)}async function cn(e,t){let n=`${e}${yp}`,r=await ua(n);if(r!==null)return async()=>la(n,r.token);if(!await xp(n))return null;let o=await ua(n);return o===null?null:async()=>la(n,o.token)}async function Np(e,t){let n=ae.join(ae.dirname(e),"recoveries");await z.mkdir(n,{recursive:!0}),await z.writeFile(ae.join(n,`${sn()}.json`),`${JSON.stringify({event:"owner_dead_recovery_attempt",recorded_at:xr(),lock:JSON.parse(t)})}
|
|
11
|
+
`,{encoding:"utf8",flag:"wx",mode:384})}async function Dp(e){let t=await cn(e.lockPath,e.id);if(t===null)return{lockInfo:e.fallbackLockInfo,shouldRetryCreate:!1,staleRemovalCounted:!1};try{let n=await Ee(e.lockPath);if(n.info===null&&n.warnings.length===0)return{lockInfo:n,shouldRetryCreate:!0,staleRemovalCounted:!1};let r=await pa(n.info);if(!ma(n.info,e.ttlSeconds)&&!r)return{lockInfo:n,shouldRetryCreate:!1,staleRemovalCounted:!1};if(Tp(e.id,n,e.force||r,e.forceRequiredForStaleLock),e.staleRemovals>=gp)throw await ba(e.id,n.info,Date.now()-e.startedAtMs);return r&&await Np(e.lockPath,JSON.stringify(n.info)),{lockInfo:n,shouldRetryCreate:await Fr(e.lockPath,"lock:stale_remove"),staleRemovalCounted:!0}}finally{await t()}}async function va(e,t,n,r,o=!1,i=!0,s,a={}){return(await Pp(e,t,n,r,o,i,s,a)).release}async function Pp(e,t,n,r,o=!1,i=!0,s,a={}){let c=jr(a.maxWaitMs),d=await Yt("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=Ip(d.result);if(k)return{release:async()=>{await Promise.resolve(k()),await Yt("lock_release",{pm_root:e,id:t,owner:r})},fence:F=>F()}}let l=Mn(e,t),m=wp(s,c),u=Ep(m,c,a.waitPolicy),f=vp(m,u),p=f.startedAtMs,_=0,g=Ur,b=sn();for(;;)try{let k=await fp(l,t,r,n,b,a.createParentDirectories!==!1),F={owner:r,token:b,acquiredAt:k,ttlSeconds:n};return{release:async()=>{await mp(l,t,r,b),await Yt("lock_release",{pm_root:e,id:t,owner:r})},fence:X=>Cp(l,t,F,X)}}catch(k){if(!await lp(k,l))throw new h(`Failed to acquire lock for ${t}: ${di(k)}`,y.GENERIC_FAILURE);let F=await Ee(l);if(await _a(F.info,n)){let Ae=await Dp({lockPath:l,id:t,ttlSeconds:n,force:o,forceRequiredForStaleLock:i,staleRemovals:_,waitBudgetMs:m,startedAtMs:p,fallbackLockInfo:F});if(F=Ae.lockInfo,Ae.staleRemovalCounted&&(_+=1),Ae.shouldRetryCreate)continue}let X=f.observe(F.info);if(X.exhausted)throw await ba(t,F.info,m===0?0:X.elapsedMs,X.ownerHandoffs);await zr(Math.min(g,X.remainingMs)),g=Math.min(g*2,an)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71b65888-baa5-5c5f-a02c-4a0fd818fadb")}catch{}})();var Y={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 ke(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 Sa(e){let t=e.maxBytes??Y.max_bytes,n=e.maxEvents??Y.max_events,r=e.retentionDays??Y.retention_days;if(!Number.isSafeInteger(t)||t<1024||t>Y.max_bytes||!Number.isSafeInteger(n)||n<1||!Number.isFinite(r)||r<=0)throw new T("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");return{maxBytes:t,maxEvents:n,cutoff:ke(e).ms-r*864e5}}async function Aa(e,t){if(!(await Ea(dn.dirname(e))).isDirectory())throw new T("Context usage runtime must be a real directory");try{if((await Ea(e)).isSymbolicLink())throw new T("Context usage ledger must not be a symbolic link")}catch(r){if(!Ie(r))throw r}let n=await Oa(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 ln(e){let t=Sa(e);try{let n=await Aa(dn.join(e.pmRoot,"runtime","context-usage.jsonl"),qe.O_RDONLY);try{let r=(await n.stat()).size,o=Math.max(0,r-t.maxBytes),i=Buffer.alloc(Math.min(r,t.maxBytes)),{bytesRead:s}=await n.read(i,0,i.length,o),a=i.subarray(0,s).toString("utf8");return(o>0?a.includes(`
|
|
12
12
|
`)?a.slice(a.indexOf(`
|
|
13
13
|
`)+1):"":a).split(`
|
|
14
|
-
`).flatMap(c=>{try{let d=JSON.parse(c);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await n.close()}}catch{return[]}}function
|
|
15
|
-
`;if(o+=Buffer.byteLength(s),o>t)break;r.push(s)}return r.reverse().join("")}async function
|
|
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=ba(a,i,r.maxEvents),d=performance.now(),l=await ya(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),m=performance.now()-d;try{await xp(cn.dirname(o),{recursive:!0});let u=await Ea(o,qe.O_WRONLY|qe.O_CREAT|qe.O_APPEND);try{let f=(await u.stat()).size,p=n===void 0?void 0:await dn(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 _=ba([...p??await dn(e),...a],i,r.maxEvents),g=`${o}.${process.pid}.${Rp()}.tmp`,b=await wa(g,"wx",384);try{try{await b.writeFile(_,"utf8")}finally{await b.close()}return await u.close(),u=void 0,await Np(g,o),{written_bytes:Buffer.byteLength(_),ledger_bytes:Buffer.byteLength(_),compacted:!0,lock_wait_ms:m}}finally{await Dp(g,{force:!0})}}finally{await u?.close()}}finally{await l()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e76b38ce-b2aa-589b-9d17-0952eca9e7a2")}catch{}})();var $p=864e5,ln=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function x(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function zE(e,t){let n=x(e);n!==null&&t!==null&&(n[ln]=t)}function un(e,t){let n=x(e),r=x(t),o=n?.[ln];r!==null&&o!==void 0&&(r[ln]=o)}function Mp(e){return x(e)?.[ln]??null}function Oa(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 ce(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function Sa(e,t){if(Array.isArray(t))for(let n of t)ce(e,x(n)?.id)}function ka(e,t){if(Array.isArray(t))for(let n of t)ce(e,n)}function Lp(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);ce(t,o?.id);for(let i of Array.isArray(o?.blockers)?o.blockers:[])ce(t,x(i)?.id);for(let i of Array.isArray(o?.unblocks)?o.unblocks:[])ce(t,i)}}function jp(e,t){for(let n of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])Sa(t,e[n]);for(let n of Array.isArray(e.blockers)?e.blockers:[])ce(t,x(n)?.blocked_by);Fp(e,t)}function Fp(e,t){for(let o of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=x(o);ce(t,i?.id),Sa(t,i?.children)}for(let o of["files","workload"])for(let i of Array.isArray(e[o])?e[o]:[])ka(t,x(i)?.items);let n=x(e.agenda);for(let o of Array.isArray(n?.events)?n.events:[])ce(t,x(o)?.item_id);let r=x(e.tests);ka(t,r?.items_failing)}function Up(e,t){let n=x(e);if(n===null||Oa(e))return[];let r=new Set;return t==="next"?Lp(n,r):jp(n,r),[...r]}async function qE(e){let t=Mp(e.result);if(t===null)return!1;let n=Oa(e.result);return await zp({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:Up(e.result,t.surface),resultOmitted:n}),!0}async function BE(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,Y.max_serving_rows),r={serve_id:Pp(),author:e.author.trim(),surface:e.surface,rows:t,recorded_item_ids:n.map(o=>o.id)};return r.storage=await yt(e,[{kind:"serve",schema_version:2,serve_id:r.serve_id,at:ke(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 zp(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:ke(e).iso,author:e.receipt.author,surface:e.receipt.surface,result_omitted:e.resultOmitted,delivered_item_ids:n.filter(i=>r.has(i))};await yt(e,[o],o.serve_id)}async function VE(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 yt(e,[{kind:"touch",at:ke(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function GE(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=ke(e).iso,i=[...r].map(s=>({kind:"touch",at:o,author:t,item_id:s,intent:n}));await yt(e,i)}function qp(e,t,n,r){return e.find(({entry:o,time:i})=>o.item_id===t&&i>=n&&i-n<=r)?.time}function Bp(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 WE(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 dn(e),n=ke(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=Bp(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 g of u.rows){if(!_.has(g.id))continue;let b=qp(i,g.id,f,r);if(b===void 0)continue;d+=1;let k=Math.max(0,(n-b)/$p);s.set(g.id,(s.get(g.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]="417afa3c-d34b-53d9-b273-86903e17576f")}catch{}})();var Ia=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"}]),Ta=new Vp;function Gp(){return Ta.getStore()??Ia}function ok(e,t){return Ta.run(Kp(e.workspaceContracts,e.packageContracts),t)}function Wp(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 Kp(e=[],t=[]){let n=[{source:"core",contracts:Ia,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=Wp(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 Ra(e,t,n=Gp(),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 g=1;g<=i.length;g+=1){let b=f[g];f[g]=Math.min(f[g]+1,f[g-1]+1,_+(u[p-1]===i[g-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=Jt(l);throw new h(`Unknown context intent "${i}" for ${o}. Did you mean "${c}"?`,y.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:i,required:`Use a declared ${o} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[m],recovery:{recovery_mode:"compact",attempted_command:Jt(d),allowed_values:[...a].sort(),suggested_retry:m,suggested_retry_args:l}})}var xa={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=mn(e.tokenBudget,t.token_budget),o=pn("context",t.intent,r,n),i=Oe(e.limit),s=String(i===void 0?o:Math.min(i,o));(e.limit===void 0||i!==void 0)&&(e.limit=s),e.activityLimit===void 0&&(e.activityLimit=s)},get:e=>{e.depth===void 0&&e.fields===void 0&&(e.depth="standard")},list:(e,t,n)=>{e.brief===void 0&&e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");let r=mn(e.tokenBudget,t.token_budget),o=pn("list",t.intent,r,n),i=Oe(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))},next:e=>{e.readyOnly===void 0&&(e.readyOnly=!0)},search:(e,t,n)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let r=mn(e.tokenBudget,t.token_budget),o=pn("search",t.intent,r,n),i=Oe(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))}};function ik(e,t,n=[]){let r=t.tokenBudget??t.token_budget;if(typeof t.for!="string"){if(r!==void 0&&(e==="get"||e==="list"||e==="search"))throw new h("--token-budget requires a declared context intent selected with --for",y.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(t.tokenBudget!==void 0||t.token_budget===void 0)return t;let a={...t,tokenBudget:r};return delete a.token_budget,a}let o=Ra(e,t.for,void 0,n),i=Oe(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)),xa[e](s,o,i),s}var Hp={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},fn=256;function zr(e){return Array.isArray(e)?e.map(zr):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,zr(n)])):typeof e=="string"&&e.length>240?`${Z(e,240)}\u2026`:e}function Oe(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 mn(e,t){let n=Oe(e);if(n===void 0)return t;if(n<fn)throw new h(`Context intent token budget must be at least ${fn}`,y.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(e),required:`Use an integer token budget of at least ${fn}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${fn} or omit the override.`]});return n}function pn(e,t,n,r){if(e==="get"||e==="next")return;let o=e==="context"&&t==="orient",i=e==="context"?o?1200:800:e==="list"?520:480,s=e==="context"?o?600:500:16,a=Math.max(e==="context"?1:2,Math.floor((n-i)/s));return r?a:Math.min(e==="context"?20:100,a)}function de(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 Aa={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 Na(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 Yp(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 Xp(e,t,n){let r=!1;for(;;){if(de(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 Jp(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=Na(i);if(s===void 0)return!1;let a=r.length,c=[...r],d=!1;for(;;){if(d=Xp(e,t,r)||d,!d)return!1;let l=Yp(r.at(-1));if(l===void 0)return r.splice(0,r.length,...c),de(e,t),!1;if(e.next_cursor=gt(s.fingerprint,l,o?s.after_index-(a-r.length):s.after_index+r.length,s.snapshot),de(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 Qp(e,t,n,r){if(e==="list"||e==="search")return Jp(t,n,r);if(e!=="next"||typeof t.next_cursor=="string")return!1;let o=!1;for(;;){if(de(t,n),n.estimated_tokens<=n.token_budget)return o;let i=Aa[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=Aa[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 Zp(e,t,n){if(typeof t.for!="string")return n;let r=e.startsWith("list-")?"list":e;if(!(r in xa))return n;let o=r,i=Ra(o,t.for),s=mn(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:Hp[o],declaration_feasible:!0,result_omitted:!1},c={...n},d=pn(o,i.intent,a.token_budget,Oe(t.tokenBudget??t.token_budget)!==void 0);if(d!==void 0){let m=Oe(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}let l={...c,context_intent:a};return de(l,a),a.estimated_tokens>a.token_budget&&(a.degradation="recursive_budget_compaction",l={...zr(c),context_intent:a},de(l,a)),a.estimated_tokens>a.token_budget&&Qp(o,l,a,t)&&(a.degradation="budget_row_compaction",de(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:n_(e,o,i.intent,a,c)},context_intent:a}),l}var e_=["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"];function t_(e,t){if(typeof e.after!="string"||e.after.length===0)return t;let n=Na(e.after)?.fingerprint??"opaque_cursor",r={...t};for(let o of e_)delete r[o];return r.continuation_contract={fingerprint:n,metadata:"reference",restore_with:"omit --after"},r}function Br(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function n_(e,t,n,r,o){let i=t==="get"&&Br(o.item)&&typeof o.item.id=="string"?o.item.id:t==="search"&&typeof o.query=="string"?o.query:void 0,s=i===void 0?"":` '${i.replaceAll("'",`'"'"'`)}'`,a=t==="get"?"":` --limit ${r.budget_derived_limit??1}`;return`pm ${e}${s} --for ${n} --token-budget ${Math.ceil(r.estimated_tokens/100)*100}${a}`}function Be(e,t){if(Br(e))return typeof e[t]=="number"?e[t]:void 0}function r_(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(Br(n.context_intent)&&de(n,n.context_intent),n=qr(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 o_(e,t,n){let r=Is(e,Ts(e??"",n)),o=typeof r=="object"&&r!==null&&!Array.isArray(r)?Ca(e??"",{...t,outputRowContract:t.outputRowContract===!0||t.output_row_contract===!0},t_(t,Zp(e??"",t,r))):r;if(un(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=r_(i,t);return delete s.row_contract,un(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 Ve=["result_rows","envelope","diagnostics","hints"],i_=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,s_=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,a_=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,c_=8;function Vr(e){return Buffer.byteLength(e,"utf8")}function Da(e){return Vr(JSON.stringify(e)??"null")}function d_(e,t){return s_.test(e)?"diagnostics":a_.test(e)?"hints":i_.test(e)||Array.isArray(t)?"result_rows":"envelope"}function l_(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"]=Da(e),t;for(let[n,r]of Object.entries(e))t[d_(n,r)]+=Da({[n]:r});return Object.values(t).every(n=>n===0)&&(t.envelope=1),t}function u_(e,t){let n=Ve.reduce((s,a)=>s+t[a],0),r=Ve.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-Ve.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))||Ve.indexOf(a.section)-Ve.indexOf(c.section))){if(i===0)break;o[s.section]+=1,i-=1}return o}function Pa(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function f_(e,t){let n=Vr(t(e)),r=u_(n,l_(e)),o=Object.fromEntries(Ve.map(a=>[a,{bytes:r[a],estimated_tokens:_e(r[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:n,total_estimated_tokens:_e(n),sections:o,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=Pa(e,i);for(let a=0;a<c_;a+=1){let c=Vr(t(s))-n;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:_e(c)},s=Pa(e,i)}return s}import{encode as Gr}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]="8936e93f-25bf-58cc-ba91-37cc2677c5d2")}catch{}})();function $a(e){let t=[...new Set(e.flatMap(i=>Object.keys(i)))],n=t.filter(i=>e.some(s=>{let a=s[i];return a!==null&&typeof a=="object"})),r=new Set(n),o=[];return{rows:e.map((i,s)=>Object.fromEntries(t.map(a=>{if(!Object.hasOwn(i,a))return o.push([s,a]),[a,null];let c=i[a];return[a,r.has(a)?JSON.stringify(c):c]}))),encoding:{json_columns:n,absent: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]="dc76b081-02dc-5b09-ab40-cd57c733b3ad")}catch{}})();var uk=["id","title","status","type","priority","parent","updated_at"],_n=["id","status","type","title"],fk={list:"brief","list-all":"full","list-draft":"full","list-open":"brief","list-in-progress":"brief","list-blocked":"brief","list-closed":"brief","list-canceled":"full"},m_=["tree_depth","tree_parent","tree_children","tree_title"];function mk(e=[]){return[...new Set([...En,"body",...m_,...e])].flatMap(t=>[t,`item.${t}`]).sort()}var pk=["brief","standard","deep"],p_=["body","linked","claim_state","children","schedule","blockers"],__=["linked.files","linked.tests","linked.docs"],g_=["claim_state.claimed","claim_state.assignee","claim_state.last_claim","claim_state.last_release"],y_=["schedule.deadline","schedule.start_at","schedule.end_at","schedule.location","schedule.reminders","schedule.events"];function _k(e=[]){return[...[...new Set([...En,...e,"notes_count","tests_count","collection_counts"])].flatMap(t=>[t,`item.${t}`]),...p_,...__,...g_,...y_].sort()}var gk=["id","title","status","type","priority","updated_at","score","matched_fields"],h_=["score","matched_fields","highlights"],Ma=["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 yk(e=[]){let t=[...new Set(e)];return[...h_,...Ma,...Ma.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]="95103919-d686-5c3b-bd51-928f5b2314ef")}catch{}})();function Ge(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function b_(e){if(!Ge(e))return!1;let t=e.fields;return e.mode==="brief"&&Object.keys(e).length===2&&Array.isArray(t)&&(t.length===_n.length||t.length===_n.length+1&&t.at(-1)==="priority")&&_n.every((n,r)=>t[r]===n)}function w_(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 v_(e){return Ge(e)&&(e.status==="complete"||e.status==="unchecked")&&e.unreadable_item_count===0&&e.unreadable_directory_count===0}function E_(e){if(!Ge(e)||!Array.isArray(e.omitted_field_groups))return!1;let t=e.omitted_field_groups,n=t[0];return e.has_omissions===!0&&e.omitted_field_group_count===1&&Object.keys(e).length===3&&t.length===1&&Ge(n)&&Object.keys(n).length===2&&n.name==="full_item_fields"&&n.restore_with==="--full"}function La(e){if(!Ge(e)||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!b_(e.projection)||!v_(e.completeness)||!w_(e,e.items.length)||!E_(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,...l}=e,m=i.status==="complete"&&!n&&Object.keys(i).length===3,{unreadable_item_count:u,unreadable_directory_count:f,...p}=i;return{...l,...m?{}:{total:t,has_more:n,completeness:p},...n?{next_cursor:o}:{},...Ge(d)&&d.sort==="default"&&d.order==="asc"&&Object.keys(d).length===2?{}:{sorting:d},details:"--full"}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dd3b19cb-eda3-5ee9-a838-f0abaa5cc8ea")}catch{}})();var $k=new Set(Object.values(y)),S_=new Map([["notes_count","notes"],["tests_count","tests"]]);var ja=!1;function j(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Wr(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function A_(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.SUCCESS)}function C_(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.GENERIC_FAILURE)}function Kr(e){if(e==="stdout"){A_();return}C_()}function Fa(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function I_(){ja||(ja=!0,process.stdout.on("error",e=>{if(Wr(e)){Kr("stdout");return}Fa(e)}),process.stderr.on("error",e=>{if(Wr(e)){Kr("stderr");return}Fa(e)}))}function T_(e,t){I_();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(n){if(Wr(n))return Kr(e),!1;throw n}}function R_(e){return T_("stderr",e)}function Ua(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function x_(e){let t=Object.keys(e[0]);return t.length>0&&e.every(n=>Object.keys(n).length===t.length&&t.every(r=>{if(!Object.hasOwn(n,r))return!1;let o=n[r];return o===null||typeof o=="string"||typeof o=="number"||typeof o=="boolean"}))}function Hr(e,t){let n=" ".repeat(t);return e.split(`
|
|
14
|
+
`).flatMap(c=>{try{let d=JSON.parse(c);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await n.close()}}catch{return[]}}function ka(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=Sa(e),o=dn.join(e.pmRoot,"runtime","context-usage.jsonl"),i=Math.floor(r.maxBytes*Y.retained_byte_fraction),s=Math.min(Y.max_event_bytes,i);if(t.some(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=ka(a,i,r.maxEvents),d=performance.now(),l=await va(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),m=performance.now()-d;try{await Mp(dn.dirname(o),{recursive:!0});let u=await Aa(o,qe.O_WRONLY|qe.O_CREAT|qe.O_APPEND);try{let f=(await u.stat()).size,p=n===void 0?void 0:await ln(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 _=ka([...p??await ln(e),...a],i,r.maxEvents),g=`${o}.${process.pid}.${$p()}.tmp`,b=await Oa(g,"wx",384);try{try{await b.writeFile(_,"utf8")}finally{await b.close()}return await u.close(),u=void 0,await Lp(g,o),{written_bytes:Buffer.byteLength(_),ledger_bytes:Buffer.byteLength(_),compacted:!0,lock_wait_ms:m}}finally{await jp(g,{force:!0})}}finally{await u?.close()}}finally{await l()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e76b38ce-b2aa-589b-9d17-0952eca9e7a2")}catch{}})();var Up=864e5,un=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function x(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function YE(e,t){let n=x(e);n!==null&&t!==null&&(n[un]=t)}function fn(e,t){let n=x(e),r=x(t),o=n?.[un];r!==null&&o!==void 0&&(r[un]=o)}function zp(e){return x(e)?.[un]??null}function Ia(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 ce(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function Ta(e,t){if(Array.isArray(t))for(let n of t)ce(e,x(n)?.id)}function Ca(e,t){if(Array.isArray(t))for(let n of t)ce(e,n)}function qp(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);ce(t,o?.id);for(let i of Array.isArray(o?.blockers)?o.blockers:[])ce(t,x(i)?.id);for(let i of Array.isArray(o?.unblocks)?o.unblocks:[])ce(t,i)}}function Bp(e,t){for(let n of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])Ta(t,e[n]);for(let n of Array.isArray(e.blockers)?e.blockers:[])ce(t,x(n)?.blocked_by);Vp(e,t)}function Vp(e,t){for(let o of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=x(o);ce(t,i?.id),Ta(t,i?.children)}for(let o of["files","workload"])for(let i of Array.isArray(e[o])?e[o]:[])Ca(t,x(i)?.items);let n=x(e.agenda);for(let o of Array.isArray(n?.events)?n.events:[])ce(t,x(o)?.item_id);let r=x(e.tests);Ca(t,r?.items_failing)}function Gp(e,t){let n=x(e);if(n===null||Ia(e))return[];let r=new Set;return t==="next"?qp(n,r):Bp(n,r),[...r]}async function XE(e){let t=zp(e.result);if(t===null)return!1;let n=Ia(e.result);return await Wp({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:Gp(e.result,t.surface),resultOmitted:n}),!0}async function JE(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,Y.max_serving_rows),r={serve_id:Fp(),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:ke(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 Wp(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:ke(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 QE(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:ke(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function ZE(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=ke(e).iso,i=[...r].map(s=>({kind:"touch",at:o,author:t,item_id:s,intent:n}));await ht(e,i)}function Kp(e,t,n,r){return e.find(({entry:o,time:i})=>o.item_id===t&&i>=n&&i-n<=r)?.time}function Hp(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 ek(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 ln(e),n=ke(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=Hp(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 g of u.rows){if(!_.has(g.id))continue;let b=Kp(i,g.id,f,r);if(b===void 0)continue;d+=1;let k=Math.max(0,(n-b)/Up);s.set(g.id,(s.get(g.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]="417afa3c-d34b-53d9-b273-86903e17576f")}catch{}})();var Na=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"}]),Da=new Yp;function Xp(){return Da.getStore()??Na}function fk(e,t){return Da.run(Qp(e.workspaceContracts,e.packageContracts),t)}function Jp(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 Qp(e=[],t=[]){let n=[{source:"core",contracts:Na,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=Jp(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 Pa(e,t,n=Xp(),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 g=1;g<=i.length;g+=1){let b=f[g];f[g]=Math.min(f[g]+1,f[g-1]+1,_+(u[p-1]===i[g-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=Qt(l);throw new h(`Unknown context intent "${i}" for ${o}. Did you mean "${c}"?`,y.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:i,required:`Use a declared ${o} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[m],recovery:{recovery_mode:"compact",attempted_command:Qt(d),allowed_values:[...a].sort(),suggested_retry:m,suggested_retry_args:l}})}var $a={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=pn(e.tokenBudget,t.token_budget),o=_n("context",t.intent,r,n),i=Oe(e.limit),s=String(i===void 0?o:Math.min(i,o));(e.limit===void 0||i!==void 0)&&(e.limit=s),e.activityLimit===void 0&&(e.activityLimit=s)},get:e=>{e.depth===void 0&&e.fields===void 0&&(e.depth="standard")},list:(e,t,n)=>{e.brief===void 0&&e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");let r=pn(e.tokenBudget,t.token_budget),o=_n("list",t.intent,r,n),i=Oe(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))},next:e=>{e.readyOnly===void 0&&(e.readyOnly=!0)},search:(e,t,n)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let r=pn(e.tokenBudget,t.token_budget),o=_n("search",t.intent,r,n),i=Oe(e.limit);(e.limit===void 0||i!==void 0)&&(e.limit=String(i===void 0?o:Math.min(i,o)))}};function mk(e,t,n=[]){let r=t.tokenBudget??t.token_budget;if(typeof t.for!="string"){if(r!==void 0&&(e==="get"||e==="list"||e==="search"))throw new h("--token-budget requires a declared context intent selected with --for",y.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(t.tokenBudget!==void 0||t.token_budget===void 0)return t;let a={...t,tokenBudget:r};return delete a.token_budget,a}let o=Pa(e,t.for,void 0,n),i=Oe(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)),$a[e](s,o,i),s}var Zp={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},mn=256;function Br(e){return Array.isArray(e)?e.map(Br):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Br(n)])):typeof e=="string"&&e.length>240?`${Z(e,240)}\u2026`:e}function Oe(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 pn(e,t){let n=Oe(e);if(n===void 0)return t;if(n<mn)throw new h(`Context intent token budget must be at least ${mn}`,y.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(e),required:`Use an integer token budget of at least ${mn}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${mn} or omit the override.`]});return n}function _n(e,t,n,r){if(e==="get"||e==="next")return;let o=e==="context"&&t==="orient",i=e==="context"?o?1200:800:e==="list"?520:480,s=e==="context"?o?600:500:16,a=Math.max(e==="context"?1:2,Math.floor((n-i)/s));return r?a:Math.min(e==="context"?20:100,a)}function de(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 Ra={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 Ma(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 e_(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 t_(e,t,n){let r=!1;for(;;){if(de(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 n_(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=Ma(i);if(s===void 0)return!1;let a=r.length,c=[...r],d=!1;for(;;){if(d=t_(e,t,r)||d,!d)return!1;let l=e_(r.at(-1));if(l===void 0)return r.splice(0,r.length,...c),de(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),de(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 r_(e,t,n,r){if(e==="list"||e==="search")return n_(t,n,r);if(e!=="next"||typeof t.next_cursor=="string")return!1;let o=!1;for(;;){if(de(t,n),n.estimated_tokens<=n.token_budget)return o;let i=Ra[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=Ra[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 o_(e,t,n){if(typeof t.for!="string")return n;let r=e.startsWith("list-")?"list":e;if(!(r in $a))return n;let o=r,i=Pa(o,t.for),s=pn(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:Zp[o],declaration_feasible:!0,result_omitted:!1},c={...n},d=_n(o,i.intent,a.token_budget,Oe(t.tokenBudget??t.token_budget)!==void 0);if(d!==void 0){let m=Oe(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}let l={...c,context_intent:a};return de(l,a),a.estimated_tokens>a.token_budget&&(a.degradation="recursive_budget_compaction",l={...Br(c),context_intent:a},de(l,a)),a.estimated_tokens>a.token_budget&&r_(o,l,a,t)&&(a.degradation="budget_row_compaction",de(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:a_(e,o,i.intent,a,c)},context_intent:a}),l}var i_=["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"];function s_(e,t){if(typeof e.after!="string"||e.after.length===0)return t;let n=Ma(e.after)?.fingerprint??"opaque_cursor",r={...t};for(let o of i_)delete r[o];return r.continuation_contract={fingerprint:n,metadata:"reference",restore_with:"omit --after"},r}function Gr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function a_(e,t,n,r,o){let i=t==="get"&&Gr(o.item)&&typeof o.item.id=="string"?o.item.id:t==="search"&&typeof o.query=="string"?o.query:void 0,s=i===void 0?"":` '${i.replaceAll("'",`'"'"'`)}'`,a=t==="get"?"":` --limit ${r.budget_derived_limit??1}`;return`pm ${e}${s} --for ${n} --token-budget ${Math.ceil(r.estimated_tokens/100)*100}${a}`}function Be(e,t){if(Gr(e))return typeof e[t]=="number"?e[t]:void 0}function c_(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(Gr(n.context_intent)&&de(n,n.context_intent),n=Vr(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 d_(e,t,n){let r=Ns(e,Ds(e??"",n)),o=typeof r=="object"&&r!==null&&!Array.isArray(r)?xa(e??"",{...t,outputRowContract:t.outputRowContract===!0||t.output_row_contract===!0},s_(t,o_(e??"",t,r))):r;if(fn(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=c_(i,t);return delete s.row_contract,fn(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 Ve=["result_rows","envelope","diagnostics","hints"],l_=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,u_=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,f_=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,m_=8;function Wr(e){return Buffer.byteLength(e,"utf8")}function La(e){return Wr(JSON.stringify(e)??"null")}function p_(e,t){return u_.test(e)?"diagnostics":f_.test(e)?"hints":l_.test(e)||Array.isArray(t)?"result_rows":"envelope"}function __(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"]=La(e),t;for(let[n,r]of Object.entries(e))t[p_(n,r)]+=La({[n]:r});return Object.values(t).every(n=>n===0)&&(t.envelope=1),t}function g_(e,t){let n=Ve.reduce((s,a)=>s+t[a],0),r=Ve.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-Ve.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))||Ve.indexOf(a.section)-Ve.indexOf(c.section))){if(i===0)break;o[s.section]+=1,i-=1}return o}function ja(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function y_(e,t){let n=Wr(t(e)),r=g_(n,__(e)),o=Object.fromEntries(Ve.map(a=>[a,{bytes:r[a],estimated_tokens:_e(r[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:n,total_estimated_tokens:_e(n),sections:o,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=ja(e,i);for(let a=0;a<m_;a+=1){let c=Wr(t(s))-n;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:_e(c)},s=ja(e,i)}return s}import{encode as Kr}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]="8936e93f-25bf-58cc-ba91-37cc2677c5d2")}catch{}})();function Fa(e){let t=[...new Set(e.flatMap(i=>Object.keys(i)))],n=t.filter(i=>e.some(s=>{let a=s[i];return a!==null&&typeof a=="object"})),r=new Set(n),o=[];return{rows:e.map((i,s)=>Object.fromEntries(t.map(a=>{if(!Object.hasOwn(i,a))return o.push([s,a]),[a,null];let c=i[a];return[a,r.has(a)?JSON.stringify(c):c]}))),encoding:{json_columns:n,absent: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]="dc76b081-02dc-5b09-ab40-cd57c733b3ad")}catch{}})();var bk=["id","title","status","type","priority","parent","updated_at"],gn=["id","status","type","title"],wk={list:"brief","list-all":"full","list-draft":"full","list-open":"brief","list-in-progress":"brief","list-blocked":"brief","list-closed":"brief","list-canceled":"full"},h_=["tree_depth","tree_parent","tree_children","tree_title"];function vk(e=[]){return[...new Set([...kn,"body",...h_,...e])].flatMap(t=>[t,`item.${t}`]).sort()}var Ek=["brief","standard","deep"],b_=["body","linked","claim_state","children","schedule","blockers"],w_=["linked.files","linked.tests","linked.docs"],v_=["claim_state.claimed","claim_state.assignee","claim_state.last_claim","claim_state.last_release"],E_=["schedule.deadline","schedule.start_at","schedule.end_at","schedule.location","schedule.reminders","schedule.events"];function kk(e=[]){return[...[...new Set([...kn,...e,"notes_count","tests_count","collection_counts"])].flatMap(t=>[t,`item.${t}`]),...b_,...w_,...v_,...E_].sort()}var Ok=["id","title","status","type","priority","updated_at","score","matched_fields"],k_=["score","matched_fields","highlights"],Ua=["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 Sk(e=[]){let t=[...new Set(e)];return[...k_,...Ua,...Ua.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]="95103919-d686-5c3b-bd51-928f5b2314ef")}catch{}})();function Ge(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function O_(e){if(!Ge(e))return!1;let t=e.fields;return e.mode==="brief"&&Object.keys(e).length===2&&Array.isArray(t)&&(t.length===gn.length||t.length===gn.length+1&&t.at(-1)==="priority")&&gn.every((n,r)=>t[r]===n)}function S_(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 A_(e){return Ge(e)&&(e.status==="complete"||e.status==="unchecked")&&e.unreadable_item_count===0&&e.unreadable_directory_count===0}function C_(e){if(!Ge(e)||!Array.isArray(e.omitted_field_groups))return!1;let t=e.omitted_field_groups,n=t[0];return e.has_omissions===!0&&e.omitted_field_group_count===1&&Object.keys(e).length===3&&t.length===1&&Ge(n)&&Object.keys(n).length===2&&n.name==="full_item_fields"&&n.restore_with==="--full"}function za(e){if(!Ge(e)||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!O_(e.projection)||!A_(e.completeness)||!S_(e,e.items.length)||!C_(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,...l}=e,m=i.status==="complete"&&!n&&Object.keys(i).length===3,{unreadable_item_count:u,unreadable_directory_count:f,...p}=i;return{...l,...m?{}:{total:t,has_more:n,completeness:p},...n?{next_cursor:o}:{},...Ge(d)&&d.sort==="default"&&d.order==="asc"&&Object.keys(d).length===2?{}:{sorting:d},details:"--full"}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dd3b19cb-eda3-5ee9-a838-f0abaa5cc8ea")}catch{}})();var Bk=new Set(Object.values(y)),R_=new Map([["notes_count","notes"],["tests_count","tests"]]);var qa=!1;function j(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Hr(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function x_(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.SUCCESS)}function N_(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.GENERIC_FAILURE)}function Yr(e){if(e==="stdout"){x_();return}N_()}function Ba(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function D_(){qa||(qa=!0,process.stdout.on("error",e=>{if(Hr(e)){Yr("stdout");return}Ba(e)}),process.stderr.on("error",e=>{if(Hr(e)){Yr("stderr");return}Ba(e)}))}function P_(e,t){D_();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(n){if(Hr(n))return Yr(e),!1;throw n}}function $_(e){return P_("stderr",e)}function Va(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function M_(e){let t=Object.keys(e[0]);return t.length>0&&e.every(n=>Object.keys(n).length===t.length&&t.every(r=>{if(!Object.hasOwn(n,r))return!1;let o=n[r];return o===null||typeof o=="string"||typeof o=="number"||typeof o=="boolean"}))}function Xr(e,t){let n=" ".repeat(t);return e.split(`
|
|
17
17
|
`).map(r=>`${n}${r}`).join(`
|
|
18
|
-
`)}function
|
|
19
|
-
${
|
|
20
|
-
`)}return`${n}${
|
|
21
|
-
`}let r=
|
|
22
|
-
`:`${
|
|
23
|
-
`}function
|
|
18
|
+
`)}function L_(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 j_(e,t,n,r){let o=" ".repeat(n);if(!j(t)&&!Array.isArray(t))return`${o}${e}: ${Va(t)}`;if(Array.isArray(t)){if(t.length===0)return`${o}${e}: []`;let i=Xr(Kr({[e]:t}),n);if(r&&t.length>=2&&t.every(j)&&!M_(t)&&L_(t)){let s=Fa(t),a=Xr(Kr({[e]:s.rows,[`${e}_encoding`]:s.encoding}),n);if(Buffer.byteLength(a)<Buffer.byteLength(i))return a}return i}return j(t)&&Object.keys(t).length===0?`${o}${e}: {}`:`${o}${e}:
|
|
19
|
+
${Ga(t,n+1)}`}function F_(e,t,n){let r=e.map(o=>yn(o,t,n||t.preserveRowFacts&&j(o))).filter(o=>o!==void 0);return r.length>0||n?r:void 0}function yn(e,t={omitDuplicateCountAliases:!0,preserveRowFacts:!0},n=!1){if(e===null)return n?null:void 0;if(Array.isArray(e))return F_(e,t,n);if(j(e)){let r=[],o=Object.entries(e).filter(([i,s])=>{let a=R_.get(i);return!t.omitDuplicateCountAliases||a===void 0||!j(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=yn(s,t,n);a!==void 0&&r.push([i,a])}return r.length>0||n?Object.fromEntries(r):void 0}return e}function Ga(e,t){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":Xr(Kr(e),t);if(j(e)){let r=Object.entries(e);return r.length===0?"{}":r.map(([o,i])=>j_(o,i,t,!Object.hasOwn(e,`${o}_encoding`)&&!(o==="checks"&&j(e.verdict)&&e.verdict.authority==="ok"))).join(`
|
|
20
|
+
`)}return`${n}${Va(e)}`}var U_=new Set(["filters","now","projection","sorting"]);function z_(e){let t=yn(e,{omitDuplicateCountAliases:!1,preserveRowFacts:!1});if(!j(t)||!Array.isArray(t.items))return t??null;let n=Object.fromEntries(Object.entries(t).filter(([r])=>!U_.has(r)));return n.has_more!==!0&&delete n.next_cursor,n}function q_(e){return!j(e)||e.ok!==!0||!j(e.verdict)||e.verdict.authority!=="ok"||!Array.isArray(e.checks)?e:{...e,checks:e.checks.map(B_)}}function B_(e){if(!j(e)||e.ok!==!0||!j(e.details)||Object.keys(e.details).length!==0)return e;let{details:t,...n}=e;return n}function Wa(e,t,n=!1){if(t==="json"){let o=n?z_(e):e,i=j(e)&&j(e.projection)&&e.projection.mode==="brief"&&Array.isArray(e.items);return`${JSON.stringify(o,null,i?void 0:2)}
|
|
21
|
+
`}let r=yn(q_(za(e)),{omitDuplicateCountAliases:!0,preserveRowFacts:!0});return r===void 0?`{}
|
|
22
|
+
`:`${Ga(r,0)}
|
|
23
|
+
`}function Vk(e){let t=Is("error_format",{message:e}),n=t.handled&&typeof t.result=="string"?t.result:e;$_(n.endsWith(`
|
|
24
24
|
`)?n:`${n}
|
|
25
|
-
`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="13e57322-501d-5927-8254-f6196854d434")}catch{}})();var F_=8,U_=64,z_=5,q_=4,Ba=100;function Va(e,t,n){if(e!=="get"||!Yr(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=[...Yr(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 Jr(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*z_/q_),i=Math.ceil(o/Ba)*Ba;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 ht(e,t){let n=t===void 0?JSON.stringify(e):qa(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function Yr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Xr(e,t,n=!1){return typeof e=="string"?n||e.length<=240?e:(t.compacted=!0,`${Z(e,240)}\u2026`):Array.isArray(e)?e.map(r=>Xr(r,t,n)):Yr(e)?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,Xr(o,t,n||r==="focus_row_states")])):e}function le(e,t,n){let r=t.estimated_tokens;for(let o=0;o<F_;o+=1){t.estimated_tokens=r;let i=ht(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function B_(e,t){return lt(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 V_(e,t,n,r,o,i){for(let s=0;s<U_;s+=1){if(i?.(e),le(e,t,o),t.estimated_tokens<=n)return;let a=B_(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=en(e)),a.path==="items"&&(e.applied_limit=p),i?.(e),le(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 Ga(e,t,n,r=new Map,o,i,s=!1){let a={compacted:!1},c=Object.fromEntries(Object.entries(e).map(([d,l])=>[d,Xr(l,a,s&&d==="diff")]));return We(e,c),t.strings_compacted=a.compacted,c.read_output=t,V_(c,t,n,r,o,i),le(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 Wk(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 Qr=256,Zr=1e4,G_=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,Wa=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,W_=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),K_=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&G_.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=Qr,reason:`token_budget must be a safe integer of at least ${Qr}.`},{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<=Zr&&e.seen_item_ids.every(t=>typeof t=="string"&&Wa.test(t)),reason:`seen_item_ids must contain at most ${Zr} portable item identifiers.`}];function hn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function yn(e){throw new h(`--output-session ${e}`,y.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function bn(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{yn("must be a valid JSON object.")}hn(t)||yn("must be a JSON object.");let n=Object.keys(t).filter(i=>!W_.has(i));n.length>0&&yn(`contains unknown field "${n.sort()[0]}".`);let r=K_.find(i=>!i.valid(t));r!==void 0&&yn(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 Ka(e){if(hn(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:hn(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function H_(e){let t=new Set,n=0,r=ie(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(!hn(c))continue;if(typeof c.context_ref=="string"){n+=1;continue}let d=Ka(c);d!==void 0&&Wa.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:n}}function Ha(e,t){let n=new Set(t.seen_item_ids);return ut(e,r=>{let o=Ka(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function eo(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=H_(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,Zr-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<Qr,l.next_state.spent_tokens=l.spent_total_tokens},f=0,p=0;for(let _=0;_<8;_+=1){u(f);let g=ht(m,n);if(g===f)return m;p=Math.max(p,g),f=g}return u(p),m}function Ya(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 bt=Symbol.for("pm.readOutputInvocationProvenance");function Hk(e,t){return Reflect.set(e,bt,{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]="a829643f-ca94-51b0-a6ae-27583cd95b3d")}catch{}})();var Se=["include","amount","cost","encoding"],tc=["canonical","legacy","intent","default"],vt=Lt,u0=Object.freeze(Se.map(e=>vt[e])),f0=jt,nc={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],cost:["--token-budget"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded","--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:{}},rc=new Set(["--collapse","--fields","--section"]),to=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 no(e){return e.slice(2).replaceAll("-","_")}function Y_(e,t){let n=to[e];if(n!==void 0)return n;let r=t==="include"?rc.has(e)?"<csv>":no(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${vt[t]} ${r}.`}function oc(e){let t=nc[e]??{},n=Object.freeze(Object.fromEntries(Se.map(r=>[r,Object.freeze({dimension:r,canonical_option:vt[r],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[r]??[]).map(o=>Object.freeze({flag:o,semantics:to[o]===void 0?"replacement":"behavior_preserving",migration_hint:Y_(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:tc,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...sc(e).keys()])})}var X_=Object.freeze(Re.map(oc)),J_=new Map(X_.map(e=>[e.command,e]));function Fe(e,t={}){let n=Qe(e.trim().toLowerCase()),r=br(n);return r!==void 0?r.read_output===void 0?void 0:`extension:${r.command}`:Q_(n,t)}function Q_(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 Re.includes(r)?r:void 0}var Z_=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],eg={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 tg(e){return Z_.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var ng=[{keys:["outputInclude","output_include"],valid:e=>wt(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=>(bn(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 m0(e,t){let n=t.outputFormat??t.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new h("--output-format must be toon or json.",y.USAGE);if(!tg(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.`,y.USAGE);if((eg[r]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new h(`Universal output controls cannot be combined with a ${r} mutation.`,y.USAGE);for(let o of ng){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new h(o.message,y.USAGE)}}function ic(e){let t=Fe(e);return t?sc(t):new Map}function sc(e){return new Map((nc[e]?.include??[]).filter(t=>!rc.has(t)&&to[t]===void 0).map(t=>[no(t),ac(t)]))}function rg(e,t,n){let r=wt(t)??[],o=ic(e),i=[],s=[],a=n,c=a[bt],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("_","-")}`;oo(ro(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([...wt(n.fields)??[],...m])].join(","),d.add("fields")),(s.length>0||u)&&(a[bt]={canonical_include_modes:[...d],explicit_legacy_aliases:[...l],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function p0(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=rg(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 ac(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}function ro(e,t){let n=ac(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 oo(e){return e!==void 0&&e!==!1&&e!==null}function wt(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 og(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=ro(t,o.flag),s={value:i,flag:o.flag};if(oo(i)&&n(s))return s}}function Xa(e,t){let n=wt(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:wt(t.value)??[no(t.flag)]}}function Ja(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 Qa(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 Za(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 cc(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 ig(e,t,n,r){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||oo(ro(r,"--no-truncate"))&&!cc(n,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function sg(e,t){return Se.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[vt[n]]:[])}function dc(e,t){let n=Fe(e,t);if(!n)return;let r=J_.get(n)??oc(n),o=t[bt],i={include:b=>Xa(void 0,b),amount:b=>Ja(void 0,b),cost:b=>Qa(void 0,b),encoding:b=>Za(void 0,b)},s=Object.fromEntries(Se.map(b=>[b,og(r.dimensions[b],t,k=>i[b](k)!==void 0,k=>cc(o,b,k))])),a=Se.flatMap(b=>{let k=s[b];return k?[k.flag]:[]}),c=Se.flatMap(b=>{let k=s[b];return k?[r.dimensions[b].legacy_aliases.find(F=>F.flag===k.flag).migration_hint]:[]}),d=Za(t.outputFormat??t.output_format,s.encoding),l=Xa(t.outputInclude??t.output_include,s.include),m=Ja(t.outputLimit??t.output_limit,s.amount),u=Qa(t.outputBudget??t.output_budget,s.cost),f=ig(e,s,o,t),p=Zo(e,{generateFallback:!0}),_=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",g=u??(f?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:l,amount:m,cost:g,encoding:d,canonical_options_used:sg({include:l,amount:m,cost:g,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:tc}}function D(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var io=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"]),ag=["collection_counts","notes_count","tests_count"];function lc(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function cg(e){let t=D(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...ag.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!io.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 dg(e,t){let n=cg(e),r=t.filter(l=>!n.valid.includes(l));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,y.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:n.itemFields.includes(l)?[l]:[]).filter((l,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.",y.USAGE);let s=new Set(t.filter(l=>n.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>io.has(l)||s.has(l)));o?a.item=n.item:i.length>0&&(a.item=lc(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=[...D(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 ec(e){let t=0;return ut({...e},n=>(D(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function lg(e,t,n,r){if(ec(t)===0||ec(n)>0)return;let o=[...ic(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${r.join(", ")}. No selector matched any returned row field.${i}`,y.USAGE)}function ug(e,t,n){if(e==="get")return dg(t,n);let r=Zt(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=ut(s,d=>D(d)?lc(d,a):d);return lg(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||io.has(s)))}function fg(e,t){if(t==="unbounded")return e;let{result:n,truncated:r}=Bs(e,t);if(!r)return n;if(n.has_more=!0,n.truncated=!0,typeof n.count=="number"){let o=D(n.projection)?n.projection.row_key:void 0;n.count=typeof o=="string"&&Array.isArray(n[o])?n[o].length:en(n)}return n.applied_bound={kind:"output_limit",source:"explicit",value:t},n}function mg(e){return Se.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(vt[t]))}function uc(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function wn(e,t,n,r){let o=eo(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;le(o,n,r);let c=o;o=eo(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 qr(e,t){if(!D(e.read_output))return e;let n=uc(t),r=e.read_output,o=bn(t.outputSession??t.output_session);return o===void 0?(le(e,r,n),e):wn(e,o,r,n)}function pg(e,t){if(e!=="validate")return t;let n=D(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(l=>D(l)&&l.name==="diagnostic_rows"))return t;let r=[...new Set(lt(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=D(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 _g(e,t,n,r,o){let i={...e};if(t.include?.source==="canonical"&&(i=ug(t.command,i,t.include.value)),t.command==="assurance"&&(i=Ks(i)),ft(i,e),i=Hs(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)),D(i.projection)&&(i.projection={...i.projection,row_key:r.path}),D(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=vg(i,e,t.command,r,o);return t.amount?.source==="canonical"&&(i=fg(i,t.amount.value),a.cursorContinuesExistingPage&&_c(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),ft(i,s),{projected:n===void 0?i:Ha(i,n),continuationState:a}}function gg(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:Ya(t)}]].sort((n,r)=>n.tokens-r.tokens)[0]}function fc(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function mc(e,t){return D(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function pc(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!mc(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function yg(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...pc(r),precedence:e.precedence,...fc(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:wn(a,n,s,i);if(n===void 0&&le(c,s,i),n!==void 0&&s.estimated_tokens>r.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",y.USAGE);return c}function hg(e,t,n){return e.command==="context"&&e.cost?.source==="legacy"&&!mc(n,e.cost.value)||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 bg(e,t,n,r,o){if(t!==void 0||hg(e,o,n))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(ie(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"||ht(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 g=c.get(p);if(g>=_.rows)return[];let b=_.baseOffset+g;return[{path:p,cursor:Er({command:t.command,path:p,offset:b,total_rows:_.totalRows,fingerprint:_.fingerprint}),retained_rows:g,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=Jr({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 _c(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=Sr(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=gt(a.fingerprint,l,m,a.snapshot),!0)}function vg(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:tn(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 Eg(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=>D(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 lt(e))f.path.startsWith("diff.")&&u.set(f.path,Object.keys(f.value).length);return Ga(e,o,i.tokens,u,d,f=>{ft(f,l);let p=_c(f,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(wg(f,r,o,i,p,c,a.collectionsBeforeBudget),r.command==="history"&&D(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,wn(f,s,o,d))},r.command==="history"&&Array.isArray(e.diff))}function Ca(e,t,n){let r=dc(e,t);if(!r)return n;let o=uc(t),i=bn(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?_t(s):void 0,c=mg(r),d=pg(r.command,n);if(a===void 0&&bg(r,i,d,o,t))return d;let l=gg(r,i),m=_g(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,...pc(l,u),precedence:r.precedence,...fc(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:wn(u,i,f,o),le(u,f,o),l!==void 0&&f.estimated_tokens>l.tokens){let p=Va(r.command,t,u);p!==void 0&&(f.applied_depth="brief",f.degradation_reason="output_budget_reached",We(u,p),u=qr(p,t)),f.estimated_tokens>l.tokens&&(u=Eg(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?yg(r,c,i,l,f.estimated_tokens,o):u}function k_(e){return D(e)&&D(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function O_(e,t){let n=t.outputFormat??t.output_format;if(n==="json"||n==="toon")return n;let r=dc(e,t)?.encoding;return r?.value==="json"||r?.value==="toon"?r.value:void 0}export{It as a,qo as b,Fn as c,wl as d,vl as e,S as f,gc as g,lo as h,Og as i,Sg as j,uo as k,Ag as l,Cg as m,Ig as n,Tg as o,Rg as p,xg as q,Ng as r,Dg as s,Pg as t,$g as u,Mg as v,Lg as w,jg as x,yc as y,Fg as z,Ug as A,zg as B,qg as C,Bg as D,Vg as E,Gg as F,Di as G,_l as H,ph as I,Lo as J,jo as K,Xi as L,Ji as M,bc as N,wc as O,Sn as P,In as Q,Tn as R,Jg as S,Qg as T,Zg as U,Tc as V,mo as W,ey as X,qn as Y,Gn as Z,zh as _,ou as $,Bh as aa,Vh as ba,Gh as ca,ii as da,si as ea,Wh as fa,Kh as ga,Hh as ha,Yh as ia,go as ja,Lc as ka,ho as la,ko as ma,dy as na,Dn as oa,Yc as pa,ly as qa,dd as ra,ld as sa,uy as ta,fy as ua,Ey as va,ky as wa,Oy as xa,Co as ya,So as za,Sy as Aa,Ay as Ba,Cy as Ca,Pn as Da,Iy as Ea,fe as Fa,B as Ga,xy as Ha,Ny as Ia,Ld as Ja,To as Ka,$n as La,Ud as Ma,zd as Na,Pt as Oa,xo as Pa,Bd as Qa,Wd as Ra,jy as Sa,Fy as Ta,Xd as Ua,Jd as Va,Qd as Wa,Zd as Xa,Mn as Ya,zy as Za,el as _a,Qe as $a,$t as ab,qy as bb,By as cb,Vy as db,tl as eb,nl as fb,rl as gb,Yy as hb,Xy as ib,ol as jb,Mt as kb,Jy as lb,Qy as mb,il as nb,sl as ob,al as pb,Do as qb,Te as rb,cl as sb,Zy as tb,eh as ub,th as vb,nh as wb,rh as xb,oh as yb,ih as zb,Re as Ab,Ft as Bb,lh as Cb,qt as Db,Yn as Eb,Xn as Fb,Jn as Gb,Qn as Hb,Zn as Ib,er as Jb,rr as Kb,Ti as Lb,yh as Mb,nf as Nb,of as Ob,sf as Pb,pf as Qb,Pw as Rb,$w as Sb,Mw as Tb,Xs as Ub,zw as Vb,Df as Wb,El as Xb,Un as Yb,Sl as Zb,Al as _b,Kw as $b,zf as ac,Hw as bc,Yw as cc,Xw as dc,Jw as ec,Qw as fc,Zw as gc,ev as hc,ws as ic,qf as jc,tv as kc,nv as lc,vs as mc,rv as nc,Es as oc,ov as pc,iv as qc,sv as rc,Ht as sc,Oh as tc,Sh as uc,Ms as vc,pv as wc,_v as xc,gv as yc,Ls as zc,js as Ac,Av as Bc,Us as Cc,Jt as Dc,Tl as Ec,xh as Fc,Jo as Gc,Rl as Hc,Fl as Ic,zl as Jc,Qo as Kc,ql as Lc,Bl as Mc,Zo as Nc,_e as Oc,ei as Pc,Nh as Qc,Dh as Rc,Nv as Sc,ft as Tc,bt as Uc,Hk as Vc,Se as Wc,u0 as Xc,f0 as Yc,X_ as Zc,Fe as _c,m0 as $c,ic as ad,rg as bd,p0 as cd,dc as dd,qr as ed,Ca as fd,k_ as gd,O_ as hd,Ws as id,tn as jd,Er as kd,_t as ld,Kv as md,Hv as nd,gt as od,Sr as pd,Ar as qd,Yv as rd,Dm as sd,Xv as td,Jv as ud,nE as vd,Tr as wd,cE as xd,Bm as yd,dE as zd,Ue as Ad,lE as Bd,uE as Cd,Nr as Dd,Dr as Ed,Pr as Fd,TE as Gd,vp as Hd,an as Id,Cp as Jd,ya as Kd,Tp as Ld,Y as Md,T as Nd,zE as Od,un as Pd,Up as Qd,qE as Rd,BE as Sd,zp as Td,VE as Ud,GE as Vd,WE as Wd,Ia as Xd,Gp as Yd,ok as Zd,Kp as _d,Ra as $d,ik as ae,Na as be,Yp as ce,Zp as de,o_ as ee,f_ as fe,uk as ge,_n as he,fk as ie,mk as je,pk as ke,_k as le,gk as me,yk as ne,R_ as oe,qa as pe,Mk as qe,Jr as re,ht as se,Wk as te,Zr as ue,bn as ve,Ha as we,eo as xe,Ya as ye};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
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 V_=8,G_=64,W_=5,K_=4,Ka=100;function Ha(e,t,n){if(e!=="get"||!Jr(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=[...Jr(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 Zr(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*W_/K_),i=Math.ceil(o/Ka)*Ka;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):Wa(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function Jr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Qr(e,t,n=!1){return typeof e=="string"?n||e.length<=240?e:(t.compacted=!0,`${Z(e,240)}\u2026`):Array.isArray(e)?e.map(r=>Qr(r,t,n)):Jr(e)?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,Qr(o,t,n||r==="focus_row_states")])):e}function le(e,t,n){let r=t.estimated_tokens;for(let o=0;o<V_;o+=1){t.estimated_tokens=r;let i=bt(e,n);if(i===r)return;r=i}t.estimated_tokens=r}function H_(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 Y_(e,t,n,r,o,i){for(let s=0;s<G_;s+=1){if(i?.(e),le(e,t,o),t.estimated_tokens<=n)return;let a=H_(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=tn(e)),a.path==="items"&&(e.applied_limit=p),i?.(e),le(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 Ya(e,t,n,r=new Map,o,i,s=!1){let a={compacted:!1},c=Object.fromEntries(Object.entries(e).map(([d,l])=>[d,Qr(l,a,s&&d==="diff")]));return We(e,c),t.strings_compacted=a.compacted,c.read_output=t,Y_(c,t,n,r,o,i),le(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 e0(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 eo=256,to=1e4,X_=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,Xa=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,J_=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),Q_=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&X_.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=eo,reason:`token_budget must be a safe integer of at least ${eo}.`},{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<=to&&e.seen_item_ids.every(t=>typeof t=="string"&&Xa.test(t)),reason:`seen_item_ids must contain at most ${to} portable item identifiers.`}];function bn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function hn(e){throw new h(`--output-session ${e}`,y.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function wn(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{hn("must be a valid JSON object.")}bn(t)||hn("must be a JSON object.");let n=Object.keys(t).filter(i=>!J_.has(i));n.length>0&&hn(`contains unknown field "${n.sort()[0]}".`);let r=Q_.find(i=>!i.valid(t));r!==void 0&&hn(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 Ja(e){if(bn(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:bn(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function Z_(e){let t=new Set,n=0,r=ie(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(!bn(c))continue;if(typeof c.context_ref=="string"){n+=1;continue}let d=Ja(c);d!==void 0&&Xa.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:n}}function Qa(e,t){let n=new Set(t.seen_item_ids);return ft(e,r=>{let o=Ja(r);return o!==void 0&&n.has(o)?{id:o,context_ref:`session:${t.id}:${o}`}:r})}function no(e,t,n){let{deliveredIds:r,suppressedRepeatCount:o}=Z_(e),i=new Set(t.seen_item_ids),s=[...r].filter(_=>!i.has(_)).sort(),a=s.slice(0,to-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<eo,l.next_state.spent_tokens=l.spent_total_tokens},f=0,p=0;for(let _=0;_<8;_+=1){u(f);let g=bt(m,n);if(g===f)return m;p=Math.max(p,g),f=g}return u(p),m}function Za(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 n0(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]="a829643f-ca94-51b0-a6ae-27583cd95b3d")}catch{}})();var Se=["include","amount","cost","encoding"],ic=["canonical","legacy","intent","default"],Et=jt,b0=Object.freeze(Se.map(e=>Et[e])),w0=Ft,sc={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],cost:["--token-budget"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded","--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:{}},ac=new Set(["--collapse","--fields","--section"]),ro=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 oo(e){return e.slice(2).replaceAll("-","_")}function eg(e,t){let n=ro[e];if(n!==void 0)return n;let r=t==="include"?ac.has(e)?"<csv>":oo(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${Et[t]} ${r}.`}function cc(e){let t=sc[e]??{},n=Object.freeze(Object.fromEntries(Se.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:ro[o]===void 0?"replacement":"behavior_preserving",migration_hint:eg(o,r),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:ic,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix",projection_modes:Object.freeze([...lc(e).keys()])})}var tg=Object.freeze(Re.map(cc)),ng=new Map(tg.map(e=>[e.command,e]));function Fe(e,t={}){let n=Qe(e.trim().toLowerCase()),r=wr(n);return r!==void 0?r.read_output===void 0?void 0:`extension:${r.command}`:rg(n,t)}function rg(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 Re.includes(r)?r:void 0}var og=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],ig={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 sg(e){return og.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var ag=[{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=>(wn(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 v0(e,t){let n=t.outputFormat??t.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new h("--output-format must be toon or json.",y.USAGE);if(!sg(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.`,y.USAGE);if((ig[r]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new h(`Universal output controls cannot be combined with a ${r} mutation.`,y.USAGE);for(let o of ag){let i=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!o.valid(i))throw new h(o.message,y.USAGE)}}function dc(e){let t=Fe(e);return t?lc(t):new Map}function lc(e){return new Map((sc[e]?.include??[]).filter(t=>!ac.has(t)&&ro[t]===void 0).map(t=>[oo(t),uc(t)]))}function cg(e,t,n){let r=vt(t)??[],o=dc(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("_","-")}`;so(io(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 E0(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:r,modes:o}=cg(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 uc(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}function io(e,t){let n=uc(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 so(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 dg(e,t,n,r){for(let o of e.legacy_aliases){if(r(o.flag))continue;let i=io(t,o.flag),s={value:i,flag:o.flag};if(so(i)&&n(s))return s}}function ec(e,t){let n=vt(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:vt(t.value)??[oo(t.flag)]}}function tc(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 nc(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 rc(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 fc(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 lg(e,t,n,r){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||so(io(r,"--no-truncate"))&&!fc(n,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function ug(e,t){return Se.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[Et[n]]:[])}function mc(e,t){let n=Fe(e,t);if(!n)return;let r=ng.get(n)??cc(n),o=t[wt],i={include:b=>ec(void 0,b),amount:b=>tc(void 0,b),cost:b=>nc(void 0,b),encoding:b=>rc(void 0,b)},s=Object.fromEntries(Se.map(b=>[b,dg(r.dimensions[b],t,k=>i[b](k)!==void 0,k=>fc(o,b,k))])),a=Se.flatMap(b=>{let k=s[b];return k?[k.flag]:[]}),c=Se.flatMap(b=>{let k=s[b];return k?[r.dimensions[b].legacy_aliases.find(F=>F.flag===k.flag).migration_hint]:[]}),d=rc(t.outputFormat??t.output_format,s.encoding),l=ec(t.outputInclude??t.output_include,s.include),m=tc(t.outputLimit??t.output_limit,s.amount),u=nc(t.outputBudget??t.output_budget,s.cost),f=lg(e,s,o,t),p=ri(e,{generateFallback:!0}),_=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",g=u??(f?{source:"intent",value:"unbounded"}:{source:"default",value:p.default_max_estimated_tokens_by_format[_]});return{command:n,include:l,amount:m,cost:g,encoding:d,canonical_options_used:ug({include:l,amount:m,cost:g,encoding:d},o),legacy_aliases_used:a,migration_hints:c,precedence:ic}}function D(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var ao=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"]),fg=["collection_counts","notes_count","tests_count"];function pc(e,t){let n=new Set(t.map(r=>r.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function mg(e){let t=D(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...fg.filter(o=>Object.hasOwn(t,o))])].sort((o,i)=>o.localeCompare(i)),r=Object.keys(e).filter(o=>o!=="item"&&o!=="read_output"&&!ao.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=mg(e),r=t.filter(l=>!n.valid.includes(l));if(r.length>0)throw new h(`Unknown --output-include selector(s) for get: ${r.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,y.USAGE);let o=t.includes("item"),i=t.flatMap(l=>l.startsWith("item.")?[l.slice(5)]:n.itemFields.includes(l)?[l]:[]).filter((l,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.",y.USAGE);let s=new Set(t.filter(l=>n.sections.includes(l))),a=Object.fromEntries(Object.entries(e).filter(([l])=>ao.has(l)||s.has(l)));o?a.item=n.item:i.length>0&&(a.item=pc(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=[...D(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 oc(e){let t=0;return ft({...e},n=>(D(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function _g(e,t,n,r){if(oc(t)===0||oc(n)>0)return;let o=[...dc(e).keys()],i=o.length>0?` Declared ${e} projection modes: ${o.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${r.join(", ")}. No selector matched any returned row field.${i}`,y.USAGE)}function gg(e,t,n){if(e==="get")return pg(t,n);let r=en(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=>D(d)?pc(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)||ao.has(s)))}function yg(e,t){if(t==="unbounded")return e;let{result:n,truncated:r}=Ks(e,t);if(!r)return n;if(n.has_more=!0,n.truncated=!0,typeof n.count=="number"){let o=D(n.projection)?n.projection.row_key:void 0;n.count=typeof o=="string"&&Array.isArray(n[o])?n[o].length:tn(n)}return n.applied_bound={kind:"output_limit",source:"explicit",value:t},n}function hg(e){return Se.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(Et[t]))}function _c(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}function vn(e,t,n,r){let o=no(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;le(o,n,r);let c=o;o=no(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 Vr(e,t){if(!D(e.read_output))return e;let n=_c(t),r=e.read_output,o=wn(t.outputSession??t.output_session);return o===void 0?(le(e,r,n),e):vn(e,o,r,n)}function bg(e,t){if(e!=="validate")return t;let n=D(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(l=>D(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=D(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 wg(e,t,n,r,o){let i={...e};if(t.include?.source==="canonical"&&(i=gg(t.command,i,t.include.value)),t.command==="assurance"&&(i=Js(i)),mt(i,e),i=Qs(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)),D(i.projection)&&(i.projection={...i.projection,row_key:r.path}),D(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=Ag(i,e,t.command,r,o);return t.amount?.source==="canonical"&&(i=yg(i,t.amount.value),a.cursorContinuesExistingPage&&bc(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),mt(i,s),{projected:n===void 0?i:Qa(i,n),continuationState:a}}function vg(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:Za(t)}]].sort((n,r)=>n.tokens-r.tokens)[0]}function gc(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function yc(e,t){return D(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function hc(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!yc(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function Eg(e,t,n,r,o,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...hc(r),precedence:e.precedence,...gc(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:vn(a,n,s,i);if(n===void 0&&le(c,s,i),n!==void 0&&s.estimated_tokens>r.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",y.USAGE);return c}function kg(e,t,n){return e.command==="context"&&e.cost?.source==="legacy"&&!yc(n,e.cost.value)||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 Og(e,t,n,r,o){if(t!==void 0||kg(e,o,n))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(ie(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 Sg(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 g=c.get(p);if(g>=_.rows)return[];let b=_.baseOffset+g;return[{path:p,cursor:Or({command:t.command,path:p,offset:b,total_rows:_.totalRows,fingerprint:_.fingerprint}),retained_rows:g,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=Zr({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 bc(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=Cr(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 Ag(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:nn(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 Cg(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=>D(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 Ya(e,o,i.tokens,u,d,f=>{mt(f,l);let p=bc(f,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(Sg(f,r,o,i,p,c,a.collectionsBeforeBudget),r.command==="history"&&D(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,vn(f,s,o,d))},r.command==="history"&&Array.isArray(e.diff))}function xa(e,t,n){let r=mc(e,t);if(!r)return n;let o=_c(t),i=wn(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?gt(s):void 0,c=hg(r),d=bg(r.command,n);if(a===void 0&&Og(r,i,d,o,t))return d;let l=vg(r,i),m=wg(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,...hc(l,u),precedence:r.precedence,...gc(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:vn(u,i,f,o),le(u,f,o),l!==void 0&&f.estimated_tokens>l.tokens){let p=Ha(r.command,t,u);p!==void 0&&(f.applied_depth="brief",f.degradation_reason="output_budget_reached",We(u,p),u=Vr(p,t)),f.estimated_tokens>l.tokens&&(u=Cg(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?Eg(r,c,i,l,f.estimated_tokens,o):u}function I_(e){return D(e)&&D(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function T_(e,t){let n=t.outputFormat??t.output_format;if(n==="json"||n==="toon")return n;let r=mc(e,t)?.encoding;return r?.value==="json"||r?.value==="toon"?r.value:void 0}export{Tt as a,Wo as b,zn as c,kl as d,Ol as e,S as f,wc as g,fo as h,Tg as i,Rg as j,mo as k,xg as l,Ng as m,Dg as n,Pg as o,$g as p,Mg as q,Lg as r,jg as s,Fg as t,Ug as u,zg as v,qg as w,Bg as x,vc as y,Vg as z,Gg as A,Wg as B,Kg as C,Hg as D,Yg as E,Xg as F,Li as G,hl as H,yh as I,zo as J,qo as K,es as L,ts as M,kc as N,Oc as O,An as P,Tn as Q,Rn as R,ny as S,ry as T,oy as U,Dc as V,_o as W,iy as X,et as Y,Wn as Z,Vh as _,au as $,Wh as aa,Kh as ba,Hh as ca,di as da,li as ea,Yh as fa,Xh as ga,Jh as ha,Qh as ia,ho as ja,zc as ka,wo as la,So as ma,py as na,Pn as oa,Zc as pa,_y as qa,md as ra,pd as sa,gy as ta,yy as ua,Cy as va,To as wa,Ro as xa,xo as ya,Co as za,Iy as Aa,Ty as Ba,Ry as Ca,Mn as Da,xy as Ea,fe as Fa,B as Ga,Py as Ha,$y as Ia,Ud as Ja,Do as Ka,Ln as La,Bd as Ma,Vd as Na,$t as Oa,$o as Pa,Wd as Qa,Yd as Ra,zy as Sa,qy as Ta,Zd as Ua,el as Va,tl as Wa,nl as Xa,jn as Ya,Vy as Za,rl as _a,Qe as $a,Mt as ab,Gy as bb,Wy as cb,Ky as db,ol as eb,il as fb,sl as gb,Qy as hb,Zy as ib,al as jb,Lt as kb,eh as lb,th as mb,cl as nb,dl as ob,ll as pb,Lo as qb,Te as rb,ul as sb,nh as tb,rh as ub,oh as vb,ih as wb,sh as xb,ah as yb,ch as zb,Re as Ab,Ut as Bb,mh as Cb,Bt as Db,Xn as Eb,Jn as Fb,Qn as Gb,Zn as Hb,er as Ib,tr as Jb,or as Kb,Di as Lb,wh as Mb,sf as Nb,cf as Ob,df as Pb,yf as Qb,Lw as Rb,jw as Sb,Fw as Tb,ea as Ub,Vw as Vb,Mf as Wb,Sl as Xb,qn as Yb,Il as Zb,Tl as _b,Xw as $b,Vf as ac,Jw as bc,Qw as cc,Zw as dc,ev as ec,tv as fc,nv as gc,rv as hc,Os as ic,Gf as jc,ov as kc,iv as lc,Ss as mc,sv as nc,As as oc,av as pc,cv as qc,dv as rc,Yt as sc,Ch as tc,Ih as uc,Us as vc,yv as wc,hv as xc,bv as yc,zs as zc,qs as Ac,Tv as Bc,Vs as Cc,Qt as Dc,Lv as Ec,jv as Fc,Nl as Gc,Ph as Hc,ti as Ic,Dl as Jc,ql as Kc,Vl as Lc,ni as Mc,Gl as Nc,Wl as Oc,ri as Pc,_e as Qc,oi as Rc,$h as Sc,Mh as Tc,Uv as Uc,mt as Vc,wt as Wc,n0 as Xc,Se as Yc,b0 as Zc,w0 as _c,tg as $c,Fe as ad,v0 as bd,dc as cd,cg as dd,E0 as ed,mc as fd,Vr as gd,xa as hd,I_ as id,T_ as jd,Xs as kd,nn as ld,Or as md,gt as nd,tE as od,nE as pd,yt as qd,Cr as rd,Ir as sd,rE as td,jm as ud,oE as vd,iE as wd,lE as xd,xr as yd,gE as zd,Hm as Ad,yE as Bd,Ue as Cd,hE as Dd,bE as Ed,Pr as Fd,$r as Gd,Mr as Hd,LE as Id,Ap as Jd,cn as Kd,Np as Ld,va as Md,Pp as Nd,Y as Od,T as Pd,YE as Qd,fn as Rd,Gp as Sd,XE as Td,JE as Ud,Wp as Vd,QE as Wd,ZE as Xd,ek as Yd,Na as Zd,Xp as _d,fk as $d,Qp as ae,Pa as be,mk as ce,Ma as de,e_ as ee,o_ as fe,d_ as ge,y_ as he,bk as ie,gn as je,wk as ke,vk as le,Ek as me,kk as ne,Ok as oe,Sk as pe,$_ as qe,Wa as re,Vk as se,Zr as te,bt as ue,e0 as ve,to as we,wn as xe,Qa as ye,no as ze,Za as Ae};
|
|
26
|
+
//# sourceMappingURL=chunk-6L4KKRK7.js.map
|