@muggleai/mcp 1.0.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/README.md +160 -0
- package/bin/muggle-mcp.js +2 -0
- package/dist/chunk-6DQWAMGJ.js +7626 -0
- package/dist/chunk-6DQWAMGJ.js.map +1 -0
- package/dist/cli/doctor.d.ts +8 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/login.d.ts +26 -0
- package/dist/cli/login.d.ts.map +1 -0
- package/dist/cli/main.d.ts +6 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/serve.d.ts +20 -0
- package/dist/cli/serve.d.ts.map +1 -0
- package/dist/cli/setup.d.ts +16 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli.js +305 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/local-qa/contracts/auth-schemas.d.ts +35 -0
- package/dist/local-qa/contracts/auth-schemas.d.ts.map +1 -0
- package/dist/local-qa/contracts/index.d.ts +7 -0
- package/dist/local-qa/contracts/index.d.ts.map +1 -0
- package/dist/local-qa/contracts/project-schemas.d.ts +1141 -0
- package/dist/local-qa/contracts/project-schemas.d.ts.map +1 -0
- package/dist/local-qa/contracts/session-schemas.d.ts +27 -0
- package/dist/local-qa/contracts/session-schemas.d.ts.map +1 -0
- package/dist/local-qa/index.d.ts +27 -0
- package/dist/local-qa/index.d.ts.map +1 -0
- package/dist/local-qa/services/auth-service.d.ts +79 -0
- package/dist/local-qa/services/auth-service.d.ts.map +1 -0
- package/dist/local-qa/services/execution-service.d.ts +55 -0
- package/dist/local-qa/services/execution-service.d.ts.map +1 -0
- package/dist/local-qa/services/index.d.ts +8 -0
- package/dist/local-qa/services/index.d.ts.map +1 -0
- package/dist/local-qa/services/project-storage-service.d.ts +262 -0
- package/dist/local-qa/services/project-storage-service.d.ts.map +1 -0
- package/dist/local-qa/services/storage-service.d.ts +166 -0
- package/dist/local-qa/services/storage-service.d.ts.map +1 -0
- package/dist/local-qa/tools/index.d.ts +5 -0
- package/dist/local-qa/tools/index.d.ts.map +1 -0
- package/dist/local-qa/tools/tool-registry.d.ts +18 -0
- package/dist/local-qa/tools/tool-registry.d.ts.map +1 -0
- package/dist/local-qa/types/auth-types.d.ts +97 -0
- package/dist/local-qa/types/auth-types.d.ts.map +1 -0
- package/dist/local-qa/types/config-types.d.ts +28 -0
- package/dist/local-qa/types/config-types.d.ts.map +1 -0
- package/dist/local-qa/types/enums.d.ts +141 -0
- package/dist/local-qa/types/enums.d.ts.map +1 -0
- package/dist/local-qa/types/index.d.ts +10 -0
- package/dist/local-qa/types/index.d.ts.map +1 -0
- package/dist/local-qa/types/project-types.d.ts +339 -0
- package/dist/local-qa/types/project-types.d.ts.map +1 -0
- package/dist/local-qa/types/storage-params.d.ts +544 -0
- package/dist/local-qa/types/storage-params.d.ts.map +1 -0
- package/dist/local-qa/types/tool-types.d.ts +38 -0
- package/dist/local-qa/types/tool-types.d.ts.map +1 -0
- package/dist/qa/contracts/index.d.ts +716 -0
- package/dist/qa/contracts/index.d.ts.map +1 -0
- package/dist/qa/index.d.ts +15 -0
- package/dist/qa/index.d.ts.map +1 -0
- package/dist/qa/tools/index.d.ts +5 -0
- package/dist/qa/tools/index.d.ts.map +1 -0
- package/dist/qa/tools/tool-registry.d.ts +22 -0
- package/dist/qa/tools/tool-registry.d.ts.map +1 -0
- package/dist/qa/types.d.ts +101 -0
- package/dist/qa/types.d.ts.map +1 -0
- package/dist/qa/upstream-client.d.ts +60 -0
- package/dist/qa/upstream-client.d.ts.map +1 -0
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/mcp-server.d.ts +34 -0
- package/dist/server/mcp-server.d.ts.map +1 -0
- package/dist/server/stdio-server.d.ts +11 -0
- package/dist/server/stdio-server.d.ts.map +1 -0
- package/dist/shared/auth.d.ts +75 -0
- package/dist/shared/auth.d.ts.map +1 -0
- package/dist/shared/config.d.ts +41 -0
- package/dist/shared/config.d.ts.map +1 -0
- package/dist/shared/credentials.d.ts +48 -0
- package/dist/shared/credentials.d.ts.map +1 -0
- package/dist/shared/index.d.ts +10 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/logger.d.ts +21 -0
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/open-browser.d.ts +27 -0
- package/dist/shared/open-browser.d.ts.map +1 -0
- package/dist/shared/types.d.ts +178 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/package.json +75 -0
- package/scripts/postinstall.mjs +153 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type definitions for @muggleai/mcp.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Auth0 configuration for device code flow.
|
|
6
|
+
*/
|
|
7
|
+
export interface IAuth0Config {
|
|
8
|
+
/** Auth0 domain (e.g., login.muggle-ai.com). */
|
|
9
|
+
domain: string;
|
|
10
|
+
/** Auth0 client ID for device code grant. */
|
|
11
|
+
clientId: string;
|
|
12
|
+
/** Auth0 API audience. */
|
|
13
|
+
audience: string;
|
|
14
|
+
/** OAuth scopes to request. */
|
|
15
|
+
scope: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Stored credentials from device code authentication.
|
|
19
|
+
*/
|
|
20
|
+
export interface IStoredCredentials {
|
|
21
|
+
/** Access token for API calls. */
|
|
22
|
+
accessToken: string;
|
|
23
|
+
/** Token expiration timestamp (ISO string). */
|
|
24
|
+
expiresAt: string;
|
|
25
|
+
/** User ID. */
|
|
26
|
+
userId?: string;
|
|
27
|
+
/** User email. */
|
|
28
|
+
email?: string;
|
|
29
|
+
/** API key (if created). */
|
|
30
|
+
apiKey?: string;
|
|
31
|
+
/** API key ID (if created). */
|
|
32
|
+
apiKeyId?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for QA Gateway (cloud) operations.
|
|
36
|
+
*/
|
|
37
|
+
export interface IQaConfig {
|
|
38
|
+
/** Base URL of the prompt service backend. */
|
|
39
|
+
promptServiceBaseUrl: string;
|
|
40
|
+
/** Request timeout in milliseconds. */
|
|
41
|
+
requestTimeoutMs: number;
|
|
42
|
+
/** Workflow timeout in milliseconds. */
|
|
43
|
+
workflowTimeoutMs: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for Local QA operations.
|
|
47
|
+
*/
|
|
48
|
+
export interface ILocalQaConfig {
|
|
49
|
+
/** Base URL of the local web-service. */
|
|
50
|
+
webServiceUrl: string;
|
|
51
|
+
/** Base URL of the prompt service (for cloud sync). */
|
|
52
|
+
promptServiceUrl: string;
|
|
53
|
+
/** Path to data directory. */
|
|
54
|
+
dataDir: string;
|
|
55
|
+
/** Path to sessions directory. */
|
|
56
|
+
sessionsDir: string;
|
|
57
|
+
/** Path to projects directory. */
|
|
58
|
+
projectsDir: string;
|
|
59
|
+
/** Path to temp directory. */
|
|
60
|
+
tempDir: string;
|
|
61
|
+
/** Path to credentials file. */
|
|
62
|
+
credentialsFilePath: string;
|
|
63
|
+
/** Path to auth file (local auth storage). */
|
|
64
|
+
authFilePath: string;
|
|
65
|
+
/** Path to electron-app executable (null if not installed). */
|
|
66
|
+
electronAppPath: string | null;
|
|
67
|
+
/** Path to web-service entry point (null if not found). */
|
|
68
|
+
webServicePath: string | null;
|
|
69
|
+
/** Path to web-service PID file. */
|
|
70
|
+
webServicePidFile: string;
|
|
71
|
+
/** Auth0 configuration for local auth. */
|
|
72
|
+
auth0: ILocalAuth0Config;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Auth0 configuration for local auth (with scopes array).
|
|
76
|
+
*/
|
|
77
|
+
export interface ILocalAuth0Config {
|
|
78
|
+
/** Auth0 domain. */
|
|
79
|
+
domain: string;
|
|
80
|
+
/** Auth0 client ID. */
|
|
81
|
+
clientId: string;
|
|
82
|
+
/** Auth0 audience. */
|
|
83
|
+
audience: string;
|
|
84
|
+
/** OAuth scopes to request (as array). */
|
|
85
|
+
scopes: string[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Unified configuration for @muggleai/mcp.
|
|
89
|
+
*/
|
|
90
|
+
export interface IConfig {
|
|
91
|
+
/** Server name for MCP protocol. */
|
|
92
|
+
serverName: string;
|
|
93
|
+
/** Server version. */
|
|
94
|
+
serverVersion: string;
|
|
95
|
+
/** Log level. */
|
|
96
|
+
logLevel: string;
|
|
97
|
+
/** Auth0 configuration. */
|
|
98
|
+
auth0: IAuth0Config;
|
|
99
|
+
/** QA Gateway configuration. */
|
|
100
|
+
qa: IQaConfig;
|
|
101
|
+
/** Local QA configuration. */
|
|
102
|
+
localQa: ILocalQaConfig;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Caller credentials for API requests.
|
|
106
|
+
*/
|
|
107
|
+
export interface ICallerCredentials {
|
|
108
|
+
/** Bearer token (from device code flow or config). */
|
|
109
|
+
bearerToken?: string;
|
|
110
|
+
/** API key (from device code flow or config). */
|
|
111
|
+
apiKey?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Device code flow response from Auth0.
|
|
115
|
+
*/
|
|
116
|
+
export interface IDeviceCodeResponse {
|
|
117
|
+
/** Device code for polling. */
|
|
118
|
+
deviceCode: string;
|
|
119
|
+
/** User-visible code to enter. */
|
|
120
|
+
userCode: string;
|
|
121
|
+
/** URL for user to visit. */
|
|
122
|
+
verificationUri: string;
|
|
123
|
+
/** URL with code pre-filled. */
|
|
124
|
+
verificationUriComplete: string;
|
|
125
|
+
/** Seconds until code expires. */
|
|
126
|
+
expiresIn: number;
|
|
127
|
+
/** Polling interval in seconds. */
|
|
128
|
+
interval: number;
|
|
129
|
+
/** Whether browser was successfully opened. */
|
|
130
|
+
browserOpened: boolean;
|
|
131
|
+
/** Error message if browser failed to open. */
|
|
132
|
+
browserOpenError?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Device code poll response.
|
|
136
|
+
*/
|
|
137
|
+
export interface IDeviceCodePollResponse {
|
|
138
|
+
/** Poll status. */
|
|
139
|
+
status: "authorized" | "authorization_pending" | "slow_down" | "expired_token" | "access_denied";
|
|
140
|
+
/** Access token (when authorized). */
|
|
141
|
+
accessToken?: string;
|
|
142
|
+
/** Token type (when authorized). */
|
|
143
|
+
tokenType?: string;
|
|
144
|
+
/** Token expiry in seconds (when authorized). */
|
|
145
|
+
expiresIn?: number;
|
|
146
|
+
/** Error code (when not authorized). */
|
|
147
|
+
error?: string;
|
|
148
|
+
/** Error description (when not authorized). */
|
|
149
|
+
errorDescription?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* MCP tool result structure.
|
|
153
|
+
*/
|
|
154
|
+
export interface IMcpToolResult {
|
|
155
|
+
/** Result content (text). */
|
|
156
|
+
content: string;
|
|
157
|
+
/** Whether this is an error result. */
|
|
158
|
+
isError?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* MCP tool definition.
|
|
162
|
+
*/
|
|
163
|
+
export interface IMcpTool {
|
|
164
|
+
/** Tool name. */
|
|
165
|
+
name: string;
|
|
166
|
+
/** Tool description. */
|
|
167
|
+
description: string;
|
|
168
|
+
/** Input schema (Zod schema). */
|
|
169
|
+
inputSchema: unknown;
|
|
170
|
+
/** Whether tool requires authentication (default: true for QA tools). */
|
|
171
|
+
requiresAuth?: boolean;
|
|
172
|
+
/** Execute the tool. */
|
|
173
|
+
execute: (params: {
|
|
174
|
+
input: unknown;
|
|
175
|
+
correlationId: string;
|
|
176
|
+
}) => Promise<IMcpToolResult>;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","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AC;IACvB,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,mBAAmB;IACnB,MAAM,EAAE,YAAY,GAAG,uBAAuB,GAAG,WAAW,GAAG,eAAe,GAAG,eAAe,CAAC;IACjG,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,WAAW,EAAE,OAAO,CAAC;IACrB,yEAAyE;IACzE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wBAAwB;IACxB,OAAO,EAAE,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CACzF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@muggleai/mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Unified MCP server for Muggle AI - Cloud QA and Local Testing tools",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"muggle-mcp": "bin/muggle-mcp.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"bin/muggle-mcp.js",
|
|
14
|
+
"scripts/postinstall.mjs"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"clean": "rimraf dist",
|
|
18
|
+
"build": "tsup && tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
19
|
+
"build:release": "npm run build",
|
|
20
|
+
"postinstall": "node scripts/postinstall.mjs",
|
|
21
|
+
"start": "node dist/index.js",
|
|
22
|
+
"dev": "tsx watch src/index.ts",
|
|
23
|
+
"lint": "eslint . --fix",
|
|
24
|
+
"lint:check": "eslint .",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:watch": "vitest"
|
|
27
|
+
},
|
|
28
|
+
"muggleConfig": {
|
|
29
|
+
"electronAppVersion": "1.0.0",
|
|
30
|
+
"downloadBaseUrl": "https://github.com/multiplex-ai/muggle-ai-mcp/releases/download"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@modelcontextprotocol/sdk": "^1.25.3",
|
|
34
|
+
"axios": "^1.7.9",
|
|
35
|
+
"commander": "^12.0.0",
|
|
36
|
+
"open": "^10.0.0",
|
|
37
|
+
"ulid": "^2.3.0",
|
|
38
|
+
"uuid": "^10.0.0",
|
|
39
|
+
"winston": "^3.17.0",
|
|
40
|
+
"zod": "^3.24.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^9.21.0",
|
|
44
|
+
"@types/node": "^22.0.0",
|
|
45
|
+
"@types/uuid": "^10.0.0",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
|
47
|
+
"@typescript-eslint/parser": "^8.34.0",
|
|
48
|
+
"eslint": "^9.28.0",
|
|
49
|
+
"eslint-plugin-unused-imports": "^4.2.0",
|
|
50
|
+
"rimraf": "^6.0.1",
|
|
51
|
+
"tsup": "^8.5.1",
|
|
52
|
+
"tsx": "^4.19.2",
|
|
53
|
+
"typescript": "^5.7.3",
|
|
54
|
+
"vitest": "^4.0.18"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=22.0.0"
|
|
58
|
+
},
|
|
59
|
+
"keywords": [
|
|
60
|
+
"mcp",
|
|
61
|
+
"model-context-protocol",
|
|
62
|
+
"muggle-ai",
|
|
63
|
+
"qa",
|
|
64
|
+
"testing",
|
|
65
|
+
"automation",
|
|
66
|
+
"localhost"
|
|
67
|
+
],
|
|
68
|
+
"author": "Muggle AI",
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"repository": {
|
|
71
|
+
"type": "git",
|
|
72
|
+
"url": "https://github.com/multiplex-ai/muggle-ai-mcp.git"
|
|
73
|
+
},
|
|
74
|
+
"homepage": "https://www.muggle-ai.com/muggleTestV0/docs/mcp/mcp-overview"
|
|
75
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall script for @muggleai/mcp.
|
|
4
|
+
* Downloads the Electron app binary for local testing.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { exec } from "child_process";
|
|
8
|
+
import { createWriteStream, existsSync, mkdirSync, rmSync } from "fs";
|
|
9
|
+
import { homedir, platform } from "os";
|
|
10
|
+
import { join } from "path";
|
|
11
|
+
import { pipeline } from "stream/promises";
|
|
12
|
+
import { createRequire } from "module";
|
|
13
|
+
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get the Muggle AI data directory.
|
|
18
|
+
* @returns {string} Path to ~/.muggle-ai
|
|
19
|
+
*/
|
|
20
|
+
function getDataDir() {
|
|
21
|
+
return join(homedir(), ".muggle-ai");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get the Electron app directory.
|
|
26
|
+
* @returns {string} Path to ~/.muggle-ai/electron-app
|
|
27
|
+
*/
|
|
28
|
+
function getElectronAppDir() {
|
|
29
|
+
return join(getDataDir(), "electron-app");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get platform-specific binary name.
|
|
34
|
+
* @returns {string} Binary filename
|
|
35
|
+
*/
|
|
36
|
+
function getBinaryName() {
|
|
37
|
+
const os = platform();
|
|
38
|
+
const arch = process.arch;
|
|
39
|
+
|
|
40
|
+
switch (os) {
|
|
41
|
+
case "darwin":
|
|
42
|
+
// Support both Apple Silicon (arm64) and Intel (x64) Macs
|
|
43
|
+
return arch === "arm64"
|
|
44
|
+
? "MuggleAI-darwin-arm64.zip"
|
|
45
|
+
: "MuggleAI-darwin-x64.zip";
|
|
46
|
+
case "win32":
|
|
47
|
+
return "MuggleAI-win32-x64.zip";
|
|
48
|
+
case "linux":
|
|
49
|
+
return "MuggleAI-linux-x64.zip";
|
|
50
|
+
default:
|
|
51
|
+
throw new Error(`Unsupported platform: ${os}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Download and extract the Electron app.
|
|
57
|
+
*/
|
|
58
|
+
async function downloadElectronApp() {
|
|
59
|
+
try {
|
|
60
|
+
// Read config from package.json
|
|
61
|
+
const packageJson = require("../package.json");
|
|
62
|
+
const config = packageJson.muggleConfig || {};
|
|
63
|
+
const version = config.electronAppVersion || "1.0.0";
|
|
64
|
+
const baseUrl = config.downloadBaseUrl || "https://github.com/multiplex-ai/muggle-ai-mcp/releases/download";
|
|
65
|
+
|
|
66
|
+
const binaryName = getBinaryName();
|
|
67
|
+
const downloadUrl = `${baseUrl}/electron-app-v${version}/${binaryName}`;
|
|
68
|
+
|
|
69
|
+
const appDir = getElectronAppDir();
|
|
70
|
+
const versionDir = join(appDir, version);
|
|
71
|
+
|
|
72
|
+
// Check if already downloaded
|
|
73
|
+
if (existsSync(versionDir)) {
|
|
74
|
+
console.log(`Electron app v${version} already installed at ${versionDir}`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log(`Downloading Muggle Test Electron app v${version}...`);
|
|
79
|
+
console.log(`URL: ${downloadUrl}`);
|
|
80
|
+
|
|
81
|
+
// Create directories
|
|
82
|
+
mkdirSync(versionDir, { recursive: true });
|
|
83
|
+
|
|
84
|
+
// Download using fetch
|
|
85
|
+
const response = await fetch(downloadUrl);
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
throw new Error(`Download failed: ${response.status} ${response.statusText}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const tempFile = join(versionDir, binaryName);
|
|
91
|
+
const fileStream = createWriteStream(tempFile);
|
|
92
|
+
await pipeline(response.body, fileStream);
|
|
93
|
+
|
|
94
|
+
console.log("Download complete, extracting...");
|
|
95
|
+
|
|
96
|
+
// Extract based on file type
|
|
97
|
+
if (binaryName.endsWith(".zip")) {
|
|
98
|
+
await extractZip(tempFile, versionDir);
|
|
99
|
+
} else if (binaryName.endsWith(".tar.gz")) {
|
|
100
|
+
await extractTarGz(tempFile, versionDir);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Clean up temp file
|
|
104
|
+
rmSync(tempFile, { force: true });
|
|
105
|
+
|
|
106
|
+
console.log(`Electron app installed to ${versionDir}`);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.warn("Warning: Failed to download Electron app.");
|
|
109
|
+
console.warn("You can manually download it later using: muggle-mcp setup");
|
|
110
|
+
console.warn(`Error: ${error.message}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Extract a zip file.
|
|
116
|
+
* @param {string} zipPath - Path to zip file
|
|
117
|
+
* @param {string} destDir - Destination directory
|
|
118
|
+
*/
|
|
119
|
+
async function extractZip(zipPath, destDir) {
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
const cmd = platform() === "win32"
|
|
122
|
+
? `powershell -command "Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force"`
|
|
123
|
+
: `unzip -o "${zipPath}" -d "${destDir}"`;
|
|
124
|
+
|
|
125
|
+
exec(cmd, (error) => {
|
|
126
|
+
if (error) {
|
|
127
|
+
reject(error);
|
|
128
|
+
} else {
|
|
129
|
+
resolve();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Extract a tar.gz file.
|
|
137
|
+
* @param {string} tarPath - Path to tar.gz file
|
|
138
|
+
* @param {string} destDir - Destination directory
|
|
139
|
+
*/
|
|
140
|
+
async function extractTarGz(tarPath, destDir) {
|
|
141
|
+
return new Promise((resolve, reject) => {
|
|
142
|
+
exec(`tar -xzf "${tarPath}" -C "${destDir}"`, (error) => {
|
|
143
|
+
if (error) {
|
|
144
|
+
reject(error);
|
|
145
|
+
} else {
|
|
146
|
+
resolve();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Run postinstall
|
|
153
|
+
downloadElectronApp().catch(console.error);
|