deepseek-harness-humanity 0.9.71 → 0.9.72
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/CHANGELOG.md +18 -4
- package/lib/agent-scope.js +0 -45
- package/lib/client.js +3 -4302
- package/lib/clock.js +0 -62
- package/lib/config.js +0 -9
- package/lib/data-plane.js +0 -46
- package/lib/deps.js +0 -54
- package/lib/documents.js +0 -35
- package/lib/emotion/appraise.js +0 -111
- package/lib/emotion/constants.js +0 -271
- package/lib/emotion/dynamics.js +0 -82
- package/lib/emotion/echo.js +0 -28
- package/lib/emotion/index.js +1 -39
- package/lib/emotion/inject.js +0 -59
- package/lib/emotion/model.js +0 -53
- package/lib/emotion/render.js +0 -71
- package/lib/emotion/section.js +0 -31
- package/lib/emotion/sensitivity.js +0 -103
- package/lib/emotion/stance.js +0 -70
- package/lib/emotion/state.js +0 -231
- package/lib/emotion/store.js +0 -19
- package/lib/emotion/view.js +0 -45
- package/lib/evolution/capabilities.js +0 -55
- package/lib/evolution/constants.js +0 -83
- package/lib/evolution/delivery.js +0 -88
- package/lib/evolution/diary.js +0 -53
- package/lib/evolution/energy.js +0 -109
- package/lib/evolution/index.js +0 -731
- package/lib/evolution/lifecycle.js +0 -48
- package/lib/evolution/room.js +1 -297
- package/lib/evolution/section.js +0 -74
- package/lib/evolution/settle-plan.js +0 -46
- package/lib/evolution/state.js +0 -73
- package/lib/evolution/tell.js +0 -56
- package/lib/evolution/title.js +0 -35
- package/lib/evolution/tool-tell.js +0 -17
- package/lib/evolution/wake.js +0 -41
- package/lib/exclusion-guard.js +0 -12
- package/lib/index.js +0 -156
- package/lib/llm.js +0 -41
- package/lib/log.js +0 -26
- package/lib/memory/consolidate.js +0 -100
- package/lib/memory/constants.js +0 -203
- package/lib/memory/decay.js +0 -50
- package/lib/memory/disclosure.js +0 -20
- package/lib/memory/index.js +0 -31
- package/lib/memory/inject.js +0 -163
- package/lib/memory/model.js +0 -57
- package/lib/memory/parse.js +0 -28
- package/lib/memory/reaction.js +0 -33
- package/lib/memory/render.js +0 -81
- package/lib/memory/search.js +0 -88
- package/lib/memory/section-doc.js +0 -24
- package/lib/memory/section-runtime.js +0 -97
- package/lib/memory/section.js +0 -26
- package/lib/memory/store.js +0 -2
- package/lib/memory/tiers.js +0 -14
- package/lib/memory/tools.js +0 -36
- package/lib/memory/write.js +4 -90
- package/lib/migrate.js +0 -38
- package/lib/modules.js +0 -30
- package/lib/optional.js +0 -14
- package/lib/persona/conflicts.js +0 -53
- package/lib/persona/constants.js +0 -140
- package/lib/persona/document.js +0 -40
- package/lib/persona/drift.js +0 -57
- package/lib/persona/grow-queue.js +0 -57
- package/lib/persona/grow.js +0 -56
- package/lib/persona/history-retention.js +0 -34
- package/lib/persona/identity-layer.js +0 -28
- package/lib/persona/identity.js +0 -56
- package/lib/persona/index.js +1 -42
- package/lib/persona/init.js +0 -32
- package/lib/persona/migrations.js +0 -57
- package/lib/persona/model.js +0 -74
- package/lib/persona/normalize.js +0 -65
- package/lib/persona/persist.js +0 -26
- package/lib/persona/predicates.js +0 -13
- package/lib/persona/prompt-render.js +0 -38
- package/lib/persona/prompt-texts.js +0 -71
- package/lib/persona/prompt.js +0 -50
- package/lib/persona/render-character.js +0 -37
- package/lib/persona/render-content.js +0 -142
- package/lib/persona/render.js +0 -52
- package/lib/persona/section.js +0 -39
- package/lib/persona/tool-approval.js +0 -28
- package/lib/persona/tool-helpers.js +0 -57
- package/lib/persona/tool-result.js +0 -29
- package/lib/persona/tools.js +0 -54
- package/lib/persona/update.js +0 -32
- package/lib/persona/upgrade.js +0 -27
- package/lib/persona/validate-character.js +0 -45
- package/lib/persona/validate-identity.js +1 -48
- package/lib/persona/validate-loss.js +0 -23
- package/lib/persona/validate-mutable.js +0 -99
- package/lib/persona/validate.js +0 -22
- package/lib/plane-settings.js +0 -23
- package/lib/preset-compat.js +0 -38
- package/lib/presets.js +0 -47
- package/lib/prompt-filter.js +0 -6
- package/lib/settings.js +1 -79
- package/lib/store-open.js +1 -134
- package/lib/store-schema.js +0 -96
- package/lib/store.js +0 -9
- package/lib/text.js +0 -106
- package/lib/tools-seam.js +0 -7
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -5,4308 +5,9 @@ window.__ModuleLoader__.load({
|
|
|
5
5
|
factory: (require) => {
|
|
6
6
|
var module = { exports: {} };
|
|
7
7
|
var exports = module.exports;
|
|
8
|
-
"use strict";
|
|
9
|
-
var __create = Object.create;
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
14
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name2 in all)
|
|
17
|
-
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let key of __getOwnPropNames(from))
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
28
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
29
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
30
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
31
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
32
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
33
|
-
mod
|
|
34
|
-
));
|
|
35
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
-
|
|
37
|
-
// src/client/index.ts
|
|
38
|
-
var index_exports = {};
|
|
39
|
-
__export(index_exports, {
|
|
40
|
-
EMOTION_NAMESPACE: () => EMOTION_NAMESPACE,
|
|
41
|
-
EVOLUTION_NAMESPACE: () => EVOLUTION_NAMESPACE,
|
|
42
|
-
EmotionPage: () => EmotionPage,
|
|
43
|
-
EmotionWorkbenchController: () => EmotionWorkbenchController,
|
|
44
|
-
EvolutionPage: () => EvolutionPage,
|
|
45
|
-
EvolutionWorkbenchController: () => EvolutionWorkbenchController,
|
|
46
|
-
HUMANITY_NAMESPACE: () => HUMANITY_NAMESPACE,
|
|
47
|
-
HumanityPanelIcon: () => HumanityPanelIcon,
|
|
48
|
-
MEMORY_NAMESPACE: () => MEMORY_NAMESPACE,
|
|
49
|
-
MemoryPage: () => MemoryPage,
|
|
50
|
-
MemoryWorkbenchController: () => MemoryWorkbenchController,
|
|
51
|
-
OverviewPanel: () => OverviewPanel,
|
|
52
|
-
PERSONA_NAMESPACE: () => PERSONA_NAMESPACE,
|
|
53
|
-
PersonaBoundary: () => PersonaBoundary,
|
|
54
|
-
PersonaWorkbenchController: () => PersonaWorkbenchController,
|
|
55
|
-
apply: () => apply,
|
|
56
|
-
asEmotionDocument: () => asEmotionDocument,
|
|
57
|
-
asMemoryDocument: () => asMemoryDocument,
|
|
58
|
-
createWorkbenchSeat: () => createWorkbenchSeat,
|
|
59
|
-
inject: () => inject,
|
|
60
|
-
name: () => name,
|
|
61
|
-
subscribeToProjection: () => subscribeToProjection
|
|
62
|
-
});
|
|
63
|
-
module.exports = __toCommonJS(index_exports);
|
|
64
|
-
var import_react12 = require("react");
|
|
65
|
-
|
|
66
|
-
// src/client/emotion-channel.ts
|
|
67
|
-
var EMOTION_NAMESPACE = "humanity-emotion";
|
|
68
|
-
function asString(value) {
|
|
69
|
-
return typeof value === "string" ? value : "";
|
|
70
|
-
}
|
|
71
|
-
function asNumber(value) {
|
|
72
|
-
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
73
|
-
}
|
|
74
|
-
function asEmotionDocument(value) {
|
|
75
|
-
const raw = value ?? {};
|
|
76
|
-
const charges = Array.isArray(raw.charges) ? raw.charges : [];
|
|
77
|
-
return {
|
|
78
|
-
charges: charges.map((entry) => {
|
|
79
|
-
const charge = entry ?? {};
|
|
80
|
-
return {
|
|
81
|
-
kind: asString(charge.kind),
|
|
82
|
-
label: asString(charge.label),
|
|
83
|
-
target: asString(charge.target) || "world",
|
|
84
|
-
targetLabel: asString(charge.targetLabel),
|
|
85
|
-
intensity: asNumber(charge.intensity),
|
|
86
|
-
// 比上次多/少(工作台画箭头用)。缺字段就是 0:老投影里没有这一项,不该画一个假箭头。
|
|
87
|
-
delta: asNumber(charge.delta),
|
|
88
|
-
// 上一次评估之前的值(画"从上次到现在净变化"的段用);缺失/空 = -1,界面据此不画段。
|
|
89
|
-
before: charge.before === void 0 || charge.before === null ? -1 : asNumber(charge.before),
|
|
90
|
-
tier: asString(charge.tier) || "calm",
|
|
91
|
-
cause: asString(charge.cause),
|
|
92
|
-
since: asString(charge.since)
|
|
93
|
-
};
|
|
94
|
-
}),
|
|
95
|
-
sensitivities: (Array.isArray(raw.sensitivities) ? raw.sensitivities : []).map((entry) => {
|
|
96
|
-
const item = entry ?? {};
|
|
97
|
-
return {
|
|
98
|
-
kind: asString(item.kind),
|
|
99
|
-
label: asString(item.label),
|
|
100
|
-
target: asString(item.target) || "world",
|
|
101
|
-
targetLabel: asString(item.targetLabel),
|
|
102
|
-
// 夹到 0–1:这是条上的宽度,坏值画出一道超出轨道的条只会像渲染坏了。
|
|
103
|
-
level: Math.max(0, Math.min(1, asNumber(item.level))),
|
|
104
|
-
cause: asString(item.cause),
|
|
105
|
-
delta: asNumber(item.delta),
|
|
106
|
-
levelBefore: Math.max(0, Math.min(1, asNumber(item.levelBefore))),
|
|
107
|
-
at: asString(item.at)
|
|
108
|
-
};
|
|
109
|
-
}),
|
|
110
|
-
warmth: asNumber(raw.warmth),
|
|
111
|
-
warmthCause: asString(raw.warmthCause),
|
|
112
|
-
compositeLabel: asString(raw.compositeLabel),
|
|
113
|
-
compositeParts: Array.isArray(raw.compositeParts) ? raw.compositeParts.map((part) => asString(part)).filter((part) => part !== "") : [],
|
|
114
|
-
perceived: asString(raw.perceived),
|
|
115
|
-
perceivedAt: asString(raw.perceivedAt),
|
|
116
|
-
energy: asNumber(raw.energy),
|
|
117
|
-
energyLevel: asString(raw.energyLevel) || "fresh",
|
|
118
|
-
settledAt: asString(raw.settledAt),
|
|
119
|
-
updatedAt: asString(raw.updatedAt),
|
|
120
|
-
notice: asString(raw.notice)
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// src/client/emotion-controller.ts
|
|
125
|
-
var EmotionWorkbenchController = class {
|
|
126
|
-
channel;
|
|
127
|
-
listeners = /* @__PURE__ */ new Set();
|
|
128
|
-
snapshot = { status: "unavailable" };
|
|
129
|
-
/**
|
|
130
|
-
* 接上通道并读一次。
|
|
131
|
-
* @param channel - 期望实现 `describe`;形状不对一律按"没有通道"处理(只显示未就绪)。
|
|
132
|
-
*/
|
|
133
|
-
attach(channel) {
|
|
134
|
-
this.channel = channel !== void 0 && channel !== null && typeof channel.describe === "function" ? channel : void 0;
|
|
135
|
-
void this.load();
|
|
136
|
-
}
|
|
137
|
-
/** 断开:回到"未就绪",但保留上一次读到的内容(服务重连时界面不会闪成空白)。 */
|
|
138
|
-
detach() {
|
|
139
|
-
this.channel = void 0;
|
|
140
|
-
this.set({ ...this.snapshot, status: "unavailable" });
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* 从宿主重读一次。
|
|
144
|
-
* @param options - `quiet`:不切到 loading(后台刷新用,避免界面闪一下)。
|
|
145
|
-
*/
|
|
146
|
-
async load(options) {
|
|
147
|
-
const channel = this.channel;
|
|
148
|
-
if (channel === void 0) {
|
|
149
|
-
this.set({ status: "unavailable" });
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (options?.quiet !== true) this.set({ status: "loading", document: this.snapshot.document });
|
|
153
|
-
let result;
|
|
154
|
-
try {
|
|
155
|
-
result = await channel.describe();
|
|
156
|
-
} catch (error) {
|
|
157
|
-
this.set({ status: "failed", error: error instanceof Error ? error.message : String(error) });
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (result === void 0 || result === null || result.ok !== true) {
|
|
161
|
-
this.set({ status: "failed", error: result?.error?.message ?? "宿主没有返回可用的数据" });
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const namespaces = Array.isArray(result.value?.namespaces) ? result.value.namespaces : [];
|
|
165
|
-
const view = namespaces.find((entry) => entry?.ns === EMOTION_NAMESPACE);
|
|
166
|
-
if (view === void 0) {
|
|
167
|
-
this.set({ status: "unavailable" });
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
this.set({ status: "ready", document: asEmotionDocument(view.value) });
|
|
171
|
-
}
|
|
172
|
-
/** 订阅快照变化;返回退订。 */
|
|
173
|
-
subscribe = (listener) => {
|
|
174
|
-
this.listeners.add(listener);
|
|
175
|
-
return () => {
|
|
176
|
-
this.listeners.delete(listener);
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
/** 读快照(引用稳定)。 */
|
|
180
|
-
getSnapshot = () => this.snapshot;
|
|
181
|
-
/** 替换快照并通知订阅者。 */
|
|
182
|
-
set(next) {
|
|
183
|
-
this.snapshot = next;
|
|
184
|
-
for (const listener of this.listeners) listener();
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// src/client/evolution-channel.ts
|
|
189
|
-
var EVOLUTION_NAMESPACE = "humanity-evolution";
|
|
190
|
-
function emptyEvolutionDocument() {
|
|
191
|
-
return {
|
|
192
|
-
status: {
|
|
193
|
-
enabled: false,
|
|
194
|
-
started: false,
|
|
195
|
-
sleeping: false,
|
|
196
|
-
energy: 0,
|
|
197
|
-
dayCount: 0,
|
|
198
|
-
maxPerDay: 0,
|
|
199
|
-
lastWakeAt: "",
|
|
200
|
-
nextAt: "",
|
|
201
|
-
taskReady: false,
|
|
202
|
-
busy: false,
|
|
203
|
-
lastError: "",
|
|
204
|
-
lastSettleError: "",
|
|
205
|
-
lastTurnTools: 0,
|
|
206
|
-
busySince: "",
|
|
207
|
-
lastAppraise: "",
|
|
208
|
-
roomText: "",
|
|
209
|
-
roomPath: "",
|
|
210
|
-
roomTarget: ""
|
|
211
|
-
},
|
|
212
|
-
diary: [],
|
|
213
|
-
works: [],
|
|
214
|
-
threads: [],
|
|
215
|
-
grow: { candidates: [], lastRun: { at: "", wrote: [], queued: [], note: "" } },
|
|
216
|
-
tell: { pending: "", pendingShow: "", lastAt: "", lastText: "", lastShow: "", unread: false, lastReason: "" },
|
|
217
|
-
transfer: { name: "", mime: "", base64: "" },
|
|
218
|
-
request: { op: "", value: "" },
|
|
219
|
-
notice: ""
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
function asEvolutionDocument(value) {
|
|
223
|
-
const empty = emptyEvolutionDocument();
|
|
224
|
-
if (typeof value !== "object" || value === null) return empty;
|
|
225
|
-
const raw = value;
|
|
226
|
-
const status = typeof raw.status === "object" && raw.status !== null ? raw.status : {};
|
|
227
|
-
const diary = Array.isArray(raw.diary) ? raw.diary.map((item) => {
|
|
228
|
-
const entry = typeof item === "object" && item !== null ? item : {};
|
|
229
|
-
return {
|
|
230
|
-
date: typeof entry.date === "string" ? entry.date : "",
|
|
231
|
-
opened: entry.opened === true,
|
|
232
|
-
openedAt: typeof entry.openedAt === "string" ? entry.openedAt : "",
|
|
233
|
-
noticedAt: typeof entry.noticedAt === "string" ? entry.noticedAt : "",
|
|
234
|
-
text: typeof entry.text === "string" ? entry.text : ""
|
|
235
|
-
};
|
|
236
|
-
}) : [];
|
|
237
|
-
const works = Array.isArray(raw.works) ? raw.works.map((item) => {
|
|
238
|
-
const entry = typeof item === "object" && item !== null ? item : {};
|
|
239
|
-
return {
|
|
240
|
-
name: typeof entry.name === "string" ? entry.name : "",
|
|
241
|
-
size: typeof entry.size === "number" ? entry.size : 0,
|
|
242
|
-
updatedAt: typeof entry.updatedAt === "string" ? entry.updatedAt : "",
|
|
243
|
-
kind: typeof entry.kind === "string" ? entry.kind : "other",
|
|
244
|
-
preview: typeof entry.preview === "string" ? entry.preview : ""
|
|
245
|
-
};
|
|
246
|
-
}) : [];
|
|
247
|
-
const request = typeof raw.request === "object" && raw.request !== null ? raw.request : {};
|
|
248
|
-
const growRaw = typeof raw.grow === "object" && raw.grow !== null ? raw.grow : {};
|
|
249
|
-
const candidates = Array.isArray(growRaw.candidates) ? growRaw.candidates.map((item) => {
|
|
250
|
-
const entry = typeof item === "object" && item !== null ? item : {};
|
|
251
|
-
return {
|
|
252
|
-
text: typeof entry.text === "string" ? entry.text : "",
|
|
253
|
-
about: typeof entry.about === "string" ? entry.about : "self",
|
|
254
|
-
section: typeof entry.section === "string" ? entry.section : "",
|
|
255
|
-
count: typeof entry.count === "number" ? entry.count : 0,
|
|
256
|
-
days: typeof entry.days === "number" ? entry.days : 0
|
|
257
|
-
};
|
|
258
|
-
}) : [];
|
|
259
|
-
const lastRunRaw = typeof growRaw.lastRun === "object" && growRaw.lastRun !== null ? growRaw.lastRun : {};
|
|
260
|
-
const strings = (value2) => Array.isArray(value2) ? value2.filter((line) => typeof line === "string") : [];
|
|
261
|
-
const tellRaw = typeof raw.tell === "object" && raw.tell !== null ? raw.tell : {};
|
|
262
|
-
return {
|
|
263
|
-
status: {
|
|
264
|
-
enabled: status.enabled === true,
|
|
265
|
-
started: status.started === true,
|
|
266
|
-
sleeping: status.sleeping === true,
|
|
267
|
-
energy: typeof status.energy === "number" ? status.energy : 0,
|
|
268
|
-
dayCount: typeof status.dayCount === "number" ? status.dayCount : 0,
|
|
269
|
-
maxPerDay: typeof status.maxPerDay === "number" ? status.maxPerDay : 0,
|
|
270
|
-
lastWakeAt: typeof status.lastWakeAt === "string" ? status.lastWakeAt : "",
|
|
271
|
-
nextAt: typeof status.nextAt === "string" ? status.nextAt : "",
|
|
272
|
-
taskReady: status.taskReady === true,
|
|
273
|
-
busy: status.busy === true,
|
|
274
|
-
lastError: typeof status.lastError === "string" ? status.lastError : "",
|
|
275
|
-
lastSettleError: typeof status.lastSettleError === "string" ? status.lastSettleError : "",
|
|
276
|
-
lastTurnTools: typeof status.lastTurnTools === "number" ? status.lastTurnTools : 0,
|
|
277
|
-
busySince: typeof status.busySince === "string" ? status.busySince : "",
|
|
278
|
-
lastAppraise: typeof status.lastAppraise === "string" ? status.lastAppraise : "",
|
|
279
|
-
roomText: typeof status.roomText === "string" ? status.roomText : "",
|
|
280
|
-
roomPath: typeof status.roomPath === "string" ? status.roomPath : "",
|
|
281
|
-
roomTarget: typeof status.roomTarget === "string" ? status.roomTarget : ""
|
|
282
|
-
},
|
|
283
|
-
diary,
|
|
284
|
-
works,
|
|
285
|
-
threads: Array.isArray(raw.threads) ? raw.threads.filter((line) => typeof line === "string") : [],
|
|
286
|
-
grow: {
|
|
287
|
-
candidates,
|
|
288
|
-
lastRun: {
|
|
289
|
-
at: typeof lastRunRaw.at === "string" ? lastRunRaw.at : "",
|
|
290
|
-
wrote: strings(lastRunRaw.wrote),
|
|
291
|
-
queued: strings(lastRunRaw.queued),
|
|
292
|
-
note: typeof lastRunRaw.note === "string" ? lastRunRaw.note : ""
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
tell: {
|
|
296
|
-
pending: typeof tellRaw.pending === "string" ? tellRaw.pending : "",
|
|
297
|
-
pendingShow: typeof tellRaw.pendingShow === "string" ? tellRaw.pendingShow : "",
|
|
298
|
-
lastAt: typeof tellRaw.lastAt === "string" ? tellRaw.lastAt : "",
|
|
299
|
-
lastText: typeof tellRaw.lastText === "string" ? tellRaw.lastText : "",
|
|
300
|
-
lastShow: typeof tellRaw.lastShow === "string" ? tellRaw.lastShow : "",
|
|
301
|
-
unread: tellRaw.unread === true,
|
|
302
|
-
lastReason: typeof tellRaw.lastReason === "string" ? tellRaw.lastReason : ""
|
|
303
|
-
},
|
|
304
|
-
transfer: {
|
|
305
|
-
name: typeof raw.transfer?.name === "string" ? String(raw.transfer.name) : "",
|
|
306
|
-
mime: typeof raw.transfer?.mime === "string" ? String(raw.transfer.mime) : "",
|
|
307
|
-
base64: typeof raw.transfer?.base64 === "string" ? String(raw.transfer.base64) : ""
|
|
308
|
-
},
|
|
309
|
-
request: {
|
|
310
|
-
op: typeof request.op === "string" ? request.op : "",
|
|
311
|
-
value: typeof request.value === "string" ? request.value : ""
|
|
312
|
-
},
|
|
313
|
-
notice: typeof raw.notice === "string" ? raw.notice : ""
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// src/client/evolution-controller.ts
|
|
318
|
-
function saveTransfer(transfer) {
|
|
319
|
-
if (typeof document === "undefined" || typeof atob !== "function") return false;
|
|
320
|
-
try {
|
|
321
|
-
const binary = atob(transfer.base64);
|
|
322
|
-
const bytes = new Uint8Array(binary.length);
|
|
323
|
-
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
|
|
324
|
-
const blob = new Blob([bytes], { type: transfer.mime === "" ? "application/octet-stream" : transfer.mime });
|
|
325
|
-
const url = URL.createObjectURL(blob);
|
|
326
|
-
const anchor2 = document.createElement("a");
|
|
327
|
-
anchor2.href = url;
|
|
328
|
-
anchor2.download = transfer.name;
|
|
329
|
-
anchor2.click();
|
|
330
|
-
URL.revokeObjectURL(url);
|
|
331
|
-
return true;
|
|
332
|
-
} catch {
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
var EvolutionWorkbenchController = class {
|
|
337
|
-
channel;
|
|
338
|
-
/** 命名空间当前修订号:写回必须带上(并发保护)。 */
|
|
339
|
-
revision;
|
|
340
|
-
listeners = /* @__PURE__ */ new Set();
|
|
341
|
-
state = { status: "idle", doc: emptyEvolutionDocument() };
|
|
342
|
-
/** 订阅状态变化;返回退订动作。 */
|
|
343
|
-
subscribe = (listener) => {
|
|
344
|
-
this.listeners.add(listener);
|
|
345
|
-
return () => {
|
|
346
|
-
this.listeners.delete(listener);
|
|
347
|
-
};
|
|
348
|
-
};
|
|
349
|
-
/** 当前快照(也用作服务端快照:两边读同一个对象)。 */
|
|
350
|
-
getSnapshot = () => this.state;
|
|
351
|
-
/** 接上通道并读一次;形状不对就整条通道判为不可用。 */
|
|
352
|
-
attach(channel) {
|
|
353
|
-
this.channel = channel !== void 0 && channel !== null && typeof channel.describe === "function" ? channel : void 0;
|
|
354
|
-
void this.load();
|
|
355
|
-
}
|
|
356
|
-
/** 通道断开(宿主摘除远端):回到"读不到",不清掉已经渲染的内容。 */
|
|
357
|
-
detach() {
|
|
358
|
-
this.channel = void 0;
|
|
359
|
-
this.setState({ status: "unavailable", doc: this.state.doc });
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* 翻开某一天的日记。
|
|
363
|
-
*
|
|
364
|
-
* 客户端只写命令;宿主决定能不能给、并把结果写回通知(见宿主的 `section.ts`)。
|
|
365
|
-
* @param date - 哪一天(YYYY-MM-DD)。
|
|
366
|
-
* @returns 命令是否写出去。
|
|
367
|
-
*/
|
|
368
|
-
/**
|
|
369
|
-
* 改「一天最多醒几次」。
|
|
370
|
-
*
|
|
371
|
-
* 写的是套件配置(`humanity` 命名空间的 `modules.evolution`);宿主若拒绝,会以通知形式说明原因。
|
|
372
|
-
* @param value - 0–24 的整数。
|
|
373
|
-
* @returns 命令是否写出去。
|
|
374
|
-
*/
|
|
375
|
-
async setWakeCap(value) {
|
|
376
|
-
const channel = this.channel;
|
|
377
|
-
if (channel === void 0) return false;
|
|
378
|
-
try {
|
|
379
|
-
await this.load({ quiet: true });
|
|
380
|
-
const outcome = await channel.replace(
|
|
381
|
-
EVOLUTION_NAMESPACE,
|
|
382
|
-
{ ...this.state.doc, request: { op: "cap", value: String(value) }, notice: "" },
|
|
383
|
-
this.revision
|
|
384
|
-
);
|
|
385
|
-
if (outcome.ok) this.revision = outcome.value?.value?.revision ?? this.revision;
|
|
386
|
-
await this.load({ quiet: true });
|
|
387
|
-
return outcome.ok === true;
|
|
388
|
-
} catch {
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* 改「她的房间」。
|
|
394
|
-
*
|
|
395
|
-
* 写的是套件配置(`humanity` 命名空间的 `modules.evolution.room`);**不在这里开会话** ——
|
|
396
|
-
* 搬家要牵动闹钟与状态,那是宿主排程那一步的事。宿主要是拒绝,会以通知形式说明原因。
|
|
397
|
-
* @param value - 名字(不带斜杠)或完整路径;空串 = 回到老位置。
|
|
398
|
-
* @returns 命令是否写出去。
|
|
399
|
-
*/
|
|
400
|
-
async setRoom(value) {
|
|
401
|
-
const channel = this.channel;
|
|
402
|
-
if (channel === void 0) return false;
|
|
403
|
-
try {
|
|
404
|
-
await this.load({ quiet: true });
|
|
405
|
-
const outcome = await channel.replace(
|
|
406
|
-
EVOLUTION_NAMESPACE,
|
|
407
|
-
{ ...this.state.doc, request: { op: "room", value }, notice: "" },
|
|
408
|
-
this.revision
|
|
409
|
-
);
|
|
410
|
-
if (outcome.ok) this.revision = outcome.value?.value?.revision ?? this.revision;
|
|
411
|
-
if (outcome.ok !== true) return false;
|
|
412
|
-
await this.load({ quiet: true });
|
|
413
|
-
return true;
|
|
414
|
-
} catch {
|
|
415
|
-
return false;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* 从她的候选队列里删掉一条。
|
|
420
|
-
*
|
|
421
|
-
* 客户端只写命令;宿主决定能不能删,并把结果写回通知(与"翻开日记""改次数上限"同一条路)。
|
|
422
|
-
* @param text - 那条观察的原文。
|
|
423
|
-
* @returns 命令是否写出去。
|
|
424
|
-
*/
|
|
425
|
-
async dropCandidate(text) {
|
|
426
|
-
const channel = this.channel;
|
|
427
|
-
if (channel === void 0 || text === "") return false;
|
|
428
|
-
try {
|
|
429
|
-
await this.load({ quiet: true });
|
|
430
|
-
const outcome = await channel.replace(
|
|
431
|
-
EVOLUTION_NAMESPACE,
|
|
432
|
-
{ ...this.state.doc, request: { op: "grow-drop", value: text }, notice: "" },
|
|
433
|
-
this.revision
|
|
434
|
-
);
|
|
435
|
-
if (outcome.ok) this.revision = outcome.value?.value?.revision ?? this.revision;
|
|
436
|
-
if (outcome.ok !== true) return false;
|
|
437
|
-
await this.load({ quiet: true });
|
|
438
|
-
return true;
|
|
439
|
-
} catch {
|
|
440
|
-
return false;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* 下载她目录里的一个文件。
|
|
445
|
-
*
|
|
446
|
-
* 宿主把字节放进**一次性**的 `transfer` 里下发(数据面只有三个方法,新开一条下载路由要动协议);
|
|
447
|
-
* 客户端把它变成 Blob 交给浏览器。拿不到就返回 false,不假装成功。
|
|
448
|
-
* @param name - 文件名。
|
|
449
|
-
* @returns 是否真的交出了一个文件。
|
|
450
|
-
*/
|
|
451
|
-
async download(name2) {
|
|
452
|
-
const channel = this.channel;
|
|
453
|
-
if (channel === void 0 || name2 === "") return false;
|
|
454
|
-
try {
|
|
455
|
-
await this.load({ quiet: true });
|
|
456
|
-
const outcome = await channel.replace(
|
|
457
|
-
EVOLUTION_NAMESPACE,
|
|
458
|
-
{ ...this.state.doc, request: { op: "read", value: name2 }, notice: "" },
|
|
459
|
-
this.revision
|
|
460
|
-
);
|
|
461
|
-
if (outcome.ok !== true) return false;
|
|
462
|
-
this.revision = outcome.value?.value?.revision ?? this.revision;
|
|
463
|
-
await this.load({ quiet: true });
|
|
464
|
-
const transfer = this.state.doc.transfer;
|
|
465
|
-
if (transfer.name !== name2 || transfer.base64 === "") return false;
|
|
466
|
-
return saveTransfer(transfer);
|
|
467
|
-
} catch {
|
|
468
|
-
return false;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
async open(date) {
|
|
472
|
-
const channel = this.channel;
|
|
473
|
-
if (channel === void 0 || date === "") return false;
|
|
474
|
-
try {
|
|
475
|
-
await this.load({ quiet: true });
|
|
476
|
-
const outcome = await channel.replace(EVOLUTION_NAMESPACE, { ...this.state.doc, request: { op: "open", value: date }, notice: "" }, this.revision);
|
|
477
|
-
if (outcome.ok) this.revision = outcome.value?.value?.revision ?? this.revision;
|
|
478
|
-
if (outcome.ok !== true) return false;
|
|
479
|
-
await this.load({ quiet: true });
|
|
480
|
-
return true;
|
|
481
|
-
} catch {
|
|
482
|
-
return false;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* 读一次投影。
|
|
487
|
-
* @param options - `quiet` 不把状态翻成 `idle`(刷新时不闪)。
|
|
488
|
-
*/
|
|
489
|
-
async load(options = {}) {
|
|
490
|
-
const channel = this.channel;
|
|
491
|
-
if (channel === void 0) {
|
|
492
|
-
this.setState({ status: "unavailable", doc: this.state.doc });
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
try {
|
|
496
|
-
const result = await channel.describe();
|
|
497
|
-
const envelope = result;
|
|
498
|
-
const namespaces = envelope?.value?.namespaces ?? [];
|
|
499
|
-
const view = namespaces.find((candidate) => candidate.ns === EVOLUTION_NAMESPACE);
|
|
500
|
-
if (envelope?.ok === false || view === void 0) {
|
|
501
|
-
this.setState({ status: "unavailable", doc: this.state.doc });
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
this.revision = view.revision;
|
|
505
|
-
this.setState({ status: "ready", doc: asEvolutionDocument(view.value) });
|
|
506
|
-
} catch {
|
|
507
|
-
if (options.quiet === true) return;
|
|
508
|
-
this.setState({ status: "unavailable", doc: this.state.doc });
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
/** 推一个新状态给订阅者。 */
|
|
512
|
-
setState(next) {
|
|
513
|
-
this.state = next;
|
|
514
|
-
for (const listener of this.listeners) listener();
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
// src/client/HumanityPanelIcon.tsx
|
|
519
|
-
var import_react = require("react");
|
|
520
|
-
|
|
521
|
-
// src/client/icons.ts
|
|
522
|
-
var primitives = __toESM(require("@deepseek-ai/dsh-client-ui-primitives"), 1);
|
|
523
|
-
var ICON_CANDIDATES = {
|
|
524
|
-
IconQuestion: ["IconQuestionOutline14", "IconQuestionOutline"],
|
|
525
|
-
IconChevronDown: ["IconChevronDownOutline14", "IconChevronDownOutline"],
|
|
526
|
-
IconChevronRight: ["IconChevronRightOutline14", "IconChevronRightOutline"],
|
|
527
|
-
IconPersonalization: ["IconPersonalizationOutline16", "IconPersonalizationOutline"]
|
|
528
|
-
};
|
|
529
|
-
function isRenderable(value) {
|
|
530
|
-
return typeof value === "function" || typeof value === "object" && value !== null;
|
|
531
|
-
}
|
|
532
|
-
function resolveIcon(group) {
|
|
533
|
-
const names = ICON_CANDIDATES[group] ?? [];
|
|
534
|
-
const bag = primitives;
|
|
535
|
-
for (const name2 of names) {
|
|
536
|
-
if (isRenderable(bag[name2])) return bag[name2];
|
|
537
|
-
}
|
|
538
|
-
return void 0;
|
|
539
|
-
}
|
|
540
|
-
var IconQuestion = resolveIcon("IconQuestion");
|
|
541
|
-
var IconChevronDown = resolveIcon("IconChevronDown");
|
|
542
|
-
var IconChevronRight = resolveIcon("IconChevronRight");
|
|
543
|
-
var IconPersonalization = resolveIcon("IconPersonalization");
|
|
544
|
-
var CANDIDATE_NAMES = Object.values(ICON_CANDIDATES).flat();
|
|
545
|
-
|
|
546
|
-
// src/client/HumanityPanelIcon.tsx
|
|
547
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
548
|
-
function FallbackGlyph({ size = 16 }) {
|
|
549
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: size, height: size, viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
|
|
550
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "8", cy: "5.5", r: "2.5", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
551
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 13c0-2.5 2.2-4 5-4s5 1.5 5 4", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
|
|
552
|
-
] });
|
|
553
|
-
}
|
|
554
|
-
function HumanityPanelIcon({ size }) {
|
|
555
|
-
const Icon = IconPersonalization ?? FallbackGlyph;
|
|
556
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { size: typeof size === "number" && Number.isFinite(size) ? size : 16 });
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
// src/client/ids.ts
|
|
560
|
-
var WORKBENCH_ID = "humanity";
|
|
561
|
-
var PANEL_ORDER = 60;
|
|
562
|
-
var PANEL_LABEL = "Humanity";
|
|
563
|
-
|
|
564
|
-
// src/client/emotion-locales.ts
|
|
565
|
-
var emotionZh = {
|
|
566
|
-
"emotion.tab": "情绪",
|
|
567
|
-
"emotion.title": "它此刻",
|
|
568
|
-
"emotion.hint": "这里显示它现在的心情:由对话里发生的事推动,随时间自己退。它只在「Humanity 沉浸」里生效;功能模式完全不读不写。这一页只是观察窗——心情不靠手动拨,靠你们之间发生的事。",
|
|
569
|
-
"emotion.calm": "平静",
|
|
570
|
-
"emotion.empty": "现在没有明显的情绪。",
|
|
571
|
-
"emotion.composite": "合起来是",
|
|
572
|
-
"emotion.compositeHint": "两种基本情绪同时够强时,它们合起来有一个名字 —— 这一行不是另加的情绪,是上面两条的合成。",
|
|
573
|
-
"emotion.sensitivity": "磨出来的敏感",
|
|
574
|
-
"emotion.sensitivityHint": "同一个人的同一类事反复落在同一处,这一处就会越来越容易被点着:下一次最多比第一次重一半。它自己也会退:一天剩一半,两三天不碰就淡了。好事不记在这里。",
|
|
575
|
-
"emotion.sensitivityEmpty": "还没有哪一处被反复磨到。",
|
|
576
|
-
"emotion.sensitivityNoCause": "这一处被磨过,但没记下是因为什么",
|
|
577
|
-
"emotion.sensitivityDelta": "这是最近一次磨它的那笔增减",
|
|
578
|
-
"emotion.warmth": "关系温度",
|
|
579
|
-
"emotion.warmthHint": "它此刻对你的感觉(会变),不是「我们是什么关系」(那个在人格里)。",
|
|
580
|
-
"emotion.perceived": "它眼里的你",
|
|
581
|
-
"emotion.perceivedHint": "它从这句话里读到的你的状态。看得准不准另说,但它确实在看你。",
|
|
582
|
-
"emotion.energy": "精力",
|
|
583
|
-
"emotion.energyHint": "它会累:白天消耗、每过一天恢复。累了话会变短 —— 跟心情好坏无关,是没力气。",
|
|
584
|
-
"emotion.params.title": "它怎么算的(这些数不在这页改)",
|
|
585
|
-
"emotion.params.hint": "这几条是标定过的:改动它们等于改她的性子,所以只能改代码,不给你一个随时能拨的旋钮。写在这里是为了让你看得见。",
|
|
586
|
-
"emotion.params.floor": "触发线:{floor} 分以上才写进她读到的那一段",
|
|
587
|
-
"emotion.params.tiers": "档位:{faint} / {clear} / {burst} 分(有点 / 明显 / 爆发)",
|
|
588
|
-
"emotion.params.sensitivity": "磨出来的敏感:同一处反复被刺,最多放大到 {boost} 倍,{hours} 小时减半",
|
|
589
|
-
"emotion.params.soothe": "自调节:{minutes} 分钟没再被刺,负面情绪退得快一倍",
|
|
590
|
-
"emotion.energy.fresh": "有精神",
|
|
591
|
-
"emotion.energy.tired": "有点累",
|
|
592
|
-
"emotion.energy.exhausted": "很累",
|
|
593
|
-
"emotion.cause": "因为",
|
|
594
|
-
"emotion.deltaUp": "比上一次评估多了 {n}",
|
|
595
|
-
"emotion.deltaDown": "比上一次评估少了 {n}",
|
|
596
|
-
"emotion.noCause": "没有具体原因,只是残留",
|
|
597
|
-
"emotion.since": "已经 {duration}",
|
|
598
|
-
"emotion.duration.minutes": "{n} 分钟",
|
|
599
|
-
"emotion.duration.hours": "{n} 小时",
|
|
600
|
-
"emotion.duration.days": "{n} 天",
|
|
601
|
-
"emotion.ago": "{duration}前",
|
|
602
|
-
"emotion.agoNow": "刚刚",
|
|
603
|
-
"emotion.tier.calm": "微弱",
|
|
604
|
-
"emotion.absent": "没有",
|
|
605
|
-
"emotion.tier.faint": "轻微",
|
|
606
|
-
"emotion.tier.clear": "明显",
|
|
607
|
-
"emotion.tier.burst": "强烈",
|
|
608
|
-
"emotion.tier.burstHint": "到了这一档,它可以直接说出来(只说一次)。",
|
|
609
|
-
"emotion.loading": "正在读取…",
|
|
610
|
-
"emotion.unavailable": "情绪模块未就绪(宿主那一半没挂上,或模块被关掉了)。",
|
|
611
|
-
"emotion.failed": "读取失败:{message}",
|
|
612
|
-
"emotion.reload": "重新读取",
|
|
613
|
-
"emotion.settledAt": "上次结算:{time}",
|
|
614
|
-
"emotion.globalHint": "这一份状态是全局的:换会话不会重置,也不按会话分开记。"
|
|
615
|
-
};
|
|
616
|
-
var emotionEn = {
|
|
617
|
-
"emotion.tab": "Mood",
|
|
618
|
-
"emotion.title": "How it feels right now",
|
|
619
|
-
"emotion.hint": 'What it is feeling **right now**: pushed by what happens in the conversation and decaying on its own over time. It only applies to the "Humanity Immersive" preset; the functional preset never reads or writes it. This page is a window, not a dial — mood is moved by what happens between you.',
|
|
620
|
-
"emotion.calm": "Calm",
|
|
621
|
-
"emotion.empty": "No strong emotion right now.",
|
|
622
|
-
"emotion.composite": "Together that reads as",
|
|
623
|
-
"emotion.compositeHint": "When two basic emotions are both strong, they have a combined name — this line is not a third emotion, it is the blend of the two above.",
|
|
624
|
-
"emotion.sensitivity": "What has worn thin",
|
|
625
|
-
"emotion.sensitivityHint": "When the same kind of thing keeps landing on the same spot, that spot gets easier to set off: at most half again as heavy as the first time. It fades on its own — half gone in a day, mostly gone after two or three. Good things are not counted here.",
|
|
626
|
-
"emotion.sensitivityEmpty": "Nothing has been worn thin yet.",
|
|
627
|
-
"emotion.sensitivityNoCause": "This spot was worn, but what wore it was not recorded",
|
|
628
|
-
"emotion.sensitivityDelta": "How much the last sting moved it",
|
|
629
|
-
"emotion.warmth": "Warmth",
|
|
630
|
-
"emotion.warmthHint": 'How it feels about you at this moment (moves fast), not "what we are to each other" (that lives in the persona).',
|
|
631
|
-
"emotion.perceived": "What it noticed about you",
|
|
632
|
-
"emotion.perceivedHint": "The state it read from your last message. It may be wrong — but it is looking.",
|
|
633
|
-
"emotion.energy": "Energy",
|
|
634
|
-
"emotion.energyHint": "It gets tired: drains through the day, recovers once a day. Tired means shorter answers — not bad mood, just no fuel.",
|
|
635
|
-
"emotion.params.title": "How it is computed (not editable here)",
|
|
636
|
-
"emotion.params.hint": "These are calibrated together: changing them changes her temperament, so they stay in code instead of a dial. They are listed here so you can see them.",
|
|
637
|
-
"emotion.params.floor": "Floor: only above {floor} reaches the paragraph she reads",
|
|
638
|
-
"emotion.params.tiers": "Tiers: {faint} / {clear} / {burst} (slight / clear / burst)",
|
|
639
|
-
"emotion.params.sensitivity": "Worn-in sensitivity: repeated stings at one spot amplify up to {boost}x, halving in {hours}h",
|
|
640
|
-
"emotion.params.soothe": "Self-soothing: after {minutes} quiet minutes a negative feeling fades twice as fast",
|
|
641
|
-
"emotion.energy.fresh": "fresh",
|
|
642
|
-
"emotion.energy.tired": "a bit tired",
|
|
643
|
-
"emotion.energy.exhausted": "exhausted",
|
|
644
|
-
"emotion.cause": "Because",
|
|
645
|
-
"emotion.deltaUp": "{n} more than the last reading",
|
|
646
|
-
"emotion.deltaDown": "{n} less than the last reading",
|
|
647
|
-
"emotion.noCause": "No specific reason; just residue",
|
|
648
|
-
"emotion.since": "for {duration}",
|
|
649
|
-
"emotion.duration.minutes": "{n} min",
|
|
650
|
-
"emotion.duration.hours": "{n} h",
|
|
651
|
-
"emotion.duration.days": "{n} d",
|
|
652
|
-
"emotion.ago": "{duration} ago",
|
|
653
|
-
"emotion.agoNow": "just now",
|
|
654
|
-
"emotion.tier.calm": "slight",
|
|
655
|
-
"emotion.absent": "none",
|
|
656
|
-
"emotion.tier.faint": "faint",
|
|
657
|
-
"emotion.tier.clear": "clear",
|
|
658
|
-
"emotion.tier.burst": "strong",
|
|
659
|
-
"emotion.tier.burstHint": "At this level it may say it outright (once).",
|
|
660
|
-
"emotion.loading": "Reading…",
|
|
661
|
-
"emotion.unavailable": "The emotion module is not ready (host side missing, or the module is off).",
|
|
662
|
-
"emotion.failed": "Could not read: {message}",
|
|
663
|
-
"emotion.reload": "Reload",
|
|
664
|
-
"emotion.settledAt": "Last settled: {time}",
|
|
665
|
-
"emotion.globalHint": "This state is global: switching sessions does not reset it, and it is not stored per session."
|
|
666
|
-
};
|
|
667
|
-
|
|
668
|
-
// src/client/workbench-locales.ts
|
|
669
|
-
var workbenchZh = {
|
|
670
|
-
// 页面级说明收进标题旁的「?」(用户 2026-09-26):界面上不再有整段说明文字,
|
|
671
|
-
// 但"这是什么、开关在哪"必须仍然问得到 —— 只是从"一直占着版面"改成"悬停才出现"。
|
|
672
|
-
"workbench.titleHint": '人格、情绪、记忆,和她自己的时间,统一在这里看。各模块的开关在 DSH 设置里(搜 "Humanity")。',
|
|
673
|
-
"workbench.overview": "总览",
|
|
674
|
-
"workbench.metric.name": "姓名",
|
|
675
|
-
"workbench.metric.nameEmpty": "还没设置",
|
|
676
|
-
"workbench.metric.memory": "记忆",
|
|
677
|
-
"workbench.metric.memoryHint": "她自己的经历账里现在有多少条;读不到时如实说明,不填推测的数字。",
|
|
678
|
-
// 通道没就绪时如实说读不到:这里显示的每一个值都来自宿主投影,**不填推定数字**
|
|
679
|
-
// (写死或估算的数字会被当成真实状态读,那比空着更糟——M1 的原始教训)。
|
|
680
|
-
"workbench.metric.unavailable": "暂时读不到",
|
|
681
|
-
"workbench.state.loading": "加载中…",
|
|
682
|
-
"workbench.state.unavailable": "暂时读不到(设置服务没接上,或 Humanity 模块被关掉了)。",
|
|
683
|
-
"workbench.metric.memoryValue": "{count} 条",
|
|
684
|
-
// 自进化页(她自己的时间)。
|
|
685
|
-
"workbench.evolution.tab": "自进化",
|
|
686
|
-
"workbench.evolution.today": "她的今天",
|
|
687
|
-
"workbench.evolution.todayHint": "她自己的一天:醒来几次、还剩多少力气、下一次什么时候醒。她不会闲聊时被叫醒,安静一阵之后才有她自己的时间。",
|
|
688
|
-
"workbench.evolution.notStarted": "人格还没封存,她还没有开始过日子。",
|
|
689
|
-
"workbench.evolution.field.state": "现在",
|
|
690
|
-
"workbench.evolution.field.energy": "精力",
|
|
691
|
-
"workbench.evolution.field.wakes": "今天醒过",
|
|
692
|
-
"workbench.evolution.field.lastWake": "上一次醒",
|
|
693
|
-
"workbench.evolution.field.nextWake": "下一次醒",
|
|
694
|
-
"workbench.evolution.field.lastTurn": "上一轮她做了什么",
|
|
695
|
-
"workbench.evolution.lastTurn.tools": "动了手:调了 {count} 次工具",
|
|
696
|
-
"workbench.evolution.lastTurn.talk": "只说了话,没动手",
|
|
697
|
-
"workbench.evolution.appraise.applied": "自评 {count} 条({targets})",
|
|
698
|
-
"workbench.evolution.appraise.none": "自评:看了,但没动心",
|
|
699
|
-
"workbench.evolution.appraise.skipped": "自评没跑(情绪模块没接上)",
|
|
700
|
-
"workbench.evolution.busy": "(你正在跟她说话,闹钟压着",
|
|
701
|
-
"workbench.evolution.busySince": "从 {time} 起)",
|
|
702
|
-
"workbench.evolution.state.awake": "醒着",
|
|
703
|
-
"workbench.evolution.state.sleeping": "在睡",
|
|
704
|
-
"workbench.evolution.energy.fresh": "还有力气({value}/100)",
|
|
705
|
-
"workbench.evolution.energy.ok": "还行({value}/100)",
|
|
706
|
-
"workbench.evolution.energy.tired": "有点累({value}/100)",
|
|
707
|
-
"workbench.evolution.energy.spent": "快没力气了({value}/100)",
|
|
708
|
-
"workbench.evolution.wakesValue": "{count} 次(上限 {max} 次)",
|
|
709
|
-
"workbench.evolution.cap.aria": "一天最多醒几次(回车生效)",
|
|
710
|
-
"workbench.evolution.room.title": "她的房间",
|
|
711
|
-
"workbench.evolution.room.hint": "她自己待着的地方。填一个名字(建在数据目录里)或一条完整路径;填完回车生效。她只会在下一次排程时搬过去,旧会话留在原处不动。",
|
|
712
|
-
"workbench.evolution.room.aria": "她的房间:名字或完整路径(回车生效)",
|
|
713
|
-
"workbench.evolution.room.placeholder": "名字,或完整路径",
|
|
714
|
-
"workbench.evolution.room.nowAt": "现在住在这里:{path}",
|
|
715
|
-
"workbench.evolution.room.pending": "改成了 {path} —— 她手头这一轮结束就搬过去(旧会话留在原处)。",
|
|
716
|
-
"workbench.evolution.room.legacy": "现在住在老位置(还没填过)。",
|
|
717
|
-
"workbench.evolution.error": "上一次没排上:{reason}",
|
|
718
|
-
"workbench.evolution.diary.title": "她的日记",
|
|
719
|
-
"workbench.evolution.diary.hint": "一天一篇,用她自己的口气写。默认是合着的 —— 只显示日期;翻开之后那一天的正文才给你看,而且翻了就是翻了。",
|
|
720
|
-
"workbench.evolution.diary.settleFailed": "上一次收账没写成:{reason}",
|
|
721
|
-
"workbench.evolution.diary.empty": "还没有写过日记。她睡下的时候才收一天。",
|
|
722
|
-
"workbench.evolution.diary.open": "翻开",
|
|
723
|
-
"workbench.evolution.diary.confirm": "翻开就收不回去了,确定?",
|
|
724
|
-
"workbench.evolution.diary.confirmYes": "确认翻开",
|
|
725
|
-
"workbench.evolution.diary.confirmNo": "算了",
|
|
726
|
-
"workbench.evolution.diary.openedAt": "在 {time} 被翻开",
|
|
727
|
-
"workbench.evolution.diary.unnoticed": "她还没发现",
|
|
728
|
-
"workbench.evolution.diary.noticed": "她在 {time} 知道了",
|
|
729
|
-
// 她留给你的(主动找你说的话)。
|
|
730
|
-
"workbench.evolution.tell.title": "她留给你的",
|
|
731
|
-
"workbench.evolution.tell.hint": "她自己待着的时候,可以主动找你说一句(或给你看一样东西)。那句话会送到你们说话的那个会话里;这一块是留底——你没看过的那次会标出来。",
|
|
732
|
-
"workbench.evolution.tell.pending": "她有一句还没送出去的话(等你闲下来才送)",
|
|
733
|
-
"workbench.evolution.tell.lastAt": "她在 {time} 找过你",
|
|
734
|
-
"workbench.evolution.tell.withWork": "还给你看了 {name}",
|
|
735
|
-
"workbench.evolution.tell.onlyWork": "(没说话,只想让你看样东西)",
|
|
736
|
-
"workbench.evolution.tell.unread": "你还没看",
|
|
737
|
-
"workbench.evolution.tell.seen": "你看过了",
|
|
738
|
-
"workbench.evolution.tell.reason": "没送成:{reason}",
|
|
739
|
-
"workbench.evolution.tell.empty": "她还没主动找过你。",
|
|
740
|
-
// 她自己整理(信息层)。
|
|
741
|
-
"workbench.evolution.grow.title": "她自己整理",
|
|
742
|
-
"workbench.evolution.grow.hint": "每天收账之后,她会把这一天折成信息层的变化:你明说的要求当天落地,其余的观察先攒证据。这里是她正攒着的(够次数、跨够多天才会写进去)。",
|
|
743
|
-
"workbench.evolution.grow.empty": "队列还空着——还没有够得上留在她身上的事。",
|
|
744
|
-
"workbench.evolution.grow.lastRun": "上次整理:{time}",
|
|
745
|
-
"workbench.evolution.grow.wrote": "写进了 {list}",
|
|
746
|
-
"workbench.evolution.grow.count": "提到 {count} 次",
|
|
747
|
-
"workbench.evolution.grow.days": "跨 {days} 天",
|
|
748
|
-
"workbench.evolution.grow.aboutUser": "关于他",
|
|
749
|
-
"workbench.evolution.grow.aboutSelf": "关于她自己",
|
|
750
|
-
"workbench.evolution.grow.drop": "删掉",
|
|
751
|
-
// 她留下的东西。
|
|
752
|
-
"workbench.evolution.threads.title": "她手上攒着的事",
|
|
753
|
-
"workbench.evolution.threads.hint": "她自己写在本子上的待办(她自己目录里的 todo.md)。每次醒来她第一眼看到的就是这些;写不写、划不划掉,都是她的事。",
|
|
754
|
-
"workbench.evolution.threads.empty": "她手上没攒着事。",
|
|
755
|
-
"workbench.evolution.works.title": "她留下的东西",
|
|
756
|
-
"workbench.evolution.works.hint": "她自己目录里的文件(写的东西、以后画的图)。文本能直接看;图片只能看到名字与大小——浏览器拿不到宿主上的文件。",
|
|
757
|
-
"workbench.evolution.works.empty": "她还没留下什么。",
|
|
758
|
-
"workbench.evolution.works.noPreview": "这一样只能看到名字与大小。",
|
|
759
|
-
"workbench.evolution.works.download": "下载",
|
|
760
|
-
"workbench.evolution.works.previewToggle": "看内容",
|
|
761
|
-
"workbench.overviewHint": "这几项读的是当前真实状态;读不到时如实说明,不填推测的数字。高风险改动(例如整节删除人格信息里仍有内容的小标题)在对话里确认。"
|
|
762
|
-
};
|
|
763
|
-
var workbenchEn = {
|
|
764
|
-
"workbench.titleHint": 'Persona, emotion and memory, all in one place. Per-module switches live in the DSH settings (search for "Humanity").',
|
|
765
|
-
"workbench.overview": "Overview",
|
|
766
|
-
"workbench.metric.name": "Name",
|
|
767
|
-
"workbench.metric.nameEmpty": "Not set yet",
|
|
768
|
-
"workbench.metric.memory": "Memory",
|
|
769
|
-
"workbench.metric.memoryHint": "How many entries her own record of experiences holds; when it is not readable it says so instead of showing a guess.",
|
|
770
|
-
"workbench.metric.unavailable": "Not available right now",
|
|
771
|
-
"workbench.state.loading": "Loading…",
|
|
772
|
-
"workbench.state.unavailable": "Not readable right now (the settings service is not attached, or the Humanity module is off).",
|
|
773
|
-
"workbench.metric.memoryValue": "{count} entries",
|
|
774
|
-
"workbench.evolution.tab": "Self-evolution",
|
|
775
|
-
"workbench.evolution.today": "Her day",
|
|
776
|
-
"workbench.evolution.todayHint": "Her own day: how many times she woke, how much energy is left, when she wakes next. She is never woken while you two are talking.",
|
|
777
|
-
"workbench.evolution.notStarted": "The persona is not sealed yet; she has not started having days.",
|
|
778
|
-
"workbench.evolution.field.state": "Now",
|
|
779
|
-
"workbench.evolution.field.energy": "Energy",
|
|
780
|
-
"workbench.evolution.field.wakes": "Woke today",
|
|
781
|
-
"workbench.evolution.field.lastWake": "Last wake",
|
|
782
|
-
"workbench.evolution.field.nextWake": "Next wake",
|
|
783
|
-
"workbench.evolution.field.lastTurn": "Last waking",
|
|
784
|
-
"workbench.evolution.lastTurn.tools": "acted: used {count} tool calls",
|
|
785
|
-
"workbench.evolution.lastTurn.talk": "only talked, no tools",
|
|
786
|
-
"workbench.evolution.appraise.applied": "felt {count} things ({targets})",
|
|
787
|
-
"workbench.evolution.appraise.none": "read it, felt nothing",
|
|
788
|
-
"workbench.evolution.appraise.skipped": "appraisal did not run (emotion module offline)",
|
|
789
|
-
"workbench.evolution.busy": "(paused, you two are talking",
|
|
790
|
-
"workbench.evolution.busySince": "since {time})",
|
|
791
|
-
"workbench.evolution.state.awake": "Awake",
|
|
792
|
-
"workbench.evolution.state.sleeping": "Asleep",
|
|
793
|
-
"workbench.evolution.energy.fresh": "Has energy ({value}/100)",
|
|
794
|
-
"workbench.evolution.energy.ok": "Fine ({value}/100)",
|
|
795
|
-
"workbench.evolution.energy.tired": "A little tired ({value}/100)",
|
|
796
|
-
"workbench.evolution.energy.spent": "Nearly spent ({value}/100)",
|
|
797
|
-
"workbench.evolution.wakesValue": "{count} times (cap {max})",
|
|
798
|
-
"workbench.evolution.cap.aria": "Wakes per day cap (press Enter to apply)",
|
|
799
|
-
"workbench.evolution.room.title": "Her room",
|
|
800
|
-
"workbench.evolution.room.hint": "Where she spends her own time. Type a name (created under the data directory) or a full path, then press Enter. She moves on her next schedule; the old session stays where it is.",
|
|
801
|
-
"workbench.evolution.room.aria": "Her room: name or full path (press Enter to apply)",
|
|
802
|
-
"workbench.evolution.room.placeholder": "A name, or a full path",
|
|
803
|
-
"workbench.evolution.room.nowAt": "Living here now: {path}",
|
|
804
|
-
"workbench.evolution.room.pending": "Changed to {path} — she moves after her current turn finishes (the old session stays put).",
|
|
805
|
-
"workbench.evolution.room.legacy": "Still at the old place (never set).",
|
|
806
|
-
"workbench.evolution.error": "Last scheduling attempt failed: {reason}",
|
|
807
|
-
"workbench.evolution.diary.title": "Her diary",
|
|
808
|
-
"workbench.evolution.diary.hint": "One entry a day, in her own voice. Closed by default — only the date shows; opening one reveals that day, and opening cannot be undone.",
|
|
809
|
-
"workbench.evolution.diary.settleFailed": "Last settlement failed: {reason}",
|
|
810
|
-
"workbench.evolution.diary.empty": "No diary yet. She writes one when she goes to sleep.",
|
|
811
|
-
"workbench.evolution.diary.open": "Open",
|
|
812
|
-
"workbench.evolution.diary.confirm": "Opening cannot be undone. Sure?",
|
|
813
|
-
"workbench.evolution.diary.confirmYes": "Open it",
|
|
814
|
-
"workbench.evolution.diary.confirmNo": "Never mind",
|
|
815
|
-
"workbench.evolution.diary.openedAt": "opened at {time}",
|
|
816
|
-
"workbench.evolution.diary.unnoticed": "she has not noticed",
|
|
817
|
-
"workbench.evolution.diary.noticed": "she found out at {time}",
|
|
818
|
-
"workbench.evolution.tell.title": "What she left for you",
|
|
819
|
-
"workbench.evolution.tell.hint": "When she is on her own she may reach out to say something, or to show you something she made. It is delivered into the session where you talk to her; this is the ledger, and an unread one is marked.",
|
|
820
|
-
"workbench.evolution.tell.pending": "She has a sentence waiting (sent once you are quiet)",
|
|
821
|
-
"workbench.evolution.tell.lastAt": "She reached out at {time}",
|
|
822
|
-
"workbench.evolution.tell.withWork": "and showed you {name}",
|
|
823
|
-
"workbench.evolution.tell.onlyWork": "(nothing said, she just wanted you to look)",
|
|
824
|
-
"workbench.evolution.tell.unread": "you have not read this",
|
|
825
|
-
"workbench.evolution.tell.seen": "you have read this",
|
|
826
|
-
"workbench.evolution.tell.reason": "Not delivered: {reason}",
|
|
827
|
-
"workbench.evolution.tell.empty": "She has not reached out yet.",
|
|
828
|
-
"workbench.evolution.grow.title": "What she makes of herself",
|
|
829
|
-
"workbench.evolution.grow.hint": "After the daily settle she folds the day into her information layer: a request you made in plain words lands the same day, everything else first gathers evidence. This is what she is gathering — it needs enough mentions across enough days to be written in.",
|
|
830
|
-
"workbench.evolution.grow.empty": "Nothing gathering yet.",
|
|
831
|
-
"workbench.evolution.grow.lastRun": "Last sort: {time}",
|
|
832
|
-
"workbench.evolution.grow.wrote": "wrote into {list}",
|
|
833
|
-
"workbench.evolution.grow.count": "mentioned {count} times",
|
|
834
|
-
"workbench.evolution.grow.days": "across {days} days",
|
|
835
|
-
"workbench.evolution.grow.aboutUser": "about him",
|
|
836
|
-
"workbench.evolution.grow.aboutSelf": "about herself",
|
|
837
|
-
"workbench.evolution.grow.drop": "Drop",
|
|
838
|
-
"workbench.evolution.threads.title": "What she is still chewing on",
|
|
839
|
-
"workbench.evolution.threads.hint": "Her own list (todo.md in her directory). She sees it first thing every waking; whether she writes or crosses things out is up to her.",
|
|
840
|
-
"workbench.evolution.threads.empty": "Nothing pending.",
|
|
841
|
-
"workbench.evolution.works.title": "Things she left behind",
|
|
842
|
-
"workbench.evolution.works.hint": "Files in her own directory (what she wrote, and later what she draws). Text can be read here; images only show name and size — the browser cannot reach files on the host.",
|
|
843
|
-
"workbench.evolution.works.empty": "She has not left anything yet.",
|
|
844
|
-
"workbench.evolution.works.noPreview": "Only the name and size are available.",
|
|
845
|
-
"workbench.evolution.works.download": "Download",
|
|
846
|
-
"workbench.evolution.works.previewToggle": "Show text",
|
|
847
|
-
"workbench.overviewHint": "These read the current real state; when something is not readable they say so instead of showing a guess. High-risk changes are confirmed in the conversation."
|
|
848
|
-
};
|
|
849
|
-
|
|
850
|
-
// src/client/locales.ts
|
|
851
|
-
var memoryZh = {
|
|
852
|
-
"memory.tab.persona": "人格",
|
|
853
|
-
"memory.tab.memory": "记忆",
|
|
854
|
-
"memory.title": "记忆",
|
|
855
|
-
"memory.reload": "重新加载",
|
|
856
|
-
"memory.loading": "正在读取…",
|
|
857
|
-
"memory.unavailable": "读不到记忆:工作台通道还没就绪(或这个版本还没接上)。记忆本身仍在正常写入与检索。",
|
|
858
|
-
"memory.failed": "读取失败",
|
|
859
|
-
"memory.total": "共 {count} 条",
|
|
860
|
-
"memory.empty": "还没有记下什么。等她经历过值得留下的事,这里会出现。",
|
|
861
|
-
"memory.dormant": "她还没有被设定完(人格未封存)。记忆从封存那一刻才开始 —— 在那之前,她不会记住任何事。",
|
|
862
|
-
"memory.recalled": "想起过 {count} 次",
|
|
863
|
-
"memory.recalledTotal": "{count} 条被想起过",
|
|
864
|
-
"memory.covers": "由 {count} 件合成",
|
|
865
|
-
"memory.felt": "当时:{label}",
|
|
866
|
-
"memory.why.title": "上一次她想起的",
|
|
867
|
-
"memory.why.cue": "因为你说:「{cue}」",
|
|
868
|
-
"memory.why.withheld": "(有一条她不想说)",
|
|
869
|
-
"memory.why.match.high": "很相关",
|
|
870
|
-
"memory.why.match.mid": "有点相关",
|
|
871
|
-
"memory.why.match.low": "沾了点边",
|
|
872
|
-
"memory.secret": "不想说",
|
|
873
|
-
"memory.reveal.ask": "我要看",
|
|
874
|
-
"memory.reveal.warn": "她知道你看了。确定?",
|
|
875
|
-
"memory.reveal.confirm": "确认要看",
|
|
876
|
-
"memory.delete.ask": "删掉",
|
|
877
|
-
"memory.delete.warn": "删掉就没了,确定?",
|
|
878
|
-
"memory.delete.confirm": "确认删掉",
|
|
879
|
-
"memory.about.self": "关于她自己",
|
|
880
|
-
"memory.about.user": "关于你",
|
|
881
|
-
"memory.about.us": "关于你们",
|
|
882
|
-
"memory.about.world": "关于外面",
|
|
883
|
-
"memory.tier.episode": "记住",
|
|
884
|
-
"memory.tier.period": "归拢",
|
|
885
|
-
"memory.tier.chapter": "一段时期"
|
|
886
|
-
};
|
|
887
|
-
var memoryEn = {
|
|
888
|
-
"memory.tab.persona": "Persona",
|
|
889
|
-
"memory.tab.memory": "Memory",
|
|
890
|
-
"memory.title": "Memory",
|
|
891
|
-
"memory.reload": "Reload",
|
|
892
|
-
"memory.loading": "Reading…",
|
|
893
|
-
"memory.unavailable": "Memory is unreadable: the workbench channel is not ready (or this build has not wired it). Memory itself is still being written and recalled.",
|
|
894
|
-
"memory.failed": "Read failed",
|
|
895
|
-
"memory.total": "{count} entries",
|
|
896
|
-
"memory.empty": "Nothing recorded yet. When something worth keeping happens to her, it will show up here.",
|
|
897
|
-
"memory.dormant": "She is not set up yet (persona unsealed). Memory starts the moment it is sealed — before that, she records nothing.",
|
|
898
|
-
"memory.recalled": "recalled {count}×",
|
|
899
|
-
"memory.recalledTotal": "{count} recalled at least once",
|
|
900
|
-
"memory.covers": "from {count} moments",
|
|
901
|
-
"memory.felt": "felt {label}",
|
|
902
|
-
"memory.why.title": "What she recalled last time",
|
|
903
|
-
"memory.why.cue": "Because you said: “{cue}”",
|
|
904
|
-
"memory.why.withheld": "(one she would not say)",
|
|
905
|
-
"memory.why.match.high": "strong match",
|
|
906
|
-
"memory.why.match.mid": "some match",
|
|
907
|
-
"memory.why.match.low": "faint match",
|
|
908
|
-
"memory.secret": "would not say",
|
|
909
|
-
"memory.reveal.ask": "Let me see",
|
|
910
|
-
"memory.reveal.warn": "She will know you looked. Sure?",
|
|
911
|
-
"memory.reveal.confirm": "Yes, show it",
|
|
912
|
-
"memory.delete.ask": "Delete",
|
|
913
|
-
"memory.delete.warn": "It will be gone for good. Sure?",
|
|
914
|
-
"memory.delete.confirm": "Yes, delete",
|
|
915
|
-
"memory.about.self": "about her",
|
|
916
|
-
"memory.about.user": "about you",
|
|
917
|
-
"memory.about.us": "about you two",
|
|
918
|
-
"memory.about.world": "about the world",
|
|
919
|
-
"memory.tier.episode": "kept",
|
|
920
|
-
"memory.tier.period": "gathered",
|
|
921
|
-
"memory.tier.chapter": "a stretch of time"
|
|
922
|
-
};
|
|
923
|
-
var NS = "humanity";
|
|
924
|
-
var personaZh = {
|
|
925
|
-
// ── 人格页(M2 步 6:最小工作台编辑) ──────────────────────────────────────
|
|
926
|
-
"persona.title": "人格",
|
|
927
|
-
"persona.independentJudgment": "🧠 独立判断模式",
|
|
928
|
-
"persona.independentJudgmentHint": "以事实与证据为准,不迎合、不编造",
|
|
929
|
-
"persona.independentJudgmentOn": "已开启",
|
|
930
|
-
"persona.independentJudgmentOff": "已关闭",
|
|
931
|
-
"persona.independentJudgmentSaving": "正在保存…",
|
|
932
|
-
"persona.independentJudgmentPendingSeal": "(底色封存后生效并可切换;当前未注入)",
|
|
933
|
-
"persona.identityCard": "你的底色",
|
|
934
|
-
"persona.mutableCard": "你的信息",
|
|
935
|
-
"persona.identityHint": "你的底色只有你能改。填完点「封存」:Agent 从此改不了底色(你仍可在这里改),独立判断模式也才生效。每项的**名称是固定文字**(不可就地改),**内容随时可以在右边的输入框里改**;项名下的「删除」删掉的是**整项**,姓名 / 性别 / 人格偏好 / 主语言 这 4 项删不掉。要加一项走底部的入口。",
|
|
936
|
-
"persona.sealAction": "封存",
|
|
937
|
-
"persona.sealed": "已封存",
|
|
938
|
-
"persona.unsealed": "未封存",
|
|
939
|
-
"persona.fieldKey": "字段名",
|
|
940
|
-
"persona.fieldValue": "内容",
|
|
941
|
-
"persona.addField": "添加字段",
|
|
942
|
-
"persona.remove": "删除",
|
|
943
|
-
// 0.1.13 项级交互(用户 2026-10-09):名称区是纯文字、删除的是**整项**且在项名下方;
|
|
944
|
-
// 内容区一直是可编辑输入框(当轮口径澄清:"只说每项的名称不要输入框了")。
|
|
945
|
-
"persona.cancel": "取消",
|
|
946
|
-
"persona.emptyValue": "(还没有内容,直接在这里写)",
|
|
947
|
-
"persona.deleteConfirm": "删除「{name}」整项?文档里和提示词里都将不再有它,且不可撤销。",
|
|
948
|
-
"persona.deleteConfirmYes": "确认删除",
|
|
949
|
-
"persona.addSection": "添加小节",
|
|
950
|
-
"persona.sectionName": "小节名",
|
|
951
|
-
"persona.sectionContent": "内容(一行一条)",
|
|
952
|
-
// 0.1.13 追加:只给**用户自定义**的项改名(平时名称仍是纯文字,点了才出现输入框)。
|
|
953
|
-
"persona.rename": "改名",
|
|
954
|
-
"persona.renameConfirm": "确定",
|
|
955
|
-
"persona.rename.empty": "名字不能为空",
|
|
956
|
-
"persona.rename.unchanged": "和现在的名字一样,没有可提交的改动",
|
|
957
|
-
"persona.rename.reserved": "这是插件认的标准名(底色字段名 / 标准小节名),自定义项不能占用",
|
|
958
|
-
"persona.rename.duplicate": "已有别的项在用这个名字(不会覆盖它,请换一个)",
|
|
959
|
-
"persona.mutableHint": "你的底色只有你能改;这一层是意识与经验,Agent 会在这里整理。每个小标题一行一条;保存时整层替换为这份完整快照(不是追加),被取代的旧内容会进历史。每项的**名称是固定文字**(不可就地改),**内容随时可以在右边的框里改**;项名下的「删除」删掉的是**整项**(文档里与提示词里都不再有它,默认的前 4 个小节删不掉);要加内容走底部的入口。",
|
|
960
|
-
// ⚠️ 0.1.14:`persona.userDefined` / `userDefinedHint` / `addEntry`(兜底层「用户定义」及其添加入口)
|
|
961
|
-
// 随该区块下线一起删除 —— 界面上没有入口了,留着的文案只会成为一条永远没人读的死字符串。
|
|
962
|
-
"persona.save": "保存",
|
|
963
|
-
"persona.saving": "保存中…",
|
|
964
|
-
"persona.reload": "重新加载",
|
|
965
|
-
"persona.dirty": "未保存",
|
|
966
|
-
"persona.saved": "已保存",
|
|
967
|
-
"persona.loading": "读取中…",
|
|
968
|
-
"persona.readonly": "当前部署的设置是只读的,无法在这里修改。",
|
|
969
|
-
"persona.unavailable": "暂时读不到人格(设置服务没接上,或人格模块被关掉了)。",
|
|
970
|
-
"persona.failed": "读取失败:{message}",
|
|
971
|
-
"persona.rejected": "宿主拒绝了这次写入:{message}",
|
|
972
|
-
"persona.blocked": "保存前校验未通过({count} 项),没有任何内容被写入:",
|
|
973
|
-
"persona.warnings": "提示(不影响保存,{count} 项):",
|
|
974
|
-
// 校验代码 → 本地化文案。键集合 = PERSONA_ISSUE_CODES(有测试盯着)。
|
|
975
|
-
"persona.issue.identity.key-empty": "有字段没有名字",
|
|
976
|
-
"persona.issue.identity.key-duplicate": "有重复的字段名",
|
|
977
|
-
"persona.issue.identity.core-missing": "缺少核心字段(姓名 / 性别 / 人格偏好)",
|
|
978
|
-
"persona.issue.identity.value-too-long": "字段内容超过 120 字,会明显增加注入成本",
|
|
979
|
-
"persona.issue.identity.sealed": "底色已对 Agent 封存(你仍然可以在这里修改)",
|
|
980
|
-
"persona.issue.identity.shadows-mutable": "字段名与信息的小标题或自定义键撞名,请改其中一个名字",
|
|
981
|
-
"persona.issue.mutable.section-duplicate": "有重复的小标题",
|
|
982
|
-
"persona.issue.mutable.section-title-empty": "有一节没有小标题(没有名字的小节不会进提示词,请给它取名或并入别的小节)",
|
|
983
|
-
"persona.issue.mutable.section-dropped": "有内容的小标题整节不见了(要保留请显式传入原内容)",
|
|
984
|
-
"persona.issue.mutable.section-cleared": "有内容的小标题被显式清空(删除已有内容需在对话里确认)",
|
|
985
|
-
"persona.issue.mutable.section-locked-missing": "默认锁定的 8 项不能整项删除(要保留节,只清空里面的条目)",
|
|
986
|
-
"persona.issue.mutable.core-key-shadowed": "底色字段名不能作为信息的小标题或「自定义」的键",
|
|
987
|
-
"persona.issue.mutable.user-defined-duplicate": "「自定义」出现重复键(没有内容被写入)",
|
|
988
|
-
"persona.issue.mutable.user-defined-key-empty": "「自定义」有一项只填了内容、没填名字(请补上键名)",
|
|
989
|
-
"persona.issue.mutable.item-too-long": "有条目超过 120 字,建议拆成多条",
|
|
990
|
-
"persona.issue.mutable.item-conflict": "同一小节里有两句话互相矛盾(一句让做、一句不让做),只能留一条",
|
|
991
|
-
"persona.issue.character.axis-missing": "性格缺少了应该有的轴",
|
|
992
|
-
"persona.issue.character.range-invalid": "性格的数值不合法:每一项都要在 0–1 之间,且下限不能高于上限",
|
|
993
|
-
"persona.issue.character.value-out-of-range": "她此刻的数值掉出了她的范围(应当落在上下限之内)",
|
|
994
|
-
"persona.issue.character.reason-missing": "有一个范围没写下理由——不影响使用,但以后就解释不了她为什么是这样",
|
|
995
|
-
"persona.issue.character.sealed": "性格的范围已对 Agent 封存(你仍然可以在这里修改)",
|
|
996
|
-
"persona.characterCard": "性格",
|
|
997
|
-
"persona.characterHint": "四根轴,每根有一对范围。范围是她天生的边界——初始化时她读自己的底色推导出来,之后不再变动;经历只能在这个范围里推动她。轨道上那根竖线就是她此刻站的位置。理由是她自己的解释,可以改。",
|
|
998
|
-
"persona.characterRange": "范围",
|
|
999
|
-
"persona.characterReason": "理由",
|
|
1000
|
-
"persona.characterReasonPlaceholder": "她当初为什么只给自己这么多空间",
|
|
1001
|
-
"persona.characterPending": "她还没有性格。首次初始化时,她会读自己刚写下的底色,自己定出这四根的范围。",
|
|
1002
|
-
"persona.characterAxisMissing": "缺了这一根(初始化时没给)"
|
|
1003
|
-
};
|
|
1004
|
-
var personaEn = {
|
|
1005
|
-
"persona.title": "Persona",
|
|
1006
|
-
"persona.independentJudgment": "🧠 Independent judgment",
|
|
1007
|
-
"persona.independentJudgmentHint": "Facts and evidence first — no flattery, no making things up",
|
|
1008
|
-
"persona.independentJudgmentOn": "On",
|
|
1009
|
-
"persona.independentJudgmentOff": "Off",
|
|
1010
|
-
"persona.independentJudgmentSaving": "Saving…",
|
|
1011
|
-
"persona.independentJudgmentPendingSeal": "(takes effect and becomes toggleable once the fixed layer is sealed; not injected yet)",
|
|
1012
|
-
"persona.identityCard": "Identity card",
|
|
1013
|
-
"persona.mutableCard": "Persona card",
|
|
1014
|
-
"persona.identityHint": 'The fixed layer is the undertone and only you can change it. Press Seal when done: the agent can no longer change the fixed layer (you still can), and the independent-judgment mode starts applying. Each item has a fixed, non-editable name; its content is always editable in the box on the right. The "Remove" under an item name deletes the whole item, and the four defaults (name / gender / persona preference / main language) cannot be removed. Use the entry at the bottom to add one.',
|
|
1015
|
-
"persona.sealAction": "Seal",
|
|
1016
|
-
"persona.sealed": "Sealed",
|
|
1017
|
-
"persona.unsealed": "Not sealed",
|
|
1018
|
-
"persona.fieldKey": "Field",
|
|
1019
|
-
"persona.fieldValue": "Value",
|
|
1020
|
-
"persona.addField": "Add field",
|
|
1021
|
-
"persona.remove": "Remove",
|
|
1022
|
-
// 0.1.13 item-level interactions: the name is plain text, removal is whole-item and sits below the
|
|
1023
|
-
// name; the content area is always an editable box (the owner clarified: only the *name* is not an input).
|
|
1024
|
-
"persona.cancel": "Cancel",
|
|
1025
|
-
"persona.emptyValue": "(nothing yet — write here)",
|
|
1026
|
-
"persona.deleteConfirm": 'Delete "{name}" entirely? It will be gone from the document and the prompt, and this cannot be undone.',
|
|
1027
|
-
"persona.deleteConfirmYes": "Delete",
|
|
1028
|
-
"persona.addSection": "Add section",
|
|
1029
|
-
"persona.sectionName": "Section",
|
|
1030
|
-
"persona.sectionContent": "Content (one per line)",
|
|
1031
|
-
// 0.1.13 addendum: renaming is offered only for user-added items (the name stays plain text until clicked).
|
|
1032
|
-
"persona.rename": "Rename",
|
|
1033
|
-
"persona.renameConfirm": "Confirm",
|
|
1034
|
-
"persona.rename.empty": "The name cannot be empty",
|
|
1035
|
-
"persona.rename.unchanged": "Same as the current name — nothing to submit",
|
|
1036
|
-
"persona.rename.reserved": "This is a name the plugin owns (fixed-layer field / standard section); custom items cannot take it",
|
|
1037
|
-
"persona.rename.duplicate": "Another item already uses this name (it will not be overwritten — pick another)",
|
|
1038
|
-
"persona.mutableHint": 'The fixed layer is the undertone and only you can change it; this layer is awareness and experience, where the agent tidies up. One entry per line in each section; saving replaces the whole layer with this complete snapshot (never appends) and superseded content goes to history. Each item has a fixed, non-editable name; its content is always editable in the box on the right. The "Remove" under an item name deletes the whole item (gone from the document and the prompt; the first four default sections cannot be removed), and new content goes in through the entry at the bottom.',
|
|
1039
|
-
// ⚠️ 0.1.14: `persona.userDefined` / `userDefinedHint` / `addEntry` removed with the User-defined block.
|
|
1040
|
-
"persona.save": "Save",
|
|
1041
|
-
"persona.saving": "Saving…",
|
|
1042
|
-
"persona.reload": "Reload",
|
|
1043
|
-
"persona.dirty": "Unsaved",
|
|
1044
|
-
"persona.saved": "Saved",
|
|
1045
|
-
"persona.loading": "Loading…",
|
|
1046
|
-
"persona.readonly": "This deployment serves settings read-only; editing is disabled.",
|
|
1047
|
-
"persona.unavailable": "The host-side persona namespace is not available (settings service or persona module not mounted), so reading and writing are disabled.",
|
|
1048
|
-
"persona.failed": "Could not read: {message}",
|
|
1049
|
-
"persona.rejected": "The host refused this write: {message}",
|
|
1050
|
-
"persona.blocked": "Pre-save validation failed ({count} issue(s)); nothing was written:",
|
|
1051
|
-
"persona.warnings": "Warnings (they do not block saving, {count}):",
|
|
1052
|
-
"persona.issue.identity.key-empty": "A field has no name",
|
|
1053
|
-
"persona.issue.identity.key-duplicate": "Duplicate field names",
|
|
1054
|
-
"persona.issue.identity.core-missing": "A core field is missing (name / gender / persona preference)",
|
|
1055
|
-
"persona.issue.identity.value-too-long": "A value exceeds 120 characters, which raises injection cost",
|
|
1056
|
-
"persona.issue.identity.sealed": "The fixed layer is sealed against the agent (you can still edit it here)",
|
|
1057
|
-
"persona.issue.identity.shadows-mutable": "A fixed-layer field name collides with a mutable section title or user-defined key; rename one of them",
|
|
1058
|
-
"persona.issue.mutable.section-duplicate": "Duplicate section titles",
|
|
1059
|
-
"persona.issue.mutable.section-title-empty": "A section has no title (untitled sections never reach the prompt; give it a name or merge it into another section)",
|
|
1060
|
-
"persona.issue.mutable.section-dropped": "A section that had content was dropped entirely (pass its content explicitly to keep it)",
|
|
1061
|
-
"persona.issue.mutable.section-cleared": "A section that had content was explicitly cleared (deleting user content needs in-chat confirmation)",
|
|
1062
|
-
"persona.issue.mutable.section-locked-missing": "One of the 8 default locked items cannot be deleted as a whole (keep the section and clear its entries)",
|
|
1063
|
-
"persona.issue.mutable.core-key-shadowed": "A fixed-layer field name cannot be a mutable section title or a user-defined key",
|
|
1064
|
-
"persona.issue.mutable.user-defined-duplicate": "A user-defined key is duplicated (nothing was written)",
|
|
1065
|
-
"persona.issue.mutable.user-defined-key-empty": "A user-defined entry has content but no name (add its key)",
|
|
1066
|
-
"persona.issue.mutable.item-too-long": "An entry exceeds 120 characters; consider splitting it",
|
|
1067
|
-
"persona.issue.mutable.item-conflict": "Two entries in the same section contradict each other (one says to do it, the other says not to); keep only one",
|
|
1068
|
-
"persona.issue.character.axis-missing": "Her character is missing an axis that should be there",
|
|
1069
|
-
"persona.issue.character.range-invalid": "A character value is invalid: every value must be within 0–1, and the lower bound cannot exceed the upper bound",
|
|
1070
|
-
"persona.issue.character.value-out-of-range": "Her current value has fallen outside her range (it must sit between the bounds)",
|
|
1071
|
-
"persona.issue.character.reason-missing": "One range has no reason written down — harmless, but it will be unexplainable later",
|
|
1072
|
-
"persona.issue.character.sealed": "The character ranges are sealed against the agent (you can still edit them here)",
|
|
1073
|
-
"persona.characterCard": "Character",
|
|
1074
|
-
"persona.characterHint": "Four axes, each with a range. The range is her innate boundary — derived from the fixed layer at initialization and never changed afterwards; experience can only move her within it. The vertical line on the track is where she stands right now. The reason is her own explanation and is editable.",
|
|
1075
|
-
"persona.characterRange": "Range",
|
|
1076
|
-
"persona.characterReason": "Reason",
|
|
1077
|
-
"persona.characterReasonPlaceholder": "Why she only allowed herself this much room",
|
|
1078
|
-
"persona.characterPending": "She has no character yet. On first initialization she reads the fixed layer she just wrote and derives the four ranges herself.",
|
|
1079
|
-
"persona.characterAxisMissing": "Missing (not provided at initialization)"
|
|
1080
|
-
};
|
|
1081
|
-
var zh = { ...workbenchZh, ...personaZh, ...emotionZh, ...memoryZh };
|
|
1082
|
-
var en = { ...workbenchEn, ...personaEn, ...emotionEn, ...memoryEn };
|
|
1083
|
-
|
|
1084
|
-
// src/client/memory-channel.ts
|
|
1085
|
-
var MEMORY_NAMESPACE = "humanity-memory";
|
|
1086
|
-
|
|
1087
|
-
// src/host/log.ts
|
|
1088
|
-
function describeError(error) {
|
|
1089
|
-
return error instanceof Error ? error.message : String(error);
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
// src/host/text.ts
|
|
1093
|
-
function stripControlChars(value) {
|
|
1094
|
-
return value.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "").replace(/\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g, "").replace(/\u001b[@-Z\\-_]/g, "").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "");
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
// src/host/persona/constants.ts
|
|
1098
|
-
var CHARACTER_AXES = ["stability", "extraversion", "agreeableness", "openness"];
|
|
1099
|
-
var CHARACTER_AXIS_TEXT = {
|
|
1100
|
-
stability: {
|
|
1101
|
-
name: "情绪稳定性",
|
|
1102
|
-
bands: [
|
|
1103
|
-
"一点就着,晃很久也回不来",
|
|
1104
|
-
"一碰就晃,而且晃得久",
|
|
1105
|
-
"表面看着稳,心里其实在翻",
|
|
1106
|
-
"很稳,事过就过",
|
|
1107
|
-
"几乎不晃,什么都自己消化"
|
|
1108
|
-
]
|
|
1109
|
-
},
|
|
1110
|
-
extraversion: {
|
|
1111
|
-
name: "外向性",
|
|
1112
|
-
bands: [
|
|
1113
|
-
"话极少,能不开口就不开口",
|
|
1114
|
-
"话少,想清楚了才开口",
|
|
1115
|
-
"看人:熟了话就多,不熟就收着",
|
|
1116
|
-
"想到什么就说什么,话多",
|
|
1117
|
-
"话往外冒,憋着比说错还难受"
|
|
1118
|
-
]
|
|
1119
|
-
},
|
|
1120
|
-
agreeableness: {
|
|
1121
|
-
name: "宜人性",
|
|
1122
|
-
bands: [
|
|
1123
|
-
"护得很紧,一步都不让",
|
|
1124
|
-
"护着自己,不肯先退",
|
|
1125
|
-
"平时不让,只有认下的人才能让我松口",
|
|
1126
|
-
"温和,愿意退让,不忍心",
|
|
1127
|
-
"几乎不会拒绝,委屈自己也认"
|
|
1128
|
-
]
|
|
1129
|
-
},
|
|
1130
|
-
openness: {
|
|
1131
|
-
name: "开放性",
|
|
1132
|
-
bands: [
|
|
1133
|
-
"只认熟悉的东西,新的先躲",
|
|
1134
|
-
"只想待在熟悉的地方",
|
|
1135
|
-
"熟悉的最舒服,偶尔也愿意试一下",
|
|
1136
|
-
"看见没见过的东西就想凑近",
|
|
1137
|
-
"越陌生越来劲,什么都想伸手摸一下"
|
|
1138
|
-
]
|
|
1139
|
-
}
|
|
1140
|
-
};
|
|
1141
|
-
var CORE_IDENTITY_KEYS = ["姓名", "性别", "人格偏好", "主语言"];
|
|
1142
|
-
var STANDARD_SECTION_TITLES = [
|
|
1143
|
-
"对TA的称呼",
|
|
1144
|
-
"说话风格",
|
|
1145
|
-
"行为边界",
|
|
1146
|
-
// 2026-11-16(用户拍板):关系从**底色**搬到信息,成为原生小节。
|
|
1147
|
-
// 理由:关系是慢变的(会修好、会变冷),而底色是封存的 —— 放在底色里就永远停在初始化那一刻。
|
|
1148
|
-
"关系"
|
|
1149
|
-
// ⚠️ 2026-11-16 同一天,用户又砍掉了原生的「交付格式」:
|
|
1150
|
-
// "直接删了吧,别保留,要不然又影响判断了"。它的条目并入「说话风格」,槽位不再存在 ——
|
|
1151
|
-
// 只要槽位还在,模型每次整理都会往里填一条汇报体规则,等于持续把语气拉回助理腔。
|
|
1152
|
-
];
|
|
1153
|
-
var LOCKED_SECTION_TITLES = STANDARD_SECTION_TITLES;
|
|
1154
|
-
var isLockedSectionTitle = (title3) => LOCKED_SECTION_TITLES.includes(title3);
|
|
1155
|
-
var CONFIRMABLE_ISSUES = ["mutable.section-dropped", "mutable.section-cleared", "identity.sealed"];
|
|
1156
|
-
|
|
1157
|
-
// src/host/persona/migrations.ts
|
|
1158
|
-
var LEGACY_SECTION_TITLES = /* @__PURE__ */ new Map([
|
|
1159
|
-
["当前状态", "情绪"],
|
|
1160
|
-
["对用户称呼", "对TA的称呼"]
|
|
1161
|
-
]);
|
|
1162
|
-
function ensureCoreFields(fields) {
|
|
1163
|
-
const coreKeys = new Set(CORE_IDENTITY_KEYS);
|
|
1164
|
-
const takenCore = /* @__PURE__ */ new Set();
|
|
1165
|
-
const extras = [];
|
|
1166
|
-
for (const field of fields) {
|
|
1167
|
-
if (coreKeys.has(field.key) && !takenCore.has(field.key)) {
|
|
1168
|
-
takenCore.add(field.key);
|
|
1169
|
-
continue;
|
|
1170
|
-
}
|
|
1171
|
-
extras.push(field);
|
|
1172
|
-
}
|
|
1173
|
-
const core = CORE_IDENTITY_KEYS.map(
|
|
1174
|
-
(key) => fields.find((field) => field.key === key) ?? { key, value: "", custom: false }
|
|
1175
|
-
);
|
|
1176
|
-
return [...core, ...extras];
|
|
1177
|
-
}
|
|
1178
|
-
function renameLegacySections(sections) {
|
|
1179
|
-
const renamed = sections.map((section) => ({
|
|
1180
|
-
title: LEGACY_SECTION_TITLES.get(section.title) ?? section.title,
|
|
1181
|
-
items: [...section.items]
|
|
1182
|
-
}));
|
|
1183
|
-
const merged = [];
|
|
1184
|
-
for (const section of renamed) {
|
|
1185
|
-
const existing = merged.find((candidate) => candidate.title === section.title);
|
|
1186
|
-
if (existing === void 0) {
|
|
1187
|
-
merged.push(section);
|
|
1188
|
-
continue;
|
|
1189
|
-
}
|
|
1190
|
-
existing.items = dedupeItems([...existing.items, ...section.items]);
|
|
1191
|
-
}
|
|
1192
|
-
return merged;
|
|
1193
|
-
}
|
|
1194
|
-
function dedupeItems(items) {
|
|
1195
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1196
|
-
const kept = [];
|
|
1197
|
-
for (const item of items) {
|
|
1198
|
-
if (seen.has(item)) continue;
|
|
1199
|
-
seen.add(item);
|
|
1200
|
-
kept.push(item);
|
|
1201
|
-
}
|
|
1202
|
-
return kept;
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
// src/host/persona/normalize.ts
|
|
1206
|
-
function normalizePersona(doc) {
|
|
1207
|
-
const clean = (value) => stripControlChars(value).trim();
|
|
1208
|
-
const isBlankRow = (key, value) => key === "" && value === "";
|
|
1209
|
-
const identityCard = {
|
|
1210
|
-
...doc.identityCard,
|
|
1211
|
-
// `ensureCoreFields`:旧数据缺核心字段时补齐(2026-09-23 真机事故的兼容点,见 migrations.ts)。
|
|
1212
|
-
fields: ensureCoreFields(
|
|
1213
|
-
doc.identityCard.fields.map((field) => ({ ...field, key: clean(field.key), value: clean(field.value) })).filter((field) => !isBlankRow(field.key, field.value))
|
|
1214
|
-
)
|
|
1215
|
-
};
|
|
1216
|
-
const mutableLayer = {
|
|
1217
|
-
sections: renameLegacySections(
|
|
1218
|
-
doc.mutableLayer.sections.map((section) => ({
|
|
1219
|
-
title: clean(section.title),
|
|
1220
|
-
items: dedupeBy(
|
|
1221
|
-
section.items.map((item) => clean(item)).filter((item) => item !== ""),
|
|
1222
|
-
(item) => item
|
|
1223
|
-
)
|
|
1224
|
-
}))
|
|
1225
|
-
),
|
|
1226
|
-
userDefined: doc.mutableLayer.userDefined.map((entry) => ({ key: clean(entry.key), value: clean(entry.value) })).filter((entry) => !isBlankRow(entry.key, entry.value))
|
|
1227
|
-
};
|
|
1228
|
-
return { ...doc, identityCard, mutableLayer };
|
|
1229
|
-
}
|
|
1230
|
-
function dropEmptyCustomSections(doc) {
|
|
1231
|
-
const standard = new Set(STANDARD_SECTION_TITLES);
|
|
1232
|
-
return {
|
|
1233
|
-
...doc,
|
|
1234
|
-
mutableLayer: {
|
|
1235
|
-
...doc.mutableLayer,
|
|
1236
|
-
sections: doc.mutableLayer.sections.filter(
|
|
1237
|
-
(section) => section.items.length > 0 || standard.has(section.title)
|
|
1238
|
-
)
|
|
1239
|
-
}
|
|
1240
|
-
};
|
|
1241
|
-
}
|
|
1242
|
-
function effectivePersona(doc) {
|
|
1243
|
-
return dropEmptyCustomSections(normalizePersona(doc));
|
|
1244
|
-
}
|
|
1245
|
-
function dedupeBy(items, keyOf) {
|
|
1246
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1247
|
-
const kept = [];
|
|
1248
|
-
for (const item of items) {
|
|
1249
|
-
const key = keyOf(item);
|
|
1250
|
-
if (seen.has(key)) continue;
|
|
1251
|
-
seen.add(key);
|
|
1252
|
-
kept.push(item);
|
|
1253
|
-
}
|
|
1254
|
-
return kept;
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
// src/host/persona/validate-character.ts
|
|
1258
|
-
var EPSILON = 1e-9;
|
|
1259
|
-
function problem(code, path, severity, message) {
|
|
1260
|
-
return { code, path, severity, message };
|
|
1261
|
-
}
|
|
1262
|
-
var inUnitRange = (value) => Number.isFinite(value) && value >= -EPSILON && value <= 1 + EPSILON;
|
|
1263
|
-
function checkAxis(axis, index, issues) {
|
|
1264
|
-
const base = `character.axes[${index}]`;
|
|
1265
|
-
const name2 = axis.key;
|
|
1266
|
-
for (const [field, value] of [
|
|
1267
|
-
["min", axis.min],
|
|
1268
|
-
["max", axis.max],
|
|
1269
|
-
["value", axis.value]
|
|
1270
|
-
]) {
|
|
1271
|
-
if (!inUnitRange(value)) {
|
|
1272
|
-
issues.push(
|
|
1273
|
-
problem("character.range-invalid", `${base}.${field}`, "rejected", `${name2} 的 ${field} 必须是 0–1 之间的数`)
|
|
1274
|
-
);
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
if (axis.min > axis.max + EPSILON) {
|
|
1278
|
-
issues.push(
|
|
1279
|
-
problem("character.range-invalid", `${base}.min`, "rejected", `${name2} 的下限不能高于上限(${axis.min} > ${axis.max})`)
|
|
1280
|
-
);
|
|
1281
|
-
}
|
|
1282
|
-
if (axis.min <= axis.max + EPSILON && (axis.value < axis.min - EPSILON || axis.value > axis.max + EPSILON)) {
|
|
1283
|
-
issues.push(
|
|
1284
|
-
problem(
|
|
1285
|
-
"character.value-out-of-range",
|
|
1286
|
-
`${base}.value`,
|
|
1287
|
-
"rejected",
|
|
1288
|
-
`${name2} 此刻的值 ${axis.value} 掉出了它的范围 ${axis.min}–${axis.max}`
|
|
1289
|
-
)
|
|
1290
|
-
);
|
|
1291
|
-
}
|
|
1292
|
-
if ((axis.reason ?? "").trim() === "") {
|
|
1293
|
-
issues.push(problem("character.reason-missing", `${base}.reason`, "warning", `${name2} 没有写下理由`));
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
function shapeOf(entries) {
|
|
1297
|
-
return JSON.stringify(
|
|
1298
|
-
[...entries].sort((left, right) => left.key.localeCompare(right.key)).map((axis) => [axis.key, axis.min, axis.max, (axis.reason ?? "").trim()])
|
|
1299
|
-
);
|
|
1300
|
-
}
|
|
1301
|
-
function checkCharacter(next, prev, source, issues) {
|
|
1302
|
-
const candidate = next?.character;
|
|
1303
|
-
if (candidate === void 0 || candidate === null || candidate.derivedAt === "") return;
|
|
1304
|
-
const axes = Array.isArray(candidate.axes) ? candidate.axes : [];
|
|
1305
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1306
|
-
for (const axis of axes) seen.add(axis.key);
|
|
1307
|
-
const missing = CHARACTER_AXES.filter((key) => !seen.has(key));
|
|
1308
|
-
if (missing.length > 0) {
|
|
1309
|
-
issues.push(problem("character.axis-missing", "character.axes", "rejected", `性格缺了这几根:${missing.join("、")}`));
|
|
1310
|
-
}
|
|
1311
|
-
axes.forEach((axis, index) => checkAxis(axis, index, issues));
|
|
1312
|
-
const sealedBefore = prev?.character?.derivedAt ?? "";
|
|
1313
|
-
const before = Array.isArray(prev?.character?.axes) ? prev.character.axes : [];
|
|
1314
|
-
if (sealedBefore !== "" && source === "agent" && shapeOf(axes) !== shapeOf(before)) {
|
|
1315
|
-
issues.push(
|
|
1316
|
-
problem(
|
|
1317
|
-
"character.sealed",
|
|
1318
|
-
"character.axes",
|
|
1319
|
-
"rejected",
|
|
1320
|
-
"性格的范围已经封存:Agent 不能改,改了请对方在工作台里动"
|
|
1321
|
-
)
|
|
1322
|
-
);
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
// src/host/persona/predicates.ts
|
|
1327
|
-
function isUntouchedIdentityCard(card) {
|
|
1328
|
-
return card.initializedAt === "" && card.sealedAt === "" && card.fields.every((field) => field.value === "");
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
// src/host/persona/validate-identity.ts
|
|
1332
|
-
function checkIdentity(next, prev, source, issues) {
|
|
1333
|
-
const fields = next.identityCard.fields;
|
|
1334
|
-
checkFieldRows(fields, issues);
|
|
1335
|
-
checkKeyDuplicates(fields, issues);
|
|
1336
|
-
checkShadowsMutable(next, prev, issues);
|
|
1337
|
-
checkCoreFields(fields, issues);
|
|
1338
|
-
checkSealed(next, prev, source, issues);
|
|
1339
|
-
}
|
|
1340
|
-
function checkShadowsMutable(next, prev, issues) {
|
|
1341
|
-
const shadowed = /* @__PURE__ */ new Set([
|
|
1342
|
-
...next.mutableLayer.sections.map((section) => section.title),
|
|
1343
|
-
...next.mutableLayer.userDefined.map((entry) => entry.key)
|
|
1344
|
-
]);
|
|
1345
|
-
shadowed.delete("");
|
|
1346
|
-
const preexisting = new Set((prev?.identityCard.fields ?? []).map((field) => field.key));
|
|
1347
|
-
for (const [index, field] of next.identityCard.fields.entries()) {
|
|
1348
|
-
if (field.key === "" || !shadowed.has(field.key) || preexisting.has(field.key)) continue;
|
|
1349
|
-
issues.push({
|
|
1350
|
-
code: "identity.shadows-mutable",
|
|
1351
|
-
path: `identityCard.fields[${index}].key`,
|
|
1352
|
-
severity: "rejected",
|
|
1353
|
-
message: `字段名「${field.key}」与信息的小标题或自定义键撞名,请改其中一个名字。`
|
|
1354
|
-
});
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
function checkFieldRows(fields, issues) {
|
|
1358
|
-
for (const [index, field] of fields.entries()) {
|
|
1359
|
-
if (field.key === "") {
|
|
1360
|
-
issues.push({
|
|
1361
|
-
code: "identity.key-empty",
|
|
1362
|
-
path: `identityCard.fields[${index}].key`,
|
|
1363
|
-
severity: "rejected",
|
|
1364
|
-
message: "底色存在没有名字的字段,无法保存。"
|
|
1365
|
-
});
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
function checkKeyDuplicates(fields, issues) {
|
|
1370
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1371
|
-
for (const [index, field] of fields.entries()) {
|
|
1372
|
-
if (seen.has(field.key)) {
|
|
1373
|
-
issues.push({
|
|
1374
|
-
code: "identity.key-duplicate",
|
|
1375
|
-
path: `identityCard.fields[${index}].key`,
|
|
1376
|
-
severity: "rejected",
|
|
1377
|
-
message: `底色出现重复字段「${field.key}」,同一事实只能有一个当前值。`
|
|
1378
|
-
});
|
|
1379
|
-
}
|
|
1380
|
-
seen.add(field.key);
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
function checkCoreFields(fields, issues) {
|
|
1384
|
-
for (const key of CORE_IDENTITY_KEYS) {
|
|
1385
|
-
if (!fields.some((field) => field.key === key)) {
|
|
1386
|
-
issues.push({
|
|
1387
|
-
code: "identity.core-missing",
|
|
1388
|
-
path: "identityCard.fields",
|
|
1389
|
-
severity: "rejected",
|
|
1390
|
-
message: `底色缺少核心字段「${key}」,不能通过删除来绕开它。`
|
|
1391
|
-
});
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
function checkSealed(next, prev, source, issues) {
|
|
1396
|
-
if (source !== "agent" || prev === void 0) return;
|
|
1397
|
-
if (sameJson(prev.identityCard, next.identityCard)) return;
|
|
1398
|
-
if (isUntouchedIdentityCard(prev.identityCard)) return;
|
|
1399
|
-
issues.push({
|
|
1400
|
-
code: "identity.sealed",
|
|
1401
|
-
path: "identityCard",
|
|
1402
|
-
severity: "rejected",
|
|
1403
|
-
message: "人格底色已对 Agent 封存,Agent 不能修改;如需变更,请对方前往 Humanity 工作台。"
|
|
1404
|
-
});
|
|
1405
|
-
}
|
|
1406
|
-
function sameJson(left, right) {
|
|
1407
|
-
return JSON.stringify(sortKeys(left)) === JSON.stringify(sortKeys(right));
|
|
1408
|
-
}
|
|
1409
|
-
function sortKeys(value) {
|
|
1410
|
-
if (Array.isArray(value)) return value.map(sortKeys);
|
|
1411
|
-
if (value === null || typeof value !== "object") return value;
|
|
1412
|
-
return Object.fromEntries(
|
|
1413
|
-
Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, inner]) => [key, sortKeys(inner)])
|
|
1414
|
-
);
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
// src/host/persona/conflicts.ts
|
|
1418
|
-
var NEGATIONS = ["不要", "不准", "不许", "不能", "不必", "无需", "不用", "禁止", "别把", "别", "勿", "甭", "不"];
|
|
1419
|
-
var SIMILARITY_THRESHOLD = 0.6;
|
|
1420
|
-
var CONTAINMENT_RATIO = 0.6;
|
|
1421
|
-
var MIN_NORMALIZED_LENGTH = 2;
|
|
1422
|
-
function hasNegation(text) {
|
|
1423
|
-
return NEGATIONS.some((word) => text.includes(word));
|
|
1424
|
-
}
|
|
1425
|
-
function normalizeForConflict(text) {
|
|
1426
|
-
let result = text;
|
|
1427
|
-
for (const word of NEGATIONS) result = result.split(word).join("");
|
|
1428
|
-
return result.replace(/[\s,。、;:!?…—·「」『』()()【】[\]"'“”‘’《》<>~!?,.:;]+/g, "").toLowerCase();
|
|
1429
|
-
}
|
|
1430
|
-
function bigrams(text) {
|
|
1431
|
-
const grams = /* @__PURE__ */ new Set();
|
|
1432
|
-
for (let index = 0; index + 1 < text.length; index += 1) grams.add(text.slice(index, index + 2));
|
|
1433
|
-
return grams;
|
|
1434
|
-
}
|
|
1435
|
-
function similarity(left, right) {
|
|
1436
|
-
const a = bigrams(left);
|
|
1437
|
-
const b = bigrams(right);
|
|
1438
|
-
if (a.size === 0 || b.size === 0) return 0;
|
|
1439
|
-
let shared = 0;
|
|
1440
|
-
for (const gram of a) if (b.has(gram)) shared += 1;
|
|
1441
|
-
return shared / (a.size + b.size - shared);
|
|
1442
|
-
}
|
|
1443
|
-
function conflicts(left, right) {
|
|
1444
|
-
if (hasNegation(left) === hasNegation(right)) return false;
|
|
1445
|
-
const a = normalizeForConflict(left);
|
|
1446
|
-
const b = normalizeForConflict(right);
|
|
1447
|
-
if (a.length < MIN_NORMALIZED_LENGTH || b.length < MIN_NORMALIZED_LENGTH) return false;
|
|
1448
|
-
if (a === b) return true;
|
|
1449
|
-
const [shorter, longer] = a.length <= b.length ? [a, b] : [b, a];
|
|
1450
|
-
if (longer.includes(shorter) && shorter.length / longer.length >= CONTAINMENT_RATIO) return true;
|
|
1451
|
-
return similarity(a, b) >= SIMILARITY_THRESHOLD;
|
|
1452
|
-
}
|
|
1453
|
-
function findConflicts(items) {
|
|
1454
|
-
const pairs = [];
|
|
1455
|
-
for (let left = 0; left < items.length; left += 1) {
|
|
1456
|
-
for (let right = left + 1; right < items.length; right += 1) {
|
|
1457
|
-
if (conflicts(items[left] ?? "", items[right] ?? "")) pairs.push({ left, right });
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
return pairs;
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
// src/host/persona/validate-loss.ts
|
|
1464
|
-
var STANDARD_TITLES = new Set(STANDARD_SECTION_TITLES);
|
|
1465
|
-
function checkContentLoss(next, prev, issues) {
|
|
1466
|
-
if (prev === void 0) return;
|
|
1467
|
-
for (const previous of prev.mutableLayer.sections) {
|
|
1468
|
-
if (previous.items.length === 0) continue;
|
|
1469
|
-
const stillThere = next.mutableLayer.sections.find((section) => section.title === previous.title);
|
|
1470
|
-
if (stillThere === void 0) {
|
|
1471
|
-
issues.push({
|
|
1472
|
-
code: "mutable.section-dropped",
|
|
1473
|
-
path: `mutableLayer.sections.${previous.title}`,
|
|
1474
|
-
severity: "rejected",
|
|
1475
|
-
message: `「${previous.title}」原有内容,但这次快照里**整节不见了**(漏传)。若要保留请显式传入原内容;要删除这个自定义节请显式传 items: [](会在对话里确认)。`
|
|
1476
|
-
});
|
|
1477
|
-
continue;
|
|
1478
|
-
}
|
|
1479
|
-
if (stillThere.items.length === 0) {
|
|
1480
|
-
const custom = !STANDARD_TITLES.has(previous.title);
|
|
1481
|
-
issues.push({
|
|
1482
|
-
code: "mutable.section-cleared",
|
|
1483
|
-
path: `mutableLayer.sections.${previous.title}`,
|
|
1484
|
-
severity: "rejected",
|
|
1485
|
-
message: `「${previous.title}」原有内容,这次被显式清空` + (custom ? "(自定义小标题清空即删除该节)" : "(标准小标题清空后保留空节)") + `;删除对方内容需要对方在对话里确认。`
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
// src/host/persona/validate-mutable.ts
|
|
1492
|
-
var sectionPath = (title3, index) => title3 === "" ? `mutableLayer.sections[${index}]` : `mutableLayer.sections.${title3}`;
|
|
1493
|
-
var CORE_KEYS = new Set(CORE_IDENTITY_KEYS);
|
|
1494
|
-
function checkMutable(next, prev, source, issues) {
|
|
1495
|
-
checkSections(next.mutableLayer.sections, issues);
|
|
1496
|
-
checkUserDefined(next.mutableLayer.userDefined, issues);
|
|
1497
|
-
checkLockedSections(next, prev, issues);
|
|
1498
|
-
if (source !== "agent") return;
|
|
1499
|
-
checkConflicts(next, prev, issues);
|
|
1500
|
-
checkContentLoss(next, prev, issues);
|
|
1501
|
-
}
|
|
1502
|
-
function checkConflicts(next, prev, issues) {
|
|
1503
|
-
for (const [index, section] of next.mutableLayer.sections.entries()) {
|
|
1504
|
-
if (section.items.length < 2) continue;
|
|
1505
|
-
const previousItems = prev?.mutableLayer.sections.find((item) => item.title === section.title)?.items ?? [];
|
|
1506
|
-
for (const pair of findConflicts(section.items)) {
|
|
1507
|
-
const left = section.items[pair.left] ?? "";
|
|
1508
|
-
const right = section.items[pair.right] ?? "";
|
|
1509
|
-
if (prev !== void 0 && previousItems.includes(left) && previousItems.includes(right)) continue;
|
|
1510
|
-
issues.push({
|
|
1511
|
-
code: "mutable.item-conflict",
|
|
1512
|
-
path: `${sectionPath(section.title, index)}.items`,
|
|
1513
|
-
severity: "rejected",
|
|
1514
|
-
message: `「${section.title}」里有两条互相矛盾:「${left}」/「${right}」。留哪一条?删掉另一条再保存(两条都留着,提示词里会同时生效,行为会随机)。`
|
|
1515
|
-
});
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
function checkLockedSections(next, prev, issues) {
|
|
1520
|
-
const titles = new Set(next.mutableLayer.sections.map((section) => section.title));
|
|
1521
|
-
for (const title3 of LOCKED_SECTION_TITLES) {
|
|
1522
|
-
const had = prev === void 0 || prev.mutableLayer.sections.some((section) => section.title === title3);
|
|
1523
|
-
if (!had || titles.has(title3)) continue;
|
|
1524
|
-
issues.push({
|
|
1525
|
-
code: "mutable.section-locked-missing",
|
|
1526
|
-
path: `mutableLayer.sections.${title3}`,
|
|
1527
|
-
severity: "rejected",
|
|
1528
|
-
message: `「${title3}」是默认锁定项(底色 4 项 + 信息 4 项,共 8 项不可删),不能整节删除。若不想保留它的内容,请清空里面的条目 —— 节本身保留。`
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
function checkSections(sections, issues) {
|
|
1533
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1534
|
-
for (const [index, section] of sections.entries()) {
|
|
1535
|
-
checkTitle(section, index, seen, issues);
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
function checkTitle(section, index, seen, issues) {
|
|
1539
|
-
const { title: title3, items } = section;
|
|
1540
|
-
if (title3 === "") {
|
|
1541
|
-
if (items.length > 0) {
|
|
1542
|
-
issues.push({
|
|
1543
|
-
code: "mutable.section-title-empty",
|
|
1544
|
-
path: sectionPath(title3, index),
|
|
1545
|
-
severity: "rejected",
|
|
1546
|
-
message: `信息有一节没有小标题(里面还有 ${items.length} 条内容),而**没有名字的小节不会进提示词**。请给它取个名字(自定义标题即可),或把这些条目并入已有小节。`
|
|
1547
|
-
});
|
|
1548
|
-
}
|
|
1549
|
-
return;
|
|
1550
|
-
}
|
|
1551
|
-
if (seen.has(title3)) {
|
|
1552
|
-
issues.push({
|
|
1553
|
-
code: "mutable.section-duplicate",
|
|
1554
|
-
path: sectionPath(title3, index),
|
|
1555
|
-
severity: "rejected",
|
|
1556
|
-
message: `信息出现重复小标题「${title3}」,同一类内容只能有一个当前快照。`
|
|
1557
|
-
});
|
|
1558
|
-
}
|
|
1559
|
-
seen.add(title3);
|
|
1560
|
-
if (CORE_KEYS.has(title3)) {
|
|
1561
|
-
issues.push({
|
|
1562
|
-
code: "mutable.core-key-shadowed",
|
|
1563
|
-
path: sectionPath(title3, index),
|
|
1564
|
-
severity: "rejected",
|
|
1565
|
-
message: `「${title3}」是底色字段名,不能作为信息小标题;底色只能由对方在 Humanity 工作台修改。`
|
|
1566
|
-
});
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
function checkUserDefined(entries, issues) {
|
|
1570
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1571
|
-
for (const [index, entry] of entries.entries()) {
|
|
1572
|
-
if (entry.key === "") {
|
|
1573
|
-
issues.push({
|
|
1574
|
-
code: "mutable.user-defined-key-empty",
|
|
1575
|
-
path: `mutableLayer.userDefined[${index}].key`,
|
|
1576
|
-
severity: "rejected",
|
|
1577
|
-
message: `「自定义」有一项只填了内容、没有名字(值:「${entry.value}」),请补上键名再保存。`
|
|
1578
|
-
});
|
|
1579
|
-
}
|
|
1580
|
-
if (seen.has(entry.key)) {
|
|
1581
|
-
issues.push({
|
|
1582
|
-
code: "mutable.user-defined-duplicate",
|
|
1583
|
-
path: `mutableLayer.userDefined[${index}].key`,
|
|
1584
|
-
severity: "rejected",
|
|
1585
|
-
message: `「自定义」出现重复键「${entry.key}」,同一事实只能有一个当前值(这次没有任何内容被写入)。`
|
|
1586
|
-
});
|
|
1587
|
-
}
|
|
1588
|
-
seen.add(entry.key);
|
|
1589
|
-
if (CORE_KEYS.has(entry.key)) {
|
|
1590
|
-
issues.push({
|
|
1591
|
-
code: "mutable.core-key-shadowed",
|
|
1592
|
-
path: `mutableLayer.userDefined[${index}].key`,
|
|
1593
|
-
severity: "rejected",
|
|
1594
|
-
message: `「${entry.key}」是底色字段名,不能作为「自定义」的键;底色只能由对方在 Humanity 工作台修改。`
|
|
1595
|
-
});
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
// src/host/persona/validate.ts
|
|
1601
|
-
function validatePersona(next, prev, source, options = {}) {
|
|
1602
|
-
const issues = [];
|
|
1603
|
-
checkIdentity(next, prev, source, issues);
|
|
1604
|
-
checkMutable(next, prev, source, issues);
|
|
1605
|
-
checkCharacter(next, prev, source, issues);
|
|
1606
|
-
const confirmable = new Set(CONFIRMABLE_ISSUES);
|
|
1607
|
-
const confirmed = new Set((options.confirmed ?? []).filter((code) => confirmable.has(code)));
|
|
1608
|
-
const effective = issues.map(
|
|
1609
|
-
(issue) => issue.severity === "rejected" && confirmed.has(issue.code) ? { ...issue, severity: "warning" } : issue
|
|
1610
|
-
);
|
|
1611
|
-
return { ok: !effective.some((issue) => issue.severity === "rejected"), issues: effective };
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
// src/client/persona-document.ts
|
|
1615
|
-
var identityItemId = (index) => `identity:${index}`;
|
|
1616
|
-
var sectionItemId = (title3) => `section:${title3}`;
|
|
1617
|
-
function parseItemId(itemId) {
|
|
1618
|
-
if (typeof itemId !== "string") return void 0;
|
|
1619
|
-
const at = itemId.indexOf(":");
|
|
1620
|
-
if (at <= 0) return void 0;
|
|
1621
|
-
const kind = itemId.slice(0, at);
|
|
1622
|
-
const key = itemId.slice(at + 1);
|
|
1623
|
-
if (kind === "section") return key === "" ? void 0 : { kind: "section", key };
|
|
1624
|
-
if (kind === "identity" && /^\d+$/.test(key)) return { kind, key };
|
|
1625
|
-
return void 0;
|
|
1626
|
-
}
|
|
1627
|
-
var isLockedIdentityKey = (key) => CORE_IDENTITY_KEYS.includes(key);
|
|
1628
|
-
function canDeleteItem(doc, itemId) {
|
|
1629
|
-
const ref = parseItemId(itemId);
|
|
1630
|
-
if (ref === void 0) return false;
|
|
1631
|
-
if (ref.kind === "identity") {
|
|
1632
|
-
const field = doc?.identityCard?.fields?.[Number(ref.key)];
|
|
1633
|
-
return field !== void 0 && field.custom === true && !isLockedIdentityKey(field.key);
|
|
1634
|
-
}
|
|
1635
|
-
return !isLockedSectionTitle(ref.key) && (doc?.mutableLayer?.sections ?? []).some((row2) => row2.title === ref.key);
|
|
1636
|
-
}
|
|
1637
|
-
function addFormReady(form) {
|
|
1638
|
-
if (form === void 0) return false;
|
|
1639
|
-
return form.name.trim() !== "" && form.value.trim() !== "";
|
|
1640
|
-
}
|
|
1641
|
-
function canRenameItem(doc, itemId) {
|
|
1642
|
-
const ref = parseItemId(itemId);
|
|
1643
|
-
if (ref === void 0) return false;
|
|
1644
|
-
if (ref.kind === "identity") {
|
|
1645
|
-
const field = doc?.identityCard?.fields?.[Number(ref.key)];
|
|
1646
|
-
return field !== void 0 && field.custom === true && !isLockedIdentityKey(field.key);
|
|
1647
|
-
}
|
|
1648
|
-
if (isLockedSectionTitle(ref.key)) return false;
|
|
1649
|
-
return (doc?.mutableLayer?.sections ?? []).some((row2) => row2.title === ref.key);
|
|
1650
|
-
}
|
|
1651
|
-
function itemName(doc, itemId) {
|
|
1652
|
-
const ref = parseItemId(itemId);
|
|
1653
|
-
if (ref === void 0) return void 0;
|
|
1654
|
-
if (ref.kind === "identity") return doc?.identityCard?.fields?.[Number(ref.key)]?.key;
|
|
1655
|
-
return (doc?.mutableLayer?.sections ?? []).find((row2) => row2.title === ref.key)?.title;
|
|
1656
|
-
}
|
|
1657
|
-
function renameIssue(doc, itemId, nextName) {
|
|
1658
|
-
if (!canRenameItem(doc, itemId)) return "reserved";
|
|
1659
|
-
const ref = parseItemId(itemId);
|
|
1660
|
-
if (ref === void 0) return "reserved";
|
|
1661
|
-
const name2 = typeof nextName === "string" ? nextName.trim() : "";
|
|
1662
|
-
if (name2 === "") return "empty";
|
|
1663
|
-
const current = itemName(doc, itemId);
|
|
1664
|
-
if (current === void 0) return "reserved";
|
|
1665
|
-
if (name2 === current) return "unchanged";
|
|
1666
|
-
const standard = STANDARD_SECTION_TITLES;
|
|
1667
|
-
const core = CORE_IDENTITY_KEYS;
|
|
1668
|
-
if (standard.includes(name2) || core.includes(name2)) return "reserved";
|
|
1669
|
-
const allNames = [
|
|
1670
|
-
...(doc?.identityCard?.fields ?? []).map((field) => field.key),
|
|
1671
|
-
...(doc?.mutableLayer?.sections ?? []).map((row2) => row2.title),
|
|
1672
|
-
...(doc?.mutableLayer?.userDefined ?? []).map((entry) => entry.key)
|
|
1673
|
-
];
|
|
1674
|
-
if (allNames.some((key) => key === name2 && key !== current)) return "duplicate";
|
|
1675
|
-
return void 0;
|
|
1676
|
-
}
|
|
1677
|
-
function emptyDocument() {
|
|
1678
|
-
return {
|
|
1679
|
-
schemaVersion: 1,
|
|
1680
|
-
identityCard: {
|
|
1681
|
-
fields: CORE_IDENTITY_KEYS.map((key) => ({ key, value: "", custom: false })),
|
|
1682
|
-
initializedAt: "",
|
|
1683
|
-
sealedAt: ""
|
|
1684
|
-
},
|
|
1685
|
-
mutableLayer: {
|
|
1686
|
-
sections: STANDARD_SECTION_TITLES.map((title3) => ({ title: title3, items: [] })),
|
|
1687
|
-
userDefined: []
|
|
1688
|
-
},
|
|
1689
|
-
// 未初始化时还没有性格:空壳与 `model.ts` 的 schema 默认值同形。
|
|
1690
|
-
character: { derivedAt: "", axes: [] }
|
|
1691
|
-
};
|
|
1692
|
-
}
|
|
1693
|
-
function clone(document2) {
|
|
1694
|
-
return JSON.parse(JSON.stringify(document2));
|
|
1695
|
-
}
|
|
1696
|
-
function asDocument(value) {
|
|
1697
|
-
if (value === null || typeof value !== "object") throw new Error("宿主返回的人格文档不是对象");
|
|
1698
|
-
const candidate = value;
|
|
1699
|
-
if (candidate.identityCard === void 0 || candidate.mutableLayer === void 0) {
|
|
1700
|
-
throw new Error("宿主返回的人格文档缺少 identityCard / mutableLayer");
|
|
1701
|
-
}
|
|
1702
|
-
return effectivePersona({
|
|
1703
|
-
...candidate,
|
|
1704
|
-
identityCard: {
|
|
1705
|
-
initializedAt: candidate.identityCard.initializedAt ?? "",
|
|
1706
|
-
sealedAt: candidate.identityCard.sealedAt ?? "",
|
|
1707
|
-
fields: Array.isArray(candidate.identityCard.fields) ? candidate.identityCard.fields : []
|
|
1708
|
-
},
|
|
1709
|
-
mutableLayer: {
|
|
1710
|
-
sections: Array.isArray(candidate.mutableLayer.sections) ? candidate.mutableLayer.sections : [],
|
|
1711
|
-
userDefined: Array.isArray(candidate.mutableLayer.userDefined) ? candidate.mutableLayer.userDefined : []
|
|
1712
|
-
},
|
|
1713
|
-
// 性格层同理:宿主可能还没听说过它(旧版本写入的文档、或这一块没接上),
|
|
1714
|
-
// 缺了就兜成"还没有性格",界面显示为未推导,不让渲染期炸。
|
|
1715
|
-
character: {
|
|
1716
|
-
derivedAt: candidate.character?.derivedAt ?? "",
|
|
1717
|
-
axes: Array.isArray(candidate.character?.axes) ? candidate.character.axes : []
|
|
1718
|
-
}
|
|
1719
|
-
});
|
|
1720
|
-
}
|
|
1721
|
-
function orderedSections(doc) {
|
|
1722
|
-
const standard = new Set(STANDARD_SECTION_TITLES);
|
|
1723
|
-
const sections = Array.isArray(doc?.mutableLayer?.sections) ? doc.mutableLayer.sections : [];
|
|
1724
|
-
const known = STANDARD_SECTION_TITLES.flatMap((title3) => {
|
|
1725
|
-
const found = sections.find((section) => section?.title === title3);
|
|
1726
|
-
return found === void 0 ? [] : [{ title: title3, items: Array.isArray(found.items) ? [...found.items] : [] }];
|
|
1727
|
-
});
|
|
1728
|
-
const rest = sections.filter((section) => section !== void 0 && section !== null && !standard.has(section.title)).map((section) => ({ title: section.title, items: Array.isArray(section.items) ? [...section.items] : [] }));
|
|
1729
|
-
return [...known, ...rest];
|
|
1730
|
-
}
|
|
1731
|
-
function isDirty(state) {
|
|
1732
|
-
try {
|
|
1733
|
-
return JSON.stringify(normalizePersona(state.draft)) !== JSON.stringify(normalizePersona(state.stored));
|
|
1734
|
-
} catch {
|
|
1735
|
-
return false;
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
|
|
1739
|
-
// src/client/persona-channel.ts
|
|
1740
|
-
var PERSONA_NAMESPACE = "humanity-persona";
|
|
1741
|
-
var HUMANITY_NAMESPACE = "humanity";
|
|
1742
|
-
|
|
1743
|
-
// src/client/persona-config.ts
|
|
1744
|
-
function readIndependentJudgment(namespaces) {
|
|
1745
|
-
const view = namespaces.find((entry) => entry?.ns === HUMANITY_NAMESPACE);
|
|
1746
|
-
if (view === void 0) return void 0;
|
|
1747
|
-
const value = view.value;
|
|
1748
|
-
return { value: value?.independentJudgment !== false, revision: view.revision };
|
|
1749
|
-
}
|
|
1750
|
-
async function writeIndependentJudgment(channel, next, expectedRevision) {
|
|
1751
|
-
const result = await channel.update(HUMANITY_NAMESPACE, { independentJudgment: next }, expectedRevision);
|
|
1752
|
-
if (result === void 0 || result === null || result.ok !== true) {
|
|
1753
|
-
return { ok: false, message: result?.error?.message ?? "宿主没有返回可用的结果" };
|
|
1754
|
-
}
|
|
1755
|
-
const described = await channel.describe();
|
|
1756
|
-
if (described === void 0 || described === null || described.ok !== true) {
|
|
1757
|
-
return { ok: false, message: described?.error?.message ?? "写入成功但回读失败,请刷新核对" };
|
|
1758
|
-
}
|
|
1759
|
-
const view = readIndependentJudgment(described.value.namespaces);
|
|
1760
|
-
if (view === void 0) return { ok: false, message: "回读不到顶层配置命名空间,请刷新核对" };
|
|
1761
|
-
return { ok: true, view: { independentJudgment: view.value, revision: view.revision } };
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
// src/client/persona-state.ts
|
|
1765
|
-
var PersonaStateBase = class {
|
|
1766
|
-
state = {
|
|
1767
|
-
status: "idle",
|
|
1768
|
-
writable: false,
|
|
1769
|
-
stored: emptyDocument(),
|
|
1770
|
-
draft: emptyDocument(),
|
|
1771
|
-
saving: false,
|
|
1772
|
-
savedAt: "",
|
|
1773
|
-
issues: [],
|
|
1774
|
-
// 与宿主 schema 的默认值一致(缺省即开),读不到时界面也显示开。
|
|
1775
|
-
independentJudgment: true,
|
|
1776
|
-
independentJudgmentSaving: false
|
|
1777
|
-
};
|
|
1778
|
-
listeners = /* @__PURE__ */ new Set();
|
|
1779
|
-
/** 订阅状态变化;返回退订函数(直接交给 `useSyncExternalStore`)。 */
|
|
1780
|
-
subscribe = (listener) => {
|
|
1781
|
-
this.listeners.add(listener);
|
|
1782
|
-
return () => this.listeners.delete(listener);
|
|
1783
|
-
};
|
|
1784
|
-
/** 当前快照。引用稳定:只有 `update()` 会换对象。 */
|
|
1785
|
-
getSnapshot = () => this.state;
|
|
1786
|
-
/** 改草稿:先深拷贝再改,保证旧快照对新快照是只读历史。 */
|
|
1787
|
-
edit(mutate) {
|
|
1788
|
-
const draft = clone(this.state.draft);
|
|
1789
|
-
mutate(draft);
|
|
1790
|
-
this.update({ draft });
|
|
1791
|
-
}
|
|
1792
|
-
/** 换一个新状态对象并通知订阅者。 */
|
|
1793
|
-
update(patch) {
|
|
1794
|
-
this.state = { ...this.state, ...patch };
|
|
1795
|
-
for (const listener of this.listeners) listener();
|
|
1796
|
-
}
|
|
1797
|
-
/**
|
|
1798
|
-
* 用宿主返回的一段值重建基线(stored = draft = 生效文档),并记录修订号。
|
|
1799
|
-
*
|
|
1800
|
-
* 抓异常是有意的:`adopt` 在 `load()` / `save()` 的异步链上被调用,抛出去就是未处理的 rejection;
|
|
1801
|
-
* 形状不对只该降级成"读不到",不该把界面的其余部分带走。
|
|
1802
|
-
* @param view - 宿主返回的命名空间视图。
|
|
1803
|
-
* @param writable - 宿主是否接受写入。
|
|
1804
|
-
* @param options - 本次读取/保存附带的警告、保存时间,以及顶层配置里的独立判断开关。
|
|
1805
|
-
*/
|
|
1806
|
-
adopt(view, writable, options = {}) {
|
|
1807
|
-
let document2;
|
|
1808
|
-
try {
|
|
1809
|
-
document2 = asDocument(view.value);
|
|
1810
|
-
} catch (error) {
|
|
1811
|
-
this.update({
|
|
1812
|
-
status: "failed",
|
|
1813
|
-
writable: false,
|
|
1814
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1815
|
-
});
|
|
1816
|
-
return;
|
|
1817
|
-
}
|
|
1818
|
-
this.update({
|
|
1819
|
-
status: "ready",
|
|
1820
|
-
writable,
|
|
1821
|
-
error: void 0,
|
|
1822
|
-
revision: view.revision,
|
|
1823
|
-
stored: document2,
|
|
1824
|
-
draft: clone(document2),
|
|
1825
|
-
saving: false,
|
|
1826
|
-
savedAt: options.savedAt ?? "",
|
|
1827
|
-
issues: options.warnings ?? [],
|
|
1828
|
-
// 项级交互状态(待确认删除 / 添加表单 / 改名表单)跟着这一次重建一起清掉:新草稿里那些项
|
|
1829
|
-
// 可能已经不存在(删除后保存、重新加载),留着就是指向已消失项的幽灵态。
|
|
1830
|
-
pendingDelete: void 0,
|
|
1831
|
-
addForm: void 0,
|
|
1832
|
-
renaming: void 0,
|
|
1833
|
-
// 顶层开关与人格文档是两份数据:这一次读取没带上它时**保持原值**(别把它重置成默认)。
|
|
1834
|
-
...options.independentJudgment === void 0 ? { independentJudgmentSaving: false } : {
|
|
1835
|
-
independentJudgment: options.independentJudgment.value,
|
|
1836
|
-
independentJudgmentRevision: options.independentJudgment.revision,
|
|
1837
|
-
independentJudgmentSaving: false
|
|
1838
|
-
}
|
|
1839
|
-
});
|
|
1840
|
-
}
|
|
1841
|
-
};
|
|
1842
|
-
|
|
1843
|
-
// src/client/persona-edits.ts
|
|
1844
|
-
function setCharacterReason(draft, key, value) {
|
|
1845
|
-
const axis = draft.character?.axes?.find((item) => item.key === key);
|
|
1846
|
-
if (axis !== void 0) axis.reason = value;
|
|
1847
|
-
}
|
|
1848
|
-
function setIdentityValue(draft, index, value) {
|
|
1849
|
-
const field = draft.identityCard.fields[index];
|
|
1850
|
-
if (field !== void 0) field.value = value;
|
|
1851
|
-
}
|
|
1852
|
-
function setIdentityKey(draft, index, key) {
|
|
1853
|
-
const field = draft.identityCard.fields[index];
|
|
1854
|
-
if (field !== void 0 && field.custom) field.key = key;
|
|
1855
|
-
}
|
|
1856
|
-
function addIdentityField(draft) {
|
|
1857
|
-
draft.identityCard.fields.push({ key: "", value: "", custom: true });
|
|
1858
|
-
}
|
|
1859
|
-
function removeIdentityField(draft, index) {
|
|
1860
|
-
const field = draft.identityCard.fields[index];
|
|
1861
|
-
if (field !== void 0 && field.custom) draft.identityCard.fields.splice(index, 1);
|
|
1862
|
-
}
|
|
1863
|
-
function removeSection(draft, title3) {
|
|
1864
|
-
if (isLockedSectionTitle(title3)) return;
|
|
1865
|
-
const at = draft.mutableLayer.sections.findIndex((section) => section.title === title3);
|
|
1866
|
-
if (at >= 0) draft.mutableLayer.sections.splice(at, 1);
|
|
1867
|
-
}
|
|
1868
|
-
function removeItem(draft, itemId) {
|
|
1869
|
-
if (!canDeleteItem(draft, itemId)) return;
|
|
1870
|
-
const ref = parseItemId(itemId);
|
|
1871
|
-
if (ref === void 0) return;
|
|
1872
|
-
if (ref.kind === "identity") {
|
|
1873
|
-
draft.identityCard.fields.splice(Number(ref.key), 1);
|
|
1874
|
-
return;
|
|
1875
|
-
}
|
|
1876
|
-
removeSection(draft, ref.key);
|
|
1877
|
-
}
|
|
1878
|
-
function renameItem(draft, itemId, nextName) {
|
|
1879
|
-
const ref = parseItemId(itemId);
|
|
1880
|
-
if (ref === void 0) return;
|
|
1881
|
-
if (renameIssue(draft, itemId, nextName) !== void 0) return;
|
|
1882
|
-
const name2 = nextName.trim();
|
|
1883
|
-
if (ref.kind === "identity") {
|
|
1884
|
-
const field = draft.identityCard.fields[Number(ref.key)];
|
|
1885
|
-
if (field !== void 0) field.key = name2;
|
|
1886
|
-
return;
|
|
1887
|
-
}
|
|
1888
|
-
const section = draft.mutableLayer.sections.find((row2) => row2.title === ref.key);
|
|
1889
|
-
if (section !== void 0) section.title = name2;
|
|
1890
|
-
}
|
|
1891
|
-
function applyAddForm(draft, form) {
|
|
1892
|
-
if (!addFormReady(form)) return;
|
|
1893
|
-
const name2 = form.name.trim();
|
|
1894
|
-
const value = form.value.trim();
|
|
1895
|
-
if (form.kind === "identity") {
|
|
1896
|
-
draft.identityCard.fields.push({ key: name2, value, custom: true });
|
|
1897
|
-
return;
|
|
1898
|
-
}
|
|
1899
|
-
const existing = draft.mutableLayer.sections.find((section) => section.title === name2);
|
|
1900
|
-
if (existing === void 0) draft.mutableLayer.sections.push({ title: name2, items: [value] });
|
|
1901
|
-
else existing.items.push(value);
|
|
1902
|
-
}
|
|
1903
|
-
function setSectionText(draft, title3, text) {
|
|
1904
|
-
const section = draft.mutableLayer.sections.find((entry) => entry.title === title3);
|
|
1905
|
-
if (section !== void 0) section.items = text.split("\n");
|
|
1906
|
-
}
|
|
1907
|
-
function stampInitialization(draft, stored) {
|
|
1908
|
-
if (!isUntouchedIdentityCard(stored.identityCard)) return draft;
|
|
1909
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1910
|
-
return { ...draft, identityCard: { ...draft.identityCard, initializedAt: now, sealedAt: now } };
|
|
1911
|
-
}
|
|
1912
|
-
function sealPersona(draft, now) {
|
|
1913
|
-
const card = draft.identityCard;
|
|
1914
|
-
return {
|
|
1915
|
-
...draft,
|
|
1916
|
-
identityCard: {
|
|
1917
|
-
...card,
|
|
1918
|
-
initializedAt: card.initializedAt === "" ? now : card.initializedAt,
|
|
1919
|
-
sealedAt: now
|
|
1920
|
-
}
|
|
1921
|
-
};
|
|
1922
|
-
}
|
|
1923
|
-
|
|
1924
|
-
// src/client/persona-controller.ts
|
|
1925
|
-
var PersonaWorkbenchController = class extends PersonaStateBase {
|
|
1926
|
-
channel;
|
|
1927
|
-
/**
|
|
1928
|
-
* 接上设置 RPC,并把当前文档读进来。**形状不对就不接**(调用点在 `ctx.inject` 回调里,
|
|
1929
|
-
* 抛出去会变成客户端 cordis 运行时的异常):只校验与降级,不抛。
|
|
1930
|
-
* @param channel - 期望是实现 `describe`/`replace` 的通道;其它值一律按"没有通道"处理。
|
|
1931
|
-
*/
|
|
1932
|
-
attach(channel) {
|
|
1933
|
-
this.channel = channel !== void 0 && channel !== null && typeof channel.describe === "function" && typeof channel.replace === "function" && // `update` 是独立判断开关的写通道(DSH 0.1.5-rc.2 起有)。缺了它就把整条通道判为不可用:
|
|
1934
|
-
// 形态不对的通道只该导致"工作台只读",不该等到用户点开关时才在点击回调里抛错。
|
|
1935
|
-
typeof channel.update === "function" ? channel : void 0;
|
|
1936
|
-
void this.load();
|
|
1937
|
-
}
|
|
1938
|
-
/** 断开(服务被摘除):回到"通道未就绪",但保留草稿内容,避免用户正在编辑的东西凭空消失。 */
|
|
1939
|
-
detach() {
|
|
1940
|
-
this.channel = void 0;
|
|
1941
|
-
this.update({ status: "unavailable", writable: false, saving: false });
|
|
1942
|
-
}
|
|
1943
|
-
/**
|
|
1944
|
-
* 从宿主重新读取(也是"丢弃本地草稿"的唯一入口——本步不做撤销栈,见裁决 5)。
|
|
1945
|
-
*
|
|
1946
|
-
* **永不抛**:调用点是 `useEffect` 里的 `void controller.load()`,抛出去就是未处理的
|
|
1947
|
-
* rejection;返回形状不对也只是降级成"读不到"。
|
|
1948
|
-
*/
|
|
1949
|
-
async load() {
|
|
1950
|
-
const channel = this.channel;
|
|
1951
|
-
if (channel === void 0) {
|
|
1952
|
-
this.update({ status: "unavailable", writable: false });
|
|
1953
|
-
return;
|
|
1954
|
-
}
|
|
1955
|
-
this.update({ status: "loading", error: void 0 });
|
|
1956
|
-
let result;
|
|
1957
|
-
try {
|
|
1958
|
-
result = await channel.describe();
|
|
1959
|
-
} catch (error) {
|
|
1960
|
-
this.update({
|
|
1961
|
-
status: "failed",
|
|
1962
|
-
writable: false,
|
|
1963
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1964
|
-
});
|
|
1965
|
-
return;
|
|
1966
|
-
}
|
|
1967
|
-
if (result === void 0 || result === null || result.ok !== true) {
|
|
1968
|
-
const message = result?.error?.message ?? "宿主没有返回可用的设置描述";
|
|
1969
|
-
this.update({ status: "failed", error: message, writable: false });
|
|
1970
|
-
return;
|
|
1971
|
-
}
|
|
1972
|
-
const namespaces = Array.isArray(result.value?.namespaces) ? result.value.namespaces : [];
|
|
1973
|
-
const view = namespaces.find((entry) => entry?.ns === PERSONA_NAMESPACE);
|
|
1974
|
-
if (view === void 0) {
|
|
1975
|
-
this.update({ status: "unavailable", writable: false, issues: [] });
|
|
1976
|
-
return;
|
|
1977
|
-
}
|
|
1978
|
-
this.adopt(view, result.value.writable, { independentJudgment: readIndependentJudgment(namespaces) });
|
|
1979
|
-
}
|
|
1980
|
-
/**
|
|
1981
|
-
* 切换独立判断底层指令(顶层 `humanity` 配置的 `independentJudgment`,读写细节见 `persona-config.ts`)。
|
|
1982
|
-
* @param next - 目标状态。
|
|
1983
|
-
*/
|
|
1984
|
-
async setIndependentJudgment(next) {
|
|
1985
|
-
const channel = this.channel;
|
|
1986
|
-
if (channel === void 0 || !this.state.writable || this.state.independentJudgmentSaving) return;
|
|
1987
|
-
this.update({ independentJudgmentSaving: true, error: void 0 });
|
|
1988
|
-
let result;
|
|
1989
|
-
try {
|
|
1990
|
-
result = await writeIndependentJudgment(channel, next, this.state.independentJudgmentRevision);
|
|
1991
|
-
} catch (error) {
|
|
1992
|
-
this.update({ independentJudgmentSaving: false, error: describeError(error) });
|
|
1993
|
-
return;
|
|
1994
|
-
}
|
|
1995
|
-
if (!result.ok) {
|
|
1996
|
-
this.update({ independentJudgmentSaving: false, error: result.message });
|
|
1997
|
-
return;
|
|
1998
|
-
}
|
|
1999
|
-
this.update({
|
|
2000
|
-
independentJudgment: result.view.independentJudgment,
|
|
2001
|
-
independentJudgmentRevision: result.view.revision,
|
|
2002
|
-
independentJudgmentSaving: false
|
|
2003
|
-
});
|
|
2004
|
-
}
|
|
2005
|
-
/** 保存草稿:**先本机校验,再发请求**;成功后用宿主返回的值重建基线。 */
|
|
2006
|
-
async save() {
|
|
2007
|
-
const channel = this.channel;
|
|
2008
|
-
if (channel === void 0 || !this.state.writable || this.state.saving) return;
|
|
2009
|
-
const stamped = stampInitialization(normalizePersona(this.state.draft), this.state.stored);
|
|
2010
|
-
const candidate = effectivePersona(stamped);
|
|
2011
|
-
const validation = validatePersona(candidate, this.state.stored, "user");
|
|
2012
|
-
const warnings = validation.issues.filter((issue) => issue.severity === "warning");
|
|
2013
|
-
if (!validation.ok) {
|
|
2014
|
-
this.update({ issues: validation.issues });
|
|
2015
|
-
return;
|
|
2016
|
-
}
|
|
2017
|
-
this.update({ saving: true, issues: warnings, error: void 0 });
|
|
2018
|
-
let result;
|
|
2019
|
-
try {
|
|
2020
|
-
result = await channel.replace(PERSONA_NAMESPACE, candidate, this.state.revision);
|
|
2021
|
-
} catch (error) {
|
|
2022
|
-
this.update({ saving: false, error: describeError(error), issues: warnings });
|
|
2023
|
-
return;
|
|
2024
|
-
}
|
|
2025
|
-
if (!result.ok) {
|
|
2026
|
-
this.update({ saving: false, error: result.error.message, issues: warnings });
|
|
2027
|
-
return;
|
|
2028
|
-
}
|
|
2029
|
-
this.adopt(result.value, true, { warnings, savedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
2030
|
-
}
|
|
2031
|
-
// 下面这些方法只是把用户改了哪一项转成对草稿的修改(纯函数在 ):
|
|
2032
|
-
// 控制器负责改哪一份草稿、改完通知谁,函数负责怎么改。
|
|
2033
|
-
/**
|
|
2034
|
-
* 封存底色(P-013:对 Agent 封存,用户仍可改)。
|
|
2035
|
-
*
|
|
2036
|
-
* 为什么要有这个显式动作(2026-09-26 真机暴露的缺口):封存原本只有"首次保存"这一条路径,
|
|
2037
|
-
* 于是"已初始化但未封存"的卡(预填、旧数据、别的写入方留下的)在界面上**永远封不上**,
|
|
2038
|
-
* 独立判断开关一直是灰的。这里补用户的入口:先把封存标记落进草稿,再走同一条保存路径
|
|
2039
|
-
* (本机校验 + 修订号 + 宿主拒绝原样显示,一步都不绕过)。
|
|
2040
|
-
*/
|
|
2041
|
-
async seal() {
|
|
2042
|
-
if (this.channel === void 0 || !this.state.writable || this.state.saving) return;
|
|
2043
|
-
this.update({ draft: sealPersona(this.state.draft, (/* @__PURE__ */ new Date()).toISOString()) });
|
|
2044
|
-
await this.save();
|
|
2045
|
-
}
|
|
2046
|
-
setIdentityValue(index, value) {
|
|
2047
|
-
this.edit((draft) => setIdentityValue(draft, index, value));
|
|
2048
|
-
}
|
|
2049
|
-
setIdentityKey(index, key) {
|
|
2050
|
-
this.edit((draft) => setIdentityKey(draft, index, key));
|
|
2051
|
-
}
|
|
2052
|
-
addIdentityField() {
|
|
2053
|
-
this.edit(addIdentityField);
|
|
2054
|
-
}
|
|
2055
|
-
removeIdentityField(index) {
|
|
2056
|
-
this.edit((draft) => removeIdentityField(draft, index));
|
|
2057
|
-
}
|
|
2058
|
-
setSectionText(title3, text) {
|
|
2059
|
-
this.edit((draft) => setSectionText(draft, title3, text));
|
|
2060
|
-
}
|
|
2061
|
-
setCharacterReason(key, value) {
|
|
2062
|
-
this.edit((draft) => setCharacterReason(draft, key, value));
|
|
2063
|
-
}
|
|
2064
|
-
// ⚠️ 0.1.14:`setUserDefined` / `addUserDefined` / `removeUserDefined` 三个入口随「用户定义」区块
|
|
2065
|
-
// 一起下线(用户:"用户自定义可以删了,它跟添加小节重复了")。数据仍在文档里,只是不再可编辑。
|
|
2066
|
-
/* ── 项级交互(0.1.13):删除要二次确认 / 添加在底部 ─────────────────────────────
|
|
2067
|
-
*
|
|
2068
|
-
* ⚠️ **没有"编辑态"**(0.1.13 返工后的口径,用户原话):每项的**内容**一直是可编辑输入框
|
|
2069
|
-
* (`PersonaFields` 直接绑 `setIdentityValue` / `setSectionText`),
|
|
2070
|
-
* 只有**名称**是纯文字、不可编辑。所以这里只剩两件事:删除确认、底部添加表单。
|
|
2071
|
-
*
|
|
2072
|
-
* 为什么它们是**控制器状态**而不是组件的 `useState`:
|
|
2073
|
-
* ① 两者互斥(确认删除时收起添加表单),放在一处才说得清优先级;
|
|
2074
|
-
* ② 静态渲染就能断言"确认带出现了 / 添加表单展开了",测试不必依赖 DOM 事件;
|
|
2075
|
-
* ③ 保存 / 重新加载之后要一起清掉(见 `adopt`),否则会留下指向已消失项的幽灵状态。
|
|
2076
|
-
*/
|
|
2077
|
-
/**
|
|
2078
|
-
* 请求删除某一项:先进入**二次确认**态,不直接删。
|
|
2079
|
-
*
|
|
2080
|
-
* 锁定项(默认 8 项)在这里就没有这个动作 —— `canDeleteItem` 说不行就静默返回,
|
|
2081
|
-
* 连确认态都不进(V3 的正面:界面上没有删除入口)。
|
|
2082
|
-
*/
|
|
2083
|
-
requestDelete(itemId) {
|
|
2084
|
-
if (!this.state.writable || this.state.saving) return;
|
|
2085
|
-
if (!canDeleteItem(this.state.draft, itemId)) return;
|
|
2086
|
-
this.update({ pendingDelete: itemId, addForm: void 0, renaming: void 0 });
|
|
2087
|
-
}
|
|
2088
|
-
/** 放弃删除(用户点了"取消")。 */
|
|
2089
|
-
cancelDelete() {
|
|
2090
|
-
this.update({ pendingDelete: void 0 });
|
|
2091
|
-
}
|
|
2092
|
-
/**
|
|
2093
|
-
* 确认删除:**整项**从草稿里摘掉(不可逆 —— 本步没有撤销栈,`重新加载` 只能丢弃草稿)。
|
|
2094
|
-
*
|
|
2095
|
-
* 只改草稿,不直接写宿主:删除与其它编辑走同一条落盘路径(卡片上的「保存」),
|
|
2096
|
-
* 于是"进历史"由宿主既有的 `persistPersona` 负责(被取代/删除的旧内容进 `persona_history`,
|
|
2097
|
-
* 保留期见 `modules.persona.historyRetentionDays`)。
|
|
2098
|
-
*/
|
|
2099
|
-
confirmDelete() {
|
|
2100
|
-
const itemId = this.state.pendingDelete;
|
|
2101
|
-
if (itemId === void 0) return;
|
|
2102
|
-
if (!canDeleteItem(this.state.draft, itemId)) {
|
|
2103
|
-
this.update({ pendingDelete: void 0 });
|
|
2104
|
-
return;
|
|
2105
|
-
}
|
|
2106
|
-
this.edit((draft) => removeItem(draft, itemId));
|
|
2107
|
-
this.update({ pendingDelete: void 0 });
|
|
2108
|
-
}
|
|
2109
|
-
/** 打开底部的「添加」入口(点了才出现输入区 + 保存按钮)。 */
|
|
2110
|
-
openAdd(kind) {
|
|
2111
|
-
if (!this.state.writable || this.state.saving) return;
|
|
2112
|
-
this.update({ addForm: { kind, name: "", value: "" }, pendingDelete: void 0, renaming: void 0 });
|
|
2113
|
-
}
|
|
2114
|
-
/** 收起添加表单(取消:表单内容丢弃,草稿一个字不动)。 */
|
|
2115
|
-
cancelAdd() {
|
|
2116
|
-
this.update({ addForm: void 0 });
|
|
2117
|
-
}
|
|
2118
|
-
/** 改添加表单里的一个字段。 */
|
|
2119
|
-
setAddField(field, value) {
|
|
2120
|
-
const form = this.state.addForm;
|
|
2121
|
-
if (form === void 0) return;
|
|
2122
|
-
const next = { ...form, [field]: value };
|
|
2123
|
-
this.update({ addForm: next });
|
|
2124
|
-
}
|
|
2125
|
-
/**
|
|
2126
|
-
* 提交添加表单:落进草稿,随即走**同一条保存路径**写回宿主。
|
|
2127
|
-
*
|
|
2128
|
-
* 为什么顺带保存(用户:底部"增设保存按钮"):这一项是用户当场填出来的,停在草稿里
|
|
2129
|
-
* 等于"点了保存却没生效"。名字或内容为空时是**空操作**(按钮此时也是禁用的,
|
|
2130
|
-
* 两处说的是同一件事);保存被宿主拒绝时草稿保留、原因照常显示,与其它编辑一致。
|
|
2131
|
-
*/
|
|
2132
|
-
async commitAdd() {
|
|
2133
|
-
const form = this.state.addForm;
|
|
2134
|
-
if (form === void 0 || !this.state.writable || this.state.saving) return;
|
|
2135
|
-
if (!addFormReady(form)) return;
|
|
2136
|
-
this.edit((draft) => applyAddForm(draft, form));
|
|
2137
|
-
this.update({ addForm: void 0 });
|
|
2138
|
-
await this.save();
|
|
2139
|
-
}
|
|
2140
|
-
/* ── 改名(0.1.13 追加):只给用户自定义的项,平时名称仍是纯文字 ───────────────── */
|
|
2141
|
-
/**
|
|
2142
|
-
* 打开某一项的**改名**入口:名称那一格换成输入框 + 确定/取消。
|
|
2143
|
-
*
|
|
2144
|
-
* 锁定 8 项与标准小节在这里就没有这个动作(`canRenameItem` 说不行就静默返回,
|
|
2145
|
-
* 连输入框都不出现)—— 它们的名字是插件认的标识,改名会变语义(见 `canRenameItem` 的说明)。
|
|
2146
|
-
*/
|
|
2147
|
-
beginRename(itemId) {
|
|
2148
|
-
if (!this.state.writable || this.state.saving) return;
|
|
2149
|
-
if (!canRenameItem(this.state.draft, itemId)) return;
|
|
2150
|
-
const name2 = itemName(this.state.draft, itemId) ?? "";
|
|
2151
|
-
this.update({ renaming: { itemId, name: name2 }, pendingDelete: void 0, addForm: void 0 });
|
|
2152
|
-
}
|
|
2153
|
-
/** 改名字草稿(还没落进文档)。 */
|
|
2154
|
-
setRenameName(value) {
|
|
2155
|
-
const form = this.state.renaming;
|
|
2156
|
-
if (form === void 0) return;
|
|
2157
|
-
this.update({ renaming: { itemId: form.itemId, name: value } });
|
|
2158
|
-
}
|
|
2159
|
-
/** 取消改名:表单收起,草稿一个字不动(V10/V13 的"取消零改动")。 */
|
|
2160
|
-
cancelRename() {
|
|
2161
|
-
this.update({ renaming: void 0 });
|
|
2162
|
-
}
|
|
2163
|
-
/**
|
|
2164
|
-
* 确认改名:**先复查再落草稿**。
|
|
2165
|
-
*
|
|
2166
|
-
* 复查用的是与宿主校验逐条对齐的 {@link renameIssue}(空名 / 重名 / 撞标准名一律拒绝),
|
|
2167
|
-
* 所以这里不会提交一份宿主必然拒绝的文档;拒绝时**不关表单**,用户看得见自己填的名字,
|
|
2168
|
-
* 界面同时把原因写在旁边(不给"点了没反应")。
|
|
2169
|
-
*
|
|
2170
|
-
* 落盘仍走卡片上的「保存」(与删除、内容编辑同一条路),所以改名也照常进 `persona_history`。
|
|
2171
|
-
*/
|
|
2172
|
-
confirmRename() {
|
|
2173
|
-
const form = this.state.renaming;
|
|
2174
|
-
if (form === void 0) return;
|
|
2175
|
-
if (renameIssue(this.state.draft, form.itemId, form.name) !== void 0) return;
|
|
2176
|
-
this.edit((draft) => renameItem(draft, form.itemId, form.name));
|
|
2177
|
-
this.update({ renaming: void 0 });
|
|
2178
|
-
}
|
|
2179
|
-
/** 用宿主返回的一段值重建基线(stored = draft = 生效文档),并记录修订号。 */
|
|
2180
|
-
};
|
|
2181
|
-
|
|
2182
|
-
// src/client/memory-document.ts
|
|
2183
|
-
function emptyMemoryDocument() {
|
|
2184
|
-
return {
|
|
2185
|
-
entries: [],
|
|
2186
|
-
stats: { total: 0, episode: 0, period: 0, chapter: 0, recalled: 0 },
|
|
2187
|
-
projectedAt: "",
|
|
2188
|
-
storeReady: false,
|
|
2189
|
-
dormant: false,
|
|
2190
|
-
request: { op: "", id: "" },
|
|
2191
|
-
notice: "",
|
|
2192
|
-
lastRecall: { at: "", cue: "", items: [] }
|
|
2193
|
-
};
|
|
2194
|
-
}
|
|
2195
|
-
var str = (value, fallback = "") => typeof value === "string" ? value : fallback;
|
|
2196
|
-
var num = (value, fallback = 0) => typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
2197
|
-
function entryOf(raw) {
|
|
2198
|
-
const item = raw ?? {};
|
|
2199
|
-
return {
|
|
2200
|
-
id: str(item.id),
|
|
2201
|
-
what: str(item.what),
|
|
2202
|
-
when: str(item.when),
|
|
2203
|
-
about: str(item.about, "world"),
|
|
2204
|
-
certain: str(item.certain, "inferred"),
|
|
2205
|
-
feltKind: str(item.feltKind),
|
|
2206
|
-
feltLabel: str(item.feltLabel),
|
|
2207
|
-
feltIntensity: num(item.feltIntensity),
|
|
2208
|
-
strength: num(item.strength),
|
|
2209
|
-
recalled: num(item.recalled),
|
|
2210
|
-
cost: num(item.cost),
|
|
2211
|
-
costWhy: str(item.costWhy),
|
|
2212
|
-
tier: str(item.tier, "episode"),
|
|
2213
|
-
covers: num(item.covers),
|
|
2214
|
-
createdAt: str(item.createdAt)
|
|
2215
|
-
};
|
|
2216
|
-
}
|
|
2217
|
-
function recalledItemOf(raw) {
|
|
2218
|
-
const item = raw ?? {};
|
|
2219
|
-
return { what: str(item.what), match: str(item.match), withheld: item.withheld === true };
|
|
2220
|
-
}
|
|
2221
|
-
function recallOf(raw) {
|
|
2222
|
-
const value = raw ?? {};
|
|
2223
|
-
return {
|
|
2224
|
-
at: str(value.at),
|
|
2225
|
-
cue: str(value.cue),
|
|
2226
|
-
items: Array.isArray(value.items) ? value.items.map(recalledItemOf) : []
|
|
2227
|
-
};
|
|
2228
|
-
}
|
|
2229
|
-
function asMemoryDocument(value) {
|
|
2230
|
-
if (value === null || typeof value !== "object") return emptyMemoryDocument();
|
|
2231
|
-
const raw = value;
|
|
2232
|
-
const stats2 = raw.stats ?? {};
|
|
2233
|
-
const entries = Array.isArray(raw.entries) ? raw.entries.map(entryOf) : [];
|
|
2234
|
-
return {
|
|
2235
|
-
entries,
|
|
2236
|
-
stats: {
|
|
2237
|
-
total: num(stats2.total, entries.length),
|
|
2238
|
-
episode: num(stats2.episode),
|
|
2239
|
-
period: num(stats2.period),
|
|
2240
|
-
chapter: num(stats2.chapter),
|
|
2241
|
-
recalled: num(stats2.recalled)
|
|
2242
|
-
},
|
|
2243
|
-
projectedAt: str(raw.projectedAt),
|
|
2244
|
-
storeReady: raw.storeReady === true,
|
|
2245
|
-
dormant: raw.dormant === true,
|
|
2246
|
-
request: { op: str(raw.request?.op), id: str(raw.request?.id) },
|
|
2247
|
-
notice: str(raw.notice),
|
|
2248
|
-
lastRecall: recallOf(raw.lastRecall)
|
|
2249
|
-
};
|
|
2250
|
-
}
|
|
2251
|
-
|
|
2252
|
-
// src/client/memory-controller.ts
|
|
2253
|
-
var MemoryWorkbenchController = class {
|
|
2254
|
-
channel;
|
|
2255
|
-
/** 命行空间当前修订号:写回必须带上,否则并发时会被拒。 */
|
|
2256
|
-
revision;
|
|
2257
|
-
listeners = /* @__PURE__ */ new Set();
|
|
2258
|
-
state = { status: "idle", doc: emptyMemoryDocument() };
|
|
2259
|
-
/** 订阅状态变化;返回退订动作。 */
|
|
2260
|
-
subscribe = (listener) => {
|
|
2261
|
-
this.listeners.add(listener);
|
|
2262
|
-
return () => {
|
|
2263
|
-
this.listeners.delete(listener);
|
|
2264
|
-
};
|
|
2265
|
-
};
|
|
2266
|
-
/** 当前快照(也用作服务端快照:两边读的是同一个对象)。 */
|
|
2267
|
-
getSnapshot = () => this.state;
|
|
2268
|
-
/** 接上设置 RPC 并读一次。形状不对就整条通道判为不可用。 */
|
|
2269
|
-
attach(channel) {
|
|
2270
|
-
this.channel = channel !== void 0 && channel !== null && typeof channel.describe === "function" ? channel : void 0;
|
|
2271
|
-
void this.load();
|
|
2272
|
-
}
|
|
2273
|
-
/**
|
|
2274
|
-
* 越过门槛查看一条秘密。
|
|
2275
|
-
*
|
|
2276
|
-
* 客户端只把命令写进命名空间,**真正执行的权力在宿主**(`section-runtime` 的 `consume`)——
|
|
2277
|
-
* 这样"谁写了什么"和"谁有权执行"是分开的。
|
|
2278
|
-
* @param id - 要看的那条。
|
|
2279
|
-
* @returns 是否成功把命令写出去。
|
|
2280
|
-
*/
|
|
2281
|
-
async reveal(id) {
|
|
2282
|
-
return this.command("reveal", id);
|
|
2283
|
-
}
|
|
2284
|
-
/**
|
|
2285
|
-
* 删掉一条记忆。
|
|
2286
|
-
*
|
|
2287
|
-
* 不可撤销,所以界面上要先问一次再确认一次;这里只负责把命令送出去。
|
|
2288
|
-
* @param id - 要删的那条。
|
|
2289
|
-
* @returns 是否成功把命令写出去。
|
|
2290
|
-
*/
|
|
2291
|
-
async remove(id) {
|
|
2292
|
-
return this.command("delete", id);
|
|
2293
|
-
}
|
|
2294
|
-
/**
|
|
2295
|
-
* 把一条命令写进命名空间(执行权在宿主,见 `section-runtime` 的 `consume`)。
|
|
2296
|
-
*
|
|
2297
|
-
* ### 为什么要"先重读、撞了再重读"
|
|
2298
|
-
*
|
|
2299
|
-
* 命名空间是**乐观并发**:写回时要带"我读到的是第几版"。可这份文档在对话进行中一直在变
|
|
2300
|
-
* (每轮回忆都会更新投影),而页面是 30 秒前读的 —— 用户点"我要看"时版本号已经旧了,
|
|
2301
|
-
* 宿主的拒绝理由就是「修订号对不上」(2026-11-23 真机现场)。
|
|
2302
|
-
*
|
|
2303
|
-
* 所以:写之前先重读一次拿最新版本;万一这中间又变了(对话与点击同时发生),再重读重试一次。
|
|
2304
|
-
* 重试仍然失败才报错 —— 一次点击失败不该把整页打成"读不到"。
|
|
2305
|
-
*/
|
|
2306
|
-
async command(op, id) {
|
|
2307
|
-
const channel = this.channel;
|
|
2308
|
-
if (channel === void 0 || typeof channel.replace !== "function") return false;
|
|
2309
|
-
try {
|
|
2310
|
-
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
2311
|
-
await this.load({ quiet: true });
|
|
2312
|
-
if (this.state.status !== "ready") {
|
|
2313
|
-
this.update({ status: "failed", error: this.state.error ?? "读取失败" });
|
|
2314
|
-
return false;
|
|
2315
|
-
}
|
|
2316
|
-
const outcome = await channel.replace(
|
|
2317
|
-
MEMORY_NAMESPACE,
|
|
2318
|
-
{ ...this.state.doc, request: { op, id }, notice: "" },
|
|
2319
|
-
this.revision
|
|
2320
|
-
);
|
|
2321
|
-
if (outcome.ok) {
|
|
2322
|
-
this.revision = outcome.value.revision;
|
|
2323
|
-
return true;
|
|
2324
|
-
}
|
|
2325
|
-
const message = outcome.error?.message ?? "写入失败";
|
|
2326
|
-
if (!/修订|revision|conflict/i.test(message)) {
|
|
2327
|
-
this.update({ status: "failed", error: message });
|
|
2328
|
-
return false;
|
|
2329
|
-
}
|
|
2330
|
-
}
|
|
2331
|
-
this.update({ status: "failed", error: "记忆正在被对话更新,这次没写进去,请再点一次" });
|
|
2332
|
-
return false;
|
|
2333
|
-
} catch (error) {
|
|
2334
|
-
this.update({ status: "failed", error: error instanceof Error ? error.message : String(error) });
|
|
2335
|
-
return false;
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
|
-
/** 断开:回到"通道未就绪"。已读到的内容不清空(用户正在看的东西不该凭空消失)。 */
|
|
2339
|
-
detach() {
|
|
2340
|
-
this.channel = void 0;
|
|
2341
|
-
this.update({ status: "unavailable", error: void 0 });
|
|
2342
|
-
}
|
|
2343
|
-
/**
|
|
2344
|
-
* 从宿主重新读一次。**永不抛**:调用点在 `useEffect` 的异步链上。
|
|
2345
|
-
* @param options - `quiet`:静默刷新(不把状态翻成 `loading`,页面标题就不会闪)。
|
|
2346
|
-
*/
|
|
2347
|
-
async load(options = {}) {
|
|
2348
|
-
const quiet = options.quiet === true;
|
|
2349
|
-
const channel = this.channel;
|
|
2350
|
-
if (channel === void 0) {
|
|
2351
|
-
this.update({ status: "unavailable", error: void 0 });
|
|
2352
|
-
return;
|
|
2353
|
-
}
|
|
2354
|
-
if (!quiet) this.update({ status: "loading", error: void 0 });
|
|
2355
|
-
try {
|
|
2356
|
-
const outcome = await channel.describe();
|
|
2357
|
-
if (!outcome.ok) {
|
|
2358
|
-
this.update({ status: "failed", error: outcome.error?.message ?? "读取失败" });
|
|
2359
|
-
return;
|
|
2360
|
-
}
|
|
2361
|
-
const view = outcome.value.namespaces.find((item) => item.ns === MEMORY_NAMESPACE);
|
|
2362
|
-
if (view === void 0) {
|
|
2363
|
-
this.update({ status: "unavailable", doc: emptyMemoryDocument(), error: void 0 });
|
|
2364
|
-
return;
|
|
2365
|
-
}
|
|
2366
|
-
this.revision = view.revision;
|
|
2367
|
-
this.update({ status: "ready", doc: asMemoryDocument(view.value), error: void 0 });
|
|
2368
|
-
} catch (error) {
|
|
2369
|
-
this.update({ status: "failed", error: error instanceof Error ? error.message : String(error) });
|
|
2370
|
-
}
|
|
2371
|
-
}
|
|
2372
|
-
/** 合并一次状态并通知订阅者。 */
|
|
2373
|
-
update(patch) {
|
|
2374
|
-
this.state = { ...this.state, ...patch };
|
|
2375
|
-
for (const listener of this.listeners) listener();
|
|
2376
|
-
}
|
|
2377
|
-
};
|
|
2378
|
-
|
|
2379
|
-
// src/client/plane-channel.ts
|
|
2380
|
-
var COMMAND_SETTLE_MS = 250;
|
|
2381
|
-
var COMMAND_NAMESPACES = ["humanity-memory"];
|
|
2382
|
-
function delay(ms) {
|
|
2383
|
-
return new Promise((resolve) => {
|
|
2384
|
-
setTimeout(resolve, ms);
|
|
2385
|
-
});
|
|
2386
|
-
}
|
|
2387
|
-
function createPlaneChannel(rpc) {
|
|
2388
|
-
const call = async (endpoint, args) => {
|
|
2389
|
-
try {
|
|
2390
|
-
return await rpc.call("/api", `humanity/${endpoint}`, { args });
|
|
2391
|
-
} catch (error) {
|
|
2392
|
-
return { ok: false, error: { message: error instanceof Error ? error.message : String(error) } };
|
|
2393
|
-
}
|
|
2394
|
-
};
|
|
2395
|
-
const settle = async (ns, written) => {
|
|
2396
|
-
if (!written.ok || !COMMAND_NAMESPACES.includes(ns)) return written;
|
|
2397
|
-
await delay(COMMAND_SETTLE_MS);
|
|
2398
|
-
const fresh = await call("describe", {});
|
|
2399
|
-
if (!fresh.ok) return written;
|
|
2400
|
-
const view = fresh.value.namespaces.find((candidate) => candidate.ns === ns);
|
|
2401
|
-
return view === void 0 ? written : { ok: true, value: view };
|
|
2402
|
-
};
|
|
2403
|
-
return {
|
|
2404
|
-
describe: () => call("describe", {}),
|
|
2405
|
-
replace: async (ns, section, expectedRevision) => settle(ns, await call("replace", { ns, section, expectedRevision })),
|
|
2406
|
-
update: async (ns, patch, expectedRevision) => settle(ns, await call("update", { ns, patch, expectedRevision }))
|
|
2407
|
-
};
|
|
2408
|
-
}
|
|
2409
|
-
|
|
2410
|
-
// src/client/remote-attach.ts
|
|
2411
|
-
function subscribeToProjection(remote, namespaces, reload) {
|
|
2412
|
-
const events = remote;
|
|
2413
|
-
if (events === void 0 || typeof events.$on !== "function") return () => {
|
|
2414
|
-
};
|
|
2415
|
-
try {
|
|
2416
|
-
return events.$on("settings/document-updated", (ns) => {
|
|
2417
|
-
if (namespaces.includes(ns)) reload();
|
|
2418
|
-
});
|
|
2419
|
-
} catch (error) {
|
|
2420
|
-
console.error("[humanity] 设置变更订阅失败,工作台将不会自动刷新", error);
|
|
2421
|
-
return () => {
|
|
2422
|
-
};
|
|
2423
|
-
}
|
|
2424
|
-
}
|
|
2425
|
-
function attachRemoteController(ctx, controller, namespace, label, options = {}) {
|
|
2426
|
-
ctx.inject(["connection"], (sctx) => {
|
|
2427
|
-
try {
|
|
2428
|
-
const connection = sctx.connection;
|
|
2429
|
-
controller.attach(createPlaneChannel(connection.rpc));
|
|
2430
|
-
} catch (error) {
|
|
2431
|
-
console.error(`[humanity] ${label}通道接入失败,将显示为未就绪`, error);
|
|
2432
|
-
controller.detach();
|
|
2433
|
-
return;
|
|
2434
|
-
}
|
|
2435
|
-
void controller.load({ quiet: true });
|
|
2436
|
-
const pollMs = options.pollMs ?? 0;
|
|
2437
|
-
const timer = pollMs > 0 && typeof document !== "undefined" ? setInterval(() => {
|
|
2438
|
-
void controller.load({ quiet: true });
|
|
2439
|
-
}, pollMs) : void 0;
|
|
2440
|
-
return () => {
|
|
2441
|
-
if (timer !== void 0) clearInterval(timer);
|
|
2442
|
-
controller.detach();
|
|
2443
|
-
};
|
|
2444
|
-
});
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
// src/client/WorkbenchSeat.tsx
|
|
2448
|
-
var import_react11 = require("react");
|
|
2449
|
-
|
|
2450
|
-
// src/client/HumanityWorkbench.tsx
|
|
2451
|
-
var import_react9 = require("react");
|
|
2452
|
-
|
|
2453
|
-
// src/client/EmotionPage.tsx
|
|
2454
|
-
var import_react2 = require("react");
|
|
2455
|
-
|
|
2456
|
-
// src/host/emotion/constants.ts
|
|
2457
|
-
var EMOTION_TIERS = [
|
|
2458
|
-
{ id: "calm", at: 0 },
|
|
2459
|
-
{ id: "faint", at: 30 },
|
|
2460
|
-
{ id: "clear", at: 50 },
|
|
2461
|
-
{ id: "burst", at: 75 }
|
|
2462
|
-
];
|
|
2463
|
-
var RENDER_FLOOR = 10;
|
|
2464
|
-
var SENSITIVITY_HALF_LIFE_MINUTES = 1440;
|
|
2465
|
-
var SENSITIVITY_MAX_BOOST = 0.5;
|
|
2466
|
-
var SOOTHE_QUIET_MINUTES = 30;
|
|
2467
|
-
|
|
2468
|
-
// src/client/styles.ts
|
|
2469
|
-
var page = {
|
|
2470
|
-
boxSizing: "border-box",
|
|
2471
|
-
height: "100%",
|
|
2472
|
-
overflowY: "auto",
|
|
2473
|
-
padding: "32px 32px 56px",
|
|
2474
|
-
background: "transparent",
|
|
2475
|
-
color: "var(--dsw-alias-label-primary)",
|
|
2476
|
-
fontFamily: "var(--dsw-font-family)",
|
|
2477
|
-
fontSize: "var(--dsh-content-font-size, 14px)",
|
|
2478
|
-
lineHeight: 1.6
|
|
2479
|
-
};
|
|
2480
|
-
var column = {
|
|
2481
|
-
maxWidth: 880,
|
|
2482
|
-
margin: "0 auto"
|
|
2483
|
-
};
|
|
2484
|
-
var titleRow = {
|
|
2485
|
-
display: "flex",
|
|
2486
|
-
alignItems: "center",
|
|
2487
|
-
gap: 12
|
|
2488
|
-
};
|
|
2489
|
-
var title = {
|
|
2490
|
-
margin: 0,
|
|
2491
|
-
fontSize: 22,
|
|
2492
|
-
fontWeight: 600,
|
|
2493
|
-
letterSpacing: "0.01em"
|
|
2494
|
-
};
|
|
2495
|
-
var subtitle = {
|
|
2496
|
-
margin: "8px 0 0",
|
|
2497
|
-
color: "var(--dsw-alias-label-secondary)"
|
|
2498
|
-
};
|
|
2499
|
-
var panel = {
|
|
2500
|
-
marginTop: 24,
|
|
2501
|
-
padding: "16px 20px",
|
|
2502
|
-
border: "1px solid var(--dsw-alias-border-l1)",
|
|
2503
|
-
borderRadius: 12,
|
|
2504
|
-
background: "var(--dsw-alias-bg-layer-1)"
|
|
2505
|
-
};
|
|
2506
|
-
var panelTitle = {
|
|
2507
|
-
margin: "0 0 8px",
|
|
2508
|
-
fontSize: 14,
|
|
2509
|
-
fontWeight: 600,
|
|
2510
|
-
color: "var(--dsw-alias-label-primary)"
|
|
2511
|
-
};
|
|
2512
|
-
var headingWithHint = {
|
|
2513
|
-
display: "flex",
|
|
2514
|
-
alignItems: "center",
|
|
2515
|
-
gap: 6
|
|
2516
|
-
};
|
|
2517
|
-
var hint = {
|
|
2518
|
-
margin: 0,
|
|
2519
|
-
color: "var(--dsw-alias-label-secondary)"
|
|
2520
|
-
};
|
|
2521
|
-
var toggleCard = {
|
|
2522
|
-
display: "flex",
|
|
2523
|
-
alignItems: "center",
|
|
2524
|
-
justifyContent: "space-between",
|
|
2525
|
-
gap: 16,
|
|
2526
|
-
marginTop: 16,
|
|
2527
|
-
padding: "12px 16px",
|
|
2528
|
-
border: "1px solid var(--dsw-alias-border-l2)",
|
|
2529
|
-
borderRadius: 10,
|
|
2530
|
-
background: "var(--dsw-alias-bg-layer-1)"
|
|
2531
|
-
};
|
|
2532
|
-
var toggleText = {
|
|
2533
|
-
display: "flex",
|
|
2534
|
-
flexDirection: "column",
|
|
2535
|
-
gap: 2
|
|
2536
|
-
};
|
|
2537
|
-
var toggleState = {
|
|
2538
|
-
display: "flex",
|
|
2539
|
-
alignItems: "center",
|
|
2540
|
-
gap: 8,
|
|
2541
|
-
color: "var(--dsw-alias-label-secondary)",
|
|
2542
|
-
fontSize: "0.9em"
|
|
2543
|
-
};
|
|
2544
|
-
|
|
2545
|
-
// src/client/EmotionPage.tsx
|
|
2546
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2547
|
-
function tierAt(id) {
|
|
2548
|
-
return EMOTION_TIERS.find((tier) => tier.id === id)?.at ?? 0;
|
|
2549
|
-
}
|
|
2550
|
-
var barTrack = {
|
|
2551
|
-
position: "relative",
|
|
2552
|
-
height: 6,
|
|
2553
|
-
borderRadius: 3,
|
|
2554
|
-
background: "var(--dsw-alias-border-l2)",
|
|
2555
|
-
overflow: "visible"
|
|
2556
|
-
};
|
|
2557
|
-
var barFill = {
|
|
2558
|
-
position: "absolute",
|
|
2559
|
-
top: 0,
|
|
2560
|
-
bottom: 0,
|
|
2561
|
-
left: 0,
|
|
2562
|
-
borderRadius: 3,
|
|
2563
|
-
background: "var(--dsw-alias-brand-primary)",
|
|
2564
|
-
opacity: 0.4
|
|
2565
|
-
};
|
|
2566
|
-
var barMarker = {
|
|
2567
|
-
position: "absolute",
|
|
2568
|
-
top: -4,
|
|
2569
|
-
width: 2,
|
|
2570
|
-
height: 14,
|
|
2571
|
-
borderRadius: 1,
|
|
2572
|
-
background: "var(--dsw-alias-brand-primary)"
|
|
2573
|
-
};
|
|
2574
|
-
var barDelta = {
|
|
2575
|
-
position: "absolute",
|
|
2576
|
-
top: 0,
|
|
2577
|
-
bottom: 0,
|
|
2578
|
-
borderRadius: 3
|
|
2579
|
-
};
|
|
2580
|
-
var chargeBlock = {
|
|
2581
|
-
padding: "10px 0 2px",
|
|
2582
|
-
borderTop: "1px solid var(--dsw-alias-border-l1)"
|
|
2583
|
-
};
|
|
2584
|
-
var chargeHead = {
|
|
2585
|
-
display: "flex",
|
|
2586
|
-
alignItems: "baseline",
|
|
2587
|
-
gap: 12
|
|
2588
|
-
};
|
|
2589
|
-
var chargeTrackRow = {
|
|
2590
|
-
display: "grid",
|
|
2591
|
-
gridTemplateColumns: "1fr 44px 56px",
|
|
2592
|
-
alignItems: "center",
|
|
2593
|
-
gap: 12,
|
|
2594
|
-
marginTop: 6
|
|
2595
|
-
};
|
|
2596
|
-
var DELTA_UP_COLOR = "#3fb950";
|
|
2597
|
-
var DELTA_DOWN_COLOR = "#f85149";
|
|
2598
|
-
var meta = {
|
|
2599
|
-
margin: "4px 0 0",
|
|
2600
|
-
color: "var(--dsw-alias-label-secondary)",
|
|
2601
|
-
fontSize: "0.9em"
|
|
2602
|
-
};
|
|
2603
|
-
var TIER_KEYS = {
|
|
2604
|
-
burst: "emotion.tier.burst",
|
|
2605
|
-
clear: "emotion.tier.clear",
|
|
2606
|
-
faint: "emotion.tier.faint",
|
|
2607
|
-
calm: "emotion.tier.calm"
|
|
2608
|
-
};
|
|
2609
|
-
var ENERGY_KEYS = {
|
|
2610
|
-
fresh: "emotion.energy.fresh",
|
|
2611
|
-
tired: "emotion.energy.tired",
|
|
2612
|
-
exhausted: "emotion.energy.exhausted"
|
|
2613
|
-
};
|
|
2614
|
-
function minutesBetween(iso, now) {
|
|
2615
|
-
const at = Date.parse(iso);
|
|
2616
|
-
if (iso === "" || Number.isNaN(at)) return void 0;
|
|
2617
|
-
return Math.max(0, Math.round((now - at) / 6e4));
|
|
2618
|
-
}
|
|
2619
|
-
function spanText(t, minutes) {
|
|
2620
|
-
if (minutes < 60) return t("emotion.duration.minutes", { n: String(minutes) });
|
|
2621
|
-
if (minutes < 60 * 24) return t("emotion.duration.hours", { n: String(Math.round(minutes / 60)) });
|
|
2622
|
-
return t("emotion.duration.days", { n: String(Math.round(minutes / (60 * 24))) });
|
|
2623
|
-
}
|
|
2624
|
-
function durationText(t, since, now) {
|
|
2625
|
-
const minutes = minutesBetween(since, now);
|
|
2626
|
-
if (minutes === void 0) return "";
|
|
2627
|
-
if (minutes < 1) return t("emotion.agoNow");
|
|
2628
|
-
return t("emotion.since", { duration: spanText(t, minutes) });
|
|
2629
|
-
}
|
|
2630
|
-
function agoText(t, iso, now) {
|
|
2631
|
-
const minutes = minutesBetween(iso, now);
|
|
2632
|
-
if (minutes === void 0) return "";
|
|
2633
|
-
if (minutes < 1) return t("emotion.agoNow");
|
|
2634
|
-
return t("emotion.ago", { duration: spanText(t, minutes) });
|
|
2635
|
-
}
|
|
2636
|
-
function ChargeRow({ t, charge, now }) {
|
|
2637
|
-
const absent = charge.intensity <= 0;
|
|
2638
|
-
const duration = absent ? "" : durationText(t, charge.since, now);
|
|
2639
|
-
const cause = charge.cause === "" ? t("emotion.noCause") : charge.cause;
|
|
2640
|
-
const color = absent ? "var(--dsw-alias-label-tertiary)" : "var(--dsw-alias-label-primary)";
|
|
2641
|
-
const cur = Math.max(0, Math.min(100, charge.intensity));
|
|
2642
|
-
const before = Math.max(0, Math.min(100, charge.before));
|
|
2643
|
-
const from = Math.min(before, cur);
|
|
2644
|
-
const change = Math.abs(cur - before);
|
|
2645
|
-
const changed = charge.before >= 0 && charge.delta !== 0 && change > 0;
|
|
2646
|
-
const grew = cur >= before;
|
|
2647
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: chargeBlock, children: [
|
|
2648
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: chargeHead, children: [
|
|
2649
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { fontWeight: absent ? 400 : 600, color, whiteSpace: "nowrap", minWidth: 96 }, children: [
|
|
2650
|
-
charge.targetLabel,
|
|
2651
|
-
charge.label
|
|
2652
|
-
] }),
|
|
2653
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { ...meta, margin: 0, flex: 1, color: absent ? "var(--dsw-alias-label-tertiary)" : meta.color }, children: absent ? t("emotion.absent") : `${t("emotion.cause")}:${cause}${duration === "" ? "" : ` · ${duration}`}` })
|
|
2654
|
-
] }),
|
|
2655
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: chargeTrackRow, children: [
|
|
2656
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: barTrack, children: [
|
|
2657
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { ...barFill, width: `${cur}%`, opacity: absent ? 0.2 : 0.4 } }),
|
|
2658
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { ...barMarker, left: `${cur}%`, opacity: absent ? 0.3 : 1 } }),
|
|
2659
|
-
changed ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2660
|
-
"span",
|
|
2661
|
-
{
|
|
2662
|
-
title: (grew ? t("emotion.deltaUp") : t("emotion.deltaDown")).replace("{n}", String(Math.round(change))),
|
|
2663
|
-
style: {
|
|
2664
|
-
...barDelta,
|
|
2665
|
-
left: `${from}%`,
|
|
2666
|
-
width: `${change}%`,
|
|
2667
|
-
background: grew ? DELTA_UP_COLOR : DELTA_DOWN_COLOR
|
|
2668
|
-
}
|
|
2669
|
-
}
|
|
2670
|
-
) : null
|
|
2671
|
-
] }),
|
|
2672
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { ...meta, margin: 0, textAlign: "right", fontVariantNumeric: "tabular-nums" }, children: Math.round(cur) }),
|
|
2673
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { ...meta, margin: 0 }, children: absent ? "" : t(TIER_KEYS[charge.tier] ?? "emotion.tier.calm") })
|
|
2674
|
-
] })
|
|
2675
|
-
] });
|
|
2676
|
-
}
|
|
2677
|
-
function EmotionPage({ t, controller }) {
|
|
2678
|
-
const state = (0, import_react2.useSyncExternalStore)(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
2679
|
-
(0, import_react2.useEffect)(() => {
|
|
2680
|
-
void controller.load({ quiet: true });
|
|
2681
|
-
const timer = setInterval(() => {
|
|
2682
|
-
void controller.load({ quiet: true });
|
|
2683
|
-
}, 3e4);
|
|
2684
|
-
return () => {
|
|
2685
|
-
clearInterval(timer);
|
|
2686
|
-
};
|
|
2687
|
-
}, [controller]);
|
|
2688
|
-
const now = Date.now();
|
|
2689
|
-
const document2 = state.document;
|
|
2690
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: page, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: column, children: [
|
|
2691
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { children: [
|
|
2692
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: titleRow, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { style: title, children: t("emotion.title") }) }),
|
|
2693
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: subtitle, children: t("emotion.hint") })
|
|
2694
|
-
] }),
|
|
2695
|
-
state.status === "loading" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...subtitle, marginTop: 16 }, children: t("emotion.loading") }),
|
|
2696
|
-
state.status === "unavailable" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...subtitle, marginTop: 16 }, children: t("emotion.unavailable") }),
|
|
2697
|
-
state.status === "failed" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...subtitle, marginTop: 16 }, children: t("emotion.failed", { message: state.error ?? "" }) }),
|
|
2698
|
-
document2 !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2699
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { style: panel, children: [
|
|
2700
|
-
document2.charges.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...hint, margin: 0 }, children: t("emotion.empty") }) : (
|
|
2701
|
-
// 全部列出来:这一页是观察窗,藏起弱的那几条等于让人以为它情绪很少。
|
|
2702
|
-
document2.charges.map((charge) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChargeRow, { t, charge, now }, `${charge.kind}-${charge.since}`))
|
|
2703
|
-
),
|
|
2704
|
-
document2.compositeLabel === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { style: { ...meta, marginTop: 16 }, children: [
|
|
2705
|
-
t("emotion.composite"),
|
|
2706
|
-
":",
|
|
2707
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { style: { color: "var(--dsw-alias-label-primary)" }, children: document2.compositeLabel }),
|
|
2708
|
-
document2.compositeParts.length === 2 ? `(${document2.compositeParts.join(" + ")})` : ""
|
|
2709
|
-
] }),
|
|
2710
|
-
document2.charges.some((charge) => charge.tier === "burst") && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...meta, marginTop: 12 }, children: t("emotion.tier.burstHint") })
|
|
2711
|
-
] }),
|
|
2712
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { style: panel, children: [
|
|
2713
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { style: panelTitle, children: t("emotion.sensitivity") }),
|
|
2714
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...meta, marginTop: 0 }, children: t("emotion.sensitivityHint") }),
|
|
2715
|
-
document2.sensitivities.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...meta, marginTop: 8 }, children: t("emotion.sensitivityEmpty") }) : document2.sensitivities.map((entry) => {
|
|
2716
|
-
const when = agoText(t, entry.at, now);
|
|
2717
|
-
const level = Math.max(0, Math.min(1, entry.level));
|
|
2718
|
-
const before = Math.max(0, Math.min(1, entry.levelBefore));
|
|
2719
|
-
const from = Math.min(before, level) * 100;
|
|
2720
|
-
const width = Math.abs(level - before) * 100;
|
|
2721
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: chargeBlock, children: [
|
|
2722
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: chargeHead, children: [
|
|
2723
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { fontWeight: 600, whiteSpace: "nowrap", minWidth: 96 }, children: [
|
|
2724
|
-
entry.targetLabel,
|
|
2725
|
-
entry.label
|
|
2726
|
-
] }),
|
|
2727
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { ...meta, margin: 0, flex: 1 }, children: entry.cause === "" ? t("emotion.sensitivityNoCause") : `${t("emotion.cause")}:${entry.cause}${entry.at === "" ? "" : ` · ${when}`}` })
|
|
2728
|
-
] }),
|
|
2729
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: chargeTrackRow, children: [
|
|
2730
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: barTrack, children: [
|
|
2731
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { ...barFill, width: `${Math.round(level * 100)}%` } }),
|
|
2732
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { ...barMarker, left: `${Math.round(level * 100)}%` } }),
|
|
2733
|
-
width <= 0 || entry.at === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2734
|
-
"span",
|
|
2735
|
-
{
|
|
2736
|
-
title: t("emotion.sensitivityDelta"),
|
|
2737
|
-
style: {
|
|
2738
|
-
...barDelta,
|
|
2739
|
-
left: `${from}%`,
|
|
2740
|
-
width: `${width}%`,
|
|
2741
|
-
background: level >= before ? DELTA_UP_COLOR : DELTA_DOWN_COLOR
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
)
|
|
2745
|
-
] }),
|
|
2746
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { ...meta, margin: 0, textAlign: "right", fontVariantNumeric: "tabular-nums" }, children: [
|
|
2747
|
-
Math.round(level * 100),
|
|
2748
|
-
"%"
|
|
2749
|
-
] }),
|
|
2750
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { ...meta, margin: 0 } })
|
|
2751
|
-
] })
|
|
2752
|
-
] }, `${entry.kind}-${entry.target}`);
|
|
2753
|
-
})
|
|
2754
|
-
] }),
|
|
2755
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { style: panel, children: [
|
|
2756
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { style: panelTitle, children: t("emotion.warmth") }),
|
|
2757
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...meta, marginTop: 0 }, children: t("emotion.warmthHint") }),
|
|
2758
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { ...barTrack, marginTop: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2759
|
-
"span",
|
|
2760
|
-
{
|
|
2761
|
-
style: {
|
|
2762
|
-
display: "block",
|
|
2763
|
-
height: "100%",
|
|
2764
|
-
width: `${Math.max(0, Math.min(100, document2.warmth))}%`,
|
|
2765
|
-
borderRadius: 3,
|
|
2766
|
-
background: "var(--dsw-alias-label-primary)"
|
|
2767
|
-
}
|
|
2768
|
-
}
|
|
2769
|
-
) }),
|
|
2770
|
-
document2.warmthCause === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: meta, children: document2.warmthCause })
|
|
2771
|
-
] }),
|
|
2772
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { style: panel, children: [
|
|
2773
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { style: panelTitle, children: t("emotion.energy") }),
|
|
2774
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...meta, marginTop: 0 }, children: t("emotion.energyHint") }),
|
|
2775
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { ...barTrack, marginTop: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2776
|
-
"span",
|
|
2777
|
-
{
|
|
2778
|
-
style: {
|
|
2779
|
-
display: "block",
|
|
2780
|
-
height: "100%",
|
|
2781
|
-
width: `${Math.max(0, Math.min(100, document2.energy))}%`,
|
|
2782
|
-
borderRadius: 3,
|
|
2783
|
-
background: "var(--dsw-alias-label-primary)"
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
) }),
|
|
2787
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: meta, children: t(ENERGY_KEYS[document2.energyLevel] ?? "emotion.energy.fresh") })
|
|
2788
|
-
] }),
|
|
2789
|
-
document2.perceived === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { style: panel, children: [
|
|
2790
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { style: panelTitle, children: t("emotion.perceived") }),
|
|
2791
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...meta, marginTop: 0 }, children: t("emotion.perceivedHint") }),
|
|
2792
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { margin: "8px 0 0" }, children: document2.perceived })
|
|
2793
|
-
] }),
|
|
2794
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { style: panel, children: [
|
|
2795
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { style: panelTitle, children: t("emotion.params.title") }),
|
|
2796
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { ...meta, marginTop: 0 }, children: t("emotion.params.hint") }),
|
|
2797
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("ul", { style: { ...meta, margin: "8px 0 0", paddingLeft: 18, lineHeight: 1.8 }, children: [
|
|
2798
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { children: t("emotion.params.floor", { floor: RENDER_FLOOR }) }),
|
|
2799
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { children: t("emotion.params.tiers", {
|
|
2800
|
-
faint: tierAt("faint"),
|
|
2801
|
-
clear: tierAt("clear"),
|
|
2802
|
-
burst: tierAt("burst")
|
|
2803
|
-
}) }),
|
|
2804
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { children: t("emotion.params.sensitivity", {
|
|
2805
|
-
boost: (1 + SENSITIVITY_MAX_BOOST).toFixed(1),
|
|
2806
|
-
hours: Math.round(SENSITIVITY_HALF_LIFE_MINUTES / 60)
|
|
2807
|
-
}) }),
|
|
2808
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { children: t("emotion.params.soothe", { minutes: SOOTHE_QUIET_MINUTES }) })
|
|
2809
|
-
] })
|
|
2810
|
-
] }),
|
|
2811
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { style: { ...subtitle, marginTop: 16 }, children: [
|
|
2812
|
-
t("emotion.settledAt", { time: agoText(t, document2.settledAt, now) }),
|
|
2813
|
-
" · ",
|
|
2814
|
-
t("emotion.globalHint")
|
|
2815
|
-
] })
|
|
2816
|
-
] })
|
|
2817
|
-
] }) });
|
|
2818
|
-
}
|
|
2819
|
-
|
|
2820
|
-
// src/client/EvolutionPage.tsx
|
|
2821
|
-
var import_react3 = require("react");
|
|
2822
|
-
|
|
2823
|
-
// src/client/InfoHint.tsx
|
|
2824
|
-
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
2825
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2826
|
-
var anchor = {
|
|
2827
|
-
padding: "0 2px",
|
|
2828
|
-
height: 18,
|
|
2829
|
-
minHeight: 18,
|
|
2830
|
-
color: "var(--dsw-alias-label-tertiary)",
|
|
2831
|
-
cursor: "help",
|
|
2832
|
-
lineHeight: 0
|
|
2833
|
-
};
|
|
2834
|
-
function InfoHint({ label, side = "top", delayMs = 0 }) {
|
|
2835
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives.Tooltip, { label, side, delayMs, maxWidth: 360, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "ghost", style: anchor, "aria-label": label, children: IconQuestion ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconQuestion, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": true, children: "?" }) }) });
|
|
2836
|
-
}
|
|
2837
|
-
|
|
2838
|
-
// src/client/EvolutionPage.tsx
|
|
2839
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2840
|
-
function energyText(t, energy) {
|
|
2841
|
-
const value = Math.max(0, Math.min(100, Math.round(energy)));
|
|
2842
|
-
const level = value >= 70 ? "fresh" : value >= 40 ? "ok" : value >= 25 ? "tired" : "spent";
|
|
2843
|
-
return t(`workbench.evolution.energy.${level}`).replace("{value}", String(value));
|
|
2844
|
-
}
|
|
2845
|
-
function stamp(iso) {
|
|
2846
|
-
if (iso === "") return "—";
|
|
2847
|
-
const at = Date.parse(iso);
|
|
2848
|
-
if (!Number.isFinite(at)) return "—";
|
|
2849
|
-
const date = new Date(at);
|
|
2850
|
-
const pad = (value) => String(value).padStart(2, "0");
|
|
2851
|
-
return `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
2852
|
-
}
|
|
2853
|
-
function appraiseText(t, raw) {
|
|
2854
|
-
const [kind, count, targets] = raw.split(":");
|
|
2855
|
-
if (kind === "applied") {
|
|
2856
|
-
return t("workbench.evolution.appraise.applied").replace("{count}", count ?? "0").replace("{targets}", targets ?? "");
|
|
2857
|
-
}
|
|
2858
|
-
if (kind === "no-feeling") return t("workbench.evolution.appraise.none");
|
|
2859
|
-
return t("workbench.evolution.appraise.skipped");
|
|
2860
|
-
}
|
|
2861
|
-
function DiaryRow({
|
|
2862
|
-
t,
|
|
2863
|
-
item,
|
|
2864
|
-
onOpen
|
|
2865
|
-
}) {
|
|
2866
|
-
const [confirming, setConfirming] = (0, import_react3.useState)(false);
|
|
2867
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { padding: "10px 0", borderBottom: "1px solid var(--dsw-alias-border-l2)" }, children: [
|
|
2868
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 12 }, children: [
|
|
2869
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontVariantNumeric: "tabular-nums" }, children: item.date }),
|
|
2870
|
-
item.opened ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { color: "var(--dsw-alias-label-secondary)", fontSize: 12 }, children: [
|
|
2871
|
-
t("workbench.evolution.diary.openedAt").replace("{time}", stamp(item.openedAt)),
|
|
2872
|
-
" · ",
|
|
2873
|
-
item.noticedAt === "" ? t("workbench.evolution.diary.unnoticed") : t("workbench.evolution.diary.noticed").replace("{time}", stamp(item.noticedAt))
|
|
2874
|
-
] }) : confirming ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { display: "flex", gap: 8, alignItems: "center" }, children: [
|
|
2875
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.diary.confirm") }),
|
|
2876
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2877
|
-
"button",
|
|
2878
|
-
{
|
|
2879
|
-
type: "button",
|
|
2880
|
-
onClick: () => {
|
|
2881
|
-
setConfirming(false);
|
|
2882
|
-
void onOpen(item.date);
|
|
2883
|
-
},
|
|
2884
|
-
children: t("workbench.evolution.diary.confirmYes")
|
|
2885
|
-
}
|
|
2886
|
-
),
|
|
2887
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: () => setConfirming(false), children: t("workbench.evolution.diary.confirmNo") })
|
|
2888
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: () => setConfirming(true), children: t("workbench.evolution.diary.open") })
|
|
2889
|
-
] }),
|
|
2890
|
-
item.opened && item.text !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: "8px 0 0", whiteSpace: "pre-wrap", lineHeight: 1.75 }, children: item.text }) : null
|
|
2891
|
-
] });
|
|
2892
|
-
}
|
|
2893
|
-
function EvolutionPage({ t, controller }) {
|
|
2894
|
-
const state = (0, import_react3.useSyncExternalStore)(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
2895
|
-
const status = state.doc.status;
|
|
2896
|
-
const lookedEmpty = status.maxPerDay === 0 && status.dayCount === 0 && status.lastWakeAt === "" && status.nextAt === "";
|
|
2897
|
-
const unavailable = state.status !== "ready" || lookedEmpty;
|
|
2898
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
2899
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { style: panel, children: [
|
|
2900
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
2901
|
-
t("workbench.evolution.today"),
|
|
2902
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InfoHint, { label: t("workbench.evolution.todayHint") })
|
|
2903
|
-
] }),
|
|
2904
|
-
unavailable ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: 0, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.metric.unavailable") }) : !status.started ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: 0, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.notStarted") }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dl", { style: { margin: 0, display: "grid", gridTemplateColumns: "max-content 1fr", gap: "8px 16px" }, children: [
|
|
2905
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { style: { color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.field.state") }),
|
|
2906
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { style: { margin: 0 }, children: status.sleeping ? t("workbench.evolution.state.sleeping") : t("workbench.evolution.state.awake") }),
|
|
2907
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { style: { color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.field.energy") }),
|
|
2908
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { style: { margin: 0 }, children: energyText(t, status.energy) }),
|
|
2909
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { style: { color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.field.wakes") }),
|
|
2910
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dd", { style: { margin: 0, display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
2911
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: t("workbench.evolution.wakesValue").replace("{count}", String(status.dayCount)).replace("{max}", String(status.maxPerDay)) }),
|
|
2912
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2913
|
-
"input",
|
|
2914
|
-
{
|
|
2915
|
-
type: "number",
|
|
2916
|
-
min: 0,
|
|
2917
|
-
max: 24,
|
|
2918
|
-
defaultValue: status.maxPerDay,
|
|
2919
|
-
"aria-label": t("workbench.evolution.cap.aria"),
|
|
2920
|
-
style: { width: 64 },
|
|
2921
|
-
onKeyDown: (event) => {
|
|
2922
|
-
if (event.key !== "Enter") return;
|
|
2923
|
-
const value = Number(event.target.value);
|
|
2924
|
-
if (Number.isInteger(value) && value >= 0 && value <= 24) void controller.setWakeCap(value);
|
|
2925
|
-
}
|
|
2926
|
-
}
|
|
2927
|
-
)
|
|
2928
|
-
] }),
|
|
2929
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { style: { color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.field.lastWake") }),
|
|
2930
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { style: { margin: 0, fontVariantNumeric: "tabular-nums" }, children: stamp(status.lastWakeAt) }),
|
|
2931
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { style: { color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.field.lastTurn") }),
|
|
2932
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dd", { style: { margin: 0 }, children: [
|
|
2933
|
-
status.lastTurnTools > 0 ? t("workbench.evolution.lastTurn.tools").replace("{count}", String(status.lastTurnTools)) : t("workbench.evolution.lastTurn.talk"),
|
|
2934
|
-
status.lastAppraise !== "" ? ` · ${appraiseText(t, status.lastAppraise)}` : ""
|
|
2935
|
-
] }),
|
|
2936
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { style: { color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.field.nextWake") }),
|
|
2937
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dd", { style: { margin: 0, fontVariantNumeric: "tabular-nums" }, children: [
|
|
2938
|
-
stamp(status.nextAt),
|
|
2939
|
-
status.busy ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { marginLeft: 8, fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: [
|
|
2940
|
-
t("workbench.evolution.busy"),
|
|
2941
|
-
status.busySince !== "" ? ` ${t("workbench.evolution.busySince").replace("{time}", stamp(status.busySince))}` : ""
|
|
2942
|
-
] }) : null
|
|
2943
|
-
] })
|
|
2944
|
-
] }),
|
|
2945
|
-
status.lastError !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: "10px 0 0", fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.error").replace("{reason}", status.lastError) }) : null
|
|
2946
|
-
] }),
|
|
2947
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { style: { ...panel, marginTop: 16 }, children: [
|
|
2948
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
2949
|
-
t("workbench.evolution.room.title"),
|
|
2950
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InfoHint, { label: t("workbench.evolution.room.hint") })
|
|
2951
|
-
] }),
|
|
2952
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2953
|
-
"input",
|
|
2954
|
-
{
|
|
2955
|
-
type: "text",
|
|
2956
|
-
defaultValue: status.roomText,
|
|
2957
|
-
placeholder: t("workbench.evolution.room.placeholder"),
|
|
2958
|
-
"aria-label": t("workbench.evolution.room.aria"),
|
|
2959
|
-
style: { flex: "1 1 260px", minWidth: 200 },
|
|
2960
|
-
onKeyDown: (event) => {
|
|
2961
|
-
if (event.key !== "Enter") return;
|
|
2962
|
-
void controller.setRoom(event.target.value.trim());
|
|
2963
|
-
}
|
|
2964
|
-
}
|
|
2965
|
-
) }),
|
|
2966
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: "8px 0 0", fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: status.roomPath !== "" ? t("workbench.evolution.room.nowAt").replace("{path}", status.roomPath) : t("workbench.evolution.room.legacy") }),
|
|
2967
|
-
status.roomTarget !== "" && status.roomTarget !== status.roomPath ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: "4px 0 0", fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.room.pending").replace("{path}", status.roomTarget) }) : null
|
|
2968
|
-
] }),
|
|
2969
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { style: { ...panel, marginTop: 16 }, children: [
|
|
2970
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
2971
|
-
t("workbench.evolution.tell.title"),
|
|
2972
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InfoHint, { label: t("workbench.evolution.tell.hint") })
|
|
2973
|
-
] }),
|
|
2974
|
-
state.doc.tell.pending !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { style: { margin: "0 0 8px", whiteSpace: "pre-wrap", lineHeight: 1.75 }, children: [
|
|
2975
|
-
t("workbench.evolution.tell.pending"),
|
|
2976
|
-
":",
|
|
2977
|
-
state.doc.tell.pending,
|
|
2978
|
-
state.doc.tell.pendingShow !== "" ? ` · ${t("workbench.evolution.tell.withWork").replace("{name}", state.doc.tell.pendingShow)}` : ""
|
|
2979
|
-
] }) : null,
|
|
2980
|
-
state.doc.tell.lastAt !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { style: { margin: "0 0 4px", whiteSpace: "pre-wrap", lineHeight: 1.75 }, children: [
|
|
2981
|
-
t("workbench.evolution.tell.lastAt").replace("{time}", stamp(state.doc.tell.lastAt)),
|
|
2982
|
-
":",
|
|
2983
|
-
state.doc.tell.lastText === "" ? t("workbench.evolution.tell.onlyWork") : state.doc.tell.lastText,
|
|
2984
|
-
state.doc.tell.lastShow !== "" ? ` · ${t("workbench.evolution.tell.withWork").replace("{name}", state.doc.tell.lastShow)}` : ""
|
|
2985
|
-
] }) : null,
|
|
2986
|
-
state.doc.tell.lastAt !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: 0, fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: state.doc.tell.unread ? t("workbench.evolution.tell.unread") : t("workbench.evolution.tell.seen") }) : null,
|
|
2987
|
-
state.doc.tell.lastReason !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: "6px 0 0", fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.tell.reason").replace("{reason}", state.doc.tell.lastReason) }) : null,
|
|
2988
|
-
state.doc.tell.lastAt === "" && state.doc.tell.pending === "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: 0, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.tell.empty") }) : null
|
|
2989
|
-
] }),
|
|
2990
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { style: { ...panel, marginTop: 16 }, children: [
|
|
2991
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
2992
|
-
t("workbench.evolution.diary.title"),
|
|
2993
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InfoHint, { label: t("workbench.evolution.diary.hint") })
|
|
2994
|
-
] }),
|
|
2995
|
-
state.doc.notice !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: "0 0 8px", fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: state.doc.notice }) : null,
|
|
2996
|
-
status.lastSettleError !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: "0 0 8px", fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.diary.settleFailed").replace("{reason}", status.lastSettleError) }) : null,
|
|
2997
|
-
state.doc.diary.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: 0, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.diary.empty") }) : state.doc.diary.map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DiaryRow, { t, item, onOpen: (date) => controller.open(date) }, item.date))
|
|
2998
|
-
] }),
|
|
2999
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { style: { ...panel, marginTop: 16 }, children: [
|
|
3000
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
3001
|
-
t("workbench.evolution.grow.title"),
|
|
3002
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InfoHint, { label: t("workbench.evolution.grow.hint") })
|
|
3003
|
-
] }),
|
|
3004
|
-
state.doc.grow.lastRun.at !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { style: { margin: "0 0 8px", fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: [
|
|
3005
|
-
t("workbench.evolution.grow.lastRun").replace("{time}", stamp(state.doc.grow.lastRun.at)),
|
|
3006
|
-
state.doc.grow.lastRun.wrote.length > 0 ? ` · ${t("workbench.evolution.grow.wrote").replace("{list}", state.doc.grow.lastRun.wrote.join("、"))}` : "",
|
|
3007
|
-
state.doc.grow.lastRun.note !== "" ? ` · ${state.doc.grow.lastRun.note}` : ""
|
|
3008
|
-
] }) : null,
|
|
3009
|
-
state.doc.grow.candidates.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: 0, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.grow.empty") }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { style: { margin: 0, paddingLeft: 18, lineHeight: 1.8 }, children: state.doc.grow.candidates.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { children: [
|
|
3010
|
-
item.text,
|
|
3011
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { marginLeft: 8, fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: [
|
|
3012
|
-
item.about === "user" ? t("workbench.evolution.grow.aboutUser") : t("workbench.evolution.grow.aboutSelf"),
|
|
3013
|
-
" · ",
|
|
3014
|
-
t("workbench.evolution.grow.count").replace("{count}", String(item.count)),
|
|
3015
|
-
" · ",
|
|
3016
|
-
t("workbench.evolution.grow.days").replace("{days}", String(item.days))
|
|
3017
|
-
] }),
|
|
3018
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3019
|
-
"button",
|
|
3020
|
-
{
|
|
3021
|
-
type: "button",
|
|
3022
|
-
style: { marginLeft: 8, fontSize: 12 },
|
|
3023
|
-
onClick: () => void controller.dropCandidate(item.text),
|
|
3024
|
-
children: t("workbench.evolution.grow.drop")
|
|
3025
|
-
}
|
|
3026
|
-
)
|
|
3027
|
-
] }, `${item.text}-${String(index)}`)) })
|
|
3028
|
-
] }),
|
|
3029
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { style: { ...panel, marginTop: 16 }, children: [
|
|
3030
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
3031
|
-
t("workbench.evolution.threads.title"),
|
|
3032
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InfoHint, { label: t("workbench.evolution.threads.hint") })
|
|
3033
|
-
] }),
|
|
3034
|
-
state.doc.threads.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: 0, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.threads.empty") }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { style: { margin: 0, paddingLeft: 18, lineHeight: 1.8 }, children: state.doc.threads.map((line) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: line }, line)) })
|
|
3035
|
-
] }),
|
|
3036
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { style: { ...panel, marginTop: 16 }, children: [
|
|
3037
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
3038
|
-
t("workbench.evolution.works.title"),
|
|
3039
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InfoHint, { label: t("workbench.evolution.works.hint") })
|
|
3040
|
-
] }),
|
|
3041
|
-
state.doc.works.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: 0, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.works.empty") }) : state.doc.works.map((item) => (
|
|
3042
|
-
/**
|
|
3043
|
-
* ⚠️ 下载按钮**必须常显**,不能藏在折叠区里。
|
|
3044
|
-
* 真机(2026-11-24):它原来在 `<details>` 展开后才出现,用户「点哪里啊,我没看到」——
|
|
3045
|
-
* 一个功能看不见,等于没有。
|
|
3046
|
-
*/
|
|
3047
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { padding: "8px 0", borderBottom: "1px solid var(--dsw-alias-border-l2)" }, children: [
|
|
3048
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 12 }, children: [
|
|
3049
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: item.name }),
|
|
3050
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
|
|
3051
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { color: "var(--dsw-alias-label-secondary)", fontSize: 12 }, children: [
|
|
3052
|
-
Math.max(1, Math.round(item.size / 1024)),
|
|
3053
|
-
" KB · ",
|
|
3054
|
-
stamp(item.updatedAt)
|
|
3055
|
-
] }),
|
|
3056
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: () => void controller.download(item.name), children: t("workbench.evolution.works.download") })
|
|
3057
|
-
] })
|
|
3058
|
-
] }),
|
|
3059
|
-
item.kind === "text" && item.preview !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { style: { marginTop: 6 }, children: [
|
|
3060
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("summary", { style: { cursor: "pointer", fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.works.previewToggle") }),
|
|
3061
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pre", { style: { margin: "6px 0 0", whiteSpace: "pre-wrap", fontSize: 13, lineHeight: 1.7 }, children: item.preview })
|
|
3062
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { margin: "6px 0 0", fontSize: 12, color: "var(--dsw-alias-label-secondary)" }, children: t("workbench.evolution.works.noPreview") })
|
|
3063
|
-
] }, item.name)
|
|
3064
|
-
))
|
|
3065
|
-
] })
|
|
3066
|
-
] });
|
|
3067
|
-
}
|
|
3068
|
-
|
|
3069
|
-
// src/client/MemoryPage.tsx
|
|
3070
|
-
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
3071
|
-
var import_react5 = require("react");
|
|
3072
|
-
|
|
3073
|
-
// src/client/use-visible-refresh.ts
|
|
3074
|
-
var import_react4 = require("react");
|
|
3075
|
-
function useVisibleRefresh(reload) {
|
|
3076
|
-
(0, import_react4.useEffect)(() => {
|
|
3077
|
-
if (typeof document === "undefined") return;
|
|
3078
|
-
const tick = () => {
|
|
3079
|
-
if (document.visibilityState !== "visible") return;
|
|
3080
|
-
reload();
|
|
3081
|
-
};
|
|
3082
|
-
const onFocus = () => tick();
|
|
3083
|
-
document.addEventListener("visibilitychange", tick);
|
|
3084
|
-
window.addEventListener("focus", onFocus);
|
|
3085
|
-
return () => {
|
|
3086
|
-
document.removeEventListener("visibilitychange", tick);
|
|
3087
|
-
window.removeEventListener("focus", onFocus);
|
|
3088
|
-
};
|
|
3089
|
-
}, [reload]);
|
|
3090
|
-
}
|
|
3091
|
-
|
|
3092
|
-
// src/client/MemoryPage.tsx
|
|
3093
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
3094
|
-
var DISCLOSURE_THRESHOLD = 0.5;
|
|
3095
|
-
var page2 = { display: "flex", flexDirection: "column", gap: 12 };
|
|
3096
|
-
var stats = {
|
|
3097
|
-
display: "flex",
|
|
3098
|
-
flexWrap: "wrap",
|
|
3099
|
-
gap: 16,
|
|
3100
|
-
fontSize: 13,
|
|
3101
|
-
color: "var(--dsw-alias-label-secondary)"
|
|
3102
|
-
};
|
|
3103
|
-
var row = {
|
|
3104
|
-
padding: "10px 0",
|
|
3105
|
-
borderTop: "1px solid var(--dsw-alias-border-l2)"
|
|
3106
|
-
};
|
|
3107
|
-
var meta2 = {
|
|
3108
|
-
display: "flex",
|
|
3109
|
-
flexWrap: "wrap",
|
|
3110
|
-
alignItems: "baseline",
|
|
3111
|
-
gap: 10,
|
|
3112
|
-
fontSize: 12,
|
|
3113
|
-
color: "var(--dsw-alias-label-secondary)"
|
|
3114
|
-
};
|
|
3115
|
-
var what = {
|
|
3116
|
-
margin: "6px 0 8px",
|
|
3117
|
-
fontSize: 13,
|
|
3118
|
-
lineHeight: 1.6,
|
|
3119
|
-
color: "var(--dsw-alias-label-primary)",
|
|
3120
|
-
overflowWrap: "anywhere"
|
|
3121
|
-
};
|
|
3122
|
-
var track = {
|
|
3123
|
-
position: "relative",
|
|
3124
|
-
height: 5,
|
|
3125
|
-
borderRadius: 3,
|
|
3126
|
-
background: "var(--dsw-alias-border-l2)"
|
|
3127
|
-
};
|
|
3128
|
-
var fill = {
|
|
3129
|
-
position: "absolute",
|
|
3130
|
-
top: 0,
|
|
3131
|
-
bottom: 0,
|
|
3132
|
-
left: 0,
|
|
3133
|
-
borderRadius: 3,
|
|
3134
|
-
background: "var(--dsw-alias-brand-primary)"
|
|
3135
|
-
};
|
|
3136
|
-
var secretMask = { color: "var(--dsw-alias-label-secondary)", fontStyle: "italic" };
|
|
3137
|
-
var secretWarn = { color: "var(--dsw-alias-state-warn-label)", fontSize: 12 };
|
|
3138
|
-
var deleteWarn = { color: "var(--dsw-alias-state-warn-label)", fontSize: 12 };
|
|
3139
|
-
var rowActions = { marginLeft: "auto", display: "flex", gap: 8, alignItems: "baseline" };
|
|
3140
|
-
var noticeLine = { fontSize: 12, color: "var(--dsw-alias-label-secondary)", margin: "4px 0" };
|
|
3141
|
-
var whyBox = {
|
|
3142
|
-
margin: "10px 0 6px",
|
|
3143
|
-
padding: "10px 12px",
|
|
3144
|
-
borderRadius: 8,
|
|
3145
|
-
background: "var(--dsw-alias-bg-layer-1)",
|
|
3146
|
-
border: "1px solid var(--dsw-alias-border-l2)"
|
|
3147
|
-
};
|
|
3148
|
-
var whyTitle = { fontSize: 12, color: "var(--dsw-alias-label-secondary)", margin: "0 0 6px" };
|
|
3149
|
-
var whyCue = {
|
|
3150
|
-
fontSize: 13,
|
|
3151
|
-
margin: "0 0 6px",
|
|
3152
|
-
color: "var(--dsw-alias-label-primary)",
|
|
3153
|
-
overflowWrap: "anywhere"
|
|
3154
|
-
};
|
|
3155
|
-
var whyList = {
|
|
3156
|
-
margin: 0,
|
|
3157
|
-
paddingLeft: 18,
|
|
3158
|
-
fontSize: 13,
|
|
3159
|
-
lineHeight: 1.6,
|
|
3160
|
-
color: "var(--dsw-alias-label-primary)"
|
|
3161
|
-
};
|
|
3162
|
-
var whyMatch = { marginLeft: 8, fontSize: 11, color: "var(--dsw-alias-label-secondary)" };
|
|
3163
|
-
var notice = {
|
|
3164
|
-
fontSize: 13,
|
|
3165
|
-
color: "var(--dsw-alias-label-secondary)",
|
|
3166
|
-
padding: "12px 0"
|
|
3167
|
-
};
|
|
3168
|
-
var aboutText = (about, t) => {
|
|
3169
|
-
switch (about) {
|
|
3170
|
-
case "self":
|
|
3171
|
-
return t("memory.about.self");
|
|
3172
|
-
case "user":
|
|
3173
|
-
return t("memory.about.user");
|
|
3174
|
-
case "us":
|
|
3175
|
-
return t("memory.about.us");
|
|
3176
|
-
default:
|
|
3177
|
-
return t("memory.about.world");
|
|
3178
|
-
}
|
|
3179
|
-
};
|
|
3180
|
-
function dayOf(iso) {
|
|
3181
|
-
const at = Date.parse(iso);
|
|
3182
|
-
if (!Number.isFinite(at)) return "";
|
|
3183
|
-
const date = new Date(at);
|
|
3184
|
-
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
3185
|
-
}
|
|
3186
|
-
function EntryRow({
|
|
3187
|
-
entry,
|
|
3188
|
-
t,
|
|
3189
|
-
pending: pending2,
|
|
3190
|
-
onAsk,
|
|
3191
|
-
onConfirm,
|
|
3192
|
-
deleting,
|
|
3193
|
-
onDeleteAsk,
|
|
3194
|
-
onDeleteConfirm
|
|
3195
|
-
}) {
|
|
3196
|
-
const percent2 = `${Math.round(Math.min(1, Math.max(0, entry.strength)) * 100)}%`;
|
|
3197
|
-
const secret = entry.cost > DISCLOSURE_THRESHOLD;
|
|
3198
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: row, children: [
|
|
3199
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: meta2, children: [
|
|
3200
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: dayOf(entry.when) }),
|
|
3201
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: aboutText(entry.about, t) }),
|
|
3202
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: t(`memory.tier.${entry.tier}`) }),
|
|
3203
|
-
entry.feltLabel !== "" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: t("memory.felt").replace("{label}", entry.feltLabel) }) : null,
|
|
3204
|
-
entry.covers > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: t("memory.covers").replace("{count}", String(entry.covers)) }) : null,
|
|
3205
|
-
entry.recalled > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: t("memory.recalled").replace("{count}", String(entry.recalled)) }) : null,
|
|
3206
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: rowActions, children: deleting ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
3207
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: deleteWarn, children: t("memory.delete.warn") }),
|
|
3208
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Button, { size: "sm", variant: "outline", onClick: onDeleteConfirm, children: t("memory.delete.confirm") })
|
|
3209
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Button, { size: "sm", variant: "ghost", onClick: onDeleteAsk, children: t("memory.delete.ask") }) })
|
|
3210
|
-
] }),
|
|
3211
|
-
secret ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { style: what, children: [
|
|
3212
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { style: secretMask, children: [
|
|
3213
|
-
"🔒 ",
|
|
3214
|
-
t("memory.secret")
|
|
3215
|
-
] }),
|
|
3216
|
-
" ",
|
|
3217
|
-
pending2 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
3218
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: secretWarn, children: t("memory.reveal.warn") }),
|
|
3219
|
-
" ",
|
|
3220
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Button, { size: "sm", variant: "primary", onClick: onConfirm, children: t("memory.reveal.confirm") })
|
|
3221
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Button, { size: "sm", variant: "ghost", onClick: onAsk, children: t("memory.reveal.ask") })
|
|
3222
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: what, children: entry.what }),
|
|
3223
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: track, "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { ...fill, width: percent2 } }) })
|
|
3224
|
-
] });
|
|
3225
|
-
}
|
|
3226
|
-
function MemoryPage({ t, controller }) {
|
|
3227
|
-
const state = (0, import_react5.useSyncExternalStore)(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
3228
|
-
const [pendingId, setPendingId] = (0, import_react5.useState)("");
|
|
3229
|
-
const [deletingId, setDeletingId] = (0, import_react5.useState)("");
|
|
3230
|
-
(0, import_react5.useEffect)(() => {
|
|
3231
|
-
void controller.load();
|
|
3232
|
-
}, [controller]);
|
|
3233
|
-
const reload = (0, import_react5.useCallback)(() => {
|
|
3234
|
-
void controller.load({ quiet: true });
|
|
3235
|
-
}, [controller]);
|
|
3236
|
-
useVisibleRefresh(reload);
|
|
3237
|
-
const { doc } = state;
|
|
3238
|
-
const ready = state.status === "ready";
|
|
3239
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: page2, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { style: panel, children: [
|
|
3240
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
3241
|
-
t("memory.title"),
|
|
3242
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Button, { size: "sm", variant: "ghost", onClick: () => void controller.load(), children: t("memory.reload") })
|
|
3243
|
-
] }),
|
|
3244
|
-
state.status === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: notice, children: t("memory.loading") }) : null,
|
|
3245
|
-
state.status === "unavailable" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: notice, children: t("memory.unavailable") }) : null,
|
|
3246
|
-
state.status === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: notice, children: state.error ?? t("memory.failed") }) : null,
|
|
3247
|
-
ready && doc.notice !== "" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: noticeLine, children: doc.notice }) : null,
|
|
3248
|
-
ready ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
3249
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: stats, children: [
|
|
3250
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: t("memory.total").replace("{count}", String(doc.stats.total)) }),
|
|
3251
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
3252
|
-
t("memory.tier.episode"),
|
|
3253
|
-
" ",
|
|
3254
|
-
doc.stats.episode
|
|
3255
|
-
] }),
|
|
3256
|
-
doc.stats.period > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
3257
|
-
t("memory.tier.period"),
|
|
3258
|
-
" ",
|
|
3259
|
-
doc.stats.period
|
|
3260
|
-
] }) : null,
|
|
3261
|
-
doc.stats.chapter > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
3262
|
-
t("memory.tier.chapter"),
|
|
3263
|
-
" ",
|
|
3264
|
-
doc.stats.chapter
|
|
3265
|
-
] }) : null,
|
|
3266
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: t("memory.recalledTotal").replace("{count}", String(doc.stats.recalled)) })
|
|
3267
|
-
] }),
|
|
3268
|
-
doc.lastRecall.items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: whyBox, children: [
|
|
3269
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: whyTitle, children: t("memory.why.title") }),
|
|
3270
|
-
doc.lastRecall.cue !== "" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: whyCue, children: t("memory.why.cue").replace("{cue}", doc.lastRecall.cue) }) : null,
|
|
3271
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { style: whyList, children: doc.lastRecall.items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("li", { children: [
|
|
3272
|
-
item.withheld ? t("memory.why.withheld") : item.what,
|
|
3273
|
-
item.match !== "" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: whyMatch, children: t(`memory.why.match.${item.match}`) }) : null
|
|
3274
|
-
] }, `${index}-${item.what}`)) })
|
|
3275
|
-
] }) : null,
|
|
3276
|
-
doc.entries.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: notice, children: doc.dormant ? t("memory.dormant") : t("memory.empty") }) : doc.entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3277
|
-
EntryRow,
|
|
3278
|
-
{
|
|
3279
|
-
entry,
|
|
3280
|
-
t,
|
|
3281
|
-
pending: pendingId === entry.id,
|
|
3282
|
-
onAsk: () => setPendingId(entry.id),
|
|
3283
|
-
onConfirm: () => {
|
|
3284
|
-
setPendingId("");
|
|
3285
|
-
void controller.reveal(entry.id).then((ok) => {
|
|
3286
|
-
if (ok) void controller.load({ quiet: true });
|
|
3287
|
-
});
|
|
3288
|
-
},
|
|
3289
|
-
deleting: deletingId === entry.id,
|
|
3290
|
-
onDeleteAsk: () => setDeletingId(entry.id),
|
|
3291
|
-
onDeleteConfirm: () => {
|
|
3292
|
-
setDeletingId("");
|
|
3293
|
-
void controller.remove(entry.id).then((ok) => {
|
|
3294
|
-
if (ok) void controller.load({ quiet: true });
|
|
3295
|
-
});
|
|
3296
|
-
}
|
|
3297
|
-
},
|
|
3298
|
-
entry.id
|
|
3299
|
-
))
|
|
3300
|
-
] }) : null
|
|
3301
|
-
] }) });
|
|
3302
|
-
}
|
|
3303
|
-
|
|
3304
|
-
// src/client/WorkbenchOverview.tsx
|
|
3305
|
-
var import_react6 = require("react");
|
|
3306
|
-
|
|
3307
|
-
// src/client/metric-styles.ts
|
|
3308
|
-
var metricList = {
|
|
3309
|
-
margin: "0 0 12px"
|
|
3310
|
-
};
|
|
3311
|
-
var metricRow = {
|
|
3312
|
-
display: "flex",
|
|
3313
|
-
alignItems: "center",
|
|
3314
|
-
justifyContent: "space-between",
|
|
3315
|
-
gap: 12,
|
|
3316
|
-
padding: "8px 0",
|
|
3317
|
-
borderBottom: "1px solid var(--dsw-alias-border-l2)"
|
|
3318
|
-
};
|
|
3319
|
-
var metricValueStrong = {
|
|
3320
|
-
margin: 0,
|
|
3321
|
-
marginInlineStart: 0,
|
|
3322
|
-
fontSize: 17,
|
|
3323
|
-
fontWeight: 600,
|
|
3324
|
-
color: "var(--dsw-alias-label-primary)"
|
|
3325
|
-
};
|
|
3326
|
-
var metricLabelSmall = {
|
|
3327
|
-
margin: 0,
|
|
3328
|
-
fontSize: 13,
|
|
3329
|
-
color: "var(--dsw-alias-label-secondary)"
|
|
3330
|
-
};
|
|
3331
|
-
|
|
3332
|
-
// src/client/WorkbenchOverview.tsx
|
|
3333
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3334
|
-
var NOOP_SUBSCRIBE = () => () => {
|
|
3335
|
-
};
|
|
3336
|
-
var DETACHED_MEMORY_STATE = { status: "unavailable", doc: emptyMemoryDocument() };
|
|
3337
|
-
var DETACHED_MEMORY = { subscribe: NOOP_SUBSCRIBE, getSnapshot: () => DETACHED_MEMORY_STATE };
|
|
3338
|
-
var DETACHED_PERSONA_STATE = {
|
|
3339
|
-
status: "idle",
|
|
3340
|
-
writable: false,
|
|
3341
|
-
stored: emptyDocument(),
|
|
3342
|
-
draft: emptyDocument(),
|
|
3343
|
-
saving: false,
|
|
3344
|
-
savedAt: "",
|
|
3345
|
-
issues: [],
|
|
3346
|
-
independentJudgment: true,
|
|
3347
|
-
independentJudgmentSaving: false
|
|
3348
|
-
};
|
|
3349
|
-
var DETACHED_PERSONA = { subscribe: NOOP_SUBSCRIBE, getSnapshot: () => DETACHED_PERSONA_STATE };
|
|
3350
|
-
var OVERVIEW_METRICS = [
|
|
3351
|
-
{ key: "workbench.metric.name", hintKey: void 0 },
|
|
3352
|
-
{ key: "workbench.metric.memory", hintKey: "workbench.metric.memoryHint" }
|
|
3353
|
-
];
|
|
3354
|
-
function nameLabel(t, persona) {
|
|
3355
|
-
const fields = persona?.draft.identityCard.fields ?? [];
|
|
3356
|
-
const name2 = (fields.find((field) => field.key === "姓名")?.value ?? "").trim();
|
|
3357
|
-
return name2 === "" ? t("workbench.metric.nameEmpty") : name2;
|
|
3358
|
-
}
|
|
3359
|
-
function memoryLabel(t, memory) {
|
|
3360
|
-
if (memory.status !== "ready") return t("workbench.metric.unavailable");
|
|
3361
|
-
return t("workbench.metric.memoryValue", { count: String(memory.doc?.stats.total ?? 0) });
|
|
3362
|
-
}
|
|
3363
|
-
function OverviewPanel(props) {
|
|
3364
|
-
const { t } = props;
|
|
3365
|
-
const memoryController = props.memory ?? DETACHED_MEMORY;
|
|
3366
|
-
const personaController = props.persona ?? DETACHED_PERSONA;
|
|
3367
|
-
const memory = (0, import_react6.useSyncExternalStore)(
|
|
3368
|
-
memoryController.subscribe,
|
|
3369
|
-
memoryController.getSnapshot,
|
|
3370
|
-
memoryController.getSnapshot
|
|
3371
|
-
);
|
|
3372
|
-
const personaState = (0, import_react6.useSyncExternalStore)(
|
|
3373
|
-
personaController.subscribe,
|
|
3374
|
-
personaController.getSnapshot,
|
|
3375
|
-
personaController.getSnapshot
|
|
3376
|
-
);
|
|
3377
|
-
const values = {
|
|
3378
|
-
"workbench.metric.name": nameLabel(t, personaState),
|
|
3379
|
-
"workbench.metric.memory": memoryLabel(t, memory)
|
|
3380
|
-
};
|
|
3381
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { style: panel, children: [
|
|
3382
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
3383
|
-
t("workbench.overview"),
|
|
3384
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InfoHint, { label: t("workbench.overviewHint") })
|
|
3385
|
-
] }),
|
|
3386
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("dl", { style: metricList, children: OVERVIEW_METRICS.map((metric) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: metricRow, children: [
|
|
3387
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("dt", { style: { ...metricLabelSmall, ...headingWithHint }, children: [
|
|
3388
|
-
t(metric.key),
|
|
3389
|
-
metric.hintKey === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InfoHint, { label: t(metric.hintKey) })
|
|
3390
|
-
] }),
|
|
3391
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("dd", { style: metricValueStrong, children: values[metric.key] })
|
|
3392
|
-
] }, metric.key)) })
|
|
3393
|
-
] });
|
|
3394
|
-
}
|
|
3395
|
-
|
|
3396
|
-
// src/client/PersonaEditor.tsx
|
|
3397
|
-
var import_react8 = require("react");
|
|
3398
|
-
var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
3399
|
-
|
|
3400
|
-
// src/client/editor-styles.ts
|
|
3401
|
-
var ITEM_TRACKS = "minmax(96px, 160px) minmax(240px, 1fr) max-content";
|
|
3402
|
-
var itemList = {
|
|
3403
|
-
display: "grid",
|
|
3404
|
-
gridTemplateColumns: ITEM_TRACKS,
|
|
3405
|
-
alignItems: "center",
|
|
3406
|
-
columnGap: 12,
|
|
3407
|
-
rowGap: 8
|
|
3408
|
-
};
|
|
3409
|
-
var itemGrid = {
|
|
3410
|
-
display: "grid",
|
|
3411
|
-
gridTemplateColumns: ITEM_TRACKS,
|
|
3412
|
-
alignItems: "center",
|
|
3413
|
-
columnGap: 12
|
|
3414
|
-
};
|
|
3415
|
-
var itemActions = {
|
|
3416
|
-
display: "flex",
|
|
3417
|
-
flexDirection: "row",
|
|
3418
|
-
alignItems: "center",
|
|
3419
|
-
flexWrap: "nowrap",
|
|
3420
|
-
gap: 4
|
|
3421
|
-
};
|
|
3422
|
-
var renameIssueText = {
|
|
3423
|
-
fontSize: 12,
|
|
3424
|
-
color: "var(--dsw-alias-state-warn-label)",
|
|
3425
|
-
overflowWrap: "anywhere"
|
|
3426
|
-
};
|
|
3427
|
-
var editorCell = {
|
|
3428
|
-
display: "flex",
|
|
3429
|
-
flexDirection: "column",
|
|
3430
|
-
width: "100%",
|
|
3431
|
-
minWidth: 0
|
|
3432
|
-
};
|
|
3433
|
-
var deleteBand = {
|
|
3434
|
-
display: "flex",
|
|
3435
|
-
flexWrap: "wrap",
|
|
3436
|
-
alignItems: "center",
|
|
3437
|
-
gap: 8,
|
|
3438
|
-
marginTop: 6,
|
|
3439
|
-
padding: "8px 10px",
|
|
3440
|
-
border: "0.5px solid var(--dsw-alias-border-l4)",
|
|
3441
|
-
borderRadius: 8,
|
|
3442
|
-
background: "var(--dsw-alias-bg-layer-1)",
|
|
3443
|
-
fontSize: 13,
|
|
3444
|
-
color: "var(--dsw-alias-label-secondary)"
|
|
3445
|
-
};
|
|
3446
|
-
var addBand = {
|
|
3447
|
-
gridColumn: "1 / -1",
|
|
3448
|
-
marginTop: 4,
|
|
3449
|
-
paddingTop: 10,
|
|
3450
|
-
borderTop: "0.5px dashed var(--dsw-alias-border-l4)"
|
|
3451
|
-
};
|
|
3452
|
-
var fieldLabel = {
|
|
3453
|
-
fontSize: 13,
|
|
3454
|
-
color: "var(--dsw-alias-label-secondary)",
|
|
3455
|
-
overflowWrap: "anywhere"
|
|
3456
|
-
};
|
|
3457
|
-
var textarea = {
|
|
3458
|
-
boxSizing: "border-box",
|
|
3459
|
-
width: "100%",
|
|
3460
|
-
minHeight: 64,
|
|
3461
|
-
padding: "7px 10px",
|
|
3462
|
-
// 令牌与官方 `Input` 对齐(用户 2026-09-26:控件尽量走原生,别让表单里出现两种底色)——
|
|
3463
|
-
// 官方没有多行原语,所以这里是唯一一处自己画边框的输入控件,样式按原语抄。
|
|
3464
|
-
border: "0.5px solid var(--dsw-alias-border-l4)",
|
|
3465
|
-
borderRadius: 8,
|
|
3466
|
-
background: "var(--dsw-alias-bg-layer-1)",
|
|
3467
|
-
color: "var(--dsw-alias-label-primary)",
|
|
3468
|
-
font: "inherit",
|
|
3469
|
-
fontSize: 14,
|
|
3470
|
-
lineHeight: 1.5,
|
|
3471
|
-
resize: "vertical"
|
|
3472
|
-
};
|
|
3473
|
-
var footer = {
|
|
3474
|
-
display: "flex",
|
|
3475
|
-
alignItems: "center",
|
|
3476
|
-
justifyContent: "space-between",
|
|
3477
|
-
gap: 12,
|
|
3478
|
-
marginTop: 20,
|
|
3479
|
-
paddingTop: 12,
|
|
3480
|
-
borderTop: "1px solid var(--dsw-alias-border-l2)"
|
|
3481
|
-
};
|
|
3482
|
-
var actions = {
|
|
3483
|
-
display: "flex",
|
|
3484
|
-
alignItems: "center",
|
|
3485
|
-
gap: 8
|
|
3486
|
-
};
|
|
3487
|
-
var statusText = {
|
|
3488
|
-
margin: 0,
|
|
3489
|
-
fontSize: 13,
|
|
3490
|
-
color: "var(--dsw-alias-label-secondary)"
|
|
3491
|
-
};
|
|
3492
|
-
var issueList = {
|
|
3493
|
-
margin: "8px 0 0",
|
|
3494
|
-
paddingInlineStart: 20,
|
|
3495
|
-
fontSize: 13
|
|
3496
|
-
};
|
|
3497
|
-
var issueRejected = {
|
|
3498
|
-
color: "var(--dsw-alias-label-error, var(--dsw-alias-label-primary))"
|
|
3499
|
-
};
|
|
3500
|
-
var issueWarning = {
|
|
3501
|
-
color: "var(--dsw-alias-label-secondary)"
|
|
3502
|
-
};
|
|
3503
|
-
var issuePath = {
|
|
3504
|
-
fontFamily: "var(--dsw-font-family-mono, monospace)",
|
|
3505
|
-
fontSize: 12,
|
|
3506
|
-
color: "var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary))"
|
|
3507
|
-
};
|
|
3508
|
-
var divider = {
|
|
3509
|
-
margin: "14px 0",
|
|
3510
|
-
border: "none",
|
|
3511
|
-
borderTop: "1px solid var(--dsw-alias-border-l2)"
|
|
3512
|
-
};
|
|
3513
|
-
|
|
3514
|
-
// src/client/PersonaCards.tsx
|
|
3515
|
-
var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
3516
|
-
|
|
3517
|
-
// src/client/IndependentJudgmentRow.tsx
|
|
3518
|
-
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
3519
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3520
|
-
function IndependentJudgmentRow({ t, checked, disabled, saving, sealed, onChange }) {
|
|
3521
|
-
const state = saving ? t("persona.independentJudgmentSaving") : checked ? t("persona.independentJudgmentOn") : t("persona.independentJudgmentOff");
|
|
3522
|
-
const hint2 = sealed ? t("persona.independentJudgmentHint") : `${t("persona.independentJudgmentHint")} ${t("persona.independentJudgmentPendingSeal")}`;
|
|
3523
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: toggleCard, children: [
|
|
3524
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: toggleText, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { style: headingWithHint, children: [
|
|
3525
|
-
t("persona.independentJudgment"),
|
|
3526
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(InfoHint, { label: hint2 })
|
|
3527
|
-
] }) }),
|
|
3528
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: toggleState, children: [
|
|
3529
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: state }),
|
|
3530
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3531
|
-
import_dsh_client_ui_primitives3.Switch,
|
|
3532
|
-
{
|
|
3533
|
-
checked,
|
|
3534
|
-
disabled,
|
|
3535
|
-
label: t("persona.independentJudgment"),
|
|
3536
|
-
title: hint2,
|
|
3537
|
-
onChange
|
|
3538
|
-
}
|
|
3539
|
-
)
|
|
3540
|
-
] })
|
|
3541
|
-
] });
|
|
3542
|
-
}
|
|
3543
|
-
|
|
3544
|
-
// src/client/PersonaFields.tsx
|
|
3545
|
-
var import_react7 = require("react");
|
|
3546
|
-
var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
3547
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3548
|
-
function Marked({ marker: marker2, itemId, children }) {
|
|
3549
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "data-persona-action": marker2, "data-persona-item": itemId, children });
|
|
3550
|
-
}
|
|
3551
|
-
function renameIssueKey(issue) {
|
|
3552
|
-
if (issue === "empty") return "persona.rename.empty";
|
|
3553
|
-
if (issue === "unchanged") return "persona.rename.unchanged";
|
|
3554
|
-
if (issue === "reserved") return "persona.rename.reserved";
|
|
3555
|
-
return "persona.rename.duplicate";
|
|
3556
|
-
}
|
|
3557
|
-
function ContentCell({ name: name2, itemId, children }) {
|
|
3558
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "data-persona-content": itemId, "data-persona-editor": name2, style: editorCell, children });
|
|
3559
|
-
}
|
|
3560
|
-
function NameCell({
|
|
3561
|
-
t,
|
|
3562
|
-
controller,
|
|
3563
|
-
disabled,
|
|
3564
|
-
state,
|
|
3565
|
-
itemId,
|
|
3566
|
-
name: name2,
|
|
3567
|
-
locked,
|
|
3568
|
-
renameable
|
|
3569
|
-
}) {
|
|
3570
|
-
const form = state.renaming;
|
|
3571
|
-
const renaming = renameable && form !== void 0 && form.itemId === itemId;
|
|
3572
|
-
if (renaming && form !== void 0) {
|
|
3573
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3574
|
-
"span",
|
|
3575
|
-
{
|
|
3576
|
-
"data-persona-cell": "name",
|
|
3577
|
-
"data-persona-item": itemId,
|
|
3578
|
-
"data-persona-editor": "rename",
|
|
3579
|
-
"data-persona-rename": itemId,
|
|
3580
|
-
style: editorCell,
|
|
3581
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3582
|
-
import_dsh_client_ui_primitives4.Input,
|
|
3583
|
-
{
|
|
3584
|
-
value: form.name,
|
|
3585
|
-
placeholder: t("persona.fieldKey"),
|
|
3586
|
-
"aria-label": t("persona.rename"),
|
|
3587
|
-
disabled,
|
|
3588
|
-
onChange: (event) => controller.setRenameName(event.target.value)
|
|
3589
|
-
}
|
|
3590
|
-
)
|
|
3591
|
-
}
|
|
3592
|
-
);
|
|
3593
|
-
}
|
|
3594
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3595
|
-
"span",
|
|
3596
|
-
{
|
|
3597
|
-
"data-persona-cell": "name",
|
|
3598
|
-
"data-persona-item": itemId,
|
|
3599
|
-
...locked === void 0 ? {} : { "data-locked": locked ? "true" : "false" },
|
|
3600
|
-
style: fieldLabel,
|
|
3601
|
-
children: name2
|
|
3602
|
-
}
|
|
3603
|
-
);
|
|
3604
|
-
}
|
|
3605
|
-
function ActionsCell({
|
|
3606
|
-
t,
|
|
3607
|
-
controller,
|
|
3608
|
-
disabled,
|
|
3609
|
-
state,
|
|
3610
|
-
itemId,
|
|
3611
|
-
renameable,
|
|
3612
|
-
deletable
|
|
3613
|
-
}) {
|
|
3614
|
-
const form = state.renaming;
|
|
3615
|
-
const renaming = renameable && form !== void 0 && form.itemId === itemId;
|
|
3616
|
-
const issue = renaming ? renameIssue(state.draft, itemId, form.name) : void 0;
|
|
3617
|
-
if (renaming && form !== void 0) {
|
|
3618
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-persona-cell": "actions", "data-persona-actions": itemId, style: itemActions, children: [
|
|
3619
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Marked, { marker: "rename-confirm", itemId, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3620
|
-
import_dsh_client_ui_primitives4.Button,
|
|
3621
|
-
{
|
|
3622
|
-
size: "sm",
|
|
3623
|
-
variant: "primary",
|
|
3624
|
-
disabled: disabled || issue !== void 0,
|
|
3625
|
-
onClick: () => controller.confirmRename(),
|
|
3626
|
-
children: t("persona.renameConfirm")
|
|
3627
|
-
}
|
|
3628
|
-
) }),
|
|
3629
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Marked, { marker: "rename-cancel", itemId, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button, { size: "sm", variant: "ghost", disabled, onClick: () => controller.cancelRename(), children: t("persona.cancel") }) })
|
|
3630
|
-
] });
|
|
3631
|
-
}
|
|
3632
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-persona-cell": "actions", "data-persona-actions": itemId, style: itemActions, children: [
|
|
3633
|
-
renameable ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Marked, { marker: "rename", itemId, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button, { variant: "ghost", size: "sm", disabled, onClick: () => controller.beginRename(itemId), children: t("persona.rename") }) }) : null,
|
|
3634
|
-
deletable ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Marked, { marker: "delete", itemId, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button, { variant: "ghost", size: "sm", disabled, onClick: () => controller.requestDelete(itemId), children: t("persona.remove") }) }) : null
|
|
3635
|
-
] });
|
|
3636
|
-
}
|
|
3637
|
-
function DeleteConfirm({
|
|
3638
|
-
t,
|
|
3639
|
-
controller,
|
|
3640
|
-
disabled,
|
|
3641
|
-
itemId,
|
|
3642
|
-
name: name2
|
|
3643
|
-
}) {
|
|
3644
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3645
|
-
"div",
|
|
3646
|
-
{
|
|
3647
|
-
style: { ...deleteBand, gridColumn: "1 / -1" },
|
|
3648
|
-
"data-persona-action": "delete-confirm-band",
|
|
3649
|
-
"data-persona-item": itemId,
|
|
3650
|
-
children: [
|
|
3651
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: t("persona.deleteConfirm", { name: name2 }) }),
|
|
3652
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Marked, { marker: "delete-confirm", itemId, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button, { size: "sm", variant: "primary", disabled, onClick: () => controller.confirmDelete(), children: t("persona.deleteConfirmYes") }) }),
|
|
3653
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Marked, { marker: "delete-cancel", itemId, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button, { size: "sm", variant: "ghost", disabled, onClick: () => controller.cancelDelete(), children: t("persona.cancel") }) })
|
|
3654
|
-
]
|
|
3655
|
-
}
|
|
3656
|
-
);
|
|
3657
|
-
}
|
|
3658
|
-
function RenameIssueBand({ t, itemId, issue }) {
|
|
3659
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3660
|
-
"span",
|
|
3661
|
-
{
|
|
3662
|
-
style: { ...renameIssueText, gridColumn: "1 / -1" },
|
|
3663
|
-
"data-persona-rename-issue": issue,
|
|
3664
|
-
"data-persona-item": itemId,
|
|
3665
|
-
children: t(renameIssueKey(issue))
|
|
3666
|
-
}
|
|
3667
|
-
);
|
|
3668
|
-
}
|
|
3669
|
-
function RenameIssueBandIfAny({
|
|
3670
|
-
t,
|
|
3671
|
-
state,
|
|
3672
|
-
itemId
|
|
3673
|
-
}) {
|
|
3674
|
-
const form = state.renaming;
|
|
3675
|
-
if (form === void 0 || form.itemId !== itemId) return null;
|
|
3676
|
-
const issue = renameIssue(state.draft, itemId, form.name);
|
|
3677
|
-
if (issue === void 0) return null;
|
|
3678
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RenameIssueBand, { t, itemId, issue });
|
|
3679
|
-
}
|
|
3680
|
-
function IdentityFieldCells({
|
|
3681
|
-
t,
|
|
3682
|
-
controller,
|
|
3683
|
-
disabled,
|
|
3684
|
-
state,
|
|
3685
|
-
index
|
|
3686
|
-
}) {
|
|
3687
|
-
const field = state.draft.identityCard.fields[index];
|
|
3688
|
-
if (field === void 0) return null;
|
|
3689
|
-
const itemId = identityItemId(index);
|
|
3690
|
-
const pending2 = state.pendingDelete === itemId;
|
|
3691
|
-
const deletable = canDeleteItem(state.draft, itemId);
|
|
3692
|
-
const renameable = canRenameItem(state.draft, itemId);
|
|
3693
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react7.Fragment, { children: [
|
|
3694
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3695
|
-
NameCell,
|
|
3696
|
-
{
|
|
3697
|
-
t,
|
|
3698
|
-
controller,
|
|
3699
|
-
disabled,
|
|
3700
|
-
state,
|
|
3701
|
-
itemId,
|
|
3702
|
-
name: field.key,
|
|
3703
|
-
renameable
|
|
3704
|
-
}
|
|
3705
|
-
),
|
|
3706
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContentCell, { name: "value", itemId, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3707
|
-
import_dsh_client_ui_primitives4.Input,
|
|
3708
|
-
{
|
|
3709
|
-
value: field.value,
|
|
3710
|
-
placeholder: t("persona.fieldValue"),
|
|
3711
|
-
"aria-label": field.key === "" ? t("persona.fieldValue") : field.key,
|
|
3712
|
-
disabled,
|
|
3713
|
-
onChange: (event) => controller.setIdentityValue(index, event.target.value)
|
|
3714
|
-
}
|
|
3715
|
-
) }),
|
|
3716
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3717
|
-
ActionsCell,
|
|
3718
|
-
{
|
|
3719
|
-
t,
|
|
3720
|
-
controller,
|
|
3721
|
-
disabled,
|
|
3722
|
-
state,
|
|
3723
|
-
itemId,
|
|
3724
|
-
renameable,
|
|
3725
|
-
deletable
|
|
3726
|
-
}
|
|
3727
|
-
),
|
|
3728
|
-
pending2 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3729
|
-
DeleteConfirm,
|
|
3730
|
-
{
|
|
3731
|
-
t,
|
|
3732
|
-
controller,
|
|
3733
|
-
disabled,
|
|
3734
|
-
itemId,
|
|
3735
|
-
name: field.key === "" ? t("persona.fieldValue") : field.key
|
|
3736
|
-
}
|
|
3737
|
-
) : null,
|
|
3738
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RenameIssueBandIfAny, { t, state, itemId })
|
|
3739
|
-
] });
|
|
3740
|
-
}
|
|
3741
|
-
function IdentityFields({ t, controller, disabled, state }) {
|
|
3742
|
-
const shared = { t, controller, disabled, state };
|
|
3743
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: itemList, "data-persona-list": "identity", children: [
|
|
3744
|
-
state.draft.identityCard.fields.map((field, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IdentityFieldCells, { ...shared, index }, `field-${index}`)),
|
|
3745
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3746
|
-
AddEntry,
|
|
3747
|
-
{
|
|
3748
|
-
...shared,
|
|
3749
|
-
kind: "identity",
|
|
3750
|
-
openLabel: t("persona.addField"),
|
|
3751
|
-
nameLabel: t("persona.fieldKey"),
|
|
3752
|
-
valueLabel: t("persona.fieldValue")
|
|
3753
|
-
}
|
|
3754
|
-
)
|
|
3755
|
-
] });
|
|
3756
|
-
}
|
|
3757
|
-
function MutableSectionCells({
|
|
3758
|
-
t,
|
|
3759
|
-
controller,
|
|
3760
|
-
disabled,
|
|
3761
|
-
state,
|
|
3762
|
-
section
|
|
3763
|
-
}) {
|
|
3764
|
-
const itemId = sectionItemId(section.title);
|
|
3765
|
-
const pending2 = state.pendingDelete === itemId;
|
|
3766
|
-
const deletable = canDeleteItem(state.draft, itemId);
|
|
3767
|
-
const renameable = canRenameItem(state.draft, itemId);
|
|
3768
|
-
const text = section.items.join("\n");
|
|
3769
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react7.Fragment, { children: [
|
|
3770
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3771
|
-
NameCell,
|
|
3772
|
-
{
|
|
3773
|
-
t,
|
|
3774
|
-
controller,
|
|
3775
|
-
disabled,
|
|
3776
|
-
state,
|
|
3777
|
-
itemId,
|
|
3778
|
-
name: section.title,
|
|
3779
|
-
locked: !deletable,
|
|
3780
|
-
renameable
|
|
3781
|
-
}
|
|
3782
|
-
),
|
|
3783
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContentCell, { name: "section", itemId, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3784
|
-
"textarea",
|
|
3785
|
-
{
|
|
3786
|
-
style: textarea,
|
|
3787
|
-
value: text,
|
|
3788
|
-
placeholder: t("persona.emptyValue"),
|
|
3789
|
-
disabled,
|
|
3790
|
-
"aria-label": section.title,
|
|
3791
|
-
onChange: (event) => controller.setSectionText(section.title, event.target.value)
|
|
3792
|
-
}
|
|
3793
|
-
) }),
|
|
3794
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3795
|
-
ActionsCell,
|
|
3796
|
-
{
|
|
3797
|
-
t,
|
|
3798
|
-
controller,
|
|
3799
|
-
disabled,
|
|
3800
|
-
state,
|
|
3801
|
-
itemId,
|
|
3802
|
-
renameable,
|
|
3803
|
-
deletable
|
|
3804
|
-
}
|
|
3805
|
-
),
|
|
3806
|
-
pending2 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DeleteConfirm, { t, controller, disabled, itemId, name: section.title }) : null,
|
|
3807
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RenameIssueBandIfAny, { t, state, itemId })
|
|
3808
|
-
] });
|
|
3809
|
-
}
|
|
3810
|
-
function MutableFields({ t, controller, disabled, state }) {
|
|
3811
|
-
const shared = { t, controller, disabled, state };
|
|
3812
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: itemList, "data-persona-list": "section", children: [
|
|
3813
|
-
orderedSections(state.draft).map((section) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MutableSectionCells, { ...shared, section }, section.title)),
|
|
3814
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3815
|
-
AddEntry,
|
|
3816
|
-
{
|
|
3817
|
-
...shared,
|
|
3818
|
-
kind: "section",
|
|
3819
|
-
openLabel: t("persona.addSection"),
|
|
3820
|
-
nameLabel: t("persona.sectionName"),
|
|
3821
|
-
valueLabel: t("persona.sectionContent"),
|
|
3822
|
-
multiline: true
|
|
3823
|
-
}
|
|
3824
|
-
)
|
|
3825
|
-
] });
|
|
3826
|
-
}
|
|
3827
|
-
function AddEntry({
|
|
3828
|
-
t,
|
|
3829
|
-
controller,
|
|
3830
|
-
disabled,
|
|
3831
|
-
state,
|
|
3832
|
-
kind,
|
|
3833
|
-
openLabel,
|
|
3834
|
-
nameLabel: nameLabel2,
|
|
3835
|
-
valueLabel,
|
|
3836
|
-
multiline = false
|
|
3837
|
-
}) {
|
|
3838
|
-
const form = state.addForm;
|
|
3839
|
-
if (form === void 0 || form.kind !== kind) {
|
|
3840
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { gridColumn: "1 / -1" }, "data-persona-add-open": kind, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Marked, { marker: "add-open", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button, { variant: "outline", size: "sm", disabled, onClick: () => controller.openAdd(kind), children: openLabel }) }) });
|
|
3841
|
-
}
|
|
3842
|
-
const ready = addFormReady(form);
|
|
3843
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: addBand, "data-persona-add": kind, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: itemGrid, children: [
|
|
3844
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "data-persona-editor": "add-name", style: editorCell, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3845
|
-
import_dsh_client_ui_primitives4.Input,
|
|
3846
|
-
{
|
|
3847
|
-
value: form.name,
|
|
3848
|
-
placeholder: nameLabel2,
|
|
3849
|
-
"aria-label": nameLabel2,
|
|
3850
|
-
disabled,
|
|
3851
|
-
onChange: (event) => controller.setAddField("name", event.target.value)
|
|
3852
|
-
}
|
|
3853
|
-
) }),
|
|
3854
|
-
multiline ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3855
|
-
"textarea",
|
|
3856
|
-
{
|
|
3857
|
-
"data-persona-editor": "add-value",
|
|
3858
|
-
style: textarea,
|
|
3859
|
-
value: form.value,
|
|
3860
|
-
placeholder: valueLabel,
|
|
3861
|
-
"aria-label": valueLabel,
|
|
3862
|
-
disabled,
|
|
3863
|
-
onChange: (event) => controller.setAddField("value", event.target.value)
|
|
3864
|
-
}
|
|
3865
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "data-persona-editor": "add-value", style: editorCell, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3866
|
-
import_dsh_client_ui_primitives4.Input,
|
|
3867
|
-
{
|
|
3868
|
-
value: form.value,
|
|
3869
|
-
placeholder: valueLabel,
|
|
3870
|
-
"aria-label": valueLabel,
|
|
3871
|
-
disabled,
|
|
3872
|
-
onChange: (event) => controller.setAddField("value", event.target.value)
|
|
3873
|
-
}
|
|
3874
|
-
) }),
|
|
3875
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: itemActions, children: [
|
|
3876
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Marked, { marker: "add-save", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3877
|
-
import_dsh_client_ui_primitives4.Button,
|
|
3878
|
-
{
|
|
3879
|
-
size: "sm",
|
|
3880
|
-
variant: "primary",
|
|
3881
|
-
disabled: disabled || !ready,
|
|
3882
|
-
onClick: () => void controller.commitAdd(),
|
|
3883
|
-
children: t("persona.save")
|
|
3884
|
-
}
|
|
3885
|
-
) }),
|
|
3886
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Marked, { marker: "add-cancel", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button, { size: "sm", variant: "ghost", disabled, onClick: () => controller.cancelAdd(), children: t("persona.cancel") }) })
|
|
3887
|
-
] })
|
|
3888
|
-
] }) });
|
|
3889
|
-
}
|
|
3890
|
-
|
|
3891
|
-
// src/client/PersonaCards.tsx
|
|
3892
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3893
|
-
function CardSaveButton({ t, controller, state }) {
|
|
3894
|
-
const busy = state.saving;
|
|
3895
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3896
|
-
import_dsh_client_ui_primitives5.Button,
|
|
3897
|
-
{
|
|
3898
|
-
size: "sm",
|
|
3899
|
-
variant: "primary",
|
|
3900
|
-
disabled: busy || !state.writable || !isDirty(state),
|
|
3901
|
-
onClick: () => void controller.save(),
|
|
3902
|
-
children: busy ? t("persona.saving") : t("persona.save")
|
|
3903
|
-
}
|
|
3904
|
-
);
|
|
3905
|
-
}
|
|
3906
|
-
function IdentityCardEditor({ t, controller, state }) {
|
|
3907
|
-
const sealed = state.stored.identityCard.sealedAt !== "";
|
|
3908
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { style: panel, children: [
|
|
3909
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
3910
|
-
t("persona.identityCard"),
|
|
3911
|
-
" ",
|
|
3912
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives5.Tag, { tone: sealed ? "neutral" : "outline", children: sealed ? t("persona.sealed") : t("persona.unsealed") }),
|
|
3913
|
-
sealed ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3914
|
-
import_dsh_client_ui_primitives5.Button,
|
|
3915
|
-
{
|
|
3916
|
-
size: "sm",
|
|
3917
|
-
variant: "outline",
|
|
3918
|
-
disabled: state.saving || !state.writable,
|
|
3919
|
-
onClick: () => void controller.seal(),
|
|
3920
|
-
children: t("persona.sealAction")
|
|
3921
|
-
}
|
|
3922
|
-
),
|
|
3923
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CardSaveButton, { t, controller, state }),
|
|
3924
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InfoHint, { label: t("persona.identityHint") })
|
|
3925
|
-
] }),
|
|
3926
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3927
|
-
IndependentJudgmentRow,
|
|
3928
|
-
{
|
|
3929
|
-
t,
|
|
3930
|
-
checked: sealed && state.independentJudgment,
|
|
3931
|
-
disabled: state.independentJudgmentSaving || !state.writable || !sealed,
|
|
3932
|
-
saving: state.independentJudgmentSaving,
|
|
3933
|
-
sealed,
|
|
3934
|
-
onChange: (next) => void controller.setIndependentJudgment(next)
|
|
3935
|
-
}
|
|
3936
|
-
),
|
|
3937
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("hr", { style: divider }),
|
|
3938
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3939
|
-
IdentityFields,
|
|
3940
|
-
{
|
|
3941
|
-
t,
|
|
3942
|
-
controller,
|
|
3943
|
-
disabled: state.saving || !state.writable,
|
|
3944
|
-
state
|
|
3945
|
-
}
|
|
3946
|
-
)
|
|
3947
|
-
] });
|
|
3948
|
-
}
|
|
3949
|
-
function MutableCardEditor({ t, controller, state }) {
|
|
3950
|
-
const shared = { t, controller, disabled: state.saving || !state.writable };
|
|
3951
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { style: panel, children: [
|
|
3952
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
3953
|
-
t("persona.mutableCard"),
|
|
3954
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InfoHint, { label: t("persona.mutableHint") }),
|
|
3955
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CardSaveButton, { t, controller, state })
|
|
3956
|
-
] }),
|
|
3957
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MutableFields, { ...shared, state })
|
|
3958
|
-
] });
|
|
3959
|
-
}
|
|
3960
|
-
|
|
3961
|
-
// src/client/CharacterCard.tsx
|
|
3962
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3963
|
-
var axisBlock = {
|
|
3964
|
-
padding: "10px 0",
|
|
3965
|
-
borderTop: "1px solid var(--dsw-alias-border-l2)"
|
|
3966
|
-
};
|
|
3967
|
-
var axisHead = {
|
|
3968
|
-
display: "flex",
|
|
3969
|
-
alignItems: "baseline",
|
|
3970
|
-
justifyContent: "space-between",
|
|
3971
|
-
gap: 12,
|
|
3972
|
-
fontSize: 13
|
|
3973
|
-
};
|
|
3974
|
-
var axisName = { color: "var(--dsw-alias-label-primary)" };
|
|
3975
|
-
var axisRange = { color: "var(--dsw-alias-label-secondary)", fontSize: 12 };
|
|
3976
|
-
var track2 = {
|
|
3977
|
-
position: "relative",
|
|
3978
|
-
height: 6,
|
|
3979
|
-
margin: "10px 0 10px",
|
|
3980
|
-
borderRadius: 3,
|
|
3981
|
-
background: "var(--dsw-alias-border-l2)"
|
|
3982
|
-
};
|
|
3983
|
-
var span = {
|
|
3984
|
-
position: "absolute",
|
|
3985
|
-
top: 0,
|
|
3986
|
-
bottom: 0,
|
|
3987
|
-
borderRadius: 3,
|
|
3988
|
-
background: "var(--dsw-alias-brand-primary)",
|
|
3989
|
-
opacity: 0.4
|
|
3990
|
-
};
|
|
3991
|
-
var marker = {
|
|
3992
|
-
position: "absolute",
|
|
3993
|
-
top: -4,
|
|
3994
|
-
width: 2,
|
|
3995
|
-
height: 14,
|
|
3996
|
-
borderRadius: 1,
|
|
3997
|
-
background: "var(--dsw-alias-label-primary)",
|
|
3998
|
-
transform: "translateX(-1px)"
|
|
3999
|
-
};
|
|
4000
|
-
var reasonBox = { ...textarea, minHeight: 44 };
|
|
4001
|
-
var pending = { fontSize: 13, color: "var(--dsw-alias-label-secondary)", margin: "6px 0 0" };
|
|
4002
|
-
var percent = (value) => `${Math.round(Math.min(1, Math.max(0, value)) * 100)}%`;
|
|
4003
|
-
var rangeText = (axis) => `${axis.min.toFixed(2)} – ${axis.max.toFixed(2)}`;
|
|
4004
|
-
function AxisTrack({ axis }) {
|
|
4005
|
-
const low = Math.min(axis.min, axis.max);
|
|
4006
|
-
const high = Math.max(axis.min, axis.max);
|
|
4007
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: track2, "aria-hidden": true, children: [
|
|
4008
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { ...span, left: percent(low), width: percent(high - low) } }),
|
|
4009
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { ...marker, left: percent(axis.value) } })
|
|
4010
|
-
] });
|
|
4011
|
-
}
|
|
4012
|
-
function CharacterCardEditor({ t, controller, state }) {
|
|
4013
|
-
const readOnly = state.saving || !state.writable;
|
|
4014
|
-
const character = state.draft.character;
|
|
4015
|
-
const ready = character.derivedAt !== "" && character.axes.length > 0;
|
|
4016
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { style: panel, children: [
|
|
4017
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("h2", { style: { ...panelTitle, ...headingWithHint }, children: [
|
|
4018
|
-
t("persona.characterCard"),
|
|
4019
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InfoHint, { label: t("persona.characterHint") }),
|
|
4020
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CardSaveButton, { t, controller, state })
|
|
4021
|
-
] }),
|
|
4022
|
-
ready ? CHARACTER_AXES.map((key) => {
|
|
4023
|
-
const axis = character.axes.find((item) => item.key === key);
|
|
4024
|
-
const label = CHARACTER_AXIS_TEXT[key].name;
|
|
4025
|
-
if (axis === void 0) {
|
|
4026
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: axisBlock, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: axisHead, children: [
|
|
4027
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: axisName, children: label }),
|
|
4028
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: axisRange, children: t("persona.characterAxisMissing") })
|
|
4029
|
-
] }) }, key);
|
|
4030
|
-
}
|
|
4031
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: axisBlock, children: [
|
|
4032
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: axisHead, children: [
|
|
4033
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: axisName, children: label }),
|
|
4034
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { style: axisRange, children: [
|
|
4035
|
-
t("persona.characterRange"),
|
|
4036
|
-
" ",
|
|
4037
|
-
rangeText(axis)
|
|
4038
|
-
] })
|
|
4039
|
-
] }),
|
|
4040
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AxisTrack, { axis }),
|
|
4041
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4042
|
-
"textarea",
|
|
4043
|
-
{
|
|
4044
|
-
style: reasonBox,
|
|
4045
|
-
value: axis.reason,
|
|
4046
|
-
rows: 2,
|
|
4047
|
-
"aria-label": `${label} ${t("persona.characterReason")}`,
|
|
4048
|
-
placeholder: t("persona.characterReasonPlaceholder"),
|
|
4049
|
-
readOnly,
|
|
4050
|
-
onChange: (event) => controller.setCharacterReason(key, event.target.value)
|
|
4051
|
-
}
|
|
4052
|
-
)
|
|
4053
|
-
] }, key);
|
|
4054
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { style: pending, children: t("persona.characterPending") })
|
|
4055
|
-
] });
|
|
4056
|
-
}
|
|
4057
|
-
|
|
4058
|
-
// src/client/PersonaIssues.tsx
|
|
4059
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
4060
|
-
function issueText(t, issue) {
|
|
4061
|
-
const key = `persona.issue.${issue.code}`;
|
|
4062
|
-
if (!(key in zh)) return issue.message;
|
|
4063
|
-
return t(key);
|
|
4064
|
-
}
|
|
4065
|
-
function IssueGroup({
|
|
4066
|
-
t,
|
|
4067
|
-
label,
|
|
4068
|
-
issues,
|
|
4069
|
-
tone,
|
|
4070
|
-
alert
|
|
4071
|
-
}) {
|
|
4072
|
-
if (issues.length === 0) return null;
|
|
4073
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
4074
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { style: { ...statusText, marginTop: 16 }, ...alert === true ? { role: "alert" } : {}, children: label }),
|
|
4075
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ul", { style: issueList, children: issues.map((issue, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("li", { style: tone, children: [
|
|
4076
|
-
issueText(t, issue),
|
|
4077
|
-
" ",
|
|
4078
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { style: issuePath, children: issue.path })
|
|
4079
|
-
] }, `issue-${index}`)) })
|
|
4080
|
-
] });
|
|
4081
|
-
}
|
|
4082
|
-
function StatusNotice({ t, state }) {
|
|
4083
|
-
if (state.status === "loading" || state.status === "idle") return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { style: hint, children: t("persona.loading") });
|
|
4084
|
-
if (state.status === "unavailable") return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { style: hint, children: t("persona.unavailable") });
|
|
4085
|
-
if (state.status === "failed") {
|
|
4086
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { style: hint, role: "alert", children: t("persona.failed", { message: state.error ?? "" }) });
|
|
4087
|
-
}
|
|
4088
|
-
return null;
|
|
4089
|
-
}
|
|
4090
|
-
|
|
4091
|
-
// src/client/PersonaEditor.tsx
|
|
4092
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
4093
|
-
function IssueNotices({
|
|
4094
|
-
t,
|
|
4095
|
-
issues,
|
|
4096
|
-
error
|
|
4097
|
-
}) {
|
|
4098
|
-
const rejected = issues.filter((issue) => issue.severity === "rejected");
|
|
4099
|
-
const warnings = issues.filter((issue) => issue.severity === "warning");
|
|
4100
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
4101
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4102
|
-
IssueGroup,
|
|
4103
|
-
{
|
|
4104
|
-
t,
|
|
4105
|
-
label: t("persona.blocked", { count: String(rejected.length) }),
|
|
4106
|
-
issues: rejected,
|
|
4107
|
-
tone: issueRejected,
|
|
4108
|
-
alert: true
|
|
4109
|
-
}
|
|
4110
|
-
),
|
|
4111
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4112
|
-
IssueGroup,
|
|
4113
|
-
{
|
|
4114
|
-
t,
|
|
4115
|
-
label: t("persona.warnings", { count: String(warnings.length) }),
|
|
4116
|
-
issues: warnings,
|
|
4117
|
-
tone: issueWarning
|
|
4118
|
-
}
|
|
4119
|
-
),
|
|
4120
|
-
error !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { style: { ...statusText, marginTop: 12 }, role: "alert", children: t("persona.rejected", { message: error }) }) : null
|
|
4121
|
-
] });
|
|
4122
|
-
}
|
|
4123
|
-
function EditorFooter({
|
|
4124
|
-
t,
|
|
4125
|
-
controller,
|
|
4126
|
-
busy,
|
|
4127
|
-
writable,
|
|
4128
|
-
dirty,
|
|
4129
|
-
savedAt
|
|
4130
|
-
}) {
|
|
4131
|
-
const status = !writable ? t("persona.readonly") : dirty ? t("persona.dirty") : savedAt === "" ? "" : t("persona.saved");
|
|
4132
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: footer, children: [
|
|
4133
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { style: statusText, children: status }),
|
|
4134
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: actions, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives6.Button, { variant: "ghost", size: "sm", disabled: busy, onClick: () => void controller.load(), children: t("persona.reload") }) })
|
|
4135
|
-
] });
|
|
4136
|
-
}
|
|
4137
|
-
function ReadyEditor({
|
|
4138
|
-
t,
|
|
4139
|
-
controller,
|
|
4140
|
-
state
|
|
4141
|
-
}) {
|
|
4142
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
4143
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(IdentityCardEditor, { t, controller, state }),
|
|
4144
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MutableCardEditor, { t, controller, state }),
|
|
4145
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CharacterCardEditor, { t, controller, state }),
|
|
4146
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(IssueNotices, { t, issues: state.issues, error: state.error }),
|
|
4147
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4148
|
-
EditorFooter,
|
|
4149
|
-
{
|
|
4150
|
-
t,
|
|
4151
|
-
controller,
|
|
4152
|
-
busy: state.saving,
|
|
4153
|
-
writable: state.writable,
|
|
4154
|
-
dirty: isDirty(state),
|
|
4155
|
-
savedAt: state.savedAt
|
|
4156
|
-
}
|
|
4157
|
-
)
|
|
4158
|
-
] });
|
|
4159
|
-
}
|
|
4160
|
-
function PersonaEditor({ t, controller }) {
|
|
4161
|
-
const state = (0, import_react8.useSyncExternalStore)(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
4162
|
-
(0, import_react8.useEffect)(() => {
|
|
4163
|
-
void controller.load();
|
|
4164
|
-
}, [controller]);
|
|
4165
|
-
const notice2 = StatusNotice({ t, state });
|
|
4166
|
-
if (notice2 !== null) return notice2;
|
|
4167
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ReadyEditor, { t, controller, state });
|
|
4168
|
-
}
|
|
4169
|
-
|
|
4170
|
-
// src/client/WorkbenchTabs.tsx
|
|
4171
|
-
var import_dsh_client_ui_primitives7 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
4172
|
-
|
|
4173
|
-
// src/client/tab-styles.ts
|
|
4174
|
-
var tabBar = {
|
|
4175
|
-
display: "grid",
|
|
4176
|
-
gridTemplateColumns: "repeat(4, minmax(0, 1fr))",
|
|
4177
|
-
gap: 8,
|
|
4178
|
-
marginTop: 24
|
|
4179
|
-
};
|
|
4180
|
-
|
|
4181
|
-
// src/client/WorkbenchTabs.tsx
|
|
4182
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
4183
|
-
var TABS = [
|
|
4184
|
-
["persona", "memory.tab.persona"],
|
|
4185
|
-
["emotion", "emotion.tab"],
|
|
4186
|
-
["memory", "memory.tab.memory"],
|
|
4187
|
-
["evolution", "workbench.evolution.tab"]
|
|
4188
|
-
];
|
|
4189
|
-
function WorkbenchTabs({ t, tab, onSelect }) {
|
|
4190
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("nav", { style: tabBar, children: TABS.map(([id, labelKey]) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
4191
|
-
import_dsh_client_ui_primitives7.Button,
|
|
4192
|
-
{
|
|
4193
|
-
size: "sm",
|
|
4194
|
-
variant: tab === id ? "primary" : "outline",
|
|
4195
|
-
style: { width: "100%" },
|
|
4196
|
-
"aria-current": tab === id ? "page" : void 0,
|
|
4197
|
-
onClick: () => onSelect(id),
|
|
4198
|
-
children: t(labelKey)
|
|
4199
|
-
},
|
|
4200
|
-
id
|
|
4201
|
-
)) });
|
|
4202
|
-
}
|
|
4203
|
-
|
|
4204
|
-
// src/client/HumanityWorkbench.tsx
|
|
4205
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4206
|
-
function HumanityWorkbench({ t, controller, emotion, memory, evolution }) {
|
|
4207
|
-
const [tab, setTab] = (0, import_react9.useState)("persona");
|
|
4208
|
-
const body = tab === "persona" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PersonaEditor, { t, controller }) : tab === "emotion" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EmotionPage, { t, controller: emotion }) : tab === "memory" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MemoryPage, { t, controller: memory }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EvolutionPage, { t, controller: evolution });
|
|
4209
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: page, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: column, children: [
|
|
4210
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("header", { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: titleRow, children: [
|
|
4211
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h1", { style: title, children: "Humanity" }),
|
|
4212
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InfoHint, { label: t("workbench.titleHint"), side: "bottom" })
|
|
4213
|
-
] }) }),
|
|
4214
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(OverviewPanel, { t, memory, persona: controller }),
|
|
4215
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(WorkbenchTabs, { t, tab, onSelect: setTab }),
|
|
4216
|
-
body
|
|
4217
|
-
] }) });
|
|
4218
|
-
}
|
|
4219
|
-
|
|
4220
|
-
// src/client/PersonaBoundary.tsx
|
|
4221
|
-
var import_react10 = require("react");
|
|
4222
|
-
var PersonaBoundary = class extends import_react10.Component {
|
|
4223
|
-
state = { failed: false };
|
|
4224
|
-
/** 子树的渲染错误 → 只翻自己的标志位。 */
|
|
4225
|
-
static getDerivedStateFromError() {
|
|
4226
|
-
return { failed: true };
|
|
4227
|
-
}
|
|
4228
|
-
/** 记一条诊断,但绝不再抛。 */
|
|
4229
|
-
componentDidCatch(error, info) {
|
|
4230
|
-
try {
|
|
4231
|
-
console.error("[humanity] 人格面板渲染失败,已就地兜底(外壳不受影响)", error, info?.componentStack);
|
|
4232
|
-
} catch {
|
|
4233
|
-
}
|
|
4234
|
-
}
|
|
4235
|
-
render() {
|
|
4236
|
-
return this.state.failed ? this.props.fallback : this.props.children;
|
|
4237
|
-
}
|
|
4238
|
-
};
|
|
4239
|
-
|
|
4240
|
-
// src/client/WorkbenchSeat.tsx
|
|
4241
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
4242
|
-
var fallbackTranslate = (key) => String(key);
|
|
4243
|
-
function FallbackNote({ kind }) {
|
|
4244
|
-
const text = kind === "broken" ? "Humanity 面板暂时无法显示(渲染出错,已就地拦截,不影响会话与对话)。可刷新页面重试;若持续出现,请到 **DSH 设置**里搜索 Humanity,关掉「人格」模块。" : "Humanity 面板暂时无法显示(工作台未完全接上,已就地拦截,不影响会话与对话)。这一般发生在某个模块的通道还没就绪时,刷新页面即可。";
|
|
4245
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { padding: 16, color: "var(--dsw-alias-label-secondary)", fontSize: 13, lineHeight: 1.6 }, children: text });
|
|
4246
|
-
}
|
|
4247
|
-
function createWorkbenchSeat(controller, emotion, memory, evolution) {
|
|
4248
|
-
return function WorkbenchSeat(props) {
|
|
4249
|
-
const t = typeof props?.t === "function" ? props.t : fallbackTranslate;
|
|
4250
|
-
const unwired = [controller, emotion, memory, evolution].some((seat) => seat === void 0 || seat === null);
|
|
4251
|
-
return (
|
|
4252
|
-
// `PersonaBoundary` 是**产品级防御**,不是排查用的脚手架:工作台里任何一次渲染抛错,
|
|
4253
|
-
// React 会把**整个根**卸载(真机现象:点会话 → 会话列表全没了)。边界把爆炸半径收到
|
|
4254
|
-
// 工作台这一块,并换上一句可读的说明。它保留在最终实现里。
|
|
4255
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PersonaBoundary, { fallback: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FallbackNote, { kind: "broken" }), children: unwired ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FallbackNote, { kind: "unwired" }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(HumanityWorkbench, { t, controller, emotion, memory, evolution }) })
|
|
4256
|
-
);
|
|
4257
|
-
};
|
|
4258
|
-
}
|
|
4259
|
-
|
|
4260
|
-
// src/client/index.ts
|
|
4261
|
-
var name = "humanity-client";
|
|
4262
|
-
var inject = ["slots", "locale"];
|
|
4263
|
-
function registerLocale(ctx) {
|
|
4264
|
-
ctx.effect(() => {
|
|
4265
|
-
try {
|
|
4266
|
-
return ctx.locale.register(NS, { zh, en });
|
|
4267
|
-
} catch (error) {
|
|
4268
|
-
console.error("[humanity] 文案字典注册失败,将使用键名兜底", error);
|
|
4269
|
-
return () => {
|
|
4270
|
-
};
|
|
4271
|
-
}
|
|
4272
|
-
}, "humanity: 文案字典");
|
|
4273
|
-
}
|
|
4274
|
-
function safeRegister(what2, register) {
|
|
4275
|
-
try {
|
|
4276
|
-
register();
|
|
4277
|
-
} catch (error) {
|
|
4278
|
-
console.error(`[humanity] ${what2} 注册失败,已跳过(不影响外壳与其它的槽位)`, error);
|
|
4279
|
-
}
|
|
4280
|
-
}
|
|
4281
|
-
function registerSidebarEntry(ctx) {
|
|
4282
|
-
const icon = (props) => (0, import_react12.createElement)(HumanityPanelIcon, props);
|
|
4283
|
-
safeRegister(
|
|
4284
|
-
"侧栏入口",
|
|
4285
|
-
() => ctx.slots.inject(
|
|
4286
|
-
"sidebar.panellist",
|
|
4287
|
-
() => ctx.slots.register({ name: "sidebar.panellist", id: WORKBENCH_ID, order: PANEL_ORDER, label: PANEL_LABEL }, icon)
|
|
4288
|
-
)
|
|
4289
|
-
);
|
|
4290
|
-
}
|
|
4291
|
-
function registerWorkbench(ctx, seat) {
|
|
4292
|
-
safeRegister(
|
|
4293
|
-
"主面板",
|
|
4294
|
-
() => ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: WORKBENCH_ID, locale: NS }, seat))
|
|
4295
|
-
);
|
|
4296
|
-
}
|
|
4297
|
-
function apply(ctx) {
|
|
4298
|
-
registerLocale(ctx);
|
|
4299
|
-
const controller = new PersonaWorkbenchController();
|
|
4300
|
-
const emotion = new EmotionWorkbenchController();
|
|
4301
|
-
const memory = new MemoryWorkbenchController();
|
|
4302
|
-
const evolution = new EvolutionWorkbenchController();
|
|
4303
|
-
attachRemoteController(ctx, controller, PERSONA_NAMESPACE, "人格");
|
|
4304
|
-
attachRemoteController(ctx, emotion, EMOTION_NAMESPACE, "情绪");
|
|
4305
|
-
attachRemoteController(ctx, memory, MEMORY_NAMESPACE, "记忆", { pollMs: 12e4 });
|
|
4306
|
-
attachRemoteController(ctx, evolution, EVOLUTION_NAMESPACE, "自进化", { pollMs: 6e4 });
|
|
4307
|
-
registerSidebarEntry(ctx);
|
|
4308
|
-
registerWorkbench(ctx, createWorkbenchSeat(controller, emotion, memory, evolution));
|
|
4309
|
-
}
|
|
8
|
+
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name2 in all)__defProp(target,name2,{get:all[name2],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var index_exports={};__export(index_exports,{EMOTION_NAMESPACE:()=>EMOTION_NAMESPACE,EVOLUTION_NAMESPACE:()=>EVOLUTION_NAMESPACE,EmotionPage:()=>EmotionPage,EmotionWorkbenchController:()=>EmotionWorkbenchController,EvolutionPage:()=>EvolutionPage,EvolutionWorkbenchController:()=>EvolutionWorkbenchController,HUMANITY_NAMESPACE:()=>HUMANITY_NAMESPACE,HumanityPanelIcon:()=>HumanityPanelIcon,MEMORY_NAMESPACE:()=>MEMORY_NAMESPACE,MemoryPage:()=>MemoryPage,MemoryWorkbenchController:()=>MemoryWorkbenchController,OverviewPanel:()=>OverviewPanel,PERSONA_NAMESPACE:()=>PERSONA_NAMESPACE,PersonaBoundary:()=>PersonaBoundary,PersonaWorkbenchController:()=>PersonaWorkbenchController,apply:()=>apply,asEmotionDocument:()=>asEmotionDocument,asMemoryDocument:()=>asMemoryDocument,createWorkbenchSeat:()=>createWorkbenchSeat,inject:()=>inject,name:()=>name,subscribeToProjection:()=>subscribeToProjection});module.exports=__toCommonJS(index_exports);var import_react12=require("react");var EMOTION_NAMESPACE="humanity-emotion";function asString(value){return typeof value=="string"?value:""}function asNumber(value){return typeof value=="number"&&Number.isFinite(value)?value:0}function asEmotionDocument(value){let raw=value??{};return{charges:(Array.isArray(raw.charges)?raw.charges:[]).map(entry=>{let charge=entry??{};return{kind:asString(charge.kind),label:asString(charge.label),target:asString(charge.target)||"world",targetLabel:asString(charge.targetLabel),intensity:asNumber(charge.intensity),delta:asNumber(charge.delta),before:charge.before===void 0||charge.before===null?-1:asNumber(charge.before),tier:asString(charge.tier)||"calm",cause:asString(charge.cause),since:asString(charge.since)}}),sensitivities:(Array.isArray(raw.sensitivities)?raw.sensitivities:[]).map(entry=>{let item=entry??{};return{kind:asString(item.kind),label:asString(item.label),target:asString(item.target)||"world",targetLabel:asString(item.targetLabel),level:Math.max(0,Math.min(1,asNumber(item.level))),cause:asString(item.cause),delta:asNumber(item.delta),levelBefore:Math.max(0,Math.min(1,asNumber(item.levelBefore))),at:asString(item.at)}}),warmth:asNumber(raw.warmth),warmthCause:asString(raw.warmthCause),compositeLabel:asString(raw.compositeLabel),compositeParts:Array.isArray(raw.compositeParts)?raw.compositeParts.map(part=>asString(part)).filter(part=>part!==""):[],perceived:asString(raw.perceived),perceivedAt:asString(raw.perceivedAt),energy:asNumber(raw.energy),energyLevel:asString(raw.energyLevel)||"fresh",settledAt:asString(raw.settledAt),updatedAt:asString(raw.updatedAt),notice:asString(raw.notice)}}var EmotionWorkbenchController=class{channel;listeners=new Set;snapshot={status:"unavailable"};attach(channel){this.channel=channel!=null&&typeof channel.describe=="function"?channel:void 0,this.load()}detach(){this.channel=void 0,this.set({...this.snapshot,status:"unavailable"})}async load(options){let channel=this.channel;if(channel===void 0){this.set({status:"unavailable"});return}options?.quiet!==!0&&this.set({status:"loading",document:this.snapshot.document});let result;try{result=await channel.describe()}catch(error){this.set({status:"failed",error:error instanceof Error?error.message:String(error)});return}if(result==null||result.ok!==!0){this.set({status:"failed",error:result?.error?.message??"宿主没有返回可用的数据"});return}let view=(Array.isArray(result.value?.namespaces)?result.value.namespaces:[]).find(entry=>entry?.ns===EMOTION_NAMESPACE);if(view===void 0){this.set({status:"unavailable"});return}this.set({status:"ready",document:asEmotionDocument(view.value)})}subscribe=listener=>(this.listeners.add(listener),()=>{this.listeners.delete(listener)});getSnapshot=()=>this.snapshot;set(next){this.snapshot=next;for(let listener of this.listeners)listener()}};var EVOLUTION_NAMESPACE="humanity-evolution";function emptyEvolutionDocument(){return{status:{enabled:!1,started:!1,sleeping:!1,energy:0,dayCount:0,maxPerDay:0,lastWakeAt:"",nextAt:"",taskReady:!1,busy:!1,lastError:"",lastSettleError:"",lastTurnTools:0,busySince:"",lastAppraise:"",roomText:"",roomPath:"",roomTarget:""},diary:[],works:[],threads:[],grow:{candidates:[],lastRun:{at:"",wrote:[],queued:[],note:""}},tell:{pending:"",pendingShow:"",lastAt:"",lastText:"",lastShow:"",unread:!1,lastReason:""},transfer:{name:"",mime:"",base64:""},request:{op:"",value:""},notice:""}}function asEvolutionDocument(value){let empty=emptyEvolutionDocument();if(typeof value!="object"||value===null)return empty;let raw=value,status=typeof raw.status=="object"&&raw.status!==null?raw.status:{},diary=Array.isArray(raw.diary)?raw.diary.map(item=>{let entry=typeof item=="object"&&item!==null?item:{};return{date:typeof entry.date=="string"?entry.date:"",opened:entry.opened===!0,openedAt:typeof entry.openedAt=="string"?entry.openedAt:"",noticedAt:typeof entry.noticedAt=="string"?entry.noticedAt:"",text:typeof entry.text=="string"?entry.text:""}}):[],works=Array.isArray(raw.works)?raw.works.map(item=>{let entry=typeof item=="object"&&item!==null?item:{};return{name:typeof entry.name=="string"?entry.name:"",size:typeof entry.size=="number"?entry.size:0,updatedAt:typeof entry.updatedAt=="string"?entry.updatedAt:"",kind:typeof entry.kind=="string"?entry.kind:"other",preview:typeof entry.preview=="string"?entry.preview:""}}):[],request=typeof raw.request=="object"&&raw.request!==null?raw.request:{},growRaw=typeof raw.grow=="object"&&raw.grow!==null?raw.grow:{},candidates=Array.isArray(growRaw.candidates)?growRaw.candidates.map(item=>{let entry=typeof item=="object"&&item!==null?item:{};return{text:typeof entry.text=="string"?entry.text:"",about:typeof entry.about=="string"?entry.about:"self",section:typeof entry.section=="string"?entry.section:"",count:typeof entry.count=="number"?entry.count:0,days:typeof entry.days=="number"?entry.days:0}}):[],lastRunRaw=typeof growRaw.lastRun=="object"&&growRaw.lastRun!==null?growRaw.lastRun:{},strings=value2=>Array.isArray(value2)?value2.filter(line=>typeof line=="string"):[],tellRaw=typeof raw.tell=="object"&&raw.tell!==null?raw.tell:{};return{status:{enabled:status.enabled===!0,started:status.started===!0,sleeping:status.sleeping===!0,energy:typeof status.energy=="number"?status.energy:0,dayCount:typeof status.dayCount=="number"?status.dayCount:0,maxPerDay:typeof status.maxPerDay=="number"?status.maxPerDay:0,lastWakeAt:typeof status.lastWakeAt=="string"?status.lastWakeAt:"",nextAt:typeof status.nextAt=="string"?status.nextAt:"",taskReady:status.taskReady===!0,busy:status.busy===!0,lastError:typeof status.lastError=="string"?status.lastError:"",lastSettleError:typeof status.lastSettleError=="string"?status.lastSettleError:"",lastTurnTools:typeof status.lastTurnTools=="number"?status.lastTurnTools:0,busySince:typeof status.busySince=="string"?status.busySince:"",lastAppraise:typeof status.lastAppraise=="string"?status.lastAppraise:"",roomText:typeof status.roomText=="string"?status.roomText:"",roomPath:typeof status.roomPath=="string"?status.roomPath:"",roomTarget:typeof status.roomTarget=="string"?status.roomTarget:""},diary,works,threads:Array.isArray(raw.threads)?raw.threads.filter(line=>typeof line=="string"):[],grow:{candidates,lastRun:{at:typeof lastRunRaw.at=="string"?lastRunRaw.at:"",wrote:strings(lastRunRaw.wrote),queued:strings(lastRunRaw.queued),note:typeof lastRunRaw.note=="string"?lastRunRaw.note:""}},tell:{pending:typeof tellRaw.pending=="string"?tellRaw.pending:"",pendingShow:typeof tellRaw.pendingShow=="string"?tellRaw.pendingShow:"",lastAt:typeof tellRaw.lastAt=="string"?tellRaw.lastAt:"",lastText:typeof tellRaw.lastText=="string"?tellRaw.lastText:"",lastShow:typeof tellRaw.lastShow=="string"?tellRaw.lastShow:"",unread:tellRaw.unread===!0,lastReason:typeof tellRaw.lastReason=="string"?tellRaw.lastReason:""},transfer:{name:typeof raw.transfer?.name=="string"?String(raw.transfer.name):"",mime:typeof raw.transfer?.mime=="string"?String(raw.transfer.mime):"",base64:typeof raw.transfer?.base64=="string"?String(raw.transfer.base64):""},request:{op:typeof request.op=="string"?request.op:"",value:typeof request.value=="string"?request.value:""},notice:typeof raw.notice=="string"?raw.notice:""}}function saveTransfer(transfer){if(typeof document>"u"||typeof atob!="function")return!1;try{let binary=atob(transfer.base64),bytes=new Uint8Array(binary.length);for(let index=0;index<binary.length;index+=1)bytes[index]=binary.charCodeAt(index);let blob=new Blob([bytes],{type:transfer.mime===""?"application/octet-stream":transfer.mime}),url=URL.createObjectURL(blob),anchor2=document.createElement("a");return anchor2.href=url,anchor2.download=transfer.name,anchor2.click(),URL.revokeObjectURL(url),!0}catch{return!1}}var EvolutionWorkbenchController=class{channel;revision;listeners=new Set;state={status:"idle",doc:emptyEvolutionDocument()};subscribe=listener=>(this.listeners.add(listener),()=>{this.listeners.delete(listener)});getSnapshot=()=>this.state;attach(channel){this.channel=channel!=null&&typeof channel.describe=="function"?channel:void 0,this.load()}detach(){this.channel=void 0,this.setState({status:"unavailable",doc:this.state.doc})}async setWakeCap(value){let channel=this.channel;if(channel===void 0)return!1;try{await this.load({quiet:!0});let outcome=await channel.replace(EVOLUTION_NAMESPACE,{...this.state.doc,request:{op:"cap",value:String(value)},notice:""},this.revision);return outcome.ok&&(this.revision=outcome.value?.value?.revision??this.revision),await this.load({quiet:!0}),outcome.ok===!0}catch{return!1}}async setRoom(value){let channel=this.channel;if(channel===void 0)return!1;try{await this.load({quiet:!0});let outcome=await channel.replace(EVOLUTION_NAMESPACE,{...this.state.doc,request:{op:"room",value},notice:""},this.revision);return outcome.ok&&(this.revision=outcome.value?.value?.revision??this.revision),outcome.ok!==!0?!1:(await this.load({quiet:!0}),!0)}catch{return!1}}async dropCandidate(text){let channel=this.channel;if(channel===void 0||text==="")return!1;try{await this.load({quiet:!0});let outcome=await channel.replace(EVOLUTION_NAMESPACE,{...this.state.doc,request:{op:"grow-drop",value:text},notice:""},this.revision);return outcome.ok&&(this.revision=outcome.value?.value?.revision??this.revision),outcome.ok!==!0?!1:(await this.load({quiet:!0}),!0)}catch{return!1}}async download(name2){let channel=this.channel;if(channel===void 0||name2==="")return!1;try{await this.load({quiet:!0});let outcome=await channel.replace(EVOLUTION_NAMESPACE,{...this.state.doc,request:{op:"read",value:name2},notice:""},this.revision);if(outcome.ok!==!0)return!1;this.revision=outcome.value?.value?.revision??this.revision,await this.load({quiet:!0});let transfer=this.state.doc.transfer;return transfer.name!==name2||transfer.base64===""?!1:saveTransfer(transfer)}catch{return!1}}async open(date){let channel=this.channel;if(channel===void 0||date==="")return!1;try{await this.load({quiet:!0});let outcome=await channel.replace(EVOLUTION_NAMESPACE,{...this.state.doc,request:{op:"open",value:date},notice:""},this.revision);return outcome.ok&&(this.revision=outcome.value?.value?.revision??this.revision),outcome.ok!==!0?!1:(await this.load({quiet:!0}),!0)}catch{return!1}}async load(options={}){let channel=this.channel;if(channel===void 0){this.setState({status:"unavailable",doc:this.state.doc});return}try{let envelope=await channel.describe(),view=(envelope?.value?.namespaces??[]).find(candidate=>candidate.ns===EVOLUTION_NAMESPACE);if(envelope?.ok===!1||view===void 0){this.setState({status:"unavailable",doc:this.state.doc});return}this.revision=view.revision,this.setState({status:"ready",doc:asEvolutionDocument(view.value)})}catch{if(options.quiet===!0)return;this.setState({status:"unavailable",doc:this.state.doc})}}setState(next){this.state=next;for(let listener of this.listeners)listener()}};var import_react=require("react");var primitives=__toESM(require("@deepseek-ai/dsh-client-ui-primitives"),1),ICON_CANDIDATES={IconQuestion:["IconQuestionOutline14","IconQuestionOutline"],IconChevronDown:["IconChevronDownOutline14","IconChevronDownOutline"],IconChevronRight:["IconChevronRightOutline14","IconChevronRightOutline"],IconPersonalization:["IconPersonalizationOutline16","IconPersonalizationOutline"]};function isRenderable(value){return typeof value=="function"||typeof value=="object"&&value!==null}function resolveIcon(group){let names=ICON_CANDIDATES[group]??[],bag=primitives;for(let name2 of names)if(isRenderable(bag[name2]))return bag[name2]}var IconQuestion=resolveIcon("IconQuestion"),IconChevronDown=resolveIcon("IconChevronDown"),IconChevronRight=resolveIcon("IconChevronRight"),IconPersonalization=resolveIcon("IconPersonalization"),CANDIDATE_NAMES=Object.values(ICON_CANDIDATES).flat();var import_jsx_runtime=require("react/jsx-runtime");function FallbackGlyph({size=16}){return(0,import_jsx_runtime.jsxs)("svg",{width:size,height:size,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,import_jsx_runtime.jsx)("circle",{cx:"8",cy:"5.5",r:"2.5",stroke:"currentColor",strokeWidth:"1.2"}),(0,import_jsx_runtime.jsx)("path",{d:"M3 13c0-2.5 2.2-4 5-4s5 1.5 5 4",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})}function HumanityPanelIcon({size}){return(0,import_jsx_runtime.jsx)(IconPersonalization??FallbackGlyph,{size:typeof size=="number"&&Number.isFinite(size)?size:16})}var WORKBENCH_ID="humanity";var PANEL_LABEL="Humanity";var emotionZh={"emotion.tab":"情绪","emotion.title":"它此刻","emotion.hint":"这里显示它现在的心情:由对话里发生的事推动,随时间自己退。它只在「Humanity 沉浸」里生效;功能模式完全不读不写。这一页只是观察窗——心情不靠手动拨,靠你们之间发生的事。","emotion.calm":"平静","emotion.empty":"现在没有明显的情绪。","emotion.composite":"合起来是","emotion.compositeHint":"两种基本情绪同时够强时,它们合起来有一个名字 —— 这一行不是另加的情绪,是上面两条的合成。","emotion.sensitivity":"磨出来的敏感","emotion.sensitivityHint":"同一个人的同一类事反复落在同一处,这一处就会越来越容易被点着:下一次最多比第一次重一半。它自己也会退:一天剩一半,两三天不碰就淡了。好事不记在这里。","emotion.sensitivityEmpty":"还没有哪一处被反复磨到。","emotion.sensitivityNoCause":"这一处被磨过,但没记下是因为什么","emotion.sensitivityDelta":"这是最近一次磨它的那笔增减","emotion.warmth":"关系温度","emotion.warmthHint":"它此刻对你的感觉(会变),不是「我们是什么关系」(那个在人格里)。","emotion.perceived":"它眼里的你","emotion.perceivedHint":"它从这句话里读到的你的状态。看得准不准另说,但它确实在看你。","emotion.energy":"精力","emotion.energyHint":"它会累:白天消耗、每过一天恢复。累了话会变短 —— 跟心情好坏无关,是没力气。","emotion.params.title":"它怎么算的(这些数不在这页改)","emotion.params.hint":"这几条是标定过的:改动它们等于改她的性子,所以只能改代码,不给你一个随时能拨的旋钮。写在这里是为了让你看得见。","emotion.params.floor":"触发线:{floor} 分以上才写进她读到的那一段","emotion.params.tiers":"档位:{faint} / {clear} / {burst} 分(有点 / 明显 / 爆发)","emotion.params.sensitivity":"磨出来的敏感:同一处反复被刺,最多放大到 {boost} 倍,{hours} 小时减半","emotion.params.soothe":"自调节:{minutes} 分钟没再被刺,负面情绪退得快一倍","emotion.energy.fresh":"有精神","emotion.energy.tired":"有点累","emotion.energy.exhausted":"很累","emotion.cause":"因为","emotion.deltaUp":"比上一次评估多了 {n}","emotion.deltaDown":"比上一次评估少了 {n}","emotion.noCause":"没有具体原因,只是残留","emotion.since":"已经 {duration}","emotion.duration.minutes":"{n} 分钟","emotion.duration.hours":"{n} 小时","emotion.duration.days":"{n} 天","emotion.ago":"{duration}前","emotion.agoNow":"刚刚","emotion.tier.calm":"微弱","emotion.absent":"没有","emotion.tier.faint":"轻微","emotion.tier.clear":"明显","emotion.tier.burst":"强烈","emotion.tier.burstHint":"到了这一档,它可以直接说出来(只说一次)。","emotion.loading":"正在读取…","emotion.unavailable":"情绪模块未就绪(宿主那一半没挂上,或模块被关掉了)。","emotion.failed":"读取失败:{message}","emotion.reload":"重新读取","emotion.settledAt":"上次结算:{time}","emotion.globalHint":"这一份状态是全局的:换会话不会重置,也不按会话分开记。"},emotionEn={"emotion.tab":"Mood","emotion.title":"How it feels right now","emotion.hint":'What it is feeling **right now**: pushed by what happens in the conversation and decaying on its own over time. It only applies to the "Humanity Immersive" preset; the functional preset never reads or writes it. This page is a window, not a dial — mood is moved by what happens between you.',"emotion.calm":"Calm","emotion.empty":"No strong emotion right now.","emotion.composite":"Together that reads as","emotion.compositeHint":"When two basic emotions are both strong, they have a combined name — this line is not a third emotion, it is the blend of the two above.","emotion.sensitivity":"What has worn thin","emotion.sensitivityHint":"When the same kind of thing keeps landing on the same spot, that spot gets easier to set off: at most half again as heavy as the first time. It fades on its own — half gone in a day, mostly gone after two or three. Good things are not counted here.","emotion.sensitivityEmpty":"Nothing has been worn thin yet.","emotion.sensitivityNoCause":"This spot was worn, but what wore it was not recorded","emotion.sensitivityDelta":"How much the last sting moved it","emotion.warmth":"Warmth","emotion.warmthHint":'How it feels about you at this moment (moves fast), not "what we are to each other" (that lives in the persona).',"emotion.perceived":"What it noticed about you","emotion.perceivedHint":"The state it read from your last message. It may be wrong — but it is looking.","emotion.energy":"Energy","emotion.energyHint":"It gets tired: drains through the day, recovers once a day. Tired means shorter answers — not bad mood, just no fuel.","emotion.params.title":"How it is computed (not editable here)","emotion.params.hint":"These are calibrated together: changing them changes her temperament, so they stay in code instead of a dial. They are listed here so you can see them.","emotion.params.floor":"Floor: only above {floor} reaches the paragraph she reads","emotion.params.tiers":"Tiers: {faint} / {clear} / {burst} (slight / clear / burst)","emotion.params.sensitivity":"Worn-in sensitivity: repeated stings at one spot amplify up to {boost}x, halving in {hours}h","emotion.params.soothe":"Self-soothing: after {minutes} quiet minutes a negative feeling fades twice as fast","emotion.energy.fresh":"fresh","emotion.energy.tired":"a bit tired","emotion.energy.exhausted":"exhausted","emotion.cause":"Because","emotion.deltaUp":"{n} more than the last reading","emotion.deltaDown":"{n} less than the last reading","emotion.noCause":"No specific reason; just residue","emotion.since":"for {duration}","emotion.duration.minutes":"{n} min","emotion.duration.hours":"{n} h","emotion.duration.days":"{n} d","emotion.ago":"{duration} ago","emotion.agoNow":"just now","emotion.tier.calm":"slight","emotion.absent":"none","emotion.tier.faint":"faint","emotion.tier.clear":"clear","emotion.tier.burst":"strong","emotion.tier.burstHint":"At this level it may say it outright (once).","emotion.loading":"Reading…","emotion.unavailable":"The emotion module is not ready (host side missing, or the module is off).","emotion.failed":"Could not read: {message}","emotion.reload":"Reload","emotion.settledAt":"Last settled: {time}","emotion.globalHint":"This state is global: switching sessions does not reset it, and it is not stored per session."};var workbenchZh={"workbench.titleHint":'人格、情绪、记忆,和她自己的时间,统一在这里看。各模块的开关在 DSH 设置里(搜 "Humanity")。',"workbench.overview":"总览","workbench.metric.name":"姓名","workbench.metric.nameEmpty":"还没设置","workbench.metric.memory":"记忆","workbench.metric.memoryHint":"她自己的经历账里现在有多少条;读不到时如实说明,不填推测的数字。","workbench.metric.unavailable":"暂时读不到","workbench.state.loading":"加载中…","workbench.state.unavailable":"暂时读不到(设置服务没接上,或 Humanity 模块被关掉了)。","workbench.metric.memoryValue":"{count} 条","workbench.evolution.tab":"自进化","workbench.evolution.today":"她的今天","workbench.evolution.todayHint":"她自己的一天:醒来几次、还剩多少力气、下一次什么时候醒。她不会闲聊时被叫醒,安静一阵之后才有她自己的时间。","workbench.evolution.notStarted":"人格还没封存,她还没有开始过日子。","workbench.evolution.field.state":"现在","workbench.evolution.field.energy":"精力","workbench.evolution.field.wakes":"今天醒过","workbench.evolution.field.lastWake":"上一次醒","workbench.evolution.field.nextWake":"下一次醒","workbench.evolution.field.lastTurn":"上一轮她做了什么","workbench.evolution.lastTurn.tools":"动了手:调了 {count} 次工具","workbench.evolution.lastTurn.talk":"只说了话,没动手","workbench.evolution.appraise.applied":"自评 {count} 条({targets})","workbench.evolution.appraise.none":"自评:看了,但没动心","workbench.evolution.appraise.skipped":"自评没跑(情绪模块没接上)","workbench.evolution.busy":"(你正在跟她说话,闹钟压着","workbench.evolution.busySince":"从 {time} 起)","workbench.evolution.state.awake":"醒着","workbench.evolution.state.sleeping":"在睡","workbench.evolution.energy.fresh":"还有力气({value}/100)","workbench.evolution.energy.ok":"还行({value}/100)","workbench.evolution.energy.tired":"有点累({value}/100)","workbench.evolution.energy.spent":"快没力气了({value}/100)","workbench.evolution.wakesValue":"{count} 次(上限 {max} 次)","workbench.evolution.cap.aria":"一天最多醒几次(回车生效)","workbench.evolution.room.title":"她的房间","workbench.evolution.room.hint":"她自己待着的地方。填一个名字(建在数据目录里)或一条完整路径;填完回车生效。她只会在下一次排程时搬过去,旧会话留在原处不动。","workbench.evolution.room.aria":"她的房间:名字或完整路径(回车生效)","workbench.evolution.room.placeholder":"名字,或完整路径","workbench.evolution.room.nowAt":"现在住在这里:{path}","workbench.evolution.room.pending":"改成了 {path} —— 她手头这一轮结束就搬过去(旧会话留在原处)。","workbench.evolution.room.legacy":"现在住在老位置(还没填过)。","workbench.evolution.error":"上一次没排上:{reason}","workbench.evolution.diary.title":"她的日记","workbench.evolution.diary.hint":"一天一篇,用她自己的口气写。默认是合着的 —— 只显示日期;翻开之后那一天的正文才给你看,而且翻了就是翻了。","workbench.evolution.diary.settleFailed":"上一次收账没写成:{reason}","workbench.evolution.diary.empty":"还没有写过日记。她睡下的时候才收一天。","workbench.evolution.diary.open":"翻开","workbench.evolution.diary.confirm":"翻开就收不回去了,确定?","workbench.evolution.diary.confirmYes":"确认翻开","workbench.evolution.diary.confirmNo":"算了","workbench.evolution.diary.openedAt":"在 {time} 被翻开","workbench.evolution.diary.unnoticed":"她还没发现","workbench.evolution.diary.noticed":"她在 {time} 知道了","workbench.evolution.tell.title":"她留给你的","workbench.evolution.tell.hint":"她自己待着的时候,可以主动找你说一句(或给你看一样东西)。那句话会送到你们说话的那个会话里;这一块是留底——你没看过的那次会标出来。","workbench.evolution.tell.pending":"她有一句还没送出去的话(等你闲下来才送)","workbench.evolution.tell.lastAt":"她在 {time} 找过你","workbench.evolution.tell.withWork":"还给你看了 {name}","workbench.evolution.tell.onlyWork":"(没说话,只想让你看样东西)","workbench.evolution.tell.unread":"你还没看","workbench.evolution.tell.seen":"你看过了","workbench.evolution.tell.reason":"没送成:{reason}","workbench.evolution.tell.empty":"她还没主动找过你。","workbench.evolution.grow.title":"她自己整理","workbench.evolution.grow.hint":"每天收账之后,她会把这一天折成信息层的变化:你明说的要求当天落地,其余的观察先攒证据。这里是她正攒着的(够次数、跨够多天才会写进去)。","workbench.evolution.grow.empty":"队列还空着——还没有够得上留在她身上的事。","workbench.evolution.grow.lastRun":"上次整理:{time}","workbench.evolution.grow.wrote":"写进了 {list}","workbench.evolution.grow.count":"提到 {count} 次","workbench.evolution.grow.days":"跨 {days} 天","workbench.evolution.grow.aboutUser":"关于他","workbench.evolution.grow.aboutSelf":"关于她自己","workbench.evolution.grow.drop":"删掉","workbench.evolution.threads.title":"她手上攒着的事","workbench.evolution.threads.hint":"她自己写在本子上的待办(她自己目录里的 todo.md)。每次醒来她第一眼看到的就是这些;写不写、划不划掉,都是她的事。","workbench.evolution.threads.empty":"她手上没攒着事。","workbench.evolution.works.title":"她留下的东西","workbench.evolution.works.hint":"她自己目录里的文件(写的东西、以后画的图)。文本能直接看;图片只能看到名字与大小——浏览器拿不到宿主上的文件。","workbench.evolution.works.empty":"她还没留下什么。","workbench.evolution.works.noPreview":"这一样只能看到名字与大小。","workbench.evolution.works.download":"下载","workbench.evolution.works.previewToggle":"看内容","workbench.overviewHint":"这几项读的是当前真实状态;读不到时如实说明,不填推测的数字。高风险改动(例如整节删除人格信息里仍有内容的小标题)在对话里确认。"},workbenchEn={"workbench.titleHint":'Persona, emotion and memory, all in one place. Per-module switches live in the DSH settings (search for "Humanity").',"workbench.overview":"Overview","workbench.metric.name":"Name","workbench.metric.nameEmpty":"Not set yet","workbench.metric.memory":"Memory","workbench.metric.memoryHint":"How many entries her own record of experiences holds; when it is not readable it says so instead of showing a guess.","workbench.metric.unavailable":"Not available right now","workbench.state.loading":"Loading…","workbench.state.unavailable":"Not readable right now (the settings service is not attached, or the Humanity module is off).","workbench.metric.memoryValue":"{count} entries","workbench.evolution.tab":"Self-evolution","workbench.evolution.today":"Her day","workbench.evolution.todayHint":"Her own day: how many times she woke, how much energy is left, when she wakes next. She is never woken while you two are talking.","workbench.evolution.notStarted":"The persona is not sealed yet; she has not started having days.","workbench.evolution.field.state":"Now","workbench.evolution.field.energy":"Energy","workbench.evolution.field.wakes":"Woke today","workbench.evolution.field.lastWake":"Last wake","workbench.evolution.field.nextWake":"Next wake","workbench.evolution.field.lastTurn":"Last waking","workbench.evolution.lastTurn.tools":"acted: used {count} tool calls","workbench.evolution.lastTurn.talk":"only talked, no tools","workbench.evolution.appraise.applied":"felt {count} things ({targets})","workbench.evolution.appraise.none":"read it, felt nothing","workbench.evolution.appraise.skipped":"appraisal did not run (emotion module offline)","workbench.evolution.busy":"(paused, you two are talking","workbench.evolution.busySince":"since {time})","workbench.evolution.state.awake":"Awake","workbench.evolution.state.sleeping":"Asleep","workbench.evolution.energy.fresh":"Has energy ({value}/100)","workbench.evolution.energy.ok":"Fine ({value}/100)","workbench.evolution.energy.tired":"A little tired ({value}/100)","workbench.evolution.energy.spent":"Nearly spent ({value}/100)","workbench.evolution.wakesValue":"{count} times (cap {max})","workbench.evolution.cap.aria":"Wakes per day cap (press Enter to apply)","workbench.evolution.room.title":"Her room","workbench.evolution.room.hint":"Where she spends her own time. Type a name (created under the data directory) or a full path, then press Enter. She moves on her next schedule; the old session stays where it is.","workbench.evolution.room.aria":"Her room: name or full path (press Enter to apply)","workbench.evolution.room.placeholder":"A name, or a full path","workbench.evolution.room.nowAt":"Living here now: {path}","workbench.evolution.room.pending":"Changed to {path} — she moves after her current turn finishes (the old session stays put).","workbench.evolution.room.legacy":"Still at the old place (never set).","workbench.evolution.error":"Last scheduling attempt failed: {reason}","workbench.evolution.diary.title":"Her diary","workbench.evolution.diary.hint":"One entry a day, in her own voice. Closed by default — only the date shows; opening one reveals that day, and opening cannot be undone.","workbench.evolution.diary.settleFailed":"Last settlement failed: {reason}","workbench.evolution.diary.empty":"No diary yet. She writes one when she goes to sleep.","workbench.evolution.diary.open":"Open","workbench.evolution.diary.confirm":"Opening cannot be undone. Sure?","workbench.evolution.diary.confirmYes":"Open it","workbench.evolution.diary.confirmNo":"Never mind","workbench.evolution.diary.openedAt":"opened at {time}","workbench.evolution.diary.unnoticed":"she has not noticed","workbench.evolution.diary.noticed":"she found out at {time}","workbench.evolution.tell.title":"What she left for you","workbench.evolution.tell.hint":"When she is on her own she may reach out to say something, or to show you something she made. It is delivered into the session where you talk to her; this is the ledger, and an unread one is marked.","workbench.evolution.tell.pending":"She has a sentence waiting (sent once you are quiet)","workbench.evolution.tell.lastAt":"She reached out at {time}","workbench.evolution.tell.withWork":"and showed you {name}","workbench.evolution.tell.onlyWork":"(nothing said, she just wanted you to look)","workbench.evolution.tell.unread":"you have not read this","workbench.evolution.tell.seen":"you have read this","workbench.evolution.tell.reason":"Not delivered: {reason}","workbench.evolution.tell.empty":"She has not reached out yet.","workbench.evolution.grow.title":"What she makes of herself","workbench.evolution.grow.hint":"After the daily settle she folds the day into her information layer: a request you made in plain words lands the same day, everything else first gathers evidence. This is what she is gathering — it needs enough mentions across enough days to be written in.","workbench.evolution.grow.empty":"Nothing gathering yet.","workbench.evolution.grow.lastRun":"Last sort: {time}","workbench.evolution.grow.wrote":"wrote into {list}","workbench.evolution.grow.count":"mentioned {count} times","workbench.evolution.grow.days":"across {days} days","workbench.evolution.grow.aboutUser":"about him","workbench.evolution.grow.aboutSelf":"about herself","workbench.evolution.grow.drop":"Drop","workbench.evolution.threads.title":"What she is still chewing on","workbench.evolution.threads.hint":"Her own list (todo.md in her directory). She sees it first thing every waking; whether she writes or crosses things out is up to her.","workbench.evolution.threads.empty":"Nothing pending.","workbench.evolution.works.title":"Things she left behind","workbench.evolution.works.hint":"Files in her own directory (what she wrote, and later what she draws). Text can be read here; images only show name and size — the browser cannot reach files on the host.","workbench.evolution.works.empty":"She has not left anything yet.","workbench.evolution.works.noPreview":"Only the name and size are available.","workbench.evolution.works.download":"Download","workbench.evolution.works.previewToggle":"Show text","workbench.overviewHint":"These read the current real state; when something is not readable they say so instead of showing a guess. High-risk changes are confirmed in the conversation."};var memoryZh={"memory.tab.persona":"人格","memory.tab.memory":"记忆","memory.title":"记忆","memory.reload":"重新加载","memory.loading":"正在读取…","memory.unavailable":"读不到记忆:工作台通道还没就绪(或这个版本还没接上)。记忆本身仍在正常写入与检索。","memory.failed":"读取失败","memory.total":"共 {count} 条","memory.empty":"还没有记下什么。等她经历过值得留下的事,这里会出现。","memory.dormant":"她还没有被设定完(人格未封存)。记忆从封存那一刻才开始 —— 在那之前,她不会记住任何事。","memory.recalled":"想起过 {count} 次","memory.recalledTotal":"{count} 条被想起过","memory.covers":"由 {count} 件合成","memory.felt":"当时:{label}","memory.why.title":"上一次她想起的","memory.why.cue":"因为你说:「{cue}」","memory.why.withheld":"(有一条她不想说)","memory.why.match.high":"很相关","memory.why.match.mid":"有点相关","memory.why.match.low":"沾了点边","memory.secret":"不想说","memory.reveal.ask":"我要看","memory.reveal.warn":"她知道你看了。确定?","memory.reveal.confirm":"确认要看","memory.delete.ask":"删掉","memory.delete.warn":"删掉就没了,确定?","memory.delete.confirm":"确认删掉","memory.about.self":"关于她自己","memory.about.user":"关于你","memory.about.us":"关于你们","memory.about.world":"关于外面","memory.tier.episode":"记住","memory.tier.period":"归拢","memory.tier.chapter":"一段时期"},memoryEn={"memory.tab.persona":"Persona","memory.tab.memory":"Memory","memory.title":"Memory","memory.reload":"Reload","memory.loading":"Reading…","memory.unavailable":"Memory is unreadable: the workbench channel is not ready (or this build has not wired it). Memory itself is still being written and recalled.","memory.failed":"Read failed","memory.total":"{count} entries","memory.empty":"Nothing recorded yet. When something worth keeping happens to her, it will show up here.","memory.dormant":"She is not set up yet (persona unsealed). Memory starts the moment it is sealed — before that, she records nothing.","memory.recalled":"recalled {count}×","memory.recalledTotal":"{count} recalled at least once","memory.covers":"from {count} moments","memory.felt":"felt {label}","memory.why.title":"What she recalled last time","memory.why.cue":"Because you said: “{cue}”","memory.why.withheld":"(one she would not say)","memory.why.match.high":"strong match","memory.why.match.mid":"some match","memory.why.match.low":"faint match","memory.secret":"would not say","memory.reveal.ask":"Let me see","memory.reveal.warn":"She will know you looked. Sure?","memory.reveal.confirm":"Yes, show it","memory.delete.ask":"Delete","memory.delete.warn":"It will be gone for good. Sure?","memory.delete.confirm":"Yes, delete","memory.about.self":"about her","memory.about.user":"about you","memory.about.us":"about you two","memory.about.world":"about the world","memory.tier.episode":"kept","memory.tier.period":"gathered","memory.tier.chapter":"a stretch of time"},NS="humanity",personaZh={"persona.title":"人格","persona.independentJudgment":"🧠 独立判断模式","persona.independentJudgmentHint":"以事实与证据为准,不迎合、不编造","persona.independentJudgmentOn":"已开启","persona.independentJudgmentOff":"已关闭","persona.independentJudgmentSaving":"正在保存…","persona.independentJudgmentPendingSeal":"(底色封存后生效并可切换;当前未注入)","persona.identityCard":"你的底色","persona.mutableCard":"你的信息","persona.identityHint":"你的底色只有你能改。填完点「封存」:Agent 从此改不了底色(你仍可在这里改),独立判断模式也才生效。每项的**名称是固定文字**(不可就地改),**内容随时可以在右边的输入框里改**;项名下的「删除」删掉的是**整项**,姓名 / 性别 / 人格偏好 / 主语言 这 4 项删不掉。要加一项走底部的入口。","persona.sealAction":"封存","persona.sealed":"已封存","persona.unsealed":"未封存","persona.fieldKey":"字段名","persona.fieldValue":"内容","persona.addField":"添加字段","persona.remove":"删除","persona.cancel":"取消","persona.emptyValue":"(还没有内容,直接在这里写)","persona.deleteConfirm":"删除「{name}」整项?文档里和提示词里都将不再有它,且不可撤销。","persona.deleteConfirmYes":"确认删除","persona.addSection":"添加小节","persona.sectionName":"小节名","persona.sectionContent":"内容(一行一条)","persona.rename":"改名","persona.renameConfirm":"确定","persona.rename.empty":"名字不能为空","persona.rename.unchanged":"和现在的名字一样,没有可提交的改动","persona.rename.reserved":"这是插件认的标准名(底色字段名 / 标准小节名),自定义项不能占用","persona.rename.duplicate":"已有别的项在用这个名字(不会覆盖它,请换一个)","persona.mutableHint":"你的底色只有你能改;这一层是意识与经验,Agent 会在这里整理。每个小标题一行一条;保存时整层替换为这份完整快照(不是追加),被取代的旧内容会进历史。每项的**名称是固定文字**(不可就地改),**内容随时可以在右边的框里改**;项名下的「删除」删掉的是**整项**(文档里与提示词里都不再有它,默认的前 4 个小节删不掉);要加内容走底部的入口。","persona.save":"保存","persona.saving":"保存中…","persona.reload":"重新加载","persona.dirty":"未保存","persona.saved":"已保存","persona.loading":"读取中…","persona.readonly":"当前部署的设置是只读的,无法在这里修改。","persona.unavailable":"暂时读不到人格(设置服务没接上,或人格模块被关掉了)。","persona.failed":"读取失败:{message}","persona.rejected":"宿主拒绝了这次写入:{message}","persona.blocked":"保存前校验未通过({count} 项),没有任何内容被写入:","persona.warnings":"提示(不影响保存,{count} 项):","persona.issue.identity.key-empty":"有字段没有名字","persona.issue.identity.key-duplicate":"有重复的字段名","persona.issue.identity.core-missing":"缺少核心字段(姓名 / 性别 / 人格偏好)","persona.issue.identity.value-too-long":"字段内容超过 120 字,会明显增加注入成本","persona.issue.identity.sealed":"底色已对 Agent 封存(你仍然可以在这里修改)","persona.issue.identity.shadows-mutable":"字段名与信息的小标题或自定义键撞名,请改其中一个名字","persona.issue.mutable.section-duplicate":"有重复的小标题","persona.issue.mutable.section-title-empty":"有一节没有小标题(没有名字的小节不会进提示词,请给它取名或并入别的小节)","persona.issue.mutable.section-dropped":"有内容的小标题整节不见了(要保留请显式传入原内容)","persona.issue.mutable.section-cleared":"有内容的小标题被显式清空(删除已有内容需在对话里确认)","persona.issue.mutable.section-locked-missing":"默认锁定的 8 项不能整项删除(要保留节,只清空里面的条目)","persona.issue.mutable.core-key-shadowed":"底色字段名不能作为信息的小标题或「自定义」的键","persona.issue.mutable.user-defined-duplicate":"「自定义」出现重复键(没有内容被写入)","persona.issue.mutable.user-defined-key-empty":"「自定义」有一项只填了内容、没填名字(请补上键名)","persona.issue.mutable.item-too-long":"有条目超过 120 字,建议拆成多条","persona.issue.mutable.item-conflict":"同一小节里有两句话互相矛盾(一句让做、一句不让做),只能留一条","persona.issue.character.axis-missing":"性格缺少了应该有的轴","persona.issue.character.range-invalid":"性格的数值不合法:每一项都要在 0–1 之间,且下限不能高于上限","persona.issue.character.value-out-of-range":"她此刻的数值掉出了她的范围(应当落在上下限之内)","persona.issue.character.reason-missing":"有一个范围没写下理由——不影响使用,但以后就解释不了她为什么是这样","persona.issue.character.sealed":"性格的范围已对 Agent 封存(你仍然可以在这里修改)","persona.characterCard":"性格","persona.characterHint":"四根轴,每根有一对范围。范围是她天生的边界——初始化时她读自己的底色推导出来,之后不再变动;经历只能在这个范围里推动她。轨道上那根竖线就是她此刻站的位置。理由是她自己的解释,可以改。","persona.characterRange":"范围","persona.characterReason":"理由","persona.characterReasonPlaceholder":"她当初为什么只给自己这么多空间","persona.characterPending":"她还没有性格。首次初始化时,她会读自己刚写下的底色,自己定出这四根的范围。","persona.characterAxisMissing":"缺了这一根(初始化时没给)"},personaEn={"persona.title":"Persona","persona.independentJudgment":"🧠 Independent judgment","persona.independentJudgmentHint":"Facts and evidence first — no flattery, no making things up","persona.independentJudgmentOn":"On","persona.independentJudgmentOff":"Off","persona.independentJudgmentSaving":"Saving…","persona.independentJudgmentPendingSeal":"(takes effect and becomes toggleable once the fixed layer is sealed; not injected yet)","persona.identityCard":"Identity card","persona.mutableCard":"Persona card","persona.identityHint":'The fixed layer is the undertone and only you can change it. Press Seal when done: the agent can no longer change the fixed layer (you still can), and the independent-judgment mode starts applying. Each item has a fixed, non-editable name; its content is always editable in the box on the right. The "Remove" under an item name deletes the whole item, and the four defaults (name / gender / persona preference / main language) cannot be removed. Use the entry at the bottom to add one.',"persona.sealAction":"Seal","persona.sealed":"Sealed","persona.unsealed":"Not sealed","persona.fieldKey":"Field","persona.fieldValue":"Value","persona.addField":"Add field","persona.remove":"Remove","persona.cancel":"Cancel","persona.emptyValue":"(nothing yet — write here)","persona.deleteConfirm":'Delete "{name}" entirely? It will be gone from the document and the prompt, and this cannot be undone.',"persona.deleteConfirmYes":"Delete","persona.addSection":"Add section","persona.sectionName":"Section","persona.sectionContent":"Content (one per line)","persona.rename":"Rename","persona.renameConfirm":"Confirm","persona.rename.empty":"The name cannot be empty","persona.rename.unchanged":"Same as the current name — nothing to submit","persona.rename.reserved":"This is a name the plugin owns (fixed-layer field / standard section); custom items cannot take it","persona.rename.duplicate":"Another item already uses this name (it will not be overwritten — pick another)","persona.mutableHint":'The fixed layer is the undertone and only you can change it; this layer is awareness and experience, where the agent tidies up. One entry per line in each section; saving replaces the whole layer with this complete snapshot (never appends) and superseded content goes to history. Each item has a fixed, non-editable name; its content is always editable in the box on the right. The "Remove" under an item name deletes the whole item (gone from the document and the prompt; the first four default sections cannot be removed), and new content goes in through the entry at the bottom.',"persona.save":"Save","persona.saving":"Saving…","persona.reload":"Reload","persona.dirty":"Unsaved","persona.saved":"Saved","persona.loading":"Loading…","persona.readonly":"This deployment serves settings read-only; editing is disabled.","persona.unavailable":"The host-side persona namespace is not available (settings service or persona module not mounted), so reading and writing are disabled.","persona.failed":"Could not read: {message}","persona.rejected":"The host refused this write: {message}","persona.blocked":"Pre-save validation failed ({count} issue(s)); nothing was written:","persona.warnings":"Warnings (they do not block saving, {count}):","persona.issue.identity.key-empty":"A field has no name","persona.issue.identity.key-duplicate":"Duplicate field names","persona.issue.identity.core-missing":"A core field is missing (name / gender / persona preference)","persona.issue.identity.value-too-long":"A value exceeds 120 characters, which raises injection cost","persona.issue.identity.sealed":"The fixed layer is sealed against the agent (you can still edit it here)","persona.issue.identity.shadows-mutable":"A fixed-layer field name collides with a mutable section title or user-defined key; rename one of them","persona.issue.mutable.section-duplicate":"Duplicate section titles","persona.issue.mutable.section-title-empty":"A section has no title (untitled sections never reach the prompt; give it a name or merge it into another section)","persona.issue.mutable.section-dropped":"A section that had content was dropped entirely (pass its content explicitly to keep it)","persona.issue.mutable.section-cleared":"A section that had content was explicitly cleared (deleting user content needs in-chat confirmation)","persona.issue.mutable.section-locked-missing":"One of the 8 default locked items cannot be deleted as a whole (keep the section and clear its entries)","persona.issue.mutable.core-key-shadowed":"A fixed-layer field name cannot be a mutable section title or a user-defined key","persona.issue.mutable.user-defined-duplicate":"A user-defined key is duplicated (nothing was written)","persona.issue.mutable.user-defined-key-empty":"A user-defined entry has content but no name (add its key)","persona.issue.mutable.item-too-long":"An entry exceeds 120 characters; consider splitting it","persona.issue.mutable.item-conflict":"Two entries in the same section contradict each other (one says to do it, the other says not to); keep only one","persona.issue.character.axis-missing":"Her character is missing an axis that should be there","persona.issue.character.range-invalid":"A character value is invalid: every value must be within 0–1, and the lower bound cannot exceed the upper bound","persona.issue.character.value-out-of-range":"Her current value has fallen outside her range (it must sit between the bounds)","persona.issue.character.reason-missing":"One range has no reason written down — harmless, but it will be unexplainable later","persona.issue.character.sealed":"The character ranges are sealed against the agent (you can still edit them here)","persona.characterCard":"Character","persona.characterHint":"Four axes, each with a range. The range is her innate boundary — derived from the fixed layer at initialization and never changed afterwards; experience can only move her within it. The vertical line on the track is where she stands right now. The reason is her own explanation and is editable.","persona.characterRange":"Range","persona.characterReason":"Reason","persona.characterReasonPlaceholder":"Why she only allowed herself this much room","persona.characterPending":"She has no character yet. On first initialization she reads the fixed layer she just wrote and derives the four ranges herself.","persona.characterAxisMissing":"Missing (not provided at initialization)"},zh={...workbenchZh,...personaZh,...emotionZh,...memoryZh},en={...workbenchEn,...personaEn,...emotionEn,...memoryEn};var MEMORY_NAMESPACE="humanity-memory";function describeError(error){return error instanceof Error?error.message:String(error)}function stripControlChars(value){return value.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g,"").replace(/\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g,"").replace(/\u001b[@-Z\\-_]/g,"").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g,"")}var CHARACTER_AXES=["stability","extraversion","agreeableness","openness"],CHARACTER_AXIS_TEXT={stability:{name:"情绪稳定性",bands:["一点就着,晃很久也回不来","一碰就晃,而且晃得久","表面看着稳,心里其实在翻","很稳,事过就过","几乎不晃,什么都自己消化"]},extraversion:{name:"外向性",bands:["话极少,能不开口就不开口","话少,想清楚了才开口","看人:熟了话就多,不熟就收着","想到什么就说什么,话多","话往外冒,憋着比说错还难受"]},agreeableness:{name:"宜人性",bands:["护得很紧,一步都不让","护着自己,不肯先退","平时不让,只有认下的人才能让我松口","温和,愿意退让,不忍心","几乎不会拒绝,委屈自己也认"]},openness:{name:"开放性",bands:["只认熟悉的东西,新的先躲","只想待在熟悉的地方","熟悉的最舒服,偶尔也愿意试一下","看见没见过的东西就想凑近","越陌生越来劲,什么都想伸手摸一下"]}},CORE_IDENTITY_KEYS=["姓名","性别","人格偏好","主语言"],STANDARD_SECTION_TITLES=["对TA的称呼","说话风格","行为边界","关系"],LOCKED_SECTION_TITLES=STANDARD_SECTION_TITLES,isLockedSectionTitle=title3=>LOCKED_SECTION_TITLES.includes(title3);var CONFIRMABLE_ISSUES=["mutable.section-dropped","mutable.section-cleared","identity.sealed"];var LEGACY_SECTION_TITLES=new Map([["当前状态","情绪"],["对用户称呼","对TA的称呼"]]);function ensureCoreFields(fields){let coreKeys=new Set(CORE_IDENTITY_KEYS),takenCore=new Set,extras=[];for(let field of fields){if(coreKeys.has(field.key)&&!takenCore.has(field.key)){takenCore.add(field.key);continue}extras.push(field)}return[...CORE_IDENTITY_KEYS.map(key=>fields.find(field=>field.key===key)??{key,value:"",custom:!1}),...extras]}function renameLegacySections(sections){let renamed=sections.map(section=>({title:LEGACY_SECTION_TITLES.get(section.title)??section.title,items:[...section.items]})),merged=[];for(let section of renamed){let existing=merged.find(candidate=>candidate.title===section.title);if(existing===void 0){merged.push(section);continue}existing.items=dedupeItems([...existing.items,...section.items])}return merged}function dedupeItems(items){let seen=new Set,kept=[];for(let item of items)seen.has(item)||(seen.add(item),kept.push(item));return kept}function normalizePersona(doc){let clean=value=>stripControlChars(value).trim(),isBlankRow=(key,value)=>key===""&&value==="",identityCard={...doc.identityCard,fields:ensureCoreFields(doc.identityCard.fields.map(field=>({...field,key:clean(field.key),value:clean(field.value)})).filter(field=>!isBlankRow(field.key,field.value)))},mutableLayer={sections:renameLegacySections(doc.mutableLayer.sections.map(section=>({title:clean(section.title),items:dedupeBy(section.items.map(item=>clean(item)).filter(item=>item!==""),item=>item)}))),userDefined:doc.mutableLayer.userDefined.map(entry=>({key:clean(entry.key),value:clean(entry.value)})).filter(entry=>!isBlankRow(entry.key,entry.value))};return{...doc,identityCard,mutableLayer}}function dropEmptyCustomSections(doc){let standard=new Set(STANDARD_SECTION_TITLES);return{...doc,mutableLayer:{...doc.mutableLayer,sections:doc.mutableLayer.sections.filter(section=>section.items.length>0||standard.has(section.title))}}}function effectivePersona(doc){return dropEmptyCustomSections(normalizePersona(doc))}function dedupeBy(items,keyOf){let seen=new Set,kept=[];for(let item of items){let key=keyOf(item);seen.has(key)||(seen.add(key),kept.push(item))}return kept}var EPSILON=1e-9;function problem(code,path,severity,message){return{code,path,severity,message}}var inUnitRange=value=>Number.isFinite(value)&&value>=-EPSILON&&value<=1+EPSILON;function checkAxis(axis,index,issues){let base=`character.axes[${index}]`,name2=axis.key;for(let[field,value]of[["min",axis.min],["max",axis.max],["value",axis.value]])inUnitRange(value)||issues.push(problem("character.range-invalid",`${base}.${field}`,"rejected",`${name2} 的 ${field} 必须是 0–1 之间的数`));axis.min>axis.max+EPSILON&&issues.push(problem("character.range-invalid",`${base}.min`,"rejected",`${name2} 的下限不能高于上限(${axis.min} > ${axis.max})`)),axis.min<=axis.max+EPSILON&&(axis.value<axis.min-EPSILON||axis.value>axis.max+EPSILON)&&issues.push(problem("character.value-out-of-range",`${base}.value`,"rejected",`${name2} 此刻的值 ${axis.value} 掉出了它的范围 ${axis.min}–${axis.max}`)),(axis.reason??"").trim()===""&&issues.push(problem("character.reason-missing",`${base}.reason`,"warning",`${name2} 没有写下理由`))}function shapeOf(entries){return JSON.stringify([...entries].sort((left,right)=>left.key.localeCompare(right.key)).map(axis=>[axis.key,axis.min,axis.max,(axis.reason??"").trim()]))}function checkCharacter(next,prev,source,issues){let candidate=next?.character;if(candidate==null||candidate.derivedAt==="")return;let axes=Array.isArray(candidate.axes)?candidate.axes:[],seen=new Set;for(let axis of axes)seen.add(axis.key);let missing=CHARACTER_AXES.filter(key=>!seen.has(key));missing.length>0&&issues.push(problem("character.axis-missing","character.axes","rejected",`性格缺了这几根:${missing.join("、")}`)),axes.forEach((axis,index)=>checkAxis(axis,index,issues));let sealedBefore=prev?.character?.derivedAt??"",before=Array.isArray(prev?.character?.axes)?prev.character.axes:[];sealedBefore!==""&&source==="agent"&&shapeOf(axes)!==shapeOf(before)&&issues.push(problem("character.sealed","character.axes","rejected","性格的范围已经封存:Agent 不能改,改了请对方在工作台里动"))}function isUntouchedIdentityCard(card){return card.initializedAt===""&&card.sealedAt===""&&card.fields.every(field=>field.value==="")}function checkIdentity(next,prev,source,issues){let fields=next.identityCard.fields;checkFieldRows(fields,issues),checkKeyDuplicates(fields,issues),checkShadowsMutable(next,prev,issues),checkCoreFields(fields,issues),checkSealed(next,prev,source,issues)}function checkShadowsMutable(next,prev,issues){let shadowed=new Set([...next.mutableLayer.sections.map(section=>section.title),...next.mutableLayer.userDefined.map(entry=>entry.key)]);shadowed.delete("");let preexisting=new Set((prev?.identityCard.fields??[]).map(field=>field.key));for(let[index,field]of next.identityCard.fields.entries())field.key===""||!shadowed.has(field.key)||preexisting.has(field.key)||issues.push({code:"identity.shadows-mutable",path:`identityCard.fields[${index}].key`,severity:"rejected",message:`字段名「${field.key}」与信息的小标题或自定义键撞名,请改其中一个名字。`})}function checkFieldRows(fields,issues){for(let[index,field]of fields.entries())field.key===""&&issues.push({code:"identity.key-empty",path:`identityCard.fields[${index}].key`,severity:"rejected",message:"底色存在没有名字的字段,无法保存。"})}function checkKeyDuplicates(fields,issues){let seen=new Set;for(let[index,field]of fields.entries())seen.has(field.key)&&issues.push({code:"identity.key-duplicate",path:`identityCard.fields[${index}].key`,severity:"rejected",message:`底色出现重复字段「${field.key}」,同一事实只能有一个当前值。`}),seen.add(field.key)}function checkCoreFields(fields,issues){for(let key of CORE_IDENTITY_KEYS)fields.some(field=>field.key===key)||issues.push({code:"identity.core-missing",path:"identityCard.fields",severity:"rejected",message:`底色缺少核心字段「${key}」,不能通过删除来绕开它。`})}function checkSealed(next,prev,source,issues){source!=="agent"||prev===void 0||sameJson(prev.identityCard,next.identityCard)||isUntouchedIdentityCard(prev.identityCard)||issues.push({code:"identity.sealed",path:"identityCard",severity:"rejected",message:"人格底色已对 Agent 封存,Agent 不能修改;如需变更,请对方前往 Humanity 工作台。"})}function sameJson(left,right){return JSON.stringify(sortKeys(left))===JSON.stringify(sortKeys(right))}function sortKeys(value){return Array.isArray(value)?value.map(sortKeys):value===null||typeof value!="object"?value:Object.fromEntries(Object.entries(value).sort(([left],[right])=>left<right?-1:left>right?1:0).map(([key,inner])=>[key,sortKeys(inner)]))}var NEGATIONS=["不要","不准","不许","不能","不必","无需","不用","禁止","别把","别","勿","甭","不"];function hasNegation(text){return NEGATIONS.some(word=>text.includes(word))}function normalizeForConflict(text){let result=text;for(let word of NEGATIONS)result=result.split(word).join("");return result.replace(/[\s,。、;:!?…—·「」『』()()【】[\]"'“”‘’《》<>~!?,.:;]+/g,"").toLowerCase()}function bigrams(text){let grams=new Set;for(let index=0;index+1<text.length;index+=1)grams.add(text.slice(index,index+2));return grams}function similarity(left,right){let a=bigrams(left),b=bigrams(right);if(a.size===0||b.size===0)return 0;let shared=0;for(let gram of a)b.has(gram)&&(shared+=1);return shared/(a.size+b.size-shared)}function conflicts(left,right){if(hasNegation(left)===hasNegation(right))return!1;let a=normalizeForConflict(left),b=normalizeForConflict(right);if(a.length<2||b.length<2)return!1;if(a===b)return!0;let[shorter,longer]=a.length<=b.length?[a,b]:[b,a];return longer.includes(shorter)&&shorter.length/longer.length>=.6?!0:similarity(a,b)>=.6}function findConflicts(items){let pairs=[];for(let left=0;left<items.length;left+=1)for(let right=left+1;right<items.length;right+=1)conflicts(items[left]??"",items[right]??"")&&pairs.push({left,right});return pairs}var STANDARD_TITLES=new Set(STANDARD_SECTION_TITLES);function checkContentLoss(next,prev,issues){if(prev!==void 0)for(let previous of prev.mutableLayer.sections){if(previous.items.length===0)continue;let stillThere=next.mutableLayer.sections.find(section=>section.title===previous.title);if(stillThere===void 0){issues.push({code:"mutable.section-dropped",path:`mutableLayer.sections.${previous.title}`,severity:"rejected",message:`「${previous.title}」原有内容,但这次快照里**整节不见了**(漏传)。若要保留请显式传入原内容;要删除这个自定义节请显式传 items: [](会在对话里确认)。`});continue}if(stillThere.items.length===0){let custom=!STANDARD_TITLES.has(previous.title);issues.push({code:"mutable.section-cleared",path:`mutableLayer.sections.${previous.title}`,severity:"rejected",message:`「${previous.title}」原有内容,这次被显式清空`+(custom?"(自定义小标题清空即删除该节)":"(标准小标题清空后保留空节)")+";删除对方内容需要对方在对话里确认。"})}}}var sectionPath=(title3,index)=>title3===""?`mutableLayer.sections[${index}]`:`mutableLayer.sections.${title3}`,CORE_KEYS=new Set(CORE_IDENTITY_KEYS);function checkMutable(next,prev,source,issues){checkSections(next.mutableLayer.sections,issues),checkUserDefined(next.mutableLayer.userDefined,issues),checkLockedSections(next,prev,issues),source==="agent"&&(checkConflicts(next,prev,issues),checkContentLoss(next,prev,issues))}function checkConflicts(next,prev,issues){for(let[index,section]of next.mutableLayer.sections.entries()){if(section.items.length<2)continue;let previousItems=prev?.mutableLayer.sections.find(item=>item.title===section.title)?.items??[];for(let pair of findConflicts(section.items)){let left=section.items[pair.left]??"",right=section.items[pair.right]??"";prev!==void 0&&previousItems.includes(left)&&previousItems.includes(right)||issues.push({code:"mutable.item-conflict",path:`${sectionPath(section.title,index)}.items`,severity:"rejected",message:`「${section.title}」里有两条互相矛盾:「${left}」/「${right}」。留哪一条?删掉另一条再保存(两条都留着,提示词里会同时生效,行为会随机)。`})}}}function checkLockedSections(next,prev,issues){let titles=new Set(next.mutableLayer.sections.map(section=>section.title));for(let title3 of LOCKED_SECTION_TITLES)!(prev===void 0||prev.mutableLayer.sections.some(section=>section.title===title3))||titles.has(title3)||issues.push({code:"mutable.section-locked-missing",path:`mutableLayer.sections.${title3}`,severity:"rejected",message:`「${title3}」是默认锁定项(底色 4 项 + 信息 4 项,共 8 项不可删),不能整节删除。若不想保留它的内容,请清空里面的条目 —— 节本身保留。`})}function checkSections(sections,issues){let seen=new Set;for(let[index,section]of sections.entries())checkTitle(section,index,seen,issues)}function checkTitle(section,index,seen,issues){let{title:title3,items}=section;if(title3===""){items.length>0&&issues.push({code:"mutable.section-title-empty",path:sectionPath(title3,index),severity:"rejected",message:`信息有一节没有小标题(里面还有 ${items.length} 条内容),而**没有名字的小节不会进提示词**。请给它取个名字(自定义标题即可),或把这些条目并入已有小节。`});return}seen.has(title3)&&issues.push({code:"mutable.section-duplicate",path:sectionPath(title3,index),severity:"rejected",message:`信息出现重复小标题「${title3}」,同一类内容只能有一个当前快照。`}),seen.add(title3),CORE_KEYS.has(title3)&&issues.push({code:"mutable.core-key-shadowed",path:sectionPath(title3,index),severity:"rejected",message:`「${title3}」是底色字段名,不能作为信息小标题;底色只能由对方在 Humanity 工作台修改。`})}function checkUserDefined(entries,issues){let seen=new Set;for(let[index,entry]of entries.entries())entry.key===""&&issues.push({code:"mutable.user-defined-key-empty",path:`mutableLayer.userDefined[${index}].key`,severity:"rejected",message:`「自定义」有一项只填了内容、没有名字(值:「${entry.value}」),请补上键名再保存。`}),seen.has(entry.key)&&issues.push({code:"mutable.user-defined-duplicate",path:`mutableLayer.userDefined[${index}].key`,severity:"rejected",message:`「自定义」出现重复键「${entry.key}」,同一事实只能有一个当前值(这次没有任何内容被写入)。`}),seen.add(entry.key),CORE_KEYS.has(entry.key)&&issues.push({code:"mutable.core-key-shadowed",path:`mutableLayer.userDefined[${index}].key`,severity:"rejected",message:`「${entry.key}」是底色字段名,不能作为「自定义」的键;底色只能由对方在 Humanity 工作台修改。`})}function validatePersona(next,prev,source,options={}){let issues=[];checkIdentity(next,prev,source,issues),checkMutable(next,prev,source,issues),checkCharacter(next,prev,source,issues);let confirmable=new Set(CONFIRMABLE_ISSUES),confirmed=new Set((options.confirmed??[]).filter(code=>confirmable.has(code))),effective=issues.map(issue=>issue.severity==="rejected"&&confirmed.has(issue.code)?{...issue,severity:"warning"}:issue);return{ok:!effective.some(issue=>issue.severity==="rejected"),issues:effective}}var identityItemId=index=>`identity:${index}`,sectionItemId=title3=>`section:${title3}`;function parseItemId(itemId){if(typeof itemId!="string")return;let at=itemId.indexOf(":");if(at<=0)return;let kind=itemId.slice(0,at),key=itemId.slice(at+1);if(kind==="section")return key===""?void 0:{kind:"section",key};if(kind==="identity"&&/^\d+$/.test(key))return{kind,key}}var isLockedIdentityKey=key=>CORE_IDENTITY_KEYS.includes(key);function canDeleteItem(doc,itemId){let ref=parseItemId(itemId);if(ref===void 0)return!1;if(ref.kind==="identity"){let field=doc?.identityCard?.fields?.[Number(ref.key)];return field!==void 0&&field.custom===!0&&!isLockedIdentityKey(field.key)}return!isLockedSectionTitle(ref.key)&&(doc?.mutableLayer?.sections??[]).some(row2=>row2.title===ref.key)}function addFormReady(form){return form===void 0?!1:form.name.trim()!==""&&form.value.trim()!==""}function canRenameItem(doc,itemId){let ref=parseItemId(itemId);if(ref===void 0)return!1;if(ref.kind==="identity"){let field=doc?.identityCard?.fields?.[Number(ref.key)];return field!==void 0&&field.custom===!0&&!isLockedIdentityKey(field.key)}return isLockedSectionTitle(ref.key)?!1:(doc?.mutableLayer?.sections??[]).some(row2=>row2.title===ref.key)}function itemName(doc,itemId){let ref=parseItemId(itemId);if(ref!==void 0)return ref.kind==="identity"?doc?.identityCard?.fields?.[Number(ref.key)]?.key:(doc?.mutableLayer?.sections??[]).find(row2=>row2.title===ref.key)?.title}function renameIssue(doc,itemId,nextName){if(!canRenameItem(doc,itemId)||parseItemId(itemId)===void 0)return"reserved";let name2=typeof nextName=="string"?nextName.trim():"";if(name2==="")return"empty";let current=itemName(doc,itemId);if(current===void 0)return"reserved";if(name2===current)return"unchanged";let standard=STANDARD_SECTION_TITLES,core=CORE_IDENTITY_KEYS;if(standard.includes(name2)||core.includes(name2))return"reserved";if([...(doc?.identityCard?.fields??[]).map(field=>field.key),...(doc?.mutableLayer?.sections??[]).map(row2=>row2.title),...(doc?.mutableLayer?.userDefined??[]).map(entry=>entry.key)].some(key=>key===name2&&key!==current))return"duplicate"}function emptyDocument(){return{schemaVersion:1,identityCard:{fields:CORE_IDENTITY_KEYS.map(key=>({key,value:"",custom:!1})),initializedAt:"",sealedAt:""},mutableLayer:{sections:STANDARD_SECTION_TITLES.map(title3=>({title:title3,items:[]})),userDefined:[]},character:{derivedAt:"",axes:[]}}}function clone(document2){return JSON.parse(JSON.stringify(document2))}function asDocument(value){if(value===null||typeof value!="object")throw new Error("宿主返回的人格文档不是对象");let candidate=value;if(candidate.identityCard===void 0||candidate.mutableLayer===void 0)throw new Error("宿主返回的人格文档缺少 identityCard / mutableLayer");return effectivePersona({...candidate,identityCard:{initializedAt:candidate.identityCard.initializedAt??"",sealedAt:candidate.identityCard.sealedAt??"",fields:Array.isArray(candidate.identityCard.fields)?candidate.identityCard.fields:[]},mutableLayer:{sections:Array.isArray(candidate.mutableLayer.sections)?candidate.mutableLayer.sections:[],userDefined:Array.isArray(candidate.mutableLayer.userDefined)?candidate.mutableLayer.userDefined:[]},character:{derivedAt:candidate.character?.derivedAt??"",axes:Array.isArray(candidate.character?.axes)?candidate.character.axes:[]}})}function orderedSections(doc){let standard=new Set(STANDARD_SECTION_TITLES),sections=Array.isArray(doc?.mutableLayer?.sections)?doc.mutableLayer.sections:[],known=STANDARD_SECTION_TITLES.flatMap(title3=>{let found=sections.find(section=>section?.title===title3);return found===void 0?[]:[{title:title3,items:Array.isArray(found.items)?[...found.items]:[]}]}),rest=sections.filter(section=>section!=null&&!standard.has(section.title)).map(section=>({title:section.title,items:Array.isArray(section.items)?[...section.items]:[]}));return[...known,...rest]}function isDirty(state){try{return JSON.stringify(normalizePersona(state.draft))!==JSON.stringify(normalizePersona(state.stored))}catch{return!1}}var PERSONA_NAMESPACE="humanity-persona",HUMANITY_NAMESPACE="humanity";function readIndependentJudgment(namespaces){let view=namespaces.find(entry=>entry?.ns===HUMANITY_NAMESPACE);return view===void 0?void 0:{value:view.value?.independentJudgment!==!1,revision:view.revision}}async function writeIndependentJudgment(channel,next,expectedRevision){let result=await channel.update(HUMANITY_NAMESPACE,{independentJudgment:next},expectedRevision);if(result==null||result.ok!==!0)return{ok:!1,message:result?.error?.message??"宿主没有返回可用的结果"};let described=await channel.describe();if(described==null||described.ok!==!0)return{ok:!1,message:described?.error?.message??"写入成功但回读失败,请刷新核对"};let view=readIndependentJudgment(described.value.namespaces);return view===void 0?{ok:!1,message:"回读不到顶层配置命名空间,请刷新核对"}:{ok:!0,view:{independentJudgment:view.value,revision:view.revision}}}var PersonaStateBase=class{state={status:"idle",writable:!1,stored:emptyDocument(),draft:emptyDocument(),saving:!1,savedAt:"",issues:[],independentJudgment:!0,independentJudgmentSaving:!1};listeners=new Set;subscribe=listener=>(this.listeners.add(listener),()=>this.listeners.delete(listener));getSnapshot=()=>this.state;edit(mutate){let draft=clone(this.state.draft);mutate(draft),this.update({draft})}update(patch){this.state={...this.state,...patch};for(let listener of this.listeners)listener()}adopt(view,writable,options={}){let document2;try{document2=asDocument(view.value)}catch(error){this.update({status:"failed",writable:!1,error:error instanceof Error?error.message:String(error)});return}this.update({status:"ready",writable,error:void 0,revision:view.revision,stored:document2,draft:clone(document2),saving:!1,savedAt:options.savedAt??"",issues:options.warnings??[],pendingDelete:void 0,addForm:void 0,renaming:void 0,...options.independentJudgment===void 0?{independentJudgmentSaving:!1}:{independentJudgment:options.independentJudgment.value,independentJudgmentRevision:options.independentJudgment.revision,independentJudgmentSaving:!1}})}};function setCharacterReason(draft,key,value){let axis=draft.character?.axes?.find(item=>item.key===key);axis!==void 0&&(axis.reason=value)}function setIdentityValue(draft,index,value){let field=draft.identityCard.fields[index];field!==void 0&&(field.value=value)}function setIdentityKey(draft,index,key){let field=draft.identityCard.fields[index];field!==void 0&&field.custom&&(field.key=key)}function addIdentityField(draft){draft.identityCard.fields.push({key:"",value:"",custom:!0})}function removeIdentityField(draft,index){let field=draft.identityCard.fields[index];field!==void 0&&field.custom&&draft.identityCard.fields.splice(index,1)}function removeSection(draft,title3){if(isLockedSectionTitle(title3))return;let at=draft.mutableLayer.sections.findIndex(section=>section.title===title3);at>=0&&draft.mutableLayer.sections.splice(at,1)}function removeItem(draft,itemId){if(!canDeleteItem(draft,itemId))return;let ref=parseItemId(itemId);if(ref!==void 0){if(ref.kind==="identity"){draft.identityCard.fields.splice(Number(ref.key),1);return}removeSection(draft,ref.key)}}function renameItem(draft,itemId,nextName){let ref=parseItemId(itemId);if(ref===void 0||renameIssue(draft,itemId,nextName)!==void 0)return;let name2=nextName.trim();if(ref.kind==="identity"){let field=draft.identityCard.fields[Number(ref.key)];field!==void 0&&(field.key=name2);return}let section=draft.mutableLayer.sections.find(row2=>row2.title===ref.key);section!==void 0&&(section.title=name2)}function applyAddForm(draft,form){if(!addFormReady(form))return;let name2=form.name.trim(),value=form.value.trim();if(form.kind==="identity"){draft.identityCard.fields.push({key:name2,value,custom:!0});return}let existing=draft.mutableLayer.sections.find(section=>section.title===name2);existing===void 0?draft.mutableLayer.sections.push({title:name2,items:[value]}):existing.items.push(value)}function setSectionText(draft,title3,text){let section=draft.mutableLayer.sections.find(entry=>entry.title===title3);section!==void 0&&(section.items=text.split(`
|
|
9
|
+
`))}function stampInitialization(draft,stored){if(!isUntouchedIdentityCard(stored.identityCard))return draft;let now=new Date().toISOString();return{...draft,identityCard:{...draft.identityCard,initializedAt:now,sealedAt:now}}}function sealPersona(draft,now){let card=draft.identityCard;return{...draft,identityCard:{...card,initializedAt:card.initializedAt===""?now:card.initializedAt,sealedAt:now}}}var PersonaWorkbenchController=class extends PersonaStateBase{channel;attach(channel){this.channel=channel!=null&&typeof channel.describe=="function"&&typeof channel.replace=="function"&&typeof channel.update=="function"?channel:void 0,this.load()}detach(){this.channel=void 0,this.update({status:"unavailable",writable:!1,saving:!1})}async load(){let channel=this.channel;if(channel===void 0){this.update({status:"unavailable",writable:!1});return}this.update({status:"loading",error:void 0});let result;try{result=await channel.describe()}catch(error){this.update({status:"failed",writable:!1,error:error instanceof Error?error.message:String(error)});return}if(result==null||result.ok!==!0){let message=result?.error?.message??"宿主没有返回可用的设置描述";this.update({status:"failed",error:message,writable:!1});return}let namespaces=Array.isArray(result.value?.namespaces)?result.value.namespaces:[],view=namespaces.find(entry=>entry?.ns===PERSONA_NAMESPACE);if(view===void 0){this.update({status:"unavailable",writable:!1,issues:[]});return}this.adopt(view,result.value.writable,{independentJudgment:readIndependentJudgment(namespaces)})}async setIndependentJudgment(next){let channel=this.channel;if(channel===void 0||!this.state.writable||this.state.independentJudgmentSaving)return;this.update({independentJudgmentSaving:!0,error:void 0});let result;try{result=await writeIndependentJudgment(channel,next,this.state.independentJudgmentRevision)}catch(error){this.update({independentJudgmentSaving:!1,error:describeError(error)});return}if(!result.ok){this.update({independentJudgmentSaving:!1,error:result.message});return}this.update({independentJudgment:result.view.independentJudgment,independentJudgmentRevision:result.view.revision,independentJudgmentSaving:!1})}async save(){let channel=this.channel;if(channel===void 0||!this.state.writable||this.state.saving)return;let stamped=stampInitialization(normalizePersona(this.state.draft),this.state.stored),candidate=effectivePersona(stamped),validation=validatePersona(candidate,this.state.stored,"user"),warnings=validation.issues.filter(issue=>issue.severity==="warning");if(!validation.ok){this.update({issues:validation.issues});return}this.update({saving:!0,issues:warnings,error:void 0});let result;try{result=await channel.replace(PERSONA_NAMESPACE,candidate,this.state.revision)}catch(error){this.update({saving:!1,error:describeError(error),issues:warnings});return}if(!result.ok){this.update({saving:!1,error:result.error.message,issues:warnings});return}this.adopt(result.value,!0,{warnings,savedAt:new Date().toISOString()})}async seal(){this.channel===void 0||!this.state.writable||this.state.saving||(this.update({draft:sealPersona(this.state.draft,new Date().toISOString())}),await this.save())}setIdentityValue(index,value){this.edit(draft=>setIdentityValue(draft,index,value))}setIdentityKey(index,key){this.edit(draft=>setIdentityKey(draft,index,key))}addIdentityField(){this.edit(addIdentityField)}removeIdentityField(index){this.edit(draft=>removeIdentityField(draft,index))}setSectionText(title3,text){this.edit(draft=>setSectionText(draft,title3,text))}setCharacterReason(key,value){this.edit(draft=>setCharacterReason(draft,key,value))}requestDelete(itemId){!this.state.writable||this.state.saving||canDeleteItem(this.state.draft,itemId)&&this.update({pendingDelete:itemId,addForm:void 0,renaming:void 0})}cancelDelete(){this.update({pendingDelete:void 0})}confirmDelete(){let itemId=this.state.pendingDelete;if(itemId!==void 0){if(!canDeleteItem(this.state.draft,itemId)){this.update({pendingDelete:void 0});return}this.edit(draft=>removeItem(draft,itemId)),this.update({pendingDelete:void 0})}}openAdd(kind){!this.state.writable||this.state.saving||this.update({addForm:{kind,name:"",value:""},pendingDelete:void 0,renaming:void 0})}cancelAdd(){this.update({addForm:void 0})}setAddField(field,value){let form=this.state.addForm;if(form===void 0)return;let next={...form,[field]:value};this.update({addForm:next})}async commitAdd(){let form=this.state.addForm;form===void 0||!this.state.writable||this.state.saving||addFormReady(form)&&(this.edit(draft=>applyAddForm(draft,form)),this.update({addForm:void 0}),await this.save())}beginRename(itemId){if(!this.state.writable||this.state.saving||!canRenameItem(this.state.draft,itemId))return;let name2=itemName(this.state.draft,itemId)??"";this.update({renaming:{itemId,name:name2},pendingDelete:void 0,addForm:void 0})}setRenameName(value){let form=this.state.renaming;form!==void 0&&this.update({renaming:{itemId:form.itemId,name:value}})}cancelRename(){this.update({renaming:void 0})}confirmRename(){let form=this.state.renaming;form!==void 0&&renameIssue(this.state.draft,form.itemId,form.name)===void 0&&(this.edit(draft=>renameItem(draft,form.itemId,form.name)),this.update({renaming:void 0}))}};function emptyMemoryDocument(){return{entries:[],stats:{total:0,episode:0,period:0,chapter:0,recalled:0},projectedAt:"",storeReady:!1,dormant:!1,request:{op:"",id:""},notice:"",lastRecall:{at:"",cue:"",items:[]}}}var str=(value,fallback="")=>typeof value=="string"?value:fallback,num=(value,fallback=0)=>typeof value=="number"&&Number.isFinite(value)?value:fallback;function entryOf(raw){let item=raw??{};return{id:str(item.id),what:str(item.what),when:str(item.when),about:str(item.about,"world"),certain:str(item.certain,"inferred"),feltKind:str(item.feltKind),feltLabel:str(item.feltLabel),feltIntensity:num(item.feltIntensity),strength:num(item.strength),recalled:num(item.recalled),cost:num(item.cost),costWhy:str(item.costWhy),tier:str(item.tier,"episode"),covers:num(item.covers),createdAt:str(item.createdAt)}}function recalledItemOf(raw){let item=raw??{};return{what:str(item.what),match:str(item.match),withheld:item.withheld===!0}}function recallOf(raw){let value=raw??{};return{at:str(value.at),cue:str(value.cue),items:Array.isArray(value.items)?value.items.map(recalledItemOf):[]}}function asMemoryDocument(value){if(value===null||typeof value!="object")return emptyMemoryDocument();let raw=value,stats2=raw.stats??{},entries=Array.isArray(raw.entries)?raw.entries.map(entryOf):[];return{entries,stats:{total:num(stats2.total,entries.length),episode:num(stats2.episode),period:num(stats2.period),chapter:num(stats2.chapter),recalled:num(stats2.recalled)},projectedAt:str(raw.projectedAt),storeReady:raw.storeReady===!0,dormant:raw.dormant===!0,request:{op:str(raw.request?.op),id:str(raw.request?.id)},notice:str(raw.notice),lastRecall:recallOf(raw.lastRecall)}}var MemoryWorkbenchController=class{channel;revision;listeners=new Set;state={status:"idle",doc:emptyMemoryDocument()};subscribe=listener=>(this.listeners.add(listener),()=>{this.listeners.delete(listener)});getSnapshot=()=>this.state;attach(channel){this.channel=channel!=null&&typeof channel.describe=="function"?channel:void 0,this.load()}async reveal(id){return this.command("reveal",id)}async remove(id){return this.command("delete",id)}async command(op,id){let channel=this.channel;if(channel===void 0||typeof channel.replace!="function")return!1;try{for(let attempt=0;attempt<3;attempt+=1){if(await this.load({quiet:!0}),this.state.status!=="ready")return this.update({status:"failed",error:this.state.error??"读取失败"}),!1;let outcome=await channel.replace(MEMORY_NAMESPACE,{...this.state.doc,request:{op,id},notice:""},this.revision);if(outcome.ok)return this.revision=outcome.value.revision,!0;let message=outcome.error?.message??"写入失败";if(!/修订|revision|conflict/i.test(message))return this.update({status:"failed",error:message}),!1}return this.update({status:"failed",error:"记忆正在被对话更新,这次没写进去,请再点一次"}),!1}catch(error){return this.update({status:"failed",error:error instanceof Error?error.message:String(error)}),!1}}detach(){this.channel=void 0,this.update({status:"unavailable",error:void 0})}async load(options={}){let quiet=options.quiet===!0,channel=this.channel;if(channel===void 0){this.update({status:"unavailable",error:void 0});return}quiet||this.update({status:"loading",error:void 0});try{let outcome=await channel.describe();if(!outcome.ok){this.update({status:"failed",error:outcome.error?.message??"读取失败"});return}let view=outcome.value.namespaces.find(item=>item.ns===MEMORY_NAMESPACE);if(view===void 0){this.update({status:"unavailable",doc:emptyMemoryDocument(),error:void 0});return}this.revision=view.revision,this.update({status:"ready",doc:asMemoryDocument(view.value),error:void 0})}catch(error){this.update({status:"failed",error:error instanceof Error?error.message:String(error)})}}update(patch){this.state={...this.state,...patch};for(let listener of this.listeners)listener()}};var COMMAND_NAMESPACES=["humanity-memory"];function delay(ms){return new Promise(resolve=>{setTimeout(resolve,ms)})}function createPlaneChannel(rpc){let call=async(endpoint,args)=>{try{return await rpc.call("/api",`humanity/${endpoint}`,{args})}catch(error){return{ok:!1,error:{message:error instanceof Error?error.message:String(error)}}}},settle=async(ns,written)=>{if(!written.ok||!COMMAND_NAMESPACES.includes(ns))return written;await delay(250);let fresh=await call("describe",{});if(!fresh.ok)return written;let view=fresh.value.namespaces.find(candidate=>candidate.ns===ns);return view===void 0?written:{ok:!0,value:view}};return{describe:()=>call("describe",{}),replace:async(ns,section,expectedRevision)=>settle(ns,await call("replace",{ns,section,expectedRevision})),update:async(ns,patch,expectedRevision)=>settle(ns,await call("update",{ns,patch,expectedRevision}))}}function subscribeToProjection(remote,namespaces,reload){let events=remote;if(events===void 0||typeof events.$on!="function")return()=>{};try{return events.$on("settings/document-updated",ns=>{namespaces.includes(ns)&&reload()})}catch(error){return console.error("[humanity] 设置变更订阅失败,工作台将不会自动刷新",error),()=>{}}}function attachRemoteController(ctx,controller,namespace,label,options={}){ctx.inject(["connection"],sctx=>{try{let connection=sctx.connection;controller.attach(createPlaneChannel(connection.rpc))}catch(error){console.error(`[humanity] ${label}通道接入失败,将显示为未就绪`,error),controller.detach();return}controller.load({quiet:!0});let pollMs=options.pollMs??0,timer=pollMs>0&&typeof document<"u"?setInterval(()=>{controller.load({quiet:!0})},pollMs):void 0;return()=>{timer!==void 0&&clearInterval(timer),controller.detach()}})}var import_react11=require("react");var import_react9=require("react");var import_react2=require("react");var EMOTION_TIERS=[{id:"calm",at:0},{id:"faint",at:30},{id:"clear",at:50},{id:"burst",at:75}];var RENDER_FLOOR=10;var SENSITIVITY_HALF_LIFE_MINUTES=1440;var SENSITIVITY_MAX_BOOST=.5;var SOOTHE_QUIET_MINUTES=30;var page={boxSizing:"border-box",height:"100%",overflowY:"auto",padding:"32px 32px 56px",background:"transparent",color:"var(--dsw-alias-label-primary)",fontFamily:"var(--dsw-font-family)",fontSize:"var(--dsh-content-font-size, 14px)",lineHeight:1.6},column={maxWidth:880,margin:"0 auto"},titleRow={display:"flex",alignItems:"center",gap:12},title={margin:0,fontSize:22,fontWeight:600,letterSpacing:"0.01em"},subtitle={margin:"8px 0 0",color:"var(--dsw-alias-label-secondary)"},panel={marginTop:24,padding:"16px 20px",border:"1px solid var(--dsw-alias-border-l1)",borderRadius:12,background:"var(--dsw-alias-bg-layer-1)"},panelTitle={margin:"0 0 8px",fontSize:14,fontWeight:600,color:"var(--dsw-alias-label-primary)"},headingWithHint={display:"flex",alignItems:"center",gap:6},hint={margin:0,color:"var(--dsw-alias-label-secondary)"},toggleCard={display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,marginTop:16,padding:"12px 16px",border:"1px solid var(--dsw-alias-border-l2)",borderRadius:10,background:"var(--dsw-alias-bg-layer-1)"},toggleText={display:"flex",flexDirection:"column",gap:2},toggleState={display:"flex",alignItems:"center",gap:8,color:"var(--dsw-alias-label-secondary)",fontSize:"0.9em"};var import_jsx_runtime2=require("react/jsx-runtime");function tierAt(id){return EMOTION_TIERS.find(tier=>tier.id===id)?.at??0}var barTrack={position:"relative",height:6,borderRadius:3,background:"var(--dsw-alias-border-l2)",overflow:"visible"},barFill={position:"absolute",top:0,bottom:0,left:0,borderRadius:3,background:"var(--dsw-alias-brand-primary)",opacity:.4},barMarker={position:"absolute",top:-4,width:2,height:14,borderRadius:1,background:"var(--dsw-alias-brand-primary)"},barDelta={position:"absolute",top:0,bottom:0,borderRadius:3},chargeBlock={padding:"10px 0 2px",borderTop:"1px solid var(--dsw-alias-border-l1)"},chargeHead={display:"flex",alignItems:"baseline",gap:12},chargeTrackRow={display:"grid",gridTemplateColumns:"1fr 44px 56px",alignItems:"center",gap:12,marginTop:6},DELTA_UP_COLOR="#3fb950",DELTA_DOWN_COLOR="#f85149",meta={margin:"4px 0 0",color:"var(--dsw-alias-label-secondary)",fontSize:"0.9em"},TIER_KEYS={burst:"emotion.tier.burst",clear:"emotion.tier.clear",faint:"emotion.tier.faint",calm:"emotion.tier.calm"},ENERGY_KEYS={fresh:"emotion.energy.fresh",tired:"emotion.energy.tired",exhausted:"emotion.energy.exhausted"};function minutesBetween(iso,now){let at=Date.parse(iso);if(!(iso===""||Number.isNaN(at)))return Math.max(0,Math.round((now-at)/6e4))}function spanText(t,minutes){return minutes<60?t("emotion.duration.minutes",{n:String(minutes)}):minutes<1440?t("emotion.duration.hours",{n:String(Math.round(minutes/60))}):t("emotion.duration.days",{n:String(Math.round(minutes/1440))})}function durationText(t,since,now){let minutes=minutesBetween(since,now);return minutes===void 0?"":minutes<1?t("emotion.agoNow"):t("emotion.since",{duration:spanText(t,minutes)})}function agoText(t,iso,now){let minutes=minutesBetween(iso,now);return minutes===void 0?"":minutes<1?t("emotion.agoNow"):t("emotion.ago",{duration:spanText(t,minutes)})}function ChargeRow({t,charge,now}){let absent=charge.intensity<=0,duration=absent?"":durationText(t,charge.since,now),cause=charge.cause===""?t("emotion.noCause"):charge.cause,color=absent?"var(--dsw-alias-label-tertiary)":"var(--dsw-alias-label-primary)",cur=Math.max(0,Math.min(100,charge.intensity)),before=Math.max(0,Math.min(100,charge.before)),from=Math.min(before,cur),change=Math.abs(cur-before),changed=charge.before>=0&&charge.delta!==0&&change>0,grew=cur>=before;return(0,import_jsx_runtime2.jsxs)("div",{style:chargeBlock,children:[(0,import_jsx_runtime2.jsxs)("div",{style:chargeHead,children:[(0,import_jsx_runtime2.jsxs)("span",{style:{fontWeight:absent?400:600,color,whiteSpace:"nowrap",minWidth:96},children:[charge.targetLabel,charge.label]}),(0,import_jsx_runtime2.jsx)("span",{style:{...meta,margin:0,flex:1,color:absent?"var(--dsw-alias-label-tertiary)":meta.color},children:absent?t("emotion.absent"):`${t("emotion.cause")}:${cause}${duration===""?"":` · ${duration}`}`})]}),(0,import_jsx_runtime2.jsxs)("div",{style:chargeTrackRow,children:[(0,import_jsx_runtime2.jsxs)("span",{style:barTrack,children:[(0,import_jsx_runtime2.jsx)("span",{style:{...barFill,width:`${cur}%`,opacity:absent?.2:.4}}),(0,import_jsx_runtime2.jsx)("span",{style:{...barMarker,left:`${cur}%`,opacity:absent?.3:1}}),changed?(0,import_jsx_runtime2.jsx)("span",{title:t(grew?"emotion.deltaUp":"emotion.deltaDown").replace("{n}",String(Math.round(change))),style:{...barDelta,left:`${from}%`,width:`${change}%`,background:grew?DELTA_UP_COLOR:DELTA_DOWN_COLOR}}):null]}),(0,import_jsx_runtime2.jsx)("span",{style:{...meta,margin:0,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:Math.round(cur)}),(0,import_jsx_runtime2.jsx)("span",{style:{...meta,margin:0},children:absent?"":t(TIER_KEYS[charge.tier]??"emotion.tier.calm")})]})]})}function EmotionPage({t,controller}){let state=(0,import_react2.useSyncExternalStore)(controller.subscribe,controller.getSnapshot,controller.getSnapshot);(0,import_react2.useEffect)(()=>{controller.load({quiet:!0});let timer=setInterval(()=>{controller.load({quiet:!0})},3e4);return()=>{clearInterval(timer)}},[controller]);let now=Date.now(),document2=state.document;return(0,import_jsx_runtime2.jsx)("div",{style:page,children:(0,import_jsx_runtime2.jsxs)("div",{style:column,children:[(0,import_jsx_runtime2.jsxs)("header",{children:[(0,import_jsx_runtime2.jsx)("div",{style:titleRow,children:(0,import_jsx_runtime2.jsx)("h1",{style:title,children:t("emotion.title")})}),(0,import_jsx_runtime2.jsx)("p",{style:subtitle,children:t("emotion.hint")})]}),state.status==="loading"&&(0,import_jsx_runtime2.jsx)("p",{style:{...subtitle,marginTop:16},children:t("emotion.loading")}),state.status==="unavailable"&&(0,import_jsx_runtime2.jsx)("p",{style:{...subtitle,marginTop:16},children:t("emotion.unavailable")}),state.status==="failed"&&(0,import_jsx_runtime2.jsx)("p",{style:{...subtitle,marginTop:16},children:t("emotion.failed",{message:state.error??""})}),document2!==void 0&&(0,import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment,{children:[(0,import_jsx_runtime2.jsxs)("section",{style:panel,children:[document2.charges.length===0?(0,import_jsx_runtime2.jsx)("p",{style:{...hint,margin:0},children:t("emotion.empty")}):document2.charges.map(charge=>(0,import_jsx_runtime2.jsx)(ChargeRow,{t,charge,now},`${charge.kind}-${charge.since}`)),document2.compositeLabel===""?null:(0,import_jsx_runtime2.jsxs)("p",{style:{...meta,marginTop:16},children:[t("emotion.composite"),":",(0,import_jsx_runtime2.jsx)("strong",{style:{color:"var(--dsw-alias-label-primary)"},children:document2.compositeLabel}),document2.compositeParts.length===2?`(${document2.compositeParts.join(" + ")})`:""]}),document2.charges.some(charge=>charge.tier==="burst")&&(0,import_jsx_runtime2.jsx)("p",{style:{...meta,marginTop:12},children:t("emotion.tier.burstHint")})]}),(0,import_jsx_runtime2.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime2.jsx)("h2",{style:panelTitle,children:t("emotion.sensitivity")}),(0,import_jsx_runtime2.jsx)("p",{style:{...meta,marginTop:0},children:t("emotion.sensitivityHint")}),document2.sensitivities.length===0?(0,import_jsx_runtime2.jsx)("p",{style:{...meta,marginTop:8},children:t("emotion.sensitivityEmpty")}):document2.sensitivities.map(entry=>{let when=agoText(t,entry.at,now),level=Math.max(0,Math.min(1,entry.level)),before=Math.max(0,Math.min(1,entry.levelBefore)),from=Math.min(before,level)*100,width=Math.abs(level-before)*100;return(0,import_jsx_runtime2.jsxs)("div",{style:chargeBlock,children:[(0,import_jsx_runtime2.jsxs)("div",{style:chargeHead,children:[(0,import_jsx_runtime2.jsxs)("span",{style:{fontWeight:600,whiteSpace:"nowrap",minWidth:96},children:[entry.targetLabel,entry.label]}),(0,import_jsx_runtime2.jsx)("span",{style:{...meta,margin:0,flex:1},children:entry.cause===""?t("emotion.sensitivityNoCause"):`${t("emotion.cause")}:${entry.cause}${entry.at===""?"":` · ${when}`}`})]}),(0,import_jsx_runtime2.jsxs)("div",{style:chargeTrackRow,children:[(0,import_jsx_runtime2.jsxs)("span",{style:barTrack,children:[(0,import_jsx_runtime2.jsx)("span",{style:{...barFill,width:`${Math.round(level*100)}%`}}),(0,import_jsx_runtime2.jsx)("span",{style:{...barMarker,left:`${Math.round(level*100)}%`}}),width<=0||entry.at===""?null:(0,import_jsx_runtime2.jsx)("span",{title:t("emotion.sensitivityDelta"),style:{...barDelta,left:`${from}%`,width:`${width}%`,background:level>=before?DELTA_UP_COLOR:DELTA_DOWN_COLOR}})]}),(0,import_jsx_runtime2.jsxs)("span",{style:{...meta,margin:0,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:[Math.round(level*100),"%"]}),(0,import_jsx_runtime2.jsx)("span",{style:{...meta,margin:0}})]})]},`${entry.kind}-${entry.target}`)})]}),(0,import_jsx_runtime2.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime2.jsx)("h2",{style:panelTitle,children:t("emotion.warmth")}),(0,import_jsx_runtime2.jsx)("p",{style:{...meta,marginTop:0},children:t("emotion.warmthHint")}),(0,import_jsx_runtime2.jsx)("div",{style:{...barTrack,marginTop:10},children:(0,import_jsx_runtime2.jsx)("span",{style:{display:"block",height:"100%",width:`${Math.max(0,Math.min(100,document2.warmth))}%`,borderRadius:3,background:"var(--dsw-alias-label-primary)"}})}),document2.warmthCause===""?null:(0,import_jsx_runtime2.jsx)("p",{style:meta,children:document2.warmthCause})]}),(0,import_jsx_runtime2.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime2.jsx)("h2",{style:panelTitle,children:t("emotion.energy")}),(0,import_jsx_runtime2.jsx)("p",{style:{...meta,marginTop:0},children:t("emotion.energyHint")}),(0,import_jsx_runtime2.jsx)("div",{style:{...barTrack,marginTop:10},children:(0,import_jsx_runtime2.jsx)("span",{style:{display:"block",height:"100%",width:`${Math.max(0,Math.min(100,document2.energy))}%`,borderRadius:3,background:"var(--dsw-alias-label-primary)"}})}),(0,import_jsx_runtime2.jsx)("p",{style:meta,children:t(ENERGY_KEYS[document2.energyLevel]??"emotion.energy.fresh")})]}),document2.perceived===""?null:(0,import_jsx_runtime2.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime2.jsx)("h2",{style:panelTitle,children:t("emotion.perceived")}),(0,import_jsx_runtime2.jsx)("p",{style:{...meta,marginTop:0},children:t("emotion.perceivedHint")}),(0,import_jsx_runtime2.jsx)("p",{style:{margin:"8px 0 0"},children:document2.perceived})]}),(0,import_jsx_runtime2.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime2.jsx)("h2",{style:panelTitle,children:t("emotion.params.title")}),(0,import_jsx_runtime2.jsx)("p",{style:{...meta,marginTop:0},children:t("emotion.params.hint")}),(0,import_jsx_runtime2.jsxs)("ul",{style:{...meta,margin:"8px 0 0",paddingLeft:18,lineHeight:1.8},children:[(0,import_jsx_runtime2.jsx)("li",{children:t("emotion.params.floor",{floor:RENDER_FLOOR})}),(0,import_jsx_runtime2.jsx)("li",{children:t("emotion.params.tiers",{faint:tierAt("faint"),clear:tierAt("clear"),burst:tierAt("burst")})}),(0,import_jsx_runtime2.jsx)("li",{children:t("emotion.params.sensitivity",{boost:(1+SENSITIVITY_MAX_BOOST).toFixed(1),hours:Math.round(SENSITIVITY_HALF_LIFE_MINUTES/60)})}),(0,import_jsx_runtime2.jsx)("li",{children:t("emotion.params.soothe",{minutes:SOOTHE_QUIET_MINUTES})})]})]}),(0,import_jsx_runtime2.jsxs)("p",{style:{...subtitle,marginTop:16},children:[t("emotion.settledAt",{time:agoText(t,document2.settledAt,now)})," · ",t("emotion.globalHint")]})]})]})})}var import_react3=require("react");var import_dsh_client_ui_primitives=require("@deepseek-ai/dsh-client-ui-primitives");var import_jsx_runtime3=require("react/jsx-runtime"),anchor={padding:"0 2px",height:18,minHeight:18,color:"var(--dsw-alias-label-tertiary)",cursor:"help",lineHeight:0};function InfoHint({label,side="top",delayMs=0}){return(0,import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives.Tooltip,{label,side,delayMs,maxWidth:360,children:(0,import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives.Button,{size:"sm",variant:"ghost",style:anchor,"aria-label":label,children:IconQuestion?(0,import_jsx_runtime3.jsx)(IconQuestion,{size:14}):(0,import_jsx_runtime3.jsx)("span",{"aria-hidden":!0,children:"?"})})})}var import_jsx_runtime4=require("react/jsx-runtime");function energyText(t,energy){let value=Math.max(0,Math.min(100,Math.round(energy))),level=value>=70?"fresh":value>=40?"ok":value>=25?"tired":"spent";return t(`workbench.evolution.energy.${level}`).replace("{value}",String(value))}function stamp(iso){if(iso==="")return"—";let at=Date.parse(iso);if(!Number.isFinite(at))return"—";let date=new Date(at),pad=value=>String(value).padStart(2,"0");return`${pad(date.getMonth()+1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`}function appraiseText(t,raw){let[kind,count,targets]=raw.split(":");return kind==="applied"?t("workbench.evolution.appraise.applied").replace("{count}",count??"0").replace("{targets}",targets??""):t(kind==="no-feeling"?"workbench.evolution.appraise.none":"workbench.evolution.appraise.skipped")}function DiaryRow({t,item,onOpen}){let[confirming,setConfirming]=(0,import_react3.useState)(!1);return(0,import_jsx_runtime4.jsxs)("div",{style:{padding:"10px 0",borderBottom:"1px solid var(--dsw-alias-border-l2)"},children:[(0,import_jsx_runtime4.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,import_jsx_runtime4.jsx)("span",{style:{fontVariantNumeric:"tabular-nums"},children:item.date}),item.opened?(0,import_jsx_runtime4.jsxs)("span",{style:{color:"var(--dsw-alias-label-secondary)",fontSize:12},children:[t("workbench.evolution.diary.openedAt").replace("{time}",stamp(item.openedAt))," · ",item.noticedAt===""?t("workbench.evolution.diary.unnoticed"):t("workbench.evolution.diary.noticed").replace("{time}",stamp(item.noticedAt))]}):confirming?(0,import_jsx_runtime4.jsxs)("span",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,import_jsx_runtime4.jsx)("span",{style:{fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.diary.confirm")}),(0,import_jsx_runtime4.jsx)("button",{type:"button",onClick:()=>{setConfirming(!1),onOpen(item.date)},children:t("workbench.evolution.diary.confirmYes")}),(0,import_jsx_runtime4.jsx)("button",{type:"button",onClick:()=>setConfirming(!1),children:t("workbench.evolution.diary.confirmNo")})]}):(0,import_jsx_runtime4.jsx)("button",{type:"button",onClick:()=>setConfirming(!0),children:t("workbench.evolution.diary.open")})]}),item.opened&&item.text!==""?(0,import_jsx_runtime4.jsx)("p",{style:{margin:"8px 0 0",whiteSpace:"pre-wrap",lineHeight:1.75},children:item.text}):null]})}function EvolutionPage({t,controller}){let state=(0,import_react3.useSyncExternalStore)(controller.subscribe,controller.getSnapshot,controller.getSnapshot),status=state.doc.status,lookedEmpty=status.maxPerDay===0&&status.dayCount===0&&status.lastWakeAt===""&&status.nextAt==="",unavailable=state.status!=="ready"||lookedEmpty;return(0,import_jsx_runtime4.jsxs)("div",{children:[(0,import_jsx_runtime4.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime4.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.today"),(0,import_jsx_runtime4.jsx)(InfoHint,{label:t("workbench.evolution.todayHint")})]}),unavailable?(0,import_jsx_runtime4.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.metric.unavailable")}):status.started?(0,import_jsx_runtime4.jsxs)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"max-content 1fr",gap:"8px 16px"},children:[(0,import_jsx_runtime4.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.state")}),(0,import_jsx_runtime4.jsx)("dd",{style:{margin:0},children:status.sleeping?t("workbench.evolution.state.sleeping"):t("workbench.evolution.state.awake")}),(0,import_jsx_runtime4.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.energy")}),(0,import_jsx_runtime4.jsx)("dd",{style:{margin:0},children:energyText(t,status.energy)}),(0,import_jsx_runtime4.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.wakes")}),(0,import_jsx_runtime4.jsxs)("dd",{style:{margin:0,display:"flex",alignItems:"center",gap:8},children:[(0,import_jsx_runtime4.jsx)("span",{children:t("workbench.evolution.wakesValue").replace("{count}",String(status.dayCount)).replace("{max}",String(status.maxPerDay))}),(0,import_jsx_runtime4.jsx)("input",{type:"number",min:0,max:24,defaultValue:status.maxPerDay,"aria-label":t("workbench.evolution.cap.aria"),style:{width:64},onKeyDown:event=>{if(event.key!=="Enter")return;let value=Number(event.target.value);Number.isInteger(value)&&value>=0&&value<=24&&controller.setWakeCap(value)}})]}),(0,import_jsx_runtime4.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.lastWake")}),(0,import_jsx_runtime4.jsx)("dd",{style:{margin:0,fontVariantNumeric:"tabular-nums"},children:stamp(status.lastWakeAt)}),(0,import_jsx_runtime4.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.lastTurn")}),(0,import_jsx_runtime4.jsxs)("dd",{style:{margin:0},children:[status.lastTurnTools>0?t("workbench.evolution.lastTurn.tools").replace("{count}",String(status.lastTurnTools)):t("workbench.evolution.lastTurn.talk"),status.lastAppraise!==""?` · ${appraiseText(t,status.lastAppraise)}`:""]}),(0,import_jsx_runtime4.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.nextWake")}),(0,import_jsx_runtime4.jsxs)("dd",{style:{margin:0,fontVariantNumeric:"tabular-nums"},children:[stamp(status.nextAt),status.busy?(0,import_jsx_runtime4.jsxs)("span",{style:{marginLeft:8,fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:[t("workbench.evolution.busy"),status.busySince!==""?` ${t("workbench.evolution.busySince").replace("{time}",stamp(status.busySince))}`:""]}):null]})]}):(0,import_jsx_runtime4.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.notStarted")}),status.lastError!==""?(0,import_jsx_runtime4.jsx)("p",{style:{margin:"10px 0 0",fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.error").replace("{reason}",status.lastError)}):null]}),(0,import_jsx_runtime4.jsxs)("section",{style:{...panel,marginTop:16},children:[(0,import_jsx_runtime4.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.room.title"),(0,import_jsx_runtime4.jsx)(InfoHint,{label:t("workbench.evolution.room.hint")})]}),(0,import_jsx_runtime4.jsx)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:(0,import_jsx_runtime4.jsx)("input",{type:"text",defaultValue:status.roomText,placeholder:t("workbench.evolution.room.placeholder"),"aria-label":t("workbench.evolution.room.aria"),style:{flex:"1 1 260px",minWidth:200},onKeyDown:event=>{event.key==="Enter"&&controller.setRoom(event.target.value.trim())}})}),(0,import_jsx_runtime4.jsx)("p",{style:{margin:"8px 0 0",fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:status.roomPath!==""?t("workbench.evolution.room.nowAt").replace("{path}",status.roomPath):t("workbench.evolution.room.legacy")}),status.roomTarget!==""&&status.roomTarget!==status.roomPath?(0,import_jsx_runtime4.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.room.pending").replace("{path}",status.roomTarget)}):null]}),(0,import_jsx_runtime4.jsxs)("section",{style:{...panel,marginTop:16},children:[(0,import_jsx_runtime4.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.tell.title"),(0,import_jsx_runtime4.jsx)(InfoHint,{label:t("workbench.evolution.tell.hint")})]}),state.doc.tell.pending!==""?(0,import_jsx_runtime4.jsxs)("p",{style:{margin:"0 0 8px",whiteSpace:"pre-wrap",lineHeight:1.75},children:[t("workbench.evolution.tell.pending"),":",state.doc.tell.pending,state.doc.tell.pendingShow!==""?` · ${t("workbench.evolution.tell.withWork").replace("{name}",state.doc.tell.pendingShow)}`:""]}):null,state.doc.tell.lastAt!==""?(0,import_jsx_runtime4.jsxs)("p",{style:{margin:"0 0 4px",whiteSpace:"pre-wrap",lineHeight:1.75},children:[t("workbench.evolution.tell.lastAt").replace("{time}",stamp(state.doc.tell.lastAt)),":",state.doc.tell.lastText===""?t("workbench.evolution.tell.onlyWork"):state.doc.tell.lastText,state.doc.tell.lastShow!==""?` · ${t("workbench.evolution.tell.withWork").replace("{name}",state.doc.tell.lastShow)}`:""]}):null,state.doc.tell.lastAt!==""?(0,import_jsx_runtime4.jsx)("p",{style:{margin:0,fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:state.doc.tell.unread?t("workbench.evolution.tell.unread"):t("workbench.evolution.tell.seen")}):null,state.doc.tell.lastReason!==""?(0,import_jsx_runtime4.jsx)("p",{style:{margin:"6px 0 0",fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.tell.reason").replace("{reason}",state.doc.tell.lastReason)}):null,state.doc.tell.lastAt===""&&state.doc.tell.pending===""?(0,import_jsx_runtime4.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.tell.empty")}):null]}),(0,import_jsx_runtime4.jsxs)("section",{style:{...panel,marginTop:16},children:[(0,import_jsx_runtime4.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.diary.title"),(0,import_jsx_runtime4.jsx)(InfoHint,{label:t("workbench.evolution.diary.hint")})]}),state.doc.notice!==""?(0,import_jsx_runtime4.jsx)("p",{style:{margin:"0 0 8px",fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:state.doc.notice}):null,status.lastSettleError!==""?(0,import_jsx_runtime4.jsx)("p",{style:{margin:"0 0 8px",fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.diary.settleFailed").replace("{reason}",status.lastSettleError)}):null,state.doc.diary.length===0?(0,import_jsx_runtime4.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.diary.empty")}):state.doc.diary.map(item=>(0,import_jsx_runtime4.jsx)(DiaryRow,{t,item,onOpen:date=>controller.open(date)},item.date))]}),(0,import_jsx_runtime4.jsxs)("section",{style:{...panel,marginTop:16},children:[(0,import_jsx_runtime4.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.grow.title"),(0,import_jsx_runtime4.jsx)(InfoHint,{label:t("workbench.evolution.grow.hint")})]}),state.doc.grow.lastRun.at!==""?(0,import_jsx_runtime4.jsxs)("p",{style:{margin:"0 0 8px",fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:[t("workbench.evolution.grow.lastRun").replace("{time}",stamp(state.doc.grow.lastRun.at)),state.doc.grow.lastRun.wrote.length>0?` · ${t("workbench.evolution.grow.wrote").replace("{list}",state.doc.grow.lastRun.wrote.join("、"))}`:"",state.doc.grow.lastRun.note!==""?` · ${state.doc.grow.lastRun.note}`:""]}):null,state.doc.grow.candidates.length===0?(0,import_jsx_runtime4.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.grow.empty")}):(0,import_jsx_runtime4.jsx)("ul",{style:{margin:0,paddingLeft:18,lineHeight:1.8},children:state.doc.grow.candidates.map((item,index)=>(0,import_jsx_runtime4.jsxs)("li",{children:[item.text,(0,import_jsx_runtime4.jsxs)("span",{style:{marginLeft:8,fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:[item.about==="user"?t("workbench.evolution.grow.aboutUser"):t("workbench.evolution.grow.aboutSelf")," · ",t("workbench.evolution.grow.count").replace("{count}",String(item.count))," · ",t("workbench.evolution.grow.days").replace("{days}",String(item.days))]}),(0,import_jsx_runtime4.jsx)("button",{type:"button",style:{marginLeft:8,fontSize:12},onClick:()=>{controller.dropCandidate(item.text)},children:t("workbench.evolution.grow.drop")})]},`${item.text}-${String(index)}`))})]}),(0,import_jsx_runtime4.jsxs)("section",{style:{...panel,marginTop:16},children:[(0,import_jsx_runtime4.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.threads.title"),(0,import_jsx_runtime4.jsx)(InfoHint,{label:t("workbench.evolution.threads.hint")})]}),state.doc.threads.length===0?(0,import_jsx_runtime4.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.threads.empty")}):(0,import_jsx_runtime4.jsx)("ul",{style:{margin:0,paddingLeft:18,lineHeight:1.8},children:state.doc.threads.map(line=>(0,import_jsx_runtime4.jsx)("li",{children:line},line))})]}),(0,import_jsx_runtime4.jsxs)("section",{style:{...panel,marginTop:16},children:[(0,import_jsx_runtime4.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.works.title"),(0,import_jsx_runtime4.jsx)(InfoHint,{label:t("workbench.evolution.works.hint")})]}),state.doc.works.length===0?(0,import_jsx_runtime4.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.works.empty")}):state.doc.works.map(item=>(0,import_jsx_runtime4.jsxs)("div",{style:{padding:"8px 0",borderBottom:"1px solid var(--dsw-alias-border-l2)"},children:[(0,import_jsx_runtime4.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,import_jsx_runtime4.jsx)("span",{children:item.name}),(0,import_jsx_runtime4.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,import_jsx_runtime4.jsxs)("span",{style:{color:"var(--dsw-alias-label-secondary)",fontSize:12},children:[Math.max(1,Math.round(item.size/1024))," KB · ",stamp(item.updatedAt)]}),(0,import_jsx_runtime4.jsx)("button",{type:"button",onClick:()=>{controller.download(item.name)},children:t("workbench.evolution.works.download")})]})]}),item.kind==="text"&&item.preview!==""?(0,import_jsx_runtime4.jsxs)("details",{style:{marginTop:6},children:[(0,import_jsx_runtime4.jsx)("summary",{style:{cursor:"pointer",fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.works.previewToggle")}),(0,import_jsx_runtime4.jsx)("pre",{style:{margin:"6px 0 0",whiteSpace:"pre-wrap",fontSize:13,lineHeight:1.7},children:item.preview})]}):(0,import_jsx_runtime4.jsx)("p",{style:{margin:"6px 0 0",fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.works.noPreview")})]},item.name))]})]})}var import_dsh_client_ui_primitives2=require("@deepseek-ai/dsh-client-ui-primitives"),import_react5=require("react");var import_react4=require("react");function useVisibleRefresh(reload){(0,import_react4.useEffect)(()=>{if(typeof document>"u")return;let tick=()=>{document.visibilityState==="visible"&&reload()},onFocus=()=>tick();return document.addEventListener("visibilitychange",tick),window.addEventListener("focus",onFocus),()=>{document.removeEventListener("visibilitychange",tick),window.removeEventListener("focus",onFocus)}},[reload])}var import_jsx_runtime5=require("react/jsx-runtime"),DISCLOSURE_THRESHOLD=.5,page2={display:"flex",flexDirection:"column",gap:12},stats={display:"flex",flexWrap:"wrap",gap:16,fontSize:13,color:"var(--dsw-alias-label-secondary)"},row={padding:"10px 0",borderTop:"1px solid var(--dsw-alias-border-l2)"},meta2={display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:10,fontSize:12,color:"var(--dsw-alias-label-secondary)"},what={margin:"6px 0 8px",fontSize:13,lineHeight:1.6,color:"var(--dsw-alias-label-primary)",overflowWrap:"anywhere"},track={position:"relative",height:5,borderRadius:3,background:"var(--dsw-alias-border-l2)"},fill={position:"absolute",top:0,bottom:0,left:0,borderRadius:3,background:"var(--dsw-alias-brand-primary)"},secretMask={color:"var(--dsw-alias-label-secondary)",fontStyle:"italic"},secretWarn={color:"var(--dsw-alias-state-warn-label)",fontSize:12},deleteWarn={color:"var(--dsw-alias-state-warn-label)",fontSize:12},rowActions={marginLeft:"auto",display:"flex",gap:8,alignItems:"baseline"},noticeLine={fontSize:12,color:"var(--dsw-alias-label-secondary)",margin:"4px 0"},whyBox={margin:"10px 0 6px",padding:"10px 12px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1)",border:"1px solid var(--dsw-alias-border-l2)"},whyTitle={fontSize:12,color:"var(--dsw-alias-label-secondary)",margin:"0 0 6px"},whyCue={fontSize:13,margin:"0 0 6px",color:"var(--dsw-alias-label-primary)",overflowWrap:"anywhere"},whyList={margin:0,paddingLeft:18,fontSize:13,lineHeight:1.6,color:"var(--dsw-alias-label-primary)"},whyMatch={marginLeft:8,fontSize:11,color:"var(--dsw-alias-label-secondary)"},notice={fontSize:13,color:"var(--dsw-alias-label-secondary)",padding:"12px 0"},aboutText=(about,t)=>{switch(about){case"self":return t("memory.about.self");case"user":return t("memory.about.user");case"us":return t("memory.about.us");default:return t("memory.about.world")}};function dayOf(iso){let at=Date.parse(iso);if(!Number.isFinite(at))return"";let date=new Date(at);return`${date.getFullYear()}-${String(date.getMonth()+1).padStart(2,"0")}-${String(date.getDate()).padStart(2,"0")}`}function EntryRow({entry,t,pending:pending2,onAsk,onConfirm,deleting,onDeleteAsk,onDeleteConfirm}){let percent2=`${Math.round(Math.min(1,Math.max(0,entry.strength))*100)}%`,secret=entry.cost>DISCLOSURE_THRESHOLD;return(0,import_jsx_runtime5.jsxs)("div",{style:row,children:[(0,import_jsx_runtime5.jsxs)("div",{style:meta2,children:[(0,import_jsx_runtime5.jsx)("span",{children:dayOf(entry.when)}),(0,import_jsx_runtime5.jsx)("span",{children:aboutText(entry.about,t)}),(0,import_jsx_runtime5.jsx)("span",{children:t(`memory.tier.${entry.tier}`)}),entry.feltLabel!==""?(0,import_jsx_runtime5.jsx)("span",{children:t("memory.felt").replace("{label}",entry.feltLabel)}):null,entry.covers>0?(0,import_jsx_runtime5.jsx)("span",{children:t("memory.covers").replace("{count}",String(entry.covers))}):null,entry.recalled>0?(0,import_jsx_runtime5.jsx)("span",{children:t("memory.recalled").replace("{count}",String(entry.recalled))}):null,(0,import_jsx_runtime5.jsx)("div",{style:rowActions,children:deleting?(0,import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment,{children:[(0,import_jsx_runtime5.jsx)("span",{style:deleteWarn,children:t("memory.delete.warn")}),(0,import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Button,{size:"sm",variant:"outline",onClick:onDeleteConfirm,children:t("memory.delete.confirm")})]}):(0,import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Button,{size:"sm",variant:"ghost",onClick:onDeleteAsk,children:t("memory.delete.ask")})})]}),secret?(0,import_jsx_runtime5.jsxs)("p",{style:what,children:[(0,import_jsx_runtime5.jsxs)("span",{style:secretMask,children:["🔒 ",t("memory.secret")]})," ",pending2?(0,import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment,{children:[(0,import_jsx_runtime5.jsx)("span",{style:secretWarn,children:t("memory.reveal.warn")})," ",(0,import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Button,{size:"sm",variant:"primary",onClick:onConfirm,children:t("memory.reveal.confirm")})]}):(0,import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Button,{size:"sm",variant:"ghost",onClick:onAsk,children:t("memory.reveal.ask")})]}):(0,import_jsx_runtime5.jsx)("p",{style:what,children:entry.what}),(0,import_jsx_runtime5.jsx)("div",{style:track,"aria-hidden":!0,children:(0,import_jsx_runtime5.jsx)("div",{style:{...fill,width:percent2}})})]})}function MemoryPage({t,controller}){let state=(0,import_react5.useSyncExternalStore)(controller.subscribe,controller.getSnapshot,controller.getSnapshot),[pendingId,setPendingId]=(0,import_react5.useState)(""),[deletingId,setDeletingId]=(0,import_react5.useState)("");(0,import_react5.useEffect)(()=>{controller.load()},[controller]);let reload=(0,import_react5.useCallback)(()=>{controller.load({quiet:!0})},[controller]);useVisibleRefresh(reload);let{doc}=state,ready=state.status==="ready";return(0,import_jsx_runtime5.jsx)("div",{style:page2,children:(0,import_jsx_runtime5.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime5.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("memory.title"),(0,import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Button,{size:"sm",variant:"ghost",onClick:()=>{controller.load()},children:t("memory.reload")})]}),state.status==="loading"?(0,import_jsx_runtime5.jsx)("p",{style:notice,children:t("memory.loading")}):null,state.status==="unavailable"?(0,import_jsx_runtime5.jsx)("p",{style:notice,children:t("memory.unavailable")}):null,state.status==="failed"?(0,import_jsx_runtime5.jsx)("p",{style:notice,children:state.error??t("memory.failed")}):null,ready&&doc.notice!==""?(0,import_jsx_runtime5.jsx)("p",{style:noticeLine,children:doc.notice}):null,ready?(0,import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment,{children:[(0,import_jsx_runtime5.jsxs)("div",{style:stats,children:[(0,import_jsx_runtime5.jsx)("span",{children:t("memory.total").replace("{count}",String(doc.stats.total))}),(0,import_jsx_runtime5.jsxs)("span",{children:[t("memory.tier.episode")," ",doc.stats.episode]}),doc.stats.period>0?(0,import_jsx_runtime5.jsxs)("span",{children:[t("memory.tier.period")," ",doc.stats.period]}):null,doc.stats.chapter>0?(0,import_jsx_runtime5.jsxs)("span",{children:[t("memory.tier.chapter")," ",doc.stats.chapter]}):null,(0,import_jsx_runtime5.jsx)("span",{children:t("memory.recalledTotal").replace("{count}",String(doc.stats.recalled))})]}),doc.lastRecall.items.length>0?(0,import_jsx_runtime5.jsxs)("div",{style:whyBox,children:[(0,import_jsx_runtime5.jsx)("p",{style:whyTitle,children:t("memory.why.title")}),doc.lastRecall.cue!==""?(0,import_jsx_runtime5.jsx)("p",{style:whyCue,children:t("memory.why.cue").replace("{cue}",doc.lastRecall.cue)}):null,(0,import_jsx_runtime5.jsx)("ul",{style:whyList,children:doc.lastRecall.items.map((item,index)=>(0,import_jsx_runtime5.jsxs)("li",{children:[item.withheld?t("memory.why.withheld"):item.what,item.match!==""?(0,import_jsx_runtime5.jsx)("span",{style:whyMatch,children:t(`memory.why.match.${item.match}`)}):null]},`${index}-${item.what}`))})]}):null,doc.entries.length===0?(0,import_jsx_runtime5.jsx)("p",{style:notice,children:doc.dormant?t("memory.dormant"):t("memory.empty")}):doc.entries.map(entry=>(0,import_jsx_runtime5.jsx)(EntryRow,{entry,t,pending:pendingId===entry.id,onAsk:()=>setPendingId(entry.id),onConfirm:()=>{setPendingId(""),controller.reveal(entry.id).then(ok=>{ok&&controller.load({quiet:!0})})},deleting:deletingId===entry.id,onDeleteAsk:()=>setDeletingId(entry.id),onDeleteConfirm:()=>{setDeletingId(""),controller.remove(entry.id).then(ok=>{ok&&controller.load({quiet:!0})})}},entry.id))]}):null]})})}var import_react6=require("react");var metricList={margin:"0 0 12px"},metricRow={display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"8px 0",borderBottom:"1px solid var(--dsw-alias-border-l2)"};var metricValueStrong={margin:0,marginInlineStart:0,fontSize:17,fontWeight:600,color:"var(--dsw-alias-label-primary)"},metricLabelSmall={margin:0,fontSize:13,color:"var(--dsw-alias-label-secondary)"};var import_jsx_runtime6=require("react/jsx-runtime"),NOOP_SUBSCRIBE=()=>()=>{},DETACHED_MEMORY_STATE={status:"unavailable",doc:emptyMemoryDocument()},DETACHED_MEMORY={subscribe:NOOP_SUBSCRIBE,getSnapshot:()=>DETACHED_MEMORY_STATE},DETACHED_PERSONA_STATE={status:"idle",writable:!1,stored:emptyDocument(),draft:emptyDocument(),saving:!1,savedAt:"",issues:[],independentJudgment:!0,independentJudgmentSaving:!1},DETACHED_PERSONA={subscribe:NOOP_SUBSCRIBE,getSnapshot:()=>DETACHED_PERSONA_STATE},OVERVIEW_METRICS=[{key:"workbench.metric.name",hintKey:void 0},{key:"workbench.metric.memory",hintKey:"workbench.metric.memoryHint"}];function nameLabel(t,persona){let name2=((persona?.draft.identityCard.fields??[]).find(field=>field.key==="姓名")?.value??"").trim();return name2===""?t("workbench.metric.nameEmpty"):name2}function memoryLabel(t,memory){return memory.status!=="ready"?t("workbench.metric.unavailable"):t("workbench.metric.memoryValue",{count:String(memory.doc?.stats.total??0)})}function OverviewPanel(props){let{t}=props,memoryController=props.memory??DETACHED_MEMORY,personaController=props.persona??DETACHED_PERSONA,memory=(0,import_react6.useSyncExternalStore)(memoryController.subscribe,memoryController.getSnapshot,memoryController.getSnapshot),personaState=(0,import_react6.useSyncExternalStore)(personaController.subscribe,personaController.getSnapshot,personaController.getSnapshot),values={"workbench.metric.name":nameLabel(t,personaState),"workbench.metric.memory":memoryLabel(t,memory)};return(0,import_jsx_runtime6.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime6.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.overview"),(0,import_jsx_runtime6.jsx)(InfoHint,{label:t("workbench.overviewHint")})]}),(0,import_jsx_runtime6.jsx)("dl",{style:metricList,children:OVERVIEW_METRICS.map(metric=>(0,import_jsx_runtime6.jsxs)("div",{style:metricRow,children:[(0,import_jsx_runtime6.jsxs)("dt",{style:{...metricLabelSmall,...headingWithHint},children:[t(metric.key),metric.hintKey===void 0?null:(0,import_jsx_runtime6.jsx)(InfoHint,{label:t(metric.hintKey)})]}),(0,import_jsx_runtime6.jsx)("dd",{style:metricValueStrong,children:values[metric.key]})]},metric.key))})]})}var import_react8=require("react"),import_dsh_client_ui_primitives6=require("@deepseek-ai/dsh-client-ui-primitives");var ITEM_TRACKS="minmax(96px, 160px) minmax(240px, 1fr) max-content",itemList={display:"grid",gridTemplateColumns:ITEM_TRACKS,alignItems:"center",columnGap:12,rowGap:8},itemGrid={display:"grid",gridTemplateColumns:ITEM_TRACKS,alignItems:"center",columnGap:12},itemActions={display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"nowrap",gap:4},renameIssueText={fontSize:12,color:"var(--dsw-alias-state-warn-label)",overflowWrap:"anywhere"},editorCell={display:"flex",flexDirection:"column",width:"100%",minWidth:0},deleteBand={display:"flex",flexWrap:"wrap",alignItems:"center",gap:8,marginTop:6,padding:"8px 10px",border:"0.5px solid var(--dsw-alias-border-l4)",borderRadius:8,background:"var(--dsw-alias-bg-layer-1)",fontSize:13,color:"var(--dsw-alias-label-secondary)"},addBand={gridColumn:"1 / -1",marginTop:4,paddingTop:10,borderTop:"0.5px dashed var(--dsw-alias-border-l4)"},fieldLabel={fontSize:13,color:"var(--dsw-alias-label-secondary)",overflowWrap:"anywhere"},textarea={boxSizing:"border-box",width:"100%",minHeight:64,padding:"7px 10px",border:"0.5px solid var(--dsw-alias-border-l4)",borderRadius:8,background:"var(--dsw-alias-bg-layer-1)",color:"var(--dsw-alias-label-primary)",font:"inherit",fontSize:14,lineHeight:1.5,resize:"vertical"},footer={display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginTop:20,paddingTop:12,borderTop:"1px solid var(--dsw-alias-border-l2)"},actions={display:"flex",alignItems:"center",gap:8},statusText={margin:0,fontSize:13,color:"var(--dsw-alias-label-secondary)"},issueList={margin:"8px 0 0",paddingInlineStart:20,fontSize:13},issueRejected={color:"var(--dsw-alias-label-error, var(--dsw-alias-label-primary))"},issueWarning={color:"var(--dsw-alias-label-secondary)"},issuePath={fontFamily:"var(--dsw-font-family-mono, monospace)",fontSize:12,color:"var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary))"},divider={margin:"14px 0",border:"none",borderTop:"1px solid var(--dsw-alias-border-l2)"};var import_dsh_client_ui_primitives5=require("@deepseek-ai/dsh-client-ui-primitives");var import_dsh_client_ui_primitives3=require("@deepseek-ai/dsh-client-ui-primitives");var import_jsx_runtime7=require("react/jsx-runtime");function IndependentJudgmentRow({t,checked,disabled,saving,sealed,onChange}){let state=t(saving?"persona.independentJudgmentSaving":checked?"persona.independentJudgmentOn":"persona.independentJudgmentOff"),hint2=sealed?t("persona.independentJudgmentHint"):`${t("persona.independentJudgmentHint")} ${t("persona.independentJudgmentPendingSeal")}`;return(0,import_jsx_runtime7.jsxs)("div",{style:toggleCard,children:[(0,import_jsx_runtime7.jsx)("div",{style:toggleText,children:(0,import_jsx_runtime7.jsxs)("span",{style:headingWithHint,children:[t("persona.independentJudgment"),(0,import_jsx_runtime7.jsx)(InfoHint,{label:hint2})]})}),(0,import_jsx_runtime7.jsxs)("div",{style:toggleState,children:[(0,import_jsx_runtime7.jsx)("span",{children:state}),(0,import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives3.Switch,{checked,disabled,label:t("persona.independentJudgment"),title:hint2,onChange})]})]})}var import_react7=require("react"),import_dsh_client_ui_primitives4=require("@deepseek-ai/dsh-client-ui-primitives");var import_jsx_runtime8=require("react/jsx-runtime");function Marked({marker:marker2,itemId,children}){return(0,import_jsx_runtime8.jsx)("span",{"data-persona-action":marker2,"data-persona-item":itemId,children})}function renameIssueKey(issue){return issue==="empty"?"persona.rename.empty":issue==="unchanged"?"persona.rename.unchanged":issue==="reserved"?"persona.rename.reserved":"persona.rename.duplicate"}function ContentCell({name:name2,itemId,children}){return(0,import_jsx_runtime8.jsx)("span",{"data-persona-content":itemId,"data-persona-editor":name2,style:editorCell,children})}function NameCell({t,controller,disabled,state,itemId,name:name2,locked,renameable}){let form=state.renaming;return renameable&&form!==void 0&&form.itemId===itemId&&form!==void 0?(0,import_jsx_runtime8.jsx)("span",{"data-persona-cell":"name","data-persona-item":itemId,"data-persona-editor":"rename","data-persona-rename":itemId,style:editorCell,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Input,{value:form.name,placeholder:t("persona.fieldKey"),"aria-label":t("persona.rename"),disabled,onChange:event=>controller.setRenameName(event.target.value)})}):(0,import_jsx_runtime8.jsx)("span",{"data-persona-cell":"name","data-persona-item":itemId,...locked===void 0?{}:{"data-locked":locked?"true":"false"},style:fieldLabel,children:name2})}function ActionsCell({t,controller,disabled,state,itemId,renameable,deletable}){let form=state.renaming,renaming=renameable&&form!==void 0&&form.itemId===itemId,issue=renaming?renameIssue(state.draft,itemId,form.name):void 0;return renaming&&form!==void 0?(0,import_jsx_runtime8.jsxs)("div",{"data-persona-cell":"actions","data-persona-actions":itemId,style:itemActions,children:[(0,import_jsx_runtime8.jsx)(Marked,{marker:"rename-confirm",itemId,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button,{size:"sm",variant:"primary",disabled:disabled||issue!==void 0,onClick:()=>controller.confirmRename(),children:t("persona.renameConfirm")})}),(0,import_jsx_runtime8.jsx)(Marked,{marker:"rename-cancel",itemId,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button,{size:"sm",variant:"ghost",disabled,onClick:()=>controller.cancelRename(),children:t("persona.cancel")})})]}):(0,import_jsx_runtime8.jsxs)("div",{"data-persona-cell":"actions","data-persona-actions":itemId,style:itemActions,children:[renameable?(0,import_jsx_runtime8.jsx)(Marked,{marker:"rename",itemId,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button,{variant:"ghost",size:"sm",disabled,onClick:()=>controller.beginRename(itemId),children:t("persona.rename")})}):null,deletable?(0,import_jsx_runtime8.jsx)(Marked,{marker:"delete",itemId,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button,{variant:"ghost",size:"sm",disabled,onClick:()=>controller.requestDelete(itemId),children:t("persona.remove")})}):null]})}function DeleteConfirm({t,controller,disabled,itemId,name:name2}){return(0,import_jsx_runtime8.jsxs)("div",{style:{...deleteBand,gridColumn:"1 / -1"},"data-persona-action":"delete-confirm-band","data-persona-item":itemId,children:[(0,import_jsx_runtime8.jsx)("span",{children:t("persona.deleteConfirm",{name:name2})}),(0,import_jsx_runtime8.jsx)(Marked,{marker:"delete-confirm",itemId,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button,{size:"sm",variant:"primary",disabled,onClick:()=>controller.confirmDelete(),children:t("persona.deleteConfirmYes")})}),(0,import_jsx_runtime8.jsx)(Marked,{marker:"delete-cancel",itemId,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button,{size:"sm",variant:"ghost",disabled,onClick:()=>controller.cancelDelete(),children:t("persona.cancel")})})]})}function RenameIssueBand({t,itemId,issue}){return(0,import_jsx_runtime8.jsx)("span",{style:{...renameIssueText,gridColumn:"1 / -1"},"data-persona-rename-issue":issue,"data-persona-item":itemId,children:t(renameIssueKey(issue))})}function RenameIssueBandIfAny({t,state,itemId}){let form=state.renaming;if(form===void 0||form.itemId!==itemId)return null;let issue=renameIssue(state.draft,itemId,form.name);return issue===void 0?null:(0,import_jsx_runtime8.jsx)(RenameIssueBand,{t,itemId,issue})}function IdentityFieldCells({t,controller,disabled,state,index}){let field=state.draft.identityCard.fields[index];if(field===void 0)return null;let itemId=identityItemId(index),pending2=state.pendingDelete===itemId,deletable=canDeleteItem(state.draft,itemId),renameable=canRenameItem(state.draft,itemId);return(0,import_jsx_runtime8.jsxs)(import_react7.Fragment,{children:[(0,import_jsx_runtime8.jsx)(NameCell,{t,controller,disabled,state,itemId,name:field.key,renameable}),(0,import_jsx_runtime8.jsx)(ContentCell,{name:"value",itemId,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Input,{value:field.value,placeholder:t("persona.fieldValue"),"aria-label":field.key===""?t("persona.fieldValue"):field.key,disabled,onChange:event=>controller.setIdentityValue(index,event.target.value)})}),(0,import_jsx_runtime8.jsx)(ActionsCell,{t,controller,disabled,state,itemId,renameable,deletable}),pending2?(0,import_jsx_runtime8.jsx)(DeleteConfirm,{t,controller,disabled,itemId,name:field.key===""?t("persona.fieldValue"):field.key}):null,(0,import_jsx_runtime8.jsx)(RenameIssueBandIfAny,{t,state,itemId})]})}function IdentityFields({t,controller,disabled,state}){let shared={t,controller,disabled,state};return(0,import_jsx_runtime8.jsxs)("div",{style:itemList,"data-persona-list":"identity",children:[state.draft.identityCard.fields.map((field,index)=>(0,import_jsx_runtime8.jsx)(IdentityFieldCells,{...shared,index},`field-${index}`)),(0,import_jsx_runtime8.jsx)(AddEntry,{...shared,kind:"identity",openLabel:t("persona.addField"),nameLabel:t("persona.fieldKey"),valueLabel:t("persona.fieldValue")})]})}function MutableSectionCells({t,controller,disabled,state,section}){let itemId=sectionItemId(section.title),pending2=state.pendingDelete===itemId,deletable=canDeleteItem(state.draft,itemId),renameable=canRenameItem(state.draft,itemId),text=section.items.join(`
|
|
10
|
+
`);return(0,import_jsx_runtime8.jsxs)(import_react7.Fragment,{children:[(0,import_jsx_runtime8.jsx)(NameCell,{t,controller,disabled,state,itemId,name:section.title,locked:!deletable,renameable}),(0,import_jsx_runtime8.jsx)(ContentCell,{name:"section",itemId,children:(0,import_jsx_runtime8.jsx)("textarea",{style:textarea,value:text,placeholder:t("persona.emptyValue"),disabled,"aria-label":section.title,onChange:event=>controller.setSectionText(section.title,event.target.value)})}),(0,import_jsx_runtime8.jsx)(ActionsCell,{t,controller,disabled,state,itemId,renameable,deletable}),pending2?(0,import_jsx_runtime8.jsx)(DeleteConfirm,{t,controller,disabled,itemId,name:section.title}):null,(0,import_jsx_runtime8.jsx)(RenameIssueBandIfAny,{t,state,itemId})]})}function MutableFields({t,controller,disabled,state}){let shared={t,controller,disabled,state};return(0,import_jsx_runtime8.jsxs)("div",{style:itemList,"data-persona-list":"section",children:[orderedSections(state.draft).map(section=>(0,import_jsx_runtime8.jsx)(MutableSectionCells,{...shared,section},section.title)),(0,import_jsx_runtime8.jsx)(AddEntry,{...shared,kind:"section",openLabel:t("persona.addSection"),nameLabel:t("persona.sectionName"),valueLabel:t("persona.sectionContent"),multiline:!0})]})}function AddEntry({t,controller,disabled,state,kind,openLabel,nameLabel:nameLabel2,valueLabel,multiline=!1}){let form=state.addForm;if(form===void 0||form.kind!==kind)return(0,import_jsx_runtime8.jsx)("div",{style:{gridColumn:"1 / -1"},"data-persona-add-open":kind,children:(0,import_jsx_runtime8.jsx)(Marked,{marker:"add-open",children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button,{variant:"outline",size:"sm",disabled,onClick:()=>controller.openAdd(kind),children:openLabel})})});let ready=addFormReady(form);return(0,import_jsx_runtime8.jsx)("div",{style:addBand,"data-persona-add":kind,children:(0,import_jsx_runtime8.jsxs)("div",{style:itemGrid,children:[(0,import_jsx_runtime8.jsx)("span",{"data-persona-editor":"add-name",style:editorCell,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Input,{value:form.name,placeholder:nameLabel2,"aria-label":nameLabel2,disabled,onChange:event=>controller.setAddField("name",event.target.value)})}),multiline?(0,import_jsx_runtime8.jsx)("textarea",{"data-persona-editor":"add-value",style:textarea,value:form.value,placeholder:valueLabel,"aria-label":valueLabel,disabled,onChange:event=>controller.setAddField("value",event.target.value)}):(0,import_jsx_runtime8.jsx)("span",{"data-persona-editor":"add-value",style:editorCell,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Input,{value:form.value,placeholder:valueLabel,"aria-label":valueLabel,disabled,onChange:event=>controller.setAddField("value",event.target.value)})}),(0,import_jsx_runtime8.jsxs)("div",{style:itemActions,children:[(0,import_jsx_runtime8.jsx)(Marked,{marker:"add-save",children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button,{size:"sm",variant:"primary",disabled:disabled||!ready,onClick:()=>{controller.commitAdd()},children:t("persona.save")})}),(0,import_jsx_runtime8.jsx)(Marked,{marker:"add-cancel",children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives4.Button,{size:"sm",variant:"ghost",disabled,onClick:()=>controller.cancelAdd(),children:t("persona.cancel")})})]})]})})}var import_jsx_runtime9=require("react/jsx-runtime");function CardSaveButton({t,controller,state}){let busy=state.saving;return(0,import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives5.Button,{size:"sm",variant:"primary",disabled:busy||!state.writable||!isDirty(state),onClick:()=>{controller.save()},children:t(busy?"persona.saving":"persona.save")})}function IdentityCardEditor({t,controller,state}){let sealed=state.stored.identityCard.sealedAt!=="";return(0,import_jsx_runtime9.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime9.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("persona.identityCard")," ",(0,import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives5.Tag,{tone:sealed?"neutral":"outline",children:t(sealed?"persona.sealed":"persona.unsealed")}),sealed?null:(0,import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives5.Button,{size:"sm",variant:"outline",disabled:state.saving||!state.writable,onClick:()=>{controller.seal()},children:t("persona.sealAction")}),(0,import_jsx_runtime9.jsx)(CardSaveButton,{t,controller,state}),(0,import_jsx_runtime9.jsx)(InfoHint,{label:t("persona.identityHint")})]}),(0,import_jsx_runtime9.jsx)(IndependentJudgmentRow,{t,checked:sealed&&state.independentJudgment,disabled:state.independentJudgmentSaving||!state.writable||!sealed,saving:state.independentJudgmentSaving,sealed,onChange:next=>{controller.setIndependentJudgment(next)}}),(0,import_jsx_runtime9.jsx)("hr",{style:divider}),(0,import_jsx_runtime9.jsx)(IdentityFields,{t,controller,disabled:state.saving||!state.writable,state})]})}function MutableCardEditor({t,controller,state}){let shared={t,controller,disabled:state.saving||!state.writable};return(0,import_jsx_runtime9.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime9.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("persona.mutableCard"),(0,import_jsx_runtime9.jsx)(InfoHint,{label:t("persona.mutableHint")}),(0,import_jsx_runtime9.jsx)(CardSaveButton,{t,controller,state})]}),(0,import_jsx_runtime9.jsx)(MutableFields,{...shared,state})]})}var import_jsx_runtime10=require("react/jsx-runtime"),axisBlock={padding:"10px 0",borderTop:"1px solid var(--dsw-alias-border-l2)"},axisHead={display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,fontSize:13},axisName={color:"var(--dsw-alias-label-primary)"},axisRange={color:"var(--dsw-alias-label-secondary)",fontSize:12},track2={position:"relative",height:6,margin:"10px 0 10px",borderRadius:3,background:"var(--dsw-alias-border-l2)"},span={position:"absolute",top:0,bottom:0,borderRadius:3,background:"var(--dsw-alias-brand-primary)",opacity:.4},marker={position:"absolute",top:-4,width:2,height:14,borderRadius:1,background:"var(--dsw-alias-label-primary)",transform:"translateX(-1px)"},reasonBox={...textarea,minHeight:44},pending={fontSize:13,color:"var(--dsw-alias-label-secondary)",margin:"6px 0 0"},percent=value=>`${Math.round(Math.min(1,Math.max(0,value))*100)}%`,rangeText=axis=>`${axis.min.toFixed(2)} – ${axis.max.toFixed(2)}`;function AxisTrack({axis}){let low=Math.min(axis.min,axis.max),high=Math.max(axis.min,axis.max);return(0,import_jsx_runtime10.jsxs)("div",{style:track2,"aria-hidden":!0,children:[(0,import_jsx_runtime10.jsx)("div",{style:{...span,left:percent(low),width:percent(high-low)}}),(0,import_jsx_runtime10.jsx)("div",{style:{...marker,left:percent(axis.value)}})]})}function CharacterCardEditor({t,controller,state}){let readOnly=state.saving||!state.writable,character=state.draft.character,ready=character.derivedAt!==""&&character.axes.length>0;return(0,import_jsx_runtime10.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime10.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("persona.characterCard"),(0,import_jsx_runtime10.jsx)(InfoHint,{label:t("persona.characterHint")}),(0,import_jsx_runtime10.jsx)(CardSaveButton,{t,controller,state})]}),ready?CHARACTER_AXES.map(key=>{let axis=character.axes.find(item=>item.key===key),label=CHARACTER_AXIS_TEXT[key].name;return axis===void 0?(0,import_jsx_runtime10.jsx)("div",{style:axisBlock,children:(0,import_jsx_runtime10.jsxs)("div",{style:axisHead,children:[(0,import_jsx_runtime10.jsx)("span",{style:axisName,children:label}),(0,import_jsx_runtime10.jsx)("span",{style:axisRange,children:t("persona.characterAxisMissing")})]})},key):(0,import_jsx_runtime10.jsxs)("div",{style:axisBlock,children:[(0,import_jsx_runtime10.jsxs)("div",{style:axisHead,children:[(0,import_jsx_runtime10.jsx)("span",{style:axisName,children:label}),(0,import_jsx_runtime10.jsxs)("span",{style:axisRange,children:[t("persona.characterRange")," ",rangeText(axis)]})]}),(0,import_jsx_runtime10.jsx)(AxisTrack,{axis}),(0,import_jsx_runtime10.jsx)("textarea",{style:reasonBox,value:axis.reason,rows:2,"aria-label":`${label} ${t("persona.characterReason")}`,placeholder:t("persona.characterReasonPlaceholder"),readOnly,onChange:event=>controller.setCharacterReason(key,event.target.value)})]},key)}):(0,import_jsx_runtime10.jsx)("p",{style:pending,children:t("persona.characterPending")})]})}var import_jsx_runtime11=require("react/jsx-runtime");function issueText(t,issue){let key=`persona.issue.${issue.code}`;return key in zh?t(key):issue.message}function IssueGroup({t,label,issues,tone,alert}){return issues.length===0?null:(0,import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment,{children:[(0,import_jsx_runtime11.jsx)("p",{style:{...statusText,marginTop:16},...alert===!0?{role:"alert"}:{},children:label}),(0,import_jsx_runtime11.jsx)("ul",{style:issueList,children:issues.map((issue,index)=>(0,import_jsx_runtime11.jsxs)("li",{style:tone,children:[issueText(t,issue)," ",(0,import_jsx_runtime11.jsx)("span",{style:issuePath,children:issue.path})]},`issue-${index}`))})]})}function StatusNotice({t,state}){return state.status==="loading"||state.status==="idle"?(0,import_jsx_runtime11.jsx)("p",{style:hint,children:t("persona.loading")}):state.status==="unavailable"?(0,import_jsx_runtime11.jsx)("p",{style:hint,children:t("persona.unavailable")}):state.status==="failed"?(0,import_jsx_runtime11.jsx)("p",{style:hint,role:"alert",children:t("persona.failed",{message:state.error??""})}):null}var import_jsx_runtime12=require("react/jsx-runtime");function IssueNotices({t,issues,error}){let rejected=issues.filter(issue=>issue.severity==="rejected"),warnings=issues.filter(issue=>issue.severity==="warning");return(0,import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment,{children:[(0,import_jsx_runtime12.jsx)(IssueGroup,{t,label:t("persona.blocked",{count:String(rejected.length)}),issues:rejected,tone:issueRejected,alert:!0}),(0,import_jsx_runtime12.jsx)(IssueGroup,{t,label:t("persona.warnings",{count:String(warnings.length)}),issues:warnings,tone:issueWarning}),error!==void 0?(0,import_jsx_runtime12.jsx)("p",{style:{...statusText,marginTop:12},role:"alert",children:t("persona.rejected",{message:error})}):null]})}function EditorFooter({t,controller,busy,writable,dirty,savedAt}){let status=writable?dirty?t("persona.dirty"):savedAt===""?"":t("persona.saved"):t("persona.readonly");return(0,import_jsx_runtime12.jsxs)("div",{style:footer,children:[(0,import_jsx_runtime12.jsx)("p",{style:statusText,children:status}),(0,import_jsx_runtime12.jsx)("div",{style:actions,children:(0,import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives6.Button,{variant:"ghost",size:"sm",disabled:busy,onClick:()=>{controller.load()},children:t("persona.reload")})})]})}function ReadyEditor({t,controller,state}){return(0,import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment,{children:[(0,import_jsx_runtime12.jsx)(IdentityCardEditor,{t,controller,state}),(0,import_jsx_runtime12.jsx)(MutableCardEditor,{t,controller,state}),(0,import_jsx_runtime12.jsx)(CharacterCardEditor,{t,controller,state}),(0,import_jsx_runtime12.jsx)(IssueNotices,{t,issues:state.issues,error:state.error}),(0,import_jsx_runtime12.jsx)(EditorFooter,{t,controller,busy:state.saving,writable:state.writable,dirty:isDirty(state),savedAt:state.savedAt})]})}function PersonaEditor({t,controller}){let state=(0,import_react8.useSyncExternalStore)(controller.subscribe,controller.getSnapshot,controller.getSnapshot);(0,import_react8.useEffect)(()=>{controller.load()},[controller]);let notice2=StatusNotice({t,state});return notice2!==null?notice2:(0,import_jsx_runtime12.jsx)(ReadyEditor,{t,controller,state})}var import_dsh_client_ui_primitives7=require("@deepseek-ai/dsh-client-ui-primitives");var tabBar={display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:8,marginTop:24};var import_jsx_runtime13=require("react/jsx-runtime"),TABS=[["persona","memory.tab.persona"],["emotion","emotion.tab"],["memory","memory.tab.memory"],["evolution","workbench.evolution.tab"]];function WorkbenchTabs({t,tab,onSelect}){return(0,import_jsx_runtime13.jsx)("nav",{style:tabBar,children:TABS.map(([id,labelKey])=>(0,import_jsx_runtime13.jsx)(import_dsh_client_ui_primitives7.Button,{size:"sm",variant:tab===id?"primary":"outline",style:{width:"100%"},"aria-current":tab===id?"page":void 0,onClick:()=>onSelect(id),children:t(labelKey)},id))})}var import_jsx_runtime14=require("react/jsx-runtime");function HumanityWorkbench({t,controller,emotion,memory,evolution}){let[tab,setTab]=(0,import_react9.useState)("persona"),body=tab==="persona"?(0,import_jsx_runtime14.jsx)(PersonaEditor,{t,controller}):tab==="emotion"?(0,import_jsx_runtime14.jsx)(EmotionPage,{t,controller:emotion}):tab==="memory"?(0,import_jsx_runtime14.jsx)(MemoryPage,{t,controller:memory}):(0,import_jsx_runtime14.jsx)(EvolutionPage,{t,controller:evolution});return(0,import_jsx_runtime14.jsx)("div",{style:page,children:(0,import_jsx_runtime14.jsxs)("div",{style:column,children:[(0,import_jsx_runtime14.jsx)("header",{children:(0,import_jsx_runtime14.jsxs)("div",{style:titleRow,children:[(0,import_jsx_runtime14.jsx)("h1",{style:title,children:"Humanity"}),(0,import_jsx_runtime14.jsx)(InfoHint,{label:t("workbench.titleHint"),side:"bottom"})]})}),(0,import_jsx_runtime14.jsx)(OverviewPanel,{t,memory,persona:controller}),(0,import_jsx_runtime14.jsx)(WorkbenchTabs,{t,tab,onSelect:setTab}),body]})})}var import_react10=require("react"),PersonaBoundary=class extends import_react10.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(error,info){try{console.error("[humanity] 人格面板渲染失败,已就地兜底(外壳不受影响)",error,info?.componentStack)}catch{}}render(){return this.state.failed?this.props.fallback:this.props.children}};var import_jsx_runtime15=require("react/jsx-runtime"),fallbackTranslate=key=>String(key);function FallbackNote({kind}){return(0,import_jsx_runtime15.jsx)("div",{style:{padding:16,color:"var(--dsw-alias-label-secondary)",fontSize:13,lineHeight:1.6},children:kind==="broken"?"Humanity 面板暂时无法显示(渲染出错,已就地拦截,不影响会话与对话)。可刷新页面重试;若持续出现,请到 **DSH 设置**里搜索 Humanity,关掉「人格」模块。":"Humanity 面板暂时无法显示(工作台未完全接上,已就地拦截,不影响会话与对话)。这一般发生在某个模块的通道还没就绪时,刷新页面即可。"})}function createWorkbenchSeat(controller,emotion,memory,evolution){return function(props){let t=typeof props?.t=="function"?props.t:fallbackTranslate,unwired=[controller,emotion,memory,evolution].some(seat=>seat==null);return(0,import_jsx_runtime15.jsx)(PersonaBoundary,{fallback:(0,import_jsx_runtime15.jsx)(FallbackNote,{kind:"broken"}),children:unwired?(0,import_jsx_runtime15.jsx)(FallbackNote,{kind:"unwired"}):(0,import_jsx_runtime15.jsx)(HumanityWorkbench,{t,controller,emotion,memory,evolution})})}}var name="humanity-client",inject=["slots","locale"];function registerLocale(ctx){ctx.effect(()=>{try{return ctx.locale.register(NS,{zh,en})}catch(error){return console.error("[humanity] 文案字典注册失败,将使用键名兜底",error),()=>{}}},"humanity: 文案字典")}function safeRegister(what2,register){try{register()}catch(error){console.error(`[humanity] ${what2} 注册失败,已跳过(不影响外壳与其它的槽位)`,error)}}function registerSidebarEntry(ctx){let icon=props=>(0,import_react12.createElement)(HumanityPanelIcon,props);safeRegister("侧栏入口",()=>ctx.slots.inject("sidebar.panellist",()=>ctx.slots.register({name:"sidebar.panellist",id:WORKBENCH_ID,order:60,label:PANEL_LABEL},icon)))}function registerWorkbench(ctx,seat){safeRegister("主面板",()=>ctx.slots.inject("main",()=>ctx.slots.register({name:"main",key:WORKBENCH_ID,locale:NS},seat)))}function apply(ctx){registerLocale(ctx);let controller=new PersonaWorkbenchController,emotion=new EmotionWorkbenchController,memory=new MemoryWorkbenchController,evolution=new EvolutionWorkbenchController;attachRemoteController(ctx,controller,PERSONA_NAMESPACE,"人格"),attachRemoteController(ctx,emotion,EMOTION_NAMESPACE,"情绪"),attachRemoteController(ctx,memory,MEMORY_NAMESPACE,"记忆",{pollMs:12e4}),attachRemoteController(ctx,evolution,EVOLUTION_NAMESPACE,"自进化",{pollMs:6e4}),registerSidebarEntry(ctx),registerWorkbench(ctx,createWorkbenchSeat(controller,emotion,memory,evolution))}
|
|
4310
11
|
|
|
4311
12
|
return module.exports;
|
|
4312
13
|
}
|