engine7 7.1.42 → 7.1.43
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/dist/cli.mjs +258 -140
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -14,6 +14,130 @@ var __export = (target, all) => {
|
|
|
14
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// src/feishu-quick-register.ts
|
|
18
|
+
var feishu_quick_register_exports = {};
|
|
19
|
+
__export(feishu_quick_register_exports, {
|
|
20
|
+
registerFeishuApp: () => registerFeishuApp
|
|
21
|
+
});
|
|
22
|
+
async function postRegistration(domain, body) {
|
|
23
|
+
const url = `${ACCOUNTS_URL[domain]}${REGISTRATION_PATH}`;
|
|
24
|
+
const res = await fetch(url, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
27
|
+
body: new URLSearchParams(body).toString(),
|
|
28
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
29
|
+
});
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
throw new Error(`\u98DE\u4E66\u6CE8\u518C\u63A5\u53E3\u8FD4\u56DE ${res.status}: ${await res.text()}`);
|
|
32
|
+
}
|
|
33
|
+
return res.json();
|
|
34
|
+
}
|
|
35
|
+
async function initRegistration(domain) {
|
|
36
|
+
const res = await postRegistration(domain, { action: "init" });
|
|
37
|
+
if (!res.supported_auth_methods?.includes("client_secret")) {
|
|
38
|
+
throw new Error("\u5F53\u524D\u98DE\u4E66\u73AF\u5883\u4E0D\u652F\u6301 client_secret \u8BA4\u8BC1\uFF0C\u65E0\u6CD5\u81EA\u52A8\u6CE8\u518C");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function beginRegistration(domain) {
|
|
42
|
+
const res = await postRegistration(domain, {
|
|
43
|
+
action: "begin",
|
|
44
|
+
archetype: "PersonalAgent",
|
|
45
|
+
auth_method: "client_secret",
|
|
46
|
+
request_user_info: "open_id"
|
|
47
|
+
});
|
|
48
|
+
if (!res.device_code || !res.verification_uri_complete) {
|
|
49
|
+
throw new Error(`\u98DE\u4E66\u6CE8\u518C\u5931\u8D25: \u672A\u8FD4\u56DE device_code
|
|
50
|
+
${JSON.stringify(res)}`);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
deviceCode: res.device_code,
|
|
54
|
+
qrUrl: res.verification_uri_complete,
|
|
55
|
+
userCode: res.user_code,
|
|
56
|
+
interval: res.interval ?? DEFAULT_POLL_INTERVAL,
|
|
57
|
+
expireIn: res.expire_in ?? 300
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function pollRegistration(domain, deviceCode, interval, deadline, onLog, signal) {
|
|
61
|
+
let currentInterval = interval;
|
|
62
|
+
let currentDomain = domain;
|
|
63
|
+
while (Date.now() < deadline) {
|
|
64
|
+
if (signal?.aborted) return null;
|
|
65
|
+
let res;
|
|
66
|
+
try {
|
|
67
|
+
res = await postRegistration(currentDomain, {
|
|
68
|
+
action: "poll",
|
|
69
|
+
device_code: deviceCode
|
|
70
|
+
});
|
|
71
|
+
} catch {
|
|
72
|
+
await sleep(currentInterval * 1e3);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (res.user_info?.tenant_brand === "lark" && currentDomain === "feishu") {
|
|
76
|
+
currentDomain = "lark";
|
|
77
|
+
onLog?.("\u68C0\u6D4B\u5230 Lark \u8D26\u53F7\uFF0C\u5207\u6362\u57DF\u540D...");
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (res.client_id && res.client_secret) {
|
|
81
|
+
return {
|
|
82
|
+
appId: res.client_id,
|
|
83
|
+
appSecret: res.client_secret,
|
|
84
|
+
openId: res.user_info?.open_id,
|
|
85
|
+
domain: currentDomain
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (res.error) {
|
|
89
|
+
if (res.error === "authorization_pending") {
|
|
90
|
+
} else if (res.error === "slow_down") {
|
|
91
|
+
currentInterval += 5;
|
|
92
|
+
} else if (res.error === "access_denied") {
|
|
93
|
+
throw new Error("\u7528\u6237\u62D2\u7EDD\u4E86\u6388\u6743");
|
|
94
|
+
} else if (res.error === "expired_token") {
|
|
95
|
+
throw new Error("\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F");
|
|
96
|
+
} else {
|
|
97
|
+
throw new Error(`\u98DE\u4E66\u6CE8\u518C\u9519\u8BEF: ${res.error} \u2014 ${res.error_description ?? ""}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
await sleep(currentInterval * 1e3);
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
async function registerFeishuApp(options = {}) {
|
|
105
|
+
const domain = options.domain ?? "feishu";
|
|
106
|
+
const timeoutSec = options.timeoutSec ?? 300;
|
|
107
|
+
const log = options.onLog ?? (() => {
|
|
108
|
+
});
|
|
109
|
+
log("\u68C0\u67E5\u98DE\u4E66\u73AF\u5883...");
|
|
110
|
+
await initRegistration(domain);
|
|
111
|
+
log("\u751F\u6210\u4E8C\u7EF4\u7801...");
|
|
112
|
+
const { deviceCode, qrUrl, interval, expireIn } = await beginRegistration(domain);
|
|
113
|
+
options.onQrCode?.(qrUrl);
|
|
114
|
+
log(`\u8BF7\u7528\u98DE\u4E66 App \u626B\u63CF\u4E8C\u7EF4\u7801\uFF08${expireIn}\u79D2\u540E\u8FC7\u671F\uFF09...`);
|
|
115
|
+
const deadline = Date.now() + Math.min(expireIn, timeoutSec) * 1e3;
|
|
116
|
+
const result = await pollRegistration(domain, deviceCode, interval, deadline, log, options.signal);
|
|
117
|
+
if (result) {
|
|
118
|
+
log(`\u2705 \u6CE8\u518C\u6210\u529F\uFF01App ID: ${result.appId}`);
|
|
119
|
+
} else {
|
|
120
|
+
log("\u23F0 \u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F");
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
function sleep(ms) {
|
|
125
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
126
|
+
}
|
|
127
|
+
var ACCOUNTS_URL, REGISTRATION_PATH, REQUEST_TIMEOUT_MS, DEFAULT_POLL_INTERVAL;
|
|
128
|
+
var init_feishu_quick_register = __esm({
|
|
129
|
+
"src/feishu-quick-register.ts"() {
|
|
130
|
+
"use strict";
|
|
131
|
+
ACCOUNTS_URL = {
|
|
132
|
+
feishu: "https://accounts.feishu.cn",
|
|
133
|
+
lark: "https://accounts.larksuite.com"
|
|
134
|
+
};
|
|
135
|
+
REGISTRATION_PATH = "/oauth/v1/app/registration";
|
|
136
|
+
REQUEST_TIMEOUT_MS = 1e4;
|
|
137
|
+
DEFAULT_POLL_INTERVAL = 5;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
17
141
|
// src/channels/wechat.ts
|
|
18
142
|
var wechat_exports = {};
|
|
19
143
|
__export(wechat_exports, {
|
|
@@ -959,6 +1083,32 @@ var init_wechat = __esm({
|
|
|
959
1083
|
}
|
|
960
1084
|
});
|
|
961
1085
|
|
|
1086
|
+
// src/qr-render.ts
|
|
1087
|
+
var qr_render_exports = {};
|
|
1088
|
+
__export(qr_render_exports, {
|
|
1089
|
+
renderQrTerminal: () => renderQrTerminal
|
|
1090
|
+
});
|
|
1091
|
+
import { createRequire } from "node:module";
|
|
1092
|
+
async function renderQrTerminal(url, options) {
|
|
1093
|
+
return new Promise((resolve2, reject) => {
|
|
1094
|
+
try {
|
|
1095
|
+
const qt = require2("qrcode-terminal");
|
|
1096
|
+
qt.generate(url, { small: options?.small ?? true }, (output) => {
|
|
1097
|
+
resolve2(output);
|
|
1098
|
+
});
|
|
1099
|
+
} catch (err) {
|
|
1100
|
+
reject(err);
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
var require2;
|
|
1105
|
+
var init_qr_render = __esm({
|
|
1106
|
+
"src/qr-render.ts"() {
|
|
1107
|
+
"use strict";
|
|
1108
|
+
require2 = createRequire(import.meta.url);
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
|
|
962
1112
|
// src/cli-travel.ts
|
|
963
1113
|
var cli_travel_exports = {};
|
|
964
1114
|
__export(cli_travel_exports, {
|
|
@@ -1569,145 +1719,13 @@ var init_cli_travel = __esm({
|
|
|
1569
1719
|
});
|
|
1570
1720
|
|
|
1571
1721
|
// src/cli-init.ts
|
|
1722
|
+
init_feishu_quick_register();
|
|
1723
|
+
init_wechat();
|
|
1724
|
+
init_qr_render();
|
|
1572
1725
|
import * as path3 from "node:path";
|
|
1573
1726
|
import * as fs3 from "node:fs";
|
|
1574
1727
|
import * as readline from "node:readline";
|
|
1575
1728
|
import { fileURLToPath } from "node:url";
|
|
1576
|
-
|
|
1577
|
-
// src/feishu-quick-register.ts
|
|
1578
|
-
var ACCOUNTS_URL = {
|
|
1579
|
-
feishu: "https://accounts.feishu.cn",
|
|
1580
|
-
lark: "https://accounts.larksuite.com"
|
|
1581
|
-
};
|
|
1582
|
-
var REGISTRATION_PATH = "/oauth/v1/app/registration";
|
|
1583
|
-
var REQUEST_TIMEOUT_MS = 1e4;
|
|
1584
|
-
var DEFAULT_POLL_INTERVAL = 5;
|
|
1585
|
-
async function postRegistration(domain, body) {
|
|
1586
|
-
const url = `${ACCOUNTS_URL[domain]}${REGISTRATION_PATH}`;
|
|
1587
|
-
const res = await fetch(url, {
|
|
1588
|
-
method: "POST",
|
|
1589
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1590
|
-
body: new URLSearchParams(body).toString(),
|
|
1591
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
1592
|
-
});
|
|
1593
|
-
if (!res.ok) {
|
|
1594
|
-
throw new Error(`\u98DE\u4E66\u6CE8\u518C\u63A5\u53E3\u8FD4\u56DE ${res.status}: ${await res.text()}`);
|
|
1595
|
-
}
|
|
1596
|
-
return res.json();
|
|
1597
|
-
}
|
|
1598
|
-
async function initRegistration(domain) {
|
|
1599
|
-
const res = await postRegistration(domain, { action: "init" });
|
|
1600
|
-
if (!res.supported_auth_methods?.includes("client_secret")) {
|
|
1601
|
-
throw new Error("\u5F53\u524D\u98DE\u4E66\u73AF\u5883\u4E0D\u652F\u6301 client_secret \u8BA4\u8BC1\uFF0C\u65E0\u6CD5\u81EA\u52A8\u6CE8\u518C");
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1604
|
-
async function beginRegistration(domain) {
|
|
1605
|
-
const res = await postRegistration(domain, {
|
|
1606
|
-
action: "begin",
|
|
1607
|
-
archetype: "PersonalAgent",
|
|
1608
|
-
auth_method: "client_secret",
|
|
1609
|
-
request_user_info: "open_id"
|
|
1610
|
-
});
|
|
1611
|
-
if (!res.device_code || !res.verification_uri_complete) {
|
|
1612
|
-
throw new Error(`\u98DE\u4E66\u6CE8\u518C\u5931\u8D25: \u672A\u8FD4\u56DE device_code
|
|
1613
|
-
${JSON.stringify(res)}`);
|
|
1614
|
-
}
|
|
1615
|
-
return {
|
|
1616
|
-
deviceCode: res.device_code,
|
|
1617
|
-
qrUrl: res.verification_uri_complete,
|
|
1618
|
-
userCode: res.user_code,
|
|
1619
|
-
interval: res.interval ?? DEFAULT_POLL_INTERVAL,
|
|
1620
|
-
expireIn: res.expire_in ?? 300
|
|
1621
|
-
};
|
|
1622
|
-
}
|
|
1623
|
-
async function pollRegistration(domain, deviceCode, interval, deadline, onLog, signal) {
|
|
1624
|
-
let currentInterval = interval;
|
|
1625
|
-
let currentDomain = domain;
|
|
1626
|
-
while (Date.now() < deadline) {
|
|
1627
|
-
if (signal?.aborted) return null;
|
|
1628
|
-
let res;
|
|
1629
|
-
try {
|
|
1630
|
-
res = await postRegistration(currentDomain, {
|
|
1631
|
-
action: "poll",
|
|
1632
|
-
device_code: deviceCode
|
|
1633
|
-
});
|
|
1634
|
-
} catch {
|
|
1635
|
-
await sleep(currentInterval * 1e3);
|
|
1636
|
-
continue;
|
|
1637
|
-
}
|
|
1638
|
-
if (res.user_info?.tenant_brand === "lark" && currentDomain === "feishu") {
|
|
1639
|
-
currentDomain = "lark";
|
|
1640
|
-
onLog?.("\u68C0\u6D4B\u5230 Lark \u8D26\u53F7\uFF0C\u5207\u6362\u57DF\u540D...");
|
|
1641
|
-
continue;
|
|
1642
|
-
}
|
|
1643
|
-
if (res.client_id && res.client_secret) {
|
|
1644
|
-
return {
|
|
1645
|
-
appId: res.client_id,
|
|
1646
|
-
appSecret: res.client_secret,
|
|
1647
|
-
openId: res.user_info?.open_id,
|
|
1648
|
-
domain: currentDomain
|
|
1649
|
-
};
|
|
1650
|
-
}
|
|
1651
|
-
if (res.error) {
|
|
1652
|
-
if (res.error === "authorization_pending") {
|
|
1653
|
-
} else if (res.error === "slow_down") {
|
|
1654
|
-
currentInterval += 5;
|
|
1655
|
-
} else if (res.error === "access_denied") {
|
|
1656
|
-
throw new Error("\u7528\u6237\u62D2\u7EDD\u4E86\u6388\u6743");
|
|
1657
|
-
} else if (res.error === "expired_token") {
|
|
1658
|
-
throw new Error("\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F");
|
|
1659
|
-
} else {
|
|
1660
|
-
throw new Error(`\u98DE\u4E66\u6CE8\u518C\u9519\u8BEF: ${res.error} \u2014 ${res.error_description ?? ""}`);
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
await sleep(currentInterval * 1e3);
|
|
1664
|
-
}
|
|
1665
|
-
return null;
|
|
1666
|
-
}
|
|
1667
|
-
async function registerFeishuApp(options = {}) {
|
|
1668
|
-
const domain = options.domain ?? "feishu";
|
|
1669
|
-
const timeoutSec = options.timeoutSec ?? 300;
|
|
1670
|
-
const log = options.onLog ?? (() => {
|
|
1671
|
-
});
|
|
1672
|
-
log("\u68C0\u67E5\u98DE\u4E66\u73AF\u5883...");
|
|
1673
|
-
await initRegistration(domain);
|
|
1674
|
-
log("\u751F\u6210\u4E8C\u7EF4\u7801...");
|
|
1675
|
-
const { deviceCode, qrUrl, interval, expireIn } = await beginRegistration(domain);
|
|
1676
|
-
options.onQrCode?.(qrUrl);
|
|
1677
|
-
log(`\u8BF7\u7528\u98DE\u4E66 App \u626B\u63CF\u4E8C\u7EF4\u7801\uFF08${expireIn}\u79D2\u540E\u8FC7\u671F\uFF09...`);
|
|
1678
|
-
const deadline = Date.now() + Math.min(expireIn, timeoutSec) * 1e3;
|
|
1679
|
-
const result = await pollRegistration(domain, deviceCode, interval, deadline, log, options.signal);
|
|
1680
|
-
if (result) {
|
|
1681
|
-
log(`\u2705 \u6CE8\u518C\u6210\u529F\uFF01App ID: ${result.appId}`);
|
|
1682
|
-
} else {
|
|
1683
|
-
log("\u23F0 \u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F");
|
|
1684
|
-
}
|
|
1685
|
-
return result;
|
|
1686
|
-
}
|
|
1687
|
-
function sleep(ms) {
|
|
1688
|
-
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
1689
|
-
}
|
|
1690
|
-
|
|
1691
|
-
// src/cli-init.ts
|
|
1692
|
-
init_wechat();
|
|
1693
|
-
|
|
1694
|
-
// src/qr-render.ts
|
|
1695
|
-
import { createRequire } from "node:module";
|
|
1696
|
-
var require2 = createRequire(import.meta.url);
|
|
1697
|
-
async function renderQrTerminal(url, options) {
|
|
1698
|
-
return new Promise((resolve2, reject) => {
|
|
1699
|
-
try {
|
|
1700
|
-
const qt = require2("qrcode-terminal");
|
|
1701
|
-
qt.generate(url, { small: options?.small ?? true }, (output) => {
|
|
1702
|
-
resolve2(output);
|
|
1703
|
-
});
|
|
1704
|
-
} catch (err) {
|
|
1705
|
-
reject(err);
|
|
1706
|
-
}
|
|
1707
|
-
});
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
|
-
// src/cli-init.ts
|
|
1711
1729
|
var __filename = fileURLToPath(import.meta.url);
|
|
1712
1730
|
var __dirname = path3.dirname(__filename);
|
|
1713
1731
|
var SCHEMA_VERSION = 1;
|
|
@@ -1746,7 +1764,7 @@ Engine 7 \u2014 Self-hosted AI agent engine
|
|
|
1746
1764
|
|
|
1747
1765
|
\u7528\u6CD5:
|
|
1748
1766
|
engine7 init --state-dir <path> [\u9009\u9879] \u521D\u59CB\u5316 agent \u5DE5\u4F5C\u76EE\u5F55
|
|
1749
|
-
engine7
|
|
1767
|
+
engine7 reconfig <\u76EE\u6807> [\u9009\u9879] \u91CD\u65B0\u914D\u7F6E\u5DF2\u88C5\u7684 agent\uFF08wechat/feishu/discord/llm/channels\uFF09
|
|
1750
1768
|
engine7 start [--config <path>] \u542F\u52A8 Engine
|
|
1751
1769
|
engine7 restart [--config <path>] \u91CD\u542F Engine\uFF08\u6740\u65E7\u8FDB\u7A0B+\u542F\u52A8\uFF09
|
|
1752
1770
|
engine7 service install|uninstall|status \u5F00\u673A\u81EA\u542F\u52A8\u7BA1\u7406
|
|
@@ -2272,8 +2290,11 @@ async function main() {
|
|
|
2272
2290
|
printHelp();
|
|
2273
2291
|
process.exit(0);
|
|
2274
2292
|
}
|
|
2275
|
-
if (subcommand === "addchannel") {
|
|
2276
|
-
const
|
|
2293
|
+
if (subcommand === "reconfig" || subcommand === "addchannel") {
|
|
2294
|
+
const isLegacyAddchannel = subcommand === "addchannel";
|
|
2295
|
+
let target = args[1] || "";
|
|
2296
|
+
if (isLegacyAddchannel) target = target || "wechat";
|
|
2297
|
+
const channel = target;
|
|
2277
2298
|
let stateDir = "";
|
|
2278
2299
|
let configName = "";
|
|
2279
2300
|
for (let i = 1; i < args.length; i++) {
|
|
@@ -2281,6 +2302,103 @@ async function main() {
|
|
|
2281
2302
|
else if (args[i] === "--config" && args[i + 1]) configName = args[++i];
|
|
2282
2303
|
}
|
|
2283
2304
|
if (!stateDir) stateDir = path3.resolve(process.cwd());
|
|
2305
|
+
if (!target && !isLegacyAddchannel) {
|
|
2306
|
+
console.log("\u{1F527} engine7 reconfig \u2014 \u91CD\u65B0\u914D\u7F6E\u5DF2\u88C5\u7684 agent");
|
|
2307
|
+
console.log(" \u7528\u6CD5: engine7 reconfig <\u76EE\u6807>");
|
|
2308
|
+
console.log("");
|
|
2309
|
+
console.log(" \u901A\u9053\u7C7B:");
|
|
2310
|
+
console.log(" wechat \u5FAE\u4FE1\u626B\u7801\u63A5\u5165\uFF08iLink\uFF0C1v1 \u79C1\u804A\uFF09");
|
|
2311
|
+
console.log(" feishu \u98DE\u4E66\u626B\u7801\u63A5\u5165\uFF08OAuth\uFF0C30\u79D2\uFF09");
|
|
2312
|
+
console.log(" discord Discord bot \u914D\u7F6E");
|
|
2313
|
+
console.log(" \u6A21\u578B\u7C7B:");
|
|
2314
|
+
console.log(" llm \u66F4\u6362 LLM provider / API key / \u7AEF\u70B9");
|
|
2315
|
+
console.log(" \u5176\u4ED6:");
|
|
2316
|
+
console.log(" channels \u67E5\u770B\u5F53\u524D\u901A\u9053\u72B6\u6001");
|
|
2317
|
+
console.log("");
|
|
2318
|
+
console.log(" \u9009\u9879: --state-dir <path> --config <file>");
|
|
2319
|
+
process.exit(0);
|
|
2320
|
+
}
|
|
2321
|
+
if (channel === "channels") {
|
|
2322
|
+
const configsDir = path3.join(stateDir, "configs");
|
|
2323
|
+
if (fs3.existsSync(configsDir)) {
|
|
2324
|
+
const files = fs3.readdirSync(configsDir).filter((f) => f.endsWith(".json"));
|
|
2325
|
+
for (const f of files) {
|
|
2326
|
+
try {
|
|
2327
|
+
const j = JSON.parse(fs3.readFileSync(path3.join(configsDir, f), "utf8"));
|
|
2328
|
+
if (!j.channels) continue;
|
|
2329
|
+
console.log(`
|
|
2330
|
+
\u{1F4C4} ${f}:`);
|
|
2331
|
+
for (const [name, conf] of Object.entries(j.channels)) {
|
|
2332
|
+
const c = conf;
|
|
2333
|
+
console.log(` ${c.enabled ? "\u2705" : "\u26D4"} ${name}${c.appId ? " (" + c.appId + ")" : ""}${c.accountId ? " (" + c.accountId + ")" : ""}`);
|
|
2334
|
+
}
|
|
2335
|
+
} catch {
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
} else {
|
|
2339
|
+
console.log(`\u26A0\uFE0F \u672A\u627E\u5230 configs \u76EE\u5F55: ${configsDir}`);
|
|
2340
|
+
}
|
|
2341
|
+
process.exit(0);
|
|
2342
|
+
}
|
|
2343
|
+
if (channel === "llm") {
|
|
2344
|
+
console.log("\u{1F527} LLM \u91CD\u914D\uFF08\u5F00\u53D1\u4E2D\uFF0Cv7.2 \u8BA1\u5212\uFF09");
|
|
2345
|
+
console.log(" \u76EE\u524D\u8BF7\u624B\u52A8\u6539 config \u7684 models.providers \u6BB5");
|
|
2346
|
+
process.exit(0);
|
|
2347
|
+
}
|
|
2348
|
+
if (channel === "discord") {
|
|
2349
|
+
console.log("\u{1F527} Discord \u91CD\u914D\uFF08\u5F00\u53D1\u4E2D\uFF09");
|
|
2350
|
+
console.log(" \u76EE\u524D\u8BF7\u624B\u52A8\u6539 config \u7684 channels.discord \u6BB5\uFF08token/userId\uFF09");
|
|
2351
|
+
process.exit(0);
|
|
2352
|
+
}
|
|
2353
|
+
if (channel === "feishu") {
|
|
2354
|
+
console.log("\u{1F527} \u98DE\u4E66\u626B\u7801\u63A5\u5165...");
|
|
2355
|
+
const { registerFeishuApp: registerFeishuApp2 } = await Promise.resolve().then(() => (init_feishu_quick_register(), feishu_quick_register_exports));
|
|
2356
|
+
const { renderQrTerminal: renderQrTerminal2 } = await Promise.resolve().then(() => (init_qr_render(), qr_render_exports));
|
|
2357
|
+
const result = await registerFeishuApp2({
|
|
2358
|
+
onLog: (msg) => console.log(` ${msg}`),
|
|
2359
|
+
onQrCode: async (url) => {
|
|
2360
|
+
try {
|
|
2361
|
+
console.log(await renderQrTerminal2(url, { small: true }));
|
|
2362
|
+
} catch {
|
|
2363
|
+
console.log(`
|
|
2364
|
+
\u6D4F\u89C8\u5668\u6253\u5F00\u626B\u7801: ${url}
|
|
2365
|
+
`);
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2369
|
+
if (!result) {
|
|
2370
|
+
console.error("\u274C \u626B\u7801\u8D85\u65F6\u6216\u5931\u8D25");
|
|
2371
|
+
process.exit(1);
|
|
2372
|
+
}
|
|
2373
|
+
const configsDir2 = path3.join(stateDir, "configs");
|
|
2374
|
+
let configFile2 = configName ? path3.join(configsDir2, configName) : "";
|
|
2375
|
+
if (!configFile2 || !fs3.existsSync(configFile2)) {
|
|
2376
|
+
if (fs3.existsSync(configsDir2)) {
|
|
2377
|
+
for (const f of fs3.readdirSync(configsDir2).filter((f2) => f2.endsWith(".json"))) {
|
|
2378
|
+
const full = path3.join(configsDir2, f);
|
|
2379
|
+
try {
|
|
2380
|
+
if (JSON.parse(fs3.readFileSync(full, "utf8")).channels) {
|
|
2381
|
+
configFile2 = full;
|
|
2382
|
+
break;
|
|
2383
|
+
}
|
|
2384
|
+
} catch {
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
if (configFile2 && fs3.existsSync(configFile2)) {
|
|
2390
|
+
const j = JSON.parse(fs3.readFileSync(configFile2, "utf8"));
|
|
2391
|
+
j.channels = j.channels || {};
|
|
2392
|
+
j.channels.feishu = { enabled: true, appId: result.appId, appSecret: result.appSecret, connectionMode: "websocket", dmPolicy: "pairing", groupPolicy: "open" };
|
|
2393
|
+
fs3.writeFileSync(configFile2, JSON.stringify(j, null, 2), "utf8");
|
|
2394
|
+
console.log("\u2705 \u98DE\u4E66\u901A\u9053\u5DF2\u5199\u5165: " + configFile2);
|
|
2395
|
+
console.log("\u91CD\u542F\u751F\u6548: engine7 restart");
|
|
2396
|
+
} else {
|
|
2397
|
+
console.log("\u26A0\uFE0F \u6CA1\u627E\u5230 config\uFF0C\u624B\u52A8\u52A0\uFF1A");
|
|
2398
|
+
console.log(JSON.stringify({ feishu: { enabled: true, appId: result.appId, appSecret: result.appSecret, connectionMode: "websocket", dmPolicy: "pairing", groupPolicy: "open" } }, null, 2));
|
|
2399
|
+
}
|
|
2400
|
+
process.exit(0);
|
|
2401
|
+
}
|
|
2284
2402
|
if (channel === "wechat") {
|
|
2285
2403
|
console.log("\u{1F4F1} \u5FAE\u4FE1\u626B\u7801\u63A5\u5165\uFF08iLink \u4E2A\u4EBA\u5FAE\u4FE1\uFF0C1v1 \u79C1\u804A\uFF09");
|
|
2286
2404
|
console.log(" \u63D0\u793A\uFF1A\u4E00\u4E2A\u5FAE\u4FE1\u53F7\u53EA\u80FD\u7ED1\u4E00\u4E2A bot\uFF1Bbot \u4E0D\u8FDB\u7FA4\uFF08\u817E\u8BAF\u9650\u5236\uFF09\n");
|
|
@@ -2330,8 +2448,8 @@ async function main() {
|
|
|
2330
2448
|
console.log("\n\u91CD\u542F engine \u751F\u6548: engine7 restart");
|
|
2331
2449
|
process.exit(0);
|
|
2332
2450
|
}
|
|
2333
|
-
console.error(`\u672A\u77E5\
|
|
2334
|
-
console.error("\u7528\u6CD5: engine7
|
|
2451
|
+
console.error(`\u672A\u77E5\u76EE\u6807: ${channel || "(\u7A7A)"}\u3002\u652F\u6301: wechat / feishu / discord / llm / channels`);
|
|
2452
|
+
console.error("\u7528\u6CD5: engine7 reconfig <\u76EE\u6807> [--state-dir <path>] [--config <file>]");
|
|
2335
2453
|
process.exit(1);
|
|
2336
2454
|
}
|
|
2337
2455
|
if (subcommand === "export") {
|