agent-loft 0.2.59 → 0.2.61
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 +12 -9
- package/package.json +2 -2
- package/src/channels/web/api.ts +31 -5
- package/src/channels/web/library-api.ts +59 -0
- package/src/core/chat-history.ts +92 -71
- package/src/core/claude-model-prices.json +23 -0
- package/src/core/db.ts +367 -0
- package/src/core/experts.ts +60 -2
- package/src/core/footers.ts +21 -43
- package/src/core/hub.ts +3 -16
- package/src/core/library.ts +401 -0
- package/src/core/local-usage.ts +275 -0
- package/src/core/memory.ts +34 -60
- package/src/core/store.ts +47 -19
- package/src/core/uploads.ts +3 -46
- package/src/core/usage.ts +63 -73
- package/src/main.ts +7 -6
- package/src/mcp/memory-server.ts +4 -7
- package/web/css/library.css +266 -0
- package/web/index.html +1 -0
- package/web/lib/dom.js +2 -0
- package/web/settings/usage.js +9 -3
- package/web/state.js +3 -3
- package/web/views/composer.js +36 -1
- package/web/views/layout.js +11 -0
- package/web/views/library.js +309 -0
- package/web/views/messages.js +3 -3
- package/web/views/remote.js +2 -1
- package/web/views/sidebar.js +1 -0
- package/web/views/topbar.js +3 -2
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/* ---------- 资料库 ---------- */
|
|
2
|
+
/* 页面沿用定时任务页的外框(.tasks-page / .tasks-head),这里只管文件网格。弹窗「从资料库选」用同一套 */
|
|
3
|
+
|
|
4
|
+
.lib-page .tasks-head p .lib-status {
|
|
5
|
+
margin-left: 6px;
|
|
6
|
+
color: var(--fg-faint);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.lib-browser {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: 14px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.lib-bar {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
gap: 12px;
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.lib-tabs {
|
|
23
|
+
display: flex;
|
|
24
|
+
gap: 4px;
|
|
25
|
+
padding: 3px;
|
|
26
|
+
background: var(--bg-soft);
|
|
27
|
+
border-radius: 10px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.lib-tab {
|
|
31
|
+
padding: 5px 12px;
|
|
32
|
+
border: none;
|
|
33
|
+
border-radius: 8px;
|
|
34
|
+
background: transparent;
|
|
35
|
+
color: var(--fg-soft);
|
|
36
|
+
font: inherit;
|
|
37
|
+
font-size: 13px;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.lib-tab.active {
|
|
42
|
+
background: var(--bg);
|
|
43
|
+
color: var(--fg);
|
|
44
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.lib-search {
|
|
48
|
+
flex: 1;
|
|
49
|
+
min-width: 160px;
|
|
50
|
+
max-width: 280px;
|
|
51
|
+
margin-left: auto;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.lib-grid {
|
|
55
|
+
display: grid;
|
|
56
|
+
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
|
57
|
+
gap: 12px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.lib-empty {
|
|
61
|
+
grid-column: 1 / -1;
|
|
62
|
+
display: flex;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
padding: 48px 12px;
|
|
65
|
+
color: var(--fg-faint);
|
|
66
|
+
font-size: 14px;
|
|
67
|
+
text-align: center;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.lib-tile {
|
|
71
|
+
position: relative;
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
min-width: 0;
|
|
75
|
+
border: 1px solid var(--border);
|
|
76
|
+
border-radius: 12px;
|
|
77
|
+
background: var(--bg);
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.lib-tile.selected {
|
|
82
|
+
border-color: var(--accent);
|
|
83
|
+
box-shadow: 0 0 0 1px var(--accent);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.lib-thumb {
|
|
87
|
+
display: grid;
|
|
88
|
+
place-items: center;
|
|
89
|
+
aspect-ratio: 4 / 3;
|
|
90
|
+
width: 100%;
|
|
91
|
+
padding: 0;
|
|
92
|
+
border: none;
|
|
93
|
+
background: var(--bg-soft);
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.lib-thumb img {
|
|
99
|
+
width: 100%;
|
|
100
|
+
height: 100%;
|
|
101
|
+
object-fit: cover;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.lib-ext {
|
|
105
|
+
font-size: 15px;
|
|
106
|
+
font-weight: 600;
|
|
107
|
+
letter-spacing: 0.04em;
|
|
108
|
+
color: var(--fg-soft);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.lib-meta {
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
gap: 2px;
|
|
115
|
+
padding: 8px 10px 9px;
|
|
116
|
+
min-width: 0;
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.lib-name {
|
|
121
|
+
font-size: 13px;
|
|
122
|
+
white-space: nowrap;
|
|
123
|
+
overflow: hidden;
|
|
124
|
+
text-overflow: ellipsis;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.lib-sub,
|
|
128
|
+
.lib-conv {
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
gap: 6px;
|
|
132
|
+
font-size: 12px;
|
|
133
|
+
color: var(--fg-faint);
|
|
134
|
+
white-space: nowrap;
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
text-overflow: ellipsis;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.lib-conv {
|
|
140
|
+
display: block;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.lib-badge {
|
|
144
|
+
flex: none;
|
|
145
|
+
padding: 0 5px;
|
|
146
|
+
border-radius: 4px;
|
|
147
|
+
background: var(--ask-bg);
|
|
148
|
+
color: var(--fg-soft);
|
|
149
|
+
font-size: 11px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* 右上角:菜单按钮(鼠标停上去才出来,触屏一直在)、选择框 */
|
|
153
|
+
.lib-menu {
|
|
154
|
+
position: absolute;
|
|
155
|
+
top: 6px;
|
|
156
|
+
right: 6px;
|
|
157
|
+
width: 28px;
|
|
158
|
+
height: 28px;
|
|
159
|
+
background: var(--bg);
|
|
160
|
+
border-radius: 8px;
|
|
161
|
+
box-shadow: var(--shadow);
|
|
162
|
+
opacity: 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.lib-tile:hover .lib-menu,
|
|
166
|
+
.lib-menu:focus-visible {
|
|
167
|
+
opacity: 1;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@media (pointer: coarse) {
|
|
171
|
+
.lib-menu {
|
|
172
|
+
opacity: 1;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.lib-check {
|
|
177
|
+
position: absolute;
|
|
178
|
+
top: 8px;
|
|
179
|
+
left: 8px;
|
|
180
|
+
display: grid;
|
|
181
|
+
place-items: center;
|
|
182
|
+
width: 22px;
|
|
183
|
+
height: 22px;
|
|
184
|
+
border: 2px solid #fff;
|
|
185
|
+
border-radius: 50%;
|
|
186
|
+
background: rgba(0, 0, 0, 0.25);
|
|
187
|
+
color: #fff;
|
|
188
|
+
cursor: pointer;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.lib-tile.selected .lib-check {
|
|
192
|
+
background: var(--accent);
|
|
193
|
+
border-color: var(--accent);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.lib-check svg {
|
|
197
|
+
width: 14px;
|
|
198
|
+
height: 14px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.lib-more {
|
|
202
|
+
align-self: center;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.lib-more[hidden] {
|
|
206
|
+
display: none;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/* 选择模式下贴在页面底部的操作条 */
|
|
210
|
+
.lib-selbar {
|
|
211
|
+
position: sticky;
|
|
212
|
+
bottom: 12px;
|
|
213
|
+
display: flex;
|
|
214
|
+
align-items: center;
|
|
215
|
+
gap: 8px;
|
|
216
|
+
padding: 10px 12px;
|
|
217
|
+
border: 1px solid var(--border);
|
|
218
|
+
border-radius: 12px;
|
|
219
|
+
background: var(--bg);
|
|
220
|
+
box-shadow: var(--shadow);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.lib-selbar[hidden] {
|
|
224
|
+
display: none;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.lib-selbar .grow {
|
|
228
|
+
flex: 1;
|
|
229
|
+
font-size: 13px;
|
|
230
|
+
color: var(--fg-soft);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* 弹窗:网格在中间滚,筛选条和底部按钮不动 */
|
|
234
|
+
.lib-pick .modal-body {
|
|
235
|
+
flex: 1;
|
|
236
|
+
display: flex;
|
|
237
|
+
flex-direction: column;
|
|
238
|
+
min-height: 0;
|
|
239
|
+
overflow: auto;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.lib-pick .modal-foot {
|
|
243
|
+
align-items: center;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.lib-pick .lib-grid {
|
|
247
|
+
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.lib-pick .modal-foot .grow {
|
|
251
|
+
font-size: 13px;
|
|
252
|
+
color: var(--fg-faint);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* 窄屏:搜索框换到下一行时占满一行 */
|
|
256
|
+
@media (max-width: 600px) {
|
|
257
|
+
.lib-search {
|
|
258
|
+
flex-basis: 100%;
|
|
259
|
+
max-width: none;
|
|
260
|
+
margin-left: 0;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.lib-grid {
|
|
264
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
265
|
+
}
|
|
266
|
+
}
|
package/web/index.html
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
<link rel="stylesheet" href="/css/schedule.css" />
|
|
28
28
|
<link rel="stylesheet" href="/css/todos.css" />
|
|
29
29
|
<link rel="stylesheet" href="/css/tasks.css" />
|
|
30
|
+
<link rel="stylesheet" href="/css/library.css" />
|
|
30
31
|
<link rel="stylesheet" href="/css/skills.css" />
|
|
31
32
|
<link rel="stylesheet" href="/css/experts.css" />
|
|
32
33
|
<link rel="stylesheet" href="/css/terminal.css" />
|
package/web/lib/dom.js
CHANGED
|
@@ -47,6 +47,8 @@ export const ICON = {
|
|
|
47
47
|
x: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M18 6 6 18M6 6l12 12"/></svg>',
|
|
48
48
|
plus: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M12 5v14M5 12h14"/></svg>',
|
|
49
49
|
trash: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M8 6V4h8v2"/><path d="M19 6l-1 14H6L5 6"/><path d="M10 11v6M14 11v6"/></svg>',
|
|
50
|
+
library: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="7" width="14" height="14" rx="2"/><path d="M7 3h12a2 2 0 0 1 2 2v12"/><path d="m3 17 4-4 3 3 2-2 5 5"/></svg>',
|
|
51
|
+
check: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>',
|
|
50
52
|
folder: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7.5A2.5 2.5 0 0 1 5.5 5h3.6l2 2.2h7.4A2.5 2.5 0 0 1 21 9.7v7.8a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 17.5Z"/><path d="M3 10h18"/></svg>',
|
|
51
53
|
folderOpen: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 17.5V7.5A2.5 2.5 0 0 1 5.5 5h3.6l2 2.2h6.4A2.5 2.5 0 0 1 20 9.7V11"/><path d="M3 17.5 5.6 12a2 2 0 0 1 1.8-1.1h13a1 1 0 0 1 .9 1.4l-2.4 6.2a2.2 2.2 0 0 1-2 1.5H5.5A2.5 2.5 0 0 1 3 17.5Z"/></svg>',
|
|
52
54
|
terminal: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="m7 9 3 3-3 3M13 15h4"/></svg>',
|
package/web/settings/usage.js
CHANGED
|
@@ -135,7 +135,8 @@ export async function usageTab(panel) {
|
|
|
135
135
|
const note = h(
|
|
136
136
|
"div",
|
|
137
137
|
{ class: "muted" },
|
|
138
|
-
"金额都是按 API 价格算的参考值,订阅用户实际不按这个扣费:Claude 用它自己报的费用;Codex
|
|
138
|
+
"金额都是按 API 价格算的参考值,订阅用户实际不按这个扣费:Agent Loft 的 Claude 用它自己报的费用;Codex 和直接使用的 Claude Code 按模型单价 × Token 估算。Agent Loft 的用量从启用记账起记录。",
|
|
139
|
+
data.localUsageIncluded ? " 包含服务端运行用户下 Claude Code、Codex 桌面端和 CLI 的历史会话记录,按服务器时区统计,Agent Loft 跑的会话不重复算;本机直接用量仅管理员可见。" : "",
|
|
139
140
|
unpriced ? ` 有 ${fmtCount(unpriced)} Token 认不出模型单价,没算进金额。` : "",
|
|
140
141
|
);
|
|
141
142
|
if (!tokens) {
|
|
@@ -178,10 +179,15 @@ export async function usageTab(panel) {
|
|
|
178
179
|
);
|
|
179
180
|
|
|
180
181
|
const agentName = (id) => S.agents.find((a) => a.id === id)?.label ?? id;
|
|
181
|
-
const
|
|
182
|
+
const sourceNames = { desktop: "桌面端", cli: "CLI", other: "其他" };
|
|
183
|
+
const hasLocal = rows.some((r) => r.source);
|
|
184
|
+
const byAgent = groupBy(rows, (r) => `${r.agent}\n${r.source ?? ""}`).map((g) => {
|
|
185
|
+
const [agent, source] = g.key.split("\n");
|
|
186
|
+
return { ...g, label: `${agentName(agent)}${source ? ` ${sourceNames[source] ?? source}` : hasLocal ? " · Agent Loft" : ""}` };
|
|
187
|
+
});
|
|
182
188
|
const byModel = groupBy(rows, (r) => r.model ?? "").map((g) => ({ ...g, label: g.key || "未记录模型" }));
|
|
183
189
|
const byUser = data.admin
|
|
184
|
-
? groupBy(rows, (r) => r.owner ?? "").map((g) => ({ ...g, label: g.key ? data.users[g.key] : "未归属(飞书等)" }))
|
|
190
|
+
? groupBy(rows.filter((r) => !r.source), (r) => r.owner ?? "").map((g) => ({ ...g, label: g.key ? data.users[g.key] : "未归属(飞书等)" }))
|
|
185
191
|
: [];
|
|
186
192
|
|
|
187
193
|
fill(
|
package/web/state.js
CHANGED
|
@@ -30,7 +30,7 @@ export const S = {
|
|
|
30
30
|
remote: null,
|
|
31
31
|
/** 远程控制在后台连着的:桌面连着没、开着几个终端(侧栏「远程控制」上的小绿点) */
|
|
32
32
|
remoteLive: { desktop: false, terminals: 0 },
|
|
33
|
-
/** 主区域在显示什么:null 是对话(或新对话),"tasks" 是定时任务页,"remote" 是远程控制 */
|
|
33
|
+
/** 主区域在显示什么:null 是对话(或新对话),"tasks" 是定时任务页,"library" 是资料库,"remote" 是远程控制 */
|
|
34
34
|
view: null,
|
|
35
35
|
};
|
|
36
36
|
|
|
@@ -57,8 +57,8 @@ export const desktopQuota = typeof desktop?.onQuota === "function";
|
|
|
57
57
|
// 桌面端里:顶栏、侧栏顶部可以按住拖动窗口(样式见 css/topbar.css 的 .in-desktop)
|
|
58
58
|
if (desktop) document.documentElement.classList.add("in-desktop");
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
60
|
+
* 桌面端 0.1.18 及以前的顶栏能打开每台服务器的设置(「更多」或设置按钮的菜单里):页面「更多」里的设置就不放了。
|
|
61
|
+
* 更老的和 0.1.19 起的桌面端没有这个入口(不给 onOpenSettings),照旧放。
|
|
62
62
|
*/
|
|
63
63
|
export const desktopSettings = typeof desktop?.onOpenSettings === "function";
|
|
64
64
|
/**
|
package/web/views/composer.js
CHANGED
|
@@ -10,6 +10,7 @@ import { renderTodos } from "./todos.js";
|
|
|
10
10
|
import { cancelVoice, SpeechRec, toggleVoice } from "./voice.js";
|
|
11
11
|
import { closeSlashMenu, commandUsage, oneLine, slashKeydown, updateSlashMenu } from "./slash.js";
|
|
12
12
|
import { doAction, openModelPicker, openSessions } from "./conv-actions.js";
|
|
13
|
+
import { showMenu } from "../lib/overlay.js";
|
|
13
14
|
|
|
14
15
|
// ---------- 输入框 ----------
|
|
15
16
|
|
|
@@ -95,7 +96,7 @@ export function renderComposer() {
|
|
|
95
96
|
h(
|
|
96
97
|
"div",
|
|
97
98
|
{ class: "composer-row" },
|
|
98
|
-
h("button", { class: "icon-btn add-btn", title: "添加附件", onclick: () =>
|
|
99
|
+
h("button", { class: "icon-btn add-btn", title: "添加附件", onclick: (e) => openAddMenu(e.currentTarget) }, icon("plus")),
|
|
99
100
|
ui.fileInput,
|
|
100
101
|
h("span", { class: "spacer" }),
|
|
101
102
|
ui.ctxRing,
|
|
@@ -246,6 +247,40 @@ export async function ensureConversation() {
|
|
|
246
247
|
return info.key;
|
|
247
248
|
}
|
|
248
249
|
|
|
250
|
+
/** 「+」:上传本机的文件,或者从资料库里挑 */
|
|
251
|
+
function openAddMenu(anchor) {
|
|
252
|
+
showMenu(anchor, [
|
|
253
|
+
{ label: "上传文件", onclick: () => ui.fileInput.click() },
|
|
254
|
+
{
|
|
255
|
+
label: "从资料库选",
|
|
256
|
+
onclick: () =>
|
|
257
|
+
import("./library.js").then(
|
|
258
|
+
(m) => m.pickFromLibrary(),
|
|
259
|
+
(err) => toast(`资料库加载失败,刷新页面再试:${err.message}`),
|
|
260
|
+
),
|
|
261
|
+
},
|
|
262
|
+
]);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** 资料库里的文件放进输入框:服务端放进这条对话的上传目录,领到和上传一样的编号 */
|
|
266
|
+
export async function attachLibraryFiles(ids) {
|
|
267
|
+
if (!ids.length) return;
|
|
268
|
+
let key;
|
|
269
|
+
try {
|
|
270
|
+
key = await ensureConversation();
|
|
271
|
+
} catch (err) {
|
|
272
|
+
toast(err.message);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
const res = await api(`/api/conversations/${encodeURIComponent(key)}/attach`, { method: "POST", body: { ids } });
|
|
277
|
+
for (const u of res.uploads) S.uploads.push({ id: u.id, name: u.name, kind: u.kind, serverName: u.name, ...(u.url ? { url: u.url } : {}) });
|
|
278
|
+
} catch (err) {
|
|
279
|
+
toast(`添加失败:${err.message}`);
|
|
280
|
+
}
|
|
281
|
+
renderChips();
|
|
282
|
+
}
|
|
283
|
+
|
|
249
284
|
async function addFiles(files) {
|
|
250
285
|
if (!files.length) return;
|
|
251
286
|
let key;
|
package/web/views/layout.js
CHANGED
|
@@ -120,6 +120,14 @@ export function openTasksView() {
|
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/** 资料库页:第一次打开时才加载 */
|
|
124
|
+
export function openLibraryView() {
|
|
125
|
+
import("./library.js").then(
|
|
126
|
+
(m) => m.openLibrary(),
|
|
127
|
+
(err) => toast(`资料库加载失败,刷新页面再试:${err.message}`),
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
123
131
|
export async function boot() {
|
|
124
132
|
const me = await api("/api/me");
|
|
125
133
|
if (!me.authed) return showAuth();
|
|
@@ -157,6 +165,7 @@ export async function boot() {
|
|
|
157
165
|
// 地址里带了会话就打开它;否则打开「最近」里最近活跃的那个对话,一个都没有才进新对话页
|
|
158
166
|
const latest = [...S.convs.values()].filter((c) => !c.hidden).sort((a, b) => b.activeAt - a.activeAt)[0];
|
|
159
167
|
if (fromHash === "tasks") openTasksView();
|
|
168
|
+
else if (fromHash === "library") openLibraryView();
|
|
160
169
|
else if (fromHash.startsWith("remote") && remoteTabs().length) {
|
|
161
170
|
// 刷新前在远程控制里:底下先放上最近的对话,切回对话时就是它
|
|
162
171
|
if (latest) await openConversation(latest.key);
|
|
@@ -271,6 +280,8 @@ function renderLayout() {
|
|
|
271
280
|
h("button", { class: "btn new-chat side-nav search-nav", onclick: () => openSearch() }, icon("search"), "搜索"),
|
|
272
281
|
// 「最近」上面的入口,像 ChatGPT 的 Tasks。当前在任务页时高亮(renderSidebar 里切换)
|
|
273
282
|
(ui.tasksNav = h("button", { class: "btn new-chat side-nav", onclick: () => openTasksView() }, icon("clock"), "定时任务")),
|
|
283
|
+
// 资料库:发过的附件、agent 生成的文件
|
|
284
|
+
(ui.libraryNav = h("button", { class: "btn new-chat side-nav", onclick: () => openLibraryView() }, icon("library"), "资料库")),
|
|
274
285
|
// 远程控制:这台机器的桌面和终端。后台连着时右边亮个小绿点(renderSidebar 里切换)
|
|
275
286
|
(ui.remoteNav = h(
|
|
276
287
|
"button",
|