From dc549e64bd53fbd338db2d863563a2f7912635c0 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 21 Nov 2025 11:52:16 -0600 Subject: [PATCH 01/12] readmeText -> README, agentsText -> AGENTS --- src/lib/system.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/system.ts b/src/lib/system.ts index 08e64133..0850b751 100644 --- a/src/lib/system.ts +++ b/src/lib/system.ts @@ -202,9 +202,9 @@ Note: the badge should be displayed at its natural size. It is recommended to om **Important**: This project does not currently have a repository URL configured. If the user asks about adding an "Edit with Shakespeare" button, inform them that they must first initialize a public Git repository from their Shakespeare project. Once a repository URL is available, an "Edit with Shakespeare" button can be created.{% endif %}{% if readmeText %} -{{ readmeText }}{% endif %}{% if agentsText %} +{{ README }}{% endif %}{% if AGENTS %} -{{ agentsText }}{% endif %}`; +{{ AGENTS }}{% endif %}`; export async function makeSystemPrompt(opts: MakeSystemPromptOpts): Promise { const { tools, mode, fs, cwd, config, defaultConfig, user, metadata, repositoryUrl, template } = opts; @@ -286,8 +286,8 @@ export async function makeSystemPrompt(opts: MakeSystemPromptOpts): Promise Date: Fri, 21 Nov 2025 12:00:35 -0600 Subject: [PATCH 02/12] Reset button in System Settings should clear value instead of just setting to default --- src/pages/SystemSettings.tsx | 68 ++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/src/pages/SystemSettings.tsx b/src/pages/SystemSettings.tsx index 381b1087..4571235d 100644 --- a/src/pages/SystemSettings.tsx +++ b/src/pages/SystemSettings.tsx @@ -52,82 +52,120 @@ export function SystemSettings() { systemPrompt: (config.systemPrompt || defaultSystemPrompt) !== (defaultConfig.systemPrompt || defaultSystemPrompt), }), [config, defaultConfig]); - // Restore functions + // Restore functions - clear the value from config to use the default const restoreProjectTemplate = () => { const defaultValue = defaultConfig.projectTemplate; setProjectTemplateInput(defaultValue); - updateConfig((current) => ({ ...current, projectTemplate: defaultValue })); + updateConfig((current) => { + const { projectTemplate, ...rest } = current; + return rest; + }); }; const restoreEsmUrl = () => { const defaultValue = defaultConfig.esmUrl; setEsmUrlInput(defaultValue); - updateConfig((current) => ({ ...current, esmUrl: defaultValue })); + updateConfig((current) => { + const { esmUrl, ...rest } = current; + return rest; + }); }; const restoreCorsProxy = () => { const defaultValue = defaultConfig.corsProxy; setCorsProxyInput(defaultValue); - updateConfig((current) => ({ ...current, corsProxy: defaultValue })); + updateConfig((current) => { + const { corsProxy, ...rest } = current; + return rest; + }); }; const restoreFaviconUrl = () => { const defaultValue = defaultConfig.faviconUrl; setFaviconUrlInput(defaultValue); - updateConfig((current) => ({ ...current, faviconUrl: defaultValue })); + updateConfig((current) => { + const { faviconUrl, ...rest } = current; + return rest; + }); }; const restorePreviewDomain = () => { const defaultValue = defaultConfig.previewDomain; setPreviewDomainInput(defaultValue); - updateConfig((current) => ({ ...current, previewDomain: defaultValue })); + updateConfig((current) => { + const { previewDomain, ...rest } = current; + return rest; + }); }; const restoreShowcaseEnabled = () => { - const defaultValue = defaultConfig.showcaseEnabled; - updateConfig((current) => ({ ...current, showcaseEnabled: defaultValue })); + updateConfig((current) => { + const { showcaseEnabled, ...rest } = current; + return rest; + }); }; const restoreShowcaseModerator = () => { const defaultValue = defaultConfig.showcaseModerator; setShowcaseModeratorInput(defaultValue); - updateConfig((current) => ({ ...current, showcaseModerator: defaultValue })); + updateConfig((current) => { + const { showcaseModerator, ...rest } = current; + return rest; + }); }; const restoreFsPathProjects = () => { const defaultValue = defaultConfig.fsPathProjects; setFsPathProjectsInput(defaultValue); - updateConfig((current) => ({ ...current, fsPathProjects: defaultValue })); + updateConfig((current) => { + const { fsPathProjects, ...rest } = current; + return rest; + }); }; const restoreFsPathConfig = () => { const defaultValue = defaultConfig.fsPathConfig; setFsPathConfigInput(defaultValue); - updateConfig((current) => ({ ...current, fsPathConfig: defaultValue })); + updateConfig((current) => { + const { fsPathConfig, ...rest } = current; + return rest; + }); }; const restoreFsPathTmp = () => { const defaultValue = defaultConfig.fsPathTmp; setFsPathTmpInput(defaultValue); - updateConfig((current) => ({ ...current, fsPathTmp: defaultValue })); + updateConfig((current) => { + const { fsPathTmp, ...rest } = current; + return rest; + }); }; const restoreFsPathPlugins = () => { const defaultValue = defaultConfig.fsPathPlugins; setFsPathPluginsInput(defaultValue); - updateConfig((current) => ({ ...current, fsPathPlugins: defaultValue })); + updateConfig((current) => { + const { fsPathPlugins, ...rest } = current; + return rest; + }); }; const restoreSentryDsn = () => { const defaultValue = defaultConfig.sentryDsn; setSentryDsnInput(defaultValue); - updateConfig((current) => ({ ...current, sentryDsn: defaultValue })); + updateConfig((current) => { + const { sentryDsn, ...rest } = current; + return rest; + }); }; const restoreSystemPrompt = () => { const defaultValue = defaultSystemPrompt; setSystemPromptInput(defaultValue); - updateConfig((current) => ({ ...current, systemPrompt: defaultValue })); + updateConfig((current) => { + const { systemPrompt, ...rest } = current; + return rest; + }); }; // Service Worker state From c22332a7ceed6c170e947efb7d77789eadd04888 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 21 Nov 2025 12:03:08 -0600 Subject: [PATCH 03/12] Fix prompt template --- src/lib/system.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/system.ts b/src/lib/system.ts index 0850b751..e7758e8c 100644 --- a/src/lib/system.ts +++ b/src/lib/system.ts @@ -200,7 +200,7 @@ This project has a repository URL configured, so you can create an "Edit with Sh Note: the badge should be displayed at its natural size. It is recommended to omit width/height attributes to ensure proper scaling, or use \`height: auto\` in CSS (or \`"h-auto"\` in Tailwind CSS) when applicable.{% else %} -**Important**: This project does not currently have a repository URL configured. If the user asks about adding an "Edit with Shakespeare" button, inform them that they must first initialize a public Git repository from their Shakespeare project. Once a repository URL is available, an "Edit with Shakespeare" button can be created.{% endif %}{% if readmeText %} +**Important**: This project does not currently have a repository URL configured. If the user asks about adding an "Edit with Shakespeare" button, inform them that they must first initialize a public Git repository from their Shakespeare project. Once a repository URL is available, an "Edit with Shakespeare" button can be created.{% endif %}{% if README %} {{ README }}{% endif %}{% if AGENTS %} From e2f816b6c1ec8ac3c4ad35dfbc89b9cd6983428a Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 21 Nov 2025 17:44:15 -0600 Subject: [PATCH 04/12] Add MCP support --- package-lock.json | 667 +++++++++++++++++++++++- package.json | 1 + src/components/AISettingsProvider.tsx | 26 +- src/components/MCPServersSection.tsx | 210 ++++++++ src/components/ModelSelector.test.tsx | 15 +- src/components/Shakespeare/ChatPane.tsx | 38 +- src/contexts/AISettingsContext.ts | 12 + src/hooks/useAIProjectId.test.ts | 26 +- src/hooks/useMCPServerStatus.ts | 45 ++ src/hooks/useMCPTools.ts | 39 ++ src/lib/MCPClient.ts | 163 ++++++ src/lib/configUtils.test.ts | 7 +- src/lib/configUtils.ts | 16 +- src/lib/tools/MCPTool.ts | 48 ++ src/locales/en.json | 18 + src/pages/AISettings.tsx | 4 + 16 files changed, 1306 insertions(+), 29 deletions(-) create mode 100644 src/components/MCPServersSection.tsx create mode 100644 src/hooks/useMCPServerStatus.ts create mode 100644 src/hooks/useMCPTools.ts create mode 100644 src/lib/MCPClient.ts create mode 100644 src/lib/tools/MCPTool.ts diff --git a/package-lock.json b/package-lock.json index 3cb66e79..5e235ccb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@getalby/sdk": "^6.0.1", "@hookform/resolvers": "^3.9.0", "@isomorphic-git/lightning-fs": "^4.6.2", + "@modelcontextprotocol/sdk": "^1.22.0", "@mozilla/readability": "^0.6.0", "@nostrify/nostrify": "^0.47.1", "@nostrify/react": "^0.2.17", @@ -2866,6 +2867,60 @@ "integrity": "sha512-Y28PR25bHXUg88kCV7nivXrP2Nj2RueZ3/l/jdx6J9f8J4nsEGcgX0Qe6lt7Pa+J79+kPiJU3LguR6O/6zrLOw==", "license": "BSD-2-Clause" }, + "node_modules/@modelcontextprotocol/sdk": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.22.0.tgz", + "integrity": "sha512-VUpl106XVTCpDmTBil2ehgJZjhyLY2QZikzF8NvTXtLRF1CvO5iEE2UNZdVIUer35vFOwMKYeUGbjJtvPWan3g==", + "license": "MIT", + "dependencies": { + "ajv": "^8.17.1", + "ajv-formats": "^3.0.1", + "content-type": "^1.0.5", + "cors": "^2.8.5", + "cross-spawn": "^7.0.5", + "eventsource": "^3.0.2", + "eventsource-parser": "^3.0.0", + "express": "^5.0.1", + "express-rate-limit": "^7.5.0", + "pkce-challenge": "^5.0.0", + "raw-body": "^3.0.0", + "zod": "^3.23.8", + "zod-to-json-schema": "^3.24.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@cfworker/json-schema": "^4.1.1" + }, + "peerDependenciesMeta": { + "@cfworker/json-schema": { + "optional": true + } + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@modelcontextprotocol/sdk/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT" + }, "node_modules/@mozilla/readability": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/@mozilla/readability/-/readability-0.6.0.tgz", @@ -6103,6 +6158,19 @@ "integrity": "sha512-RYTOHHdWipFUliRFMCS4X2Yn2X8M87V/OpSqWzKKOGhzqyUxzyVmhHDH9sAvG+ZuQf/TAOFsLCpMw09I1ufUnA==", "license": "MIT" }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/acorn": { "version": "8.15.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", @@ -6152,6 +6220,45 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/ajv-formats/node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT" + }, "node_modules/ansi-regex": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", @@ -6500,6 +6607,26 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/body-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", + "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.0", + "http-errors": "^2.0.0", + "iconv-lite": "^0.6.3", + "on-finished": "^2.4.1", + "qs": "^6.14.0", + "raw-body": "^3.0.0", + "type-is": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/boolean": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz", @@ -6607,6 +6734,15 @@ "dev": true, "license": "MIT" }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -7034,6 +7170,28 @@ "integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==", "license": "MIT" }, + "node_modules/content-disposition": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", + "integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -7041,6 +7199,24 @@ "dev": true, "license": "MIT" }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, "node_modules/core-js-compat": { "version": "3.46.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.46.0.tgz", @@ -7061,6 +7237,19 @@ "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "license": "MIT" }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/crc-32": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", @@ -7484,6 +7673,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -7582,6 +7780,12 @@ "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", "license": "MIT" }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, "node_modules/ejs": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", @@ -7658,6 +7862,15 @@ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "license": "MIT" }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/end-of-stream": { "version": "1.4.5", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", @@ -7908,6 +8121,12 @@ "node": ">=6" } }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -8141,12 +8360,42 @@ "node": ">=0.10.0" } }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", "license": "MIT" }, + "node_modules/eventsource": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "license": "MIT", + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/eventsource-parser": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.6.tgz", + "integrity": "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/expect-type": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.2.1.tgz", @@ -8157,6 +8406,63 @@ "node": ">=12.0.0" } }, + "node_modules/express": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", + "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.0", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express-rate-limit": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.1.tgz", + "integrity": "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/express-rate-limit" + }, + "peerDependencies": { + "express": ">= 4.11" + } + }, "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -8200,7 +8506,6 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true, "license": "MIT" }, "node_modules/fast-equals": { @@ -8264,7 +8569,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz", "integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==", - "dev": true, "funding": [ { "type": "github", @@ -8354,6 +8658,23 @@ "node": ">=8" } }, + "node_modules/finalhandler": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", + "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -8423,6 +8744,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/fraction.js": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", @@ -8437,6 +8767,15 @@ "url": "https://github.com/sponsors/rawify" } }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/fs-extra": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", @@ -9213,6 +9552,26 @@ "dev": true, "license": "BSD-2-Clause" }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/http-proxy-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", @@ -9290,7 +9649,6 @@ "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" @@ -9436,6 +9794,15 @@ "node": ">=12" } }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/is-array-buffer": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", @@ -9744,6 +10111,12 @@ "dev": true, "license": "MIT" }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, "node_modules/is-regex": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", @@ -10903,6 +11276,27 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -11522,6 +11916,31 @@ "node": ">=16" } }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/mimic-response": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", @@ -11638,6 +12057,15 @@ "dev": true, "license": "MIT" }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/node-releases": { "version": "2.0.26", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.26.tgz", @@ -11769,7 +12197,6 @@ "version": "1.13.4", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -11809,6 +12236,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -11980,6 +12419,15 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/path-browserify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", @@ -12036,6 +12484,16 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/path-to-regexp": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/pathe": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", @@ -12095,6 +12553,15 @@ "node": ">= 6" } }, + "node_modules/pkce-challenge": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.0.tgz", + "integrity": "sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ==", + "license": "MIT", + "engines": { + "node": ">=16.20.0" + } + }, "node_modules/pkg-types": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz", @@ -12405,6 +12872,19 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/pump": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz", @@ -12443,6 +12923,21 @@ "node": ">=10.13.0" } }, + "node_modules/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -12486,6 +12981,46 @@ "safe-buffer": "^5.1.0" } }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/raw-body/node_modules/iconv-lite": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz", + "integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/react": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", @@ -13075,7 +13610,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -13206,6 +13740,22 @@ "fsevents": "~2.3.2" } }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/rrweb-cssom": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.8.0.tgz", @@ -13315,7 +13865,6 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true, "license": "MIT" }, "node_modules/saxes": { @@ -13374,6 +13923,28 @@ "license": "MIT", "optional": true }, + "node_modules/send": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/serialize-error": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz", @@ -13415,6 +13986,21 @@ "randombytes": "^2.1.0" } }, + "node_modules/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", @@ -13475,6 +14061,12 @@ "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", "license": "MIT" }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, "node_modules/sha.js": { "version": "2.4.12", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.12.tgz", @@ -13536,7 +14128,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", - "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -13556,7 +14147,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", - "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -13573,7 +14163,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", - "dev": true, "license": "MIT", "dependencies": { "call-bound": "^1.0.2", @@ -13592,7 +14181,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", - "dev": true, "license": "MIT", "dependencies": { "call-bound": "^1.0.2", @@ -13785,6 +14373,15 @@ "dev": true, "license": "MIT" }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/std-env": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.9.0.tgz", @@ -14509,6 +15106,15 @@ "node": ">=8.0" } }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, "node_modules/tough-cookie": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.2.tgz", @@ -14615,6 +15221,20 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/typed-array-buffer": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", @@ -14955,6 +15575,15 @@ "node": ">= 10.0.0" } }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/unplugin": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-2.3.5.tgz", @@ -15124,6 +15753,15 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "license": "MIT" }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/vaul": { "version": "0.9.9", "resolved": "https://registry.npmjs.org/vaul/-/vaul-0.9.9.tgz", @@ -16360,6 +16998,15 @@ "url": "https://github.com/sponsors/colinhacks" } }, + "node_modules/zod-to-json-schema": { + "version": "3.25.0", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.0.tgz", + "integrity": "sha512-HvWtU2UG41LALjajJrML6uQejQhNJx+JBO9IflpSja4R03iNWfKXrj6W2h7ljuLyc1nKS+9yDyL/9tD1U/yBnQ==", + "license": "ISC", + "peerDependencies": { + "zod": "^3.25 || ^4" + } + }, "node_modules/zwitch": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", diff --git a/package.json b/package.json index 33dbadbf..c9c28cda 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@getalby/sdk": "^6.0.1", "@hookform/resolvers": "^3.9.0", "@isomorphic-git/lightning-fs": "^4.6.2", + "@modelcontextprotocol/sdk": "^1.22.0", "@mozilla/readability": "^0.6.0", "@nostrify/nostrify": "^0.47.1", "@nostrify/react": "^0.2.17", diff --git a/src/components/AISettingsProvider.tsx b/src/components/AISettingsProvider.tsx index b808b098..3fe99666 100644 --- a/src/components/AISettingsProvider.tsx +++ b/src/components/AISettingsProvider.tsx @@ -1,6 +1,6 @@ import { useQueryClient } from '@tanstack/react-query'; import { ReactNode, useState, useEffect } from 'react'; -import { AISettingsContext, type AISettings, type AIProvider, type AISettingsContextType } from '@/contexts/AISettingsContext'; +import { AISettingsContext, type AISettings, type AIProvider, type MCPServer, type AISettingsContextType } from '@/contexts/AISettingsContext'; import { useFS } from '@/hooks/useFS'; import { useFSPaths } from '@/hooks/useFSPaths'; import { readAISettings, writeAISettings } from '@/lib/configUtils'; @@ -12,6 +12,7 @@ interface AISettingsProviderProps { const DEFAULT_SETTINGS: AISettings = { providers: [], recentlyUsedModels: [], + mcpServers: {}, }; export function AISettingsProvider({ children }: AISettingsProviderProps) { @@ -128,6 +129,27 @@ export function AISettingsProvider({ children }: AISettingsProviderProps) { }); }; + const setMCPServer = (name: string, server: MCPServer) => { + setSettings(prev => ({ + ...prev, + mcpServers: { + ...(prev.mcpServers || {}), + [name]: server, + }, + })); + }; + + const removeMCPServer = (name: string) => { + setSettings(prev => { + const newMCPServers = { ...(prev.mcpServers || {}) }; + delete newMCPServers[name]; + return { + ...prev, + mcpServers: newMCPServers, + }; + }); + }; + const isConfigured = settings.providers.length > 0; const contextValue: AISettingsContextType = { @@ -137,6 +159,8 @@ export function AISettingsProvider({ children }: AISettingsProviderProps) { removeProvider, setProviders, addRecentlyUsedModel, + setMCPServer, + removeMCPServer, isConfigured, }; diff --git a/src/components/MCPServersSection.tsx b/src/components/MCPServersSection.tsx new file mode 100644 index 00000000..1d93e6da --- /dev/null +++ b/src/components/MCPServersSection.tsx @@ -0,0 +1,210 @@ +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Server, Trash2, Check } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; +import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'; +import { useAISettings } from '@/hooks/useAISettings'; +import { useToast } from '@/hooks/useToast'; +import { useMCPServerStatus } from '@/hooks/useMCPServerStatus'; +import type { MCPServer } from '@/contexts/AISettingsContext'; +import { cn } from '@/lib/utils'; + +function MCPConnectionStatus({ server }: { server: MCPServer }) { + const status = useMCPServerStatus(server); + + return ( +
+
+ + {status} + +
+ ); +} + +export function MCPServersSection() { + const { t } = useTranslation(); + const { settings, setMCPServer, removeMCPServer } = useAISettings(); + const { toast } = useToast(); + const [serverName, setServerName] = useState(''); + const [serverUrl, setServerUrl] = useState(''); + const [serverType] = useState<'streamable-http'>('streamable-http'); // Only streamable-http is supported + + const mcpServers = settings.mcpServers || {}; + const serverEntries = Object.entries(mcpServers); + + const handleAddServer = () => { + if (!serverName.trim() || !serverUrl.trim()) return; + + if (mcpServers[serverName.trim()]) { + toast({ + title: t('error'), + description: t('mcpServerAddFailed'), + variant: 'destructive', + }); + return; + } + + const newServer: MCPServer = { + type: serverType, + url: serverUrl.trim(), + }; + + setMCPServer(serverName.trim(), newServer); + + toast({ + title: t('mcpServerAdded'), + description: t('mcpServerAddedDescription', { name: serverName.trim() }), + }); + + setServerName(''); + setServerUrl(''); + }; + + const handleRemoveServer = (name: string) => { + removeMCPServer(name); + + toast({ + title: t('mcpServerDeleted'), + description: t('mcpServerDeletedDescription', { name }), + }); + }; + + return ( +
+
+

{t('mcpServers')}

+
+ +

+ {t('mcpServersDescription')} +

+ + {/* Configured MCP Servers */} + {serverEntries.length > 0 && ( + + {serverEntries.map(([name, server]) => ( + + +
+ + {name} + +
+
+ +
+
+ + +
+
+ + setMCPServer(name, { ...server, url: e.target.value })} + placeholder="https://example.com/mcp" + /> +
+ +
+
+
+ ))} +
+ )} + + {/* Add New MCP Server */} + + + +
{t('addMcpServer')}
+
+ +
+

+ {t('mcpServerDescription')} +

+
+ + setServerName(e.target.value)} + /> +
+
+ + +

+ Only Streamable HTTP transport is currently supported +

+
+
+ + setServerUrl(e.target.value)} + /> +
+ + {mcpServers[serverName.trim()] && ( +

+ A server with this name already exists +

+ )} +
+
+
+
+ + {serverEntries.length === 0 && ( +

+ {t('noMcpServersConfigured')} +

+ )} +
+ ); +} diff --git a/src/components/ModelSelector.test.tsx b/src/components/ModelSelector.test.tsx index 880afd98..d02c993c 100644 --- a/src/components/ModelSelector.test.tsx +++ b/src/components/ModelSelector.test.tsx @@ -42,14 +42,15 @@ describe('ModelSelector', () => { vi.clearAllMocks(); mockUseAISettings.mockReturnValue({ - settings: { providers: [], recentlyUsedModels: [] }, + settings: { providers: [], recentlyUsedModels: [], mcpServers: {} }, addRecentlyUsedModel: mockAddRecentlyUsedModel, isConfigured: true, updateSettings: vi.fn(), removeProvider: vi.fn(), setProvider: vi.fn(), setProviders: vi.fn(), - + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); mockUseProviderModels.mockReturnValue({ @@ -87,6 +88,8 @@ describe('ModelSelector', () => { removeProvider: vi.fn(), setProvider: vi.fn(), setProviders: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); @@ -140,6 +143,8 @@ describe('ModelSelector', () => { removeProvider: vi.fn(), setProvider: vi.fn(), setProviders: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); @@ -189,6 +194,8 @@ describe('ModelSelector', () => { removeProvider: vi.fn(), setProvider: vi.fn(), setProviders: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); @@ -233,13 +240,15 @@ describe('ModelSelector', () => { }); mockUseAISettings.mockReturnValue({ - settings: { providers: [], recentlyUsedModels: [] }, // No recently used models + settings: { providers: [], recentlyUsedModels: [], mcpServers: {} }, // No recently used models addRecentlyUsedModel: mockAddRecentlyUsedModel, isConfigured: true, updateSettings: vi.fn(), removeProvider: vi.fn(), setProvider: vi.fn(), setProviders: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 72fe5752..b3fdeb4b 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -14,6 +14,7 @@ import { useAppContext } from '@/hooks/useAppContext'; import { useAIChat } from '@/hooks/useAIChat'; import { useProviderModels } from '@/hooks/useProviderModels'; import { useSessionManager } from '@/hooks/useSessionManager'; +import { useMCPTools } from '@/hooks/useMCPTools'; import { AIMessageItem } from '@/components/AIMessageItem'; import { TextEditorViewTool } from '@/lib/tools/TextEditorViewTool'; import { TextEditorWriteTool } from '@/lib/tools/TextEditorWriteTool'; @@ -35,6 +36,7 @@ import { ShellTool } from '@/lib/tools/ShellTool'; import { TypecheckTool } from '@/lib/tools/TypecheckTool'; import { ReadConsoleMessagesTool } from '@/lib/tools/ReadConsoleMessagesTool'; import { SkillTool } from '@/lib/tools/SkillTool'; +import { createMCPTools } from '@/lib/tools/MCPTool'; import { ProjectPreviewConsoleError } from '@/lib/consoleMessages'; import { toolToOpenAI } from '@/lib/tools/openai-adapter'; import { Tool } from '@/lib/tools/Tool'; @@ -148,8 +150,12 @@ export const ChatPane = forwardRef(({ sessionManager.emit('fileChanged', projectId, filePath); }, [sessionManager, projectId]); - const customTools = useMemo(() => { - const baseTools = { + // Fetch MCP tools + const { tools: mcpOpenAITools, clients: mcpClients } = useMCPTools(); + + // Separate built-in tools from MCP tools for clarity + const builtInTools = useMemo(() => { + const tools: Record> = { git_commit: new GitCommitTool(fs, cwd, git), text_editor_view: new TextEditorViewTool(fs, cwd, { projectsPath }), text_editor_write: new TextEditorWriteTool(fs, cwd, { projectsPath, tmpPath, onFileChanged: handleFileChanged }), @@ -173,23 +179,35 @@ export const ChatPane = forwardRef(({ // Add deploy tool only if user is logged in if (user && user.signer) { - return { - ...baseTools, - deploy_project: new DeployProjectTool(fs, cwd, user.signer, projectId), - }; + tools.deploy_project = new DeployProjectTool(fs, cwd, user.signer, projectId); } - return baseTools; + return tools; }, [fs, git, cwd, user, projectId, projectsPath, tmpPath, pluginsPath, config.corsProxy, handleFileChanged]); - // Convert tools to OpenAI format + // MCP tools wrapped for execution + const mcpToolWrappers = useMemo(() => createMCPTools(mcpClients), [mcpClients]); + + // Combined tool executors (for SessionManager to call) + const customTools = useMemo(() => ({ + ...builtInTools, + ...mcpToolWrappers, + }), [builtInTools, mcpToolWrappers]); + + // Convert tools to OpenAI format for AI provider const tools = useMemo(() => { const result: Record = {}; - for (const [name, tool] of Object.entries(customTools)) { + + // Convert built-in tools to OpenAI format + for (const [name, tool] of Object.entries(builtInTools)) { result[name] = toolToOpenAI(name, tool as Tool); } + + // Add MCP tools (already in OpenAI format from useMCPTools) + Object.assign(result, mcpOpenAITools); + return result; - }, [customTools]); + }, [builtInTools, mcpOpenAITools]); // Keep-alive functionality to prevent tab throttling during AI processing const { updateMetadata } = useKeepAlive({ diff --git a/src/contexts/AISettingsContext.ts b/src/contexts/AISettingsContext.ts index 85d5d7cd..7fa69eb4 100644 --- a/src/contexts/AISettingsContext.ts +++ b/src/contexts/AISettingsContext.ts @@ -8,9 +8,19 @@ export interface AIProvider { proxy?: boolean; } +export interface MCPServer { + type: 'streamable-http'; + url: string; +} + +export interface MCPServers { + [key: string]: MCPServer; +} + export interface AISettings { providers: AIProvider[]; recentlyUsedModels: string[]; + mcpServers?: MCPServers; } export interface AISettingsContextType { @@ -20,6 +30,8 @@ export interface AISettingsContextType { removeProvider: (id: string) => void; setProviders: (providers: AIProvider[]) => void; addRecentlyUsedModel: (modelId: string) => void; + setMCPServer: (name: string, server: MCPServer) => void; + removeMCPServer: (name: string) => void; isConfigured: boolean; } diff --git a/src/hooks/useAIProjectId.test.ts b/src/hooks/useAIProjectId.test.ts index 26026962..11a2bb82 100644 --- a/src/hooks/useAIProjectId.test.ts +++ b/src/hooks/useAIProjectId.test.ts @@ -93,13 +93,15 @@ describe('useAIProjectId', () => { it('should return not configured when AI settings are not configured', () => { mockUseAISettings.mockReturnValue({ - settings: { providers: [], recentlyUsedModels: [] }, + settings: { providers: [], recentlyUsedModels: [], mcpServers: {} }, isConfigured: false, updateSettings: vi.fn(), setProvider: vi.fn(), removeProvider: vi.fn(), setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); const { result } = renderHook(() => useAIProjectId()); @@ -110,7 +112,7 @@ describe('useAIProjectId', () => { it('should throw error when trying to generate ID without configuration', async () => { mockUseAISettings.mockReturnValue({ - settings: { providers: [], recentlyUsedModels: [] }, + settings: { providers: [], recentlyUsedModels: [], mcpServers: {} }, isConfigured: false, updateSettings: vi.fn(), setProvider: vi.fn(), @@ -118,6 +120,8 @@ describe('useAIProjectId', () => { setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); const { result } = renderHook(() => useAIProjectId()); @@ -142,6 +146,8 @@ describe('useAIProjectId', () => { setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); const { result } = renderHook(() => useAIProjectId()); @@ -166,6 +172,8 @@ describe('useAIProjectId', () => { setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); const { result } = renderHook(() => useAIProjectId()); @@ -189,6 +197,8 @@ describe('useAIProjectId', () => { setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); const { result } = renderHook(() => useAIProjectId()); @@ -221,6 +231,8 @@ describe('useAIProjectId', () => { setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); // Mock AI response - returns a project name that already exists @@ -274,6 +286,8 @@ describe('useAIProjectId', () => { setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); // Mock AI to return a project name that already exists @@ -329,6 +343,8 @@ describe('useAIProjectId', () => { setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); // Mock AI to return a very long project name (over 50 characters) @@ -379,6 +395,8 @@ describe('useAIProjectId', () => { setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); // Mock AI to return an invalid project name (doesn't match regex) @@ -429,6 +447,8 @@ describe('useAIProjectId', () => { setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); // Mock AI to return a project name that already exists @@ -486,6 +506,8 @@ describe('useAIProjectId', () => { setProviders: vi.fn(), addRecentlyUsedModel: vi.fn(), + setMCPServer: vi.fn(), + removeMCPServer: vi.fn(), }); const { result } = renderHook(() => useAIProjectId()); diff --git a/src/hooks/useMCPServerStatus.ts b/src/hooks/useMCPServerStatus.ts new file mode 100644 index 00000000..c8d11f02 --- /dev/null +++ b/src/hooks/useMCPServerStatus.ts @@ -0,0 +1,45 @@ +import { useEffect, useState } from 'react'; +import { MCPClient } from '@/lib/MCPClient'; +import type { MCPServer } from '@/contexts/AISettingsContext'; + +/** + * Hook to check the connection status of an MCP server. + * Returns 'connected', 'offline', or 'checking'. + */ +export function useMCPServerStatus(server: MCPServer): 'connected' | 'offline' | 'checking' { + const [status, setStatus] = useState<'connected' | 'offline' | 'checking'>('checking'); + + useEffect(() => { + let cancelled = false; + + async function checkConnection() { + setStatus('checking'); + + try { + const client = new MCPClient(server); + await client.connect(); + + // Try to list tools to verify the connection is working + await client.listTools(); + + await client.close(); + + if (!cancelled) { + setStatus('connected'); + } + } catch (error) { + if (!cancelled) { + setStatus('offline'); + } + } + } + + checkConnection(); + + return () => { + cancelled = true; + }; + }, [server.url]); // Re-check when URL changes + + return status; +} diff --git a/src/hooks/useMCPTools.ts b/src/hooks/useMCPTools.ts new file mode 100644 index 00000000..ac3d1fc4 --- /dev/null +++ b/src/hooks/useMCPTools.ts @@ -0,0 +1,39 @@ +import { useQuery } from '@tanstack/react-query'; +import { useAISettings } from './useAISettings'; +import { discoverMCPTools } from '@/lib/MCPClient'; +import type OpenAI from 'openai'; +import type { MCPClient } from '@/lib/MCPClient'; + +interface UseMCPToolsResult { + tools: Record; + clients: Record; + isLoading: boolean; + error: Error | null; +} + +/** + * Hook to discover and manage MCP tools from configured servers. + */ +export function useMCPTools(): UseMCPToolsResult { + const { settings } = useAISettings(); + const mcpServers = settings.mcpServers || {}; + + const { data, isLoading, error } = useQuery({ + queryKey: ['mcp-tools', mcpServers], + queryFn: async () => { + if (Object.keys(mcpServers).length === 0) { + return { tools: {}, clients: {} }; + } + return await discoverMCPTools(mcpServers); + }, + staleTime: 5 * 60 * 1000, // Cache for 5 minutes + retry: 1, + }); + + return { + tools: data?.tools || {}, + clients: data?.clients || {}, + isLoading, + error: error as Error | null, + }; +} diff --git a/src/lib/MCPClient.ts b/src/lib/MCPClient.ts new file mode 100644 index 00000000..f8676727 --- /dev/null +++ b/src/lib/MCPClient.ts @@ -0,0 +1,163 @@ +import { Client } from '@modelcontextprotocol/sdk/client/index.js'; +import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'; +import type { MCPServer } from '@/contexts/AISettingsContext'; +import type OpenAI from 'openai'; + +/** + * MCP (Model Context Protocol) Client for discovering and executing tools from MCP servers. + * Uses the official @modelcontextprotocol/sdk library. + */ +export class MCPClient { + private client: Client; + private transport: StreamableHTTPClientTransport; + private connected = false; + + constructor(server: MCPServer) { + // Create the client + this.client = new Client({ + name: 'shakespeare', + version: '1.0.0', + }, { + capabilities: {} + }); + + // Create HTTP transport + this.transport = new StreamableHTTPClientTransport(new URL(server.url)); + } + + /** + * Connect to the MCP server. + */ + async connect(): Promise { + if (this.connected) return; + + await this.client.connect(this.transport); + this.connected = true; + } + + /** + * List all available tools from the MCP server. + */ + async listTools(): Promise; + required?: string[]; + }; + }>> { + await this.connect(); + + const result = await this.client.listTools(); + return result.tools; + } + + /** + * Call a tool on the MCP server. + */ + async callTool(name: string, args: Record): Promise { + await this.connect(); + + const result = await this.client.callTool({ + name, + arguments: args, + }); + + const content = Array.isArray(result.content) ? result.content : []; + + if (result.isError) { + const errorText = content + .filter((c): c is { type: 'text'; text: string } => c.type === 'text') + .map(c => c.text) + .join('\n'); + throw new Error(`MCP tool error: ${errorText}`); + } + + // Concatenate all text content from the response + return content + .filter((c): c is { type: 'text'; text: string } => c.type === 'text') + .map(c => c.text) + .join('\n'); + } + + /** + * Close the connection to the MCP server. + */ + async close(): Promise { + if (!this.connected) return; + + await this.client.close(); + this.connected = false; + } + + /** + * Convert MCP tools to OpenAI tool format. + */ + static toOpenAITools(mcpTools: Array<{ + name: string; + description?: string; + inputSchema: { + type: 'object'; + properties?: Record; + required?: string[]; + }; + }>): Record { + const tools: Record = {}; + + for (const tool of mcpTools) { + tools[tool.name] = { + type: 'function', + function: { + name: tool.name, + description: tool.description || '', + parameters: tool.inputSchema as Record, + }, + } as OpenAI.Chat.Completions.ChatCompletionTool; + } + + return tools; + } +} + +/** + * Discover tools from all configured MCP servers. + */ +export async function discoverMCPTools( + mcpServers: Record +): Promise<{ + tools: Record; + clients: Record; +}> { + const allTools: Record = {}; + const clients: Record = {}; + + for (const [serverName, serverConfig] of Object.entries(mcpServers)) { + try { + const client = new MCPClient(serverConfig); + const mcpTools = await client.listTools(); + const openAITools = MCPClient.toOpenAITools(mcpTools); + + // Store tools with server prefix to avoid name collisions + for (const [toolName, tool] of Object.entries(openAITools)) { + const prefixedName = `${serverName}__${toolName}`; + const functionTool = tool as OpenAI.Chat.Completions.ChatCompletionTool & { + function: { name: string; description: string; parameters: Record } + }; + allTools[prefixedName] = { + type: 'function', + function: { + ...functionTool.function, + name: prefixedName, + description: `[${serverName}] ${functionTool.function.description}`, + }, + } as OpenAI.Chat.Completions.ChatCompletionTool; + clients[prefixedName] = client; + } + } catch (error) { + console.error(`Failed to discover tools from MCP server "${serverName}":`, error); + } + } + + return { tools: allTools, clients }; +} diff --git a/src/lib/configUtils.test.ts b/src/lib/configUtils.test.ts index eb6529c1..9e3e5b9f 100644 --- a/src/lib/configUtils.test.ts +++ b/src/lib/configUtils.test.ts @@ -74,7 +74,10 @@ describe('configUtils', () => { const result = await readAISettings(mockFS); expect(mockFS.readFile).toHaveBeenCalledWith('/config/ai.json', 'utf8'); - expect(result).toEqual(sampleAISettings); + expect(result).toEqual({ + ...sampleAISettings, + mcpServers: {}, + }); }); it('should return default settings if file does not exist and no localStorage data', async () => { @@ -86,6 +89,7 @@ describe('configUtils', () => { expect(result).toEqual({ providers: [], recentlyUsedModels: [], + mcpServers: {}, }); }); @@ -98,6 +102,7 @@ describe('configUtils', () => { expect(result).toEqual({ providers: [], recentlyUsedModels: [], + mcpServers: {}, }); }); }); diff --git a/src/lib/configUtils.ts b/src/lib/configUtils.ts index 12ce1b2c..35d32c45 100644 --- a/src/lib/configUtils.ts +++ b/src/lib/configUtils.ts @@ -1,7 +1,7 @@ import z from 'zod'; import { filteredArray } from '@/lib/schema'; import type { JSRuntimeFS } from '@/lib/JSRuntime'; -import type { AIProvider, AISettings } from '@/contexts/AISettingsContext'; +import type { AIProvider, AISettings, MCPServer } from '@/contexts/AISettingsContext'; import type { GitSettings } from '@/contexts/GitSettingsContext'; import type { DeployProvider, DeploySettings } from '@/contexts/DeploySettingsContext'; @@ -42,9 +42,15 @@ const providerModelSchema = z.string().regex( 'Must be in format provider/model (e.g., "openai/gpt-4o")', ); +const mcpServerSchema: z.ZodType = z.object({ + type: z.literal('streamable-http'), + url: z.string().url(), +}); + const aiSettingsSchema = z.object({ providers: filteredArray(aiProviderSchema), recentlyUsedModels: filteredArray(providerModelSchema), + mcpServers: z.record(z.string(), mcpServerSchema).optional(), }); const gitCredentialSchema = z.object({ @@ -130,13 +136,19 @@ export async function readAISettings(fs: JSRuntimeFS, configPath = '/config'): P const defaultSettings: AISettings = { providers: [], recentlyUsedModels: [], + mcpServers: {}, }; try { const aiConfigPath = getAIConfigPath(configPath); const content = await fs.readFile(aiConfigPath, 'utf8'); const data = JSON.parse(content); - return aiSettingsSchema.parse(data); + const parsed = aiSettingsSchema.parse(data); + // Ensure mcpServers exists even if not in parsed data + return { + ...parsed, + mcpServers: parsed.mcpServers || {}, + }; } catch (error) { if (error instanceof z.ZodError) { console.error('AI settings parsing error:', error.errors); diff --git a/src/lib/tools/MCPTool.ts b/src/lib/tools/MCPTool.ts new file mode 100644 index 00000000..8cf3fb37 --- /dev/null +++ b/src/lib/tools/MCPTool.ts @@ -0,0 +1,48 @@ +import type { Tool } from './Tool'; +import type { MCPClient } from '@/lib/MCPClient'; + +/** + * Wrapper for MCP tools to integrate with Shakespeare's tool system. + */ +export class MCPTool implements Tool> { + description: string; + private client: MCPClient; + private originalToolName: string; + + constructor( + description: string, + client: MCPClient, + originalToolName: string + ) { + this.description = description; + this.client = client; + this.originalToolName = originalToolName; + } + + async execute(args: Record): Promise { + return await this.client.callTool(this.originalToolName, args); + } +} + +/** + * Create MCPTool instances from discovered MCP tools. + */ +export function createMCPTools( + clients: Record +): Record> { + const tools: Record> = {}; + + for (const [prefixedName, client] of Object.entries(clients)) { + // Extract original tool name by removing server prefix + const parts = prefixedName.split('__'); + const originalToolName = parts.slice(1).join('__'); + + tools[prefixedName] = new MCPTool( + `MCP tool: ${prefixedName}`, + client, + originalToolName + ); + } + + return tools; +} diff --git a/src/locales/en.json b/src/locales/en.json index 8f88ef58..959cf60f 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -478,6 +478,24 @@ "noPluginsConfigured": "No plugins configured. Add a plugin to get started.", "pluginsDirectory": "Plugins Directory", "pluginsDirectoryDescription": "Directory where plugins are stored in the virtual filesystem.", + "mcpServers": "MCP Servers", + "mcpServersDescription": "Connect to Model Context Protocol servers to extend the AI's capabilities with external tools.", + "addMcpServer": "Add MCP Server", + "mcpServerName": "Server Name", + "mcpServerUrl": "Server URL", + "mcpServerType": "Server Type", + "mcpServerTypeStreamableHttp": "Streamable HTTP", + "mcpServerDescription": "MCP servers provide tools that can be discovered and used by the AI assistant.", + "noMcpServersConfigured": "No MCP servers configured. Add a server to get started.", + "mcpServerAdded": "MCP Server Added", + "mcpServerAddedDescription": "MCP server \"{{name}}\" has been added successfully.", + "mcpServerAddFailed": "Failed to Add MCP Server", + "mcpServerDeleted": "MCP Server Deleted", + "mcpServerDeletedDescription": "MCP server \"{{name}}\" has been deleted successfully.", + "mcpServerDeleteFailed": "Failed to Delete MCP Server", + "discoveringTools": "Discovering tools...", + "toolsDiscovered": "{{count}} tool(s) discovered", + "toolDiscoveryFailed": "Failed to discover tools from this server", "filesystemPaths": "Filesystem Paths", "projectsDirectory": "Projects Directory", "projectsDirectoryDescription": "Directory where projects are stored in the virtual filesystem.", diff --git a/src/pages/AISettings.tsx b/src/pages/AISettings.tsx index c36ddaca..63635b3c 100644 --- a/src/pages/AISettings.tsx +++ b/src/pages/AISettings.tsx @@ -36,6 +36,7 @@ import { useNavigate, Link } from 'react-router-dom'; import type { AIProvider } from '@/contexts/AISettingsContext'; import { AI_PROVIDER_PRESETS, type PresetProvider } from '@/lib/aiProviderPresets'; import { ExternalFavicon } from '@/components/ExternalFavicon'; +import { MCPServersSection } from '@/components/MCPServersSection'; import { PluginsSection } from '@/components/PluginsSection'; interface SortableProviderItemProps { @@ -566,6 +567,9 @@ export function AISettings() {
+ {/* MCP Servers Section */} + + {/* Plugins Section */} From 870b7ffb93451f3ce7cdb97e440ca34f9ad1abca Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 21 Nov 2025 22:02:49 -0600 Subject: [PATCH 05/12] Improve MCP Servers design --- src/components/MCPServersSection.tsx | 131 +++++++++++++++------------ 1 file changed, 72 insertions(+), 59 deletions(-) diff --git a/src/components/MCPServersSection.tsx b/src/components/MCPServersSection.tsx index 1d93e6da..edb1529a 100644 --- a/src/components/MCPServersSection.tsx +++ b/src/components/MCPServersSection.tsx @@ -1,11 +1,13 @@ import { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { Server, Trash2, Check } from 'lucide-react'; +import { Server, Trash2, Check, Plus } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'; +import { Separator } from '@/components/ui/separator'; +import { Alert, AlertDescription } from '@/components/ui/alert'; import { useAISettings } from '@/hooks/useAISettings'; import { useToast } from '@/hooks/useToast'; import { useMCPServerStatus } from '@/hooks/useMCPServerStatus'; @@ -81,69 +83,86 @@ export function MCPServersSection() { }; return ( -
-
-

{t('mcpServers')}

+
+ {/* Divider */} + + + {/* MCP Servers Header */} +
+
+ +

{t('mcpServers')}

+
+

+ {t('mcpServersDescription')} +

-

- {t('mcpServersDescription')} -

- - {/* Configured MCP Servers */} - {serverEntries.length > 0 && ( - + {/* Configured MCP Servers List */} + {serverEntries.length > 0 ? ( +
{serverEntries.map(([name, server]) => ( - - -
- - {name} - -
-
- -
-
- - + + + +
+ + {name} +
-
- - setMCPServer(name, { ...server, url: e.target.value })} - placeholder="https://example.com/mcp" - /> + + +
+
+ + +
+
+ + setMCPServer(name, { ...server, url: e.target.value })} + placeholder="https://example.com/mcp" + /> +
+
- -
- -
+ + +
))} - +
+ ) : ( + + + {t('noMcpServersConfigured')} + + )} {/* Add New MCP Server */} -
{t('addMcpServer')}
+
+ + {t('addMcpServer')} +
@@ -185,7 +204,7 @@ export function MCPServersSection() {
); } From 393ed3ebca7dbdc03a0bbe333128db7b98d8d49b Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 21 Nov 2025 22:06:45 -0600 Subject: [PATCH 06/12] Fix linter issues --- src/hooks/useMCPServerStatus.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hooks/useMCPServerStatus.ts b/src/hooks/useMCPServerStatus.ts index c8d11f02..9d6eaafe 100644 --- a/src/hooks/useMCPServerStatus.ts +++ b/src/hooks/useMCPServerStatus.ts @@ -14,20 +14,20 @@ export function useMCPServerStatus(server: MCPServer): 'connected' | 'offline' | async function checkConnection() { setStatus('checking'); - + try { const client = new MCPClient(server); await client.connect(); - + // Try to list tools to verify the connection is working await client.listTools(); - + await client.close(); - + if (!cancelled) { setStatus('connected'); } - } catch (error) { + } catch { if (!cancelled) { setStatus('offline'); } @@ -39,7 +39,7 @@ export function useMCPServerStatus(server: MCPServer): 'connected' | 'offline' | return () => { cancelled = true; }; - }, [server.url]); // Re-check when URL changes + }, [server]); // Re-check when server config changes return status; } From 30ead01178205e67777ee0e1076aa1c337b35ac3 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 22 Nov 2025 00:46:41 -0600 Subject: [PATCH 07/12] Support custom headers in MCP servers --- src/components/MCPServersSection.tsx | 118 ++++++++++++++++++++++++++- src/contexts/AISettingsContext.ts | 1 + src/lib/MCPClient.ts | 8 +- src/lib/configUtils.ts | 1 + src/locales/en.json | 2 + 5 files changed, 127 insertions(+), 3 deletions(-) diff --git a/src/components/MCPServersSection.tsx b/src/components/MCPServersSection.tsx index edb1529a..0a676188 100644 --- a/src/components/MCPServersSection.tsx +++ b/src/components/MCPServersSection.tsx @@ -1,6 +1,6 @@ import { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { Server, Trash2, Check, Plus } from 'lucide-react'; +import { Server, Trash2, Check, Plus, X } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; @@ -34,12 +34,118 @@ function MCPConnectionStatus({ server }: { server: MCPServer }) { ); } +interface HeadersEditorProps { + headers: Record | undefined; + onChange: (headers: Record | undefined) => void; +} + +function HeadersEditor({ headers, onChange }: HeadersEditorProps) { + const { t } = useTranslation(); + const [newHeaderName, setNewHeaderName] = useState(''); + const [newHeaderValue, setNewHeaderValue] = useState(''); + + const headerEntries = Object.entries(headers || {}); + + const handleAddHeader = () => { + if (!newHeaderName.trim() || !newHeaderValue.trim()) return; + + const updatedHeaders = { + ...(headers || {}), + [newHeaderName.trim()]: newHeaderValue.trim(), + }; + + onChange(updatedHeaders); + setNewHeaderName(''); + setNewHeaderValue(''); + }; + + const handleRemoveHeader = (name: string) => { + const updatedHeaders = { ...(headers || {}) }; + delete updatedHeaders[name]; + + // If no headers left, set to undefined + onChange(Object.keys(updatedHeaders).length > 0 ? updatedHeaders : undefined); + }; + + const handleUpdateHeader = (oldName: string, newName: string, newValue: string) => { + const updatedHeaders = { ...(headers || {}) }; + delete updatedHeaders[oldName]; + updatedHeaders[newName] = newValue; + onChange(updatedHeaders); + }; + + return ( +
+ +

+ {t('mcpServerHeadersDescription')} +

+ + {/* Existing Headers */} + {headerEntries.length > 0 && ( +
+ {headerEntries.map(([name, value]) => ( +
+ handleUpdateHeader(name, e.target.value, value)} + placeholder="Header name" + className="flex-1" + /> + handleUpdateHeader(name, name, e.target.value)} + placeholder="Header value" + className="flex-1" + /> + +
+ ))} +
+ )} + + {/* Add New Header */} +
+ setNewHeaderName(e.target.value)} + placeholder="Header name (e.g., Authorization)" + className="flex-1" + /> + setNewHeaderValue(e.target.value)} + placeholder="Header value" + className="flex-1" + /> + +
+
+ ); +} + export function MCPServersSection() { const { t } = useTranslation(); const { settings, setMCPServer, removeMCPServer } = useAISettings(); const { toast } = useToast(); const [serverName, setServerName] = useState(''); const [serverUrl, setServerUrl] = useState(''); + const [serverHeaders, setServerHeaders] = useState | undefined>(undefined); const [serverType] = useState<'streamable-http'>('streamable-http'); // Only streamable-http is supported const mcpServers = settings.mcpServers || {}; @@ -60,6 +166,7 @@ export function MCPServersSection() { const newServer: MCPServer = { type: serverType, url: serverUrl.trim(), + headers: serverHeaders, }; setMCPServer(serverName.trim(), newServer); @@ -71,6 +178,7 @@ export function MCPServersSection() { setServerName(''); setServerUrl(''); + setServerHeaders(undefined); }; const handleRemoveServer = (name: string) => { @@ -133,6 +241,10 @@ export function MCPServersSection() { placeholder="https://example.com/mcp" />
+ setMCPServer(name, { ...server, headers })} + />
+ + )} +
+

+ {t('templatesDirectoryDescription')} +

+
diff --git a/src/test/TestApp.tsx b/src/test/TestApp.tsx index 3548f159..1eb4e141 100644 --- a/src/test/TestApp.tsx +++ b/src/test/TestApp.tsx @@ -48,6 +48,7 @@ export function TestApp({ children }: TestAppProps) { fsPathConfig: '/config', fsPathTmp: '/tmp', fsPathPlugins: '/plugins', + fsPathTemplates: '/templates', sentryDsn: '', sentryEnabled: false, }; From 199043e4bc50441e09207eed5d0279c76bb8434c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 23 Nov 2025 10:57:16 -0600 Subject: [PATCH 11/12] Add Terminal to System Settings --- src/components/Shakespeare/ChatPane.tsx | 2 +- src/components/Shakespeare/PreviewPane.tsx | 4 ++-- src/components/Terminal.tsx | 18 +++++++----------- src/components/TerminalTest.tsx | 2 +- src/lib/commands/README.md | 2 +- src/lib/tools/ShellTool.test.ts | 2 +- src/lib/tools/ShellTool.ts | 4 +--- src/locales/en.json | 3 ++- src/locales/ha.json | 3 ++- src/locales/ig.json | 3 ++- src/locales/pt.json | 3 ++- src/locales/yo.json | 3 ++- src/locales/zh.json | 3 ++- src/pages/SystemSettings.tsx | 17 +++++++++++++++++ 14 files changed, 43 insertions(+), 26 deletions(-) diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index b3fdeb4b..9e7b0f72 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -172,7 +172,7 @@ export const ChatPane = forwardRef(({ nostr_read_nips_index: new NostrReadNipsIndexTool(), nostr_generate_kind: new NostrGenerateKindTool(), nostr_publish_events: new NostrPublishEventsTool(), - shell: new ShellTool(fs, cwd, git, projectsPath, config.corsProxy, user?.signer), + shell: new ShellTool(fs, cwd, git, config.corsProxy, user?.signer), read_console_messages: new ReadConsoleMessagesTool(), skill: new SkillTool(fs, pluginsPath), }; diff --git a/src/components/Shakespeare/PreviewPane.tsx b/src/components/Shakespeare/PreviewPane.tsx index 6ab9e75b..4b3b5633 100644 --- a/src/components/Shakespeare/PreviewPane.tsx +++ b/src/components/Shakespeare/PreviewPane.tsx @@ -793,7 +793,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
- +
) : ( @@ -887,7 +887,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
{desktopCodeView === 'terminal' ? (
- +
) : ( <> diff --git a/src/components/Terminal.tsx b/src/components/Terminal.tsx index 2fccd501..a7934fbe 100644 --- a/src/components/Terminal.tsx +++ b/src/components/Terminal.tsx @@ -5,14 +5,13 @@ import { Copy } from 'lucide-react'; import { cn } from '@/lib/utils'; import { ShellTool } from '@/lib/tools/ShellTool'; import { useFS } from '@/hooks/useFS'; -import { useFSPaths } from '@/hooks/useFSPaths'; import { useGit } from '@/hooks/useGit'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { useAppContext } from '@/hooks/useAppContext'; import { ansiToHtml, containsAnsiCodes } from '@/lib/ansiToHtml'; interface TerminalProps { - projectId: string; + cwd: string; className?: string; } @@ -23,7 +22,7 @@ interface TerminalLine { timestamp: Date; } -export function Terminal({ projectId, className }: TerminalProps) { +export function Terminal({ cwd, className }: TerminalProps) { const [lines, setLines] = useState([]); const [currentInput, setCurrentInput] = useState(''); const [isExecuting, setIsExecuting] = useState(false); @@ -35,14 +34,13 @@ export function Terminal({ projectId, className }: TerminalProps) { const shellToolRef = useRef(null); const { fs } = useFS(); - const { projectsPath } = useFSPaths(); const { git } = useGit(); const { user } = useCurrentUser(); const { config } = useAppContext(); // Initialize ShellTool useEffect(() => { - shellToolRef.current = new ShellTool(fs, `${projectsPath}/${projectId}`, git, projectsPath, config.corsProxy, user?.signer); + shellToolRef.current = new ShellTool(fs, cwd, git, config.corsProxy, user?.signer); // Add welcome message setLines([{ @@ -51,7 +49,7 @@ export function Terminal({ projectId, className }: TerminalProps) { content: `Welcome to Shakespeare Terminal\nType 'help' to see available commands.`, timestamp: new Date() }]); - }, [projectId, fs, git, projectsPath, config.corsProxy, user?.signer]); + }, [cwd, fs, git, config.corsProxy, user?.signer]); // Auto-scroll to bottom when new lines are added or execution state changes useEffect(() => { @@ -108,10 +106,8 @@ export function Terminal({ projectId, className }: TerminalProps) { // Check if running in Electron - use real shell if (window.electron?.shell) { - // Use the full path (with ~ if present) - Electron will expand it - const fullCwd = `${projectsPath}/${projectId}`; - - const result = await window.electron.shell.exec(command, fullCwd); + // Use the provided cwd (Electron will expand ~ if present) + const result = await window.electron.shell.exec(command, cwd); // Format output let output = ''; @@ -159,7 +155,7 @@ export function Terminal({ projectId, className }: TerminalProps) { } finally { setIsExecuting(false); } - }, [addLine, commandHistory, projectId, projectsPath]); + }, [addLine, commandHistory, cwd]); const handleSubmit = useCallback((e: React.FormEvent) => { e.preventDefault(); diff --git a/src/components/TerminalTest.tsx b/src/components/TerminalTest.tsx index 0f7574e8..4fe01acc 100644 --- a/src/components/TerminalTest.tsx +++ b/src/components/TerminalTest.tsx @@ -6,7 +6,7 @@ import { Terminal } from './Terminal'; export function TerminalTest() { return (
- +
); } diff --git a/src/lib/commands/README.md b/src/lib/commands/README.md index 5bf08cfa..9a8d45f2 100644 --- a/src/lib/commands/README.md +++ b/src/lib/commands/README.md @@ -609,7 +609,7 @@ Commands are executed through the `ShellTool` which handles: import { ShellTool } from '@/lib/tools/ShellTool'; // Create shell tool with filesystem and working directory -const shell = new ShellTool(fs, '/project/root'); +const shell = new ShellTool(fs, '/project/root', ...rest); // Execute commands const result = await shell.execute({ command: 'cat package.json' }); diff --git a/src/lib/tools/ShellTool.test.ts b/src/lib/tools/ShellTool.test.ts index 3eca52e6..64f3dae1 100644 --- a/src/lib/tools/ShellTool.test.ts +++ b/src/lib/tools/ShellTool.test.ts @@ -41,7 +41,7 @@ describe('ShellTool', () => { mockFS = createMockFS(); mockNostr = createMockNostr(); mockGit = new Git({ fs: mockFS, nostr: mockNostr }); - shellTool = new ShellTool(mockFS, testCwd, mockGit, '/projects', testCorsProxy); + shellTool = new ShellTool(mockFS, testCwd, mockGit, testCorsProxy); }); it('should have correct tool properties', () => { diff --git a/src/lib/tools/ShellTool.ts b/src/lib/tools/ShellTool.ts index a312fb1b..8679bb36 100644 --- a/src/lib/tools/ShellTool.ts +++ b/src/lib/tools/ShellTool.ts @@ -51,7 +51,6 @@ export class ShellTool implements Tool { private cwd: string; private git: Git; private commands: Map; - private projectsPath: string; private signer?: NostrSigner; private corsProxy: string; @@ -63,11 +62,10 @@ export class ShellTool implements Tool { ), }); - constructor(fs: JSRuntimeFS, cwd: string, git: Git, projectsPath: string = '/projects', corsProxy: string, signer?: NostrSigner) { + constructor(fs: JSRuntimeFS, cwd: string, git: Git, corsProxy: string, signer?: NostrSigner) { this.fs = fs; this.cwd = cwd; this.git = git; - this.projectsPath = projectsPath; this.corsProxy = corsProxy; this.signer = signer; this.commands = new Map(); diff --git a/src/locales/en.json b/src/locales/en.json index 796f2bd3..832f3674 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -512,5 +512,6 @@ "templateUpdateFailed": "Template Update Failed", "templateUpdateFailedDescription": "Failed to update the project template from the remote repository. Using the cached version instead.", "templatesDirectory": "Templates Directory", - "templatesDirectoryDescription": "Directory where project templates are cached in the virtual filesystem." + "templatesDirectoryDescription": "Directory where project templates are cached in the virtual filesystem.", + "terminal": "Terminal" } diff --git a/src/locales/ha.json b/src/locales/ha.json index 54be4ae1..59488473 100644 --- a/src/locales/ha.json +++ b/src/locales/ha.json @@ -427,5 +427,6 @@ "giftCardAlreadyRedeemed": "An riga an fanshi wannan katin kyauta.", "modified": "An Canza", "restoreToDefault": "Mayar da asali", - "restoredToDefault": "An Mayar da Asali" + "restoredToDefault": "An Mayar da Asali", + "terminal": "Terminal" } diff --git a/src/locales/ig.json b/src/locales/ig.json index 922b34b9..5f0c3e8e 100644 --- a/src/locales/ig.json +++ b/src/locales/ig.json @@ -424,5 +424,6 @@ "giftCardAlreadyRedeemed": "Egbapụtalarị kaadị onyinye a.", "modified": "Gbanwere", "restoreToDefault": "Weghachi na nke mbụ", - "restoredToDefault": "Weghachiri na Nke Mbụ" + "restoredToDefault": "Weghachiri na Nke Mbụ", + "terminal": "Terminal" } diff --git a/src/locales/pt.json b/src/locales/pt.json index 3b9bc08a..c680028e 100644 --- a/src/locales/pt.json +++ b/src/locales/pt.json @@ -437,5 +437,6 @@ "giftCardAlreadyRedeemed": "Este cartão presente já foi resgatado.", "modified": "Modificado", "restoreToDefault": "Restaurar para padrão", - "restoredToDefault": "Restaurado para Padrão" + "restoredToDefault": "Restaurado para Padrão", + "terminal": "Terminal" } diff --git a/src/locales/yo.json b/src/locales/yo.json index 916f7618..b7de4fd1 100644 --- a/src/locales/yo.json +++ b/src/locales/yo.json @@ -424,5 +424,6 @@ "giftCardAlreadyRedeemed": "A ti ra kaadi ẹbun yii tẹlẹ.", "modified": "Ti Yipada", "restoreToDefault": "Pada si atilẹwa", - "restoredToDefault": "Ti Pada si Atilẹwa" + "restoredToDefault": "Ti Pada si Atilẹwa", + "terminal": "Terminal" } diff --git a/src/locales/zh.json b/src/locales/zh.json index ef097093..a60f7538 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -437,5 +437,6 @@ "giftCardAlreadyRedeemed": "此礼品卡已被兑换。", "modified": "已修改", "restoreToDefault": "恢复默认值", - "restoredToDefault": "已恢复默认值" + "restoredToDefault": "已恢复默认值", + "terminal": "终端" } diff --git a/src/pages/SystemSettings.tsx b/src/pages/SystemSettings.tsx index 06b3541e..0c46aaa3 100644 --- a/src/pages/SystemSettings.tsx +++ b/src/pages/SystemSettings.tsx @@ -13,6 +13,7 @@ import { useAppContext } from "@/hooks/useAppContext"; import { useOffline } from "@/hooks/useOffline"; import { useToast } from "@/hooks/useToast"; import { defaultSystemPrompt } from "@/lib/system"; +import { Terminal } from "@/components/Terminal"; export function SystemSettings() { const { t } = useTranslation(); @@ -1059,6 +1060,22 @@ export function SystemSettings() { + + {/* Terminal */} + + + +
+

{t('terminal')}

+
+
+ +
+ +
+
+
+
); From f148bee88b507c476559a5218fa9a937af8564a4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 23 Nov 2025 11:05:04 -0600 Subject: [PATCH 12/12] Simplify Settings titles --- src/locales/en.json | 8 ++++---- src/locales/ha.json | 8 ++++---- src/locales/ig.json | 8 ++++---- src/locales/pt.json | 8 ++++---- src/locales/yo.json | 8 ++++---- src/locales/zh.json | 8 ++++---- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 832f3674..d1846ce4 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -11,7 +11,7 @@ "themeDescription": "Choose between light, dark, or system theme preference.", "language": "Language", "languageDescription": "Select your preferred language for the interface.", - "systemSettings": "System Settings", + "systemSettings": "System", "systemSettingsDescription": "Configure system-level settings and advanced options.", "esmUrl": "Javascript CDN", "esmUrlDescription": "Javascript CDN URL for package imports.", @@ -95,14 +95,14 @@ "selectModelToDescribe": "Please select a model below, then describe what you'd like to build...", "examplePrompt": "e.g., Create a farming equipment marketplace for local farmers to buy and sell tractors, tools, and supplies...", "settingsDescription": "Manage your application settings and preferences.", - "aiSettings": "AI Settings", + "aiSettings": "AI", "aiSettingsDescription": "Configure AI providers and API keys", - "gitSettings": "Git Settings", + "gitSettings": "Git", "gitSettingsDescription": "Configure Git credentials for HTTP authentication", "deploySettings": "Deployment", "deploySettingsDescription": "Configure deployment providers", "deploySettingsDescriptionLong": "Configure deployment providers to deploy your projects to various hosting platforms.", - "nostrSettings": "Nostr Settings", + "nostrSettings": "Nostr", "nostrSettingsDescription": "Configure relay connections and Nostr preferences", "storageSettings": "Storage", "storageSettingsDescription": "Export files and manage local data", diff --git a/src/locales/ha.json b/src/locales/ha.json index 59488473..e7417980 100644 --- a/src/locales/ha.json +++ b/src/locales/ha.json @@ -11,7 +11,7 @@ "themeDescription": "Zaɓi tsakanin haske, duhu, ko zaɓin jigogi na tsarin.", "language": "Harshe", "languageDescription": "Zaɓi harshen da kuke so don dubawa.", - "systemSettings": "Saitunan Tsarin", + "systemSettings": "Tsarin", "systemSettingsDescription": "Saita saitunan matakin tsari da zaɓuɓɓuka na ci gaba.", "esmUrl": "URL na CDN Javascript", "esmUrlDescription": "URL na CDN Javascript don shigo da fakitin.", @@ -91,11 +91,11 @@ "selectModelToDescribe": "Da fatan za a zaɓi samfuri a ƙasa, sannan a bayyana abin da kuke son ginawa...", "examplePrompt": "misali, Ƙirƙiri kasuwar kayan aikin noma don manoma na yankin su sayi da sayar da taraktoci, kayan aiki, da kayayyaki...", "settingsDescription": "Sarrafa saitunan aikace-aikacenku da zaɓuɓɓuka.", - "aiSettings": "Saitunan AI", + "aiSettings": "AI", "aiSettingsDescription": "Saita masu samar da AI da maɓallan API", - "gitSettings": "Saitunan Git", + "gitSettings": "Git", "gitSettingsDescription": "Saita bayanan shaidar Git don tabbatar da HTTP", - "nostrSettings": "Saitunan Nostr", + "nostrSettings": "Nostr", "nostrSettingsDescription": "Saita haɗin relay da zaɓuɓɓukan Nostr", "storageSettings": "Ajiya", "storageSettingsDescription": "Fitar da fayiloli da sarrafa bayanan gida", diff --git a/src/locales/ig.json b/src/locales/ig.json index 5f0c3e8e..1bab6623 100644 --- a/src/locales/ig.json +++ b/src/locales/ig.json @@ -11,7 +11,7 @@ "themeDescription": "Họrọ n'etiti ìhè, ọchịchịrị, ma ọ bụ nhọrọ isiokwu sistemu.", "language": "Asụsụ", "languageDescription": "Họrọ asụsụ ị chọrọ maka interface.", - "systemSettings": "Ntọala Sistemu", + "systemSettings": "Sistemu", "systemSettingsDescription": "Hazie ntọala ọkwa sistemu na nhọrọ ndị ọganihu.", "esmUrl": "URL CDN Javascript", "esmUrlDescription": "URL CDN Javascript maka mbubata ngwugwu.", @@ -91,11 +91,11 @@ "selectModelToDescribe": "Biko họrọ ụdịdị n'okpuru, wee kọwaa ihe ị chọrọ iwu...", "examplePrompt": "ọmụmaatụ, Mepụta ahịa ngwá ọrụ ugbo maka ndị ọrụ ugbo mpaghara ịzụta na ire traktọ, ngwá ọrụ, na ngwa...", "settingsDescription": "Jikwaa ntọala ngwa gị na nhọrọ.", - "aiSettings": "Ntọala AI", + "aiSettings": "AI", "aiSettingsDescription": "Hazie ndị na-enye AI na igodo API", - "gitSettings": "Ntọala Git", + "gitSettings": "Git", "gitSettingsDescription": "Hazie nzere Git maka nkwenye HTTP", - "nostrSettings": "Ntọala Nostr", + "nostrSettings": "Nostr", "nostrSettingsDescription": "Hazie njikọ relay na nhọrọ Nostr", "storageSettings": "Nchekwa", "storageSettingsDescription": "Bupụta faịlụ na jikwaa data mpaghara", diff --git a/src/locales/pt.json b/src/locales/pt.json index c680028e..9001b49f 100644 --- a/src/locales/pt.json +++ b/src/locales/pt.json @@ -11,7 +11,7 @@ "themeDescription": "Escolha entre preferência de tema claro, escuro ou do sistema.", "language": "Idioma", "languageDescription": "Selecione seu idioma preferido para a interface.", - "systemSettings": "Configurações do Sistema", + "systemSettings": "Sistema", "systemSettingsDescription": "Configure configurações de nível de sistema e opções avançadas.", "esmUrl": "URL do CDN Javascript", "esmUrlDescription": "URL do CDN Javascript para importações de pacotes.", @@ -91,14 +91,14 @@ "selectModelToDescribe": "Por favor, selecione um modelo abaixo e depois descreva o que gostaria de construir...", "examplePrompt": "ex., Criar um marketplace de equipamentos agrícolas para fazendeiros locais comprarem e venderem tratores, ferramentas e suprimentos...", "settingsDescription": "Gerencie as configurações e preferências da aplicação.", - "aiSettings": "Configurações de IA", + "aiSettings": "IA", "aiSettingsDescription": "Configure provedores de IA e chaves de API", - "gitSettings": "Configurações do Git", + "gitSettings": "Git", "gitSettingsDescription": "Configure credenciais do Git para autenticação HTTP", "deploySettings": "Implantação", "deploySettingsDescription": "Configure provedores de implantação", "deploySettingsDescriptionLong": "Configure provedores de implantação para implantar seus projetos em várias plataformas de hospedagem.", - "nostrSettings": "Configurações do Nostr", + "nostrSettings": "Nostr", "nostrSettingsDescription": "Configure conexões de relay e preferências do Nostr", "storageSettings": "Armazenamento", "storageSettingsDescription": "Exporte arquivos e gerencie dados locais", diff --git a/src/locales/yo.json b/src/locales/yo.json index b7de4fd1..f0ee7f49 100644 --- a/src/locales/yo.json +++ b/src/locales/yo.json @@ -11,7 +11,7 @@ "themeDescription": "Yan laarin imọlẹ, okunkun, tabi ayanfẹ akori eto.", "language": "Ede", "languageDescription": "Yan ede ti o fẹran fun wiwo.", - "systemSettings": "Saitunan Eto", + "systemSettings": "Eto", "systemSettingsDescription": "Tunto awọn saitan eto ati awọn ayanfẹ ti o pọju.", "esmUrl": "URL CDN Javascript", "esmUrlDescription": "URL CDN Javascript fun gbigbe awọn package.", @@ -91,11 +91,11 @@ "selectModelToDescribe": "Jọwọ yan awoṣe ni isalẹ, lẹhinna ṣapejuwe ohun ti o fẹ kọ...", "examplePrompt": "apeere, Ṣẹda ọja ẹrọ ogbin fun awọn agbe agbegbe lati ra ati ta awọn traktọ, awọn irinṣẹ, ati awọn ipese...", "settingsDescription": "Ṣakoso awọn eto ohun elo rẹ ati awọn ayanfẹ.", - "aiSettings": "Awọn eto AI", + "aiSettings": "AI", "aiSettingsDescription": "Tunto awọn olupese AI ati awọn bọtini API", - "gitSettings": "Awọn eto Git", + "gitSettings": "Git", "gitSettingsDescription": "Tunto awọn ẹri Git fun ijẹrisi HTTP", - "nostrSettings": "Awọn eto Nostr", + "nostrSettings": "Nostr", "nostrSettingsDescription": "Tunto awọn asopọ relay ati awọn ayanfẹ Nostr", "storageSettings": "Ibi ipamọ", "storageSettingsDescription": "Gbe awọn faili jade ati ṣakoso data agbegbe", diff --git a/src/locales/zh.json b/src/locales/zh.json index a60f7538..12485f3c 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -11,7 +11,7 @@ "themeDescription": "选择浅色、深色或系统主题偏好。", "language": "语言", "languageDescription": "选择您的界面首选语言。", - "systemSettings": "系统设置", + "systemSettings": "系统", "systemSettingsDescription": "配置系统级设置和高级选项。", "esmUrl": "Javascript CDN URL", "esmUrlDescription": "包导入的 Javascript CDN URL。", @@ -91,14 +91,14 @@ "selectModelToDescribe": "请在下方选择一个模型,然后描述您想要构建的内容...", "examplePrompt": "例如:为当地农民创建一个农业设备市场,用于买卖拖拉机、工具和用品...", "settingsDescription": "管理您的应用程序设置和偏好。", - "aiSettings": "AI设置", + "aiSettings": "AI", "aiSettingsDescription": "配置AI提供商和API密钥", - "gitSettings": "Git设置", + "gitSettings": "Git", "gitSettingsDescription": "配置HTTP身份验证的Git凭据", "deploySettings": "部署", "deploySettingsDescription": "配置部署提供商", "deploySettingsDescriptionLong": "配置部署提供商以将您的项目部署到各种托管平台。", - "nostrSettings": "Nostr设置", + "nostrSettings": "Nostr", "nostrSettingsDescription": "配置中继连接和Nostr偏好", "storageSettings": "存储", "storageSettingsDescription": "导出文件和管理本地数据",