@contractspec/bundle.library 3.9.0 → 3.9.3

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 (724) hide show
  1. package/.turbo/turbo-build.log +612 -608
  2. package/CHANGELOG.md +89 -0
  3. package/README.md +2 -1
  4. package/dist/__tests__/mocks/prisma.d.ts +5 -5
  5. package/dist/application/context-storage/index.js +1 -1
  6. package/dist/application/index.js +6 -6
  7. package/dist/application/mcp/cliMcp.js +2 -2
  8. package/dist/application/mcp/cliMcp.onboarding.js +1 -1
  9. package/dist/application/mcp/common.js +1 -1
  10. package/dist/application/mcp/contractsMcp.js +2 -2
  11. package/dist/application/mcp/contractsMcpAdoptionTools.js +1 -1
  12. package/dist/application/mcp/contractsMcpResources.js +2 -2
  13. package/dist/application/mcp/contractsMcpTools.js +1 -1
  14. package/dist/application/mcp/docsMcp.catalog.js +2 -2
  15. package/dist/application/mcp/docsMcp.data.js +1 -1
  16. package/dist/application/mcp/docsMcp.js +3 -3
  17. package/dist/application/mcp/docsMcp.prompts.js +3 -3
  18. package/dist/application/mcp/docsMcp.reference.js +2 -2
  19. package/dist/application/mcp/docsMcp.resources.js +2 -2
  20. package/dist/application/mcp/docsMcp.tools.js +2 -2
  21. package/dist/application/mcp/index.js +6 -6
  22. package/dist/application/mcp/internalMcp.js +2 -2
  23. package/dist/application/mcp/normalizeMcpRequest.js +1 -1
  24. package/dist/application/mcp/providerRankingMcp.js +1 -1
  25. package/dist/bundles/LibraryBundle.d.ts +19 -111
  26. package/dist/bundles/LibraryBundle.js +1 -1
  27. package/dist/bundles/index.js +1 -1
  28. package/dist/components/docs/DocsIndexPage.js +2 -2
  29. package/dist/components/docs/advanced/AdvancedMCPPage.js +3 -3
  30. package/dist/components/docs/advanced/AdvancedOverlayEditorPage.js +1 -1
  31. package/dist/components/docs/advanced/AdvancedRenderersPage.js +2 -2
  32. package/dist/components/docs/advanced/AdvancedSpecExperimentsPage.js +4 -4
  33. package/dist/components/docs/advanced/AdvancedTelemetryPage.js +2 -2
  34. package/dist/components/docs/advanced/AdvancedWorkflowMonitoringPage.js +2 -2
  35. package/dist/components/docs/advanced/index.js +9 -9
  36. package/dist/components/docs/architecture/ArchitectureAppConfigPage.js +6 -6
  37. package/dist/components/docs/architecture/ArchitectureControlPlanePage.js +3 -3
  38. package/dist/components/docs/architecture/ArchitectureIntegrationBindingPage.js +7 -7
  39. package/dist/components/docs/architecture/ArchitectureKnowledgeBindingPage.js +6 -6
  40. package/dist/components/docs/architecture/ArchitectureMultiTenancyPage.js +2 -2
  41. package/dist/components/docs/architecture/ArchitectureOverviewPage.js +1 -1
  42. package/dist/components/docs/architecture/index.js +20 -20
  43. package/dist/components/docs/comparison/ComparisonAutomationPlatformsPage.js +1 -1
  44. package/dist/components/docs/comparison/ComparisonEnterprisePlatformsPage.js +1 -1
  45. package/dist/components/docs/comparison/ComparisonInternalToolBuildersPage.js +1 -1
  46. package/dist/components/docs/comparison/ComparisonOverviewPage.js +1 -1
  47. package/dist/components/docs/comparison/ComparisonWindmillPage.js +1 -1
  48. package/dist/components/docs/comparison/ComparisonWorkflowEnginesPage.js +1 -1
  49. package/dist/components/docs/comparison/index.js +1 -1
  50. package/dist/components/docs/docsManifest.js +1 -1
  51. package/dist/components/docs/ecosystem/IntegrationsPage.js +2 -2
  52. package/dist/components/docs/ecosystem/PluginsPage.js +4 -4
  53. package/dist/components/docs/ecosystem/RegistryPage.js +4 -4
  54. package/dist/components/docs/ecosystem/TemplatesPage.js +3 -3
  55. package/dist/components/docs/ecosystem/index.js +11 -11
  56. package/dist/components/docs/examples/DocsExamplesPage.js +1 -1
  57. package/dist/components/docs/examples/ExampleShowcasePage.js +2 -2
  58. package/dist/components/docs/examples/exampleShowcaseData.js +2 -2
  59. package/dist/components/docs/examples/index.js +2 -2
  60. package/dist/components/docs/generated/docs-index.generated.js +1 -1
  61. package/dist/components/docs/generated/index.d.ts +7 -1
  62. package/dist/components/docs/generated/index.js +1 -1
  63. package/dist/components/docs/generated/loader.js +1 -1
  64. package/dist/components/docs/getting-started/CLIPage.js +4 -4
  65. package/dist/components/docs/getting-started/CompatibilityPage.js +1 -1
  66. package/dist/components/docs/getting-started/DataViewTutorialPage.js +4 -4
  67. package/dist/components/docs/getting-started/DeveloperToolsPage.js +1 -1
  68. package/dist/components/docs/getting-started/HelloWorldPage.js +5 -5
  69. package/dist/components/docs/getting-started/InstallationPage.js +3 -3
  70. package/dist/components/docs/getting-started/StartHerePage.js +3 -3
  71. package/dist/components/docs/getting-started/TroubleshootingPage.js +2 -2
  72. package/dist/components/docs/getting-started/VSCodeExtensionPage.js +1 -1
  73. package/dist/components/docs/getting-started/getting-started.docblocks.js +2 -2
  74. package/dist/components/docs/getting-started/index.js +17 -17
  75. package/dist/components/docs/guides/GuideCIDiffGatingPage.js +2 -2
  76. package/dist/components/docs/guides/GuideConnectInRepoPage.js +6 -6
  77. package/dist/components/docs/guides/GuideContractTypesPage.js +6 -6
  78. package/dist/components/docs/guides/GuideDocsPipelinePage.js +3 -3
  79. package/dist/components/docs/guides/GuideFirstModuleBundlePage.js +4 -4
  80. package/dist/components/docs/guides/GuideGenerateDocsClientsSchemasPage.js +2 -2
  81. package/dist/components/docs/guides/GuideHostBuilderWorkbenchPage.js +7 -7
  82. package/dist/components/docs/guides/GuideImportExistingCodebasesPage.js +8 -8
  83. package/dist/components/docs/guides/GuideNextjsOneEndpointPage.js +6 -6
  84. package/dist/components/docs/guides/GuideReleaseCapsulesPage.js +3 -3
  85. package/dist/components/docs/guides/GuideSpecValidationTypingPage.js +4 -4
  86. package/dist/components/docs/guides/GuidesIndexPage.js +2 -2
  87. package/dist/components/docs/guides/index.js +43 -43
  88. package/dist/components/docs/index.js +375 -255
  89. package/dist/components/docs/integrations/IntegrationsCircuitBreakersPage.js +2 -2
  90. package/dist/components/docs/integrations/IntegrationsElevenLabsPage.js +3 -3
  91. package/dist/components/docs/integrations/IntegrationsGithubPage.js +2 -2
  92. package/dist/components/docs/integrations/IntegrationsGmailPage.js +3 -3
  93. package/dist/components/docs/integrations/IntegrationsGoogleCalendarPage.js +3 -3
  94. package/dist/components/docs/integrations/IntegrationsHealthRoutingPage.js +2 -2
  95. package/dist/components/docs/integrations/IntegrationsMistralPage.js +2 -2
  96. package/dist/components/docs/integrations/IntegrationsOpenAIPage.js +2 -2
  97. package/dist/components/docs/integrations/IntegrationsOverviewPage.js +1 -1
  98. package/dist/components/docs/integrations/IntegrationsPostmarkPage.js +2 -2
  99. package/dist/components/docs/integrations/IntegrationsPowensPage.js +2 -2
  100. package/dist/components/docs/integrations/IntegrationsQdrantPage.js +5 -5
  101. package/dist/components/docs/integrations/IntegrationsResendPage.js +3 -3
  102. package/dist/components/docs/integrations/IntegrationsS3Page.js +4 -4
  103. package/dist/components/docs/integrations/IntegrationsSlackPage.js +2 -2
  104. package/dist/components/docs/integrations/IntegrationsSpecModelPage.js +2 -2
  105. package/dist/components/docs/integrations/IntegrationsStripePage.js +2 -2
  106. package/dist/components/docs/integrations/IntegrationsTwilioPage.js +3 -3
  107. package/dist/components/docs/integrations/IntegrationsWhatsappMetaPage.js +2 -2
  108. package/dist/components/docs/integrations/IntegrationsWhatsappTwilioPage.js +2 -2
  109. package/dist/components/docs/integrations/index.js +39 -39
  110. package/dist/components/docs/intent/ContractFirstApiPage.js +2 -2
  111. package/dist/components/docs/intent/DeterministicCodegenPage.js +2 -2
  112. package/dist/components/docs/intent/GenerateClientFromSchemaPage.js +7 -7
  113. package/dist/components/docs/intent/OpenapiAlternativePage.js +3 -3
  114. package/dist/components/docs/intent/SchemaValidationTypescriptPage.js +4 -4
  115. package/dist/components/docs/intent/SpecDrivenDevelopmentPage.js +2 -2
  116. package/dist/components/docs/intent/index.js +15 -15
  117. package/dist/components/docs/intent/intent-pages.docblocks.js +1 -1
  118. package/dist/components/docs/knowledge/KnowledgeCategoriesPage.js +2 -2
  119. package/dist/components/docs/knowledge/KnowledgeExamplesPage.js +2 -2
  120. package/dist/components/docs/knowledge/KnowledgeOverviewPage.js +1 -1
  121. package/dist/components/docs/knowledge/KnowledgeSourcesPage.js +2 -2
  122. package/dist/components/docs/knowledge/KnowledgeSpacesPage.js +2 -2
  123. package/dist/components/docs/knowledge/index.js +5 -5
  124. package/dist/components/docs/libraries/LibrariesAccessibilityPage.js +3 -3
  125. package/dist/components/docs/libraries/LibrariesAiAgentPage.js +3 -3
  126. package/dist/components/docs/libraries/LibrariesAnalyticsPage.js +4 -4
  127. package/dist/components/docs/libraries/LibrariesContentGenPage.js +2 -2
  128. package/dist/components/docs/libraries/LibrariesContractsPage.js +2 -2
  129. package/dist/components/docs/libraries/LibrariesCostTrackingPage.js +3 -3
  130. package/dist/components/docs/libraries/LibrariesCrossPlatformUIPage.content.d.ts +67 -0
  131. package/dist/components/docs/libraries/LibrariesCrossPlatformUIPage.content.js +86 -0
  132. package/dist/components/docs/libraries/LibrariesCrossPlatformUIPage.d.ts +1 -0
  133. package/dist/components/docs/libraries/LibrariesCrossPlatformUIPage.js +86 -0
  134. package/dist/components/docs/libraries/LibrariesDataBackendPage.js +2 -2
  135. package/dist/components/docs/libraries/LibrariesDataViewsPage.js +3 -3
  136. package/dist/components/docs/libraries/LibrariesDesignSystemPage.js +38 -2
  137. package/dist/components/docs/libraries/LibrariesEvolutionPage.js +4 -4
  138. package/dist/components/docs/libraries/LibrariesGraphQLPage.js +2 -2
  139. package/dist/components/docs/libraries/LibrariesGrowthPage.js +3 -3
  140. package/dist/components/docs/libraries/LibrariesMultiTenancyPage.js +3 -3
  141. package/dist/components/docs/libraries/LibrariesObservabilityPage.js +5 -5
  142. package/dist/components/docs/libraries/LibrariesOverlayEnginePage.js +4 -4
  143. package/dist/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  144. package/dist/components/docs/libraries/LibrariesPersonalizationPage.js +4 -4
  145. package/dist/components/docs/libraries/LibrariesProgressiveDeliveryPage.js +3 -3
  146. package/dist/components/docs/libraries/LibrariesResiliencePage.js +4 -4
  147. package/dist/components/docs/libraries/LibrariesRuntimePage.js +2 -2
  148. package/dist/components/docs/libraries/LibrariesSLOPage.js +3 -3
  149. package/dist/components/docs/libraries/LibrariesSchemaPage.js +3 -3
  150. package/dist/components/docs/libraries/LibrariesSupportBotPage.js +3 -3
  151. package/dist/components/docs/libraries/LibrariesTestingPage.js +3 -3
  152. package/dist/components/docs/libraries/LibrariesUIKitPage.js +2 -2
  153. package/dist/components/docs/libraries/LibrariesUIKitWebPage.js +2 -2
  154. package/dist/components/docs/libraries/LibrariesWorkflowComposerPage.js +3 -3
  155. package/dist/components/docs/libraries/LibrariesWorkflowsPage.js +2 -2
  156. package/dist/components/docs/libraries/index.d.ts +1 -0
  157. package/dist/components/docs/libraries/index.js +173 -53
  158. package/dist/components/docs/manifesto/ManifestoPage.js +1 -1
  159. package/dist/components/docs/ops/AutoEvolutionOpsPage.js +2 -2
  160. package/dist/components/docs/ops/DistributedTracingOpsPage.js +2 -2
  161. package/dist/components/docs/ops/index.js +3 -3
  162. package/dist/components/docs/ops/ops-lifecycle.docblocks.js +2 -2
  163. package/dist/components/docs/ops/ops-runbooks-a.docblocks.js +2 -2
  164. package/dist/components/docs/ops/ops-runbooks-b.docblocks.js +2 -2
  165. package/dist/components/docs/ops/ops-slo-tenant.docblocks.js +2 -2
  166. package/dist/components/docs/ops/ops-top.docs.js +2 -2
  167. package/dist/components/docs/ops/ops.docs.js +6 -6
  168. package/dist/components/docs/product/product.docblocks.js +2 -2
  169. package/dist/components/docs/reference/DocsMarkdownContent.js +2 -2
  170. package/dist/components/docs/reference/DocsReferenceContent.js +3 -3
  171. package/dist/components/docs/reference/DocsReferenceIndexClient.js +2 -2
  172. package/dist/components/docs/reference/DocsReferenceIndexPage.js +2 -2
  173. package/dist/components/docs/reference/DocsReferencePage.js +3 -3
  174. package/dist/components/docs/reference/docsMarkdownParser.js +2 -2
  175. package/dist/components/docs/reference/index.js +4 -4
  176. package/dist/components/docs/safety/SafetyAuditingPage.js +2 -2
  177. package/dist/components/docs/safety/SafetyMigrationsPage.js +2 -2
  178. package/dist/components/docs/safety/SafetyOverviewPage.js +1 -1
  179. package/dist/components/docs/safety/SafetyPDPPage.js +2 -2
  180. package/dist/components/docs/safety/SafetySecurityTrustPage.js +1 -1
  181. package/dist/components/docs/safety/SafetySigningPage.js +3 -3
  182. package/dist/components/docs/safety/SafetyTenantIsolationPage.js +2 -2
  183. package/dist/components/docs/safety/index.js +7 -7
  184. package/dist/components/docs/shared/StudioPrompt.js +1 -1
  185. package/dist/components/docs/specs/SpecsBuilderControlPlanePage.js +4 -4
  186. package/dist/components/docs/specs/SpecsCapabilitiesPage.js +2 -2
  187. package/dist/components/docs/specs/SpecsConnectPage.js +2 -2
  188. package/dist/components/docs/specs/SpecsDataViewsPage.js +2 -2
  189. package/dist/components/docs/specs/SpecsModuleBundlesPage.js +3 -3
  190. package/dist/components/docs/specs/SpecsOverlaysPage.js +2 -2
  191. package/dist/components/docs/specs/SpecsOverviewPage.js +1 -1
  192. package/dist/components/docs/specs/SpecsPolicyPage.js +3 -3
  193. package/dist/components/docs/specs/SpecsWorkflowsPage.js +2 -2
  194. package/dist/components/docs/specs/index.js +13 -13
  195. package/dist/components/docs/studio/StudioBYOKPage.js +1 -1
  196. package/dist/components/docs/studio/StudioDeploymentsPage.js +1 -1
  197. package/dist/components/docs/studio/StudioGettingStartedPage.js +1 -1
  198. package/dist/components/docs/studio/StudioIntegrationsPage.js +1 -1
  199. package/dist/components/docs/studio/StudioOverviewPage.js +1 -1
  200. package/dist/components/docs/studio/StudioVisualBuilderPage.js +1 -1
  201. package/dist/components/docs/studio/index.js +1 -1
  202. package/dist/components/docs/tech/contracts/tech-docs.docblocks.js +2 -2
  203. package/dist/components/integrations/index.js +2 -2
  204. package/dist/components/integrations/molecules/IntegrationCard.js +1 -1
  205. package/dist/components/integrations/organisms/IntegrationMarketplace.js +1 -1
  206. package/dist/components/integrations/organisms/IntegrationSettings.js +2 -2
  207. package/dist/components/integrations/organisms/KnowledgeSourceList.js +1 -1
  208. package/dist/components/legal/PrivacyTemplate.js +1 -1
  209. package/dist/components/legal/TermsTemplate.js +1 -1
  210. package/dist/components/legal/index.js +1 -1
  211. package/dist/components/shared/FeatureGateNotice.js +1 -1
  212. package/dist/components/shared/index.js +1 -1
  213. package/dist/components/shell/WorkspaceHeader.js +1 -1
  214. package/dist/components/shell/WorkspaceProjectShellLayout.js +1 -1
  215. package/dist/components/shell/WorkspaceShellRenderer.js +1 -1
  216. package/dist/components/shell/WorkspaceSidebar.js +1 -1
  217. package/dist/components/shell/index.js +1 -1
  218. package/dist/components/templates/engine/index.js +1 -1
  219. package/dist/components/templates/index.js +11 -11
  220. package/dist/components/templates/messaging/ConversationList.js +2 -2
  221. package/dist/components/templates/messaging/MessageComposer.js +4 -4
  222. package/dist/components/templates/messaging/MessageThread.js +3 -3
  223. package/dist/components/templates/messaging/MessagingWorkspace.js +5 -5
  224. package/dist/components/templates/messaging/index.js +5 -5
  225. package/dist/components/templates/recipes/LanguageSwitcher.js +1 -1
  226. package/dist/components/templates/recipes/RecipeCard.js +1 -1
  227. package/dist/components/templates/recipes/RecipeDetail.js +1 -1
  228. package/dist/components/templates/recipes/RecipeList.js +3 -3
  229. package/dist/components/templates/recipes/index.js +3 -3
  230. package/dist/components/templates/todos/FilterBar.js +1 -1
  231. package/dist/components/templates/todos/TaskForm.js +2 -2
  232. package/dist/components/templates/todos/TaskItem.js +1 -1
  233. package/dist/components/templates/todos/TaskList.js +5 -5
  234. package/dist/components/templates/todos/index.js +5 -5
  235. package/dist/config/contractspec-blueprint.js +1 -1
  236. package/dist/config/contractspec-branding.js +1 -1
  237. package/dist/config/contractspec-routes.js +1 -1
  238. package/dist/config/index.js +1 -1
  239. package/dist/features/contracts-registry.js +1 -1
  240. package/dist/features/docs/docs.contracts.js +1 -1
  241. package/dist/features/docs/index.js +1 -1
  242. package/dist/features/docs.feature.js +1 -1
  243. package/dist/features/index.js +1 -1
  244. package/dist/features/mcp.feature.js +1 -1
  245. package/dist/features/presentations.feature.js +1 -1
  246. package/dist/features/registry.js +1 -1
  247. package/dist/index.d.ts +1 -0
  248. package/dist/index.js +382 -262
  249. package/dist/infrastructure/elysia/index.js +1 -1
  250. package/dist/infrastructure/elysia/logger.js +1 -1
  251. package/dist/infrastructure/index.js +1 -1
  252. package/dist/libs/email/client.js +1 -1
  253. package/dist/libs/email/contact.js +3 -3
  254. package/dist/libs/email/newsletter.js +3 -3
  255. package/dist/libs/email/utils.js +2 -2
  256. package/dist/libs/email/waitlist-application.js +3 -3
  257. package/dist/libs/email/waitlist.js +3 -3
  258. package/dist/libs/email.js +6 -6
  259. package/dist/libs/posthog/client.js +1 -1
  260. package/dist/libs/posthog/native.js +1 -1
  261. package/dist/libs/posthog/server.js +1 -1
  262. package/dist/libs/pricing-examples.js +1 -1
  263. package/dist/node/application/context-storage/index.js +1 -1
  264. package/dist/node/application/index.js +6 -6
  265. package/dist/node/application/mcp/cliMcp.js +2 -2
  266. package/dist/node/application/mcp/cliMcp.onboarding.js +1 -1
  267. package/dist/node/application/mcp/common.js +1 -1
  268. package/dist/node/application/mcp/contractsMcp.js +2 -2
  269. package/dist/node/application/mcp/contractsMcpAdoptionTools.js +1 -1
  270. package/dist/node/application/mcp/contractsMcpResources.js +2 -2
  271. package/dist/node/application/mcp/contractsMcpTools.js +1 -1
  272. package/dist/node/application/mcp/docsMcp.catalog.js +2 -2
  273. package/dist/node/application/mcp/docsMcp.data.js +1 -1
  274. package/dist/node/application/mcp/docsMcp.js +3 -3
  275. package/dist/node/application/mcp/docsMcp.prompts.js +3 -3
  276. package/dist/node/application/mcp/docsMcp.reference.js +2 -2
  277. package/dist/node/application/mcp/docsMcp.resources.js +2 -2
  278. package/dist/node/application/mcp/docsMcp.tools.js +2 -2
  279. package/dist/node/application/mcp/index.js +6 -6
  280. package/dist/node/application/mcp/internalMcp.js +2 -2
  281. package/dist/node/application/mcp/normalizeMcpRequest.js +1 -1
  282. package/dist/node/application/mcp/providerRankingMcp.js +1 -1
  283. package/dist/node/bundles/LibraryBundle.js +1 -1
  284. package/dist/node/bundles/index.js +1 -1
  285. package/dist/node/components/docs/DocsIndexPage.js +2 -2
  286. package/dist/node/components/docs/advanced/AdvancedMCPPage.js +3 -3
  287. package/dist/node/components/docs/advanced/AdvancedOverlayEditorPage.js +1 -1
  288. package/dist/node/components/docs/advanced/AdvancedRenderersPage.js +2 -2
  289. package/dist/node/components/docs/advanced/AdvancedSpecExperimentsPage.js +4 -4
  290. package/dist/node/components/docs/advanced/AdvancedTelemetryPage.js +2 -2
  291. package/dist/node/components/docs/advanced/AdvancedWorkflowMonitoringPage.js +2 -2
  292. package/dist/node/components/docs/advanced/index.js +9 -9
  293. package/dist/node/components/docs/architecture/ArchitectureAppConfigPage.js +6 -6
  294. package/dist/node/components/docs/architecture/ArchitectureControlPlanePage.js +3 -3
  295. package/dist/node/components/docs/architecture/ArchitectureIntegrationBindingPage.js +7 -7
  296. package/dist/node/components/docs/architecture/ArchitectureKnowledgeBindingPage.js +6 -6
  297. package/dist/node/components/docs/architecture/ArchitectureMultiTenancyPage.js +2 -2
  298. package/dist/node/components/docs/architecture/ArchitectureOverviewPage.js +1 -1
  299. package/dist/node/components/docs/architecture/index.js +20 -20
  300. package/dist/node/components/docs/comparison/ComparisonAutomationPlatformsPage.js +1 -1
  301. package/dist/node/components/docs/comparison/ComparisonEnterprisePlatformsPage.js +1 -1
  302. package/dist/node/components/docs/comparison/ComparisonInternalToolBuildersPage.js +1 -1
  303. package/dist/node/components/docs/comparison/ComparisonOverviewPage.js +1 -1
  304. package/dist/node/components/docs/comparison/ComparisonWindmillPage.js +1 -1
  305. package/dist/node/components/docs/comparison/ComparisonWorkflowEnginesPage.js +1 -1
  306. package/dist/node/components/docs/comparison/index.js +1 -1
  307. package/dist/node/components/docs/docsManifest.js +1 -1
  308. package/dist/node/components/docs/ecosystem/IntegrationsPage.js +2 -2
  309. package/dist/node/components/docs/ecosystem/PluginsPage.js +4 -4
  310. package/dist/node/components/docs/ecosystem/RegistryPage.js +4 -4
  311. package/dist/node/components/docs/ecosystem/TemplatesPage.js +3 -3
  312. package/dist/node/components/docs/ecosystem/index.js +11 -11
  313. package/dist/node/components/docs/examples/DocsExamplesPage.js +1 -1
  314. package/dist/node/components/docs/examples/ExampleShowcasePage.js +2 -2
  315. package/dist/node/components/docs/examples/exampleShowcaseData.js +2 -2
  316. package/dist/node/components/docs/examples/index.js +2 -2
  317. package/dist/node/components/docs/generated/docs-index.generated.js +1 -1
  318. package/dist/node/components/docs/generated/index.js +1 -1
  319. package/dist/node/components/docs/generated/loader.js +1 -1
  320. package/dist/node/components/docs/getting-started/CLIPage.js +4 -4
  321. package/dist/node/components/docs/getting-started/CompatibilityPage.js +1 -1
  322. package/dist/node/components/docs/getting-started/DataViewTutorialPage.js +4 -4
  323. package/dist/node/components/docs/getting-started/DeveloperToolsPage.js +1 -1
  324. package/dist/node/components/docs/getting-started/HelloWorldPage.js +5 -5
  325. package/dist/node/components/docs/getting-started/InstallationPage.js +3 -3
  326. package/dist/node/components/docs/getting-started/StartHerePage.js +3 -3
  327. package/dist/node/components/docs/getting-started/TroubleshootingPage.js +2 -2
  328. package/dist/node/components/docs/getting-started/VSCodeExtensionPage.js +1 -1
  329. package/dist/node/components/docs/getting-started/getting-started.docblocks.js +2 -2
  330. package/dist/node/components/docs/getting-started/index.js +17 -17
  331. package/dist/node/components/docs/guides/GuideCIDiffGatingPage.js +2 -2
  332. package/dist/node/components/docs/guides/GuideConnectInRepoPage.js +6 -6
  333. package/dist/node/components/docs/guides/GuideContractTypesPage.js +6 -6
  334. package/dist/node/components/docs/guides/GuideDocsPipelinePage.js +3 -3
  335. package/dist/node/components/docs/guides/GuideFirstModuleBundlePage.js +4 -4
  336. package/dist/node/components/docs/guides/GuideGenerateDocsClientsSchemasPage.js +2 -2
  337. package/dist/node/components/docs/guides/GuideHostBuilderWorkbenchPage.js +7 -7
  338. package/dist/node/components/docs/guides/GuideImportExistingCodebasesPage.js +8 -8
  339. package/dist/node/components/docs/guides/GuideNextjsOneEndpointPage.js +6 -6
  340. package/dist/node/components/docs/guides/GuideReleaseCapsulesPage.js +3 -3
  341. package/dist/node/components/docs/guides/GuideSpecValidationTypingPage.js +4 -4
  342. package/dist/node/components/docs/guides/GuidesIndexPage.js +2 -2
  343. package/dist/node/components/docs/guides/index.js +43 -43
  344. package/dist/node/components/docs/index.js +375 -255
  345. package/dist/node/components/docs/integrations/IntegrationsCircuitBreakersPage.js +2 -2
  346. package/dist/node/components/docs/integrations/IntegrationsElevenLabsPage.js +3 -3
  347. package/dist/node/components/docs/integrations/IntegrationsGithubPage.js +2 -2
  348. package/dist/node/components/docs/integrations/IntegrationsGmailPage.js +3 -3
  349. package/dist/node/components/docs/integrations/IntegrationsGoogleCalendarPage.js +3 -3
  350. package/dist/node/components/docs/integrations/IntegrationsHealthRoutingPage.js +2 -2
  351. package/dist/node/components/docs/integrations/IntegrationsMistralPage.js +2 -2
  352. package/dist/node/components/docs/integrations/IntegrationsOpenAIPage.js +2 -2
  353. package/dist/node/components/docs/integrations/IntegrationsOverviewPage.js +1 -1
  354. package/dist/node/components/docs/integrations/IntegrationsPostmarkPage.js +2 -2
  355. package/dist/node/components/docs/integrations/IntegrationsPowensPage.js +2 -2
  356. package/dist/node/components/docs/integrations/IntegrationsQdrantPage.js +5 -5
  357. package/dist/node/components/docs/integrations/IntegrationsResendPage.js +3 -3
  358. package/dist/node/components/docs/integrations/IntegrationsS3Page.js +4 -4
  359. package/dist/node/components/docs/integrations/IntegrationsSlackPage.js +2 -2
  360. package/dist/node/components/docs/integrations/IntegrationsSpecModelPage.js +2 -2
  361. package/dist/node/components/docs/integrations/IntegrationsStripePage.js +2 -2
  362. package/dist/node/components/docs/integrations/IntegrationsTwilioPage.js +3 -3
  363. package/dist/node/components/docs/integrations/IntegrationsWhatsappMetaPage.js +2 -2
  364. package/dist/node/components/docs/integrations/IntegrationsWhatsappTwilioPage.js +2 -2
  365. package/dist/node/components/docs/integrations/index.js +39 -39
  366. package/dist/node/components/docs/intent/ContractFirstApiPage.js +2 -2
  367. package/dist/node/components/docs/intent/DeterministicCodegenPage.js +2 -2
  368. package/dist/node/components/docs/intent/GenerateClientFromSchemaPage.js +7 -7
  369. package/dist/node/components/docs/intent/OpenapiAlternativePage.js +3 -3
  370. package/dist/node/components/docs/intent/SchemaValidationTypescriptPage.js +4 -4
  371. package/dist/node/components/docs/intent/SpecDrivenDevelopmentPage.js +2 -2
  372. package/dist/node/components/docs/intent/index.js +15 -15
  373. package/dist/node/components/docs/intent/intent-pages.docblocks.js +1 -1
  374. package/dist/node/components/docs/knowledge/KnowledgeCategoriesPage.js +2 -2
  375. package/dist/node/components/docs/knowledge/KnowledgeExamplesPage.js +2 -2
  376. package/dist/node/components/docs/knowledge/KnowledgeOverviewPage.js +1 -1
  377. package/dist/node/components/docs/knowledge/KnowledgeSourcesPage.js +2 -2
  378. package/dist/node/components/docs/knowledge/KnowledgeSpacesPage.js +2 -2
  379. package/dist/node/components/docs/knowledge/index.js +5 -5
  380. package/dist/node/components/docs/libraries/LibrariesAccessibilityPage.js +3 -3
  381. package/dist/node/components/docs/libraries/LibrariesAiAgentPage.js +3 -3
  382. package/dist/node/components/docs/libraries/LibrariesAnalyticsPage.js +4 -4
  383. package/dist/node/components/docs/libraries/LibrariesContentGenPage.js +2 -2
  384. package/dist/node/components/docs/libraries/LibrariesContractsPage.js +2 -2
  385. package/dist/node/components/docs/libraries/LibrariesCostTrackingPage.js +3 -3
  386. package/dist/node/components/docs/libraries/LibrariesCrossPlatformUIPage.content.js +85 -0
  387. package/dist/node/components/docs/libraries/LibrariesCrossPlatformUIPage.js +85 -0
  388. package/dist/node/components/docs/libraries/LibrariesDataBackendPage.js +2 -2
  389. package/dist/node/components/docs/libraries/LibrariesDataViewsPage.js +3 -3
  390. package/dist/node/components/docs/libraries/LibrariesDesignSystemPage.js +38 -2
  391. package/dist/node/components/docs/libraries/LibrariesEvolutionPage.js +4 -4
  392. package/dist/node/components/docs/libraries/LibrariesGraphQLPage.js +2 -2
  393. package/dist/node/components/docs/libraries/LibrariesGrowthPage.js +3 -3
  394. package/dist/node/components/docs/libraries/LibrariesMultiTenancyPage.js +3 -3
  395. package/dist/node/components/docs/libraries/LibrariesObservabilityPage.js +5 -5
  396. package/dist/node/components/docs/libraries/LibrariesOverlayEnginePage.js +4 -4
  397. package/dist/node/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  398. package/dist/node/components/docs/libraries/LibrariesPersonalizationPage.js +4 -4
  399. package/dist/node/components/docs/libraries/LibrariesProgressiveDeliveryPage.js +3 -3
  400. package/dist/node/components/docs/libraries/LibrariesResiliencePage.js +4 -4
  401. package/dist/node/components/docs/libraries/LibrariesRuntimePage.js +2 -2
  402. package/dist/node/components/docs/libraries/LibrariesSLOPage.js +3 -3
  403. package/dist/node/components/docs/libraries/LibrariesSchemaPage.js +3 -3
  404. package/dist/node/components/docs/libraries/LibrariesSupportBotPage.js +3 -3
  405. package/dist/node/components/docs/libraries/LibrariesTestingPage.js +3 -3
  406. package/dist/node/components/docs/libraries/LibrariesUIKitPage.js +2 -2
  407. package/dist/node/components/docs/libraries/LibrariesUIKitWebPage.js +2 -2
  408. package/dist/node/components/docs/libraries/LibrariesWorkflowComposerPage.js +3 -3
  409. package/dist/node/components/docs/libraries/LibrariesWorkflowsPage.js +2 -2
  410. package/dist/node/components/docs/libraries/index.js +173 -53
  411. package/dist/node/components/docs/manifesto/ManifestoPage.js +1 -1
  412. package/dist/node/components/docs/ops/AutoEvolutionOpsPage.js +2 -2
  413. package/dist/node/components/docs/ops/DistributedTracingOpsPage.js +2 -2
  414. package/dist/node/components/docs/ops/index.js +3 -3
  415. package/dist/node/components/docs/ops/ops-lifecycle.docblocks.js +2 -2
  416. package/dist/node/components/docs/ops/ops-runbooks-a.docblocks.js +2 -2
  417. package/dist/node/components/docs/ops/ops-runbooks-b.docblocks.js +2 -2
  418. package/dist/node/components/docs/ops/ops-slo-tenant.docblocks.js +2 -2
  419. package/dist/node/components/docs/ops/ops-top.docs.js +2 -2
  420. package/dist/node/components/docs/ops/ops.docs.js +6 -6
  421. package/dist/node/components/docs/product/product.docblocks.js +2 -2
  422. package/dist/node/components/docs/reference/DocsMarkdownContent.js +2 -2
  423. package/dist/node/components/docs/reference/DocsReferenceContent.js +3 -3
  424. package/dist/node/components/docs/reference/DocsReferenceIndexClient.js +2 -2
  425. package/dist/node/components/docs/reference/DocsReferenceIndexPage.js +2 -2
  426. package/dist/node/components/docs/reference/DocsReferencePage.js +3 -3
  427. package/dist/node/components/docs/reference/docsMarkdownParser.js +2 -2
  428. package/dist/node/components/docs/reference/index.js +4 -4
  429. package/dist/node/components/docs/safety/SafetyAuditingPage.js +2 -2
  430. package/dist/node/components/docs/safety/SafetyMigrationsPage.js +2 -2
  431. package/dist/node/components/docs/safety/SafetyOverviewPage.js +1 -1
  432. package/dist/node/components/docs/safety/SafetyPDPPage.js +2 -2
  433. package/dist/node/components/docs/safety/SafetySecurityTrustPage.js +1 -1
  434. package/dist/node/components/docs/safety/SafetySigningPage.js +3 -3
  435. package/dist/node/components/docs/safety/SafetyTenantIsolationPage.js +2 -2
  436. package/dist/node/components/docs/safety/index.js +7 -7
  437. package/dist/node/components/docs/shared/StudioPrompt.js +1 -1
  438. package/dist/node/components/docs/specs/SpecsBuilderControlPlanePage.js +4 -4
  439. package/dist/node/components/docs/specs/SpecsCapabilitiesPage.js +2 -2
  440. package/dist/node/components/docs/specs/SpecsConnectPage.js +2 -2
  441. package/dist/node/components/docs/specs/SpecsDataViewsPage.js +2 -2
  442. package/dist/node/components/docs/specs/SpecsModuleBundlesPage.js +3 -3
  443. package/dist/node/components/docs/specs/SpecsOverlaysPage.js +2 -2
  444. package/dist/node/components/docs/specs/SpecsOverviewPage.js +1 -1
  445. package/dist/node/components/docs/specs/SpecsPolicyPage.js +3 -3
  446. package/dist/node/components/docs/specs/SpecsWorkflowsPage.js +2 -2
  447. package/dist/node/components/docs/specs/index.js +13 -13
  448. package/dist/node/components/docs/studio/StudioBYOKPage.js +1 -1
  449. package/dist/node/components/docs/studio/StudioDeploymentsPage.js +1 -1
  450. package/dist/node/components/docs/studio/StudioGettingStartedPage.js +1 -1
  451. package/dist/node/components/docs/studio/StudioIntegrationsPage.js +1 -1
  452. package/dist/node/components/docs/studio/StudioOverviewPage.js +1 -1
  453. package/dist/node/components/docs/studio/StudioVisualBuilderPage.js +1 -1
  454. package/dist/node/components/docs/studio/index.js +1 -1
  455. package/dist/node/components/docs/tech/contracts/tech-docs.docblocks.js +2 -2
  456. package/dist/node/components/integrations/index.js +2 -2
  457. package/dist/node/components/integrations/molecules/IntegrationCard.js +1 -1
  458. package/dist/node/components/integrations/organisms/IntegrationMarketplace.js +1 -1
  459. package/dist/node/components/integrations/organisms/IntegrationSettings.js +2 -2
  460. package/dist/node/components/integrations/organisms/KnowledgeSourceList.js +1 -1
  461. package/dist/node/components/legal/PrivacyTemplate.js +1 -1
  462. package/dist/node/components/legal/TermsTemplate.js +1 -1
  463. package/dist/node/components/legal/index.js +1 -1
  464. package/dist/node/components/shared/FeatureGateNotice.js +1 -1
  465. package/dist/node/components/shared/index.js +1 -1
  466. package/dist/node/components/shell/WorkspaceHeader.js +1 -1
  467. package/dist/node/components/shell/WorkspaceProjectShellLayout.js +1 -1
  468. package/dist/node/components/shell/WorkspaceShellRenderer.js +1 -1
  469. package/dist/node/components/shell/WorkspaceSidebar.js +1 -1
  470. package/dist/node/components/shell/index.js +1 -1
  471. package/dist/node/components/templates/engine/index.js +1 -1
  472. package/dist/node/components/templates/index.js +11 -11
  473. package/dist/node/components/templates/messaging/ConversationList.js +2 -2
  474. package/dist/node/components/templates/messaging/MessageComposer.js +4 -4
  475. package/dist/node/components/templates/messaging/MessageThread.js +3 -3
  476. package/dist/node/components/templates/messaging/MessagingWorkspace.js +5 -5
  477. package/dist/node/components/templates/messaging/index.js +5 -5
  478. package/dist/node/components/templates/recipes/LanguageSwitcher.js +1 -1
  479. package/dist/node/components/templates/recipes/RecipeCard.js +1 -1
  480. package/dist/node/components/templates/recipes/RecipeDetail.js +1 -1
  481. package/dist/node/components/templates/recipes/RecipeList.js +3 -3
  482. package/dist/node/components/templates/recipes/index.js +3 -3
  483. package/dist/node/components/templates/todos/FilterBar.js +1 -1
  484. package/dist/node/components/templates/todos/TaskForm.js +2 -2
  485. package/dist/node/components/templates/todos/TaskItem.js +1 -1
  486. package/dist/node/components/templates/todos/TaskList.js +5 -5
  487. package/dist/node/components/templates/todos/index.js +5 -5
  488. package/dist/node/config/contractspec-blueprint.js +1 -1
  489. package/dist/node/config/contractspec-branding.js +1 -1
  490. package/dist/node/config/contractspec-routes.js +1 -1
  491. package/dist/node/config/index.js +1 -1
  492. package/dist/node/features/contracts-registry.js +1 -1
  493. package/dist/node/features/docs/docs.contracts.js +1 -1
  494. package/dist/node/features/docs/index.js +1 -1
  495. package/dist/node/features/docs.feature.js +1 -1
  496. package/dist/node/features/index.js +1 -1
  497. package/dist/node/features/mcp.feature.js +1 -1
  498. package/dist/node/features/presentations.feature.js +1 -1
  499. package/dist/node/features/registry.js +1 -1
  500. package/dist/node/index.js +382 -262
  501. package/dist/node/infrastructure/elysia/index.js +1 -1
  502. package/dist/node/infrastructure/elysia/logger.js +1 -1
  503. package/dist/node/infrastructure/index.js +1 -1
  504. package/dist/node/libs/email/client.js +1 -1
  505. package/dist/node/libs/email/contact.js +3 -3
  506. package/dist/node/libs/email/newsletter.js +3 -3
  507. package/dist/node/libs/email/utils.js +2 -2
  508. package/dist/node/libs/email/waitlist-application.js +3 -3
  509. package/dist/node/libs/email/waitlist.js +3 -3
  510. package/dist/node/libs/email.js +6 -6
  511. package/dist/node/libs/posthog/client.js +1 -1
  512. package/dist/node/libs/posthog/native.js +1 -1
  513. package/dist/node/libs/posthog/server.js +1 -1
  514. package/dist/node/libs/pricing-examples.js +1 -1
  515. package/dist/node/presentation/features/atoms/FeatureIcon/FeatureIcon.js +1 -1
  516. package/dist/node/presentation/features/atoms/FeatureIcon/index.js +1 -1
  517. package/dist/node/presentation/features/atoms/index.js +1 -1
  518. package/dist/node/presentation/features/hooks/index.js +1 -1
  519. package/dist/node/presentation/features/hooks/useContractsRegistry.js +1 -1
  520. package/dist/node/presentation/features/hooks/useFeatureFilters.js +1 -1
  521. package/dist/node/presentation/features/hooks/useFeatureRegistry.js +1 -1
  522. package/dist/node/presentation/features/hooks/useRelatedDocs.js +1 -1
  523. package/dist/node/presentation/features/index.js +1 -1
  524. package/dist/node/presentation/features/molecules/FeatureCard/FeatureCard.js +1 -1
  525. package/dist/node/presentation/features/molecules/FeatureCard/index.js +1 -1
  526. package/dist/node/presentation/features/molecules/FeatureCategoryHeader/FeatureCategoryHeader.js +1 -1
  527. package/dist/node/presentation/features/molecules/FeatureCategoryHeader/index.js +1 -1
  528. package/dist/node/presentation/features/molecules/FeatureFilters/FeatureFilters.js +1 -1
  529. package/dist/node/presentation/features/molecules/FeatureFilters/index.js +1 -1
  530. package/dist/node/presentation/features/molecules/FeatureHoverPreview/FeatureHoverPreview.js +1 -1
  531. package/dist/node/presentation/features/molecules/FeatureHoverPreview/index.js +1 -1
  532. package/dist/node/presentation/features/molecules/index.js +1 -1
  533. package/dist/node/presentation/features/organisms/FeatureDataViewsList.js +1 -1
  534. package/dist/node/presentation/features/organisms/FeatureDetail/FeatureDetail.js +1 -1
  535. package/dist/node/presentation/features/organisms/FeatureDetail/index.js +1 -1
  536. package/dist/node/presentation/features/organisms/FeatureDiscovery/FeatureDiscovery.js +1 -1
  537. package/dist/node/presentation/features/organisms/FeatureDiscovery/index.js +1 -1
  538. package/dist/node/presentation/features/organisms/FeatureEventsList.js +1 -1
  539. package/dist/node/presentation/features/organisms/FeatureFormsList.js +1 -1
  540. package/dist/node/presentation/features/organisms/FeatureOperationsList.js +1 -1
  541. package/dist/node/presentation/features/organisms/FeaturePresentationsList.js +1 -1
  542. package/dist/node/presentation/features/organisms/index.js +1 -1
  543. package/dist/node/presentation/features/templates/FeatureDataViewDetailTemplate/FeatureDataViewDetailTemplate.js +1 -1
  544. package/dist/node/presentation/features/templates/FeatureDataViewDetailTemplate/index.js +1 -1
  545. package/dist/node/presentation/features/templates/FeatureDataViewsTemplate/FeatureDataViewsTemplate.js +1 -1
  546. package/dist/node/presentation/features/templates/FeatureDataViewsTemplate/index.js +1 -1
  547. package/dist/node/presentation/features/templates/FeatureEventDetailTemplate/FeatureEventDetailTemplate.js +1 -1
  548. package/dist/node/presentation/features/templates/FeatureEventDetailTemplate/index.js +1 -1
  549. package/dist/node/presentation/features/templates/FeatureEventsTemplate/FeatureEventsTemplate.js +1 -1
  550. package/dist/node/presentation/features/templates/FeatureEventsTemplate/index.js +1 -1
  551. package/dist/node/presentation/features/templates/FeatureFormDetailTemplate/FeatureFormDetailTemplate.js +1 -1
  552. package/dist/node/presentation/features/templates/FeatureFormDetailTemplate/index.js +1 -1
  553. package/dist/node/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.js +1 -1
  554. package/dist/node/presentation/features/templates/FeatureFormsTemplate/index.js +1 -1
  555. package/dist/node/presentation/features/templates/FeatureOperationDetailTemplate/FeatureOperationDetailTemplate.js +1 -1
  556. package/dist/node/presentation/features/templates/FeatureOperationDetailTemplate/index.js +1 -1
  557. package/dist/node/presentation/features/templates/FeatureOperationsTemplate/FeatureOperationsTemplate.js +1 -1
  558. package/dist/node/presentation/features/templates/FeatureOperationsTemplate/index.js +1 -1
  559. package/dist/node/presentation/features/templates/FeatureOverviewTemplate/FeatureOverviewTemplate.js +1 -1
  560. package/dist/node/presentation/features/templates/FeatureOverviewTemplate/index.js +1 -1
  561. package/dist/node/presentation/features/templates/FeaturePresentationDetailTemplate/FeaturePresentationDetailTemplate.js +1 -1
  562. package/dist/node/presentation/features/templates/FeaturePresentationDetailTemplate/index.js +1 -1
  563. package/dist/node/presentation/features/templates/FeaturePresentationsTemplate/FeaturePresentationsTemplate.js +1 -1
  564. package/dist/node/presentation/features/templates/FeaturePresentationsTemplate/index.js +1 -1
  565. package/dist/presentation/features/atoms/FeatureIcon/FeatureIcon.js +1 -1
  566. package/dist/presentation/features/atoms/FeatureIcon/index.js +1 -1
  567. package/dist/presentation/features/atoms/index.js +1 -1
  568. package/dist/presentation/features/hooks/index.js +1 -1
  569. package/dist/presentation/features/hooks/useContractsRegistry.js +1 -1
  570. package/dist/presentation/features/hooks/useFeatureFilters.js +1 -1
  571. package/dist/presentation/features/hooks/useFeatureRegistry.js +1 -1
  572. package/dist/presentation/features/hooks/useRelatedDocs.js +1 -1
  573. package/dist/presentation/features/index.js +1 -1
  574. package/dist/presentation/features/molecules/FeatureCard/FeatureCard.js +1 -1
  575. package/dist/presentation/features/molecules/FeatureCard/index.js +1 -1
  576. package/dist/presentation/features/molecules/FeatureCategoryHeader/FeatureCategoryHeader.js +1 -1
  577. package/dist/presentation/features/molecules/FeatureCategoryHeader/index.js +1 -1
  578. package/dist/presentation/features/molecules/FeatureFilters/FeatureFilters.js +1 -1
  579. package/dist/presentation/features/molecules/FeatureFilters/index.js +1 -1
  580. package/dist/presentation/features/molecules/FeatureHoverPreview/FeatureHoverPreview.js +1 -1
  581. package/dist/presentation/features/molecules/FeatureHoverPreview/index.js +1 -1
  582. package/dist/presentation/features/molecules/index.js +1 -1
  583. package/dist/presentation/features/organisms/FeatureDataViewsList.js +1 -1
  584. package/dist/presentation/features/organisms/FeatureDetail/FeatureDetail.js +1 -1
  585. package/dist/presentation/features/organisms/FeatureDetail/index.js +1 -1
  586. package/dist/presentation/features/organisms/FeatureDiscovery/FeatureDiscovery.js +1 -1
  587. package/dist/presentation/features/organisms/FeatureDiscovery/index.js +1 -1
  588. package/dist/presentation/features/organisms/FeatureEventsList.js +1 -1
  589. package/dist/presentation/features/organisms/FeatureFormsList.js +1 -1
  590. package/dist/presentation/features/organisms/FeatureOperationsList.js +1 -1
  591. package/dist/presentation/features/organisms/FeaturePresentationsList.js +1 -1
  592. package/dist/presentation/features/organisms/index.js +1 -1
  593. package/dist/presentation/features/templates/FeatureDataViewDetailTemplate/FeatureDataViewDetailTemplate.js +1 -1
  594. package/dist/presentation/features/templates/FeatureDataViewDetailTemplate/index.js +1 -1
  595. package/dist/presentation/features/templates/FeatureDataViewsTemplate/FeatureDataViewsTemplate.js +1 -1
  596. package/dist/presentation/features/templates/FeatureDataViewsTemplate/index.js +1 -1
  597. package/dist/presentation/features/templates/FeatureEventDetailTemplate/FeatureEventDetailTemplate.js +1 -1
  598. package/dist/presentation/features/templates/FeatureEventDetailTemplate/index.js +1 -1
  599. package/dist/presentation/features/templates/FeatureEventsTemplate/FeatureEventsTemplate.js +1 -1
  600. package/dist/presentation/features/templates/FeatureEventsTemplate/index.js +1 -1
  601. package/dist/presentation/features/templates/FeatureFormDetailTemplate/FeatureFormDetailTemplate.js +1 -1
  602. package/dist/presentation/features/templates/FeatureFormDetailTemplate/index.js +1 -1
  603. package/dist/presentation/features/templates/FeatureFormsTemplate/FeatureFormsTemplate.js +1 -1
  604. package/dist/presentation/features/templates/FeatureFormsTemplate/index.js +1 -1
  605. package/dist/presentation/features/templates/FeatureOperationDetailTemplate/FeatureOperationDetailTemplate.js +1 -1
  606. package/dist/presentation/features/templates/FeatureOperationDetailTemplate/index.js +1 -1
  607. package/dist/presentation/features/templates/FeatureOperationsTemplate/FeatureOperationsTemplate.js +1 -1
  608. package/dist/presentation/features/templates/FeatureOperationsTemplate/index.js +1 -1
  609. package/dist/presentation/features/templates/FeatureOverviewTemplate/FeatureOverviewTemplate.js +1 -1
  610. package/dist/presentation/features/templates/FeatureOverviewTemplate/index.js +1 -1
  611. package/dist/presentation/features/templates/FeaturePresentationDetailTemplate/FeaturePresentationDetailTemplate.js +1 -1
  612. package/dist/presentation/features/templates/FeaturePresentationDetailTemplate/index.js +1 -1
  613. package/dist/presentation/features/templates/FeaturePresentationsTemplate/FeaturePresentationsTemplate.js +1 -1
  614. package/dist/presentation/features/templates/FeaturePresentationsTemplate/index.js +1 -1
  615. package/package.json +49 -24
  616. package/src/application/mcp/internalMcp.ts +1 -1
  617. package/src/bundles/LibraryBundle.ts +19 -130
  618. package/src/components/docs/docsManifest.test.ts +14 -0
  619. package/src/components/docs/docsManifest.ts +10 -0
  620. package/src/components/docs/examples/DocsExamplesPage.tsx +3 -3
  621. package/src/components/docs/examples/ExampleShowcasePage.tsx +1 -1
  622. package/src/components/docs/examples/exampleShowcaseData.test.ts +5 -3
  623. package/src/components/docs/examples/exampleShowcaseData.ts +3 -3
  624. package/src/components/docs/generated/docs-index._common.json +1699 -2008
  625. package/src/components/docs/generated/docs-index.agent-console.json +377 -377
  626. package/src/components/docs/generated/docs-index.ai-chat-assistant.json +17 -17
  627. package/src/components/docs/generated/docs-index.ai-chat.json +105 -105
  628. package/src/components/docs/generated/docs-index.ai-support-bot.json +9 -9
  629. package/src/components/docs/generated/docs-index.analytics-dashboard.json +169 -169
  630. package/src/components/docs/generated/docs-index.app-config.json +137 -137
  631. package/src/components/docs/generated/docs-index.artisan-knowledge-product.json +17 -17
  632. package/src/components/docs/generated/docs-index.artisan-payments-stripe.json +33 -33
  633. package/src/components/docs/generated/docs-index.audit-trail.json +49 -49
  634. package/src/components/docs/generated/docs-index.calendar-google.json +9 -9
  635. package/src/components/docs/generated/docs-index.content-generation.json +9 -9
  636. package/src/components/docs/generated/docs-index.control-plane.json +17 -17
  637. package/src/components/docs/generated/docs-index.crm-pipeline.json +161 -161
  638. package/src/components/docs/generated/docs-index.data-grid-showcase.json +25 -25
  639. package/src/components/docs/generated/docs-index.defineExample.json +9 -9
  640. package/src/components/docs/generated/docs-index.email-gmail.json +9 -9
  641. package/src/components/docs/generated/docs-index.feature-flags.json +217 -217
  642. package/src/components/docs/generated/docs-index.files.json +177 -177
  643. package/src/components/docs/generated/docs-index.generated.ts +20 -20
  644. package/src/components/docs/generated/docs-index.harness-lab.json +9 -9
  645. package/src/components/docs/generated/docs-index.health.json +97 -97
  646. package/src/components/docs/generated/docs-index.identity-rbac.json +313 -313
  647. package/src/components/docs/generated/docs-index.in-app-docs.json +9 -9
  648. package/src/components/docs/generated/docs-index.integration-hub.json +265 -265
  649. package/src/components/docs/generated/docs-index.integration-posthog.json +9 -9
  650. package/src/components/docs/generated/docs-index.integration-stripe.json +9 -9
  651. package/src/components/docs/generated/docs-index.integration-supabase.json +9 -9
  652. package/src/components/docs/generated/docs-index.jobs.json +137 -137
  653. package/src/components/docs/generated/docs-index.kb-update-pipeline.json +129 -129
  654. package/src/components/docs/generated/docs-index.knowledge-canon.json +9 -9
  655. package/src/components/docs/generated/docs-index.learning-journey-ambient-coach.json +9 -9
  656. package/src/components/docs/generated/docs-index.learning-journey-crm-onboarding.json +49 -49
  657. package/src/components/docs/generated/docs-index.learning-journey-duo-drills.json +9 -9
  658. package/src/components/docs/generated/docs-index.learning-journey-platform-tour.json +49 -49
  659. package/src/components/docs/generated/docs-index.learning-journey-quest-challenges.json +9 -9
  660. package/src/components/docs/generated/docs-index.learning-journey-registry.json +33 -33
  661. package/src/components/docs/generated/docs-index.learning-journey-studio-onboarding.json +49 -49
  662. package/src/components/docs/generated/docs-index.learning-journey-ui-coaching.json +9 -9
  663. package/src/components/docs/generated/docs-index.learning-journey-ui-gamified.json +9 -9
  664. package/src/components/docs/generated/docs-index.learning-journey-ui-onboarding.json +9 -9
  665. package/src/components/docs/generated/docs-index.learning-journey-ui-shared.json +9 -9
  666. package/src/components/docs/generated/docs-index.learning-journey.json +241 -241
  667. package/src/components/docs/generated/docs-index.learning-patterns.json +9 -9
  668. package/src/components/docs/generated/docs-index.lifecycle-cli.json +9 -9
  669. package/src/components/docs/generated/docs-index.lifecycle-dashboard.json +9 -9
  670. package/src/components/docs/generated/docs-index.locale-jurisdiction-gate.json +65 -65
  671. package/src/components/docs/generated/docs-index.manifest.json +432 -432
  672. package/src/components/docs/generated/docs-index.marketplace.json +337 -337
  673. package/src/components/docs/generated/docs-index.meeting-recorder-providers.json +9 -9
  674. package/src/components/docs/generated/docs-index.meeting-recorder.json +49 -49
  675. package/src/components/docs/generated/docs-index.messaging-agent-actions.json +17 -17
  676. package/src/components/docs/generated/docs-index.metrics.json +201 -201
  677. package/src/components/docs/generated/docs-index.minimal.json +17 -17
  678. package/src/components/docs/generated/docs-index.mobile-demo-landing.json +42 -0
  679. package/src/components/docs/generated/docs-index.notifications.json +65 -65
  680. package/src/components/docs/generated/docs-index.openbanking-powens.json +9 -9
  681. package/src/components/docs/generated/docs-index.openbanking.json +65 -65
  682. package/src/components/docs/generated/docs-index.opencode-cli.json +17 -17
  683. package/src/components/docs/generated/docs-index.personalization.json +9 -9
  684. package/src/components/docs/generated/docs-index.platform-acp.json +137 -137
  685. package/src/components/docs/generated/docs-index.platform-agent.json +201 -201
  686. package/src/components/docs/generated/docs-index.platform-context.json +121 -121
  687. package/src/components/docs/generated/docs-index.platform-control-plane.json +321 -321
  688. package/src/components/docs/generated/docs-index.platform-database.json +89 -89
  689. package/src/components/docs/generated/docs-index.platform-docs.json +161 -161
  690. package/src/components/docs/generated/docs-index.platform-harness.json +177 -177
  691. package/src/components/docs/generated/docs-index.platform-integrations.json +329 -329
  692. package/src/components/docs/generated/docs-index.platform-knowledge.json +57 -57
  693. package/src/components/docs/generated/docs-index.platform-provider-ranking.json +217 -217
  694. package/src/components/docs/generated/docs-index.pocket-family-office.json +129 -129
  695. package/src/components/docs/generated/docs-index.policy-safe-knowledge-assistant.json +9 -9
  696. package/src/components/docs/generated/docs-index.product-intent.json +9 -9
  697. package/src/components/docs/generated/docs-index.project-management-sync.json +9 -9
  698. package/src/components/docs/generated/docs-index.saas-boilerplate.json +209 -209
  699. package/src/components/docs/generated/docs-index.service-business-os.json +193 -193
  700. package/src/components/docs/generated/docs-index.team-hub.json +185 -185
  701. package/src/components/docs/generated/docs-index.unknown.json +521 -521
  702. package/src/components/docs/generated/docs-index.versioned-knowledge-base.json +81 -81
  703. package/src/components/docs/generated/docs-index.video-api-showcase.json +33 -33
  704. package/src/components/docs/generated/docs-index.video-docs-terminal.json +9 -9
  705. package/src/components/docs/generated/docs-index.video-marketing-clip.json +9 -9
  706. package/src/components/docs/generated/docs-index.visualization-showcase.json +17 -17
  707. package/src/components/docs/generated/docs-index.voice-providers.json +9 -9
  708. package/src/components/docs/generated/docs-index.wealth-snapshot.json +153 -153
  709. package/src/components/docs/generated/docs-index.workflow-system.json +433 -433
  710. package/src/components/docs/generated/docs-index.workspace-cli.json +9 -9
  711. package/src/components/docs/generated/index.ts +20 -5
  712. package/src/components/docs/generated/loader.ts +15 -8
  713. package/src/components/docs/getting-started/CompatibilityPage.tsx +14 -0
  714. package/src/components/docs/libraries/LibrariesCrossPlatformUIPage.content.ts +252 -0
  715. package/src/components/docs/libraries/LibrariesCrossPlatformUIPage.tsx +232 -0
  716. package/src/components/docs/libraries/LibrariesDesignSystemPage.tsx +79 -0
  717. package/src/components/docs/libraries/LibrariesOverviewPage.tsx +6 -0
  718. package/src/components/docs/libraries/LibrariesRuntimePage.tsx +15 -0
  719. package/src/components/docs/libraries/LibrariesUIKitPage.tsx +15 -0
  720. package/src/components/docs/libraries/LibrariesUIKitWebPage.tsx +14 -0
  721. package/src/components/docs/libraries/index.ts +1 -0
  722. package/src/components/docs/reference/DocsReferenceIndexPage.tsx +1 -1
  723. package/src/index.ts +1 -1
  724. package/src/components/docs/generated/docs-index.mobile-demo-tasks.json +0 -34
@@ -1,3 +1,3 @@
1
- import{defaultDocRegistry as c}from"@contractspec/lib.contracts-spec/docs";var i=20,a=100;function U(j){return j?.trim().toLowerCase()??""}function x(j){let w=decodeURIComponent(j).trim();if(!w)return"/";return w.startsWith("/")?w:`/${w}`}function o(j){return(Array.isArray(j)?j:j?[j]:[]).map((H)=>U(H)).filter(Boolean)}function t(j){if(!j||Number.isNaN(j))return i;return Math.min(Math.max(j,1),a)}function s(j){if(!j||Number.isNaN(j))return 0;return Math.max(j,0)}function _({block:j,route:w}){return{id:j.id,title:j.title,summary:j.summary??"",route:w,visibility:j.visibility??"public",kind:j.kind??"reference",version:j.version??"1.0.0",tags:j.tags??[]}}function r(j,w){if(!w)return 1;let H=w.split(/\s+/).filter(Boolean),J=U(j.block.title),Y=U(j.block.id),N=U(j.block.summary),$=U(j.block.body),K=U(j.route),Q=(j.block.tags??[]).map((W)=>U(W)),L=[J,Y,N,$,K,...Q].join(" ");if(H.some((W)=>!L.includes(W)))return 0;let V=0;for(let W of H){if(Y.includes(W))V+=8;if(J.includes(W))V+=7;if(Q.some((X)=>X.includes(W)))V+=5;if(N.includes(W))V+=4;if(K.includes(W))V+=3;if($.includes(W))V+=2}return V}function D(j,w){let H=U(typeof w.query==="string"?w.query:void 0),J=o(w.tag),Y=U(typeof w.visibility==="string"?w.visibility:void 0),N=U(typeof w.kind==="string"?w.kind:void 0),$=t(typeof w.limit==="number"?w.limit:void 0),K=s(typeof w.offset==="number"?w.offset:void 0),Q=j.map((W)=>({doc:_(W),score:r(W,H)})).filter(({doc:W,score:X})=>{let y=H?X>0:!0,l=J.length?J.every((n)=>W.tags.some((u)=>U(u).includes(n))):!0,g=Y?U(W.visibility)===Y:!0,d=N?U(W.kind)===N:!0;return y&&l&&g&&d}).sort((W,X)=>{if(X.score!==W.score)return X.score-W.score;return W.doc.title.localeCompare(X.doc.title)}),L=Q.slice(K,K+$).map(({doc:W})=>W),V=K+L.length<Q.length?K+L.length:void 0;return{docs:L,items:L,total:Q.length,...V!=null?{nextOffset:V}:{}}}function S(j){let w=decodeURIComponent(j),H=c.get(w);if(!H)return;return{doc:_(H),content:String(H.block.body??"")}}function b(j,w){let H=x(w),J=j.find((Y)=>x(Y.route)===H);if(!J)return;return{doc:_(J),content:String(J.block.body??"")}}function h(j){let w=new Map,H=new Map,J=new Map;for(let N of j){let $=N.block.kind??"reference",K=N.block.visibility??"public";H.set($,(H.get($)??0)+1),J.set(K,(J.get(K)??0)+1);for(let Q of N.block.tags??[])w.set(Q,(w.get(Q)??0)+1)}let Y=(N,$)=>[...N.entries()].sort((K,Q)=>Q[1]-K[1]||K[0].localeCompare(Q[0])).map(([K,Q])=>({[$]:K,count:Q}));return{totalDocs:j.length,tags:Y(w,"tag"),kinds:Y(H,"kind"),visibilities:Y(J,"visibility")}}import{EventRegistry as e,OperationSpecRegistry as jj}from"@contractspec/lib.contracts-spec";import{DataViewRegistry as wj}from"@contractspec/lib.contracts-spec/data-views";import{ContractReferenceDataView as Hj,ContractReferenceQuery as Jj,DocsGenerateCommand as Nj,DocsGeneratedEvent as Wj,DocsIndexDataView as Yj,DocsIndexQuery as Zj,DocsLayoutPresentation as $j,DocsPublishCommand as Kj,DocsPublishedEvent as Qj,DocsReferencePagePresentation as Uj,DocsSearchForm as Vj,ExampleCatalogDataView as Xj}from"@contractspec/lib.contracts-spec/docs";import{FormRegistry as Bj}from"@contractspec/lib.contracts-spec/forms";import{PresentationRegistry as Fj}from"@contractspec/lib.contracts-spec/presentations";import{serializeDataViewSpec as Lj,serializeEventSpec as Ej,serializeFormSpec as Mj,serializeOperationSpec as Gj,serializePresentationSpec as Aj}from"@contractspec/lib.contracts-spec/serialization";var E=null;function Cj(){let j=new jj;return j.register(Zj).register(Jj).register(Nj).register(Kj),j}function _j(){if(!E)E=Cj();return E}function O(j,w){return _j().get(j,w)}var M=null;function Oj(){let j=new e;return j.register(Wj).register(Qj),j}function qj(){if(!M)M=Oj();return M}function q(j,w){return qj().get(j,w)}var G=null;function Pj(){let j=new Fj;return j.register($j).register(Uj),j}function Ij(){if(!G)G=Pj();return G}function P(j,w){return Ij().get(j,w)}var A=null;function Rj(){let j=new wj;return j.register(Yj).register(Hj).register(Xj),j}function xj(){if(!A)A=Rj();return A}function I(j,w){return xj().get(j,w)}var C=null;function Dj(){let j=new Bj;return j.register(Vj),j}function Sj(){if(!C)C=Dj();return C}function R(j,w){return Sj().get(j)}function z(j,w){let H=O(j,w);return Gj(H)??void 0}function T(j,w){let H=q(j,w);return Ej(H)??void 0}function v(j,w){let H=P(j,w);return Aj(H)??void 0}function f(j,w){let H=I(j,w);return Lj(H)??void 0}function m(j,w){let H=R(j,w);return Mj(H)??void 0}function bj(){E=null}function hj(){M=null}function zj(){G=null}function Tj(){A=null}function vj(){C=null}function aj(){bj(),hj(),zj(),Tj(),vj()}import{defaultDocRegistry as fj}from"@contractspec/lib.contracts-spec/docs";function mj(j){return j?.trim().toLowerCase()??""}function kj(j){for(let w of j??[]){let H=fj.get(w);if(H)return H.route}return}function k(j,w,H,J){let Y=j.meta.title??j.meta.key,N=kj(j.meta.docId),$=j.meta.description;return{key:j.meta.key,version:j.meta.version,type:w,title:Y,description:$,markdown:[`# ${Y}`,`- Key: ${j.meta.key}`,`- Type: ${w}`,`- Version: ${j.meta.version}`,N?`- Docs route: ${N}`:"",$?`
1
+ var c=Object.defineProperty;var i=(j)=>j;function a(j,w){this[j]=i.bind(null,w)}var dj=(j,w)=>{for(var H in w)c(j,H,{get:w[H],enumerable:!0,configurable:!0,set:a.bind(w,H)})};var nj=(j,w)=>()=>(j&&(w=j(j=0)),w);import{defaultDocRegistry as o}from"@contractspec/lib.contracts-spec/docs";var t=20,s=100;function U(j){return j?.trim().toLowerCase()??""}function x(j){let w=decodeURIComponent(j).trim();if(!w)return"/";return w.startsWith("/")?w:`/${w}`}function r(j){return(Array.isArray(j)?j:j?[j]:[]).map((H)=>U(H)).filter(Boolean)}function e(j){if(!j||Number.isNaN(j))return t;return Math.min(Math.max(j,1),s)}function jj(j){if(!j||Number.isNaN(j))return 0;return Math.max(j,0)}function _({block:j,route:w}){return{id:j.id,title:j.title,summary:j.summary??"",route:w,visibility:j.visibility??"public",kind:j.kind??"reference",version:j.version??"1.0.0",tags:j.tags??[]}}function wj(j,w){if(!w)return 1;let H=w.split(/\s+/).filter(Boolean),J=U(j.block.title),Y=U(j.block.id),N=U(j.block.summary),$=U(j.block.body),K=U(j.route),Q=(j.block.tags??[]).map((W)=>U(W)),L=[J,Y,N,$,K,...Q].join(" ");if(H.some((W)=>!L.includes(W)))return 0;let V=0;for(let W of H){if(Y.includes(W))V+=8;if(J.includes(W))V+=7;if(Q.some((X)=>X.includes(W)))V+=5;if(N.includes(W))V+=4;if(K.includes(W))V+=3;if($.includes(W))V+=2}return V}function D(j,w){let H=U(typeof w.query==="string"?w.query:void 0),J=r(w.tag),Y=U(typeof w.visibility==="string"?w.visibility:void 0),N=U(typeof w.kind==="string"?w.kind:void 0),$=e(typeof w.limit==="number"?w.limit:void 0),K=jj(typeof w.offset==="number"?w.offset:void 0),Q=j.map((W)=>({doc:_(W),score:wj(W,H)})).filter(({doc:W,score:X})=>{let y=H?X>0:!0,l=J.length?J.every((n)=>W.tags.some((u)=>U(u).includes(n))):!0,g=Y?U(W.visibility)===Y:!0,d=N?U(W.kind)===N:!0;return y&&l&&g&&d}).sort((W,X)=>{if(X.score!==W.score)return X.score-W.score;return W.doc.title.localeCompare(X.doc.title)}),L=Q.slice(K,K+$).map(({doc:W})=>W),V=K+L.length<Q.length?K+L.length:void 0;return{docs:L,items:L,total:Q.length,...V!=null?{nextOffset:V}:{}}}function S(j){let w=decodeURIComponent(j),H=o.get(w);if(!H)return;return{doc:_(H),content:String(H.block.body??"")}}function b(j,w){let H=x(w),J=j.find((Y)=>x(Y.route)===H);if(!J)return;return{doc:_(J),content:String(J.block.body??"")}}function h(j){let w=new Map,H=new Map,J=new Map;for(let N of j){let $=N.block.kind??"reference",K=N.block.visibility??"public";H.set($,(H.get($)??0)+1),J.set(K,(J.get(K)??0)+1);for(let Q of N.block.tags??[])w.set(Q,(w.get(Q)??0)+1)}let Y=(N,$)=>[...N.entries()].sort((K,Q)=>Q[1]-K[1]||K[0].localeCompare(Q[0])).map(([K,Q])=>({[$]:K,count:Q}));return{totalDocs:j.length,tags:Y(w,"tag"),kinds:Y(H,"kind"),visibilities:Y(J,"visibility")}}import{EventRegistry as Hj,OperationSpecRegistry as Jj}from"@contractspec/lib.contracts-spec";import{DataViewRegistry as Nj}from"@contractspec/lib.contracts-spec/data-views";import{ContractReferenceDataView as Wj,ContractReferenceQuery as Yj,DocsGenerateCommand as Zj,DocsGeneratedEvent as $j,DocsIndexDataView as Kj,DocsIndexQuery as Qj,DocsLayoutPresentation as Uj,DocsPublishCommand as Vj,DocsPublishedEvent as Xj,DocsReferencePagePresentation as Bj,DocsSearchForm as Fj,ExampleCatalogDataView as Lj}from"@contractspec/lib.contracts-spec/docs";import{FormRegistry as Ej}from"@contractspec/lib.contracts-spec/forms";import{PresentationRegistry as Mj}from"@contractspec/lib.contracts-spec/presentations";import{serializeDataViewSpec as Gj,serializeEventSpec as Aj,serializeFormSpec as Cj,serializeOperationSpec as _j,serializePresentationSpec as Oj}from"@contractspec/lib.contracts-spec/serialization";var E=null;function qj(){let j=new Jj;return j.register(Qj).register(Yj).register(Zj).register(Vj),j}function Pj(){if(!E)E=qj();return E}function O(j,w){return Pj().get(j,w)}var M=null;function Ij(){let j=new Hj;return j.register($j).register(Xj),j}function Rj(){if(!M)M=Ij();return M}function q(j,w){return Rj().get(j,w)}var G=null;function xj(){let j=new Mj;return j.register(Uj).register(Bj),j}function Dj(){if(!G)G=xj();return G}function P(j,w){return Dj().get(j,w)}var A=null;function Sj(){let j=new Nj;return j.register(Kj).register(Wj).register(Lj),j}function bj(){if(!A)A=Sj();return A}function I(j,w){return bj().get(j,w)}var C=null;function hj(){let j=new Ej;return j.register(Fj),j}function zj(){if(!C)C=hj();return C}function R(j,w){return zj().get(j)}function z(j,w){let H=O(j,w);return _j(H)??void 0}function T(j,w){let H=q(j,w);return Aj(H)??void 0}function v(j,w){let H=P(j,w);return Oj(H)??void 0}function f(j,w){let H=I(j,w);return Gj(H)??void 0}function m(j,w){let H=R(j,w);return Cj(H)??void 0}function Tj(){E=null}function vj(){M=null}function fj(){G=null}function mj(){A=null}function kj(){C=null}function jw(){Tj(),vj(),fj(),mj(),kj()}import{defaultDocRegistry as pj}from"@contractspec/lib.contracts-spec/docs";function yj(j){return j?.trim().toLowerCase()??""}function lj(j){for(let w of j??[]){let H=pj.get(w);if(H)return H.route}return}function k(j,w,H,J){let Y=j.meta.title??j.meta.key,N=lj(j.meta.docId),$=j.meta.description;return{key:j.meta.key,version:j.meta.version,type:w,title:Y,description:$,markdown:[`# ${Y}`,`- Key: ${j.meta.key}`,`- Type: ${w}`,`- Version: ${j.meta.version}`,N?`- Docs route: ${N}`:"",$?`
2
2
  ${$}`:""].filter(Boolean).join(`
3
- `),...N?{route:N}:{},...H?{schema:H}:{},...J?{policy:J}:{},tags:j.meta.tags??[],owners:j.meta.owners??[],stability:j.meta.stability}}function p(j){let w=j.includeSchema??!1,H=mj(j.type),J=O(j.key,j.version);if(J&&(!H||H==="operation"||H===J.meta.kind))return{reference:k(J,J.meta.kind,w?z(j.key,j.version):void 0,J.policy)};let Y=[{type:"data-view",spec:I(j.key,j.version),schema:w?f(j.key,j.version):void 0},{type:"form",spec:R(j.key,j.version),schema:w?m(j.key,j.version):void 0},{type:"presentation",spec:P(j.key,j.version),schema:w?v(j.key,j.version):void 0},{type:"event",spec:q(j.key,j.version),schema:w?T(j.key,j.version):void 0}];for(let N of Y)if(N.spec&&(!H||H===N.type))return{reference:k(N.spec,N.type,N.schema)};throw Error(`Contract reference not found: ${j.key}`)}import{defineResourceTemplate as B,ResourceRegistry as pj}from"@contractspec/lib.contracts-spec";import Z from"zod";var F=["docs","mcp"];function Jw(j){let w=new pj,H=(J)=>D(j,J);return w.register(B({meta:{uriTemplate:"docs://index",title:"DocBlocks index",description:"Default ContractSpec docs index resource.",mimeType:"application/json",tags:F},input:Z.object({}),resolve:async()=>({uri:"docs://index",mimeType:"application/json",data:JSON.stringify(H({}),null,2)})})),w.register(B({meta:{uriTemplate:"docs://index{?query,tag,kind,visibility,limit,offset}",title:"DocBlocks index",description:"Search and paginate ContractSpec docs by query, tag, kind, or visibility.",mimeType:"application/json",tags:F},input:Z.object({query:Z.string().optional(),tag:Z.string().optional(),kind:Z.string().optional(),visibility:Z.string().optional(),limit:Z.coerce.number().optional(),offset:Z.coerce.number().optional()}),resolve:async(J)=>({uri:"docs://index",mimeType:"application/json",data:JSON.stringify(H(J),null,2)})})),w.register(B({meta:{uriTemplate:"docs://list",title:"DocBlocks index (legacy alias)",description:"Compatibility alias for the docs index resource.",mimeType:"application/json",tags:F},input:Z.object({}),resolve:async()=>({uri:"docs://list",mimeType:"application/json",data:JSON.stringify(H({}),null,2)})})),w.register(B({meta:{uriTemplate:"docs://doc/{id}",title:"Doc markdown",description:"Fetch a single DocBlock body by id as markdown.",mimeType:"text/markdown",tags:F},input:Z.object({id:Z.string()}),resolve:async({id:J})=>{let Y=S(J);if(!Y)return{uri:`docs://doc/${encodeURIComponent(J)}`,mimeType:"text/plain",data:`DocBlock not found: ${J}`};return{uri:`docs://doc/${encodeURIComponent(J)}`,mimeType:"text/markdown",data:Y.content}}})),w.register(B({meta:{uriTemplate:"docs://route/{routePath}",title:"Doc by route",description:"Resolve a docs route to the matching DocBlock summary and body.",mimeType:"application/json",tags:F},input:Z.object({routePath:Z.string()}),resolve:async({routePath:J})=>({uri:`docs://route/${encodeURIComponent(J)}`,mimeType:"application/json",data:JSON.stringify(b(j,J)??{error:"not_found",route:J},null,2)})})),w.register(B({meta:{uriTemplate:"docs://facets",title:"Docs facets",description:"Counts of available tags, kinds, and visibilities across docs.",mimeType:"application/json",tags:F},input:Z.object({}),resolve:async()=>({uri:"docs://facets",mimeType:"application/json",data:JSON.stringify(h(j),null,2)})})),w.register(B({meta:{uriTemplate:"docs://contract-reference/{key}{?version,type,includeSchema}",title:"Contract reference",description:"Resolve a ContractSpec surface into a docs-ready reference payload.",mimeType:"application/json",tags:F},input:Z.object({key:Z.string(),version:Z.string().optional(),type:Z.string().optional(),includeSchema:Z.coerce.boolean().optional()}),resolve:async({key:J,version:Y,type:N,includeSchema:$})=>({uri:`docs://contract-reference/${encodeURIComponent(J)}`,mimeType:"application/json",data:JSON.stringify(p({key:J,version:Y,type:N,includeSchema:$}),null,2)})})),w}export{Jw as buildDocResources};
3
+ `),...N?{route:N}:{},...H?{schema:H}:{},...J?{policy:J}:{},tags:j.meta.tags??[],owners:j.meta.owners??[],stability:j.meta.stability}}function p(j){let w=j.includeSchema??!1,H=yj(j.type),J=O(j.key,j.version);if(J&&(!H||H==="operation"||H===J.meta.kind))return{reference:k(J,J.meta.kind,w?z(j.key,j.version):void 0,J.policy)};let Y=[{type:"data-view",spec:I(j.key,j.version),schema:w?f(j.key,j.version):void 0},{type:"form",spec:R(j.key,j.version),schema:w?m(j.key,j.version):void 0},{type:"presentation",spec:P(j.key,j.version),schema:w?v(j.key,j.version):void 0},{type:"event",spec:q(j.key,j.version),schema:w?T(j.key,j.version):void 0}];for(let N of Y)if(N.spec&&(!H||H===N.type))return{reference:k(N.spec,N.type,N.schema)};throw Error(`Contract reference not found: ${j.key}`)}import{defineResourceTemplate as B,ResourceRegistry as gj}from"@contractspec/lib.contracts-spec";import Z from"zod";var F=["docs","mcp"];function Kw(j){let w=new gj,H=(J)=>D(j,J);return w.register(B({meta:{uriTemplate:"docs://index",title:"DocBlocks index",description:"Default ContractSpec docs index resource.",mimeType:"application/json",tags:F},input:Z.object({}),resolve:async()=>({uri:"docs://index",mimeType:"application/json",data:JSON.stringify(H({}),null,2)})})),w.register(B({meta:{uriTemplate:"docs://index{?query,tag,kind,visibility,limit,offset}",title:"DocBlocks index",description:"Search and paginate ContractSpec docs by query, tag, kind, or visibility.",mimeType:"application/json",tags:F},input:Z.object({query:Z.string().optional(),tag:Z.string().optional(),kind:Z.string().optional(),visibility:Z.string().optional(),limit:Z.coerce.number().optional(),offset:Z.coerce.number().optional()}),resolve:async(J)=>({uri:"docs://index",mimeType:"application/json",data:JSON.stringify(H(J),null,2)})})),w.register(B({meta:{uriTemplate:"docs://list",title:"DocBlocks index (legacy alias)",description:"Compatibility alias for the docs index resource.",mimeType:"application/json",tags:F},input:Z.object({}),resolve:async()=>({uri:"docs://list",mimeType:"application/json",data:JSON.stringify(H({}),null,2)})})),w.register(B({meta:{uriTemplate:"docs://doc/{id}",title:"Doc markdown",description:"Fetch a single DocBlock body by id as markdown.",mimeType:"text/markdown",tags:F},input:Z.object({id:Z.string()}),resolve:async({id:J})=>{let Y=S(J);if(!Y)return{uri:`docs://doc/${encodeURIComponent(J)}`,mimeType:"text/plain",data:`DocBlock not found: ${J}`};return{uri:`docs://doc/${encodeURIComponent(J)}`,mimeType:"text/markdown",data:Y.content}}})),w.register(B({meta:{uriTemplate:"docs://route/{routePath}",title:"Doc by route",description:"Resolve a docs route to the matching DocBlock summary and body.",mimeType:"application/json",tags:F},input:Z.object({routePath:Z.string()}),resolve:async({routePath:J})=>({uri:`docs://route/${encodeURIComponent(J)}`,mimeType:"application/json",data:JSON.stringify(b(j,J)??{error:"not_found",route:J},null,2)})})),w.register(B({meta:{uriTemplate:"docs://facets",title:"Docs facets",description:"Counts of available tags, kinds, and visibilities across docs.",mimeType:"application/json",tags:F},input:Z.object({}),resolve:async()=>({uri:"docs://facets",mimeType:"application/json",data:JSON.stringify(h(j),null,2)})})),w.register(B({meta:{uriTemplate:"docs://contract-reference/{key}{?version,type,includeSchema}",title:"Contract reference",description:"Resolve a ContractSpec surface into a docs-ready reference payload.",mimeType:"application/json",tags:F},input:Z.object({key:Z.string(),version:Z.string().optional(),type:Z.string().optional(),includeSchema:Z.coerce.boolean().optional()}),resolve:async({key:J,version:Y,type:N,includeSchema:$})=>({uri:`docs://contract-reference/${encodeURIComponent(J)}`,mimeType:"application/json",data:JSON.stringify(p({key:J,version:Y,type:N,includeSchema:$}),null,2)})})),w}export{Kw as buildDocResources};
@@ -1,3 +1,3 @@
1
- import{defaultDocRegistry as o}from"@contractspec/lib.contracts-spec/docs";var s=20,t=100;function V(j){return j?.trim().toLowerCase()??""}function O(j){let w=decodeURIComponent(j).trim();if(!w)return"/";return w.startsWith("/")?w:`/${w}`}function r(j){return(Array.isArray(j)?j:j?[j]:[]).map((H)=>V(H)).filter(Boolean)}function e(j){if(!j||Number.isNaN(j))return s;return Math.min(Math.max(j,1),t)}function jj(j){if(!j||Number.isNaN(j))return 0;return Math.max(j,0)}function E({block:j,route:w}){return{id:j.id,title:j.title,summary:j.summary??"",route:w,visibility:j.visibility??"public",kind:j.kind??"reference",version:j.version??"1.0.0",tags:j.tags??[]}}function wj(j,w){if(!w)return 1;let H=w.split(/\s+/).filter(Boolean),J=V(j.block.title),$=V(j.block.id),Z=V(j.block.summary),U=V(j.block.body),K=V(j.route),Q=(j.block.tags??[]).map((Y)=>V(Y)),L=[J,$,Z,U,K,...Q].join(" ");if(H.some((Y)=>!L.includes(Y)))return 0;let X=0;for(let Y of H){if($.includes(Y))X+=8;if(J.includes(Y))X+=7;if(Q.some((B)=>B.includes(Y)))X+=5;if(Z.includes(Y))X+=4;if(K.includes(Y))X+=3;if(U.includes(Y))X+=2}return X}function S(j,w){let H=V(typeof w.query==="string"?w.query:void 0),J=r(w.tag),$=V(typeof w.visibility==="string"?w.visibility:void 0),Z=V(typeof w.kind==="string"?w.kind:void 0),U=e(typeof w.limit==="number"?w.limit:void 0),K=jj(typeof w.offset==="number"?w.offset:void 0),Q=j.map((Y)=>({doc:E(Y),score:wj(Y,H)})).filter(({doc:Y,score:B})=>{let g=H?B>0:!0,u=J.length?J.every((i)=>Y.tags.some((a)=>V(a).includes(i))):!0,n=$?V(Y.visibility)===$:!0,c=Z?V(Y.kind)===Z:!0;return g&&u&&n&&c}).sort((Y,B)=>{if(B.score!==Y.score)return B.score-Y.score;return Y.doc.title.localeCompare(B.doc.title)}),L=Q.slice(K,K+U).map(({doc:Y})=>Y),X=K+L.length<Q.length?K+L.length:void 0;return{docs:L,items:L,total:Q.length,...X!=null?{nextOffset:X}:{}}}function h(j){let w=decodeURIComponent(j),H=o.get(w);if(!H)return;return{doc:E(H),content:String(H.block.body??"")}}function T(j,w){let H=O(w),J=j.find(($)=>O($.route)===H);if(!J)return;return{doc:E(J),content:String(J.block.body??"")}}function v(j){let w=new Map,H=new Map,J=new Map;for(let Z of j){let U=Z.block.kind??"reference",K=Z.block.visibility??"public";H.set(U,(H.get(U)??0)+1),J.set(K,(J.get(K)??0)+1);for(let Q of Z.block.tags??[])w.set(Q,(w.get(Q)??0)+1)}let $=(Z,U)=>[...Z.entries()].sort((K,Q)=>Q[1]-K[1]||K[0].localeCompare(Q[0])).map(([K,Q])=>({[U]:K,count:Q}));return{totalDocs:j.length,tags:$(w,"tag"),kinds:$(H,"kind"),visibilities:$(J,"visibility")}}import{EventRegistry as Hj,OperationSpecRegistry as Jj}from"@contractspec/lib.contracts-spec";import{DataViewRegistry as Yj}from"@contractspec/lib.contracts-spec/data-views";import{ContractReferenceDataView as Zj,ContractReferenceQuery as $j,DocsGenerateCommand as Kj,DocsGeneratedEvent as Qj,DocsIndexDataView as Uj,DocsIndexQuery as Vj,DocsLayoutPresentation as Xj,DocsPublishCommand as Bj,DocsPublishedEvent as Fj,DocsReferencePagePresentation as Lj,DocsSearchForm as Nj,ExampleCatalogDataView as Pj}from"@contractspec/lib.contracts-spec/docs";import{FormRegistry as Wj}from"@contractspec/lib.contracts-spec/forms";import{PresentationRegistry as Aj}from"@contractspec/lib.contracts-spec/presentations";import{serializeDataViewSpec as Gj,serializeEventSpec as qj,serializeFormSpec as Mj,serializeOperationSpec as _j,serializePresentationSpec as Ij}from"@contractspec/lib.contracts-spec/serialization";var q=null;function xj(){let j=new Jj;return j.register(Vj).register($j).register(Kj).register(Bj),j}function Ej(){if(!q)q=xj();return q}function R(j,w){return Ej().get(j,w)}var M=null;function Rj(){let j=new Hj;return j.register(Qj).register(Fj),j}function zj(){if(!M)M=Rj();return M}function z(j,w){return zj().get(j,w)}var _=null;function Cj(){let j=new Aj;return j.register(Xj).register(Lj),j}function bj(){if(!_)_=Cj();return _}function C(j,w){return bj().get(j,w)}var I=null;function Dj(){let j=new Yj;return j.register(Uj).register(Zj).register(Pj),j}function Oj(){if(!I)I=Dj();return I}function b(j,w){return Oj().get(j,w)}var x=null;function Sj(){let j=new Wj;return j.register(Nj),j}function hj(){if(!x)x=Sj();return x}function D(j,w){return hj().get(j)}function k(j,w){let H=R(j,w);return _j(H)??void 0}function f(j,w){let H=z(j,w);return qj(H)??void 0}function m(j,w){let H=C(j,w);return Ij(H)??void 0}function y(j,w){let H=b(j,w);return Gj(H)??void 0}function p(j,w){let H=D(j,w);return Mj(H)??void 0}function Tj(){q=null}function vj(){M=null}function kj(){_=null}function fj(){I=null}function mj(){x=null}function Kw(){Tj(),vj(),kj(),fj(),mj()}import{defaultDocRegistry as yj}from"@contractspec/lib.contracts-spec/docs";function pj(j){return j?.trim().toLowerCase()??""}function dj(j){for(let w of j??[]){let H=yj.get(w);if(H)return H.route}return}function d(j,w,H,J){let $=j.meta.title??j.meta.key,Z=dj(j.meta.docId),U=j.meta.description;return{key:j.meta.key,version:j.meta.version,type:w,title:$,description:U,markdown:[`# ${$}`,`- Key: ${j.meta.key}`,`- Type: ${w}`,`- Version: ${j.meta.version}`,Z?`- Docs route: ${Z}`:"",U?`
1
+ var o=Object.defineProperty;var s=(j)=>j;function t(j,w){this[j]=s.bind(null,w)}var Hw=(j,w)=>{for(var H in w)o(j,H,{get:w[H],enumerable:!0,configurable:!0,set:t.bind(w,H)})};var Jw=(j,w)=>()=>(j&&(w=j(j=0)),w);import{defaultDocRegistry as r}from"@contractspec/lib.contracts-spec/docs";var e=20,jj=100;function V(j){return j?.trim().toLowerCase()??""}function O(j){let w=decodeURIComponent(j).trim();if(!w)return"/";return w.startsWith("/")?w:`/${w}`}function wj(j){return(Array.isArray(j)?j:j?[j]:[]).map((H)=>V(H)).filter(Boolean)}function Hj(j){if(!j||Number.isNaN(j))return e;return Math.min(Math.max(j,1),jj)}function Jj(j){if(!j||Number.isNaN(j))return 0;return Math.max(j,0)}function E({block:j,route:w}){return{id:j.id,title:j.title,summary:j.summary??"",route:w,visibility:j.visibility??"public",kind:j.kind??"reference",version:j.version??"1.0.0",tags:j.tags??[]}}function Yj(j,w){if(!w)return 1;let H=w.split(/\s+/).filter(Boolean),J=V(j.block.title),$=V(j.block.id),Z=V(j.block.summary),U=V(j.block.body),K=V(j.route),Q=(j.block.tags??[]).map((Y)=>V(Y)),L=[J,$,Z,U,K,...Q].join(" ");if(H.some((Y)=>!L.includes(Y)))return 0;let X=0;for(let Y of H){if($.includes(Y))X+=8;if(J.includes(Y))X+=7;if(Q.some((B)=>B.includes(Y)))X+=5;if(Z.includes(Y))X+=4;if(K.includes(Y))X+=3;if(U.includes(Y))X+=2}return X}function S(j,w){let H=V(typeof w.query==="string"?w.query:void 0),J=wj(w.tag),$=V(typeof w.visibility==="string"?w.visibility:void 0),Z=V(typeof w.kind==="string"?w.kind:void 0),U=Hj(typeof w.limit==="number"?w.limit:void 0),K=Jj(typeof w.offset==="number"?w.offset:void 0),Q=j.map((Y)=>({doc:E(Y),score:Yj(Y,H)})).filter(({doc:Y,score:B})=>{let g=H?B>0:!0,u=J.length?J.every((i)=>Y.tags.some((a)=>V(a).includes(i))):!0,n=$?V(Y.visibility)===$:!0,c=Z?V(Y.kind)===Z:!0;return g&&u&&n&&c}).sort((Y,B)=>{if(B.score!==Y.score)return B.score-Y.score;return Y.doc.title.localeCompare(B.doc.title)}),L=Q.slice(K,K+U).map(({doc:Y})=>Y),X=K+L.length<Q.length?K+L.length:void 0;return{docs:L,items:L,total:Q.length,...X!=null?{nextOffset:X}:{}}}function h(j){let w=decodeURIComponent(j),H=r.get(w);if(!H)return;return{doc:E(H),content:String(H.block.body??"")}}function T(j,w){let H=O(w),J=j.find(($)=>O($.route)===H);if(!J)return;return{doc:E(J),content:String(J.block.body??"")}}function v(j){let w=new Map,H=new Map,J=new Map;for(let Z of j){let U=Z.block.kind??"reference",K=Z.block.visibility??"public";H.set(U,(H.get(U)??0)+1),J.set(K,(J.get(K)??0)+1);for(let Q of Z.block.tags??[])w.set(Q,(w.get(Q)??0)+1)}let $=(Z,U)=>[...Z.entries()].sort((K,Q)=>Q[1]-K[1]||K[0].localeCompare(Q[0])).map(([K,Q])=>({[U]:K,count:Q}));return{totalDocs:j.length,tags:$(w,"tag"),kinds:$(H,"kind"),visibilities:$(J,"visibility")}}import{EventRegistry as Zj,OperationSpecRegistry as $j}from"@contractspec/lib.contracts-spec";import{DataViewRegistry as Kj}from"@contractspec/lib.contracts-spec/data-views";import{ContractReferenceDataView as Qj,ContractReferenceQuery as Uj,DocsGenerateCommand as Vj,DocsGeneratedEvent as Xj,DocsIndexDataView as Bj,DocsIndexQuery as Fj,DocsLayoutPresentation as Lj,DocsPublishCommand as Nj,DocsPublishedEvent as Pj,DocsReferencePagePresentation as Wj,DocsSearchForm as Aj,ExampleCatalogDataView as Gj}from"@contractspec/lib.contracts-spec/docs";import{FormRegistry as qj}from"@contractspec/lib.contracts-spec/forms";import{PresentationRegistry as Mj}from"@contractspec/lib.contracts-spec/presentations";import{serializeDataViewSpec as _j,serializeEventSpec as Ij,serializeFormSpec as xj,serializeOperationSpec as Ej,serializePresentationSpec as Rj}from"@contractspec/lib.contracts-spec/serialization";var q=null;function zj(){let j=new $j;return j.register(Fj).register(Uj).register(Vj).register(Nj),j}function Cj(){if(!q)q=zj();return q}function R(j,w){return Cj().get(j,w)}var M=null;function bj(){let j=new Zj;return j.register(Xj).register(Pj),j}function Dj(){if(!M)M=bj();return M}function z(j,w){return Dj().get(j,w)}var _=null;function Oj(){let j=new Mj;return j.register(Lj).register(Wj),j}function Sj(){if(!_)_=Oj();return _}function C(j,w){return Sj().get(j,w)}var I=null;function hj(){let j=new Kj;return j.register(Bj).register(Qj).register(Gj),j}function Tj(){if(!I)I=hj();return I}function b(j,w){return Tj().get(j,w)}var x=null;function vj(){let j=new qj;return j.register(Aj),j}function kj(){if(!x)x=vj();return x}function D(j,w){return kj().get(j)}function k(j,w){let H=R(j,w);return Ej(H)??void 0}function f(j,w){let H=z(j,w);return Ij(H)??void 0}function m(j,w){let H=C(j,w);return Rj(H)??void 0}function y(j,w){let H=b(j,w);return _j(H)??void 0}function p(j,w){let H=D(j,w);return xj(H)??void 0}function fj(){q=null}function mj(){M=null}function yj(){_=null}function pj(){I=null}function dj(){x=null}function Fw(){fj(),mj(),yj(),pj(),dj()}import{defaultDocRegistry as lj}from"@contractspec/lib.contracts-spec/docs";function gj(j){return j?.trim().toLowerCase()??""}function uj(j){for(let w of j??[]){let H=lj.get(w);if(H)return H.route}return}function d(j,w,H,J){let $=j.meta.title??j.meta.key,Z=uj(j.meta.docId),U=j.meta.description;return{key:j.meta.key,version:j.meta.version,type:w,title:$,description:U,markdown:[`# ${$}`,`- Key: ${j.meta.key}`,`- Type: ${w}`,`- Version: ${j.meta.version}`,Z?`- Docs route: ${Z}`:"",U?`
2
2
  ${U}`:""].filter(Boolean).join(`
3
- `),...Z?{route:Z}:{},...H?{schema:H}:{},...J?{policy:J}:{},tags:j.meta.tags??[],owners:j.meta.owners??[],stability:j.meta.stability}}function l(j){let w=j.includeSchema??!1,H=pj(j.type),J=R(j.key,j.version);if(J&&(!H||H==="operation"||H===J.meta.kind))return{reference:d(J,J.meta.kind,w?k(j.key,j.version):void 0,J.policy)};let $=[{type:"data-view",spec:b(j.key,j.version),schema:w?y(j.key,j.version):void 0},{type:"form",spec:D(j.key,j.version),schema:w?p(j.key,j.version):void 0},{type:"presentation",spec:C(j.key,j.version),schema:w?m(j.key,j.version):void 0},{type:"event",spec:z(j.key,j.version),schema:w?f(j.key,j.version):void 0}];for(let Z of $)if(Z.spec&&(!H||H===Z.type))return{reference:d(Z.spec,Z.type,Z.schema)};throw Error(`Contract reference not found: ${j.key}`)}import{defineCommand as P,defineSchemaModel as N,installOp as W,OperationSpecRegistry as lj}from"@contractspec/lib.contracts-spec";import{ContractReferenceInput as gj,ContractReferenceOutput as uj,DocsIndexInput as nj,DocsIndexOutput as cj}from"@contractspec/lib.contracts-spec/docs";import{ScalarTypeEnum as F}from"@contractspec/lib.schema";var A=["@contractspec"],G=["docs","mcp"],ij=N({name:"DocsGetInput",fields:{id:{type:F.String_unsecure(),isOptional:!1}}}),aj=N({name:"DocsGetOutput",fields:{doc:{type:F.JSON(),isOptional:!1},content:{type:F.String_unsecure(),isOptional:!1}}}),oj=N({name:"DocsResolveRouteInput",fields:{route:{type:F.String_unsecure(),isOptional:!1}}}),sj=N({name:"DocsResolveRouteOutput",fields:{doc:{type:F.JSON(),isOptional:!1},content:{type:F.String_unsecure(),isOptional:!1}}}),tj=N({name:"DocsFacetsInput",fields:{}}),rj=N({name:"DocsFacetsOutput",fields:{facets:{type:F.JSON(),isOptional:!1}}});function Ww(j){let w=new lj;return W(w,P({meta:{key:"docs.search",version:"1.0.0",stability:"beta",owners:A,tags:G,description:"Search ContractSpec docs by query, tag, kind, or visibility.",goal:"Find the most relevant DocBlocks without browsing the full corpus.",context:"Read-only docs MCP search surface."},io:{input:nj,output:cj},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_search-v1_0_0"}}}),async(H)=>S(j,H)),W(w,P({meta:{key:"docs.get",version:"1.0.0",stability:"beta",owners:A,tags:G,description:"Read a single DocBlock by id.",goal:"Fetch the exact markdown content and metadata for a known doc id.",context:"Read-only docs MCP surface."},io:{input:ij,output:aj},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_get-v1_0_0"}}}),async({id:H})=>{let J=h(H);if(!J)throw Error(`DocBlock not found: ${H}`);return J}),W(w,P({meta:{key:"docs.resolveRoute",version:"1.0.0",stability:"beta",owners:A,tags:G,description:"Resolve a docs route to the matching DocBlock.",goal:"Turn a route or URL path into a canonical doc id and markdown body.",context:"Read-only docs MCP surface."},io:{input:oj,output:sj},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_resolve_route-v1_0_0"}}}),async({route:H})=>{let J=T(j,H);if(!J)throw Error(`Doc route not found: ${H}`);return J}),W(w,P({meta:{key:"docs.contract.lookup",version:"1.0.0",stability:"beta",owners:A,tags:G,description:"Resolve a ContractSpec surface into a docs-ready reference payload.",goal:"Get canonical docs metadata, route, and optional schema for a spec key.",context:"Read-only docs MCP surface."},io:{input:gj,output:uj},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_contract_reference-v1_0_0"}}}),async(H)=>l(H)),W(w,P({meta:{key:"docs.list.facets",version:"1.0.0",stability:"beta",owners:A,tags:G,description:"List docs taxonomy facets such as tags, kinds, and visibilities.",goal:"Help agents browse the docs corpus before making targeted reads.",context:"Read-only docs MCP surface."},io:{input:tj,output:rj},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_list_facets-v1_0_0"}}}),async()=>({facets:v(j)})),w}export{Ww as buildDocOps};
3
+ `),...Z?{route:Z}:{},...H?{schema:H}:{},...J?{policy:J}:{},tags:j.meta.tags??[],owners:j.meta.owners??[],stability:j.meta.stability}}function l(j){let w=j.includeSchema??!1,H=gj(j.type),J=R(j.key,j.version);if(J&&(!H||H==="operation"||H===J.meta.kind))return{reference:d(J,J.meta.kind,w?k(j.key,j.version):void 0,J.policy)};let $=[{type:"data-view",spec:b(j.key,j.version),schema:w?y(j.key,j.version):void 0},{type:"form",spec:D(j.key,j.version),schema:w?p(j.key,j.version):void 0},{type:"presentation",spec:C(j.key,j.version),schema:w?m(j.key,j.version):void 0},{type:"event",spec:z(j.key,j.version),schema:w?f(j.key,j.version):void 0}];for(let Z of $)if(Z.spec&&(!H||H===Z.type))return{reference:d(Z.spec,Z.type,Z.schema)};throw Error(`Contract reference not found: ${j.key}`)}import{defineCommand as P,defineSchemaModel as N,installOp as W,OperationSpecRegistry as nj}from"@contractspec/lib.contracts-spec";import{ContractReferenceInput as cj,ContractReferenceOutput as ij,DocsIndexInput as aj,DocsIndexOutput as oj}from"@contractspec/lib.contracts-spec/docs";import{ScalarTypeEnum as F}from"@contractspec/lib.schema";var A=["@contractspec"],G=["docs","mcp"],sj=N({name:"DocsGetInput",fields:{id:{type:F.String_unsecure(),isOptional:!1}}}),tj=N({name:"DocsGetOutput",fields:{doc:{type:F.JSON(),isOptional:!1},content:{type:F.String_unsecure(),isOptional:!1}}}),rj=N({name:"DocsResolveRouteInput",fields:{route:{type:F.String_unsecure(),isOptional:!1}}}),ej=N({name:"DocsResolveRouteOutput",fields:{doc:{type:F.JSON(),isOptional:!1},content:{type:F.String_unsecure(),isOptional:!1}}}),jw=N({name:"DocsFacetsInput",fields:{}}),ww=N({name:"DocsFacetsOutput",fields:{facets:{type:F.JSON(),isOptional:!1}}});function Iw(j){let w=new nj;return W(w,P({meta:{key:"docs.search",version:"1.0.0",stability:"beta",owners:A,tags:G,description:"Search ContractSpec docs by query, tag, kind, or visibility.",goal:"Find the most relevant DocBlocks without browsing the full corpus.",context:"Read-only docs MCP search surface."},io:{input:aj,output:oj},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_search-v1_0_0"}}}),async(H)=>S(j,H)),W(w,P({meta:{key:"docs.get",version:"1.0.0",stability:"beta",owners:A,tags:G,description:"Read a single DocBlock by id.",goal:"Fetch the exact markdown content and metadata for a known doc id.",context:"Read-only docs MCP surface."},io:{input:sj,output:tj},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_get-v1_0_0"}}}),async({id:H})=>{let J=h(H);if(!J)throw Error(`DocBlock not found: ${H}`);return J}),W(w,P({meta:{key:"docs.resolveRoute",version:"1.0.0",stability:"beta",owners:A,tags:G,description:"Resolve a docs route to the matching DocBlock.",goal:"Turn a route or URL path into a canonical doc id and markdown body.",context:"Read-only docs MCP surface."},io:{input:rj,output:ej},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_resolve_route-v1_0_0"}}}),async({route:H})=>{let J=T(j,H);if(!J)throw Error(`Doc route not found: ${H}`);return J}),W(w,P({meta:{key:"docs.contract.lookup",version:"1.0.0",stability:"beta",owners:A,tags:G,description:"Resolve a ContractSpec surface into a docs-ready reference payload.",goal:"Get canonical docs metadata, route, and optional schema for a spec key.",context:"Read-only docs MCP surface."},io:{input:cj,output:ij},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_contract_reference-v1_0_0"}}}),async(H)=>l(H)),W(w,P({meta:{key:"docs.list.facets",version:"1.0.0",stability:"beta",owners:A,tags:G,description:"List docs taxonomy facets such as tags, kinds, and visibilities.",goal:"Help agents browse the docs corpus before making targeted reads.",context:"Read-only docs MCP surface."},io:{input:jw,output:ww},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_list_facets-v1_0_0"}}}),async()=>({facets:v(j)})),w}export{Iw as buildDocOps};
@@ -1,4 +1,4 @@
1
- import{Logger as Dj,LogLevel as Cj}from"@contractspec/lib.logger";function Aj(){return"production"}var LY=()=>new Dj({level:Cj.INFO,environment:Aj(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),D=LY(),OJ=new Dj({level:Cj.WARN,environment:Aj(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),RJ=new Dj({level:Cj.INFO,environment:Aj(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1});import{createNodeAdapters as qY,onboarding as Ej}from"@contractspec/bundle.workspace";import{defineCommand as Ij,definePrompt as _Y,defineResourceTemplate as Nj,installOp as zj}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as o,ScalarTypeEnum as q}from"@contractspec/lib.schema";import C from"zod";var E=["cli","mcp","onboarding"],Zj=["@contractspec"];function MY(j){return j?.split(",").map((Y)=>Y.trim()).filter(Boolean)}async function $j(j={}){let Y=qY({cwd:process.cwd(),silent:!0});return Ej.buildOnboardingPlan(Y,{forcedExampleKey:j.example,selectedTracks:MY(j.tracks)})}function pj(j){j.register(Nj({meta:{uriTemplate:"onboarding://tracks",title:"Onboarding tracks",description:"Primary ContractSpec onboarding tracks exposed by the CLI.",mimeType:"application/json",tags:E},input:C.object({}),resolve:async()=>({uri:"onboarding://tracks",mimeType:"application/json",data:JSON.stringify(Ej.listOnboardingTracks(),null,2)})})),j.register(Nj({meta:{uriTemplate:"onboarding://track/{id}",title:"Onboarding track",description:"Track-specific onboarding metadata and recommended commands.",mimeType:"application/json",tags:E},input:C.object({id:C.string()}),resolve:async({id:Y})=>({uri:`onboarding://track/${Y}`,mimeType:"application/json",data:JSON.stringify(Ej.getOnboardingTrack(Y)??null,null,2)})})),j.register(Nj({meta:{uriTemplate:"onboarding://artifacts/{id}{?tracks,example}",title:"Rendered onboarding artifact",description:"Render AGENTS.md or USAGE.md content for the current repo.",mimeType:"text/markdown",tags:E},input:C.object({example:C.string().optional(),id:C.enum(["agent-guide","human-guide"]),tracks:C.string().optional()}),resolve:async({example:Y,id:J,tracks:Q})=>{let $=await $j({example:Y,tracks:Q});return{uri:`onboarding://artifacts/${J}`,mimeType:"text/markdown",data:J==="agent-guide"?$.guides.agentGuide:$.guides.humanGuide}}}))}function lj(j){j.register(_Y({meta:{key:"cli.onboarding",version:"1.0.0",title:"Plan a ContractSpec onboarding flow",description:"Suggest the right onboarding track and artifacts for a repo.",tags:E,stability:"beta",owners:Zj},args:[{name:"goal",description:"Repository onboarding goal or focus area.",required:!1,schema:C.string().optional()}],input:C.object({goal:C.string().optional()}),render:async({goal:Y})=>[{type:"text",text:`Use onboarding://tracks and onboarding_suggestTracks-v1_0_0 before recommending repo-local ContractSpec adoption steps.${Y?` Goal: ${Y}.`:""}`},{type:"resource",uri:"onboarding://tracks",title:"Tracks"}]}))}function nj(j){let Y=o({name:"OnboardingSuggestTracksInput",fields:{example:{type:q.String_unsecure(),isOptional:!0},tracks:{type:q.String_unsecure(),isOptional:!0}}}),J=o({name:"OnboardingSuggestTracksOutput",fields:{nextCommands:{type:q.String_unsecure(),isArray:!0,isOptional:!1},primaryTrack:{type:q.String_unsecure(),isOptional:!1},reason:{type:q.String_unsecure(),isOptional:!1},tracks:{type:q.String_unsecure(),isArray:!0,isOptional:!1}}}),Q=o({name:"OnboardingRenderArtifactOutput",fields:{content:{type:q.String_unsecure(),isOptional:!1},primaryTrack:{type:q.String_unsecure(),isOptional:!1}}}),$=o({name:"OnboardingNextCommandOutput",fields:{nextCommand:{type:q.String_unsecure(),isOptional:!1},primaryTrack:{type:q.String_unsecure(),isOptional:!1}}});zj(j,Ij({meta:{key:"onboarding.suggestTracks",version:"1.0.0",stability:"stable",owners:Zj,tags:E,description:"Suggest the recommended ContractSpec onboarding tracks.",goal:"Help agents choose the right onboarding track before editing repo-local guides.",context:"Used inside the CLI MCP server."},io:{input:Y,output:J},policy:{auth:"anonymous"}}),async({example:Z,tracks:X})=>{let U=await $j({example:Z,tracks:X});return{nextCommands:U.nextCommands,primaryTrack:U.primaryTrack.id,reason:U.recommendations[0]?.reason??U.primaryTrack.summary,tracks:U.recommendations.map((V)=>V.track.id)}}),zj(j,Ij({meta:{key:"onboarding.renderArtifacts",version:"1.0.0",stability:"stable",owners:Zj,tags:E,description:"Render onboarding artifacts for the current repo.",goal:"Provide AGENTS.md or USAGE.md content without mutating the repo.",context:"Used inside the CLI MCP server."},io:{input:o({name:"OnboardingRenderArtifactInput",fields:{artifact:{type:q.String_unsecure(),isOptional:!1},example:{type:q.String_unsecure(),isOptional:!0},tracks:{type:q.String_unsecure(),isOptional:!0}}}),output:Q},policy:{auth:"anonymous"}}),async({artifact:Z,example:X,tracks:U})=>{let V=await $j({example:X,tracks:U});return{content:Z==="agent-guide"?V.guides.agentGuide:V.guides.humanGuide,primaryTrack:V.primaryTrack.id}}),zj(j,Ij({meta:{key:"onboarding.nextCommand",version:"1.0.0",stability:"stable",owners:Zj,tags:E,description:"Return the next recommended CLI command for onboarding.",goal:"Help agents choose the next onboarding command without mutating the repo.",context:"Used inside the CLI MCP server."},io:{input:Y,output:$},policy:{auth:"anonymous"}}),async({example:Z,tracks:X})=>{let U=await $j({example:Z,tracks:X});return{nextCommand:U.nextCommands[0]??"contractspec onboard",primaryTrack:U.primaryTrack.id}})}var cj=["application/json","text/event-stream"];function bY(j){return!j||j.includes("*/*")||j.includes("application/*")||cj.some((Y)=>j.includes(Y))}function kj(j){if(j.method!=="POST")return j;let Y=j.headers.get("accept");if(!bY(Y))return j;let J=cj.filter(($)=>!Y?.includes($));if(J.length===0)return j;let Q=new Headers(j.headers);return Q.set("accept",[Y,...J].filter(Boolean).join(", ")),new Request(j,{headers:Q})}import{createMcpServer as GY}from"@contractspec/lib.contracts-runtime-server-mcp/provider-mcp";import{PresentationRegistry as DY}from"@contractspec/lib.contracts-spec/presentations";import{McpServer as CY}from"@modelcontextprotocol/sdk/server/mcp.js";import{WebStandardStreamableHTTPServerTransport as AY}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";import{randomUUID as IY}from"crypto";import{Elysia as NY}from"elysia";var zY={actor:"anonymous",decide:async()=>({effect:"allow"})};function vj(j,Y,J,Q){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:Y,message:J,...Q?{data:Q}:{}},id:null}),{status:j,headers:{"content-type":"application/json"}})}function ij({logger:j,serverName:Y,ops:J,resources:Q,prompts:$,presentations:Z,stateful:X}){let U=new CY({name:Y,version:"1.0.0"},{capabilities:{tools:{},resources:{},prompts:{},logging:{}}});j.info("Setting up MCP server..."),GY(U,J,Q,$,{logger:j,toolCtx:()=>zY,promptCtx:()=>({locale:"en"}),resourceCtx:()=>({locale:"en"}),presentations:new DY(Z)});let V=new AY({sessionIdGenerator:X?()=>IY():void 0,enableJsonResponse:!0});return U.connect(V).then(()=>({server:U,transport:V}))}async function Xj(j){await Promise.allSettled([j.transport.close(),j.server.close()])}function EY(j){return j instanceof Error?j.stack??j.message:String(j)}function A({logger:j,path:Y,serverName:J,ops:Q,resources:$,prompts:Z,presentations:X,validateAuth:U,requiredAuthMethods:V}){j.info("Setting up MCP handler...",{requiredAuthMethods:V??[]});let B=process.env.CONTRACTSPEC_MCP_STATEFUL==="1",H=new Map;async function K(W){let x=await ij({logger:j,path:Y,serverName:J,ops:Q,resources:$,prompts:Z,presentations:X,stateful:!1});try{return await x.transport.handleRequest(kj(W))}finally{await Xj(x)}}async function P(W){let x=H.get(W);if(!x)return;H.delete(W),await Xj(x)}async function Gj(W){let x=W.headers.get("mcp-session-id"),N,i=!1;if(x){let z=H.get(x);if(!z)return vj(404,-32001,"Session not found");N=z}else N=await ij({logger:j,path:Y,serverName:J,ops:Q,resources:$,prompts:Z,presentations:X,stateful:!0}),i=!0;try{let z=await N.transport.handleRequest(kj(W)),h=N.transport.sessionId;if(h&&!H.has(h))H.set(h,N);if(W.method==="DELETE"&&h)await P(h);else if(!h&&i)await Xj(N);return z}catch(z){if(i)await Xj(N);throw z}}return new NY({name:`mcp-${J}`}).all(Y,async({request:W})=>{try{if(U){let x=await U(W);if(!x.valid)return vj(401,-32002,"Authentication failed",x.reason)}if(B)return await Gj(W);return await K(W)}catch(x){return j.error("Error handling MCP request",{path:Y,method:W.method,error:EY(x)}),vj(500,-32000,"Internal error")}})}import kY from"node:fs/promises";import{defineCommand as vY,definePrompt as OY,defineResourceTemplate as oj,installOp as RY,OperationSpecRegistry as hY,PromptRegistry as TY,ResourceRegistry as fY}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as aj,ScalarTypeEnum as a}from"@contractspec/lib.schema";import t from"path";import T from"zod";var __dirname="/home/runner/work/contractspec/contractspec/packages/bundles/library/src/application/mcp",SY={quickstart:"packages/apps/cli-contractspec/QUICK_START.md",reference:"packages/apps/cli-contractspec/QUICK_REFERENCE.md",readme:"packages/apps/cli-contractspec/README.md"},yY={quickstart:`# ContractSpec CLI quickstart
1
+ var LY=Object.defineProperty;var qY=(j)=>j;function _Y(j,Y){this[j]=qY.bind(null,Y)}var hJ=(j,Y)=>{for(var J in Y)LY(j,J,{get:Y[J],enumerable:!0,configurable:!0,set:_Y.bind(Y,J)})};var TJ=(j,Y)=>()=>(j&&(Y=j(j=0)),Y);import{Logger as Dj,LogLevel as Cj}from"@contractspec/lib.logger";function Aj(){return"production"}var MY=()=>new Dj({level:Cj.INFO,environment:Aj(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),D=MY(),yJ=new Dj({level:Cj.WARN,environment:Aj(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),mJ=new Dj({level:Cj.INFO,environment:Aj(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1});import{createNodeAdapters as bY,onboarding as Ej}from"@contractspec/bundle.workspace";import{defineCommand as Ij,definePrompt as GY,defineResourceTemplate as Nj,installOp as zj}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as o,ScalarTypeEnum as q}from"@contractspec/lib.schema";import C from"zod";var E=["cli","mcp","onboarding"],Zj=["@contractspec"];function DY(j){return j?.split(",").map((Y)=>Y.trim()).filter(Boolean)}async function $j(j={}){let Y=bY({cwd:process.cwd(),silent:!0});return Ej.buildOnboardingPlan(Y,{forcedExampleKey:j.example,selectedTracks:DY(j.tracks)})}function pj(j){j.register(Nj({meta:{uriTemplate:"onboarding://tracks",title:"Onboarding tracks",description:"Primary ContractSpec onboarding tracks exposed by the CLI.",mimeType:"application/json",tags:E},input:C.object({}),resolve:async()=>({uri:"onboarding://tracks",mimeType:"application/json",data:JSON.stringify(Ej.listOnboardingTracks(),null,2)})})),j.register(Nj({meta:{uriTemplate:"onboarding://track/{id}",title:"Onboarding track",description:"Track-specific onboarding metadata and recommended commands.",mimeType:"application/json",tags:E},input:C.object({id:C.string()}),resolve:async({id:Y})=>({uri:`onboarding://track/${Y}`,mimeType:"application/json",data:JSON.stringify(Ej.getOnboardingTrack(Y)??null,null,2)})})),j.register(Nj({meta:{uriTemplate:"onboarding://artifacts/{id}{?tracks,example}",title:"Rendered onboarding artifact",description:"Render AGENTS.md or USAGE.md content for the current repo.",mimeType:"text/markdown",tags:E},input:C.object({example:C.string().optional(),id:C.enum(["agent-guide","human-guide"]),tracks:C.string().optional()}),resolve:async({example:Y,id:J,tracks:Q})=>{let $=await $j({example:Y,tracks:Q});return{uri:`onboarding://artifacts/${J}`,mimeType:"text/markdown",data:J==="agent-guide"?$.guides.agentGuide:$.guides.humanGuide}}}))}function lj(j){j.register(GY({meta:{key:"cli.onboarding",version:"1.0.0",title:"Plan a ContractSpec onboarding flow",description:"Suggest the right onboarding track and artifacts for a repo.",tags:E,stability:"beta",owners:Zj},args:[{name:"goal",description:"Repository onboarding goal or focus area.",required:!1,schema:C.string().optional()}],input:C.object({goal:C.string().optional()}),render:async({goal:Y})=>[{type:"text",text:`Use onboarding://tracks and onboarding_suggestTracks-v1_0_0 before recommending repo-local ContractSpec adoption steps.${Y?` Goal: ${Y}.`:""}`},{type:"resource",uri:"onboarding://tracks",title:"Tracks"}]}))}function nj(j){let Y=o({name:"OnboardingSuggestTracksInput",fields:{example:{type:q.String_unsecure(),isOptional:!0},tracks:{type:q.String_unsecure(),isOptional:!0}}}),J=o({name:"OnboardingSuggestTracksOutput",fields:{nextCommands:{type:q.String_unsecure(),isArray:!0,isOptional:!1},primaryTrack:{type:q.String_unsecure(),isOptional:!1},reason:{type:q.String_unsecure(),isOptional:!1},tracks:{type:q.String_unsecure(),isArray:!0,isOptional:!1}}}),Q=o({name:"OnboardingRenderArtifactOutput",fields:{content:{type:q.String_unsecure(),isOptional:!1},primaryTrack:{type:q.String_unsecure(),isOptional:!1}}}),$=o({name:"OnboardingNextCommandOutput",fields:{nextCommand:{type:q.String_unsecure(),isOptional:!1},primaryTrack:{type:q.String_unsecure(),isOptional:!1}}});zj(j,Ij({meta:{key:"onboarding.suggestTracks",version:"1.0.0",stability:"stable",owners:Zj,tags:E,description:"Suggest the recommended ContractSpec onboarding tracks.",goal:"Help agents choose the right onboarding track before editing repo-local guides.",context:"Used inside the CLI MCP server."},io:{input:Y,output:J},policy:{auth:"anonymous"}}),async({example:Z,tracks:X})=>{let U=await $j({example:Z,tracks:X});return{nextCommands:U.nextCommands,primaryTrack:U.primaryTrack.id,reason:U.recommendations[0]?.reason??U.primaryTrack.summary,tracks:U.recommendations.map((V)=>V.track.id)}}),zj(j,Ij({meta:{key:"onboarding.renderArtifacts",version:"1.0.0",stability:"stable",owners:Zj,tags:E,description:"Render onboarding artifacts for the current repo.",goal:"Provide AGENTS.md or USAGE.md content without mutating the repo.",context:"Used inside the CLI MCP server."},io:{input:o({name:"OnboardingRenderArtifactInput",fields:{artifact:{type:q.String_unsecure(),isOptional:!1},example:{type:q.String_unsecure(),isOptional:!0},tracks:{type:q.String_unsecure(),isOptional:!0}}}),output:Q},policy:{auth:"anonymous"}}),async({artifact:Z,example:X,tracks:U})=>{let V=await $j({example:X,tracks:U});return{content:Z==="agent-guide"?V.guides.agentGuide:V.guides.humanGuide,primaryTrack:V.primaryTrack.id}}),zj(j,Ij({meta:{key:"onboarding.nextCommand",version:"1.0.0",stability:"stable",owners:Zj,tags:E,description:"Return the next recommended CLI command for onboarding.",goal:"Help agents choose the next onboarding command without mutating the repo.",context:"Used inside the CLI MCP server."},io:{input:Y,output:$},policy:{auth:"anonymous"}}),async({example:Z,tracks:X})=>{let U=await $j({example:Z,tracks:X});return{nextCommand:U.nextCommands[0]??"contractspec onboard",primaryTrack:U.primaryTrack.id}})}var cj=["application/json","text/event-stream"];function CY(j){return!j||j.includes("*/*")||j.includes("application/*")||cj.some((Y)=>j.includes(Y))}function kj(j){if(j.method!=="POST")return j;let Y=j.headers.get("accept");if(!CY(Y))return j;let J=cj.filter(($)=>!Y?.includes($));if(J.length===0)return j;let Q=new Headers(j.headers);return Q.set("accept",[Y,...J].filter(Boolean).join(", ")),new Request(j,{headers:Q})}import{createMcpServer as AY}from"@contractspec/lib.contracts-runtime-server-mcp/provider-mcp";import{PresentationRegistry as IY}from"@contractspec/lib.contracts-spec/presentations";import{McpServer as NY}from"@modelcontextprotocol/sdk/server/mcp.js";import{WebStandardStreamableHTTPServerTransport as zY}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";import{randomUUID as EY}from"crypto";import{Elysia as kY}from"elysia";var vY={actor:"anonymous",decide:async()=>({effect:"allow"})};function vj(j,Y,J,Q){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:Y,message:J,...Q?{data:Q}:{}},id:null}),{status:j,headers:{"content-type":"application/json"}})}function ij({logger:j,serverName:Y,ops:J,resources:Q,prompts:$,presentations:Z,stateful:X}){let U=new NY({name:Y,version:"1.0.0"},{capabilities:{tools:{},resources:{},prompts:{},logging:{}}});j.info("Setting up MCP server..."),AY(U,J,Q,$,{logger:j,toolCtx:()=>vY,promptCtx:()=>({locale:"en"}),resourceCtx:()=>({locale:"en"}),presentations:new IY(Z)});let V=new zY({sessionIdGenerator:X?()=>EY():void 0,enableJsonResponse:!0});return U.connect(V).then(()=>({server:U,transport:V}))}async function Xj(j){await Promise.allSettled([j.transport.close(),j.server.close()])}function OY(j){return j instanceof Error?j.stack??j.message:String(j)}function A({logger:j,path:Y,serverName:J,ops:Q,resources:$,prompts:Z,presentations:X,validateAuth:U,requiredAuthMethods:V}){j.info("Setting up MCP handler...",{requiredAuthMethods:V??[]});let B=process.env.CONTRACTSPEC_MCP_STATEFUL==="1",H=new Map;async function K(W){let x=await ij({logger:j,path:Y,serverName:J,ops:Q,resources:$,prompts:Z,presentations:X,stateful:!1});try{return await x.transport.handleRequest(kj(W))}finally{await Xj(x)}}async function P(W){let x=H.get(W);if(!x)return;H.delete(W),await Xj(x)}async function Gj(W){let x=W.headers.get("mcp-session-id"),N,i=!1;if(x){let z=H.get(x);if(!z)return vj(404,-32001,"Session not found");N=z}else N=await ij({logger:j,path:Y,serverName:J,ops:Q,resources:$,prompts:Z,presentations:X,stateful:!0}),i=!0;try{let z=await N.transport.handleRequest(kj(W)),h=N.transport.sessionId;if(h&&!H.has(h))H.set(h,N);if(W.method==="DELETE"&&h)await P(h);else if(!h&&i)await Xj(N);return z}catch(z){if(i)await Xj(N);throw z}}return new kY({name:`mcp-${J}`}).all(Y,async({request:W})=>{try{if(U){let x=await U(W);if(!x.valid)return vj(401,-32002,"Authentication failed",x.reason)}if(B)return await Gj(W);return await K(W)}catch(x){return j.error("Error handling MCP request",{path:Y,method:W.method,error:OY(x)}),vj(500,-32000,"Internal error")}})}import RY from"node:fs/promises";import{defineCommand as hY,definePrompt as TY,defineResourceTemplate as oj,installOp as fY,OperationSpecRegistry as SY,PromptRegistry as yY,ResourceRegistry as mY}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as aj,ScalarTypeEnum as a}from"@contractspec/lib.schema";import t from"path";import T from"zod";var __dirname="/home/runner/work/contractspec/contractspec/packages/bundles/library/src/application/mcp",gY={quickstart:"packages/apps/cli-contractspec/QUICK_START.md",reference:"packages/apps/cli-contractspec/QUICK_REFERENCE.md",readme:"packages/apps/cli-contractspec/README.md"},dY={quickstart:`# ContractSpec CLI quickstart
2
2
 
3
3
  contractspec quickstart
4
4
  contractspec onboard
@@ -6,11 +6,11 @@ contractspec validate`,reference:`# ContractSpec CLI reference
6
6
 
7
7
  Key commands: onboard, create, generate, validate. See README for full options.`,readme:`# ContractSpec CLI
8
8
 
9
- Stabilize AI-generated code across API, DB, UI, events. Use onboard/create/generate/validate commands.`},Vj=["cli","mcp"],tj=["@contractspec"],mY=(()=>{let j=new Set([process.cwd(),t.resolve(process.cwd(),".."),t.resolve(process.cwd(),"../.."),t.resolve(process.cwd(),"../../..")]);if(typeof __dirname==="string")j.add(t.resolve(__dirname,"../../../../.."));return[...j]})(),Uj=new Map;async function gY(j){if(Uj.has(j))return Uj.get(j);let Y=SY[j];for(let Q of mY){let $=t.resolve(Q,Y);try{let Z=await kY.readFile($,"utf8");return Uj.set(j,Z),Z}catch{}}let J=yY[j];return Uj.set(j,J),J}function dY(){let j=new fY;return j.register(oj({meta:{uriTemplate:"cli://doc/{slug}",title:"CLI documentation",description:"Quickstart, reference, and README for the CLI.",mimeType:"text/markdown",tags:Vj},input:T.object({slug:T.enum(["quickstart","reference","readme"])}),resolve:async({slug:Y})=>{let J=await gY(Y);return{uri:`cli://doc/${Y}`,mimeType:"text/markdown",data:J}}})),j.register(oj({meta:{uriTemplate:"cli://commands",title:"CLI commands summary",description:"Key ContractSpec CLI commands and when to use them.",mimeType:"application/json",tags:Vj},input:T.object({}),resolve:async()=>{return{uri:"cli://commands",mimeType:"application/json",data:JSON.stringify([{command:"contractspec onboard",summary:"Generate repo-local AGENTS.md and USAGE.md guidance plus recommended tracks.",doc:"cli://doc/quickstart"},{command:"contractspec create",summary:"Interactive wizard to author specs (with optional AI).",doc:"cli://doc/quickstart"},{command:"contractspec build <specPath>",summary:"Generate implementation code from a ContractSpec (agents + templates).",doc:"cli://doc/reference"},{command:"contractspec validate <specPath>",summary:"Validate specs and optionally check implementations against them.",doc:"cli://doc/reference"}],null,2)}}})),pj(j),j}function uY(){let j=new TY;return j.register(OY({meta:{key:"cli.usage",version:"1.0.0",title:"Use ContractSpec CLI safely",description:"Remind agents to read CLI docs and pick commands from the canonical list.",tags:Vj,stability:"beta",owners:tj},args:[{name:"goal",description:"Task the user wants to achieve.",required:!1,schema:T.string().optional()}],input:T.object({goal:T.string().optional()}),render:async({goal:Y})=>[{type:"text",text:`Use CLI commands only from cli://commands. Prefer quickstart for newcomers and reference for options.${Y?` Goal: ${Y}.`:""}`},{type:"resource",uri:"cli://commands",title:"Commands"},{type:"resource",uri:"cli://doc/quickstart",title:"Quickstart"}]})),lj(j),j}function pY(){let j=new hY,Y=aj({name:"CliSuggestInput",fields:{goal:{type:a.String_unsecure(),isOptional:!1},prefersAi:{type:a.Boolean(),isOptional:!0}}}),J=aj({name:"CliSuggestOutput",fields:{command:{type:a.String_unsecure(),isOptional:!1},docUri:{type:a.String_unsecure(),isOptional:!1},reason:{type:a.String_unsecure(),isOptional:!1}}}),Q=vY({meta:{key:"cli_suggestCommand",version:"1.0.0",stability:"stable",owners:tj,tags:Vj,description:"Recommend a CLI command for the requested goal.",goal:"Help AI agents choose the correct CLI entrypoint quickly.",context:"Used inside the CLI MCP server."},io:{input:Y,output:J},policy:{auth:"anonymous"}});return RY(j,Q,async({goal:$,prefersAi:Z})=>{let X=$.toLowerCase();if(X.includes("onboard")||X.includes("start")||X.includes("guide")||X.includes("install"))return{command:"contractspec onboard",docUri:"cli://doc/quickstart",reason:"Starts the CLI-first onboarding flow for the current repo."};if(X.includes("create")||X.includes("new"))return{command:Z?"contractspec create --ai":"contractspec create",docUri:"cli://doc/quickstart",reason:"Creates a new ContractSpec interactively (optionally with AI)."};if(X.includes("build")||X.includes("generate"))return{command:"contractspec build <path-to-spec>",docUri:"cli://doc/reference",reason:"Builds implementation code from a spec using agents + templates."};if(X.includes("validate")||X.includes("check"))return{command:"contractspec validate <path-to-spec>",docUri:"cli://doc/reference",reason:"Validates a spec and optionally checks its implementation for drift."};return{command:"contractspec --help",docUri:"cli://doc/readme",reason:"Fallback when the goal is unclear; read README for options."}}),nj(j),j}function QQ(j="/api/mcp/cli"){return A({logger:D,path:j,serverName:"contractspec-cli-mcp",ops:pY(),resources:dY(),prompts:uY()})}import{definePrompt as lY,defineResourceTemplate as s,PromptRegistry as nY,ResourceRegistry as cY}from"@contractspec/lib.contracts-spec";import I from"zod";var iY=["@contractspec"],f=["contracts","mcp"];function sj(j){let Y=new cY;return Y.register(s({meta:{uriTemplate:"contracts://list",title:"Contract specs list",description:"JSON list of all contract specs in the workspace.",mimeType:"application/json",tags:f},input:I.object({}),resolve:async()=>{let J=await j.listSpecs();return{uri:"contracts://list",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),Y.register(s({meta:{uriTemplate:"contracts://spec/{path}",title:"Contract spec content",description:"Read a single contract spec file by path.",mimeType:"text/plain",tags:f},input:I.object({path:I.string()}),resolve:async({path:J})=>{let Q=await j.getSpec(J);if(!Q)return{uri:`contracts://spec/${encodeURIComponent(J)}`,mimeType:"text/plain",data:`Spec not found: ${J}`};return{uri:`contracts://spec/${encodeURIComponent(J)}`,mimeType:"text/plain",data:Q.content}}})),Y.register(s({meta:{uriTemplate:"contracts://registry/manifest",title:"Remote registry manifest",description:"Contract registry manifest from the remote server.",mimeType:"application/json",tags:f},input:I.object({}),resolve:async()=>{let J=await j.fetchRegistryManifest();return{uri:"contracts://registry/manifest",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),Y.register(s({meta:{uriTemplate:"adoption://catalog",title:"ContractSpec adoption catalog",description:"Bundled ContractSpec adoption catalog used by Connect and MCP.",mimeType:"application/json",tags:f},input:I.object({}),resolve:async()=>{let J=await j.searchAdoptionCatalog({query:"contractspec"});return{uri:"adoption://catalog",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),Y.register(s({meta:{uriTemplate:"adoption://policy/{family}",title:"ContractSpec adoption policy",description:"Family-aware adoption recommendation and verdict policy.",mimeType:"application/json",tags:f},input:I.object({family:I.string()}),resolve:async({family:J})=>{let Q=await j.resolveAdoption({family:J,query:J});return{uri:`adoption://policy/${encodeURIComponent(J)}`,mimeType:"application/json",data:JSON.stringify(Q,null,2)}}})),Y}function rj(){let j=new nY;return j.register(lY({meta:{key:"contracts.editor",version:"1.0.0",title:"Contract editing guide",description:"Guide AI agents through reading, editing, and validating contracts.",tags:f,stability:"beta",owners:iY},args:[{name:"goal",description:"What the agent wants to achieve with the contract.",required:!1,schema:I.string().optional()}],input:I.object({goal:I.string().optional()}),render:async({goal:Y})=>[{type:"text",text:["Contract editing workflow:","1. Use contracts.list to discover specs","2. Use contracts.get to read a spec","3. Edit content and call contracts.update","4. Run contracts.validate to verify changes","5. Run contracts.build to regenerate artifacts","6. Use adoption.resolve to prefer existing workspace or ContractSpec surfaces before inventing new ones",Y?`Agent goal: ${Y}`:""].filter(Boolean).join(`
10
- `)},{type:"resource",uri:"contracts://list",title:"Available contracts"}]})),j}import{defineCommand as Oj,installOp as Rj}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as S,ScalarTypeEnum as b}from"@contractspec/lib.schema";var hj=["@contractspec"],Tj=["contracts","mcp","adoption"];function ej(j,Y){let J=S({name:"AdoptionCatalogSearchInput",fields:{query:{type:b.String_unsecure(),isOptional:!1},family:{type:b.String_unsecure(),isOptional:!0},platform:{type:b.String_unsecure(),isOptional:!0}}}),Q=S({name:"AdoptionCatalogSearchOutput",fields:{results:{type:b.JSON(),isOptional:!1}}});Rj(j,Oj({meta:{key:"adoption.catalog_search",version:"1.0.0",stability:"beta",owners:hj,tags:Tj,description:"Search the local ContractSpec adoption catalog.",goal:"Find relevant ContractSpec reuse candidates for a query.",context:"Contracts MCP server."},io:{input:J,output:Q},policy:{auth:"anonymous"}}),async({family:V,platform:B,query:H})=>({results:await Y.searchAdoptionCatalog({family:V,platform:B,query:H})}));let $=S({name:"AdoptionResolveInput",fields:{family:{type:b.String_unsecure(),isOptional:!1},query:{type:b.String_unsecure(),isOptional:!1},paths:{type:b.JSON(),isOptional:!0},platform:{type:b.String_unsecure(),isOptional:!0},runtime:{type:b.String_unsecure(),isOptional:!0}}}),Z=S({name:"AdoptionResolveOutput",fields:{resolution:{type:b.JSON(),isOptional:!1}}});Rj(j,Oj({meta:{key:"adoption.resolve",version:"1.0.0",stability:"beta",owners:hj,tags:Tj,description:"Resolve the best adoption candidate for one family.",goal:"Provide one ordered recommendation that matches Connect.",context:"Contracts MCP server."},io:{input:$,output:Z},policy:{auth:"anonymous"}}),async({family:V,paths:B,platform:H,query:K,runtime:P})=>({resolution:await Y.resolveAdoption({family:V,paths:Array.isArray(B)?B:void 0,platform:H,query:K,runtime:P})}));let X=S({name:"AdoptionSyncInput",fields:{}}),U=S({name:"AdoptionSyncOutput",fields:{catalogPath:{type:b.String_unsecure(),isOptional:!1},total:{type:b.Int_unsecure(),isOptional:!1}}});Rj(j,Oj({meta:{key:"adoption.sync",version:"1.0.0",stability:"beta",owners:hj,tags:Tj,description:"Mirror the bundled ContractSpec adoption catalog locally.",goal:"Refresh the local adoption catalog used by Connect and MCP.",context:"Contracts MCP server."},io:{input:X,output:U},policy:{auth:"user"}}),async()=>Y.syncAdoptionCatalog())}import{defineCommand as y,installOp as m,OperationSpecRegistry as oY}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as G,ScalarTypeEnum as w}from"@contractspec/lib.schema";var g=["@contractspec"],d=["contracts","mcp"];function jY(j){let Y=new oY,J=G({name:"ContractsListInput",fields:{pattern:{type:w.String_unsecure(),isOptional:!0},type:{type:w.String_unsecure(),isOptional:!0}}}),Q=G({name:"ContractsListOutput",fields:{specs:{type:w.JSON(),isOptional:!1},total:{type:w.Int_unsecure(),isOptional:!1}}});m(Y,y({meta:{key:"contracts.list",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"List contract specs in the workspace.",goal:"Discover available contracts by type, pattern, or owner.",context:"Contracts MCP server."},io:{input:J,output:Q},policy:{auth:"anonymous"}}),async({pattern:H,type:K})=>{let P=await j.listSpecs({pattern:H,type:K});return{specs:P,total:P.length}});let $=G({name:"ContractsGetInput",fields:{path:{type:w.String_unsecure(),isOptional:!1}}}),Z=G({name:"ContractsGetOutput",fields:{content:{type:w.String_unsecure(),isOptional:!1},info:{type:w.JSON(),isOptional:!1}}});m(Y,y({meta:{key:"contracts.get",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"Read a single contract spec file.",goal:"Fetch spec content and parsed metadata.",context:"Contracts MCP server."},io:{input:$,output:Z},policy:{auth:"anonymous"}}),async({path:H})=>{let K=await j.getSpec(H);if(!K)throw Error(`Spec not found: ${H}`);return K});let X=G({name:"ContractsValidateInput",fields:{path:{type:w.String_unsecure(),isOptional:!1}}}),U=G({name:"ContractsValidateOutput",fields:{valid:{type:w.Boolean(),isOptional:!1},errors:{type:w.JSON(),isOptional:!1},warnings:{type:w.JSON(),isOptional:!1}}});m(Y,y({meta:{key:"contracts.validate",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"Validate a contract spec structure.",goal:"Check spec for structural or policy issues.",context:"Contracts MCP server."},io:{input:X,output:U},policy:{auth:"anonymous"}}),async({path:H})=>j.validateSpec(H));let V=G({name:"ContractsBuildInput",fields:{path:{type:w.String_unsecure(),isOptional:!1},dryRun:{type:w.Boolean(),isOptional:!0}}}),B=G({name:"ContractsBuildOutput",fields:{results:{type:w.JSON(),isOptional:!1}}});return m(Y,y({meta:{key:"contracts.build",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"Generate implementation code from a contract spec.",goal:"Produce handler, component, or test skeletons.",context:"Contracts MCP server."},io:{input:V,output:B},policy:{auth:"user"}}),async({path:H,dryRun:K})=>j.buildSpec(H,{dryRun:K})),aY(Y,j),ej(Y,j),Y}function aY(j,Y){let J=G({name:"ContractsUpdateInput",fields:{path:{type:w.String_unsecure(),isOptional:!1},content:{type:w.String_unsecure(),isOptional:!0},fields:{type:w.JSON(),isOptional:!0}}}),Q=G({name:"ContractsUpdateOutput",fields:{updated:{type:w.Boolean(),isOptional:!1},errors:{type:w.JSON(),isOptional:!1},warnings:{type:w.JSON(),isOptional:!1}}});m(j,y({meta:{key:"contracts.update",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"Update an existing contract spec.",goal:"Modify spec content or individual fields with validation.",context:"Contracts MCP server."},io:{input:J,output:Q},policy:{auth:"user"}}),async({path:X,content:U,fields:V})=>Y.updateSpec(X,{content:U,fields:Array.isArray(V)?V:void 0}));let $=G({name:"ContractsDeleteInput",fields:{path:{type:w.String_unsecure(),isOptional:!1},clean:{type:w.Boolean(),isOptional:!0}}}),Z=G({name:"ContractsDeleteOutput",fields:{deleted:{type:w.Boolean(),isOptional:!1},cleanedFiles:{type:w.JSON(),isOptional:!1},errors:{type:w.JSON(),isOptional:!1}}});m(j,y({meta:{key:"contracts.delete",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"Delete a contract spec and optionally its artifacts.",goal:"Remove a spec file and clean generated handlers/tests.",context:"Contracts MCP server."},io:{input:$,output:Z},policy:{auth:"user"}}),async({path:X,clean:U})=>Y.deleteSpec(X,{clean:U}))}function _Q(j="/api/mcp/contracts",Y){return A({logger:D,path:j,serverName:"contractspec-contracts-mcp",ops:jY(Y),resources:sj(Y),prompts:rj()})}import{defaultDocRegistry as tY}from"@contractspec/lib.contracts-spec/docs";var sY=20,rY=100;function _(j){return j?.trim().toLowerCase()??""}function YY(j){let Y=decodeURIComponent(j).trim();if(!Y)return"/";return Y.startsWith("/")?Y:`/${Y}`}function eY(j){return(Array.isArray(j)?j:j?[j]:[]).map((J)=>_(J)).filter(Boolean)}function j0(j){if(!j||Number.isNaN(j))return sY;return Math.min(Math.max(j,1),rY)}function Y0(j){if(!j||Number.isNaN(j))return 0;return Math.max(j,0)}function fj({block:j,route:Y}){return{id:j.id,title:j.title,summary:j.summary??"",route:Y,visibility:j.visibility??"public",kind:j.kind??"reference",version:j.version??"1.0.0",tags:j.tags??[]}}function J0(j,Y){if(!Y)return 1;let J=Y.split(/\s+/).filter(Boolean),Q=_(j.block.title),$=_(j.block.id),Z=_(j.block.summary),X=_(j.block.body),U=_(j.route),V=(j.block.tags??[]).map((K)=>_(K)),B=[Q,$,Z,X,U,...V].join(" ");if(J.some((K)=>!B.includes(K)))return 0;let H=0;for(let K of J){if($.includes(K))H+=8;if(Q.includes(K))H+=7;if(V.some((P)=>P.includes(K)))H+=5;if(Z.includes(K))H+=4;if(U.includes(K))H+=3;if(X.includes(K))H+=2}return H}function u(j,Y){let J=_(typeof Y.query==="string"?Y.query:void 0),Q=eY(Y.tag),$=_(typeof Y.visibility==="string"?Y.visibility:void 0),Z=_(typeof Y.kind==="string"?Y.kind:void 0),X=j0(typeof Y.limit==="number"?Y.limit:void 0),U=Y0(typeof Y.offset==="number"?Y.offset:void 0),V=j.map((K)=>({doc:fj(K),score:J0(K,J)})).filter(({doc:K,score:P})=>{let Gj=J?P>0:!0,W=Q.length?Q.every((i)=>K.tags.some((z)=>_(z).includes(i))):!0,x=$?_(K.visibility)===$:!0,N=Z?_(K.kind)===Z:!0;return Gj&&W&&x&&N}).sort((K,P)=>{if(P.score!==K.score)return P.score-K.score;return K.doc.title.localeCompare(P.doc.title)}),B=V.slice(U,U+X).map(({doc:K})=>K),H=U+B.length<V.length?U+B.length:void 0;return{docs:B,items:B,total:V.length,...H!=null?{nextOffset:H}:{}}}function Hj(j){let Y=decodeURIComponent(j),J=tY.get(Y);if(!J)return;return{doc:fj(J),content:String(J.block.body??"")}}function Kj(j,Y){let J=YY(Y),Q=j.find(($)=>YY($.route)===J);if(!Q)return;return{doc:fj(Q),content:String(Q.block.body??"")}}function wj(j){let Y=new Map,J=new Map,Q=new Map;for(let Z of j){let X=Z.block.kind??"reference",U=Z.block.visibility??"public";J.set(X,(J.get(X)??0)+1),Q.set(U,(Q.get(U)??0)+1);for(let V of Z.block.tags??[])Y.set(V,(Y.get(V)??0)+1)}let $=(Z,X)=>[...Z.entries()].sort((U,V)=>V[1]-U[1]||U[0].localeCompare(V[0])).map(([U,V])=>({[X]:U,count:V}));return{totalDocs:j.length,tags:$(Y,"tag"),kinds:$(J,"kind"),visibilities:$(Q,"visibility")}}import{EventRegistry as Q0,OperationSpecRegistry as Z0}from"@contractspec/lib.contracts-spec";import{DataViewRegistry as $0}from"@contractspec/lib.contracts-spec/data-views";import{ContractReferenceDataView as X0,ContractReferenceQuery as U0,DocsGenerateCommand as V0,DocsGeneratedEvent as H0,DocsIndexDataView as K0,DocsIndexQuery as w0,DocsLayoutPresentation as F0,DocsPublishCommand as B0,DocsPublishedEvent as W0,DocsReferencePagePresentation as x0,DocsSearchForm as P0,ExampleCatalogDataView as L0}from"@contractspec/lib.contracts-spec/docs";import{FormRegistry as q0}from"@contractspec/lib.contracts-spec/forms";import{PresentationRegistry as _0}from"@contractspec/lib.contracts-spec/presentations";import{serializeDataViewSpec as M0,serializeEventSpec as b0,serializeFormSpec as G0,serializeOperationSpec as D0,serializePresentationSpec as C0}from"@contractspec/lib.contracts-spec/serialization";var Fj=null;function A0(){let j=new Z0;return j.register(w0).register(U0).register(V0).register(B0),j}function I0(){if(!Fj)Fj=A0();return Fj}function Sj(j,Y){return I0().get(j,Y)}var Bj=null;function N0(){let j=new Q0;return j.register(H0).register(W0),j}function z0(){if(!Bj)Bj=N0();return Bj}function yj(j,Y){return z0().get(j,Y)}var Wj=null;function E0(){let j=new _0;return j.register(F0).register(x0),j}function k0(){if(!Wj)Wj=E0();return Wj}function mj(j,Y){return k0().get(j,Y)}var xj=null;function v0(){let j=new $0;return j.register(K0).register(X0).register(L0),j}function O0(){if(!xj)xj=v0();return xj}function gj(j,Y){return O0().get(j,Y)}var Pj=null;function R0(){let j=new q0;return j.register(P0),j}function h0(){if(!Pj)Pj=R0();return Pj}function dj(j,Y){return h0().get(j)}function JY(j,Y){let J=Sj(j,Y);return D0(J)??void 0}function QY(j,Y){let J=yj(j,Y);return b0(J)??void 0}function ZY(j,Y){let J=mj(j,Y);return C0(J)??void 0}function $Y(j,Y){let J=gj(j,Y);return M0(J)??void 0}function XY(j,Y){let J=dj(j,Y);return G0(J)??void 0}function T0(){Fj=null}function f0(){Bj=null}function S0(){Wj=null}function y0(){xj=null}function m0(){Pj=null}function EQ(){T0(),f0(),S0(),y0(),m0()}import{defaultDocRegistry as g0}from"@contractspec/lib.contracts-spec/docs";function d0(j){return j?.trim().toLowerCase()??""}function u0(j){for(let Y of j??[]){let J=g0.get(Y);if(J)return J.route}return}function UY(j,Y,J,Q){let $=j.meta.title??j.meta.key,Z=u0(j.meta.docId),X=j.meta.description;return{key:j.meta.key,version:j.meta.version,type:Y,title:$,description:X,markdown:[`# ${$}`,`- Key: ${j.meta.key}`,`- Type: ${Y}`,`- Version: ${j.meta.version}`,Z?`- Docs route: ${Z}`:"",X?`
9
+ Stabilize AI-generated code across API, DB, UI, events. Use onboard/create/generate/validate commands.`},Vj=["cli","mcp"],tj=["@contractspec"],uY=(()=>{let j=new Set([process.cwd(),t.resolve(process.cwd(),".."),t.resolve(process.cwd(),"../.."),t.resolve(process.cwd(),"../../..")]);if(typeof __dirname==="string")j.add(t.resolve(__dirname,"../../../../.."));return[...j]})(),Uj=new Map;async function pY(j){if(Uj.has(j))return Uj.get(j);let Y=gY[j];for(let Q of uY){let $=t.resolve(Q,Y);try{let Z=await RY.readFile($,"utf8");return Uj.set(j,Z),Z}catch{}}let J=dY[j];return Uj.set(j,J),J}function lY(){let j=new mY;return j.register(oj({meta:{uriTemplate:"cli://doc/{slug}",title:"CLI documentation",description:"Quickstart, reference, and README for the CLI.",mimeType:"text/markdown",tags:Vj},input:T.object({slug:T.enum(["quickstart","reference","readme"])}),resolve:async({slug:Y})=>{let J=await pY(Y);return{uri:`cli://doc/${Y}`,mimeType:"text/markdown",data:J}}})),j.register(oj({meta:{uriTemplate:"cli://commands",title:"CLI commands summary",description:"Key ContractSpec CLI commands and when to use them.",mimeType:"application/json",tags:Vj},input:T.object({}),resolve:async()=>{return{uri:"cli://commands",mimeType:"application/json",data:JSON.stringify([{command:"contractspec onboard",summary:"Generate repo-local AGENTS.md and USAGE.md guidance plus recommended tracks.",doc:"cli://doc/quickstart"},{command:"contractspec create",summary:"Interactive wizard to author specs (with optional AI).",doc:"cli://doc/quickstart"},{command:"contractspec build <specPath>",summary:"Generate implementation code from a ContractSpec (agents + templates).",doc:"cli://doc/reference"},{command:"contractspec validate <specPath>",summary:"Validate specs and optionally check implementations against them.",doc:"cli://doc/reference"}],null,2)}}})),pj(j),j}function nY(){let j=new yY;return j.register(TY({meta:{key:"cli.usage",version:"1.0.0",title:"Use ContractSpec CLI safely",description:"Remind agents to read CLI docs and pick commands from the canonical list.",tags:Vj,stability:"beta",owners:tj},args:[{name:"goal",description:"Task the user wants to achieve.",required:!1,schema:T.string().optional()}],input:T.object({goal:T.string().optional()}),render:async({goal:Y})=>[{type:"text",text:`Use CLI commands only from cli://commands. Prefer quickstart for newcomers and reference for options.${Y?` Goal: ${Y}.`:""}`},{type:"resource",uri:"cli://commands",title:"Commands"},{type:"resource",uri:"cli://doc/quickstart",title:"Quickstart"}]})),lj(j),j}function cY(){let j=new SY,Y=aj({name:"CliSuggestInput",fields:{goal:{type:a.String_unsecure(),isOptional:!1},prefersAi:{type:a.Boolean(),isOptional:!0}}}),J=aj({name:"CliSuggestOutput",fields:{command:{type:a.String_unsecure(),isOptional:!1},docUri:{type:a.String_unsecure(),isOptional:!1},reason:{type:a.String_unsecure(),isOptional:!1}}}),Q=hY({meta:{key:"cli_suggestCommand",version:"1.0.0",stability:"stable",owners:tj,tags:Vj,description:"Recommend a CLI command for the requested goal.",goal:"Help AI agents choose the correct CLI entrypoint quickly.",context:"Used inside the CLI MCP server."},io:{input:Y,output:J},policy:{auth:"anonymous"}});return fY(j,Q,async({goal:$,prefersAi:Z})=>{let X=$.toLowerCase();if(X.includes("onboard")||X.includes("start")||X.includes("guide")||X.includes("install"))return{command:"contractspec onboard",docUri:"cli://doc/quickstart",reason:"Starts the CLI-first onboarding flow for the current repo."};if(X.includes("create")||X.includes("new"))return{command:Z?"contractspec create --ai":"contractspec create",docUri:"cli://doc/quickstart",reason:"Creates a new ContractSpec interactively (optionally with AI)."};if(X.includes("build")||X.includes("generate"))return{command:"contractspec build <path-to-spec>",docUri:"cli://doc/reference",reason:"Builds implementation code from a spec using agents + templates."};if(X.includes("validate")||X.includes("check"))return{command:"contractspec validate <path-to-spec>",docUri:"cli://doc/reference",reason:"Validates a spec and optionally checks its implementation for drift."};return{command:"contractspec --help",docUri:"cli://doc/readme",reason:"Fallback when the goal is unclear; read README for options."}}),nj(j),j}function HQ(j="/api/mcp/cli"){return A({logger:D,path:j,serverName:"contractspec-cli-mcp",ops:cY(),resources:lY(),prompts:nY()})}import{definePrompt as iY,defineResourceTemplate as s,PromptRegistry as oY,ResourceRegistry as aY}from"@contractspec/lib.contracts-spec";import I from"zod";var tY=["@contractspec"],f=["contracts","mcp"];function sj(j){let Y=new aY;return Y.register(s({meta:{uriTemplate:"contracts://list",title:"Contract specs list",description:"JSON list of all contract specs in the workspace.",mimeType:"application/json",tags:f},input:I.object({}),resolve:async()=>{let J=await j.listSpecs();return{uri:"contracts://list",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),Y.register(s({meta:{uriTemplate:"contracts://spec/{path}",title:"Contract spec content",description:"Read a single contract spec file by path.",mimeType:"text/plain",tags:f},input:I.object({path:I.string()}),resolve:async({path:J})=>{let Q=await j.getSpec(J);if(!Q)return{uri:`contracts://spec/${encodeURIComponent(J)}`,mimeType:"text/plain",data:`Spec not found: ${J}`};return{uri:`contracts://spec/${encodeURIComponent(J)}`,mimeType:"text/plain",data:Q.content}}})),Y.register(s({meta:{uriTemplate:"contracts://registry/manifest",title:"Remote registry manifest",description:"Contract registry manifest from the remote server.",mimeType:"application/json",tags:f},input:I.object({}),resolve:async()=>{let J=await j.fetchRegistryManifest();return{uri:"contracts://registry/manifest",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),Y.register(s({meta:{uriTemplate:"adoption://catalog",title:"ContractSpec adoption catalog",description:"Bundled ContractSpec adoption catalog used by Connect and MCP.",mimeType:"application/json",tags:f},input:I.object({}),resolve:async()=>{let J=await j.searchAdoptionCatalog({query:"contractspec"});return{uri:"adoption://catalog",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),Y.register(s({meta:{uriTemplate:"adoption://policy/{family}",title:"ContractSpec adoption policy",description:"Family-aware adoption recommendation and verdict policy.",mimeType:"application/json",tags:f},input:I.object({family:I.string()}),resolve:async({family:J})=>{let Q=await j.resolveAdoption({family:J,query:J});return{uri:`adoption://policy/${encodeURIComponent(J)}`,mimeType:"application/json",data:JSON.stringify(Q,null,2)}}})),Y}function rj(){let j=new oY;return j.register(iY({meta:{key:"contracts.editor",version:"1.0.0",title:"Contract editing guide",description:"Guide AI agents through reading, editing, and validating contracts.",tags:f,stability:"beta",owners:tY},args:[{name:"goal",description:"What the agent wants to achieve with the contract.",required:!1,schema:I.string().optional()}],input:I.object({goal:I.string().optional()}),render:async({goal:Y})=>[{type:"text",text:["Contract editing workflow:","1. Use contracts.list to discover specs","2. Use contracts.get to read a spec","3. Edit content and call contracts.update","4. Run contracts.validate to verify changes","5. Run contracts.build to regenerate artifacts","6. Use adoption.resolve to prefer existing workspace or ContractSpec surfaces before inventing new ones",Y?`Agent goal: ${Y}`:""].filter(Boolean).join(`
10
+ `)},{type:"resource",uri:"contracts://list",title:"Available contracts"}]})),j}import{defineCommand as Oj,installOp as Rj}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as S,ScalarTypeEnum as b}from"@contractspec/lib.schema";var hj=["@contractspec"],Tj=["contracts","mcp","adoption"];function ej(j,Y){let J=S({name:"AdoptionCatalogSearchInput",fields:{query:{type:b.String_unsecure(),isOptional:!1},family:{type:b.String_unsecure(),isOptional:!0},platform:{type:b.String_unsecure(),isOptional:!0}}}),Q=S({name:"AdoptionCatalogSearchOutput",fields:{results:{type:b.JSON(),isOptional:!1}}});Rj(j,Oj({meta:{key:"adoption.catalog_search",version:"1.0.0",stability:"beta",owners:hj,tags:Tj,description:"Search the local ContractSpec adoption catalog.",goal:"Find relevant ContractSpec reuse candidates for a query.",context:"Contracts MCP server."},io:{input:J,output:Q},policy:{auth:"anonymous"}}),async({family:V,platform:B,query:H})=>({results:await Y.searchAdoptionCatalog({family:V,platform:B,query:H})}));let $=S({name:"AdoptionResolveInput",fields:{family:{type:b.String_unsecure(),isOptional:!1},query:{type:b.String_unsecure(),isOptional:!1},paths:{type:b.JSON(),isOptional:!0},platform:{type:b.String_unsecure(),isOptional:!0},runtime:{type:b.String_unsecure(),isOptional:!0}}}),Z=S({name:"AdoptionResolveOutput",fields:{resolution:{type:b.JSON(),isOptional:!1}}});Rj(j,Oj({meta:{key:"adoption.resolve",version:"1.0.0",stability:"beta",owners:hj,tags:Tj,description:"Resolve the best adoption candidate for one family.",goal:"Provide one ordered recommendation that matches Connect.",context:"Contracts MCP server."},io:{input:$,output:Z},policy:{auth:"anonymous"}}),async({family:V,paths:B,platform:H,query:K,runtime:P})=>({resolution:await Y.resolveAdoption({family:V,paths:Array.isArray(B)?B:void 0,platform:H,query:K,runtime:P})}));let X=S({name:"AdoptionSyncInput",fields:{}}),U=S({name:"AdoptionSyncOutput",fields:{catalogPath:{type:b.String_unsecure(),isOptional:!1},total:{type:b.Int_unsecure(),isOptional:!1}}});Rj(j,Oj({meta:{key:"adoption.sync",version:"1.0.0",stability:"beta",owners:hj,tags:Tj,description:"Mirror the bundled ContractSpec adoption catalog locally.",goal:"Refresh the local adoption catalog used by Connect and MCP.",context:"Contracts MCP server."},io:{input:X,output:U},policy:{auth:"user"}}),async()=>Y.syncAdoptionCatalog())}import{defineCommand as y,installOp as m,OperationSpecRegistry as sY}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as G,ScalarTypeEnum as w}from"@contractspec/lib.schema";var g=["@contractspec"],d=["contracts","mcp"];function jY(j){let Y=new sY,J=G({name:"ContractsListInput",fields:{pattern:{type:w.String_unsecure(),isOptional:!0},type:{type:w.String_unsecure(),isOptional:!0}}}),Q=G({name:"ContractsListOutput",fields:{specs:{type:w.JSON(),isOptional:!1},total:{type:w.Int_unsecure(),isOptional:!1}}});m(Y,y({meta:{key:"contracts.list",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"List contract specs in the workspace.",goal:"Discover available contracts by type, pattern, or owner.",context:"Contracts MCP server."},io:{input:J,output:Q},policy:{auth:"anonymous"}}),async({pattern:H,type:K})=>{let P=await j.listSpecs({pattern:H,type:K});return{specs:P,total:P.length}});let $=G({name:"ContractsGetInput",fields:{path:{type:w.String_unsecure(),isOptional:!1}}}),Z=G({name:"ContractsGetOutput",fields:{content:{type:w.String_unsecure(),isOptional:!1},info:{type:w.JSON(),isOptional:!1}}});m(Y,y({meta:{key:"contracts.get",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"Read a single contract spec file.",goal:"Fetch spec content and parsed metadata.",context:"Contracts MCP server."},io:{input:$,output:Z},policy:{auth:"anonymous"}}),async({path:H})=>{let K=await j.getSpec(H);if(!K)throw Error(`Spec not found: ${H}`);return K});let X=G({name:"ContractsValidateInput",fields:{path:{type:w.String_unsecure(),isOptional:!1}}}),U=G({name:"ContractsValidateOutput",fields:{valid:{type:w.Boolean(),isOptional:!1},errors:{type:w.JSON(),isOptional:!1},warnings:{type:w.JSON(),isOptional:!1}}});m(Y,y({meta:{key:"contracts.validate",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"Validate a contract spec structure.",goal:"Check spec for structural or policy issues.",context:"Contracts MCP server."},io:{input:X,output:U},policy:{auth:"anonymous"}}),async({path:H})=>j.validateSpec(H));let V=G({name:"ContractsBuildInput",fields:{path:{type:w.String_unsecure(),isOptional:!1},dryRun:{type:w.Boolean(),isOptional:!0}}}),B=G({name:"ContractsBuildOutput",fields:{results:{type:w.JSON(),isOptional:!1}}});return m(Y,y({meta:{key:"contracts.build",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"Generate implementation code from a contract spec.",goal:"Produce handler, component, or test skeletons.",context:"Contracts MCP server."},io:{input:V,output:B},policy:{auth:"user"}}),async({path:H,dryRun:K})=>j.buildSpec(H,{dryRun:K})),rY(Y,j),ej(Y,j),Y}function rY(j,Y){let J=G({name:"ContractsUpdateInput",fields:{path:{type:w.String_unsecure(),isOptional:!1},content:{type:w.String_unsecure(),isOptional:!0},fields:{type:w.JSON(),isOptional:!0}}}),Q=G({name:"ContractsUpdateOutput",fields:{updated:{type:w.Boolean(),isOptional:!1},errors:{type:w.JSON(),isOptional:!1},warnings:{type:w.JSON(),isOptional:!1}}});m(j,y({meta:{key:"contracts.update",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"Update an existing contract spec.",goal:"Modify spec content or individual fields with validation.",context:"Contracts MCP server."},io:{input:J,output:Q},policy:{auth:"user"}}),async({path:X,content:U,fields:V})=>Y.updateSpec(X,{content:U,fields:Array.isArray(V)?V:void 0}));let $=G({name:"ContractsDeleteInput",fields:{path:{type:w.String_unsecure(),isOptional:!1},clean:{type:w.Boolean(),isOptional:!0}}}),Z=G({name:"ContractsDeleteOutput",fields:{deleted:{type:w.Boolean(),isOptional:!1},cleanedFiles:{type:w.JSON(),isOptional:!1},errors:{type:w.JSON(),isOptional:!1}}});m(j,y({meta:{key:"contracts.delete",version:"1.0.0",stability:"beta",owners:g,tags:d,description:"Delete a contract spec and optionally its artifacts.",goal:"Remove a spec file and clean generated handlers/tests.",context:"Contracts MCP server."},io:{input:$,output:Z},policy:{auth:"user"}}),async({path:X,clean:U})=>Y.deleteSpec(X,{clean:U}))}function AQ(j="/api/mcp/contracts",Y){return A({logger:D,path:j,serverName:"contractspec-contracts-mcp",ops:jY(Y),resources:sj(Y),prompts:rj()})}import{defaultDocRegistry as eY}from"@contractspec/lib.contracts-spec/docs";var j0=20,Y0=100;function _(j){return j?.trim().toLowerCase()??""}function YY(j){let Y=decodeURIComponent(j).trim();if(!Y)return"/";return Y.startsWith("/")?Y:`/${Y}`}function J0(j){return(Array.isArray(j)?j:j?[j]:[]).map((J)=>_(J)).filter(Boolean)}function Q0(j){if(!j||Number.isNaN(j))return j0;return Math.min(Math.max(j,1),Y0)}function Z0(j){if(!j||Number.isNaN(j))return 0;return Math.max(j,0)}function fj({block:j,route:Y}){return{id:j.id,title:j.title,summary:j.summary??"",route:Y,visibility:j.visibility??"public",kind:j.kind??"reference",version:j.version??"1.0.0",tags:j.tags??[]}}function $0(j,Y){if(!Y)return 1;let J=Y.split(/\s+/).filter(Boolean),Q=_(j.block.title),$=_(j.block.id),Z=_(j.block.summary),X=_(j.block.body),U=_(j.route),V=(j.block.tags??[]).map((K)=>_(K)),B=[Q,$,Z,X,U,...V].join(" ");if(J.some((K)=>!B.includes(K)))return 0;let H=0;for(let K of J){if($.includes(K))H+=8;if(Q.includes(K))H+=7;if(V.some((P)=>P.includes(K)))H+=5;if(Z.includes(K))H+=4;if(U.includes(K))H+=3;if(X.includes(K))H+=2}return H}function u(j,Y){let J=_(typeof Y.query==="string"?Y.query:void 0),Q=J0(Y.tag),$=_(typeof Y.visibility==="string"?Y.visibility:void 0),Z=_(typeof Y.kind==="string"?Y.kind:void 0),X=Q0(typeof Y.limit==="number"?Y.limit:void 0),U=Z0(typeof Y.offset==="number"?Y.offset:void 0),V=j.map((K)=>({doc:fj(K),score:$0(K,J)})).filter(({doc:K,score:P})=>{let Gj=J?P>0:!0,W=Q.length?Q.every((i)=>K.tags.some((z)=>_(z).includes(i))):!0,x=$?_(K.visibility)===$:!0,N=Z?_(K.kind)===Z:!0;return Gj&&W&&x&&N}).sort((K,P)=>{if(P.score!==K.score)return P.score-K.score;return K.doc.title.localeCompare(P.doc.title)}),B=V.slice(U,U+X).map(({doc:K})=>K),H=U+B.length<V.length?U+B.length:void 0;return{docs:B,items:B,total:V.length,...H!=null?{nextOffset:H}:{}}}function Hj(j){let Y=decodeURIComponent(j),J=eY.get(Y);if(!J)return;return{doc:fj(J),content:String(J.block.body??"")}}function Kj(j,Y){let J=YY(Y),Q=j.find(($)=>YY($.route)===J);if(!Q)return;return{doc:fj(Q),content:String(Q.block.body??"")}}function wj(j){let Y=new Map,J=new Map,Q=new Map;for(let Z of j){let X=Z.block.kind??"reference",U=Z.block.visibility??"public";J.set(X,(J.get(X)??0)+1),Q.set(U,(Q.get(U)??0)+1);for(let V of Z.block.tags??[])Y.set(V,(Y.get(V)??0)+1)}let $=(Z,X)=>[...Z.entries()].sort((U,V)=>V[1]-U[1]||U[0].localeCompare(V[0])).map(([U,V])=>({[X]:U,count:V}));return{totalDocs:j.length,tags:$(Y,"tag"),kinds:$(J,"kind"),visibilities:$(Q,"visibility")}}import{EventRegistry as X0,OperationSpecRegistry as U0}from"@contractspec/lib.contracts-spec";import{DataViewRegistry as V0}from"@contractspec/lib.contracts-spec/data-views";import{ContractReferenceDataView as H0,ContractReferenceQuery as K0,DocsGenerateCommand as w0,DocsGeneratedEvent as F0,DocsIndexDataView as B0,DocsIndexQuery as W0,DocsLayoutPresentation as x0,DocsPublishCommand as P0,DocsPublishedEvent as L0,DocsReferencePagePresentation as q0,DocsSearchForm as _0,ExampleCatalogDataView as M0}from"@contractspec/lib.contracts-spec/docs";import{FormRegistry as b0}from"@contractspec/lib.contracts-spec/forms";import{PresentationRegistry as G0}from"@contractspec/lib.contracts-spec/presentations";import{serializeDataViewSpec as D0,serializeEventSpec as C0,serializeFormSpec as A0,serializeOperationSpec as I0,serializePresentationSpec as N0}from"@contractspec/lib.contracts-spec/serialization";var Fj=null;function z0(){let j=new U0;return j.register(W0).register(K0).register(w0).register(P0),j}function E0(){if(!Fj)Fj=z0();return Fj}function Sj(j,Y){return E0().get(j,Y)}var Bj=null;function k0(){let j=new X0;return j.register(F0).register(L0),j}function v0(){if(!Bj)Bj=k0();return Bj}function yj(j,Y){return v0().get(j,Y)}var Wj=null;function O0(){let j=new G0;return j.register(x0).register(q0),j}function R0(){if(!Wj)Wj=O0();return Wj}function mj(j,Y){return R0().get(j,Y)}var xj=null;function h0(){let j=new V0;return j.register(B0).register(H0).register(M0),j}function T0(){if(!xj)xj=h0();return xj}function gj(j,Y){return T0().get(j,Y)}var Pj=null;function f0(){let j=new b0;return j.register(_0),j}function S0(){if(!Pj)Pj=f0();return Pj}function dj(j,Y){return S0().get(j)}function JY(j,Y){let J=Sj(j,Y);return I0(J)??void 0}function QY(j,Y){let J=yj(j,Y);return C0(J)??void 0}function ZY(j,Y){let J=mj(j,Y);return N0(J)??void 0}function $Y(j,Y){let J=gj(j,Y);return D0(J)??void 0}function XY(j,Y){let J=dj(j,Y);return A0(J)??void 0}function y0(){Fj=null}function m0(){Bj=null}function g0(){Wj=null}function d0(){xj=null}function u0(){Pj=null}function TQ(){y0(),m0(),g0(),d0(),u0()}import{defaultDocRegistry as p0}from"@contractspec/lib.contracts-spec/docs";function l0(j){return j?.trim().toLowerCase()??""}function n0(j){for(let Y of j??[]){let J=p0.get(Y);if(J)return J.route}return}function UY(j,Y,J,Q){let $=j.meta.title??j.meta.key,Z=n0(j.meta.docId),X=j.meta.description;return{key:j.meta.key,version:j.meta.version,type:Y,title:$,description:X,markdown:[`# ${$}`,`- Key: ${j.meta.key}`,`- Type: ${Y}`,`- Version: ${j.meta.version}`,Z?`- Docs route: ${Z}`:"",X?`
11
11
  ${X}`:""].filter(Boolean).join(`
12
- `),...Z?{route:Z}:{},...J?{schema:J}:{},...Q?{policy:Q}:{},tags:j.meta.tags??[],owners:j.meta.owners??[],stability:j.meta.stability}}function p(j){let Y=j.includeSchema??!1,J=d0(j.type),Q=Sj(j.key,j.version);if(Q&&(!J||J==="operation"||J===Q.meta.kind))return{reference:UY(Q,Q.meta.kind,Y?JY(j.key,j.version):void 0,Q.policy)};let $=[{type:"data-view",spec:gj(j.key,j.version),schema:Y?$Y(j.key,j.version):void 0},{type:"form",spec:dj(j.key,j.version),schema:Y?XY(j.key,j.version):void 0},{type:"presentation",spec:mj(j.key,j.version),schema:Y?ZY(j.key,j.version):void 0},{type:"event",spec:yj(j.key,j.version),schema:Y?QY(j.key,j.version):void 0}];for(let Z of $)if(Z.spec&&(!J||J===Z.type))return{reference:UY(Z.spec,Z.type,Z.schema)};throw Error(`Contract reference not found: ${j.key}`)}import{definePrompt as VY,PromptRegistry as p0}from"@contractspec/lib.contracts-spec";import L from"zod";var HY=["@contractspec"],KY=["docs","mcp"];function wY(j){let Y=new p0;return Y.register(VY({meta:{key:"docs.navigator",version:"1.0.0",title:"Find relevant ContractSpec docs",description:"Guide agents to search, filter, and open the right ContractSpec docs.",tags:KY,stability:"beta",owners:HY},args:[{name:"topic",description:"Goal or subject to search for.",required:!1,schema:L.string().optional()},{name:"kind",description:"Optional doc kind filter.",required:!1,schema:L.string().optional()},{name:"tag",description:"Optional tag filter.",required:!1,schema:L.string().optional()}],input:L.object({topic:L.string().optional(),kind:L.string().optional(),tag:L.string().optional()}),render:async({topic:J,kind:Q,tag:$})=>{let Z=u(j,{query:J,kind:Q,tag:$,limit:3}),X=Z.docs.length?Z.docs.map((U)=>`- ${U.title} (${U.id}) -> ${U.route}`).join(`
12
+ `),...Z?{route:Z}:{},...J?{schema:J}:{},...Q?{policy:Q}:{},tags:j.meta.tags??[],owners:j.meta.owners??[],stability:j.meta.stability}}function p(j){let Y=j.includeSchema??!1,J=l0(j.type),Q=Sj(j.key,j.version);if(Q&&(!J||J==="operation"||J===Q.meta.kind))return{reference:UY(Q,Q.meta.kind,Y?JY(j.key,j.version):void 0,Q.policy)};let $=[{type:"data-view",spec:gj(j.key,j.version),schema:Y?$Y(j.key,j.version):void 0},{type:"form",spec:dj(j.key,j.version),schema:Y?XY(j.key,j.version):void 0},{type:"presentation",spec:mj(j.key,j.version),schema:Y?ZY(j.key,j.version):void 0},{type:"event",spec:yj(j.key,j.version),schema:Y?QY(j.key,j.version):void 0}];for(let Z of $)if(Z.spec&&(!J||J===Z.type))return{reference:UY(Z.spec,Z.type,Z.schema)};throw Error(`Contract reference not found: ${j.key}`)}import{definePrompt as VY,PromptRegistry as c0}from"@contractspec/lib.contracts-spec";import L from"zod";var HY=["@contractspec"],KY=["docs","mcp"];function wY(j){let Y=new c0;return Y.register(VY({meta:{key:"docs.navigator",version:"1.0.0",title:"Find relevant ContractSpec docs",description:"Guide agents to search, filter, and open the right ContractSpec docs.",tags:KY,stability:"beta",owners:HY},args:[{name:"topic",description:"Goal or subject to search for.",required:!1,schema:L.string().optional()},{name:"kind",description:"Optional doc kind filter.",required:!1,schema:L.string().optional()},{name:"tag",description:"Optional tag filter.",required:!1,schema:L.string().optional()}],input:L.object({topic:L.string().optional(),kind:L.string().optional(),tag:L.string().optional()}),render:async({topic:J,kind:Q,tag:$})=>{let Z=u(j,{query:J,kind:Q,tag:$,limit:3}),X=Z.docs.length?Z.docs.map((U)=>`- ${U.title} (${U.id}) -> ${U.route}`).join(`
13
13
  `):"- No direct pre-match. Use docs_list_facets-v1_0_0 to browse tags and kinds.";return[{type:"text",text:["Use docs_search-v1_0_0 first, then read docs://doc/{id} for the strongest matches.","Use docs_resolve_route-v1_0_0 when the user already gives you a docs URL or route.","Use docs_list_facets-v1_0_0 or docs://facets to browse the docs taxonomy before guessing.",J?`Topic: ${J}`:"",Q?`Kind: ${Q}`:"",$?`Tag: ${$}`:"","Suggested starting docs:",X].filter(Boolean).join(`
14
14
  `)},{type:"resource",uri:"docs://index",title:"DocBlocks index"},{type:"resource",uri:"docs://facets",title:"Docs facets"}]}})),Y.register(VY({meta:{key:"docs.reference.guide",version:"1.0.0",title:"Resolve a ContractSpec reference",description:"Guide agents to fetch the canonical reference payload for a ContractSpec surface.",tags:KY,stability:"beta",owners:HY},args:[{name:"key",description:"ContractSpec key to resolve.",required:!0,schema:L.string()},{name:"version",description:"Optional version override.",required:!1,schema:L.string().optional()},{name:"type",description:"Optional surface type: command, query, form, data-view, presentation, event.",required:!1,schema:L.string().optional()}],input:L.object({key:L.string(),version:L.string().optional(),type:L.string().optional()}),render:async({key:J,version:Q,type:$})=>{let Z=p({key:J,version:Q,type:$,includeSchema:!0}).reference;return[{type:"text",text:["Use docs_contract_reference-v1_0_0 when you need the canonical docs payload for a ContractSpec surface.","Use docs_get-v1_0_0 only when you already know the exact DocBlock id and need raw markdown.",`Resolved key: ${Z.key}`,`Resolved type: ${Z.type}`,Z.route?`Docs route: ${Z.route}`:"",`Resource URI: docs://contract-reference/${encodeURIComponent(J)}`].filter(Boolean).join(`
15
- `)},{type:"resource",uri:`docs://contract-reference/${encodeURIComponent(J)}`,title:"Contract reference"}]}})),Y}import{defineResourceTemplate as k,ResourceRegistry as l0}from"@contractspec/lib.contracts-spec";import F from"zod";var v=["docs","mcp"];function FY(j){let Y=new l0,J=(Q)=>u(j,Q);return Y.register(k({meta:{uriTemplate:"docs://index",title:"DocBlocks index",description:"Default ContractSpec docs index resource.",mimeType:"application/json",tags:v},input:F.object({}),resolve:async()=>({uri:"docs://index",mimeType:"application/json",data:JSON.stringify(J({}),null,2)})})),Y.register(k({meta:{uriTemplate:"docs://index{?query,tag,kind,visibility,limit,offset}",title:"DocBlocks index",description:"Search and paginate ContractSpec docs by query, tag, kind, or visibility.",mimeType:"application/json",tags:v},input:F.object({query:F.string().optional(),tag:F.string().optional(),kind:F.string().optional(),visibility:F.string().optional(),limit:F.coerce.number().optional(),offset:F.coerce.number().optional()}),resolve:async(Q)=>({uri:"docs://index",mimeType:"application/json",data:JSON.stringify(J(Q),null,2)})})),Y.register(k({meta:{uriTemplate:"docs://list",title:"DocBlocks index (legacy alias)",description:"Compatibility alias for the docs index resource.",mimeType:"application/json",tags:v},input:F.object({}),resolve:async()=>({uri:"docs://list",mimeType:"application/json",data:JSON.stringify(J({}),null,2)})})),Y.register(k({meta:{uriTemplate:"docs://doc/{id}",title:"Doc markdown",description:"Fetch a single DocBlock body by id as markdown.",mimeType:"text/markdown",tags:v},input:F.object({id:F.string()}),resolve:async({id:Q})=>{let $=Hj(Q);if(!$)return{uri:`docs://doc/${encodeURIComponent(Q)}`,mimeType:"text/plain",data:`DocBlock not found: ${Q}`};return{uri:`docs://doc/${encodeURIComponent(Q)}`,mimeType:"text/markdown",data:$.content}}})),Y.register(k({meta:{uriTemplate:"docs://route/{routePath}",title:"Doc by route",description:"Resolve a docs route to the matching DocBlock summary and body.",mimeType:"application/json",tags:v},input:F.object({routePath:F.string()}),resolve:async({routePath:Q})=>({uri:`docs://route/${encodeURIComponent(Q)}`,mimeType:"application/json",data:JSON.stringify(Kj(j,Q)??{error:"not_found",route:Q},null,2)})})),Y.register(k({meta:{uriTemplate:"docs://facets",title:"Docs facets",description:"Counts of available tags, kinds, and visibilities across docs.",mimeType:"application/json",tags:v},input:F.object({}),resolve:async()=>({uri:"docs://facets",mimeType:"application/json",data:JSON.stringify(wj(j),null,2)})})),Y.register(k({meta:{uriTemplate:"docs://contract-reference/{key}{?version,type,includeSchema}",title:"Contract reference",description:"Resolve a ContractSpec surface into a docs-ready reference payload.",mimeType:"application/json",tags:v},input:F.object({key:F.string(),version:F.string().optional(),type:F.string().optional(),includeSchema:F.coerce.boolean().optional()}),resolve:async({key:Q,version:$,type:Z,includeSchema:X})=>({uri:`docs://contract-reference/${encodeURIComponent(Q)}`,mimeType:"application/json",data:JSON.stringify(p({key:Q,version:$,type:Z,includeSchema:X}),null,2)})})),Y}import{defineCommand as r,defineSchemaModel as l,installOp as e,OperationSpecRegistry as n0}from"@contractspec/lib.contracts-spec";import{ContractReferenceInput as c0,ContractReferenceOutput as i0,DocsIndexInput as o0,DocsIndexOutput as a0}from"@contractspec/lib.contracts-spec/docs";import{ScalarTypeEnum as O}from"@contractspec/lib.schema";var jj=["@contractspec"],Yj=["docs","mcp"],t0=l({name:"DocsGetInput",fields:{id:{type:O.String_unsecure(),isOptional:!1}}}),s0=l({name:"DocsGetOutput",fields:{doc:{type:O.JSON(),isOptional:!1},content:{type:O.String_unsecure(),isOptional:!1}}}),r0=l({name:"DocsResolveRouteInput",fields:{route:{type:O.String_unsecure(),isOptional:!1}}}),e0=l({name:"DocsResolveRouteOutput",fields:{doc:{type:O.JSON(),isOptional:!1},content:{type:O.String_unsecure(),isOptional:!1}}}),jJ=l({name:"DocsFacetsInput",fields:{}}),YJ=l({name:"DocsFacetsOutput",fields:{facets:{type:O.JSON(),isOptional:!1}}});function BY(j){let Y=new n0;return e(Y,r({meta:{key:"docs.search",version:"1.0.0",stability:"beta",owners:jj,tags:Yj,description:"Search ContractSpec docs by query, tag, kind, or visibility.",goal:"Find the most relevant DocBlocks without browsing the full corpus.",context:"Read-only docs MCP search surface."},io:{input:o0,output:a0},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_search-v1_0_0"}}}),async(J)=>u(j,J)),e(Y,r({meta:{key:"docs.get",version:"1.0.0",stability:"beta",owners:jj,tags:Yj,description:"Read a single DocBlock by id.",goal:"Fetch the exact markdown content and metadata for a known doc id.",context:"Read-only docs MCP surface."},io:{input:t0,output:s0},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_get-v1_0_0"}}}),async({id:J})=>{let Q=Hj(J);if(!Q)throw Error(`DocBlock not found: ${J}`);return Q}),e(Y,r({meta:{key:"docs.resolveRoute",version:"1.0.0",stability:"beta",owners:jj,tags:Yj,description:"Resolve a docs route to the matching DocBlock.",goal:"Turn a route or URL path into a canonical doc id and markdown body.",context:"Read-only docs MCP surface."},io:{input:r0,output:e0},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_resolve_route-v1_0_0"}}}),async({route:J})=>{let Q=Kj(j,J);if(!Q)throw Error(`Doc route not found: ${J}`);return Q}),e(Y,r({meta:{key:"docs.contract.lookup",version:"1.0.0",stability:"beta",owners:jj,tags:Yj,description:"Resolve a ContractSpec surface into a docs-ready reference payload.",goal:"Get canonical docs metadata, route, and optional schema for a spec key.",context:"Read-only docs MCP surface."},io:{input:c0,output:i0},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_contract_reference-v1_0_0"}}}),async(J)=>p(J)),e(Y,r({meta:{key:"docs.list.facets",version:"1.0.0",stability:"beta",owners:jj,tags:Yj,description:"List docs taxonomy facets such as tags, kinds, and visibilities.",goal:"Help agents browse the docs corpus before making targeted reads.",context:"Read-only docs MCP surface."},io:{input:jJ,output:YJ},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_list_facets-v1_0_0"}}}),async()=>({facets:wj(j)})),Y}import{defaultDocRegistry as JJ}from"@contractspec/lib.contracts-spec/docs";function JZ(j="/api/mcp/docs",Y={}){let J=JJ.list();return A({logger:D,path:j,serverName:"contractspec-docs-mcp",ops:BY(J),resources:FY(J),prompts:wY(J),presentations:Y.includePresentations?J.map(({descriptor:Q})=>Q):void 0})}import{defineCommand as QJ,definePrompt as ZJ,defineResourceTemplate as Lj,installOp as $J,OperationSpecRegistry as XJ,PromptRegistry as UJ,ResourceRegistry as VJ}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as WY,ScalarTypeEnum as xY}from"@contractspec/lib.schema";import{getExample as HJ,listExamples as KJ,searchExamples as wJ}from"@contractspec/module.examples";import R from"zod";var n=["internal","mcp"],PY=["@contractspec"],Jj={docs:"/api/mcp/docs",cli:"/api/mcp/cli",internal:"/api/mcp/internal",graphql:"/graphql",health:"/health"};function FJ(){let j=new VJ;return j.register(Lj({meta:{uriTemplate:"examples://list{?q}",title:"ContractSpec examples registry",description:"List available examples (templates, integrations, knowledge, scripts). Optional query `q` filters results.",mimeType:"application/json",tags:["examples",...n]},input:R.object({q:R.string().optional()}),resolve:async({q:Y})=>{let J=Y?wJ(Y):[...KJ()];return{uri:Y?`examples://list?q=${encodeURIComponent(Y)}`:"examples://list",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),j.register(Lj({meta:{uriTemplate:"examples://example/{id}",title:"ContractSpec example (by id)",description:"Fetch a single example manifest by id.",mimeType:"application/json",tags:["examples",...n]},input:R.object({id:R.string().min(1)}),resolve:async({id:Y})=>{let J=HJ(Y);if(!J)return{uri:`examples://example/${encodeURIComponent(Y)}`,mimeType:"application/json",data:JSON.stringify({error:"not_found",id:Y,message:`Unknown example id: ${Y}`},null,2)};return{uri:`examples://example/${encodeURIComponent(Y)}`,mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),j.register(Lj({meta:{uriTemplate:"internal://endpoints",title:"ContractSpec MCP endpoints",description:"Endpoints for docs, CLI, internal MCP servers.",mimeType:"application/json",tags:n},input:R.object({}),resolve:async()=>({uri:"internal://endpoints",mimeType:"application/json",data:JSON.stringify(Jj,null,2)})})),j.register(Lj({meta:{uriTemplate:"internal://playbook",title:"Internal MCP usage playbook",description:"How internal agents should discover docs, CLI usage, and endpoints.",mimeType:"text/markdown",tags:n},input:R.object({}),resolve:async()=>({uri:"internal://playbook",mimeType:"text/markdown",data:["# Internal MCP playbook","- Connect to docs MCP first for canonical specs.","- Use CLI MCP to surface quickstart/reference before running commands.","- Keep calls read-only unless explicitly approved.",`- Endpoints: ${Jj.docs}, ${Jj.cli}, ${Jj.internal}.`,"- For API work, GraphQL at /graphql; health at /health."].join(`
16
- `)})})),j}function BJ(){let j=new UJ;return j.register(ZJ({meta:{key:"internal_bootstrap",version:"1.0.0",title:"Bootstrap internal ContractSpec agent",description:"Points agents to the correct MCP endpoints and guardrails.",tags:n,owners:PY,stability:"beta"},args:[],input:R.object({}),render:async()=>[{type:"text",text:"Start with internal://endpoints to pick the right MCP. Use docs MCP for specifications and CLI MCP for commands. Keep actions read-only unless explicitly approved."},{type:"resource",uri:"internal://endpoints",title:"Endpoints"}]})),j}function WJ(){let j=new XJ,Y=WY({name:"InternalDescribeOutput",fields:{endpoints:{type:xY.JSONObject(),isOptional:!1},notes:{type:xY.String_unsecure(),isOptional:!1}}}),J=QJ({meta:{key:"internal_describe",version:"1.0.0",stability:"stable",owners:PY,tags:n,description:"Return MCP endpoints and guidance for internal ContractSpec agents.",goal:"Speed up internal development with the correct MCP entrypoints.",context:"Used by internal MCP surface; read-only."},io:{input:WY({name:"InternalDescribeInput",fields:{}}),output:Y},policy:{auth:"anonymous"}});return $J(j,J,async()=>({endpoints:Jj,notes:"Use docs MCP for canonical specs, CLI MCP for contractspec commands, and keep side-effecting actions gated behind human review."})),j}function KZ(j="/api/mcp/internal"){return A({logger:D,path:j,serverName:"contractspec-internal-mcp",ops:WJ(),resources:FJ(),prompts:BJ()})}import{getModelInfo as xJ}from"@contractspec/lib.ai-providers/models";import{definePrompt as PJ,defineResourceTemplate as qj,installOp as uj,OperationSpecRegistry as LJ,PromptRegistry as qJ,ResourceRegistry as _J}from"@contractspec/lib.contracts-spec";import{BenchmarkIngestCommand as MJ,BenchmarkRunCustomCommand as bJ,RankingRefreshCommand as GJ}from"@contractspec/lib.contracts-spec/provider-ranking";import{InMemoryProviderRankingStore as DJ}from"@contractspec/lib.provider-ranking/in-memory-store";import{createDefaultIngesterRegistry as CJ}from"@contractspec/lib.provider-ranking/ingesters";import{computeModelRankings as AJ,normalizeBenchmarkResults as IJ}from"@contractspec/lib.provider-ranking/scoring";import M from"zod";var Mj=M.enum(["rest","mcp","webhook","sdk"]).optional(),bj=M.enum(["api-key","oauth2","bearer","header","basic","webhook-signing","service-account"]).optional(),Qj=["ranking","mcp","ai"],NJ=["platform.ai"],_j=null;function c(){if(!_j)_j=new DJ;return _j}function zJ(){let j=new _J;return j.register(qj({meta:{uriTemplate:"ranking://leaderboard",title:"AI Model Leaderboard",description:"Current ranked list of AI models by composite score. Supports optional transport and authMethod query filters.",mimeType:"application/json",tags:Qj},input:M.object({transport:Mj,authMethod:bj}),resolve:async({transport:Y,authMethod:J})=>{let $=await c().listModelRankings({limit:100,requiredTransport:Y,requiredAuthMethod:J});return{uri:"ranking://leaderboard",mimeType:"application/json",data:JSON.stringify($,null,2)}}})),j.register(qj({meta:{uriTemplate:"ranking://leaderboard/{dimension}",title:"AI Model Leaderboard by Dimension",description:"Ranked list of AI models filtered by a specific dimension. Supports optional transport and authMethod query filters.",mimeType:"application/json",tags:Qj},input:M.object({dimension:M.string(),transport:Mj,authMethod:bj}),resolve:async({dimension:Y,transport:J,authMethod:Q})=>{let Z=await c().listModelRankings({dimension:Y,limit:100,requiredTransport:J,requiredAuthMethod:Q});return{uri:`ranking://leaderboard/${encodeURIComponent(Y)}`,mimeType:"application/json",data:JSON.stringify(Z,null,2)}}})),j.register(qj({meta:{uriTemplate:"ranking://model/{modelId}",title:"AI Model Profile",description:"Detailed profile for a specific AI model including scores and benchmarks.",mimeType:"application/json",tags:Qj},input:M.object({modelId:M.string()}),resolve:async({modelId:Y})=>{let Q=await c().getModelProfile(Y);if(!Q)return{uri:`ranking://model/${encodeURIComponent(Y)}`,mimeType:"application/json",data:JSON.stringify({error:"not_found",modelId:Y})};let $=Q.costPerMillion==null?(()=>{let Z=xJ(Q.modelId);return Z?.costPerMillion?{...Q,costPerMillion:Z.costPerMillion,displayName:Z.name,contextWindow:Z.contextWindow,capabilities:[...Z.capabilities.vision?["vision"]:[],...Z.capabilities.tools?["tools"]:[],...Z.capabilities.reasoning?["reasoning"]:[],...Z.capabilities.streaming?["streaming"]:[]]}:Q})():Q;return{uri:`ranking://model/${encodeURIComponent(Y)}`,mimeType:"application/json",data:JSON.stringify($,null,2)}}})),j.register(qj({meta:{uriTemplate:"ranking://results",title:"Benchmark Results",description:"List of raw benchmark results from all ingested sources.",mimeType:"application/json",tags:Qj},input:M.object({}),resolve:async()=>{let J=await c().listBenchmarkResults({limit:200});return{uri:"ranking://results",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),j}function EJ(){let j=new qJ;return j.register(PJ({meta:{key:"ranking.advisor",version:"1.0.0",title:"AI Model Advisor",description:"Which AI model is best for a given task? Uses the leaderboard to recommend.",tags:Qj,stability:"beta",owners:NJ},args:[{name:"task",description:"The task or use case to recommend a model for.",required:!0,schema:M.string()},{name:"priority",description:"Priority dimension (coding, reasoning, cost, latency, etc.).",required:!1,schema:M.string().optional()},{name:"transport",description:"Required transport type (rest, mcp, webhook, sdk).",required:!1,schema:Mj},{name:"authMethod",description:"Required auth method (api-key, oauth2, bearer, etc.).",required:!1,schema:bj}],input:M.object({task:M.string(),priority:M.string().optional(),transport:Mj,authMethod:bj}),render:async({task:Y,priority:J,transport:Q,authMethod:$})=>{let Z=[];if(J)Z.push(`Prioritize: ${J}.`);if(Q)Z.push(`Required transport: ${Q}.`);if($)Z.push(`Required auth: ${$}.`);return[{type:"text",text:`Recommend the best AI model for: "${Y}".${Z.length?` ${Z.join(" ")}`:""} Use the leaderboard data to justify your recommendation.`},{type:"resource",uri:J?`ranking://leaderboard/${J}`:"ranking://leaderboard",title:"Leaderboard"}]}})),j}function kJ(){let j=new LJ,Y=CJ();return uj(j,MJ,async(J)=>{let Q=c(),$=J.source,Z=Y.get($);if(!Z)throw Error(`No ingester registered for source: ${$}`);let X=await Z.ingest({sourceUrl:J.sourceUrl,dimensions:J.dimensions}),U=IJ(X);for(let V of U)await Q.upsertBenchmarkResult(V);return{ingestionId:`ingest-${$}-${Date.now()}`,source:$,resultsCount:U.length,status:"completed",ingestedAt:new Date}}),uj(j,bJ,async(J)=>{return{runId:`custom-${Date.now()}`,evalSuiteKey:J.evalSuiteKey,modelId:J.modelId,status:"started",startedAt:new Date}}),uj(j,GJ,async(J)=>{let Q=c(),$=[],Z=0,X=500;while(!0){let H=await Q.listBenchmarkResults({limit:X,offset:Z});if($.push(...H.results),$.length>=H.total||H.results.length<X)break;Z+=X}let U=new Map((await Q.listModelRankings({limit:1e4})).rankings.map((H)=>[H.modelId,H])),V=J.weightOverrides?Array.isArray(J.weightOverrides)?J.weightOverrides:[J.weightOverrides]:void 0,B=AJ($,V?{weightOverrides:V}:void 0,U);for(let H of B)await Q.upsertModelRanking(H);return{modelsRanked:B.length,updatedAt:new Date,status:"completed"}}),j}function bZ(j="/api/mcp/ranking"){return A({logger:D,path:j,serverName:"contractspec-ranking-mcp",ops:kJ(),resources:zJ(),prompts:EJ()})}function GZ(j){_j=j}export{GZ as setProviderRankingStore,bZ as createProviderRankingMcpHandler,KZ as createInternalMcpHandler,JZ as createDocsMcpHandler,_Q as createContractsMcpHandler,QQ as createCliMcpHandler};
15
+ `)},{type:"resource",uri:`docs://contract-reference/${encodeURIComponent(J)}`,title:"Contract reference"}]}})),Y}import{defineResourceTemplate as k,ResourceRegistry as i0}from"@contractspec/lib.contracts-spec";import F from"zod";var v=["docs","mcp"];function FY(j){let Y=new i0,J=(Q)=>u(j,Q);return Y.register(k({meta:{uriTemplate:"docs://index",title:"DocBlocks index",description:"Default ContractSpec docs index resource.",mimeType:"application/json",tags:v},input:F.object({}),resolve:async()=>({uri:"docs://index",mimeType:"application/json",data:JSON.stringify(J({}),null,2)})})),Y.register(k({meta:{uriTemplate:"docs://index{?query,tag,kind,visibility,limit,offset}",title:"DocBlocks index",description:"Search and paginate ContractSpec docs by query, tag, kind, or visibility.",mimeType:"application/json",tags:v},input:F.object({query:F.string().optional(),tag:F.string().optional(),kind:F.string().optional(),visibility:F.string().optional(),limit:F.coerce.number().optional(),offset:F.coerce.number().optional()}),resolve:async(Q)=>({uri:"docs://index",mimeType:"application/json",data:JSON.stringify(J(Q),null,2)})})),Y.register(k({meta:{uriTemplate:"docs://list",title:"DocBlocks index (legacy alias)",description:"Compatibility alias for the docs index resource.",mimeType:"application/json",tags:v},input:F.object({}),resolve:async()=>({uri:"docs://list",mimeType:"application/json",data:JSON.stringify(J({}),null,2)})})),Y.register(k({meta:{uriTemplate:"docs://doc/{id}",title:"Doc markdown",description:"Fetch a single DocBlock body by id as markdown.",mimeType:"text/markdown",tags:v},input:F.object({id:F.string()}),resolve:async({id:Q})=>{let $=Hj(Q);if(!$)return{uri:`docs://doc/${encodeURIComponent(Q)}`,mimeType:"text/plain",data:`DocBlock not found: ${Q}`};return{uri:`docs://doc/${encodeURIComponent(Q)}`,mimeType:"text/markdown",data:$.content}}})),Y.register(k({meta:{uriTemplate:"docs://route/{routePath}",title:"Doc by route",description:"Resolve a docs route to the matching DocBlock summary and body.",mimeType:"application/json",tags:v},input:F.object({routePath:F.string()}),resolve:async({routePath:Q})=>({uri:`docs://route/${encodeURIComponent(Q)}`,mimeType:"application/json",data:JSON.stringify(Kj(j,Q)??{error:"not_found",route:Q},null,2)})})),Y.register(k({meta:{uriTemplate:"docs://facets",title:"Docs facets",description:"Counts of available tags, kinds, and visibilities across docs.",mimeType:"application/json",tags:v},input:F.object({}),resolve:async()=>({uri:"docs://facets",mimeType:"application/json",data:JSON.stringify(wj(j),null,2)})})),Y.register(k({meta:{uriTemplate:"docs://contract-reference/{key}{?version,type,includeSchema}",title:"Contract reference",description:"Resolve a ContractSpec surface into a docs-ready reference payload.",mimeType:"application/json",tags:v},input:F.object({key:F.string(),version:F.string().optional(),type:F.string().optional(),includeSchema:F.coerce.boolean().optional()}),resolve:async({key:Q,version:$,type:Z,includeSchema:X})=>({uri:`docs://contract-reference/${encodeURIComponent(Q)}`,mimeType:"application/json",data:JSON.stringify(p({key:Q,version:$,type:Z,includeSchema:X}),null,2)})})),Y}import{defineCommand as r,defineSchemaModel as l,installOp as e,OperationSpecRegistry as o0}from"@contractspec/lib.contracts-spec";import{ContractReferenceInput as a0,ContractReferenceOutput as t0,DocsIndexInput as s0,DocsIndexOutput as r0}from"@contractspec/lib.contracts-spec/docs";import{ScalarTypeEnum as O}from"@contractspec/lib.schema";var jj=["@contractspec"],Yj=["docs","mcp"],e0=l({name:"DocsGetInput",fields:{id:{type:O.String_unsecure(),isOptional:!1}}}),jJ=l({name:"DocsGetOutput",fields:{doc:{type:O.JSON(),isOptional:!1},content:{type:O.String_unsecure(),isOptional:!1}}}),YJ=l({name:"DocsResolveRouteInput",fields:{route:{type:O.String_unsecure(),isOptional:!1}}}),JJ=l({name:"DocsResolveRouteOutput",fields:{doc:{type:O.JSON(),isOptional:!1},content:{type:O.String_unsecure(),isOptional:!1}}}),QJ=l({name:"DocsFacetsInput",fields:{}}),ZJ=l({name:"DocsFacetsOutput",fields:{facets:{type:O.JSON(),isOptional:!1}}});function BY(j){let Y=new o0;return e(Y,r({meta:{key:"docs.search",version:"1.0.0",stability:"beta",owners:jj,tags:Yj,description:"Search ContractSpec docs by query, tag, kind, or visibility.",goal:"Find the most relevant DocBlocks without browsing the full corpus.",context:"Read-only docs MCP search surface."},io:{input:s0,output:r0},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_search-v1_0_0"}}}),async(J)=>u(j,J)),e(Y,r({meta:{key:"docs.get",version:"1.0.0",stability:"beta",owners:jj,tags:Yj,description:"Read a single DocBlock by id.",goal:"Fetch the exact markdown content and metadata for a known doc id.",context:"Read-only docs MCP surface."},io:{input:e0,output:jJ},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_get-v1_0_0"}}}),async({id:J})=>{let Q=Hj(J);if(!Q)throw Error(`DocBlock not found: ${J}`);return Q}),e(Y,r({meta:{key:"docs.resolveRoute",version:"1.0.0",stability:"beta",owners:jj,tags:Yj,description:"Resolve a docs route to the matching DocBlock.",goal:"Turn a route or URL path into a canonical doc id and markdown body.",context:"Read-only docs MCP surface."},io:{input:YJ,output:JJ},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_resolve_route-v1_0_0"}}}),async({route:J})=>{let Q=Kj(j,J);if(!Q)throw Error(`Doc route not found: ${J}`);return Q}),e(Y,r({meta:{key:"docs.contract.lookup",version:"1.0.0",stability:"beta",owners:jj,tags:Yj,description:"Resolve a ContractSpec surface into a docs-ready reference payload.",goal:"Get canonical docs metadata, route, and optional schema for a spec key.",context:"Read-only docs MCP surface."},io:{input:a0,output:t0},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_contract_reference-v1_0_0"}}}),async(J)=>p(J)),e(Y,r({meta:{key:"docs.list.facets",version:"1.0.0",stability:"beta",owners:jj,tags:Yj,description:"List docs taxonomy facets such as tags, kinds, and visibilities.",goal:"Help agents browse the docs corpus before making targeted reads.",context:"Read-only docs MCP surface."},io:{input:QJ,output:ZJ},policy:{auth:"anonymous"},transport:{mcp:{toolName:"docs_list_facets-v1_0_0"}}}),async()=>({facets:wj(j)})),Y}import{defaultDocRegistry as $J}from"@contractspec/lib.contracts-spec/docs";function VZ(j="/api/mcp/docs",Y={}){let J=$J.list();return A({logger:D,path:j,serverName:"contractspec-docs-mcp",ops:BY(J),resources:FY(J),prompts:wY(J),presentations:Y.includePresentations?J.map(({descriptor:Q})=>Q):void 0})}import{defineCommand as XJ,definePrompt as UJ,defineResourceTemplate as Lj,installOp as VJ,OperationSpecRegistry as HJ,PromptRegistry as KJ,ResourceRegistry as wJ}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as WY,ScalarTypeEnum as xY}from"@contractspec/lib.schema";import{getExample as FJ,listExamples as BJ,searchExamples as WJ}from"@contractspec/module.examples/catalog";import R from"zod";var n=["internal","mcp"],PY=["@contractspec"],Jj={docs:"/api/mcp/docs",cli:"/api/mcp/cli",internal:"/api/mcp/internal",graphql:"/graphql",health:"/health"};function xJ(){let j=new wJ;return j.register(Lj({meta:{uriTemplate:"examples://list{?q}",title:"ContractSpec examples registry",description:"List available examples (templates, integrations, knowledge, scripts). Optional query `q` filters results.",mimeType:"application/json",tags:["examples",...n]},input:R.object({q:R.string().optional()}),resolve:async({q:Y})=>{let J=Y?WJ(Y):[...BJ()];return{uri:Y?`examples://list?q=${encodeURIComponent(Y)}`:"examples://list",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),j.register(Lj({meta:{uriTemplate:"examples://example/{id}",title:"ContractSpec example (by id)",description:"Fetch a single example manifest by id.",mimeType:"application/json",tags:["examples",...n]},input:R.object({id:R.string().min(1)}),resolve:async({id:Y})=>{let J=FJ(Y);if(!J)return{uri:`examples://example/${encodeURIComponent(Y)}`,mimeType:"application/json",data:JSON.stringify({error:"not_found",id:Y,message:`Unknown example id: ${Y}`},null,2)};return{uri:`examples://example/${encodeURIComponent(Y)}`,mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),j.register(Lj({meta:{uriTemplate:"internal://endpoints",title:"ContractSpec MCP endpoints",description:"Endpoints for docs, CLI, internal MCP servers.",mimeType:"application/json",tags:n},input:R.object({}),resolve:async()=>({uri:"internal://endpoints",mimeType:"application/json",data:JSON.stringify(Jj,null,2)})})),j.register(Lj({meta:{uriTemplate:"internal://playbook",title:"Internal MCP usage playbook",description:"How internal agents should discover docs, CLI usage, and endpoints.",mimeType:"text/markdown",tags:n},input:R.object({}),resolve:async()=>({uri:"internal://playbook",mimeType:"text/markdown",data:["# Internal MCP playbook","- Connect to docs MCP first for canonical specs.","- Use CLI MCP to surface quickstart/reference before running commands.","- Keep calls read-only unless explicitly approved.",`- Endpoints: ${Jj.docs}, ${Jj.cli}, ${Jj.internal}.`,"- For API work, GraphQL at /graphql; health at /health."].join(`
16
+ `)})})),j}function PJ(){let j=new KJ;return j.register(UJ({meta:{key:"internal_bootstrap",version:"1.0.0",title:"Bootstrap internal ContractSpec agent",description:"Points agents to the correct MCP endpoints and guardrails.",tags:n,owners:PY,stability:"beta"},args:[],input:R.object({}),render:async()=>[{type:"text",text:"Start with internal://endpoints to pick the right MCP. Use docs MCP for specifications and CLI MCP for commands. Keep actions read-only unless explicitly approved."},{type:"resource",uri:"internal://endpoints",title:"Endpoints"}]})),j}function LJ(){let j=new HJ,Y=WY({name:"InternalDescribeOutput",fields:{endpoints:{type:xY.JSONObject(),isOptional:!1},notes:{type:xY.String_unsecure(),isOptional:!1}}}),J=XJ({meta:{key:"internal_describe",version:"1.0.0",stability:"stable",owners:PY,tags:n,description:"Return MCP endpoints and guidance for internal ContractSpec agents.",goal:"Speed up internal development with the correct MCP entrypoints.",context:"Used by internal MCP surface; read-only."},io:{input:WY({name:"InternalDescribeInput",fields:{}}),output:Y},policy:{auth:"anonymous"}});return VJ(j,J,async()=>({endpoints:Jj,notes:"Use docs MCP for canonical specs, CLI MCP for contractspec commands, and keep side-effecting actions gated behind human review."})),j}function PZ(j="/api/mcp/internal"){return A({logger:D,path:j,serverName:"contractspec-internal-mcp",ops:LJ(),resources:xJ(),prompts:PJ()})}import{getModelInfo as qJ}from"@contractspec/lib.ai-providers/models";import{definePrompt as _J,defineResourceTemplate as qj,installOp as uj,OperationSpecRegistry as MJ,PromptRegistry as bJ,ResourceRegistry as GJ}from"@contractspec/lib.contracts-spec";import{BenchmarkIngestCommand as DJ,BenchmarkRunCustomCommand as CJ,RankingRefreshCommand as AJ}from"@contractspec/lib.contracts-spec/provider-ranking";import{InMemoryProviderRankingStore as IJ}from"@contractspec/lib.provider-ranking/in-memory-store";import{createDefaultIngesterRegistry as NJ}from"@contractspec/lib.provider-ranking/ingesters";import{computeModelRankings as zJ,normalizeBenchmarkResults as EJ}from"@contractspec/lib.provider-ranking/scoring";import M from"zod";var Mj=M.enum(["rest","mcp","webhook","sdk"]).optional(),bj=M.enum(["api-key","oauth2","bearer","header","basic","webhook-signing","service-account"]).optional(),Qj=["ranking","mcp","ai"],kJ=["platform.ai"],_j=null;function c(){if(!_j)_j=new IJ;return _j}function vJ(){let j=new GJ;return j.register(qj({meta:{uriTemplate:"ranking://leaderboard",title:"AI Model Leaderboard",description:"Current ranked list of AI models by composite score. Supports optional transport and authMethod query filters.",mimeType:"application/json",tags:Qj},input:M.object({transport:Mj,authMethod:bj}),resolve:async({transport:Y,authMethod:J})=>{let $=await c().listModelRankings({limit:100,requiredTransport:Y,requiredAuthMethod:J});return{uri:"ranking://leaderboard",mimeType:"application/json",data:JSON.stringify($,null,2)}}})),j.register(qj({meta:{uriTemplate:"ranking://leaderboard/{dimension}",title:"AI Model Leaderboard by Dimension",description:"Ranked list of AI models filtered by a specific dimension. Supports optional transport and authMethod query filters.",mimeType:"application/json",tags:Qj},input:M.object({dimension:M.string(),transport:Mj,authMethod:bj}),resolve:async({dimension:Y,transport:J,authMethod:Q})=>{let Z=await c().listModelRankings({dimension:Y,limit:100,requiredTransport:J,requiredAuthMethod:Q});return{uri:`ranking://leaderboard/${encodeURIComponent(Y)}`,mimeType:"application/json",data:JSON.stringify(Z,null,2)}}})),j.register(qj({meta:{uriTemplate:"ranking://model/{modelId}",title:"AI Model Profile",description:"Detailed profile for a specific AI model including scores and benchmarks.",mimeType:"application/json",tags:Qj},input:M.object({modelId:M.string()}),resolve:async({modelId:Y})=>{let Q=await c().getModelProfile(Y);if(!Q)return{uri:`ranking://model/${encodeURIComponent(Y)}`,mimeType:"application/json",data:JSON.stringify({error:"not_found",modelId:Y})};let $=Q.costPerMillion==null?(()=>{let Z=qJ(Q.modelId);return Z?.costPerMillion?{...Q,costPerMillion:Z.costPerMillion,displayName:Z.name,contextWindow:Z.contextWindow,capabilities:[...Z.capabilities.vision?["vision"]:[],...Z.capabilities.tools?["tools"]:[],...Z.capabilities.reasoning?["reasoning"]:[],...Z.capabilities.streaming?["streaming"]:[]]}:Q})():Q;return{uri:`ranking://model/${encodeURIComponent(Y)}`,mimeType:"application/json",data:JSON.stringify($,null,2)}}})),j.register(qj({meta:{uriTemplate:"ranking://results",title:"Benchmark Results",description:"List of raw benchmark results from all ingested sources.",mimeType:"application/json",tags:Qj},input:M.object({}),resolve:async()=>{let J=await c().listBenchmarkResults({limit:200});return{uri:"ranking://results",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),j}function OJ(){let j=new bJ;return j.register(_J({meta:{key:"ranking.advisor",version:"1.0.0",title:"AI Model Advisor",description:"Which AI model is best for a given task? Uses the leaderboard to recommend.",tags:Qj,stability:"beta",owners:kJ},args:[{name:"task",description:"The task or use case to recommend a model for.",required:!0,schema:M.string()},{name:"priority",description:"Priority dimension (coding, reasoning, cost, latency, etc.).",required:!1,schema:M.string().optional()},{name:"transport",description:"Required transport type (rest, mcp, webhook, sdk).",required:!1,schema:Mj},{name:"authMethod",description:"Required auth method (api-key, oauth2, bearer, etc.).",required:!1,schema:bj}],input:M.object({task:M.string(),priority:M.string().optional(),transport:Mj,authMethod:bj}),render:async({task:Y,priority:J,transport:Q,authMethod:$})=>{let Z=[];if(J)Z.push(`Prioritize: ${J}.`);if(Q)Z.push(`Required transport: ${Q}.`);if($)Z.push(`Required auth: ${$}.`);return[{type:"text",text:`Recommend the best AI model for: "${Y}".${Z.length?` ${Z.join(" ")}`:""} Use the leaderboard data to justify your recommendation.`},{type:"resource",uri:J?`ranking://leaderboard/${J}`:"ranking://leaderboard",title:"Leaderboard"}]}})),j}function RJ(){let j=new MJ,Y=NJ();return uj(j,DJ,async(J)=>{let Q=c(),$=J.source,Z=Y.get($);if(!Z)throw Error(`No ingester registered for source: ${$}`);let X=await Z.ingest({sourceUrl:J.sourceUrl,dimensions:J.dimensions}),U=EJ(X);for(let V of U)await Q.upsertBenchmarkResult(V);return{ingestionId:`ingest-${$}-${Date.now()}`,source:$,resultsCount:U.length,status:"completed",ingestedAt:new Date}}),uj(j,CJ,async(J)=>{return{runId:`custom-${Date.now()}`,evalSuiteKey:J.evalSuiteKey,modelId:J.modelId,status:"started",startedAt:new Date}}),uj(j,AJ,async(J)=>{let Q=c(),$=[],Z=0,X=500;while(!0){let H=await Q.listBenchmarkResults({limit:X,offset:Z});if($.push(...H.results),$.length>=H.total||H.results.length<X)break;Z+=X}let U=new Map((await Q.listModelRankings({limit:1e4})).rankings.map((H)=>[H.modelId,H])),V=J.weightOverrides?Array.isArray(J.weightOverrides)?J.weightOverrides:[J.weightOverrides]:void 0,B=zJ($,V?{weightOverrides:V}:void 0,U);for(let H of B)await Q.upsertModelRanking(H);return{modelsRanked:B.length,updatedAt:new Date,status:"completed"}}),j}function NZ(j="/api/mcp/ranking"){return A({logger:D,path:j,serverName:"contractspec-ranking-mcp",ops:RJ(),resources:vJ(),prompts:OJ()})}function zZ(j){_j=j}export{zZ as setProviderRankingStore,NZ as createProviderRankingMcpHandler,PZ as createInternalMcpHandler,VZ as createDocsMcpHandler,AQ as createContractsMcpHandler,HQ as createCliMcpHandler};
@@ -1,2 +1,2 @@
1
- import{Logger as G,LogLevel as P}from"@contractspec/lib.logger";function _(){return"production"}var v=()=>new G({level:P.INFO,environment:_(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),y=v(),kj=new G({level:P.WARN,environment:_(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),Cj=new G({level:P.INFO,environment:_(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1});var O=["application/json","text/event-stream"];function S(j){return!j||j.includes("*/*")||j.includes("application/*")||O.some((w)=>j.includes(w))}function f(j){if(j.method!=="POST")return j;let w=j.headers.get("accept");if(!S(w))return j;let B=O.filter((F)=>!w?.includes(F));if(B.length===0)return j;let Y=new Headers(j.headers);return Y.set("accept",[w,...B].filter(Boolean).join(", ")),new Request(j,{headers:Y})}import{createMcpServer as m}from"@contractspec/lib.contracts-runtime-server-mcp/provider-mcp";import{PresentationRegistry as N}from"@contractspec/lib.contracts-spec/presentations";import{McpServer as n}from"@modelcontextprotocol/sdk/server/mcp.js";import{WebStandardStreamableHTTPServerTransport as l}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";import{randomUUID as g}from"crypto";import{Elysia as u}from"elysia";var d={actor:"anonymous",decide:async()=>({effect:"allow"})};function b(j,w,B,Y){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:w,message:B,...Y?{data:Y}:{}},id:null}),{status:j,headers:{"content-type":"application/json"}})}function R({logger:j,serverName:w,ops:B,resources:Y,prompts:F,presentations:H,stateful:W}){let J=new n({name:w,version:"1.0.0"},{capabilities:{tools:{},resources:{},prompts:{},logging:{}}});j.info("Setting up MCP server..."),m(J,B,Y,F,{logger:j,toolCtx:()=>d,promptCtx:()=>({locale:"en"}),resourceCtx:()=>({locale:"en"}),presentations:new N(H)});let z=new l({sessionIdGenerator:W?()=>g():void 0,enableJsonResponse:!0});return J.connect(z).then(()=>({server:J,transport:z}))}async function D(j){await Promise.allSettled([j.transport.close(),j.server.close()])}function p(j){return j instanceof Error?j.stack??j.message:String(j)}function A({logger:j,path:w,serverName:B,ops:Y,resources:F,prompts:H,presentations:W,validateAuth:J,requiredAuthMethods:z}){j.info("Setting up MCP handler...",{requiredAuthMethods:z??[]});let T=process.env.CONTRACTSPEC_MCP_STATEFUL==="1",Z=new Map;async function I(Q){let U=await R({logger:j,path:w,serverName:B,ops:Y,resources:F,prompts:H,presentations:W,stateful:!1});try{return await U.transport.handleRequest(f(Q))}finally{await D(U)}}async function c(Q){let U=Z.get(Q);if(!U)return;Z.delete(Q),await D(U)}async function q(Q){let U=Q.headers.get("mcp-session-id"),k,x=!1;if(U){let K=Z.get(U);if(!K)return b(404,-32001,"Session not found");k=K}else k=await R({logger:j,path:w,serverName:B,ops:Y,resources:F,prompts:H,presentations:W,stateful:!0}),x=!0;try{let K=await k.transport.handleRequest(f(Q)),V=k.transport.sessionId;if(V&&!Z.has(V))Z.set(V,k);if(Q.method==="DELETE"&&V)await c(V);else if(!V&&x)await D(k);return K}catch(K){if(x)await D(k);throw K}}return new u({name:`mcp-${B}`}).all(w,async({request:Q})=>{try{if(J){let U=await J(Q);if(!U.valid)return b(401,-32002,"Authentication failed",U.reason)}if(T)return await q(Q);return await I(Q)}catch(U){return j.error("Error handling MCP request",{path:w,method:Q.method,error:p(U)}),b(500,-32000,"Internal error")}})}import{defineCommand as i,definePrompt as o,defineResourceTemplate as M,installOp as a,OperationSpecRegistry as t,PromptRegistry as r,ResourceRegistry as s}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as E,ScalarTypeEnum as h}from"@contractspec/lib.schema";import{getExample as e,listExamples as jj,searchExamples as wj}from"@contractspec/module.examples";import C from"zod";var X=["internal","mcp"],L=["@contractspec"],$={docs:"/api/mcp/docs",cli:"/api/mcp/cli",internal:"/api/mcp/internal",graphql:"/graphql",health:"/health"};function Bj(){let j=new s;return j.register(M({meta:{uriTemplate:"examples://list{?q}",title:"ContractSpec examples registry",description:"List available examples (templates, integrations, knowledge, scripts). Optional query `q` filters results.",mimeType:"application/json",tags:["examples",...X]},input:C.object({q:C.string().optional()}),resolve:async({q:w})=>{let B=w?wj(w):[...jj()];return{uri:w?`examples://list?q=${encodeURIComponent(w)}`:"examples://list",mimeType:"application/json",data:JSON.stringify(B,null,2)}}})),j.register(M({meta:{uriTemplate:"examples://example/{id}",title:"ContractSpec example (by id)",description:"Fetch a single example manifest by id.",mimeType:"application/json",tags:["examples",...X]},input:C.object({id:C.string().min(1)}),resolve:async({id:w})=>{let B=e(w);if(!B)return{uri:`examples://example/${encodeURIComponent(w)}`,mimeType:"application/json",data:JSON.stringify({error:"not_found",id:w,message:`Unknown example id: ${w}`},null,2)};return{uri:`examples://example/${encodeURIComponent(w)}`,mimeType:"application/json",data:JSON.stringify(B,null,2)}}})),j.register(M({meta:{uriTemplate:"internal://endpoints",title:"ContractSpec MCP endpoints",description:"Endpoints for docs, CLI, internal MCP servers.",mimeType:"application/json",tags:X},input:C.object({}),resolve:async()=>({uri:"internal://endpoints",mimeType:"application/json",data:JSON.stringify($,null,2)})})),j.register(M({meta:{uriTemplate:"internal://playbook",title:"Internal MCP usage playbook",description:"How internal agents should discover docs, CLI usage, and endpoints.",mimeType:"text/markdown",tags:X},input:C.object({}),resolve:async()=>({uri:"internal://playbook",mimeType:"text/markdown",data:["# Internal MCP playbook","- Connect to docs MCP first for canonical specs.","- Use CLI MCP to surface quickstart/reference before running commands.","- Keep calls read-only unless explicitly approved.",`- Endpoints: ${$.docs}, ${$.cli}, ${$.internal}.`,"- For API work, GraphQL at /graphql; health at /health."].join(`
2
- `)})})),j}function Qj(){let j=new r;return j.register(o({meta:{key:"internal_bootstrap",version:"1.0.0",title:"Bootstrap internal ContractSpec agent",description:"Points agents to the correct MCP endpoints and guardrails.",tags:X,owners:L,stability:"beta"},args:[],input:C.object({}),render:async()=>[{type:"text",text:"Start with internal://endpoints to pick the right MCP. Use docs MCP for specifications and CLI MCP for commands. Keep actions read-only unless explicitly approved."},{type:"resource",uri:"internal://endpoints",title:"Endpoints"}]})),j}function Uj(){let j=new t,w=E({name:"InternalDescribeOutput",fields:{endpoints:{type:h.JSONObject(),isOptional:!1},notes:{type:h.String_unsecure(),isOptional:!1}}}),B=i({meta:{key:"internal_describe",version:"1.0.0",stability:"stable",owners:L,tags:X,description:"Return MCP endpoints and guidance for internal ContractSpec agents.",goal:"Speed up internal development with the correct MCP entrypoints.",context:"Used by internal MCP surface; read-only."},io:{input:E({name:"InternalDescribeInput",fields:{}}),output:w},policy:{auth:"anonymous"}});return a(j,B,async()=>({endpoints:$,notes:"Use docs MCP for canonical specs, CLI MCP for contractspec commands, and keep side-effecting actions gated behind human review."})),j}function fj(j="/api/mcp/internal"){return A({logger:y,path:j,serverName:"contractspec-internal-mcp",ops:Uj(),resources:Bj(),prompts:Qj()})}export{fj as createInternalMcpHandler};
1
+ var v=Object.defineProperty;var S=(j)=>j;function m(j,w){this[j]=S.bind(null,w)}var Fj=(j,w)=>{for(var B in w)v(j,B,{get:w[B],enumerable:!0,configurable:!0,set:m.bind(w,B)})};var Jj=(j,w)=>()=>(j&&(w=j(j=0)),w);import{Logger as G,LogLevel as P}from"@contractspec/lib.logger";function _(){return"production"}var N=()=>new G({level:P.INFO,environment:_(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),y=N(),Xj=new G({level:P.WARN,environment:_(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),Zj=new G({level:P.INFO,environment:_(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1});var O=["application/json","text/event-stream"];function n(j){return!j||j.includes("*/*")||j.includes("application/*")||O.some((w)=>j.includes(w))}function f(j){if(j.method!=="POST")return j;let w=j.headers.get("accept");if(!n(w))return j;let B=O.filter((F)=>!w?.includes(F));if(B.length===0)return j;let Y=new Headers(j.headers);return Y.set("accept",[w,...B].filter(Boolean).join(", ")),new Request(j,{headers:Y})}import{createMcpServer as l}from"@contractspec/lib.contracts-runtime-server-mcp/provider-mcp";import{PresentationRegistry as g}from"@contractspec/lib.contracts-spec/presentations";import{McpServer as u}from"@modelcontextprotocol/sdk/server/mcp.js";import{WebStandardStreamableHTTPServerTransport as d}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";import{randomUUID as p}from"crypto";import{Elysia as i}from"elysia";var o={actor:"anonymous",decide:async()=>({effect:"allow"})};function b(j,w,B,Y){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:w,message:B,...Y?{data:Y}:{}},id:null}),{status:j,headers:{"content-type":"application/json"}})}function R({logger:j,serverName:w,ops:B,resources:Y,prompts:F,presentations:H,stateful:W}){let J=new u({name:w,version:"1.0.0"},{capabilities:{tools:{},resources:{},prompts:{},logging:{}}});j.info("Setting up MCP server..."),l(J,B,Y,F,{logger:j,toolCtx:()=>o,promptCtx:()=>({locale:"en"}),resourceCtx:()=>({locale:"en"}),presentations:new g(H)});let z=new d({sessionIdGenerator:W?()=>p():void 0,enableJsonResponse:!0});return J.connect(z).then(()=>({server:J,transport:z}))}async function D(j){await Promise.allSettled([j.transport.close(),j.server.close()])}function a(j){return j instanceof Error?j.stack??j.message:String(j)}function A({logger:j,path:w,serverName:B,ops:Y,resources:F,prompts:H,presentations:W,validateAuth:J,requiredAuthMethods:z}){j.info("Setting up MCP handler...",{requiredAuthMethods:z??[]});let T=process.env.CONTRACTSPEC_MCP_STATEFUL==="1",Z=new Map;async function I(Q){let U=await R({logger:j,path:w,serverName:B,ops:Y,resources:F,prompts:H,presentations:W,stateful:!1});try{return await U.transport.handleRequest(f(Q))}finally{await D(U)}}async function c(Q){let U=Z.get(Q);if(!U)return;Z.delete(Q),await D(U)}async function q(Q){let U=Q.headers.get("mcp-session-id"),k,x=!1;if(U){let K=Z.get(U);if(!K)return b(404,-32001,"Session not found");k=K}else k=await R({logger:j,path:w,serverName:B,ops:Y,resources:F,prompts:H,presentations:W,stateful:!0}),x=!0;try{let K=await k.transport.handleRequest(f(Q)),V=k.transport.sessionId;if(V&&!Z.has(V))Z.set(V,k);if(Q.method==="DELETE"&&V)await c(V);else if(!V&&x)await D(k);return K}catch(K){if(x)await D(k);throw K}}return new i({name:`mcp-${B}`}).all(w,async({request:Q})=>{try{if(J){let U=await J(Q);if(!U.valid)return b(401,-32002,"Authentication failed",U.reason)}if(T)return await q(Q);return await I(Q)}catch(U){return j.error("Error handling MCP request",{path:w,method:Q.method,error:a(U)}),b(500,-32000,"Internal error")}})}import{defineCommand as t,definePrompt as r,defineResourceTemplate as M,installOp as s,OperationSpecRegistry as e,PromptRegistry as jj,ResourceRegistry as wj}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as E,ScalarTypeEnum as h}from"@contractspec/lib.schema";import{getExample as Bj,listExamples as Qj,searchExamples as Uj}from"@contractspec/module.examples/catalog";import C from"zod";var X=["internal","mcp"],L=["@contractspec"],$={docs:"/api/mcp/docs",cli:"/api/mcp/cli",internal:"/api/mcp/internal",graphql:"/graphql",health:"/health"};function Yj(){let j=new wj;return j.register(M({meta:{uriTemplate:"examples://list{?q}",title:"ContractSpec examples registry",description:"List available examples (templates, integrations, knowledge, scripts). Optional query `q` filters results.",mimeType:"application/json",tags:["examples",...X]},input:C.object({q:C.string().optional()}),resolve:async({q:w})=>{let B=w?Uj(w):[...Qj()];return{uri:w?`examples://list?q=${encodeURIComponent(w)}`:"examples://list",mimeType:"application/json",data:JSON.stringify(B,null,2)}}})),j.register(M({meta:{uriTemplate:"examples://example/{id}",title:"ContractSpec example (by id)",description:"Fetch a single example manifest by id.",mimeType:"application/json",tags:["examples",...X]},input:C.object({id:C.string().min(1)}),resolve:async({id:w})=>{let B=Bj(w);if(!B)return{uri:`examples://example/${encodeURIComponent(w)}`,mimeType:"application/json",data:JSON.stringify({error:"not_found",id:w,message:`Unknown example id: ${w}`},null,2)};return{uri:`examples://example/${encodeURIComponent(w)}`,mimeType:"application/json",data:JSON.stringify(B,null,2)}}})),j.register(M({meta:{uriTemplate:"internal://endpoints",title:"ContractSpec MCP endpoints",description:"Endpoints for docs, CLI, internal MCP servers.",mimeType:"application/json",tags:X},input:C.object({}),resolve:async()=>({uri:"internal://endpoints",mimeType:"application/json",data:JSON.stringify($,null,2)})})),j.register(M({meta:{uriTemplate:"internal://playbook",title:"Internal MCP usage playbook",description:"How internal agents should discover docs, CLI usage, and endpoints.",mimeType:"text/markdown",tags:X},input:C.object({}),resolve:async()=>({uri:"internal://playbook",mimeType:"text/markdown",data:["# Internal MCP playbook","- Connect to docs MCP first for canonical specs.","- Use CLI MCP to surface quickstart/reference before running commands.","- Keep calls read-only unless explicitly approved.",`- Endpoints: ${$.docs}, ${$.cli}, ${$.internal}.`,"- For API work, GraphQL at /graphql; health at /health."].join(`
2
+ `)})})),j}function kj(){let j=new jj;return j.register(r({meta:{key:"internal_bootstrap",version:"1.0.0",title:"Bootstrap internal ContractSpec agent",description:"Points agents to the correct MCP endpoints and guardrails.",tags:X,owners:L,stability:"beta"},args:[],input:C.object({}),render:async()=>[{type:"text",text:"Start with internal://endpoints to pick the right MCP. Use docs MCP for specifications and CLI MCP for commands. Keep actions read-only unless explicitly approved."},{type:"resource",uri:"internal://endpoints",title:"Endpoints"}]})),j}function Cj(){let j=new e,w=E({name:"InternalDescribeOutput",fields:{endpoints:{type:h.JSONObject(),isOptional:!1},notes:{type:h.String_unsecure(),isOptional:!1}}}),B=t({meta:{key:"internal_describe",version:"1.0.0",stability:"stable",owners:L,tags:X,description:"Return MCP endpoints and guidance for internal ContractSpec agents.",goal:"Speed up internal development with the correct MCP entrypoints.",context:"Used by internal MCP surface; read-only."},io:{input:E({name:"InternalDescribeInput",fields:{}}),output:w},policy:{auth:"anonymous"}});return s(j,B,async()=>({endpoints:$,notes:"Use docs MCP for canonical specs, CLI MCP for contractspec commands, and keep side-effecting actions gated behind human review."})),j}function Ej(j="/api/mcp/internal"){return A({logger:y,path:j,serverName:"contractspec-internal-mcp",ops:Cj(),resources:Yj(),prompts:kj()})}export{Ej as createInternalMcpHandler};
@@ -1 +1 @@
1
- var o=["application/json","text/event-stream"];function c(n){return!n||n.includes("*/*")||n.includes("application/*")||o.some((e)=>n.includes(e))}function l(n){if(n.method!=="POST")return n;let e=n.headers.get("accept");if(!c(e))return n;let t=o.filter((s)=>!e?.includes(s));if(t.length===0)return n;let i=new Headers(n.headers);return i.set("accept",[e,...t].filter(Boolean).join(", ")),new Request(n,{headers:i})}export{l as normalizeMcpRequest};
1
+ var c=Object.defineProperty;var l=(n)=>n;function r(n,e){this[n]=l.bind(null,e)}var u=(n,e)=>{for(var t in e)c(n,t,{get:e[t],enumerable:!0,configurable:!0,set:r.bind(e,t)})};var d=(n,e)=>()=>(n&&(e=n(n=0)),e);var o=["application/json","text/event-stream"];function a(n){return!n||n.includes("*/*")||n.includes("application/*")||o.some((e)=>n.includes(e))}function f(n){if(n.method!=="POST")return n;let e=n.headers.get("accept");if(!a(e))return n;let t=o.filter((s)=>!e?.includes(s));if(t.length===0)return n;let i=new Headers(n.headers);return i.set("accept",[e,...t].filter(Boolean).join(", ")),new Request(n,{headers:i})}export{f as normalizeMcpRequest};
@@ -1 +1 @@
1
- import{Logger as M,LogLevel as k}from"@contractspec/lib.logger";function L(){return"production"}var c=()=>new M({level:k.INFO,environment:L(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),q=c(),Bj=new M({level:k.WARN,environment:L(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),Ej=new M({level:k.INFO,environment:L(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1});var N=["application/json","text/event-stream"];function h(j){return!j||j.includes("*/*")||j.includes("application/*")||N.some((U)=>j.includes(U))}function z(j){if(j.method!=="POST")return j;let U=j.headers.get("accept");if(!h(U))return j;let Q=N.filter((J)=>!U?.includes(J));if(Q.length===0)return j;let Y=new Headers(j.headers);return Y.set("accept",[U,...Q].filter(Boolean).join(", ")),new Request(j,{headers:Y})}import{createMcpServer as m}from"@contractspec/lib.contracts-runtime-server-mcp/provider-mcp";import{PresentationRegistry as u}from"@contractspec/lib.contracts-spec/presentations";import{McpServer as d}from"@modelcontextprotocol/sdk/server/mcp.js";import{WebStandardStreamableHTTPServerTransport as l}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";import{randomUUID as p}from"crypto";import{Elysia as g}from"elysia";var n={actor:"anonymous",decide:async()=>({effect:"allow"})};function y(j,U,Q,Y){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:U,message:Q,...Y?{data:Y}:{}},id:null}),{status:j,headers:{"content-type":"application/json"}})}function f({logger:j,serverName:U,ops:Q,resources:Y,prompts:J,presentations:D,stateful:B}){let x=new d({name:U,version:"1.0.0"},{capabilities:{tools:{},resources:{},prompts:{},logging:{}}});j.info("Setting up MCP server..."),m(x,Q,Y,J,{logger:j,toolCtx:()=>n,promptCtx:()=>({locale:"en"}),resourceCtx:()=>({locale:"en"}),presentations:new u(D)});let E=new l({sessionIdGenerator:B?()=>p():void 0,enableJsonResponse:!0});return x.connect(E).then(()=>({server:x,transport:E}))}async function K(j){await Promise.allSettled([j.transport.close(),j.server.close()])}function i(j){return j instanceof Error?j.stack??j.message:String(j)}function I({logger:j,path:U,serverName:Q,ops:Y,resources:J,prompts:D,presentations:B,validateAuth:x,requiredAuthMethods:E}){j.info("Setting up MCP handler...",{requiredAuthMethods:E??[]});let _=process.env.CONTRACTSPEC_MCP_STATEFUL==="1",V=new Map;async function R(X){let Z=await f({logger:j,path:U,serverName:Q,ops:Y,resources:J,prompts:D,presentations:B,stateful:!1});try{return await Z.transport.handleRequest(z(X))}finally{await K(Z)}}async function v(X){let Z=V.get(X);if(!Z)return;V.delete(X),await K(Z)}async function S(X){let Z=X.headers.get("mcp-session-id"),H,T=!1;if(Z){let P=V.get(Z);if(!P)return y(404,-32001,"Session not found");H=P}else H=await f({logger:j,path:U,serverName:Q,ops:Y,resources:J,prompts:D,presentations:B,stateful:!0}),T=!0;try{let P=await H.transport.handleRequest(z(X)),W=H.transport.sessionId;if(W&&!V.has(W))V.set(W,H);if(X.method==="DELETE"&&W)await v(W);else if(!W&&T)await K(H);return P}catch(P){if(T)await K(H);throw P}}return new g({name:`mcp-${Q}`}).all(U,async({request:X})=>{try{if(x){let Z=await x(X);if(!Z.valid)return y(401,-32002,"Authentication failed",Z.reason)}if(_)return await S(X);return await R(X)}catch(Z){return j.error("Error handling MCP request",{path:U,method:X.method,error:i(Z)}),y(500,-32000,"Internal error")}})}import{getModelInfo as a}from"@contractspec/lib.ai-providers/models";import{definePrompt as o,defineResourceTemplate as b,installOp as A,OperationSpecRegistry as t,PromptRegistry as s,ResourceRegistry as r}from"@contractspec/lib.contracts-spec";import{BenchmarkIngestCommand as e,BenchmarkRunCustomCommand as jj,RankingRefreshCommand as Qj}from"@contractspec/lib.contracts-spec/provider-ranking";import{InMemoryProviderRankingStore as Uj}from"@contractspec/lib.provider-ranking/in-memory-store";import{createDefaultIngesterRegistry as Yj}from"@contractspec/lib.provider-ranking/ingesters";import{computeModelRankings as Dj,normalizeBenchmarkResults as Jj}from"@contractspec/lib.provider-ranking/scoring";import $ from"zod";var F=$.enum(["rest","mcp","webhook","sdk"]).optional(),G=$.enum(["api-key","oauth2","bearer","header","basic","webhook-signing","service-account"]).optional(),w=["ranking","mcp","ai"],Vj=["platform.ai"],O=null;function C(){if(!O)O=new Uj;return O}function Xj(){let j=new r;return j.register(b({meta:{uriTemplate:"ranking://leaderboard",title:"AI Model Leaderboard",description:"Current ranked list of AI models by composite score. Supports optional transport and authMethod query filters.",mimeType:"application/json",tags:w},input:$.object({transport:F,authMethod:G}),resolve:async({transport:U,authMethod:Q})=>{let J=await C().listModelRankings({limit:100,requiredTransport:U,requiredAuthMethod:Q});return{uri:"ranking://leaderboard",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),j.register(b({meta:{uriTemplate:"ranking://leaderboard/{dimension}",title:"AI Model Leaderboard by Dimension",description:"Ranked list of AI models filtered by a specific dimension. Supports optional transport and authMethod query filters.",mimeType:"application/json",tags:w},input:$.object({dimension:$.string(),transport:F,authMethod:G}),resolve:async({dimension:U,transport:Q,authMethod:Y})=>{let D=await C().listModelRankings({dimension:U,limit:100,requiredTransport:Q,requiredAuthMethod:Y});return{uri:`ranking://leaderboard/${encodeURIComponent(U)}`,mimeType:"application/json",data:JSON.stringify(D,null,2)}}})),j.register(b({meta:{uriTemplate:"ranking://model/{modelId}",title:"AI Model Profile",description:"Detailed profile for a specific AI model including scores and benchmarks.",mimeType:"application/json",tags:w},input:$.object({modelId:$.string()}),resolve:async({modelId:U})=>{let Y=await C().getModelProfile(U);if(!Y)return{uri:`ranking://model/${encodeURIComponent(U)}`,mimeType:"application/json",data:JSON.stringify({error:"not_found",modelId:U})};let J=Y.costPerMillion==null?(()=>{let D=a(Y.modelId);return D?.costPerMillion?{...Y,costPerMillion:D.costPerMillion,displayName:D.name,contextWindow:D.contextWindow,capabilities:[...D.capabilities.vision?["vision"]:[],...D.capabilities.tools?["tools"]:[],...D.capabilities.reasoning?["reasoning"]:[],...D.capabilities.streaming?["streaming"]:[]]}:Y})():Y;return{uri:`ranking://model/${encodeURIComponent(U)}`,mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),j.register(b({meta:{uriTemplate:"ranking://results",title:"Benchmark Results",description:"List of raw benchmark results from all ingested sources.",mimeType:"application/json",tags:w},input:$.object({}),resolve:async()=>{let Q=await C().listBenchmarkResults({limit:200});return{uri:"ranking://results",mimeType:"application/json",data:JSON.stringify(Q,null,2)}}})),j}function Zj(){let j=new s;return j.register(o({meta:{key:"ranking.advisor",version:"1.0.0",title:"AI Model Advisor",description:"Which AI model is best for a given task? Uses the leaderboard to recommend.",tags:w,stability:"beta",owners:Vj},args:[{name:"task",description:"The task or use case to recommend a model for.",required:!0,schema:$.string()},{name:"priority",description:"Priority dimension (coding, reasoning, cost, latency, etc.).",required:!1,schema:$.string().optional()},{name:"transport",description:"Required transport type (rest, mcp, webhook, sdk).",required:!1,schema:F},{name:"authMethod",description:"Required auth method (api-key, oauth2, bearer, etc.).",required:!1,schema:G}],input:$.object({task:$.string(),priority:$.string().optional(),transport:F,authMethod:G}),render:async({task:U,priority:Q,transport:Y,authMethod:J})=>{let D=[];if(Q)D.push(`Prioritize: ${Q}.`);if(Y)D.push(`Required transport: ${Y}.`);if(J)D.push(`Required auth: ${J}.`);return[{type:"text",text:`Recommend the best AI model for: "${U}".${D.length?` ${D.join(" ")}`:""} Use the leaderboard data to justify your recommendation.`},{type:"resource",uri:Q?`ranking://leaderboard/${Q}`:"ranking://leaderboard",title:"Leaderboard"}]}})),j}function $j(){let j=new t,U=Yj();return A(j,e,async(Q)=>{let Y=C(),J=Q.source,D=U.get(J);if(!D)throw Error(`No ingester registered for source: ${J}`);let B=await D.ingest({sourceUrl:Q.sourceUrl,dimensions:Q.dimensions}),x=Jj(B);for(let E of x)await Y.upsertBenchmarkResult(E);return{ingestionId:`ingest-${J}-${Date.now()}`,source:J,resultsCount:x.length,status:"completed",ingestedAt:new Date}}),A(j,jj,async(Q)=>{return{runId:`custom-${Date.now()}`,evalSuiteKey:Q.evalSuiteKey,modelId:Q.modelId,status:"started",startedAt:new Date}}),A(j,Qj,async(Q)=>{let Y=C(),J=[],D=0,B=500;while(!0){let V=await Y.listBenchmarkResults({limit:B,offset:D});if(J.push(...V.results),J.length>=V.total||V.results.length<B)break;D+=B}let x=new Map((await Y.listModelRankings({limit:1e4})).rankings.map((V)=>[V.modelId,V])),E=Q.weightOverrides?Array.isArray(Q.weightOverrides)?Q.weightOverrides:[Q.weightOverrides]:void 0,_=Dj(J,E?{weightOverrides:E}:void 0,x);for(let V of _)await Y.upsertModelRanking(V);return{modelsRanked:_.length,updatedAt:new Date,status:"completed"}}),j}function Nj(j="/api/mcp/ranking"){return I({logger:q,path:j,serverName:"contractspec-ranking-mcp",ops:$j(),resources:Xj(),prompts:Zj()})}function fj(j){O=j}export{fj as setProviderRankingStore,Nj as createProviderRankingMcpHandler};
1
+ var c=Object.defineProperty;var h=(j)=>j;function m(j,Q){this[j]=h.bind(null,Q)}var Hj=(j,Q)=>{for(var U in Q)c(j,U,{get:Q[U],enumerable:!0,configurable:!0,set:m.bind(Q,U)})};var Pj=(j,Q)=>()=>(j&&(Q=j(j=0)),Q);import{Logger as M,LogLevel as k}from"@contractspec/lib.logger";function L(){return"production"}var u=()=>new M({level:k.INFO,environment:L(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),q=u(),wj=new M({level:k.WARN,environment:L(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1}),_j=new M({level:k.INFO,environment:L(),enableTracing:!0,enableTiming:!0,enableContext:!0,enableColors:!1});var N=["application/json","text/event-stream"];function d(j){return!j||j.includes("*/*")||j.includes("application/*")||N.some((Q)=>j.includes(Q))}function z(j){if(j.method!=="POST")return j;let Q=j.headers.get("accept");if(!d(Q))return j;let U=N.filter((J)=>!Q?.includes(J));if(U.length===0)return j;let Y=new Headers(j.headers);return Y.set("accept",[Q,...U].filter(Boolean).join(", ")),new Request(j,{headers:Y})}import{createMcpServer as l}from"@contractspec/lib.contracts-runtime-server-mcp/provider-mcp";import{PresentationRegistry as p}from"@contractspec/lib.contracts-spec/presentations";import{McpServer as g}from"@modelcontextprotocol/sdk/server/mcp.js";import{WebStandardStreamableHTTPServerTransport as n}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";import{randomUUID as i}from"crypto";import{Elysia as a}from"elysia";var o={actor:"anonymous",decide:async()=>({effect:"allow"})};function y(j,Q,U,Y){return new Response(JSON.stringify({jsonrpc:"2.0",error:{code:Q,message:U,...Y?{data:Y}:{}},id:null}),{status:j,headers:{"content-type":"application/json"}})}function f({logger:j,serverName:Q,ops:U,resources:Y,prompts:J,presentations:D,stateful:B}){let x=new g({name:Q,version:"1.0.0"},{capabilities:{tools:{},resources:{},prompts:{},logging:{}}});j.info("Setting up MCP server..."),l(x,U,Y,J,{logger:j,toolCtx:()=>o,promptCtx:()=>({locale:"en"}),resourceCtx:()=>({locale:"en"}),presentations:new p(D)});let E=new n({sessionIdGenerator:B?()=>i():void 0,enableJsonResponse:!0});return x.connect(E).then(()=>({server:x,transport:E}))}async function K(j){await Promise.allSettled([j.transport.close(),j.server.close()])}function t(j){return j instanceof Error?j.stack??j.message:String(j)}function I({logger:j,path:Q,serverName:U,ops:Y,resources:J,prompts:D,presentations:B,validateAuth:x,requiredAuthMethods:E}){j.info("Setting up MCP handler...",{requiredAuthMethods:E??[]});let _=process.env.CONTRACTSPEC_MCP_STATEFUL==="1",V=new Map;async function R(X){let Z=await f({logger:j,path:Q,serverName:U,ops:Y,resources:J,prompts:D,presentations:B,stateful:!1});try{return await Z.transport.handleRequest(z(X))}finally{await K(Z)}}async function v(X){let Z=V.get(X);if(!Z)return;V.delete(X),await K(Z)}async function S(X){let Z=X.headers.get("mcp-session-id"),H,T=!1;if(Z){let P=V.get(Z);if(!P)return y(404,-32001,"Session not found");H=P}else H=await f({logger:j,path:Q,serverName:U,ops:Y,resources:J,prompts:D,presentations:B,stateful:!0}),T=!0;try{let P=await H.transport.handleRequest(z(X)),W=H.transport.sessionId;if(W&&!V.has(W))V.set(W,H);if(X.method==="DELETE"&&W)await v(W);else if(!W&&T)await K(H);return P}catch(P){if(T)await K(H);throw P}}return new a({name:`mcp-${U}`}).all(Q,async({request:X})=>{try{if(x){let Z=await x(X);if(!Z.valid)return y(401,-32002,"Authentication failed",Z.reason)}if(_)return await S(X);return await R(X)}catch(Z){return j.error("Error handling MCP request",{path:Q,method:X.method,error:t(Z)}),y(500,-32000,"Internal error")}})}import{getModelInfo as s}from"@contractspec/lib.ai-providers/models";import{definePrompt as r,defineResourceTemplate as b,installOp as A,OperationSpecRegistry as e,PromptRegistry as jj,ResourceRegistry as Qj}from"@contractspec/lib.contracts-spec";import{BenchmarkIngestCommand as Uj,BenchmarkRunCustomCommand as Yj,RankingRefreshCommand as Dj}from"@contractspec/lib.contracts-spec/provider-ranking";import{InMemoryProviderRankingStore as Jj}from"@contractspec/lib.provider-ranking/in-memory-store";import{createDefaultIngesterRegistry as Vj}from"@contractspec/lib.provider-ranking/ingesters";import{computeModelRankings as Xj,normalizeBenchmarkResults as Zj}from"@contractspec/lib.provider-ranking/scoring";import $ from"zod";var F=$.enum(["rest","mcp","webhook","sdk"]).optional(),G=$.enum(["api-key","oauth2","bearer","header","basic","webhook-signing","service-account"]).optional(),w=["ranking","mcp","ai"],$j=["platform.ai"],O=null;function C(){if(!O)O=new Jj;return O}function xj(){let j=new Qj;return j.register(b({meta:{uriTemplate:"ranking://leaderboard",title:"AI Model Leaderboard",description:"Current ranked list of AI models by composite score. Supports optional transport and authMethod query filters.",mimeType:"application/json",tags:w},input:$.object({transport:F,authMethod:G}),resolve:async({transport:Q,authMethod:U})=>{let J=await C().listModelRankings({limit:100,requiredTransport:Q,requiredAuthMethod:U});return{uri:"ranking://leaderboard",mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),j.register(b({meta:{uriTemplate:"ranking://leaderboard/{dimension}",title:"AI Model Leaderboard by Dimension",description:"Ranked list of AI models filtered by a specific dimension. Supports optional transport and authMethod query filters.",mimeType:"application/json",tags:w},input:$.object({dimension:$.string(),transport:F,authMethod:G}),resolve:async({dimension:Q,transport:U,authMethod:Y})=>{let D=await C().listModelRankings({dimension:Q,limit:100,requiredTransport:U,requiredAuthMethod:Y});return{uri:`ranking://leaderboard/${encodeURIComponent(Q)}`,mimeType:"application/json",data:JSON.stringify(D,null,2)}}})),j.register(b({meta:{uriTemplate:"ranking://model/{modelId}",title:"AI Model Profile",description:"Detailed profile for a specific AI model including scores and benchmarks.",mimeType:"application/json",tags:w},input:$.object({modelId:$.string()}),resolve:async({modelId:Q})=>{let Y=await C().getModelProfile(Q);if(!Y)return{uri:`ranking://model/${encodeURIComponent(Q)}`,mimeType:"application/json",data:JSON.stringify({error:"not_found",modelId:Q})};let J=Y.costPerMillion==null?(()=>{let D=s(Y.modelId);return D?.costPerMillion?{...Y,costPerMillion:D.costPerMillion,displayName:D.name,contextWindow:D.contextWindow,capabilities:[...D.capabilities.vision?["vision"]:[],...D.capabilities.tools?["tools"]:[],...D.capabilities.reasoning?["reasoning"]:[],...D.capabilities.streaming?["streaming"]:[]]}:Y})():Y;return{uri:`ranking://model/${encodeURIComponent(Q)}`,mimeType:"application/json",data:JSON.stringify(J,null,2)}}})),j.register(b({meta:{uriTemplate:"ranking://results",title:"Benchmark Results",description:"List of raw benchmark results from all ingested sources.",mimeType:"application/json",tags:w},input:$.object({}),resolve:async()=>{let U=await C().listBenchmarkResults({limit:200});return{uri:"ranking://results",mimeType:"application/json",data:JSON.stringify(U,null,2)}}})),j}function Bj(){let j=new jj;return j.register(r({meta:{key:"ranking.advisor",version:"1.0.0",title:"AI Model Advisor",description:"Which AI model is best for a given task? Uses the leaderboard to recommend.",tags:w,stability:"beta",owners:$j},args:[{name:"task",description:"The task or use case to recommend a model for.",required:!0,schema:$.string()},{name:"priority",description:"Priority dimension (coding, reasoning, cost, latency, etc.).",required:!1,schema:$.string().optional()},{name:"transport",description:"Required transport type (rest, mcp, webhook, sdk).",required:!1,schema:F},{name:"authMethod",description:"Required auth method (api-key, oauth2, bearer, etc.).",required:!1,schema:G}],input:$.object({task:$.string(),priority:$.string().optional(),transport:F,authMethod:G}),render:async({task:Q,priority:U,transport:Y,authMethod:J})=>{let D=[];if(U)D.push(`Prioritize: ${U}.`);if(Y)D.push(`Required transport: ${Y}.`);if(J)D.push(`Required auth: ${J}.`);return[{type:"text",text:`Recommend the best AI model for: "${Q}".${D.length?` ${D.join(" ")}`:""} Use the leaderboard data to justify your recommendation.`},{type:"resource",uri:U?`ranking://leaderboard/${U}`:"ranking://leaderboard",title:"Leaderboard"}]}})),j}function Ej(){let j=new e,Q=Vj();return A(j,Uj,async(U)=>{let Y=C(),J=U.source,D=Q.get(J);if(!D)throw Error(`No ingester registered for source: ${J}`);let B=await D.ingest({sourceUrl:U.sourceUrl,dimensions:U.dimensions}),x=Zj(B);for(let E of x)await Y.upsertBenchmarkResult(E);return{ingestionId:`ingest-${J}-${Date.now()}`,source:J,resultsCount:x.length,status:"completed",ingestedAt:new Date}}),A(j,Yj,async(U)=>{return{runId:`custom-${Date.now()}`,evalSuiteKey:U.evalSuiteKey,modelId:U.modelId,status:"started",startedAt:new Date}}),A(j,Dj,async(U)=>{let Y=C(),J=[],D=0,B=500;while(!0){let V=await Y.listBenchmarkResults({limit:B,offset:D});if(J.push(...V.results),J.length>=V.total||V.results.length<B)break;D+=B}let x=new Map((await Y.listModelRankings({limit:1e4})).rankings.map((V)=>[V.modelId,V])),E=U.weightOverrides?Array.isArray(U.weightOverrides)?U.weightOverrides:[U.weightOverrides]:void 0,_=Xj(J,E?{weightOverrides:E}:void 0,x);for(let V of _)await Y.upsertModelRanking(V);return{modelsRanked:_.length,updatedAt:new Date,status:"completed"}}),j}function cj(j="/api/mcp/ranking"){return I({logger:q,path:j,serverName:"contractspec-ranking-mcp",ops:Ej(),resources:xj(),prompts:Bj()})}function hj(j){O=j}export{hj as setProviderRankingStore,cj as createProviderRankingMcpHandler};
@@ -1 +1 @@
1
- import{defineModuleBundle as g}from"@contractspec/lib.surface-runtime/spec";var j=g({meta:{key:"library.workspace",version:"0.1.0",title:"Library Workspace",description:"Workspace shell for docs, templates, sandbox, and feature discovery",owners:["team-platform"],tags:["library","workspace","docs","sandbox","templates"],stability:"experimental"},routes:[{routeId:"sandbox",path:"/sandbox",defaultSurface:"workspace-shell"},{routeId:"docs",path:"/docs",defaultSurface:"workspace-shell"},{routeId:"docs-slug",path:"/docs/:slug",defaultSurface:"workspace-shell"},{routeId:"studio",path:"/studio/:projectSlug",defaultSurface:"workspace-shell"}],surfaces:{"workspace-shell":{surfaceId:"workspace-shell",kind:"workbench",title:"Workspace Shell",slots:[{slotId:"header",role:"header",accepts:["action-bar"],cardinality:"many"},{slotId:"sidebar",role:"secondary",accepts:["entity-section","custom-widget"],cardinality:"one"},{slotId:"primary",role:"primary",accepts:["entity-section","rich-doc","data-view","form","custom-widget"],cardinality:"many",mutableByAi:!0,mutableByUser:!0},{slotId:"assistant",role:"assistant",accepts:["assistant-panel","chat-thread"],cardinality:"many",mutableByAi:!0,mutableByUser:!0}],layouts:[{layoutId:"sidebar-main",title:"Sidebar + Main",root:{type:"panel-group",direction:"horizontal",persistKey:"library.workspace.sidebar-main",children:[{type:"slot",slotId:"sidebar"},{type:"panel-group",direction:"vertical",persistKey:"library.workspace.content",children:[{type:"slot",slotId:"header"},{type:"slot",slotId:"primary"}]}]}},{layoutId:"sidebar-main-assistant",title:"Sidebar + Main + Assistant",root:{type:"panel-group",direction:"horizontal",persistKey:"library.workspace.sidebar-main-assistant",children:[{type:"slot",slotId:"sidebar"},{type:"panel-group",direction:"vertical",persistKey:"library.workspace.content",children:[{type:"slot",slotId:"header"},{type:"slot",slotId:"primary"}]},{type:"slot",slotId:"assistant"}]}}],data:[],verification:{dimensions:{guidance:"Can reveal walkthrough notes, field help, and contextual hints.",density:"Can select compact, balanced, or dense layouts for docs and templates.",dataDepth:"Controls content depth, pagination size, and inline expansion.",control:"Shows advanced commands and raw config only when allowed.",media:"Supports text-first docs, visual templates, and hybrid modes.",pace:"Maps to motion tokens and confirmation behavior.",narrative:"Can order summary before or after detail sections."}}}}});export{j as LibraryBundle};
1
+ var k=Object.defineProperty;var q=(g)=>g;function v(g,h){this[g]=q.bind(null,h)}var x=(g,h)=>{for(var j in h)k(g,j,{get:h[j],enumerable:!0,configurable:!0,set:v.bind(h,j)})};var y=(g,h)=>()=>(g&&(h=g(g=0)),h);import{defineModuleBundle as w}from"@contractspec/lib.surface-runtime/spec";var C=w({meta:{key:"bundles.library",version:"1.0.0",title:"Library",description:"ContractSpec package declaration for @contractspec/bundle.library."},routes:[{routeId:"default",path:"/",defaultSurface:"main"}],surfaces:{main:{surfaceId:"main",kind:"workbench",title:"Library",slots:[],layouts:[],data:[],verification:{dimensions:{guidance:"Scaffolded guidance profile for Library.",density:"Scaffolded density profile for Library.",dataDepth:"Scaffolded data-depth profile for Library.",control:"Scaffolded control profile for Library.",media:"Scaffolded media profile for Library.",pace:"Scaffolded pace profile for Library.",narrative:"Scaffolded narrative profile for Library."}}}}});export{C as LibraryBundle};
@@ -1 +1 @@
1
- import{defineModuleBundle as r}from"@contractspec/lib.surface-runtime/spec";var x=r({meta:{key:"library.workspace",version:"0.1.0",title:"Library Workspace",description:"Workspace shell for docs, templates, sandbox, and feature discovery",owners:["team-platform"],tags:["library","workspace","docs","sandbox","templates"],stability:"experimental"},routes:[{routeId:"sandbox",path:"/sandbox",defaultSurface:"workspace-shell"},{routeId:"docs",path:"/docs",defaultSurface:"workspace-shell"},{routeId:"docs-slug",path:"/docs/:slug",defaultSurface:"workspace-shell"},{routeId:"studio",path:"/studio/:projectSlug",defaultSurface:"workspace-shell"}],surfaces:{"workspace-shell":{surfaceId:"workspace-shell",kind:"workbench",title:"Workspace Shell",slots:[{slotId:"header",role:"header",accepts:["action-bar"],cardinality:"many"},{slotId:"sidebar",role:"secondary",accepts:["entity-section","custom-widget"],cardinality:"one"},{slotId:"primary",role:"primary",accepts:["entity-section","rich-doc","data-view","form","custom-widget"],cardinality:"many",mutableByAi:!0,mutableByUser:!0},{slotId:"assistant",role:"assistant",accepts:["assistant-panel","chat-thread"],cardinality:"many",mutableByAi:!0,mutableByUser:!0}],layouts:[{layoutId:"sidebar-main",title:"Sidebar + Main",root:{type:"panel-group",direction:"horizontal",persistKey:"library.workspace.sidebar-main",children:[{type:"slot",slotId:"sidebar"},{type:"panel-group",direction:"vertical",persistKey:"library.workspace.content",children:[{type:"slot",slotId:"header"},{type:"slot",slotId:"primary"}]}]}},{layoutId:"sidebar-main-assistant",title:"Sidebar + Main + Assistant",root:{type:"panel-group",direction:"horizontal",persistKey:"library.workspace.sidebar-main-assistant",children:[{type:"slot",slotId:"sidebar"},{type:"panel-group",direction:"vertical",persistKey:"library.workspace.content",children:[{type:"slot",slotId:"header"},{type:"slot",slotId:"primary"}]},{type:"slot",slotId:"assistant"}]}}],data:[],verification:{dimensions:{guidance:"Can reveal walkthrough notes, field help, and contextual hints.",density:"Can select compact, balanced, or dense layouts for docs and templates.",dataDepth:"Controls content depth, pagination size, and inline expansion.",control:"Shows advanced commands and raw config only when allowed.",media:"Supports text-first docs, visual templates, and hybrid modes.",pace:"Maps to motion tokens and confirmation behavior.",narrative:"Can order summary before or after detail sections."}}}}});export{x as LibraryBundle};
1
+ var L=Object.defineProperty;var b=(r)=>r;function g(r,x){this[r]=b.bind(null,x)}var k=(r,x)=>{for(var y in x)L(r,y,{get:x[y],enumerable:!0,configurable:!0,set:g.bind(x,y)})};var m=(r,x)=>()=>(r&&(x=r(r=0)),x);import{defineModuleBundle as h}from"@contractspec/lib.surface-runtime/spec";var j=h({meta:{key:"bundles.library",version:"1.0.0",title:"Library",description:"ContractSpec package declaration for @contractspec/bundle.library."},routes:[{routeId:"default",path:"/",defaultSurface:"main"}],surfaces:{main:{surfaceId:"main",kind:"workbench",title:"Library",slots:[],layouts:[],data:[],verification:{dimensions:{guidance:"Scaffolded guidance profile for Library.",density:"Scaffolded density profile for Library.",dataDepth:"Scaffolded data-depth profile for Library.",control:"Scaffolded control profile for Library.",media:"Scaffolded media profile for Library.",pace:"Scaffolded pace profile for Library.",narrative:"Scaffolded narrative profile for Library."}}}}});export{j as LibraryBundle};