effect 4.1.2 → 4.1.4
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 +1 -1
- package/ai-docs/tsconfig.json +2 -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/Match.d.ts +6 -6
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.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/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/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 +26 -3
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +13 -2
- 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/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 +31 -5
- 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 +24 -5
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +26 -12
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +110 -110
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpServer.d.ts +15 -0
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +211 -33
- 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/WorkloadIdentity.d.ts +111 -0
- package/dist/ai/WorkloadIdentity.d.ts.map +1 -0
- package/dist/ai/WorkloadIdentity.js +227 -0
- package/dist/ai/WorkloadIdentity.js.map +1 -0
- package/dist/ai/index.d.ts +20 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +20 -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 +5 -8
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +5 -8
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +5 -5
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +5 -5
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +60 -51
- 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 +2 -0
- 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 +5 -17
- 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 +5 -1
- 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 +88 -10
- 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/cli/internal/lexer.js +13 -0
- package/dist/cli/internal/lexer.js.map +1 -1
- package/dist/cli/internal/parser.js +23 -16
- package/dist/cli/internal/parser.js.map +1 -1
- package/dist/cli/internal/wizard.d.ts.map +1 -1
- package/dist/cli/internal/wizard.js +4 -0
- package/dist/cli/internal/wizard.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +15 -13
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Entity.d.ts +17 -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 +81 -0
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +34 -2
- package/dist/cluster/MessageStorage.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/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/SchemaBinary.d.ts +14 -2
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +78 -5
- 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/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 +57 -12
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +92 -54
- 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.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +5 -3
- 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/internal/requestState.js +15 -0
- package/dist/http/internal/requestState.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +47 -0
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +66 -0
- package/dist/http-api/HttpApi.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +18 -2
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +1 -1
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +5 -1
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +85 -0
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +74 -2
- 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 +18 -10
- 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/matcher.js +1 -1
- package/dist/internal/matcher.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 +161 -36
- 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/toCodeDocument.js +3 -0
- package/dist/internal/schema/toCodeDocument.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/version.js +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 +12 -2
- package/dist/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/persistence/RateLimiter.js +11 -4
- 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 +67 -25
- 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 +59 -6
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +64 -17
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +1 -1
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +9 -16
- 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 +179 -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 +3 -3
- package/src/DateTime.ts +35 -2
- package/src/Match.ts +10 -8
- package/src/Queue.ts +16 -11
- package/src/Rational.ts +1549 -0
- package/src/RcMap.ts +16 -14
- package/src/Runtime.ts +84 -4
- package/src/Schema.ts +188 -29
- package/src/SchemaAST.ts +29 -13
- package/src/SchemaParser.ts +2 -2
- package/src/SchemaRepresentation.ts +31 -3
- package/src/ScopedCache.ts +18 -1
- 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 +87 -19
- package/src/ai/LanguageModel.ts +97 -23
- package/src/ai/McpServer.ts +244 -49
- 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/WorkloadIdentity.ts +318 -0
- package/src/ai/index.ts +24 -0
- package/src/ai/internal/mcpCore.ts +11 -15
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +8 -11
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +8 -11
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +8 -8
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +8 -8
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +76 -55
- package/src/ai/internal/mcpProtocol.ts +22 -3
- package/src/ai/internal/mcpProtocolRegistry.ts +5 -0
- package/src/ai/internal/mcpRuntime.ts +4 -2
- 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 +5 -20
- package/src/ai/internal/mcpStatefulRuntime.ts +0 -2
- package/src/ai/internal/structured-output.ts +7 -2
- package/src/cli/Argument.ts +86 -0
- package/src/cli/CliError.ts +7 -4
- package/src/cli/Command.ts +266 -36
- 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/cli/internal/lexer.ts +14 -0
- package/src/cli/internal/parser.ts +28 -20
- package/src/cli/internal/wizard.ts +4 -0
- package/src/cluster/ClusterWorkflowEngine.ts +14 -15
- package/src/cluster/Entity.ts +24 -0
- package/src/cluster/MessageRetention.ts +111 -0
- package/src/cluster/MessageStorage.ts +73 -2
- package/src/cluster/ShardingConfig.ts +12 -1
- package/src/cluster/SqlMessageStorage.ts +271 -41
- package/src/cluster/index.ts +6 -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/SchemaBinary.ts +76 -5
- package/src/encoding/Xml.ts +65 -16
- package/src/graphql/GraphQL.ts +7 -4
- package/src/http/Headers.ts +7 -2
- package/src/http/HttpClient.ts +118 -68
- package/src/http/HttpClientError.ts +82 -15
- package/src/http/HttpEffect.ts +101 -10
- package/src/http/HttpMiddleware.ts +15 -4
- package/src/http/HttpServer.ts +80 -0
- package/src/http/HttpServerRequest.ts +1 -19
- package/src/http/HttpStaticServer.ts +10 -16
- package/src/http/internal/requestState.ts +20 -0
- package/src/http-api/HttpApi.ts +80 -0
- package/src/http-api/HttpApiBuilder.ts +20 -2
- package/src/http-api/HttpApiClient.ts +13 -2
- package/src/http-api/HttpApiSchema.ts +90 -3
- 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 +27 -13
- package/src/internal/effect.ts +45 -18
- package/src/internal/equal.ts +8 -0
- package/src/internal/matcher.ts +7 -3
- package/src/internal/schema/codegen.ts +8 -7
- package/src/internal/schema/fromJsonSchemaDocument.ts +175 -35
- package/src/internal/schema/interpreter.ts +10 -10
- package/src/internal/schema/parser.ts +8 -4
- package/src/internal/schema/toCodeDocument.ts +8 -0
- package/src/internal/schema/toEquivalence.ts +7 -5
- package/src/internal/schema/toFormatter.ts +3 -2
- package/src/internal/version.ts +1 -1
- 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 +17 -5
- 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 +77 -28
- package/src/rpc/index.ts +6 -0
- package/src/schema/SchemaCompiler/runtime.ts +8 -3
- package/src/sql/SqlClient.ts +112 -26
- package/src/sql/Statement.ts +19 -23
- 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/rpc/Rpc.ts
CHANGED
|
@@ -696,7 +696,38 @@ export type IsStream<R extends Any, Tag extends string> = R extends Rpc<
|
|
|
696
696
|
* @category utility types
|
|
697
697
|
* @since 4.0.0
|
|
698
698
|
*/
|
|
699
|
-
export type ExtractTag<R extends Any, Tag extends string> = R extends
|
|
699
|
+
export type ExtractTag<R extends Any, Tag extends string> = [NonLiteralTagged<R>] extends [never] ?
|
|
700
|
+
ByTag<R>[Tag & Exclude<R, NonLiteralTagged<R>>["_tag"]]
|
|
701
|
+
: ExtractTagDistributive<R, Tag>
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Indexes the RPCs of a union by their tag.
|
|
705
|
+
*
|
|
706
|
+
* **Details**
|
|
707
|
+
*
|
|
708
|
+
* Indexing it with a literal tag selects that RPC without testing every RPC in
|
|
709
|
+
* the union, which keeps tag-based client calls fast for large groups.
|
|
710
|
+
*
|
|
711
|
+
* @stability unstable
|
|
712
|
+
* @category utility types
|
|
713
|
+
* @since 4.1.3
|
|
714
|
+
*/
|
|
715
|
+
export type ByTag<R extends Any> = { readonly [Current in R as Current["_tag"]]: Current }
|
|
716
|
+
|
|
717
|
+
// The RPCs whose tag is not a single literal. `ByTag` cannot index a union
|
|
718
|
+
// containing one: a `string`, template literal pattern or union-valued tag
|
|
719
|
+
// would change which RPCs a tag matches.
|
|
720
|
+
type NonLiteralTagged<R extends Any> = R extends Any ? IsLiteral<R["_tag"]> extends true ? never : R : never
|
|
721
|
+
|
|
722
|
+
// `true` when `T` is one string literal: not `string`, not a template literal
|
|
723
|
+
// pattern and not a union.
|
|
724
|
+
type IsLiteral<T extends string, Each = T> = {} extends Record<T, unknown> ? false
|
|
725
|
+
: Each extends unknown ? [T] extends [Each] ? true : false
|
|
726
|
+
: never
|
|
727
|
+
|
|
728
|
+
// Tests every RPC in the union. Used when some RPC's tag is not a single
|
|
729
|
+
// literal, which `ByTag` cannot index without changing which RPCs match.
|
|
730
|
+
type ExtractTagDistributive<R extends Any, Tag extends string> = R extends Rpc<
|
|
700
731
|
infer _Tag extends Tag,
|
|
701
732
|
infer _Payload,
|
|
702
733
|
infer _Success,
|
|
@@ -761,7 +792,8 @@ export type ExcludeProvides<Env, R extends Any, Tag extends string> = Exclude<
|
|
|
761
792
|
*
|
|
762
793
|
* Streaming RPCs may return a stream or an effect that produces a queue. Other
|
|
763
794
|
* RPCs return an effect that succeeds with the success value or a deferred
|
|
764
|
-
* success value.
|
|
795
|
+
* success value. Handlers may also fail with the errors of the RPC's server
|
|
796
|
+
* middleware, but a returned `Deferred` can only fail with the RPC's own error.
|
|
765
797
|
*
|
|
766
798
|
* @stability unstable
|
|
767
799
|
* @category utility types
|
|
@@ -777,17 +809,17 @@ export type ResultFrom<R extends Any, Services> = R extends Rpc<
|
|
|
777
809
|
> ? [_Success] extends [RpcSchema.Stream<infer _SA, infer _SE>] ?
|
|
778
810
|
| Stream<
|
|
779
811
|
_SA["Type"],
|
|
780
|
-
_SE["Type"] | _Error["Type"],
|
|
812
|
+
_SE["Type"] | _Error["Type"] | _Middleware["error"]["Type"],
|
|
781
813
|
Services
|
|
782
814
|
>
|
|
783
815
|
| Effect<
|
|
784
|
-
Queue.Dequeue<_SA["Type"], _SE["Type"] | _Error["Type"] | Cause.Done>,
|
|
785
|
-
_SE["Type"] |
|
|
816
|
+
Queue.Dequeue<_SA["Type"], _SE["Type"] | _Error["Type"] | _Middleware["error"]["Type"] | Cause.Done>,
|
|
817
|
+
_SE["Type"] | _Error["Type"] | _Middleware["error"]["Type"],
|
|
786
818
|
Services
|
|
787
819
|
> :
|
|
788
820
|
Effect<
|
|
789
821
|
_Success["Type"] | Deferred<_Success["Type"], _Error["Type"]>,
|
|
790
|
-
_Error["Type"],
|
|
822
|
+
_Error["Type"] | _Middleware["error"]["Type"],
|
|
791
823
|
Services
|
|
792
824
|
> :
|
|
793
825
|
never
|
package/src/rpc/RpcClient.ts
CHANGED
|
@@ -98,65 +98,8 @@ export declare namespace RpcClient {
|
|
|
98
98
|
const Discard = false
|
|
99
99
|
>(
|
|
100
100
|
input: Rpc.PayloadConstructor<Current>,
|
|
101
|
-
options?:
|
|
102
|
-
|
|
103
|
-
readonly streamBufferSize?: number | undefined
|
|
104
|
-
readonly headers?: Headers.Input | undefined
|
|
105
|
-
readonly context?: Context.Context<never> | undefined
|
|
106
|
-
} :
|
|
107
|
-
{
|
|
108
|
-
readonly headers?: Headers.Input | undefined
|
|
109
|
-
readonly context?: Context.Context<never> | undefined
|
|
110
|
-
/**
|
|
111
|
-
* Completes once the server acknowledges the call as its handler starts,
|
|
112
|
-
* after the middleware has run, instead of waiting for the result. The
|
|
113
|
-
* handler's result and error are not returned, but transport errors,
|
|
114
|
-
* middleware errors and failures before the handler starts still fail the
|
|
115
|
-
* call. Over HTTP and workers the call completes after the handler has
|
|
116
|
-
* finished. A protocol that only delivers requests acknowledges the call
|
|
117
|
-
* itself once it has delivered the request.
|
|
118
|
-
*/
|
|
119
|
-
readonly discard?: Discard | undefined
|
|
120
|
-
}
|
|
121
|
-
) => Current extends Rpc.Rpc<
|
|
122
|
-
infer _Tag,
|
|
123
|
-
infer _Payload,
|
|
124
|
-
infer _Success,
|
|
125
|
-
infer _Error,
|
|
126
|
-
infer _Middleware,
|
|
127
|
-
infer _Requires
|
|
128
|
-
> ? [_Success] extends [RpcSchema.Stream<infer _A, infer _E>] ? AsQueue extends true ? Effect.Effect<
|
|
129
|
-
Queue.Dequeue<
|
|
130
|
-
_A["Type"],
|
|
131
|
-
_E["Type"] | _Error["Type"] | E | _Middleware["error"]["Type"] | _Middleware["~ClientError"] | Cause.Done
|
|
132
|
-
>,
|
|
133
|
-
never,
|
|
134
|
-
| Scope.Scope
|
|
135
|
-
| _Payload["EncodingServices"]
|
|
136
|
-
| _Success["DecodingServices"]
|
|
137
|
-
| _Error["DecodingServices"]
|
|
138
|
-
| _Middleware["error"]["DecodingServices"]
|
|
139
|
-
>
|
|
140
|
-
: Stream.Stream<
|
|
141
|
-
_A["Type"],
|
|
142
|
-
_E["Type"] | _Error["Type"] | E | _Middleware["error"]["Type"] | _Middleware["~ClientError"],
|
|
143
|
-
| _Payload["EncodingServices"]
|
|
144
|
-
| _Success["DecodingServices"]
|
|
145
|
-
| _Error["DecodingServices"]
|
|
146
|
-
| _Middleware["error"]["DecodingServices"]
|
|
147
|
-
>
|
|
148
|
-
: Effect.Effect<
|
|
149
|
-
Discard extends true ? void : _Success["Type"],
|
|
150
|
-
| (Discard extends true ? never : _Error["Type"])
|
|
151
|
-
| E
|
|
152
|
-
| _Middleware["error"]["Type"]
|
|
153
|
-
| _Middleware["~ClientError"],
|
|
154
|
-
| _Payload["EncodingServices"]
|
|
155
|
-
| _Success["DecodingServices"]
|
|
156
|
-
| _Error["DecodingServices"]
|
|
157
|
-
| _Middleware["error"]["DecodingServices"]
|
|
158
|
-
> :
|
|
159
|
-
never
|
|
101
|
+
options?: Options<Current, AsQueue, Discard>
|
|
102
|
+
) => Result<Current, E, AsQueue, Discard>
|
|
160
103
|
}
|
|
161
104
|
|
|
162
105
|
/**
|
|
@@ -174,28 +117,48 @@ export declare namespace RpcClient {
|
|
|
174
117
|
>(
|
|
175
118
|
tag: Tag,
|
|
176
119
|
payload: Rpc.PayloadConstructor<Rpc.ExtractTag<Rpcs, Tag>>,
|
|
177
|
-
options?:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
120
|
+
options?: Options<Rpc.ExtractTag<Rpcs, Tag>, AsQueue, Discard>
|
|
121
|
+
) => Result<Rpc.ExtractTag<Rpcs, Tag>, E, AsQueue, Discard>
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The options accepted by a client call for the given RPC(s).
|
|
125
|
+
*
|
|
126
|
+
* @stability unstable
|
|
127
|
+
* @category utility types
|
|
128
|
+
* @since 4.1.3
|
|
129
|
+
*/
|
|
130
|
+
export type Options<Current, AsQueue extends boolean, Discard> = Rpc.Success<Current> extends
|
|
131
|
+
Stream.Stream<infer _A, infer _E, infer _R> ? {
|
|
132
|
+
readonly asQueue?: AsQueue | undefined
|
|
133
|
+
readonly streamBufferSize?: number | undefined
|
|
134
|
+
readonly headers?: Headers.Input | undefined
|
|
135
|
+
readonly context?: Context.Context<never> | undefined
|
|
136
|
+
} :
|
|
137
|
+
{
|
|
138
|
+
readonly headers?: Headers.Input | undefined
|
|
139
|
+
readonly context?: Context.Context<never> | undefined
|
|
140
|
+
/**
|
|
141
|
+
* Completes once the server acknowledges the call as its handler starts,
|
|
142
|
+
* after the middleware has run, instead of waiting for the result. The
|
|
143
|
+
* handler's result and error are not returned, but transport errors,
|
|
144
|
+
* middleware errors and failures before the handler starts still fail the
|
|
145
|
+
* call. Over HTTP and workers the call completes after the handler has
|
|
146
|
+
* finished. A protocol that only delivers requests acknowledges the call
|
|
147
|
+
* itself once it has delivered the request.
|
|
148
|
+
*/
|
|
149
|
+
readonly discard?: Discard | undefined
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The result of a client call for the given RPC(s). Distributes over a union
|
|
154
|
+
* of RPCs.
|
|
155
|
+
*
|
|
156
|
+
* @stability unstable
|
|
157
|
+
* @category utility types
|
|
158
|
+
* @since 4.1.3
|
|
159
|
+
*/
|
|
160
|
+
export type Result<Current, E, AsQueue extends boolean, Discard> = Current extends Rpc.Rpc<
|
|
161
|
+
infer _Tag,
|
|
199
162
|
infer _Payload,
|
|
200
163
|
infer _Success,
|
|
201
164
|
infer _Error,
|
|
@@ -204,7 +167,7 @@ export declare namespace RpcClient {
|
|
|
204
167
|
> ? [_Success] extends [RpcSchema.Stream<infer _A, infer _E>] ? AsQueue extends true ? Effect.Effect<
|
|
205
168
|
Queue.Dequeue<
|
|
206
169
|
_A["Type"],
|
|
207
|
-
_E["Type"] | _Error["Type"] | E | _Middleware["error"]["Type"] | _Middleware["~ClientError"]
|
|
170
|
+
_E["Type"] | _Error["Type"] | E | _Middleware["error"]["Type"] | _Middleware["~ClientError"] | Cause.Done
|
|
208
171
|
>,
|
|
209
172
|
never,
|
|
210
173
|
| Scope.Scope
|
package/src/rpc/RpcServer.ts
CHANGED
|
@@ -31,6 +31,7 @@ import * as Option from "../Option.ts"
|
|
|
31
31
|
import * as Predicate from "../Predicate.ts"
|
|
32
32
|
import * as Pull from "../Pull.ts"
|
|
33
33
|
import * as Queue from "../Queue.ts"
|
|
34
|
+
import * as Runtime from "../Runtime.ts"
|
|
34
35
|
import * as Schedule from "../Schedule.ts"
|
|
35
36
|
import * as Schema from "../Schema.ts"
|
|
36
37
|
import * as SchemaIssue from "../SchemaIssue.ts"
|
|
@@ -73,7 +74,9 @@ import { withRun } from "./Utils.ts"
|
|
|
73
74
|
*/
|
|
74
75
|
export interface RpcServer<A extends Rpc.Any> {
|
|
75
76
|
readonly write: (clientId: number, message: FromClient<A>, options?: {
|
|
76
|
-
readonly onRequest?:
|
|
77
|
+
readonly onRequest?:
|
|
78
|
+
| (<X, E, R>(effect: Effect.Effect<X, E, R>, request: Request<A>) => Effect.Effect<X, E, R>)
|
|
79
|
+
| undefined
|
|
77
80
|
}) => Effect.Effect<void>
|
|
78
81
|
readonly disconnect: (clientId: number) => Effect.Effect<void>
|
|
79
82
|
}
|
|
@@ -377,7 +380,7 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any>(
|
|
|
377
380
|
return close ? Effect.ensuring(write, close) : write
|
|
378
381
|
})
|
|
379
382
|
if (opts?.onRequest) {
|
|
380
|
-
effect = opts.onRequest(effect)
|
|
383
|
+
effect = opts.onRequest(effect, request)
|
|
381
384
|
}
|
|
382
385
|
if (enableTracing) {
|
|
383
386
|
const parentSpan = Context.getOrUndefined(
|
|
@@ -634,6 +637,12 @@ const applyMiddleware = <A, E, R>(
|
|
|
634
637
|
* client's requests, so use the `onDisconnect` option to observe disconnects
|
|
635
638
|
* instead of taking from that queue.
|
|
636
639
|
*
|
|
640
|
+
* `onRequest` wraps the effect that runs one decoded request: its middleware
|
|
641
|
+
* and handler and, when the handler returns its result directly, the response
|
|
642
|
+
* write. The wrapped effect is interrupted when the request is cancelled, its
|
|
643
|
+
* client disconnects or the server stops. It runs inside the request's tracing
|
|
644
|
+
* span unless tracing is disabled.
|
|
645
|
+
*
|
|
637
646
|
* `onDisconnect` is called for each disconnect reported by the `Protocol`,
|
|
638
647
|
* after the server has requested interruption of that client's in-flight
|
|
639
648
|
* requests. It does not wait for those requests to finish. It is not called
|
|
@@ -645,6 +654,12 @@ const applyMiddleware = <A, E, R>(
|
|
|
645
654
|
* callbacks are interrupted when the server stops. Failures are ignored and
|
|
646
655
|
* logged at `References.UnhandledLogLevel`.
|
|
647
656
|
*
|
|
657
|
+
* **Gotchas**
|
|
658
|
+
*
|
|
659
|
+
* When a handler succeeds with a `Deferred`, the effect wrapped by
|
|
660
|
+
* `onRequest` ends at that point. The reply is sent once the `Deferred`
|
|
661
|
+
* completes, outside the wrapped effect.
|
|
662
|
+
*
|
|
648
663
|
* @stability unstable
|
|
649
664
|
* @category running
|
|
650
665
|
* @since 4.0.0
|
|
@@ -658,6 +673,9 @@ export const make: <Rpcs extends Rpc.Any>(
|
|
|
658
673
|
readonly spanAttributes?: Record<string, unknown> | undefined
|
|
659
674
|
readonly concurrency?: number | "unbounded" | undefined
|
|
660
675
|
readonly disableFatalDefects?: boolean | undefined
|
|
676
|
+
readonly onRequest?:
|
|
677
|
+
| (<X, E, R>(effect: Effect.Effect<X, E, R>, request: Request<Rpcs>) => Effect.Effect<X, E, R>)
|
|
678
|
+
| undefined
|
|
661
679
|
readonly onDisconnect?: ((clientId: number) => Effect.Effect<void>) | undefined
|
|
662
680
|
}
|
|
663
681
|
| undefined
|
|
@@ -676,6 +694,9 @@ export const make: <Rpcs extends Rpc.Any>(
|
|
|
676
694
|
readonly spanAttributes?: Record<string, unknown> | undefined
|
|
677
695
|
readonly concurrency?: number | "unbounded" | undefined
|
|
678
696
|
readonly disableFatalDefects?: boolean | undefined
|
|
697
|
+
readonly onRequest?:
|
|
698
|
+
| (<X, E, R>(effect: Effect.Effect<X, E, R>, request: Request<Rpcs>) => Effect.Effect<X, E, R>)
|
|
699
|
+
| undefined
|
|
679
700
|
readonly onDisconnect?: ((clientId: number) => Effect.Effect<void>) | undefined
|
|
680
701
|
}
|
|
681
702
|
) {
|
|
@@ -693,6 +714,7 @@ export const make: <Rpcs extends Rpc.Any>(
|
|
|
693
714
|
const services = yield* Effect.context<Rpc.ToHandler<Rpcs> | Rpc.Middleware<Rpcs>>()
|
|
694
715
|
const scope = yield* Scope.make()
|
|
695
716
|
|
|
717
|
+
const writeOptions = options?.onRequest ? { onRequest: options.onRequest } : undefined
|
|
696
718
|
const server = yield* makeNoSerialization(group, {
|
|
697
719
|
...options,
|
|
698
720
|
disableClientAcks: !supportsAck,
|
|
@@ -931,7 +953,7 @@ export const make: <Rpcs extends Rpc.Any>(
|
|
|
931
953
|
decoded.id = requestId
|
|
932
954
|
decoded.payload = payload
|
|
933
955
|
decoded.headers = headers as any
|
|
934
|
-
return server.write(client.id, decoded as any)
|
|
956
|
+
return server.write(client.id, decoded as any, writeOptions)
|
|
935
957
|
}
|
|
936
958
|
|
|
937
959
|
let notificationCount = 0
|
|
@@ -1335,42 +1357,48 @@ export const makeProtocolWithHttpEffect: (
|
|
|
1335
1357
|
end: Queue.end(queue)
|
|
1336
1358
|
}
|
|
1337
1359
|
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
Effect.forEach(
|
|
1360
|
+
// Ends an unfinished response, failing it with `cause` when given, and interrupts its requests.
|
|
1361
|
+
const terminate = (cause?: Cause.Cause<never>) =>
|
|
1362
|
+
Effect.suspend(() => {
|
|
1363
|
+
if (queue.state._tag === "Done") return Effect.void
|
|
1364
|
+
if (cause) Queue.failCauseUnsafe(queue, cause)
|
|
1365
|
+
Queue.shutdownUnsafe(queue)
|
|
1366
|
+
return Effect.forEach(
|
|
1346
1367
|
requestIds,
|
|
1347
1368
|
(requestId) => writeRequest(id, { _tag: "Interrupt", requestId }),
|
|
1348
1369
|
{ discard: true }
|
|
1349
1370
|
)
|
|
1350
|
-
)
|
|
1371
|
+
})
|
|
1372
|
+
yield* Scope.addFinalizerExit(scope, () => {
|
|
1373
|
+
clients.delete(id)
|
|
1374
|
+
clientIds.delete(id)
|
|
1375
|
+
Queue.offerUnsafe(disconnects, id)
|
|
1376
|
+
return terminate()
|
|
1351
1377
|
})
|
|
1352
1378
|
clients.set(id, client)
|
|
1353
1379
|
clientIds.add(id)
|
|
1354
1380
|
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1381
|
+
const dispatch = Effect.gen(function*() {
|
|
1382
|
+
// @effect-diagnostics-next-line tryCatchInEffectGen:off
|
|
1383
|
+
try {
|
|
1384
|
+
const decoded = parser.decode(data) as ReadonlyArray<FromClientEncoded>
|
|
1385
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
1386
|
+
const message = decoded[i]
|
|
1387
|
+
if (message._tag === "Request") {
|
|
1388
|
+
requestIds.push(RequestId(message.id))
|
|
1389
|
+
;(message as Types.Mutable<RequestEncoded>).headers = requestHeaders.concat(message.headers)
|
|
1390
|
+
}
|
|
1391
|
+
yield* writeRequest(id, message)
|
|
1363
1392
|
}
|
|
1364
|
-
|
|
1393
|
+
} catch (cause) {
|
|
1394
|
+
yield* client.write(ResponseDefectEncoded(encodeDefectUnsafe(cause)))
|
|
1365
1395
|
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
yield* writeRequest(id, constEof)
|
|
1396
|
+
yield* writeRequest(id, constEof)
|
|
1397
|
+
})
|
|
1371
1398
|
|
|
1372
|
-
// Allow request aborts during response waits without unmasking response construction.
|
|
1373
1399
|
if (!includesFraming) {
|
|
1400
|
+
yield* dispatch
|
|
1401
|
+
// Allow request aborts during response waits without unmasking response construction.
|
|
1374
1402
|
const responses = yield* Effect.interruptible(Queue.collect(queue))
|
|
1375
1403
|
// Notification-only batches encode without a response body.
|
|
1376
1404
|
const encoded = parser.encode(responses)
|
|
@@ -1379,11 +1407,16 @@ export const makeProtocolWithHttpEffect: (
|
|
|
1379
1407
|
})
|
|
1380
1408
|
}
|
|
1381
1409
|
|
|
1410
|
+
// Dispatch concurrently so the bounded queue can drain; a failed dispatch fails the response.
|
|
1411
|
+
yield* Effect.forkIn(Effect.onError(dispatch, terminate), scope, { startImmediately: true })
|
|
1412
|
+
|
|
1382
1413
|
const initialChunk = yield* Effect.interruptible(Pull.catchDone(
|
|
1383
1414
|
Queue.takeAll(queue as Queue.Dequeue<Uint8Array, Cause.Done>),
|
|
1384
1415
|
() => Effect.succeed([])
|
|
1385
1416
|
))
|
|
1386
1417
|
if (queue.state._tag === "Done") {
|
|
1418
|
+
// A failed dispatch may have completed the queue after the initial chunk was taken.
|
|
1419
|
+
yield* Pull.doneExitFromCause<Cause.Done>(queue.state.exit.cause)
|
|
1387
1420
|
return HttpServerResponse.uint8Array(initialChunk.length === 1 ? initialChunk[0] : Bytes.concat(initialChunk), {
|
|
1388
1421
|
contentType: serialization.contentType
|
|
1389
1422
|
})
|
|
@@ -1591,7 +1624,15 @@ export const makeProtocolStdio = Effect.gen(function*() {
|
|
|
1591
1624
|
yield* Stream.fromQueue(queue).pipe(
|
|
1592
1625
|
Stream.run(stdio.stdout()),
|
|
1593
1626
|
Effect.retry(Schedule.spaced(500)),
|
|
1594
|
-
Effect.
|
|
1627
|
+
Effect.onExit((exit) => {
|
|
1628
|
+
if (Exit.isFailure(exit) && Cause.hasInterruptsOnly(exit.cause)) return Effect.void
|
|
1629
|
+
return Effect.forkDetach(
|
|
1630
|
+
Exit.isSuccess(exit)
|
|
1631
|
+
? Fiber.interruptAs(fiber, undefined, Context.make(Runtime.InterruptExitCode, 0))
|
|
1632
|
+
: Fiber.interrupt(fiber),
|
|
1633
|
+
{ startImmediately: true }
|
|
1634
|
+
)
|
|
1635
|
+
}),
|
|
1595
1636
|
Effect.forkScoped
|
|
1596
1637
|
)
|
|
1597
1638
|
|
|
@@ -1622,6 +1663,14 @@ export const makeProtocolStdio = Effect.gen(function*() {
|
|
|
1622
1663
|
* Provides a server `Protocol` that reads RPC messages from `Stdio.stdin` and
|
|
1623
1664
|
* writes encoded responses to `Stdio.stdout`.
|
|
1624
1665
|
*
|
|
1666
|
+
* **Gotchas**
|
|
1667
|
+
*
|
|
1668
|
+
* This layer is a module-level constant, and layers are memoized by reference
|
|
1669
|
+
* within one layer graph. Providing it to several servers in the same graph
|
|
1670
|
+
* yields one shared `Protocol` bound to the first `Stdio` that was built. To
|
|
1671
|
+
* run more than one stdio server in a graph, wrap it in `Layer.fresh` or build
|
|
1672
|
+
* a separate `Layer.effect(Protocol, makeProtocolStdio)` per server.
|
|
1673
|
+
*
|
|
1625
1674
|
* @stability unstable
|
|
1626
1675
|
* @category layers
|
|
1627
1676
|
* @since 4.0.0
|
package/src/rpc/index.ts
CHANGED
|
@@ -58,7 +58,12 @@ const makeObjectBase = (
|
|
|
58
58
|
parser = compileField(property.type)
|
|
59
59
|
parsers.set(property.type, parser)
|
|
60
60
|
}
|
|
61
|
-
return {
|
|
61
|
+
return {
|
|
62
|
+
parser,
|
|
63
|
+
name: property.name,
|
|
64
|
+
type: property.type,
|
|
65
|
+
ownOnly: SchemaAST.requiresOwnProperty(property.name)
|
|
66
|
+
}
|
|
62
67
|
})
|
|
63
68
|
}
|
|
64
69
|
let fallback: SchemaIssueParser | undefined
|
|
@@ -70,7 +75,7 @@ const makeObjectBase = (
|
|
|
70
75
|
pending: Effect.Effect<unknown, SchemaIssue.Issue, any>
|
|
71
76
|
): Effect.Effect<unknown, SchemaIssue.Issue, any> => {
|
|
72
77
|
const property = properties![index]
|
|
73
|
-
return Effect.flatMap(Effect.exit(pending), (exit) => {
|
|
78
|
+
return Effect.flatMap(Effect.exit(pending), (exit): Effect.Effect<unknown, SchemaIssue.Issue, any> => {
|
|
74
79
|
// Each execution gets its own output; `issues` is still undefined here
|
|
75
80
|
// because `errors: "all"` is routed to the fallback before suspending.
|
|
76
81
|
const state: ObjectParserState = { ...snapshot, out: { ...snapshot.out } }
|
|
@@ -266,7 +271,7 @@ export const runtime = {
|
|
|
266
271
|
invalid,
|
|
267
272
|
missing: InternalParser.missing,
|
|
268
273
|
missingExit: InternalParser.missingExit,
|
|
269
|
-
|
|
274
|
+
isSameExit: InternalParser.isSameExit,
|
|
270
275
|
args: InternalParser.args,
|
|
271
276
|
succeed: InternalParser.succeed,
|
|
272
277
|
effectIsExit,
|