limixbot 0.3.161 → 0.3.162
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-D4K2fyw7.js → ActivityPanel-CMN_U4H6.js} +1 -1
- package/dist/assets/{App-B6W9JFXZ.js → App-DbfRrJPA.js} +94 -94
- package/dist/assets/{AppEventEditor-OWWzSxPd.js → AppEventEditor-BpXev-Xi.js} +1 -1
- package/dist/assets/{BotSettingsDialog-W_eO05D2.js → BotSettingsDialog-DzL9xn3E.js} +1 -1
- package/dist/assets/{BrowserPanel-C0NOYaOK.js → BrowserPanel-Dq80i975.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-48HNAHJm.js → BrowserProfilesManager-BiDKQm59.js} +1 -1
- package/dist/assets/{CloudAddDialog-RDN92Hbu.js → CloudAddDialog-B-QSFP19.js} +1 -1
- package/dist/assets/{ComputerFilesPane-HhCIEUQ4.js → ComputerFilesPane-DU2CnBSk.js} +1 -1
- package/dist/assets/{ComputerPanel-C8ZuT_hf.js → ComputerPanel-3z4z9zuO.js} +2 -2
- package/dist/assets/{DataPanel-CEPYRb_t.js → DataPanel-D2rowgqx.js} +1 -1
- package/dist/assets/{GrokMoveDialog-BEkVuGJs.js → GrokMoveDialog-BM1fpvD9.js} +1 -1
- package/dist/assets/{InspectorPanel-CYwO5Hpk.js → InspectorPanel-CSXRdQWb.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-CvoUyPNv.js → KeyboardShortcutsModal-Bl0rAIm5.js} +1 -1
- package/dist/assets/{KnowledgePanel-Crh_Mb2-.js → KnowledgePanel-BIucsmt4.js} +1 -1
- package/dist/assets/{LiveDesktop-DZV6iCg2.js → LiveDesktop-9xq-uOSe.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-C82LcwJQ.js → LocalVmWorkspace-SpZ3uYGB.js} +1 -1
- package/dist/assets/{MacLocalControl-Bx_fyo-H.js → MacLocalControl-BSQ9KcLo.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-BXNCSmvg.js → MarkdownFilePreview-Bdq8zdL7.js} +1 -1
- package/dist/assets/{NewBotDialog-D0agPdOC.js → NewBotDialog-Y3yhTrdv.js} +1 -1
- package/dist/assets/{PhoneAppDialog-DQpyRnEJ.js → PhoneAppDialog-xyMORAow.js} +1 -1
- package/dist/assets/{PluginsPanel-C4HY0lnL.js → PluginsPanel-BycWst3k.js} +1 -1
- package/dist/assets/{ProIntroduction-BO5ABFTi.js → ProIntroduction-CSoN3fqJ.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-D0vIEaec.js → RemoteAgentSettingsPanel-BPaZTL6O.js} +1 -1
- package/dist/assets/{RoomPanel-KgR5RAVc.js → RoomPanel-D0qQD9cP.js} +1 -1
- package/dist/assets/{RoutinesPage-CFb9pR_B.js → RoutinesPage-BcixjsUv.js} +1 -1
- package/dist/assets/{SettingsModal-CBovr73q.js → SettingsModal-TeyS-NmE.js} +1 -1
- package/dist/assets/{ShareTeamDialog-E7_x3dOd.js → ShareTeamDialog-lgrszRmR.js} +1 -1
- package/dist/assets/{SignedInSites-tgZ-kFN4.js → SignedInSites-CZ0n7vLp.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-DA7R6knC.js → TeamLibraryPanel-C4-iBK0f.js} +1 -1
- package/dist/assets/{TeamMapPage-CrEl0669.js → TeamMapPage-Bj61D2B3.js} +1 -1
- package/dist/assets/{TriggersPage-DoApzhWG.js → TriggersPage-ByPFvYfu.js} +1 -1
- package/dist/assets/{VisibilitySection-ChKxjJ5C.js → VisibilitySection-DoYze3-2.js} +1 -1
- package/dist/assets/{WebhookTrigger-B_VHQtPd.js → WebhookTrigger-B2um3gdH.js} +1 -1
- package/dist/assets/{WorksOnGrid-CBZxKyOV.js → WorksOnGrid-BHChAxnC.js} +1 -1
- package/dist/assets/{core-DXs_9m1L.js → core-9eGd8K9v.js} +1 -1
- package/dist/assets/{import-name-DviM_E6k.js → import-name-DoP5S_PW.js} +1 -1
- package/dist/assets/{index-kl2U4CdS.js → index-Cmy63UPX.js} +1 -1
- package/dist/assets/{index-Bh1qTRXw.js → index-DAHkvjY_.js} +2 -2
- package/dist/assets/{new-bot-78Wk4hfY.js → new-bot-C-8Y9Kzd.js} +1 -1
- package/dist/assets/{org-library-tkloWFxW.js → org-library-DBxhMG4q.js} +1 -1
- package/dist/assets/{package-format-nQAkOC1F.js → package-format-B8QbigkU.js} +1 -1
- package/dist/assets/{remote-desktop-panel-ByE5Ghzy.js → remote-desktop-panel-WDJu4EfU.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/index.js +2495 -2482
- package/dist-server/package.json +1 -1
- package/dist-server/server/index.js +2 -1
- package/dist-server/server/working-drive-import.js +196 -0
- package/dist-server/server/working-folders.js +12 -3
- package/package.json +1 -1
package/dist-server/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"0.3.
|
|
1
|
+
{"type":"module","version":"0.3.162"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createWorkingDriveImportRoutes } from "./working-drive-import.js";
|
|
1
2
|
import { availableWorkingFolders, createWorkingFolderRoutes, validateWorkingFolders } from "./working-folders.js";
|
|
2
3
|
import { imageConnectorRefusal } from "./limix-image-routing.js";
|
|
3
4
|
import { createChiefTemplates } from "./chief-templates.js";
|
|
@@ -12771,7 +12772,7 @@ ROUTES.push(createRoomHoldRoutes({
|
|
|
12771
12772
|
},
|
|
12772
12773
|
}));
|
|
12773
12774
|
// `routines` and `orgLibrary` are assigned at boot, after this line: read them per request.
|
|
12774
|
-
ROUTES.push(createWorkingFolderRoutes());
|
|
12775
|
+
ROUTES.push(createWorkingFolderRoutes(), createWorkingDriveImportRoutes());
|
|
12775
12776
|
ROUTES.push(createGroupRoutes({
|
|
12776
12777
|
store,
|
|
12777
12778
|
cloudHome: Boolean(CLOUD_HOME),
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { constants, createWriteStream } from "node:fs";
|
|
3
|
+
import { access, lstat, mkdir, open, rename, rm } from "node:fs/promises";
|
|
4
|
+
import { basename, join } from "node:path";
|
|
5
|
+
import { Transform } from "node:stream";
|
|
6
|
+
import { pipeline } from "node:stream/promises";
|
|
7
|
+
import { validWirePath, windowsProblem } from "../electron/cloud-sync-rules.mjs";
|
|
8
|
+
import { cloudHomeConfigured } from "./cloud-home.js";
|
|
9
|
+
import { PASS } from "./routes/table.js";
|
|
10
|
+
import { resolveWorkingDriveFolder } from "./working-folders.js";
|
|
11
|
+
const base = "/api/working-drive-import";
|
|
12
|
+
const ttl = 30 * 60_000;
|
|
13
|
+
const fileLimit = 64 * 1024 ** 2;
|
|
14
|
+
const batchLimit = 1024 ** 3;
|
|
15
|
+
function validPath(path) {
|
|
16
|
+
return validWirePath(path) && !windowsProblem(path)
|
|
17
|
+
&& path.split("/").length <= 32 && !path.split("/").some(part => part === ".git" || Buffer.byteLength(part) > 240);
|
|
18
|
+
}
|
|
19
|
+
const fdPath = (handle) => "/proc/self/fd/" + handle.fd;
|
|
20
|
+
const openDirectory = (path) => open(path, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
21
|
+
async function sameDirectory(handle, path) {
|
|
22
|
+
const entry = await lstat(path);
|
|
23
|
+
const status = await handle.stat();
|
|
24
|
+
return entry.isDirectory() && entry.ino === status.ino && entry.dev === status.dev;
|
|
25
|
+
}
|
|
26
|
+
async function discard(upload, remove) {
|
|
27
|
+
try {
|
|
28
|
+
const temporary = join(fdPath(upload.destination), basename(upload.temporary));
|
|
29
|
+
if (remove && await sameDirectory(upload.stage, temporary))
|
|
30
|
+
await rm(temporary, { force: true, recursive: true });
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
await Promise.allSettled([upload.stage.close(), upload.destination.close()]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function writeFile(ctx, upload, path) {
|
|
37
|
+
const length = Number(ctx.req.headers["x-limix-file-size"]);
|
|
38
|
+
if (!Number.isSafeInteger(length) || length < 0 || length > fileLimit || upload.bytes + length > batchLimit || upload.count >= 4096) {
|
|
39
|
+
ctx.req.resume();
|
|
40
|
+
return ctx.json(ctx.res, 413, { error: "The file or folder is too large to copy." });
|
|
41
|
+
}
|
|
42
|
+
const parts = path.split("/");
|
|
43
|
+
let directory = upload.stage;
|
|
44
|
+
let temporary;
|
|
45
|
+
let bytes = 0;
|
|
46
|
+
const limit = new Transform({
|
|
47
|
+
transform(chunk, _encoding, done) {
|
|
48
|
+
bytes += chunk.length;
|
|
49
|
+
done(bytes > length ? new Error("The file size changed.") : null, bytes <= length ? chunk : undefined);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
try {
|
|
53
|
+
for (const part of parts.slice(0, -1)) {
|
|
54
|
+
const child = join(fdPath(directory), part);
|
|
55
|
+
try {
|
|
56
|
+
await mkdir(child);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error.code !== "EEXIST")
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
const next = await openDirectory(child);
|
|
63
|
+
if (directory !== upload.stage)
|
|
64
|
+
await directory.close();
|
|
65
|
+
directory = next;
|
|
66
|
+
}
|
|
67
|
+
const file = join(fdPath(directory), parts.at(-1));
|
|
68
|
+
temporary = join(fdPath(directory), ".part-" + randomUUID());
|
|
69
|
+
try {
|
|
70
|
+
await lstat(file);
|
|
71
|
+
ctx.req.resume();
|
|
72
|
+
return ctx.json(ctx.res, 409, { error: "A file with this name already exists in the copy." });
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error.code !== "ENOENT")
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
await pipeline(ctx.req.iterator({ destroyOnReturn: false }), limit, createWriteStream(temporary, { flags: "wx", mode: 0o600 }));
|
|
79
|
+
if (bytes !== length)
|
|
80
|
+
throw new Error("The file size changed.");
|
|
81
|
+
await rename(temporary, file);
|
|
82
|
+
upload.count++;
|
|
83
|
+
upload.bytes += bytes;
|
|
84
|
+
ctx.json(ctx.res, 200, { ok: true });
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
if (temporary)
|
|
88
|
+
await rm(temporary, { force: true }).catch(() => { });
|
|
89
|
+
if (directory !== upload.stage)
|
|
90
|
+
await directory.close();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function createWorkingDriveImportRoutes() {
|
|
94
|
+
const uploads = new Map();
|
|
95
|
+
function expire() {
|
|
96
|
+
for (const [id, upload] of uploads) {
|
|
97
|
+
if (!upload.busy && upload.expires < Date.now()) {
|
|
98
|
+
uploads.delete(id);
|
|
99
|
+
void discard(upload, true).catch(() => { });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const timer = setInterval(expire, ttl);
|
|
104
|
+
timer.unref();
|
|
105
|
+
return async (ctx) => {
|
|
106
|
+
const { path, method, auth, req, res, url, json, readBody } = ctx;
|
|
107
|
+
if (path !== base && !path.startsWith(base + "/"))
|
|
108
|
+
return PASS;
|
|
109
|
+
if (process.platform !== "linux" || !cloudHomeConfigured())
|
|
110
|
+
return PASS;
|
|
111
|
+
if (auth.kind !== "session" || !auth.scopes.includes("admin"))
|
|
112
|
+
return json(res, 403, { error: "Sign in to your own Limix Cloud to copy files." });
|
|
113
|
+
let upload;
|
|
114
|
+
try {
|
|
115
|
+
if (path === base && method === "POST") {
|
|
116
|
+
expire();
|
|
117
|
+
const body = await readBody(req, 8192);
|
|
118
|
+
const source = body?.source;
|
|
119
|
+
const folder = body?.folder ?? "";
|
|
120
|
+
if ((source !== "googleDrive" && source !== "cloudDrive") || typeof folder !== "string") {
|
|
121
|
+
return json(res, 400, { error: "Choose a drive and folder." });
|
|
122
|
+
}
|
|
123
|
+
if (uploads.size >= 8)
|
|
124
|
+
return json(res, 429, { error: "Too many copies are in progress." });
|
|
125
|
+
const { root, parts, actual } = await resolveWorkingDriveFolder(source, folder);
|
|
126
|
+
const id = randomUUID();
|
|
127
|
+
const label = typeof body?.name === "string" && validPath(body.name) && !body.name.includes("/") && !body.name.startsWith(".") ? [...body.name].slice(0, 50).join("") : "Files";
|
|
128
|
+
const target = join(actual, label + " - " + id);
|
|
129
|
+
const temporary = join(actual, ".limix-copy-" + id);
|
|
130
|
+
let destination = await openDirectory(root);
|
|
131
|
+
try {
|
|
132
|
+
for (const part of parts) {
|
|
133
|
+
const child = await openDirectory(join(fdPath(destination), part));
|
|
134
|
+
await destination.close();
|
|
135
|
+
destination = child;
|
|
136
|
+
}
|
|
137
|
+
await access(fdPath(destination), constants.W_OK);
|
|
138
|
+
if (!await sameDirectory(destination, actual))
|
|
139
|
+
throw new Error("Drive changed");
|
|
140
|
+
const stagePath = join(fdPath(destination), basename(temporary));
|
|
141
|
+
await mkdir(stagePath, { mode: 0o700 });
|
|
142
|
+
const stage = await openDirectory(stagePath);
|
|
143
|
+
uploads.set(id, { target, temporary, root: actual, destination, stage, source, folder, expires: Date.now() + ttl, count: 0, bytes: 0, busy: false });
|
|
144
|
+
return json(res, 201, { id });
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
await destination.close();
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const id = path.slice(base.length + 1);
|
|
152
|
+
upload = uploads.get(id);
|
|
153
|
+
if (!upload || upload.expires < Date.now())
|
|
154
|
+
return json(res, 404, { error: "This copy has expired. Start again." });
|
|
155
|
+
if (upload.busy)
|
|
156
|
+
return json(res, 409, { error: "This copy is busy." });
|
|
157
|
+
upload.busy = true;
|
|
158
|
+
try {
|
|
159
|
+
const { actual } = await resolveWorkingDriveFolder(upload.source, upload.folder);
|
|
160
|
+
const stagePath = join(fdPath(upload.destination), basename(upload.temporary));
|
|
161
|
+
if (actual !== upload.root || !await sameDirectory(upload.destination, actual))
|
|
162
|
+
throw new Error("Drive changed");
|
|
163
|
+
if (!await sameDirectory(upload.stage, stagePath))
|
|
164
|
+
throw new Error("Copy folder changed");
|
|
165
|
+
if (method === "PUT") {
|
|
166
|
+
const file = url.searchParams.get("path");
|
|
167
|
+
if (!validPath(file)) {
|
|
168
|
+
req.resume();
|
|
169
|
+
return json(res, 400, { error: "Invalid file name." });
|
|
170
|
+
}
|
|
171
|
+
return await writeFile(ctx, upload, file);
|
|
172
|
+
}
|
|
173
|
+
if (method === "DELETE") {
|
|
174
|
+
uploads.delete(id);
|
|
175
|
+
await discard(upload, true);
|
|
176
|
+
return json(res, 200, { ok: true });
|
|
177
|
+
}
|
|
178
|
+
if (method === "POST" && upload.count > 0) {
|
|
179
|
+
await rename(stagePath, join(fdPath(upload.destination), basename(upload.target)));
|
|
180
|
+
uploads.delete(id);
|
|
181
|
+
await discard(upload, false);
|
|
182
|
+
return json(res, 201, { path: upload.target, name: basename(upload.target), files: upload.count });
|
|
183
|
+
}
|
|
184
|
+
return json(res, 400, { error: "There are no files to copy." });
|
|
185
|
+
}
|
|
186
|
+
finally {
|
|
187
|
+
upload.busy = false;
|
|
188
|
+
upload.expires = Date.now() + ttl;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
if (!res.headersSent && !res.destroyed)
|
|
193
|
+
json(res, 409, { error: "Could not write to that drive folder. Check its connection and write access." });
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { realpathSync, statSync } from "node:fs";
|
|
2
|
-
import { realpath, stat, opendir } from "node:fs/promises";
|
|
1
|
+
import { constants, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { access, realpath, stat, opendir } from "node:fs/promises";
|
|
3
3
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { WORKING_FOLDER_SOURCES } from "../shared/working-folders.js";
|
|
5
5
|
import { DATA_DIR } from "./config.js";
|
|
@@ -95,6 +95,15 @@ export async function availableWorkingFolders(folders) {
|
|
|
95
95
|
.map(folder => checkedPath(folder).catch(() => null))))
|
|
96
96
|
.filter((path) => path !== null);
|
|
97
97
|
}
|
|
98
|
+
export async function resolveWorkingDriveFolder(source, folder) {
|
|
99
|
+
const root = driveRoot(source);
|
|
100
|
+
if (!root || !isAbsolute(root))
|
|
101
|
+
throw new Error("Drive unavailable");
|
|
102
|
+
const parts = folder ? folder.split("/") : [];
|
|
103
|
+
if (parts.some(part => !part || part.startsWith(".") || /[\\:\x00-\x1f]/.test(part)))
|
|
104
|
+
throw new Error("Invalid drive folder");
|
|
105
|
+
return { root, parts, actual: await checkedPath({ source, path: join(root, ...parts) }) };
|
|
106
|
+
}
|
|
98
107
|
export function createWorkingFolderRoutes() {
|
|
99
108
|
return async ({ path, method, auth, url, res, json }) => {
|
|
100
109
|
if (path !== "/api/working-folders" || method !== "GET")
|
|
@@ -132,7 +141,7 @@ export function createWorkingFolderRoutes() {
|
|
|
132
141
|
if (directories.length > 300)
|
|
133
142
|
break;
|
|
134
143
|
}
|
|
135
|
-
return json(res, 200, { path: selected, directories: directories.sort((a, b) => a.localeCompare(b)).slice(0, 300), truncated: directories.length > 300 });
|
|
144
|
+
return json(res, 200, { path: selected, directories: directories.sort((a, b) => a.localeCompare(b)).slice(0, 300), truncated: directories.length > 300, writable: await access(actual, constants.W_OK).then(() => true, () => false) });
|
|
136
145
|
}
|
|
137
146
|
catch {
|
|
138
147
|
return json(res, 404, { error: "This folder is unavailable" });
|