@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
package/src/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export { ConnectionManager } from "./connection-manager.js";
|
|
2
|
-
export {
|
|
3
|
-
appNotFoundError,
|
|
4
|
-
invalidRequestError,
|
|
5
|
-
ipcTimeoutError,
|
|
6
|
-
McpError,
|
|
7
|
-
McpErrorCode,
|
|
8
|
-
methodNotFoundError,
|
|
9
|
-
noAppConnectedError,
|
|
10
|
-
widgetNotFoundError,
|
|
11
|
-
} from "./protocol/errors.js";
|
|
12
|
-
export {
|
|
13
|
-
type AppInfo,
|
|
14
|
-
DEFAULT_SOCKET_PATH,
|
|
15
|
-
getRuntimeDir,
|
|
16
|
-
type IpcError,
|
|
17
|
-
IpcErrorSchema,
|
|
18
|
-
type IpcMessage,
|
|
19
|
-
type IpcMethod,
|
|
20
|
-
type IpcRequest,
|
|
21
|
-
IpcRequestSchema,
|
|
22
|
-
type IpcResponse,
|
|
23
|
-
IpcResponseSchema,
|
|
24
|
-
type QueryOptions,
|
|
25
|
-
type SerializedWidget,
|
|
26
|
-
} from "./protocol/types.js";
|
|
27
|
-
export { type AppConnection, SocketServer } from "./socket-server.js";
|
package/src/protocol/types.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { tmpdir } from "node:os";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Zod schema for validating IPC requests.
|
|
7
|
-
*/
|
|
8
|
-
export const IpcRequestSchema = z.object({
|
|
9
|
-
id: z.string(),
|
|
10
|
-
method: z.string(),
|
|
11
|
-
params: z.unknown().optional(),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* An IPC request message.
|
|
16
|
-
*/
|
|
17
|
-
export type IpcRequest = z.infer<typeof IpcRequestSchema>;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* An IPC error object.
|
|
21
|
-
*/
|
|
22
|
-
export type IpcError = {
|
|
23
|
-
/** Error code */
|
|
24
|
-
code: number;
|
|
25
|
-
/** Error message */
|
|
26
|
-
message: string;
|
|
27
|
-
/** Additional error data */
|
|
28
|
-
data?: unknown;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Zod schema for validating IPC errors.
|
|
33
|
-
*/
|
|
34
|
-
export const IpcErrorSchema = z.object({
|
|
35
|
-
code: z.number(),
|
|
36
|
-
message: z.string(),
|
|
37
|
-
data: z.unknown().optional(),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Zod schema for validating IPC responses.
|
|
42
|
-
*/
|
|
43
|
-
export const IpcResponseSchema = z.object({
|
|
44
|
-
id: z.string(),
|
|
45
|
-
result: z.unknown().optional(),
|
|
46
|
-
error: IpcErrorSchema.optional(),
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* An IPC response message.
|
|
51
|
-
*/
|
|
52
|
-
export type IpcResponse = z.infer<typeof IpcResponseSchema>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* A serialized representation of a GTK widget for IPC transfer.
|
|
56
|
-
*/
|
|
57
|
-
export type SerializedWidget = {
|
|
58
|
-
/** Unique widget identifier */
|
|
59
|
-
id: string;
|
|
60
|
-
/** Widget type name (e.g., "GtkButton") */
|
|
61
|
-
type: string;
|
|
62
|
-
/** Accessible role */
|
|
63
|
-
role: string;
|
|
64
|
-
/** Widget name (test ID) */
|
|
65
|
-
name: string | null;
|
|
66
|
-
/** Accessible label */
|
|
67
|
-
label: string | null;
|
|
68
|
-
/** Text content */
|
|
69
|
-
text: string | null;
|
|
70
|
-
/** Whether the widget is sensitive (interactive) */
|
|
71
|
-
sensitive: boolean;
|
|
72
|
-
/** Whether the widget is visible */
|
|
73
|
-
visible: boolean;
|
|
74
|
-
/** CSS class names */
|
|
75
|
-
cssClasses: string[];
|
|
76
|
-
/** Child widgets */
|
|
77
|
-
children: SerializedWidget[];
|
|
78
|
-
/** Widget bounds in window coordinates */
|
|
79
|
-
bounds?: {
|
|
80
|
-
x: number;
|
|
81
|
-
y: number;
|
|
82
|
-
width: number;
|
|
83
|
-
height: number;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Information about a connected GTKX application.
|
|
89
|
-
*/
|
|
90
|
-
export type AppInfo = {
|
|
91
|
-
/** Application ID (e.g., "com.example.myapp") */
|
|
92
|
-
appId: string;
|
|
93
|
-
/** Process ID */
|
|
94
|
-
pid: number;
|
|
95
|
-
/** Open windows */
|
|
96
|
-
windows: Array<{
|
|
97
|
-
id: string;
|
|
98
|
-
title: string | null;
|
|
99
|
-
}>;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Options for widget queries.
|
|
104
|
-
*/
|
|
105
|
-
export type QueryOptions = {
|
|
106
|
-
/** Widget name to match */
|
|
107
|
-
name?: string;
|
|
108
|
-
/** Require exact match */
|
|
109
|
-
exact?: boolean;
|
|
110
|
-
/** Query timeout in milliseconds */
|
|
111
|
-
timeout?: number;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Zod schema for app registration parameters.
|
|
116
|
-
* @internal
|
|
117
|
-
*/
|
|
118
|
-
export const RegisterParamsSchema = z.object({
|
|
119
|
-
appId: z.string(),
|
|
120
|
-
pid: z.number(),
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Available IPC methods.
|
|
125
|
-
*/
|
|
126
|
-
export type IpcMethod =
|
|
127
|
-
| "app.register"
|
|
128
|
-
| "app.unregister"
|
|
129
|
-
| "app.getWindows"
|
|
130
|
-
| "widget.getTree"
|
|
131
|
-
| "widget.query"
|
|
132
|
-
| "widget.getProps"
|
|
133
|
-
| "widget.click"
|
|
134
|
-
| "widget.type"
|
|
135
|
-
| "widget.fireEvent"
|
|
136
|
-
| "widget.screenshot";
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Union type for any IPC message (request or response).
|
|
140
|
-
*/
|
|
141
|
-
export type IpcMessage = IpcRequest | IpcResponse;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Gets the XDG runtime directory or falls back to system temp.
|
|
145
|
-
*
|
|
146
|
-
* @returns Path to the runtime directory
|
|
147
|
-
*/
|
|
148
|
-
export const getRuntimeDir = (): string => process.env.XDG_RUNTIME_DIR ?? tmpdir();
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Default path for the MCP socket file.
|
|
152
|
-
*/
|
|
153
|
-
export const DEFAULT_SOCKET_PATH = join(getRuntimeDir(), "gtkx-mcp.sock");
|