agent-loft 0.2.133 → 0.2.134
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 +29 -29
- package/package.json +1 -1
- package/src/agents/dsh/errors.ts +2 -2
- package/src/agents/pi/constants.ts +1 -1
- package/src/agents/pi/errors.ts +2 -2
- package/src/agents/workbuddy/errors.ts +2 -2
- package/src/agents/workbuddy/sdk.ts +1 -1
- package/src/channels/feishu/bot.ts +3 -3
- package/src/channels/feishu/cards.ts +2 -2
- package/src/channels/web/desktop.ts +1 -1
- package/src/channels/web/terminal.ts +1 -1
- package/src/channels/web/workspace-api.ts +2 -2
- package/src/channels/weixin/bot.ts +1 -1
- package/src/core/command-catalog.ts +1 -1
- package/src/core/commands.ts +1 -1
- package/src/core/feishu-links.ts +1 -1
- package/src/core/hub.ts +1 -1
- package/src/core/memory-curator.ts +1 -1
- package/src/core/ui-prefs.ts +1 -1
- package/src/mcp/memory-server.ts +1 -1
- package/web/css/mobile.css +8 -31
- package/web/css/settings.css +53 -32
- package/web/lib/push.js +1 -1
- package/web/lib/shell.js +1 -1
- package/web/settings/agent-defaults.js +2 -16
- package/web/settings/agents.js +119 -95
- package/web/settings/commands.js +3 -4
- package/web/settings/experts.js +10 -9
- package/web/settings/feishu.js +3 -3
- package/web/settings/general.js +17 -14
- package/web/settings/index.js +177 -94
- package/web/settings/memory.js +50 -35
- package/web/settings/notify.js +1 -1
- package/web/settings/security.js +9 -3
- package/web/settings/servers.js +3 -3
- package/web/settings/skills.js +6 -4
- package/web/settings/tabs.js +61 -51
- package/web/settings/users.js +3 -7
- package/web/state.js +2 -2
- package/web/views/layout.js +4 -4
- package/web/views/memo-dialogs.js +1 -1
- package/web/views/sidebar-nav.js +2 -1
- package/web/views/tasks.js +1 -1
package/web/settings/general.js
CHANGED
|
@@ -5,10 +5,10 @@ import { field, saveButton, saveConfig } from "./common.js";
|
|
|
5
5
|
|
|
6
6
|
/** 设置 → 对话:所有会话共用的规矩——在哪个目录、多久算新会话、授权卡等多久、Claude 的「总是允许」 */
|
|
7
7
|
export async function conversationTab(cfg, page) {
|
|
8
|
-
const root = h("input", { value: cfg.workspaceRoot });
|
|
8
|
+
const root = h("input", { "data-section": "workspace", value: cfg.workspaceRoot });
|
|
9
9
|
const ttl = h("input", { type: "number", min: 0, value: Math.round(cfg.sessionTtlMs / 3600000) });
|
|
10
|
-
const approval = h("input", { type: "number", min: 1, value: Math.round(cfg.approvalTimeoutMs / 60000) });
|
|
11
|
-
const allowBox = h("div", { class: "section", "data-form": "" }, h("h4", {}, "Claude「总是允许」名单"), h("span", { class: "spinner" }));
|
|
10
|
+
const approval = h("input", { type: "number", "data-section": "approval", min: 1, value: Math.round(cfg.approvalTimeoutMs / 60000) });
|
|
11
|
+
const allowBox = h("div", { class: "section", "data-section": "allowlist", "data-form": "" }, h("h4", {}, "Claude「总是允许」名单"), h("span", { class: "spinner" }));
|
|
12
12
|
page.append(
|
|
13
13
|
h(
|
|
14
14
|
"div",
|
|
@@ -25,7 +25,7 @@ export async function conversationTab(cfg, page) {
|
|
|
25
25
|
workspaceRoot: root.value,
|
|
26
26
|
sessionTtlMs: Number(ttl.value) * 3600000,
|
|
27
27
|
approvalTimeoutMs: Number(approval.value) * 60000,
|
|
28
|
-
}),
|
|
28
|
+
}), "保存会话设置",
|
|
29
29
|
),
|
|
30
30
|
),
|
|
31
31
|
),
|
|
@@ -45,7 +45,7 @@ export async function conversationTab(cfg, page) {
|
|
|
45
45
|
saveButton(async () => {
|
|
46
46
|
await api("/api/claude/allowlist", { method: "PUT", body: { list: allowText.value.split("\n") } });
|
|
47
47
|
toast("已保存");
|
|
48
|
-
}),
|
|
48
|
+
}, "保存允许名单"),
|
|
49
49
|
),
|
|
50
50
|
);
|
|
51
51
|
}
|
|
@@ -117,11 +117,11 @@ export function remoteTab(cfg, page) {
|
|
|
117
117
|
h(
|
|
118
118
|
"div",
|
|
119
119
|
{ class: "section", "data-form": "" },
|
|
120
|
-
h("h4", {}, "
|
|
120
|
+
h("h4", {}, "终端与桌面"),
|
|
121
121
|
h(
|
|
122
122
|
"div",
|
|
123
123
|
{ class: "muted" },
|
|
124
|
-
"侧栏「远程控制」里直接操作这台机器的桌面和终端,切回对话时连接留在后台。以运行 agent-loft 的系统用户执行,没有授权卡。管理员能用;成员要在
|
|
124
|
+
"侧栏「远程控制」里直接操作这台机器的桌面和终端,切回对话时连接留在后台。以运行 agent-loft 的系统用户执行,没有授权卡。管理员能用;成员要在 实例管理 →「用户与权限」里单独开通。",
|
|
125
125
|
),
|
|
126
126
|
status,
|
|
127
127
|
h("label", { class: "check" }, termOn, "网页终端"),
|
|
@@ -147,7 +147,7 @@ export function remoteTab(cfg, page) {
|
|
|
147
147
|
});
|
|
148
148
|
if (ok) void loadStatus();
|
|
149
149
|
return ok;
|
|
150
|
-
}),
|
|
150
|
+
}, "保存远程控制设置"),
|
|
151
151
|
),
|
|
152
152
|
),
|
|
153
153
|
);
|
|
@@ -163,11 +163,15 @@ function loopbackHost(host) {
|
|
|
163
163
|
* 网络访问:要不要让局域网里的其他设备打开、监听哪个端口。保存后服务端当场换过去,不用重启;
|
|
164
164
|
* 端口被占用之类的失败会直接报出来,原来的照常工作。
|
|
165
165
|
*/
|
|
166
|
-
export function
|
|
166
|
+
export function networkTab(cfg, page) {
|
|
167
|
+
page.append(networkSection(cfg));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function networkSection(cfg) {
|
|
167
171
|
const net = cfg.network ?? { lan: [], local: true, listening: null };
|
|
168
172
|
const box = h("div", { class: "section", "data-form": "" });
|
|
169
|
-
const lanOn = h("input", { type: "checkbox", checked: !loopbackHost(cfg.web.host) });
|
|
170
|
-
const port = h("input", { type: "number", min: 1, max: 65535, value: cfg.web.port });
|
|
173
|
+
const lanOn = h("input", { "data-section": "lan", type: "checkbox", checked: !loopbackHost(cfg.web.host) });
|
|
174
|
+
const port = h("input", { type: "number", min: 1, max: 65535, "data-section": "port", value: cfg.web.port });
|
|
171
175
|
const hint = h("small", {});
|
|
172
176
|
// 现在这个页面是不是直接连的这个端口(不是经由反代 / 隧道)
|
|
173
177
|
const pagePort = Number(location.port || (location.protocol === "https:" ? 443 : 80));
|
|
@@ -231,11 +235,10 @@ export function networkSection(cfg) {
|
|
|
231
235
|
|
|
232
236
|
fill(
|
|
233
237
|
box,
|
|
234
|
-
h("h4", {}, "网络访问"),
|
|
235
238
|
h("label", { class: "check" }, lanOn, "允许局域网内的其他设备访问"),
|
|
236
239
|
hint,
|
|
237
|
-
field("
|
|
238
|
-
h("div", { class: "row" }, saveButton(save)),
|
|
240
|
+
field("监听端口", port, "保存后立即生效"),
|
|
241
|
+
h("div", { class: "row" }, saveButton(save, "保存网络设置")),
|
|
239
242
|
);
|
|
240
243
|
return box;
|
|
241
244
|
}
|
package/web/settings/index.js
CHANGED
|
@@ -6,37 +6,37 @@ import { closeSide, openSide, renderSidebar } from "../views/sidebar.js";
|
|
|
6
6
|
import { syncDesktopMenu } from "../views/topbar.js";
|
|
7
7
|
import { WS } from "../lib/ws.js";
|
|
8
8
|
import { hasDirty, markDirty } from "./common.js";
|
|
9
|
+
import { directory, resolvePage, searchDirectory, sections } from "./tabs.js";
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const areas = { settings: "设置", assistants: "助手中心" };
|
|
12
|
+
const storageKeys = { settings: "aim.settingsTab", assistants: "aim.assistantTab" };
|
|
13
|
+
const narrow = matchMedia("(max-width: 768px)");
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
function beforeUnload(event) {
|
|
16
|
+
if (ui.settings?.isDirty()) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
event.returnValue = true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
event.preventDefault();
|
|
24
|
-
event.returnValue = true;
|
|
22
|
+
export function openAssistants() {
|
|
23
|
+
return openSettings(undefined, "assistants");
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
export async function openSettings(tab) {
|
|
26
|
+
export async function openSettings(requested, area = "settings") {
|
|
29
27
|
closeSide();
|
|
30
28
|
closeMenu();
|
|
31
|
-
if (ui.settings)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
let page
|
|
37
|
-
const isDirty = () => page?.isConnected && hasDirty(page);
|
|
29
|
+
if (ui.settings) return ui.settings.selectTab(requested, area);
|
|
30
|
+
const pages = directory.filter(p => !p.admin || isAdmin());
|
|
31
|
+
const previousHash = contentHash();
|
|
32
|
+
const previousFocus = document.activeElement;
|
|
33
|
+
const scrollTop = ui.messages?.scrollTop;
|
|
34
|
+
let active, page, pendingConfig, editFocus;
|
|
38
35
|
let confirming = false;
|
|
39
|
-
|
|
36
|
+
let navScroll = 0;
|
|
37
|
+
|
|
38
|
+
const isDirty = () => Boolean(page?.isConnected && hasDirty(page));
|
|
39
|
+
async function leaveOk() {
|
|
40
40
|
if (!isDirty()) return true;
|
|
41
41
|
if (confirming) return false;
|
|
42
42
|
confirming = true;
|
|
@@ -45,97 +45,180 @@ export async function openSettings(tab) {
|
|
|
45
45
|
} finally {
|
|
46
46
|
confirming = false;
|
|
47
47
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const previousFocus = document.activeElement;
|
|
51
|
-
const scrollTop = ui.messages?.scrollTop;
|
|
52
|
-
const close = async () => {
|
|
48
|
+
}
|
|
49
|
+
async function close() {
|
|
53
50
|
if (!(await leaveOk()) || ui.settings !== settings) return false;
|
|
54
|
-
window.removeEventListener("beforeunload",
|
|
55
|
-
|
|
56
|
-
ui.settings = null;
|
|
51
|
+
window.removeEventListener("beforeunload", beforeUnload);
|
|
52
|
+
narrow.removeEventListener("change", resize);
|
|
57
53
|
const returnHash = contentHash();
|
|
58
54
|
const { settingsReturnHash, ...state } = history.state ?? {};
|
|
59
55
|
history.replaceState(state, "", location.pathname + location.search + returnHash);
|
|
56
|
+
pane.remove();
|
|
57
|
+
ui.settings = null;
|
|
60
58
|
syncDesktopMenu();
|
|
61
59
|
renderSidebar();
|
|
62
60
|
WS.presence();
|
|
63
61
|
if (ui.messages && previousHash === returnHash) ui.messages.scrollTop = scrollTop;
|
|
64
62
|
if (previousFocus?.isConnected) previousFocus.focus({ preventScroll: true });
|
|
65
63
|
return true;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const title = h("h1", { tabindex: "-1" });
|
|
67
|
+
const back = h("button", { class: "btn settings-directory-back", onclick: showDirectory }, icon("back"), "目录");
|
|
68
|
+
const search = h("input", { type: "search", autocomplete: "off", "aria-label": "搜索设置和工具", placeholder: "搜索设置和工具", oninput: drawNav });
|
|
69
|
+
const status = h("span", { class: "settings-sr", role: "status" });
|
|
70
|
+
const list = h("div", { class: "settings-links" });
|
|
71
|
+
search.addEventListener("keydown", event => {
|
|
72
|
+
if (event.isComposing || !search.value.trim()) return;
|
|
73
|
+
const results = list.querySelectorAll("button");
|
|
74
|
+
if (event.key === "Escape") {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
search.value = "";
|
|
77
|
+
drawNav();
|
|
78
|
+
} else if (event.key === "ArrowDown" && results.length) {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
results[0].focus();
|
|
81
|
+
} else if (event.key === "Enter" && results.length === 1) {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
results[0].click();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const nav = h("nav", { class: "settings-nav" }, h("label", { class: "settings-search" }, icon("search"), search), status, list);
|
|
87
|
+
const panel = h("div", { class: "settings-body" });
|
|
88
|
+
const pane = h("main", { class: "settings-view" },
|
|
69
89
|
h("header", { class: "settings-header" },
|
|
70
90
|
h("button", { class: "icon-btn menu-btn", onclick: openSide, title: "会话列表" }, icon("menu")),
|
|
71
|
-
title,
|
|
72
|
-
|
|
73
|
-
h("div", { class: "settings" }, nav, panel)
|
|
74
|
-
|
|
75
|
-
const settings = { close, isDirty, selectTab: (name) => { tab = name; } };
|
|
91
|
+
back, title, h("span", { class: "grow" }),
|
|
92
|
+
h("button", { class: "icon-btn", onclick: close, "aria-label": "返回原页面", title: "返回原页面" }, icon("x"))),
|
|
93
|
+
h("div", { class: "settings" }, nav, panel));
|
|
94
|
+
const settings = { area, close, isDirty, selectTab: select };
|
|
76
95
|
ui.settings = settings;
|
|
77
|
-
window.addEventListener("beforeunload", warnBeforeUnload);
|
|
78
96
|
ui.layout.append(pane);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
window.addEventListener("beforeunload", beforeUnload);
|
|
98
|
+
narrow.addEventListener("change", resize);
|
|
99
|
+
for (const type of ["input", "change"]) panel.addEventListener(type, e => {
|
|
100
|
+
if (!e.target.closest("[data-nodirty]")) markDirty(e.target.closest("[data-form]"));
|
|
101
|
+
});
|
|
102
|
+
function resize() {
|
|
103
|
+
if (!narrow.matches && pane.classList.contains("at-directory")) {
|
|
104
|
+
void select(active?.id || pages.find(p => p.area === settings.area).id);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function drawNav() {
|
|
108
|
+
const query = search.value.trim();
|
|
109
|
+
const available = pages.filter(p => p.area === settings.area);
|
|
110
|
+
const results = query ? searchDirectory(settings.area === "settings" ? pages : available, query) : available.map(page => ({ page, label: page.label }));
|
|
111
|
+
const nodes = [];
|
|
112
|
+
let lastGroup;
|
|
113
|
+
for (const { page: item, section, label } of results) {
|
|
114
|
+
if (!query && item.group !== lastGroup && settings.area !== "assistants") nodes.push(h("h2", { class: "settings-group" }, item.group));
|
|
115
|
+
lastGroup = item.group;
|
|
116
|
+
nodes.push(h("button", {
|
|
117
|
+
class: "settings-nav-link", "data-page": item.id, "aria-current": item === active && !query ? "page" : null,
|
|
118
|
+
onclick: () => select([item.id, section].filter(Boolean).join("/")),
|
|
119
|
+
}, icon(item.icon), h("span", {}, label, query ? h("small", {}, [item.group, item.label === label ? "" : item.label].filter(Boolean).join(" › ")) : null)));
|
|
120
|
+
}
|
|
121
|
+
fill(list, ...nodes, results.length ? null : h("p", { class: "muted" }, "没有匹配项,试试其他关键词。"));
|
|
122
|
+
status.textContent = query ? `找到 ${results.length} 项` : "";
|
|
103
123
|
}
|
|
104
|
-
const tabs = groups.flatMap((g) => g.tabs);
|
|
105
|
-
const buttons = [];
|
|
106
|
-
let current = -1;
|
|
107
124
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
125
|
+
function setRoute(route) {
|
|
126
|
+
history.replaceState({ ...history.state, settingsReturnHash: contentHash() }, "", "#" + route);
|
|
127
|
+
}
|
|
128
|
+
function setArea(next) {
|
|
129
|
+
if (next !== settings.area) { search.value = ""; navScroll = 0; }
|
|
130
|
+
settings.area = next;
|
|
131
|
+
title.textContent = areas[next];
|
|
132
|
+
nav.setAttribute("aria-label", areas[next] + "目录");
|
|
133
|
+
pane.setAttribute("aria-label", areas[next]);
|
|
134
|
+
renderSidebar();
|
|
135
|
+
syncDesktopMenu();
|
|
136
|
+
}
|
|
137
|
+
function showDirectory() {
|
|
138
|
+
if (panel.contains(document.activeElement)) editFocus = document.activeElement;
|
|
139
|
+
pane.classList.add("at-directory");
|
|
140
|
+
setRoute(settings.area);
|
|
141
|
+
drawNav();
|
|
142
|
+
nav.scrollTop = navScroll;
|
|
143
|
+
(list.querySelector('[aria-current="page"]') || search).focus({ preventScroll: true });
|
|
144
|
+
}
|
|
145
|
+
function revealSection(content, key) {
|
|
146
|
+
if (!key || pane.classList.contains("at-directory")) return false;
|
|
147
|
+
const target = content.querySelector(`[data-section="${key}"]`);
|
|
148
|
+
if (!target) return false;
|
|
149
|
+
const disclosure = target.closest("details");
|
|
150
|
+
if (disclosure) disclosure.open = true;
|
|
151
|
+
if (!target.matches("input,select,button,textarea")) target.tabIndex = -1;
|
|
152
|
+
target.focus({ preventScroll: true });
|
|
153
|
+
target.scrollIntoView({ block: "nearest" });
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
function showActivePage() {
|
|
157
|
+
if (pane.classList.contains("at-directory")) navScroll = nav.scrollTop;
|
|
158
|
+
pane.classList.remove("at-directory");
|
|
159
|
+
setRoute([active.area, active.id, page.dataset.section].filter(Boolean).join("/"));
|
|
160
|
+
(editFocus?.isConnected ? editFocus : panel.querySelector("h2"))?.focus({ preventScroll: true });
|
|
161
|
+
}
|
|
162
|
+
async function select(name, preferredArea = "settings") {
|
|
163
|
+
const implicit = !name;
|
|
164
|
+
const stored = localStorage.getItem(storageKeys[preferredArea]);
|
|
165
|
+
const route = resolvePage(name || stored, isAdmin()) || "";
|
|
166
|
+
const [id, anchor] = route.split("/");
|
|
167
|
+
const item = pages.find(p => p.id === id) || pages.find(p => p.area === preferredArea);
|
|
168
|
+
const section = sections[item.id]?.find(([key]) => key === anchor)?.[0];
|
|
169
|
+
if (implicit && stored && preferredArea !== item.area) localStorage.removeItem(storageKeys[preferredArea]);
|
|
170
|
+
if (implicit && narrow.matches && item.area === "settings" && (!stored || stored === id)) {
|
|
171
|
+
if (settings.area !== item.area) {
|
|
172
|
+
if (!(await leaveOk()) || !pane.isConnected) return;
|
|
173
|
+
page = null;
|
|
174
|
+
fill(panel);
|
|
175
|
+
}
|
|
176
|
+
setArea(item.area);
|
|
177
|
+
active = page ? active : item;
|
|
178
|
+
return showDirectory();
|
|
179
|
+
}
|
|
180
|
+
const target = section && page?.querySelector(`[data-section="${section}"]`);
|
|
181
|
+
if (active === item && page && (!section || target)) {
|
|
182
|
+
if (section) page.dataset.section = section;
|
|
183
|
+
showActivePage();
|
|
184
|
+
revealSection(page, section);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (!(await leaveOk()) || !pane.isConnected) {
|
|
188
|
+
if (pane.isConnected && pane.classList.contains("at-directory") && page) showActivePage();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (pane.classList.contains("at-directory")) navScroll = nav.scrollTop;
|
|
192
|
+
setArea(item.area);
|
|
193
|
+
active = item;
|
|
194
|
+
localStorage.setItem(storageKeys[item.area], item.id);
|
|
195
|
+
pane.classList.remove("at-directory");
|
|
196
|
+
const routeId = [item.area, item.id, section].filter(Boolean).join("/");
|
|
197
|
+
setRoute(routeId);
|
|
198
|
+
drawNav();
|
|
199
|
+
const heading = h("h2", { class: "settings-page-title", tabindex: "-1" }, item.label);
|
|
200
|
+
const content = h("div", { class: "settings-page", "aria-busy": "true" }, h("span", { class: "spinner", role: "status", "aria-label": "加载设置" }));
|
|
201
|
+
editFocus = null;
|
|
116
202
|
page = content;
|
|
117
|
-
|
|
203
|
+
if (section) content.dataset.section = section;
|
|
204
|
+
fill(panel, heading, content);
|
|
118
205
|
panel.scrollTop = 0;
|
|
206
|
+
heading.focus({ preventScroll: true });
|
|
119
207
|
try {
|
|
120
|
-
|
|
208
|
+
if (item.config) pendingConfig ??= api("/api/config").catch(err => { pendingConfig = null; throw err; });
|
|
209
|
+
const [module, cfg] = await Promise.all([item.load(), item.config ? pendingConfig : null]);
|
|
210
|
+
if (!content.isConnected) return;
|
|
211
|
+
fill(content);
|
|
212
|
+
if (item.config) await module[item.method](cfg, content, section);
|
|
213
|
+
else await module[item.method](content, section);
|
|
214
|
+
if (content.isConnected) revealSection(content, content.dataset.section);
|
|
121
215
|
} catch (err) {
|
|
122
|
-
if (content.isConnected) fill(content, h("
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
for (const g of groups) {
|
|
127
|
-
// 只有一组时不用标题
|
|
128
|
-
if (groups.length > 1) nav.append(h("div", { class: "settings-group" }, g.name));
|
|
129
|
-
for (const [name] of g.tabs) {
|
|
130
|
-
const i = buttons.length;
|
|
131
|
-
const b = h("button", { onclick: () => void select(i) }, name);
|
|
132
|
-
buttons.push(b);
|
|
133
|
-
nav.append(b);
|
|
216
|
+
if (content.isConnected) fill(content, h("p", { class: "error-text", role: "alert" }, err.message),
|
|
217
|
+
h("button", { class: "btn", onclick: () => { active = null; void select(routeId.split("/").slice(1).join("/")); } }, "重试"));
|
|
218
|
+
} finally {
|
|
219
|
+
content.removeAttribute("aria-busy");
|
|
134
220
|
}
|
|
135
221
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return select(Math.max(0, tabs.findIndex(([name]) => name === want)));
|
|
139
|
-
};
|
|
140
|
-
await settings.selectTab(tab || localStorage.getItem(LAST_TAB));
|
|
222
|
+
WS.presence();
|
|
223
|
+
await select(requested, area);
|
|
141
224
|
}
|
package/web/settings/memory.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { showMemorySync } from "./memory-sync.js";
|
|
2
2
|
import { fill, h, toast } from "../lib/dom.js";
|
|
3
|
+
import { ui } from "../state.js";
|
|
3
4
|
import { api } from "../lib/api.js";
|
|
4
5
|
import { relTime } from "../lib/time.js";
|
|
5
6
|
import { agentCatalog } from "../views/topbar.js";
|
|
@@ -26,7 +27,7 @@ const openSections = new Set();
|
|
|
26
27
|
/** 一个点开才读的区块 */
|
|
27
28
|
function lazySection(key, title, load) {
|
|
28
29
|
const body = h("div", { class: "memory-more-body" });
|
|
29
|
-
const details = h("details", { open: openSections.has(key) }, h("summary", { class: "memory-more" }, title), body);
|
|
30
|
+
const details = h("details", { "data-section": key, open: openSections.has(key) }, h("summary", { class: "memory-more" }, title), body);
|
|
30
31
|
let loaded = false;
|
|
31
32
|
details.ontoggle = () => {
|
|
32
33
|
if (details.open) openSections.add(key);
|
|
@@ -227,7 +228,7 @@ function dataSection(mem, reload) {
|
|
|
227
228
|
}
|
|
228
229
|
return h(
|
|
229
230
|
"div",
|
|
230
|
-
{ class: "section" },
|
|
231
|
+
{ class: "section", "data-section": "data" },
|
|
231
232
|
h("h4", {}, "导出和备份"),
|
|
232
233
|
h(
|
|
233
234
|
"div",
|
|
@@ -243,7 +244,10 @@ function dataSection(mem, reload) {
|
|
|
243
244
|
);
|
|
244
245
|
}
|
|
245
246
|
|
|
246
|
-
export
|
|
247
|
+
export const memoryTab = panel => loadMemory(panel, false, renderItems);
|
|
248
|
+
export const memoryPrefsTab = panel => loadMemory(panel, false, renderPreferences);
|
|
249
|
+
|
|
250
|
+
async function loadMemory(panel, refresh, render) {
|
|
247
251
|
const box = h("div", { class: "section" }, h("h4", {}, "记忆"), h("span", { class: "spinner" }));
|
|
248
252
|
// 更新时保留旧内容,避免加载占位让页面变短、滚动位置被浏览器压回顶部。
|
|
249
253
|
if (!refresh) fill(panel, box);
|
|
@@ -255,7 +259,7 @@ export async function memoryTab(panel, refresh = false) {
|
|
|
255
259
|
else fill(box, h("h4", {}, "记忆"), h("div", { class: "error-text" }, err.message));
|
|
256
260
|
return;
|
|
257
261
|
}
|
|
258
|
-
const reload = () =>
|
|
262
|
+
const reload = () => loadMemory(panel, true, render);
|
|
259
263
|
const run = (btn, fn) => async () => {
|
|
260
264
|
btn.disabled = true;
|
|
261
265
|
try {
|
|
@@ -267,6 +271,10 @@ export async function memoryTab(panel, refresh = false) {
|
|
|
267
271
|
}
|
|
268
272
|
};
|
|
269
273
|
|
|
274
|
+
await render(panel, mem, reload, run);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function renderPreferences(panel, mem, reload, run) {
|
|
270
278
|
const enabled = h("input", { type: "checkbox", checked: mem.enabled });
|
|
271
279
|
enabled.onchange = async () => {
|
|
272
280
|
try {
|
|
@@ -311,8 +319,43 @@ export async function memoryTab(panel, refresh = false) {
|
|
|
311
319
|
const saveAbout = saveButton(async () => {
|
|
312
320
|
await api("/api/account/memory", { method: "PUT", body: { about: about.value } });
|
|
313
321
|
toast("已保存,之后的对话会用上");
|
|
314
|
-
});
|
|
322
|
+
}, "保存自我介绍");
|
|
323
|
+
|
|
324
|
+
fill(
|
|
325
|
+
panel,
|
|
326
|
+
h(
|
|
327
|
+
"div",
|
|
328
|
+
{ class: "section" },
|
|
329
|
+
h("h4", {}, "使用记忆", h("span", { class: "grow" }), h("label", { class: "check" }, enabled, "开启")),
|
|
330
|
+
h(
|
|
331
|
+
"div",
|
|
332
|
+
{ class: "muted" },
|
|
333
|
+
"像 ChatGPT 的记忆:对话时 agent 会参考你的「关于我」和记住的事,聊天里遇到长期有用的信息也会主动记一条(会在回复里告诉你)。Claude 和 Codex、Web 和飞书共用这一份。",
|
|
334
|
+
),
|
|
335
|
+
h(
|
|
336
|
+
"div",
|
|
337
|
+
{ class: "muted" },
|
|
338
|
+
"用在哪些对话:你在 Web 上的对话;在「账号」里绑定了飞书后,和机器人的私聊也会用。飞书群聊不用。别人(包括管理员)看不到你的记忆,管理员只能清空它。",
|
|
339
|
+
),
|
|
340
|
+
),
|
|
341
|
+
h(
|
|
342
|
+
"div",
|
|
343
|
+
{ class: "section", "data-section": "automatic" },
|
|
344
|
+
h("h4", {}, "自动整理与聊天历史"),
|
|
345
|
+
curateSection(mem, reload),
|
|
346
|
+
toggle("chatHistory", "参考以前的聊天", "已开启:agent 能搜你以前的聊天了", "已关闭:agent 不再搜以前的聊天"),
|
|
347
|
+
h(
|
|
348
|
+
"div",
|
|
349
|
+
{ class: "muted" },
|
|
350
|
+
`agent 遇到「上次说的那个……」时,可以搜你以前的聊天(只有你自己的对话,被删掉的对话不算)。侧栏的「搜索」也用这份聊天记录索引,不开记忆也会记。${history ? `现在收录了 ${history.conversations} 段对话、${history.count} 句话。` : ""}`,
|
|
351
|
+
),
|
|
352
|
+
h("div", { class: "row" }, clearHistory),
|
|
353
|
+
),
|
|
354
|
+
h("div", { class: "section", "data-section": "about", "data-form": "" }, h("h4", {}, "关于我"), field("写给 agent 看的自我介绍:你是谁、在做什么、希望它怎么回答", about, `每次对话都会带上,最多 ${mem.limits.about} 字`), h("div", { class: "row" }, saveAbout)),
|
|
355
|
+
);
|
|
356
|
+
}
|
|
315
357
|
|
|
358
|
+
function renderItems(panel, mem, reload, run) {
|
|
316
359
|
const newItem = h("input", { class: "input", maxlength: mem.limits.item, style: { flex: "1", minWidth: "0" }, placeholder: "手动加一条,比如:我的软路由是 iStoreOS,地址 192.168.8.2" });
|
|
317
360
|
const addBtn = h("button", { class: "btn" }, "添加");
|
|
318
361
|
addBtn.onclick = run(addBtn, async () => {
|
|
@@ -399,36 +442,8 @@ export async function memoryTab(panel, refresh = false) {
|
|
|
399
442
|
h(
|
|
400
443
|
"div",
|
|
401
444
|
{ class: "section" },
|
|
402
|
-
h("
|
|
403
|
-
|
|
404
|
-
"div",
|
|
405
|
-
{ class: "muted" },
|
|
406
|
-
"像 ChatGPT 的记忆:对话时 agent 会参考你的「关于我」和记住的事,聊天里遇到长期有用的信息也会主动记一条(会在回复里告诉你)。Claude 和 Codex、Web 和飞书共用这一份。",
|
|
407
|
-
),
|
|
408
|
-
h(
|
|
409
|
-
"div",
|
|
410
|
-
{ class: "muted" },
|
|
411
|
-
"用在哪些对话:你在 Web 上的对话;在「账号」里绑定了飞书后,和机器人的私聊也会用。飞书群聊不用。别人(包括管理员)看不到你的记忆,管理员只能清空它。",
|
|
412
|
-
),
|
|
413
|
-
),
|
|
414
|
-
h(
|
|
415
|
-
"div",
|
|
416
|
-
{ class: "section" },
|
|
417
|
-
h("h4", {}, "自动"),
|
|
418
|
-
curateSection(mem, reload),
|
|
419
|
-
toggle("chatHistory", "参考以前的聊天", "已开启:agent 能搜你以前的聊天了", "已关闭:agent 不再搜以前的聊天"),
|
|
420
|
-
h(
|
|
421
|
-
"div",
|
|
422
|
-
{ class: "muted" },
|
|
423
|
-
`agent 遇到「上次说的那个……」时,可以搜你以前的聊天(只有你自己的对话,被删掉的对话不算)。侧栏的「搜索」也用这份聊天记录索引,不开记忆也会记。${history ? `现在收录了 ${history.conversations} 段对话、${history.count} 句话。` : ""}`,
|
|
424
|
-
),
|
|
425
|
-
h("div", { class: "row" }, clearHistory),
|
|
426
|
-
),
|
|
427
|
-
h("div", { class: "section", "data-form": "" }, h("h4", {}, "关于我"), field("写给 agent 看的自我介绍:你是谁、在做什么、希望它怎么回答", about, `每次对话都会带上,最多 ${mem.limits.about} 字`), h("div", { class: "row" }, saveAbout)),
|
|
428
|
-
h(
|
|
429
|
-
"div",
|
|
430
|
-
{ class: "section" },
|
|
431
|
-
h("h4", {}, `记住的事(${items.length})`),
|
|
445
|
+
h("div", { class: "row" }, h("h4", {}, `记住的事(${items.length})`), h("span", { class: "grow" }),
|
|
446
|
+
h("button", { class: "btn small", onclick: () => ui.settings.selectTab("memory-prefs") }, "记忆偏好")),
|
|
432
447
|
h("div", { class: "muted" }, "「长期」和置顶的一直放在系统提示里;其余的按最近动过的时间放,放不下的 agent 需要时能搜到。满了会把最久没动过的挪到归档,不会删掉。你加的、你让记的、置顶的,自动整理都不会动。"),
|
|
433
448
|
h("div", { class: "row" }, newItem, addBtn),
|
|
434
449
|
items.length > 8 ? h("div", { class: "row" }, filter) : null,
|
package/web/settings/notify.js
CHANGED
|
@@ -17,7 +17,7 @@ export async function notifyTab(panel) {
|
|
|
17
17
|
fill(box, h("h4", {}, "系统通知"), h("div", { class: "error-text" }, err.message));
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
const mine = await currentPushSub();
|
|
20
|
+
const mine = data.subscriptions.length ? await currentPushSub() : null;
|
|
21
21
|
const here = mine && data.subscriptions.some((d) => d.endpoint === mine.endpoint);
|
|
22
22
|
const busy = (btn, fn) => async () => {
|
|
23
23
|
btn.disabled = true;
|
package/web/settings/security.js
CHANGED
|
@@ -26,7 +26,7 @@ export async function accountTab(page) {
|
|
|
26
26
|
const pw = h("input", { type: "password", autocomplete: "new-password" });
|
|
27
27
|
const name = h("input", { value: S.user?.name ?? "", autocomplete: "username", autocapitalize: "off", spellcheck: "false", maxlength: "32" });
|
|
28
28
|
const currentName = h("span", {}, S.user?.name ?? "");
|
|
29
|
-
const devicesBox = h("div", { class: "section" }, h("h4", {}, "已登录的设备"), h("span", { class: "spinner" }));
|
|
29
|
+
const devicesBox = h("div", { class: "section", "data-section": "devices" }, h("h4", {}, "已登录的设备"), h("span", { class: "spinner" }));
|
|
30
30
|
const nameForm = h("div", { class: "account-edit", "data-form": "", hidden: true });
|
|
31
31
|
const passwordForm = h("div", { class: "account-edit", "data-form": "", hidden: true });
|
|
32
32
|
const hideForms = () => {
|
|
@@ -74,8 +74,6 @@ export async function accountTab(page) {
|
|
|
74
74
|
nameForm,
|
|
75
75
|
passwordForm,
|
|
76
76
|
),
|
|
77
|
-
feishuLinkSection(),
|
|
78
|
-
weixinLinkSection(),
|
|
79
77
|
devicesBox,
|
|
80
78
|
);
|
|
81
79
|
const loadDevices = async () => {
|
|
@@ -93,6 +91,14 @@ export async function accountTab(page) {
|
|
|
93
91
|
await loadDevices();
|
|
94
92
|
}
|
|
95
93
|
|
|
94
|
+
export function bindingsTab(page) {
|
|
95
|
+
const feishu = feishuLinkSection();
|
|
96
|
+
const weixin = weixinLinkSection();
|
|
97
|
+
feishu.dataset.section = "feishu";
|
|
98
|
+
weixin.dataset.section = "weixin";
|
|
99
|
+
page.append(feishu, weixin);
|
|
100
|
+
}
|
|
101
|
+
|
|
96
102
|
/** 登录设备列表,每台一个「下线」。showOwner:标上是谁的(管理员看所有人时) */
|
|
97
103
|
export function deviceList(sessions, { showOwner = false, onChange }) {
|
|
98
104
|
if (!sessions.length) return h("div", { class: "muted" }, "没有");
|
package/web/settings/servers.js
CHANGED
|
@@ -124,14 +124,14 @@ function listSection(cfg) {
|
|
|
124
124
|
h("div", { class: "muted" }, HINT),
|
|
125
125
|
field("这台", h("div", { class: "srv-edit-fields self" }, selfIcon, selfName), "左上角列表里这台的图标(一个 emoji)和名字"),
|
|
126
126
|
h("div", { class: "field" }, h("span", {}, "其他服务器"), rows),
|
|
127
|
-
h("div", { class: "row" }, add, saveButton(save)),
|
|
127
|
+
h("div", { class: "row" }, add, saveButton(save, "保存服务器列表")),
|
|
128
128
|
);
|
|
129
129
|
return box;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/** 允许哪些地址把这台嵌进去 */
|
|
133
133
|
function embeddersSection(cfg) {
|
|
134
|
-
const box = h("div", { class: "section", "data-form": "" });
|
|
134
|
+
const box = h("div", { class: "section", "data-section": "embed", "data-form": "" });
|
|
135
135
|
let list = [...cfg.servers.embedders];
|
|
136
136
|
const rows = h("div", {});
|
|
137
137
|
const input = h("input", { class: "input grow", placeholder: "https://loft.example.com", autocapitalize: "off", spellcheck: "false" });
|
|
@@ -201,7 +201,7 @@ function embeddersSection(cfg) {
|
|
|
201
201
|
`别的 agent-loft 要在左上角切到这台,得先允许它嵌入这台的页面。一般不用手填:在那边加上这台(${location.origin})后点「授权」,在打开的页面里确认就行。切过来时照样要登录这台的账号。`,
|
|
202
202
|
),
|
|
203
203
|
rows,
|
|
204
|
-
h("div", { class: "row" }, input, h("button", { class: "btn", onclick: addOne }, "添加"), saveButton(save)),
|
|
204
|
+
h("div", { class: "row" }, input, h("button", { class: "btn", onclick: addOne }, "添加"), saveButton(save, "保存嵌入授权")),
|
|
205
205
|
);
|
|
206
206
|
return box;
|
|
207
207
|
}
|