effect 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +111 -0
- package/ai-docs/src/52_graphql/20_testing.ts +45 -0
- package/ai-docs/src/52_graphql/30_batching.ts +116 -0
- package/ai-docs/src/52_graphql/40_aliased-batching.ts +122 -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/Context.d.ts.map +1 -1
- package/dist/Context.js +12 -3
- package/dist/Context.js.map +1 -1
- package/dist/Crypto.d.ts +33 -5
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +8 -2
- package/dist/Crypto.js.map +1 -1
- package/dist/DateTime.d.ts +9 -6
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +9 -6
- package/dist/DateTime.js.map +1 -1
- package/dist/Duration.d.ts +6 -6
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +27 -8
- package/dist/Duration.js.map +1 -1
- package/dist/FileSystem.d.ts +44 -2
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.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 +481 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +362 -4
- 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/Stdio.d.ts +7 -1
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +1 -0
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +22 -11
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +21 -6
- package/dist/Stream.js.map +1 -1
- package/dist/Utils.js +8 -3
- package/dist/Utils.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/LanguageModel.d.ts +38 -7
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +25 -7
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpServer.d.ts +61 -0
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +196 -44
- 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 +4 -3
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +5 -0
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +1 -0
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/cli/CliOutput.d.ts +27 -0
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +33 -10
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +6 -3
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Completions.d.ts +3 -3
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js +8 -5
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/GlobalFlag.d.ts +5 -4
- package/dist/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/cli/GlobalFlag.js +3 -3
- package/dist/cli/GlobalFlag.js.map +1 -1
- package/dist/cli/Prompt.d.ts +17 -1
- package/dist/cli/Prompt.d.ts.map +1 -1
- package/dist/cli/Prompt.js +119 -114
- package/dist/cli/Prompt.js.map +1 -1
- package/dist/cli/internal/ansi.d.ts +0 -1
- package/dist/cli/internal/ansi.d.ts.map +1 -1
- package/dist/cli/internal/ansi.js +20 -3
- package/dist/cli/internal/ansi.js.map +1 -1
- package/dist/cli/internal/completions/powershell.d.ts +2 -0
- package/dist/cli/internal/completions/powershell.d.ts.map +1 -0
- package/dist/cli/internal/completions/powershell.js +273 -0
- package/dist/cli/internal/completions/powershell.js.map +1 -0
- package/dist/cli/internal/completions/zsh.js +3 -2
- package/dist/cli/internal/completions/zsh.js.map +1 -1
- package/dist/cli/internal/wizard.d.ts +3 -3
- package/dist/cli/internal/wizard.d.ts.map +1 -1
- package/dist/cli/internal/wizard.js +21 -18
- package/dist/cli/internal/wizard.js.map +1 -1
- package/dist/cluster/ClusterSchema.d.ts +28 -0
- package/dist/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/cluster/ClusterSchema.js +30 -0
- package/dist/cluster/ClusterSchema.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +56 -26
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +18 -3
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +31 -11
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +8 -2
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +187 -66
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts +59 -19
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +84 -55
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts +68 -19
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +191 -113
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +104 -37
- 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 +62 -70
- 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 +498 -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 +731 -0
- package/dist/graphql/GraphQLProtocol.d.ts.map +1 -0
- package/dist/graphql/GraphQLProtocol.js +719 -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 +552 -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/FindMyWay/internal/router.js +3 -6
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/HttpClient.d.ts +21 -0
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +63 -12
- package/dist/http/HttpClient.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.map +1 -1
- package/dist/http/HttpMiddleware.js +31 -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 +35 -0
- package/dist/http/HttpRouter.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/HttpTraceContext.d.ts.map +1 -1
- package/dist/http/HttpTraceContext.js +4 -2
- 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-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/dateTime.js +40 -35
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +19 -9
- 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 +195 -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/AddressResolver.d.ts +145 -0
- package/dist/net/AddressResolver.d.ts.map +1 -0
- package/dist/net/AddressResolver.js +114 -0
- package/dist/net/AddressResolver.js.map +1 -0
- package/dist/net/Dns.d.ts +596 -0
- package/dist/net/Dns.d.ts.map +1 -0
- package/dist/net/Dns.js +549 -0
- package/dist/net/Dns.js.map +1 -0
- package/dist/net/Host.d.ts +369 -0
- package/dist/net/Host.d.ts.map +1 -0
- package/dist/net/Host.js +397 -0
- package/dist/net/Host.js.map +1 -0
- package/dist/net/IpInterface.d.ts +76 -3
- package/dist/net/IpInterface.d.ts.map +1 -1
- package/dist/net/IpInterface.js +53 -4
- package/dist/net/IpInterface.js.map +1 -1
- package/dist/net/IpNetwork.d.ts +82 -8
- package/dist/net/IpNetwork.d.ts.map +1 -1
- package/dist/net/IpNetwork.js +60 -4
- package/dist/net/IpNetwork.js.map +1 -1
- package/dist/net/NetAddress.d.ts +396 -35
- package/dist/net/NetAddress.d.ts.map +1 -1
- package/dist/net/NetAddress.js +358 -34
- package/dist/net/NetAddress.js.map +1 -1
- package/dist/net/index.d.ts +15 -0
- package/dist/net/index.d.ts.map +1 -1
- package/dist/net/index.js +15 -0
- package/dist/net/index.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +15 -21
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/PrometheusMetrics.js +1 -0
- package/dist/observability/PrometheusMetrics.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts +32 -3
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +75 -16
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +22 -6
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +12 -5
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts +6 -0
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +78 -29
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/socket/DatagramSocket.d.ts +456 -0
- package/dist/socket/DatagramSocket.d.ts.map +1 -0
- package/dist/socket/DatagramSocket.js +535 -0
- package/dist/socket/DatagramSocket.js.map +1 -0
- package/dist/socket/Socket.d.ts +20 -1
- package/dist/socket/Socket.d.ts.map +1 -1
- package/dist/socket/Socket.js +9 -1
- package/dist/socket/Socket.js.map +1 -1
- package/dist/socket/index.d.ts +5 -0
- package/dist/socket/index.d.ts.map +1 -1
- package/dist/socket/index.js +5 -0
- package/dist/socket/index.js.map +1 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +7 -2
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +7 -1
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +31 -6
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/testing/TestCrypto.d.ts +73 -0
- package/dist/testing/TestCrypto.d.ts.map +1 -0
- package/dist/testing/TestCrypto.js +87 -0
- package/dist/testing/TestCrypto.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +5 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/workflow/DurableDeferred.d.ts +54 -0
- package/dist/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/workflow/DurableDeferred.js +108 -50
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts +24 -2
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +13 -3
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +6 -3
- package/src/Context.ts +12 -3
- package/src/Crypto.ts +43 -9
- package/src/DateTime.ts +9 -6
- package/src/Duration.ts +36 -16
- package/src/FileSystem.ts +48 -2
- package/src/RequestResolver.ts +4 -10
- package/src/Scheduler.ts +9 -0
- package/src/Schema.ts +677 -5
- package/src/SchemaGetter.ts +47 -35
- package/src/Sink.ts +45 -18
- package/src/Stdio.ts +9 -2
- package/src/Stream.ts +44 -15
- package/src/Utils.ts +8 -5
- package/src/ai/AnthropicStructuredOutput.ts +2 -2
- package/src/ai/Chat.ts +2 -2
- package/src/ai/LanguageModel.ts +96 -24
- package/src/ai/McpServer.ts +288 -94
- package/src/ai/Prompt.ts +24 -10
- package/src/ai/Response.ts +6 -3
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +5 -0
- package/src/ai/internal/mcpProtocol.ts +3 -0
- package/src/ai/internal/mcpRuntime.ts +2 -0
- package/src/cli/CliOutput.ts +33 -16
- package/src/cli/Command.ts +4 -3
- package/src/cli/Completions.ts +9 -6
- package/src/cli/GlobalFlag.ts +19 -11
- package/src/cli/Prompt.ts +159 -149
- package/src/cli/internal/ansi.ts +26 -3
- package/src/cli/internal/completions/powershell.ts +322 -0
- package/src/cli/internal/completions/zsh.ts +4 -2
- package/src/cli/internal/wizard.ts +34 -26
- package/src/cluster/ClusterSchema.ts +32 -0
- package/src/cluster/ClusterWorkflowEngine.ts +64 -36
- package/src/cluster/MessageStorage.ts +45 -14
- package/src/cluster/Runners.ts +8 -2
- package/src/cluster/Sharding.ts +219 -58
- package/src/cluster/SqlMessageStorage.ts +118 -84
- package/src/cluster/SqlRunnerStorage.ts +224 -128
- package/src/cluster/internal/entityManager.ts +151 -55
- package/src/encoding/Sse.ts +69 -79
- package/src/graphql/GraphQL.ts +494 -0
- package/src/graphql/GraphQLClient.ts +912 -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 +1286 -0
- package/src/graphql/GraphQLResolver.ts +1010 -0
- package/src/graphql/index.ts +48 -0
- package/src/http/FindMyWay/internal/router.ts +4 -7
- package/src/http/HttpClient.ts +110 -12
- package/src/http/HttpEffect.ts +11 -5
- package/src/http/HttpMiddleware.ts +33 -34
- package/src/http/HttpRouter.ts +35 -0
- package/src/http/HttpServerResponse.ts +28 -16
- package/src/http/HttpTraceContext.ts +8 -2
- package/src/http/Multipart.ts +17 -1
- package/src/http-api/HttpApiScalar.ts +5 -0
- package/src/internal/dateTime.ts +13 -10
- package/src/internal/effect.ts +22 -15
- package/src/internal/graphql.ts +263 -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/AddressResolver.ts +222 -0
- package/src/net/Dns.ts +1035 -0
- package/src/net/Host.ts +544 -0
- package/src/net/IpInterface.ts +117 -7
- package/src/net/IpNetwork.ts +116 -17
- package/src/net/NetAddress.ts +620 -76
- package/src/net/index.ts +18 -0
- package/src/observability/OtlpMetrics.ts +12 -23
- package/src/observability/PrometheusMetrics.ts +1 -0
- package/src/persistence/PersistedQueue.ts +146 -53
- package/src/rpc/RpcClient.ts +41 -19
- package/src/rpc/RpcServer.ts +115 -40
- package/src/socket/DatagramSocket.ts +919 -0
- package/src/socket/Socket.ts +28 -2
- package/src/socket/index.ts +6 -0
- package/src/sql/Migrator.ts +21 -5
- package/src/sql/SqlClient.ts +39 -15
- package/src/testing/TestCrypto.ts +94 -0
- package/src/testing/index.ts +6 -0
- package/src/workflow/DurableDeferred.ts +160 -47
- package/src/workflow/WorkflowEngine.ts +50 -5
package/src/SchemaGetter.ts
CHANGED
|
@@ -2264,6 +2264,8 @@ function bracketPathToTokens(bracketPath: string): Array<string | number> {
|
|
|
2264
2264
|
.map((part) => (Arr.isCanonicalArrayIndex(part) ? globalThis.Number(part) : part))
|
|
2265
2265
|
}
|
|
2266
2266
|
|
|
2267
|
+
const MAX_ARRAY_HOLES = 20
|
|
2268
|
+
|
|
2267
2269
|
/**
|
|
2268
2270
|
* Builds a nested tree object from a list of bracket-path entries.
|
|
2269
2271
|
*
|
|
@@ -2287,6 +2289,10 @@ function bracketPathToTokens(bracketPath: string): Array<string | number> {
|
|
|
2287
2289
|
* - `""` → real empty key
|
|
2288
2290
|
* - Numeric bracket segments become array indices only when they are valid
|
|
2289
2291
|
* JavaScript array-index strings; otherwise they remain object keys.
|
|
2292
|
+
* - An indexed container becomes an array only when it has at most 20 holes
|
|
2293
|
+
* (missing indices below its highest index). Otherwise it is returned as an
|
|
2294
|
+
* object keyed by the index strings, so untrusted input such as
|
|
2295
|
+
* `a[4294967294]` cannot produce huge sparse arrays.
|
|
2290
2296
|
* - Duplicate keys for the same path are merged into arrays.
|
|
2291
2297
|
* - If a structural path conflicts with a previous leaf or a different container
|
|
2292
2298
|
* type, the later structural path replaces the conflicting value.
|
|
@@ -2319,43 +2325,31 @@ export function makeTreeRecord<A>(
|
|
|
2319
2325
|
const out: any = {}
|
|
2320
2326
|
const containers = new WeakSet<object>()
|
|
2321
2327
|
const duplicates = new WeakSet<object>()
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
if (containers.has(current) && Array.isArray(current) === shouldBeArray) {
|
|
2326
|
-
return current
|
|
2327
|
-
}
|
|
2328
|
-
const container = shouldBeArray ? [] : {}
|
|
2329
|
-
containers.add(container)
|
|
2330
|
-
InternalRecord.assignProperty(self, key, container)
|
|
2331
|
-
return container
|
|
2332
|
-
}
|
|
2328
|
+
// Indexed containers are built as plain objects so that large indices never
|
|
2329
|
+
// allocate sparse arrays, and are materialized once all entries are applied
|
|
2330
|
+
const indexed = new Map<object, { readonly parent: any; readonly key: PropertyKey; length: number }>()
|
|
2333
2331
|
|
|
2334
2332
|
bracketPathEntries.forEach(([key, value]) => {
|
|
2335
2333
|
const tokens = bracketPathToTokens(key)
|
|
2336
2334
|
let cur: any = out
|
|
2337
|
-
tokens.
|
|
2338
|
-
const
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
if (
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
// convert it to an array to support multiple values for the same key
|
|
2354
|
-
const hasOwn = Object.hasOwn(cur, token)
|
|
2355
|
-
if (hasOwn && Array.isArray(cur[token]) && (containers.has(cur[token]) || duplicates.has(cur[token]))) {
|
|
2356
|
-
cur[token].push(value)
|
|
2335
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
2336
|
+
const state = indexed.get(cur)
|
|
2337
|
+
// Resolve "[]" to the next index before handling leaves or containers
|
|
2338
|
+
const token = tokens[i] === "" && state !== undefined ? state.length : tokens[i]
|
|
2339
|
+
if (state !== undefined && typeof token === "number") {
|
|
2340
|
+
state.length = Math.max(state.length, token + 1)
|
|
2341
|
+
}
|
|
2342
|
+
const hasOwn = Object.hasOwn(cur, token)
|
|
2343
|
+
const current = hasOwn ? cur[token] : undefined
|
|
2344
|
+
|
|
2345
|
+
if (i === tokens.length - 1) {
|
|
2346
|
+
const currentState = indexed.get(current)
|
|
2347
|
+
if (currentState !== undefined) {
|
|
2348
|
+
InternalRecord.assignProperty(current, currentState.length++, value)
|
|
2349
|
+
} else if (duplicates.has(current)) {
|
|
2350
|
+
current.push(value)
|
|
2357
2351
|
} else if (hasOwn) {
|
|
2358
|
-
const values = [
|
|
2352
|
+
const values = [current, value]
|
|
2359
2353
|
duplicates.add(values)
|
|
2360
2354
|
InternalRecord.assignProperty(cur, token, values)
|
|
2361
2355
|
} else {
|
|
@@ -2363,12 +2357,30 @@ export function makeTreeRecord<A>(
|
|
|
2363
2357
|
}
|
|
2364
2358
|
} else {
|
|
2365
2359
|
const next = tokens[i + 1]
|
|
2366
|
-
// if next is a number OR "" (from []), we are building an array
|
|
2367
2360
|
const shouldBeArray = typeof next === "number" || next === ""
|
|
2368
|
-
|
|
2361
|
+
if (containers.has(current) && indexed.has(current) === shouldBeArray) {
|
|
2362
|
+
cur = current
|
|
2363
|
+
} else {
|
|
2364
|
+
const container = {}
|
|
2365
|
+
containers.add(container)
|
|
2366
|
+
if (shouldBeArray) {
|
|
2367
|
+
indexed.set(container, { parent: cur, key: token, length: 0 })
|
|
2368
|
+
}
|
|
2369
|
+
InternalRecord.assignProperty(cur, token, container)
|
|
2370
|
+
cur = container
|
|
2371
|
+
}
|
|
2369
2372
|
}
|
|
2370
|
-
}
|
|
2373
|
+
}
|
|
2371
2374
|
})
|
|
2375
|
+
|
|
2376
|
+
// Children are created after their parents, so materializing in reverse
|
|
2377
|
+
// creation order replaces every nested container before its parent is copied
|
|
2378
|
+
for (const [builder, { key, length, parent }] of Array.from(indexed).reverse()) {
|
|
2379
|
+
// A later conflicting path may have replaced the container in its parent
|
|
2380
|
+
if (parent[key] === builder && length - Object.keys(builder).length <= MAX_ARRAY_HOLES) {
|
|
2381
|
+
InternalRecord.assignProperty(parent, key, Object.assign(new Array(length), builder))
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2372
2384
|
return out
|
|
2373
2385
|
}
|
|
2374
2386
|
|
package/src/Sink.ts
CHANGED
|
@@ -2177,13 +2177,24 @@ export const takeWhileFilterEffect = <In, Out, X, E, R>(
|
|
|
2177
2177
|
* @since 4.0.0
|
|
2178
2178
|
*/
|
|
2179
2179
|
export const takeUntil = <In>(predicate: Predicate<In>): Sink<Array<In>, In, In> =>
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
return
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2180
|
+
fromTransform((upstream) => {
|
|
2181
|
+
const out = Arr.empty<In>()
|
|
2182
|
+
return upstream.pipe(
|
|
2183
|
+
Effect.flatMap((arr) => {
|
|
2184
|
+
for (let i = 0; i < arr.length; i++) {
|
|
2185
|
+
out.push(arr[i])
|
|
2186
|
+
if (predicate(arr[i])) {
|
|
2187
|
+
const leftover: NonEmptyReadonlyArray<In> | undefined = (i + 1) < arr.length
|
|
2188
|
+
? arr.slice(i + 1) as Arr.NonEmptyArray<In>
|
|
2189
|
+
: undefined
|
|
2190
|
+
return Cause.done([out, leftover] as const)
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
return Effect.void
|
|
2194
|
+
}),
|
|
2195
|
+
Effect.forever({ disableYield: true }),
|
|
2196
|
+
Pull.catchDone((end) => Effect.succeed<End<Array<In>, In>>(end ?? [out]))
|
|
2197
|
+
)
|
|
2187
2198
|
})
|
|
2188
2199
|
|
|
2189
2200
|
/**
|
|
@@ -2201,17 +2212,33 @@ export const takeUntil = <In>(predicate: Predicate<In>): Sink<Array<In>, In, In>
|
|
|
2201
2212
|
export const takeUntilEffect = <In, E, R>(
|
|
2202
2213
|
predicate: (input: In) => Effect.Effect<boolean, E, R>
|
|
2203
2214
|
): Sink<Array<In>, In, In, E, R> =>
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
+
fromTransform((upstream) => {
|
|
2216
|
+
const out = Arr.empty<In>()
|
|
2217
|
+
let leftover: NonEmptyReadonlyArray<In> | undefined = undefined
|
|
2218
|
+
return upstream.pipe(
|
|
2219
|
+
Effect.flatMap((arr) => {
|
|
2220
|
+
let i = 0
|
|
2221
|
+
return Effect.whileLoop({
|
|
2222
|
+
while: () => i < arr.length,
|
|
2223
|
+
body: () => {
|
|
2224
|
+
const input = arr[i++]
|
|
2225
|
+
return Effect.flatMap(predicate(input), (matched) => {
|
|
2226
|
+
out.push(input)
|
|
2227
|
+
if (!matched) {
|
|
2228
|
+
return Effect.void
|
|
2229
|
+
}
|
|
2230
|
+
if (i < arr.length) {
|
|
2231
|
+
leftover = arr.slice(i) as Arr.NonEmptyArray<In>
|
|
2232
|
+
}
|
|
2233
|
+
return Cause.done()
|
|
2234
|
+
})
|
|
2235
|
+
},
|
|
2236
|
+
step: constVoid
|
|
2237
|
+
})
|
|
2238
|
+
}),
|
|
2239
|
+
Effect.forever({ disableYield: true }),
|
|
2240
|
+
Pull.catchDone(() => Effect.succeed([out, leftover] as const))
|
|
2241
|
+
)
|
|
2215
2242
|
})
|
|
2216
2243
|
|
|
2217
2244
|
/**
|
package/src/Stdio.ts
CHANGED
|
@@ -79,6 +79,12 @@ export interface Stdio {
|
|
|
79
79
|
* @since 4.0.0
|
|
80
80
|
*/
|
|
81
81
|
readonly stdoutIsTerminal: Effect.Effect<boolean>
|
|
82
|
+
/**
|
|
83
|
+
* Whether standard error is attached to a terminal.
|
|
84
|
+
*
|
|
85
|
+
* @since 4.0.0
|
|
86
|
+
*/
|
|
87
|
+
readonly stderrIsTerminal: Effect.Effect<boolean>
|
|
82
88
|
stdout(options?: {
|
|
83
89
|
readonly endOnDone?: boolean | undefined
|
|
84
90
|
}): Sink.Sink<void, string | Uint8Array, never, PlatformError>
|
|
@@ -127,12 +133,13 @@ export const Stdio: Context.Service<Stdio, Stdio> = Context.Service<Stdio>(TypeI
|
|
|
127
133
|
*/
|
|
128
134
|
export const make = (
|
|
129
135
|
options:
|
|
130
|
-
& Omit<Stdio, TypeId | "stdinIsTerminal" | "stdoutIsTerminal">
|
|
131
|
-
& Partial<Pick<Stdio, "stdinIsTerminal" | "stdoutIsTerminal">>
|
|
136
|
+
& Omit<Stdio, TypeId | "stdinIsTerminal" | "stdoutIsTerminal" | "stderrIsTerminal">
|
|
137
|
+
& Partial<Pick<Stdio, "stdinIsTerminal" | "stdoutIsTerminal" | "stderrIsTerminal">>
|
|
132
138
|
): Stdio => ({
|
|
133
139
|
[TypeId]: TypeId,
|
|
134
140
|
stdinIsTerminal: Effect.succeed(false),
|
|
135
141
|
stdoutIsTerminal: Effect.succeed(false),
|
|
142
|
+
stderrIsTerminal: Effect.succeed(false),
|
|
136
143
|
...options
|
|
137
144
|
})
|
|
138
145
|
|
package/src/Stream.ts
CHANGED
|
@@ -20767,6 +20767,9 @@ export const mkUint8Array = <E, R>(self: Stream<Uint8Array, E, R>): Effect.Effec
|
|
|
20767
20767
|
*
|
|
20768
20768
|
* See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream.
|
|
20769
20769
|
*
|
|
20770
|
+
* When `signal` aborts, the stream is interrupted even if the reader has
|
|
20771
|
+
* stopped pulling, and the `ReadableStream` closes.
|
|
20772
|
+
*
|
|
20770
20773
|
* **Example** (Converting to a ReadableStream with services)
|
|
20771
20774
|
*
|
|
20772
20775
|
* ```ts import.meta.vitest
|
|
@@ -20774,7 +20777,7 @@ export const mkUint8Array = <E, R>(self: Stream<Uint8Array, E, R>): Effect.Effec
|
|
|
20774
20777
|
*
|
|
20775
20778
|
* const stream = Stream.make(1, 2, 3, 4, 5)
|
|
20776
20779
|
* const readableStream = Stream.toReadableStreamWith(stream, Context.empty())
|
|
20777
|
-
* const values = await Array.fromAsync(readableStream)
|
|
20780
|
+
* const values = await globalThis.Array.fromAsync(readableStream)
|
|
20778
20781
|
* values // => [ 1, 2, 3, 4, 5 ]
|
|
20779
20782
|
* ```
|
|
20780
20783
|
*
|
|
@@ -20795,6 +20798,9 @@ export const toReadableStreamWith: {
|
|
|
20795
20798
|
*
|
|
20796
20799
|
* See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream.
|
|
20797
20800
|
*
|
|
20801
|
+
* When `signal` aborts, the stream is interrupted even if the reader has
|
|
20802
|
+
* stopped pulling, and the `ReadableStream` closes.
|
|
20803
|
+
*
|
|
20798
20804
|
* **Example** (Converting to a ReadableStream with services)
|
|
20799
20805
|
*
|
|
20800
20806
|
* ```ts import.meta.vitest
|
|
@@ -20802,7 +20808,7 @@ export const toReadableStreamWith: {
|
|
|
20802
20808
|
*
|
|
20803
20809
|
* const stream = Stream.make(1, 2, 3, 4, 5)
|
|
20804
20810
|
* const readableStream = Stream.toReadableStreamWith(stream, Context.empty())
|
|
20805
|
-
* const values = await Array.fromAsync(readableStream)
|
|
20811
|
+
* const values = await globalThis.Array.fromAsync(readableStream)
|
|
20806
20812
|
* values // => [ 1, 2, 3, 4, 5 ]
|
|
20807
20813
|
* ```
|
|
20808
20814
|
*
|
|
@@ -20812,7 +20818,10 @@ export const toReadableStreamWith: {
|
|
|
20812
20818
|
*/
|
|
20813
20819
|
<A, XR>(
|
|
20814
20820
|
context: Context.Context<XR>,
|
|
20815
|
-
options?: {
|
|
20821
|
+
options?: {
|
|
20822
|
+
readonly strategy?: QueuingStrategy<A> | undefined
|
|
20823
|
+
readonly signal?: AbortSignal | undefined
|
|
20824
|
+
}
|
|
20816
20825
|
): <E, R extends XR>(self: Stream<A, E, R>) => ReadableStream<A>
|
|
20817
20826
|
/**
|
|
20818
20827
|
* Converts the stream to a `ReadableStream` using the provided services.
|
|
@@ -20826,6 +20835,9 @@ export const toReadableStreamWith: {
|
|
|
20826
20835
|
*
|
|
20827
20836
|
* See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream.
|
|
20828
20837
|
*
|
|
20838
|
+
* When `signal` aborts, the stream is interrupted even if the reader has
|
|
20839
|
+
* stopped pulling, and the `ReadableStream` closes.
|
|
20840
|
+
*
|
|
20829
20841
|
* **Example** (Converting to a ReadableStream with services)
|
|
20830
20842
|
*
|
|
20831
20843
|
* ```ts import.meta.vitest
|
|
@@ -20833,7 +20845,7 @@ export const toReadableStreamWith: {
|
|
|
20833
20845
|
*
|
|
20834
20846
|
* const stream = Stream.make(1, 2, 3, 4, 5)
|
|
20835
20847
|
* const readableStream = Stream.toReadableStreamWith(stream, Context.empty())
|
|
20836
|
-
* const values = await Array.fromAsync(readableStream)
|
|
20848
|
+
* const values = await globalThis.Array.fromAsync(readableStream)
|
|
20837
20849
|
* values // => [ 1, 2, 3, 4, 5 ]
|
|
20838
20850
|
* ```
|
|
20839
20851
|
*
|
|
@@ -20844,18 +20856,28 @@ export const toReadableStreamWith: {
|
|
|
20844
20856
|
<A, E, XR, R extends XR>(
|
|
20845
20857
|
self: Stream<A, E, R>,
|
|
20846
20858
|
context: Context.Context<XR>,
|
|
20847
|
-
options?: {
|
|
20859
|
+
options?: {
|
|
20860
|
+
readonly strategy?: QueuingStrategy<A> | undefined
|
|
20861
|
+
readonly signal?: AbortSignal | undefined
|
|
20862
|
+
}
|
|
20848
20863
|
): ReadableStream<A>
|
|
20849
20864
|
} = dual(
|
|
20850
20865
|
(args) => isStream(args[0]),
|
|
20851
20866
|
<A, E, XR, R extends XR>(
|
|
20852
20867
|
self: Stream<A, E, R>,
|
|
20853
20868
|
context: Context.Context<XR>,
|
|
20854
|
-
options?: {
|
|
20869
|
+
options?: {
|
|
20870
|
+
readonly strategy?: QueuingStrategy<A> | undefined
|
|
20871
|
+
readonly signal?: AbortSignal | undefined
|
|
20872
|
+
}
|
|
20855
20873
|
): ReadableStream<A> => {
|
|
20856
20874
|
let currentResolve: (() => void) | undefined = undefined
|
|
20857
20875
|
let fiber: Fiber.Fiber<void, E> | undefined = undefined
|
|
20876
|
+
let cancelled = false
|
|
20858
20877
|
const latch = Latch.makeUnsafe(false)
|
|
20878
|
+
const signal = options?.signal
|
|
20879
|
+
// Interrupting the fiber directly also stops a consumer waiting for a pull.
|
|
20880
|
+
const onAbort = () => fiber!.interruptUnsafe()
|
|
20859
20881
|
|
|
20860
20882
|
return new ReadableStream<A>({
|
|
20861
20883
|
start(controller) {
|
|
@@ -20872,12 +20894,18 @@ export const toReadableStreamWith: {
|
|
|
20872
20894
|
context
|
|
20873
20895
|
))
|
|
20874
20896
|
fiber.addObserver((exit) => {
|
|
20875
|
-
|
|
20897
|
+
signal?.removeEventListener("abort", onAbort)
|
|
20898
|
+
if (cancelled) return
|
|
20899
|
+
if (exit._tag === "Failure" && signal?.aborted !== true) {
|
|
20876
20900
|
controller.error(Cause.squash(exit.cause))
|
|
20877
20901
|
} else {
|
|
20878
20902
|
controller.close()
|
|
20879
20903
|
}
|
|
20880
20904
|
})
|
|
20905
|
+
if (signal !== undefined && fiber.pollUnsafe() === undefined) {
|
|
20906
|
+
if (signal.aborted) onAbort()
|
|
20907
|
+
else signal.addEventListener("abort", onAbort, { once: true })
|
|
20908
|
+
}
|
|
20881
20909
|
},
|
|
20882
20910
|
pull() {
|
|
20883
20911
|
return new Promise<void>((resolve) => {
|
|
@@ -20887,6 +20915,7 @@ export const toReadableStreamWith: {
|
|
|
20887
20915
|
},
|
|
20888
20916
|
cancel() {
|
|
20889
20917
|
if (!fiber) return
|
|
20918
|
+
cancelled = true
|
|
20890
20919
|
return Effect.runPromise(Effect.asVoid(Fiber.interrupt(fiber)))
|
|
20891
20920
|
}
|
|
20892
20921
|
}, options?.strategy)
|
|
@@ -20906,7 +20935,7 @@ export const toReadableStreamWith: {
|
|
|
20906
20935
|
* import { Stream } from "effect"
|
|
20907
20936
|
*
|
|
20908
20937
|
* const readableStream = Stream.toReadableStream(Stream.make(1, 2, 3))
|
|
20909
|
-
* const values = await Array.fromAsync(readableStream)
|
|
20938
|
+
* const values = await globalThis.Array.fromAsync(readableStream)
|
|
20910
20939
|
* values // => [ 1, 2, 3 ]
|
|
20911
20940
|
* ```
|
|
20912
20941
|
*
|
|
@@ -20928,7 +20957,7 @@ export const toReadableStream: {
|
|
|
20928
20957
|
* import { Stream } from "effect"
|
|
20929
20958
|
*
|
|
20930
20959
|
* const readableStream = Stream.toReadableStream(Stream.make(1, 2, 3))
|
|
20931
|
-
* const values = await Array.fromAsync(readableStream)
|
|
20960
|
+
* const values = await globalThis.Array.fromAsync(readableStream)
|
|
20932
20961
|
* values // => [ 1, 2, 3 ]
|
|
20933
20962
|
* ```
|
|
20934
20963
|
*
|
|
@@ -20952,7 +20981,7 @@ export const toReadableStream: {
|
|
|
20952
20981
|
* import { Stream } from "effect"
|
|
20953
20982
|
*
|
|
20954
20983
|
* const readableStream = Stream.toReadableStream(Stream.make(1, 2, 3))
|
|
20955
|
-
* const values = await Array.fromAsync(readableStream)
|
|
20984
|
+
* const values = await globalThis.Array.fromAsync(readableStream)
|
|
20956
20985
|
* values // => [ 1, 2, 3 ]
|
|
20957
20986
|
* ```
|
|
20958
20987
|
*
|
|
@@ -21132,7 +21161,7 @@ export const toReadableStreamEffect: {
|
|
|
21132
21161
|
* const stream = Stream.make(1, 2, 3)
|
|
21133
21162
|
* const iterable = Stream.toAsyncIterableWith(stream, Context.empty())
|
|
21134
21163
|
*
|
|
21135
|
-
* await Array.fromAsync(iterable) // => [1, 2, 3]
|
|
21164
|
+
* await globalThis.Array.fromAsync(iterable) // => [1, 2, 3]
|
|
21136
21165
|
* ```
|
|
21137
21166
|
*
|
|
21138
21167
|
* @stability stable
|
|
@@ -21156,7 +21185,7 @@ export const toAsyncIterableWith: {
|
|
|
21156
21185
|
* const stream = Stream.make(1, 2, 3)
|
|
21157
21186
|
* const iterable = Stream.toAsyncIterableWith(stream, Context.empty())
|
|
21158
21187
|
*
|
|
21159
|
-
* await Array.fromAsync(iterable) // => [1, 2, 3]
|
|
21188
|
+
* await globalThis.Array.fromAsync(iterable) // => [1, 2, 3]
|
|
21160
21189
|
* ```
|
|
21161
21190
|
*
|
|
21162
21191
|
* @stability stable
|
|
@@ -21180,7 +21209,7 @@ export const toAsyncIterableWith: {
|
|
|
21180
21209
|
* const stream = Stream.make(1, 2, 3)
|
|
21181
21210
|
* const iterable = Stream.toAsyncIterableWith(stream, Context.empty())
|
|
21182
21211
|
*
|
|
21183
|
-
* await Array.fromAsync(iterable) // => [1, 2, 3]
|
|
21212
|
+
* await globalThis.Array.fromAsync(iterable) // => [1, 2, 3]
|
|
21184
21213
|
* ```
|
|
21185
21214
|
*
|
|
21186
21215
|
* @stability stable
|
|
@@ -21282,7 +21311,7 @@ export const toAsyncIterableWith: {
|
|
|
21282
21311
|
*
|
|
21283
21312
|
* const program = Effect.gen(function*() {
|
|
21284
21313
|
* const iterable = yield* Stream.toAsyncIterableEffect(stream)
|
|
21285
|
-
* return yield* Effect.promise(() => Array.fromAsync(iterable))
|
|
21314
|
+
* return yield* Effect.promise(() => globalThis.Array.fromAsync(iterable))
|
|
21286
21315
|
* })
|
|
21287
21316
|
*
|
|
21288
21317
|
* await Effect.runPromise(program) // => [1, 2, 3]
|
|
@@ -21308,7 +21337,7 @@ export const toAsyncIterableEffect = <A, E, R>(self: Stream<A, E, R>): Effect.Ef
|
|
|
21308
21337
|
*
|
|
21309
21338
|
* const stream = Stream.make(1, 2, 3)
|
|
21310
21339
|
*
|
|
21311
|
-
* await Array.fromAsync(Stream.toAsyncIterable(stream)) // => [1, 2, 3]
|
|
21340
|
+
* await globalThis.Array.fromAsync(Stream.toAsyncIterable(stream)) // => [1, 2, 3]
|
|
21312
21341
|
* ```
|
|
21313
21342
|
*
|
|
21314
21343
|
* @stability stable
|
package/src/Utils.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @since 2.0.0
|
|
13
13
|
*/
|
|
14
14
|
import type { Kind, TypeLambda } from "./HKT.ts"
|
|
15
|
-
import { getStackTraceLimit } from "./internal/stackTraceLimit.ts"
|
|
15
|
+
import { getStackTraceLimit, setStackTraceLimit } from "./internal/stackTraceLimit.ts"
|
|
16
16
|
import type * as Types from "./Types.ts"
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -209,10 +209,13 @@ const pickInternalCall = (): <A>(body: () => A) => A => {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
const limit = getStackTraceLimit()
|
|
213
|
+
if (limit === 0) return forced[InternalTypeId]
|
|
214
|
+
// Only the callback and internal call frames are needed for detection.
|
|
215
|
+
setStackTraceLimit(2)
|
|
216
|
+
const error = standard[InternalTypeId](() => new Error())
|
|
217
|
+
setStackTraceLimit(limit)
|
|
218
|
+
return error.stack?.includes(InternalTypeId) === true ? standard[InternalTypeId] : forced[InternalTypeId]
|
|
216
219
|
}
|
|
217
220
|
|
|
218
221
|
/** @internal */
|
|
@@ -14,8 +14,8 @@ import type * as JsonSchema from "../JsonSchema.ts"
|
|
|
14
14
|
import * as Rec from "../Record.ts"
|
|
15
15
|
import * as Schema from "../Schema.ts"
|
|
16
16
|
import * as InternalStructuredOutput from "./internal/structured-output.ts"
|
|
17
|
-
import * as LanguageModel from "./LanguageModel.ts"
|
|
18
|
-
import * as OpenAiStructuredOutput from "./OpenAiStructuredOutput.ts"
|
|
17
|
+
import type * as LanguageModel from "./LanguageModel.ts"
|
|
18
|
+
import type * as OpenAiStructuredOutput from "./OpenAiStructuredOutput.ts"
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Converts a `Schema.Codec` to Anthropic structured-output JSON Schema and a
|
package/src/ai/Chat.ts
CHANGED
|
@@ -228,7 +228,7 @@ export interface Chat {
|
|
|
228
228
|
<Options extends NoExcessProperties<LanguageModel.GenerateTextOptions<{}>, Options>>(
|
|
229
229
|
options: Options & { readonly toolkit?: undefined } & LanguageModel.GenerateTextOptions<{}>
|
|
230
230
|
): Effect.Effect<
|
|
231
|
-
LanguageModel.GenerateTextResponse<{}
|
|
231
|
+
LanguageModel.GenerateTextResponse<{}, LanguageModel.ExtractToolParametersModeWithoutToolkit<Options>>,
|
|
232
232
|
LanguageModel.ExtractError<Options>,
|
|
233
233
|
LanguageModel.LanguageModel | LanguageModel.ExtractServices<Options>
|
|
234
234
|
>
|
|
@@ -310,7 +310,7 @@ export interface Chat {
|
|
|
310
310
|
<Options extends NoExcessProperties<LanguageModel.GenerateTextOptions<{}>, Options>>(
|
|
311
311
|
options: Options & { readonly toolkit?: undefined } & LanguageModel.GenerateTextOptions<{}>
|
|
312
312
|
): Stream.Stream<
|
|
313
|
-
Response.StreamPart<{}
|
|
313
|
+
Response.StreamPart<{}, LanguageModel.ExtractToolParametersModeWithoutToolkit<Options>>,
|
|
314
314
|
LanguageModel.ExtractError<Options>,
|
|
315
315
|
LanguageModel.LanguageModel | LanguageModel.ExtractServices<Options>
|
|
316
316
|
>
|