effect 4.0.0-beta.10 → 4.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Channel.d.ts +7 -7
- package/dist/Config.d.ts +157 -0
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +56 -1
- package/dist/Config.js.map +1 -1
- package/dist/Effect.d.ts +296 -8
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +72 -0
- package/dist/Effect.js.map +1 -1
- package/dist/ErrorReporter.d.ts +376 -0
- package/dist/ErrorReporter.d.ts.map +1 -0
- package/dist/ErrorReporter.js +246 -0
- package/dist/ErrorReporter.js.map +1 -0
- package/dist/Fiber.d.ts +2 -2
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +3 -6
- package/dist/Graph.js.map +1 -1
- package/dist/LogLevel.d.ts +5 -0
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +25 -91
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +2 -3
- package/dist/Logger.js.map +1 -1
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +0 -1
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +17 -0
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +17 -0
- package/dist/Random.js.map +1 -1
- package/dist/References.d.ts +3 -3
- package/dist/References.d.ts.map +1 -1
- package/dist/Schema.d.ts +3 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +2 -1
- package/dist/SchemaAST.js.map +1 -1
- package/dist/Stream.d.ts +5 -5
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +98 -33
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +2 -2
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +86 -14
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +112 -36
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +47 -10
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +33 -6
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +16 -0
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +14 -0
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/CliOutput.js +37 -6
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +199 -7
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +116 -6
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +60 -2
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +11 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +33 -8
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +7 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +10 -2
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +2 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +27 -10
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +28 -4
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +3 -8
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +25 -31
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +4 -8
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +14 -27
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +37 -44
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
- package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +5 -5
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +2 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +2 -0
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
- package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js +10 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +11 -0
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +29 -9
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +7 -4
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/reactivity/Atom.js +1 -1
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +22 -1
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +14 -0
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +34 -9
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +0 -7
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +9 -10
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +6 -0
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +131 -0
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Channel.ts +9 -9
- package/src/Config.ts +171 -9
- package/src/Effect.ts +315 -8
- package/src/ErrorReporter.ts +459 -0
- package/src/Fiber.ts +9 -2
- package/src/Graph.ts +16 -6
- package/src/LogLevel.ts +6 -0
- package/src/Logger.ts +28 -95
- package/src/Queue.ts +0 -1
- package/src/Random.ts +18 -0
- package/src/References.ts +4 -4
- package/src/Schema.ts +1 -1
- package/src/SchemaAST.ts +2 -1
- package/src/Stream.ts +7 -7
- package/src/index.ts +5 -0
- package/src/internal/effect.ts +205 -49
- package/src/internal/hashMap.ts +2 -2
- package/src/unstable/ai/LanguageModel.ts +117 -16
- package/src/unstable/ai/McpSchema.ts +57 -11
- package/src/unstable/ai/McpServer.ts +44 -6
- package/src/unstable/ai/Tool.ts +15 -0
- package/src/unstable/cli/CliOutput.ts +45 -6
- package/src/unstable/cli/Command.ts +298 -11
- package/src/unstable/cli/HelpDoc.ts +68 -2
- package/src/unstable/cli/internal/command.ts +47 -11
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +7 -2
- package/src/unstable/cli/internal/parser.ts +11 -3
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +2 -2
- package/src/unstable/http/Headers.ts +28 -13
- package/src/unstable/http/HttpClient.ts +45 -10
- package/src/unstable/http/HttpEffect.ts +30 -44
- package/src/unstable/http/HttpMiddleware.ts +4 -14
- package/src/unstable/http/HttpServerError.ts +42 -45
- package/src/unstable/http/HttpServerRespondable.ts +6 -6
- package/src/unstable/http/HttpServerResponse.ts +3 -1
- package/src/unstable/http/internal/preResponseHandler.ts +15 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +2 -1
- package/src/unstable/httpapi/HttpApiError.ts +30 -9
- package/src/unstable/observability/OtlpLogger.ts +9 -5
- package/src/unstable/reactivity/Atom.ts +1 -1
- package/src/unstable/reactivity/AtomRegistry.ts +29 -1
- package/src/unstable/rpc/RpcSchema.ts +17 -0
- package/src/unstable/rpc/RpcSerialization.ts +44 -9
- package/src/unstable/rpc/RpcServer.ts +14 -19
- package/src/unstable/workflow/WorkflowEngine.ts +178 -0
|
@@ -240,6 +240,11 @@ export class ClientCapabilities extends Schema.Class<ClientCapabilities>(
|
|
|
240
240
|
* Experimental, non-standard capabilities that the client supports.
|
|
241
241
|
*/
|
|
242
242
|
experimental: optional(Schema.Record(Schema.String, Schema.Struct({}))),
|
|
243
|
+
/**
|
|
244
|
+
* Optional extensions capabilities advertised by the client.
|
|
245
|
+
* Keys are extension identifiers following <vendor-prefix>/<extension-name> (e.g. "io.modelcontextprotocol/ui").
|
|
246
|
+
*/
|
|
247
|
+
extensions: optional(Schema.Record(Schema.TemplateLiteral([Schema.String, "/", Schema.String]), Schema.Unknown)),
|
|
243
248
|
/**
|
|
244
249
|
* Present if the client supports listing roots.
|
|
245
250
|
*/
|
|
@@ -272,6 +277,11 @@ export class ServerCapabilities extends Schema.Opaque<ServerCapabilities>()(Sche
|
|
|
272
277
|
* Experimental, non-standard capabilities that the server supports.
|
|
273
278
|
*/
|
|
274
279
|
experimental: optional(Schema.Record(Schema.String, Schema.Struct({}))),
|
|
280
|
+
/**
|
|
281
|
+
* Optional extensions capabilities advertised by the server.
|
|
282
|
+
* Keys are extension identifiers following <vendor-prefix>/<extension-name> (e.g. "io.modelcontextprotocol/ui").
|
|
283
|
+
*/
|
|
284
|
+
extensions: optional(Schema.Record(Schema.TemplateLiteral([Schema.String, "/", Schema.String]), Schema.Unknown)),
|
|
275
285
|
/**
|
|
276
286
|
* Present if the server supports sending log messages to the client.
|
|
277
287
|
*/
|
|
@@ -321,8 +331,8 @@ export class ServerCapabilities extends Schema.Opaque<ServerCapabilities>()(Sche
|
|
|
321
331
|
* @since 4.0.0
|
|
322
332
|
* @category errors
|
|
323
333
|
*/
|
|
324
|
-
export class
|
|
325
|
-
"@effect/ai/McpSchema/
|
|
334
|
+
export class McpErrorBase extends Schema.Class<McpErrorBase>(
|
|
335
|
+
"@effect/ai/McpSchema/McpErrorBase"
|
|
326
336
|
)({
|
|
327
337
|
/**
|
|
328
338
|
* The error type that occurred.
|
|
@@ -371,7 +381,7 @@ export const PARSE_ERROR_CODE = -32700 as const
|
|
|
371
381
|
* @category errors
|
|
372
382
|
*/
|
|
373
383
|
export class ParseError extends Schema.ErrorClass<ParseError>("effect/ai/McpSchema/ParseError")({
|
|
374
|
-
...
|
|
384
|
+
...McpErrorBase.fields,
|
|
375
385
|
_tag: Schema.tag("ParseError"),
|
|
376
386
|
code: Schema.tag(PARSE_ERROR_CODE)
|
|
377
387
|
}) {}
|
|
@@ -381,7 +391,7 @@ export class ParseError extends Schema.ErrorClass<ParseError>("effect/ai/McpSche
|
|
|
381
391
|
* @category errors
|
|
382
392
|
*/
|
|
383
393
|
export class InvalidRequest extends Schema.ErrorClass<InvalidRequest>("effect/ai/McpSchema/InvalidRequest")({
|
|
384
|
-
...
|
|
394
|
+
...McpErrorBase.fields,
|
|
385
395
|
_tag: Schema.tag("InvalidRequest"),
|
|
386
396
|
code: Schema.tag(INVALID_REQUEST_ERROR_CODE)
|
|
387
397
|
}) {}
|
|
@@ -391,7 +401,7 @@ export class InvalidRequest extends Schema.ErrorClass<InvalidRequest>("effect/ai
|
|
|
391
401
|
* @category errors
|
|
392
402
|
*/
|
|
393
403
|
export class MethodNotFound extends Schema.ErrorClass<MethodNotFound>("effect/ai/McpSchema/MethodNotFound")({
|
|
394
|
-
...
|
|
404
|
+
...McpErrorBase.fields,
|
|
395
405
|
_tag: Schema.tag("MethodNotFound"),
|
|
396
406
|
code: Schema.tag(METHOD_NOT_FOUND_ERROR_CODE)
|
|
397
407
|
}) {}
|
|
@@ -401,7 +411,7 @@ export class MethodNotFound extends Schema.ErrorClass<MethodNotFound>("effect/ai
|
|
|
401
411
|
* @category errors
|
|
402
412
|
*/
|
|
403
413
|
export class InvalidParams extends Schema.ErrorClass<InvalidParams>("effect/ai/McpSchema/InvalidParams")({
|
|
404
|
-
...
|
|
414
|
+
...McpErrorBase.fields,
|
|
405
415
|
_tag: Schema.tag("InvalidParams"),
|
|
406
416
|
code: Schema.tag(INVALID_PARAMS_ERROR_CODE)
|
|
407
417
|
}) {}
|
|
@@ -411,13 +421,26 @@ export class InvalidParams extends Schema.ErrorClass<InvalidParams>("effect/ai/M
|
|
|
411
421
|
* @category errors
|
|
412
422
|
*/
|
|
413
423
|
export class InternalError extends Schema.ErrorClass<InternalError>("effect/ai/McpSchema/InternalError")({
|
|
414
|
-
...
|
|
424
|
+
...McpErrorBase.fields,
|
|
415
425
|
_tag: Schema.tag("InternalError"),
|
|
416
426
|
code: Schema.tag(INTERNAL_ERROR_CODE)
|
|
417
427
|
}) {
|
|
418
428
|
static readonly notImplemented = new InternalError({ message: "Not implemented" })
|
|
419
429
|
}
|
|
420
430
|
|
|
431
|
+
/**
|
|
432
|
+
* @since 4.0.0
|
|
433
|
+
* @category errors
|
|
434
|
+
*/
|
|
435
|
+
export const McpError = Schema.Union([
|
|
436
|
+
ParseError,
|
|
437
|
+
InvalidRequest,
|
|
438
|
+
MethodNotFound,
|
|
439
|
+
InvalidParams,
|
|
440
|
+
InternalError,
|
|
441
|
+
McpErrorBase
|
|
442
|
+
])
|
|
443
|
+
|
|
421
444
|
// =============================================================================
|
|
422
445
|
// Ping
|
|
423
446
|
// =============================================================================
|
|
@@ -615,7 +638,14 @@ export class Resource extends Schema.Class<Resource>(
|
|
|
615
638
|
* This can be used by Hosts to display file sizes and estimate context
|
|
616
639
|
* window usage.
|
|
617
640
|
*/
|
|
618
|
-
size: optional(Schema.Number)
|
|
641
|
+
size: optional(Schema.Number),
|
|
642
|
+
/**
|
|
643
|
+
* Optional additional metadata for the client.
|
|
644
|
+
*
|
|
645
|
+
* This parameter name is reserved by MCP to allow clients and servers to
|
|
646
|
+
* attach additional metadata to resources.
|
|
647
|
+
*/
|
|
648
|
+
_meta: optional(Schema.Record(Schema.String, Schema.Unknown))
|
|
619
649
|
}) {}
|
|
620
650
|
|
|
621
651
|
/**
|
|
@@ -656,7 +686,12 @@ export class ResourceTemplate extends Schema.Class<ResourceTemplate>(
|
|
|
656
686
|
/**
|
|
657
687
|
* Optional annotations for the client.
|
|
658
688
|
*/
|
|
659
|
-
annotations: optional(Annotations)
|
|
689
|
+
annotations: optional(Annotations),
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Optional additional metadata for the client.
|
|
693
|
+
*/
|
|
694
|
+
_meta: optional(Schema.Record(Schema.String, Schema.Unknown))
|
|
660
695
|
}) {}
|
|
661
696
|
|
|
662
697
|
/**
|
|
@@ -673,7 +708,11 @@ export class ResourceContents extends Schema.Opaque<ResourceContents>()(Schema.S
|
|
|
673
708
|
/**
|
|
674
709
|
* The MIME type of this resource, if known.
|
|
675
710
|
*/
|
|
676
|
-
mimeType: optional(Schema.String)
|
|
711
|
+
mimeType: optional(Schema.String),
|
|
712
|
+
/**
|
|
713
|
+
* Optional additional metadata for the client.
|
|
714
|
+
*/
|
|
715
|
+
_meta: optional(Schema.Record(Schema.String, Schema.Unknown))
|
|
677
716
|
})) {}
|
|
678
717
|
|
|
679
718
|
/**
|
|
@@ -1183,7 +1222,14 @@ export class Tool extends Schema.Class<Tool>(
|
|
|
1183
1222
|
/**
|
|
1184
1223
|
* Optional additional tool information.
|
|
1185
1224
|
*/
|
|
1186
|
-
annotations: optional(ToolAnnotations)
|
|
1225
|
+
annotations: optional(ToolAnnotations),
|
|
1226
|
+
/**
|
|
1227
|
+
* Optional additional metadata for the client.
|
|
1228
|
+
*
|
|
1229
|
+
* This parameter name is reserved by MCP to allow clients and servers to
|
|
1230
|
+
* attach additional metadata to resources.
|
|
1231
|
+
*/
|
|
1232
|
+
_meta: optional(Schema.Record(Schema.String, Schema.Unknown))
|
|
1187
1233
|
}) {}
|
|
1188
1234
|
|
|
1189
1235
|
/**
|
|
@@ -9,6 +9,7 @@ import * as Layer from "../../Layer.ts"
|
|
|
9
9
|
import * as Option from "../../Option.ts"
|
|
10
10
|
import * as Queue from "../../Queue.ts"
|
|
11
11
|
import * as RcMap from "../../RcMap.ts"
|
|
12
|
+
import { CurrentLogLevel } from "../../References.ts"
|
|
12
13
|
import * as Schema from "../../Schema.ts"
|
|
13
14
|
import * as AST from "../../SchemaAST.ts"
|
|
14
15
|
import * as ServiceMap from "../../ServiceMap.ts"
|
|
@@ -548,6 +549,7 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>>(
|
|
|
548
549
|
>)
|
|
549
550
|
const services = yield* Effect.services<never>()
|
|
550
551
|
for (const tool of Object.values(built.tools)) {
|
|
552
|
+
const toolMeta = ServiceMap.getOrUndefined(tool.annotations, Tool.Meta)
|
|
551
553
|
const mcpTool = new McpTool({
|
|
552
554
|
name: tool.name,
|
|
553
555
|
description: Tool.getDescription(tool),
|
|
@@ -561,7 +563,8 @@ export const registerToolkit: <Tools extends Record<string, Tool.Any>>(
|
|
|
561
563
|
destructiveHint: ServiceMap.get(tool.annotations, Tool.Destructive),
|
|
562
564
|
idempotentHint: ServiceMap.get(tool.annotations, Tool.Idempotent),
|
|
563
565
|
openWorldHint: ServiceMap.get(tool.annotations, Tool.OpenWorld)
|
|
564
|
-
}
|
|
566
|
+
},
|
|
567
|
+
_meta: toolMeta
|
|
565
568
|
})
|
|
566
569
|
yield* registry.addTool({
|
|
567
570
|
tool: mcpTool,
|
|
@@ -1075,6 +1078,7 @@ const layerHandlers = (serverInfo: {
|
|
|
1075
1078
|
ClientRpcs.toLayer(
|
|
1076
1079
|
Effect.gen(function*() {
|
|
1077
1080
|
const server = yield* McpServer
|
|
1081
|
+
let currentLogLevel = yield* CurrentLogLevel
|
|
1078
1082
|
|
|
1079
1083
|
return ClientRpcs.of({
|
|
1080
1084
|
// Requests
|
|
@@ -1105,17 +1109,51 @@ const layerHandlers = (serverInfo: {
|
|
|
1105
1109
|
: LATEST_PROTOCOL_VERSION
|
|
1106
1110
|
})
|
|
1107
1111
|
},
|
|
1108
|
-
"completion/complete":
|
|
1109
|
-
|
|
1110
|
-
|
|
1112
|
+
"completion/complete": (r) =>
|
|
1113
|
+
server.completion(r).pipe(
|
|
1114
|
+
Effect.provideService(CurrentLogLevel, currentLogLevel)
|
|
1115
|
+
),
|
|
1116
|
+
"logging/setLevel": ({ level }) =>
|
|
1117
|
+
Effect.sync(() => {
|
|
1118
|
+
switch (level) {
|
|
1119
|
+
case "notice":
|
|
1120
|
+
case "info":
|
|
1121
|
+
currentLogLevel = "Info"
|
|
1122
|
+
break
|
|
1123
|
+
case "error":
|
|
1124
|
+
currentLogLevel = "Error"
|
|
1125
|
+
break
|
|
1126
|
+
case "debug":
|
|
1127
|
+
currentLogLevel = "Debug"
|
|
1128
|
+
break
|
|
1129
|
+
case "warning":
|
|
1130
|
+
currentLogLevel = "Warn"
|
|
1131
|
+
break
|
|
1132
|
+
case "critical":
|
|
1133
|
+
case "alert":
|
|
1134
|
+
case "emergency":
|
|
1135
|
+
currentLogLevel = "Fatal"
|
|
1136
|
+
break
|
|
1137
|
+
}
|
|
1138
|
+
}),
|
|
1139
|
+
"prompts/get": (r) =>
|
|
1140
|
+
server.getPromptResult(r).pipe(
|
|
1141
|
+
Effect.provideService(CurrentLogLevel, currentLogLevel)
|
|
1142
|
+
),
|
|
1111
1143
|
"prompts/list": () => Effect.sync(() => new ListPromptsResult({ prompts: server.prompts })),
|
|
1112
1144
|
"resources/list": () => Effect.sync(() => new ListResourcesResult({ resources: server.resources })),
|
|
1113
|
-
"resources/read": ({ uri }) =>
|
|
1145
|
+
"resources/read": ({ uri }) =>
|
|
1146
|
+
server.findResource(uri).pipe(
|
|
1147
|
+
Effect.provideService(CurrentLogLevel, currentLogLevel)
|
|
1148
|
+
),
|
|
1114
1149
|
"resources/subscribe": () => InternalError.notImplemented.asEffect(),
|
|
1115
1150
|
"resources/unsubscribe": () => InternalError.notImplemented.asEffect(),
|
|
1116
1151
|
"resources/templates/list": () =>
|
|
1117
1152
|
Effect.sync(() => new ListResourceTemplatesResult({ resourceTemplates: server.resourceTemplates })),
|
|
1118
|
-
"tools/call":
|
|
1153
|
+
"tools/call": (r) =>
|
|
1154
|
+
server.callTool(r).pipe(
|
|
1155
|
+
Effect.provideService(CurrentLogLevel, currentLogLevel)
|
|
1156
|
+
),
|
|
1119
1157
|
"tools/list": () => Effect.sync(() => new ListToolsResult({ tools: server.tools })),
|
|
1120
1158
|
|
|
1121
1159
|
// Notifications
|
package/src/unstable/ai/Tool.ts
CHANGED
|
@@ -1661,6 +1661,21 @@ export const getJsonSchemaFromSchema = <S extends Schema.Top>(schema: S, options
|
|
|
1661
1661
|
*/
|
|
1662
1662
|
export class Title extends ServiceMap.Service<Title, string>()("effect/ai/Tool/Title") {}
|
|
1663
1663
|
|
|
1664
|
+
/**
|
|
1665
|
+
* Annotation for providing tool metadata for MCP.
|
|
1666
|
+
*
|
|
1667
|
+
* @example
|
|
1668
|
+
* ```ts
|
|
1669
|
+
* import { Tool } from "effect/unstable/ai"
|
|
1670
|
+
*
|
|
1671
|
+
* const myCalculatorUi = Tool.make("calculator_ui", {})
|
|
1672
|
+
* .annotate(Tool.Meta, { ui: { resourceUri: "ui://example/calculator-ui" } })
|
|
1673
|
+
* ```
|
|
1674
|
+
* @since 1.0.0
|
|
1675
|
+
* @category annotations
|
|
1676
|
+
*/
|
|
1677
|
+
export class Meta extends ServiceMap.Service<Meta, Record<string, unknown>>()("effect/ai/Tool/Meta") {}
|
|
1678
|
+
|
|
1664
1679
|
/**
|
|
1665
1680
|
* Annotation indicating whether a tool only reads data without making changes.
|
|
1666
1681
|
*
|
|
@@ -499,14 +499,53 @@ const formatHelpDocImpl = (doc: HelpDoc, colors: ColorFunctions): string => {
|
|
|
499
499
|
|
|
500
500
|
// Subcommands section
|
|
501
501
|
if (doc.subcommands && doc.subcommands.length > 0) {
|
|
502
|
-
|
|
502
|
+
const ungrouped = doc.subcommands.find((group) => group.group === undefined)
|
|
503
|
+
|
|
504
|
+
if (ungrouped) {
|
|
505
|
+
sections.push(colors.bold("SUBCOMMANDS"))
|
|
506
|
+
sections.push(renderTable(
|
|
507
|
+
ungrouped.commands.map((sub) => ({
|
|
508
|
+
left: colors.cyan(sub.name),
|
|
509
|
+
right: sub.shortDescription ?? sub.description
|
|
510
|
+
})),
|
|
511
|
+
20
|
|
512
|
+
))
|
|
513
|
+
if (doc.subcommands.length > 1) {
|
|
514
|
+
sections.push("")
|
|
515
|
+
}
|
|
516
|
+
}
|
|
503
517
|
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
518
|
+
for (const group of doc.subcommands) {
|
|
519
|
+
if (group.group === undefined) continue
|
|
520
|
+
sections.push(colors.bold(`${group.group}:`))
|
|
521
|
+
sections.push(renderTable(
|
|
522
|
+
group.commands.map((sub) => ({
|
|
523
|
+
left: colors.cyan(sub.name),
|
|
524
|
+
right: sub.shortDescription ?? sub.description
|
|
525
|
+
})),
|
|
526
|
+
20
|
|
527
|
+
))
|
|
528
|
+
sections.push("")
|
|
529
|
+
}
|
|
530
|
+
}
|
|
508
531
|
|
|
509
|
-
|
|
532
|
+
// Examples section
|
|
533
|
+
if (doc.examples && doc.examples.length > 0) {
|
|
534
|
+
sections.push(colors.bold("EXAMPLES"))
|
|
535
|
+
|
|
536
|
+
let first = true
|
|
537
|
+
let previousHadDescription = false
|
|
538
|
+
for (const example of doc.examples) {
|
|
539
|
+
if (example.description) {
|
|
540
|
+
if (!first) sections.push("")
|
|
541
|
+
sections.push(` ${colors.dim(`# ${example.description}`)}`)
|
|
542
|
+
} else if (previousHadDescription) {
|
|
543
|
+
sections.push("")
|
|
544
|
+
}
|
|
545
|
+
sections.push(` ${colors.cyan(example.command)}`)
|
|
546
|
+
first = false
|
|
547
|
+
previousHadDescription = !!example.description
|
|
548
|
+
}
|
|
510
549
|
sections.push("")
|
|
511
550
|
}
|
|
512
551
|
|