limixbot 0.3.138 → 0.3.140

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 (56) hide show
  1. package/dist/assets/{ActivityPanel-D11DdBLn.js → ActivityPanel-D6E89sXu.js} +1 -1
  2. package/dist/assets/{App-Bj0tKLqI.js → App-CU4DNgMp.js} +9 -9
  3. package/dist/assets/{AppEventEditor-BZm5qzWI.js → AppEventEditor-Ck4sgNn_.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-a4tl-Jtk.js → BotSettingsDialog-CjQJUCCI.js} +1 -1
  5. package/dist/assets/{BrowserPanel-BkN--gaQ.js → BrowserPanel-CBsnU8X8.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-2c06SlLG.js → BrowserProfilesManager-BpXwgH-G.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-CSe9cX5E.js → CloudAddDialog-CRh5oPqb.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-C9YdhDQf.js → ComputerFilesPane-CXFT5Cyx.js} +1 -1
  9. package/dist/assets/{ComputerPanel-DtxWNNUz.js → ComputerPanel-6IZImgTq.js} +2 -2
  10. package/dist/assets/{DataPanel-DMlyf9fW.js → DataPanel-BELccijF.js} +1 -1
  11. package/dist/assets/{GrokMoveDialog-C9EcWVjf.js → GrokMoveDialog-B6ulid29.js} +1 -1
  12. package/dist/assets/{InspectorPanel-DiZjRbh0.js → InspectorPanel-TRCCEONY.js} +1 -1
  13. package/dist/assets/{KeyboardShortcutsModal-SgMAfDS1.js → KeyboardShortcutsModal-DvBBVPMo.js} +1 -1
  14. package/dist/assets/{LimixResizeHandles-C6rWI3oY.js → LimixResizeHandles-CHcC7B6u.js} +1 -1
  15. package/dist/assets/{LiveDesktop-CwVl4Rsk.js → LiveDesktop-DZBDQKPB.js} +1 -1
  16. package/dist/assets/{LocalVmWorkspace-BiVUN9P5.js → LocalVmWorkspace-BQ8o-Sqf.js} +1 -1
  17. package/dist/assets/{MacLocalControl-CKsXMQI7.js → MacLocalControl-BMOWUy6p.js} +1 -1
  18. package/dist/assets/{MarkdownFilePreview-uf-VhnED.js → MarkdownFilePreview-DMGDT496.js} +1 -1
  19. package/dist/assets/{NewBotDialog-CEL68Gfd.js → NewBotDialog-DivTZTqp.js} +1 -1
  20. package/dist/assets/{PhoneAppDialog-DSb2xu1M.js → PhoneAppDialog-cY2obVld.js} +1 -1
  21. package/dist/assets/{PluginsPanel-BEyyO24l.js → PluginsPanel-D46R0ZKx.js} +1 -1
  22. package/dist/assets/{ProIntroduction-6Xk1l5IO.js → ProIntroduction-B62nUDOS.js} +1 -1
  23. package/dist/assets/{RemoteAgentSettingsPanel-W0orKyBL.js → RemoteAgentSettingsPanel-Dr1nHYOm.js} +1 -1
  24. package/dist/assets/{RoomPanel-4aqJ2G_P.js → RoomPanel-i7Z3Iptr.js} +1 -1
  25. package/dist/assets/{RoutinesPage-1AmztgVS.js → RoutinesPage-sUwVY-65.js} +1 -1
  26. package/dist/assets/{SettingsModal-CV9isboD.js → SettingsModal-BtZBQ0gZ.js} +1 -1
  27. package/dist/assets/{ShareTeamDialog-DZ3nO0IZ.js → ShareTeamDialog-Ds6cJP3j.js} +1 -1
  28. package/dist/assets/{SignedInSites-C3USxxuq.js → SignedInSites-CLmC1zEb.js} +1 -1
  29. package/dist/assets/{TeamLibraryPanel-BMmmfNo1.js → TeamLibraryPanel-6M9JNfWF.js} +1 -1
  30. package/dist/assets/{TeamMapPage-CuzONb_B.js → TeamMapPage-CzbEqlVs.js} +1 -1
  31. package/dist/assets/{TriggersPage-CjBP3OH3.js → TriggersPage-BWzw6q27.js} +1 -1
  32. package/dist/assets/{VisibilitySection-COoNsUi2.js → VisibilitySection-QUqz3Nz-.js} +1 -1
  33. package/dist/assets/{WebhookTrigger-LiI18iEt.js → WebhookTrigger-DdRB7WoM.js} +1 -1
  34. package/dist/assets/{WorksOnGrid-C39tIePi.js → WorksOnGrid-D4bJMovq.js} +1 -1
  35. package/dist/assets/{core-CsIC63G4.js → core-DiviRa7B.js} +1 -1
  36. package/dist/assets/{import-name-D3vkWnN_.js → import-name-BdbPuVgh.js} +1 -1
  37. package/dist/assets/{index-DqMSXUyq.js → index-B7iWCi3b.js} +2 -2
  38. package/dist/assets/{index-3chxjQko.js → index-UUTfZrHw.js} +1 -1
  39. package/dist/assets/{new-bot-CwYSYOwM.js → new-bot-DCESQUvR.js} +1 -1
  40. package/dist/assets/{org-library-D6wR1ytn.js → org-library-BS5-sY6M.js} +1 -1
  41. package/dist/assets/{package-format-BaW3i_LZ.js → package-format-CE-xmtGw.js} +1 -1
  42. package/dist/assets/{remote-desktop-panel-C7BRuixV.js → remote-desktop-panel-BTToRYMw.js} +1 -1
  43. package/dist/index.html +1 -1
  44. package/dist-server/index.js +2610 -2586
  45. package/dist-server/limixbot.js +44 -44
  46. package/dist-server/package.json +1 -1
  47. package/dist-server/pair-cli.js +44 -44
  48. package/dist-server/server/drivers/codex.js +6 -5
  49. package/dist-server/server/index.js +83 -20
  50. package/dist-server/server/next-message-suggestion.js +6 -28
  51. package/dist-server/server/plugin-hub.js +2 -0
  52. package/dist-server/server/routes/bot-messages.js +19 -18
  53. package/dist-server/server/steer-queue.js +22 -10
  54. package/dist-server/server/workspace-read.js +276 -0
  55. package/dist-server/shared/mcp-name.js +1 -0
  56. package/package.json +1 -1
@@ -0,0 +1,276 @@
1
+ import { constants } from "node:fs";
2
+ import { lstat, open, opendir, realpath } from "node:fs/promises";
3
+ import { extname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
+ export const WORKSPACE_READ = "limix-workspace-read";
5
+ export const WORKSPACE_READ_PATH = "/api/internal/workspace-read/mcp";
6
+ const MAX_FILE_BYTES = 128 * 1024;
7
+ const MAX_SCAN_BYTES = 1024 * 1024;
8
+ const MAX_ENTRIES = 512;
9
+ const MAX_FILES = 128;
10
+ const MAX_ITEMS = 8;
11
+ const MAX_LINE_BYTES = 216;
12
+ const MAX_ITEM_BYTES = 850;
13
+ const files = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".md", ".txt", ".py", ".rs", ".go", ".java", ".cs", ".css", ".html", ".vue", ".svelte", ".sql"]);
14
+ const ignored = new Set(["node_modules", "vendor", "dist", "build", "coverage", "target"]);
15
+ const decoder = new TextDecoder("utf-8", { fatal: true });
16
+ const readFlags = process.platform === "win32" ? constants.O_RDONLY : constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK;
17
+ const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
18
+ const within = (root, path) => {
19
+ const suffix = relative(root, path);
20
+ return suffix !== ".." && !suffix.startsWith(".." + sep) && !isAbsolute(suffix);
21
+ };
22
+ export function sameWorkspacePath(left, right) {
23
+ return Boolean(left && right && isAbsolute(left) && isAbsolute(right) && relative(resolve(left), resolve(right)) === "");
24
+ }
25
+ export async function bindWorkspaceRead(path, dataDir) {
26
+ try {
27
+ const canonical = await realpath(path);
28
+ const data = await realpath(dataDir);
29
+ if (within(data, canonical) || within(canonical, data) || canonical.startsWith("\\\\"))
30
+ return;
31
+ const stat = await lstat(path, { bigint: true });
32
+ if (stat.isDirectory() && !stat.isSymbolicLink() && stat.ino !== 0n)
33
+ return { path, canonical, dev: stat.dev, ino: stat.ino };
34
+ }
35
+ catch { }
36
+ }
37
+ export async function workspaceReadRootCurrent(root) {
38
+ try {
39
+ const stat = await lstat(root.path, { bigint: true });
40
+ return stat.isDirectory() && stat.dev === root.dev && stat.ino === root.ino && sameWorkspacePath(root.canonical, await realpath(root.path));
41
+ }
42
+ catch {
43
+ return false;
44
+ }
45
+ }
46
+ const pathSchema = { type: "string", description: "Workspace-relative file path with forward slashes.", minLength: 1, maxLength: 160 };
47
+ const lineSchema = { type: "integer", minimum: 1, maximum: MAX_FILE_BYTES };
48
+ const objectSchema = (properties, required) => ({ type: "object", properties, required, additionalProperties: false });
49
+ const batchSchema = (key, items) => objectSchema({ [key]: { type: "array", items, minItems: 1, maxItems: MAX_ITEMS } }, [key]);
50
+ const tools = [
51
+ { name: "batch_search", description: "Find independent case-sensitive literal strings in supported workspace text files. An optional exact path skips the bounded directory scan.", inputSchema: batchSchema("queries", objectSchema({ text: { type: "string", minLength: 1, maxLength: 128 }, path: pathSchema }, ["text"])) },
52
+ { name: "quick_outline", description: "Find simple named declarations in JavaScript and TypeScript files. Verify exact code with read_slices.", inputSchema: batchSchema("paths", pathSchema) },
53
+ { name: "read_slices", description: "Read inclusive 1-based line ranges from supported workspace text files.", inputSchema: batchSchema("ranges", objectSchema({ path: pathSchema, start: lineSchema, end: lineSchema }, ["path", "start", "end"])) },
54
+ ].map(tool => ({ ...tool, annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false } }));
55
+ function allowedName(name) {
56
+ return name.length > 0 && !name.startsWith(".") && !ignored.has(name.toLowerCase()) && !/[\\:\x00-\x1f\x7f]/u.test(name)
57
+ && !/[. ]$/u.test(name) && !/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/iu.test(name);
58
+ }
59
+ function supportedPath(path) {
60
+ return typeof path === "string" && Buffer.byteLength(path) <= 160
61
+ && path.split("/").every(allowedName) && files.has(extname(path).toLowerCase());
62
+ }
63
+ async function readWorkspaceFile(root, path) {
64
+ if (!supportedPath(path))
65
+ throw new Error("Expected a supported relative workspace file.");
66
+ const target = join(root.canonical, path);
67
+ try {
68
+ if (!sameWorkspacePath(target, await realpath(target)))
69
+ throw new Error();
70
+ const before = await lstat(target, { bigint: true });
71
+ if (!before.isFile() || before.nlink !== 1n || before.ino === 0n || before.size > BigInt(MAX_FILE_BYTES)
72
+ || !sameWorkspacePath(target, await realpath(target)))
73
+ throw new Error();
74
+ const file = await open(target, readFlags);
75
+ try {
76
+ // Validate the opened file before reading so replacing the path cannot redirect the read.
77
+ const opened = await file.stat({ bigint: true });
78
+ if (!opened.isFile() || opened.nlink !== 1n || opened.dev !== before.dev || opened.ino !== before.ino
79
+ || opened.size > BigInt(MAX_FILE_BYTES) || !await workspaceReadRootCurrent(root)
80
+ || !sameWorkspacePath(target, await realpath(target)))
81
+ throw new Error();
82
+ const buffer = Buffer.alloc(Number(opened.size) + 1);
83
+ let length = 0;
84
+ while (length < buffer.length) {
85
+ const { bytesRead } = await file.read(buffer, length, buffer.length - length, length);
86
+ if (!bytesRead)
87
+ break;
88
+ length += bytesRead;
89
+ }
90
+ const after = await lstat(target, { bigint: true });
91
+ if (length !== Number(opened.size) || after.dev !== opened.dev || after.ino !== opened.ino
92
+ || after.mtimeNs !== opened.mtimeNs || after.ctimeNs !== opened.ctimeNs
93
+ || !sameWorkspacePath(target, await realpath(target)))
94
+ throw new Error();
95
+ const text = decoder.decode(buffer.subarray(0, length));
96
+ if (text.includes("\0"))
97
+ throw new Error();
98
+ return { path, length, lines: text ? text.replace(/(?:\r\n|\n|\r)$/u, "").split(/\r\n|\n|\r/u) : [] };
99
+ }
100
+ finally {
101
+ await file.close();
102
+ }
103
+ }
104
+ catch {
105
+ throw new Error("File unavailable as bounded UTF-8 workspace text.");
106
+ }
107
+ }
108
+ async function scanWorkspace(root) {
109
+ const paths = [];
110
+ const pending = [""];
111
+ let entries = 0;
112
+ let truncated = false;
113
+ while (pending.length && !truncated) {
114
+ const directory = pending.shift();
115
+ const target = join(root.canonical, directory);
116
+ try {
117
+ if (!sameWorkspacePath(target, await realpath(target))) {
118
+ truncated = true;
119
+ break;
120
+ }
121
+ for await (const entry of await opendir(target)) {
122
+ if (++entries > MAX_ENTRIES) {
123
+ truncated = true;
124
+ break;
125
+ }
126
+ if (!allowedName(entry.name))
127
+ continue;
128
+ const path = directory ? directory + "/" + entry.name : entry.name;
129
+ if (entry.isDirectory() && path.split("/").length < 8)
130
+ pending.push(path);
131
+ else if (entry.isDirectory())
132
+ truncated = true;
133
+ else if (entry.isFile() && supportedPath(path))
134
+ paths.push(path);
135
+ }
136
+ }
137
+ catch {
138
+ truncated = true;
139
+ }
140
+ }
141
+ const contents = [];
142
+ let bytes = 0;
143
+ for (const path of paths.sort().slice(0, MAX_FILES)) {
144
+ const file = await readWorkspaceFile(root, path).catch(() => null);
145
+ if (!file) {
146
+ truncated = true;
147
+ continue;
148
+ }
149
+ bytes += file.length;
150
+ if (bytes > MAX_SCAN_BYTES) {
151
+ truncated = true;
152
+ break;
153
+ }
154
+ contents.push(file);
155
+ }
156
+ return { contents, truncated: truncated || paths.length > MAX_FILES };
157
+ }
158
+ function prefix(text, bytes) {
159
+ let length = 0;
160
+ let chars = 0;
161
+ for (const point of text) {
162
+ length += Buffer.byteLength(point);
163
+ if (length > bytes)
164
+ break;
165
+ chars += point.length;
166
+ }
167
+ return text.slice(0, chars);
168
+ }
169
+ function boundedRows(index, candidates, truncated = false) {
170
+ const rows = [];
171
+ let bytes = 0;
172
+ for (const candidate of candidates) {
173
+ const text = prefix(candidate.text, MAX_LINE_BYTES);
174
+ const row = { ...candidate, text, ...(text !== candidate.text ? { clipped: true } : {}) };
175
+ bytes += Buffer.byteLength(JSON.stringify(row)) + 1;
176
+ if (rows.length === 12 || bytes > MAX_ITEM_BYTES) {
177
+ truncated = true;
178
+ break;
179
+ }
180
+ truncated ||= row.clipped === true;
181
+ rows.push(row);
182
+ }
183
+ return { index, rows, truncated };
184
+ }
185
+ const declaration = /^(?:export\s+)?(?:default\s+)?(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function(?:\s*\*\s*|\s+)|(?:class|interface|type|enum|namespace|const|let|var)\s+)[A-Za-z_$][\w$]*/u;
186
+ function* matchingLines(contents, match, start = 1, end = MAX_FILE_BYTES) {
187
+ for (const { path, lines } of contents) {
188
+ for (let line = start; line <= Math.min(end, lines.length); line++) {
189
+ const text = lines[line - 1];
190
+ if (match(text))
191
+ yield { path, line, text };
192
+ }
193
+ }
194
+ }
195
+ function* searchLines(contents, query) {
196
+ for (const row of matchingLines(contents, line => line.includes(query))) {
197
+ if (prefix(row.text, MAX_LINE_BYTES).includes(query))
198
+ yield row;
199
+ else
200
+ yield { ...row, text: row.text.slice(row.text.indexOf(query)), clipped: true };
201
+ }
202
+ }
203
+ function textResult(text, isError = false) {
204
+ return { content: [{ type: "text", text }], ...(isError ? { isError } : {}) };
205
+ }
206
+ async function callWorkspace(root, name, args) {
207
+ const key = name === "batch_search" ? "queries" : name === "quick_outline" ? "paths" : "ranges";
208
+ const items = args[key];
209
+ if (Object.keys(args).length !== 1 || !Array.isArray(items) || items.length < 1 || items.length > MAX_ITEMS) {
210
+ return textResult("Expected one batch of 1–8 items.", true);
211
+ }
212
+ let scan;
213
+ const results = [];
214
+ for (const [index, item] of items.entries()) {
215
+ try {
216
+ if (name === "batch_search") {
217
+ if (!record(item) || Object.keys(item).some(key => key !== "text" && key !== "path") || typeof item.text !== "string"
218
+ || !item.text || Buffer.byteLength(item.text) > 128 || /[\r\n]/u.test(item.text))
219
+ throw new Error("Expected a nonempty single-line search literal.");
220
+ const query = item.text;
221
+ const selected = Object.hasOwn(item, "path") ? { contents: [await readWorkspaceFile(root, item.path)], truncated: false } : (scan ??= await scanWorkspace(root));
222
+ results.push(boundedRows(index, searchLines(selected.contents, query), selected.truncated));
223
+ }
224
+ else if (name === "quick_outline") {
225
+ if (typeof item !== "string" || !/\.(?:[mc]?[jt]s|[jt]sx)$/iu.test(item))
226
+ throw new Error("Expected a JavaScript or TypeScript path.");
227
+ results.push(boundedRows(index, matchingLines([await readWorkspaceFile(root, item)], line => declaration.test(line))));
228
+ }
229
+ else {
230
+ if (!record(item) || Object.keys(item).length !== 3 || typeof item.start !== "number" || typeof item.end !== "number"
231
+ || !Number.isInteger(item.start) || !Number.isInteger(item.end) || item.start < 1 || item.end < item.start
232
+ || item.end > MAX_FILE_BYTES)
233
+ throw new Error("Expected a valid inclusive line range.");
234
+ const file = await readWorkspaceFile(root, item.path);
235
+ if (item.start > file.lines.length)
236
+ throw new Error("Start line is beyond the end of the file.");
237
+ results.push(boundedRows(index, matchingLines([file], () => true, item.start, item.end)));
238
+ }
239
+ }
240
+ catch (error) {
241
+ results.push({ index, rows: [], truncated: false, error: error.message });
242
+ }
243
+ }
244
+ return textResult(JSON.stringify({ results }));
245
+ }
246
+ export async function workspaceReadRpc(root, request, allowed) {
247
+ const valid = record(request) && request.jsonrpc === "2.0" && typeof request.method === "string";
248
+ const id = valid && (typeof request.id === "string" || typeof request.id === "number") ? request.id : null;
249
+ const reply = (result) => ({ jsonrpc: "2.0", id, result });
250
+ const error = (code, message) => ({ jsonrpc: "2.0", id, error: { code, message } });
251
+ if (!valid)
252
+ return error(-32600, "Invalid MCP request.");
253
+ if (!Object.hasOwn(request, "id"))
254
+ return;
255
+ if (request.method === "initialize") {
256
+ const asked = record(request.params) ? request.params.protocolVersion : undefined;
257
+ const protocolVersion = typeof asked === "string" && ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"].includes(asked) ? asked : "2025-11-25";
258
+ return reply({ protocolVersion, capabilities: { tools: {} }, serverInfo: { name: WORKSPACE_READ, version: "1.0.0" } });
259
+ }
260
+ if (request.method === "ping")
261
+ return reply({});
262
+ if (request.method === "tools/list")
263
+ return reply({ tools: tools.filter(tool => allowed(tool.name, {})) });
264
+ if (request.method !== "tools/call")
265
+ return error(-32601, "Method not found.");
266
+ const params = request.params;
267
+ if (!record(params) || typeof params.name !== "string" || !record(params.arguments)
268
+ || !tools.some(tool => tool.name === params.name))
269
+ return error(-32602, "Invalid workspace tool call.");
270
+ const { name, arguments: args } = params;
271
+ if (!allowed(name, args))
272
+ return error(-32602, "Workspace tool is outside the current access scope.");
273
+ const result = await callWorkspace(root, name, args);
274
+ return allowed(name, args) && await workspaceReadRootCurrent(root) && allowed(name, args)
275
+ ? reply(result) : error(-32602, "Workspace access changed during the call.");
276
+ }
@@ -9,6 +9,7 @@ export const RESERVED_MCP_NAMES = new Set([
9
9
  "email",
10
10
  "device",
11
11
  "phone",
12
+ "limix-workspace-read",
12
13
  "dweb",
13
14
  "openmausbot_connectors",
14
15
  "openmausbot_phone",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limixbot",
3
- "version": "0.3.138",
3
+ "version": "0.3.140",
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",