@linjz/opencode-qqbot 0.3.15 → 0.3.16
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 +42 -5
- package/bin/openqq.js +13 -0
- package/dist/notify-cli.js +28 -14
- package/dist/opencode-qqbot-plugin.js +934 -64
- package/dist/openqq-bot.js +3095 -677
- package/dist/openqq-cli.js +791 -0
- package/dist/openqq-watchdog.js +1063 -0
- package/package.json +8 -5
- package/src/bridge.ts +1310 -150
- package/src/cli/notify.ts +167 -158
- package/src/cli/openqq-main.ts +95 -0
- package/src/cli/service-main.ts +302 -0
- package/src/cli/watchdog-main.ts +77 -0
- package/src/commands.ts +644 -554
- package/src/config.ts +85 -0
- package/src/core/bot-control.ts +148 -0
- package/src/core/bot-launcher.ts +106 -13
- package/src/core/card-approval.ts +20 -9
- package/src/core/delivery.ts +145 -54
- package/src/core/discovery.ts +22 -4
- package/src/core/file-log.ts +35 -3
- package/src/core/form-bridge.ts +14 -5
- package/src/core/form-journal.ts +4 -4
- package/src/core/gateway-state.ts +3 -3
- package/src/core/inflight-journal.ts +214 -36
- package/src/core/instance-lock.ts +10 -2
- package/src/core/linkwatch.ts +3 -4
- package/src/core/markdown.ts +117 -0
- package/src/core/message-queue.ts +242 -91
- package/src/core/mirror.ts +222 -182
- package/src/core/notify-sink.ts +93 -96
- package/src/core/outbox.ts +10 -9
- package/src/core/permission.ts +627 -303
- package/src/core/question-form.ts +230 -0
- package/src/core/queue-view.ts +661 -0
- package/src/core/send-media.ts +32 -0
- package/src/core/storage.ts +34 -0
- package/src/core/watchdog.ts +513 -0
- package/src/core/zombie-reaper.ts +127 -0
- package/src/index.ts +140 -52
- package/src/opencode/client.ts +206 -27
- package/src/opencode/eventstream.ts +94 -12
- package/src/opencode/history.ts +4 -2
- package/src/opencode/mirror.ts +15 -2
- package/src/opencode/sessions.ts +135 -37
- package/src/plugin-entry.ts +120 -115
- package/src/qq/api.ts +165 -61
- package/src/qq/gateway.ts +79 -16
- package/src/qq/sender.ts +30 -18
- package/src/qq/types.ts +7 -0
package/src/cli/notify.ts
CHANGED
|
@@ -1,158 +1,167 @@
|
|
|
1
|
-
// @input: node:fs/homedir/join、../config(ENV_FILE/loadEnvFile)、../qq/api(getAccessToken 校准用不入队)、./outbox.ts、../core/notify-sink.ts(resolveNotifyRecipients/defaultOutboxPath)
|
|
2
|
-
// @output: runNotifyCli(argv)(供 bin/openqq.js 与测试调用),只入队不发送。
|
|
3
|
-
// @pos: cli - openqq notify 外部入队通道(feature:headless 定时任务结果推送)。
|
|
4
|
-
// BOT(notify-sink)进程消费投递;CLI 不取 token、不连 OpenCode、不抢实例锁。
|
|
5
|
-
// @note: 设计文档:Desktop `opencode-qqbot-feature-request.md` Part 1;
|
|
6
|
-
// 收件人 fail-closed:缺省取 ALLOWED_USERS 唯一项;显式 --user 必须命中名单。
|
|
7
|
-
import { existsSync, readFileSync } from "node:fs"
|
|
8
|
-
import { createOutbox } from "../core/outbox.js"
|
|
9
|
-
import { ENV_FILE, loadEnvFile } from "../config.js"
|
|
10
|
-
import { defaultOutboxPath, resolveNotifyRecipients } from "../core/notify-sink.js"
|
|
11
|
-
|
|
12
|
-
export interface NotifyCliOptions {
|
|
13
|
-
filePath?: string
|
|
14
|
-
now?: number
|
|
15
|
-
env?: { allowedUsers: readonly string[] }
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** CLI 结果(--json 输出同 shape;dry-run 时 queued=false 并附 wouldEnqueue)。 */
|
|
19
|
-
export interface NotifyCliResult {
|
|
20
|
-
ok: boolean
|
|
21
|
-
queued: boolean
|
|
22
|
-
id: string
|
|
23
|
-
user: string
|
|
24
|
-
chars: number
|
|
25
|
-
truncated: boolean
|
|
26
|
-
dryRun: boolean
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
case "--
|
|
54
|
-
case "--
|
|
55
|
-
case "--
|
|
56
|
-
case "--
|
|
57
|
-
case "--
|
|
58
|
-
case "--
|
|
59
|
-
case "--
|
|
60
|
-
case "--
|
|
61
|
-
case "--
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (parsed.
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return ""
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
" --
|
|
103
|
-
" --
|
|
104
|
-
" --
|
|
105
|
-
" --
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
1
|
+
// @input: node:fs/homedir/join、../config(ENV_FILE/loadEnvFile)、../qq/api(getAccessToken 校准用不入队)、./outbox.ts、../core/notify-sink.ts(resolveNotifyRecipients/defaultOutboxPath)
|
|
2
|
+
// @output: runNotifyCli(argv)(供 bin/openqq.js 与测试调用),只入队不发送。
|
|
3
|
+
// @pos: cli - openqq notify 外部入队通道(feature:headless 定时任务结果推送)。
|
|
4
|
+
// BOT(notify-sink)进程消费投递;CLI 不取 token、不连 OpenCode、不抢实例锁。
|
|
5
|
+
// @note: 设计文档:Desktop `opencode-qqbot-feature-request.md` Part 1;
|
|
6
|
+
// 收件人 fail-closed:缺省取 ALLOWED_USERS 唯一项;显式 --user 必须命中名单。
|
|
7
|
+
import { existsSync, readFileSync } from "node:fs"
|
|
8
|
+
import { createOutbox } from "../core/outbox.js"
|
|
9
|
+
import { ENV_FILE, loadEnvFile } from "../config.js"
|
|
10
|
+
import { defaultOutboxPath, resolveNotifyRecipients } from "../core/notify-sink.js"
|
|
11
|
+
|
|
12
|
+
export interface NotifyCliOptions {
|
|
13
|
+
filePath?: string
|
|
14
|
+
now?: number
|
|
15
|
+
env?: { allowedUsers: readonly string[] }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** CLI 结果(--json 输出同 shape;dry-run 时 queued=false 并附 wouldEnqueue)。 */
|
|
19
|
+
export interface NotifyCliResult {
|
|
20
|
+
ok: boolean
|
|
21
|
+
queued: boolean
|
|
22
|
+
id: string
|
|
23
|
+
user: string
|
|
24
|
+
chars: number
|
|
25
|
+
truncated: boolean
|
|
26
|
+
dryRun: boolean
|
|
27
|
+
json: boolean
|
|
28
|
+
reason?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** 保守截断:默认 1500 字(主动消息日配额 100/天——长输出拆几十条会吃光);0=不截断。 */
|
|
32
|
+
export const NOTIFY_DEFAULT_MAX_CHARS = 1500
|
|
33
|
+
|
|
34
|
+
interface ParsedArgs {
|
|
35
|
+
text?: string
|
|
36
|
+
filePath?: string
|
|
37
|
+
stdin?: boolean
|
|
38
|
+
user?: string
|
|
39
|
+
id?: string
|
|
40
|
+
maxChars: number
|
|
41
|
+
ttlHours?: number
|
|
42
|
+
dryRun: boolean
|
|
43
|
+
json: boolean
|
|
44
|
+
help: boolean
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function parseArgs(argv: readonly string[]): ParsedArgs {
|
|
48
|
+
const parsed: ParsedArgs = { maxChars: NOTIFY_DEFAULT_MAX_CHARS, dryRun: false, json: false, help: false }
|
|
49
|
+
for (let i = 0; i < argv.length; i++) {
|
|
50
|
+
const a = argv[i]
|
|
51
|
+
const next = argv[i + 1]
|
|
52
|
+
switch (a) {
|
|
53
|
+
case "--text": parsed.text = next; i++; break
|
|
54
|
+
case "--file": parsed.filePath = next; i++; break
|
|
55
|
+
case "--stdin": parsed.stdin = true; break
|
|
56
|
+
case "--user": parsed.user = next; i++; break
|
|
57
|
+
case "--id": parsed.id = next; i++; break
|
|
58
|
+
case "--max-chars": parsed.maxChars = Number(next); i++; break
|
|
59
|
+
case "--ttl-hours": parsed.ttlHours = Number(next); i++; break
|
|
60
|
+
case "--dry-run": parsed.dryRun = true; break
|
|
61
|
+
case "--json": parsed.json = true; break
|
|
62
|
+
case "--help": case "-h": parsed.help = true; i++; break
|
|
63
|
+
default:
|
|
64
|
+
throw new Error(`未知参数:${a}(用法:openqq notify --text "…" | --file <p> | --stdin)`)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!parsed.help && !parsed.text && !parsed.filePath && !parsed.stdin) {
|
|
68
|
+
throw new Error("必须提供正文来源:--text / --file / --stdin 三选一")
|
|
69
|
+
}
|
|
70
|
+
if (!Number.isFinite(parsed.maxChars) || parsed.maxChars < 0) {
|
|
71
|
+
throw new Error("--max-chars 必须是 >= 0 的有限数(0=不截断)")
|
|
72
|
+
}
|
|
73
|
+
return parsed
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** 收件人 fail-closed:显式 --user 必须命中名单;缺省仅取 ALLOWED_USERS 唯一项。 */
|
|
77
|
+
export function resolveUser(envAllowed: readonly string[], explicit?: string): string {
|
|
78
|
+
return resolveNotifyRecipients(envAllowed, explicit)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** 正文来源:--text / --file / --stdin;--file - 读 stdin(同步可读)。 */
|
|
82
|
+
function readBody(parsed: ParsedArgs): string {
|
|
83
|
+
if (parsed.text !== undefined) return parsed.text
|
|
84
|
+
if (parsed.filePath !== undefined) {
|
|
85
|
+
if (parsed.filePath === "-") return readFileSync(0 as unknown as number, "utf8")
|
|
86
|
+
if (!existsSync(parsed.filePath)) throw new Error(`--file 不存在:${parsed.filePath}`)
|
|
87
|
+
return readFileSync(parsed.filePath, "utf8")
|
|
88
|
+
}
|
|
89
|
+
if (parsed.stdin) return readFileSync(0 as unknown as number, "utf8")
|
|
90
|
+
return ""
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function runNotifyCli(
|
|
94
|
+
argv: readonly string[],
|
|
95
|
+
options: NotifyCliOptions = {},
|
|
96
|
+
): Promise<NotifyCliResult> {
|
|
97
|
+
const now = options.now ?? Date.now()
|
|
98
|
+
const parsed = parseArgs(argv)
|
|
99
|
+
if (parsed.help) {
|
|
100
|
+
const help = [
|
|
101
|
+
"用法:openqq notify --text \"…\" | --file <路径> | --stdin",
|
|
102
|
+
" --user <openid> 收件人;缺省取 ALLOWED_USERS 唯一项(多用户必须显式指定)",
|
|
103
|
+
" --id <key> 幂等键(同 key 不重复投递)",
|
|
104
|
+
" --max-chars <n> 截断上限,默认 1500,0 不截断",
|
|
105
|
+
" --ttl-hours <n> 队列等待上限,默认 24(env QQ_NOTIFY_TTL_HOURS 兜底)",
|
|
106
|
+
" --dry-run / --json 不入队 / 机器可读输出",
|
|
107
|
+
].join("\n")
|
|
108
|
+
console.log(help)
|
|
109
|
+
return { ok: true, queued: false, id: "", user: "", chars: 0, truncated: false, dryRun: true, json: parsed.json, reason: "help" }
|
|
110
|
+
}
|
|
111
|
+
// .env 注入:bot 进程入口已做;CLI 独立进程需自行加载(ALLOWED_USERS/凭据同源单点)
|
|
112
|
+
if (!options.env && existsSync(ENV_FILE)) loadEnvFile(ENV_FILE)
|
|
113
|
+
const allowedUsers = options.env ? [...options.env.allowedUsers] : String(process.env.ALLOWED_USERS ?? "")
|
|
114
|
+
.split(/[,\s]+/).filter(Boolean)
|
|
115
|
+
const user = resolveUser(allowedUsers, parsed.user)
|
|
116
|
+
if (!user) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
allowedUsers.length === 0
|
|
119
|
+
? "ALLOWED_USERS 为空——fail-closed 不允许无名单入队(先在 ~/.openqq/.env 配置)"
|
|
120
|
+
: parsed.user
|
|
121
|
+
? `收件人不在名单:${parsed.user}(ALLOWED_USERS 共 ${allowedUsers.length} 项,--user 必须精确命中;请核对 openid)`
|
|
122
|
+
: "多用户名单必须用 --user <openid> 显式指定收件人",
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
const raw = readBody(parsed)
|
|
126
|
+
const max = parsed.maxChars
|
|
127
|
+
const content = max === 0 ? raw : raw.length > max ? `${raw.slice(0, max)}…` : raw
|
|
128
|
+
const id = parsed.id || `notify-${now.toString(36)}-${Math.random().toString(36).slice(2, 8)}`
|
|
129
|
+
const filePath = options.filePath ?? defaultOutboxPath()
|
|
130
|
+
if (parsed.dryRun) {
|
|
131
|
+
return { ok: true, queued: false, id, user, chars: content.length, truncated: content.length !== raw.length, dryRun: true, json: parsed.json }
|
|
132
|
+
}
|
|
133
|
+
const ttlHours =
|
|
134
|
+
parsed.ttlHours ?? Number(process.env.QQ_NOTIFY_TTL_HOURS ?? 24)
|
|
135
|
+
const nextAttemptAt = parsed.ttlHours !== undefined && Number.isFinite(ttlHours) && ttlHours > 0
|
|
136
|
+
? now + ttlHours * 60 * 60 * 1000
|
|
137
|
+
: now
|
|
138
|
+
const outbox = createOutbox({ filePath, pollIntervalMs: 0 })
|
|
139
|
+
const entry = await outbox.enqueue({
|
|
140
|
+
...(parsed.id ? { id: parsed.id } : {}),
|
|
141
|
+
kind: "notify",
|
|
142
|
+
payload: { text: content },
|
|
143
|
+
ctx: { type: "c2c", userId: user, msgId: "", content: "(openqq notify)", timestamp: String(now) },
|
|
144
|
+
sessionId: "",
|
|
145
|
+
nextAttemptAt,
|
|
146
|
+
})
|
|
147
|
+
return { ok: true, queued: true, id: entry.id, user, chars: content.length, truncated: content.length !== raw.length, dryRun: false, json: parsed.json }
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** bin/openqq.js 入口:返回进程退出码(0=已入队;1=参数/配置错误)。 */
|
|
151
|
+
export async function main(argv: readonly string[]): Promise<number> {
|
|
152
|
+
try {
|
|
153
|
+
const result = await runNotifyCli(argv)
|
|
154
|
+
if (result.reason === "help") return 0
|
|
155
|
+
if (result.json) {
|
|
156
|
+
console.log(JSON.stringify(result))
|
|
157
|
+
} else if (result.queued && !result.dryRun) {
|
|
158
|
+
console.log(`[notify] 已入队 id=${result.id} user=${result.user} chars=${result.chars}${result.truncated ? "(已截断)" : ""}`)
|
|
159
|
+
} else if (result.dryRun) {
|
|
160
|
+
console.log(`[notify] dry-run:将入队 user=${result.user} chars=${result.chars}${result.truncated ? "(已截断)" : ""}`)
|
|
161
|
+
}
|
|
162
|
+
return result.ok ? 0 : 1
|
|
163
|
+
} catch (error) {
|
|
164
|
+
console.error(`[notify] 入队失败:${error instanceof Error ? error.message : String(error)}`)
|
|
165
|
+
return 1
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @input: argv(restart | service ...)、core/bot-control、cli/service-main
|
|
2
|
+
// @output: (side-effect) 重启/自启注册/状态查询
|
|
3
|
+
// @pos: cli - 运维命令入口(dist/openqq-cli.js)
|
|
4
|
+
//
|
|
5
|
+
// 用法:
|
|
6
|
+
// node dist/openqq-cli.js restart [--force] [--timeout-min 60]
|
|
7
|
+
// node dist/openqq-cli.js service install|uninstall|status
|
|
8
|
+
// 2026-11-09 架构红线:取代 safe-restart.ps1 / start-openqq.ps1 / watchdog.ps1,全 TS 跨平台。
|
|
9
|
+
import { existsSync } from "fs"
|
|
10
|
+
import { dirname, join } from "path"
|
|
11
|
+
import { fileURLToPath } from "url"
|
|
12
|
+
import { restartBot } from "../core/bot-control.js"
|
|
13
|
+
import {
|
|
14
|
+
serviceInstall,
|
|
15
|
+
serviceStatus,
|
|
16
|
+
serviceUninstall,
|
|
17
|
+
type CommandResult,
|
|
18
|
+
type ServiceSpec,
|
|
19
|
+
} from "./service-main.js"
|
|
20
|
+
import { resolveBunCommand, locateOnPath, resolveRuntime } from "../core/bot-launcher.js"
|
|
21
|
+
|
|
22
|
+
const DEFAULT_INTERVAL_MIN = 10
|
|
23
|
+
|
|
24
|
+
function sibling(name: string): string {
|
|
25
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
26
|
+
const candidates = [join(here, name), join(here, "..", "dist", name)]
|
|
27
|
+
return candidates.find((p) => existsSync(p)) ?? candidates[0]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function runtimeCommand(): string {
|
|
31
|
+
const runtime = resolveRuntime()
|
|
32
|
+
if (runtime === "bun") return resolveBunCommand() ?? throwNoRuntime("bun")
|
|
33
|
+
if (runtime === "node") return locateOnPath("node") ?? throwNoRuntime("node")
|
|
34
|
+
throw new Error("未找到 bun/node 运行时")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function throwNoRuntime(kind: string): never {
|
|
38
|
+
throw new Error(`未找到 ${kind} 全路径可执行体——注册动作需要全路径命令(静默红线)`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function printResult(label: string, r: CommandResult): void {
|
|
42
|
+
console.log(`[${label}] ${r.ok ? "OK" : "FAIL"}\n${r.detail}`)
|
|
43
|
+
process.exitCode = r.ok ? 0 : 1
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function parseFlag(argv: string[], name: string): string | null {
|
|
47
|
+
const i = argv.indexOf(name)
|
|
48
|
+
return i >= 0 ? (argv[i + 1] ?? "") : null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function main(): Promise<void> {
|
|
52
|
+
const [cmd, sub] = process.argv.slice(2)
|
|
53
|
+
|
|
54
|
+
if (cmd === "restart") {
|
|
55
|
+
const force = process.argv.includes("--force")
|
|
56
|
+
const timeoutMin = Number(parseFlag(process.argv.slice(2), "--timeout-min"))
|
|
57
|
+
const res = await restartBot({
|
|
58
|
+
force,
|
|
59
|
+
timeoutMs: Number.isFinite(timeoutMin) && timeoutMin > 0 ? timeoutMin * 60_000 : undefined,
|
|
60
|
+
spawnFromUrl: import.meta.url,
|
|
61
|
+
log: (line) => console.log(line),
|
|
62
|
+
})
|
|
63
|
+
console.log(`[restart] ${res.action}(${res.reason})killed=${res.killedPid ?? "-"} spawned=${res.spawnedPid ?? "-"}`)
|
|
64
|
+
process.exitCode = res.action === "restarted" ? 0 : 2
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (cmd === "service") {
|
|
69
|
+
const spec: ServiceSpec = {
|
|
70
|
+
runtimeCmd: runtimeCommand(),
|
|
71
|
+
scriptPath: sibling("openqq-watchdog.js"),
|
|
72
|
+
intervalMin: DEFAULT_INTERVAL_MIN,
|
|
73
|
+
}
|
|
74
|
+
if (sub === "install") return printResult("service install", serviceInstall(spec))
|
|
75
|
+
if (sub === "uninstall") return printResult("service uninstall", serviceUninstall())
|
|
76
|
+
if (sub === "status") {
|
|
77
|
+
const r = serviceStatus()
|
|
78
|
+
return printResult("service status", {
|
|
79
|
+
ok: r.ok,
|
|
80
|
+
detail: `runtime=${spec.runtimeCmd}\nscript=${spec.scriptPath}\n${r.detail}`,
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
console.error("用法:openqq service install|uninstall|status")
|
|
84
|
+
process.exitCode = 2
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
console.error("用法:openqq-cli restart [--force] [--timeout-min N] | service install|uninstall|status")
|
|
89
|
+
process.exitCode = 2
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
void main().catch((error) => {
|
|
93
|
+
console.error("[openqq-cli] 执行失败:", error instanceof Error ? error.message : error)
|
|
94
|
+
process.exit(1)
|
|
95
|
+
})
|