agent-loft 0.2.67 → 0.2.69
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 +5 -1
- package/package.json +1 -1
- package/src/channels/feishu/cards.ts +3 -2
- package/src/channels/web/api.ts +26 -10
- package/src/channels/web/experts-api.ts +12 -4
- package/src/core/albums.ts +49 -0
- package/src/core/expert-prompt.ts +12 -2
- package/src/core/experts.ts +3 -3
- package/src/core/hub.ts +7 -5
- package/src/core/reply-files.ts +4 -1
- package/src/core/servers.ts +5 -3
- package/src/core/task-runner.ts +4 -4
- package/src/core/ui-prefs.ts +3 -3
- package/src/core/users.ts +32 -8
- package/web/css/albums.css +40 -0
- package/web/css/settings.css +26 -0
- package/web/css/sidebar.css +1 -1
- package/web/index.html +1 -0
- package/web/lib/albums.js +128 -0
- package/web/lib/markdown.js +3 -3
- package/web/settings/agents.js +2 -1
- package/web/settings/security.js +11 -2
- package/web/settings/users.js +56 -4
- package/web/views/experts.js +5 -1
- package/web/views/file-preview.js +6 -2
- package/web/views/layout.js +12 -15
- package/web/views/sidebar.js +90 -81
- package/web/views/topbar.js +19 -9
package/web/views/sidebar.js
CHANGED
|
@@ -240,15 +240,15 @@ function agentShort(id) {
|
|
|
240
240
|
return id === "claude" ? "Claude" : id === "codex" ? "Codex" : id;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
/**
|
|
243
|
+
/** 侧栏状态:order 混排目录路径和 feishu:<机器人 id>,兼容原有的目录顺序。 */
|
|
244
244
|
export const sideState = { open: [], botOpen: [], more: [], folded: [], forkFolded: [], order: [], ...JSON.parse(localStorage.getItem("aim.side") || "{}") };
|
|
245
245
|
|
|
246
246
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
247
|
+
* 项目和飞书分组共用 sideState.order,新消息不会改变分组位置。
|
|
248
|
+
* 顺序存在服务端、跟着账号走(换设备也一样);新出现的分组接在最后,
|
|
249
249
|
* 接上之后名次也就定了
|
|
250
250
|
*/
|
|
251
|
-
function
|
|
251
|
+
function orderSidebarGroups(dirs) {
|
|
252
252
|
const rank = new Map(sideState.order.map((d, i) => [d, i]));
|
|
253
253
|
const ranked = dirs.filter((d) => rank.has(d)).sort((a, b) => rank.get(a) - rank.get(b));
|
|
254
254
|
const fresh = dirs.filter((d) => !rank.has(d));
|
|
@@ -277,42 +277,95 @@ async function putDirOrder(body) {
|
|
|
277
277
|
scheduleSidebar();
|
|
278
278
|
}
|
|
279
279
|
} catch (err) {
|
|
280
|
-
toast(
|
|
280
|
+
toast(`保存侧栏顺序失败:${err.message}`);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
/**
|
|
285
|
-
export
|
|
286
|
-
/** 同一批目录按最近活跃的顺序(「按最近活跃重排」用) */
|
|
287
|
-
let projDirsByActivity = [];
|
|
284
|
+
/** 飞书的排序键与绝对目录路径分开,改机器人名称不会影响位置。 */
|
|
285
|
+
export const botGroupId = (id) => `feishu:${id}`;
|
|
288
286
|
|
|
289
|
-
/**
|
|
290
|
-
export
|
|
287
|
+
/** 当前侧栏里显示的混合顺序(拖拽 / 右键菜单用) */
|
|
288
|
+
export let sidebarGroups = [];
|
|
289
|
+
/** 同一批分组按最近活跃的顺序(「按最近活跃重排」用) */
|
|
290
|
+
let groupsByActivity = [];
|
|
291
|
+
|
|
292
|
+
/** 移到另一个分组前 / 后;target 为 null 时置顶。隐藏的分组仍保留在已存顺序中。 */
|
|
293
|
+
export function moveSidebarGroup(dir, target, after = false) {
|
|
291
294
|
if (dir === target) return;
|
|
292
|
-
const list =
|
|
295
|
+
const list = sidebarGroups.filter((d) => d !== dir);
|
|
293
296
|
const idx = target === null ? 0 : list.indexOf(target);
|
|
294
297
|
if (idx < 0) return;
|
|
295
298
|
list.splice(idx + (after ? 1 : 0), 0, dir);
|
|
296
299
|
// 暂时没显示出来的目录(会话都被隐藏了之类)保留原来的名次,排在后面
|
|
297
|
-
|
|
300
|
+
setSidebarGroupOrder([...list, ...sideState.order.filter((d) => !list.includes(d))]);
|
|
298
301
|
}
|
|
299
302
|
|
|
300
303
|
/** 按最近活跃重排一次,之后照样固定 */
|
|
301
|
-
export function
|
|
302
|
-
|
|
304
|
+
export function resetSidebarGroupOrder() {
|
|
305
|
+
setSidebarGroupOrder([...groupsByActivity, ...sideState.order.filter((d) => !groupsByActivity.includes(d))]);
|
|
303
306
|
}
|
|
304
307
|
|
|
305
|
-
function
|
|
308
|
+
function setSidebarGroupOrder(order) {
|
|
306
309
|
sideState.order = order;
|
|
307
310
|
saveSideState();
|
|
308
311
|
if (orderSynced) void putDirOrder({ order });
|
|
309
312
|
renderSidebar();
|
|
310
313
|
}
|
|
311
314
|
|
|
312
|
-
/**
|
|
313
|
-
let
|
|
315
|
+
/** 拖动过程中暂停重绘,防止被拖的元素被替换;结束后补上更新。 */
|
|
316
|
+
let groupDrag = null;
|
|
314
317
|
let sidebarStale = false;
|
|
315
318
|
|
|
319
|
+
function groupDragAttrs(id) {
|
|
320
|
+
const clearDrop = () => ui.convList.querySelectorAll(".drop-before, .drop-after").forEach((el) => el.classList.remove("drop-before", "drop-after"));
|
|
321
|
+
const isAfter = (e) => {
|
|
322
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
323
|
+
return e.clientY > r.top + r.height / 2;
|
|
324
|
+
};
|
|
325
|
+
const endDrag = () => {
|
|
326
|
+
groupDrag = null;
|
|
327
|
+
clearDrop();
|
|
328
|
+
if (sidebarStale) renderSidebar();
|
|
329
|
+
};
|
|
330
|
+
return {
|
|
331
|
+
draggable: "true",
|
|
332
|
+
ondragstart: (e) => {
|
|
333
|
+
groupDrag = id;
|
|
334
|
+
e.dataTransfer.effectAllowed = "move";
|
|
335
|
+
e.dataTransfer.setData("text/plain", id);
|
|
336
|
+
e.currentTarget.classList.add("dragging");
|
|
337
|
+
stopMarquee();
|
|
338
|
+
},
|
|
339
|
+
ondragend: (e) => {
|
|
340
|
+
e.currentTarget.classList.remove("dragging");
|
|
341
|
+
endDrag();
|
|
342
|
+
},
|
|
343
|
+
ondragover: (e) => {
|
|
344
|
+
if (!groupDrag) return;
|
|
345
|
+
e.preventDefault();
|
|
346
|
+
e.dataTransfer.dropEffect = "move";
|
|
347
|
+
const after = isAfter(e);
|
|
348
|
+
if (!e.currentTarget.classList.contains(after ? "drop-after" : "drop-before")) {
|
|
349
|
+
clearDrop();
|
|
350
|
+
if (groupDrag !== id) e.currentTarget.classList.add(after ? "drop-after" : "drop-before");
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
ondragleave: (e) => {
|
|
354
|
+
if (!e.currentTarget.contains(e.relatedTarget)) e.currentTarget.classList.remove("drop-before", "drop-after");
|
|
355
|
+
},
|
|
356
|
+
ondrop: (e) => {
|
|
357
|
+
if (!groupDrag) return;
|
|
358
|
+
e.preventDefault();
|
|
359
|
+
const from = groupDrag;
|
|
360
|
+
const after = isAfter(e);
|
|
361
|
+
groupDrag = null;
|
|
362
|
+
clearDrop();
|
|
363
|
+
if (from !== id) moveSidebarGroup(from, id, after);
|
|
364
|
+
else if (sidebarStale) renderSidebar();
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
|
|
316
369
|
function toggleSide(list, id) {
|
|
317
370
|
const set = new Set(sideState[list]);
|
|
318
371
|
set.has(id) ? set.delete(id) : set.add(id);
|
|
@@ -450,7 +503,7 @@ export function reportDesktop() {
|
|
|
450
503
|
|
|
451
504
|
export function renderSidebar() {
|
|
452
505
|
if (!ui.convList) return;
|
|
453
|
-
if (
|
|
506
|
+
if (groupDrag) {
|
|
454
507
|
sidebarStale = true;
|
|
455
508
|
return;
|
|
456
509
|
}
|
|
@@ -490,8 +543,7 @@ export function renderSidebar() {
|
|
|
490
543
|
c.taskId ? h("span", { class: "brand-icon task-mark", title: "定时任务的对话", html: ICON.clock }) : null,
|
|
491
544
|
);
|
|
492
545
|
|
|
493
|
-
|
|
494
|
-
// 飞书机器人和项目一样展开会话,独立显示在文件夹后面。
|
|
546
|
+
// 飞书和项目共用排序,展开后的会话跟随所属分组。
|
|
495
547
|
if (cur?.channel === "feishu" && cur.key !== autoOpenedFor) {
|
|
496
548
|
autoOpenedFor = cur.key;
|
|
497
549
|
if (!sideState.botOpen.includes(cur.channelId)) {
|
|
@@ -507,12 +559,12 @@ export function renderSidebar() {
|
|
|
507
559
|
const expanded = sideState.botOpen.includes(bot.id);
|
|
508
560
|
const rows = [h(
|
|
509
561
|
"div",
|
|
510
|
-
{ class: "proj-row bot-row", "data-bot": bot.id },
|
|
562
|
+
{ class: "proj-row bot-row", "data-bot": bot.id, ...groupDragAttrs(botGroupId(bot.id)) },
|
|
511
563
|
h(
|
|
512
564
|
"button",
|
|
513
565
|
{
|
|
514
566
|
class: "conv-item proj",
|
|
515
|
-
title: `飞书 · ${bot.name}
|
|
567
|
+
title: `飞书 · ${bot.name}\n拖动可调整顺序,右键更多操作`,
|
|
516
568
|
"aria-expanded": String(expanded),
|
|
517
569
|
onclick: () => toggleSide("botOpen", bot.id),
|
|
518
570
|
},
|
|
@@ -553,12 +605,13 @@ export function renderSidebar() {
|
|
|
553
605
|
if (btn) rows.push(h("div", { class: "sub-more" }, btn));
|
|
554
606
|
}
|
|
555
607
|
botRows.push({
|
|
608
|
+
id: botGroupId(bot.id),
|
|
556
609
|
at: latest?.activeAt ?? 0,
|
|
557
610
|
rows,
|
|
558
611
|
});
|
|
559
612
|
}
|
|
560
613
|
|
|
561
|
-
// ---- Web 会话直接按工作目录分组,目录按用户排的顺序(见
|
|
614
|
+
// ---- Web 会话直接按工作目录分组,目录按用户排的顺序(见 orderSidebarGroups) ----
|
|
562
615
|
const byDir = new Map();
|
|
563
616
|
for (const c of visible.filter((c) => c.channel === "web")) {
|
|
564
617
|
if (!byDir.has(c.cwd)) byDir.set(c.cwd, []);
|
|
@@ -575,65 +628,21 @@ export function renderSidebar() {
|
|
|
575
628
|
// 目录行要全部显示:服务端给了每个目录最近的活跃时间,加上本地已有的(刚建的、刚变活跃的)
|
|
576
629
|
const dirAt = new Map(pages.dirAt);
|
|
577
630
|
for (const [dir, convs] of byDir) dirAt.set(dir, Math.max(dirAt.get(dir) ?? 0, convs[0].activeAt));
|
|
578
|
-
|
|
579
|
-
|
|
631
|
+
const dirsByActivity = [...dirAt.keys()].sort((a, b) => dirAt.get(b) - dirAt.get(a));
|
|
632
|
+
const groupRows = new Map(botRows.map((group) => [group.id, group.rows]));
|
|
633
|
+
const groupAt = new Map([...dirAt, ...botRows.map((group) => [group.id, group.at])]);
|
|
634
|
+
groupsByActivity = [...groupAt.keys()].sort((a, b) => groupAt.get(b) - groupAt.get(a));
|
|
635
|
+
sidebarGroups = orderSidebarGroups([...dirsByActivity, ...botRows.sort((a, b) => b.at - a.at).map((group) => group.id)]);
|
|
580
636
|
if (dirAt.size) {
|
|
581
|
-
|
|
582
|
-
const endDrag = () => {
|
|
583
|
-
dirDrag = null;
|
|
584
|
-
clearDrop();
|
|
585
|
-
if (sidebarStale) renderSidebar();
|
|
586
|
-
};
|
|
587
|
-
for (const dir of projDirs) {
|
|
637
|
+
for (const dir of dirsByActivity) {
|
|
588
638
|
const convs = byDir.get(dir) ?? [];
|
|
589
639
|
const expanded = sideState.open.includes(dir);
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
return e.clientY > r.top + r.height / 2;
|
|
594
|
-
};
|
|
595
|
-
nodes.push(
|
|
640
|
+
const rows = [];
|
|
641
|
+
groupRows.set(dir, rows);
|
|
642
|
+
rows.push(
|
|
596
643
|
h(
|
|
597
644
|
"div",
|
|
598
|
-
{
|
|
599
|
-
class: "proj-row",
|
|
600
|
-
"data-dir": dir,
|
|
601
|
-
draggable: "true",
|
|
602
|
-
ondragstart: (e) => {
|
|
603
|
-
dirDrag = dir;
|
|
604
|
-
e.dataTransfer.effectAllowed = "move";
|
|
605
|
-
e.dataTransfer.setData("text/plain", dir);
|
|
606
|
-
e.currentTarget.classList.add("dragging");
|
|
607
|
-
stopMarquee();
|
|
608
|
-
},
|
|
609
|
-
ondragend: (e) => {
|
|
610
|
-
e.currentTarget.classList.remove("dragging");
|
|
611
|
-
endDrag();
|
|
612
|
-
},
|
|
613
|
-
ondragover: (e) => {
|
|
614
|
-
if (!dirDrag) return;
|
|
615
|
-
e.preventDefault();
|
|
616
|
-
e.dataTransfer.dropEffect = "move";
|
|
617
|
-
const after = isAfter(e, e.currentTarget);
|
|
618
|
-
if (!e.currentTarget.classList.contains(after ? "drop-after" : "drop-before")) {
|
|
619
|
-
clearDrop();
|
|
620
|
-
if (dirDrag !== dir) e.currentTarget.classList.add(after ? "drop-after" : "drop-before");
|
|
621
|
-
}
|
|
622
|
-
},
|
|
623
|
-
ondragleave: (e) => {
|
|
624
|
-
if (!e.currentTarget.contains(e.relatedTarget)) e.currentTarget.classList.remove("drop-before", "drop-after");
|
|
625
|
-
},
|
|
626
|
-
ondrop: (e) => {
|
|
627
|
-
if (!dirDrag) return;
|
|
628
|
-
e.preventDefault();
|
|
629
|
-
const from = dirDrag;
|
|
630
|
-
const after = isAfter(e, e.currentTarget);
|
|
631
|
-
dirDrag = null;
|
|
632
|
-
clearDrop();
|
|
633
|
-
if (from !== dir) moveProjectDir(from, dir, after);
|
|
634
|
-
else if (sidebarStale) renderSidebar();
|
|
635
|
-
},
|
|
636
|
-
},
|
|
645
|
+
{ class: "proj-row", "data-dir": dir, ...groupDragAttrs(dir) },
|
|
637
646
|
h(
|
|
638
647
|
"button",
|
|
639
648
|
{ class: "conv-item proj", title: `${dir}\n拖动可调整顺序,右键可置顶`, onclick: () => toggleSide("open", dir) },
|
|
@@ -684,13 +693,13 @@ export function renderSidebar() {
|
|
|
684
693
|
// 「展开显示」按主对话算条数,分叉跟着主对话一起出现
|
|
685
694
|
const forest = loadedPrefix(st, forkForest(convs));
|
|
686
695
|
for (const node of forest.slice(0, st.show)) {
|
|
687
|
-
|
|
696
|
+
rows.push(renderForkNode(node, (c, orphan, fold) => convRow(c, " sub", agentLabel(c.agent), orphan, fold)));
|
|
688
697
|
}
|
|
689
698
|
const btn = moreButton(st, forest.length, PROJECT_LIMIT, load);
|
|
690
|
-
if (btn)
|
|
699
|
+
if (btn) rows.push(h("div", { class: "sub-more" }, btn));
|
|
691
700
|
}
|
|
692
701
|
}
|
|
693
|
-
nodes.
|
|
702
|
+
const nodes = sidebarGroups.flatMap((id) => groupRows.get(id) ?? []);
|
|
694
703
|
if (!nodes.length) nodes.push(h("div", { class: "conv-empty" }, "还没有会话"));
|
|
695
704
|
paintList(nodes, askKeys.size);
|
|
696
705
|
}
|
package/web/views/topbar.js
CHANGED
|
@@ -146,6 +146,8 @@ function topMenuItems() {
|
|
|
146
146
|
const items = [];
|
|
147
147
|
if (!S.view) {
|
|
148
148
|
items.push({ id: "schedule", label: "定时发送", icon: "clock", onclick: () => openSchedule() });
|
|
149
|
+
const actions = convMenuItems(S.current);
|
|
150
|
+
if (actions.length) items.push("sep", ...actions);
|
|
149
151
|
}
|
|
150
152
|
return items;
|
|
151
153
|
}
|
|
@@ -163,7 +165,7 @@ function openTopMore(anchor) {
|
|
|
163
165
|
? h("div", { class: "sep" })
|
|
164
166
|
: h(
|
|
165
167
|
"button",
|
|
166
|
-
{ class: `pop-item${it.checked ? " on" : ""}`, onclick: () => (closeMenu(), it.onclick()) },
|
|
168
|
+
{ class: `pop-item${it.checked ? " on" : ""}${it.danger ? " danger" : ""}`, onclick: () => (closeMenu(), it.onclick()) },
|
|
167
169
|
icon(it.icon),
|
|
168
170
|
h("span", { class: "grow" }, it.label),
|
|
169
171
|
it.checked ? h("span", { class: "check" }, "✓") : null,
|
|
@@ -473,13 +475,15 @@ export function updateCtxVisibility() {
|
|
|
473
475
|
if (ui.ctxBar) ui.ctxBar.hidden = !!S.current && (S.items.length > 0 || sentKeys.has(S.current));
|
|
474
476
|
}
|
|
475
477
|
|
|
476
|
-
/**
|
|
477
|
-
|
|
478
|
+
/** 顶栏和侧栏共用的会话操作,显示条件和行为保持一致。 */
|
|
479
|
+
function convMenuItems(key) {
|
|
478
480
|
const c = S.convs.get(key);
|
|
479
|
-
if (!c) return;
|
|
480
|
-
|
|
481
|
+
if (!c) return [];
|
|
482
|
+
return [
|
|
481
483
|
{
|
|
484
|
+
id: "fork",
|
|
482
485
|
label: "分叉",
|
|
486
|
+
icon: "fork",
|
|
483
487
|
onclick: async () => {
|
|
484
488
|
if (c.canFork) return forkConversation(undefined, key);
|
|
485
489
|
// 不支持另开一条的:只能在原对话里分叉,先切过去
|
|
@@ -487,10 +491,16 @@ export function openConvContextMenu(key, at) {
|
|
|
487
491
|
await doAction("fork");
|
|
488
492
|
},
|
|
489
493
|
},
|
|
490
|
-
{ label: "重命名", onclick: () => renameConv(key) },
|
|
491
|
-
...(c.channel === "web" && S.bots.length > 0 ? [{ label: "
|
|
492
|
-
...(c.channel === "web" ? [{ label: "删除", danger: true, onclick: () => deleteConv(key) }] : []),
|
|
493
|
-
]
|
|
494
|
+
{ id: "rename", label: "重命名", icon: "edit", onclick: () => renameConv(key) },
|
|
495
|
+
...(c.channel === "web" && S.bots.length > 0 ? [{ id: "feishu", label: "在飞书继续", icon: "feishu", onclick: () => continueInFeishu(key) }] : []),
|
|
496
|
+
...(c.channel === "web" ? [{ id: "delete", label: "删除", icon: "trash", danger: true, onclick: () => deleteConv(key) }] : []),
|
|
497
|
+
];
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/** 侧栏会话的右键菜单 */
|
|
501
|
+
export function openConvContextMenu(key, at) {
|
|
502
|
+
const items = convMenuItems(key);
|
|
503
|
+
if (items.length) showMenu(at, items);
|
|
494
504
|
}
|
|
495
505
|
|
|
496
506
|
/**
|