functionalscript 0.46.1 → 0.47.0
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/fjs/basen/cbase32/module.f.mjs +18 -10
- package/fjs/basen/cbase32/proof.f.d.mts +3 -0
- package/fjs/basen/cbase32/proof.f.mjs +24 -2
- package/fjs/basen/proof.f.mjs +8 -16
- package/fjs/bnf/ll1/proof.f.d.mts +2 -0
- package/fjs/bnf/ll1/proof.f.mjs +33 -18
- package/fjs/bnf/module.f.d.mts +2 -2
- package/fjs/bnf/module.f.mjs +2 -2
- package/fjs/cas/proof.f.mjs +4 -26
- package/fjs/ci/common/module.f.mjs +6 -0
- package/fjs/ci/config/module.f.d.mts +7 -7
- package/fjs/ci/config/module.f.mjs +7 -7
- package/fjs/cli/module.f.mjs +14 -10
- package/fjs/crypto/vdf/module.f.d.mts +0 -1
- package/fjs/crypto/vdf/module.f.mjs +3 -14
- package/fjs/dev/module.f.mjs +10 -20
- package/fjs/djs/parser/module.f.d.mts +101 -53
- package/fjs/djs/parser/module.f.mjs +732 -525
- package/fjs/djs/parser/proof.f.d.mts +6 -0
- package/fjs/djs/parser/proof.f.mjs +315 -11
- package/fjs/djs/parser/types.d.ts +29 -2
- package/fjs/djs/tokenizer/module.f.mjs +122 -105
- package/fjs/djs/tokenizer/proof.f.mjs +17 -0
- package/fjs/djs/transpiler/module.f.mjs +4 -5
- package/fjs/djs/transpiler/proof.f.d.mts +2 -0
- package/fjs/djs/transpiler/proof.f.mjs +25 -0
- package/fjs/edag/amnesia/module.f.d.mts +20 -0
- package/fjs/edag/amnesia/module.f.mjs +303 -0
- package/fjs/edag/amnesia/proof.f.d.mts +79 -0
- package/fjs/edag/amnesia/proof.f.mjs +573 -0
- package/fjs/edag/amnesia/types.d.ts +15 -0
- package/fjs/edag/module.f.d.mts +410 -0
- package/fjs/edag/module.f.mjs +559 -0
- package/fjs/edag/proof.f.d.mts +116 -0
- package/fjs/edag/proof.f.mjs +686 -0
- package/fjs/edag/types.d.ts +55 -0
- package/fjs/effects/node/memory/module.d.mts +37 -3
- package/fjs/effects/node/memory/module.mjs +38 -4
- package/fjs/effects/node/memory/proof.d.mts +5 -2
- package/fjs/effects/node/memory/proof.mjs +36 -6
- package/fjs/effects/node/module.d.mts +9 -1
- package/fjs/effects/node/module.f.d.mts +39 -0
- package/fjs/effects/node/module.f.mjs +46 -0
- package/fjs/effects/node/module.mjs +234 -32
- package/fjs/effects/node/types.d.ts +28 -2
- package/fjs/effects/node/virtual/module.f.d.mts +19 -10
- package/fjs/effects/node/virtual/module.f.mjs +246 -32
- package/fjs/effects/node/virtual/proof.f.d.mts +17 -2
- package/fjs/effects/node/virtual/proof.f.mjs +232 -8
- package/fjs/effects/node/virtual/types.d.ts +57 -1
- package/fjs/emergent_testing/browser/proof.d.mts +55 -0
- package/fjs/emergent_testing/browser/proof.mjs +352 -0
- package/fjs/emergent_testing/browser/species.proof.d.mts +4 -0
- package/fjs/emergent_testing/browser/species.proof.mjs +45 -0
- package/fjs/emergent_testing/browser.d.mts +79 -0
- package/fjs/emergent_testing/browser.mjs +432 -0
- package/fjs/emergent_testing/proof.f.d.mts +1 -1
- package/fjs/emergent_testing/proof.f.mjs +2 -2
- package/fjs/js/string_escape/module.f.d.mts +47 -0
- package/fjs/js/string_escape/module.f.mjs +95 -0
- package/fjs/js/string_escape/proof.f.d.mts +8 -0
- package/fjs/js/string_escape/proof.f.mjs +68 -0
- package/fjs/js/tokenizer/module.f.mjs +14 -12
- package/fjs/mcp/cas/module.f.d.mts +1 -7
- package/fjs/mcp/cas/module.f.mjs +24 -15
- package/fjs/mcp/evo/module.f.mjs +9 -24
- package/fjs/mcp/module.f.d.mts +3 -1
- package/fjs/mcp/module.f.mjs +4 -2
- package/fjs/media/json/rtti/module.f.d.mts +2 -2
- package/fjs/media/json/rtti/module.f.mjs +1 -1
- package/fjs/media/json/schema/module.f.d.mts +15 -5
- package/fjs/media/json/schema/module.f.mjs +42 -15
- package/fjs/media/json/schema/proof.f.d.mts +10 -1
- package/fjs/media/json/schema/proof.f.mjs +88 -16
- package/fjs/media/json/serializer/module.f.mjs +14 -26
- package/fjs/media/json/types.d.ts +1 -1
- package/fjs/media/lock/module.f.d.mts +8 -3
- package/fjs/media/lock/module.f.mjs +9 -3
- package/fjs/media/lock/proof.f.d.mts +1 -1
- package/fjs/media/lock/proof.f.mjs +2 -2
- package/fjs/media/lock/types.d.ts +1 -3
- package/fjs/media/module.f.d.mts +20 -13
- package/fjs/media/module.f.mjs +29 -16
- package/fjs/media/note/module.f.d.mts +14 -7
- package/fjs/media/note/module.f.mjs +14 -7
- package/fjs/media/note/proof.f.mjs +1 -1
- package/fjs/media/proof.f.mjs +5 -5
- package/fjs/media/revision/module.f.d.mts +8 -2
- package/fjs/media/revision/module.f.mjs +9 -3
- package/fjs/media/revision/proof.f.mjs +1 -1
- package/fjs/media/revision/types.d.ts +1 -1
- package/fjs/media/type/module.f.d.mts +20 -0
- package/fjs/media/type/module.f.mjs +74 -0
- package/fjs/media/type/proof.f.d.mts +5 -0
- package/fjs/media/type/proof.f.mjs +24 -1
- package/fjs/module.f.mjs +6 -0
- package/fjs/path/module.f.d.mts +60 -3
- package/fjs/path/module.f.mjs +138 -14
- package/fjs/path/proof.f.d.mts +3 -0
- package/fjs/path/proof.f.mjs +298 -2
- package/fjs/protocol/json_rpc/module.f.d.mts +65 -28
- package/fjs/protocol/json_rpc/module.f.mjs +49 -13
- package/fjs/protocol/json_rpc/proof.f.d.mts +4 -0
- package/fjs/protocol/json_rpc/proof.f.mjs +29 -0
- package/fjs/protocol/json_rpc/types.d.ts +12 -2
- package/fjs/protocol/mcp/module.f.d.mts +89 -54
- package/fjs/protocol/mcp/module.f.mjs +110 -56
- package/fjs/protocol/mcp/proof.f.d.mts +13 -0
- package/fjs/protocol/mcp/proof.f.mjs +107 -7
- package/fjs/protocol/mcp/stdio/module.f.mjs +3 -4
- package/fjs/protocol/mcp/stdio/proof.f.mjs +2 -2
- package/fjs/protocol/mcp/types.d.ts +14 -2
- package/fjs/text/utf8/module.f.mjs +27 -1
- package/fjs/text/utf8/proof.f.mjs +37 -0
- package/fjs/types/array/module.f.mjs +18 -11
- package/fjs/types/array/proof.f.mjs +27 -1
- package/fjs/types/bigfloat/module.f.d.mts +48 -9
- package/fjs/types/bigfloat/module.f.mjs +147 -59
- package/fjs/types/bigfloat/proof.f.d.mts +2 -0
- package/fjs/types/bigfloat/proof.f.mjs +136 -4
- package/fjs/types/bigfloat/types.d.ts +17 -0
- package/fjs/types/function/module.f.d.mts +11 -2
- package/fjs/types/function/module.f.mjs +20 -2
- package/fjs/types/function/proof.f.mjs +5 -1
- package/fjs/types/phantom/types.d.ts +21 -0
- package/fjs/types/result/module.f.d.mts +4 -4
- package/fjs/types/result/module.f.mjs +2 -2
- package/fjs/types/result/proof.f.d.mts +6 -2
- package/fjs/types/result/proof.f.mjs +17 -1
- package/fjs/types/rtti/common/module.f.d.mts +78 -5
- package/fjs/types/rtti/common/module.f.mjs +168 -3
- package/fjs/types/rtti/common/proof.f.d.mts +14 -0
- package/fjs/types/rtti/common/proof.f.mjs +61 -2
- package/fjs/types/rtti/common/types.d.ts +23 -1
- package/fjs/types/rtti/data/module.f.d.mts +57 -1
- package/fjs/types/rtti/data/module.f.mjs +241 -47
- package/fjs/types/rtti/data/proof.f.d.mts +10 -0
- package/fjs/types/rtti/data/proof.f.mjs +272 -39
- package/fjs/types/rtti/data/types.d.ts +14 -7
- package/fjs/types/rtti/host.proof.d.mts +33 -0
- package/fjs/types/rtti/host.proof.mjs +170 -0
- package/fjs/types/rtti/module.f.d.mts +51 -6
- package/fjs/types/rtti/module.f.mjs +50 -3
- package/fjs/types/rtti/parse/module.f.d.mts +31 -24
- package/fjs/types/rtti/parse/module.f.mjs +197 -59
- package/fjs/types/rtti/parse/proof.f.d.mts +37 -2
- package/fjs/types/rtti/parse/proof.f.mjs +171 -47
- package/fjs/types/rtti/proof.f.d.mts +6 -0
- package/fjs/types/rtti/proof.f.mjs +42 -1
- package/fjs/types/rtti/ts/module.f.d.mts +9 -3
- package/fjs/types/rtti/ts/module.f.mjs +68 -15
- package/fjs/types/rtti/ts/proof.f.d.mts +42 -2
- package/fjs/types/rtti/ts/proof.f.mjs +139 -6
- package/fjs/types/rtti/ts/types.d.ts +164 -16
- package/fjs/types/rtti/types.d.ts +31 -3
- package/fjs/types/rtti/validate/module.f.d.mts +42 -25
- package/fjs/types/rtti/validate/module.f.mjs +187 -53
- package/fjs/types/rtti/validate/proof.f.d.mts +28 -2
- package/fjs/types/rtti/validate/proof.f.mjs +430 -75
- package/fjs/types/ts/types.d.ts +4 -0
- package/fjs/web/module.f.d.mts +115 -0
- package/fjs/web/module.f.mjs +581 -0
- package/fjs/web/proof.f.d.mts +39 -0
- package/fjs/web/proof.f.mjs +413 -0
- package/fjs/web/types.d.ts +39 -0
- package/fjs/website/browser-prepare.d.mts +5 -0
- package/fjs/website/browser-prepare.mjs +115 -0
- package/fjs/website/browser-source.d.mts +37 -0
- package/fjs/website/browser-source.mjs +202 -0
- package/fjs/website/browser-source.proof.d.mts +31 -0
- package/fjs/website/browser-source.proof.mjs +162 -0
- package/fjs/website/browser.d.mts +5 -0
- package/fjs/website/browser.mjs +8 -0
- package/fjs/website/module.f.d.mts +3 -3
- package/fjs/website/module.f.mjs +62 -9
- package/fjs/website/proof.f.d.mts +4 -0
- package/fjs/website/proof.f.mjs +18 -3
- package/package.json +2 -3
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* @import { Ts } from '../../types/rtti/ts/types.ts'
|
|
18
18
|
* @import { Effect, Operation } from '../../effects/types.ts'
|
|
19
19
|
* @import { Key, MemOp } from '../../effects/memory/types.ts'
|
|
20
|
-
* @import { Response
|
|
20
|
+
* @import { Response } from '../json_rpc/types.ts'
|
|
21
21
|
* @import { Type } from '../../types/rtti/types.ts'
|
|
22
|
-
* @import { Implementation, ServerCapabilities, InitializeResult, Tool, ToolsListParams, ToolsCallResult, McpHandlers, ToolEntry, McpSessionState, McpConfig } from './types.ts'
|
|
22
|
+
* @import { Implementation, ServerCapabilities, InitializeResult, Tool, ToolsListParams, ToolsCallResult, McpHandlers, ToolEntry, McpSessionState, McpConfig, ProtocolVersions } from './types.ts'
|
|
23
23
|
*/
|
|
24
24
|
import type { Unknown } from '../../media/json/types.ts';
|
|
25
25
|
import type { Ts } from '../../types/rtti/ts/types.ts';
|
|
@@ -29,123 +29,123 @@ import type { Response } from '../json_rpc/types.ts';
|
|
|
29
29
|
import type { Type } from '../../types/rtti/types.ts';
|
|
30
30
|
import type { ToolsCallResult, McpHandlers, ToolEntry, McpSessionState, McpConfig } from './types.ts';
|
|
31
31
|
/** Name + version pair sent in `initialize` requests and responses. */
|
|
32
|
-
export declare const implementation: {
|
|
32
|
+
export declare const implementation: import("../../types/rtti/types.ts").Rest<{
|
|
33
33
|
readonly name: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
34
34
|
readonly version: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
35
|
-
}
|
|
35
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
36
36
|
/** Server capabilities advertised in the `initialize` response. */
|
|
37
|
-
export declare const serverCapabilities: {
|
|
38
|
-
readonly tools: import("../../types/rtti/types.ts").Or<readonly [{
|
|
37
|
+
export declare const serverCapabilities: import("../../types/rtti/types.ts").Rest<{
|
|
38
|
+
readonly tools: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts").Rest<{
|
|
39
39
|
readonly listChanged: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"boolean">, undefined]>;
|
|
40
|
-
}, undefined]>;
|
|
41
|
-
}
|
|
40
|
+
}, import("../../types/rtti/types.ts").Unknown>, undefined]>;
|
|
41
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
42
42
|
/** Params for the `initialize` request. */
|
|
43
|
-
export declare const initializeParams: {
|
|
43
|
+
export declare const initializeParams: import("../../types/rtti/types.ts").Rest<{
|
|
44
44
|
readonly protocolVersion: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
45
45
|
readonly capabilities: () => readonly ['or', typeof import("../../media/json/rtti/module.f.mjs").primitive, typeof import("../../media/json/rtti/module.f.mjs").object, typeof import("../../media/json/rtti/module.f.mjs").array];
|
|
46
|
-
readonly clientInfo: {
|
|
46
|
+
readonly clientInfo: import("../../types/rtti/types.ts").Rest<{
|
|
47
47
|
readonly name: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
48
48
|
readonly version: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
49
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
50
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
51
51
|
/** Result for the `initialize` request. */
|
|
52
|
-
export declare const initializeResult: {
|
|
52
|
+
export declare const initializeResult: import("../../types/rtti/types.ts").Rest<{
|
|
53
53
|
readonly protocolVersion: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
54
|
-
readonly capabilities: {
|
|
55
|
-
readonly tools: import("../../types/rtti/types.ts").Or<readonly [{
|
|
54
|
+
readonly capabilities: import("../../types/rtti/types.ts").Rest<{
|
|
55
|
+
readonly tools: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts").Rest<{
|
|
56
56
|
readonly listChanged: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"boolean">, undefined]>;
|
|
57
|
-
}, undefined]>;
|
|
58
|
-
}
|
|
59
|
-
readonly serverInfo: {
|
|
57
|
+
}, import("../../types/rtti/types.ts").Unknown>, undefined]>;
|
|
58
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
59
|
+
readonly serverInfo: import("../../types/rtti/types.ts").Rest<{
|
|
60
60
|
readonly name: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
61
61
|
readonly version: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
62
|
-
}
|
|
62
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
63
63
|
readonly instructions: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
|
|
64
|
-
}
|
|
64
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
65
65
|
/** Plain-text content item returned by a tool call. */
|
|
66
|
-
export declare const textContent: {
|
|
66
|
+
export declare const textContent: import("../../types/rtti/types.ts").Rest<{
|
|
67
67
|
readonly type: 'text';
|
|
68
68
|
readonly text: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
69
|
-
}
|
|
69
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
70
70
|
/**
|
|
71
71
|
* A binary resource carried inside an {@link embeddedResource}: a base64
|
|
72
72
|
* `blob`, an addressing `uri`, and an optional `mimeType`. This is MCP's
|
|
73
73
|
* `BlobResource` shape — the idiomatic way to return typed binary content so a
|
|
74
74
|
* `mimeType` travels alongside the bytes and clients know how to route them.
|
|
75
75
|
*/
|
|
76
|
-
export declare const blobResource: {
|
|
76
|
+
export declare const blobResource: import("../../types/rtti/types.ts").Rest<{
|
|
77
77
|
readonly uri: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
78
78
|
readonly mimeType: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
|
|
79
79
|
readonly blob: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
80
|
-
}
|
|
80
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
81
81
|
/** An `EmbeddedResource` content item wrapping a {@link blobResource}. */
|
|
82
|
-
export declare const embeddedResource: {
|
|
82
|
+
export declare const embeddedResource: import("../../types/rtti/types.ts").Rest<{
|
|
83
83
|
readonly type: 'resource';
|
|
84
|
-
readonly resource: {
|
|
84
|
+
readonly resource: import("../../types/rtti/types.ts").Rest<{
|
|
85
85
|
readonly uri: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
86
86
|
readonly mimeType: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
|
|
87
87
|
readonly blob: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
88
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
89
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
90
90
|
/**
|
|
91
91
|
* A single item in a `tools/call` result's `content` array: either plain
|
|
92
92
|
* {@link textContent} or an {@link embeddedResource} for typed binary. The
|
|
93
93
|
* `image` and `audio` variants are not modelled yet.
|
|
94
94
|
*/
|
|
95
|
-
export declare const contentItem: import("../../types/rtti/types.ts").Or<[{
|
|
95
|
+
export declare const contentItem: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts").Rest<{
|
|
96
96
|
readonly type: 'text';
|
|
97
97
|
readonly text: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
98
|
-
}, {
|
|
98
|
+
}, import("../../types/rtti/types.ts").Unknown>, import("../../types/rtti/types.ts").Rest<{
|
|
99
99
|
readonly type: 'resource';
|
|
100
|
-
readonly resource: {
|
|
100
|
+
readonly resource: import("../../types/rtti/types.ts").Rest<{
|
|
101
101
|
readonly uri: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
102
102
|
readonly mimeType: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
|
|
103
103
|
readonly blob: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
104
|
-
}
|
|
105
|
-
}]>;
|
|
104
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
105
|
+
}, import("../../types/rtti/types.ts").Unknown>]>;
|
|
106
106
|
/**
|
|
107
107
|
* A tool descriptor returned by `tools/list`.
|
|
108
108
|
* `inputSchema` is a JSON Schema object — use `toJsonSchema` to derive it from
|
|
109
109
|
* an rtti schema.
|
|
110
110
|
*/
|
|
111
|
-
export declare const tool: {
|
|
111
|
+
export declare const tool: import("../../types/rtti/types.ts").Rest<{
|
|
112
112
|
readonly name: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
113
113
|
readonly description: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
|
|
114
114
|
readonly inputSchema: () => readonly ['or', typeof import("../../media/json/rtti/module.f.mjs").primitive, typeof import("../../media/json/rtti/module.f.mjs").object, typeof import("../../media/json/rtti/module.f.mjs").array];
|
|
115
|
-
}
|
|
115
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
116
116
|
/**
|
|
117
117
|
* Params for the `tools/list` request. `cursor` is an opaque pagination token
|
|
118
118
|
* from a previous `ToolsListResult.nextCursor`.
|
|
119
119
|
*/
|
|
120
|
-
export declare const toolsListParams: {
|
|
120
|
+
export declare const toolsListParams: import("../../types/rtti/types.ts").Rest<{
|
|
121
121
|
readonly cursor: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
|
|
122
|
-
}
|
|
123
|
-
export declare const toolsListResult: {
|
|
124
|
-
readonly tools: import("../../types/rtti/types.ts").Type1<"array", {
|
|
122
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
123
|
+
export declare const toolsListResult: import("../../types/rtti/types.ts").Rest<{
|
|
124
|
+
readonly tools: import("../../types/rtti/types.ts").Type1<"array", import("../../types/rtti/types.ts").Rest<{
|
|
125
125
|
readonly name: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
126
126
|
readonly description: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
|
|
127
127
|
readonly inputSchema: () => readonly ['or', typeof import("../../media/json/rtti/module.f.mjs").primitive, typeof import("../../media/json/rtti/module.f.mjs").object, typeof import("../../media/json/rtti/module.f.mjs").array];
|
|
128
|
-
}
|
|
128
|
+
}, import("../../types/rtti/types.ts").Unknown>>;
|
|
129
129
|
readonly nextCursor: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
|
|
130
|
-
}
|
|
131
|
-
export declare const toolsCallParams: {
|
|
130
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
131
|
+
export declare const toolsCallParams: import("../../types/rtti/types.ts").Rest<{
|
|
132
132
|
readonly name: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
133
133
|
readonly arguments: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts").Type1<"record", () => readonly ['or', typeof import("../../media/json/rtti/module.f.mjs").primitive, typeof import("../../media/json/rtti/module.f.mjs").object, typeof import("../../media/json/rtti/module.f.mjs").array]>, undefined]>;
|
|
134
|
-
}
|
|
135
|
-
export declare const toolsCallResult: {
|
|
136
|
-
readonly content: import("../../types/rtti/types.ts").Type1<"array", import("../../types/rtti/types.ts").Or<[{
|
|
134
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
135
|
+
export declare const toolsCallResult: import("../../types/rtti/types.ts").Rest<{
|
|
136
|
+
readonly content: import("../../types/rtti/types.ts").Type1<"array", import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts").Rest<{
|
|
137
137
|
readonly type: 'text';
|
|
138
138
|
readonly text: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
139
|
-
}, {
|
|
139
|
+
}, import("../../types/rtti/types.ts").Unknown>, import("../../types/rtti/types.ts").Rest<{
|
|
140
140
|
readonly type: 'resource';
|
|
141
|
-
readonly resource: {
|
|
141
|
+
readonly resource: import("../../types/rtti/types.ts").Rest<{
|
|
142
142
|
readonly uri: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
143
143
|
readonly mimeType: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"string">, undefined]>;
|
|
144
144
|
readonly blob: import("../../types/rtti/types.ts")._Type0<"string">;
|
|
145
|
-
}
|
|
146
|
-
}]>>;
|
|
145
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
146
|
+
}, import("../../types/rtti/types.ts").Unknown>]>>;
|
|
147
147
|
readonly isError: import("../../types/rtti/types.ts").Or<readonly [import("../../types/rtti/types.ts")._Type0<"boolean">, undefined]>;
|
|
148
|
-
}
|
|
148
|
+
}, import("../../types/rtti/types.ts").Unknown>;
|
|
149
149
|
/**
|
|
150
150
|
* Creates a type-safe tool entry that binds an RTTI schema with a handler.
|
|
151
151
|
*
|
|
@@ -153,7 +153,7 @@ export declare const toolsCallResult: {
|
|
|
153
153
|
* arguments (typed as `Ts<T>`) to the handler. This eliminates manual validation
|
|
154
154
|
* boilerplate and type assertions.
|
|
155
155
|
*
|
|
156
|
-
* @template {Type} T
|
|
156
|
+
* @template {Type} const T
|
|
157
157
|
* @template {Operation} O
|
|
158
158
|
* @param {string} name - The tool name (used in `tools/call` requests)
|
|
159
159
|
* @param {string} description - Human-readable description for `tools/list`
|
|
@@ -161,7 +161,7 @@ export declare const toolsCallResult: {
|
|
|
161
161
|
* @param {(args: Ts<T>) => Effect<O, ToolsCallResult, never>} handle - Handler receiving validated arguments of type `Ts<inputRtti>`
|
|
162
162
|
* @returns {ToolEntry<O>} A `ToolEntry` ready to be added to a registry
|
|
163
163
|
*/
|
|
164
|
-
export declare const toolEntry: <T extends Type, O extends Operation>(name: string, description: string, inputRtti: T, handle: (args: Ts<T>) => Effect<O, ToolsCallResult, never>) => ToolEntry<O>;
|
|
164
|
+
export declare const toolEntry: <const T extends Type, O extends Operation>(name: string, description: string, inputRtti: T, handle: (args: Ts<T>) => Effect<O, ToolsCallResult, never>) => ToolEntry<O>;
|
|
165
165
|
/**
|
|
166
166
|
* Helper to create a successful single-text-block tool result.
|
|
167
167
|
*
|
|
@@ -176,6 +176,36 @@ export declare const okResult: (text: string) => ToolsCallResult;
|
|
|
176
176
|
* @returns {ToolsCallResult} A `ToolsCallResult` with `isError: true` and the text explanation
|
|
177
177
|
*/
|
|
178
178
|
export declare const errorResult: (text: string) => ToolsCallResult;
|
|
179
|
+
/**
|
|
180
|
+
* Answers a tool call with the outcome of one fallible operation: the `ok`
|
|
181
|
+
* value rendered by `text`, the failure rendered by `errorText` and tagged
|
|
182
|
+
* `isError`. It is the third member of the {@link okResult} / {@link errorResult}
|
|
183
|
+
* family — the one that picks between them — and it empties the error channel,
|
|
184
|
+
* because a tool-level failure is a result the client reads, never a transport
|
|
185
|
+
* error.
|
|
186
|
+
*
|
|
187
|
+
* Every tool whose body is a single `Evo`- or `Cas`-shaped call is that
|
|
188
|
+
* dispatch and nothing else, so each one is a single line:
|
|
189
|
+
*
|
|
190
|
+
* ```js
|
|
191
|
+
* ({ subject }) => toolResultStep(e.head(subject), lines, evoSummary)
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* **Both renderers are required, and `errorText` is the load-bearing one** —
|
|
195
|
+
* for the reason `unwrapStep` gives for its own `summary`
|
|
196
|
+
* (`fjs/effects/module.f.mjs`): a renderer written for a particular error
|
|
197
|
+
* channel cannot accept a wider one, so a fallible call added upstream turns
|
|
198
|
+
* into a compile error at the tool that has to say what the new failure reads
|
|
199
|
+
* like, instead of silently reaching the client as whatever `String` made of
|
|
200
|
+
* it. `evoSummary` and `errorSummary` are the two in use today.
|
|
201
|
+
*
|
|
202
|
+
* @type {<O extends Operation, T, E>(
|
|
203
|
+
* e: Effect<O, T, E>,
|
|
204
|
+
* text: (value: T) => string,
|
|
205
|
+
* errorText: (e: E) => string,
|
|
206
|
+
* ) => Effect<O, ToolsCallResult, never>}
|
|
207
|
+
*/
|
|
208
|
+
export declare const toolResultStep: <O extends Operation, T, E>(e: Effect<O, T, E>, text: (value: T) => string, errorText: (e: E) => string) => Effect<O, ToolsCallResult, never>;
|
|
179
209
|
/**
|
|
180
210
|
* Builds `McpHandlers` from a registry of tool entries.
|
|
181
211
|
*
|
|
@@ -208,7 +238,12 @@ export declare const uninitializedState: McpSessionState;
|
|
|
208
238
|
* - `ping` returns an empty success regardless of session state; non-object
|
|
209
239
|
* params → -32602.
|
|
210
240
|
* - `initialize` is accepted only while uninitialized; a second call returns -32600.
|
|
211
|
-
* On success the state moves to `initializing`, not `initialized`.
|
|
241
|
+
* On success the state moves to `initializing`, not `initialized`. The answered
|
|
242
|
+
* `protocolVersion` is negotiated against `config.protocolVersions`: the client's
|
|
243
|
+
* requested revision when the server supports it, the latest supported one
|
|
244
|
+
* otherwise. A counter-proposal is a success frame like any other — the client,
|
|
245
|
+
* not the server, decides whether the answer is usable — so the state moves the
|
|
246
|
+
* same way in both cases.
|
|
212
247
|
* - `notifications/initialized` (no `id`) transitions `initializing` → `initialized`;
|
|
213
248
|
* a malformed one (non-object params) is ignored and the session stays gated;
|
|
214
249
|
* other notifications are silently ignored in any state.
|
|
@@ -221,4 +256,4 @@ export declare const uninitializedState: McpSessionState;
|
|
|
221
256
|
* @param {McpConfig} config
|
|
222
257
|
* @returns {<O extends Operation>(handlers: McpHandlers<O>) => (stateKey: Key<McpSessionState>) => (value: Unknown) => Effect<MemOp | O, Response | null, never>}
|
|
223
258
|
*/
|
|
224
|
-
export declare const mcpStep: ({
|
|
259
|
+
export declare const mcpStep: ({ protocolVersions, capabilities, serverInfo, }: McpConfig) => <O extends Operation>(handlers: McpHandlers<O>) => (stateKey: Key<McpSessionState>) => (value: Unknown) => Effect<MemOp | O, Response | null, never>;
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
* @import { Ts } from '../../types/rtti/ts/types.ts'
|
|
18
18
|
* @import { Effect, Operation } from '../../effects/types.ts'
|
|
19
19
|
* @import { Key, MemOp } from '../../effects/memory/types.ts'
|
|
20
|
-
* @import { Response
|
|
20
|
+
* @import { Response } from '../json_rpc/types.ts'
|
|
21
21
|
* @import { Type } from '../../types/rtti/types.ts'
|
|
22
|
-
* @import { Implementation, ServerCapabilities, InitializeResult, Tool, ToolsListParams, ToolsCallResult, McpHandlers, ToolEntry, McpSessionState, McpConfig } from './types.ts'
|
|
22
|
+
* @import { Implementation, ServerCapabilities, InitializeResult, Tool, ToolsListParams, ToolsCallResult, McpHandlers, ToolEntry, McpSessionState, McpConfig, ProtocolVersions } from './types.ts'
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import { boolean, string, option, array, record, or } from '../../types/rtti/module.f.mjs'
|
|
25
|
+
import { boolean, string, open, option, array, record, or } from '../../types/rtti/module.f.mjs'
|
|
26
26
|
import { pureOk, resultMapStep, resultStep, step as ioStep } from '../../effects/module.f.mjs'
|
|
27
27
|
import { ok } from '../../types/result/module.f.mjs'
|
|
28
28
|
import { read, write } from '../../effects/memory/module.f.mjs'
|
|
29
29
|
import {
|
|
30
30
|
decodeRequest,
|
|
31
31
|
rpcError, internalError, invalidRequest, invalidParams, methodNotFound,
|
|
32
|
-
|
|
32
|
+
errorResponseOf, successResponseOf,
|
|
33
33
|
} from '../json_rpc/module.f.mjs'
|
|
34
34
|
import { parse } from '../../types/rtti/parse/module.f.mjs'
|
|
35
35
|
import { toJsonSchema } from '../../media/json/schema/module.f.mjs'
|
|
@@ -37,42 +37,48 @@ import { unknown } from '../../media/json/rtti/module.f.mjs'
|
|
|
37
37
|
|
|
38
38
|
// ── Shared ─────────────────────────────────────────────────────────────────────
|
|
39
39
|
|
|
40
|
+
// Every struct below says `open`, and that is the protocol's requirement
|
|
41
|
+
// rather than a default: a bare struct is closed, and a peer implementing a
|
|
42
|
+
// later revision of MCP sends members this one does not name — a schema that
|
|
43
|
+
// rejected them would fail every such peer outright, where ignoring them is
|
|
44
|
+
// what the specification asks for. Do not drop a wrapper.
|
|
45
|
+
|
|
40
46
|
/** Name + version pair sent in `initialize` requests and responses. */
|
|
41
|
-
export const implementation = /** @type {const} */ ({
|
|
47
|
+
export const implementation = open(/** @type {const} */ ({
|
|
42
48
|
name: string,
|
|
43
49
|
version: string,
|
|
44
|
-
})
|
|
50
|
+
}))
|
|
45
51
|
|
|
46
52
|
// ── Capabilities ───────────────────────────────────────────────────────────────
|
|
47
53
|
|
|
48
|
-
const toolsCapability = /** @type {const} */ ({ listChanged: option(boolean) })
|
|
54
|
+
const toolsCapability = open(/** @type {const} */ ({ listChanged: option(boolean) }))
|
|
49
55
|
|
|
50
56
|
/** Server capabilities advertised in the `initialize` response. */
|
|
51
|
-
export const serverCapabilities = /** @type {const} */ ({
|
|
57
|
+
export const serverCapabilities = open(/** @type {const} */ ({
|
|
52
58
|
tools: option(toolsCapability),
|
|
53
|
-
})
|
|
59
|
+
}))
|
|
54
60
|
|
|
55
61
|
// ── Lifecycle ──────────────────────────────────────────────────────────────────
|
|
56
62
|
|
|
57
63
|
/** Params for the `initialize` request. */
|
|
58
|
-
export const initializeParams = /** @type {const} */ ({
|
|
64
|
+
export const initializeParams = open(/** @type {const} */ ({
|
|
59
65
|
protocolVersion: string,
|
|
60
66
|
capabilities: unknown,
|
|
61
67
|
clientInfo: implementation,
|
|
62
|
-
})
|
|
68
|
+
}))
|
|
63
69
|
|
|
64
70
|
/** Result for the `initialize` request. */
|
|
65
|
-
export const initializeResult = /** @type {const} */ ({
|
|
71
|
+
export const initializeResult = open(/** @type {const} */ ({
|
|
66
72
|
protocolVersion: string,
|
|
67
73
|
capabilities: serverCapabilities,
|
|
68
74
|
serverInfo: implementation,
|
|
69
75
|
instructions: option(string),
|
|
70
|
-
})
|
|
76
|
+
}))
|
|
71
77
|
|
|
72
78
|
// ── Content ────────────────────────────────────────────────────────────────────
|
|
73
79
|
|
|
74
80
|
/** Plain-text content item returned by a tool call. */
|
|
75
|
-
export const textContent = /** @type {const} */ ({ type: 'text', text: string })
|
|
81
|
+
export const textContent = open(/** @type {const} */ ({ type: 'text', text: string }))
|
|
76
82
|
|
|
77
83
|
/**
|
|
78
84
|
* A binary resource carried inside an {@link embeddedResource}: a base64
|
|
@@ -80,17 +86,17 @@ export const textContent = /** @type {const} */ ({ type: 'text', text: string })
|
|
|
80
86
|
* `BlobResource` shape — the idiomatic way to return typed binary content so a
|
|
81
87
|
* `mimeType` travels alongside the bytes and clients know how to route them.
|
|
82
88
|
*/
|
|
83
|
-
export const blobResource = /** @type {const} */ ({
|
|
89
|
+
export const blobResource = open(/** @type {const} */ ({
|
|
84
90
|
uri: string,
|
|
85
91
|
mimeType: option(string),
|
|
86
92
|
blob: string,
|
|
87
|
-
})
|
|
93
|
+
}))
|
|
88
94
|
|
|
89
95
|
/** An `EmbeddedResource` content item wrapping a {@link blobResource}. */
|
|
90
|
-
export const embeddedResource = /** @type {const} */ ({
|
|
96
|
+
export const embeddedResource = open(/** @type {const} */ ({
|
|
91
97
|
type: 'resource',
|
|
92
98
|
resource: blobResource,
|
|
93
|
-
})
|
|
99
|
+
}))
|
|
94
100
|
|
|
95
101
|
/**
|
|
96
102
|
* A single item in a `tools/call` result's `content` array: either plain
|
|
@@ -106,34 +112,34 @@ export const contentItem = or(textContent, embeddedResource)
|
|
|
106
112
|
* `inputSchema` is a JSON Schema object — use `toJsonSchema` to derive it from
|
|
107
113
|
* an rtti schema.
|
|
108
114
|
*/
|
|
109
|
-
export const tool = /** @type {const} */ ({
|
|
115
|
+
export const tool = open(/** @type {const} */ ({
|
|
110
116
|
name: string,
|
|
111
117
|
description: option(string),
|
|
112
118
|
inputSchema: unknown,
|
|
113
|
-
})
|
|
119
|
+
}))
|
|
114
120
|
|
|
115
121
|
/**
|
|
116
122
|
* Params for the `tools/list` request. `cursor` is an opaque pagination token
|
|
117
123
|
* from a previous `ToolsListResult.nextCursor`.
|
|
118
124
|
*/
|
|
119
|
-
export const toolsListParams = /** @type {const} */ ({
|
|
125
|
+
export const toolsListParams = open(/** @type {const} */ ({
|
|
120
126
|
cursor: option(string),
|
|
121
|
-
})
|
|
127
|
+
}))
|
|
122
128
|
|
|
123
|
-
export const toolsListResult = /** @type {const} */ ({
|
|
129
|
+
export const toolsListResult = open(/** @type {const} */ ({
|
|
124
130
|
tools: array(tool),
|
|
125
131
|
nextCursor: option(string),
|
|
126
|
-
})
|
|
132
|
+
}))
|
|
127
133
|
|
|
128
|
-
export const toolsCallParams = /** @type {const} */ ({
|
|
134
|
+
export const toolsCallParams = open(/** @type {const} */ ({
|
|
129
135
|
name: string,
|
|
130
136
|
arguments: option(record(unknown)),
|
|
131
|
-
})
|
|
137
|
+
}))
|
|
132
138
|
|
|
133
|
-
export const toolsCallResult = /** @type {const} */ ({
|
|
139
|
+
export const toolsCallResult = open(/** @type {const} */ ({
|
|
134
140
|
content: array(contentItem),
|
|
135
141
|
isError: option(boolean),
|
|
136
|
-
})
|
|
142
|
+
}))
|
|
137
143
|
|
|
138
144
|
// ── Dispatch ───────────────────────────────────────────────────────────────────
|
|
139
145
|
|
|
@@ -144,7 +150,7 @@ export const toolsCallResult = /** @type {const} */ ({
|
|
|
144
150
|
* arguments (typed as `Ts<T>`) to the handler. This eliminates manual validation
|
|
145
151
|
* boilerplate and type assertions.
|
|
146
152
|
*
|
|
147
|
-
* @template {Type} T
|
|
153
|
+
* @template {Type} const T
|
|
148
154
|
* @template {Operation} O
|
|
149
155
|
* @param {string} name - The tool name (used in `tools/call` requests)
|
|
150
156
|
* @param {string} description - Human-readable description for `tools/list`
|
|
@@ -183,6 +189,41 @@ export const okResult = text =>
|
|
|
183
189
|
export const errorResult = text =>
|
|
184
190
|
({ ...okResult(text), isError: true })
|
|
185
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Answers a tool call with the outcome of one fallible operation: the `ok`
|
|
194
|
+
* value rendered by `text`, the failure rendered by `errorText` and tagged
|
|
195
|
+
* `isError`. It is the third member of the {@link okResult} / {@link errorResult}
|
|
196
|
+
* family — the one that picks between them — and it empties the error channel,
|
|
197
|
+
* because a tool-level failure is a result the client reads, never a transport
|
|
198
|
+
* error.
|
|
199
|
+
*
|
|
200
|
+
* Every tool whose body is a single `Evo`- or `Cas`-shaped call is that
|
|
201
|
+
* dispatch and nothing else, so each one is a single line:
|
|
202
|
+
*
|
|
203
|
+
* ```js
|
|
204
|
+
* ({ subject }) => toolResultStep(e.head(subject), lines, evoSummary)
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* **Both renderers are required, and `errorText` is the load-bearing one** —
|
|
208
|
+
* for the reason `unwrapStep` gives for its own `summary`
|
|
209
|
+
* (`fjs/effects/module.f.mjs`): a renderer written for a particular error
|
|
210
|
+
* channel cannot accept a wider one, so a fallible call added upstream turns
|
|
211
|
+
* into a compile error at the tool that has to say what the new failure reads
|
|
212
|
+
* like, instead of silently reaching the client as whatever `String` made of
|
|
213
|
+
* it. `evoSummary` and `errorSummary` are the two in use today.
|
|
214
|
+
*
|
|
215
|
+
* @type {<O extends Operation, T, E>(
|
|
216
|
+
* e: Effect<O, T, E>,
|
|
217
|
+
* text: (value: T) => string,
|
|
218
|
+
* errorText: (e: E) => string,
|
|
219
|
+
* ) => Effect<O, ToolsCallResult, never>}
|
|
220
|
+
*/
|
|
221
|
+
export const toolResultStep = (e, text, errorText) => resultMapStep(
|
|
222
|
+
e,
|
|
223
|
+
([tag, value]) => ok(tag === 'error'
|
|
224
|
+
? errorResult(errorText(value))
|
|
225
|
+
: okResult(text(value))))
|
|
226
|
+
|
|
186
227
|
/**
|
|
187
228
|
* Builds `McpHandlers` from a registry of tool entries.
|
|
188
229
|
*
|
|
@@ -215,12 +256,6 @@ export const fromRegistry = registry => ({
|
|
|
215
256
|
|
|
216
257
|
// ── Lifecycle / capability state machine ───────────────────────────────────────
|
|
217
258
|
|
|
218
|
-
/** @type {(id: Id) => (error: RpcError) => Response} */
|
|
219
|
-
const _errResponse = id => error => ({ jsonrpc, error, id })
|
|
220
|
-
|
|
221
|
-
/** @type {(id: Id) => (result: Unknown) => Response} */
|
|
222
|
-
const _okResponse = id => result => ({ jsonrpc, result, id })
|
|
223
|
-
|
|
224
259
|
/** MCP error -32002: the client called a method before `initialize`. */
|
|
225
260
|
export const notInitialized = rpcError(-32002)('Server not initialized')
|
|
226
261
|
|
|
@@ -232,6 +267,20 @@ const _noParams = option(record(unknown))
|
|
|
232
267
|
/** @type {McpSessionState} */
|
|
233
268
|
export const uninitializedState = ['uninitialized']
|
|
234
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Version negotiation: the revision to answer an `initialize` with. The
|
|
272
|
+
* requested one when this server speaks it, the latest one it does speak
|
|
273
|
+
* otherwise — a counter-proposal, not an error, because the
|
|
274
|
+
* [lifecycle spec](https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle#version-negotiation)
|
|
275
|
+
* leaves the decision to the client (`SHOULD disconnect`). `supported` is
|
|
276
|
+
* non-empty by type, so there is always something to propose.
|
|
277
|
+
* @type {(supported: ProtocolVersions, requested: string) => string}
|
|
278
|
+
*/
|
|
279
|
+
const _negotiateVersion = (supported, requested) => {
|
|
280
|
+
const [latest] = supported
|
|
281
|
+
return supported.includes(requested) ? requested : latest
|
|
282
|
+
}
|
|
283
|
+
|
|
235
284
|
/**
|
|
236
285
|
* State-machine step for an MCP session using memory effects.
|
|
237
286
|
*
|
|
@@ -242,7 +291,12 @@ export const uninitializedState = ['uninitialized']
|
|
|
242
291
|
* - `ping` returns an empty success regardless of session state; non-object
|
|
243
292
|
* params → -32602.
|
|
244
293
|
* - `initialize` is accepted only while uninitialized; a second call returns -32600.
|
|
245
|
-
* On success the state moves to `initializing`, not `initialized`.
|
|
294
|
+
* On success the state moves to `initializing`, not `initialized`. The answered
|
|
295
|
+
* `protocolVersion` is negotiated against `config.protocolVersions`: the client's
|
|
296
|
+
* requested revision when the server supports it, the latest supported one
|
|
297
|
+
* otherwise. A counter-proposal is a success frame like any other — the client,
|
|
298
|
+
* not the server, decides whether the answer is usable — so the state moves the
|
|
299
|
+
* same way in both cases.
|
|
246
300
|
* - `notifications/initialized` (no `id`) transitions `initializing` → `initialized`;
|
|
247
301
|
* a malformed one (non-object params) is ignored and the session stays gated;
|
|
248
302
|
* other notifications are silently ignored in any state.
|
|
@@ -256,7 +310,7 @@ export const uninitializedState = ['uninitialized']
|
|
|
256
310
|
* @returns {<O extends Operation>(handlers: McpHandlers<O>) => (stateKey: Key<McpSessionState>) => (value: Unknown) => Effect<MemOp | O, Response | null, never>}
|
|
257
311
|
*/
|
|
258
312
|
export const mcpStep = ({
|
|
259
|
-
|
|
313
|
+
protocolVersions,
|
|
260
314
|
capabilities,
|
|
261
315
|
serverInfo,
|
|
262
316
|
}) =>
|
|
@@ -265,7 +319,7 @@ export const mcpStep = ({
|
|
|
265
319
|
value => {
|
|
266
320
|
const [t, message] = decodeRequest(value)
|
|
267
321
|
if (t === 'error') {
|
|
268
|
-
return pureOk(
|
|
322
|
+
return pureOk(errorResponseOf(null)(invalidRequest))
|
|
269
323
|
}
|
|
270
324
|
const { id, method, params } = message
|
|
271
325
|
|
|
@@ -302,8 +356,8 @@ export const mcpStep = ({
|
|
|
302
356
|
if (method === 'ping') {
|
|
303
357
|
const [pt] = parse(_noParams)(params)
|
|
304
358
|
return pt === 'error'
|
|
305
|
-
? pureOk(
|
|
306
|
-
: pureOk(
|
|
359
|
+
? pureOk(errorResponseOf(id)(invalidParams))
|
|
360
|
+
: pureOk(successResponseOf(id)({}))
|
|
307
361
|
}
|
|
308
362
|
|
|
309
363
|
// `initialize` transitions uninitialized → initializing; reject if already done.
|
|
@@ -311,17 +365,17 @@ export const mcpStep = ({
|
|
|
311
365
|
return resultStep(
|
|
312
366
|
read(stateKey),
|
|
313
367
|
r => {
|
|
314
|
-
if (r[0] === 'error') { return pureOk(
|
|
368
|
+
if (r[0] === 'error') { return pureOk(errorResponseOf(id)(internalError)) }
|
|
315
369
|
if (r[1][0] !== 'uninitialized') {
|
|
316
|
-
return pureOk(
|
|
370
|
+
return pureOk(errorResponseOf(id)(invalidRequest))
|
|
317
371
|
}
|
|
318
|
-
const [pr] = parse(initializeParams)(params)
|
|
372
|
+
const [pr, pv] = parse(initializeParams)(params)
|
|
319
373
|
if (pr === 'error') {
|
|
320
|
-
return pureOk(
|
|
374
|
+
return pureOk(errorResponseOf(id)(invalidParams))
|
|
321
375
|
}
|
|
322
376
|
/** @type {InitializeResult} */
|
|
323
377
|
const result = {
|
|
324
|
-
protocolVersion,
|
|
378
|
+
protocolVersion: _negotiateVersion(protocolVersions, pv.protocolVersion),
|
|
325
379
|
capabilities,
|
|
326
380
|
serverInfo,
|
|
327
381
|
}
|
|
@@ -333,8 +387,8 @@ export const mcpStep = ({
|
|
|
333
387
|
return resultStep(
|
|
334
388
|
write(stateKey, ['initializing']),
|
|
335
389
|
w => pureOk(w[0] === 'error'
|
|
336
|
-
?
|
|
337
|
-
:
|
|
390
|
+
? errorResponseOf(id)(internalError)
|
|
391
|
+
: successResponseOf(id)(result)),
|
|
338
392
|
)
|
|
339
393
|
},
|
|
340
394
|
)
|
|
@@ -347,39 +401,39 @@ export const mcpStep = ({
|
|
|
347
401
|
return resultStep(
|
|
348
402
|
read(stateKey),
|
|
349
403
|
r => {
|
|
350
|
-
if (r[0] === 'error') { return pureOk(
|
|
404
|
+
if (r[0] === 'error') { return pureOk(errorResponseOf(id)(internalError)) }
|
|
351
405
|
if (r[1][0] !== 'initialized') {
|
|
352
|
-
return pureOk(
|
|
406
|
+
return pureOk(errorResponseOf(id)(notInitialized))
|
|
353
407
|
}
|
|
354
408
|
|
|
355
409
|
if (method === 'tools/list') {
|
|
356
410
|
if (capabilities.tools === undefined) {
|
|
357
|
-
return pureOk(
|
|
411
|
+
return pureOk(errorResponseOf(id)(methodNotFound))
|
|
358
412
|
}
|
|
359
413
|
// `params` may be absent — `tools/list` without a cursor.
|
|
360
414
|
const [t, pr] = parse(toolsListParams)(params === undefined ? {} : params)
|
|
361
415
|
return t === 'error'
|
|
362
|
-
? pureOk(
|
|
416
|
+
? pureOk(errorResponseOf(id)(invalidParams))
|
|
363
417
|
: ioStep(
|
|
364
418
|
handlers.toolsList(pr),
|
|
365
|
-
r => pureOk(
|
|
419
|
+
r => pureOk(successResponseOf(id)(r)),
|
|
366
420
|
)
|
|
367
421
|
}
|
|
368
422
|
|
|
369
423
|
if (method === 'tools/call') {
|
|
370
424
|
if (capabilities.tools === undefined) {
|
|
371
|
-
return pureOk(
|
|
425
|
+
return pureOk(errorResponseOf(id)(methodNotFound))
|
|
372
426
|
}
|
|
373
427
|
const [t, pr] = parse(toolsCallParams)(params)
|
|
374
428
|
return t === 'error'
|
|
375
|
-
? pureOk(
|
|
429
|
+
? pureOk(errorResponseOf(id)(invalidParams))
|
|
376
430
|
: ioStep(
|
|
377
431
|
handlers.toolsCall(pr),
|
|
378
|
-
r => pureOk(
|
|
432
|
+
r => pureOk(successResponseOf(id)(r)),
|
|
379
433
|
)
|
|
380
434
|
}
|
|
381
435
|
|
|
382
|
-
return pureOk(
|
|
436
|
+
return pureOk(errorResponseOf(id)(methodNotFound))
|
|
383
437
|
},
|
|
384
438
|
)
|
|
385
439
|
}
|