agent-loft 0.2.80 → 0.2.82
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 +4 -4
- package/package.json +1 -1
- package/src/channels/web/api.ts +19 -1
- package/src/channels/web/conv-pages.ts +1 -1
- package/src/channels/weixin/bot.ts +2 -24
- package/src/channels/weixin/conversation.ts +32 -0
- package/web/css/sidebar.css +6 -6
- package/web/css/topbar.css +16 -0
- package/web/settings/weixin.js +21 -0
- package/web/views/layout.js +2 -4
- package/web/views/sidebar.js +42 -26
package/README.md
CHANGED
|
@@ -55,17 +55,17 @@ Logo 就是这个意思:一大两小几颗星(多个 agent)站在同一张
|
|
|
55
55
|
- 输入框里的小圆环显示上下文窗口占用;模型按钮显示实际的模型和思考程度(如「Opus 5.5 high」)。
|
|
56
56
|
- 滚动和 ChatGPT 一样:发出的问题顶到最上面、下面留白,回复长到屏幕底部才跟着往下滚;回复过程中自己滚动了就不再自动滚,下次发消息再恢复。
|
|
57
57
|
- 定时发送:右上角「更多」→「定时发送」,默认排在 5 小时额度重置后 5 分钟(弹窗里提示 5 小时 / 7 天额度的重置时间),由服务端到点发出,关掉页面也会发。适合额度用完、要等刷新才能接着干活的时候。
|
|
58
|
-
- 侧栏直接显示各个文件夹,Web
|
|
58
|
+
- 侧栏直接显示各个文件夹,Web 会话按工作目录归类(目录可以拖动排序,右键可置顶;排好的顺序跟着账号走、各设备一致,新消息不会打乱),飞书会话按机器人分组,微信会话也单独分组,两者都能展开 / 折叠并记住状态,收起时仍显示运行中和待处理提示(飞书分组右键仍可看历史会话)。渠道分组行右侧平时显示飞书或微信图标,鼠标悬停时切成加号;点击加号在 Web 开新对话,沿用该分组最近会话的专家和工作目录。项目名、渠道分组名和有分叉的会话后面有个小三角,点一下折叠 / 展开(分叉折叠后显示「N 个嵌套会话」);分叉出来的会话缩进挂在原会话下面,用一条细线连着;标题放不下时尾巴淡出;Web 和飞书会话都先用首条消息命名,再同步 agent 自动生成的标题,旧飞书会话会从历史记录补名,双击可手动重命名;鼠标移到会话上,行尾显示对应的专家图标;定时任务的时钟图标始终放在最右侧。
|
|
59
59
|
- **搜索**:侧栏「搜索」弹窗,搜全部会话的标题、目录名和聊天内容(不开记忆也能搜),可以按专家筛;电脑和手机上弹窗都固定高度,结果在内部滚动,手机上从底部展开;↑↓ 选、回车打开。
|
|
60
60
|
- **侧栏菜单**:项目上方的「更多」支持点击或鼠标悬停展开,设置入口也在这里。「编辑侧边栏」可勾选直接显示的菜单、拖动调整顺序,未勾选的收进「更多」;配置跟着账号走,电脑和手机共用。
|
|
61
|
-
-
|
|
61
|
+
- 会话页顶部标题前是专家的头像,PC 端头像与会话名称字号一致(15px);鼠标停上去或点一下,看专家的说明、模型、能力和当前工作目录。
|
|
62
62
|
- 附件可以直接拖到聊天区任意位置上传。
|
|
63
63
|
- 回复过程中接着发的消息排队,标着「排队中」,隐藏底部的复制和回退按钮,上一条回复完自动接着处理;点「撤销并编辑」图标把排队消息放回输入框;点「打断并发送」停掉正在进行的回复、马上处理这条;点停止则连排着的一起取消(标「没有发出」)。
|
|
64
64
|
- 用户消息的复制按钮后有「回退到此处」图标:把这条消息及附件放回输入框,并删除它及之后的聊天内容,重新发送时从之前的上下文继续。
|
|
65
65
|
- 太长的消息先收起,点「展开显示」看全文;对话里有至少 3 条用户消息时,右侧显示快速定位尺,电脑上鼠标移入查看消息开头、点击跳转;手机上手动滚动时显示短轨道,按住拖动可预览问题和位置,松手跳转,停止操作约 1.6 秒后隐藏。
|
|
66
66
|
- 回复底部的 token 数自动按大小显示为 K、M 等单位。
|
|
67
67
|
- 侧栏按页加载:每个项目目录和飞书机器人分组先显示 5 条,点「展开显示」每次再拉 10 条。
|
|
68
|
-
-
|
|
68
|
+
- 项目、飞书和微信分组可混合拖拽排序,渠道分组可以放在项目前面或项目之间;右键(触屏长按)可置顶、上移、下移或按最近活跃重排。顺序按账号保存,刷新、换设备后保留,新消息不会改变已排好的位置。
|
|
69
69
|
- 侧栏底部显示 Claude / Codex 的订阅额度(5 小时 / 7 天窗口,以及多久后重置);关了额度查询就整块不显示。
|
|
70
70
|
- 右上角「更多」最下面显示当前会话累计消耗的 token 分布(输入 / 缓存写入 / 缓存读取 / 输出,Claude 还有按 API 价格估算的费用)。设置也在「更多」里。
|
|
71
71
|
- 设置 → 用量:按日 / 月 / 年(默认按月)统计 token 和金额,有每天(每月)的柱状图,按 agent、模型、用户(管理员才有)分开看;成员只看到自己的。管理员还可查看服务端本机直接使用的 Claude Code、Codex 桌面端和 CLI 用量,和 Agent Loft 的用量分开显示、避免重复计算。金额都是按 API 价格算的参考值:Agent Loft 的 Claude 用它自己报的费用,Codex 和直接用的 Claude Code 按模型单价 × token 估算(OpenAI 单价来自 LiteLLM 公开价格表,内置快照、联网时每天更新)。Agent Loft 的账从 0.2.34 开始记录;本机直接使用的用量可回溯已有会话记录。
|
|
@@ -96,7 +96,7 @@ Logo 就是这个意思:一大两小几颗星(多个 agent)站在同一张
|
|
|
96
96
|
- 桌面:走 VNC 协议,网页里用 noVNC 显示,鼠标、键盘、剪贴板都能用,进来时不自动连、点「连接桌面」才连,工具栏上选画质:流畅 / 标准(默认)/ 高清由服务端把画面缩小到长边 1280 / 1920 / 2560、只把变了的地方压成 JPEG 发过来(macOS 屏幕共享只给无损的 ZRLE,5K 屏一整屏 30MB,原样转发隔着公网几秒一帧),原画是原样转发、只适合局域网;远程那边接了几块屏时可以只看其中一块(按系统里的显示器名称选,服务端只截那块再缩,比几块屏拼在一起缩小清楚得多;macOS 的各块屏位置要从屏幕共享发来的画面里学,第一次连上要几秒,原画下不能选);可以缩放到窗口或按原始大小看、全屏(手机上也能,iPhone 上是铺满页面)、「只看不控制」、发送 Ctrl+Alt+Del 之类的组合键。手机上有两种手势(右上角切换,「?」看说明):**触控板模式**(默认)屏幕上有个指针,单指滑动移动、轻点单击、双指轻点右键、长按后拖动是按住左键拖、双指滑动滚动;**触摸模式**点哪就点哪。两种模式都能双指捏合在本地放大画面(放大后小按钮也点得准,右下角「还原」),画面下面一排 Esc / Tab / Ctrl / Alt / Win / 方向键,Ctrl、Alt、Win 点一下会粘住,带给下一个按键或点击;键盘按钮弹出软键盘打字,中文输入法也能用。Linux 上 agent-loft 在有人连时用 x11vnc 共享当前的桌面(Xorg 会话;只听 127.0.0.1、随机端口、每次随机密码,需要 `sudo apt install x11vnc`),没人连着 30 分钟后停掉;macOS 上在 设置 → 远程控制 里改用「已有的 VNC 服务」,接系统自带的屏幕共享:填 VNC 密码,或者屏幕共享没开 VNC 密码时填 Mac 的用户名和登录密码(苹果认证,由服务端登录)。
|
|
97
97
|
- 终端:新终端开在当前对话的工作目录里,可以开多个标签;`Ctrl+Shift+C` / `Ctrl+Shift+V` 复制粘贴。`` Ctrl+` `` 在对话下面拉出终端面板(高度可拖动),面板和远程控制里的是同一批终端。关掉页面、手机切到后台、断线都不结束 shell,重新打开时接着用、补上错过的输出,别的设备上也能接上;没有页面连着超过 30 分钟(设置里可改)才结束,点标签上的 × 立即结束。依赖可选的原生模块 `node-pty`:Linux 上安装时要现场编译(需要 `make`、`g++`、`python3`),没装好时终端用不了,其他功能照常。手机上单指上下滑翻看历史(在 less、vim 里是翻页),长按选中文字、接着拖动扩大选区,再点「复制」;终端下面多一排 Esc / Tab / Ctrl / Alt / 方向键 / Home / End / PgUp / PgDn / 粘贴。iOS 上软键盘弹出来时这排键会垫到键盘上面。
|
|
98
98
|
- 管理员能用;成员要管理员在 设置 → 用户 里单独「开通远程控制」。终端、桌面在 设置 → 远程控制 里各有总开关。
|
|
99
|
-
- **微信 ClawBot**:设置 → 账号 → 微信 →「扫码连接微信」,用手机微信扫码并确认(要求微信 8.0.70 以上,「设置 → 插件」里有 ClawBot;这个功能腾讯还在逐步放量)。每个人连自己的微信,这条对话归扫码的人,用他的记忆和工具,只认扫码的这个微信号;服务端主动连向腾讯,不需要公网地址。微信里发文字或语音(要微信能转成文字),不发过程,只显示「正在输入」,结束后发结果;授权和提问是一条文字,回复数字处理(`1` 允许一次、`0` 拒绝,含义固定),网页上也能处理。`/new`、`/stop`、`/model`、`/expert`
|
|
99
|
+
- **微信 ClawBot**:设置 → 账号 → 微信 →「扫码连接微信」,用手机微信扫码并确认(要求微信 8.0.70 以上,「设置 → 插件」里有 ClawBot;这个功能腾讯还在逐步放量)。每个人连自己的微信,这条对话归扫码的人,用他的记忆和工具,只认扫码的这个微信号;服务端主动连向腾讯,不需要公网地址。微信里发文字或语音(要微信能转成文字),不发过程,只显示「正在输入」,结束后发结果;授权和提问是一条文字,回复数字处理(`1` 允许一次、`0` 拒绝,含义固定),网页上也能处理。`/new`、`/stop`、`/model`、`/expert` 等命令都能用。连接后可在同一设置页的「微信使用的专家」中选择专家并点击「切换专家」,也能在首次发微信消息前选好;切换会开启新会话,和微信里的 `/expert` 共用同一份选择。
|
|
100
100
|
|
|
101
101
|
微信的限制(官方没公布具体数字,以下来自社区实测,agent-loft 按此处理):每条入站消息之后约能发 10 条,所以长回复每次发 3 段,回「继续」接着发,额度用完时在网页上说明;约 24 小时没在微信里说话后微信会拒绝发送,定时任务的结果可能发不过去,这时改走网页提示和系统推送。接口受理了但没给 `message_id` 时手机可能没收到(微信可能在静默限制账号),设置页和对话里会提示。Web 上说的话回复留在 Web,不花微信的额度。暂不支持群聊和收发图片、文件。
|
|
102
102
|
|
package/package.json
CHANGED
package/src/channels/web/api.ts
CHANGED
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
type CurateSettings,
|
|
43
43
|
} from "../../core/memory.js";
|
|
44
44
|
import { createLinkCode, listLinks, unlink, unlinkUser } from "../../core/feishu-links.js";
|
|
45
|
-
import { getWeixinAccount, removeWeixinAccount } from "../../core/weixin-accounts.js";
|
|
45
|
+
import { getWeixinAccount, removeWeixinAccount, weixinKey } from "../../core/weixin-accounts.js";
|
|
46
46
|
import { purgeUserData } from "../../core/personal.js";
|
|
47
47
|
import { countRecords, purgeHistory, readMeta, searchHistory, writeMeta } from "../../core/chat-history.js";
|
|
48
48
|
import { curateNow, pendingCount } from "../../core/memory-curator.js";
|
|
@@ -52,6 +52,7 @@ import { agentAvailability, agentHealth, invalidateHealth } from "../../agents/h
|
|
|
52
52
|
import { installCodex, upgrade, useInstalledCodex, versionInfo } from "../../core/upgrade.js";
|
|
53
53
|
import { feishuBots } from "../feishu/index.js";
|
|
54
54
|
import { weixinStatus } from "../weixin/index.js";
|
|
55
|
+
import { ensureWeixinConversation, weixinExpertChoices } from "../weixin/conversation.js";
|
|
55
56
|
import { cancelWeixinLogin, startWeixinLogin, submitWeixinVerifyCode, weixinLoginStatus } from "../weixin/login.js";
|
|
56
57
|
import { fromThisMachine, isLoopbackHost, lanAddresses, listening, rebind } from "./listen.js";
|
|
57
58
|
import { beginRegistration, initRegistration, pollRegistration, qrSvg } from "../feishu/register.js";
|
|
@@ -538,12 +539,16 @@ function feishuLinksOf(userId: string) {
|
|
|
538
539
|
function weixinAccountView(userId: string) {
|
|
539
540
|
const account = getWeixinAccount(userId);
|
|
540
541
|
if (!account) return { linked: false };
|
|
542
|
+
const { choices } = weixinExpertChoices(userId);
|
|
543
|
+
const conv = getConversation(weixinKey(userId));
|
|
541
544
|
return {
|
|
542
545
|
linked: true,
|
|
543
546
|
wechatShort: maskOpenId(account.ilinkUserId),
|
|
544
547
|
boundAt: account.boundAt,
|
|
545
548
|
lastInboundAt: account.lastInboundAt,
|
|
546
549
|
status: weixinStatus(userId) ?? { state: "stopped", since: account.boundAt },
|
|
550
|
+
expert: conv ? (conv.expert ?? conv.agent) : (choices[0]?.id ?? null),
|
|
551
|
+
experts: choices.map(({ id, label }) => ({ id, label })),
|
|
547
552
|
};
|
|
548
553
|
}
|
|
549
554
|
|
|
@@ -1425,6 +1430,19 @@ export async function handleApi(req: IncomingMessage, res: ServerResponse, url:
|
|
|
1425
1430
|
sendJson(res, 200, weixinAccountView(user.id));
|
|
1426
1431
|
return;
|
|
1427
1432
|
}
|
|
1433
|
+
if (p === "/api/account/weixin" && method === "PATCH") {
|
|
1434
|
+
if (!getWeixinAccount(user.id)) throw new HttpError(409, "请先扫码连接微信");
|
|
1435
|
+
const body = await readJsonBody<{ expert?: unknown }>(req);
|
|
1436
|
+
const { choices } = weixinExpertChoices(user.id);
|
|
1437
|
+
if (typeof body.expert !== "string" || !choices.some((e) => e.id === body.expert)) throw new HttpError(400, "请选择一个可用的专家");
|
|
1438
|
+
const allowed = await ensureWeixinConversation(user.id);
|
|
1439
|
+
if (!allowed) throw new HttpError(409, "你现在没有可用的专家");
|
|
1440
|
+
const message = await hub.setExpert(weixinKey(user.id), body.expert, allowed);
|
|
1441
|
+
const conv = getConversation(weixinKey(user.id));
|
|
1442
|
+
if ((conv?.expert ?? conv?.agent) !== body.expert) throw new HttpError(409, message);
|
|
1443
|
+
sendJson(res, 200, { ...weixinAccountView(user.id), message });
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1428
1446
|
if (p === "/api/account/weixin" && method === "DELETE") {
|
|
1429
1447
|
removeWeixinAccount(user.id);
|
|
1430
1448
|
sendJson(res, 200, weixinAccountView(user.id));
|
|
@@ -9,7 +9,7 @@ export type Cursor = { at: number; key: string };
|
|
|
9
9
|
export type Page = { conversations: ConversationInfo[]; next: Cursor | null };
|
|
10
10
|
type Tree = { root: ConversationInfo; convs: ConversationInfo[]; at: number };
|
|
11
11
|
|
|
12
|
-
/**
|
|
12
|
+
/** 最近:飞书、微信以外的会话(IM 渠道在侧栏单独分组) */
|
|
13
13
|
export const inRecent = (c: ConversationInfo): boolean => c.channel !== "feishu" && c.channel !== "weixin";
|
|
14
14
|
/** 项目:Web 会话按工作目录分组 */
|
|
15
15
|
export const inDir = (dir: string) => (c: ConversationInfo): boolean => c.channel === "web" && c.cwd === dir;
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
toWeixinText,
|
|
29
29
|
} from "./format.js";
|
|
30
30
|
import { weixinEvents } from "./events.js";
|
|
31
|
+
import { ensureWeixinConversation } from "./conversation.js";
|
|
31
32
|
|
|
32
33
|
/** 每条入站消息之后能发的条数(社区实测,官方没有公布) */
|
|
33
34
|
export const SEND_LIMIT = 10;
|
|
@@ -234,29 +235,6 @@ export class WeixinBot {
|
|
|
234
235
|
});
|
|
235
236
|
}
|
|
236
237
|
|
|
237
|
-
/** 专家:新会话选第一个能用的,手上的专家不能用了就换掉 */
|
|
238
|
-
private async ensureConversation(user: User): Promise<string[] | undefined> {
|
|
239
|
-
const allowed = hub.enabledAgents().map((d) => d.id);
|
|
240
|
-
const choices = hub.expertChoices(user.id, allowed);
|
|
241
|
-
if (choices.length === 0) return undefined;
|
|
242
|
-
const first = choices[0]!;
|
|
243
|
-
const existed = getConversation(this.key);
|
|
244
|
-
if (!existed) {
|
|
245
|
-
hub.ensure({
|
|
246
|
-
key: this.key,
|
|
247
|
-
channel: "weixin",
|
|
248
|
-
channelId: user.id,
|
|
249
|
-
defaultAgent: first.engine,
|
|
250
|
-
expert: first.id,
|
|
251
|
-
owner: user.id,
|
|
252
|
-
title: "微信",
|
|
253
|
-
});
|
|
254
|
-
} else if (!choices.some((e) => e.id === (existed.expert ?? existed.agent))) {
|
|
255
|
-
await hub.setExpert(this.key, first.id, allowed);
|
|
256
|
-
}
|
|
257
|
-
return allowed;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
238
|
private async handleInbound(msg: WeixinMessage): Promise<void> {
|
|
261
239
|
const user = this.user;
|
|
262
240
|
if (!user) return;
|
|
@@ -267,7 +245,7 @@ export class WeixinBot {
|
|
|
267
245
|
}
|
|
268
246
|
if (!text) return;
|
|
269
247
|
|
|
270
|
-
const allowed = await
|
|
248
|
+
const allowed = await ensureWeixinConversation(user.id);
|
|
271
249
|
if (!allowed) {
|
|
272
250
|
this.say("你现在没有可用的专家。所选专家可能已取消共享、删除,或引擎已停用。");
|
|
273
251
|
return;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// 设置页和微信入站共用同一条会话、同一份专家选择。
|
|
2
|
+
import { hub } from "../../core/hub.js";
|
|
3
|
+
import { getConversation } from "../../core/store.js";
|
|
4
|
+
import { weixinKey } from "../../core/weixin-accounts.js";
|
|
5
|
+
|
|
6
|
+
export function weixinExpertChoices(userId: string) {
|
|
7
|
+
const allowed = hub.enabledAgents().map((d) => d.id);
|
|
8
|
+
return { allowed, choices: hub.expertChoices(userId, allowed) };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** 新会话选第一个可用专家;原专家不可用时换掉。 */
|
|
12
|
+
export async function ensureWeixinConversation(userId: string): Promise<string[] | undefined> {
|
|
13
|
+
const { allowed, choices } = weixinExpertChoices(userId);
|
|
14
|
+
const first = choices[0];
|
|
15
|
+
if (!first) return undefined;
|
|
16
|
+
const key = weixinKey(userId);
|
|
17
|
+
const existed = getConversation(key);
|
|
18
|
+
if (!existed) {
|
|
19
|
+
hub.ensure({
|
|
20
|
+
key,
|
|
21
|
+
channel: "weixin",
|
|
22
|
+
channelId: userId,
|
|
23
|
+
defaultAgent: first.engine,
|
|
24
|
+
expert: first.id,
|
|
25
|
+
owner: userId,
|
|
26
|
+
title: "微信",
|
|
27
|
+
});
|
|
28
|
+
} else if (!choices.some((e) => e.id === (existed.expert ?? existed.agent))) {
|
|
29
|
+
await hub.setExpert(key, first.id, allowed);
|
|
30
|
+
}
|
|
31
|
+
return allowed;
|
|
32
|
+
}
|
package/web/css/sidebar.css
CHANGED
|
@@ -202,7 +202,7 @@ button.conv-group:hover {
|
|
|
202
202
|
color: var(--fg);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
/* 项目 /
|
|
205
|
+
/* 项目 / IM 分组拖动排序:被拖的行变淡,落点处画一条横线 */
|
|
206
206
|
.proj-row.dragging {
|
|
207
207
|
opacity: 0.4;
|
|
208
208
|
}
|
|
@@ -265,13 +265,13 @@ button.conv-group:hover {
|
|
|
265
265
|
display: grid;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
.bot-new .
|
|
268
|
+
.bot-new .channel-mark,
|
|
269
269
|
.bot-new .bot-plus {
|
|
270
270
|
grid-area: 1 / 1;
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
.bot-new .
|
|
274
|
-
.bot-new .
|
|
273
|
+
.bot-new .channel-mark,
|
|
274
|
+
.bot-new .channel-mark svg {
|
|
275
275
|
width: 14px;
|
|
276
276
|
height: 14px;
|
|
277
277
|
}
|
|
@@ -281,8 +281,8 @@ button.conv-group:hover {
|
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
@media (hover: hover) and (pointer: fine) {
|
|
284
|
-
.bot-row:hover .bot-new .
|
|
285
|
-
.bot-row:focus-within .bot-new .
|
|
284
|
+
.bot-row:hover .bot-new .channel-mark,
|
|
285
|
+
.bot-row:focus-within .bot-new .channel-mark {
|
|
286
286
|
visibility: hidden;
|
|
287
287
|
}
|
|
288
288
|
|
package/web/css/topbar.css
CHANGED
|
@@ -201,6 +201,22 @@
|
|
|
201
201
|
font-size: 16px;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
/* PC 顶栏头像与 15px 会话名称等大,按钮保留原来的点击区域。 */
|
|
205
|
+
@media (min-width: 769px) {
|
|
206
|
+
.topbar .conv-expert-icon .agent-icon,
|
|
207
|
+
.topbar .conv-expert-icon svg,
|
|
208
|
+
.topbar .conv-expert-icon img,
|
|
209
|
+
.topbar .conv-expert-icon .expert-avatar,
|
|
210
|
+
.topbar .conv-expert-icon .expert-avatar img {
|
|
211
|
+
width: 15px;
|
|
212
|
+
height: 15px;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.topbar .conv-expert-icon .expert-emoji {
|
|
216
|
+
font-size: 15px;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
204
220
|
/* ---- 专家信息卡 ---- */
|
|
205
221
|
.popover.expert-card {
|
|
206
222
|
width: 300px;
|
package/web/settings/weixin.js
CHANGED
|
@@ -66,6 +66,27 @@ export function weixinLinkSection() {
|
|
|
66
66
|
].join(" · ");
|
|
67
67
|
rows.push(h("div", { class: "list-item" }, h("div", { class: "grow" }, h("div", { class: "t" }, state), h("div", { class: "s" }, facts)), rm));
|
|
68
68
|
if (DELIVERY_TEXT[data.status.delivery]) rows.push(h("div", { class: "error-text" }, DELIVERY_TEXT[data.status.delivery]));
|
|
69
|
+
const choices = data.experts;
|
|
70
|
+
const currentAvailable = choices.some((e) => e.id === data.expert);
|
|
71
|
+
const expert = h("select", { disabled: !choices.length, "aria-label": "微信专家", style: { flex: "1", minWidth: "0" } },
|
|
72
|
+
!currentAvailable ? h("option", { value: "", selected: true, disabled: true }, choices.length ? "当前专家已不可用,请重新选择" : "没有可用的专家") : null,
|
|
73
|
+
choices.map((e) => h("option", { value: e.id, selected: e.id === data.expert }, e.label)));
|
|
74
|
+
const change = h("button", { class: "btn", disabled: true }, "切换专家");
|
|
75
|
+
expert.onchange = () => { change.disabled = !expert.value || expert.value === data.expert; };
|
|
76
|
+
change.onclick = async () => {
|
|
77
|
+
change.disabled = true;
|
|
78
|
+
expert.disabled = true;
|
|
79
|
+
try {
|
|
80
|
+
const result = await api("/api/account/weixin", { method: "PATCH", body: { expert: expert.value } });
|
|
81
|
+
toast(result.message);
|
|
82
|
+
await load();
|
|
83
|
+
} catch (err) {
|
|
84
|
+
toast(err.message);
|
|
85
|
+
expert.disabled = !choices.length;
|
|
86
|
+
change.disabled = !expert.value || expert.value === data.expert;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
rows.push(field("微信使用的专家", h("div", { class: "row" }, expert, change), "切换会结束当前会话并开启新会话,之后的微信消息使用所选专家。也可以在微信里发 /expert 切换。"));
|
|
69
90
|
}
|
|
70
91
|
fill(
|
|
71
92
|
box,
|
package/web/views/layout.js
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
bootstrapQuery,
|
|
9
9
|
closeSide,
|
|
10
10
|
marquee,
|
|
11
|
-
botGroupId,
|
|
12
11
|
moveSidebarGroup,
|
|
13
12
|
sidebarGroups,
|
|
14
13
|
renderSidebar,
|
|
@@ -236,10 +235,9 @@ function renderLayout() {
|
|
|
236
235
|
lastDown = { key, at: now };
|
|
237
236
|
});
|
|
238
237
|
ui.convList.addEventListener("contextmenu", (e) => {
|
|
239
|
-
//
|
|
238
|
+
// 项目和 IM 分组共用移动菜单;触屏也可以通过长按调整混合顺序。
|
|
240
239
|
const bot = e.target.closest?.("[data-bot]")?.dataset.bot;
|
|
241
|
-
const
|
|
242
|
-
const group = bot ? botGroupId(bot) : dir;
|
|
240
|
+
const group = e.target.closest?.("[data-group]")?.dataset.group;
|
|
243
241
|
if (group) {
|
|
244
242
|
const i = sidebarGroups.indexOf(group);
|
|
245
243
|
const moves = [
|
package/web/views/sidebar.js
CHANGED
|
@@ -241,11 +241,11 @@ function agentShort(id) {
|
|
|
241
241
|
return id === "claude" ? "Claude" : id === "codex" ? "Codex" : id;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
/** 侧栏状态:order
|
|
245
|
-
export const sideState = { open: [], botOpen: [], more: [], folded: [], forkFolded: [], order: [], ...JSON.parse(localStorage.getItem("aim.side") || "{}") };
|
|
244
|
+
/** 侧栏状态:order 混排目录路径和渠道分组,兼容原有的顺序。 */
|
|
245
|
+
export const sideState = { open: [], botOpen: [], weixinOpen: [], more: [], folded: [], forkFolded: [], order: [], ...JSON.parse(localStorage.getItem("aim.side") || "{}") };
|
|
246
246
|
|
|
247
247
|
/**
|
|
248
|
-
*
|
|
248
|
+
* 项目和 IM 分组共用 sideState.order,新消息不会改变分组位置。
|
|
249
249
|
* 顺序存在服务端、跟着账号走(换设备也一样);新出现的分组接在最后,
|
|
250
250
|
* 接上之后名次也就定了
|
|
251
251
|
*/
|
|
@@ -329,6 +329,7 @@ function groupDragAttrs(id) {
|
|
|
329
329
|
if (sidebarStale) renderSidebar();
|
|
330
330
|
};
|
|
331
331
|
return {
|
|
332
|
+
"data-group": id,
|
|
332
333
|
draggable: "true",
|
|
333
334
|
ondragstart: (e) => {
|
|
334
335
|
groupDrag = id;
|
|
@@ -544,32 +545,32 @@ export function renderSidebar() {
|
|
|
544
545
|
status(fold?.folded ? fold.keys : [c.key]),
|
|
545
546
|
);
|
|
546
547
|
|
|
547
|
-
//
|
|
548
|
-
if (cur?.channel === "feishu" && cur.key !== autoOpenedFor) {
|
|
548
|
+
// 切到 IM 会话时展开所属分组一次,之后仍可手动收起。
|
|
549
|
+
if ((cur?.channel === "feishu" || cur?.channel === "weixin") && cur.key !== autoOpenedFor) {
|
|
549
550
|
autoOpenedFor = cur.key;
|
|
550
|
-
|
|
551
|
-
|
|
551
|
+
const list = cur.channel === "feishu" ? sideState.botOpen : sideState.weixinOpen;
|
|
552
|
+
const id = cur.channel === "feishu" ? cur.channelId : cur.key;
|
|
553
|
+
if (!list.includes(id)) {
|
|
554
|
+
list.push(id);
|
|
552
555
|
saveSideState();
|
|
553
556
|
}
|
|
554
557
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const convs = visible.filter((c) => c.channel === "feishu" && c.channelId === bot.id);
|
|
558
|
-
if (bot.enabled === false && convs.length === 0) continue;
|
|
558
|
+
// 飞书和微信共用分组标题、折叠状态提示及继承专家/目录的新建入口。
|
|
559
|
+
const imGroupRow = ({ id, channel, name, convs, expanded, toggle, agent, attrs = {} }) => {
|
|
559
560
|
const latest = convs[0];
|
|
560
|
-
const
|
|
561
|
-
|
|
561
|
+
const label = channel === "feishu" ? "飞书" : "微信";
|
|
562
|
+
return h(
|
|
562
563
|
"div",
|
|
563
|
-
{ class: "proj-row bot-row",
|
|
564
|
+
{ class: "proj-row bot-row", ...attrs, ...groupDragAttrs(id) },
|
|
564
565
|
h(
|
|
565
566
|
"button",
|
|
566
567
|
{
|
|
567
568
|
class: "conv-item proj",
|
|
568
|
-
title:
|
|
569
|
+
title: `${label} · ${name}\n拖动可调整顺序,右键更多操作`,
|
|
569
570
|
"aria-expanded": String(expanded),
|
|
570
|
-
onclick:
|
|
571
|
+
onclick: toggle,
|
|
571
572
|
},
|
|
572
|
-
h("span", { class: "title" },
|
|
573
|
+
h("span", { class: "title" }, name),
|
|
573
574
|
caret(!expanded),
|
|
574
575
|
expanded ? null : status(convs.map((c) => c.key)),
|
|
575
576
|
),
|
|
@@ -577,21 +578,32 @@ export function renderSidebar() {
|
|
|
577
578
|
"button",
|
|
578
579
|
{
|
|
579
580
|
class: "proj-new bot-new",
|
|
580
|
-
title: `使用 ${
|
|
581
|
-
"aria-label": `使用 ${
|
|
581
|
+
title: `使用 ${name} 的专家和工作目录开新对话`,
|
|
582
|
+
"aria-label": `使用 ${name} 的专家和工作目录开新对话`,
|
|
582
583
|
onclick: () => {
|
|
583
584
|
S.draftCwd = latest?.cwd && latest.cwd !== S.workspaceRoot ? latest.cwd : null;
|
|
584
585
|
S.draftCwdPicked = true;
|
|
585
|
-
const expert = latest?.expert?.id ?? latest?.agent ??
|
|
586
|
+
const expert = latest?.expert?.id ?? latest?.agent ?? agent;
|
|
586
587
|
if (expert) setDraftExpert(expert);
|
|
587
588
|
newDraft();
|
|
588
589
|
closeSide();
|
|
589
590
|
},
|
|
590
591
|
},
|
|
591
|
-
h("span", { class:
|
|
592
|
+
h("span", { class: `brand-icon channel-mark ${channel}-mark`, html: ICON[channel], "aria-hidden": "true" }),
|
|
592
593
|
h("span", { class: "bot-plus", "aria-hidden": "true" }, icon("plus")),
|
|
593
594
|
),
|
|
594
|
-
)
|
|
595
|
+
);
|
|
596
|
+
};
|
|
597
|
+
const botRows = [];
|
|
598
|
+
for (const bot of S.bots) {
|
|
599
|
+
const convs = visible.filter((c) => c.channel === "feishu" && c.channelId === bot.id);
|
|
600
|
+
if (bot.enabled === false && convs.length === 0) continue;
|
|
601
|
+
const latest = convs[0];
|
|
602
|
+
const expanded = sideState.botOpen.includes(bot.id);
|
|
603
|
+
const rows = [imGroupRow({
|
|
604
|
+
id: botGroupId(bot.id), channel: "feishu", name: bot.name, convs, expanded,
|
|
605
|
+
toggle: () => toggleSide("botOpen", bot.id), agent: bot.agents?.[0], attrs: { "data-bot": bot.id },
|
|
606
|
+
})];
|
|
595
607
|
if (expanded) {
|
|
596
608
|
const st = botState(bot.id);
|
|
597
609
|
const load = (limit) => fetchPage(st, { scope: "bot", bot: bot.id, limit: String(limit) });
|
|
@@ -612,12 +624,16 @@ export function renderSidebar() {
|
|
|
612
624
|
});
|
|
613
625
|
}
|
|
614
626
|
|
|
615
|
-
//
|
|
627
|
+
// 微信每个人一条对话,也使用 IM 分组;沿用旧排序键,升级后位置不变。
|
|
616
628
|
for (const c of visible.filter((c) => c.channel === "weixin")) {
|
|
617
629
|
const id = `weixin:${c.key}`;
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
630
|
+
const expanded = sideState.weixinOpen.includes(c.key);
|
|
631
|
+
const rows = [imGroupRow({
|
|
632
|
+
id, channel: "weixin", name: "微信", convs: [c], expanded,
|
|
633
|
+
toggle: () => toggleSide("weixinOpen", c.key),
|
|
634
|
+
})];
|
|
635
|
+
if (expanded) rows.push(convRow(c, " sub", `微信 · ${agentLabel(c.agent)} · ${c.cwd}`));
|
|
636
|
+
botRows.push({ id, at: c.activeAt, rows });
|
|
621
637
|
}
|
|
622
638
|
|
|
623
639
|
// ---- Web 会话直接按工作目录分组,目录按用户排的顺序(见 orderSidebarGroups) ----
|