effect 4.1.5 → 4.1.7
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/dist/Channel.d.ts +104 -7
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +73 -4
- package/dist/Channel.js.map +1 -1
- package/dist/Codegen.d.ts +7 -2
- package/dist/Codegen.d.ts.map +1 -1
- package/dist/Codegen.js +7 -2
- package/dist/Codegen.js.map +1 -1
- package/dist/Config.d.ts +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +5 -3
- package/dist/Config.js.map +1 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +79 -31
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +10 -9
- package/dist/Cron.js.map +1 -1
- package/dist/Effect.d.ts +139 -18
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +10 -2
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts +4 -4
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +78 -66
- package/dist/Equal.js.map +1 -1
- package/dist/Formatter.js +4 -4
- package/dist/Formatter.js.map +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +34 -41
- package/dist/Hash.js.map +1 -1
- package/dist/LayerRef.d.ts +1 -1
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +3 -3
- package/dist/LayerRef.js.map +1 -1
- package/dist/Logger.d.ts +37 -13
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +39 -10
- package/dist/Logger.js.map +1 -1
- package/dist/Match.d.ts +23 -23
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +3 -4
- package/dist/Metric.js.map +1 -1
- package/dist/Order.js +1 -1
- package/dist/Order.js.map +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +49 -21
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/Predicate.js +2 -1
- package/dist/Predicate.js.map +1 -1
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +15 -9
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +41 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +51 -390
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +2 -2
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +199 -98
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +29 -50
- package/dist/SchemaParser.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +6 -4
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Stream.d.ts +128 -5
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +124 -29
- package/dist/Stream.js.map +1 -1
- package/dist/String.js +1 -1
- package/dist/String.js.map +1 -1
- package/dist/Tracer.d.ts +10 -0
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +3 -4
- package/dist/Tracer.js.map +1 -1
- package/dist/ai/McpClient.d.ts +68 -4
- package/dist/ai/McpClient.d.ts.map +1 -1
- package/dist/ai/McpClient.js +100 -17
- package/dist/ai/McpClient.js.map +1 -1
- package/dist/ai/McpClientError.d.ts +46 -4
- package/dist/ai/McpClientError.d.ts.map +1 -1
- package/dist/ai/McpClientError.js +38 -3
- package/dist/ai/McpClientError.js.map +1 -1
- package/dist/ai/McpServer.d.ts +158 -7
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +103 -49
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +3 -1
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +17 -3
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Skill.d.ts +172 -0
- package/dist/ai/Skill.d.ts.map +1 -0
- package/dist/ai/Skill.js +209 -0
- package/dist/ai/Skill.js.map +1 -0
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +5 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +9 -7
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +12 -11
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +18 -17
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +19 -18
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +11 -0
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +29 -17
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2024_11_05.js +2 -1
- package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_03_26.js +1 -8
- package/dist/ai/internal/mcpSchema/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_06_18.js +5 -9
- package/dist/ai/internal/mcpSchema/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_11_25.js +1 -8
- package/dist/ai/internal/mcpSchema/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2026_07_28.js +4 -3
- package/dist/ai/internal/mcpSchema/v2026_07_28.js.map +1 -1
- package/dist/cluster/ClusterCron.d.ts +5 -20
- package/dist/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/cluster/ClusterCron.js +16 -4
- package/dist/cluster/ClusterCron.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +155 -83
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +56 -0
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +18 -2
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +48 -23
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/internal/entityActivation.js +2 -0
- package/dist/cluster/internal/entityActivation.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +8 -5
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/encoding/Base64.js +5 -1
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +6 -1
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Hex.js +7 -5
- package/dist/encoding/Hex.js.map +1 -1
- package/dist/encoding/Xml.d.ts +38 -9
- package/dist/encoding/Xml.d.ts.map +1 -1
- package/dist/encoding/Xml.js +63 -31
- package/dist/encoding/Xml.js.map +1 -1
- package/dist/http/FetchHttpClient.d.ts +2 -1
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +14 -10
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/Headers.d.ts +201 -3
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +205 -3
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +11 -7
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts +1 -0
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +32 -9
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +46 -0
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +15 -0
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpClientResponse.d.ts +132 -0
- package/dist/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/http/HttpClientResponse.js +83 -0
- package/dist/http/HttpClientResponse.js.map +1 -1
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +31 -2
- 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/HttpServerError.d.ts +1 -1
- package/dist/http/HttpServerError.js +1 -1
- package/dist/http/HttpServerResponse.d.ts +118 -0
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +43 -0
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/Multipart.d.ts.map +1 -1
- package/dist/http/Multipart.js +0 -5
- package/dist/http/Multipart.js.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.d.ts +6 -0
- package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.js +1 -1
- package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
- package/dist/http/internal/clientPath.d.ts +2 -0
- package/dist/http/internal/clientPath.d.ts.map +1 -0
- package/dist/http/internal/clientPath.js +24 -0
- package/dist/http/internal/clientPath.js.map +1 -0
- package/dist/http/internal/redactedPath.js +2 -0
- package/dist/http/internal/redactedPath.js.map +1 -1
- package/dist/http/internal/tracing.js +5 -3
- package/dist/http/internal/tracing.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +2 -2
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +30 -7
- 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 +5 -2
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +23 -6
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/internal/redactedKeys.d.ts +2 -0
- package/dist/http-api/internal/redactedKeys.d.ts.map +1 -0
- package/dist/http-api/internal/redactedKeys.js +37 -0
- package/dist/http-api/internal/redactedKeys.js.map +1 -0
- package/dist/internal/base64.js +34 -2
- package/dist/internal/base64.js.map +1 -1
- package/dist/internal/core.js +60 -43
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +35 -17
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +60 -52
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js +44 -13
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/fiberCachedKeys.d.ts +2 -0
- package/dist/internal/fiberCachedKeys.d.ts.map +1 -0
- package/dist/internal/fiberCachedKeys.js +48 -0
- package/dist/internal/fiberCachedKeys.js.map +1 -0
- package/dist/internal/hashMap.js +1 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/matcher.js +17 -17
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/predicate.d.ts +2 -0
- package/dist/internal/predicate.d.ts.map +1 -0
- package/dist/internal/predicate.js +10 -0
- package/dist/internal/predicate.js.map +1 -0
- package/dist/internal/references.js +8 -11
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/schema/schemaCodegen.js +3 -2
- package/dist/internal/schema/schemaCodegen.js.map +1 -1
- package/dist/internal/schema/schemaCodegenBuiltIns.d.ts +2 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.d.ts.map +1 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.js +425 -0
- package/dist/internal/schema/schemaCodegenBuiltIns.js.map +1 -0
- package/dist/internal/schema/toEquivalence.js +3 -4
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/jose/JoseError.d.ts +51 -1
- package/dist/jose/JoseError.d.ts.map +1 -1
- package/dist/jose/JoseError.js +25 -18
- package/dist/jose/JoseError.js.map +1 -1
- package/dist/jose/internal/compact.js +10 -5
- package/dist/jose/internal/compact.js.map +1 -1
- package/dist/observability/Otlp.d.ts +19 -0
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +10 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts +49 -13
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +135 -54
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts +14 -0
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +10 -2
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +2 -0
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpTracer.d.ts +14 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +10 -2
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/persistence/KeyValueStore.js +6 -4
- package/dist/persistence/KeyValueStore.js.map +1 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +10 -9
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +32 -1
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcGroup.d.ts +1 -1
- package/dist/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/rpc/RpcGroup.js +4 -0
- package/dist/rpc/RpcGroup.js.map +1 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +2 -5
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +5 -1
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +23 -0
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +30 -5
- package/dist/sql/Statement.js.map +1 -1
- package/dist/workers/Worker.d.ts +21 -0
- package/dist/workers/Worker.d.ts.map +1 -1
- package/dist/workers/Worker.js +23 -0
- package/dist/workers/Worker.js.map +1 -1
- package/dist/workflow/Activity.d.ts +18 -0
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow/Activity.js +13 -4
- package/dist/workflow/Activity.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +10 -9
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +33 -22
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +26 -12
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/dist/workflow/internal/retry.d.ts +2 -0
- package/dist/workflow/internal/retry.d.ts.map +1 -0
- package/dist/workflow/internal/retry.js +11 -0
- package/dist/workflow/internal/retry.js.map +1 -0
- package/dist/workflow/internal/scope.d.ts +2 -0
- package/dist/workflow/internal/scope.d.ts.map +1 -0
- package/dist/workflow/internal/scope.js +26 -0
- package/dist/workflow/internal/scope.js.map +1 -0
- package/package.json +3 -3
- package/src/Channel.ts +105 -8
- package/src/Codegen.ts +7 -2
- package/src/Config.ts +6 -3
- package/src/Context.ts +108 -50
- package/src/Cron.ts +11 -10
- package/src/Effect.ts +224 -48
- package/src/Equal.ts +93 -80
- package/src/Formatter.ts +4 -4
- package/src/Hash.ts +49 -48
- package/src/LayerRef.ts +6 -4
- package/src/Logger.ts +68 -25
- package/src/Match.ts +78 -50
- package/src/Metric.ts +4 -4
- package/src/Order.ts +1 -1
- package/src/Pool.ts +62 -33
- package/src/Predicate.ts +2 -5
- package/src/Scheduler.ts +27 -10
- package/src/Schema.ts +79 -296
- package/src/SchemaAST.ts +231 -157
- package/src/SchemaParser.ts +40 -57
- package/src/ScopedCache.ts +6 -4
- package/src/Stream.ts +167 -33
- package/src/String.ts +1 -1
- package/src/Tracer.ts +11 -2
- package/src/ai/McpClient.ts +157 -15
- package/src/ai/McpClientError.ts +55 -4
- package/src/ai/McpServer.ts +318 -91
- package/src/ai/Prompt.ts +20 -3
- package/src/ai/Skill.ts +236 -0
- package/src/ai/index.ts +6 -0
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +8 -13
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +13 -15
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +21 -23
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +22 -24
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +1 -1
- package/src/ai/internal/mcpProtocol.ts +15 -0
- package/src/ai/internal/mcpRuntime.ts +36 -13
- package/src/ai/internal/mcpSchema/v2024_11_05.ts +2 -1
- package/src/ai/internal/mcpSchema/v2025_03_26.ts +1 -9
- package/src/ai/internal/mcpSchema/v2025_06_18.ts +3 -10
- package/src/ai/internal/mcpSchema/v2025_11_25.ts +1 -9
- package/src/ai/internal/mcpSchema/v2026_07_28.ts +6 -8
- package/src/cluster/ClusterCron.ts +31 -20
- package/src/cluster/ClusterWorkflowEngine.ts +172 -96
- package/src/cluster/MessageStorage.ts +51 -2
- package/src/cluster/SqlMessageStorage.ts +88 -36
- package/src/cluster/internal/entityActivation.ts +6 -0
- package/src/cluster/internal/entityManager.ts +8 -4
- package/src/encoding/Base64.ts +5 -1
- package/src/encoding/Base64Url.ts +6 -1
- package/src/encoding/Hex.ts +5 -5
- package/src/encoding/Xml.ts +96 -26
- package/src/http/FetchHttpClient.ts +8 -5
- package/src/http/Headers.ts +309 -3
- package/src/http/HttpClient.ts +19 -7
- package/src/http/HttpClientError.ts +42 -9
- package/src/http/HttpClientRequest.ts +51 -0
- package/src/http/HttpClientResponse.ts +156 -0
- package/src/http/HttpEffect.ts +23 -3
- package/src/http/HttpMiddleware.ts +1 -1
- package/src/http/HttpServerError.ts +1 -1
- package/src/http/HttpServerResponse.ts +126 -0
- package/src/http/Multipart.ts +0 -5
- package/src/http/MultipartParser/internal/contentType.ts +1 -1
- package/src/http/internal/clientPath.ts +39 -0
- package/src/http/internal/redactedPath.ts +4 -0
- package/src/http/internal/tracing.ts +6 -3
- package/src/http-api/HttpApi.ts +29 -8
- package/src/http-api/HttpApiBuilder.ts +7 -2
- package/src/http-api/HttpApiClient.ts +30 -7
- package/src/http-api/internal/redactedKeys.ts +40 -0
- package/src/internal/base64.ts +57 -2
- package/src/internal/core.ts +80 -44
- package/src/internal/dateTime.ts +43 -24
- package/src/internal/effect.ts +115 -157
- package/src/internal/equal.ts +73 -17
- package/src/internal/fiberCachedKeys.ts +81 -0
- package/src/internal/hashMap.ts +1 -1
- package/src/internal/matcher.ts +34 -113
- package/src/internal/predicate.ts +10 -0
- package/src/internal/references.ts +21 -14
- package/src/internal/schema/schemaCodegen.ts +5 -4
- package/src/internal/schema/schemaCodegenBuiltIns.ts +343 -0
- package/src/internal/schema/toEquivalence.ts +3 -5
- package/src/internal/version.ts +1 -1
- package/src/jose/JoseError.ts +34 -0
- package/src/jose/internal/compact.ts +14 -5
- package/src/observability/Otlp.ts +29 -0
- package/src/observability/OtlpExporter.ts +206 -75
- package/src/observability/OtlpLogger.ts +24 -2
- package/src/observability/OtlpMetrics.ts +2 -0
- package/src/observability/OtlpTracer.ts +24 -3
- package/src/persistence/KeyValueStore.ts +17 -14
- package/src/reactivity/Atom.ts +12 -18
- package/src/rpc/RpcClient.ts +26 -1
- package/src/rpc/RpcGroup.ts +4 -1
- package/src/sql/Migrator.ts +2 -11
- package/src/sql/SqlClient.ts +14 -8
- package/src/sql/Statement.ts +48 -12
- package/src/workers/Worker.ts +25 -0
- package/src/workflow/Activity.ts +28 -4
- package/src/workflow/Workflow.ts +68 -44
- package/src/workflow/WorkflowEngine.ts +38 -15
- package/src/workflow/internal/retry.ts +12 -0
- package/src/workflow/internal/scope.ts +36 -0
- package/dist/internal/hash.d.ts +0 -2
- package/dist/internal/hash.d.ts.map +0 -1
- package/dist/internal/hash.js +0 -11
- package/dist/internal/hash.js.map +0 -1
- package/dist/internal/metric.d.ts +0 -2
- package/dist/internal/metric.d.ts.map +0 -1
- package/dist/internal/metric.js +0 -3
- package/dist/internal/metric.js.map +0 -1
- package/src/internal/hash.ts +0 -11
- package/src/internal/metric.ts +0 -2
package/src/ai/McpServer.ts
CHANGED
|
@@ -97,6 +97,7 @@ import type {
|
|
|
97
97
|
ServerCapabilities
|
|
98
98
|
} from "./McpSchema.ts"
|
|
99
99
|
import * as AiPrompt from "./Prompt.ts"
|
|
100
|
+
import * as Skill from "./Skill.ts"
|
|
100
101
|
import * as Tool from "./Tool.ts"
|
|
101
102
|
import * as Toolkit from "./Toolkit.ts"
|
|
102
103
|
|
|
@@ -1101,6 +1102,7 @@ export class McpServer extends Context.Service<McpServer, {
|
|
|
1101
1102
|
*/
|
|
1102
1103
|
static readonly make = Effect.gen(function*() {
|
|
1103
1104
|
const internalCore = yield* McpCore.make
|
|
1105
|
+
const toolIndex = new Map<string, number>()
|
|
1104
1106
|
const tools = Arr.empty<{
|
|
1105
1107
|
readonly tool: McpTool
|
|
1106
1108
|
readonly annotations: Context.Context<never>
|
|
@@ -1244,18 +1246,20 @@ export class McpServer extends Context.Service<McpServer, {
|
|
|
1244
1246
|
return tools
|
|
1245
1247
|
},
|
|
1246
1248
|
addTool: Effect.fnUntraced(function*(options) {
|
|
1247
|
-
const existingIndex =
|
|
1248
|
-
if (existingIndex ===
|
|
1249
|
+
const existingIndex = toolIndex.get(options.tool.name)
|
|
1250
|
+
if (existingIndex === undefined) {
|
|
1251
|
+
toolIndex.set(options.tool.name, tools.length)
|
|
1249
1252
|
tools.push(options)
|
|
1250
1253
|
} else {
|
|
1251
1254
|
tools[existingIndex] = options
|
|
1252
1255
|
}
|
|
1253
1256
|
const { invoke, visible } = makeInvoke(options.services, globalMiddleware)
|
|
1257
|
+
const title = options.tool.title ?? options.tool.annotations?.title
|
|
1254
1258
|
yield* internalCore.tools.register({
|
|
1255
|
-
descriptor
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
+
// Reuse a validated descriptor whose title is already resolved.
|
|
1260
|
+
descriptor: options.tool instanceof McpTool && title === options.tool.title
|
|
1261
|
+
? options.tool
|
|
1262
|
+
: new McpTool({ ...options.tool, title }),
|
|
1259
1263
|
visible: visible("tools/list", options.tool.name),
|
|
1260
1264
|
isVisible: isEnabled(options.annotations),
|
|
1261
1265
|
handle: (call, invocation, beforeHandle) =>
|
|
@@ -1537,6 +1541,7 @@ const requestSpanOptions = (
|
|
|
1537
1541
|
readonly networkTransport: string | undefined
|
|
1538
1542
|
readonly sessionId: string | undefined
|
|
1539
1543
|
readonly recordToolArguments: boolean
|
|
1544
|
+
readonly server: McpServer["Service"]
|
|
1540
1545
|
}
|
|
1541
1546
|
): Tracer.SpanOptionsNoTrace & { readonly name: string } => {
|
|
1542
1547
|
const params = Predicate.isReadonlyObject(request.payload)
|
|
@@ -1553,18 +1558,20 @@ const requestSpanOptions = (
|
|
|
1553
1558
|
switch (method) {
|
|
1554
1559
|
case "tools/call": {
|
|
1555
1560
|
attributes["gen_ai.operation.name"] = "execute_tool"
|
|
1556
|
-
|
|
1557
|
-
|
|
1561
|
+
const registered = options.server.tools.find(({ tool }) => tool.name === params?.name)
|
|
1562
|
+
if (registered !== undefined) {
|
|
1563
|
+
target = registered.tool.name
|
|
1558
1564
|
attributes["gen_ai.tool.name"] = target
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1565
|
+
if (options.recordToolArguments && params?.arguments !== undefined) {
|
|
1566
|
+
attributes["gen_ai.tool.call.arguments"] = Toolkit.stringifyToolArguments(params.arguments)
|
|
1567
|
+
}
|
|
1562
1568
|
}
|
|
1563
1569
|
break
|
|
1564
1570
|
}
|
|
1565
1571
|
case "prompts/get": {
|
|
1566
|
-
|
|
1567
|
-
|
|
1572
|
+
const registered = options.server.prompts.find(({ prompt }) => prompt.name === params?.name)
|
|
1573
|
+
if (registered !== undefined) {
|
|
1574
|
+
target = registered.prompt.name
|
|
1568
1575
|
attributes["gen_ai.prompt.name"] = target
|
|
1569
1576
|
}
|
|
1570
1577
|
break
|
|
@@ -1572,8 +1579,9 @@ const requestSpanOptions = (
|
|
|
1572
1579
|
case "resources/read":
|
|
1573
1580
|
case "resources/subscribe":
|
|
1574
1581
|
case "resources/unsubscribe": {
|
|
1575
|
-
// Resource URIs
|
|
1576
|
-
|
|
1582
|
+
// Resource URIs stay out of span names; only registered static URIs are bounded enough to record.
|
|
1583
|
+
const registered = options.server.resources.find(({ resource }) => resource.uri === params?.uri)
|
|
1584
|
+
if (registered !== undefined) attributes["mcp.resource.uri"] = registered.resource.uri
|
|
1577
1585
|
break
|
|
1578
1586
|
}
|
|
1579
1587
|
}
|
|
@@ -1722,11 +1730,12 @@ const normalizeCacheHints = (
|
|
|
1722
1730
|
*
|
|
1723
1731
|
* Each request handled by the server runs in a server span that follows the
|
|
1724
1732
|
* OpenTelemetry MCP semantic conventions. Spans are named after the JSON-RPC
|
|
1725
|
-
* method, with the tool or prompt name appended for `tools/call`
|
|
1726
|
-
* `prompts/get` (for example `tools/call get_weather`).
|
|
1727
|
-
* `
|
|
1728
|
-
*
|
|
1729
|
-
*
|
|
1733
|
+
* method, with the tool or prompt name appended for registered `tools/call`
|
|
1734
|
+
* and `prompts/get` targets (for example `tools/call get_weather`).
|
|
1735
|
+
* `mcp.resource.uri` is recorded only for registered static resources. A W3C
|
|
1736
|
+
* `traceparent` in `params._meta` becomes the span's parent, and the transport
|
|
1737
|
+
* span (such as the HTTP server span) is linked. Tool arguments are recorded
|
|
1738
|
+
* only for registered tools when `Toolkit.RecordToolArguments` is `true`.
|
|
1730
1739
|
*
|
|
1731
1740
|
* @stability unstable
|
|
1732
1741
|
* @category running
|
|
@@ -1805,7 +1814,8 @@ const runWithRuntime = Effect.fnUntraced(function*(
|
|
|
1805
1814
|
sessionId: isHttp
|
|
1806
1815
|
? Context.getOrUndefined(fiber.context, HttpServerRequest.HttpServerRequest)?.headers[MCP_SESSION_ID_HEADER]
|
|
1807
1816
|
: undefined,
|
|
1808
|
-
recordToolArguments: fiber.getRef(Toolkit.RecordToolArguments)
|
|
1817
|
+
recordToolArguments: fiber.getRef(Toolkit.RecordToolArguments),
|
|
1818
|
+
server
|
|
1809
1819
|
})
|
|
1810
1820
|
const ambientParent = Context.getOrUndefined(fiber.context, Tracer.ParentSpan)
|
|
1811
1821
|
return Effect.flatMap(
|
|
@@ -3004,12 +3014,19 @@ const addMcpHttpRoutes = Effect.fnUntraced(function*(
|
|
|
3004
3014
|
const router = yield* HttpRouter.HttpRouter
|
|
3005
3015
|
const allowSessionTermination = options.allowSessionTermination === true &&
|
|
3006
3016
|
runtime.protocols.some((protocol) => protocol.runtime._tag === "Stateful")
|
|
3007
|
-
const
|
|
3008
|
-
const
|
|
3009
|
-
|
|
3017
|
+
const unsupportedContentType = Effect.succeed(mcpTransportRejection(415, "Content-Type must be application/json"))
|
|
3018
|
+
const notAcceptable = Effect.succeed(
|
|
3019
|
+
mcpTransportRejection(406, "Accept header must include both application/json and text/event-stream")
|
|
3020
|
+
)
|
|
3021
|
+
const withAllowedOrigin = <R>(
|
|
3022
|
+
handler: (
|
|
3023
|
+
request: HttpServerRequest.HttpServerRequest
|
|
3024
|
+
) => Effect.Effect<HttpServerResponse.HttpServerResponse, never, R>
|
|
3010
3025
|
) =>
|
|
3011
3026
|
(request: HttpServerRequest.HttpServerRequest) =>
|
|
3012
|
-
isAllowedMcpOrigin(request, options.allowedOrigins)
|
|
3027
|
+
isAllowedMcpOrigin(request, options.allowedOrigins)
|
|
3028
|
+
? handler(request)
|
|
3029
|
+
: Effect.succeed(mcpTransportRejection(403, `Origin '${request.headers["origin"]}' is not allowed`))
|
|
3013
3030
|
const methodNotAllowedResponse = Effect.succeed(HttpServerResponse.empty({
|
|
3014
3031
|
status: 405,
|
|
3015
3032
|
headers: { allow: allowSessionTermination ? "POST, DELETE" : "POST" }
|
|
@@ -3025,51 +3042,52 @@ const addMcpHttpRoutes = Effect.fnUntraced(function*(
|
|
|
3025
3042
|
? withAllowedOrigin((request) => runtime.terminateHttpSession(request.headers))
|
|
3026
3043
|
: methodNotAllowed
|
|
3027
3044
|
)
|
|
3028
|
-
yield* router.add(
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
}
|
|
3035
|
-
const accepted = mcpMediaTypes(request.headers["accept"])
|
|
3036
|
-
if (!accepted.includes("application/json") || !accepted.includes("text/event-stream")) {
|
|
3037
|
-
return Effect.succeed(HttpServerResponse.empty({ status: 406 }))
|
|
3038
|
-
}
|
|
3039
|
-
return Effect.gen(function*() {
|
|
3040
|
-
const parsed = yield* Effect.result(
|
|
3041
|
-
Effect.flatMap(request.text, Schema.decodeEffect(Schema.UnknownFromJsonString))
|
|
3042
|
-
)
|
|
3043
|
-
const admission = runtime.admitHttp(request.headers, parsed)
|
|
3044
|
-
if (admission._tag === "Rejected") {
|
|
3045
|
-
return admission.response
|
|
3045
|
+
yield* router.add(
|
|
3046
|
+
"POST",
|
|
3047
|
+
options.path,
|
|
3048
|
+
withAllowedOrigin((request) => {
|
|
3049
|
+
if (mcpMediaTypes(request.headers["content-type"])[0] !== "application/json") {
|
|
3050
|
+
return unsupportedContentType
|
|
3046
3051
|
}
|
|
3047
|
-
const
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
response.body.body.subarray(0, -1).includes(10)
|
|
3051
|
-
return admission.isSubscription || response.body._tag === "Stream" || hasMultipleMessages
|
|
3052
|
-
? toServerSentEvents(response, admission.isSubscription)
|
|
3053
|
-
: response
|
|
3052
|
+
const accepted = mcpMediaTypes(request.headers["accept"])
|
|
3053
|
+
if (!accepted.includes("application/json") || !accepted.includes("text/event-stream")) {
|
|
3054
|
+
return notAcceptable
|
|
3054
3055
|
}
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
Effect.
|
|
3058
|
-
() => Effect.succeed(HttpServerResponse.empty({ status: 202 }))
|
|
3056
|
+
return Effect.gen(function*() {
|
|
3057
|
+
const parsed = yield* Effect.result(
|
|
3058
|
+
Effect.flatMap(request.text, Schema.decodeEffect(Schema.UnknownFromJsonString))
|
|
3059
3059
|
)
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3060
|
+
const admission = runtime.admitHttp(request.headers, parsed)
|
|
3061
|
+
if (admission._tag === "Rejected") {
|
|
3062
|
+
return admission.response
|
|
3063
|
+
}
|
|
3064
|
+
const toResponse = (response: HttpServerResponse.HttpServerResponse) => {
|
|
3065
|
+
// Completed responses may already contain notifications followed by the result.
|
|
3066
|
+
const hasMultipleMessages = response.body._tag === "Uint8Array" &&
|
|
3067
|
+
response.body.body.subarray(0, -1).includes(10)
|
|
3068
|
+
return admission.isSubscription || response.body._tag === "Stream" || hasMultipleMessages
|
|
3069
|
+
? toServerSentEvents(response, admission.isSubscription)
|
|
3070
|
+
: response
|
|
3071
|
+
}
|
|
3072
|
+
if (admission.acknowledge) {
|
|
3073
|
+
return yield* Effect.catchCause(
|
|
3074
|
+
Effect.map(httpEffect, toResponse),
|
|
3075
|
+
() => Effect.succeed(HttpServerResponse.empty({ status: 202 }))
|
|
3076
|
+
)
|
|
3064
3077
|
}
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3078
|
+
return yield* Effect.flatMap(httpEffect, (response) => {
|
|
3079
|
+
if (response.body._tag !== "Uint8Array" || response.body.body.length > 0) {
|
|
3080
|
+
return Effect.succeed(toResponse(response))
|
|
3081
|
+
}
|
|
3082
|
+
// Only fully cancelled request POSTs may return an empty SSE response.
|
|
3083
|
+
// https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#sending-messages-to-the-server
|
|
3084
|
+
return httpPostResponses.get(request)?.expected === 0
|
|
3085
|
+
? Effect.succeed(HttpServerResponse.stream(Stream.empty, { contentType: "text/event-stream" }))
|
|
3086
|
+
: Effect.die(new Error("MCP request ended without writing its response"))
|
|
3087
|
+
})
|
|
3070
3088
|
})
|
|
3071
3089
|
})
|
|
3072
|
-
|
|
3090
|
+
)
|
|
3073
3091
|
})
|
|
3074
3092
|
|
|
3075
3093
|
const mcpHttpSerialization: RpcSerialization.RpcSerialization["Service"] = (() => {
|
|
@@ -3192,6 +3210,9 @@ const isAllowedMcpOrigin = (
|
|
|
3192
3210
|
return origin === undefined || (allowedOrigins ?? []).includes(origin)
|
|
3193
3211
|
}
|
|
3194
3212
|
|
|
3213
|
+
const mcpTransportRejection = (status: 403 | 406 | 415, message: string): HttpServerResponse.HttpServerResponse =>
|
|
3214
|
+
McpRuntime.jsonRpcError(status, { code: McpSchema.INVALID_REQUEST_ERROR_CODE, message })
|
|
3215
|
+
|
|
3195
3216
|
const mcpMediaTypes = (header: string | undefined): ReadonlyArray<string> =>
|
|
3196
3217
|
header === undefined
|
|
3197
3218
|
? []
|
|
@@ -3422,6 +3443,9 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>, Names ext
|
|
|
3422
3443
|
if (origin === "parameters" && isParameterValidationError(error)) {
|
|
3423
3444
|
return Effect.fail(new InvalidParams({ message: error.reason.message }))
|
|
3424
3445
|
}
|
|
3446
|
+
if (origin === "handler" && isInvalidParams(error)) {
|
|
3447
|
+
return Effect.fail(error)
|
|
3448
|
+
}
|
|
3425
3449
|
if (origin === "handler" && isDeclaredFailure(error)) {
|
|
3426
3450
|
return Effect.catchCause(declaredFailureResult(error), internalToolError)
|
|
3427
3451
|
}
|
|
@@ -3430,40 +3454,48 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>, Names ext
|
|
|
3430
3454
|
}
|
|
3431
3455
|
const content = options?.content
|
|
3432
3456
|
const mapper = content && Object.hasOwn(content, tool.name) ? content[tool.name as Names] : undefined
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
rawJsonSchema ?? toolJsonSchema(tool.parametersSchema, strict)
|
|
3438
|
-
).pipe(
|
|
3439
|
-
Effect.catchTag("SchemaError", (error) =>
|
|
3457
|
+
// Decoding copies a caller-owned raw schema, so later mutation does not change the descriptor.
|
|
3458
|
+
const inputSchema = rawJsonSchema === undefined
|
|
3459
|
+
? toolJsonSchema(tool.parametersSchema, strict)
|
|
3460
|
+
: yield* Effect.catch(Schema.decodeUnknownEffect(ToolJson)(rawJsonSchema), (cause) =>
|
|
3440
3461
|
Effect.die(
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
`(type: "object").\n\n${error.message}`
|
|
3444
|
-
: `McpServer cannot register tool '${tool.name}': its parameters must encode to a JSON Schema with an ` +
|
|
3445
|
-
`object root (type: "object"), such as a Schema.Struct. Use Tool.EmptyParams for a tool without ` +
|
|
3446
|
-
`parameters.\n\n${error.message}`
|
|
3462
|
+
`McpServer cannot register tool '${tool.name}': its raw JSON Schema must have an object root ` +
|
|
3463
|
+
`(type: "object").\n\n${cause.message}`
|
|
3447
3464
|
))
|
|
3448
|
-
)
|
|
3465
|
+
const title = Context.getOrUndefined(tool.annotations, Tool.Title)
|
|
3449
3466
|
const readOnlyHint = Context.get(tool.annotations, Tool.Readonly)
|
|
3450
|
-
const
|
|
3467
|
+
const fields = {
|
|
3451
3468
|
name: tool.name,
|
|
3469
|
+
title,
|
|
3452
3470
|
description: Tool.getDescription(tool),
|
|
3453
|
-
inputSchema,
|
|
3454
|
-
outputSchema,
|
|
3471
|
+
inputSchema: inputSchema as McpSchema.ToolJson,
|
|
3472
|
+
outputSchema: mapper ? undefined : toolJsonSchema(tool.successSchema, false),
|
|
3455
3473
|
annotations: {
|
|
3456
|
-
...(
|
|
3457
|
-
Option.map((title) => ({ title })),
|
|
3458
|
-
Option.getOrUndefined
|
|
3459
|
-
)),
|
|
3474
|
+
...(title !== undefined ? { title } : undefined),
|
|
3460
3475
|
readOnlyHint,
|
|
3461
3476
|
destructiveHint: Context.getOrUndefined(tool.annotations, Tool.Destructive) ?? !readOnlyHint,
|
|
3462
3477
|
idempotentHint: Context.get(tool.annotations, Tool.Idempotent),
|
|
3463
3478
|
openWorldHint: Context.get(tool.annotations, Tool.OpenWorld)
|
|
3464
3479
|
},
|
|
3465
|
-
_meta: toolMeta
|
|
3466
|
-
}
|
|
3480
|
+
_meta: Predicate.isReadonlyObject(toolMeta) ? { ...toolMeta } : toolMeta
|
|
3481
|
+
}
|
|
3482
|
+
let mcpTool: McpTool
|
|
3483
|
+
if (isValidTool(fields)) {
|
|
3484
|
+
mcpTool = Schema.makeClassTrusted(McpTool, fields)
|
|
3485
|
+
} else {
|
|
3486
|
+
try {
|
|
3487
|
+
mcpTool = new McpTool(fields)
|
|
3488
|
+
} catch (error) {
|
|
3489
|
+
// Name the tool when the input schema lacks an object root; rethrow anything else.
|
|
3490
|
+
yield* Effect.catch(Schema.decodeUnknownEffect(ToolJson)(inputSchema), (cause) =>
|
|
3491
|
+
Effect.die(
|
|
3492
|
+
`McpServer cannot register tool '${tool.name}': its parameters must encode to a JSON Schema with an ` +
|
|
3493
|
+
`object root (type: "object"), such as a Schema.Struct. Use Tool.EmptyParams for a tool without ` +
|
|
3494
|
+
`parameters.\n\n${cause.message}`
|
|
3495
|
+
))
|
|
3496
|
+
throw error
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3467
3499
|
registrations.push({
|
|
3468
3500
|
tool: mcpTool,
|
|
3469
3501
|
annotations,
|
|
@@ -3527,11 +3559,50 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>, Names ext
|
|
|
3527
3559
|
}
|
|
3528
3560
|
})
|
|
3529
3561
|
|
|
3562
|
+
const isInvalidParams = Schema.is(InvalidParams)
|
|
3563
|
+
|
|
3530
3564
|
const isParameterValidationError = (
|
|
3531
3565
|
error: unknown
|
|
3532
3566
|
): error is AiError.AiError & { readonly reason: AiError.ToolParameterValidationError } =>
|
|
3533
3567
|
AiError.isAiError(error) && error.reason._tag === "ToolParameterValidationError"
|
|
3534
3568
|
|
|
3569
|
+
// Shallow check of the `McpTool` fields `registerToolkit` sets. Passing descriptors
|
|
3570
|
+
// skip schema validation; the rest go through the checked constructor.
|
|
3571
|
+
const isValidTool = (fields: {
|
|
3572
|
+
readonly name: unknown
|
|
3573
|
+
readonly title: unknown
|
|
3574
|
+
readonly description: unknown
|
|
3575
|
+
readonly inputSchema: unknown
|
|
3576
|
+
readonly outputSchema: unknown
|
|
3577
|
+
readonly annotations: { readonly [x: string]: unknown }
|
|
3578
|
+
readonly _meta: unknown
|
|
3579
|
+
}): boolean => {
|
|
3580
|
+
const { annotations, inputSchema } = fields
|
|
3581
|
+
if (!Predicate.isReadonlyObject(inputSchema)) return false
|
|
3582
|
+
const { properties, required } = inputSchema
|
|
3583
|
+
return typeof fields.name === "string" &&
|
|
3584
|
+
(fields.title === undefined || typeof fields.title === "string") &&
|
|
3585
|
+
(fields.description === undefined || typeof fields.description === "string") &&
|
|
3586
|
+
inputSchema.type === "object" &&
|
|
3587
|
+
(properties === undefined || (Predicate.isReadonlyObject(properties) &&
|
|
3588
|
+
Object.values(properties).every((value) => typeof value === "boolean" || Predicate.isReadonlyObject(value)))) &&
|
|
3589
|
+
(required === undefined || (Array.isArray(required) && isStringArray(required))) &&
|
|
3590
|
+
(fields.outputSchema === undefined || Predicate.isReadonlyObject(fields.outputSchema)) &&
|
|
3591
|
+
typeof annotations.readOnlyHint === "boolean" &&
|
|
3592
|
+
typeof annotations.destructiveHint === "boolean" &&
|
|
3593
|
+
typeof annotations.idempotentHint === "boolean" &&
|
|
3594
|
+
typeof annotations.openWorldHint === "boolean" &&
|
|
3595
|
+
(fields._meta === undefined || Predicate.isReadonlyObject(fields._meta))
|
|
3596
|
+
}
|
|
3597
|
+
|
|
3598
|
+
// Unlike `Array.prototype.every`, this also rejects holes in sparse arrays.
|
|
3599
|
+
const isStringArray = (array: ReadonlyArray<unknown>): boolean => {
|
|
3600
|
+
for (let i = 0; i < array.length; i++) {
|
|
3601
|
+
if (typeof array[i] !== "string") return false
|
|
3602
|
+
}
|
|
3603
|
+
return true
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3535
3606
|
// MCP requires an object root. A non-recursive root is compiled inline rather
|
|
3536
3607
|
// than as a definition; a recursive root keeps its definition and the top-level
|
|
3537
3608
|
// `$ref` is inlined.
|
|
@@ -4011,6 +4082,16 @@ export interface SkillOptions {
|
|
|
4011
4082
|
readonly annotations?: Context.Context<never> | undefined
|
|
4012
4083
|
}
|
|
4013
4084
|
|
|
4085
|
+
/**
|
|
4086
|
+
* Options for registering a {@link Skill.Skill} with {@link registerSkill} or
|
|
4087
|
+
* {@link skill}: {@link SkillOptions} without `files`, which come from the skill.
|
|
4088
|
+
*
|
|
4089
|
+
* @stability unstable
|
|
4090
|
+
* @category models
|
|
4091
|
+
* @since 4.1.6
|
|
4092
|
+
*/
|
|
4093
|
+
export type SkillRegistration = Omit<SkillOptions, "files">
|
|
4094
|
+
|
|
4014
4095
|
const skillFileEncoder = new TextEncoder()
|
|
4015
4096
|
|
|
4016
4097
|
// Bytes are copied so that later changes by the caller cannot alter what is
|
|
@@ -4025,6 +4106,9 @@ const toSkillSourceFile = (path: string, file: SkillFile): McpSkills.SourceFile
|
|
|
4025
4106
|
}
|
|
4026
4107
|
}
|
|
4027
4108
|
|
|
4109
|
+
const toSkillOptions = (skillOrOptions: Skill.Skill | SkillOptions, registration?: SkillRegistration): SkillOptions =>
|
|
4110
|
+
skillOrOptions instanceof Skill.Skill ? { ...registration!, files: Skill.toFiles(skillOrOptions) } : skillOrOptions
|
|
4111
|
+
|
|
4028
4112
|
/**
|
|
4029
4113
|
* Registers an Agent Skill under the MCP Skills extension (SEP-2640).
|
|
4030
4114
|
*
|
|
@@ -4052,8 +4136,68 @@ const toSkillSourceFile = (path: string, file: SkillFile): McpSkills.SourceFile
|
|
|
4052
4136
|
* @category handlers
|
|
4053
4137
|
* @since 4.1.1
|
|
4054
4138
|
*/
|
|
4055
|
-
export const registerSkill:
|
|
4056
|
-
|
|
4139
|
+
export const registerSkill: {
|
|
4140
|
+
/**
|
|
4141
|
+
* Registers an Agent Skill under the MCP Skills extension (SEP-2640).
|
|
4142
|
+
*
|
|
4143
|
+
* **Details**
|
|
4144
|
+
*
|
|
4145
|
+
* Each file is registered as a resource, and the skill is listed by
|
|
4146
|
+
* `skills/list` and `skills/get` with a manifest of every file's SHA-256
|
|
4147
|
+
* digest and size, computed from the bytes served. Every directory of the
|
|
4148
|
+
* skill namespace is readable with `resources/directory/read`. The server
|
|
4149
|
+
* declares the extension once any skill is registered.
|
|
4150
|
+
*
|
|
4151
|
+
* Fails when the skill breaks the extension's rules: a name that does not
|
|
4152
|
+
* match the URI, a `SKILL.md` without YAML frontmatter, frontmatter that is
|
|
4153
|
+
* not valid {@link McpSchema.SkillFrontmatter}, a file path that leaves the
|
|
4154
|
+
* skill, or more than 512 files or 16 MiB in all. It also fails when the
|
|
4155
|
+
* skill's directory contains or lies inside another skill's, or one of its
|
|
4156
|
+
* files is already registered as a resource. Registering a resource at the
|
|
4157
|
+
* URI of a skill's file afterwards is a defect.
|
|
4158
|
+
*
|
|
4159
|
+
* SHA-256 runs on `crypto.subtle`.
|
|
4160
|
+
*
|
|
4161
|
+
* @see {@link skill} for the layer-based skill registration wrapper
|
|
4162
|
+
*
|
|
4163
|
+
* @stability unstable
|
|
4164
|
+
* @category handlers
|
|
4165
|
+
* @since 4.1.1
|
|
4166
|
+
*/
|
|
4167
|
+
(skill: Skill.Skill, options: SkillRegistration): Effect.Effect<void, Cause.IllegalArgumentError, McpServer>
|
|
4168
|
+
/**
|
|
4169
|
+
* Registers an Agent Skill under the MCP Skills extension (SEP-2640).
|
|
4170
|
+
*
|
|
4171
|
+
* **Details**
|
|
4172
|
+
*
|
|
4173
|
+
* Each file is registered as a resource, and the skill is listed by
|
|
4174
|
+
* `skills/list` and `skills/get` with a manifest of every file's SHA-256
|
|
4175
|
+
* digest and size, computed from the bytes served. Every directory of the
|
|
4176
|
+
* skill namespace is readable with `resources/directory/read`. The server
|
|
4177
|
+
* declares the extension once any skill is registered.
|
|
4178
|
+
*
|
|
4179
|
+
* Fails when the skill breaks the extension's rules: a name that does not
|
|
4180
|
+
* match the URI, a `SKILL.md` without YAML frontmatter, frontmatter that is
|
|
4181
|
+
* not valid {@link McpSchema.SkillFrontmatter}, a file path that leaves the
|
|
4182
|
+
* skill, or more than 512 files or 16 MiB in all. It also fails when the
|
|
4183
|
+
* skill's directory contains or lies inside another skill's, or one of its
|
|
4184
|
+
* files is already registered as a resource. Registering a resource at the
|
|
4185
|
+
* URI of a skill's file afterwards is a defect.
|
|
4186
|
+
*
|
|
4187
|
+
* SHA-256 runs on `crypto.subtle`.
|
|
4188
|
+
*
|
|
4189
|
+
* @see {@link skill} for the layer-based skill registration wrapper
|
|
4190
|
+
*
|
|
4191
|
+
* @stability unstable
|
|
4192
|
+
* @category handlers
|
|
4193
|
+
* @since 4.1.1
|
|
4194
|
+
*/
|
|
4195
|
+
(options: SkillOptions): Effect.Effect<void, Cause.IllegalArgumentError, McpServer>
|
|
4196
|
+
} = (skillOrOptions: Skill.Skill | SkillOptions, registration?: SkillRegistration) =>
|
|
4197
|
+
registerSkillFiles(toSkillOptions(skillOrOptions, registration))
|
|
4198
|
+
|
|
4199
|
+
const registerSkillFiles: (options: SkillOptions) => Effect.Effect<void, Cause.IllegalArgumentError, McpServer> = Effect
|
|
4200
|
+
.fnUntraced(function*(options: SkillOptions) {
|
|
4057
4201
|
const files = Object.entries(options.files).map(([path, file]) => toSkillSourceFile(path, file))
|
|
4058
4202
|
const skill = yield* McpSkills.makeStaticSkill({ uri: options.uri, files }).pipe(
|
|
4059
4203
|
Effect.provide(Digest.layerWebCrypto)
|
|
@@ -4131,8 +4275,91 @@ export const registerSkill: (options: SkillOptions) => Effect.Effect<void, Cause
|
|
|
4131
4275
|
* @category layers
|
|
4132
4276
|
* @since 4.1.1
|
|
4133
4277
|
*/
|
|
4134
|
-
export const skill
|
|
4135
|
-
|
|
4278
|
+
export const skill: {
|
|
4279
|
+
/**
|
|
4280
|
+
* Creates a layer that registers an Agent Skill under the MCP Skills extension
|
|
4281
|
+
* (SEP-2640).
|
|
4282
|
+
*
|
|
4283
|
+
* **Example** (Publishing a skill with a supporting file)
|
|
4284
|
+
*
|
|
4285
|
+
* ```ts
|
|
4286
|
+
* import { Layer } from "effect"
|
|
4287
|
+
* import { McpProtocol, McpServer } from "effect/ai"
|
|
4288
|
+
*
|
|
4289
|
+
* const RefundsSkill = McpServer.skill({
|
|
4290
|
+
* uri: "skill://billing/refunds/SKILL.md",
|
|
4291
|
+
* files: {
|
|
4292
|
+
* "SKILL.md": `---
|
|
4293
|
+
* name: refunds
|
|
4294
|
+
* description: Process refunds using the billing tools
|
|
4295
|
+
* ---
|
|
4296
|
+
*
|
|
4297
|
+
* Read references/policy.md before issuing a refund.
|
|
4298
|
+
* `,
|
|
4299
|
+
* "references/policy.md": "Refunds above CHF 500 require manager approval.\n"
|
|
4300
|
+
* }
|
|
4301
|
+
* })
|
|
4302
|
+
*
|
|
4303
|
+
* const ServerLayer = RefundsSkill.pipe(
|
|
4304
|
+
* Layer.provide(McpServer.layerHttp({
|
|
4305
|
+
* name: "billing",
|
|
4306
|
+
* version: "1.0.0",
|
|
4307
|
+
* path: "/mcp",
|
|
4308
|
+
* protocols: [McpProtocol.v2026_07_28, McpProtocol.v2025_11_25]
|
|
4309
|
+
* }))
|
|
4310
|
+
* )
|
|
4311
|
+
* ```
|
|
4312
|
+
*
|
|
4313
|
+
* @see {@link registerSkill} for the Effect-level skill registration API
|
|
4314
|
+
*
|
|
4315
|
+
* @stability unstable
|
|
4316
|
+
* @category layers
|
|
4317
|
+
* @since 4.1.1
|
|
4318
|
+
*/
|
|
4319
|
+
(skill: Skill.Skill, options: SkillRegistration): Layer.Layer<never, Cause.IllegalArgumentError, McpServer>
|
|
4320
|
+
/**
|
|
4321
|
+
* Creates a layer that registers an Agent Skill under the MCP Skills extension
|
|
4322
|
+
* (SEP-2640).
|
|
4323
|
+
*
|
|
4324
|
+
* **Example** (Publishing a skill with a supporting file)
|
|
4325
|
+
*
|
|
4326
|
+
* ```ts
|
|
4327
|
+
* import { Layer } from "effect"
|
|
4328
|
+
* import { McpProtocol, McpServer } from "effect/ai"
|
|
4329
|
+
*
|
|
4330
|
+
* const RefundsSkill = McpServer.skill({
|
|
4331
|
+
* uri: "skill://billing/refunds/SKILL.md",
|
|
4332
|
+
* files: {
|
|
4333
|
+
* "SKILL.md": `---
|
|
4334
|
+
* name: refunds
|
|
4335
|
+
* description: Process refunds using the billing tools
|
|
4336
|
+
* ---
|
|
4337
|
+
*
|
|
4338
|
+
* Read references/policy.md before issuing a refund.
|
|
4339
|
+
* `,
|
|
4340
|
+
* "references/policy.md": "Refunds above CHF 500 require manager approval.\n"
|
|
4341
|
+
* }
|
|
4342
|
+
* })
|
|
4343
|
+
*
|
|
4344
|
+
* const ServerLayer = RefundsSkill.pipe(
|
|
4345
|
+
* Layer.provide(McpServer.layerHttp({
|
|
4346
|
+
* name: "billing",
|
|
4347
|
+
* version: "1.0.0",
|
|
4348
|
+
* path: "/mcp",
|
|
4349
|
+
* protocols: [McpProtocol.v2026_07_28, McpProtocol.v2025_11_25]
|
|
4350
|
+
* }))
|
|
4351
|
+
* )
|
|
4352
|
+
* ```
|
|
4353
|
+
*
|
|
4354
|
+
* @see {@link registerSkill} for the Effect-level skill registration API
|
|
4355
|
+
*
|
|
4356
|
+
* @stability unstable
|
|
4357
|
+
* @category layers
|
|
4358
|
+
* @since 4.1.1
|
|
4359
|
+
*/
|
|
4360
|
+
(options: SkillOptions): Layer.Layer<never, Cause.IllegalArgumentError, McpServer>
|
|
4361
|
+
} = (skillOrOptions: Skill.Skill | SkillOptions, registration?: SkillRegistration) =>
|
|
4362
|
+
Layer.effectDiscard(registerSkillFiles(toSkillOptions(skillOrOptions, registration)))
|
|
4136
4363
|
|
|
4137
4364
|
/**
|
|
4138
4365
|
* Registers an MCP prompt from an Effect program.
|
package/src/ai/Prompt.ts
CHANGED
|
@@ -2204,7 +2204,9 @@ const mergeOptions = (left: ProviderOptions, right: ProviderOptions): ProviderOp
|
|
|
2204
2204
|
* reasoning streams into assistant parts, preserving provider metadata as
|
|
2205
2205
|
* prompt options, placing tool calls and approval requests in an assistant
|
|
2206
2206
|
* message, and placing non-preliminary tool results in a tool message using
|
|
2207
|
-
* their encoded results.
|
|
2207
|
+
* their encoded results. Results for tool calls from an earlier message, such
|
|
2208
|
+
* as resolved approvals, are placed in a tool message before the assistant
|
|
2209
|
+
* message.
|
|
2208
2210
|
*
|
|
2209
2211
|
* **Example** (Creating prompts from response parts)
|
|
2210
2212
|
*
|
|
@@ -2248,6 +2250,13 @@ export const fromResponseParts = (parts: ReadonlyArray<Response.AnyPart>): Promp
|
|
|
2248
2250
|
|
|
2249
2251
|
const assistantParts: Array<AssistantMessagePart | undefined> = []
|
|
2250
2252
|
const toolParts: Array<ToolMessagePart> = []
|
|
2253
|
+
const priorToolParts: Array<ToolMessagePart> = []
|
|
2254
|
+
const toolCallIds = new Set<string>()
|
|
2255
|
+
for (const part of parts) {
|
|
2256
|
+
if (part.type === "tool-call") {
|
|
2257
|
+
toolCallIds.add(part.id)
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2251
2260
|
|
|
2252
2261
|
const activeTextDeltas = new Map<string, { index: number; text: string; options: ProviderOptions }>()
|
|
2253
2262
|
const activeReasoningDeltas = new Map<string, { index: number; text: string; options: ProviderOptions }>()
|
|
@@ -2339,7 +2348,11 @@ export const fromResponseParts = (parts: ReadonlyArray<Response.AnyPart>): Promp
|
|
|
2339
2348
|
// Tool Result Parts (skip preliminary results)
|
|
2340
2349
|
case "tool-result": {
|
|
2341
2350
|
if (part.preliminary !== true) {
|
|
2342
|
-
const target = part.providerExecuted === true
|
|
2351
|
+
const target = part.providerExecuted === true
|
|
2352
|
+
? assistantParts
|
|
2353
|
+
: toolCallIds.has(part.id)
|
|
2354
|
+
? toolParts
|
|
2355
|
+
: priorToolParts
|
|
2343
2356
|
target.push(makePart("tool-result", {
|
|
2344
2357
|
id: part.id,
|
|
2345
2358
|
name: part.name,
|
|
@@ -2374,12 +2387,16 @@ export const fromResponseParts = (parts: ReadonlyArray<Response.AnyPart>): Promp
|
|
|
2374
2387
|
|
|
2375
2388
|
const assistantContent = assistantParts.filter((part) => part !== undefined)
|
|
2376
2389
|
|
|
2377
|
-
if (assistantContent.length === 0 && toolParts.length === 0) {
|
|
2390
|
+
if (assistantContent.length === 0 && toolParts.length === 0 && priorToolParts.length === 0) {
|
|
2378
2391
|
return empty
|
|
2379
2392
|
}
|
|
2380
2393
|
|
|
2381
2394
|
const messages: Array<Message> = []
|
|
2382
2395
|
|
|
2396
|
+
if (priorToolParts.length > 0) {
|
|
2397
|
+
messages.push(makeMessage("tool", { content: priorToolParts }))
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2383
2400
|
if (assistantContent.length > 0) {
|
|
2384
2401
|
messages.push(makeMessage("assistant", { content: assistantContent }))
|
|
2385
2402
|
}
|