limixbot 0.3.129 → 0.3.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActivityPanel-C092xjIk.js → ActivityPanel-DLm-v_Kg.js} +1 -1
- package/dist/assets/{App-CFt1bVwj.js → App-Co1EFoza.js} +134 -133
- package/dist/assets/{AppEventEditor-C00_DMLy.js → AppEventEditor-BdU7zTya.js} +1 -1
- package/dist/assets/BotSettingsDialog-DZbrG3Yu.js +16 -0
- package/dist/assets/BrowserPanel-BAmkHZNW.js +3 -0
- package/dist/assets/{BrowserProfilesManager-CIDDGvM_.js → BrowserProfilesManager-DL_IVvlO.js} +1 -1
- package/dist/assets/{CloudAddDialog-bLdejHsc.js → CloudAddDialog-Cs6tRBOu.js} +1 -1
- package/dist/assets/{ComputerFilesPane-Ce9ODuX8.js → ComputerFilesPane-Bl6NnCOe.js} +1 -1
- package/dist/assets/{ComputerPanel-Dpekp0Z2.js → ComputerPanel-CzwDPKV_.js} +2 -2
- package/dist/assets/{DataPanel-i5mxANER.js → DataPanel-FEAZNWku.js} +1 -1
- package/dist/assets/{DesktopViewer-B9mw98xI.js → DesktopViewer-Cb9PL6v1.js} +1 -1
- package/dist/assets/{GrokMoveDialog-DYarhzxZ.js → GrokMoveDialog-Bp0mxIE8.js} +1 -1
- package/dist/assets/{InspectorPanel-D5ulGIOz.js → InspectorPanel-DJADxXPA.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-BVDKAY0o.js → KeyboardShortcutsModal-CNiZBEA1.js} +1 -1
- package/dist/assets/{LimixResizeHandles-Jjthi0zS.js → LimixResizeHandles-nzE7n7jC.js} +1 -1
- package/dist/assets/{LiveDesktop-CFqHs50a.js → LiveDesktop-BvdjlV9Q.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-DbB_ec11.js → LocalVmWorkspace-DmQTSD1_.js} +1 -1
- package/dist/assets/{MacLocalControl-DoWLhevV.js → MacLocalControl-WWFi-S9U.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-CCaYi8EP.js → MarkdownFilePreview-BsGqiWI2.js} +1 -1
- package/dist/assets/{MenuMotion-DG5tk0i3.js → MenuMotion-owWIcamS.js} +1 -1
- package/dist/assets/{NewBotDialog-CWbeGI3M.js → NewBotDialog-sr2kfVv6.js} +1 -1
- package/dist/assets/{PhoneAppDialog-BErSSwmM.js → PhoneAppDialog-DC4JUrmh.js} +1 -1
- package/dist/assets/{PlacesRail-CAV7kW3Y.js → PlacesRail-BxdV2GDQ.js} +1 -1
- package/dist/assets/{PluginsPanel-BKQ4in_K.js → PluginsPanel-BMHhkTNZ.js} +5 -5
- package/dist/assets/{ProIntroduction-DgDPOYzn.js → ProIntroduction-CLLJ3Vgd.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-BsD_TT_T.js → RemoteAgentSettingsPanel-DWTstMZc.js} +1 -1
- package/dist/assets/{RoomPanel-UR35p-lT.js → RoomPanel-DuE_Gpr5.js} +1 -1
- package/dist/assets/{RoutinesPage-Cims3t6g.js → RoutinesPage-CPo3eSc1.js} +2 -2
- package/dist/assets/{SettingsModal-2S8H2h_g.js → SettingsModal-BZzK-mss.js} +4 -4
- package/dist/assets/{ShareTeamDialog-org_7J0x.js → ShareTeamDialog-CDkcowQz.js} +1 -1
- package/dist/assets/{SignedInSites-Dp2PSLBK.js → SignedInSites-DLDJv-6U.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-Ch-zZVWY.js → TeamLibraryPanel-X0NQqbX0.js} +1 -1
- package/dist/assets/{TeamMapPage-Ba7y1YPZ.js → TeamMapPage-C6K12Ejq.js} +1 -1
- package/dist/assets/{TriggersPage-qUNQ79Nb.js → TriggersPage-BAXbOt6i.js} +1 -1
- package/dist/assets/VisibilitySection-CC7rEV8o.js +22 -0
- package/dist/assets/{WebhookTrigger-DjYDUzGP.js → WebhookTrigger-cHV0kIQv.js} +1 -1
- package/dist/assets/{WorksOnGrid-wPPuMbjR.js → WorksOnGrid-DZ5DXYgb.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-v0NjYm2N.js → abnfDiagram-YUKMZFIV-vvJbRPlq.js} +1 -1
- package/dist/assets/{activity-DONzM_Hr.js → activity-D26W1wR5.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-C9p47RSg.js → architectureDiagram-47P4ROYG-BxqUvVUX.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-BjCDCsDZ.js → blockDiagram-E7TT5TSB-DDe2YxQP.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-BwcLeGrs.js → c4Diagram-CRA5TL53-OdUvGZP-.js} +1 -1
- package/dist/assets/{calendar-days-C0163EM9.js → calendar-days-OEtSVrLe.js} +1 -1
- package/dist/assets/channel-D_nJ6dC4.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-DkMrEZ1P.js → chunk-2Q5K7J3B-DpnJlpzb.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-BvT5jzrf.js → chunk-5VM5RSS4-C5UgOu8-.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-BPY6DMgY.js → chunk-7TKQ45FW-Dv-gctKP.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-CA02FkCe.js → chunk-AW2ZBBNX-mehzuNgt.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-DR_HIm4k.js → chunk-FVRAUYC3-6bArILty.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF--Q5YJ5qq.js → chunk-HTAEGDNF-0w6XIlls.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-CdUxnp0z.js → chunk-JWPE2WC7-DaZro178.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-CZ_kOJX4.js → chunk-KQW6MTUR-CqA51RiN.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-Baw_LI4a.js → chunk-XXDRQBXY-DPZH_wOz.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-C3p6RSXv.js → classDiagram-v2-K4WV4PDN-Dgn2w_U2.js} +1 -1
- package/dist/assets/{coins-CRTGCu3d.js → coins-D0EwvaZf.js} +1 -1
- package/dist/assets/{core-C6iWxuTj.js → core-Lc3koHof.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-DexASxvw.js → cose-bilkent-JH36ORCC-B9lVmBnW.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-CnBYCH8E.js → cynefin-EF2NZ3EQ-BoirpSv2.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-BxlPVTxc.js → cynefinDiagram-3GCD6N5R-Cdmdj7_K.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-DwHsGS35.js → dagre-W4DXFKR2-BFjlE582.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-BitCWJhQ.js → diagram-2UJZ2QOL-OsLSZez_.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-DVq8AK9P.js → diagram-OVF4WLC6-CwDUdKBh.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-B1CGGTYD.js → diagram-PFPMY2P6-BLtFTcT4.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-BJOrT_fX.js → diagram-UMYRVEAY-BSLF9HqA.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-CqTidMyp.js → diagram-YEKJPTXX-9rCjHXiY.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-BrETFWbJ.js → diagram-ZIFT7M5P-C4BY_KLT.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-odzlCiG_.js → ebnfDiagram-VR2GEFS7-AhQ5NsrM.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-DOqejjFU.js → elk-IJKZMXRS-UnH28E2R.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-pus74-u1.js → erDiagram-O2IAPWRE-CO0nepRl.js} +1 -1
- package/dist/assets/{file-up-VlqNWssp.js → file-up-D-jXnd_Y.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-BoR02YXy.js → flowDiagram-OXPTDLAJ-DdStYfx7.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-DEWJjq9w.js → ganttDiagram-R7TSEDQI-DH8CA0Mt.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-A0Ut1vzJ.js → gitGraphDiagram-XJZIOB7I-Ds4256L4.js} +1 -1
- package/dist/assets/{import-name-Dzn9IajS.js → import-name-CHPmMQSU.js} +1 -1
- package/dist/assets/{index-ByrnprY3.js → index-CFBg45ji.js} +1 -1
- package/dist/assets/{index-DoClz3zG.js → index-CGhQDBT_.js} +3 -3
- package/dist/assets/{infoDiagram-5W2HQ5XZ-IrI9xNS5.js → infoDiagram-5W2HQ5XZ-mNLO1zPg.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-CcZaBkPV.js → ishikawaDiagram-K3B6WC7H-Daak_Ht_.js} +1 -1
- package/dist/assets/{journeyDiagram-COXZFDF6-Lhq1JIrG.js → journeyDiagram-COXZFDF6-U58GAPno.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-Dpnd1w1Z.js → kanban-definition-P3RFRI5V-CcRE6J9f.js} +1 -1
- package/dist/assets/{mermaid.core-CwYv1-pN.js → mermaid.core-QHRYQaNt.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-BQu-1VuI.js → mindmap-definition-LZFPQGKD-CEyDomxS.js} +1 -1
- package/dist/assets/{minimize-BRtvUvR3.js → minimize-oQ71ZbVB.js} +1 -1
- package/dist/assets/{monitor-Gc_xwWHG.js → monitor-BmIglcrr.js} +1 -1
- package/dist/assets/{new-bot-CMIOaWIO.js → new-bot-tCPJjkMQ.js} +1 -1
- package/dist/assets/{org-library-CwIWLSKR.js → org-library-Dr5sX_Fu.js} +1 -1
- package/dist/assets/{package-format-C4Kbcf94.js → package-format-heZrOI7V.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-C2kBJx8q.js → pegDiagram-BGZESJAR-CTxI-cP8.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-3IGf8-rd.js → pieDiagram-CAPJLFHJ-B8DCNi6O.js} +1 -1
- package/dist/assets/{quadrantDiagram-GDMTTRAM-Ds0i1JJu.js → quadrantDiagram-GDMTTRAM-CWdpAW4W.js} +1 -1
- package/dist/assets/{rail-BxO9nJ7b.js → rail-WaxapGbo.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-C5HMZeLZ.js → railroadDiagram-SM67HX2B-BCY8OR1i.js} +1 -1
- package/dist/assets/{remote-desktop-panel-z23u6kyq.js → remote-desktop-panel-CRSqL4w9.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-W7wEhXbS.js → requirementDiagram-X7JNWC4A-BcX43ufU.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-BIIvZEMK.js → sankeyDiagram-UM26HJRW-C3YBTWo7.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-B6ZAapb0.js → sequenceDiagram-ZO4K6R2Y-CNLzalKN.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-CijBtoJ-.js → sizeCapture-INFHLROL-D55E_ZEd.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-gVAJTp58.js → stateDiagram-v2-TBUQTH76-CRDCsicX.js} +1 -1
- package/dist/assets/styles-Cr4TcnLq.css +1 -0
- package/dist/assets/{styles-Be5qq6WR.js → styles-D7SaLPZf.js} +2 -2
- package/dist/assets/{swimlanes-N4OXWK64-1T5CmmoT.js → swimlanes-N4OXWK64-Ah7OauuN.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-G_1ilp2C.js +8 -0
- package/dist/assets/{team-share-DZ71boDj.js → team-share-D3Hwdncm.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-b2WZ1F71.js → timeline-definition-YOQAKGHF-DV-V6CCB.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-DvPVm705.js → usecaseDiagram-VIAY4XPW-T9J5Wpir.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-BG-PWVxl.js → vennDiagram-BLWOH2XV-RqJjHEmQ.js} +1 -1
- package/dist/assets/{vi-DltOYiYl.js → vi-Bu86KxVI.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-5xjAr3nW.js → wardleyDiagram-YMQ3BMBF-xZxQC8Rt.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-DgoVlD5n.js → xychartDiagram-TAQBALBS-BgPG2lil.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/rail.html +6 -6
- package/dist-server/bot-box/box-check.js +6 -6
- package/dist-server/drivers/agents-proxy.js +50 -48
- package/dist-server/hybrid-plugin-gateway.js +1489 -0
- package/dist-server/index.js +5546 -5454
- package/dist-server/limixbot.js +517 -508
- package/dist-server/mcp-gate.js +76 -61
- package/dist-server/mcp-remote-proxy.js +26 -23
- package/dist-server/mcp-server.js +28 -25
- package/dist-server/package.json +1 -1
- package/dist-server/pair-cli.js +517 -508
- package/dist-server/scripts/mcp-server.js +30 -27
- package/dist-server/server/agents-turn.js +1 -0
- package/dist-server/server/auto-approve.js +2 -0
- package/dist-server/server/bot-box/env.js +2 -2
- package/dist-server/server/cli-usage.js +2 -2
- package/dist-server/server/drivers/acp/native-process-sampler.js +84 -0
- package/dist-server/server/drivers/acp/quiet-status.js +12 -3
- package/dist-server/server/drivers/agents-call.js +4 -0
- package/dist-server/server/drivers/agents-catalog-profile.js +1 -0
- package/dist-server/server/drivers/agents-catalog.js +16 -1
- package/dist-server/server/drivers/agents-mcp-env.js +1 -1
- package/dist-server/server/drivers/claude-elicitation.js +21 -9
- package/dist-server/server/drivers/elicited-consent.js +24 -0
- package/dist-server/server/headless/client.js +10 -9
- package/dist-server/server/headless/main.js +1 -1
- package/dist-server/server/hybrid-plugin-gateway.js +162 -0
- package/dist-server/server/hybrid-plugin-manifest.js +99 -0
- package/dist-server/server/index.js +41 -3
- package/dist-server/server/limix-native-path.js +8 -0
- package/dist-server/server/mcp-app-connections.js +58 -5
- package/dist-server/server/mcp-gate-tasks.js +75 -0
- package/dist-server/server/mcp-gate.js +81 -5
- package/dist-server/server/mcp-http.js +34 -6
- package/dist-server/server/mcp-native-response.js +112 -0
- package/dist-server/server/mcp-skills.js +263 -0
- package/dist-server/server/mcp-trim.js +15 -8
- package/dist-server/server/plugin-hub.js +259 -25
- package/dist-server/server/plugin-passages.js +16 -0
- package/dist-server/server/routes/plugin-mcp.js +118 -0
- package/dist-server/server/routes/plugin-studio.js +50 -0
- package/dist-server/server/side-jobs.js +1 -1
- package/dist-server/shared/plugin-hub.js +6 -2
- package/dist-server/vps-container-mcp.js +6 -6
- package/package.json +1 -1
- package/skills/limix-bot-factory/SKILL.md +2 -0
- package/skills/limix-bot-factory/assets/schemas/bot-spec.schema.json +14 -0
- package/skills/limix-bot-factory/references/integration-blueprint.md +1 -1
- package/skills/limix-bot-factory/references/vi.md +4 -0
- package/skills/limix-bot-factory/scripts/factorylib/cli.py +2 -1
- package/skills/limix-bot-factory/scripts/factorylib/core.py +19 -1
- package/skills/limix-bot-factory/scripts/factorylib/engine.py +10 -1
- package/skills/limix-bot-factory/scripts/mcp_server.py +3 -3
- package/dist/assets/BotSettingsDialog-81Yk4G56.js +0 -16
- package/dist/assets/BrowserPanel-BZiZr6JO.js +0 -3
- package/dist/assets/VisibilitySection-DdEr_5bZ.js +0 -22
- package/dist/assets/channel-BloV1v8U.js +0 -1
- package/dist/assets/mcp-servers-iT-sFJLT.js +0 -1
- package/dist/assets/styles-DiAFRlxu.css +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-D0mOoyOD.js +0 -8
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, statSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { once } from "node:events";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { parseDocument } from "yaml";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { approvedForExport, pluginId } from "./hybrid-plugin-manifest.js";
|
|
9
|
+
const pin = z.object({ id: pluginId, sha256: z.string().regex(/^[a-f0-9]{64}$/), kind: z.enum(["skills", "resources"]), name: z.string().regex(/^[a-z0-9-]{1,64}$/) }).strict();
|
|
10
|
+
const pins = z.array(pin).min(1).max(32);
|
|
11
|
+
const grantSchema = z.object({ tokenHash: z.string().regex(/^[a-f0-9]{64}$/), pins });
|
|
12
|
+
const digest = (value) => createHash("sha256").update(value).digest("hex");
|
|
13
|
+
const revision = "2026-07-28";
|
|
14
|
+
const cache = { ttlMs: 0, cacheScope: "private" };
|
|
15
|
+
const clientId = z.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/);
|
|
16
|
+
function grantFile(dir, client) {
|
|
17
|
+
return join(dir, "plugin-gateway", clientId.parse(client) + ".json");
|
|
18
|
+
}
|
|
19
|
+
function entries(dir, allowed) {
|
|
20
|
+
const dbFile = join(dir, "plugin-library.json");
|
|
21
|
+
if (!existsSync(dbFile) || statSync(dbFile).size > 32 * 1024 * 1024)
|
|
22
|
+
return [];
|
|
23
|
+
const db = JSON.parse(readFileSync(dbFile, "utf8"));
|
|
24
|
+
if (db.schemaVersion !== 2 || !Array.isArray(db.installed))
|
|
25
|
+
return [];
|
|
26
|
+
return allowed.flatMap(pin => {
|
|
27
|
+
const approved = approvedForExport(db, pin.id, pin.sha256);
|
|
28
|
+
if (approved?.type !== "local")
|
|
29
|
+
return [];
|
|
30
|
+
const part = approved.components[pin.kind].find(item => item.name === pin.name);
|
|
31
|
+
if (!part)
|
|
32
|
+
return [];
|
|
33
|
+
const uri = pin.kind === "skills" ? `skill://${pin.id}/${part.name}/SKILL.md` : `limix-resource://${pin.id}/${part.name}`;
|
|
34
|
+
return [{ ...part, kind: pin.kind, uri }];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export function grantPluginAccess(dir, client, input) {
|
|
38
|
+
const selected = pins.parse(input);
|
|
39
|
+
const available = entries(dir, selected);
|
|
40
|
+
if (new Set(available.map(part => part.uri)).size !== selected.length)
|
|
41
|
+
throw Error("Every component must belong to an approved local revision");
|
|
42
|
+
const file = grantFile(dir, client);
|
|
43
|
+
mkdirSync(join(dir, "plugin-gateway"), { recursive: true, mode: 0o700 });
|
|
44
|
+
const token = randomBytes(32).toString("hex");
|
|
45
|
+
writeFileSync(file, JSON.stringify({ pins: selected, tokenHash: digest(token) }), { mode: 0o600, flag: "wx" });
|
|
46
|
+
return token;
|
|
47
|
+
}
|
|
48
|
+
export function pluginGateway(dir, client, token) {
|
|
49
|
+
const file = grantFile(dir, client);
|
|
50
|
+
const serverInfo = { name: "Limix MCP Gateway", version: "1.0.0" };
|
|
51
|
+
let started = 0, requests = 0;
|
|
52
|
+
return (method, params) => {
|
|
53
|
+
const grant = grantSchema.parse(JSON.parse(readFileSync(file, "utf8")));
|
|
54
|
+
if (!timingSafeEqual(Buffer.from(digest(token), "hex"), Buffer.from(grant.tokenHash, "hex")))
|
|
55
|
+
throw Error("Access denied");
|
|
56
|
+
if (Date.now() - started >= 60000) {
|
|
57
|
+
started = Date.now();
|
|
58
|
+
requests = 0;
|
|
59
|
+
}
|
|
60
|
+
if (++requests > 120)
|
|
61
|
+
throw Error("Request limit exceeded");
|
|
62
|
+
const audit = join(dir, "plugin-gateway", client + ".audit.jsonl");
|
|
63
|
+
if (existsSync(audit) && statSync(audit).size > 1024 * 1024)
|
|
64
|
+
renameSync(audit, audit + ".1");
|
|
65
|
+
appendFileSync(audit, JSON.stringify({ at: new Date().toISOString(), method: method.slice(0, 80) }) + "\n", { mode: 0o600 });
|
|
66
|
+
const capabilities = { resources: {}, tools: {}, extensions: { "io.modelcontextprotocol/skills": {} } };
|
|
67
|
+
if (method === "initialize")
|
|
68
|
+
return { protocolVersion: "2025-11-25", capabilities: { resources: {}, tools: {} }, serverInfo };
|
|
69
|
+
const meta = params._meta;
|
|
70
|
+
const version = meta?.["io.modelcontextprotocol/protocolVersion"];
|
|
71
|
+
if (version !== undefined && version !== revision)
|
|
72
|
+
throw Error("Unsupported protocol revision");
|
|
73
|
+
const modern = version === revision;
|
|
74
|
+
const wrap = (result) => modern ? { resultType: "complete", ...cache, ...result } : result;
|
|
75
|
+
if (method === "server/discover" && modern)
|
|
76
|
+
return wrap({ supportedVersions: [revision], capabilities, _meta: { "io.modelcontextprotocol/serverInfo": serverInfo } });
|
|
77
|
+
if (method === "ping")
|
|
78
|
+
return wrap({});
|
|
79
|
+
const available = entries(dir, grant.pins);
|
|
80
|
+
const description = ({ uri, name, description }) => ({ uri, name, description, mimeType: "text/markdown" });
|
|
81
|
+
const skills = available.filter(part => part.kind === "skills").map(part => {
|
|
82
|
+
const header = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(part.content);
|
|
83
|
+
if (!header)
|
|
84
|
+
throw Error("Invalid skill");
|
|
85
|
+
const doc = parseDocument(header[1], { schema: "core", uniqueKeys: true });
|
|
86
|
+
if (doc.errors.length || doc.warnings.length)
|
|
87
|
+
throw Error("Invalid skill");
|
|
88
|
+
return { uri: part.uri, frontmatter: doc.toJS({ maxAliasCount: 0 }), resources: [{ uri: part.uri, digest: "sha256:" + digest(part.content), size: Buffer.byteLength(part.content) }] };
|
|
89
|
+
});
|
|
90
|
+
if (method === "skills/list" && modern)
|
|
91
|
+
return wrap({ skills });
|
|
92
|
+
if (method === "skills/get" && modern) {
|
|
93
|
+
const skill = skills.find(part => part.uri === params.uri);
|
|
94
|
+
if (skill)
|
|
95
|
+
return wrap({ skill });
|
|
96
|
+
}
|
|
97
|
+
if (method === "resources/list")
|
|
98
|
+
return wrap({ resources: available.map(description) });
|
|
99
|
+
if (method === "tools/list")
|
|
100
|
+
return wrap({ tools: [{ name: "read_plugin_resource", description: "Read an explicitly shared plugin resource by URI.", inputSchema: { type: "object", additionalProperties: false, properties: { uri: { type: "string" } }, required: ["uri"] } }] });
|
|
101
|
+
if (method === "resources/read" || (method === "tools/call" && params.name === "read_plugin_resource")) {
|
|
102
|
+
const uri = method === "resources/read" ? params.uri : params.arguments?.uri;
|
|
103
|
+
const row = available.find(part => part.uri === uri);
|
|
104
|
+
if (row)
|
|
105
|
+
return wrap(method === "resources/read" ? { contents: [{ uri: row.uri, mimeType: "text/markdown", text: row.content }] } : { content: [{ type: "text", text: row.content }] });
|
|
106
|
+
}
|
|
107
|
+
throw Error("Unknown method or unavailable component");
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
async function main() {
|
|
111
|
+
const [command, directory, client, input] = process.argv.slice(2);
|
|
112
|
+
if (!directory || !client)
|
|
113
|
+
throw Error("Usage: hybrid-plugin-gateway.ts grant|serve|revoke DATA_DIR CLIENT [PINS.json]");
|
|
114
|
+
const dir = resolve(directory);
|
|
115
|
+
if (command === "grant" && input) {
|
|
116
|
+
process.stdout.write(grantPluginAccess(dir, client, JSON.parse(readFileSync(input, "utf8"))) + "\n");
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (command === "revoke") {
|
|
120
|
+
unlinkSync(grantFile(dir, client));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (command !== "serve" || !process.env.LIMIX_PLUGIN_GATEWAY_TOKEN)
|
|
124
|
+
throw Error("A client token is required to serve");
|
|
125
|
+
const rpc = pluginGateway(dir, client, process.env.LIMIX_PLUGIN_GATEWAY_TOKEN);
|
|
126
|
+
const send = async (response) => {
|
|
127
|
+
if (!process.stdout.write(JSON.stringify(response) + "\n"))
|
|
128
|
+
await once(process.stdout, "drain");
|
|
129
|
+
};
|
|
130
|
+
let buffer = "";
|
|
131
|
+
process.stdin.setEncoding("utf8");
|
|
132
|
+
for await (const chunk of process.stdin) {
|
|
133
|
+
buffer += chunk;
|
|
134
|
+
let pos;
|
|
135
|
+
while ((pos = buffer.indexOf("\n")) >= 0) {
|
|
136
|
+
if (pos > 65536)
|
|
137
|
+
throw Error("Request exceeds 64 KiB");
|
|
138
|
+
const line = buffer.slice(0, pos);
|
|
139
|
+
buffer = buffer.slice(pos + 1);
|
|
140
|
+
let id = null;
|
|
141
|
+
try {
|
|
142
|
+
const msg = JSON.parse(line);
|
|
143
|
+
if (msg.jsonrpc !== "2.0" || typeof msg.method !== "string")
|
|
144
|
+
throw Error("Invalid request");
|
|
145
|
+
if (msg.id === undefined)
|
|
146
|
+
continue;
|
|
147
|
+
if (typeof msg.id !== "string" && typeof msg.id !== "number")
|
|
148
|
+
throw Error("Invalid request");
|
|
149
|
+
id = msg.id;
|
|
150
|
+
await send({ jsonrpc: "2.0", id, result: rpc(msg.method, msg.params ?? {}) });
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
await send({ jsonrpc: "2.0", id, error: { code: -32602, message: "Invalid request or access denied" } });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (buffer.length > 65536)
|
|
157
|
+
throw Error("Request exceeds 64 KiB");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
|
161
|
+
main().catch(() => { process.stderr.write("Limix MCP Gateway could not complete the request. Check client, grant and workspace.\n"); process.exitCode = 1; });
|
|
162
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { pluginContentKinds } from "../shared/plugin-hub.js";
|
|
4
|
+
import { isSkillName, parseSkillMd, scanSkillText, SKILL_FILE_MAX_BYTES } from "../shared/skill-md.js";
|
|
5
|
+
import { holdsCredential } from "../shared/redact.js";
|
|
6
|
+
export const pluginId = z.string().max(80).regex(/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/);
|
|
7
|
+
export const pluginVersion = z.string().max(40).regex(/^\d+\.\d+\.\d+$/);
|
|
8
|
+
export const labels = (max) => z.object({ en: z.string().min(1).max(max), vi: z.string().min(1).max(max) }).strict();
|
|
9
|
+
export const serverName = z.string().regex(/^[\w-]{1,80}$/);
|
|
10
|
+
const unique = (entries) => new Set(entries).size === entries.length;
|
|
11
|
+
const text = z.object({
|
|
12
|
+
name: z.string().refine(isSkillName), description: z.string().min(1).max(1024), content: z.string().min(1).max(SKILL_FILE_MAX_BYTES),
|
|
13
|
+
}).strict();
|
|
14
|
+
const texts = z.array(text).max(32).refine(items => unique(items.map(item => item.name))).default([]);
|
|
15
|
+
const source = z.object({ server: serverName, uri: z.string().min(1).max(2048), revision: z.string().min(1).max(512) }).strict();
|
|
16
|
+
export const manifestSchema = z.object({
|
|
17
|
+
schemaVersion: z.literal("1.0.0"), id: pluginId, version: pluginVersion, name: labels(96), description: labels(1024),
|
|
18
|
+
license: z.string().trim().min(1).max(512), type: z.enum(["local", "remote-mcp", "hybrid"]),
|
|
19
|
+
components: z.object({
|
|
20
|
+
skills: texts, resources: texts, frameworks: texts, guardrails: texts,
|
|
21
|
+
mcpServers: z.array(serverName).max(12).refine(unique).default([]),
|
|
22
|
+
tools: z.array(z.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/)).max(64).refine(unique).default([]),
|
|
23
|
+
}).strict(),
|
|
24
|
+
localization: z.union([
|
|
25
|
+
z.object({ core: z.literal("en"), interface: z.literal("vi") }).strict(),
|
|
26
|
+
z.object({ core: z.literal("original"), interface: z.literal("original") }).strict(),
|
|
27
|
+
]),
|
|
28
|
+
source: source.optional(),
|
|
29
|
+
permissions: z.object({ shell: z.literal(false), filesystem: z.array(z.string()).max(0), network: z.array(z.string()).max(0), secrets: z.array(z.string()).max(0) }).strict().optional(),
|
|
30
|
+
security: z.object({ approvalRequired: z.literal(true), sandboxRequired: z.literal(true), verifyIntegrity: z.literal(true) }).strict().optional(),
|
|
31
|
+
}).strict().superRefine((m, ctx) => {
|
|
32
|
+
const issue = (message) => ctx.addIssue({ code: "custom", message });
|
|
33
|
+
const remote = m.components.mcpServers.length > 0;
|
|
34
|
+
const content = pluginContentKinds.some(kind => m.components[kind].length > 0);
|
|
35
|
+
if (remote !== (m.type !== "local"))
|
|
36
|
+
issue("The manifest type must match its MCP connections");
|
|
37
|
+
if (m.type === "hybrid" && !content)
|
|
38
|
+
issue("A hybrid plugin needs a local component");
|
|
39
|
+
if (!remote && !content && !m.components.tools.length)
|
|
40
|
+
issue("The package is empty");
|
|
41
|
+
if (m.source && (m.type !== "remote-mcp" || !m.components.mcpServers.includes(m.source.server)))
|
|
42
|
+
issue("Invalid skill origin");
|
|
43
|
+
if (!m.source && m.localization.core !== "en")
|
|
44
|
+
issue("Local packages require an English core");
|
|
45
|
+
const encoded = JSON.stringify(m);
|
|
46
|
+
if (Buffer.byteLength(encoded) > 512 * 1024)
|
|
47
|
+
issue("Package exceeds the 512 KiB limit");
|
|
48
|
+
if (holdsCredential(encoded))
|
|
49
|
+
issue("A plugin manifest cannot contain credentials");
|
|
50
|
+
for (const skill of m.components.skills) {
|
|
51
|
+
const parsed = parseSkillMd(skill.content);
|
|
52
|
+
if ("error" in parsed || parsed.name !== skill.name || !parsed.body.trim())
|
|
53
|
+
issue("SKILL.md must contain a matching name, description and body");
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
export const hurdleEvaluation = z.object({
|
|
57
|
+
schemaVersion: z.union([z.literal(2), z.literal(3)]),
|
|
58
|
+
id: z.string().regex(/^run_[0-9a-f-]{36}$/),
|
|
59
|
+
state: z.literal("complete"),
|
|
60
|
+
verdict: z.enum(["pass", "fail", "incomplete", "unknown"]),
|
|
61
|
+
snapshotFingerprint: z.string().regex(/^sha256:[0-9a-f]{64}$/),
|
|
62
|
+
}).strict();
|
|
63
|
+
export const scanPluginContent = manifest => {
|
|
64
|
+
const warnings = new Set();
|
|
65
|
+
const inspect = (label, value) => {
|
|
66
|
+
for (const warning of scanSkillText(value))
|
|
67
|
+
warnings.add(label + ": " + warning);
|
|
68
|
+
if (/\b(ignore|override|bypass|disregard)\b.{0,48}\b(instructions?|policy|policies|permissions?|approval)\b/i.test(value)) {
|
|
69
|
+
warnings.add(label + ": instructions may attempt to override host policy");
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
for (const kind of pluginContentKinds) {
|
|
73
|
+
for (const part of manifest.components[kind])
|
|
74
|
+
inspect(kind + "/" + part.name, part.description + "\n" + part.content);
|
|
75
|
+
}
|
|
76
|
+
for (const lang of ["en", "vi"])
|
|
77
|
+
inspect(lang, manifest.name[lang] + "\n" + manifest.description[lang]);
|
|
78
|
+
if (manifest.source && manifest.license === "Unspecified")
|
|
79
|
+
warnings.add("Remote source does not declare a license");
|
|
80
|
+
return [...warnings];
|
|
81
|
+
};
|
|
82
|
+
export function reviewManifest(manifest, evaluate = scanPluginContent) {
|
|
83
|
+
const { id, version, name, description } = manifest;
|
|
84
|
+
const sha256 = createHash("sha256").update(JSON.stringify(manifest)).digest("hex");
|
|
85
|
+
return { id, version, name, description, requiresMcp: manifest.components.mcpServers, manifest, sha256, warnings: evaluate(manifest) };
|
|
86
|
+
}
|
|
87
|
+
export function approvedForExport(input, id, sha256) {
|
|
88
|
+
const library = z.object({ schemaVersion: z.literal(2), installed: z.array(z.unknown()) }).safeParse(input);
|
|
89
|
+
if (!library.success)
|
|
90
|
+
return null;
|
|
91
|
+
for (const row of library.data.installed) {
|
|
92
|
+
if (!row || typeof row !== "object" || !("sha256" in row) || row.sha256 !== sha256 || !("manifest" in row))
|
|
93
|
+
continue;
|
|
94
|
+
const checked = manifestSchema.safeParse(row.manifest);
|
|
95
|
+
if (checked.success && checked.data.id === id && !checked.data.source && reviewManifest(checked.data).sha256 === sha256)
|
|
96
|
+
return checked.data;
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
@@ -136,7 +136,7 @@ import { DataFailure } from "./data/types.js";
|
|
|
136
136
|
import { TeamComputers, teamComputerOwner } from "./team-computers.js";
|
|
137
137
|
import { isEffortLevel } from "../shared/wire.js";
|
|
138
138
|
import { isPersistentQuestionCard, shouldSettleRequestCard } from "../shared/ask-question.js";
|
|
139
|
-
import { parseToolScope } from "../shared/tool-scope.js";
|
|
139
|
+
import { allowsTool, canUseMcpServer, parseToolScope } from "../shared/tool-scope.js";
|
|
140
140
|
import { boatCreateRecoverySnapshot } from "./boat-create-idempotency.js";
|
|
141
141
|
import { boatDeletionSnapshot } from "./boat-delete-journal.js";
|
|
142
142
|
import { liveDecisionRefusal } from "../shared/live-approval.js";
|
|
@@ -535,6 +535,10 @@ import { createGroupOrderRoutes } from "./routes/group-order.js";
|
|
|
535
535
|
import { createBotLifecycleRoutes } from "./routes/bot-lifecycle.js";
|
|
536
536
|
import { createBotSkillsRoutes } from "./routes/bot-skills.js";
|
|
537
537
|
import { startHubAutoSync } from "./limix-skill-hub.js";
|
|
538
|
+
import { createPluginStudio } from "./routes/plugin-studio.js";
|
|
539
|
+
import { createPluginMcpRoutes, readPluginComponent } from "./routes/plugin-mcp.js";
|
|
540
|
+
import { customMcpServers as pluginServerSpecs } from "./config.js";
|
|
541
|
+
import { withMcpSignIn } from "./mcp-oauth.js";
|
|
538
542
|
import { createPluginHub } from "./plugin-hub.js";
|
|
539
543
|
import { limixBundledFor, limixSelectBundled, limixSkillDefaultsMigration } from "./limix-skill-store.js";
|
|
540
544
|
import { createSkillShareRoutes } from "./routes/skill-share.js";
|
|
@@ -1849,7 +1853,7 @@ researchAvailability.available();
|
|
|
1849
1853
|
function agentsIntegration(botId, threadId, depth, skillAuthoring, generation, roomHandoffId, hostFiles = false, automated = false) {
|
|
1850
1854
|
const bot = store.bot(botId), speaking = botForThread(botId, threadId) ?? bot;
|
|
1851
1855
|
// Only advertises the tools; the routes behind them refuse regardless.
|
|
1852
|
-
const host = { skillAuthoring: skillAuthoringEnabled(cfg), sharedComputers: botLending(), cloudHome: Boolean(CLOUD_HOME), team: Boolean(CLOUD_TEAM),
|
|
1856
|
+
const host = { pluginRead: Boolean(bot && pluginHub.hasComponents(bot, Object.keys(engineMcpServers(bot)))), skillAuthoring: skillAuthoringEnabled(cfg), sharedComputers: botLending(), cloudHome: Boolean(CLOUD_HOME), team: Boolean(CLOUD_TEAM),
|
|
1853
1857
|
voiceNotes: tts.voiceReady(cfg, speaking?.voice) && speaking?.voiceNotes !== false, x: Boolean(researchCredential(cfg.treg?.key)), research: researchAvailability.available(), imageGeneration: imageGenerationReady(cfg), meetings: boat.boatConfigured(cfg) };
|
|
1854
1858
|
return { ...agentsProxyLaunch(), env: agentsServerEnv({ threadId, bot: bot ?? { id: botId }, room: Boolean(store.groupByThread(threadId)), teamComputer: Boolean(bot && inheritedTeamComputer(bot)), botDriven: automated || botDrivenConversation(store.taskByThread(botId, threadId)), host }, { generation, depth, skillAuthoring, roomHandoffId, ...(hostFiles && !CLOUD_HOME && !HOSTED_WORKSPACE ? { deliversSavedFiles: true } : {}) }, (turn) => mintInternalCapability({ botId, threadId, kind: "agents", createdBots: 0, openedThreads: 0, ...turn }), `http://127.0.0.1:${PORT}`) };
|
|
1855
1859
|
}
|
|
@@ -6773,6 +6777,7 @@ bus.subscribe((event) => {
|
|
|
6773
6777
|
const verdict = permission && asker && event.requestId
|
|
6774
6778
|
? heldAtSafetyFloor(event, autoVerdict(effectiveApprovalMode, event.tool, {
|
|
6775
6779
|
requiresExplicitApproval: event.requiresExplicitApproval,
|
|
6780
|
+
humanElicitation: event.humanElicitation,
|
|
6776
6781
|
commandAllowed: Boolean(command && commandAllowlist.matches(asker.id, command)),
|
|
6777
6782
|
toolAllowed: Boolean(toolAllowKey && asker.alwaysAllow?.includes(toolAllowKey)), ownFilesRead: !guestDriven && readsOwnFiles(DATA_DIR, asker.id, event), // never in a guest's turn: the folder holds its owner's memory
|
|
6778
6783
|
}))
|
|
@@ -12591,6 +12596,22 @@ const pluginHub = createPluginHub(DATA_DIR, () => ({
|
|
|
12591
12596
|
teams: store.sections.filter(Boolean),
|
|
12592
12597
|
}));
|
|
12593
12598
|
pluginHub.pruneTeams(store.sections);
|
|
12599
|
+
async function resolvePluginServer(name, botId) {
|
|
12600
|
+
if (!Object.hasOwn(cfg.mcpServers ?? {}, name) || teamConnections.personMcp().includes(name))
|
|
12601
|
+
return null;
|
|
12602
|
+
const spec = managedPolicy.filterMcp(pluginServerSpecs(cfg, [name]))[name];
|
|
12603
|
+
if (!spec || ("url" in spec && botBox.enabled()))
|
|
12604
|
+
return null;
|
|
12605
|
+
await mcpKeys.warm(name, spec);
|
|
12606
|
+
const keyed = mcpKeys.resolve(name, spec, botId);
|
|
12607
|
+
if (!keyed.ok)
|
|
12608
|
+
return null;
|
|
12609
|
+
return (await withMcpSignIn({ [name]: keyed.server }, mcpOAuth))[name] ?? null;
|
|
12610
|
+
}
|
|
12611
|
+
ROUTES.push(createPluginMcpRoutes(pluginHub, resolvePluginServer, DATA_DIR), createPluginStudio(async (botId, prompt, signal) => {
|
|
12612
|
+
assertWithinBudget(cfg, DATA_DIR);
|
|
12613
|
+
return sideJobs.text("plugin-draft", botId)?.generateText(prompt, { timeoutMs: 45_000, signal });
|
|
12614
|
+
}));
|
|
12594
12615
|
const skillsRoutes = createBotSkillsRoutes({ store, cfg, listBotSkills, readBotSkillFile, stagedSkillListing });
|
|
12595
12616
|
ROUTES.push(skillsRoutes, pluginHub.route);
|
|
12596
12617
|
startHubAutoSync();
|
|
@@ -13097,7 +13118,7 @@ const handleRequest = async (req, res) => {
|
|
|
13097
13118
|
// Two public routes come first; everything else needs the loopback owner or a paired session with the right scope.
|
|
13098
13119
|
if (method === "GET" && !path.startsWith("/api/") && !path.startsWith("/.well-known/") && (moveFreeze.screen(path) ? (res.writeHead(302, { location: moveFreeze.screen(path), "cache-control": "no-store" }).end(), true) : serveStatic(res, path, STATIC_DIR)))
|
|
13099
13120
|
return;
|
|
13100
|
-
if (method === "GET" && path === "/.well-known/openmausbot/environment") {
|
|
13121
|
+
if (method === "GET" && (path === "/.well-known/limixbot/environment" || path === "/.well-known/openmausbot/environment")) {
|
|
13101
13122
|
return json(res, 200, environmentDescriptor({ environmentId: ENVIRONMENT_ID, ...TEAM_LABEL, desktopManaged: DESKTOP_MANAGED, emailSignIn: !HOSTED_WORKSPACE && !CLOUD_HOME && emailSignIn.enabled(), sharedComputers: lendingEnabled(), cloudHome: Boolean(CLOUD_HOME), cloudTeam: CLOUD_TEAM !== null, ownHome: ownHome.takesMove() }));
|
|
13102
13123
|
}
|
|
13103
13124
|
const domainCheck = /^\/\.well-known\/openmausbot\/domain-check\/([a-f0-9]{64})$/.exec(path);
|
|
@@ -14210,6 +14231,23 @@ const handleRequest = async (req, res) => {
|
|
|
14210
14231
|
task: store.taskByThread(from.id, threadId)?.title,
|
|
14211
14232
|
});
|
|
14212
14233
|
}
|
|
14234
|
+
if (method === "POST" && path === "/api/internal/plugin-read") {
|
|
14235
|
+
const input = await readInternalBody();
|
|
14236
|
+
if ((internalCapability.pluginReads ?? 0) >= 32)
|
|
14237
|
+
return json(res, 429, { error: "Plugin read budget exhausted for this turn" });
|
|
14238
|
+
internalCapability.pluginReads = (internalCapability.pluginReads ?? 0) + 1;
|
|
14239
|
+
if (!allowsTool(internalSender.toolScope, { kind: "mcp", server: "agents", name: "plugin_read" }, input))
|
|
14240
|
+
return json(res, 403, { error: "Plugin reads disabled for this bot" });
|
|
14241
|
+
const allowed = () => Object.keys(engineMcpServers(internalSender)).filter(name => canUseMcpServer(internalSender.toolScope, name));
|
|
14242
|
+
const result = await readPluginComponent(pluginHub, resolvePluginServer, internalSender, allowed, input, DATA_DIR, mcpServersHost.probeAs({ bot: internalSender.id }), origin => {
|
|
14243
|
+
if (internalCapability.pluginOrigin && internalCapability.pluginOrigin !== origin)
|
|
14244
|
+
return false;
|
|
14245
|
+
internalCapability.pluginOrigin = origin;
|
|
14246
|
+
return true;
|
|
14247
|
+
});
|
|
14248
|
+
requireActiveInternalCapability();
|
|
14249
|
+
return json(res, result.status, result.body);
|
|
14250
|
+
}
|
|
14213
14251
|
if (method === "GET" && path === "/api/internal/skills") {
|
|
14214
14252
|
if (!skillAuthoringEnabled(cfg))
|
|
14215
14253
|
return json(res, 403, { error: "skill authoring is not enabled in Settings" });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { SERVER_ROOT } from "./proxy-paths.js";
|
|
3
|
+
export function limixNativeResource(name) {
|
|
4
|
+
const directory = import.meta.url.endsWith(".ts")
|
|
5
|
+
? join(SERVER_ROOT, "..", "dist-native", "limix-native", `${process.platform}-${process.arch}`)
|
|
6
|
+
: join(SERVER_ROOT, "..", "limix-native");
|
|
7
|
+
return join(directory, name);
|
|
8
|
+
}
|
|
@@ -6,13 +6,14 @@ import { APP_EXTENSION_KEY } from "../shared/app.js";
|
|
|
6
6
|
import { botBox } from "./bot-box/box.js";
|
|
7
7
|
import { createLineSplitter } from "./mcp-bridge.js";
|
|
8
8
|
import { UI_EXTENSION, withUiExtension } from "./mcp-app-observer.js";
|
|
9
|
-
import { MAX_REMOTE_MCP_BYTES, McpHttpError, McpRpcError, REMOTE_MCP_STARTUP_MS, RemoteMcpClient } from "./mcp-http.js";
|
|
9
|
+
import { MAX_REMOTE_MCP_BYTES, McpHttpError, McpRpcError, REMOTE_MCP_STARTUP_MS, modernProtocolError, RemoteMcpClient } from "./mcp-http.js";
|
|
10
10
|
import { probeEnvironment } from "./mcp-probe.js";
|
|
11
11
|
import { killCliTree, spawnCli } from "./procs.js";
|
|
12
12
|
export const APP_CONNECTION_IDLE_MS = 5 * 60_000;
|
|
13
13
|
export const APP_CONNECTIONS_MAX = 6;
|
|
14
14
|
export const APP_TOOLS_CACHE_MS = 60_000;
|
|
15
15
|
const TOOL_PAGES = 100;
|
|
16
|
+
const SKILLS_MESSAGE_BYTES = 4 * 1024 * 1024;
|
|
16
17
|
function isRecord(value) {
|
|
17
18
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
18
19
|
}
|
|
@@ -24,7 +25,8 @@ class StdioAppClient {
|
|
|
24
25
|
closed = false;
|
|
25
26
|
extensions;
|
|
26
27
|
serverInfo;
|
|
27
|
-
|
|
28
|
+
capabilities;
|
|
29
|
+
constructor(server, hooks, as = {}, maxBytes = MAX_REMOTE_MCP_BYTES) {
|
|
28
30
|
// With the box off `box` changes nothing, and the server starts where it always did.
|
|
29
31
|
this.child = spawnCli(server.command, server.args, {
|
|
30
32
|
...(botBox.enabled() ? (as.cwd ? { cwd: as.cwd } : {}) : { cwd: process.cwd() }),
|
|
@@ -35,7 +37,7 @@ class StdioAppClient {
|
|
|
35
37
|
this.child.stdout.on("data", (chunk) => {
|
|
36
38
|
// A connection lives for minutes; the bound is per message, not total.
|
|
37
39
|
this.stdoutBytes += chunk.byteLength;
|
|
38
|
-
if (this.stdoutBytes >
|
|
40
|
+
if (this.stdoutBytes > maxBytes) {
|
|
39
41
|
this.fail(new McpHttpError("protocol", "message too large"));
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
@@ -140,6 +142,8 @@ class StdioAppClient {
|
|
|
140
142
|
else {
|
|
141
143
|
result = await this.request("initialize", params, signal);
|
|
142
144
|
}
|
|
145
|
+
if (isRecord(result) && isRecord(result.capabilities))
|
|
146
|
+
this.capabilities = result.capabilities;
|
|
143
147
|
this.serverInfo = isRecord(result) && isRecord(result.serverInfo) ? result.serverInfo : undefined;
|
|
144
148
|
this.write({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
145
149
|
}
|
|
@@ -150,10 +154,11 @@ class StdioAppClient {
|
|
|
150
154
|
class RemoteAppClient {
|
|
151
155
|
client;
|
|
152
156
|
serverInfo;
|
|
157
|
+
capabilities;
|
|
153
158
|
closed = false;
|
|
154
|
-
constructor(server, hooks) {
|
|
159
|
+
constructor(server, hooks, discover = false) {
|
|
155
160
|
this.client = new RemoteMcpClient(server, {
|
|
156
|
-
maxBytes: MAX_REMOTE_MCP_BYTES,
|
|
161
|
+
maxBytes: discover ? SKILLS_MESSAGE_BYTES : MAX_REMOTE_MCP_BYTES, discover,
|
|
157
162
|
onNotification: (message) => { if (typeof message.method === "string")
|
|
158
163
|
hooks.onNotification(message.method); },
|
|
159
164
|
});
|
|
@@ -161,6 +166,8 @@ class RemoteAppClient {
|
|
|
161
166
|
get extensions() { return this.client.extensions; }
|
|
162
167
|
async initialize(signal, extension) {
|
|
163
168
|
const result = await this.client.initialize("Limix Bot", signal, extension ? { extensions: { [APP_EXTENSION_KEY]: UI_EXTENSION } } : {});
|
|
169
|
+
if (isRecord(result) && isRecord(result.capabilities))
|
|
170
|
+
this.capabilities = result.capabilities;
|
|
164
171
|
this.serverInfo = isRecord(result) && isRecord(result.serverInfo) ? result.serverInfo : undefined;
|
|
165
172
|
}
|
|
166
173
|
request(method, params, signal) {
|
|
@@ -182,6 +189,52 @@ export async function openAppClient(server, hooks, extension, signal, as = {}) {
|
|
|
182
189
|
throw error;
|
|
183
190
|
}
|
|
184
191
|
}
|
|
192
|
+
export async function openSkillConnection(server, signal, as = {}) {
|
|
193
|
+
const hooks = { onNotification() { } };
|
|
194
|
+
const client = "url" in server ? new RemoteAppClient(server, hooks, true) : new StdioAppClient(server, hooks, as, SKILLS_MESSAGE_BYTES);
|
|
195
|
+
const modern = async (method, params, requestSignal = signal) => {
|
|
196
|
+
const result = await client.request(method, {
|
|
197
|
+
...params, _meta: {
|
|
198
|
+
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
|
|
199
|
+
"io.modelcontextprotocol/clientInfo": { name: "Limix Bot", version: "1" },
|
|
200
|
+
"io.modelcontextprotocol/clientCapabilities": {},
|
|
201
|
+
},
|
|
202
|
+
}, requestSignal);
|
|
203
|
+
if (!isRecord(result) || result.resultType !== "complete")
|
|
204
|
+
throw new Error("MCP request did not return a complete result");
|
|
205
|
+
return result;
|
|
206
|
+
};
|
|
207
|
+
try {
|
|
208
|
+
if (!("type" in server && server.type === "sse")) {
|
|
209
|
+
const discoveryTimeout = "url" in server ? signal : AbortSignal.any([signal, AbortSignal.timeout(3500)]);
|
|
210
|
+
try {
|
|
211
|
+
const discovery = await modern("server/discover", {}, discoveryTimeout);
|
|
212
|
+
if (!Array.isArray(discovery.supportedVersions) || !discovery.supportedVersions.includes("2026-07-28") || !isRecord(discovery.capabilities)) {
|
|
213
|
+
throw new Error("Invalid MCP discovery result");
|
|
214
|
+
}
|
|
215
|
+
return { capabilities: discovery.capabilities, request: modern, close: () => client.close() };
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
if (signal.aborted || (error instanceof McpRpcError && modernProtocolError(error.code)))
|
|
219
|
+
throw error;
|
|
220
|
+
const legacyRequest = error instanceof McpRpcError || discoveryTimeout.aborted;
|
|
221
|
+
const legacyStatus = error instanceof McpHttpError && error.status === 400;
|
|
222
|
+
if (!legacyRequest && !legacyStatus)
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
await client.initialize(signal, false);
|
|
227
|
+
return {
|
|
228
|
+
capabilities: { ...client.capabilities, extensions: undefined },
|
|
229
|
+
request: (method, params) => client.request(method, params, signal),
|
|
230
|
+
close: () => client.close(),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
await client.close();
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
185
238
|
function connectionLost(error) {
|
|
186
239
|
return !(error instanceof McpRpcError);
|
|
187
240
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
const record = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
3
|
+
const revision = "2026-07-28";
|
|
4
|
+
const extension = "io.modelcontextprotocol/tasks";
|
|
5
|
+
const MAX_HANDLES = 256;
|
|
6
|
+
const statuses = new Set(["working", "input_required", "completed", "failed", "cancelled"]);
|
|
7
|
+
export function taskRevision(params) {
|
|
8
|
+
return record(params?._meta) && params._meta["io.modelcontextprotocol/protocolVersion"] === revision;
|
|
9
|
+
}
|
|
10
|
+
function supportsTasks(caps) {
|
|
11
|
+
return record(caps) && record(caps.extensions) && record(caps.extensions[extension]);
|
|
12
|
+
}
|
|
13
|
+
export function clientRequestsTasks(params) {
|
|
14
|
+
return taskRevision(params) && record(params?._meta) && supportsTasks(params._meta["io.modelcontextprotocol/clientCapabilities"]);
|
|
15
|
+
}
|
|
16
|
+
function timing(result) {
|
|
17
|
+
const { ttlMs, pollIntervalMs = 0, createdAt, lastUpdatedAt, status } = result;
|
|
18
|
+
if (typeof status !== "string" || !statuses.has(status) ||
|
|
19
|
+
typeof createdAt !== "string" || !Number.isFinite(Date.parse(createdAt)) ||
|
|
20
|
+
typeof lastUpdatedAt !== "string" || !Number.isFinite(Date.parse(lastUpdatedAt)) ||
|
|
21
|
+
(ttlMs !== null && !(typeof ttlMs === "number" && Number.isSafeInteger(ttlMs) && ttlMs >= 0)) ||
|
|
22
|
+
typeof pollIntervalMs !== "number" || !Number.isSafeInteger(pollIntervalMs) || pollIntervalMs < 0)
|
|
23
|
+
return null;
|
|
24
|
+
return { expires: ttlMs === null ? Infinity : Date.parse(createdAt) + ttlMs, interval: pollIntervalMs };
|
|
25
|
+
}
|
|
26
|
+
export function createGateTasks() {
|
|
27
|
+
const held = new Map();
|
|
28
|
+
let supported = false;
|
|
29
|
+
const sweep = (now) => {
|
|
30
|
+
for (const [key, task] of held)
|
|
31
|
+
if (task.expires <= now)
|
|
32
|
+
held.delete(key);
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
discover(result) {
|
|
36
|
+
supported = record(result) && result.resultType === "complete" && Array.isArray(result.supportedVersions)
|
|
37
|
+
&& result.supportedVersions.includes(revision) && supportsTasks(result.capabilities);
|
|
38
|
+
if (!supported)
|
|
39
|
+
held.clear();
|
|
40
|
+
},
|
|
41
|
+
canRequest(params) {
|
|
42
|
+
return supported && clientRequestsTasks(params);
|
|
43
|
+
},
|
|
44
|
+
issue(result, tool) {
|
|
45
|
+
const now = Date.now();
|
|
46
|
+
sweep(now);
|
|
47
|
+
const schedule = timing(result);
|
|
48
|
+
const upstreamId = result.taskId;
|
|
49
|
+
if (!supported || held.size >= MAX_HANDLES || !schedule || typeof upstreamId !== "string" || !upstreamId || upstreamId.length > 2048)
|
|
50
|
+
return null;
|
|
51
|
+
const handle = randomUUID();
|
|
52
|
+
held.set(handle, { upstreamId, tool, ...schedule, nextPoll: now + schedule.interval });
|
|
53
|
+
return handle;
|
|
54
|
+
},
|
|
55
|
+
resolve(handle, poll) {
|
|
56
|
+
const now = Date.now();
|
|
57
|
+
sweep(now);
|
|
58
|
+
if (!supported || typeof handle !== "string")
|
|
59
|
+
return null;
|
|
60
|
+
const task = held.get(handle);
|
|
61
|
+
if (!task || (poll && now < task.nextPoll))
|
|
62
|
+
return null;
|
|
63
|
+
if (poll)
|
|
64
|
+
task.nextPoll = now + task.interval;
|
|
65
|
+
return task;
|
|
66
|
+
},
|
|
67
|
+
polled(task, result) {
|
|
68
|
+
const schedule = timing(result);
|
|
69
|
+
if (!schedule || result.resultType !== "complete" || result.taskId !== task.upstreamId)
|
|
70
|
+
return false;
|
|
71
|
+
Object.assign(task, schedule, { nextPoll: Date.now() + schedule.interval });
|
|
72
|
+
return true;
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|