effect 4.0.4 → 4.0.6
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/ai-docs/package.json +1 -1
- package/ai-docs/src/06_schedule/10_schedules.ts +5 -4
- package/ai-docs/src/52_graphql/10_basics.ts +19 -13
- package/ai-docs/src/52_graphql/30_batching.ts +6 -4
- package/ai-docs/src/52_graphql/40_aliased-batching.ts +6 -4
- package/ai-docs/tsconfig.json +3 -1
- package/dist/Array.d.ts +207 -58
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +45 -22
- package/dist/Array.js.map +1 -1
- package/dist/Bytes.d.ts +79 -0
- package/dist/Bytes.d.ts.map +1 -0
- package/dist/Bytes.js +109 -0
- package/dist/Bytes.js.map +1 -0
- package/dist/Channel.d.ts +187 -14
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +142 -33
- package/dist/Channel.js.map +1 -1
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/ChannelSchema.js.map +1 -1
- package/dist/Chunk.d.ts +39 -21
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +26 -17
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +8 -3
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +34 -32
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Cron.d.ts +2 -2
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +6 -3
- package/dist/Cron.js.map +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +58 -21
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +548 -182
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +261 -76
- package/dist/Effect.js.map +1 -1
- package/dist/Equivalence.d.ts +2 -1
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +12 -8
- package/dist/Equivalence.js.map +1 -1
- package/dist/Exit.d.ts +24 -9
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +8 -3
- package/dist/Exit.js.map +1 -1
- package/dist/FiberHandle.d.ts +2 -0
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +9 -4
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +2 -0
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +5 -2
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +28 -9
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +3 -0
- package/dist/FileSystem.js.map +1 -1
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js.map +1 -1
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +18 -17
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts +9 -3
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +19 -3
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +2 -2
- package/dist/Layer.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +19 -1
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +62 -6
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Match.d.ts +20 -6
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +2 -2
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +132 -0
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +197 -25
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/Number.js +2 -2
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js.map +1 -1
- package/dist/Path.d.ts +37 -5
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +44 -6
- package/dist/Path.js.map +1 -1
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +12 -7
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +4 -1
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +4 -1
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +1 -1
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +12 -7
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +9 -6
- package/dist/RcMap.js.map +1 -1
- package/dist/Record.d.ts +51 -0
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +17 -0
- package/dist/Record.js.map +1 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js.map +1 -1
- package/dist/References.d.ts +5 -4
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +5 -4
- package/dist/References.js.map +1 -1
- package/dist/RequestResolver.d.ts +31 -1
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +39 -4
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.js +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/Runtime.d.ts +3 -3
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +18 -15
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +383 -326
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +338 -17
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +5 -5
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +24 -8
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +8 -3
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +15 -5
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +4 -4
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +29 -51
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +56 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +18 -0
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +1 -1
- package/dist/SchemaTransformation.js +1 -1
- package/dist/Scope.d.ts +12 -2
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +5 -0
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.d.ts +10 -7
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +9 -5
- package/dist/ScopedCache.js.map +1 -1
- package/dist/SemVer.d.ts +1196 -0
- package/dist/SemVer.d.ts.map +1 -0
- package/dist/SemVer.js +756 -0
- package/dist/SemVer.js.map +1 -0
- package/dist/SemVerRange.d.ts +559 -0
- package/dist/SemVerRange.d.ts.map +1 -0
- package/dist/SemVerRange.js +551 -0
- package/dist/SemVerRange.js.map +1 -0
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +6 -2
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +235 -8
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +145 -60
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +16 -2
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +25 -10
- package/dist/String.js.map +1 -1
- package/dist/TextDiff.d.ts +399 -0
- package/dist/TextDiff.d.ts.map +1 -0
- package/dist/TextDiff.js +634 -0
- package/dist/TextDiff.js.map +1 -0
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +3 -2
- package/dist/TxRef.js.map +1 -1
- package/dist/ai/AiError.d.ts +78 -14
- package/dist/ai/AiError.d.ts.map +1 -1
- package/dist/ai/AiError.js +51 -3
- package/dist/ai/AiError.js.map +1 -1
- package/dist/ai/Chat.d.ts +1 -2
- package/dist/ai/Chat.d.ts.map +1 -1
- package/dist/ai/Chat.js +6 -3
- package/dist/ai/Chat.js.map +1 -1
- package/dist/ai/Decision.d.ts +116 -20
- package/dist/ai/Decision.d.ts.map +1 -1
- package/dist/ai/Decision.js +37 -3
- package/dist/ai/Decision.js.map +1 -1
- package/dist/ai/DecisionModel.d.ts +129 -11
- package/dist/ai/DecisionModel.d.ts.map +1 -1
- package/dist/ai/DecisionModel.js +183 -95
- package/dist/ai/DecisionModel.js.map +1 -1
- package/dist/ai/EmbeddingModel.d.ts +10 -0
- package/dist/ai/EmbeddingModel.d.ts.map +1 -1
- package/dist/ai/EmbeddingModel.js +21 -7
- package/dist/ai/EmbeddingModel.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +47 -35
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpClient.d.ts +289 -0
- package/dist/ai/McpClient.d.ts.map +1 -0
- package/dist/ai/McpClient.js +819 -0
- package/dist/ai/McpClient.js.map +1 -0
- package/dist/ai/McpClientError.d.ts +254 -0
- package/dist/ai/McpClientError.d.ts.map +1 -0
- package/dist/ai/McpClientError.js +260 -0
- package/dist/ai/McpClientError.js.map +1 -0
- package/dist/ai/McpProtocol.d.ts +2 -2
- package/dist/ai/McpProtocol.d.ts.map +1 -1
- package/dist/ai/McpSchema.d.ts +368 -235
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpSchema.js +94 -24
- package/dist/ai/McpSchema.js.map +1 -1
- package/dist/ai/McpServer.d.ts +6 -52
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +27 -50
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +22 -20
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +23 -1
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +148 -4
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +35 -37
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +12 -4
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/Toolkit.d.ts +48 -1
- package/dist/ai/Toolkit.d.ts.map +1 -1
- package/dist/ai/Toolkit.js +65 -12
- package/dist/ai/Toolkit.js.map +1 -1
- package/dist/ai/index.d.ts +10 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +10 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +2 -2
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +2 -2
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +4 -7
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +16 -2
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +3 -4
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2024_11_05.js +19 -13
- package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_03_26.js +3 -2
- package/dist/ai/internal/mcpSchema/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_06_18.js +7 -7
- package/dist/ai/internal/mcpSchema/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_11_25.js +8 -8
- package/dist/ai/internal/mcpSchema/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2026_07_28.js +43 -42
- package/dist/ai/internal/mcpSchema/v2026_07_28.js.map +1 -1
- package/dist/cli/CliError.d.ts +42 -2
- package/dist/cli/CliError.d.ts.map +1 -1
- package/dist/cli/CliError.js +44 -5
- package/dist/cli/CliError.js.map +1 -1
- package/dist/cli/Command.d.ts +286 -2
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +107 -6
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Completions.d.ts +10 -0
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/Flag.d.ts +215 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +89 -0
- package/dist/cli/Flag.js.map +1 -1
- 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/Param.d.ts +194 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +86 -0
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/TerminalCapabilities.d.ts +84 -0
- package/dist/cli/TerminalCapabilities.d.ts.map +1 -0
- package/dist/cli/TerminalCapabilities.js +122 -0
- package/dist/cli/TerminalCapabilities.js.map +1 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +5 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/internal/command.d.ts +2 -1
- package/dist/cli/internal/command.d.ts.map +1 -1
- package/dist/cli/internal/command.js +7 -3
- package/dist/cli/internal/command.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +7 -5
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cli/internal/completions/descriptor.js +16 -1
- package/dist/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/cli/internal/completions/fish.js +12 -10
- package/dist/cli/internal/completions/fish.js.map +1 -1
- package/dist/cli/internal/completions/powershell.js +20 -10
- package/dist/cli/internal/completions/powershell.js.map +1 -1
- package/dist/cli/internal/completions/zsh.js +15 -8
- package/dist/cli/internal/completions/zsh.js.map +1 -1
- package/dist/cli/internal/formatter.d.ts +2 -0
- package/dist/cli/internal/formatter.d.ts.map +1 -0
- package/dist/cli/internal/formatter.js +15 -0
- package/dist/cli/internal/formatter.js.map +1 -0
- package/dist/cli/internal/lexer.js +24 -10
- package/dist/cli/internal/lexer.js.map +1 -1
- package/dist/cli/internal/parser.js +35 -15
- package/dist/cli/internal/parser.js.map +1 -1
- package/dist/cli/internal/wizard.d.ts.map +1 -1
- package/dist/cli/internal/wizard.js +2 -1
- package/dist/cli/internal/wizard.js.map +1 -1
- package/dist/cluster/ClusterCron.d.ts +29 -1
- package/dist/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/cluster/ClusterCron.js +64 -32
- package/dist/cluster/ClusterCron.js.map +1 -1
- package/dist/cluster/ClusterMetrics.d.ts +143 -7
- package/dist/cluster/ClusterMetrics.d.ts.map +1 -1
- package/dist/cluster/ClusterMetrics.js +151 -7
- package/dist/cluster/ClusterMetrics.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts +2 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +98 -18
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Entity.d.ts +2 -0
- package/dist/cluster/Entity.d.ts.map +1 -1
- package/dist/cluster/Entity.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +21 -0
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +20 -12
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +96 -37
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts +1 -0
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +95 -32
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +20 -0
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js +4 -0
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +40 -50
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts +2 -2
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +10 -4
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +66 -9
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/devtools/DevTools.d.ts +3 -2
- package/dist/devtools/DevTools.d.ts.map +1 -1
- package/dist/devtools/DevTools.js +3 -2
- package/dist/devtools/DevTools.js.map +1 -1
- package/dist/devtools/DevToolsClient.d.ts +11 -0
- package/dist/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/devtools/DevToolsClient.js +31 -4
- package/dist/devtools/DevToolsClient.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts +29 -0
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +29 -0
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Ini.d.ts.map +1 -1
- package/dist/encoding/Ini.js +3 -0
- package/dist/encoding/Ini.js.map +1 -1
- package/dist/encoding/JsonArray.d.ts +270 -0
- package/dist/encoding/JsonArray.d.ts.map +1 -0
- package/dist/encoding/JsonArray.js +691 -0
- package/dist/encoding/JsonArray.js.map +1 -0
- package/dist/encoding/Ndjson.d.ts +43 -4
- package/dist/encoding/Ndjson.d.ts.map +1 -1
- package/dist/encoding/Ndjson.js +169 -18
- package/dist/encoding/Ndjson.js.map +1 -1
- package/dist/encoding/SchemaBinary.d.ts +9 -1
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +12 -19
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Sse.js +1 -1
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/encoding/Tar.d.ts +309 -0
- package/dist/encoding/Tar.d.ts.map +1 -0
- package/dist/encoding/Tar.js +1182 -0
- package/dist/encoding/Tar.js.map +1 -0
- package/dist/encoding/Toml.js +3 -3
- package/dist/encoding/Toml.js.map +1 -1
- package/dist/encoding/Xml.d.ts +464 -0
- package/dist/encoding/Xml.d.ts.map +1 -0
- package/dist/encoding/Xml.js +1619 -0
- package/dist/encoding/Xml.js.map +1 -0
- package/dist/encoding/Yaml.d.ts +6 -2
- package/dist/encoding/Yaml.d.ts.map +1 -1
- package/dist/encoding/Yaml.js +97 -34
- package/dist/encoding/Yaml.js.map +1 -1
- package/dist/encoding/Zip.d.ts +413 -0
- package/dist/encoding/Zip.d.ts.map +1 -0
- package/dist/encoding/Zip.js +1255 -0
- package/dist/encoding/Zip.js.map +1 -0
- package/dist/encoding/index.d.ts +20 -0
- package/dist/encoding/index.d.ts.map +1 -1
- package/dist/encoding/index.js +20 -0
- package/dist/encoding/index.js.map +1 -1
- package/dist/eventlog/EventJournal.d.ts +90 -5
- package/dist/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/eventlog/EventJournal.js +488 -228
- package/dist/eventlog/EventJournal.js.map +1 -1
- package/dist/eventlog/EventLog.d.ts +180 -12
- package/dist/eventlog/EventLog.d.ts.map +1 -1
- package/dist/eventlog/EventLog.js +394 -146
- package/dist/eventlog/EventLog.js.map +1 -1
- package/dist/eventlog/EventLogEncryption.d.ts +36 -30
- package/dist/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/eventlog/EventLogEncryption.js +97 -38
- package/dist/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/eventlog/EventLogMessage.d.ts +74 -34
- package/dist/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/eventlog/EventLogMessage.js +45 -11
- package/dist/eventlog/EventLogMessage.js.map +1 -1
- package/dist/eventlog/EventLogRemote.d.ts +45 -8
- package/dist/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/eventlog/EventLogRemote.js +51 -14
- package/dist/eventlog/EventLogRemote.js.map +1 -1
- package/dist/eventlog/EventLogServer.d.ts +46 -3
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +119 -19
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.d.ts +23 -33
- package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.js +97 -70
- package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/EventLogServerUnencrypted.d.ts +39 -5
- package/dist/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerUnencrypted.js +151 -69
- package/dist/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/eventlog/EventRow.d.ts +288 -0
- package/dist/eventlog/EventRow.d.ts.map +1 -0
- package/dist/eventlog/EventRow.js +435 -0
- package/dist/eventlog/EventRow.js.map +1 -0
- package/dist/eventlog/SqlEventJournal.d.ts +18 -18
- package/dist/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/eventlog/SqlEventJournal.js +387 -159
- package/dist/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.d.ts +10 -18
- package/dist/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.js +179 -69
- package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerUnencrypted.d.ts +23 -3
- package/dist/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/eventlog/SqlEventLogServerUnencrypted.js +102 -51
- package/dist/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/eventlog/index.d.ts +5 -0
- package/dist/eventlog/index.d.ts.map +1 -1
- package/dist/eventlog/index.js +5 -0
- package/dist/eventlog/index.js.map +1 -1
- package/dist/eventlog/internal/conflicts.d.ts +47 -0
- package/dist/eventlog/internal/conflicts.d.ts.map +1 -0
- package/dist/eventlog/internal/conflicts.js +92 -0
- package/dist/eventlog/internal/conflicts.js.map +1 -0
- package/dist/graphql/GraphQLClient.d.ts.map +1 -1
- package/dist/graphql/GraphQLClient.js +12 -5
- package/dist/graphql/GraphQLClient.js.map +1 -1
- package/dist/graphql/GraphQLClientError.d.ts +2 -2
- package/dist/graphql/GraphQLClientError.d.ts.map +1 -1
- package/dist/graphql/GraphQLClientError.js +4 -18
- package/dist/graphql/GraphQLClientError.js.map +1 -1
- package/dist/graphql/GraphQLProtocol.d.ts +252 -11
- package/dist/graphql/GraphQLProtocol.d.ts.map +1 -1
- package/dist/graphql/GraphQLProtocol.js +99 -8
- package/dist/graphql/GraphQLProtocol.js.map +1 -1
- package/dist/graphql/GraphQLResolver.d.ts +3 -1
- package/dist/graphql/GraphQLResolver.d.ts.map +1 -1
- package/dist/graphql/GraphQLResolver.js +91 -19
- package/dist/graphql/GraphQLResolver.js.map +1 -1
- package/dist/http/FetchHttpClient.d.ts +13 -3
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +56 -6
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/FindMyWay/internal/router.js +12 -1
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/Headers.d.ts +230 -3
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +267 -5
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts +105 -0
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +69 -17
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +8 -6
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +274 -7
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +91 -3
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpClientResponse.d.ts +53 -0
- package/dist/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/http/HttpClientResponse.js +47 -0
- package/dist/http/HttpClientResponse.js.map +1 -1
- package/dist/http/HttpEffect.d.ts +6 -2
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +21 -17
- package/dist/http/HttpEffect.js.map +1 -1
- package/dist/http/HttpIncomingMessage.d.ts +2 -1
- package/dist/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/http/HttpIncomingMessage.js +3 -23
- package/dist/http/HttpIncomingMessage.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts +179 -2
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +226 -18
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +58 -14
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerError.d.ts +5 -2
- package/dist/http/HttpServerError.d.ts.map +1 -1
- package/dist/http/HttpServerError.js +11 -7
- package/dist/http/HttpServerError.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts +25 -5
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +38 -12
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts +17 -8
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +37 -21
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/HttpStaticServer.d.ts +0 -12
- package/dist/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/http/HttpStaticServer.js +25 -17
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http/HttpTraceContext.js +1 -1
- package/dist/http/HttpTraceContext.js.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.d.ts +15 -1
- package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.js +87 -5
- package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
- package/dist/http/MultipartParser/internal/headers.d.ts.map +1 -1
- package/dist/http/MultipartParser/internal/headers.js +4 -12
- package/dist/http/MultipartParser/internal/headers.js.map +1 -1
- package/dist/http/MultipartParser/internal/multipart.d.ts.map +1 -1
- package/dist/http/MultipartParser/internal/multipart.js +6 -27
- package/dist/http/MultipartParser/internal/multipart.js.map +1 -1
- package/dist/http/Url.d.ts.map +1 -1
- package/dist/http/Url.js +8 -2
- package/dist/http/Url.js.map +1 -1
- package/dist/http/UrlParams.d.ts +112 -8
- package/dist/http/UrlParams.d.ts.map +1 -1
- package/dist/http/UrlParams.js +141 -14
- package/dist/http/UrlParams.js.map +1 -1
- package/dist/http/internal/compression.d.ts +1 -1
- package/dist/http/internal/compression.d.ts.map +1 -1
- package/dist/http/internal/compression.js +2 -10
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/compressionBody.d.ts +2 -0
- package/dist/http/internal/compressionBody.d.ts.map +1 -0
- package/dist/http/internal/compressionBody.js +36 -0
- package/dist/http/internal/compressionBody.js.map +1 -0
- package/dist/http/internal/decompression.d.ts +2 -0
- package/dist/http/internal/decompression.d.ts.map +1 -0
- package/dist/http/internal/decompression.js +168 -0
- package/dist/http/internal/decompression.js.map +1 -0
- package/dist/http/internal/lazyStream.d.ts +2 -0
- package/dist/http/internal/lazyStream.d.ts.map +1 -0
- package/dist/http/internal/lazyStream.js +18 -0
- package/dist/http/internal/lazyStream.js.map +1 -0
- package/dist/http/internal/requestState.d.ts +2 -0
- package/dist/http/internal/requestState.d.ts.map +1 -0
- package/dist/http/internal/requestState.js +28 -0
- package/dist/http/internal/requestState.js.map +1 -0
- package/dist/http/internal/tracing.js +14 -4
- package/dist/http/internal/tracing.js.map +1 -1
- package/dist/http/internal/urlParams.d.ts +2 -0
- package/dist/http/internal/urlParams.d.ts.map +1 -0
- package/dist/http/internal/urlParams.js +4 -0
- package/dist/http/internal/urlParams.js.map +1 -0
- package/dist/http/internal/webResponse.d.ts +2 -0
- package/dist/http/internal/webResponse.d.ts.map +1 -0
- package/dist/http/internal/webResponse.js +12 -0
- package/dist/http/internal/webResponse.js.map +1 -0
- package/dist/http-api/HttpApi.js +1 -1
- package/dist/http-api/HttpApi.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +121 -18
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +29 -4
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +85 -24
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts +55 -29
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +49 -5
- package/dist/http-api/HttpApiEndpoint.js.map +1 -1
- package/dist/http-api/HttpApiError.d.ts +58 -0
- package/dist/http-api/HttpApiError.d.ts.map +1 -1
- package/dist/http-api/HttpApiError.js +38 -12
- package/dist/http-api/HttpApiError.js.map +1 -1
- package/dist/http-api/HttpApiScalar.d.ts +2 -1
- package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
- package/dist/http-api/HttpApiScalar.js +6 -3
- package/dist/http-api/HttpApiScalar.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +191 -9
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +137 -4
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/http-api/HttpApiSwagger.d.ts +5 -0
- package/dist/http-api/HttpApiSwagger.d.ts.map +1 -1
- package/dist/http-api/HttpApiSwagger.js +14 -4
- package/dist/http-api/HttpApiSwagger.js.map +1 -1
- package/dist/http-api/HttpApiTest.d.ts +13 -2
- package/dist/http-api/HttpApiTest.d.ts.map +1 -1
- package/dist/http-api/HttpApiTest.js +30 -9
- package/dist/http-api/HttpApiTest.js.map +1 -1
- package/dist/http-api/OpenApi.d.ts +17 -3
- package/dist/http-api/OpenApi.d.ts.map +1 -1
- package/dist/http-api/OpenApi.js +57 -32
- package/dist/http-api/OpenApi.js.map +1 -1
- package/dist/http-api/internal/path.js +35 -10
- package/dist/http-api/internal/path.js.map +1 -1
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +18 -2
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +19 -7
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +89 -76
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/graphql.js +12 -2
- package/dist/internal/graphql.js.map +1 -1
- package/dist/internal/hashMap.js +2 -2
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hydration.d.ts +2 -0
- package/dist/internal/hydration.d.ts.map +1 -0
- package/dist/internal/hydration.js +15 -0
- package/dist/internal/hydration.js.map +1 -0
- package/dist/internal/inflate.d.ts +2 -0
- package/dist/internal/inflate.d.ts.map +1 -0
- package/dist/internal/inflate.js +680 -0
- package/dist/internal/inflate.js.map +1 -0
- package/dist/internal/record.js +6 -0
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/request.js +20 -7
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schedule.js +17 -22
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +136 -126
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/interpreter.js +51 -36
- package/dist/internal/schema/interpreter.js.map +1 -1
- package/dist/internal/schema/standardSchema.js +34 -33
- package/dist/internal/schema/standardSchema.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +7 -2
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.js +86 -1
- package/dist/internal/schema/toCodec.js.map +1 -1
- package/dist/internal/schema/toFormatter.js +5 -5
- package/dist/internal/schema/toFormatter.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +60 -38
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/trie.js +1 -3
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/uuid.js +7 -3
- package/dist/internal/uuid.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/net/NetAddress.d.ts.map +1 -1
- package/dist/net/NetAddress.js +2 -8
- package/dist/net/NetAddress.js.map +1 -1
- package/dist/observability/Otlp.d.ts +15 -0
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +3 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts +8 -0
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +15 -13
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts +17 -0
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +14 -1
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts +17 -0
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +18 -3
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpResource.d.ts +3 -1
- package/dist/observability/OtlpResource.d.ts.map +1 -1
- package/dist/observability/OtlpResource.js +11 -4
- package/dist/observability/OtlpResource.js.map +1 -1
- package/dist/observability/OtlpSerialization.d.ts +5 -0
- package/dist/observability/OtlpSerialization.d.ts.map +1 -1
- package/dist/observability/OtlpSerialization.js +14 -3
- package/dist/observability/OtlpSerialization.js.map +1 -1
- package/dist/observability/OtlpTracer.d.ts +17 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +15 -2
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/observability/internal/protobuf.d.ts +0 -9
- package/dist/observability/internal/protobuf.d.ts.map +1 -1
- package/dist/observability/internal/protobuf.js +2 -10
- package/dist/observability/internal/protobuf.js.map +1 -1
- package/dist/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/persistence/PersistedCache.js +1 -1
- package/dist/persistence/PersistedCache.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts +6 -2
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +162 -84
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/persistence/Persistence.d.ts +28 -0
- package/dist/persistence/Persistence.d.ts.map +1 -1
- package/dist/persistence/Persistence.js +36 -8
- package/dist/persistence/Persistence.js.map +1 -1
- package/dist/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/persistence/RateLimiter.js +8 -12
- package/dist/persistence/RateLimiter.js.map +1 -1
- package/dist/persistence/UserDirectories.d.ts +129 -0
- package/dist/persistence/UserDirectories.d.ts.map +1 -0
- package/dist/persistence/UserDirectories.js +178 -0
- package/dist/persistence/UserDirectories.js.map +1 -0
- package/dist/persistence/index.d.ts +5 -0
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +5 -0
- package/dist/persistence/index.js.map +1 -1
- package/dist/process/ChildProcess.d.ts +2 -1
- package/dist/process/ChildProcess.d.ts.map +1 -1
- package/dist/process/ChildProcess.js.map +1 -1
- package/dist/reactivity/AsyncResult.d.ts +6 -0
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/reactivity/AsyncResult.js +28 -1
- package/dist/reactivity/AsyncResult.js.map +1 -1
- package/dist/reactivity/Atom.d.ts +69 -30
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +40 -15
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomHttpApi.d.ts +5 -5
- package/dist/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/reactivity/AtomHttpApi.js +1 -1
- package/dist/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/reactivity/AtomRegistry.d.ts +2 -2
- package/dist/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/reactivity/AtomRegistry.js +47 -10
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/reactivity/AtomRpc.d.ts +3 -3
- package/dist/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/reactivity/AtomRpc.js +1 -1
- package/dist/reactivity/AtomRpc.js.map +1 -1
- package/dist/reactivity/Hydration.d.ts.map +1 -1
- package/dist/reactivity/Hydration.js +46 -12
- package/dist/reactivity/Hydration.js.map +1 -1
- package/dist/reactivity/Reactivity.d.ts +71 -7
- package/dist/reactivity/Reactivity.d.ts.map +1 -1
- package/dist/reactivity/Reactivity.js +21 -12
- package/dist/reactivity/Reactivity.js.map +1 -1
- package/dist/rpc/Rpc.d.ts +18 -0
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.js +20 -0
- package/dist/rpc/Rpc.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +26 -2
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +202 -61
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts +15 -0
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +21 -5
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +9 -18
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/schema/Model.d.ts +1 -1
- package/dist/schema/VariantSchema.d.ts +22 -3
- package/dist/schema/VariantSchema.d.ts.map +1 -1
- package/dist/schema/VariantSchema.js +32 -18
- package/dist/schema/VariantSchema.js.map +1 -1
- package/dist/socket/Socket.d.ts +23 -1
- package/dist/socket/Socket.d.ts.map +1 -1
- package/dist/socket/Socket.js +36 -3
- package/dist/socket/Socket.js.map +1 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +15 -3
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +151 -12
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +156 -34
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/SqlResolver.d.ts +9 -0
- package/dist/sql/SqlResolver.d.ts.map +1 -1
- package/dist/sql/SqlResolver.js +9 -0
- package/dist/sql/SqlResolver.js.map +1 -1
- package/dist/sql/Statement.d.ts +3 -1
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +24 -5
- package/dist/sql/Statement.js.map +1 -1
- package/dist/testing/TestClock.d.ts +16 -3
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +115 -23
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +7 -1
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +9 -3
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/workflow/Activity.js +1 -0
- package/dist/workflow/Activity.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +22 -0
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +15 -3
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts +20 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +52 -24
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +13 -3
- package/src/Array.ts +223 -61
- package/src/Bytes.ts +111 -0
- package/src/Channel.ts +287 -439
- package/src/ChannelSchema.ts +1 -49
- package/src/Chunk.ts +55 -61
- package/src/Config.ts +12 -86
- package/src/ConfigProvider.ts +41 -44
- package/src/Cron.ts +6 -3
- package/src/Duration.ts +70 -21
- package/src/Effect.ts +642 -220
- package/src/Equivalence.ts +7 -4
- package/src/Exit.ts +24 -9
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +13 -66
- package/src/FileSystem.ts +33 -9
- package/src/Graph.ts +171 -1263
- package/src/HashSet.ts +0 -60
- package/src/Iterable.ts +15 -14
- package/src/JsonSchema.ts +28 -3
- package/src/Layer.ts +2 -2
- package/src/ManagedRuntime.ts +72 -6
- package/src/Match.ts +65 -12
- package/src/Metric.ts +249 -507
- package/src/MutableHashMap.ts +4 -473
- package/src/Number.ts +2 -2
- package/src/Optic.ts +17 -332
- package/src/Path.ts +61 -8
- package/src/PubSub.ts +12 -7
- package/src/Queue.ts +5 -37
- package/src/Random.ts +1 -1
- package/src/RcMap.ts +14 -8
- package/src/Record.ts +51 -0
- package/src/Ref.ts +7 -104
- package/src/References.ts +5 -4
- package/src/RequestResolver.ts +46 -87
- package/src/Resource.ts +1 -1
- package/src/Runtime.ts +19 -18
- package/src/Schedule.ts +2 -94
- package/src/Schema.ts +596 -348
- package/src/SchemaAST.ts +20 -9
- package/src/SchemaGetter.ts +22 -5
- package/src/SchemaIssue.ts +44 -53
- package/src/SchemaRepresentation.ts +64 -1
- package/src/SchemaTransformation.ts +1 -1
- package/src/Scope.ts +12 -2
- package/src/ScopedCache.ts +17 -142
- package/src/SemVer.ts +1528 -0
- package/src/SemVerRange.ts +883 -0
- package/src/Sink.ts +6 -2
- package/src/Stream.ts +334 -1011
- package/src/String.ts +25 -12
- package/src/TextDiff.ts +766 -0
- package/src/TxHashMap.ts +1 -103
- package/src/TxHashSet.ts +48 -753
- package/src/TxRef.ts +4 -2
- package/src/ai/AiError.ts +69 -5
- package/src/ai/Chat.ts +10 -5
- package/src/ai/Decision.ts +119 -22
- package/src/ai/DecisionModel.ts +265 -109
- package/src/ai/EmbeddingModel.ts +25 -13
- package/src/ai/LanguageModel.ts +57 -51
- package/src/ai/McpClient.ts +1211 -0
- package/src/ai/McpClientError.ts +329 -0
- package/src/ai/McpProtocol.ts +2 -2
- package/src/ai/McpSchema.ts +153 -35
- package/src/ai/McpServer.ts +232 -275
- package/src/ai/Prompt.ts +49 -35
- package/src/ai/Response.ts +195 -65
- package/src/ai/Tool.ts +12 -4
- package/src/ai/Toolkit.ts +78 -10
- package/src/ai/index.ts +12 -0
- package/src/ai/internal/mcpCore.ts +13 -14
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +1 -1
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +1 -1
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -3
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -3
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +12 -14
- package/src/ai/internal/mcpProtocol.ts +22 -2
- package/src/ai/internal/mcpRuntime.ts +3 -4
- package/src/ai/internal/mcpSchema/v2024_11_05.ts +20 -13
- package/src/ai/internal/mcpSchema/v2025_03_26.ts +4 -2
- package/src/ai/internal/mcpSchema/v2025_06_18.ts +7 -7
- package/src/ai/internal/mcpSchema/v2025_11_25.ts +8 -8
- package/src/ai/internal/mcpSchema/v2026_07_28.ts +44 -42
- package/src/cli/CliError.ts +49 -4
- package/src/cli/Command.ts +316 -9
- package/src/cli/Completions.ts +10 -0
- package/src/cli/Flag.ts +218 -0
- package/src/cli/GlobalFlag.ts +3 -3
- package/src/cli/Param.ts +218 -0
- package/src/cli/TerminalCapabilities.ts +156 -0
- package/src/cli/index.ts +6 -0
- package/src/cli/internal/command.ts +10 -4
- package/src/cli/internal/completions/bash.ts +7 -5
- package/src/cli/internal/completions/descriptor.ts +20 -1
- package/src/cli/internal/completions/fish.ts +12 -10
- package/src/cli/internal/completions/powershell.ts +25 -13
- package/src/cli/internal/completions/zsh.ts +15 -8
- package/src/cli/internal/formatter.ts +18 -0
- package/src/cli/internal/lexer.ts +12 -5
- package/src/cli/internal/parser.ts +43 -14
- package/src/cli/internal/wizard.ts +2 -1
- package/src/cluster/ClusterCron.ts +94 -35
- package/src/cluster/ClusterMetrics.ts +149 -7
- package/src/cluster/ClusterWorkflowEngine.ts +164 -53
- package/src/cluster/Entity.ts +4 -0
- package/src/cluster/MessageStorage.ts +21 -3
- package/src/cluster/Runners.ts +145 -72
- package/src/cluster/Sharding.ts +118 -38
- package/src/cluster/ShardingConfig.ts +15 -0
- package/src/cluster/SqlMessageStorage.ts +58 -55
- package/src/cluster/SqlRunnerStorage.ts +10 -4
- package/src/cluster/internal/entityManager.ts +81 -11
- package/src/devtools/DevTools.ts +3 -2
- package/src/devtools/DevToolsClient.ts +27 -10
- package/src/encoding/Base64Url.ts +31 -0
- package/src/encoding/Ini.ts +3 -0
- package/src/encoding/JsonArray.ts +849 -0
- package/src/encoding/Ndjson.ts +211 -20
- package/src/encoding/SchemaBinary.ts +14 -48
- package/src/encoding/Sse.ts +1 -1
- package/src/encoding/Tar.ts +1417 -0
- package/src/encoding/Toml.ts +3 -3
- package/src/encoding/Xml.ts +2037 -0
- package/src/encoding/Yaml.ts +108 -36
- package/src/encoding/Zip.ts +1558 -0
- package/src/encoding/index.ts +24 -0
- package/src/eventlog/EventJournal.ts +611 -227
- package/src/eventlog/EventLog.ts +496 -196
- package/src/eventlog/EventLogEncryption.ts +128 -43
- package/src/eventlog/EventLogMessage.ts +62 -11
- package/src/eventlog/EventLogRemote.ts +77 -21
- package/src/eventlog/EventLogServer.ts +162 -20
- package/src/eventlog/EventLogServerEncrypted.ts +121 -80
- package/src/eventlog/EventLogServerUnencrypted.ts +180 -77
- package/src/eventlog/EventRow.ts +706 -0
- package/src/eventlog/SqlEventJournal.ts +453 -173
- package/src/eventlog/SqlEventLogServerEncrypted.ts +212 -83
- package/src/eventlog/SqlEventLogServerUnencrypted.ts +141 -62
- package/src/eventlog/index.ts +6 -0
- package/src/eventlog/internal/conflicts.ts +123 -0
- package/src/graphql/GraphQLClient.ts +17 -5
- package/src/graphql/GraphQLClientError.ts +5 -12
- package/src/graphql/GraphQLProtocol.ts +277 -20
- package/src/graphql/GraphQLResolver.ts +109 -230
- package/src/http/FetchHttpClient.ts +61 -8
- package/src/http/FindMyWay/internal/router.ts +13 -1
- package/src/http/Headers.ts +343 -163
- package/src/http/HttpClient.ts +144 -136
- package/src/http/HttpClientError.ts +10 -6
- package/src/http/HttpClientRequest.ts +315 -11
- package/src/http/HttpClientResponse.ts +71 -0
- package/src/http/HttpEffect.ts +25 -33
- package/src/http/HttpIncomingMessage.ts +3 -23
- package/src/http/HttpMiddleware.ts +265 -28
- package/src/http/HttpRouter.ts +67 -14
- package/src/http/HttpServerError.ts +14 -7
- package/src/http/HttpServerRequest.ts +73 -14
- package/src/http/HttpServerResponse.ts +49 -23
- package/src/http/HttpStaticServer.ts +29 -19
- package/src/http/HttpTraceContext.ts +1 -1
- package/src/http/MultipartParser/internal/contentType.ts +107 -6
- package/src/http/MultipartParser/internal/headers.ts +4 -16
- package/src/http/MultipartParser/internal/multipart.ts +10 -32
- package/src/http/Url.ts +8 -2
- package/src/http/UrlParams.ts +225 -26
- package/src/http/internal/compression.ts +3 -17
- package/src/http/internal/compressionBody.ts +56 -0
- package/src/http/internal/decompression.ts +235 -0
- package/src/http/internal/lazyStream.ts +25 -0
- package/src/http/internal/requestState.ts +33 -0
- package/src/http/internal/tracing.ts +21 -4
- package/src/http/internal/urlParams.ts +5 -0
- package/src/http/internal/webResponse.ts +20 -0
- package/src/http-api/HttpApi.ts +1 -1
- package/src/http-api/HttpApiBuilder.ts +151 -23
- package/src/http-api/HttpApiClient.ts +160 -31
- package/src/http-api/HttpApiEndpoint.ts +144 -33
- package/src/http-api/HttpApiError.ts +55 -0
- package/src/http-api/HttpApiScalar.ts +4 -3
- package/src/http-api/HttpApiSchema.ts +275 -13
- package/src/http-api/HttpApiSwagger.ts +11 -4
- package/src/http-api/HttpApiTest.ts +33 -9
- package/src/http-api/OpenApi.ts +84 -42
- package/src/http-api/internal/path.ts +40 -12
- package/src/index.ts +24 -0
- package/src/internal/core.ts +22 -2
- package/src/internal/dateTime.ts +20 -7
- package/src/internal/effect.ts +125 -88
- package/src/internal/graphql.ts +30 -7
- package/src/internal/hashMap.ts +2 -2
- package/src/internal/hydration.ts +15 -0
- package/src/internal/inflate.ts +710 -0
- package/src/internal/record.ts +6 -0
- package/src/internal/request.ts +21 -6
- package/src/internal/schedule.ts +20 -39
- package/src/internal/schema/fromJsonSchemaDocument.ts +262 -193
- package/src/internal/schema/interpreter.ts +58 -45
- package/src/internal/schema/standardSchema.ts +32 -30
- package/src/internal/schema/toCodeDocument.ts +8 -3
- package/src/internal/schema/toCodec.ts +116 -1
- package/src/internal/schema/toFormatter.ts +6 -6
- package/src/internal/schema/toJsonSchemaDocument.ts +69 -39
- package/src/internal/trie.ts +1 -3
- package/src/internal/uuid.ts +15 -10
- package/src/internal/version.ts +1 -1
- package/src/net/NetAddress.ts +2 -9
- package/src/observability/Otlp.ts +18 -0
- package/src/observability/OtlpExporter.ts +19 -15
- package/src/observability/OtlpLogger.ts +31 -2
- package/src/observability/OtlpMetrics.ts +35 -4
- package/src/observability/OtlpResource.ts +16 -6
- package/src/observability/OtlpSerialization.ts +17 -3
- package/src/observability/OtlpTracer.ts +32 -3
- package/src/observability/internal/protobuf.ts +2 -10
- package/src/persistence/PersistedCache.ts +3 -1
- package/src/persistence/PersistedQueue.ts +223 -153
- package/src/persistence/Persistence.ts +64 -30
- package/src/persistence/RateLimiter.ts +18 -21
- package/src/persistence/UserDirectories.ts +273 -0
- package/src/persistence/index.ts +6 -0
- package/src/process/ChildProcess.ts +2 -1
- package/src/reactivity/AsyncResult.ts +35 -38
- package/src/reactivity/Atom.ts +134 -166
- package/src/reactivity/AtomHttpApi.ts +10 -16
- package/src/reactivity/AtomRegistry.ts +53 -30
- package/src/reactivity/AtomRpc.ts +6 -22
- package/src/reactivity/Hydration.ts +53 -12
- package/src/reactivity/Reactivity.ts +97 -39
- package/src/rpc/Rpc.ts +21 -0
- package/src/rpc/RpcClient.ts +285 -104
- package/src/rpc/RpcSerialization.ts +21 -5
- package/src/rpc/RpcServer.ts +11 -20
- package/src/schema/VariantSchema.ts +86 -22
- package/src/socket/Socket.ts +45 -20
- package/src/sql/Migrator.ts +19 -9
- package/src/sql/SqlClient.ts +275 -36
- package/src/sql/SqlResolver.ts +9 -0
- package/src/sql/Statement.ts +35 -8
- package/src/testing/TestClock.ts +147 -29
- package/src/testing/TestSchema.ts +9 -3
- package/src/workflow/Activity.ts +1 -0
- package/src/workflow/Workflow.ts +31 -5
- package/src/workflow/WorkflowEngine.ts +93 -31
- package/dist/http/internal/preResponseHandler.d.ts +0 -2
- package/dist/http/internal/preResponseHandler.d.ts.map +0 -1
- package/dist/http/internal/preResponseHandler.js +0 -14
- package/dist/http/internal/preResponseHandler.js.map +0 -1
- package/src/http/internal/preResponseHandler.ts +0 -19
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Defines the provider-neutral service for structured decisions.
|
|
3
3
|
* `decide` encodes one input as JSON, sends its named decisions in one provider
|
|
4
4
|
* call, and validates the answers. Failures are reported as `AiError` values.
|
|
5
|
+
* `decideSettled` makes the same call but reports each decision separately, so
|
|
6
|
+
* valid answers survive when others are missing, refused, or invalid.
|
|
5
7
|
* @stability unstable
|
|
6
8
|
* @since 4.0.0
|
|
7
9
|
*/
|
|
@@ -10,6 +12,7 @@ import * as Effect from "../Effect.ts";
|
|
|
10
12
|
import * as Schema from "../Schema.ts";
|
|
11
13
|
import * as AiError from "./AiError.ts";
|
|
12
14
|
import type * as Decision from "./Decision.ts";
|
|
15
|
+
import type * as Response from "./Response.ts";
|
|
13
16
|
/**
|
|
14
17
|
* Service key for answering decisions about an input. Create implementations
|
|
15
18
|
* with `make`.
|
|
@@ -77,7 +80,17 @@ export interface Image {
|
|
|
77
80
|
readonly data: string | Uint8Array | URL;
|
|
78
81
|
}
|
|
79
82
|
/**
|
|
80
|
-
*
|
|
83
|
+
* Provider-specific response metadata keyed by provider name. Provider
|
|
84
|
+
* packages augment this interface.
|
|
85
|
+
*
|
|
86
|
+
* @stability unstable
|
|
87
|
+
* @category models
|
|
88
|
+
* @since 4.0.6
|
|
89
|
+
*/
|
|
90
|
+
export interface DecideResponseMetadata extends Response.ProviderMetadata {
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Answers for every decision in a definition with usage and response metadata.
|
|
81
94
|
*
|
|
82
95
|
* @see {@link DecisionUsage} for token usage metadata
|
|
83
96
|
*
|
|
@@ -88,6 +101,42 @@ export interface Image {
|
|
|
88
101
|
export interface DecideResponse<Decisions extends Record<string, Decision.Any>> {
|
|
89
102
|
readonly answers: Decision.Answers<Decisions>;
|
|
90
103
|
readonly usage: DecisionUsage;
|
|
104
|
+
/**
|
|
105
|
+
* Response id reported by the provider.
|
|
106
|
+
*
|
|
107
|
+
* @since 4.0.6
|
|
108
|
+
*/
|
|
109
|
+
readonly id?: string | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Model that answered. Can differ from the requested model when the
|
|
112
|
+
* provider resolves an alias.
|
|
113
|
+
*
|
|
114
|
+
* @since 4.0.6
|
|
115
|
+
*/
|
|
116
|
+
readonly modelId?: string | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Provider-specific metadata, such as reported cost.
|
|
119
|
+
*
|
|
120
|
+
* @since 4.0.6
|
|
121
|
+
*/
|
|
122
|
+
readonly metadata: DecideResponseMetadata;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Per-decision outcomes, token usage, and response metadata for the whole
|
|
126
|
+
* request.
|
|
127
|
+
*
|
|
128
|
+
* @see {@link decideSettled} for producing this response
|
|
129
|
+
*
|
|
130
|
+
* @stability unstable
|
|
131
|
+
* @category models
|
|
132
|
+
* @since 4.0.6
|
|
133
|
+
*/
|
|
134
|
+
export interface DecideSettledResponse<Decisions extends Record<string, Decision.Any>> {
|
|
135
|
+
readonly outcomes: Decision.Outcomes<Decisions>;
|
|
136
|
+
readonly usage: DecisionUsage;
|
|
137
|
+
readonly id?: string | undefined;
|
|
138
|
+
readonly modelId?: string | undefined;
|
|
139
|
+
readonly metadata: DecideResponseMetadata;
|
|
91
140
|
}
|
|
92
141
|
/**
|
|
93
142
|
* Provider input options for a decision request.
|
|
@@ -105,7 +154,7 @@ export interface ProviderOptions {
|
|
|
105
154
|
readonly images?: ReadonlyArray<Image> | undefined;
|
|
106
155
|
}
|
|
107
156
|
/**
|
|
108
|
-
* Provider answer
|
|
157
|
+
* Provider classify answer. Omit `probabilities` when no distribution is available.
|
|
109
158
|
*
|
|
110
159
|
* @stability unstable
|
|
111
160
|
* @category models
|
|
@@ -114,13 +163,12 @@ export interface ProviderOptions {
|
|
|
114
163
|
export interface ProviderClassifyAnswer {
|
|
115
164
|
readonly _tag: "Classify";
|
|
116
165
|
readonly label: string;
|
|
117
|
-
readonly probabilities
|
|
166
|
+
readonly probabilities?: Readonly<Record<string, number>> | undefined;
|
|
118
167
|
readonly confidence?: number | undefined;
|
|
119
168
|
}
|
|
120
169
|
/**
|
|
121
|
-
* Provider answer
|
|
122
|
-
*
|
|
123
|
-
* first criteria entry on ties.
|
|
170
|
+
* Provider rate answer. The highest probability determines the label, with
|
|
171
|
+
* ties going to the first criterion. Omit `probabilities` when unavailable.
|
|
124
172
|
*
|
|
125
173
|
* @stability unstable
|
|
126
174
|
* @category models
|
|
@@ -129,7 +177,7 @@ export interface ProviderClassifyAnswer {
|
|
|
129
177
|
export interface ProviderRateAnswer {
|
|
130
178
|
readonly _tag: "Rate";
|
|
131
179
|
readonly rating: number;
|
|
132
|
-
readonly probabilities
|
|
180
|
+
readonly probabilities?: Readonly<Record<string, number>> | undefined;
|
|
133
181
|
readonly confidence?: number | undefined;
|
|
134
182
|
}
|
|
135
183
|
/**
|
|
@@ -143,6 +191,16 @@ export interface ProviderProbabilityAnswer {
|
|
|
143
191
|
readonly _tag: "Probability";
|
|
144
192
|
readonly probability: number;
|
|
145
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Provider refusal to answer a decision.
|
|
196
|
+
*
|
|
197
|
+
* @stability unstable
|
|
198
|
+
* @category models
|
|
199
|
+
* @since 4.0.6
|
|
200
|
+
*/
|
|
201
|
+
export interface ProviderRefusalAnswer {
|
|
202
|
+
readonly _tag: "Refusal";
|
|
203
|
+
}
|
|
146
204
|
/**
|
|
147
205
|
* Provider answer for any decision kind.
|
|
148
206
|
*
|
|
@@ -150,11 +208,13 @@ export interface ProviderProbabilityAnswer {
|
|
|
150
208
|
* @category models
|
|
151
209
|
* @since 4.0.0
|
|
152
210
|
*/
|
|
153
|
-
export type ProviderAnswer = ProviderClassifyAnswer | ProviderRateAnswer | ProviderProbabilityAnswer;
|
|
211
|
+
export type ProviderAnswer = ProviderClassifyAnswer | ProviderRateAnswer | ProviderProbabilityAnswer | ProviderRefusalAnswer;
|
|
154
212
|
/**
|
|
155
213
|
* Provider response for a decision request.
|
|
156
214
|
* `answers` is keyed like the requested decisions. Each answer is validated
|
|
157
|
-
* against its decision before it is returned to the caller.
|
|
215
|
+
* against its decision before it is returned to the caller. Omit the key of a
|
|
216
|
+
* decision the provider did not answer. `id`, `modelId` and `metadata` are
|
|
217
|
+
* passed through; `metadata` defaults to `{}`.
|
|
158
218
|
*
|
|
159
219
|
* @stability unstable
|
|
160
220
|
* @category models
|
|
@@ -166,6 +226,9 @@ export interface ProviderResponse {
|
|
|
166
226
|
readonly inputTokens: number | undefined;
|
|
167
227
|
readonly outputTokens: number | undefined;
|
|
168
228
|
};
|
|
229
|
+
readonly id?: string | undefined;
|
|
230
|
+
readonly modelId?: string | undefined;
|
|
231
|
+
readonly metadata?: DecideResponseMetadata | undefined;
|
|
169
232
|
}
|
|
170
233
|
/**
|
|
171
234
|
* Decision operations over a definition.
|
|
@@ -177,13 +240,16 @@ export interface ProviderResponse {
|
|
|
177
240
|
export interface DecisionModel {
|
|
178
241
|
readonly [TypeId]: TypeId;
|
|
179
242
|
readonly decide: <Input extends Schema.Constraint, Decisions extends Record<string, Decision.Any>>(definition: Decision.Definition<Input, Decisions>, options: DecideOptions<Input>) => Effect.Effect<DecideResponse<Decisions>, AiError.AiError, Input["EncodingServices"]>;
|
|
243
|
+
readonly decideSettled: <Input extends Schema.Constraint, Decisions extends Record<string, Decision.Any>>(definition: Decision.Definition<Input, Decisions>, options: DecideOptions<Input>) => Effect.Effect<DecideSettledResponse<Decisions>, AiError.AiError, Input["EncodingServices"]>;
|
|
180
244
|
}
|
|
181
245
|
/**
|
|
182
246
|
* Creates a `DecisionModel` that encodes inputs as JSON and validates provider answers.
|
|
183
247
|
* Answers must cover every decision and use its labels. Distributions must
|
|
184
248
|
* sum to 1 within `1e-6`, optional confidence must be in `[0, 1]`, and ratings must be
|
|
185
|
-
* in `[0, criteria.length - 1]`.
|
|
186
|
-
* `AiError.
|
|
249
|
+
* in `[0, criteria.length - 1]`. With `decide`, refused decisions fail with
|
|
250
|
+
* `AiError.ContentPolicyError` and other unanswered decisions fail with
|
|
251
|
+
* `AiError.InvalidOutputError`; `decideSettled` reports them per decision
|
|
252
|
+
* instead. Encoding failures use `AiError.InvalidUserInputError`.
|
|
187
253
|
*
|
|
188
254
|
* **Details**
|
|
189
255
|
*
|
|
@@ -214,6 +280,9 @@ export declare const make: (params: {
|
|
|
214
280
|
* Explicit `undefined` fields become `null`; absent fields stay absent.
|
|
215
281
|
* Custom declarations need a JSON codec annotation or encoding fails.
|
|
216
282
|
* Returned answers and probability dictionaries have null prototypes.
|
|
283
|
+
* Fails with `AiError.ContentPolicyError` if the provider refuses any decision,
|
|
284
|
+
* and otherwise with `AiError.InvalidOutputError` for the first unanswered
|
|
285
|
+
* decision in definition order.
|
|
217
286
|
*
|
|
218
287
|
* **Example** (Triaging a ticket)
|
|
219
288
|
*
|
|
@@ -240,11 +309,60 @@ export declare const make: (params: {
|
|
|
240
309
|
* ```
|
|
241
310
|
*
|
|
242
311
|
* @see {@link DecisionModel} for the service this function requires
|
|
312
|
+
* @see {@link decideSettled} for keeping valid answers when others fail
|
|
243
313
|
*
|
|
244
314
|
* @stability unstable
|
|
245
315
|
* @category decisions
|
|
246
316
|
* @since 4.0.0
|
|
247
317
|
*/
|
|
248
318
|
export declare const decide: <Input extends Schema.Constraint, Decisions extends Record<string, Decision.Any>>(definition: Decision.Definition<Input, Decisions>, options: DecideOptions<Input>) => Effect.Effect<DecideResponse<Decisions>, AiError.AiError, DecisionModel | Input["EncodingServices"]>;
|
|
319
|
+
/**
|
|
320
|
+
* Answers each decision with a `Result` containing a validated answer or a
|
|
321
|
+
* `Decision.Unanswered` reason. Input encoding and provider failures still
|
|
322
|
+
* fail the effect. Token usage covers the whole call.
|
|
323
|
+
*
|
|
324
|
+
* **Details**
|
|
325
|
+
*
|
|
326
|
+
* Provider response decoding errors fail the whole call. Per-decision reasons
|
|
327
|
+
* reflect the first failed validation check; `"NoDistribution"` requires an
|
|
328
|
+
* otherwise valid answer.
|
|
329
|
+
*
|
|
330
|
+
* **Example** (Falling back for unanswered decisions)
|
|
331
|
+
*
|
|
332
|
+
* ```ts
|
|
333
|
+
* import { Effect, Result, Schema } from "effect"
|
|
334
|
+
* import { Decision, DecisionModel } from "effect/ai"
|
|
335
|
+
*
|
|
336
|
+
* const TicketTriage = Decision.make({
|
|
337
|
+
* input: Schema.String,
|
|
338
|
+
* decisions: {
|
|
339
|
+
* department: Decision.classify({
|
|
340
|
+
* instructions: "Which team should handle this",
|
|
341
|
+
* criteria: { billing: "payments", technical: "bugs" }
|
|
342
|
+
* }),
|
|
343
|
+
* urgent: Decision.probability({ instructions: "The message is time-sensitive" })
|
|
344
|
+
* }
|
|
345
|
+
* })
|
|
346
|
+
*
|
|
347
|
+
* const program = Effect.gen(function*() {
|
|
348
|
+
* const { outcomes } = yield* DecisionModel.decideSettled(TicketTriage, {
|
|
349
|
+
* input: "My card was charged twice, please fix this today"
|
|
350
|
+
* })
|
|
351
|
+
* const department = Result.isSuccess(outcomes.department) &&
|
|
352
|
+
* outcomes.department.success.probabilities.billing >= 0.8
|
|
353
|
+
* ? "billing"
|
|
354
|
+
* : "needs review"
|
|
355
|
+
* const urgent = Result.isSuccess(outcomes.urgent) ? outcomes.urgent.success.probability : undefined
|
|
356
|
+
* return { department, urgent }
|
|
357
|
+
* })
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @see {@link decide} for failing unless every decision is answered
|
|
361
|
+
*
|
|
362
|
+
* @stability unstable
|
|
363
|
+
* @category decisions
|
|
364
|
+
* @since 4.0.6
|
|
365
|
+
*/
|
|
366
|
+
export declare const decideSettled: <Input extends Schema.Constraint, Decisions extends Record<string, Decision.Any>>(definition: Decision.Definition<Input, Decisions>, options: DecideOptions<Input>) => Effect.Effect<DecideSettledResponse<Decisions>, AiError.AiError, DecisionModel | Input["EncodingServices"]>;
|
|
249
367
|
export {};
|
|
250
368
|
//# sourceMappingURL=DecisionModel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecisionModel.d.ts","sourceRoot":"","sources":["../../src/ai/DecisionModel.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"DecisionModel.d.ts","sourceRoot":"","sources":["../../src/ai/DecisionModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAGtC,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,KAAK,QAAQ,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,KAAK,QAAQ,MAAM,eAAe,CAAA;AAE9C;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,aAAa,CAEvE,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG,0BAA0B,CAAA;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,EAAE,MAAmC,CAAA;;;;;AAExD;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,kBAKjC;CAAG;AAEL;;;;;;GAMG;AACH,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,MAAM,CAAC,UAAU;IAC5D,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC7B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;CACnD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,GAAG,CAAA;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAuB,SAAQ,QAAQ,CAAC,gBAAgB;CAAG;AAE5E;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC;IAC5E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAC7C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAA;CAC1C;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC;IACnF,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IAC/C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAA;CAC1C;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAA;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAA;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;CACnD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAA;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACzC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAA;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACzC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CACzB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GACtB,sBAAsB,GACtB,kBAAkB,GAClB,yBAAyB,GACzB,qBAAqB,CAAA;AAEzB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;IAC1D,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;QACxC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1C,CAAA;IACD,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAA;CACvD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,SAAS,MAAM,CAAC,UAAU,EAAE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,EAC/F,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,EACjD,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,KAC1B,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAA;IACzF,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,SAAS,MAAM,CAAC,UAAU,EAAE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,EACtG,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,EACjD,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,KAC1B,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAA;CACjG;AAiKD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,IAAI,WAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/F,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAClD,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9C,KAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAmD3B,CAAA;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,SAAS,MAAM,CAAC,UAAU,EAAE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,cACxF,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,WACxC,aAAa,CAAC,KAAK,CAAC,KAC5B,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,KAAK,CAAC,kBAAkB,CAAC,CACrC,CAAA;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,MAAM,CAAC,UAAU,EAAE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,cAC/F,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,WACxC,aAAa,CAAC,KAAK,CAAC,KAC5B,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,KAAK,CAAC,kBAAkB,CAAC,CACrC,CAAA"}
|
package/dist/ai/DecisionModel.js
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
* Defines the provider-neutral service for structured decisions.
|
|
3
3
|
* `decide` encodes one input as JSON, sends its named decisions in one provider
|
|
4
4
|
* call, and validates the answers. Failures are reported as `AiError` values.
|
|
5
|
+
* `decideSettled` makes the same call but reports each decision separately, so
|
|
6
|
+
* valid answers survive when others are missing, refused, or invalid.
|
|
5
7
|
* @stability unstable
|
|
6
8
|
* @since 4.0.0
|
|
7
9
|
*/
|
|
8
10
|
import * as Context from "../Context.js";
|
|
9
11
|
import * as Effect from "../Effect.js";
|
|
10
12
|
import * as Predicate from "../Predicate.js";
|
|
13
|
+
import * as Result from "../Result.js";
|
|
11
14
|
import * as Schema from "../Schema.js";
|
|
12
15
|
import * as AiError from "./AiError.js";
|
|
13
16
|
/**
|
|
@@ -40,12 +43,16 @@ export class DecisionUsage extends /*#__PURE__*/Schema.Class("effect/ai/Decision
|
|
|
40
43
|
inputTokens: /*#__PURE__*/Schema.optional(Schema.Finite),
|
|
41
44
|
outputTokens: /*#__PURE__*/Schema.optional(Schema.Finite)
|
|
42
45
|
}) {}
|
|
43
|
-
const
|
|
46
|
+
const unanswered = (reason, description) => Result.fail({
|
|
47
|
+
_tag: "Unanswered",
|
|
48
|
+
reason,
|
|
49
|
+
description
|
|
50
|
+
});
|
|
51
|
+
const invalid = description => unanswered("Invalid", description);
|
|
52
|
+
const aiError = (method, reason) => AiError.make({
|
|
44
53
|
module: "DecisionModel",
|
|
45
|
-
method
|
|
46
|
-
reason
|
|
47
|
-
description
|
|
48
|
-
})
|
|
54
|
+
method,
|
|
55
|
+
reason
|
|
49
56
|
});
|
|
50
57
|
const isFiniteNumber = value => Predicate.isNumber(value) && Number.isFinite(value);
|
|
51
58
|
const isUnitInterval = value => isFiniteNumber(value) && value >= 0 && value <= 1;
|
|
@@ -58,120 +65,140 @@ const sumTolerance = 1e-6;
|
|
|
58
65
|
const validateDistribution = (key, labels, answer, roundingError) => {
|
|
59
66
|
const raw = answer.probabilities;
|
|
60
67
|
if (!Predicate.isObject(raw)) {
|
|
61
|
-
return
|
|
68
|
+
return unanswered("NoDistribution", `Provider returned no probabilities for decision "${key}"`);
|
|
62
69
|
}
|
|
63
70
|
const probabilities = Object.create(null);
|
|
64
71
|
let total = 0;
|
|
65
72
|
for (const label of labels) {
|
|
66
73
|
const value = raw[label];
|
|
67
74
|
if (!isUnitInterval(value)) {
|
|
68
|
-
return
|
|
75
|
+
return invalid(`Provider returned no probability for label "${label}" of decision "${key}"`);
|
|
69
76
|
}
|
|
70
77
|
probabilities[label] = value;
|
|
71
78
|
total += value;
|
|
72
79
|
}
|
|
73
80
|
const drift = Math.abs(total - 1);
|
|
74
81
|
if (total === 0 || drift > labels.length * roundingError + sumTolerance) {
|
|
75
|
-
return
|
|
82
|
+
return invalid(`Provider returned probabilities that do not sum to 1 for decision "${key}"`);
|
|
76
83
|
}
|
|
77
84
|
if (drift > sumTolerance) {
|
|
78
85
|
for (const label of labels) probabilities[label] /= total;
|
|
79
86
|
}
|
|
80
|
-
return probabilities;
|
|
87
|
+
return Result.succeed(probabilities);
|
|
81
88
|
};
|
|
82
89
|
const validateConfidence = (key, answer) => {
|
|
83
90
|
if (answer.confidence === undefined) {
|
|
84
|
-
return undefined;
|
|
91
|
+
return Result.succeed(undefined);
|
|
85
92
|
}
|
|
86
|
-
return isUnitInterval(answer.confidence) ? answer.confidence :
|
|
93
|
+
return isUnitInterval(answer.confidence) ? Result.succeed(answer.confidence) : invalid(`Provider returned confidence outside [0, 1] for decision "${key}"`);
|
|
87
94
|
};
|
|
88
95
|
const validateAnswer = (key, decision, answer, roundingError) => {
|
|
89
96
|
if (!Predicate.isObject(answer)) {
|
|
90
|
-
return
|
|
97
|
+
return unanswered("Missing", `Provider returned no answer for decision "${key}"`);
|
|
98
|
+
}
|
|
99
|
+
if (answer._tag === "Refusal") {
|
|
100
|
+
return unanswered("Refused", `Provider refused to answer decision "${key}"`);
|
|
91
101
|
}
|
|
92
102
|
if (answer._tag !== decision._tag) {
|
|
93
|
-
return
|
|
103
|
+
return invalid(`Provider returned a "${String(answer._tag)}" answer for decision "${key}", expected "${decision._tag}"`);
|
|
94
104
|
}
|
|
95
105
|
switch (decision._tag) {
|
|
96
106
|
case "Classify":
|
|
97
107
|
{
|
|
98
108
|
const labels = Object.keys(decision.criteria);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const confidence = validateConfidence(key, answer);
|
|
103
|
-
if (AiError.isAiError(confidence)) {
|
|
104
|
-
return confidence;
|
|
109
|
+
const label = answer.label;
|
|
110
|
+
if (!Predicate.isString(label) || !labels.includes(label)) {
|
|
111
|
+
return invalid(`Provider returned an unknown label for decision "${key}"`);
|
|
105
112
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
};
|
|
113
|
+
return Result.gen(function* () {
|
|
114
|
+
const confidence = yield* validateConfidence(key, answer);
|
|
115
|
+
const probabilities = yield* validateDistribution(key, labels, answer, roundingError);
|
|
116
|
+
return {
|
|
117
|
+
label,
|
|
118
|
+
probabilities,
|
|
119
|
+
...(confidence === undefined ? undefined : {
|
|
120
|
+
confidence
|
|
121
|
+
})
|
|
122
|
+
};
|
|
123
|
+
});
|
|
117
124
|
}
|
|
118
125
|
case "Rate":
|
|
119
126
|
{
|
|
120
|
-
const levels = decision.criteria;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const confidence = validateConfidence(key, answer);
|
|
125
|
-
if (AiError.isAiError(confidence)) {
|
|
126
|
-
return confidence;
|
|
127
|
-
}
|
|
128
|
-
const probabilities = validateDistribution(key, levels, answer, roundingError);
|
|
129
|
-
if (AiError.isAiError(probabilities)) {
|
|
130
|
-
return probabilities;
|
|
127
|
+
const levels = decision.criteria.map(level => level.label);
|
|
128
|
+
const rating = answer.rating;
|
|
129
|
+
if (!isFiniteNumber(rating) || rating < 0 || rating > levels.length - 1) {
|
|
130
|
+
return invalid(`Provider returned a rating outside [0, ${levels.length - 1}] for decision "${key}"`);
|
|
131
131
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
return Result.gen(function* () {
|
|
133
|
+
const confidence = yield* validateConfidence(key, answer);
|
|
134
|
+
const probabilities = yield* validateDistribution(key, levels, answer, roundingError);
|
|
135
|
+
let label = levels[0];
|
|
136
|
+
for (let i = 1; i < levels.length; i++) {
|
|
137
|
+
if (probabilities[levels[i]] > probabilities[label]) {
|
|
138
|
+
label = levels[i];
|
|
139
|
+
}
|
|
136
140
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
};
|
|
141
|
+
return {
|
|
142
|
+
rating,
|
|
143
|
+
label,
|
|
144
|
+
probabilities,
|
|
145
|
+
...(confidence === undefined ? undefined : {
|
|
146
|
+
confidence
|
|
147
|
+
})
|
|
148
|
+
};
|
|
149
|
+
});
|
|
146
150
|
}
|
|
147
151
|
case "Probability":
|
|
148
152
|
{
|
|
149
153
|
if (!isUnitInterval(answer.probability)) {
|
|
150
|
-
return
|
|
154
|
+
return invalid(`Provider returned a probability outside [0, 1] for decision "${key}"`);
|
|
151
155
|
}
|
|
152
|
-
return {
|
|
156
|
+
return Result.succeed({
|
|
153
157
|
probability: answer.probability
|
|
154
|
-
};
|
|
158
|
+
});
|
|
155
159
|
}
|
|
156
160
|
}
|
|
157
161
|
};
|
|
158
|
-
const
|
|
159
|
-
const
|
|
162
|
+
const settleAnswers = (decisions, answers, roundingError) => {
|
|
163
|
+
const outcomes = Object.create(null);
|
|
160
164
|
for (const key of Object.keys(decisions)) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
outcomes[key] = validateAnswer(key, decisions[key], answers[key], roundingError);
|
|
166
|
+
}
|
|
167
|
+
return outcomes;
|
|
168
|
+
};
|
|
169
|
+
const requireAnswers = outcomes => {
|
|
170
|
+
const answers = Object.create(null);
|
|
171
|
+
const refused = [];
|
|
172
|
+
let firstUnanswered;
|
|
173
|
+
for (const [key, outcome] of Object.entries(outcomes)) {
|
|
174
|
+
if (Result.isSuccess(outcome)) {
|
|
175
|
+
answers[key] = outcome.success;
|
|
176
|
+
} else if (outcome.failure.reason === "Refused") {
|
|
177
|
+
refused.push(`"${key}"`);
|
|
178
|
+
} else {
|
|
179
|
+
firstUnanswered ??= outcome.failure;
|
|
164
180
|
}
|
|
165
|
-
validated[key] = answer;
|
|
166
181
|
}
|
|
167
|
-
|
|
182
|
+
if (refused.length > 0) {
|
|
183
|
+
return Effect.fail(aiError("decide", new AiError.ContentPolicyError({
|
|
184
|
+
description: `Provider refused to answer decisions ${refused.join(", ")}`
|
|
185
|
+
})));
|
|
186
|
+
}
|
|
187
|
+
if (firstUnanswered !== undefined) {
|
|
188
|
+
return Effect.fail(aiError("decide", new AiError.InvalidOutputError({
|
|
189
|
+
description: firstUnanswered.description
|
|
190
|
+
})));
|
|
191
|
+
}
|
|
192
|
+
return Effect.succeed(answers);
|
|
168
193
|
};
|
|
169
194
|
/**
|
|
170
195
|
* Creates a `DecisionModel` that encodes inputs as JSON and validates provider answers.
|
|
171
196
|
* Answers must cover every decision and use its labels. Distributions must
|
|
172
197
|
* sum to 1 within `1e-6`, optional confidence must be in `[0, 1]`, and ratings must be
|
|
173
|
-
* in `[0, criteria.length - 1]`.
|
|
174
|
-
* `AiError.
|
|
198
|
+
* in `[0, criteria.length - 1]`. With `decide`, refused decisions fail with
|
|
199
|
+
* `AiError.ContentPolicyError` and other unanswered decisions fail with
|
|
200
|
+
* `AiError.InvalidOutputError`; `decideSettled` reports them per decision
|
|
201
|
+
* instead. Encoding failures use `AiError.InvalidUserInputError`.
|
|
175
202
|
*
|
|
176
203
|
* **Details**
|
|
177
204
|
*
|
|
@@ -193,40 +220,49 @@ const validateAnswers = (decisions, answers, roundingError) => {
|
|
|
193
220
|
*/
|
|
194
221
|
export const make = params => Effect.sync(() => {
|
|
195
222
|
const roundingError = params.probabilityPrecision === undefined ? 0 : 0.5 * 10 ** -params.probabilityPrecision;
|
|
223
|
+
const settle = (method, definition, options) => Schema.encodeEffect(Schema.toCodecJson(definition.input))(options.input).pipe(Effect.mapError(error => aiError(method, new AiError.InvalidUserInputError({
|
|
224
|
+
description: error.message
|
|
225
|
+
}))), Effect.flatMap(state => {
|
|
226
|
+
const images = options.images?.length ? options.images : undefined;
|
|
227
|
+
if (images !== undefined && params.supportsImages !== true) {
|
|
228
|
+
return Effect.fail(aiError(method, new AiError.InvalidUserInputError({
|
|
229
|
+
description: "This decision model does not accept images"
|
|
230
|
+
})));
|
|
231
|
+
}
|
|
232
|
+
return params.decide({
|
|
233
|
+
state,
|
|
234
|
+
decisions: definition.decisions,
|
|
235
|
+
...(images === undefined ? undefined : {
|
|
236
|
+
images
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
}), Effect.map(response => ({
|
|
240
|
+
outcomes: settleAnswers(definition.decisions, response.answers, roundingError),
|
|
241
|
+
usage: new DecisionUsage({
|
|
242
|
+
inputTokens: response.usage.inputTokens,
|
|
243
|
+
outputTokens: response.usage.outputTokens
|
|
244
|
+
}),
|
|
245
|
+
...(response.id === undefined ? undefined : {
|
|
246
|
+
id: response.id
|
|
247
|
+
}),
|
|
248
|
+
...(response.modelId === undefined ? undefined : {
|
|
249
|
+
modelId: response.modelId
|
|
250
|
+
}),
|
|
251
|
+
metadata: response.metadata ?? {}
|
|
252
|
+
})));
|
|
196
253
|
return DecisionModel.of({
|
|
197
254
|
[TypeId]: TypeId,
|
|
198
|
-
decide: (definition, options) =>
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
description: error.message
|
|
203
|
-
})
|
|
204
|
-
})), Effect.flatMap(state => {
|
|
205
|
-
const images = options.images?.length ? options.images : undefined;
|
|
206
|
-
if (images !== undefined && params.supportsImages !== true) {
|
|
207
|
-
return Effect.fail(AiError.make({
|
|
208
|
-
module: "DecisionModel",
|
|
209
|
-
method: "decide",
|
|
210
|
-
reason: new AiError.InvalidUserInputError({
|
|
211
|
-
description: "This decision model does not accept images"
|
|
212
|
-
})
|
|
213
|
-
}));
|
|
214
|
-
}
|
|
215
|
-
return params.decide({
|
|
216
|
-
state,
|
|
217
|
-
decisions: definition.decisions,
|
|
218
|
-
...(images === undefined ? undefined : {
|
|
219
|
-
images
|
|
220
|
-
})
|
|
221
|
-
});
|
|
222
|
-
}), Effect.flatMap(response => Effect.map(validateAnswers(definition.decisions, response.answers, roundingError), answers => ({
|
|
255
|
+
decide: (definition, options) => settle("decide", definition, options).pipe(Effect.flatMap(({
|
|
256
|
+
outcomes,
|
|
257
|
+
...response
|
|
258
|
+
}) => Effect.map(requireAnswers(outcomes), answers => ({
|
|
223
259
|
answers,
|
|
224
|
-
|
|
225
|
-
inputTokens: response.usage.inputTokens,
|
|
226
|
-
outputTokens: response.usage.outputTokens
|
|
227
|
-
})
|
|
260
|
+
...response
|
|
228
261
|
}))), effect => Effect.withSpan(effect, "DecisionModel.decide", {
|
|
229
262
|
captureStackTrace: false
|
|
263
|
+
})),
|
|
264
|
+
decideSettled: (definition, options) => settle("decideSettled", definition, options).pipe(effect => Effect.withSpan(effect, "DecisionModel.decideSettled", {
|
|
265
|
+
captureStackTrace: false
|
|
230
266
|
}))
|
|
231
267
|
});
|
|
232
268
|
});
|
|
@@ -236,6 +272,9 @@ export const make = params => Effect.sync(() => {
|
|
|
236
272
|
* Explicit `undefined` fields become `null`; absent fields stay absent.
|
|
237
273
|
* Custom declarations need a JSON codec annotation or encoding fails.
|
|
238
274
|
* Returned answers and probability dictionaries have null prototypes.
|
|
275
|
+
* Fails with `AiError.ContentPolicyError` if the provider refuses any decision,
|
|
276
|
+
* and otherwise with `AiError.InvalidOutputError` for the first unanswered
|
|
277
|
+
* decision in definition order.
|
|
239
278
|
*
|
|
240
279
|
* **Example** (Triaging a ticket)
|
|
241
280
|
*
|
|
@@ -262,10 +301,59 @@ export const make = params => Effect.sync(() => {
|
|
|
262
301
|
* ```
|
|
263
302
|
*
|
|
264
303
|
* @see {@link DecisionModel} for the service this function requires
|
|
304
|
+
* @see {@link decideSettled} for keeping valid answers when others fail
|
|
265
305
|
*
|
|
266
306
|
* @stability unstable
|
|
267
307
|
* @category decisions
|
|
268
308
|
* @since 4.0.0
|
|
269
309
|
*/
|
|
270
310
|
export const decide = (definition, options) => DecisionModel.use(model => model.decide(definition, options));
|
|
311
|
+
/**
|
|
312
|
+
* Answers each decision with a `Result` containing a validated answer or a
|
|
313
|
+
* `Decision.Unanswered` reason. Input encoding and provider failures still
|
|
314
|
+
* fail the effect. Token usage covers the whole call.
|
|
315
|
+
*
|
|
316
|
+
* **Details**
|
|
317
|
+
*
|
|
318
|
+
* Provider response decoding errors fail the whole call. Per-decision reasons
|
|
319
|
+
* reflect the first failed validation check; `"NoDistribution"` requires an
|
|
320
|
+
* otherwise valid answer.
|
|
321
|
+
*
|
|
322
|
+
* **Example** (Falling back for unanswered decisions)
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* import { Effect, Result, Schema } from "effect"
|
|
326
|
+
* import { Decision, DecisionModel } from "effect/ai"
|
|
327
|
+
*
|
|
328
|
+
* const TicketTriage = Decision.make({
|
|
329
|
+
* input: Schema.String,
|
|
330
|
+
* decisions: {
|
|
331
|
+
* department: Decision.classify({
|
|
332
|
+
* instructions: "Which team should handle this",
|
|
333
|
+
* criteria: { billing: "payments", technical: "bugs" }
|
|
334
|
+
* }),
|
|
335
|
+
* urgent: Decision.probability({ instructions: "The message is time-sensitive" })
|
|
336
|
+
* }
|
|
337
|
+
* })
|
|
338
|
+
*
|
|
339
|
+
* const program = Effect.gen(function*() {
|
|
340
|
+
* const { outcomes } = yield* DecisionModel.decideSettled(TicketTriage, {
|
|
341
|
+
* input: "My card was charged twice, please fix this today"
|
|
342
|
+
* })
|
|
343
|
+
* const department = Result.isSuccess(outcomes.department) &&
|
|
344
|
+
* outcomes.department.success.probabilities.billing >= 0.8
|
|
345
|
+
* ? "billing"
|
|
346
|
+
* : "needs review"
|
|
347
|
+
* const urgent = Result.isSuccess(outcomes.urgent) ? outcomes.urgent.success.probability : undefined
|
|
348
|
+
* return { department, urgent }
|
|
349
|
+
* })
|
|
350
|
+
* ```
|
|
351
|
+
*
|
|
352
|
+
* @see {@link decide} for failing unless every decision is answered
|
|
353
|
+
*
|
|
354
|
+
* @stability unstable
|
|
355
|
+
* @category decisions
|
|
356
|
+
* @since 4.0.6
|
|
357
|
+
*/
|
|
358
|
+
export const decideSettled = (definition, options) => DecisionModel.use(model => model.decideSettled(definition, options));
|
|
271
359
|
//# sourceMappingURL=DecisionModel.js.map
|