@axiom-lattice/gateway 2.1.58 → 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 +19 -0
- package/dist/index.js +78 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -34
- 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 +69 -34
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,24 @@
|
|
|
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
|
+
|
|
14
|
+
## 2.1.59
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [505d7c1]
|
|
19
|
+
- @axiom-lattice/core@2.1.53
|
|
20
|
+
- @axiom-lattice/pg-stores@1.0.43
|
|
21
|
+
|
|
3
22
|
## 2.1.58
|
|
4
23
|
|
|
5
24
|
### 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,12 +2557,9 @@ var WorkspaceController = class {
|
|
|
2557
2557
|
workspaceId,
|
|
2558
2558
|
projectId
|
|
2559
2559
|
};
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
return { backend: volumeBackend, workspace };
|
|
2564
|
-
}
|
|
2565
|
-
} catch {
|
|
2560
|
+
const volumeBackend = await sandboxManager.getVolumeBackendForPath(volumeConfig, filePath || "/project");
|
|
2561
|
+
if (volumeBackend) {
|
|
2562
|
+
return { backend: volumeBackend, workspace };
|
|
2566
2563
|
}
|
|
2567
2564
|
const sandbox = await sandboxManager.getSandboxFromConfig(volumeConfig);
|
|
2568
2565
|
return {
|
|
@@ -2607,6 +2604,38 @@ var WorkspaceController = class {
|
|
|
2607
2604
|
};
|
|
2608
2605
|
return mimeTypes[ext] || "application/octet-stream";
|
|
2609
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
|
+
}
|
|
2610
2639
|
async downloadFile(request, reply) {
|
|
2611
2640
|
const tenantId = this.getTenantId(request);
|
|
2612
2641
|
const { workspaceId, projectId } = request.params;
|
|
@@ -2620,25 +2649,29 @@ var WorkspaceController = class {
|
|
|
2620
2649
|
const resolvedPath = filePath;
|
|
2621
2650
|
if (workspace.storageType === "sandbox") {
|
|
2622
2651
|
const sandboxManager = (0, import_core18.getSandBoxManager)();
|
|
2623
|
-
const
|
|
2652
|
+
const volumeConfig = {
|
|
2624
2653
|
assistant_id: assistantId || "",
|
|
2625
2654
|
thread_id: "",
|
|
2626
2655
|
tenantId,
|
|
2627
2656
|
workspaceId,
|
|
2628
2657
|
projectId
|
|
2629
|
-
}
|
|
2630
|
-
const realPath = resolvedPath;
|
|
2658
|
+
};
|
|
2631
2659
|
const filename2 = this.getFilenameFromPath(resolvedPath);
|
|
2632
|
-
const
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
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 });
|
|
2639
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);
|
|
2640
2673
|
}
|
|
2641
|
-
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
|
|
2674
|
+
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId, resolvedPath);
|
|
2642
2675
|
const content = await backend.read(resolvedPath, 0, Infinity);
|
|
2643
2676
|
const filename = this.getFilenameFromPath(resolvedPath);
|
|
2644
2677
|
const mimeType = this.getMimeType(filename);
|
|
@@ -2666,18 +2699,26 @@ var WorkspaceController = class {
|
|
|
2666
2699
|
const resolvedPath = filePath;
|
|
2667
2700
|
if (workspace.storageType === "sandbox") {
|
|
2668
2701
|
const sandboxManager = (0, import_core18.getSandBoxManager)();
|
|
2669
|
-
const
|
|
2702
|
+
const volumeConfig = {
|
|
2670
2703
|
assistant_id: assistantId || "",
|
|
2671
2704
|
thread_id: "",
|
|
2672
2705
|
tenantId,
|
|
2673
2706
|
workspaceId,
|
|
2674
2707
|
projectId
|
|
2675
|
-
}
|
|
2676
|
-
const realPath = resolvedPath;
|
|
2708
|
+
};
|
|
2677
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
|
+
}
|
|
2678
2720
|
const inferredContentType = this.getMimeType(filename2);
|
|
2679
2721
|
try {
|
|
2680
|
-
const buf = await sandbox.file.downloadFile({ file: realPath });
|
|
2681
2722
|
let contentType = inferredContentType;
|
|
2682
2723
|
const isHtml = contentType?.toLowerCase().includes("text/html") || filename2.toLowerCase().endsWith(".html") || filename2.toLowerCase().endsWith(".htm");
|
|
2683
2724
|
let outputBuf = buf;
|
|
@@ -2707,7 +2748,7 @@ var WorkspaceController = class {
|
|
|
2707
2748
|
return reply.status(502).send({ success: false, error: String(err) });
|
|
2708
2749
|
}
|
|
2709
2750
|
}
|
|
2710
|
-
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
|
|
2751
|
+
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId, resolvedPath);
|
|
2711
2752
|
const content = await backend.read(resolvedPath, 0, Infinity);
|
|
2712
2753
|
const filename = this.getFilenameFromPath(resolvedPath);
|
|
2713
2754
|
const mimeType = this.getMimeType(filename);
|
|
@@ -2744,7 +2785,7 @@ var WorkspaceController = class {
|
|
|
2744
2785
|
const { workspaceId, projectId } = request.params;
|
|
2745
2786
|
const path3 = request.query.path || "/";
|
|
2746
2787
|
const assistantId = request.query.assistantId;
|
|
2747
|
-
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
|
|
2788
|
+
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId, path3);
|
|
2748
2789
|
const files = await backend.lsInfo(path3);
|
|
2749
2790
|
return { success: true, data: files };
|
|
2750
2791
|
}
|
|
@@ -2752,7 +2793,7 @@ var WorkspaceController = class {
|
|
|
2752
2793
|
const tenantId = this.getTenantId(request);
|
|
2753
2794
|
const { workspaceId, projectId } = request.params;
|
|
2754
2795
|
const { path: path3, offset = 0, limit = 1e3, assistantId } = request.query;
|
|
2755
|
-
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
|
|
2796
|
+
const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId, path3);
|
|
2756
2797
|
const content = await backend.read(path3, Number(offset), Number(limit));
|
|
2757
2798
|
return { success: true, data: { content, offset, limit } };
|
|
2758
2799
|
}
|
|
@@ -2792,20 +2833,23 @@ var WorkspaceController = class {
|
|
|
2792
2833
|
}
|
|
2793
2834
|
if (workspace.storageType === "sandbox") {
|
|
2794
2835
|
const sandboxManager = (0, import_core18.getSandBoxManager)();
|
|
2795
|
-
const
|
|
2836
|
+
const volumeConfig = {
|
|
2796
2837
|
assistant_id: assistantId || "",
|
|
2797
2838
|
thread_id: "",
|
|
2798
2839
|
tenantId,
|
|
2799
2840
|
workspaceId,
|
|
2800
2841
|
projectId
|
|
2801
|
-
}
|
|
2802
|
-
const realPath = pathValue ? path.posix.join(pathValue, filename) : filename;
|
|
2803
|
-
|
|
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);
|
|
2804
2850
|
await sandbox.file.uploadFile({ file: realPath, data: buffer });
|
|
2805
|
-
} catch (err) {
|
|
2806
|
-
return reply.status(500).send({ success: false, error: String(err) });
|
|
2807
2851
|
}
|
|
2808
|
-
const relativePath = pathValue ? path.posix.join(pathValue, filename) :
|
|
2852
|
+
const relativePath = pathValue ? path.posix.join(pathValue, filename) : path.posix.join("/project/uploads", filename);
|
|
2809
2853
|
const result2 = {
|
|
2810
2854
|
path: relativePath,
|
|
2811
2855
|
name: filename,
|