effect 4.0.3 → 4.0.5
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/AGENTS.md +24 -0
- package/CLAUDE.md +24 -0
- package/ai-docs/package.json +2 -2
- package/ai-docs/src/52_graphql/10_basics.ts +117 -0
- package/ai-docs/src/52_graphql/20_testing.ts +45 -0
- package/ai-docs/src/52_graphql/30_batching.ts +118 -0
- package/ai-docs/src/52_graphql/40_aliased-batching.ts +124 -0
- package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
- package/ai-docs/src/52_graphql/index.md +6 -0
- package/dist/Array.d.ts +90 -6
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +4 -2
- package/dist/Array.js.map +1 -1
- package/dist/Channel.d.ts +6 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +17 -3
- package/dist/Channel.js.map +1 -1
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +33 -32
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +9 -0
- package/dist/Context.js.map +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +2 -5
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +61 -19
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +58 -39
- package/dist/Effect.js.map +1 -1
- package/dist/FileSystem.d.ts +23 -9
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js.map +1 -1
- package/dist/Match.d.ts +20 -6
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +2 -2
- package/dist/Match.js.map +1 -1
- package/dist/Path.d.ts +37 -5
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +36 -5
- package/dist/Path.js.map +1 -1
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +4 -10
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Scheduler.d.ts +9 -0
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +9 -0
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +15 -2
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +16 -2
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.d.ts +4 -0
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +52 -33
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +38 -17
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +11 -0
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +16 -1
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +12 -0
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +17 -4
- package/dist/String.js.map +1 -1
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +3 -2
- package/dist/TxRef.js.map +1 -1
- package/dist/Utils.js +8 -3
- package/dist/Utils.js.map +1 -1
- package/dist/ai/AiError.d.ts +10 -10
- package/dist/ai/AiError.d.ts.map +1 -1
- package/dist/ai/AiError.js +1 -1
- package/dist/ai/AiError.js.map +1 -1
- package/dist/ai/AnthropicStructuredOutput.js +0 -2
- package/dist/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/ai/Chat.d.ts +2 -2
- package/dist/ai/Chat.d.ts.map +1 -1
- package/dist/ai/Decision.d.ts +70 -19
- package/dist/ai/Decision.d.ts.map +1 -1
- package/dist/ai/Decision.js +37 -3
- package/dist/ai/Decision.js.map +1 -1
- package/dist/ai/DecisionModel.js +1 -1
- package/dist/ai/DecisionModel.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts +38 -7
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +70 -40
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpServer.d.ts +61 -52
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +134 -50
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +28 -5
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +5 -4
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js.map +1 -1
- 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 +100 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +33 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/Param.d.ts +87 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +30 -0
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/internal/command.d.ts.map +1 -1
- package/dist/cli/internal/command.js +2 -1
- package/dist/cli/internal/command.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +4 -3
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cli/internal/completions/descriptor.js +8 -1
- package/dist/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/cli/internal/completions/fish.js +4 -4
- package/dist/cli/internal/completions/fish.js.map +1 -1
- package/dist/cli/internal/completions/powershell.js +3 -2
- package/dist/cli/internal/completions/powershell.js.map +1 -1
- package/dist/cli/internal/completions/zsh.js +7 -3
- package/dist/cli/internal/completions/zsh.js.map +1 -1
- package/dist/cli/internal/parser.js +11 -3
- 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 +2 -1
- package/dist/cli/internal/wizard.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts +1 -0
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +113 -21
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +20 -12
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +54 -34
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +6 -4
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +1 -1
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/encoding/Sse.d.ts +6 -0
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +63 -71
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/graphql/GraphQL.d.ts +349 -0
- package/dist/graphql/GraphQL.d.ts.map +1 -0
- package/dist/graphql/GraphQL.js +207 -0
- package/dist/graphql/GraphQL.js.map +1 -0
- package/dist/graphql/GraphQLClient.d.ts +562 -0
- package/dist/graphql/GraphQLClient.d.ts.map +1 -0
- package/dist/graphql/GraphQLClient.js +505 -0
- package/dist/graphql/GraphQLClient.js.map +1 -0
- package/dist/graphql/GraphQLClientError.d.ts +445 -0
- package/dist/graphql/GraphQLClientError.d.ts.map +1 -0
- package/dist/graphql/GraphQLClientError.js +479 -0
- package/dist/graphql/GraphQLClientError.js.map +1 -0
- package/dist/graphql/GraphQLGroup.d.ts +118 -0
- package/dist/graphql/GraphQLGroup.d.ts.map +1 -0
- package/dist/graphql/GraphQLGroup.js +109 -0
- package/dist/graphql/GraphQLGroup.js.map +1 -0
- package/dist/graphql/GraphQLMiddleware.d.ts +249 -0
- package/dist/graphql/GraphQLMiddleware.d.ts.map +1 -0
- package/dist/graphql/GraphQLMiddleware.js +130 -0
- package/dist/graphql/GraphQLMiddleware.js.map +1 -0
- package/dist/graphql/GraphQLProtocol.d.ts +969 -0
- package/dist/graphql/GraphQLProtocol.d.ts.map +1 -0
- package/dist/graphql/GraphQLProtocol.js +809 -0
- package/dist/graphql/GraphQLProtocol.js.map +1 -0
- package/dist/graphql/GraphQLResolver.d.ts +453 -0
- package/dist/graphql/GraphQLResolver.d.ts.map +1 -0
- package/dist/graphql/GraphQLResolver.js +582 -0
- package/dist/graphql/GraphQLResolver.js.map +1 -0
- package/dist/graphql/index.d.ts +40 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +41 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/http/FetchHttpClient.d.ts +6 -3
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +6 -3
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/FindMyWay/internal/router.js +2 -1
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/Headers.d.ts +3 -3
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +6 -5
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts +27 -0
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +38 -11
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +8 -6
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +147 -4
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +47 -1
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +14 -7
- package/dist/http/HttpEffect.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts +60 -0
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +93 -32
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts +35 -0
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +87 -13
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerError.d.ts.map +1 -1
- package/dist/http/HttpServerError.js +6 -4
- package/dist/http/HttpServerError.js.map +1 -1
- package/dist/http/HttpServerRequest.js +2 -2
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts +8 -6
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +27 -16
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/http/HttpStaticServer.js +4 -10
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http/HttpTraceContext.js +1 -1
- package/dist/http/HttpTraceContext.js.map +1 -1
- package/dist/http/Multipart.d.ts.map +1 -1
- package/dist/http/Multipart.js +15 -1
- package/dist/http/Multipart.js.map +1 -1
- package/dist/http/Url.d.ts.map +1 -1
- package/dist/http/Url.js +2 -1
- package/dist/http/Url.js.map +1 -1
- package/dist/http/UrlParams.d.ts +112 -8
- package/dist/http/UrlParams.d.ts.map +1 -1
- package/dist/http/UrlParams.js +141 -14
- package/dist/http/UrlParams.js.map +1 -1
- package/dist/http/internal/compression.d.ts +1 -1
- package/dist/http/internal/compression.d.ts.map +1 -1
- package/dist/http/internal/compression.js +2 -10
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/compressionBody.d.ts +2 -0
- package/dist/http/internal/compressionBody.d.ts.map +1 -0
- package/dist/http/internal/compressionBody.js +36 -0
- package/dist/http/internal/compressionBody.js.map +1 -0
- package/dist/http/internal/decompression.d.ts +2 -0
- package/dist/http/internal/decompression.d.ts.map +1 -0
- package/dist/http/internal/decompression.js +162 -0
- package/dist/http/internal/decompression.js.map +1 -0
- package/dist/http/internal/tracing.js +14 -4
- package/dist/http/internal/tracing.js.map +1 -1
- package/dist/http/internal/urlParams.d.ts +2 -0
- package/dist/http/internal/urlParams.d.ts.map +1 -0
- package/dist/http/internal/urlParams.js +4 -0
- package/dist/http/internal/urlParams.js.map +1 -0
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +2 -1
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiScalar.d.ts +5 -0
- package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
- package/dist/http-api/HttpApiScalar.js.map +1 -1
- package/dist/internal/core.js +17 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +40 -35
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +13 -6
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/graphql.d.ts +2 -0
- package/dist/internal/graphql.d.ts.map +1 -0
- package/dist/internal/graphql.js +205 -0
- package/dist/internal/graphql.js.map +1 -0
- package/dist/internal/graphqlHeaders.d.ts +4 -0
- package/dist/internal/graphqlHeaders.d.ts.map +1 -0
- package/dist/internal/graphqlHeaders.js +11 -0
- package/dist/internal/graphqlHeaders.js.map +1 -0
- package/dist/internal/request.js +20 -1
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +4 -1
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +29 -5
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/net/Host.d.ts +49 -0
- package/dist/net/Host.d.ts.map +1 -1
- package/dist/net/Host.js +55 -0
- package/dist/net/Host.js.map +1 -1
- package/dist/net/NetAddress.d.ts +8 -0
- package/dist/net/NetAddress.d.ts.map +1 -1
- package/dist/net/NetAddress.js +8 -0
- package/dist/net/NetAddress.js.map +1 -1
- package/dist/observability/Otlp.d.ts +15 -0
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +3 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts +8 -0
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +10 -1
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts +17 -0
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +14 -1
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts +17 -0
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +13 -0
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpTracer.d.ts +17 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +15 -2
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/reactivity/AsyncResult.d.ts +6 -0
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/reactivity/AsyncResult.js +27 -0
- package/dist/reactivity/AsyncResult.js.map +1 -1
- package/dist/reactivity/AtomRegistry.js +3 -1
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +6 -1
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +36 -9
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/socket/Socket.d.ts +6 -0
- package/dist/socket/Socket.d.ts.map +1 -1
- package/dist/socket/Socket.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +8 -7
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +8 -7
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/testing/TestClock.d.ts +16 -3
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +112 -22
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/workflow/Activity.js +1 -0
- package/dist/workflow/Activity.js.map +1 -1
- package/dist/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/workflow/DurableDeferred.js +32 -3
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +22 -0
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +15 -3
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts +44 -3
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +45 -22
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +6 -3
- package/src/Array.ts +95 -6
- package/src/Channel.ts +24 -3
- package/src/ConfigProvider.ts +40 -44
- package/src/Context.ts +9 -0
- package/src/Duration.ts +4 -5
- package/src/Effect.ts +140 -53
- package/src/FileSystem.ts +23 -9
- package/src/Match.ts +65 -12
- package/src/Path.ts +52 -7
- package/src/RequestResolver.ts +4 -10
- package/src/Scheduler.ts +9 -0
- package/src/Schema.ts +25 -4
- package/src/SchemaGetter.ts +47 -35
- package/src/Sink.ts +45 -18
- package/src/Stream.ts +33 -4
- package/src/String.ts +17 -4
- package/src/TxRef.ts +4 -2
- package/src/Utils.ts +8 -5
- package/src/ai/AiError.ts +3 -1
- package/src/ai/AnthropicStructuredOutput.ts +2 -2
- package/src/ai/Chat.ts +2 -2
- package/src/ai/Decision.ts +70 -21
- package/src/ai/DecisionModel.ts +1 -1
- package/src/ai/LanguageModel.ts +141 -63
- package/src/ai/McpServer.ts +259 -145
- package/src/ai/Prompt.ts +24 -10
- package/src/ai/Response.ts +6 -3
- package/src/cli/Completions.ts +5 -0
- package/src/cli/Flag.ts +101 -0
- package/src/cli/Param.ts +96 -0
- package/src/cli/internal/command.ts +2 -1
- package/src/cli/internal/completions/bash.ts +4 -3
- package/src/cli/internal/completions/descriptor.ts +10 -1
- package/src/cli/internal/completions/fish.ts +4 -4
- package/src/cli/internal/completions/powershell.ts +5 -2
- package/src/cli/internal/completions/zsh.ts +7 -3
- package/src/cli/internal/parser.ts +12 -3
- package/src/cli/internal/wizard.ts +2 -1
- package/src/cluster/ClusterWorkflowEngine.ts +143 -36
- package/src/cluster/MessageStorage.ts +14 -3
- package/src/cluster/Runners.ts +88 -66
- package/src/cluster/Sharding.ts +12 -9
- package/src/cluster/internal/entityManager.ts +1 -1
- package/src/encoding/Sse.ts +70 -80
- package/src/graphql/GraphQL.ts +494 -0
- package/src/graphql/GraphQLClient.ts +924 -0
- package/src/graphql/GraphQLClientError.ts +542 -0
- package/src/graphql/GraphQLGroup.ts +167 -0
- package/src/graphql/GraphQLMiddleware.ts +253 -0
- package/src/graphql/GraphQLProtocol.ts +1540 -0
- package/src/graphql/GraphQLResolver.ts +1038 -0
- package/src/graphql/index.ts +48 -0
- package/src/http/FetchHttpClient.ts +6 -3
- package/src/http/FindMyWay/internal/router.ts +2 -1
- package/src/http/Headers.ts +6 -9
- package/src/http/HttpClient.ts +72 -11
- package/src/http/HttpClientError.ts +10 -6
- package/src/http/HttpClientRequest.ts +173 -7
- package/src/http/HttpEffect.ts +11 -5
- package/src/http/HttpMiddleware.ts +113 -34
- package/src/http/HttpRouter.ts +95 -13
- package/src/http/HttpServerError.ts +8 -4
- package/src/http/HttpServerRequest.ts +2 -2
- package/src/http/HttpServerResponse.ts +28 -16
- package/src/http/HttpStaticServer.ts +4 -10
- package/src/http/HttpTraceContext.ts +1 -1
- package/src/http/Multipart.ts +17 -1
- package/src/http/Url.ts +2 -1
- package/src/http/UrlParams.ts +225 -26
- package/src/http/internal/compression.ts +3 -17
- package/src/http/internal/compressionBody.ts +56 -0
- package/src/http/internal/decompression.ts +226 -0
- package/src/http/internal/tracing.ts +21 -4
- package/src/http/internal/urlParams.ts +5 -0
- package/src/http-api/HttpApiClient.ts +2 -1
- package/src/http-api/HttpApiScalar.ts +5 -0
- package/src/internal/core.ts +21 -1
- package/src/internal/dateTime.ts +13 -10
- package/src/internal/effect.ts +13 -7
- package/src/internal/graphql.ts +286 -0
- package/src/internal/graphqlHeaders.ts +11 -0
- package/src/internal/request.ts +31 -3
- package/src/internal/schema/toCodeDocument.ts +7 -1
- package/src/internal/schema/toJsonSchemaDocument.ts +34 -2
- package/src/internal/version.ts +1 -1
- package/src/net/Host.ts +72 -0
- package/src/net/NetAddress.ts +9 -0
- package/src/observability/Otlp.ts +18 -0
- package/src/observability/OtlpExporter.ts +14 -3
- package/src/observability/OtlpLogger.ts +31 -2
- package/src/observability/OtlpMetrics.ts +30 -1
- package/src/observability/OtlpTracer.ts +32 -3
- package/src/reactivity/AsyncResult.ts +31 -0
- package/src/reactivity/AtomRegistry.ts +3 -1
- package/src/rpc/RpcClient.ts +6 -1
- package/src/rpc/RpcServer.ts +55 -15
- package/src/socket/Socket.ts +6 -0
- package/src/sql/SqlClient.ts +9 -7
- package/src/testing/TestClock.ts +144 -29
- package/src/workflow/Activity.ts +1 -0
- package/src/workflow/DurableDeferred.ts +43 -5
- package/src/workflow/Workflow.ts +31 -5
- package/src/workflow/WorkflowEngine.ts +107 -25
package/src/ai/Prompt.ts
CHANGED
|
@@ -2159,11 +2159,11 @@ export const fromResponseParts = (parts: ReadonlyArray<Response.AnyPart>): Promp
|
|
|
2159
2159
|
return empty
|
|
2160
2160
|
}
|
|
2161
2161
|
|
|
2162
|
-
const assistantParts: Array<AssistantMessagePart> = []
|
|
2162
|
+
const assistantParts: Array<AssistantMessagePart | undefined> = []
|
|
2163
2163
|
const toolParts: Array<ToolMessagePart> = []
|
|
2164
2164
|
|
|
2165
|
-
const activeTextDeltas = new Map<string, { text: string; options: ProviderOptions }>()
|
|
2166
|
-
const activeReasoningDeltas = new Map<string, { text: string; options: ProviderOptions }>()
|
|
2165
|
+
const activeTextDeltas = new Map<string, { index: number; text: string; options: ProviderOptions }>()
|
|
2166
|
+
const activeReasoningDeltas = new Map<string, { index: number; text: string; options: ProviderOptions }>()
|
|
2167
2167
|
|
|
2168
2168
|
for (const part of parts) {
|
|
2169
2169
|
switch (part.type) {
|
|
@@ -2175,7 +2175,8 @@ export const fromResponseParts = (parts: ReadonlyArray<Response.AnyPart>): Promp
|
|
|
2175
2175
|
|
|
2176
2176
|
// Text Parts (streaming)
|
|
2177
2177
|
case "text-start": {
|
|
2178
|
-
activeTextDeltas.set(part.id, { text: "", options: part.metadata })
|
|
2178
|
+
activeTextDeltas.set(part.id, { index: assistantParts.length, text: "", options: part.metadata })
|
|
2179
|
+
assistantParts.push(undefined)
|
|
2179
2180
|
break
|
|
2180
2181
|
}
|
|
2181
2182
|
case "text-delta": {
|
|
@@ -2190,7 +2191,8 @@ export const fromResponseParts = (parts: ReadonlyArray<Response.AnyPart>): Promp
|
|
|
2190
2191
|
if (activeTextDeltas.has(part.id)) {
|
|
2191
2192
|
const active = activeTextDeltas.get(part.id)!
|
|
2192
2193
|
active.options = mergeOptions(active.options, part.metadata)
|
|
2193
|
-
assistantParts.
|
|
2194
|
+
assistantParts[active.index] = makePart("text", { text: active.text, options: active.options })
|
|
2195
|
+
activeTextDeltas.delete(part.id)
|
|
2194
2196
|
}
|
|
2195
2197
|
break
|
|
2196
2198
|
}
|
|
@@ -2203,7 +2205,8 @@ export const fromResponseParts = (parts: ReadonlyArray<Response.AnyPart>): Promp
|
|
|
2203
2205
|
|
|
2204
2206
|
// Reasoning Parts (streaming)
|
|
2205
2207
|
case "reasoning-start": {
|
|
2206
|
-
activeReasoningDeltas.set(part.id, { text: "", options: part.metadata })
|
|
2208
|
+
activeReasoningDeltas.set(part.id, { index: assistantParts.length, text: "", options: part.metadata })
|
|
2209
|
+
assistantParts.push(undefined)
|
|
2207
2210
|
break
|
|
2208
2211
|
}
|
|
2209
2212
|
case "reasoning-delta": {
|
|
@@ -2218,7 +2221,8 @@ export const fromResponseParts = (parts: ReadonlyArray<Response.AnyPart>): Promp
|
|
|
2218
2221
|
if (activeReasoningDeltas.has(part.id)) {
|
|
2219
2222
|
const active = activeReasoningDeltas.get(part.id)!
|
|
2220
2223
|
active.options = mergeOptions(active.options, part.metadata)
|
|
2221
|
-
assistantParts.
|
|
2224
|
+
assistantParts[active.index] = makePart("reasoning", { text: active.text, options: active.options })
|
|
2225
|
+
activeReasoningDeltas.delete(part.id)
|
|
2222
2226
|
}
|
|
2223
2227
|
break
|
|
2224
2228
|
}
|
|
@@ -2272,14 +2276,24 @@ export const fromResponseParts = (parts: ReadonlyArray<Response.AnyPart>): Promp
|
|
|
2272
2276
|
}
|
|
2273
2277
|
}
|
|
2274
2278
|
|
|
2275
|
-
|
|
2279
|
+
// Keep partial text from unended blocks. Unended reasoning is dropped since it
|
|
2280
|
+
// may lack the signature or encrypted content providers require for replay.
|
|
2281
|
+
for (const active of activeTextDeltas.values()) {
|
|
2282
|
+
if (active.text.length > 0) {
|
|
2283
|
+
assistantParts[active.index] = makePart("text", { text: active.text, options: active.options })
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
const assistantContent = assistantParts.filter((part) => part !== undefined)
|
|
2288
|
+
|
|
2289
|
+
if (assistantContent.length === 0 && toolParts.length === 0) {
|
|
2276
2290
|
return empty
|
|
2277
2291
|
}
|
|
2278
2292
|
|
|
2279
2293
|
const messages: Array<Message> = []
|
|
2280
2294
|
|
|
2281
|
-
if (
|
|
2282
|
-
messages.push(makeMessage("assistant", { content:
|
|
2295
|
+
if (assistantContent.length > 0) {
|
|
2296
|
+
messages.push(makeMessage("assistant", { content: assistantContent }))
|
|
2283
2297
|
}
|
|
2284
2298
|
|
|
2285
2299
|
if (toolParts.length > 0) {
|
package/src/ai/Response.ts
CHANGED
|
@@ -441,16 +441,19 @@ export const StreamPart = <T extends Toolkit.Any | Toolkit.WithHandler<any>>(
|
|
|
441
441
|
export type ToolCallParts<
|
|
442
442
|
Tools extends Record<string, Tool.Any>,
|
|
443
443
|
ParametersMode extends ToolParametersMode = "decoded"
|
|
444
|
-
> =
|
|
444
|
+
> = ParametersMode extends "deferred" ?
|
|
445
|
+
ToolCallPartForName<Tools, "opaque", keyof Tools> | ToolCallPart<string, unknown>
|
|
446
|
+
: ToolCallPartForName<Tools, ParametersMode, keyof Tools>
|
|
445
447
|
|
|
446
448
|
/**
|
|
447
|
-
* Controls
|
|
449
|
+
* Controls tool parameter decoding. `"deferred"` allows undeclared tool names
|
|
450
|
+
* with opaque parameters, leaving validation to the caller.
|
|
448
451
|
*
|
|
449
452
|
* @stability unstable
|
|
450
453
|
* @category utility types
|
|
451
454
|
* @since 4.0.0
|
|
452
455
|
*/
|
|
453
|
-
export type ToolParametersMode = "decoded" | "encoded" | "opaque"
|
|
456
|
+
export type ToolParametersMode = "decoded" | "encoded" | "opaque" | "deferred"
|
|
454
457
|
|
|
455
458
|
type ToolCallPartForName<
|
|
456
459
|
Tools extends Record<string, Tool.Any>,
|
package/src/cli/Completions.ts
CHANGED
|
@@ -48,6 +48,11 @@ export interface FlagDescriptor {
|
|
|
48
48
|
readonly aliases: ReadonlyArray<string>
|
|
49
49
|
readonly description: string | undefined
|
|
50
50
|
readonly type: FlagType
|
|
51
|
+
/**
|
|
52
|
+
* Whether the flag's value is optional. Its value can only be attached with
|
|
53
|
+
* `=` (`--name=value`), never given as the next word.
|
|
54
|
+
*/
|
|
55
|
+
readonly optionalValue?: boolean | undefined
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
/**
|
package/src/cli/Flag.ts
CHANGED
|
@@ -611,6 +611,107 @@ export const withDescription: {
|
|
|
611
611
|
<A>(self: Flag<A>, description: string): Flag<A>
|
|
612
612
|
} = dual(2, <A>(self: Flag<A>, description: string) => Param.withDescription(self, description))
|
|
613
613
|
|
|
614
|
+
/**
|
|
615
|
+
* Lets a flag be given without a value, in which case `value` is used.
|
|
616
|
+
*
|
|
617
|
+
* **Details**
|
|
618
|
+
*
|
|
619
|
+
* Follows GNU-style optional values, like `--color[=WHEN]`. An explicit value
|
|
620
|
+
* must be attached with `=` (`--watch=until-done` or `-w=until-done`). A bare
|
|
621
|
+
* `--watch` is parsed as `--watch=<value>`, so `value` is validated like any
|
|
622
|
+
* other input. The flag never consumes the next token, so in `--watch build`,
|
|
623
|
+
* `build` stays a positional argument or subcommand. The flag is still
|
|
624
|
+
* required unless it is made optional or given a default.
|
|
625
|
+
*
|
|
626
|
+
* **Example** (Flag with an optional value)
|
|
627
|
+
*
|
|
628
|
+
* ```ts import.meta.vitest
|
|
629
|
+
* import { Flag } from "effect/cli"
|
|
630
|
+
*
|
|
631
|
+
* const watch = Flag.Literals("watch", ["first-failure", "until-done"]).pipe(
|
|
632
|
+
* Flag.withOptionalValue("first-failure"),
|
|
633
|
+
* Flag.optional
|
|
634
|
+
* )
|
|
635
|
+
* // --watch => Option.some("first-failure")
|
|
636
|
+
* // --watch=until-done => Option.some("until-done")
|
|
637
|
+
* // (absent) => Option.none()
|
|
638
|
+
* // In help: --watch [=choice]
|
|
639
|
+
* watch.kind // => "flag"
|
|
640
|
+
* ```
|
|
641
|
+
*
|
|
642
|
+
* @stability unstable
|
|
643
|
+
* @category combinators
|
|
644
|
+
* @since 4.1.0
|
|
645
|
+
*/
|
|
646
|
+
export const withOptionalValue: {
|
|
647
|
+
/**
|
|
648
|
+
* Lets a flag be given without a value, in which case `value` is used.
|
|
649
|
+
*
|
|
650
|
+
* **Details**
|
|
651
|
+
*
|
|
652
|
+
* Follows GNU-style optional values, like `--color[=WHEN]`. An explicit value
|
|
653
|
+
* must be attached with `=` (`--watch=until-done` or `-w=until-done`). A bare
|
|
654
|
+
* `--watch` is parsed as `--watch=<value>`, so `value` is validated like any
|
|
655
|
+
* other input. The flag never consumes the next token, so in `--watch build`,
|
|
656
|
+
* `build` stays a positional argument or subcommand. The flag is still
|
|
657
|
+
* required unless it is made optional or given a default.
|
|
658
|
+
*
|
|
659
|
+
* **Example** (Flag with an optional value)
|
|
660
|
+
*
|
|
661
|
+
* ```ts import.meta.vitest
|
|
662
|
+
* import { Flag } from "effect/cli"
|
|
663
|
+
*
|
|
664
|
+
* const watch = Flag.Literals("watch", ["first-failure", "until-done"]).pipe(
|
|
665
|
+
* Flag.withOptionalValue("first-failure"),
|
|
666
|
+
* Flag.optional
|
|
667
|
+
* )
|
|
668
|
+
* // --watch => Option.some("first-failure")
|
|
669
|
+
* // --watch=until-done => Option.some("until-done")
|
|
670
|
+
* // (absent) => Option.none()
|
|
671
|
+
* // In help: --watch [=choice]
|
|
672
|
+
* watch.kind // => "flag"
|
|
673
|
+
* ```
|
|
674
|
+
*
|
|
675
|
+
* @stability unstable
|
|
676
|
+
* @category combinators
|
|
677
|
+
* @since 4.1.0
|
|
678
|
+
*/
|
|
679
|
+
(value: string): <A>(self: Flag<A>) => Flag<A>
|
|
680
|
+
/**
|
|
681
|
+
* Lets a flag be given without a value, in which case `value` is used.
|
|
682
|
+
*
|
|
683
|
+
* **Details**
|
|
684
|
+
*
|
|
685
|
+
* Follows GNU-style optional values, like `--color[=WHEN]`. An explicit value
|
|
686
|
+
* must be attached with `=` (`--watch=until-done` or `-w=until-done`). A bare
|
|
687
|
+
* `--watch` is parsed as `--watch=<value>`, so `value` is validated like any
|
|
688
|
+
* other input. The flag never consumes the next token, so in `--watch build`,
|
|
689
|
+
* `build` stays a positional argument or subcommand. The flag is still
|
|
690
|
+
* required unless it is made optional or given a default.
|
|
691
|
+
*
|
|
692
|
+
* **Example** (Flag with an optional value)
|
|
693
|
+
*
|
|
694
|
+
* ```ts import.meta.vitest
|
|
695
|
+
* import { Flag } from "effect/cli"
|
|
696
|
+
*
|
|
697
|
+
* const watch = Flag.Literals("watch", ["first-failure", "until-done"]).pipe(
|
|
698
|
+
* Flag.withOptionalValue("first-failure"),
|
|
699
|
+
* Flag.optional
|
|
700
|
+
* )
|
|
701
|
+
* // --watch => Option.some("first-failure")
|
|
702
|
+
* // --watch=until-done => Option.some("until-done")
|
|
703
|
+
* // (absent) => Option.none()
|
|
704
|
+
* // In help: --watch [=choice]
|
|
705
|
+
* watch.kind // => "flag"
|
|
706
|
+
* ```
|
|
707
|
+
*
|
|
708
|
+
* @stability unstable
|
|
709
|
+
* @category combinators
|
|
710
|
+
* @since 4.1.0
|
|
711
|
+
*/
|
|
712
|
+
<A>(self: Flag<A>, value: string): Flag<A>
|
|
713
|
+
} = dual(2, <A>(self: Flag<A>, value: string) => Param.withOptionalValue(self, value))
|
|
714
|
+
|
|
614
715
|
// -------------------------------------------------------------------------------------
|
|
615
716
|
// metadata
|
|
616
717
|
// -------------------------------------------------------------------------------------
|
package/src/cli/Param.ts
CHANGED
|
@@ -213,6 +213,10 @@ export interface Single<Kind extends ParamKind, out A> extends Param<Kind, A> {
|
|
|
213
213
|
readonly primitiveType: Primitive.Primitive<A>
|
|
214
214
|
readonly typeName?: string | undefined
|
|
215
215
|
readonly hidden: boolean
|
|
216
|
+
/**
|
|
217
|
+
* Raw value used for a bare flag. See `withOptionalValue`.
|
|
218
|
+
*/
|
|
219
|
+
readonly optionalValue?: string | undefined
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
/**
|
|
@@ -362,6 +366,7 @@ export const makeSingle = <const Kind extends ParamKind, A>(params: {
|
|
|
362
366
|
readonly description?: Option.Option<string> | undefined
|
|
363
367
|
readonly aliases?: ReadonlyArray<string> | undefined
|
|
364
368
|
readonly hidden?: boolean | undefined
|
|
369
|
+
readonly optionalValue?: string | undefined
|
|
365
370
|
}): Single<Kind, A> => {
|
|
366
371
|
const parse: Parse<A> = (args) =>
|
|
367
372
|
params.kind === argumentKind
|
|
@@ -2664,6 +2669,97 @@ export const withMetavar: {
|
|
|
2664
2669
|
typeName: metavar
|
|
2665
2670
|
})))
|
|
2666
2671
|
|
|
2672
|
+
/**
|
|
2673
|
+
* Lets a flag be given without a value, in which case `value` is used.
|
|
2674
|
+
*
|
|
2675
|
+
* **Details**
|
|
2676
|
+
*
|
|
2677
|
+
* Follows GNU-style optional values. An explicit value must be attached with
|
|
2678
|
+
* `=` (`--watch=until-done`), and a bare `--watch` is parsed as
|
|
2679
|
+
* `--watch=<value>`. The flag never consumes the next token. It is still
|
|
2680
|
+
* required unless it is made optional or given a default.
|
|
2681
|
+
*
|
|
2682
|
+
* **Example** (Flag with an optional value)
|
|
2683
|
+
*
|
|
2684
|
+
* ```ts import.meta.vitest
|
|
2685
|
+
* import { Param } from "effect/cli"
|
|
2686
|
+
*
|
|
2687
|
+
* const watch = Param.String(Param.flagKind, "watch").pipe(
|
|
2688
|
+
* Param.withOptionalValue("first-failure"),
|
|
2689
|
+
* Param.optional
|
|
2690
|
+
* )
|
|
2691
|
+
* watch.kind // => "flag"
|
|
2692
|
+
* ```
|
|
2693
|
+
*
|
|
2694
|
+
* @stability unstable
|
|
2695
|
+
* @category combinators
|
|
2696
|
+
* @since 4.1.0
|
|
2697
|
+
*/
|
|
2698
|
+
export const withOptionalValue: {
|
|
2699
|
+
/**
|
|
2700
|
+
* Lets a flag be given without a value, in which case `value` is used.
|
|
2701
|
+
*
|
|
2702
|
+
* **Details**
|
|
2703
|
+
*
|
|
2704
|
+
* Follows GNU-style optional values. An explicit value must be attached with
|
|
2705
|
+
* `=` (`--watch=until-done`), and a bare `--watch` is parsed as
|
|
2706
|
+
* `--watch=<value>`. The flag never consumes the next token. It is still
|
|
2707
|
+
* required unless it is made optional or given a default.
|
|
2708
|
+
*
|
|
2709
|
+
* **Example** (Flag with an optional value)
|
|
2710
|
+
*
|
|
2711
|
+
* ```ts import.meta.vitest
|
|
2712
|
+
* import { Param } from "effect/cli"
|
|
2713
|
+
*
|
|
2714
|
+
* const watch = Param.String(Param.flagKind, "watch").pipe(
|
|
2715
|
+
* Param.withOptionalValue("first-failure"),
|
|
2716
|
+
* Param.optional
|
|
2717
|
+
* )
|
|
2718
|
+
* watch.kind // => "flag"
|
|
2719
|
+
* ```
|
|
2720
|
+
*
|
|
2721
|
+
* @stability unstable
|
|
2722
|
+
* @category combinators
|
|
2723
|
+
* @since 4.1.0
|
|
2724
|
+
*/
|
|
2725
|
+
(value: string): <A>(self: Param<typeof flagKind, A>) => Param<typeof flagKind, A>
|
|
2726
|
+
/**
|
|
2727
|
+
* Lets a flag be given without a value, in which case `value` is used.
|
|
2728
|
+
*
|
|
2729
|
+
* **Details**
|
|
2730
|
+
*
|
|
2731
|
+
* Follows GNU-style optional values. An explicit value must be attached with
|
|
2732
|
+
* `=` (`--watch=until-done`), and a bare `--watch` is parsed as
|
|
2733
|
+
* `--watch=<value>`. The flag never consumes the next token. It is still
|
|
2734
|
+
* required unless it is made optional or given a default.
|
|
2735
|
+
*
|
|
2736
|
+
* **Example** (Flag with an optional value)
|
|
2737
|
+
*
|
|
2738
|
+
* ```ts import.meta.vitest
|
|
2739
|
+
* import { Param } from "effect/cli"
|
|
2740
|
+
*
|
|
2741
|
+
* const watch = Param.String(Param.flagKind, "watch").pipe(
|
|
2742
|
+
* Param.withOptionalValue("first-failure"),
|
|
2743
|
+
* Param.optional
|
|
2744
|
+
* )
|
|
2745
|
+
* watch.kind // => "flag"
|
|
2746
|
+
* ```
|
|
2747
|
+
*
|
|
2748
|
+
* @stability unstable
|
|
2749
|
+
* @category combinators
|
|
2750
|
+
* @since 4.1.0
|
|
2751
|
+
*/
|
|
2752
|
+
<A>(self: Param<typeof flagKind, A>, value: string): Param<typeof flagKind, A>
|
|
2753
|
+
} = dual(2, <A>(
|
|
2754
|
+
self: Param<typeof flagKind, A>,
|
|
2755
|
+
value: string
|
|
2756
|
+
) =>
|
|
2757
|
+
transformSingle(self, (single) =>
|
|
2758
|
+
makeSingle({
|
|
2759
|
+
...single,
|
|
2760
|
+
optionalValue: value
|
|
2761
|
+
})))
|
|
2762
|
+
|
|
2667
2763
|
/**
|
|
2668
2764
|
* Validates parsed values against a Schema, providing detailed error messages.
|
|
2669
2765
|
*
|
|
@@ -242,10 +242,11 @@ export const toFlagDoc = (
|
|
|
242
242
|
metadata: ReturnType<typeof Param.getParamMetadata>
|
|
243
243
|
): FlagDoc => {
|
|
244
244
|
const formattedAliases = single.aliases.map((alias) => alias.length === 1 ? `-${alias}` : `--${alias}`)
|
|
245
|
+
const type = single.typeName ?? Primitive.getTypeName(single.primitiveType)
|
|
245
246
|
return {
|
|
246
247
|
name: single.name,
|
|
247
248
|
aliases: formattedAliases,
|
|
248
|
-
type: single.
|
|
249
|
+
type: single.optionalValue === undefined ? type : `[=${type}]`,
|
|
249
250
|
description: appendChoiceKeys(single.description, Primitive.getChoiceKeys(single.primitiveType)),
|
|
250
251
|
required: single.primitiveType._tag !== "Boolean" && !metadata.isOptional
|
|
251
252
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
9
|
import type * as Completions from "../../Completions.ts"
|
|
10
|
+
import { takesSeparateValue } from "./descriptor.ts"
|
|
10
11
|
|
|
11
12
|
// ---------------------------------------------------------------------------
|
|
12
13
|
// Helpers
|
|
@@ -164,7 +165,7 @@ const generateFunction = (
|
|
|
164
165
|
lines.push(``)
|
|
165
166
|
|
|
166
167
|
// Build flag-value dispatch
|
|
167
|
-
const flagsWithValues = descriptor.flags.filter(
|
|
168
|
+
const flagsWithValues = descriptor.flags.filter(takesSeparateValue)
|
|
168
169
|
if (flagsWithValues.length > 0) {
|
|
169
170
|
lines.push(` # Flag value completions`)
|
|
170
171
|
lines.push(` case "$prev" in`)
|
|
@@ -196,7 +197,7 @@ const generateFunction = (
|
|
|
196
197
|
lines.push(` fi`)
|
|
197
198
|
lines.push(` case "\${words[i]}" in`)
|
|
198
199
|
for (const flag of descriptor.flags) {
|
|
199
|
-
if (flag
|
|
200
|
+
if (!takesSeparateValue(flag)) continue
|
|
200
201
|
const forms = flagNamesForWordlist(flag)
|
|
201
202
|
lines.push(` ${forms.join("|")}) _skip_next=1 ;;`)
|
|
202
203
|
lines.push(` ${forms.map((form) => `${form}=*`).join("|")}) ;;`)
|
|
@@ -248,7 +249,7 @@ const generateFunction = (
|
|
|
248
249
|
lines.push(` --) _end_of_options=1 ;;`)
|
|
249
250
|
for (const flag of descriptor.flags) {
|
|
250
251
|
const forms = flagNamesForWordlist(flag)
|
|
251
|
-
if (flag
|
|
252
|
+
if (!takesSeparateValue(flag)) {
|
|
252
253
|
lines.push(` ${forms.join("|")}) ;;`)
|
|
253
254
|
} else {
|
|
254
255
|
lines.push(` ${forms.join("|")}) _skip_next=1 ;;`)
|
|
@@ -95,7 +95,8 @@ export const fromCommand = (
|
|
|
95
95
|
name: single.name,
|
|
96
96
|
aliases: single.aliases,
|
|
97
97
|
description: Option.getOrUndefined(single.description),
|
|
98
|
-
type: toFlagType(single as Param.Single<"flag", unknown>)
|
|
98
|
+
type: toFlagType(single as Param.Single<"flag", unknown>),
|
|
99
|
+
optionalValue: single.optionalValue !== undefined
|
|
99
100
|
})
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -139,3 +140,11 @@ export const fromCommand = (
|
|
|
139
140
|
subcommands
|
|
140
141
|
}
|
|
141
142
|
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Whether the flag reads its value from the next word.
|
|
146
|
+
*
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
export const takesSeparateValue = (flag: Completions.FlagDescriptor): boolean =>
|
|
150
|
+
flag.type._tag !== "Boolean" && flag.optionalValue !== true
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
9
|
import type * as Completions from "../../Completions.ts"
|
|
10
|
+
import { takesSeparateValue } from "./descriptor.ts"
|
|
10
11
|
|
|
11
12
|
// ---------------------------------------------------------------------------
|
|
12
13
|
// Helpers
|
|
@@ -88,7 +89,7 @@ const flagCompletionArgs = (flag: Completions.FlagDescriptor): Array<string> =>
|
|
|
88
89
|
if (flag.description) {
|
|
89
90
|
args.push(`-d '${escapeFishString(flag.description)}'`)
|
|
90
91
|
}
|
|
91
|
-
const valueArgs = flagValueArgs(flag.type)
|
|
92
|
+
const valueArgs = takesSeparateValue(flag) ? flagValueArgs(flag.type) : undefined
|
|
92
93
|
if (valueArgs) {
|
|
93
94
|
args.push(valueArgs)
|
|
94
95
|
}
|
|
@@ -159,8 +160,7 @@ const generateCompletions = (
|
|
|
159
160
|
|
|
160
161
|
// Flag completions
|
|
161
162
|
for (const flag of descriptor.flags) {
|
|
162
|
-
const
|
|
163
|
-
const dedup = isBoolean ? flagContainsOptCondition(flag) : valueFlagDedupCondition(flag)
|
|
163
|
+
const dedup = takesSeparateValue(flag) ? valueFlagDedupCondition(flag) : flagContainsOptCondition(flag)
|
|
164
164
|
const flagCondition = condition ? `${condition}; and ${dedup}` : dedup
|
|
165
165
|
const flagCondArg = flagCondition ? `-n '${flagCondition}'` : ``
|
|
166
166
|
|
|
@@ -170,7 +170,7 @@ const generateCompletions = (
|
|
|
170
170
|
lines.push(parts.join(" "))
|
|
171
171
|
|
|
172
172
|
// Boolean negation
|
|
173
|
-
if (
|
|
173
|
+
if (flag.type._tag === "Boolean") {
|
|
174
174
|
const negParts = [`complete -c ${executableName}`]
|
|
175
175
|
if (flagCondArg) negParts.push(flagCondArg)
|
|
176
176
|
negParts.push(`-l no-${flag.name}`)
|
|
@@ -48,7 +48,9 @@ const valueFields = (type: Completions.FlagType | Completions.ArgumentType): str
|
|
|
48
48
|
|
|
49
49
|
const flagEntry = (flag: Completions.FlagDescriptor): string =>
|
|
50
50
|
`@{ name = ${quotePs(flag.name)}; forms = ${psArray(flagForms(flag))}; ` +
|
|
51
|
-
`takesValue = $${flag.type._tag !== "Boolean"};
|
|
51
|
+
`takesValue = $${flag.type._tag !== "Boolean"}; ` +
|
|
52
|
+
(flag.optionalValue === true ? `optionalValue = $true; ` : "") +
|
|
53
|
+
`${valueFields(flag.type)}; ` +
|
|
52
54
|
`description = ${psOptional(flag.description)} }`
|
|
53
55
|
|
|
54
56
|
const argumentEntry = (argument: Completions.ArgumentDescriptor): string =>
|
|
@@ -235,7 +237,8 @@ const completer = (dataName: string): string =>
|
|
|
235
237
|
continue
|
|
236
238
|
}
|
|
237
239
|
$used[$flag.name] = $true
|
|
238
|
-
|
|
240
|
+
# A flag with an optional value only takes a value attached with '='.
|
|
241
|
+
if (-not $hasValue -and -not $flag.optionalValue) { $pending = $flag }
|
|
239
242
|
}
|
|
240
243
|
continue
|
|
241
244
|
}
|
|
@@ -72,16 +72,20 @@ const argAction = (type: Completions.ArgumentType): string => {
|
|
|
72
72
|
const flagSpecs = (flag: Completions.FlagDescriptor): Array<string> => {
|
|
73
73
|
const specs: Array<string> = []
|
|
74
74
|
const desc = flag.description ? `[${escapeZshExplanation(flag.description)}]` : ""
|
|
75
|
-
|
|
75
|
+
// An optional value must follow `=` in the same word (`--name=-`), and `::`
|
|
76
|
+
// marks it optional.
|
|
77
|
+
const optional = flag.optionalValue === true && flag.type._tag !== "Boolean"
|
|
78
|
+
const valueSuffix = optional ? "=-" : ""
|
|
79
|
+
const action = optional ? `:${valueAction(flag.type)}` : valueAction(flag.type)
|
|
76
80
|
const excl = `(${allForms(flag).join(" ")})`
|
|
77
81
|
|
|
78
82
|
// Primary long name
|
|
79
|
-
specs.push(`'${excl}--${flag.name}${desc}${action}'`)
|
|
83
|
+
specs.push(`'${excl}--${flag.name}${valueSuffix}${desc}${action}'`)
|
|
80
84
|
|
|
81
85
|
// Aliases
|
|
82
86
|
for (const alias of flag.aliases) {
|
|
83
87
|
const prefix = alias.length === 1 ? "-" : "--"
|
|
84
|
-
specs.push(`'${excl}${prefix}${alias}${desc}${action}'`)
|
|
88
|
+
specs.push(`'${excl}${prefix}${alias}${valueSuffix}${desc}${action}'`)
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
// Boolean negation
|
|
@@ -425,8 +425,9 @@ const asBooleanLiteral = (token: Token | undefined): string | undefined =>
|
|
|
425
425
|
*
|
|
426
426
|
* Value resolution order:
|
|
427
427
|
* 1. Inline value: --flag=value or -f=value
|
|
428
|
-
* 2.
|
|
429
|
-
* 3.
|
|
428
|
+
* 2. Optional value: the flag's configured value, without consuming a token
|
|
429
|
+
* 3. Boolean special case: implicit "true" or explicit boolean literal
|
|
430
|
+
* 4. Next token: consume following Value token if present
|
|
430
431
|
*/
|
|
431
432
|
const consumeFlagValue = (
|
|
432
433
|
cursor: TokenCursor,
|
|
@@ -465,7 +466,7 @@ const consumeFlagValueWithTokens = (
|
|
|
465
466
|
}
|
|
466
467
|
}
|
|
467
468
|
|
|
468
|
-
const literal = asBooleanLiteral(cursor.peek())
|
|
469
|
+
const literal = spec.optionalValue === undefined ? asBooleanLiteral(cursor.peek()) : undefined
|
|
469
470
|
if (literal !== undefined) {
|
|
470
471
|
const literalToken = cursor.take()
|
|
471
472
|
return {
|
|
@@ -490,6 +491,14 @@ const consumeFlagValueWithTokens = (
|
|
|
490
491
|
}
|
|
491
492
|
}
|
|
492
493
|
|
|
494
|
+
if (spec.optionalValue !== undefined) {
|
|
495
|
+
return {
|
|
496
|
+
_tag: "Value",
|
|
497
|
+
value: spec.optionalValue,
|
|
498
|
+
tokens: []
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
493
502
|
// Boolean flags: check for explicit literal or default to "true"
|
|
494
503
|
if (Primitive.isBoolean(spec.primitiveType)) {
|
|
495
504
|
const literal = asBooleanLiteral(cursor.peek())
|
|
@@ -171,8 +171,9 @@ const promptParam = Effect.fnUntraced(
|
|
|
171
171
|
return values
|
|
172
172
|
}
|
|
173
173
|
// Inline option-looking values so the lexer cannot interpret them as flags or the -- delimiter.
|
|
174
|
+
// Flags with an optional value only accept an inline value.
|
|
174
175
|
return values.flatMap((value) =>
|
|
175
|
-
value.value.startsWith("-") && value.value.length > 1
|
|
176
|
+
single.optionalValue !== undefined || (value.value.startsWith("-") && value.value.length > 1)
|
|
176
177
|
? [commandLineArg(`--${single.name}=${value.value}`, `--${single.name}=${value.displayValue}`)]
|
|
177
178
|
: [commandLineArg(`--${single.name}`), value]
|
|
178
179
|
)
|