@reskill/agent-aware-server 0.4.0 → 0.4.1
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/LICENSE +21 -0
- package/README.md +77 -75
- package/README.zh-CN.md +220 -0
- package/dist/cli.js +1 -1
- package/dist/httpApi.js +2 -2
- package/dist/httpApi.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 kanyun-inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,71 +1,73 @@
|
|
|
1
1
|
# @reskill/agent-aware-server
|
|
2
2
|
|
|
3
|
-
Agent-aware Server
|
|
3
|
+
Agent-aware Server provides HTTP APIs to collect user interaction behaviors and page errors, with intelligent detectors for proactive issue discovery.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[简体中文](./README.zh-CN.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Features
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- **错误数据收集**:收集运行时错误、Promise 异常和 Console 错误
|
|
9
|
+
### 1. Data Collection
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
- **Behavior Data Collection**: Receives user interaction data from SDK at `http://localhost:4100`
|
|
12
|
+
- **Error Data Collection**: Collects runtime errors, Promise rejections, and console errors
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
### 2. Intelligent Detectors
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
- 检测消极的用户交互行为
|
|
18
|
-
- 触发条件:
|
|
19
|
-
- 挫折指数 >= 70(Critical)
|
|
20
|
-
- 挫折指数 50-70(Warning)
|
|
21
|
-
- 愤怒点击 >= 3 次(Warning)
|
|
22
|
-
- 死点击 >= 2 次(Warning)
|
|
23
|
-
- 输出文件:`.agent-aware/alert/behavior.json`
|
|
16
|
+
The refactored architecture includes two independent detectors:
|
|
24
17
|
|
|
25
|
-
####
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
18
|
+
#### BehaviorDetector
|
|
19
|
+
- Detects negative user interaction behaviors
|
|
20
|
+
- Trigger conditions:
|
|
21
|
+
- Frustration score >= 70 (Critical)
|
|
22
|
+
- Frustration score 50-70 (Warning)
|
|
23
|
+
- Rage clicks >= 3 (Warning)
|
|
24
|
+
- Dead clicks >= 2 (Warning)
|
|
25
|
+
- Output file: `.agent-aware/alert/behavior.json`
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
#### AlertDetector (Error Detector)
|
|
28
|
+
- Detects high-risk runtime errors
|
|
29
|
+
- Trigger conditions:
|
|
30
|
+
- Error count >= 1 (Critical)
|
|
31
|
+
- Output file: `.agent-aware/alert/error.json`
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
### 3. Data Storage
|
|
34
|
+
|
|
35
|
+
**All data is stored in the `.agent-aware/` directory under the user's project root**:
|
|
34
36
|
|
|
35
37
|
```
|
|
36
38
|
.agent-aware/
|
|
37
|
-
├── alert/ #
|
|
38
|
-
│ ├── behavior.json #
|
|
39
|
-
│ └── error.json #
|
|
40
|
-
└── detail/ #
|
|
41
|
-
├── behaviors.json #
|
|
42
|
-
└── errors.json #
|
|
39
|
+
├── alert/ # Alert files (for Agent monitoring)
|
|
40
|
+
│ ├── behavior.json # Behavior detection alerts (max 100 history)
|
|
41
|
+
│ └── error.json # Error detection alerts (max 100 history)
|
|
42
|
+
└── detail/ # Detail data files (for HTTP API queries)
|
|
43
|
+
├── behaviors.json # Behavior detail data (max 1000 entries)
|
|
44
|
+
└── errors.json # Error detail data (max 1000 entries)
|
|
43
45
|
```
|
|
44
46
|
|
|
45
|
-
##
|
|
47
|
+
## Usage
|
|
46
48
|
|
|
47
|
-
###
|
|
49
|
+
### Installation (Recommended as project dev dependency)
|
|
48
50
|
|
|
49
51
|
```bash
|
|
50
52
|
npm install --save-dev @reskill/agent-aware-server
|
|
51
53
|
```
|
|
52
54
|
|
|
53
|
-
###
|
|
55
|
+
### Starting the Server
|
|
54
56
|
|
|
55
|
-
####
|
|
57
|
+
#### Method 1: Using CLI (Recommended)
|
|
56
58
|
|
|
57
59
|
```bash
|
|
58
|
-
#
|
|
60
|
+
# Default start (output to current directory)
|
|
59
61
|
npx agent-aware-server start
|
|
60
62
|
|
|
61
|
-
#
|
|
63
|
+
# Specify project root directory
|
|
62
64
|
npx agent-aware-server start --project-root /path/to/project
|
|
63
65
|
|
|
64
|
-
#
|
|
66
|
+
# Use environment variable (highest priority)
|
|
65
67
|
USER_PROJECT_ROOT=/path/to/project npx agent-aware-server start
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
####
|
|
70
|
+
#### Method 2: Programmatic
|
|
69
71
|
|
|
70
72
|
```typescript
|
|
71
73
|
import { serve } from '@hono/node-server'
|
|
@@ -78,7 +80,7 @@ import { AlertDetector } from '@reskill/agent-aware-server/detector/alertDetecto
|
|
|
78
80
|
const PORT = 4100
|
|
79
81
|
const PROJECT_ROOT = process.env.USER_PROJECT_ROOT || process.cwd()
|
|
80
82
|
|
|
81
|
-
//
|
|
83
|
+
// All components use PROJECT_ROOT, data stored in .agent-aware/ directory
|
|
82
84
|
const store = new BehaviorStore(PROJECT_ROOT)
|
|
83
85
|
const errorStore = new ErrorStore(PROJECT_ROOT)
|
|
84
86
|
const behaviorDetector = new BehaviorDetector(PROJECT_ROOT)
|
|
@@ -96,39 +98,39 @@ console.log(`Server running on http://localhost:${PORT}`)
|
|
|
96
98
|
|
|
97
99
|
## HTTP API
|
|
98
100
|
|
|
99
|
-
###
|
|
101
|
+
### Behavior Related
|
|
100
102
|
|
|
101
|
-
- **POST /behaviors** -
|
|
102
|
-
- **GET /behaviors** -
|
|
103
|
-
-
|
|
104
|
-
- **GET /summary** -
|
|
105
|
-
- **GET /hotspots** -
|
|
106
|
-
-
|
|
107
|
-
- **DELETE /behaviors** -
|
|
103
|
+
- **POST /behaviors** - Receive behavior data (SDK reports)
|
|
104
|
+
- **GET /behaviors** - Query behavior data
|
|
105
|
+
- Parameters: `types` (optional), `limit` (optional)
|
|
106
|
+
- **GET /behaviors/summary** - Get behavior summary
|
|
107
|
+
- **GET /hotspots** - Get interaction hotspots
|
|
108
|
+
- Parameters: `limit` (optional)
|
|
109
|
+
- **DELETE /behaviors** - Clear behavior data
|
|
108
110
|
|
|
109
|
-
###
|
|
111
|
+
### Error Related
|
|
110
112
|
|
|
111
|
-
- **POST /errors** -
|
|
112
|
-
- **GET /errors** -
|
|
113
|
-
-
|
|
114
|
-
- **GET /errors/summary** -
|
|
115
|
-
- **DELETE /errors** -
|
|
113
|
+
- **POST /errors** - Receive error data (SDK reports)
|
|
114
|
+
- **GET /errors** - Query error data
|
|
115
|
+
- Parameters: `errorTypes` (optional), `limit` (optional)
|
|
116
|
+
- **GET /errors/summary** - Get error summary
|
|
117
|
+
- **DELETE /errors** - Clear error data
|
|
116
118
|
|
|
117
|
-
###
|
|
119
|
+
### Health Check
|
|
118
120
|
|
|
119
|
-
- **GET /health** -
|
|
121
|
+
- **GET /health** - Health check
|
|
120
122
|
|
|
121
|
-
##
|
|
123
|
+
## Project Root Configuration
|
|
122
124
|
|
|
123
|
-
|
|
125
|
+
The output file location is determined by the following priority:
|
|
124
126
|
|
|
125
|
-
1.
|
|
126
|
-
2.
|
|
127
|
-
3.
|
|
127
|
+
1. **Environment variable** `USER_PROJECT_ROOT` (highest priority)
|
|
128
|
+
2. **Startup parameter** `--project-root`
|
|
129
|
+
3. **Default** `process.cwd()` (current working directory)
|
|
128
130
|
|
|
129
|
-
##
|
|
131
|
+
## Output File Examples
|
|
130
132
|
|
|
131
|
-
|
|
133
|
+
Alert files retain history (max 100 entries) in the following format:
|
|
132
134
|
|
|
133
135
|
### alert/behavior.json
|
|
134
136
|
|
|
@@ -140,7 +142,7 @@ console.log(`Server running on http://localhost:${PORT}`)
|
|
|
140
142
|
"timestamp": "2026-01-30T10:30:00.000Z",
|
|
141
143
|
"severity": "critical",
|
|
142
144
|
"type": "frustration",
|
|
143
|
-
"summary": "
|
|
145
|
+
"summary": "检测到用户挫折行为(挫折指数: 75)",
|
|
144
146
|
"details": {
|
|
145
147
|
"frustrationScore": 75,
|
|
146
148
|
"rageClickCount": 5,
|
|
@@ -182,32 +184,32 @@ console.log(`Server running on http://localhost:${PORT}`)
|
|
|
182
184
|
}
|
|
183
185
|
```
|
|
184
186
|
|
|
185
|
-
##
|
|
187
|
+
## Cooldown Mechanism
|
|
186
188
|
|
|
187
|
-
|
|
188
|
-
-
|
|
189
|
-
-
|
|
189
|
+
To prevent alert storms, each detector has a 10-second cooldown period:
|
|
190
|
+
- Minimum 10 seconds between file writes for the same detector
|
|
191
|
+
- New issues during cooldown are accumulated for the next write
|
|
190
192
|
|
|
191
|
-
##
|
|
193
|
+
## Architecture
|
|
192
194
|
|
|
193
|
-
|
|
195
|
+
Based on [SPEC-SRV-005: Detector Architecture Refactor](../../specs/server/005-detector-refactor.md)
|
|
194
196
|
|
|
195
|
-
###
|
|
197
|
+
### Design Principles
|
|
196
198
|
|
|
197
|
-
1.
|
|
198
|
-
2.
|
|
199
|
-
3.
|
|
200
|
-
4.
|
|
199
|
+
1. **Separation of Concerns**: BehaviorDetector and AlertDetector have distinct responsibilities
|
|
200
|
+
2. **Asynchronous Detection**: Detection logic doesn't block API responses
|
|
201
|
+
3. **Fault Tolerant**: File write failures don't affect data reception
|
|
202
|
+
4. **Independent Operation**: Each detector works independently without interference
|
|
201
203
|
|
|
202
|
-
##
|
|
204
|
+
## Development
|
|
203
205
|
|
|
204
|
-
###
|
|
206
|
+
### Run Tests
|
|
205
207
|
|
|
206
208
|
```bash
|
|
207
209
|
npm test
|
|
208
210
|
```
|
|
209
211
|
|
|
210
|
-
###
|
|
212
|
+
### Build
|
|
211
213
|
|
|
212
214
|
```bash
|
|
213
215
|
npm run build
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# @reskill/agent-aware-server
|
|
2
|
+
|
|
3
|
+
Agent-aware Server 提供 HTTP API 来收集用户交互行为和页面报错信息,并通过智能检测器主动发现问题。
|
|
4
|
+
|
|
5
|
+
[English](./README.md)
|
|
6
|
+
|
|
7
|
+
## 功能特性
|
|
8
|
+
|
|
9
|
+
### 1. 数据收集
|
|
10
|
+
|
|
11
|
+
- **行为数据收集**:从 `http://localhost:4100` 接收 SDK 上报的用户交互数据
|
|
12
|
+
- **错误数据收集**:收集运行时错误、Promise 异常和 Console 错误
|
|
13
|
+
|
|
14
|
+
### 2. 智能检测器
|
|
15
|
+
|
|
16
|
+
重构后的架构包含两个独立的检测器:
|
|
17
|
+
|
|
18
|
+
#### BehaviorDetector(行为检测器)
|
|
19
|
+
- 检测消极的用户交互行为
|
|
20
|
+
- 触发条件:
|
|
21
|
+
- 挫折指数 >= 70(Critical)
|
|
22
|
+
- 挫折指数 50-70(Warning)
|
|
23
|
+
- 愤怒点击 >= 3 次(Warning)
|
|
24
|
+
- 死点击 >= 2 次(Warning)
|
|
25
|
+
- 输出文件:`.agent-aware/alert/behavior.json`
|
|
26
|
+
|
|
27
|
+
#### AlertDetector(错误检测器)
|
|
28
|
+
- 检测高危的运行时错误
|
|
29
|
+
- 触发条件:
|
|
30
|
+
- 错误数 >= 1(Critical)
|
|
31
|
+
- 输出文件:`.agent-aware/alert/error.json`
|
|
32
|
+
|
|
33
|
+
### 3. 数据存储
|
|
34
|
+
|
|
35
|
+
**所有数据统一存储到用户项目根目录的 `.agent-aware/` 目录**:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
.agent-aware/
|
|
39
|
+
├── alert/ # 检测告警文件(供 Agent 监控)
|
|
40
|
+
│ ├── behavior.json # 行为检测告警(最多 100 条历史)
|
|
41
|
+
│ └── error.json # 错误检测告警(最多 100 条历史)
|
|
42
|
+
└── detail/ # 详细数据文件(供 HTTP API 查询)
|
|
43
|
+
├── behaviors.json # 行为详细数据(最多 1000 条)
|
|
44
|
+
└── errors.json # 错误详细数据(最多 1000 条)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 使用方式
|
|
48
|
+
|
|
49
|
+
### 安装(推荐项目级别开发依赖)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install --save-dev @reskill/agent-aware-server
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 启动服务
|
|
56
|
+
|
|
57
|
+
#### 方式 1:使用 CLI(推荐)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# 默认启动(输出到当前目录)
|
|
61
|
+
npx agent-aware-server start
|
|
62
|
+
|
|
63
|
+
# 指定项目根目录
|
|
64
|
+
npx agent-aware-server start --project-root /path/to/project
|
|
65
|
+
|
|
66
|
+
# 使用环境变量(优先级最高)
|
|
67
|
+
USER_PROJECT_ROOT=/path/to/project npx agent-aware-server start
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### 方式 2:编程方式
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { serve } from '@hono/node-server'
|
|
74
|
+
import { createHttpApi } from '@reskill/agent-aware-server/httpApi'
|
|
75
|
+
import { BehaviorStore } from '@reskill/agent-aware-server/store/behaviorStore'
|
|
76
|
+
import { ErrorStore } from '@reskill/agent-aware-server/store/errorStore'
|
|
77
|
+
import { BehaviorDetector } from '@reskill/agent-aware-server/detector/behaviorDetector'
|
|
78
|
+
import { AlertDetector } from '@reskill/agent-aware-server/detector/alertDetector'
|
|
79
|
+
|
|
80
|
+
const PORT = 4100
|
|
81
|
+
const PROJECT_ROOT = process.env.USER_PROJECT_ROOT || process.cwd()
|
|
82
|
+
|
|
83
|
+
// 所有组件统一使用 PROJECT_ROOT,数据存储在 .agent-aware/ 目录下
|
|
84
|
+
const store = new BehaviorStore(PROJECT_ROOT)
|
|
85
|
+
const errorStore = new ErrorStore(PROJECT_ROOT)
|
|
86
|
+
const behaviorDetector = new BehaviorDetector(PROJECT_ROOT)
|
|
87
|
+
const alertDetector = new AlertDetector(PROJECT_ROOT)
|
|
88
|
+
|
|
89
|
+
const app = createHttpApi(store, errorStore, behaviorDetector, alertDetector)
|
|
90
|
+
|
|
91
|
+
serve({
|
|
92
|
+
fetch: app.fetch,
|
|
93
|
+
port: PORT,
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
console.log(`Server running on http://localhost:${PORT}`)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## HTTP API
|
|
100
|
+
|
|
101
|
+
### 行为相关
|
|
102
|
+
|
|
103
|
+
- **POST /behaviors** - 接收行为数据(SDK 上报)
|
|
104
|
+
- **GET /behaviors** - 查询行为数据
|
|
105
|
+
- 参数:`types`(可选)、`limit`(可选)
|
|
106
|
+
- **GET /behaviors/summary** - 获取行为摘要
|
|
107
|
+
- **GET /hotspots** - 获取交互热点
|
|
108
|
+
- 参数:`limit`(可选)
|
|
109
|
+
- **DELETE /behaviors** - 清空行为数据
|
|
110
|
+
|
|
111
|
+
### 错误相关
|
|
112
|
+
|
|
113
|
+
- **POST /errors** - 接收错误数据(SDK 上报)
|
|
114
|
+
- **GET /errors** - 查询错误数据
|
|
115
|
+
- 参数:`errorTypes`(可选)、`limit`(可选)
|
|
116
|
+
- **GET /errors/summary** - 获取错误摘要
|
|
117
|
+
- **DELETE /errors** - 清空错误数据
|
|
118
|
+
|
|
119
|
+
### 健康检查
|
|
120
|
+
|
|
121
|
+
- **GET /health** - 健康检查
|
|
122
|
+
|
|
123
|
+
## 项目根目录配置
|
|
124
|
+
|
|
125
|
+
检测器输出文件的位置由以下优先级决定:
|
|
126
|
+
|
|
127
|
+
1. **环境变量** `USER_PROJECT_ROOT`(优先级最高)
|
|
128
|
+
2. **启动参数** `--project-root`
|
|
129
|
+
3. **默认值** `process.cwd()`(当前工作目录)
|
|
130
|
+
|
|
131
|
+
## 输出文件示例
|
|
132
|
+
|
|
133
|
+
告警文件保留历史记录(最多 100 条),新格式如下:
|
|
134
|
+
|
|
135
|
+
### alert/behavior.json
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"version": "1.0",
|
|
140
|
+
"alerts": [
|
|
141
|
+
{
|
|
142
|
+
"timestamp": "2026-01-30T10:30:00.000Z",
|
|
143
|
+
"severity": "critical",
|
|
144
|
+
"type": "frustration",
|
|
145
|
+
"summary": "检测到用户挫折行为",
|
|
146
|
+
"details": {
|
|
147
|
+
"frustrationScore": 75,
|
|
148
|
+
"rageClickCount": 5,
|
|
149
|
+
"deadClickCount": 3,
|
|
150
|
+
"totalInteractions": 50
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### alert/error.json
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"version": "1.0",
|
|
162
|
+
"alerts": [
|
|
163
|
+
{
|
|
164
|
+
"timestamp": "2026-01-30T10:30:00.000Z",
|
|
165
|
+
"severity": "critical",
|
|
166
|
+
"type": "error",
|
|
167
|
+
"summary": "检测到 3 个运行时错误",
|
|
168
|
+
"details": {
|
|
169
|
+
"totalErrors": 3,
|
|
170
|
+
"runtimeErrorCount": 2,
|
|
171
|
+
"unhandledRejectionCount": 1,
|
|
172
|
+
"consoleErrorCount": 0,
|
|
173
|
+
"recentErrors": [
|
|
174
|
+
{
|
|
175
|
+
"id": "uuid-1",
|
|
176
|
+
"timestamp": 1738233000000,
|
|
177
|
+
"errorType": "runtime",
|
|
178
|
+
"message": "Cannot read property 'foo' of undefined"
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## 冷却期机制
|
|
188
|
+
|
|
189
|
+
为避免告警风暴,每个检测器都有 10 秒的冷却期:
|
|
190
|
+
- 同一检测器的文件写入间隔至少 10 秒
|
|
191
|
+
- 冷却期内的新问题会累积到下次写入
|
|
192
|
+
|
|
193
|
+
## 架构说明
|
|
194
|
+
|
|
195
|
+
基于 [SPEC-SRV-005: Detector 架构重构](../../specs/server/005-detector-refactor.md)
|
|
196
|
+
|
|
197
|
+
### 设计原则
|
|
198
|
+
|
|
199
|
+
1. **职责分离**:BehaviorDetector 和 AlertDetector 各司其职
|
|
200
|
+
2. **异步检测**:检测逻辑不阻塞 API 响应
|
|
201
|
+
3. **容错设计**:文件写入失败不影响数据接收
|
|
202
|
+
4. **独立工作**:每个检测器独立工作,互不干扰
|
|
203
|
+
|
|
204
|
+
## 开发
|
|
205
|
+
|
|
206
|
+
### 运行测试
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
npm test
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### 构建
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
npm run build
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT
|
package/dist/cli.js
CHANGED
|
@@ -51,7 +51,7 @@ function start() {
|
|
|
51
51
|
║ Endpoints: ║
|
|
52
52
|
║ POST /behaviors - SDK 上报行为数据 ║
|
|
53
53
|
║ GET /behaviors - 查询行为列表 ║
|
|
54
|
-
║ GET /summary
|
|
54
|
+
║ GET /behaviors/summary - 获取行为摘要 ║
|
|
55
55
|
║ GET /hotspots - 获取交互热点 ║
|
|
56
56
|
║ DELETE /behaviors - 清空行为数据 ║
|
|
57
57
|
║ POST /errors - SDK 上报错误数据 ║
|
package/dist/httpApi.js
CHANGED
|
@@ -52,8 +52,8 @@ export function createHttpApi(store, errorStore, behaviorDetector, alertDetector
|
|
|
52
52
|
const behaviors = await store.query({ types, limit });
|
|
53
53
|
return c.json(behaviors);
|
|
54
54
|
});
|
|
55
|
-
// GET /summary - 获取行为摘要
|
|
56
|
-
app.get('/summary', async (c) => {
|
|
55
|
+
// GET /behaviors/summary - 获取行为摘要
|
|
56
|
+
app.get('/behaviors/summary', async (c) => {
|
|
57
57
|
const summary = await store.getSummary();
|
|
58
58
|
return c.json(summary);
|
|
59
59
|
});
|
package/dist/httpApi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpApi.js","sourceRoot":"","sources":["../src/httpApi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAehC,MAAM,UAAU,aAAa,CAC3B,KAAoB,EACpB,UAAuB,EACvB,gBAAmC,EACnC,aAA6B;IAE7B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IAEtB,yBAAyB;IACzB,8CAA8C;IAC9C,GAAG,CAAC,GAAG,CAAC,IA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