agent-loft 0.2.133 → 0.2.135
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 +31 -31
- 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/api.ts +3 -1
- 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 +3 -3
- package/src/core/memory-curator.ts +1 -1
- package/src/core/ui-prefs.ts +10 -4
- package/src/mcp/memory-server.ts +1 -1
- package/web/css/mobile.css +19 -31
- package/web/css/settings.css +66 -37
- package/web/lib/overlay.js +15 -2
- package/web/lib/push.js +1 -1
- package/web/lib/shell.js +1 -1
- package/web/settings/agent-defaults.js +3 -16
- package/web/settings/agents.js +118 -95
- package/web/settings/commands.js +32 -29
- package/web/settings/experts.js +14 -12
- package/web/settings/feishu.js +6 -6
- package/web/settings/general.js +22 -17
- package/web/settings/index.js +193 -112
- package/web/settings/memory-sync.js +1 -1
- package/web/settings/memory.js +63 -73
- package/web/settings/notify.js +2 -2
- package/web/settings/security.js +14 -6
- package/web/settings/servers.js +6 -5
- package/web/settings/skills.js +9 -4
- package/web/settings/tabs.js +67 -51
- package/web/settings/usage.js +3 -3
- package/web/settings/users.js +25 -8
- package/web/settings/weixin.js +1 -1
- package/web/state.js +2 -2
- package/web/views/layout.js +2 -2
- package/web/views/memo-dialogs.js +1 -1
- package/web/views/sidebar-gestures.js +1 -1
- package/web/views/sidebar-nav.js +2 -2
- package/web/views/tasks.js +1 -1
- package/web/views/topbar.js +1 -1
package/web/settings/servers.js
CHANGED
|
@@ -56,8 +56,9 @@ function listSection(cfg) {
|
|
|
56
56
|
render();
|
|
57
57
|
};
|
|
58
58
|
return h(
|
|
59
|
-
"
|
|
60
|
-
{ class: "srv-edit" },
|
|
59
|
+
"details",
|
|
60
|
+
{ class: "srv-edit", open: !s.id },
|
|
61
|
+
h("summary", {}, s.name || s.url || "新服务器"),
|
|
61
62
|
h("div", { class: "srv-edit-fields" }, em, name, url),
|
|
62
63
|
h(
|
|
63
64
|
"div",
|
|
@@ -124,14 +125,14 @@ function listSection(cfg) {
|
|
|
124
125
|
h("div", { class: "muted" }, HINT),
|
|
125
126
|
field("这台", h("div", { class: "srv-edit-fields self" }, selfIcon, selfName), "左上角列表里这台的图标(一个 emoji)和名字"),
|
|
126
127
|
h("div", { class: "field" }, h("span", {}, "其他服务器"), rows),
|
|
127
|
-
h("div", { class: "row" }, add, saveButton(save)),
|
|
128
|
+
h("div", { class: "row" }, add, saveButton(save, "保存服务器列表")),
|
|
128
129
|
);
|
|
129
130
|
return box;
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
/** 允许哪些地址把这台嵌进去 */
|
|
133
134
|
function embeddersSection(cfg) {
|
|
134
|
-
const box = h("div", { class: "section", "data-form": "" });
|
|
135
|
+
const box = h("div", { class: "section", "data-section": "embed", "data-form": "" });
|
|
135
136
|
let list = [...cfg.servers.embedders];
|
|
136
137
|
const rows = h("div", {});
|
|
137
138
|
const input = h("input", { class: "input grow", placeholder: "https://loft.example.com", autocapitalize: "off", spellcheck: "false" });
|
|
@@ -201,7 +202,7 @@ function embeddersSection(cfg) {
|
|
|
201
202
|
`别的 agent-loft 要在左上角切到这台,得先允许它嵌入这台的页面。一般不用手填:在那边加上这台(${location.origin})后点「授权」,在打开的页面里确认就行。切过来时照样要登录这台的账号。`,
|
|
202
203
|
),
|
|
203
204
|
rows,
|
|
204
|
-
h("div", { class: "row" }, input, h("button", { class: "btn", onclick: addOne }, "添加"), saveButton(save)),
|
|
205
|
+
h("div", { class: "row" }, input, h("button", { class: "btn", onclick: addOne }, "添加"), saveButton(save, "保存嵌入授权")),
|
|
205
206
|
);
|
|
206
207
|
return box;
|
|
207
208
|
}
|
package/web/settings/skills.js
CHANGED
|
@@ -11,8 +11,8 @@ const K = { data: null, tab: "mine", query: "", token: 0, reloadTimer: 0, box: n
|
|
|
11
11
|
|
|
12
12
|
const SHARED = { private: "仅自己可见", users: "共享给指定用户", all: "所有人可见" };
|
|
13
13
|
|
|
14
|
-
export async function skillsTab(panel) {
|
|
15
|
-
K.tab = "mine";
|
|
14
|
+
export async function skillsTab(panel, section) {
|
|
15
|
+
K.tab = section === "shared" ? "shared" : "mine";
|
|
16
16
|
K.query = "";
|
|
17
17
|
K.box = h("div", { class: "skills-page" }, h("div", { class: "section" }, h("h4", {}, "技能"), h("span", { class: "spinner" })));
|
|
18
18
|
fill(panel, K.box);
|
|
@@ -73,12 +73,12 @@ function render() {
|
|
|
73
73
|
h(
|
|
74
74
|
"p",
|
|
75
75
|
{ class: "skill-note" },
|
|
76
|
-
"技能是一份写给 agent 的做事方法(SKILL.md),可以带脚本和资料,Claude 和 Codex 都能用。自己建的技能可共享给指定用户或所有人;别人共享的技能安装后可用,变量由每个人自己填写。内置专家默认使用你启用的技能,自定义专家只用它选中的(设置 → 专家)。",
|
|
76
|
+
"技能是一份写给 agent 的做事方法(SKILL.md),可以带脚本和资料,Claude 和 Codex 都能用。自己建的技能可共享给指定用户或所有人;别人共享的技能安装后可用,变量由每个人自己填写。内置专家默认使用你启用的技能,自定义专家只用它选中的(设置 → 助手 → 专家)。",
|
|
77
77
|
),
|
|
78
78
|
h(
|
|
79
79
|
"div",
|
|
80
80
|
{ class: "skill-head-btns" },
|
|
81
|
-
h("button", { class: "btn", onclick: () => pickUpload() }, "上传"),
|
|
81
|
+
h("button", { class: "btn", "data-section": "upload", onclick: () => pickUpload() }, "上传"),
|
|
82
82
|
h("button", { class: "btn primary", onclick: () => openEditor() }, icon("plus"), "新建"),
|
|
83
83
|
),
|
|
84
84
|
),
|
|
@@ -93,6 +93,8 @@ function render() {
|
|
|
93
93
|
h(
|
|
94
94
|
"button",
|
|
95
95
|
{
|
|
96
|
+
"data-section": K.tab === id ? id : null,
|
|
97
|
+
"aria-pressed": String(K.tab === id),
|
|
96
98
|
class: K.tab === id ? "on" : "",
|
|
97
99
|
onclick: () => {
|
|
98
100
|
K.tab = id;
|
|
@@ -442,6 +444,7 @@ function openVars(s) {
|
|
|
442
444
|
});
|
|
443
445
|
const save = h("button", { class: "btn primary" }, "保存");
|
|
444
446
|
const close = modal({
|
|
447
|
+
editor: true,
|
|
445
448
|
title: `${s.name} 的变量`,
|
|
446
449
|
body: h(
|
|
447
450
|
"div",
|
|
@@ -523,6 +526,7 @@ async function openSharing(s) {
|
|
|
523
526
|
const visibility = visibilityEditor(d);
|
|
524
527
|
const save = h("button", { class: "btn primary" }, "保存");
|
|
525
528
|
const close = modal({
|
|
529
|
+
editor: true,
|
|
526
530
|
title: `共享 ${d.name}`,
|
|
527
531
|
body: h("div", { class: "modal-body task-form" },
|
|
528
532
|
field("共享范围", visibility.el),
|
|
@@ -632,6 +636,7 @@ async function openEditor(s) {
|
|
|
632
636
|
const visibility = visibilityEditor(d ?? {});
|
|
633
637
|
const save = h("button", { class: "btn primary" }, d ? "保存" : "创建");
|
|
634
638
|
const close = modal({
|
|
639
|
+
editor: true,
|
|
635
640
|
title: d ? `编辑 ${d.name}` : "新建技能",
|
|
636
641
|
wide: true,
|
|
637
642
|
tall: true,
|
package/web/settings/tabs.js
CHANGED
|
@@ -1,53 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
// 静态目录也用于搜索,个人数据只在打开详情时读取。
|
|
2
|
+
const pages = [
|
|
3
|
+
["account", "账号", "个人", "shield", "账号 登录 退出 改名 改密码 登录设备 下线", () => import("./security.js"), "accountTab"],
|
|
4
|
+
["notifications", "通知", "个人", "chat", "开启通知 推送 测试通知 已订阅设备 提醒", () => import("./notify.js"), "notifyTab"],
|
|
5
|
+
["memory", "记忆", "个人", "clipboard", "记住的事 归档 回收站 跨实例同步 摘要 导出", () => import("./memory.js"), "memoryTab"],
|
|
6
|
+
["memory-prefs", "记忆偏好", "个人", "edit", "关于我 记忆开关 聊天历史 自动整理 自我介绍", () => import("./memory.js"), "memoryPrefsTab"],
|
|
7
|
+
["experts", "专家", "助手", "spark", "换模型 专家模型 内置权限 默认加载 共享 新建专家", () => import("./experts.js"), "expertsTab"],
|
|
8
|
+
["skills", "技能", "助手", "bolt", "安装技能 技能包 上传 共享技能 变量", () => import("./skills.js"), "skillsTab"],
|
|
9
|
+
["mcp", "MCP", "助手", "plug", "工具服务 共享 MCP 凭据 密钥", () => import("./experts.js"), "mcpTab"],
|
|
10
|
+
["usage", "用量", "对话", "clock", "Token 费用 统计 成本", () => import("./usage.js"), "usageTab"],
|
|
11
|
+
["quota", "订阅额度查询", "对话", "bolt", "订阅额度 查询 刷新间隔", () => import("./agents.js"), "quotaTab", true],
|
|
12
|
+
["engines", "引擎与模型", "对话", "bolt", "换模型 引擎 实例默认模型 默认思考程度 API Key 登录 沙箱 标题 配额", () => import("./agents.js"), "agentsTab", true],
|
|
13
|
+
["sessions", "会话规则", "对话", "shield", "工作目录 工作区 闲置 超时 Claude 总是允许 白名单", () => import("./general.js"), "conversationTab", true],
|
|
14
|
+
["commands", "斜杠命令", "对话", "terminal", "斜杠命令 指令 命令列表", () => import("./commands.js"), "commandsTab", true],
|
|
15
|
+
["weixin", "微信", "连接", "plug", "微信 扫码 重连 微信专家", () => import("./security.js"), "weixinTab"],
|
|
16
|
+
["bindings", "飞书", "连接", "plug", "生成绑定码 绑定飞书 配对个人账号", () => import("./security.js"), "bindingsTab"],
|
|
17
|
+
["feishu", "机器人管理", "连接", "feishu", "飞书机器人 Lark 机器人 配对请求 已配对 指令面板", () => import("./feishu.js"), "feishuTab", true],
|
|
18
|
+
["remote", "终端与桌面", "连接", "monitor", "网页终端 桌面 VNC Mac 屏幕共享", () => import("./general.js"), "remoteTab", true],
|
|
19
|
+
["servers", "服务器切换", "连接", "monitor", "切换服务器 允许被嵌入 iframe", () => import("./servers.js"), "serversTab", true],
|
|
20
|
+
["network", "网络访问", "连接", "plug", "局域网 监听地址 改端口", () => import("./general.js"), "networkTab", true],
|
|
21
|
+
["users", "成员", "管理", "shield", "成员 添加用户 设备 管理员 权限", () => import("./users.js"), "usersTab"],
|
|
22
|
+
["service", "服务维护", "管理", "gear", "数据库备份 升级 检查更新 版本 重启 服务状态", () => import("./users.js"), "systemTab"],
|
|
23
|
+
];
|
|
12
24
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
25
|
+
const parents = { "memory-prefs": "memory", quota: "usage", feishu: "bindings" };
|
|
26
|
+
const restricted = new Set(["quota", "engines", "sessions", "commands", "feishu", "remote", "servers", "network", "users", "service"]);
|
|
27
|
+
export const directory = pages.map(([id, label, group, icon, keywords, load, method, config]) => ({
|
|
28
|
+
id, label, group, icon, keywords, load, method, config, parent: parents[id], admin: restricted.has(id),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const legacy = {
|
|
32
|
+
"bindings/weixin": "weixin", "bindings/feishu": "bindings", "engines/quota": "quota",
|
|
33
|
+
"账号绑定": "bindings", "账号与安全": "account", "我的账号": "account", "设备通知": "notifications",
|
|
34
|
+
"模型与运行环境": "engines", "会话与授权": "sessions", "对话": "sessions", "通用": "sessions",
|
|
35
|
+
"授权": "sessions/approval", "命令": "commands", "快捷命令": "commands",
|
|
36
|
+
"飞书机器人": "feishu", "飞书": "feishu", "远程控制": "remote",
|
|
37
|
+
"多服务器": "servers", "服务器": "servers", "用户与权限": "users", "用户": "users", "服务与更新": "service",
|
|
38
|
+
};
|
|
39
|
+
export function resolvePage(name, isAdmin) {
|
|
40
|
+
if (name === "飞书" && !isAdmin) return "bindings";
|
|
41
|
+
if (name === "Agent") return isAdmin ? "engines" : "experts";
|
|
42
|
+
if (name === "系统") return isAdmin ? "service" : "notifications";
|
|
43
|
+
return Object.hasOwn(legacy, name) ? legacy[name] : directory.find(p => p.label === name)?.id || name;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 分区 ID 也用于书签。只收录稳定的操作或字段,不索引账号数据。
|
|
47
|
+
export const sections = {
|
|
48
|
+
service: [["backup", "数据库备份", "备份整个实例"]],
|
|
49
|
+
account: [["devices", "登录设备", "下线设备"]],
|
|
50
|
+
bindings: [["feishu", "绑定飞书", "飞书账号"]],
|
|
51
|
+
"memory-prefs": [["about", "关于我", "自我介绍"], ["automatic", "自动整理与聊天历史", "以前的聊天 历史索引"]],
|
|
52
|
+
engines: [["claude", "Claude Code", "换模型 默认模型 默认思考程度"], ["codex", "Codex", "换模型 默认模型"], ["codex-sandbox", "Codex 沙箱", "沙箱权限限制"], ["codex-path", "Codex 可执行文件", "路径 CLI"], ["pi", "pi", "默认模型"], ["pi-providers", "pi 模型服务商", "API Key 订阅登录"], ["workbuddy", "WorkBuddy", "默认模型"], ["workbuddy-site", "WorkBuddy 账号站点", "腾讯 CodeBuddy"], ["dsh", "dsh", "DeepSeek Harness"], ["dsh-patch", "dsh 补丁文件", "patch"]],
|
|
53
|
+
sessions: [["workspace", "工作目录", "workspace"], ["approval", "授权等待时间", "授权超时"], ["allowlist", "Claude 总是允许名单", "白名单"]],
|
|
54
|
+
skills: [["shared", "安装共享技能", "安装技能"], ["upload", "上传技能包", "导入技能"]],
|
|
55
|
+
network: [["port", "监听端口", "改端口 端口号"], ["lan", "局域网访问", "允许局域网"]],
|
|
56
|
+
servers: [["embed", "允许被嵌入", "嵌入授权"]],
|
|
57
|
+
feishu: [["pair", "配对请求", "批准配对"], ["slash", "指令面板", "同步指令"]],
|
|
58
|
+
memory: [["sync", "跨实例同步", "配对码"], ["archive", "归档", "恢复归档"], ["trash", "回收站", "恢复删除"], ["data", "个人数据导入导出", "导入记忆 导出记忆"]],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export function searchDirectory(pages, query) {
|
|
62
|
+
const words = query.trim().toLowerCase().split(/\s+/);
|
|
63
|
+
const matches = text => words.every(word => text.toLowerCase().includes(word));
|
|
64
|
+
return pages.flatMap(page => {
|
|
65
|
+
const hits = (sections[page.id] || []).filter(([, label, keywords]) => matches([page.label, label, keywords].join(" ")));
|
|
66
|
+
if (hits.length) return hits.map(([section, label]) => ({ page, section, label }));
|
|
67
|
+
return matches([page.group, page.label, page.keywords].join(" ")) ? [{ page, label: page.label }] : [];
|
|
68
|
+
});
|
|
53
69
|
}
|
package/web/settings/usage.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fill, h } from "../lib/dom.js";
|
|
2
2
|
import { api } from "../lib/api.js";
|
|
3
|
-
import { S } from "../state.js";
|
|
3
|
+
import { isAdmin, S, ui } from "../state.js";
|
|
4
4
|
|
|
5
5
|
// ---------- 用量:按日 / 月 / 年统计 token 和费用(数据见 src/core/usage.ts 按天的账) ----------
|
|
6
6
|
|
|
@@ -80,7 +80,7 @@ export async function usageTab(panel) {
|
|
|
80
80
|
let unit = "month";
|
|
81
81
|
let anchor = new Date();
|
|
82
82
|
const box = h("div", { class: "section usage-stats" });
|
|
83
|
-
fill(panel, box);
|
|
83
|
+
fill(panel, box, isAdmin() ? h("button", { class: "btn", onclick: () => ui.settings.selectTab("quota") }, "订阅额度查询") : null);
|
|
84
84
|
|
|
85
85
|
const render = async () => {
|
|
86
86
|
const period = periodOf(unit, anchor);
|
|
@@ -116,7 +116,7 @@ export async function usageTab(panel) {
|
|
|
116
116
|
),
|
|
117
117
|
isCurrent ? null : h("button", { class: "btn small", onclick: () => ((anchor = new Date()), void render()) }, unit === "day" ? "今天" : unit === "month" ? "本月" : "今年"),
|
|
118
118
|
);
|
|
119
|
-
const head = h("div", { class: "us-head" }, h("h4", {}, "
|
|
119
|
+
const head = h("div", { class: "us-head" }, h("h4", {}, isAdmin() ? "实例用量与参考费用" : "我的用量与参考费用"), seg, nav);
|
|
120
120
|
fill(box, head, h("span", { class: "spinner" }));
|
|
121
121
|
|
|
122
122
|
let data;
|
package/web/settings/users.js
CHANGED
|
@@ -3,9 +3,7 @@ import { api } from "../lib/api.js";
|
|
|
3
3
|
import { relTime } from "../lib/time.js";
|
|
4
4
|
import { confirmDialog, modal, showMenu } from "../lib/overlay.js";
|
|
5
5
|
import { field, markDirty, saveButton } from "./common.js";
|
|
6
|
-
import { networkSection } from "./general.js";
|
|
7
6
|
import { deviceList } from "./security.js";
|
|
8
|
-
import { notifyTab } from "./notify.js";
|
|
9
7
|
|
|
10
8
|
/** null 沿用全部;指定列表可以全部取消,新增资源不会自动加入。 */
|
|
11
9
|
function permissionFields(resources, permissions = {}) {
|
|
@@ -276,7 +274,7 @@ export async function usersTab(page) {
|
|
|
276
274
|
fill(
|
|
277
275
|
addBox,
|
|
278
276
|
field("用户名", name),
|
|
279
|
-
field("密码", pw, "告诉对方,让他登录后在 设置
|
|
277
|
+
field("密码", pw, "告诉对方,让他登录后在 设置 →「账号与安全」里自己改掉"),
|
|
280
278
|
field("角色", role, "成员只能用自己的对话;管理员能改所有设置、管理用户"),
|
|
281
279
|
memberOptions,
|
|
282
280
|
h(
|
|
@@ -303,7 +301,7 @@ export async function usersTab(page) {
|
|
|
303
301
|
),
|
|
304
302
|
);
|
|
305
303
|
|
|
306
|
-
const close = modal({ title: "添加用户", body: addBox, wide: true });
|
|
304
|
+
const close = modal({ editor: true, title: "添加用户", body: addBox, wide: true });
|
|
307
305
|
name.focus();
|
|
308
306
|
};
|
|
309
307
|
|
|
@@ -324,11 +322,9 @@ export async function usersTab(page) {
|
|
|
324
322
|
}
|
|
325
323
|
|
|
326
324
|
/** 设置 → 系统:服务端运行状态、版本和升级、重启,网络访问 */
|
|
327
|
-
export async function systemTab(
|
|
328
|
-
if (!cfg) return notifyTab(page);
|
|
325
|
+
export async function systemTab(page) {
|
|
329
326
|
const sysBox = h("div", { class: "section" }, h("h4", {}, "服务端", h("span", { class: "grow" }), h("span", { class: "spinner" })));
|
|
330
|
-
page.append(sysBox
|
|
331
|
-
void notifyTab(page);
|
|
327
|
+
page.append(sysBox);
|
|
332
328
|
|
|
333
329
|
const restart = async () => {
|
|
334
330
|
if (!(await confirmDialog({ title: "重启 agent-loft?", message: "进行中的对话会被中断。", confirmText: "重启", danger: true }))) return;
|
|
@@ -432,6 +428,7 @@ export async function systemTab(cfg, page) {
|
|
|
432
428
|
const versionDone = checkVersion(false);
|
|
433
429
|
try {
|
|
434
430
|
sys = await api("/api/system");
|
|
431
|
+
if (sys.backup) page.append(backupSection(sys.backup));
|
|
435
432
|
} catch (err) {
|
|
436
433
|
fill(sysBox, h("h4", {}, "服务端"), h("div", { class: "error-text" }, err.message));
|
|
437
434
|
return;
|
|
@@ -448,3 +445,23 @@ function uptime(ms) {
|
|
|
448
445
|
if (min < 1440) return `${Math.floor(min / 60)} 小时 ${min % 60} 分钟`;
|
|
449
446
|
return `${Math.floor(min / 1440)} 天 ${Math.floor((min % 1440) / 60)} 小时`;
|
|
450
447
|
}
|
|
448
|
+
|
|
449
|
+
function backupSection(status) {
|
|
450
|
+
const box = h("div", { class: "section", "data-section": "backup" });
|
|
451
|
+
const button = h("button", { class: "btn", onclick: async () => {
|
|
452
|
+
button.disabled = true;
|
|
453
|
+
try {
|
|
454
|
+
render(await api("/api/system/backup", { method: "POST" }));
|
|
455
|
+
toast("整个实例数据库已备份");
|
|
456
|
+
} catch (err) { toast(err.message); }
|
|
457
|
+
finally { button.disabled = false; }
|
|
458
|
+
} }, "现在备份");
|
|
459
|
+
function render(b) {
|
|
460
|
+
fill(box, h("h4", {}, "数据库备份"),
|
|
461
|
+
h("p", { class: "muted" }, "整个实例数据库每天自动备份到 " + b.dir + ",保留最近 7 天、4 周、12 个月。可用 AGENT_LOFT_BACKUP_DIR 指定其他磁盘。"),
|
|
462
|
+
h("div", { class: "row" }, button, b.last ? "上次备份:" + relTime(b.last.at) + ",共 " + b.count + " 份" : "还没有备份"),
|
|
463
|
+
b.error ? h("p", { class: "error-text" }, b.error.message) : null);
|
|
464
|
+
}
|
|
465
|
+
render(status);
|
|
466
|
+
return box;
|
|
467
|
+
}
|
package/web/settings/weixin.js
CHANGED
|
@@ -71,7 +71,7 @@ export function weixinLinkSection() {
|
|
|
71
71
|
const expert = h("select", { disabled: !choices.length, "aria-label": "微信专家", style: { flex: "1", minWidth: "0" } },
|
|
72
72
|
!currentAvailable ? h("option", { value: "", selected: true, disabled: true }, choices.length ? "当前专家已不可用,请重新选择" : "没有可用的专家") : null,
|
|
73
73
|
choices.map((e) => h("option", { value: e.id, selected: e.id === data.expert }, e.label)));
|
|
74
|
-
const change = h("button", { class: "btn", disabled: true }, "
|
|
74
|
+
const change = h("button", { class: "btn", disabled: true }, "切换并开启新会话");
|
|
75
75
|
expert.onchange = () => { change.disabled = !expert.value || expert.value === data.expert; };
|
|
76
76
|
change.onclick = async () => {
|
|
77
77
|
change.disabled = true;
|
package/web/state.js
CHANGED
|
@@ -56,12 +56,12 @@ export const ui = {};
|
|
|
56
56
|
|
|
57
57
|
/** 设置页保留底下的会话或工具页,刷新和后台重连都用同一条返回地址。 */
|
|
58
58
|
export function contentHash() {
|
|
59
|
-
return location.hash
|
|
59
|
+
return /^#(?:settings|assistants)(?:\/|$)/.test(location.hash) ? (history.state?.settingsReturnHash ?? "") : location.hash;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
export function setContentHash(hash) {
|
|
63
63
|
if (ui.settings) {
|
|
64
|
-
history.replaceState({ ...history.state, settingsReturnHash: hash }, "",
|
|
64
|
+
history.replaceState({ ...history.state, settingsReturnHash: hash }, "", location.hash);
|
|
65
65
|
} else {
|
|
66
66
|
history.replaceState(history.state, "", hash || location.pathname + location.search);
|
|
67
67
|
}
|
package/web/views/layout.js
CHANGED
|
@@ -162,11 +162,11 @@ export async function boot() {
|
|
|
162
162
|
if (desktopQuota) desktop.onQuota(applyDesktopQuota);
|
|
163
163
|
else void loadQuota();
|
|
164
164
|
if (srv && srv !== HOME) routeToServer(srv, decodeURIComponent(landing.hash.slice(1)));
|
|
165
|
-
const restoreSettings = location.hash
|
|
165
|
+
const restoreSettings = /^#(settings|assistants)(?:\/(.*))?$/.exec(location.hash);
|
|
166
166
|
const fromHash = decodeURIComponent(contentHash().slice(1));
|
|
167
167
|
// 地址里带了会话就打开它;否则打开最近活跃的 Web 对话,没有才进新对话页
|
|
168
168
|
const latest = latestConversation("web");
|
|
169
|
-
if (restoreSettings) void openSettings();
|
|
169
|
+
if (restoreSettings) void openSettings(restoreSettings[2], restoreSettings[1]);
|
|
170
170
|
if (fromHash === "tasks") openTasksView();
|
|
171
171
|
else if (fromHash === "memos") await openMemosView();
|
|
172
172
|
else if (fromHash === "library") openLibraryView();
|
|
@@ -22,7 +22,7 @@ export async function memoAccessSettings(source) {
|
|
|
22
22
|
const save = h("button", { class: "btn primary", type: "submit" }, "保存权限");
|
|
23
23
|
const form = h("form", { class: "modal-body memo-fields" },
|
|
24
24
|
h("label", {}, "默认权限", select),
|
|
25
|
-
h("small", {}, "专家默认沿用此权限。可在「设置 → 专家」中为指定专家单独设置。"),
|
|
25
|
+
h("small", {}, "专家默认沿用此权限。可在「设置 → 助手 → 专家」中为指定专家单独设置。"),
|
|
26
26
|
h("small", {}, "授权后会建立全文索引。在专家对话里直接说「帮我搜笔记」或「把这段记到笔记里」即可。"),
|
|
27
27
|
status, refresh, save);
|
|
28
28
|
let timer, sequence = 0;
|
|
@@ -25,7 +25,7 @@ export function bindSidebarGestures(layout, sidebar) {
|
|
|
25
25
|
if (!mobile.matches || e.touches.length !== 1) return;
|
|
26
26
|
if (e.defaultPrevented || document.querySelector(".overlay, .popover")) return;
|
|
27
27
|
const target = e.target;
|
|
28
|
-
if (!(target instanceof Element) || target.closest("input, textarea, select, [contenteditable]:not([contenteditable='false']), .desk-viewport, .term-pane, .msg-nav, .ws-panel") || ownsHorizontalScroll(target)) return;
|
|
28
|
+
if (!(target instanceof Element) || target.closest("input, textarea, select, [contenteditable]:not([contenteditable='false']), .desk-viewport, .term-pane, .msg-nav, .ws-panel, .settings-view") || ownsHorizontalScroll(target)) return;
|
|
29
29
|
if (window.getSelection()?.isCollapsed === false) return;
|
|
30
30
|
const touch = e.touches[0];
|
|
31
31
|
const open = layout.classList.contains("side-open");
|
package/web/views/sidebar-nav.js
CHANGED
|
@@ -25,11 +25,11 @@ function configuredItems() {
|
|
|
25
25
|
seen.add(item.id);
|
|
26
26
|
items.push({ ...item, visible: saved.visible !== false });
|
|
27
27
|
}
|
|
28
|
-
return [...items, ...ITEMS.filter((it) => !seen.has(it.id)).map((it) => ({ ...it, visible:
|
|
28
|
+
return [...items, ...ITEMS.filter((it) => !seen.has(it.id)).map((it) => ({ ...it, visible: true }))];
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const available = (item) => item.id !== "remote" || remoteTabs().length > 0;
|
|
32
|
-
const isActive = (item) => (ui.settings
|
|
32
|
+
const isActive = (item) => (ui.settings?.area ?? S.view) === item.id;
|
|
33
33
|
const remoteLive = () => S.remoteLive.desktop || S.remoteLive.terminals > 0;
|
|
34
34
|
|
|
35
35
|
function navButton(item, inMenu = false) {
|
package/web/views/tasks.js
CHANGED
|
@@ -532,7 +532,7 @@ export function openTaskForm(task, preset) {
|
|
|
532
532
|
const context = h("select", { class: "task-context" }, keepOption, h("option", { value: "fresh", selected: !!src.freshContext }, "不携带(每次都从头开始)"));
|
|
533
533
|
const contextHint = h("small", {});
|
|
534
534
|
const contextField = h("div", { class: "field" }, h("span", {}, "上下文"), context, contextHint);
|
|
535
|
-
const dedicatedBox = h("div", { class: "task-dedicated" }, field("专家", expert, "到点由这个专家来做。要联网、读文件还是跑命令,看专家的权限(设置 → 专家)。"), modelRow, cwdField, permissionField);
|
|
535
|
+
const dedicatedBox = h("div", { class: "task-dedicated" }, field("专家", expert, "到点由这个专家来做。要联网、读文件还是跑命令,看专家的权限(设置 → 助手 → 专家)。"), modelRow, cwdField, permissionField);
|
|
536
536
|
// 发到已有对话:专家、目录属于对话,中途换不了,只显示;权限可以改,改的是对话自己的
|
|
537
537
|
const convBox = h("div", { class: "task-dedicated task-conv" });
|
|
538
538
|
let convPermission = null;
|
package/web/views/topbar.js
CHANGED