@gtkx/mcp 0.21.0 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -34
- package/bin/gtkx-mcp.js +9 -1
- package/dist/app-router.d.ts +35 -0
- package/dist/app-router.d.ts.map +1 -0
- package/dist/app-router.js +143 -0
- package/dist/app-router.js.map +1 -0
- package/dist/connection-registry.d.ts +12 -0
- package/dist/connection-registry.d.ts.map +1 -0
- package/dist/connection-registry.js +39 -0
- package/dist/connection-registry.js.map +1 -0
- package/dist/internal.d.ts +4 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +1 -0
- package/dist/protocol/errors.d.ts +25 -87
- package/dist/protocol/errors.d.ts.map +1 -1
- package/dist/protocol/errors.js +38 -101
- package/dist/protocol/errors.js.map +1 -1
- package/dist/protocol/schemas.d.ts +93 -0
- package/dist/protocol/schemas.d.ts.map +1 -0
- package/dist/protocol/schemas.js +63 -0
- package/dist/protocol/schemas.js.map +1 -0
- package/dist/reference.d.ts +13 -0
- package/dist/reference.d.ts.map +1 -0
- package/dist/reference.js +293 -0
- package/dist/reference.js.map +1 -0
- package/dist/server.d.ts +14 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +244 -0
- package/dist/server.js.map +1 -0
- package/dist/socket-server.d.ts +5 -38
- package/dist/socket-server.d.ts.map +1 -1
- package/dist/socket-server.js +36 -108
- package/dist/socket-server.js.map +1 -1
- package/dist/tool.d.ts +22 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +40 -0
- package/dist/tool.js.map +1 -0
- package/dist/transport.d.ts +49 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +152 -0
- package/dist/transport.js.map +1 -0
- package/package.json +15 -11
- package/src/app-router.ts +209 -0
- package/src/connection-registry.ts +57 -0
- package/src/internal.ts +17 -0
- package/src/protocol/errors.ts +67 -110
- package/src/protocol/schemas.ts +173 -0
- package/src/reference.ts +449 -0
- package/src/server.ts +334 -0
- package/src/socket-server.ts +46 -147
- package/src/tool.ts +73 -0
- package/src/transport.ts +242 -0
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -399
- package/dist/cli.js.map +0 -1
- package/dist/connection-manager.d.ts +0 -48
- package/dist/connection-manager.d.ts.map +0 -1
- package/dist/connection-manager.js +0 -185
- package/dist/connection-manager.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -5
- package/dist/index.js.map +0 -1
- package/dist/protocol/types.d.ts +0 -132
- package/dist/protocol/types.d.ts.map +0 -1
- package/dist/protocol/types.js +0 -46
- package/dist/protocol/types.js.map +0 -1
- package/src/cli.ts +0 -449
- package/src/connection-manager.ts +0 -247
- package/src/index.ts +0 -27
- package/src/protocol/types.ts +0 -153
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/protocol/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/protocol/errors.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAE5D,QAAA,MAAM,SAAS;;;;;;;;;CASL,CAAC;AAEX,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,SAAS,CAEpD;AAED,iBAAS,mBAAmB,IAAI,aAAa,CAM5C;AAED,iBAAS,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAE9D;AAED,iBAAS,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAMxE;AAED,iBAAS,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAE5D;AAED,iBAAS,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAE3D;AAED,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAE1D;AAED,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAE1D;AAED,cAAM,aAAc,SAAQ,KAAK;IAC7B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;gBAEH,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;IAO5D,aAAa,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE;CAOrE;AAED,OAAO,EACH,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GAChB,CAAC"}
|
package/dist/protocol/errors.js
CHANGED
|
@@ -1,58 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export class McpError extends Error {
|
|
37
|
-
/** The MCP error code */
|
|
1
|
+
const ErrorCode = {
|
|
2
|
+
INTERNAL_ERROR: 1000,
|
|
3
|
+
NO_APP_CONNECTED: 1001,
|
|
4
|
+
APP_NOT_FOUND: 1002,
|
|
5
|
+
WIDGET_NOT_FOUND: 1003,
|
|
6
|
+
CONNECTION_WRITE_FAILED: 1004,
|
|
7
|
+
REQUEST_TIMEOUT: 1005,
|
|
8
|
+
INVALID_REQUEST: 1006,
|
|
9
|
+
METHOD_NOT_FOUND: 1007,
|
|
10
|
+
};
|
|
11
|
+
function isErrorCode(code) {
|
|
12
|
+
return Object.values(ErrorCode).includes(code);
|
|
13
|
+
}
|
|
14
|
+
function noAppConnectedError() {
|
|
15
|
+
return new ProtocolError(ErrorCode.NO_APP_CONNECTED, "No GTKX application connected: start an app with 'gtkx dev' to connect", { hint: "Run 'gtkx dev' in your project directory" });
|
|
16
|
+
}
|
|
17
|
+
function appNotFoundError(applicationId) {
|
|
18
|
+
return new ProtocolError(ErrorCode.APP_NOT_FOUND, `Application '${applicationId}' not found`, { applicationId });
|
|
19
|
+
}
|
|
20
|
+
function connectionWriteFailedError(applicationId) {
|
|
21
|
+
return new ProtocolError(ErrorCode.CONNECTION_WRITE_FAILED, `Connection to application '${applicationId}' is no longer writable`, { applicationId });
|
|
22
|
+
}
|
|
23
|
+
function widgetNotFoundError(widgetId) {
|
|
24
|
+
return new ProtocolError(ErrorCode.WIDGET_NOT_FOUND, `Widget '${widgetId}' not found`, { widgetId });
|
|
25
|
+
}
|
|
26
|
+
function requestTimeoutError(timeout) {
|
|
27
|
+
return new ProtocolError(ErrorCode.REQUEST_TIMEOUT, `Request timed out after ${String(timeout)}ms`, { timeout });
|
|
28
|
+
}
|
|
29
|
+
function invalidRequestError(reason) {
|
|
30
|
+
return new ProtocolError(ErrorCode.INVALID_REQUEST, `Invalid request: ${reason}`, { reason });
|
|
31
|
+
}
|
|
32
|
+
function methodNotFoundError(method) {
|
|
33
|
+
return new ProtocolError(ErrorCode.METHOD_NOT_FOUND, `Method '${method}' not found`, { method });
|
|
34
|
+
}
|
|
35
|
+
class ProtocolError extends Error {
|
|
38
36
|
code;
|
|
39
|
-
/** Additional error context */
|
|
40
37
|
data;
|
|
41
38
|
constructor(code, message, data) {
|
|
42
39
|
super(message);
|
|
43
40
|
this.code = code;
|
|
44
41
|
this.data = data;
|
|
45
|
-
this.name = "
|
|
46
|
-
if (Error.captureStackTrace) {
|
|
47
|
-
Error.captureStackTrace(this, McpError);
|
|
48
|
-
}
|
|
42
|
+
this.name = "ProtocolError";
|
|
49
43
|
}
|
|
50
|
-
|
|
51
|
-
* Converts the error to an IPC-compatible format.
|
|
52
|
-
*
|
|
53
|
-
* @returns Object suitable for IPC response error field
|
|
54
|
-
*/
|
|
55
|
-
toIpcError() {
|
|
44
|
+
toErrorObject() {
|
|
56
45
|
return {
|
|
57
46
|
code: this.code,
|
|
58
47
|
message: this.message,
|
|
@@ -60,57 +49,5 @@ export class McpError extends Error {
|
|
|
60
49
|
};
|
|
61
50
|
}
|
|
62
51
|
}
|
|
63
|
-
|
|
64
|
-
* Creates an error for when no GTKX application is connected.
|
|
65
|
-
*
|
|
66
|
-
* @returns McpError with NO_APP_CONNECTED code
|
|
67
|
-
*/
|
|
68
|
-
export function noAppConnectedError() {
|
|
69
|
-
return new McpError(McpErrorCode.NO_APP_CONNECTED, "No GTKX application connected: start an app with 'gtkx dev' to connect", { hint: "Run 'gtkx dev src/app.tsx' in your project directory" });
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Creates an error for when a requested app is not found.
|
|
73
|
-
*
|
|
74
|
-
* @param appId - The application ID that was not found
|
|
75
|
-
* @returns McpError with APP_NOT_FOUND code
|
|
76
|
-
*/
|
|
77
|
-
export function appNotFoundError(appId) {
|
|
78
|
-
return new McpError(McpErrorCode.APP_NOT_FOUND, `Application '${appId}' not found`, { appId });
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Creates an error for when a widget is not found.
|
|
82
|
-
*
|
|
83
|
-
* @param widgetId - The widget ID that was not found
|
|
84
|
-
* @returns McpError with WIDGET_NOT_FOUND code
|
|
85
|
-
*/
|
|
86
|
-
export function widgetNotFoundError(widgetId) {
|
|
87
|
-
return new McpError(McpErrorCode.WIDGET_NOT_FOUND, `Widget '${widgetId}' not found`, { widgetId });
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Creates an error for when an IPC request times out.
|
|
91
|
-
*
|
|
92
|
-
* @param timeout - The timeout duration in milliseconds
|
|
93
|
-
* @returns McpError with IPC_TIMEOUT code
|
|
94
|
-
*/
|
|
95
|
-
export function ipcTimeoutError(timeout) {
|
|
96
|
-
return new McpError(McpErrorCode.IPC_TIMEOUT, `IPC request timed out after ${timeout}ms`, { timeout });
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Creates an error for invalid request format.
|
|
100
|
-
*
|
|
101
|
-
* @param reason - Description of why the request is invalid
|
|
102
|
-
* @returns McpError with INVALID_REQUEST code
|
|
103
|
-
*/
|
|
104
|
-
export function invalidRequestError(reason) {
|
|
105
|
-
return new McpError(McpErrorCode.INVALID_REQUEST, `Invalid request: ${reason}`, { reason });
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Creates an error for when a method is not found.
|
|
109
|
-
*
|
|
110
|
-
* @param method - The method name that was not found
|
|
111
|
-
* @returns McpError with METHOD_NOT_FOUND code
|
|
112
|
-
*/
|
|
113
|
-
export function methodNotFoundError(method) {
|
|
114
|
-
return new McpError(McpErrorCode.METHOD_NOT_FOUND, `Method '${method}' not found`, { method });
|
|
115
|
-
}
|
|
52
|
+
export { ErrorCode, isErrorCode, noAppConnectedError, appNotFoundError, connectionWriteFailedError, widgetNotFoundError, requestTimeoutError, invalidRequestError, methodNotFoundError, ProtocolError, };
|
|
116
53
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/protocol/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/protocol/errors.ts"],"names":[],"mappings":"AAEA,MAAM,SA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BAAoB,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAClG,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAc;IACvC,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,gBAAgB,EAAE,WAAW,MAAM,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AACrG,CAAC;AAED,MAAM,aAAc,SAAQ,KAAK;IAC7B,IAAI,CAAY;IAChB,IAAI,CAAW;IAEf,YAAY,IAAe,EAAE,OAAe,EAAE,IAAc;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAChC,CAAC;IAED,aAAa;QACT,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;SACtD,CAAC;IACN,CAAC;CACJ;AAED,OAAO,EACH,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GAChB,CAAC","sourcesContent":["type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nconst ErrorCode = {\n INTERNAL_ERROR: 1000,\n NO_APP_CONNECTED: 1001,\n APP_NOT_FOUND: 1002,\n WIDGET_NOT_FOUND: 1003,\n CONNECTION_WRITE_FAILED: 1004,\n REQUEST_TIMEOUT: 1005,\n INVALID_REQUEST: 1006,\n METHOD_NOT_FOUND: 1007,\n} as const;\n\nfunction isErrorCode(code: number): code is ErrorCode {\n return (Object.values(ErrorCode) as number[]).includes(code);\n}\n\nfunction noAppConnectedError(): ProtocolError {\n return new ProtocolError(\n ErrorCode.NO_APP_CONNECTED,\n \"No GTKX application connected: start an app with 'gtkx dev' to connect\",\n { hint: \"Run 'gtkx dev' in your project directory\" },\n );\n}\n\nfunction appNotFoundError(applicationId: string): ProtocolError {\n return new ProtocolError(ErrorCode.APP_NOT_FOUND, `Application '${applicationId}' not found`, { applicationId });\n}\n\nfunction connectionWriteFailedError(applicationId: string): ProtocolError {\n return new ProtocolError(\n ErrorCode.CONNECTION_WRITE_FAILED,\n `Connection to application '${applicationId}' is no longer writable`,\n { applicationId },\n );\n}\n\nfunction widgetNotFoundError(widgetId: string): ProtocolError {\n return new ProtocolError(ErrorCode.WIDGET_NOT_FOUND, `Widget '${widgetId}' not found`, { widgetId });\n}\n\nfunction requestTimeoutError(timeout: number): ProtocolError {\n return new ProtocolError(ErrorCode.REQUEST_TIMEOUT, `Request timed out after ${String(timeout)}ms`, { timeout });\n}\n\nfunction invalidRequestError(reason: string): ProtocolError {\n return new ProtocolError(ErrorCode.INVALID_REQUEST, `Invalid request: ${reason}`, { reason });\n}\n\nfunction methodNotFoundError(method: string): ProtocolError {\n return new ProtocolError(ErrorCode.METHOD_NOT_FOUND, `Method '${method}' not found`, { method });\n}\n\nclass ProtocolError extends Error {\n code: ErrorCode;\n data?: unknown;\n\n constructor(code: ErrorCode, message: string, data?: unknown) {\n super(message);\n this.code = code;\n this.data = data;\n this.name = \"ProtocolError\";\n }\n\n toErrorObject(): { code: number; message: string; data?: unknown } {\n return {\n code: this.code,\n message: this.message,\n ...(this.data !== undefined && { data: this.data }),\n };\n }\n}\n\nexport {\n ErrorCode,\n isErrorCode,\n noAppConnectedError,\n appNotFoundError,\n connectionWriteFailedError,\n widgetNotFoundError,\n requestTimeoutError,\n invalidRequestError,\n methodNotFoundError,\n ProtocolError,\n};\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
type Request = z.infer<typeof RequestSchema>;
|
|
3
|
+
type Response = z.infer<typeof ResponseSchema>;
|
|
4
|
+
type SerializedWidget = {
|
|
5
|
+
id: string;
|
|
6
|
+
type: string;
|
|
7
|
+
role: string;
|
|
8
|
+
name: string | null;
|
|
9
|
+
text: string | null;
|
|
10
|
+
sensitive: boolean;
|
|
11
|
+
visible: boolean;
|
|
12
|
+
cssClasses: string[];
|
|
13
|
+
children: SerializedWidget[];
|
|
14
|
+
};
|
|
15
|
+
type AppInfo = {
|
|
16
|
+
applicationId: string;
|
|
17
|
+
pid: number;
|
|
18
|
+
projectRoot?: string;
|
|
19
|
+
};
|
|
20
|
+
type ServerRequestParams<Method extends keyof typeof ServerRequestParamsSchemas> = z.infer<(typeof ServerRequestParamsSchemas)[Method]>;
|
|
21
|
+
type ParamsSchema<Output> = z.ZodType<Output>;
|
|
22
|
+
type ServerInitiatedMethod = keyof typeof ServerRequestParamsSchemas;
|
|
23
|
+
type Message = Request | Response;
|
|
24
|
+
declare const RequestSchema: z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
method: z.ZodString;
|
|
27
|
+
params: z.ZodOptional<z.ZodUnknown>;
|
|
28
|
+
}>;
|
|
29
|
+
declare const ErrorSchema: z.ZodObject<{
|
|
30
|
+
code: z.ZodNumber;
|
|
31
|
+
message: z.ZodString;
|
|
32
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
33
|
+
}>;
|
|
34
|
+
declare const ResponseSchema: z.ZodObject<{
|
|
35
|
+
id: z.ZodString;
|
|
36
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
37
|
+
error: z.ZodOptional<typeof ErrorSchema>;
|
|
38
|
+
}>;
|
|
39
|
+
declare const RegisterParamsSchema: z.ZodObject<{
|
|
40
|
+
applicationId: z.ZodString;
|
|
41
|
+
pid: z.ZodNumber;
|
|
42
|
+
projectRoot: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}>;
|
|
44
|
+
declare const emptyParams: z.ZodObject<Record<string, never>>;
|
|
45
|
+
declare const widgetIdParams: z.ZodObject<{
|
|
46
|
+
widgetId: z.ZodString;
|
|
47
|
+
}>;
|
|
48
|
+
declare const treeParams: z.ZodObject<{
|
|
49
|
+
rootId: z.ZodOptional<z.ZodString>;
|
|
50
|
+
maxDepth: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
}>;
|
|
52
|
+
declare const queryOptionsSchema: z.ZodObject<{
|
|
53
|
+
name: z.ZodOptional<z.ZodString>;
|
|
54
|
+
exact: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
}>;
|
|
57
|
+
declare const queryParams: z.ZodObject<{
|
|
58
|
+
by: z.ZodEnum<{
|
|
59
|
+
role: "role";
|
|
60
|
+
text: "text";
|
|
61
|
+
name: "name";
|
|
62
|
+
labelText: "labelText";
|
|
63
|
+
}>;
|
|
64
|
+
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
65
|
+
options: z.ZodOptional<typeof queryOptionsSchema>;
|
|
66
|
+
}>;
|
|
67
|
+
declare const typeParams: z.ZodObject<{
|
|
68
|
+
widgetId: z.ZodString;
|
|
69
|
+
text: z.ZodString;
|
|
70
|
+
clear: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
}>;
|
|
72
|
+
declare const fireEventParams: z.ZodObject<{
|
|
73
|
+
widgetId: z.ZodString;
|
|
74
|
+
signal: z.ZodString;
|
|
75
|
+
args: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
76
|
+
}>;
|
|
77
|
+
declare const screenshotParams: z.ZodObject<{
|
|
78
|
+
windowId: z.ZodOptional<z.ZodString>;
|
|
79
|
+
path: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}>;
|
|
81
|
+
declare const ServerRequestParamsSchemas: {
|
|
82
|
+
"app.getWindows": typeof emptyParams;
|
|
83
|
+
"widget.getTree": typeof treeParams;
|
|
84
|
+
"widget.query": typeof queryParams;
|
|
85
|
+
"widget.getProps": typeof widgetIdParams;
|
|
86
|
+
"widget.click": typeof widgetIdParams;
|
|
87
|
+
"widget.type": typeof typeParams;
|
|
88
|
+
"widget.fireEvent": typeof fireEventParams;
|
|
89
|
+
"widget.screenshot": typeof screenshotParams;
|
|
90
|
+
};
|
|
91
|
+
declare const DEFAULT_SOCKET_PATH: string;
|
|
92
|
+
export { RequestSchema, ResponseSchema, RegisterParamsSchema, widgetIdParams, treeParams, queryOptionsSchema, queryParams, typeParams, fireEventParams, screenshotParams, ServerRequestParamsSchemas, DEFAULT_SOCKET_PATH, type Request, type Response, type SerializedWidget, type AppInfo, type ServerRequestParams, type ParamsSchema, type ServerInitiatedMethod, type Message, };
|
|
93
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/protocol/schemas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,KAAK,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAC7C,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE/C,KAAK,gBAAgB,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAChC,CAAC;AAEF,KAAK,OAAO,GAAG;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,mB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nB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACZ,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,OAAO,GACf,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { tmpdir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
const RequestSchema = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
method: z.string(),
|
|
7
|
+
params: z.unknown().optional(),
|
|
8
|
+
});
|
|
9
|
+
const ErrorSchema = z.object({
|
|
10
|
+
code: z.number(),
|
|
11
|
+
message: z.string(),
|
|
12
|
+
data: z.unknown().optional(),
|
|
13
|
+
});
|
|
14
|
+
const ResponseSchema = z.object({
|
|
15
|
+
id: z.string(),
|
|
16
|
+
result: z.unknown().optional(),
|
|
17
|
+
error: ErrorSchema.optional(),
|
|
18
|
+
});
|
|
19
|
+
const RegisterParamsSchema = z.object({
|
|
20
|
+
applicationId: z.string(),
|
|
21
|
+
pid: z.number(),
|
|
22
|
+
projectRoot: z.string().optional(),
|
|
23
|
+
});
|
|
24
|
+
const emptyParams = z.object({});
|
|
25
|
+
const widgetIdParams = z.object({
|
|
26
|
+
widgetId: z.string(),
|
|
27
|
+
});
|
|
28
|
+
const treeParams = z.object({
|
|
29
|
+
rootId: z.string().optional(),
|
|
30
|
+
maxDepth: z.number().int().positive().optional(),
|
|
31
|
+
});
|
|
32
|
+
const queryOptionsSchema = z.object({
|
|
33
|
+
name: z.string().optional(),
|
|
34
|
+
exact: z.boolean().optional(),
|
|
35
|
+
timeout: z.number().optional(),
|
|
36
|
+
});
|
|
37
|
+
const queryParams = z.object({
|
|
38
|
+
by: z.enum(["role", "text", "name", "labelText"]),
|
|
39
|
+
value: z.union([z.string(), z.number()]),
|
|
40
|
+
options: queryOptionsSchema.optional(),
|
|
41
|
+
});
|
|
42
|
+
const typeParams = z.object({ widgetId: z.string(), text: z.string(), clear: z.boolean().optional() });
|
|
43
|
+
const fireEventParams = z.object({ widgetId: z.string(), signal: z.string(), args: z.array(z.unknown()).optional() });
|
|
44
|
+
const screenshotParams = z.object({
|
|
45
|
+
windowId: z.string().optional(),
|
|
46
|
+
path: z.string().optional(),
|
|
47
|
+
});
|
|
48
|
+
const ServerRequestParamsSchemas = {
|
|
49
|
+
"app.getWindows": emptyParams,
|
|
50
|
+
"widget.getTree": treeParams,
|
|
51
|
+
"widget.query": queryParams,
|
|
52
|
+
"widget.getProps": widgetIdParams,
|
|
53
|
+
"widget.click": widgetIdParams,
|
|
54
|
+
"widget.type": typeParams,
|
|
55
|
+
"widget.fireEvent": fireEventParams,
|
|
56
|
+
"widget.screenshot": screenshotParams,
|
|
57
|
+
};
|
|
58
|
+
const DEFAULT_SOCKET_PATH = join(getRuntimeDir(), "gtkx-mcp.sock");
|
|
59
|
+
function getRuntimeDir() {
|
|
60
|
+
return process.env.XDG_RUNTIME_DIR ?? tmpdir();
|
|
61
|
+
}
|
|
62
|
+
export { RequestSchema, ResponseSchema, RegisterParamsSchema, widgetIdParams, treeParams, queryOptionsSchema, queryParams, typeParams, fireEventParams, screenshotParams, ServerRequestParamsSchemas, DEFAULT_SOCKET_PATH, };
|
|
63
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/protocol/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA+BxB,MAAM,aAAa,GAMf,CAAC,CAAC,MAAM,CAAC;IACT,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,MAAM,EAAE,C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E,cAAc;IACjC,cAAc,EAAE,cAAc;IAC9B,aAAa,EAAE,UAAU;IACzB,kBAAkB,EAAE,eAAe;IACnC,mBAAmB,EAAE,gBAAgB;CACxC,CAAC;AAEF,MAAM,mBAAmB,GAAW,IAAI,CAAC,aAAa,EAAE,EAAE,eAAe,CAAC,CAAC;AAE3E,SAAS,aAAa;IAClB,OAAO,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,MAAM,EAAE,CAAC;AACnD,CAAC;AAED,OAAO,EACH,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,GAStB,CAAC","sourcesContent":["import { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\n\ntype Request = z.infer<typeof RequestSchema>;\ntype Response = z.infer<typeof ResponseSchema>;\n\ntype SerializedWidget = {\n id: string;\n type: string;\n role: string;\n name: string | null;\n text: string | null;\n sensitive: boolean;\n visible: boolean;\n cssClasses: string[];\n children: SerializedWidget[];\n};\n\ntype AppInfo = {\n applicationId: string;\n pid: number;\n projectRoot?: string;\n};\n\ntype ServerRequestParams<Method extends keyof typeof ServerRequestParamsSchemas> = z.infer<\n (typeof ServerRequestParamsSchemas)[Method]\n>;\n\ntype ParamsSchema<Output> = z.ZodType<Output>;\ntype ServerInitiatedMethod = keyof typeof ServerRequestParamsSchemas;\ntype Message = Request | Response;\n\nconst RequestSchema: z.ZodObject<\n {\n id: z.ZodString;\n method: z.ZodString;\n params: z.ZodOptional<z.ZodUnknown>;\n }\n> = z.object({\n id: z.string(),\n method: z.string(),\n params: z.unknown().optional(),\n});\n\nconst ErrorSchema: z.ZodObject<\n { code: z.ZodNumber; message: z.ZodString; data: z.ZodOptional<z.ZodUnknown> }\n> = z.object({\n code: z.number(),\n message: z.string(),\n data: z.unknown().optional(),\n});\n\nconst ResponseSchema: z.ZodObject<\n {\n id: z.ZodString;\n result: z.ZodOptional<z.ZodUnknown>;\n error: z.ZodOptional<typeof ErrorSchema>;\n }\n> = z.object({\n id: z.string(),\n result: z.unknown().optional(),\n error: ErrorSchema.optional(),\n});\n\nconst RegisterParamsSchema: z.ZodObject<\n {\n applicationId: z.ZodString;\n pid: z.ZodNumber;\n projectRoot: z.ZodOptional<z.ZodString>;\n }\n> = z.object({\n applicationId: z.string(),\n pid: z.number(),\n projectRoot: z.string().optional(),\n});\n\nconst emptyParams: z.ZodObject<Record<string, never>> = z.object({});\n\nconst widgetIdParams: z.ZodObject<{ widgetId: z.ZodString }> = z.object({\n widgetId: z.string(),\n});\n\nconst treeParams: z.ZodObject<\n { rootId: z.ZodOptional<z.ZodString>; maxDepth: z.ZodOptional<z.ZodNumber> }\n> = z.object({\n rootId: z.string().optional(),\n maxDepth: z.number().int().positive().optional(),\n});\n\nconst queryOptionsSchema: z.ZodObject<\n { name: z.ZodOptional<z.ZodString>; exact: z.ZodOptional<z.ZodBoolean>; timeout: z.ZodOptional<z.ZodNumber> }\n> = z.object({\n name: z.string().optional(),\n exact: z.boolean().optional(),\n timeout: z.number().optional(),\n});\n\nconst queryParams: z.ZodObject<\n {\n by: z.ZodEnum<{ role: \"role\"; text: \"text\"; name: \"name\"; labelText: \"labelText\" }>;\n value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;\n options: z.ZodOptional<typeof queryOptionsSchema>;\n }\n> = z.object({\n by: z.enum([\"role\", \"text\", \"name\", \"labelText\"]),\n value: z.union([z.string(), z.number()]),\n options: queryOptionsSchema.optional(),\n});\n\nconst typeParams: z.ZodObject<\n { widgetId: z.ZodString; text: z.ZodString; clear: z.ZodOptional<z.ZodBoolean> }\n> = z.object({ widgetId: z.string(), text: z.string(), clear: z.boolean().optional() });\n\nconst fireEventParams: z.ZodObject<\n { widgetId: z.ZodString; signal: z.ZodString; args: z.ZodOptional<z.ZodArray<z.ZodUnknown>> }\n> = z.object({ widgetId: z.string(), signal: z.string(), args: z.array(z.unknown()).optional() });\n\nconst screenshotParams: z.ZodObject<\n { windowId: z.ZodOptional<z.ZodString>; path: z.ZodOptional<z.ZodString> }\n> = z.object({\n windowId: z.string().optional(),\n path: z.string().optional(),\n});\n\nconst ServerRequestParamsSchemas: {\n \"app.getWindows\": typeof emptyParams;\n \"widget.getTree\": typeof treeParams;\n \"widget.query\": typeof queryParams;\n \"widget.getProps\": typeof widgetIdParams;\n \"widget.click\": typeof widgetIdParams;\n \"widget.type\": typeof typeParams;\n \"widget.fireEvent\": typeof fireEventParams;\n \"widget.screenshot\": typeof screenshotParams;\n} = {\n \"app.getWindows\": emptyParams,\n \"widget.getTree\": treeParams,\n \"widget.query\": queryParams,\n \"widget.getProps\": widgetIdParams,\n \"widget.click\": widgetIdParams,\n \"widget.type\": typeParams,\n \"widget.fireEvent\": fireEventParams,\n \"widget.screenshot\": screenshotParams,\n};\n\nconst DEFAULT_SOCKET_PATH: string = join(getRuntimeDir(), \"gtkx-mcp.sock\");\n\nfunction getRuntimeDir(): string {\n return process.env.XDG_RUNTIME_DIR ?? tmpdir();\n}\n\nexport {\n RequestSchema,\n ResponseSchema,\n RegisterParamsSchema,\n widgetIdParams,\n treeParams,\n queryOptionsSchema,\n queryParams,\n typeParams,\n fireEventParams,\n screenshotParams,\n ServerRequestParamsSchemas,\n DEFAULT_SOCKET_PATH,\n type Request,\n type Response,\n type SerializedWidget,\n type AppInfo,\n type ServerRequestParams,\n type ParamsSchema,\n type ServerInitiatedMethod,\n type Message,\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ApiReference } from "@gtkx/codegen";
|
|
2
|
+
import { type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { type Tool } from "./tool.js";
|
|
4
|
+
type ReferenceApi = Pick<ApiReference, "lookup" | "namespaceOverview" | "namespaces" | "overview" | "search" | "symbolNames">;
|
|
5
|
+
type ReferenceProvider = {
|
|
6
|
+
get(): Promise<ReferenceApi>;
|
|
7
|
+
};
|
|
8
|
+
type ResourceServer = Pick<McpServer, "registerResource">;
|
|
9
|
+
declare const createReferenceProvider: (resolveRoot: () => string) => ReferenceProvider;
|
|
10
|
+
declare const buildReferenceTools: (provider: ReferenceProvider) => Tool[];
|
|
11
|
+
declare const registerReferenceResources: (server: ResourceServer, provider: ReferenceProvider) => void;
|
|
12
|
+
export { createReferenceProvider, buildReferenceTools, registerReferenceResources, type ReferenceApi, type ReferenceProvider, };
|
|
13
|
+
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../src/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAsE,MAAM,eAAe,CAAC;AAEtH,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AAK3F,OAAO,EAAsC,KAAK,IAAI,EAAiB,MAAM,WAAW,CAAC;AAEzF,KAAK,YAAY,GAAG,IAAI,CACpB,YAAY,EACZ,QAAQ,GAAG,mBAAmB,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,CACxF,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACrB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;CAChC,CAAC;AAqBF,KAAK,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;AA0I1D,QAAA,MAAM,uBAAuB,GAAI,aAAa,MAAM,MAAM,KAAG,iBAM5D,CAAC;AAwGF,QAAA,MAAM,mBAAmB,GAAI,UAAU,iBAAiB,KAAG,IAAI,EAI9D,CAAC;AAmJF,QAAA,MAAM,0BAA0B,GAAI,QAAQ,cAAc,EAAE,UAAU,iBAAiB,KAAG,IAIzF,CAAC;AAEF,OAAO,EACH,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,EAC1B,KAAK,YAAY,EACjB,KAAK,iBAAiB,GACzB,CAAC"}
|