@axiom-lattice/gateway 2.1.59 → 2.1.60
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +11 -0
- package/dist/index.js +76 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/workspace.test.ts +9 -9
- package/src/controllers/sandbox.ts +3 -3
- package/src/controllers/workspace.ts +67 -28
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/gateway@2.1.
|
|
2
|
+
> @axiom-lattice/gateway@2.1.60 build /home/runner/work/agentic/agentic/packages/gateway
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --clean --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
You need to set the output format to "esm" for "import.meta" to work correctly.
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
21
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m186.92 KB[39m
|
|
22
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m407.95 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 366ms
|
|
24
|
+
[32mCJS[39m [1mdist/index.js [22m[32m190.22 KB[39m
|
|
25
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m407.37 KB[39m
|
|
26
|
+
[32mCJS[39m ⚡️ Build success in 369ms
|
|
27
27
|
[34mDTS[39m Build start
|
|
28
|
-
[32mDTS[39m ⚡️ Build success in
|
|
28
|
+
[32mDTS[39m ⚡️ Build success in 13383ms
|
|
29
29
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.76 KB[39m
|
|
30
30
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.76 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
+
## 2.1.60
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3339f6e: fix sandbox files
|
|
8
|
+
- Updated dependencies [3339f6e]
|
|
9
|
+
- @axiom-lattice/core@2.1.54
|
|
10
|
+
- @axiom-lattice/pg-stores@1.0.44
|
|
11
|
+
- @axiom-lattice/protocols@2.1.30
|
|
12
|
+
- @axiom-lattice/queue-redis@1.0.29
|
|
13
|
+
|
|
3
14
|
## 2.1.59
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -2349,7 +2349,7 @@ function registerSandboxProxyRoutes(app2) {
|
|
|
2349
2349
|
const buffer = await data.toBuffer();
|
|
2350
2350
|
const pathEntry = data.fields?.path;
|
|
2351
2351
|
const pathValue = pathEntry && typeof pathEntry === "object" && "value" in pathEntry ? String(pathEntry.value) : typeof pathEntry === "string" ? pathEntry : void 0;
|
|
2352
|
-
const filePath =
|
|
2352
|
+
const filePath = `/uploads/${pathValue ? pathValue : ""}${data.filename}`;
|
|
2353
2353
|
try {
|
|
2354
2354
|
await sandbox.file.uploadFile({ file: filePath, data: buffer });
|
|
2355
2355
|
} catch (err) {
|
|
@@ -2386,7 +2386,7 @@ function registerSandboxProxyRoutes(app2) {
|
|
|
2386
2386
|
const sandboxManager = (0, import_core15.getSandBoxManager)();
|
|
2387
2387
|
const sandbox = await sandboxManager.createSandbox(sandboxName);
|
|
2388
2388
|
try {
|
|
2389
|
-
const resolvedPath = filePath.startsWith("
|
|
2389
|
+
const resolvedPath = filePath.startsWith("/") ? filePath : `/${filePath}`;
|
|
2390
2390
|
const filename = getFilenameFromPath(resolvedPath);
|
|
2391
2391
|
const inferredContentType = getContentTypeFromFilename(filename);
|
|
2392
2392
|
try {
|
|
@@ -2540,7 +2540,7 @@ var WorkspaceController = class {
|
|
|
2540
2540
|
return { success: true };
|
|
2541
2541
|
}
|
|
2542
2542
|
// ==================== File Operations ====================
|
|
2543
|
-
async getBackend(tenantId, workspaceId, projectId, assistantId) {
|
|
2543
|
+
async getBackend(tenantId, workspaceId, projectId, assistantId, filePath) {
|
|
2544
2544
|
const workspace = await this.workspaceStore.getWorkspaceById(
|
|
2545
2545
|
tenantId,
|
|
2546
2546
|
workspaceId
|
|
@@ -2557,7 +2557,7 @@ var WorkspaceController = class {
|
|
|
2557
2557
|
workspaceId,
|
|
2558
2558
|
projectId
|
|
2559
2559
|
};
|
|
2560
|
-
const volumeBackend = await sandboxManager.
|
|
2560
|
+
const volumeBackend = await sandboxManager.getVolumeBackendForPath(volumeConfig, filePath || "/project");
|
|
2561
2561
|
if (volumeBackend) {
|
|
2562
2562
|
return { backend: volumeBackend, workspace };
|
|
2563
2563
|
}
|
|
@@ -2604,6 +2604,38 @@ var WorkspaceController = class {
|
|
|
2604
2604
|
};
|
|
2605
2605
|
return mimeTypes[ext] || "application/octet-stream";
|
|
2606
2606
|
}
|
|
2607
|
+
isBinaryContentType(filename) {
|
|
2608
|
+
const ext = filename.split(".").pop()?.toLowerCase() || "";
|
|
2609
|
+
const binaryExtensions = /* @__PURE__ */ new Set([
|
|
2610
|
+
"pdf",
|
|
2611
|
+
"xlsx",
|
|
2612
|
+
"xls",
|
|
2613
|
+
"docx",
|
|
2614
|
+
"doc",
|
|
2615
|
+
"pptx",
|
|
2616
|
+
"ppt",
|
|
2617
|
+
"png",
|
|
2618
|
+
"jpg",
|
|
2619
|
+
"jpeg",
|
|
2620
|
+
"gif",
|
|
2621
|
+
"bmp",
|
|
2622
|
+
"ico",
|
|
2623
|
+
"webp",
|
|
2624
|
+
"mp3",
|
|
2625
|
+
"mp4",
|
|
2626
|
+
"webm",
|
|
2627
|
+
"ogg",
|
|
2628
|
+
"wav",
|
|
2629
|
+
"avi",
|
|
2630
|
+
"mov",
|
|
2631
|
+
"zip",
|
|
2632
|
+
"tar",
|
|
2633
|
+
"gz",
|
|
2634
|
+
"rar",
|
|
2635
|
+
"7z"
|
|
2636
|
+
]);
|
|
2637
|
+
return binaryExtensions.has(ext);
|
|
2638
|
+
}
|
|
2607
2639
|
async downloadFile(request, reply) {
|
|
2608
2640
|
const tenantId = this.getTenantId(request);
|
|
2609
2641
|
const { workspaceId, projectId } = request.params;
|
|
@@ -2617,25 +2649,29 @@ var WorkspaceController = class {
|
|
|
2617
2649
|
const resolvedPath = filePath;
|
|
2618
2650
|
if (workspace.storageType === "sandbox") {
|
|
2619
2651
|
const sandboxManager = (0, import_core18.getSandBoxManager)();
|
|
2620
|
-
const
|
|
2652
|
+
const volumeConfig = {
|
|
2621
2653
|
assistant_id: assistantId || "",
|
|
2622
2654
|
thread_id: "",
|
|
2623
2655
|
tenantId,
|
|
2624
2656
|
workspaceId,
|
|
2625
2657
|
projectId
|
|
2626
|
-
}
|
|
2627
|
-
const realPath = resolvedPath;
|
|
2658
|
+
};
|
|
2628
2659
|
const filename2 = this.getFilenameFromPath(resolvedPath);
|
|
2629
|
-
const
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2660
|
+
const isBinary = this.isBinaryContentType(filename2);
|
|
2661
|
+
const volumeBackend = await sandboxManager.getVolumeBackendForPath(volumeConfig, resolvedPath);
|
|
2662
|
+
let buf;
|
|
2663
|
+
if (volumeBackend && !isBinary) {
|
|
2664
|
+
const fileData = await volumeBackend.readRaw(resolvedPath);
|
|
2665
|
+
buf = Buffer.from(fileData.content.join("\n"), "utf-8");
|
|
2666
|
+
} else {
|
|
2667
|
+
const sandbox = await sandboxManager.getSandboxFromConfig(volumeConfig);
|
|
2668
|
+
buf = await sandbox.file.downloadFile({ file: resolvedPath });
|
|
2636
2669
|
}
|
|
2670
|
+
const inferredContentType = this.getMimeType(filename2);
|
|
2671
|
+
const contentDisposition = `attachment; filename*=UTF-8''${encodeURIComponent(filename2)}`;
|
|
2672
|
+
return reply.status(200).type(inferredContentType).header("Content-Disposition", contentDisposition).send(buf);
|
|
2637
2673
|
}
|
|
2638
|
-
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
|
|
2674
|
+
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId, resolvedPath);
|
|
2639
2675
|
const content = await backend.read(resolvedPath, 0, Infinity);
|
|
2640
2676
|
const filename = this.getFilenameFromPath(resolvedPath);
|
|
2641
2677
|
const mimeType = this.getMimeType(filename);
|
|
@@ -2663,18 +2699,26 @@ var WorkspaceController = class {
|
|
|
2663
2699
|
const resolvedPath = filePath;
|
|
2664
2700
|
if (workspace.storageType === "sandbox") {
|
|
2665
2701
|
const sandboxManager = (0, import_core18.getSandBoxManager)();
|
|
2666
|
-
const
|
|
2702
|
+
const volumeConfig = {
|
|
2667
2703
|
assistant_id: assistantId || "",
|
|
2668
2704
|
thread_id: "",
|
|
2669
2705
|
tenantId,
|
|
2670
2706
|
workspaceId,
|
|
2671
2707
|
projectId
|
|
2672
|
-
}
|
|
2673
|
-
const realPath = resolvedPath;
|
|
2708
|
+
};
|
|
2674
2709
|
const filename2 = this.getFilenameFromPath(resolvedPath);
|
|
2710
|
+
const isBinary = this.isBinaryContentType(filename2);
|
|
2711
|
+
const volumeBackend = await sandboxManager.getVolumeBackendForPath(volumeConfig, resolvedPath);
|
|
2712
|
+
let buf;
|
|
2713
|
+
if (volumeBackend && !isBinary) {
|
|
2714
|
+
const fileData = await volumeBackend.readRaw(resolvedPath);
|
|
2715
|
+
buf = Buffer.from(fileData.content.join("\n"), "utf-8");
|
|
2716
|
+
} else {
|
|
2717
|
+
const sandbox = await sandboxManager.getSandboxFromConfig(volumeConfig);
|
|
2718
|
+
buf = await sandbox.file.downloadFile({ file: resolvedPath });
|
|
2719
|
+
}
|
|
2675
2720
|
const inferredContentType = this.getMimeType(filename2);
|
|
2676
2721
|
try {
|
|
2677
|
-
const buf = await sandbox.file.downloadFile({ file: realPath });
|
|
2678
2722
|
let contentType = inferredContentType;
|
|
2679
2723
|
const isHtml = contentType?.toLowerCase().includes("text/html") || filename2.toLowerCase().endsWith(".html") || filename2.toLowerCase().endsWith(".htm");
|
|
2680
2724
|
let outputBuf = buf;
|
|
@@ -2704,7 +2748,7 @@ var WorkspaceController = class {
|
|
|
2704
2748
|
return reply.status(502).send({ success: false, error: String(err) });
|
|
2705
2749
|
}
|
|
2706
2750
|
}
|
|
2707
|
-
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
|
|
2751
|
+
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId, resolvedPath);
|
|
2708
2752
|
const content = await backend.read(resolvedPath, 0, Infinity);
|
|
2709
2753
|
const filename = this.getFilenameFromPath(resolvedPath);
|
|
2710
2754
|
const mimeType = this.getMimeType(filename);
|
|
@@ -2741,7 +2785,7 @@ var WorkspaceController = class {
|
|
|
2741
2785
|
const { workspaceId, projectId } = request.params;
|
|
2742
2786
|
const path3 = request.query.path || "/";
|
|
2743
2787
|
const assistantId = request.query.assistantId;
|
|
2744
|
-
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
|
|
2788
|
+
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId, path3);
|
|
2745
2789
|
const files = await backend.lsInfo(path3);
|
|
2746
2790
|
return { success: true, data: files };
|
|
2747
2791
|
}
|
|
@@ -2749,7 +2793,7 @@ var WorkspaceController = class {
|
|
|
2749
2793
|
const tenantId = this.getTenantId(request);
|
|
2750
2794
|
const { workspaceId, projectId } = request.params;
|
|
2751
2795
|
const { path: path3, offset = 0, limit = 1e3, assistantId } = request.query;
|
|
2752
|
-
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
|
|
2796
|
+
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId, path3);
|
|
2753
2797
|
const content = await backend.read(path3, Number(offset), Number(limit));
|
|
2754
2798
|
return { success: true, data: { content, offset, limit } };
|
|
2755
2799
|
}
|
|
@@ -2789,20 +2833,23 @@ var WorkspaceController = class {
|
|
|
2789
2833
|
}
|
|
2790
2834
|
if (workspace.storageType === "sandbox") {
|
|
2791
2835
|
const sandboxManager = (0, import_core18.getSandBoxManager)();
|
|
2792
|
-
const
|
|
2836
|
+
const volumeConfig = {
|
|
2793
2837
|
assistant_id: assistantId || "",
|
|
2794
2838
|
thread_id: "",
|
|
2795
2839
|
tenantId,
|
|
2796
2840
|
workspaceId,
|
|
2797
2841
|
projectId
|
|
2798
|
-
}
|
|
2799
|
-
const realPath = pathValue ? path.posix.join(pathValue, filename) : filename;
|
|
2800
|
-
|
|
2842
|
+
};
|
|
2843
|
+
const realPath = pathValue ? path.posix.join(pathValue, filename) : path.posix.join("/project/uploads", filename);
|
|
2844
|
+
const isBinary = this.isBinaryContentType(filename);
|
|
2845
|
+
const volumeBackend = await sandboxManager.getVolumeBackendForPath(volumeConfig, realPath);
|
|
2846
|
+
if (volumeBackend && !isBinary) {
|
|
2847
|
+
await volumeBackend.write(realPath, buffer.toString("utf-8"));
|
|
2848
|
+
} else {
|
|
2849
|
+
const sandbox = await sandboxManager.getSandboxFromConfig(volumeConfig);
|
|
2801
2850
|
await sandbox.file.uploadFile({ file: realPath, data: buffer });
|
|
2802
|
-
} catch (err) {
|
|
2803
|
-
return reply.status(500).send({ success: false, error: String(err) });
|
|
2804
2851
|
}
|
|
2805
|
-
const relativePath = pathValue ? path.posix.join(pathValue, filename) :
|
|
2852
|
+
const relativePath = pathValue ? path.posix.join(pathValue, filename) : path.posix.join("/project/uploads", filename);
|
|
2806
2853
|
const result2 = {
|
|
2807
2854
|
path: relativePath,
|
|
2808
2855
|
name: filename,
|