@frontmcp/sdk 1.11.3 → 1.12.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/answer/answer-meter.d.ts +2 -0
- package/answer/answer-meter.d.ts.map +1 -1
- package/app/instances/app.esm.instance.d.ts +4 -2
- package/app/instances/app.esm.instance.d.ts.map +1 -1
- package/app/instances/app.lazy.instance.d.ts.map +1 -1
- package/app/lazy/lazy-app.rules.d.ts +4 -0
- package/app/lazy/lazy-app.rules.d.ts.map +1 -1
- package/browser/answer/answer-meter.mjs +1 -0
- package/browser/app/instances/app.esm.instance.mjs +11 -3
- package/browser/app/instances/app.lazy.instance.mjs +7 -3
- package/browser/app/lazy/lazy-app.rules.mjs +4 -1
- package/browser/channel/channel-notification.service.mjs +20 -8
- package/browser/channel/channel.instance.mjs +10 -1
- package/browser/channel/channel.utils.mjs +22 -1
- package/browser/channel/sources/app-event.source.mjs +5 -2
- package/browser/channel/sources/file-watcher.source.mjs +66 -0
- package/browser/common/decorators/duty.decorator.mjs +3 -4
- package/browser/common/decorators/event.decorator.mjs +49 -0
- package/browser/common/decorators/index.mjs +2 -0
- package/browser/common/decorators/worker.decorator.mjs +23 -0
- package/browser/common/entries/event.entry.mjs +59 -0
- package/browser/common/entries/index.mjs +1 -0
- package/browser/common/index.mjs +7 -7
- package/browser/common/interfaces/event.interface.mjs +17 -0
- package/browser/common/interfaces/execution-context.interface.mjs +8 -0
- package/browser/common/interfaces/index.mjs +2 -0
- package/browser/common/interfaces/worker.interface.mjs +0 -0
- package/browser/common/metadata/app.metadata.mjs +2 -0
- package/browser/common/metadata/duty.metadata.mjs +28 -13
- package/browser/common/metadata/duty.resolved.mjs +13 -0
- package/browser/common/metadata/event.metadata.mjs +137 -0
- package/browser/common/metadata/front-mcp.metadata.mjs +3 -0
- package/browser/common/metadata/index.mjs +5 -1
- package/browser/common/metadata/worker.metadata.mjs +44 -0
- package/browser/common/metadata/worker.resolved.mjs +13 -0
- package/browser/common/metadata/workflow.metadata.mjs +7 -1
- package/browser/common/records/event.record.mjs +9 -0
- package/browser/common/records/index.mjs +1 -0
- package/browser/common/schemas/annotated-class.schema.mjs +10 -0
- package/browser/common/schemas/index.mjs +1 -1
- package/browser/common/tokens/app.tokens.mjs +1 -0
- package/browser/common/tokens/event.tokens.mjs +11 -0
- package/browser/common/tokens/front-mcp.tokens.mjs +2 -0
- package/browser/common/tokens/index.mjs +1 -0
- package/browser/common/tokens/workflow.tokens.mjs +1 -0
- package/browser/common/utils/offset-cursor.utils.mjs +23 -0
- package/browser/common/utils/principal.utils.mjs +1 -1
- package/browser/common/utils/time-zone.utils.mjs +12 -0
- package/browser/direct/create.mjs +3 -1
- package/browser/direct/direct-client.mjs +16 -2
- package/browser/direct/direct-events-transport.mjs +47 -0
- package/browser/direct/direct-server.mjs +5 -1
- package/browser/duty/cron-schedule.mjs +62 -0
- package/browser/duty/describe-thrown.mjs +12 -0
- package/browser/duty/duty.lifecycle.mjs +102 -97
- package/browser/duty/duty.runner.mjs +117 -115
- package/browser/duty/lazy-lease-store.mjs +60 -0
- package/browser/duty/lease-holder.mjs +132 -0
- package/browser/duty/lease-store.mjs +125 -0
- package/browser/elicitation/questions/question-subject.mjs +8 -2
- package/browser/errors/duty.errors.mjs +20 -0
- package/browser/errors/event.errors.mjs +128 -0
- package/browser/errors/index.mjs +36 -1
- package/browser/errors/worker.errors.mjs +14 -0
- package/browser/event/delivery/event-metrics.mjs +37 -0
- package/browser/event/delivery/event-outbox.mjs +251 -0
- package/browser/event/event-channel.mjs +30 -0
- package/browser/event/event-dialect.mjs +23 -0
- package/browser/event/event-gates.mjs +72 -0
- package/browser/event/event-outbound.mjs +8 -0
- package/browser/event/event-publisher.mjs +55 -0
- package/browser/event/event-reauthorization.mjs +48 -0
- package/browser/event/event-scope.helper.mjs +266 -0
- package/browser/event/event-subscriber.mjs +31 -0
- package/browser/event/event.instance.mjs +44 -0
- package/browser/event/event.registry.mjs +145 -0
- package/browser/event/event.utils.mjs +31 -0
- package/browser/event/flows/event-deliver.flow.mjs +175 -0
- package/browser/event/flows/event-poll.flow.mjs +308 -0
- package/browser/event/flows/event-publish-http.flow.mjs +288 -0
- package/browser/event/flows/event-publish.flow.mjs +371 -0
- package/browser/event/flows/event-stream.flow.mjs +222 -0
- package/browser/event/flows/event-subscribe.flow.mjs +351 -0
- package/browser/event/flows/event-unsubscribe.flow.mjs +120 -0
- package/browser/event/flows/list-events.flow.mjs +145 -0
- package/browser/event/index.mjs +104 -0
- package/browser/event/poll/event-buffer.mjs +77 -0
- package/browser/event/poll/event-poll-leases.mjs +118 -0
- package/browser/event/publish-endpoint/event-publish-endpoint.mjs +75 -0
- package/browser/event/publish-endpoint/event-publish-idempotency.mjs +54 -0
- package/browser/event/replay/event-replays.mjs +298 -0
- package/browser/event/stream/event-stream.mjs +279 -0
- package/browser/event/stream/event-streams.mjs +122 -0
- package/browser/event/subscription/event-callback-verifier.mjs +165 -0
- package/browser/event/subscription/event-subscription-store.factory.mjs +59 -0
- package/browser/event/subscription/event-subscription-termination.mjs +34 -0
- package/browser/event/subscription/event-subscription.store.mjs +167 -0
- package/browser/event/subscription/event-subscriptions.mjs +126 -0
- package/browser/event-client/event-client.errors.mjs +50 -0
- package/browser/event-client/event-webhook-receiver.mjs +155 -0
- package/browser/event-client/events-client.mjs +471 -0
- package/browser/event-client/index.mjs +28 -0
- package/browser/front-mcp/authorities-rules.check.mjs +15 -1
- package/browser/front-mcp/front-mcp.mjs +4 -6
- package/browser/index.cjs +23640 -16042
- package/browser/index.mjs +37 -2
- package/browser/job/execution/job-execution.manager.mjs +39 -5
- package/browser/job/job-scope.helper.mjs +21 -0
- package/browser/job/store/memory-job-state.store.mjs +5 -0
- package/browser/job/store/redis-job-state.store.mjs +11 -0
- package/browser/job/store/storage-job-state.store.mjs +18 -2
- package/browser/notification/notification.service.mjs +36 -6
- package/browser/provider/create-container.mjs +20 -9
- package/browser/provider/provider.lifecycle.mjs +4 -0
- package/browser/provider/provider.registry.mjs +55 -11
- package/browser/scope/event-publisher.providers.mjs +32 -0
- package/browser/scope/scope.instance.mjs +34 -21
- package/browser/skill/skill-instructions.helper.mjs +12 -6
- package/browser/subsystems.mjs +3 -0
- package/browser/tool/flows/tools-list.flow.mjs +3 -33
- package/browser/transport/adapters/transport.local.adapter.mjs +9 -2
- package/browser/transport/build-scoped-server-options.mjs +5 -1
- package/browser/transport/flows/handle.mcp-20260728.flow.mjs +76 -3
- package/browser/transport/in-memory-server.mjs +3 -0
- package/browser/transport/mcp-20260728/discover.mjs +1 -0
- package/browser/transport/mcp-20260728/event-stream-response.mjs +44 -0
- package/browser/transport/mcp-20260728/index.mjs +2 -1
- package/browser/transport/mcp-20260728/protocol-20260728.constants.mjs +8 -1
- package/browser/transport/mcp-20260728/request-validation.mjs +9 -5
- package/browser/transport/mcp-handlers/events-list-request.handler.mjs +23 -0
- package/browser/transport/mcp-handlers/events-poll-request.handler.mjs +23 -0
- package/browser/transport/mcp-handlers/events-stream-request.handler.mjs +44 -0
- package/browser/transport/mcp-handlers/events-subscribe-request.handler.mjs +23 -0
- package/browser/transport/mcp-handlers/events-unsubscribe-request.handler.mjs +25 -0
- package/browser/transport/mcp-handlers/index.mjs +13 -0
- package/browser/transport/mcp-handlers/initialize-request.handler.mjs +3 -1
- package/browser/transport/stdio-revision-router.mjs +29 -2
- package/browser/worker/worker.lifecycle.mjs +199 -0
- package/browser/worker/worker.supervisor.mjs +111 -0
- package/browser/workflow/tools/register-workflow.tool.mjs +3 -3
- package/browser/workflow/trigger/workflow-events.mjs +3 -1
- package/browser/workflow/trigger/workflow-schedules.mjs +173 -0
- package/browser/workflow/trigger/workflow-triggers.mjs +31 -0
- package/channel/channel-notification.service.d.ts +5 -2
- package/channel/channel-notification.service.d.ts.map +1 -1
- package/channel/channel-scope.helper.d.ts +4 -1
- package/channel/channel-scope.helper.d.ts.map +1 -1
- package/channel/channel.instance.d.ts +7 -1
- package/channel/channel.instance.d.ts.map +1 -1
- package/channel/channel.utils.d.ts +20 -0
- package/channel/channel.utils.d.ts.map +1 -1
- package/channel/sources/app-event.source.d.ts +11 -2
- package/channel/sources/app-event.source.d.ts.map +1 -1
- package/channel/sources/file-watcher.source.d.ts +21 -0
- package/channel/sources/file-watcher.source.d.ts.map +1 -0
- package/channel/sources/index.d.ts +1 -0
- package/channel/sources/index.d.ts.map +1 -1
- package/common/decorators/duty.decorator.d.ts +3 -2
- package/common/decorators/duty.decorator.d.ts.map +1 -1
- package/common/decorators/event.decorator.d.ts +38 -0
- package/common/decorators/event.decorator.d.ts.map +1 -0
- package/common/decorators/index.d.ts +2 -0
- package/common/decorators/index.d.ts.map +1 -1
- package/common/decorators/worker.decorator.d.ts +13 -0
- package/common/decorators/worker.decorator.d.ts.map +1 -0
- package/common/entries/event.entry.d.ts +34 -0
- package/common/entries/event.entry.d.ts.map +1 -0
- package/common/entries/index.d.ts +1 -0
- package/common/entries/index.d.ts.map +1 -1
- package/common/entries/scope.entry.d.ts +3 -0
- package/common/entries/scope.entry.d.ts.map +1 -1
- package/common/interfaces/event.interface.d.ts +124 -0
- package/common/interfaces/event.interface.d.ts.map +1 -0
- package/common/interfaces/execution-context.interface.d.ts +3 -0
- package/common/interfaces/execution-context.interface.d.ts.map +1 -1
- package/common/interfaces/index.d.ts +2 -0
- package/common/interfaces/index.d.ts.map +1 -1
- package/common/interfaces/internal/registry.interface.d.ts +3 -1
- package/common/interfaces/internal/registry.interface.d.ts.map +1 -1
- package/common/interfaces/worker.interface.d.ts +13 -0
- package/common/interfaces/worker.interface.d.ts.map +1 -0
- package/common/metadata/agent.metadata.d.ts +1 -1
- package/common/metadata/app.metadata.d.ts +4 -1
- package/common/metadata/app.metadata.d.ts.map +1 -1
- package/common/metadata/channel.metadata.d.ts +40 -8
- package/common/metadata/channel.metadata.d.ts.map +1 -1
- package/common/metadata/duty.metadata.d.ts +67 -13
- package/common/metadata/duty.metadata.d.ts.map +1 -1
- package/common/metadata/duty.resolved.d.ts +4 -0
- package/common/metadata/duty.resolved.d.ts.map +1 -0
- package/common/metadata/event.metadata.d.ts +451 -0
- package/common/metadata/event.metadata.d.ts.map +1 -0
- package/common/metadata/front-mcp.metadata.d.ts +1652 -16
- package/common/metadata/front-mcp.metadata.d.ts.map +1 -1
- package/common/metadata/index.d.ts +4 -0
- package/common/metadata/index.d.ts.map +1 -1
- package/common/metadata/job.metadata.d.ts +1 -1
- package/common/metadata/prompt.metadata.d.ts +1 -1
- package/common/metadata/resource.metadata.d.ts +2 -2
- package/common/metadata/skill.metadata.d.ts +1 -1
- package/common/metadata/tool.metadata.d.ts +1 -1
- package/common/metadata/worker.metadata.d.ts +69 -0
- package/common/metadata/worker.metadata.d.ts.map +1 -0
- package/common/metadata/worker.resolved.d.ts +4 -0
- package/common/metadata/worker.resolved.d.ts.map +1 -0
- package/common/metadata/workflow.metadata.d.ts +31 -3
- package/common/metadata/workflow.metadata.d.ts.map +1 -1
- package/common/records/event.record.d.ts +21 -0
- package/common/records/event.record.d.ts.map +1 -0
- package/common/records/index.d.ts +1 -0
- package/common/records/index.d.ts.map +1 -1
- package/common/schemas/annotated-class.schema.d.ts +1 -0
- package/common/schemas/annotated-class.schema.d.ts.map +1 -1
- package/common/tokens/app.tokens.d.ts.map +1 -1
- package/common/tokens/event.tokens.d.ts +9 -0
- package/common/tokens/event.tokens.d.ts.map +1 -0
- package/common/tokens/front-mcp.tokens.d.ts.map +1 -1
- package/common/tokens/index.d.ts +1 -0
- package/common/tokens/index.d.ts.map +1 -1
- package/common/tokens/workflow.tokens.d.ts +1 -0
- package/common/tokens/workflow.tokens.d.ts.map +1 -1
- package/common/utils/offset-cursor.utils.d.ts +5 -0
- package/common/utils/offset-cursor.utils.d.ts.map +1 -0
- package/common/utils/principal.utils.d.ts +11 -9
- package/common/utils/principal.utils.d.ts.map +1 -1
- package/common/utils/time-zone.utils.d.ts +3 -0
- package/common/utils/time-zone.utils.d.ts.map +1 -0
- package/direct/client.types.d.ts +8 -0
- package/direct/client.types.d.ts.map +1 -1
- package/direct/create.d.ts.map +1 -1
- package/direct/create.types.d.ts +3 -1
- package/direct/create.types.d.ts.map +1 -1
- package/direct/direct-events-transport.d.ts +20 -0
- package/direct/direct-events-transport.d.ts.map +1 -0
- package/direct/direct-server.d.ts +3 -0
- package/direct/direct-server.d.ts.map +1 -1
- package/direct/direct.types.d.ts +6 -0
- package/direct/direct.types.d.ts.map +1 -1
- package/duty/cron-schedule.d.ts +51 -0
- package/duty/cron-schedule.d.ts.map +1 -0
- package/duty/describe-thrown.d.ts +3 -0
- package/duty/describe-thrown.d.ts.map +1 -0
- package/duty/duty.lifecycle.d.ts +33 -4
- package/duty/duty.lifecycle.d.ts.map +1 -1
- package/duty/duty.runner.d.ts +49 -31
- package/duty/duty.runner.d.ts.map +1 -1
- package/duty/lazy-lease-store.d.ts +29 -0
- package/duty/lazy-lease-store.d.ts.map +1 -0
- package/duty/lease-holder.d.ts +73 -0
- package/duty/lease-holder.d.ts.map +1 -0
- package/duty/lease-store.d.ts +40 -0
- package/duty/lease-store.d.ts.map +1 -0
- package/elicitation/hooks/elicitation.hooks.d.ts +5 -5
- package/elicitation/questions/question-subject.d.ts +8 -3
- package/elicitation/questions/question-subject.d.ts.map +1 -1
- package/errors/duty.errors.d.ts +10 -0
- package/errors/duty.errors.d.ts.map +1 -1
- package/errors/event.errors.d.ts +73 -0
- package/errors/event.errors.d.ts.map +1 -0
- package/errors/index.d.ts +4 -1
- package/errors/index.d.ts.map +1 -1
- package/errors/worker.errors.d.ts +7 -0
- package/errors/worker.errors.d.ts.map +1 -0
- package/esm/index.mjs +38 -34
- package/event/delivery/event-metrics.d.ts +25 -0
- package/event/delivery/event-metrics.d.ts.map +1 -0
- package/event/delivery/event-outbox.d.ts +129 -0
- package/event/delivery/event-outbox.d.ts.map +1 -0
- package/event/event-channel.d.ts +21 -0
- package/event/event-channel.d.ts.map +1 -0
- package/event/event-dialect.d.ts +20 -0
- package/event/event-dialect.d.ts.map +1 -0
- package/event/event-gates.d.ts +23 -0
- package/event/event-gates.d.ts.map +1 -0
- package/event/event-outbound.d.ts +9 -0
- package/event/event-outbound.d.ts.map +1 -0
- package/event/event-publisher.d.ts +14 -0
- package/event/event-publisher.d.ts.map +1 -0
- package/event/event-reauthorization.d.ts +35 -0
- package/event/event-reauthorization.d.ts.map +1 -0
- package/event/event-scope.helper.d.ts +23 -0
- package/event/event-scope.helper.d.ts.map +1 -0
- package/event/event-subscriber.d.ts +12 -0
- package/event/event-subscriber.d.ts.map +1 -0
- package/event/event.instance.d.ts +15 -0
- package/event/event.instance.d.ts.map +1 -0
- package/event/event.registry.d.ts +97 -0
- package/event/event.registry.d.ts.map +1 -0
- package/event/event.utils.d.ts +6 -0
- package/event/event.utils.d.ts.map +1 -0
- package/event/flows/event-deliver.flow.d.ts +73 -0
- package/event/flows/event-deliver.flow.d.ts.map +1 -0
- package/event/flows/event-poll.flow.d.ts +105 -0
- package/event/flows/event-poll.flow.d.ts.map +1 -0
- package/event/flows/event-publish-http.flow.d.ts +114 -0
- package/event/flows/event-publish-http.flow.d.ts.map +1 -0
- package/event/flows/event-publish.flow.d.ts +109 -0
- package/event/flows/event-publish.flow.d.ts.map +1 -0
- package/event/flows/event-stream.flow.d.ts +78 -0
- package/event/flows/event-stream.flow.d.ts.map +1 -0
- package/event/flows/event-subscribe.flow.d.ts +132 -0
- package/event/flows/event-subscribe.flow.d.ts.map +1 -0
- package/event/flows/event-unsubscribe.flow.d.ts +71 -0
- package/event/flows/event-unsubscribe.flow.d.ts.map +1 -0
- package/event/flows/list-events.flow.d.ts +75 -0
- package/event/flows/list-events.flow.d.ts.map +1 -0
- package/event/index.d.ts +46 -0
- package/event/index.d.ts.map +1 -0
- package/event/poll/event-buffer.d.ts +54 -0
- package/event/poll/event-buffer.d.ts.map +1 -0
- package/event/poll/event-poll-leases.d.ts +63 -0
- package/event/poll/event-poll-leases.d.ts.map +1 -0
- package/event/publish-endpoint/event-publish-endpoint.d.ts +29 -0
- package/event/publish-endpoint/event-publish-endpoint.d.ts.map +1 -0
- package/event/publish-endpoint/event-publish-idempotency.d.ts +35 -0
- package/event/publish-endpoint/event-publish-idempotency.d.ts.map +1 -0
- package/event/replay/event-replays.d.ts +116 -0
- package/event/replay/event-replays.d.ts.map +1 -0
- package/event/stream/event-stream.d.ts +116 -0
- package/event/stream/event-stream.d.ts.map +1 -0
- package/event/stream/event-streams.d.ts +52 -0
- package/event/stream/event-streams.d.ts.map +1 -0
- package/event/subscription/event-callback-verifier.d.ts +58 -0
- package/event/subscription/event-callback-verifier.d.ts.map +1 -0
- package/event/subscription/event-subscription-store.factory.d.ts +31 -0
- package/event/subscription/event-subscription-store.factory.d.ts.map +1 -0
- package/event/subscription/event-subscription-termination.d.ts +25 -0
- package/event/subscription/event-subscription-termination.d.ts.map +1 -0
- package/event/subscription/event-subscription.store.d.ts +131 -0
- package/event/subscription/event-subscription.store.d.ts.map +1 -0
- package/event/subscription/event-subscriptions.d.ts +66 -0
- package/event/subscription/event-subscriptions.d.ts.map +1 -0
- package/event-client/event-client.errors.d.ts +35 -0
- package/event-client/event-client.errors.d.ts.map +1 -0
- package/event-client/event-webhook-receiver.d.ts +75 -0
- package/event-client/event-webhook-receiver.d.ts.map +1 -0
- package/event-client/events-client.d.ts +33 -0
- package/event-client/events-client.d.ts.map +1 -0
- package/event-client/events-client.types.d.ts +74 -0
- package/event-client/events-client.types.d.ts.map +1 -0
- package/event-client/index.d.ts +6 -0
- package/event-client/index.d.ts.map +1 -0
- package/front-mcp/authorities-rules.check.d.ts +5 -0
- package/front-mcp/authorities-rules.check.d.ts.map +1 -1
- package/front-mcp/front-mcp.d.ts.map +1 -1
- package/index.d.ts +70 -0
- package/index.d.ts.map +1 -1
- package/index.js +46 -42
- package/job/execution/job-execution.manager.d.ts +7 -0
- package/job/execution/job-execution.manager.d.ts.map +1 -1
- package/job/job-scope.helper.d.ts.map +1 -1
- package/job/store/job-state.interface.d.ts +2 -0
- package/job/store/job-state.interface.d.ts.map +1 -1
- package/job/store/memory-job-state.store.d.ts +1 -0
- package/job/store/memory-job-state.store.d.ts.map +1 -1
- package/job/store/redis-job-state.store.d.ts +3 -0
- package/job/store/redis-job-state.store.d.ts.map +1 -1
- package/job/store/storage-job-state.store.d.ts +1 -0
- package/job/store/storage-job-state.store.d.ts.map +1 -1
- package/notification/index.d.ts +1 -1
- package/notification/index.d.ts.map +1 -1
- package/notification/notification.service.d.ts +31 -2
- package/notification/notification.service.d.ts.map +1 -1
- package/package.json +11 -10
- package/provider/create-container.d.ts +14 -4
- package/provider/create-container.d.ts.map +1 -1
- package/provider/provider.lifecycle.d.ts +11 -1
- package/provider/provider.lifecycle.d.ts.map +1 -1
- package/provider/provider.registry.d.ts +18 -4
- package/provider/provider.registry.d.ts.map +1 -1
- package/scope/event-publisher.providers.d.ts +17 -0
- package/scope/event-publisher.providers.d.ts.map +1 -0
- package/scope/scope.instance.d.ts +6 -1
- package/scope/scope.instance.d.ts.map +1 -1
- package/shared/shared-attach.d.ts +3 -1
- package/shared/shared-attach.d.ts.map +1 -1
- package/shared/shared-server.lifecycle.d.ts +14 -5
- package/shared/shared-server.lifecycle.d.ts.map +1 -1
- package/skill/skill-instructions.helper.d.ts +10 -4
- package/skill/skill-instructions.helper.d.ts.map +1 -1
- package/subsystems.d.ts +1 -0
- package/subsystems.d.ts.map +1 -1
- package/tool/flows/tools-list.flow.d.ts +0 -11
- package/tool/flows/tools-list.flow.d.ts.map +1 -1
- package/transport/adapters/transport.local.adapter.d.ts.map +1 -1
- package/transport/build-scoped-server-options.d.ts.map +1 -1
- package/transport/flows/handle.mcp-20260728.flow.d.ts +8 -2
- package/transport/flows/handle.mcp-20260728.flow.d.ts.map +1 -1
- package/transport/in-memory-server.d.ts.map +1 -1
- package/transport/mcp-20260728/discover.d.ts.map +1 -1
- package/transport/mcp-20260728/event-stream-response.d.ts +12 -0
- package/transport/mcp-20260728/event-stream-response.d.ts.map +1 -0
- package/transport/mcp-20260728/index.d.ts +1 -0
- package/transport/mcp-20260728/index.d.ts.map +1 -1
- package/transport/mcp-20260728/protocol-20260728.constants.d.ts.map +1 -1
- package/transport/mcp-20260728/request-validation.d.ts +2 -0
- package/transport/mcp-20260728/request-validation.d.ts.map +1 -1
- package/transport/mcp-handlers/events-list-request.handler.d.ts +5 -0
- package/transport/mcp-handlers/events-list-request.handler.d.ts.map +1 -0
- package/transport/mcp-handlers/events-poll-request.handler.d.ts +5 -0
- package/transport/mcp-handlers/events-poll-request.handler.d.ts.map +1 -0
- package/transport/mcp-handlers/events-stream-request.handler.d.ts +8 -0
- package/transport/mcp-handlers/events-stream-request.handler.d.ts.map +1 -0
- package/transport/mcp-handlers/events-subscribe-request.handler.d.ts +5 -0
- package/transport/mcp-handlers/events-subscribe-request.handler.d.ts.map +1 -0
- package/transport/mcp-handlers/events-unsubscribe-request.handler.d.ts +5 -0
- package/transport/mcp-handlers/events-unsubscribe-request.handler.d.ts.map +1 -0
- package/transport/mcp-handlers/index.d.ts +162 -3
- package/transport/mcp-handlers/index.d.ts.map +1 -1
- package/transport/mcp-handlers/initialize-request.handler.d.ts.map +1 -1
- package/transport/stdio-revision-router.d.ts +2 -0
- package/transport/stdio-revision-router.d.ts.map +1 -1
- package/worker/worker.lifecycle.d.ts +63 -0
- package/worker/worker.lifecycle.d.ts.map +1 -0
- package/worker/worker.supervisor.d.ts +62 -0
- package/worker/worker.supervisor.d.ts.map +1 -0
- package/workflow/tools/register-workflow.tool.d.ts +2 -1
- package/workflow/tools/register-workflow.tool.d.ts.map +1 -1
- package/workflow/trigger/workflow-events.d.ts.map +1 -1
- package/workflow/trigger/workflow-schedules.d.ts +76 -0
- package/workflow/trigger/workflow-schedules.d.ts.map +1 -0
- package/workflow/trigger/workflow-triggers.d.ts +16 -1
- package/workflow/trigger/workflow-triggers.d.ts.map +1 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// libs/sdk/src/event/flows/list-events.flow.ts
|
|
13
|
+
import { internalZ as z } from "@frontmcp/lazy-zod";
|
|
14
|
+
import {
|
|
15
|
+
EventDeliveryModeSchema,
|
|
16
|
+
ListEventsRequestSchema,
|
|
17
|
+
ListEventsResultSchema
|
|
18
|
+
} from "@frontmcp/protocol";
|
|
19
|
+
import { EventEntry, Flow, FlowBase, FlowHooksOf } from "../../common/index.mjs";
|
|
20
|
+
import { callSurfaceOf, isOfferedOnSurface } from "../../common/availability/index.mjs";
|
|
21
|
+
import { encodeOffsetCursor, parseOffsetCursor } from "../../common/utils/offset-cursor.utils.mjs";
|
|
22
|
+
import { InvalidInputError } from "../../errors/index.mjs";
|
|
23
|
+
import { isListedByAuthorities } from "../../surface/entry-authorized.mjs";
|
|
24
|
+
var EVENTS_LIST_PAGE_SIZE = 40;
|
|
25
|
+
var inputSchema = z.object({
|
|
26
|
+
request: ListEventsRequestSchema,
|
|
27
|
+
ctx: z.unknown()
|
|
28
|
+
});
|
|
29
|
+
var outputSchema = ListEventsResultSchema;
|
|
30
|
+
var stateSchema = z.object({
|
|
31
|
+
cursor: z.string().optional(),
|
|
32
|
+
authInfo: z.any(),
|
|
33
|
+
events: z.array(
|
|
34
|
+
z.object({
|
|
35
|
+
event: z.instanceof(EventEntry),
|
|
36
|
+
delivery: z.array(EventDeliveryModeSchema)
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
});
|
|
40
|
+
var plan = {
|
|
41
|
+
pre: ["parseInput"],
|
|
42
|
+
execute: ["findEvents", "filterByAvailability", "filterByAuthorities", "filterByDiscovery"],
|
|
43
|
+
post: ["parseEvents"],
|
|
44
|
+
finalize: ["finalize"]
|
|
45
|
+
};
|
|
46
|
+
var name = "events:list";
|
|
47
|
+
var { Stage } = FlowHooksOf(name);
|
|
48
|
+
function compareByName(left, right) {
|
|
49
|
+
if (left.event.name < right.event.name) return -1;
|
|
50
|
+
return left.event.name > right.event.name ? 1 : 0;
|
|
51
|
+
}
|
|
52
|
+
var ListEventsFlow = class extends FlowBase {
|
|
53
|
+
logger = this.scopeLogger.child("ListEventsFlow");
|
|
54
|
+
async parseInput() {
|
|
55
|
+
const { request, ctx } = this.input;
|
|
56
|
+
const authInfo = ctx?.authInfo ?? {};
|
|
57
|
+
this.state.set({ cursor: request.params?.cursor ?? void 0, authInfo });
|
|
58
|
+
}
|
|
59
|
+
async findEvents() {
|
|
60
|
+
this.state.set("events", this.scope.events?.getServedEvents() ?? []);
|
|
61
|
+
}
|
|
62
|
+
async filterByAvailability() {
|
|
63
|
+
const callSurface = callSurfaceOf(this.input.ctx);
|
|
64
|
+
const offered = this.state.required.events.filter(
|
|
65
|
+
({ event }) => isOfferedOnSurface(event.metadata.availableWhen, callSurface)
|
|
66
|
+
);
|
|
67
|
+
this.state.set("events", offered);
|
|
68
|
+
}
|
|
69
|
+
async filterByAuthorities() {
|
|
70
|
+
const engine = this.scope.authoritiesEngine;
|
|
71
|
+
const contextBuilder = this.scope.authoritiesContextBuilder;
|
|
72
|
+
if (!engine || !contextBuilder) return;
|
|
73
|
+
const { events, authInfo } = this.state.required;
|
|
74
|
+
const answers = await Promise.all(
|
|
75
|
+
events.map(({ event }) => {
|
|
76
|
+
const authorities = event.getAuthorities();
|
|
77
|
+
if (authorities === void 0) return true;
|
|
78
|
+
return isListedByAuthorities(engine, contextBuilder, authorities, authInfo, event.name, this.logger);
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
this.state.set(
|
|
82
|
+
"events",
|
|
83
|
+
events.filter((_item, index) => answers[index])
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
async filterByDiscovery() {
|
|
87
|
+
const discoverable = this.state.required.events.filter(({ event }) => !event.metadata.hideFromDiscovery);
|
|
88
|
+
this.state.set("events", discoverable);
|
|
89
|
+
}
|
|
90
|
+
async parseEvents() {
|
|
91
|
+
const sorted = [...this.state.required.events].sort(compareByName);
|
|
92
|
+
const offset = this.state.cursor ? parseOffsetCursor(this.state.cursor) : 0;
|
|
93
|
+
if (offset > sorted.length) {
|
|
94
|
+
throw new InvalidInputError(
|
|
95
|
+
`Invalid pagination cursor: offset ${offset} exceeds total event count ${sorted.length}`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
const events = sorted.slice(offset, offset + EVENTS_LIST_PAGE_SIZE).map(({ event, delivery }) => ({
|
|
99
|
+
name: event.name,
|
|
100
|
+
...event.metadata.description && { description: event.metadata.description },
|
|
101
|
+
delivery,
|
|
102
|
+
inputSchema: event.getInputJsonSchema(),
|
|
103
|
+
payloadSchema: event.getPayloadJsonSchema()
|
|
104
|
+
}));
|
|
105
|
+
const nextOffset = offset + EVENTS_LIST_PAGE_SIZE;
|
|
106
|
+
this.respond({ events, ...nextOffset < sorted.length && { nextCursor: encodeOffsetCursor(nextOffset) } });
|
|
107
|
+
}
|
|
108
|
+
async finalize() {
|
|
109
|
+
this.logger.verbose("finalize");
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
__decorateClass([
|
|
113
|
+
Stage("parseInput")
|
|
114
|
+
], ListEventsFlow.prototype, "parseInput", 1);
|
|
115
|
+
__decorateClass([
|
|
116
|
+
Stage("findEvents")
|
|
117
|
+
], ListEventsFlow.prototype, "findEvents", 1);
|
|
118
|
+
__decorateClass([
|
|
119
|
+
Stage("filterByAvailability")
|
|
120
|
+
], ListEventsFlow.prototype, "filterByAvailability", 1);
|
|
121
|
+
__decorateClass([
|
|
122
|
+
Stage("filterByAuthorities")
|
|
123
|
+
], ListEventsFlow.prototype, "filterByAuthorities", 1);
|
|
124
|
+
__decorateClass([
|
|
125
|
+
Stage("filterByDiscovery")
|
|
126
|
+
], ListEventsFlow.prototype, "filterByDiscovery", 1);
|
|
127
|
+
__decorateClass([
|
|
128
|
+
Stage("parseEvents")
|
|
129
|
+
], ListEventsFlow.prototype, "parseEvents", 1);
|
|
130
|
+
__decorateClass([
|
|
131
|
+
Stage("finalize")
|
|
132
|
+
], ListEventsFlow.prototype, "finalize", 1);
|
|
133
|
+
ListEventsFlow = __decorateClass([
|
|
134
|
+
Flow({
|
|
135
|
+
name,
|
|
136
|
+
plan,
|
|
137
|
+
inputSchema,
|
|
138
|
+
outputSchema,
|
|
139
|
+
access: "authorized"
|
|
140
|
+
})
|
|
141
|
+
], ListEventsFlow);
|
|
142
|
+
export {
|
|
143
|
+
EVENTS_LIST_PAGE_SIZE,
|
|
144
|
+
ListEventsFlow as default
|
|
145
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// libs/sdk/src/event/index.ts
|
|
2
|
+
import { EventInstance } from "./event.instance.mjs";
|
|
3
|
+
import { default as default2 } from "./event.registry.mjs";
|
|
4
|
+
import { normalizeEvent } from "./event.utils.mjs";
|
|
5
|
+
import { registerEventCapabilities } from "./event-scope.helper.mjs";
|
|
6
|
+
import { EVENT_DIALECTS, callerPlatformOf, resolveEventDialect } from "./event-dialect.mjs";
|
|
7
|
+
import { eventOutboundTargetOptions } from "./event-outbound.mjs";
|
|
8
|
+
import { eventSubscriberOf } from "./event-subscriber.mjs";
|
|
9
|
+
import { EventCallbackVerifier, VERIFICATION_ATTEMPTS_PER_HOST } from "./subscription/event-callback-verifier.mjs";
|
|
10
|
+
import { createEventSubscriptionStore, openEventStorage } from "./subscription/event-subscription-store.factory.mjs";
|
|
11
|
+
import { StorageEventSubscriptionStore } from "./subscription/event-subscription.store.mjs";
|
|
12
|
+
import {
|
|
13
|
+
EventSubscriptions,
|
|
14
|
+
SUBSCRIPTION_SWEEP_INTERVAL_MS,
|
|
15
|
+
deliveryStatusOf,
|
|
16
|
+
subscriptionRefOf
|
|
17
|
+
} from "./subscription/event-subscriptions.mjs";
|
|
18
|
+
import { EVENT_COUNTERS, createEventMetrics } from "./delivery/event-metrics.mjs";
|
|
19
|
+
import { EventOutbox, OUTBOX_SWEEP_INTERVAL_MS } from "./delivery/event-outbox.mjs";
|
|
20
|
+
import { ScopeEventPublisher, newEventId } from "./event-publisher.mjs";
|
|
21
|
+
import {
|
|
22
|
+
assertEventAuthorities,
|
|
23
|
+
assertEventAuthorizes,
|
|
24
|
+
eventReaderOf,
|
|
25
|
+
offeredEventOf,
|
|
26
|
+
parsedEventArguments,
|
|
27
|
+
readerSubscriptionOf
|
|
28
|
+
} from "./event-gates.mjs";
|
|
29
|
+
import { EventBuffer } from "./poll/event-buffer.mjs";
|
|
30
|
+
import {
|
|
31
|
+
EventPollLeases,
|
|
32
|
+
MAX_POLL_LEASES,
|
|
33
|
+
POLL_LEASE_INTERVALS,
|
|
34
|
+
POLL_LEASE_MIN_MS,
|
|
35
|
+
POLL_LEASE_SWEEP_INTERVAL_MS,
|
|
36
|
+
pollLeaseMs
|
|
37
|
+
} from "./poll/event-poll-leases.mjs";
|
|
38
|
+
import { EventReplays, MAX_PENDING_BATCHES, REPLAY_LEASE_MS } from "./replay/event-replays.mjs";
|
|
39
|
+
import { EventStream, MAX_QUEUED_NOTIFICATIONS } from "./stream/event-stream.mjs";
|
|
40
|
+
import { EVENT_RELAY_CHANNEL, EventStreams, MAX_OPEN_STREAMS } from "./stream/event-streams.mjs";
|
|
41
|
+
import { SUSPEND_AFTER_FAILURES } from "./flows/event-deliver.flow.mjs";
|
|
42
|
+
import { EVENT_DELIVERY_MAX_BYTES, isInAudience } from "./flows/event-publish.flow.mjs";
|
|
43
|
+
import { EVENT_PUBLISH_MAX_BODY_BYTES } from "./flows/event-publish-http.flow.mjs";
|
|
44
|
+
import { enablePublishEndpoint } from "./publish-endpoint/event-publish-endpoint.mjs";
|
|
45
|
+
import {
|
|
46
|
+
EventPublishIdempotency,
|
|
47
|
+
PUBLISH_CLAIM_SECONDS,
|
|
48
|
+
PUBLISH_IDEMPOTENCY_WINDOW_SECONDS
|
|
49
|
+
} from "./publish-endpoint/event-publish-idempotency.mjs";
|
|
50
|
+
export {
|
|
51
|
+
EVENT_COUNTERS,
|
|
52
|
+
EVENT_DELIVERY_MAX_BYTES,
|
|
53
|
+
EVENT_DIALECTS,
|
|
54
|
+
EVENT_PUBLISH_MAX_BODY_BYTES,
|
|
55
|
+
EVENT_RELAY_CHANNEL,
|
|
56
|
+
EventBuffer,
|
|
57
|
+
EventCallbackVerifier,
|
|
58
|
+
EventInstance,
|
|
59
|
+
EventOutbox,
|
|
60
|
+
EventPollLeases,
|
|
61
|
+
EventPublishIdempotency,
|
|
62
|
+
default2 as EventRegistry,
|
|
63
|
+
EventReplays,
|
|
64
|
+
EventStream,
|
|
65
|
+
EventStreams,
|
|
66
|
+
EventSubscriptions,
|
|
67
|
+
MAX_OPEN_STREAMS,
|
|
68
|
+
MAX_PENDING_BATCHES,
|
|
69
|
+
MAX_POLL_LEASES,
|
|
70
|
+
MAX_QUEUED_NOTIFICATIONS,
|
|
71
|
+
OUTBOX_SWEEP_INTERVAL_MS,
|
|
72
|
+
POLL_LEASE_INTERVALS,
|
|
73
|
+
POLL_LEASE_MIN_MS,
|
|
74
|
+
POLL_LEASE_SWEEP_INTERVAL_MS,
|
|
75
|
+
PUBLISH_CLAIM_SECONDS,
|
|
76
|
+
PUBLISH_IDEMPOTENCY_WINDOW_SECONDS,
|
|
77
|
+
REPLAY_LEASE_MS,
|
|
78
|
+
SUBSCRIPTION_SWEEP_INTERVAL_MS,
|
|
79
|
+
SUSPEND_AFTER_FAILURES,
|
|
80
|
+
ScopeEventPublisher,
|
|
81
|
+
StorageEventSubscriptionStore,
|
|
82
|
+
VERIFICATION_ATTEMPTS_PER_HOST,
|
|
83
|
+
assertEventAuthorities,
|
|
84
|
+
assertEventAuthorizes,
|
|
85
|
+
callerPlatformOf,
|
|
86
|
+
createEventMetrics,
|
|
87
|
+
createEventSubscriptionStore,
|
|
88
|
+
deliveryStatusOf,
|
|
89
|
+
enablePublishEndpoint,
|
|
90
|
+
eventOutboundTargetOptions,
|
|
91
|
+
eventReaderOf,
|
|
92
|
+
eventSubscriberOf,
|
|
93
|
+
isInAudience,
|
|
94
|
+
newEventId,
|
|
95
|
+
normalizeEvent,
|
|
96
|
+
offeredEventOf,
|
|
97
|
+
openEventStorage,
|
|
98
|
+
parsedEventArguments,
|
|
99
|
+
pollLeaseMs,
|
|
100
|
+
readerSubscriptionOf,
|
|
101
|
+
registerEventCapabilities,
|
|
102
|
+
resolveEventDialect,
|
|
103
|
+
subscriptionRefOf
|
|
104
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// libs/sdk/src/event/poll/event-buffer.ts
|
|
2
|
+
import { randomUUID } from "@frontmcp/utils";
|
|
3
|
+
var CURSOR_SEPARATOR = ".";
|
|
4
|
+
var EventBuffer = class {
|
|
5
|
+
/** Takes the age and count limits, and draws the boot id that this process's cursors carry. */
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
this.bootId = randomUUID().replace(/-/g, "");
|
|
9
|
+
}
|
|
10
|
+
options;
|
|
11
|
+
bootId;
|
|
12
|
+
rings = /* @__PURE__ */ new Map();
|
|
13
|
+
sequence = 0;
|
|
14
|
+
/** Keep a published occurrence, and drop what its event's ring no longer holds. */
|
|
15
|
+
append(occurrence, audience, subscriptionId) {
|
|
16
|
+
const now = Date.now();
|
|
17
|
+
this.sequence += 1;
|
|
18
|
+
const buffered = { sequence: this.sequence, publishedAt: now, occurrence, audience, subscriptionId };
|
|
19
|
+
const ring = this.ringOf(occurrence.name);
|
|
20
|
+
ring.events.push(buffered);
|
|
21
|
+
this.prune(ring, now);
|
|
22
|
+
return buffered;
|
|
23
|
+
}
|
|
24
|
+
/** The cursor of the current position: a later read from it gives what is published from now on. */
|
|
25
|
+
currentCursor() {
|
|
26
|
+
return this.cursorAt(this.sequence);
|
|
27
|
+
}
|
|
28
|
+
/** The sequence of the last occurrence appended, of any event; 0 before the first. */
|
|
29
|
+
currentSequence() {
|
|
30
|
+
return this.sequence;
|
|
31
|
+
}
|
|
32
|
+
/** The cursor of a position: a read from it gives the occurrences after that position. */
|
|
33
|
+
cursorAt(sequence) {
|
|
34
|
+
return `${this.bootId}${CURSOR_SEPARATOR}${sequence}`;
|
|
35
|
+
}
|
|
36
|
+
/** The occurrences of an event after a cursor. A cursor this process cannot place reads as a gap, from now. */
|
|
37
|
+
read(eventName, cursor) {
|
|
38
|
+
const ring = this.ringOf(eventName);
|
|
39
|
+
this.prune(ring, Date.now());
|
|
40
|
+
const position = this.positionOf(cursor);
|
|
41
|
+
if (position === void 0) return { events: [], truncated: true };
|
|
42
|
+
return {
|
|
43
|
+
events: ring.events.filter((buffered) => buffered.sequence > position),
|
|
44
|
+
truncated: position < ring.droppedThrough
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** The position a cursor names, when this process issued a cursor of that shape and has reached it. */
|
|
48
|
+
positionOf(cursor) {
|
|
49
|
+
const [bootId, position, ...rest] = cursor.split(CURSOR_SEPARATOR);
|
|
50
|
+
const sequence = Number(position);
|
|
51
|
+
const isPosition = Number.isSafeInteger(sequence) && sequence >= 0 && String(sequence) === position;
|
|
52
|
+
if (bootId !== this.bootId || !isPosition || rest.length > 0 || sequence > this.sequence) return void 0;
|
|
53
|
+
return sequence;
|
|
54
|
+
}
|
|
55
|
+
/** The ring of an event, made on first use. */
|
|
56
|
+
ringOf(eventName) {
|
|
57
|
+
let ring = this.rings.get(eventName);
|
|
58
|
+
if (!ring) {
|
|
59
|
+
ring = { events: [], droppedThrough: 0 };
|
|
60
|
+
this.rings.set(eventName, ring);
|
|
61
|
+
}
|
|
62
|
+
return ring;
|
|
63
|
+
}
|
|
64
|
+
/** Drop the occurrences that are too old or too many, remembering how far the ring was cut. */
|
|
65
|
+
prune(ring, now) {
|
|
66
|
+
const { maxAgeMs, maxEvents } = this.options;
|
|
67
|
+
const oldestKept = now - maxAgeMs;
|
|
68
|
+
let dropCount = Math.max(0, ring.events.length - maxEvents);
|
|
69
|
+
while (dropCount < ring.events.length && ring.events[dropCount].publishedAt < oldestKept) dropCount += 1;
|
|
70
|
+
if (dropCount === 0) return;
|
|
71
|
+
ring.droppedThrough = ring.events[dropCount - 1].sequence;
|
|
72
|
+
ring.events.splice(0, dropCount);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
EventBuffer
|
|
77
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// libs/sdk/src/event/poll/event-poll-leases.ts
|
|
2
|
+
import { getRuntimeContext } from "@frontmcp/utils";
|
|
3
|
+
var POLL_LEASE_MIN_MS = 3e5;
|
|
4
|
+
var POLL_LEASE_INTERVALS = 5;
|
|
5
|
+
var POLL_LEASE_SWEEP_INTERVAL_MS = 6e4;
|
|
6
|
+
var MAX_POLL_LEASES = 1e4;
|
|
7
|
+
function pollLeaseMs(nextPollMs) {
|
|
8
|
+
return Math.max(POLL_LEASE_MIN_MS, POLL_LEASE_INTERVALS * nextPollMs);
|
|
9
|
+
}
|
|
10
|
+
var EventPollLeases = class {
|
|
11
|
+
/** Takes the per-owner lease limit and the logger to report lease ends with. */
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
this.logger = options.logger.child("EventPollLeases");
|
|
15
|
+
}
|
|
16
|
+
options;
|
|
17
|
+
leases = /* @__PURE__ */ new Map();
|
|
18
|
+
/** The leases whose `onSubscribe` is running, so concurrent first polls wait for it instead of calling it again. */
|
|
19
|
+
starting = /* @__PURE__ */ new Map();
|
|
20
|
+
logger;
|
|
21
|
+
sweepTimer;
|
|
22
|
+
lastSweepAt = 0;
|
|
23
|
+
/** How many leases are alive. */
|
|
24
|
+
get size() {
|
|
25
|
+
return this.leases.size;
|
|
26
|
+
}
|
|
27
|
+
/** Whether a new lease would exceed what one owner (the anonymous callers count as one), or the process, may hold. */
|
|
28
|
+
isFull(principalKey) {
|
|
29
|
+
if (this.leases.size >= MAX_POLL_LEASES) return true;
|
|
30
|
+
let held = 0;
|
|
31
|
+
for (const lease of this.leases.values()) {
|
|
32
|
+
if (lease.principalKey === principalKey) held += 1;
|
|
33
|
+
}
|
|
34
|
+
return held >= this.options.maxPerPrincipal;
|
|
35
|
+
}
|
|
36
|
+
/** Whether the subscription already has a lease, or is getting one. */
|
|
37
|
+
has(subscriptionId) {
|
|
38
|
+
return this.leases.has(subscriptionId) || this.starting.has(subscriptionId);
|
|
39
|
+
}
|
|
40
|
+
/** Renew the lease of a poll, or start it: a new lease calls the event's `onSubscribe` first. */
|
|
41
|
+
async renew(request) {
|
|
42
|
+
const { subscription, leaseMs } = request;
|
|
43
|
+
const now = Date.now();
|
|
44
|
+
this.sweepIfDue(now);
|
|
45
|
+
const lease = this.leases.get(subscription.id);
|
|
46
|
+
if (lease) {
|
|
47
|
+
lease.expiresAt = now + leaseMs;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const pending = this.starting.get(subscription.id);
|
|
51
|
+
if (pending) return pending;
|
|
52
|
+
const start = this.subscribe(request, now).finally(() => this.starting.delete(subscription.id));
|
|
53
|
+
this.starting.set(subscription.id, start);
|
|
54
|
+
return start;
|
|
55
|
+
}
|
|
56
|
+
/** Call the event's `onSubscribe`, then keep the lease. */
|
|
57
|
+
async subscribe(request, now) {
|
|
58
|
+
const { subscription, context, leaseMs } = request;
|
|
59
|
+
await context.onSubscribe?.(request.arguments, subscription);
|
|
60
|
+
this.leases.set(subscription.id, {
|
|
61
|
+
subscription,
|
|
62
|
+
arguments: request.arguments,
|
|
63
|
+
principalKey: request.principalKey,
|
|
64
|
+
expiresAt: now + leaseMs,
|
|
65
|
+
end: async (reason) => {
|
|
66
|
+
await context.onUnsubscribe?.(request.arguments, subscription, reason);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/** End every lease no poll renewed in time. */
|
|
71
|
+
async sweep(now = Date.now()) {
|
|
72
|
+
this.lastSweepAt = now;
|
|
73
|
+
for (const [subscriptionId, lease] of this.leases) {
|
|
74
|
+
if (lease.expiresAt > now) continue;
|
|
75
|
+
this.leases.delete(subscriptionId);
|
|
76
|
+
await this.end(lease, "expired");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** Look for lapsed leases on a timer, where the process is long-lived. */
|
|
80
|
+
start() {
|
|
81
|
+
const { runtime, deployment } = getRuntimeContext();
|
|
82
|
+
if (deployment === "serverless" || runtime === "edge" || runtime === "browser") return;
|
|
83
|
+
this.sweepTimer = setInterval(() => this.sweepInBackground(Date.now()), POLL_LEASE_SWEEP_INTERVAL_MS);
|
|
84
|
+
this.sweepTimer.unref?.();
|
|
85
|
+
}
|
|
86
|
+
/** Stop the timer and forget the leases: a restart starts them again at the next poll. */
|
|
87
|
+
stop() {
|
|
88
|
+
if (this.sweepTimer) clearInterval(this.sweepTimer);
|
|
89
|
+
this.sweepTimer = void 0;
|
|
90
|
+
this.leases.clear();
|
|
91
|
+
}
|
|
92
|
+
/** Sweep in the background when the last sweep is old enough: the only sweep where no timer runs. */
|
|
93
|
+
sweepIfDue(now) {
|
|
94
|
+
if (now - this.lastSweepAt < POLL_LEASE_SWEEP_INTERVAL_MS) return;
|
|
95
|
+
this.sweepInBackground(now);
|
|
96
|
+
}
|
|
97
|
+
/** Run a sweep nobody waits for; its failure is logged. */
|
|
98
|
+
sweepInBackground(now) {
|
|
99
|
+
this.sweep(now).catch((error) => this.logger.warn("The poll lease sweep failed", error));
|
|
100
|
+
}
|
|
101
|
+
/** Tell the event a lease ended; a failure there is logged, never thrown. */
|
|
102
|
+
async end(lease, reason) {
|
|
103
|
+
try {
|
|
104
|
+
await lease.end(reason);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
const { id, name } = lease.subscription;
|
|
107
|
+
this.logger.warn(`onUnsubscribe of event "${name}" failed for poll subscription ${id}`, error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
export {
|
|
112
|
+
EventPollLeases,
|
|
113
|
+
MAX_POLL_LEASES,
|
|
114
|
+
POLL_LEASE_INTERVALS,
|
|
115
|
+
POLL_LEASE_MIN_MS,
|
|
116
|
+
POLL_LEASE_SWEEP_INTERVAL_MS,
|
|
117
|
+
pollLeaseMs
|
|
118
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// libs/sdk/src/event/publish-endpoint/event-publish-endpoint.ts
|
|
2
|
+
import { normalizeScopeBase } from "../../common/index.mjs";
|
|
3
|
+
import { EventPublishEndpointError } from "../../errors/index.mjs";
|
|
4
|
+
import { matchRoutePath } from "../../flows/flow.http-path.mjs";
|
|
5
|
+
import { assertEntryAuthorities } from "../../front-mcp/authorities-rules.check.mjs";
|
|
6
|
+
import { servedHealthPaths } from "../../health/health.routes.mjs";
|
|
7
|
+
import {
|
|
8
|
+
assertNotReserved,
|
|
9
|
+
computeReservedPaths,
|
|
10
|
+
ReservedRouteCollisionError
|
|
11
|
+
} from "../../server/custom-routes.helper.mjs";
|
|
12
|
+
import { WorkflowWebhookReplayGuard } from "../../workflow/trigger/workflow-webhook.signature.mjs";
|
|
13
|
+
import EventPublishHttpFlow from "../flows/event-publish-http.flow.mjs";
|
|
14
|
+
import { openEventStorage } from "../subscription/event-subscription-store.factory.mjs";
|
|
15
|
+
import { EventPublishIdempotency } from "./event-publish-idempotency.mjs";
|
|
16
|
+
function assertPathFree(scope, path) {
|
|
17
|
+
const reserved = computeReservedPaths(scope.entryPath, scope.routeBase, servedHealthPaths(scope.metadata.health));
|
|
18
|
+
try {
|
|
19
|
+
assertNotReserved("POST", path, reserved);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (!(error instanceof ReservedRouteCollisionError)) throw error;
|
|
22
|
+
throw new EventPublishEndpointError(
|
|
23
|
+
`events.publishEndpoint.path "${path}" is on the reserved FrontMCP path "${error.reserved}": choose another path`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const routes = [...scope.httpRouteTable?.routes ?? [], ...scope.metadata.http?.routes ?? []];
|
|
27
|
+
const taken = routes.find(
|
|
28
|
+
(route) => route.method.toUpperCase() === "POST" && matchRoutePath(route.path, path) !== void 0
|
|
29
|
+
);
|
|
30
|
+
if (taken) {
|
|
31
|
+
throw new EventPublishEndpointError(
|
|
32
|
+
`events.publishEndpoint.path "${path}" is already served by the route POST ${taken.path}: choose another path`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function enablePublishEndpoint(args) {
|
|
37
|
+
const { scope, eventRegistry, identifiesCallers, keyPrefix, logger } = args;
|
|
38
|
+
const { secret, authorities, path: configuredPath } = eventRegistry.config.publishEndpoint;
|
|
39
|
+
const { store: storeConfig } = eventRegistry.config;
|
|
40
|
+
if (!secret && !identifiesCallers) {
|
|
41
|
+
throw new EventPublishEndpointError(
|
|
42
|
+
"the server runs in public auth mode, so nothing tells who publishes. Set events.publishEndpoint.secret (at least 32 characters) for signed requests, or configure an auth mode that signs callers in."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (authorities !== void 0) {
|
|
46
|
+
assertEntryAuthorities(scope.authoritiesEngine, scope.authoritiesContextBuilder, [
|
|
47
|
+
{ label: "events.publishEndpoint", authorities }
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
const path = `${normalizeScopeBase(scope.routeBase)}${configuredPath}`;
|
|
51
|
+
assertPathFree(scope, path);
|
|
52
|
+
let storage = eventRegistry.storage;
|
|
53
|
+
if (!storage) {
|
|
54
|
+
const ownStorage = await openEventStorage({ redis: storeConfig?.redis, sqlite: storeConfig?.sqlite, keyPrefix });
|
|
55
|
+
scope.onDispose(() => ownStorage.disconnect());
|
|
56
|
+
storage = ownStorage;
|
|
57
|
+
}
|
|
58
|
+
eventRegistry.publishEndpoint = {
|
|
59
|
+
path,
|
|
60
|
+
secret,
|
|
61
|
+
authorities,
|
|
62
|
+
replays: new WorkflowWebhookReplayGuard(),
|
|
63
|
+
idempotency: new EventPublishIdempotency(storage, scope.id)
|
|
64
|
+
};
|
|
65
|
+
await scope.registryFlows(EventPublishHttpFlow);
|
|
66
|
+
logger.info(`Events can be published over HTTP: POST ${path} (${secret ? "signed requests" : "bearer callers"})`);
|
|
67
|
+
if (!secret && authorities === void 0) {
|
|
68
|
+
logger.warn(
|
|
69
|
+
`POST ${path} lets every signed-in caller publish every event. Set events.publishEndpoint.authorities to name who may publish.`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
enablePublishEndpoint
|
|
75
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// libs/sdk/src/event/publish-endpoint/event-publish-idempotency.ts
|
|
2
|
+
import { randomUUID, sha256Hex } from "@frontmcp/utils";
|
|
3
|
+
var PUBLISH_IDEMPOTENCY_WINDOW_SECONDS = 600;
|
|
4
|
+
var PUBLISH_CLAIM_SECONDS = 60;
|
|
5
|
+
var RECORD_PREFIX = "published:";
|
|
6
|
+
function pendingRecordOf(token) {
|
|
7
|
+
return JSON.stringify({ pending: token });
|
|
8
|
+
}
|
|
9
|
+
function isPending(record) {
|
|
10
|
+
return "pending" in record;
|
|
11
|
+
}
|
|
12
|
+
var EventPublishIdempotency = class {
|
|
13
|
+
/** Takes the events storage the claims and answers are kept in, and the scope whose endpoint publishes. */
|
|
14
|
+
constructor(storage, scopeId) {
|
|
15
|
+
this.storage = storage;
|
|
16
|
+
this.scopeId = scopeId;
|
|
17
|
+
}
|
|
18
|
+
storage;
|
|
19
|
+
scopeId;
|
|
20
|
+
/** Claim an `eventId` of an event for this request, or learn what became of the request that claimed it. */
|
|
21
|
+
async claim(eventName, eventId) {
|
|
22
|
+
const key = this.keyOf(eventName, eventId);
|
|
23
|
+
const token = randomUUID();
|
|
24
|
+
await this.storage.set(key, pendingRecordOf(token), {
|
|
25
|
+
ttlSeconds: PUBLISH_CLAIM_SECONDS,
|
|
26
|
+
ifNotExists: true
|
|
27
|
+
});
|
|
28
|
+
const stored = await this.storage.get(key);
|
|
29
|
+
if (stored === null) return { state: "in-flight" };
|
|
30
|
+
const record = JSON.parse(stored);
|
|
31
|
+
if (!isPending(record)) return { state: "published", result: record };
|
|
32
|
+
return record.pending === token ? { state: "claimed", token } : { state: "in-flight" };
|
|
33
|
+
}
|
|
34
|
+
/** Keep the answer of a publish for the window, unless its claim expired and another request holds the eventId. */
|
|
35
|
+
async complete(eventName, eventId, token, result) {
|
|
36
|
+
const key = this.keyOf(eventName, eventId);
|
|
37
|
+
const answer = JSON.stringify(result);
|
|
38
|
+
if (!await this.storage.setIfEquals(key, pendingRecordOf(token), answer)) return;
|
|
39
|
+
await this.storage.expireIfEquals(key, answer, PUBLISH_IDEMPOTENCY_WINDOW_SECONDS);
|
|
40
|
+
}
|
|
41
|
+
/** Give a claim back after its publish failed, so the sender's retry publishes; a newer claim is left alone. */
|
|
42
|
+
async release(eventName, eventId, token) {
|
|
43
|
+
await this.storage.deleteIfEquals(this.keyOf(eventName, eventId), pendingRecordOf(token));
|
|
44
|
+
}
|
|
45
|
+
/** The storage key of one `eventId` of one event of one scope; hashed, so no id can shape a key. */
|
|
46
|
+
keyOf(eventName, eventId) {
|
|
47
|
+
return RECORD_PREFIX + sha256Hex(JSON.stringify([this.scopeId, eventName, eventId])).slice(0, 40);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
EventPublishIdempotency,
|
|
52
|
+
PUBLISH_CLAIM_SECONDS,
|
|
53
|
+
PUBLISH_IDEMPOTENCY_WINDOW_SECONDS
|
|
54
|
+
};
|