@contractspec/lib.contracts 0.0.0-canary-20260113162409
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/_virtual/rolldown_runtime.js +37 -0
- package/dist/app-config/app-config.capability.d.ts +7 -0
- package/dist/app-config/app-config.capability.js +23 -0
- package/dist/app-config/app-config.feature.d.ts +11 -0
- package/dist/app-config/app-config.feature.js +61 -0
- package/dist/app-config/branding.d.ts +55 -0
- package/dist/app-config/branding.js +0 -0
- package/dist/app-config/contracts.d.ts +245 -0
- package/dist/app-config/contracts.js +395 -0
- package/dist/app-config/docs/app-config.docblock.d.ts +6 -0
- package/dist/app-config/docs/app-config.docblock.js +21 -0
- package/dist/app-config/events.d.ts +122 -0
- package/dist/app-config/events.js +174 -0
- package/dist/app-config/index.d.ts +10 -0
- package/dist/app-config/index.js +9 -0
- package/dist/app-config/lifecycle-contracts.d.ts +273 -0
- package/dist/app-config/lifecycle-contracts.js +440 -0
- package/dist/app-config/lifecycle.d.ts +27 -0
- package/dist/app-config/lifecycle.js +0 -0
- package/dist/app-config/runtime.d.ts +120 -0
- package/dist/app-config/runtime.js +617 -0
- package/dist/app-config/spec.d.ts +175 -0
- package/dist/app-config/spec.js +19 -0
- package/dist/app-config/validation.d.ts +49 -0
- package/dist/app-config/validation.js +538 -0
- package/dist/capabilities/capabilities.d.ts +41 -0
- package/dist/capabilities/capabilities.js +48 -0
- package/dist/capabilities/docs/capabilities.docblock.d.ts +6 -0
- package/dist/capabilities/docs/capabilities.docblock.js +21 -0
- package/dist/capabilities/index.d.ts +3 -0
- package/dist/capabilities/index.js +4 -0
- package/dist/capabilities/openbanking.d.ts +10 -0
- package/dist/capabilities/openbanking.js +92 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +9 -0
- package/dist/client/react/drivers/rn-reusables.d.ts +22 -0
- package/dist/client/react/drivers/rn-reusables.js +21 -0
- package/dist/client/react/drivers/shadcn.d.ts +12 -0
- package/dist/client/react/drivers/shadcn.js +11 -0
- package/dist/client/react/feature-render.d.ts +23 -0
- package/dist/client/react/feature-render.js +44 -0
- package/dist/client/react/form-render.d.ts +92 -0
- package/dist/client/react/form-render.js +301 -0
- package/dist/client/react/index.d.ts +5 -0
- package/dist/client/react/index.js +8 -0
- package/dist/contract-registry/index.d.ts +3 -0
- package/dist/contract-registry/index.js +3 -0
- package/dist/contract-registry/schemas.d.ts +124 -0
- package/dist/contract-registry/schemas.js +61 -0
- package/dist/contract-registry/types.d.ts +46 -0
- package/dist/contract-registry/types.js +0 -0
- package/dist/data-views/data-views.d.ts +5 -0
- package/dist/data-views/data-views.js +5 -0
- package/dist/data-views/docs/data-views.docblock.d.ts +6 -0
- package/dist/data-views/docs/data-views.docblock.js +21 -0
- package/dist/data-views/index.d.ts +4 -0
- package/dist/data-views/index.js +4 -0
- package/dist/data-views/query-generator.d.ts +40 -0
- package/dist/data-views/query-generator.js +48 -0
- package/dist/data-views/registry.d.ts +17 -0
- package/dist/data-views/registry.js +20 -0
- package/dist/data-views/runtime.d.ts +32 -0
- package/dist/data-views/runtime.js +68 -0
- package/dist/data-views/spec.d.ts +32 -0
- package/dist/data-views/spec.js +10 -0
- package/dist/data-views/types.d.ts +157 -0
- package/dist/data-views/types.js +0 -0
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.d.ts +6 -0
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +17 -0
- package/dist/docs/index.d.ts +6 -0
- package/dist/docs/index.js +30 -0
- package/dist/docs/meta.docs.d.ts +6 -0
- package/dist/docs/meta.docs.js +29 -0
- package/dist/docs/presentations.d.ts +31 -0
- package/dist/docs/presentations.js +57 -0
- package/dist/docs/registry.d.ts +23 -0
- package/dist/docs/registry.js +51 -0
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.d.ts +6 -0
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +81 -0
- package/dist/docs/tech/cli.docblock.d.ts +6 -0
- package/dist/docs/tech/cli.docblock.js +138 -0
- package/dist/docs/tech/contracts/README.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/README.docblock.js +21 -0
- package/dist/docs/tech/contracts/migrations.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/migrations.docblock.js +21 -0
- package/dist/docs/tech/contracts/openapi-export.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/openapi-export.docblock.js +58 -0
- package/dist/docs/tech/contracts/openapi-import.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/openapi-import.docblock.js +65 -0
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +21 -0
- package/dist/docs/tech/contracts/overlays.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/overlays.docblock.js +21 -0
- package/dist/docs/tech/contracts/tests.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/tests.docblock.js +21 -0
- package/dist/docs/tech/contracts/themes.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/themes.docblock.js +21 -0
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +126 -0
- package/dist/docs/tech/lifecycle-stage-system.docblock.d.ts +6 -0
- package/dist/docs/tech/lifecycle-stage-system.docblock.js +17 -0
- package/dist/docs/tech/llm/llm-integration.docblock.d.ts +7 -0
- package/dist/docs/tech/llm/llm-integration.docblock.js +358 -0
- package/dist/docs/tech/mcp-endpoints.docblock.d.ts +6 -0
- package/dist/docs/tech/mcp-endpoints.docblock.js +38 -0
- package/dist/docs/tech/presentation-runtime.docblock.d.ts +6 -0
- package/dist/docs/tech/presentation-runtime.docblock.js +17 -0
- package/dist/docs/tech/schema/README.docblock.d.ts +6 -0
- package/dist/docs/tech/schema/README.docblock.js +21 -0
- package/dist/docs/tech/studio/learning-events.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/learning-events.docblock.js +49 -0
- package/dist/docs/tech/studio/learning-journeys.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/learning-journeys.docblock.js +80 -0
- package/dist/docs/tech/studio/platform-admin-panel.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/platform-admin-panel.docblock.js +85 -0
- package/dist/docs/tech/studio/project-access-teams.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/project-access-teams.docblock.js +48 -0
- package/dist/docs/tech/studio/project-routing.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/project-routing.docblock.js +68 -0
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +41 -0
- package/dist/docs/tech/studio/team-invitations.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/team-invitations.docblock.js +70 -0
- package/dist/docs/tech/studio/workspace-ops.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/workspace-ops.docblock.js +48 -0
- package/dist/docs/tech/studio/workspaces.docblock.d.ts +6 -0
- package/dist/docs/tech/studio/workspaces.docblock.js +63 -0
- package/dist/docs/tech/telemetry-ingest.docblock.d.ts +6 -0
- package/dist/docs/tech/telemetry-ingest.docblock.js +156 -0
- package/dist/docs/tech/vscode-extension.docblock.d.ts +6 -0
- package/dist/docs/tech/vscode-extension.docblock.js +102 -0
- package/dist/docs/tech-contracts.docs.d.ts +6 -0
- package/dist/docs/tech-contracts.docs.js +96 -0
- package/dist/docs/types.d.ts +41 -0
- package/dist/docs/types.js +0 -0
- package/dist/events.d.ts +47 -0
- package/dist/events.js +19 -0
- package/dist/examples/docs/examples.docblock.d.ts +6 -0
- package/dist/examples/docs/examples.docblock.js +165 -0
- package/dist/examples/index.d.ts +13 -0
- package/dist/examples/index.js +13 -0
- package/dist/examples/registry.d.ts +43 -0
- package/dist/examples/registry.js +88 -0
- package/dist/examples/schema.d.ts +282 -0
- package/dist/examples/schema.js +125 -0
- package/dist/examples/types.d.ts +167 -0
- package/dist/examples/types.js +43 -0
- package/dist/examples/validation.d.ts +65 -0
- package/dist/examples/validation.js +144 -0
- package/dist/experiments/docs/experiments.docblock.d.ts +6 -0
- package/dist/experiments/docs/experiments.docblock.js +21 -0
- package/dist/experiments/evaluator.d.ts +37 -0
- package/dist/experiments/evaluator.js +101 -0
- package/dist/experiments/spec-resolver.d.ts +17 -0
- package/dist/experiments/spec-resolver.js +0 -0
- package/dist/experiments/spec.d.ts +80 -0
- package/dist/experiments/spec.js +15 -0
- package/dist/features/index.d.ts +13 -0
- package/dist/features/index.js +12 -0
- package/dist/features/install.d.ts +22 -0
- package/dist/features/install.js +36 -0
- package/dist/features/registry.d.ts +26 -0
- package/dist/features/registry.js +49 -0
- package/dist/features/types.d.ts +88 -0
- package/dist/features/types.js +0 -0
- package/dist/features/validation.d.ts +8 -0
- package/dist/features/validation.js +14 -0
- package/dist/forms/docs/forms.docblock.d.ts +6 -0
- package/dist/forms/docs/forms.docblock.js +21 -0
- package/dist/forms/forms.d.ts +266 -0
- package/dist/forms/forms.js +143 -0
- package/dist/forms/index.d.ts +2 -0
- package/dist/forms/index.js +3 -0
- package/dist/index.d.ts +154 -0
- package/dist/index.js +132 -0
- package/dist/install.d.ts +77 -0
- package/dist/install.js +40 -0
- package/dist/integrations/binding.d.ts +17 -0
- package/dist/integrations/binding.js +0 -0
- package/dist/integrations/connection.d.ts +51 -0
- package/dist/integrations/connection.js +0 -0
- package/dist/integrations/docs/integrations.docblock.d.ts +6 -0
- package/dist/integrations/docs/integrations.docblock.js +94 -0
- package/dist/integrations/health.d.ts +21 -0
- package/dist/integrations/health.js +69 -0
- package/dist/integrations/index.d.ts +34 -0
- package/dist/integrations/index.js +23 -0
- package/dist/integrations/integrations.capability.d.ts +7 -0
- package/dist/integrations/integrations.capability.js +17 -0
- package/dist/integrations/integrations.feature.d.ts +11 -0
- package/dist/integrations/integrations.feature.js +67 -0
- package/dist/integrations/openbanking/contracts/accounts.d.ts +289 -0
- package/dist/integrations/openbanking/contracts/accounts.js +236 -0
- package/dist/integrations/openbanking/contracts/balances.d.ts +165 -0
- package/dist/integrations/openbanking/contracts/balances.js +166 -0
- package/dist/integrations/openbanking/contracts/index.d.ts +10 -0
- package/dist/integrations/openbanking/contracts/index.js +12 -0
- package/dist/integrations/openbanking/contracts/transactions.d.ts +213 -0
- package/dist/integrations/openbanking/contracts/transactions.js +217 -0
- package/dist/integrations/openbanking/guards.d.ts +12 -0
- package/dist/integrations/openbanking/guards.js +33 -0
- package/dist/integrations/openbanking/models.d.ts +228 -0
- package/dist/integrations/openbanking/models.js +240 -0
- package/dist/integrations/openbanking/openbanking.capability.d.ts +7 -0
- package/dist/integrations/openbanking/openbanking.capability.js +21 -0
- package/dist/integrations/openbanking/openbanking.feature.d.ts +11 -0
- package/dist/integrations/openbanking/openbanking.feature.js +76 -0
- package/dist/integrations/openbanking/telemetry.d.ts +15 -0
- package/dist/integrations/openbanking/telemetry.js +39 -0
- package/dist/integrations/operations.d.ts +437 -0
- package/dist/integrations/operations.js +392 -0
- package/dist/integrations/providers/calendar.d.ts +78 -0
- package/dist/integrations/providers/calendar.js +0 -0
- package/dist/integrations/providers/elevenlabs.d.ts +8 -0
- package/dist/integrations/providers/elevenlabs.js +56 -0
- package/dist/integrations/providers/email.d.ts +86 -0
- package/dist/integrations/providers/email.js +0 -0
- package/dist/integrations/providers/embedding.d.ts +24 -0
- package/dist/integrations/providers/embedding.js +0 -0
- package/dist/integrations/providers/gcs-storage.d.ts +8 -0
- package/dist/integrations/providers/gcs-storage.js +79 -0
- package/dist/integrations/providers/gmail.d.ts +8 -0
- package/dist/integrations/providers/gmail.js +91 -0
- package/dist/integrations/providers/google-calendar.d.ts +8 -0
- package/dist/integrations/providers/google-calendar.js +70 -0
- package/dist/integrations/providers/impls/elevenlabs-voice.d.ts +20 -0
- package/dist/integrations/providers/impls/elevenlabs-voice.js +95 -0
- package/dist/integrations/providers/impls/gcs-storage.d.ts +24 -0
- package/dist/integrations/providers/impls/gcs-storage.js +88 -0
- package/dist/integrations/providers/impls/gmail-inbound.d.ts +26 -0
- package/dist/integrations/providers/impls/gmail-inbound.js +200 -0
- package/dist/integrations/providers/impls/gmail-outbound.d.ts +18 -0
- package/dist/integrations/providers/impls/gmail-outbound.js +105 -0
- package/dist/integrations/providers/impls/google-calendar.d.ts +23 -0
- package/dist/integrations/providers/impls/google-calendar.js +154 -0
- package/dist/integrations/providers/impls/index.d.ts +15 -0
- package/dist/integrations/providers/impls/index.js +16 -0
- package/dist/integrations/providers/impls/mistral-embedding.d.ts +23 -0
- package/dist/integrations/providers/impls/mistral-embedding.js +41 -0
- package/dist/integrations/providers/impls/mistral-llm.d.ts +31 -0
- package/dist/integrations/providers/impls/mistral-llm.js +247 -0
- package/dist/integrations/providers/impls/postmark-email.d.ts +19 -0
- package/dist/integrations/providers/impls/postmark-email.js +55 -0
- package/dist/integrations/providers/impls/powens-client.d.ts +124 -0
- package/dist/integrations/providers/impls/powens-client.js +171 -0
- package/dist/integrations/providers/impls/powens-openbanking.d.ts +27 -0
- package/dist/integrations/providers/impls/powens-openbanking.js +218 -0
- package/dist/integrations/providers/impls/provider-factory.d.ts +26 -0
- package/dist/integrations/providers/impls/provider-factory.js +146 -0
- package/dist/integrations/providers/impls/qdrant-vector.d.ts +24 -0
- package/dist/integrations/providers/impls/qdrant-vector.js +69 -0
- package/dist/integrations/providers/impls/stripe-payments.d.ts +28 -0
- package/dist/integrations/providers/impls/stripe-payments.js +202 -0
- package/dist/integrations/providers/impls/twilio-sms.d.ts +20 -0
- package/dist/integrations/providers/impls/twilio-sms.js +58 -0
- package/dist/integrations/providers/index.d.ts +22 -0
- package/dist/integrations/providers/index.js +13 -0
- package/dist/integrations/providers/llm.d.ts +82 -0
- package/dist/integrations/providers/llm.js +0 -0
- package/dist/integrations/providers/mistral.d.ts +8 -0
- package/dist/integrations/providers/mistral.js +72 -0
- package/dist/integrations/providers/openbanking.d.ts +128 -0
- package/dist/integrations/providers/openbanking.js +0 -0
- package/dist/integrations/providers/payments.d.ts +109 -0
- package/dist/integrations/providers/payments.js +0 -0
- package/dist/integrations/providers/postmark.d.ts +8 -0
- package/dist/integrations/providers/postmark.js +72 -0
- package/dist/integrations/providers/powens.d.ts +8 -0
- package/dist/integrations/providers/powens.js +120 -0
- package/dist/integrations/providers/qdrant.d.ts +8 -0
- package/dist/integrations/providers/qdrant.js +77 -0
- package/dist/integrations/providers/registry.d.ts +11 -0
- package/dist/integrations/providers/registry.js +34 -0
- package/dist/integrations/providers/sms.d.ts +34 -0
- package/dist/integrations/providers/sms.js +0 -0
- package/dist/integrations/providers/storage.d.ts +60 -0
- package/dist/integrations/providers/storage.js +0 -0
- package/dist/integrations/providers/stripe.d.ts +8 -0
- package/dist/integrations/providers/stripe.js +87 -0
- package/dist/integrations/providers/twilio-sms.d.ts +8 -0
- package/dist/integrations/providers/twilio-sms.js +65 -0
- package/dist/integrations/providers/vector-store.d.ts +43 -0
- package/dist/integrations/providers/vector-store.js +0 -0
- package/dist/integrations/providers/voice.d.ts +34 -0
- package/dist/integrations/providers/voice.js +0 -0
- package/dist/integrations/runtime.d.ts +99 -0
- package/dist/integrations/runtime.js +186 -0
- package/dist/integrations/secrets/aws-secret-manager.d.ts +31 -0
- package/dist/integrations/secrets/aws-secret-manager.js +231 -0
- package/dist/integrations/secrets/env-secret-provider.d.ts +31 -0
- package/dist/integrations/secrets/env-secret-provider.js +81 -0
- package/dist/integrations/secrets/gcp-secret-manager.d.ts +32 -0
- package/dist/integrations/secrets/gcp-secret-manager.js +229 -0
- package/dist/integrations/secrets/index.d.ts +7 -0
- package/dist/integrations/secrets/index.js +8 -0
- package/dist/integrations/secrets/manager.d.ts +47 -0
- package/dist/integrations/secrets/manager.js +103 -0
- package/dist/integrations/secrets/provider.d.ts +52 -0
- package/dist/integrations/secrets/provider.js +58 -0
- package/dist/integrations/secrets/scaleway-secret-manager.d.ts +38 -0
- package/dist/integrations/secrets/scaleway-secret-manager.js +247 -0
- package/dist/integrations/secrets-types.d.ts +17 -0
- package/dist/integrations/secrets-types.js +0 -0
- package/dist/integrations/spec.d.ts +77 -0
- package/dist/integrations/spec.js +22 -0
- package/dist/jobs/define-job.d.ts +18 -0
- package/dist/jobs/define-job.js +16 -0
- package/dist/jobs/gcp-cloud-tasks.d.ts +41 -0
- package/dist/jobs/gcp-cloud-tasks.js +53 -0
- package/dist/jobs/gcp-pubsub.d.ts +25 -0
- package/dist/jobs/gcp-pubsub.js +39 -0
- package/dist/jobs/handlers/gmail-sync-handler.d.ts +9 -0
- package/dist/jobs/handlers/gmail-sync-handler.js +9 -0
- package/dist/jobs/handlers/index.d.ts +9 -0
- package/dist/jobs/handlers/index.js +12 -0
- package/dist/jobs/handlers/ping-handler.d.ts +10 -0
- package/dist/jobs/handlers/ping-handler.js +15 -0
- package/dist/jobs/handlers/storage-document-handler.d.ts +12 -0
- package/dist/jobs/handlers/storage-document-handler.js +14 -0
- package/dist/jobs/index.d.ts +3 -0
- package/dist/jobs/index.js +4 -0
- package/dist/jobs/memory-queue.d.ts +18 -0
- package/dist/jobs/memory-queue.js +71 -0
- package/dist/jobs/queue.d.ts +131 -0
- package/dist/jobs/queue.js +33 -0
- package/dist/jobs/scaleway-sqs-queue.d.ts +30 -0
- package/dist/jobs/scaleway-sqs-queue.js +153 -0
- package/dist/jsonschema.d.ts +42 -0
- package/dist/jsonschema.js +51 -0
- package/dist/knowledge/binding.d.ts +25 -0
- package/dist/knowledge/binding.js +0 -0
- package/dist/knowledge/docs/knowledge.docblock.d.ts +6 -0
- package/dist/knowledge/docs/knowledge.docblock.js +21 -0
- package/dist/knowledge/index.d.ts +11 -0
- package/dist/knowledge/index.js +10 -0
- package/dist/knowledge/ingestion/document-processor.d.ts +24 -0
- package/dist/knowledge/ingestion/document-processor.js +54 -0
- package/dist/knowledge/ingestion/embedding-service.d.ts +12 -0
- package/dist/knowledge/ingestion/embedding-service.js +25 -0
- package/dist/knowledge/ingestion/gmail-adapter.d.ts +18 -0
- package/dist/knowledge/ingestion/gmail-adapter.js +51 -0
- package/dist/knowledge/ingestion/index.d.ts +6 -0
- package/dist/knowledge/ingestion/index.js +7 -0
- package/dist/knowledge/ingestion/storage-adapter.d.ts +15 -0
- package/dist/knowledge/ingestion/storage-adapter.js +26 -0
- package/dist/knowledge/ingestion/vector-indexer.d.ts +18 -0
- package/dist/knowledge/ingestion/vector-indexer.js +32 -0
- package/dist/knowledge/knowledge.capability.d.ts +7 -0
- package/dist/knowledge/knowledge.capability.js +21 -0
- package/dist/knowledge/knowledge.feature.d.ts +11 -0
- package/dist/knowledge/knowledge.feature.js +68 -0
- package/dist/knowledge/operations.d.ts +318 -0
- package/dist/knowledge/operations.js +321 -0
- package/dist/knowledge/query/index.d.ts +2 -0
- package/dist/knowledge/query/index.js +3 -0
- package/dist/knowledge/query/service.d.ts +29 -0
- package/dist/knowledge/query/service.js +65 -0
- package/dist/knowledge/runtime.d.ts +32 -0
- package/dist/knowledge/runtime.js +49 -0
- package/dist/knowledge/source.d.ts +32 -0
- package/dist/knowledge/source.js +0 -0
- package/dist/knowledge/spaces/email-threads.d.ts +7 -0
- package/dist/knowledge/spaces/email-threads.js +37 -0
- package/dist/knowledge/spaces/financial-docs.d.ts +7 -0
- package/dist/knowledge/spaces/financial-docs.js +37 -0
- package/dist/knowledge/spaces/financial-overview.d.ts +7 -0
- package/dist/knowledge/spaces/financial-overview.js +41 -0
- package/dist/knowledge/spaces/index.d.ts +7 -0
- package/dist/knowledge/spaces/index.js +8 -0
- package/dist/knowledge/spaces/product-canon.d.ts +7 -0
- package/dist/knowledge/spaces/product-canon.js +37 -0
- package/dist/knowledge/spaces/support-faq.d.ts +7 -0
- package/dist/knowledge/spaces/support-faq.js +40 -0
- package/dist/knowledge/spaces/uploaded-docs.d.ts +7 -0
- package/dist/knowledge/spaces/uploaded-docs.js +37 -0
- package/dist/knowledge/spec.d.ts +46 -0
- package/dist/knowledge/spec.js +17 -0
- package/dist/llm/exporters.d.ts +70 -0
- package/dist/llm/exporters.js +542 -0
- package/dist/llm/index.d.ts +4 -0
- package/dist/llm/index.js +4 -0
- package/dist/llm/prompts.d.ts +52 -0
- package/dist/llm/prompts.js +410 -0
- package/dist/llm/types.d.ts +215 -0
- package/dist/llm/types.js +0 -0
- package/dist/markdown.d.ts +22 -0
- package/dist/markdown.js +119 -0
- package/dist/migrations.d.ts +52 -0
- package/dist/migrations.js +31 -0
- package/dist/model-registry.d.ts +13 -0
- package/dist/model-registry.js +33 -0
- package/dist/onboarding-base.d.ts +138 -0
- package/dist/onboarding-base.js +195 -0
- package/dist/openapi.d.ts +31 -0
- package/dist/openapi.js +82 -0
- package/dist/operations/index.d.ts +3 -0
- package/dist/operations/index.js +4 -0
- package/dist/operations/operation.d.ts +186 -0
- package/dist/operations/operation.js +35 -0
- package/dist/operations/registry.d.ts +54 -0
- package/dist/operations/registry.js +176 -0
- package/dist/ownership.d.ts +84 -0
- package/dist/ownership.js +38 -0
- package/dist/policy/docs/policy.docblock.d.ts +6 -0
- package/dist/policy/docs/policy.docblock.js +21 -0
- package/dist/policy/engine.d.ts +40 -0
- package/dist/policy/engine.js +225 -0
- package/dist/policy/index.d.ts +5 -0
- package/dist/policy/index.js +5 -0
- package/dist/policy/opa-adapter.d.ts +45 -0
- package/dist/policy/opa-adapter.js +71 -0
- package/dist/policy/registry.d.ts +9 -0
- package/dist/policy/registry.js +11 -0
- package/dist/policy/spec.d.ts +103 -0
- package/dist/policy/spec.js +0 -0
- package/dist/presentations/docs/presentations-conventions.docblock.d.ts +6 -0
- package/dist/presentations/docs/presentations-conventions.docblock.js +21 -0
- package/dist/presentations/index.d.ts +4 -0
- package/dist/presentations/index.js +5 -0
- package/dist/presentations/presentations.d.ts +50 -0
- package/dist/presentations/presentations.js +7 -0
- package/dist/presentations/registry.d.ts +10 -0
- package/dist/presentations/registry.js +12 -0
- package/dist/presentations/transform-engine.d.ts +66 -0
- package/dist/presentations/transform-engine.js +282 -0
- package/dist/prompt.d.ts +53 -0
- package/dist/prompt.js +10 -0
- package/dist/promptRegistry.d.ts +15 -0
- package/dist/promptRegistry.js +31 -0
- package/dist/regenerator/adapters.d.ts +19 -0
- package/dist/regenerator/adapters.js +0 -0
- package/dist/regenerator/docs/regenerator.docblock.d.ts +6 -0
- package/dist/regenerator/docs/regenerator.docblock.js +21 -0
- package/dist/regenerator/executor.d.ts +70 -0
- package/dist/regenerator/executor.js +86 -0
- package/dist/regenerator/index.d.ts +7 -0
- package/dist/regenerator/index.js +6 -0
- package/dist/regenerator/service.d.ts +33 -0
- package/dist/regenerator/service.js +93 -0
- package/dist/regenerator/sinks.d.ts +26 -0
- package/dist/regenerator/sinks.js +32 -0
- package/dist/regenerator/types.d.ts +107 -0
- package/dist/regenerator/types.js +0 -0
- package/dist/regenerator/utils.d.ts +9 -0
- package/dist/regenerator/utils.js +51 -0
- package/dist/registry-utils.d.ts +106 -0
- package/dist/registry-utils.js +122 -0
- package/dist/registry.d.ts +32 -0
- package/dist/registry.js +61 -0
- package/dist/resources.d.ts +64 -0
- package/dist/resources.js +50 -0
- package/dist/schema-to-markdown.d.ts +54 -0
- package/dist/schema-to-markdown.js +217 -0
- package/dist/server/contracts-adapter-hydration.d.ts +15 -0
- package/dist/server/contracts-adapter-hydration.js +41 -0
- package/dist/server/contracts-adapter-input.d.ts +9 -0
- package/dist/server/contracts-adapter-input.js +83 -0
- package/dist/server/graphql-pothos.d.ts +31 -0
- package/dist/server/graphql-pothos.js +134 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +10 -0
- package/dist/server/mcp/createMcpServer.d.ts +15 -0
- package/dist/server/mcp/createMcpServer.js +27 -0
- package/dist/server/mcp/mcpTypes.d.ts +27 -0
- package/dist/server/mcp/mcpTypes.js +0 -0
- package/dist/server/mcp/registerPresentations.d.ts +7 -0
- package/dist/server/mcp/registerPresentations.js +54 -0
- package/dist/server/mcp/registerPrompts.d.ts +8 -0
- package/dist/server/mcp/registerPrompts.js +41 -0
- package/dist/server/mcp/registerResources.d.ts +8 -0
- package/dist/server/mcp/registerResources.js +35 -0
- package/dist/server/mcp/registerTools.d.ts +8 -0
- package/dist/server/mcp/registerTools.js +22 -0
- package/dist/server/provider-mcp.d.ts +2 -0
- package/dist/server/provider-mcp.js +3 -0
- package/dist/server/rest-elysia.d.ts +40 -0
- package/dist/server/rest-elysia.js +20 -0
- package/dist/server/rest-express.d.ts +16 -0
- package/dist/server/rest-express.js +36 -0
- package/dist/server/rest-generic.d.ts +32 -0
- package/dist/server/rest-generic.js +124 -0
- package/dist/server/rest-next-app.d.ts +35 -0
- package/dist/server/rest-next-app.js +38 -0
- package/dist/server/rest-next-mcp.d.ts +11 -0
- package/dist/server/rest-next-mcp.js +45 -0
- package/dist/server/rest-next-pages.d.ts +9 -0
- package/dist/server/rest-next-pages.js +22 -0
- package/dist/telemetry/anomaly.d.ts +27 -0
- package/dist/telemetry/anomaly.js +48 -0
- package/dist/telemetry/docs/telemetry.docblock.d.ts +6 -0
- package/dist/telemetry/docs/telemetry.docblock.js +21 -0
- package/dist/telemetry/index.d.ts +4 -0
- package/dist/telemetry/index.js +5 -0
- package/dist/telemetry/spec.d.ts +91 -0
- package/dist/telemetry/spec.js +42 -0
- package/dist/telemetry/tracker.d.ts +51 -0
- package/dist/telemetry/tracker.js +76 -0
- package/dist/tests/index.d.ts +3 -0
- package/dist/tests/index.js +4 -0
- package/dist/tests/runner.d.ts +43 -0
- package/dist/tests/runner.js +150 -0
- package/dist/tests/spec.d.ts +82 -0
- package/dist/tests/spec.js +34 -0
- package/dist/themes.d.ts +51 -0
- package/dist/themes.js +17 -0
- package/dist/translations/catalog.d.ts +28 -0
- package/dist/translations/catalog.js +0 -0
- package/dist/translations/tenant.d.ts +15 -0
- package/dist/translations/tenant.js +0 -0
- package/dist/types.d.ts +92 -0
- package/dist/types.js +0 -0
- package/dist/versioning/index.d.ts +3 -0
- package/dist/versioning/index.js +4 -0
- package/dist/versioning/types.d.ts +127 -0
- package/dist/versioning/types.js +24 -0
- package/dist/versioning/utils.d.ts +95 -0
- package/dist/versioning/utils.js +180 -0
- package/dist/workflow/adapters/db-adapter.d.ts +46 -0
- package/dist/workflow/adapters/db-adapter.js +83 -0
- package/dist/workflow/adapters/file-adapter.d.ts +14 -0
- package/dist/workflow/adapters/file-adapter.js +11 -0
- package/dist/workflow/adapters/index.d.ts +4 -0
- package/dist/workflow/adapters/index.js +5 -0
- package/dist/workflow/adapters/memory-store.d.ts +18 -0
- package/dist/workflow/adapters/memory-store.js +58 -0
- package/dist/workflow/expression.d.ts +9 -0
- package/dist/workflow/expression.js +99 -0
- package/dist/workflow/index.d.ts +17 -0
- package/dist/workflow/index.js +16 -0
- package/dist/workflow/overview.docblock.d.ts +6 -0
- package/dist/workflow/overview.docblock.js +21 -0
- package/dist/workflow/runner.d.ts +77 -0
- package/dist/workflow/runner.js +337 -0
- package/dist/workflow/sla-monitor.d.ts +20 -0
- package/dist/workflow/sla-monitor.js +47 -0
- package/dist/workflow/spec.d.ts +93 -0
- package/dist/workflow/spec.js +11 -0
- package/dist/workflow/state.d.ts +35 -0
- package/dist/workflow/state.js +0 -0
- package/dist/workflow/validation.d.ts +29 -0
- package/dist/workflow/validation.js +176 -0
- package/dist/workspace-config/contractsrc-schema.d.ts +1162 -0
- package/dist/workspace-config/contractsrc-schema.js +421 -0
- package/dist/workspace-config/index.d.ts +2 -0
- package/dist/workspace-config/index.js +3 -0
- package/dist/workspace-config/workspace-config.docblock.d.ts +6 -0
- package/dist/workspace-config/workspace-config.docblock.js +45 -0
- package/package.json +618 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { defaultGqlField } from "../jsonschema.js";
|
|
2
|
+
import { createInputTypeBuilder } from "./contracts-adapter-input.js";
|
|
3
|
+
import { hydrateResourceIfNeeded, parseReturns } from "./contracts-adapter-hydration.js";
|
|
4
|
+
import { isSchemaModel } from "@contractspec/lib.schema";
|
|
5
|
+
import "@pothos/plugin-prisma";
|
|
6
|
+
import "@pothos/plugin-complexity";
|
|
7
|
+
import "@pothos/plugin-relay";
|
|
8
|
+
import "@pothos/plugin-dataloader";
|
|
9
|
+
import "@pothos/plugin-tracing";
|
|
10
|
+
|
|
11
|
+
//#region src/server/graphql-pothos.ts
|
|
12
|
+
/**
|
|
13
|
+
* Registers all ContractSpecs from a OperationSpecRegistry onto a Pothos SchemaBuilder.
|
|
14
|
+
*
|
|
15
|
+
* This adapter:
|
|
16
|
+
* 1. Discovers output types from specs and registers them as Pothos object types.
|
|
17
|
+
* 2. Maps `ContractSpec` (OperationSpec) inputs to Pothos input types.
|
|
18
|
+
* 3. Mounts `query` specs as `Query` fields and `command` specs as `Mutation` fields.
|
|
19
|
+
* 4. Wraps the resolver to:
|
|
20
|
+
* - Enforce auth policies (basic check).
|
|
21
|
+
* - Build a `HandlerCtx`.
|
|
22
|
+
* - Execute via `OperationSpecRegistry`.
|
|
23
|
+
* - Hydrate resource references if applicable.
|
|
24
|
+
*
|
|
25
|
+
* @param builder - The Pothos SchemaBuilder instance.
|
|
26
|
+
* @param reg - The OperationSpecRegistry containing operations.
|
|
27
|
+
* @param resources - (Optional) ResourceRegistry for hydrating resource references.
|
|
28
|
+
*/
|
|
29
|
+
function registerContractsOnBuilder(builder, reg, resources) {
|
|
30
|
+
const { buildInputFieldArgs } = createInputTypeBuilder(builder);
|
|
31
|
+
const outputTypeCache = /* @__PURE__ */ new Map();
|
|
32
|
+
for (const spec of reg.list()) {
|
|
33
|
+
const out = spec.io.output;
|
|
34
|
+
if (out && "getZod" in out && typeof out.getZod === "function") {
|
|
35
|
+
const model = out;
|
|
36
|
+
const typeName = isSchemaModel(model) ? model.config?.name : "UnknownOutput";
|
|
37
|
+
if (typeName && !outputTypeCache.has(typeName)) outputTypeCache.set(typeName, model);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
for (const [typeName, model] of outputTypeCache.entries()) {
|
|
41
|
+
if (!isSchemaModel(model)) continue;
|
|
42
|
+
builder.objectType(typeName, { fields: (t) => {
|
|
43
|
+
const entries = Object.entries(model.config.fields);
|
|
44
|
+
const acc = {};
|
|
45
|
+
for (const [key, field] of entries) {
|
|
46
|
+
const fieldType = field.type;
|
|
47
|
+
let gqlType = "JSON";
|
|
48
|
+
if (fieldType && typeof fieldType.getPothos === "function") {
|
|
49
|
+
gqlType = fieldType.getPothos().name || "JSON";
|
|
50
|
+
if (gqlType === "String_unsecure") gqlType = "String";
|
|
51
|
+
if (gqlType === "Int_unsecure") gqlType = "Int";
|
|
52
|
+
if (gqlType === "Float_unsecure") gqlType = "Float";
|
|
53
|
+
if (gqlType === "Boolean_unsecure") gqlType = "Boolean";
|
|
54
|
+
if (gqlType === "ID_unsecure") gqlType = "ID";
|
|
55
|
+
}
|
|
56
|
+
const typeRef = field.isArray ? [gqlType] : gqlType;
|
|
57
|
+
acc[key] = t.field({
|
|
58
|
+
type: typeRef,
|
|
59
|
+
nullable: field.isOptional,
|
|
60
|
+
resolve: (parent) => parent[key]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return acc;
|
|
64
|
+
} });
|
|
65
|
+
}
|
|
66
|
+
function resolveGraphQLTypeName(contractSpec) {
|
|
67
|
+
const returnsName = contractSpec.transport?.gql?.returns;
|
|
68
|
+
if (returnsName) return returnsName;
|
|
69
|
+
const out = contractSpec.io.output ?? {};
|
|
70
|
+
if (out && "kind" in out && out.kind === "resource_ref" && "graphQLType" in out && out.graphQLType) return String(out.graphQLType);
|
|
71
|
+
if (out && "getZod" in out && typeof out.getZod === "function") {
|
|
72
|
+
const model = out;
|
|
73
|
+
if (isSchemaModel(model)) {
|
|
74
|
+
const typeName = model.config?.name;
|
|
75
|
+
if (typeName && outputTypeCache.has(typeName)) return typeName;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return "JSON";
|
|
79
|
+
}
|
|
80
|
+
for (const spec of reg.list()) {
|
|
81
|
+
const fieldName = spec.transport?.gql?.field ?? defaultGqlField(spec.meta.key, spec.meta.version);
|
|
82
|
+
const byIdField = spec.transport?.gql?.byIdField ?? "id";
|
|
83
|
+
const returnsResource = spec.transport?.gql?.resource;
|
|
84
|
+
const isQuery = spec.meta.kind === "query";
|
|
85
|
+
const graphQLTypeName = resolveGraphQLTypeName(spec);
|
|
86
|
+
const returnsDecl = spec.transport?.gql?.returns;
|
|
87
|
+
const parsed = parseReturns(returnsDecl ?? graphQLTypeName);
|
|
88
|
+
const resolveFieldFn = async (_root, args, ctx) => {
|
|
89
|
+
if (spec.policy.auth !== "anonymous" && !ctx.user) throw new Error("Unauthorized");
|
|
90
|
+
const handlerCtx = {
|
|
91
|
+
traceId: ctx.logger?.getTraceId?.() ?? void 0,
|
|
92
|
+
userId: ctx.user?.id ?? null,
|
|
93
|
+
organizationId: ctx.session?.activeOrganizationId ?? null,
|
|
94
|
+
actor: ctx.user ? "user" : "anonymous",
|
|
95
|
+
channel: "web",
|
|
96
|
+
eventPublisher: ctx.eventPublisher
|
|
97
|
+
};
|
|
98
|
+
const parsedInput = spec.io.input?.getZod().parse(args.input ?? {});
|
|
99
|
+
const result = await reg.execute(spec.meta.key, spec.meta.version, parsedInput, handlerCtx);
|
|
100
|
+
const out = spec.io.output;
|
|
101
|
+
if (resources && (returnsResource || out?.kind === "resource_ref")) {
|
|
102
|
+
const varName = byIdField ?? out?.varName ?? "id";
|
|
103
|
+
const hydrated = await hydrateResourceIfNeeded(resources, result, {
|
|
104
|
+
template: returnsResource ?? out?.uriTemplate,
|
|
105
|
+
varName,
|
|
106
|
+
returns: parsed
|
|
107
|
+
});
|
|
108
|
+
if (hydrated !== result) return hydrated;
|
|
109
|
+
}
|
|
110
|
+
if (graphQLTypeName) {
|
|
111
|
+
if (parsed.inner === "Boolean" && !parsed.isList) return Boolean(result?.ok ?? result);
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
return spec.io.output.getZod().parse(result);
|
|
115
|
+
};
|
|
116
|
+
const fieldSettingsFn = (t) => {
|
|
117
|
+
const inputType = buildInputFieldArgs(spec.io.input);
|
|
118
|
+
return t.field({
|
|
119
|
+
type: parsed.isList ? [parsed.inner] : parsed.inner,
|
|
120
|
+
complexity: () => 10,
|
|
121
|
+
resolve: resolveFieldFn,
|
|
122
|
+
args: inputType ? { input: t.arg({
|
|
123
|
+
type: inputType,
|
|
124
|
+
required: true
|
|
125
|
+
}) } : void 0
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
if (isQuery) builder.queryField(fieldName, fieldSettingsFn);
|
|
129
|
+
else builder.mutationField(fieldName, fieldSettingsFn);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
export { registerContractsOnBuilder };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { registerContractsOnBuilder } from "./graphql-pothos.js";
|
|
2
|
+
import { createMcpServer } from "./mcp/createMcpServer.js";
|
|
3
|
+
import "./provider-mcp.js";
|
|
4
|
+
import { RestOptions, createFetchHandler } from "./rest-generic.js";
|
|
5
|
+
import { elysiaPlugin } from "./rest-elysia.js";
|
|
6
|
+
import { expressRouter } from "./rest-express.js";
|
|
7
|
+
import { makeNextAppHandler } from "./rest-next-app.js";
|
|
8
|
+
import { makeNextPagesHandler } from "./rest-next-pages.js";
|
|
9
|
+
export { RestOptions, createFetchHandler, createMcpServer, elysiaPlugin, expressRouter, makeNextAppHandler, makeNextPagesHandler, registerContractsOnBuilder };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { registerContractsOnBuilder } from "./graphql-pothos.js";
|
|
2
|
+
import { createMcpServer } from "./mcp/createMcpServer.js";
|
|
3
|
+
import "./provider-mcp.js";
|
|
4
|
+
import { createFetchHandler } from "./rest-generic.js";
|
|
5
|
+
import { elysiaPlugin } from "./rest-elysia.js";
|
|
6
|
+
import { expressRouter } from "./rest-express.js";
|
|
7
|
+
import { makeNextAppHandler } from "./rest-next-app.js";
|
|
8
|
+
import { makeNextPagesHandler } from "./rest-next-pages.js";
|
|
9
|
+
|
|
10
|
+
export { createFetchHandler, createMcpServer, elysiaPlugin, expressRouter, makeNextAppHandler, makeNextPagesHandler, registerContractsOnBuilder };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ResourceRegistry } from "../../resources.js";
|
|
2
|
+
import { OperationSpecRegistry } from "../../operations/registry.js";
|
|
3
|
+
import { PromptRegistry } from "../../promptRegistry.js";
|
|
4
|
+
import { McpCtxFactories } from "./mcpTypes.js";
|
|
5
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
|
|
7
|
+
//#region src/server/mcp/createMcpServer.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a unified Model Context Protocol (MCP) server exposing operations, resources, prompts,
|
|
11
|
+
* and (optionally) presentations.\n+ *
|
|
12
|
+
* ContractSpec exposes:\n+ * - Tools: `command` operations from `OperationSpecRegistry`.\n+ * - Resources: templates from `ResourceRegistry`.\n+ * - Prompts: templates from `PromptRegistry`.\n+ * - Presentations: V1 registry and/or V2 descriptors as read-only resources.\n+ */
|
|
13
|
+
declare function createMcpServer(server: McpServer, ops: OperationSpecRegistry, resources: ResourceRegistry, prompts: PromptRegistry, ctxFactories: McpCtxFactories): McpServer;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { createMcpServer };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { registerMcpTools } from "./registerTools.js";
|
|
2
|
+
import { registerMcpResources } from "./registerResources.js";
|
|
3
|
+
import { registerMcpPrompts } from "./registerPrompts.js";
|
|
4
|
+
import { registerMcpPresentations } from "./registerPresentations.js";
|
|
5
|
+
|
|
6
|
+
//#region src/server/mcp/createMcpServer.ts
|
|
7
|
+
/**
|
|
8
|
+
* Creates a unified Model Context Protocol (MCP) server exposing operations, resources, prompts,
|
|
9
|
+
* and (optionally) presentations.\n+ *
|
|
10
|
+
* ContractSpec exposes:\n+ * - Tools: `command` operations from `OperationSpecRegistry`.\n+ * - Resources: templates from `ResourceRegistry`.\n+ * - Prompts: templates from `PromptRegistry`.\n+ * - Presentations: V1 registry and/or V2 descriptors as read-only resources.\n+ */
|
|
11
|
+
function createMcpServer(server, ops, resources, prompts, ctxFactories) {
|
|
12
|
+
ctxFactories.logger.debug("Creating MCP server");
|
|
13
|
+
registerMcpTools(server, ops, { toolCtx: ctxFactories.toolCtx });
|
|
14
|
+
registerMcpResources(server, resources, {
|
|
15
|
+
logger: ctxFactories.logger,
|
|
16
|
+
resourceCtx: ctxFactories.resourceCtx
|
|
17
|
+
});
|
|
18
|
+
registerMcpPresentations(server, {
|
|
19
|
+
logger: ctxFactories.logger,
|
|
20
|
+
presentations: ctxFactories.presentations
|
|
21
|
+
});
|
|
22
|
+
registerMcpPrompts(server, prompts, { promptCtx: ctxFactories.promptCtx });
|
|
23
|
+
return server;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { createMcpServer };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PresentationRegistry } from "../../presentations/registry.js";
|
|
2
|
+
import "../../presentations/index.js";
|
|
3
|
+
import { HandlerCtx } from "../../types.js";
|
|
4
|
+
import { Logger } from "@contractspec/lib.logger";
|
|
5
|
+
|
|
6
|
+
//#region src/server/mcp/mcpTypes.d.ts
|
|
7
|
+
interface McpCtxFactories {
|
|
8
|
+
logger: Logger;
|
|
9
|
+
/** Factory for tool execution context (e.g., system actor) */
|
|
10
|
+
toolCtx: () => HandlerCtx;
|
|
11
|
+
/** Factory for prompt rendering context */
|
|
12
|
+
promptCtx: () => {
|
|
13
|
+
userId?: string | null;
|
|
14
|
+
orgId?: string | null;
|
|
15
|
+
locale?: string;
|
|
16
|
+
};
|
|
17
|
+
/** Factory for resource resolution context */
|
|
18
|
+
resourceCtx: () => {
|
|
19
|
+
userId?: string | null;
|
|
20
|
+
orgId?: string | null;
|
|
21
|
+
locale?: string;
|
|
22
|
+
};
|
|
23
|
+
/** Optional registry for presentations */
|
|
24
|
+
presentations?: PresentationRegistry;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { McpCtxFactories };
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { McpCtxFactories } from "./mcpTypes.js";
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
|
|
4
|
+
//#region src/server/mcp/registerPresentations.d.ts
|
|
5
|
+
declare function registerMcpPresentations(server: McpServer, ctx: Pick<McpCtxFactories, 'logger' | 'presentations'>): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { registerMcpPresentations };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createDefaultTransformEngine, registerBasicValidation, registerDefaultReactRenderer } from "../../presentations/transform-engine.js";
|
|
2
|
+
import "../../presentations/index.js";
|
|
3
|
+
import { sanitizeMcpName } from "../../jsonschema.js";
|
|
4
|
+
|
|
5
|
+
//#region src/server/mcp/registerPresentations.ts
|
|
6
|
+
function isEngineRenderOutput(x) {
|
|
7
|
+
if (!x || typeof x !== "object") return false;
|
|
8
|
+
return "body" in x && typeof x.body === "string";
|
|
9
|
+
}
|
|
10
|
+
function registerMcpPresentations(server, ctx) {
|
|
11
|
+
if (!ctx.presentations?.count()) return;
|
|
12
|
+
const engine = registerBasicValidation(registerDefaultReactRenderer(createDefaultTransformEngine()));
|
|
13
|
+
for (const presentationSpec of ctx.presentations.list()) {
|
|
14
|
+
const baseKey = sanitizeMcpName(`presentation_${presentationSpec.meta.key}_v${presentationSpec.meta.version}`);
|
|
15
|
+
const baseUri = `presentation://${presentationSpec.meta.key}/v${presentationSpec.meta.version}`;
|
|
16
|
+
ctx.logger.debug(`Registering presentation ${baseUri} for ${baseKey}`);
|
|
17
|
+
server.registerResource(baseKey, baseUri, {
|
|
18
|
+
title: `${presentationSpec.meta.key} v${presentationSpec.meta.version}`,
|
|
19
|
+
description: presentationSpec.meta.description ?? "Presentation",
|
|
20
|
+
mimeType: "application/json"
|
|
21
|
+
}, async () => {
|
|
22
|
+
return { contents: [{
|
|
23
|
+
uri: baseUri,
|
|
24
|
+
mimeType: "application/json",
|
|
25
|
+
text: JSON.stringify({
|
|
26
|
+
meta: presentationSpec.meta,
|
|
27
|
+
source: presentationSpec.source,
|
|
28
|
+
targets: presentationSpec.targets
|
|
29
|
+
}, null, 2)
|
|
30
|
+
}] };
|
|
31
|
+
});
|
|
32
|
+
for (const v of [{
|
|
33
|
+
ext: ".md",
|
|
34
|
+
target: "markdown"
|
|
35
|
+
}]) {
|
|
36
|
+
const key = `${baseKey}${v.ext}`;
|
|
37
|
+
const uri = `${baseUri}${v.ext}`;
|
|
38
|
+
server.registerResource(key, uri, {
|
|
39
|
+
title: `${presentationSpec.meta.key} v${presentationSpec.meta.version} (${v.ext})`,
|
|
40
|
+
description: `${presentationSpec.meta.description ?? "Presentation"} (${v.ext})`
|
|
41
|
+
}, async () => {
|
|
42
|
+
const out = await engine.render(v.target, presentationSpec);
|
|
43
|
+
return { contents: [{
|
|
44
|
+
uri,
|
|
45
|
+
mimeType: isEngineRenderOutput(out) && out.mimeType ? out.mimeType : v.target === "markdown" ? "text/markdown" : v.target,
|
|
46
|
+
text: isEngineRenderOutput(out) && typeof out.body === "string" ? out.body : String(out)
|
|
47
|
+
}] };
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { registerMcpPresentations };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PromptRegistry } from "../../promptRegistry.js";
|
|
2
|
+
import { McpCtxFactories } from "./mcpTypes.js";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
|
|
5
|
+
//#region src/server/mcp/registerPrompts.d.ts
|
|
6
|
+
declare function registerMcpPrompts(server: McpServer, prompts: PromptRegistry, ctx: Pick<McpCtxFactories, 'promptCtx'>): void;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { registerMcpPrompts };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defaultMcpPrompt } from "../../jsonschema.js";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/server/mcp/registerPrompts.ts
|
|
5
|
+
function promptArgsSchemaFromPromptArgs(args) {
|
|
6
|
+
const shape = {};
|
|
7
|
+
for (const a of args) shape[a.name] = a.schema;
|
|
8
|
+
return shape;
|
|
9
|
+
}
|
|
10
|
+
function registerMcpPrompts(server, prompts, ctx) {
|
|
11
|
+
for (const prompt of prompts.list()) {
|
|
12
|
+
const promptName = defaultMcpPrompt(prompt.meta.key);
|
|
13
|
+
server.registerPrompt(promptName, {
|
|
14
|
+
title: prompt.meta.title,
|
|
15
|
+
description: prompt.meta.description,
|
|
16
|
+
argsSchema: promptArgsSchemaFromPromptArgs(prompt.args)
|
|
17
|
+
}, async (args) => {
|
|
18
|
+
const link = (tpl, vars) => {
|
|
19
|
+
let out = tpl;
|
|
20
|
+
for (const [k, v] of Object.entries(vars)) out = out.replace(new RegExp(`\\{${k}\\}`, "g"), encodeURIComponent(String(v)));
|
|
21
|
+
return out;
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
messages: [{
|
|
25
|
+
role: "assistant",
|
|
26
|
+
content: {
|
|
27
|
+
type: "text",
|
|
28
|
+
text: (await prompt.render(prompt.input.parse(args), {
|
|
29
|
+
...ctx.promptCtx(),
|
|
30
|
+
link
|
|
31
|
+
})).map((p) => p.type === "text" ? p.text : `See resource: ${p.title ?? p.uri}\nURI: ${p.uri}`).join("\n\n")
|
|
32
|
+
}
|
|
33
|
+
}],
|
|
34
|
+
description: prompt.meta.description
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { registerMcpPrompts };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResourceRegistry } from "../../resources.js";
|
|
2
|
+
import { McpCtxFactories } from "./mcpTypes.js";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
|
|
5
|
+
//#region src/server/mcp/registerResources.d.ts
|
|
6
|
+
declare function registerMcpResources(server: McpServer, resources: ResourceRegistry, ctx: Pick<McpCtxFactories, 'logger' | 'resourceCtx'>): void;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { registerMcpResources };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { Buffer } from "node:buffer";
|
|
3
|
+
|
|
4
|
+
//#region src/server/mcp/registerResources.ts
|
|
5
|
+
function mcpResourceMeta(resource) {
|
|
6
|
+
return {
|
|
7
|
+
title: resource.meta.title,
|
|
8
|
+
description: resource.meta.description,
|
|
9
|
+
mimeType: resource.meta.mimeType,
|
|
10
|
+
_meta: { tags: resource.meta.tags ?? [] }
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function registerMcpResources(server, resources, ctx) {
|
|
14
|
+
for (const resource of resources.listTemplates()) {
|
|
15
|
+
ctx.logger.debug("Registering resource: " + resource.meta.uriTemplate);
|
|
16
|
+
server.registerResource(resource.meta.uriTemplate, new ResourceTemplate(resource.meta.uriTemplate, { list: void 0 }), mcpResourceMeta(resource), async (_uri, variables) => {
|
|
17
|
+
const parsedArgs = resource.input.parse(variables);
|
|
18
|
+
const out = await resource.resolve(parsedArgs, ctx.resourceCtx());
|
|
19
|
+
if (typeof out.data === "string") return { contents: [{
|
|
20
|
+
uri: out.uri,
|
|
21
|
+
mimeType: out.mimeType ?? resource.meta.mimeType,
|
|
22
|
+
text: out.data
|
|
23
|
+
}] };
|
|
24
|
+
return { contents: [{
|
|
25
|
+
uri: out.uri,
|
|
26
|
+
mimeType: out.mimeType ?? resource.meta.mimeType,
|
|
27
|
+
blob: Buffer.from(out.data).toString("base64")
|
|
28
|
+
}] };
|
|
29
|
+
});
|
|
30
|
+
ctx.logger.debug("Registered resource: " + resource.meta.uriTemplate);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { registerMcpResources };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OperationSpecRegistry } from "../../operations/registry.js";
|
|
2
|
+
import { McpCtxFactories } from "./mcpTypes.js";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
|
|
5
|
+
//#region src/server/mcp/registerTools.d.ts
|
|
6
|
+
declare function registerMcpTools(server: McpServer, ops: OperationSpecRegistry, ctx: Pick<McpCtxFactories, 'toolCtx'>): void;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { registerMcpTools };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defaultMcpTool } from "../../jsonschema.js";
|
|
2
|
+
|
|
3
|
+
//#region src/server/mcp/registerTools.ts
|
|
4
|
+
function registerMcpTools(server, ops, ctx) {
|
|
5
|
+
for (const spec of ops.list()) {
|
|
6
|
+
if (spec.meta.kind !== "command") continue;
|
|
7
|
+
const toolName = spec.transport?.mcp?.toolName ?? defaultMcpTool(spec.meta.key, spec.meta.version);
|
|
8
|
+
server.registerTool(toolName, {
|
|
9
|
+
description: spec.meta.description,
|
|
10
|
+
inputSchema: spec.io.input?.getZod()
|
|
11
|
+
}, async (args) => {
|
|
12
|
+
const result = await ops.execute(spec.meta.key, spec.meta.version, args ?? {}, ctx.toolCtx());
|
|
13
|
+
return { content: [{
|
|
14
|
+
type: "text",
|
|
15
|
+
text: JSON.stringify(result, null, 4)
|
|
16
|
+
}] };
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { registerMcpTools };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { OperationSpecRegistry } from "../operations/registry.js";
|
|
2
|
+
import { HandlerCtx } from "../types.js";
|
|
3
|
+
import { RestOptions } from "./rest-generic.js";
|
|
4
|
+
import { Elysia } from "elysia";
|
|
5
|
+
|
|
6
|
+
//#region src/server/rest-elysia.d.ts
|
|
7
|
+
/** Mount routes on an Elysia instance */
|
|
8
|
+
declare function elysiaPlugin(app: Elysia, reg: OperationSpecRegistry, ctxFactory: (c: {
|
|
9
|
+
request: Request;
|
|
10
|
+
store: unknown;
|
|
11
|
+
}) => HandlerCtx, options?: RestOptions): Elysia<"", {
|
|
12
|
+
decorator: {};
|
|
13
|
+
store: {};
|
|
14
|
+
derive: {};
|
|
15
|
+
resolve: {};
|
|
16
|
+
}, {
|
|
17
|
+
typebox: {};
|
|
18
|
+
error: {};
|
|
19
|
+
}, {
|
|
20
|
+
schema: {};
|
|
21
|
+
standaloneSchema: {};
|
|
22
|
+
macro: {};
|
|
23
|
+
macroFn: {};
|
|
24
|
+
parser: {};
|
|
25
|
+
response: {};
|
|
26
|
+
}, {}, {
|
|
27
|
+
derive: {};
|
|
28
|
+
resolve: {};
|
|
29
|
+
schema: {};
|
|
30
|
+
standaloneSchema: {};
|
|
31
|
+
response: {};
|
|
32
|
+
}, {
|
|
33
|
+
derive: {};
|
|
34
|
+
resolve: {};
|
|
35
|
+
schema: {};
|
|
36
|
+
standaloneSchema: {};
|
|
37
|
+
response: {};
|
|
38
|
+
}>;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { elysiaPlugin };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createFetchHandler } from "./rest-generic.js";
|
|
2
|
+
|
|
3
|
+
//#region src/server/rest-elysia.ts
|
|
4
|
+
/** Mount routes on an Elysia instance */
|
|
5
|
+
function elysiaPlugin(app, reg, ctxFactory, options) {
|
|
6
|
+
const handler = createFetchHandler(reg, (req) => ctxFactory({
|
|
7
|
+
request: req,
|
|
8
|
+
store: app.store
|
|
9
|
+
}), options);
|
|
10
|
+
for (const spec of reg.list()) {
|
|
11
|
+
const method = spec.transport?.rest?.method ?? (spec.meta.kind === "query" ? "GET" : "POST");
|
|
12
|
+
const path = (options?.basePath ?? "") + (spec.transport?.rest?.path ?? `/${spec.meta.key.replace(/\./g, "/")}/v${spec.meta.version}`);
|
|
13
|
+
app[method.toLowerCase()](path, ({ request }) => handler(request));
|
|
14
|
+
}
|
|
15
|
+
if (options?.cors) app.options("*", ({ request }) => handler(request));
|
|
16
|
+
return app;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { elysiaPlugin };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OperationSpecRegistry } from "../operations/registry.js";
|
|
2
|
+
import { HandlerCtx } from "../types.js";
|
|
3
|
+
import { RestOptions } from "./rest-generic.js";
|
|
4
|
+
import { Request, Router } from "express";
|
|
5
|
+
|
|
6
|
+
//#region src/server/rest-express.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Build an Express Router that proxies to the Fetch-style handler.
|
|
10
|
+
* You can mount it at any base path; pass the same basePath in options.
|
|
11
|
+
*/
|
|
12
|
+
declare function expressRouter(express: {
|
|
13
|
+
Router: () => Router;
|
|
14
|
+
}, reg: OperationSpecRegistry, ctxFactory: (req: Request) => HandlerCtx, options?: RestOptions): Router;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { expressRouter };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createFetchHandler } from "./rest-generic.js";
|
|
2
|
+
|
|
3
|
+
//#region src/server/rest-express.ts
|
|
4
|
+
/**
|
|
5
|
+
* Build an Express Router that proxies to the Fetch-style handler.
|
|
6
|
+
* You can mount it at any base path; pass the same basePath in options.
|
|
7
|
+
*/
|
|
8
|
+
function expressRouter(express, reg, ctxFactory, options) {
|
|
9
|
+
const router = express.Router();
|
|
10
|
+
for (const spec of reg.list()) {
|
|
11
|
+
const method = spec.transport?.rest?.method ?? (spec.meta.kind === "query" ? "GET" : "POST");
|
|
12
|
+
const path = (options?.basePath ?? "") + (spec.transport?.rest?.path ?? `/${spec.meta.key.replace(/\./g, "/")}/v${spec.meta.version}`);
|
|
13
|
+
router[method.toLowerCase()](path, async (req, res) => {
|
|
14
|
+
const url = new URL(`${req.protocol}://${req.get("host")}${req.originalUrl}`);
|
|
15
|
+
const request = new Request(url.toString(), {
|
|
16
|
+
method,
|
|
17
|
+
headers: Object.fromEntries(Object.entries(req.headers).map(([k, v]) => [k, String(v)])),
|
|
18
|
+
body: method === "POST" ? JSON.stringify(req.body ?? {}) : void 0
|
|
19
|
+
});
|
|
20
|
+
const response = await createFetchHandler(reg, () => ctxFactory(req), options)(request);
|
|
21
|
+
res.status(response.status);
|
|
22
|
+
response.headers.forEach((v, k) => res.setHeader(k, v));
|
|
23
|
+
const text = await response.text();
|
|
24
|
+
res.send(text);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (options?.cors) router.options("*", (_req, res) => {
|
|
28
|
+
const h = new Headers();
|
|
29
|
+
new Response(null, { status: 204 }).headers.forEach((v, k) => h.set(k, v));
|
|
30
|
+
res.status(204).send();
|
|
31
|
+
});
|
|
32
|
+
return router;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { expressRouter };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { OperationSpecRegistry } from "../operations/registry.js";
|
|
2
|
+
import { HandlerCtx } from "../types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/server/rest-generic.d.ts
|
|
5
|
+
interface RestOptions {
|
|
6
|
+
/** Prefix all routes, e.g. "/api" */
|
|
7
|
+
basePath?: string;
|
|
8
|
+
/** If true, handle OPTIONS and set CORS headers */
|
|
9
|
+
cors?: boolean | {
|
|
10
|
+
origin?: string | '*';
|
|
11
|
+
methods?: string[];
|
|
12
|
+
headers?: string[];
|
|
13
|
+
credentials?: boolean;
|
|
14
|
+
maxAge?: number;
|
|
15
|
+
};
|
|
16
|
+
/** JSON spacing in responses (dev only ideally) */
|
|
17
|
+
prettyJson?: number | false;
|
|
18
|
+
/** Map thrown errors to {status, body} */
|
|
19
|
+
onError?: (err: unknown) => {
|
|
20
|
+
status: number;
|
|
21
|
+
body: unknown;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build a single Fetch-style handler: (req) => Response
|
|
26
|
+
* - Discovers routes from OperationSpecRegistry
|
|
27
|
+
* - Validates with zod via registry.execute()
|
|
28
|
+
* - Handles CORS (optional)
|
|
29
|
+
*/
|
|
30
|
+
declare function createFetchHandler(reg: OperationSpecRegistry, ctxFactory: (req: Request) => HandlerCtx, options?: RestOptions): (req: Request) => Promise<Response>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { RestOptions, createFetchHandler };
|