@gxp-dev/tools 2.0.62 → 2.0.64
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 +32 -31
- package/bin/gx-devtools.js +74 -54
- package/bin/lib/cli.js +23 -21
- package/bin/lib/commands/add-dependency.js +366 -325
- package/bin/lib/commands/assets.js +137 -139
- package/bin/lib/commands/build.js +169 -174
- package/bin/lib/commands/datastore.js +181 -183
- package/bin/lib/commands/dev.js +127 -131
- package/bin/lib/commands/extensions.js +147 -149
- package/bin/lib/commands/extract-config.js +73 -67
- package/bin/lib/commands/index.js +12 -12
- package/bin/lib/commands/init.js +342 -240
- package/bin/lib/commands/publish.js +69 -75
- package/bin/lib/commands/socket.js +69 -69
- package/bin/lib/commands/ssl.js +14 -14
- package/bin/lib/constants.js +10 -24
- package/bin/lib/tui/App.tsx +761 -705
- package/bin/lib/tui/components/AIPanel.tsx +191 -171
- package/bin/lib/tui/components/CommandInput.tsx +394 -343
- package/bin/lib/tui/components/GeminiPanel.tsx +175 -151
- package/bin/lib/tui/components/Header.tsx +23 -21
- package/bin/lib/tui/components/LogPanel.tsx +244 -220
- package/bin/lib/tui/components/TabBar.tsx +50 -48
- package/bin/lib/tui/components/WelcomeScreen.tsx +126 -71
- package/bin/lib/tui/index.tsx +37 -39
- package/bin/lib/tui/services/AIService.ts +518 -462
- package/bin/lib/tui/services/ExtensionService.ts +140 -129
- package/bin/lib/tui/services/GeminiService.ts +367 -337
- package/bin/lib/tui/services/ServiceManager.ts +344 -322
- package/bin/lib/tui/services/SocketService.ts +168 -168
- package/bin/lib/tui/services/ViteService.ts +88 -88
- package/bin/lib/tui/services/index.ts +47 -22
- package/bin/lib/utils/ai-scaffold.js +291 -280
- package/bin/lib/utils/extract-config.js +157 -140
- package/bin/lib/utils/files.js +82 -86
- package/bin/lib/utils/index.js +7 -7
- package/bin/lib/utils/paths.js +34 -34
- package/bin/lib/utils/prompts.js +194 -169
- package/bin/lib/utils/ssl.js +79 -81
- package/browser-extensions/README.md +0 -1
- package/browser-extensions/chrome/background.js +244 -237
- package/browser-extensions/chrome/content.js +32 -29
- package/browser-extensions/chrome/devtools.html +7 -7
- package/browser-extensions/chrome/devtools.js +19 -19
- package/browser-extensions/chrome/inspector.js +802 -767
- package/browser-extensions/chrome/manifest.json +71 -63
- package/browser-extensions/chrome/panel.html +674 -636
- package/browser-extensions/chrome/panel.js +722 -712
- package/browser-extensions/chrome/popup.html +586 -543
- package/browser-extensions/chrome/popup.js +282 -244
- package/browser-extensions/chrome/rules.json +1 -1
- package/browser-extensions/chrome/test-chrome.html +216 -136
- package/browser-extensions/chrome/test-mixed-content.html +284 -189
- package/browser-extensions/chrome/test-uri-pattern.html +221 -198
- package/browser-extensions/firefox/README.md +9 -6
- package/browser-extensions/firefox/background.js +221 -218
- package/browser-extensions/firefox/content.js +55 -52
- package/browser-extensions/firefox/debug-errors.html +386 -228
- package/browser-extensions/firefox/debug-https.html +153 -105
- package/browser-extensions/firefox/devtools.html +7 -7
- package/browser-extensions/firefox/devtools.js +23 -20
- package/browser-extensions/firefox/inspector.js +802 -767
- package/browser-extensions/firefox/manifest.json +68 -68
- package/browser-extensions/firefox/panel.html +674 -636
- package/browser-extensions/firefox/panel.js +722 -712
- package/browser-extensions/firefox/popup.html +572 -535
- package/browser-extensions/firefox/popup.js +281 -236
- package/browser-extensions/firefox/test-gramercy.html +170 -125
- package/browser-extensions/firefox/test-imports.html +59 -55
- package/browser-extensions/firefox/test-masking.html +231 -140
- package/browser-extensions/firefox/test-uri-pattern.html +221 -198
- package/dist/tui/App.d.ts +1 -1
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +154 -150
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/components/AIPanel.d.ts.map +1 -1
- package/dist/tui/components/AIPanel.js +42 -35
- package/dist/tui/components/AIPanel.js.map +1 -1
- package/dist/tui/components/CommandInput.d.ts +1 -1
- package/dist/tui/components/CommandInput.d.ts.map +1 -1
- package/dist/tui/components/CommandInput.js +92 -62
- package/dist/tui/components/CommandInput.js.map +1 -1
- package/dist/tui/components/GeminiPanel.d.ts.map +1 -1
- package/dist/tui/components/GeminiPanel.js +37 -30
- package/dist/tui/components/GeminiPanel.js.map +1 -1
- package/dist/tui/components/Header.d.ts.map +1 -1
- package/dist/tui/components/Header.js +1 -1
- package/dist/tui/components/Header.js.map +1 -1
- package/dist/tui/components/LogPanel.d.ts +1 -1
- package/dist/tui/components/LogPanel.d.ts.map +1 -1
- package/dist/tui/components/LogPanel.js +26 -24
- package/dist/tui/components/LogPanel.js.map +1 -1
- package/dist/tui/components/TabBar.d.ts +2 -2
- package/dist/tui/components/TabBar.d.ts.map +1 -1
- package/dist/tui/components/TabBar.js +11 -11
- package/dist/tui/components/TabBar.js.map +1 -1
- package/dist/tui/components/WelcomeScreen.d.ts.map +1 -1
- package/dist/tui/components/WelcomeScreen.js +6 -6
- package/dist/tui/components/WelcomeScreen.js.map +1 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +8 -8
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/services/AIService.d.ts +2 -2
- package/dist/tui/services/AIService.d.ts.map +1 -1
- package/dist/tui/services/AIService.js +165 -125
- package/dist/tui/services/AIService.js.map +1 -1
- package/dist/tui/services/ExtensionService.d.ts +1 -1
- package/dist/tui/services/ExtensionService.d.ts.map +1 -1
- package/dist/tui/services/ExtensionService.js +33 -26
- package/dist/tui/services/ExtensionService.js.map +1 -1
- package/dist/tui/services/GeminiService.d.ts +1 -1
- package/dist/tui/services/GeminiService.d.ts.map +1 -1
- package/dist/tui/services/GeminiService.js +87 -76
- package/dist/tui/services/GeminiService.js.map +1 -1
- package/dist/tui/services/ServiceManager.d.ts +3 -3
- package/dist/tui/services/ServiceManager.d.ts.map +1 -1
- package/dist/tui/services/ServiceManager.js +72 -58
- package/dist/tui/services/ServiceManager.js.map +1 -1
- package/dist/tui/services/SocketService.d.ts.map +1 -1
- package/dist/tui/services/SocketService.js +32 -32
- package/dist/tui/services/SocketService.js.map +1 -1
- package/dist/tui/services/ViteService.d.ts.map +1 -1
- package/dist/tui/services/ViteService.js +26 -28
- package/dist/tui/services/ViteService.js.map +1 -1
- package/dist/tui/services/index.d.ts +6 -6
- package/dist/tui/services/index.d.ts.map +1 -1
- package/dist/tui/services/index.js +6 -6
- package/dist/tui/services/index.js.map +1 -1
- package/mcp/gxp-api-server.js +83 -81
- package/package.json +109 -93
- package/runtime/PortalContainer.vue +258 -234
- package/runtime/dev-tools/DevToolsModal.vue +153 -155
- package/runtime/dev-tools/LayoutSwitcher.vue +144 -140
- package/runtime/dev-tools/MockDataEditor.vue +456 -433
- package/runtime/dev-tools/SocketSimulator.vue +379 -371
- package/runtime/dev-tools/StoreInspector.vue +517 -455
- package/runtime/dev-tools/index.js +5 -5
- package/runtime/fallback-layouts/PrivateLayout.vue +2 -2
- package/runtime/fallback-layouts/PublicLayout.vue +2 -2
- package/runtime/fallback-layouts/SystemLayout.vue +2 -2
- package/runtime/gxpStringsPlugin.js +159 -134
- package/runtime/index.html +17 -19
- package/runtime/main.js +24 -22
- package/runtime/mock-api/auth-middleware.js +15 -15
- package/runtime/mock-api/image-generator.js +46 -46
- package/runtime/mock-api/index.js +55 -55
- package/runtime/mock-api/response-generator.js +116 -105
- package/runtime/mock-api/route-generator.js +107 -84
- package/runtime/mock-api/socket-triggers.js +94 -93
- package/runtime/mock-api/spec-loader.js +79 -80
- package/runtime/package.json +3 -0
- package/runtime/server.js +68 -68
- package/runtime/stores/gxpPortalConfigStore.js +204 -186
- package/runtime/stores/index.js +2 -2
- package/runtime/vite-inspector-plugin.js +858 -707
- package/runtime/vite-source-tracker-plugin.js +132 -113
- package/runtime/vite.config.js +207 -132
- package/scripts/launch-chrome.js +41 -41
- package/scripts/pack-chrome.js +38 -39
- package/socket-events/AiSessionMessageCreated.json +17 -17
- package/socket-events/SocialStreamPostCreated.json +23 -23
- package/socket-events/SocialStreamPostVariantCompleted.json +22 -22
- package/template/.claude/agents/gxp-developer.md +100 -99
- package/template/.claude/settings.json +7 -7
- package/template/AGENTS.md +30 -23
- package/template/GEMINI.md +20 -20
- package/template/README.md +70 -53
- package/template/app-manifest.json +2 -4
- package/template/configuration.json +10 -10
- package/template/default-styling.css +1 -1
- package/template/index.html +18 -20
- package/template/main.js +24 -22
- package/template/src/DemoPage.vue +415 -362
- package/template/src/Plugin.vue +76 -85
- package/template/src/stores/index.js +3 -3
- package/template/src/stores/test-data.json +164 -172
- package/template/theme-layouts/AdditionalStyling.css +50 -50
- package/template/theme-layouts/PrivateLayout.vue +8 -12
- package/template/theme-layouts/PublicLayout.vue +8 -12
- package/template/theme-layouts/SystemLayout.vue +8 -12
- package/template/vite.extend.js +45 -0
- package/template/vite.config.js +0 -409
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViteService.d.ts","sourceRoot":"","sources":["../../../bin/lib/tui/services/ViteService.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;
|
|
1
|
+
{"version":3,"file":"ViteService.d.ts","sourceRoot":"","sources":["../../../bin/lib/tui/services/ViteService.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AA4BD,wBAAgB,SAAS,CAAC,OAAO,GAAE,WAAgB,GAAG,IAAI,CA6DzD;AAED,wBAAgB,QAAQ,IAAI,OAAO,CAElC;AAED,wBAAgB,aAAa,IAAI,OAAO,CAEvC"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { serviceManager } from
|
|
2
|
-
import path from
|
|
3
|
-
import fs from
|
|
4
|
-
import { fileURLToPath } from
|
|
5
|
-
import dotenv from
|
|
1
|
+
import { serviceManager } from "./ServiceManager.js";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import dotenv from "dotenv";
|
|
6
6
|
// Get the toolkit root directory
|
|
7
7
|
function getToolkitRoot() {
|
|
8
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
// Navigate from dist/tui/services to project root (3 levels up)
|
|
10
|
-
return path.resolve(__dirname,
|
|
10
|
+
return path.resolve(__dirname, "..", "..", "..");
|
|
11
11
|
}
|
|
12
12
|
// Find existing SSL certificates in a directory
|
|
13
13
|
function findExistingCertificates(certsDir) {
|
|
14
14
|
if (!fs.existsSync(certsDir))
|
|
15
15
|
return null;
|
|
16
16
|
const files = fs.readdirSync(certsDir);
|
|
17
|
-
const certFile = files.find(f => f.endsWith(
|
|
18
|
-
const keyFile = files.find(f => f.includes(
|
|
17
|
+
const certFile = files.find((f) => f.endsWith(".pem") && !f.includes("key"));
|
|
18
|
+
const keyFile = files.find((f) => f.includes("key") && f.endsWith(".pem"));
|
|
19
19
|
if (certFile && keyFile) {
|
|
20
20
|
return {
|
|
21
21
|
certPath: path.join(certsDir, certFile),
|
|
@@ -28,7 +28,7 @@ export function startVite(options = {}) {
|
|
|
28
28
|
const cwd = options.cwd || process.cwd();
|
|
29
29
|
const toolkitRoot = getToolkitRoot();
|
|
30
30
|
// Load .env file if it exists
|
|
31
|
-
const envPath = path.join(cwd,
|
|
31
|
+
const envPath = path.join(cwd, ".env");
|
|
32
32
|
let envVars = {};
|
|
33
33
|
if (fs.existsSync(envPath)) {
|
|
34
34
|
const envResult = dotenv.config({ path: envPath });
|
|
@@ -38,10 +38,10 @@ export function startVite(options = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
// Determine HTTPS settings
|
|
40
40
|
let useHttps = !options.noHttps;
|
|
41
|
-
let certPath =
|
|
42
|
-
let keyPath =
|
|
41
|
+
let certPath = "";
|
|
42
|
+
let keyPath = "";
|
|
43
43
|
if (useHttps) {
|
|
44
|
-
const certsDir = path.join(cwd,
|
|
44
|
+
const certsDir = path.join(cwd, ".certs");
|
|
45
45
|
const existingCerts = findExistingCertificates(certsDir);
|
|
46
46
|
if (existingCerts) {
|
|
47
47
|
certPath = existingCerts.certPath;
|
|
@@ -52,38 +52,36 @@ export function startVite(options = {}) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
// Determine the port (priority: .env > default)
|
|
55
|
-
const port = envVars.NODE_PORT ||
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const toolkitViteConfig = path.join(toolkitRoot, 'runtime', 'vite.config.js');
|
|
60
|
-
const viteConfigPath = fs.existsSync(localViteConfig) ? localViteConfig : toolkitViteConfig;
|
|
55
|
+
const port = envVars.NODE_PORT || "3060";
|
|
56
|
+
// Vite config always comes from the runtime. Projects extend it via an
|
|
57
|
+
// optional `vite.extend.js` at the project root.
|
|
58
|
+
const viteConfigPath = path.join(toolkitRoot, "runtime", "vite.config.js");
|
|
61
59
|
// Build final environment variables
|
|
62
60
|
const env = {
|
|
63
61
|
...envVars,
|
|
64
|
-
FORCE_COLOR:
|
|
62
|
+
FORCE_COLOR: "1",
|
|
65
63
|
NODE_PORT: port,
|
|
66
|
-
USE_HTTPS: useHttps ?
|
|
64
|
+
USE_HTTPS: useHttps ? "true" : "false",
|
|
67
65
|
CERT_PATH: certPath,
|
|
68
66
|
KEY_PATH: keyPath,
|
|
69
|
-
COMPONENT_PATH: envVars.COMPONENT_PATH ||
|
|
70
|
-
NODE_LOG_LEVEL: envVars.NODE_LOG_LEVEL ||
|
|
67
|
+
COMPONENT_PATH: envVars.COMPONENT_PATH || "./src/Plugin.vue",
|
|
68
|
+
NODE_LOG_LEVEL: envVars.NODE_LOG_LEVEL || "info",
|
|
71
69
|
};
|
|
72
70
|
// Run vite directly with the correct config
|
|
73
71
|
const config = {
|
|
74
|
-
id:
|
|
75
|
-
name:
|
|
76
|
-
command:
|
|
77
|
-
args: [
|
|
72
|
+
id: "vite",
|
|
73
|
+
name: "Vite",
|
|
74
|
+
command: "npx",
|
|
75
|
+
args: ["vite", "dev", "--config", viteConfigPath],
|
|
78
76
|
cwd,
|
|
79
77
|
env,
|
|
80
78
|
};
|
|
81
79
|
serviceManager.start(config);
|
|
82
80
|
}
|
|
83
81
|
export function stopVite() {
|
|
84
|
-
return serviceManager.stop(
|
|
82
|
+
return serviceManager.stop("vite");
|
|
85
83
|
}
|
|
86
84
|
export function isViteRunning() {
|
|
87
|
-
return serviceManager.isRunning(
|
|
85
|
+
return serviceManager.isRunning("vite");
|
|
88
86
|
}
|
|
89
87
|
//# sourceMappingURL=ViteService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViteService.js","sourceRoot":"","sources":["../../../bin/lib/tui/services/ViteService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"ViteService.js","sourceRoot":"","sources":["../../../bin/lib/tui/services/ViteService.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { serviceManager, ServiceManager, ServiceStatus, ServiceConfig, ServiceState } from
|
|
2
|
-
export { startVite, stopVite, isViteRunning, ViteOptions } from
|
|
3
|
-
export { startSocket, stopSocket, isSocketRunning, listSocketEvents, sendSocketEvent, SocketOptions, SocketEvent } from
|
|
4
|
-
export { startExtension, stopExtension, isExtensionRunning, BrowserType, ExtensionOptions } from
|
|
5
|
-
export { geminiService, GeminiService, GeminiConfig, isAuthenticated, loadGeminiConfig, saveGeminiConfig, clearAuthTokens } from
|
|
6
|
-
export { aiService, AIService, AIProvider, AIProviderInfo, AIConfig, loadAIConfig, saveAIConfig, getAvailableProviders, getProviderStatus } from
|
|
1
|
+
export { serviceManager, ServiceManager, ServiceStatus, ServiceConfig, ServiceState, } from "./ServiceManager.js";
|
|
2
|
+
export { startVite, stopVite, isViteRunning, ViteOptions, } from "./ViteService.js";
|
|
3
|
+
export { startSocket, stopSocket, isSocketRunning, listSocketEvents, sendSocketEvent, SocketOptions, SocketEvent, } from "./SocketService.js";
|
|
4
|
+
export { startExtension, stopExtension, isExtensionRunning, BrowserType, ExtensionOptions, } from "./ExtensionService.js";
|
|
5
|
+
export { geminiService, GeminiService, GeminiConfig, isAuthenticated, loadGeminiConfig, saveGeminiConfig, clearAuthTokens, } from "./GeminiService.js";
|
|
6
|
+
export { aiService, AIService, AIProvider, AIProviderInfo, AIConfig, loadAIConfig, saveAIConfig, getAvailableProviders, getProviderStatus, } from "./AIService.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../bin/lib/tui/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../bin/lib/tui/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,GACZ,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACN,SAAS,EACT,QAAQ,EACR,aAAa,EACb,WAAW,GACX,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACN,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,WAAW,GACX,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACN,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,gBAAgB,GAChB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GACf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACN,SAAS,EACT,SAAS,EACT,UAAU,EACV,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,GACjB,MAAM,gBAAgB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { serviceManager, ServiceManager } from
|
|
2
|
-
export { startVite, stopVite, isViteRunning } from
|
|
3
|
-
export { startSocket, stopSocket, isSocketRunning, listSocketEvents, sendSocketEvent } from
|
|
4
|
-
export { startExtension, stopExtension, isExtensionRunning } from
|
|
5
|
-
export { geminiService, GeminiService, isAuthenticated, loadGeminiConfig, saveGeminiConfig, clearAuthTokens } from
|
|
6
|
-
export { aiService, AIService, loadAIConfig, saveAIConfig, getAvailableProviders, getProviderStatus } from
|
|
1
|
+
export { serviceManager, ServiceManager, } from "./ServiceManager.js";
|
|
2
|
+
export { startVite, stopVite, isViteRunning, } from "./ViteService.js";
|
|
3
|
+
export { startSocket, stopSocket, isSocketRunning, listSocketEvents, sendSocketEvent, } from "./SocketService.js";
|
|
4
|
+
export { startExtension, stopExtension, isExtensionRunning, } from "./ExtensionService.js";
|
|
5
|
+
export { geminiService, GeminiService, isAuthenticated, loadGeminiConfig, saveGeminiConfig, clearAuthTokens, } from "./GeminiService.js";
|
|
6
|
+
export { aiService, AIService, loadAIConfig, saveAIConfig, getAvailableProviders, getProviderStatus, } from "./AIService.js";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../bin/lib/tui/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../bin/lib/tui/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd,cAAc,GAId,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACN,SAAS,EACT,QAAQ,EACR,aAAa,GAEb,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACN,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,GAGf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACN,cAAc,EACd,aAAa,EACb,kBAAkB,GAGlB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,aAAa,EACb,aAAa,EAEb,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GACf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACN,SAAS,EACT,SAAS,EAIT,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,GACjB,MAAM,gBAAgB,CAAA"}
|
package/mcp/gxp-api-server.js
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* Configure in your AI tool's MCP settings to enable API-aware assistance.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
const readline = require("readline")
|
|
21
|
-
const fs = require("fs")
|
|
22
|
-
const path = require("path")
|
|
20
|
+
const readline = require("readline")
|
|
21
|
+
const fs = require("fs")
|
|
22
|
+
const path = require("path")
|
|
23
23
|
|
|
24
24
|
// Environment URL configuration (matches constants.js)
|
|
25
25
|
const ENVIRONMENT_URLS = {
|
|
@@ -62,7 +62,7 @@ const ENVIRONMENT_URLS = {
|
|
|
62
62
|
asyncApiSpec: "https://api.eventfinity.test/api-specs/asyncapi.json",
|
|
63
63
|
webhookSpec: "https://api.eventfinity.test/api-specs/webhooks.json",
|
|
64
64
|
},
|
|
65
|
-
}
|
|
65
|
+
}
|
|
66
66
|
|
|
67
67
|
// Cache for fetched specs
|
|
68
68
|
const specCache = {
|
|
@@ -70,74 +70,76 @@ const specCache = {
|
|
|
70
70
|
asyncapi: null,
|
|
71
71
|
webhooks: null,
|
|
72
72
|
lastFetch: null,
|
|
73
|
-
}
|
|
73
|
+
}
|
|
74
74
|
|
|
75
|
-
const CACHE_TTL = 5 * 60 * 1000
|
|
75
|
+
const CACHE_TTL = 5 * 60 * 1000 // 5 minutes
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* Get current environment from .env file or default
|
|
79
79
|
*/
|
|
80
80
|
function getEnvironment() {
|
|
81
81
|
// Try to read from .env file in current directory
|
|
82
|
-
const envPath = path.join(process.cwd(), ".env")
|
|
82
|
+
const envPath = path.join(process.cwd(), ".env")
|
|
83
83
|
if (fs.existsSync(envPath)) {
|
|
84
|
-
const envContent = fs.readFileSync(envPath, "utf-8")
|
|
85
|
-
const match = envContent.match(/VITE_API_ENV=(\w+)/)
|
|
84
|
+
const envContent = fs.readFileSync(envPath, "utf-8")
|
|
85
|
+
const match = envContent.match(/VITE_API_ENV=(\w+)/)
|
|
86
86
|
if (match) {
|
|
87
|
-
return match[1]
|
|
87
|
+
return match[1]
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// Fall back to environment variable or default
|
|
92
|
-
return process.env.VITE_API_ENV || process.env.API_ENV || "develop"
|
|
92
|
+
return process.env.VITE_API_ENV || process.env.API_ENV || "develop"
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Get URLs for current environment
|
|
97
97
|
*/
|
|
98
98
|
function getEnvUrls() {
|
|
99
|
-
const env = getEnvironment()
|
|
100
|
-
return ENVIRONMENT_URLS[env] || ENVIRONMENT_URLS.develop
|
|
99
|
+
const env = getEnvironment()
|
|
100
|
+
return ENVIRONMENT_URLS[env] || ENVIRONMENT_URLS.develop
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Fetch a spec with caching
|
|
105
105
|
*/
|
|
106
106
|
async function fetchSpec(specType) {
|
|
107
|
-
const urls = getEnvUrls()
|
|
107
|
+
const urls = getEnvUrls()
|
|
108
108
|
const urlMap = {
|
|
109
109
|
openapi: urls.openApiSpec,
|
|
110
110
|
asyncapi: urls.asyncApiSpec,
|
|
111
111
|
webhooks: urls.webhookSpec,
|
|
112
|
-
}
|
|
112
|
+
}
|
|
113
113
|
|
|
114
|
-
const url = urlMap[specType]
|
|
114
|
+
const url = urlMap[specType]
|
|
115
115
|
if (!url) {
|
|
116
|
-
throw new Error(`Unknown spec type: ${specType}`)
|
|
116
|
+
throw new Error(`Unknown spec type: ${specType}`)
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// Check cache
|
|
120
|
-
const now = Date.now()
|
|
120
|
+
const now = Date.now()
|
|
121
121
|
if (
|
|
122
122
|
specCache[specType] &&
|
|
123
123
|
specCache.lastFetch &&
|
|
124
124
|
now - specCache.lastFetch < CACHE_TTL
|
|
125
125
|
) {
|
|
126
|
-
return specCache[specType]
|
|
126
|
+
return specCache[specType]
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
// Fetch fresh
|
|
130
130
|
try {
|
|
131
|
-
const response = await fetch(url)
|
|
131
|
+
const response = await fetch(url)
|
|
132
132
|
if (!response.ok) {
|
|
133
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`)
|
|
133
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`)
|
|
134
134
|
}
|
|
135
|
-
const data = await response.json()
|
|
136
|
-
specCache[specType] = data
|
|
137
|
-
specCache.lastFetch = now
|
|
138
|
-
return data
|
|
135
|
+
const data = await response.json()
|
|
136
|
+
specCache[specType] = data
|
|
137
|
+
specCache.lastFetch = now
|
|
138
|
+
return data
|
|
139
139
|
} catch (error) {
|
|
140
|
-
throw new Error(
|
|
140
|
+
throw new Error(
|
|
141
|
+
`Failed to fetch ${specType} spec from ${url}: ${error.message}`,
|
|
142
|
+
)
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
|
|
@@ -145,8 +147,8 @@ async function fetchSpec(specType) {
|
|
|
145
147
|
* Search OpenAPI spec for endpoints matching a query
|
|
146
148
|
*/
|
|
147
149
|
function searchEndpoints(spec, query) {
|
|
148
|
-
const results = []
|
|
149
|
-
const queryLower = query.toLowerCase()
|
|
150
|
+
const results = []
|
|
151
|
+
const queryLower = query.toLowerCase()
|
|
150
152
|
|
|
151
153
|
if (spec.paths) {
|
|
152
154
|
for (const [path, methods] of Object.entries(spec.paths)) {
|
|
@@ -169,21 +171,21 @@ function searchEndpoints(spec, query) {
|
|
|
169
171
|
parameters: details.parameters || [],
|
|
170
172
|
requestBody: details.requestBody || null,
|
|
171
173
|
responses: Object.keys(details.responses || {}),
|
|
172
|
-
})
|
|
174
|
+
})
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
}
|
|
177
179
|
|
|
178
|
-
return results
|
|
180
|
+
return results
|
|
179
181
|
}
|
|
180
182
|
|
|
181
183
|
/**
|
|
182
184
|
* Search AsyncAPI spec for channels/events matching a query
|
|
183
185
|
*/
|
|
184
186
|
function searchEvents(spec, query) {
|
|
185
|
-
const results = []
|
|
186
|
-
const queryLower = query.toLowerCase()
|
|
187
|
+
const results = []
|
|
188
|
+
const queryLower = query.toLowerCase()
|
|
187
189
|
|
|
188
190
|
if (spec.channels) {
|
|
189
191
|
for (const [channel, details] of Object.entries(spec.channels)) {
|
|
@@ -191,43 +193,43 @@ function searchEvents(spec, query) {
|
|
|
191
193
|
channel.toLowerCase().includes(queryLower) ||
|
|
192
194
|
details.description?.toLowerCase().includes(queryLower)
|
|
193
195
|
) {
|
|
194
|
-
const operations = []
|
|
196
|
+
const operations = []
|
|
195
197
|
if (details.publish) {
|
|
196
198
|
operations.push({
|
|
197
199
|
type: "publish",
|
|
198
200
|
summary: details.publish.summary || "",
|
|
199
201
|
message: details.publish.message || null,
|
|
200
|
-
})
|
|
202
|
+
})
|
|
201
203
|
}
|
|
202
204
|
if (details.subscribe) {
|
|
203
205
|
operations.push({
|
|
204
206
|
type: "subscribe",
|
|
205
207
|
summary: details.subscribe.summary || "",
|
|
206
208
|
message: details.subscribe.message || null,
|
|
207
|
-
})
|
|
209
|
+
})
|
|
208
210
|
}
|
|
209
211
|
|
|
210
212
|
results.push({
|
|
211
213
|
channel,
|
|
212
214
|
description: details.description || "",
|
|
213
215
|
operations,
|
|
214
|
-
})
|
|
216
|
+
})
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
219
|
}
|
|
218
220
|
|
|
219
|
-
return results
|
|
221
|
+
return results
|
|
220
222
|
}
|
|
221
223
|
|
|
222
224
|
/**
|
|
223
225
|
* Get endpoint details by path and method
|
|
224
226
|
*/
|
|
225
227
|
function getEndpointDetails(spec, path, method) {
|
|
226
|
-
const methodLower = method.toLowerCase()
|
|
227
|
-
const endpoint = spec.paths?.[path]?.[methodLower]
|
|
228
|
+
const methodLower = method.toLowerCase()
|
|
229
|
+
const endpoint = spec.paths?.[path]?.[methodLower]
|
|
228
230
|
|
|
229
231
|
if (!endpoint) {
|
|
230
|
-
return null
|
|
232
|
+
return null
|
|
231
233
|
}
|
|
232
234
|
|
|
233
235
|
return {
|
|
@@ -241,7 +243,7 @@ function getEndpointDetails(spec, path, method) {
|
|
|
241
243
|
requestBody: endpoint.requestBody || null,
|
|
242
244
|
responses: endpoint.responses || {},
|
|
243
245
|
security: endpoint.security || spec.security || [],
|
|
244
|
-
}
|
|
246
|
+
}
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
// MCP Server Implementation
|
|
@@ -249,7 +251,7 @@ const SERVER_INFO = {
|
|
|
249
251
|
name: "gxp-api-server",
|
|
250
252
|
version: "1.0.0",
|
|
251
253
|
description: "GxP API documentation server for AI coding assistants",
|
|
252
|
-
}
|
|
254
|
+
}
|
|
253
255
|
|
|
254
256
|
const TOOLS = [
|
|
255
257
|
{
|
|
@@ -333,7 +335,7 @@ const TOOLS = [
|
|
|
333
335
|
required: [],
|
|
334
336
|
},
|
|
335
337
|
},
|
|
336
|
-
]
|
|
338
|
+
]
|
|
337
339
|
|
|
338
340
|
/**
|
|
339
341
|
* Handle MCP tool calls
|
|
@@ -341,7 +343,7 @@ const TOOLS = [
|
|
|
341
343
|
async function handleToolCall(name, args) {
|
|
342
344
|
switch (name) {
|
|
343
345
|
case "get_openapi_spec": {
|
|
344
|
-
const spec = await fetchSpec("openapi")
|
|
346
|
+
const spec = await fetchSpec("openapi")
|
|
345
347
|
return {
|
|
346
348
|
content: [
|
|
347
349
|
{
|
|
@@ -349,11 +351,11 @@ async function handleToolCall(name, args) {
|
|
|
349
351
|
text: JSON.stringify(spec, null, 2),
|
|
350
352
|
},
|
|
351
353
|
],
|
|
352
|
-
}
|
|
354
|
+
}
|
|
353
355
|
}
|
|
354
356
|
|
|
355
357
|
case "get_asyncapi_spec": {
|
|
356
|
-
const spec = await fetchSpec("asyncapi")
|
|
358
|
+
const spec = await fetchSpec("asyncapi")
|
|
357
359
|
return {
|
|
358
360
|
content: [
|
|
359
361
|
{
|
|
@@ -361,12 +363,12 @@ async function handleToolCall(name, args) {
|
|
|
361
363
|
text: JSON.stringify(spec, null, 2),
|
|
362
364
|
},
|
|
363
365
|
],
|
|
364
|
-
}
|
|
366
|
+
}
|
|
365
367
|
}
|
|
366
368
|
|
|
367
369
|
case "search_api_endpoints": {
|
|
368
|
-
const spec = await fetchSpec("openapi")
|
|
369
|
-
const results = searchEndpoints(spec, args.query)
|
|
370
|
+
const spec = await fetchSpec("openapi")
|
|
371
|
+
const results = searchEndpoints(spec, args.query)
|
|
370
372
|
return {
|
|
371
373
|
content: [
|
|
372
374
|
{
|
|
@@ -377,12 +379,12 @@ async function handleToolCall(name, args) {
|
|
|
377
379
|
: `No endpoints found matching "${args.query}"`,
|
|
378
380
|
},
|
|
379
381
|
],
|
|
380
|
-
}
|
|
382
|
+
}
|
|
381
383
|
}
|
|
382
384
|
|
|
383
385
|
case "search_websocket_events": {
|
|
384
|
-
const spec = await fetchSpec("asyncapi")
|
|
385
|
-
const results = searchEvents(spec, args.query)
|
|
386
|
+
const spec = await fetchSpec("asyncapi")
|
|
387
|
+
const results = searchEvents(spec, args.query)
|
|
386
388
|
return {
|
|
387
389
|
content: [
|
|
388
390
|
{
|
|
@@ -393,12 +395,12 @@ async function handleToolCall(name, args) {
|
|
|
393
395
|
: `No events found matching "${args.query}"`,
|
|
394
396
|
},
|
|
395
397
|
],
|
|
396
|
-
}
|
|
398
|
+
}
|
|
397
399
|
}
|
|
398
400
|
|
|
399
401
|
case "get_endpoint_details": {
|
|
400
|
-
const spec = await fetchSpec("openapi")
|
|
401
|
-
const details = getEndpointDetails(spec, args.path, args.method)
|
|
402
|
+
const spec = await fetchSpec("openapi")
|
|
403
|
+
const details = getEndpointDetails(spec, args.path, args.method)
|
|
402
404
|
return {
|
|
403
405
|
content: [
|
|
404
406
|
{
|
|
@@ -408,12 +410,12 @@ async function handleToolCall(name, args) {
|
|
|
408
410
|
: `Endpoint not found: ${args.method} ${args.path}`,
|
|
409
411
|
},
|
|
410
412
|
],
|
|
411
|
-
}
|
|
413
|
+
}
|
|
412
414
|
}
|
|
413
415
|
|
|
414
416
|
case "get_api_environment": {
|
|
415
|
-
const env = getEnvironment()
|
|
416
|
-
const urls = getEnvUrls()
|
|
417
|
+
const env = getEnvironment()
|
|
418
|
+
const urls = getEnvUrls()
|
|
417
419
|
return {
|
|
418
420
|
content: [
|
|
419
421
|
{
|
|
@@ -424,15 +426,15 @@ async function handleToolCall(name, args) {
|
|
|
424
426
|
...urls,
|
|
425
427
|
},
|
|
426
428
|
null,
|
|
427
|
-
2
|
|
429
|
+
2,
|
|
428
430
|
),
|
|
429
431
|
},
|
|
430
432
|
],
|
|
431
|
-
}
|
|
433
|
+
}
|
|
432
434
|
}
|
|
433
435
|
|
|
434
436
|
default:
|
|
435
|
-
throw new Error(`Unknown tool: ${name}`)
|
|
437
|
+
throw new Error(`Unknown tool: ${name}`)
|
|
436
438
|
}
|
|
437
439
|
}
|
|
438
440
|
|
|
@@ -440,10 +442,10 @@ async function handleToolCall(name, args) {
|
|
|
440
442
|
* Process MCP JSON-RPC request
|
|
441
443
|
*/
|
|
442
444
|
async function processRequest(request) {
|
|
443
|
-
const { method, params, id } = request
|
|
445
|
+
const { method, params, id } = request
|
|
444
446
|
|
|
445
447
|
try {
|
|
446
|
-
let result
|
|
448
|
+
let result
|
|
447
449
|
|
|
448
450
|
switch (method) {
|
|
449
451
|
case "initialize":
|
|
@@ -453,26 +455,26 @@ async function processRequest(request) {
|
|
|
453
455
|
tools: {},
|
|
454
456
|
},
|
|
455
457
|
serverInfo: SERVER_INFO,
|
|
456
|
-
}
|
|
457
|
-
break
|
|
458
|
+
}
|
|
459
|
+
break
|
|
458
460
|
|
|
459
461
|
case "tools/list":
|
|
460
|
-
result = { tools: TOOLS }
|
|
461
|
-
break
|
|
462
|
+
result = { tools: TOOLS }
|
|
463
|
+
break
|
|
462
464
|
|
|
463
465
|
case "tools/call":
|
|
464
|
-
result = await handleToolCall(params.name, params.arguments || {})
|
|
465
|
-
break
|
|
466
|
+
result = await handleToolCall(params.name, params.arguments || {})
|
|
467
|
+
break
|
|
466
468
|
|
|
467
469
|
case "notifications/initialized":
|
|
468
470
|
// No response needed for notifications
|
|
469
|
-
return null
|
|
471
|
+
return null
|
|
470
472
|
|
|
471
473
|
default:
|
|
472
|
-
throw new Error(`Unknown method: ${method}`)
|
|
474
|
+
throw new Error(`Unknown method: ${method}`)
|
|
473
475
|
}
|
|
474
476
|
|
|
475
|
-
return { jsonrpc: "2.0", id, result }
|
|
477
|
+
return { jsonrpc: "2.0", id, result }
|
|
476
478
|
} catch (error) {
|
|
477
479
|
return {
|
|
478
480
|
jsonrpc: "2.0",
|
|
@@ -481,7 +483,7 @@ async function processRequest(request) {
|
|
|
481
483
|
code: -32603,
|
|
482
484
|
message: error.message,
|
|
483
485
|
},
|
|
484
|
-
}
|
|
486
|
+
}
|
|
485
487
|
}
|
|
486
488
|
}
|
|
487
489
|
|
|
@@ -493,17 +495,17 @@ async function main() {
|
|
|
493
495
|
input: process.stdin,
|
|
494
496
|
output: process.stdout,
|
|
495
497
|
terminal: false,
|
|
496
|
-
})
|
|
498
|
+
})
|
|
497
499
|
|
|
498
500
|
for await (const line of rl) {
|
|
499
|
-
if (!line.trim()) continue
|
|
501
|
+
if (!line.trim()) continue
|
|
500
502
|
|
|
501
503
|
try {
|
|
502
|
-
const request = JSON.parse(line)
|
|
503
|
-
const response = await processRequest(request)
|
|
504
|
+
const request = JSON.parse(line)
|
|
505
|
+
const response = await processRequest(request)
|
|
504
506
|
|
|
505
507
|
if (response) {
|
|
506
|
-
console.log(JSON.stringify(response))
|
|
508
|
+
console.log(JSON.stringify(response))
|
|
507
509
|
}
|
|
508
510
|
} catch (error) {
|
|
509
511
|
console.log(
|
|
@@ -514,11 +516,11 @@ async function main() {
|
|
|
514
516
|
code: -32700,
|
|
515
517
|
message: `Parse error: ${error.message}`,
|
|
516
518
|
},
|
|
517
|
-
})
|
|
518
|
-
)
|
|
519
|
+
}),
|
|
520
|
+
)
|
|
519
521
|
}
|
|
520
522
|
}
|
|
521
523
|
}
|
|
522
524
|
|
|
523
525
|
// Run server
|
|
524
|
-
main().catch(console.error)
|
|
526
|
+
main().catch(console.error)
|