agent-loft 0.2.83 → 0.2.85
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 +9 -8
- package/package.json +1 -1
- package/src/channels/web/api.ts +11 -2
- package/src/channels/web/assets.ts +50 -0
- package/src/channels/web/http.ts +5 -0
- package/src/channels/web/server.ts +90 -11
- package/web/css/experts.css +23 -0
- package/web/css/mobile.css +2 -2
- package/web/css/servers.css +23 -22
- package/web/css/settings.css +38 -4
- package/web/css/sidebar.css +12 -25
- package/web/css/topbar.css +6 -1
- package/web/index.html +6 -6
- package/web/lib/diagrams.js +5 -3
- package/web/lib/markdown.js +3 -3
- package/web/lib/shell.js +4 -12
- package/web/settings/agents.js +74 -108
- package/web/settings/experts.js +3 -3
- package/web/settings/index.js +4 -5
- package/web/settings/memory.js +1 -0
- package/web/settings/notify.js +1 -1
- package/web/settings/security.js +46 -37
- package/web/settings/users.js +59 -54
- package/web/settings/weixin.js +2 -3
- package/web/sw.js +3 -2
- package/web/views/desktop.js +1 -1
- package/web/views/file-preview.js +1 -1
- package/web/views/sidebar.js +6 -17
- package/web/views/terminal.js +3 -3
- package/web/views/topbar.js +7 -22
package/web/lib/diagrams.js
CHANGED
|
@@ -124,7 +124,9 @@ darkQuery.addEventListener("change", () => {
|
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
const scripts = {};
|
|
127
|
-
|
|
127
|
+
/** vendor 脚本的地址:跟着当前模块走,页面用了带版本的地址(见服务端 assets.ts)这里也带上 */
|
|
128
|
+
function loadScript(file, name) {
|
|
129
|
+
const src = new URL(`../vendor/${file}`, import.meta.url).href;
|
|
128
130
|
return (scripts[src] ??= new Promise((resolve, reject) => {
|
|
129
131
|
const s = document.createElement("script");
|
|
130
132
|
s.src = src;
|
|
@@ -293,7 +295,7 @@ function chartOption(spec) {
|
|
|
293
295
|
}
|
|
294
296
|
|
|
295
297
|
async function drawChart(box) {
|
|
296
|
-
const echarts = await loadScript("
|
|
298
|
+
const echarts = await loadScript("echarts.js", "echarts");
|
|
297
299
|
box._chart?.dispose();
|
|
298
300
|
const chart = echarts.init(box._body, null, { renderer: "svg" });
|
|
299
301
|
box._chart = chart;
|
|
@@ -340,7 +342,7 @@ let mermaidTheme;
|
|
|
340
342
|
function drawMermaid(box) {
|
|
341
343
|
// mermaid 同一时间只能画一张(共用一个全局状态),排队
|
|
342
344
|
const job = mermaidQueue.then(async () => {
|
|
343
|
-
const mermaid = await loadScript("
|
|
345
|
+
const mermaid = await loadScript("mermaid.js", "mermaid");
|
|
344
346
|
const theme = mode() === "dark" ? "dark" : "default";
|
|
345
347
|
if (mermaidTheme !== theme) {
|
|
346
348
|
const font = getComputedStyle(document.documentElement).getPropertyValue("--font").trim();
|
package/web/lib/markdown.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import DOMPurify from "
|
|
2
|
-
import hljs from "
|
|
3
|
-
import { marked } from "
|
|
1
|
+
import DOMPurify from "../vendor/purify.js";
|
|
2
|
+
import hljs from "../vendor/hljs.js";
|
|
3
|
+
import { marked } from "../vendor/marked.js";
|
|
4
4
|
import { diagramLang, mountDiagram, unmountDiagrams } from "./diagrams.js";
|
|
5
5
|
import { h, toast } from "./dom.js";
|
|
6
6
|
|
package/web/lib/shell.js
CHANGED
|
@@ -56,6 +56,7 @@ const emit = (name, detail) => document.dispatchEvent(new CustomEvent(name, { de
|
|
|
56
56
|
const mounted = new Map();
|
|
57
57
|
|
|
58
58
|
export function mountSwitcher(name, el) {
|
|
59
|
+
el.classList.add("server-switcher");
|
|
59
60
|
mounted.set(name, el);
|
|
60
61
|
renderSwitcher(el);
|
|
61
62
|
return el;
|
|
@@ -70,31 +71,23 @@ function rerender() {
|
|
|
70
71
|
|
|
71
72
|
const currentId = () => (SH.role === "guest" ? SH.self : SH.current);
|
|
72
73
|
|
|
73
|
-
function srvIcon(s, cls = "srv-icon") {
|
|
74
|
-
if (s.icon) return h("span", { class: cls }, s.icon);
|
|
75
|
-
// 没设图标:名字的第一个字
|
|
76
|
-
return h("span", { class: `${cls} letter` }, [...(s.name || "?")][0].toUpperCase());
|
|
77
|
-
}
|
|
78
|
-
|
|
79
74
|
function renderSwitcher(el) {
|
|
80
75
|
const cur = SH.servers.find((s) => s.id === currentId());
|
|
81
|
-
el.hidden = !SH.role || SH.servers.length < 2 || !cur;
|
|
76
|
+
el.hidden = !!desktop || !SH.role || SH.servers.length < 2 || !cur;
|
|
82
77
|
if (el.hidden) return fill(el);
|
|
83
|
-
//
|
|
78
|
+
// 别的服务器上有等你处理的:在按钮旁标出来,不用点开才知道
|
|
84
79
|
const ask = SH.servers.filter((s) => s !== cur).reduce((n, s) => n + (s.pending || 0), 0);
|
|
85
80
|
const btn = h(
|
|
86
81
|
"button",
|
|
87
82
|
{ class: "server-switch", title: "切换服务器", "aria-haspopup": "menu" },
|
|
88
|
-
srvIcon(cur),
|
|
89
83
|
h("span", { class: "srv-name" }, cur.name),
|
|
90
|
-
ask ? h("span", { class: "srv-badge", title: `别的服务器上有 ${ask} 项等你处理` }, ask) : null,
|
|
91
84
|
h("span", { class: "srv-chev" }, icon("down")),
|
|
92
85
|
);
|
|
93
86
|
btn.onclick = () => {
|
|
94
87
|
if (ui.menu?.anchor === btn) return closeMenu();
|
|
95
88
|
openSwitchMenu(btn);
|
|
96
89
|
};
|
|
97
|
-
fill(el, btn);
|
|
90
|
+
fill(el, btn, ask ? h("span", { class: "srv-badge", title: `别的服务器上有 ${ask} 项等你处理` }, ask) : null);
|
|
98
91
|
}
|
|
99
92
|
|
|
100
93
|
function openSwitchMenu(btn) {
|
|
@@ -102,7 +95,6 @@ function openSwitchMenu(btn) {
|
|
|
102
95
|
const items = SH.servers.map((s) => ({
|
|
103
96
|
class: `srv-item${s.id === cur ? " on" : ""}`,
|
|
104
97
|
label: [
|
|
105
|
-
srvIcon(s),
|
|
106
98
|
h("span", { class: "srv-item-name" }, s.name),
|
|
107
99
|
s.pending
|
|
108
100
|
? h("span", { class: "srv-badge", title: `${s.pending} 项等你处理` }, s.pending)
|
package/web/settings/agents.js
CHANGED
|
@@ -156,18 +156,16 @@ function installCodexButton(after) {
|
|
|
156
156
|
return h("div", {}, btn);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
/**
|
|
160
|
-
function
|
|
161
|
-
const section = h("div", { class: "section", "data-form": "" }, h("h4", {}, "内置 Agent 默认加载"), h("span", { class: "spinner" }));
|
|
159
|
+
/** 个人默认工具单独保存,避免改服务器配置时覆盖尚未保存的个人选择。 */
|
|
160
|
+
function builtinDefaultsSections(targets) {
|
|
162
161
|
const load = async () => {
|
|
163
162
|
let data;
|
|
164
163
|
try {
|
|
165
164
|
data = await api("/api/agents/defaults");
|
|
166
165
|
} catch (err) {
|
|
167
|
-
|
|
166
|
+
for (const section of Object.values(targets)) fill(section, h("div", { class: "error-text" }, err.message), h("button", { class: "btn small", onclick: load }, "重试"));
|
|
168
167
|
return;
|
|
169
168
|
}
|
|
170
|
-
const choices = {};
|
|
171
169
|
const picker = (label, items, selected, inheritLabel) => {
|
|
172
170
|
const mode = h("select", { "aria-label": label },
|
|
173
171
|
...(inheritLabel ? [h("option", { value: "inherit", selected: selected === null }, inheritLabel)] : []),
|
|
@@ -176,128 +174,96 @@ function builtinDefaultsSection() {
|
|
|
176
174
|
const missing = (selected ?? []).filter((id) => !known.has(id)).map((id) => ({ id, name: `${id}(暂不可用,可取消)` }));
|
|
177
175
|
const inputs = [...items, ...missing].map((item) => ({ id: item.id, input: h("input", { type: "checkbox", checked: (selected ?? []).includes(item.id) }), item }));
|
|
178
176
|
const list = h("div", { class: "check-list" }, inputs.length
|
|
179
|
-
? inputs.map(({ input, item }) => h("label", { class: "check-item", title: item.description ??
|
|
177
|
+
? inputs.map(({ input, item }) => h("label", { class: "check-item tool-check-item", title: item.description ?? item.name }, input, h("span", {}, item.name)))
|
|
180
178
|
: h("small", {}, "暂无可选项,请先在设置中添加"));
|
|
181
179
|
const sync = () => { list.hidden = mode.value !== "pick"; };
|
|
182
180
|
mode.addEventListener("change", sync);
|
|
183
181
|
sync();
|
|
184
182
|
return { el: h("div", { class: "field" }, h("span", {}, label), mode, list), value: () => mode.value === "inherit" ? null : inputs.filter((x) => x.input.checked).map((x) => x.id) };
|
|
185
183
|
};
|
|
186
|
-
const
|
|
187
|
-
const label = engine === "claude" ? "Claude Code" : "Codex";
|
|
184
|
+
for (const [engine, section] of Object.entries(targets)) {
|
|
188
185
|
const prefs = data.agents[engine];
|
|
186
|
+
if (!prefs) {
|
|
187
|
+
section.hidden = true;
|
|
188
|
+
if (section.parentElement?.dataset.personal) section.parentElement.hidden = true;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const label = engine === "claude" ? "Claude Code" : "Codex";
|
|
189
192
|
const skills = picker(`${label} 技能`, data.skills, prefs.skills, "全部已启用的个人技能(含以后新增)");
|
|
190
193
|
const machine = (data.machineMcp?.[engine] ?? []).map((name) => ({ id: `${data.machinePrefix}${name}`, name: `${name}(本机)` }));
|
|
191
194
|
const mcp = picker(`${label} MCP`, [...data.mcp, ...machine], prefs.mcp, data.machineMcp ? "沿用机器上的 MCP 配置" : null);
|
|
192
195
|
const machineSkills = h("input", { type: "checkbox", checked: prefs.machineSkills });
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
fill(section, h("h4", {}, "默认加载"),
|
|
197
|
+
h("p", { class: "skill-note" }, "仅影响你当前账号使用的这个内置 Agent,自定义专家使用各自的配置。保存后,下次发消息生效。"),
|
|
198
|
+
skills.el,
|
|
195
199
|
data.machineMcp ? h("label", { class: "check-item" }, machineSkills, "同时加载机器上的技能") : null,
|
|
196
|
-
mcp.el
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}, "
|
|
200
|
+
mcp.el,
|
|
201
|
+
h("small", {}, "技能和 MCP 可分别全部取消。记忆、定时任务、技能管理等系统工具仍按功能设置提供。"),
|
|
202
|
+
h("div", { class: "row" }, saveButton(async () => {
|
|
203
|
+
await api("/api/agents/defaults", { method: "PUT", body: { agents: { [engine]: { skills: skills.value(), machineSkills: machineSkills.checked, mcp: mcp.value() } } } });
|
|
204
|
+
toast("已保存,下次发消息生效");
|
|
205
|
+
}, `保存 ${label} 默认加载`)));
|
|
206
|
+
}
|
|
207
|
+
if (!Object.keys(data.agents).length) {
|
|
208
|
+
const section = Object.values(targets)[0];
|
|
209
|
+
section.hidden = false;
|
|
210
|
+
section.parentElement.hidden = false;
|
|
211
|
+
const message = h("p", { class: "muted" }, "没有获授权的内置 Agent,请联系管理员配置使用权限。");
|
|
212
|
+
if (section.parentElement.dataset.personal) fill(section.parentElement, h("h4", {}, "内置 Agent"), message);
|
|
213
|
+
else fill(section, message);
|
|
214
|
+
}
|
|
208
215
|
};
|
|
209
216
|
void load();
|
|
210
|
-
return section;
|
|
211
217
|
}
|
|
212
218
|
|
|
213
219
|
export function agentsTab(cfg, page) {
|
|
214
|
-
|
|
215
|
-
if (!cfg)
|
|
220
|
+
const targets = Object.fromEntries(["claude", "codex"].map((engine) => [engine, h("div", { class: "builtin-agent-defaults", "data-form": "" }, h("span", { class: "spinner" }))]));
|
|
221
|
+
if (!cfg) {
|
|
222
|
+
for (const [engine, target] of Object.entries(targets)) page.append(h("div", { class: "section", "data-personal": "true", "data-agent": engine }, h("h4", {}, engine === "claude" ? "Claude Code" : "Codex"), target));
|
|
223
|
+
builtinDefaultsSections(targets);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
216
226
|
page.append(agentHealthSection());
|
|
217
227
|
const a = structuredClone(cfg.agents);
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
h(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
field("codex 可执行文件", codexPath, "以系统服务运行时 PATH 很短,建议写绝对路径"),
|
|
258
|
-
field("CODEX_HOME", codexHome),
|
|
259
|
-
field("沙箱", sandbox, "workspace-write:目录内可读写,越界才弹授权。danger-full-access 等于关掉沙箱"),
|
|
260
|
-
field("默认模型", codexPick.modelEl),
|
|
261
|
-
field("默认思考程度", codexPick.effortEl),
|
|
262
|
-
checksField(codexModels),
|
|
263
|
-
h("div", { class: "row title-row" }, h("label", { class: "check" }, titleOn, "自动生成会话名称"), titleModelEl),
|
|
264
|
-
),
|
|
265
|
-
h(
|
|
266
|
-
"div",
|
|
267
|
-
{ class: "row" },
|
|
268
|
-
saveButton(() => {
|
|
269
|
-
const claudeList = claudeModels.value();
|
|
270
|
-
const codexList = codexModels.value();
|
|
271
|
-
if (!claudeList || !codexList) {
|
|
272
|
-
toast(`${!claudeList ? "Claude Code" : "Codex"} 至少勾选一个模型`);
|
|
273
|
-
return false;
|
|
274
|
-
}
|
|
275
|
-
return saveConfig(cfg, {
|
|
276
|
-
agents: {
|
|
277
|
-
claude: {
|
|
278
|
-
enabled: claudeOn.checked,
|
|
279
|
-
defaultModel: claudePick.model(),
|
|
280
|
-
defaultEffort: claudePick.effort(),
|
|
281
|
-
models: claudeList,
|
|
282
|
-
},
|
|
283
|
-
codex: {
|
|
284
|
-
enabled: codexOn.checked,
|
|
285
|
-
path: codexPath.value.trim() || "codex",
|
|
286
|
-
home: codexHome.value.trim(),
|
|
287
|
-
sandbox: sandbox.value,
|
|
288
|
-
defaultModel: codexPick.model(),
|
|
289
|
-
defaultEffort: codexPick.effort(),
|
|
290
|
-
models: codexList,
|
|
291
|
-
autoTitle: titleOn.checked,
|
|
292
|
-
titleModel: titlePick.model(),
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
});
|
|
296
|
-
}, "保存 Agent 设置"),
|
|
297
|
-
),
|
|
298
|
-
),
|
|
299
|
-
quotaSection(cfg),
|
|
300
|
-
);
|
|
228
|
+
for (const engine of ["claude", "codex"]) {
|
|
229
|
+
const label = engine === "claude" ? "Claude Code" : "Codex";
|
|
230
|
+
const settings = a[engine];
|
|
231
|
+
const on = h("input", { type: "checkbox", checked: settings.enabled });
|
|
232
|
+
const pick = modelPicker(engine, settings.defaultModel, settings.defaultEffort, engine === "claude" ? "跟随 Claude Code 默认" : "跟随 config.toml");
|
|
233
|
+
const models = modelChecklist(engine, settings.models ?? []);
|
|
234
|
+
const config = h("div", { class: "agent-config", "data-form": "" },
|
|
235
|
+
h("h4", {}, label, h("span", { class: "grow" }), h("label", { class: "check" }, on, "启用")));
|
|
236
|
+
let codex = null;
|
|
237
|
+
if (engine === "codex") {
|
|
238
|
+
const path = h("input", { value: settings.path });
|
|
239
|
+
const home = h("input", { value: settings.home, placeholder: "留空用 ~/.codex" });
|
|
240
|
+
const sandbox = h("select", {}, ["read-only", "workspace-write", "danger-full-access"].map((mode) => h("option", { value: mode, selected: mode === settings.sandbox }, mode)));
|
|
241
|
+
const titleOn = h("input", { type: "checkbox", checked: !!settings.autoTitle });
|
|
242
|
+
const titlePick = modelPicker("codex", settings.titleModel ?? "", "", "跟随 config.toml");
|
|
243
|
+
const titleModel = h("div", { class: "grow field" }, titlePick.modelEl);
|
|
244
|
+
const syncTitle = () => { titleModel.hidden = !titleOn.checked; };
|
|
245
|
+
titleOn.addEventListener("change", syncTitle);
|
|
246
|
+
syncTitle();
|
|
247
|
+
codex = { path, home, sandbox, titleOn, titlePick, titleModel };
|
|
248
|
+
config.append(field("codex 可执行文件", path, "以系统服务运行时 PATH 很短,建议写绝对路径"), field("CODEX_HOME", home), field("沙箱", sandbox, "workspace-write:目录内可读写,越界才弹授权。danger-full-access 等于关掉沙箱"));
|
|
249
|
+
}
|
|
250
|
+
config.append(field("默认模型", pick.modelEl), field("默认思考程度", pick.effortEl), h("div", { class: "field" }, h("span", {}, "输入框可选模型"), models.el));
|
|
251
|
+
if (codex) config.append(h("div", { class: "row title-row" }, h("label", { class: "check" }, codex.titleOn, "自动生成会话名称"), codex.titleModel));
|
|
252
|
+
config.append(h("div", { class: "row" }, saveButton(() => {
|
|
253
|
+
const selected = models.value();
|
|
254
|
+
if (!selected) {
|
|
255
|
+
toast(`${label} 至少勾选一个模型`);
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
return saveConfig(cfg, { agents: { [engine]: {
|
|
259
|
+
enabled: on.checked, defaultModel: pick.model(), defaultEffort: pick.effort(), models: selected,
|
|
260
|
+
...(codex ? { path: codex.path.value.trim() || "codex", home: codex.home.value.trim(), sandbox: codex.sandbox.value, autoTitle: codex.titleOn.checked, titleModel: codex.titlePick.model() } : {}),
|
|
261
|
+
} } });
|
|
262
|
+
}, `保存 ${label} 设置`)));
|
|
263
|
+
page.append(h("div", { class: "section", "data-agent": engine }, config, targets[engine]));
|
|
264
|
+
}
|
|
265
|
+
page.append(quotaSection(cfg));
|
|
266
|
+
builtinDefaultsSections(targets);
|
|
301
267
|
}
|
|
302
268
|
|
|
303
269
|
/** 账号额度:侧栏底部、/status、桌面端显示的 Claude / Codex 订阅额度,查不查、多久查一次 */
|
package/web/settings/experts.js
CHANGED
|
@@ -51,7 +51,7 @@ function render(box, data, reload) {
|
|
|
51
51
|
h(
|
|
52
52
|
"p",
|
|
53
53
|
{ class: "skill-note" },
|
|
54
|
-
"专家决定引擎、提示词和能力。共享给所有账号后,设定由创建者维护,每个人的记忆、技能和 MCP 仍各自独立;点「我的工具」选择自己要用的工具。内置的 Claude Code、Codex 在「设置 → Agent
|
|
54
|
+
"专家决定引擎、提示词和能力。共享给所有账号后,设定由创建者维护,每个人的记忆、技能和 MCP 仍各自独立;点「我的工具」选择自己要用的工具。内置的 Claude Code、Codex 在「设置 → Agent」各自卡片的「默认加载」中选择技能和 MCP。",
|
|
55
55
|
),
|
|
56
56
|
h("div", { class: "skill-head-btns" }, add),
|
|
57
57
|
),
|
|
@@ -165,7 +165,7 @@ function field(label, input, hint) {
|
|
|
165
165
|
function checkList(items, picked, empty) {
|
|
166
166
|
const boxes = items.map((it) => {
|
|
167
167
|
const box = h("input", { type: "checkbox", checked: picked.includes(it.id) });
|
|
168
|
-
return { id: it.id, box, el: h("label", { class: "check-item", title: it.hint
|
|
168
|
+
return { id: it.id, box, el: h("label", { class: "check-item tool-check-item", title: [it.label, it.hint].filter(Boolean).join(" · ") }, box, h("span", {}, it.label), it.hint ? h("small", {}, it.hint) : null) };
|
|
169
169
|
});
|
|
170
170
|
return {
|
|
171
171
|
el: boxes.length ? h("div", { class: "check-list" }, boxes.map((b) => b.el)) : h("div", { class: "muted" }, empty),
|
|
@@ -531,7 +531,7 @@ function renderMcp(box, data, reload) {
|
|
|
531
531
|
h(
|
|
532
532
|
"p",
|
|
533
533
|
{ class: "skill-note" },
|
|
534
|
-
"MCP
|
|
534
|
+
"MCP 服务提供查数据、调接口等工具,只供你自己的账号使用。这里加好后,自定义专家在「专家」里勾选;内置的 Claude Code / Codex 在「Agent」各自卡片的「默认加载」中选择。",
|
|
535
535
|
),
|
|
536
536
|
h("div", { class: "skill-head-btns" }, h("button", { class: "btn primary", onclick: () => openMcpEditor(null, reload) }, icon("plus"), "添加")),
|
|
537
537
|
),
|
package/web/settings/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import { fill, h } from "../lib/dom.js";
|
|
|
2
2
|
import { api } from "../lib/api.js";
|
|
3
3
|
import { isAdmin } from "../state.js";
|
|
4
4
|
import { confirmDialog, modal } from "../lib/overlay.js";
|
|
5
|
-
import { notifyTab } from "./notify.js";
|
|
6
5
|
import { conversationTab, remoteTab } from "./general.js";
|
|
7
6
|
import { commandsTab } from "./commands.js";
|
|
8
7
|
import { agentsTab } from "./agents.js";
|
|
@@ -23,14 +22,13 @@ import { hasDirty, markDirty } from "./common.js";
|
|
|
23
22
|
const LAST_TAB = "aim.settingsTab";
|
|
24
23
|
|
|
25
24
|
/** 以前的标签名:外面(地址、别处的按钮)传进来的旧名字照样能打开对应的页 */
|
|
26
|
-
const RENAMED = { 通用: "对话", 授权: "对话", 飞书机器人: "飞书", 我的账号: "账号" };
|
|
25
|
+
const RENAMED = { 通用: "对话", 授权: "对话", 飞书机器人: "飞书", 我的账号: "账号", 通知: "系统" };
|
|
27
26
|
|
|
28
27
|
function groupsFor(cfg) {
|
|
29
28
|
const mine = {
|
|
30
29
|
name: "我的",
|
|
31
30
|
tabs: [
|
|
32
31
|
["账号", (p) => accountTab(p)],
|
|
33
|
-
["通知", (p) => notifyTab(p)],
|
|
34
32
|
["记忆", (p) => memoryTab(p)],
|
|
35
33
|
["专家", (p) => expertsTab(p)],
|
|
36
34
|
["技能", (p) => skillsTab(p)],
|
|
@@ -38,7 +36,7 @@ function groupsFor(cfg) {
|
|
|
38
36
|
["用量", (p) => usageTab(p)],
|
|
39
37
|
],
|
|
40
38
|
};
|
|
41
|
-
if (!cfg) return [mine, { name: "Agent", tabs: [["Agent", (p) => agentsTab(null, p)]] }];
|
|
39
|
+
if (!cfg) return [mine, { name: "Agent", tabs: [["Agent", (p) => agentsTab(null, p)]] }, { name: "系统", tabs: [["系统", (p) => systemTab(null, p)]] }];
|
|
42
40
|
return [
|
|
43
41
|
mine,
|
|
44
42
|
{
|
|
@@ -129,6 +127,7 @@ export async function openSettings(tab) {
|
|
|
129
127
|
nav.append(b);
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
|
-
const
|
|
130
|
+
const requested = tab || localStorage.getItem(LAST_TAB);
|
|
131
|
+
const want = RENAMED[requested] ?? requested;
|
|
133
132
|
void select(Math.max(0, tabs.findIndex(([name]) => name === want)));
|
|
134
133
|
}
|
package/web/settings/memory.js
CHANGED
|
@@ -95,6 +95,7 @@ export async function memoryTab(panel, refresh = false) {
|
|
|
95
95
|
const edit = h("button", { class: "btn small" }, "编辑");
|
|
96
96
|
const del = h("button", { class: "btn small danger" }, "删除");
|
|
97
97
|
edit.onclick = () => {
|
|
98
|
+
edit.hidden = del.hidden = true;
|
|
98
99
|
const input = h("textarea", { class: "input", rows: 2, maxlength: mem.limits.item });
|
|
99
100
|
input.value = it.text;
|
|
100
101
|
const ok = h("button", { class: "btn small primary" }, "保存");
|
package/web/settings/notify.js
CHANGED
|
@@ -8,7 +8,7 @@ import { WS } from "../lib/ws.js";
|
|
|
8
8
|
export async function notifyTab(panel) {
|
|
9
9
|
const support = pushSupport();
|
|
10
10
|
const box = h("div", { class: "section" }, h("h4", {}, "系统通知"), h("span", { class: "spinner" }));
|
|
11
|
-
|
|
11
|
+
panel.append(box);
|
|
12
12
|
const render = async () => {
|
|
13
13
|
let data = { subscriptions: [] };
|
|
14
14
|
try {
|
package/web/settings/security.js
CHANGED
|
@@ -4,7 +4,7 @@ import { relTime } from "../lib/time.js";
|
|
|
4
4
|
import { copyText } from "../lib/markdown.js";
|
|
5
5
|
import { isAdmin, S } from "../state.js";
|
|
6
6
|
import { dropPushSub } from "../lib/push.js";
|
|
7
|
-
import { field, saveButton } from "./common.js";
|
|
7
|
+
import { field, markClean, saveButton } from "./common.js";
|
|
8
8
|
import { weixinLinkSection } from "./weixin.js";
|
|
9
9
|
|
|
10
10
|
/** 设置 → 账号:我是谁、改密码、绑定飞书、我登录着的设备。别人的设备在 管理 →「用户」里 */
|
|
@@ -27,42 +27,52 @@ export async function accountTab(page) {
|
|
|
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
29
|
const devicesBox = h("div", { class: "section" }, h("h4", {}, "已登录的设备"), h("span", { class: "spinner" }));
|
|
30
|
+
const nameForm = h("div", { class: "account-edit", "data-form": "", hidden: true });
|
|
31
|
+
const passwordForm = h("div", { class: "account-edit", "data-form": "", hidden: true });
|
|
32
|
+
const hideForms = () => {
|
|
33
|
+
nameForm.hidden = passwordForm.hidden = true;
|
|
34
|
+
old.value = pw.value = "";
|
|
35
|
+
markClean(nameForm);
|
|
36
|
+
markClean(passwordForm);
|
|
37
|
+
};
|
|
38
|
+
const rename = h("button", { class: "btn small", onclick: () => {
|
|
39
|
+
hideForms();
|
|
40
|
+
name.value = S.user?.name ?? "";
|
|
41
|
+
nameForm.hidden = false;
|
|
42
|
+
name.focus();
|
|
43
|
+
} }, "修改名称");
|
|
44
|
+
const password = h("button", { class: "btn small", onclick: () => {
|
|
45
|
+
hideForms();
|
|
46
|
+
passwordForm.hidden = false;
|
|
47
|
+
old.focus();
|
|
48
|
+
} }, "修改密码");
|
|
49
|
+
nameForm.append(
|
|
50
|
+
field("账号名称", name, "也是登录时使用的用户名。1~32 个字符,可用文字、数字和 _ . @ -;修改后请用新名称登录。"),
|
|
51
|
+
h("div", { class: "row" }, saveButton(async () => {
|
|
52
|
+
const data = await api("/api/account", { method: "PATCH", body: { name: name.value.trim() } });
|
|
53
|
+
S.user = data.user;
|
|
54
|
+
name.value = currentName.textContent = data.user.name;
|
|
55
|
+
hideForms();
|
|
56
|
+
toast("账号名称已修改");
|
|
57
|
+
}, "保存账号名称"), h("button", { class: "btn", onclick: hideForms }, "取消")),
|
|
58
|
+
);
|
|
59
|
+
passwordForm.append(
|
|
60
|
+
field("原密码", old),
|
|
61
|
+
field("新密码(至少 8 位)", pw),
|
|
62
|
+
h("div", { class: "row" }, saveButton(async () => {
|
|
63
|
+
await api("/api/password", { method: "POST", body: { old: old.value, password: pw.value } });
|
|
64
|
+
hideForms();
|
|
65
|
+
toast("密码已修改,你的其它设备已下线");
|
|
66
|
+
void loadDevices();
|
|
67
|
+
}, "保存密码"), h("button", { class: "btn", onclick: hideForms }, "取消")),
|
|
68
|
+
);
|
|
30
69
|
page.append(
|
|
31
|
-
h(
|
|
32
|
-
"
|
|
33
|
-
{ class: "section", "data-form": "" },
|
|
34
|
-
h(
|
|
35
|
-
"h4",
|
|
36
|
-
{},
|
|
37
|
-
"当前账号",
|
|
38
|
-
h("span", { class: "grow" }),
|
|
39
|
-
logout,
|
|
40
|
-
),
|
|
70
|
+
h("div", { class: "section" },
|
|
71
|
+
h("h4", {}, "当前账号"),
|
|
41
72
|
S.user ? h("div", {}, currentName, " ", h("span", { class: "status-tag" }, S.user.role === "admin" ? "管理员" : "成员")) : null,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
S.user = data.user;
|
|
46
|
-
name.value = currentName.textContent = data.user.name;
|
|
47
|
-
toast("账号名称已修改");
|
|
48
|
-
}, "保存账号名称")),
|
|
49
|
-
),
|
|
50
|
-
h(
|
|
51
|
-
"div",
|
|
52
|
-
{ class: "section", "data-form": "" },
|
|
53
|
-
h("h4", {}, "修改登录密码"),
|
|
54
|
-
field("原密码", old),
|
|
55
|
-
field("新密码(至少 8 位)", pw),
|
|
56
|
-
h(
|
|
57
|
-
"div",
|
|
58
|
-
{ class: "row" },
|
|
59
|
-
saveButton(async () => {
|
|
60
|
-
await api("/api/password", { method: "POST", body: { old: old.value, password: pw.value } });
|
|
61
|
-
toast("密码已修改,你的其它设备已下线");
|
|
62
|
-
old.value = pw.value = "";
|
|
63
|
-
void loadDevices();
|
|
64
|
-
}, "修改"),
|
|
65
|
-
),
|
|
73
|
+
h("div", { class: "row account-actions" }, rename, password, logout),
|
|
74
|
+
nameForm,
|
|
75
|
+
passwordForm,
|
|
66
76
|
),
|
|
67
77
|
feishuLinkSection(),
|
|
68
78
|
weixinLinkSection(),
|
|
@@ -160,7 +170,7 @@ function feishuLinkSection() {
|
|
|
160
170
|
};
|
|
161
171
|
fill(
|
|
162
172
|
box,
|
|
163
|
-
h("h4", {}, "飞书账号"),
|
|
173
|
+
h("h4", {}, "飞书账号", h("span", { class: "grow" }), gen),
|
|
164
174
|
h("div", { class: "muted" }, "绑定后,你和飞书机器人的私聊就是你的个人会话:用你的记忆,/sessions 只列你的会话,/web 能接上你自己的 Web 会话。群聊不受影响。"),
|
|
165
175
|
data.links.map((l) => {
|
|
166
176
|
const rm = h("button", { class: "btn small danger" }, "解除绑定");
|
|
@@ -182,7 +192,6 @@ function feishuLinkSection() {
|
|
|
182
192
|
rm,
|
|
183
193
|
);
|
|
184
194
|
}),
|
|
185
|
-
h("div", { class: "row" }, gen),
|
|
186
195
|
codeBox,
|
|
187
196
|
);
|
|
188
197
|
};
|