@frontmcp/sdk 1.13.1 → 1.14.0-rc.1
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/agent/agent.instance.d.ts +4 -0
- package/agent/agent.instance.d.ts.map +1 -1
- package/agent/agent.scope.d.ts +3 -0
- package/agent/agent.scope.d.ts.map +1 -1
- package/agent/flows/call-agent.flow.d.ts.map +1 -1
- package/app/instances/app.local.instance.d.ts.map +1 -1
- package/app/lazy/lazy-placeholders.d.ts +6 -9
- package/app/lazy/lazy-placeholders.d.ts.map +1 -1
- package/auth/auth-ui/auth-ui.contract.d.ts +4 -1
- package/auth/auth-ui/auth-ui.contract.d.ts.map +1 -1
- package/auth/auth-ui/auth-ui.render.d.ts +5 -2
- package/auth/auth-ui/auth-ui.render.d.ts.map +1 -1
- package/auth/auth-ui/index.d.ts +1 -1
- package/auth/auth-ui/index.d.ts.map +1 -1
- package/auth/authorized-apps.utils.d.ts +2 -0
- package/auth/authorized-apps.utils.d.ts.map +1 -1
- package/auth/client-display-name.d.ts +52 -0
- package/auth/client-display-name.d.ts.map +1 -0
- package/auth/federated-steps.d.ts.map +1 -1
- package/auth/flows/oauth.auth-ui.flow.d.ts +1 -1
- package/auth/flows/oauth.authorize.flow.d.ts +7 -3
- package/auth/flows/oauth.authorize.flow.d.ts.map +1 -1
- package/auth/flows/oauth.callback.flow.d.ts +3 -8
- package/auth/flows/oauth.callback.flow.d.ts.map +1 -1
- package/auth/flows/oauth.connect.flow.d.ts +1 -1
- package/auth/flows/oauth.provider-callback.flow.d.ts +9 -2
- package/auth/flows/oauth.provider-callback.flow.d.ts.map +1 -1
- package/auth/flows/oauth.register.flow.d.ts +24 -5
- package/auth/flows/oauth.register.flow.d.ts.map +1 -1
- package/auth/flows/oauth.token.flow.d.ts +1 -1
- package/auth/flows/oauth.userinfo.flow.d.ts +1 -1
- package/auth/flows/session.verify.flow.d.ts +20 -4
- package/auth/flows/session.verify.flow.d.ts.map +1 -1
- package/auth/flows/well-known.jwks.flow.d.ts +3 -3
- package/auth/flows/well-known.oauth-authorization-server.flow.d.ts +2 -2
- package/auth/flows/well-known.prm.flow.d.ts +5 -1
- package/auth/flows/well-known.prm.flow.d.ts.map +1 -1
- package/auth/instances/instance.local-primary-auth.d.ts +12 -3
- package/auth/instances/instance.local-primary-auth.d.ts.map +1 -1
- package/auth/instances/instance.remote-primary-auth.d.ts +2 -0
- package/auth/instances/instance.remote-primary-auth.d.ts.map +1 -1
- package/auth/session/session-store.factory.d.ts.map +1 -1
- package/browser/agent/agent.instance.mjs +16 -0
- package/browser/agent/agent.scope.mjs +9 -0
- package/browser/agent/flows/call-agent.flow.mjs +3 -1
- package/browser/app/instances/app.local.instance.mjs +6 -1
- package/browser/app/lazy/lazy-placeholders.mjs +3 -3
- package/browser/auth/auth-ui/auth-ui.render.mjs +9 -8
- package/browser/auth/auth-ui/index.mjs +4 -2
- package/browser/auth/authorized-apps.utils.mjs +15 -0
- package/browser/auth/client-display-name.mjs +62 -0
- package/browser/auth/federated-steps.mjs +3 -1
- package/browser/auth/flows/oauth.authorize.flow.mjs +39 -17
- package/browser/auth/flows/oauth.callback.flow.mjs +39 -34
- package/browser/auth/flows/oauth.connect.flow.mjs +1 -1
- package/browser/auth/flows/oauth.provider-callback.flow.mjs +84 -15
- package/browser/auth/flows/oauth.register.flow.mjs +9 -24
- package/browser/auth/flows/session.verify.flow.mjs +31 -12
- package/browser/auth/flows/well-known.prm.flow.mjs +22 -3
- package/browser/auth/instances/instance.local-primary-auth.mjs +63 -19
- package/browser/auth/instances/instance.remote-primary-auth.mjs +20 -0
- package/browser/auth/session/session-store.factory.mjs +15 -36
- package/browser/builtin/authorities/authorities-input.mjs +12 -0
- package/browser/common/decorators/front-mcp.decorator.mjs +2 -1
- package/browser/common/decorators/http-route.decorator.mjs +13 -1
- package/browser/common/index.mjs +3 -3
- package/browser/common/interfaces/server.interface.mjs +4 -0
- package/browser/common/metadata/duty.metadata.mjs +29 -6
- package/browser/common/metadata/event.metadata.mjs +2 -1
- package/browser/common/metadata/front-mcp.metadata.mjs +18 -1
- package/browser/common/metadata/index.mjs +1 -1
- package/browser/common/metadata/materialized.metadata.mjs +13 -0
- package/browser/common/metadata/resource.metadata.mjs +6 -5
- package/browser/common/metadata/workflow.metadata.mjs +1 -0
- package/browser/common/tokens/front-mcp.tokens.mjs +3 -0
- package/browser/common/tokens/resource.tokens.mjs +1 -0
- package/browser/common/tokens/workflow.tokens.mjs +1 -0
- package/browser/common/types/auth/session.types.mjs +2 -0
- package/browser/common/types/index.mjs +1 -1
- package/browser/common/types/options/http/schema.mjs +26 -2
- package/browser/common/types/options/index.mjs +1 -1
- package/browser/common/types/options/redis/connection.mjs +19 -0
- package/browser/common/types/options/redis/index.mjs +12 -0
- package/browser/common/types/options/redis/schema.mjs +145 -12
- package/browser/common/types/options/skills-http/schema.mjs +18 -0
- package/browser/common/types/options/transport/schema.mjs +21 -1
- package/browser/common/utils/auth-info.utils.mjs +17 -3
- package/browser/common/utils/guard.utils.mjs +3 -2
- package/browser/common/utils/index.mjs +2 -1
- package/browser/completion/flows/complete.flow.mjs +13 -7
- package/browser/direct/direct-server.mjs +15 -11
- package/browser/duty/duty.lifecycle.mjs +32 -5
- package/browser/duty/duty.runner.mjs +3 -1
- package/browser/duty/lease-holder.mjs +50 -3
- package/browser/duty/lease-store.mjs +9 -6
- package/browser/elicitation/flows/elicitation-request.flow.mjs +7 -1
- package/browser/elicitation/flows/elicitation-result.flow.mjs +8 -2
- package/browser/elicitation/questions/question-store.factory.mjs +2 -5
- package/browser/elicitation/store/elicitation-store.factory.mjs +11 -4
- package/browser/errors/browser-entry-point.errors.mjs +1 -0
- package/browser/errors/duty.errors.mjs +9 -0
- package/browser/errors/index.mjs +14 -2
- package/browser/errors/job.errors.mjs +29 -4
- package/browser/errors/mcp.error.mjs +61 -8
- package/browser/errors/provider.errors.mjs +18 -0
- package/browser/errors/transport.errors.mjs +38 -1
- package/browser/event/delivery/event-outbox.mjs +43 -9
- package/browser/event/event-gates.mjs +6 -2
- package/browser/event/event-scope.helper.mjs +8 -2
- package/browser/event/event-subscription-info.mjs +55 -0
- package/browser/event/event.registry.mjs +18 -0
- package/browser/event/flows/event-ended.flow.mjs +95 -0
- package/browser/event/flows/event-poll.flow.mjs +3 -1
- package/browser/event/flows/event-publish.flow.mjs +1 -0
- package/browser/event/flows/event-subscribe.flow.mjs +2 -9
- package/browser/event/flows/event-unsubscribe.flow.mjs +10 -1
- package/browser/event/poll/event-poll-leases.mjs +15 -3
- package/browser/event/replay/event-replays.mjs +2 -0
- package/browser/event/stream/event-stream.mjs +8 -0
- package/browser/event/stream/event-streams.mjs +22 -6
- package/browser/event/subscription/event-subscription-store.factory.mjs +3 -4
- package/browser/event/subscription/event-subscription-termination.mjs +2 -0
- package/browser/event/subscription/event-subscription.store.mjs +11 -1
- package/browser/event/subscription/event-subscriptions.mjs +21 -2
- package/browser/front-mcp/front-mcp.mjs +51 -4
- package/browser/ha/ha-manager.mjs +2 -1
- package/browser/ha/ha-redis-client.mjs +22 -0
- package/browser/ha/heartbeat.service.mjs +2 -1
- package/browser/ha/index.mjs +2 -0
- package/browser/ha/notification-relay.mjs +11 -3
- package/browser/http-route/flows/http.route.flow.mjs +148 -14
- package/browser/http-route/http-route.table.mjs +94 -21
- package/browser/http-route/people-session-store.mjs +48 -0
- package/browser/http-route/people-sign-in.routes.mjs +47 -5
- package/browser/http-route/sse-route.stream.mjs +19 -8
- package/browser/index.cjs +23016 -18521
- package/browser/index.mjs +32 -4
- package/browser/job/execution/job-execution.manager.mjs +293 -84
- package/browser/job/flows/execute-job.flow.mjs +6 -4
- package/browser/job/index.mjs +3 -1
- package/browser/job/job-admission.mjs +284 -2
- package/browser/job/job-attempt.mjs +2 -1
- package/browser/job/job-run-access.mjs +20 -0
- package/browser/job/job-scope.helper.mjs +37 -10
- package/browser/job/runner/detached-job.worker.mjs +71 -10
- package/browser/job/runner/job-runner.mjs +27 -1
- package/browser/job/store/job-definition-store.factory.mjs +13 -12
- package/browser/job/store/job-state-store.factory.mjs +14 -5
- package/browser/job/store/memory-job-state.store.mjs +91 -7
- package/browser/job/store/redis-job-state.store.mjs +39 -6
- package/browser/job/store/storage-job-state.store.mjs +35 -2
- package/browser/job/tools/cancel-job.tool.mjs +2 -2
- package/browser/job/tools/register-job.tool.mjs +5 -2
- package/browser/job/tools/remove-job.tool.mjs +9 -0
- package/browser/job/tools/update-job.tool.mjs +8 -0
- package/browser/notification/notification.service.mjs +22 -4
- package/browser/prompt/flows/get-prompt.flow.mjs +10 -3
- package/browser/prompt/flows/prompts-list.flow.mjs +7 -2
- package/browser/provider/borrow-providers.mjs +40 -0
- package/browser/provider/container-handle.mjs +10 -0
- package/browser/provider/create-container.mjs +25 -3
- package/browser/provider/provider.registry.mjs +43 -6
- package/browser/remote-mcp/remote-oauth.mjs +43 -13
- package/browser/resource/flows/read-resource.flow.mjs +15 -4
- package/browser/resource/flows/resource-templates-list.flow.mjs +7 -2
- package/browser/resource/flows/resources-list.flow.mjs +7 -2
- package/browser/resource/flows/subscribe-resource.flow.mjs +21 -5
- package/browser/resource/materialized/materialized-resource.context.mjs +3 -1
- package/browser/resource/materialized/materialized-resources.mjs +85 -29
- package/browser/resource/materialized/resource-store.mjs +352 -29
- package/browser/resource/resource.events.mjs +12 -1
- package/browser/resource/resource.registry.mjs +92 -3
- package/browser/scope/flows/http.request.flow.mjs +52 -3
- package/browser/scope/http-scope.helper.mjs +2 -1
- package/browser/scope/scope.instance.mjs +14 -16
- package/browser/server/custom-routes.helper.mjs +57 -6
- package/browser/server/security/host-validation.mjs +4 -1
- package/browser/server/security/resolve-allowed-hosts.mjs +26 -2
- package/browser/server/security/same-origin.mjs +5 -5
- package/browser/server/server.instance.mjs +77 -6
- package/browser/skill/cache/skill-http-cache.catalog.mjs +7 -6
- package/browser/skill/cache/skill-http-cache.factory.mjs +16 -19
- package/browser/skill/cache/skill-http-cache.mjs +14 -4
- package/browser/skill/flows/http/llm-full-txt.flow.mjs +16 -5
- package/browser/skill/flows/http/llm-txt.flow.mjs +1 -0
- package/browser/skill/flows/http/skills-api.flow.mjs +6 -5
- package/browser/skill/flows/load-skill.flow.mjs +9 -4
- package/browser/skill/skill-filter.helper.mjs +41 -4
- package/browser/skill/skill-http.utils.mjs +8 -8
- package/browser/subsystems.mjs +21 -2
- package/browser/surface/entry-enabled.mjs +22 -6
- package/browser/surface/index.mjs +8 -2
- package/browser/surface/live-surface.mjs +63 -3
- package/browser/task/helpers/task-run-context.mjs +12 -0
- package/browser/task/helpers/task-runner.mjs +2 -0
- package/browser/task/store/storage-task.store.mjs +1 -4
- package/browser/task/store/task-store.factory.mjs +2 -3
- package/browser/task/task.types.mjs +2 -0
- package/browser/tool/flows/call-tool.flow.mjs +59 -20
- package/browser/tool/flows/tools-list.flow.mjs +2 -2
- package/browser/tool/ui/ui-shared.mjs +5 -1
- package/browser/tool/ui/widget-enabled.mjs +11 -0
- package/browser/tool/undeclared-arguments-message.mjs +16 -12
- package/browser/tool/undeclared-arguments.mjs +41 -1
- package/browser/transport/adapters/streamable-http-transport.mjs +4 -0
- package/browser/transport/adapters/transport.local.adapter.mjs +26 -21
- package/browser/transport/adapters/transport.sse.adapter.mjs +20 -4
- package/browser/transport/adapters/transport.streamable-http.adapter.mjs +10 -2
- package/browser/transport/bus/redis-transport-bus.mjs +83 -28
- package/browser/transport/channel-signature.mjs +40 -0
- package/browser/transport/event-stores/redis.event-store.mjs +14 -27
- package/browser/transport/flows/handle.mcp-20260728.flow.mjs +10 -4
- package/browser/transport/flows/handle.streamable-http.flow.mjs +17 -10
- package/browser/transport/mcp-20260728/client/index.mjs +1 -1
- package/browser/transport/mcp-20260728/client/mcp-stateless.client.mjs +77 -15
- package/browser/transport/mcp-20260728/index.mjs +1 -1
- package/browser/transport/mcp-20260728/result-decorator.mjs +14 -7
- package/browser/transport/mcp-20260728/subscriptions.mjs +47 -7
- package/browser/transport/mcp-handlers/index.mjs +11 -2
- package/browser/transport/relay/relay-scope.helper.mjs +34 -6
- package/browser/transport/session-end-channel.mjs +199 -0
- package/browser/transport/stream-keep-alive.mjs +70 -0
- package/browser/transport/transport.local.mjs +3 -0
- package/browser/transport/transport.registry.mjs +361 -28
- package/browser/transport/web-fetch-handler.mjs +64 -4
- package/browser/transport/web-standard-mcp.mjs +3 -1
- package/browser/utils/same-origin-fetch.utils.mjs +33 -0
- package/browser/work/index.mjs +13 -0
- package/browser/work/work-spans.mjs +55 -0
- package/browser/worker/worker.lifecycle.mjs +3 -1
- package/browser/workflow/engine/workflow-step.executor.mjs +32 -12
- package/browser/workflow/engine/workflow.engine.mjs +5 -0
- package/browser/workflow/tools/register-workflow.tool.mjs +5 -2
- package/browser/workflow/tools/remove-workflow.tool.mjs +9 -0
- package/browser/workflow/tools/update-workflow.tool.mjs +8 -0
- package/builtin/authorities/authorities-input.d.ts +3 -0
- package/builtin/authorities/authorities-input.d.ts.map +1 -0
- package/common/decorators/front-mcp.decorator.d.ts.map +1 -1
- package/common/decorators/http-route.decorator.d.ts +2 -1
- package/common/decorators/http-route.decorator.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/http-route.interface.d.ts +9 -1
- package/common/interfaces/http-route.interface.d.ts.map +1 -1
- package/common/interfaces/server.interface.d.ts +2 -0
- package/common/interfaces/server.interface.d.ts.map +1 -1
- package/common/metadata/agent.metadata.d.ts +2 -2
- package/common/metadata/app.metadata.d.ts +508 -52
- package/common/metadata/app.metadata.d.ts.map +1 -1
- package/common/metadata/duty.metadata.d.ts +41 -11
- package/common/metadata/duty.metadata.d.ts.map +1 -1
- package/common/metadata/enabled.metadata.d.ts +32 -0
- package/common/metadata/enabled.metadata.d.ts.map +1 -1
- package/common/metadata/event.metadata.d.ts +146 -0
- package/common/metadata/event.metadata.d.ts.map +1 -1
- package/common/metadata/front-mcp.metadata.d.ts +9578 -272
- package/common/metadata/front-mcp.metadata.d.ts.map +1 -1
- package/common/metadata/http-route.metadata.d.ts +18 -3
- package/common/metadata/http-route.metadata.d.ts.map +1 -1
- package/common/metadata/job.metadata.d.ts +1 -1
- package/common/metadata/materialized.metadata.d.ts +21 -0
- package/common/metadata/materialized.metadata.d.ts.map +1 -1
- package/common/metadata/output-policy.d.ts +1 -1
- package/common/metadata/plugin.metadata.d.ts +2 -2
- package/common/metadata/resource.metadata.d.ts +8 -1
- package/common/metadata/resource.metadata.d.ts.map +1 -1
- package/common/metadata/tool.metadata.d.ts +1 -1
- package/common/metadata/worker.metadata.d.ts +4 -4
- package/common/metadata/workflow.metadata.d.ts +15 -1
- package/common/metadata/workflow.metadata.d.ts.map +1 -1
- package/common/records/job.record.d.ts +6 -0
- package/common/records/job.record.d.ts.map +1 -1
- package/common/records/workflow.record.d.ts +6 -0
- package/common/records/workflow.record.d.ts.map +1 -1
- package/common/schemas/annotated-class.schema.d.ts +1 -1
- package/common/schemas/http-output.schema.d.ts +24 -24
- package/common/tokens/front-mcp.tokens.d.ts.map +1 -1
- package/common/tokens/resource.tokens.d.ts +1 -0
- package/common/tokens/resource.tokens.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/types/auth/session.types.d.ts +12 -1
- package/common/types/auth/session.types.d.ts.map +1 -1
- package/common/types/options/auth/index.d.ts +1 -1
- package/common/types/options/auth/index.d.ts.map +1 -1
- package/common/types/options/elicitation/schema.d.ts +137 -0
- package/common/types/options/elicitation/schema.d.ts.map +1 -1
- package/common/types/options/http/index.d.ts +1 -1
- package/common/types/options/http/index.d.ts.map +1 -1
- package/common/types/options/http/interfaces.d.ts +79 -2
- package/common/types/options/http/interfaces.d.ts.map +1 -1
- package/common/types/options/http/schema.d.ts +15 -0
- package/common/types/options/http/schema.d.ts.map +1 -1
- package/common/types/options/redis/connection.d.ts +18 -0
- package/common/types/options/redis/connection.d.ts.map +1 -0
- package/common/types/options/redis/index.d.ts +7 -3
- package/common/types/options/redis/index.d.ts.map +1 -1
- package/common/types/options/redis/interfaces.d.ts +54 -2
- package/common/types/options/redis/interfaces.d.ts.map +1 -1
- package/common/types/options/redis/schema.d.ts +412 -2
- package/common/types/options/redis/schema.d.ts.map +1 -1
- package/common/types/options/skills-http/interfaces.d.ts +7 -0
- package/common/types/options/skills-http/interfaces.d.ts.map +1 -1
- package/common/types/options/skills-http/schema.d.ts +19 -0
- package/common/types/options/skills-http/schema.d.ts.map +1 -1
- package/common/types/options/transport/index.d.ts +1 -1
- package/common/types/options/transport/index.d.ts.map +1 -1
- package/common/types/options/transport/interfaces.d.ts +56 -0
- package/common/types/options/transport/interfaces.d.ts.map +1 -1
- package/common/types/options/transport/schema.d.ts +551 -0
- package/common/types/options/transport/schema.d.ts.map +1 -1
- package/common/utils/auth-info.utils.d.ts +29 -1
- package/common/utils/auth-info.utils.d.ts.map +1 -1
- package/common/utils/guard.utils.d.ts +6 -3
- package/common/utils/guard.utils.d.ts.map +1 -1
- package/common/utils/index.d.ts +1 -0
- package/common/utils/index.d.ts.map +1 -1
- package/completion/flows/complete.flow.d.ts +5 -1
- package/completion/flows/complete.flow.d.ts.map +1 -1
- package/context/frontmcp-context.provider.d.ts +1 -1
- package/direct/direct-server.d.ts +4 -2
- package/direct/direct-server.d.ts.map +1 -1
- package/direct/direct.types.d.ts +7 -0
- package/direct/direct.types.d.ts.map +1 -1
- package/duty/duty.lifecycle.d.ts +1 -1
- package/duty/duty.lifecycle.d.ts.map +1 -1
- package/duty/duty.runner.d.ts +6 -1
- package/duty/duty.runner.d.ts.map +1 -1
- package/duty/lease-holder.d.ts +26 -3
- package/duty/lease-holder.d.ts.map +1 -1
- package/duty/lease-store.d.ts +2 -0
- package/duty/lease-store.d.ts.map +1 -1
- package/elicitation/elicitation.types.d.ts +2 -0
- package/elicitation/elicitation.types.d.ts.map +1 -1
- package/elicitation/flows/elicitation-request.flow.d.ts +2 -0
- package/elicitation/flows/elicitation-request.flow.d.ts.map +1 -1
- package/elicitation/flows/elicitation-result.flow.d.ts +3 -1
- package/elicitation/flows/elicitation-result.flow.d.ts.map +1 -1
- package/elicitation/questions/question-store.factory.d.ts.map +1 -1
- package/elicitation/store/elicitation-store.factory.d.ts.map +1 -1
- package/elicitation/store/elicitation.store.d.ts +2 -0
- package/elicitation/store/elicitation.store.d.ts.map +1 -1
- package/errors/browser-entry-point.errors.d.ts +1 -0
- package/errors/browser-entry-point.errors.d.ts.map +1 -1
- package/errors/duty.errors.d.ts +4 -0
- package/errors/duty.errors.d.ts.map +1 -1
- package/errors/index.d.ts +3 -3
- package/errors/index.d.ts.map +1 -1
- package/errors/job.errors.d.ts +22 -4
- package/errors/job.errors.d.ts.map +1 -1
- package/errors/mcp.error.d.ts +15 -1
- package/errors/mcp.error.d.ts.map +1 -1
- package/errors/provider.errors.d.ts +11 -0
- package/errors/provider.errors.d.ts.map +1 -1
- package/errors/transport.errors.d.ts +33 -0
- package/errors/transport.errors.d.ts.map +1 -1
- package/esm/index.mjs +59 -54
- package/event/delivery/event-outbox.d.ts +15 -2
- package/event/delivery/event-outbox.d.ts.map +1 -1
- package/event/event-gates.d.ts +6 -1
- package/event/event-gates.d.ts.map +1 -1
- package/event/event-scope.helper.d.ts.map +1 -1
- package/event/event-subscription-info.d.ts +72 -0
- package/event/event-subscription-info.d.ts.map +1 -0
- package/event/event.registry.d.ts +7 -0
- package/event/event.registry.d.ts.map +1 -1
- package/event/flows/event-ended.flow.d.ts +57 -0
- package/event/flows/event-ended.flow.d.ts.map +1 -0
- package/event/flows/event-poll.flow.d.ts.map +1 -1
- package/event/flows/event-publish-http.flow.d.ts +1 -1
- package/event/flows/event-publish.flow.d.ts.map +1 -1
- package/event/flows/event-subscribe.flow.d.ts.map +1 -1
- package/event/flows/event-unsubscribe.flow.d.ts +4 -1
- package/event/flows/event-unsubscribe.flow.d.ts.map +1 -1
- package/event/index.d.ts +4 -2
- package/event/index.d.ts.map +1 -1
- package/event/poll/event-poll-leases.d.ts +7 -2
- package/event/poll/event-poll-leases.d.ts.map +1 -1
- package/event/replay/event-replays.d.ts.map +1 -1
- package/event/stream/event-stream.d.ts +4 -0
- package/event/stream/event-stream.d.ts.map +1 -1
- package/event/stream/event-streams.d.ts +8 -2
- package/event/stream/event-streams.d.ts.map +1 -1
- package/event/subscription/event-subscription-store.factory.d.ts.map +1 -1
- package/event/subscription/event-subscription-termination.d.ts +4 -1
- package/event/subscription/event-subscription-termination.d.ts.map +1 -1
- package/event/subscription/event-subscription.store.d.ts +6 -0
- package/event/subscription/event-subscription.store.d.ts.map +1 -1
- package/event/subscription/event-subscriptions.d.ts +21 -3
- package/event/subscription/event-subscriptions.d.ts.map +1 -1
- package/front-mcp/front-mcp.d.ts +7 -2
- package/front-mcp/front-mcp.d.ts.map +1 -1
- package/ha/ha-manager.d.ts.map +1 -1
- package/ha/ha-redis-client.d.ts +16 -0
- package/ha/ha-redis-client.d.ts.map +1 -0
- package/ha/heartbeat.service.d.ts +4 -2
- package/ha/heartbeat.service.d.ts.map +1 -1
- package/ha/index.d.ts +2 -1
- package/ha/index.d.ts.map +1 -1
- package/ha/notification-relay.d.ts +8 -3
- package/ha/notification-relay.d.ts.map +1 -1
- package/ha/relay-messages.d.ts +23 -4
- package/ha/relay-messages.d.ts.map +1 -1
- package/http-route/flows/http.route.flow.d.ts +23 -4
- package/http-route/flows/http.route.flow.d.ts.map +1 -1
- package/http-route/http-route.table.d.ts +15 -4
- package/http-route/http-route.table.d.ts.map +1 -1
- package/http-route/people-session-store.d.ts +26 -0
- package/http-route/people-session-store.d.ts.map +1 -0
- package/http-route/people-sign-in.routes.d.ts +12 -2
- package/http-route/people-sign-in.routes.d.ts.map +1 -1
- package/http-route/sse-route.stream.d.ts +6 -1
- package/http-route/sse-route.stream.d.ts.map +1 -1
- package/index.d.ts +25 -16
- package/index.d.ts.map +1 -1
- package/index.js +65 -60
- package/job/execution/job-execution.manager.d.ts +73 -7
- package/job/execution/job-execution.manager.d.ts.map +1 -1
- package/job/flows/execute-job.flow.d.ts.map +1 -1
- package/job/index.d.ts +2 -2
- package/job/index.d.ts.map +1 -1
- package/job/job-admission.d.ts +81 -2
- package/job/job-admission.d.ts.map +1 -1
- package/job/job-attempt.d.ts +2 -2
- package/job/job-attempt.d.ts.map +1 -1
- package/job/job-run-access.d.ts +14 -0
- package/job/job-run-access.d.ts.map +1 -1
- package/job/job-scope.helper.d.ts +20 -0
- package/job/job-scope.helper.d.ts.map +1 -1
- package/job/runner/detached-job.worker.d.ts +9 -0
- package/job/runner/detached-job.worker.d.ts.map +1 -1
- package/job/runner/job-runner.d.ts +18 -0
- package/job/runner/job-runner.d.ts.map +1 -1
- package/job/store/job-definition-store.factory.d.ts +5 -1
- package/job/store/job-definition-store.factory.d.ts.map +1 -1
- package/job/store/job-state-store.factory.d.ts +5 -1
- package/job/store/job-state-store.factory.d.ts.map +1 -1
- package/job/store/job-state.interface.d.ts +16 -0
- package/job/store/job-state.interface.d.ts.map +1 -1
- package/job/store/memory-job-state.store.d.ts +33 -2
- package/job/store/memory-job-state.store.d.ts.map +1 -1
- package/job/store/redis-job-state.store.d.ts +13 -3
- package/job/store/redis-job-state.store.d.ts.map +1 -1
- package/job/store/storage-job-state.store.d.ts +4 -0
- package/job/store/storage-job-state.store.d.ts.map +1 -1
- package/job/tools/cancel-job.tool.d.ts.map +1 -1
- package/job/tools/register-job.tool.d.ts.map +1 -1
- package/job/tools/remove-job.tool.d.ts.map +1 -1
- package/job/tools/update-job.tool.d.ts.map +1 -1
- package/mcp-registry/flows/server-card.flow.d.ts +3 -3
- package/mcp-registry/flows/well-known.ai-catalog.flow.d.ts +2 -2
- package/mcp-registry/flows/well-known.mcp-registry-auth.flow.d.ts +1 -1
- package/notification/notification.service.d.ts +5 -1
- package/notification/notification.service.d.ts.map +1 -1
- package/package.json +10 -10
- package/prompt/flows/get-prompt.flow.d.ts.map +1 -1
- package/prompt/flows/prompts-list.flow.d.ts +1 -1
- package/prompt/flows/prompts-list.flow.d.ts.map +1 -1
- package/provider/borrow-providers.d.ts +15 -0
- package/provider/borrow-providers.d.ts.map +1 -0
- package/provider/container-handle.d.ts +31 -0
- package/provider/container-handle.d.ts.map +1 -0
- package/provider/create-container.d.ts +8 -2
- package/provider/create-container.d.ts.map +1 -1
- package/provider/provider.registry.d.ts +23 -4
- package/provider/provider.registry.d.ts.map +1 -1
- package/remote-mcp/remote-oauth.d.ts +3 -1
- package/remote-mcp/remote-oauth.d.ts.map +1 -1
- package/resource/flows/read-resource.flow.d.ts.map +1 -1
- package/resource/flows/resource-templates-list.flow.d.ts +1 -1
- package/resource/flows/resource-templates-list.flow.d.ts.map +1 -1
- package/resource/flows/resources-list.flow.d.ts +1 -1
- package/resource/flows/resources-list.flow.d.ts.map +1 -1
- package/resource/flows/subscribe-resource.flow.d.ts +1 -0
- package/resource/flows/subscribe-resource.flow.d.ts.map +1 -1
- package/resource/materialized/index.d.ts +1 -1
- package/resource/materialized/index.d.ts.map +1 -1
- package/resource/materialized/materialized-resource.context.d.ts +1 -0
- package/resource/materialized/materialized-resource.context.d.ts.map +1 -1
- package/resource/materialized/materialized-resources.d.ts +22 -4
- package/resource/materialized/materialized-resources.d.ts.map +1 -1
- package/resource/materialized/resource-store.d.ts +37 -3
- package/resource/materialized/resource-store.d.ts.map +1 -1
- package/resource/resource.events.d.ts +3 -0
- package/resource/resource.events.d.ts.map +1 -1
- package/resource/resource.registry.d.ts +17 -1
- package/resource/resource.registry.d.ts.map +1 -1
- package/scope/flows/http.request.flow.d.ts +8 -1
- package/scope/flows/http.request.flow.d.ts.map +1 -1
- package/scope/http-scope.helper.d.ts +1 -1
- package/scope/http-scope.helper.d.ts.map +1 -1
- package/scope/scope.instance.d.ts +2 -2
- package/scope/scope.instance.d.ts.map +1 -1
- package/server/adapters/express.host.adapter.d.ts +26 -0
- package/server/adapters/express.host.adapter.d.ts.map +1 -1
- package/server/adapters/polyfills/browser-express-host.d.ts +3 -0
- package/server/adapters/polyfills/browser-express-host.d.ts.map +1 -1
- package/server/adapters/polyfills/node-express-host.d.ts +1 -0
- package/server/adapters/polyfills/node-express-host.d.ts.map +1 -1
- package/server/adapters/user-content.listener.d.ts +30 -0
- package/server/adapters/user-content.listener.d.ts.map +1 -0
- package/server/custom-routes.helper.d.ts +19 -2
- package/server/custom-routes.helper.d.ts.map +1 -1
- package/server/security/host-validation.d.ts.map +1 -1
- package/server/security/resolve-allowed-hosts.d.ts +16 -0
- package/server/security/resolve-allowed-hosts.d.ts.map +1 -1
- package/server/security/same-origin.d.ts +2 -1
- package/server/security/same-origin.d.ts.map +1 -1
- package/server/server.instance.d.ts +11 -0
- package/server/server.instance.d.ts.map +1 -1
- package/shared/ensure-shared-server.d.ts +9 -2
- package/shared/ensure-shared-server.d.ts.map +1 -1
- package/shared/flows/shared.drain.flow.d.ts +1 -1
- package/shared/flows/shared.identify.flow.d.ts +6 -2
- package/shared/flows/shared.identify.flow.d.ts.map +1 -1
- package/shared/index.d.ts.map +1 -1
- package/shared/shared-attach.d.ts +15 -6
- package/shared/shared-attach.d.ts.map +1 -1
- package/shared/shared-embedded.d.ts +12 -2
- package/shared/shared-embedded.d.ts.map +1 -1
- package/shared/shared-endpoint.d.ts +3 -1
- package/shared/shared-endpoint.d.ts.map +1 -1
- package/shared/shared-files.d.ts +2 -0
- package/shared/shared-files.d.ts.map +1 -1
- package/shared/shared-serve.d.ts +20 -1
- package/shared/shared-serve.d.ts.map +1 -1
- package/shared/shared-server.lifecycle.d.ts +40 -10
- package/shared/shared-server.lifecycle.d.ts.map +1 -1
- package/shared/shared-server.options.d.ts +43 -6
- package/shared/shared-server.options.d.ts.map +1 -1
- package/skill/cache/skill-http-cache.catalog.d.ts +4 -4
- package/skill/cache/skill-http-cache.catalog.d.ts.map +1 -1
- package/skill/cache/skill-http-cache.d.ts +15 -2
- package/skill/cache/skill-http-cache.d.ts.map +1 -1
- package/skill/cache/skill-http-cache.factory.d.ts +12 -0
- package/skill/cache/skill-http-cache.factory.d.ts.map +1 -1
- package/skill/flows/http/llm-full-txt.flow.d.ts +1 -1
- package/skill/flows/http/llm-full-txt.flow.d.ts.map +1 -1
- package/skill/flows/http/llm-txt.flow.d.ts +1 -1
- package/skill/flows/http/llm-txt.flow.d.ts.map +1 -1
- package/skill/flows/http/skills-api.flow.d.ts +1 -1
- package/skill/flows/http/skills-api.flow.d.ts.map +1 -1
- package/skill/flows/load-skill.flow.d.ts.map +1 -1
- package/skill/skill-filter.helper.d.ts +16 -0
- package/skill/skill-filter.helper.d.ts.map +1 -1
- package/skill/skill-http.utils.d.ts +7 -1
- package/skill/skill-http.utils.d.ts.map +1 -1
- package/subsystems.d.ts +1 -1
- package/subsystems.d.ts.map +1 -1
- package/surface/entry-enabled.d.ts +23 -6
- package/surface/entry-enabled.d.ts.map +1 -1
- package/surface/index.d.ts +2 -2
- package/surface/index.d.ts.map +1 -1
- package/surface/live-surface.d.ts +32 -7
- package/surface/live-surface.d.ts.map +1 -1
- package/task/helpers/task-run-context.d.ts +5 -0
- package/task/helpers/task-run-context.d.ts.map +1 -0
- package/task/helpers/task-runner.d.ts.map +1 -1
- package/task/store/storage-task.store.d.ts.map +1 -1
- package/task/store/task-store.factory.d.ts.map +1 -1
- package/task/store/task.store.d.ts +1 -1
- package/task/store/task.store.d.ts.map +1 -1
- package/task/task.types.d.ts +1 -0
- package/task/task.types.d.ts.map +1 -1
- package/tool/flows/call-tool.flow.d.ts +10 -3
- package/tool/flows/call-tool.flow.d.ts.map +1 -1
- package/tool/flows/tools-list.flow.d.ts +1 -1
- package/tool/flows/tools-list.flow.d.ts.map +1 -1
- package/tool/ui/ui-shared.d.ts +2 -0
- package/tool/ui/ui-shared.d.ts.map +1 -1
- package/tool/ui/widget-enabled.d.ts +8 -0
- package/tool/ui/widget-enabled.d.ts.map +1 -0
- package/tool/undeclared-arguments-message.d.ts +8 -5
- package/tool/undeclared-arguments-message.d.ts.map +1 -1
- package/tool/undeclared-arguments.d.ts +6 -0
- package/tool/undeclared-arguments.d.ts.map +1 -1
- package/transport/adapters/base-sse-transport.d.ts +4 -0
- package/transport/adapters/base-sse-transport.d.ts.map +1 -1
- package/transport/adapters/polyfills/browser-sse-transport.d.ts +1 -0
- package/transport/adapters/polyfills/browser-sse-transport.d.ts.map +1 -1
- package/transport/adapters/streamable-http-transport.d.ts +4 -0
- package/transport/adapters/streamable-http-transport.d.ts.map +1 -1
- package/transport/adapters/transport.local.adapter.d.ts +3 -0
- package/transport/adapters/transport.local.adapter.d.ts.map +1 -1
- package/transport/adapters/transport.sse.adapter.d.ts +3 -0
- package/transport/adapters/transport.sse.adapter.d.ts.map +1 -1
- package/transport/adapters/transport.streamable-http.adapter.d.ts +1 -0
- package/transport/adapters/transport.streamable-http.adapter.d.ts.map +1 -1
- package/transport/bus/redis-transport-bus.d.ts +25 -4
- package/transport/bus/redis-transport-bus.d.ts.map +1 -1
- package/transport/channel-signature.d.ts +16 -0
- package/transport/channel-signature.d.ts.map +1 -0
- package/transport/event-stores/redis.event-store.d.ts +1 -1
- package/transport/event-stores/redis.event-store.d.ts.map +1 -1
- package/transport/flows/handle.mcp-20260728.flow.d.ts +2 -1
- package/transport/flows/handle.mcp-20260728.flow.d.ts.map +1 -1
- package/transport/flows/handle.streamable-http.flow.d.ts +1 -1
- package/transport/flows/handle.streamable-http.flow.d.ts.map +1 -1
- package/transport/mcp-20260728/client/mcp-stateless.client.d.ts +8 -0
- package/transport/mcp-20260728/client/mcp-stateless.client.d.ts.map +1 -1
- package/transport/mcp-20260728/result-decorator.d.ts +4 -2
- package/transport/mcp-20260728/result-decorator.d.ts.map +1 -1
- package/transport/mcp-20260728/subscriptions.d.ts +4 -0
- package/transport/mcp-20260728/subscriptions.d.ts.map +1 -1
- package/transport/mcp-handlers/index.d.ts +5 -3
- package/transport/mcp-handlers/index.d.ts.map +1 -1
- package/transport/relay/relay-scope.helper.d.ts +2 -2
- package/transport/relay/relay-scope.helper.d.ts.map +1 -1
- package/transport/session-end-channel.d.ts +81 -0
- package/transport/session-end-channel.d.ts.map +1 -0
- package/transport/stream-keep-alive.d.ts +13 -0
- package/transport/stream-keep-alive.d.ts.map +1 -0
- package/transport/transport.local.d.ts +2 -1
- package/transport/transport.local.d.ts.map +1 -1
- package/transport/transport.registry.d.ts +74 -3
- package/transport/transport.registry.d.ts.map +1 -1
- package/transport/transport.types.d.ts +6 -1
- package/transport/transport.types.d.ts.map +1 -1
- package/transport/web-fetch-handler.d.ts.map +1 -1
- package/transport/web-standard-mcp.d.ts.map +1 -1
- package/utils/same-origin-fetch.utils.d.ts +5 -0
- package/utils/same-origin-fetch.utils.d.ts.map +1 -0
- package/work/index.d.ts +2 -0
- package/work/index.d.ts.map +1 -0
- package/work/work-spans.d.ts +42 -0
- package/work/work-spans.d.ts.map +1 -0
- package/worker/worker.lifecycle.d.ts.map +1 -1
- package/workflow/engine/workflow-step.executor.d.ts +10 -3
- package/workflow/engine/workflow-step.executor.d.ts.map +1 -1
- package/workflow/engine/workflow.engine.d.ts +2 -0
- package/workflow/engine/workflow.engine.d.ts.map +1 -1
- package/workflow/tools/register-workflow.tool.d.ts.map +1 -1
- package/workflow/tools/remove-workflow.tool.d.ts.map +1 -1
- package/workflow/tools/update-workflow.tool.d.ts.map +1 -1
|
@@ -4,9 +4,55 @@ import {
|
|
|
4
4
|
createChangeFeed,
|
|
5
5
|
createStorage
|
|
6
6
|
} from "@frontmcp/utils";
|
|
7
|
-
import { InvalidResourceStoreError } from "../../errors/mcp.error.mjs";
|
|
7
|
+
import { InvalidInputError, InvalidResourceStoreError, ResourceStoreClosedError } from "../../errors/mcp.error.mjs";
|
|
8
8
|
import { refuseServerStoresInBrowser } from "../../scope/browser-stores.mjs";
|
|
9
9
|
var STORAGE_TYPES = ["memory", "redis", "sqlite"];
|
|
10
|
+
var DEFAULT_MIN_INTERVAL_MS = 50;
|
|
11
|
+
var DEFAULT_COST_FACTOR = 1;
|
|
12
|
+
var FAMILY_KEYS_KEPT = 1e3;
|
|
13
|
+
var FAMILY_KEYS_CHECKED_PER_LOOKUP = 32;
|
|
14
|
+
var PRODUCED_FAMILY_RECORD_TTL_SECONDS = 24 * 60 * 60;
|
|
15
|
+
var MAX_RESOURCE_KEY_PARAMS_LENGTH = 2048;
|
|
16
|
+
var producerOptionsSchema = z.object({
|
|
17
|
+
produce: z.custom((value) => typeof value === "function", {
|
|
18
|
+
message: "produce must be a function that returns the value"
|
|
19
|
+
}),
|
|
20
|
+
minIntervalMs: z.number().int().nonnegative().optional(),
|
|
21
|
+
costFactor: z.number().nonnegative().finite().optional()
|
|
22
|
+
}).strict();
|
|
23
|
+
function parseProducer(subject, options) {
|
|
24
|
+
const parsed = producerOptionsSchema.safeParse(options);
|
|
25
|
+
if (parsed.success) return;
|
|
26
|
+
const problems = parsed.error.issues.map((issue) => `${issue.path.join(".") || "options"}: ${issue.message}`);
|
|
27
|
+
throw new InvalidResourceStoreError(`${subject}: ${problems.join("; ")}`);
|
|
28
|
+
}
|
|
29
|
+
function isProducerOptions(options) {
|
|
30
|
+
return "produce" in options;
|
|
31
|
+
}
|
|
32
|
+
function memberName(family, params) {
|
|
33
|
+
return `${family}?${encodedParams(params)}`;
|
|
34
|
+
}
|
|
35
|
+
function encodedParams(params) {
|
|
36
|
+
const names = Object.keys(params).sort();
|
|
37
|
+
const length = names.reduce((total, name) => total + name.length + params[name].length, 0);
|
|
38
|
+
let query = "";
|
|
39
|
+
if (length <= MAX_RESOURCE_KEY_PARAMS_LENGTH) {
|
|
40
|
+
try {
|
|
41
|
+
query = names.map((name) => `${encodeURIComponent(name)}=${encodeURIComponent(params[name])}`).join("&");
|
|
42
|
+
} catch {
|
|
43
|
+
throw new InvalidInputError("The parameters of a resource key must be well-formed text");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (length > MAX_RESOURCE_KEY_PARAMS_LENGTH || query.length > MAX_RESOURCE_KEY_PARAMS_LENGTH) {
|
|
47
|
+
throw new InvalidInputError(
|
|
48
|
+
`The parameters of a resource key take at most ${MAX_RESOURCE_KEY_PARAMS_LENGTH} characters, percent-encoded`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return query;
|
|
52
|
+
}
|
|
53
|
+
function assertResourceKeyParams(params) {
|
|
54
|
+
encodedParams(params);
|
|
55
|
+
}
|
|
10
56
|
var resourceStoreOptionsSchema = z.object({
|
|
11
57
|
storage: z.object({ type: z.enum(STORAGE_TYPES) }).passthrough().optional(),
|
|
12
58
|
pollIntervalMs: z.number().int().positive().optional(),
|
|
@@ -21,22 +67,46 @@ var ResourceStore = class {
|
|
|
21
67
|
options;
|
|
22
68
|
opened;
|
|
23
69
|
connections = 0;
|
|
70
|
+
closes = 0;
|
|
24
71
|
backend = {
|
|
25
|
-
storage: async () =>
|
|
72
|
+
storage: async (epoch) => {
|
|
73
|
+
if (epoch !== void 0 && epoch !== this.closes) throw new ResourceStoreClosedError();
|
|
74
|
+
return (await this.open()).storage;
|
|
75
|
+
},
|
|
76
|
+
publish: async (topic, epoch, options) => {
|
|
77
|
+
if (epoch === void 0 || epoch === this.closes) await this.publish(topic, options);
|
|
78
|
+
},
|
|
79
|
+
epoch: () => this.closes,
|
|
26
80
|
reportError: (error) => this.options.onError?.(error)
|
|
27
81
|
};
|
|
28
82
|
key(name, options = {}) {
|
|
29
|
-
|
|
30
|
-
|
|
83
|
+
requireName("key", name);
|
|
84
|
+
if (isProducerOptions(options)) {
|
|
85
|
+
parseProducer(`key "${name}"`, options);
|
|
86
|
+
const { produce, ...throttle } = options;
|
|
87
|
+
return new ProducedKey(this, this.backend, name, produce, throttle);
|
|
31
88
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
89
|
+
return new StoredResourceKey(this, this.backend, name, initialRecordOf(name, options.initial));
|
|
90
|
+
}
|
|
91
|
+
family(name, options = {}) {
|
|
92
|
+
requireName("family", name);
|
|
93
|
+
if (isProducerOptions(options)) {
|
|
94
|
+
parseProducer(`family "${name}"`, options);
|
|
95
|
+
const { produce, ...throttle } = options;
|
|
96
|
+
const family = new KeyFamily(
|
|
97
|
+
this,
|
|
98
|
+
name,
|
|
99
|
+
(memberKey, params) => new ProducedKey(this, this.backend, memberKey, () => produce(params), throttle, {
|
|
100
|
+
ttlSeconds: PRODUCED_FAMILY_RECORD_TTL_SECONDS
|
|
101
|
+
}),
|
|
102
|
+
(memberKey, params) => new FamilyKeyHandle(family, memberKey, params)
|
|
103
|
+
);
|
|
104
|
+
return family;
|
|
38
105
|
}
|
|
39
|
-
|
|
106
|
+
const initialRecord = initialRecordOf(name, options.initial);
|
|
107
|
+
return new KeyFamily(this, name, (memberKey) => {
|
|
108
|
+
return new StoredResourceKey(this, this.backend, memberKey, initialRecord);
|
|
109
|
+
});
|
|
40
110
|
}
|
|
41
111
|
/** Call `listener` when `topic` is published, in this process or in another one that shares the storage. */
|
|
42
112
|
subscribe(topic, listener) {
|
|
@@ -54,9 +124,9 @@ var ResourceStore = class {
|
|
|
54
124
|
};
|
|
55
125
|
}
|
|
56
126
|
/** Tell the listeners of `topic`, here and in the other processes, that it changed. */
|
|
57
|
-
async publish(topic) {
|
|
127
|
+
async publish(topic, options) {
|
|
58
128
|
const { feed } = await this.open();
|
|
59
|
-
await feed.publish(topic);
|
|
129
|
+
await feed.publish(topic, options);
|
|
60
130
|
}
|
|
61
131
|
/** Open the storage and the change feed; the store stays open until each `connect()` has had its `close()`. */
|
|
62
132
|
async connect() {
|
|
@@ -75,6 +145,7 @@ var ResourceStore = class {
|
|
|
75
145
|
return;
|
|
76
146
|
}
|
|
77
147
|
this.connections = 0;
|
|
148
|
+
this.closes++;
|
|
78
149
|
const opened = this.opened;
|
|
79
150
|
this.opened = void 0;
|
|
80
151
|
if (!opened) return;
|
|
@@ -107,68 +178,125 @@ var ResourceStore = class {
|
|
|
107
178
|
return { root, storage: namespaced, feed };
|
|
108
179
|
}
|
|
109
180
|
};
|
|
181
|
+
function requireName(kind, name) {
|
|
182
|
+
if (typeof name !== "string" || name.length === 0) {
|
|
183
|
+
throw new InvalidResourceStoreError(`a ${kind} needs a name, such as ${kind}("board")`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function initialRecordOf(name, initial) {
|
|
187
|
+
try {
|
|
188
|
+
return JSON.stringify({ value: initial, revision: 0 });
|
|
189
|
+
} catch (error) {
|
|
190
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
191
|
+
throw new InvalidResourceStoreError(`the initial value of key "${name}" cannot be stored as JSON: ${reason}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function isNewSnapshot(snapshot, last) {
|
|
195
|
+
if (!last || snapshot.revision !== last.revision) return true;
|
|
196
|
+
if (snapshot.updatedAt === last.updatedAt) return false;
|
|
197
|
+
return JSON.stringify(snapshot.value) !== JSON.stringify(last.value);
|
|
198
|
+
}
|
|
110
199
|
var StoredResourceKey = class {
|
|
111
|
-
constructor(store, backend, name, initialRecord) {
|
|
200
|
+
constructor(store, backend, name, initialRecord, retention = {}) {
|
|
112
201
|
this.store = store;
|
|
113
202
|
this.backend = backend;
|
|
114
203
|
this.name = name;
|
|
115
204
|
this.initialRecord = initialRecord;
|
|
205
|
+
this.retention = retention;
|
|
116
206
|
this.recordKey = `value:${name}`;
|
|
117
207
|
}
|
|
118
208
|
store;
|
|
119
209
|
backend;
|
|
120
210
|
name;
|
|
121
211
|
initialRecord;
|
|
212
|
+
retention;
|
|
122
213
|
recordKey;
|
|
214
|
+
/** A write stored the record, but its expiry could not be set: the next read sets it. */
|
|
215
|
+
expiryPending = false;
|
|
123
216
|
async get() {
|
|
217
|
+
return await this.stored() ?? this.parse(null);
|
|
218
|
+
}
|
|
219
|
+
/** The stored record, or undefined before the first write and once it expired or was deleted. */
|
|
220
|
+
async stored() {
|
|
124
221
|
const storage = await this.backend.storage();
|
|
125
|
-
|
|
222
|
+
const raw = await storage.get(this.recordKey);
|
|
223
|
+
if (raw !== null && this.expiryPending) await this.setExpiry(storage);
|
|
224
|
+
return raw === null ? void 0 : this.parse(raw);
|
|
225
|
+
}
|
|
226
|
+
/** Give the record its expiry again; one that cannot be set stays pending for the next read or write. */
|
|
227
|
+
async setExpiry(storage) {
|
|
228
|
+
const { ttlSeconds } = this.retention;
|
|
229
|
+
if (ttlSeconds === void 0) return;
|
|
230
|
+
try {
|
|
231
|
+
await storage.expire(this.recordKey, ttlSeconds);
|
|
232
|
+
this.expiryPending = false;
|
|
233
|
+
} catch (error) {
|
|
234
|
+
this.expiryPending = true;
|
|
235
|
+
this.backend.reportError(error);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/** What a subscription reads to learn of a new revision. */
|
|
239
|
+
current() {
|
|
240
|
+
return this.get();
|
|
126
241
|
}
|
|
127
242
|
set(value) {
|
|
128
243
|
return this.update(() => value);
|
|
129
244
|
}
|
|
130
|
-
|
|
131
|
-
|
|
245
|
+
update(change) {
|
|
246
|
+
return this.write(change, false);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Store what `change` makes of the value; with `onlyIfChanged`, output with the same JSON keeps the revision. With
|
|
250
|
+
* the `epoch` it began in, a write the store closed during fails instead of opening the store again.
|
|
251
|
+
*/
|
|
252
|
+
async write(change, onlyIfChanged, epoch) {
|
|
253
|
+
const storage = await this.backend.storage(epoch);
|
|
254
|
+
const { ttlSeconds } = this.retention;
|
|
132
255
|
for (; ; ) {
|
|
133
256
|
const raw = await storage.get(this.recordKey);
|
|
134
257
|
if (raw === null) {
|
|
135
|
-
await storage.set(this.recordKey, this.initialRecord, { ifNotExists: true });
|
|
258
|
+
await storage.set(this.recordKey, this.initialRecord, { ifNotExists: true, ttlSeconds });
|
|
136
259
|
continue;
|
|
137
260
|
}
|
|
138
261
|
const current = this.parse(raw);
|
|
262
|
+
const value = await change(current.value);
|
|
263
|
+
if (onlyIfChanged && current.revision > 0 && JSON.stringify(value) === JSON.stringify(current.value)) {
|
|
264
|
+
return current;
|
|
265
|
+
}
|
|
139
266
|
const next = JSON.stringify({
|
|
140
|
-
value
|
|
267
|
+
value,
|
|
141
268
|
revision: current.revision + 1,
|
|
142
269
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
143
270
|
});
|
|
144
271
|
if (await storage.setIfEquals(this.recordKey, raw, next)) {
|
|
145
|
-
await this.
|
|
272
|
+
await this.setExpiry(storage);
|
|
273
|
+
await this.backend.publish(this.name, epoch, ttlSeconds === void 0 ? void 0 : { ttlSeconds }).catch((error) => this.backend.reportError(error));
|
|
146
274
|
return this.parse(next);
|
|
147
275
|
}
|
|
148
276
|
}
|
|
149
277
|
}
|
|
150
278
|
subscribe(listener) {
|
|
151
279
|
let active = true;
|
|
152
|
-
let seen = this.
|
|
153
|
-
(snapshot) => snapshot
|
|
154
|
-
() =>
|
|
280
|
+
let seen = this.current().then(
|
|
281
|
+
(snapshot) => snapshot,
|
|
282
|
+
() => void 0
|
|
155
283
|
);
|
|
156
|
-
const check = async (
|
|
157
|
-
if (!active) return
|
|
284
|
+
const check = async (last) => {
|
|
285
|
+
if (!active) return last;
|
|
158
286
|
let snapshot;
|
|
159
287
|
try {
|
|
160
|
-
snapshot = await this.
|
|
288
|
+
snapshot = await this.current();
|
|
161
289
|
} catch (error) {
|
|
162
290
|
this.backend.reportError(error);
|
|
163
|
-
return
|
|
291
|
+
return last;
|
|
164
292
|
}
|
|
165
|
-
if (!active || snapshot
|
|
293
|
+
if (!active || !isNewSnapshot(snapshot, last)) return snapshot;
|
|
166
294
|
try {
|
|
167
295
|
listener(snapshot);
|
|
168
296
|
} catch (error) {
|
|
169
297
|
this.backend.reportError(error);
|
|
170
298
|
}
|
|
171
|
-
return snapshot
|
|
299
|
+
return snapshot;
|
|
172
300
|
};
|
|
173
301
|
const stop = this.store.subscribe(this.name, () => {
|
|
174
302
|
seen = seen.then(check);
|
|
@@ -183,6 +311,199 @@ var StoredResourceKey = class {
|
|
|
183
311
|
return record.updatedAt === void 0 ? { value: record.value, revision: record.revision } : { value: record.value, revision: record.revision, updatedAt: record.updatedAt };
|
|
184
312
|
}
|
|
185
313
|
};
|
|
314
|
+
var ProducedKey = class extends StoredResourceKey {
|
|
315
|
+
constructor(store, backend, name, produce, throttle, retention) {
|
|
316
|
+
super(store, backend, name, initialRecordOf(name, void 0), retention);
|
|
317
|
+
this.produce = produce;
|
|
318
|
+
this.minIntervalMs = throttle.minIntervalMs ?? DEFAULT_MIN_INTERVAL_MS;
|
|
319
|
+
this.costFactor = throttle.costFactor ?? DEFAULT_COST_FACTOR;
|
|
320
|
+
}
|
|
321
|
+
produce;
|
|
322
|
+
/** Moves on each `markDirty()`; the key is clean once a run that started at the current one has stored its output. */
|
|
323
|
+
generation = 1;
|
|
324
|
+
producedGeneration = 0;
|
|
325
|
+
/** The store's epoch the stored output was produced in: after a close, the reopened storage may not hold it. */
|
|
326
|
+
producedEpoch = -1;
|
|
327
|
+
run;
|
|
328
|
+
runGeneration = 0;
|
|
329
|
+
runEpoch = -1;
|
|
330
|
+
timer;
|
|
331
|
+
subscribers = 0;
|
|
332
|
+
lastEndedAt = -Infinity;
|
|
333
|
+
lastDurationMs = 0;
|
|
334
|
+
minIntervalMs;
|
|
335
|
+
costFactor;
|
|
336
|
+
/** No one subscribes and no run is due or running: what a family may forget. */
|
|
337
|
+
get idle() {
|
|
338
|
+
return this.subscribers === 0 && !this.run && !this.timer;
|
|
339
|
+
}
|
|
340
|
+
markDirty() {
|
|
341
|
+
this.generation++;
|
|
342
|
+
if (this.subscribers > 0) this.schedule();
|
|
343
|
+
}
|
|
344
|
+
async get() {
|
|
345
|
+
for (; ; ) {
|
|
346
|
+
if (!this.run) {
|
|
347
|
+
if (this.dirty) return this.start();
|
|
348
|
+
const stored = await this.stored();
|
|
349
|
+
if (stored) return stored;
|
|
350
|
+
if (!this.run) this.generation++;
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
if (this.runGeneration === this.generation && this.runEpoch === this.backend.epoch()) return this.run;
|
|
354
|
+
await this.run.catch(() => void 0);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
/** Deletes the stored output, for a family that forgets this key; a later read produces it again. */
|
|
358
|
+
forgetStored() {
|
|
359
|
+
this.backend.storage().then((storage) => storage.delete(this.recordKey)).catch((error) => this.backend.reportError(error));
|
|
360
|
+
}
|
|
361
|
+
/** Marked dirty since the last stored run, or the store closed since then, so its storage may not hold the output. */
|
|
362
|
+
get dirty() {
|
|
363
|
+
return this.producedGeneration < this.generation || this.producedEpoch !== this.backend.epoch();
|
|
364
|
+
}
|
|
365
|
+
/** A subscription reads the stored value: only a read or the throttled timer runs the producer. */
|
|
366
|
+
current() {
|
|
367
|
+
return super.get();
|
|
368
|
+
}
|
|
369
|
+
subscribe(listener) {
|
|
370
|
+
this.subscribers++;
|
|
371
|
+
const stop = super.subscribe(listener);
|
|
372
|
+
this.schedule();
|
|
373
|
+
let subscribed = true;
|
|
374
|
+
return () => {
|
|
375
|
+
if (!subscribed) return;
|
|
376
|
+
subscribed = false;
|
|
377
|
+
stop();
|
|
378
|
+
if (--this.subscribers > 0) return;
|
|
379
|
+
clearTimeout(this.timer);
|
|
380
|
+
this.timer = void 0;
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
schedule() {
|
|
384
|
+
if (this.timer || this.run || !this.dirty) return;
|
|
385
|
+
const waitMs = Math.max(this.minIntervalMs, this.lastDurationMs * this.costFactor);
|
|
386
|
+
this.timer = setTimeout(
|
|
387
|
+
() => {
|
|
388
|
+
this.timer = void 0;
|
|
389
|
+
if (this.subscribers > 0 && !this.run && this.dirty) {
|
|
390
|
+
this.start().catch(() => void 0);
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
Math.max(0, this.lastEndedAt + waitMs - performance.now())
|
|
394
|
+
);
|
|
395
|
+
this.timer.unref?.();
|
|
396
|
+
}
|
|
397
|
+
start() {
|
|
398
|
+
clearTimeout(this.timer);
|
|
399
|
+
this.timer = void 0;
|
|
400
|
+
const generation = this.runGeneration = this.generation;
|
|
401
|
+
const epoch = this.runEpoch = this.backend.epoch();
|
|
402
|
+
const startedAt = performance.now();
|
|
403
|
+
const run = this.produceAndStore(generation, epoch);
|
|
404
|
+
this.run = run;
|
|
405
|
+
const settle = (produced) => {
|
|
406
|
+
this.lastEndedAt = performance.now();
|
|
407
|
+
this.lastDurationMs = this.lastEndedAt - startedAt;
|
|
408
|
+
if (this.run === run) this.run = void 0;
|
|
409
|
+
if (this.subscribers > 0 && (produced || this.generation !== generation)) this.schedule();
|
|
410
|
+
};
|
|
411
|
+
run.then(
|
|
412
|
+
() => settle(true),
|
|
413
|
+
(error) => {
|
|
414
|
+
settle(false);
|
|
415
|
+
if (!(error instanceof ResourceStoreClosedError)) this.backend.reportError(error);
|
|
416
|
+
}
|
|
417
|
+
);
|
|
418
|
+
return run;
|
|
419
|
+
}
|
|
420
|
+
async produceAndStore(generation, epoch) {
|
|
421
|
+
const value = await this.produce();
|
|
422
|
+
let snapshot;
|
|
423
|
+
try {
|
|
424
|
+
snapshot = await this.write(() => value, true, epoch);
|
|
425
|
+
} catch (error) {
|
|
426
|
+
throw error instanceof ResourceStoreClosedError ? new ResourceStoreClosedError(this.name) : error;
|
|
427
|
+
}
|
|
428
|
+
this.producedGeneration = Math.max(this.producedGeneration, generation);
|
|
429
|
+
this.producedEpoch = epoch;
|
|
430
|
+
return snapshot;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
var FamilyKeyHandle = class {
|
|
434
|
+
constructor(family, name, params) {
|
|
435
|
+
this.family = family;
|
|
436
|
+
this.name = name;
|
|
437
|
+
this.params = params;
|
|
438
|
+
}
|
|
439
|
+
family;
|
|
440
|
+
name;
|
|
441
|
+
params;
|
|
442
|
+
get store() {
|
|
443
|
+
return this.family.store;
|
|
444
|
+
}
|
|
445
|
+
get() {
|
|
446
|
+
return this.family.liveKey(this.params).get();
|
|
447
|
+
}
|
|
448
|
+
set(value) {
|
|
449
|
+
return this.family.liveKey(this.params).set(value);
|
|
450
|
+
}
|
|
451
|
+
update(change) {
|
|
452
|
+
return this.family.liveKey(this.params).update(change);
|
|
453
|
+
}
|
|
454
|
+
subscribe(listener) {
|
|
455
|
+
return this.family.liveKey(this.params).subscribe(listener);
|
|
456
|
+
}
|
|
457
|
+
markDirty() {
|
|
458
|
+
this.family.liveKey(this.params).markDirty();
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
var KeyFamily = class {
|
|
462
|
+
constructor(store, name, create, handleOf) {
|
|
463
|
+
this.store = store;
|
|
464
|
+
this.name = name;
|
|
465
|
+
this.create = create;
|
|
466
|
+
this.handleOf = handleOf;
|
|
467
|
+
}
|
|
468
|
+
store;
|
|
469
|
+
name;
|
|
470
|
+
create;
|
|
471
|
+
handleOf;
|
|
472
|
+
members = /* @__PURE__ */ new Map();
|
|
473
|
+
key(params) {
|
|
474
|
+
return this.member(params).handle;
|
|
475
|
+
}
|
|
476
|
+
/** The key the family holds for `params` now, made again if it was forgotten. */
|
|
477
|
+
liveKey(params) {
|
|
478
|
+
return this.member(params).key;
|
|
479
|
+
}
|
|
480
|
+
member(params) {
|
|
481
|
+
const memberKey = memberName(this.name, params);
|
|
482
|
+
let member = this.members.get(memberKey);
|
|
483
|
+
if (member) {
|
|
484
|
+
this.members.delete(memberKey);
|
|
485
|
+
} else {
|
|
486
|
+
const key = this.create(memberKey, { ...params });
|
|
487
|
+
member = { key, handle: this.handleOf ? this.handleOf(memberKey, { ...params }) : key };
|
|
488
|
+
}
|
|
489
|
+
this.members.set(memberKey, member);
|
|
490
|
+
this.forgetIdleKeys(memberKey);
|
|
491
|
+
return member;
|
|
492
|
+
}
|
|
493
|
+
/** Forgets the oldest idle keys past the limit, a few per call and never `returning`; a busy key moves last. */
|
|
494
|
+
forgetIdleKeys(returning) {
|
|
495
|
+
let checked = 0;
|
|
496
|
+
for (const [memberKey, member] of this.members) {
|
|
497
|
+
if (this.members.size <= FAMILY_KEYS_KEPT || checked++ >= FAMILY_KEYS_CHECKED_PER_LOOKUP) return;
|
|
498
|
+
if (memberKey === returning) continue;
|
|
499
|
+
this.members.delete(memberKey);
|
|
500
|
+
const { key } = member;
|
|
501
|
+
if (!(key instanceof ProducedKey)) continue;
|
|
502
|
+
if (key.idle) key.forgetStored();
|
|
503
|
+
else this.members.set(memberKey, member);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
};
|
|
186
507
|
function resourceStore(options = {}) {
|
|
187
508
|
const parsed = resourceStoreOptionsSchema.safeParse(options);
|
|
188
509
|
if (!parsed.success) {
|
|
@@ -192,6 +513,8 @@ function resourceStore(options = {}) {
|
|
|
192
513
|
return new ResourceStore(options);
|
|
193
514
|
}
|
|
194
515
|
export {
|
|
516
|
+
MAX_RESOURCE_KEY_PARAMS_LENGTH,
|
|
195
517
|
ResourceStore,
|
|
518
|
+
assertResourceKeyParams,
|
|
196
519
|
resourceStore
|
|
197
520
|
};
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
// libs/sdk/src/resource/resource.events.ts
|
|
2
2
|
var ResourceEmitter = class {
|
|
3
|
+
/** `onListenerError` is told of a listener that threw; the other listeners are still called. */
|
|
4
|
+
constructor(onListenerError) {
|
|
5
|
+
this.onListenerError = onListenerError;
|
|
6
|
+
}
|
|
7
|
+
onListenerError;
|
|
3
8
|
listeners = /* @__PURE__ */ new Set();
|
|
4
9
|
on(l) {
|
|
5
10
|
this.listeners.add(l);
|
|
6
11
|
return () => this.listeners.delete(l);
|
|
7
12
|
}
|
|
8
13
|
emit(e) {
|
|
9
|
-
for (const l of [...this.listeners])
|
|
14
|
+
for (const l of [...this.listeners]) {
|
|
15
|
+
try {
|
|
16
|
+
l(e);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
this.onListenerError?.(error);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
10
21
|
}
|
|
11
22
|
};
|
|
12
23
|
export {
|
|
@@ -23,6 +23,43 @@ import {
|
|
|
23
23
|
normalizeResourceTemplate,
|
|
24
24
|
resourceDiscoveryDeps
|
|
25
25
|
} from "./resource.utils.mjs";
|
|
26
|
+
var RESERVED_URI_CHARACTERS = new Set(":/?#[]@!$&'()*+,;=%");
|
|
27
|
+
var strictUtf8 = new TextDecoder("utf-8", { fatal: true });
|
|
28
|
+
function isHexPair(text) {
|
|
29
|
+
return text.length === 2 && [...text].every((char) => "0123456789abcdefABCDEF".includes(char));
|
|
30
|
+
}
|
|
31
|
+
function decodedUriOf(uri) {
|
|
32
|
+
const scheme = /^[A-Za-z][A-Za-z0-9+.-]*:/.exec(uri)?.[0] ?? "";
|
|
33
|
+
let decoded = scheme.toLowerCase();
|
|
34
|
+
const pending = [];
|
|
35
|
+
const flush = () => {
|
|
36
|
+
if (pending.length === 0) return true;
|
|
37
|
+
try {
|
|
38
|
+
decoded += strictUtf8.decode(new Uint8Array(pending));
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
pending.length = 0;
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
for (let index = scheme.length; index < uri.length; index++) {
|
|
46
|
+
const char = uri[index];
|
|
47
|
+
if (char !== "%") {
|
|
48
|
+
if (!flush()) return void 0;
|
|
49
|
+
decoded += char;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const hex = uri.slice(index + 1, index + 3);
|
|
53
|
+
if (!isHexPair(hex)) return void 0;
|
|
54
|
+
index += 2;
|
|
55
|
+
const byte = Number.parseInt(hex, 16);
|
|
56
|
+
if (byte < 128 && RESERVED_URI_CHARACTERS.has(String.fromCharCode(byte))) {
|
|
57
|
+
if (!flush()) return void 0;
|
|
58
|
+
decoded += `%${hex.toUpperCase()}`;
|
|
59
|
+
} else pending.push(byte);
|
|
60
|
+
}
|
|
61
|
+
return flush() ? decoded : void 0;
|
|
62
|
+
}
|
|
26
63
|
var ResourceRegistry = class extends RegistryAbstract {
|
|
27
64
|
/** Who owns this registry (used for provenance). */
|
|
28
65
|
owner;
|
|
@@ -39,6 +76,8 @@ var ResourceRegistry = class extends RegistryAbstract {
|
|
|
39
76
|
// baseName -> rows
|
|
40
77
|
byUri = /* @__PURE__ */ new Map();
|
|
41
78
|
// uri -> row (static resources)
|
|
79
|
+
byDecodedUri = /* @__PURE__ */ new Map();
|
|
80
|
+
// decoded uri -> row (static resources)
|
|
42
81
|
byUriTemplate = /* @__PURE__ */ new Map();
|
|
43
82
|
// uriTemplate -> row (templates)
|
|
44
83
|
byOwnerAndName = /* @__PURE__ */ new Map();
|
|
@@ -49,7 +88,10 @@ var ResourceRegistry = class extends RegistryAbstract {
|
|
|
49
88
|
// instance -> first row's lineage
|
|
50
89
|
// version + emitter
|
|
51
90
|
version = 0;
|
|
52
|
-
emitter = new ResourceEmitter();
|
|
91
|
+
emitter = new ResourceEmitter((error) => this.reportListenerError("resource change", error));
|
|
92
|
+
/** Subscribers by URI: a session's `resources/subscribe`, or a `subscriptions/listen` stream's URI prefix. */
|
|
93
|
+
watchers = /* @__PURE__ */ new Map();
|
|
94
|
+
watchListeners = /* @__PURE__ */ new Set();
|
|
53
95
|
/**
|
|
54
96
|
* When false, the registry holds only the entries registered into it and adopts nothing: it
|
|
55
97
|
* does not pull in the apps or the other registries visible on `providers`. A remote app's
|
|
@@ -252,6 +294,11 @@ var ResourceRegistry = class extends RegistryAbstract {
|
|
|
252
294
|
const row = this.byUri.get(uri);
|
|
253
295
|
return row?.instance;
|
|
254
296
|
}
|
|
297
|
+
/** Find a resource whose URI is the same as this one once both are decoded. */
|
|
298
|
+
findByDecodedUri(uri) {
|
|
299
|
+
const decoded = decodedUriOf(uri);
|
|
300
|
+
return decoded === void 0 ? void 0 : this.byDecodedUri.get(decoded)?.instance;
|
|
301
|
+
}
|
|
255
302
|
/**
|
|
256
303
|
* Find the resource template that serves a URI template: the first one registered for it
|
|
257
304
|
*/
|
|
@@ -272,10 +319,11 @@ var ResourceRegistry = class extends RegistryAbstract {
|
|
|
272
319
|
return void 0;
|
|
273
320
|
}
|
|
274
321
|
/**
|
|
275
|
-
* Find a resource by URI - tries exact match first, then template matching
|
|
322
|
+
* Find a resource by URI - tries exact match first, then template matching.
|
|
323
|
+
* A URI that spells a resource's own URI another way (percent-encoded, upper-case scheme) finds that resource.
|
|
276
324
|
*/
|
|
277
325
|
findResourceForUri(uri) {
|
|
278
|
-
const exact = this.findByUri(uri);
|
|
326
|
+
const exact = this.findByUri(uri) ?? this.findByDecodedUri(uri);
|
|
279
327
|
if (exact) {
|
|
280
328
|
return { instance: exact, params: {} };
|
|
281
329
|
}
|
|
@@ -303,6 +351,7 @@ var ResourceRegistry = class extends RegistryAbstract {
|
|
|
303
351
|
this.byQualifiedId.clear();
|
|
304
352
|
this.byName.clear();
|
|
305
353
|
this.byUri.clear();
|
|
354
|
+
this.byDecodedUri.clear();
|
|
306
355
|
this.byUriTemplate.clear();
|
|
307
356
|
this.byOwnerAndName.clear();
|
|
308
357
|
this.byOwner.clear();
|
|
@@ -323,6 +372,8 @@ var ResourceRegistry = class extends RegistryAbstract {
|
|
|
323
372
|
const served = uriIndex.get(uriKey);
|
|
324
373
|
if (!served) uriIndex.set(uriKey, r);
|
|
325
374
|
else if (served.instance !== r.instance) this.warnDuplicateUri(uriKey, served, r);
|
|
375
|
+
const decoded = r.isTemplate ? void 0 : decodedUriOf(uriKey);
|
|
376
|
+
if (decoded !== void 0 && !this.byDecodedUri.has(decoded)) this.byDecodedUri.set(decoded, served ?? r);
|
|
326
377
|
}
|
|
327
378
|
}
|
|
328
379
|
warnDuplicateUri(uri, served, shadowed) {
|
|
@@ -416,6 +467,44 @@ var ResourceRegistry = class extends RegistryAbstract {
|
|
|
416
467
|
}
|
|
417
468
|
return this.emitter.on((e) => cb({ ...e, snapshot: this.listAllInstances().filter(filter) }));
|
|
418
469
|
}
|
|
470
|
+
/** Count a subscriber of `uri` until {@link unwatchUri}: a session's `resources/subscribe`, or a listen stream's prefix. */
|
|
471
|
+
watchUri(uri) {
|
|
472
|
+
const count = this.watchers.get(uri) ?? 0;
|
|
473
|
+
this.watchers.set(uri, count + 1);
|
|
474
|
+
if (count === 0) this.emitWatchChange(uri, true);
|
|
475
|
+
}
|
|
476
|
+
unwatchUri(uri) {
|
|
477
|
+
const count = this.watchers.get(uri);
|
|
478
|
+
if (count === void 0) return;
|
|
479
|
+
if (count > 1) {
|
|
480
|
+
this.watchers.set(uri, count - 1);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
this.watchers.delete(uri);
|
|
484
|
+
this.emitWatchChange(uri, false);
|
|
485
|
+
}
|
|
486
|
+
/** The URIs (or listen-stream prefixes) that have a subscriber now. */
|
|
487
|
+
watchedUris() {
|
|
488
|
+
return [...this.watchers.keys()];
|
|
489
|
+
}
|
|
490
|
+
/** Call `listener` with the URI when it gets its first subscriber (`watched` true) or loses its last one. */
|
|
491
|
+
onWatchChange(listener) {
|
|
492
|
+
this.watchListeners.add(listener);
|
|
493
|
+
return () => this.watchListeners.delete(listener);
|
|
494
|
+
}
|
|
495
|
+
emitWatchChange(uri, watched) {
|
|
496
|
+
for (const listener of [...this.watchListeners]) {
|
|
497
|
+
try {
|
|
498
|
+
listener(uri, watched);
|
|
499
|
+
} catch (error) {
|
|
500
|
+
this.reportListenerError("subscription", error);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
reportListenerError(kind, error) {
|
|
505
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
506
|
+
this.providers.getActiveScope().logger.warn(`A ${kind} listener of the resource registry failed: ${reason}`);
|
|
507
|
+
}
|
|
419
508
|
/**
|
|
420
509
|
* Signal that a specific resource's content has changed without modifying the resource list.
|
|
421
510
|
* Emits an 'updated' event that NotificationService uses to notify subscribed sessions.
|