effect 4.1.1 → 4.1.3
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 +2 -2
- package/ai-docs/tsconfig.json +2 -1
- package/dist/ByteSize.d.ts.map +1 -1
- package/dist/ByteSize.js +27 -14
- package/dist/ByteSize.js.map +1 -1
- package/dist/DateTime.d.ts +33 -2
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +16 -0
- package/dist/DateTime.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +27 -24
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +27 -6
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Match.d.ts +6 -6
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js.map +1 -1
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +0 -7
- package/dist/MutableRef.js.map +1 -1
- package/dist/Queue.d.ts +2 -1
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +16 -9
- package/dist/Queue.js.map +1 -1
- package/dist/Rational.d.ts +1214 -0
- package/dist/Rational.d.ts.map +1 -0
- package/dist/Rational.js +880 -0
- package/dist/Rational.js.map +1 -0
- package/dist/RcMap.d.ts +3 -0
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +13 -14
- package/dist/RcMap.js.map +1 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +0 -8
- package/dist/Ref.js.map +1 -1
- package/dist/Runtime.d.ts +75 -3
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +81 -4
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +8 -3
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +131 -29
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +128 -22
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +24 -12
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.js +2 -2
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +9 -0
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +9 -0
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/ScopedCache.d.ts +7 -0
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +18 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +6 -5
- package/dist/Stream.js.map +1 -1
- package/dist/ai/AgUi.d.ts +109 -0
- package/dist/ai/AgUi.d.ts.map +1 -0
- package/dist/ai/AgUi.js +543 -0
- package/dist/ai/AgUi.js.map +1 -0
- package/dist/ai/AgUiSchema.d.ts +6965 -0
- package/dist/ai/AgUiSchema.d.ts.map +1 -0
- package/dist/ai/AgUiSchema.js +974 -0
- package/dist/ai/AgUiSchema.js.map +1 -0
- package/dist/ai/AgUiServer.d.ts +6400 -0
- package/dist/ai/AgUiServer.d.ts.map +1 -0
- package/dist/ai/AgUiServer.js +309 -0
- package/dist/ai/AgUiServer.js.map +1 -0
- package/dist/ai/Chat.d.ts +30 -4
- package/dist/ai/Chat.d.ts.map +1 -1
- package/dist/ai/Chat.js +34 -4
- package/dist/ai/Chat.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts +1 -1
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +18 -8
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpClient.d.ts +5 -0
- package/dist/ai/McpClient.d.ts.map +1 -1
- package/dist/ai/McpClient.js +11 -1
- package/dist/ai/McpClient.js.map +1 -1
- package/dist/ai/McpServer.d.ts +18 -1
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +251 -43
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +6 -2
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +5 -2
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +5 -1
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +265 -69
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +19 -2
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/Toolkit.d.ts +32 -2
- package/dist/ai/Toolkit.d.ts.map +1 -1
- package/dist/ai/Toolkit.js +61 -8
- package/dist/ai/Toolkit.js.map +1 -1
- package/dist/ai/index.d.ts +15 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +15 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/internal/mcpCore.d.ts +0 -2
- package/dist/ai/internal/mcpCore.d.ts.map +1 -1
- package/dist/ai/internal/mcpCore.js +2 -8
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +6 -11
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +6 -11
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +6 -8
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +6 -8
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +64 -54
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +11 -1
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpProtocolRegistry.js +4 -0
- package/dist/ai/internal/mcpProtocolRegistry.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +6 -2
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2024_11_05.js +0 -2
- package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_03_26.d.ts.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_03_26.js +0 -2
- package/dist/ai/internal/mcpSchema/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_06_18.d.ts.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_06_18.js +0 -2
- package/dist/ai/internal/mcpSchema/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_11_25.d.ts.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_11_25.js +0 -2
- package/dist/ai/internal/mcpSchema/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2026_07_28.d.ts.map +1 -1
- package/dist/ai/internal/mcpSchema/v2026_07_28.js +0 -2
- package/dist/ai/internal/mcpSchema/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpSkills.js +3 -93
- package/dist/ai/internal/mcpSkills.js.map +1 -1
- package/dist/ai/internal/mcpStatefulRuntime.js +0 -2
- package/dist/ai/internal/mcpStatefulRuntime.js.map +1 -1
- package/dist/ai/internal/structured-output.js +12 -3
- package/dist/ai/internal/structured-output.js.map +1 -1
- package/dist/cli/Argument.d.ts +81 -0
- package/dist/cli/Argument.d.ts.map +1 -1
- package/dist/cli/Argument.js +26 -0
- package/dist/cli/Argument.js.map +1 -1
- package/dist/cli/CliError.d.ts +7 -4
- package/dist/cli/CliError.d.ts.map +1 -1
- package/dist/cli/CliError.js +7 -4
- package/dist/cli/CliError.js.map +1 -1
- package/dist/cli/Command.d.ts +241 -22
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +85 -9
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/CommandSpec.d.ts +287 -0
- package/dist/cli/CommandSpec.d.ts.map +1 -0
- package/dist/cli/CommandSpec.js +277 -0
- package/dist/cli/CommandSpec.js.map +1 -0
- package/dist/cli/Completions.d.ts +5 -0
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/Flag.d.ts +102 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +47 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/Param.d.ts +154 -1
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +87 -29
- package/dist/cli/Param.js.map +1 -1
- 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 -2
- package/dist/cli/internal/command.d.ts.map +1 -1
- package/dist/cli/internal/command.js +1 -1
- package/dist/cli/internal/command.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +6 -7
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cli/internal/completions/descriptor.js +21 -7
- package/dist/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/cli/internal/completions/fish.js +3 -3
- package/dist/cli/internal/completions/fish.js.map +1 -1
- package/dist/cli/internal/completions/powershell.js +2 -2
- package/dist/cli/internal/completions/powershell.js.map +1 -1
- package/dist/cli/internal/completions/zsh.js +2 -2
- package/dist/cli/internal/completions/zsh.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +31 -20
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Entity.d.ts +43 -0
- package/dist/cluster/Entity.d.ts.map +1 -1
- package/dist/cluster/Entity.js +20 -0
- package/dist/cluster/Entity.js.map +1 -1
- package/dist/cluster/MessageRetention.d.ts +71 -0
- package/dist/cluster/MessageRetention.d.ts.map +1 -0
- package/dist/cluster/MessageRetention.js +100 -0
- package/dist/cluster/MessageRetention.js.map +1 -0
- package/dist/cluster/MessageStorage.d.ts +87 -6
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +35 -5
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +13 -2
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts +13 -0
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +24 -2
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +187 -29
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/index.d.ts +5 -0
- package/dist/cluster/index.d.ts.map +1 -1
- package/dist/cluster/index.js +5 -0
- package/dist/cluster/index.js.map +1 -1
- package/dist/cluster/internal/clusterAbandon.d.ts.map +1 -1
- package/dist/cluster/internal/clusterAbandon.js +6 -4
- package/dist/cluster/internal/clusterAbandon.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +48 -4
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/cluster/internal/transactionNotifications.d.ts +5 -0
- package/dist/cluster/internal/transactionNotifications.d.ts.map +1 -0
- package/dist/cluster/internal/transactionNotifications.js +5 -0
- package/dist/cluster/internal/transactionNotifications.js.map +1 -0
- package/dist/encoding/Base64.d.ts +0 -6
- package/dist/encoding/Base64.d.ts.map +1 -1
- package/dist/encoding/Base64.js +25 -5
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts +0 -6
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +91 -8
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Csv.d.ts.map +1 -1
- package/dist/encoding/Csv.js +11 -5
- package/dist/encoding/Csv.js.map +1 -1
- package/dist/encoding/Hex.d.ts.map +1 -1
- package/dist/encoding/Hex.js +51 -34
- package/dist/encoding/Hex.js.map +1 -1
- package/dist/encoding/Json5.d.ts +44 -0
- package/dist/encoding/Json5.d.ts.map +1 -0
- package/dist/encoding/Json5.js +56 -0
- package/dist/encoding/Json5.js.map +1 -0
- package/dist/encoding/Jsonc.d.ts +47 -0
- package/dist/encoding/Jsonc.d.ts.map +1 -0
- package/dist/encoding/Jsonc.js +120 -0
- package/dist/encoding/Jsonc.js.map +1 -0
- package/dist/encoding/SchemaBinary.d.ts +108 -2
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +297 -11
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Xml.d.ts +25 -0
- package/dist/encoding/Xml.d.ts.map +1 -1
- package/dist/encoding/Xml.js +44 -19
- package/dist/encoding/Xml.js.map +1 -1
- package/dist/encoding/index.d.ts +10 -0
- package/dist/encoding/index.d.ts.map +1 -1
- package/dist/encoding/index.js +10 -0
- package/dist/encoding/index.js.map +1 -1
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +28 -12
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/graphql/GraphQL.d.ts.map +1 -1
- package/dist/graphql/GraphQL.js +4 -1
- package/dist/graphql/GraphQL.js.map +1 -1
- package/dist/http/Headers.d.ts +5 -1
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +7 -2
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts +72 -21
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +105 -60
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts +22 -8
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +68 -14
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpEffect.d.ts +63 -4
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +89 -9
- package/dist/http/HttpEffect.js.map +1 -1
- package/dist/http/HttpMiddleware.js +1 -1
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpServer.d.ts +80 -0
- package/dist/http/HttpServer.d.ts.map +1 -1
- package/dist/http/HttpServer.js +16 -0
- package/dist/http/HttpServer.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +1 -14
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpStaticServer.js +10 -16
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +9 -1
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +19 -0
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +8 -1
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/base64.d.ts +2 -0
- package/dist/internal/base64.d.ts.map +1 -0
- package/dist/internal/base64.js +30 -0
- package/dist/internal/base64.js.map +1 -0
- package/dist/internal/core.js +3 -4
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +35 -13
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +41 -17
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js +7 -0
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/jsonParser.d.ts +5 -0
- package/dist/internal/jsonParser.d.ts.map +1 -0
- package/dist/internal/jsonParser.js +280 -0
- package/dist/internal/jsonParser.js.map +1 -0
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/persistence.js +8 -1
- package/dist/internal/persistence.js.map +1 -1
- package/dist/internal/schema/codegen.js +7 -7
- package/dist/internal/schema/codegen.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +20 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/interpreter.js +10 -10
- package/dist/internal/schema/interpreter.js.map +1 -1
- package/dist/internal/schema/parser.js +9 -4
- package/dist/internal/schema/parser.js.map +1 -1
- package/dist/internal/schema/toEquivalence.js +6 -5
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toFormatter.js +3 -2
- package/dist/internal/schema/toFormatter.js.map +1 -1
- package/dist/internal/sql.js +16 -0
- package/dist/internal/sql.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/observability/OtlpExporter.d.ts +4 -0
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +40 -12
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpMetrics.js +1 -1
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpTracer.js +2 -2
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts +72 -3
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +142 -29
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/persistence/RateLimiter.d.ts +19 -2
- package/dist/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/persistence/RateLimiter.js +24 -8
- package/dist/persistence/RateLimiter.js.map +1 -1
- package/dist/process/CommandLine.d.ts +9 -9
- package/dist/process/CommandLine.js +6 -6
- package/dist/process/index.d.ts +1 -1
- package/dist/process/index.js +1 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +24 -3
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomRpc.d.ts +24 -6
- package/dist/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/reactivity/AtomRpc.js.map +1 -1
- package/dist/rpc/OpenRpc.d.ts +384 -0
- package/dist/rpc/OpenRpc.d.ts.map +1 -0
- package/dist/rpc/OpenRpc.js +490 -0
- package/dist/rpc/OpenRpc.js.map +1 -0
- package/dist/rpc/Rpc.d.ts +22 -3
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +20 -21
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts +23 -2
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +77 -26
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/rpc/index.d.ts +5 -0
- package/dist/rpc/index.d.ts.map +1 -1
- package/dist/rpc/index.js +5 -0
- package/dist/rpc/index.js.map +1 -1
- package/dist/schema/SchemaCompiler/runtime.js +3 -2
- package/dist/schema/SchemaCompiler/runtime.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +67 -6
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +98 -27
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +6 -1
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +17 -22
- package/dist/sql/Statement.js.map +1 -1
- package/dist/testing/TestClock.d.ts +2 -12
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +177 -169
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/workflow/DurableClock.d.ts +27 -0
- package/dist/workflow/DurableClock.d.ts.map +1 -1
- package/dist/workflow/DurableClock.js +18 -2
- package/dist/workflow/DurableClock.js.map +1 -1
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +5 -4
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +14 -3
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +5 -5
- package/src/ByteSize.ts +29 -14
- package/src/DateTime.ts +35 -2
- package/src/Iterable.ts +20 -14
- package/src/JsonSchema.ts +45 -7
- package/src/Match.ts +10 -8
- package/src/MutableRef.ts +1 -8
- package/src/Queue.ts +16 -11
- package/src/Rational.ts +1549 -0
- package/src/RcMap.ts +16 -14
- package/src/Ref.ts +0 -8
- package/src/Runtime.ts +84 -4
- package/src/Schedule.ts +8 -6
- package/src/Schema.ts +188 -29
- package/src/SchemaAST.ts +29 -13
- package/src/SchemaParser.ts +2 -2
- package/src/SchemaRepresentation.ts +13 -0
- package/src/ScopedCache.ts +18 -1
- package/src/Stream.ts +6 -5
- package/src/ai/AgUi.ts +485 -0
- package/src/ai/AgUiSchema.ts +1666 -0
- package/src/ai/AgUiServer.ts +451 -0
- package/src/ai/Chat.ts +78 -16
- package/src/ai/LanguageModel.ts +27 -9
- package/src/ai/McpClient.ts +11 -1
- package/src/ai/McpServer.ts +287 -67
- package/src/ai/Prompt.ts +6 -2
- package/src/ai/Response.ts +19 -3
- package/src/ai/Tool.ts +426 -110
- package/src/ai/Toolkit.ts +71 -10
- package/src/ai/index.ts +18 -0
- package/src/ai/internal/mcpCore.ts +11 -15
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +9 -14
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +9 -14
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +9 -11
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +9 -11
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +80 -60
- package/src/ai/internal/mcpProtocol.ts +22 -3
- package/src/ai/internal/mcpProtocolRegistry.ts +5 -0
- package/src/ai/internal/mcpRuntime.ts +10 -4
- package/src/ai/internal/mcpSchema/v2024_11_05.ts +0 -2
- package/src/ai/internal/mcpSchema/v2025_03_26.ts +0 -2
- package/src/ai/internal/mcpSchema/v2025_06_18.ts +0 -2
- package/src/ai/internal/mcpSchema/v2025_11_25.ts +0 -2
- package/src/ai/internal/mcpSchema/v2026_07_28.ts +0 -2
- package/src/ai/internal/mcpSkills.ts +3 -86
- package/src/ai/internal/mcpStatefulRuntime.ts +0 -2
- package/src/ai/internal/structured-output.ts +11 -5
- package/src/cli/Argument.ts +86 -0
- package/src/cli/CliError.ts +7 -4
- package/src/cli/Command.ts +261 -35
- package/src/cli/CommandSpec.ts +508 -0
- package/src/cli/Completions.ts +5 -0
- package/src/cli/Flag.ts +106 -0
- package/src/cli/Param.ts +225 -23
- package/src/cli/index.ts +6 -0
- package/src/cli/internal/command.ts +3 -4
- package/src/cli/internal/completions/bash.ts +9 -7
- package/src/cli/internal/completions/descriptor.ts +37 -5
- package/src/cli/internal/completions/fish.ts +9 -3
- package/src/cli/internal/completions/powershell.ts +2 -1
- package/src/cli/internal/completions/zsh.ts +2 -2
- package/src/cluster/ClusterWorkflowEngine.ts +41 -41
- package/src/cluster/Entity.ts +76 -0
- package/src/cluster/MessageRetention.ts +111 -0
- package/src/cluster/MessageStorage.ts +76 -8
- package/src/cluster/Runners.ts +16 -2
- package/src/cluster/Sharding.ts +13 -0
- package/src/cluster/ShardingConfig.ts +12 -1
- package/src/cluster/SqlMessageStorage.ts +271 -41
- package/src/cluster/index.ts +6 -0
- package/src/cluster/internal/clusterAbandon.ts +7 -7
- package/src/cluster/internal/entityManager.ts +65 -5
- package/src/cluster/internal/transactionNotifications.ts +7 -0
- package/src/encoding/Base64.ts +26 -5
- package/src/encoding/Base64Url.ts +93 -10
- package/src/encoding/Csv.ts +11 -5
- package/src/encoding/Hex.ts +56 -42
- package/src/encoding/Json5.ts +59 -0
- package/src/encoding/Jsonc.ts +126 -0
- package/src/encoding/SchemaBinary.ts +304 -12
- package/src/encoding/Xml.ts +65 -16
- package/src/encoding/index.ts +12 -0
- package/src/eventlog/EventLogServer.ts +36 -12
- package/src/graphql/GraphQL.ts +7 -4
- package/src/http/Headers.ts +7 -2
- package/src/http/HttpClient.ts +147 -85
- package/src/http/HttpClientError.ts +82 -15
- package/src/http/HttpEffect.ts +101 -10
- package/src/http/HttpMiddleware.ts +2 -2
- package/src/http/HttpServer.ts +80 -0
- package/src/http/HttpServerRequest.ts +1 -19
- package/src/http/HttpStaticServer.ts +10 -16
- package/src/http-api/HttpApiBuilder.ts +11 -1
- package/src/http-api/HttpApiSchema.ts +22 -1
- package/src/index.ts +6 -0
- package/src/internal/base64.ts +42 -0
- package/src/internal/core.ts +3 -4
- package/src/internal/dateTime.ts +53 -16
- package/src/internal/effect.ts +45 -18
- package/src/internal/equal.ts +8 -0
- package/src/internal/jsonParser.ts +307 -0
- package/src/internal/matcher.ts +7 -3
- package/src/internal/persistence.ts +9 -1
- package/src/internal/schema/codegen.ts +8 -7
- package/src/internal/schema/fromJsonSchemaDocument.ts +21 -1
- package/src/internal/schema/interpreter.ts +10 -10
- package/src/internal/schema/parser.ts +8 -4
- package/src/internal/schema/toEquivalence.ts +7 -5
- package/src/internal/schema/toFormatter.ts +3 -2
- package/src/internal/sql.ts +25 -0
- package/src/internal/version.ts +1 -1
- package/src/observability/OtlpExporter.ts +42 -18
- package/src/observability/OtlpMetrics.ts +1 -1
- package/src/observability/OtlpTracer.ts +2 -2
- package/src/persistence/PersistedQueue.ts +199 -41
- package/src/persistence/RateLimiter.ts +30 -9
- package/src/process/CommandLine.ts +10 -10
- package/src/process/index.ts +1 -1
- package/src/reactivity/Atom.ts +25 -3
- package/src/reactivity/AtomRpc.ts +61 -45
- package/src/rpc/OpenRpc.ts +747 -0
- package/src/rpc/Rpc.ts +38 -6
- package/src/rpc/RpcClient.ts +45 -82
- package/src/rpc/RpcServer.ts +89 -29
- package/src/rpc/index.ts +6 -0
- package/src/schema/SchemaCompiler/runtime.ts +8 -3
- package/src/sql/SqlClient.ts +156 -36
- package/src/sql/Statement.ts +27 -36
- package/src/testing/TestClock.ts +204 -189
- package/src/workflow/DurableClock.ts +20 -3
- package/src/workflow/Workflow.ts +5 -3
- package/src/workflow/WorkflowEngine.ts +20 -5
|
@@ -0,0 +1,1666 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines schemas for the Agent User Interaction (AG-UI) protocol.
|
|
3
|
+
*
|
|
4
|
+
* AG-UI connects an agent backend to a user-facing application: the
|
|
5
|
+
* application posts a `RunAgentInput` and the agent answers with a stream of
|
|
6
|
+
* events describing the run. These schemas follow the AG-UI 1.0 specification
|
|
7
|
+
* and describe the request body, the conversation messages it carries, and
|
|
8
|
+
* every event type. Converting to and from `effect/ai` values lives in `AgUi`,
|
|
9
|
+
* and the HTTP binding lives in `AgUiServer`.
|
|
10
|
+
*
|
|
11
|
+
* @see https://docs.ag-ui.com
|
|
12
|
+
*
|
|
13
|
+
* @stability experimental
|
|
14
|
+
* @since 4.1.0
|
|
15
|
+
*/
|
|
16
|
+
import * as Effect from "../Effect.ts"
|
|
17
|
+
import { identity } from "../Function.ts"
|
|
18
|
+
import * as Predicate from "../Predicate.ts"
|
|
19
|
+
import * as Schema from "../Schema.ts"
|
|
20
|
+
import * as SchemaTransformation from "../SchemaTransformation.ts"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* AG-UI protocol version implemented by these schemas.
|
|
24
|
+
*
|
|
25
|
+
* @stability experimental
|
|
26
|
+
* @category constants
|
|
27
|
+
* @since 4.1.0
|
|
28
|
+
*/
|
|
29
|
+
export const protocolVersion = "1.0"
|
|
30
|
+
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// Shared
|
|
33
|
+
// =============================================================================
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Schema for open-ended metadata attached to events, messages, tools, and
|
|
37
|
+
* other protocol values.
|
|
38
|
+
*
|
|
39
|
+
* **Details**
|
|
40
|
+
*
|
|
41
|
+
* The `ag-ui` key is reserved for the protocol's own use.
|
|
42
|
+
*
|
|
43
|
+
* @stability experimental
|
|
44
|
+
* @category schemas
|
|
45
|
+
* @since 4.1.0
|
|
46
|
+
*/
|
|
47
|
+
export const Metadata = Schema.Record(Schema.String, Schema.Unknown)
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Open-ended metadata attached to events, messages, tools, and other protocol
|
|
51
|
+
* values.
|
|
52
|
+
*
|
|
53
|
+
* @stability experimental
|
|
54
|
+
* @category models
|
|
55
|
+
* @since 4.1.0
|
|
56
|
+
*/
|
|
57
|
+
export type Metadata = typeof Metadata.Type
|
|
58
|
+
|
|
59
|
+
const baseEventFields = {
|
|
60
|
+
timestamp: Schema.optionalKey(Schema.Int),
|
|
61
|
+
rawEvent: Schema.optionalKey(Schema.Unknown),
|
|
62
|
+
metadata: Schema.optionalKey(Metadata)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const subagentEventFields = {
|
|
66
|
+
...baseEventFields,
|
|
67
|
+
subagentRunId: Schema.optionalKey(Schema.String)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const TokenCount = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))
|
|
71
|
+
|
|
72
|
+
// AG-UI consumers remove list elements they do not recognise, such as union
|
|
73
|
+
// members or closed-set values added by a newer protocol version, instead of
|
|
74
|
+
// rejecting the value holding them. Recognised but malformed elements still
|
|
75
|
+
// fail to decode.
|
|
76
|
+
const withoutUnknownMembers = <S extends Schema.Constraint>(item: S, isUnknown: (value: unknown) => boolean) => {
|
|
77
|
+
// Accepts only unrecognised material, so it never hides a malformed item.
|
|
78
|
+
// JSON Schema and OpenAPI document the canonical model: a union splices in
|
|
79
|
+
// a member that is only an `anyOf`, so an empty one leaves just the item's
|
|
80
|
+
// variants and generated clients keep their discriminated types.
|
|
81
|
+
const Unrecognised = Schema.Any.check(Schema.makeFilter(isUnknown, {
|
|
82
|
+
toJsonSchema: () => ({ anyOf: [] })
|
|
83
|
+
}))
|
|
84
|
+
return Schema.Array(Schema.Union([item, Unrecognised])).pipe(
|
|
85
|
+
Schema.decodeTo(
|
|
86
|
+
Schema.Array(Schema.toType(item)),
|
|
87
|
+
SchemaTransformation.transform({
|
|
88
|
+
decode: (values) => values.filter((value) => !isUnknown(value)) as ReadonlyArray<S["Type"]>,
|
|
89
|
+
encode: identity
|
|
90
|
+
})
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Only a string outside the closed set is unrecognised; a missing or
|
|
96
|
+
// mistyped value is malformed
|
|
97
|
+
const hasUnknownTag = (value: unknown, key: string, tags: ReadonlySet<string>): boolean =>
|
|
98
|
+
Predicate.isObject(value) && typeof value[key] === "string" && !tags.has(value[key])
|
|
99
|
+
|
|
100
|
+
// =============================================================================
|
|
101
|
+
// Content
|
|
102
|
+
// =============================================================================
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Schema for media bytes carried inline as base64 data.
|
|
106
|
+
*
|
|
107
|
+
* @stability experimental
|
|
108
|
+
* @category schemas
|
|
109
|
+
* @since 4.1.0
|
|
110
|
+
*/
|
|
111
|
+
export const DataSource = Schema.Struct({
|
|
112
|
+
type: Schema.Literal("data"),
|
|
113
|
+
value: Schema.String,
|
|
114
|
+
mimeType: Schema.String
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Media bytes carried inline as base64 data.
|
|
119
|
+
*
|
|
120
|
+
* @stability experimental
|
|
121
|
+
* @category models
|
|
122
|
+
* @since 4.1.0
|
|
123
|
+
*/
|
|
124
|
+
export type DataSource = typeof DataSource.Type
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Schema for media bytes referenced by URL.
|
|
128
|
+
*
|
|
129
|
+
* @stability experimental
|
|
130
|
+
* @category schemas
|
|
131
|
+
* @since 4.1.0
|
|
132
|
+
*/
|
|
133
|
+
export const UrlSource = Schema.Struct({
|
|
134
|
+
type: Schema.Literal("url"),
|
|
135
|
+
value: Schema.String,
|
|
136
|
+
mimeType: Schema.optionalKey(Schema.String)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Media bytes referenced by URL.
|
|
141
|
+
*
|
|
142
|
+
* @stability experimental
|
|
143
|
+
* @category models
|
|
144
|
+
* @since 4.1.0
|
|
145
|
+
*/
|
|
146
|
+
export type UrlSource = typeof UrlSource.Type
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Schema for media bytes already stored at a provider and named by a handle
|
|
150
|
+
* that provider issued.
|
|
151
|
+
*
|
|
152
|
+
* @stability experimental
|
|
153
|
+
* @category schemas
|
|
154
|
+
* @since 4.1.0
|
|
155
|
+
*/
|
|
156
|
+
export const FileSource = Schema.Struct({
|
|
157
|
+
type: Schema.Literal("file"),
|
|
158
|
+
value: Schema.String,
|
|
159
|
+
provider: Schema.optionalKey(Schema.String),
|
|
160
|
+
mimeType: Schema.optionalKey(Schema.String)
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Media bytes already stored at a provider and named by a handle that provider
|
|
165
|
+
* issued.
|
|
166
|
+
*
|
|
167
|
+
* @stability experimental
|
|
168
|
+
* @category models
|
|
169
|
+
* @since 4.1.0
|
|
170
|
+
*/
|
|
171
|
+
export type FileSource = typeof FileSource.Type
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Schema for the source of a media content part.
|
|
175
|
+
*
|
|
176
|
+
* @stability experimental
|
|
177
|
+
* @category schemas
|
|
178
|
+
* @since 4.1.0
|
|
179
|
+
*/
|
|
180
|
+
export const PartSource = Schema.Union([DataSource, UrlSource, FileSource])
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Source of a media content part.
|
|
184
|
+
*
|
|
185
|
+
* @stability experimental
|
|
186
|
+
* @category models
|
|
187
|
+
* @since 4.1.0
|
|
188
|
+
*/
|
|
189
|
+
export type PartSource = typeof PartSource.Type
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Schema for a text content part.
|
|
193
|
+
*
|
|
194
|
+
* @stability experimental
|
|
195
|
+
* @category schemas
|
|
196
|
+
* @since 4.1.0
|
|
197
|
+
*/
|
|
198
|
+
export const TextPart = Schema.Struct({
|
|
199
|
+
type: Schema.Literal("text"),
|
|
200
|
+
id: Schema.optionalKey(Schema.String),
|
|
201
|
+
text: Schema.String,
|
|
202
|
+
metadata: Schema.optionalKey(Schema.Unknown)
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* A text content part.
|
|
207
|
+
*
|
|
208
|
+
* @stability experimental
|
|
209
|
+
* @category models
|
|
210
|
+
* @since 4.1.0
|
|
211
|
+
*/
|
|
212
|
+
export type TextPart = typeof TextPart.Type
|
|
213
|
+
|
|
214
|
+
const mediaPart = <Type extends string>(type: Type) =>
|
|
215
|
+
Schema.Struct({
|
|
216
|
+
type: Schema.Literal(type),
|
|
217
|
+
id: Schema.optionalKey(Schema.String),
|
|
218
|
+
source: PartSource,
|
|
219
|
+
metadata: Schema.optionalKey(Schema.Unknown)
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Schema for an image content part.
|
|
224
|
+
*
|
|
225
|
+
* @stability experimental
|
|
226
|
+
* @category schemas
|
|
227
|
+
* @since 4.1.0
|
|
228
|
+
*/
|
|
229
|
+
export const ImagePart = mediaPart("image")
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* An image content part.
|
|
233
|
+
*
|
|
234
|
+
* @stability experimental
|
|
235
|
+
* @category models
|
|
236
|
+
* @since 4.1.0
|
|
237
|
+
*/
|
|
238
|
+
export type ImagePart = typeof ImagePart.Type
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Schema for an audio content part.
|
|
242
|
+
*
|
|
243
|
+
* @stability experimental
|
|
244
|
+
* @category schemas
|
|
245
|
+
* @since 4.1.0
|
|
246
|
+
*/
|
|
247
|
+
export const AudioPart = mediaPart("audio")
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* An audio content part.
|
|
251
|
+
*
|
|
252
|
+
* @stability experimental
|
|
253
|
+
* @category models
|
|
254
|
+
* @since 4.1.0
|
|
255
|
+
*/
|
|
256
|
+
export type AudioPart = typeof AudioPart.Type
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Schema for a video content part.
|
|
260
|
+
*
|
|
261
|
+
* @stability experimental
|
|
262
|
+
* @category schemas
|
|
263
|
+
* @since 4.1.0
|
|
264
|
+
*/
|
|
265
|
+
export const VideoPart = mediaPart("video")
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* A video content part.
|
|
269
|
+
*
|
|
270
|
+
* @stability experimental
|
|
271
|
+
* @category models
|
|
272
|
+
* @since 4.1.0
|
|
273
|
+
*/
|
|
274
|
+
export type VideoPart = typeof VideoPart.Type
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Schema for a document content part.
|
|
278
|
+
*
|
|
279
|
+
* @stability experimental
|
|
280
|
+
* @category schemas
|
|
281
|
+
* @since 4.1.0
|
|
282
|
+
*/
|
|
283
|
+
export const DocumentPart = mediaPart("document")
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* A document content part.
|
|
287
|
+
*
|
|
288
|
+
* @stability experimental
|
|
289
|
+
* @category models
|
|
290
|
+
* @since 4.1.0
|
|
291
|
+
*/
|
|
292
|
+
export type DocumentPart = typeof DocumentPart.Type
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Schema for any content part of a user or tool message.
|
|
296
|
+
*
|
|
297
|
+
* @stability experimental
|
|
298
|
+
* @category schemas
|
|
299
|
+
* @since 4.1.0
|
|
300
|
+
*/
|
|
301
|
+
export const ContentPart = Schema.Union([TextPart, ImagePart, AudioPart, VideoPart, DocumentPart])
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Any content part of a user or tool message.
|
|
305
|
+
*
|
|
306
|
+
* @stability experimental
|
|
307
|
+
* @category models
|
|
308
|
+
* @since 4.1.0
|
|
309
|
+
*/
|
|
310
|
+
export type ContentPart = typeof ContentPart.Type
|
|
311
|
+
|
|
312
|
+
const contentPartTypes: ReadonlySet<string> = new Set(["text", "image", "audio", "video", "document"])
|
|
313
|
+
const partSourceTypes: ReadonlySet<string> = new Set(["data", "url", "file"])
|
|
314
|
+
|
|
315
|
+
const mediaPartTypes: ReadonlySet<unknown> = new Set(["image", "audio", "video", "document"])
|
|
316
|
+
|
|
317
|
+
// A recognised media part whose required source is unrecognised is removed
|
|
318
|
+
// with it
|
|
319
|
+
const isUnknownContentPart = (value: unknown): boolean =>
|
|
320
|
+
hasUnknownTag(value, "type", contentPartTypes) ||
|
|
321
|
+
(Predicate.isObject(value) && mediaPartTypes.has(value.type) &&
|
|
322
|
+
hasUnknownTag(value.source, "type", partSourceTypes))
|
|
323
|
+
|
|
324
|
+
const Content = Schema.Union([Schema.String, withoutUnknownMembers(ContentPart, isUnknownContentPart)])
|
|
325
|
+
|
|
326
|
+
// =============================================================================
|
|
327
|
+
// Messages
|
|
328
|
+
// =============================================================================
|
|
329
|
+
|
|
330
|
+
const messageFields = {
|
|
331
|
+
subagentRunId: Schema.optionalKey(Schema.String),
|
|
332
|
+
id: Schema.String,
|
|
333
|
+
metadata: Schema.optionalKey(Metadata)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Schema for instructions from the application developer.
|
|
338
|
+
*
|
|
339
|
+
* @stability experimental
|
|
340
|
+
* @category schemas
|
|
341
|
+
* @since 4.1.0
|
|
342
|
+
*/
|
|
343
|
+
export const DeveloperMessage = Schema.Struct({
|
|
344
|
+
...messageFields,
|
|
345
|
+
role: Schema.Literal("developer"),
|
|
346
|
+
name: Schema.optionalKey(Schema.String),
|
|
347
|
+
encryptedValue: Schema.optionalKey(Schema.String),
|
|
348
|
+
content: Schema.String
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Instructions from the application developer.
|
|
353
|
+
*
|
|
354
|
+
* @stability experimental
|
|
355
|
+
* @category models
|
|
356
|
+
* @since 4.1.0
|
|
357
|
+
*/
|
|
358
|
+
export type DeveloperMessage = typeof DeveloperMessage.Type
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Schema for instructions from the system.
|
|
362
|
+
*
|
|
363
|
+
* @stability experimental
|
|
364
|
+
* @category schemas
|
|
365
|
+
* @since 4.1.0
|
|
366
|
+
*/
|
|
367
|
+
export const SystemMessage = Schema.Struct({
|
|
368
|
+
...messageFields,
|
|
369
|
+
role: Schema.Literal("system"),
|
|
370
|
+
name: Schema.optionalKey(Schema.String),
|
|
371
|
+
encryptedValue: Schema.optionalKey(Schema.String),
|
|
372
|
+
content: Schema.String
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Instructions from the system.
|
|
377
|
+
*
|
|
378
|
+
* @stability experimental
|
|
379
|
+
* @category models
|
|
380
|
+
* @since 4.1.0
|
|
381
|
+
*/
|
|
382
|
+
export type SystemMessage = typeof SystemMessage.Type
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Schema for a tool call made by an assistant message.
|
|
386
|
+
*
|
|
387
|
+
* **Details**
|
|
388
|
+
*
|
|
389
|
+
* `function.arguments` is the JSON text of the call's arguments.
|
|
390
|
+
*
|
|
391
|
+
* @stability experimental
|
|
392
|
+
* @category schemas
|
|
393
|
+
* @since 4.1.0
|
|
394
|
+
*/
|
|
395
|
+
export const ToolCall = Schema.Struct({
|
|
396
|
+
id: Schema.String,
|
|
397
|
+
type: Schema.Literal("function"),
|
|
398
|
+
function: Schema.Struct({
|
|
399
|
+
name: Schema.String,
|
|
400
|
+
arguments: Schema.String
|
|
401
|
+
}),
|
|
402
|
+
encryptedValue: Schema.optionalKey(Schema.String),
|
|
403
|
+
metadata: Schema.optionalKey(Metadata)
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* A tool call made by an assistant message.
|
|
408
|
+
*
|
|
409
|
+
* @stability experimental
|
|
410
|
+
* @category models
|
|
411
|
+
* @since 4.1.0
|
|
412
|
+
*/
|
|
413
|
+
export type ToolCall = typeof ToolCall.Type
|
|
414
|
+
|
|
415
|
+
const toolCallTypes: ReadonlySet<string> = new Set(["function"])
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Schema for a message from the agent.
|
|
419
|
+
*
|
|
420
|
+
* @stability experimental
|
|
421
|
+
* @category schemas
|
|
422
|
+
* @since 4.1.0
|
|
423
|
+
*/
|
|
424
|
+
export const AssistantMessage = Schema.Struct({
|
|
425
|
+
...messageFields,
|
|
426
|
+
role: Schema.Literal("assistant"),
|
|
427
|
+
name: Schema.optionalKey(Schema.String),
|
|
428
|
+
encryptedValue: Schema.optionalKey(Schema.String),
|
|
429
|
+
content: Schema.optionalKey(Schema.String),
|
|
430
|
+
toolCalls: Schema.optionalKey(
|
|
431
|
+
withoutUnknownMembers(ToolCall, (value) => hasUnknownTag(value, "type", toolCallTypes))
|
|
432
|
+
)
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* A message from the agent.
|
|
437
|
+
*
|
|
438
|
+
* @stability experimental
|
|
439
|
+
* @category models
|
|
440
|
+
* @since 4.1.0
|
|
441
|
+
*/
|
|
442
|
+
export type AssistantMessage = typeof AssistantMessage.Type
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Schema for a message from the person using the application.
|
|
446
|
+
*
|
|
447
|
+
* @stability experimental
|
|
448
|
+
* @category schemas
|
|
449
|
+
* @since 4.1.0
|
|
450
|
+
*/
|
|
451
|
+
export const UserMessage = Schema.Struct({
|
|
452
|
+
...messageFields,
|
|
453
|
+
role: Schema.Literal("user"),
|
|
454
|
+
name: Schema.optionalKey(Schema.String),
|
|
455
|
+
encryptedValue: Schema.optionalKey(Schema.String),
|
|
456
|
+
content: Content
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* A message from the person using the application.
|
|
461
|
+
*
|
|
462
|
+
* @stability experimental
|
|
463
|
+
* @category models
|
|
464
|
+
* @since 4.1.0
|
|
465
|
+
*/
|
|
466
|
+
export type UserMessage = typeof UserMessage.Type
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Schema for the result of a tool call, as a message in the conversation.
|
|
470
|
+
*
|
|
471
|
+
* **Details**
|
|
472
|
+
*
|
|
473
|
+
* `error` is present when the tool call failed.
|
|
474
|
+
*
|
|
475
|
+
* @stability experimental
|
|
476
|
+
* @category schemas
|
|
477
|
+
* @since 4.1.0
|
|
478
|
+
*/
|
|
479
|
+
export const ToolMessage = Schema.Struct({
|
|
480
|
+
...messageFields,
|
|
481
|
+
role: Schema.Literal("tool"),
|
|
482
|
+
content: Content,
|
|
483
|
+
toolCallId: Schema.String,
|
|
484
|
+
error: Schema.optionalKey(Schema.String),
|
|
485
|
+
encryptedValue: Schema.optionalKey(Schema.String)
|
|
486
|
+
})
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* The result of a tool call, as a message in the conversation.
|
|
490
|
+
*
|
|
491
|
+
* @stability experimental
|
|
492
|
+
* @category models
|
|
493
|
+
* @since 4.1.0
|
|
494
|
+
*/
|
|
495
|
+
export type ToolMessage = typeof ToolMessage.Type
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Schema for structured progress kept in the conversation as a message.
|
|
499
|
+
*
|
|
500
|
+
* @stability experimental
|
|
501
|
+
* @category schemas
|
|
502
|
+
* @since 4.1.0
|
|
503
|
+
*/
|
|
504
|
+
export const ActivityMessage = Schema.Struct({
|
|
505
|
+
...messageFields,
|
|
506
|
+
role: Schema.Literal("activity"),
|
|
507
|
+
activityType: Schema.String,
|
|
508
|
+
content: Schema.Record(Schema.String, Schema.Unknown)
|
|
509
|
+
})
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Structured progress kept in the conversation as a message.
|
|
513
|
+
*
|
|
514
|
+
* @stability experimental
|
|
515
|
+
* @category models
|
|
516
|
+
* @since 4.1.0
|
|
517
|
+
*/
|
|
518
|
+
export type ActivityMessage = typeof ActivityMessage.Type
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Schema for a span of the agent's reasoning, kept in the conversation as a
|
|
522
|
+
* message.
|
|
523
|
+
*
|
|
524
|
+
* @stability experimental
|
|
525
|
+
* @category schemas
|
|
526
|
+
* @since 4.1.0
|
|
527
|
+
*/
|
|
528
|
+
export const ReasoningMessage = Schema.Struct({
|
|
529
|
+
...messageFields,
|
|
530
|
+
role: Schema.Literal("reasoning"),
|
|
531
|
+
content: Schema.String,
|
|
532
|
+
encryptedValue: Schema.optionalKey(Schema.String)
|
|
533
|
+
})
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* A span of the agent's reasoning, kept in the conversation as a message.
|
|
537
|
+
*
|
|
538
|
+
* @stability experimental
|
|
539
|
+
* @category models
|
|
540
|
+
* @since 4.1.0
|
|
541
|
+
*/
|
|
542
|
+
export type ReasoningMessage = typeof ReasoningMessage.Type
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Schema for any message in an AG-UI conversation, discriminated by `role`.
|
|
546
|
+
*
|
|
547
|
+
* @stability experimental
|
|
548
|
+
* @category schemas
|
|
549
|
+
* @since 4.1.0
|
|
550
|
+
*/
|
|
551
|
+
export const Message = Schema.Union([
|
|
552
|
+
DeveloperMessage,
|
|
553
|
+
SystemMessage,
|
|
554
|
+
AssistantMessage,
|
|
555
|
+
UserMessage,
|
|
556
|
+
ToolMessage,
|
|
557
|
+
ActivityMessage,
|
|
558
|
+
ReasoningMessage
|
|
559
|
+
])
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Any message in an AG-UI conversation, discriminated by `role`.
|
|
563
|
+
*
|
|
564
|
+
* @stability experimental
|
|
565
|
+
* @category models
|
|
566
|
+
* @since 4.1.0
|
|
567
|
+
*/
|
|
568
|
+
export type Message = typeof Message.Type
|
|
569
|
+
|
|
570
|
+
const messageRoles: ReadonlySet<string> = new Set([
|
|
571
|
+
"developer",
|
|
572
|
+
"system",
|
|
573
|
+
"assistant",
|
|
574
|
+
"user",
|
|
575
|
+
"tool",
|
|
576
|
+
"activity",
|
|
577
|
+
"reasoning"
|
|
578
|
+
])
|
|
579
|
+
|
|
580
|
+
const Messages = withoutUnknownMembers(Message, (value) => hasUnknownTag(value, "role", messageRoles))
|
|
581
|
+
|
|
582
|
+
// =============================================================================
|
|
583
|
+
// Run input
|
|
584
|
+
// =============================================================================
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Schema for a tool the application offers to the agent.
|
|
588
|
+
*
|
|
589
|
+
* **Details**
|
|
590
|
+
*
|
|
591
|
+
* `parameters` is a JSON Schema describing the tool's arguments.
|
|
592
|
+
*
|
|
593
|
+
* @stability experimental
|
|
594
|
+
* @category schemas
|
|
595
|
+
* @since 4.1.0
|
|
596
|
+
*/
|
|
597
|
+
export const Tool = Schema.Struct({
|
|
598
|
+
name: Schema.String,
|
|
599
|
+
description: Schema.String,
|
|
600
|
+
parameters: Schema.optionalKey(Schema.Unknown),
|
|
601
|
+
metadata: Schema.optionalKey(Metadata)
|
|
602
|
+
})
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* A tool the application offers to the agent.
|
|
606
|
+
*
|
|
607
|
+
* @stability experimental
|
|
608
|
+
* @category models
|
|
609
|
+
* @since 4.1.0
|
|
610
|
+
*/
|
|
611
|
+
export type Tool = typeof Tool.Type
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Schema for a named piece of ambient information given to the agent for a
|
|
615
|
+
* run.
|
|
616
|
+
*
|
|
617
|
+
* @stability experimental
|
|
618
|
+
* @category schemas
|
|
619
|
+
* @since 4.1.0
|
|
620
|
+
*/
|
|
621
|
+
export const Context = Schema.Struct({
|
|
622
|
+
description: Schema.String,
|
|
623
|
+
value: Schema.String
|
|
624
|
+
})
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* A named piece of ambient information given to the agent for a run.
|
|
628
|
+
*
|
|
629
|
+
* @stability experimental
|
|
630
|
+
* @category models
|
|
631
|
+
* @since 4.1.0
|
|
632
|
+
*/
|
|
633
|
+
export type Context = typeof Context.Type
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Schema for an answer to an interrupt, sent on the run that continues from
|
|
637
|
+
* it.
|
|
638
|
+
*
|
|
639
|
+
* @stability experimental
|
|
640
|
+
* @category schemas
|
|
641
|
+
* @since 4.1.0
|
|
642
|
+
*/
|
|
643
|
+
export const ResumeEntry = Schema.Struct({
|
|
644
|
+
interruptId: Schema.String,
|
|
645
|
+
status: Schema.Literals(["resolved", "cancelled"]),
|
|
646
|
+
payload: Schema.optionalKey(Schema.Unknown),
|
|
647
|
+
metadata: Schema.optionalKey(Metadata)
|
|
648
|
+
})
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* An answer to an interrupt, sent on the run that continues from it.
|
|
652
|
+
*
|
|
653
|
+
* @stability experimental
|
|
654
|
+
* @category models
|
|
655
|
+
* @since 4.1.0
|
|
656
|
+
*/
|
|
657
|
+
export type ResumeEntry = typeof ResumeEntry.Type
|
|
658
|
+
|
|
659
|
+
const resumeStatuses: ReadonlySet<string> = new Set(["resolved", "cancelled"])
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Schema for the request body that starts an agent run.
|
|
663
|
+
*
|
|
664
|
+
* **Details**
|
|
665
|
+
*
|
|
666
|
+
* `messages` is the complete conversation so far, which lets an agent serve
|
|
667
|
+
* runs without keeping its own history. Missing `tools` and `context` decode
|
|
668
|
+
* to empty arrays. As AG-UI requires, messages, content parts, tool calls,
|
|
669
|
+
* and resume entries of kinds or statuses this version does not recognise are
|
|
670
|
+
* removed during decoding rather than rejected.
|
|
671
|
+
*
|
|
672
|
+
* **Gotchas**
|
|
673
|
+
*
|
|
674
|
+
* Every field comes from the client. Treat messages, tools, and context as
|
|
675
|
+
* untrusted input.
|
|
676
|
+
*
|
|
677
|
+
* @stability experimental
|
|
678
|
+
* @category schemas
|
|
679
|
+
* @since 4.1.0
|
|
680
|
+
*/
|
|
681
|
+
export const RunAgentInput = Schema.Struct({
|
|
682
|
+
threadId: Schema.String,
|
|
683
|
+
runId: Schema.String,
|
|
684
|
+
protocolVersion: Schema.optionalKey(Schema.String),
|
|
685
|
+
parentRunId: Schema.optionalKey(Schema.String),
|
|
686
|
+
state: Schema.optionalKey(Schema.Unknown),
|
|
687
|
+
messages: Messages,
|
|
688
|
+
tools: Schema.Array(Tool).pipe(Schema.withDecodingDefaultTypeKey(Effect.succeed([]))),
|
|
689
|
+
context: Schema.Array(Context).pipe(Schema.withDecodingDefaultTypeKey(Effect.succeed([]))),
|
|
690
|
+
forwardedProps: Schema.optionalKey(Schema.Unknown),
|
|
691
|
+
resume: Schema.optionalKey(
|
|
692
|
+
withoutUnknownMembers(ResumeEntry, (value) => hasUnknownTag(value, "status", resumeStatuses))
|
|
693
|
+
)
|
|
694
|
+
})
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* The request body that starts an agent run.
|
|
698
|
+
*
|
|
699
|
+
* @stability experimental
|
|
700
|
+
* @category models
|
|
701
|
+
* @since 4.1.0
|
|
702
|
+
*/
|
|
703
|
+
export type RunAgentInput = typeof RunAgentInput.Type
|
|
704
|
+
|
|
705
|
+
// =============================================================================
|
|
706
|
+
// Text message events
|
|
707
|
+
// =============================================================================
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Schema for the role of a streamed text message.
|
|
711
|
+
*
|
|
712
|
+
* @stability experimental
|
|
713
|
+
* @category schemas
|
|
714
|
+
* @since 4.1.0
|
|
715
|
+
*/
|
|
716
|
+
export const TextMessageRole = Schema.Literals(["developer", "system", "assistant", "user"])
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* The role of a streamed text message.
|
|
720
|
+
*
|
|
721
|
+
* @stability experimental
|
|
722
|
+
* @category models
|
|
723
|
+
* @since 4.1.0
|
|
724
|
+
*/
|
|
725
|
+
export type TextMessageRole = typeof TextMessageRole.Type
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Schema for the event that opens a streamed text message.
|
|
729
|
+
*
|
|
730
|
+
* @stability experimental
|
|
731
|
+
* @category schemas
|
|
732
|
+
* @since 4.1.0
|
|
733
|
+
*/
|
|
734
|
+
export const TextMessageStartEvent = Schema.Struct({
|
|
735
|
+
type: Schema.Literal("TEXT_MESSAGE_START"),
|
|
736
|
+
...subagentEventFields,
|
|
737
|
+
messageId: Schema.String,
|
|
738
|
+
role: Schema.optionalKey(TextMessageRole),
|
|
739
|
+
name: Schema.optionalKey(Schema.String)
|
|
740
|
+
})
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Opens a streamed text message.
|
|
744
|
+
*
|
|
745
|
+
* @stability experimental
|
|
746
|
+
* @category models
|
|
747
|
+
* @since 4.1.0
|
|
748
|
+
*/
|
|
749
|
+
export type TextMessageStartEvent = typeof TextMessageStartEvent.Type
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Schema for the event that appends a fragment to a streamed text message.
|
|
753
|
+
*
|
|
754
|
+
* @stability experimental
|
|
755
|
+
* @category schemas
|
|
756
|
+
* @since 4.1.0
|
|
757
|
+
*/
|
|
758
|
+
export const TextMessageContentEvent = Schema.Struct({
|
|
759
|
+
type: Schema.Literal("TEXT_MESSAGE_CONTENT"),
|
|
760
|
+
...subagentEventFields,
|
|
761
|
+
messageId: Schema.String,
|
|
762
|
+
delta: Schema.String
|
|
763
|
+
})
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Appends a fragment to a streamed text message.
|
|
767
|
+
*
|
|
768
|
+
* @stability experimental
|
|
769
|
+
* @category models
|
|
770
|
+
* @since 4.1.0
|
|
771
|
+
*/
|
|
772
|
+
export type TextMessageContentEvent = typeof TextMessageContentEvent.Type
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Schema for the event that closes a streamed text message.
|
|
776
|
+
*
|
|
777
|
+
* @stability experimental
|
|
778
|
+
* @category schemas
|
|
779
|
+
* @since 4.1.0
|
|
780
|
+
*/
|
|
781
|
+
export const TextMessageEndEvent = Schema.Struct({
|
|
782
|
+
type: Schema.Literal("TEXT_MESSAGE_END"),
|
|
783
|
+
...subagentEventFields,
|
|
784
|
+
messageId: Schema.String
|
|
785
|
+
})
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Closes a streamed text message.
|
|
789
|
+
*
|
|
790
|
+
* @stability experimental
|
|
791
|
+
* @category models
|
|
792
|
+
* @since 4.1.0
|
|
793
|
+
*/
|
|
794
|
+
export type TextMessageEndEvent = typeof TextMessageEndEvent.Type
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Schema for the shorthand event that stands in for a text message's start,
|
|
798
|
+
* content, and end sequence.
|
|
799
|
+
*
|
|
800
|
+
* @stability experimental
|
|
801
|
+
* @category schemas
|
|
802
|
+
* @since 4.1.0
|
|
803
|
+
*/
|
|
804
|
+
export const TextMessageChunkEvent = Schema.Struct({
|
|
805
|
+
type: Schema.Literal("TEXT_MESSAGE_CHUNK"),
|
|
806
|
+
...subagentEventFields,
|
|
807
|
+
messageId: Schema.optionalKey(Schema.String),
|
|
808
|
+
role: Schema.optionalKey(TextMessageRole),
|
|
809
|
+
delta: Schema.optionalKey(Schema.String),
|
|
810
|
+
name: Schema.optionalKey(Schema.String)
|
|
811
|
+
})
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Shorthand that stands in for a text message's start, content, and end
|
|
815
|
+
* sequence.
|
|
816
|
+
*
|
|
817
|
+
* @stability experimental
|
|
818
|
+
* @category models
|
|
819
|
+
* @since 4.1.0
|
|
820
|
+
*/
|
|
821
|
+
export type TextMessageChunkEvent = typeof TextMessageChunkEvent.Type
|
|
822
|
+
|
|
823
|
+
// =============================================================================
|
|
824
|
+
// Tool call events
|
|
825
|
+
// =============================================================================
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Schema for the event that opens a tool call.
|
|
829
|
+
*
|
|
830
|
+
* @stability experimental
|
|
831
|
+
* @category schemas
|
|
832
|
+
* @since 4.1.0
|
|
833
|
+
*/
|
|
834
|
+
export const ToolCallStartEvent = Schema.Struct({
|
|
835
|
+
type: Schema.Literal("TOOL_CALL_START"),
|
|
836
|
+
...subagentEventFields,
|
|
837
|
+
toolCallId: Schema.String,
|
|
838
|
+
toolCallName: Schema.String,
|
|
839
|
+
parentMessageId: Schema.optionalKey(Schema.String)
|
|
840
|
+
})
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* Opens a tool call.
|
|
844
|
+
*
|
|
845
|
+
* @stability experimental
|
|
846
|
+
* @category models
|
|
847
|
+
* @since 4.1.0
|
|
848
|
+
*/
|
|
849
|
+
export type ToolCallStartEvent = typeof ToolCallStartEvent.Type
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Schema for the event that appends a fragment of a tool call's JSON
|
|
853
|
+
* arguments.
|
|
854
|
+
*
|
|
855
|
+
* @stability experimental
|
|
856
|
+
* @category schemas
|
|
857
|
+
* @since 4.1.0
|
|
858
|
+
*/
|
|
859
|
+
export const ToolCallArgsEvent = Schema.Struct({
|
|
860
|
+
type: Schema.Literal("TOOL_CALL_ARGS"),
|
|
861
|
+
...subagentEventFields,
|
|
862
|
+
toolCallId: Schema.String,
|
|
863
|
+
delta: Schema.String
|
|
864
|
+
})
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Appends a fragment of a tool call's JSON arguments.
|
|
868
|
+
*
|
|
869
|
+
* @stability experimental
|
|
870
|
+
* @category models
|
|
871
|
+
* @since 4.1.0
|
|
872
|
+
*/
|
|
873
|
+
export type ToolCallArgsEvent = typeof ToolCallArgsEvent.Type
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Schema for the event that closes a tool call once its arguments are
|
|
877
|
+
* complete.
|
|
878
|
+
*
|
|
879
|
+
* @stability experimental
|
|
880
|
+
* @category schemas
|
|
881
|
+
* @since 4.1.0
|
|
882
|
+
*/
|
|
883
|
+
export const ToolCallEndEvent = Schema.Struct({
|
|
884
|
+
type: Schema.Literal("TOOL_CALL_END"),
|
|
885
|
+
...subagentEventFields,
|
|
886
|
+
toolCallId: Schema.String
|
|
887
|
+
})
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Closes a tool call once its arguments are complete.
|
|
891
|
+
*
|
|
892
|
+
* @stability experimental
|
|
893
|
+
* @category models
|
|
894
|
+
* @since 4.1.0
|
|
895
|
+
*/
|
|
896
|
+
export type ToolCallEndEvent = typeof ToolCallEndEvent.Type
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Schema for the shorthand event that stands in for a tool call's start,
|
|
900
|
+
* arguments, and end sequence.
|
|
901
|
+
*
|
|
902
|
+
* @stability experimental
|
|
903
|
+
* @category schemas
|
|
904
|
+
* @since 4.1.0
|
|
905
|
+
*/
|
|
906
|
+
export const ToolCallChunkEvent = Schema.Struct({
|
|
907
|
+
type: Schema.Literal("TOOL_CALL_CHUNK"),
|
|
908
|
+
...subagentEventFields,
|
|
909
|
+
toolCallId: Schema.optionalKey(Schema.String),
|
|
910
|
+
toolCallName: Schema.optionalKey(Schema.String),
|
|
911
|
+
parentMessageId: Schema.optionalKey(Schema.String),
|
|
912
|
+
delta: Schema.optionalKey(Schema.String)
|
|
913
|
+
})
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Shorthand that stands in for a tool call's start, arguments, and end
|
|
917
|
+
* sequence.
|
|
918
|
+
*
|
|
919
|
+
* @stability experimental
|
|
920
|
+
* @category models
|
|
921
|
+
* @since 4.1.0
|
|
922
|
+
*/
|
|
923
|
+
export type ToolCallChunkEvent = typeof ToolCallChunkEvent.Type
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Schema for the event that delivers the result of a tool call as a new tool
|
|
927
|
+
* message.
|
|
928
|
+
*
|
|
929
|
+
* @stability experimental
|
|
930
|
+
* @category schemas
|
|
931
|
+
* @since 4.1.0
|
|
932
|
+
*/
|
|
933
|
+
export const ToolCallResultEvent = Schema.Struct({
|
|
934
|
+
type: Schema.Literal("TOOL_CALL_RESULT"),
|
|
935
|
+
...subagentEventFields,
|
|
936
|
+
messageId: Schema.String,
|
|
937
|
+
toolCallId: Schema.String,
|
|
938
|
+
content: Content,
|
|
939
|
+
role: Schema.optionalKey(Schema.Literal("tool"))
|
|
940
|
+
})
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Delivers the result of a tool call as a new tool message.
|
|
944
|
+
*
|
|
945
|
+
* @stability experimental
|
|
946
|
+
* @category models
|
|
947
|
+
* @since 4.1.0
|
|
948
|
+
*/
|
|
949
|
+
export type ToolCallResultEvent = typeof ToolCallResultEvent.Type
|
|
950
|
+
|
|
951
|
+
// =============================================================================
|
|
952
|
+
// State and activity events
|
|
953
|
+
// =============================================================================
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Schema for one RFC 6902 JSON Patch operation.
|
|
957
|
+
*
|
|
958
|
+
* @stability experimental
|
|
959
|
+
* @category schemas
|
|
960
|
+
* @since 4.1.0
|
|
961
|
+
*/
|
|
962
|
+
export const JsonPatchOperation = Schema.Union([
|
|
963
|
+
Schema.Struct({ op: Schema.Literal("add"), path: Schema.String, value: Schema.Unknown }),
|
|
964
|
+
Schema.Struct({ op: Schema.Literal("remove"), path: Schema.String }),
|
|
965
|
+
Schema.Struct({ op: Schema.Literal("replace"), path: Schema.String, value: Schema.Unknown }),
|
|
966
|
+
Schema.Struct({ op: Schema.Literal("move"), from: Schema.String, path: Schema.String }),
|
|
967
|
+
Schema.Struct({ op: Schema.Literal("copy"), from: Schema.String, path: Schema.String }),
|
|
968
|
+
Schema.Struct({ op: Schema.Literal("test"), path: Schema.String, value: Schema.Unknown })
|
|
969
|
+
])
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* One RFC 6902 JSON Patch operation.
|
|
973
|
+
*
|
|
974
|
+
* @stability experimental
|
|
975
|
+
* @category models
|
|
976
|
+
* @since 4.1.0
|
|
977
|
+
*/
|
|
978
|
+
export type JsonPatchOperation = typeof JsonPatchOperation.Type
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Schema for the event that replaces the agent state.
|
|
982
|
+
*
|
|
983
|
+
* @stability experimental
|
|
984
|
+
* @category schemas
|
|
985
|
+
* @since 4.1.0
|
|
986
|
+
*/
|
|
987
|
+
export const StateSnapshotEvent = Schema.Struct({
|
|
988
|
+
type: Schema.Literal("STATE_SNAPSHOT"),
|
|
989
|
+
...subagentEventFields,
|
|
990
|
+
snapshot: Schema.Unknown
|
|
991
|
+
})
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Replaces the agent state.
|
|
995
|
+
*
|
|
996
|
+
* @stability experimental
|
|
997
|
+
* @category models
|
|
998
|
+
* @since 4.1.0
|
|
999
|
+
*/
|
|
1000
|
+
export type StateSnapshotEvent = typeof StateSnapshotEvent.Type
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Schema for the event that applies a JSON Patch to the agent state.
|
|
1004
|
+
*
|
|
1005
|
+
* @stability experimental
|
|
1006
|
+
* @category schemas
|
|
1007
|
+
* @since 4.1.0
|
|
1008
|
+
*/
|
|
1009
|
+
export const StateDeltaEvent = Schema.Struct({
|
|
1010
|
+
type: Schema.Literal("STATE_DELTA"),
|
|
1011
|
+
...subagentEventFields,
|
|
1012
|
+
delta: Schema.Array(JsonPatchOperation)
|
|
1013
|
+
})
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* Applies a JSON Patch to the agent state.
|
|
1017
|
+
*
|
|
1018
|
+
* @stability experimental
|
|
1019
|
+
* @category models
|
|
1020
|
+
* @since 4.1.0
|
|
1021
|
+
*/
|
|
1022
|
+
export type StateDeltaEvent = typeof StateDeltaEvent.Type
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* Schema for the event that replaces the conversation the agent owns.
|
|
1026
|
+
*
|
|
1027
|
+
* @stability experimental
|
|
1028
|
+
* @category schemas
|
|
1029
|
+
* @since 4.1.0
|
|
1030
|
+
*/
|
|
1031
|
+
export const MessagesSnapshotEvent = Schema.Struct({
|
|
1032
|
+
type: Schema.Literal("MESSAGES_SNAPSHOT"),
|
|
1033
|
+
...baseEventFields,
|
|
1034
|
+
messages: Messages
|
|
1035
|
+
})
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Replaces the conversation the agent owns.
|
|
1039
|
+
*
|
|
1040
|
+
* @stability experimental
|
|
1041
|
+
* @category models
|
|
1042
|
+
* @since 4.1.0
|
|
1043
|
+
*/
|
|
1044
|
+
export type MessagesSnapshotEvent = typeof MessagesSnapshotEvent.Type
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Schema for the event that sets the content of an activity message.
|
|
1048
|
+
*
|
|
1049
|
+
* @stability experimental
|
|
1050
|
+
* @category schemas
|
|
1051
|
+
* @since 4.1.0
|
|
1052
|
+
*/
|
|
1053
|
+
export const ActivitySnapshotEvent = Schema.Struct({
|
|
1054
|
+
type: Schema.Literal("ACTIVITY_SNAPSHOT"),
|
|
1055
|
+
...subagentEventFields,
|
|
1056
|
+
messageId: Schema.String,
|
|
1057
|
+
activityType: Schema.String,
|
|
1058
|
+
content: Schema.Record(Schema.String, Schema.Unknown),
|
|
1059
|
+
replace: Schema.optionalKey(Schema.Boolean)
|
|
1060
|
+
})
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* Sets the content of an activity message.
|
|
1064
|
+
*
|
|
1065
|
+
* @stability experimental
|
|
1066
|
+
* @category models
|
|
1067
|
+
* @since 4.1.0
|
|
1068
|
+
*/
|
|
1069
|
+
export type ActivitySnapshotEvent = typeof ActivitySnapshotEvent.Type
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* Schema for the event that applies a JSON Patch to an activity message.
|
|
1073
|
+
*
|
|
1074
|
+
* @stability experimental
|
|
1075
|
+
* @category schemas
|
|
1076
|
+
* @since 4.1.0
|
|
1077
|
+
*/
|
|
1078
|
+
export const ActivityDeltaEvent = Schema.Struct({
|
|
1079
|
+
type: Schema.Literal("ACTIVITY_DELTA"),
|
|
1080
|
+
...subagentEventFields,
|
|
1081
|
+
messageId: Schema.String,
|
|
1082
|
+
activityType: Schema.String,
|
|
1083
|
+
patch: Schema.Array(JsonPatchOperation)
|
|
1084
|
+
})
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* Applies a JSON Patch to an activity message.
|
|
1088
|
+
*
|
|
1089
|
+
* @stability experimental
|
|
1090
|
+
* @category models
|
|
1091
|
+
* @since 4.1.0
|
|
1092
|
+
*/
|
|
1093
|
+
export type ActivityDeltaEvent = typeof ActivityDeltaEvent.Type
|
|
1094
|
+
|
|
1095
|
+
// =============================================================================
|
|
1096
|
+
// Special events
|
|
1097
|
+
// =============================================================================
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Schema for the event that passes through an event from an external system.
|
|
1101
|
+
*
|
|
1102
|
+
* @stability experimental
|
|
1103
|
+
* @category schemas
|
|
1104
|
+
* @since 4.1.0
|
|
1105
|
+
*/
|
|
1106
|
+
export const RawEvent = Schema.Struct({
|
|
1107
|
+
type: Schema.Literal("RAW"),
|
|
1108
|
+
...subagentEventFields,
|
|
1109
|
+
event: Schema.Unknown,
|
|
1110
|
+
source: Schema.optionalKey(Schema.String)
|
|
1111
|
+
})
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Passes through an event from an external system.
|
|
1115
|
+
*
|
|
1116
|
+
* @stability experimental
|
|
1117
|
+
* @category models
|
|
1118
|
+
* @since 4.1.0
|
|
1119
|
+
*/
|
|
1120
|
+
export type RawEvent = typeof RawEvent.Type
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* Schema for an application-defined event.
|
|
1124
|
+
*
|
|
1125
|
+
* @stability experimental
|
|
1126
|
+
* @category schemas
|
|
1127
|
+
* @since 4.1.0
|
|
1128
|
+
*/
|
|
1129
|
+
export const CustomEvent = Schema.Struct({
|
|
1130
|
+
type: Schema.Literal("CUSTOM"),
|
|
1131
|
+
...subagentEventFields,
|
|
1132
|
+
name: Schema.String,
|
|
1133
|
+
value: Schema.Unknown
|
|
1134
|
+
})
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* An application-defined event.
|
|
1138
|
+
*
|
|
1139
|
+
* @stability experimental
|
|
1140
|
+
* @category models
|
|
1141
|
+
* @since 4.1.0
|
|
1142
|
+
*/
|
|
1143
|
+
export type CustomEvent = typeof CustomEvent.Type
|
|
1144
|
+
|
|
1145
|
+
// =============================================================================
|
|
1146
|
+
// Lifecycle events
|
|
1147
|
+
// =============================================================================
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Schema for the event that opens a run.
|
|
1151
|
+
*
|
|
1152
|
+
* @stability experimental
|
|
1153
|
+
* @category schemas
|
|
1154
|
+
* @since 4.1.0
|
|
1155
|
+
*/
|
|
1156
|
+
export const RunStartedEvent = Schema.Struct({
|
|
1157
|
+
type: Schema.Literal("RUN_STARTED"),
|
|
1158
|
+
...baseEventFields,
|
|
1159
|
+
threadId: Schema.String,
|
|
1160
|
+
runId: Schema.String,
|
|
1161
|
+
protocolVersion: Schema.optionalKey(Schema.String),
|
|
1162
|
+
parentRunId: Schema.optionalKey(Schema.String),
|
|
1163
|
+
input: Schema.optionalKey(RunAgentInput)
|
|
1164
|
+
})
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* Opens a run.
|
|
1168
|
+
*
|
|
1169
|
+
* @stability experimental
|
|
1170
|
+
* @category models
|
|
1171
|
+
* @since 4.1.0
|
|
1172
|
+
*/
|
|
1173
|
+
export type RunStartedEvent = typeof RunStartedEvent.Type
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Schema for something a run needs from outside before it can continue, such
|
|
1177
|
+
* as an approval.
|
|
1178
|
+
*
|
|
1179
|
+
* @stability experimental
|
|
1180
|
+
* @category schemas
|
|
1181
|
+
* @since 4.1.0
|
|
1182
|
+
*/
|
|
1183
|
+
export const Interrupt = Schema.Struct({
|
|
1184
|
+
subagentRunId: Schema.optionalKey(Schema.String),
|
|
1185
|
+
id: Schema.String,
|
|
1186
|
+
reason: Schema.String,
|
|
1187
|
+
message: Schema.optionalKey(Schema.String),
|
|
1188
|
+
toolCallId: Schema.optionalKey(Schema.String),
|
|
1189
|
+
responseSchema: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown)),
|
|
1190
|
+
expiresAt: Schema.optionalKey(Schema.String),
|
|
1191
|
+
metadata: Schema.optionalKey(Metadata)
|
|
1192
|
+
})
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Something a run needs from outside before it can continue, such as an
|
|
1196
|
+
* approval.
|
|
1197
|
+
*
|
|
1198
|
+
* @stability experimental
|
|
1199
|
+
* @category models
|
|
1200
|
+
* @since 4.1.0
|
|
1201
|
+
*/
|
|
1202
|
+
export type Interrupt = typeof Interrupt.Type
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* Schema for why a run ended.
|
|
1206
|
+
*
|
|
1207
|
+
* **Details**
|
|
1208
|
+
*
|
|
1209
|
+
* A `success` outcome may name frontend tool calls the application still has
|
|
1210
|
+
* to answer. An `interrupt` outcome pauses the run until a later run resumes
|
|
1211
|
+
* it.
|
|
1212
|
+
*
|
|
1213
|
+
* @stability experimental
|
|
1214
|
+
* @category schemas
|
|
1215
|
+
* @since 4.1.0
|
|
1216
|
+
*/
|
|
1217
|
+
export const RunFinishedOutcome = Schema.Union([
|
|
1218
|
+
Schema.Struct({
|
|
1219
|
+
type: Schema.Literal("success"),
|
|
1220
|
+
pendingToolCallIds: Schema.optionalKey(Schema.Array(Schema.String))
|
|
1221
|
+
}),
|
|
1222
|
+
Schema.Struct({
|
|
1223
|
+
type: Schema.Literal("interrupt"),
|
|
1224
|
+
interrupts: Schema.NonEmptyArray(Interrupt)
|
|
1225
|
+
}),
|
|
1226
|
+
Schema.Struct({
|
|
1227
|
+
type: Schema.Literal("cancelled")
|
|
1228
|
+
})
|
|
1229
|
+
])
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Why a run ended.
|
|
1233
|
+
*
|
|
1234
|
+
* @stability experimental
|
|
1235
|
+
* @category models
|
|
1236
|
+
* @since 4.1.0
|
|
1237
|
+
*/
|
|
1238
|
+
export type RunFinishedOutcome = typeof RunFinishedOutcome.Type
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* Schema for token counts reported for one provider and model.
|
|
1242
|
+
*
|
|
1243
|
+
* @stability experimental
|
|
1244
|
+
* @category schemas
|
|
1245
|
+
* @since 4.1.0
|
|
1246
|
+
*/
|
|
1247
|
+
export const TokenUsage = Schema.Struct({
|
|
1248
|
+
provider: Schema.optionalKey(Schema.String),
|
|
1249
|
+
model: Schema.optionalKey(Schema.String),
|
|
1250
|
+
inputTokens: Schema.optionalKey(TokenCount),
|
|
1251
|
+
outputTokens: Schema.optionalKey(TokenCount),
|
|
1252
|
+
totalTokens: Schema.optionalKey(TokenCount),
|
|
1253
|
+
reasoningTokens: Schema.optionalKey(TokenCount),
|
|
1254
|
+
cachedInputTokens: Schema.optionalKey(TokenCount),
|
|
1255
|
+
cacheWriteInputTokens: Schema.optionalKey(TokenCount)
|
|
1256
|
+
})
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Token counts reported for one provider and model.
|
|
1260
|
+
*
|
|
1261
|
+
* @stability experimental
|
|
1262
|
+
* @category models
|
|
1263
|
+
* @since 4.1.0
|
|
1264
|
+
*/
|
|
1265
|
+
export type TokenUsage = typeof TokenUsage.Type
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* Schema for the event that closes a run that did not fail.
|
|
1269
|
+
*
|
|
1270
|
+
* @stability experimental
|
|
1271
|
+
* @category schemas
|
|
1272
|
+
* @since 4.1.0
|
|
1273
|
+
*/
|
|
1274
|
+
export const RunFinishedEvent = Schema.Struct({
|
|
1275
|
+
type: Schema.Literal("RUN_FINISHED"),
|
|
1276
|
+
...baseEventFields,
|
|
1277
|
+
threadId: Schema.String,
|
|
1278
|
+
runId: Schema.String,
|
|
1279
|
+
result: Schema.optionalKey(Schema.Unknown),
|
|
1280
|
+
outcome: Schema.optionalKey(RunFinishedOutcome),
|
|
1281
|
+
usage: Schema.optionalKey(Schema.Array(TokenUsage))
|
|
1282
|
+
})
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Closes a run that did not fail.
|
|
1286
|
+
*
|
|
1287
|
+
* @stability experimental
|
|
1288
|
+
* @category models
|
|
1289
|
+
* @since 4.1.0
|
|
1290
|
+
*/
|
|
1291
|
+
export type RunFinishedEvent = typeof RunFinishedEvent.Type
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Schema for the event that ends a run that failed.
|
|
1295
|
+
*
|
|
1296
|
+
* @stability experimental
|
|
1297
|
+
* @category schemas
|
|
1298
|
+
* @since 4.1.0
|
|
1299
|
+
*/
|
|
1300
|
+
export const RunErrorEvent = Schema.Struct({
|
|
1301
|
+
type: Schema.Literal("RUN_ERROR"),
|
|
1302
|
+
...baseEventFields,
|
|
1303
|
+
message: Schema.String,
|
|
1304
|
+
code: Schema.optionalKey(Schema.String),
|
|
1305
|
+
usage: Schema.optionalKey(Schema.Array(TokenUsage))
|
|
1306
|
+
})
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Ends a run that failed.
|
|
1310
|
+
*
|
|
1311
|
+
* @stability experimental
|
|
1312
|
+
* @category models
|
|
1313
|
+
* @since 4.1.0
|
|
1314
|
+
*/
|
|
1315
|
+
export type RunErrorEvent = typeof RunErrorEvent.Type
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Schema for the event that opens a named step within a run.
|
|
1319
|
+
*
|
|
1320
|
+
* @stability experimental
|
|
1321
|
+
* @category schemas
|
|
1322
|
+
* @since 4.1.0
|
|
1323
|
+
*/
|
|
1324
|
+
export const StepStartedEvent = Schema.Struct({
|
|
1325
|
+
type: Schema.Literal("STEP_STARTED"),
|
|
1326
|
+
...subagentEventFields,
|
|
1327
|
+
stepName: Schema.String
|
|
1328
|
+
})
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Opens a named step within a run.
|
|
1332
|
+
*
|
|
1333
|
+
* @stability experimental
|
|
1334
|
+
* @category models
|
|
1335
|
+
* @since 4.1.0
|
|
1336
|
+
*/
|
|
1337
|
+
export type StepStartedEvent = typeof StepStartedEvent.Type
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* Schema for the event that closes a named step.
|
|
1341
|
+
*
|
|
1342
|
+
* @stability experimental
|
|
1343
|
+
* @category schemas
|
|
1344
|
+
* @since 4.1.0
|
|
1345
|
+
*/
|
|
1346
|
+
export const StepFinishedEvent = Schema.Struct({
|
|
1347
|
+
type: Schema.Literal("STEP_FINISHED"),
|
|
1348
|
+
...subagentEventFields,
|
|
1349
|
+
stepName: Schema.String
|
|
1350
|
+
})
|
|
1351
|
+
|
|
1352
|
+
/**
|
|
1353
|
+
* Closes a named step.
|
|
1354
|
+
*
|
|
1355
|
+
* @stability experimental
|
|
1356
|
+
* @category models
|
|
1357
|
+
* @since 4.1.0
|
|
1358
|
+
*/
|
|
1359
|
+
export type StepFinishedEvent = typeof StepFinishedEvent.Type
|
|
1360
|
+
|
|
1361
|
+
// =============================================================================
|
|
1362
|
+
// Reasoning events
|
|
1363
|
+
// =============================================================================
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* Schema for the event that opens a span of reasoning.
|
|
1367
|
+
*
|
|
1368
|
+
* @stability experimental
|
|
1369
|
+
* @category schemas
|
|
1370
|
+
* @since 4.1.0
|
|
1371
|
+
*/
|
|
1372
|
+
export const ReasoningStartEvent = Schema.Struct({
|
|
1373
|
+
type: Schema.Literal("REASONING_START"),
|
|
1374
|
+
...subagentEventFields,
|
|
1375
|
+
messageId: Schema.String
|
|
1376
|
+
})
|
|
1377
|
+
|
|
1378
|
+
/**
|
|
1379
|
+
* Opens a span of reasoning.
|
|
1380
|
+
*
|
|
1381
|
+
* @stability experimental
|
|
1382
|
+
* @category models
|
|
1383
|
+
* @since 4.1.0
|
|
1384
|
+
*/
|
|
1385
|
+
export type ReasoningStartEvent = typeof ReasoningStartEvent.Type
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* Schema for the event that opens a streamed reasoning message.
|
|
1389
|
+
*
|
|
1390
|
+
* @stability experimental
|
|
1391
|
+
* @category schemas
|
|
1392
|
+
* @since 4.1.0
|
|
1393
|
+
*/
|
|
1394
|
+
export const ReasoningMessageStartEvent = Schema.Struct({
|
|
1395
|
+
type: Schema.Literal("REASONING_MESSAGE_START"),
|
|
1396
|
+
...subagentEventFields,
|
|
1397
|
+
messageId: Schema.String,
|
|
1398
|
+
role: Schema.Literal("reasoning")
|
|
1399
|
+
})
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* Opens a streamed reasoning message.
|
|
1403
|
+
*
|
|
1404
|
+
* @stability experimental
|
|
1405
|
+
* @category models
|
|
1406
|
+
* @since 4.1.0
|
|
1407
|
+
*/
|
|
1408
|
+
export type ReasoningMessageStartEvent = typeof ReasoningMessageStartEvent.Type
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* Schema for the event that appends a fragment to a streamed reasoning
|
|
1412
|
+
* message.
|
|
1413
|
+
*
|
|
1414
|
+
* @stability experimental
|
|
1415
|
+
* @category schemas
|
|
1416
|
+
* @since 4.1.0
|
|
1417
|
+
*/
|
|
1418
|
+
export const ReasoningMessageContentEvent = Schema.Struct({
|
|
1419
|
+
type: Schema.Literal("REASONING_MESSAGE_CONTENT"),
|
|
1420
|
+
...subagentEventFields,
|
|
1421
|
+
messageId: Schema.String,
|
|
1422
|
+
delta: Schema.String
|
|
1423
|
+
})
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* Appends a fragment to a streamed reasoning message.
|
|
1427
|
+
*
|
|
1428
|
+
* @stability experimental
|
|
1429
|
+
* @category models
|
|
1430
|
+
* @since 4.1.0
|
|
1431
|
+
*/
|
|
1432
|
+
export type ReasoningMessageContentEvent = typeof ReasoningMessageContentEvent.Type
|
|
1433
|
+
|
|
1434
|
+
/**
|
|
1435
|
+
* Schema for the event that closes a streamed reasoning message.
|
|
1436
|
+
*
|
|
1437
|
+
* @stability experimental
|
|
1438
|
+
* @category schemas
|
|
1439
|
+
* @since 4.1.0
|
|
1440
|
+
*/
|
|
1441
|
+
export const ReasoningMessageEndEvent = Schema.Struct({
|
|
1442
|
+
type: Schema.Literal("REASONING_MESSAGE_END"),
|
|
1443
|
+
...subagentEventFields,
|
|
1444
|
+
messageId: Schema.String
|
|
1445
|
+
})
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* Closes a streamed reasoning message.
|
|
1449
|
+
*
|
|
1450
|
+
* @stability experimental
|
|
1451
|
+
* @category models
|
|
1452
|
+
* @since 4.1.0
|
|
1453
|
+
*/
|
|
1454
|
+
export type ReasoningMessageEndEvent = typeof ReasoningMessageEndEvent.Type
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Schema for the shorthand event that stands in for a reasoning message's
|
|
1458
|
+
* start, content, and end sequence.
|
|
1459
|
+
*
|
|
1460
|
+
* @stability experimental
|
|
1461
|
+
* @category schemas
|
|
1462
|
+
* @since 4.1.0
|
|
1463
|
+
*/
|
|
1464
|
+
export const ReasoningMessageChunkEvent = Schema.Struct({
|
|
1465
|
+
type: Schema.Literal("REASONING_MESSAGE_CHUNK"),
|
|
1466
|
+
...subagentEventFields,
|
|
1467
|
+
messageId: Schema.optionalKey(Schema.String),
|
|
1468
|
+
delta: Schema.optionalKey(Schema.String)
|
|
1469
|
+
})
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* Shorthand that stands in for a reasoning message's start, content, and end
|
|
1473
|
+
* sequence.
|
|
1474
|
+
*
|
|
1475
|
+
* @stability experimental
|
|
1476
|
+
* @category models
|
|
1477
|
+
* @since 4.1.0
|
|
1478
|
+
*/
|
|
1479
|
+
export type ReasoningMessageChunkEvent = typeof ReasoningMessageChunkEvent.Type
|
|
1480
|
+
|
|
1481
|
+
/**
|
|
1482
|
+
* Schema for the event that closes a span of reasoning.
|
|
1483
|
+
*
|
|
1484
|
+
* @stability experimental
|
|
1485
|
+
* @category schemas
|
|
1486
|
+
* @since 4.1.0
|
|
1487
|
+
*/
|
|
1488
|
+
export const ReasoningEndEvent = Schema.Struct({
|
|
1489
|
+
type: Schema.Literal("REASONING_END"),
|
|
1490
|
+
...subagentEventFields,
|
|
1491
|
+
messageId: Schema.String
|
|
1492
|
+
})
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* Closes a span of reasoning.
|
|
1496
|
+
*
|
|
1497
|
+
* @stability experimental
|
|
1498
|
+
* @category models
|
|
1499
|
+
* @since 4.1.0
|
|
1500
|
+
*/
|
|
1501
|
+
export type ReasoningEndEvent = typeof ReasoningEndEvent.Type
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* Schema for the event that attaches provider-encrypted reasoning to a message
|
|
1505
|
+
* or tool call.
|
|
1506
|
+
*
|
|
1507
|
+
* @stability experimental
|
|
1508
|
+
* @category schemas
|
|
1509
|
+
* @since 4.1.0
|
|
1510
|
+
*/
|
|
1511
|
+
export const ReasoningEncryptedValueEvent = Schema.Struct({
|
|
1512
|
+
type: Schema.Literal("REASONING_ENCRYPTED_VALUE"),
|
|
1513
|
+
...subagentEventFields,
|
|
1514
|
+
subtype: Schema.Literals(["tool-call", "message"]),
|
|
1515
|
+
entityId: Schema.String,
|
|
1516
|
+
encryptedValue: Schema.String
|
|
1517
|
+
})
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* Attaches provider-encrypted reasoning to a message or tool call.
|
|
1521
|
+
*
|
|
1522
|
+
* @stability experimental
|
|
1523
|
+
* @category models
|
|
1524
|
+
* @since 4.1.0
|
|
1525
|
+
*/
|
|
1526
|
+
export type ReasoningEncryptedValueEvent = typeof ReasoningEncryptedValueEvent.Type
|
|
1527
|
+
|
|
1528
|
+
// =============================================================================
|
|
1529
|
+
// Subagent events
|
|
1530
|
+
// =============================================================================
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* Schema for the event that opens a subagent invocation within a run.
|
|
1534
|
+
*
|
|
1535
|
+
* @stability experimental
|
|
1536
|
+
* @category schemas
|
|
1537
|
+
* @since 4.1.0
|
|
1538
|
+
*/
|
|
1539
|
+
export const SubagentStartedEvent = Schema.Struct({
|
|
1540
|
+
type: Schema.Literal("SUBAGENT_STARTED"),
|
|
1541
|
+
...baseEventFields,
|
|
1542
|
+
subagentRunId: Schema.String,
|
|
1543
|
+
name: Schema.String,
|
|
1544
|
+
description: Schema.optionalKey(Schema.String),
|
|
1545
|
+
parentSubagentRunId: Schema.optionalKey(Schema.String),
|
|
1546
|
+
parentToolCallId: Schema.optionalKey(Schema.String),
|
|
1547
|
+
parentMessageId: Schema.optionalKey(Schema.String)
|
|
1548
|
+
})
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* Opens a subagent invocation within a run.
|
|
1552
|
+
*
|
|
1553
|
+
* @stability experimental
|
|
1554
|
+
* @category models
|
|
1555
|
+
* @since 4.1.0
|
|
1556
|
+
*/
|
|
1557
|
+
export type SubagentStartedEvent = typeof SubagentStartedEvent.Type
|
|
1558
|
+
|
|
1559
|
+
/**
|
|
1560
|
+
* Schema for the event that closes a subagent invocation that did not fail.
|
|
1561
|
+
*
|
|
1562
|
+
* @stability experimental
|
|
1563
|
+
* @category schemas
|
|
1564
|
+
* @since 4.1.0
|
|
1565
|
+
*/
|
|
1566
|
+
export const SubagentFinishedEvent = Schema.Struct({
|
|
1567
|
+
type: Schema.Literal("SUBAGENT_FINISHED"),
|
|
1568
|
+
...baseEventFields,
|
|
1569
|
+
subagentRunId: Schema.String,
|
|
1570
|
+
result: Schema.optionalKey(Schema.Unknown),
|
|
1571
|
+
outcome: Schema.optionalKey(Schema.Union([
|
|
1572
|
+
Schema.Struct({ type: Schema.Literal("success") }),
|
|
1573
|
+
Schema.Struct({
|
|
1574
|
+
type: Schema.Literal("suspended"),
|
|
1575
|
+
interruptIds: Schema.optionalKey(Schema.Array(Schema.String))
|
|
1576
|
+
})
|
|
1577
|
+
]))
|
|
1578
|
+
})
|
|
1579
|
+
|
|
1580
|
+
/**
|
|
1581
|
+
* Closes a subagent invocation that did not fail.
|
|
1582
|
+
*
|
|
1583
|
+
* @stability experimental
|
|
1584
|
+
* @category models
|
|
1585
|
+
* @since 4.1.0
|
|
1586
|
+
*/
|
|
1587
|
+
export type SubagentFinishedEvent = typeof SubagentFinishedEvent.Type
|
|
1588
|
+
|
|
1589
|
+
/**
|
|
1590
|
+
* Schema for the event that reports a failed subagent invocation without
|
|
1591
|
+
* ending the run.
|
|
1592
|
+
*
|
|
1593
|
+
* @stability experimental
|
|
1594
|
+
* @category schemas
|
|
1595
|
+
* @since 4.1.0
|
|
1596
|
+
*/
|
|
1597
|
+
export const SubagentErrorEvent = Schema.Struct({
|
|
1598
|
+
type: Schema.Literal("SUBAGENT_ERROR"),
|
|
1599
|
+
...baseEventFields,
|
|
1600
|
+
subagentRunId: Schema.String,
|
|
1601
|
+
message: Schema.String,
|
|
1602
|
+
code: Schema.optionalKey(Schema.String)
|
|
1603
|
+
})
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Reports a failed subagent invocation without ending the run.
|
|
1607
|
+
*
|
|
1608
|
+
* @stability experimental
|
|
1609
|
+
* @category models
|
|
1610
|
+
* @since 4.1.0
|
|
1611
|
+
*/
|
|
1612
|
+
export type SubagentErrorEvent = typeof SubagentErrorEvent.Type
|
|
1613
|
+
|
|
1614
|
+
// =============================================================================
|
|
1615
|
+
// Events
|
|
1616
|
+
// =============================================================================
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* Schema for any AG-UI event, discriminated by `type`.
|
|
1620
|
+
*
|
|
1621
|
+
* @stability experimental
|
|
1622
|
+
* @category schemas
|
|
1623
|
+
* @since 4.1.0
|
|
1624
|
+
*/
|
|
1625
|
+
export const Event = Schema.Union([
|
|
1626
|
+
TextMessageStartEvent,
|
|
1627
|
+
TextMessageContentEvent,
|
|
1628
|
+
TextMessageEndEvent,
|
|
1629
|
+
TextMessageChunkEvent,
|
|
1630
|
+
ToolCallStartEvent,
|
|
1631
|
+
ToolCallArgsEvent,
|
|
1632
|
+
ToolCallEndEvent,
|
|
1633
|
+
ToolCallChunkEvent,
|
|
1634
|
+
ToolCallResultEvent,
|
|
1635
|
+
StateSnapshotEvent,
|
|
1636
|
+
StateDeltaEvent,
|
|
1637
|
+
MessagesSnapshotEvent,
|
|
1638
|
+
ActivitySnapshotEvent,
|
|
1639
|
+
ActivityDeltaEvent,
|
|
1640
|
+
RawEvent,
|
|
1641
|
+
CustomEvent,
|
|
1642
|
+
RunStartedEvent,
|
|
1643
|
+
RunFinishedEvent,
|
|
1644
|
+
RunErrorEvent,
|
|
1645
|
+
StepStartedEvent,
|
|
1646
|
+
StepFinishedEvent,
|
|
1647
|
+
ReasoningStartEvent,
|
|
1648
|
+
ReasoningMessageStartEvent,
|
|
1649
|
+
ReasoningMessageContentEvent,
|
|
1650
|
+
ReasoningMessageEndEvent,
|
|
1651
|
+
ReasoningMessageChunkEvent,
|
|
1652
|
+
ReasoningEndEvent,
|
|
1653
|
+
ReasoningEncryptedValueEvent,
|
|
1654
|
+
SubagentStartedEvent,
|
|
1655
|
+
SubagentFinishedEvent,
|
|
1656
|
+
SubagentErrorEvent
|
|
1657
|
+
])
|
|
1658
|
+
|
|
1659
|
+
/**
|
|
1660
|
+
* Any AG-UI event, discriminated by `type`.
|
|
1661
|
+
*
|
|
1662
|
+
* @stability experimental
|
|
1663
|
+
* @category models
|
|
1664
|
+
* @since 4.1.0
|
|
1665
|
+
*/
|
|
1666
|
+
export type Event = typeof Event.Type
|