@contractspec/lib.contracts 1.44.0
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.feature.d.ts +12 -0
- package/dist/app-config/app-config.feature.js +54 -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 +9 -0
- package/dist/app-config/index.js +8 -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 +173 -0
- package/dist/app-config/spec.js +36 -0
- package/dist/app-config/validation.d.ts +49 -0
- package/dist/app-config/validation.js +538 -0
- package/dist/capabilities/capabilities.d.ts +48 -0
- package/dist/capabilities/capabilities.js +50 -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 +298 -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 +4 -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 +51 -0
- package/dist/data-views/registry.js +82 -0
- package/dist/data-views/runtime.d.ts +28 -0
- package/dist/data-views/runtime.js +39 -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 +29 -0
- package/dist/docs/meta.docs.d.ts +6 -0
- package/dist/docs/meta.docs.js +29 -0
- package/dist/docs/presentations.d.ts +33 -0
- package/dist/docs/presentations.js +64 -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/contracts/README.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/README.docblock.js +21 -0
- package/dist/docs/tech/contracts/create-subscription.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/create-subscription.docblock.js +21 -0
- package/dist/docs/tech/contracts/graphql-typed-outputs.docblock.d.ts +6 -0
- package/dist/docs/tech/contracts/graphql-typed-outputs.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 +21 -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 +46 -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/templates/runtime.docblock.d.ts +6 -0
- package/dist/docs/tech/templates/runtime.docblock.js +21 -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/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 +82 -0
- package/dist/experiments/spec.js +33 -0
- package/dist/features/index.d.ts +5 -0
- package/dist/features/index.js +5 -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 +146 -0
- package/dist/forms/index.d.ts +2 -0
- package/dist/forms/index.js +3 -0
- package/dist/index.d.ts +147 -0
- package/dist/index.js +121 -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.feature.d.ts +12 -0
- package/dist/integrations/integrations.feature.js +60 -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.feature.d.ts +12 -0
- package/dist/integrations/openbanking/openbanking.feature.js +69 -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 +7 -0
- package/dist/integrations/providers/elevenlabs.js +55 -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 +7 -0
- package/dist/integrations/providers/gcs-storage.js +78 -0
- package/dist/integrations/providers/gmail.d.ts +7 -0
- package/dist/integrations/providers/gmail.js +90 -0
- package/dist/integrations/providers/google-calendar.d.ts +7 -0
- package/dist/integrations/providers/google-calendar.js +69 -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 +145 -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 +7 -0
- package/dist/integrations/providers/mistral.js +71 -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 +7 -0
- package/dist/integrations/providers/postmark.js +71 -0
- package/dist/integrations/providers/powens.d.ts +7 -0
- package/dist/integrations/providers/powens.js +119 -0
- package/dist/integrations/providers/qdrant.d.ts +7 -0
- package/dist/integrations/providers/qdrant.js +76 -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 +7 -0
- package/dist/integrations/providers/stripe.js +86 -0
- package/dist/integrations/providers/twilio-sms.d.ts +7 -0
- package/dist/integrations/providers/twilio-sms.js +64 -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 +75 -0
- package/dist/integrations/spec.js +39 -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 +27 -0
- package/dist/jsonschema.js +32 -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.feature.d.ts +12 -0
- package/dist/knowledge/knowledge.feature.js +61 -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 +48 -0
- package/dist/knowledge/spec.js +39 -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 +33 -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 +75 -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 +103 -0
- package/dist/operations/registry.js +252 -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 +223 -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 +60 -0
- package/dist/prompt.js +10 -0
- package/dist/promptRegistry.d.ts +15 -0
- package/dist/promptRegistry.js +34 -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 +31 -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 +63 -0
- package/dist/server/mcp/registerPrompts.d.ts +8 -0
- package/dist/server/mcp/registerPrompts.js +37 -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 +69 -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 +81 -0
- package/dist/tests/spec.js +33 -0
- package/dist/themes.d.ts +53 -0
- package/dist/themes.js +39 -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/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 +10 -0
- package/dist/workflow/index.js +9 -0
- package/dist/workflow/overview.docblock.d.ts +6 -0
- package/dist/workflow/overview.docblock.js +21 -0
- package/dist/workflow/runner.d.ts +75 -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 +106 -0
- package/dist/workflow/spec.js +55 -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 +862 -0
- package/dist/workspace-config/contractsrc-schema.js +281 -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 +598 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { evaluateExpression } from "./expression.js";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
|
|
4
|
+
//#region src/workflow/runner.ts
|
|
5
|
+
var WorkflowRunner = class {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async preFlightCheck(workflowName, version, resolvedConfig) {
|
|
10
|
+
const spec = this.getSpec(workflowName, version);
|
|
11
|
+
return this.performPreFlight(spec, resolvedConfig);
|
|
12
|
+
}
|
|
13
|
+
async start(workflowName, version, initialData) {
|
|
14
|
+
const spec = this.getSpec(workflowName, version);
|
|
15
|
+
const entryStepId = resolveEntryStepId(spec);
|
|
16
|
+
const now = /* @__PURE__ */ new Date();
|
|
17
|
+
const workflowId = randomUUID();
|
|
18
|
+
const state = {
|
|
19
|
+
workflowId,
|
|
20
|
+
workflowName: spec.meta.key,
|
|
21
|
+
workflowVersion: spec.meta.version,
|
|
22
|
+
currentStep: entryStepId,
|
|
23
|
+
data: { ...initialData ?? {} },
|
|
24
|
+
retryCounts: {},
|
|
25
|
+
history: [],
|
|
26
|
+
status: "running",
|
|
27
|
+
createdAt: now,
|
|
28
|
+
updatedAt: now
|
|
29
|
+
};
|
|
30
|
+
const resolvedAppConfig = this.config.appConfigProvider ? await this.config.appConfigProvider(state) : void 0;
|
|
31
|
+
const preFlightResult = await this.performPreFlight(spec, resolvedAppConfig);
|
|
32
|
+
if (!preFlightResult.canStart) throw new WorkflowPreFlightError(preFlightResult.issues);
|
|
33
|
+
await this.config.stateStore.create(state);
|
|
34
|
+
this.emit("workflow.started", {
|
|
35
|
+
workflowId,
|
|
36
|
+
workflowName: spec.meta.key,
|
|
37
|
+
workflowVersion: spec.meta.version,
|
|
38
|
+
currentStep: entryStepId
|
|
39
|
+
});
|
|
40
|
+
return workflowId;
|
|
41
|
+
}
|
|
42
|
+
async executeStep(workflowId, input) {
|
|
43
|
+
const state = await this.getStateOrThrow(workflowId);
|
|
44
|
+
if (isTerminalStatus(state.status)) throw new Error(`Workflow ${workflowId} is in terminal status "${state.status}".`);
|
|
45
|
+
const spec = this.getSpec(state.workflowName, state.workflowVersion);
|
|
46
|
+
const step = getCurrentStep(spec, state.currentStep);
|
|
47
|
+
if (!await this.evaluateGuard(step, state, input)) throw new Error(`GuardRejected: ${state.workflowName} -> ${step.id}`);
|
|
48
|
+
const execution = {
|
|
49
|
+
stepId: step.id,
|
|
50
|
+
startedAt: /* @__PURE__ */ new Date(),
|
|
51
|
+
status: "running",
|
|
52
|
+
input
|
|
53
|
+
};
|
|
54
|
+
const workingState = {
|
|
55
|
+
...state,
|
|
56
|
+
data: { ...state.data },
|
|
57
|
+
history: [...state.history]
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
const output = await this.runStepAction(step, workingState, input);
|
|
61
|
+
execution.output = output;
|
|
62
|
+
execution.status = "completed";
|
|
63
|
+
execution.completedAt = /* @__PURE__ */ new Date();
|
|
64
|
+
workingState.history.push(execution);
|
|
65
|
+
workingState.updatedAt = /* @__PURE__ */ new Date();
|
|
66
|
+
if (isRecord(input)) workingState.data = {
|
|
67
|
+
...workingState.data,
|
|
68
|
+
...input
|
|
69
|
+
};
|
|
70
|
+
if (isRecord(output)) workingState.data = {
|
|
71
|
+
...workingState.data,
|
|
72
|
+
...output
|
|
73
|
+
};
|
|
74
|
+
const nextStepId = this.pickNextStepId(spec, workingState, step, input, output);
|
|
75
|
+
if (nextStepId) {
|
|
76
|
+
workingState.currentStep = nextStepId;
|
|
77
|
+
workingState.status = "running";
|
|
78
|
+
} else if (!hasOutgoing(spec, step.id)) workingState.status = "completed";
|
|
79
|
+
else throw new Error(`No transition matched after executing step "${step.id}".`);
|
|
80
|
+
await this.config.stateStore.update(workflowId, () => workingState);
|
|
81
|
+
this.emit("workflow.step_completed", {
|
|
82
|
+
workflowId,
|
|
83
|
+
workflowName: state.workflowName,
|
|
84
|
+
stepId: step.id,
|
|
85
|
+
status: workingState.status
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
execution.status = "failed";
|
|
89
|
+
execution.completedAt = /* @__PURE__ */ new Date();
|
|
90
|
+
execution.error = error instanceof Error ? error.message : String(error);
|
|
91
|
+
workingState.history.push(execution);
|
|
92
|
+
workingState.updatedAt = /* @__PURE__ */ new Date();
|
|
93
|
+
if (step.retry) {
|
|
94
|
+
const retries = state.retryCounts?.[step.id] ?? 0;
|
|
95
|
+
if (retries < step.retry.maxAttempts) {
|
|
96
|
+
const backoff = step.retry.backoff ?? "exponential";
|
|
97
|
+
const baseDelay = step.retry.delayMs ?? 1e3;
|
|
98
|
+
const delay = backoff === "exponential" ? baseDelay * Math.pow(2, retries) : baseDelay;
|
|
99
|
+
const cappedDelay = Math.min(delay, step.retry.maxDelayMs ?? Infinity);
|
|
100
|
+
workingState.retryCounts = {
|
|
101
|
+
...state.retryCounts ?? {},
|
|
102
|
+
[step.id]: retries + 1
|
|
103
|
+
};
|
|
104
|
+
workingState.status = "running";
|
|
105
|
+
await this.config.stateStore.update(workflowId, () => workingState);
|
|
106
|
+
this.emit("workflow.step_retrying", {
|
|
107
|
+
workflowId,
|
|
108
|
+
workflowName: state.workflowName,
|
|
109
|
+
stepId: step.id,
|
|
110
|
+
attempt: retries + 1,
|
|
111
|
+
delay: cappedDelay,
|
|
112
|
+
error: execution.error
|
|
113
|
+
});
|
|
114
|
+
await new Promise((resolve) => setTimeout(resolve, cappedDelay));
|
|
115
|
+
return this.executeStep(workflowId, input);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
workingState.status = "failed";
|
|
119
|
+
await this.config.stateStore.update(workflowId, () => workingState);
|
|
120
|
+
this.emit("workflow.step_failed", {
|
|
121
|
+
workflowId,
|
|
122
|
+
workflowName: state.workflowName,
|
|
123
|
+
stepId: step.id,
|
|
124
|
+
error: execution.error ?? "unknown"
|
|
125
|
+
});
|
|
126
|
+
if (spec.definition.compensation?.trigger === "on_failure") await this.rollback(workflowId);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async rollback(workflowId) {
|
|
131
|
+
const state = await this.getStateOrThrow(workflowId);
|
|
132
|
+
const spec = this.getSpec(state.workflowName, state.workflowVersion);
|
|
133
|
+
if (!spec.definition.compensation) return;
|
|
134
|
+
this.emit("workflow.rollback_started", { workflowId });
|
|
135
|
+
const completedSteps = state.history.filter((h) => h.status === "completed").reverse();
|
|
136
|
+
for (const execution of completedSteps) {
|
|
137
|
+
const compStep = spec.definition.compensation.steps.find((s) => s.stepId === execution.stepId);
|
|
138
|
+
if (compStep) {
|
|
139
|
+
const input = {
|
|
140
|
+
stepId: execution.stepId,
|
|
141
|
+
originalInput: execution.input,
|
|
142
|
+
originalOutput: execution.output,
|
|
143
|
+
workflowData: state.data
|
|
144
|
+
};
|
|
145
|
+
try {
|
|
146
|
+
const step = getCurrentStep(spec, execution.stepId);
|
|
147
|
+
const resolvedAppConfig = this.config.appConfigProvider ? await this.config.appConfigProvider(state) : void 0;
|
|
148
|
+
const executorContext = {
|
|
149
|
+
workflow: state,
|
|
150
|
+
step,
|
|
151
|
+
resolvedAppConfig,
|
|
152
|
+
integrations: resolvedAppConfig?.integrations ?? [],
|
|
153
|
+
knowledge: resolvedAppConfig?.knowledge ?? [],
|
|
154
|
+
branding: resolvedAppConfig?.branding,
|
|
155
|
+
translation: resolvedAppConfig?.translation,
|
|
156
|
+
translationResolver: this.config.translationResolver,
|
|
157
|
+
secretProvider: this.config.secretProvider
|
|
158
|
+
};
|
|
159
|
+
await this.config.opExecutor(compStep.operation, input, executorContext);
|
|
160
|
+
this.emit("workflow.compensation_step_completed", {
|
|
161
|
+
workflowId,
|
|
162
|
+
stepId: execution.stepId,
|
|
163
|
+
compensationOp: compStep.operation.key
|
|
164
|
+
});
|
|
165
|
+
} catch (error) {
|
|
166
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
167
|
+
this.emit("workflow.compensation_step_failed", {
|
|
168
|
+
workflowId,
|
|
169
|
+
stepId: execution.stepId,
|
|
170
|
+
compensationOp: compStep.operation.key,
|
|
171
|
+
error: errorMessage
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
this.emit("workflow.rollback_completed", { workflowId });
|
|
177
|
+
}
|
|
178
|
+
async getState(workflowId) {
|
|
179
|
+
return this.getStateOrThrow(workflowId);
|
|
180
|
+
}
|
|
181
|
+
async cancel(workflowId) {
|
|
182
|
+
const state = await this.getStateOrThrow(workflowId);
|
|
183
|
+
if (state.status === "cancelled") return;
|
|
184
|
+
const nextState = {
|
|
185
|
+
...state,
|
|
186
|
+
status: "cancelled",
|
|
187
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
188
|
+
};
|
|
189
|
+
await this.config.stateStore.update(workflowId, () => nextState);
|
|
190
|
+
this.emit("workflow.cancelled", {
|
|
191
|
+
workflowId,
|
|
192
|
+
workflowName: state.workflowName
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async performPreFlight(spec, resolvedConfig) {
|
|
196
|
+
if (!resolvedConfig) return {
|
|
197
|
+
canStart: true,
|
|
198
|
+
issues: []
|
|
199
|
+
};
|
|
200
|
+
const issues = [];
|
|
201
|
+
const integrationBySlot = /* @__PURE__ */ new Map();
|
|
202
|
+
for (const integration of resolvedConfig.integrations) integrationBySlot.set(integration.slot.slotId, integration);
|
|
203
|
+
for (const step of spec.definition.steps) for (const slotId of step.requiredIntegrations ?? []) {
|
|
204
|
+
const integration = integrationBySlot.get(slotId);
|
|
205
|
+
if (!integration) {
|
|
206
|
+
issues.push({
|
|
207
|
+
stepId: step.id,
|
|
208
|
+
type: "integration",
|
|
209
|
+
identifier: slotId,
|
|
210
|
+
severity: "error",
|
|
211
|
+
reason: `Integration slot "${slotId}" is not bound in the resolved app config.`
|
|
212
|
+
});
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const status = integration.connection.status;
|
|
216
|
+
if (status === "disconnected" || status === "error") issues.push({
|
|
217
|
+
stepId: step.id,
|
|
218
|
+
type: "integration",
|
|
219
|
+
identifier: slotId,
|
|
220
|
+
severity: "error",
|
|
221
|
+
reason: `Integration slot "${slotId}" is in status "${status}".`
|
|
222
|
+
});
|
|
223
|
+
else if (status === "unknown") issues.push({
|
|
224
|
+
stepId: step.id,
|
|
225
|
+
type: "integration",
|
|
226
|
+
identifier: slotId,
|
|
227
|
+
severity: "warning",
|
|
228
|
+
reason: `Integration slot "${slotId}" reports unknown health status.`
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const enabledCapabilities = new Set(resolvedConfig.capabilities.enabled.map(capabilityKey));
|
|
232
|
+
for (const step of spec.definition.steps) for (const required of step.requiredCapabilities ?? []) if (!enabledCapabilities.has(capabilityKey(required))) issues.push({
|
|
233
|
+
stepId: step.id,
|
|
234
|
+
type: "capability",
|
|
235
|
+
identifier: capabilityKey(required),
|
|
236
|
+
severity: "error",
|
|
237
|
+
reason: `Capability "${required.key}@${required.version}" is not enabled.`
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
canStart: issues.every((issue) => issue.severity !== "error"),
|
|
241
|
+
issues
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
async evaluateGuard(step, state, input) {
|
|
245
|
+
if (!step.guard) return true;
|
|
246
|
+
if (this.config.guardEvaluator) return this.config.guardEvaluator(step.guard, {
|
|
247
|
+
workflow: state,
|
|
248
|
+
step,
|
|
249
|
+
input
|
|
250
|
+
});
|
|
251
|
+
if (step.guard.type === "expression") return evaluateExpression(step.guard.value, {
|
|
252
|
+
data: state.data,
|
|
253
|
+
input
|
|
254
|
+
});
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
async runStepAction(step, state, input) {
|
|
258
|
+
if (step.type === "automation") {
|
|
259
|
+
const op = step.action?.operation;
|
|
260
|
+
if (!op) throw new Error(`Automation step "${step.id}" requires an operation.`);
|
|
261
|
+
const resolvedAppConfig = this.config.appConfigProvider ? await this.config.appConfigProvider(state) : void 0;
|
|
262
|
+
const executorContext = {
|
|
263
|
+
workflow: state,
|
|
264
|
+
step,
|
|
265
|
+
resolvedAppConfig,
|
|
266
|
+
integrations: resolvedAppConfig?.integrations ?? [],
|
|
267
|
+
knowledge: resolvedAppConfig?.knowledge ?? [],
|
|
268
|
+
branding: resolvedAppConfig?.branding,
|
|
269
|
+
translation: resolvedAppConfig?.translation,
|
|
270
|
+
translationResolver: this.config.translationResolver,
|
|
271
|
+
secretProvider: this.config.secretProvider
|
|
272
|
+
};
|
|
273
|
+
if (this.config.enforceCapabilities) await this.config.enforceCapabilities(op, executorContext);
|
|
274
|
+
return this.config.opExecutor(op, input, executorContext);
|
|
275
|
+
}
|
|
276
|
+
if (step.type === "human") return input;
|
|
277
|
+
return input;
|
|
278
|
+
}
|
|
279
|
+
pickNextStepId(spec, state, step, input, output) {
|
|
280
|
+
const transitions = spec.definition.transitions.filter((t) => t.from === step.id);
|
|
281
|
+
for (const transition of transitions) if (evaluateExpression(transition.condition, {
|
|
282
|
+
data: state.data,
|
|
283
|
+
input,
|
|
284
|
+
output
|
|
285
|
+
})) {
|
|
286
|
+
const target = spec.definition.steps.find((s) => s.id === transition.to);
|
|
287
|
+
if (!target) throw new Error(`Transition ${transition.from} -> ${transition.to} points to missing step.`);
|
|
288
|
+
return target.id;
|
|
289
|
+
}
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
getSpec(name, version) {
|
|
293
|
+
const spec = this.config.registry.get(name, version);
|
|
294
|
+
if (!spec) throw new Error(`Workflow spec not found for ${name}${version ? `.v${version}` : ""}`);
|
|
295
|
+
return spec;
|
|
296
|
+
}
|
|
297
|
+
async getStateOrThrow(workflowId) {
|
|
298
|
+
const state = await this.config.stateStore.get(workflowId);
|
|
299
|
+
if (!state) throw new Error(`Workflow state not found for ${workflowId}`);
|
|
300
|
+
return state;
|
|
301
|
+
}
|
|
302
|
+
emit(event, payload) {
|
|
303
|
+
this.config.eventEmitter?.(event, payload);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
function resolveEntryStepId(spec) {
|
|
307
|
+
const entry = spec.definition.entryStepId ?? spec.definition.steps[0]?.id ?? null;
|
|
308
|
+
if (!entry) throw new Error(`Workflow ${spec.meta.key}.v${spec.meta.version} has no entry step.`);
|
|
309
|
+
return entry;
|
|
310
|
+
}
|
|
311
|
+
function getCurrentStep(spec, stepId) {
|
|
312
|
+
const step = spec.definition.steps.find((s) => s.id === stepId);
|
|
313
|
+
if (!step) throw new Error(`Step "${stepId}" not found in workflow ${spec.meta.key}.v${spec.meta.version}.`);
|
|
314
|
+
return step;
|
|
315
|
+
}
|
|
316
|
+
function hasOutgoing(spec, stepId) {
|
|
317
|
+
return spec.definition.transitions.some((t) => t.from === stepId);
|
|
318
|
+
}
|
|
319
|
+
function isRecord(value) {
|
|
320
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
321
|
+
}
|
|
322
|
+
function isTerminalStatus(status) {
|
|
323
|
+
return status === "completed" || status === "failed" || status === "cancelled";
|
|
324
|
+
}
|
|
325
|
+
var WorkflowPreFlightError = class extends Error {
|
|
326
|
+
constructor(issues) {
|
|
327
|
+
super(`Workflow pre-flight failed: ${issues.filter((issue) => issue.severity === "error").map((issue) => `${issue.type}:${issue.identifier}`).join(", ")}`);
|
|
328
|
+
this.issues = issues;
|
|
329
|
+
this.name = "WorkflowPreFlightError";
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
function capabilityKey(ref) {
|
|
333
|
+
return `${ref.key}@${ref.version}`;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
//#endregion
|
|
337
|
+
export { WorkflowPreFlightError, WorkflowRunner };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WorkflowSpec } from "./spec.js";
|
|
2
|
+
import { WorkflowState } from "./state.js";
|
|
3
|
+
|
|
4
|
+
//#region src/workflow/sla-monitor.d.ts
|
|
5
|
+
interface SLABreachEvent {
|
|
6
|
+
workflowId: string;
|
|
7
|
+
workflowName: string;
|
|
8
|
+
type: 'workflow_duration' | 'step_duration';
|
|
9
|
+
stepId?: string;
|
|
10
|
+
expectedMs: number;
|
|
11
|
+
actualMs: number;
|
|
12
|
+
breachedAt: Date;
|
|
13
|
+
}
|
|
14
|
+
declare class SLAMonitor {
|
|
15
|
+
private readonly eventEmitter;
|
|
16
|
+
constructor(eventEmitter: (event: string, payload: SLABreachEvent) => void);
|
|
17
|
+
check(state: WorkflowState, spec: WorkflowSpec): void;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { SLABreachEvent, SLAMonitor };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/workflow/sla-monitor.ts
|
|
2
|
+
var SLAMonitor = class {
|
|
3
|
+
constructor(eventEmitter) {
|
|
4
|
+
this.eventEmitter = eventEmitter;
|
|
5
|
+
}
|
|
6
|
+
check(state, spec) {
|
|
7
|
+
const sla = spec.definition.sla;
|
|
8
|
+
if (!sla) return;
|
|
9
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
10
|
+
if (sla.totalDurationMs) {
|
|
11
|
+
const duration = now - state.createdAt.getTime();
|
|
12
|
+
if (duration > sla.totalDurationMs) {
|
|
13
|
+
if (state.status === "running" || state.status === "paused") this.eventEmitter("workflow.sla_breach", {
|
|
14
|
+
workflowId: state.workflowId,
|
|
15
|
+
workflowName: state.workflowName,
|
|
16
|
+
type: "workflow_duration",
|
|
17
|
+
expectedMs: sla.totalDurationMs,
|
|
18
|
+
actualMs: duration,
|
|
19
|
+
breachedAt: /* @__PURE__ */ new Date()
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (sla.stepDurationMs) {
|
|
24
|
+
if (state.status === "running" && state.currentStep) {
|
|
25
|
+
const currentExecution = state.history.find((h) => h.stepId === state.currentStep && h.status === "running");
|
|
26
|
+
if (currentExecution) {
|
|
27
|
+
const stepLimit = sla.stepDurationMs[state.currentStep];
|
|
28
|
+
if (stepLimit) {
|
|
29
|
+
const stepDuration = now - currentExecution.startedAt.getTime();
|
|
30
|
+
if (stepDuration > stepLimit) this.eventEmitter("workflow.sla_breach", {
|
|
31
|
+
workflowId: state.workflowId,
|
|
32
|
+
workflowName: state.workflowName,
|
|
33
|
+
type: "step_duration",
|
|
34
|
+
stepId: state.currentStep,
|
|
35
|
+
expectedMs: stepLimit,
|
|
36
|
+
actualMs: stepDuration,
|
|
37
|
+
breachedAt: /* @__PURE__ */ new Date()
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { SLAMonitor };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { OwnerShipMeta } from "../ownership.js";
|
|
2
|
+
import { CapabilityRef } from "../capabilities/capabilities.js";
|
|
3
|
+
import "../capabilities/index.js";
|
|
4
|
+
import { ExperimentRef } from "../experiments/spec.js";
|
|
5
|
+
import { GroupKeyFn, RegistryFilter } from "../registry-utils.js";
|
|
6
|
+
import { OpRef } from "../features/types.js";
|
|
7
|
+
import "../features/index.js";
|
|
8
|
+
|
|
9
|
+
//#region src/workflow/spec.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Reference to a form spec declared in {@link FormRegistry}.
|
|
12
|
+
*/
|
|
13
|
+
interface FormRef {
|
|
14
|
+
key: string;
|
|
15
|
+
version: number;
|
|
16
|
+
}
|
|
17
|
+
type StepType = 'human' | 'automation' | 'decision';
|
|
18
|
+
type WorkflowStatus = 'running' | 'paused' | 'completed' | 'failed' | 'cancelled';
|
|
19
|
+
type GuardConditionKind = 'policy' | 'expression';
|
|
20
|
+
interface GuardCondition {
|
|
21
|
+
type: GuardConditionKind;
|
|
22
|
+
/** Policy name or expression string depending on the type. */
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
interface RetryPolicy {
|
|
26
|
+
maxAttempts: number;
|
|
27
|
+
backoff: 'linear' | 'exponential';
|
|
28
|
+
delayMs: number;
|
|
29
|
+
/** Optional max delay cap for exponential backoff. */
|
|
30
|
+
maxDelayMs?: number;
|
|
31
|
+
}
|
|
32
|
+
interface StepAction {
|
|
33
|
+
/** Operation executed for automation steps. */
|
|
34
|
+
operation?: OpRef;
|
|
35
|
+
/** Form rendered for human input steps. */
|
|
36
|
+
form?: FormRef;
|
|
37
|
+
}
|
|
38
|
+
interface Step {
|
|
39
|
+
id: string;
|
|
40
|
+
type: StepType;
|
|
41
|
+
label: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
action?: StepAction;
|
|
44
|
+
guard?: GuardCondition;
|
|
45
|
+
timeoutMs?: number;
|
|
46
|
+
retry?: RetryPolicy;
|
|
47
|
+
/** Integration slot identifiers required before this step can execute. */
|
|
48
|
+
requiredIntegrations?: string[];
|
|
49
|
+
/** Capabilities that must be enabled for this step to execute. */
|
|
50
|
+
requiredCapabilities?: CapabilityRef[];
|
|
51
|
+
}
|
|
52
|
+
interface Transition {
|
|
53
|
+
from: string;
|
|
54
|
+
to: string;
|
|
55
|
+
label?: string;
|
|
56
|
+
/** Expression evaluated against workflow data (e.g., `data.approved === true`). */
|
|
57
|
+
condition?: string;
|
|
58
|
+
}
|
|
59
|
+
interface SLA {
|
|
60
|
+
totalDurationMs?: number;
|
|
61
|
+
stepDurationMs?: Record<string, number>;
|
|
62
|
+
}
|
|
63
|
+
interface CompensationStep {
|
|
64
|
+
stepId: string;
|
|
65
|
+
operation: OpRef;
|
|
66
|
+
description?: string;
|
|
67
|
+
}
|
|
68
|
+
interface CompensationStrategy {
|
|
69
|
+
trigger?: 'on_failure' | 'manual';
|
|
70
|
+
steps: CompensationStep[];
|
|
71
|
+
}
|
|
72
|
+
interface WorkflowDefinition {
|
|
73
|
+
steps: Step[];
|
|
74
|
+
transitions: Transition[];
|
|
75
|
+
/** Optional explicit entry step. Defaults to the first step when omitted. */
|
|
76
|
+
entryStepId?: string;
|
|
77
|
+
sla?: SLA;
|
|
78
|
+
compensation?: CompensationStrategy;
|
|
79
|
+
}
|
|
80
|
+
type WorkflowMeta = OwnerShipMeta;
|
|
81
|
+
interface WorkflowSpec {
|
|
82
|
+
meta: WorkflowMeta;
|
|
83
|
+
definition: WorkflowDefinition;
|
|
84
|
+
policy?: {
|
|
85
|
+
flags?: string[];
|
|
86
|
+
};
|
|
87
|
+
experiments?: ExperimentRef[];
|
|
88
|
+
}
|
|
89
|
+
declare class WorkflowRegistry {
|
|
90
|
+
private readonly items;
|
|
91
|
+
register(spec: WorkflowSpec): this;
|
|
92
|
+
list(): WorkflowSpec[];
|
|
93
|
+
get(name: string, version?: number): WorkflowSpec | undefined;
|
|
94
|
+
/** Filter workflows by criteria. */
|
|
95
|
+
filter(criteria: RegistryFilter): WorkflowSpec[];
|
|
96
|
+
/** List workflows with specific tag. */
|
|
97
|
+
listByTag(tag: string): WorkflowSpec[];
|
|
98
|
+
/** List workflows by owner. */
|
|
99
|
+
listByOwner(owner: string): WorkflowSpec[];
|
|
100
|
+
/** Group workflows by key function. */
|
|
101
|
+
groupBy(keyFn: GroupKeyFn<WorkflowSpec>): Map<string, WorkflowSpec[]>;
|
|
102
|
+
/** Get unique tags from all workflows. */
|
|
103
|
+
getUniqueTags(): string[];
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { CompensationStep, CompensationStrategy, FormRef, GuardCondition, GuardConditionKind, RetryPolicy, SLA, Step, StepAction, StepType, Transition, WorkflowDefinition, WorkflowMeta, WorkflowRegistry, WorkflowSpec, WorkflowStatus };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { filterBy, getUniqueTags, groupBy, init_registry_utils } from "../registry-utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/workflow/spec.ts
|
|
4
|
+
init_registry_utils();
|
|
5
|
+
function workflowKey(meta) {
|
|
6
|
+
return `${meta.key}.v${meta.version}`;
|
|
7
|
+
}
|
|
8
|
+
var WorkflowRegistry = class {
|
|
9
|
+
items = /* @__PURE__ */ new Map();
|
|
10
|
+
register(spec) {
|
|
11
|
+
const key = workflowKey(spec.meta);
|
|
12
|
+
if (this.items.has(key)) throw new Error(`Duplicate workflow ${key}`);
|
|
13
|
+
this.items.set(key, spec);
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
list() {
|
|
17
|
+
return [...this.items.values()];
|
|
18
|
+
}
|
|
19
|
+
get(name, version) {
|
|
20
|
+
if (version != null) return this.items.get(`${name}.v${version}`);
|
|
21
|
+
let candidate;
|
|
22
|
+
let max = -Infinity;
|
|
23
|
+
for (const spec of this.items.values()) {
|
|
24
|
+
if (spec.meta.key !== name) continue;
|
|
25
|
+
if (spec.meta.version > max) {
|
|
26
|
+
max = spec.meta.version;
|
|
27
|
+
candidate = spec;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return candidate;
|
|
31
|
+
}
|
|
32
|
+
/** Filter workflows by criteria. */
|
|
33
|
+
filter(criteria) {
|
|
34
|
+
return filterBy(this.list(), criteria);
|
|
35
|
+
}
|
|
36
|
+
/** List workflows with specific tag. */
|
|
37
|
+
listByTag(tag) {
|
|
38
|
+
return this.list().filter((w) => w.meta.tags?.includes(tag));
|
|
39
|
+
}
|
|
40
|
+
/** List workflows by owner. */
|
|
41
|
+
listByOwner(owner) {
|
|
42
|
+
return this.list().filter((w) => w.meta.owners?.includes(owner));
|
|
43
|
+
}
|
|
44
|
+
/** Group workflows by key function. */
|
|
45
|
+
groupBy(keyFn) {
|
|
46
|
+
return groupBy(this.list(), keyFn);
|
|
47
|
+
}
|
|
48
|
+
/** Get unique tags from all workflows. */
|
|
49
|
+
getUniqueTags() {
|
|
50
|
+
return getUniqueTags(this.list());
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { WorkflowRegistry };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { WorkflowStatus } from "./spec.js";
|
|
2
|
+
|
|
3
|
+
//#region src/workflow/state.d.ts
|
|
4
|
+
interface StepExecution {
|
|
5
|
+
stepId: string;
|
|
6
|
+
startedAt: Date;
|
|
7
|
+
completedAt?: Date;
|
|
8
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
9
|
+
input?: unknown;
|
|
10
|
+
output?: unknown;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
interface WorkflowState {
|
|
14
|
+
workflowId: string;
|
|
15
|
+
workflowName: string;
|
|
16
|
+
workflowVersion: number;
|
|
17
|
+
currentStep: string;
|
|
18
|
+
data: Record<string, unknown>;
|
|
19
|
+
retryCounts?: Record<string, number>;
|
|
20
|
+
history: StepExecution[];
|
|
21
|
+
status: WorkflowStatus;
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
updatedAt: Date;
|
|
24
|
+
}
|
|
25
|
+
interface WorkflowStateFilters {
|
|
26
|
+
status?: WorkflowStatus;
|
|
27
|
+
}
|
|
28
|
+
interface StateStore {
|
|
29
|
+
create(state: WorkflowState): Promise<void>;
|
|
30
|
+
get(workflowId: string): Promise<WorkflowState | undefined>;
|
|
31
|
+
update(workflowId: string, updater: (current: WorkflowState) => WorkflowState): Promise<WorkflowState>;
|
|
32
|
+
list(filters?: WorkflowStateFilters): Promise<WorkflowState[]>;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { StateStore, StepExecution, WorkflowState, WorkflowStateFilters };
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { WorkflowSpec } from "./spec.js";
|
|
2
|
+
import { OperationSpecRegistry } from "../operations/registry.js";
|
|
3
|
+
import { FormRegistry } from "../forms/forms.js";
|
|
4
|
+
import "../forms/index.js";
|
|
5
|
+
|
|
6
|
+
//#region src/workflow/validation.d.ts
|
|
7
|
+
type WorkflowValidationLevel = 'error' | 'warning';
|
|
8
|
+
interface WorkflowValidationIssue {
|
|
9
|
+
level: WorkflowValidationLevel;
|
|
10
|
+
message: string;
|
|
11
|
+
context?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
interface ValidateWorkflowSpecOptions {
|
|
14
|
+
operations?: OperationSpecRegistry;
|
|
15
|
+
forms?: FormRegistry;
|
|
16
|
+
}
|
|
17
|
+
declare class WorkflowValidationError extends Error {
|
|
18
|
+
readonly issues: WorkflowValidationIssue[];
|
|
19
|
+
constructor(message: string, issues: WorkflowValidationIssue[]);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Validate workflow structure, references, and reachability.
|
|
23
|
+
* Returns the collected issues. Consumers may call {@link assertWorkflowSpecValid}
|
|
24
|
+
* to throw on validation errors.
|
|
25
|
+
*/
|
|
26
|
+
declare function validateWorkflowSpec(spec: WorkflowSpec, options?: ValidateWorkflowSpecOptions): WorkflowValidationIssue[];
|
|
27
|
+
declare function assertWorkflowSpecValid(spec: WorkflowSpec, options?: ValidateWorkflowSpecOptions): void;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { ValidateWorkflowSpecOptions, WorkflowValidationError, WorkflowValidationIssue, WorkflowValidationLevel, assertWorkflowSpecValid, validateWorkflowSpec };
|