@axiom-lattice/gateway 2.1.87 → 2.1.88
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 +10 -10
- package/CHANGELOG.md +12 -0
- package/README.md +37 -94
- package/dist/index.js +34 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/controllers/channel-bindings.ts +1 -1
- package/src/controllers/data-query.ts +1 -1
- package/src/controllers/metrics-configs.ts +3 -3
- package/src/index.ts +1 -15
- package/src/bindings/index.ts +0 -14
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/gateway@2.1.
|
|
2
|
+
> @axiom-lattice/gateway@2.1.88 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
|
|
@@ -11,22 +11,22 @@
|
|
|
11
11
|
[34mESM[39m Build start
|
|
12
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
13
|
|
|
14
|
-
src/index.ts:
|
|
15
|
-
[37m
|
|
14
|
+
src/index.ts:175:33:
|
|
15
|
+
[37m 175 │ const __filename = fileURLToPath([32mimport.meta[37m.url);
|
|
16
16
|
╵ [32m~~~~~~~~~~~[0m
|
|
17
17
|
|
|
18
18
|
You need to set the output format to "esm" for "import.meta" to work correctly.
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
[
|
|
22
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m507.89 KB[39m
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in 387ms
|
|
24
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m237.76 KB[39m
|
|
21
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m237.01 KB[39m
|
|
25
22
|
[32mESM[39m [1mdist/sender-PX32VSHB.mjs [22m[32m873.00 B[39m
|
|
23
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m504.85 KB[39m
|
|
26
24
|
[32mESM[39m [1mdist/sender-PX32VSHB.mjs.map [22m[32m2.07 KB[39m
|
|
27
|
-
[32mESM[39m
|
|
28
|
-
[
|
|
25
|
+
[32mESM[39m ⚡️ Build success in 417ms
|
|
26
|
+
[32mCJS[39m [1mdist/index.js [22m[32m241.90 KB[39m
|
|
27
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m506.42 KB[39m
|
|
28
|
+
[32mCJS[39m ⚡️ Build success in 418ms
|
|
29
29
|
[34mDTS[39m Build start
|
|
30
|
-
[32mDTS[39m ⚡️ Build success in
|
|
30
|
+
[32mDTS[39m ⚡️ Build success in 13918ms
|
|
31
31
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m5.01 KB[39m
|
|
32
32
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m5.01 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
+
## 2.1.88
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6ff5bd5: fix issue
|
|
8
|
+
- Updated dependencies [6ff5bd5]
|
|
9
|
+
- @axiom-lattice/agent-eval@2.1.70
|
|
10
|
+
- @axiom-lattice/core@2.1.76
|
|
11
|
+
- @axiom-lattice/pg-stores@1.0.67
|
|
12
|
+
- @axiom-lattice/protocols@2.1.39
|
|
13
|
+
- @axiom-lattice/queue-redis@1.0.38
|
|
14
|
+
|
|
3
15
|
## 2.1.87
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,125 +1,68 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Fastify-based HTTP API gateway exposing REST endpoints for agent execution, thread management, and configuration.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Store Consumption
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- 流式响应支持
|
|
10
|
-
- 事件总线
|
|
11
|
-
- 队列服务(基于 QueueLattice)
|
|
12
|
-
- 日志服务(基于 LoggerLattice,支持自定义配置)
|
|
7
|
+
The gateway reads all stores from `StoreLatticeManager` at startup — no manual wiring needed.
|
|
8
|
+
Register stores via `configureStores` **before** calling `startAsHttpEndpoint()`:
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## 启动服务
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
# 开发环境
|
|
24
|
-
pnpm dev
|
|
25
|
-
|
|
26
|
-
# 生产环境
|
|
27
|
-
pnpm build
|
|
28
|
-
pnpm start
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## API 接口
|
|
32
|
-
|
|
33
|
-
### Configuration API
|
|
34
|
-
|
|
35
|
-
The gateway supports dynamic configuration updates via JSON. You can update environment variables at runtime without restarting the server.
|
|
10
|
+
```typescript
|
|
11
|
+
import { configureStores } from "@axiom-lattice/core";
|
|
12
|
+
import { createPgStoreConfig } from "@axiom-lattice/pg-stores";
|
|
13
|
+
import { LatticeGateway } from "@axiom-lattice/gateway";
|
|
36
14
|
|
|
37
|
-
|
|
15
|
+
const stores = createPgStoreConfig(process.env.DATABASE_URL);
|
|
16
|
+
await configureStores({ ...stores });
|
|
38
17
|
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
// Gateway picks up stores from StoreLatticeManager automatically
|
|
19
|
+
LatticeGateway.startAsHttpEndpoint({ port: 4001 });
|
|
41
20
|
```
|
|
42
21
|
|
|
43
|
-
|
|
22
|
+
### How it works
|
|
44
23
|
|
|
45
|
-
|
|
24
|
+
The gateway internally calls `getStoreLattice("default", type)` for each store it needs:
|
|
46
25
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
26
|
+
- **`channelBinding`** — used by `MessageRouter` for sender-to-agent binding resolution
|
|
27
|
+
- **`channelInstallation`** — used for channel instance lookup
|
|
28
|
+
- **`database`** — `SqlDatabaseManager` reads configs lazily on first query
|
|
29
|
+
- **`metrics`** — `MetricsServerManager` loads configs on first access
|
|
30
|
+
- **All other stores** — consumed by controllers via `getStoreLattice("default", type)`
|
|
50
31
|
|
|
51
|
-
|
|
52
|
-
"config": {
|
|
53
|
-
"port": 4001,
|
|
54
|
-
"queueServiceType": "redis",
|
|
55
|
-
"redisUrl": "redis://localhost:6379",
|
|
56
|
-
"redisPassword": "your-password",
|
|
57
|
-
"queueName": "tasks"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**Note**: When updating `queueServiceType`, the queue service will be automatically reconfigured.
|
|
32
|
+
No `setConfigStore()` or `loadConfigsFromStore()` calls needed — each manager reads directly from `StoreLatticeManager`.
|
|
63
33
|
|
|
64
|
-
|
|
34
|
+
## Quick Start
|
|
65
35
|
|
|
66
36
|
```typescript
|
|
67
|
-
|
|
68
|
-
const response = await fetch("http://localhost:4001/api/config", {
|
|
69
|
-
method: "PUT",
|
|
70
|
-
headers: {
|
|
71
|
-
"Content-Type": "application/json",
|
|
72
|
-
},
|
|
73
|
-
body: JSON.stringify({
|
|
74
|
-
config: {
|
|
75
|
-
queueServiceType: "redis",
|
|
76
|
-
redisUrl: "redis://localhost:6379",
|
|
77
|
-
redisPassword: "your-password",
|
|
78
|
-
},
|
|
79
|
-
}),
|
|
80
|
-
});
|
|
37
|
+
import { LatticeGateway } from "@axiom-lattice/gateway";
|
|
81
38
|
|
|
82
|
-
|
|
83
|
-
|
|
39
|
+
LatticeGateway.startAsHttpEndpoint({
|
|
40
|
+
port: 4001,
|
|
41
|
+
queueServiceConfig: { type: "memory", defaultStartPollingQueue: true },
|
|
42
|
+
});
|
|
84
43
|
```
|
|
85
44
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
- `POST /api/v1/run`: 运行代理
|
|
89
|
-
- `POST /api/v1/run/stream`: 流式运行代理
|
|
90
|
-
- `GET /api/v1/run/:thread_id`: 获取运行状态
|
|
91
|
-
- `GET /api/v1/run/:thread_id/messages`: 获取消息历史
|
|
92
|
-
|
|
93
|
-
## Logger 配置
|
|
94
|
-
|
|
95
|
-
Gateway 使用 Logger Lattice 进行日志管理,支持自定义日志配置。详细说明请参考 [LOGGER_CONFIG.md](./LOGGER_CONFIG.md)。
|
|
96
|
-
|
|
97
|
-
### 快速开始
|
|
45
|
+
## Logger Configuration
|
|
98
46
|
|
|
99
47
|
```typescript
|
|
100
48
|
import { LatticeGateway } from "@axiom-lattice/gateway";
|
|
101
49
|
import { LoggerType } from "@axiom-lattice/protocols";
|
|
102
50
|
|
|
103
|
-
// 使用默认配置
|
|
104
|
-
LatticeGateway.startAsHttpEndpoint({
|
|
105
|
-
port: 4001,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// 自定义日志配置
|
|
109
51
|
LatticeGateway.startAsHttpEndpoint({
|
|
110
52
|
port: 4001,
|
|
111
53
|
loggerConfig: {
|
|
112
|
-
|
|
54
|
+
name: "default",
|
|
55
|
+
type: LoggerType.PINO,
|
|
113
56
|
serviceName: "my-service",
|
|
114
57
|
},
|
|
115
58
|
});
|
|
116
59
|
```
|
|
117
60
|
|
|
118
|
-
##
|
|
61
|
+
## API Endpoints
|
|
119
62
|
|
|
120
|
-
- `
|
|
121
|
-
- `
|
|
122
|
-
- `
|
|
123
|
-
- `
|
|
124
|
-
- `
|
|
125
|
-
- `
|
|
63
|
+
- `POST /api/v1/run` — Execute agent
|
|
64
|
+
- `POST /api/v1/run/stream` — Stream agent execution
|
|
65
|
+
- `GET /api/v1/run/:thread_id` — Get run status
|
|
66
|
+
- `GET /api/v1/run/:thread_id/messages` — Get message history
|
|
67
|
+
- `GET /api/config` — Get gateway configuration
|
|
68
|
+
- `PUT /api/config` — Update gateway configuration
|
package/dist/index.js
CHANGED
|
@@ -1715,7 +1715,7 @@ async function executeDataQuery(request, reply) {
|
|
|
1715
1715
|
message: `Metrics server not registered: ${body.serverKey}. Please register the server first.`
|
|
1716
1716
|
};
|
|
1717
1717
|
}
|
|
1718
|
-
const client = import_core12.metricsServerManager.getClient(tenantId, body.serverKey);
|
|
1718
|
+
const client = await import_core12.metricsServerManager.getClient(tenantId, body.serverKey);
|
|
1719
1719
|
if (isSemanticQuery) {
|
|
1720
1720
|
return await executeSemanticQuery(client, body, reply);
|
|
1721
1721
|
} else {
|
|
@@ -3915,7 +3915,7 @@ async function testMetricsServerConnection(request, reply) {
|
|
|
3915
3915
|
const testKey = `__test_${key}_${Date.now()}`;
|
|
3916
3916
|
import_core21.metricsServerManager.registerServer(tenantId, testKey, config.config);
|
|
3917
3917
|
try {
|
|
3918
|
-
const client = import_core21.metricsServerManager.getClient(tenantId, testKey);
|
|
3918
|
+
const client = await import_core21.metricsServerManager.getClient(tenantId, testKey);
|
|
3919
3919
|
const result = await client.testConnection();
|
|
3920
3920
|
import_core21.metricsServerManager.removeServer(tenantId, testKey);
|
|
3921
3921
|
return {
|
|
@@ -3966,7 +3966,7 @@ async function listAvailableMetrics(request, reply) {
|
|
|
3966
3966
|
if (!import_core21.metricsServerManager.hasServer(tenantId, key)) {
|
|
3967
3967
|
import_core21.metricsServerManager.registerServer(tenantId, key, config.config);
|
|
3968
3968
|
}
|
|
3969
|
-
const client = import_core21.metricsServerManager.getClient(tenantId, key);
|
|
3969
|
+
const client = await import_core21.metricsServerManager.getClient(tenantId, key);
|
|
3970
3970
|
const metrics = await client.listMetrics();
|
|
3971
3971
|
return {
|
|
3972
3972
|
success: true,
|
|
@@ -4012,7 +4012,7 @@ async function queryMetricsData(request, reply) {
|
|
|
4012
4012
|
if (!import_core21.metricsServerManager.hasServer(tenantId, key)) {
|
|
4013
4013
|
import_core21.metricsServerManager.registerServer(tenantId, key, config.config);
|
|
4014
4014
|
}
|
|
4015
|
-
const client = import_core21.metricsServerManager.getClient(tenantId, key);
|
|
4015
|
+
const client = await import_core21.metricsServerManager.getClient(tenantId, key);
|
|
4016
4016
|
const result = await client.queryMetricData(metricName, {
|
|
4017
4017
|
startTime,
|
|
4018
4018
|
endTime,
|
|
@@ -6354,19 +6354,8 @@ function registerChannelInstallationRoutes(app2) {
|
|
|
6354
6354
|
app2.delete("/api/channel-installations/:installationId", deleteChannelInstallation);
|
|
6355
6355
|
}
|
|
6356
6356
|
|
|
6357
|
-
// src/bindings/index.ts
|
|
6358
|
-
var registryInstance = null;
|
|
6359
|
-
function setBindingRegistry(registry) {
|
|
6360
|
-
registryInstance = registry;
|
|
6361
|
-
}
|
|
6362
|
-
function getBindingRegistry() {
|
|
6363
|
-
if (!registryInstance) {
|
|
6364
|
-
throw new Error("BindingRegistry not initialized. Call setBindingRegistry() first.");
|
|
6365
|
-
}
|
|
6366
|
-
return registryInstance;
|
|
6367
|
-
}
|
|
6368
|
-
|
|
6369
6357
|
// src/controllers/channel-bindings.ts
|
|
6358
|
+
var import_core28 = require("@axiom-lattice/core");
|
|
6370
6359
|
function getTenantId12(request) {
|
|
6371
6360
|
const userTenantId = request.user?.tenantId;
|
|
6372
6361
|
if (userTenantId) return userTenantId;
|
|
@@ -6376,7 +6365,7 @@ async function getBindingList(request, _reply) {
|
|
|
6376
6365
|
const tenantId = getTenantId12(request);
|
|
6377
6366
|
const { channel, agentId, channelInstallationId, limit, offset } = request.query;
|
|
6378
6367
|
try {
|
|
6379
|
-
const registry = getBindingRegistry();
|
|
6368
|
+
const registry = (0, import_core28.getBindingRegistry)();
|
|
6380
6369
|
const bindings = await registry.list({ channel, agentId, tenantId, channelInstallationId, limit, offset });
|
|
6381
6370
|
return { success: true, message: "Bindings retrieved", data: { records: bindings, total: bindings.length } };
|
|
6382
6371
|
} catch (error) {
|
|
@@ -6387,7 +6376,7 @@ async function getBindingList(request, _reply) {
|
|
|
6387
6376
|
async function getBinding(request, reply) {
|
|
6388
6377
|
const tenantId = getTenantId12(request);
|
|
6389
6378
|
try {
|
|
6390
|
-
const registry = getBindingRegistry();
|
|
6379
|
+
const registry = (0, import_core28.getBindingRegistry)();
|
|
6391
6380
|
const bindings = await registry.list({ tenantId });
|
|
6392
6381
|
const binding = bindings.find((b) => b.id === request.params.id);
|
|
6393
6382
|
if (!binding || binding.tenantId !== tenantId) {
|
|
@@ -6403,7 +6392,7 @@ async function getBinding(request, reply) {
|
|
|
6403
6392
|
async function createBinding(request, reply) {
|
|
6404
6393
|
const tenantId = getTenantId12(request);
|
|
6405
6394
|
try {
|
|
6406
|
-
const registry = getBindingRegistry();
|
|
6395
|
+
const registry = (0, import_core28.getBindingRegistry)();
|
|
6407
6396
|
const binding = await registry.create({ ...request.body, tenantId });
|
|
6408
6397
|
reply.status(201);
|
|
6409
6398
|
return { success: true, message: "Binding created", data: binding };
|
|
@@ -6416,7 +6405,7 @@ async function createBinding(request, reply) {
|
|
|
6416
6405
|
async function updateBinding(request, reply) {
|
|
6417
6406
|
try {
|
|
6418
6407
|
const tenantId = getTenantId12(request);
|
|
6419
|
-
const registry = getBindingRegistry();
|
|
6408
|
+
const registry = (0, import_core28.getBindingRegistry)();
|
|
6420
6409
|
const bindings = await registry.list({ tenantId });
|
|
6421
6410
|
const existing = bindings.find((b) => b.id === request.params.id);
|
|
6422
6411
|
if (!existing || existing.tenantId !== tenantId) {
|
|
@@ -6434,7 +6423,7 @@ async function updateBinding(request, reply) {
|
|
|
6434
6423
|
async function deleteBinding(request, reply) {
|
|
6435
6424
|
try {
|
|
6436
6425
|
const tenantId = getTenantId12(request);
|
|
6437
|
-
const registry = getBindingRegistry();
|
|
6426
|
+
const registry = (0, import_core28.getBindingRegistry)();
|
|
6438
6427
|
const bindings = await registry.list({ tenantId });
|
|
6439
6428
|
const existing = bindings.find((b) => b.id === request.params.id);
|
|
6440
6429
|
if (!existing || existing.tenantId !== tenantId) {
|
|
@@ -6453,7 +6442,7 @@ async function resolveBinding(request, _reply) {
|
|
|
6453
6442
|
const tenantId = getTenantId12(request);
|
|
6454
6443
|
const { channel, senderId, channelInstallationId } = request.query;
|
|
6455
6444
|
try {
|
|
6456
|
-
const registry = getBindingRegistry();
|
|
6445
|
+
const registry = (0, import_core28.getBindingRegistry)();
|
|
6457
6446
|
const binding = await registry.resolve({ channel, senderId, channelInstallationId, tenantId });
|
|
6458
6447
|
if (!binding) {
|
|
6459
6448
|
return { success: false, message: "No binding found", data: null };
|
|
@@ -6690,7 +6679,7 @@ var registerLatticeRoutes = (app2, channelDeps) => {
|
|
|
6690
6679
|
};
|
|
6691
6680
|
|
|
6692
6681
|
// src/router/MessageRouter.ts
|
|
6693
|
-
var
|
|
6682
|
+
var import_core29 = require("@axiom-lattice/core");
|
|
6694
6683
|
var import_crypto8 = require("crypto");
|
|
6695
6684
|
var BindingNotFoundError = class extends Error {
|
|
6696
6685
|
constructor(message) {
|
|
@@ -6806,7 +6795,7 @@ var MessageRouter = class {
|
|
|
6806
6795
|
}
|
|
6807
6796
|
let threadId = ctx.binding.threadMode === "per_conversation" ? void 0 : ctx.binding.threadId;
|
|
6808
6797
|
if (!threadId) {
|
|
6809
|
-
const threadStore = (0,
|
|
6798
|
+
const threadStore = (0, import_core29.getStoreLattice)("default", "thread").store;
|
|
6810
6799
|
const newThreadId = (0, import_crypto8.randomUUID)();
|
|
6811
6800
|
console.log({
|
|
6812
6801
|
event: "dispatch:thread:create",
|
|
@@ -6847,7 +6836,7 @@ var MessageRouter = class {
|
|
|
6847
6836
|
senderId: message.sender.id,
|
|
6848
6837
|
contentLength: message.content.text.length
|
|
6849
6838
|
}, "Dispatching to agent");
|
|
6850
|
-
const agent =
|
|
6839
|
+
const agent = import_core29.agentInstanceManager.getAgent({
|
|
6851
6840
|
tenant_id: tenantId,
|
|
6852
6841
|
assistant_id: ctx.binding.agentId,
|
|
6853
6842
|
thread_id: threadId,
|
|
@@ -7027,7 +7016,7 @@ function createAuditLoggerMiddleware() {
|
|
|
7027
7016
|
}
|
|
7028
7017
|
|
|
7029
7018
|
// src/index.ts
|
|
7030
|
-
var
|
|
7019
|
+
var import_core31 = require("@axiom-lattice/core");
|
|
7031
7020
|
|
|
7032
7021
|
// src/swagger.ts
|
|
7033
7022
|
var import_swagger = __toESM(require("@fastify/swagger"));
|
|
@@ -7092,7 +7081,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
|
|
|
7092
7081
|
};
|
|
7093
7082
|
|
|
7094
7083
|
// src/services/agent_task_consumer.ts
|
|
7095
|
-
var
|
|
7084
|
+
var import_core30 = require("@axiom-lattice/core");
|
|
7096
7085
|
var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
7097
7086
|
const {
|
|
7098
7087
|
assistant_id,
|
|
@@ -7110,18 +7099,18 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
7110
7099
|
console.log(
|
|
7111
7100
|
`\u5F00\u59CB\u5904\u7406\u4EFB\u52A1 [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
|
|
7112
7101
|
);
|
|
7113
|
-
const agent =
|
|
7114
|
-
await agent.addMessage({ input, command, custom_run_config: runConfig },
|
|
7102
|
+
const agent = import_core30.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: runConfig?.workspaceId, project_id: runConfig?.projectId, custom_run_config: runConfig });
|
|
7103
|
+
await agent.addMessage({ input, command, custom_run_config: runConfig }, import_core30.QueueMode.STEER);
|
|
7115
7104
|
if (callback_event) {
|
|
7116
7105
|
agent.subscribeOnce("message:completed", (evt) => {
|
|
7117
|
-
|
|
7106
|
+
import_core30.eventBus.publish(callback_event, {
|
|
7118
7107
|
success: true,
|
|
7119
7108
|
state: evt.state,
|
|
7120
7109
|
config: { assistant_id, thread_id, tenant_id }
|
|
7121
7110
|
});
|
|
7122
7111
|
if (main_thread_id && main_tenant_id) {
|
|
7123
7112
|
try {
|
|
7124
|
-
const mainAgent =
|
|
7113
|
+
const mainAgent = import_core30.agentInstanceManager.getAgent({
|
|
7125
7114
|
assistant_id: main_assistant_id ?? assistant_id,
|
|
7126
7115
|
thread_id: main_thread_id,
|
|
7127
7116
|
tenant_id: main_tenant_id
|
|
@@ -7149,7 +7138,7 @@ ${summary}`
|
|
|
7149
7138
|
}
|
|
7150
7139
|
});
|
|
7151
7140
|
agent.subscribeOnce("message:interrupted", (evt) => {
|
|
7152
|
-
|
|
7141
|
+
import_core30.eventBus.publish(callback_event, {
|
|
7153
7142
|
success: true,
|
|
7154
7143
|
state: evt.state,
|
|
7155
7144
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -7173,7 +7162,7 @@ ${summary}`
|
|
|
7173
7162
|
return handleAgentTask(taskRequest, nextRetryCount);
|
|
7174
7163
|
}
|
|
7175
7164
|
if (callback_event) {
|
|
7176
|
-
|
|
7165
|
+
import_core30.eventBus.publish(callback_event, {
|
|
7177
7166
|
success: false,
|
|
7178
7167
|
error: error instanceof Error ? error.message : String(error),
|
|
7179
7168
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -7211,7 +7200,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
7211
7200
|
* 初始化事件监听和队列轮询
|
|
7212
7201
|
*/
|
|
7213
7202
|
initialize() {
|
|
7214
|
-
|
|
7203
|
+
import_core30.eventBus.subscribe(import_core30.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
|
|
7215
7204
|
this.startPollingQueue();
|
|
7216
7205
|
console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
|
|
7217
7206
|
}
|
|
@@ -7330,7 +7319,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
7330
7319
|
handleAgentTask(taskRequest).catch((error) => {
|
|
7331
7320
|
console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
|
|
7332
7321
|
if (taskRequest.callback_event) {
|
|
7333
|
-
|
|
7322
|
+
import_core30.eventBus.publish(taskRequest.callback_event, {
|
|
7334
7323
|
success: false,
|
|
7335
7324
|
error: error instanceof Error ? error.message : String(error),
|
|
7336
7325
|
config: {
|
|
@@ -7350,7 +7339,7 @@ _AgentTaskConsumer.agent_run_endpoint = "http://localhost:4001/api/runs";
|
|
|
7350
7339
|
var AgentTaskConsumer = _AgentTaskConsumer;
|
|
7351
7340
|
|
|
7352
7341
|
// src/index.ts
|
|
7353
|
-
var
|
|
7342
|
+
var import_core32 = require("@axiom-lattice/core");
|
|
7354
7343
|
var import_protocols4 = require("@axiom-lattice/protocols");
|
|
7355
7344
|
var import_meta = {};
|
|
7356
7345
|
process.on("unhandledRejection", (reason, promise) => {
|
|
@@ -7366,11 +7355,11 @@ var DEFAULT_LOGGER_CONFIG = {
|
|
|
7366
7355
|
var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
|
|
7367
7356
|
var logger3 = loggerLattice.client;
|
|
7368
7357
|
function initializeLogger(config) {
|
|
7369
|
-
if (
|
|
7370
|
-
|
|
7358
|
+
if (import_core32.loggerLatticeManager.hasLattice("default")) {
|
|
7359
|
+
import_core32.loggerLatticeManager.removeLattice("default");
|
|
7371
7360
|
}
|
|
7372
|
-
(0,
|
|
7373
|
-
return (0,
|
|
7361
|
+
(0, import_core32.registerLoggerLattice)("default", config);
|
|
7362
|
+
return (0, import_core32.getLoggerLattice)("default");
|
|
7374
7363
|
}
|
|
7375
7364
|
var app = (0, import_fastify.default)({
|
|
7376
7365
|
logger: false,
|
|
@@ -7473,7 +7462,7 @@ app.setErrorHandler((error, request, reply) => {
|
|
|
7473
7462
|
});
|
|
7474
7463
|
function getConfiguredSandboxProvider() {
|
|
7475
7464
|
const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || "microsandbox-remote";
|
|
7476
|
-
return (0,
|
|
7465
|
+
return (0, import_core32.createSandboxProvider)({
|
|
7477
7466
|
type: sandboxProviderType,
|
|
7478
7467
|
remoteBaseURL: process.env.SANDBOX_BASE_URL,
|
|
7479
7468
|
microsandboxServiceBaseURL: process.env.MICROSANDBOX_SERVICE_BASE_URL,
|
|
@@ -7505,8 +7494,7 @@ var start = async (config) => {
|
|
|
7505
7494
|
const { getStoreLattice: getStoreLattice16 } = await import("@axiom-lattice/core");
|
|
7506
7495
|
const bindingStore = getStoreLattice16("default", "channelBinding").store;
|
|
7507
7496
|
const installationStore = getStoreLattice16("default", "channelInstallation").store;
|
|
7508
|
-
setBindingRegistry(bindingStore);
|
|
7509
|
-
(0, import_core30.setBindingRegistry)(bindingStore);
|
|
7497
|
+
(0, import_core31.setBindingRegistry)(bindingStore);
|
|
7510
7498
|
const adapterRegistry = new ChannelAdapterRegistry();
|
|
7511
7499
|
adapterRegistry.register(larkChannelAdapter);
|
|
7512
7500
|
const router = new MessageRouter({
|
|
@@ -7523,16 +7511,8 @@ var start = async (config) => {
|
|
|
7523
7511
|
} catch {
|
|
7524
7512
|
}
|
|
7525
7513
|
registerLatticeRoutes(app, channelDeps);
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
const store = storeLattice.store;
|
|
7529
|
-
import_core31.sqlDatabaseManager.setConfigStore(store);
|
|
7530
|
-
logger3.info("Database config store set for SqlDatabaseManager");
|
|
7531
|
-
} catch (error) {
|
|
7532
|
-
logger3.warn("Failed to set database config store: " + (error instanceof Error ? error.message : String(error)));
|
|
7533
|
-
}
|
|
7534
|
-
if (!import_core31.sandboxLatticeManager.hasLattice("default")) {
|
|
7535
|
-
import_core31.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
|
|
7514
|
+
if (!import_core32.sandboxLatticeManager.hasLattice("default")) {
|
|
7515
|
+
import_core32.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
|
|
7536
7516
|
logger3.info("Registered sandbox manager from env configuration");
|
|
7537
7517
|
}
|
|
7538
7518
|
const target_port = config?.port || Number(process.env.PORT) || 4001;
|
|
@@ -7553,7 +7533,7 @@ var start = async (config) => {
|
|
|
7553
7533
|
}
|
|
7554
7534
|
try {
|
|
7555
7535
|
logger3.info("Starting agent instance recovery...");
|
|
7556
|
-
const restoreStats = await
|
|
7536
|
+
const restoreStats = await import_core32.agentInstanceManager.restore();
|
|
7557
7537
|
logger3.info(`Agent recovery complete: ${restoreStats.restored} threads restored, ${restoreStats.errors} errors`);
|
|
7558
7538
|
} catch (error) {
|
|
7559
7539
|
logger3.error("Agent recovery failed", { error });
|