effect 4.1.1 → 4.1.3
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/ai-docs/package.json +2 -2
- package/ai-docs/tsconfig.json +2 -1
- package/dist/ByteSize.d.ts.map +1 -1
- package/dist/ByteSize.js +27 -14
- package/dist/ByteSize.js.map +1 -1
- package/dist/DateTime.d.ts +33 -2
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +16 -0
- package/dist/DateTime.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +27 -24
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +27 -6
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Match.d.ts +6 -6
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js.map +1 -1
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +0 -7
- package/dist/MutableRef.js.map +1 -1
- package/dist/Queue.d.ts +2 -1
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +16 -9
- package/dist/Queue.js.map +1 -1
- package/dist/Rational.d.ts +1214 -0
- package/dist/Rational.d.ts.map +1 -0
- package/dist/Rational.js +880 -0
- package/dist/Rational.js.map +1 -0
- package/dist/RcMap.d.ts +3 -0
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +13 -14
- package/dist/RcMap.js.map +1 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +0 -8
- package/dist/Ref.js.map +1 -1
- package/dist/Runtime.d.ts +75 -3
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +81 -4
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +8 -3
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +131 -29
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +128 -22
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +24 -12
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.js +2 -2
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +9 -0
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +9 -0
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/ScopedCache.d.ts +7 -0
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +18 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +6 -5
- package/dist/Stream.js.map +1 -1
- package/dist/ai/AgUi.d.ts +109 -0
- package/dist/ai/AgUi.d.ts.map +1 -0
- package/dist/ai/AgUi.js +543 -0
- package/dist/ai/AgUi.js.map +1 -0
- package/dist/ai/AgUiSchema.d.ts +6965 -0
- package/dist/ai/AgUiSchema.d.ts.map +1 -0
- package/dist/ai/AgUiSchema.js +974 -0
- package/dist/ai/AgUiSchema.js.map +1 -0
- package/dist/ai/AgUiServer.d.ts +6400 -0
- package/dist/ai/AgUiServer.d.ts.map +1 -0
- package/dist/ai/AgUiServer.js +309 -0
- package/dist/ai/AgUiServer.js.map +1 -0
- package/dist/ai/Chat.d.ts +30 -4
- package/dist/ai/Chat.d.ts.map +1 -1
- package/dist/ai/Chat.js +34 -4
- package/dist/ai/Chat.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts +1 -1
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +18 -8
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpClient.d.ts +5 -0
- package/dist/ai/McpClient.d.ts.map +1 -1
- package/dist/ai/McpClient.js +11 -1
- package/dist/ai/McpClient.js.map +1 -1
- package/dist/ai/McpServer.d.ts +18 -1
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +251 -43
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +6 -2
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +5 -2
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +5 -1
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +265 -69
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +19 -2
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/Toolkit.d.ts +32 -2
- package/dist/ai/Toolkit.d.ts.map +1 -1
- package/dist/ai/Toolkit.js +61 -8
- package/dist/ai/Toolkit.js.map +1 -1
- package/dist/ai/index.d.ts +15 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +15 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/internal/mcpCore.d.ts +0 -2
- package/dist/ai/internal/mcpCore.d.ts.map +1 -1
- package/dist/ai/internal/mcpCore.js +2 -8
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +6 -11
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +6 -11
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +6 -8
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +6 -8
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +64 -54
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +11 -1
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpProtocolRegistry.js +4 -0
- package/dist/ai/internal/mcpProtocolRegistry.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +6 -2
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2024_11_05.js +0 -2
- package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_03_26.d.ts.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_03_26.js +0 -2
- package/dist/ai/internal/mcpSchema/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_06_18.d.ts.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_06_18.js +0 -2
- package/dist/ai/internal/mcpSchema/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_11_25.d.ts.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_11_25.js +0 -2
- package/dist/ai/internal/mcpSchema/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2026_07_28.d.ts.map +1 -1
- package/dist/ai/internal/mcpSchema/v2026_07_28.js +0 -2
- package/dist/ai/internal/mcpSchema/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpSkills.js +3 -93
- package/dist/ai/internal/mcpSkills.js.map +1 -1
- package/dist/ai/internal/mcpStatefulRuntime.js +0 -2
- package/dist/ai/internal/mcpStatefulRuntime.js.map +1 -1
- package/dist/ai/internal/structured-output.js +12 -3
- package/dist/ai/internal/structured-output.js.map +1 -1
- package/dist/cli/Argument.d.ts +81 -0
- package/dist/cli/Argument.d.ts.map +1 -1
- package/dist/cli/Argument.js +26 -0
- package/dist/cli/Argument.js.map +1 -1
- package/dist/cli/CliError.d.ts +7 -4
- package/dist/cli/CliError.d.ts.map +1 -1
- package/dist/cli/CliError.js +7 -4
- package/dist/cli/CliError.js.map +1 -1
- package/dist/cli/Command.d.ts +241 -22
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +85 -9
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/CommandSpec.d.ts +287 -0
- package/dist/cli/CommandSpec.d.ts.map +1 -0
- package/dist/cli/CommandSpec.js +277 -0
- package/dist/cli/CommandSpec.js.map +1 -0
- package/dist/cli/Completions.d.ts +5 -0
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/Flag.d.ts +102 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +47 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/Param.d.ts +154 -1
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +87 -29
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +5 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/internal/command.d.ts +2 -2
- package/dist/cli/internal/command.d.ts.map +1 -1
- package/dist/cli/internal/command.js +1 -1
- package/dist/cli/internal/command.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +6 -7
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cli/internal/completions/descriptor.js +21 -7
- package/dist/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/cli/internal/completions/fish.js +3 -3
- package/dist/cli/internal/completions/fish.js.map +1 -1
- package/dist/cli/internal/completions/powershell.js +2 -2
- package/dist/cli/internal/completions/powershell.js.map +1 -1
- package/dist/cli/internal/completions/zsh.js +2 -2
- package/dist/cli/internal/completions/zsh.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +31 -20
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Entity.d.ts +43 -0
- package/dist/cluster/Entity.d.ts.map +1 -1
- package/dist/cluster/Entity.js +20 -0
- package/dist/cluster/Entity.js.map +1 -1
- package/dist/cluster/MessageRetention.d.ts +71 -0
- package/dist/cluster/MessageRetention.d.ts.map +1 -0
- package/dist/cluster/MessageRetention.js +100 -0
- package/dist/cluster/MessageRetention.js.map +1 -0
- package/dist/cluster/MessageStorage.d.ts +87 -6
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +35 -5
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +13 -2
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts +13 -0
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +24 -2
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +187 -29
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/index.d.ts +5 -0
- package/dist/cluster/index.d.ts.map +1 -1
- package/dist/cluster/index.js +5 -0
- package/dist/cluster/index.js.map +1 -1
- package/dist/cluster/internal/clusterAbandon.d.ts.map +1 -1
- package/dist/cluster/internal/clusterAbandon.js +6 -4
- package/dist/cluster/internal/clusterAbandon.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +48 -4
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/cluster/internal/transactionNotifications.d.ts +5 -0
- package/dist/cluster/internal/transactionNotifications.d.ts.map +1 -0
- package/dist/cluster/internal/transactionNotifications.js +5 -0
- package/dist/cluster/internal/transactionNotifications.js.map +1 -0
- package/dist/encoding/Base64.d.ts +0 -6
- package/dist/encoding/Base64.d.ts.map +1 -1
- package/dist/encoding/Base64.js +25 -5
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts +0 -6
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +91 -8
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Csv.d.ts.map +1 -1
- package/dist/encoding/Csv.js +11 -5
- package/dist/encoding/Csv.js.map +1 -1
- package/dist/encoding/Hex.d.ts.map +1 -1
- package/dist/encoding/Hex.js +51 -34
- package/dist/encoding/Hex.js.map +1 -1
- package/dist/encoding/Json5.d.ts +44 -0
- package/dist/encoding/Json5.d.ts.map +1 -0
- package/dist/encoding/Json5.js +56 -0
- package/dist/encoding/Json5.js.map +1 -0
- package/dist/encoding/Jsonc.d.ts +47 -0
- package/dist/encoding/Jsonc.d.ts.map +1 -0
- package/dist/encoding/Jsonc.js +120 -0
- package/dist/encoding/Jsonc.js.map +1 -0
- package/dist/encoding/SchemaBinary.d.ts +108 -2
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +297 -11
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Xml.d.ts +25 -0
- package/dist/encoding/Xml.d.ts.map +1 -1
- package/dist/encoding/Xml.js +44 -19
- package/dist/encoding/Xml.js.map +1 -1
- package/dist/encoding/index.d.ts +10 -0
- package/dist/encoding/index.d.ts.map +1 -1
- package/dist/encoding/index.js +10 -0
- package/dist/encoding/index.js.map +1 -1
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +28 -12
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/graphql/GraphQL.d.ts.map +1 -1
- package/dist/graphql/GraphQL.js +4 -1
- package/dist/graphql/GraphQL.js.map +1 -1
- package/dist/http/Headers.d.ts +5 -1
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +7 -2
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts +72 -21
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +105 -60
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts +22 -8
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +68 -14
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpEffect.d.ts +63 -4
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +89 -9
- package/dist/http/HttpEffect.js.map +1 -1
- package/dist/http/HttpMiddleware.js +1 -1
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpServer.d.ts +80 -0
- package/dist/http/HttpServer.d.ts.map +1 -1
- package/dist/http/HttpServer.js +16 -0
- package/dist/http/HttpServer.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +1 -14
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpStaticServer.js +10 -16
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +9 -1
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +19 -0
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +8 -1
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/base64.d.ts +2 -0
- package/dist/internal/base64.d.ts.map +1 -0
- package/dist/internal/base64.js +30 -0
- package/dist/internal/base64.js.map +1 -0
- package/dist/internal/core.js +3 -4
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +35 -13
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +41 -17
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js +7 -0
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/jsonParser.d.ts +5 -0
- package/dist/internal/jsonParser.d.ts.map +1 -0
- package/dist/internal/jsonParser.js +280 -0
- package/dist/internal/jsonParser.js.map +1 -0
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/persistence.js +8 -1
- package/dist/internal/persistence.js.map +1 -1
- package/dist/internal/schema/codegen.js +7 -7
- package/dist/internal/schema/codegen.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +20 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/interpreter.js +10 -10
- package/dist/internal/schema/interpreter.js.map +1 -1
- package/dist/internal/schema/parser.js +9 -4
- package/dist/internal/schema/parser.js.map +1 -1
- package/dist/internal/schema/toEquivalence.js +6 -5
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toFormatter.js +3 -2
- package/dist/internal/schema/toFormatter.js.map +1 -1
- package/dist/internal/sql.js +16 -0
- package/dist/internal/sql.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/observability/OtlpExporter.d.ts +4 -0
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +40 -12
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpMetrics.js +1 -1
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpTracer.js +2 -2
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts +72 -3
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +142 -29
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/persistence/RateLimiter.d.ts +19 -2
- package/dist/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/persistence/RateLimiter.js +24 -8
- package/dist/persistence/RateLimiter.js.map +1 -1
- package/dist/process/CommandLine.d.ts +9 -9
- package/dist/process/CommandLine.js +6 -6
- package/dist/process/index.d.ts +1 -1
- package/dist/process/index.js +1 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +24 -3
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomRpc.d.ts +24 -6
- package/dist/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/reactivity/AtomRpc.js.map +1 -1
- package/dist/rpc/OpenRpc.d.ts +384 -0
- package/dist/rpc/OpenRpc.d.ts.map +1 -0
- package/dist/rpc/OpenRpc.js +490 -0
- package/dist/rpc/OpenRpc.js.map +1 -0
- package/dist/rpc/Rpc.d.ts +22 -3
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +20 -21
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts +23 -2
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +77 -26
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/rpc/index.d.ts +5 -0
- package/dist/rpc/index.d.ts.map +1 -1
- package/dist/rpc/index.js +5 -0
- package/dist/rpc/index.js.map +1 -1
- package/dist/schema/SchemaCompiler/runtime.js +3 -2
- package/dist/schema/SchemaCompiler/runtime.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +67 -6
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +98 -27
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +6 -1
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +17 -22
- package/dist/sql/Statement.js.map +1 -1
- package/dist/testing/TestClock.d.ts +2 -12
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +177 -169
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/workflow/DurableClock.d.ts +27 -0
- package/dist/workflow/DurableClock.d.ts.map +1 -1
- package/dist/workflow/DurableClock.js +18 -2
- package/dist/workflow/DurableClock.js.map +1 -1
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +5 -4
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +14 -3
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +5 -5
- package/src/ByteSize.ts +29 -14
- package/src/DateTime.ts +35 -2
- package/src/Iterable.ts +20 -14
- package/src/JsonSchema.ts +45 -7
- package/src/Match.ts +10 -8
- package/src/MutableRef.ts +1 -8
- package/src/Queue.ts +16 -11
- package/src/Rational.ts +1549 -0
- package/src/RcMap.ts +16 -14
- package/src/Ref.ts +0 -8
- package/src/Runtime.ts +84 -4
- package/src/Schedule.ts +8 -6
- package/src/Schema.ts +188 -29
- package/src/SchemaAST.ts +29 -13
- package/src/SchemaParser.ts +2 -2
- package/src/SchemaRepresentation.ts +13 -0
- package/src/ScopedCache.ts +18 -1
- package/src/Stream.ts +6 -5
- package/src/ai/AgUi.ts +485 -0
- package/src/ai/AgUiSchema.ts +1666 -0
- package/src/ai/AgUiServer.ts +451 -0
- package/src/ai/Chat.ts +78 -16
- package/src/ai/LanguageModel.ts +27 -9
- package/src/ai/McpClient.ts +11 -1
- package/src/ai/McpServer.ts +287 -67
- package/src/ai/Prompt.ts +6 -2
- package/src/ai/Response.ts +19 -3
- package/src/ai/Tool.ts +426 -110
- package/src/ai/Toolkit.ts +71 -10
- package/src/ai/index.ts +18 -0
- package/src/ai/internal/mcpCore.ts +11 -15
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +9 -14
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +9 -14
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +9 -11
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +9 -11
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +80 -60
- package/src/ai/internal/mcpProtocol.ts +22 -3
- package/src/ai/internal/mcpProtocolRegistry.ts +5 -0
- package/src/ai/internal/mcpRuntime.ts +10 -4
- package/src/ai/internal/mcpSchema/v2024_11_05.ts +0 -2
- package/src/ai/internal/mcpSchema/v2025_03_26.ts +0 -2
- package/src/ai/internal/mcpSchema/v2025_06_18.ts +0 -2
- package/src/ai/internal/mcpSchema/v2025_11_25.ts +0 -2
- package/src/ai/internal/mcpSchema/v2026_07_28.ts +0 -2
- package/src/ai/internal/mcpSkills.ts +3 -86
- package/src/ai/internal/mcpStatefulRuntime.ts +0 -2
- package/src/ai/internal/structured-output.ts +11 -5
- package/src/cli/Argument.ts +86 -0
- package/src/cli/CliError.ts +7 -4
- package/src/cli/Command.ts +261 -35
- package/src/cli/CommandSpec.ts +508 -0
- package/src/cli/Completions.ts +5 -0
- package/src/cli/Flag.ts +106 -0
- package/src/cli/Param.ts +225 -23
- package/src/cli/index.ts +6 -0
- package/src/cli/internal/command.ts +3 -4
- package/src/cli/internal/completions/bash.ts +9 -7
- package/src/cli/internal/completions/descriptor.ts +37 -5
- package/src/cli/internal/completions/fish.ts +9 -3
- package/src/cli/internal/completions/powershell.ts +2 -1
- package/src/cli/internal/completions/zsh.ts +2 -2
- package/src/cluster/ClusterWorkflowEngine.ts +41 -41
- package/src/cluster/Entity.ts +76 -0
- package/src/cluster/MessageRetention.ts +111 -0
- package/src/cluster/MessageStorage.ts +76 -8
- package/src/cluster/Runners.ts +16 -2
- package/src/cluster/Sharding.ts +13 -0
- package/src/cluster/ShardingConfig.ts +12 -1
- package/src/cluster/SqlMessageStorage.ts +271 -41
- package/src/cluster/index.ts +6 -0
- package/src/cluster/internal/clusterAbandon.ts +7 -7
- package/src/cluster/internal/entityManager.ts +65 -5
- package/src/cluster/internal/transactionNotifications.ts +7 -0
- package/src/encoding/Base64.ts +26 -5
- package/src/encoding/Base64Url.ts +93 -10
- package/src/encoding/Csv.ts +11 -5
- package/src/encoding/Hex.ts +56 -42
- package/src/encoding/Json5.ts +59 -0
- package/src/encoding/Jsonc.ts +126 -0
- package/src/encoding/SchemaBinary.ts +304 -12
- package/src/encoding/Xml.ts +65 -16
- package/src/encoding/index.ts +12 -0
- package/src/eventlog/EventLogServer.ts +36 -12
- package/src/graphql/GraphQL.ts +7 -4
- package/src/http/Headers.ts +7 -2
- package/src/http/HttpClient.ts +147 -85
- package/src/http/HttpClientError.ts +82 -15
- package/src/http/HttpEffect.ts +101 -10
- package/src/http/HttpMiddleware.ts +2 -2
- package/src/http/HttpServer.ts +80 -0
- package/src/http/HttpServerRequest.ts +1 -19
- package/src/http/HttpStaticServer.ts +10 -16
- package/src/http-api/HttpApiBuilder.ts +11 -1
- package/src/http-api/HttpApiSchema.ts +22 -1
- package/src/index.ts +6 -0
- package/src/internal/base64.ts +42 -0
- package/src/internal/core.ts +3 -4
- package/src/internal/dateTime.ts +53 -16
- package/src/internal/effect.ts +45 -18
- package/src/internal/equal.ts +8 -0
- package/src/internal/jsonParser.ts +307 -0
- package/src/internal/matcher.ts +7 -3
- package/src/internal/persistence.ts +9 -1
- package/src/internal/schema/codegen.ts +8 -7
- package/src/internal/schema/fromJsonSchemaDocument.ts +21 -1
- package/src/internal/schema/interpreter.ts +10 -10
- package/src/internal/schema/parser.ts +8 -4
- package/src/internal/schema/toEquivalence.ts +7 -5
- package/src/internal/schema/toFormatter.ts +3 -2
- package/src/internal/sql.ts +25 -0
- package/src/internal/version.ts +1 -1
- package/src/observability/OtlpExporter.ts +42 -18
- package/src/observability/OtlpMetrics.ts +1 -1
- package/src/observability/OtlpTracer.ts +2 -2
- package/src/persistence/PersistedQueue.ts +199 -41
- package/src/persistence/RateLimiter.ts +30 -9
- package/src/process/CommandLine.ts +10 -10
- package/src/process/index.ts +1 -1
- package/src/reactivity/Atom.ts +25 -3
- package/src/reactivity/AtomRpc.ts +61 -45
- package/src/rpc/OpenRpc.ts +747 -0
- package/src/rpc/Rpc.ts +38 -6
- package/src/rpc/RpcClient.ts +45 -82
- package/src/rpc/RpcServer.ts +89 -29
- package/src/rpc/index.ts +6 -0
- package/src/schema/SchemaCompiler/runtime.ts +8 -3
- package/src/sql/SqlClient.ts +156 -36
- package/src/sql/Statement.ts +27 -36
- package/src/testing/TestClock.ts +204 -189
- package/src/workflow/DurableClock.ts +20 -3
- package/src/workflow/Workflow.ts +5 -3
- package/src/workflow/WorkflowEngine.ts +20 -5
package/src/ai/McpServer.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import * as Arr from "../Array.ts"
|
|
15
15
|
import * as Cause from "../Cause.ts"
|
|
16
|
+
import * as Clock from "../Clock.ts"
|
|
16
17
|
import * as Context from "../Context.ts"
|
|
17
18
|
import * as Digest from "../crypto/Digest.ts"
|
|
18
19
|
import * as Data from "../Data.ts"
|
|
@@ -28,7 +29,9 @@ import { appendPreResponseHandlerUnsafe } from "../http/HttpEffect.ts"
|
|
|
28
29
|
import * as HttpRouter from "../http/HttpRouter.ts"
|
|
29
30
|
import * as HttpServerRequest from "../http/HttpServerRequest.ts"
|
|
30
31
|
import * as HttpServerResponse from "../http/HttpServerResponse.ts"
|
|
32
|
+
import * as HttpTraceContext from "../http/HttpTraceContext.ts"
|
|
31
33
|
import type * as JsonSchema from "../JsonSchema.ts"
|
|
34
|
+
import * as Latch from "../Latch.ts"
|
|
32
35
|
import * as Layer from "../Layer.ts"
|
|
33
36
|
import * as Option from "../Option.ts"
|
|
34
37
|
import * as Predicate from "../Predicate.ts"
|
|
@@ -104,6 +107,7 @@ interface QueuedServerNotification {
|
|
|
104
107
|
readonly delivered: Deferred.Deferred<void>
|
|
105
108
|
readonly requestContext?: McpRequestContext["Service"] | undefined
|
|
106
109
|
readonly requestHeaders?: Headers.Headers | undefined
|
|
110
|
+
readonly requestLiveness?: { active: boolean } | undefined
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
const internalState = new WeakMap<object, {
|
|
@@ -121,6 +125,10 @@ const RequestNotificationQueue = Context.Reference<Queue.Queue<QueuedServerNotif
|
|
|
121
125
|
"effect/ai/McpServer/RequestNotificationQueue",
|
|
122
126
|
{ defaultValue: () => undefined }
|
|
123
127
|
)
|
|
128
|
+
const RequestLiveness = Context.Reference<{ active: boolean } | undefined>(
|
|
129
|
+
"effect/ai/McpServer/RequestLiveness",
|
|
130
|
+
{ defaultValue: () => undefined }
|
|
131
|
+
)
|
|
124
132
|
// Progress and logs belong to the request that emitted them.
|
|
125
133
|
const isRequestNotification = (notification: McpCore.ServerNotification) =>
|
|
126
134
|
notification._tag === "Progress" || notification._tag === "LoggingMessage"
|
|
@@ -737,23 +745,48 @@ class MiddlewareImpl {
|
|
|
737
745
|
}
|
|
738
746
|
}
|
|
739
747
|
|
|
740
|
-
// The innermost middleware comes first.
|
|
748
|
+
// The innermost middleware comes first. Each stack keeps its own order, and
|
|
749
|
+
// where that leaves the order open, stacks provided further outside, which come
|
|
750
|
+
// first in the context, run further outside. Stacks that order the same
|
|
751
|
+
// middleware both ways have no common order, so insertion order decides.
|
|
741
752
|
const getMiddleware = (context: Context.Context<never>): ReadonlyArray<AnyMiddlewareFn> => {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
753
|
+
// The middleware directly inside each middleware, and how many of those
|
|
754
|
+
// directly outside it are still unplaced.
|
|
755
|
+
const inners = new Map<AnyMiddlewareFn, Array<AnyMiddlewareFn>>()
|
|
756
|
+
const unplacedOuters = new Map<AnyMiddlewareFn, number>()
|
|
757
|
+
for (const [key, stack] of context.mapUnsafe) {
|
|
758
|
+
if (!key.startsWith(middlewareKeyPrefix)) continue
|
|
759
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
760
|
+
const fn = stack[i]
|
|
761
|
+
if (!inners.has(fn)) {
|
|
762
|
+
inners.set(fn, [])
|
|
763
|
+
unplacedOuters.set(fn, 0)
|
|
764
|
+
}
|
|
765
|
+
const outer = stack[i + 1]
|
|
766
|
+
if (outer !== undefined && outer !== fn) {
|
|
767
|
+
inners.get(outer)!.push(fn)
|
|
768
|
+
unplacedOuters.set(fn, unplacedOuters.get(fn)! + 1)
|
|
769
|
+
}
|
|
748
770
|
}
|
|
749
771
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
772
|
+
// Repeatedly places the first middleware with nothing left to place outside it.
|
|
773
|
+
const outermostFirst: Array<AnyMiddlewareFn> = []
|
|
774
|
+
while (unplacedOuters.size > 0) {
|
|
775
|
+
let next = unplacedOuters.keys().next().value!
|
|
776
|
+
for (const [fn, count] of unplacedOuters) {
|
|
777
|
+
if (count === 0) {
|
|
778
|
+
next = fn
|
|
779
|
+
break
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
unplacedOuters.delete(next)
|
|
783
|
+
outermostFirst.push(next)
|
|
784
|
+
for (const fn of inners.get(next)!) {
|
|
785
|
+
const count = unplacedOuters.get(fn)
|
|
786
|
+
if (count !== undefined) unplacedOuters.set(fn, count - 1)
|
|
754
787
|
}
|
|
755
788
|
}
|
|
756
|
-
return
|
|
789
|
+
return outermostFirst.reverse()
|
|
757
790
|
}
|
|
758
791
|
|
|
759
792
|
const isMcpError = (error: unknown): error is McpErrorBase =>
|
|
@@ -1092,6 +1125,7 @@ export class McpServer extends Context.Service<McpServer, {
|
|
|
1092
1125
|
const queued: QueuedServerNotification = {
|
|
1093
1126
|
notification,
|
|
1094
1127
|
delivered,
|
|
1128
|
+
requestLiveness: Context.get(fiber.context, RequestLiveness),
|
|
1095
1129
|
requestContext: Context.getOrUndefined(fiber.context, McpRequestContext),
|
|
1096
1130
|
requestHeaders: Context.getOrUndefined(fiber.context, HttpServerRequest.HttpServerRequest)?.headers
|
|
1097
1131
|
}
|
|
@@ -1208,8 +1242,8 @@ export class McpServer extends Context.Service<McpServer, {
|
|
|
1208
1242
|
}),
|
|
1209
1243
|
visible: visible("tools/list", options.tool.name),
|
|
1210
1244
|
isVisible: isEnabled(options.annotations),
|
|
1211
|
-
handle: (call, invocation) =>
|
|
1212
|
-
invoke(options.handle(call.arguments), invocation, {
|
|
1245
|
+
handle: (call, invocation, beforeHandle) =>
|
|
1246
|
+
invoke(Effect.andThen(beforeHandle, () => options.handle(call.arguments)), invocation, {
|
|
1213
1247
|
method: "tools/call",
|
|
1214
1248
|
target: call.name,
|
|
1215
1249
|
payload: call
|
|
@@ -1460,10 +1494,123 @@ const requestKey = (requestId: string | number): string => `${typeof requestId}:
|
|
|
1460
1494
|
interface ActiveRequest {
|
|
1461
1495
|
readonly requestId: RpcMessage.RequestId
|
|
1462
1496
|
readonly prepared: McpRuntime.PreparedRequest
|
|
1497
|
+
readonly liveness: { active: boolean }
|
|
1463
1498
|
readonly cancelled: boolean
|
|
1464
1499
|
readonly httpPost: { expected: number } | undefined
|
|
1465
1500
|
}
|
|
1466
1501
|
|
|
1502
|
+
// JSON-RPC errors caused by the request rather than the server: parse error,
|
|
1503
|
+
// invalid request, method not found, invalid params and resource not found.
|
|
1504
|
+
// Per the MCP semantic conventions they do not mark the server span as failed.
|
|
1505
|
+
const requestErrorCodes: ReadonlySet<number> = new Set([-32700, -32600, -32601, -32602, -32002])
|
|
1506
|
+
|
|
1507
|
+
// Only the W3C keys are read: other `_meta` members can carry protocol claims.
|
|
1508
|
+
const remoteParentSpan = (params: Readonly<Record<string, unknown>> | undefined): Tracer.ExternalSpan | undefined => {
|
|
1509
|
+
const meta = params?._meta
|
|
1510
|
+
if (!Predicate.isReadonlyObject(meta) || typeof meta.traceparent !== "string") {
|
|
1511
|
+
return undefined
|
|
1512
|
+
}
|
|
1513
|
+
return Option.getOrUndefined(HttpTraceContext.w3c(Headers.fromInput({ traceparent: meta.traceparent })))
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
const requestSpanOptions = (
|
|
1517
|
+
method: string,
|
|
1518
|
+
request: RpcMessage.Request<Rpc.Any>,
|
|
1519
|
+
options: {
|
|
1520
|
+
readonly protocolVersion: string
|
|
1521
|
+
readonly networkTransport: string | undefined
|
|
1522
|
+
readonly sessionId: string | undefined
|
|
1523
|
+
readonly recordToolArguments: boolean
|
|
1524
|
+
}
|
|
1525
|
+
): Tracer.SpanOptionsNoTrace & { readonly name: string } => {
|
|
1526
|
+
const params = Predicate.isReadonlyObject(request.payload)
|
|
1527
|
+
? request.payload as Readonly<Record<string, unknown>>
|
|
1528
|
+
: undefined
|
|
1529
|
+
const attributes: Record<string, unknown> = {
|
|
1530
|
+
"mcp.method.name": method,
|
|
1531
|
+
"mcp.protocol.version": options.protocolVersion
|
|
1532
|
+
}
|
|
1533
|
+
if (request.isNotification !== true) attributes["jsonrpc.request.id"] = String(request.id)
|
|
1534
|
+
if (options.sessionId !== undefined) attributes["mcp.session.id"] = options.sessionId
|
|
1535
|
+
if (options.networkTransport !== undefined) attributes["network.transport"] = options.networkTransport
|
|
1536
|
+
let target: string | undefined
|
|
1537
|
+
switch (method) {
|
|
1538
|
+
case "tools/call": {
|
|
1539
|
+
attributes["gen_ai.operation.name"] = "execute_tool"
|
|
1540
|
+
if (typeof params?.name === "string") {
|
|
1541
|
+
target = params.name
|
|
1542
|
+
attributes["gen_ai.tool.name"] = target
|
|
1543
|
+
}
|
|
1544
|
+
if (options.recordToolArguments && params?.arguments !== undefined) {
|
|
1545
|
+
attributes["gen_ai.tool.call.arguments"] = Toolkit.stringifyToolArguments(params.arguments)
|
|
1546
|
+
}
|
|
1547
|
+
break
|
|
1548
|
+
}
|
|
1549
|
+
case "prompts/get": {
|
|
1550
|
+
if (typeof params?.name === "string") {
|
|
1551
|
+
target = params.name
|
|
1552
|
+
attributes["gen_ai.prompt.name"] = target
|
|
1553
|
+
}
|
|
1554
|
+
break
|
|
1555
|
+
}
|
|
1556
|
+
case "resources/read":
|
|
1557
|
+
case "resources/subscribe":
|
|
1558
|
+
case "resources/unsubscribe": {
|
|
1559
|
+
// Resource URIs can be unbounded and sensitive, so they stay out of the span name.
|
|
1560
|
+
if (typeof params?.uri === "string") attributes["mcp.resource.uri"] = params.uri
|
|
1561
|
+
break
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
return {
|
|
1565
|
+
name: target === undefined ? method : `${method} ${target}`,
|
|
1566
|
+
kind: "server",
|
|
1567
|
+
attributes,
|
|
1568
|
+
parent: remoteParentSpan(params)
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
// The MCP span of the request being handled. Unlike `Tracer.ParentSpan`, it is
|
|
1573
|
+
// unset outside a request, so code that sends a response for a request can
|
|
1574
|
+
// tell whether that request has an MCP span.
|
|
1575
|
+
const CurrentRequestSpan = Context.Reference<Tracer.Span | undefined>("effect/ai/McpServer/CurrentRequestSpan", {
|
|
1576
|
+
defaultValue: () => undefined
|
|
1577
|
+
})
|
|
1578
|
+
|
|
1579
|
+
// Spans whose request was answered with an error response sent by `McpServer`
|
|
1580
|
+
// itself. That response, not the handler's exit, classifies the span.
|
|
1581
|
+
const errorResponseSpans = new WeakSet<Tracer.Span>()
|
|
1582
|
+
|
|
1583
|
+
const recordErrorResponse = (span: Tracer.Span, code: number) => {
|
|
1584
|
+
errorResponseSpans.add(span)
|
|
1585
|
+
span.attribute("rpc.status_code", String(code))
|
|
1586
|
+
span.attribute("error.type", String(code))
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
const endRequestSpan = (span: Tracer.Span, method: string, exit: Exit.Exit<unknown, unknown>, endTime: bigint) => {
|
|
1590
|
+
if (errorResponseSpans.has(span)) {
|
|
1591
|
+
return span.end(endTime, exit)
|
|
1592
|
+
}
|
|
1593
|
+
if (Exit.isSuccess(exit)) {
|
|
1594
|
+
if (method === "tools/call" && Predicate.hasProperty(exit.value, "isError") && exit.value.isError === true) {
|
|
1595
|
+
span.attribute("error.type", "tool_error")
|
|
1596
|
+
}
|
|
1597
|
+
return span.end(endTime, exit)
|
|
1598
|
+
}
|
|
1599
|
+
// Interruptions and defects carry no JSON-RPC error. When one is answered
|
|
1600
|
+
// with an internal error, the response write records it on the span.
|
|
1601
|
+
const error = Cause.findErrorOption(exit.cause)
|
|
1602
|
+
if (Option.isNone(error) || !Predicate.hasProperty(error.value, "code") || typeof error.value.code !== "number") {
|
|
1603
|
+
return span.end(endTime, exit)
|
|
1604
|
+
}
|
|
1605
|
+
const code = error.value.code
|
|
1606
|
+
span.attribute("rpc.status_code", String(code))
|
|
1607
|
+
if (requestErrorCodes.has(code)) {
|
|
1608
|
+
return span.end(endTime, Exit.void)
|
|
1609
|
+
}
|
|
1610
|
+
span.attribute("error.type", String(code))
|
|
1611
|
+
span.end(endTime, exit)
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1467
1614
|
class McpClientKey extends Data.Class<{
|
|
1468
1615
|
readonly clientId: number
|
|
1469
1616
|
readonly profile: McpCore.NegotiatedProtocolProfile<string>
|
|
@@ -1557,6 +1704,14 @@ const normalizeCacheHints = (
|
|
|
1557
1704
|
* runtime handles protocol lifecycle state and determines which clients receive
|
|
1558
1705
|
* queued server notifications.
|
|
1559
1706
|
*
|
|
1707
|
+
* Each request handled by the server runs in a server span that follows the
|
|
1708
|
+
* OpenTelemetry MCP semantic conventions. Spans are named after the JSON-RPC
|
|
1709
|
+
* method, with the tool or prompt name appended for `tools/call` and
|
|
1710
|
+
* `prompts/get` (for example `tools/call get_weather`). A W3C `traceparent` in
|
|
1711
|
+
* `params._meta` becomes the span's parent, and the transport span (such as
|
|
1712
|
+
* the HTTP server span) is linked. Tool arguments are recorded only when
|
|
1713
|
+
* `Toolkit.RecordToolArguments` is `true`.
|
|
1714
|
+
*
|
|
1560
1715
|
* @stability unstable
|
|
1561
1716
|
* @category running
|
|
1562
1717
|
* @since 4.0.0
|
|
@@ -1617,14 +1772,56 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
1617
1772
|
const server = yield* McpServer
|
|
1618
1773
|
const defaultLogLevel = yield* CurrentLogLevel
|
|
1619
1774
|
const isHttp = transport === "http"
|
|
1775
|
+
const networkTransport = isHttp ? "tcp" : transport === "stdio" ? "pipe" : undefined
|
|
1776
|
+
// `RpcServer` tracing is disabled so that this span can follow the MCP
|
|
1777
|
+
// semantic conventions and continue the client's `_meta` trace. Wrapping the
|
|
1778
|
+
// request effect keeps the span on its lifecycle: it ends after the response
|
|
1779
|
+
// is written, or when the request is interrupted.
|
|
1780
|
+
const traceRequest = <X, E, R>(
|
|
1781
|
+
effect: Effect.Effect<X, E, R>,
|
|
1782
|
+
request: RpcMessage.Request<Rpc.Any>
|
|
1783
|
+
): Effect.Effect<X, E, R> =>
|
|
1784
|
+
Effect.withFiber((fiber) => {
|
|
1785
|
+
const method = runtime.methodForInternalTag(request.tag)
|
|
1786
|
+
const { name, ...spanOptions } = requestSpanOptions(method, request, {
|
|
1787
|
+
protocolVersion: runtime.protocolForInternalTag(request.tag).protocolVersion,
|
|
1788
|
+
networkTransport,
|
|
1789
|
+
sessionId: isHttp
|
|
1790
|
+
? Context.getOrUndefined(fiber.context, HttpServerRequest.HttpServerRequest)?.headers[MCP_SESSION_ID_HEADER]
|
|
1791
|
+
: undefined,
|
|
1792
|
+
recordToolArguments: fiber.getRef(Toolkit.RecordToolArguments)
|
|
1793
|
+
})
|
|
1794
|
+
const ambientParent = Context.getOrUndefined(fiber.context, Tracer.ParentSpan)
|
|
1795
|
+
return Effect.flatMap(
|
|
1796
|
+
Effect.makeSpan(name, {
|
|
1797
|
+
...spanOptions,
|
|
1798
|
+
links: spanOptions.parent !== undefined && ambientParent !== undefined
|
|
1799
|
+
? [{ span: ambientParent, attributes: {} }]
|
|
1800
|
+
: undefined
|
|
1801
|
+
}),
|
|
1802
|
+
(span) =>
|
|
1803
|
+
Effect.onExit(
|
|
1804
|
+
effect.pipe(
|
|
1805
|
+
Effect.provideService(Tracer.ParentSpan, span),
|
|
1806
|
+
Effect.provideService(CurrentRequestSpan, span)
|
|
1807
|
+
),
|
|
1808
|
+
(exit) =>
|
|
1809
|
+
Effect.sync(() => endRequestSpan(span, method, exit, fiber.getRef(Clock.Clock).currentTimeNanosUnsafe()))
|
|
1810
|
+
)
|
|
1811
|
+
)
|
|
1812
|
+
})
|
|
1620
1813
|
const clientStates = new Map<number, {
|
|
1621
1814
|
protocol: McpProtocol.AnyProtocolAdapter
|
|
1622
1815
|
profile: McpCore.NegotiatedProtocolProfile<string> | undefined
|
|
1623
1816
|
sessionHeaders: Headers.Headers | undefined
|
|
1624
1817
|
}>()
|
|
1625
1818
|
const activeRequests = new Map<number, Map<string, ActiveRequest>>()
|
|
1819
|
+
// Stdio has a single client whose session ends with stdin, so one latch is
|
|
1820
|
+
// enough; built-in subscriptions complete on it while finite requests drain.
|
|
1821
|
+
const stdioEnd = transport === "stdio" ? Latch.makeUnsafe() : undefined
|
|
1626
1822
|
const reverseRequestClients = new Map<string, Array<McpClientKey>>()
|
|
1627
1823
|
const disconnectClient = (clientId: number) => {
|
|
1824
|
+
for (const request of activeRequests.get(clientId)?.values() ?? []) request.liveness.active = false
|
|
1628
1825
|
activeRequests.delete(clientId)
|
|
1629
1826
|
clientStates.delete(clientId)
|
|
1630
1827
|
runtime.disconnect(clientId)
|
|
@@ -1687,6 +1884,7 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
1687
1884
|
if (request === undefined) {
|
|
1688
1885
|
return false
|
|
1689
1886
|
}
|
|
1887
|
+
request.liveness.active = false
|
|
1690
1888
|
requests!.set(key, { ...request, cancelled: true })
|
|
1691
1889
|
return true
|
|
1692
1890
|
}
|
|
@@ -1715,6 +1913,7 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
1715
1913
|
getListChangeRevision: () => notificationDelivery.listChangeRevision,
|
|
1716
1914
|
...(!protocol.supportsNotifications || options.allowSubscriptions === false ? {} : {
|
|
1717
1915
|
sendNotification,
|
|
1916
|
+
awaitClientEnd: stdioEnd?.await,
|
|
1718
1917
|
markSubscriptionCancelled: (clientId: number, requestId: RpcMessage.RequestId) =>
|
|
1719
1918
|
Effect.sync(() => {
|
|
1720
1919
|
cancelRequest(clientId, requestId)
|
|
@@ -1854,6 +2053,7 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
1854
2053
|
const requests = activeRequests.get(clientId)
|
|
1855
2054
|
const key = requestKey(response.requestId)
|
|
1856
2055
|
const active = requests?.get(key)
|
|
2056
|
+
if (active !== undefined) active.liveness.active = false
|
|
1857
2057
|
if (requests !== undefined && requests.delete(key) && requests.size === 0) {
|
|
1858
2058
|
activeRequests.delete(clientId)
|
|
1859
2059
|
}
|
|
@@ -1870,7 +2070,12 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
1870
2070
|
return sendRequestError(clientId, response.requestId, {
|
|
1871
2071
|
code: McpSchema.INTERNAL_ERROR_CODE,
|
|
1872
2072
|
message: "Internal error"
|
|
1873
|
-
})
|
|
2073
|
+
}).pipe(
|
|
2074
|
+
Effect.andThen(CurrentRequestSpan),
|
|
2075
|
+
Effect.map((span) => {
|
|
2076
|
+
if (span !== undefined) recordErrorResponse(span, McpSchema.INTERNAL_ERROR_CODE)
|
|
2077
|
+
})
|
|
2078
|
+
)
|
|
1874
2079
|
}
|
|
1875
2080
|
}
|
|
1876
2081
|
return protocol.send(clientId, response)
|
|
@@ -2033,17 +2238,19 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
2033
2238
|
? Effect.void
|
|
2034
2239
|
: sendRequestError(clientId, request.id, new InvalidParams({ message: "Invalid method parameters" }))
|
|
2035
2240
|
}
|
|
2241
|
+
const liveness = { active: true }
|
|
2036
2242
|
if (request.isNotification !== true) {
|
|
2037
2243
|
const requests = activeRequests.get(clientId) ?? new Map<string, ActiveRequest>()
|
|
2038
2244
|
requests.set(requestKey(request.id), {
|
|
2039
2245
|
requestId: RpcMessage.RequestId(request.id),
|
|
2040
2246
|
prepared,
|
|
2247
|
+
liveness,
|
|
2041
2248
|
cancelled: false,
|
|
2042
2249
|
httpPost: httpRequest === undefined ? undefined : httpPostResponses.get(httpRequest)
|
|
2043
2250
|
})
|
|
2044
2251
|
activeRequests.set(clientId, requests)
|
|
2045
2252
|
}
|
|
2046
|
-
const handled = f(clientId, routedRequest)
|
|
2253
|
+
const handled = Effect.provideService(f(clientId, routedRequest), RequestLiveness, liveness)
|
|
2047
2254
|
return yield* prepared.requestContext === undefined
|
|
2048
2255
|
? handled
|
|
2049
2256
|
: Effect.provideService(handled, McpRequestContext, prepared.requestContext)
|
|
@@ -2067,6 +2274,7 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
2067
2274
|
return f(clientId, request)
|
|
2068
2275
|
case "Eof":
|
|
2069
2276
|
if (!isHttp) {
|
|
2277
|
+
stdioEnd?.openUnsafe()
|
|
2070
2278
|
disconnectClient(clientId)
|
|
2071
2279
|
}
|
|
2072
2280
|
return f(clientId, request)
|
|
@@ -2099,7 +2307,7 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
2099
2307
|
const selectedProtocol = clientState?.protocol ?? runtime.protocols[0]
|
|
2100
2308
|
const profile = reverseKey?.profile ?? clientState?.profile ?? {
|
|
2101
2309
|
protocolVersion: selectedProtocol.protocolVersion,
|
|
2102
|
-
clientCapabilities: {},
|
|
2310
|
+
clientCapabilities: new McpSchema.ClientCapabilities({}),
|
|
2103
2311
|
clientInfo: { name: "unknown", version: "unknown" }
|
|
2104
2312
|
}
|
|
2105
2313
|
return RcMap.get(
|
|
@@ -2235,6 +2443,12 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
2235
2443
|
return
|
|
2236
2444
|
}
|
|
2237
2445
|
const encoded = yield* selectedProtocol.payloadCodecs(rpc).encode(projected.payload)
|
|
2446
|
+
// Projection and encoding can suspend after the request has ended.
|
|
2447
|
+
if (notification._tag === "Progress") {
|
|
2448
|
+
// The disconnect hook may still be scheduled when an interrupted handler resumes delivery.
|
|
2449
|
+
if (!(yield* patchedProtocol.clientIds).has(clientId)) return
|
|
2450
|
+
if (queued.requestLiveness?.active === false) return
|
|
2451
|
+
}
|
|
2238
2452
|
yield* patchedProtocol.send(clientId, {
|
|
2239
2453
|
_tag: "Request",
|
|
2240
2454
|
id: "",
|
|
@@ -2263,8 +2477,12 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
2263
2477
|
)
|
|
2264
2478
|
|
|
2265
2479
|
return yield* RpcServer.make(runtime.clientRpcs, {
|
|
2266
|
-
|
|
2267
|
-
disableFatalDefects: true
|
|
2480
|
+
disableTracing: true,
|
|
2481
|
+
disableFatalDefects: true,
|
|
2482
|
+
onDisconnect: (clientId) => Effect.sync(() => disconnectClient(clientId)),
|
|
2483
|
+
// Wrapped so `RpcServer.make` infers the group's rpcs from `clientRpcs`
|
|
2484
|
+
// rather than from `traceRequest`'s parameter type.
|
|
2485
|
+
onRequest: (effect, request) => traceRequest(effect, request)
|
|
2268
2486
|
}).pipe(
|
|
2269
2487
|
Effect.provideService(RpcServer.Protocol, patchedProtocol),
|
|
2270
2488
|
Effect.provideService(McpServerClientMiddleware, clientMiddleware),
|
|
@@ -2321,6 +2539,9 @@ type RegistrationServices<RR> = Exclude<McpRequest.Without<RR>, McpServer>
|
|
|
2321
2539
|
* `McpServer.layer`, so registration layers can use the `McpServer` service
|
|
2322
2540
|
* while the server is running.
|
|
2323
2541
|
*
|
|
2542
|
+
* Core lists return one complete page; supplying a cursor, including an empty
|
|
2543
|
+
* string, fails with `InvalidParams`.
|
|
2544
|
+
*
|
|
2324
2545
|
* Pass registration layers as `registrations` to build them before the server
|
|
2325
2546
|
* reads its first request. The transport discharges the request-level
|
|
2326
2547
|
* dependencies it supplies (see `ProvidedServices`); any other `McpRequest`
|
|
@@ -2409,6 +2630,10 @@ const layerWithRuntime = (options: {
|
|
|
2409
2630
|
* dependencies it supplies (see `ProvidedServices`); any other `McpRequest`
|
|
2410
2631
|
* marker stays in the layer's requirements and must be met by MCP middleware.
|
|
2411
2632
|
*
|
|
2633
|
+
* Each call builds its own `RpcServer.Protocol`, so several stdio servers can
|
|
2634
|
+
* live in one layer graph as long as each is provided its own `Stdio`. They
|
|
2635
|
+
* still share the memoized `McpServer` registry.
|
|
2636
|
+
*
|
|
2412
2637
|
* @see {@link layer} for running over an existing `RpcServer.Protocol`
|
|
2413
2638
|
* @see {@link layerHttp} for the single-endpoint HTTP transport
|
|
2414
2639
|
*
|
|
@@ -2441,7 +2666,11 @@ export const layerStdio = <
|
|
|
2441
2666
|
> =>
|
|
2442
2667
|
layerWithRuntime(options, "stdio").pipe(
|
|
2443
2668
|
Layer.provide(McpRuntime.layer(options.protocols)),
|
|
2444
|
-
|
|
2669
|
+
// Build a fresh protocol layer per call. `RpcServer.layerProtocolStdio` is
|
|
2670
|
+
// a module-level constant, and layers are memoized by reference, so two
|
|
2671
|
+
// `layerStdio` servers in one layer graph would otherwise share a single
|
|
2672
|
+
// protocol bound to whichever `Stdio` was built first.
|
|
2673
|
+
Layer.provide(Layer.effect(RpcServer.Protocol, RpcServer.makeProtocolStdio)),
|
|
2445
2674
|
Layer.provide(Layer.succeed(
|
|
2446
2675
|
RpcSerialization.RpcSerialization,
|
|
2447
2676
|
mcpStdioSerialization(options.protocols)
|
|
@@ -3081,40 +3310,33 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>>(
|
|
|
3081
3310
|
const annotations = tool.annotations
|
|
3082
3311
|
const toolMeta = Context.getOrUndefined(annotations, Tool.Meta)
|
|
3083
3312
|
const isDeclaredFailure = Schema.is(tool.failureSchema)
|
|
3084
|
-
|
|
3085
|
-
|
|
3313
|
+
// MCP content is JSON. Failures raised in "error" mode skip the Toolkit's encoding, so they use the JSON codec here.
|
|
3314
|
+
const encodeFailureJson = Schema.encodeUnknownEffect(Schema.toCodecJson(tool.failureSchema)) as (
|
|
3315
|
+
value: unknown
|
|
3086
3316
|
) => Effect.Effect<unknown, Schema.SchemaError, Tool.HandlerServices<Tools[keyof Tools]>>
|
|
3317
|
+
const encodeFailure = (toolResult: unknown) =>
|
|
3318
|
+
Effect.mapError(encodeFailureJson(toolResult), (cause) =>
|
|
3319
|
+
AiError.make({
|
|
3320
|
+
module: "McpServer",
|
|
3321
|
+
method: "registerToolkit",
|
|
3322
|
+
reason: new AiError.ToolResultEncodingError({
|
|
3323
|
+
toolName: tool.name,
|
|
3324
|
+
toolResult,
|
|
3325
|
+
description: cause.message
|
|
3326
|
+
})
|
|
3327
|
+
}))
|
|
3328
|
+
const failureResult = (encoded: unknown) =>
|
|
3329
|
+
new CallToolResult({ isError: true, content: toolResultContent(encoded) })
|
|
3087
3330
|
const declaredFailureResult = (error: unknown) =>
|
|
3088
3331
|
error instanceof Error && error.message !== ""
|
|
3089
3332
|
? Effect.succeed(toolErrorResult(error.message))
|
|
3090
|
-
: Effect.map(encodeFailure(error),
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
const successResult = (result: unknown) =>
|
|
3098
|
-
encodeStructured(result).pipe(
|
|
3099
|
-
Effect.mapError((cause) =>
|
|
3100
|
-
AiError.make({
|
|
3101
|
-
module: "McpServer",
|
|
3102
|
-
method: "registerToolkit",
|
|
3103
|
-
reason: new AiError.ToolResultEncodingError({
|
|
3104
|
-
toolName: tool.name,
|
|
3105
|
-
toolResult: result,
|
|
3106
|
-
description: cause.message
|
|
3107
|
-
})
|
|
3108
|
-
})
|
|
3109
|
-
),
|
|
3110
|
-
Effect.map((structuredContent) =>
|
|
3111
|
-
new CallToolResult({
|
|
3112
|
-
isError: false,
|
|
3113
|
-
structuredContent,
|
|
3114
|
-
content: toolResultContent(structuredContent)
|
|
3115
|
-
})
|
|
3116
|
-
)
|
|
3117
|
-
)
|
|
3333
|
+
: Effect.map(encodeFailure(error), failureResult)
|
|
3334
|
+
const successResult = (structuredContent: unknown) =>
|
|
3335
|
+
new CallToolResult({
|
|
3336
|
+
isError: false,
|
|
3337
|
+
structuredContent,
|
|
3338
|
+
content: toolResultContent(structuredContent)
|
|
3339
|
+
})
|
|
3118
3340
|
const handleCause = (cause: Cause.Cause<unknown>) => {
|
|
3119
3341
|
const failure = Cause.findFail(cause)
|
|
3120
3342
|
if (Result.isSuccess(failure)) {
|
|
@@ -3175,17 +3397,18 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>>(
|
|
|
3175
3397
|
unknown,
|
|
3176
3398
|
Tool.HandlerServices<Tools[keyof Tools]>
|
|
3177
3399
|
> => {
|
|
3400
|
+
// The Toolkit encodes successes and "return"-mode failures with their JSON codec.
|
|
3178
3401
|
if (!result.isFailure) {
|
|
3179
3402
|
// An absent result, such as `Schema.Void`, has no structured form.
|
|
3180
|
-
return
|
|
3181
|
-
|
|
3182
|
-
|
|
3403
|
+
return Effect.succeed(
|
|
3404
|
+
result.result === undefined
|
|
3405
|
+
? new CallToolResult({ isError: false, content: [] })
|
|
3406
|
+
: successResult(result.encodedResult)
|
|
3407
|
+
)
|
|
3183
3408
|
}
|
|
3184
3409
|
// Declared failures return their encoded payload; anything else is classified by origin.
|
|
3185
3410
|
return result.failureOrigin === "handler"
|
|
3186
|
-
? Effect.succeed(
|
|
3187
|
-
new CallToolResult({ isError: true, content: toolResultContent(result.encodedResult) })
|
|
3188
|
-
)
|
|
3411
|
+
? Effect.succeed(failureResult(result.encodedResult))
|
|
3189
3412
|
: Effect.failCause(Cause.annotate(
|
|
3190
3413
|
Cause.fail(result.result),
|
|
3191
3414
|
Context.make(Toolkit.FailureOrigin, result.failureOrigin ?? "result")
|
|
@@ -3463,7 +3686,7 @@ export const registerResource: {
|
|
|
3463
3686
|
}),
|
|
3464
3687
|
services,
|
|
3465
3688
|
handle: options.content.pipe(
|
|
3466
|
-
Effect.map((content) => resolveResourceContent(options.uri, content)),
|
|
3689
|
+
Effect.map((content) => resolveResourceContent(options.uri, options.mimeType, content)),
|
|
3467
3690
|
Effect.catchCause(handlerFailureToInternalError)
|
|
3468
3691
|
),
|
|
3469
3692
|
annotations: options.annotations ?? Context.empty()
|
|
@@ -3527,7 +3750,7 @@ export const registerResource: {
|
|
|
3527
3750
|
Effect.mapError((error) => new InvalidParams({ message: error.message })),
|
|
3528
3751
|
Effect.flatMap((params: any) =>
|
|
3529
3752
|
options.content(uri, ...params).pipe(
|
|
3530
|
-
Effect.map((content) => resolveResourceContent(uri, content)),
|
|
3753
|
+
Effect.map((content) => resolveResourceContent(uri, options.mimeType, content)),
|
|
3531
3754
|
Effect.catchCause(handlerFailureToInternalError)
|
|
3532
3755
|
)
|
|
3533
3756
|
)
|
|
@@ -3688,7 +3911,9 @@ const toSkillSourceFile = (path: string, file: SkillFile): McpSkills.SourceFile
|
|
|
3688
3911
|
* `skills/list` and `skills/get` with a manifest of every file's SHA-256
|
|
3689
3912
|
* digest and size, computed from the bytes served. Every directory of the
|
|
3690
3913
|
* skill namespace is readable with `resources/directory/read`. The server
|
|
3691
|
-
* declares the extension once any skill is registered.
|
|
3914
|
+
* declares the extension on protocol 2026-07-28 once any skill is registered.
|
|
3915
|
+
* Earlier revisions neither declare it nor answer its methods, but still serve
|
|
3916
|
+
* the skill's files through `resources/read`.
|
|
3692
3917
|
*
|
|
3693
3918
|
* Fails when the skill breaks the extension's rules: a name that does not
|
|
3694
3919
|
* match the URI, a `SKILL.md` without YAML frontmatter, frontmatter that is
|
|
@@ -4053,21 +4278,16 @@ const compileUriTemplate = (segments: TemplateStringsArray, ...schemas: Readonly
|
|
|
4053
4278
|
|
|
4054
4279
|
const resolveResourceContent = (
|
|
4055
4280
|
uri: string,
|
|
4281
|
+
mimeType: string | undefined,
|
|
4056
4282
|
content: ReadResourceResult | string | Uint8Array
|
|
4057
4283
|
): ReadResourceResult => {
|
|
4058
4284
|
if (typeof content === "string") {
|
|
4059
4285
|
return {
|
|
4060
|
-
contents: [{
|
|
4061
|
-
uri,
|
|
4062
|
-
text: content
|
|
4063
|
-
}]
|
|
4286
|
+
contents: [mimeType === undefined ? { uri, text: content } : { uri, mimeType, text: content }]
|
|
4064
4287
|
}
|
|
4065
4288
|
} else if (content instanceof Uint8Array) {
|
|
4066
4289
|
return {
|
|
4067
|
-
contents: [{
|
|
4068
|
-
uri,
|
|
4069
|
-
blob: content
|
|
4070
|
-
}]
|
|
4290
|
+
contents: [mimeType === undefined ? { uri, blob: content } : { uri, mimeType, blob: content }]
|
|
4071
4291
|
}
|
|
4072
4292
|
}
|
|
4073
4293
|
return content
|
package/src/ai/Prompt.ts
CHANGED
|
@@ -788,7 +788,9 @@ export interface ToolResultPart extends BasePart<"tool-result", ToolResultPartOp
|
|
|
788
788
|
*/
|
|
789
789
|
readonly isFailure: boolean
|
|
790
790
|
/**
|
|
791
|
-
* The result returned by the tool execution.
|
|
791
|
+
* The result returned by the tool execution. Results of locally handled
|
|
792
|
+
* tools hold their JSON encoding; provider-executed tools keep the
|
|
793
|
+
* provider's payload.
|
|
792
794
|
*/
|
|
793
795
|
readonly result: unknown
|
|
794
796
|
/**
|
|
@@ -822,7 +824,9 @@ export interface ToolResultPartEncoded extends BasePartEncoded<"tool-result", To
|
|
|
822
824
|
*/
|
|
823
825
|
readonly isFailure: boolean
|
|
824
826
|
/**
|
|
825
|
-
* The result returned by the tool execution.
|
|
827
|
+
* The result returned by the tool execution. Results of locally handled
|
|
828
|
+
* tools hold their JSON encoding; provider-executed tools keep the
|
|
829
|
+
* provider's payload.
|
|
826
830
|
*/
|
|
827
831
|
readonly result: unknown
|
|
828
832
|
/**
|
package/src/ai/Response.ts
CHANGED
|
@@ -162,9 +162,15 @@ const toolPartSchemaCache = new WeakMap<Tool.Any, {
|
|
|
162
162
|
const toolPartSchemas = (tool: Tool.Any) => {
|
|
163
163
|
let parts = toolPartSchemaCache.get(tool)
|
|
164
164
|
if (parts === undefined) {
|
|
165
|
+
// Provider-executed tools keep the provider's payload; locally handled
|
|
166
|
+
// tools carry the JSON encoding of their results, as the Toolkit produces.
|
|
167
|
+
const hasProviderResults = Tool.isProviderDefined(tool) && !tool.requiresHandler
|
|
168
|
+
const failure = Tool.failureResultSchema(tool)
|
|
165
169
|
parts = {
|
|
166
170
|
toolCall: ToolCallPart(tool.name, tool.parametersSchema),
|
|
167
|
-
toolResult:
|
|
171
|
+
toolResult: hasProviderResults
|
|
172
|
+
? ToolResultPart(tool.name, tool.successSchema, failure)
|
|
173
|
+
: ToolResultPart(tool.name, Schema.toCodecJson(tool.successSchema), Schema.toCodecJson(failure))
|
|
168
174
|
}
|
|
169
175
|
toolPartSchemaCache.set(tool, parts)
|
|
170
176
|
}
|
|
@@ -599,12 +605,20 @@ type ToolCallPartForName<
|
|
|
599
605
|
Name extends keyof Tools
|
|
600
606
|
> = Name extends string ? ToolCallPart<
|
|
601
607
|
Name,
|
|
602
|
-
ParametersMode extends "encoded" ?
|
|
608
|
+
ParametersMode extends "encoded" ? ToolCallParametersEncoded<Tools[Name]>
|
|
603
609
|
: ParametersMode extends "opaque" ? unknown
|
|
604
610
|
: Tool.Parameters<Tools[Name]>
|
|
605
611
|
>
|
|
606
612
|
: never
|
|
607
613
|
|
|
614
|
+
// Provider-executed tools keep the provider's payload; locally handled tool
|
|
615
|
+
// calls carry the JSON encoding of their parameters. Distributes over a
|
|
616
|
+
// non-literal handler flag, which may be either at runtime.
|
|
617
|
+
type ToolCallParametersEncoded<T extends Tool.Any> = T extends
|
|
618
|
+
Tool.ProviderDefined<any, any, any, infer RequiresHandler, any>
|
|
619
|
+
? RequiresHandler extends true ? Schema.Json : Tool.ParametersEncoded<T>
|
|
620
|
+
: Schema.Json
|
|
621
|
+
|
|
608
622
|
/**
|
|
609
623
|
* Utility type that extracts tool result parts from a set of tools.
|
|
610
624
|
*
|
|
@@ -1705,7 +1719,9 @@ export interface BaseToolResult<Name extends string> extends BasePart<"tool-resu
|
|
|
1705
1719
|
*/
|
|
1706
1720
|
readonly name: Name
|
|
1707
1721
|
/**
|
|
1708
|
-
* The encoded result for serialization purposes.
|
|
1722
|
+
* The encoded result for serialization purposes. Results of locally handled
|
|
1723
|
+
* tools hold their JSON encoding; provider-executed tools keep the
|
|
1724
|
+
* provider's payload.
|
|
1709
1725
|
*/
|
|
1710
1726
|
readonly encodedResult: unknown
|
|
1711
1727
|
/**
|