@axiom-lattice/gateway 2.1.56 → 2.1.58

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.56 build /home/runner/work/agentic/agentic/packages/gateway
2
+ > @axiom-lattice/gateway@2.1.58 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
@@ -9,13 +9,22 @@
9
9
  CLI Cleaning output folder
10
10
  CJS Build start
11
11
  ESM Build start
12
- CJS dist/index.js 187.77 KB
13
- CJS dist/index.js.map 403.05 KB
14
- CJS ⚡️ Build success in 328ms
15
- ESM dist/index.mjs 184.87 KB
16
- ESM dist/index.mjs.map 403.64 KB
17
- ESM ⚡️ Build success in 326ms
12
+ [warn] ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta]
13
+
14
+ src/index.ts:151:33:
15
+  151 │ const __filename = fileURLToPath(import.meta.url);
16
+ ~~~~~~~~~~~
17
+
18
+ You need to set the output format to "esm" for "import.meta" to work correctly.
19
+
20
+
21
+ CJS dist/index.js 188.76 KB
22
+ CJS dist/index.js.map 404.76 KB
23
+ CJS ⚡️ Build success in 373ms
24
+ ESM dist/index.mjs 185.45 KB
25
+ ESM dist/index.mjs.map 405.33 KB
26
+ ESM ⚡️ Build success in 376ms
18
27
  DTS Build start
19
- DTS ⚡️ Build success in 9689ms
28
+ DTS ⚡️ Build success in 12757ms
20
29
  DTS dist/index.d.ts 3.76 KB
21
30
  DTS dist/index.d.mts 3.76 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @axiom-lattice/gateway
2
2
 
3
+ ## 2.1.58
4
+
5
+ ### Patch Changes
6
+
7
+ - 64a0971: fix path resolve
8
+ - Updated dependencies [64a0971]
9
+ - @axiom-lattice/core@2.1.52
10
+ - @axiom-lattice/pg-stores@1.0.42
11
+ - @axiom-lattice/protocols@2.1.29
12
+ - @axiom-lattice/queue-redis@1.0.28
13
+
14
+ ## 2.1.57
15
+
16
+ ### Patch Changes
17
+
18
+ - a8c25a6: fix sandbox
19
+ - Updated dependencies [a8c25a6]
20
+ - @axiom-lattice/core@2.1.51
21
+ - @axiom-lattice/pg-stores@1.0.41
22
+ - @axiom-lattice/protocols@2.1.28
23
+ - @axiom-lattice/queue-redis@1.0.27
24
+
3
25
  ## 2.1.56
4
26
 
5
27
  ### Patch Changes
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ var import_sensible = __toESM(require("@fastify/sensible"));
40
40
  var import_websocket = __toESM(require("@fastify/websocket"));
41
41
  var import_static = __toESM(require("@fastify/static"));
42
42
  var import_path = __toESM(require("path"));
43
+ var import_url = require("url");
43
44
 
44
45
  // src/controllers/assistant.ts
45
46
  var import_core = require("@axiom-lattice/core");
@@ -512,7 +513,7 @@ var getAgentState = async (request, reply) => {
512
513
  }
513
514
  const normalizedPendingMessages = pendingMessages.map((msg) => ({
514
515
  ...msg,
515
- content: typeof msg.content === "object" && msg.content !== null ? msg.content.message || JSON.stringify(msg.content) : String(msg.content || "")
516
+ content: typeof msg.content === "object" && msg.content !== null ? "message" in msg.content ? msg.content.message : JSON.stringify(msg.content) : String(msg.content || "")
516
517
  }));
517
518
  const mergedResult = {
518
519
  ...result,
@@ -2539,7 +2540,7 @@ var WorkspaceController = class {
2539
2540
  return { success: true };
2540
2541
  }
2541
2542
  // ==================== File Operations ====================
2542
- async getBackend(tenantId, workspaceId, projectId) {
2543
+ async getBackend(tenantId, workspaceId, projectId, assistantId) {
2543
2544
  const workspace = await this.workspaceStore.getWorkspaceById(
2544
2545
  tenantId,
2545
2546
  workspaceId
@@ -2549,13 +2550,21 @@ var WorkspaceController = class {
2549
2550
  }
2550
2551
  if (workspace.storageType === "sandbox") {
2551
2552
  const sandboxManager = (0, import_core18.getSandBoxManager)();
2552
- const sandbox = await sandboxManager.getSandboxFromConfig({
2553
- assistant_id: "",
2553
+ const volumeConfig = {
2554
+ assistant_id: assistantId || "",
2554
2555
  thread_id: "",
2555
2556
  tenantId,
2556
2557
  workspaceId,
2557
2558
  projectId
2558
- });
2559
+ };
2560
+ try {
2561
+ const volumeBackend = await sandboxManager.getVolumeBackend(volumeConfig);
2562
+ if (volumeBackend) {
2563
+ return { backend: volumeBackend, workspace };
2564
+ }
2565
+ } catch {
2566
+ }
2567
+ const sandbox = await sandboxManager.getSandboxFromConfig(volumeConfig);
2559
2568
  return {
2560
2569
  backend: new import_core17.SandboxFilesystem({
2561
2570
  sandboxInstance: sandbox
@@ -2602,16 +2611,17 @@ var WorkspaceController = class {
2602
2611
  const tenantId = this.getTenantId(request);
2603
2612
  const { workspaceId, projectId } = request.params;
2604
2613
  const filePath = request.query.path;
2614
+ const assistantId = request.query.assistantId;
2605
2615
  if (!filePath) {
2606
2616
  return reply.status(400).send({ success: false, error: "Path is required" });
2607
2617
  }
2608
2618
  try {
2609
- const { workspace } = await this.getBackend(tenantId, workspaceId, projectId);
2619
+ const { workspace } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2610
2620
  const resolvedPath = filePath;
2611
2621
  if (workspace.storageType === "sandbox") {
2612
2622
  const sandboxManager = (0, import_core18.getSandBoxManager)();
2613
2623
  const sandbox = await sandboxManager.getSandboxFromConfig({
2614
- assistant_id: "",
2624
+ assistant_id: assistantId || "",
2615
2625
  thread_id: "",
2616
2626
  tenantId,
2617
2627
  workspaceId,
@@ -2628,7 +2638,7 @@ var WorkspaceController = class {
2628
2638
  return reply.status(502).send({ success: false, error: String(err) });
2629
2639
  }
2630
2640
  }
2631
- const { backend } = await this.getBackend(tenantId, workspaceId, projectId);
2641
+ const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2632
2642
  const content = await backend.read(resolvedPath, 0, Infinity);
2633
2643
  const filename = this.getFilenameFromPath(resolvedPath);
2634
2644
  const mimeType = this.getMimeType(filename);
@@ -2647,16 +2657,17 @@ var WorkspaceController = class {
2647
2657
  const tenantId = this.getTenantId(request);
2648
2658
  const { workspaceId, projectId } = request.params;
2649
2659
  const filePath = request.query.path;
2660
+ const assistantId = request.query.assistantId;
2650
2661
  if (!filePath) {
2651
2662
  return reply.status(400).send({ success: false, error: "Path is required" });
2652
2663
  }
2653
2664
  try {
2654
- const { workspace } = await this.getBackend(tenantId, workspaceId, projectId);
2665
+ const { workspace } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2655
2666
  const resolvedPath = filePath;
2656
2667
  if (workspace.storageType === "sandbox") {
2657
2668
  const sandboxManager = (0, import_core18.getSandBoxManager)();
2658
2669
  const sandbox = await sandboxManager.getSandboxFromConfig({
2659
- assistant_id: "",
2670
+ assistant_id: assistantId || "",
2660
2671
  thread_id: "",
2661
2672
  tenantId,
2662
2673
  workspaceId,
@@ -2696,7 +2707,7 @@ var WorkspaceController = class {
2696
2707
  return reply.status(502).send({ success: false, error: String(err) });
2697
2708
  }
2698
2709
  }
2699
- const { backend } = await this.getBackend(tenantId, workspaceId, projectId);
2710
+ const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2700
2711
  const content = await backend.read(resolvedPath, 0, Infinity);
2701
2712
  const filename = this.getFilenameFromPath(resolvedPath);
2702
2713
  const mimeType = this.getMimeType(filename);
@@ -2732,15 +2743,16 @@ var WorkspaceController = class {
2732
2743
  const tenantId = this.getTenantId(request);
2733
2744
  const { workspaceId, projectId } = request.params;
2734
2745
  const path3 = request.query.path || "/";
2735
- const { backend } = await this.getBackend(tenantId, workspaceId, projectId);
2746
+ const assistantId = request.query.assistantId;
2747
+ const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2736
2748
  const files = await backend.lsInfo(path3);
2737
2749
  return { success: true, data: files };
2738
2750
  }
2739
2751
  async readFile(request) {
2740
2752
  const tenantId = this.getTenantId(request);
2741
2753
  const { workspaceId, projectId } = request.params;
2742
- const { path: path3, offset = 0, limit = 1e3 } = request.query;
2743
- const { backend } = await this.getBackend(tenantId, workspaceId, projectId);
2754
+ const { path: path3, offset = 0, limit = 1e3, assistantId } = request.query;
2755
+ const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2744
2756
  const content = await backend.read(path3, Number(offset), Number(limit));
2745
2757
  return { success: true, data: { content, offset, limit } };
2746
2758
  }
@@ -2751,12 +2763,14 @@ var WorkspaceController = class {
2751
2763
  * Accepts multipart/form-data with:
2752
2764
  * - `file`: the file to upload (required)
2753
2765
  * - `path`: optional directory path relative to project root (e.g., "docs", "src/utils")
2766
+ * - `assistantId`: optional query parameter for sandbox identity matching
2754
2767
  * For sandbox storage, delegates to the sandbox upload API.
2755
2768
  * For filesystem storage, writes directly under /lattice_store/workspaces/{workspaceId}/{projectId}.
2756
2769
  */
2757
2770
  async uploadFile(request, reply) {
2758
2771
  const tenantId = this.getTenantId(request);
2759
2772
  const { workspaceId, projectId } = request.params;
2773
+ const assistantId = request.query.assistantId;
2760
2774
  const workspace = await this.workspaceStore.getWorkspaceById(
2761
2775
  tenantId,
2762
2776
  workspaceId
@@ -2779,7 +2793,7 @@ var WorkspaceController = class {
2779
2793
  if (workspace.storageType === "sandbox") {
2780
2794
  const sandboxManager = (0, import_core18.getSandBoxManager)();
2781
2795
  const sandbox = await sandboxManager.getSandboxFromConfig({
2782
- assistant_id: "",
2796
+ assistant_id: assistantId || "",
2783
2797
  thread_id: "",
2784
2798
  tenantId,
2785
2799
  workspaceId,
@@ -3626,7 +3640,7 @@ async function querySemanticMetrics(request, reply) {
3626
3640
  const valueColIdx = columnNames.findIndex(
3627
3641
  (col) => col.toLowerCase().includes("value") || col.toLowerCase().includes("rate") || col.toLowerCase().includes("amt")
3628
3642
  );
3629
- for (const row of result.rows) {
3643
+ for (const row of result.rows ?? []) {
3630
3644
  const timestamp = timestampColIdx >= 0 ? row[timestampColIdx] : void 0;
3631
3645
  const value = valueColIdx >= 0 ? row[valueColIdx] : row[row.length - 1];
3632
3646
  allDataPoints.push({
@@ -3645,7 +3659,7 @@ async function querySemanticMetrics(request, reply) {
3645
3659
  columns: columnNames,
3646
3660
  dataPoints: allDataPoints,
3647
3661
  metadata: {
3648
- rowCount: result.rows.length,
3662
+ rowCount: result.rows?.length ?? 0,
3649
3663
  columnCount: result.columns.length
3650
3664
  }
3651
3665
  }
@@ -4990,10 +5004,11 @@ async function runAgentAndCollectLarkReply(input) {
4990
5004
  }
4991
5005
 
4992
5006
  // src/channels/lark/sender.ts
4993
- function createLarkSender(config, client = createDefaultLarkClient(config)) {
5007
+ async function createLarkSender(config, client) {
5008
+ const resolved = client ?? await createDefaultLarkClient(config);
4994
5009
  return {
4995
5010
  async sendTextReply(input) {
4996
- const response = await client.im.v1.message.create({
5011
+ const response = await resolved.im.v1.message.create({
4997
5012
  params: {
4998
5013
  receive_id_type: "chat_id"
4999
5014
  },
@@ -5009,8 +5024,8 @@ function createLarkSender(config, client = createDefaultLarkClient(config)) {
5009
5024
  }
5010
5025
  };
5011
5026
  }
5012
- function createDefaultLarkClient(config) {
5013
- const Lark = require("@larksuiteoapi/node-sdk");
5027
+ async function createDefaultLarkClient(config) {
5028
+ const Lark = await import("@larksuiteoapi/node-sdk");
5014
5029
  return new Lark.Client({
5015
5030
  appId: config.appId,
5016
5031
  appSecret: config.appSecret
@@ -5131,7 +5146,7 @@ function createDefaultLarkDependencies() {
5131
5146
  projectId
5132
5147
  }),
5133
5148
  sendTextReply: async ({ chatId, text, config }) => {
5134
- const sender = createLarkSender({
5149
+ const sender = await createLarkSender({
5135
5150
  appId: config.appId,
5136
5151
  appSecret: config.appSecret
5137
5152
  });
@@ -5166,8 +5181,8 @@ function getTenantId9(request) {
5166
5181
  }
5167
5182
  return request.headers["x-tenant-id"] || "default";
5168
5183
  }
5169
- function getInstallationStore() {
5170
- const { PostgreSQLChannelInstallationStore: PostgreSQLChannelInstallationStore2 } = require("@axiom-lattice/pg-stores");
5184
+ async function getInstallationStore() {
5185
+ const { PostgreSQLChannelInstallationStore: PostgreSQLChannelInstallationStore2 } = await import("@axiom-lattice/pg-stores");
5171
5186
  const databaseUrl = process.env.DATABASE_URL;
5172
5187
  if (!databaseUrl) {
5173
5188
  throw new Error("DATABASE_URL is required for channel installation store");
@@ -5180,7 +5195,7 @@ async function getChannelInstallationList(request, reply) {
5180
5195
  const tenantId = getTenantId9(request);
5181
5196
  const { channel } = request.query;
5182
5197
  try {
5183
- const store = getInstallationStore();
5198
+ const store = await getInstallationStore();
5184
5199
  const installations = await store.getInstallationsByTenant(tenantId, channel);
5185
5200
  return {
5186
5201
  success: true,
@@ -5206,7 +5221,7 @@ async function getChannelInstallation(request, reply) {
5206
5221
  const tenantId = getTenantId9(request);
5207
5222
  const { installationId } = request.params;
5208
5223
  try {
5209
- const store = getInstallationStore();
5224
+ const store = await getInstallationStore();
5210
5225
  const installation = await store.getInstallationById(installationId);
5211
5226
  if (!installation) {
5212
5227
  reply.code(404);
@@ -5270,7 +5285,7 @@ async function createChannelInstallation(request, reply) {
5270
5285
  };
5271
5286
  }
5272
5287
  }
5273
- const store = getInstallationStore();
5288
+ const store = await getInstallationStore();
5274
5289
  const installationId = body.id || (0, import_crypto8.randomUUID)();
5275
5290
  const installation = await store.createInstallation(
5276
5291
  tenantId,
@@ -5303,7 +5318,7 @@ async function updateChannelInstallation(request, reply) {
5303
5318
  const { installationId } = request.params;
5304
5319
  const body = request.body;
5305
5320
  try {
5306
- const store = getInstallationStore();
5321
+ const store = await getInstallationStore();
5307
5322
  const existing = await store.getInstallationById(installationId);
5308
5323
  if (!existing) {
5309
5324
  reply.code(404);
@@ -5348,7 +5363,7 @@ async function deleteChannelInstallation(request, reply) {
5348
5363
  const tenantId = getTenantId9(request);
5349
5364
  const { installationId } = request.params;
5350
5365
  try {
5351
- const store = getInstallationStore();
5366
+ const store = await getInstallationStore();
5352
5367
  const existing = await store.getInstallationById(installationId);
5353
5368
  if (!existing) {
5354
5369
  reply.code(404);
@@ -5829,6 +5844,7 @@ var AgentTaskConsumer = _AgentTaskConsumer;
5829
5844
  // src/index.ts
5830
5845
  var import_core28 = require("@axiom-lattice/core");
5831
5846
  var import_protocols5 = require("@axiom-lattice/protocols");
5847
+ var import_meta = {};
5832
5848
  process.on("unhandledRejection", (reason, promise) => {
5833
5849
  console.error("\u672A\u5904\u7406\u7684Promise\u62D2\u7EDD:", reason);
5834
5850
  });
@@ -5909,6 +5925,8 @@ app.register(import_multipart.default, {
5909
5925
  }
5910
5926
  });
5911
5927
  app.register(import_websocket.default);
5928
+ var __filename = (0, import_url.fileURLToPath)(import_meta.url);
5929
+ var __dirname = import_path.default.dirname(__filename);
5912
5930
  app.register(import_static.default, {
5913
5931
  root: import_path.default.join(__dirname, "../public"),
5914
5932
  prefix: "/"