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/ai/LanguageModel.ts
CHANGED
|
@@ -122,7 +122,7 @@ export interface LanguageModel {
|
|
|
122
122
|
<Options extends NoExcessProperties<GenerateTextOptionsWithoutToolkit, Options>>(
|
|
123
123
|
options: Options & GenerateTextOptionsWithoutToolkit
|
|
124
124
|
): Effect.Effect<
|
|
125
|
-
GenerateTextResponse<{}
|
|
125
|
+
GenerateTextResponse<{}, ExtractToolParametersModeWithoutToolkit<Options>>,
|
|
126
126
|
ExtractError<Options>,
|
|
127
127
|
ExtractServices<Options>
|
|
128
128
|
>
|
|
@@ -181,7 +181,7 @@ export interface LanguageModel {
|
|
|
181
181
|
<Options extends NoExcessProperties<GenerateTextOptionsWithoutToolkit, Options>>(
|
|
182
182
|
options: Options & GenerateTextOptionsWithoutToolkit
|
|
183
183
|
): Stream.Stream<
|
|
184
|
-
Response.StreamPart<{}
|
|
184
|
+
Response.StreamPart<{}, ExtractToolParametersModeWithoutToolkit<Options>>,
|
|
185
185
|
ExtractError<Options>,
|
|
186
186
|
ExtractServices<Options>
|
|
187
187
|
>
|
|
@@ -312,6 +312,22 @@ export interface GenerateTextOptions<Tools extends Record<string, Tool.Any>> {
|
|
|
312
312
|
* resolver execution yourself.
|
|
313
313
|
*/
|
|
314
314
|
readonly disableToolCallResolution?: boolean | undefined
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Controls tool call validation when `disableToolCallResolution` is `true`.
|
|
318
|
+
* Defaults to `"strict"`, which validates tool names and encoded parameters.
|
|
319
|
+
*
|
|
320
|
+
* **Details**
|
|
321
|
+
*
|
|
322
|
+
* `"deferred"` returns model-generated calls with `unknown` parameters for
|
|
323
|
+
* the caller to validate, including undeclared names and calls without a
|
|
324
|
+
* toolkit. Provider-executed calls and other response parts remain validated.
|
|
325
|
+
* Providers must support this option to return undeclared tool calls.
|
|
326
|
+
*
|
|
327
|
+
* Has no effect when resolution is enabled; `Toolkit` validates parameters
|
|
328
|
+
* according to each tool's `failureMode`.
|
|
329
|
+
*/
|
|
330
|
+
readonly toolCallValidation?: "strict" | "deferred" | undefined
|
|
315
331
|
}
|
|
316
332
|
|
|
317
333
|
type GenerateTextOptionsWithoutToolkit = Omit<GenerateTextOptions<{}>, "toolkit"> & {
|
|
@@ -589,18 +605,32 @@ export type ExtractTools<Options> = Options extends {
|
|
|
589
605
|
: {}
|
|
590
606
|
|
|
591
607
|
/**
|
|
592
|
-
* Resolves to `"
|
|
593
|
-
*
|
|
608
|
+
* Resolves to `"deferred"` when tool call resolution may be disabled with
|
|
609
|
+
* deferred tool call validation. Otherwise resolves to `"encoded"` when tool
|
|
610
|
+
* call resolution is disabled and `"opaque"` when it may be enabled.
|
|
594
611
|
*
|
|
595
612
|
* @stability unstable
|
|
596
613
|
* @category utility types
|
|
597
614
|
* @since 4.0.0
|
|
598
615
|
*/
|
|
599
|
-
export type ExtractToolParametersMode<Options> =
|
|
600
|
-
|
|
601
|
-
} ? "encoded"
|
|
616
|
+
export type ExtractToolParametersMode<Options> = "deferred" extends Options["toolCallValidation" & keyof Options] ?
|
|
617
|
+
true extends Options["disableToolCallResolution" & keyof Options] ? "deferred" : "opaque"
|
|
618
|
+
: Options extends { readonly disableToolCallResolution: true } ? "encoded"
|
|
602
619
|
: "opaque"
|
|
603
620
|
|
|
621
|
+
/**
|
|
622
|
+
* Resolves the tool parameters mode for requests without a toolkit:
|
|
623
|
+
* `"deferred"` when tool call validation may be deferred, otherwise
|
|
624
|
+
* `"decoded"`.
|
|
625
|
+
*
|
|
626
|
+
* @stability unstable
|
|
627
|
+
* @category utility types
|
|
628
|
+
* @since 4.0.4
|
|
629
|
+
*/
|
|
630
|
+
export type ExtractToolParametersModeWithoutToolkit<Options> = "deferred" extends ExtractToolParametersMode<Options>
|
|
631
|
+
? "deferred"
|
|
632
|
+
: "decoded"
|
|
633
|
+
|
|
604
634
|
type ExtractErrorFromToolkitOption<ToolkitValue, DisableToolCallResolution extends boolean> = ToolkitValue extends
|
|
605
635
|
Toolkit.WithHandler<infer Tools> ?
|
|
606
636
|
| AiError.AiError
|
|
@@ -785,6 +815,12 @@ export interface ProviderOptions {
|
|
|
785
815
|
* prompt after the provider rejected the incremental request.
|
|
786
816
|
*/
|
|
787
817
|
readonly incrementalFallback?: boolean | undefined
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Defaults to `"strict"`. With `"deferred"`, return calls to tools absent
|
|
821
|
+
* from `tools` with unchanged parameters instead of `ToolNotFoundError`.
|
|
822
|
+
*/
|
|
823
|
+
readonly toolCallValidation?: "strict" | "deferred" | undefined
|
|
788
824
|
}
|
|
789
825
|
|
|
790
826
|
/**
|
|
@@ -863,7 +899,7 @@ export const make: (params: {
|
|
|
863
899
|
>(
|
|
864
900
|
options: Options & GenerateTextOptions<Tools>
|
|
865
901
|
): Effect.Effect<
|
|
866
|
-
GenerateTextResponse<Tools>,
|
|
902
|
+
GenerateTextResponse<Tools, Response.ToolParametersMode>,
|
|
867
903
|
ExtractError<Options>,
|
|
868
904
|
ExtractServices<Options>
|
|
869
905
|
> =>
|
|
@@ -1071,6 +1107,10 @@ export const make: (params: {
|
|
|
1071
1107
|
const toolChoice = options.toolChoice ?? "auto"
|
|
1072
1108
|
const concurrency = options.concurrency ?? "unbounded"
|
|
1073
1109
|
annotateRequestOptions(providerOptions, toolChoice, concurrency)
|
|
1110
|
+
const deferToolCallValidation = isToolCallValidationDeferred(options)
|
|
1111
|
+
if (deferToolCallValidation) {
|
|
1112
|
+
providerOptions.toolCallValidation = "deferred"
|
|
1113
|
+
}
|
|
1074
1114
|
|
|
1075
1115
|
const generateWithNonIncrementalFallback = () => {
|
|
1076
1116
|
const requestOptions: ProviderOptions = {
|
|
@@ -1120,7 +1160,7 @@ export const make: (params: {
|
|
|
1120
1160
|
}
|
|
1121
1161
|
}
|
|
1122
1162
|
const ResponseSchema = Schema.mutable(
|
|
1123
|
-
Schema.Array(Response.Part(Toolkit.empty))
|
|
1163
|
+
Schema.Array(withUndeclaredToolCalls(Response.Part(Toolkit.empty), deferToolCallValidation))
|
|
1124
1164
|
)
|
|
1125
1165
|
const rawContent = yield* generateWithNonIncrementalFallback()
|
|
1126
1166
|
const content = yield* Schema.decodeEffect(ResponseSchema)(rawContent)
|
|
@@ -1158,7 +1198,7 @@ export const make: (params: {
|
|
|
1158
1198
|
}
|
|
1159
1199
|
}
|
|
1160
1200
|
const ResponseSchema = Schema.mutable(
|
|
1161
|
-
Schema.Array(Response.Part(Toolkit.empty))
|
|
1201
|
+
Schema.Array(withUndeclaredToolCalls(Response.Part(Toolkit.empty), deferToolCallValidation))
|
|
1162
1202
|
)
|
|
1163
1203
|
const rawContent = yield* generateWithNonIncrementalFallback()
|
|
1164
1204
|
const content = yield* Schema.decodeEffect(ResponseSchema)(rawContent)
|
|
@@ -1232,10 +1272,13 @@ export const make: (params: {
|
|
|
1232
1272
|
}
|
|
1233
1273
|
}
|
|
1234
1274
|
|
|
1235
|
-
const ResponseSchema = Schema.mutable(Schema.Array(
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1275
|
+
const ResponseSchema = Schema.mutable(Schema.Array(withUndeclaredToolCalls(
|
|
1276
|
+
Response.Part(
|
|
1277
|
+
options.disableToolCallResolution === true && !deferToolCallValidation
|
|
1278
|
+
? makeToolkitWithEncodedParameters(toolkit)
|
|
1279
|
+
: makeToolkitWithOpaqueParameters(toolkit)
|
|
1280
|
+
),
|
|
1281
|
+
deferToolCallValidation
|
|
1239
1282
|
)))
|
|
1240
1283
|
|
|
1241
1284
|
// If tool call resolution is disabled, return the response without
|
|
@@ -1243,6 +1286,9 @@ export const make: (params: {
|
|
|
1243
1286
|
if (options.disableToolCallResolution === true) {
|
|
1244
1287
|
const rawContent = yield* generateWithNonIncrementalFallback()
|
|
1245
1288
|
const content = yield* Schema.decodeEffect(ResponseSchema)(rawContent)
|
|
1289
|
+
if (deferToolCallValidation) {
|
|
1290
|
+
yield* validateProviderExecutedToolCalls(makeToolkitWithEncodedParameters(toolkit), rawContent)
|
|
1291
|
+
}
|
|
1246
1292
|
if (tracker) {
|
|
1247
1293
|
const responseMetadata = content.find((part) => part.type === "response-metadata")
|
|
1248
1294
|
if (Predicate.isNotUndefined(responseMetadata) && Predicate.isNotUndefined(responseMetadata.id)) {
|
|
@@ -1324,6 +1370,10 @@ export const make: (params: {
|
|
|
1324
1370
|
const toolChoice = options.toolChoice ?? "auto"
|
|
1325
1371
|
const concurrency = options.concurrency ?? "unbounded"
|
|
1326
1372
|
annotateRequestOptions(providerOptions, toolChoice, concurrency)
|
|
1373
|
+
const deferToolCallValidation = isToolCallValidationDeferred(options)
|
|
1374
|
+
if (deferToolCallValidation) {
|
|
1375
|
+
providerOptions.toolCallValidation = "deferred"
|
|
1376
|
+
}
|
|
1327
1377
|
|
|
1328
1378
|
const streamWithNonIncrementalFallback = () => {
|
|
1329
1379
|
const requestOptions: ProviderOptions = {
|
|
@@ -1383,7 +1433,9 @@ export const make: (params: {
|
|
|
1383
1433
|
providerOptions.incrementalPrompt = prepared.value.prompt
|
|
1384
1434
|
}
|
|
1385
1435
|
}
|
|
1386
|
-
const schema = Schema.NonEmptyArray(
|
|
1436
|
+
const schema = Schema.NonEmptyArray(
|
|
1437
|
+
withUndeclaredToolCalls(Response.StreamPart(Toolkit.empty), deferToolCallValidation)
|
|
1438
|
+
)
|
|
1387
1439
|
const decodeParts = Schema.decodeEffect(schema)
|
|
1388
1440
|
return pipe(
|
|
1389
1441
|
streamWithNonIncrementalFallback(),
|
|
@@ -1432,7 +1484,9 @@ export const make: (params: {
|
|
|
1432
1484
|
providerOptions.incrementalPrompt = prepared.value.prompt
|
|
1433
1485
|
}
|
|
1434
1486
|
}
|
|
1435
|
-
const schema = Schema.NonEmptyArray(
|
|
1487
|
+
const schema = Schema.NonEmptyArray(
|
|
1488
|
+
withUndeclaredToolCalls(Response.StreamPart(Toolkit.empty), deferToolCallValidation)
|
|
1489
|
+
)
|
|
1436
1490
|
const decodeParts = Schema.decodeEffect(schema)
|
|
1437
1491
|
return pipe(
|
|
1438
1492
|
streamWithNonIncrementalFallback(),
|
|
@@ -1535,19 +1589,26 @@ export const make: (params: {
|
|
|
1535
1589
|
}
|
|
1536
1590
|
}
|
|
1537
1591
|
|
|
1538
|
-
const ResponseSchema = Schema.NonEmptyArray(
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1592
|
+
const ResponseSchema = Schema.NonEmptyArray(withUndeclaredToolCalls(
|
|
1593
|
+
Response.StreamPart(
|
|
1594
|
+
options.disableToolCallResolution === true && !deferToolCallValidation
|
|
1595
|
+
? makeToolkitWithEncodedParameters(toolkit)
|
|
1596
|
+
: makeToolkitWithOpaqueParameters(toolkit)
|
|
1597
|
+
),
|
|
1598
|
+
deferToolCallValidation
|
|
1542
1599
|
))
|
|
1543
1600
|
const decodeParts = Schema.decodeEffect(ResponseSchema)
|
|
1544
1601
|
|
|
1545
1602
|
// If tool call resolution is disabled, return the response without
|
|
1546
1603
|
// resolving the tool calls that were generated
|
|
1547
1604
|
if (options.disableToolCallResolution === true) {
|
|
1605
|
+
const encodedToolkit = deferToolCallValidation ? makeToolkitWithEncodedParameters(toolkit) : undefined
|
|
1548
1606
|
return streamWithNonIncrementalFallback().pipe(
|
|
1549
1607
|
Stream.mapArrayEffect((parts) =>
|
|
1550
1608
|
decodeParts(parts).pipe(
|
|
1609
|
+
encodedToolkit
|
|
1610
|
+
? Effect.tap(() => validateProviderExecutedToolCalls(encodedToolkit, parts))
|
|
1611
|
+
: identity,
|
|
1551
1612
|
tracker ?
|
|
1552
1613
|
Effect.tap((decodedParts) => {
|
|
1553
1614
|
for (const part of decodedParts) {
|
|
@@ -1812,7 +1873,7 @@ export const generateText: {
|
|
|
1812
1873
|
>(
|
|
1813
1874
|
options: Options & GenerateTextOptionsWithoutToolkit
|
|
1814
1875
|
): Effect.Effect<
|
|
1815
|
-
GenerateTextResponse<{}
|
|
1876
|
+
GenerateTextResponse<{}, ExtractToolParametersModeWithoutToolkit<Options>>,
|
|
1816
1877
|
ExtractError<Options>,
|
|
1817
1878
|
LanguageModel | ExtractServices<Options>
|
|
1818
1879
|
>
|
|
@@ -1962,7 +2023,7 @@ export const streamText: {
|
|
|
1962
2023
|
>(
|
|
1963
2024
|
options: Options & GenerateTextOptionsWithoutToolkit
|
|
1964
2025
|
): Stream.Stream<
|
|
1965
|
-
Response.StreamPart<{}
|
|
2026
|
+
Response.StreamPart<{}, ExtractToolParametersModeWithoutToolkit<Options>>,
|
|
1966
2027
|
ExtractError<Options>,
|
|
1967
2028
|
ExtractServices<Options> | LanguageModel
|
|
1968
2029
|
>
|
|
@@ -2443,9 +2504,20 @@ const makeToolkitWithOpaqueParameters = <Tools extends Record<string, Tool.Any>>
|
|
|
2443
2504
|
...Object.values(toolkit.tools).map((tool) => withParameterMode(tool, "opaque"))
|
|
2444
2505
|
)
|
|
2445
2506
|
|
|
2507
|
+
const isToolCallValidationDeferred = (options: GenerateTextOptions<any>): boolean =>
|
|
2508
|
+
options.disableToolCallResolution === true && options.toolCallValidation === "deferred"
|
|
2509
|
+
|
|
2510
|
+
const UndeclaredToolCallPart = Response.ToolCallPart("", Schema.Unknown).mapFields((fields) => ({
|
|
2511
|
+
...fields,
|
|
2512
|
+
name: Schema.String
|
|
2513
|
+
}))
|
|
2514
|
+
|
|
2515
|
+
const withUndeclaredToolCalls = <S extends Schema.Top>(partSchema: S, deferToolCallValidation: boolean): S =>
|
|
2516
|
+
deferToolCallValidation ? Schema.Union([partSchema, UndeclaredToolCallPart]) as any : partSchema
|
|
2517
|
+
|
|
2446
2518
|
// Provider-executed tools bypass Toolkit, so validate their parameters here.
|
|
2447
|
-
const validateProviderExecutedToolCalls =
|
|
2448
|
-
toolkit:
|
|
2519
|
+
const validateProviderExecutedToolCalls = (
|
|
2520
|
+
toolkit: { readonly tools: Record<string, Tool.Any> },
|
|
2449
2521
|
parts: ReadonlyArray<Response.PartEncoded | Response.StreamPartEncoded>
|
|
2450
2522
|
): Effect.Effect<void, Schema.SchemaError> =>
|
|
2451
2523
|
Effect.forEach(
|