@cxyhhhhh/qqbot-cli 0.1.0-dev.202606011703
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/README.md +239 -0
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +25 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/chunk-WRKDI4MF.js +407 -0
- package/dist/chunk-WRKDI4MF.js.map +1 -0
- package/dist/chunk-XIJ6OSLY.js +3654 -0
- package/dist/chunk-XIJ6OSLY.js.map +1 -0
- package/dist/cli-TUC3HG75.js +14 -0
- package/dist/cli-TUC3HG75.js.map +1 -0
- package/dist/src/index.d.ts +1540 -0
- package/dist/src/index.js +11 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +73 -0
- package/templates/bot.cloudagent.yaml +131 -0
- package/templates/bot.echo.yaml +55 -0
- package/templates/bot.galileo.yaml +63 -0
- package/templates/bot.openai.yaml +63 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cxyhhhhh/qqbot-cli",
|
|
3
|
+
"version": "0.1.0-dev.202606011703",
|
|
4
|
+
"description": "CLI tool to run a QQ Bot with pluggable AI backends (Echo / OpenAI / CloudAgent ACP)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"qqbot-cli": "./dist/bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/src/index.js",
|
|
10
|
+
"types": "./dist/src/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"templates"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "tsx bin/cli.ts",
|
|
17
|
+
"build": "tsup",
|
|
18
|
+
"start": "node dist/bin/cli.js start",
|
|
19
|
+
"typecheck": "tsc --noEmit",
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"commitlint": "commitlint",
|
|
22
|
+
"clean": "rm -rf dist"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18.0.0"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"qq",
|
|
29
|
+
"bot",
|
|
30
|
+
"cli",
|
|
31
|
+
"cloudagent",
|
|
32
|
+
"acp",
|
|
33
|
+
"openai"
|
|
34
|
+
],
|
|
35
|
+
"license": "ISC",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@agentclientprotocol/sdk": "^0.21.1",
|
|
38
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
39
|
+
"@opentelemetry/api": "^1.9.1",
|
|
40
|
+
"@opentelemetry/core": "^1.30.1",
|
|
41
|
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.57.2",
|
|
42
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.57.2",
|
|
43
|
+
"@opentelemetry/resources": "^1.30.1",
|
|
44
|
+
"@opentelemetry/sdk-metrics": "^1.30.1",
|
|
45
|
+
"@opentelemetry/sdk-trace-node": "^1.30.1",
|
|
46
|
+
"@opentelemetry/semantic-conventions": "^1.41.1",
|
|
47
|
+
"@tencent/qqbot-nodejs": "0.0.0-dev.e55b99d7",
|
|
48
|
+
"commander": "^12.1.0",
|
|
49
|
+
"cosmiconfig": "^9.0.1",
|
|
50
|
+
"dotenv": "^16.6.1",
|
|
51
|
+
"json-bigint": "^1.0.0",
|
|
52
|
+
"pino": "^10.3.1",
|
|
53
|
+
"pino-pretty": "^13.1.3",
|
|
54
|
+
"pino-roll": "^4.0.0",
|
|
55
|
+
"ws": "^8.20.1",
|
|
56
|
+
"yaml": "^2.9.0",
|
|
57
|
+
"zod": "^3.25.76"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@commitlint/cli": "^19.8.1",
|
|
61
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
62
|
+
"@eslint/js": "^9.27.0",
|
|
63
|
+
"@types/json-bigint": "^1.0.4",
|
|
64
|
+
"@types/node": "^20.19.41",
|
|
65
|
+
"@types/ws": "^8.18.1",
|
|
66
|
+
"eslint": "^9.27.0",
|
|
67
|
+
"globals": "^16.1.0",
|
|
68
|
+
"tsup": "^8.5.1",
|
|
69
|
+
"tsx": "^4.22.3",
|
|
70
|
+
"typescript": "^5.9.3",
|
|
71
|
+
"typescript-eslint": "^8.33.0"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# qqbot-cli 配置模板 — CloudAgent ACP 模式
|
|
2
|
+
|
|
3
|
+
qq:
|
|
4
|
+
appId: ${QQBOT_APP_ID}
|
|
5
|
+
appSecret: ${QQBOT_APP_SECRET}
|
|
6
|
+
markdown: false
|
|
7
|
+
# userAgent: qqbot-cli/0.1.0 # 自定义 User-Agent(默认 qqbot-cli/<version>)
|
|
8
|
+
# baseUrl: https://api.sgroup.qq.com
|
|
9
|
+
# tokenBaseUrl: https://bots.qq.com
|
|
10
|
+
# Token 获取策略:sync (默认,阻塞启动,fail-fast) | async (异步,快速启动)
|
|
11
|
+
# tokenPrefetch: sync
|
|
12
|
+
# 事件传输模式:websocket (默认) | webhook
|
|
13
|
+
# transport: websocket
|
|
14
|
+
# webhook 模式配置:
|
|
15
|
+
# webhook:
|
|
16
|
+
# port: 8080
|
|
17
|
+
# path: /callback
|
|
18
|
+
|
|
19
|
+
mcp:
|
|
20
|
+
enabled: true
|
|
21
|
+
# host: 127.0.0.1 # Docker 容器内需设为 0.0.0.0
|
|
22
|
+
port: 0
|
|
23
|
+
# pathPrefix: "" # 文件路径前缀,拼接在工具收到的路径之前(容器卷映射场景)
|
|
24
|
+
|
|
25
|
+
backend:
|
|
26
|
+
type: cloudagent
|
|
27
|
+
cloudagent:
|
|
28
|
+
apiKey: ${CODEBUDDY_API_KEY}
|
|
29
|
+
endpoint: https://www.codebuddy.cn/v2
|
|
30
|
+
sandbox:
|
|
31
|
+
mode: auto
|
|
32
|
+
# runtimeName: my-bot
|
|
33
|
+
# 复用已有沙箱(下次启动用 manual 模式):
|
|
34
|
+
# mode: manual
|
|
35
|
+
# runtimeId: "xxx"
|
|
36
|
+
# 直连本地 ACP:
|
|
37
|
+
# mode: direct
|
|
38
|
+
# acpEndpoint: http://localhost:65225/acp
|
|
39
|
+
manifest:
|
|
40
|
+
systemPrompt: "你是一个有用的 QQ 机器人助手。用中文回答问题。"
|
|
41
|
+
acp:
|
|
42
|
+
lazyConnect: true
|
|
43
|
+
maxRetries: 20
|
|
44
|
+
retryIntervalMs: 3000
|
|
45
|
+
# 等待 ACP 事件超时(ms),工具调用可能耗时较长
|
|
46
|
+
eventTimeoutMs: 180000
|
|
47
|
+
# 多用户 Session 管理
|
|
48
|
+
session:
|
|
49
|
+
maxConnections: 50 # 单 Runtime 最大连接数
|
|
50
|
+
enableCleanup: false # 是否启用空闲清理
|
|
51
|
+
idleTimeoutMs: 1800000 # 空闲超时(ms),默认 30 分钟
|
|
52
|
+
cleanupIntervalMs: 60000 # 清理扫描间隔(ms),默认 1 分钟
|
|
53
|
+
preserveOnEvict: true # 淘汰时保留服务端会话(下次自动恢复上下文)
|
|
54
|
+
|
|
55
|
+
middleware:
|
|
56
|
+
messageFilter:
|
|
57
|
+
skipSelfEcho: true
|
|
58
|
+
dedup: { windowMs: 5000 }
|
|
59
|
+
contentSanitizer:
|
|
60
|
+
stripBotMention: true
|
|
61
|
+
mentionGate:
|
|
62
|
+
requireMentionInGroup: true
|
|
63
|
+
alwaysAnswerC2C: true
|
|
64
|
+
typingIndicator:
|
|
65
|
+
enabled: true
|
|
66
|
+
durationSec: 30
|
|
67
|
+
# 指令白名单(用户 OpenID),为空则所有人可用
|
|
68
|
+
# slashCommands:
|
|
69
|
+
# allowFrom:
|
|
70
|
+
# - "USER_OPENID"
|
|
71
|
+
# 并发控制:同一用户/群串行处理 strategy: queue | drop | abort | merge
|
|
72
|
+
concurrency:
|
|
73
|
+
strategy: merge
|
|
74
|
+
maxQueue: 50
|
|
75
|
+
|
|
76
|
+
streaming:
|
|
77
|
+
c2c: true
|
|
78
|
+
throttleMs: 500
|
|
79
|
+
|
|
80
|
+
# 消息展示样式 preset: full | compact | minimal | text-only
|
|
81
|
+
message:
|
|
82
|
+
display:
|
|
83
|
+
preset: minimal
|
|
84
|
+
# toolDetailMaxLength: 120
|
|
85
|
+
# toolDetailTruncate: [execute, other]
|
|
86
|
+
# errorMessages:
|
|
87
|
+
# debug: false
|
|
88
|
+
# troubleshootHint: "💡 如持续出现问题,请联系管理员。"
|
|
89
|
+
# rules:
|
|
90
|
+
# - match: ["session not bound", "session not found", "session expired"]
|
|
91
|
+
# reply: "⚠️ 会话已断开,正在重新连接,请稍后再试。"
|
|
92
|
+
# hint: "如反复出现,请发送 /new 重置会话。"
|
|
93
|
+
# - match: ["agent not alive", "connection closed", "transport closed"]
|
|
94
|
+
# reply: "⚠️ 服务连接中断,正在恢复,请稍后再试。"
|
|
95
|
+
# - match: ["timeout", "timed out"]
|
|
96
|
+
# reply: "⚠️ 响应超时,请稍后重试。"
|
|
97
|
+
# - match: ["rate limit", "429"]
|
|
98
|
+
# reply: "⚠️ 请求过于频繁,请稍后再试。"
|
|
99
|
+
# - match: ["context window", "token limit", "max_tokens"]
|
|
100
|
+
# reply: "⚠️ 对话上下文过长,请重新开始新会话。"
|
|
101
|
+
# hint: "发送 /new 开始新对话。"
|
|
102
|
+
# emptyReply: "⚠️ Agent 未生成回复内容,请换个方式描述或重试。"
|
|
103
|
+
# unknown: "⚠️ 处理失败,请稍后重试。"
|
|
104
|
+
|
|
105
|
+
session:
|
|
106
|
+
persistence:
|
|
107
|
+
type: file
|
|
108
|
+
dir: ./.qqbot-data
|
|
109
|
+
|
|
110
|
+
log:
|
|
111
|
+
level: info
|
|
112
|
+
# console: pretty # pretty | json(Docker 建议 json)
|
|
113
|
+
# file:
|
|
114
|
+
# enabled: true
|
|
115
|
+
# dir: ./logs
|
|
116
|
+
# maxSize: 10m
|
|
117
|
+
# maxFiles: 7
|
|
118
|
+
# frequency: daily # daily | hourly | weekly(按时间滚动)
|
|
119
|
+
# dateFormat: yyyy-MM-dd # 文件名日期格式
|
|
120
|
+
# symlink: true # 创建 current.log 指向当前文件
|
|
121
|
+
|
|
122
|
+
# OpenTelemetry 可观测性上报(Traces + Metrics)
|
|
123
|
+
# telemetry:
|
|
124
|
+
# enabled: true
|
|
125
|
+
# serviceName: qqbot-cli
|
|
126
|
+
# endpoint: http://localhost:4318 # OTLP HTTP endpoint
|
|
127
|
+
# protocol: http # http | grpc
|
|
128
|
+
# sampleRate: 1.0 # 采样率 0.0~1.0
|
|
129
|
+
# exportIntervalMs: 30000 # metrics 导出间隔
|
|
130
|
+
# attributes:
|
|
131
|
+
# env: production
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# qqbot-cli 配置模板 — Echo 模式(开发测试用)
|
|
2
|
+
|
|
3
|
+
qq:
|
|
4
|
+
appId: ${QQBOT_APP_ID}
|
|
5
|
+
appSecret: ${QQBOT_APP_SECRET}
|
|
6
|
+
markdown: false
|
|
7
|
+
# baseUrl: https://api.sgroup.qq.com
|
|
8
|
+
# tokenBaseUrl: https://bots.qq.com
|
|
9
|
+
# tokenPrefetch: sync
|
|
10
|
+
# transport: websocket
|
|
11
|
+
# webhook:
|
|
12
|
+
# port: 8080
|
|
13
|
+
# path: /callback
|
|
14
|
+
|
|
15
|
+
backend:
|
|
16
|
+
type: echo
|
|
17
|
+
|
|
18
|
+
middleware:
|
|
19
|
+
messageFilter:
|
|
20
|
+
skipSelfEcho: true
|
|
21
|
+
dedup: { windowMs: 5000 }
|
|
22
|
+
contentSanitizer:
|
|
23
|
+
stripBotMention: true
|
|
24
|
+
mentionGate:
|
|
25
|
+
requireMentionInGroup: true
|
|
26
|
+
alwaysAnswerC2C: true
|
|
27
|
+
typingIndicator:
|
|
28
|
+
enabled: true
|
|
29
|
+
durationSec: 30
|
|
30
|
+
# 并发控制:同一用户/群串行处理 strategy: queue | drop | abort
|
|
31
|
+
concurrency:
|
|
32
|
+
strategy: abort
|
|
33
|
+
maxQueue: 10
|
|
34
|
+
|
|
35
|
+
streaming:
|
|
36
|
+
c2c: true
|
|
37
|
+
throttleMs: 500
|
|
38
|
+
|
|
39
|
+
# 消息展示样式 preset: full | compact | minimal | text-only
|
|
40
|
+
message:
|
|
41
|
+
display:
|
|
42
|
+
preset: minimal
|
|
43
|
+
|
|
44
|
+
session:
|
|
45
|
+
persistence:
|
|
46
|
+
type: memory
|
|
47
|
+
|
|
48
|
+
log:
|
|
49
|
+
level: info
|
|
50
|
+
|
|
51
|
+
# MCP Server:在 qqbot-cli 进程内启动 HTTP+SSE MCP Server
|
|
52
|
+
# 可供外部 Agent 调用已注册的工具(如 send_file)
|
|
53
|
+
# mcp:
|
|
54
|
+
# enabled: true
|
|
55
|
+
# port: 0
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# qqbot-cli 配置模板 — 接入伽利略监控平台
|
|
2
|
+
#
|
|
3
|
+
# 使用前请替换以下变量:
|
|
4
|
+
# - QQBOT_APP_ID / QQBOT_APP_SECRET: QQ Bot 凭证
|
|
5
|
+
# - CODEBUDDY_API_KEY: CloudAgent API Key
|
|
6
|
+
# - galileo.platform / app / server: 伽利略可观测对象标识
|
|
7
|
+
|
|
8
|
+
qq:
|
|
9
|
+
appId: ${QQBOT_APP_ID}
|
|
10
|
+
appSecret: ${QQBOT_APP_SECRET}
|
|
11
|
+
# tokenPrefetch: sync
|
|
12
|
+
|
|
13
|
+
backend:
|
|
14
|
+
type: cloudagent
|
|
15
|
+
cloudagent:
|
|
16
|
+
apiKey: ${CODEBUDDY_API_KEY}
|
|
17
|
+
endpoint: https://www.codebuddy.cn/v2
|
|
18
|
+
sandbox:
|
|
19
|
+
mode: auto
|
|
20
|
+
|
|
21
|
+
middleware:
|
|
22
|
+
mentionGate:
|
|
23
|
+
requireMentionInGroup: true
|
|
24
|
+
alwaysAnswerC2C: true
|
|
25
|
+
concurrency:
|
|
26
|
+
strategy: merge
|
|
27
|
+
maxQueue: 50
|
|
28
|
+
|
|
29
|
+
streaming:
|
|
30
|
+
c2c: true
|
|
31
|
+
throttleMs: 500
|
|
32
|
+
|
|
33
|
+
message:
|
|
34
|
+
display:
|
|
35
|
+
preset: minimal
|
|
36
|
+
|
|
37
|
+
log:
|
|
38
|
+
level: info
|
|
39
|
+
console: json
|
|
40
|
+
file:
|
|
41
|
+
enabled: true
|
|
42
|
+
dir: ./logs
|
|
43
|
+
maxSize: 10m
|
|
44
|
+
maxFiles: 7
|
|
45
|
+
frequency: daily
|
|
46
|
+
dateFormat: yyyy-MM-dd
|
|
47
|
+
symlink: true
|
|
48
|
+
|
|
49
|
+
# 伽利略监控平台上报配置
|
|
50
|
+
telemetry:
|
|
51
|
+
enabled: true
|
|
52
|
+
endpoint: http://localhost:4318
|
|
53
|
+
protocol: http
|
|
54
|
+
sampleRate: 1.0
|
|
55
|
+
exportIntervalMs: 10000
|
|
56
|
+
galileo:
|
|
57
|
+
platform: YOUR_PLATFORM # 平台标识
|
|
58
|
+
app: qqbot # 应用名
|
|
59
|
+
server: qqbot-cli # 服务名(最终 target = platform.app.server)
|
|
60
|
+
namespace: Production # 命名空间:Production / Development
|
|
61
|
+
envName: formal # 环境:formal / test
|
|
62
|
+
attributes:
|
|
63
|
+
env: production
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# qqbot-cli 配置模板 — OpenAI 兼容 API 模式
|
|
2
|
+
|
|
3
|
+
qq:
|
|
4
|
+
appId: ${QQBOT_APP_ID}
|
|
5
|
+
appSecret: ${QQBOT_APP_SECRET}
|
|
6
|
+
markdown: false
|
|
7
|
+
# baseUrl: https://api.sgroup.qq.com
|
|
8
|
+
# tokenBaseUrl: https://bots.qq.com
|
|
9
|
+
# tokenPrefetch: sync
|
|
10
|
+
# transport: websocket
|
|
11
|
+
# webhook:
|
|
12
|
+
# port: 8080
|
|
13
|
+
# path: /callback
|
|
14
|
+
|
|
15
|
+
backend:
|
|
16
|
+
type: openai
|
|
17
|
+
openai:
|
|
18
|
+
apiKey: ${OPENAI_API_KEY}
|
|
19
|
+
baseUrl: https://api.openai.com/v1
|
|
20
|
+
model: gpt-4o
|
|
21
|
+
systemPrompt: "你是一个 QQ 机器人助手。用中文简洁回答。"
|
|
22
|
+
maxTokens: 2048
|
|
23
|
+
temperature: 0.7
|
|
24
|
+
|
|
25
|
+
middleware:
|
|
26
|
+
messageFilter:
|
|
27
|
+
skipSelfEcho: true
|
|
28
|
+
dedup: { windowMs: 5000 }
|
|
29
|
+
contentSanitizer:
|
|
30
|
+
stripBotMention: true
|
|
31
|
+
mentionGate:
|
|
32
|
+
requireMentionInGroup: true
|
|
33
|
+
alwaysAnswerC2C: true
|
|
34
|
+
typingIndicator:
|
|
35
|
+
enabled: true
|
|
36
|
+
durationSec: 30
|
|
37
|
+
# 并发控制:同一用户/群串行处理 strategy: queue | drop | abort
|
|
38
|
+
concurrency:
|
|
39
|
+
strategy: abort
|
|
40
|
+
maxQueue: 10
|
|
41
|
+
|
|
42
|
+
streaming:
|
|
43
|
+
c2c: true
|
|
44
|
+
throttleMs: 500
|
|
45
|
+
|
|
46
|
+
# 消息展示样式 preset: full | compact | minimal | text-only
|
|
47
|
+
message:
|
|
48
|
+
display:
|
|
49
|
+
preset: minimal
|
|
50
|
+
|
|
51
|
+
session:
|
|
52
|
+
persistence:
|
|
53
|
+
type: file
|
|
54
|
+
dir: ./.qqbot-data
|
|
55
|
+
|
|
56
|
+
log:
|
|
57
|
+
level: info
|
|
58
|
+
|
|
59
|
+
# MCP Server:在 qqbot-cli 进程内启动 HTTP+SSE MCP Server
|
|
60
|
+
# 可供外部 Agent 调用已注册的工具(如 send_file)
|
|
61
|
+
# mcp:
|
|
62
|
+
# enabled: true
|
|
63
|
+
# port: 0
|