@unbrained/pm-cli 2026.10.17 → 2026.10.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +25 -0
  3. package/dist/cli/register-list-query.js +2 -2
  4. package/dist/cli-bundle/bundle-manifest.json +1 -1
  5. package/dist/cli-bundle/chunks/{chunk-3QKI3XNX.js → chunk-4GA4MUTE.js} +2 -2
  6. package/dist/cli-bundle/chunks/{chunk-X2ONXFBP.js → chunk-4V6ONLI6.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-B5QVGCZX.js → chunk-6VZKYJW7.js} +2 -2
  8. package/dist/cli-bundle/chunks/chunk-7PATQWTH.js +20 -0
  9. package/dist/cli-bundle/chunks/{chunk-W3KZ22DW.js → chunk-7WIEAGDS.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-EA2CG7UM.js → chunk-AETP4JEM.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-6ZDKKOKM.js → chunk-FIJOSX2C.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-VMCSTFSO.js → chunk-LUKVNL72.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-J4LPQCET.js → chunk-OJ77ZQN3.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-O4YBC3OM.js → chunk-PYRREEUB.js} +30 -30
  15. package/dist/cli-bundle/chunks/chunk-RHQJ6VWC.js +237 -0
  16. package/dist/cli-bundle/chunks/{chunk-OZCSXX4D.js → chunk-RNABUEFB.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-HY7FQ7QX.js → chunk-TO6CIV4C.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-JS3B2M4D.js → chunk-ZZED447K.js} +2 -2
  19. package/dist/cli-bundle/chunks/{register-list-query-RU3QZSAQ.js → register-list-query-PUCVYYBD.js} +7 -7
  20. package/dist/cli-bundle/chunks/{register-mutation-EQYMT32A.js → register-mutation-GGGVBXD5.js} +2 -2
  21. package/dist/cli-bundle/chunks/{register-operations-VXBGE4XI.js → register-operations-NRZ6Q4QE.js} +2 -2
  22. package/dist/cli-bundle/chunks/{register-setup-UUDEGFRO.js → register-setup-MV3P3YSF.js} +2 -2
  23. package/dist/cli-bundle/focused-chunks/{chunk-LDKX4KYJ.js → chunk-2MPQUMTF.js} +2 -2
  24. package/dist/cli-bundle/focused-chunks/{chunk-MBQF6HT6.js → chunk-5UKCSZWT.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-FTUZ3JF2.js → chunk-A4ZHHTEX.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/{chunk-JXR6UKFM.js → chunk-B4YLP5ZB.js} +2 -2
  27. package/dist/cli-bundle/focused-chunks/{chunk-NZO7GOXD.js → chunk-BFEMT5U3.js} +16 -16
  28. package/dist/cli-bundle/focused-chunks/{chunk-QOSVJDOO.js → chunk-FW7CSSKL.js} +61 -61
  29. package/dist/cli-bundle/focused-chunks/{chunk-AH6NX6GM.js → chunk-HYPRPSYD.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/{chunk-RBLSY6ML.js → chunk-IRVL4UXR.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/{chunk-RHTH5ILM.js → chunk-L55KQ2KT.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/{chunk-PYC7BF6Z.js → chunk-MASIOFPG.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-RJ3EIHDU.js +26 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-SEL4Z2OO.js +167 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-2IOHHNRT.js → chunk-TB7F4FCR.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-UNTQE37U.js → chunk-TZUIBG3P.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-E33QA7PK.js → chunk-Z7YIFCNE.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-SIGIGZCG.js → chunk-ZDBS2DCT.js} +2 -2
  39. package/dist/cli-bundle/main.js +2 -2
  40. package/dist/cli-bundle/sdk-authoring.js +1 -1
  41. package/dist/cli-bundle/sdk-contracts.js +1 -1
  42. package/dist/cli-bundle/sdk-core.js +16 -16
  43. package/dist/cli-bundle/sdk-governance.js +1 -1
  44. package/dist/cli-bundle/sdk-graph.js +1 -1
  45. package/dist/cli-bundle/sdk-merge.js +50 -49
  46. package/dist/cli-bundle/sdk-query.js +1 -1
  47. package/dist/cli-bundle/sdk-runtime.js +1 -1
  48. package/dist/cli-bundle/sdk-testing.js +1 -1
  49. package/dist/cli-bundle/sdk.js +1 -1
  50. package/dist/core/history/event-index.d.ts +8 -1
  51. package/dist/core/history/event-index.js +19 -18
  52. package/dist/core/item/item-format.js +1 -1
  53. package/dist/core/lock/lock.d.ts +8 -1
  54. package/dist/core/lock/lock.js +3 -3
  55. package/dist/core/output/output.js +2 -2
  56. package/dist/core/store/paths.js +1 -1
  57. package/dist/core/telemetry/policy.d.ts +2 -0
  58. package/dist/core/telemetry/policy.js +1 -1
  59. package/dist/core/telemetry/runtime.d.ts +5 -3
  60. package/dist/core/telemetry/runtime.js +3 -3
  61. package/dist/sdk/governance/health/projection.d.ts +37 -0
  62. package/dist/sdk/governance/health/projection.js +2 -0
  63. package/dist/sdk/governance/health.d.ts +7 -18
  64. package/dist/sdk/governance/health.js +2 -2
  65. package/dist/sdk/mutation-events.js +1 -1
  66. package/dist/sdk/public-surface.json +1 -1
  67. package/dist/sdk/query/list.d.ts +2 -0
  68. package/dist/sdk/query/list.js +1 -1
  69. package/dist/types.d.ts +2 -2
  70. package/dist/types.js +1 -1
  71. package/docs/COMMANDS.md +26 -0
  72. package/docs/CONFIGURATION.md +22 -1
  73. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +22 -3
  74. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +10 -0
  75. package/docs/RELEASING.md +8 -1
  76. package/docs/SDK_CONTEXT_COORDINATION.md +71 -7
  77. package/docs/SDK_STORAGE_LIFECYCLE.md +24 -2
  78. package/docs/TESTING.md +8 -0
  79. package/docs/examples/ci/github-actions-pm-extension-gate.yml +1 -1
  80. package/docs/examples/ci/gitlab-ci-pm-extension-gate.yml +1 -1
  81. package/docs/examples/ci/jenkins-pm-extension-gate.Jenkinsfile +1 -1
  82. package/marketplace.json +1 -1
  83. package/node_modules/@opentelemetry/core/package.json +2 -1
  84. package/node_modules/@opentelemetry/instrumentation/package.json +2 -1
  85. package/node_modules/@opentelemetry/resources/package.json +2 -1
  86. package/node_modules/@opentelemetry/sdk-trace/package.json +2 -1
  87. package/node_modules/@opentelemetry/sdk-trace-base/package.json +2 -1
  88. package/node_modules/@sentry/core/build/cjs/client.js +5 -4
  89. package/node_modules/@sentry/core/build/cjs/tracing/ai/gen-ai-attributes.js +0 -4
  90. package/node_modules/@sentry/core/build/cjs/tracing/ai/utils.js +33 -23
  91. package/node_modules/@sentry/core/build/cjs/tracing/anthropic-ai/index.js +7 -6
  92. package/node_modules/@sentry/core/build/cjs/tracing/anthropic-ai/streaming.js +3 -1
  93. package/node_modules/@sentry/core/build/cjs/tracing/google-genai/index.js +13 -14
  94. package/node_modules/@sentry/core/build/cjs/tracing/google-genai/streaming.js +6 -1
  95. package/node_modules/@sentry/core/build/cjs/tracing/langchain/utils.js +71 -21
  96. package/node_modules/@sentry/core/build/cjs/tracing/langgraph/utils.js +23 -33
  97. package/node_modules/@sentry/core/build/cjs/tracing/openai/streaming.js +6 -0
  98. package/node_modules/@sentry/core/build/cjs/tracing/openai/utils.js +11 -0
  99. package/node_modules/@sentry/core/build/cjs/tracing/workers-ai/utils.js +1 -1
  100. package/node_modules/@sentry/core/build/cjs/utils/eventUtils.js +4 -0
  101. package/node_modules/@sentry/core/build/cjs/utils/prepareEvent.js +2 -2
  102. package/node_modules/@sentry/core/build/cjs/utils/version.js +1 -1
  103. package/node_modules/@sentry/core/build/esm/client.js +6 -5
  104. package/node_modules/@sentry/core/build/esm/package.json +1 -1
  105. package/node_modules/@sentry/core/build/esm/tracing/ai/gen-ai-attributes.js +1 -3
  106. package/node_modules/@sentry/core/build/esm/tracing/ai/utils.js +34 -24
  107. package/node_modules/@sentry/core/build/esm/tracing/anthropic-ai/index.js +8 -7
  108. package/node_modules/@sentry/core/build/esm/tracing/anthropic-ai/streaming.js +3 -1
  109. package/node_modules/@sentry/core/build/esm/tracing/google-genai/index.js +15 -16
  110. package/node_modules/@sentry/core/build/esm/tracing/google-genai/streaming.js +6 -1
  111. package/node_modules/@sentry/core/build/esm/tracing/langchain/utils.js +73 -24
  112. package/node_modules/@sentry/core/build/esm/tracing/langgraph/utils.js +24 -34
  113. package/node_modules/@sentry/core/build/esm/tracing/openai/streaming.js +6 -0
  114. package/node_modules/@sentry/core/build/esm/tracing/openai/utils.js +11 -0
  115. package/node_modules/@sentry/core/build/esm/tracing/workers-ai/utils.js +2 -2
  116. package/node_modules/@sentry/core/build/esm/utils/eventUtils.js +4 -1
  117. package/node_modules/@sentry/core/build/esm/utils/prepareEvent.js +2 -2
  118. package/node_modules/@sentry/core/build/esm/utils/version.js +1 -1
  119. package/node_modules/@sentry/core/build/types/tracing/ai/utils.d.ts +3 -7
  120. package/node_modules/@sentry/core/build/types/tracing/anthropic-ai/types.d.ts +2 -2
  121. package/node_modules/@sentry/core/build/types/tracing/langchain/types.d.ts +15 -0
  122. package/node_modules/@sentry/core/build/types/tracing/langchain/utils.d.ts +1 -0
  123. package/node_modules/@sentry/core/build/types/tracing/langgraph/utils.d.ts +2 -0
  124. package/node_modules/@sentry/core/build/types/tracing/openai/types.d.ts +2 -0
  125. package/node_modules/@sentry/core/build/types/utils/eventUtils.d.ts +2 -1
  126. package/node_modules/@sentry/core/build/types-ts3.8/tracing/ai/utils.d.ts +3 -7
  127. package/node_modules/@sentry/core/build/types-ts3.8/tracing/anthropic-ai/types.d.ts +2 -2
  128. package/node_modules/@sentry/core/build/types-ts3.8/tracing/langchain/types.d.ts +15 -0
  129. package/node_modules/@sentry/core/build/types-ts3.8/tracing/langchain/utils.d.ts +1 -0
  130. package/node_modules/@sentry/core/build/types-ts3.8/tracing/langgraph/utils.d.ts +2 -0
  131. package/node_modules/@sentry/core/build/types-ts3.8/tracing/openai/types.d.ts +2 -0
  132. package/node_modules/@sentry/core/build/types-ts3.8/utils/eventUtils.d.ts +2 -1
  133. package/node_modules/@sentry/core/package.json +1 -1
  134. package/node_modules/@sentry/node/build/esm/package.json +1 -1
  135. package/node_modules/@sentry/node/package.json +5 -5
  136. package/node_modules/@sentry/node-core/build/cjs/integrations/anr/index.js +1 -1
  137. package/node_modules/@sentry/node-core/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  138. package/node_modules/@sentry/node-core/build/esm/integrations/anr/index.js +1 -1
  139. package/node_modules/@sentry/node-core/build/esm/integrations/anr/worker-script.js +2 -2
  140. package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  141. package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/worker-script.js +1 -1
  142. package/node_modules/@sentry/node-core/build/esm/package.json +1 -1
  143. package/node_modules/@sentry/node-core/package.json +10 -4
  144. package/node_modules/@sentry/opentelemetry/build/esm/package.json +1 -1
  145. package/node_modules/@sentry/opentelemetry/package.json +5 -2
  146. package/node_modules/@sentry/server-utils/build/THIRD-PARTY-LICENSES.txt +55 -55
  147. package/node_modules/@sentry/server-utils/build/esm/package.json +1 -1
  148. package/node_modules/@sentry/server-utils/package.json +2 -2
  149. package/node_modules/@toon-format/toon/README.md +10 -41
  150. package/node_modules/@toon-format/toon/dist/index.d.mts +12 -36
  151. package/node_modules/@toon-format/toon/dist/index.mjs +134 -202
  152. package/node_modules/@toon-format/toon/package.json +2 -2
  153. package/node_modules/debug/package.json +3 -0
  154. package/node_modules/fdir/package.json +3 -0
  155. package/node_modules/has-flag/index.d.ts +39 -0
  156. package/node_modules/has-flag/index.js +8 -0
  157. package/node_modules/has-flag/license +9 -0
  158. package/node_modules/has-flag/package.json +46 -0
  159. package/node_modules/has-flag/readme.md +89 -0
  160. package/node_modules/supports-color/browser.js +5 -0
  161. package/node_modules/supports-color/index.js +135 -0
  162. package/node_modules/supports-color/license +9 -0
  163. package/node_modules/supports-color/package.json +53 -0
  164. package/node_modules/supports-color/readme.md +76 -0
  165. package/package.json +4 -4
  166. package/packages/pm-beads/package.json +1 -1
  167. package/packages/pm-calendar/package.json +1 -1
  168. package/packages/pm-command-kit/package.json +1 -1
  169. package/packages/pm-digital-twin/package.json +1 -1
  170. package/packages/pm-governance-audit/package.json +1 -1
  171. package/packages/pm-guide-shell/package.json +1 -1
  172. package/packages/pm-kanban/package.json +1 -1
  173. package/packages/pm-lifecycle-hooks/package.json +1 -1
  174. package/packages/pm-linked-test-adapters/package.json +1 -1
  175. package/packages/pm-search-advanced/package.json +1 -1
  176. package/packages/pm-templates/package.json +1 -1
  177. package/packages/pm-todos/package.json +1 -1
  178. package/packages/pm-vcs/package.json +1 -1
  179. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  180. package/plugins/pm-claude/package.json +1 -1
  181. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  182. package/plugins/pm-codex/package.json +1 -1
  183. package/plugins/pm-codex/plugin.json +1 -1
  184. package/runtime-dependencies.json +1 -1
  185. package/dist/cli-bundle/chunks/chunk-4PNPDT2N.js +0 -236
  186. package/dist/cli-bundle/chunks/chunk-X53HM753.js +0 -20
  187. package/dist/cli-bundle/focused-chunks/chunk-5JEFDEL3.js +0 -166
  188. package/dist/cli-bundle/focused-chunks/chunk-TRFVAWF2.js +0 -26
@@ -1,2 +1,2 @@
1
- import{$ as bo,Aa as Do,B as p,Ba as vo,C as Ge,Ca as Fo,D as He,Da as So,E as Je,Ea as Mo,F as Ke,Fa as Ro,G as Qe,Ga as Ao,H as Ye,Ha as Po,I as Ze,Ia as Bo,J as $e,Ja as Oo,K as eo,Ka as Uo,L as oo,La as Wo,M as to,Ma as jo,N as ro,Na as Lo,O as no,Oa as No,P as fo,Pa as Vo,Q as po,Qa as zo,R as ao,Ra as Xo,S as mo,Sa as qo,T as so,Ta as Go,U as io,Ua as Ho,V as xo,Va as Jo,W as lo,Wa as Ko,X as uo,Xa as k,Y as co,Ya as E,Z as yo,Za as D,_ as go,aa as Co,ba as Io,ca as a,da as m,e as Be,ea as d,f as Oe,fa as s,g as Ue,ga as i,h as We,ha as x,i as je,ia as l,j as Le,ja as u,k as Ne,ka as c,la as y,ma as g,na as b,oa as C,pa as I,qa as w,ra as T,s as Ve,sa as h,t as ze,ta as _,u as Xe,ua as wo,v as qe,va as To,wa as ho,xa as _o,ya as ko,za as Eo}from"./focused-chunks/chunk-FTUZ3JF2.js";import{Oa as Ce,Pa as Ie,Q as te,Qa as we,Ra as Te,Sa as he,Ta as _e,Ua as ke,bb as Ee,cb as De,da as n,db as ve,eb as Fe,fb as Se,gb as Me,hb as Re,ib as Ae,jb as Pe,rb as f}from"./focused-chunks/chunk-NZO7GOXD.js";import"./focused-chunks/chunk-SIGIGZCG.js";import{a as J,b as K,c as Q,d as Y,e as Z,f as $}from"./focused-chunks/chunk-UNTQE37U.js";import"./focused-chunks/chunk-MBQF6HT6.js";import{Ab as me,Bb as de,Ga as oe,Qb as se,Rb as ie,Sb as xe,Tb as le,Ub as ue,Vb as ce,Wb as ye,Xb as ge,Yb as be,ca as ee,rb as r,ub as re,vb as ne,wb as fe,xb as pe,zb as ae}from"./focused-chunks/chunk-5JEFDEL3.js";import"./focused-chunks/chunk-AH6NX6GM.js";import"./focused-chunks/chunk-YLVHHWHN.js";import{Sd as v,Td as F,Ud as S,Vd as M,Wd as R,Xd as A,Yd as P,Zd as B,_d as O,ke as U,le as W,me as j,ne as L,oe as N,pe as V,qe as z,re as X,se as q,te as G,ue as H}from"./focused-chunks/chunk-TRFVAWF2.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="d45a8203-4501-5797-a6cc-a2e7844adec9")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="d007edcb-46f0-5546-b804-27d86afe23e7")}catch{}})();export{ie as ACTIONABILITY_ORDERING_KINDS,K as BRIEF_LIST_FIELDS,Ze as CONTEXT_EVALUATION_METRIC_NAMES,a as CONTEXT_OUTPUT_VALUES,ro as CONTEXT_PACKING_PROFILES,Je as CONTEXT_RELEVANCE_SERVICE,Ge as CONTEXT_RELEVANCE_SIGNAL_NAMES,po as CONTEXT_SIGNAL_SET_VERSION,fo as CONTEXT_SIGNAL_STORE_FORMAT_VERSION,ao as CONTEXT_SIGNAL_STORE_WARNING_DETAILS,U as CONTEXT_USAGE_LIMITS,xo as ContextSignalStore,W as ContextUsageValidationError,So as DEFAULT_CHILD_SAMPLE_LIMIT,J as DEFAULT_COMPACT_LIST_FIELDS,pe as DEFAULT_DERIVED_INDEX_MINIMUM_ITEMS,uo as DEFAULT_WORKSPACE_MEMORY_MINIMUM_ITEMS,k as EVAL_METRIC_NAMES,Z as GET_DEPTH_VALUES,io as JsonFileContextSignalStoreAdapter,Q as LIST_COMMAND_DEFAULT_PROJECTIONS,ve as LIST_SORT_FIELDS,Fe as LIST_SORT_ORDER_VALUES,Fo as MAX_CHILD_PROJECTION_ITEMS,wo as NEXT_OUTPUT_VALUES,Be as PM_COMPLETE_LIST_FINDING_CODES,Oe as PmCompleteListValidationError,O as QUERY_CURSOR_CONTRACT,Pe as _testOnly,vo as _testOnlyAggregateCommand,Ao as _testOnlyGetCommand,ho as _testOnlyNextCommand,Jo as _testOnlySearchCommand,ae as acquireItemMetadataDerivedIndexLock,f as analyzeDuplicateItems,h as applyContextTagProjection,Se as applyFilterValueEcho,Le as assertCompleteListResult,j as attachContextUsageServingReceipt,C as buildChildrenByParent,Vo as buildCompactSearchFilterSummary,Me as buildContentFilterEcho,so as buildContextSignalSnapshot,Re as buildGovernanceMissingFilterEcho,Mo as buildItemChildrenRollup,He as buildItemContextRelevanceCandidates,zo as buildVerboseSearchFilters,co as buildWorkspaceMemorySnapshot,je as certifyCompleteListResult,qo as classifyImplicitSemanticFallbackReason,xe as collectBlockedByIds,ue as collectBlockedByIdsFromCorpus,N as collectContextUsageDeliveredItemIds,ye as collectDependencyBlockedIds,Xo as collectErrorCauseCodes,u as collectSubtreeIds,c as compareCriticalItems,be as computeActionabilityReport,Ue as createCompleteListOptions,F as createQueryFingerprint,Lo as createSearchCursorFingerprint,A as decodeQueryCursor,M as decodeQueryCursorEnvelope,R as decodeQueryCursorState,Ke as defaultScoreContextCandidates,S as encodeQueryCursor,$e as evaluateContextRanking,D as evaluateMetricFloors,n as executeEmbeddingBatchesWithRetry,V as finalizeContextUsageDelivery,Ho as formatVectorIndexRecoveryWarnings,le as indexBlockedByIds,We as inspectCompleteListResult,$ as listGetProjectionFields,Y as listListProjectionFields,r as measureItemMetadataReadWork,w as mergeSortedWarnings,no as packContextCandidates,y as packRankedContextItems,B as paginateQueryRows,x as parseContextDepth,m as parseContextFocusFields,l as parseContextSections,mo as parseContextSignalSnapshot,E as parseEvalMetricFloors,Ce as parseIntegerLimit,te as parseLimit,Te as parseMultiValueFilter,Ie as parsePriority,ke as parsePriorityFilterSet,he as parseStringFilterSet,we as parseType,_e as parseTypeFilterSet,_o as partitionDecisionEntries,d as projectContextFocusRows,L as propagateContextUsageServingReceipt,re as queryItemMetadataIndex,ne as queryLinkedFileMetadataIndex,fe as querySimilarItemMetadataIndex,H as readContextUsageAffinity,ee as readHistoryEntries,me as readItemMetadataDerivedIndexState,lo as readWorkspaceContextSignals,yo as readWorkspaceMemory,X as recordContextUsageDelivery,z as recordContextUsageServing,q as recordContextUsageTouch,G as recordContextUsageTouches,de as refreshItemMetadataDerivedIndex,ze as renderCalendarMarkdown,Xe as renderCalendarToon,T as renderContextMarkdown,Eo as renderNextMarkdown,Ve as resolveCalendarOutputFormat,De as resolveContentFieldFilters,s as resolveContextOutputFormat,i as resolveContextTokenBudget,Oo as resolveEffectiveSearchMode,Wo as resolveHybridSemanticWeight,ce as resolveItemBlockers,se as resolveItemExecutionRole,Ee as resolveMissingMetadataFilters,To as resolveNextOutputFormat,P as resolveQueryCursorStart,Bo as resolveSearchMaxResults,No as resolveSearchPage,Uo as resolveSearchScoreThreshold,jo as resolveSearchTuning,Go as resolveVectorIndexRecovery,p as runActivity,Do as runAggregate,qe as runCalendar,_ as runContext,to as runContextEvaluationCorpus,eo as runContextEvaluationScenario,Ne as runDuplicates,Ro as runGet,Po as runHistory,Ae as runList,ko as runNext,Ko as runSearch,Qe as scoreContextCandidates,Ye as scoreContextCandidatesWithActiveExtensions,Co as searchWorkspaceMemory,Io as searchWorkspaceMemoryReadResult,ge as selectActionableEntries,v as selectCursorSemanticOptions,bo as selectWorkspaceMemory,go as selectWorkspaceMemoryRollups,oo as summarizeContextEvaluationReports,I as toContextFocusItem,g as toContextPackingSummary,b as toContextRankingSummary,oe as verifyHistoryChain};
1
+ import{$ as bo,Aa as Do,B as p,Ba as vo,C as Ge,Ca as Fo,D as He,Da as So,E as Je,Ea as Mo,F as Ke,Fa as Ro,G as Qe,Ga as Ao,H as Ye,Ha as Po,I as Ze,Ia as Bo,J as $e,Ja as Oo,K as eo,Ka as Uo,L as oo,La as Wo,M as to,Ma as jo,N as ro,Na as Lo,O as no,Oa as No,P as fo,Pa as Vo,Q as po,Qa as zo,R as ao,Ra as Xo,S as mo,Sa as qo,T as so,Ta as Go,U as io,Ua as Ho,V as xo,Va as Jo,W as lo,Wa as Ko,X as uo,Xa as k,Y as co,Ya as E,Z as yo,Za as D,_ as go,aa as Co,ba as Io,ca as a,da as m,e as Be,ea as d,f as Oe,fa as s,g as Ue,ga as i,h as We,ha as x,i as je,ia as l,j as Le,ja as u,k as Ne,ka as c,la as y,ma as g,na as b,oa as C,pa as I,qa as w,ra as T,s as Ve,sa as h,t as ze,ta as _,u as Xe,ua as wo,v as qe,va as To,wa as ho,xa as _o,ya as ko,za as Eo}from"./focused-chunks/chunk-A4ZHHTEX.js";import{Oa as Ce,Pa as Ie,Q as te,Qa as we,Ra as Te,Sa as he,Ta as _e,Ua as ke,bb as Ee,cb as De,da as n,db as ve,eb as Fe,fb as Se,gb as Me,hb as Re,ib as Ae,jb as Pe,rb as f}from"./focused-chunks/chunk-BFEMT5U3.js";import"./focused-chunks/chunk-ZDBS2DCT.js";import{a as J,b as K,c as Q,d as Y,e as Z,f as $}from"./focused-chunks/chunk-TZUIBG3P.js";import"./focused-chunks/chunk-5UKCSZWT.js";import{Ab as me,Bb as de,Ga as oe,Qb as se,Rb as ie,Sb as xe,Tb as le,Ub as ue,Vb as ce,Wb as ye,Xb as ge,Yb as be,ca as ee,rb as r,ub as re,vb as ne,wb as fe,xb as pe,zb as ae}from"./focused-chunks/chunk-SEL4Z2OO.js";import"./focused-chunks/chunk-HYPRPSYD.js";import"./focused-chunks/chunk-YLVHHWHN.js";import{Sd as v,Td as F,Ud as S,Vd as M,Wd as R,Xd as A,Yd as P,Zd as B,_d as O,le as U,me as W,ne as j,oe as L,pe as N,qe as V,re as z,se as X,te as q,ue as G,ve as H}from"./focused-chunks/chunk-RJ3EIHDU.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="d45a8203-4501-5797-a6cc-a2e7844adec9")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="d007edcb-46f0-5546-b804-27d86afe23e7")}catch{}})();export{ie as ACTIONABILITY_ORDERING_KINDS,K as BRIEF_LIST_FIELDS,Ze as CONTEXT_EVALUATION_METRIC_NAMES,a as CONTEXT_OUTPUT_VALUES,ro as CONTEXT_PACKING_PROFILES,Je as CONTEXT_RELEVANCE_SERVICE,Ge as CONTEXT_RELEVANCE_SIGNAL_NAMES,po as CONTEXT_SIGNAL_SET_VERSION,fo as CONTEXT_SIGNAL_STORE_FORMAT_VERSION,ao as CONTEXT_SIGNAL_STORE_WARNING_DETAILS,U as CONTEXT_USAGE_LIMITS,xo as ContextSignalStore,W as ContextUsageValidationError,So as DEFAULT_CHILD_SAMPLE_LIMIT,J as DEFAULT_COMPACT_LIST_FIELDS,pe as DEFAULT_DERIVED_INDEX_MINIMUM_ITEMS,uo as DEFAULT_WORKSPACE_MEMORY_MINIMUM_ITEMS,k as EVAL_METRIC_NAMES,Z as GET_DEPTH_VALUES,io as JsonFileContextSignalStoreAdapter,Q as LIST_COMMAND_DEFAULT_PROJECTIONS,ve as LIST_SORT_FIELDS,Fe as LIST_SORT_ORDER_VALUES,Fo as MAX_CHILD_PROJECTION_ITEMS,wo as NEXT_OUTPUT_VALUES,Be as PM_COMPLETE_LIST_FINDING_CODES,Oe as PmCompleteListValidationError,O as QUERY_CURSOR_CONTRACT,Pe as _testOnly,vo as _testOnlyAggregateCommand,Ao as _testOnlyGetCommand,ho as _testOnlyNextCommand,Jo as _testOnlySearchCommand,ae as acquireItemMetadataDerivedIndexLock,f as analyzeDuplicateItems,h as applyContextTagProjection,Se as applyFilterValueEcho,Le as assertCompleteListResult,j as attachContextUsageServingReceipt,C as buildChildrenByParent,Vo as buildCompactSearchFilterSummary,Me as buildContentFilterEcho,so as buildContextSignalSnapshot,Re as buildGovernanceMissingFilterEcho,Mo as buildItemChildrenRollup,He as buildItemContextRelevanceCandidates,zo as buildVerboseSearchFilters,co as buildWorkspaceMemorySnapshot,je as certifyCompleteListResult,qo as classifyImplicitSemanticFallbackReason,xe as collectBlockedByIds,ue as collectBlockedByIdsFromCorpus,N as collectContextUsageDeliveredItemIds,ye as collectDependencyBlockedIds,Xo as collectErrorCauseCodes,u as collectSubtreeIds,c as compareCriticalItems,be as computeActionabilityReport,Ue as createCompleteListOptions,F as createQueryFingerprint,Lo as createSearchCursorFingerprint,A as decodeQueryCursor,M as decodeQueryCursorEnvelope,R as decodeQueryCursorState,Ke as defaultScoreContextCandidates,S as encodeQueryCursor,$e as evaluateContextRanking,D as evaluateMetricFloors,n as executeEmbeddingBatchesWithRetry,V as finalizeContextUsageDelivery,Ho as formatVectorIndexRecoveryWarnings,le as indexBlockedByIds,We as inspectCompleteListResult,$ as listGetProjectionFields,Y as listListProjectionFields,r as measureItemMetadataReadWork,w as mergeSortedWarnings,no as packContextCandidates,y as packRankedContextItems,B as paginateQueryRows,x as parseContextDepth,m as parseContextFocusFields,l as parseContextSections,mo as parseContextSignalSnapshot,E as parseEvalMetricFloors,Ce as parseIntegerLimit,te as parseLimit,Te as parseMultiValueFilter,Ie as parsePriority,ke as parsePriorityFilterSet,he as parseStringFilterSet,we as parseType,_e as parseTypeFilterSet,_o as partitionDecisionEntries,d as projectContextFocusRows,L as propagateContextUsageServingReceipt,re as queryItemMetadataIndex,ne as queryLinkedFileMetadataIndex,fe as querySimilarItemMetadataIndex,H as readContextUsageAffinity,ee as readHistoryEntries,me as readItemMetadataDerivedIndexState,lo as readWorkspaceContextSignals,yo as readWorkspaceMemory,X as recordContextUsageDelivery,z as recordContextUsageServing,q as recordContextUsageTouch,G as recordContextUsageTouches,de as refreshItemMetadataDerivedIndex,ze as renderCalendarMarkdown,Xe as renderCalendarToon,T as renderContextMarkdown,Eo as renderNextMarkdown,Ve as resolveCalendarOutputFormat,De as resolveContentFieldFilters,s as resolveContextOutputFormat,i as resolveContextTokenBudget,Oo as resolveEffectiveSearchMode,Wo as resolveHybridSemanticWeight,ce as resolveItemBlockers,se as resolveItemExecutionRole,Ee as resolveMissingMetadataFilters,To as resolveNextOutputFormat,P as resolveQueryCursorStart,Bo as resolveSearchMaxResults,No as resolveSearchPage,Uo as resolveSearchScoreThreshold,jo as resolveSearchTuning,Go as resolveVectorIndexRecovery,p as runActivity,Do as runAggregate,qe as runCalendar,_ as runContext,to as runContextEvaluationCorpus,eo as runContextEvaluationScenario,Ne as runDuplicates,Ro as runGet,Po as runHistory,Ae as runList,ko as runNext,Ko as runSearch,Qe as scoreContextCandidates,Ye as scoreContextCandidatesWithActiveExtensions,Co as searchWorkspaceMemory,Io as searchWorkspaceMemoryReadResult,ge as selectActionableEntries,v as selectCursorSemanticOptions,bo as selectWorkspaceMemory,go as selectWorkspaceMemoryRollups,oo as summarizeContextEvaluationReports,I as toContextFocusItem,g as toContextPackingSummary,b as toContextRankingSummary,oe as verifyHistoryChain};
2
2
  //# sourceMappingURL=sdk-query.js.map
@@ -1,2 +1,2 @@
1
- import{$a as rc,$b as rd,Aa as Nb,Ab as Sc,Ba as Ob,Bb as Tc,Ca as Pb,Cb as Uc,Da as Qb,Db as Vc,Ea as Rb,Eb as Wc,Fa as Sb,Fb as Xc,Ga as Tb,Gb as Yc,Ha as Ub,Hb as Zc,Ia as Vb,Ib as _c,Ja as Wb,Jb as $c,Ka as Xb,Kb as ad,La as Yb,Lb as bd,Ma as Zb,Mb as cd,Na as _b,Nb as dd,Oa as $b,Ob as ed,P as sb,Pa as ac,Pb as fd,Q as tb,Qa as bc,Qb as gd,R as ub,Ra as cc,Rb as hd,S as vb,Sa as dc,Sb as id,Ta as jc,Tb as jd,Ua as kc,Ub as kd,Va as lc,Vb as ld,Wa as mc,Wb as md,Xa as nc,Xb as nd,Ya as oc,Yb as od,Za as pc,Zb as pd,_a as qc,_b as qd,ab as sc,ac as sd,bb as tc,bc as td,cb as uc,cc as ud,db as vc,dc as vd,eb as wc,ec as wd,fb as xc,fc as xd,ga as Ab,gb as yc,gc as yd,ha as Bb,hb as zc,hc as zd,ib as Ac,ic as Ad,jb as Bc,jc as Bd,k as Ra,kb as Cc,kc as Cd,l as Sa,lb as Dc,lc as Dd,m as Ta,mb as Ec,mc as Ed,n as Ua,nb as Fc,nc as Fd,o as Va,ob as Gc,oc as Gd,pa as Cb,pb as Hc,pc as Hd,qa as Db,qb as Ic,qc as Id,ra as Eb,rb as Jc,rc as Jd,sa as Fb,sb as Kc,sc as Kd,t as cb,ta as Gb,tb as Lc,tc as Ld,u as db,ua as Hb,ub as Mc,uc as Md,v as eb,va as Ib,vb as Nc,vc as Nd,w as gb,wa as Jb,wb as Oc,wc as Od,xa as Kb,xb as Pc,ya as Lb,yb as Qc,za as Mb,zb as Rc}from"./chunks/chunk-6ZDKKOKM.js";import"./chunks/chunk-X2ONXFBP.js";import{P as yb,a as sa,c as ta,d as ua,q as bb,r as wb,y as xb}from"./chunks/chunk-JS3B2M4D.js";import{$d as ic,Id as zb,Wc as fb,Xd as ec,Yd as fc,Zd as gc,_d as hc,bd as pb,cd as qb,dd as rb,pc as Xa,qc as Ya,rc as Za,tb as Wa,tc as _a,uc as $a,vc as ab}from"./chunks/chunk-O4YBC3OM.js";import{N as Ma,O as Na,Q as Oa,R as Pa,S as Qa,j as Ia,k as Ja,m as Ka,n as La}from"./chunks/chunk-OZCSXX4D.js";import{Ec as lb,Nb as hb,Ob as ib,Pb as jb,Qb as kb,Vc as mb,Wc as nb,_c as ob,na as Ha}from"./chunks/chunk-X53HM753.js";import{$ as e,$a as o,Aa as l,Ab as x,Ae as R,Ah as ma,Ba as m,Bb as y,Bd as G,Be as S,Bh as na,Cb as z,Ce as T,Ch as oa,Db as A,De as U,Dg as $,Eb as B,Ee as V,Eg as aa,Fb as C,Gb as D,Gg as ba,Gi as ra,Hg as ca,Ig as da,Jd as H,Jg as ea,Kg as fa,Mg as ga,Pg as ha,Pi as va,Qg as ia,Qi as wa,R as a,Ri as xa,Sg as ja,T as b,Tg as ka,Ui as ya,V as c,Va as n,Wn as Ea,Xn as Fa,Y as d,Yh as pa,Zh as qa,Zn as Ga,aa as f,bb as p,bm as Da,eb as q,fb as r,hb as s,of as W,pf as X,qd as E,ra as g,re as I,sa as h,se as J,ta as i,te as K,ue as L,ve as M,vf as Y,vg as Z,vj as za,wb as t,we as N,wj as Aa,xa as j,xb as u,xe as O,xg as _,yb as v,ye as P,yj as Ba,za as k,zb as w,zd as F,ze as Q,zh as la,zj as Ca}from"./chunks/chunk-4PNPDT2N.js";export{$ as BASELINE_ITEM_FORMAT_VERSION,g as BUILTIN_ITEM_TYPE_VALUES,m as CONFIDENCE_TEXT_VALUES,lb as CONTEXT_OUTPUT_VALUES,aa as CURRENT_ITEM_FORMAT_VERSION,Xa as DEFAULT_TERMINAL_TRANSITION_POLICY,j as DEPENDENCY_KIND_VALUES,a as EXIT_CODE,la as HISTORY_EVENT_CLASSIFICATION_VERSION,l as ISSUE_SEVERITY_VALUES,h as ITEM_TYPE_VALUES,ma as MAINTENANCE_HISTORY_OPERATIONS,u as MAX_WORKFLOW_POLICIES,v as MAX_WORKFLOW_POLICY_TERMS,nb as NEXT_OUTPUT_VALUES,sa as PM_CLI_EXPECTED_ERROR_NAME,Q as PM_COMMAND_OUTPUT_BUDGET_CONTRACTS,L as PM_DIAGNOSTIC_DEGRADATION_STEPS,M as PM_DIAGNOSTIC_OUTPUT_BUDGET_CONTRACTS,K as PM_DIAGNOSTIC_OUTPUT_CLASSES,Ja as PM_GITIGNORE_END,Ia as PM_GITIGNORE_START,J as PM_OUTPUT_BUDGET_CLASSES,I as PM_OUTPUT_DEGRADATION_STEPS,b as PmCliError,jc as PmClient,Ra as PmCompleteListValidationError,k as RISK_VALUES,Cb as SEARCH_EXTENSION_FLAG_DEFINITIONS,i as STATUS_VALUES,na as SUBSTANTIVE_HISTORY_OPERATIONS,t as WORKFLOW_POLICY_ACTIONS,Na as WORKFLOW_POLICY_DOCUMENT_SCHEMA,Ma as WORKFLOW_POLICY_SCHEMA,Y as acquireLock,qc as aggregate,Od as analyzeSdkActionCoverage,Cc as append,qa as appendHistoryEntry,_a as applyTerminalOrderingPolicy,Va as assertCompleteListResult,Oa as buildWorkflowCompletenessCheck,ka as canonicalDocument,Ua as certifyCompleteListResult,ld as claim,md as claimNext,oa as classifyHistoryEvent,da as classifyItemFormatVersion,Bb as clearWorkspaceContractsCache,kd as close,$a as closeItem,ud as closeTask,tc as comments,_b as commitImportedItem,Ec as config,kc as context,od as copy,hd as create,Sa as createCompleteListOptions,pa as createHistoryEntry,Pa as createLifecycleCompletenessPolicies,ta as createPmCliExpectedError,O as createPmCommandOutputBudget,D as createWorkflowPolicyEvaluator,P as definePmCommandOutputBudget,pd as deleteItem,Ac as deps,zc as docs,sc as duplicates,ba as effectiveItemFormatVersion,Zb as emptyImportedDocument,La as ensurePmGitignore,Yb as ensureTrackerInitialized,S as estimatePmOutputTokens,C as evaluateWorkflowPolicies,vd as extension,xd as extensionActivate,yd as extensionDeactivate,wd as extensionList,wc as files,xc as filesDiscover,yc as filesLookup,rd as focus,bd as gc,xa as generateItemId,oc as get,E as getActiveExtensionRegistrations,Ld as getContracts,s as getHistoryPath,r as getItemPath,Ka as getPmGitignoreBlock,q as getSettingsPath,Db as getWorkspaceContracts,Bc as graph,ad as health,fd as historyCompact,gd as historyCompactBulk,cd as historyRedact,dd as historyRepair,ed as historyRepairAll,N as inferPmOutputBudgetClass,Dc as init,Ta as inspectCompleteListResult,ua as isPmCliExpectedError,ga as isTerminalStatus,X as isTimestampLiteral,H as jaccardSimilarity,vc as learnings,lc as list,mc as listAllComplete,Ba as listAllItemMetadata,Ca as listAllItemMetadataLight,sb as loadCreateTemplateOptions,za as locateItem,pc as next,ca as normalizeItemFormatVersion,wa as normalizeItemId,ha as normalizeItemMetadata,va as normalizeRawItemId,Ea as normalizeSimilarityText,fa as normalizeStatusInput,uc as notes,W as nowIso,Id as packageActivate,Hd as packageCatalog,Jd as packageDeactivate,Fd as packageDescribe,Dd as packageDoctor,Bd as packageInstall,zd as packageLifecycle,Ad as packageList,Ed as packageManage,Gd as packageReload,Cd as packageUninstall,Da as parseTags,w as parseWorkflowPolicy,x as parseWorkflowPolicyDocument,c as pathExists,td as pauseTask,Wc as profile,Zc as profileApply,_c as profileLint,Xc as profileList,Yc as profileShow,U as projectPmDiagnosticOutput,V as projectPmDiagnosticText,Fb as readBooleanOption,Gb as readCsvListOption,d as readFileIfExists,Aa as readLocatedItem,Ab as readRequiredString,ra as readSettings,Eb as readStringOption,ya as readWorkflowPolicies,y as readWorkflowPolicyField,nd as release,f as removeFileIfExists,ib as renderCalendarMarkdown,jb as renderCalendarToon,bc as renderGuideMarkdown,jd as reopen,Za as requireTerminalReason,hb as resolveCalendarOutputFormat,$b as resolveGuideOutputFormat,o as resolveImplicitPmRoot,n as resolveItemTypeRegistry,R as resolvePmCommandOutputBudget,T as resolvePmDiagnosticOutputBudget,p as resolvePmRoot,_ as resolveRuntimeFieldRegistry,Z as resolveRuntimeStatusRegistry,Ya as resolveTerminalReason,qd as restore,Nd as runAction,G as runActiveOnReadHooks,F as runActiveOnWriteHooks,wb as runAggregate,kb as runCalendar,ab as runClose,rb as runCloseTask,cc as runCompletion,mb as runContext,cb as runCopy,db as runDelete,Wa as runDuplicates,eb as runFocus,xb as runGet,ac as runGuide,Ha as runList,ob as runNext,qb as runPauseTask,dc as runReindex,gb as runReopen,bb as runRestore,yb as runSearch,pb as runStartTask,zb as runStats,ub as runTemplatesList,tb as runTemplatesSave,vb as runTemplatesShow,ec as runTestRunsList,gc as runTestRunsLogs,ic as runTestRunsResume,fc as runTestRunsStatus,hc as runTestRunsStop,fb as runUpdate,Md as runWithActiveExtensions,Qa as runWorkflowPolicyAction,ea as scanItemFormatVersions,Fc as schema,Mc as schemaAddField,Kc as schemaAddStatus,Ic as schemaAddType,Qc as schemaApplyPreset,Rc as schemaInferTypes,Gc as schemaList,Oc as schemaListFields,Uc as schemaRemapStatus,Nc as schemaRemoveField,Lc as schemaRemoveStatus,Jc as schemaRemoveType,Tc as schemaRenameField,Sc as schemaRenameType,Hc as schemaShow,Pc as schemaShowField,Vc as schemaShowStatus,Ga as scoreItemSimilarity,nc as search,Xb as selectImportAuthor,ja as serializeItemDocument,ia as splitFrontMatter,sd as startTask,rc as stats,Ib as toEstimatedMinutesValue,Nb as toImportBoolean,Rb as toImportConfidence,Mb as toImportInteger,Vb as toImportLinkedDocs,Ub as toImportLinkedFiles,Wb as toImportLinkedTests,Tb as toImportLogEntries,Sb as toImportNormalizedEnum,Qb as toImportNumberMap,Jb as toImportPriority,Lb as toImportStatus,Ob as toImportStringList,Pb as toImportStringMap,Kb as toImportTags,Hb as toNonEmptyImportString,Fa as tokenizeSimilarityText,id as update,Kd as upgrade,$c as validate,A as workflowApprovalFingerprint,B as workflowPolicyApplies,z as workflowPolicyFingerprint,e as writeFileAtomic};
1
+ import{$a as rc,$b as rd,Aa as Nb,Ab as Sc,Ba as Ob,Bb as Tc,Ca as Pb,Cb as Uc,Da as Qb,Db as Vc,Ea as Rb,Eb as Wc,Fa as Sb,Fb as Xc,Ga as Tb,Gb as Yc,Ha as Ub,Hb as Zc,Ia as Vb,Ib as _c,Ja as Wb,Jb as $c,Ka as Xb,Kb as ad,La as Yb,Lb as bd,Ma as Zb,Mb as cd,Na as _b,Nb as dd,Oa as $b,Ob as ed,P as sb,Pa as ac,Pb as fd,Q as tb,Qa as bc,Qb as gd,R as ub,Ra as cc,Rb as hd,S as vb,Sa as dc,Sb as id,Ta as jc,Tb as jd,Ua as kc,Ub as kd,Va as lc,Vb as ld,Wa as mc,Wb as md,Xa as nc,Xb as nd,Ya as oc,Yb as od,Za as pc,Zb as pd,_a as qc,_b as qd,ab as sc,ac as sd,bb as tc,bc as td,cb as uc,cc as ud,db as vc,dc as vd,eb as wc,ec as wd,fb as xc,fc as xd,ga as Ab,gb as yc,gc as yd,ha as Bb,hb as zc,hc as zd,ib as Ac,ic as Ad,jb as Bc,jc as Bd,k as Ra,kb as Cc,kc as Cd,l as Sa,lb as Dc,lc as Dd,m as Ta,mb as Ec,mc as Ed,n as Ua,nb as Fc,nc as Fd,o as Va,ob as Gc,oc as Gd,pa as Cb,pb as Hc,pc as Hd,qa as Db,qb as Ic,qc as Id,ra as Eb,rb as Jc,rc as Jd,sa as Fb,sb as Kc,sc as Kd,t as cb,ta as Gb,tb as Lc,tc as Ld,u as db,ua as Hb,ub as Mc,uc as Md,v as eb,va as Ib,vb as Nc,vc as Nd,w as gb,wa as Jb,wb as Oc,wc as Od,xa as Kb,xb as Pc,ya as Lb,yb as Qc,za as Mb,zb as Rc}from"./chunks/chunk-FIJOSX2C.js";import"./chunks/chunk-4V6ONLI6.js";import{P as yb,a as sa,c as ta,d as ua,q as bb,r as wb,y as xb}from"./chunks/chunk-ZZED447K.js";import{$d as ic,Id as zb,Wc as fb,Xd as ec,Yd as fc,Zd as gc,_d as hc,bd as pb,cd as qb,dd as rb,pc as Xa,qc as Ya,rc as Za,tb as Wa,tc as _a,uc as $a,vc as ab}from"./chunks/chunk-PYRREEUB.js";import{N as Ma,O as Na,Q as Oa,R as Pa,S as Qa,j as Ia,k as Ja,m as Ka,n as La}from"./chunks/chunk-RNABUEFB.js";import{Ec as lb,Nb as hb,Ob as ib,Pb as jb,Qb as kb,Vc as mb,Wc as nb,_c as ob,na as Ha}from"./chunks/chunk-7PATQWTH.js";import{$ as e,$a as o,Aa as l,Ab as x,Ae as R,Ah as ma,Ba as m,Bb as y,Bd as G,Be as S,Bh as na,Cb as z,Ce as T,Ch as oa,Db as A,De as U,Dg as $,Eb as B,Ee as V,Eg as aa,Fb as C,Gb as D,Gg as ba,Gi as ra,Hg as ca,Ig as da,Jd as H,Jg as ea,Kg as fa,Mg as ga,Pg as ha,Pi as va,Qg as ia,Qi as wa,R as a,Ri as xa,Sg as ja,T as b,Tg as ka,Ui as ya,V as c,Va as n,Wn as Ea,Xn as Fa,Y as d,Yh as pa,Zh as qa,Zn as Ga,aa as f,bb as p,bm as Da,eb as q,fb as r,hb as s,of as W,pf as X,qd as E,ra as g,re as I,sa as h,se as J,ta as i,te as K,ue as L,ve as M,vf as Y,vg as Z,vj as za,wb as t,we as N,wj as Aa,xa as j,xb as u,xe as O,xg as _,yb as v,ye as P,yj as Ba,za as k,zb as w,zd as F,ze as Q,zh as la,zj as Ca}from"./chunks/chunk-RHQJ6VWC.js";export{$ as BASELINE_ITEM_FORMAT_VERSION,g as BUILTIN_ITEM_TYPE_VALUES,m as CONFIDENCE_TEXT_VALUES,lb as CONTEXT_OUTPUT_VALUES,aa as CURRENT_ITEM_FORMAT_VERSION,Xa as DEFAULT_TERMINAL_TRANSITION_POLICY,j as DEPENDENCY_KIND_VALUES,a as EXIT_CODE,la as HISTORY_EVENT_CLASSIFICATION_VERSION,l as ISSUE_SEVERITY_VALUES,h as ITEM_TYPE_VALUES,ma as MAINTENANCE_HISTORY_OPERATIONS,u as MAX_WORKFLOW_POLICIES,v as MAX_WORKFLOW_POLICY_TERMS,nb as NEXT_OUTPUT_VALUES,sa as PM_CLI_EXPECTED_ERROR_NAME,Q as PM_COMMAND_OUTPUT_BUDGET_CONTRACTS,L as PM_DIAGNOSTIC_DEGRADATION_STEPS,M as PM_DIAGNOSTIC_OUTPUT_BUDGET_CONTRACTS,K as PM_DIAGNOSTIC_OUTPUT_CLASSES,Ja as PM_GITIGNORE_END,Ia as PM_GITIGNORE_START,J as PM_OUTPUT_BUDGET_CLASSES,I as PM_OUTPUT_DEGRADATION_STEPS,b as PmCliError,jc as PmClient,Ra as PmCompleteListValidationError,k as RISK_VALUES,Cb as SEARCH_EXTENSION_FLAG_DEFINITIONS,i as STATUS_VALUES,na as SUBSTANTIVE_HISTORY_OPERATIONS,t as WORKFLOW_POLICY_ACTIONS,Na as WORKFLOW_POLICY_DOCUMENT_SCHEMA,Ma as WORKFLOW_POLICY_SCHEMA,Y as acquireLock,qc as aggregate,Od as analyzeSdkActionCoverage,Cc as append,qa as appendHistoryEntry,_a as applyTerminalOrderingPolicy,Va as assertCompleteListResult,Oa as buildWorkflowCompletenessCheck,ka as canonicalDocument,Ua as certifyCompleteListResult,ld as claim,md as claimNext,oa as classifyHistoryEvent,da as classifyItemFormatVersion,Bb as clearWorkspaceContractsCache,kd as close,$a as closeItem,ud as closeTask,tc as comments,_b as commitImportedItem,Ec as config,kc as context,od as copy,hd as create,Sa as createCompleteListOptions,pa as createHistoryEntry,Pa as createLifecycleCompletenessPolicies,ta as createPmCliExpectedError,O as createPmCommandOutputBudget,D as createWorkflowPolicyEvaluator,P as definePmCommandOutputBudget,pd as deleteItem,Ac as deps,zc as docs,sc as duplicates,ba as effectiveItemFormatVersion,Zb as emptyImportedDocument,La as ensurePmGitignore,Yb as ensureTrackerInitialized,S as estimatePmOutputTokens,C as evaluateWorkflowPolicies,vd as extension,xd as extensionActivate,yd as extensionDeactivate,wd as extensionList,wc as files,xc as filesDiscover,yc as filesLookup,rd as focus,bd as gc,xa as generateItemId,oc as get,E as getActiveExtensionRegistrations,Ld as getContracts,s as getHistoryPath,r as getItemPath,Ka as getPmGitignoreBlock,q as getSettingsPath,Db as getWorkspaceContracts,Bc as graph,ad as health,fd as historyCompact,gd as historyCompactBulk,cd as historyRedact,dd as historyRepair,ed as historyRepairAll,N as inferPmOutputBudgetClass,Dc as init,Ta as inspectCompleteListResult,ua as isPmCliExpectedError,ga as isTerminalStatus,X as isTimestampLiteral,H as jaccardSimilarity,vc as learnings,lc as list,mc as listAllComplete,Ba as listAllItemMetadata,Ca as listAllItemMetadataLight,sb as loadCreateTemplateOptions,za as locateItem,pc as next,ca as normalizeItemFormatVersion,wa as normalizeItemId,ha as normalizeItemMetadata,va as normalizeRawItemId,Ea as normalizeSimilarityText,fa as normalizeStatusInput,uc as notes,W as nowIso,Id as packageActivate,Hd as packageCatalog,Jd as packageDeactivate,Fd as packageDescribe,Dd as packageDoctor,Bd as packageInstall,zd as packageLifecycle,Ad as packageList,Ed as packageManage,Gd as packageReload,Cd as packageUninstall,Da as parseTags,w as parseWorkflowPolicy,x as parseWorkflowPolicyDocument,c as pathExists,td as pauseTask,Wc as profile,Zc as profileApply,_c as profileLint,Xc as profileList,Yc as profileShow,U as projectPmDiagnosticOutput,V as projectPmDiagnosticText,Fb as readBooleanOption,Gb as readCsvListOption,d as readFileIfExists,Aa as readLocatedItem,Ab as readRequiredString,ra as readSettings,Eb as readStringOption,ya as readWorkflowPolicies,y as readWorkflowPolicyField,nd as release,f as removeFileIfExists,ib as renderCalendarMarkdown,jb as renderCalendarToon,bc as renderGuideMarkdown,jd as reopen,Za as requireTerminalReason,hb as resolveCalendarOutputFormat,$b as resolveGuideOutputFormat,o as resolveImplicitPmRoot,n as resolveItemTypeRegistry,R as resolvePmCommandOutputBudget,T as resolvePmDiagnosticOutputBudget,p as resolvePmRoot,_ as resolveRuntimeFieldRegistry,Z as resolveRuntimeStatusRegistry,Ya as resolveTerminalReason,qd as restore,Nd as runAction,G as runActiveOnReadHooks,F as runActiveOnWriteHooks,wb as runAggregate,kb as runCalendar,ab as runClose,rb as runCloseTask,cc as runCompletion,mb as runContext,cb as runCopy,db as runDelete,Wa as runDuplicates,eb as runFocus,xb as runGet,ac as runGuide,Ha as runList,ob as runNext,qb as runPauseTask,dc as runReindex,gb as runReopen,bb as runRestore,yb as runSearch,pb as runStartTask,zb as runStats,ub as runTemplatesList,tb as runTemplatesSave,vb as runTemplatesShow,ec as runTestRunsList,gc as runTestRunsLogs,ic as runTestRunsResume,fc as runTestRunsStatus,hc as runTestRunsStop,fb as runUpdate,Md as runWithActiveExtensions,Qa as runWorkflowPolicyAction,ea as scanItemFormatVersions,Fc as schema,Mc as schemaAddField,Kc as schemaAddStatus,Ic as schemaAddType,Qc as schemaApplyPreset,Rc as schemaInferTypes,Gc as schemaList,Oc as schemaListFields,Uc as schemaRemapStatus,Nc as schemaRemoveField,Lc as schemaRemoveStatus,Jc as schemaRemoveType,Tc as schemaRenameField,Sc as schemaRenameType,Hc as schemaShow,Pc as schemaShowField,Vc as schemaShowStatus,Ga as scoreItemSimilarity,nc as search,Xb as selectImportAuthor,ja as serializeItemDocument,ia as splitFrontMatter,sd as startTask,rc as stats,Ib as toEstimatedMinutesValue,Nb as toImportBoolean,Rb as toImportConfidence,Mb as toImportInteger,Vb as toImportLinkedDocs,Ub as toImportLinkedFiles,Wb as toImportLinkedTests,Tb as toImportLogEntries,Sb as toImportNormalizedEnum,Qb as toImportNumberMap,Jb as toImportPriority,Lb as toImportStatus,Ob as toImportStringList,Pb as toImportStringMap,Kb as toImportTags,Hb as toNonEmptyImportString,Fa as tokenizeSimilarityText,id as update,Kd as upgrade,$c as validate,A as workflowApprovalFingerprint,B as workflowPolicyApplies,z as workflowPolicyFingerprint,e as writeFileAtomic};
2
2
  //# sourceMappingURL=sdk-runtime.js.map
@@ -1,2 +1,2 @@
1
- import{A as t,B as u,C as v,D as w,E as x,F as y,G as z,H as A,I as B,J as C,K as D,L as E,M as F,N as G,O as H,P as I,Q as J,R as K,S as L,T as M,U as N,V as O,W as P,X as Q,Y as R,Z as S,_ as T,f as c,g as d,l as e,m as f,n as g,o as h,p as i,q as j,r as k,s as l,t as m,u as n,v as o,w as p,x as q,y as r,z as s}from"./chunks/chunk-J4LPQCET.js";import"./chunks/chunk-6ZDKKOKM.js";import"./chunks/chunk-X2ONXFBP.js";import"./chunks/chunk-JS3B2M4D.js";import"./chunks/chunk-O4YBC3OM.js";import{Ja as b,o as a}from"./chunks/chunk-OZCSXX4D.js";import"./chunks/chunk-X53HM753.js";import"./chunks/chunk-4PNPDT2N.js";export{g as activateExtensionForTest,O as assertExtensionBlueprint,N as assertExtensionCapabilityUsage,v as assertExtensionDeactivated,R as assertExtensionManifestCompatible,Q as assertExtensionManifestMatchesBlueprint,S as assertExtensionPreflight,w as assertPackageManifest,P as assertProjectProfile,x as assertRegisteredCommandContract,H as assertRegisteredCommandOverride,D as assertRegisteredExporter,y as assertRegisteredFlags,z as assertRegisteredHook,C as assertRegisteredImporter,E as assertRegisteredItemField,F as assertRegisteredItemType,M as assertRegisteredMigration,I as assertRegisteredParserOverride,J as assertRegisteredPreflightOverride,G as assertRegisteredProfile,K as assertRegisteredRendererOverride,A as assertRegisteredSearchProvider,L as assertRegisteredServiceOverride,B as assertRegisteredVectorStoreAdapter,T as createExtensionTestHarness,h as deactivateExtensionForTest,e as decodeToon,a as describeExtensionActivation,c as describeExtensionBlueprint,f as encodeToon,d as lintExtensionBlueprint,b as renderExtensionSurfaceMarkdown,i as runRegisteredCommandForTest,n as runRegisteredCommandOverrideForTest,u as runRegisteredExporterForTest,k as runRegisteredHookForTest,t as runRegisteredImporterForTest,s as runRegisteredMigrationForTest,j as runRegisteredMutationGuardForTest,l as runRegisteredParserOverrideForTest,m as runRegisteredPreflightOverrideForTest,o as runRegisteredRendererOverrideForTest,q as runRegisteredSearchProviderForTest,p as runRegisteredServiceOverrideForTest,r as runRegisteredVectorStoreAdapterForTest};
1
+ import{A as t,B as u,C as v,D as w,E as x,F as y,G as z,H as A,I as B,J as C,K as D,L as E,M as F,N as G,O as H,P as I,Q as J,R as K,S as L,T as M,U as N,V as O,W as P,X as Q,Y as R,Z as S,_ as T,f as c,g as d,l as e,m as f,n as g,o as h,p as i,q as j,r as k,s as l,t as m,u as n,v as o,w as p,x as q,y as r,z as s}from"./chunks/chunk-OJ77ZQN3.js";import"./chunks/chunk-FIJOSX2C.js";import"./chunks/chunk-4V6ONLI6.js";import"./chunks/chunk-ZZED447K.js";import"./chunks/chunk-PYRREEUB.js";import{Ja as b,o as a}from"./chunks/chunk-RNABUEFB.js";import"./chunks/chunk-7PATQWTH.js";import"./chunks/chunk-RHQJ6VWC.js";export{g as activateExtensionForTest,O as assertExtensionBlueprint,N as assertExtensionCapabilityUsage,v as assertExtensionDeactivated,R as assertExtensionManifestCompatible,Q as assertExtensionManifestMatchesBlueprint,S as assertExtensionPreflight,w as assertPackageManifest,P as assertProjectProfile,x as assertRegisteredCommandContract,H as assertRegisteredCommandOverride,D as assertRegisteredExporter,y as assertRegisteredFlags,z as assertRegisteredHook,C as assertRegisteredImporter,E as assertRegisteredItemField,F as assertRegisteredItemType,M as assertRegisteredMigration,I as assertRegisteredParserOverride,J as assertRegisteredPreflightOverride,G as assertRegisteredProfile,K as assertRegisteredRendererOverride,A as assertRegisteredSearchProvider,L as assertRegisteredServiceOverride,B as assertRegisteredVectorStoreAdapter,T as createExtensionTestHarness,h as deactivateExtensionForTest,e as decodeToon,a as describeExtensionActivation,c as describeExtensionBlueprint,f as encodeToon,d as lintExtensionBlueprint,b as renderExtensionSurfaceMarkdown,i as runRegisteredCommandForTest,n as runRegisteredCommandOverrideForTest,u as runRegisteredExporterForTest,k as runRegisteredHookForTest,t as runRegisteredImporterForTest,s as runRegisteredMigrationForTest,j as runRegisteredMutationGuardForTest,l as runRegisteredParserOverrideForTest,m as runRegisteredPreflightOverrideForTest,o as runRegisteredRendererOverrideForTest,q as runRegisteredSearchProviderForTest,p as runRegisteredServiceOverrideForTest,r as runRegisteredVectorStoreAdapterForTest};
2
2
  //# sourceMappingURL=sdk-testing.js.map
@@ -1,4 +1,4 @@
1
- import{A as s0,B as a0,C as d0,a as Wn,b as yA,c as bA,d as Da,e as $a,f as Fa,h as Ga,i as Ua,j as ja,k as Ba,l as qa,m as za,n as Va,o as Ha,p as rd,q as od,r as nd,s as id,t as sd,u as e0,v as t0,w as r0,x as o0,y as n0,z as i0}from"./chunks/chunk-VMCSTFSO.js";import{A as tk,B as rk,C as ok,D as nk,E as ik,F as sk,G as ak,H as dk,I as ck,J as lk,K as pk,L as uk,M as mk,N as fk,O as _k,P as hk,Q as gk,R as yk,S as bk,T as Tk,U as Ck,V as wk,W as Sk,X as Ek,Y as Ak,Z as vk,_ as Ok,a as R0,b as M0,c as P0,d as k0,e as x0,f as N0,g as L0,h as D0,i as $0,j as F0,k as G0,l as U0,m as j0,n as B0,o as q0,p as z0,q as V0,r as H0,s as K0,t as W0,u as X0,v as Y0,w as J0,x as Z0,y as Q0,z as ek}from"./chunks/chunk-J4LPQCET.js";import{a as $h}from"./chunks/chunk-B5QVGCZX.js";import{a as c0,b as l0,c as p0,d as u0}from"./chunks/chunk-EA2CG7UM.js";import{a as m0,b as f0,c as _0,d as h0,e as g0,f as y0,g as b0,h as T0,i as C0,j as w0,k as S0,l as E0,m as A0,n as v0,o as O0,p as I0}from"./chunks/chunk-HY7FQ7QX.js";import{a as rS,b as oS,c as nS,d as iS,e as sS}from"./chunks/chunk-W3KZ22DW.js";import{$ as Tm,$a as m_,$b as mh,A as im,Aa as Lf,Ab as U_,B as sm,Ba as Df,Bb as j_,C as am,Ca as $f,Cb as B_,D as qt,Da as Ff,Db as q_,E as zt,Ea as Gf,Eb as z_,F as Vt,Fa as Uf,Fb as V_,G as Ht,Ga as jf,Gb as H_,H as Kt,Ha as Bf,Hb as K_,I as Wt,Ia as qf,Ib as W_,J as Xt,Ja as zf,Jb as X_,K as Yt,Ka as Vf,Kb as Y_,L as Jt,La as Hf,Lb as J_,M as Zt,Ma as Kf,Mb as Z_,N as Qt,Na as Wf,Nb as Q_,O as dm,Oa as Xf,Ob as eh,P as cm,Pa as Yf,Pb as th,Q as lm,Qa as Jf,Qb as rh,R as pm,Ra as Zf,Rb as oh,S as um,Sa as er,Sb as nh,T as Xe,Ta as he,Tb as ih,U as mm,Ua as s_,Ub as sh,V as fm,Va as a_,Vb as ah,W as _m,Wa as d_,Wb as dh,X as hm,Xa as c_,Xb as ch,Y as gm,Ya as l_,Yb as lh,Z as ym,Za as p_,Zb as ph,_ as bm,_a as u_,_b as uh,a as Yw,aa as LP,ab as f_,ac as fh,b as Jw,ba as DP,bb as __,bc as _h,c as Zw,ca as $P,cb as h_,cc as hh,d as Qw,da as xm,db as g_,dc as gh,e as eS,ea as Nm,eb as y_,ec as yh,f as tS,fa as Lm,fb as b_,fc as bh,g as JE,ga as Sf,gb as T_,gc as Th,h as ZE,ha as Ef,hb as C_,hc as Ch,i as Wi,ia as HP,ib as w_,ic as wh,j as WI,ja as KP,jb as S_,jc as Sh,k as XI,ka as WP,kb as E_,kc as Eh,l as YI,la as XP,lb as A_,lc as Ah,m as JI,ma as YP,mb as v_,mc as vh,n as ZI,na as JP,nb as O_,nc as Oh,o as QI,oa as ZP,ob as I_,oc as Ih,p as _l,pa as QP,pb as R_,pc as Rh,q as Vp,qa as Af,qb as M_,qc as Mh,r as Hp,ra as vf,rb as P_,rc as Ph,s as Yp,sa as Of,sb as k_,sc as kh,t as Jp,ta as If,tb as x_,tc as xh,u as hu,ua as Rf,ub as N_,uc as Nh,v as Su,va as Mf,vb as L_,vc as Lh,w as SM,wa as Pf,wb as D_,wc as Dh,x as We,xa as kf,xb as $_,y as om,ya as xf,yb as F_,z as nm,za as Nf,zb as G_}from"./chunks/chunk-6ZDKKOKM.js";import{e as rR,f as oR,g as hl,h as gl,i as Ut}from"./chunks/chunk-X2ONXFBP.js";import{A as TP,B as CP,C as wP,D as SP,E as EP,F as AP,G as vP,H as OP,I as IP,J as RP,K as MP,L as PP,M as kP,N as xP,O as NP,P as Sm,Q as Em,R as Am,S as vm,T as Om,U as Im,V as Rm,W as Mm,X as Pm,Y as km,a as $i,b as Fi,c as Gi,d as Ui,e as sM,f as aM,g as dM,h as cM,i as lM,j as zp,k as pM,l as uM,m as mM,n as fM,o as _M,q as Xp,r as Cm,s as mP,t as fP,u as _P,v as hP,w as gP,x as yP,y as wm,z as bP}from"./chunks/chunk-JS3B2M4D.js";import{$ as OI,$a as vl,$b as Dp,$c as Zu,$d as n_,A as rI,Ab as dR,Ac as tu,Ad as tf,B as oI,Bb as cR,Bc as ru,Bd as rf,C as nI,Cb as lR,Cc as ou,Cd as of,D as iI,Db as pR,Dc as nu,Dd as nf,E as sI,Eb as uR,Ec as iu,Ed as sf,F as Ke,Fa as Qc,Fb as mR,Fc as su,Fd as af,G as aI,Ga as el,Gb as xR,Gc as au,Gd as df,H as Nt,Ha as tl,Hb as NR,Hc as du,Hd as cf,I as dI,Ia as rl,Ib as LR,Ic as cu,Id as lf,J as cI,Ja as ol,Jb as DR,Jc as lu,Jd as pf,K as lI,Kb as $R,Kc as pu,L as pI,La as nl,Lb as FR,Lc as uu,Ld as uf,M as uI,Ma as il,Mb as GR,Mc as mu,Md as mf,N as mI,Na as sl,Nb as VR,Nc as fu,Nd as ff,O as fI,Oa as al,Ob as HR,Od as _f,P as _I,Pa as eR,Pb as Rp,Pc as CM,Pd as hf,Q as hI,Qa as tR,Qb as Mp,Qc as wM,Qd as gf,R as gI,Ra as dl,Rb as KR,Rc as _u,Rd as yf,S as yI,Sa as cl,Sb as WR,Sc as Eu,Sd as bf,T as bI,Ta as ll,Tb as XR,Td as Tf,U as TI,Ua as pl,Ub as YR,Ud as Cf,V as CI,Va as ul,Vb as JR,Vd as wf,W as wI,Wa as ml,Wb as Pp,Wc as Au,Wd as Qf,X as SI,Xa as fl,Xb as kp,Xd as e_,Y as EI,Ya as Sl,Yb as xp,Yc as vu,Yd as t_,Z as AI,Za as El,Zb as Np,Zc as Yu,Zd as r_,_ as vI,_a as Al,_b as Lp,_c as Ju,_d as o_,a as KO,aa as II,ab as Ol,ac as $p,ad as Qu,ae as i_,b as Pt,ba as RI,bb as Il,bc as Fp,bd as em,c as WO,ca as MI,cb as Rl,cc as Gp,cd as tm,d as Ve,da as PI,db as Ml,dc as Up,dd as rm,e as te,ea as kI,eb as Pl,ec as jp,ed as Dm,f as _c,fa as xI,fb as kl,fc as Bp,fd as $m,gb as xl,gc as ZR,gd as Fm,hb as Nl,hc as QR,hd as Gm,i as He,ib as Ll,ic as eM,id as Um,j as hc,jb as Dl,jc as tM,jd as jm,k as gc,kb as $l,kc as rM,kd as Bm,lb as Fl,lc as oM,ld as qm,m as _e,ma as Zc,mb as Gl,mc as nM,md as zm,n as yc,nb as Ul,nc as iM,nd as qP,o as bc,ob as iR,oc as qp,od as zP,p as Tc,pb as jl,pc as hM,pd as VP,q as Cc,qb as Bl,qc as gM,qd as Vm,r as XO,rb as ql,rc as yM,rd as Hm,s as YO,sb as zl,sc as bM,sd as Km,t as JO,tb as sR,tc as TM,td as Wm,u as ZO,ub as Vl,uc as Kp,ud as Xm,v as QO,vb as Hl,vc as Wp,vd as Ym,w as kt,wb as Kl,wc as Zp,wd as Jm,x as eI,xb as Wl,xc as Qp,xd as Zm,y as tI,yb as Xl,yd as Qm,z as xt,zb as aR,zc as eu,zd as ef}from"./chunks/chunk-O4YBC3OM.js";import{$a as Jc,A as Mc,B as BI,C as Pc,D as kc,Da as Dt,E as xc,Ea as $t,Fa as Ft,Ga as Gt,Ha as Fc,Ja as Gc,Ka as Uc,La as jc,N as qI,O as zI,Q as VI,Qa as Bc,R as HI,Ra as qc,S as KI,T as Nc,Ta as zc,U as Lc,Ua as Vc,V as Dc,Va as Hc,W as $c,Wa as Kc,X as Lt,Xa as Wc,Za as Xc,_a as Yc,a as oA,b as nA,c as iA,d as Xi,e as Yi,f as Ji,g as Zi,h as Qi,j as wc,k as Sc,m as Ec,n as Ac,o as NI,p as LI,q as DI,r as $I,s as FI,t as GI,u as UI,v as jI,w as vc,x as Oc,y as Ic,z as Rc}from"./chunks/chunk-OZCSXX4D.js";import{$ as LO,$a as Ip,$b as kM,$c as uP,Aa as tp,Ab as kR,Ac as iP,Ba as rp,Bc as sP,Ca as op,Cb as UR,Cc as aP,Da as np,Db as jR,Dc as dP,Ea as ip,Eb as BR,Ec as jt,Fa as sp,Fb as qR,Fc as ku,G as vO,Ga as ap,Gb as zR,Gc as xu,H as OO,Ha as dp,Hb as gu,Hc as Nu,I as IO,Ia as cp,Ib as yu,Ic as Lu,J as RO,Ja as lp,Jb as bu,Jc as Du,K as MO,Ka as pp,Kb as Tu,Kc as $u,L as PO,La as up,Lb as Cu,Lc as Fu,M as kO,Ma as mp,Mb as wu,Mc as Gu,N as xO,Na as fp,Nb as Ou,Nc as Uu,O as oc,Oa as _p,Ob as Iu,Oc as ju,P as nc,Pa as hp,Pb as Ru,Pc as Bu,Q as ic,Qa as gp,Qb as Mu,Qc as qu,R as sc,Ra as yp,Rb as EM,Rc as zu,S as ac,Sa as bp,Sb as AM,Sc as Vu,T as dc,Ta as Tp,Tb as vM,Tc as Hu,U as cc,Ua as Cp,Ub as OM,Uc as Ku,V as lc,Va as wp,Vb as IM,Vc as Bt,W as pc,Wa as Sp,Wb as RM,Wc as Wu,X as uc,Xa as Ep,Xb as MM,Xc as cP,Y as mc,Ya as Ap,Yc as lP,Z as ze,Za as vp,Zb as Pu,Zc as pP,_ as NO,_a as Op,_b as PM,_c as Xu,aa as DO,ac as xM,ad as FP,b as WE,ba as $O,bc as NM,bd as GP,c as XE,ca as FO,cc as LM,cd as UP,d as YE,da as GO,db as fR,dc as DM,dd as jP,e as QE,eb as _R,ec as $M,ed as BP,f as eA,fb as hR,fc as FM,g as tA,ga as UO,gb as gR,gc as GM,h as rA,ha as jO,hb as yR,hc as UM,i as lO,ia as BO,ib as bR,ic as jM,j as pO,ja as qO,jb as TR,jc as BM,k as uO,ka as zO,kb as CR,kc as qM,l as mO,la as VO,lb as wR,lc as zM,m as fO,ma as HO,mb as SR,mc as VM,n as _O,na as fc,nb as ER,nc as HM,o as hO,oa as yl,ob as AR,oc as KM,p as gO,pa as bl,pb as vR,pc as WM,q as yO,qa as Tl,qc as XM,r as bO,ra as Cl,rc as YM,s as TO,sa as nR,sc as JM,t as CO,tb as OR,tc as ZM,u as wO,ua as wl,uc as QM,v as SO,va as Yl,vb as IR,vc as eP,w as EO,wa as Jl,wb as RR,wc as tP,x as AO,xa as Zl,xc as rP,ya as Ql,yb as MR,yc as oP,za as ep,zb as PR,zc as nP}from"./chunks/chunk-X53HM753.js";import{$ as De,$a as Wo,$b as yn,$c as WT,$d as wt,$e as dw,$f as Jn,$i as wE,$j as is,$k as na,$m as pv,$n as Td,$o as Vd,Aa as Vo,Ab as wT,Ac as FT,Ad as uC,Ae as jn,Af as vw,Ah as Pi,Ak as Ps,Al as Pa,An as Mv,Ao as aO,Ba as Ho,Bb as ST,Bd as On,Be as Bn,Bf as Ow,Bg as SS,Bh as ki,Bj as zE,Bk as ks,Bl as ka,Bm as YA,Bn as Pv,Bo as dO,Cb as ET,Ce as qn,Cf as Iw,Cg as ES,Ch as xi,Ci as mE,Cj as VE,Ck as xs,Cl as xa,Cm as JA,Cn as It,Co as cO,Db as AT,Dc as GT,Dd as mC,De as zn,Df as Rw,Dg as ei,Dj as HE,Dk as Ns,Dl as Na,Dm as ZA,Dn as kv,Eb as vT,Ec as UT,Ed as fC,Ee as Vn,Ef as Mw,Eg as ti,Ek as Ls,Em as QA,Eo as wd,Fb as OT,Fc as jT,Fd as _C,Fe as jC,Ff as Pw,Fi as fE,Fj as KE,Fk as Ds,Fl as qe,Fm as ev,Fo as Sd,G as Kb,Gb as IT,Gc as BT,Gd as hC,Ge as BC,Gf as kw,Gg as ri,Gi as Di,Gk as $s,Gl as ee,Gn as xv,Go as Ed,Hb as Qo,Hd as gC,He as qC,Hf as xw,Hg as oi,Hi as _E,Hj as sA,Hk as Fs,Hl as La,Hm as tv,Hn as Nv,Ho as Ad,Ib as en,Ie as zC,If as Nw,Ig as ni,Ij as aA,Ik as Gs,Il as Ka,In as Lv,Io as vd,J as Wb,Jb as tn,Jc as qT,Jd as In,Je as VC,Jf as Lw,Jg as ii,Jh as LS,Ji as hE,Jj as dA,Jk as Us,Jl as Wa,Jm as rv,Jn as Dv,Jo as Od,Kb as rn,Ke as HC,Kf as Dw,Kg as si,Kh as DS,Ki as gE,Kj as je,Kk as js,Kl as Xa,Km as ov,Kn as $v,Ko as Id,Lb as on,Lc as zT,Ld as yC,Lf as $w,Lg as AS,Lh as $S,Li as yE,Lj as cA,Lk as Bs,Ll as Ya,Lm as nv,Ln as Fv,Lo as Rd,M as Xb,Mb as nn,Md as bC,Me as KC,Mf as Fw,Mg as vS,Mh as FS,Mi as bE,Mj as lA,Mk as qs,Ml as Ja,Mm as iv,Mn as Gv,Mo as Md,Nb as sn,Nd as TC,Ne as WC,Nf as Gw,Nh as GS,Ni as TE,Nj as pA,Nk as zs,Nl as Za,Nm as sv,Nn as Uv,No as Pd,Ob as Fe,Od as CC,Oe as XC,Of as Uw,Oh as US,Oj as vt,Ok as Vs,Ol as Qa,On as jv,Oo as kd,Pb as Ge,Pd as wC,Pe as YC,Pf as jw,Pg as ai,Ph as jS,Pi as ji,Pj as Be,Pk as Hs,Pl as ed,Pn as Bv,Po as xd,Q as Yb,Qa as dT,Qb as an,Qd as SC,Qe as JC,Qf as Bw,Qg as di,Qh as BS,Qi as Bi,Qj as uA,Qk as Ks,Ql as td,Qn as cd,Qo as Nd,R as ue,Ra as cT,Rb as dn,Rd as EC,Re as ZC,Rf as qw,Rg as OS,Rh as qS,Ri as qi,Rj as mA,Rk as Ws,Rl as TA,Rn as ld,Ro as Ld,S as Jb,Sa as lT,Sb as cn,Sd as AC,Se as QC,Sf as zw,Sg as ci,Sh as zS,Sj as fA,Sk as Xs,Sl as CA,Sn as pd,So as Dd,T as b,Tb as ln,Td as vC,Te as ew,Tf as Vw,Tg as li,Th as VS,Tj as _A,Tk as Ys,Tl as wA,Tn as ud,To as $d,Ub as pn,Ud as OC,Ue as tw,Uf as Hw,Ug as IS,Uh as HS,Ui as CE,Uj as hA,Uk as Js,Ul as SA,Un as md,Uo as Fd,V as $o,Va as Ko,Vb as un,Vd as IC,Ve as rw,Vf as Kw,Vg as pi,Vh as KS,Vj as gA,Vk as Zs,Vl as EA,Vn as fd,Vo as Gd,W as bt,Wa as pT,Wb as mn,We as ow,Wg as ui,Wj as es,Wk as Qs,Wl as AA,Wn as _d,Wo as Ud,X as me,Xa as uT,Xb as fn,Xc as VT,Xe as nw,Xf as Ww,Xg as D,Xh as WS,Xj as ts,Xk as ea,Xl as vA,Xm as av,Xn as hd,Xo as jd,Y as Fo,Ya as mT,Yb as _n,Yc as HT,Ye as iw,Yf as Xw,Yg as mi,Yh as Ni,Yi as zi,Yj as rs,Yk as ta,Ym as dv,Yn as gd,Yo as Bd,Za as fT,Zb as hn,Zc as KT,Ze as sw,Zf as Xn,Zh as Li,Zj as os,Zk as ra,Zl as OA,Zm as cv,Zn as yd,Zo as qd,_b as gn,_d as Ct,_e as aw,_f as Yn,_h as XS,_i as At,_j as ns,_k as oa,_l as IA,_m as lv,_n as bd,_o as zd,aa as Go,ab as Xo,ac as bn,ad as XT,ae as Rn,af as cw,ag as aS,aj as SE,ak as ss,al as ia,an as uv,ao as Cd,ap as Hd,b as Io,bb as $e,be as Mn,bf as lw,bg as dS,bj as EE,bk as as,bl as sa,bm as ad,bn as mv,bo as qv,bp as Kd,c as Ro,ca as Zb,cb as _T,cd as YT,ce as Pn,cf as pw,cg as cS,cj as AE,ck as ds,cl as aa,cm as RA,cn as fv,co as zv,cp as Wd,d as Mo,da as Qb,db as hT,dc as RT,dd as wn,df as uw,dg as lS,dh as RS,di as YS,dj as vE,dk as cs,dl as da,dm as MA,dn as _v,do as Vv,dp as Xd,e as Po,ea as eT,eb as Yo,ee as RC,ef as mw,eg as pS,eh as MS,ei as JS,ej as OE,ek as ls,el as ca,em as PA,en as Ot,eo as Hv,ep as Yd,f as xe,fa as tT,fb as Jo,fc as Tn,fd as Sn,fe as MC,ff as fw,fg as uS,fh as PS,fi as ZS,fj as IE,fk as ps,fl as la,fm as kA,fo as Kv,fp as Jd,g as ko,ga as rT,gc as Cn,gd as En,ge as PC,gf as _w,gg as mS,gh as fi,gi as QS,gj as RE,gk as us,gl as pa,gm as xA,gn as hv,go as Wv,gp as Zd,h as L,ha as oT,hb as Zo,hc as MT,he as kC,hf as hw,hg as fS,hh as _i,hj as ME,hk as ms,hl as ua,hm as NA,ho as Xv,hp as Qd,i as Ne,ie as xC,if as gw,ig as _S,ih as hi,ii as eE,ij as PE,ik as fs,il as ma,in as gv,io as Yv,ip as ec,j as xo,ja as nT,jd as JT,je as NC,jf as yw,jg as hS,jh as gi,ji as tE,jj as kE,jk as _s,jl as fa,jm as LA,jp as tc,k as No,ka as iT,kd as ZT,ke as LC,kf as bw,kg as gS,kh as yi,kj as xE,kk as hs,kl as _a,km as DA,kp as rc,l as Lo,ld as QT,le as DC,lf as St,lg as yS,lh as bi,li as rE,lj as NE,ll as ha,lm as $A,lp as Mt,m as Do,md as eC,me as $C,mg as bS,mh as Ti,mj as LE,mk as gs,ml as ga,mm as FA,mn as yv,mo as Rt,n as Fb,na as sT,nd as tC,ne as FC,nf as Et,nh as Ci,ni as oE,nj as DE,nk as ys,nl as ya,nn as bv,no as Jv,o as Le,od as rC,oe as GC,of as Hn,oh as wi,oi as nE,oj as $E,ok as bs,ol as ba,om as GA,on as Tv,oo as Zv,p as yt,pd as oC,pe as UC,pf as Kn,ph as Si,pi as iE,pj as FE,pk as Ts,pl as Ta,pm as UA,pn as dd,po as Qv,q as Gb,qa as aT,qd as An,qf as fe,qh as Ei,qi as sE,qk as Cs,ql as Ca,qn as Cv,r as Ub,ra as Uo,rd as nC,re as kn,rh as Ai,ri as aE,rj as GE,rk as ws,rl as wa,rm as jA,ro as eO,s as jb,sa as jo,sc as PT,sd as iC,se as xn,sf as Tw,sg as TS,sh as vi,si as dE,sj as UE,sk as Ss,sl as Sa,sm as BA,sn as wv,so as tO,t as Bb,ta as Bo,tb as R,td as sC,te as Nn,th as Oi,ti as cE,tj as jE,tk as Es,tl as Ea,tm as qA,tn as Sv,u as z,ub as gT,uc as kT,ud as aC,ue as Ln,uf as Cw,uh as Ii,ui as lE,uj as BE,uk as As,ul as Aa,um as zA,un as Ev,v as qb,vb as Tt,vc as xT,vd as dC,ve as Dn,vf as Ue,vg as Zn,vh as kS,vi as pE,vj as Vi,vk as vs,vl as va,vm as VA,vn as Av,vo as rO,wb as yT,wc as NT,wd as cC,we as $n,wf as ww,wg as CS,wh as xS,wj as Hi,wk as Os,wl as Oa,wm as HA,wn as vv,wo as oO,x as zb,xa as qo,xb as bT,xc as LT,xd as lC,xe as Fn,xf as Sw,xg as Qn,xh as Ri,xk as Is,xl as Ia,xm as KA,xn as Ov,xo as nO,y as Vb,yb as TT,yc as DT,yd as pC,ye as Gn,yf as Ew,yh as NS,yj as Ki,yk as Rs,yl as Ra,ym as WA,yn as Iv,yo as iO,z as Hb,za as zo,zb as CT,zc as $T,zd as vn,ze as Un,zf as Aw,zg as wS,zh as Mi,zi as uE,zj as qE,zk as Ms,zl as Ma,zm as XA,zn as Rv,zo as sO}from"./chunks/chunk-4PNPDT2N.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]="8f11e0bf-4115-55a8-bd39-c360f43cdc09")}catch{}})();var V="2026-07-28",Ik=["2025-11-25","2025-06-18"],Ye=[V],m={headerMismatch:-32020,missingRequiredClientCapability:-32021,unsupportedProtocolVersion:-32022,invalidParams:-32602},E={clientCapabilities:"io.modelcontextprotocol/clientCapabilities",clientInfo:"io.modelcontextprotocol/clientInfo",logLevel:"io.modelcontextprotocol/logLevel",protocolVersion:"io.modelcontextprotocol/protocolVersion",serverInfo:"io.modelcontextprotocol/serverInfo"},tr=["debug","info","notice","warning","error","critical","alert","emergency"],u=class extends Error{code;data;constructor(t,r,o={}){super(t),this.name="PmMcpProtocolError",this.code=r,this.data=o}};function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Fh(e){if(e===void 0)return;if(!h(e))throw new u("Invalid MCP clientInfo metadata",m.invalidParams,{field:E.clientInfo,expected:"object"});let t=typeof e.name=="string"?e.name.trim():"",r=typeof e.version=="string"?e.version.trim():"";if(t.length===0||r.length===0)throw new u("Invalid MCP clientInfo metadata",m.invalidParams,{field:E.clientInfo,required:["name","version"]});let o={name:t.slice(0,128),version:r.slice(0,128)};return typeof e.description=="string"&&e.description.trim()&&(o.description=e.description.trim().slice(0,1024)),typeof e.websiteUrl=="string"&&e.websiteUrl.trim()&&(o.websiteUrl=e.websiteUrl.trim().slice(0,2048)),o}function Gh(e){if(e!==void 0){if(typeof e!="string"||!tr.includes(e))throw new u("Invalid MCP logLevel metadata",m.invalidParams,{field:E.logLevel,allowed:[...tr]});return e}}function Je(e){let t=h(e)?e._meta:void 0;if(!h(t))throw new u("Missing required MCP request metadata",m.invalidParams,{required:[E.protocolVersion,E.clientCapabilities]});let r=t[E.protocolVersion];if(typeof r!="string"||!Ye.includes(r))throw new u("Unsupported protocol version",m.unsupportedProtocolVersion,{supported:[...Ye],requested:typeof r=="string"?r:null});let o=t[E.clientCapabilities];if(!h(o))throw new u("Invalid MCP client capabilities metadata",m.invalidParams,{field:E.clientCapabilities,expected:"object"});let n=Fh(t[E.clientInfo]),s=Gh(t[E.logLevel]);return{protocolVersion:V,clientCapabilities:o,...n?{clientInfo:n}:{},...s?{logLevel:s}:{}}}function Rk(e,t){if(t!==e.protocolVersion)throw new u("MCP protocol header does not match request metadata",m.headerMismatch,{header:t??null,metadata:e.protocolVersion})}function Mk(e,t){let r=t.filter(o=>!Object.prototype.hasOwnProperty.call(e.clientCapabilities,o));if(r.length>0)throw new u("Missing required client capability",m.missingRequiredClientCapability,{requiredCapabilities:Object.fromEntries(r.map(o=>[o,{}]))})}function Pk(e,t){let r=e.clientCapabilities.extensions;return h(r)&&h(r[t])}function Ze(e,t){let r=h(e._meta)?e._meta:{};return{...e,_meta:{...r,[E.serverInfo]:{...t}}}}function Uh(e,t){return Ze({...e,resultType:"complete"},t)}function kk(e){let t=e.ttlMs??6e4;if(!Number.isFinite(t)||t<0)throw new u("Invalid MCP discovery cache TTL",m.invalidParams,{ttlMs:t});return Uh({supportedVersions:[...Ye],capabilities:structuredClone(e.capabilities),ttlMs:t,cacheScope:"public",...e.instructions?{instructions:e.instructions}:{}},e.serverInfo)}function xk(e,t){if(h(e)&&typeof e.resultType=="string")return e.resultType;if(t==="legacy")return"complete";throw new u("Modern MCP result is missing resultType",m.invalidParams,{required:"resultType"})}import{createHash as nr,createHmac as ir,timingSafeEqual as jh}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]="15b81dd0-ef1a-58be-b6ee-5975b6778993")}catch{}})();var Bh=["elicitation/create","roots/list","sampling/createMessage"],rr=class extends Error{inputRequests;requestState;constructor(t){super("MCP operation requires additional input"),this.name="PmMcpInputRequiredError",this.inputRequests=t.inputRequests,this.requestState=t.requestState}},sr=/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/u,ge=32,et=64*1024,ye=16*1024,Qe={maxBytes:256*1024,maxDepth:32,maxNodes:4096};function qh(e){return e==="elicitation/create"?"elicitation":e==="sampling/createMessage"?"sampling":"roots"}function be(e,t,r){let o;try{o=JSON.stringify(e)}catch{throw new u(`Invalid ${r}: value is not JSON serializable`,m.invalidParams,{field:r})}if(Buffer.byteLength(o,"utf8")>t)throw new u(`Invalid ${r}: payload exceeds the protocol bound`,m.invalidParams,{field:r,maximumBytes:t})}function tt(e,t){if(!h(e))throw new u("Invalid MCP inputRequests",m.invalidParams,{field:"inputRequests",expected:"object"});let r=Object.entries(e);if(r.length===0||r.length>ge)throw new u("Invalid MCP inputRequests count",m.invalidParams,{minimum:1,maximum:ge,observed:r.length});let o={};for(let[n,s]of r){if(!sr.test(n)||!h(s))throw new u("Invalid MCP input request entry",m.invalidParams,{field:`inputRequests.${n}`});let i=s.method;if(typeof i!="string"||!Bh.includes(i))throw new u("Unsupported MCP input request method",m.invalidParams,{field:`inputRequests.${n}.method`,method:i??null});let a=qh(i);if(!Object.prototype.hasOwnProperty.call(t.clientCapabilities,a))throw new u("Missing required client capability",m.missingRequiredClientCapability,{requiredCapabilities:{[a]:{}}});if(!h(s.params))throw new u("Invalid MCP input request parameters",m.invalidParams,{field:`inputRequests.${n}.params`,expected:"object"});o[n]={method:i,params:structuredClone(s.params)}}return be(o,et,"inputRequests"),o}function ar(e){if(!h(e))throw new u("Invalid MCP inputResponses",m.invalidParams,{field:"inputResponses",expected:"object"});let t=Object.entries(e);if(t.length>ge)throw new u("Invalid MCP inputResponses count",m.invalidParams,{maximum:ge,observed:t.length});let r={};for(let[o,n]of t){if(!sr.test(o)||!h(n))throw new u("Invalid MCP input response entry",m.invalidParams,{field:`inputResponses.${o}`});r[o]=structuredClone(n)}return be(r,et,"inputResponses"),r}function $k(e){let t=e.requestState?.trim();if(t&&Buffer.byteLength(t,"utf8")>ye)throw new u("Invalid MCP requestState: payload exceeds the protocol bound",m.invalidParams,{field:"requestState",maximumBytes:ye});let r=e.inputRequests===void 0?void 0:tt(e.inputRequests,e.requestContext);if(r===void 0&&!t)throw new u("InputRequiredResult requires inputRequests or requestState",m.invalidParams,{requiredAnyOf:["inputRequests","requestState"]});return{resultType:"input_required",...r?{inputRequests:r}:{},...t?{requestState:t}:{},_meta:{[E.serverInfo]:{...e.serverInfo}}}}function dr(e){let t=Buffer.from(e);if(t.byteLength<32)throw new u("MCP requestState signing key must contain at least 32 bytes",m.invalidParams,{minimumBytes:32});return t}function Fk(e,t){if(!Number.isSafeInteger(e.expiresAt)||e.expiresAt<=0||e.method.trim().length===0||e.parameterDigest.trim().length===0||e.principal.trim().length===0)throw new u("Invalid MCP requestState payload",m.invalidParams);let r=Buffer.from(JSON.stringify({version:1,...e}),"utf8");if(r.byteLength>ye/2)throw new u("MCP requestState payload exceeds the protocol bound",m.invalidParams,{maximumBytes:ye/2});let o=r.toString("base64url"),n=ir("sha256",dr(t)).update(o).digest("base64url");return`${o}.${n}`}function zh(e){if(!h(e)||e.version!==1)throw new u("Invalid MCP requestState payload",m.invalidParams,{field:"requestState"});let{expiresAt:t,method:r,parameterDigest:o,principal:n,state:s}=e;if(typeof t!="number"||!Number.isSafeInteger(t))throw new u("Invalid MCP requestState payload",m.invalidParams,{field:"requestState"});if(typeof r!="string"||typeof o!="string"||typeof n!="string")throw new u("Invalid MCP requestState payload",m.invalidParams,{field:"requestState"});return{expiresAt:t,method:r,parameterDigest:o,principal:n,state:s}}function Gk(e,t,r){let[o,n,s]=e.split(".");if(!o||!n||s!==void 0)throw new u("Invalid MCP requestState encoding",m.invalidParams,{field:"requestState"});let i=Buffer.from(n,"base64url"),a=ir("sha256",dr(t)).update(o).digest();if(i.byteLength!==a.byteLength||!jh(i,a))throw new u("Invalid MCP requestState signature",m.invalidParams,{field:"requestState"});let d;try{d=JSON.parse(Buffer.from(o,"base64url").toString("utf8"))}catch{d=null}let c=zh(d),{expiresAt:l,method:p,parameterDigest:f,principal:_}=c;if(l<(r.nowMs??Date.now()))throw new u("Expired MCP requestState",m.invalidParams,{field:"requestState",expiredAt:l});if(p!==r.method||f!==r.parameterDigest||_!==r.principal)throw new u("MCP requestState binding mismatch",m.invalidParams,{field:"requestState"});return c}function Uk(e){return be(e,et,"request parameters"),nr("sha256").update(JSON.stringify(e)).digest("hex")}var or=class{#e=new Set;#t;constructor(t=4096){if(!Number.isSafeInteger(t)||t<1)throw new u("Invalid MCP replay guard capacity",m.invalidParams,{maximumEntries:t});this.#t=t}consume(t){let r=nr("sha256").update(t).digest("hex");if(this.#e.has(r))throw new u("MCP requestState replay detected",m.invalidParams,{field:"requestState"});if(this.#e.size>=this.#t){let o=this.#e.values().next().value;this.#e.delete(o)}this.#e.add(r)}};function Vh(e){if(!Number.isSafeInteger(e.ttlMs)||e.ttlMs<0||e.cacheScope!=="public"&&e.cacheScope!=="private")throw new u("Invalid MCP cache policy",m.invalidParams,{ttlMs:e.ttlMs,cacheScope:e.cacheScope});return{ttlMs:e.ttlMs,cacheScope:e.cacheScope}}function jk(e,t){return{...e,...Vh(t)}}function Hh(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function Kh(e,t){if(t==="#")return e;if(!t.startsWith("#/"))return;let r=e;for(let o of t.slice(2).split("/").map(Hh)){if(!h(r)&&!Array.isArray(r)||!Object.prototype.hasOwnProperty.call(r,o))return;r=r[o]}return r}function Wh(e){let t=e.maxBytes??Qe.maxBytes,r=e.maxDepth??Qe.maxDepth,o=e.maxNodes??Qe.maxNodes;if(!Number.isSafeInteger(t)||t<2)throw new u("Invalid MCP JSON Schema work bounds",m.invalidParams);if(!Number.isSafeInteger(r)||r<1)throw new u("Invalid MCP JSON Schema work bounds",m.invalidParams);if(!Number.isSafeInteger(o)||o<1)throw new u("Invalid MCP JSON Schema work bounds",m.invalidParams);return{maximumBytes:t,maximumDepth:r,maximumNodes:o}}function Xh(e,t){let r=Array.isArray(e.value)?e.value:h(e.value)?Object.values(e.value):[];for(let o of r)t.push({value:o,depth:e.depth+1})}function Yh(e,t){if(!h(t)||typeof t.$ref!="string")return;let r=t.$ref;if(r.startsWith("#")&&Kh(e,r)===void 0)throw new u("MCP JSON Schema contains an unresolved local reference",m.invalidParams,{reference:r})}function Bk(e,t={}){let{maximumBytes:r,maximumDepth:o,maximumNodes:n}=Wh(t);if(typeof e!="boolean"&&!h(e))throw new u("Invalid MCP JSON Schema root",m.invalidParams,{expected:"object or boolean"});be(e,r,"JSON Schema");let s=[{value:e,depth:0}],i=0;for(;s.length>0;){let a=s.pop();if(i+=1,i>n||a.depth>o)throw new u("MCP JSON Schema exceeds validation work bounds",m.invalidParams,{maximumDepth:o,maximumNodes:n});Yh(e,a.value),Xh(a,s)}return structuredClone(e)}import{randomUUID as Jh}from"node:crypto";import{readFile as Zh}from"node:fs/promises";import cr 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]="f3e94896-b2a0-561c-902b-71c28ddde2a1")}catch{}})();var Yk="io.modelcontextprotocol/tasks",Qh=["working","input_required","completed","failed","cancelled"],eg=/^mcp-task-[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,tg=3600*1e3,rg=1e3,Ce=1024,og=30,ng=2e3;function rt(e){return new u(e,m.invalidParams,{code:"mcp_task_not_found_or_not_authorized"})}function Te(e){let t=e.trim();if(!eg.test(t))throw rt("Unknown MCP task");return t}function lr(e,t){if(typeof e!="string"||!Number.isFinite(Date.parse(e)))throw new u("Corrupt MCP task record",m.invalidParams,{field:t});return e}function pr(e){if(!h(e)||typeof e.code!="number"||!Number.isFinite(e.code)||typeof e.message!="string")throw new u("Corrupt MCP task error",m.invalidParams);return{code:e.code,message:e.message.slice(0,Ce),...h(e.data)?{data:structuredClone(e.data)}:{}}}function ig(e){if(!Qh.includes(e))throw new u("Corrupt MCP task record",m.invalidParams);return e}function sg(e){if(typeof e!="string"||e.length===0)throw new u("Corrupt MCP task record",m.invalidParams);return e}function ag(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<1)throw new u("Corrupt MCP task record",m.invalidParams);return e}function dg(e){if(e!==null&&(typeof e!="number"||!Number.isSafeInteger(e)||e<0))throw new u("Corrupt MCP task record",m.invalidParams);return e}function cg(e){if(e!==void 0){if(typeof e!="number"||!Number.isSafeInteger(e)||e<0)throw new u("Corrupt MCP task record",m.invalidParams);return e}}function lg(e){if(!Array.isArray(e)||e.some(t=>typeof t!="string"))throw new u("Corrupt MCP task record",m.invalidParams);return[...e]}function pg(e){if(!h(e)||e.version!==1)throw new u("Corrupt MCP task record",m.invalidParams);let t=typeof e.taskId=="string"?Te(e.taskId):"",r=ig(e.status),o=sg(e.principal),n=ag(e.workerPid),s=dg(e.ttlMs),i=cg(e.pollIntervalMs),a={version:1,taskId:t,status:r,principal:o,workerPid:n,createdAt:lr(e.createdAt,"createdAt"),lastUpdatedAt:lr(e.lastUpdatedAt,"lastUpdatedAt"),ttlMs:s,consumedInputKeys:lg(e.consumedInputKeys),...typeof e.statusMessage=="string"?{statusMessage:e.statusMessage.slice(0,Ce)}:{},...typeof i=="number"?{pollIntervalMs:i}:{}};if(h(e.inputRequests)&&(a.inputRequests=structuredClone(e.inputRequests)),h(e.inputResponses)&&(a.inputResponses=structuredClone(e.inputResponses)),h(e.result)&&(a.result=structuredClone(e.result)),e.error!==void 0&&(a.error=pr(e.error)),a.status==="input_required"&&!a.inputRequests||a.status==="completed"&&!a.result||a.status==="failed"&&!a.error)throw new u("Corrupt MCP task status payload",m.invalidParams,{status:a.status});return a}function H(e){let t={taskId:e.taskId,status:e.status,createdAt:e.createdAt,lastUpdatedAt:e.lastUpdatedAt,ttlMs:e.ttlMs,...e.statusMessage?{statusMessage:e.statusMessage}:{},...e.pollIntervalMs===void 0?{}:{pollIntervalMs:e.pollIntervalMs}};return e.status==="input_required"?{...t,status:"input_required",inputRequests:structuredClone(e.inputRequests)}:e.status==="completed"?{...t,status:"completed",result:structuredClone(e.result)}:e.status==="failed"?{...t,status:"failed",error:structuredClone(e.error)}:e.status==="cancelled"?{...t,status:"cancelled"}:{...t,status:"working"}}function re(e){return e==="completed"||e==="failed"||e==="cancelled"}function ug(e){try{return process.kill(e,0),!0}catch(t){return!(typeof t=="object"&&t!==null&&"code"in t&&t.code==="ESRCH")}}var ot=class{#e;#t;#r;#o;#i;constructor(t){this.#e=cr.resolve(t.pmRoot),this.#t=t.owner?.trim()||"pm-mcp",this.#r=t.now??(()=>new Date),this.#o=t.taskIdFactory??(()=>`mcp-task-${Jh()}`),this.#i=t.workerPid??process.pid}#s(t){return cr.join(this.#e,"runtime","mcp-tasks","records",`${Te(t)}.json`)}async#d(t){try{return pg(JSON.parse(await Zh(this.#s(t),"utf8")))}catch(r){throw me(r)||r instanceof SyntaxError?rt("Unknown MCP task"):r}}async#a(t){await De(this.#s(t.taskId),`${JSON.stringify(t,null,2)}
1
+ import{A as s0,B as a0,C as d0,a as Wn,b as yA,c as bA,d as Da,e as $a,f as Fa,h as Ga,i as Ua,j as ja,k as Ba,l as qa,m as za,n as Va,o as Ha,p as rd,q as od,r as nd,s as id,t as sd,u as e0,v as t0,w as r0,x as o0,y as n0,z as i0}from"./chunks/chunk-LUKVNL72.js";import{A as tk,B as rk,C as ok,D as nk,E as ik,F as sk,G as ak,H as dk,I as ck,J as lk,K as pk,L as uk,M as mk,N as fk,O as _k,P as hk,Q as gk,R as yk,S as bk,T as Tk,U as Ck,V as wk,W as Sk,X as Ek,Y as Ak,Z as vk,_ as Ok,a as R0,b as M0,c as P0,d as k0,e as x0,f as N0,g as L0,h as D0,i as $0,j as F0,k as G0,l as U0,m as j0,n as B0,o as q0,p as z0,q as V0,r as H0,s as K0,t as W0,u as X0,v as Y0,w as J0,x as Z0,y as Q0,z as ek}from"./chunks/chunk-OJ77ZQN3.js";import{a as $h}from"./chunks/chunk-6VZKYJW7.js";import{a as c0,b as l0,c as p0,d as u0}from"./chunks/chunk-AETP4JEM.js";import{a as m0,b as f0,c as _0,d as h0,e as g0,f as y0,g as b0,h as T0,i as C0,j as w0,k as S0,l as E0,m as A0,n as v0,o as O0,p as I0}from"./chunks/chunk-TO6CIV4C.js";import{a as rS,b as oS,c as nS,d as iS,e as sS}from"./chunks/chunk-7WIEAGDS.js";import{$ as Tm,$a as m_,$b as mh,A as im,Aa as Lf,Ab as U_,B as sm,Ba as Df,Bb as j_,C as am,Ca as $f,Cb as B_,D as qt,Da as Ff,Db as q_,E as zt,Ea as Gf,Eb as z_,F as Vt,Fa as Uf,Fb as V_,G as Ht,Ga as jf,Gb as H_,H as Kt,Ha as Bf,Hb as K_,I as Wt,Ia as qf,Ib as W_,J as Xt,Ja as zf,Jb as X_,K as Yt,Ka as Vf,Kb as Y_,L as Jt,La as Hf,Lb as J_,M as Zt,Ma as Kf,Mb as Z_,N as Qt,Na as Wf,Nb as Q_,O as dm,Oa as Xf,Ob as eh,P as cm,Pa as Yf,Pb as th,Q as lm,Qa as Jf,Qb as rh,R as pm,Ra as Zf,Rb as oh,S as um,Sa as er,Sb as nh,T as Xe,Ta as he,Tb as ih,U as mm,Ua as s_,Ub as sh,V as fm,Va as a_,Vb as ah,W as _m,Wa as d_,Wb as dh,X as hm,Xa as c_,Xb as ch,Y as gm,Ya as l_,Yb as lh,Z as ym,Za as p_,Zb as ph,_ as bm,_a as u_,_b as uh,a as Yw,aa as LP,ab as f_,ac as fh,b as Jw,ba as DP,bb as __,bc as _h,c as Zw,ca as $P,cb as h_,cc as hh,d as Qw,da as xm,db as g_,dc as gh,e as eS,ea as Nm,eb as y_,ec as yh,f as tS,fa as Lm,fb as b_,fc as bh,g as JE,ga as Sf,gb as T_,gc as Th,h as ZE,ha as Ef,hb as C_,hc as Ch,i as Wi,ia as HP,ib as w_,ic as wh,j as WI,ja as KP,jb as S_,jc as Sh,k as XI,ka as WP,kb as E_,kc as Eh,l as YI,la as XP,lb as A_,lc as Ah,m as JI,ma as YP,mb as v_,mc as vh,n as ZI,na as JP,nb as O_,nc as Oh,o as QI,oa as ZP,ob as I_,oc as Ih,p as _l,pa as QP,pb as R_,pc as Rh,q as Vp,qa as Af,qb as M_,qc as Mh,r as Hp,ra as vf,rb as P_,rc as Ph,s as Yp,sa as Of,sb as k_,sc as kh,t as Jp,ta as If,tb as x_,tc as xh,u as hu,ua as Rf,ub as N_,uc as Nh,v as Su,va as Mf,vb as L_,vc as Lh,w as SM,wa as Pf,wb as D_,wc as Dh,x as We,xa as kf,xb as $_,y as om,ya as xf,yb as F_,z as nm,za as Nf,zb as G_}from"./chunks/chunk-FIJOSX2C.js";import{e as rR,f as oR,g as hl,h as gl,i as Ut}from"./chunks/chunk-4V6ONLI6.js";import{A as TP,B as CP,C as wP,D as SP,E as EP,F as AP,G as vP,H as OP,I as IP,J as RP,K as MP,L as PP,M as kP,N as xP,O as NP,P as Sm,Q as Em,R as Am,S as vm,T as Om,U as Im,V as Rm,W as Mm,X as Pm,Y as km,a as $i,b as Fi,c as Gi,d as Ui,e as sM,f as aM,g as dM,h as cM,i as lM,j as zp,k as pM,l as uM,m as mM,n as fM,o as _M,q as Xp,r as Cm,s as mP,t as fP,u as _P,v as hP,w as gP,x as yP,y as wm,z as bP}from"./chunks/chunk-ZZED447K.js";import{$ as OI,$a as vl,$b as Dp,$c as Zu,$d as n_,A as rI,Ab as dR,Ac as tu,Ad as tf,B as oI,Bb as cR,Bc as ru,Bd as rf,C as nI,Cb as lR,Cc as ou,Cd as of,D as iI,Db as pR,Dc as nu,Dd as nf,E as sI,Eb as uR,Ec as iu,Ed as sf,F as Ke,Fa as Qc,Fb as mR,Fc as su,Fd as af,G as aI,Ga as el,Gb as xR,Gc as au,Gd as df,H as Nt,Ha as tl,Hb as NR,Hc as du,Hd as cf,I as dI,Ia as rl,Ib as LR,Ic as cu,Id as lf,J as cI,Ja as ol,Jb as DR,Jc as lu,Jd as pf,K as lI,Kb as $R,Kc as pu,L as pI,La as nl,Lb as FR,Lc as uu,Ld as uf,M as uI,Ma as il,Mb as GR,Mc as mu,Md as mf,N as mI,Na as sl,Nb as VR,Nc as fu,Nd as ff,O as fI,Oa as al,Ob as HR,Od as _f,P as _I,Pa as eR,Pb as Rp,Pc as CM,Pd as hf,Q as hI,Qa as tR,Qb as Mp,Qc as wM,Qd as gf,R as gI,Ra as dl,Rb as KR,Rc as _u,Rd as yf,S as yI,Sa as cl,Sb as WR,Sc as Eu,Sd as bf,T as bI,Ta as ll,Tb as XR,Td as Tf,U as TI,Ua as pl,Ub as YR,Ud as Cf,V as CI,Va as ul,Vb as JR,Vd as wf,W as wI,Wa as ml,Wb as Pp,Wc as Au,Wd as Qf,X as SI,Xa as fl,Xb as kp,Xd as e_,Y as EI,Ya as Sl,Yb as xp,Yc as vu,Yd as t_,Z as AI,Za as El,Zb as Np,Zc as Yu,Zd as r_,_ as vI,_a as Al,_b as Lp,_c as Ju,_d as o_,a as KO,aa as II,ab as Ol,ac as $p,ad as Qu,ae as i_,b as Pt,ba as RI,bb as Il,bc as Fp,bd as em,c as WO,ca as MI,cb as Rl,cc as Gp,cd as tm,d as Ve,da as PI,db as Ml,dc as Up,dd as rm,e as te,ea as kI,eb as Pl,ec as jp,ed as Dm,f as _c,fa as xI,fb as kl,fc as Bp,fd as $m,gb as xl,gc as ZR,gd as Fm,hb as Nl,hc as QR,hd as Gm,i as He,ib as Ll,ic as eM,id as Um,j as hc,jb as Dl,jc as tM,jd as jm,k as gc,kb as $l,kc as rM,kd as Bm,lb as Fl,lc as oM,ld as qm,m as _e,ma as Zc,mb as Gl,mc as nM,md as zm,n as yc,nb as Ul,nc as iM,nd as qP,o as bc,ob as iR,oc as qp,od as zP,p as Tc,pb as jl,pc as hM,pd as VP,q as Cc,qb as Bl,qc as gM,qd as Vm,r as XO,rb as ql,rc as yM,rd as Hm,s as YO,sb as zl,sc as bM,sd as Km,t as JO,tb as sR,tc as TM,td as Wm,u as ZO,ub as Vl,uc as Kp,ud as Xm,v as QO,vb as Hl,vc as Wp,vd as Ym,w as kt,wb as Kl,wc as Zp,wd as Jm,x as eI,xb as Wl,xc as Qp,xd as Zm,y as tI,yb as Xl,yd as Qm,z as xt,zb as aR,zc as eu,zd as ef}from"./chunks/chunk-PYRREEUB.js";import{$a as Jc,A as Mc,B as BI,C as Pc,D as kc,Da as Dt,E as xc,Ea as $t,Fa as Ft,Ga as Gt,Ha as Fc,Ja as Gc,Ka as Uc,La as jc,N as qI,O as zI,Q as VI,Qa as Bc,R as HI,Ra as qc,S as KI,T as Nc,Ta as zc,U as Lc,Ua as Vc,V as Dc,Va as Hc,W as $c,Wa as Kc,X as Lt,Xa as Wc,Za as Xc,_a as Yc,a as oA,b as nA,c as iA,d as Xi,e as Yi,f as Ji,g as Zi,h as Qi,j as wc,k as Sc,m as Ec,n as Ac,o as NI,p as LI,q as DI,r as $I,s as FI,t as GI,u as UI,v as jI,w as vc,x as Oc,y as Ic,z as Rc}from"./chunks/chunk-RNABUEFB.js";import{$ as LO,$a as Ip,$b as kM,$c as uP,Aa as tp,Ab as kR,Ac as iP,Ba as rp,Bc as sP,Ca as op,Cb as UR,Cc as aP,Da as np,Db as jR,Dc as dP,Ea as ip,Eb as BR,Ec as jt,Fa as sp,Fb as qR,Fc as ku,G as vO,Ga as ap,Gb as zR,Gc as xu,H as OO,Ha as dp,Hb as gu,Hc as Nu,I as IO,Ia as cp,Ib as yu,Ic as Lu,J as RO,Ja as lp,Jb as bu,Jc as Du,K as MO,Ka as pp,Kb as Tu,Kc as $u,L as PO,La as up,Lb as Cu,Lc as Fu,M as kO,Ma as mp,Mb as wu,Mc as Gu,N as xO,Na as fp,Nb as Ou,Nc as Uu,O as oc,Oa as _p,Ob as Iu,Oc as ju,P as nc,Pa as hp,Pb as Ru,Pc as Bu,Q as ic,Qa as gp,Qb as Mu,Qc as qu,R as sc,Ra as yp,Rb as EM,Rc as zu,S as ac,Sa as bp,Sb as AM,Sc as Vu,T as dc,Ta as Tp,Tb as vM,Tc as Hu,U as cc,Ua as Cp,Ub as OM,Uc as Ku,V as lc,Va as wp,Vb as IM,Vc as Bt,W as pc,Wa as Sp,Wb as RM,Wc as Wu,X as uc,Xa as Ep,Xb as MM,Xc as cP,Y as mc,Ya as Ap,Yc as lP,Z as ze,Za as vp,Zb as Pu,Zc as pP,_ as NO,_a as Op,_b as PM,_c as Xu,aa as DO,ac as xM,ad as FP,b as WE,ba as $O,bc as NM,bd as GP,c as XE,ca as FO,cc as LM,cd as UP,d as YE,da as GO,db as fR,dc as DM,dd as jP,e as QE,eb as _R,ec as $M,ed as BP,f as eA,fb as hR,fc as FM,g as tA,ga as UO,gb as gR,gc as GM,h as rA,ha as jO,hb as yR,hc as UM,i as lO,ia as BO,ib as bR,ic as jM,j as pO,ja as qO,jb as TR,jc as BM,k as uO,ka as zO,kb as CR,kc as qM,l as mO,la as VO,lb as wR,lc as zM,m as fO,ma as HO,mb as SR,mc as VM,n as _O,na as fc,nb as ER,nc as HM,o as hO,oa as yl,ob as AR,oc as KM,p as gO,pa as bl,pb as vR,pc as WM,q as yO,qa as Tl,qc as XM,r as bO,ra as Cl,rc as YM,s as TO,sa as nR,sc as JM,t as CO,tb as OR,tc as ZM,u as wO,ua as wl,uc as QM,v as SO,va as Yl,vb as IR,vc as eP,w as EO,wa as Jl,wb as RR,wc as tP,x as AO,xa as Zl,xc as rP,ya as Ql,yb as MR,yc as oP,za as ep,zb as PR,zc as nP}from"./chunks/chunk-7PATQWTH.js";import{$ as De,$a as Wo,$b as yn,$c as WT,$d as wt,$e as dw,$f as Jn,$i as wE,$j as is,$k as na,$m as pv,$n as Td,$o as Vd,Aa as Vo,Ab as wT,Ac as FT,Ad as uC,Ae as jn,Af as vw,Ah as Pi,Ak as Ps,Al as Pa,An as Mv,Ao as aO,Ba as Ho,Bb as ST,Bd as On,Be as Bn,Bf as Ow,Bg as SS,Bh as ki,Bj as zE,Bk as ks,Bl as ka,Bm as YA,Bn as Pv,Bo as dO,Cb as ET,Ce as qn,Cf as Iw,Cg as ES,Ch as xi,Ci as mE,Cj as VE,Ck as xs,Cl as xa,Cm as JA,Cn as It,Co as cO,Db as AT,Dc as GT,Dd as mC,De as zn,Df as Rw,Dg as ei,Dj as HE,Dk as Ns,Dl as Na,Dm as ZA,Dn as kv,Eb as vT,Ec as UT,Ed as fC,Ee as Vn,Ef as Mw,Eg as ti,Ek as Ls,Em as QA,Eo as wd,Fb as OT,Fc as jT,Fd as _C,Fe as jC,Ff as Pw,Fi as fE,Fj as KE,Fk as Ds,Fl as qe,Fm as ev,Fo as Sd,G as Kb,Gb as IT,Gc as BT,Gd as hC,Ge as BC,Gf as kw,Gg as ri,Gi as Di,Gk as $s,Gl as ee,Gn as xv,Go as Ed,Hb as Qo,Hd as gC,He as qC,Hf as xw,Hg as oi,Hi as _E,Hj as sA,Hk as Fs,Hl as La,Hm as tv,Hn as Nv,Ho as Ad,Ib as en,Ie as zC,If as Nw,Ig as ni,Ij as aA,Ik as Gs,Il as Ka,In as Lv,Io as vd,J as Wb,Jb as tn,Jc as qT,Jd as In,Je as VC,Jf as Lw,Jg as ii,Jh as LS,Ji as hE,Jj as dA,Jk as Us,Jl as Wa,Jm as rv,Jn as Dv,Jo as Od,Kb as rn,Ke as HC,Kf as Dw,Kg as si,Kh as DS,Ki as gE,Kj as je,Kk as js,Kl as Xa,Km as ov,Kn as $v,Ko as Id,Lb as on,Lc as zT,Ld as yC,Lf as $w,Lg as AS,Lh as $S,Li as yE,Lj as cA,Lk as Bs,Ll as Ya,Lm as nv,Ln as Fv,Lo as Rd,M as Xb,Mb as nn,Md as bC,Me as KC,Mf as Fw,Mg as vS,Mh as FS,Mi as bE,Mj as lA,Mk as qs,Ml as Ja,Mm as iv,Mn as Gv,Mo as Md,Nb as sn,Nd as TC,Ne as WC,Nf as Gw,Nh as GS,Ni as TE,Nj as pA,Nk as zs,Nl as Za,Nm as sv,Nn as Uv,No as Pd,Ob as Fe,Od as CC,Oe as XC,Of as Uw,Oh as US,Oj as vt,Ok as Vs,Ol as Qa,On as jv,Oo as kd,Pb as Ge,Pd as wC,Pe as YC,Pf as jw,Pg as ai,Ph as jS,Pi as ji,Pj as Be,Pk as Hs,Pl as ed,Pn as Bv,Po as xd,Q as Yb,Qa as dT,Qb as an,Qd as SC,Qe as JC,Qf as Bw,Qg as di,Qh as BS,Qi as Bi,Qj as uA,Qk as Ks,Ql as td,Qn as cd,Qo as Nd,R as ue,Ra as cT,Rb as dn,Rd as EC,Re as ZC,Rf as qw,Rg as OS,Rh as qS,Ri as qi,Rj as mA,Rk as Ws,Rl as TA,Rn as ld,Ro as Ld,S as Jb,Sa as lT,Sb as cn,Sd as AC,Se as QC,Sf as zw,Sg as ci,Sh as zS,Sj as fA,Sk as Xs,Sl as CA,Sn as pd,So as Dd,T as b,Tb as ln,Td as vC,Te as ew,Tf as Vw,Tg as li,Th as VS,Tj as _A,Tk as Ys,Tl as wA,Tn as ud,To as $d,Ub as pn,Ud as OC,Ue as tw,Uf as Hw,Ug as IS,Uh as HS,Ui as CE,Uj as hA,Uk as Js,Ul as SA,Un as md,Uo as Fd,V as $o,Va as Ko,Vb as un,Vd as IC,Ve as rw,Vf as Kw,Vg as pi,Vh as KS,Vj as gA,Vk as Zs,Vl as EA,Vn as fd,Vo as Gd,W as bt,Wa as pT,Wb as mn,We as ow,Wg as ui,Wj as es,Wk as Qs,Wl as AA,Wn as _d,Wo as Ud,X as me,Xa as uT,Xb as fn,Xc as VT,Xe as nw,Xf as Ww,Xg as D,Xh as WS,Xj as ts,Xk as ea,Xl as vA,Xm as av,Xn as hd,Xo as jd,Y as Fo,Ya as mT,Yb as _n,Yc as HT,Ye as iw,Yf as Xw,Yg as mi,Yh as Ni,Yi as zi,Yj as rs,Yk as ta,Ym as dv,Yn as gd,Yo as Bd,Za as fT,Zb as hn,Zc as KT,Ze as sw,Zf as Xn,Zh as Li,Zj as os,Zk as ra,Zl as OA,Zm as cv,Zn as yd,Zo as qd,_b as gn,_d as Ct,_e as aw,_f as Yn,_h as XS,_i as At,_j as ns,_k as oa,_l as IA,_m as lv,_n as bd,_o as zd,aa as Go,ab as Xo,ac as bn,ad as XT,ae as Rn,af as cw,ag as aS,aj as SE,ak as ss,al as ia,an as uv,ao as Cd,ap as Hd,b as Io,bb as $e,be as Mn,bf as lw,bg as dS,bj as EE,bk as as,bl as sa,bm as ad,bn as mv,bo as qv,bp as Kd,c as Ro,ca as Zb,cb as _T,cd as YT,ce as Pn,cf as pw,cg as cS,cj as AE,ck as ds,cl as aa,cm as RA,cn as fv,co as zv,cp as Wd,d as Mo,da as Qb,db as hT,dc as RT,dd as wn,df as uw,dg as lS,dh as RS,di as YS,dj as vE,dk as cs,dl as da,dm as MA,dn as _v,do as Vv,dp as Xd,e as Po,ea as eT,eb as Yo,ee as RC,ef as mw,eg as pS,eh as MS,ei as JS,ej as OE,ek as ls,el as ca,em as PA,en as Ot,eo as Hv,ep as Yd,f as xe,fa as tT,fb as Jo,fc as Tn,fd as Sn,fe as MC,ff as fw,fg as uS,fh as PS,fi as ZS,fj as IE,fk as ps,fl as la,fm as kA,fo as Kv,fp as Jd,g as ko,ga as rT,gc as Cn,gd as En,ge as PC,gf as _w,gg as mS,gh as fi,gi as QS,gj as RE,gk as us,gl as pa,gm as xA,gn as hv,go as Wv,gp as Zd,h as L,ha as oT,hb as Zo,hc as MT,he as kC,hf as hw,hg as fS,hh as _i,hj as ME,hk as ms,hl as ua,hm as NA,ho as Xv,hp as Qd,i as Ne,ie as xC,if as gw,ig as _S,ih as hi,ii as eE,ij as PE,ik as fs,il as ma,in as gv,io as Yv,ip as ec,j as xo,ja as nT,jd as JT,je as NC,jf as yw,jg as hS,jh as gi,ji as tE,jj as kE,jk as _s,jl as fa,jm as LA,jp as tc,k as No,ka as iT,kd as ZT,ke as LC,kf as bw,kg as gS,kh as yi,kj as xE,kk as hs,kl as _a,km as DA,kp as rc,l as Lo,ld as QT,le as DC,lf as St,lg as yS,lh as bi,li as rE,lj as NE,ll as ha,lm as $A,lp as Mt,m as Do,md as eC,me as $C,mg as bS,mh as Ti,mj as LE,mk as gs,ml as ga,mm as FA,mn as yv,mo as Rt,n as Fb,na as sT,nd as tC,ne as FC,nf as Et,nh as Ci,ni as oE,nj as DE,nk as ys,nl as ya,nn as bv,no as Jv,o as Le,od as rC,oe as GC,of as Hn,oh as wi,oi as nE,oj as $E,ok as bs,ol as ba,om as GA,on as Tv,oo as Zv,p as yt,pd as oC,pe as UC,pf as Kn,ph as Si,pi as iE,pj as FE,pk as Ts,pl as Ta,pm as UA,pn as dd,po as Qv,q as Gb,qa as aT,qd as An,qf as fe,qh as Ei,qi as sE,qk as Cs,ql as Ca,qn as Cv,r as Ub,ra as Uo,rd as nC,re as kn,rh as Ai,ri as aE,rj as GE,rk as ws,rl as wa,rm as jA,ro as eO,s as jb,sa as jo,sc as PT,sd as iC,se as xn,sf as Tw,sg as TS,sh as vi,si as dE,sj as UE,sk as Ss,sl as Sa,sm as BA,sn as wv,so as tO,t as Bb,ta as Bo,tb as R,td as sC,te as Nn,th as Oi,ti as cE,tj as jE,tk as Es,tl as Ea,tm as qA,tn as Sv,u as z,ub as gT,uc as kT,ud as aC,ue as Ln,uf as Cw,uh as Ii,ui as lE,uj as BE,uk as As,ul as Aa,um as zA,un as Ev,v as qb,vb as Tt,vc as xT,vd as dC,ve as Dn,vf as Ue,vg as Zn,vh as kS,vi as pE,vj as Vi,vk as vs,vl as va,vm as VA,vn as Av,vo as rO,wb as yT,wc as NT,wd as cC,we as $n,wf as ww,wg as CS,wh as xS,wj as Hi,wk as Os,wl as Oa,wm as HA,wn as vv,wo as oO,x as zb,xa as qo,xb as bT,xc as LT,xd as lC,xe as Fn,xf as Sw,xg as Qn,xh as Ri,xk as Is,xl as Ia,xm as KA,xn as Ov,xo as nO,y as Vb,yb as TT,yc as DT,yd as pC,ye as Gn,yf as Ew,yh as NS,yj as Ki,yk as Rs,yl as Ra,ym as WA,yn as Iv,yo as iO,z as Hb,za as zo,zb as CT,zc as $T,zd as vn,ze as Un,zf as Aw,zg as wS,zh as Mi,zi as uE,zj as qE,zk as Ms,zl as Ma,zm as XA,zn as Rv,zo as sO}from"./chunks/chunk-RHQJ6VWC.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]="8f11e0bf-4115-55a8-bd39-c360f43cdc09")}catch{}})();var V="2026-07-28",Ik=["2025-11-25","2025-06-18"],Ye=[V],m={headerMismatch:-32020,missingRequiredClientCapability:-32021,unsupportedProtocolVersion:-32022,invalidParams:-32602},E={clientCapabilities:"io.modelcontextprotocol/clientCapabilities",clientInfo:"io.modelcontextprotocol/clientInfo",logLevel:"io.modelcontextprotocol/logLevel",protocolVersion:"io.modelcontextprotocol/protocolVersion",serverInfo:"io.modelcontextprotocol/serverInfo"},tr=["debug","info","notice","warning","error","critical","alert","emergency"],u=class extends Error{code;data;constructor(t,r,o={}){super(t),this.name="PmMcpProtocolError",this.code=r,this.data=o}};function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Fh(e){if(e===void 0)return;if(!h(e))throw new u("Invalid MCP clientInfo metadata",m.invalidParams,{field:E.clientInfo,expected:"object"});let t=typeof e.name=="string"?e.name.trim():"",r=typeof e.version=="string"?e.version.trim():"";if(t.length===0||r.length===0)throw new u("Invalid MCP clientInfo metadata",m.invalidParams,{field:E.clientInfo,required:["name","version"]});let o={name:t.slice(0,128),version:r.slice(0,128)};return typeof e.description=="string"&&e.description.trim()&&(o.description=e.description.trim().slice(0,1024)),typeof e.websiteUrl=="string"&&e.websiteUrl.trim()&&(o.websiteUrl=e.websiteUrl.trim().slice(0,2048)),o}function Gh(e){if(e!==void 0){if(typeof e!="string"||!tr.includes(e))throw new u("Invalid MCP logLevel metadata",m.invalidParams,{field:E.logLevel,allowed:[...tr]});return e}}function Je(e){let t=h(e)?e._meta:void 0;if(!h(t))throw new u("Missing required MCP request metadata",m.invalidParams,{required:[E.protocolVersion,E.clientCapabilities]});let r=t[E.protocolVersion];if(typeof r!="string"||!Ye.includes(r))throw new u("Unsupported protocol version",m.unsupportedProtocolVersion,{supported:[...Ye],requested:typeof r=="string"?r:null});let o=t[E.clientCapabilities];if(!h(o))throw new u("Invalid MCP client capabilities metadata",m.invalidParams,{field:E.clientCapabilities,expected:"object"});let n=Fh(t[E.clientInfo]),s=Gh(t[E.logLevel]);return{protocolVersion:V,clientCapabilities:o,...n?{clientInfo:n}:{},...s?{logLevel:s}:{}}}function Rk(e,t){if(t!==e.protocolVersion)throw new u("MCP protocol header does not match request metadata",m.headerMismatch,{header:t??null,metadata:e.protocolVersion})}function Mk(e,t){let r=t.filter(o=>!Object.prototype.hasOwnProperty.call(e.clientCapabilities,o));if(r.length>0)throw new u("Missing required client capability",m.missingRequiredClientCapability,{requiredCapabilities:Object.fromEntries(r.map(o=>[o,{}]))})}function Pk(e,t){let r=e.clientCapabilities.extensions;return h(r)&&h(r[t])}function Ze(e,t){let r=h(e._meta)?e._meta:{};return{...e,_meta:{...r,[E.serverInfo]:{...t}}}}function Uh(e,t){return Ze({...e,resultType:"complete"},t)}function kk(e){let t=e.ttlMs??6e4;if(!Number.isFinite(t)||t<0)throw new u("Invalid MCP discovery cache TTL",m.invalidParams,{ttlMs:t});return Uh({supportedVersions:[...Ye],capabilities:structuredClone(e.capabilities),ttlMs:t,cacheScope:"public",...e.instructions?{instructions:e.instructions}:{}},e.serverInfo)}function xk(e,t){if(h(e)&&typeof e.resultType=="string")return e.resultType;if(t==="legacy")return"complete";throw new u("Modern MCP result is missing resultType",m.invalidParams,{required:"resultType"})}import{createHash as nr,createHmac as ir,timingSafeEqual as jh}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]="15b81dd0-ef1a-58be-b6ee-5975b6778993")}catch{}})();var Bh=["elicitation/create","roots/list","sampling/createMessage"],rr=class extends Error{inputRequests;requestState;constructor(t){super("MCP operation requires additional input"),this.name="PmMcpInputRequiredError",this.inputRequests=t.inputRequests,this.requestState=t.requestState}},sr=/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/u,ge=32,et=64*1024,ye=16*1024,Qe={maxBytes:256*1024,maxDepth:32,maxNodes:4096};function qh(e){return e==="elicitation/create"?"elicitation":e==="sampling/createMessage"?"sampling":"roots"}function be(e,t,r){let o;try{o=JSON.stringify(e)}catch{throw new u(`Invalid ${r}: value is not JSON serializable`,m.invalidParams,{field:r})}if(Buffer.byteLength(o,"utf8")>t)throw new u(`Invalid ${r}: payload exceeds the protocol bound`,m.invalidParams,{field:r,maximumBytes:t})}function tt(e,t){if(!h(e))throw new u("Invalid MCP inputRequests",m.invalidParams,{field:"inputRequests",expected:"object"});let r=Object.entries(e);if(r.length===0||r.length>ge)throw new u("Invalid MCP inputRequests count",m.invalidParams,{minimum:1,maximum:ge,observed:r.length});let o={};for(let[n,s]of r){if(!sr.test(n)||!h(s))throw new u("Invalid MCP input request entry",m.invalidParams,{field:`inputRequests.${n}`});let i=s.method;if(typeof i!="string"||!Bh.includes(i))throw new u("Unsupported MCP input request method",m.invalidParams,{field:`inputRequests.${n}.method`,method:i??null});let a=qh(i);if(!Object.prototype.hasOwnProperty.call(t.clientCapabilities,a))throw new u("Missing required client capability",m.missingRequiredClientCapability,{requiredCapabilities:{[a]:{}}});if(!h(s.params))throw new u("Invalid MCP input request parameters",m.invalidParams,{field:`inputRequests.${n}.params`,expected:"object"});o[n]={method:i,params:structuredClone(s.params)}}return be(o,et,"inputRequests"),o}function ar(e){if(!h(e))throw new u("Invalid MCP inputResponses",m.invalidParams,{field:"inputResponses",expected:"object"});let t=Object.entries(e);if(t.length>ge)throw new u("Invalid MCP inputResponses count",m.invalidParams,{maximum:ge,observed:t.length});let r={};for(let[o,n]of t){if(!sr.test(o)||!h(n))throw new u("Invalid MCP input response entry",m.invalidParams,{field:`inputResponses.${o}`});r[o]=structuredClone(n)}return be(r,et,"inputResponses"),r}function $k(e){let t=e.requestState?.trim();if(t&&Buffer.byteLength(t,"utf8")>ye)throw new u("Invalid MCP requestState: payload exceeds the protocol bound",m.invalidParams,{field:"requestState",maximumBytes:ye});let r=e.inputRequests===void 0?void 0:tt(e.inputRequests,e.requestContext);if(r===void 0&&!t)throw new u("InputRequiredResult requires inputRequests or requestState",m.invalidParams,{requiredAnyOf:["inputRequests","requestState"]});return{resultType:"input_required",...r?{inputRequests:r}:{},...t?{requestState:t}:{},_meta:{[E.serverInfo]:{...e.serverInfo}}}}function dr(e){let t=Buffer.from(e);if(t.byteLength<32)throw new u("MCP requestState signing key must contain at least 32 bytes",m.invalidParams,{minimumBytes:32});return t}function Fk(e,t){if(!Number.isSafeInteger(e.expiresAt)||e.expiresAt<=0||e.method.trim().length===0||e.parameterDigest.trim().length===0||e.principal.trim().length===0)throw new u("Invalid MCP requestState payload",m.invalidParams);let r=Buffer.from(JSON.stringify({version:1,...e}),"utf8");if(r.byteLength>ye/2)throw new u("MCP requestState payload exceeds the protocol bound",m.invalidParams,{maximumBytes:ye/2});let o=r.toString("base64url"),n=ir("sha256",dr(t)).update(o).digest("base64url");return`${o}.${n}`}function zh(e){if(!h(e)||e.version!==1)throw new u("Invalid MCP requestState payload",m.invalidParams,{field:"requestState"});let{expiresAt:t,method:r,parameterDigest:o,principal:n,state:s}=e;if(typeof t!="number"||!Number.isSafeInteger(t))throw new u("Invalid MCP requestState payload",m.invalidParams,{field:"requestState"});if(typeof r!="string"||typeof o!="string"||typeof n!="string")throw new u("Invalid MCP requestState payload",m.invalidParams,{field:"requestState"});return{expiresAt:t,method:r,parameterDigest:o,principal:n,state:s}}function Gk(e,t,r){let[o,n,s]=e.split(".");if(!o||!n||s!==void 0)throw new u("Invalid MCP requestState encoding",m.invalidParams,{field:"requestState"});let i=Buffer.from(n,"base64url"),a=ir("sha256",dr(t)).update(o).digest();if(i.byteLength!==a.byteLength||!jh(i,a))throw new u("Invalid MCP requestState signature",m.invalidParams,{field:"requestState"});let d;try{d=JSON.parse(Buffer.from(o,"base64url").toString("utf8"))}catch{d=null}let c=zh(d),{expiresAt:l,method:p,parameterDigest:f,principal:_}=c;if(l<(r.nowMs??Date.now()))throw new u("Expired MCP requestState",m.invalidParams,{field:"requestState",expiredAt:l});if(p!==r.method||f!==r.parameterDigest||_!==r.principal)throw new u("MCP requestState binding mismatch",m.invalidParams,{field:"requestState"});return c}function Uk(e){return be(e,et,"request parameters"),nr("sha256").update(JSON.stringify(e)).digest("hex")}var or=class{#e=new Set;#t;constructor(t=4096){if(!Number.isSafeInteger(t)||t<1)throw new u("Invalid MCP replay guard capacity",m.invalidParams,{maximumEntries:t});this.#t=t}consume(t){let r=nr("sha256").update(t).digest("hex");if(this.#e.has(r))throw new u("MCP requestState replay detected",m.invalidParams,{field:"requestState"});if(this.#e.size>=this.#t){let o=this.#e.values().next().value;this.#e.delete(o)}this.#e.add(r)}};function Vh(e){if(!Number.isSafeInteger(e.ttlMs)||e.ttlMs<0||e.cacheScope!=="public"&&e.cacheScope!=="private")throw new u("Invalid MCP cache policy",m.invalidParams,{ttlMs:e.ttlMs,cacheScope:e.cacheScope});return{ttlMs:e.ttlMs,cacheScope:e.cacheScope}}function jk(e,t){return{...e,...Vh(t)}}function Hh(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function Kh(e,t){if(t==="#")return e;if(!t.startsWith("#/"))return;let r=e;for(let o of t.slice(2).split("/").map(Hh)){if(!h(r)&&!Array.isArray(r)||!Object.prototype.hasOwnProperty.call(r,o))return;r=r[o]}return r}function Wh(e){let t=e.maxBytes??Qe.maxBytes,r=e.maxDepth??Qe.maxDepth,o=e.maxNodes??Qe.maxNodes;if(!Number.isSafeInteger(t)||t<2)throw new u("Invalid MCP JSON Schema work bounds",m.invalidParams);if(!Number.isSafeInteger(r)||r<1)throw new u("Invalid MCP JSON Schema work bounds",m.invalidParams);if(!Number.isSafeInteger(o)||o<1)throw new u("Invalid MCP JSON Schema work bounds",m.invalidParams);return{maximumBytes:t,maximumDepth:r,maximumNodes:o}}function Xh(e,t){let r=Array.isArray(e.value)?e.value:h(e.value)?Object.values(e.value):[];for(let o of r)t.push({value:o,depth:e.depth+1})}function Yh(e,t){if(!h(t)||typeof t.$ref!="string")return;let r=t.$ref;if(r.startsWith("#")&&Kh(e,r)===void 0)throw new u("MCP JSON Schema contains an unresolved local reference",m.invalidParams,{reference:r})}function Bk(e,t={}){let{maximumBytes:r,maximumDepth:o,maximumNodes:n}=Wh(t);if(typeof e!="boolean"&&!h(e))throw new u("Invalid MCP JSON Schema root",m.invalidParams,{expected:"object or boolean"});be(e,r,"JSON Schema");let s=[{value:e,depth:0}],i=0;for(;s.length>0;){let a=s.pop();if(i+=1,i>n||a.depth>o)throw new u("MCP JSON Schema exceeds validation work bounds",m.invalidParams,{maximumDepth:o,maximumNodes:n});Yh(e,a.value),Xh(a,s)}return structuredClone(e)}import{randomUUID as Jh}from"node:crypto";import{readFile as Zh}from"node:fs/promises";import cr 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]="f3e94896-b2a0-561c-902b-71c28ddde2a1")}catch{}})();var Yk="io.modelcontextprotocol/tasks",Qh=["working","input_required","completed","failed","cancelled"],eg=/^mcp-task-[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,tg=3600*1e3,rg=1e3,Ce=1024,og=30,ng=2e3;function rt(e){return new u(e,m.invalidParams,{code:"mcp_task_not_found_or_not_authorized"})}function Te(e){let t=e.trim();if(!eg.test(t))throw rt("Unknown MCP task");return t}function lr(e,t){if(typeof e!="string"||!Number.isFinite(Date.parse(e)))throw new u("Corrupt MCP task record",m.invalidParams,{field:t});return e}function pr(e){if(!h(e)||typeof e.code!="number"||!Number.isFinite(e.code)||typeof e.message!="string")throw new u("Corrupt MCP task error",m.invalidParams);return{code:e.code,message:e.message.slice(0,Ce),...h(e.data)?{data:structuredClone(e.data)}:{}}}function ig(e){if(!Qh.includes(e))throw new u("Corrupt MCP task record",m.invalidParams);return e}function sg(e){if(typeof e!="string"||e.length===0)throw new u("Corrupt MCP task record",m.invalidParams);return e}function ag(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<1)throw new u("Corrupt MCP task record",m.invalidParams);return e}function dg(e){if(e!==null&&(typeof e!="number"||!Number.isSafeInteger(e)||e<0))throw new u("Corrupt MCP task record",m.invalidParams);return e}function cg(e){if(e!==void 0){if(typeof e!="number"||!Number.isSafeInteger(e)||e<0)throw new u("Corrupt MCP task record",m.invalidParams);return e}}function lg(e){if(!Array.isArray(e)||e.some(t=>typeof t!="string"))throw new u("Corrupt MCP task record",m.invalidParams);return[...e]}function pg(e){if(!h(e)||e.version!==1)throw new u("Corrupt MCP task record",m.invalidParams);let t=typeof e.taskId=="string"?Te(e.taskId):"",r=ig(e.status),o=sg(e.principal),n=ag(e.workerPid),s=dg(e.ttlMs),i=cg(e.pollIntervalMs),a={version:1,taskId:t,status:r,principal:o,workerPid:n,createdAt:lr(e.createdAt,"createdAt"),lastUpdatedAt:lr(e.lastUpdatedAt,"lastUpdatedAt"),ttlMs:s,consumedInputKeys:lg(e.consumedInputKeys),...typeof e.statusMessage=="string"?{statusMessage:e.statusMessage.slice(0,Ce)}:{},...typeof i=="number"?{pollIntervalMs:i}:{}};if(h(e.inputRequests)&&(a.inputRequests=structuredClone(e.inputRequests)),h(e.inputResponses)&&(a.inputResponses=structuredClone(e.inputResponses)),h(e.result)&&(a.result=structuredClone(e.result)),e.error!==void 0&&(a.error=pr(e.error)),a.status==="input_required"&&!a.inputRequests||a.status==="completed"&&!a.result||a.status==="failed"&&!a.error)throw new u("Corrupt MCP task status payload",m.invalidParams,{status:a.status});return a}function H(e){let t={taskId:e.taskId,status:e.status,createdAt:e.createdAt,lastUpdatedAt:e.lastUpdatedAt,ttlMs:e.ttlMs,...e.statusMessage?{statusMessage:e.statusMessage}:{},...e.pollIntervalMs===void 0?{}:{pollIntervalMs:e.pollIntervalMs}};return e.status==="input_required"?{...t,status:"input_required",inputRequests:structuredClone(e.inputRequests)}:e.status==="completed"?{...t,status:"completed",result:structuredClone(e.result)}:e.status==="failed"?{...t,status:"failed",error:structuredClone(e.error)}:e.status==="cancelled"?{...t,status:"cancelled"}:{...t,status:"working"}}function re(e){return e==="completed"||e==="failed"||e==="cancelled"}function ug(e){try{return process.kill(e,0),!0}catch(t){return!(typeof t=="object"&&t!==null&&"code"in t&&t.code==="ESRCH")}}var ot=class{#e;#t;#r;#o;#i;constructor(t){this.#e=cr.resolve(t.pmRoot),this.#t=t.owner?.trim()||"pm-mcp",this.#r=t.now??(()=>new Date),this.#o=t.taskIdFactory??(()=>`mcp-task-${Jh()}`),this.#i=t.workerPid??process.pid}#s(t){return cr.join(this.#e,"runtime","mcp-tasks","records",`${Te(t)}.json`)}async#d(t){try{return pg(JSON.parse(await Zh(this.#s(t),"utf8")))}catch(r){throw me(r)||r instanceof SyntaxError?rt("Unknown MCP task"):r}}async#a(t){await De(this.#s(t.taskId),`${JSON.stringify(t,null,2)}
2
2
  `)}async#n(t,r,o){let n=Te(t),s=await Ue(this.#e,n,og,this.#t,!1,!1,ng);try{let i=await this.#d(n);if(i.principal!==r)throw rt("Unknown MCP task");let a=o(i);return await this.#a(a),a}finally{await s()}}async create(t){let r=Te(this.#o()),o=t.principal.trim(),n=t.ttlMs===void 0?tg:t.ttlMs,s=t.pollIntervalMs??rg;if(o.length===0||n!==null&&(!Number.isSafeInteger(n)||n<0)||!Number.isSafeInteger(s)||s<0)throw new u("Invalid MCP task creation options",m.invalidParams);let i=this.#r().toISOString(),a={version:1,taskId:r,status:"working",createdAt:i,lastUpdatedAt:i,ttlMs:n,pollIntervalMs:s,principal:o,workerPid:this.#i,consumedInputKeys:[],...t.statusMessage?.trim()?{statusMessage:t.statusMessage.trim().slice(0,Ce)}:{}};return await this.#a(a),{...H(a),resultType:"task"}}async get(t,r){return H(await this.#n(t,r,o=>{if(re(o.status))return o;let n=this.#r().getTime(),s=o.ttlMs!==null&&Date.parse(o.createdAt)+o.ttlMs<=n,i=o.workerPid!==this.#i&&!ug(o.workerPid);return!s&&!i?o:{...o,status:"failed",statusMessage:s?"Task retention expired before completion.":"Task worker ended before recording a terminal result.",lastUpdatedAt:this.#r().toISOString(),error:{code:-32603,message:s?"MCP task expired":"MCP task worker unavailable after restart",data:{recoverable:!1,createNewTask:!0}},inputRequests:void 0}}))}async requireInput(t){let r=tt(t.inputRequests,t.requestContext);return H(await this.#n(t.taskId,t.principal,o=>{if(re(o.status))return o;let n=Object.keys(r).filter(s=>o.consumedInputKeys.includes(s));if(n.length>0)throw new u("MCP task input request keys must be unique for the task lifetime",m.invalidParams,{reused:n});return{...o,status:"input_required",statusMessage:t.statusMessage?.trim().slice(0,Ce),lastUpdatedAt:this.#r().toISOString(),inputRequests:r}}))}async update(t,r,o){let n=ar(o),s=[],i=[];return await this.#n(t,r,a=>{if(a.status!=="input_required"||!a.inputRequests)return a;let d={...a.inputRequests},c=a.inputResponses?{...a.inputResponses}:{};for(let[l,p]of Object.entries(n))Object.prototype.hasOwnProperty.call(d,l)&&(c[l]=p,delete d[l],s.push(l));return i=Object.keys(d).sort(),s.length===0?a:{...a,status:i.length===0?"working":"input_required",lastUpdatedAt:this.#r().toISOString(),inputRequests:i.length===0?void 0:d,inputResponses:c,consumedInputKeys:[...new Set([...a.consumedInputKeys,...s])].sort()}}),{acceptedKeys:s.sort(),remainingKeys:i}}async takeInputResponses(t,r){let o={};return await this.#n(t,r,n=>(o=structuredClone(n.inputResponses??{}),Object.keys(o).length===0?n:{...n,inputResponses:void 0})),o}async complete(t,r,o){return H(await this.#n(t,r,n=>re(n.status)?n:{...n,status:"completed",statusMessage:"Task completed.",lastUpdatedAt:this.#r().toISOString(),result:structuredClone(o),inputRequests:void 0,error:void 0}))}async fail(t,r,o){let n=pr(o);return H(await this.#n(t,r,s=>re(s.status)?s:{...s,status:"failed",statusMessage:n.message,lastUpdatedAt:this.#r().toISOString(),error:n,inputRequests:void 0,result:void 0}))}async cancel(t,r){return H(await this.#n(t,r,o=>re(o.status)?o:{...o,status:"cancelled",statusMessage:"Task cancelled by the client.",lastUpdatedAt:this.#r().toISOString(),inputRequests:void 0,result:void 0,error:void 0}))}};function Jk(e){return new ot(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]="15cbe26a-5716-5e8c-8700-eb36a1a056d6")}catch{}})();var we="io.modelcontextprotocol/subscriptionId",ur=256,mr=2048,mg=5e3;function fg(e,t){return new Promise((r,o)=>{let n=setTimeout(()=>o(new Error("MCP subscription sink write timed out")),mg);n.unref(),Promise.resolve().then(()=>e(t)).then(()=>{clearTimeout(n),r()},s=>{clearTimeout(n),o(s instanceof Error?s:new Error(String(s)))})})}function nt(e,t){if(e!==void 0){if(typeof e!="boolean")throw new u("Invalid MCP subscription filter",m.invalidParams,{field:`notifications.${t}`,expected:"boolean"});return e||void 0}}function _g(e){if(!h(e))throw new u("Invalid MCP subscription filter",m.invalidParams,{field:"notifications",expected:"object"});let t=nt(e.toolsListChanged,"toolsListChanged"),r=nt(e.promptsListChanged,"promptsListChanged"),o=nt(e.resourcesListChanged,"resourcesListChanged"),n;if(e.resourceSubscriptions!==void 0){if(!Array.isArray(e.resourceSubscriptions)||e.resourceSubscriptions.length>ur)throw new u("Invalid MCP resource subscriptions",m.invalidParams,{field:"notifications.resourceSubscriptions",maximum:ur});let s=new Set;for(let i of e.resourceSubscriptions){if(typeof i!="string"||i.trim().length===0||Buffer.byteLength(i,"utf8")>mr)throw new u("Invalid MCP resource subscription URI",m.invalidParams,{field:"notifications.resourceSubscriptions",maximumBytes:mr});s.add(i)}s.size>0&&(n=[...s].sort())}return{...t?{toolsListChanged:t}:{},...r?{promptsListChanged:r}:{},...o?{resourcesListChanged:o}:{},...n?{resourceSubscriptions:n}:{}}}function hg(e,t){return{...e.toolsListChanged&&t.tools?.listChanged?{toolsListChanged:!0}:{},...e.promptsListChanged&&t.prompts?.listChanged?{promptsListChanged:!0}:{},...e.resourcesListChanged&&t.resources?.listChanged?{resourcesListChanged:!0}:{},...e.resourceSubscriptions&&t.resources?.subscribe?{resourceSubscriptions:[...e.resourceSubscriptions]}:{}}}var fr=class{#e;#t=new Map;#r;constructor(t){this.#e=structuredClone(t.capabilities),this.#r={...t.serverInfo}}get size(){return this.#t.size}async open(t){if(this.#t.has(t.id))throw new u("MCP subscription id is already active",m.invalidParams,{subscriptionId:t.id});let r=hg(_g(t.notifications),this.#e),o={filter:r,sink:t.sink,writeQueue:Promise.resolve()};this.#t.set(t.id,o);try{await this.#o(t.id,o,{jsonrpc:"2.0",method:"notifications/subscriptions/acknowledged",params:{_meta:{[we]:t.id},notifications:structuredClone(r)}},!0)}catch(n){throw this.#t.delete(t.id),n}return structuredClone(r)}async emitListChanged(t){let r=`${t}ListChanged`,o=`notifications/${t}/list_changed`,n=[];for(let[s,i]of this.#t)i.filter[r]===!0&&n.push(this.#o(s,i,{jsonrpc:"2.0",method:o,params:{_meta:{[we]:s}}}));return(await Promise.all(n)).filter(Boolean).length}async emitResourceUpdated(t){let r=[];for(let[o,n]of this.#t)n.filter.resourceSubscriptions?.includes(t)&&r.push(this.#o(o,n,{jsonrpc:"2.0",method:"notifications/resources/updated",params:{_meta:{[we]:o},uri:t}}));return(await Promise.all(r)).filter(Boolean).length}async#o(t,r,o,n=!1){let s=r.writeQueue.then(async()=>{if(this.#t.get(t)!==r)return!1;try{return await fg(r.sink,o),!0}catch(i){if(this.#t.get(t)===r&&this.#t.delete(t),n)throw i;return!1}});return r.writeQueue=s.then(()=>{},()=>{}),s}close(t){if(this.#t.delete(t))return{...Ze({resultType:"complete",_meta:{[we]:t}},this.#r)}}closeAll(){let t=[];for(let r of this.#t.keys()){let o=this.close(r);t.push({id:r,result:o})}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]="3681273a-e101-57a0-9446-982c450e7183")}catch{}})();var _r=/^=\?base64\?([A-Za-z0-9+/]*={0,2})\?=$/u,gg=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u,hr=/^[\t\x20-\x7E]*$/u,gr=new Set(["prompts/get","resources/read","tools/call"]);function yg(e){let t=new Map;for(let[r,o]of Object.entries(e)){if(o===void 0)continue;let n=typeof o=="string"?o:o.join(", ");t.set(r.toLowerCase(),n)}return t}function A(e,t){throw new u(e,m.headerMismatch,{header:t})}function yr(e){let t=typeof e=="boolean"?String(e).toLowerCase():String(e);return t.length>0&&t.trim()===t&&hr.test(t)&&!_r.test(t)?t:`=?base64?${Buffer.from(t,"utf8").toString("base64")}?=`}function br(e,t){let r=_r.exec(e);if(r){let o=r[1],n=Buffer.from(o,"base64");return n.toString("base64")!==o||n.length===0?A("Malformed MCP Base64 header value",t):n.toString("utf8")}return e.length===0||e.trim()!==e||!hr.test(e)?A("Malformed MCP header value",t):e}function Se(e){return Array.isArray(e)?e.some(Se):h(e)?Object.prototype.hasOwnProperty.call(e,"x-mcp-header")||Object.values(e).some(Se):!1}function bg(e,t,r){let o=e["x-mcp-header"];if(o===void 0)return;let n=e.type;if(typeof o!="string"||!gg.test(o)||!["boolean","integer","string"].includes(String(n))||r.has(o.toLowerCase()))throw new u("Invalid MCP x-mcp-header annotation",m.invalidParams,{field:t.join("."),annotation:o});return r.add(o.toLowerCase()),{name:o,path:t,type:n}}function Tr(e){if(!h(e))throw new u("Invalid MCP tool schema",m.invalidParams,{field:"inputSchema",expected:"object"});let t=[],r=new Set,o=(n,s)=>{let i=n.properties;if(i!==void 0){if(!h(i))throw new u("Invalid MCP tool schema properties",m.invalidParams,{field:"inputSchema.properties"});for(let[a,d]of Object.entries(i)){if(!h(d))continue;let c=[...s,a],l=bg(d,c,r);l&&t.push(l);for(let[p,f]of Object.entries(d))if(p!=="properties"&&p!=="x-mcp-header"&&Se(f))throw new u("MCP x-mcp-header is not statically reachable",m.invalidParams,{field:c.join("."),keyword:p});o(d,c)}}};for(let[n,s]of Object.entries(e))if(n!=="properties"&&Se(s))throw new u("MCP x-mcp-header is not statically reachable",m.invalidParams,{field:"inputSchema",keyword:n});return o(e,[]),t}function Cr(e,t){let r=e;for(let o of t){if(!h(r))return;r=r[o]}return r}function wr(e,t){let r=e==="resources/read"?t.uri:t.name;return typeof r=="string"?r:void 0}function Tg(e,t){let r=h(e.arguments)?e.arguments:{},o={};for(let n of Tr(t)){let s=Cr(r,n.path);if(s!=null){if(!(n.type==="integer"&&typeof s=="number"&&Number.isSafeInteger(s)||n.type==="boolean"&&typeof s=="boolean"||n.type==="string"&&typeof s=="string"))throw new u("Invalid MCP custom header argument",m.invalidParams,{field:n.path.join("."),expected:n.type});o[`Mcp-Param-${n.name}`]=yr(s)}}return o}function rx(e){let t=h(e.request.params)?e.request.params:void 0,r=Je(t),o=e.request.method;if(typeof o!="string"||o.length===0)return A("Missing MCP request method","Mcp-Method");let n={Accept:"application/json, text/event-stream","Content-Type":"application/json","MCP-Protocol-Version":r.protocolVersion,"Mcp-Method":o},s=wr(o,t);if(gr.has(o)){if(s===void 0)return A("Missing MCP request name","Mcp-Name");n["Mcp-Name"]=yr(s)}return o==="tools/call"&&e.toolSchema!==void 0&&Object.assign(n,Tg(t,e.toolSchema)),n}function Cg(e,t){let r=t.method;(typeof r!="string"||r.length===0)&&A("Missing MCP request method","Mcp-Method");let o=h(t.params)?t.params:void 0,n=Je(o).protocolVersion;if(e.get("mcp-protocol-version")!==n&&A("MCP protocol header does not match request metadata","MCP-Protocol-Version"),e.get("mcp-method")!==r&&A("MCP method header does not match request body","Mcp-Method"),gr.has(r)){let s=e.get("mcp-name"),i=wr(r,o);(s===void 0||i===void 0||br(s,"Mcp-Name")!==i)&&A("MCP name header does not match request body","Mcp-Name")}e.has("last-event-id")&&A("MCP SSE resumability is not supported","Last-Event-ID")}function wg(e,t,r){return e.type==="integer"?typeof t=="number"&&Number.isSafeInteger(t)&&Number(r)===t:e.type==="boolean"?typeof t=="boolean"&&r===String(t):typeof t=="string"&&r===t}function Sg(e){let t=h(e.params.arguments)?e.params.arguments:{};for(let r of Tr(e.toolSchema)){let o=Cr(t,r.path),n=`Mcp-Param-${r.name}`,s=e.headers.get(n.toLowerCase());if(o==null){s!==void 0&&A("Unexpected MCP parameter header",n);continue}s===void 0&&A("Missing MCP parameter header",n),wg(r,o,br(s,n))||A("MCP parameter header does not match request body",n)}}function ox(e){let t=yg(e.headers),r=typeof e.request.method=="string"?e.request.method:"";Cg(t,e.request),!(r!=="tools/call"||e.toolSchema===void 0)&&Sg({headers:t,params:e.request.params,toolSchema:e.toolSchema})}var nx=V;import{AsyncLocalStorage as Eg}from"node:async_hooks";import{createHash as Sr,timingSafeEqual as Ag}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]="a7c30d99-a0e4-552e-be61-0c54a455e211")}catch{}})();var y=class extends Error{httpStatus;challenge;constructor(t,r,o){super(t),this.name="PmMcpAuthorizationError",this.httpStatus=r,this.challenge=o}},vg=/^00-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/u,Og=/^[a-z][a-z0-9_*/-]{0,255}$/u,Ig=/^(?:[a-z0-9][a-z0-9_*/-]{0,240})@[a-z][a-z0-9_*/-]{0,13}$/u,Rg=/^[\x20-\x2B\x2D-\x3C\x3E-\x7E]{0,255}[\x21-\x2B\x2D-\x3C\x3E-\x7E]$/u,Ar=/^[\x21\x23-\x5B\x5D-\x7E]+$/u,vr=/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/u,Mg=/^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]*$/u,Pg=/%(?![0-9A-Fa-f]{2})/u,kg=512,xg=32,Ng=180,Lg=8192,Dg=8192,Or=new Eg;function S(e,t,r=!1){if(new RegExp("\\p{Cc}","u").test(e))throw new y(`Invalid ${t}`,401);let o;try{o=new URL(e)}catch{throw new y(`Invalid ${t}`,401)}let n=o.hostname==="127.0.0.1"||o.hostname==="localhost";if(o.hash.length>0||o.protocol!=="https:"&&!(r&&n&&o.protocol==="http:"))throw new y(`Invalid ${t}`,401);return o}function $g(e,t){let r=t.toLowerCase();for(let[o,n]of Object.entries(e))if(!(o.toLowerCase()!==r||n===void 0))return typeof n=="string"?n:n.join(", ")}function cx(e){let t=S(e.resource,"protected resource URI",!0).href.replace(/\/$/u,"");if(e.authorizationServers.length===0)throw new y("Protected resource metadata requires an authorization server",401);let r=e.authorizationServers.map(n=>S(n,"authorization server issuer").href.replace(/\/$/u,"")),o=[...new Set(e.scopes??[])];if(o.some(n=>!Ar.test(n)))throw new y("Invalid authorization scope",401);return{resource:t,authorization_servers:r,...o.length>0?{scopes_supported:o.sort()}:{}}}function lx(e){let t=S(e,"authorization server issuer"),r=t.pathname.replace(/^\/+|\/+$/gu,""),o=t.origin;return r?[`${o}/.well-known/oauth-authorization-server/${r}`,`${o}/.well-known/openid-configuration/${r}`,`${o}/${r}/.well-known/openid-configuration`]:[`${o}/.well-known/oauth-authorization-server`,`${o}/.well-known/openid-configuration`]}function px(e,t){if(!h(e)||typeof e.issuer!="string")throw new y("Invalid authorization server metadata",401);let r=S(t,"expected issuer").href.replace(/\/$/u,"");if(S(e.issuer,"metadata issuer").href.replace(/\/$/u,"")!==r)throw new y("Authorization server issuer mismatch",401);if(!Array.isArray(e.code_challenge_methods_supported)||!e.code_challenge_methods_supported.includes("S256"))throw new y("Authorization server does not support required S256 PKCE",401);let o=d=>{let c=e[d];if(typeof c!="string")throw new y(`Authorization server metadata requires ${d}`,401);return S(c,d).href},n=d=>{let c=e[d];return typeof c=="string"?S(c,d).href:void 0},s=o("authorization_endpoint"),i=o("token_endpoint"),a=n("registration_endpoint");return{issuer:r,authorization_endpoint:s,token_endpoint:i,code_challenge_methods_supported:[...new Set(e.code_challenge_methods_supported.filter(d=>typeof d=="string"))],...e.client_id_metadata_document_supported===!0?{client_id_metadata_document_supported:!0}:{},...a?{registration_endpoint:a}:{}}}function ux(e){return e.hasPreRegisteredClient?"pre_registered":e.metadata.client_id_metadata_document_supported?"client_id_metadata_document":e.metadata.registration_endpoint?"dynamic":"user_supplied"}function mx(e){if(e.responseIssuer===void 0){if(e.issuerParameterSupported)throw new y("Authorization response omitted the advertised issuer",401);return}if(e.responseIssuer!==e.expectedIssuer)throw new y("Authorization response issuer mismatch",401)}function fx(e,t){let r=S(t,"client metadata document URL");if(r.pathname==="/"||!h(e)||e.client_id!==r.href||typeof e.client_name!="string"||e.client_name.trim().length===0||!Array.isArray(e.redirect_uris)||e.redirect_uris.length===0)throw new y("Invalid Client ID Metadata Document",401);for(let o of e.redirect_uris){if(typeof o!="string")throw new y("Invalid client redirect URI",401);S(o,"client redirect URI",!0)}return structuredClone(e)}function _x(e){if(e.redirectUris.length===0||e.clientName.trim().length===0)throw new y("Invalid dynamic client registration metadata",401);let t=e.redirectUris.map(r=>S(r,"redirect URI",!0).href);return{application_type:e.applicationType,client_name:e.clientName.trim().slice(0,128),redirect_uris:t,grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none"}}var Er=class{#e=new Map;set(t,r){let o=S(t,"credential issuer").href;this.#e.set(o,structuredClone(r))}get(t){let r=S(t,"credential issuer").href,o=this.#e.get(r);return o?structuredClone(o):void 0}delete(t){let r=S(t,"credential issuer").href;return this.#e.delete(r)}};function Fg(e){let t=e.traceparent,r=e.tracestate;if(t!==void 0){let o=typeof t=="string"?vg.exec(t):null;if(!o)throw new y("Invalid MCP traceparent",403);let n=o[1],s=o[2];if(/^0+$/u.test(n)||/^0+$/u.test(s))throw new y("Invalid MCP traceparent",403)}if(r!==void 0&&(typeof r!="string"||!Ug(r)))throw new y("Invalid MCP tracestate",403);return{...typeof t=="string"?{traceparent:t}:{},...typeof r=="string"?{tracestate:r}:{}}}function $(e){return e.replace(/^[ \t]*|[ \t]*$/gu,"")}function Gg(e){return Og.test(e)||Ig.test(e)}function Ug(e){if(Buffer.byteLength(e,"utf8")>kg)return!1;let t=e.split(",");if(t.length>xg)return!1;let r=new Set;for(let o of t){let n=$(o);if(n.length===0)continue;let s=n.indexOf("="),i=s>0?n.slice(0,s):"",a=s>0?n.slice(s+1):"";if(!Gg(i)||!Rg.test(a)||r.has(i))return!1;r.add(i)}return!0}function Ir(e){return Mg.test(e)&&!Pg.test(e)}function jg(e){let t=$(e),r=t.indexOf("="),o=$(r>=0?t.slice(0,r):t),n=r>=0?$(t.slice(r+1)):void 0;return vr.test(o)&&(n===void 0||Ir(n))}function Bg(e){let t=$(e),r=t.split(";"),o=r[0],n=r.slice(1),s=o.indexOf("="),i=$(s>0?o.slice(0,s):""),a=s>0?$(o.slice(s+1)):"";if(!(!vr.test(i)||!Ir(a)||!n.every(jg)))return{key:i,serialized:t}}function qg(e,t){if(e===void 0)return;if(typeof e!="string"||Buffer.byteLength(e,"utf8")>Lg)throw new y("Invalid MCP baggage",403);let r=new Set(t),o=e.split(",");if(o.length>Ng)throw new y("Invalid MCP baggage",403);let n=[];for(let s of o){let i=Bg(s);if(!i)throw new y("Invalid MCP baggage",403);r.has(i.key)&&n.push(i.serialized)}return n.length>0?n.join(","):void 0}function hx(e,t={}){let r=h(e)&&h(e._meta)?e._meta:{},o=qg(r.baggage,t.baggageAllowlist??[]);return{...Fg(r),...o?{baggage:o}:{}}}function gx(e,t){return Or.run(structuredClone(e),t)}function yx(){let e=Or.getStore();return e?{...e}:void 0}async function bx(e){let t=S(e.policy.resourceMetadataUrl,"protected resource metadata URL",!0).href,r=[...new Set(e.policy.requiredScopes??[])];if(r.some(c=>!Ar.test(c)))throw new y("Invalid authorization scope",401);let o=`Bearer resource_metadata="${t}"`;if(new URL(e.requestUrl,e.policy.resource).searchParams.has("access_token"))throw new y("Access tokens must not appear in URI query parameters",401,o);let n=$g(e.headers,"authorization")?.match(/^Bearer ([^\s]+)$/iu);if(!n)throw new y("Missing or malformed bearer token",401,o);let s=n[1];if(Buffer.byteLength(s,"utf8")>Dg)throw new y("Missing or malformed bearer token",401,o);let i;try{i=await e.policy.verifyAccessToken(s)}catch{throw new y("Invalid bearer token",401,o)}let a=Array.isArray(i.audience)?i.audience:[i.audience];if(i.issuer!==e.policy.issuer||!a.includes(e.policy.resource))throw new y("Bearer token issuer or audience mismatch",401,o);let d=r.filter(c=>!i.scopes.includes(c));if(d.length>0)throw new y("Bearer token has insufficient scope",403,`${o}, scope="${d.join(" ")}"`);return{...i,audience:[...a],scopes:[...i.scopes]}}function Tx(e){let t=Sr("sha256").update(e.token).digest();return r=>{let o=Sr("sha256").update(r).digest();if(!Ag(t,o))throw new y("Invalid bearer token",401);return structuredClone(e.claims)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="46f5fe59-6b84-5c68-ad07-bb1329f4ea29")}catch{}})();var it="io.modelcontextprotocol/ui",Ee="2026-01-26",Pr="text/html;profile=mcp-app",Rr=Object.freeze({specVersion:Ee,mimeTypes:[Pr]});function Sx(e){let t=e.clientCapabilities.extensions;if(!h(t))return!1;let r=t[it];if(r===void 0)return!1;if(!h(r))throw new u("Invalid MCP Apps client capability",m.missingRequiredClientCapability,{requiredCapabilities:{extensions:{[it]:Rr}}});let o=r.mimeTypes,n=r.specVersion;if(!Array.isArray(o)||!o.includes(Pr)||n!==void 0&&n!==Ee)throw new u("Unsupported MCP Apps client capability",m.missingRequiredClientCapability,{requiredCapabilities:{extensions:{[it]:Rr}}});return!0}var zg={csp:{connectDomains:[],resourceDomains:[],frameDomains:[]},permissions:{},prefersBorder:!0},kr=Object.freeze([{id:"context",name:"Context explorer",description:"Inspect bounded project context, provenance, omissions, and token accounting.",toolName:"pm_context",uri:"ui://pm/context.html"},{id:"graph",name:"Relationship graph",description:"Explore typed relationships, explaining paths, and graph-governance evidence.",toolName:"pm_graph",uri:"ui://pm/graph.html"},{id:"plan",name:"Plan and milestone view",description:"Review durable plan steps, dependencies, decisions, discoveries, and validation state.",toolName:"pm_plan",uri:"ui://pm/plan.html"},{id:"assurance",name:"Assurance dashboard",description:"Inspect validation verdicts, evidence, omissions, and actionable recovery paths.",toolName:"pm_validate",uri:"ui://pm/assurance.html"},{id:"operations",name:"Long-operation view",description:"Inspect durable test and operation results without creating a second task store.",toolName:"pm_test",uri:"ui://pm/operations.html"}].map(e=>({...e,toolMeta:{resourceUri:e.uri,visibility:["model","app"]},resourceMeta:zg})));function Ex(e){return kr.find(t=>t.uri===e)}function Ax(e){let t=new Map(kr.map(r=>[r.toolName,r]));return e.map(r=>{let o=t.get(r.name);return o?{...r,_meta:{...r._meta,ui:o.toolMeta}}:{...r}})}function Mr(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function vx(e){let t=Mr(e.name),r=Mr(e.description),o=JSON.stringify({name:`pm-${e.id}-view`,version:Ee}),n=JSON.stringify(Ee);return`<!doctype html>
3
3
  <html lang="en">
4
4
  <head>
@@ -51,7 +51,9 @@ has_more:boolean;
51
51
  /** Latest substantive immutable event for each requested history stream. */
52
52
  export type LatestSubstantiveHistoryEvents = Readonly<Record<string,IndexedHistoryEvent>>;
53
53
  /** Rebuild the complete optional event projection from authoritative streams. */
54
- export declare function rebuildHistoryEventIndex(pmRoot:string):Promise<boolean>;
54
+ export declare function rebuildHistoryEventIndex(pmRoot:string,options?:{
55
+ lockWaitMs?:number;
56
+ }):Promise<boolean>;
55
57
  /**
56
58
  * Query authoritative history streams when the optional SQLite accelerator is
57
59
  * unavailable. The result preserves the index contract at higher read cost.
@@ -65,6 +67,11 @@ export declare function queryHistoryEventStreams(pmRoot:string,query:HistoryEven
65
67
  export declare function appendHistoryEntryWithEventIndex(historyPath:string,entry:HistoryEntry,append:() => Promise<void>):Promise<void>;
66
68
  /** Invalidate the optional event projection after a non-append rewrite. */
67
69
  export declare function removeHistoryEventIndexForHistoryPath(historyPath:string):Promise<void>;
70
+ /** Distinguish repairable cache absence/damage from transient concurrent writes. */
71
+ export declare function readHistoryEventIndexPage(pmRoot:string,query:HistoryEventIndexQuery):Promise<{
72
+ result:HistoryEventIndexQueryResult | null;
73
+ repair_needed:boolean;
74
+ }>;
68
75
  /** Query the optional event projection without scanning history streams. */
69
76
  export declare function queryHistoryEventIndex(pmRoot:string,query:HistoryEventIndexQuery):Promise<HistoryEventIndexQueryResult | null>;
70
77
  declare function collectLatestSubstantiveEvents(events:readonly IndexedHistoryEvent[],requested:ReadonlySet<string>):Record<string,IndexedHistoryEvent>;
@@ -1,5 +1,7 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="59e8ff0e-d2af-5f7a-a64b-1b86e075acdc")}catch{}})();import fs from"node:fs/promises";import path from"node:path";import{randomUUID}from"node:crypto";import{createRequire}from"node:module";import{isFileMissingError}from"../fs/fs-utils.js";import{acquireLock,captureProcessIdentity,isProcessIdentityAlive}from"../lock/lock.js";import{EXIT_CODE}from"../shared/constants.js";import{PmCliError}from"../shared/errors.js";import{isMillisecondPrecisionRfc3339DateTime}from"../shared/time.js";import{readHistoryEntries}from"./read.js";import{classifyHistoryEvent}from"./event-classification.js";import{loadDatabaseSync,loadStableDatabaseSync}from"../store/sqlite-runtime.js";const EVENT_INDEX_FILENAME="history-event-index.sqlite",EVENT_INDEX_VERSION="5",AUTHORITATIVE_HISTORY_CACHE_LIMIT=8,HISTORY_EVENT_INDEX_LOCK_ID="history-event-index",HISTORY_EVENT_INDEX_LOCK_TTL_SECONDS=300,HISTORY_EVENT_INDEX_LOCK_WAIT_MS=3e4,HISTORY_EVENT_INDEX_INVALIDATION_LOCK_ID="history-event-index-invalidation",HISTORY_EVENT_INDEX_INVALIDATION_DIRECTORY="history-event-index-invalidations",HISTORY_EVENT_INDEX_INVALIDATION_MAX_UNVERIFIED_AGE_MS=HISTORY_EVENT_INDEX_LOCK_TTL_SECONDS*2*1e3,HISTORY_INDEX_LOCK_CONTENDED=Symbol("history-index-lock-contended"),authoritativeHistoryCaches=new Map;function eventIndexPath(pmRoot){return path.join(pmRoot,"runtime",EVENT_INDEX_FILENAME)}function historyEventIndexInvalidationDirectory(pmRoot){return path.join(pmRoot,"runtime",HISTORY_EVENT_INDEX_INVALIDATION_DIRECTORY)}async function listHistoryEventIndexInvalidations(pmRoot){const entries=await fs.readdir(historyEventIndexInvalidationDirectory(pmRoot)).catch(error=>{if(isFileMissingError(error))return[];throw error});return{pending:entries.filter(name=>name.endsWith(".pending")).sort(),committed:entries.filter(name=>name.endsWith(".committed")).sort()}}async function recoverAbandonedHistoryEventIndexInvalidations(pmRoot){const invalidations=await listHistoryEventIndexInvalidations(pmRoot);return{pending:(await Promise.all(invalidations.pending.map(async name=>{const owner=/^(\d+)-(unknown|\d+)-(\d+)-.+\.pending$/u.exec(name);if(owner!==null){const processStartIdentity=owner[2];if(await isProcessIdentityAlive({pid:Number(owner[1]),...processStartIdentity==="unknown"?{}:{process_start_identity:processStartIdentity}},Math.max(0,Date.now()-Number(owner[3])),HISTORY_EVENT_INDEX_INVALIDATION_MAX_UNVERIFIED_AGE_MS))return name}return await fs.rm(path.join(historyEventIndexInvalidationDirectory(pmRoot),name),{force:!0}),null}))).filter(name=>name!==null),committed:invalidations.committed}}async function withHistoryEventIndexInvalidationLock(pmRoot,operation){const release=await acquireLock(pmRoot,HISTORY_EVENT_INDEX_INVALIDATION_LOCK_ID,HISTORY_EVENT_INDEX_LOCK_TTL_SECONDS,`history-event-index-invalidation:${process.pid}`,!1,!1,HISTORY_EVENT_INDEX_LOCK_WAIT_MS);try{return await operation()}finally{await release()}}async function beginHistoryEventIndexInvalidation(pmRoot){const directory=historyEventIndexInvalidationDirectory(pmRoot);await fs.mkdir(directory,{recursive:!0});const token=randomUUID(),processIdentity=await captureProcessIdentity(),pendingPath=path.join(directory,`${processIdentity.pid}-${processIdentity.process_start_identity??"unknown"}-${Date.now()}-${token}.pending`);return await fs.writeFile(pendingPath,`pending
2
- `,{flag:"wx"}),{pendingPath,committedPath:path.join(directory,`${token}.committed`)}}function sameInvalidationNames(left,right){return left.length===right.length&&left.every((name,index)=>name===right[index])}async function invalidateHistoryEventIndex(pmRoot){try{await fs.rm(eventIndexPath(pmRoot),{force:!0})}catch{}}async function withHistoryEventIndexLock(pmRoot,operation){const release=await acquireLock(pmRoot,HISTORY_EVENT_INDEX_LOCK_ID,HISTORY_EVENT_INDEX_LOCK_TTL_SECONDS,`history-event-index:${process.pid}`,!1,!1,HISTORY_EVENT_INDEX_LOCK_WAIT_MS);try{return await operation()}finally{await release()}}async function readAuthoritativeHistorySnapshot(pmRoot){const historyRoot=path.join(pmRoot,"history"),entries=await fs.readdir(historyRoot,{withFileTypes:!0}).catch(error=>{if(typeof error=="object"&&error!==null&&"code"in error&&error.code==="ENOENT")return[];throw error}),cached=authoritativeHistoryCaches.get(pmRoot)??{streams:new Map,ordered_events:[]},presentStreams=new Set;let changed=!authoritativeHistoryCaches.has(pmRoot);for(const historyFile of entries.filter(entry=>entry.isFile()&&entry.name.endsWith(".jsonl")).sort((left,right)=>left.name.localeCompare(right.name))){const streamId=historyFile.name.slice(0,-6);presentStreams.add(streamId);const historyPath=path.join(historyRoot,historyFile.name),stats=await fs.stat(historyPath,{bigint:!0}),signature=[stats.dev,stats.ino,stats.size,stats.mtimeNs,stats.ctimeNs].join(":");if(cached.streams.get(streamId)?.signature===signature)continue;const history=await readIndexableHistoryEntries(historyPath,streamId);cached.streams.set(streamId,{signature,byte_size:Number(stats.size),events:history.map((entry,streamOffset)=>({stream_id:streamId,stream_offset:streamOffset,entry}))}),changed=!0}for(const streamId of cached.streams.keys())presentStreams.has(streamId)||(cached.streams.delete(streamId),changed=!0);if(changed&&(cached.ordered_events=[...cached.streams.values()].flatMap(stream=>stream.events).sort(compareHistoryEventPosition)),authoritativeHistoryCaches.delete(pmRoot),authoritativeHistoryCaches.set(pmRoot,cached),authoritativeHistoryCaches.size>AUTHORITATIVE_HISTORY_CACHE_LIMIT){const oldestRoot=authoritativeHistoryCaches.keys().next().value;authoritativeHistoryCaches.delete(oldestRoot)}return{events:cached.ordered_events,stream_byte_sizes:new Map([...cached.streams].map(([streamId,stream])=>[streamId,stream.byte_size]))}}async function readIndexableHistoryEntries(historyPath,streamId){const entries=await readHistoryEntries(historyPath,streamId);for(const[index,entry]of entries.entries())if(typeof entry.ts!="string"||!isMillisecondPrecisionRfc3339DateTime(entry.ts.trim()))throw new PmCliError(`History for ${streamId} contains an invalid or sub-millisecond timestamp at line ${index+1}. Repair or restore the history stream and retry.`,EXIT_CODE.GENERIC_FAILURE,{code:"history_timestamp_invalid"});return entries.map(entry=>({...entry,ts:new Date(entry.ts.trim()).toISOString()}))}async function readAuthoritativeHistoryEvents(pmRoot){return(await readAuthoritativeHistorySnapshot(pmRoot)).events}let RuntimeDatabaseSync;function resolveDatabaseSync(){return RuntimeDatabaseSync!==void 0||(RuntimeDatabaseSync=loadStableDatabaseSync(process.versions.node,createRequire(import.meta.url))),RuntimeDatabaseSync}function createSchema(database){database.exec(`
1
+ (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="641c311a-5de1-579a-ba44-b9a49978dfe0")}catch{}})();import fs from"node:fs/promises";import path from"node:path";import{randomUUID}from"node:crypto";import{createRequire}from"node:module";import{setImmediate as yieldToEventLoop}from"node:timers/promises";import{isFileMissingError}from"../fs/fs-utils.js";import{acquireLock,captureProcessIdentity,isProcessIdentityAlive,hasUnexpiredLockOwner}from"../lock/lock.js";import{EXIT_CODE}from"../shared/constants.js";import{PmCliError}from"../shared/errors.js";import{isMillisecondPrecisionRfc3339DateTime}from"../shared/time.js";import{readHistoryEntries}from"./read.js";import{classifyHistoryEvent}from"./event-classification.js";import{loadDatabaseSync,loadStableDatabaseSync}from"../store/sqlite-runtime.js";const EVENT_INDEX_FILENAME="history-event-index.sqlite",EVENT_INDEX_VERSION="6",AUTHORITATIVE_HISTORY_CACHE_LIMIT=8,HISTORY_EVENT_INDEX_LOCK_ID="history-event-index",HISTORY_EVENT_INDEX_APPEND_OWNER_PREFIX="history-event-index:append:",HISTORY_EVENT_INDEX_REPAIR_COOLDOWN_MS=5e3,HISTORY_EVENT_INDEX_LOCK_TTL_SECONDS=300,HISTORY_EVENT_INDEX_LOCK_WAIT_MS=3e4,HISTORY_EVENT_INDEX_INVALIDATION_LOCK_ID="history-event-index-invalidation",HISTORY_EVENT_INDEX_INVALIDATION_DIRECTORY="history-event-index-invalidations",HISTORY_EVENT_INDEX_INVALIDATION_MAX_UNVERIFIED_AGE_MS=HISTORY_EVENT_INDEX_LOCK_TTL_SECONDS*2*1e3,HISTORY_INDEX_CHANGED=Symbol("history-index-changed"),authoritativeHistoryCaches=new Map;function eventIndexPath(pmRoot){return path.join(pmRoot,"runtime",EVENT_INDEX_FILENAME)}function refusedHistoryRepairPath(pmRoot){return path.join(pmRoot,"runtime","history-event-index-repair-deferred")}async function hasRecentRefusedHistoryRepair(pmRoot){try{const deferredAt=Number(await fs.readFile(refusedHistoryRepairPath(pmRoot),"utf8")),age=Date.now()-deferredAt;return age>=0&&age<HISTORY_EVENT_INDEX_REPAIR_COOLDOWN_MS}catch{return!1}}async function deferAutomaticHistoryRepair(pmRoot){try{await fs.writeFile(refusedHistoryRepairPath(pmRoot),`${Date.now()}
2
+ `)}catch{}}function historyEventIndexInvalidationDirectory(pmRoot){return path.join(pmRoot,"runtime",HISTORY_EVENT_INDEX_INVALIDATION_DIRECTORY)}async function listHistoryEventIndexInvalidations(pmRoot){const entries=await fs.readdir(historyEventIndexInvalidationDirectory(pmRoot)).catch(error=>{if(isFileMissingError(error))return[];throw error});return{pending:entries.filter(name=>name.endsWith(".pending")).sort(),committed:entries.filter(name=>name.endsWith(".committed")).sort()}}async function recoverAbandonedHistoryEventIndexInvalidations(pmRoot){const invalidations=await listHistoryEventIndexInvalidations(pmRoot);return{pending:(await Promise.all(invalidations.pending.map(async name=>{const owner=/^(\d+)-(unknown|\d+)-(\d+)-.+\.pending$/u.exec(name);if(owner!==null){const processStartIdentity=owner[2];if(await isProcessIdentityAlive({pid:Number(owner[1]),...processStartIdentity==="unknown"?{}:{process_start_identity:processStartIdentity}},Math.max(0,Date.now()-Number(owner[3])),HISTORY_EVENT_INDEX_INVALIDATION_MAX_UNVERIFIED_AGE_MS))return name}return await fs.rm(path.join(historyEventIndexInvalidationDirectory(pmRoot),name),{force:!0}),null}))).filter(name=>name!==null),committed:invalidations.committed}}async function withHistoryEventIndexInvalidationLock(pmRoot,operation,waitMs=HISTORY_EVENT_INDEX_LOCK_WAIT_MS){const release=await acquireLock(pmRoot,HISTORY_EVENT_INDEX_INVALIDATION_LOCK_ID,HISTORY_EVENT_INDEX_LOCK_TTL_SECONDS,`history-event-index-invalidation:${process.pid}`,!1,!1,waitMs,waitMs===0?{maxWaitMs:0}:void 0);try{return await operation()}finally{await release()}}async function beginHistoryEventIndexInvalidation(pmRoot){const directory=historyEventIndexInvalidationDirectory(pmRoot);await fs.mkdir(directory,{recursive:!0});const token=randomUUID(),processIdentity=await captureProcessIdentity(),pendingPath=path.join(directory,`${processIdentity.pid}-${processIdentity.process_start_identity??"unknown"}-${Date.now()}-${token}.pending`);return await fs.writeFile(pendingPath,`pending
3
+ `,{flag:"wx"}),{pendingPath,committedPath:path.join(directory,`${token}.committed`)}}function sameInvalidationNames(left,right){return left.length===right.length&&left.every((name,index)=>name===right[index])}async function invalidateHistoryEventIndex(pmRoot){try{await fs.rm(eventIndexPath(pmRoot),{force:!0})}catch{}}async function recordHistoryEventIndexInvalidation(pmRoot,retainCache){const directory=historyEventIndexInvalidationDirectory(pmRoot);await fs.mkdir(directory,{recursive:!0}),await fs.writeFile(path.join(directory,`${randomUUID()}${retainCache?".contended":""}.committed`),`committed
4
+ `,{flag:"wx"}),retainCache||await invalidateHistoryEventIndex(pmRoot)}function hasContendedHistoryEventIndexInvalidation(invalidations){return invalidations.committed.some(name=>name.endsWith(".contended.committed"))}function hasNativeHistoryEventIndexContention(pmRoot,Database){let database;try{return database=new Database(eventIndexPath(pmRoot)),database.exec("PRAGMA busy_timeout = 0"),database.exec("BEGIN EXCLUSIVE"),!1}catch(error){return isHistoryIndexSqliteContention(error)}finally{database?.close()}}async function historyEventIndexAppendIsActive(pmRoot,invalidations){return invalidations.pending.length>0||await hasUnexpiredLockOwner(pmRoot,HISTORY_EVENT_INDEX_LOCK_ID,HISTORY_EVENT_INDEX_APPEND_OWNER_PREFIX)}async function withHistoryEventIndexLock(pmRoot,operation,waitMs=HISTORY_EVENT_INDEX_LOCK_WAIT_MS,purpose="rebuild"){const release=await acquireLock(pmRoot,HISTORY_EVENT_INDEX_LOCK_ID,HISTORY_EVENT_INDEX_LOCK_TTL_SECONDS,`history-event-index:${purpose}:${process.pid}`,!1,!1,waitMs,waitMs===0?{maxWaitMs:0}:void 0);try{return await operation()}finally{await release()}}async function readAuthoritativeHistorySnapshot(pmRoot){const historyRoot=path.join(pmRoot,"history"),entries=await fs.readdir(historyRoot,{withFileTypes:!0}).catch(error=>{if(typeof error=="object"&&error!==null&&"code"in error&&error.code==="ENOENT")return[];throw error}),cached=authoritativeHistoryCaches.get(pmRoot)??{streams:new Map,ordered_events:[]},presentStreams=new Set;let changed=!authoritativeHistoryCaches.has(pmRoot);for(const historyFile of entries.filter(entry=>entry.isFile()&&entry.name.endsWith(".jsonl")).sort((left,right)=>left.name.localeCompare(right.name))){const streamId=historyFile.name.slice(0,-6);presentStreams.add(streamId);const historyPath=path.join(historyRoot,historyFile.name),stats=await fs.stat(historyPath,{bigint:!0}),signature=[stats.dev,stats.ino,stats.size,stats.mtimeNs,stats.ctimeNs].join(":");if(cached.streams.get(streamId)?.signature===signature)continue;const history=await readIndexableHistoryEntries(historyPath,streamId);cached.streams.set(streamId,{signature,byte_size:Number(stats.size),events:history.map((entry,streamOffset)=>({stream_id:streamId,stream_offset:streamOffset,entry}))}),changed=!0}for(const streamId of cached.streams.keys())presentStreams.has(streamId)||(cached.streams.delete(streamId),changed=!0);if(changed&&(cached.ordered_events=[...cached.streams.values()].flatMap(stream=>stream.events).sort(compareHistoryEventPosition)),authoritativeHistoryCaches.delete(pmRoot),authoritativeHistoryCaches.set(pmRoot,cached),authoritativeHistoryCaches.size>AUTHORITATIVE_HISTORY_CACHE_LIMIT){const oldestRoot=authoritativeHistoryCaches.keys().next().value;authoritativeHistoryCaches.delete(oldestRoot)}return{events:cached.ordered_events,stream_byte_sizes:new Map([...cached.streams].map(([streamId,stream])=>[streamId,stream.byte_size]))}}async function readIndexableHistoryEntries(historyPath,streamId){const entries=await readHistoryEntries(historyPath,streamId);for(const[index,entry]of entries.entries())if(typeof entry.ts!="string"||!isMillisecondPrecisionRfc3339DateTime(entry.ts.trim()))throw new PmCliError(`History for ${streamId} contains an invalid or sub-millisecond timestamp at line ${index+1}. Repair or restore the history stream and retry.`,EXIT_CODE.GENERIC_FAILURE,{code:"history_timestamp_invalid"});return entries.map(entry=>({...entry,ts:new Date(entry.ts.trim()).toISOString()}))}async function readAuthoritativeHistoryEvents(pmRoot){return(await readAuthoritativeHistorySnapshot(pmRoot)).events}let RuntimeDatabaseSync;function resolveDatabaseSync(){return RuntimeDatabaseSync!==void 0||(RuntimeDatabaseSync=loadStableDatabaseSync(process.versions.node,createRequire(import.meta.url))),RuntimeDatabaseSync}function createSchema(database){database.exec(`
3
5
  PRAGMA journal_mode = OFF;
4
6
  PRAGMA synchronous = OFF;
5
7
  CREATE TABLE metadata (
@@ -38,20 +40,19 @@
38
40
  stream_id, stream_offset, ts, author, agent_harness,
39
41
  agent_instance, op, event_class, entry_json
40
42
  ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(event.stream_id,event.stream_offset,entry.ts,entry.author,entry.agent_harness??null,entry.agent_instance??null,entry.op,classifyHistoryEvent(entry),JSON.stringify(entry))}function parseIndexedHistoryEvent(row){const entry=JSON.parse(String(row.entry_json));return typeof entry.ts!="string"||!isMillisecondPrecisionRfc3339DateTime(entry.ts.trim())?null:{stream_id:String(row.stream_id),stream_offset:Number(row.stream_offset),entry:{...entry,ts:new Date(entry.ts.trim()).toISOString()}}}function upsertStreamByteSize(database,streamId,byteSize){database.prepare(`INSERT INTO streams(stream_id, byte_size) VALUES (?, ?)
41
- ON CONFLICT(stream_id) DO UPDATE SET byte_size = excluded.byte_size`).run(streamId,byteSize)}async function rebuildHistoryEventIndex(pmRoot){const Database=resolveDatabaseSync();return Database?withHistoryEventIndexLock(pmRoot,async()=>{let invalidations;try{invalidations=await withHistoryEventIndexInvalidationLock(pmRoot,()=>recoverAbandonedHistoryEventIndexInvalidations(pmRoot))}catch(error){if(error instanceof PmCliError&&error.code==="lock_conflict")return!1;throw error}if(invalidations.pending.length>0)return!1;const targetPath=eventIndexPath(pmRoot);await fs.mkdir(path.dirname(targetPath),{recursive:!0});const temporaryPath=`${targetPath}.${randomUUID()}.tmp`;let database;try{database=new Database(temporaryPath),createSchema(database),database.exec("BEGIN IMMEDIATE");const authoritative=await readAuthoritativeHistorySnapshot(pmRoot);for(const event of authoritative.events)insertEvent(database,event);for(const[streamId,byteSize]of authoritative.stream_byte_sizes)upsertStreamByteSize(database,streamId,byteSize);database.exec("COMMIT"),database.close(),database=void 0;const published=await withHistoryEventIndexInvalidationLock(pmRoot,async()=>{const current=await recoverAbandonedHistoryEventIndexInvalidations(pmRoot);return current.pending.length>0||!sameInvalidationNames(invalidations.committed,current.committed)?!1:(await fs.rm(targetPath,{force:!0}),await fs.rename(temporaryPath,targetPath),await Promise.all(invalidations.committed.map(name=>fs.rm(path.join(historyEventIndexInvalidationDirectory(pmRoot),name),{force:!0}))),!0)});return published||await fs.rm(temporaryPath,{force:!0}),published}catch(error){throw database?.close(),await fs.rm(temporaryPath,{force:!0}),error}}):!1}function matchesSet(value,accepted){return!accepted||accepted.length===0||accepted.includes(value)}function compareHistoryEventPosition(left,right){return left.entry.ts.localeCompare(right.entry.ts)||left.stream_id.localeCompare(right.stream_id)||left.stream_offset-right.stream_offset}function canonicalHistoryQueryTimestamp(value){const milliseconds=Date.parse(value);return Number.isFinite(milliseconds)?new Date(milliseconds).toISOString():value}function isInsideHistoryEventWindow(event,query){if(query.after_ts!==void 0&&query.after_stream_id!==void 0&&query.after_stream_offset!==void 0){if(compareHistoryEventPosition(event,{stream_id:query.after_stream_id,stream_offset:query.after_stream_offset,entry:{...event.entry,ts:canonicalHistoryQueryTimestamp(query.after_ts)}})<=0)return!1}else if(query.since_ts!==void 0&&event.entry.ts<canonicalHistoryQueryTimestamp(query.since_ts))return!1;return!0}function matchesHistoryEventHarness(event,query){return!query.harnesses||query.harnesses.length===0||query.harnesses.includes(event.entry.agent_harness??"")?!0:event.entry.agent_harness===void 0&&(query.harness_alias_authors??[]).includes(event.entry.author)}function matchesHistoryEventQuery(event,query){return!isInsideHistoryEventWindow(event,query)||!matchesSet(event.entry.op,query.ops)||!matchesSet(event.entry.author,query.authors)||!matchesSet(event.entry.agent_instance??"",query.agent_instances)||!matchesSet(event.stream_id,query.stream_ids)||!matchesHistoryEventHarness(event,query)?!1:(query.provenance??[]).every(predicate=>{const value=event.entry.agent_provenance?.[predicate.dimension]?.value;return value!==void 0&&predicate.values.includes(value)})}async function queryHistoryEventStreams(pmRoot,query){const limit=Math.max(0,Math.floor(query.limit)),rows=(await readAuthoritativeHistoryEvents(pmRoot)).filter(event=>matchesHistoryEventQuery(event,query)).slice(0,limit+1);return{events:rows.slice(0,query.limit),has_more:rows.length>query.limit}}async function appendHistoryEntryWithEventIndex(historyPath,entry,append){const pmRoot=path.dirname(path.dirname(historyPath)),Database=resolveDatabaseSync();if(!Database){await append();return}let authoritativeAppendCommitted=!1;try{await withHistoryEventIndexLock(pmRoot,async()=>{const targetPath=eventIndexPath(pmRoot);try{await fs.access(targetPath)}catch{await append();return}let database;try{if(database=new Database(targetPath),database.prepare("SELECT value FROM metadata WHERE key = 'version'").get()?.value!==EVENT_INDEX_VERSION)throw new TypeError("Unsupported history event index version")}catch{database?.close(),await fs.rm(targetPath,{force:!0}),await append();return}try{database.exec("PRAGMA busy_timeout = 5000"),database.exec("BEGIN IMMEDIATE")}catch(error){throw database.close(),error}let appended=!1;try{await append(),appended=!0,authoritativeAppendCommitted=!0;const streamId=path.basename(historyPath,".jsonl"),offset=database.prepare("SELECT COALESCE(MAX(stream_offset), -1) + 1 AS value FROM events WHERE stream_id = ?").get(streamId);insertEvent(database,{stream_id:streamId,stream_offset:Number(offset.value),entry}),upsertStreamByteSize(database,streamId,(await fs.stat(historyPath)).size),database.exec("COMMIT"),database.close()}catch(error){if(database?.close(),!appended)throw error;await invalidateHistoryEventIndex(pmRoot)}})}catch(error){if(authoritativeAppendCommitted){await invalidateHistoryEventIndex(pmRoot);return}if(!(error instanceof PmCliError)||error.code!=="lock_conflict")throw error;let pendingMarkerPath;try{await withHistoryEventIndexInvalidationLock(pmRoot,async()=>{const marker=await beginHistoryEventIndexInvalidation(pmRoot);pendingMarkerPath=marker.pendingPath;try{await append(),authoritativeAppendCommitted=!0}catch(appendError){throw await fs.rm(marker.pendingPath,{force:!0}),appendError}await fs.rename(marker.pendingPath,marker.committedPath),await invalidateHistoryEventIndex(pmRoot)})}catch(fallbackError){if(authoritativeAppendCommitted){await invalidateHistoryEventIndex(pmRoot);try{await fs.rm(pendingMarkerPath,{force:!0})}catch{}return}throw fallbackError}}}async function removeHistoryEventIndexForHistoryPath(historyPath){await fs.rm(eventIndexPath(path.dirname(path.dirname(historyPath))),{force:!0})}function appendSetPredicate(clauses,parameters,column,values){!values||values.length===0||(clauses.push(`${column} IN (${values.map(()=>"?").join(", ")})`),parameters.push(...values))}function appendHarnessPredicate(clauses,parameters,harnesses,aliasAuthors){if(!harnesses||harnesses.length===0)return;const harnessPlaceholders=harnesses.map(()=>"?").join(", "),aliases=aliasAuthors??[];if(aliases.length>0){clauses.push(`(agent_harness IN (${harnessPlaceholders}) OR (agent_harness IS NULL AND author IN (${aliases.map(()=>"?").join(", ")})))`),parameters.push(...harnesses,...aliases);return}clauses.push(`agent_harness IN (${harnessPlaceholders})`),parameters.push(...harnesses)}async function openSettledHistoryEventIndex(pmRoot,Database){const invalidations=await recoverAbandonedHistoryEventIndexInvalidations(pmRoot);if(invalidations.pending.length>0||invalidations.committed.length>0)return;const database=new Database(eventIndexPath(pmRoot),{readOnly:!0});try{if(database.prepare("SELECT value FROM metadata WHERE key = 'version'").get()?.value===EVENT_INDEX_VERSION)return database}catch(error){throw database.close(),error}database.close()}async function queryHistoryEventIndex(pmRoot,query){const Database=resolveDatabaseSync();if(!Database)return null;const clauses=[],parameters=[];if(query.after_ts!==void 0&&query.after_stream_id!==void 0&&query.after_stream_offset!==void 0){clauses.push("(ts > ? OR (ts = ? AND stream_id > ?) OR (ts = ? AND stream_id = ? AND stream_offset > ?))");const afterTimestamp=canonicalHistoryQueryTimestamp(query.after_ts);parameters.push(afterTimestamp,afterTimestamp,query.after_stream_id,afterTimestamp,query.after_stream_id,query.after_stream_offset)}else query.since_ts!==void 0&&(clauses.push("ts >= ?"),parameters.push(canonicalHistoryQueryTimestamp(query.since_ts)));appendSetPredicate(clauses,parameters,"op",query.ops),appendSetPredicate(clauses,parameters,"author",query.authors),appendHarnessPredicate(clauses,parameters,query.harnesses,query.harness_alias_authors),appendSetPredicate(clauses,parameters,"agent_instance",query.agent_instances);for(const predicate of query.provenance??[])clauses.push(`json_extract(entry_json, '$.agent_provenance.${predicate.dimension}.value') IN (${predicate.values.map(()=>"?").join(", ")})`),parameters.push(...predicate.values);appendSetPredicate(clauses,parameters,"stream_id",query.stream_ids);const where=clauses.length===0?"":` WHERE ${clauses.join(" AND ")}`;let database;try{return await withHistoryEventIndexLock(pmRoot,async()=>withHistoryEventIndexInvalidationLock(pmRoot,async()=>{if(database=await openSettledHistoryEventIndex(pmRoot,Database),!database)return null;const validationStreamIds=await historyIndexValidationStreamIds(database,pmRoot,query.stream_ids);if(!await historyIndexMatchesStreamSizes(database,pmRoot,validationStreamIds))return database.close(),database=void 0,null;const rows=database.prepare(`SELECT stream_id, stream_offset, entry_json
42
- FROM events${where}
43
- ORDER BY ts, stream_id, stream_offset
44
- LIMIT ?`).all(...parameters,Math.max(0,Math.floor(query.limit))+1),events=rows.slice(0,query.limit).map(parseIndexedHistoryEvent);return database.close(),database=void 0,events.includes(null)?null:{events,has_more:rows.length>query.limit}}))}catch{return database?.close(),null}}function collectLatestSubstantiveEvents(events,requested){const latest=Object.create(null);for(const event of events){if(!requested.has(event.stream_id)||classifyHistoryEvent(event.entry)!=="substantive")continue;const current=latest[event.stream_id];(current===void 0||compareHistoryEventPosition(current,event)<0)&&(latest[event.stream_id]=event)}return latest}async function readHistoryStreamByteSize(pmRoot,streamId){if(path.basename(streamId)!==streamId)return null;try{return(await fs.stat(path.join(pmRoot,"history",`${streamId}.jsonl`))).size}catch(error){if(isFileMissingError(error))return 0;throw error}}async function historyIndexMatchesStreamSizes(database,pmRoot,streamIds){for(let start=0;start<streamIds.length;start+=500){const chunk=streamIds.slice(start,start+500),storedSizes=new Map(database.prepare(`SELECT stream_id, byte_size FROM streams
45
- WHERE stream_id IN (${chunk.map(()=>"?").join(", ")})`).all(...chunk).map(row=>[String(row.stream_id),Number(row.byte_size)])),currentSizes=await Promise.all(chunk.map(streamId=>readHistoryStreamByteSize(pmRoot,streamId)));for(const[index,currentSize]of currentSizes.entries()){if(currentSize===null)return!1;const streamId=chunk[index],storedSize=storedSizes.get(streamId);if(!(currentSize===0&&storedSize===void 0)&&currentSize!==storedSize)return!1}}return!0}async function historyIndexValidationStreamIds(database,pmRoot,requestedStreamIds){if(requestedStreamIds&&requestedStreamIds.length>0)return[...new Set(requestedStreamIds.filter(streamId=>streamId.trim().length>0))];const indexed=database.prepare("SELECT stream_id FROM streams").all().map(row=>String(row.stream_id)),authoritative=await fs.readdir(path.join(pmRoot,"history"),{withFileTypes:!0}).then(entries=>entries.filter(entry=>entry.isFile()&&entry.name.endsWith(".jsonl")).map(entry=>entry.name.slice(0,-6))).catch(error=>{if(isFileMissingError(error))return[];throw error});return[...new Set([...indexed,...authoritative])]}async function readIndexedLatestSubstantiveEvents(Database,pmRoot,streamIds,requested){if(!Database)return null;let database;try{return await withHistoryEventIndexLock(pmRoot,async()=>withHistoryEventIndexInvalidationLock(pmRoot,async()=>{if(database=await openSettledHistoryEventIndex(pmRoot,Database),!database)return null;if(!await historyIndexMatchesStreamSizes(database,pmRoot,streamIds))return database.close(),database=void 0,null;const indexed=[];for(let start=0;start<streamIds.length;start+=500){const chunk=streamIds.slice(start,start+500),parsed=database.prepare(`SELECT stream_id, stream_offset, entry_json
46
- FROM (
47
- SELECT stream_id, stream_offset, entry_json,
48
- ROW_NUMBER() OVER (
49
- PARTITION BY stream_id
50
- ORDER BY ts DESC, stream_offset DESC
51
- ) AS recency_rank
52
- FROM events
53
- WHERE event_class = 'substantive'
54
- AND stream_id IN (${chunk.map(()=>"?").join(", ")})
55
- )
56
- WHERE recency_rank = 1`).all(...chunk).map(parseIndexedHistoryEvent);if(parsed.includes(null))return database.close(),database=void 0,null;indexed.push(...parsed)}return database.close(),database=void 0,collectLatestSubstantiveEvents(indexed,requested)}))}catch(error){return database?.close(),error instanceof PmCliError&&error.code==="lock_conflict"?HISTORY_INDEX_LOCK_CONTENDED:null}}async function readLatestSubstantiveHistoryEvents(pmRoot,streamIds){const uniqueIds=[...new Set(streamIds.filter(id=>id.trim().length>0&&path.basename(id)===id))];if(uniqueIds.length===0)return{};const requested=new Set(uniqueIds),Database=resolveDatabaseSync(),indexed=await readIndexedLatestSubstantiveEvents(Database,pmRoot,uniqueIds,requested);if(indexed!==null&&indexed!==HISTORY_INDEX_LOCK_CONTENDED)return indexed;if(Database&&indexed!==HISTORY_INDEX_LOCK_CONTENDED)try{if(await rebuildHistoryEventIndex(pmRoot)){const rebuilt=await readIndexedLatestSubstantiveEvents(Database,pmRoot,uniqueIds,requested);if(rebuilt!==null&&rebuilt!==HISTORY_INDEX_LOCK_CONTENDED)return rebuilt}}catch{}const authoritative=[];return await Promise.all(uniqueIds.map(async streamId=>{const historyPath=path.join(pmRoot,"history",`${streamId}.jsonl`);(await readIndexableHistoryEntries(historyPath,streamId).catch(error=>{if(error instanceof PmCliError&&error.code==="history_timestamp_invalid")return[];throw error})).forEach((entry,streamOffset)=>{authoritative.push({stream_id:streamId,stream_offset:streamOffset,entry})})})),collectLatestSubstantiveEvents(authoritative,requested)}const _testOnly={collectLatestSubstantiveEvents,loadDatabaseSync,loadStableDatabaseSync,setDatabaseSync(databaseSync){const previous=RuntimeDatabaseSync;return RuntimeDatabaseSync=databaseSync,()=>{RuntimeDatabaseSync=previous}}};export{_testOnly,appendHistoryEntryWithEventIndex,queryHistoryEventIndex,queryHistoryEventStreams,readLatestSubstantiveHistoryEvents,rebuildHistoryEventIndex,removeHistoryEventIndexForHistoryPath};
43
+ ON CONFLICT(stream_id) DO UPDATE SET byte_size = excluded.byte_size`).run(streamId,byteSize)}async function rebuildHistoryEventIndex(pmRoot,options={}){const Database=resolveDatabaseSync();return Database?withHistoryEventIndexLock(pmRoot,async()=>{let invalidations;try{invalidations=await withHistoryEventIndexInvalidationLock(pmRoot,()=>recoverAbandonedHistoryEventIndexInvalidations(pmRoot),options.lockWaitMs)}catch(error){if(error instanceof PmCliError&&error.code==="lock_conflict")return!1;throw error}if(invalidations.pending.length>0||hasContendedHistoryEventIndexInvalidation(invalidations)&&hasNativeHistoryEventIndexContention(pmRoot,Database))return!1;const targetPath=eventIndexPath(pmRoot);await fs.mkdir(path.dirname(targetPath),{recursive:!0});const temporaryPath=`${targetPath}.${randomUUID()}.tmp`;let database;try{database=new Database(temporaryPath),createSchema(database),database.exec("BEGIN IMMEDIATE");const authoritative=await readAuthoritativeHistorySnapshot(pmRoot);await populateHistoryEventIndex(database,authoritative),database.exec("COMMIT"),database.close(),database=void 0;const published=await withHistoryEventIndexInvalidationLock(pmRoot,async()=>{const current=await recoverAbandonedHistoryEventIndexInvalidations(pmRoot);return current.pending.length>0||!sameInvalidationNames(invalidations.committed,current.committed)||hasContendedHistoryEventIndexInvalidation(current)&&hasNativeHistoryEventIndexContention(pmRoot,Database)?!1:(await fs.rm(targetPath,{force:!0}),await fs.rename(temporaryPath,targetPath),!0)},options.lockWaitMs);return published&&await Promise.all(invalidations.committed.map(name=>fs.rm(path.join(historyEventIndexInvalidationDirectory(pmRoot),name),{force:!0}))),published||(await deferAutomaticHistoryRepair(pmRoot),await fs.rm(temporaryPath,{force:!0})),published}catch(error){throw await deferAutomaticHistoryRepair(pmRoot),database?.close(),await fs.rm(temporaryPath,{force:!0}),error}},options.lockWaitMs):!1}async function populateHistoryEventIndex(database,snapshot){let inserted=0;for(const event of snapshot.events)insertEvent(database,event),++inserted%500===0&&await yieldToEventLoop();for(const[streamId,byteSize]of snapshot.stream_byte_sizes)upsertStreamByteSize(database,streamId,byteSize),++inserted%500===0&&await yieldToEventLoop()}function matchesSet(value,accepted){return!accepted||accepted.length===0||accepted.includes(value)}function compareHistoryEventPosition(left,right){return left.entry.ts.localeCompare(right.entry.ts)||left.stream_id.localeCompare(right.stream_id)||left.stream_offset-right.stream_offset}function canonicalHistoryQueryTimestamp(value){const milliseconds=Date.parse(value);return Number.isFinite(milliseconds)?new Date(milliseconds).toISOString():value}function isInsideHistoryEventWindow(event,query){if(query.after_ts!==void 0&&query.after_stream_id!==void 0&&query.after_stream_offset!==void 0){if(compareHistoryEventPosition(event,{stream_id:query.after_stream_id,stream_offset:query.after_stream_offset,entry:{...event.entry,ts:canonicalHistoryQueryTimestamp(query.after_ts)}})<=0)return!1}else if(query.since_ts!==void 0&&event.entry.ts<canonicalHistoryQueryTimestamp(query.since_ts))return!1;return!0}function matchesHistoryEventHarness(event,query){return!query.harnesses||query.harnesses.length===0||query.harnesses.includes(event.entry.agent_harness??"")?!0:event.entry.agent_harness===void 0&&(query.harness_alias_authors??[]).includes(event.entry.author)}function matchesHistoryEventQuery(event,query){return!isInsideHistoryEventWindow(event,query)||!matchesSet(event.entry.op,query.ops)||!matchesSet(event.entry.author,query.authors)||!matchesSet(event.entry.agent_instance??"",query.agent_instances)||!matchesSet(event.stream_id,query.stream_ids)||!matchesHistoryEventHarness(event,query)?!1:(query.provenance??[]).every(predicate=>{const value=event.entry.agent_provenance?.[predicate.dimension]?.value;return value!==void 0&&predicate.values.includes(value)})}async function queryHistoryEventStreams(pmRoot,query){const limit=Math.max(0,Math.floor(query.limit)),rows=(await readAuthoritativeHistoryEvents(pmRoot)).filter(event=>matchesHistoryEventQuery(event,query)).slice(0,limit+1);return{events:rows.slice(0,query.limit),has_more:rows.length>query.limit}}async function historyEventIndexHasAppendBase(database,historyPath){const stored=database.prepare("SELECT byte_size FROM streams WHERE stream_id = ?").get(path.basename(historyPath,".jsonl"));let actualSize=0;try{actualSize=(await fs.stat(historyPath)).size}catch(error){if(!isFileMissingError(error))throw error}return Number(stored?.byte_size??0)===actualSize}async function appendHistoryEntryWithEventIndex(historyPath,entry,append){const pmRoot=path.dirname(path.dirname(historyPath)),Database=resolveDatabaseSync();let authoritativeAppendCommitted=!1;const appendAuthoritative=async()=>{await append(),authoritativeAppendCommitted=!0};if(!Database){await appendUnindexedHistory(pmRoot,appendAuthoritative);return}try{await withHistoryEventIndexLock(pmRoot,async()=>{const targetPath=eventIndexPath(pmRoot);try{await fs.access(targetPath)}catch{await appendAuthoritative();return}let database;try{if(database=new Database(targetPath),database.prepare("SELECT value FROM metadata WHERE key = 'version'").get()?.value!==EVENT_INDEX_VERSION)throw new TypeError("Unsupported history event index version");if(!await historyEventIndexHasAppendBase(database,historyPath))throw new TypeError("Stale history event index append base")}catch(error){if(database?.close(),isHistoryIndexSqliteContention(error))throw error;await recordHistoryEventIndexInvalidation(pmRoot,!0),await appendAuthoritative();return}try{database.exec("PRAGMA busy_timeout = 0"),database.exec("BEGIN IMMEDIATE")}catch(error){throw database.close(),error}let appended=!1;try{await appendAuthoritative(),appended=!0;const streamId=path.basename(historyPath,".jsonl"),offset=database.prepare("SELECT COALESCE(MAX(stream_offset), -1) + 1 AS value FROM events WHERE stream_id = ?").get(streamId);insertEvent(database,{stream_id:streamId,stream_offset:Number(offset.value),entry}),upsertStreamByteSize(database,streamId,(await fs.stat(historyPath)).size),database.exec("COMMIT"),database.close()}catch(error){if(database?.close(),!appended)throw error;await recordHistoryEventIndexInvalidation(pmRoot,isHistoryIndexSqliteContention(error))}},0,"append")}catch(error){if(authoritativeAppendCommitted){await invalidateHistoryEventIndex(pmRoot);return}if(!isHistoryIndexWriteContention(error))throw error;await appendUnindexedHistory(pmRoot,appendAuthoritative,isHistoryIndexSqliteContention(error))}}async function appendUnindexedHistory(pmRoot,append,nativeContention=!1){let authoritativeAppendCommitted=!1,pendingMarkerPath;try{await withHistoryEventIndexInvalidationLock(pmRoot,async()=>{const contended=nativeContention||hasContendedHistoryEventIndexInvalidation(await listHistoryEventIndexInvalidations(pmRoot)),marker=await beginHistoryEventIndexInvalidation(pmRoot);pendingMarkerPath=marker.pendingPath;try{await append(),authoritativeAppendCommitted=!0}catch(appendError){throw await fs.rm(marker.pendingPath,{force:!0}),appendError}await fs.rename(marker.pendingPath,contended?marker.committedPath.replace(/\.committed$/u,".contended.committed"):marker.committedPath),contended||await invalidateHistoryEventIndex(pmRoot)})}catch(fallbackError){if(authoritativeAppendCommitted){await invalidateHistoryEventIndex(pmRoot);try{await fs.rm(pendingMarkerPath,{force:!0})}catch{}return}throw fallbackError}}async function removeHistoryEventIndexForHistoryPath(historyPath){await fs.rm(eventIndexPath(path.dirname(path.dirname(historyPath))),{force:!0})}function appendSetPredicate(clauses,parameters,column,values){!values||values.length===0||(clauses.push(`${column} IN (${values.map(()=>"?").join(", ")})`),parameters.push(...values))}function appendHarnessPredicate(clauses,parameters,harnesses,aliasAuthors){if(!harnesses||harnesses.length===0)return;const harnessPlaceholders=harnesses.map(()=>"?").join(", "),aliases=aliasAuthors??[];if(aliases.length>0){clauses.push(`(agent_harness IN (${harnessPlaceholders}) OR (agent_harness IS NULL AND author IN (${aliases.map(()=>"?").join(", ")})))`),parameters.push(...harnesses,...aliases);return}clauses.push(`agent_harness IN (${harnessPlaceholders})`),parameters.push(...harnesses)}async function readHistoryEventIndexSnapshot(pmRoot,Database,requestedStreamIds,read){let database;try{const invalidations=await listHistoryEventIndexInvalidations(pmRoot);if(await historyEventIndexAppendIsActive(pmRoot,invalidations))return HISTORY_INDEX_CHANGED;const before=await historyEventIndexSignature(pmRoot);if(invalidations.committed.length>0)return hasContendedHistoryEventIndexInvalidation(invalidations)&&hasNativeHistoryEventIndexContention(pmRoot,Database)?HISTORY_INDEX_CHANGED:null;if(database=new Database(eventIndexPath(pmRoot),{readOnly:!0}),database.exec("BEGIN"),database.prepare("SELECT value FROM metadata WHERE key = 'version'").get()?.value!==EVENT_INDEX_VERSION)return null;const result=read(database);if(result===null)return null;const storedSizes=readHistoryEventIndexStreamSizes(database,requestedStreamIds),completed=database;database=void 0,completed.close();const streamIds=await historyIndexValidationStreamIds([...storedSizes.keys()],pmRoot,requestedStreamIds),sizesMatch=await historyIndexMatchesStreamSizes(storedSizes,pmRoot,streamIds),current=await listHistoryEventIndexInvalidations(pmRoot);return current.committed.length>0||await historyEventIndexAppendIsActive(pmRoot,current)||before!==await historyEventIndexSignature(pmRoot)?HISTORY_INDEX_CHANGED:sizesMatch?result:null}catch(error){return isHistoryIndexSqliteContention(error)?HISTORY_INDEX_CHANGED:null}finally{database?.close()}}function isHistoryIndexSqliteContention(error){return typeof error=="object"&&error!==null&&"errcode"in error&&[5,6].includes(error.errcode)}function isHistoryIndexWriteContention(error){return isHistoryIndexSqliteContention(error)||error instanceof PmCliError&&error.code==="lock_conflict"}function readHistoryEventIndexStreamSizes(database,requestedStreamIds){const storedSizes=new Map,ids=requestedStreamIds&&requestedStreamIds.length>0?[...new Set(requestedStreamIds)]:void 0;if(ids===void 0)for(const row of database.prepare("SELECT stream_id, byte_size FROM streams").all())storedSizes.set(String(row.stream_id),Number(row.byte_size));else for(let start=0;start<ids.length;start+=500){const chunk=ids.slice(start,start+500);for(const row of database.prepare(`SELECT stream_id, byte_size FROM streams WHERE stream_id IN (${chunk.map(()=>"?").join(", ")})`).all(...chunk))storedSizes.set(String(row.stream_id),Number(row.byte_size))}return storedSizes}async function historyEventIndexSignature(pmRoot){const stats=await fs.stat(eventIndexPath(pmRoot),{bigint:!0});return[stats.dev,stats.ino,stats.size,stats.mtimeNs,stats.ctimeNs].join(":")}async function readHistoryEventIndexPage(pmRoot,query){const Database=resolveDatabaseSync();if(!Database)return{result:null,repair_needed:!1};const clauses=[],parameters=[];if(query.after_ts!==void 0&&query.after_stream_id!==void 0&&query.after_stream_offset!==void 0){clauses.push("(ts > ? OR (ts = ? AND stream_id > ?) OR (ts = ? AND stream_id = ? AND stream_offset > ?))");const afterTimestamp=canonicalHistoryQueryTimestamp(query.after_ts);parameters.push(afterTimestamp,afterTimestamp,query.after_stream_id,afterTimestamp,query.after_stream_id,query.after_stream_offset)}else query.since_ts!==void 0&&(clauses.push("ts >= ?"),parameters.push(canonicalHistoryQueryTimestamp(query.since_ts)));appendSetPredicate(clauses,parameters,"op",query.ops),appendSetPredicate(clauses,parameters,"author",query.authors),appendHarnessPredicate(clauses,parameters,query.harnesses,query.harness_alias_authors),appendSetPredicate(clauses,parameters,"agent_instance",query.agent_instances);for(const predicate of query.provenance??[])clauses.push(`json_extract(entry_json, '$.agent_provenance.${predicate.dimension}.value') IN (${predicate.values.map(()=>"?").join(", ")})`),parameters.push(...predicate.values);appendSetPredicate(clauses,parameters,"stream_id",query.stream_ids);const where=clauses.length===0?"":` WHERE ${clauses.join(" AND ")}`,attempt=await readHistoryEventIndexSnapshot(pmRoot,Database,query.stream_ids,database=>{const rows=database.prepare(`SELECT stream_id, stream_offset, entry_json
44
+ FROM events${where}
45
+ ORDER BY ts, stream_id, stream_offset
46
+ LIMIT ?`).all(...parameters,Math.max(0,Math.floor(query.limit))+1),events=rows.slice(0,query.limit).map(parseIndexedHistoryEvent);return events.includes(null)?null:{events,has_more:rows.length>query.limit}});return{result:attempt===HISTORY_INDEX_CHANGED?null:attempt,repair_needed:attempt===null&&!await hasRecentRefusedHistoryRepair(pmRoot)}}async function queryHistoryEventIndex(pmRoot,query){return(await readHistoryEventIndexPage(pmRoot,query)).result}function collectLatestSubstantiveEvents(events,requested){const latest=Object.create(null);for(const event of events){if(!requested.has(event.stream_id)||classifyHistoryEvent(event.entry)!=="substantive")continue;const current=latest[event.stream_id];(current===void 0||compareHistoryEventPosition(current,event)<0)&&(latest[event.stream_id]=event)}return latest}async function readHistoryStreamByteSize(pmRoot,streamId){if(path.basename(streamId)!==streamId)return null;try{return(await fs.stat(path.join(pmRoot,"history",`${streamId}.jsonl`))).size}catch(error){if(isFileMissingError(error))return 0;throw error}}async function historyIndexMatchesStreamSizes(storedSizes,pmRoot,streamIds){for(let start=0;start<streamIds.length;start+=500){const chunk=streamIds.slice(start,start+500),currentSizes=await Promise.all(chunk.map(streamId=>readHistoryStreamByteSize(pmRoot,streamId)));for(const[index,currentSize]of currentSizes.entries()){if(currentSize===null)return!1;const streamId=chunk[index],storedSize=storedSizes.get(streamId);if(!(currentSize===0&&storedSize===void 0)&&currentSize!==storedSize)return!1}}return!0}async function historyIndexValidationStreamIds(indexed,pmRoot,requestedStreamIds){if(requestedStreamIds&&requestedStreamIds.length>0)return[...new Set(requestedStreamIds.filter(streamId=>streamId.trim().length>0))];const authoritative=await fs.readdir(path.join(pmRoot,"history"),{withFileTypes:!0}).then(entries=>entries.filter(entry=>entry.isFile()&&entry.name.endsWith(".jsonl")).map(entry=>entry.name.slice(0,-6))).catch(error=>{if(isFileMissingError(error))return[];throw error});return[...new Set([...indexed,...authoritative])]}async function readIndexedLatestSubstantiveEvents(Database,pmRoot,streamIds,requested){return Database?readHistoryEventIndexSnapshot(pmRoot,Database,streamIds,database=>{const indexed=[];for(let start=0;start<streamIds.length;start+=500){const chunk=streamIds.slice(start,start+500),parsed=database.prepare(`SELECT stream_id, stream_offset, entry_json
47
+ FROM (
48
+ SELECT stream_id, stream_offset, entry_json,
49
+ ROW_NUMBER() OVER (
50
+ PARTITION BY stream_id
51
+ ORDER BY ts DESC, stream_offset DESC
52
+ ) AS recency_rank
53
+ FROM events
54
+ WHERE event_class = 'substantive'
55
+ AND stream_id IN (${chunk.map(()=>"?").join(", ")})
56
+ )
57
+ WHERE recency_rank = 1`).all(...chunk).map(parseIndexedHistoryEvent);if(parsed.includes(null))return null;indexed.push(...parsed)}return collectLatestSubstantiveEvents(indexed,requested)}):null}async function readLatestSubstantiveHistoryEvents(pmRoot,streamIds){const uniqueIds=[...new Set(streamIds.filter(id=>id.trim().length>0&&path.basename(id)===id))];if(uniqueIds.length===0)return{};const requested=new Set(uniqueIds),Database=resolveDatabaseSync(),indexed=await readIndexedLatestSubstantiveEvents(Database,pmRoot,uniqueIds,requested);if(indexed!==null&&indexed!==HISTORY_INDEX_CHANGED)return indexed;if(Database&&indexed!==HISTORY_INDEX_CHANGED&&!await hasRecentRefusedHistoryRepair(pmRoot))try{if(await rebuildHistoryEventIndex(pmRoot,{lockWaitMs:0})){const rebuilt=await readIndexedLatestSubstantiveEvents(Database,pmRoot,uniqueIds,requested);if(rebuilt!==null&&rebuilt!==HISTORY_INDEX_CHANGED)return rebuilt}}catch{}const authoritative=[];return await Promise.all(uniqueIds.map(async streamId=>{const historyPath=path.join(pmRoot,"history",`${streamId}.jsonl`);(await readIndexableHistoryEntries(historyPath,streamId).catch(error=>{if(error instanceof PmCliError&&error.code==="history_timestamp_invalid")return[];throw error})).forEach((entry,streamOffset)=>{authoritative.push({stream_id:streamId,stream_offset:streamOffset,entry})})})),collectLatestSubstantiveEvents(authoritative,requested)}const _testOnly={collectLatestSubstantiveEvents,loadDatabaseSync,loadStableDatabaseSync,setDatabaseSync(databaseSync){const previous=RuntimeDatabaseSync;return RuntimeDatabaseSync=databaseSync,()=>{RuntimeDatabaseSync=previous}}};export{_testOnly,appendHistoryEntryWithEventIndex,queryHistoryEventIndex,queryHistoryEventStreams,readHistoryEventIndexPage,readLatestSubstantiveHistoryEvents,rebuildHistoryEventIndex,removeHistoryEventIndexForHistoryPath};
57
58
  //# sourceMappingURL=event-index.js.map