dsh-macro-memory 0.0.0-stage → 0.3.0
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/LICENSE +21 -0
- package/README.md +457 -2
- package/cordis.patch.yml +6 -0
- package/lib/client.js +3623 -0
- package/lib/index.js +469 -0
- package/lib/macro/brand.js +82 -0
- package/lib/macro/bridge.js +158 -0
- package/lib/macro/chain.js +206 -0
- package/lib/macro/contract.js +471 -0
- package/lib/macro/cost.js +164 -0
- package/lib/macro/defs/admin.js +439 -0
- package/lib/macro/defs/dream.js +24 -0
- package/lib/macro/defs/link.js +257 -0
- package/lib/macro/defs/project.js +25 -0
- package/lib/macro/defs/read.js +145 -0
- package/lib/macro/defs/remember.js +213 -0
- package/lib/macro/defs/search.js +661 -0
- package/lib/macro/defs/update.js +161 -0
- package/lib/macro/dreamledger.js +1398 -0
- package/lib/macro/facade.js +135 -0
- package/lib/macro/fusion.js +182 -0
- package/lib/macro/linkflow.js +391 -0
- package/lib/macro/links.js +448 -0
- package/lib/macro/neighbor.js +209 -0
- package/lib/macro/panel.js +96 -0
- package/lib/macro/prompt.js +139 -0
- package/lib/macro/provenance.js +148 -0
- package/lib/macro/render.js +35 -0
- package/lib/macro/revisions.js +253 -0
- package/lib/macro/shared.js +113 -0
- package/lib/macro/store.js +103 -0
- package/lib/macro/tokencost.js +90 -0
- package/lib/macro/tools.js +67 -0
- package/package.json +54 -4
- package/vendor/VENDOR.json +23 -0
- package/vendor/dsh-memory-nebula/CONTRIBUTING.md +48 -0
- package/vendor/dsh-memory-nebula/LICENSE +21 -0
- package/vendor/dsh-memory-nebula/README.en.md +203 -0
- package/vendor/dsh-memory-nebula/README.md +253 -0
- package/vendor/dsh-memory-nebula/SECURITY.md +43 -0
- package/vendor/dsh-memory-nebula/SUPPORT.md +33 -0
- package/vendor/dsh-memory-nebula/cordis.patch.yml +4 -0
- package/vendor/dsh-memory-nebula/lib/client.js +105 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/index.js +279 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/ingest.js +230 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/meow.js +317 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/notes.js +305 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/sqlite.js +287 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/util.js +231 -0
- package/vendor/dsh-memory-nebula/lib/host/bridge.js +351 -0
- package/vendor/dsh-memory-nebula/lib/host/compress.js +97 -0
- package/vendor/dsh-memory-nebula/lib/host/demo.js +357 -0
- package/vendor/dsh-memory-nebula/lib/host/diagnostics.js +125 -0
- package/vendor/dsh-memory-nebula/lib/host/doctor.js +270 -0
- package/vendor/dsh-memory-nebula/lib/host/graph.js +1663 -0
- package/vendor/dsh-memory-nebula/lib/host/graphcache.js +282 -0
- package/vendor/dsh-memory-nebula/lib/host/http.js +993 -0
- package/vendor/dsh-memory-nebula/lib/host/injectcfg.js +95 -0
- package/vendor/dsh-memory-nebula/lib/host/ledger.js +175 -0
- package/vendor/dsh-memory-nebula/lib/host/live.js +204 -0
- package/vendor/dsh-memory-nebula/lib/host/nebula.js +2105 -0
- package/vendor/dsh-memory-nebula/lib/host/page.js +75 -0
- package/vendor/dsh-memory-nebula/lib/host/path.js +83 -0
- package/vendor/dsh-memory-nebula/lib/host/recall.js +451 -0
- package/vendor/dsh-memory-nebula/lib/host/share.js +633 -0
- package/vendor/dsh-memory-nebula/lib/host/sources.js +266 -0
- package/vendor/dsh-memory-nebula/lib/host/store.js +333 -0
- package/vendor/dsh-memory-nebula/lib/host/text.js +410 -0
- package/vendor/dsh-memory-nebula/lib/host/transcripts.js +396 -0
- package/vendor/dsh-memory-nebula/lib/index.js +759 -0
- package/vendor/dsh-memory-nebula/lib/standalone.mjs +315 -0
- package/vendor/dsh-memory-nebula/lib/web/api.js +426 -0
- package/vendor/dsh-memory-nebula/lib/web/app.js +4159 -0
- package/vendor/dsh-memory-nebula/lib/web/i18n.js +580 -0
- package/vendor/dsh-memory-nebula/lib/web/index.html +174 -0
- package/vendor/dsh-memory-nebula/lib/web/nav.js +132 -0
- package/vendor/dsh-memory-nebula/lib/web/render.js +1890 -0
- package/vendor/dsh-memory-nebula/lib/web/space3d.js +1883 -0
- package/vendor/dsh-memory-nebula/lib/web/style.css +1402 -0
- package/vendor/dsh-memory-nebula/locale/en.json +7 -0
- package/vendor/dsh-memory-nebula/locale/zh.json +7 -0
- package/vendor/dsh-memory-nebula/market/assets/icon-180.png +0 -0
- package/vendor/dsh-memory-nebula/market/assets/icon.svg +40 -0
- package/vendor/dsh-memory-nebula/market/index.json +101 -0
- package/vendor/dsh-memory-nebula/package.json +87 -0
- package/vendor/dsh-memory-nebula/sidecar.ps1 +119 -0
- package/vendor/meow-memory/LICENSE +21 -0
- package/vendor/meow-memory/README.en.md +192 -0
- package/vendor/meow-memory/README.md +174 -0
- package/vendor/meow-memory/README.pt-br.md +180 -0
- package/vendor/meow-memory/cordis.patch.yml +7 -0
- package/vendor/meow-memory/lib/client.js +3344 -0
- package/vendor/meow-memory/lib/client.js.map +7 -0
- package/vendor/meow-memory/lib/index.js +9567 -0
- package/vendor/meow-memory/lib/index.js.map +7 -0
- package/vendor/meow-memory/lib/prompts/README.md +65 -0
- package/vendor/meow-memory/lib/prompts/en/dream-atomic.md +36 -0
- package/vendor/meow-memory/lib/prompts/en/dream-header.md +9 -0
- package/vendor/meow-memory/lib/prompts/en/dream-project-summary.md +12 -0
- package/vendor/meow-memory/lib/prompts/en/dream-topic.md +27 -0
- package/vendor/meow-memory/lib/prompts/en/external-memory-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/en/first-create-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/en/labels.md +98 -0
- package/vendor/meow-memory/lib/prompts/en/reflect.md +31 -0
- package/vendor/meow-memory/lib/prompts/en/system-guide.md +121 -0
- package/vendor/meow-memory/lib/prompts/en/tools.md +83 -0
- package/vendor/meow-memory/lib/prompts/en/welcome-guide.md +12 -0
- package/vendor/meow-memory/lib/prompts/pt-br/dream-atomic.md +36 -0
- package/vendor/meow-memory/lib/prompts/pt-br/dream-header.md +9 -0
- package/vendor/meow-memory/lib/prompts/pt-br/dream-project-summary.md +12 -0
- package/vendor/meow-memory/lib/prompts/pt-br/dream-topic.md +27 -0
- package/vendor/meow-memory/lib/prompts/pt-br/external-memory-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/pt-br/first-create-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/pt-br/labels.md +98 -0
- package/vendor/meow-memory/lib/prompts/pt-br/reflect.md +31 -0
- package/vendor/meow-memory/lib/prompts/pt-br/system-guide.md +121 -0
- package/vendor/meow-memory/lib/prompts/pt-br/tools.md +83 -0
- package/vendor/meow-memory/lib/prompts/pt-br/welcome-guide.md +12 -0
- package/vendor/meow-memory/lib/prompts/zh/dream-atomic.md +36 -0
- package/vendor/meow-memory/lib/prompts/zh/dream-header.md +9 -0
- package/vendor/meow-memory/lib/prompts/zh/dream-project-summary.md +19 -0
- package/vendor/meow-memory/lib/prompts/zh/dream-topic.md +27 -0
- package/vendor/meow-memory/lib/prompts/zh/external-memory-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/zh/first-create-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/zh/labels.md +98 -0
- package/vendor/meow-memory/lib/prompts/zh/reflect.md +30 -0
- package/vendor/meow-memory/lib/prompts/zh/system-guide.md +119 -0
- package/vendor/meow-memory/lib/prompts/zh/tools.md +83 -0
- package/vendor/meow-memory/lib/prompts/zh/welcome-guide.md +12 -0
- package/vendor/meow-memory/package.json +64 -0
|
@@ -0,0 +1,3344 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "meow-memory",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
"use strict";
|
|
7
|
+
var __create = Object.create;
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
|
+
|
|
35
|
+
// src/client.ts
|
|
36
|
+
var client_exports = {};
|
|
37
|
+
__export(client_exports, {
|
|
38
|
+
MemoryFoldDock: () => MemoryFoldDock,
|
|
39
|
+
apply: () => apply,
|
|
40
|
+
inject: () => inject,
|
|
41
|
+
mountMemoryFoldView: () => mountMemoryFoldView
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(client_exports);
|
|
44
|
+
var import_react = require("react");
|
|
45
|
+
|
|
46
|
+
// src/i18n/en.ts
|
|
47
|
+
var en = {
|
|
48
|
+
// ── reflection / dream turn bars ──────────────────────────────────────────
|
|
49
|
+
"fold.title.reflect": "Memory reflection",
|
|
50
|
+
"fold.title.dream": "Memory dream task",
|
|
51
|
+
"fold.status.running": "{title} in progress\u2026",
|
|
52
|
+
"fold.hint.running": " (your message joins this turn)",
|
|
53
|
+
"fold.status.interrupted": "{title} interrupted",
|
|
54
|
+
"fold.status.remembered": "{title} \xB7 {n} memories added",
|
|
55
|
+
"fold.status.updated": "{title} \xB7 {n} updated",
|
|
56
|
+
"fold.status.nothing": "{title} \xB7 nothing to save",
|
|
57
|
+
// ── memory injection bars ─────────────────────────────────────────────────
|
|
58
|
+
"inject.bar": "Memory injected",
|
|
59
|
+
"inject.kind.first": " (long-term)",
|
|
60
|
+
"inject.kind.hit": " (keyword hits)",
|
|
61
|
+
"inject.expand": "Click to expand",
|
|
62
|
+
"inject.collapse": "Click to collapse",
|
|
63
|
+
"inject.copy": "Copy",
|
|
64
|
+
"inject.copied": "Copied",
|
|
65
|
+
"inject.result": "[Result]",
|
|
66
|
+
// ── delegate marker bubbles ───────────────────────────────────────────────
|
|
67
|
+
"notice.reflect.running": "\u25B8 Memory reflection task in progress\u2026",
|
|
68
|
+
"notice.reflect.done": "\u25B8 Memory reflection task completed.",
|
|
69
|
+
"notice.dream.running": "\u25B8 Memory dream task in progress\u2026",
|
|
70
|
+
"notice.dream.done": "\u25B8 Memory dream task completed.",
|
|
71
|
+
"notice.dream.interrupted": "\u25B8 Memory dream task interrupted; retrying automatically later.",
|
|
72
|
+
// ── session menu ──────────────────────────────────────────────────────────
|
|
73
|
+
"part.menu": "Memory participation",
|
|
74
|
+
"part.state.active": "All on",
|
|
75
|
+
"part.state.writeonly": "No auto-injection",
|
|
76
|
+
"part.state.readonly": "No auto-consolidation",
|
|
77
|
+
"part.state.exited": "Tools only",
|
|
78
|
+
"part.panel.inject": "Auto injection (first-turn, per-turn, post-compaction)",
|
|
79
|
+
"part.panel.consolidate": "Auto consolidation (reflect + dream)",
|
|
80
|
+
"part.panel.on": "On",
|
|
81
|
+
"part.panel.off": "Off",
|
|
82
|
+
// ── settings tab ──────────────────────────────────────────────────────────
|
|
83
|
+
"settings.title": "Meow memory",
|
|
84
|
+
"settings.summary": 'Every setting of the cross-session memory plugin. Changes are stored in DSH settings (per field; "Restore default" goes back to the plugin factory default and ignores the patch assembly baseline); they take effect immediately: surface fields rebuild the tool set, engine fields re-mount the memory engine.',
|
|
85
|
+
"settings.loading": "Loading Macro Memory configuration\u2026",
|
|
86
|
+
"settings.unavailable": "This connection has no settings write channel, so this field cannot be saved.",
|
|
87
|
+
"settings.readonly": "This connection is read-only, so settings cannot be saved from here.",
|
|
88
|
+
"settings.saved": "Saved \u2713 takes effect immediately: surface fields rebuild the tool set, engine fields re-mount the memory engine",
|
|
89
|
+
"settings.badge.override": "Overridden",
|
|
90
|
+
"settings.badge.default": "Default",
|
|
91
|
+
"settings.reset": "Restore default",
|
|
92
|
+
"settings.saveFailed": "Save failed: {error}",
|
|
93
|
+
"settings.saveNotApplied": "Save did not take effect: the server rejected the write (it may have failed validation). Showing the current server value again.",
|
|
94
|
+
"settings.resetFailed": "Restore default failed: {error}",
|
|
95
|
+
"settings.resetNotApplied": "Restore default did not take effect; please try again.",
|
|
96
|
+
"settings.suppress.format": 'A window must look like "HH:MM-HH:MM"; got "{value}"',
|
|
97
|
+
"settings.suppress.atLeastOne": "At least one window is required",
|
|
98
|
+
"settings.group.base": "Basics",
|
|
99
|
+
"settings.group.inject": "Injection and hits",
|
|
100
|
+
"settings.group.reflect": "Reflection",
|
|
101
|
+
"settings.group.delegate": "Consolidation task model",
|
|
102
|
+
"settings.group.dream": "Idle consolidation (dream)",
|
|
103
|
+
"settings.group.language": "Language",
|
|
104
|
+
"settings.group.storage": "Directories & migration",
|
|
105
|
+
"settings.field.enabled.label": "Master switch",
|
|
106
|
+
"settings.field.enabled.hint": "When off, injection, reflection and the memory tools are all disabled",
|
|
107
|
+
"settings.field.projectDir.label": "Memory directory",
|
|
108
|
+
"settings.field.projectDir.hint": "Data directory, relative to the workspace",
|
|
109
|
+
"settings.field.homeDir.label": "Global data directory",
|
|
110
|
+
"settings.field.homeDir.hint": "Where instance-level data (logs, window index) lives. On change, contents of the old directory are migrated automatically (same-disk move / cross-disk copy); after a cross-disk copy the old directory is kept \u2014 delete it manually once verified. If multiple dsh instances share one directory, update them together.",
|
|
111
|
+
"settings.field.homeDir.preset.default": "System user home (default)",
|
|
112
|
+
"settings.field.homeDir.preset.dshStorage": "DSH home storage",
|
|
113
|
+
"settings.field.homeDir.preset.pluginRoot": "Plugin folder",
|
|
114
|
+
"settings.field.homeDir.preset.custom": "Custom path",
|
|
115
|
+
"settings.mirrorReadonly": "Non-local connection: dsh serves this settings page as a read-only mirror and no change will be saved. Open dsh via 127.0.0.1 on the host machine to edit settings.",
|
|
116
|
+
"settings.field.autoMigrate.label": "Auto-migrate old database",
|
|
117
|
+
"settings.field.autoMigrate.hint": "Migrate PROJECT.md automatically the first time a v1 database is opened",
|
|
118
|
+
"settings.field.hitTopK.label": "Max hits per message",
|
|
119
|
+
"settings.field.hitTopK.hint": "Upper bound on keyword-hit entries injected per message (fact/lesson/rules/topic)",
|
|
120
|
+
"settings.field.titleMax.label": "Guide title truncation length",
|
|
121
|
+
"settings.field.titleMax.hint": "Truncation length (characters) of the project list in the memory guide",
|
|
122
|
+
"settings.field.reflect.label": "Automatic reflection",
|
|
123
|
+
"settings.field.reflect.hint": "Review memory automatically after a task ends",
|
|
124
|
+
"settings.field.reflectTurns.label": "Reflection trigger turns",
|
|
125
|
+
"settings.field.reflectTurns.hint": "Consecutive tool steps inside one task needed to trigger at the end",
|
|
126
|
+
"settings.field.delegateModel.label": "Reflection/dream model override",
|
|
127
|
+
"settings.field.delegateModel.hint": "Empty = the main model throughout. When set, reflection and dream turns run on that model and switch back to the main model at the end of the turn (the rest of the conversation is unaffected); 'provider/model' selects the route, 'model' only changes the model name",
|
|
128
|
+
"settings.field.delegateModel.placeholder": "e.g. zai-coding-cn/glm-5.3-flash",
|
|
129
|
+
"settings.field.delegateEffort.label": "Reasoning effort for the delegate model",
|
|
130
|
+
"settings.field.delegateEffort.hint": "Empty = strip the main session's reasoning effort (default, recommended: requests fail outright with UNSUPPORTED_REASONING_EFFORT if the target model does not declare efforts). 'inherit' keeps the main effort; or set a value the delegate model supports (e.g. high)",
|
|
131
|
+
"settings.field.delegateEffort.placeholder": "empty = strip; inherit / low / medium / high",
|
|
132
|
+
"fold.body.unloaded": "This turn's content is not loaded yet (not mounted under virtual scrolling) \u2014 scroll to that turn and it fills in automatically",
|
|
133
|
+
"settings.field.dreamEnabled.label": "Idle consolidation switch",
|
|
134
|
+
"settings.field.dream.idleMinutes.label": "Idle minutes",
|
|
135
|
+
"settings.field.dream.idleMinutes.hint": "A window idle for this many minutes allows a dream",
|
|
136
|
+
"settings.field.dream.suppressWindows.label": "Peak-hour suppression windows",
|
|
137
|
+
"settings.field.dream.suppressWindows.hint": 'Comma-separated "HH:MM-HH:MM"; no dream is triggered inside these windows',
|
|
138
|
+
"settings.field.dream.suppressLeadMinutes.label": "Extra suppression before peak (minutes)",
|
|
139
|
+
"settings.field.dream.checkMinutes.label": "Check interval (minutes)",
|
|
140
|
+
"settings.field.dream.timeZone.label": "Timezone for suppression windows",
|
|
141
|
+
"settings.field.dream.timeZone.hint": "Peak windows are computed in this fixed timezone (independent of the system clock)",
|
|
142
|
+
"settings.field.dream.rulesReviewDays.label": "Rules anti-churn days",
|
|
143
|
+
"settings.field.dream.rulesReviewDays.hint": "Stable rules whose updated_at is older than this many days skip dream round 1; 0 = no filter",
|
|
144
|
+
"settings.field.promptLang.label": "Prompt and retrieval language",
|
|
145
|
+
"settings.field.promptLang.hint": "Empty = zh by default (sessions that never configured it get a one-time first-run guide); 'en' = built-in English pack. The UI language is unrelated \u2014 that follows the DSH language setting. The language must match the one you speak, or keyword hit rates drop",
|
|
146
|
+
"settings.field.promptLang.placeholder": "zh / en",
|
|
147
|
+
// ── date and time ─────────────────────────────────────────────────────────
|
|
148
|
+
"datetime.ymd": "{m}/{d}",
|
|
149
|
+
"datetime.ymdFull": "{y}/{m}/{d}"
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// src/i18n/zh.ts
|
|
153
|
+
var zh = {
|
|
154
|
+
// ── 反思 / dream 轮横条 ────────────────────────────────────────────────────
|
|
155
|
+
"fold.title.reflect": "\u8BB0\u5FC6\u53CD\u601D",
|
|
156
|
+
"fold.title.dream": "\u8BB0\u5FC6\u68A6\u5883\u4EFB\u52A1",
|
|
157
|
+
"fold.status.running": "{title}\u8FDB\u884C\u4E2D\u2026",
|
|
158
|
+
"fold.hint.running": "\uFF08\u63D2\u8BDD\u4F1A\u62FC\u8FDB\u672C\u8F6E\uFF09",
|
|
159
|
+
"fold.status.interrupted": "{title}\u5DF2\u4E2D\u65AD",
|
|
160
|
+
"fold.status.remembered": "{title} \xB7 \u65B0\u589E\u8BB0\u5FC6 {n} \u6761",
|
|
161
|
+
"fold.status.updated": "{title} \xB7 \u5DF2\u66F4\u65B0 {n} \u6761",
|
|
162
|
+
"fold.status.nothing": "{title} \xB7 \u65E0\u9700\u8BB0\u5FC6",
|
|
163
|
+
// ── 记忆注入横条 ──────────────────────────────────────────────────────────
|
|
164
|
+
"inject.bar": "\u5DF2\u6CE8\u5165\u8BB0\u5FC6",
|
|
165
|
+
"inject.kind.first": "\uFF08\u957F\u671F\u8BB0\u5FC6\uFF09",
|
|
166
|
+
"inject.kind.hit": "\uFF08\u5173\u952E\u8BCD\u547D\u4E2D\uFF09",
|
|
167
|
+
"inject.expand": "\u70B9\u51FB\u5C55\u5F00",
|
|
168
|
+
"inject.collapse": "\u70B9\u51FB\u6536\u8D77",
|
|
169
|
+
"inject.copy": "\u590D\u5236",
|
|
170
|
+
"inject.copied": "\u5DF2\u590D\u5236",
|
|
171
|
+
"inject.result": "\u3010\u7ED3\u679C\u3011",
|
|
172
|
+
// ── delegate 打点气泡 ─────────────────────────────────────────────────────
|
|
173
|
+
"notice.reflect.running": "\u25B8 \u8BB0\u5FC6\u53CD\u601D\u4EFB\u52A1\u8FDB\u884C\u4E2D\u2026\u2026",
|
|
174
|
+
"notice.reflect.done": "\u25B8 \u8BB0\u5FC6\u53CD\u601D\u4EFB\u52A1\u5DF2\u5B8C\u6210\u3002",
|
|
175
|
+
"notice.dream.running": "\u25B8 \u68A6\u5883\u8BB0\u5FC6\u6574\u7406\u4EFB\u52A1\u8FDB\u884C\u4E2D\u2026\u2026",
|
|
176
|
+
"notice.dream.done": "\u25B8 \u68A6\u5883\u8BB0\u5FC6\u6574\u7406\u4EFB\u52A1\u5DF2\u5B8C\u6210\u3002",
|
|
177
|
+
"notice.dream.interrupted": "\u25B8 \u68A6\u5883\u8BB0\u5FC6\u6574\u7406\u5DF2\u4E2D\u65AD\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\u3002",
|
|
178
|
+
// ── 会话菜单 ──────────────────────────────────────────────────────────────
|
|
179
|
+
"part.menu": "\u8BB0\u5FC6\u53C2\u4E0E",
|
|
180
|
+
"part.state.active": "\u529F\u80FD\u5168\u5F00",
|
|
181
|
+
"part.state.writeonly": "\u4E0D\u81EA\u52A8\u6CE8\u5165",
|
|
182
|
+
"part.state.readonly": "\u4E0D\u81EA\u52A8\u6574\u7406",
|
|
183
|
+
"part.state.exited": "\u53EA\u7528\u5DE5\u5177",
|
|
184
|
+
"part.panel.inject": "\u81EA\u52A8\u6CE8\u5165\uFF08\u9996\u8F6E\u3001\u6BCF\u8F6E\u3001\u538B\u7F29\u540E\u91CD\u6CE8\u5165\uFF09",
|
|
185
|
+
"part.panel.consolidate": "\u81EA\u52A8\u6574\u7406\uFF08\u53CD\u601D\u3001\u68A6\u5883\uFF09",
|
|
186
|
+
"part.panel.on": "\u6253\u5F00",
|
|
187
|
+
"part.panel.off": "\u5173\u95ED",
|
|
188
|
+
// ── 设置页 ────────────────────────────────────────────────────────────────
|
|
189
|
+
"settings.title": "\u55B5\u8BB0\u5FC6",
|
|
190
|
+
"settings.summary": "\u8DE8\u4F1A\u8BDD\u8BB0\u5FC6\u63D2\u4EF6\u7684\u5168\u90E8\u8BBE\u7F6E\u3002\u6539\u52A8\u4FDD\u5B58\u5728 DSH \u8BBE\u7F6E\u91CC\uFF08\u5B57\u6BB5\u7EA7\uFF0C\u300C\u6062\u590D\u9ED8\u8BA4\u300D= \u56DE\u5230\u63D2\u4EF6\u51FA\u5382\u9ED8\u8BA4\uFF0C\u4E0D\u53D7 patch \u88C5\u914D\u57FA\u7EBF\u5F71\u54CD\uFF09\uFF1B\u751F\u6548\u662F\u5373\u65F6\u7684\uFF1A\u878D\u5408\u5C42\u5B57\u6BB5\u91CD\u5EFA\u5DE5\u5177\u9762\uFF0C\u8BB0\u5FC6\u5F15\u64CE\u5B57\u6BB5\u4F1A\u91CD\u65B0\u88C5\u914D\uFF08\u626B\u63CF\u4F1A\u91CD\u542F\uFF09\u3002",
|
|
191
|
+
"settings.loading": "\u5B8F\u8BB0\u5FC6\u914D\u7F6E\u52A0\u8F7D\u4E2D\u2026",
|
|
192
|
+
"settings.unavailable": "\u5F53\u524D\u8FDE\u63A5\u6CA1\u6709\u8BBE\u7F6E\u5199\u5165\u901A\u9053\uFF0C\u8FD9\u4E00\u9879\u5B58\u4E0D\u4E0B\u53BB\uFF08\u5176\u4F59\u529F\u80FD\u4E0D\u53D7\u5F71\u54CD\uFF09\u3002",
|
|
193
|
+
"settings.readonly": "\u5F53\u524D\u8FDE\u63A5\u662F\u53EA\u8BFB\u7684\uFF0C\u8BBE\u7F6E\u6539\u4E0D\u4E86\u3002",
|
|
194
|
+
"settings.saved": "\u5DF2\u4FDD\u5B58 \u2713 \u5DF2\u751F\u6548",
|
|
195
|
+
"settings.badge.override": "\u5DF2\u8986\u76D6",
|
|
196
|
+
"settings.badge.default": "\u9ED8\u8BA4",
|
|
197
|
+
"settings.reset": "\u6062\u590D\u9ED8\u8BA4",
|
|
198
|
+
"settings.saveFailed": "\u4FDD\u5B58\u5931\u8D25\uFF1A{error}",
|
|
199
|
+
"settings.saveNotApplied": "\u4FDD\u5B58\u672A\u751F\u6548\uFF1A\u5199\u5165\u88AB\u670D\u52A1\u5668\u62D2\u7EDD\uFF08\u53EF\u80FD\u672A\u901A\u8FC7\u6821\u9A8C\uFF09\uFF0C\u5DF2\u6062\u590D\u663E\u793A\u670D\u52A1\u5668\u5F53\u524D\u503C\u3002",
|
|
200
|
+
"settings.resetFailed": "\u6062\u590D\u9ED8\u8BA4\u5931\u8D25\uFF1A{error}",
|
|
201
|
+
"settings.resetNotApplied": "\u6062\u590D\u9ED8\u8BA4\u672A\u751F\u6548\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
202
|
+
"settings.suppress.format": '\u65F6\u6BB5\u683C\u5F0F\u5E94\u4E3A "HH:MM-HH:MM"\uFF0C\u6536\u5230 "{value}"',
|
|
203
|
+
"settings.suppress.atLeastOne": "\u81F3\u5C11\u4E00\u4E2A\u65F6\u6BB5",
|
|
204
|
+
"settings.group.base": "\u57FA\u7840",
|
|
205
|
+
"settings.group.inject": "\u6CE8\u5165\u4E0E\u547D\u4E2D",
|
|
206
|
+
"settings.group.reflect": "\u53CD\u601D",
|
|
207
|
+
"settings.group.delegate": "\u6574\u7406\u4EFB\u52A1\u6A21\u578B",
|
|
208
|
+
"settings.group.dream": "\u7A7A\u95F2\u6574\u7406\uFF08dream\uFF09",
|
|
209
|
+
"settings.group.language": "\u8BED\u8A00",
|
|
210
|
+
"settings.group.storage": "\u76EE\u5F55\u4E0E\u8FC1\u79FB",
|
|
211
|
+
"settings.field.enabled.label": "\u603B\u5F00\u5173",
|
|
212
|
+
"settings.field.enabled.hint": "\u5173\u95ED\u540E\u6CE8\u5165\u3001\u53CD\u601D\u3001\u8BB0\u5FC6\u5DE5\u5177\u5168\u90E8\u505C\u7528",
|
|
213
|
+
"settings.field.projectDir.label": "\u8BB0\u5FC6\u76EE\u5F55",
|
|
214
|
+
"settings.field.projectDir.hint": "\u76F8\u5BF9\u5DE5\u4F5C\u533A\u7684\u6570\u636E\u76EE\u5F55",
|
|
215
|
+
"settings.field.homeDir.label": "\u5168\u5C40\u6570\u636E\u76EE\u5F55",
|
|
216
|
+
"settings.field.homeDir.hint": "\u65E5\u5FD7\u7B49\u5B9E\u4F8B\u7EA7\u6570\u636E\u7684\u5B58\u653E\u4F4D\u7F6E\u3002\u5207\u6362\u540E\u81EA\u52A8\u628A\u65E7\u76EE\u5F55\u5185\u5BB9\u8FC1\u8FC7\u53BB\uFF08\u540C\u76D8\u79FB\u52A8/\u8DE8\u76D8\u590D\u5236\uFF09\uFF1B\u8DE8\u76D8\u590D\u5236\u65F6\u65E7\u76EE\u5F55\u4FDD\u7559\uFF0C\u786E\u8BA4\u65E0\u8BEF\u540E\u8BF7\u624B\u52A8\u5220\u9664\u3002\u82E5\u591A\u4E2A dsh \u5B9E\u4F8B\u5171\u4EAB\u540C\u4E00\u76EE\u5F55\uFF0C\u8BF7\u540C\u6B65\u4FEE\u6539\u5176\u4ED6\u5B9E\u4F8B\u7684\u8BBE\u7F6E\u3002",
|
|
217
|
+
"settings.field.homeDir.preset.default": "\u7CFB\u7EDF\u7528\u6237\u4E3B\u76EE\u5F55\uFF08\u9ED8\u8BA4\uFF09",
|
|
218
|
+
"settings.field.homeDir.preset.dshStorage": "DSH \u6839\u76EE\u5F55 Storage",
|
|
219
|
+
"settings.field.homeDir.preset.pluginRoot": "\u63D2\u4EF6\u672C\u4F53\u6839\u76EE\u5F55",
|
|
220
|
+
"settings.field.homeDir.preset.custom": "\u81EA\u5B9A\u4E49\u8DEF\u5F84",
|
|
221
|
+
"settings.mirrorReadonly": "\u5F53\u524D\u4E3A\u975E\u672C\u673A\u8FDE\u63A5\uFF1Adsh \u5C06\u8BBE\u7F6E\u9875\u964D\u4E3A\u53EA\u8BFB\u955C\u50CF\uFF0C\u4EFB\u4F55\u4FEE\u6539\u90FD\u4E0D\u4F1A\u88AB\u4FDD\u5B58\u3002\u8BF7\u5728\u5BBF\u4E3B\u672C\u673A\u901A\u8FC7 127.0.0.1 \u8BBF\u95EE dsh \u540E\u518D\u4FEE\u6539\u914D\u7F6E\u3002",
|
|
222
|
+
"settings.field.autoMigrate.label": "\u81EA\u52A8\u8FC1\u79FB\u65E7\u5E93",
|
|
223
|
+
"settings.field.autoMigrate.hint": "\u9996\u6B21\u6253\u5F00 v1 \u5E93\u65F6\u81EA\u52A8\u8FC1\u79FB PROJECT.md",
|
|
224
|
+
"settings.field.hitTopK.label": "\u6BCF\u6761\u6D88\u606F\u547D\u4E2D\u6761\u6570\u4E0A\u9650",
|
|
225
|
+
"settings.field.hitTopK.hint": "\u5173\u952E\u8BCD\u547D\u4E2D\u6CE8\u5165\u7684\u6761\u76EE\u4E0A\u9650\uFF08fact/lesson/rules/topic\uFF09",
|
|
226
|
+
"settings.field.titleMax.label": "\u5BFC\u5F15\u6807\u9898\u622A\u65AD\u957F\u5EA6",
|
|
227
|
+
"settings.field.titleMax.hint": "\u8BB0\u5FC6\u5BFC\u5F15\u91CC\u9879\u76EE\u5217\u8868\u7684\u622A\u65AD\u957F\u5EA6\uFF08\u5B57\u7B26\uFF09",
|
|
228
|
+
"settings.field.reflect.label": "\u81EA\u52A8\u53CD\u601D",
|
|
229
|
+
"settings.field.reflect.hint": "\u4EFB\u52A1\u7ED3\u675F\u540E\u81EA\u52A8\u56DE\u987E\u8BB0\u5FC6",
|
|
230
|
+
"settings.field.reflectTurns.label": "\u53CD\u601D\u89E6\u53D1\u8F6E\u6570",
|
|
231
|
+
"settings.field.reflectTurns.hint": "\u5355\u4EFB\u52A1\u5185\u8FDE\u7EED\u5DE5\u5177\u6B65\u8FBE\u5230\u8BE5\u503C\u624D\u5728\u7ED3\u675F\u65F6\u89E6\u53D1",
|
|
232
|
+
"settings.field.delegateModel.label": "\u53CD\u601D/\u68A6\u5883\u6362\u6A21\u578B",
|
|
233
|
+
"settings.field.delegateModel.hint": "\u7559\u7A7A=\u5168\u7A0B\u4E3B\u6A21\u578B\u3002\u586B\u5199\u540E\u53CD\u601D\u8F6E\u4E0E\u68A6\u5883\u8F6E\u81EA\u52A8\u6362\u7528\u8BE5\u6A21\u578B\u6267\u884C\uFF0C\u8F6E\u6B21\u7ED3\u675F\u81EA\u52A8\u6362\u56DE\u4E3B\u6A21\u578B\uFF08\u5176\u4F59\u5BF9\u8BDD\u4E0D\u53D7\u5F71\u54CD\uFF09\uFF1B'provider/model' \u6307\u5B9A\u8DEF\u7531\uFF0C'model' \u53EA\u6362\u6A21\u578B\u540D",
|
|
234
|
+
"settings.field.delegateModel.placeholder": "\u5982 zai-coding-cn/glm-5.3-flash",
|
|
235
|
+
"settings.field.delegateEffort.label": "\u6362\u7528\u6A21\u578B\u7684\u601D\u8003\u6863\u4F4D",
|
|
236
|
+
"settings.field.delegateEffort.hint": "\u7559\u7A7A=\u5265\u79BB\u4E3B\u4F1A\u8BDD\u7684\u601D\u8003\u6863\u4F4D\uFF08\u9ED8\u8BA4\uFF0C\u63A8\u8350\uFF1A\u76EE\u6807\u6A21\u578B\u4E0D\u58F0\u660E\u601D\u8003\u6863\u4F4D\u65F6\u5E26\u7740\u4F1A\u76F4\u63A5\u88AB\u62D2\uFF09\u3002\u586B 'inherit' \u6CBF\u7528\u4E3B\u4F1A\u8BDD\u6863\u4F4D\uFF1B\u6216\u663E\u5F0F\u586B delegate \u6A21\u578B\u652F\u6301\u7684\u6863\u4F4D\uFF08\u5982 high\uFF09",
|
|
237
|
+
"settings.field.delegateEffort.placeholder": "\u7559\u7A7A=\u5265\u79BB\uFF1Binherit / low / medium / high",
|
|
238
|
+
"fold.body.unloaded": "\u8BE5\u8F6E\u6B63\u6587\u6682\u672A\u52A0\u8F7D\uFF08\u865A\u62DF\u6EDA\u52A8\u4E0B\u5C1A\u672A\u6302\u8F7D\uFF09\u2014\u2014\u6EDA\u52A8\u5230\u8BE5\u8F6E\u4F4D\u7F6E\u540E\u4F1A\u81EA\u52A8\u586B\u5145",
|
|
239
|
+
"settings.field.dreamEnabled.label": "\u7A7A\u95F2\u6574\u7406\u5F00\u5173",
|
|
240
|
+
"settings.field.dream.idleMinutes.label": "\u7A7A\u95F2\u5206\u949F\u6570",
|
|
241
|
+
"settings.field.dream.idleMinutes.hint": "\u7A97\u53E3\u7A7A\u95F2\u6EE1\u8BE5\u5206\u949F\u6570\u5373\u5141\u8BB8 dream",
|
|
242
|
+
"settings.field.dream.suppressWindows.label": "\u5CF0\u65F6\u6291\u5236\u65F6\u6BB5",
|
|
243
|
+
"settings.field.dream.suppressWindows.hint": '"HH:MM-HH:MM" \u9017\u53F7\u5206\u9694\uFF1B\u8FD9\u4E9B\u65F6\u6BB5\u5185\u4E0D\u89E6\u53D1 dream',
|
|
244
|
+
"settings.field.dream.suppressLeadMinutes.label": "\u5CF0\u65F6\u524D\u8FFD\u52A0\u6291\u5236\uFF08\u5206\u949F\uFF09",
|
|
245
|
+
"settings.field.dream.checkMinutes.label": "\u68C0\u67E5\u5468\u671F\uFF08\u5206\u949F\uFF09",
|
|
246
|
+
"settings.field.dream.timeZone.label": "\u6291\u5236\u65F6\u6BB5\u65F6\u533A",
|
|
247
|
+
"settings.field.dream.timeZone.hint": "\u5CF0\u65F6\u7A97\u53E3\u6309\u6B64\u56FA\u5B9A\u65F6\u533A\u8BA1\u7B97\uFF08\u4E0E\u7CFB\u7EDF\u65F6\u949F\u65E0\u5173\uFF09",
|
|
248
|
+
"settings.field.dream.rulesReviewDays.label": "\u51C6\u5219\u9632 churn \u5929\u6570",
|
|
249
|
+
"settings.field.dream.rulesReviewDays.hint": "updated_at \u8DDD\u4ECA\u8D85\u8BE5\u5929\u6570\u7684\u7A33\u5B9A\u51C6\u5219\u4E0D\u8FDB dream \u7B2C 1 \u8F6E\uFF1B0=\u4E0D\u8FC7\u6EE4",
|
|
250
|
+
"settings.field.promptLang.label": "prompt \u4E0E\u68C0\u7D22\u8BED\u8A00",
|
|
251
|
+
"settings.field.promptLang.hint": "\u7559\u7A7A=\u9ED8\u8BA4 zh\uFF08\u672A\u914D\u7F6E\u8FC7\u7684\u4F1A\u8BDD\u4F1A\u6536\u5230\u4E00\u6B21\u9996\u7528\u5F15\u5BFC\uFF09\uFF1B'en'=\u5185\u7F6E\u82F1\u6587\u8BED\u8A00\u5305\u3002\u754C\u9762\u8BED\u8A00\u4E0E\u5B83\u65E0\u5173\u2014\u2014\u90A3\u7531 DSH \u7684\u8BED\u8A00\u8BBE\u7F6E\u51B3\u5B9A\u3002\u8BED\u8A00\u5FC5\u987B\u4E0E\u4F60\u8BF4\u7684\u8BDD\u4E00\u81F4\uFF0C\u5426\u5219\u5173\u952E\u8BCD\u547D\u4E2D\u7387\u4E0B\u964D",
|
|
252
|
+
"settings.field.promptLang.placeholder": "zh / en",
|
|
253
|
+
// ── 日期时间 ──────────────────────────────────────────────────────────────
|
|
254
|
+
"datetime.ymd": "{m}\u6708{d}\u65E5",
|
|
255
|
+
"datetime.ymdFull": "{y}\u5E74{m}\u6708{d}\u65E5"
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// src/i18n/pt-br.ts
|
|
259
|
+
var ptBr = {
|
|
260
|
+
// ── barras das rodadas de reflection / dream ──────────────────────────────
|
|
261
|
+
"fold.title.reflect": "Reflex\xE3o de mem\xF3ria",
|
|
262
|
+
"fold.title.dream": "Consolida\xE7\xE3o ociosa de mem\xF3ria (dream)",
|
|
263
|
+
"fold.status.running": "{title} em andamento\u2026",
|
|
264
|
+
"fold.hint.running": " (mensagem entra nesta rodada)",
|
|
265
|
+
"fold.status.interrupted": "{title} interrompida",
|
|
266
|
+
"fold.status.remembered": "{title} \xB7 {n} mem\xF3rias adicionadas",
|
|
267
|
+
"fold.status.updated": "{title} \xB7 {n} atualizadas",
|
|
268
|
+
"fold.status.nothing": "{title} \xB7 nada a guardar",
|
|
269
|
+
// ── barras de injeção de memória ──────────────────────────────────────────
|
|
270
|
+
"inject.bar": "Mem\xF3ria injetada",
|
|
271
|
+
"inject.kind.first": " (longo prazo)",
|
|
272
|
+
"inject.kind.hit": " (acertos por palavra-chave)",
|
|
273
|
+
"inject.expand": "Clique para expandir",
|
|
274
|
+
"inject.collapse": "Clique para recolher",
|
|
275
|
+
"inject.copy": "Copiar",
|
|
276
|
+
"inject.copied": "Copiado",
|
|
277
|
+
"inject.result": "[Resultado]",
|
|
278
|
+
// ── bolhas de marcação do delegate ────────────────────────────────────────
|
|
279
|
+
"notice.reflect.running": "\u25B8 Tarefa de reflex\xE3o de mem\xF3ria em andamento\u2026",
|
|
280
|
+
"notice.reflect.done": "\u25B8 Tarefa de reflex\xE3o de mem\xF3ria conclu\xEDda.",
|
|
281
|
+
"notice.dream.running": "\u25B8 Tarefa de consolida\xE7\xE3o ociosa de mem\xF3ria em andamento\u2026",
|
|
282
|
+
"notice.dream.done": "\u25B8 Tarefa de consolida\xE7\xE3o ociosa de mem\xF3ria conclu\xEDda.",
|
|
283
|
+
"notice.dream.interrupted": "\u25B8 Tarefa de consolida\xE7\xE3o ociosa de mem\xF3ria interrompida; nova tentativa autom\xE1tica em breve.",
|
|
284
|
+
// ── menu da sessão ────────────────────────────────────────────────────────
|
|
285
|
+
"part.menu": "Participa\xE7\xE3o de mem\xF3ria",
|
|
286
|
+
"part.state.active": "Tudo ativo",
|
|
287
|
+
"part.state.writeonly": "Sem inje\xE7\xE3o autom\xE1tica",
|
|
288
|
+
"part.state.readonly": "Sem consolida\xE7\xE3o autom\xE1tica",
|
|
289
|
+
"part.state.exited": "S\xF3 ferramentas",
|
|
290
|
+
"part.panel.inject": "Inje\xE7\xE3o autom\xE1tica (primeiro turno, por turno, p\xF3s-compacta\xE7\xE3o)",
|
|
291
|
+
"part.panel.consolidate": "Consolida\xE7\xE3o autom\xE1tica (reflect + dream)",
|
|
292
|
+
"part.panel.on": "Ativa",
|
|
293
|
+
"part.panel.off": "Inativa",
|
|
294
|
+
// ── aba de configurações ──────────────────────────────────────────────────
|
|
295
|
+
"settings.title": "Meow memory",
|
|
296
|
+
"settings.summary": 'Todas as configura\xE7\xF5es do plugin de mem\xF3ria entre sess\xF5es. As mudan\xE7as ficam nas configura\xE7\xF5es do DSH (campo a campo; "Restaurar padr\xE3o" volta ao padr\xE3o de f\xE1brica do plugin e ignora a base do patch); para valer, \xE9 preciso salvar (campos do motor reiniciam o motor de mem\u00F3ria).',
|
|
297
|
+
"settings.loading": "Carregando a configura\xE7\xE3o do Macro Memory\u2026",
|
|
298
|
+
"settings.unavailable": "Esta conex\xE3o n\xE3o permite gravar configura\xE7\xF5es (s\xF3 conex\xF5es locais de loopback podem editar).",
|
|
299
|
+
"settings.readonly": "Esta conex\xE3o \xE9 somente leitura (gravar configura\xE7\xF5es \xE9 limitado a conex\xF5es locais de loopback).",
|
|
300
|
+
"settings.saved": "Salvo \u2713 passa a valer ap\xF3s valer na hora (motor de mem\u00F3ria reconfigurado)",
|
|
301
|
+
"settings.badge.override": "Alterado",
|
|
302
|
+
"settings.badge.default": "Padr\xE3o",
|
|
303
|
+
"settings.reset": "Restaurar padr\xE3o",
|
|
304
|
+
"settings.saveFailed": "Falha ao salvar: {error}",
|
|
305
|
+
"settings.saveNotApplied": "A grava\xE7\xE3o n\xE3o teve efeito: o servidor recusou a escrita (talvez n\xE3o tenha passado na valida\xE7\xE3o). Exibindo de novo o valor atual do servidor.",
|
|
306
|
+
"settings.resetFailed": "Falha ao restaurar o padr\xE3o: {error}",
|
|
307
|
+
"settings.resetNotApplied": "Restaurar o padr\xE3o n\xE3o teve efeito; tente de novo.",
|
|
308
|
+
"settings.suppress.format": 'O intervalo deve ter o formato "HH:MM-HH:MM"; recebido "{value}"',
|
|
309
|
+
"settings.suppress.atLeastOne": "\xC9 necess\xE1rio pelo menos um intervalo",
|
|
310
|
+
"settings.group.base": "B\xE1sico",
|
|
311
|
+
"settings.group.inject": "Inje\xE7\xE3o e acertos",
|
|
312
|
+
"settings.group.reflect": "Reflex\xE3o",
|
|
313
|
+
"settings.group.delegate": "Modelo das tarefas de consolida\xE7\xE3o",
|
|
314
|
+
"settings.group.dream": "Consolida\xE7\xE3o ociosa (dream)",
|
|
315
|
+
"settings.group.language": "Idioma",
|
|
316
|
+
"settings.group.storage": "Diret\xF3rios e migra\xE7\xE3o",
|
|
317
|
+
"settings.field.enabled.label": "Chave geral",
|
|
318
|
+
"settings.field.enabled.hint": "Desligado, a inje\xE7\xE3o, a reflex\xE3o e as ferramentas de mem\xF3ria ficam todas inativas",
|
|
319
|
+
"settings.field.projectDir.label": "Diret\xF3rio de mem\xF3ria",
|
|
320
|
+
"settings.field.projectDir.hint": "Diret\xF3rio de dados, relativo ao workspace",
|
|
321
|
+
"settings.field.homeDir.label": "Diret\xF3rio global de dados",
|
|
322
|
+
"settings.field.homeDir.hint": "Onde residem os dados de n\xEDvel de inst\xE2ncia (logs, \xEDndice de janelas). Ao alterar, o conte\xFAdo do diret\xF3rio antigo \xE9 migrado automaticamente (movimenta\xE7\xE3o no mesmo disco / c\xF3pia entre discos); na c\xF3pia entre discos o diret\xF3rio antigo \xE9 mantido \u2014 exclua-o manualmente ap\xF3s verificar. Se v\xE1rias inst\xE2ncias do dsh compartilham o mesmo diret\xF3rio, atualize-as juntas.",
|
|
323
|
+
"settings.field.homeDir.preset.default": "Pasta pessoal do usu\xE1rio (padr\xE3o)",
|
|
324
|
+
"settings.field.homeDir.preset.dshStorage": "Armazenamento da raiz do DSH",
|
|
325
|
+
"settings.field.homeDir.preset.pluginRoot": "Pasta do plugin",
|
|
326
|
+
"settings.field.homeDir.preset.custom": "Caminho personalizado",
|
|
327
|
+
"settings.mirrorReadonly": "Conex\xE3o n\xE3o local: o dsh serve esta p\xE1gina como espelho somente leitura e nenhuma altera\xE7\xE3o ser\xE1 salva. Abra o dsh via 127.0.0.1 na m\xE1quina host para editar as configura\xE7\xF5es.",
|
|
328
|
+
"settings.field.autoMigrate.label": "Migrar banco antigo automaticamente",
|
|
329
|
+
"settings.field.autoMigrate.hint": "Migra o PROJECT.md automaticamente na primeira vez que um banco v1 \xE9 aberto",
|
|
330
|
+
"settings.field.hitTopK.label": "M\xE1ximo de acertos por mensagem",
|
|
331
|
+
"settings.field.hitTopK.hint": "Limite de entradas por acerto de palavra-chave injetadas a cada mensagem (fact/lesson/rules/topic)",
|
|
332
|
+
"settings.field.titleMax.label": "Comprimento de corte do t\xEDtulo",
|
|
333
|
+
"settings.field.titleMax.hint": "Comprimento (em caracteres) do corte da lista de projetos no guia de mem\xF3ria",
|
|
334
|
+
"settings.field.reflect.label": "Reflex\xE3o autom\xE1tica",
|
|
335
|
+
"settings.field.reflect.hint": "Revisa a mem\xF3ria automaticamente quando a tarefa termina",
|
|
336
|
+
"settings.field.reflectTurns.label": "Rodadas para disparar a reflex\xE3o",
|
|
337
|
+
"settings.field.reflectTurns.hint": "Passos de ferramenta seguidos dentro de uma tarefa para disparar no fim",
|
|
338
|
+
"settings.field.delegateModel.label": "Trocar o modelo de reflex\xE3o/consolida\xE7\xE3o ociosa",
|
|
339
|
+
"settings.field.delegateModel.hint": "Vazio = modelo principal do come\xE7o ao fim. Preenchido, as rodadas de reflex\xE3o e de consolida\xE7\xE3o ociosa passam a usar esse modelo e voltam ao principal no fim da rodada (o resto da conversa n\xE3o muda); 'provider/model' escolhe a rota, 'model' troca s\xF3 o nome do modelo",
|
|
340
|
+
"settings.field.delegateModel.placeholder": "ex.: zai-coding-cn/glm-5.3-flash",
|
|
341
|
+
"settings.field.delegateEffort.label": "Esfor\xE7o de racioc\xEDnio do modelo substituto",
|
|
342
|
+
"settings.field.delegateEffort.hint": "Vazio = descarta o esfor\xE7o de racioc\xEDnio da sess\xE3o principal (padr\xE3o, recomendado: a requisi\xE7\xE3o falha com UNSUPPORTED_REASONING_EFFORT se o modelo alvo n\xE3o declara esfor\xE7os). 'inherit' mant\xE9m o esfor\xE7o principal; ou defina um valor aceito pelo modelo (ex.: high)",
|
|
343
|
+
"settings.field.delegateEffort.placeholder": "vazio = descartar; inherit / low / medium / high",
|
|
344
|
+
"fold.body.unloaded": "O conte\xFAdo desta rodada ainda n\xE3o foi carregado (n\xE3o montado na rolagem virtual) \u2014 role at\xE9 ela para preencher automaticamente",
|
|
345
|
+
"settings.field.dreamEnabled.label": "Ligar a consolida\xE7\xE3o ociosa",
|
|
346
|
+
"settings.field.dream.idleMinutes.label": "Minutos de ociosidade",
|
|
347
|
+
"settings.field.dream.idleMinutes.hint": "Uma janela ociosa por esses minutos j\xE1 permite um dream",
|
|
348
|
+
"settings.field.dream.suppressWindows.label": "Janelas de supress\xE3o em hor\xE1rio de pico",
|
|
349
|
+
"settings.field.dream.suppressWindows.hint": '"HH:MM-HH:MM" separados por v\xEDrgula; dentro dessas janelas nenhum dream \xE9 disparado',
|
|
350
|
+
"settings.field.dream.suppressLeadMinutes.label": "Supress\xE3o extra antes do pico (minutos)",
|
|
351
|
+
"settings.field.dream.checkMinutes.label": "Intervalo de verifica\xE7\xE3o (minutos)",
|
|
352
|
+
"settings.field.dream.timeZone.label": "Fuso das janelas de supress\xE3o",
|
|
353
|
+
"settings.field.dream.timeZone.hint": "As janelas de pico s\xE3o calculadas neste fuso fixo (independente do rel\xF3gio do sistema)",
|
|
354
|
+
"settings.field.dream.rulesReviewDays.label": "Dias anti-churn das regras",
|
|
355
|
+
"settings.field.dream.rulesReviewDays.hint": "Regras est\xE1veis com updated_at mais antigo que esses dias ficam fora da 1\xAA rodada do dream; 0 = sem filtro",
|
|
356
|
+
"settings.field.promptLang.label": "Idioma dos prompts e da busca",
|
|
357
|
+
"settings.field.promptLang.hint": "Vazio = zh por padr\xE3o (sess\xF5es que nunca configuraram recebem um guia de primeira vez); 'en' = pacote ingl\xEAs embutido. O idioma da interface n\xE3o tem rela\xE7\xE3o \u2014 ele segue a configura\xE7\xE3o de idioma do DSH. O idioma precisa ser o mesmo em que voc\xEA fala, sen\xE3o a taxa de acerto das palavras-chave cai",
|
|
358
|
+
"settings.field.promptLang.placeholder": "zh / en",
|
|
359
|
+
// ── data e hora ───────────────────────────────────────────────────────────
|
|
360
|
+
"datetime.ymd": "{d}/{m}",
|
|
361
|
+
"datetime.ymdFull": "{d}/{m}/{y}"
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// src/i18n/core.ts
|
|
365
|
+
var NS = "meow-memory";
|
|
366
|
+
var SUPPORTED_UI_LOCALES = [
|
|
367
|
+
{ id: "zh", label: "\u4E2D\u6587" },
|
|
368
|
+
{ id: "en", label: "English" },
|
|
369
|
+
{ id: "pt-br", label: "Portugu\xEAs (Brasil)" }
|
|
370
|
+
];
|
|
371
|
+
var DICTS = {
|
|
372
|
+
en,
|
|
373
|
+
zh,
|
|
374
|
+
"pt-br": ptBr
|
|
375
|
+
};
|
|
376
|
+
var FALLBACK_CHAIN = {
|
|
377
|
+
zh: ["zh", "en"],
|
|
378
|
+
en: ["en"],
|
|
379
|
+
"pt-br": ["pt-br", "en"]
|
|
380
|
+
};
|
|
381
|
+
var DEFAULT_LOCALE = "zh";
|
|
382
|
+
var service = null;
|
|
383
|
+
var active = DEFAULT_LOCALE;
|
|
384
|
+
var registeredLocales = /* @__PURE__ */ new Set();
|
|
385
|
+
var registeredDicts = /* @__PURE__ */ new Set();
|
|
386
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
387
|
+
var localeRetryMs = 1e3;
|
|
388
|
+
var localeRetryMax = 30;
|
|
389
|
+
var localeRetryTimer;
|
|
390
|
+
var localeRetryAttempts = 0;
|
|
391
|
+
function probeLocaleService(ctx) {
|
|
392
|
+
const svc = typeof ctx?.get === "function" ? ctx.get("locale") : null;
|
|
393
|
+
if (svc === null || svc === void 0 || typeof svc.getLocale !== "function" || typeof svc.register !== "function") return null;
|
|
394
|
+
return svc;
|
|
395
|
+
}
|
|
396
|
+
function stopLocaleRetry() {
|
|
397
|
+
if (localeRetryTimer !== void 0) clearTimeout(localeRetryTimer);
|
|
398
|
+
localeRetryTimer = void 0;
|
|
399
|
+
localeRetryAttempts = 0;
|
|
400
|
+
}
|
|
401
|
+
function armLocaleRetry(ctx, warn) {
|
|
402
|
+
if (localeRetryTimer !== void 0) return;
|
|
403
|
+
localeRetryAttempts = 0;
|
|
404
|
+
const tick = () => {
|
|
405
|
+
localeRetryTimer = void 0;
|
|
406
|
+
localeRetryAttempts++;
|
|
407
|
+
let svc = null;
|
|
408
|
+
try {
|
|
409
|
+
svc = probeLocaleService(ctx);
|
|
410
|
+
} catch {
|
|
411
|
+
svc = null;
|
|
412
|
+
}
|
|
413
|
+
if (svc !== null) {
|
|
414
|
+
installI18n(ctx, warn);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
if (localeRetryAttempts >= localeRetryMax) return;
|
|
418
|
+
localeRetryTimer = setTimeout(tick, localeRetryMs);
|
|
419
|
+
};
|
|
420
|
+
localeRetryTimer = setTimeout(tick, localeRetryMs);
|
|
421
|
+
}
|
|
422
|
+
function normalize(tag) {
|
|
423
|
+
return tag.trim().toLowerCase().replace(/_/g, "-");
|
|
424
|
+
}
|
|
425
|
+
function primary(tag) {
|
|
426
|
+
return normalize(tag).split("-")[0];
|
|
427
|
+
}
|
|
428
|
+
function match(tag) {
|
|
429
|
+
const wanted = normalize(tag);
|
|
430
|
+
const exact = SUPPORTED_UI_LOCALES.find((l) => normalize(l.id) === wanted);
|
|
431
|
+
if (exact !== void 0) return exact.id;
|
|
432
|
+
const byPrimary = SUPPORTED_UI_LOCALES.find((l) => primary(l.id) === primary(wanted));
|
|
433
|
+
return byPrimary !== void 0 ? byPrimary.id : null;
|
|
434
|
+
}
|
|
435
|
+
function browserLocale() {
|
|
436
|
+
if (typeof navigator === "undefined") return null;
|
|
437
|
+
const listed = [];
|
|
438
|
+
if (Array.isArray(navigator.languages)) {
|
|
439
|
+
for (const tag of navigator.languages) if (typeof tag === "string") listed.push(tag);
|
|
440
|
+
}
|
|
441
|
+
if (typeof navigator.language === "string") listed.push(navigator.language);
|
|
442
|
+
for (const tag of listed) {
|
|
443
|
+
const hit = match(tag);
|
|
444
|
+
if (hit !== null) return hit;
|
|
445
|
+
}
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
function staticTranslate(locale, key, params) {
|
|
449
|
+
const chain = FALLBACK_CHAIN[locale] ?? [locale, "en"];
|
|
450
|
+
let template;
|
|
451
|
+
for (const lang of chain) {
|
|
452
|
+
const hit = DICTS[lang]?.[key];
|
|
453
|
+
if (hit !== void 0) {
|
|
454
|
+
template = hit;
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (template === void 0) template = DICTS.en[key] ?? key;
|
|
459
|
+
return fill(template, params);
|
|
460
|
+
}
|
|
461
|
+
function fill(template, params) {
|
|
462
|
+
if (params === void 0) return template;
|
|
463
|
+
let out = template;
|
|
464
|
+
for (const [name, value] of Object.entries(params)) {
|
|
465
|
+
out = out.replaceAll(`{${name}}`, () => String(value));
|
|
466
|
+
}
|
|
467
|
+
return out;
|
|
468
|
+
}
|
|
469
|
+
function installI18n(ctx, warn = (m) => console.warn(m)) {
|
|
470
|
+
const svc = typeof ctx?.get === "function" ? ctx.get("locale") : null;
|
|
471
|
+
if (svc === null || svc === void 0 || typeof svc.getLocale !== "function" || typeof svc.register !== "function") {
|
|
472
|
+
service = null;
|
|
473
|
+
active = browserLocale() ?? DEFAULT_LOCALE;
|
|
474
|
+
notify();
|
|
475
|
+
if (typeof ctx?.get === "function") armLocaleRetry(ctx, warn);
|
|
476
|
+
else stopLocaleRetry();
|
|
477
|
+
return [];
|
|
478
|
+
}
|
|
479
|
+
stopLocaleRetry();
|
|
480
|
+
service = svc;
|
|
481
|
+
const done = [];
|
|
482
|
+
for (const locale of SUPPORTED_UI_LOCALES) {
|
|
483
|
+
if (registeredLocales.has(locale.id)) {
|
|
484
|
+
done.push(locale.id);
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
try {
|
|
488
|
+
if (locale.id === "zh" || locale.id === "en") {
|
|
489
|
+
registeredLocales.add(locale.id);
|
|
490
|
+
done.push(locale.id);
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
if (typeof svc.addLanguage !== "function") continue;
|
|
494
|
+
svc.addLanguage({ id: locale.id, label: locale.label, fallback: "en" });
|
|
495
|
+
registeredLocales.add(locale.id);
|
|
496
|
+
done.push(locale.id);
|
|
497
|
+
} catch (error) {
|
|
498
|
+
if (String(error).includes("already")) {
|
|
499
|
+
registeredLocales.add(locale.id);
|
|
500
|
+
done.push(locale.id);
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
warn(`[meow-memory] \u8BED\u8A00 "${locale.id}" \u6CE8\u518C\u5931\u8D25\uFF08UI \u9000\u56DE\u82F1\u6587/\u4E2D\u6587\uFF09\uFF1A${String(error)}`);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
for (const locale of SUPPORTED_UI_LOCALES) {
|
|
507
|
+
const dict = DICTS[locale.id];
|
|
508
|
+
if (dict === void 0 || registeredDicts.has(locale.id)) continue;
|
|
509
|
+
try {
|
|
510
|
+
svc.register(NS, locale.id, { ...dict });
|
|
511
|
+
registeredDicts.add(locale.id);
|
|
512
|
+
} catch (error) {
|
|
513
|
+
if (String(error).includes("already")) {
|
|
514
|
+
registeredDicts.add(locale.id);
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
warn(`[meow-memory] \u754C\u9762\u5B57\u5178 "${locale.id}" \u6CE8\u518C\u5931\u8D25\uFF08\u8BE5\u8BED\u8A00\u9000\u56DE\u82F1\u6587\uFF09\uFF1A${String(error)}`);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
active = readServiceLocale();
|
|
521
|
+
try {
|
|
522
|
+
svc.subscribe(() => {
|
|
523
|
+
const next = readServiceLocale();
|
|
524
|
+
if (next === active) return;
|
|
525
|
+
active = next;
|
|
526
|
+
notify();
|
|
527
|
+
});
|
|
528
|
+
} catch (error) {
|
|
529
|
+
warn(`[meow-memory] \u8BED\u8A00\u53D8\u5316\u8BA2\u9605\u5931\u8D25\uFF08\u6587\u6848\u5728\u5207\u6362\u8BED\u8A00\u524D\u4FDD\u6301\u5F53\u524D\u8BED\u8A00\uFF09\uFF1A${String(error)}`);
|
|
530
|
+
}
|
|
531
|
+
notify();
|
|
532
|
+
return done;
|
|
533
|
+
}
|
|
534
|
+
function readServiceLocale() {
|
|
535
|
+
try {
|
|
536
|
+
const snapshot = service?.getLocale();
|
|
537
|
+
const id = snapshot?.active;
|
|
538
|
+
if (typeof id !== "string" || id === "") return DEFAULT_LOCALE;
|
|
539
|
+
return match(id) ?? primary(id);
|
|
540
|
+
} catch {
|
|
541
|
+
return DEFAULT_LOCALE;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
function notify() {
|
|
545
|
+
for (const fn of [...listeners]) {
|
|
546
|
+
try {
|
|
547
|
+
fn(active);
|
|
548
|
+
} catch (error) {
|
|
549
|
+
console.error("[meow-memory] UI \u8BED\u8A00\u8BA2\u9605\u8005\u5F02\u5E38\uFF1A", error);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function getUiLocale() {
|
|
554
|
+
return active;
|
|
555
|
+
}
|
|
556
|
+
function onUiLocaleChange(fn) {
|
|
557
|
+
listeners.add(fn);
|
|
558
|
+
try {
|
|
559
|
+
fn(active);
|
|
560
|
+
} catch (error) {
|
|
561
|
+
console.error("[meow-memory] UI \u8BED\u8A00\u8BA2\u9605\u8005\u5F02\u5E38\uFF1A", error);
|
|
562
|
+
}
|
|
563
|
+
return () => {
|
|
564
|
+
listeners.delete(fn);
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
var t = (key, params) => {
|
|
568
|
+
if (service !== null) {
|
|
569
|
+
try {
|
|
570
|
+
const translate = service.bind(NS);
|
|
571
|
+
const out = translate(key, params);
|
|
572
|
+
if (out !== key) return out;
|
|
573
|
+
} catch {
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return staticTranslate(active, key, params);
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
// src/i18n/keys.ts
|
|
580
|
+
var UI_KEYS = [
|
|
581
|
+
// reflection / dream turn bars
|
|
582
|
+
"fold.title.reflect",
|
|
583
|
+
"fold.title.dream",
|
|
584
|
+
"fold.status.running",
|
|
585
|
+
"fold.hint.running",
|
|
586
|
+
"fold.status.interrupted",
|
|
587
|
+
"fold.status.remembered",
|
|
588
|
+
"fold.status.updated",
|
|
589
|
+
"fold.status.nothing",
|
|
590
|
+
// memory injection bars
|
|
591
|
+
"inject.bar",
|
|
592
|
+
"inject.kind.first",
|
|
593
|
+
"inject.kind.hit",
|
|
594
|
+
"inject.expand",
|
|
595
|
+
"inject.collapse",
|
|
596
|
+
"inject.copy",
|
|
597
|
+
"inject.copied",
|
|
598
|
+
"inject.result",
|
|
599
|
+
// delegate marker bubbles
|
|
600
|
+
"notice.reflect.running",
|
|
601
|
+
"notice.reflect.done",
|
|
602
|
+
"notice.dream.running",
|
|
603
|
+
"notice.dream.done",
|
|
604
|
+
"notice.dream.interrupted",
|
|
605
|
+
// session menu
|
|
606
|
+
// memory participation gate (issue #38/#28): per-window two-gate panel
|
|
607
|
+
"part.menu",
|
|
608
|
+
"part.state.active",
|
|
609
|
+
"part.state.writeonly",
|
|
610
|
+
"part.state.readonly",
|
|
611
|
+
"part.state.exited",
|
|
612
|
+
"part.panel.inject",
|
|
613
|
+
"part.panel.consolidate",
|
|
614
|
+
"part.panel.on",
|
|
615
|
+
"part.panel.off",
|
|
616
|
+
// settings tab
|
|
617
|
+
"settings.title",
|
|
618
|
+
"settings.summary",
|
|
619
|
+
"settings.loading",
|
|
620
|
+
"settings.unavailable",
|
|
621
|
+
"settings.readonly",
|
|
622
|
+
"settings.saved",
|
|
623
|
+
"settings.badge.override",
|
|
624
|
+
"settings.badge.default",
|
|
625
|
+
"settings.reset",
|
|
626
|
+
"settings.saveFailed",
|
|
627
|
+
"settings.saveNotApplied",
|
|
628
|
+
"settings.resetFailed",
|
|
629
|
+
"settings.resetNotApplied",
|
|
630
|
+
"settings.suppress.format",
|
|
631
|
+
"settings.suppress.atLeastOne",
|
|
632
|
+
"settings.group.base",
|
|
633
|
+
"settings.group.inject",
|
|
634
|
+
"settings.group.reflect",
|
|
635
|
+
"settings.group.delegate",
|
|
636
|
+
"settings.group.dream",
|
|
637
|
+
"settings.group.language",
|
|
638
|
+
"settings.group.storage",
|
|
639
|
+
"settings.field.enabled.label",
|
|
640
|
+
"settings.field.enabled.hint",
|
|
641
|
+
"settings.field.projectDir.label",
|
|
642
|
+
"settings.field.projectDir.hint",
|
|
643
|
+
"settings.field.homeDir.label",
|
|
644
|
+
"settings.field.homeDir.hint",
|
|
645
|
+
"settings.field.homeDir.preset.default",
|
|
646
|
+
"settings.field.homeDir.preset.dshStorage",
|
|
647
|
+
"settings.field.homeDir.preset.pluginRoot",
|
|
648
|
+
"settings.field.homeDir.preset.custom",
|
|
649
|
+
"settings.mirrorReadonly",
|
|
650
|
+
"settings.field.autoMigrate.label",
|
|
651
|
+
"settings.field.autoMigrate.hint",
|
|
652
|
+
"settings.field.hitTopK.label",
|
|
653
|
+
"settings.field.hitTopK.hint",
|
|
654
|
+
"settings.field.titleMax.label",
|
|
655
|
+
"settings.field.titleMax.hint",
|
|
656
|
+
"settings.field.reflect.label",
|
|
657
|
+
"settings.field.reflect.hint",
|
|
658
|
+
"settings.field.reflectTurns.label",
|
|
659
|
+
"settings.field.reflectTurns.hint",
|
|
660
|
+
"settings.field.delegateModel.label",
|
|
661
|
+
"settings.field.delegateModel.hint",
|
|
662
|
+
"settings.field.delegateModel.placeholder",
|
|
663
|
+
"settings.field.delegateEffort.label",
|
|
664
|
+
"settings.field.delegateEffort.hint",
|
|
665
|
+
"settings.field.delegateEffort.placeholder",
|
|
666
|
+
"fold.body.unloaded",
|
|
667
|
+
"settings.field.dreamEnabled.label",
|
|
668
|
+
"settings.field.dream.idleMinutes.label",
|
|
669
|
+
"settings.field.dream.idleMinutes.hint",
|
|
670
|
+
"settings.field.dream.suppressWindows.label",
|
|
671
|
+
"settings.field.dream.suppressWindows.hint",
|
|
672
|
+
"settings.field.dream.suppressLeadMinutes.label",
|
|
673
|
+
"settings.field.dream.checkMinutes.label",
|
|
674
|
+
"settings.field.dream.timeZone.label",
|
|
675
|
+
"settings.field.dream.timeZone.hint",
|
|
676
|
+
"settings.field.dream.rulesReviewDays.label",
|
|
677
|
+
"settings.field.dream.rulesReviewDays.hint",
|
|
678
|
+
"settings.field.promptLang.label",
|
|
679
|
+
"settings.field.promptLang.hint",
|
|
680
|
+
"settings.field.promptLang.placeholder",
|
|
681
|
+
// date and time
|
|
682
|
+
"datetime.ymd",
|
|
683
|
+
"datetime.ymdFull"
|
|
684
|
+
];
|
|
685
|
+
|
|
686
|
+
// src/source.ts
|
|
687
|
+
// [macro-fusion 0.2.80] 与 host 侧同一口径:新快照写 plugin:macro-memory,
|
|
688
|
+
// 老快照的 plugin:meow-memory 也要认(见 host 侧注释)。
|
|
689
|
+
var PLUGIN_NAME = "meow-memory";
|
|
690
|
+
var PLUGIN_KIND = "plugin:macro-memory";
|
|
691
|
+
var LEGACY_PLUGIN_KINDS = ["plugin:meow-memory", `plugin:${PLUGIN_NAME}`];
|
|
692
|
+
function isMeowSource(source) {
|
|
693
|
+
if (source === null || typeof source !== "object") return false;
|
|
694
|
+
const record = source;
|
|
695
|
+
if (record.kind === PLUGIN_KIND) return true;
|
|
696
|
+
if (LEGACY_PLUGIN_KINDS.includes(record.kind)) return true;
|
|
697
|
+
return record.kind === "plugin" && record.plugin === PLUGIN_NAME;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// src/client-fold.ts
|
|
701
|
+
var REFLECT_MARKER = "[meow-memory-reflect]";
|
|
702
|
+
var DREAM_MARKER = "[meow-memory-dream]";
|
|
703
|
+
var META_SECTION_NAME = "__meta__";
|
|
704
|
+
function extractMetaFromSections(sections) {
|
|
705
|
+
if (!Array.isArray(sections)) return void 0;
|
|
706
|
+
const raw = sections.find((s) => s?.name === META_SECTION_NAME)?.text;
|
|
707
|
+
if (raw === void 0) return void 0;
|
|
708
|
+
try {
|
|
709
|
+
return JSON.parse(raw);
|
|
710
|
+
} catch {
|
|
711
|
+
return void 0;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
function turnOf(node) {
|
|
715
|
+
const location = node.location;
|
|
716
|
+
if (location?.kind === "turn") return location.turn?.turn;
|
|
717
|
+
if (location?.kind === "step") return location.turn?.turn;
|
|
718
|
+
return void 0;
|
|
719
|
+
}
|
|
720
|
+
function contextText(node) {
|
|
721
|
+
return blocksToText(node.data.content ?? []);
|
|
722
|
+
}
|
|
723
|
+
function isMemoryPrompt(node) {
|
|
724
|
+
if (node.kind !== "context" && node.kind !== "turn-trigger") return false;
|
|
725
|
+
const source = node.data.source;
|
|
726
|
+
if (!isMeowSource(source)) return false;
|
|
727
|
+
return promptVariantHead(contextText(node)) !== void 0;
|
|
728
|
+
}
|
|
729
|
+
function promptVariantHead(text) {
|
|
730
|
+
const head = text.trimStart().slice(0, 40);
|
|
731
|
+
if (head.includes(REFLECT_MARKER)) return "reflect";
|
|
732
|
+
if (head.includes(DREAM_MARKER)) return "dream";
|
|
733
|
+
return void 0;
|
|
734
|
+
}
|
|
735
|
+
function toolNameOfBlock(block) {
|
|
736
|
+
if (block === null || typeof block !== "object") return void 0;
|
|
737
|
+
const b = block;
|
|
738
|
+
if (typeof b.name === "string") return b.name;
|
|
739
|
+
if (typeof b.call?.name === "string") return b.call.name;
|
|
740
|
+
return void 0;
|
|
741
|
+
}
|
|
742
|
+
function countMemoryCalls(node, seen, counts) {
|
|
743
|
+
if (node.kind !== "tool-call") return;
|
|
744
|
+
visitCallBlock(node.data.root, seen, counts);
|
|
745
|
+
}
|
|
746
|
+
function visitCallBlock(block, seen, counts) {
|
|
747
|
+
if (block === null || typeof block !== "object") return;
|
|
748
|
+
const b = block;
|
|
749
|
+
if (typeof b.callId === "string") {
|
|
750
|
+
if (seen.has(b.callId)) return;
|
|
751
|
+
seen.add(b.callId);
|
|
752
|
+
}
|
|
753
|
+
const name = toolNameOfBlock(block);
|
|
754
|
+
if (name === "memory_remember") counts.remember++;
|
|
755
|
+
else if (name === "memory_update") counts.update++;
|
|
756
|
+
if (Array.isArray(b.subCalls)) {
|
|
757
|
+
for (const sub of b.subCalls) visitCallBlock(sub, seen, counts);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function chatKeyOrder(snapshot) {
|
|
761
|
+
const chat = snapshot.chat;
|
|
762
|
+
const keys = [];
|
|
763
|
+
const seen = /* @__PURE__ */ new Set();
|
|
764
|
+
for (const key of chat.order) {
|
|
765
|
+
if (seen.has(key)) continue;
|
|
766
|
+
seen.add(key);
|
|
767
|
+
keys.push(key);
|
|
768
|
+
}
|
|
769
|
+
const store = chat.nodes;
|
|
770
|
+
if (typeof store.values !== "function") return keys;
|
|
771
|
+
const extra = [];
|
|
772
|
+
for (const node of store.values()) {
|
|
773
|
+
const key = node.key;
|
|
774
|
+
if (key === void 0 || seen.has(key)) continue;
|
|
775
|
+
seen.add(key);
|
|
776
|
+
const seq = node.anchorSeq ?? node.data.seq ?? 0;
|
|
777
|
+
extra.push({ key, seq });
|
|
778
|
+
}
|
|
779
|
+
extra.sort((a, b) => a.seq - b.seq);
|
|
780
|
+
for (const item of extra) keys.push(item.key);
|
|
781
|
+
return keys;
|
|
782
|
+
}
|
|
783
|
+
function computeFoldGroups(snapshot) {
|
|
784
|
+
if (snapshot?.chat === void 0) return [];
|
|
785
|
+
const order = chatKeyOrder(snapshot);
|
|
786
|
+
const nodes = snapshot.chat.nodes;
|
|
787
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
788
|
+
for (const key of order) {
|
|
789
|
+
const node = nodes.get(key);
|
|
790
|
+
if (node === void 0 || !isMemoryPrompt(node)) continue;
|
|
791
|
+
const turn = turnOf(node);
|
|
792
|
+
if (turn === void 0) continue;
|
|
793
|
+
const variant = promptVariantHead(contextText(node)) ?? "reflect";
|
|
794
|
+
const mapKey = `${turn}:${variant}`;
|
|
795
|
+
if (anchors.has(mapKey)) continue;
|
|
796
|
+
anchors.set(mapKey, { key, turn, variant });
|
|
797
|
+
}
|
|
798
|
+
const groups = [];
|
|
799
|
+
for (const anchor of anchors.values()) {
|
|
800
|
+
const scanned = order.filter((key) => {
|
|
801
|
+
const node = nodes.get(key);
|
|
802
|
+
return node !== void 0 && turnOf(node) === anchor.turn;
|
|
803
|
+
});
|
|
804
|
+
const turnKeys = scanned.length > 0 ? scanned : snapshot.chat.locations.getTurn(anchor.turn);
|
|
805
|
+
const startIdx = turnKeys.indexOf(anchor.key);
|
|
806
|
+
const ownsTurn = startIdx === 0;
|
|
807
|
+
const keys = turnKeys.slice(startIdx === -1 ? 0 : startIdx).filter((k) => {
|
|
808
|
+
const n = nodes.get(k);
|
|
809
|
+
return n !== void 0 && n.kind !== "user" && n.kind !== "steering" && (n.kind !== "turn-tail" || ownsTurn);
|
|
810
|
+
});
|
|
811
|
+
const counts = { remember: 0, update: 0 };
|
|
812
|
+
const seenCalls = /* @__PURE__ */ new Set();
|
|
813
|
+
let status = "done";
|
|
814
|
+
for (const k of keys) {
|
|
815
|
+
const n = nodes.get(k);
|
|
816
|
+
if (n === void 0) continue;
|
|
817
|
+
countMemoryCalls(n, seenCalls, counts);
|
|
818
|
+
if (n.kind === "assistant") {
|
|
819
|
+
const data = n.data;
|
|
820
|
+
if (data.status === "running") status = "running";
|
|
821
|
+
else if (data.status === "interrupted" && status !== "running") status = "interrupted";
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
groups.push({ id: anchor.key, variant: anchor.variant, keys, rememberCount: counts.remember, updateCount: counts.update, status, turn: anchor.turn });
|
|
825
|
+
}
|
|
826
|
+
return groups;
|
|
827
|
+
}
|
|
828
|
+
function memoryTurnNumbers(snapshot) {
|
|
829
|
+
const out = /* @__PURE__ */ new Set();
|
|
830
|
+
if (snapshot?.chat === void 0) return out;
|
|
831
|
+
for (const key of chatKeyOrder(snapshot)) {
|
|
832
|
+
const node = snapshot.chat.nodes.get(key);
|
|
833
|
+
if (node === void 0 || !isMemoryPrompt(node)) continue;
|
|
834
|
+
const turn = turnOf(node);
|
|
835
|
+
if (turn !== void 0) out.add(turn);
|
|
836
|
+
}
|
|
837
|
+
return out;
|
|
838
|
+
}
|
|
839
|
+
function foldLabel(group, expanded) {
|
|
840
|
+
const arrow = expanded ? "\u25BE" : "\u25B8";
|
|
841
|
+
const title = t(group.variant === "dream" ? "fold.title.dream" : "fold.title.reflect");
|
|
842
|
+
if (group.status === "running") {
|
|
843
|
+
const hint = group.variant === "dream" ? t("fold.hint.running") : "";
|
|
844
|
+
return `${arrow} ${t("fold.status.running", { title })}${hint}`;
|
|
845
|
+
}
|
|
846
|
+
if (group.status === "interrupted") return `${arrow} ${t("fold.status.interrupted", { title })}`;
|
|
847
|
+
if (group.rememberCount > 0) return `${arrow} ${t("fold.status.remembered", { title, n: group.rememberCount })}`;
|
|
848
|
+
if (group.updateCount > 0) return `${arrow} ${t("fold.status.updated", { title, n: group.updateCount })}`;
|
|
849
|
+
return `${arrow} ${t("fold.status.nothing", { title })}`;
|
|
850
|
+
}
|
|
851
|
+
function argsFieldOf(record) {
|
|
852
|
+
if (record === null || typeof record !== "object") return void 0;
|
|
853
|
+
const s = record;
|
|
854
|
+
return s.argsRaw ?? s.arguments ?? s.args ?? s.input;
|
|
855
|
+
}
|
|
856
|
+
function toolArgsOf(record) {
|
|
857
|
+
const r = record;
|
|
858
|
+
for (const c of [record, r?.root, r?.call, r?.root?.call]) {
|
|
859
|
+
const v = argsFieldOf(c);
|
|
860
|
+
if (v !== void 0) return v;
|
|
861
|
+
}
|
|
862
|
+
return "";
|
|
863
|
+
}
|
|
864
|
+
function toolCallDetail(block) {
|
|
865
|
+
const raw = toolArgsOf(block);
|
|
866
|
+
let args;
|
|
867
|
+
if (typeof raw === "string") {
|
|
868
|
+
args = raw;
|
|
869
|
+
try {
|
|
870
|
+
args = JSON.stringify(JSON.parse(raw), null, 2);
|
|
871
|
+
} catch {
|
|
872
|
+
}
|
|
873
|
+
} else {
|
|
874
|
+
try {
|
|
875
|
+
args = raw === null || raw === void 0 ? "" : JSON.stringify(raw, null, 2) ?? "";
|
|
876
|
+
} catch {
|
|
877
|
+
args = String(raw);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
const name = typeof block?.name === "string" ? block.name : "";
|
|
881
|
+
return args.length > 0 ? `${name}
|
|
882
|
+
${args}` : name;
|
|
883
|
+
}
|
|
884
|
+
function blocksToText(blocks) {
|
|
885
|
+
return blocks.map((block) => block.text ?? "").join("\n").trim();
|
|
886
|
+
}
|
|
887
|
+
var FIRST_INJECTION_MARKER = "===== \u957F\u671F\u8BB0\u5FC6 =====";
|
|
888
|
+
var HIT_INJECTION_MARKER = "\u53EF\u80FD\u76F8\u5173\u7684\u8BB0\u5FC6\uFF0C\u4EC5\u4F9B\u53C2\u8003\uFF1A";
|
|
889
|
+
var PROMPT_SEPARATOR = "\u672C\u8F6E\u7528\u6237prompt\uFF1A";
|
|
890
|
+
var EN_PROMPT_SEPARATOR = "This turn's user prompt:";
|
|
891
|
+
function computeInjectionGroups(snapshot) {
|
|
892
|
+
if (snapshot?.chat === void 0) return [];
|
|
893
|
+
const groups = [];
|
|
894
|
+
for (const key of chatKeyOrder(snapshot)) {
|
|
895
|
+
const node = snapshot.chat.nodes.get(key);
|
|
896
|
+
if (node === void 0) continue;
|
|
897
|
+
if (node.kind === "context") {
|
|
898
|
+
const ctx = node.data;
|
|
899
|
+
const source = ctx.source;
|
|
900
|
+
if (!isMeowSource(source)) continue;
|
|
901
|
+
const meta = extractMetaFromSections(source.sections) ?? source.memory;
|
|
902
|
+
const memKind = meta?.kind;
|
|
903
|
+
if (memKind === "initial" || memKind === "reinjection") {
|
|
904
|
+
groups.push({ id: key, kind: "first", injectedText: contextText(node), turn: turnOf(node) });
|
|
905
|
+
continue;
|
|
906
|
+
}
|
|
907
|
+
if (memKind === "hit") {
|
|
908
|
+
groups.push({ id: key, kind: "hit", injectedText: contextText(node), turn: turnOf(node) });
|
|
909
|
+
continue;
|
|
910
|
+
}
|
|
911
|
+
if (meta !== void 0) continue;
|
|
912
|
+
if (source.form === "snapshot") {
|
|
913
|
+
const injectedText = contextText(node);
|
|
914
|
+
const isFirst = injectedText.startsWith(FIRST_INJECTION_MARKER) || injectedText.includes("LONG-TERM MEMORY");
|
|
915
|
+
groups.push({ id: key, kind: isFirst ? "first" : "hit", injectedText, turn: turnOf(node) });
|
|
916
|
+
}
|
|
917
|
+
continue;
|
|
918
|
+
}
|
|
919
|
+
if (node.kind !== "user") continue;
|
|
920
|
+
const content = node.data.content ?? [];
|
|
921
|
+
if (content.length === 0 || content.some((b) => b.type !== "text")) continue;
|
|
922
|
+
const text = blocksToText(content);
|
|
923
|
+
if (text.length === 0) continue;
|
|
924
|
+
let kind = null;
|
|
925
|
+
if (text.startsWith(FIRST_INJECTION_MARKER) || text.includes("LONG-TERM MEMORY") || text.includes("===== \u957F\u671F\u8BB0\u5FC6 =====")) kind = "first";
|
|
926
|
+
else if (text.startsWith(HIT_INJECTION_MARKER) || text.includes("Possibly relevant memories") || text.includes("\u53EF\u80FD\u76F8\u5173\u7684\u8BB0\u5FC6")) kind = "hit";
|
|
927
|
+
if (kind === null) continue;
|
|
928
|
+
const sep = text.includes(PROMPT_SEPARATOR) ? PROMPT_SEPARATOR : text.includes(EN_PROMPT_SEPARATOR) ? EN_PROMPT_SEPARATOR : null;
|
|
929
|
+
if (sep === null) continue;
|
|
930
|
+
const sepIdx = text.lastIndexOf(sep);
|
|
931
|
+
const userText = text.slice(sepIdx + sep.length).replace(/^\n+/, "");
|
|
932
|
+
const time = typeof node.data.time === "number" ? node.data.time : void 0;
|
|
933
|
+
groups.push({ id: key, kind, injectedText: text.slice(0, sepIdx + sep.length), userText, time });
|
|
934
|
+
}
|
|
935
|
+
return groups;
|
|
936
|
+
}
|
|
937
|
+
function formatInjectionClock(time, now = Date.now()) {
|
|
938
|
+
const d = new Date(time);
|
|
939
|
+
const n = new Date(now);
|
|
940
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
941
|
+
const clock = `${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
942
|
+
const sameDay = d.getFullYear() === n.getFullYear() && d.getMonth() === n.getMonth() && d.getDate() === n.getDate();
|
|
943
|
+
if (sameDay) return clock;
|
|
944
|
+
const md = d.getFullYear() === n.getFullYear() ? t("datetime.ymd", { m: d.getMonth() + 1, d: d.getDate() }) : t("datetime.ymdFull", { y: d.getFullYear(), m: d.getMonth() + 1, d: d.getDate() });
|
|
945
|
+
return `${md} ${clock}`;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
// src/client-delegate-vanish.ts
|
|
949
|
+
var DELEGATE_LABEL_PREFIX = "meow-memory ";
|
|
950
|
+
function isMeowDelegateLabel(label) {
|
|
951
|
+
return typeof label === "string" && label.startsWith(DELEGATE_LABEL_PREFIX);
|
|
952
|
+
}
|
|
953
|
+
function indexSubagentDescendantCount(byId, rootId) {
|
|
954
|
+
if (byId === void 0 || rootId === void 0) return 0;
|
|
955
|
+
let total = 0;
|
|
956
|
+
for (const descendant of Object.values(byId)) {
|
|
957
|
+
if (descendant?.origin !== "subagent") continue;
|
|
958
|
+
const seen = /* @__PURE__ */ new Set();
|
|
959
|
+
let node = descendant;
|
|
960
|
+
while (node?.origin === "subagent" && typeof node.parentId === "string" && !seen.has(node.id ?? "")) {
|
|
961
|
+
seen.add(node.id ?? "");
|
|
962
|
+
if (node.parentId === rootId) {
|
|
963
|
+
total += 1;
|
|
964
|
+
break;
|
|
965
|
+
}
|
|
966
|
+
node = byId[node.parentId];
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return total;
|
|
970
|
+
}
|
|
971
|
+
function computeVanishDecision(state) {
|
|
972
|
+
const current = state?.current;
|
|
973
|
+
const catalog = current === void 0 ? void 0 : state?.subagentsByParent?.[current];
|
|
974
|
+
const entries = catalog?.state === "ready" ? (catalog.entries ?? []).filter((e) => e?.kind === "child") : [];
|
|
975
|
+
if (catalog?.state !== "ready") {
|
|
976
|
+
return { known: false, hideTrigger: false, mineCount: 0, othersCount: 0 };
|
|
977
|
+
}
|
|
978
|
+
const mine = entries.filter((e) => isMeowDelegateLabel(e.label));
|
|
979
|
+
const others = entries.length - mine.length;
|
|
980
|
+
const lineageTotal = indexSubagentDescendantCount(state?.byId, current);
|
|
981
|
+
const hideTrigger = others === 0 && mine.length > 0 && lineageTotal <= mine.length;
|
|
982
|
+
return { known: true, hideTrigger, mineCount: mine.length, othersCount: others };
|
|
983
|
+
}
|
|
984
|
+
var SENTINEL_ATTR = "data-meow-vanish";
|
|
985
|
+
var ROW_ATTR = "data-meow-vanish-row";
|
|
986
|
+
function locateLineageRoot(sentinel) {
|
|
987
|
+
let scope = sentinel?.parentElement ?? null;
|
|
988
|
+
for (let hop = 0; scope !== null && hop < 5; hop += 1, scope = scope.parentElement) {
|
|
989
|
+
const candidates = scope.querySelectorAll(':scope [class*="_root"]');
|
|
990
|
+
for (const candidate of Array.from(candidates)) {
|
|
991
|
+
if (candidate.contains(sentinel ?? null)) continue;
|
|
992
|
+
if (candidate.querySelector(':scope [class*="_trigger"]') !== null) return candidate;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
return null;
|
|
996
|
+
}
|
|
997
|
+
function vanishRows(root = document) {
|
|
998
|
+
const rows = root.querySelectorAll('[role="treeitem"]');
|
|
999
|
+
for (const row of Array.from(rows)) {
|
|
1000
|
+
const match2 = isMeowDelegateLabel(row.getAttribute("aria-label"));
|
|
1001
|
+
const marked = row.getAttribute(ROW_ATTR) === "1";
|
|
1002
|
+
if (match2 && !marked) {
|
|
1003
|
+
row.setAttribute(ROW_ATTR, "1");
|
|
1004
|
+
row.style.display = "none";
|
|
1005
|
+
} else if (!match2 && marked) {
|
|
1006
|
+
row.removeAttribute(ROW_ATTR);
|
|
1007
|
+
row.style.display = "";
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
function applyTriggerVisibility(root, hide) {
|
|
1012
|
+
if (root === null || root === void 0) return;
|
|
1013
|
+
const trigger = root.querySelector(':scope [class*="_trigger"]');
|
|
1014
|
+
if (trigger === null) return;
|
|
1015
|
+
const next = hide ? "none" : "";
|
|
1016
|
+
if (trigger.style.display !== next) trigger.style.display = next;
|
|
1017
|
+
}
|
|
1018
|
+
function applyVanishDom(decision, sentinel) {
|
|
1019
|
+
try {
|
|
1020
|
+
vanishRows();
|
|
1021
|
+
if (decision.known) applyTriggerVisibility(locateLineageRoot(sentinel), decision.hideTrigger);
|
|
1022
|
+
} catch (e) {
|
|
1023
|
+
console.warn("[meow-memory] vanish DOM \u5E94\u7528\u5931\u8D25\uFF08fail-open\uFF0C\u4FDD\u6301\u5B98\u65B9\u663E\u793A\uFF09\uFF1A", e);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
function startVanishObserver(getApply) {
|
|
1027
|
+
let timer = 0;
|
|
1028
|
+
const observer = new MutationObserver(() => {
|
|
1029
|
+
window.clearTimeout(timer);
|
|
1030
|
+
timer = window.setTimeout(() => {
|
|
1031
|
+
const { decision, sentinel } = getApply();
|
|
1032
|
+
applyVanishDom(decision, sentinel);
|
|
1033
|
+
}, 80);
|
|
1034
|
+
});
|
|
1035
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
1036
|
+
return () => {
|
|
1037
|
+
window.clearTimeout(timer);
|
|
1038
|
+
observer.disconnect();
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// src/client-dream-events.ts
|
|
1043
|
+
var listeners2 = /* @__PURE__ */ new Set();
|
|
1044
|
+
var pollTimer = 0;
|
|
1045
|
+
var lastStates = /* @__PURE__ */ new Map();
|
|
1046
|
+
var lastSkipped = /* @__PURE__ */ new Set();
|
|
1047
|
+
var lastScopes = /* @__PURE__ */ new Map();
|
|
1048
|
+
var hasBaseline = false;
|
|
1049
|
+
function emit(sessionId, state, detail) {
|
|
1050
|
+
for (const listener of [...listeners2]) {
|
|
1051
|
+
try {
|
|
1052
|
+
listener(detail === void 0 ? { sessionId, state } : { sessionId, state, ...detail });
|
|
1053
|
+
} catch {
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
async function pollDreamEventsOnce() {
|
|
1058
|
+
let states;
|
|
1059
|
+
let skipped;
|
|
1060
|
+
let scopes2;
|
|
1061
|
+
try {
|
|
1062
|
+
const [statesRes, skipRes] = await Promise.all([
|
|
1063
|
+
fetch("/meow-memory/dreamed-sessions", { cache: "no-store" }),
|
|
1064
|
+
fetch("/meow-memory/skip-dreams", { cache: "no-store" })
|
|
1065
|
+
]);
|
|
1066
|
+
if (!statesRes.ok || !skipRes.ok) return;
|
|
1067
|
+
const statesData = await statesRes.json();
|
|
1068
|
+
const skipData = await skipRes.json();
|
|
1069
|
+
states = /* @__PURE__ */ new Map();
|
|
1070
|
+
if (Array.isArray(statesData.sessionIds)) {
|
|
1071
|
+
for (const id of statesData.sessionIds) if (typeof id === "string") states.set(id, "dreamed");
|
|
1072
|
+
}
|
|
1073
|
+
if (Array.isArray(statesData.dreamingIds)) {
|
|
1074
|
+
for (const id of statesData.dreamingIds) if (typeof id === "string") states.set(id, "dreaming");
|
|
1075
|
+
}
|
|
1076
|
+
skipped = /* @__PURE__ */ new Set();
|
|
1077
|
+
scopes2 = /* @__PURE__ */ new Map();
|
|
1078
|
+
if (Array.isArray(skipData.scopes)) {
|
|
1079
|
+
for (const sc of skipData.scopes) {
|
|
1080
|
+
if (typeof sc.sessionId !== "string") continue;
|
|
1081
|
+
scopes2.set(sc.sessionId, { dream: sc.dream === true, inject: sc.inject === true, write: sc.write === true });
|
|
1082
|
+
}
|
|
1083
|
+
} else if (Array.isArray(skipData.sessionIds)) {
|
|
1084
|
+
for (const id of skipData.sessionIds) if (typeof id === "string") skipped.add(id);
|
|
1085
|
+
}
|
|
1086
|
+
for (const id of skipped) if (!scopes2.has(id)) scopes2.set(id, { dream: true, inject: false, write: false });
|
|
1087
|
+
} catch {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
if (!hasBaseline) {
|
|
1091
|
+
lastStates = states;
|
|
1092
|
+
lastSkipped = skipped;
|
|
1093
|
+
lastScopes = scopes2;
|
|
1094
|
+
hasBaseline = true;
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
for (const [sessionId, state] of states) {
|
|
1098
|
+
if (lastStates.get(sessionId) !== state) emit(sessionId, state);
|
|
1099
|
+
}
|
|
1100
|
+
for (const [sessionId, state] of lastStates) {
|
|
1101
|
+
if (!states.has(sessionId)) emit(sessionId, "active");
|
|
1102
|
+
}
|
|
1103
|
+
for (const sessionId of skipped) {
|
|
1104
|
+
if (!lastSkipped.has(sessionId)) emit(sessionId, "skip");
|
|
1105
|
+
}
|
|
1106
|
+
for (const sessionId of lastSkipped) {
|
|
1107
|
+
if (!skipped.has(sessionId)) emit(sessionId, "unskip");
|
|
1108
|
+
}
|
|
1109
|
+
for (const [sessionId, scope] of scopes2) {
|
|
1110
|
+
const prev = lastScopes.get(sessionId) ?? { dream: false, inject: false, write: false };
|
|
1111
|
+
for (const field of ["dream", "inject", "write"]) {
|
|
1112
|
+
if (scope[field] !== prev[field]) emit(sessionId, "scope", { field, value: scope[field] });
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
for (const sessionId of lastScopes.keys()) {
|
|
1116
|
+
if (!scopes2.has(sessionId)) {
|
|
1117
|
+
const prev = lastScopes.get(sessionId);
|
|
1118
|
+
for (const field of ["dream", "inject", "write"]) {
|
|
1119
|
+
if (prev[field]) emit(sessionId, "scope", { field, value: false });
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
lastStates = states;
|
|
1124
|
+
lastSkipped = skipped;
|
|
1125
|
+
lastScopes = scopes2;
|
|
1126
|
+
}
|
|
1127
|
+
function subscribeDreamEvents(listener) {
|
|
1128
|
+
listeners2.add(listener);
|
|
1129
|
+
if (listeners2.size === 1 && pollTimer === 0) {
|
|
1130
|
+
pollTimer = window.setInterval(() => {
|
|
1131
|
+
void pollDreamEventsOnce();
|
|
1132
|
+
}, 6e4);
|
|
1133
|
+
void pollDreamEventsOnce();
|
|
1134
|
+
}
|
|
1135
|
+
return () => {
|
|
1136
|
+
listeners2.delete(listener);
|
|
1137
|
+
if (listeners2.size === 0 && pollTimer !== 0) {
|
|
1138
|
+
window.clearInterval(pollTimer);
|
|
1139
|
+
pollTimer = 0;
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
// src/client-conversation-dom.ts
|
|
1145
|
+
function chatFlows(root) {
|
|
1146
|
+
return Array.from(root.querySelectorAll("[data-chat-flow]")).filter((flow) => flow.closest("[data-conversation-scroll]") === root).filter((flow) => flow.parentElement?.closest("[data-chat-flow]")?.closest("[data-conversation-scroll]") !== root);
|
|
1147
|
+
}
|
|
1148
|
+
function flowElements(flow, selector) {
|
|
1149
|
+
return Array.from(flow.querySelectorAll(selector)).filter((element) => element.closest("[data-chat-flow]") === flow);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// src/client-delegate-notice.ts
|
|
1153
|
+
var REFLECT_DELEGATE_MARKER = "\u3010\u8BB0\u5FC6\u53CD\u601D\u6807\u8BB0\u3011";
|
|
1154
|
+
var REFLECT_DONE_DELEGATE_MARKER = "\u3010\u8BB0\u5FC6\u53CD\u601D\u5B8C\u6210\u6807\u8BB0\u3011";
|
|
1155
|
+
var DREAM_DELEGATE_MARKER = "\u3010\u8BB0\u5FC6\u6574\u7406\u6807\u8BB0\u3011";
|
|
1156
|
+
var HIDDEN_ATTR = "data-meow-delegate-hidden";
|
|
1157
|
+
var ANCHOR_ATTR = "data-meow-delegate-anchor";
|
|
1158
|
+
var CSS_ID = "meow-meow-delegate-notice-css";
|
|
1159
|
+
var NOTICE_CSS = `[${HIDDEN_ATTR}="true"]{display:none!important}`;
|
|
1160
|
+
var REFLECT_FRESH_MS = 30 * 6e4;
|
|
1161
|
+
var DREAM_RUNNING_STALE_MS = 30 * 6e4;
|
|
1162
|
+
var META_SECTION_NAME2 = "__meta__";
|
|
1163
|
+
function extractMetaFromSections2(sections) {
|
|
1164
|
+
if (!Array.isArray(sections)) return void 0;
|
|
1165
|
+
const raw = sections.find((s) => s?.name === META_SECTION_NAME2)?.text;
|
|
1166
|
+
if (raw === void 0) return void 0;
|
|
1167
|
+
try {
|
|
1168
|
+
return JSON.parse(raw);
|
|
1169
|
+
} catch {
|
|
1170
|
+
return void 0;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
function noticeText(node) {
|
|
1174
|
+
const blocks = node.data?.content ?? [];
|
|
1175
|
+
return blocks.map((block) => block.text ?? "").join("\n").trim();
|
|
1176
|
+
}
|
|
1177
|
+
function delegateVariantOf(node) {
|
|
1178
|
+
if (node.kind !== "context") return void 0;
|
|
1179
|
+
const source = node.data?.source;
|
|
1180
|
+
if (source === void 0 || source === null || typeof source !== "object") return void 0;
|
|
1181
|
+
if (!isMeowSource(source)) return void 0;
|
|
1182
|
+
const meta = extractMetaFromSections2(source.sections) ?? source.memory;
|
|
1183
|
+
const memKind = meta?.kind;
|
|
1184
|
+
if (memKind === "reflect-marker") return "reflect";
|
|
1185
|
+
if (memKind === "reflect-done-marker") return "reflect-done";
|
|
1186
|
+
if (memKind === "dream-marker") return "dream";
|
|
1187
|
+
const text = noticeText(node);
|
|
1188
|
+
if (text.includes(REFLECT_DONE_DELEGATE_MARKER)) return "reflect-done";
|
|
1189
|
+
if (text.includes(REFLECT_DELEGATE_MARKER)) return "reflect";
|
|
1190
|
+
if (text.includes(DREAM_DELEGATE_MARKER)) return "dream";
|
|
1191
|
+
return void 0;
|
|
1192
|
+
}
|
|
1193
|
+
function delegateSessionIdOf(node) {
|
|
1194
|
+
const meta = extractMetaFromSections2(node.data?.source?.sections) ?? node.data?.source?.memory;
|
|
1195
|
+
const sid = meta?.sessionId;
|
|
1196
|
+
return typeof sid === "string" && sid !== "" ? sid : void 0;
|
|
1197
|
+
}
|
|
1198
|
+
function delegateTimeOf(node) {
|
|
1199
|
+
const time = node.data?.time;
|
|
1200
|
+
return typeof time === "number" ? time : void 0;
|
|
1201
|
+
}
|
|
1202
|
+
var dreamStateBySession = /* @__PURE__ */ new Map();
|
|
1203
|
+
var stateListeners = /* @__PURE__ */ new Set();
|
|
1204
|
+
function onDelegateStateChange(listener) {
|
|
1205
|
+
stateListeners.add(listener);
|
|
1206
|
+
return () => {
|
|
1207
|
+
stateListeners.delete(listener);
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
function delegateNoticeLabelFor(variant, running, interrupted = false) {
|
|
1211
|
+
if (variant === "dream") {
|
|
1212
|
+
if (interrupted) return t("notice.dream.interrupted");
|
|
1213
|
+
return running ? t("notice.dream.running") : t("notice.dream.done");
|
|
1214
|
+
}
|
|
1215
|
+
if (variant === "reflect-done") return t("notice.reflect.done");
|
|
1216
|
+
return running ? t("notice.reflect.running") : t("notice.reflect.done");
|
|
1217
|
+
}
|
|
1218
|
+
function delegateNoticeLabel(notice) {
|
|
1219
|
+
return delegateNoticeLabelFor(notice.variant, notice.running, notice.interrupted === true);
|
|
1220
|
+
}
|
|
1221
|
+
function computeDelegateNotices(snapshot, now = Date.now()) {
|
|
1222
|
+
if (snapshot?.chat === void 0) return [];
|
|
1223
|
+
const found = [];
|
|
1224
|
+
for (const key of snapshot.chat.order) {
|
|
1225
|
+
const node = snapshot.chat.nodes.get(key);
|
|
1226
|
+
if (node === void 0) continue;
|
|
1227
|
+
const variant = delegateVariantOf(node);
|
|
1228
|
+
if (variant === void 0) continue;
|
|
1229
|
+
found.push({ key, variant, sessionId: delegateSessionIdOf(node), time: delegateTimeOf(node) });
|
|
1230
|
+
}
|
|
1231
|
+
let lastReflectIdx = -1;
|
|
1232
|
+
for (let i = 0; i < found.length; i++) {
|
|
1233
|
+
if (found[i].variant === "reflect" || found[i].variant === "reflect-done") lastReflectIdx = i;
|
|
1234
|
+
}
|
|
1235
|
+
const out = found.map((f, i) => {
|
|
1236
|
+
if (f.variant !== "dream") {
|
|
1237
|
+
return {
|
|
1238
|
+
id: f.key,
|
|
1239
|
+
variant: f.variant,
|
|
1240
|
+
sessionId: f.sessionId,
|
|
1241
|
+
running: f.variant === "reflect" && i === lastReflectIdx && f.time !== void 0 && now - f.time < REFLECT_FRESH_MS
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
const state = f.sessionId !== void 0 ? dreamStateBySession.get(f.sessionId) : void 0;
|
|
1245
|
+
if (state === "dreaming") return { id: f.key, variant: f.variant, sessionId: f.sessionId, running: true };
|
|
1246
|
+
if (state === "dreamed") return { id: f.key, variant: f.variant, sessionId: f.sessionId, running: false };
|
|
1247
|
+
const stale = f.time !== void 0 && now - f.time >= DREAM_RUNNING_STALE_MS;
|
|
1248
|
+
return { id: f.key, variant: f.variant, sessionId: f.sessionId, running: !stale, interrupted: stale };
|
|
1249
|
+
});
|
|
1250
|
+
return out;
|
|
1251
|
+
}
|
|
1252
|
+
function ensureCss() {
|
|
1253
|
+
if (typeof document === "undefined") return;
|
|
1254
|
+
const existing = document.querySelector(`style[data-plugin-css="${CSS_ID}"]`);
|
|
1255
|
+
if (existing !== null && existing.textContent === NOTICE_CSS) return;
|
|
1256
|
+
for (const stale of Array.from(document.querySelectorAll(`style[data-plugin-css="${CSS_ID}"]`))) {
|
|
1257
|
+
stale.remove();
|
|
1258
|
+
}
|
|
1259
|
+
const tag = document.createElement("style");
|
|
1260
|
+
tag.dataset.plugin = "meow-memory-delegate-notice";
|
|
1261
|
+
tag.dataset.pluginCss = CSS_ID;
|
|
1262
|
+
tag.textContent = NOTICE_CSS;
|
|
1263
|
+
document.head.appendChild(tag);
|
|
1264
|
+
}
|
|
1265
|
+
function applyDelegateNotices(containers, groups) {
|
|
1266
|
+
if (typeof document === "undefined") return;
|
|
1267
|
+
ensureCss();
|
|
1268
|
+
if (containers.length === 0) return;
|
|
1269
|
+
const liveIds = new Set(groups.map((group) => group.id));
|
|
1270
|
+
for (const container of containers) {
|
|
1271
|
+
for (const stale of flowElements(container, `[${ANCHOR_ATTR}]`)) {
|
|
1272
|
+
if (!liveIds.has(stale.getAttribute(ANCHOR_ATTR) ?? "")) stale.remove();
|
|
1273
|
+
}
|
|
1274
|
+
for (const row of flowElements(container, `[${HIDDEN_ATTR}]`)) {
|
|
1275
|
+
if (!liveIds.has(row.getAttribute("data-chat-flow-key") ?? "")) row.removeAttribute(HIDDEN_ATTR);
|
|
1276
|
+
}
|
|
1277
|
+
for (const group of groups) {
|
|
1278
|
+
const row = flowElements(container, `[data-chat-flow-key="${CSS.escape(group.id)}"]`)[0] ?? null;
|
|
1279
|
+
if (row === null || row.parentElement === null) continue;
|
|
1280
|
+
row.setAttribute(HIDDEN_ATTR, "true");
|
|
1281
|
+
if (group.variant === "reflect-done") continue;
|
|
1282
|
+
let anchor = flowElements(container, `[${ANCHOR_ATTR}="${CSS.escape(group.id)}"]`)[0] ?? null;
|
|
1283
|
+
if (anchor === null) {
|
|
1284
|
+
anchor = document.createElement("div");
|
|
1285
|
+
anchor.setAttribute(ANCHOR_ATTR, group.id);
|
|
1286
|
+
row.parentElement.insertBefore(anchor, row);
|
|
1287
|
+
}
|
|
1288
|
+
let bubble = anchor.querySelector(":scope > [data-meow-delegate-bubble]");
|
|
1289
|
+
if (bubble === null) {
|
|
1290
|
+
bubble = document.createElement("div");
|
|
1291
|
+
bubble.setAttribute("data-meow-delegate-bubble", "true");
|
|
1292
|
+
bubble.style.cssText = [
|
|
1293
|
+
"display:block;margin:4px 0;padding:5px 12px;",
|
|
1294
|
+
"font-size:12px;line-height:1.6;text-align:left;",
|
|
1295
|
+
"color:var(--dsw-alias-label-secondary, rgba(127,127,127,.9));",
|
|
1296
|
+
"background:rgba(127,127,127,.07);border:1px solid rgba(127,127,127,.14);",
|
|
1297
|
+
"border-radius:999px;"
|
|
1298
|
+
].join("");
|
|
1299
|
+
anchor.appendChild(bubble);
|
|
1300
|
+
}
|
|
1301
|
+
const label = delegateNoticeLabel(group);
|
|
1302
|
+
if (bubble.textContent !== label) bubble.textContent = label;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
function startDelegateStateSync() {
|
|
1307
|
+
if (typeof window === "undefined") return () => {
|
|
1308
|
+
};
|
|
1309
|
+
let disposed = false;
|
|
1310
|
+
const notify2 = () => {
|
|
1311
|
+
for (const listener of stateListeners) listener();
|
|
1312
|
+
};
|
|
1313
|
+
const refresh = async () => {
|
|
1314
|
+
try {
|
|
1315
|
+
const response = await fetch("/meow-memory/dreamed-sessions", { cache: "no-store" });
|
|
1316
|
+
if (!response.ok) return;
|
|
1317
|
+
const data = await response.json();
|
|
1318
|
+
if (disposed) return;
|
|
1319
|
+
dreamStateBySession.clear();
|
|
1320
|
+
if (Array.isArray(data.sessionIds)) {
|
|
1321
|
+
for (const id of data.sessionIds) if (typeof id === "string") dreamStateBySession.set(id, "dreamed");
|
|
1322
|
+
}
|
|
1323
|
+
if (Array.isArray(data.dreamingIds)) {
|
|
1324
|
+
for (const id of data.dreamingIds) if (typeof id === "string") dreamStateBySession.set(id, "dreaming");
|
|
1325
|
+
}
|
|
1326
|
+
notify2();
|
|
1327
|
+
} catch {
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
const unsubscribeDreamEvents = subscribeDreamEvents((event) => {
|
|
1331
|
+
const { sessionId, state } = event;
|
|
1332
|
+
if (state === "dreaming" || state === "dreamed") dreamStateBySession.set(sessionId, state);
|
|
1333
|
+
else dreamStateBySession.delete(sessionId);
|
|
1334
|
+
notify2();
|
|
1335
|
+
});
|
|
1336
|
+
void refresh();
|
|
1337
|
+
return () => {
|
|
1338
|
+
disposed = true;
|
|
1339
|
+
unsubscribeDreamEvents();
|
|
1340
|
+
dreamStateBySession.clear();
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
// src/client-dream-icon.ts
|
|
1345
|
+
var DREAM_ICON_ATTR = "data-meow-dreamed";
|
|
1346
|
+
var DREAMING_ATTR = "data-meow-dreaming";
|
|
1347
|
+
var SKIPPED_ATTR = "data-meow-skip-dream";
|
|
1348
|
+
var MOON_SVG = '<svg width="10" height="10" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg>';
|
|
1349
|
+
var SKIP_MOON_PATH = "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z";
|
|
1350
|
+
var SKIP_SLASH_PATH = "M2.5 2.5l19 19";
|
|
1351
|
+
function makeSkipMoonSvg() {
|
|
1352
|
+
const id = `meow-skip-${Math.random().toString(36).slice(2, 10)}`;
|
|
1353
|
+
return `<svg width="10" height="10" viewBox="0 0 24 24" aria-hidden="true"><defs><mask id="${id}"><rect width="24" height="24" fill="#fff"/><path d="${SKIP_SLASH_PATH}" fill="none" stroke="#000" stroke-width="4.4" stroke-linecap="round"/></mask></defs><g mask="url(#${id})"><path fill="currentColor" d="${SKIP_MOON_PATH}"/></g><path d="${SKIP_SLASH_PATH}" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>`;
|
|
1354
|
+
}
|
|
1355
|
+
var ICON_CSS = `[${DREAM_ICON_ATTR}],
|
|
1356
|
+
[${DREAMING_ATTR}],
|
|
1357
|
+
[${SKIPPED_ATTR}] {
|
|
1358
|
+
display: inline-flex;
|
|
1359
|
+
flex: none;
|
|
1360
|
+
align-items: center;
|
|
1361
|
+
justify-content: center;
|
|
1362
|
+
width: 10px;
|
|
1363
|
+
height: 10px;
|
|
1364
|
+
margin-right: 4px; /* \u69FD\u4F4D\u5185\u5C45\u72B6\u6001\u70B9\u5DE6\u4FA7 / flat \u884C\u9996\u5185\u8054\uFF1A\u4E0E\u53F3\u4FA7\u5185\u5BB9\u4FDD\u6301\u95F4\u8DDD */
|
|
1365
|
+
}
|
|
1366
|
+
[${DREAM_ICON_ATTR}] { color: #e9c46a; opacity: 0.9; } /* \u6DE1\u9EC4\u505C\u9A7B */
|
|
1367
|
+
[${DREAMING_ATTR}] {
|
|
1368
|
+
color: #f2c14e;
|
|
1369
|
+
animation: meow-dream-breathe 2.4s ease-in-out infinite;
|
|
1370
|
+
}
|
|
1371
|
+
@keyframes meow-dream-breathe {
|
|
1372
|
+
0%, 100% { color: #fff8e6; opacity: 0.55; }
|
|
1373
|
+
50% { color: #f2c14e; opacity: 1; }
|
|
1374
|
+
}
|
|
1375
|
+
[${SKIPPED_ATTR}] { color: #94a3b8; opacity: 0.85; } /* \u9759\u97F3\u7070\uFF1A\u8FD9\u6247\u7A97\u4E0D\u505A\u68A6 */
|
|
1376
|
+
`;
|
|
1377
|
+
var FIBER_KEY_RE = /^__reactFiber\$/;
|
|
1378
|
+
function readSessionId(row) {
|
|
1379
|
+
let fiber = null;
|
|
1380
|
+
for (const key of Object.keys(row)) {
|
|
1381
|
+
if (FIBER_KEY_RE.test(key)) {
|
|
1382
|
+
fiber = row[key];
|
|
1383
|
+
break;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
let cur = fiber;
|
|
1387
|
+
for (let depth = 0; depth < 8 && cur !== null && cur !== void 0; depth++) {
|
|
1388
|
+
const f = cur;
|
|
1389
|
+
if (typeof f.key === "string" && f.key.length > 0) return f.key;
|
|
1390
|
+
cur = f.return;
|
|
1391
|
+
}
|
|
1392
|
+
return null;
|
|
1393
|
+
}
|
|
1394
|
+
function makeIcon(state) {
|
|
1395
|
+
const icon = document.createElement("span");
|
|
1396
|
+
icon.setAttribute(attrForState(state) ?? DREAM_ICON_ATTR, "true");
|
|
1397
|
+
icon.setAttribute("aria-hidden", "true");
|
|
1398
|
+
icon.innerHTML = state === "skipped" ? makeSkipMoonSvg() : MOON_SVG;
|
|
1399
|
+
return icon;
|
|
1400
|
+
}
|
|
1401
|
+
function attrForState(state) {
|
|
1402
|
+
if (state === "dreaming") return DREAMING_ATTR;
|
|
1403
|
+
if (state === "dreamed") return DREAM_ICON_ATTR;
|
|
1404
|
+
if (state === "skipped") return SKIPPED_ATTR;
|
|
1405
|
+
return null;
|
|
1406
|
+
}
|
|
1407
|
+
var ANY_ICON_SEL = `[${DREAM_ICON_ATTR}], [${DREAMING_ATTR}], [${SKIPPED_ATTR}]`;
|
|
1408
|
+
var SESSION_ROWS_SEL = 'div[role="treeitem"][class*="_sessionRow"]';
|
|
1409
|
+
function mergeIconStates(dreamStates, skippedIds) {
|
|
1410
|
+
const merged = /* @__PURE__ */ new Map();
|
|
1411
|
+
for (const [id, state] of dreamStates) merged.set(id, state);
|
|
1412
|
+
for (const id of skippedIds) {
|
|
1413
|
+
if (merged.get(id) !== "dreaming") merged.set(id, "skipped");
|
|
1414
|
+
}
|
|
1415
|
+
return merged;
|
|
1416
|
+
}
|
|
1417
|
+
function applyDreamIcons(states, rows) {
|
|
1418
|
+
const all = rows ?? document.querySelectorAll(SESSION_ROWS_SEL);
|
|
1419
|
+
for (const row of all) {
|
|
1420
|
+
const id = readSessionId(row);
|
|
1421
|
+
const state = id !== null ? states.get(id) : void 0;
|
|
1422
|
+
const wantAttr = attrForState(state);
|
|
1423
|
+
const slot = row.querySelector('[class$="_slot"]');
|
|
1424
|
+
if (slot !== null) {
|
|
1425
|
+
const cur = slot.querySelector(ANY_ICON_SEL);
|
|
1426
|
+
const consistent = cur !== null && wantAttr !== null && cur.getAttribute(wantAttr) === "true";
|
|
1427
|
+
if (state !== void 0 && !consistent) {
|
|
1428
|
+
cur?.remove();
|
|
1429
|
+
slot.insertBefore(makeIcon(state), slot.firstChild);
|
|
1430
|
+
} else if (state === void 0 && cur !== null) {
|
|
1431
|
+
cur.remove();
|
|
1432
|
+
}
|
|
1433
|
+
} else if (state !== void 0) {
|
|
1434
|
+
const cur = row.querySelector(ANY_ICON_SEL);
|
|
1435
|
+
const consistent = cur !== null && cur.getAttribute(wantAttr ?? "") === "true";
|
|
1436
|
+
if (!consistent) {
|
|
1437
|
+
cur?.remove();
|
|
1438
|
+
const icon = makeIcon(state);
|
|
1439
|
+
icon.setAttribute("data-meow-inline-icon", "true");
|
|
1440
|
+
row.insertBefore(icon, row.firstChild);
|
|
1441
|
+
}
|
|
1442
|
+
} else {
|
|
1443
|
+
row.querySelector(ANY_ICON_SEL)?.remove();
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
function startDreamIconManager() {
|
|
1448
|
+
const dreamStates = /* @__PURE__ */ new Map();
|
|
1449
|
+
const skippedIds = /* @__PURE__ */ new Set();
|
|
1450
|
+
let timer = 0;
|
|
1451
|
+
const replay = () => applyDreamIcons(mergeIconStates(dreamStates, skippedIds));
|
|
1452
|
+
const refreshSkips = async () => {
|
|
1453
|
+
try {
|
|
1454
|
+
const response = await fetch("/meow-memory/skip-dreams", { cache: "no-store" });
|
|
1455
|
+
if (!response.ok) return;
|
|
1456
|
+
const data = await response.json();
|
|
1457
|
+
skippedIds.clear();
|
|
1458
|
+
if (Array.isArray(data.scopes)) {
|
|
1459
|
+
for (const sc of data.scopes) {
|
|
1460
|
+
if (typeof sc.sessionId !== "string") continue;
|
|
1461
|
+
if (sc.dream === true) skippedIds.add(sc.sessionId);
|
|
1462
|
+
}
|
|
1463
|
+
} else if (Array.isArray(data.sessionIds)) {
|
|
1464
|
+
for (const id of data.sessionIds) {
|
|
1465
|
+
if (typeof id === "string") skippedIds.add(id);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
} catch {
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
const refresh = async () => {
|
|
1472
|
+
try {
|
|
1473
|
+
const response = await fetch("/meow-memory/dreamed-sessions", { cache: "no-store" });
|
|
1474
|
+
if (!response.ok) return;
|
|
1475
|
+
const data = await response.json();
|
|
1476
|
+
dreamStates.clear();
|
|
1477
|
+
if (Array.isArray(data.sessionIds)) {
|
|
1478
|
+
for (const id of data.sessionIds) {
|
|
1479
|
+
if (typeof id === "string") dreamStates.set(id, "dreamed");
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
if (Array.isArray(data.dreamingIds)) {
|
|
1483
|
+
for (const id of data.dreamingIds) {
|
|
1484
|
+
if (typeof id === "string") dreamStates.set(id, "dreaming");
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
} catch {
|
|
1488
|
+
}
|
|
1489
|
+
await refreshSkips();
|
|
1490
|
+
replay();
|
|
1491
|
+
};
|
|
1492
|
+
const unsubscribeDreamEvents = subscribeDreamEvents((event) => {
|
|
1493
|
+
const { sessionId, state } = event;
|
|
1494
|
+
if (state === "scope") return;
|
|
1495
|
+
if (state === "dreamed" || state === "dreaming") dreamStates.set(sessionId, state);
|
|
1496
|
+
else if (state === "skip") skippedIds.add(sessionId);
|
|
1497
|
+
else if (state === "unskip") skippedIds.delete(sessionId);
|
|
1498
|
+
else dreamStates.delete(sessionId);
|
|
1499
|
+
replay();
|
|
1500
|
+
});
|
|
1501
|
+
for (const stale of Array.from(document.querySelectorAll("style[data-meow-dream-icon-css]"))) {
|
|
1502
|
+
stale.remove();
|
|
1503
|
+
}
|
|
1504
|
+
const style = document.createElement("style");
|
|
1505
|
+
style.dataset.meowDreamIconCss = "true";
|
|
1506
|
+
style.dataset.plugin = "meow-memory";
|
|
1507
|
+
style.textContent = ICON_CSS;
|
|
1508
|
+
document.head.appendChild(style);
|
|
1509
|
+
const observer = new MutationObserver(() => {
|
|
1510
|
+
window.clearTimeout(timer);
|
|
1511
|
+
timer = window.setTimeout(replay, 120);
|
|
1512
|
+
});
|
|
1513
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
1514
|
+
void refresh();
|
|
1515
|
+
return () => {
|
|
1516
|
+
observer.disconnect();
|
|
1517
|
+
window.clearTimeout(timer);
|
|
1518
|
+
unsubscribeDreamEvents();
|
|
1519
|
+
style.remove();
|
|
1520
|
+
for (const el2 of Array.from(document.querySelectorAll(`[${DREAM_ICON_ATTR}], [${DREAMING_ATTR}], [${SKIPPED_ATTR}]`))) el2.remove();
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
// src/client-i18n-replay.ts
|
|
1525
|
+
var replayers = /* @__PURE__ */ new Set();
|
|
1526
|
+
function registerUiReplayer(fn) {
|
|
1527
|
+
replayers.add(fn);
|
|
1528
|
+
return () => {
|
|
1529
|
+
replayers.delete(fn);
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
function replayUiForLocale() {
|
|
1533
|
+
for (const fn of [...replayers]) {
|
|
1534
|
+
try {
|
|
1535
|
+
fn();
|
|
1536
|
+
} catch (error) {
|
|
1537
|
+
console.error("[meow-memory] UI \u8BED\u8A00\u91CD\u653E\u5931\u8D25\uFF1A", error);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
onUiLocaleChange(() => {
|
|
1542
|
+
replayUiForLocale();
|
|
1543
|
+
});
|
|
1544
|
+
|
|
1545
|
+
// src/client-dream-skip.ts
|
|
1546
|
+
var SKIP_ITEM_ATTR = "data-meow-skip-item";
|
|
1547
|
+
var ROW_ACTIONS_SEL = '[class*="_rowActions"]';
|
|
1548
|
+
var SESSION_ROW_SEL = '[role="treeitem"][class*="_sessionRow"]';
|
|
1549
|
+
var MENU_OPEN_ROW_SEL = '[role="treeitem"][class*="_sessionRow"][class*="_menuOpen"]';
|
|
1550
|
+
var MENU_WINDOW_MS = 1500;
|
|
1551
|
+
var PART_STATE_KEYS = {
|
|
1552
|
+
active: "part.state.active",
|
|
1553
|
+
writeonly: "part.state.writeonly",
|
|
1554
|
+
readonly: "part.state.readonly",
|
|
1555
|
+
exited: "part.state.exited"
|
|
1556
|
+
};
|
|
1557
|
+
function participationState(scope) {
|
|
1558
|
+
const { dream, inject: inject2 } = scope;
|
|
1559
|
+
if (!inject2 && !dream) return "active";
|
|
1560
|
+
if (inject2 && !dream) return "writeonly";
|
|
1561
|
+
if (!inject2 && dream) return "readonly";
|
|
1562
|
+
return "exited";
|
|
1563
|
+
}
|
|
1564
|
+
function participationLabel(scope) {
|
|
1565
|
+
return `${t("part.menu")} \xB7 ${t(PART_STATE_KEYS[participationState(scope)])}`;
|
|
1566
|
+
}
|
|
1567
|
+
function captureSessionIdFromTarget(target) {
|
|
1568
|
+
const el2 = target;
|
|
1569
|
+
if (el2 === null || el2 === void 0 || typeof el2.closest !== "function") return null;
|
|
1570
|
+
if (el2.closest(ROW_ACTIONS_SEL) === null) return null;
|
|
1571
|
+
const row = el2.closest(SESSION_ROW_SEL);
|
|
1572
|
+
if (row === null) return null;
|
|
1573
|
+
return readSessionId(row);
|
|
1574
|
+
}
|
|
1575
|
+
function retitleLeaf(root, text) {
|
|
1576
|
+
let leaf = null;
|
|
1577
|
+
const walk = (el2) => {
|
|
1578
|
+
let hasElementChild = false;
|
|
1579
|
+
for (const c of el2.children) {
|
|
1580
|
+
hasElementChild = true;
|
|
1581
|
+
walk(c);
|
|
1582
|
+
}
|
|
1583
|
+
if (!hasElementChild && (el2.textContent ?? "").trim().length > 0) leaf = el2;
|
|
1584
|
+
};
|
|
1585
|
+
walk(root);
|
|
1586
|
+
if (leaf === null) return false;
|
|
1587
|
+
leaf.textContent = text;
|
|
1588
|
+
return true;
|
|
1589
|
+
}
|
|
1590
|
+
function resolveMenuSessionId(doc, fallback) {
|
|
1591
|
+
const openRow = doc.querySelector(MENU_OPEN_ROW_SEL);
|
|
1592
|
+
if (openRow === null) return null;
|
|
1593
|
+
const sid = readSessionId(openRow);
|
|
1594
|
+
return sid !== null ? sid : fallback;
|
|
1595
|
+
}
|
|
1596
|
+
var scopes = /* @__PURE__ */ new Map();
|
|
1597
|
+
function readScope(sid) {
|
|
1598
|
+
return scopes.get(sid) ?? { dream: false, inject: false, write: false };
|
|
1599
|
+
}
|
|
1600
|
+
function writeScopeField(sid, field, val) {
|
|
1601
|
+
const cur = readScope(sid);
|
|
1602
|
+
cur[field] = val;
|
|
1603
|
+
scopes.set(sid, cur);
|
|
1604
|
+
}
|
|
1605
|
+
function injectSkipItem(menu, sessionId, host) {
|
|
1606
|
+
for (const old of Array.from(menu.querySelectorAll(`[${SKIP_ITEM_ATTR}]`))) {
|
|
1607
|
+
if (old.getAttribute("data-meow-session-id") === sessionId) return null;
|
|
1608
|
+
old.remove();
|
|
1609
|
+
}
|
|
1610
|
+
const template = menu.querySelector('[role="menuitem"]');
|
|
1611
|
+
if (template === null) return null;
|
|
1612
|
+
const item = template.cloneNode(true);
|
|
1613
|
+
item.removeAttribute("id");
|
|
1614
|
+
for (const el2 of Array.from(item.querySelectorAll("[id]"))) el2.removeAttribute("id");
|
|
1615
|
+
item.setAttribute("role", "menuitem");
|
|
1616
|
+
if (!retitleLeaf(item, participationLabel(readScope(sessionId)))) return null;
|
|
1617
|
+
item.setAttribute(SKIP_ITEM_ATTR, "true");
|
|
1618
|
+
item.setAttribute("data-meow-session-id", sessionId);
|
|
1619
|
+
const icon = item.querySelector("svg");
|
|
1620
|
+
if (icon !== null) icon.outerHTML = MOON_SVG;
|
|
1621
|
+
const onClick = (e) => {
|
|
1622
|
+
e.stopPropagation();
|
|
1623
|
+
e.preventDefault();
|
|
1624
|
+
host.onOpen(sessionId, item);
|
|
1625
|
+
};
|
|
1626
|
+
item.addEventListener("click", onClick, true);
|
|
1627
|
+
item.addEventListener("pointerdown", (e) => e.stopPropagation());
|
|
1628
|
+
menu.appendChild(item);
|
|
1629
|
+
return item;
|
|
1630
|
+
}
|
|
1631
|
+
var openPanel = null;
|
|
1632
|
+
var openPanelMenu = null;
|
|
1633
|
+
var outsideCloseHandler = null;
|
|
1634
|
+
var escapeCloseHandler = null;
|
|
1635
|
+
var panelRerender = null;
|
|
1636
|
+
function closeScopePanel() {
|
|
1637
|
+
if (openPanel === null) return;
|
|
1638
|
+
openPanel.remove();
|
|
1639
|
+
openPanel = null;
|
|
1640
|
+
if (openPanelMenu !== null) {
|
|
1641
|
+
try {
|
|
1642
|
+
openPanelMenu.style.visibility = "";
|
|
1643
|
+
} catch {
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
openPanelMenu = null;
|
|
1647
|
+
if (outsideCloseHandler !== null) document.removeEventListener("pointerdown", outsideCloseHandler, true);
|
|
1648
|
+
if (escapeCloseHandler !== null) document.removeEventListener("keydown", escapeCloseHandler, true);
|
|
1649
|
+
outsideCloseHandler = null;
|
|
1650
|
+
escapeCloseHandler = null;
|
|
1651
|
+
panelRerender = null;
|
|
1652
|
+
}
|
|
1653
|
+
function buildScopePanel(sid, post) {
|
|
1654
|
+
const panel = document.createElement("div");
|
|
1655
|
+
panel.setAttribute("data-meow-scope-panel", "true");
|
|
1656
|
+
panel.style.cssText = "position:fixed;z-index:2147483647;background:#0f172a;color:#e2e8f0;border:1px solid #334155;border-radius:8px;padding:8px 8px 6px;font-size:12px;line-height:1.6;min-width:276px;box-shadow:0 8px 24px rgba(0,0,0,0.45);font-family:inherit;";
|
|
1657
|
+
const rerender = () => renderRows(sid);
|
|
1658
|
+
panelRerender = rerender;
|
|
1659
|
+
const title = document.createElement("div");
|
|
1660
|
+
title.style.cssText = "font-weight:600;margin-bottom:4px;display:flex;justify-content:space-between;align-items:center;gap:12px;";
|
|
1661
|
+
const titleText = document.createElement("span");
|
|
1662
|
+
titleText.textContent = t("part.menu");
|
|
1663
|
+
const close = document.createElement("span");
|
|
1664
|
+
close.textContent = "\u2715";
|
|
1665
|
+
close.style.cssText = "cursor:pointer;opacity:0.7;padding:0 3px;";
|
|
1666
|
+
close.addEventListener("click", () => closeScopePanel());
|
|
1667
|
+
title.append(titleText, close);
|
|
1668
|
+
panel.appendChild(title);
|
|
1669
|
+
const rows = [
|
|
1670
|
+
{ field: "inject", key: "part.panel.inject" },
|
|
1671
|
+
{ field: "dream", key: "part.panel.consolidate" }
|
|
1672
|
+
];
|
|
1673
|
+
const rowEls = [];
|
|
1674
|
+
for (const { field, key } of rows) {
|
|
1675
|
+
const row = document.createElement("div");
|
|
1676
|
+
row.style.cssText = "display:flex;justify-content:space-between;align-items:center;gap:16px;padding:5px 6px;border-radius:4px;cursor:pointer;white-space:nowrap;";
|
|
1677
|
+
row.addEventListener("pointerenter", () => {
|
|
1678
|
+
row.style.background = "rgba(128,128,128,0.18)";
|
|
1679
|
+
});
|
|
1680
|
+
row.addEventListener("pointerleave", () => {
|
|
1681
|
+
row.style.background = "transparent";
|
|
1682
|
+
});
|
|
1683
|
+
row.addEventListener("click", () => {
|
|
1684
|
+
const next = !readScope(sid)[field];
|
|
1685
|
+
writeScopeField(sid, field, next);
|
|
1686
|
+
post(field, next);
|
|
1687
|
+
rerender();
|
|
1688
|
+
syncOpenMenuLabels();
|
|
1689
|
+
});
|
|
1690
|
+
const label = document.createElement("span");
|
|
1691
|
+
label.textContent = t(key);
|
|
1692
|
+
const state = document.createElement("span");
|
|
1693
|
+
state.style.cssText = "white-space:nowrap;";
|
|
1694
|
+
row.append(label, state);
|
|
1695
|
+
panel.appendChild(row);
|
|
1696
|
+
rowEls.push({ el: row, field, state });
|
|
1697
|
+
}
|
|
1698
|
+
function renderRows(sid2) {
|
|
1699
|
+
const cur = readScope(sid2);
|
|
1700
|
+
for (const { field, state } of rowEls) {
|
|
1701
|
+
const on = cur[field];
|
|
1702
|
+
state.textContent = on ? t("part.panel.off") : t("part.panel.on");
|
|
1703
|
+
state.style.cssText = on ? "opacity:0.55;" : "color:#93c5fd;";
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
renderRows(sid);
|
|
1707
|
+
return panel;
|
|
1708
|
+
}
|
|
1709
|
+
function openScopePanel(sid, anchor, post) {
|
|
1710
|
+
closeScopePanel();
|
|
1711
|
+
const menu = anchor.closest('[role="menu"]');
|
|
1712
|
+
const panel = buildScopePanel(sid, post);
|
|
1713
|
+
document.body.appendChild(panel);
|
|
1714
|
+
const rect = anchor.getBoundingClientRect();
|
|
1715
|
+
const pw = panel.offsetWidth;
|
|
1716
|
+
const ph = panel.offsetHeight;
|
|
1717
|
+
let left = rect.right + 6;
|
|
1718
|
+
if (left + pw > window.innerWidth - 8) left = Math.max(8, rect.left - pw - 6);
|
|
1719
|
+
let top = rect.top;
|
|
1720
|
+
if (top + ph > window.innerHeight - 8) top = Math.max(8, window.innerHeight - ph - 8);
|
|
1721
|
+
panel.style.left = `${Math.max(8, left)}px`;
|
|
1722
|
+
panel.style.top = `${Math.max(8, top)}px`;
|
|
1723
|
+
openPanel = panel;
|
|
1724
|
+
openPanelMenu = menu;
|
|
1725
|
+
if (menu !== null) menu.style.visibility = "hidden";
|
|
1726
|
+
outsideCloseHandler = (e) => {
|
|
1727
|
+
if (openPanel !== null && !openPanel.contains(e.target)) closeScopePanel();
|
|
1728
|
+
};
|
|
1729
|
+
escapeCloseHandler = (e) => {
|
|
1730
|
+
if (e.key === "Escape") closeScopePanel();
|
|
1731
|
+
};
|
|
1732
|
+
document.addEventListener("pointerdown", outsideCloseHandler, true);
|
|
1733
|
+
document.addEventListener("keydown", escapeCloseHandler, true);
|
|
1734
|
+
}
|
|
1735
|
+
function syncOpenMenuLabels() {
|
|
1736
|
+
for (const item of Array.from(document.querySelectorAll(`[${SKIP_ITEM_ATTR}]`))) {
|
|
1737
|
+
const sid = item.getAttribute("data-meow-session-id");
|
|
1738
|
+
if (sid !== null) retitleLeaf(item, participationLabel(readScope(sid)));
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
function startDreamSkipManager() {
|
|
1742
|
+
let pendingSid = null;
|
|
1743
|
+
let pendingAt = 0;
|
|
1744
|
+
let observerTimer = 0;
|
|
1745
|
+
const syncOpenMenus = () => {
|
|
1746
|
+
const withinWindow = pendingSid !== null && Date.now() - pendingAt <= MENU_WINDOW_MS;
|
|
1747
|
+
const sid = resolveMenuSessionId(document, withinWindow ? pendingSid : null);
|
|
1748
|
+
if (sid === null) return;
|
|
1749
|
+
for (const menu of Array.from(document.querySelectorAll('[role="menu"]'))) {
|
|
1750
|
+
injectSkipItem(menu, sid, { onOpen: handleOpen });
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
const observer = new MutationObserver((muts) => {
|
|
1754
|
+
if (pendingSid !== null && Date.now() - pendingAt <= MENU_WINDOW_MS) {
|
|
1755
|
+
const sid = resolveMenuSessionId(document, pendingSid);
|
|
1756
|
+
if (sid !== null) {
|
|
1757
|
+
for (const m of muts) {
|
|
1758
|
+
for (const node of Array.from(m.addedNodes)) {
|
|
1759
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
1760
|
+
const menus = node.matches('[role="menu"]') ? [node] : Array.from(node.querySelectorAll('[role="menu"]'));
|
|
1761
|
+
for (const menu of menus) injectSkipItem(menu, sid, { onOpen: handleOpen });
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
for (const menu of Array.from(document.querySelectorAll('[role="menu"]'))) {
|
|
1765
|
+
injectSkipItem(menu, sid, { onOpen: handleOpen });
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
window.clearTimeout(observerTimer);
|
|
1770
|
+
observerTimer = window.setTimeout(syncOpenMenus, 120);
|
|
1771
|
+
});
|
|
1772
|
+
const handlePost = (sessionId, field, value) => {
|
|
1773
|
+
void (async () => {
|
|
1774
|
+
try {
|
|
1775
|
+
const resp = await fetch("/meow-memory/skip-dreams", {
|
|
1776
|
+
method: "POST",
|
|
1777
|
+
headers: { "content-type": "application/json" },
|
|
1778
|
+
body: JSON.stringify({ sessionId, field, value })
|
|
1779
|
+
});
|
|
1780
|
+
if (!resp.ok) throw new Error(String(resp.status));
|
|
1781
|
+
} catch {
|
|
1782
|
+
writeScopeField(sessionId, field, !value);
|
|
1783
|
+
panelRerender?.();
|
|
1784
|
+
syncOpenMenuLabels();
|
|
1785
|
+
}
|
|
1786
|
+
})();
|
|
1787
|
+
};
|
|
1788
|
+
const handleOpen = (sessionId, item) => {
|
|
1789
|
+
openScopePanel(sessionId, item, (field, value) => {
|
|
1790
|
+
handlePost(sessionId, field, value);
|
|
1791
|
+
});
|
|
1792
|
+
};
|
|
1793
|
+
const onPointerDown = (e) => {
|
|
1794
|
+
const sid = captureSessionIdFromTarget(e.target);
|
|
1795
|
+
if (sid === null) return;
|
|
1796
|
+
pendingSid = sid;
|
|
1797
|
+
pendingAt = Date.now();
|
|
1798
|
+
};
|
|
1799
|
+
const refresh = async () => {
|
|
1800
|
+
try {
|
|
1801
|
+
const response = await fetch("/meow-memory/skip-dreams", { cache: "no-store" });
|
|
1802
|
+
if (!response.ok) return;
|
|
1803
|
+
const data = await response.json();
|
|
1804
|
+
scopes.clear();
|
|
1805
|
+
if (Array.isArray(data.scopes)) {
|
|
1806
|
+
for (const sc of data.scopes) {
|
|
1807
|
+
if (typeof sc.sessionId !== "string") continue;
|
|
1808
|
+
scopes.set(sc.sessionId, { dream: sc.dream === true, inject: sc.inject === true, write: sc.write === true });
|
|
1809
|
+
}
|
|
1810
|
+
} else if (Array.isArray(data.sessionIds)) {
|
|
1811
|
+
for (const id of data.sessionIds) {
|
|
1812
|
+
if (typeof id === "string") scopes.set(id, { dream: true, inject: false, write: false });
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
syncOpenMenuLabels();
|
|
1816
|
+
} catch {
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
const unsubscribeDreamEvents = subscribeDreamEvents((event) => {
|
|
1820
|
+
const { sessionId, state } = event;
|
|
1821
|
+
if (state === "scope" && (event.field === "dream" || event.field === "inject" || event.field === "write")) {
|
|
1822
|
+
writeScopeField(sessionId, event.field, event.value === true);
|
|
1823
|
+
} else if (state === "skip") {
|
|
1824
|
+
writeScopeField(sessionId, "dream", true);
|
|
1825
|
+
} else if (state === "unskip") {
|
|
1826
|
+
writeScopeField(sessionId, "dream", false);
|
|
1827
|
+
} else {
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1830
|
+
syncOpenMenuLabels();
|
|
1831
|
+
panelRerender?.();
|
|
1832
|
+
});
|
|
1833
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1834
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
1835
|
+
void refresh();
|
|
1836
|
+
const unregisterReplay = registerUiReplayer(() => {
|
|
1837
|
+
syncOpenMenuLabels();
|
|
1838
|
+
});
|
|
1839
|
+
return () => {
|
|
1840
|
+
unregisterReplay();
|
|
1841
|
+
closeScopePanel();
|
|
1842
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
1843
|
+
observer.disconnect();
|
|
1844
|
+
window.clearTimeout(observerTimer);
|
|
1845
|
+
unsubscribeDreamEvents();
|
|
1846
|
+
for (const item of Array.from(document.querySelectorAll(`[${SKIP_ITEM_ATTR}]`))) item.remove();
|
|
1847
|
+
for (const el2 of Array.from(document.querySelectorAll("[data-meow-scope-panel]"))) el2.remove();
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
// src/client-menu-dream.ts
|
|
1852
|
+
var MENU_SELECTOR = "[data-trigger-menu]";
|
|
1853
|
+
var ROW_ID_PREFIX = "dsh-slash-option-command-";
|
|
1854
|
+
var DREAM_SHORT = "\u624B\u52A8\u5524\u8D77\u4E00\u6B21\u8BB0\u5FC6\u6574\u7406";
|
|
1855
|
+
var DREAM_LABEL = "\u8BB0\u5FC6\u6574\u7406";
|
|
1856
|
+
var DREAM_LONG_PREFIX = "\u624B\u52A8\u5524\u8D77\u4E00\u6B21\u8BB0\u5FC6\u6574\u7406\uFF08dream\uFF09";
|
|
1857
|
+
var OFFICIAL_ALIASES = ["compact", "model", "export", "permission", "goal", "plan", "feedback"];
|
|
1858
|
+
var MOON_SVG2 = '<svg viewBox="0 0 512 512" aria-hidden="true" focusable="false"><path fill="currentColor" d="M279.135 512c78.756 0 150.982-35.804 198.844-94.775 28.27-34.831-2.558-85.722-46.249-77.401-82.348 15.683-158.272-47.268-158.272-130.792 0-48.424 26.06-92.292 67.434-115.836 38.745-22.05 28.999-80.788-15.022-88.919A257.936 257.936 0 0 0 279.135 0c-141.36 0-256 114.575-256 256 0 141.36 114.576 256 256 256zm0-464c12.985 0 25.689 1.201 38.016 3.478-54.76 31.163-91.693 90.042-91.693 157.554 0 113.848 103.641 199.2 215.252 177.944C402.574 433.964 344.366 464 279.135 464c-114.875 0-208-93.125-208-208s93.125-208 208-208z"/></svg>';
|
|
1859
|
+
function findDreamRow(menu) {
|
|
1860
|
+
const rows = menu.querySelectorAll(`button[id^="${ROW_ID_PREFIX}"]`);
|
|
1861
|
+
for (const row of rows) {
|
|
1862
|
+
for (const span of row.querySelectorAll(":scope > span")) {
|
|
1863
|
+
if (span.textContent === "dream") return row;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
return null;
|
|
1867
|
+
}
|
|
1868
|
+
function officialIconClass(menu) {
|
|
1869
|
+
const svg = menu.querySelector(`button[id^="${ROW_ID_PREFIX}"] > span > svg`);
|
|
1870
|
+
const span = svg?.parentElement;
|
|
1871
|
+
if (span === null || span === void 0 || span.className.length === 0) return null;
|
|
1872
|
+
return span.className;
|
|
1873
|
+
}
|
|
1874
|
+
function officialAliasClass(menu) {
|
|
1875
|
+
const spans = menu.querySelectorAll(`button[id^="${ROW_ID_PREFIX}"] > span`);
|
|
1876
|
+
for (const name of OFFICIAL_ALIASES) {
|
|
1877
|
+
for (const span of spans) {
|
|
1878
|
+
if (span.textContent === name && span.className.length > 0) return span.className;
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
return null;
|
|
1882
|
+
}
|
|
1883
|
+
function decorateRow(row, iconClass, aliasClass) {
|
|
1884
|
+
const spans = row.querySelectorAll(":scope > span");
|
|
1885
|
+
let nameSpan = null;
|
|
1886
|
+
let descriptionSpan = null;
|
|
1887
|
+
const aliasSpan = row.querySelector(":scope > span[data-meow-dream-alias]");
|
|
1888
|
+
for (const span of spans) {
|
|
1889
|
+
if (span === aliasSpan) {
|
|
1890
|
+
nameSpan = aliasSpan.previousElementSibling;
|
|
1891
|
+
continue;
|
|
1892
|
+
}
|
|
1893
|
+
if (span.textContent === "dream" && nameSpan === null) nameSpan = span;
|
|
1894
|
+
else if ((span.textContent?.length ?? 0) > 4 && span !== nameSpan) descriptionSpan = span;
|
|
1895
|
+
}
|
|
1896
|
+
if (nameSpan === null) return;
|
|
1897
|
+
if (nameSpan.textContent === "dream") nameSpan.textContent = DREAM_LABEL;
|
|
1898
|
+
if (aliasSpan === null) {
|
|
1899
|
+
const alias = document.createElement("span");
|
|
1900
|
+
alias.setAttribute("data-meow-dream-alias", "1");
|
|
1901
|
+
if (aliasClass !== null) alias.className = aliasClass;
|
|
1902
|
+
else alias.style.cssText = "opacity:.55;font-size:.9em;";
|
|
1903
|
+
alias.textContent = "dream";
|
|
1904
|
+
nameSpan.parentElement?.insertBefore(alias, nameSpan.nextSibling);
|
|
1905
|
+
}
|
|
1906
|
+
const prev = nameSpan.previousElementSibling;
|
|
1907
|
+
if (prev === null || !prev.hasAttribute("data-meow-dream-face")) {
|
|
1908
|
+
const icon = document.createElement("span");
|
|
1909
|
+
icon.setAttribute("data-meow-dream-face", "1");
|
|
1910
|
+
if (iconClass !== null) icon.className = iconClass;
|
|
1911
|
+
else icon.style.cssText = "display:inline-flex;flex:none;width:14px;height:14px;align-items:center;justify-content:center;";
|
|
1912
|
+
icon.innerHTML = MOON_SVG2;
|
|
1913
|
+
nameSpan.parentElement?.insertBefore(icon, nameSpan);
|
|
1914
|
+
}
|
|
1915
|
+
if (descriptionSpan !== null && descriptionSpan !== nameSpan && descriptionSpan.textContent?.startsWith(DREAM_LONG_PREFIX) === true) {
|
|
1916
|
+
descriptionSpan.textContent = DREAM_SHORT;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
function startMenuDreamFace() {
|
|
1920
|
+
if (typeof document === "undefined") return () => {
|
|
1921
|
+
};
|
|
1922
|
+
let scheduled = false;
|
|
1923
|
+
const decorate = () => {
|
|
1924
|
+
scheduled = false;
|
|
1925
|
+
try {
|
|
1926
|
+
const menu = document.querySelector(MENU_SELECTOR);
|
|
1927
|
+
if (menu === null) return;
|
|
1928
|
+
const row = findDreamRow(menu);
|
|
1929
|
+
if (row === null) return;
|
|
1930
|
+
decorateRow(row, officialIconClass(menu), officialAliasClass(menu));
|
|
1931
|
+
} catch {
|
|
1932
|
+
}
|
|
1933
|
+
};
|
|
1934
|
+
const schedule = () => {
|
|
1935
|
+
if (scheduled) return;
|
|
1936
|
+
scheduled = true;
|
|
1937
|
+
queueMicrotask(decorate);
|
|
1938
|
+
};
|
|
1939
|
+
const observer = new MutationObserver(schedule);
|
|
1940
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
1941
|
+
schedule();
|
|
1942
|
+
return () => {
|
|
1943
|
+
observer.disconnect();
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
// src/settings-page.ts
|
|
1948
|
+
var React = __toESM(require("react"), 1);
|
|
1949
|
+
|
|
1950
|
+
// src/defaults.ts
|
|
1951
|
+
var DEFAULT_RULES_REVIEW_DAYS = 2;
|
|
1952
|
+
var CONFIG_DEFAULTS = {
|
|
1953
|
+
enabled: true,
|
|
1954
|
+
projectDir: ".dsh-meow",
|
|
1955
|
+
hitTopK: 2,
|
|
1956
|
+
titleMax: 40,
|
|
1957
|
+
reflect: true,
|
|
1958
|
+
reflectTurns: 7,
|
|
1959
|
+
autoMigrate: true,
|
|
1960
|
+
/** 全局目录选择:''=默认(平台用户主目录);预设标记或绝对路径见 home-dir.ts。
|
|
1961
|
+
* 恢复默认写入 ''(而非删字段)=回落平台默认目录。 */
|
|
1962
|
+
homeDir: "",
|
|
1963
|
+
dream: {
|
|
1964
|
+
enabled: true,
|
|
1965
|
+
idleMinutes: 180,
|
|
1966
|
+
suppressWindows: [{ start: "09:00", end: "12:00" }, { start: "14:00", end: "18:00" }],
|
|
1967
|
+
suppressLeadMinutes: 15,
|
|
1968
|
+
checkMinutes: 15,
|
|
1969
|
+
timeZone: "Asia/Shanghai",
|
|
1970
|
+
rulesReviewDays: DEFAULT_RULES_REVIEW_DAYS
|
|
1971
|
+
},
|
|
1972
|
+
delegate: { model: "", effort: "" },
|
|
1973
|
+
/** 记忆库自动备份(#37 增量②,默认关):开启后每次 dream 收尾把 memory.db
|
|
1974
|
+
* 快照轮转到 memory.db.bak(VACUUM INTO 一致性备份)。 */
|
|
1975
|
+
backup: { enabled: false },
|
|
1976
|
+
/** 工作区停用名单(#28):列出的工作区(cwd 归一匹配)完全停用记忆——读/整理/写
|
|
1977
|
+
* 全部拒绝(含手动 /dream)。用于一次性任务的工作区,避免污染记忆库。 */
|
|
1978
|
+
disabledWorkspaces: []
|
|
1979
|
+
};
|
|
1980
|
+
function factoryDefaultOf(spec) {
|
|
1981
|
+
const scope = spec.sub === void 0 ? CONFIG_DEFAULTS : CONFIG_DEFAULTS[spec.sub];
|
|
1982
|
+
if (scope === void 0 || scope === null || typeof scope !== "object") return void 0;
|
|
1983
|
+
return scope[spec.key];
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
// src/settings-page.ts
|
|
1987
|
+
var SETTINGS_NS = "meow-memory";
|
|
1988
|
+
// 2026-11-18 22:30 修复(tools/patch-meow-settings-ns.mjs):宿主按 entry id 注册 config
|
|
1989
|
+
// 命名空间,本包以 macro-memory 身份挂载时配置挂在 "macro-memory" 下;写死读 "meow-memory"
|
|
1990
|
+
// 会读不到(设置面板空白)。按候选顺序探测,独立运行时仍回落到 meow-memory。
|
|
1991
|
+
var SETTINGS_NS_CANDIDATES = ["macro-memory", "dsh-macro-memory", "meow-memory"];
|
|
1992
|
+
function resolveSettingsNs(probe) {
|
|
1993
|
+
for (let i = 0; i < SETTINGS_NS_CANDIDATES.length; i += 1) {
|
|
1994
|
+
const ns = SETTINGS_NS_CANDIDATES[i];
|
|
1995
|
+
try {
|
|
1996
|
+
if (probe(ns)) return ns;
|
|
1997
|
+
} catch {
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
return SETTINGS_NS_CANDIDATES[0];
|
|
2001
|
+
}
|
|
2002
|
+
function bindSettingsScope(scope, order) {
|
|
2003
|
+
const list = Array.isArray(order) && order.length > 0 ? order : SETTINGS_NS_CANDIDATES;
|
|
2004
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
2005
|
+
try {
|
|
2006
|
+
return scope.bind({ namespace: list[i] });
|
|
2007
|
+
} catch {
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
return null;
|
|
2011
|
+
}
|
|
2012
|
+
var CSS_ID2 = "meow-memory-settings-css";
|
|
2013
|
+
var CSS2 = `
|
|
2014
|
+
.meowmm_set_page{color:var(--dsw-alias-label-primary);display:flex;flex-direction:column;gap:10px;max-width:760px;padding:4px 0}
|
|
2015
|
+
.meowmm_set_title{font-size:16px;font-weight:600;margin:0}
|
|
2016
|
+
.meowmm_set_subtitle{color:var(--dsw-alias-label-caption);font-size:12px;line-height:1.6;margin:0}
|
|
2017
|
+
.meowmm_set_card{background:color-mix(in srgb,currentColor 3%,transparent);border:1px solid var(--dsw-alias-border-l3);border-radius:10px;display:flex;flex-direction:column;gap:8px;padding:12px}
|
|
2018
|
+
.meowmm_set_group{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:600;margin-top:2px}
|
|
2019
|
+
.meowmm_set_row{align-items:flex-start;display:flex;gap:10px;justify-content:space-between}
|
|
2020
|
+
.meowmm_set_rowtext{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
2021
|
+
.meowmm_set_label{font-size:13px;font-weight:500}
|
|
2022
|
+
.meowmm_set_hint{color:var(--dsw-alias-label-caption);font-size:12px;line-height:1.5}
|
|
2023
|
+
.meowmm_set_ctrl{flex:none;padding-top:2px}
|
|
2024
|
+
.meowmm_set_input{background:transparent;border:1px solid var(--dsw-alias-border-l3);border-radius:6px;color:inherit;font-size:13px;padding:4px 8px;width:190px}
|
|
2025
|
+
.meowmm_set_input_err{border-color:#f43f5e}
|
|
2026
|
+
.meowmm_set_input_time{width:230px;font-family:ui-monospace,monospace}
|
|
2027
|
+
.meowmm_set_check{cursor:pointer}
|
|
2028
|
+
.meowmm_set_homedir_block{display:flex;flex-direction:column;gap:10px}
|
|
2029
|
+
.meowmm_set_homedir{display:flex;flex-direction:column;gap:12px;min-width:300px}
|
|
2030
|
+
.meowmm_set_homedir_opt{cursor:pointer;display:flex;flex-direction:column;gap:3px}
|
|
2031
|
+
.meowmm_set_homedir_row{align-items:center;display:flex;gap:8px}
|
|
2032
|
+
.meowmm_set_homedir_name{color:var(--dsw-alias-label-secondary);font-size:13px}
|
|
2033
|
+
.meowmm_set_homedir_opt_on .meowmm_set_homedir_name{color:var(--dsw-alias-label-primary);font-weight:500}
|
|
2034
|
+
.meowmm_set_homedir_path{color:var(--dsw-alias-label-caption);font-family:ui-monospace,monospace;font-size:11px;padding-left:27px;word-break:break-all}
|
|
2035
|
+
.meowmm_set_homedir_input{margin-left:27px;width:320px;font-family:ui-monospace,monospace}
|
|
2036
|
+
.meowmm_set_badge{border-radius:999px;font-size:11px;line-height:16px;padding:0 8px;flex:none}
|
|
2037
|
+
.meowmm_set_badge_override{background:color-mix(in srgb,#f59e0b 18%,transparent);color:#f59e0b}
|
|
2038
|
+
.meowmm_set_badge_prefill{background:color-mix(in srgb,#60a5fa 18%,transparent);color:#60a5fa}
|
|
2039
|
+
.meowmm_set_reset{background:transparent;border:1px solid var(--dsw-alias-border-l3);border-radius:6px;color:var(--dsw-alias-label-secondary);cursor:pointer;font-size:12px;padding:2px 8px}
|
|
2040
|
+
.meowmm_set_reset:hover{border-color:var(--dsw-alias-border-l2);color:inherit}
|
|
2041
|
+
.meowmm_set_err{color:#f43f5e;font-size:12px;line-height:1.5;margin:0}
|
|
2042
|
+
.meowmm_set_mirrornote{background:color-mix(in srgb,#f59e0b 12%,transparent);border:1px solid color-mix(in srgb,#f59e0b 35%,transparent);border-radius:8px;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.6;padding:8px 12px}
|
|
2043
|
+
.meowmm_set_saved{color:#34d399;font-size:12px}
|
|
2044
|
+
.meowmm_set_muted{color:var(--dsw-alias-label-caption);font-size:12px}
|
|
2045
|
+
`;
|
|
2046
|
+
var el = React.createElement;
|
|
2047
|
+
var FIELDS = [
|
|
2048
|
+
{
|
|
2049
|
+
title: "settings.group.base",
|
|
2050
|
+
fields: [
|
|
2051
|
+
{ key: "enabled", label: "settings.field.enabled.label", type: "bool", hint: "settings.field.enabled.hint" }
|
|
2052
|
+
]
|
|
2053
|
+
},
|
|
2054
|
+
{
|
|
2055
|
+
title: "settings.group.inject",
|
|
2056
|
+
fields: [
|
|
2057
|
+
{ key: "hitTopK", label: "settings.field.hitTopK.label", type: "num", hint: "settings.field.hitTopK.hint" },
|
|
2058
|
+
{ key: "titleMax", label: "settings.field.titleMax.label", type: "num", hint: "settings.field.titleMax.hint" }
|
|
2059
|
+
]
|
|
2060
|
+
},
|
|
2061
|
+
{
|
|
2062
|
+
title: "settings.group.reflect",
|
|
2063
|
+
fields: [
|
|
2064
|
+
{ key: "reflect", label: "settings.field.reflect.label", type: "bool", hint: "settings.field.reflect.hint" },
|
|
2065
|
+
{ key: "reflectTurns", label: "settings.field.reflectTurns.label", type: "num", hint: "settings.field.reflectTurns.hint" }
|
|
2066
|
+
]
|
|
2067
|
+
},
|
|
2068
|
+
{
|
|
2069
|
+
title: "settings.group.delegate",
|
|
2070
|
+
fields: [
|
|
2071
|
+
{ key: "model", sub: "delegate", label: "settings.field.delegateModel.label", type: "str", hint: "settings.field.delegateModel.hint", placeholder: "settings.field.delegateModel.placeholder" },
|
|
2072
|
+
{ key: "effort", sub: "delegate", label: "settings.field.delegateEffort.label", type: "str", hint: "settings.field.delegateEffort.hint", placeholder: "settings.field.delegateEffort.placeholder" }
|
|
2073
|
+
]
|
|
2074
|
+
},
|
|
2075
|
+
{
|
|
2076
|
+
title: "settings.group.dream",
|
|
2077
|
+
fields: [
|
|
2078
|
+
{ key: "enabled", sub: "dream", label: "settings.field.dreamEnabled.label", type: "bool" },
|
|
2079
|
+
{ key: "idleMinutes", sub: "dream", label: "settings.field.dream.idleMinutes.label", type: "num", hint: "settings.field.dream.idleMinutes.hint" },
|
|
2080
|
+
{ key: "suppressWindows", sub: "dream", label: "settings.field.dream.suppressWindows.label", type: "str", hint: "settings.field.dream.suppressWindows.hint", placeholder: "09:00-12:00, 14:00-18:00" },
|
|
2081
|
+
{ key: "suppressLeadMinutes", sub: "dream", label: "settings.field.dream.suppressLeadMinutes.label", type: "num" },
|
|
2082
|
+
{ key: "checkMinutes", sub: "dream", label: "settings.field.dream.checkMinutes.label", type: "num" },
|
|
2083
|
+
{ key: "timeZone", sub: "dream", label: "settings.field.dream.timeZone.label", type: "str", hint: "settings.field.dream.timeZone.hint" },
|
|
2084
|
+
{ key: "rulesReviewDays", sub: "dream", label: "settings.field.dream.rulesReviewDays.label", type: "num", hint: "settings.field.dream.rulesReviewDays.hint" }
|
|
2085
|
+
]
|
|
2086
|
+
},
|
|
2087
|
+
{
|
|
2088
|
+
title: "settings.group.language",
|
|
2089
|
+
fields: [
|
|
2090
|
+
{ key: "promptLang", label: "settings.field.promptLang.label", type: "str", hint: "settings.field.promptLang.hint", placeholder: "settings.field.promptLang.placeholder" }
|
|
2091
|
+
]
|
|
2092
|
+
},
|
|
2093
|
+
{
|
|
2094
|
+
title: "settings.group.storage",
|
|
2095
|
+
fields: [
|
|
2096
|
+
{ key: "projectDir", label: "settings.field.projectDir.label", type: "str", hint: "settings.field.projectDir.hint", placeholder: ".dsh-meow" },
|
|
2097
|
+
{ key: "homeDir", label: "settings.field.homeDir.label", type: "homeDir", hint: "settings.field.homeDir.hint", placeholder: "D:\\data\\meow-memory" },
|
|
2098
|
+
{ key: "autoMigrate", label: "settings.field.autoMigrate.label", type: "bool", hint: "settings.field.autoMigrate.hint" }
|
|
2099
|
+
]
|
|
2100
|
+
}
|
|
2101
|
+
];
|
|
2102
|
+
function placeholderOf(spec) {
|
|
2103
|
+
if (spec.placeholder === void 0) return void 0;
|
|
2104
|
+
return UI_KEYS.includes(spec.placeholder) ? t(spec.placeholder) : spec.placeholder;
|
|
2105
|
+
}
|
|
2106
|
+
function parseSuppressWindows(text) {
|
|
2107
|
+
const trimmed = text.trim();
|
|
2108
|
+
if (trimmed === "") return { value: [] };
|
|
2109
|
+
const out = [];
|
|
2110
|
+
for (const part of trimmed.split(/[,,]/)) {
|
|
2111
|
+
const seg = part.trim();
|
|
2112
|
+
if (!seg) continue;
|
|
2113
|
+
const m = /^(\d{1,2}:\d{2})\s*-\s*(\d{1,2}:\d{2})$/.exec(seg);
|
|
2114
|
+
if (!m) return { error: t("settings.suppress.format", { value: seg }) };
|
|
2115
|
+
out.push({ start: m[1], end: m[2] });
|
|
2116
|
+
}
|
|
2117
|
+
if (out.length === 0) return { error: t("settings.suppress.atLeastOne") };
|
|
2118
|
+
return { value: out };
|
|
2119
|
+
}
|
|
2120
|
+
function serializeSuppressWindows(w) {
|
|
2121
|
+
return (w ?? []).map((x) => `${x.start}-${x.end}`).join(", ");
|
|
2122
|
+
}
|
|
2123
|
+
function fieldValue(value, spec) {
|
|
2124
|
+
if (spec.sub === void 0) return value?.[spec.key];
|
|
2125
|
+
const parent = value?.[spec.sub];
|
|
2126
|
+
return parent?.[spec.key];
|
|
2127
|
+
}
|
|
2128
|
+
function inUserLayer(user, spec) {
|
|
2129
|
+
if (user === void 0) return false;
|
|
2130
|
+
if (spec.sub === void 0) return spec.key in user;
|
|
2131
|
+
const parent = user[spec.sub];
|
|
2132
|
+
return parent !== void 0 && spec.key in parent;
|
|
2133
|
+
}
|
|
2134
|
+
function draftKey(spec) {
|
|
2135
|
+
return spec.sub === void 0 ? spec.key : `${spec.sub}.${spec.key}`;
|
|
2136
|
+
}
|
|
2137
|
+
function jsonEqual(a, b) {
|
|
2138
|
+
if (a === b) return true;
|
|
2139
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
2140
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
2141
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
2142
|
+
return a.length === b.length && a.every((entry, i) => jsonEqual(entry, b[i]));
|
|
2143
|
+
}
|
|
2144
|
+
const ka = Object.keys(a);
|
|
2145
|
+
const kb = Object.keys(b);
|
|
2146
|
+
return ka.length === kb.length && ka.every((k) => k in b && jsonEqual(a[k], b[k]));
|
|
2147
|
+
}
|
|
2148
|
+
function useUiLocale() {
|
|
2149
|
+
const subscribe = React.useCallback((cb) => onUiLocaleChange(() => cb()), []);
|
|
2150
|
+
return React.useSyncExternalStore(subscribe, getUiLocale, getUiLocale);
|
|
2151
|
+
}
|
|
2152
|
+
function MemorySettingsSection(props) {
|
|
2153
|
+
const scope = props.scope;
|
|
2154
|
+
useUiLocale();
|
|
2155
|
+
const subscribe = React.useCallback((cb) => scope.subscribe(cb), [scope]);
|
|
2156
|
+
const getSnapshot = React.useCallback(() => scope.getSnapshot(), [scope]);
|
|
2157
|
+
const snap = React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
2158
|
+
const [savedAt, setSavedAt] = React.useState(0);
|
|
2159
|
+
const [error, setError] = React.useState(null);
|
|
2160
|
+
const [suppressText, setSuppressText] = React.useState(null);
|
|
2161
|
+
const [drafts, setDrafts] = React.useState({});
|
|
2162
|
+
const flashSaved = () => {
|
|
2163
|
+
setSavedAt(Date.now());
|
|
2164
|
+
window.setTimeout(() => setSavedAt((t2) => t2 === 0 ? 0 : t2), 4e3);
|
|
2165
|
+
};
|
|
2166
|
+
const clearDraft = (spec) => {
|
|
2167
|
+
const key = draftKey(spec);
|
|
2168
|
+
setDrafts((prev) => {
|
|
2169
|
+
if (!(key in prev)) return prev;
|
|
2170
|
+
const next = { ...prev };
|
|
2171
|
+
delete next[key];
|
|
2172
|
+
return next;
|
|
2173
|
+
});
|
|
2174
|
+
};
|
|
2175
|
+
const apply2 = async (spec, newValue) => {
|
|
2176
|
+
setError(null);
|
|
2177
|
+
if (snap.mode === "memory") {
|
|
2178
|
+
setError(t("settings.mirrorReadonly"));
|
|
2179
|
+
return false;
|
|
2180
|
+
}
|
|
2181
|
+
let setOk;
|
|
2182
|
+
try {
|
|
2183
|
+
if (spec.sub === void 0) {
|
|
2184
|
+
setOk = await scope.set(spec.key, newValue);
|
|
2185
|
+
} else {
|
|
2186
|
+
const user = scope.getSnapshot().user;
|
|
2187
|
+
const parent = { ...user?.[spec.sub] ?? {} };
|
|
2188
|
+
parent[spec.key] = newValue;
|
|
2189
|
+
setOk = await scope.set(spec.sub, parent);
|
|
2190
|
+
}
|
|
2191
|
+
} catch (e) {
|
|
2192
|
+
setError(t("settings.saveFailed", { error: e instanceof Error ? e.message : String(e) }));
|
|
2193
|
+
return false;
|
|
2194
|
+
}
|
|
2195
|
+
console.info("[meow-memory] settings write", spec.key, {
|
|
2196
|
+
mode: snap.mode,
|
|
2197
|
+
setReturned: setOk,
|
|
2198
|
+
userNow: scope.getSnapshot().user?.[spec.sub === void 0 ? spec.key : `${String(spec.sub)}.${String(spec.key)}`]
|
|
2199
|
+
});
|
|
2200
|
+
const landed = () => {
|
|
2201
|
+
const v = scope.getSnapshot().user;
|
|
2202
|
+
const cur = spec.sub === void 0 ? v?.[spec.key] : v?.[spec.sub]?.[spec.key];
|
|
2203
|
+
return jsonEqual(cur, newValue);
|
|
2204
|
+
};
|
|
2205
|
+
if (landed()) {
|
|
2206
|
+
flashSaved();
|
|
2207
|
+
return true;
|
|
2208
|
+
}
|
|
2209
|
+
await new Promise((resolve) => window.setTimeout(resolve, 300));
|
|
2210
|
+
if (landed()) {
|
|
2211
|
+
flashSaved();
|
|
2212
|
+
return true;
|
|
2213
|
+
}
|
|
2214
|
+
clearDraft(spec);
|
|
2215
|
+
setError(t("settings.saveNotApplied"));
|
|
2216
|
+
if (spec.sub === void 0) void probeMutationRejection(spec.key, newValue);
|
|
2217
|
+
return false;
|
|
2218
|
+
};
|
|
2219
|
+
const reset = async (spec) => {
|
|
2220
|
+
setError(null);
|
|
2221
|
+
const def = factoryDefaultOf(spec);
|
|
2222
|
+
try {
|
|
2223
|
+
if (def === void 0) {
|
|
2224
|
+
if (spec.sub === void 0) {
|
|
2225
|
+
await scope.unset(spec.key);
|
|
2226
|
+
} else {
|
|
2227
|
+
const user = scope.getSnapshot().user;
|
|
2228
|
+
const parent = { ...user?.[spec.sub] ?? {} };
|
|
2229
|
+
delete parent[spec.key];
|
|
2230
|
+
if (Object.keys(parent).length === 0) await scope.unset(spec.sub);
|
|
2231
|
+
else await scope.set(spec.sub, parent);
|
|
2232
|
+
}
|
|
2233
|
+
} else {
|
|
2234
|
+
const value = JSON.parse(JSON.stringify(def));
|
|
2235
|
+
if (spec.sub === void 0) {
|
|
2236
|
+
await scope.set(spec.key, value);
|
|
2237
|
+
} else {
|
|
2238
|
+
const user = scope.getSnapshot().user;
|
|
2239
|
+
const parent = { ...user?.[spec.sub] ?? {} };
|
|
2240
|
+
parent[spec.key] = value;
|
|
2241
|
+
await scope.set(spec.sub, parent);
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
const landed = () => {
|
|
2245
|
+
const user = scope.getSnapshot().user;
|
|
2246
|
+
if (def === void 0) {
|
|
2247
|
+
const cur = spec.sub === void 0 ? user?.[spec.key] : user?.[spec.sub]?.[spec.key];
|
|
2248
|
+
return cur === void 0;
|
|
2249
|
+
}
|
|
2250
|
+
return jsonEqual(fieldValue(user, spec), def);
|
|
2251
|
+
};
|
|
2252
|
+
if (!landed()) await new Promise((resolve) => window.setTimeout(resolve, 300));
|
|
2253
|
+
if (landed()) {
|
|
2254
|
+
flashSaved();
|
|
2255
|
+
} else {
|
|
2256
|
+
setError(t("settings.resetNotApplied"));
|
|
2257
|
+
}
|
|
2258
|
+
} catch (e) {
|
|
2259
|
+
setError(t("settings.resetFailed", { error: e instanceof Error ? e.message : String(e) }));
|
|
2260
|
+
}
|
|
2261
|
+
};
|
|
2262
|
+
if (snap.status === "loading") {
|
|
2263
|
+
return el("div", { className: "meowmm_set_page" }, el("span", { className: "meowmm_set_muted" }, t("settings.loading")));
|
|
2264
|
+
}
|
|
2265
|
+
if (snap.status === "unavailable") {
|
|
2266
|
+
return el("div", { className: "meowmm_set_page" }, el("span", { className: "meowmm_set_muted" }, t("settings.unavailable")));
|
|
2267
|
+
}
|
|
2268
|
+
const renderField = (spec) => {
|
|
2269
|
+
const raw = fieldValue(snap.value, spec);
|
|
2270
|
+
const def = factoryDefaultOf(spec);
|
|
2271
|
+
const overridden = def === void 0 ? inUserLayer(snap.user, spec) : !jsonEqual(raw, def);
|
|
2272
|
+
const isSuppress = spec.sub === "dream" && spec.key === "suppressWindows";
|
|
2273
|
+
const editingSuppress = isSuppress && suppressText !== null;
|
|
2274
|
+
const mirrorText = typeof raw === "string" ? raw : spec.type === "num" && typeof raw === "number" ? String(raw) : "";
|
|
2275
|
+
const draft = drafts[draftKey(spec)];
|
|
2276
|
+
let control = null;
|
|
2277
|
+
if (spec.type === "homeDir") {
|
|
2278
|
+
const presets = snap.base?.homeDirPresets;
|
|
2279
|
+
const saved = typeof raw === "string" && raw !== "" ? raw : "default";
|
|
2280
|
+
const isCustomSaved = saved !== "default" && saved !== "dsh-storage" && saved !== "plugin-root";
|
|
2281
|
+
const draftText = typeof draft === "string" ? draft : void 0;
|
|
2282
|
+
const radio = (value, labelKey, realPath) => el(
|
|
2283
|
+
"label",
|
|
2284
|
+
{ key: value, className: "meowmm_set_homedir_opt" + (!isCustomSaved && saved === value ? " meowmm_set_homedir_opt_on" : "") },
|
|
2285
|
+
el(
|
|
2286
|
+
"span",
|
|
2287
|
+
{ className: "meowmm_set_homedir_row" },
|
|
2288
|
+
el("input", {
|
|
2289
|
+
type: "radio",
|
|
2290
|
+
name: draftKey(spec),
|
|
2291
|
+
checked: !isCustomSaved && saved === value,
|
|
2292
|
+
disabled: !snap.writable,
|
|
2293
|
+
onChange: () => {
|
|
2294
|
+
void apply2(spec, value);
|
|
2295
|
+
}
|
|
2296
|
+
}),
|
|
2297
|
+
el("span", { className: "meowmm_set_homedir_name" }, t(labelKey))
|
|
2298
|
+
),
|
|
2299
|
+
realPath !== void 0 ? el("span", { className: "meowmm_set_homedir_path" }, realPath) : null
|
|
2300
|
+
);
|
|
2301
|
+
control = el(
|
|
2302
|
+
"div",
|
|
2303
|
+
{ className: "meowmm_set_homedir" },
|
|
2304
|
+
radio("default", "settings.field.homeDir.preset.default", presets?.default),
|
|
2305
|
+
radio("dsh-storage", "settings.field.homeDir.preset.dshStorage", presets?.["dsh-storage"]),
|
|
2306
|
+
radio("plugin-root", "settings.field.homeDir.preset.pluginRoot", presets?.["plugin-root"]),
|
|
2307
|
+
// 自定义行:radio 只反映「已保存的自定义路径」;输入框常驻,blur 保存
|
|
2308
|
+
//(空值不切换)。draft 只影响输入框文本,不碰选中态。
|
|
2309
|
+
el(
|
|
2310
|
+
"div",
|
|
2311
|
+
{ key: "custom", className: "meowmm_set_homedir_opt" + (isCustomSaved ? " meowmm_set_homedir_opt_on" : "") },
|
|
2312
|
+
el(
|
|
2313
|
+
"span",
|
|
2314
|
+
{ className: "meowmm_set_homedir_row" },
|
|
2315
|
+
el("input", {
|
|
2316
|
+
type: "radio",
|
|
2317
|
+
name: draftKey(spec),
|
|
2318
|
+
checked: isCustomSaved,
|
|
2319
|
+
disabled: !snap.writable,
|
|
2320
|
+
onChange: () => {
|
|
2321
|
+
}
|
|
2322
|
+
}),
|
|
2323
|
+
el("span", { className: "meowmm_set_homedir_name" }, t("settings.field.homeDir.preset.custom"))
|
|
2324
|
+
),
|
|
2325
|
+
el("input", {
|
|
2326
|
+
key: "custom-path",
|
|
2327
|
+
className: "meowmm_set_input meowmm_set_homedir_input",
|
|
2328
|
+
type: "text",
|
|
2329
|
+
value: draftText !== void 0 ? draftText : isCustomSaved ? saved : "",
|
|
2330
|
+
placeholder: placeholderOf(spec),
|
|
2331
|
+
disabled: !snap.writable,
|
|
2332
|
+
onClick: (e) => e.stopPropagation(),
|
|
2333
|
+
onChange: (e) => setDrafts((prev) => ({ ...prev, [draftKey(spec)]: e.target.value })),
|
|
2334
|
+
onBlur: (e) => {
|
|
2335
|
+
const next = e.target.value.trim();
|
|
2336
|
+
if (next === saved || next === "") {
|
|
2337
|
+
clearDraft(spec);
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2340
|
+
void apply2(spec, next);
|
|
2341
|
+
}
|
|
2342
|
+
})
|
|
2343
|
+
)
|
|
2344
|
+
);
|
|
2345
|
+
} else if (spec.type === "bool") {
|
|
2346
|
+
const checked = typeof draft === "boolean" ? draft : raw === true;
|
|
2347
|
+
control = el("input", {
|
|
2348
|
+
className: "meowmm_set_check",
|
|
2349
|
+
type: "checkbox",
|
|
2350
|
+
checked,
|
|
2351
|
+
disabled: !snap.writable,
|
|
2352
|
+
onChange: (e) => {
|
|
2353
|
+
const next = e.target.checked;
|
|
2354
|
+
void apply2(spec, next);
|
|
2355
|
+
}
|
|
2356
|
+
});
|
|
2357
|
+
} else if (spec.type === "num") {
|
|
2358
|
+
const text = typeof draft === "string" ? draft : mirrorText;
|
|
2359
|
+
control = el("input", {
|
|
2360
|
+
className: "meowmm_set_input",
|
|
2361
|
+
type: "number",
|
|
2362
|
+
value: text,
|
|
2363
|
+
disabled: !snap.writable,
|
|
2364
|
+
onChange: (e) => setDrafts((prev) => ({ ...prev, [draftKey(spec)]: e.target.value })),
|
|
2365
|
+
onBlur: (e) => {
|
|
2366
|
+
const v = e.target.value;
|
|
2367
|
+
const num = Number(v);
|
|
2368
|
+
if (v.trim() === "" || !Number.isFinite(num) || num === raw) {
|
|
2369
|
+
clearDraft(spec);
|
|
2370
|
+
return;
|
|
2371
|
+
}
|
|
2372
|
+
void apply2(spec, num);
|
|
2373
|
+
}
|
|
2374
|
+
});
|
|
2375
|
+
} else if (isSuppress) {
|
|
2376
|
+
const text = editingSuppress ? suppressText : serializeSuppressWindows(raw);
|
|
2377
|
+
const parsed = parseSuppressWindows(text);
|
|
2378
|
+
control = el("input", {
|
|
2379
|
+
className: "meowmm_set_input meowmm_set_input_time" + (editingSuppress && parsed.error ? " meowmm_set_input_err" : ""),
|
|
2380
|
+
value: text,
|
|
2381
|
+
disabled: !snap.writable,
|
|
2382
|
+
placeholder: "09:00-12:00, 14:00-18:00",
|
|
2383
|
+
onChange: (e) => setSuppressText(e.target.value),
|
|
2384
|
+
onBlur: () => {
|
|
2385
|
+
if (!editingSuppress) return;
|
|
2386
|
+
const res = parseSuppressWindows(suppressText);
|
|
2387
|
+
setSuppressText(null);
|
|
2388
|
+
if (res.error !== void 0 || res.value === void 0) return;
|
|
2389
|
+
void apply2(spec, res.value);
|
|
2390
|
+
}
|
|
2391
|
+
});
|
|
2392
|
+
} else {
|
|
2393
|
+
const text = typeof draft === "string" ? draft : mirrorText;
|
|
2394
|
+
control = el("input", {
|
|
2395
|
+
className: "meowmm_set_input",
|
|
2396
|
+
type: "text",
|
|
2397
|
+
value: text,
|
|
2398
|
+
placeholder: placeholderOf(spec),
|
|
2399
|
+
disabled: !snap.writable,
|
|
2400
|
+
onChange: (e) => setDrafts((prev) => ({ ...prev, [draftKey(spec)]: e.target.value })),
|
|
2401
|
+
onBlur: (e) => {
|
|
2402
|
+
const next = e.target.value;
|
|
2403
|
+
if (next === mirrorText) {
|
|
2404
|
+
clearDraft(spec);
|
|
2405
|
+
return;
|
|
2406
|
+
}
|
|
2407
|
+
void apply2(spec, next);
|
|
2408
|
+
}
|
|
2409
|
+
});
|
|
2410
|
+
}
|
|
2411
|
+
if (spec.type === "homeDir") {
|
|
2412
|
+
return el(
|
|
2413
|
+
"div",
|
|
2414
|
+
{ key: spec.key, className: "meowmm_set_homedir_block" },
|
|
2415
|
+
el(
|
|
2416
|
+
"div",
|
|
2417
|
+
{ className: "meowmm_set_rowtext" },
|
|
2418
|
+
el(
|
|
2419
|
+
"span",
|
|
2420
|
+
{ className: "meowmm_set_label", style: { display: "flex", gap: "8px", alignItems: "center" } },
|
|
2421
|
+
t(spec.label),
|
|
2422
|
+
el("span", { className: `meowmm_set_badge ${overridden ? "meowmm_set_badge_override" : "meowmm_set_badge_prefill"}` }, t(overridden ? "settings.badge.override" : "settings.badge.default")),
|
|
2423
|
+
overridden && snap.writable ? el("button", { className: "meowmm_set_reset", onClick: () => {
|
|
2424
|
+
clearDraft(spec);
|
|
2425
|
+
setSuppressText(null);
|
|
2426
|
+
void reset(spec);
|
|
2427
|
+
} }, t("settings.reset")) : null
|
|
2428
|
+
),
|
|
2429
|
+
spec.hint !== void 0 ? el("span", { className: "meowmm_set_hint" }, t(spec.hint)) : null
|
|
2430
|
+
),
|
|
2431
|
+
control
|
|
2432
|
+
);
|
|
2433
|
+
}
|
|
2434
|
+
return el(
|
|
2435
|
+
"div",
|
|
2436
|
+
{ key: spec.key, className: "meowmm_set_row" },
|
|
2437
|
+
el(
|
|
2438
|
+
"div",
|
|
2439
|
+
{ className: "meowmm_set_rowtext" },
|
|
2440
|
+
el("span", { className: "meowmm_set_label" }, t(spec.label)),
|
|
2441
|
+
spec.hint !== void 0 ? el("span", { className: "meowmm_set_hint" }, t(spec.hint)) : null,
|
|
2442
|
+
editingSuppress && parseSuppressWindows(suppressText).error !== void 0 ? el("span", { className: "meowmm_set_err" }, parseSuppressWindows(suppressText).error) : null
|
|
2443
|
+
),
|
|
2444
|
+
el(
|
|
2445
|
+
"div",
|
|
2446
|
+
{ className: "meowmm_set_ctrl", style: { display: "flex", gap: "8px", alignItems: "center" } },
|
|
2447
|
+
control,
|
|
2448
|
+
el("span", { className: `meowmm_set_badge ${overridden ? "meowmm_set_badge_override" : "meowmm_set_badge_prefill"}` }, t(overridden ? "settings.badge.override" : "settings.badge.default")),
|
|
2449
|
+
overridden && snap.writable ? el("button", { className: "meowmm_set_reset", onClick: () => {
|
|
2450
|
+
clearDraft(spec);
|
|
2451
|
+
setSuppressText(null);
|
|
2452
|
+
void reset(spec);
|
|
2453
|
+
} }, t("settings.reset")) : null
|
|
2454
|
+
)
|
|
2455
|
+
);
|
|
2456
|
+
};
|
|
2457
|
+
return el(
|
|
2458
|
+
"div",
|
|
2459
|
+
{ className: "meowmm_set_page" },
|
|
2460
|
+
el("h2", { className: "meowmm_set_title" }, t("settings.title")),
|
|
2461
|
+
el("p", { className: "meowmm_set_subtitle" }, t("settings.summary")),
|
|
2462
|
+
// 只读镜像横幅(用户实证 2026-09-25):dsh 0.1.7 非 loopback 连接下 configForms
|
|
2463
|
+
// persistence='memory'——所有写入在客户端本地丢弃、根本不达宿主(describe 却仍
|
|
2464
|
+
// 报 writable=true)。以 snap.mode 为准提前亮牌,不再让用户点了才收到误导报错。
|
|
2465
|
+
snap.mode === "memory" ? el("div", { className: "meowmm_set_mirrornote" }, t("settings.mirrorReadonly")) : null,
|
|
2466
|
+
!snap.writable ? el("span", { className: "meowmm_set_muted" }, t("settings.readonly")) : null,
|
|
2467
|
+
savedAt > 0 ? el("span", { className: "meowmm_set_saved" }, t("settings.saved")) : null,
|
|
2468
|
+
error !== null ? el("div", { className: "meowmm_set_err" }, error) : null,
|
|
2469
|
+
...FIELDS.map(
|
|
2470
|
+
(group) => el(
|
|
2471
|
+
"div",
|
|
2472
|
+
{ key: group.title, className: "meowmm_set_card" },
|
|
2473
|
+
el("div", { className: "meowmm_set_group" }, t(group.title)),
|
|
2474
|
+
...group.fields.map(renderField)
|
|
2475
|
+
)
|
|
2476
|
+
)
|
|
2477
|
+
);
|
|
2478
|
+
}
|
|
2479
|
+
function softService(ctx, name) {
|
|
2480
|
+
if (typeof ctx?.get === "function") return ctx.get(name);
|
|
2481
|
+
try {
|
|
2482
|
+
return ctx?.[name];
|
|
2483
|
+
} catch {
|
|
2484
|
+
return void 0;
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
var probeCtx = null;
|
|
2488
|
+
async function probeMutationRejection(field, value) {
|
|
2489
|
+
try {
|
|
2490
|
+
const remote = softService(probeCtx, "remote")?.settings;
|
|
2491
|
+
if (typeof remote?.describe !== "function" || typeof remote?.mutate !== "function") {
|
|
2492
|
+
console.info("[meow-memory] probe: remote.settings unavailable", {
|
|
2493
|
+
hasCtx: probeCtx !== null,
|
|
2494
|
+
hasGet: typeof probeCtx?.get === "function"
|
|
2495
|
+
});
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
const describe = await remote.describe();
|
|
2499
|
+
const view = describe?.ok === true ? describe.value : describe;
|
|
2500
|
+
const ns = view?.namespaces?.find((row) => row?.ns === "meow-memory");
|
|
2501
|
+
console.info("[meow-memory] probe describe:", JSON.stringify({
|
|
2502
|
+
ok: describe?.ok,
|
|
2503
|
+
nsListed: ns !== void 0,
|
|
2504
|
+
all: view?.namespaces?.map((row) => row?.ns),
|
|
2505
|
+
revision: ns?.revision,
|
|
2506
|
+
writable: view?.writable
|
|
2507
|
+
}));
|
|
2508
|
+
if (ns === void 0) return;
|
|
2509
|
+
const response = await remote.mutate("meow-memory", [{ op: "set", path: [field], value }], ns.revision);
|
|
2510
|
+
console.info("[meow-memory] probe mutate envelope:", JSON.stringify(response));
|
|
2511
|
+
const err = response?.error;
|
|
2512
|
+
if (err) {
|
|
2513
|
+
console.info("[meow-memory] probe mutate error fields:", JSON.stringify({
|
|
2514
|
+
code: err.code,
|
|
2515
|
+
message: err.message ?? null,
|
|
2516
|
+
details: err.details ?? null,
|
|
2517
|
+
causeMessage: err.cause instanceof Error ? err.cause.message : err.cause?.message ?? err.cause ?? null
|
|
2518
|
+
}));
|
|
2519
|
+
}
|
|
2520
|
+
if (response?.ok !== true) {
|
|
2521
|
+
const upd = await remote.update("meow-memory", { [field]: value }, ns.revision);
|
|
2522
|
+
console.info("[meow-memory] probe update envelope:", JSON.stringify(upd));
|
|
2523
|
+
const uerr = upd?.error;
|
|
2524
|
+
if (uerr) {
|
|
2525
|
+
console.info("[meow-memory] probe update error fields:", JSON.stringify({
|
|
2526
|
+
code: uerr.code,
|
|
2527
|
+
message: uerr.message ?? null,
|
|
2528
|
+
causeMessage: uerr.cause instanceof Error ? uerr.cause.message : uerr.cause?.message ?? null
|
|
2529
|
+
}));
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
} catch (e) {
|
|
2533
|
+
console.info("[meow-memory] probe threw:", e instanceof Error ? e.message : String(e));
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
function injectSettingsCss() {
|
|
2537
|
+
if (typeof document === "undefined") return;
|
|
2538
|
+
let tag = document.querySelector(`style[data-plugin-css="${CSS_ID2}"]`);
|
|
2539
|
+
if (tag === null) {
|
|
2540
|
+
tag = document.createElement("style");
|
|
2541
|
+
tag.dataset.plugin = "meow-memory-settings";
|
|
2542
|
+
tag.dataset.pluginCss = CSS_ID2;
|
|
2543
|
+
document.head.appendChild(tag);
|
|
2544
|
+
}
|
|
2545
|
+
tag.textContent = CSS2;
|
|
2546
|
+
}
|
|
2547
|
+
function applySettingsPage(ctx, opts) {
|
|
2548
|
+
probeCtx = ctx;
|
|
2549
|
+
const pollMs = opts?.pollMs ?? 400;
|
|
2550
|
+
const maxPollAttempts = opts?.maxPollAttempts ?? 75;
|
|
2551
|
+
const mountWithScope = (scope) => {
|
|
2552
|
+
injectSettingsCss();
|
|
2553
|
+
let disposeEntry = null;
|
|
2554
|
+
let slotReady = false;
|
|
2555
|
+
const registerSection = () => {
|
|
2556
|
+
try {
|
|
2557
|
+
disposeEntry?.();
|
|
2558
|
+
} catch {
|
|
2559
|
+
}
|
|
2560
|
+
disposeEntry = null;
|
|
2561
|
+
try {
|
|
2562
|
+
disposeEntry = ctx.slots.register(
|
|
2563
|
+
{
|
|
2564
|
+
name: "settings.section",
|
|
2565
|
+
id: SETTINGS_NS,
|
|
2566
|
+
order: 35,
|
|
2567
|
+
label: () => t("settings.title"),
|
|
2568
|
+
inject: () => ({ scope })
|
|
2569
|
+
},
|
|
2570
|
+
MemorySettingsSection
|
|
2571
|
+
);
|
|
2572
|
+
} catch (error) {
|
|
2573
|
+
console.info(
|
|
2574
|
+
"[meow-memory] settings.section \u5C1A\u672A\u58F0\u660E\uFF0C\u8DF3\u8FC7\u672C\u6B21\u6CE8\u518C\uFF08\u63D2\u69FD\u5C31\u7EEA\u540E\u7531 inject \u56DE\u8C03\u8865\u6302\uFF09\uFF1A",
|
|
2575
|
+
error instanceof Error ? error.message : String(error)
|
|
2576
|
+
);
|
|
2577
|
+
}
|
|
2578
|
+
};
|
|
2579
|
+
const disposeInjection = ctx.slots.inject("settings.section", () => {
|
|
2580
|
+
slotReady = true;
|
|
2581
|
+
registerSection();
|
|
2582
|
+
});
|
|
2583
|
+
const unsubscribeLocale = onUiLocaleChange(() => {
|
|
2584
|
+
if (!slotReady) return;
|
|
2585
|
+
registerSection();
|
|
2586
|
+
});
|
|
2587
|
+
return () => {
|
|
2588
|
+
unsubscribeLocale();
|
|
2589
|
+
try {
|
|
2590
|
+
disposeInjection();
|
|
2591
|
+
} catch {
|
|
2592
|
+
}
|
|
2593
|
+
try {
|
|
2594
|
+
disposeEntry?.();
|
|
2595
|
+
} catch {
|
|
2596
|
+
}
|
|
2597
|
+
};
|
|
2598
|
+
};
|
|
2599
|
+
const settingsScope = softService(ctx, "settingsScope");
|
|
2600
|
+
const resolveNsFromForms = () => {
|
|
2601
|
+
const forms = softService(ctx, "configForms");
|
|
2602
|
+
if (forms === void 0 || typeof forms.get !== "function") return SETTINGS_NS_CANDIDATES[0];
|
|
2603
|
+
return resolveSettingsNs((key) => {
|
|
2604
|
+
try {
|
|
2605
|
+
return forms.get(key) !== void 0;
|
|
2606
|
+
} catch {
|
|
2607
|
+
return false;
|
|
2608
|
+
}
|
|
2609
|
+
});
|
|
2610
|
+
};
|
|
2611
|
+
if (settingsScope !== void 0) {
|
|
2612
|
+
const boundScope = bindSettingsScope(settingsScope, [resolveNsFromForms(), ...SETTINGS_NS_CANDIDATES]);
|
|
2613
|
+
if (boundScope !== null) return mountWithScope(boundScope);
|
|
2614
|
+
}
|
|
2615
|
+
let mountDisposer = null;
|
|
2616
|
+
let pollTimer2;
|
|
2617
|
+
let attempts = 0;
|
|
2618
|
+
const stopPoll = () => {
|
|
2619
|
+
if (pollTimer2 !== void 0) {
|
|
2620
|
+
clearInterval(pollTimer2);
|
|
2621
|
+
pollTimer2 = void 0;
|
|
2622
|
+
}
|
|
2623
|
+
};
|
|
2624
|
+
const attach = () => {
|
|
2625
|
+
if (mountDisposer !== null) return;
|
|
2626
|
+
const configForms = softService(ctx, "configForms");
|
|
2627
|
+
if (configForms === void 0 || typeof configForms.get !== "function") return;
|
|
2628
|
+
const settingsForm = configForms.get(resolveSettingsNs((key) => {
|
|
2629
|
+
try {
|
|
2630
|
+
return configForms.get(key) !== void 0;
|
|
2631
|
+
} catch {
|
|
2632
|
+
return false;
|
|
2633
|
+
}
|
|
2634
|
+
}));
|
|
2635
|
+
if (settingsForm === void 0 || settingsForm === null) return;
|
|
2636
|
+
mountDisposer = mountWithScope(settingsForm);
|
|
2637
|
+
stopPoll();
|
|
2638
|
+
};
|
|
2639
|
+
attach();
|
|
2640
|
+
if (mountDisposer === null) {
|
|
2641
|
+
pollTimer2 = setInterval(() => {
|
|
2642
|
+
attach();
|
|
2643
|
+
attempts += 1;
|
|
2644
|
+
if (mountDisposer === null && attempts >= maxPollAttempts) {
|
|
2645
|
+
stopPoll();
|
|
2646
|
+
console.info("[meow-memory] configForms \u670D\u52A1\u672A\u5C31\u7EEA\uFF080.1.7 \u8BBE\u7F6E\u9875\u672A\u6CE8\u518C\uFF1B\u63D2\u4EF6\u5176\u4F59\u529F\u80FD\u4E0D\u53D7\u5F71\u54CD\uFF09");
|
|
2647
|
+
}
|
|
2648
|
+
}, pollMs);
|
|
2649
|
+
}
|
|
2650
|
+
return () => {
|
|
2651
|
+
stopPoll();
|
|
2652
|
+
if (mountDisposer !== null) {
|
|
2653
|
+
try {
|
|
2654
|
+
mountDisposer();
|
|
2655
|
+
} catch {
|
|
2656
|
+
}
|
|
2657
|
+
mountDisposer = null;
|
|
2658
|
+
}
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
// src/client.ts
|
|
2663
|
+
var FOLDED_ATTR = "data-meow-memory-folded";
|
|
2664
|
+
var ANCHOR_ATTR2 = "data-meow-memory-anchor";
|
|
2665
|
+
var BODY_ATTR = "data-meow-memory-body";
|
|
2666
|
+
var INJ_ANCHOR_ATTR = "data-meow-injection-anchor";
|
|
2667
|
+
var INJ_BODY_ATTR = "data-meow-injection-body";
|
|
2668
|
+
var INJ_PROMPT_ATTR = "data-meow-injection-prompt";
|
|
2669
|
+
var FOLD_CSS = `[${FOLDED_ATTR}="true"] { display: none !important; }
|
|
2670
|
+
[data-meow-detail-body] {
|
|
2671
|
+
display: none;
|
|
2672
|
+
margin: 2px 0 8px 22px;
|
|
2673
|
+
padding: 8px 10px;
|
|
2674
|
+
font-size: 13px;
|
|
2675
|
+
line-height: 1.7;
|
|
2676
|
+
white-space: pre-wrap;
|
|
2677
|
+
word-break: break-word;
|
|
2678
|
+
color: var(--dsw-alias-label-secondary, rgba(190,190,190,.9));
|
|
2679
|
+
background: rgba(127,127,127,.06);
|
|
2680
|
+
border: 1px solid rgba(127,127,127,.12);
|
|
2681
|
+
border-radius: 8px;
|
|
2682
|
+
font-family: ui-monospace, 'Cascadia Code', Consolas, 'Courier New', monospace;
|
|
2683
|
+
}
|
|
2684
|
+
[data-meow-detail-body="think"] {
|
|
2685
|
+
font-family: inherit;
|
|
2686
|
+
font-style: italic;
|
|
2687
|
+
opacity: .9;
|
|
2688
|
+
}
|
|
2689
|
+
[${INJ_BODY_ATTR}] {
|
|
2690
|
+
display: none;
|
|
2691
|
+
margin: 2px 0 8px;
|
|
2692
|
+
padding: 8px 10px;
|
|
2693
|
+
font-size: 12px;
|
|
2694
|
+
line-height: 1.7;
|
|
2695
|
+
white-space: pre-wrap;
|
|
2696
|
+
word-break: break-word;
|
|
2697
|
+
color: var(--dsw-alias-label-secondary, rgba(190,190,190,.9));
|
|
2698
|
+
background: rgba(127,127,127,.05);
|
|
2699
|
+
border: 1px solid rgba(127,127,127,.12);
|
|
2700
|
+
border-radius: 8px;
|
|
2701
|
+
font-family: ui-monospace, 'Cascadia Code', Consolas, 'Courier New', monospace;
|
|
2702
|
+
}
|
|
2703
|
+
[${INJ_PROMPT_ATTR}] {
|
|
2704
|
+
display: flex;
|
|
2705
|
+
flex-direction: column;
|
|
2706
|
+
align-items: flex-end;
|
|
2707
|
+
gap: 6px;
|
|
2708
|
+
}
|
|
2709
|
+
/* \u7528\u6237 prompt \u6C14\u6CE1\uFF1A\u6837\u5F0F\u5BF9\u9F50 dsh \u672C\u4F53 UserStyleBubble\uFF08MessageItem.module.css
|
|
2710
|
+
* .userStack/.bubble\uFF09\u2014\u2014\u540C token \u540C\u5C3A\u5BF8\uFF0C\u4E3B\u9898\u5207\u6362\u81EA\u52A8\u8DDF\u968F\u3002 */
|
|
2711
|
+
[${INJ_PROMPT_ATTR}] > [data-meow-inj-bubble] {
|
|
2712
|
+
max-width: min(525px, 82%);
|
|
2713
|
+
padding: 10px 16px;
|
|
2714
|
+
border-radius: 22px;
|
|
2715
|
+
background: var(--dsw-specific-bubble);
|
|
2716
|
+
color: var(--dsw-alias-label-primary);
|
|
2717
|
+
font-size: 16px;
|
|
2718
|
+
line-height: 24px;
|
|
2719
|
+
white-space: pre-wrap;
|
|
2720
|
+
word-break: break-word;
|
|
2721
|
+
}
|
|
2722
|
+
[data-meow-inj-actions] {
|
|
2723
|
+
display: flex;
|
|
2724
|
+
align-items: center;
|
|
2725
|
+
gap: 10px;
|
|
2726
|
+
height: 28px;
|
|
2727
|
+
background: transparent;
|
|
2728
|
+
}
|
|
2729
|
+
[data-meow-inj-time] {
|
|
2730
|
+
padding-right: 12px;
|
|
2731
|
+
font-size: 14px;
|
|
2732
|
+
line-height: 24px;
|
|
2733
|
+
color: var(--dsw-alias-label-tertiary);
|
|
2734
|
+
white-space: nowrap;
|
|
2735
|
+
background: transparent;
|
|
2736
|
+
}
|
|
2737
|
+
@media (hover: hover) {
|
|
2738
|
+
[data-meow-inj-time] {
|
|
2739
|
+
opacity: 0;
|
|
2740
|
+
transition: opacity 80ms ease;
|
|
2741
|
+
}
|
|
2742
|
+
[${INJ_PROMPT_ATTR}]:hover [data-meow-inj-time],
|
|
2743
|
+
[${INJ_PROMPT_ATTR}]:focus-within [data-meow-inj-time] {
|
|
2744
|
+
opacity: 1;
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
[data-meow-inj-copy] {
|
|
2748
|
+
display: inline-flex;
|
|
2749
|
+
align-items: center;
|
|
2750
|
+
justify-content: center;
|
|
2751
|
+
width: 28px;
|
|
2752
|
+
height: 28px;
|
|
2753
|
+
padding: 6px;
|
|
2754
|
+
border: none;
|
|
2755
|
+
border-radius: 28px;
|
|
2756
|
+
background: transparent;
|
|
2757
|
+
color: var(--dsw-alias-label-tertiary);
|
|
2758
|
+
cursor: pointer;
|
|
2759
|
+
}
|
|
2760
|
+
[data-meow-inj-copy]:hover {
|
|
2761
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
2762
|
+
color: var(--dsw-alias-label-secondary);
|
|
2763
|
+
}`;
|
|
2764
|
+
var bodySigs = /* @__PURE__ */ new WeakMap();
|
|
2765
|
+
function sigOf(container, keys) {
|
|
2766
|
+
return keys.map((key) => flowRow(container, key)?.textContent ?? "").join("");
|
|
2767
|
+
}
|
|
2768
|
+
function flowRow(container, key) {
|
|
2769
|
+
return flowElements(container, `[data-chat-flow-key="${CSS.escape(key)}"]`).find((row) => row.closest(`[${BODY_ATTR}]`) === null) ?? null;
|
|
2770
|
+
}
|
|
2771
|
+
function anchorOf(container, id) {
|
|
2772
|
+
return flowElements(container, `[${ANCHOR_ATTR2}="${CSS.escape(id)}"]`)[0] ?? null;
|
|
2773
|
+
}
|
|
2774
|
+
function foldAnchorRow(container, group) {
|
|
2775
|
+
const exact = flowRow(container, group.id);
|
|
2776
|
+
if (exact !== null) return exact;
|
|
2777
|
+
for (const key of group.keys) {
|
|
2778
|
+
const row = flowRow(container, key);
|
|
2779
|
+
if (row !== null) return row;
|
|
2780
|
+
}
|
|
2781
|
+
if (typeof group.turn === "number") {
|
|
2782
|
+
const turnRow = flowElements(container, `[data-chat-turn="${group.turn}"]`).find((row) => row.closest(`[${BODY_ATTR}]`) === null) ?? null;
|
|
2783
|
+
if (turnRow !== null) return turnRow;
|
|
2784
|
+
}
|
|
2785
|
+
return null;
|
|
2786
|
+
}
|
|
2787
|
+
function ensureAnchor(container, group, expanded, onToggle) {
|
|
2788
|
+
let anchor = anchorOf(container, group.id);
|
|
2789
|
+
if (anchor === null) {
|
|
2790
|
+
const startRow = foldAnchorRow(container, group);
|
|
2791
|
+
if (startRow === null || startRow.parentElement === null) return;
|
|
2792
|
+
anchor = document.createElement("div");
|
|
2793
|
+
anchor.setAttribute(ANCHOR_ATTR2, group.id);
|
|
2794
|
+
startRow.parentElement.insertBefore(anchor, startRow);
|
|
2795
|
+
}
|
|
2796
|
+
let bar = anchor.querySelector(":scope > button");
|
|
2797
|
+
if (bar === null) {
|
|
2798
|
+
bar = document.createElement("button");
|
|
2799
|
+
bar.type = "button";
|
|
2800
|
+
bar.style.cssText = [
|
|
2801
|
+
"display:block;width:100%;margin:4px 0;padding:5px 12px;",
|
|
2802
|
+
"font-size:12px;line-height:1.6;text-align:left;cursor:pointer;",
|
|
2803
|
+
"color:var(--dsw-alias-label-secondary, rgba(127,127,127,.9));",
|
|
2804
|
+
"background:rgba(127,127,127,.07);border:1px solid rgba(127,127,127,.14);",
|
|
2805
|
+
"border-radius:999px;"
|
|
2806
|
+
].join("");
|
|
2807
|
+
bar.addEventListener("click", () => onToggle(group.id));
|
|
2808
|
+
anchor.appendChild(bar);
|
|
2809
|
+
}
|
|
2810
|
+
const label = foldLabel(group, expanded);
|
|
2811
|
+
if (bar.textContent !== label) bar.textContent = label;
|
|
2812
|
+
const hint = t(expanded ? "inject.collapse" : "inject.expand");
|
|
2813
|
+
if (bar.title !== hint) bar.title = hint;
|
|
2814
|
+
let body = anchor.querySelector(`:scope > [${BODY_ATTR}]`);
|
|
2815
|
+
if (body === null) {
|
|
2816
|
+
body = document.createElement("div");
|
|
2817
|
+
body.setAttribute(BODY_ATTR, "true");
|
|
2818
|
+
body.style.display = "none";
|
|
2819
|
+
body.style.cssText = [
|
|
2820
|
+
"display:none;",
|
|
2821
|
+
"background:rgba(127,127,127,.05);",
|
|
2822
|
+
"border:1px solid rgba(127,127,127,.12);",
|
|
2823
|
+
"border-radius:12px;",
|
|
2824
|
+
"margin:2px 0 6px;",
|
|
2825
|
+
"padding:6px 10px;",
|
|
2826
|
+
"max-height:70vh;",
|
|
2827
|
+
"overflow-y:auto;"
|
|
2828
|
+
].join("");
|
|
2829
|
+
anchor.appendChild(body);
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
function attachDisclosure(rowEl, label, text) {
|
|
2833
|
+
const root = rowEl.parentElement;
|
|
2834
|
+
if (root === null) return;
|
|
2835
|
+
if (root.querySelector(":scope > [data-meow-detail-body]") !== null) return;
|
|
2836
|
+
const body = document.createElement("div");
|
|
2837
|
+
body.setAttribute("data-meow-detail-body", label);
|
|
2838
|
+
body.textContent = text;
|
|
2839
|
+
body.style.display = "none";
|
|
2840
|
+
root.appendChild(body);
|
|
2841
|
+
rowEl.addEventListener("click", () => {
|
|
2842
|
+
const open = root.getAttribute("data-open") === "true";
|
|
2843
|
+
root.setAttribute("data-open", open ? "" : "true");
|
|
2844
|
+
body.style.display = open ? "none" : "block";
|
|
2845
|
+
});
|
|
2846
|
+
}
|
|
2847
|
+
function enhanceClone(clone, node) {
|
|
2848
|
+
if (node === void 0) return;
|
|
2849
|
+
if (node.kind === "assistant-step") {
|
|
2850
|
+
const blocks = node.data.blocks ?? [];
|
|
2851
|
+
const reasoning = blocks.filter((b) => b.kind === "reasoning");
|
|
2852
|
+
const toolCalls = blocks.filter((b) => b.kind === "tool-call");
|
|
2853
|
+
const thinkRows = Array.from(clone.querySelectorAll('[data-variant="think"]'));
|
|
2854
|
+
thinkRows.forEach((root, i) => {
|
|
2855
|
+
const text = reasoning[i]?.text;
|
|
2856
|
+
const rowEl = root.querySelector("[data-disclosure-row]");
|
|
2857
|
+
if (text !== void 0 && rowEl !== null) attachDisclosure(rowEl, "think", text);
|
|
2858
|
+
});
|
|
2859
|
+
const toolRows = Array.from(clone.querySelectorAll("[data-disclosure-row]")).filter((el2) => el2.closest('[data-variant="think"]') === null);
|
|
2860
|
+
toolRows.forEach((rowEl, i) => {
|
|
2861
|
+
const block = toolCalls[i];
|
|
2862
|
+
if (block !== void 0) attachDisclosure(rowEl, "tool", toolCallDetail(block));
|
|
2863
|
+
});
|
|
2864
|
+
} else if (node.kind === "tool-call") {
|
|
2865
|
+
const root = node.data.root;
|
|
2866
|
+
if (root === void 0) return;
|
|
2867
|
+
const rowEl = clone.querySelector("[data-disclosure-row]");
|
|
2868
|
+
if (rowEl === null) return;
|
|
2869
|
+
const name = "name" in root ? root.name : root.call?.name ?? root.callId;
|
|
2870
|
+
const detail = toolCallDetail({ name, root });
|
|
2871
|
+
const resultText = "content" in root ? blocksToText(root.content) : "";
|
|
2872
|
+
attachDisclosure(rowEl, "tool", resultText.length > 0 ? `${detail}
|
|
2873
|
+
|
|
2874
|
+
${t("inject.result")}
|
|
2875
|
+
${resultText}` : detail);
|
|
2876
|
+
} else if (node.kind === "context") {
|
|
2877
|
+
const content = node.data.content;
|
|
2878
|
+
const text = blocksToText(content ?? []);
|
|
2879
|
+
const rowEl = clone.querySelector("[data-disclosure-row]");
|
|
2880
|
+
if (rowEl !== null && text.length > 0) attachDisclosure(rowEl, "context", text);
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
function fillBody(container, id, visible, keys, session) {
|
|
2884
|
+
const anchor = anchorOf(container, id);
|
|
2885
|
+
if (anchor === null) return;
|
|
2886
|
+
const body = anchor.querySelector(`:scope > [${BODY_ATTR}]`);
|
|
2887
|
+
if (body === null) return;
|
|
2888
|
+
body.replaceChildren();
|
|
2889
|
+
if (!visible) {
|
|
2890
|
+
body.style.display = "none";
|
|
2891
|
+
bodySigs.delete(body);
|
|
2892
|
+
return;
|
|
2893
|
+
}
|
|
2894
|
+
body.style.display = "block";
|
|
2895
|
+
for (const key of keys) {
|
|
2896
|
+
const row = flowRow(container, key);
|
|
2897
|
+
if (row === null) continue;
|
|
2898
|
+
const clone = row.cloneNode(true);
|
|
2899
|
+
clone.removeAttribute(FOLDED_ATTR);
|
|
2900
|
+
clone.removeAttribute("data-chat-flow-key");
|
|
2901
|
+
clone.removeAttribute("data-chat-anchor-key");
|
|
2902
|
+
clone.removeAttribute("data-chat-flow-kind");
|
|
2903
|
+
for (const el2 of Array.from(clone.querySelectorAll("[data-chat-call-id]"))) {
|
|
2904
|
+
const host = el2.parentElement;
|
|
2905
|
+
if (host !== null && host !== clone) host.remove();
|
|
2906
|
+
else el2.remove();
|
|
2907
|
+
}
|
|
2908
|
+
for (const child of Array.from(clone.children)) {
|
|
2909
|
+
if (child.textContent?.trim() === "" && child.querySelector("[data-disclosure-row], [data-chat-call-id]") === null) {
|
|
2910
|
+
child.remove();
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
body.appendChild(clone);
|
|
2914
|
+
try {
|
|
2915
|
+
enhanceClone(clone, session.chat?.nodes.get(key));
|
|
2916
|
+
} catch {
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
if (body.childElementCount === 0) {
|
|
2920
|
+
const hint = document.createElement("div");
|
|
2921
|
+
hint.setAttribute("data-meow-memory-unloaded", "true");
|
|
2922
|
+
hint.textContent = t("fold.body.unloaded");
|
|
2923
|
+
hint.style.color = "var(--dsw-alias-label-secondary, inherit)";
|
|
2924
|
+
hint.style.fontSize = "12px";
|
|
2925
|
+
body.appendChild(hint);
|
|
2926
|
+
}
|
|
2927
|
+
segmentDreamGroups(body);
|
|
2928
|
+
bodySigs.set(body, sigOf(container, keys));
|
|
2929
|
+
}
|
|
2930
|
+
var GROUP_MARKER_RE = /\[meow-dream-group\s+(\d+)\/(\d+)[\s·]*([^\]]*)\]/;
|
|
2931
|
+
function stripGroupMarker(el2) {
|
|
2932
|
+
const walker = document.createTreeWalker(el2, window.NodeFilter.SHOW_TEXT);
|
|
2933
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {
|
|
2934
|
+
const data = node.nodeValue ?? "";
|
|
2935
|
+
if (GROUP_MARKER_RE.test(data)) {
|
|
2936
|
+
node.nodeValue = data.replace(GROUP_MARKER_RE, "").replace(/^\s+/, "");
|
|
2937
|
+
return;
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
function segmentDreamGroups(body) {
|
|
2942
|
+
const children = Array.from(body.children);
|
|
2943
|
+
const first = children.findIndex((c) => GROUP_MARKER_RE.test(c.textContent ?? ""));
|
|
2944
|
+
if (first === -1) return;
|
|
2945
|
+
const heading = (n, total, label) => {
|
|
2946
|
+
const h = document.createElement("div");
|
|
2947
|
+
h.setAttribute("data-meow-dream-section", `${n}/${total}`);
|
|
2948
|
+
h.textContent = `${n}/${total} \xB7 ${label}`;
|
|
2949
|
+
h.style.color = "var(--dsw-alias-label-secondary, inherit)";
|
|
2950
|
+
h.style.fontSize = "12px";
|
|
2951
|
+
h.style.fontWeight = "600";
|
|
2952
|
+
h.style.margin = "10px 0 4px";
|
|
2953
|
+
h.style.paddingTop = "8px";
|
|
2954
|
+
h.style.borderTop = "1px solid var(--dsw-alias-border-secondary, rgba(127,127,127,.25))";
|
|
2955
|
+
return h;
|
|
2956
|
+
};
|
|
2957
|
+
const rebuild = document.createDocumentFragment();
|
|
2958
|
+
for (const child of children.slice(0, first)) rebuild.appendChild(child);
|
|
2959
|
+
let current = null;
|
|
2960
|
+
for (const child of children.slice(first)) {
|
|
2961
|
+
const m = (child.textContent ?? "").match(GROUP_MARKER_RE);
|
|
2962
|
+
if (m !== null) {
|
|
2963
|
+
current = heading(m[1], m[2], m[3]);
|
|
2964
|
+
rebuild.appendChild(current);
|
|
2965
|
+
stripGroupMarker(child);
|
|
2966
|
+
}
|
|
2967
|
+
rebuild.appendChild(child);
|
|
2968
|
+
}
|
|
2969
|
+
body.replaceChildren(rebuild);
|
|
2970
|
+
}
|
|
2971
|
+
var COPY_ICON_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.14929 4.02032C7.11197 4.02032 7.87983 4.02016 8.49597 4.07598C9.12128 4.13269 9.65792 4.25188 10.1415 4.53106C10.7202 4.8653 11.2008 5.3459 11.535 5.92462C11.8142 6.40818 11.9334 6.94481 11.9901 7.57012C12.0459 8.18625 12.0458 8.95419 12.0458 9.9168C12.0458 10.8795 12.0459 11.6473 11.9901 12.2635C11.9334 12.8888 11.8142 13.4254 11.535 13.909C11.2008 14.4877 10.7202 14.9683 10.1415 15.3025C9.65792 15.5817 9.12128 15.7009 8.49597 15.7576C7.87984 15.8134 7.11196 15.8133 6.14929 15.8133C5.18667 15.8133 4.41874 15.8134 3.80261 15.7576C3.1773 15.7009 2.64067 15.5817 2.1571 15.3025C1.5784 14.9683 1.09778 14.4877 0.76355 13.909C0.484366 13.4254 0.365184 12.8888 0.308472 12.2635C0.252649 11.6473 0.252808 10.8795 0.252808 9.9168C0.252808 8.95418 0.252664 8.18625 0.308472 7.57012C0.365184 6.94481 0.484366 6.40818 0.76355 5.92462C1.09777 5.34589 1.57839 4.86529 2.1571 4.53106C2.64067 4.25188 3.1773 4.13269 3.80261 4.07598C4.41874 4.02017 5.18666 4.02032 6.14929 4.02032ZM6.14929 5.37774C5.16181 5.37774 4.46634 5.37761 3.92566 5.42657C3.39434 5.47472 3.07859 5.56574 2.83582 5.70587C2.4632 5.92106 2.15354 6.2307 1.93835 6.60333C1.79823 6.8461 1.70721 7.16185 1.65906 7.69317C1.6101 8.23385 1.61023 8.92933 1.61023 9.9168C1.61023 10.9043 1.61009 11.5998 1.65906 12.1404C1.70721 12.6717 1.79823 12.9875 1.93835 13.2303C2.15356 13.6029 2.46321 13.9126 2.83582 14.1277C3.07859 14.2679 3.39434 14.3589 3.92566 14.407C4.46634 14.456 5.16182 14.4559 6.14929 14.4559C7.13682 14.4559 7.83224 14.456 8.37292 14.407C8.90425 14.3589 9.21999 14.2679 9.46277 14.1277C9.83535 13.9126 10.145 13.6029 10.3602 13.2303C10.5004 12.9875 10.5914 12.6717 10.6395 12.1404C10.6885 11.5998 10.6884 10.9043 10.6884 9.9168C10.6884 8.92934 10.6885 8.23384 10.6395 7.69317C10.5914 7.16185 10.5004 6.8461 10.3602 6.60333C10.1451 6.23071 9.83536 5.92107 9.46277 5.70587C9.21999 5.56574 8.90424 5.47472 8.37292 5.42657C7.83224 5.3776 7.13682 5.37774 6.14929 5.37774ZM9.80164 0.367975C10.7638 0.367975 11.5314 0.36788 12.1473 0.423639C12.7726 0.480307 13.3093 0.598759 13.7928 0.877741C14.3717 1.21192 14.8521 1.69355 15.1864 2.27227C15.4655 2.75574 15.5857 3.29164 15.6425 3.9168C15.6983 4.53301 15.6971 5.3016 15.6971 6.26446V7.82989C15.6971 8.29264 15.6989 8.58993 15.6649 8.84844C15.4668 10.3525 14.401 11.5738 12.9833 11.9988V10.5467C13.6973 10.1903 14.2105 9.49662 14.3192 8.67169C14.3387 8.52347 14.3407 8.3358 14.3407 7.82989V6.26446C14.3407 5.27706 14.3398 4.58149 14.2909 4.04083C14.2428 3.50968 14.1526 3.19372 14.0126 2.95098C13.7974 2.57849 13.4876 2.26869 13.1151 2.05352C12.8724 1.91347 12.5564 1.82237 12.0253 1.77423C11.4847 1.72528 10.7888 1.7254 9.80164 1.7254H7.71472C6.7562 1.72558 5.92665 2.27697 5.52332 3.07891H4.07019C4.54221 1.51132 5.9932 0.368186 7.71472 0.367975H9.80164Z" fill="currentColor"/></svg>';
|
|
2972
|
+
var CHECK_ICON_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.0498 3.92579L8.49512 12.3818C8.25774 12.6881 8.04517 12.9645 7.84668 13.1689C7.63957 13.3823 7.38732 13.5841 7.04492 13.6719C6.86373 13.7183 6.6757 13.7346 6.48926 13.7197C6.13666 13.6915 5.8528 13.5355 5.6123 13.3604C5.38201 13.1926 5.12573 12.9567 4.83984 12.6953L1.03125 9.21289L1.96875 8.1875L5.77734 11.6699C6.08684 11.9529 6.27773 12.1249 6.43066 12.2363C6.50183 12.2882 6.54699 12.3135 6.57324 12.3252C6.58525 12.3305 6.59269 12.3322 6.5957 12.333C6.59802 12.3336 6.59961 12.334 6.59961 12.334C6.63317 12.3367 6.66758 12.3335 6.7002 12.3252C6.7002 12.3252 6.70211 12.3251 6.7041 12.3242C6.70698 12.3229 6.71348 12.319 6.72461 12.3115C6.74849 12.2956 6.78843 12.2642 6.84961 12.2012C6.98138 12.0654 7.13957 11.8628 7.39648 11.5313L13.9502 3.07422L15.0498 3.92579Z" fill="currentColor"/></svg>';
|
|
2973
|
+
async function copyInjectionText(button, text) {
|
|
2974
|
+
let ok = false;
|
|
2975
|
+
try {
|
|
2976
|
+
await navigator.clipboard.writeText(text);
|
|
2977
|
+
ok = true;
|
|
2978
|
+
} catch {
|
|
2979
|
+
const textarea = document.createElement("textarea");
|
|
2980
|
+
textarea.value = text;
|
|
2981
|
+
textarea.style.position = "fixed";
|
|
2982
|
+
textarea.style.opacity = "0";
|
|
2983
|
+
document.body.appendChild(textarea);
|
|
2984
|
+
textarea.select();
|
|
2985
|
+
try {
|
|
2986
|
+
ok = document.execCommand("copy");
|
|
2987
|
+
} catch {
|
|
2988
|
+
ok = false;
|
|
2989
|
+
}
|
|
2990
|
+
textarea.remove();
|
|
2991
|
+
}
|
|
2992
|
+
if (!ok || button.dataset.meowInjState === "copied") return;
|
|
2993
|
+
button.dataset.meowInjState = "copied";
|
|
2994
|
+
button.title = t("inject.copied");
|
|
2995
|
+
button.innerHTML = CHECK_ICON_SVG;
|
|
2996
|
+
window.setTimeout(() => {
|
|
2997
|
+
button.dataset.meowInjState = "copy";
|
|
2998
|
+
button.title = t("inject.copy");
|
|
2999
|
+
button.innerHTML = COPY_ICON_SVG;
|
|
3000
|
+
}, 1e3);
|
|
3001
|
+
}
|
|
3002
|
+
function injectionRow(container, group) {
|
|
3003
|
+
const exact = flowRow(container, group.id);
|
|
3004
|
+
if (exact !== null) return { row: exact, exact: true };
|
|
3005
|
+
if (typeof group.turn === "number") {
|
|
3006
|
+
const turnRow = flowElements(container, `[data-chat-turn="${group.turn}"]`).find((row) => row.closest(`[${BODY_ATTR}]`) === null) ?? null;
|
|
3007
|
+
if (turnRow !== null) return { row: turnRow, exact: false };
|
|
3008
|
+
}
|
|
3009
|
+
return null;
|
|
3010
|
+
}
|
|
3011
|
+
function applyInjectionFold(containers, groups, expanded, onToggle) {
|
|
3012
|
+
if (containers.length === 0) return;
|
|
3013
|
+
const liveIds = new Set(groups.map((g) => g.id));
|
|
3014
|
+
for (const container of containers) {
|
|
3015
|
+
for (const stale of flowElements(container, `[${INJ_ANCHOR_ATTR}]`)) {
|
|
3016
|
+
if (!liveIds.has(stale.getAttribute(INJ_ANCHOR_ATTR) ?? "")) stale.remove();
|
|
3017
|
+
}
|
|
3018
|
+
for (const group of groups) {
|
|
3019
|
+
const start = injectionRow(container, group);
|
|
3020
|
+
if (start === null || start.row.parentElement === null) continue;
|
|
3021
|
+
if (start.exact) start.row.setAttribute(FOLDED_ATTR, "true");
|
|
3022
|
+
const anchorSlot = start.row;
|
|
3023
|
+
let anchor = flowElements(container, `[${INJ_ANCHOR_ATTR}="${CSS.escape(group.id)}"]`)[0] ?? null;
|
|
3024
|
+
if (anchor === null) {
|
|
3025
|
+
anchor = document.createElement("div");
|
|
3026
|
+
anchor.setAttribute(INJ_ANCHOR_ATTR, group.id);
|
|
3027
|
+
anchorSlot.parentElement.insertBefore(anchor, anchorSlot);
|
|
3028
|
+
}
|
|
3029
|
+
let bar = anchor.querySelector(":scope > button");
|
|
3030
|
+
if (bar === null) {
|
|
3031
|
+
bar = document.createElement("button");
|
|
3032
|
+
bar.type = "button";
|
|
3033
|
+
bar.style.cssText = [
|
|
3034
|
+
"display:block;margin:4px 0 4px auto;max-width:82%;padding:5px 12px;",
|
|
3035
|
+
"font-size:12px;line-height:1.6;text-align:left;cursor:pointer;",
|
|
3036
|
+
"color:var(--dsw-alias-label-secondary, rgba(127,127,127,.9));",
|
|
3037
|
+
"background:rgba(127,127,127,.07);border:1px solid rgba(127,127,127,.14);",
|
|
3038
|
+
"border-radius:999px;"
|
|
3039
|
+
].join("");
|
|
3040
|
+
bar.addEventListener("click", () => onToggle(group.id));
|
|
3041
|
+
anchor.appendChild(bar);
|
|
3042
|
+
}
|
|
3043
|
+
const kindLabel = t(group.kind === "first" ? "inject.kind.first" : "inject.kind.hit");
|
|
3044
|
+
const label = `${expanded.has(group.id) ? "\u25BE" : "\u25B8"} ${t("inject.bar")}${kindLabel}`;
|
|
3045
|
+
if (bar.textContent !== label) bar.textContent = label;
|
|
3046
|
+
let body = anchor.querySelector(`:scope > [${INJ_BODY_ATTR}]`);
|
|
3047
|
+
if (body === null) {
|
|
3048
|
+
body = document.createElement("div");
|
|
3049
|
+
body.setAttribute(INJ_BODY_ATTR, "true");
|
|
3050
|
+
anchor.appendChild(body);
|
|
3051
|
+
}
|
|
3052
|
+
if (expanded.has(group.id)) {
|
|
3053
|
+
if (body.textContent !== group.injectedText) body.textContent = group.injectedText;
|
|
3054
|
+
body.style.display = "block";
|
|
3055
|
+
} else {
|
|
3056
|
+
body.style.display = "none";
|
|
3057
|
+
}
|
|
3058
|
+
let prompt = anchor.querySelector(`:scope > [${INJ_PROMPT_ATTR}]`);
|
|
3059
|
+
if (group.userText === void 0) {
|
|
3060
|
+
prompt?.remove();
|
|
3061
|
+
continue;
|
|
3062
|
+
}
|
|
3063
|
+
if (prompt === null) {
|
|
3064
|
+
prompt = document.createElement("div");
|
|
3065
|
+
prompt.setAttribute(INJ_PROMPT_ATTR, "true");
|
|
3066
|
+
const bubble2 = document.createElement("div");
|
|
3067
|
+
bubble2.dataset.meowInjBubble = "true";
|
|
3068
|
+
prompt.appendChild(bubble2);
|
|
3069
|
+
const actions = document.createElement("div");
|
|
3070
|
+
actions.dataset.meowInjActions = "true";
|
|
3071
|
+
const timeLabel2 = document.createElement("span");
|
|
3072
|
+
timeLabel2.dataset.meowInjTime = "true";
|
|
3073
|
+
actions.appendChild(timeLabel2);
|
|
3074
|
+
const copyButton = document.createElement("button");
|
|
3075
|
+
copyButton.type = "button";
|
|
3076
|
+
copyButton.dataset.meowInjCopy = "true";
|
|
3077
|
+
copyButton.title = t("inject.copy");
|
|
3078
|
+
copyButton.setAttribute("aria-label", t("inject.copy"));
|
|
3079
|
+
copyButton.innerHTML = COPY_ICON_SVG;
|
|
3080
|
+
copyButton.addEventListener("click", () => {
|
|
3081
|
+
if (group.userText !== void 0) {
|
|
3082
|
+
void copyInjectionText(copyButton, group.userText);
|
|
3083
|
+
}
|
|
3084
|
+
});
|
|
3085
|
+
actions.appendChild(copyButton);
|
|
3086
|
+
prompt.appendChild(actions);
|
|
3087
|
+
anchor.appendChild(prompt);
|
|
3088
|
+
}
|
|
3089
|
+
const bubble = prompt.querySelector(":scope > [data-meow-inj-bubble]");
|
|
3090
|
+
if (bubble !== null && bubble.textContent !== group.userText) bubble.textContent = group.userText;
|
|
3091
|
+
const timeLabel = prompt.querySelector(":scope > [data-meow-inj-actions] > [data-meow-inj-time]");
|
|
3092
|
+
if (timeLabel !== null) {
|
|
3093
|
+
const label2 = group.time === void 0 ? "" : formatInjectionClock(group.time);
|
|
3094
|
+
if (timeLabel.textContent !== label2) timeLabel.textContent = label2;
|
|
3095
|
+
if (label2 === "") timeLabel.style.display = "none";
|
|
3096
|
+
else if (timeLabel.style.display !== "") timeLabel.style.display = "";
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
function applyFoldState(containers, groups, expanded, onToggle, session) {
|
|
3102
|
+
if (containers.length === 0) return;
|
|
3103
|
+
const liveIds = new Set(groups.map((group) => group.id));
|
|
3104
|
+
for (const container of containers) {
|
|
3105
|
+
for (const stale of flowElements(container, `[${ANCHOR_ATTR2}]`)) {
|
|
3106
|
+
if (!liveIds.has(stale.getAttribute(ANCHOR_ATTR2) ?? "")) stale.remove();
|
|
3107
|
+
}
|
|
3108
|
+
for (const group of groups) {
|
|
3109
|
+
for (const key of group.keys) {
|
|
3110
|
+
const row = flowRow(container, key);
|
|
3111
|
+
if (row === null) continue;
|
|
3112
|
+
row.setAttribute(FOLDED_ATTR, "true");
|
|
3113
|
+
}
|
|
3114
|
+
ensureAnchor(container, group, expanded.has(group.id), onToggle);
|
|
3115
|
+
if (expanded.has(group.id)) {
|
|
3116
|
+
const sig = sigOf(container, group.keys);
|
|
3117
|
+
const body = anchorOf(container, group.id)?.querySelector(`:scope > [${BODY_ATTR}]`);
|
|
3118
|
+
if (body && bodySigs.get(body) !== sig) fillBody(container, group.id, true, group.keys, session);
|
|
3119
|
+
} else {
|
|
3120
|
+
const body = anchorOf(container, group.id)?.querySelector(`:scope > [${BODY_ATTR}]`);
|
|
3121
|
+
if (body && body.style.display !== "none") fillBody(container, group.id, false, [], session);
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
var TURN_NAV_FRAME_VAR = "--turn-rail-inset";
|
|
3127
|
+
function applyTurnNavHiding(root, memoryTurns) {
|
|
3128
|
+
for (const nav of root.querySelectorAll("nav[style]")) {
|
|
3129
|
+
if (nav.closest("[data-conversation-scroll]") !== root) continue;
|
|
3130
|
+
if (nav.style.getPropertyValue(TURN_NAV_FRAME_VAR) === "") continue;
|
|
3131
|
+
for (const btn of nav.querySelectorAll("button[aria-label]")) {
|
|
3132
|
+
const nums = (btn.getAttribute("aria-label") ?? "").match(/\d+/g);
|
|
3133
|
+
if (nums === null) continue;
|
|
3134
|
+
const turn = Number(nums[nums.length - 1]);
|
|
3135
|
+
const slot = btn.parentElement;
|
|
3136
|
+
if (slot === null) continue;
|
|
3137
|
+
if (Number.isInteger(turn) && memoryTurns.has(turn)) {
|
|
3138
|
+
if (!slot.hasAttribute("data-meow-memory-nav-display")) {
|
|
3139
|
+
slot.setAttribute("data-meow-memory-nav-display", slot.style.display);
|
|
3140
|
+
}
|
|
3141
|
+
slot.style.display = "none";
|
|
3142
|
+
} else if (slot.hasAttribute("data-meow-memory-nav-display")) {
|
|
3143
|
+
slot.style.display = slot.getAttribute("data-meow-memory-nav-display") ?? "";
|
|
3144
|
+
slot.removeAttribute("data-meow-memory-nav-display");
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
function mountMemoryFoldView(root, read) {
|
|
3150
|
+
const toggle = (id) => read().toggle(id);
|
|
3151
|
+
const toggleInj = (id) => read().toggleInj(id);
|
|
3152
|
+
let disposed = false;
|
|
3153
|
+
const apply2 = () => {
|
|
3154
|
+
if (disposed) return;
|
|
3155
|
+
const state = read();
|
|
3156
|
+
const before = root.scrollHeight;
|
|
3157
|
+
const nearBottom = before - root.clientHeight - root.scrollTop <= 160;
|
|
3158
|
+
const containers = chatFlows(root);
|
|
3159
|
+
const hiddenKeys = /* @__PURE__ */ new Set([...state.groups.flatMap((g) => g.keys), ...state.injGroups.map((g) => g.id)]);
|
|
3160
|
+
for (const container of containers) {
|
|
3161
|
+
for (const row of flowElements(container, `[${FOLDED_ATTR}]`)) {
|
|
3162
|
+
if (!hiddenKeys.has(row.getAttribute("data-chat-flow-key") ?? "")) row.removeAttribute(FOLDED_ATTR);
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
applyFoldState(containers, state.groups, state.expanded, toggle, state.snapshot);
|
|
3166
|
+
applyInjectionFold(containers, state.injGroups, state.injExpanded, toggleInj);
|
|
3167
|
+
applyDelegateNotices(containers, computeDelegateNotices(state.snapshot));
|
|
3168
|
+
applyTurnNavHiding(root, state.memTurns);
|
|
3169
|
+
const after = root.scrollHeight;
|
|
3170
|
+
if (after < before && nearBottom) root.scrollTop = root.scrollHeight;
|
|
3171
|
+
};
|
|
3172
|
+
let timer = 0;
|
|
3173
|
+
const observer = new MutationObserver(() => {
|
|
3174
|
+
window.clearTimeout(timer);
|
|
3175
|
+
timer = window.setTimeout(apply2, 80);
|
|
3176
|
+
});
|
|
3177
|
+
observer.observe(root, { childList: true, subtree: true, characterData: true });
|
|
3178
|
+
const offLocale = onUiLocaleChange(apply2);
|
|
3179
|
+
const offState = onDelegateStateChange(apply2);
|
|
3180
|
+
apply2();
|
|
3181
|
+
return {
|
|
3182
|
+
apply: apply2,
|
|
3183
|
+
dispose: () => {
|
|
3184
|
+
disposed = true;
|
|
3185
|
+
window.clearTimeout(timer);
|
|
3186
|
+
observer.disconnect();
|
|
3187
|
+
offLocale();
|
|
3188
|
+
offState();
|
|
3189
|
+
for (const container of chatFlows(root)) {
|
|
3190
|
+
for (const anchor of flowElements(container, `[${ANCHOR_ATTR2}], [${INJ_ANCHOR_ATTR}]`)) anchor.remove();
|
|
3191
|
+
for (const row of flowElements(container, `[${FOLDED_ATTR}]`)) row.removeAttribute(FOLDED_ATTR);
|
|
3192
|
+
}
|
|
3193
|
+
applyDelegateNotices(chatFlows(root), []);
|
|
3194
|
+
applyTurnNavHiding(root, /* @__PURE__ */ new Set());
|
|
3195
|
+
}
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
var chatIdentity = (chat) => chat;
|
|
3199
|
+
function MemoryFoldDock(props) {
|
|
3200
|
+
const sentinelRef = (0, import_react.useRef)(null);
|
|
3201
|
+
const viewRef = (0, import_react.useRef)(null);
|
|
3202
|
+
const useChat = props?.useChat;
|
|
3203
|
+
const chatViaHook = typeof useChat === "function" ? useChat(chatIdentity) : void 0;
|
|
3204
|
+
const legacySession = props?.session;
|
|
3205
|
+
const snapshot = chatViaHook !== void 0 ? { chat: chatViaHook } : legacySession !== null && typeof legacySession === "object" && legacySession.chat !== void 0 ? legacySession : void 0;
|
|
3206
|
+
const [expanded, setExpanded] = (0, import_react.useState)(() => /* @__PURE__ */ new Set());
|
|
3207
|
+
const [injExpanded, setInjExpanded] = (0, import_react.useState)(() => /* @__PURE__ */ new Set());
|
|
3208
|
+
const groups = (0, import_react.useMemo)(() => computeFoldGroups(snapshot), [snapshot]);
|
|
3209
|
+
const injGroups = (0, import_react.useMemo)(() => computeInjectionGroups(snapshot), [snapshot]);
|
|
3210
|
+
const memTurns = (0, import_react.useMemo)(() => memoryTurnNumbers(snapshot), [snapshot]);
|
|
3211
|
+
const toggle = (0, import_react.useCallback)((id) => {
|
|
3212
|
+
setExpanded((prev) => {
|
|
3213
|
+
const next = new Set(prev);
|
|
3214
|
+
const willExpand = !next.has(id);
|
|
3215
|
+
if (willExpand) next.add(id);
|
|
3216
|
+
else next.delete(id);
|
|
3217
|
+
return next;
|
|
3218
|
+
});
|
|
3219
|
+
}, []);
|
|
3220
|
+
const toggleInj = (0, import_react.useCallback)((id) => {
|
|
3221
|
+
setInjExpanded((prev) => {
|
|
3222
|
+
const next = new Set(prev);
|
|
3223
|
+
if (next.has(id)) next.delete(id);
|
|
3224
|
+
else next.add(id);
|
|
3225
|
+
return next;
|
|
3226
|
+
});
|
|
3227
|
+
}, []);
|
|
3228
|
+
const state = { groups, expanded, toggle, snapshot, injGroups, injExpanded, toggleInj, memTurns };
|
|
3229
|
+
const latest = (0, import_react.useRef)(state);
|
|
3230
|
+
latest.current = state;
|
|
3231
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
3232
|
+
const root = sentinelRef.current?.closest("[data-conversation-scroll]");
|
|
3233
|
+
if (!root) return;
|
|
3234
|
+
const view = mountMemoryFoldView(root, () => latest.current);
|
|
3235
|
+
viewRef.current = view;
|
|
3236
|
+
return () => {
|
|
3237
|
+
viewRef.current = null;
|
|
3238
|
+
view.dispose();
|
|
3239
|
+
};
|
|
3240
|
+
}, []);
|
|
3241
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
3242
|
+
viewRef.current?.apply();
|
|
3243
|
+
});
|
|
3244
|
+
return (0, import_react.createElement)("span", { ref: sentinelRef, "data-meow-memory-dock": "", style: { display: "none" } });
|
|
3245
|
+
}
|
|
3246
|
+
function makeDelegateVanishDock(refreshSubagents) {
|
|
3247
|
+
return function DelegateVanishDock({ useSessions }) {
|
|
3248
|
+
const current = useSessions?.((state) => state?.current);
|
|
3249
|
+
const byId = useSessions?.((state) => state?.byId);
|
|
3250
|
+
const catalogs = useSessions?.((state) => state?.subagentsByParent);
|
|
3251
|
+
const sentinelRef = (0, import_react.useRef)(null);
|
|
3252
|
+
const decision = (0, import_react.useMemo)(
|
|
3253
|
+
() => computeVanishDecision({ current, byId, subagentsByParent: catalogs }),
|
|
3254
|
+
[current, byId, catalogs]
|
|
3255
|
+
);
|
|
3256
|
+
const latest = (0, import_react.useRef)({ decision });
|
|
3257
|
+
latest.current = { decision };
|
|
3258
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
3259
|
+
applyVanishDom(decision, sentinelRef.current);
|
|
3260
|
+
}, [decision]);
|
|
3261
|
+
(0, import_react.useEffect)(() => {
|
|
3262
|
+
if (current !== void 0 && typeof refreshSubagents === "function") {
|
|
3263
|
+
try {
|
|
3264
|
+
refreshSubagents(current);
|
|
3265
|
+
} catch {
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
return startVanishObserver(() => ({ decision: latest.current.decision, sentinel: sentinelRef.current }));
|
|
3269
|
+
}, [current]);
|
|
3270
|
+
return (0, import_react.createElement)("span", {
|
|
3271
|
+
[SENTINEL_ATTR]: "1",
|
|
3272
|
+
style: { display: "none" },
|
|
3273
|
+
ref: sentinelRef
|
|
3274
|
+
});
|
|
3275
|
+
};
|
|
3276
|
+
}
|
|
3277
|
+
var inject = ["slots", "sessions", "remote.settings"];
|
|
3278
|
+
function apply(ctx) {
|
|
3279
|
+
const disposers = [];
|
|
3280
|
+
try {
|
|
3281
|
+
installI18n(ctx);
|
|
3282
|
+
} catch (e) {
|
|
3283
|
+
console.warn("[meow-memory] \u6587\u6848\u5C42\u521D\u59CB\u5316\u5931\u8D25\uFF08UI \u9000\u56DE\u9ED8\u8BA4\u8BED\u8A00\uFF09\uFF1A", e);
|
|
3284
|
+
}
|
|
3285
|
+
const safePush = (name, start) => {
|
|
3286
|
+
try {
|
|
3287
|
+
disposers.push(start());
|
|
3288
|
+
} catch (e) {
|
|
3289
|
+
console.warn(`[meow-memory] ${name} \u521D\u59CB\u5316\u5931\u8D25\uFF08\u8BE5\u529F\u80FD\u964D\u7EA7\uFF0C\u5176\u4F59\u4E0D\u53D7\u5F71\u54CD\uFF09\uFF1A`, e);
|
|
3290
|
+
}
|
|
3291
|
+
};
|
|
3292
|
+
safePush("dream \u56FE\u6807", startDreamIconManager);
|
|
3293
|
+
safePush("delegate \u6C14\u6CE1\u540C\u6B65", startDelegateStateSync);
|
|
3294
|
+
safePush("dream \u8DF3\u8FC7\u83DC\u5355", startDreamSkipManager);
|
|
3295
|
+
safePush("\u83DC\u5355 dream \u8138", startMenuDreamFace);
|
|
3296
|
+
try {
|
|
3297
|
+
disposers.push(applySettingsPage(ctx));
|
|
3298
|
+
} catch (e) {
|
|
3299
|
+
console.warn("[meow-memory] \u8BBE\u7F6E\u9875\u6CE8\u518C\u5931\u8D25\uFF08\u4E0D\u5F71\u54CD\u6298\u53E0\u4E0E\u56FE\u6807\uFF09\uFF1A", e);
|
|
3300
|
+
}
|
|
3301
|
+
for (const stale of Array.from(document.querySelectorAll("style[data-meow-memory-css]"))) {
|
|
3302
|
+
stale.remove();
|
|
3303
|
+
}
|
|
3304
|
+
const style = document.createElement("style");
|
|
3305
|
+
style.dataset.meowMemoryCss = "true";
|
|
3306
|
+
style.dataset.plugin = "meow-memory";
|
|
3307
|
+
style.textContent = FOLD_CSS;
|
|
3308
|
+
document.head.appendChild(style);
|
|
3309
|
+
const slots = ctx?.slots;
|
|
3310
|
+
if (slots === void 0 || typeof slots.inject !== "function") {
|
|
3311
|
+
console.warn("[meow-memory] slots service unavailable; reflection folding disabled");
|
|
3312
|
+
} else {
|
|
3313
|
+
disposers.push(slots.inject("conversation.composer.dock", () => slots.register(
|
|
3314
|
+
{
|
|
3315
|
+
name: "conversation.composer.dock",
|
|
3316
|
+
id: "meow-memory",
|
|
3317
|
+
order: 90
|
|
3318
|
+
},
|
|
3319
|
+
MemoryFoldDock
|
|
3320
|
+
)));
|
|
3321
|
+
const sessions = ctx?.sessions;
|
|
3322
|
+
const refreshSubagents = typeof sessions?.refreshSubagents === "function" ? (id) => sessions.refreshSubagents(id) : void 0;
|
|
3323
|
+
disposers.push(slots.inject("conversation.session.header.actions", () => slots.register(
|
|
3324
|
+
{
|
|
3325
|
+
name: "conversation.session.header.actions",
|
|
3326
|
+
id: "meow-memory",
|
|
3327
|
+
order: 200
|
|
3328
|
+
},
|
|
3329
|
+
makeDelegateVanishDock(refreshSubagents)
|
|
3330
|
+
)));
|
|
3331
|
+
}
|
|
3332
|
+
return () => {
|
|
3333
|
+
for (const dispose of disposers) {
|
|
3334
|
+
try {
|
|
3335
|
+
dispose();
|
|
3336
|
+
} catch {
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
};
|
|
3340
|
+
}
|
|
3341
|
+
return module.exports;
|
|
3342
|
+
}
|
|
3343
|
+
});
|
|
3344
|
+
//# sourceMappingURL=client.js.map
|