@agent_memory/dsh 0.4.0 → 0.5.1
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/client/client.js +41 -0
- package/dist/plugin.mjs +798 -109
- package/dist/plugin.mjs.map +4 -4
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -588,6 +588,8 @@ function MemoryPage() {
|
|
|
588
588
|
const [tagDraft, setTagDraft] = React2.useState("");
|
|
589
589
|
const [relationTarget, setRelationTarget] = React2.useState("");
|
|
590
590
|
const [relationType, setRelationType] = React2.useState("relates_to");
|
|
591
|
+
const [updateInfo, setUpdateInfo] = React2.useState(null);
|
|
592
|
+
const [updateBusy, setUpdateBusy] = React2.useState(false);
|
|
591
593
|
React2.useEffect(() => {
|
|
592
594
|
persistTheme(theme);
|
|
593
595
|
}, [theme]);
|
|
@@ -705,6 +707,29 @@ function MemoryPage() {
|
|
|
705
707
|
fetch("/api/agent-memory/rules", { headers: { accept: "application/json" } }).then((response) => response.json()).then((data2) => setRulesText(data2.text || "")).catch(() => setNotice("读取规则失败"));
|
|
706
708
|
fetch("/api/agent-memory/soul-path", { headers: { accept: "application/json" } }).then((response) => response.json()).then((data2) => setSoulPath(data2)).catch(() => setSoulPath(null));
|
|
707
709
|
};
|
|
710
|
+
const checkUpdate = () => {
|
|
711
|
+
setUpdateBusy(true);
|
|
712
|
+
setUpdateInfo({ checking: true });
|
|
713
|
+
fetch("/api/agent-memory/update/check", { headers: { accept: "application/json" } }).then(async (response) => {
|
|
714
|
+
const data2 = await response.json();
|
|
715
|
+
if (!response.ok) throw new Error(data2.error || `HTTP ${response.status}`);
|
|
716
|
+
return data2;
|
|
717
|
+
}).then((data2) => setUpdateInfo(data2)).catch((error) => setUpdateInfo({ error: String(error) })).finally(() => setUpdateBusy(false));
|
|
718
|
+
};
|
|
719
|
+
const applyUpdate = () => {
|
|
720
|
+
if (updateInfo === null || typeof updateInfo.latest !== "string") return;
|
|
721
|
+
setUpdateBusy(true);
|
|
722
|
+
setUpdateInfo((previous) => ({ ...previous || {}, applying: true }));
|
|
723
|
+
fetch("/api/agent-memory/update/apply", {
|
|
724
|
+
method: "POST",
|
|
725
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
726
|
+
body: JSON.stringify({ version: updateInfo.latest })
|
|
727
|
+
}).then(async (response) => {
|
|
728
|
+
const data2 = await response.json();
|
|
729
|
+
if (!response.ok || data2.ok === false) throw new Error(data2.error || `HTTP ${response.status}`);
|
|
730
|
+
return data2;
|
|
731
|
+
}).then((data2) => setUpdateInfo((previous) => ({ ...previous || {}, applied: data2 }))).catch((error) => setUpdateInfo((previous) => ({ ...previous || {}, applyError: String(error) }))).finally(() => setUpdateBusy(false));
|
|
732
|
+
};
|
|
708
733
|
const openCreate = (kind) => {
|
|
709
734
|
setPanel("create");
|
|
710
735
|
setCreateKind(kind);
|
|
@@ -1640,6 +1665,22 @@ ${lines.join("\n")}`);
|
|
|
1640
1665
|
),
|
|
1641
1666
|
React2.createElement("p", { style: styles.small }, soulPath.hint)
|
|
1642
1667
|
),
|
|
1668
|
+
React2.createElement("h2", { style: styles.groupTitle }, "插件更新"),
|
|
1669
|
+
React2.createElement(
|
|
1670
|
+
"div",
|
|
1671
|
+
{ style: styles.actions },
|
|
1672
|
+
React2.createElement(
|
|
1673
|
+
AmButton,
|
|
1674
|
+
{ variant: "ghost", disabled: updateBusy, onClick: checkUpdate },
|
|
1675
|
+
"检查更新"
|
|
1676
|
+
),
|
|
1677
|
+
updateInfo !== null && updateInfo.update_available === true ? React2.createElement(
|
|
1678
|
+
AmButton,
|
|
1679
|
+
{ variant: "primary", disabled: updateBusy, onClick: applyUpdate },
|
|
1680
|
+
`升级到 ${updateInfo.latest}`
|
|
1681
|
+
) : null
|
|
1682
|
+
),
|
|
1683
|
+
updateInfo === null ? React2.createElement("p", { style: styles.small }, "不会自动联网;点一下才会检查。") : updateInfo.checking === true ? React2.createElement("p", { style: styles.small }, "正在检查…") : updateInfo.error !== void 0 ? React2.createElement("p", { style: styles.small }, `检查失败:${updateInfo.error}`) : updateInfo.applied !== void 0 ? React2.createElement("p", { style: styles.small }, "新版本已安装,请完整重启 DSH 后生效。") : updateInfo.applyError !== void 0 ? React2.createElement("p", { style: styles.small }, `升级失败:${updateInfo.applyError}`) : updateInfo.applying === true ? React2.createElement("p", { style: styles.small }, "正在安装…") : updateInfo.update_available === true ? React2.createElement("p", { style: styles.small }, `当前 ${updateInfo.current},最新 ${updateInfo.latest}。`) : React2.createElement("p", { style: styles.small }, `已是最新版本(${updateInfo.current})。`),
|
|
1643
1684
|
React2.createElement("button", { style: { ...styles.button, marginTop: "12px" }, onClick: () => setPanel(null) }, "返回列表")
|
|
1644
1685
|
) : null,
|
|
1645
1686
|
panel !== null ? null : React2.createElement(
|