@keyou007/agent-bot 0.1.17-alpha.2 → 0.1.18-alpha.0
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/CHANGELOG.md +9 -0
- package/dist/feishu/CardRenderer.js +6 -16
- package/dist/feishu/CardRenderer.js.map +1 -1
- package/dist/local-files/LocalFileViewerServer.js +519 -59
- package/dist/local-files/LocalFileViewerServer.js.map +1 -1
- package/dist/proxy/ProxySessionController.js +62 -9
- package/dist/proxy/ProxySessionController.js.map +1 -1
- package/dist/startup/StartupNotifier.js +7 -4
- package/dist/startup/StartupNotifier.js.map +1 -1
- package/docs/technical-reference.md +2 -0
- package/docs/technical-reference.zh.md +2 -0
- package/npm-shrinkwrap.json +108 -2
- package/package.json +3 -1
- package/src/feishu/CardRenderer.ts +6 -22
- package/src/local-files/LocalFileViewerServer.ts +536 -61
- package/src/proxy/ProxySessionController.ts +68 -7
- package/src/startup/StartupNotifier.ts +9 -4
|
@@ -22,8 +22,11 @@ export class StartupNotifier {
|
|
|
22
22
|
const knownGroups = new Map(this.store.listChatContexts("group")
|
|
23
23
|
.filter((chat) => !isThreadContextKey(chat.contextKey))
|
|
24
24
|
.map((chat) => [chat.contextKey, chat]));
|
|
25
|
+
const knownPrivateChats = new Map(this.store.listChatContexts("p2p")
|
|
26
|
+
.filter((chat) => !isThreadContextKey(chat.contextKey))
|
|
27
|
+
.map((chat) => [chat.contextKey, chat]));
|
|
25
28
|
const targetsByContext = new Map();
|
|
26
|
-
for (const chat of
|
|
29
|
+
for (const chat of knownPrivateChats.values()) {
|
|
27
30
|
targetsByContext.set(chat.contextKey, {
|
|
28
31
|
contextKey: chat.contextKey,
|
|
29
32
|
context: this.store.getUserContext(chat.contextKey),
|
|
@@ -46,11 +49,12 @@ export class StartupNotifier {
|
|
|
46
49
|
continue;
|
|
47
50
|
if (isThreadContextKey(contextKey)) {
|
|
48
51
|
const baseContextKey = baseChatContextKey(contextKey);
|
|
49
|
-
|
|
52
|
+
const parentChat = knownGroups.get(baseContextKey) ?? knownPrivateChats.get(baseContextKey);
|
|
53
|
+
if (!parentChat)
|
|
50
54
|
continue;
|
|
51
55
|
const replyMessageId = target.replyMessageId?.trim();
|
|
52
56
|
if (replyMessageId) {
|
|
53
|
-
if (!explicitBaseContextKeys.has(baseContextKey)) {
|
|
57
|
+
if (parentChat.chatType === "group" && !explicitBaseContextKeys.has(baseContextKey)) {
|
|
54
58
|
targetsByContext.delete(baseContextKey);
|
|
55
59
|
}
|
|
56
60
|
targetsByContext.set(contextKey, {
|
|
@@ -60,7 +64,6 @@ export class StartupNotifier {
|
|
|
60
64
|
});
|
|
61
65
|
}
|
|
62
66
|
else {
|
|
63
|
-
const group = knownGroups.get(baseContextKey);
|
|
64
67
|
targetsByContext.set(baseContextKey, {
|
|
65
68
|
contextKey: baseContextKey,
|
|
66
69
|
context: this.store.getUserContext(baseContextKey),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartupNotifier.js","sourceRoot":"","sources":["../../src/startup/StartupNotifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAwBjF,MAAM,OAAO,eAAe;IAEP,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,gBAAgB;IANnC,YACmB,KAAiB,EACjB,QAAwB,EACxB,QAAsB,EACtB,MAA4B,EAC5B,OAAmC,EACnC,gBAA8C;qBAL9C,KAAK;wBACL,QAAQ;wBACR,QAAQ;sBACR,MAAM;uBACN,OAAO;gCACP,gBAAgB;IAChC,CAAC;IAEJ,KAAK,CAAC,MAAM,CACV,SAAe,EACf,aAAqB,EACrB,cAAc,GAAgC,EAAE;QAEhD,IAAI,OAAoC,CAAC;QACzC,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,IAAI,IAAI,C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SAAS;wBAC5B,aAAa,EAAE,OAAO,CAAC,MAAM;wBAC7B,cAAc,EAAE,OAAO,CAAC,cAAc;qBACvC;oBACH,CAAC,CAAC,SAAS;aACd,CAAC,CAAC;YACH,IAAI,CAAC;gBACH,IAAI,cAAc,EAAE,CAAC;oBACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;wBACxC,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;oBACpF,CAAC;oBACD,MAAM,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CACtC,UAAU,EACV,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,IAAI,EAAE,EAClD,IAAI,CACL,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;gBAC5D,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,EAAE,KAAK,EAAE,UAAU,EAAE,EACrB,6CAA6C,CAC9C,CAAC;gBACF,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CAAC,CAAC;QACJ,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACvD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -193,6 +193,8 @@ logging:
|
|
|
193
193
|
path: "./logs/agent-bot.log"
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
+
New viewer links use a `/preview/<short-token>?path=<absolute-path>` shape. Windows paths use readable forward slashes, such as `D:/project/file.md`; only spaces and URL delimiter characters are percent-encoded. The short token is a truncated HMAC bound to the normalized absolute path, so changing either the token or path fails validation without requiring a link registry. The per-Profile signing secret keeps links valid after restart; legacy `/view/<encoded-path>?sig=...` links remain accepted. Viewer pages show the absolute local path in a compact sticky header. Common source, configuration, markup, shell, and data formats receive server-side syntax highlighting; large files fall back to plain text. Line anchors dynamically account for the sticky header height, append the selected line number to the header path, and keep that line visibly highlighted. File pages subscribe to a signed Server-Sent Events stream; content and metadata update in place while preserving the reader's vertical position, bottom-follow state, horizontal code scroll, and selected-line highlight.
|
|
197
|
+
|
|
196
198
|
`fileViewer` turns local non-image files and directories in final replies into signed, read-only HTTP links. The default `host: "127.0.0.1"` accepts connections only from the Agent Bot machine. With `0.0.0.0` or `::`, the server listens on every interface and automatically chooses a non-internal IPv4 link address in wired, Wi-Fi, other physical, then VPN order. Docker, Hyper-V, VMware, VirtualBox, WSL, loopback, and link-local interfaces are excluded; if no candidate remains, links fall back to loopback. `publicBaseUrl` has the highest priority and overrides automatic selection for domains, HTTPS reverse proxies, NAT, or port mappings. With `port: 0`, the first startup selects a free port and stores it in `<data>/file-viewer/port`; later restarts reuse it, while separate Profiles avoid a shared fixed port. The signing key is stored beside it as `secret`. File URLs can read only their signed absolute path. Directory URLs list direct children and allow downward navigation without exposing a parent-directory action. Text identity is detected from a content sample, and text pages preview the first 2 MiB with line anchors; images, PDFs, audio, and video use native browser previews; other binary files expose raw and download actions. Treat each signed URL as a bearer credential and do not share it publicly.
|
|
197
199
|
|
|
198
200
|
`feishu.respondToOwnerOnly` defaults to `true`. It compares each message sender and card-action operator Open ID with `feishu.userOpenId`, ignoring non-owner input before durable event claims, reactions, downloads, commands, or Agent work. Set it to `false` to allow other users. If it is enabled without a configured owner Open ID, all Feishu messages and card actions are ignored; configure `FEISHU_USER_OPEN_ID` or temporarily disable the restriction to bootstrap from a private message.
|
|
@@ -193,6 +193,8 @@ logging:
|
|
|
193
193
|
path: "./logs/agent-bot.log"
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
+
新查看链接使用 `/preview/<短 token>?path=<绝对路径>` 格式。Windows 路径使用便于复制的正斜杠,例如 `D:/project/file.md`;只有空格和 URL 分隔符等必要字符会进行百分号编码。短 token 是与规范化绝对路径绑定的截断 HMAC,因此修改 token 或路径都会校验失败,也不再需要链接注册表。每个 Profile 持久化的签名密钥可保证重启后原链接仍然有效;旧的 `/view/<编码路径>?sig=...` 链接也保持兼容。查看页会在紧凑的置顶头部显示本地绝对路径。常见源码、配置、标记、Shell 和数据格式会在服务端完成语法高亮,较大文件则回退为纯文本;行号锚点会动态避开悬浮头部,在标题路径后显示所选行号,并持续高亮目标行。文件页面通过带签名的 SSE 流订阅更新,正文和元信息会原地刷新,并保留阅读位置、末尾跟随状态、代码区域的横向滚动位置和目标行高亮。
|
|
197
|
+
|
|
196
198
|
`fileViewer` 为最终回答中的本地非图片文件和目录生成带签名的只读 HTTP 链接。默认 `host: "127.0.0.1"`,只能从运行 Agent Bot 的机器访问。设为 `0.0.0.0` 或 `::` 时,服务会监听所有网卡,并从非内部 IPv4 地址中按有线、Wi-Fi、其他物理网卡、VPN 的顺序自动选择链接地址;Docker、Hyper-V、VMware、VirtualBox、WSL、回环和链路本地地址会被排除,没有候选地址时回退到本机环回地址。`publicBaseUrl` 的优先级最高,用于域名、HTTPS 反向代理、NAT 或端口映射。`port: 0` 会在第一次启动时选择空闲端口,并保存到 `<data>/file-viewer/port`,以后重启继续使用,同一机器上的多个 Profile 不会争用固定端口。签名密钥保存在同目录的 `secret` 文件中。文件 URL 只能读取签发时对应的绝对路径;目录 URL 会列出其直接子项并允许继续向下浏览,但不提供向父目录跳转。文本身份由内容采样识别,页面显示带行号的开头 2 MiB;图片、PDF、音视频使用浏览器原生预览,其他二进制文件提供原始打开和下载入口。签名 URL 是持有者凭证,不应公开分享。
|
|
197
199
|
|
|
198
200
|
`feishu.respondToOwnerOnly` 默认为 `true`。每条消息的发送者及卡片操作人的 Open ID 都会与 `feishu.userOpenId` 比较;非拥有者输入会在持久化事件、添加 reaction、下载图片、执行命令或启动 Agent 前被忽略。设为 `false` 可允许其他用户。开启后若未配置拥有者 Open ID,所有飞书消息和卡片操作都会被忽略;需先配置 `FEISHU_USER_OPEN_ID`,或临时关闭限制后通过私聊完成补全。
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyou007/agent-bot",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18-alpha.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@keyou007/agent-bot",
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.18-alpha.0",
|
|
10
10
|
"license": "GPL-3.0-only",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@agentclientprotocol/sdk": "1.2.1",
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
"@resvg/resvg-js": "2.6.2",
|
|
16
16
|
"better-sqlite3": "12.11.1",
|
|
17
17
|
"dotenv": "17.4.2",
|
|
18
|
+
"highlight.js": "11.12.0",
|
|
19
|
+
"markdown-it": "15.0.1",
|
|
18
20
|
"pino": "10.3.1",
|
|
19
21
|
"yaml": "2.9.0",
|
|
20
22
|
"zod": "4.4.3"
|
|
@@ -1926,6 +1928,22 @@
|
|
|
1926
1928
|
"url": "https://github.com/sponsors/epoberezkin"
|
|
1927
1929
|
}
|
|
1928
1930
|
},
|
|
1931
|
+
"node_modules/argparse": {
|
|
1932
|
+
"version": "3.0.1",
|
|
1933
|
+
"resolved": "https://registry.npmjs.org/argparse/-/argparse-3.0.1.tgz",
|
|
1934
|
+
"integrity": "sha512-nM4mHF/KM1v59ZNKX7zfusQz5wUAxR511YG8Vo6TyiV4aqhu++rbJW4v04xsWhpSsHFj66flT8P7znVpyO20xQ==",
|
|
1935
|
+
"funding": [
|
|
1936
|
+
{
|
|
1937
|
+
"type": "github",
|
|
1938
|
+
"url": "https://github.com/sponsors/puzrin"
|
|
1939
|
+
},
|
|
1940
|
+
{
|
|
1941
|
+
"type": "github",
|
|
1942
|
+
"url": "https://github.com/sponsors/nodeca"
|
|
1943
|
+
}
|
|
1944
|
+
],
|
|
1945
|
+
"license": "PSF-2.0"
|
|
1946
|
+
},
|
|
1929
1947
|
"node_modules/assertion-error": {
|
|
1930
1948
|
"version": "2.0.1",
|
|
1931
1949
|
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
|
|
@@ -2244,6 +2262,18 @@
|
|
|
2244
2262
|
"once": "^1.4.0"
|
|
2245
2263
|
}
|
|
2246
2264
|
},
|
|
2265
|
+
"node_modules/entities": {
|
|
2266
|
+
"version": "8.0.0",
|
|
2267
|
+
"resolved": "https://registry.npmjs.org/entities/-/entities-8.0.0.tgz",
|
|
2268
|
+
"integrity": "sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==",
|
|
2269
|
+
"license": "BSD-2-Clause",
|
|
2270
|
+
"engines": {
|
|
2271
|
+
"node": ">=20.19.0"
|
|
2272
|
+
},
|
|
2273
|
+
"funding": {
|
|
2274
|
+
"url": "https://github.com/fb55/entities?sponsor=1"
|
|
2275
|
+
}
|
|
2276
|
+
},
|
|
2247
2277
|
"node_modules/es-define-property": {
|
|
2248
2278
|
"version": "1.0.1",
|
|
2249
2279
|
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
|
@@ -2828,6 +2858,15 @@
|
|
|
2828
2858
|
"node": ">= 0.4"
|
|
2829
2859
|
}
|
|
2830
2860
|
},
|
|
2861
|
+
"node_modules/highlight.js": {
|
|
2862
|
+
"version": "11.12.0",
|
|
2863
|
+
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.12.0.tgz",
|
|
2864
|
+
"integrity": "sha512-nbfWpyRMcMrPMmDwJB+dhX/eiaPKtc2RB+0QZskqJ3WjRA/FDS0e9hZrx8EC/lbEv8gXy98FcDbNa/dspAaJMg==",
|
|
2865
|
+
"license": "BSD-3-Clause",
|
|
2866
|
+
"engines": {
|
|
2867
|
+
"node": ">=12.0.0"
|
|
2868
|
+
}
|
|
2869
|
+
},
|
|
2831
2870
|
"node_modules/https-proxy-agent": {
|
|
2832
2871
|
"version": "5.0.1",
|
|
2833
2872
|
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
|
|
@@ -3241,6 +3280,25 @@
|
|
|
3241
3280
|
"url": "https://opencollective.com/parcel"
|
|
3242
3281
|
}
|
|
3243
3282
|
},
|
|
3283
|
+
"node_modules/linkify-it": {
|
|
3284
|
+
"version": "6.1.0",
|
|
3285
|
+
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-6.1.0.tgz",
|
|
3286
|
+
"integrity": "sha512-wJ/TwpSDTLepCrQoYWYIExIKg5Zchex2Nn5yk2mFnB+6PtdkHtyLx742md9csRjjOnGkKIS/RrbY7l8D6gT9Vw==",
|
|
3287
|
+
"funding": [
|
|
3288
|
+
{
|
|
3289
|
+
"type": "github",
|
|
3290
|
+
"url": "https://github.com/sponsors/puzrin"
|
|
3291
|
+
},
|
|
3292
|
+
{
|
|
3293
|
+
"type": "github",
|
|
3294
|
+
"url": "https://github.com/sponsors/markdown-it"
|
|
3295
|
+
}
|
|
3296
|
+
],
|
|
3297
|
+
"license": "MIT",
|
|
3298
|
+
"dependencies": {
|
|
3299
|
+
"uc.micro": "^3.0.0"
|
|
3300
|
+
}
|
|
3301
|
+
},
|
|
3244
3302
|
"node_modules/locate-path": {
|
|
3245
3303
|
"version": "6.0.0",
|
|
3246
3304
|
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
|
|
@@ -3291,6 +3349,33 @@
|
|
|
3291
3349
|
"@jridgewell/sourcemap-codec": "^1.5.5"
|
|
3292
3350
|
}
|
|
3293
3351
|
},
|
|
3352
|
+
"node_modules/markdown-it": {
|
|
3353
|
+
"version": "15.0.1",
|
|
3354
|
+
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-15.0.1.tgz",
|
|
3355
|
+
"integrity": "sha512-9/7gE95FNPkfUWrjJIoHZza2iLmuJlPD0UNMxPi7bxUrbCR525YZY0r+zyfes0dZI5ZZ/uNIXUJca0pJvtw41g==",
|
|
3356
|
+
"funding": [
|
|
3357
|
+
{
|
|
3358
|
+
"type": "github",
|
|
3359
|
+
"url": "https://github.com/sponsors/puzrin"
|
|
3360
|
+
},
|
|
3361
|
+
{
|
|
3362
|
+
"type": "github",
|
|
3363
|
+
"url": "https://github.com/sponsors/markdown-it"
|
|
3364
|
+
}
|
|
3365
|
+
],
|
|
3366
|
+
"license": "MIT",
|
|
3367
|
+
"dependencies": {
|
|
3368
|
+
"argparse": "^3.0.0",
|
|
3369
|
+
"entities": "^8.0.0",
|
|
3370
|
+
"linkify-it": "^6.0.0",
|
|
3371
|
+
"mdurl": "^2.1.0",
|
|
3372
|
+
"punycode.js": "^2.3.1",
|
|
3373
|
+
"uc.micro": "^3.0.0"
|
|
3374
|
+
},
|
|
3375
|
+
"bin": {
|
|
3376
|
+
"markdown-it": "bin/markdown-it.mjs"
|
|
3377
|
+
}
|
|
3378
|
+
},
|
|
3294
3379
|
"node_modules/math-intrinsics": {
|
|
3295
3380
|
"version": "1.1.0",
|
|
3296
3381
|
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
|
@@ -3300,6 +3385,12 @@
|
|
|
3300
3385
|
"node": ">= 0.4"
|
|
3301
3386
|
}
|
|
3302
3387
|
},
|
|
3388
|
+
"node_modules/mdurl": {
|
|
3389
|
+
"version": "2.1.0",
|
|
3390
|
+
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.1.0.tgz",
|
|
3391
|
+
"integrity": "sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==",
|
|
3392
|
+
"license": "MIT"
|
|
3393
|
+
},
|
|
3303
3394
|
"node_modules/mime-db": {
|
|
3304
3395
|
"version": "1.52.0",
|
|
3305
3396
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
|
@@ -3742,6 +3833,15 @@
|
|
|
3742
3833
|
"node": ">=6"
|
|
3743
3834
|
}
|
|
3744
3835
|
},
|
|
3836
|
+
"node_modules/punycode.js": {
|
|
3837
|
+
"version": "2.3.1",
|
|
3838
|
+
"resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",
|
|
3839
|
+
"integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==",
|
|
3840
|
+
"license": "MIT",
|
|
3841
|
+
"engines": {
|
|
3842
|
+
"node": ">=6"
|
|
3843
|
+
}
|
|
3844
|
+
},
|
|
3745
3845
|
"node_modules/qs": {
|
|
3746
3846
|
"version": "6.15.3",
|
|
3747
3847
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz",
|
|
@@ -4267,6 +4367,12 @@
|
|
|
4267
4367
|
"@typescript/typescript-win32-x64": "7.0.2"
|
|
4268
4368
|
}
|
|
4269
4369
|
},
|
|
4370
|
+
"node_modules/uc.micro": {
|
|
4371
|
+
"version": "3.0.0",
|
|
4372
|
+
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-3.0.0.tgz",
|
|
4373
|
+
"integrity": "sha512-U3PppEkleoTnIfi8BozMx3yju3qc/L6SwqWo2Sw+54PX+PX0q9I+r1Um5HCmqD7n9VDX5/v3vQH/AjA6deDdtw==",
|
|
4374
|
+
"license": "MIT"
|
|
4375
|
+
},
|
|
4270
4376
|
"node_modules/undici-types": {
|
|
4271
4377
|
"version": "6.21.0",
|
|
4272
4378
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyou007/agent-bot",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Use Codex, TraeX, and compatible coding agents from Lark/Feishu.",
|
|
6
6
|
"license": "GPL-3.0-only",
|
|
@@ -73,6 +73,8 @@
|
|
|
73
73
|
"@resvg/resvg-js": "2.6.2",
|
|
74
74
|
"better-sqlite3": "12.11.1",
|
|
75
75
|
"dotenv": "17.4.2",
|
|
76
|
+
"highlight.js": "11.12.0",
|
|
77
|
+
"markdown-it": "15.0.1",
|
|
76
78
|
"pino": "10.3.1",
|
|
77
79
|
"yaml": "2.9.0",
|
|
78
80
|
"zod": "4.4.3"
|
|
@@ -995,8 +995,7 @@ export class CardRenderer {
|
|
|
995
995
|
usesHistoricalPrefixPages ? historyGroups : allGroups,
|
|
996
996
|
state.projectCwd,
|
|
997
997
|
{
|
|
998
|
-
|
|
999
|
-
includeReasoningHistory: true,
|
|
998
|
+
fullActivityText: true,
|
|
1000
999
|
},
|
|
1001
1000
|
)
|
|
1002
1001
|
: activityPages(activities);
|
|
@@ -1024,7 +1023,6 @@ export class CardRenderer {
|
|
|
1024
1023
|
elements.push(...(grouped
|
|
1025
1024
|
? renderGroupedActivityGroups(pages[page] as GroupedTurnActivity[] | undefined ?? [], state.projectCwd, {
|
|
1026
1025
|
fullActivityText: true,
|
|
1027
|
-
includeReasoningHistory: true,
|
|
1028
1026
|
})
|
|
1029
1027
|
: renderActivities(pages[page] as TurnActivity[] | undefined ?? [], state.projectCwd, true)));
|
|
1030
1028
|
return sectionCard(`思考活动历史 · ${page + 1}/${totalPages}`, elements.length > 0 ? elements : [markdown("无")]);
|
|
@@ -1463,7 +1461,6 @@ function renderGroupedTurnElements(
|
|
|
1463
1461
|
const visible = groupedLiveActivityPage(livePages, state.projectCwd);
|
|
1464
1462
|
const historyPages = groupedActivityPagesFromGroups(visible.historyGroups, state.projectCwd, {
|
|
1465
1463
|
fullActivityText: true,
|
|
1466
|
-
includeReasoningHistory: true,
|
|
1467
1464
|
});
|
|
1468
1465
|
if (state.plan.length > 0) elements.push(planPanel(state.plan));
|
|
1469
1466
|
if (historyPages.length > 0) {
|
|
@@ -1623,7 +1620,6 @@ type GroupedTurnActivity =
|
|
|
1623
1620
|
kind: "execution";
|
|
1624
1621
|
id: string;
|
|
1625
1622
|
latestReasoning?: Extract<TurnActivity, { kind: "reasoning" }>;
|
|
1626
|
-
reasonings: Array<Extract<TurnActivity, { kind: "reasoning" }>>;
|
|
1627
1623
|
tools: ToolState[];
|
|
1628
1624
|
};
|
|
1629
1625
|
|
|
@@ -1632,7 +1628,6 @@ function renderGroupedActivityGroups(
|
|
|
1632
1628
|
projectCwd?: string,
|
|
1633
1629
|
options: {
|
|
1634
1630
|
fullActivityText?: boolean;
|
|
1635
|
-
includeReasoningHistory?: boolean;
|
|
1636
1631
|
} = {},
|
|
1637
1632
|
): Record<string, unknown>[] {
|
|
1638
1633
|
return groups.flatMap((group) => {
|
|
@@ -1641,12 +1636,10 @@ function renderGroupedActivityGroups(
|
|
|
1641
1636
|
return renderActivity(group.activity, projectCwd, options.fullActivityText === true);
|
|
1642
1637
|
}
|
|
1643
1638
|
if (group.tools.length === 0) {
|
|
1644
|
-
const reasonings =
|
|
1645
|
-
? group.reasonings
|
|
1646
|
-
: group.latestReasoning ? [group.latestReasoning] : [];
|
|
1639
|
+
const reasonings = group.latestReasoning ? [group.latestReasoning] : [];
|
|
1647
1640
|
return renderReasoningGroup(reasonings);
|
|
1648
1641
|
}
|
|
1649
|
-
return [executionActivityPanel(group, projectCwd
|
|
1642
|
+
return [executionActivityPanel(group, projectCwd)];
|
|
1650
1643
|
});
|
|
1651
1644
|
}
|
|
1652
1645
|
|
|
@@ -1660,12 +1653,11 @@ function groupTurnActivities(activities: TurnActivity[]): GroupedTurnActivity[]
|
|
|
1660
1653
|
for (let index = 0; index < segment.length; index += 1) {
|
|
1661
1654
|
const activity = segment[index]!;
|
|
1662
1655
|
if (isRawReasoning(activity)) {
|
|
1663
|
-
execution ??= { kind: "execution", id: activity.id,
|
|
1664
|
-
execution.reasonings.push(activity);
|
|
1656
|
+
execution ??= { kind: "execution", id: activity.id, tools: [] };
|
|
1665
1657
|
execution.latestReasoning = activity;
|
|
1666
1658
|
executionPosition = index;
|
|
1667
1659
|
} else if (activity.kind === "tool") {
|
|
1668
|
-
execution ??= { kind: "execution", id: activity.id,
|
|
1660
|
+
execution ??= { kind: "execution", id: activity.id, tools: [] };
|
|
1669
1661
|
execution.tools.push(activity.tool);
|
|
1670
1662
|
executionPosition = index;
|
|
1671
1663
|
}
|
|
@@ -1700,13 +1692,9 @@ function isCommentaryActivity(activity: TurnActivity): boolean {
|
|
|
1700
1692
|
function executionActivityPanel(
|
|
1701
1693
|
group: Extract<GroupedTurnActivity, { kind: "execution" }>,
|
|
1702
1694
|
projectCwd: string | undefined,
|
|
1703
|
-
includeReasoningHistory = false,
|
|
1704
1695
|
): Record<string, unknown> {
|
|
1705
1696
|
const status = executionActivityStatus(group.tools);
|
|
1706
|
-
const elements =
|
|
1707
|
-
...(includeReasoningHistory ? renderReasoningGroup(group.reasonings) : []),
|
|
1708
|
-
...group.tools.map((tool) => toolPanel(tool, projectCwd)),
|
|
1709
|
-
];
|
|
1697
|
+
const elements = group.tools.map((tool) => toolPanel(tool, projectCwd));
|
|
1710
1698
|
return collapsiblePanel(
|
|
1711
1699
|
executionActivityTitle(group, status),
|
|
1712
1700
|
elements,
|
|
@@ -1790,7 +1778,6 @@ function groupedActivityPages(
|
|
|
1790
1778
|
projectCwd?: string,
|
|
1791
1779
|
renderOptions: {
|
|
1792
1780
|
fullActivityText?: boolean;
|
|
1793
|
-
includeReasoningHistory?: boolean;
|
|
1794
1781
|
} = {},
|
|
1795
1782
|
): GroupedTurnActivity[][] {
|
|
1796
1783
|
const groups = groupTurnActivities(activities).flatMap(splitGroupedExecutionActivity);
|
|
@@ -1802,7 +1789,6 @@ function groupedActivityPagesFromGroups(
|
|
|
1802
1789
|
projectCwd?: string,
|
|
1803
1790
|
renderOptions: {
|
|
1804
1791
|
fullActivityText?: boolean;
|
|
1805
|
-
includeReasoningHistory?: boolean;
|
|
1806
1792
|
} = {},
|
|
1807
1793
|
): GroupedTurnActivity[][] {
|
|
1808
1794
|
if (groups.length === 0) return [];
|
|
@@ -1827,7 +1813,6 @@ function groupedActivityPageFits(
|
|
|
1827
1813
|
projectCwd: string | undefined,
|
|
1828
1814
|
renderOptions: {
|
|
1829
1815
|
fullActivityText?: boolean;
|
|
1830
|
-
includeReasoningHistory?: boolean;
|
|
1831
1816
|
},
|
|
1832
1817
|
): boolean {
|
|
1833
1818
|
const elements = renderGroupedActivityGroups(groups, projectCwd, renderOptions);
|
|
@@ -1921,7 +1906,6 @@ function splitGroupedExecutionActivity(group: GroupedTurnActivity): GroupedTurnA
|
|
|
1921
1906
|
kind: "execution",
|
|
1922
1907
|
id: index === 0 ? group.id : tools[0]?.id ?? `${group.id}:${index}`,
|
|
1923
1908
|
...(isLast && group.latestReasoning ? { latestReasoning: group.latestReasoning } : {}),
|
|
1924
|
-
reasonings: isLast ? group.reasonings : [],
|
|
1925
1909
|
tools,
|
|
1926
1910
|
});
|
|
1927
1911
|
}
|