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
|
@@ -83,8 +83,28 @@ export interface PersistedQueue<in out A, out R = never> {
|
|
|
83
83
|
*
|
|
84
84
|
* If an element with the same id already exists in the queue, it will not be
|
|
85
85
|
* added again, and the `delay` of the duplicate offer is ignored.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
86
|
+
* `deduplicate` sets how long a custom `id` stays reserved:
|
|
87
|
+
*
|
|
88
|
+
* - `"untilRemoved"` (default): until `layerCleanup` removes the completed
|
|
89
|
+
* or failed element. The id works as an idempotency key.
|
|
90
|
+
* - `"untilExecuted"`: until the element completes or fails its final
|
|
91
|
+
* attempt. Offers while it is pending, processing or waiting to retry are
|
|
92
|
+
* ignored. A later offer enqueues a new element behind queued work, with its
|
|
93
|
+
* own `delay`, so a producer that retries after completion runs the work
|
|
94
|
+
* again.
|
|
95
|
+
*
|
|
96
|
+
* The mode is chosen per offer and is not stored with the id. An
|
|
97
|
+
* `"untilExecuted"` offer can re-open a completed or failed id even when
|
|
98
|
+
* other producers offer it with `"untilRemoved"`, so don't share an
|
|
99
|
+
* idempotency key with `"untilExecuted"` producers.
|
|
100
|
+
*
|
|
101
|
+
* With `"untilExecuted"`, handlers should read current state rather than the
|
|
102
|
+
* offered value. An offer that arrives after the handler read state but before
|
|
103
|
+
* the element completes is ignored, so check a version or dirty flag when a
|
|
104
|
+
* missed change matters.
|
|
105
|
+
*
|
|
106
|
+
* A re-offered failed id may lose its earlier failure record. See
|
|
107
|
+
* `makeStoreSql` and `makeStoreRedis` for what each store keeps.
|
|
88
108
|
*
|
|
89
109
|
* `delay` postpones the first delivery. Measured by the store's clock, the
|
|
90
110
|
* element is never delivered before the delay elapses, and is typically
|
|
@@ -103,6 +123,7 @@ export interface PersistedQueue<in out A, out R = never> {
|
|
|
103
123
|
readonly offer: (value: A, options?: {
|
|
104
124
|
readonly id?: string | undefined
|
|
105
125
|
readonly delay?: Duration.Input | undefined
|
|
126
|
+
readonly deduplicate?: "untilExecuted" | "untilRemoved" | undefined
|
|
106
127
|
}) => Effect.Effect<string, PersistedQueueError | Schema.SchemaError, R>
|
|
107
128
|
|
|
108
129
|
/**
|
|
@@ -265,7 +286,8 @@ export const makeFactory = Effect.gen(function*() {
|
|
|
265
286
|
id,
|
|
266
287
|
element,
|
|
267
288
|
isCustomId: opts?.id !== undefined,
|
|
268
|
-
delay
|
|
289
|
+
delay,
|
|
290
|
+
deduplicate: opts?.deduplicate
|
|
269
291
|
}),
|
|
270
292
|
id
|
|
271
293
|
)
|
|
@@ -442,7 +464,8 @@ const makeAckRetrySchedule = (lockExpiration: Duration.Input) =>
|
|
|
442
464
|
|
|
443
465
|
// Internal signal used by the factory to tell a store that a taken element
|
|
444
466
|
// cannot ever be processed (its stored payload fails to decode) and must be
|
|
445
|
-
// dead-lettered instead of retried.
|
|
467
|
+
// dead-lettered instead of retried. Stores outside this module detect it with
|
|
468
|
+
// the exported `isDeadLetterCause`.
|
|
446
469
|
class DeadLetter {
|
|
447
470
|
readonly _tag = "~effect/persistence/PersistedQueue/DeadLetter"
|
|
448
471
|
readonly cause: Cause.Cause<unknown>
|
|
@@ -486,11 +509,18 @@ const deadLetterFromCause = (cause: Cause.Cause<unknown>): DeadLetter | undefine
|
|
|
486
509
|
* An offered `delay` is always finite and positive, and the element must not
|
|
487
510
|
* be taken before it elapses. It is `undefined` for immediate elements.
|
|
488
511
|
*
|
|
512
|
+
* An offer whose id is already stored is ignored, unless `deduplicate` is
|
|
513
|
+
* `"untilExecuted"` and that element has completed or failed its final
|
|
514
|
+
* attempt. The offer is then stored as a new element after earlier offers,
|
|
515
|
+
* atomically with respect to concurrent offers of the id. `undefined` means
|
|
516
|
+
* `"untilRemoved"`.
|
|
517
|
+
*
|
|
489
518
|
* Claiming an element counts an attempt, so the `attempts` returned by `take`
|
|
490
519
|
* is 1-based. When the take scope closes with a success the element is marked
|
|
491
520
|
* completed; a failure retries it according to `retryDelay` or marks it failed
|
|
492
521
|
* once `maxAttempts` is exhausted; an interruption releases it without
|
|
493
|
-
* counting the attempt.
|
|
522
|
+
* counting the attempt. A failure for which {@link isDeadLetterCause} holds
|
|
523
|
+
* marks the element failed immediately, without a retry.
|
|
494
524
|
*
|
|
495
525
|
* @stability unstable
|
|
496
526
|
* @category services
|
|
@@ -506,6 +536,7 @@ export class PersistedQueueStore extends Context.Service<
|
|
|
506
536
|
readonly element: unknown
|
|
507
537
|
readonly isCustomId: boolean
|
|
508
538
|
readonly delay?: Duration.Duration | undefined
|
|
539
|
+
readonly deduplicate?: "untilExecuted" | "untilRemoved" | undefined
|
|
509
540
|
}
|
|
510
541
|
) => Effect.Effect<void, PersistedQueueError>
|
|
511
542
|
|
|
@@ -535,6 +566,30 @@ export class PersistedQueueStore extends Context.Service<
|
|
|
535
566
|
}
|
|
536
567
|
>()("effect/persistence/PersistedQueue/PersistedQueueStore") {}
|
|
537
568
|
|
|
569
|
+
/**
|
|
570
|
+
* Returns `true` when a take scope failed because the queue could not decode
|
|
571
|
+
* the element's stored payload.
|
|
572
|
+
*
|
|
573
|
+
* **When to use**
|
|
574
|
+
*
|
|
575
|
+
* Use when a custom `PersistedQueueStore` take finalizer decides whether a
|
|
576
|
+
* failed element is marked failed at once or retried.
|
|
577
|
+
*
|
|
578
|
+
* **Details**
|
|
579
|
+
*
|
|
580
|
+
* A payload that fails to decode with the queue's schema can never be
|
|
581
|
+
* processed, so `PersistedQueue` fails the take scope with an internal
|
|
582
|
+
* dead-letter signal and takes the next element. The store should mark the
|
|
583
|
+
* element failed whatever attempts remain, which also releases its id for a
|
|
584
|
+
* `deduplicate: "untilExecuted"` offer.
|
|
585
|
+
*
|
|
586
|
+
* @see {@link PersistedQueueStore} for the store contract that calls for this check
|
|
587
|
+
* @stability unstable
|
|
588
|
+
* @category predicates
|
|
589
|
+
* @since 4.1.3
|
|
590
|
+
*/
|
|
591
|
+
export const isDeadLetterCause = (cause: Cause.Cause<unknown>): boolean => deadLetterFromCause(cause) !== undefined
|
|
592
|
+
|
|
538
593
|
/**
|
|
539
594
|
* Provides an in-memory `PersistedQueueStore`.
|
|
540
595
|
*
|
|
@@ -590,7 +645,15 @@ export const layerStoreMemory: Layer.Layer<
|
|
|
590
645
|
Effect.sync(() => {
|
|
591
646
|
const now = clock.currentTimeMillisUnsafe()
|
|
592
647
|
const queue = getOrCreateQueue(options.name)
|
|
593
|
-
|
|
648
|
+
const existing = queue.entries.get(options.id)
|
|
649
|
+
if (existing !== undefined) {
|
|
650
|
+
if (
|
|
651
|
+
options.deduplicate !== "untilExecuted" ||
|
|
652
|
+
(existing.state !== "completed" && existing.state !== "failed")
|
|
653
|
+
) return
|
|
654
|
+
// delete first so the new entry is ordered after existing ones
|
|
655
|
+
queue.entries.delete(options.id)
|
|
656
|
+
}
|
|
594
657
|
const entry: Entry = {
|
|
595
658
|
id: options.id,
|
|
596
659
|
element: options.element,
|
|
@@ -638,8 +701,7 @@ export const layerStoreMemory: Layer.Layer<
|
|
|
638
701
|
entry.stateChangedAt = now
|
|
639
702
|
return
|
|
640
703
|
}
|
|
641
|
-
|
|
642
|
-
if (deadLetter !== undefined) {
|
|
704
|
+
if (isDeadLetterCause(exit.cause)) {
|
|
643
705
|
entry.state = "failed"
|
|
644
706
|
entry.stateChangedAt = now
|
|
645
707
|
return
|
|
@@ -706,6 +768,11 @@ export const layerStoreMemory: Layer.Layer<
|
|
|
706
768
|
* worker and let its locks expire before starting upgraded workers. Keep the
|
|
707
769
|
* existing Redis data rather than flushing it.
|
|
708
770
|
*
|
|
771
|
+
* Every failure of an id re-offered with `deduplicate: "untilExecuted"` stays
|
|
772
|
+
* in the failed list until `layerCleanup` removes it, which requires
|
|
773
|
+
* `failedTimeToLive`. Ids that failed on an earlier `effect` version stay
|
|
774
|
+
* reserved until then, even for `"untilExecuted"` offers.
|
|
775
|
+
*
|
|
709
776
|
* @stability unstable
|
|
710
777
|
* @category constructors
|
|
711
778
|
* @since 4.0.0
|
|
@@ -907,21 +974,22 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
907
974
|
})
|
|
908
975
|
|
|
909
976
|
return PersistedQueueStore.of({
|
|
910
|
-
offer: ({ delay, element, id, isCustomId, name }) => {
|
|
977
|
+
offer: ({ deduplicate, delay, element, id, isCustomId, name }) => {
|
|
911
978
|
const keys = keysFor(name)
|
|
912
979
|
// replace lone surrogates like Redis' UTF-8 encoding does, so the id in
|
|
913
980
|
// the payload matches the id keys
|
|
914
981
|
id = id.replace(/[\uD800-\uDFFF]/gu, "\uFFFD")
|
|
915
982
|
const payload = JSON.stringify({ id, element })
|
|
983
|
+
const untilExecuted = deduplicate === "untilExecuted" ? 1 : 0
|
|
916
984
|
const send = Effect.suspend(() => {
|
|
917
985
|
if (delay === undefined) {
|
|
918
986
|
return isCustomId
|
|
919
|
-
? offer(keys.queue, keys.ids, id, payload)
|
|
987
|
+
? offer(keys.queue, keys.ids, id, payload, untilExecuted)
|
|
920
988
|
: redis.send("RPUSH", keys.queue, payload)
|
|
921
989
|
}
|
|
922
990
|
const visibleAt = clock.currentTimeMillisUnsafe() + Duration.toMillis(delay)
|
|
923
991
|
return isCustomId
|
|
924
|
-
? offerDelayed(keys.delayed, keys.ids, id, payload, visibleAt)
|
|
992
|
+
? offerDelayed(keys.delayed, keys.ids, id, payload, visibleAt, untilExecuted)
|
|
925
993
|
: redis.send("ZADD", keys.delayed, visibleAt.toString(), payload)
|
|
926
994
|
})
|
|
927
995
|
return send.pipe(
|
|
@@ -994,7 +1062,8 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
994
1062
|
attempts: element.attempts,
|
|
995
1063
|
lastFailure: Cause.pretty(cause),
|
|
996
1064
|
failedAt: now
|
|
997
|
-
})
|
|
1065
|
+
}),
|
|
1066
|
+
now
|
|
998
1067
|
))
|
|
999
1068
|
if (dead !== undefined) {
|
|
1000
1069
|
return failElement(dead.cause)
|
|
@@ -1056,8 +1125,43 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
1056
1125
|
});
|
|
1057
1126
|
})
|
|
1058
1127
|
|
|
1128
|
+
// ids sorted set scores. The sentinels sit above any completion time, so the
|
|
1129
|
+
// timeToLive trim skips them:
|
|
1130
|
+
// - inFlightIdScore: pending or processing
|
|
1131
|
+
// - failedIdScore + failedAt: failed at failedAt. trimFailed removes it only
|
|
1132
|
+
// with the failed record carrying that failedAt
|
|
1133
|
+
// - +inf: legacy in-flight or failed entry. Offers treat it as in flight
|
|
1134
|
+
// - otherwise: the completion time
|
|
1135
|
+
const inFlightIdScore = 1e15
|
|
1136
|
+
const failedIdScore = 2e15
|
|
1137
|
+
|
|
1138
|
+
// formatted as an integer, since Lua's default number formatting keeps only 14
|
|
1139
|
+
// significant digits
|
|
1140
|
+
const failedScoreLua = `local function failed_score(failed_at)
|
|
1141
|
+
return string.format("%.0f", ${failedIdScore} + tonumber(failed_at))
|
|
1142
|
+
end
|
|
1143
|
+
`
|
|
1144
|
+
|
|
1145
|
+
// Reserves the id and returns whether to store the offer. With until_executed,
|
|
1146
|
+
// a completed or failed id is reclaimed.
|
|
1147
|
+
const claimIdLua = `local function claim_id(key_ids, id, until_executed)
|
|
1148
|
+
if redis.call("ZADD", key_ids, "NX", ${inFlightIdScore}, id) == 1 then
|
|
1149
|
+
return true
|
|
1150
|
+
end
|
|
1151
|
+
if until_executed ~= "1" then
|
|
1152
|
+
return false
|
|
1153
|
+
end
|
|
1154
|
+
local score = redis.call("ZSCORE", key_ids, id)
|
|
1155
|
+
if score == "inf" or tonumber(score) == ${inFlightIdScore} then
|
|
1156
|
+
return false
|
|
1157
|
+
end
|
|
1158
|
+
redis.call("ZADD", key_ids, "XX", ${inFlightIdScore}, id)
|
|
1159
|
+
return true
|
|
1160
|
+
end
|
|
1161
|
+
`
|
|
1162
|
+
|
|
1059
1163
|
const offerRedis = Redis.script(
|
|
1060
|
-
(...args: [keyQueue: string, keyIds: string, id: string, payload: string]) => args,
|
|
1164
|
+
(...args: [keyQueue: string, keyIds: string, id: string, payload: string, untilExecuted: number]) => args,
|
|
1061
1165
|
{
|
|
1062
1166
|
lua: `
|
|
1063
1167
|
local key_queue = KEYS[1]
|
|
@@ -1065,10 +1169,8 @@ local key_ids = KEYS[2]
|
|
|
1065
1169
|
local id = ARGV[1]
|
|
1066
1170
|
local payload = ARGV[2]
|
|
1067
1171
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
local result = redis.call("ZADD", key_ids, "NX", "+inf", id)
|
|
1071
|
-
if result == 1 then
|
|
1172
|
+
${claimIdLua}
|
|
1173
|
+
if claim_id(key_ids, id, ARGV[3]) then
|
|
1072
1174
|
redis.call("RPUSH", key_queue, payload)
|
|
1073
1175
|
end
|
|
1074
1176
|
`,
|
|
@@ -1077,7 +1179,16 @@ end
|
|
|
1077
1179
|
)
|
|
1078
1180
|
|
|
1079
1181
|
const offerDelayedRedis = Redis.script(
|
|
1080
|
-
(
|
|
1182
|
+
(
|
|
1183
|
+
...args: [
|
|
1184
|
+
keyDelayed: string,
|
|
1185
|
+
keyIds: string,
|
|
1186
|
+
id: string,
|
|
1187
|
+
payload: string,
|
|
1188
|
+
visibleAt: number,
|
|
1189
|
+
untilExecuted: number
|
|
1190
|
+
]
|
|
1191
|
+
) => args,
|
|
1081
1192
|
{
|
|
1082
1193
|
lua: `
|
|
1083
1194
|
local key_delayed = KEYS[1]
|
|
@@ -1086,8 +1197,8 @@ local id = ARGV[1]
|
|
|
1086
1197
|
local payload = ARGV[2]
|
|
1087
1198
|
local visible_at = ARGV[3]
|
|
1088
1199
|
|
|
1089
|
-
|
|
1090
|
-
if
|
|
1200
|
+
${claimIdLua}
|
|
1201
|
+
if claim_id(key_ids, id, ARGV[4]) then
|
|
1091
1202
|
redis.call("ZADD", key_delayed, visible_at, payload)
|
|
1092
1203
|
end
|
|
1093
1204
|
`,
|
|
@@ -1119,6 +1230,7 @@ local key_owners = KEYS[6]
|
|
|
1119
1230
|
local max_attempts = tonumber(ARGV[1])
|
|
1120
1231
|
local now = ARGV[2]
|
|
1121
1232
|
|
|
1233
|
+
${failedScoreLua}
|
|
1122
1234
|
local entries = redis.call("HGETALL", key_pending)
|
|
1123
1235
|
-- recovery revokes ownership, so late settlements from the old claim are no-ops
|
|
1124
1236
|
for i = 1, #entries, 2 do
|
|
@@ -1136,7 +1248,7 @@ for i = 1, #entries, 2 do
|
|
|
1136
1248
|
redis.call("HDEL", key_attempts, id)
|
|
1137
1249
|
-- failed ids keep their dedupe entry until failedTimeToLive removes the
|
|
1138
1250
|
-- dead-letter record, so park them outside the timeToLive trim range
|
|
1139
|
-
redis.call("ZADD", key_ids, "XX",
|
|
1251
|
+
redis.call("ZADD", key_ids, "XX", failed_score(now), id)
|
|
1140
1252
|
else
|
|
1141
1253
|
redis.call("RPUSH", key_queue, payload)
|
|
1142
1254
|
end
|
|
@@ -1262,7 +1374,8 @@ const failedRedis = Redis.script(
|
|
|
1262
1374
|
keyIds: string,
|
|
1263
1375
|
keyOwners: string,
|
|
1264
1376
|
id: string,
|
|
1265
|
-
payload: string
|
|
1377
|
+
payload: string,
|
|
1378
|
+
failedAt: number
|
|
1266
1379
|
]
|
|
1267
1380
|
) => args,
|
|
1268
1381
|
{
|
|
@@ -1275,13 +1388,15 @@ local key_ids = KEYS[5]
|
|
|
1275
1388
|
local key_owners = KEYS[6]
|
|
1276
1389
|
local id = ARGV[1]
|
|
1277
1390
|
local payload = ARGV[2]
|
|
1391
|
+
local failed_at = ARGV[3]
|
|
1278
1392
|
|
|
1393
|
+
${failedScoreLua}
|
|
1279
1394
|
${releaseClaimLua}
|
|
1280
1395
|
redis.call("HDEL", key_attempts, id)
|
|
1281
1396
|
redis.call("RPUSH", key_failed, payload)
|
|
1282
1397
|
-- failed ids keep their dedupe entry until failedTimeToLive removes the
|
|
1283
1398
|
-- dead-letter record, so park them outside the timeToLive trim range
|
|
1284
|
-
redis.call("ZADD", key_ids, "XX",
|
|
1399
|
+
redis.call("ZADD", key_ids, "XX", failed_score(failed_at), id)
|
|
1285
1400
|
`,
|
|
1286
1401
|
numberOfKeys: 6
|
|
1287
1402
|
}
|
|
@@ -1422,7 +1537,11 @@ while removed < ${trimFailedBatchSize} do
|
|
|
1422
1537
|
-- failedAt is always the last field of a failed record
|
|
1423
1538
|
local failed_at = tonumber(string.match(head, ',"failedAt":([^,}]+)%}$'))
|
|
1424
1539
|
if failed_at ~= nil and failed_at >= cutoff then break end
|
|
1425
|
-
|
|
1540
|
+
-- release the id only if it still belongs to this failure
|
|
1541
|
+
local score = redis.call("ZSCORE", key_ids, id)
|
|
1542
|
+
if score == "inf" or (failed_at ~= nil and tonumber(score) == ${failedIdScore} + failed_at) then
|
|
1543
|
+
redis.call("ZREM", key_ids, id)
|
|
1544
|
+
end
|
|
1426
1545
|
end
|
|
1427
1546
|
-- a corrupt head would otherwise block trimming of the whole list
|
|
1428
1547
|
redis.call("LPOP", key_failed)
|
|
@@ -1471,6 +1590,17 @@ export const layerStoreRedis: (
|
|
|
1471
1590
|
* Offer and retry delays are measured with the database clock and rounded up
|
|
1472
1591
|
* to whole seconds.
|
|
1473
1592
|
*
|
|
1593
|
+
* An id re-offered with `deduplicate: "untilExecuted"` keeps only its latest
|
|
1594
|
+
* failure.
|
|
1595
|
+
*
|
|
1596
|
+
* **Gotchas**
|
|
1597
|
+
*
|
|
1598
|
+
* An `"untilExecuted"` offer inside a transaction checks the id against that
|
|
1599
|
+
* transaction's snapshot. Under an isolation level with one snapshot per
|
|
1600
|
+
* transaction, such as MySQL's default repeatable read, an element that
|
|
1601
|
+
* completed or failed after the first read still looks in flight, so the offer
|
|
1602
|
+
* is ignored.
|
|
1603
|
+
*
|
|
1474
1604
|
* @stability unstable
|
|
1475
1605
|
* @category constructors
|
|
1476
1606
|
* @since 4.0.0
|
|
@@ -1532,17 +1662,21 @@ export const makeStoreSql: (
|
|
|
1532
1662
|
})
|
|
1533
1663
|
}
|
|
1534
1664
|
const secondsAgo = (seconds: number) => secondsOffset(-Math.max(Math.ceil(seconds), 0))
|
|
1535
|
-
|
|
1536
|
-
//
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
//
|
|
1540
|
-
|
|
1541
|
-
|
|
1665
|
+
// sqlite's CURRENT_TIMESTAMP drops the fraction of the current second, so
|
|
1666
|
+
// visible_at deadlines and the readiness check share this fractional clock
|
|
1667
|
+
const sqliteOffset = (seconds: number) =>
|
|
1668
|
+
sql`strftime('%Y-%m-%d %H:%M:%f', 'now', '${sql.literal(seconds.toString())} seconds')`
|
|
1669
|
+
// Deadline for a delayed offer or retry, which must never land before the
|
|
1670
|
+
// delay elapses. pg reads clock_timestamp() since NOW() is fixed at
|
|
1671
|
+
// transaction start. mysql stores whole seconds and NOW() drops the current
|
|
1672
|
+
// fraction, so it gets an extra second to cover it.
|
|
1673
|
+
const visibleAfter = (delay: Duration.Duration) => {
|
|
1674
|
+
const seconds = Math.max(Math.ceil(Duration.toSeconds(delay)), 0)
|
|
1542
1675
|
return sql.onDialectOrElse({
|
|
1543
1676
|
pg: () => sql`clock_timestamp() + INTERVAL '${sql.literal(seconds.toString())} seconds'`,
|
|
1677
|
+
mysql: () => secondsOffset(seconds + 1),
|
|
1544
1678
|
mssql: () => secondsOffset(seconds),
|
|
1545
|
-
orElse: () =>
|
|
1679
|
+
orElse: () => sqliteOffset(seconds)
|
|
1546
1680
|
})
|
|
1547
1681
|
}
|
|
1548
1682
|
const expiresAt = secondsAgo(Duration.toSeconds(lockExpiration))
|
|
@@ -1668,9 +1802,8 @@ export const makeStoreSql: (
|
|
|
1668
1802
|
ack(
|
|
1669
1803
|
sql`
|
|
1670
1804
|
UPDATE ${tableNameSql}
|
|
1671
|
-
SET acquired_at = NULL, acquired_by = NULL, updated_at = ${sqlNow}, visible_at = ${
|
|
1672
|
-
|
|
1673
|
-
}, last_failure = ${Cause.pretty(cause)}
|
|
1805
|
+
SET acquired_at = NULL, acquired_by = NULL, updated_at = ${sqlNow}, visible_at = ${visibleAfter(delay)},
|
|
1806
|
+
last_failure = ${Cause.pretty(cause)}
|
|
1674
1807
|
WHERE sequence = ${element.sequence}
|
|
1675
1808
|
AND acquired_by = ${stringLiteral(element.lock)}
|
|
1676
1809
|
`,
|
|
@@ -1822,7 +1955,7 @@ export const makeStoreSql: (
|
|
|
1822
1955
|
WHERE queue_name = ${name}
|
|
1823
1956
|
AND state = 'pending'
|
|
1824
1957
|
AND attempts < ${maxAttempts}
|
|
1825
|
-
AND visible_at <= ${
|
|
1958
|
+
AND visible_at <= ${sqliteOffset(0)}
|
|
1826
1959
|
AND (acquired_at IS NULL OR acquired_at < ${expiresAt})
|
|
1827
1960
|
ORDER BY visible_at ASC, sequence ASC
|
|
1828
1961
|
LIMIT ${sql.literal(size.toString())}
|
|
@@ -1920,17 +2053,42 @@ export const makeStoreSql: (
|
|
|
1920
2053
|
})
|
|
1921
2054
|
)
|
|
1922
2055
|
|
|
2056
|
+
// Stores the re-offer as a new row with a fresh sequence. The plain read keeps
|
|
2057
|
+
// new ids lock-free, since under MySQL's repeatable read deleting an absent
|
|
2058
|
+
// key takes gap locks that deadlock concurrent inserts. The delete re-checks
|
|
2059
|
+
// the state and shares a transaction with the insert, so concurrent offers of
|
|
2060
|
+
// the id wait on the deleted row and then see the re-offer.
|
|
2061
|
+
const replaceExecuted = <A, E, R>(id: string, name: string, insert: Effect.Effect<A, E, R>) =>
|
|
2062
|
+
Effect.flatMap(
|
|
2063
|
+
sql<{ readonly sequence: number | string }>`
|
|
2064
|
+
SELECT sequence FROM ${tableNameSql}
|
|
2065
|
+
WHERE id = ${id} AND queue_name = ${name} AND state IN ('completed', 'failed')
|
|
2066
|
+
`,
|
|
2067
|
+
(rows) =>
|
|
2068
|
+
rows.length === 0 ? insert : sql.withTransaction(Effect.andThen(
|
|
2069
|
+
sql`
|
|
2070
|
+
DELETE FROM ${tableNameSql}
|
|
2071
|
+
WHERE sequence = ${rows[0].sequence} AND state IN ('completed', 'failed')
|
|
2072
|
+
`,
|
|
2073
|
+
insert
|
|
2074
|
+
))
|
|
2075
|
+
)
|
|
2076
|
+
|
|
1923
2077
|
return PersistedQueueStore.of({
|
|
1924
|
-
offer: ({ delay, element, id, name }) =>
|
|
2078
|
+
offer: ({ deduplicate, delay, element, id, isCustomId, name }) =>
|
|
1925
2079
|
Effect.catchCause(
|
|
1926
|
-
Effect.suspend(() =>
|
|
1927
|
-
offer(
|
|
2080
|
+
Effect.suspend(() => {
|
|
2081
|
+
const insert = offer(
|
|
1928
2082
|
id,
|
|
1929
2083
|
name,
|
|
1930
2084
|
JSON.stringify(element),
|
|
1931
|
-
delay === undefined ? sqlNow :
|
|
2085
|
+
delay === undefined ? sqlNow : visibleAfter(delay)
|
|
1932
2086
|
)
|
|
1933
|
-
|
|
2087
|
+
// generated ids are never offered twice
|
|
2088
|
+
return deduplicate === "untilExecuted" && isCustomId
|
|
2089
|
+
? replaceExecuted(id, name, insert)
|
|
2090
|
+
: insert
|
|
2091
|
+
}),
|
|
1934
2092
|
(cause) =>
|
|
1935
2093
|
Effect.fail(
|
|
1936
2094
|
new PersistedQueueError({
|
|
@@ -653,8 +653,13 @@ export class RateLimiterStore extends Context.Service<
|
|
|
653
653
|
* Returns the token count *after* taking the specified `tokens` and time to
|
|
654
654
|
* live for the `key`.
|
|
655
655
|
*
|
|
656
|
+
* Without a `limit`, each admission extends the time to live by
|
|
657
|
+
* `refillRate` per taken token.
|
|
658
|
+
*
|
|
656
659
|
* If `limit` is provided, the number of taken tokens will be capped at the
|
|
657
|
-
* limit.
|
|
660
|
+
* limit. The first admission of positive tokens into an empty or expired
|
|
661
|
+
* key opens a window lasting `refillRate * limit`, and later admissions do
|
|
662
|
+
* not extend it.
|
|
658
663
|
*
|
|
659
664
|
* In the case the limit is exceeded, the returned count will be greater
|
|
660
665
|
* than the limit, but the TTL will not be updated.
|
|
@@ -778,7 +783,12 @@ export const makeMemoryStore: Effect.Effect<
|
|
|
778
783
|
return [counter.count + options.tokens, counter.expiresAt - now] as const
|
|
779
784
|
}
|
|
780
785
|
counter.count += options.tokens
|
|
781
|
-
|
|
786
|
+
if (options.limit === undefined) {
|
|
787
|
+
counter.expiresAt += refillRateMillis * options.tokens
|
|
788
|
+
} else if (counter.expiresAt === now && options.tokens > 0) {
|
|
789
|
+
// A capped window opens on its first positive admission and lasts the full window.
|
|
790
|
+
counter.expiresAt = now + refillRateMillis * options.limit
|
|
791
|
+
}
|
|
782
792
|
return [counter.count, counter.expiresAt - now] as const
|
|
783
793
|
})
|
|
784
794
|
),
|
|
@@ -1132,10 +1142,11 @@ local limit = tonumber(ARGV[3])
|
|
|
1132
1142
|
local current = tonumber(redis.call("GET", key))
|
|
1133
1143
|
|
|
1134
1144
|
if not current then
|
|
1135
|
-
|
|
1145
|
+
-- A capped window opens on its first positive admission and lasts the full window.
|
|
1146
|
+
if limit and (tokens > limit or tokens <= 0) then
|
|
1136
1147
|
return { string.format("%.17g", tokens), 0 }
|
|
1137
1148
|
end
|
|
1138
|
-
local nextpttl = math.max(1, math.ceil(refillms * tokens))
|
|
1149
|
+
local nextpttl = math.max(1, math.ceil(refillms * (limit or tokens)))
|
|
1139
1150
|
redis.call("SET", key, tokens, "PX", nextpttl)
|
|
1140
1151
|
return { string.format("%.17g", tokens), nextpttl }
|
|
1141
1152
|
end
|
|
@@ -1146,7 +1157,8 @@ if limit and next > limit then
|
|
|
1146
1157
|
return { string.format("%.17g", next), currentpttl }
|
|
1147
1158
|
end
|
|
1148
1159
|
|
|
1149
|
-
|
|
1160
|
+
-- A capped window keeps its expiry (PX rather than KEEPTTL, which needs Redis 6.0).
|
|
1161
|
+
local nextpttl = math.max(1, limit and currentpttl or math.ceil(currentpttl + (refillms * tokens)))
|
|
1150
1162
|
redis.call("SET", key, next, "PX", nextpttl)
|
|
1151
1163
|
-- Use 17 significant digits to round-trip fractional token counts.
|
|
1152
1164
|
return { string.format("%.17g", next), nextpttl }
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* `<redacted>`.
|
|
24
24
|
*
|
|
25
25
|
* @stability unstable
|
|
26
|
-
* @since 4.0
|
|
26
|
+
* @since 4.1.0
|
|
27
27
|
*/
|
|
28
28
|
import * as Data from "../Data.ts"
|
|
29
29
|
import * as Redacted from "../Redacted.ts"
|
|
@@ -45,7 +45,7 @@ import * as Result from "../Result.ts"
|
|
|
45
45
|
*
|
|
46
46
|
* @stability unstable
|
|
47
47
|
* @category models
|
|
48
|
-
* @since 4.0
|
|
48
|
+
* @since 4.1.0
|
|
49
49
|
*/
|
|
50
50
|
export type Format = "posix" | "powershell" | "windows"
|
|
51
51
|
|
|
@@ -55,7 +55,7 @@ export type Format = "posix" | "powershell" | "windows"
|
|
|
55
55
|
*
|
|
56
56
|
* @stability unstable
|
|
57
57
|
* @category models
|
|
58
|
-
* @since 4.0
|
|
58
|
+
* @since 4.1.0
|
|
59
59
|
*/
|
|
60
60
|
export type Word = string | Redacted.Redacted<string>
|
|
61
61
|
|
|
@@ -64,7 +64,7 @@ export type Word = string | Redacted.Redacted<string>
|
|
|
64
64
|
*
|
|
65
65
|
* @stability unstable
|
|
66
66
|
* @category models
|
|
67
|
-
* @since 4.0
|
|
67
|
+
* @since 4.1.0
|
|
68
68
|
*/
|
|
69
69
|
export type TemplateExpressionItem = string | number | boolean | Redacted.Redacted<string>
|
|
70
70
|
|
|
@@ -78,7 +78,7 @@ export type TemplateExpressionItem = string | number | boolean | Redacted.Redact
|
|
|
78
78
|
*
|
|
79
79
|
* @stability unstable
|
|
80
80
|
* @category models
|
|
81
|
-
* @since 4.0
|
|
81
|
+
* @since 4.1.0
|
|
82
82
|
*/
|
|
83
83
|
export type TemplateExpression = TemplateExpressionItem | ReadonlyArray<TemplateExpressionItem>
|
|
84
84
|
|
|
@@ -103,7 +103,7 @@ export type TemplateExpression = TemplateExpressionItem | ReadonlyArray<Template
|
|
|
103
103
|
*
|
|
104
104
|
* @stability unstable
|
|
105
105
|
* @category errors
|
|
106
|
-
* @since 4.0
|
|
106
|
+
* @since 4.1.0
|
|
107
107
|
*/
|
|
108
108
|
export class CommandLineError extends Data.TaggedError("CommandLineError")<{
|
|
109
109
|
readonly reason: "NulCharacter" | "InvalidArgument" | "InvalidEscape" | "UnterminatedQuote" | "UnsupportedSyntax"
|
|
@@ -156,7 +156,7 @@ export class CommandLineError extends Data.TaggedError("CommandLineError")<{
|
|
|
156
156
|
*
|
|
157
157
|
* @stability unstable
|
|
158
158
|
* @category encoding
|
|
159
|
-
* @since 4.0
|
|
159
|
+
* @since 4.1.0
|
|
160
160
|
*/
|
|
161
161
|
export const quote = (
|
|
162
162
|
word: Word,
|
|
@@ -218,7 +218,7 @@ export const quote = (
|
|
|
218
218
|
*
|
|
219
219
|
* @stability unstable
|
|
220
220
|
* @category encoding
|
|
221
|
-
* @since 4.0
|
|
221
|
+
* @since 4.1.0
|
|
222
222
|
*/
|
|
223
223
|
export const join = (
|
|
224
224
|
words: ReadonlyArray<Word>,
|
|
@@ -291,7 +291,7 @@ export const join = (
|
|
|
291
291
|
*
|
|
292
292
|
* @stability unstable
|
|
293
293
|
* @category encoding
|
|
294
|
-
* @since 4.0
|
|
294
|
+
* @since 4.1.0
|
|
295
295
|
*/
|
|
296
296
|
export const display = (words: ReadonlyArray<Word>, options?: { readonly format?: Format | undefined }): string => {
|
|
297
297
|
if (words.length === 0) return ""
|
|
@@ -362,7 +362,7 @@ export const display = (words: ReadonlyArray<Word>, options?: { readonly format?
|
|
|
362
362
|
*
|
|
363
363
|
* @stability unstable
|
|
364
364
|
* @category constructors
|
|
365
|
-
* @since 4.0
|
|
365
|
+
* @since 4.1.0
|
|
366
366
|
*/
|
|
367
367
|
export const template = (
|
|
368
368
|
strings: TemplateStringsArray,
|
package/src/process/index.ts
CHANGED
package/src/reactivity/Atom.ts
CHANGED
|
@@ -267,7 +267,7 @@ const AtomProto = {
|
|
|
267
267
|
_id: "Atom",
|
|
268
268
|
keepAlive: this.keepAlive,
|
|
269
269
|
lazy: this.lazy,
|
|
270
|
-
label: this.label
|
|
270
|
+
label: this.label && [this.label[0], this.label[1]]
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
} as const
|
|
@@ -1953,9 +1953,31 @@ export const withLabel: {
|
|
|
1953
1953
|
>(2, (self, name) =>
|
|
1954
1954
|
Object.assign(Object.create(Object.getPrototypeOf(self)), {
|
|
1955
1955
|
...self,
|
|
1956
|
-
label:
|
|
1956
|
+
label: makeLabel(name, getStackTraceLimit() === 0 ? undefined : new Error())
|
|
1957
1957
|
}))
|
|
1958
1958
|
|
|
1959
|
+
// Formatting `error.stack` is slow on some engines (e.g. Hermes), so defer it
|
|
1960
|
+
// until the location is read.
|
|
1961
|
+
function makeLabel(name: string, error: Error | undefined): readonly [name: string, stack: string] {
|
|
1962
|
+
const label: [name: string, stack: string] = [name, ""]
|
|
1963
|
+
if (error === undefined) {
|
|
1964
|
+
return label
|
|
1965
|
+
}
|
|
1966
|
+
let location = ""
|
|
1967
|
+
Object.defineProperty(label, 1, {
|
|
1968
|
+
configurable: true,
|
|
1969
|
+
enumerable: true,
|
|
1970
|
+
get: () => {
|
|
1971
|
+
if (error !== undefined) {
|
|
1972
|
+
location = error.stack?.split("\n")[5] ?? ""
|
|
1973
|
+
error = undefined
|
|
1974
|
+
}
|
|
1975
|
+
return location
|
|
1976
|
+
}
|
|
1977
|
+
})
|
|
1978
|
+
return label
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1959
1981
|
/**
|
|
1960
1982
|
* Options for seeding an effect or stream atom through registry initial values
|
|
1961
1983
|
* or hydration.
|
|
@@ -3263,7 +3285,7 @@ export const serializable: {
|
|
|
3263
3285
|
const codecJson = Schema.toCodecJson(options.schema)
|
|
3264
3286
|
return Object.assign(Object.create(Object.getPrototypeOf(self)), {
|
|
3265
3287
|
...self,
|
|
3266
|
-
label: self.label ??
|
|
3288
|
+
label: self.label ?? makeLabel(options.key, getStackTraceLimit() === 0 ? undefined : new Error()),
|
|
3267
3289
|
[SerializableTypeId]: {
|
|
3268
3290
|
key: options.key,
|
|
3269
3291
|
encode: Schema.encodeSync(codecJson),
|