@axiom-lattice/gateway 2.1.18 → 2.1.20
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 +20 -0
- package/LOGGER_CONFIG.md +135 -0
- package/README.md +28 -1
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +288 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +278 -152
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/controllers/schedules.ts +316 -0
- package/src/index.ts +112 -17
- package/src/routes/index.ts +30 -0
- package/src/services/agent_service.ts +12 -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.20 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,13 @@
|
|
|
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
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m59.42 KB[39m
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m129.40 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 154ms
|
|
15
|
+
[32mCJS[39m [1mdist/index.js [22m[32m61.85 KB[39m
|
|
16
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m129.46 KB[39m
|
|
17
|
+
[32mCJS[39m ⚡️ Build success in 157ms
|
|
18
18
|
[34mDTS[39m Build start
|
|
19
|
-
[32mDTS[39m ⚡️ Build success in
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.
|
|
19
|
+
[32mDTS[39m ⚡️ Build success in 7579ms
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.72 KB[39m
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.72 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
+
## 2.1.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ef0fb84: update lagger lattice
|
|
8
|
+
- Updated dependencies [ef0fb84]
|
|
9
|
+
- @axiom-lattice/protocols@2.1.9
|
|
10
|
+
- @axiom-lattice/core@2.1.15
|
|
11
|
+
- @axiom-lattice/queue-redis@1.0.8
|
|
12
|
+
|
|
13
|
+
## 2.1.19
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- d43ea0b: add schedule task
|
|
18
|
+
- Updated dependencies [d43ea0b]
|
|
19
|
+
- @axiom-lattice/protocols@2.1.8
|
|
20
|
+
- @axiom-lattice/core@2.1.14
|
|
21
|
+
- @axiom-lattice/queue-redis@1.0.7
|
|
22
|
+
|
|
3
23
|
## 2.1.18
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/LOGGER_CONFIG.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Logger Configuration Guide
|
|
2
|
+
|
|
3
|
+
Gateway 支持通过 `LatticeGatewayConfig` 自定义 logger 配置。
|
|
4
|
+
|
|
5
|
+
## 默认配置
|
|
6
|
+
|
|
7
|
+
如果不提供 `loggerConfig`,Gateway 会使用以下默认配置:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
{
|
|
11
|
+
name: "default",
|
|
12
|
+
description: "Default logger for lattice-gateway service",
|
|
13
|
+
type: LoggerType.PINO,
|
|
14
|
+
serviceName: "lattice/gateway",
|
|
15
|
+
loggerName: "lattice/gateway",
|
|
16
|
+
file: {
|
|
17
|
+
file: "./logs/lattice/gateway",
|
|
18
|
+
frequency: "daily",
|
|
19
|
+
mkdir: true,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 自定义配置示例
|
|
25
|
+
|
|
26
|
+
### 示例 1: 自定义日志文件路径
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { LatticeGateway } from "@axiom-lattice/gateway";
|
|
30
|
+
import { LoggerType } from "@axiom-lattice/protocols";
|
|
31
|
+
|
|
32
|
+
LatticeGateway.startAsHttpEndpoint({
|
|
33
|
+
port: 4001,
|
|
34
|
+
loggerConfig: {
|
|
35
|
+
file: "./logs/my-custom-app.log", // 简单字符串路径
|
|
36
|
+
},
|
|
37
|
+
queueServiceConfig: {
|
|
38
|
+
type: "memory",
|
|
39
|
+
defaultStartPollingQueue: true,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 示例 2: 详细文件配置
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { LatticeGateway } from "@axiom-lattice/gateway";
|
|
48
|
+
import { LoggerType } from "@axiom-lattice/protocols";
|
|
49
|
+
|
|
50
|
+
LatticeGateway.startAsHttpEndpoint({
|
|
51
|
+
port: 4001,
|
|
52
|
+
loggerConfig: {
|
|
53
|
+
serviceName: "my-service",
|
|
54
|
+
loggerName: "my-logger",
|
|
55
|
+
file: {
|
|
56
|
+
file: "./logs/my-service", // 文件路径(不含扩展名)
|
|
57
|
+
frequency: "daily", // 轮转频率: "daily" | "hourly" | "minutely"
|
|
58
|
+
mkdir: true, // 自动创建目录
|
|
59
|
+
maxFiles: 30, // 保留30天的日志文件
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
queueServiceConfig: {
|
|
63
|
+
type: "memory",
|
|
64
|
+
defaultStartPollingQueue: true,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 示例 3: 使用控制台日志(开发环境)
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { LatticeGateway } from "@axiom-lattice/gateway";
|
|
73
|
+
import { LoggerType } from "@axiom-lattice/protocols";
|
|
74
|
+
|
|
75
|
+
LatticeGateway.startAsHttpEndpoint({
|
|
76
|
+
port: 4001,
|
|
77
|
+
loggerConfig: {
|
|
78
|
+
type: LoggerType.CONSOLE, // 使用控制台输出
|
|
79
|
+
serviceName: "my-service",
|
|
80
|
+
},
|
|
81
|
+
queueServiceConfig: {
|
|
82
|
+
type: "memory",
|
|
83
|
+
defaultStartPollingQueue: true,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 示例 4: 仅覆盖部分配置
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { LatticeGateway } from "@axiom-lattice/gateway";
|
|
92
|
+
|
|
93
|
+
LatticeGateway.startAsHttpEndpoint({
|
|
94
|
+
port: 4001,
|
|
95
|
+
loggerConfig: {
|
|
96
|
+
// 只覆盖文件路径,其他使用默认值
|
|
97
|
+
file: "./logs/custom-path/app",
|
|
98
|
+
},
|
|
99
|
+
queueServiceConfig: {
|
|
100
|
+
type: "memory",
|
|
101
|
+
defaultStartPollingQueue: true,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 配置选项说明
|
|
107
|
+
|
|
108
|
+
### GatewayLoggerConfig
|
|
109
|
+
|
|
110
|
+
| 字段 | 类型 | 说明 | 默认值 |
|
|
111
|
+
|------|------|------|--------|
|
|
112
|
+
| `name` | `string?` | Logger 名称 | `"default"` |
|
|
113
|
+
| `description` | `string?` | Logger 描述 | `"Default logger for lattice-gateway service"` |
|
|
114
|
+
| `type` | `LoggerType?` | Logger 类型 | `LoggerType.PINO` |
|
|
115
|
+
| `serviceName` | `string?` | 服务名称 | `"lattice/gateway"` |
|
|
116
|
+
| `loggerName` | `string?` | Logger 实例名称 | `"lattice/gateway"` |
|
|
117
|
+
| `file` | `string \| PinoFileOptions?` | 文件路径或详细配置 | `{ file: "./logs/lattice/gateway", frequency: "daily", mkdir: true }` |
|
|
118
|
+
| `context` | `Record<string, any>?` | 初始上下文 | `{}` |
|
|
119
|
+
|
|
120
|
+
### PinoFileOptions
|
|
121
|
+
|
|
122
|
+
| 字段 | 类型 | 说明 | 默认值 |
|
|
123
|
+
|------|------|------|--------|
|
|
124
|
+
| `file` | `string?` | 日志文件路径 | `"./logs/app"` |
|
|
125
|
+
| `frequency` | `"daily" \| "hourly" \| "minutely" \| string` | 日志轮转频率 | `"daily"` |
|
|
126
|
+
| `mkdir` | `boolean?` | 自动创建目录 | `true` |
|
|
127
|
+
| `size` | `string?` | 最大文件大小(如 "10M", "100K") | - |
|
|
128
|
+
| `maxFiles` | `number?` | 保留的最大文件数 | - |
|
|
129
|
+
|
|
130
|
+
## 注意事项
|
|
131
|
+
|
|
132
|
+
1. **配置合并**: 提供的 `loggerConfig` 会与默认配置合并,未指定的字段会使用默认值
|
|
133
|
+
2. **文件路径**: 如果指定的是字符串路径,会自动使用默认的 `daily` 轮转策略
|
|
134
|
+
3. **生产环境**: 在生产环境(`NODE_ENV=production`)下,如果没有指定 `file` 配置,会自动使用文件日志
|
|
135
|
+
4. **开发环境**: 在开发环境下,如果没有指定 `file` 配置,会使用控制台输出(pino-pretty)
|
package/README.md
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
- 代理调用服务
|
|
9
9
|
- 流式响应支持
|
|
10
10
|
- 事件总线
|
|
11
|
-
-
|
|
11
|
+
- 队列服务(基于 QueueLattice)
|
|
12
|
+
- 日志服务(基于 LoggerLattice,支持自定义配置)
|
|
12
13
|
|
|
13
14
|
## 安装
|
|
14
15
|
|
|
@@ -89,6 +90,31 @@ console.log(result); // { success: true, message: "Configuration updated success
|
|
|
89
90
|
- `GET /api/v1/run/:thread_id`: 获取运行状态
|
|
90
91
|
- `GET /api/v1/run/:thread_id/messages`: 获取消息历史
|
|
91
92
|
|
|
93
|
+
## Logger 配置
|
|
94
|
+
|
|
95
|
+
Gateway 使用 Logger Lattice 进行日志管理,支持自定义日志配置。详细说明请参考 [LOGGER_CONFIG.md](./LOGGER_CONFIG.md)。
|
|
96
|
+
|
|
97
|
+
### 快速开始
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { LatticeGateway } from "@axiom-lattice/gateway";
|
|
101
|
+
import { LoggerType } from "@axiom-lattice/protocols";
|
|
102
|
+
|
|
103
|
+
// 使用默认配置
|
|
104
|
+
LatticeGateway.startAsHttpEndpoint({
|
|
105
|
+
port: 4001,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// 自定义日志配置
|
|
109
|
+
LatticeGateway.startAsHttpEndpoint({
|
|
110
|
+
port: 4001,
|
|
111
|
+
loggerConfig: {
|
|
112
|
+
file: "./logs/my-app/gateway",
|
|
113
|
+
serviceName: "my-service",
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
92
118
|
## 目录结构
|
|
93
119
|
|
|
94
120
|
- `src/config/`: 配置文件
|
|
@@ -96,3 +122,4 @@ console.log(result); // { success: true, message: "Configuration updated success
|
|
|
96
122
|
- `src/routes/`: 路由定义
|
|
97
123
|
- `src/services/`: 服务实现
|
|
98
124
|
- `src/types/`: 类型定义
|
|
125
|
+
- `LOGGER_CONFIG.md`: Logger 配置详细文档
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as http from 'http';
|
|
2
2
|
import * as fastify from 'fastify';
|
|
3
|
+
import { LoggerType, PinoFileOptions } from '@axiom-lattice/protocols';
|
|
3
4
|
|
|
4
5
|
declare const defaultSwaggerConfig: {
|
|
5
6
|
openapi: {
|
|
@@ -100,12 +101,25 @@ declare class AgentTaskConsumer {
|
|
|
100
101
|
trigger_agent_task(taskRequest: AgentTaskRequest): void;
|
|
101
102
|
}
|
|
102
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Logger configuration for gateway
|
|
106
|
+
*/
|
|
107
|
+
interface GatewayLoggerConfig {
|
|
108
|
+
name?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
type?: LoggerType;
|
|
111
|
+
serviceName?: string;
|
|
112
|
+
loggerName?: string;
|
|
113
|
+
file?: string | PinoFileOptions;
|
|
114
|
+
context?: Record<string, any>;
|
|
115
|
+
}
|
|
103
116
|
interface LatticeGatewayConfig {
|
|
104
117
|
port?: number;
|
|
105
118
|
queueServiceConfig?: {
|
|
106
119
|
type: QueueServiceType;
|
|
107
120
|
defaultStartPollingQueue: boolean;
|
|
108
121
|
};
|
|
122
|
+
loggerConfig?: Partial<GatewayLoggerConfig>;
|
|
109
123
|
}
|
|
110
124
|
declare const LatticeGateway: {
|
|
111
125
|
startAsHttpEndpoint: (config?: LatticeGatewayConfig) => Promise<void>;
|
|
@@ -117,4 +131,4 @@ declare const LatticeGateway: {
|
|
|
117
131
|
AgentTaskConsumer: typeof AgentTaskConsumer;
|
|
118
132
|
};
|
|
119
133
|
|
|
120
|
-
export { LatticeGateway, type LatticeGatewayConfig };
|
|
134
|
+
export { type GatewayLoggerConfig, LatticeGateway, type LatticeGatewayConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as http from 'http';
|
|
2
2
|
import * as fastify from 'fastify';
|
|
3
|
+
import { LoggerType, PinoFileOptions } from '@axiom-lattice/protocols';
|
|
3
4
|
|
|
4
5
|
declare const defaultSwaggerConfig: {
|
|
5
6
|
openapi: {
|
|
@@ -100,12 +101,25 @@ declare class AgentTaskConsumer {
|
|
|
100
101
|
trigger_agent_task(taskRequest: AgentTaskRequest): void;
|
|
101
102
|
}
|
|
102
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Logger configuration for gateway
|
|
106
|
+
*/
|
|
107
|
+
interface GatewayLoggerConfig {
|
|
108
|
+
name?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
type?: LoggerType;
|
|
111
|
+
serviceName?: string;
|
|
112
|
+
loggerName?: string;
|
|
113
|
+
file?: string | PinoFileOptions;
|
|
114
|
+
context?: Record<string, any>;
|
|
115
|
+
}
|
|
103
116
|
interface LatticeGatewayConfig {
|
|
104
117
|
port?: number;
|
|
105
118
|
queueServiceConfig?: {
|
|
106
119
|
type: QueueServiceType;
|
|
107
120
|
defaultStartPollingQueue: boolean;
|
|
108
121
|
};
|
|
122
|
+
loggerConfig?: Partial<GatewayLoggerConfig>;
|
|
109
123
|
}
|
|
110
124
|
declare const LatticeGateway: {
|
|
111
125
|
startAsHttpEndpoint: (config?: LatticeGatewayConfig) => Promise<void>;
|
|
@@ -117,4 +131,4 @@ declare const LatticeGateway: {
|
|
|
117
131
|
AgentTaskConsumer: typeof AgentTaskConsumer;
|
|
118
132
|
};
|
|
119
133
|
|
|
120
|
-
export { LatticeGateway, type LatticeGatewayConfig };
|
|
134
|
+
export { type GatewayLoggerConfig, LatticeGateway, type LatticeGatewayConfig };
|