@axiom-lattice/gateway 2.1.57 → 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.
- package/.turbo/turbo-build.log +17 -8
- package/CHANGELOG.md +11 -0
- package/dist/index.js +47 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/channels/lark/__tests__/sender.test.ts +1 -1
- package/src/channels/lark/routes.ts +1 -1
- package/src/channels/lark/sender.ts +7 -7
- package/src/controllers/assistant.ts +2 -1
- package/src/controllers/channel-installations.ts +7 -7
- package/src/controllers/memory.ts +1 -1
- package/src/controllers/metrics-configs.ts +2 -2
- package/src/controllers/workspace.ts +36 -16
- package/src/index.ts +3 -0
- package/src/services/queue_service.ts +2 -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.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
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -9,13 +9,22 @@
|
|
|
9
9
|
[34mCLI[39m Cleaning output folder
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
|
|
12
|
+
[warn] [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1m"import.meta" is not available with the "cjs" output format and will be empty[0m [empty-import-meta]
|
|
13
|
+
|
|
14
|
+
src/index.ts:151:33:
|
|
15
|
+
[37m 151 │ const __filename = fileURLToPath([32mimport.meta[37m.url);
|
|
16
|
+
╵ [32m~~~~~~~~~~~[0m
|
|
17
|
+
|
|
18
|
+
You need to set the output format to "esm" for "import.meta" to work correctly.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
[32mCJS[39m [1mdist/index.js [22m[32m188.76 KB[39m
|
|
22
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m404.76 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 373ms
|
|
24
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m185.45 KB[39m
|
|
25
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m405.33 KB[39m
|
|
26
|
+
[32mESM[39m ⚡️ Build success in 376ms
|
|
18
27
|
[34mDTS[39m Build start
|
|
19
|
-
[32mDTS[39m ⚡️ Build success in
|
|
28
|
+
[32mDTS[39m ⚡️ Build success in 12757ms
|
|
20
29
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.76 KB[39m
|
|
21
30
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.76 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
3
14
|
## 2.1.57
|
|
4
15
|
|
|
5
16
|
### 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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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 } =
|
|
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: "/"
|