effect 4.1.0 → 4.1.2
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/README.md +30 -0
- package/THIRD_PARTY_NOTICES.md +62 -0
- package/ai-docs/package.json +2 -2
- package/dist/BigDecimal.d.ts +139 -7
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +83 -14
- package/dist/BigDecimal.js.map +1 -1
- package/dist/ByteSize.d.ts.map +1 -1
- package/dist/ByteSize.js +27 -14
- package/dist/ByteSize.js.map +1 -1
- package/dist/Equal.d.ts +2 -2
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +3 -3
- package/dist/Equal.js.map +1 -1
- package/dist/Hash.d.ts +3 -2
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +5 -4
- package/dist/Hash.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +38 -32
- 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/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +0 -7
- package/dist/MutableRef.js.map +1 -1
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +5 -1
- package/dist/Path.js.map +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +2 -1
- package/dist/Pool.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/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +8 -3
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +2 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +4 -2
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +4 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +2 -2
- package/dist/SchemaTransformation.js +2 -2
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +6 -5
- package/dist/Stream.js.map +1 -1
- package/dist/ai/McpClient.d.ts +171 -19
- package/dist/ai/McpClient.d.ts.map +1 -1
- package/dist/ai/McpClient.js +277 -66
- package/dist/ai/McpClient.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +108 -0
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpSchema.js +99 -0
- package/dist/ai/McpSchema.js.map +1 -1
- package/dist/ai/McpServer.d.ts +120 -6
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +258 -49
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +20 -11
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +5 -7
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/internal/mcpCore.js +72 -3
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +44 -8
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +12 -0
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +3 -3
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSkills.d.ts +2 -0
- package/dist/ai/internal/mcpSkills.d.ts.map +1 -0
- package/dist/ai/internal/mcpSkills.js +428 -0
- package/dist/ai/internal/mcpSkills.js.map +1 -0
- package/dist/ai/internal/structured-output.js +11 -2
- package/dist/ai/internal/structured-output.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +30 -11
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Entity.d.ts +26 -0
- package/dist/cluster/Entity.d.ts.map +1 -1
- package/dist/cluster/Entity.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +6 -6
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +1 -3
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Reply.d.ts +1 -1
- package/dist/cluster/Reply.d.ts.map +1 -1
- package/dist/cluster/Reply.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 +4 -1
- package/dist/cluster/Sharding.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 +63 -11
- 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/crypto/Aead.d.ts +2 -1
- package/dist/crypto/Aead.d.ts.map +1 -1
- package/dist/crypto/Aead.js +2 -2
- package/dist/crypto/Aead.js.map +1 -1
- package/dist/crypto/Cipher.d.ts +2 -1
- package/dist/crypto/Cipher.d.ts.map +1 -1
- package/dist/crypto/Cipher.js +2 -2
- package/dist/crypto/Cipher.js.map +1 -1
- package/dist/crypto/KeyAgreement.d.ts +3 -2
- package/dist/crypto/KeyAgreement.d.ts.map +1 -1
- package/dist/crypto/KeyAgreement.js +2 -2
- package/dist/crypto/KeyAgreement.js.map +1 -1
- package/dist/crypto/KeyFormat.d.ts +33 -1
- package/dist/crypto/KeyFormat.d.ts.map +1 -1
- package/dist/crypto/KeyFormat.js.map +1 -1
- package/dist/crypto/KeyWrap.d.ts +4 -3
- package/dist/crypto/KeyWrap.d.ts.map +1 -1
- package/dist/crypto/KeyWrap.js +2 -2
- package/dist/crypto/KeyWrap.js.map +1 -1
- package/dist/crypto/Mac.d.ts +2 -1
- package/dist/crypto/Mac.d.ts.map +1 -1
- package/dist/crypto/Mac.js +2 -2
- package/dist/crypto/Mac.js.map +1 -1
- package/dist/crypto/Signature.d.ts +3 -2
- package/dist/crypto/Signature.d.ts.map +1 -1
- package/dist/crypto/Signature.js +2 -2
- package/dist/crypto/Signature.js.map +1 -1
- package/dist/crypto/WebCrypto.d.ts +19 -0
- package/dist/crypto/WebCrypto.d.ts.map +1 -1
- package/dist/crypto/WebCrypto.js.map +1 -1
- package/dist/crypto/internal/asymmetric.js.map +1 -1
- package/dist/crypto/internal/key.js +3 -2
- package/dist/crypto/internal/key.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +26 -3
- package/dist/encoding/Base64Url.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/Ndjson.d.ts +5 -4
- package/dist/encoding/Ndjson.d.ts.map +1 -1
- package/dist/encoding/Ndjson.js +6 -5
- package/dist/encoding/Ndjson.js.map +1 -1
- package/dist/encoding/SchemaBinary.d.ts +94 -0
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +219 -6
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Sse.d.ts +3 -1
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +5 -3
- package/dist/encoding/Sse.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/EventLog.d.ts +7 -0
- package/dist/eventlog/EventLog.d.ts.map +1 -1
- package/dist/eventlog/EventLog.js +7 -0
- package/dist/eventlog/EventLog.js.map +1 -1
- package/dist/eventlog/EventLogServer.d.ts +7 -1
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +55 -24
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.d.ts +10 -0
- package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/EventLogServerUnencrypted.d.ts +17 -0
- package/dist/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerUnencrypted.js +14 -2
- package/dist/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.d.ts +21 -0
- package/dist/eventlog/EventLogSessionAuth.d.ts.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.js +22 -0
- package/dist/eventlog/EventLogSessionAuth.js.map +1 -1
- package/dist/graphql/GraphQLClient.d.ts +3 -1
- package/dist/graphql/GraphQLClient.d.ts.map +1 -1
- package/dist/graphql/GraphQLClient.js.map +1 -1
- package/dist/graphql/GraphQLClientError.d.ts +14 -9
- package/dist/graphql/GraphQLClientError.d.ts.map +1 -1
- package/dist/graphql/GraphQLClientError.js +14 -21
- package/dist/graphql/GraphQLClientError.js.map +1 -1
- package/dist/graphql/GraphQLProtocol.d.ts +12 -3
- package/dist/graphql/GraphQLProtocol.d.ts.map +1 -1
- package/dist/graphql/GraphQLProtocol.js +4 -1
- package/dist/graphql/GraphQLProtocol.js.map +1 -1
- package/dist/http/HttpClient.d.ts +204 -16
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +93 -13
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +38 -22
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/internal/mimeTypes.d.ts +4 -1
- package/dist/http/internal/mimeTypes.d.ts.map +1 -1
- package/dist/http/internal/mimeTypes.js +4 -1
- package/dist/http/internal/mimeTypes.js.map +1 -1
- package/dist/http-api/HttpApiSchema.js +1 -1
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/internal/dateTime.js +66 -27
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +10 -0
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/glob.js +234 -56
- package/dist/internal/glob.js.map +1 -1
- package/dist/internal/graphql.js +21 -7
- package/dist/internal/graphql.js.map +1 -1
- package/dist/internal/graphqlHeaders.d.ts +7 -0
- package/dist/internal/graphqlHeaders.d.ts.map +1 -1
- package/dist/internal/graphqlHeaders.js +11 -0
- package/dist/internal/graphqlHeaders.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/persistence.js +8 -1
- package/dist/internal/persistence.js.map +1 -1
- package/dist/internal/request.js +29 -42
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +7 -8
- package/dist/internal/schema/fromJsonSchemaDocument.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/jose/JoseError.d.ts +285 -0
- package/dist/jose/JoseError.d.ts.map +1 -0
- package/dist/jose/JoseError.js +269 -0
- package/dist/jose/JoseError.js.map +1 -0
- package/dist/jose/Jwe.d.ts +128 -0
- package/dist/jose/Jwe.d.ts.map +1 -0
- package/dist/jose/Jwe.js +134 -0
- package/dist/jose/Jwe.js.map +1 -0
- package/dist/jose/Jwk.d.ts +597 -0
- package/dist/jose/Jwk.d.ts.map +1 -0
- package/dist/jose/Jwk.js +503 -0
- package/dist/jose/Jwk.js.map +1 -0
- package/dist/jose/Jwks.d.ts +236 -0
- package/dist/jose/Jwks.d.ts.map +1 -0
- package/dist/jose/Jwks.js +306 -0
- package/dist/jose/Jwks.js.map +1 -0
- package/dist/jose/Jws.d.ts +177 -0
- package/dist/jose/Jws.d.ts.map +1 -0
- package/dist/jose/Jws.js +183 -0
- package/dist/jose/Jws.js.map +1 -0
- package/dist/jose/Jwt.d.ts +270 -0
- package/dist/jose/Jwt.d.ts.map +1 -0
- package/dist/jose/Jwt.js +293 -0
- package/dist/jose/Jwt.js.map +1 -0
- package/dist/jose/index.d.ts +51 -0
- package/dist/jose/index.d.ts.map +1 -0
- package/dist/jose/index.js +52 -0
- package/dist/jose/index.js.map +1 -0
- package/dist/jose/internal/compact.d.ts +2 -0
- package/dist/jose/internal/compact.d.ts.map +1 -0
- package/dist/jose/internal/compact.js +179 -0
- package/dist/jose/internal/compact.js.map +1 -0
- package/dist/net/Host.d.ts.map +1 -1
- package/dist/net/Host.js +5 -10
- package/dist/net/Host.js.map +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/OtlpSerialization.d.ts +1 -1
- package/dist/observability/OtlpSerialization.d.ts.map +1 -1
- package/dist/observability/OtlpSerialization.js +10 -4
- package/dist/observability/OtlpSerialization.js.map +1 -1
- package/dist/observability/internal/otlpProtobuf.js +3 -3
- package/dist/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/observability/internal/protobuf.js +6 -0
- package/dist/observability/internal/protobuf.js.map +1 -1
- package/dist/persistence/CircuitBreaker.d.ts +98 -38
- package/dist/persistence/CircuitBreaker.d.ts.map +1 -1
- package/dist/persistence/CircuitBreaker.js +67 -29
- package/dist/persistence/CircuitBreaker.js.map +1 -1
- package/dist/persistence/RateLimiter.d.ts +15 -0
- package/dist/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/persistence/RateLimiter.js +76 -16
- package/dist/persistence/RateLimiter.js.map +1 -1
- package/dist/persistence/index.d.ts +1 -1
- package/dist/persistence/index.js +1 -1
- package/dist/reactivity/AtomRegistry.js +17 -7
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/rpc/Rpc.d.ts +1 -1
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +14 -2
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +38 -21
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcMessage.d.ts +3 -2
- package/dist/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/rpc/RpcMessage.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +10 -1
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/sql/Migrator.d.ts +9 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +18 -6
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +46 -3
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +40 -15
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +46 -3
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +32 -26
- package/dist/sql/Statement.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +4 -0
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +5 -0
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +7 -3
- package/src/BigDecimal.ts +170 -16
- package/src/ByteSize.ts +29 -14
- package/src/Equal.ts +3 -3
- package/src/Hash.ts +5 -4
- package/src/Iterable.ts +28 -19
- package/src/JsonSchema.ts +45 -7
- package/src/MutableRef.ts +1 -8
- package/src/Path.ts +6 -1
- package/src/Pool.ts +2 -1
- package/src/Ref.ts +0 -8
- package/src/Schedule.ts +8 -6
- package/src/Schema.ts +3 -2
- package/src/SchemaRepresentation.ts +4 -2
- package/src/SchemaTransformation.ts +2 -2
- package/src/Stream.ts +6 -5
- package/src/ai/McpClient.ts +488 -91
- package/src/ai/McpSchema.ts +119 -0
- package/src/ai/McpServer.ts +302 -56
- package/src/ai/Prompt.ts +16 -11
- package/src/ai/Tool.ts +5 -10
- package/src/ai/internal/mcpCore.ts +165 -12
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +42 -9
- package/src/ai/internal/mcpProtocol.ts +15 -0
- package/src/ai/internal/mcpRuntime.ts +6 -3
- package/src/ai/internal/mcpSkills.ts +480 -0
- package/src/ai/internal/structured-output.ts +10 -4
- package/src/cluster/ClusterWorkflowEngine.ts +48 -33
- package/src/cluster/Entity.ts +52 -0
- package/src/cluster/MessageStorage.ts +3 -6
- package/src/cluster/Reply.ts +1 -1
- package/src/cluster/Runners.ts +16 -2
- package/src/cluster/Sharding.ts +17 -1
- package/src/cluster/internal/clusterAbandon.ts +7 -7
- package/src/cluster/internal/entityManager.ts +89 -15
- package/src/cluster/internal/transactionNotifications.ts +7 -0
- package/src/crypto/Aead.ts +3 -3
- package/src/crypto/Cipher.ts +3 -3
- package/src/crypto/KeyAgreement.ts +4 -4
- package/src/crypto/KeyFormat.ts +30 -1
- package/src/crypto/KeyWrap.ts +6 -6
- package/src/crypto/Mac.ts +3 -3
- package/src/crypto/Signature.ts +4 -4
- package/src/crypto/WebCrypto.ts +20 -0
- package/src/crypto/internal/asymmetric.ts +2 -1
- package/src/crypto/internal/key.ts +12 -5
- package/src/encoding/Base64Url.ts +27 -3
- package/src/encoding/Json5.ts +59 -0
- package/src/encoding/Jsonc.ts +126 -0
- package/src/encoding/Ndjson.ts +6 -5
- package/src/encoding/SchemaBinary.ts +228 -7
- package/src/encoding/Sse.ts +5 -3
- package/src/encoding/index.ts +12 -0
- package/src/eventlog/EventLog.ts +7 -0
- package/src/eventlog/EventLogServer.ts +67 -24
- package/src/eventlog/EventLogServerEncrypted.ts +5 -0
- package/src/eventlog/EventLogServerUnencrypted.ts +19 -2
- package/src/eventlog/EventLogSessionAuth.ts +26 -0
- package/src/graphql/GraphQLClient.ts +3 -1
- package/src/graphql/GraphQLClientError.ts +15 -22
- package/src/graphql/GraphQLProtocol.ts +12 -3
- package/src/http/HttpClient.ts +244 -33
- package/src/http/HttpServerRequest.ts +61 -23
- package/src/http/internal/mimeTypes.ts +4 -1
- package/src/http-api/HttpApiSchema.ts +1 -1
- package/src/internal/dateTime.ts +80 -27
- package/src/internal/effect.ts +6 -0
- package/src/internal/glob.ts +279 -63
- package/src/internal/graphql.ts +27 -9
- package/src/internal/graphqlHeaders.ts +13 -0
- package/src/internal/jsonParser.ts +307 -0
- package/src/internal/persistence.ts +9 -1
- package/src/internal/request.ts +51 -58
- package/src/internal/schema/fromJsonSchemaDocument.ts +11 -10
- package/src/internal/sql.ts +25 -0
- package/src/internal/version.ts +1 -1
- package/src/jose/JoseError.ts +329 -0
- package/src/jose/Jwe.ts +196 -0
- package/src/jose/Jwk.ts +777 -0
- package/src/jose/Jwks.ts +418 -0
- package/src/jose/Jws.ts +312 -0
- package/src/jose/Jwt.ts +493 -0
- package/src/jose/index.ts +58 -0
- package/src/jose/internal/compact.ts +195 -0
- package/src/net/Host.ts +5 -10
- package/src/observability/OtlpExporter.ts +42 -18
- package/src/observability/OtlpSerialization.ts +13 -5
- package/src/observability/internal/otlpProtobuf.ts +6 -6
- package/src/observability/internal/protobuf.ts +10 -0
- package/src/persistence/CircuitBreaker.ts +113 -48
- package/src/persistence/RateLimiter.ts +97 -19
- package/src/persistence/index.ts +1 -1
- package/src/reactivity/AtomRegistry.ts +19 -8
- package/src/rpc/Rpc.ts +3 -1
- package/src/rpc/RpcClient.ts +44 -24
- package/src/rpc/RpcMessage.ts +3 -2
- package/src/rpc/RpcServer.ts +12 -1
- package/src/sql/Migrator.ts +35 -18
- package/src/sql/SqlClient.ts +91 -22
- package/src/sql/Statement.ts +60 -35
- package/src/workflow/Workflow.ts +4 -0
- package/src/workflow/WorkflowEngine.ts +5 -0
package/src/ai/Tool.ts
CHANGED
|
@@ -2096,8 +2096,9 @@ export const getStrictMode = <T extends Any>(tool: T): boolean | undefined => Co
|
|
|
2096
2096
|
//
|
|
2097
2097
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2098
2098
|
|
|
2099
|
-
|
|
2100
|
-
|
|
2099
|
+
// Text that may decode to a forbidden key. `JSON.parse` decodes Unicode
|
|
2100
|
+
// escapes (e.g. `"\u005f_proto__"`), so any `\u` escape also triggers the scan.
|
|
2101
|
+
const suspectRx = /"__proto__"\s*:|"constructor"\s*:|\\u/
|
|
2101
2102
|
|
|
2102
2103
|
function _parse(text: string) {
|
|
2103
2104
|
// Parse normally
|
|
@@ -2108,15 +2109,8 @@ function _parse(text: string) {
|
|
|
2108
2109
|
return obj
|
|
2109
2110
|
}
|
|
2110
2111
|
|
|
2111
|
-
if (
|
|
2112
|
-
suspectProtoRx.test(text) === false &&
|
|
2113
|
-
suspectConstructorRx.test(text) === false
|
|
2114
|
-
) {
|
|
2115
|
-
return obj
|
|
2116
|
-
}
|
|
2117
|
-
|
|
2118
2112
|
// Scan result for proto keys
|
|
2119
|
-
return filter(obj)
|
|
2113
|
+
return suspectRx.test(text) ? filter(obj) : obj
|
|
2120
2114
|
}
|
|
2121
2115
|
|
|
2122
2116
|
function filter(obj: any) {
|
|
@@ -2133,6 +2127,7 @@ function filter(obj: any) {
|
|
|
2133
2127
|
|
|
2134
2128
|
if (
|
|
2135
2129
|
Object.hasOwn(node, "constructor") &&
|
|
2130
|
+
node.constructor !== null &&
|
|
2136
2131
|
Object.hasOwn(node.constructor, "prototype")
|
|
2137
2132
|
) {
|
|
2138
2133
|
throw new SyntaxError("Object contains forbidden prototype property")
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as Arr from "../../Array.ts"
|
|
8
|
+
import * as Cause from "../../Cause.ts"
|
|
8
9
|
import * as Data from "../../Data.ts"
|
|
9
10
|
import * as Effect from "../../Effect.ts"
|
|
10
11
|
import type * as McpProtocol from "../McpProtocol.ts"
|
|
@@ -247,7 +248,8 @@ export interface ResourceTemplateRegistration {
|
|
|
247
248
|
* @internal
|
|
248
249
|
*/
|
|
249
250
|
export interface Resources {
|
|
250
|
-
|
|
251
|
+
// Synchronous, so a caller can check skill ownership and register in one step.
|
|
252
|
+
readonly register: (registration: ResourceRegistration) => void
|
|
251
253
|
readonly registerTemplate: (registration: ResourceTemplateRegistration) => Effect.Effect<void>
|
|
252
254
|
readonly list: (
|
|
253
255
|
invocation: McpInvocation
|
|
@@ -264,6 +266,91 @@ export interface Resources {
|
|
|
264
266
|
>
|
|
265
267
|
}
|
|
266
268
|
|
|
269
|
+
/**
|
|
270
|
+
* A file of a skill, with the digest and size of the bytes it is served as.
|
|
271
|
+
*
|
|
272
|
+
* @internal
|
|
273
|
+
*/
|
|
274
|
+
export interface SkillResource {
|
|
275
|
+
readonly uri: string
|
|
276
|
+
readonly digest: string
|
|
277
|
+
readonly size: number
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* A `skills/list` and `skills/get` entry. `resources` is `"dynamic"` for a
|
|
282
|
+
* skill whose content cannot carry stable digests.
|
|
283
|
+
*
|
|
284
|
+
* @internal
|
|
285
|
+
*/
|
|
286
|
+
export interface Skill {
|
|
287
|
+
readonly uri: string
|
|
288
|
+
readonly frontmatter: Readonly<Record<string, unknown>>
|
|
289
|
+
readonly resources: ReadonlyArray<SkillResource> | "dynamic"
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* A `resources/directory/read` child: a file, with the metadata
|
|
294
|
+
* `resources/list` gives it, or a subdirectory with the `inode/directory` MIME
|
|
295
|
+
* type.
|
|
296
|
+
*
|
|
297
|
+
* @internal
|
|
298
|
+
*/
|
|
299
|
+
export interface DirectoryChild {
|
|
300
|
+
readonly uri: string
|
|
301
|
+
readonly name: string
|
|
302
|
+
readonly description?: string | undefined
|
|
303
|
+
readonly mimeType: string
|
|
304
|
+
readonly size?: number | undefined
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @internal
|
|
309
|
+
*/
|
|
310
|
+
export class SkillNotFound extends Data.TaggedError("SkillNotFound")<{
|
|
311
|
+
readonly uri: string
|
|
312
|
+
}> {}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @internal
|
|
316
|
+
*/
|
|
317
|
+
export class DirectoryNotFound extends Data.TaggedError("DirectoryNotFound")<{
|
|
318
|
+
readonly uri: string
|
|
319
|
+
}> {}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* @internal
|
|
323
|
+
*/
|
|
324
|
+
export interface SkillRegistration {
|
|
325
|
+
readonly entry: Skill
|
|
326
|
+
readonly isVisible: (profile: NegotiatedProtocolProfile<string>) => boolean
|
|
327
|
+
readonly visible?: Visible | undefined
|
|
328
|
+
// Hides the skill's directories on `resources/directory/read`.
|
|
329
|
+
readonly visibleInDirectories?: Visible | undefined
|
|
330
|
+
readonly get: (invocation: McpInvocation) => Effect.Effect<Skill, SkillNotFound | RequestRejected>
|
|
331
|
+
// `undefined` when this skill has no directory at `uri`. Directories shared
|
|
332
|
+
// by several skills, such as a common path prefix, list the union of what
|
|
333
|
+
// each skill returns.
|
|
334
|
+
readonly directory: (uri: string) => ReadonlyArray<DirectoryChild> | undefined
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* @internal
|
|
339
|
+
*/
|
|
340
|
+
export interface Skills {
|
|
341
|
+
// Fails when the skill's directory overlaps another skill's, or one of its
|
|
342
|
+
// files is already registered as a resource.
|
|
343
|
+
readonly register: (registration: SkillRegistration) => Effect.Effect<void, Cause.IllegalArgumentError>
|
|
344
|
+
// Whether `uri` is a file of a registered skill, which only that skill may serve.
|
|
345
|
+
readonly ownsFile: (uri: string) => boolean
|
|
346
|
+
readonly list: (invocation: McpInvocation) => Effect.Effect<ReadonlyArray<Skill>, RequestRejected>
|
|
347
|
+
readonly get: (uri: string, invocation: McpInvocation) => Effect.Effect<Skill, SkillNotFound | RequestRejected>
|
|
348
|
+
readonly readDirectory: (
|
|
349
|
+
uri: string,
|
|
350
|
+
invocation: McpInvocation
|
|
351
|
+
) => Effect.Effect<ReadonlyArray<DirectoryChild>, DirectoryNotFound | RequestRejected>
|
|
352
|
+
}
|
|
353
|
+
|
|
267
354
|
/**
|
|
268
355
|
* @internal
|
|
269
356
|
*/
|
|
@@ -423,10 +510,12 @@ export interface McpCore {
|
|
|
423
510
|
readonly resources: Resources
|
|
424
511
|
readonly prompts: Prompts
|
|
425
512
|
readonly completions: Completions
|
|
513
|
+
readonly skills: Skills
|
|
426
514
|
readonly registrationPresence: Effect.Effect<{
|
|
427
515
|
readonly tools: boolean
|
|
428
516
|
readonly resources: boolean
|
|
429
517
|
readonly prompts: boolean
|
|
518
|
+
readonly skills: boolean
|
|
430
519
|
}>
|
|
431
520
|
}
|
|
432
521
|
|
|
@@ -438,6 +527,13 @@ export interface McpCore {
|
|
|
438
527
|
*/
|
|
439
528
|
export type Visible = (invocation: McpInvocation) => Effect.Effect<boolean, RequestRejected>
|
|
440
529
|
|
|
530
|
+
// Whether one skill directory contains the other, or both are the same.
|
|
531
|
+
const skillsOverlap = (a: string, b: string): boolean => {
|
|
532
|
+
const rootA = a.slice(0, -"/SKILL.md".length)
|
|
533
|
+
const rootB = b.slice(0, -"/SKILL.md".length)
|
|
534
|
+
return rootA === rootB || rootA.startsWith(`${rootB}/`) || rootB.startsWith(`${rootA}/`)
|
|
535
|
+
}
|
|
536
|
+
|
|
441
537
|
/**
|
|
442
538
|
* @internal
|
|
443
539
|
*/
|
|
@@ -446,6 +542,8 @@ export const make: Effect.Effect<McpCore> = Effect.sync(() => {
|
|
|
446
542
|
const resourceRegistrations: Array<ResourceRegistration> = []
|
|
447
543
|
const resourceTemplateRegistrations: Array<ResourceTemplateRegistration> = []
|
|
448
544
|
const promptRegistrations = new Map<string, PromptRegistration>()
|
|
545
|
+
const skillRegistrations = new Map<string, SkillRegistration>()
|
|
546
|
+
const skillFiles = new Set<string>()
|
|
449
547
|
const completionRegistrations = new Map<
|
|
450
548
|
string,
|
|
451
549
|
(
|
|
@@ -494,15 +592,14 @@ export const make: Effect.Effect<McpCore> = Effect.sync(() => {
|
|
|
494
592
|
}
|
|
495
593
|
|
|
496
594
|
const resources: Resources = {
|
|
497
|
-
register: (registration) =>
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}),
|
|
595
|
+
register: (registration) => {
|
|
596
|
+
const index = resourceRegistrations.findIndex((entry) => entry.descriptor.uri === registration.descriptor.uri)
|
|
597
|
+
if (index === -1) {
|
|
598
|
+
resourceRegistrations.push(registration)
|
|
599
|
+
} else {
|
|
600
|
+
resourceRegistrations[index] = registration
|
|
601
|
+
}
|
|
602
|
+
},
|
|
506
603
|
registerTemplate: (registration) =>
|
|
507
604
|
Effect.sync(() => {
|
|
508
605
|
const index = resourceTemplateRegistrations.findIndex(
|
|
@@ -569,11 +666,67 @@ export const make: Effect.Effect<McpCore> = Effect.sync(() => {
|
|
|
569
666
|
})
|
|
570
667
|
}
|
|
571
668
|
|
|
669
|
+
const skills: Skills = {
|
|
670
|
+
register: (registration) =>
|
|
671
|
+
Effect.suspend(() => {
|
|
672
|
+
const { uri, resources } = registration.entry
|
|
673
|
+
const fail = (reason: string) => Effect.fail(new Cause.IllegalArgumentError(`Skill ${uri}: ${reason}`))
|
|
674
|
+
for (const other of skillRegistrations.keys()) {
|
|
675
|
+
if (skillsOverlap(uri, other)) return fail(`its directory overlaps the skill ${other}`)
|
|
676
|
+
}
|
|
677
|
+
const files = resources === "dynamic" ? [] : resources.map((resource) => resource.uri)
|
|
678
|
+
for (const file of files) {
|
|
679
|
+
if (resourceRegistrations.some((entry) => entry.descriptor.uri === file)) {
|
|
680
|
+
return fail(`${file} is already registered as a resource`)
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
skillRegistrations.set(uri, registration)
|
|
684
|
+
for (const file of files) skillFiles.add(file)
|
|
685
|
+
return Effect.void
|
|
686
|
+
}),
|
|
687
|
+
ownsFile: (uri) => skillFiles.has(uri),
|
|
688
|
+
list: (invocation) =>
|
|
689
|
+
filterList(
|
|
690
|
+
Array.from(skillRegistrations.values(), (registration) => ({
|
|
691
|
+
descriptor: registration.entry,
|
|
692
|
+
isVisible: registration.isVisible,
|
|
693
|
+
visible: registration.visible
|
|
694
|
+
})),
|
|
695
|
+
invocation
|
|
696
|
+
),
|
|
697
|
+
get: (uri, invocation) =>
|
|
698
|
+
Effect.suspend(() => {
|
|
699
|
+
const registration = skillRegistrations.get(uri)
|
|
700
|
+
return registration !== undefined && registration.isVisible(invocation.protocol)
|
|
701
|
+
? registration.get(invocation)
|
|
702
|
+
: Effect.fail(new SkillNotFound({ uri }))
|
|
703
|
+
}),
|
|
704
|
+
readDirectory: Effect.fnUntraced(function*(uri, invocation) {
|
|
705
|
+
const children = new Map<string, DirectoryChild>()
|
|
706
|
+
let found = false
|
|
707
|
+
for (const registration of skillRegistrations.values()) {
|
|
708
|
+
const own = registration.directory(uri)
|
|
709
|
+
if (own === undefined || !registration.isVisible(invocation.protocol)) continue
|
|
710
|
+
if (
|
|
711
|
+
registration.visibleInDirectories !== undefined &&
|
|
712
|
+
!(yield* registration.visibleInDirectories(invocation))
|
|
713
|
+
) continue
|
|
714
|
+
found = true
|
|
715
|
+
for (const child of own) children.set(child.uri, child)
|
|
716
|
+
}
|
|
717
|
+
if (!found) {
|
|
718
|
+
return yield* new DirectoryNotFound({ uri })
|
|
719
|
+
}
|
|
720
|
+
return Array.from(children.values()).sort((a, b) => a.uri < b.uri ? -1 : a.uri > b.uri ? 1 : 0)
|
|
721
|
+
})
|
|
722
|
+
}
|
|
723
|
+
|
|
572
724
|
const registrationPresence = Effect.sync(() => ({
|
|
573
725
|
tools: registrations.size > 0,
|
|
574
726
|
resources: resourceRegistrations.length > 0 || resourceTemplateRegistrations.length > 0,
|
|
575
|
-
prompts: promptRegistrations.size > 0
|
|
727
|
+
prompts: promptRegistrations.size > 0,
|
|
728
|
+
skills: skillRegistrations.size > 0
|
|
576
729
|
}))
|
|
577
730
|
|
|
578
|
-
return { tools, resources, prompts, completions, registrationPresence }
|
|
731
|
+
return { tools, resources, prompts, completions, skills, registrationPresence }
|
|
579
732
|
})
|
|
@@ -10,9 +10,10 @@ import * as McpCore from "../mcpCore.ts"
|
|
|
10
10
|
import * as McpProtocol from "../mcpProtocol.ts"
|
|
11
11
|
import * as McpRuntime from "../mcpRuntime.ts"
|
|
12
12
|
import * as McpSchema from "../mcpSchema/v2024_11_05.ts"
|
|
13
|
+
import * as McpSkills from "../mcpSkills.ts"
|
|
13
14
|
|
|
14
15
|
// Pings can arrive before initialize and do not require a client session.
|
|
15
|
-
const ClientRequestRpcs = McpSchema.ClientRequestRpcs.omit("ping").middleware(
|
|
16
|
+
const ClientRequestRpcs = McpSchema.ClientRequestRpcs.omit("ping").merge(McpSkills.LegacyRpcs).middleware(
|
|
16
17
|
PublicMcpSchema.McpServerClientMiddleware
|
|
17
18
|
).add(McpSchema.Ping)
|
|
18
19
|
|
|
@@ -124,6 +125,7 @@ export const protocol = McpProtocol.make({
|
|
|
124
125
|
handlerRpcs: AdapterRpcs,
|
|
125
126
|
makeHandlers: (core, lifecycle) =>
|
|
126
127
|
AdapterRpcs.of({
|
|
128
|
+
...McpSkills.legacyHandlers(core),
|
|
127
129
|
initialize: (request, { client }) =>
|
|
128
130
|
lifecycle.initialize(McpSchema.protocolVersion, profileFromInitialize(request), client.id).pipe(
|
|
129
131
|
Effect.map((result) =>
|
|
@@ -10,9 +10,10 @@ import * as McpCore from "../mcpCore.ts"
|
|
|
10
10
|
import * as McpProtocol from "../mcpProtocol.ts"
|
|
11
11
|
import * as McpRuntime from "../mcpRuntime.ts"
|
|
12
12
|
import * as McpSchema from "../mcpSchema/v2025_03_26.ts"
|
|
13
|
+
import * as McpSkills from "../mcpSkills.ts"
|
|
13
14
|
|
|
14
15
|
// Pings can arrive before initialize and do not require a client session.
|
|
15
|
-
const ClientRequestRpcs = McpSchema.ClientRequestRpcs.omit("ping").middleware(
|
|
16
|
+
const ClientRequestRpcs = McpSchema.ClientRequestRpcs.omit("ping").merge(McpSkills.LegacyRpcs).middleware(
|
|
16
17
|
PublicMcpSchema.McpServerClientMiddleware
|
|
17
18
|
).add(McpSchema.Ping)
|
|
18
19
|
|
|
@@ -127,6 +128,7 @@ export const protocol = McpProtocol.make({
|
|
|
127
128
|
handlerRpcs: AdapterRpcs,
|
|
128
129
|
makeHandlers: (core, lifecycle) =>
|
|
129
130
|
AdapterRpcs.of({
|
|
131
|
+
...McpSkills.legacyHandlers(core),
|
|
130
132
|
initialize: (request, { client }) =>
|
|
131
133
|
lifecycle.initialize(McpSchema.protocolVersion, profileFromInitialize(request), client.id).pipe(
|
|
132
134
|
Effect.map((result) =>
|
|
@@ -9,9 +9,10 @@ import * as McpCore from "../mcpCore.ts"
|
|
|
9
9
|
import * as McpProtocol from "../mcpProtocol.ts"
|
|
10
10
|
import * as McpRuntime from "../mcpRuntime.ts"
|
|
11
11
|
import * as McpSchema from "../mcpSchema/v2025_06_18.ts"
|
|
12
|
+
import * as McpSkills from "../mcpSkills.ts"
|
|
12
13
|
|
|
13
14
|
// Pings can arrive before initialize and do not require a client session.
|
|
14
|
-
const ClientRequestRpcs = McpSchema.ClientRequestRpcs.omit("ping").middleware(
|
|
15
|
+
const ClientRequestRpcs = McpSchema.ClientRequestRpcs.omit("ping").merge(McpSkills.LegacyRpcs).middleware(
|
|
15
16
|
PublicMcpSchema.McpServerClientMiddleware
|
|
16
17
|
).add(McpSchema.Ping)
|
|
17
18
|
|
|
@@ -143,6 +144,7 @@ export const protocol = McpProtocol.make({
|
|
|
143
144
|
handlerRpcs: AdapterRpcs,
|
|
144
145
|
makeHandlers: (core, lifecycle) =>
|
|
145
146
|
AdapterRpcs.of({
|
|
147
|
+
...McpSkills.legacyHandlers(core),
|
|
146
148
|
initialize: (request, { client }) =>
|
|
147
149
|
lifecycle.initialize(McpSchema.protocolVersion, profileFromInitialize(request), client.id).pipe(
|
|
148
150
|
Effect.map((result) =>
|
|
@@ -8,9 +8,10 @@ import * as McpCore from "../mcpCore.ts"
|
|
|
8
8
|
import * as McpProtocol from "../mcpProtocol.ts"
|
|
9
9
|
import * as McpRuntime from "../mcpRuntime.ts"
|
|
10
10
|
import * as McpSchema from "../mcpSchema/v2025_11_25.ts"
|
|
11
|
+
import * as McpSkills from "../mcpSkills.ts"
|
|
11
12
|
|
|
12
13
|
// Pings can arrive before initialize and do not require a client session.
|
|
13
|
-
const ClientRequestRpcs = McpSchema.ClientRequestRpcs.omit("ping").middleware(
|
|
14
|
+
const ClientRequestRpcs = McpSchema.ClientRequestRpcs.omit("ping").merge(McpSkills.LegacyRpcs).middleware(
|
|
14
15
|
PublicMcpSchema.McpServerClientMiddleware
|
|
15
16
|
).add(McpSchema.Ping)
|
|
16
17
|
|
|
@@ -133,6 +134,7 @@ export const protocol = McpProtocol.make({
|
|
|
133
134
|
handlerRpcs: AdapterRpcs,
|
|
134
135
|
makeHandlers: (core, lifecycle) =>
|
|
135
136
|
AdapterRpcs.of({
|
|
137
|
+
...McpSkills.legacyHandlers(core),
|
|
136
138
|
initialize: (request, { client }) =>
|
|
137
139
|
lifecycle.initialize(McpSchema.protocolVersion, {
|
|
138
140
|
protocolVersion: McpSchema.protocolVersion,
|
|
@@ -25,6 +25,7 @@ import * as PublicMcpSchema from "../../McpSchema.ts"
|
|
|
25
25
|
import * as McpCore from "../mcpCore.ts"
|
|
26
26
|
import * as McpProtocol from "../mcpProtocol.ts"
|
|
27
27
|
import * as McpSchema from "../mcpSchema/v2026_07_28.ts"
|
|
28
|
+
import * as McpSkills from "../mcpSkills.ts"
|
|
28
29
|
|
|
29
30
|
const InputResponses = Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.Unknown))
|
|
30
31
|
const decodeRequestMetadata = Schema.decodeUnknownEffect(McpSchema.RequestMetaObject)
|
|
@@ -202,12 +203,12 @@ const projectContent = Match.type<PublicMcpSchema.ContentBlock>().pipe(
|
|
|
202
203
|
Match.exhaustive
|
|
203
204
|
)
|
|
204
205
|
|
|
205
|
-
|
|
206
|
+
// Registrations may be plain objects, so encode with the wire struct.
|
|
207
|
+
const projectResource = (resource: PublicMcpSchema.Resource) => Schema.encodeEffect(McpSchema.Resource)(resource)
|
|
206
208
|
const projectResourceTemplate = (resourceTemplate: PublicMcpSchema.ResourceTemplate) =>
|
|
207
|
-
McpSchema.ResourceTemplate
|
|
209
|
+
Schema.encodeEffect(McpSchema.ResourceTemplate)(resourceTemplate)
|
|
208
210
|
|
|
209
|
-
const projectPrompt = (prompt: PublicMcpSchema.Prompt) =>
|
|
210
|
-
McpProtocol.transcode(PublicMcpSchema.Prompt, McpSchema.Prompt, prompt)
|
|
211
|
+
const projectPrompt = (prompt: PublicMcpSchema.Prompt) => Schema.encodeEffect(McpSchema.Prompt)(prompt)
|
|
211
212
|
|
|
212
213
|
const projectTool = (tool: PublicMcpSchema.Tool) => McpProtocol.transcode(PublicMcpSchema.Tool, McpSchema.Tool, tool)
|
|
213
214
|
|
|
@@ -231,6 +232,8 @@ const projectCompleteResult = Effect.fnUntraced(function*(
|
|
|
231
232
|
type ProtocolError =
|
|
232
233
|
| McpCore.ResourceNotFound
|
|
233
234
|
| McpCore.PromptNotFound
|
|
235
|
+
| McpCore.SkillNotFound
|
|
236
|
+
| McpCore.DirectoryNotFound
|
|
234
237
|
| McpCore.ToolError
|
|
235
238
|
| McpCore.UnsupportedByProtocol
|
|
236
239
|
| McpProtocol.ProtocolError
|
|
@@ -297,7 +300,7 @@ const unsupported = (
|
|
|
297
300
|
/**
|
|
298
301
|
* @internal
|
|
299
302
|
*/
|
|
300
|
-
export const handlerRpcs = McpSchema.ClientRequestRpcs.merge(McpSchema.ClientNotificationRpcs)
|
|
303
|
+
export const handlerRpcs = McpSchema.ClientRequestRpcs.merge(McpSchema.ClientNotificationRpcs, McpSkills.StatelessRpcs)
|
|
301
304
|
|
|
302
305
|
/**
|
|
303
306
|
* @internal
|
|
@@ -320,6 +323,9 @@ export const makeHandlers = (
|
|
|
320
323
|
]))
|
|
321
324
|
const decodeCompleteResult = Schema.decodeUnknownEffect(McpSchema.CompleteResult)
|
|
322
325
|
const decodeListToolsResult = Schema.decodeUnknownEffect(McpSchema.ListToolsResult)
|
|
326
|
+
const decodeListSkillsResult = Schema.decodeUnknownEffect(McpSkills.ListSkillsResult)
|
|
327
|
+
const decodeGetSkillResult = Schema.decodeUnknownEffect(McpSkills.GetSkillResult)
|
|
328
|
+
const decodeReadResourceDirectoryResult = Schema.decodeUnknownEffect(McpSkills.ReadResourceDirectoryResult)
|
|
323
329
|
const sendNotification = context.sendNotification
|
|
324
330
|
const supportsSubscriptions = sendNotification !== undefined
|
|
325
331
|
// Older adapters accept arbitrary JSON; this binding requires extension settings objects.
|
|
@@ -334,7 +340,8 @@ export const makeHandlers = (
|
|
|
334
340
|
}
|
|
335
341
|
const getDiscovery = Effect.map(context.registrationPresence, (presence) => {
|
|
336
342
|
const capabilities: Types.Mutable<typeof McpSchema.ServerCapabilities.Type> = { completions: {}, logging: {} }
|
|
337
|
-
|
|
343
|
+
const declared = McpSkills.declareExtension(extensions, presence.skills)
|
|
344
|
+
if (declared !== undefined) capabilities.extensions = declared
|
|
338
345
|
if (presence.tools) capabilities.tools = { listChanged: supportsSubscriptions }
|
|
339
346
|
if (presence.resources) {
|
|
340
347
|
capabilities.resources = { listChanged: supportsSubscriptions, subscribe: supportsSubscriptions }
|
|
@@ -342,6 +349,10 @@ export const makeHandlers = (
|
|
|
342
349
|
if (presence.prompts) capabilities.prompts = { listChanged: supportsSubscriptions }
|
|
343
350
|
return { supportedVersions: context.supportedVersions, capabilities, serverInfo: context.serverInfo }
|
|
344
351
|
})
|
|
352
|
+
const requireSkills = (method: string) =>
|
|
353
|
+
McpSkills.requireSkills(core, method).pipe(
|
|
354
|
+
Effect.catch((error) => failWithHttpStatus(404, error))
|
|
355
|
+
)
|
|
345
356
|
const getInvocation = PublicMcpSchema.McpRequestContext.useSync(
|
|
346
357
|
McpProtocol.invocationFromRequestContext
|
|
347
358
|
)
|
|
@@ -502,7 +513,7 @@ export const makeHandlers = (
|
|
|
502
513
|
const resources = yield* core.resources.list(invocation)
|
|
503
514
|
const result = yield* projectCompleteResult({
|
|
504
515
|
...cacheHint("resources"),
|
|
505
|
-
resources:
|
|
516
|
+
resources: yield* Effect.forEach(resources, projectResource)
|
|
506
517
|
}, context.serverInfo)
|
|
507
518
|
return yield* decodeListResourcesResult(result)
|
|
508
519
|
}, Effect.mapError(projectError)),
|
|
@@ -513,7 +524,7 @@ export const makeHandlers = (
|
|
|
513
524
|
const resourceTemplates = yield* core.resources.listTemplates(invocation)
|
|
514
525
|
const result = yield* projectCompleteResult({
|
|
515
526
|
...cacheHint("resourceTemplates"),
|
|
516
|
-
resourceTemplates:
|
|
527
|
+
resourceTemplates: yield* Effect.forEach(resourceTemplates, projectResourceTemplate)
|
|
517
528
|
}, context.serverInfo)
|
|
518
529
|
return yield* decodeListResourceTemplatesResult(result)
|
|
519
530
|
}, Effect.mapError(projectError)),
|
|
@@ -673,6 +684,28 @@ export const makeHandlers = (
|
|
|
673
684
|
context.serverInfo
|
|
674
685
|
)
|
|
675
686
|
}, Effect.mapError(projectError)),
|
|
687
|
+
"skills/list": Effect.fnUntraced(function*(request: typeof McpSkills.ListSkills.payloadSchema.Type) {
|
|
688
|
+
yield* requireSkills("skills/list")
|
|
689
|
+
yield* McpSkills.rejectCursor(request.cursor)
|
|
690
|
+
const skills = yield* core.skills.list(yield* getInvocation)
|
|
691
|
+
const result = yield* projectCompleteResult({ ...cacheHint("skills"), skills }, context.serverInfo)
|
|
692
|
+
return yield* decodeListSkillsResult(result)
|
|
693
|
+
}, Effect.mapError(projectError)),
|
|
694
|
+
"skills/get": Effect.fnUntraced(function*(request: typeof McpSkills.GetSkill.payloadSchema.Type) {
|
|
695
|
+
yield* requireSkills("skills/get")
|
|
696
|
+
const skill = yield* core.skills.get(request.uri, yield* getInvocation)
|
|
697
|
+
const result = yield* projectCompleteResult({ ...cacheHint("skills"), skill }, context.serverInfo)
|
|
698
|
+
return yield* decodeGetSkillResult(result)
|
|
699
|
+
}, Effect.mapError(projectError)),
|
|
700
|
+
"resources/directory/read": Effect.fnUntraced(function*(
|
|
701
|
+
request: typeof McpSkills.ReadResourceDirectory.payloadSchema.Type
|
|
702
|
+
) {
|
|
703
|
+
yield* requireSkills("resources/directory/read")
|
|
704
|
+
yield* McpSkills.rejectCursor(request.cursor)
|
|
705
|
+
const resources = yield* core.skills.readDirectory(request.uri, yield* getInvocation)
|
|
706
|
+
const result = yield* projectCompleteResult({ ...cacheHint("skills"), resources }, context.serverInfo)
|
|
707
|
+
return yield* decodeReadResourceDirectoryResult(result)
|
|
708
|
+
}, Effect.mapError(projectError)),
|
|
676
709
|
"notifications/cancelled": Effect.fnUntraced(function*(
|
|
677
710
|
_request: typeof McpSchema.CancelledNotification.payloadSchema.Type
|
|
678
711
|
) {
|
|
@@ -696,7 +729,7 @@ const runtime = {
|
|
|
696
729
|
export const protocol = McpProtocol.make({
|
|
697
730
|
protocolVersion: McpSchema.protocolVersion,
|
|
698
731
|
runtime,
|
|
699
|
-
clientRpcs: McpSchema.ClientRpcs,
|
|
732
|
+
clientRpcs: McpSchema.ClientRpcs.merge(McpSkills.StatelessRpcs),
|
|
700
733
|
clientNotificationRpcs: McpSchema.ClientNotificationRpcs,
|
|
701
734
|
serverRequestRpcs: McpSchema.ServerRequestRpcs,
|
|
702
735
|
serverNotificationRpcs: McpSchema.ServerNotificationRpcs,
|
|
@@ -257,6 +257,20 @@ export class ProtocolError extends Data.TaggedError("ProtocolError")<{
|
|
|
257
257
|
message: `Prompt '${error.name}' not found`
|
|
258
258
|
})
|
|
259
259
|
}
|
|
260
|
+
if (error._tag === "SkillNotFound" && Predicate.hasProperty(error, "uri") && Predicate.isString(error.uri)) {
|
|
261
|
+
return new ProtocolError({
|
|
262
|
+
code: PublicMcpSchema.INVALID_PARAMS_ERROR_CODE,
|
|
263
|
+
message: `Skill '${error.uri}' not found`
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
if (
|
|
267
|
+
error._tag === "DirectoryNotFound" && Predicate.hasProperty(error, "uri") && Predicate.isString(error.uri)
|
|
268
|
+
) {
|
|
269
|
+
return new ProtocolError({
|
|
270
|
+
code: PublicMcpSchema.INVALID_PARAMS_ERROR_CODE,
|
|
271
|
+
message: `Directory '${error.uri}' not found`
|
|
272
|
+
})
|
|
273
|
+
}
|
|
260
274
|
if (error._tag === "ResourceNotFound" && Predicate.hasProperty(error, "uri") && Predicate.isString(error.uri)) {
|
|
261
275
|
return new ProtocolError({
|
|
262
276
|
code: LEGACY_RESOURCE_NOT_FOUND_ERROR_CODE,
|
|
@@ -450,6 +464,7 @@ export interface HandlerInstallationContext {
|
|
|
450
464
|
readonly tools: boolean
|
|
451
465
|
readonly resources: boolean
|
|
452
466
|
readonly prompts: boolean
|
|
467
|
+
readonly skills: boolean
|
|
453
468
|
}>
|
|
454
469
|
}
|
|
455
470
|
|
|
@@ -19,11 +19,13 @@ import * as Result from "../../Result.ts"
|
|
|
19
19
|
import * as RpcGroup from "../../rpc/RpcGroup.ts"
|
|
20
20
|
import type * as RpcMessage from "../../rpc/RpcMessage.ts"
|
|
21
21
|
import type * as Scope from "../../Scope.ts"
|
|
22
|
+
import type * as Types from "../../Types.ts"
|
|
22
23
|
import type * as PublicMcpProtocol from "../McpProtocol.ts"
|
|
23
24
|
import * as PublicMcpSchema from "../McpSchema.ts"
|
|
24
25
|
import type * as McpCore from "./mcpCore.ts"
|
|
25
26
|
import * as McpProtocol from "./mcpProtocol.ts"
|
|
26
27
|
import * as McpProtocolRegistry from "./mcpProtocolRegistry.ts"
|
|
28
|
+
import * as McpSkills from "./mcpSkills.ts"
|
|
27
29
|
import * as McpStatefulRuntime from "./mcpStatefulRuntime.ts"
|
|
28
30
|
|
|
29
31
|
const MCP_SESSION_ID_HEADER = "mcp-session-id"
|
|
@@ -542,16 +544,17 @@ export const make = Effect.fnUntraced(function*(
|
|
|
542
544
|
const presence = yield* options.core.registrationPresence
|
|
543
545
|
return yield* Effect.withFiber((fiber) => {
|
|
544
546
|
const httpRequest = Context.getOrUndefined(fiber.context, HttpServerRequest.HttpServerRequest)
|
|
545
|
-
const capabilities: McpCore.CanonicalServerCapabilities = {
|
|
547
|
+
const capabilities: Types.Mutable<McpCore.CanonicalServerCapabilities> = {
|
|
546
548
|
completions: true,
|
|
547
549
|
logging: true,
|
|
548
550
|
...(presence.tools ? { tools: { listChanged: true } } : {}),
|
|
549
551
|
...(presence.resources
|
|
550
552
|
? { resources: { listChanged: true, subscribe: httpRequest === undefined } }
|
|
551
553
|
: {}),
|
|
552
|
-
...(presence.prompts ? { prompts: { listChanged: true } } : {})
|
|
553
|
-
...(options.serverInfo.extensions ? { extensions: options.serverInfo.extensions } : {})
|
|
554
|
+
...(presence.prompts ? { prompts: { listChanged: true } } : {})
|
|
554
555
|
}
|
|
556
|
+
const extensions = McpSkills.declareExtension(options.serverInfo.extensions, presence.skills)
|
|
557
|
+
if (extensions !== undefined) capabilities.extensions = extensions
|
|
555
558
|
const initializePayload = PublicMcpSchema.Initialize.payloadSchema.make({
|
|
556
559
|
protocolVersion,
|
|
557
560
|
capabilities: profile.clientCapabilities,
|