limixbot 0.3.26 → 0.3.27

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.
Files changed (51) hide show
  1. package/dist/assets/{ActivityPanel-DkwIh-YJ.js → ActivityPanel-CZp2xEki.js} +1 -1
  2. package/dist/assets/{App-DCe3hDbm.js → App-D_mkV9W-.js} +8 -8
  3. package/dist/assets/{AppEventEditor-25dBAYiN.js → AppEventEditor-D64c8IWK.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-DJxZo-ro.js → BotSettingsDialog-DaI2-9_R.js} +1 -1
  5. package/dist/assets/{BrowserPanel-DVji4pZh.js → BrowserPanel-6q-wWkU_.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-C4rCEedT.js → BrowserProfilesManager-A9Zp2yg3.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-BybF9Mcz.js → CloudAddDialog-C13cTWxt.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-D-EgbYKM.js → ComputerFilesPane-DXUwyPuB.js} +1 -1
  9. package/dist/assets/{ComputerPanel-CGKdVGz4.js → ComputerPanel-B9Q6kwf8.js} +2 -2
  10. package/dist/assets/{DataPanel-BXh6perv.js → DataPanel-D7ycypEv.js} +1 -1
  11. package/dist/assets/{FilesView-B67sskTN.js → FilesView-C9q-oJuG.js} +1 -1
  12. package/dist/assets/{GrokMoveDialog-DNJckF5G.js → GrokMoveDialog-CZv7Fds1.js} +1 -1
  13. package/dist/assets/{InspectorPanel-CjtRMfJu.js → InspectorPanel-fkCIC4EB.js} +1 -1
  14. package/dist/assets/{KeyboardShortcutsModal-znw4NkA5.js → KeyboardShortcutsModal-CgCp58T_.js} +1 -1
  15. package/dist/assets/{LiveDesktop-BgFrQKAC.js → LiveDesktop-od0aHHqq.js} +1 -1
  16. package/dist/assets/{LocalVmWorkspace-Dk61S9xg.js → LocalVmWorkspace-DH05UaVi.js} +1 -1
  17. package/dist/assets/{MacLocalControl-DjyhCaWB.js → MacLocalControl-CEALKyim.js} +1 -1
  18. package/dist/assets/{MarkdownFilePreview-Btb--ZSy.js → MarkdownFilePreview-DhFsdkOv.js} +1 -1
  19. package/dist/assets/{NewBotDialog-CsQPMX7F.js → NewBotDialog-Ceqj6MMN.js} +1 -1
  20. package/dist/assets/{PhoneAppDialog-4OG210md.js → PhoneAppDialog-CUxtDKPl.js} +1 -1
  21. package/dist/assets/{PluginsPanel-CaWk4eSi.js → PluginsPanel-CCQmQ2XT.js} +1 -1
  22. package/dist/assets/{ProIntroduction-BuOIgmKa.js → ProIntroduction-D0A7u7j2.js} +1 -1
  23. package/dist/assets/{RemoteAgentSettingsPanel-Drk4pPKT.js → RemoteAgentSettingsPanel-CMyqxw7K.js} +1 -1
  24. package/dist/assets/{RoomPanel-BGLIvmBz.js → RoomPanel-DNYnR3YM.js} +1 -1
  25. package/dist/assets/{RoutinesPage-BuAEX1fg.js → RoutinesPage-BOkrb8H8.js} +1 -1
  26. package/dist/assets/{SettingsModal-CwK4KFqq.js → SettingsModal-ZyPdij7d.js} +1 -1
  27. package/dist/assets/{ShareTeamDialog-C5Fv8jWl.js → ShareTeamDialog-BlrpGRW0.js} +1 -1
  28. package/dist/assets/{SignedInSites-BQ2QP4YA.js → SignedInSites-Deoa-m3S.js} +1 -1
  29. package/dist/assets/{TeamLibraryPanel-B0HAAvLv.js → TeamLibraryPanel-jl65sW8p.js} +1 -1
  30. package/dist/assets/{TeamMapPage-DCkx9eov.js → TeamMapPage-DkQj9J_8.js} +1 -1
  31. package/dist/assets/{TriggersPage-B2sqDFfI.js → TriggersPage-CiEkHUBu.js} +1 -1
  32. package/dist/assets/{VisibilitySection-CqL-TbZp.js → VisibilitySection-Dd761EPJ.js} +1 -1
  33. package/dist/assets/{WebhookTrigger-CorVaJKR.js → WebhookTrigger-DSdjao1J.js} +1 -1
  34. package/dist/assets/{WorksOnGrid-1tMl62nD.js → WorksOnGrid-Bu7gRfv5.js} +1 -1
  35. package/dist/assets/{core-Blwbk7ct.js → core-8pT2FttX.js} +1 -1
  36. package/dist/assets/{import-name-B3mVDURb.js → import-name-C4W1Pfjg.js} +1 -1
  37. package/dist/assets/{index-D2Jm8LAf.js → index-C-oxoDHn.js} +2 -2
  38. package/dist/assets/{index-BZOGYABm.js → index-IrHnIHKE.js} +1 -1
  39. package/dist/assets/{mcp-servers-D3PCWkFu.js → mcp-servers-sCMeVHO_.js} +1 -1
  40. package/dist/assets/{new-bot-3sQib6nJ.js → new-bot-BEp90nDO.js} +1 -1
  41. package/dist/assets/{org-library-DHuACSMf.js → org-library-CtpOGMPw.js} +1 -1
  42. package/dist/assets/{package-format-CAZ-xCP-.js → package-format-JjOaH2hV.js} +1 -1
  43. package/dist/assets/{remote-desktop-panel-sCBdOaQh.js → remote-desktop-panel-D_ANOxbk.js} +1 -1
  44. package/dist/index.html +1 -1
  45. package/dist-server/index.js +1645 -1639
  46. package/dist-server/package.json +1 -1
  47. package/dist-server/server/index.js +2 -0
  48. package/dist-server/server/limix-gateway-sidecar.js +114 -0
  49. package/dist-server/server/limix-owner-lane.js +5 -2
  50. package/dist-server/server/routes/bot-skills.js +3 -0
  51. package/package.json +1 -1
@@ -1 +1 @@
1
- {"type":"module","version":"0.3.26"}
1
+ {"type":"module","version":"0.3.27"}
@@ -512,6 +512,7 @@ import { createBotOrderRoutes } from "./routes/bot-order.js";
512
512
  import { createBotLifecycleRoutes } from "./routes/bot-lifecycle.js";
513
513
  import { createBotSkillsRoutes } from "./routes/bot-skills.js";
514
514
  import { startHubAutoSync } from "./limix-skill-hub.js";
515
+ import { startLimixGatewaySidecar } from "./limix-gateway-sidecar.js";
515
516
  import { limixBundledFor, limixSelectBundled, limixSkillDefaultsMigration } from "./limix-skill-store.js";
516
517
  import { createSkillShareRoutes } from "./routes/skill-share.js";
517
518
  import { createTeamContextRoutes } from "./routes/team-context.js";
@@ -1438,6 +1439,7 @@ const firstEngineRead = holdUntilFirstEngineRead();
1438
1439
  await registry.load(providerConfigs(), decorateHostedProvider);
1439
1440
  const bundledSkills = loadBundledSkills();
1440
1441
  limixSkillDefaultsMigration();
1442
+ startLimixGatewaySidecar({ port: PORT, webhookPort: WEBHOOK_PORT });
1441
1443
  const availableSkills = () => mergeSkills(bundledSkills, loadUserSkills(join(DATA_DIR, "skills")));
1442
1444
  /** Every turn the engine can mount it, whatever its words: they pick only the skill's instructions. A Cloud home or a hosted workspace has no USB port. */
1443
1445
  const usbPhoneOffered = (instance, skills) => instance.adapter.capabilities.phoneMcp === true &&
@@ -0,0 +1,114 @@
1
+ // Limix Bot on a server (Docker image, LIMIX_GATEWAY_SIDECAR=1): the Telegram / Zalo / Discord connector
2
+ // (limix/gateway) runs beside the server, so the bots keep answering while every computer is off. On the desktop the
3
+ // app runs the connector itself (electron/limix-gateway.mjs) and this file does nothing.
4
+ //
5
+ // The connector listens only on 127.0.0.1:8790 inside the machine. Its page is reached through this server at
6
+ // /api/limix/gateway/, behind the server's own sign-in (a paired device or the loopback owner): the server adds the
7
+ // connector's admin token to each call, so the token never has to be typed or shared.
8
+ import { spawn } from "node:child_process";
9
+ import { randomBytes } from "node:crypto";
10
+ import { existsSync, mkdirSync } from "node:fs";
11
+ import { request as httpRequest } from "node:http";
12
+ import { join } from "node:path";
13
+ import { DATA_DIR } from "./config.js";
14
+ import { limixOwnerLaneToken } from "./limix-owner-lane.js";
15
+ const GATEWAY_PORT = Number(process.env.LIMIX_GATEWAY_PORT) || 8790;
16
+ const PREFIX = "/api/limix/gateway";
17
+ const ADMIN = randomBytes(24).toString("base64url");
18
+ let child = null;
19
+ let stopping = false;
20
+ let restarts = 0;
21
+ export const limixGatewaySidecarOn = () => process.env.LIMIX_GATEWAY_SIDECAR === "1";
22
+ function entry() {
23
+ const candidates = [process.env.LIMIX_GATEWAY_ENTRY, "/app/limix-gateway/src/main.mjs", join(process.cwd(), "limix", "gateway", "src", "main.mjs")];
24
+ return candidates.find((candidate) => Boolean(candidate && existsSync(candidate))) ?? null;
25
+ }
26
+ /** Starts the connector once; it is started again (up to 20 times, waiting longer each time) when it stops. */
27
+ export function startLimixGatewaySidecar({ port, webhookPort }) {
28
+ if (!limixGatewaySidecarOn() || child || stopping)
29
+ return;
30
+ const main = entry();
31
+ if (!main) {
32
+ console.log("limix gateway: not in this image");
33
+ return;
34
+ }
35
+ const dataDir = join(DATA_DIR, "limix-gateway");
36
+ mkdirSync(dataDir, { recursive: true, mode: 0o700 });
37
+ const owner = limixOwnerLaneToken();
38
+ child = spawn(process.execPath, [main], {
39
+ stdio: ["ignore", "pipe", "pipe"],
40
+ env: {
41
+ PATH: process.env.PATH, HOME: process.env.HOME, TZ: process.env.TZ, NODE_ENV: "production",
42
+ LIMIX_DATA_DIR: dataDir, LIMIX_PORT: String(GATEWAY_PORT), LIMIX_NO_BROWSER: "1", LIMIX_ADMIN_TOKEN: ADMIN,
43
+ LIMIX_SERVER_URL: `http://127.0.0.1:${port}`, LIMIX_BOT_API_URL: `http://127.0.0.1:${webhookPort}`,
44
+ ...(owner ? { LIMIX_OWNER_LANE_TOKEN: owner } : {}),
45
+ },
46
+ });
47
+ const note = (chunk) => { const line = String(chunk).trim().split("\n").pop(); if (line)
48
+ console.log(`limix gateway: ${line.slice(0, 200)}`); };
49
+ child.stdout?.on("data", note);
50
+ child.stderr?.on("data", note);
51
+ const started = Date.now();
52
+ child.on("exit", (code) => {
53
+ child = null;
54
+ if (stopping)
55
+ return;
56
+ if (Date.now() - started > 10 * 60_000)
57
+ restarts = 0; // ran a good while: a fresh failure, not a crash loop
58
+ console.log(`limix gateway exited (${code})`);
59
+ if (restarts++ < 20)
60
+ setTimeout(() => startLimixGatewaySidecar({ port, webhookPort }), Math.min(60_000, 2000 * restarts)).unref();
61
+ });
62
+ const stop = () => { stopping = true; try {
63
+ child?.kill();
64
+ }
65
+ catch { /* gone */ } };
66
+ process.once("exit", stop);
67
+ process.once("SIGTERM", stop);
68
+ }
69
+ /** GET|POST /api/limix/gateway/… → the connector. False: not this route (or no sidecar here). */
70
+ export function proxyLimixGateway(req, res, path) {
71
+ if (!limixGatewaySidecarOn() || (path !== PREFIX && !path.startsWith(`${PREFIX}/`)))
72
+ return false;
73
+ if (path === PREFIX) {
74
+ res.writeHead(308, { location: `${PREFIX}/` });
75
+ res.end();
76
+ return true;
77
+ }
78
+ const rest = path.slice(PREFIX.length) || "/";
79
+ const send = (status, error) => { res.writeHead(status, { "content-type": "application/json" }); res.end(JSON.stringify({ error })); };
80
+ // The server keeps the connector running; stopping it from its page would only make it start again.
81
+ if (rest === "/api/shutdown") {
82
+ send(403, "On a server the connector always runs. Remove a connection to stop it.");
83
+ return true;
84
+ }
85
+ if (!["GET", "POST"].includes(req.method ?? "")) {
86
+ send(405, "method not allowed");
87
+ return true;
88
+ }
89
+ const query = new URL(req.url ?? "/", "http://x").search;
90
+ const upstream = httpRequest({
91
+ host: "127.0.0.1", port: GATEWAY_PORT, method: req.method, path: rest + query, timeout: 30_000,
92
+ headers: {
93
+ host: `127.0.0.1:${GATEWAY_PORT}`, "x-limix-admin": ADMIN,
94
+ ...(req.headers["content-type"] ? { "content-type": req.headers["content-type"] } : {}),
95
+ ...(req.headers["content-length"] ? { "content-length": req.headers["content-length"] } : {}),
96
+ },
97
+ }, (reply) => {
98
+ const headers = {};
99
+ for (const name of ["content-type", "cache-control", "content-security-policy", "x-frame-options"]) {
100
+ const value = reply.headers[name];
101
+ if (value !== undefined)
102
+ headers[name] = value;
103
+ }
104
+ res.writeHead(reply.statusCode ?? 502, headers);
105
+ reply.pipe(res);
106
+ });
107
+ upstream.on("timeout", () => upstream.destroy(new Error("timeout")));
108
+ upstream.on("error", () => { if (!res.headersSent)
109
+ send(502, "The Telegram / Zalo / Discord connector is starting. Reload in a few seconds.");
110
+ else
111
+ res.end(); });
112
+ req.pipe(upstream);
113
+ return true;
114
+ }
@@ -2,12 +2,15 @@
2
2
  // confined guest turn. The connector (limix-gateway) sends X-Limix-Owner only for a sender the owner linked with /link,
3
3
  // in a private chat; the secret is made per launch by the desktop app and never reaches an engine (deleted below,
4
4
  // before any engine is started). An owner thread stays an owner thread: a guest's call can never continue it.
5
- import { timingSafeEqual } from "node:crypto";
5
+ import { randomBytes, timingSafeEqual } from "node:crypto";
6
6
  import { readFileSync, writeFileSync } from "node:fs";
7
7
  import { join } from "node:path";
8
8
  import { DATA_DIR } from "./config.js";
9
- const TOKEN = process.env.LIMIX_OWNER_LANE_TOKEN?.trim() ?? "";
9
+ // On a server the connector is this server's own sidecar (limix-gateway-sidecar.ts): the server makes the secret.
10
+ const TOKEN = process.env.LIMIX_OWNER_LANE_TOKEN?.trim() || (process.env.LIMIX_GATEWAY_SIDECAR === "1" ? randomBytes(32).toString("base64url") : "");
10
11
  delete process.env.LIMIX_OWNER_LANE_TOKEN;
12
+ /** The secret, for the sidecar connector only (never for an engine). */
13
+ export const limixOwnerLaneToken = () => (process.env.LIMIX_GATEWAY_SIDECAR === "1" ? TOKEN : "");
11
14
  export const LIMIX_OWNER_HEADER = "x-limix-owner";
12
15
  export function limixOwnerCall(header) {
13
16
  if (!/^[A-Za-z0-9_-]{43}$/.test(TOKEN) || typeof header !== "string")
@@ -7,6 +7,7 @@ import { fetchSkillFromSource } from "../skill-fetch.js";
7
7
  import { readLocalSkills } from "../limix-skill-folder.js";
8
8
  import { loadBundledSkills } from "../skill-library.js";
9
9
  import { handleLimixHub } from "../limix-skill-hub.js";
10
+ import { proxyLimixGateway } from "../limix-gateway-sidecar.js";
10
11
  import { handleLimixSkillStore, LIMIX_CORE_SKILLS, limixBundledListings, limixBundledSwitch } from "../limix-skill-store.js";
11
12
  import { skillImportSummary } from "../skill-folder.js";
12
13
  import { installLibrarySkill, librarySkillOptOuts, listLibrarySkills, readLibrarySkillFile, readSkillLibraryIndex, setLibrarySkillEveryBot, setLibrarySkillOptOut, setLibrarySkillReviewState, skillsLibraryEnabled, unassignLibrarySkill } from "../skill-library.js";
@@ -16,6 +17,8 @@ export function createBotSkillsRoutes(deps) {
16
17
  const { store, cfg, listBotSkills, readBotSkillFile, stagedSkillListing } = deps;
17
18
  return async ({ req, res, url, path, method, json, readBody }) => {
18
19
  let m = null;
20
+ if (path.startsWith("/api/limix/gateway") && proxyLimixGateway(req, res, path))
21
+ return;
19
22
  if (path.startsWith("/api/limix/bots")) {
20
23
  const library = await handleLimixBotLibrary(method, path);
21
24
  if (library)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limixbot",
3
- "version": "0.3.26",
3
+ "version": "0.3.27",
4
4
  "description": "Run the Limix Bot server anywhere and pair your devices to it (Leox ৹ Limix AI)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",