agent-loft 0.2.81 → 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 CHANGED
@@ -55,17 +55,17 @@ Logo 就是这个意思:一大两小几颗星(多个 agent)站在同一张
55
55
  - 输入框里的小圆环显示上下文窗口占用;模型按钮显示实际的模型和思考程度(如「Opus 5.5 high」)。
56
56
  - 滚动和 ChatGPT 一样:发出的问题顶到最上面、下面留白,回复长到屏幕底部才跟着往下滚;回复过程中自己滚动了就不再自动滚,下次发消息再恢复。
57
57
  - 定时发送:右上角「更多」→「定时发送」,默认排在 5 小时额度重置后 5 分钟(弹窗里提示 5 小时 / 7 天额度的重置时间),由服务端到点发出,关掉页面也会发。适合额度用完、要等刷新才能接着干活的时候。
58
- - 侧栏直接显示各个文件夹,Web 会话按工作目录归类(目录可以拖动排序,右键可置顶;排好的顺序跟着账号走、各设备一致,新消息不会打乱),飞书会话按机器人分组,也能展开 / 折叠并记住状态(右键仍可看历史会话)。机器人行右侧平时显示飞书图标,鼠标悬停时切成加号;点击加号在 Web 开新对话,沿用最近飞书会话的专家和工作目录。项目名、机器人名和有分叉的会话后面有个小三角,点一下折叠 / 展开(分叉折叠后显示「N 个嵌套会话」);分叉出来的会话缩进挂在原会话下面,用一条细线连着;标题放不下时尾巴淡出;Web 和飞书会话都先用首条消息命名,再同步 agent 自动生成的标题,旧飞书会话会从历史记录补名,双击可手动重命名;鼠标移到会话上,行尾显示对应的专家图标;定时任务的时钟图标始终放在最右侧。
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 开始记录;本机直接使用的用量可回溯已有会话记录。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-loft",
3
- "version": "0.2.81",
3
+ "version": "0.2.82",
4
4
  "type": "module",
5
5
  "description": "多个 agent 的工作台:把本机 Claude Code / Codex 放到一处统一管理,用飞书和 Web 页面随时驱动——会话、审批、模型切换都共用",
6
6
  "keywords": [
@@ -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;
@@ -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 .feishu-mark,
268
+ .bot-new .channel-mark,
269
269
  .bot-new .bot-plus {
270
270
  grid-area: 1 / 1;
271
271
  }
272
272
 
273
- .bot-new .feishu-mark,
274
- .bot-new .feishu-mark svg {
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 .feishu-mark,
285
- .bot-row:focus-within .bot-new .feishu-mark {
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
 
@@ -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;
@@ -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 dir = e.target.closest?.("[data-dir]")?.dataset.dir;
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 = [
@@ -241,11 +241,11 @@ function agentShort(id) {
241
241
  return id === "claude" ? "Claude" : id === "codex" ? "Codex" : id;
242
242
  }
243
243
 
244
- /** 侧栏状态:order 混排目录路径和 feishu:<机器人 id>,兼容原有的目录顺序。 */
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
- * 项目和飞书分组共用 sideState.order,新消息不会改变分组位置。
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
- if (!sideState.botOpen.includes(cur.channelId)) {
551
- sideState.botOpen.push(cur.channelId);
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
- const botRows = [];
556
- for (const bot of S.bots) {
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 expanded = sideState.botOpen.includes(bot.id);
561
- const rows = [h(
561
+ const label = channel === "feishu" ? "飞书" : "微信";
562
+ return h(
562
563
  "div",
563
- { class: "proj-row bot-row", "data-bot": bot.id, ...groupDragAttrs(botGroupId(bot.id)) },
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: `飞书 · ${bot.name}\n拖动可调整顺序,右键更多操作`,
569
+ title: `${label} · ${name}\n拖动可调整顺序,右键更多操作`,
569
570
  "aria-expanded": String(expanded),
570
- onclick: () => toggleSide("botOpen", bot.id),
571
+ onclick: toggle,
571
572
  },
572
- h("span", { class: "title" }, bot.name),
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: `使用 ${bot.name} 的专家和工作目录开新对话`,
581
- "aria-label": `使用 ${bot.name} 的专家和工作目录开新对话`,
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 ?? bot.agents?.[0];
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: "brand-icon feishu-mark", html: ICON.feishu, "aria-hidden": "true" }),
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 row = convRow(c, "", `微信 · ${agentLabel(c.agent)} · ${c.cwd}`);
619
- row.prepend(h("span", { class: "brand-icon lead", html: ICON.weixin, "aria-hidden": "true" }));
620
- botRows.push({ id, at: c.activeAt, rows: [h("div", { class: "proj-row", ...groupDragAttrs(id) }, row)] });
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) ----