effect 4.0.7 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +3 -0
- package/dist/BigDecimal.js.map +1 -1
- package/dist/Channel.d.ts +12 -6
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +9 -3
- package/dist/Channel.js.map +1 -1
- package/dist/Config.d.ts +7 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js.map +1 -1
- package/dist/Context.d.ts +18 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +27 -8
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +81 -11
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +101 -26
- package/dist/Cron.js.map +1 -1
- package/dist/Duration.d.ts +78 -0
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +123 -0
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +164 -7
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +11 -1
- package/dist/Effect.js.map +1 -1
- package/dist/FileSystem.d.ts +59 -4
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +9 -2
- package/dist/FileSystem.js.map +1 -1
- package/dist/Glob.d.ts +165 -0
- package/dist/Glob.d.ts.map +1 -0
- package/dist/Glob.js +127 -0
- package/dist/Glob.js.map +1 -0
- package/dist/Match.d.ts +86 -0
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +72 -0
- package/dist/Match.js.map +1 -1
- package/dist/Pool.d.ts +51 -0
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +59 -9
- package/dist/Pool.js.map +1 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +3 -3
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +8 -2
- package/dist/RcMap.js.map +1 -1
- package/dist/Schedule.d.ts +18 -1
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +7 -2
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +666 -41
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +650 -0
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.d.ts +6 -1
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +22 -11
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +14 -0
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +16 -0
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +8 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +6 -3
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +5 -7
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +130 -0
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +40 -0
- package/dist/Semaphore.js.map +1 -1
- package/dist/Stream.d.ts +13 -4
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +9 -0
- package/dist/Stream.js.map +1 -1
- package/dist/Terminal.d.ts +18 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/ai/AiError.d.ts +43 -116
- package/dist/ai/AiError.d.ts.map +1 -1
- package/dist/ai/AiError.js +53 -72
- package/dist/ai/AiError.js.map +1 -1
- package/dist/ai/Decision.d.ts +196 -15
- package/dist/ai/Decision.d.ts.map +1 -1
- package/dist/ai/Decision.js +130 -0
- package/dist/ai/Decision.js.map +1 -1
- package/dist/ai/DecisionModel.d.ts +54 -13
- package/dist/ai/DecisionModel.d.ts.map +1 -1
- package/dist/ai/DecisionModel.js +123 -12
- package/dist/ai/DecisionModel.js.map +1 -1
- package/dist/ai/McpServer.d.ts +630 -29
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +562 -116
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/McpTest.d.ts +130 -0
- package/dist/ai/McpTest.d.ts.map +1 -0
- package/dist/ai/McpTest.js +237 -0
- package/dist/ai/McpTest.js.map +1 -0
- package/dist/ai/Response.d.ts +1 -25
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +1 -10
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +19 -1
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +5 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/internal/mcpCore.js +17 -12
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +18 -10
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +13 -0
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +5 -3
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpStatefulRuntime.js +6 -1
- package/dist/ai/internal/mcpStatefulRuntime.js.map +1 -1
- package/dist/cli/Argument.d.ts +6 -0
- package/dist/cli/Argument.d.ts.map +1 -1
- package/dist/cli/Argument.js +2 -0
- package/dist/cli/Argument.js.map +1 -1
- package/dist/cli/CliOutput.d.ts +65 -1
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +94 -37
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts +23 -0
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +8 -0
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Flag.d.ts +107 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +37 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/HelpDoc.d.ts +15 -1
- package/dist/cli/HelpDoc.d.ts.map +1 -1
- package/dist/cli/Param.d.ts +6 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +2 -0
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/Primitive.d.ts +14 -0
- package/dist/cli/Primitive.d.ts.map +1 -1
- package/dist/cli/Primitive.js +15 -1
- package/dist/cli/Primitive.js.map +1 -1
- package/dist/cli/Prompt.d.ts +1 -0
- package/dist/cli/Prompt.d.ts.map +1 -1
- package/dist/cli/Prompt.js +1 -0
- package/dist/cli/Prompt.js.map +1 -1
- package/dist/cli/internal/help.d.ts.map +1 -1
- package/dist/cli/internal/help.js +17 -10
- package/dist/cli/internal/help.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +90 -28
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +72 -6
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js +4 -0
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/SingleRunner.d.ts +3 -3
- package/dist/cluster/SingleRunner.d.ts.map +1 -1
- package/dist/cluster/SingleRunner.js +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts +37 -6
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +34 -7
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +23 -8
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/crypto/Aead.d.ts +322 -0
- package/dist/crypto/Aead.d.ts.map +1 -0
- package/dist/crypto/Aead.js +331 -0
- package/dist/crypto/Aead.js.map +1 -0
- package/dist/crypto/Cipher.d.ts +235 -0
- package/dist/crypto/Cipher.d.ts.map +1 -0
- package/dist/crypto/Cipher.js +233 -0
- package/dist/crypto/Cipher.js.map +1 -0
- package/dist/crypto/CryptoError.d.ts +212 -0
- package/dist/crypto/CryptoError.d.ts.map +1 -0
- package/dist/crypto/CryptoError.js +202 -0
- package/dist/crypto/CryptoError.js.map +1 -0
- package/dist/crypto/Digest.d.ts +143 -0
- package/dist/crypto/Digest.d.ts.map +1 -0
- package/dist/crypto/Digest.js +146 -0
- package/dist/crypto/Digest.js.map +1 -0
- package/dist/crypto/Kdf.d.ts +220 -0
- package/dist/crypto/Kdf.d.ts.map +1 -0
- package/dist/crypto/Kdf.js +212 -0
- package/dist/crypto/Kdf.js.map +1 -0
- package/dist/crypto/KeyAgreement.d.ts +323 -0
- package/dist/crypto/KeyAgreement.d.ts.map +1 -0
- package/dist/crypto/KeyAgreement.js +303 -0
- package/dist/crypto/KeyAgreement.js.map +1 -0
- package/dist/crypto/KeyFormat.d.ts +309 -0
- package/dist/crypto/KeyFormat.d.ts.map +1 -0
- package/dist/crypto/KeyFormat.js +556 -0
- package/dist/crypto/KeyFormat.js.map +1 -0
- package/dist/crypto/KeyWrap.d.ts +389 -0
- package/dist/crypto/KeyWrap.d.ts.map +1 -0
- package/dist/crypto/KeyWrap.js +381 -0
- package/dist/crypto/KeyWrap.js.map +1 -0
- package/dist/crypto/Mac.d.ts +277 -0
- package/dist/crypto/Mac.d.ts.map +1 -0
- package/dist/crypto/Mac.js +288 -0
- package/dist/crypto/Mac.js.map +1 -0
- package/dist/crypto/SecureRandom.d.ts +340 -0
- package/dist/crypto/SecureRandom.d.ts.map +1 -0
- package/dist/crypto/SecureRandom.js +257 -0
- package/dist/crypto/SecureRandom.js.map +1 -0
- package/dist/crypto/Signature.d.ts +448 -0
- package/dist/crypto/Signature.d.ts.map +1 -0
- package/dist/crypto/Signature.js +484 -0
- package/dist/crypto/Signature.js.map +1 -0
- package/dist/crypto/WebCrypto.d.ts +61 -0
- package/dist/crypto/WebCrypto.d.ts.map +1 -0
- package/dist/crypto/WebCrypto.js +63 -0
- package/dist/crypto/WebCrypto.js.map +1 -0
- package/dist/crypto/index.d.ts +65 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/index.js +66 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/crypto/internal/asymmetric.d.ts +2 -0
- package/dist/crypto/internal/asymmetric.d.ts.map +1 -0
- package/dist/crypto/internal/asymmetric.js +210 -0
- package/dist/crypto/internal/asymmetric.js.map +1 -0
- package/dist/crypto/internal/chacha.d.ts +46 -0
- package/dist/crypto/internal/chacha.d.ts.map +1 -0
- package/dist/crypto/internal/chacha.js +885 -0
- package/dist/crypto/internal/chacha.js.map +1 -0
- package/dist/crypto/internal/der.d.ts +6 -0
- package/dist/crypto/internal/der.d.ts.map +1 -0
- package/dist/crypto/internal/der.js +86 -0
- package/dist/crypto/internal/der.js.map +1 -0
- package/dist/crypto/internal/digest.d.ts +2 -0
- package/dist/crypto/internal/digest.d.ts.map +1 -0
- package/dist/crypto/internal/digest.js +15 -0
- package/dist/crypto/internal/digest.js.map +1 -0
- package/dist/crypto/internal/key.d.ts +2 -0
- package/dist/crypto/internal/key.d.ts.map +1 -0
- package/dist/crypto/internal/key.js +170 -0
- package/dist/crypto/internal/key.js.map +1 -0
- package/dist/crypto/internal/md5.d.ts +39 -0
- package/dist/crypto/internal/md5.d.ts.map +1 -0
- package/dist/crypto/internal/md5.js +179 -0
- package/dist/crypto/internal/md5.js.map +1 -0
- package/dist/crypto/internal/webCrypto.d.ts +2 -0
- package/dist/crypto/internal/webCrypto.d.ts.map +1 -0
- package/dist/crypto/internal/webCrypto.js +111 -0
- package/dist/crypto/internal/webCrypto.js.map +1 -0
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +3 -2
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Csv.d.ts +608 -0
- package/dist/encoding/Csv.d.ts.map +1 -0
- package/dist/encoding/Csv.js +718 -0
- package/dist/encoding/Csv.js.map +1 -0
- package/dist/encoding/Hex.d.ts +3 -2
- package/dist/encoding/Hex.d.ts.map +1 -1
- package/dist/encoding/Hex.js +3 -2
- package/dist/encoding/Hex.js.map +1 -1
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +42 -4
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Toml.d.ts +17 -3
- package/dist/encoding/Toml.d.ts.map +1 -1
- package/dist/encoding/Toml.js +104 -16
- package/dist/encoding/Toml.js.map +1 -1
- package/dist/encoding/Yaml.d.ts +8 -1
- package/dist/encoding/Yaml.d.ts.map +1 -1
- package/dist/encoding/Yaml.js +54 -18
- package/dist/encoding/Yaml.js.map +1 -1
- package/dist/encoding/index.d.ts +5 -0
- package/dist/encoding/index.d.ts.map +1 -1
- package/dist/encoding/index.js +5 -0
- package/dist/encoding/index.js.map +1 -1
- package/dist/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/eventlog/EventJournal.js +6 -3
- package/dist/eventlog/EventJournal.js.map +1 -1
- package/dist/eventlog/EventLog.d.ts +119 -4
- package/dist/eventlog/EventLog.d.ts.map +1 -1
- package/dist/eventlog/EventLog.js +200 -12
- package/dist/eventlog/EventLog.js.map +1 -1
- package/dist/eventlog/EventLogEncryption.d.ts +41 -4
- package/dist/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/eventlog/EventLogEncryption.js +83 -64
- package/dist/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/eventlog/EventLogMessage.d.ts +279 -0
- package/dist/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/eventlog/EventLogMessage.js +217 -1
- package/dist/eventlog/EventLogMessage.js.map +1 -1
- package/dist/eventlog/EventLogRemote.d.ts +200 -28
- package/dist/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/eventlog/EventLogRemote.js +186 -16
- package/dist/eventlog/EventLogRemote.js.map +1 -1
- package/dist/eventlog/EventLogServer.d.ts +3 -0
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +18 -10
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.d.ts +326 -5
- package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.js +769 -14
- package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.d.ts +5 -3
- package/dist/eventlog/EventLogSessionAuth.d.ts.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.js +41 -64
- package/dist/eventlog/EventLogSessionAuth.js.map +1 -1
- package/dist/eventlog/EventRow.d.ts +4 -0
- package/dist/eventlog/EventRow.d.ts.map +1 -1
- package/dist/eventlog/EventRow.js +12 -2
- package/dist/eventlog/EventRow.js.map +1 -1
- package/dist/eventlog/SqlEventJournal.js +2 -2
- package/dist/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.d.ts +21 -5
- package/dist/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.js +1048 -113
- package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerUnencrypted.js +2 -2
- package/dist/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/eventlog/internal/batches.d.ts +12 -0
- package/dist/eventlog/internal/batches.d.ts.map +1 -0
- package/dist/eventlog/internal/batches.js +26 -0
- package/dist/eventlog/internal/batches.js.map +1 -0
- package/dist/eventlog/internal/compaction.d.ts +38 -0
- package/dist/eventlog/internal/compaction.d.ts.map +1 -0
- package/dist/eventlog/internal/compaction.js +33 -0
- package/dist/eventlog/internal/compaction.js.map +1 -0
- package/dist/eventlog/internal/identityRootSecretDerivation.js +66 -67
- package/dist/eventlog/internal/identityRootSecretDerivation.js.map +1 -1
- package/dist/eventlog/internal/remoteCompaction.d.ts +31 -0
- package/dist/eventlog/internal/remoteCompaction.d.ts.map +1 -0
- package/dist/eventlog/internal/remoteCompaction.js +76 -0
- package/dist/eventlog/internal/remoteCompaction.js.map +1 -0
- package/dist/http/Cookies.d.ts +172 -0
- package/dist/http/Cookies.d.ts.map +1 -1
- package/dist/http/Cookies.js +143 -1
- package/dist/http/Cookies.js.map +1 -1
- package/dist/http/FetchHttpClient.d.ts +26 -2
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +78 -15
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/HttpClient.d.ts +79 -8
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +65 -5
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +9 -5
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +2 -3
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/http/HttpClientResponse.js +3 -2
- package/dist/http/HttpClientResponse.js.map +1 -1
- package/dist/http/HttpMethod.d.ts +7 -1
- package/dist/http/HttpMethod.d.ts.map +1 -1
- package/dist/http/HttpMethod.js +3 -8
- package/dist/http/HttpMethod.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts +5 -2
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +6 -17
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +3 -2
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/HttpTraceContext.d.ts +2 -1
- package/dist/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/http/HttpTraceContext.js +7 -5
- package/dist/http/HttpTraceContext.js.map +1 -1
- package/dist/http/ProblemDetails.d.ts +96 -0
- package/dist/http/ProblemDetails.d.ts.map +1 -0
- package/dist/http/ProblemDetails.js +98 -0
- package/dist/http/ProblemDetails.js.map +1 -0
- package/dist/http/index.d.ts +5 -0
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +5 -0
- package/dist/http/index.js.map +1 -1
- package/dist/http/internal/decompression.js +3 -2
- package/dist/http/internal/decompression.js.map +1 -1
- package/dist/http/internal/urlParams.js +8 -0
- package/dist/http/internal/urlParams.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +19 -5
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +63 -0
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +51 -0
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +14 -5
- package/dist/http-api/HttpApiEndpoint.js.map +1 -1
- package/dist/http-api/HttpApiError.d.ts +185 -13
- package/dist/http-api/HttpApiError.d.ts.map +1 -1
- package/dist/http-api/HttpApiError.js +128 -0
- package/dist/http-api/HttpApiError.js.map +1 -1
- package/dist/http-api/HttpApiMiddleware.d.ts +64 -17
- package/dist/http-api/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/http-api/HttpApiMiddleware.js +85 -1
- package/dist/http-api/HttpApiMiddleware.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +76 -14
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +53 -0
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +25 -14
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/glob.d.ts +2 -0
- package/dist/internal/glob.d.ts.map +1 -0
- package/dist/internal/glob.js +630 -0
- package/dist/internal/glob.js.map +1 -0
- package/dist/internal/matcher.js +10 -0
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/persistence.js +9 -0
- package/dist/internal/persistence.js.map +1 -1
- package/dist/internal/rcRef.js +4 -1
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +6 -3
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/trie.js +42 -13
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/ulid.js +41 -0
- package/dist/internal/ulid.js.map +1 -1
- package/dist/internal/uuid.js +52 -8
- package/dist/internal/uuid.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/observability/Otlp.d.ts +15 -4
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +10 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpResource.d.ts +7 -0
- package/dist/observability/OtlpResource.d.ts.map +1 -1
- package/dist/observability/OtlpResource.js +11 -1
- package/dist/observability/OtlpResource.js.map +1 -1
- package/dist/persistence/KeyValueStore.d.ts +47 -2
- package/dist/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/persistence/KeyValueStore.js +129 -18
- package/dist/persistence/KeyValueStore.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts +9 -0
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +94 -52
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/persistence/Persistence.d.ts +10 -4
- package/dist/persistence/Persistence.d.ts.map +1 -1
- package/dist/persistence/Persistence.js +18 -11
- package/dist/persistence/Persistence.js.map +1 -1
- package/dist/process/ChildProcess.d.ts +207 -67
- package/dist/process/ChildProcess.d.ts.map +1 -1
- package/dist/process/ChildProcess.js +56 -158
- package/dist/process/ChildProcess.js.map +1 -1
- package/dist/process/ChildProcessSpawner.d.ts +5 -0
- package/dist/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/process/ChildProcessSpawner.js.map +1 -1
- package/dist/process/CommandLine.d.ts +294 -0
- package/dist/process/CommandLine.d.ts.map +1 -0
- package/dist/process/CommandLine.js +481 -0
- package/dist/process/CommandLine.js.map +1 -0
- package/dist/process/index.d.ts +5 -0
- package/dist/process/index.d.ts.map +1 -1
- package/dist/process/index.js +5 -0
- package/dist/process/index.js.map +1 -1
- package/dist/reactivity/Atom.d.ts +2 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +3 -4
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +16 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +50 -16
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcMessage.d.ts +10 -1
- package/dist/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/rpc/RpcMessage.js +1 -0
- package/dist/rpc/RpcMessage.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +6 -0
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts +31 -0
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +139 -66
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/schema/Model.d.ts +14 -0
- package/dist/schema/Model.d.ts.map +1 -1
- package/dist/schema/Model.js +18 -3
- package/dist/schema/Model.js.map +1 -1
- package/dist/sql/Migrator.d.ts +0 -19
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +3 -48
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/MigratorFileSystem.d.ts +21 -0
- package/dist/sql/MigratorFileSystem.d.ts.map +1 -0
- package/dist/sql/MigratorFileSystem.js +57 -0
- package/dist/sql/MigratorFileSystem.js.map +1 -0
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +5 -9
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +20 -6
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +0 -13
- package/dist/sql/Statement.js.map +1 -1
- package/dist/sql/index.js +1 -1
- package/dist/testing/index.d.ts +0 -5
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +0 -5
- package/dist/testing/index.js.map +1 -1
- package/dist/workflow/internal/crypto.js +9 -8
- package/dist/workflow/internal/crypto.js.map +1 -1
- package/package.json +3 -1
- package/src/BigDecimal.ts +3 -0
- package/src/Channel.ts +17 -11
- package/src/Config.ts +7 -1
- package/src/Context.ts +34 -10
- package/src/Cron.ts +178 -29
- package/src/Duration.ts +140 -0
- package/src/Effect.ts +914 -85
- package/src/FileSystem.ts +65 -4
- package/src/Glob.ts +205 -0
- package/src/Match.ts +127 -0
- package/src/Pool.ts +73 -15
- package/src/Random.ts +3 -3
- package/src/RcMap.ts +5 -1
- package/src/Schedule.ts +26 -3
- package/src/Schema.ts +1189 -62
- package/src/SchemaGetter.ts +27 -11
- package/src/SchemaRepresentation.ts +19 -0
- package/src/SchemaTransformation.ts +8 -3
- package/src/ScopedCache.ts +5 -9
- package/src/Semaphore.ts +141 -0
- package/src/Stream.ts +15 -6
- package/src/Terminal.ts +19 -1
- package/src/ai/AiError.ts +56 -80
- package/src/ai/Decision.ts +257 -6
- package/src/ai/DecisionModel.ts +171 -28
- package/src/ai/McpServer.ts +1269 -286
- package/src/ai/McpTest.ts +380 -0
- package/src/ai/Response.ts +2 -22
- package/src/ai/Tool.ts +27 -8
- package/src/ai/index.ts +6 -0
- package/src/ai/internal/mcpCore.ts +78 -44
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +15 -10
- package/src/ai/internal/mcpProtocol.ts +29 -0
- package/src/ai/internal/mcpRuntime.ts +9 -5
- package/src/ai/internal/mcpStatefulRuntime.ts +14 -2
- package/src/cli/Argument.ts +6 -0
- package/src/cli/CliOutput.ts +117 -49
- package/src/cli/Command.ts +23 -0
- package/src/cli/Flag.ts +107 -0
- package/src/cli/HelpDoc.ts +18 -1
- package/src/cli/Param.ts +6 -0
- package/src/cli/Primitive.ts +16 -1
- package/src/cli/Prompt.ts +1 -0
- package/src/cli/internal/help.ts +21 -9
- package/src/cluster/Sharding.ts +93 -26
- package/src/cluster/ShardingConfig.ts +41 -3
- package/src/cluster/SingleRunner.ts +3 -3
- package/src/cluster/SqlMessageStorage.ts +49 -17
- package/src/cluster/SqlRunnerStorage.ts +37 -27
- package/src/crypto/Aead.ts +517 -0
- package/src/crypto/Cipher.ts +326 -0
- package/src/crypto/CryptoError.ts +242 -0
- package/src/crypto/Digest.ts +167 -0
- package/src/crypto/Kdf.ts +315 -0
- package/src/crypto/KeyAgreement.ts +489 -0
- package/src/crypto/KeyFormat.ts +712 -0
- package/src/crypto/KeyWrap.ts +639 -0
- package/src/crypto/Mac.ts +386 -0
- package/src/crypto/SecureRandom.ts +459 -0
- package/src/crypto/Signature.ts +673 -0
- package/src/crypto/WebCrypto.ts +64 -0
- package/src/crypto/index.ts +78 -0
- package/src/crypto/internal/asymmetric.ts +329 -0
- package/src/crypto/internal/chacha.ts +1088 -0
- package/src/crypto/internal/der.ts +110 -0
- package/src/crypto/internal/digest.ts +16 -0
- package/src/crypto/internal/key.ts +235 -0
- package/src/crypto/internal/md5.ts +170 -0
- package/src/crypto/internal/webCrypto.ts +150 -0
- package/src/encoding/Base64Url.ts +5 -2
- package/src/encoding/Csv.ts +1298 -0
- package/src/encoding/Hex.ts +3 -2
- package/src/encoding/SchemaBinary.ts +40 -4
- package/src/encoding/Toml.ts +85 -20
- package/src/encoding/Yaml.ts +61 -18
- package/src/encoding/index.ts +6 -0
- package/src/eventlog/EventJournal.ts +4 -3
- package/src/eventlog/EventLog.ts +340 -15
- package/src/eventlog/EventLogEncryption.ts +118 -110
- package/src/eventlog/EventLogMessage.ts +273 -1
- package/src/eventlog/EventLogRemote.ts +367 -23
- package/src/eventlog/EventLogServer.ts +23 -8
- package/src/eventlog/EventLogServerEncrypted.ts +1130 -67
- package/src/eventlog/EventLogSessionAuth.ts +56 -70
- package/src/eventlog/EventRow.ts +12 -3
- package/src/eventlog/SqlEventJournal.ts +2 -2
- package/src/eventlog/SqlEventLogServerEncrypted.ts +1244 -136
- package/src/eventlog/SqlEventLogServerUnencrypted.ts +2 -2
- package/src/eventlog/internal/batches.ts +30 -0
- package/src/eventlog/internal/compaction.ts +64 -0
- package/src/eventlog/internal/identityRootSecretDerivation.ts +93 -123
- package/src/eventlog/internal/remoteCompaction.ts +92 -0
- package/src/http/Cookies.ts +281 -1
- package/src/http/FetchHttpClient.ts +88 -16
- package/src/http/HttpClient.ts +89 -22
- package/src/http/HttpClientRequest.ts +12 -9
- package/src/http/HttpClientResponse.ts +3 -2
- package/src/http/HttpMethod.ts +10 -2
- package/src/http/HttpServerRequest.ts +15 -30
- package/src/http/HttpServerResponse.ts +3 -2
- package/src/http/HttpTraceContext.ts +7 -4
- package/src/http/ProblemDetails.ts +149 -0
- package/src/http/index.ts +6 -0
- package/src/http/internal/decompression.ts +4 -4
- package/src/http/internal/urlParams.ts +8 -0
- package/src/http-api/HttpApiBuilder.ts +24 -12
- package/src/http-api/HttpApiClient.ts +67 -1
- package/src/http-api/HttpApiEndpoint.ts +14 -5
- package/src/http-api/HttpApiError.ts +250 -0
- package/src/http-api/HttpApiMiddleware.ts +95 -1
- package/src/http-api/HttpApiSchema.ts +105 -14
- package/src/index.ts +6 -6
- package/src/internal/effect.ts +34 -18
- package/src/internal/glob.ts +736 -0
- package/src/internal/matcher.ts +17 -0
- package/src/internal/persistence.ts +11 -0
- package/src/internal/rcRef.ts +4 -1
- package/src/internal/schema/toCodeDocument.ts +7 -3
- package/src/internal/trie.ts +43 -14
- package/src/internal/ulid.ts +44 -0
- package/src/internal/uuid.ts +57 -16
- package/src/internal/version.ts +1 -1
- package/src/observability/Otlp.ts +21 -4
- package/src/observability/OtlpResource.ts +9 -1
- package/src/persistence/KeyValueStore.ts +219 -22
- package/src/persistence/PersistedQueue.ts +128 -59
- package/src/persistence/Persistence.ts +20 -13
- package/src/process/ChildProcess.ts +255 -260
- package/src/process/ChildProcessSpawner.ts +5 -0
- package/src/process/CommandLine.ts +630 -0
- package/src/process/index.ts +6 -0
- package/src/reactivity/Atom.ts +5 -5
- package/src/reactivity/AtomRegistry.ts +1 -1
- package/src/rpc/RpcClient.ts +62 -26
- package/src/rpc/RpcMessage.ts +10 -1
- package/src/rpc/RpcSerialization.ts +3 -0
- package/src/rpc/RpcServer.ts +176 -78
- package/src/schema/Model.ts +26 -3
- package/src/sql/Migrator.ts +4 -63
- package/src/sql/MigratorFileSystem.ts +71 -0
- package/src/sql/SqlClient.ts +2 -16
- package/src/sql/Statement.ts +8 -7
- package/src/sql/index.ts +1 -1
- package/src/testing/index.ts +0 -6
- package/src/workflow/internal/crypto.ts +15 -11
- package/dist/Crypto.d.ts +0 -244
- package/dist/Crypto.d.ts.map +0 -1
- package/dist/Crypto.js +0 -139
- package/dist/Crypto.js.map +0 -1
- package/dist/testing/TestCrypto.d.ts +0 -73
- package/dist/testing/TestCrypto.d.ts.map +0 -1
- package/dist/testing/TestCrypto.js +0 -87
- package/dist/testing/TestCrypto.js.map +0 -1
- package/src/Crypto.ts +0 -347
- package/src/testing/TestCrypto.ts +0 -94
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory test client for `McpServer` registrations.
|
|
3
|
+
*
|
|
4
|
+
* `McpTest.makeClient` runs the MCP server over an in-memory
|
|
5
|
+
* `RpcServer.Protocol`, performs the handshake for the selected protocol
|
|
6
|
+
* version, and returns a typed client. Requests travel through the same
|
|
7
|
+
* JSON-RPC encoding, routing, middleware, and response encoding as the stdio
|
|
8
|
+
* and HTTP transports, so tests reach protocol encoding, list methods,
|
|
9
|
+
* sessions, and notifications without opening a transport.
|
|
10
|
+
*
|
|
11
|
+
* @stability unstable
|
|
12
|
+
* @since 4.0.0
|
|
13
|
+
*/
|
|
14
|
+
import type * as Arr from "../Array.ts"
|
|
15
|
+
import * as Cause from "../Cause.ts"
|
|
16
|
+
import * as Context from "../Context.ts"
|
|
17
|
+
import * as Effect from "../Effect.ts"
|
|
18
|
+
import { identity } from "../Function.ts"
|
|
19
|
+
import * as Layer from "../Layer.ts"
|
|
20
|
+
import * as Predicate from "../Predicate.ts"
|
|
21
|
+
import * as Queue from "../Queue.ts"
|
|
22
|
+
import * as RpcClient from "../rpc/RpcClient.ts"
|
|
23
|
+
import type * as RpcClientError from "../rpc/RpcClientError.ts"
|
|
24
|
+
import * as RpcMessage from "../rpc/RpcMessage.ts"
|
|
25
|
+
import * as RpcSerialization from "../rpc/RpcSerialization.ts"
|
|
26
|
+
import * as RpcServer from "../rpc/RpcServer.ts"
|
|
27
|
+
import * as Schema from "../Schema.ts"
|
|
28
|
+
import type * as Scope from "../Scope.ts"
|
|
29
|
+
import type * as McpProtocol from "./McpProtocol.ts"
|
|
30
|
+
import * as McpSchema from "./McpSchema.ts"
|
|
31
|
+
import * as McpServer from "./McpServer.ts"
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A typed in-memory MCP client connected to a running `McpServer`.
|
|
35
|
+
*
|
|
36
|
+
* **Details**
|
|
37
|
+
*
|
|
38
|
+
* Each request method mirrors one entry of `McpSchema.ClientRequestRpcs`,
|
|
39
|
+
* except `initialize`, which `makeClient` sends during the handshake. Requests
|
|
40
|
+
* are encoded with the client schemas and decoded with the server's selected
|
|
41
|
+
* protocol adapter, so results and errors match what a wire client observes.
|
|
42
|
+
*
|
|
43
|
+
* Server-to-client notifications are queued on `notifications` in their wire
|
|
44
|
+
* encoding, in delivery order. Server-to-client requests (elicitation, sampling, roots) are
|
|
45
|
+
* rejected with a method-not-found error.
|
|
46
|
+
*
|
|
47
|
+
* @stability unstable
|
|
48
|
+
* @category models
|
|
49
|
+
* @since 4.0.0
|
|
50
|
+
*/
|
|
51
|
+
export interface Client {
|
|
52
|
+
/**
|
|
53
|
+
* The protocol version negotiated during the handshake.
|
|
54
|
+
*/
|
|
55
|
+
readonly protocolVersion: McpProtocol.ProtocolVersion
|
|
56
|
+
/**
|
|
57
|
+
* The `McpServer` service the client is connected to, for registering
|
|
58
|
+
* capabilities or emitting notifications from a test.
|
|
59
|
+
*/
|
|
60
|
+
readonly server: McpServer.McpServer["Service"]
|
|
61
|
+
/**
|
|
62
|
+
* Notifications the server sent to this client, in delivery order.
|
|
63
|
+
*/
|
|
64
|
+
readonly notifications: Queue.Dequeue<McpSchema.ServerNotificationEncoded>
|
|
65
|
+
readonly ping: Effect.Effect<void, McpSchema.McpError>
|
|
66
|
+
readonly listTools: (
|
|
67
|
+
request?: typeof McpSchema.ListTools.payloadSchema.Type
|
|
68
|
+
) => Effect.Effect<McpSchema.ListToolsResult, McpSchema.McpError>
|
|
69
|
+
readonly callTool: (
|
|
70
|
+
request: typeof McpSchema.CallTool.payloadSchema.Type
|
|
71
|
+
) => Effect.Effect<McpSchema.CallToolResult, McpSchema.McpError>
|
|
72
|
+
readonly listResources: (
|
|
73
|
+
request?: typeof McpSchema.ListResources.payloadSchema.Type
|
|
74
|
+
) => Effect.Effect<McpSchema.ListResourcesResult, McpSchema.McpError>
|
|
75
|
+
readonly listResourceTemplates: (
|
|
76
|
+
request?: typeof McpSchema.ListResourceTemplates.payloadSchema.Type
|
|
77
|
+
) => Effect.Effect<McpSchema.ListResourceTemplatesResult, McpSchema.McpError>
|
|
78
|
+
readonly readResource: (
|
|
79
|
+
request: typeof McpSchema.ReadResource.payloadSchema.Type
|
|
80
|
+
) => Effect.Effect<McpSchema.ReadResourceResult, McpSchema.McpError>
|
|
81
|
+
readonly subscribe: (
|
|
82
|
+
request: typeof McpSchema.Subscribe.payloadSchema.Type
|
|
83
|
+
) => Effect.Effect<void, McpSchema.McpError>
|
|
84
|
+
readonly unsubscribe: (
|
|
85
|
+
request: typeof McpSchema.Unsubscribe.payloadSchema.Type
|
|
86
|
+
) => Effect.Effect<void, McpSchema.McpError>
|
|
87
|
+
readonly listPrompts: (
|
|
88
|
+
request?: typeof McpSchema.ListPrompts.payloadSchema.Type
|
|
89
|
+
) => Effect.Effect<McpSchema.ListPromptsResult, McpSchema.McpError>
|
|
90
|
+
readonly getPrompt: (
|
|
91
|
+
request: typeof McpSchema.GetPrompt.payloadSchema.Type
|
|
92
|
+
) => Effect.Effect<McpSchema.GetPromptResult, McpSchema.McpError>
|
|
93
|
+
readonly complete: (
|
|
94
|
+
request: typeof McpSchema.Complete.payloadSchema.Type
|
|
95
|
+
) => Effect.Effect<McpSchema.CompleteResult, McpSchema.McpError>
|
|
96
|
+
readonly setLevel: (
|
|
97
|
+
request: typeof McpSchema.SetLevel.payloadSchema.Type
|
|
98
|
+
) => Effect.Effect<void, McpSchema.McpError>
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Creates an in-memory MCP client for a registration layer.
|
|
103
|
+
*
|
|
104
|
+
* **Details**
|
|
105
|
+
*
|
|
106
|
+
* The server is built from `McpServer.layer` with the supplied `protocols`
|
|
107
|
+
* and `registrations`, over an in-memory `RpcServer.Protocol`. The client
|
|
108
|
+
* speaks `options.protocolVersion`, by default the first adapter's version:
|
|
109
|
+
* stateful versions `initialize` and send `notifications/initialized` before
|
|
110
|
+
* `makeClient` returns; the stateless version attaches request metadata to
|
|
111
|
+
* every request instead.
|
|
112
|
+
*
|
|
113
|
+
* Because requests reach handlers through the server runner, the transport
|
|
114
|
+
* built-ins are discharged the same way as on stdio: `McpRequestContext` on
|
|
115
|
+
* every request, and `McpServerClient` only when every adapter in `protocols`
|
|
116
|
+
* is stateful (see `McpServer.ProvidedServices`). Any other `McpRequest`
|
|
117
|
+
* marker in `registrations` stays in the requirements and must be met by MCP
|
|
118
|
+
* middleware; providing the service directly does not discharge it.
|
|
119
|
+
*
|
|
120
|
+
* The client and server live in the surrounding `Scope`.
|
|
121
|
+
*
|
|
122
|
+
* **Example** (Reading a resource in a test)
|
|
123
|
+
*
|
|
124
|
+
* ```ts import.meta.vitest
|
|
125
|
+
* import { Effect } from "effect"
|
|
126
|
+
* import { McpProtocol, McpServer, McpTest } from "effect/ai"
|
|
127
|
+
*
|
|
128
|
+
* const registrations = McpServer.resource({
|
|
129
|
+
* uri: "test://greeting",
|
|
130
|
+
* name: "greeting",
|
|
131
|
+
* content: Effect.succeed("hello")
|
|
132
|
+
* })
|
|
133
|
+
*
|
|
134
|
+
* const program = Effect.gen(function*() {
|
|
135
|
+
* const client = yield* McpTest.makeClient(registrations, {
|
|
136
|
+
* protocols: [McpProtocol.v2025_11_25]
|
|
137
|
+
* })
|
|
138
|
+
* const result = yield* client.readResource({ uri: "test://greeting" })
|
|
139
|
+
* return result.contents.map((content) => content.uri)
|
|
140
|
+
* }).pipe(Effect.scoped)
|
|
141
|
+
*
|
|
142
|
+
* const actual = await Effect.runPromise(program)
|
|
143
|
+
* actual // => ["test://greeting"]
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @see {@link Client} for the request methods and notifications
|
|
147
|
+
* @see {@link McpServer.middleware} for discharging request-level dependencies
|
|
148
|
+
*
|
|
149
|
+
* @stability unstable
|
|
150
|
+
* @category constructors
|
|
151
|
+
* @since 4.0.0
|
|
152
|
+
*/
|
|
153
|
+
export const makeClient: <
|
|
154
|
+
const Protocols extends Arr.NonEmptyReadonlyArray<McpProtocol.ProtocolAdapter>,
|
|
155
|
+
RA = never,
|
|
156
|
+
RE = never,
|
|
157
|
+
RR = never
|
|
158
|
+
>(
|
|
159
|
+
registrations: Layer.Layer<RA, RE, RR>,
|
|
160
|
+
options: {
|
|
161
|
+
readonly protocols: Protocols
|
|
162
|
+
readonly protocolVersion?: Protocols[number]["protocolVersion"] | undefined
|
|
163
|
+
readonly name?: string | undefined
|
|
164
|
+
readonly version?: string | undefined
|
|
165
|
+
readonly instructions?: string | undefined
|
|
166
|
+
readonly extensions?: NonNullable<McpSchema.ServerCapabilities["extensions"]> | undefined
|
|
167
|
+
readonly clientInfo?: McpSchema.Implementation | undefined
|
|
168
|
+
readonly clientCapabilities?: McpSchema.ClientCapabilities | undefined
|
|
169
|
+
}
|
|
170
|
+
) => Effect.Effect<
|
|
171
|
+
Client,
|
|
172
|
+
Cause.IllegalArgumentError | RE,
|
|
173
|
+
| Scope.Scope
|
|
174
|
+
| Exclude<McpServer.McpRequest.Without<RR>, McpServer.McpServer>
|
|
175
|
+
| McpServer.McpRequest.From<
|
|
176
|
+
"Requires",
|
|
177
|
+
Exclude<McpServer.McpRequest.Only<"Requires", RR>, McpServer.ProvidedServices<Protocols>>
|
|
178
|
+
>
|
|
179
|
+
> = Effect.fnUntraced(function*(
|
|
180
|
+
registrations: Layer.Layer<any, any, any>,
|
|
181
|
+
options: {
|
|
182
|
+
readonly protocols: Arr.NonEmptyReadonlyArray<McpProtocol.ProtocolAdapter>
|
|
183
|
+
readonly protocolVersion?: string | undefined
|
|
184
|
+
readonly name?: string | undefined
|
|
185
|
+
readonly version?: string | undefined
|
|
186
|
+
readonly instructions?: string | undefined
|
|
187
|
+
readonly extensions?: NonNullable<McpSchema.ServerCapabilities["extensions"]> | undefined
|
|
188
|
+
readonly clientInfo?: McpSchema.Implementation | undefined
|
|
189
|
+
readonly clientCapabilities?: McpSchema.ClientCapabilities | undefined
|
|
190
|
+
}
|
|
191
|
+
) {
|
|
192
|
+
const selected = options.protocolVersion === undefined
|
|
193
|
+
? options.protocols[0]
|
|
194
|
+
: options.protocols.find((protocol) => protocol.protocolVersion === options.protocolVersion)
|
|
195
|
+
if (selected === undefined) {
|
|
196
|
+
return yield* new Cause.IllegalArgumentError(
|
|
197
|
+
`MCP protocol ${options.protocolVersion} is not in the configured protocols`
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
const clientInfo = options.clientInfo ?? defaultClientInfo
|
|
201
|
+
const clientCapabilities = options.clientCapabilities ?? new McpSchema.ClientCapabilities({})
|
|
202
|
+
|
|
203
|
+
// Each direction carries one serialized JSON-RPC message per element, so
|
|
204
|
+
// requests and responses round-trip through the same JSON-RPC encoding as
|
|
205
|
+
// the stdio and HTTP transports.
|
|
206
|
+
const toServer = yield* Queue.unbounded<string>()
|
|
207
|
+
const toClient = yield* Queue.unbounded<string>()
|
|
208
|
+
const notifications = yield* Queue.unbounded<McpSchema.ServerNotificationEncoded>()
|
|
209
|
+
const serverProtocol = RpcServer.Protocol.make(Effect.fnUntraced(function*(writeRequest) {
|
|
210
|
+
const parser = serialization.makeUnsafe()
|
|
211
|
+
yield* Queue.take(toServer).pipe(
|
|
212
|
+
Effect.flatMap((frame) =>
|
|
213
|
+
Effect.forEach(
|
|
214
|
+
parser.decode(frame) as ReadonlyArray<RpcMessage.FromClientEncoded>,
|
|
215
|
+
(message) => writeRequest(0, message),
|
|
216
|
+
{ discard: true }
|
|
217
|
+
)
|
|
218
|
+
),
|
|
219
|
+
Effect.forever,
|
|
220
|
+
Effect.forkScoped
|
|
221
|
+
)
|
|
222
|
+
return {
|
|
223
|
+
disconnects: yield* Queue.make<number>(),
|
|
224
|
+
send(_clientId, response) {
|
|
225
|
+
const encoded = parser.encode(response)
|
|
226
|
+
return typeof encoded === "string" ? Effect.asVoid(Queue.offer(toClient, encoded)) : Effect.void
|
|
227
|
+
},
|
|
228
|
+
end: () => Effect.void,
|
|
229
|
+
clientIds: Effect.succeed(new Set([0])),
|
|
230
|
+
initialMessage: Effect.succeedNone,
|
|
231
|
+
supportsAck: false,
|
|
232
|
+
supportsTransferables: false,
|
|
233
|
+
supportsSpanPropagation: false,
|
|
234
|
+
supportsNotifications: true,
|
|
235
|
+
codecFor: serialization.codecFor
|
|
236
|
+
}
|
|
237
|
+
}))
|
|
238
|
+
const context = yield* Layer.build(
|
|
239
|
+
McpServer.layer({
|
|
240
|
+
name: options.name ?? "McpTest",
|
|
241
|
+
version: options.version ?? "1.0.0",
|
|
242
|
+
instructions: options.instructions,
|
|
243
|
+
extensions: options.extensions,
|
|
244
|
+
protocols: options.protocols,
|
|
245
|
+
registrations
|
|
246
|
+
}).pipe(Layer.provide(Layer.effect(RpcServer.Protocol, serverProtocol)))
|
|
247
|
+
)
|
|
248
|
+
const server = Context.get(context as Context.Context<McpServer.McpServer>, McpServer.McpServer)
|
|
249
|
+
|
|
250
|
+
const write = (message: object) => Effect.asVoid(Queue.offer(toServer, JSON.stringify(message)))
|
|
251
|
+
|
|
252
|
+
// Stateless revisions carry the client profile on every request instead of
|
|
253
|
+
// negotiating it with `initialize`.
|
|
254
|
+
const requestMetadata = selected.runtime._tag === "Stateless"
|
|
255
|
+
? {
|
|
256
|
+
"io.modelcontextprotocol/protocolVersion": selected.protocolVersion,
|
|
257
|
+
"io.modelcontextprotocol/clientCapabilities": encodeClientCapabilities(clientCapabilities),
|
|
258
|
+
"io.modelcontextprotocol/clientInfo": encodeImplementation(clientInfo)
|
|
259
|
+
}
|
|
260
|
+
: undefined
|
|
261
|
+
const params = (payload: unknown) => {
|
|
262
|
+
if (requestMetadata === undefined) {
|
|
263
|
+
return payload === undefined || payload === null ? {} : { params: payload }
|
|
264
|
+
}
|
|
265
|
+
const fields = Predicate.isReadonlyObject(payload) ? payload : {}
|
|
266
|
+
return {
|
|
267
|
+
params: {
|
|
268
|
+
...fields,
|
|
269
|
+
_meta: { ...requestMetadata, ...(Predicate.isReadonlyObject(fields._meta) ? fields._meta : {}) }
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const protocol = yield* RpcClient.Protocol.make(Effect.fnUntraced(function*(writeResponse) {
|
|
275
|
+
const parser = serialization.makeUnsafe()
|
|
276
|
+
let clientId = 0
|
|
277
|
+
const route = (message: RpcMessage.FromServerEncoded | RpcMessage.FromClientEncoded): Effect.Effect<void> => {
|
|
278
|
+
if (message._tag !== "Request") {
|
|
279
|
+
return writeResponse(clientId, message as RpcMessage.FromServerEncoded)
|
|
280
|
+
}
|
|
281
|
+
if (message.isNotification === true) {
|
|
282
|
+
return Effect.asVoid(Queue.offer(notifications, {
|
|
283
|
+
_tag: "Notification",
|
|
284
|
+
method: message.tag,
|
|
285
|
+
payload: message.payload ?? undefined
|
|
286
|
+
} as McpSchema.ServerNotificationEncoded))
|
|
287
|
+
}
|
|
288
|
+
// Server-to-client requests are not supported, so reject them instead
|
|
289
|
+
// of leaving the handler waiting for a reply.
|
|
290
|
+
return write({
|
|
291
|
+
jsonrpc: "2.0",
|
|
292
|
+
id: message.id,
|
|
293
|
+
error: { code: McpSchema.METHOD_NOT_FOUND_ERROR_CODE, message: `Method not found: ${message.tag}` }
|
|
294
|
+
})
|
|
295
|
+
}
|
|
296
|
+
yield* Queue.take(toClient).pipe(
|
|
297
|
+
Effect.flatMap((frame) =>
|
|
298
|
+
Effect.forEach(
|
|
299
|
+
parser.decode(frame) as ReadonlyArray<RpcMessage.FromServerEncoded | RpcMessage.FromClientEncoded>,
|
|
300
|
+
route,
|
|
301
|
+
{ discard: true }
|
|
302
|
+
)
|
|
303
|
+
),
|
|
304
|
+
Effect.forever,
|
|
305
|
+
Effect.forkScoped
|
|
306
|
+
)
|
|
307
|
+
return {
|
|
308
|
+
send(id, request) {
|
|
309
|
+
clientId = id
|
|
310
|
+
switch (request._tag) {
|
|
311
|
+
case "Request":
|
|
312
|
+
return write({ jsonrpc: "2.0", id: request.id, method: request.tag, ...params(request.payload) })
|
|
313
|
+
case "Interrupt":
|
|
314
|
+
return write({
|
|
315
|
+
jsonrpc: "2.0",
|
|
316
|
+
method: "notifications/cancelled",
|
|
317
|
+
...params({ requestId: request.requestId })
|
|
318
|
+
})
|
|
319
|
+
default:
|
|
320
|
+
// Effect RPC control messages are not part of the MCP protocol.
|
|
321
|
+
return Effect.void
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
supportsAck: false,
|
|
325
|
+
supportsTransferables: false,
|
|
326
|
+
codecFor: serialization.codecFor
|
|
327
|
+
}
|
|
328
|
+
}))
|
|
329
|
+
let nextRequestId = 1
|
|
330
|
+
const rpc = yield* RpcClient.make(McpSchema.ClientRequestRpcs, {
|
|
331
|
+
spanPrefix: "McpTest",
|
|
332
|
+
generateRequestId: () => RpcMessage.RequestId(nextRequestId++)
|
|
333
|
+
}).pipe(Effect.provideService(RpcClient.Protocol, protocol))
|
|
334
|
+
|
|
335
|
+
let protocolVersion = selected.protocolVersion
|
|
336
|
+
if (selected.runtime._tag === "Stateful") {
|
|
337
|
+
const result = yield* rpc.initialize({
|
|
338
|
+
protocolVersion: selected.protocolVersion,
|
|
339
|
+
capabilities: clientCapabilities,
|
|
340
|
+
clientInfo
|
|
341
|
+
}).pipe(Effect.orDie)
|
|
342
|
+
protocolVersion = result.protocolVersion as McpProtocol.ProtocolVersion
|
|
343
|
+
yield* write({ jsonrpc: "2.0", method: "notifications/initialized" })
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return identity<Client>({
|
|
347
|
+
protocolVersion,
|
|
348
|
+
server,
|
|
349
|
+
notifications,
|
|
350
|
+
ping: Effect.asVoid(orDieClientError(rpc.ping(undefined))),
|
|
351
|
+
listTools: (request) => orDieClientError(rpc["tools/list"](request)),
|
|
352
|
+
callTool: (request) => orDieClientError(rpc["tools/call"](request)),
|
|
353
|
+
listResources: (request) => orDieClientError(rpc["resources/list"](request)),
|
|
354
|
+
listResourceTemplates: (request) => orDieClientError(rpc["resources/templates/list"](request)),
|
|
355
|
+
readResource: (request) => orDieClientError(rpc["resources/read"](request)),
|
|
356
|
+
subscribe: (request) => Effect.asVoid(orDieClientError(rpc["resources/subscribe"](request))),
|
|
357
|
+
unsubscribe: (request) => Effect.asVoid(orDieClientError(rpc["resources/unsubscribe"](request))),
|
|
358
|
+
listPrompts: (request) => orDieClientError(rpc["prompts/list"](request)),
|
|
359
|
+
getPrompt: (request) => orDieClientError(rpc["prompts/get"](request)),
|
|
360
|
+
complete: (request) => orDieClientError(rpc["completion/complete"](request)),
|
|
361
|
+
setLevel: (request) => Effect.asVoid(orDieClientError(rpc["logging/setLevel"](request)))
|
|
362
|
+
})
|
|
363
|
+
}) as any
|
|
364
|
+
|
|
365
|
+
const serialization = RpcSerialization.jsonRpc()
|
|
366
|
+
|
|
367
|
+
const defaultClientInfo: McpSchema.Implementation = { name: "McpTest", version: "1.0.0" }
|
|
368
|
+
|
|
369
|
+
const encodeClientCapabilities = Schema.encodeSync(Schema.toCodecJson(McpSchema.ClientCapabilities))
|
|
370
|
+
const encodeImplementation = Schema.encodeSync(Schema.toCodecJson(McpSchema.Implementation))
|
|
371
|
+
|
|
372
|
+
// The in-memory transport never fails to send, so a client error is a defect.
|
|
373
|
+
const orDieClientError = <A, E>(
|
|
374
|
+
effect: Effect.Effect<A, E | RpcClientError.RpcClientError>
|
|
375
|
+
): Effect.Effect<A, Exclude<E, RpcClientError.RpcClientError>> =>
|
|
376
|
+
Effect.catchIf(
|
|
377
|
+
effect,
|
|
378
|
+
(error): error is RpcClientError.RpcClientError => Predicate.isTagged(error, "RpcClientError"),
|
|
379
|
+
Effect.die
|
|
380
|
+
) as any
|
package/src/ai/Response.ts
CHANGED
|
@@ -2376,15 +2376,6 @@ export const UrlSourcePart: Schema.Struct<{
|
|
|
2376
2376
|
// HTTP Details
|
|
2377
2377
|
// =============================================================================
|
|
2378
2378
|
|
|
2379
|
-
/**
|
|
2380
|
-
* Alias of {@link AiError.HttpRequestDetails}.
|
|
2381
|
-
*
|
|
2382
|
-
* @stability unstable
|
|
2383
|
-
* @category schemas
|
|
2384
|
-
* @since 4.0.0
|
|
2385
|
-
*/
|
|
2386
|
-
export const HttpRequestDetails = AiError.HttpRequestDetails
|
|
2387
|
-
|
|
2388
2379
|
/**
|
|
2389
2380
|
* Alias of {@link AiError.HttpResponseDetails}.
|
|
2390
2381
|
*
|
|
@@ -2412,8 +2403,7 @@ export const HttpResponseDetails = AiError.HttpResponseDetails
|
|
|
2412
2403
|
* {
|
|
2413
2404
|
* id: "resp_123",
|
|
2414
2405
|
* modelId: "gpt-4",
|
|
2415
|
-
* timestamp: DateTime.makeUnsafe("2024-01-01T00:00:00Z")
|
|
2416
|
-
* request: undefined
|
|
2406
|
+
* timestamp: DateTime.makeUnsafe("2024-01-01T00:00:00Z")
|
|
2417
2407
|
* }
|
|
2418
2408
|
* )
|
|
2419
2409
|
* const result = [metadataPart.id, metadataPart.modelId] // => ["resp_123", "gpt-4"]
|
|
@@ -2436,10 +2426,6 @@ export interface ResponseMetadataPart extends BasePart<"response-metadata", Resp
|
|
|
2436
2426
|
* Optional timestamp when the response was generated.
|
|
2437
2427
|
*/
|
|
2438
2428
|
readonly timestamp?: DateTime.Utc | undefined
|
|
2439
|
-
/**
|
|
2440
|
-
* Optional HTTP request details for the request made to the AI provider.
|
|
2441
|
-
*/
|
|
2442
|
-
readonly request?: typeof HttpRequestDetails.Type | undefined
|
|
2443
2429
|
}
|
|
2444
2430
|
|
|
2445
2431
|
/**
|
|
@@ -2464,10 +2450,6 @@ export interface ResponseMetadataPartEncoded
|
|
|
2464
2450
|
* Optional timestamp when the response was generated.
|
|
2465
2451
|
*/
|
|
2466
2452
|
readonly timestamp?: string | undefined
|
|
2467
|
-
/**
|
|
2468
|
-
* Optional HTTP request details for the request made to the AI provider.
|
|
2469
|
-
*/
|
|
2470
|
-
readonly request?: typeof HttpRequestDetails.Encoded | undefined
|
|
2471
2453
|
}
|
|
2472
2454
|
|
|
2473
2455
|
/**
|
|
@@ -2492,7 +2474,6 @@ export const ResponseMetadataPart: Schema.Struct<{
|
|
|
2492
2474
|
readonly id: Schema.optional<Schema.String>
|
|
2493
2475
|
readonly modelId: Schema.optional<Schema.String>
|
|
2494
2476
|
readonly timestamp: Schema.optional<Schema.DateTimeUtcFromString>
|
|
2495
|
-
readonly request: Schema.optional<typeof HttpRequestDetails>
|
|
2496
2477
|
readonly "~effect/ai/Response/Part": Schema.withDecodingDefaultKey<Schema.tag<"~effect/ai/Response/Part">>
|
|
2497
2478
|
readonly metadata: Schema.withDecodingDefault<
|
|
2498
2479
|
Schema.$Record<Schema.String, Schema.Codec<Schema.Json>>
|
|
@@ -2502,8 +2483,7 @@ export const ResponseMetadataPart: Schema.Struct<{
|
|
|
2502
2483
|
type: Schema.tag("response-metadata"),
|
|
2503
2484
|
id: Schema.optional(Schema.String),
|
|
2504
2485
|
modelId: Schema.optional(Schema.String),
|
|
2505
|
-
timestamp: Schema.optional(Schema.DateTimeUtcFromString)
|
|
2506
|
-
request: Schema.optional(HttpRequestDetails)
|
|
2486
|
+
timestamp: Schema.optional(Schema.DateTimeUtcFromString)
|
|
2507
2487
|
}).annotate({ identifier: "ResponseMetadataPart" }) satisfies Schema.Codec<
|
|
2508
2488
|
ResponseMetadataPart,
|
|
2509
2489
|
ResponseMetadataPartEncoded
|
package/src/ai/Tool.ts
CHANGED
|
@@ -918,17 +918,36 @@ export type ResultEncoded<T> = SuccessEncoded<T> | FailureResultEncoded<T>
|
|
|
918
918
|
* @category utility types
|
|
919
919
|
* @since 4.0.0
|
|
920
920
|
*/
|
|
921
|
-
export type HandlerServices<T> = T
|
|
921
|
+
export type HandlerServices<T> = SchemaServices<T> | Requirements<T>
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* A utility type to extract the request-level dependencies a `Tool` declares
|
|
925
|
+
* with `dependencies` or `Tool.addDependency`.
|
|
926
|
+
*
|
|
927
|
+
* @stability unstable
|
|
928
|
+
* @category utility types
|
|
929
|
+
* @since 4.0.0
|
|
930
|
+
*/
|
|
931
|
+
export type Requirements<T> = T extends Tool<
|
|
932
|
+
infer _Name,
|
|
933
|
+
infer _Config,
|
|
934
|
+
infer _Requirements
|
|
935
|
+
> ? _Requirements
|
|
936
|
+
: never
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* A utility type to extract the services needed to decode the parameters of a
|
|
940
|
+
* `Tool` call and encode its result, whether success or failure.
|
|
941
|
+
*
|
|
942
|
+
* @stability unstable
|
|
943
|
+
* @category utility types
|
|
944
|
+
* @since 4.0.0
|
|
945
|
+
*/
|
|
946
|
+
export type SchemaServices<T> = T extends Tool<
|
|
922
947
|
infer _Name,
|
|
923
948
|
infer _Config,
|
|
924
949
|
infer _Requirements
|
|
925
|
-
> ?
|
|
926
|
-
| _Config["parameters"]["DecodingServices"]
|
|
927
|
-
// A tool call `result`, whether success or failure, is encoded and returned
|
|
928
|
-
// as the `encodedResult` along with the `result`
|
|
929
|
-
| ResultEncodingServices<T>
|
|
930
|
-
// Per-request requirements
|
|
931
|
-
| _Requirements
|
|
950
|
+
> ? _Config["parameters"]["DecodingServices"] | ResultEncodingServices<T>
|
|
932
951
|
: never
|
|
933
952
|
|
|
934
953
|
/**
|
package/src/ai/index.ts
CHANGED
|
@@ -83,6 +83,12 @@ export * as McpSchema from "./McpSchema.ts"
|
|
|
83
83
|
*/
|
|
84
84
|
export * as McpServer from "./McpServer.ts"
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* @stability unstable
|
|
88
|
+
* @since 4.0.0
|
|
89
|
+
*/
|
|
90
|
+
export * as McpTest from "./McpTest.ts"
|
|
91
|
+
|
|
86
92
|
/**
|
|
87
93
|
* @stability unstable
|
|
88
94
|
* @since 4.0.0
|