@axiom-lattice/gateway 2.1.102 → 2.1.104
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 +9 -9
- package/CHANGELOG.md +22 -0
- package/dist/index.js +68 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{resources-3DGHISBZ.mjs → resources-NE6DFF5I.mjs} +68 -18
- package/dist/resources-NE6DFF5I.mjs.map +1 -0
- package/package.json +11 -8
- package/src/controllers/resources.ts +68 -21
- package/dist/resources-3DGHISBZ.mjs.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/gateway@2.1.
|
|
2
|
+
> @axiom-lattice/gateway@2.1.104 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,25 +18,25 @@
|
|
|
18
18
|
You need to set the output format to "esm" for "import.meta" to work correctly.
|
|
19
19
|
|
|
20
20
|
|
|
21
|
+
[32mCJS[39m [1mdist/index.js [22m[32m323.03 KB[39m
|
|
22
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m662.42 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 364ms
|
|
21
24
|
[32mESM[39m [1mdist/index.mjs [22m[32m271.42 KB[39m
|
|
22
25
|
[32mESM[39m [1mdist/sender-PX32VSHB.mjs [22m[32m873.00 B[39m
|
|
23
26
|
[32mESM[39m [1mdist/WechatChannelAdapter-WSDKR4OA.mjs [22m[32m8.27 KB[39m
|
|
24
27
|
[32mESM[39m [1mdist/chunk-6CUQGDJI.mjs [22m[32m6.42 KB[39m
|
|
25
28
|
[32mESM[39m [1mdist/a2a-ERG5RMUW.mjs [22m[32m15.95 KB[39m
|
|
26
|
-
[32mESM[39m [1mdist/resources-
|
|
29
|
+
[32mESM[39m [1mdist/resources-NE6DFF5I.mjs [22m[32m10.75 KB[39m
|
|
27
30
|
[32mESM[39m [1mdist/chunk-R4ZO3HZ3.mjs [22m[32m1.44 KB[39m
|
|
28
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[32m575.75 KB[39m
|
|
29
31
|
[32mESM[39m [1mdist/sender-PX32VSHB.mjs.map [22m[32m2.07 KB[39m
|
|
30
32
|
[32mESM[39m [1mdist/WechatChannelAdapter-WSDKR4OA.mjs.map [22m[32m16.28 KB[39m
|
|
31
33
|
[32mESM[39m [1mdist/chunk-6CUQGDJI.mjs.map [22m[32m14.04 KB[39m
|
|
32
34
|
[32mESM[39m [1mdist/a2a-ERG5RMUW.mjs.map [22m[32m32.14 KB[39m
|
|
33
|
-
[32mESM[39m [1mdist/resources-
|
|
35
|
+
[32mESM[39m [1mdist/resources-NE6DFF5I.mjs.map [22m[32m19.57 KB[39m
|
|
34
36
|
[32mESM[39m [1mdist/chunk-R4ZO3HZ3.mjs.map [22m[32m2.35 KB[39m
|
|
35
|
-
[32mESM[39m
|
|
36
|
-
[
|
|
37
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m658.17 KB[39m
|
|
38
|
-
[32mCJS[39m ⚡️ Build success in 535ms
|
|
37
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m575.75 KB[39m
|
|
38
|
+
[32mESM[39m ⚡️ Build success in 371ms
|
|
39
39
|
[34mDTS[39m Build start
|
|
40
|
-
[32mDTS[39m ⚡️ Build success in
|
|
40
|
+
[32mDTS[39m ⚡️ Build success in 16969ms
|
|
41
41
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.57 KB[39m
|
|
42
42
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m7.57 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
+
## 2.1.104
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4ff0c0f: enhance share
|
|
8
|
+
- Updated dependencies [4ff0c0f]
|
|
9
|
+
- @axiom-lattice/core@2.1.92
|
|
10
|
+
- @axiom-lattice/agent-eval@2.1.86
|
|
11
|
+
- @axiom-lattice/pg-stores@1.0.83
|
|
12
|
+
|
|
13
|
+
## 2.1.103
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 9d3cb30: fix share url
|
|
18
|
+
- Updated dependencies [9d3cb30]
|
|
19
|
+
- @axiom-lattice/core@2.1.91
|
|
20
|
+
- @axiom-lattice/pg-stores@1.0.82
|
|
21
|
+
- @axiom-lattice/protocols@2.1.46
|
|
22
|
+
- @axiom-lattice/queue-redis@1.0.45
|
|
23
|
+
- @axiom-lattice/agent-eval@2.1.85
|
|
24
|
+
|
|
3
25
|
## 2.1.102
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1197,10 +1197,11 @@ var resources_exports = {};
|
|
|
1197
1197
|
__export(resources_exports, {
|
|
1198
1198
|
ResourceController: () => ResourceController
|
|
1199
1199
|
});
|
|
1200
|
-
var import_core35, ResourceController;
|
|
1200
|
+
var import_bcryptjs, import_core35, ResourceController;
|
|
1201
1201
|
var init_resources = __esm({
|
|
1202
1202
|
"src/controllers/resources.ts"() {
|
|
1203
1203
|
"use strict";
|
|
1204
|
+
import_bcryptjs = __toESM(require("bcryptjs"));
|
|
1204
1205
|
import_core35 = require("@axiom-lattice/core");
|
|
1205
1206
|
init_mime();
|
|
1206
1207
|
ResourceController = class {
|
|
@@ -1227,8 +1228,8 @@ var init_resources = __esm({
|
|
|
1227
1228
|
try {
|
|
1228
1229
|
await this.deps.store.create({ ...payload, token });
|
|
1229
1230
|
this.deps.logger.info(
|
|
1230
|
-
"
|
|
1231
|
-
{ token,
|
|
1231
|
+
"[share] created",
|
|
1232
|
+
{ token, originalPath: body.resourcePath, normalizedPath: payload.address.resourcePath, volume: payload.address.volume, userId }
|
|
1232
1233
|
);
|
|
1233
1234
|
} catch {
|
|
1234
1235
|
return reply.status(500).send({ error: "Failed to create share" });
|
|
@@ -1270,22 +1271,44 @@ var init_resources = __esm({
|
|
|
1270
1271
|
const params = request.params;
|
|
1271
1272
|
const { token } = params;
|
|
1272
1273
|
const subPath = params["*"] ?? "";
|
|
1274
|
+
this.deps.logger.info("[share] resolve start", { token, subPath });
|
|
1273
1275
|
const cached = this.deps.cache.get(token);
|
|
1274
1276
|
if (cached && !cached.requiresUnlock) {
|
|
1275
|
-
|
|
1277
|
+
this.deps.logger.info("[share] cache hit", { token, volume: cached.address.volume, resourcePath: cached.address.resourcePath });
|
|
1278
|
+
return this._serveFile(cached.address, token, subPath, cached.sandboxConfig ?? { tenantId: "default", workspaceId: "", projectId: "", assistantId: null }, reply);
|
|
1276
1279
|
}
|
|
1280
|
+
this.deps.logger.info("[share] cache miss, querying DB", { token });
|
|
1277
1281
|
const record = await this.deps.store.findByToken(token);
|
|
1278
|
-
if (!record || record.revoked)
|
|
1282
|
+
if (!record || record.revoked) {
|
|
1283
|
+
this.deps.logger.warn("[share] token not found or revoked", { token, found: !!record, revoked: record?.revoked });
|
|
1284
|
+
return reply.status(404).send("Not found");
|
|
1285
|
+
}
|
|
1279
1286
|
if (record.expiresAt && new Date(record.expiresAt) < /* @__PURE__ */ new Date()) {
|
|
1287
|
+
this.deps.logger.info("[share] token expired", { token, expiresAt: record.expiresAt });
|
|
1280
1288
|
return reply.status(410).send("Expired");
|
|
1281
1289
|
}
|
|
1282
|
-
|
|
1290
|
+
this.deps.logger.info("[share] record found", {
|
|
1291
|
+
token,
|
|
1292
|
+
volume: record.address.volume,
|
|
1293
|
+
resourcePath: record.address.resourcePath,
|
|
1294
|
+
visibility: record.visibility,
|
|
1295
|
+
workspaceId: record.workspaceId,
|
|
1296
|
+
projectId: record.projectId
|
|
1297
|
+
});
|
|
1298
|
+
const isInternal = this._isInternalRequest(request);
|
|
1299
|
+
if (!isInternal) {
|
|
1283
1300
|
if (record.visibility === "password") {
|
|
1284
1301
|
const unlocked = this._isUnlocked(request, token);
|
|
1285
1302
|
if (!unlocked) {
|
|
1286
|
-
this.deps.
|
|
1303
|
+
this.deps.logger.info("[share] password protected, returning password page", { token });
|
|
1304
|
+
this.deps.cache.set(token, {
|
|
1305
|
+
address: record.address,
|
|
1306
|
+
requiresUnlock: true,
|
|
1307
|
+
sandboxConfig: { tenantId: record.tenantId, workspaceId: record.workspaceId, projectId: record.projectId, assistantId: record.assistantId }
|
|
1308
|
+
});
|
|
1287
1309
|
return reply.type("text/html").send(this._passwordPage(token));
|
|
1288
1310
|
}
|
|
1311
|
+
this.deps.logger.info("[share] password unlocked", { token });
|
|
1289
1312
|
}
|
|
1290
1313
|
}
|
|
1291
1314
|
if (record.maxAccess !== null) {
|
|
@@ -1295,11 +1318,13 @@ var init_resources = __esm({
|
|
|
1295
1318
|
this.deps.store.incrementAccess(token).catch(() => {
|
|
1296
1319
|
});
|
|
1297
1320
|
}
|
|
1321
|
+
const sandboxConfig = { tenantId: record.tenantId, workspaceId: record.workspaceId, projectId: record.projectId, assistantId: record.assistantId };
|
|
1298
1322
|
this.deps.cache.set(token, {
|
|
1299
1323
|
address: record.address,
|
|
1300
|
-
requiresUnlock: record.visibility === "password" && !
|
|
1324
|
+
requiresUnlock: record.visibility === "password" && !isInternal,
|
|
1325
|
+
sandboxConfig
|
|
1301
1326
|
});
|
|
1302
|
-
return this._serveFile(record.address, token, subPath, reply);
|
|
1327
|
+
return this._serveFile(record.address, token, subPath, sandboxConfig, reply);
|
|
1303
1328
|
}
|
|
1304
1329
|
async unlockShare(request, reply) {
|
|
1305
1330
|
const { token } = request.params;
|
|
@@ -1308,7 +1333,7 @@ var init_resources = __esm({
|
|
|
1308
1333
|
if (!record || !record.passwordHash) {
|
|
1309
1334
|
return reply.status(404).send({ error: "Invalid request" });
|
|
1310
1335
|
}
|
|
1311
|
-
const valid = password
|
|
1336
|
+
const valid = await import_bcryptjs.default.compare(password, record.passwordHash);
|
|
1312
1337
|
if (!valid) {
|
|
1313
1338
|
return reply.status(401).send({ error: "Incorrect password" });
|
|
1314
1339
|
}
|
|
@@ -1326,20 +1351,45 @@ var init_resources = __esm({
|
|
|
1326
1351
|
const cookie = request.headers.cookie ?? "";
|
|
1327
1352
|
return cookie.includes(`share_unlock_${token}=1`);
|
|
1328
1353
|
}
|
|
1329
|
-
async _serveFile(address, token, subPath, reply) {
|
|
1354
|
+
async _serveFile(address, token, subPath, sandboxConfig, reply) {
|
|
1330
1355
|
const provider = this.deps.sandboxManager.getDefaultProvider();
|
|
1331
1356
|
const resolver = provider.getResourceResolver();
|
|
1332
|
-
const
|
|
1357
|
+
const sandboxPath = subPath ? this._resolveSafeSubPath(address.resourcePath, subPath) : address.resourcePath;
|
|
1358
|
+
this.deps.logger.info("[share] serving file", {
|
|
1359
|
+
token,
|
|
1360
|
+
volume: address.volume,
|
|
1361
|
+
sandboxPath,
|
|
1362
|
+
subPath: subPath || "(none)",
|
|
1363
|
+
tenantId: sandboxConfig.tenantId,
|
|
1364
|
+
workspaceId: sandboxConfig.workspaceId,
|
|
1365
|
+
projectId: sandboxConfig.projectId
|
|
1366
|
+
});
|
|
1333
1367
|
let buf;
|
|
1334
1368
|
try {
|
|
1335
|
-
buf = await resolver.resolve({ ...address, resourcePath:
|
|
1369
|
+
buf = await resolver.resolve({ ...address, resourcePath: sandboxPath });
|
|
1370
|
+
this.deps.logger.info("[share] resolved via volume FS", { token, size: buf.length });
|
|
1336
1371
|
} catch (err) {
|
|
1337
|
-
this.deps.logger.warn(
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1372
|
+
this.deps.logger.warn("[share] volume FS failed, trying sandbox fallback", {
|
|
1373
|
+
token,
|
|
1374
|
+
path: sandboxPath,
|
|
1375
|
+
error: err.message
|
|
1376
|
+
});
|
|
1377
|
+
try {
|
|
1378
|
+
const sandbox = await this.deps.sandboxManager.getSandboxFromConfig({
|
|
1379
|
+
assistant_id: sandboxConfig.assistantId ?? "",
|
|
1380
|
+
thread_id: "",
|
|
1381
|
+
tenantId: sandboxConfig.tenantId,
|
|
1382
|
+
workspaceId: sandboxConfig.workspaceId,
|
|
1383
|
+
projectId: sandboxConfig.projectId
|
|
1384
|
+
});
|
|
1385
|
+
buf = await sandbox.file.downloadFile({ file: `/project/${sandboxPath}` });
|
|
1386
|
+
this.deps.logger.info("[share] resolved via sandbox fallback", { token, size: buf.length });
|
|
1387
|
+
} catch (err2) {
|
|
1388
|
+
this.deps.logger.warn("[share] all resolution attempts failed", { token, resourcePath: sandboxPath, error: err2.message });
|
|
1389
|
+
return reply.status(404).send("File not found");
|
|
1390
|
+
}
|
|
1342
1391
|
}
|
|
1392
|
+
const fullPath = sandboxPath;
|
|
1343
1393
|
const filename = fullPath.split("/").pop() || "download";
|
|
1344
1394
|
const isHtml = !subPath && /\.(html|htm)$/i.test(filename);
|
|
1345
1395
|
if (isHtml) {
|