effect 4.0.6 → 4.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Arbitrary.d.ts +10 -2
- package/dist/Arbitrary.d.ts.map +1 -1
- package/dist/Arbitrary.js +2 -1
- package/dist/Arbitrary.js.map +1 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +21 -6
- package/dist/Channel.js.map +1 -1
- package/dist/Data.d.ts +54 -235
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js.map +1 -1
- package/dist/Effect.d.ts +1 -1
- package/dist/Effect.js +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +8 -1
- package/dist/Equal.js.map +1 -1
- package/dist/Exit.d.ts +3 -3
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js.map +1 -1
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +27 -13
- package/dist/Formatter.js.map +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +4 -1
- package/dist/Hash.js.map +1 -1
- package/dist/JsonPatch.js +4 -0
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +13 -40
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Metric.d.ts +3 -3
- package/dist/MutableList.d.ts +5 -2
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +7 -5
- package/dist/MutableList.js.map +1 -1
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +7 -0
- package/dist/MutableRef.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +2 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +22 -12
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +77 -27
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +5 -6
- package/dist/PubSub.js.map +1 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +8 -0
- package/dist/Ref.js.map +1 -1
- package/dist/Schedule.js +1 -1
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +24 -8
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +37 -28
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +4 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +14 -17
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +48 -22
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +19 -10
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +23 -13
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +4 -1
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +9 -2
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +54 -35
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +7 -2
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +22 -10
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +3 -0
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +3 -0
- package/dist/String.js.map +1 -1
- package/dist/Tracer.d.ts +11 -1
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +6 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +9 -0
- 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.map +1 -1
- package/dist/ai/McpServer.js +21 -15
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +52 -0
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +38 -0
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +16 -3
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +4 -0
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +24 -0
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +5 -2
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/Toolkit.d.ts.map +1 -1
- package/dist/ai/Toolkit.js +8 -1
- package/dist/ai/Toolkit.js.map +1 -1
- package/dist/cli/Argument.d.ts +15 -0
- package/dist/cli/Argument.d.ts.map +1 -1
- package/dist/cli/Argument.js +5 -0
- package/dist/cli/Argument.js.map +1 -1
- package/dist/cli/CliError.d.ts +78 -0
- package/dist/cli/CliError.d.ts.map +1 -1
- package/dist/cli/CliError.js +65 -3
- package/dist/cli/CliError.js.map +1 -1
- package/dist/cli/CliOutput.d.ts +155 -6
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +62 -6
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts +24 -16
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +59 -29
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Completions.d.ts +58 -0
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js +49 -9
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/Flag.d.ts +15 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +5 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/cli/GlobalFlag.js +15 -7
- package/dist/cli/GlobalFlag.js.map +1 -1
- package/dist/cli/Param.d.ts +9 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +21 -2
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/TerminalCapabilities.d.ts +3 -2
- package/dist/cli/TerminalCapabilities.d.ts.map +1 -1
- package/dist/cli/TerminalCapabilities.js +3 -1
- package/dist/cli/TerminalCapabilities.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +73 -27
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +45 -10
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +23 -45
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +6 -7
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +61 -21
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +10 -0
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/Snowflake.d.ts.map +1 -1
- package/dist/cluster/Snowflake.js +3 -7
- package/dist/cluster/Snowflake.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +87 -39
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +54 -20
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/devtools/DevToolsClient.js +2 -0
- package/dist/devtools/DevToolsClient.js.map +1 -1
- package/dist/encoding/Base64.js +36 -0
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +3 -3
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/encoding/Toml.d.ts.map +1 -1
- package/dist/encoding/Toml.js +21 -16
- package/dist/encoding/Toml.js.map +1 -1
- package/dist/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/eventlog/SqlEventJournal.js +47 -27
- package/dist/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/eventlog/internal/conflicts.d.ts +0 -1
- package/dist/eventlog/internal/conflicts.d.ts.map +1 -1
- package/dist/eventlog/internal/conflicts.js +0 -3
- package/dist/eventlog/internal/conflicts.js.map +1 -1
- package/dist/http/Cookies.d.ts.map +1 -1
- package/dist/http/Cookies.js +10 -9
- package/dist/http/Cookies.js.map +1 -1
- package/dist/http/HttpClient.d.ts +423 -0
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +231 -7
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts +8 -1
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +37 -1
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +1 -1
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts +1 -1
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +14 -16
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +2 -1
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerError.js +2 -2
- package/dist/http/HttpServerError.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts +6 -1
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +73 -10
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/http/HttpStaticServer.js +48 -21
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.js +3 -3
- package/dist/http/UrlParams.d.ts +3 -1
- package/dist/http/UrlParams.d.ts.map +1 -1
- package/dist/http/UrlParams.js +4 -2
- package/dist/http/UrlParams.js.map +1 -1
- package/dist/http/internal/compression.js +4 -5
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/decompression.js +3 -0
- package/dist/http/internal/decompression.js.map +1 -1
- package/dist/http/internal/httpBody.js +8 -1
- package/dist/http/internal/httpBody.js.map +1 -1
- package/dist/http/internal/urlParams.js +25 -0
- package/dist/http/internal/urlParams.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +3 -6
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +3 -6
- 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 +27 -11
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +77 -7
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +142 -44
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts +24 -7
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +109 -27
- package/dist/http-api/HttpApiEndpoint.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +76 -29
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +70 -59
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/http-api/HttpApiTest.d.ts.map +1 -1
- package/dist/http-api/HttpApiTest.js +3 -2
- package/dist/http-api/HttpApiTest.js.map +1 -1
- package/dist/http-api/OpenApi.d.ts.map +1 -1
- package/dist/http-api/OpenApi.js +25 -16
- package/dist/http-api/OpenApi.js.map +1 -1
- package/dist/http-api/internal/toCodecHttpProperties.d.ts +2 -0
- package/dist/http-api/internal/toCodecHttpProperties.d.ts.map +1 -0
- package/dist/http-api/internal/toCodecHttpProperties.js +38 -0
- package/dist/http-api/internal/toCodecHttpProperties.js.map +1 -0
- package/dist/internal/arbitrary/runner.d.ts.map +1 -1
- package/dist/internal/arbitrary/runner.js +120 -44
- package/dist/internal/arbitrary/runner.js.map +1 -1
- package/dist/internal/core.js +2 -0
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/effect.js +21 -13
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js +14 -0
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/jsonSchema.d.ts +2 -0
- package/dist/internal/jsonSchema.d.ts.map +1 -0
- package/dist/internal/jsonSchema.js +28 -0
- package/dist/internal/jsonSchema.js.map +1 -0
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/schema/compilerRegistry.js +4 -1
- package/dist/internal/schema/compilerRegistry.js.map +1 -1
- package/dist/internal/schema/content.d.ts +2 -0
- package/dist/internal/schema/content.d.ts.map +1 -0
- package/dist/internal/schema/content.js +13 -0
- package/dist/internal/schema/content.js.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +173 -185
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +2 -1
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- package/dist/internal/schema/standardSchema.js +8 -2
- package/dist/internal/schema/standardSchema.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +3 -3
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.js +21 -24
- package/dist/internal/schema/toCodec.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +205 -140
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +107 -129
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/internal/sql.d.ts +2 -0
- package/dist/internal/sql.d.ts.map +1 -0
- package/dist/internal/sql.js +13 -0
- package/dist/internal/sql.js.map +1 -0
- package/dist/internal/version.js +1 -1
- package/dist/observability/OtlpProxy.d.ts +154 -0
- package/dist/observability/OtlpProxy.d.ts.map +1 -0
- package/dist/observability/OtlpProxy.js +235 -0
- package/dist/observability/OtlpProxy.js.map +1 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +4 -0
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/observability/index.d.ts +5 -0
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +5 -0
- package/dist/observability/index.js.map +1 -1
- package/dist/persistence/CircuitBreaker.d.ts +897 -0
- package/dist/persistence/CircuitBreaker.d.ts.map +1 -0
- package/dist/persistence/CircuitBreaker.js +1165 -0
- package/dist/persistence/CircuitBreaker.js.map +1 -0
- package/dist/persistence/Redis.d.ts +78 -2
- package/dist/persistence/Redis.d.ts.map +1 -1
- package/dist/persistence/Redis.js +62 -7
- package/dist/persistence/Redis.js.map +1 -1
- package/dist/persistence/index.d.ts +5 -0
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +5 -0
- package/dist/persistence/index.js.map +1 -1
- package/dist/process/ChildProcess.d.ts +30 -4
- package/dist/process/ChildProcess.d.ts.map +1 -1
- package/dist/process/ChildProcess.js.map +1 -1
- package/dist/process/ChildProcessSpawner.d.ts +30 -0
- package/dist/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/process/ChildProcessSpawner.js +5 -2
- package/dist/process/ChildProcessSpawner.js.map +1 -1
- package/dist/reactivity/AsyncResult.d.ts +1 -1
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +9 -8
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts +14 -0
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +20 -8
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +11 -1
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/rpc/RpcTest.d.ts +1 -0
- package/dist/rpc/RpcTest.d.ts.map +1 -1
- package/dist/rpc/RpcTest.js +1 -0
- package/dist/rpc/RpcTest.js.map +1 -1
- package/dist/sql/Migrator.d.ts +2 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +11 -8
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +9 -4
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +8 -1
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/SqlResolver.d.ts +4 -0
- package/dist/sql/SqlResolver.d.ts.map +1 -1
- package/dist/sql/SqlResolver.js +18 -4
- package/dist/sql/SqlResolver.js.map +1 -1
- package/dist/sql/Statement.d.ts +7 -0
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +21 -2
- package/dist/sql/Statement.js.map +1 -1
- package/dist/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/workflow/DurableDeferred.js +21 -2
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +10 -2
- package/src/Channel.ts +47 -18
- package/src/Data.ts +60 -265
- package/src/Effect.ts +1 -1
- package/src/Equal.ts +8 -1
- package/src/Exit.ts +3 -3
- package/src/Formatter.ts +28 -13
- package/src/Hash.ts +4 -1
- package/src/JsonPatch.ts +4 -0
- package/src/JsonSchema.ts +12 -40
- package/src/Metric.ts +3 -3
- package/src/MutableList.ts +7 -5
- package/src/MutableRef.ts +8 -1
- package/src/PartitionedSemaphore.ts +24 -13
- package/src/Pool.ts +109 -37
- package/src/PubSub.ts +5 -6
- package/src/Ref.ts +8 -0
- package/src/Schedule.ts +1 -1
- package/src/Schema.ts +48 -25
- package/src/SchemaAST.ts +20 -20
- package/src/SchemaParser.ts +51 -18
- package/src/SchemaRepresentation.ts +31 -34
- package/src/SchemaTransformation.ts +9 -2
- package/src/Semaphore.ts +67 -40
- package/src/Sink.ts +15 -2
- package/src/Stream.ts +33 -16
- package/src/String.ts +3 -0
- package/src/Tracer.ts +15 -1
- package/src/ai/LanguageModel.ts +9 -0
- package/src/ai/McpServer.ts +14 -13
- package/src/ai/Prompt.ts +65 -0
- package/src/ai/Response.ts +34 -9
- package/src/ai/Tool.ts +38 -2
- package/src/ai/Toolkit.ts +4 -1
- package/src/cli/Argument.ts +15 -0
- package/src/cli/CliError.ts +90 -3
- package/src/cli/CliOutput.ts +183 -6
- package/src/cli/Command.ts +53 -41
- package/src/cli/Completions.ts +51 -0
- package/src/cli/Flag.ts +15 -0
- package/src/cli/GlobalFlag.ts +6 -7
- package/src/cli/Param.ts +29 -6
- package/src/cli/TerminalCapabilities.ts +6 -3
- package/src/cli/internal/completions/bash.ts +79 -29
- package/src/cluster/ClusterWorkflowEngine.ts +46 -16
- package/src/cluster/MessageStorage.ts +19 -14
- package/src/cluster/Sharding.ts +83 -21
- package/src/cluster/ShardingConfig.ts +5 -0
- package/src/cluster/Snowflake.ts +3 -7
- package/src/cluster/SqlRunnerStorage.ts +110 -47
- package/src/cluster/internal/entityManager.ts +75 -22
- package/src/devtools/DevToolsClient.ts +2 -0
- package/src/encoding/Base64.ts +38 -0
- package/src/encoding/Sse.ts +4 -3
- package/src/encoding/Toml.ts +33 -16
- package/src/eventlog/SqlEventJournal.ts +68 -45
- package/src/eventlog/internal/conflicts.ts +0 -4
- package/src/http/Cookies.ts +10 -11
- package/src/http/HttpClient.ts +547 -7
- package/src/http/HttpClientError.ts +35 -1
- package/src/http/HttpClientRequest.ts +9 -1
- package/src/http/HttpMiddleware.ts +15 -18
- package/src/http/HttpRouter.ts +2 -1
- package/src/http/HttpServerError.ts +2 -2
- package/src/http/HttpServerRequest.ts +102 -16
- package/src/http/HttpStaticServer.ts +51 -22
- package/src/http/MultipartParser/internal/contentType.ts +3 -3
- package/src/http/UrlParams.ts +6 -1
- package/src/http/internal/compression.ts +4 -5
- package/src/http/internal/decompression.ts +6 -0
- package/src/http/internal/httpBody.ts +10 -2
- package/src/http/internal/urlParams.ts +29 -0
- package/src/http-api/HttpApi.ts +3 -6
- package/src/http-api/HttpApiBuilder.ts +45 -15
- package/src/http-api/HttpApiClient.ts +218 -72
- package/src/http-api/HttpApiEndpoint.ts +121 -30
- package/src/http-api/HttpApiSchema.ts +141 -48
- package/src/http-api/HttpApiTest.ts +3 -2
- package/src/http-api/OpenApi.ts +20 -17
- package/src/http-api/internal/toCodecHttpProperties.ts +56 -0
- package/src/internal/arbitrary/runner.ts +133 -36
- package/src/internal/core.ts +2 -0
- package/src/internal/effect.ts +24 -16
- package/src/internal/equal.ts +17 -0
- package/src/internal/jsonSchema.ts +27 -0
- package/src/internal/matcher.ts +1 -1
- package/src/internal/schema/compilerRegistry.ts +6 -1
- package/src/internal/schema/content.ts +18 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +228 -190
- package/src/internal/schema/fromRepresentation.ts +2 -1
- package/src/internal/schema/standardSchema.ts +2 -2
- package/src/internal/schema/toCodeDocument.ts +4 -4
- package/src/internal/schema/toCodec.ts +26 -22
- package/src/internal/schema/toJsonSchemaDocument.ts +189 -167
- package/src/internal/schema/toRepresentation.ts +122 -140
- package/src/internal/sql.ts +14 -0
- package/src/internal/version.ts +1 -1
- package/src/observability/OtlpProxy.ts +314 -0
- package/src/observability/OtlpTracer.ts +4 -0
- package/src/observability/index.ts +6 -0
- package/src/persistence/CircuitBreaker.ts +1678 -0
- package/src/persistence/Redis.ts +129 -8
- package/src/persistence/index.ts +6 -0
- package/src/process/ChildProcess.ts +30 -4
- package/src/process/ChildProcessSpawner.ts +41 -2
- package/src/reactivity/AsyncResult.ts +1 -1
- package/src/rpc/RpcClient.ts +13 -10
- package/src/rpc/RpcSerialization.ts +32 -9
- package/src/rpc/RpcServer.ts +16 -1
- package/src/rpc/RpcTest.ts +3 -0
- package/src/sql/Migrator.ts +12 -7
- package/src/sql/SqlClient.ts +11 -4
- package/src/sql/SqlResolver.ts +23 -9
- package/src/sql/Statement.ts +30 -2
- package/src/workflow/DurableDeferred.ts +23 -6
package/src/ai/McpServer.ts
CHANGED
|
@@ -770,11 +770,19 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
770
770
|
clientStates.delete(clientId)
|
|
771
771
|
runtime.disconnect(clientId)
|
|
772
772
|
}
|
|
773
|
-
|
|
773
|
+
// The exit is sent already encoded, so it must carry only the JSON-RPC error members.
|
|
774
|
+
const sendRequestError = (
|
|
775
|
+
clientId: number,
|
|
776
|
+
requestId: string | number,
|
|
777
|
+
{ code, data, message }: { readonly code: number; readonly message: string; readonly data?: unknown }
|
|
778
|
+
) =>
|
|
774
779
|
protocol.send(clientId, {
|
|
775
780
|
_tag: "Exit",
|
|
776
781
|
requestId,
|
|
777
|
-
exit: {
|
|
782
|
+
exit: {
|
|
783
|
+
_tag: "Failure",
|
|
784
|
+
cause: [{ _tag: "Fail", error: data === undefined ? { code, message } : { code, message, data } }]
|
|
785
|
+
}
|
|
778
786
|
})
|
|
779
787
|
const removeReverseRequestClient = (requestId: string, key: McpClientKey) => {
|
|
780
788
|
const waiting = reverseRequestClients.get(requestId)
|
|
@@ -1000,16 +1008,9 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
1000
1008
|
response.exit._tag === "Failure" &&
|
|
1001
1009
|
!response.exit.cause.some((failure) => failure._tag === "Fail")
|
|
1002
1010
|
) {
|
|
1003
|
-
return
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
exit: {
|
|
1007
|
-
_tag: "Failure",
|
|
1008
|
-
cause: [{
|
|
1009
|
-
_tag: "Fail",
|
|
1010
|
-
error: new InternalError({ message: "Internal error" })
|
|
1011
|
-
}]
|
|
1012
|
-
}
|
|
1011
|
+
return sendRequestError(clientId, response.requestId, {
|
|
1012
|
+
code: McpSchema.INTERNAL_ERROR_CODE,
|
|
1013
|
+
message: "Internal error"
|
|
1013
1014
|
})
|
|
1014
1015
|
}
|
|
1015
1016
|
}
|
|
@@ -1900,7 +1901,7 @@ const normalizeMcpJsonRpcResponse = (response: unknown): unknown => {
|
|
|
1900
1901
|
function mcpJsonRpcSerialization(options?: {
|
|
1901
1902
|
readonly contentType?: string | undefined
|
|
1902
1903
|
}): RpcSerialization.RpcSerialization["Service"] {
|
|
1903
|
-
const serialization = RpcSerialization.jsonRpc(options)
|
|
1904
|
+
const serialization = RpcSerialization.jsonRpc({ ...options, controlMessages: false })
|
|
1904
1905
|
return RpcSerialization.RpcSerialization.of({
|
|
1905
1906
|
...serialization,
|
|
1906
1907
|
makeUnsafe: () => {
|
package/src/ai/Prompt.ts
CHANGED
|
@@ -689,6 +689,60 @@ export const toolCallPart = (params: PartConstructorParams<ToolCallPart>): ToolC
|
|
|
689
689
|
// Tool Result Part
|
|
690
690
|
// =============================================================================
|
|
691
691
|
|
|
692
|
+
/**
|
|
693
|
+
* A part returned by a tool's `toModelOutput` mapping and sent to the model in
|
|
694
|
+
* place of the serialized tool result.
|
|
695
|
+
*
|
|
696
|
+
* @stability unstable
|
|
697
|
+
* @category models
|
|
698
|
+
* @since 4.0.0
|
|
699
|
+
*/
|
|
700
|
+
export type ToolModelOutputPart = TextPart | FilePart
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Schema for validation and encoding of tool model output parts.
|
|
704
|
+
*
|
|
705
|
+
* @stability unstable
|
|
706
|
+
* @category schemas
|
|
707
|
+
* @since 4.0.0
|
|
708
|
+
*/
|
|
709
|
+
export const ToolModelOutputPart: Schema.Union<readonly [typeof TextPart, typeof FilePart]> = Schema.Union([
|
|
710
|
+
TextPart,
|
|
711
|
+
FilePart
|
|
712
|
+
])
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Converts tool model output to text for providers that only accept text tool
|
|
716
|
+
* results.
|
|
717
|
+
*
|
|
718
|
+
* **Details**
|
|
719
|
+
*
|
|
720
|
+
* Joins text parts with newlines and replaces each file part with a placeholder
|
|
721
|
+
* naming its media type and file name.
|
|
722
|
+
*
|
|
723
|
+
* **Example** (Converting tool model output to text)
|
|
724
|
+
*
|
|
725
|
+
* ```ts import.meta.vitest
|
|
726
|
+
* import { Prompt } from "effect/ai"
|
|
727
|
+
*
|
|
728
|
+
* const text = Prompt.toolModelOutputToText([
|
|
729
|
+
* Prompt.textPart({ text: "Screenshot" }),
|
|
730
|
+
* Prompt.filePart({ mediaType: "image/png", fileName: "screenshot.png", data: "iVBORw0KGgo=" })
|
|
731
|
+
* ])
|
|
732
|
+
* text // => "Screenshot\n[image/png screenshot.png omitted]"
|
|
733
|
+
* ```
|
|
734
|
+
*
|
|
735
|
+
* @stability unstable
|
|
736
|
+
* @category combinators
|
|
737
|
+
* @since 4.0.0
|
|
738
|
+
*/
|
|
739
|
+
export const toolModelOutputToText = (parts: ReadonlyArray<ToolModelOutputPart>): string =>
|
|
740
|
+
parts.map((part) =>
|
|
741
|
+
part.type === "text"
|
|
742
|
+
? part.text
|
|
743
|
+
: `[${part.mediaType}${part.fileName === undefined ? "" : ` ${part.fileName}`} omitted]`
|
|
744
|
+
).join("\n")
|
|
745
|
+
|
|
692
746
|
/**
|
|
693
747
|
* Content part representing the result of a tool call.
|
|
694
748
|
*
|
|
@@ -732,6 +786,10 @@ export interface ToolResultPart extends BasePart<"tool-result", ToolResultPartOp
|
|
|
732
786
|
* The result returned by the tool execution.
|
|
733
787
|
*/
|
|
734
788
|
readonly result: unknown
|
|
789
|
+
/**
|
|
790
|
+
* Content sent to the model in place of the serialized `result`.
|
|
791
|
+
*/
|
|
792
|
+
readonly modelOutput?: ReadonlyArray<ToolModelOutputPart> | undefined
|
|
735
793
|
/**
|
|
736
794
|
* Whether the tool was executed by the provider (true) or framework (false).
|
|
737
795
|
*/
|
|
@@ -762,6 +820,10 @@ export interface ToolResultPartEncoded extends BasePartEncoded<"tool-result", To
|
|
|
762
820
|
* The result returned by the tool execution.
|
|
763
821
|
*/
|
|
764
822
|
readonly result: unknown
|
|
823
|
+
/**
|
|
824
|
+
* Content sent to the model in place of the serialized `result`.
|
|
825
|
+
*/
|
|
826
|
+
readonly modelOutput?: ReadonlyArray<TextPartEncoded | FilePartEncoded> | undefined
|
|
765
827
|
/**
|
|
766
828
|
* Whether the tool was executed by the provider (true) or framework (false).
|
|
767
829
|
*/
|
|
@@ -791,6 +853,7 @@ export const ToolResultPart: Schema.Struct<{
|
|
|
791
853
|
readonly name: Schema.String
|
|
792
854
|
readonly isFailure: Schema.Boolean
|
|
793
855
|
readonly result: Schema.Unknown
|
|
856
|
+
readonly modelOutput: Schema.optional<Schema.$Array<typeof ToolModelOutputPart>>
|
|
794
857
|
readonly providerExecuted: Schema.withDecodingDefault<Schema.Boolean>
|
|
795
858
|
readonly "~effect/ai/Prompt/Part": Schema.withDecodingDefaultKey<Schema.Literal<"~effect/ai/Prompt/Part">>
|
|
796
859
|
readonly options: Schema.withDecodingDefault<
|
|
@@ -806,6 +869,7 @@ export const ToolResultPart: Schema.Struct<{
|
|
|
806
869
|
name: Schema.String,
|
|
807
870
|
isFailure: Schema.Boolean,
|
|
808
871
|
result: Schema.Unknown,
|
|
872
|
+
modelOutput: Schema.optional(Schema.Array(ToolModelOutputPart)),
|
|
809
873
|
providerExecuted: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false)))
|
|
810
874
|
}).annotate({ identifier: "ToolResultPart" })
|
|
811
875
|
|
|
@@ -2272,6 +2336,7 @@ export const fromResponseParts = (parts: ReadonlyArray<Response.AnyPart>): Promp
|
|
|
2272
2336
|
name: part.name,
|
|
2273
2337
|
isFailure: part.isFailure,
|
|
2274
2338
|
result: part.encodedResult,
|
|
2339
|
+
...(part.modelOutput !== undefined ? { modelOutput: part.modelOutput } : undefined),
|
|
2275
2340
|
providerExecuted: part.providerExecuted ?? false,
|
|
2276
2341
|
options: part.metadata
|
|
2277
2342
|
}))
|
package/src/ai/Response.ts
CHANGED
|
@@ -18,6 +18,7 @@ import * as Predicate from "../Predicate.ts"
|
|
|
18
18
|
import * as Schema from "../Schema.ts"
|
|
19
19
|
import * as SchemaTransformation from "../SchemaTransformation.ts"
|
|
20
20
|
import * as AiError from "./AiError.ts"
|
|
21
|
+
import * as Prompt from "./Prompt.ts"
|
|
21
22
|
import * as Tool from "./Tool.ts"
|
|
22
23
|
import type * as Toolkit from "./Toolkit.ts"
|
|
23
24
|
|
|
@@ -172,6 +173,18 @@ const toolPartSchemas = (tool: Tool.Any) => {
|
|
|
172
173
|
|
|
173
174
|
type AnyToolParts = ToolCallPart<string, unknown> | ToolResultPart<string, unknown, unknown>
|
|
174
175
|
|
|
176
|
+
type ToolkitTools<T> = T extends Toolkit.Any ? Toolkit.Tools<T> : Toolkit.WithHandlerTools<T>
|
|
177
|
+
|
|
178
|
+
type ToolkitTool<T> = ToolkitTools<T>[keyof ToolkitTools<T>]
|
|
179
|
+
|
|
180
|
+
type ToolkitDecodingServices<T> =
|
|
181
|
+
| Tool.ParametersDecodingServices<ToolkitTool<T>>
|
|
182
|
+
| Tool.ResultDecodingServices<ToolkitTool<T>>
|
|
183
|
+
|
|
184
|
+
type ToolkitEncodingServices<T> =
|
|
185
|
+
| Tool.ParametersEncodingServices<ToolkitTool<T>>
|
|
186
|
+
| Tool.ResultEncodingServices<ToolkitTool<T>>
|
|
187
|
+
|
|
175
188
|
const toolPartSchemasFor = (
|
|
176
189
|
toolkit: Toolkit.Any | Toolkit.WithHandler<any> | undefined
|
|
177
190
|
): ReadonlyArray<Schema.Top> => {
|
|
@@ -257,10 +270,10 @@ export const AllParts: {
|
|
|
257
270
|
* @since 4.0.0
|
|
258
271
|
*/
|
|
259
272
|
<T extends Toolkit.Any | Toolkit.WithHandler<any>>(toolkit: T): Schema.Codec<
|
|
260
|
-
AllParts<
|
|
273
|
+
AllParts<ToolkitTools<T>>,
|
|
261
274
|
AllPartsEncoded,
|
|
262
|
-
|
|
263
|
-
|
|
275
|
+
ToolkitDecodingServices<T>,
|
|
276
|
+
ToolkitEncodingServices<T>
|
|
264
277
|
>
|
|
265
278
|
/**
|
|
266
279
|
* Creates a Schema for all response parts based on a toolkit.
|
|
@@ -395,10 +408,10 @@ export const Part: {
|
|
|
395
408
|
* @since 4.0.0
|
|
396
409
|
*/
|
|
397
410
|
<T extends Toolkit.Any | Toolkit.WithHandler<any>>(toolkit: T): Schema.Codec<
|
|
398
|
-
Part<
|
|
411
|
+
Part<ToolkitTools<T>>,
|
|
399
412
|
PartEncoded,
|
|
400
|
-
|
|
401
|
-
|
|
413
|
+
ToolkitDecodingServices<T>,
|
|
414
|
+
ToolkitEncodingServices<T>
|
|
402
415
|
>
|
|
403
416
|
/**
|
|
404
417
|
* Creates a Schema for non-streaming response parts based on a toolkit.
|
|
@@ -513,10 +526,10 @@ export const StreamPart: {
|
|
|
513
526
|
* @since 4.0.0
|
|
514
527
|
*/
|
|
515
528
|
<T extends Toolkit.Any | Toolkit.WithHandler<any>>(toolkit: T): Schema.Codec<
|
|
516
|
-
StreamPart<
|
|
529
|
+
StreamPart<ToolkitTools<T>>,
|
|
517
530
|
StreamPartEncoded,
|
|
518
|
-
|
|
519
|
-
|
|
531
|
+
ToolkitDecodingServices<T>,
|
|
532
|
+
ToolkitEncodingServices<T>
|
|
520
533
|
>
|
|
521
534
|
/**
|
|
522
535
|
* Creates a Schema for streaming response parts based on a toolkit.
|
|
@@ -1695,6 +1708,10 @@ export interface BaseToolResult<Name extends string> extends BasePart<"tool-resu
|
|
|
1695
1708
|
* The encoded result for serialization purposes.
|
|
1696
1709
|
*/
|
|
1697
1710
|
readonly encodedResult: unknown
|
|
1711
|
+
/**
|
|
1712
|
+
* Content sent to the model in place of the encoded result.
|
|
1713
|
+
*/
|
|
1714
|
+
readonly modelOutput?: ReadonlyArray<Prompt.ToolModelOutputPart> | undefined
|
|
1698
1715
|
/**
|
|
1699
1716
|
* Whether the tool was executed by the provider (true) or framework (false).
|
|
1700
1717
|
*/
|
|
@@ -1818,6 +1835,10 @@ export interface ToolResultPartEncoded extends BasePartEncoded<"tool-result", To
|
|
|
1818
1835
|
* The result returned by the tool execution.
|
|
1819
1836
|
*/
|
|
1820
1837
|
readonly result: unknown
|
|
1838
|
+
/**
|
|
1839
|
+
* Content sent to the model in place of the result.
|
|
1840
|
+
*/
|
|
1841
|
+
readonly modelOutput?: ReadonlyArray<Prompt.TextPartEncoded | Prompt.FilePartEncoded> | undefined
|
|
1821
1842
|
/**
|
|
1822
1843
|
* Whether or not the result of executing the tool call handler was an error.
|
|
1823
1844
|
*/
|
|
@@ -1871,6 +1892,8 @@ export const ToolResultPart = <
|
|
|
1871
1892
|
identifier: `ToolResultPart(${name})`
|
|
1872
1893
|
}) as any
|
|
1873
1894
|
|
|
1895
|
+
const ModelOutput = Schema.Array(Prompt.ToolModelOutputPart)
|
|
1896
|
+
|
|
1874
1897
|
const makeToolResultPart = (name: Schema.Top, success: Schema.Constraint, failure: Schema.Constraint) => {
|
|
1875
1898
|
const makeSchema = (result: Schema.Constraint, isFailure: boolean) => {
|
|
1876
1899
|
const encodedResult = Schema.toEncoded(result)
|
|
@@ -1887,11 +1910,13 @@ const makeToolResultPart = (name: Schema.Top, success: Schema.Constraint, failur
|
|
|
1887
1910
|
providerExecuted: Schema.Boolean,
|
|
1888
1911
|
metadata: ProviderMetadata,
|
|
1889
1912
|
encodedResult,
|
|
1913
|
+
modelOutput: Schema.optional(ModelOutput),
|
|
1890
1914
|
preliminary: Schema.Boolean
|
|
1891
1915
|
})
|
|
1892
1916
|
const Encoded = Schema.Struct({
|
|
1893
1917
|
...Common,
|
|
1894
1918
|
result: encodedResult,
|
|
1919
|
+
modelOutput: Schema.optional(Schema.toEncoded(ModelOutput)),
|
|
1895
1920
|
providerExecuted: Schema.optional(Schema.Boolean),
|
|
1896
1921
|
metadata: Schema.optional(ProviderMetadata),
|
|
1897
1922
|
preliminary: Schema.optional(Schema.Boolean)
|
package/src/ai/Tool.ts
CHANGED
|
@@ -290,6 +290,12 @@ export interface Tool<
|
|
|
290
290
|
*/
|
|
291
291
|
readonly needsApproval?: boolean | NeedsApprovalFunction<any> | undefined
|
|
292
292
|
|
|
293
|
+
/**
|
|
294
|
+
* Maps a successful tool result to the content sent to the model in place
|
|
295
|
+
* of the encoded result. `setSuccess` removes the mapping.
|
|
296
|
+
*/
|
|
297
|
+
readonly toModelOutput?: ((result: any) => ReadonlyArray<Prompt.ToolModelOutputPart>) | undefined
|
|
298
|
+
|
|
293
299
|
/**
|
|
294
300
|
* Set whether user approval is required before executing this tool.
|
|
295
301
|
*/
|
|
@@ -955,6 +961,20 @@ export type ResultDecodingServices<T> = T extends Tool<
|
|
|
955
961
|
> ? _Config["success"]["DecodingServices"] | _Config["failure"]["DecodingServices"]
|
|
956
962
|
: never
|
|
957
963
|
|
|
964
|
+
/**
|
|
965
|
+
* Extracts the services required to decode tool parameters.
|
|
966
|
+
*
|
|
967
|
+
* @stability unstable
|
|
968
|
+
* @category utility types
|
|
969
|
+
* @since 4.0.0
|
|
970
|
+
*/
|
|
971
|
+
export type ParametersDecodingServices<T> = T extends Tool<
|
|
972
|
+
infer _Name,
|
|
973
|
+
infer _Config,
|
|
974
|
+
infer _Requirements
|
|
975
|
+
> ? _Config["parameters"]["DecodingServices"]
|
|
976
|
+
: never
|
|
977
|
+
|
|
958
978
|
/**
|
|
959
979
|
* Extracts the services required to encode tool parameters.
|
|
960
980
|
*
|
|
@@ -1016,6 +1036,10 @@ export interface HandlerResult<Tool extends Any> {
|
|
|
1016
1036
|
* into subsequent requests to the large language model.
|
|
1017
1037
|
*/
|
|
1018
1038
|
readonly encodedResult: unknown
|
|
1039
|
+
/**
|
|
1040
|
+
* The output of the tool's `toModelOutput` mapping for a successful result.
|
|
1041
|
+
*/
|
|
1042
|
+
readonly modelOutput?: ReadonlyArray<Prompt.ToolModelOutputPart> | undefined
|
|
1019
1043
|
/**
|
|
1020
1044
|
* Whether the result of executing the tool call handler was an error or not.
|
|
1021
1045
|
*/
|
|
@@ -1117,7 +1141,7 @@ const Proto = {
|
|
|
1117
1141
|
return clone(this, { parametersSchema, jsonSchema: undefined })
|
|
1118
1142
|
},
|
|
1119
1143
|
setSuccess(this: Any, successSchema: Schema.Constraint) {
|
|
1120
|
-
return clone(this, { successSchema })
|
|
1144
|
+
return clone(this, { successSchema, toModelOutput: undefined })
|
|
1121
1145
|
},
|
|
1122
1146
|
setFailure(this: Any, failureSchema: Schema.Constraint) {
|
|
1123
1147
|
return clone(this, { failureSchema })
|
|
@@ -1158,6 +1182,7 @@ const userDefinedProto = <
|
|
|
1158
1182
|
readonly annotations: Context.Context<never>
|
|
1159
1183
|
readonly failureMode: Mode
|
|
1160
1184
|
readonly needsApproval?: NeedsApproval<Parameters> | undefined
|
|
1185
|
+
readonly toModelOutput?: ((result: any) => ReadonlyArray<Prompt.ToolModelOutputPart>) | undefined
|
|
1161
1186
|
}): Tool<
|
|
1162
1187
|
Name,
|
|
1163
1188
|
{
|
|
@@ -1220,6 +1245,7 @@ const dynamicProto = <
|
|
|
1220
1245
|
readonly annotations: Context.Context<never>
|
|
1221
1246
|
readonly failureMode: Mode
|
|
1222
1247
|
readonly needsApproval?: NeedsApproval<any> | undefined
|
|
1248
|
+
readonly toModelOutput?: ((result: any) => ReadonlyArray<Prompt.ToolModelOutputPart>) | undefined
|
|
1223
1249
|
readonly jsonSchema: JsonSchema.JsonSchema | undefined
|
|
1224
1250
|
}): Dynamic<
|
|
1225
1251
|
Name,
|
|
@@ -1319,6 +1345,12 @@ export const make = <
|
|
|
1319
1345
|
* dynamically determine if approval is needed.
|
|
1320
1346
|
*/
|
|
1321
1347
|
readonly needsApproval?: NeedsApproval<Parameters> | undefined
|
|
1348
|
+
/**
|
|
1349
|
+
* Maps a successful tool result to the content sent to the model in place
|
|
1350
|
+
* of the encoded result, such as images or files. The application still
|
|
1351
|
+
* receives the typed result.
|
|
1352
|
+
*/
|
|
1353
|
+
readonly toModelOutput?: ((result: Success["Type"]) => ReadonlyArray<Prompt.ToolModelOutputPart>) | undefined
|
|
1322
1354
|
}): Tool<
|
|
1323
1355
|
Name,
|
|
1324
1356
|
{
|
|
@@ -1339,7 +1371,8 @@ export const make = <
|
|
|
1339
1371
|
failureSchema,
|
|
1340
1372
|
failureMode: options?.failureMode ?? "error",
|
|
1341
1373
|
annotations: Context.empty(),
|
|
1342
|
-
needsApproval: options?.needsApproval as any
|
|
1374
|
+
needsApproval: options?.needsApproval as any,
|
|
1375
|
+
toModelOutput: options?.toModelOutput
|
|
1343
1376
|
}) as any
|
|
1344
1377
|
}
|
|
1345
1378
|
|
|
@@ -1447,6 +1480,7 @@ export const dynamic: {
|
|
|
1447
1480
|
readonly failure?: Schema.Constraint | undefined
|
|
1448
1481
|
readonly failureMode?: FailureMode | undefined
|
|
1449
1482
|
readonly needsApproval?: NeedsApproval<any> | undefined
|
|
1483
|
+
readonly toModelOutput?: ((result: any) => ReadonlyArray<Prompt.ToolModelOutputPart>) | undefined
|
|
1450
1484
|
}
|
|
1451
1485
|
>(name: Name, options?: Options): Dynamic<
|
|
1452
1486
|
Name,
|
|
@@ -1471,6 +1505,7 @@ export const dynamic: {
|
|
|
1471
1505
|
readonly failure?: Schema.Constraint | undefined
|
|
1472
1506
|
readonly failureMode?: FailureMode | undefined
|
|
1473
1507
|
readonly needsApproval?: NeedsApproval<any> | undefined
|
|
1508
|
+
readonly toModelOutput?: ((result: any) => ReadonlyArray<Prompt.ToolModelOutputPart>) | undefined
|
|
1474
1509
|
}
|
|
1475
1510
|
>(name: Name, options?: Options): any => {
|
|
1476
1511
|
const successSchema = options?.success ?? Schema.Unknown
|
|
@@ -1488,6 +1523,7 @@ export const dynamic: {
|
|
|
1488
1523
|
failureMode: options?.failureMode ?? "error",
|
|
1489
1524
|
annotations: Context.empty(),
|
|
1490
1525
|
needsApproval: options?.needsApproval,
|
|
1526
|
+
toModelOutput: options?.toModelOutput,
|
|
1491
1527
|
jsonSchema
|
|
1492
1528
|
})
|
|
1493
1529
|
}
|
package/src/ai/Toolkit.ts
CHANGED
|
@@ -525,7 +525,10 @@ const Proto = {
|
|
|
525
525
|
),
|
|
526
526
|
Stream.mapEffect(Effect.fnUntraced(function*(output) {
|
|
527
527
|
const encodedResult = yield* encodeResult(output.result, output.isFailure)
|
|
528
|
-
|
|
528
|
+
if (output.isFailure || output.preliminary || tool.toModelOutput === undefined) {
|
|
529
|
+
return { ...output, encodedResult }
|
|
530
|
+
}
|
|
531
|
+
return { ...output, encodedResult, modelOutput: tool.toModelOutput(output.result) }
|
|
529
532
|
})),
|
|
530
533
|
Stream.ensuring(Fiber.interrupt(fiber))
|
|
531
534
|
) satisfies Stream.Stream<Tool.HandlerResult<any>, any>
|
package/src/cli/Argument.ts
CHANGED
|
@@ -509,6 +509,11 @@ export const withFallbackConfig: {
|
|
|
509
509
|
/**
|
|
510
510
|
* Adds a fallback prompt that is shown when a required argument is missing.
|
|
511
511
|
*
|
|
512
|
+
* **Gotchas**
|
|
513
|
+
*
|
|
514
|
+
* When `TerminalCapabilities.canPrompt` is `false`, the prompt is skipped and
|
|
515
|
+
* the original `MissingArgument` error is returned.
|
|
516
|
+
*
|
|
512
517
|
* **Example** (Showing a fallback prompt)
|
|
513
518
|
*
|
|
514
519
|
* ```ts import.meta.vitest
|
|
@@ -528,6 +533,11 @@ export const withFallbackPrompt: {
|
|
|
528
533
|
/**
|
|
529
534
|
* Adds a fallback prompt that is shown when a required argument is missing.
|
|
530
535
|
*
|
|
536
|
+
* **Gotchas**
|
|
537
|
+
*
|
|
538
|
+
* When `TerminalCapabilities.canPrompt` is `false`, the prompt is skipped and
|
|
539
|
+
* the original `MissingArgument` error is returned.
|
|
540
|
+
*
|
|
531
541
|
* **Example** (Showing a fallback prompt)
|
|
532
542
|
*
|
|
533
543
|
* ```ts import.meta.vitest
|
|
@@ -547,6 +557,11 @@ export const withFallbackPrompt: {
|
|
|
547
557
|
/**
|
|
548
558
|
* Adds a fallback prompt that is shown when a required argument is missing.
|
|
549
559
|
*
|
|
560
|
+
* **Gotchas**
|
|
561
|
+
*
|
|
562
|
+
* When `TerminalCapabilities.canPrompt` is `false`, the prompt is skipped and
|
|
563
|
+
* the original `MissingArgument` error is returned.
|
|
564
|
+
*
|
|
550
565
|
* **Example** (Showing a fallback prompt)
|
|
551
566
|
*
|
|
552
567
|
* ```ts import.meta.vitest
|
package/src/cli/CliError.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* flags or arguments, unexpected positional arguments, invalid values, unknown
|
|
6
6
|
* subcommands, rejected input combinations, user handler failures, and
|
|
7
7
|
* requests to show command help. This module includes the `CliError` union,
|
|
8
|
-
* the `isCliError` guard,
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* the `isCliError` guard, the `userMessage` annotation for rendering handler
|
|
9
|
+
* failures, schema-backed error classes with display messages, and the
|
|
10
|
+
* `NonShowHelpErrors` union used when parse or validation errors should be
|
|
11
|
+
* shown with help output.
|
|
11
12
|
*
|
|
12
13
|
* @stability unstable
|
|
13
14
|
* @since 4.0.0
|
|
@@ -46,6 +47,82 @@ const TypeId = "~effect/cli/CliError"
|
|
|
46
47
|
*/
|
|
47
48
|
export const isCliError = (u: unknown): u is CliError => Predicate.hasProperty(u, TypeId)
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Defines the string property key used to give an object error a user-facing
|
|
52
|
+
* message.
|
|
53
|
+
*
|
|
54
|
+
* **When to use**
|
|
55
|
+
*
|
|
56
|
+
* Use to type the property key that marks handler failures for rendering by
|
|
57
|
+
* `Command.run`.
|
|
58
|
+
*
|
|
59
|
+
* @stability unstable
|
|
60
|
+
* @category annotations
|
|
61
|
+
* @since 4.0.0
|
|
62
|
+
*/
|
|
63
|
+
export type userMessage = "~effect/cli/CliError/userMessage"
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Defines the runtime property key used to give an object error a user-facing
|
|
67
|
+
* message.
|
|
68
|
+
*
|
|
69
|
+
* **When to use**
|
|
70
|
+
*
|
|
71
|
+
* Use when a handler fails with a domain error that should be shown to the
|
|
72
|
+
* user without wrapping it in {@link UserError}.
|
|
73
|
+
*
|
|
74
|
+
* **Details**
|
|
75
|
+
*
|
|
76
|
+
* When a handler failure has a string `[CliError.userMessage]`, `Command.run`
|
|
77
|
+
* renders it with the installed formatter, sets `Runtime.errorReported` to
|
|
78
|
+
* `false`, and rethrows the original error, so its tag is preserved. The
|
|
79
|
+
* global `Error` interface declares this key as an optional string.
|
|
80
|
+
*
|
|
81
|
+
* **Example** (Rendering a tagged handler failure)
|
|
82
|
+
*
|
|
83
|
+
* ```ts import.meta.vitest
|
|
84
|
+
* import { Schema } from "effect"
|
|
85
|
+
* import { CliError } from "effect/cli"
|
|
86
|
+
*
|
|
87
|
+
* class Occupied extends Schema.TaggedError<Occupied>()("Occupied", {
|
|
88
|
+
* path: Schema.String
|
|
89
|
+
* }) {
|
|
90
|
+
* override get [CliError.userMessage]() {
|
|
91
|
+
* return `${this.path} already exists`
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
*
|
|
95
|
+
* const error = new Occupied({ path: "config.yaml" })
|
|
96
|
+
* CliError.getUserMessage(error) // => "config.yaml already exists"
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @see {@link getUserMessage} for reading the message stored under this key
|
|
100
|
+
*
|
|
101
|
+
* @stability unstable
|
|
102
|
+
* @category annotations
|
|
103
|
+
* @since 4.0.0
|
|
104
|
+
*/
|
|
105
|
+
export const userMessage: userMessage = "~effect/cli/CliError/userMessage"
|
|
106
|
+
|
|
107
|
+
declare global {
|
|
108
|
+
interface Error {
|
|
109
|
+
readonly [userMessage]?: string
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Reads the `CliError.userMessage` annotation from an error object, returning
|
|
115
|
+
* `undefined` when it is unset or not a string.
|
|
116
|
+
*
|
|
117
|
+
* @see {@link userMessage} for the annotation key this getter reads
|
|
118
|
+
*
|
|
119
|
+
* @stability unstable
|
|
120
|
+
* @category annotations
|
|
121
|
+
* @since 4.0.0
|
|
122
|
+
*/
|
|
123
|
+
export const getUserMessage = (error: object): string | undefined =>
|
|
124
|
+
userMessage in error && typeof error[userMessage] === "string" ? error[userMessage] : undefined
|
|
125
|
+
|
|
49
126
|
/**
|
|
50
127
|
* Union type representing all possible CLI error conditions.
|
|
51
128
|
*
|
|
@@ -624,6 +701,16 @@ export class UserError extends Schema.TaggedError<UserError>(
|
|
|
624
701
|
if (this.cause instanceof Error && this.cause.message) return this.cause.message
|
|
625
702
|
return "An error occurred"
|
|
626
703
|
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Exposes `message` as the user-facing message rendered by `Command.run`.
|
|
707
|
+
*
|
|
708
|
+
* @stability unstable
|
|
709
|
+
* @since 4.0.0
|
|
710
|
+
*/
|
|
711
|
+
override get [userMessage]() {
|
|
712
|
+
return this.message
|
|
713
|
+
}
|
|
627
714
|
}
|
|
628
715
|
|
|
629
716
|
/**
|