effect 4.0.0-beta.100 → 4.0.0-beta.102
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/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +81 -5
- package/dist/Array.js.map +1 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +27 -9
- package/dist/Channel.js.map +1 -1
- package/dist/Config.d.ts +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +6 -5
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.js +7 -7
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +2 -1
- package/dist/Data.js.map +1 -1
- package/dist/Effect.d.ts +61 -100
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +66 -39
- package/dist/Effect.js.map +1 -1
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +3 -2
- package/dist/FiberHandle.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +2 -1
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.d.ts.map +1 -1
- package/dist/JsonPatch.js +4 -3
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +9 -11
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +3 -2
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +9 -0
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +3 -0
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +4 -3
- package/dist/Metric.js.map +1 -1
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +4 -0
- package/dist/MutableList.js.map +1 -1
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +5 -4
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +2 -1
- package/dist/Option.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +1 -4
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Record.d.ts +93 -1
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +57 -19
- package/dist/Record.js.map +1 -1
- package/dist/References.d.ts +0 -45
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +0 -45
- package/dist/References.js.map +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +9 -6
- package/dist/Request.js.map +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +2 -1
- package/dist/Result.js.map +1 -1
- package/dist/Schema.d.ts +1269 -496
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2308 -614
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +2 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +189 -130
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaError.js +1 -1
- package/dist/SchemaError.js.map +1 -1
- package/dist/SchemaGetter.d.ts +13 -11
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +34 -24
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.js +1 -1
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +1 -12
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +403 -1504
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +294 -2852
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +2 -2
- package/dist/SchemaTransformation.js +3 -3
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts +5 -3
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js.map +1 -1
- package/dist/Stream.d.ts +15 -9
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +46 -16
- package/dist/Stream.js.map +1 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +5 -4
- package/dist/Struct.js.map +1 -1
- package/dist/Types.d.ts +1 -3
- package/dist/Types.d.ts.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +3 -2
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/effect.js +119 -53
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/record.d.ts +0 -3
- package/dist/internal/record.d.ts.map +1 -1
- package/dist/internal/record.js +10 -5
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/references.js +0 -4
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/schema/annotations.js +12 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/fromJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +743 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/fromRepresentation.d.ts +2 -0
- package/dist/internal/schema/fromRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/fromRepresentation.js +252 -0
- package/dist/internal/schema/fromRepresentation.js.map +1 -0
- package/dist/internal/schema/schema.js +28 -40
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/{arbitrary.d.ts → toArbitrary.d.ts} +1 -1
- package/dist/internal/schema/toArbitrary.d.ts.map +1 -0
- package/dist/internal/schema/{arbitrary.js → toArbitrary.js} +8 -9
- package/dist/internal/schema/toArbitrary.js.map +1 -0
- package/dist/internal/schema/toCodeDocument.d.ts +2 -0
- package/dist/internal/schema/toCodeDocument.d.ts.map +1 -0
- package/dist/internal/schema/toCodeDocument.js +438 -0
- package/dist/internal/schema/toCodeDocument.js.map +1 -0
- package/dist/internal/schema/toEquivalence.d.ts +2 -0
- package/dist/internal/schema/toEquivalence.d.ts.map +1 -0
- package/dist/internal/schema/{equivalence.js → toEquivalence.js} +15 -13
- package/dist/internal/schema/toEquivalence.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts +2 -0
- package/dist/internal/schema/toJsonSchemaDocument.d.ts.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +466 -0
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -0
- package/dist/internal/schema/toRepresentation.d.ts +2 -0
- package/dist/internal/schema/toRepresentation.d.ts.map +1 -0
- package/dist/internal/schema/toRepresentation.js +369 -0
- package/dist/internal/schema/toRepresentation.js.map +1 -0
- package/dist/internal/stackTraceLimit.js +3 -6
- package/dist/internal/stackTraceLimit.js.map +1 -1
- package/dist/testing/TestClock.js +4 -1
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +26 -26
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +5 -4
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts +21 -6
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +86 -316
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +1 -1
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +4 -1
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +19 -17
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +197 -197
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +13 -13
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +4 -4
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +116 -49
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts +32 -10
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +193 -377
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +19 -19
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +14 -14
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +4 -0
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +11 -3
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +9 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +14 -10
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +15 -12
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/ai/internal/structured-output.d.ts +2 -0
- package/dist/unstable/ai/internal/structured-output.d.ts.map +1 -0
- package/dist/unstable/ai/internal/structured-output.js +316 -0
- package/dist/unstable/ai/internal/structured-output.js.map +1 -0
- package/dist/unstable/cli/CliError.d.ts +40 -2
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +45 -6
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/Command.js +14 -5
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Param.js +3 -3
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.js +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +3 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +11 -4
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/config.d.ts +0 -48
- package/dist/unstable/cli/internal/config.d.ts.map +1 -1
- package/dist/unstable/cli/internal/config.js +8 -10
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.js +1 -1
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +2 -1
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/Reply.js +1 -1
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runner.js +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js +1 -1
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +125 -24
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +10 -2
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SingleRunner.d.ts +4 -2
- package/dist/unstable/cluster/SingleRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/SingleRunner.js +2 -1
- package/dist/unstable/cluster/SingleRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts +7 -4
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +55 -24
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +109 -62
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +19 -7
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/shardLock.d.ts +2 -0
- package/dist/unstable/cluster/internal/shardLock.d.ts.map +1 -0
- package/dist/unstable/cluster/internal/shardLock.js +4 -0
- package/dist/unstable/cluster/internal/shardLock.js.map +1 -0
- package/dist/unstable/devtools/DevToolsSchema.d.ts +20 -20
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +8 -5
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
- package/dist/unstable/eventlog/EventJournal.js +1 -1
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +15 -11
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js +1 -1
- package/dist/unstable/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +26 -26
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +8 -3
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +2 -2
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +3 -3
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +24 -22
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Headers.js +8 -8
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +44 -0
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +14 -0
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -2
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +5 -4
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +17 -15
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/Template.js +1 -1
- package/dist/unstable/http/Template.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +17 -14
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js +3 -3
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +5 -5
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +37 -24
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +72 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +69 -4
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -3
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +2 -2
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +7 -3
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +5 -2
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -3
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +2 -2
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +2 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +2 -2
- package/dist/unstable/persistence/RateLimiter.js +2 -2
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/persistence/Redis.d.ts.map +1 -1
- package/dist/unstable/persistence/Redis.js +2 -2
- package/dist/unstable/persistence/Redis.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +3 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/unstable/reactivity/AsyncResult.js +4 -3
- package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +83 -0
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +31 -0
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +2 -1
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +1 -2
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +13 -10
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +1 -1
- package/dist/unstable/socket/Socket.js +1 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +2 -2
- package/dist/unstable/sql/SqlError.js +2 -2
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +7 -6
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +86 -25
- package/src/Channel.ts +32 -14
- package/src/Config.ts +6 -5
- package/src/ConfigProvider.ts +7 -7
- package/src/Data.ts +3 -2
- package/src/Effect.ts +70 -116
- package/src/FiberHandle.ts +3 -2
- package/src/Iterable.ts +2 -1
- package/src/JsonPatch.ts +4 -3
- package/src/JsonSchema.ts +9 -11
- package/src/Logger.ts +3 -2
- package/src/ManagedRuntime.ts +13 -0
- package/src/Metric.ts +4 -3
- package/src/MutableList.ts +4 -0
- package/src/Optic.ts +5 -4
- package/src/Option.ts +2 -1
- package/src/PartitionedSemaphore.ts +1 -4
- package/src/Record.ts +119 -22
- package/src/References.ts +0 -46
- package/src/Request.ts +5 -7
- package/src/Result.ts +2 -1
- package/src/Schema.ts +2538 -987
- package/src/SchemaAST.ts +228 -149
- package/src/SchemaError.ts +1 -1
- package/src/SchemaGetter.ts +36 -29
- package/src/SchemaIssue.ts +1 -1
- package/src/SchemaParser.ts +1 -25
- package/src/SchemaRepresentation.ts +697 -3398
- package/src/SchemaTransformation.ts +3 -3
- package/src/Semaphore.ts +5 -3
- package/src/Stream.ts +63 -19
- package/src/Struct.ts +5 -4
- package/src/Types.ts +1 -3
- package/src/index.ts +0 -5
- package/src/internal/core.ts +4 -3
- package/src/internal/effect.ts +132 -70
- package/src/internal/matcher.ts +1 -1
- package/src/internal/record.ts +11 -7
- package/src/internal/references.ts +0 -5
- package/src/internal/schema/annotations.ts +44 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +957 -0
- package/src/internal/schema/fromRepresentation.ts +345 -0
- package/src/internal/schema/schema.ts +45 -46
- package/src/internal/schema/{arbitrary.ts → toArbitrary.ts} +8 -10
- package/src/internal/schema/toCodeDocument.ts +572 -0
- package/src/internal/schema/{equivalence.ts → toEquivalence.ts} +12 -7
- package/src/internal/schema/toJsonSchemaDocument.ts +475 -0
- package/src/internal/schema/toRepresentation.ts +401 -0
- package/src/internal/stackTraceLimit.ts +3 -7
- package/src/testing/TestClock.ts +1 -1
- package/src/unstable/ai/AiError.ts +5 -4
- package/src/unstable/ai/AnthropicStructuredOutput.ts +102 -333
- package/src/unstable/ai/EmbeddingModel.ts +1 -1
- package/src/unstable/ai/LanguageModel.ts +30 -28
- package/src/unstable/ai/McpSchema.ts +15 -15
- package/src/unstable/ai/McpServer.ts +172 -56
- package/src/unstable/ai/OpenAiStructuredOutput.ts +230 -395
- package/src/unstable/ai/Response.ts +24 -24
- package/src/unstable/ai/Tool.ts +22 -4
- package/src/unstable/ai/Toolkit.ts +19 -7
- package/src/unstable/ai/internal/codec-transformer.ts +13 -7
- package/src/unstable/ai/internal/structured-output.ts +458 -0
- package/src/unstable/cli/CliError.ts +51 -5
- package/src/unstable/cli/Command.ts +4 -4
- package/src/unstable/cli/Param.ts +3 -3
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/internal/command.ts +13 -5
- package/src/unstable/cli/internal/config.ts +8 -10
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +3 -3
- package/src/unstable/cluster/Entity.ts +1 -1
- package/src/unstable/cluster/Envelope.ts +2 -1
- package/src/unstable/cluster/Reply.ts +1 -1
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/ShardId.ts +1 -1
- package/src/unstable/cluster/Sharding.ts +161 -34
- package/src/unstable/cluster/ShardingConfig.ts +5 -1
- package/src/unstable/cluster/SingleRunner.ts +4 -2
- package/src/unstable/cluster/SqlMessageStorage.ts +83 -35
- package/src/unstable/cluster/SqlRunnerStorage.ts +186 -116
- package/src/unstable/cluster/internal/entityManager.ts +31 -10
- package/src/unstable/cluster/internal/shardLock.ts +9 -0
- package/src/unstable/devtools/DevToolsSchema.ts +10 -5
- package/src/unstable/eventlog/EventJournal.ts +1 -1
- package/src/unstable/eventlog/EventLog.ts +21 -11
- package/src/unstable/eventlog/EventLogEncryption.ts +1 -1
- package/src/unstable/eventlog/EventLogMessage.ts +10 -3
- package/src/unstable/eventlog/SqlEventJournal.ts +2 -2
- package/src/unstable/eventlog/SqlEventLogServerEncrypted.ts +1 -1
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +6 -3
- package/src/unstable/http/Cookies.ts +29 -24
- package/src/unstable/http/Headers.ts +8 -8
- package/src/unstable/http/HttpClientRequest.ts +57 -0
- package/src/unstable/http/HttpRouter.ts +6 -3
- package/src/unstable/http/HttpServerRequest.ts +5 -4
- package/src/unstable/http/Multipart.ts +16 -13
- package/src/unstable/http/Template.ts +1 -1
- package/src/unstable/http/UrlParams.ts +17 -14
- package/src/unstable/httpapi/HttpApi.ts +3 -3
- package/src/unstable/httpapi/HttpApiClient.ts +5 -5
- package/src/unstable/httpapi/HttpApiGroup.ts +1 -1
- package/src/unstable/httpapi/OpenApi.ts +52 -28
- package/src/unstable/observability/OtlpExporter.ts +109 -5
- package/src/unstable/observability/OtlpLogger.ts +5 -5
- package/src/unstable/observability/OtlpMetrics.ts +8 -4
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/persistence/Persistable.ts +3 -2
- package/src/unstable/persistence/RateLimiter.ts +2 -2
- package/src/unstable/persistence/Redis.ts +2 -2
- package/src/unstable/process/ChildProcessSpawner.ts +1 -1
- package/src/unstable/reactivity/AsyncResult.ts +4 -3
- package/src/unstable/reactivity/Atom.ts +92 -0
- package/src/unstable/reactivity/AtomRegistry.ts +1 -1
- package/src/unstable/rpc/RpcClient.ts +2 -1
- package/src/unstable/schema/VariantSchema.ts +14 -24
- package/src/unstable/socket/Socket.ts +1 -1
- package/src/unstable/sql/SqlError.ts +2 -2
- package/src/unstable/sql/Statement.ts +7 -6
- package/dist/SchemaUtils.d.ts +0 -28
- package/dist/SchemaUtils.d.ts.map +0 -1
- package/dist/SchemaUtils.js +0 -45
- package/dist/SchemaUtils.js.map +0 -1
- package/dist/internal/schema/arbitrary.d.ts.map +0 -1
- package/dist/internal/schema/arbitrary.js.map +0 -1
- package/dist/internal/schema/equivalence.d.ts +0 -2
- package/dist/internal/schema/equivalence.d.ts.map +0 -1
- package/dist/internal/schema/equivalence.js.map +0 -1
- package/dist/internal/schema/representation.d.ts +0 -2
- package/dist/internal/schema/representation.d.ts.map +0 -1
- package/dist/internal/schema/representation.js +0 -865
- package/dist/internal/schema/representation.js.map +0 -1
- package/src/SchemaUtils.ts +0 -51
- package/src/internal/schema/representation.ts +0 -795
|
@@ -39,6 +39,7 @@ import type * as RpcGroup from "../rpc/RpcGroup.ts"
|
|
|
39
39
|
import * as RpcMessage from "../rpc/RpcMessage.ts"
|
|
40
40
|
import * as RpcSerialization from "../rpc/RpcSerialization.ts"
|
|
41
41
|
import * as RpcServer from "../rpc/RpcServer.ts"
|
|
42
|
+
import * as AiError from "./AiError.ts"
|
|
42
43
|
import {
|
|
43
44
|
CallToolResult,
|
|
44
45
|
ClientNotificationRpcs,
|
|
@@ -340,8 +341,22 @@ const SUPPORTED_PROTOCOL_VERSIONS = [
|
|
|
340
341
|
"2024-11-05",
|
|
341
342
|
"2024-10-07"
|
|
342
343
|
]
|
|
343
|
-
const
|
|
344
|
-
const
|
|
344
|
+
const MCP_SESSION_ID_HEADER = "mcp-session-id"
|
|
345
|
+
const MCP_PROTOCOL_VERSION_HEADER = "mcp-protocol-version"
|
|
346
|
+
|
|
347
|
+
class McpProtocolState extends Context.Service<McpProtocolState, {
|
|
348
|
+
readonly clientSessions: Map<string, typeof Initialize.payloadSchema.Type>
|
|
349
|
+
readonly latestProtocolVersion: string
|
|
350
|
+
readonly supportedProtocolVersions: ReadonlySet<string>
|
|
351
|
+
}>()("effect/ai/McpServer/McpProtocolState") {}
|
|
352
|
+
|
|
353
|
+
const makeMcpProtocolState = (): McpProtocolState["Service"] => ({
|
|
354
|
+
clientSessions: new Map(),
|
|
355
|
+
latestProtocolVersion: LATEST_PROTOCOL_VERSION,
|
|
356
|
+
supportedProtocolVersions: new Set(SUPPORTED_PROTOCOL_VERSIONS)
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
const layerMcpProtocolState = Layer.sync(McpProtocolState, makeMcpProtocolState)
|
|
345
360
|
|
|
346
361
|
/**
|
|
347
362
|
* Runs an MCP server over the current `RpcServer.Protocol`.
|
|
@@ -366,12 +381,19 @@ export const run: (options: {
|
|
|
366
381
|
> = Effect.fnUntraced(function*(options: {
|
|
367
382
|
readonly name: string
|
|
368
383
|
readonly version: string
|
|
384
|
+
readonly extensions?: Record<`${string}/${string}`, unknown> | undefined
|
|
369
385
|
}) {
|
|
386
|
+
const protocolState = Option.getOrElse(
|
|
387
|
+
yield* Effect.serviceOption(McpProtocolState),
|
|
388
|
+
makeMcpProtocolState
|
|
389
|
+
)
|
|
370
390
|
const protocol = yield* RpcServer.Protocol
|
|
371
391
|
const server = yield* McpServer
|
|
372
392
|
const isHttp = Option.isSome(yield* Effect.serviceOption(HttpRouter.HttpRouter))
|
|
373
|
-
const clientSessions =
|
|
374
|
-
const handlers = yield* Layer.build(layerHandlers(options
|
|
393
|
+
const clientSessions = protocolState.clientSessions
|
|
394
|
+
const handlers = yield* Layer.build(layerHandlers(options)).pipe(
|
|
395
|
+
Effect.provideService(McpProtocolState, protocolState)
|
|
396
|
+
)
|
|
375
397
|
|
|
376
398
|
const clients = yield* RcMap.make({
|
|
377
399
|
lookup: Effect.fnUntraced(function*(clientId: number) {
|
|
@@ -439,24 +461,49 @@ export const run: (options: {
|
|
|
439
461
|
...protocol,
|
|
440
462
|
run: (f) =>
|
|
441
463
|
protocol.run((clientId, request_) => {
|
|
442
|
-
const
|
|
464
|
+
const fiber = Fiber.getCurrent()!
|
|
465
|
+
const request = request_ as unknown as
|
|
443
466
|
| RpcMessage.FromServerEncoded
|
|
444
467
|
| RpcMessage.FromClientEncoded
|
|
468
|
+
const httpRequest = isHttp
|
|
469
|
+
? Context.getOrUndefined(fiber.context, HttpServerRequest.HttpServerRequest)
|
|
470
|
+
: undefined
|
|
471
|
+
if (httpRequest !== undefined && request._tag !== "Eof") {
|
|
472
|
+
appendPreResponseHandlerUnsafe(httpRequest, (_, response) =>
|
|
473
|
+
Effect.succeed(
|
|
474
|
+
response.status === 200 &&
|
|
475
|
+
response.body._tag === "Uint8Array" &&
|
|
476
|
+
response.body.contentLength === 0
|
|
477
|
+
? HttpServerResponse.empty({
|
|
478
|
+
headers: Headers.remove(response.headers, "content-type"),
|
|
479
|
+
status: 202
|
|
480
|
+
})
|
|
481
|
+
: response
|
|
482
|
+
))
|
|
483
|
+
}
|
|
445
484
|
switch (request._tag) {
|
|
446
485
|
case "Request": {
|
|
447
|
-
if (
|
|
448
|
-
const fiber = Fiber.getCurrent()!
|
|
449
|
-
const httpRequest = Context.getUnsafe(fiber.context, HttpServerRequest.HttpServerRequest)
|
|
486
|
+
if (httpRequest !== undefined) {
|
|
450
487
|
const client = getInitializedClient(clientSessions, clientId, httpRequest.headers)
|
|
451
488
|
if (client) {
|
|
452
489
|
appendPreResponseHandlerUnsafe(httpRequest, (_, res) =>
|
|
453
490
|
Effect.succeed(
|
|
454
|
-
HttpServerResponse.setHeader(res,
|
|
491
|
+
HttpServerResponse.setHeader(res, MCP_PROTOCOL_VERSION_HEADER, client.protocolVersion)
|
|
455
492
|
))
|
|
456
493
|
}
|
|
457
494
|
}
|
|
458
495
|
const rpc = ClientNotificationRpcs.requests.get(request.tag)
|
|
459
496
|
if (rpc) {
|
|
497
|
+
const headers = Headers.fromInput(request.headers)
|
|
498
|
+
if (!getInitializedClient(clientSessions, clientId, headers)) {
|
|
499
|
+
if (httpRequest !== undefined) {
|
|
500
|
+
appendPreResponseHandlerUnsafe(
|
|
501
|
+
httpRequest,
|
|
502
|
+
() => Effect.succeed(HttpServerResponse.empty({ status: 404 }))
|
|
503
|
+
)
|
|
504
|
+
}
|
|
505
|
+
return Effect.void
|
|
506
|
+
}
|
|
460
507
|
if (request.tag === "notifications/cancelled") {
|
|
461
508
|
return f(clientId, {
|
|
462
509
|
_tag: "Interrupt",
|
|
@@ -469,7 +516,7 @@ export const run: (options: {
|
|
|
469
516
|
rpc,
|
|
470
517
|
requestId: RpcMessage.RequestId(request.id),
|
|
471
518
|
client: new Rpc.ServerClient(clientId),
|
|
472
|
-
headers
|
|
519
|
+
headers
|
|
473
520
|
}) as any as Effect.Effect<void>
|
|
474
521
|
: Effect.void
|
|
475
522
|
}
|
|
@@ -562,6 +609,15 @@ export const layer = (options: {
|
|
|
562
609
|
readonly version: string
|
|
563
610
|
readonly extensions?: Record<`${string}/${string}`, unknown> | undefined
|
|
564
611
|
}): Layer.Layer<McpServer | McpServerClient, never, RpcServer.Protocol> =>
|
|
612
|
+
layerWithProtocolState(options).pipe(
|
|
613
|
+
Layer.provide(layerMcpProtocolState)
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
const layerWithProtocolState = (options: {
|
|
617
|
+
readonly name: string
|
|
618
|
+
readonly version: string
|
|
619
|
+
readonly extensions?: Record<`${string}/${string}`, unknown> | undefined
|
|
620
|
+
}): Layer.Layer<McpServer | McpServerClient, never, RpcServer.Protocol | McpProtocolState> =>
|
|
565
621
|
Layer.effectDiscard(Effect.forkScoped(run(options))).pipe(
|
|
566
622
|
Layer.provideMerge(McpServer.layer)
|
|
567
623
|
)
|
|
@@ -635,8 +691,7 @@ export const layerStdio = (options: {
|
|
|
635
691
|
)
|
|
636
692
|
|
|
637
693
|
/**
|
|
638
|
-
* Registers
|
|
639
|
-
* `HttpRouter`.
|
|
694
|
+
* Registers a Streamable HTTP MCP endpoint at `options.path`.
|
|
640
695
|
*
|
|
641
696
|
* **When to use**
|
|
642
697
|
*
|
|
@@ -644,8 +699,9 @@ export const layerStdio = (options: {
|
|
|
644
699
|
*
|
|
645
700
|
* **Details**
|
|
646
701
|
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
702
|
+
* POST serves JSON-RPC and accepted notification-only requests return `202`.
|
|
703
|
+
* Unsupported protocol versions return `400`; methods without MCP handlers
|
|
704
|
+
* return `405`.
|
|
649
705
|
*
|
|
650
706
|
* @see {@link layerStdio} for exposing the server over stdio
|
|
651
707
|
* @see {@link layer} for the base MCP server layer without a transport protocol
|
|
@@ -658,11 +714,56 @@ export const layerHttp = (options: {
|
|
|
658
714
|
readonly version: string
|
|
659
715
|
readonly path: HttpRouter.PathInput
|
|
660
716
|
readonly extensions?: Record<`${string}/${string}`, unknown> | undefined
|
|
661
|
-
}): Layer.Layer<McpServer | McpServerClient, never, HttpRouter.HttpRouter> =>
|
|
662
|
-
|
|
663
|
-
|
|
717
|
+
}): Layer.Layer<McpServer | McpServerClient, never, HttpRouter.HttpRouter> => {
|
|
718
|
+
const protocolState = layerMcpProtocolState
|
|
719
|
+
const methodNotAllowedResponse = HttpServerResponse.empty({
|
|
720
|
+
status: 405,
|
|
721
|
+
headers: { allow: "POST" }
|
|
722
|
+
})
|
|
723
|
+
const routes = Layer.mergeAll(
|
|
724
|
+
HttpRouter.add("GET", options.path, methodNotAllowedResponse),
|
|
725
|
+
HttpRouter.add("PUT", options.path, methodNotAllowedResponse),
|
|
726
|
+
HttpRouter.add("PATCH", options.path, methodNotAllowedResponse),
|
|
727
|
+
HttpRouter.add("DELETE", options.path, methodNotAllowedResponse)
|
|
728
|
+
)
|
|
729
|
+
return Layer.merge(layerWithProtocolState(options), routes).pipe(
|
|
730
|
+
Layer.provide(layerMcpProtocolHttp(options)),
|
|
731
|
+
Layer.provide(protocolState),
|
|
664
732
|
Layer.provide(RpcSerialization.layerJsonRpc())
|
|
665
733
|
)
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
const layerMcpProtocolHttp = (options: {
|
|
737
|
+
readonly path: HttpRouter.PathInput
|
|
738
|
+
}): Layer.Layer<
|
|
739
|
+
RpcServer.Protocol,
|
|
740
|
+
never,
|
|
741
|
+
McpProtocolState | RpcSerialization.RpcSerialization | HttpRouter.HttpRouter
|
|
742
|
+
> =>
|
|
743
|
+
Layer.effect(RpcServer.Protocol)(Effect.gen(function*() {
|
|
744
|
+
const state = yield* McpProtocolState
|
|
745
|
+
const { httpEffect, protocol } = yield* RpcServer.makeProtocolWithHttpEffect
|
|
746
|
+
const router = yield* HttpRouter.HttpRouter
|
|
747
|
+
yield* router.add("POST", options.path, (request) => {
|
|
748
|
+
const protocolVersion = request.headers[MCP_PROTOCOL_VERSION_HEADER]
|
|
749
|
+
if (
|
|
750
|
+
protocolVersion !== undefined &&
|
|
751
|
+
!state.supportedProtocolVersions.has(protocolVersion)
|
|
752
|
+
) {
|
|
753
|
+
return Effect.succeed(HttpServerResponse.empty({ status: 400 }))
|
|
754
|
+
}
|
|
755
|
+
return httpEffect
|
|
756
|
+
})
|
|
757
|
+
return protocol
|
|
758
|
+
}))
|
|
759
|
+
|
|
760
|
+
const INTERNAL_TOOL_ERROR_MESSAGE = "Tool execution failed due to an internal server error."
|
|
761
|
+
|
|
762
|
+
const toolErrorResult = (message: string): CallToolResult =>
|
|
763
|
+
new CallToolResult({
|
|
764
|
+
isError: true,
|
|
765
|
+
content: [{ type: "text", text: message }]
|
|
766
|
+
})
|
|
666
767
|
|
|
667
768
|
/**
|
|
668
769
|
* Registers a `Toolkit` with the `McpServer`.
|
|
@@ -689,6 +790,7 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>>(
|
|
|
689
790
|
for (const tool of Object.values(built.tools)) {
|
|
690
791
|
const annotations = tool.annotations
|
|
691
792
|
const toolMeta = Context.getOrUndefined(annotations, Tool.Meta)
|
|
793
|
+
const isDeclaredFailure = Schema.is(tool.failureSchema)
|
|
692
794
|
const mcpTool = new McpTool({
|
|
693
795
|
name: tool.name,
|
|
694
796
|
description: Tool.getDescription(tool),
|
|
@@ -709,32 +811,41 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>>(
|
|
|
709
811
|
tool: mcpTool,
|
|
710
812
|
annotations,
|
|
711
813
|
handle(payload) {
|
|
712
|
-
return built.handle(tool.name as
|
|
814
|
+
return built.handle(tool.name as keyof Tools, payload).pipe(
|
|
713
815
|
Stream.unwrap,
|
|
714
816
|
Stream.run(Sink.last()),
|
|
715
817
|
Effect.flatMap(Effect.fromOption),
|
|
716
|
-
Effect.provideContext(
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
818
|
+
Effect.provideContext(
|
|
819
|
+
services as Context.Context<Tool.HandlerServices<Tools[keyof Tools]>>
|
|
820
|
+
),
|
|
821
|
+
Effect.map((result) =>
|
|
822
|
+
new CallToolResult({
|
|
823
|
+
isError: false,
|
|
824
|
+
structuredContent: typeof result.encodedResult === "object" ? result.encodedResult : undefined,
|
|
825
|
+
content: [{
|
|
826
|
+
type: "text",
|
|
827
|
+
text: JSON.stringify(result.encodedResult)
|
|
828
|
+
}]
|
|
829
|
+
})
|
|
830
|
+
),
|
|
831
|
+
Effect.tapCause(Effect.logError),
|
|
832
|
+
Effect.catch((error) => {
|
|
833
|
+
if (AiError.isAiError(error)) {
|
|
834
|
+
const reason = (error as AiError.AiError).reason
|
|
835
|
+
return reason._tag === "ToolParameterValidationError"
|
|
836
|
+
? Effect.succeed(toolErrorResult(reason.message))
|
|
837
|
+
: Effect.succeed(toolErrorResult(INTERNAL_TOOL_ERROR_MESSAGE))
|
|
838
|
+
}
|
|
839
|
+
if (isDeclaredFailure(error)) {
|
|
840
|
+
const message = error instanceof Error
|
|
841
|
+
? error.message
|
|
842
|
+
: INTERNAL_TOOL_ERROR_MESSAGE
|
|
843
|
+
return Effect.succeed(toolErrorResult(message))
|
|
844
|
+
}
|
|
845
|
+
return Effect.succeed(toolErrorResult(INTERNAL_TOOL_ERROR_MESSAGE))
|
|
735
846
|
}),
|
|
736
|
-
Effect.
|
|
737
|
-
)
|
|
847
|
+
Effect.catchDefect(() => Effect.succeed(toolErrorResult(INTERNAL_TOOL_ERROR_MESSAGE)))
|
|
848
|
+
)
|
|
738
849
|
}
|
|
739
850
|
})
|
|
740
851
|
}
|
|
@@ -939,7 +1050,9 @@ export const registerResource: {
|
|
|
939
1050
|
uriTemplate: uriPath,
|
|
940
1051
|
annotations: options!
|
|
941
1052
|
})
|
|
942
|
-
const completions: Record<string, (input: string) => Effect.Effect<CompleteResult, InternalError>> =
|
|
1053
|
+
const completions: Record<string, (input: string) => Effect.Effect<CompleteResult, InternalError>> = Object.create(
|
|
1054
|
+
null
|
|
1055
|
+
)
|
|
943
1056
|
for (const [param, handle] of Object.entries(options.completion ?? {})) {
|
|
944
1057
|
const encodeArray = Schema.encodeUnknownEffect(Schema.Array(params[param]))
|
|
945
1058
|
const handler = (input: string) =>
|
|
@@ -1135,7 +1248,7 @@ export const registerPrompt = <
|
|
|
1135
1248
|
const completions: Record<
|
|
1136
1249
|
string,
|
|
1137
1250
|
(input: string) => Effect.Effect<CompleteResult, InternalError, McpServerClient>
|
|
1138
|
-
> =
|
|
1251
|
+
> = Object.create(null)
|
|
1139
1252
|
for (const [param, handle] of Object.entries(completion)) {
|
|
1140
1253
|
const encodeArray = Schema.encodeEffect(Schema.Array(props[param]))
|
|
1141
1254
|
const handler = (input: string) =>
|
|
@@ -1300,7 +1413,7 @@ const makeUriMatcher = <A>() => {
|
|
|
1300
1413
|
const compileUriTemplate = (segments: TemplateStringsArray, ...schemas: ReadonlyArray<Schema.Constraint>) => {
|
|
1301
1414
|
let routerPath = segments[0].replace(":", "::")
|
|
1302
1415
|
let uriPath = segments[0]
|
|
1303
|
-
const params: Record<string, Schema.Top> =
|
|
1416
|
+
const params: Record<string, Schema.Top> = Object.create(null)
|
|
1304
1417
|
let pathSchema = Schema.Tuple([]) as Schema.Top
|
|
1305
1418
|
if (schemas.length > 0) {
|
|
1306
1419
|
const arr: Array<Schema.Top> = []
|
|
@@ -1329,21 +1442,21 @@ const layerHandlers = (serverInfo: {
|
|
|
1329
1442
|
readonly name: string
|
|
1330
1443
|
readonly version: string
|
|
1331
1444
|
readonly extensions?: Record<`${string}/${string}`, unknown> | undefined
|
|
1332
|
-
}, options: {
|
|
1333
|
-
readonly clientSessions: Map<string, typeof Initialize.payloadSchema.Type>
|
|
1334
1445
|
}) =>
|
|
1335
1446
|
ClientRpcs.toLayer(
|
|
1336
1447
|
Effect.gen(function*() {
|
|
1337
1448
|
const server = yield* McpServer
|
|
1449
|
+
const protocolState = yield* McpProtocolState
|
|
1450
|
+
const clientSessions = protocolState.clientSessions
|
|
1338
1451
|
let currentLogLevel = yield* CurrentLogLevel
|
|
1339
1452
|
|
|
1340
1453
|
return ClientRpcs.of({
|
|
1341
1454
|
// Requests
|
|
1342
1455
|
ping: () => Effect.succeed({}),
|
|
1343
1456
|
initialize(params, { client }) {
|
|
1344
|
-
const requestedVersion =
|
|
1457
|
+
const requestedVersion = protocolState.supportedProtocolVersions.has(params.protocolVersion)
|
|
1345
1458
|
? params.protocolVersion
|
|
1346
|
-
:
|
|
1459
|
+
: protocolState.latestProtocolVersion
|
|
1347
1460
|
if (requestedVersion !== params.protocolVersion) {
|
|
1348
1461
|
params = {
|
|
1349
1462
|
...params,
|
|
@@ -1372,14 +1485,14 @@ const layerHandlers = (serverInfo: {
|
|
|
1372
1485
|
const httpRequest = Context.getOrUndefined(fiber.context, HttpServerRequest.HttpServerRequest)
|
|
1373
1486
|
if (httpRequest) {
|
|
1374
1487
|
const sessionId = crypto.randomUUID()
|
|
1375
|
-
|
|
1488
|
+
clientSessions.set(sessionId, params)
|
|
1376
1489
|
appendPreResponseHandlerUnsafe(httpRequest, (_req, res) =>
|
|
1377
1490
|
Effect.succeed(HttpServerResponse.setHeaders(res, {
|
|
1378
|
-
[
|
|
1379
|
-
[
|
|
1491
|
+
[MCP_SESSION_ID_HEADER]: sessionId,
|
|
1492
|
+
[MCP_PROTOCOL_VERSION_HEADER]: requestedVersion
|
|
1380
1493
|
})))
|
|
1381
1494
|
} else {
|
|
1382
|
-
|
|
1495
|
+
clientSessions.set(String(client.id), params)
|
|
1383
1496
|
}
|
|
1384
1497
|
return Effect.succeed({
|
|
1385
1498
|
capabilities,
|
|
@@ -1421,12 +1534,12 @@ const layerHandlers = (serverInfo: {
|
|
|
1421
1534
|
),
|
|
1422
1535
|
"prompts/list": (_, { client, headers }) =>
|
|
1423
1536
|
Effect.sync(() => {
|
|
1424
|
-
const initialized = getInitializedClient(
|
|
1537
|
+
const initialized = getInitializedClient(clientSessions, client.id, headers)
|
|
1425
1538
|
return new ListPromptsResult({ prompts: filterByClient(initialized, server.prompts, "prompt") })
|
|
1426
1539
|
}),
|
|
1427
1540
|
"resources/list": (_, { client, headers }) =>
|
|
1428
1541
|
Effect.sync(() => {
|
|
1429
|
-
const initialized = getInitializedClient(
|
|
1542
|
+
const initialized = getInitializedClient(clientSessions, client.id, headers)
|
|
1430
1543
|
return new ListResourcesResult({ resources: filterByClient(initialized, server.resources, "resource") })
|
|
1431
1544
|
}),
|
|
1432
1545
|
"resources/read": ({ uri }) =>
|
|
@@ -1439,7 +1552,7 @@ const layerHandlers = (serverInfo: {
|
|
|
1439
1552
|
InternalError.notImplemented,
|
|
1440
1553
|
"resources/templates/list": (_, { client, headers }) =>
|
|
1441
1554
|
Effect.sync(() => {
|
|
1442
|
-
const initialized = getInitializedClient(
|
|
1555
|
+
const initialized = getInitializedClient(clientSessions, client.id, headers)
|
|
1443
1556
|
return new ListResourceTemplatesResult({
|
|
1444
1557
|
resourceTemplates: filterByClient(initialized, server.resourceTemplates, "template")
|
|
1445
1558
|
})
|
|
@@ -1450,7 +1563,7 @@ const layerHandlers = (serverInfo: {
|
|
|
1450
1563
|
),
|
|
1451
1564
|
"tools/list": (_, { client, headers }) =>
|
|
1452
1565
|
Effect.sync(() => {
|
|
1453
|
-
const initialized = getInitializedClient(
|
|
1566
|
+
const initialized = getInitializedClient(clientSessions, client.id, headers)
|
|
1454
1567
|
return new ListToolsResult({
|
|
1455
1568
|
tools: filterByClient(initialized, server.tools, "tool")
|
|
1456
1569
|
})
|
|
@@ -1458,7 +1571,10 @@ const layerHandlers = (serverInfo: {
|
|
|
1458
1571
|
|
|
1459
1572
|
// Notifications
|
|
1460
1573
|
"notifications/cancelled": (_) => Effect.void,
|
|
1461
|
-
"notifications/initialized": (_) =>
|
|
1574
|
+
"notifications/initialized": (_, { client }) =>
|
|
1575
|
+
Effect.sync(() => {
|
|
1576
|
+
server.initializedClients.add(client.id)
|
|
1577
|
+
}),
|
|
1462
1578
|
"notifications/progress": (_) => Effect.void,
|
|
1463
1579
|
"notifications/roots/list_changed": (_) => Effect.void
|
|
1464
1580
|
})
|
|
@@ -1516,7 +1632,7 @@ const getInitializedClient = (
|
|
|
1516
1632
|
clientId: number,
|
|
1517
1633
|
headers: Headers.Headers
|
|
1518
1634
|
) => {
|
|
1519
|
-
const sessionId = headers[
|
|
1635
|
+
const sessionId = headers[MCP_SESSION_ID_HEADER]
|
|
1520
1636
|
if (sessionId === undefined) {
|
|
1521
1637
|
return sessions.get(String(clientId))
|
|
1522
1638
|
}
|