@axiom-lattice/gateway 2.1.102 → 2.1.103

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @axiom-lattice/gateway@2.1.102 build /home/runner/work/agentic/agentic/packages/gateway
2
+ > @axiom-lattice/gateway@2.1.103 build /home/runner/work/agentic/agentic/packages/gateway
3
3
  > tsup src/index.ts --format cjs,esm --dts --clean --sourcemap
4
4
 
5
5
  CLI 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
- ESM dist/index.mjs 271.42 KB
21
+ CJS dist/index.js 323.03 KB
22
+ CJS dist/index.js.map 662.42 KB
23
+ CJS ⚡️ Build success in 568ms
22
24
  ESM dist/sender-PX32VSHB.mjs 873.00 B
23
25
  ESM dist/WechatChannelAdapter-WSDKR4OA.mjs 8.27 KB
24
26
  ESM dist/chunk-6CUQGDJI.mjs 6.42 KB
25
27
  ESM dist/a2a-ERG5RMUW.mjs 15.95 KB
26
- ESM dist/resources-3DGHISBZ.mjs 8.12 KB
28
+ ESM dist/resources-NE6DFF5I.mjs 10.75 KB
29
+ ESM dist/index.mjs 271.42 KB
27
30
  ESM dist/chunk-R4ZO3HZ3.mjs 1.44 KB
28
- ESM dist/index.mjs.map 575.75 KB
29
- ESM dist/sender-PX32VSHB.mjs.map 2.07 KB
30
31
  ESM dist/WechatChannelAdapter-WSDKR4OA.mjs.map 16.28 KB
31
32
  ESM dist/chunk-6CUQGDJI.mjs.map 14.04 KB
33
+ ESM dist/sender-PX32VSHB.mjs.map 2.07 KB
32
34
  ESM dist/a2a-ERG5RMUW.mjs.map 32.14 KB
33
- ESM dist/resources-3DGHISBZ.mjs.map 15.35 KB
35
+ ESM dist/resources-NE6DFF5I.mjs.map 19.57 KB
34
36
  ESM dist/chunk-R4ZO3HZ3.mjs.map 2.35 KB
35
- ESM ⚡️ Build success in 520ms
36
- CJS dist/index.js 320.15 KB
37
- CJS dist/index.js.map 658.17 KB
38
- CJS ⚡️ Build success in 535ms
37
+ ESM dist/index.mjs.map 575.75 KB
38
+ ESM ⚡️ Build success in 586ms
39
39
  DTS Build start
40
- DTS ⚡️ Build success in 18706ms
40
+ DTS ⚡️ Build success in 22321ms
41
41
  DTS dist/index.d.ts 7.57 KB
42
42
  DTS dist/index.d.mts 7.57 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @axiom-lattice/gateway
2
2
 
3
+ ## 2.1.103
4
+
5
+ ### Patch Changes
6
+
7
+ - 9d3cb30: fix share url
8
+ - Updated dependencies [9d3cb30]
9
+ - @axiom-lattice/core@2.1.91
10
+ - @axiom-lattice/pg-stores@1.0.82
11
+ - @axiom-lattice/protocols@2.1.46
12
+ - @axiom-lattice/queue-redis@1.0.45
13
+ - @axiom-lattice/agent-eval@2.1.85
14
+
3
15
  ## 2.1.102
4
16
 
5
17
  ### 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
- "Share created",
1231
- { token, resourcePath: body.resourcePath, userId }
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
- return this._serveFile(cached.address, token, subPath, reply);
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) return reply.status(404).send("Not found");
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
- if (!this._isInternalRequest(request)) {
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.cache.set(token, { address: record.address, requiresUnlock: true });
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" && !this._isInternalRequest(request)
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 === record.passwordHash;
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 fullPath = subPath ? this._resolveSafeSubPath(address.resourcePath, subPath) : address.resourcePath;
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: fullPath });
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
- "Resource resolution failed",
1339
- { token, resourcePath: fullPath, error: err.message }
1340
- );
1341
- return reply.status(404).send("File not found");
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) {