effect 4.0.0-beta.31 → 4.0.0-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Array.d.ts +87 -86
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +47 -40
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +46 -45
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +35 -38
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +39 -32
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +32 -29
- package/dist/BigInt.js.map +1 -1
- package/dist/Chunk.d.ts +58 -57
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +20 -21
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +4 -1
- package/dist/Config.js.map +1 -1
- package/dist/Cron.d.ts +3 -6
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +8 -15
- package/dist/Cron.js.map +1 -1
- package/dist/DateTime.d.ts +16 -15
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +8 -8
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +7 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +7 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +26 -24
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +23 -22
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +7 -3
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +3 -4
- package/dist/Effect.js.map +1 -1
- package/dist/Fiber.d.ts +2 -1
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +9 -8
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +8 -7
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +20 -19
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +6 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +17 -16
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +10 -7
- package/dist/FileSystem.js.map +1 -1
- package/dist/Graph.d.ts +64 -64
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +53 -53
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +11 -5
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +3 -1
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +11 -11
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +12 -12
- package/dist/Iterable.js.map +1 -1
- package/dist/Latch.d.ts +69 -3
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +58 -0
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +84 -0
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +27 -0
- package/dist/Layer.js.map +1 -1
- package/dist/Number.d.ts +74 -18
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +34 -15
- package/dist/Number.js.map +1 -1
- package/dist/Option.d.ts +2 -0
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +183 -0
- package/dist/PartitionedSemaphore.d.ts.map +1 -0
- package/dist/PartitionedSemaphore.js +231 -0
- package/dist/PartitionedSemaphore.js.map +1 -0
- package/dist/PubSub.d.ts +5 -4
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +6 -5
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +4 -4
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +2 -2
- package/dist/Queue.js.map +1 -1
- package/dist/Record.d.ts +40 -40
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +16 -15
- package/dist/Record.js.map +1 -1
- package/dist/Scheduler.d.ts +25 -123
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +20 -123
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +30 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +28 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.js +6 -4
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +32 -27
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts +149 -53
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +137 -117
- package/dist/Semaphore.js.map +1 -1
- package/dist/ServiceMap.d.ts +26 -0
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +36 -21
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Stream.js +1 -1
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +114 -47
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +29 -47
- package/dist/String.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +1 -2
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +81 -115
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Terminal.d.ts +2 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +5 -4
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +26 -14
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +8 -4
- package/dist/Trie.js.map +1 -1
- package/dist/TxHashMap.d.ts +77 -59
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +25 -19
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxSemaphore.d.ts +162 -2
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +16 -2
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/index.d.ts +88 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -32
- package/dist/index.js.map +1 -1
- package/dist/internal/dateTime.js +9 -9
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +20 -89
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +2 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/option.js +6 -0
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/trie.js +3 -3
- package/dist/internal/trie.js.map +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +2 -2
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +8 -0
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +112 -11
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
- package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
- package/dist/unstable/ai/ResponseIdTracker.js +68 -0
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
- package/dist/unstable/ai/Tool.d.ts +14 -0
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +13 -0
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +4 -0
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +4 -0
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +2 -4
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +1 -3
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +3 -2
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +4 -3
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +3 -2
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +3 -3
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +2 -2
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +14 -12
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +4 -4
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +7 -7
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +1 -1
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +71 -67
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +8 -3
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +3 -2
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +7 -7
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +4 -3
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +3 -2
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +12 -12
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +2 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -3
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +9 -8
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +2 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +7 -6
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +19 -13
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +4 -4
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +9 -10
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +1 -4
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +5 -4
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +3 -4
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +5 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +3 -2
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +2 -1
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +2 -1
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -6
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +2 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +16 -15
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +3 -2
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +7 -7
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +2 -2
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -1
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +2 -1
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +14 -10
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +4 -3
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js +27 -15
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +5 -4
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +5 -6
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +81 -3
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +2 -2
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +1 -5
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +4 -2
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -3
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +4 -4
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +3 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +4 -1
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +3 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +2 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +5 -3
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +1 -1
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +6 -6
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +2 -1
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +19 -14
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +112 -105
- package/src/BigDecimal.ts +63 -66
- package/src/BigInt.ts +49 -41
- package/src/Chunk.ts +68 -63
- package/src/Config.ts +4 -1
- package/src/Cron.ts +10 -15
- package/src/DateTime.ts +16 -15
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +34 -33
- package/src/Effect.ts +12 -23
- package/src/Fiber.ts +2 -1
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +22 -22
- package/src/FileSystem.ts +25 -22
- package/src/Graph.ts +105 -105
- package/src/HashMap.ts +11 -5
- package/src/Iterable.ts +13 -13
- package/src/Latch.ts +85 -3
- package/src/Layer.ts +121 -0
- package/src/Number.ts +85 -26
- package/src/Option.ts +2 -0
- package/src/PartitionedSemaphore.ts +414 -0
- package/src/PubSub.ts +7 -6
- package/src/Queue.ts +6 -6
- package/src/Record.ts +52 -47
- package/src/Scheduler.ts +37 -126
- package/src/Schema.ts +49 -1
- package/src/SchemaGetter.ts +4 -4
- package/src/SchemaTransformation.ts +27 -27
- package/src/Semaphore.ts +271 -183
- package/src/ServiceMap.ts +83 -31
- package/src/Stream.ts +1 -1
- package/src/String.ts +122 -69
- package/src/SubscriptionRef.ts +96 -117
- package/src/Terminal.ts +2 -1
- package/src/Tracer.ts +6 -5
- package/src/Trie.ts +26 -14
- package/src/TxHashMap.ts +78 -60
- package/src/TxSemaphore.ts +186 -11
- package/src/index.ts +89 -33
- package/src/internal/dateTime.ts +14 -14
- package/src/internal/effect.ts +29 -121
- package/src/internal/hashMap.ts +4 -3
- package/src/internal/option.ts +7 -0
- package/src/internal/trie.ts +6 -6
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
- package/src/unstable/ai/Chat.ts +6 -2
- package/src/unstable/ai/LanguageModel.ts +192 -65
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
- package/src/unstable/ai/ResponseIdTracker.ts +97 -0
- package/src/unstable/ai/Tool.ts +20 -0
- package/src/unstable/ai/index.ts +5 -0
- package/src/unstable/cli/Argument.ts +2 -4
- package/src/unstable/cli/CliOutput.ts +7 -5
- package/src/unstable/cli/Command.ts +5 -5
- package/src/unstable/cli/Flag.ts +2 -2
- package/src/unstable/cli/HelpDoc.ts +14 -12
- package/src/unstable/cli/Param.ts +15 -11
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/Prompt.ts +81 -83
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
- package/src/unstable/cli/internal/parser.ts +7 -4
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
- package/src/unstable/cluster/Entity.ts +13 -12
- package/src/unstable/cluster/Message.ts +6 -5
- package/src/unstable/cluster/MessageStorage.ts +26 -25
- package/src/unstable/cluster/Reply.ts +7 -4
- package/src/unstable/cluster/RunnerServer.ts +10 -13
- package/src/unstable/cluster/Runners.ts +8 -7
- package/src/unstable/cluster/Sharding.ts +24 -17
- package/src/unstable/cluster/ShardingConfig.ts +6 -6
- package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
- package/src/unstable/cluster/internal/entityManager.ts +27 -21
- package/src/unstable/devtools/DevToolsSchema.ts +3 -2
- package/src/unstable/http/Cookies.ts +7 -8
- package/src/unstable/http/Etag.ts +5 -3
- package/src/unstable/http/Headers.ts +6 -5
- package/src/unstable/http/HttpClient.ts +2 -1
- package/src/unstable/http/HttpClientRequest.ts +11 -9
- package/src/unstable/http/HttpClientResponse.ts +3 -2
- package/src/unstable/http/HttpIncomingMessage.ts +2 -1
- package/src/unstable/http/HttpMiddleware.ts +16 -15
- package/src/unstable/http/HttpPlatform.ts +3 -2
- package/src/unstable/http/HttpRouter.ts +9 -9
- package/src/unstable/http/HttpServer.ts +3 -9
- package/src/unstable/http/HttpServerError.ts +3 -2
- package/src/unstable/http/HttpServerRequest.ts +25 -21
- package/src/unstable/http/HttpServerResponse.ts +5 -4
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/UrlParams.ts +11 -14
- package/src/unstable/httpapi/HttpApiBuilder.ts +9 -3
- package/src/unstable/httpapi/HttpApiError.ts +67 -12
- package/src/unstable/observability/OtlpExporter.ts +5 -2
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/reactivity/Atom.ts +1 -4
- package/src/unstable/reactivity/AtomRegistry.ts +5 -3
- package/src/unstable/rpc/Rpc.ts +4 -3
- package/src/unstable/rpc/RpcClient.ts +10 -9
- package/src/unstable/rpc/RpcSchema.ts +6 -5
- package/src/unstable/rpc/RpcSerialization.ts +4 -1
- package/src/unstable/rpc/RpcServer.ts +3 -3
- package/src/unstable/socket/Socket.ts +14 -9
- package/src/unstable/sql/SqlClient.ts +5 -3
- package/src/unstable/workflow/DurableDeferred.ts +6 -6
- package/src/unstable/workflow/Workflow.ts +1 -1
- package/src/unstable/workflow/WorkflowEngine.ts +29 -20
- package/dist/NullOr.d.ts +0 -149
- package/dist/NullOr.d.ts.map +0 -1
- package/dist/NullOr.js +0 -152
- package/dist/NullOr.js.map +0 -1
- package/src/NullOr.ts +0 -204
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
import type * as Cause from "../../Cause.ts"
|
|
52
52
|
import * as Effect from "../../Effect.ts"
|
|
53
53
|
import * as FiberSet from "../../FiberSet.ts"
|
|
54
|
-
import { constFalse } from "../../Function.ts"
|
|
54
|
+
import { constFalse, identity, pipe } from "../../Function.ts"
|
|
55
55
|
import type * as JsonSchema from "../../JsonSchema.ts"
|
|
56
56
|
import * as Option from "../../Option.ts"
|
|
57
57
|
import * as Predicate from "../../Predicate.ts"
|
|
@@ -69,6 +69,7 @@ import { defaultIdGenerator, IdGenerator } from "./IdGenerator.ts"
|
|
|
69
69
|
import * as InternalCodecTransformer from "./internal/codec-transformer.ts"
|
|
70
70
|
import * as Prompt from "./Prompt.ts"
|
|
71
71
|
import * as Response from "./Response.ts"
|
|
72
|
+
import * as ResponseIdTracker from "./ResponseIdTracker.ts"
|
|
72
73
|
import type { SpanTransformer } from "./Telemetry.ts"
|
|
73
74
|
import { CurrentSpanTransformer } from "./Telemetry.ts"
|
|
74
75
|
import type * as Tool from "./Tool.ts"
|
|
@@ -648,6 +649,16 @@ export interface ProviderOptions {
|
|
|
648
649
|
* The span to use to trace interactions with the large language model.
|
|
649
650
|
*/
|
|
650
651
|
readonly span: Span
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* The previous response identifier for incremental provider calls.
|
|
655
|
+
*/
|
|
656
|
+
readonly previousResponseId: string | undefined
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* The prompt reduced to messages not yet seen by the provider.
|
|
660
|
+
*/
|
|
661
|
+
readonly incrementalPrompt: Prompt.Prompt | undefined
|
|
651
662
|
}
|
|
652
663
|
|
|
653
664
|
/**
|
|
@@ -727,7 +738,9 @@ export const make: (params: {
|
|
|
727
738
|
tools: [],
|
|
728
739
|
toolChoice: "none",
|
|
729
740
|
responseFormat: { type: "text" },
|
|
730
|
-
span
|
|
741
|
+
span,
|
|
742
|
+
previousResponseId: undefined,
|
|
743
|
+
incrementalPrompt: undefined
|
|
731
744
|
}
|
|
732
745
|
const content = yield* generateContent(options, providerOptions)
|
|
733
746
|
|
|
@@ -790,7 +803,9 @@ export const make: (params: {
|
|
|
790
803
|
objectName,
|
|
791
804
|
schema: options.schema
|
|
792
805
|
},
|
|
793
|
-
span
|
|
806
|
+
span,
|
|
807
|
+
previousResponseId: undefined,
|
|
808
|
+
incrementalPrompt: undefined
|
|
794
809
|
}
|
|
795
810
|
|
|
796
811
|
const content = yield* generateContent(options, providerOptions)
|
|
@@ -857,7 +872,9 @@ export const make: (params: {
|
|
|
857
872
|
tools: [],
|
|
858
873
|
toolChoice: "none",
|
|
859
874
|
responseFormat: { type: "text" },
|
|
860
|
-
span
|
|
875
|
+
span,
|
|
876
|
+
previousResponseId: undefined,
|
|
877
|
+
incrementalPrompt: undefined
|
|
861
878
|
}
|
|
862
879
|
|
|
863
880
|
// Resolve the content stream for the request
|
|
@@ -917,6 +934,7 @@ export const make: (params: {
|
|
|
917
934
|
options: Options & GenerateTextOptions<Tools>,
|
|
918
935
|
providerOptions: Mutable<ProviderOptions>
|
|
919
936
|
) {
|
|
937
|
+
const tracker = Option.getOrUndefined(yield* Effect.serviceOption(ResponseIdTracker.ResponseIdTracker))
|
|
920
938
|
const toolChoice = options.toolChoice ?? "auto"
|
|
921
939
|
|
|
922
940
|
// Check for pending approvals that need resolution
|
|
@@ -940,11 +958,24 @@ export const make: (params: {
|
|
|
940
958
|
})
|
|
941
959
|
})
|
|
942
960
|
}
|
|
961
|
+
if (tracker) {
|
|
962
|
+
const prepared = tracker.prepareUnsafe(providerOptions.prompt)
|
|
963
|
+
if (Option.isSome(prepared)) {
|
|
964
|
+
providerOptions.previousResponseId = prepared.value.previousResponseId
|
|
965
|
+
providerOptions.incrementalPrompt = prepared.value.prompt
|
|
966
|
+
}
|
|
967
|
+
}
|
|
943
968
|
const ResponseSchema = Schema.mutable(
|
|
944
969
|
Schema.Array(Response.Part(Toolkit.empty))
|
|
945
970
|
)
|
|
946
971
|
const rawContent = yield* params.generateText(providerOptions)
|
|
947
972
|
const content = yield* Schema.decodeEffect(ResponseSchema)(rawContent)
|
|
973
|
+
if (tracker) {
|
|
974
|
+
const responseMetadata = content.find((part) => part.type === "response-metadata")
|
|
975
|
+
if (Predicate.isNotUndefined(responseMetadata) && Predicate.isNotUndefined(responseMetadata.id)) {
|
|
976
|
+
tracker.markParts(providerOptions.prompt.content, responseMetadata.id)
|
|
977
|
+
}
|
|
978
|
+
}
|
|
948
979
|
return content as Array<Response.Part<Tools>>
|
|
949
980
|
}
|
|
950
981
|
|
|
@@ -965,11 +996,24 @@ export const make: (params: {
|
|
|
965
996
|
})
|
|
966
997
|
})
|
|
967
998
|
}
|
|
999
|
+
if (tracker) {
|
|
1000
|
+
const prepared = tracker.prepareUnsafe(providerOptions.prompt)
|
|
1001
|
+
if (Option.isSome(prepared)) {
|
|
1002
|
+
providerOptions.previousResponseId = prepared.value.previousResponseId
|
|
1003
|
+
providerOptions.incrementalPrompt = prepared.value.prompt
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
968
1006
|
const ResponseSchema = Schema.mutable(
|
|
969
1007
|
Schema.Array(Response.Part(Toolkit.empty))
|
|
970
1008
|
)
|
|
971
1009
|
const rawContent = yield* params.generateText(providerOptions)
|
|
972
1010
|
const content = yield* Schema.decodeEffect(ResponseSchema)(rawContent)
|
|
1011
|
+
if (tracker) {
|
|
1012
|
+
const responseMetadata = content.find((part) => part.type === "response-metadata")
|
|
1013
|
+
if (Predicate.isNotUndefined(responseMetadata) && Predicate.isNotUndefined(responseMetadata.id)) {
|
|
1014
|
+
tracker.markParts(providerOptions.prompt.content, responseMetadata.id)
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
973
1017
|
return content as Array<Response.Part<Tools>>
|
|
974
1018
|
}
|
|
975
1019
|
|
|
@@ -1025,6 +1069,14 @@ export const make: (params: {
|
|
|
1025
1069
|
providerOptions.tools = tools
|
|
1026
1070
|
providerOptions.toolChoice = toolChoice
|
|
1027
1071
|
|
|
1072
|
+
if (tracker) {
|
|
1073
|
+
const prepared = tracker.prepareUnsafe(providerOptions.prompt)
|
|
1074
|
+
if (Option.isSome(prepared)) {
|
|
1075
|
+
providerOptions.previousResponseId = prepared.value.previousResponseId
|
|
1076
|
+
providerOptions.incrementalPrompt = prepared.value.prompt
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1028
1080
|
// Construct the response schema with the tools from the toolkit
|
|
1029
1081
|
const ResponseSchema = Schema.mutable(
|
|
1030
1082
|
Schema.Array(Response.Part(toolkit))
|
|
@@ -1035,6 +1087,12 @@ export const make: (params: {
|
|
|
1035
1087
|
if (options.disableToolCallResolution === true) {
|
|
1036
1088
|
const rawContent = yield* params.generateText(providerOptions)
|
|
1037
1089
|
const content = yield* Schema.decodeEffect(ResponseSchema)(rawContent)
|
|
1090
|
+
if (tracker) {
|
|
1091
|
+
const responseMetadata = content.find((part) => part.type === "response-metadata")
|
|
1092
|
+
if (Predicate.isNotUndefined(responseMetadata) && Predicate.isNotUndefined(responseMetadata.id)) {
|
|
1093
|
+
tracker.markParts(providerOptions.prompt.content, responseMetadata.id)
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1038
1096
|
return content as Array<Response.Part<Tools>>
|
|
1039
1097
|
}
|
|
1040
1098
|
|
|
@@ -1057,6 +1115,13 @@ export const make: (params: {
|
|
|
1057
1115
|
|
|
1058
1116
|
const content = yield* Schema.decodeEffect(ResponseSchema)(rawContent)
|
|
1059
1117
|
|
|
1118
|
+
if (tracker) {
|
|
1119
|
+
const responseMetadata = content.find((part) => part.type === "response-metadata")
|
|
1120
|
+
if (Predicate.isNotUndefined(responseMetadata) && Predicate.isNotUndefined(responseMetadata.id)) {
|
|
1121
|
+
tracker.markParts(providerOptions.prompt.content, responseMetadata.id)
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1060
1125
|
// Return the content merged with the tool call results
|
|
1061
1126
|
return [...content, ...toolResults] as Array<Response.Part<Tools>>
|
|
1062
1127
|
})
|
|
@@ -1086,6 +1151,7 @@ export const make: (params: {
|
|
|
1086
1151
|
options: Options & GenerateTextOptions<Tools>,
|
|
1087
1152
|
providerOptions: Mutable<ProviderOptions>
|
|
1088
1153
|
) {
|
|
1154
|
+
const tracker = Option.getOrUndefined(yield* Effect.serviceOption(ResponseIdTracker.ResponseIdTracker))
|
|
1089
1155
|
const toolChoice = options.toolChoice ?? "auto"
|
|
1090
1156
|
|
|
1091
1157
|
// Check for pending approvals that need resolution
|
|
@@ -1108,17 +1174,36 @@ export const make: (params: {
|
|
|
1108
1174
|
})
|
|
1109
1175
|
})
|
|
1110
1176
|
}
|
|
1177
|
+
if (tracker) {
|
|
1178
|
+
const prepared = tracker.prepareUnsafe(providerOptions.prompt)
|
|
1179
|
+
if (Option.isSome(prepared)) {
|
|
1180
|
+
providerOptions.previousResponseId = prepared.value.previousResponseId
|
|
1181
|
+
providerOptions.incrementalPrompt = prepared.value.prompt
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1111
1184
|
const schema = Schema.NonEmptyArray(Response.StreamPart(Toolkit.empty))
|
|
1112
1185
|
const decodeParts = Schema.decodeEffect(schema)
|
|
1113
|
-
return
|
|
1114
|
-
.streamText(providerOptions)
|
|
1115
|
-
.
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1186
|
+
return pipe(
|
|
1187
|
+
params.streamText(providerOptions),
|
|
1188
|
+
Stream.mapArrayEffect((parts) =>
|
|
1189
|
+
decodeParts(parts).pipe(
|
|
1190
|
+
tracker ?
|
|
1191
|
+
Effect.tap((decodedParts) => {
|
|
1192
|
+
for (const part of decodedParts) {
|
|
1193
|
+
if (part.type === "response-metadata" && Predicate.isNotUndefined(part.id)) {
|
|
1194
|
+
tracker.markParts(providerOptions.prompt.content, part.id)
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
return Effect.void
|
|
1198
|
+
}) :
|
|
1199
|
+
identity
|
|
1200
|
+
)
|
|
1201
|
+
)
|
|
1202
|
+
) as Stream.Stream<
|
|
1203
|
+
Response.StreamPart<Tools>,
|
|
1204
|
+
AiError.AiError | Schema.SchemaError,
|
|
1205
|
+
IdGenerator
|
|
1206
|
+
>
|
|
1122
1207
|
}
|
|
1123
1208
|
|
|
1124
1209
|
// If there is a toolkit resolve and apply it to the provider options
|
|
@@ -1138,17 +1223,36 @@ export const make: (params: {
|
|
|
1138
1223
|
})
|
|
1139
1224
|
})
|
|
1140
1225
|
}
|
|
1226
|
+
if (tracker) {
|
|
1227
|
+
const prepared = tracker.prepareUnsafe(providerOptions.prompt)
|
|
1228
|
+
if (Option.isSome(prepared)) {
|
|
1229
|
+
providerOptions.previousResponseId = prepared.value.previousResponseId
|
|
1230
|
+
providerOptions.incrementalPrompt = prepared.value.prompt
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1141
1233
|
const schema = Schema.NonEmptyArray(Response.StreamPart(Toolkit.empty))
|
|
1142
1234
|
const decodeParts = Schema.decodeEffect(schema)
|
|
1143
|
-
return
|
|
1144
|
-
.streamText(providerOptions)
|
|
1145
|
-
.
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1235
|
+
return pipe(
|
|
1236
|
+
params.streamText(providerOptions),
|
|
1237
|
+
Stream.mapArrayEffect((parts) =>
|
|
1238
|
+
decodeParts(parts).pipe(
|
|
1239
|
+
tracker ?
|
|
1240
|
+
Effect.tap((decodedParts) => {
|
|
1241
|
+
for (const part of decodedParts) {
|
|
1242
|
+
if (part.type === "response-metadata" && part.id) {
|
|
1243
|
+
tracker.markParts(providerOptions.prompt.content, part.id)
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
return Effect.void
|
|
1247
|
+
}) :
|
|
1248
|
+
identity
|
|
1249
|
+
)
|
|
1250
|
+
)
|
|
1251
|
+
) as Stream.Stream<
|
|
1252
|
+
Response.StreamPart<Tools>,
|
|
1253
|
+
AiError.AiError | Schema.SchemaError,
|
|
1254
|
+
IdGenerator
|
|
1255
|
+
>
|
|
1152
1256
|
}
|
|
1153
1257
|
|
|
1154
1258
|
// Pre-resolve pending tool approvals before calling the LLM
|
|
@@ -1222,20 +1326,39 @@ export const make: (params: {
|
|
|
1222
1326
|
providerOptions.tools = tools
|
|
1223
1327
|
providerOptions.toolChoice = toolChoice
|
|
1224
1328
|
|
|
1329
|
+
if (tracker) {
|
|
1330
|
+
const prepared = tracker.prepareUnsafe(providerOptions.prompt)
|
|
1331
|
+
if (Option.isSome(prepared)) {
|
|
1332
|
+
providerOptions.previousResponseId = prepared.value.previousResponseId
|
|
1333
|
+
providerOptions.incrementalPrompt = prepared.value.prompt
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1225
1337
|
// If tool call resolution is disabled, return the response without
|
|
1226
1338
|
// resolving the tool calls that were generated
|
|
1227
1339
|
if (options.disableToolCallResolution === true) {
|
|
1228
1340
|
const schema = Schema.NonEmptyArray(Response.StreamPart(toolkit))
|
|
1229
1341
|
const decodeParts = Schema.decodeEffect(schema)
|
|
1230
|
-
return params
|
|
1231
|
-
.
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1342
|
+
return params.streamText(providerOptions).pipe(
|
|
1343
|
+
Stream.mapArrayEffect((parts) =>
|
|
1344
|
+
decodeParts(parts).pipe(
|
|
1345
|
+
tracker ?
|
|
1346
|
+
Effect.tap((decodedParts) => {
|
|
1347
|
+
for (const part of decodedParts) {
|
|
1348
|
+
if (part.type === "response-metadata" && Predicate.isNotUndefined(part.id)) {
|
|
1349
|
+
tracker.markParts(providerOptions.prompt.content, part.id)
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
return Effect.void
|
|
1353
|
+
}) :
|
|
1354
|
+
identity
|
|
1355
|
+
)
|
|
1356
|
+
)
|
|
1357
|
+
) as Stream.Stream<
|
|
1358
|
+
Response.StreamPart<Tools>,
|
|
1359
|
+
AiError.AiError | Schema.SchemaError,
|
|
1360
|
+
IdGenerator
|
|
1361
|
+
>
|
|
1239
1362
|
}
|
|
1240
1363
|
|
|
1241
1364
|
const ResponseSchema = Schema.NonEmptyArray(Response.StreamPart(toolkit))
|
|
@@ -1260,48 +1383,52 @@ export const make: (params: {
|
|
|
1260
1383
|
const toolCallFibers = yield* FiberSet.make<void, AiError.AiError>()
|
|
1261
1384
|
|
|
1262
1385
|
// Helper function to handle tool calls with approval logic
|
|
1263
|
-
const handleToolCall = (part: Response.ToolCallPartEncoded)
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
if (!tool) {
|
|
1267
|
-
return
|
|
1268
|
-
}
|
|
1386
|
+
const handleToolCall = Effect.fnUntraced(function*(part: Response.ToolCallPartEncoded) {
|
|
1387
|
+
const tool = toolkit.tools[part.name]
|
|
1388
|
+
if (!tool) return
|
|
1269
1389
|
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1390
|
+
const needsApproval = yield* isApprovalNeeded(
|
|
1391
|
+
tool,
|
|
1392
|
+
part,
|
|
1393
|
+
providerOptions.prompt.content
|
|
1394
|
+
)
|
|
1275
1395
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1396
|
+
if (needsApproval) {
|
|
1397
|
+
const idGen = yield* IdGenerator
|
|
1398
|
+
const approvalId = yield* idGen.generateId()
|
|
1399
|
+
const approvalPart = Response.makePart("tool-approval-request", {
|
|
1400
|
+
approvalId,
|
|
1401
|
+
toolCallId: part.id
|
|
1402
|
+
}) as Response.StreamPart<Tools>
|
|
1403
|
+
yield* Queue.offer(queue, approvalPart)
|
|
1404
|
+
return
|
|
1405
|
+
}
|
|
1286
1406
|
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1407
|
+
yield* toolkit.handle(part.name, part.params as any).pipe(
|
|
1408
|
+
Stream.unwrap,
|
|
1409
|
+
Stream.runForEach((result) => {
|
|
1410
|
+
const toolResultPart = Response.makePart("tool-result", {
|
|
1411
|
+
id: part.id,
|
|
1412
|
+
name: part.name,
|
|
1413
|
+
providerExecuted: false,
|
|
1414
|
+
...result
|
|
1415
|
+
}) as Response.StreamPart<Tools>
|
|
1416
|
+
return Queue.offer(queue, toolResultPart)
|
|
1417
|
+
})
|
|
1418
|
+
)
|
|
1419
|
+
})
|
|
1300
1420
|
|
|
1301
1421
|
yield* params.streamText(providerOptions).pipe(
|
|
1302
1422
|
Stream.runForEachArray(
|
|
1303
1423
|
Effect.fnUntraced(function*(chunk) {
|
|
1304
1424
|
const parts = yield* decodeParts(chunk)
|
|
1425
|
+
if (tracker) {
|
|
1426
|
+
for (const part of parts) {
|
|
1427
|
+
if (part.type === "response-metadata" && part.id) {
|
|
1428
|
+
tracker.markParts(providerOptions.prompt.content, part.id)
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1305
1432
|
// Add decoded response parts to the output queue
|
|
1306
1433
|
yield* Queue.offerAll(queue, parts)
|
|
1307
1434
|
// Fork tool call handlers - use the raw chunk for encoded params
|
|
@@ -11,6 +11,7 @@ import * as Rec from "../../Record.ts"
|
|
|
11
11
|
import * as Schema from "../../Schema.ts"
|
|
12
12
|
import * as AST from "../../SchemaAST.ts"
|
|
13
13
|
import * as Transformation from "../../SchemaTransformation.ts"
|
|
14
|
+
import * as Tool from "./Tool.ts"
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Transforms a `Schema.Codec` into a form compatible with OpenAI's
|
|
@@ -243,6 +244,9 @@ function recurOpenAI(ast: AST.AST): AST.AST {
|
|
|
243
244
|
}
|
|
244
245
|
} else if (ast.indexSignatures.length === 1 && ast.propertySignatures.length === 0) {
|
|
245
246
|
const is = ast.indexSignatures[0]
|
|
247
|
+
if (Tool.isEmptyParamsRecord(is)) {
|
|
248
|
+
return ast
|
|
249
|
+
}
|
|
246
250
|
// records are not supported by OpenAI, so we translate them to arrays of key-value pairs
|
|
247
251
|
if (annotations !== undefined && typeof annotations.description === "string") {
|
|
248
252
|
annotations.description = `${RECORD_DESCRIPTION}; ${annotations.description}`
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 4.0.0
|
|
3
|
+
*/
|
|
4
|
+
import * as Effect from "../../Effect.ts"
|
|
5
|
+
import * as Option from "../../Option.ts"
|
|
6
|
+
import * as ServiceMap from "../../ServiceMap.ts"
|
|
7
|
+
import * as Prompt from "./Prompt.ts"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @since 4.0.0
|
|
11
|
+
* @category models
|
|
12
|
+
*/
|
|
13
|
+
export interface PrepareResult {
|
|
14
|
+
readonly previousResponseId: string
|
|
15
|
+
readonly prompt: Prompt.Prompt
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @since 4.0.0
|
|
20
|
+
* @category models
|
|
21
|
+
*/
|
|
22
|
+
export interface Service {
|
|
23
|
+
clearUnsafe(): void
|
|
24
|
+
markParts(parts: ReadonlyArray<object>, responseId: string): void
|
|
25
|
+
prepareUnsafe(prompt: Prompt.Prompt): Option.Option<PrepareResult>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @since 4.0.0
|
|
30
|
+
* @category Services
|
|
31
|
+
*/
|
|
32
|
+
export class ResponseIdTracker
|
|
33
|
+
extends ServiceMap.Service<ResponseIdTracker, Service>()("effect/ai/ResponseIdTracker")
|
|
34
|
+
{}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @since 4.0.0
|
|
38
|
+
* @category constructors
|
|
39
|
+
*/
|
|
40
|
+
export const make: Effect.Effect<Service> = Effect.sync(() => {
|
|
41
|
+
let sentParts = new WeakMap<object, string>()
|
|
42
|
+
|
|
43
|
+
const none = () => {
|
|
44
|
+
sentParts = new WeakMap<object, string>()
|
|
45
|
+
return Option.none<PrepareResult>()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
clearUnsafe() {
|
|
50
|
+
sentParts = new WeakMap<object, string>()
|
|
51
|
+
},
|
|
52
|
+
markParts(parts, responseId) {
|
|
53
|
+
for (let i = 0; i < parts.length; i++) {
|
|
54
|
+
sentParts.set(parts[i], responseId)
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
prepareUnsafe(prompt) {
|
|
58
|
+
const messages = prompt.content
|
|
59
|
+
|
|
60
|
+
let anyTracked = false
|
|
61
|
+
for (let i = 0; i < messages.length; i++) {
|
|
62
|
+
if (sentParts.has(messages[i])) {
|
|
63
|
+
anyTracked = true
|
|
64
|
+
break
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!anyTracked) return none()
|
|
68
|
+
|
|
69
|
+
let lastAssistantIndex = -1
|
|
70
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
71
|
+
if (messages[i].role === "assistant") {
|
|
72
|
+
lastAssistantIndex = i
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (lastAssistantIndex === -1) return none()
|
|
77
|
+
|
|
78
|
+
let responseId: string | undefined
|
|
79
|
+
for (let i = 0; i < lastAssistantIndex; i++) {
|
|
80
|
+
const id = sentParts.get(messages[i])
|
|
81
|
+
if (id === undefined) return none()
|
|
82
|
+
responseId = id
|
|
83
|
+
}
|
|
84
|
+
if (responseId === undefined) return none()
|
|
85
|
+
|
|
86
|
+
const partsAfterLastAssistant = messages.slice(lastAssistantIndex + 1)
|
|
87
|
+
if (partsAfterLastAssistant.length === 0) {
|
|
88
|
+
return none()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return Option.some({
|
|
92
|
+
previousResponseId: responseId,
|
|
93
|
+
prompt: Prompt.fromMessages(partsAfterLastAssistant)
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
package/src/unstable/ai/Tool.ts
CHANGED
|
@@ -1129,6 +1129,9 @@ const dynamicProto = <
|
|
|
1129
1129
|
* can call. The tool definition includes parameter validation, success/failure
|
|
1130
1130
|
* schemas, and optional service dependencies.
|
|
1131
1131
|
*
|
|
1132
|
+
* If a tool accepts no parameters but still needs an explicit empty object
|
|
1133
|
+
* schema, use {@link EmptyParams}.
|
|
1134
|
+
*
|
|
1132
1135
|
* @example
|
|
1133
1136
|
* ```ts
|
|
1134
1137
|
* import { Schema } from "effect"
|
|
@@ -1866,3 +1869,20 @@ export const unsafeSecureJsonParse = (text: string): unknown => {
|
|
|
1866
1869
|
Error.stackTraceLimit = stackTraceLimit
|
|
1867
1870
|
}
|
|
1868
1871
|
}
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* @since 4.0.0
|
|
1875
|
+
*/
|
|
1876
|
+
export interface EmptyParams extends Schema.$Record<Schema.String, Schema.Never> {}
|
|
1877
|
+
|
|
1878
|
+
/**
|
|
1879
|
+
* A schema for tools that accept no parameters.
|
|
1880
|
+
*
|
|
1881
|
+
* @since 4.0.0
|
|
1882
|
+
*/
|
|
1883
|
+
export const EmptyParams: EmptyParams = Schema.Record(Schema.String, Schema.Never)
|
|
1884
|
+
|
|
1885
|
+
/** @internal */
|
|
1886
|
+
export function isEmptyParamsRecord(indexSignature: AST.IndexSignature): boolean {
|
|
1887
|
+
return indexSignature.parameter === AST.string && AST.isNever(indexSignature.type)
|
|
1888
|
+
}
|
package/src/unstable/ai/index.ts
CHANGED
|
@@ -388,6 +388,11 @@ export * as Prompt from "./Prompt.ts"
|
|
|
388
388
|
*/
|
|
389
389
|
export * as Response from "./Response.ts"
|
|
390
390
|
|
|
391
|
+
/**
|
|
392
|
+
* @since 4.0.0
|
|
393
|
+
*/
|
|
394
|
+
export * as ResponseIdTracker from "./ResponseIdTracker.ts"
|
|
395
|
+
|
|
391
396
|
/**
|
|
392
397
|
* The `Telemetry` module provides OpenTelemetry integration for operations
|
|
393
398
|
* performed against a large language model provider by defining telemetry
|
|
@@ -226,9 +226,7 @@ export const fileParse = (
|
|
|
226
226
|
* host: Schema.String
|
|
227
227
|
* })
|
|
228
228
|
*
|
|
229
|
-
* const
|
|
230
|
-
*
|
|
231
|
-
* const config = Argument.fileSchema("config", JsonConfigSchema)
|
|
229
|
+
* const config = Argument.fileSchema("config", ConfigSchema)
|
|
232
230
|
* ```
|
|
233
231
|
*
|
|
234
232
|
* @since 4.0.0
|
|
@@ -236,7 +234,7 @@ export const fileParse = (
|
|
|
236
234
|
*/
|
|
237
235
|
export const fileSchema = <A>(
|
|
238
236
|
name: string,
|
|
239
|
-
schema: Schema.
|
|
237
|
+
schema: Schema.Decoder<A>,
|
|
240
238
|
options?: Primitive.FileSchemaOptions | undefined
|
|
241
239
|
): Argument<A> => Param.fileSchema(Param.argumentKind, name, schema, options)
|
|
242
240
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as Layer from "../../Layer.ts"
|
|
6
|
+
import * as Option from "../../Option.ts"
|
|
6
7
|
import * as ServiceMap from "../../ServiceMap.ts"
|
|
7
8
|
import type * as CliError from "./CliError.ts"
|
|
8
9
|
import type { HelpDoc } from "./HelpDoc.ts"
|
|
@@ -44,6 +45,7 @@ export interface Formatter {
|
|
|
44
45
|
*
|
|
45
46
|
* @example
|
|
46
47
|
* ```ts
|
|
48
|
+
* import { Option as O } from "effect"
|
|
47
49
|
* import type { HelpDoc } from "effect/unstable/cli"
|
|
48
50
|
* import { CliOutput } from "effect/unstable/cli"
|
|
49
51
|
*
|
|
@@ -55,7 +57,7 @@ export interface Formatter {
|
|
|
55
57
|
* name: "verbose",
|
|
56
58
|
* aliases: ["-v"],
|
|
57
59
|
* type: "boolean",
|
|
58
|
-
* description: "Enable verbose output",
|
|
60
|
+
* description: O.some("Enable verbose output"),
|
|
59
61
|
* required: false
|
|
60
62
|
* }
|
|
61
63
|
* ],
|
|
@@ -63,7 +65,7 @@ export interface Formatter {
|
|
|
63
65
|
* {
|
|
64
66
|
* name: "file",
|
|
65
67
|
* type: "string",
|
|
66
|
-
* description: "Input file to process",
|
|
68
|
+
* description: O.some("Input file to process"),
|
|
67
69
|
* required: true,
|
|
68
70
|
* variadic: false
|
|
69
71
|
* }
|
|
@@ -459,7 +461,7 @@ const formatHelpDocImpl = (doc: HelpDoc, colors: ColorFunctions): string => {
|
|
|
459
461
|
const nameType = `${coloredName} ${coloredType}`
|
|
460
462
|
|
|
461
463
|
const optionalSuffix = arg.required ? "" : colors.dim(" (optional)")
|
|
462
|
-
const description = (arg.description
|
|
464
|
+
const description = Option.getOrElse(arg.description, () => "") + optionalSuffix
|
|
463
465
|
|
|
464
466
|
return {
|
|
465
467
|
left: nameType,
|
|
@@ -491,7 +493,7 @@ const formatHelpDocImpl = (doc: HelpDoc, colors: ColorFunctions): string => {
|
|
|
491
493
|
|
|
492
494
|
return {
|
|
493
495
|
left: namesPart + typePart,
|
|
494
|
-
right: flag.description
|
|
496
|
+
right: Option.getOrElse(flag.description, () => "")
|
|
495
497
|
}
|
|
496
498
|
})
|
|
497
499
|
|
|
@@ -519,7 +521,7 @@ const formatHelpDocImpl = (doc: HelpDoc, colors: ColorFunctions): string => {
|
|
|
519
521
|
|
|
520
522
|
return {
|
|
521
523
|
left: namesPart + typePart,
|
|
522
|
-
right: flag.description
|
|
524
|
+
right: Option.getOrElse(flag.description, () => "")
|
|
523
525
|
}
|
|
524
526
|
})
|
|
525
527
|
|
|
@@ -360,10 +360,10 @@ export interface ParsedTokens {
|
|
|
360
360
|
readonly flags: Record<string, ReadonlyArray<string>>
|
|
361
361
|
readonly arguments: ReadonlyArray<string>
|
|
362
362
|
readonly errors?: ReadonlyArray<CliError.CliError>
|
|
363
|
-
readonly subcommand
|
|
363
|
+
readonly subcommand: Option.Option<{
|
|
364
364
|
readonly name: string
|
|
365
365
|
readonly parsedInput: ParsedTokens
|
|
366
|
-
}
|
|
366
|
+
}>
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
/**
|
|
@@ -939,17 +939,17 @@ export const withSubcommands: {
|
|
|
939
939
|
type InternalInput = NextInput & { readonly [SubcommandStateSymbol]?: SubcommandState }
|
|
940
940
|
|
|
941
941
|
const parse = Effect.fnUntraced(function*(raw: ParsedTokens) {
|
|
942
|
-
if (
|
|
942
|
+
if (Option.isNone(raw.subcommand)) {
|
|
943
943
|
return (yield* impl.parse(raw)) as NextInput
|
|
944
944
|
}
|
|
945
945
|
|
|
946
|
-
const sub = byName.get(raw.subcommand.name)
|
|
946
|
+
const sub = byName.get(raw.subcommand.value.name)
|
|
947
947
|
if (!sub) {
|
|
948
948
|
return (yield* impl.parse(raw)) as NextInput
|
|
949
949
|
}
|
|
950
950
|
|
|
951
951
|
const context = yield* impl.parseContext(raw)
|
|
952
|
-
const result = yield* sub.parse(raw.subcommand.parsedInput)
|
|
952
|
+
const result = yield* sub.parse(raw.subcommand.value.parsedInput)
|
|
953
953
|
return Object.assign({}, context, { [SubcommandStateSymbol]: { name: sub.name, result } }) as NextInput
|
|
954
954
|
})
|
|
955
955
|
|