@axiom-lattice/gateway 2.1.57 → 2.1.59

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.57 build /home/runner/work/agentic/agentic/packages/gateway
2
+ > @axiom-lattice/gateway@2.1.59 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 369ms
15
- ESM dist/index.mjs 184.87 KB
16
- ESM dist/index.mjs.map 403.64 KB
17
- ESM ⚡️ Build success in 370ms
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.71 KB
22
+ CJS dist/index.js.map 404.62 KB
23
+ CJS ⚡️ Build success in 378ms
24
+ ESM dist/index.mjs 185.41 KB
25
+ ESM dist/index.mjs.map 405.19 KB
26
+ ESM ⚡️ Build success in 380ms
18
27
  DTS Build start
19
- DTS ⚡️ Build success in 10503ms
28
+ DTS ⚡️ Build success in 13346ms
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,24 @@
1
1
  # @axiom-lattice/gateway
2
2
 
3
+ ## 2.1.59
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [505d7c1]
8
+ - @axiom-lattice/core@2.1.53
9
+ - @axiom-lattice/pg-stores@1.0.43
10
+
11
+ ## 2.1.58
12
+
13
+ ### Patch Changes
14
+
15
+ - 64a0971: fix path resolve
16
+ - Updated dependencies [64a0971]
17
+ - @axiom-lattice/core@2.1.52
18
+ - @axiom-lattice/pg-stores@1.0.42
19
+ - @axiom-lattice/protocols@2.1.29
20
+ - @axiom-lattice/queue-redis@1.0.28
21
+
3
22
  ## 2.1.57
4
23
 
5
24
  ### 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,18 @@ 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
+ const volumeBackend = await sandboxManager.getVolumeBackend(volumeConfig);
2561
+ if (volumeBackend) {
2562
+ return { backend: volumeBackend, workspace };
2563
+ }
2564
+ const sandbox = await sandboxManager.getSandboxFromConfig(volumeConfig);
2559
2565
  return {
2560
2566
  backend: new import_core17.SandboxFilesystem({
2561
2567
  sandboxInstance: sandbox
@@ -2602,16 +2608,17 @@ var WorkspaceController = class {
2602
2608
  const tenantId = this.getTenantId(request);
2603
2609
  const { workspaceId, projectId } = request.params;
2604
2610
  const filePath = request.query.path;
2611
+ const assistantId = request.query.assistantId;
2605
2612
  if (!filePath) {
2606
2613
  return reply.status(400).send({ success: false, error: "Path is required" });
2607
2614
  }
2608
2615
  try {
2609
- const { workspace } = await this.getBackend(tenantId, workspaceId, projectId);
2616
+ const { workspace } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2610
2617
  const resolvedPath = filePath;
2611
2618
  if (workspace.storageType === "sandbox") {
2612
2619
  const sandboxManager = (0, import_core18.getSandBoxManager)();
2613
2620
  const sandbox = await sandboxManager.getSandboxFromConfig({
2614
- assistant_id: "",
2621
+ assistant_id: assistantId || "",
2615
2622
  thread_id: "",
2616
2623
  tenantId,
2617
2624
  workspaceId,
@@ -2628,7 +2635,7 @@ var WorkspaceController = class {
2628
2635
  return reply.status(502).send({ success: false, error: String(err) });
2629
2636
  }
2630
2637
  }
2631
- const { backend } = await this.getBackend(tenantId, workspaceId, projectId);
2638
+ const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2632
2639
  const content = await backend.read(resolvedPath, 0, Infinity);
2633
2640
  const filename = this.getFilenameFromPath(resolvedPath);
2634
2641
  const mimeType = this.getMimeType(filename);
@@ -2647,16 +2654,17 @@ var WorkspaceController = class {
2647
2654
  const tenantId = this.getTenantId(request);
2648
2655
  const { workspaceId, projectId } = request.params;
2649
2656
  const filePath = request.query.path;
2657
+ const assistantId = request.query.assistantId;
2650
2658
  if (!filePath) {
2651
2659
  return reply.status(400).send({ success: false, error: "Path is required" });
2652
2660
  }
2653
2661
  try {
2654
- const { workspace } = await this.getBackend(tenantId, workspaceId, projectId);
2662
+ const { workspace } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2655
2663
  const resolvedPath = filePath;
2656
2664
  if (workspace.storageType === "sandbox") {
2657
2665
  const sandboxManager = (0, import_core18.getSandBoxManager)();
2658
2666
  const sandbox = await sandboxManager.getSandboxFromConfig({
2659
- assistant_id: "",
2667
+ assistant_id: assistantId || "",
2660
2668
  thread_id: "",
2661
2669
  tenantId,
2662
2670
  workspaceId,
@@ -2696,7 +2704,7 @@ var WorkspaceController = class {
2696
2704
  return reply.status(502).send({ success: false, error: String(err) });
2697
2705
  }
2698
2706
  }
2699
- const { backend } = await this.getBackend(tenantId, workspaceId, projectId);
2707
+ const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2700
2708
  const content = await backend.read(resolvedPath, 0, Infinity);
2701
2709
  const filename = this.getFilenameFromPath(resolvedPath);
2702
2710
  const mimeType = this.getMimeType(filename);
@@ -2732,15 +2740,16 @@ var WorkspaceController = class {
2732
2740
  const tenantId = this.getTenantId(request);
2733
2741
  const { workspaceId, projectId } = request.params;
2734
2742
  const path3 = request.query.path || "/";
2735
- const { backend } = await this.getBackend(tenantId, workspaceId, projectId);
2743
+ const assistantId = request.query.assistantId;
2744
+ const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2736
2745
  const files = await backend.lsInfo(path3);
2737
2746
  return { success: true, data: files };
2738
2747
  }
2739
2748
  async readFile(request) {
2740
2749
  const tenantId = this.getTenantId(request);
2741
2750
  const { workspaceId, projectId } = request.params;
2742
- const { path: path3, offset = 0, limit = 1e3 } = request.query;
2743
- const { backend } = await this.getBackend(tenantId, workspaceId, projectId);
2751
+ const { path: path3, offset = 0, limit = 1e3, assistantId } = request.query;
2752
+ const { backend } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
2744
2753
  const content = await backend.read(path3, Number(offset), Number(limit));
2745
2754
  return { success: true, data: { content, offset, limit } };
2746
2755
  }
@@ -2751,12 +2760,14 @@ var WorkspaceController = class {
2751
2760
  * Accepts multipart/form-data with:
2752
2761
  * - `file`: the file to upload (required)
2753
2762
  * - `path`: optional directory path relative to project root (e.g., "docs", "src/utils")
2763
+ * - `assistantId`: optional query parameter for sandbox identity matching
2754
2764
  * For sandbox storage, delegates to the sandbox upload API.
2755
2765
  * For filesystem storage, writes directly under /lattice_store/workspaces/{workspaceId}/{projectId}.
2756
2766
  */
2757
2767
  async uploadFile(request, reply) {
2758
2768
  const tenantId = this.getTenantId(request);
2759
2769
  const { workspaceId, projectId } = request.params;
2770
+ const assistantId = request.query.assistantId;
2760
2771
  const workspace = await this.workspaceStore.getWorkspaceById(
2761
2772
  tenantId,
2762
2773
  workspaceId
@@ -2779,7 +2790,7 @@ var WorkspaceController = class {
2779
2790
  if (workspace.storageType === "sandbox") {
2780
2791
  const sandboxManager = (0, import_core18.getSandBoxManager)();
2781
2792
  const sandbox = await sandboxManager.getSandboxFromConfig({
2782
- assistant_id: "",
2793
+ assistant_id: assistantId || "",
2783
2794
  thread_id: "",
2784
2795
  tenantId,
2785
2796
  workspaceId,
@@ -3626,7 +3637,7 @@ async function querySemanticMetrics(request, reply) {
3626
3637
  const valueColIdx = columnNames.findIndex(
3627
3638
  (col) => col.toLowerCase().includes("value") || col.toLowerCase().includes("rate") || col.toLowerCase().includes("amt")
3628
3639
  );
3629
- for (const row of result.rows) {
3640
+ for (const row of result.rows ?? []) {
3630
3641
  const timestamp = timestampColIdx >= 0 ? row[timestampColIdx] : void 0;
3631
3642
  const value = valueColIdx >= 0 ? row[valueColIdx] : row[row.length - 1];
3632
3643
  allDataPoints.push({
@@ -3645,7 +3656,7 @@ async function querySemanticMetrics(request, reply) {
3645
3656
  columns: columnNames,
3646
3657
  dataPoints: allDataPoints,
3647
3658
  metadata: {
3648
- rowCount: result.rows.length,
3659
+ rowCount: result.rows?.length ?? 0,
3649
3660
  columnCount: result.columns.length
3650
3661
  }
3651
3662
  }
@@ -4990,10 +5001,11 @@ async function runAgentAndCollectLarkReply(input) {
4990
5001
  }
4991
5002
 
4992
5003
  // src/channels/lark/sender.ts
4993
- function createLarkSender(config, client = createDefaultLarkClient(config)) {
5004
+ async function createLarkSender(config, client) {
5005
+ const resolved = client ?? await createDefaultLarkClient(config);
4994
5006
  return {
4995
5007
  async sendTextReply(input) {
4996
- const response = await client.im.v1.message.create({
5008
+ const response = await resolved.im.v1.message.create({
4997
5009
  params: {
4998
5010
  receive_id_type: "chat_id"
4999
5011
  },
@@ -5009,8 +5021,8 @@ function createLarkSender(config, client = createDefaultLarkClient(config)) {
5009
5021
  }
5010
5022
  };
5011
5023
  }
5012
- function createDefaultLarkClient(config) {
5013
- const Lark = require("@larksuiteoapi/node-sdk");
5024
+ async function createDefaultLarkClient(config) {
5025
+ const Lark = await import("@larksuiteoapi/node-sdk");
5014
5026
  return new Lark.Client({
5015
5027
  appId: config.appId,
5016
5028
  appSecret: config.appSecret
@@ -5131,7 +5143,7 @@ function createDefaultLarkDependencies() {
5131
5143
  projectId
5132
5144
  }),
5133
5145
  sendTextReply: async ({ chatId, text, config }) => {
5134
- const sender = createLarkSender({
5146
+ const sender = await createLarkSender({
5135
5147
  appId: config.appId,
5136
5148
  appSecret: config.appSecret
5137
5149
  });
@@ -5166,8 +5178,8 @@ function getTenantId9(request) {
5166
5178
  }
5167
5179
  return request.headers["x-tenant-id"] || "default";
5168
5180
  }
5169
- function getInstallationStore() {
5170
- const { PostgreSQLChannelInstallationStore: PostgreSQLChannelInstallationStore2 } = require("@axiom-lattice/pg-stores");
5181
+ async function getInstallationStore() {
5182
+ const { PostgreSQLChannelInstallationStore: PostgreSQLChannelInstallationStore2 } = await import("@axiom-lattice/pg-stores");
5171
5183
  const databaseUrl = process.env.DATABASE_URL;
5172
5184
  if (!databaseUrl) {
5173
5185
  throw new Error("DATABASE_URL is required for channel installation store");
@@ -5180,7 +5192,7 @@ async function getChannelInstallationList(request, reply) {
5180
5192
  const tenantId = getTenantId9(request);
5181
5193
  const { channel } = request.query;
5182
5194
  try {
5183
- const store = getInstallationStore();
5195
+ const store = await getInstallationStore();
5184
5196
  const installations = await store.getInstallationsByTenant(tenantId, channel);
5185
5197
  return {
5186
5198
  success: true,
@@ -5206,7 +5218,7 @@ async function getChannelInstallation(request, reply) {
5206
5218
  const tenantId = getTenantId9(request);
5207
5219
  const { installationId } = request.params;
5208
5220
  try {
5209
- const store = getInstallationStore();
5221
+ const store = await getInstallationStore();
5210
5222
  const installation = await store.getInstallationById(installationId);
5211
5223
  if (!installation) {
5212
5224
  reply.code(404);
@@ -5270,7 +5282,7 @@ async function createChannelInstallation(request, reply) {
5270
5282
  };
5271
5283
  }
5272
5284
  }
5273
- const store = getInstallationStore();
5285
+ const store = await getInstallationStore();
5274
5286
  const installationId = body.id || (0, import_crypto8.randomUUID)();
5275
5287
  const installation = await store.createInstallation(
5276
5288
  tenantId,
@@ -5303,7 +5315,7 @@ async function updateChannelInstallation(request, reply) {
5303
5315
  const { installationId } = request.params;
5304
5316
  const body = request.body;
5305
5317
  try {
5306
- const store = getInstallationStore();
5318
+ const store = await getInstallationStore();
5307
5319
  const existing = await store.getInstallationById(installationId);
5308
5320
  if (!existing) {
5309
5321
  reply.code(404);
@@ -5348,7 +5360,7 @@ async function deleteChannelInstallation(request, reply) {
5348
5360
  const tenantId = getTenantId9(request);
5349
5361
  const { installationId } = request.params;
5350
5362
  try {
5351
- const store = getInstallationStore();
5363
+ const store = await getInstallationStore();
5352
5364
  const existing = await store.getInstallationById(installationId);
5353
5365
  if (!existing) {
5354
5366
  reply.code(404);
@@ -5829,6 +5841,7 @@ var AgentTaskConsumer = _AgentTaskConsumer;
5829
5841
  // src/index.ts
5830
5842
  var import_core28 = require("@axiom-lattice/core");
5831
5843
  var import_protocols5 = require("@axiom-lattice/protocols");
5844
+ var import_meta = {};
5832
5845
  process.on("unhandledRejection", (reason, promise) => {
5833
5846
  console.error("\u672A\u5904\u7406\u7684Promise\u62D2\u7EDD:", reason);
5834
5847
  });
@@ -5909,6 +5922,8 @@ app.register(import_multipart.default, {
5909
5922
  }
5910
5923
  });
5911
5924
  app.register(import_websocket.default);
5925
+ var __filename = (0, import_url.fileURLToPath)(import_meta.url);
5926
+ var __dirname = import_path.default.dirname(__filename);
5912
5927
  app.register(import_static.default, {
5913
5928
  root: import_path.default.join(__dirname, "../public"),
5914
5929
  prefix: "/"