@foldkit/devtools-mcp 0.19.2-canary.d902ee3d7d0b → 0.19.2-canary.fe9a895a47a8
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/server.js +27 -13
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +38 -38
- package/dist/webSocketClient.js +3 -3
- package/package.json +3 -3
package/dist/server.js
CHANGED
|
@@ -41762,7 +41762,9 @@ var defineUnion = (variantLabel, casesByTag) => {
|
|
|
41762
41762
|
);
|
|
41763
41763
|
}
|
|
41764
41764
|
const callables = {};
|
|
41765
|
-
for (const [tag4, fields] of Object.entries(
|
|
41765
|
+
for (const [tag4, fields] of Object.entries(
|
|
41766
|
+
casesByTag
|
|
41767
|
+
)) {
|
|
41766
41768
|
callables[tag4] = makeCallable(tag4, fields);
|
|
41767
41769
|
}
|
|
41768
41770
|
const subset = (tags3) => {
|
|
@@ -41832,19 +41834,25 @@ var Request = defineTaggedUnion({
|
|
|
41832
41834
|
RequestListMessages: {
|
|
41833
41835
|
limit: Schema_exports.Number,
|
|
41834
41836
|
maybeSinceIndex: Schema_exports.OptionFromNullOr(Schema_exports.Number),
|
|
41835
|
-
maybeChangedPathsMatch: Schema_exports.OptionFromNullOr(
|
|
41836
|
-
Schema_exports.
|
|
41837
|
-
),
|
|
41838
|
-
fromEnd: Schema_exports.Boolean.pipe(
|
|
41837
|
+
maybeChangedPathsMatch: Schema_exports.OptionFromNullOr(
|
|
41838
|
+
Schema_exports.Array(Schema_exports.String)
|
|
41839
|
+
).pipe(Schema_exports.withDecodingDefault(Effect_exports.succeed(null))),
|
|
41840
|
+
fromEnd: Schema_exports.Boolean.pipe(
|
|
41841
|
+
Schema_exports.withDecodingDefault(Effect_exports.succeed(false))
|
|
41842
|
+
)
|
|
41839
41843
|
},
|
|
41840
41844
|
RequestCountMessagesByTag: {
|
|
41841
41845
|
maybeSinceIndex: Schema_exports.OptionFromNullOr(Schema_exports.Number),
|
|
41842
|
-
maybeChangedPathsMatch: Schema_exports.OptionFromNullOr(
|
|
41846
|
+
maybeChangedPathsMatch: Schema_exports.OptionFromNullOr(
|
|
41847
|
+
Schema_exports.Array(Schema_exports.String)
|
|
41848
|
+
)
|
|
41843
41849
|
},
|
|
41844
41850
|
RequestDiffModels: {
|
|
41845
41851
|
fromIndex: Schema_exports.Number,
|
|
41846
41852
|
toIndex: Schema_exports.Number,
|
|
41847
|
-
maybeChangedPathsMatch: Schema_exports.OptionFromNullOr(
|
|
41853
|
+
maybeChangedPathsMatch: Schema_exports.OptionFromNullOr(
|
|
41854
|
+
Schema_exports.Array(Schema_exports.String)
|
|
41855
|
+
)
|
|
41848
41856
|
},
|
|
41849
41857
|
RequestGetMessage: { index: Schema_exports.Number },
|
|
41850
41858
|
RequestListKeyframes: {},
|
|
@@ -41855,7 +41863,9 @@ var Request = defineTaggedUnion({
|
|
|
41855
41863
|
RequestListRuntimes: {},
|
|
41856
41864
|
RequestGetInit: {},
|
|
41857
41865
|
RequestGetRuntimeState: {},
|
|
41858
|
-
RequestGetMessageSchema: {
|
|
41866
|
+
RequestGetMessageSchema: {
|
|
41867
|
+
maybeVariantTag: Schema_exports.OptionFromNullOr(Schema_exports.String)
|
|
41868
|
+
}
|
|
41859
41869
|
});
|
|
41860
41870
|
var MessageTagCount = Schema_exports.Struct({
|
|
41861
41871
|
tag: Schema_exports.String,
|
|
@@ -41883,7 +41893,11 @@ var MessageSchemaResult = defineTaggedUnion({
|
|
|
41883
41893
|
MessageSchemaDocumentResult: { document: Schema_exports.Unknown }
|
|
41884
41894
|
});
|
|
41885
41895
|
var Response = defineTaggedUnion({
|
|
41886
|
-
ResponseModel: {
|
|
41896
|
+
ResponseModel: {
|
|
41897
|
+
value: Schema_exports.Unknown,
|
|
41898
|
+
atPath: Schema_exports.String,
|
|
41899
|
+
summarized: Schema_exports.Boolean
|
|
41900
|
+
},
|
|
41887
41901
|
ResponseMessages: {
|
|
41888
41902
|
entries: Schema_exports.Array(SerializedEntry),
|
|
41889
41903
|
maybeNextIndex: Schema_exports.OptionFromNullOr(Schema_exports.Number)
|
|
@@ -42271,7 +42285,7 @@ var buildTools = (wsClient) => [
|
|
|
42271
42285
|
},
|
|
42272
42286
|
{
|
|
42273
42287
|
name: "foldkit_get_message_schema",
|
|
42274
|
-
description: 'Describe the Message Schema for a Foldkit runtime so agents can construct valid payloads for `foldkit_dispatch_message`. Call with no arguments to receive a small variant index (every top-level variant\'s `_tag`, its payload field names, and which payload fields are themselves tagged-union shapes). Then call with `variant_tag: "ChosenVariant"` to drill in. The argument is a dot-separated path of variant `_tag` values: each segment names a variant, and the walker steps through the variant\'s single tagged-union payload field to reach the next. So `"GotMobileMenuDialogMessage"` narrows one level; `"GotMobileMenuDialogMessage.GotAnimationMessage"` narrows two levels of a Submodel chain. Discriminated unions deeper than the supplied path collapse to `{ "_summary": "union", "variants": [...] }` placeholders so the response stays compact even for deeply-nested apps; extend the path to drill further. `
|
|
42288
|
+
description: 'Describe the Message Schema for a Foldkit runtime so agents can construct valid payloads for `foldkit_dispatch_message`. Call with no arguments to receive a small variant index (every top-level variant\'s `_tag`, its payload field names, and which payload fields are themselves tagged-union shapes). Then call with `variant_tag: "ChosenVariant"` to drill in. The argument is a dot-separated path of variant `_tag` values: each segment names a variant, and the walker steps through the variant\'s single tagged-union payload field to reach the next. So `"GotMobileMenuDialogMessage"` narrows one level; `"GotMobileMenuDialogMessage.GotAnimationMessage"` narrows two levels of a Submodel chain. Discriminated unions deeper than the supplied path collapse to `{ "_summary": "union", "variants": [...] }` placeholders so the response stays compact even for deeply-nested apps; extend the path to drill further. `Schema.Option` fields render as `anyOf: [{_tag: "Some", value}, {_tag: "None"}]`. The full document follows the JSON Schema draft-2020-12 shape from `Schema.toJsonSchemaDocument`: `{ dialect, schema, definitions }`. Returns `maybeResult: None` when the runtime hasn\'t configured `DevToolsConfig.Message` (dispatch is also unavailable). Fields with no JSON representation, notably `Schema.instanceOf(File)` for user-uploaded files, render as `{type: "null"}`; those variants can\'t be dispatched via MCP because their values live in browser memory.',
|
|
42275
42289
|
inputSchema: toInputSchema(GetMessageSchemaInput),
|
|
42276
42290
|
handle: runRuntimeTool(
|
|
42277
42291
|
GetMessageSchemaInput,
|
|
@@ -42470,9 +42484,9 @@ var connectWebSocketClient = (url) => Effect_exports.gen(function* () {
|
|
|
42470
42484
|
return { sendRequest, close: close2 };
|
|
42471
42485
|
});
|
|
42472
42486
|
var handleIncomingMessage = (raw, pendingResponsesRef) => {
|
|
42473
|
-
const decoded = Schema_exports.decodeUnknownExit(
|
|
42474
|
-
|
|
42475
|
-
);
|
|
42487
|
+
const decoded = Schema_exports.decodeUnknownExit(
|
|
42488
|
+
Schema_exports.fromJsonString(ResponseFrame)
|
|
42489
|
+
)(raw.toString());
|
|
42476
42490
|
return Exit_exports.match(decoded, {
|
|
42477
42491
|
onFailure: (error3) => Effect_exports.sync(
|
|
42478
42492
|
() => console.error("[foldkit-devtools-mcp] failed to decode frame", error3)
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAyB,MAAM,QAAQ,CAAA;AAO7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AA0L3D,KAAK,UAAU,GAAG,QAAQ,CAAC;IACzB,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAA;IAChE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAC,CAAA;AAEF,8HAA8H;AAC9H,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;CACzD,CAAC,CAAA;AAsHF;;;;GAIG;AACH,eAAO,MAAM,UAAU,aACX,eAAe,KACxB,aAAa,CAAC,cAAc,CAsM9B,CAAA"}
|
package/dist/tools.js
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
import { Array, Effect, Match, Option, Schema
|
|
1
|
+
import { Array, Effect, Match, Option, Schema } from 'effect';
|
|
2
2
|
import { MAX_DISPATCH_BATCH_SIZE, Request, } from 'foldkit/devtools-protocol';
|
|
3
3
|
const RUNTIME_ID_DESCRIPTION = 'Optional connection id of a specific Foldkit runtime. Defaults to the most recently connected runtime.';
|
|
4
4
|
const DEFAULT_LIST_MESSAGES_LIMIT = 50;
|
|
5
|
-
const RuntimeIdField =
|
|
6
|
-
const ListLimit =
|
|
5
|
+
const RuntimeIdField = Schema.optional(Schema.String.annotate({ description: RUNTIME_ID_DESCRIPTION }));
|
|
6
|
+
const ListLimit = Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 500 })).annotate({
|
|
7
7
|
description: `Maximum number of entries to return. Defaults to ${DEFAULT_LIST_MESSAGES_LIMIT}; max 500.`,
|
|
8
8
|
});
|
|
9
|
-
const SinceIndex =
|
|
9
|
+
const SinceIndex = Schema.Int.annotate({
|
|
10
10
|
description: 'Absolute history index to start from. Use the maybeNextIndex returned by a prior call to paginate.',
|
|
11
11
|
});
|
|
12
|
-
const ChangedPathsMatchField =
|
|
12
|
+
const ChangedPathsMatchField = Schema.optional(Schema.Array(Schema.String).annotate({
|
|
13
13
|
description: "Dot-string path patterns matched against each entry's changedPaths, in the same 'root'-anchored alphabet foldkit_get_model uses. An entry matches when any pattern matches any changed path. Patterns compare segment-by-segment for the length of the shorter side, so 'root.grid' matches every change inside the grid subtree, and 'root.grid.5.3' also matches a wholesale replacement recorded at 'root.grid'. '*' matches exactly one segment: 'root.cards.*.title'. Entries that did not change the Model never match. An empty list applies no filter. Patterns not starting with 'root' or '*' are rejected.",
|
|
14
14
|
}));
|
|
15
|
-
const DiffChangedPathsMatchField =
|
|
15
|
+
const DiffChangedPathsMatchField = Schema.optional(Schema.Array(Schema.String).annotate({
|
|
16
16
|
description: "Dot-string path patterns narrowing the reported changes, in the same 'root'-anchored alphabet as changedPaths. A changed path is kept when any pattern matches it: patterns compare segment-by-segment for the length of the shorter side ('root.grid' keeps everything under the grid subtree) and '*' matches exactly one segment. An empty list applies no filter. Patterns not starting with 'root' or '*' are rejected.",
|
|
17
17
|
}));
|
|
18
|
-
const FromEndField =
|
|
18
|
+
const FromEndField = Schema.optional(Schema.Boolean.annotate({
|
|
19
19
|
description: "When true, return the final `limit` matching entries (the most recent) instead of the first, still in chronological order. The natural first call when live-debugging: 'what just happened'. Cannot be combined with since_index.",
|
|
20
20
|
}));
|
|
21
|
-
const DiffFromIndex =
|
|
21
|
+
const DiffFromIndex = Schema.Int.annotate({
|
|
22
22
|
description: 'Absolute history index of the diff baseline: the Model state right after this entry was applied. Use -1 for the initial Model.',
|
|
23
23
|
});
|
|
24
|
-
const DiffToIndex =
|
|
24
|
+
const DiffToIndex = Schema.Int.annotate({
|
|
25
25
|
description: 'Absolute history index of the diff target: the Model state right after this entry was applied. -1 addresses the initial Model.',
|
|
26
26
|
});
|
|
27
|
-
const MessageIndex =
|
|
27
|
+
const MessageIndex = Schema.Int.annotate({
|
|
28
28
|
description: 'Absolute history index of the entry to read.',
|
|
29
29
|
});
|
|
30
|
-
const KeyframeIndex =
|
|
30
|
+
const KeyframeIndex = Schema.Int.annotate({
|
|
31
31
|
description: 'Index to replay to. Use -1 to jump to the initial Model (before any messages). Use a non-negative index to jump to the Model state right after that history index. Call foldkit_list_keyframes for the canonical replay points.',
|
|
32
32
|
});
|
|
33
|
-
const ModelIndex =
|
|
33
|
+
const ModelIndex = Schema.Int.annotate({
|
|
34
34
|
description: 'Absolute history index. Returns the Model state right after the entry at this index was applied. To inspect the Model immediately before message N, pass index N - 1. For the initial Model, use foldkit_get_init.',
|
|
35
35
|
});
|
|
36
|
-
const PathField =
|
|
36
|
+
const PathField = Schema.optional(Schema.String.annotate({
|
|
37
37
|
description: "Dot-string path into the Model anchored at 'root'. Examples: 'root', 'root.route', 'root.session.user', 'root.cards.0'. Matches the alphabet used by SerializedEntry.changedPaths so paths copied from one tool's output can be passed straight into the next. Defaults to 'root' (the whole Model).",
|
|
38
38
|
}));
|
|
39
|
-
const ExpandField =
|
|
39
|
+
const ExpandField = Schema.optional(Schema.Boolean.annotate({
|
|
40
40
|
description: "When false (the default), large arrays/records/strings collapse to '_summary' placeholders to keep payloads small. Set true to receive the literal value at the path. Pair with `path` to drill in: a narrow path with `expand: true` is the cheapest way to read a specific subtree at full fidelity.",
|
|
41
41
|
}));
|
|
42
|
-
const GetModelInput =
|
|
42
|
+
const GetModelInput = Schema.Struct({
|
|
43
43
|
runtime_id: RuntimeIdField,
|
|
44
44
|
path: PathField,
|
|
45
45
|
expand: ExpandField,
|
|
46
46
|
});
|
|
47
|
-
const GetModelAtInput =
|
|
47
|
+
const GetModelAtInput = Schema.Struct({
|
|
48
48
|
runtime_id: RuntimeIdField,
|
|
49
49
|
index: ModelIndex,
|
|
50
50
|
path: PathField,
|
|
51
51
|
expand: ExpandField,
|
|
52
52
|
});
|
|
53
|
-
const ListMessagesInput =
|
|
53
|
+
const ListMessagesInput = Schema.Struct({
|
|
54
54
|
runtime_id: RuntimeIdField,
|
|
55
|
-
limit:
|
|
56
|
-
since_index:
|
|
55
|
+
limit: Schema.optional(ListLimit),
|
|
56
|
+
since_index: Schema.optional(SinceIndex),
|
|
57
57
|
changed_paths_match: ChangedPathsMatchField,
|
|
58
58
|
from_end: FromEndField,
|
|
59
59
|
});
|
|
60
|
-
const CountMessagesByTagInput =
|
|
60
|
+
const CountMessagesByTagInput = Schema.Struct({
|
|
61
61
|
runtime_id: RuntimeIdField,
|
|
62
|
-
since_index:
|
|
62
|
+
since_index: Schema.optional(SinceIndex),
|
|
63
63
|
changed_paths_match: ChangedPathsMatchField,
|
|
64
64
|
});
|
|
65
|
-
const DiffModelsInput =
|
|
65
|
+
const DiffModelsInput = Schema.Struct({
|
|
66
66
|
runtime_id: RuntimeIdField,
|
|
67
67
|
from_index: DiffFromIndex,
|
|
68
68
|
to_index: DiffToIndex,
|
|
69
69
|
changed_paths_match: DiffChangedPathsMatchField,
|
|
70
70
|
});
|
|
71
|
-
const GetMessageInput =
|
|
71
|
+
const GetMessageInput = Schema.Struct({
|
|
72
72
|
runtime_id: RuntimeIdField,
|
|
73
73
|
index: MessageIndex,
|
|
74
74
|
});
|
|
75
|
-
const ListKeyframesInput =
|
|
75
|
+
const ListKeyframesInput = Schema.Struct({
|
|
76
76
|
runtime_id: RuntimeIdField,
|
|
77
77
|
});
|
|
78
|
-
const ReplayToKeyframeInput =
|
|
78
|
+
const ReplayToKeyframeInput = Schema.Struct({
|
|
79
79
|
runtime_id: RuntimeIdField,
|
|
80
80
|
keyframe_index: KeyframeIndex,
|
|
81
81
|
});
|
|
82
|
-
const ResumeInput =
|
|
82
|
+
const ResumeInput = Schema.Struct({
|
|
83
83
|
runtime_id: RuntimeIdField,
|
|
84
84
|
});
|
|
85
|
-
const GetInitInput =
|
|
85
|
+
const GetInitInput = Schema.Struct({
|
|
86
86
|
runtime_id: RuntimeIdField,
|
|
87
87
|
});
|
|
88
|
-
const GetRuntimeStateInput =
|
|
88
|
+
const GetRuntimeStateInput = Schema.Struct({
|
|
89
89
|
runtime_id: RuntimeIdField,
|
|
90
90
|
});
|
|
91
|
-
const DispatchMessageInput =
|
|
91
|
+
const DispatchMessageInput = Schema.Struct({
|
|
92
92
|
runtime_id: RuntimeIdField,
|
|
93
|
-
message:
|
|
93
|
+
message: Schema.Record(Schema.String, Schema.Unknown).annotate({
|
|
94
94
|
description: "A Foldkit Message object to dispatch into the runtime. Must match the runtime's Message Schema. Call `foldkit_get_message_schema` with no arguments to see the available variant tags, then `foldkit_get_message_schema { variant_tag: \"X\" }` to learn one variant's exact payload shape. At minimum it has a `_tag` field naming the variant. The runtime decodes the payload and returns a clean error if it doesn't match.",
|
|
95
95
|
}),
|
|
96
96
|
});
|
|
97
|
-
const DispatchMessagesInput =
|
|
97
|
+
const DispatchMessagesInput = Schema.Struct({
|
|
98
98
|
runtime_id: RuntimeIdField,
|
|
99
|
-
messages:
|
|
100
|
-
.check(
|
|
99
|
+
messages: Schema.Array(Schema.Record(Schema.String, Schema.Unknown))
|
|
100
|
+
.check(Schema.isNonEmpty(), Schema.isMaxLength(MAX_DISPATCH_BATCH_SIZE))
|
|
101
101
|
.annotate({
|
|
102
102
|
description: `An ordered list of Foldkit Message objects to dispatch into the runtime, first to last. Must hold between 1 and ${MAX_DISPATCH_BATCH_SIZE} Messages. Each must match the runtime's Message Schema; call foldkit_get_message_schema to learn the shapes. The runtime decodes every entry before dispatching any of them, so one invalid entry rejects the whole batch with its zero-based position and nothing is dispatched.`,
|
|
103
103
|
}),
|
|
104
104
|
});
|
|
105
|
-
const VariantTagField =
|
|
105
|
+
const VariantTagField = Schema.optional(Schema.String.annotate({
|
|
106
106
|
description: 'Optional dot-separated path of variant `_tag` values. When omitted, the tool returns a small variant index (tag names plus payload field names plus a tagged-union indicator) so agents can enumerate the top-level union cheaply. When provided, the tool walks the path through each variant\'s single tagged-union payload field, narrows the schema along the chain, and collapses any union deeper than the path to a `{ "_summary": "union", "variants": [...] }` placeholder. Extend the path to drill further. Examples: `"ScrolledSidebar"` (one top-level variant), `"GotMobileMenuDialogMessage.GotAnimationMessage"` (two levels of a Submodel chain).',
|
|
107
107
|
}));
|
|
108
|
-
const GetMessageSchemaInput =
|
|
108
|
+
const GetMessageSchemaInput = Schema.Struct({
|
|
109
109
|
runtime_id: RuntimeIdField,
|
|
110
110
|
variant_tag: VariantTagField,
|
|
111
111
|
});
|
|
@@ -116,7 +116,7 @@ const GetMessageSchemaInput = S.Struct({
|
|
|
116
116
|
* `type` one level deeper, so registration silently fails. Unwrapping fixes
|
|
117
117
|
* tool surfacing in Claude Code, Cursor, and any other MCP host.
|
|
118
118
|
*/
|
|
119
|
-
const toInputSchema = (codec) =>
|
|
119
|
+
const toInputSchema = (codec) => Schema.toJsonSchemaDocument(codec).schema;
|
|
120
120
|
const NO_INPUT_SCHEMA = {
|
|
121
121
|
type: 'object',
|
|
122
122
|
properties: {},
|
|
@@ -139,7 +139,7 @@ const errorReason = (error) => error.message ? error.message : String(error);
|
|
|
139
139
|
* Decode a tool's raw input against its Effect Schema. Failure surfaces as an
|
|
140
140
|
* `Error` for the outer handler's `catchAll` to convert into a `ToolResult`.
|
|
141
141
|
*/
|
|
142
|
-
const decodeInput = (schema, rawInput) =>
|
|
142
|
+
const decodeInput = (schema, rawInput) => Schema.decodeUnknownEffect(schema)(rawInput).pipe(Effect.mapError(error => new Error(`Invalid input: ${error.message}`)));
|
|
143
143
|
/**
|
|
144
144
|
* Resolve a runtime id, defaulting to the most recently connected runtime when
|
|
145
145
|
* the caller did not specify one. Failures (no runtimes connected, relay
|
|
@@ -267,7 +267,7 @@ export const buildTools = (wsClient) => [
|
|
|
267
267
|
},
|
|
268
268
|
{
|
|
269
269
|
name: 'foldkit_get_message_schema',
|
|
270
|
-
description: 'Describe the Message Schema for a Foldkit runtime so agents can construct valid payloads for `foldkit_dispatch_message`. Call with no arguments to receive a small variant index (every top-level variant\'s `_tag`, its payload field names, and which payload fields are themselves tagged-union shapes). Then call with `variant_tag: "ChosenVariant"` to drill in. The argument is a dot-separated path of variant `_tag` values: each segment names a variant, and the walker steps through the variant\'s single tagged-union payload field to reach the next. So `"GotMobileMenuDialogMessage"` narrows one level; `"GotMobileMenuDialogMessage.GotAnimationMessage"` narrows two levels of a Submodel chain. Discriminated unions deeper than the supplied path collapse to `{ "_summary": "union", "variants": [...] }` placeholders so the response stays compact even for deeply-nested apps; extend the path to drill further. `
|
|
270
|
+
description: 'Describe the Message Schema for a Foldkit runtime so agents can construct valid payloads for `foldkit_dispatch_message`. Call with no arguments to receive a small variant index (every top-level variant\'s `_tag`, its payload field names, and which payload fields are themselves tagged-union shapes). Then call with `variant_tag: "ChosenVariant"` to drill in. The argument is a dot-separated path of variant `_tag` values: each segment names a variant, and the walker steps through the variant\'s single tagged-union payload field to reach the next. So `"GotMobileMenuDialogMessage"` narrows one level; `"GotMobileMenuDialogMessage.GotAnimationMessage"` narrows two levels of a Submodel chain. Discriminated unions deeper than the supplied path collapse to `{ "_summary": "union", "variants": [...] }` placeholders so the response stays compact even for deeply-nested apps; extend the path to drill further. `Schema.Option` fields render as `anyOf: [{_tag: "Some", value}, {_tag: "None"}]`. The full document follows the JSON Schema draft-2020-12 shape from `Schema.toJsonSchemaDocument`: `{ dialect, schema, definitions }`. Returns `maybeResult: None` when the runtime hasn\'t configured `DevToolsConfig.Message` (dispatch is also unavailable). Fields with no JSON representation, notably `Schema.instanceOf(File)` for user-uploaded files, render as `{type: "null"}`; those variants can\'t be dispatched via MCP because their values live in browser memory.',
|
|
271
271
|
inputSchema: toInputSchema(GetMessageSchemaInput),
|
|
272
272
|
handle: runRuntimeTool(GetMessageSchemaInput, ({ variant_tag }) => Request.RequestGetMessageSchema({
|
|
273
273
|
maybeVariantTag: Option.fromNullishOr(variant_tag),
|
package/dist/webSocketClient.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Console, Deferred, Duration, Effect, Exit, Fiber, HashMap, Option, Ref,
|
|
1
|
+
import { Console, Deferred, Duration, Effect, Exit, Fiber, HashMap, Option, Ref, Schedule, Schema, pipe, } from 'effect';
|
|
2
2
|
import { RequestFrame, ResponseFrame, } from 'foldkit/devtools-protocol';
|
|
3
3
|
import { WebSocket } from 'ws';
|
|
4
4
|
const REQUEST_TIMEOUT = Duration.seconds(10);
|
|
5
5
|
const INITIAL_RECONNECT_DELAY = Duration.millis(500);
|
|
6
6
|
const MAX_RECONNECT_DELAY = Duration.seconds(30);
|
|
7
|
-
const encodeRequestFrameToJson =
|
|
7
|
+
const encodeRequestFrameToJson = Schema.encodeUnknownSync(Schema.fromJsonString(RequestFrame));
|
|
8
8
|
const generateRequestId = () => `req-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
9
9
|
const reconnectSchedule = Schedule.exponential(INITIAL_RECONNECT_DELAY).pipe(Schedule.modifyDelay(({ duration }) => Effect.succeed(Duration.min(duration, MAX_RECONNECT_DELAY))));
|
|
10
10
|
const attemptOpen = (url) => Effect.callback(resume => {
|
|
@@ -119,7 +119,7 @@ export const connectWebSocketClient = (url) => Effect.gen(function* () {
|
|
|
119
119
|
return { sendRequest, close };
|
|
120
120
|
});
|
|
121
121
|
const handleIncomingMessage = (raw, pendingResponsesRef) => {
|
|
122
|
-
const decoded =
|
|
122
|
+
const decoded = Schema.decodeUnknownExit(Schema.fromJsonString(ResponseFrame))(raw.toString());
|
|
123
123
|
return Exit.match(decoded, {
|
|
124
124
|
onFailure: error => Effect.sync(() => console.error('[foldkit-devtools-mcp] failed to decode frame', error)),
|
|
125
125
|
onSuccess: responseFrame => Effect.gen(function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foldkit/devtools-mcp",
|
|
3
|
-
"version": "0.19.2-canary.
|
|
3
|
+
"version": "0.19.2-canary.fe9a895a47a8",
|
|
4
4
|
"description": "MCP server exposing Foldkit DevTools to AI agents (Claude Code, Cursor, etc.)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/server.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"effect": "4.0.0-rc.112",
|
|
20
|
-
"foldkit": "0.
|
|
20
|
+
"foldkit": "0.156.0-canary.fe9a895a47a8"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"esbuild": "^0.28.2",
|
|
31
31
|
"rimraf": "^6.1.3",
|
|
32
32
|
"typescript": "^7.0.2",
|
|
33
|
-
"foldkit": "0.
|
|
33
|
+
"foldkit": "0.156.0-canary.fe9a895a47a8"
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"dist"
|