deepseek-harness-humanity 0.9.74 → 0.10.28

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/lib/client.js CHANGED
@@ -5,9 +5,9 @@ window.__ModuleLoader__.load({
5
5
  factory: (require) => {
6
6
  var module = { exports: {} };
7
7
  var exports = module.exports;
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))}
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,{AutonomyPage:()=>AutonomyPage,DEFAULT_PAGE:()=>DEFAULT_PAGE,EMOTION_NAMESPACE:()=>EMOTION_NAMESPACE,EVOLUTION_NAMESPACE:()=>EVOLUTION_NAMESPACE,EmotionPage:()=>EmotionPage,EmotionWorkbenchController:()=>EmotionWorkbenchController,EvolutionWorkbenchController:()=>EvolutionWorkbenchController,HUMANITY_NAMESPACE:()=>HUMANITY_NAMESPACE,HumanityPanelIcon:()=>HumanityPanelIcon,IdentityCardPage:()=>IdentityCardPage,MEMORY_NAMESPACE:()=>MEMORY_NAMESPACE,MODES:()=>MODES,MemoryPage:()=>MemoryPage,MemoryWorkbenchController:()=>MemoryWorkbenchController,OverviewPage:()=>OverviewPage,PAGES:()=>PAGES,PERSONA_NAMESPACE:()=>PERSONA_NAMESPACE,PersonaBoundary:()=>PersonaBoundary,PersonaWorkbenchController:()=>PersonaWorkbenchController,SettingsPage:()=>SettingsPage,SettingsWorkbenchController:()=>SettingsWorkbenchController,SoulPage:()=>SoulPage,Workbench:()=>Workbench,ageOf:()=>ageOf,apply:()=>apply,asEmotionDocument:()=>asEmotionDocument,asMemoryDocument:()=>asMemoryDocument,birthDateOf:()=>birthDateOf,createWorkbenchSeat:()=>createWorkbenchSeat,inject:()=>inject,name:()=>name,policyOf:()=>policyOf,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),request:{op:asString(raw.request?.op),value:asString(raw.request?.value)},history:{points:(Array.isArray(raw.history?.points)?raw.history.points:[]).map(entry=>{let item=entry??{},at=asString(item.at),values=Array.isArray(item.values)?item.values:[];if(at!=="")return{at,values:values.map(value2=>asNumber(value2))}}).filter(entry=>entry!==void 0)}}}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;async setCharge(kind,target,intensity){return this.send("set",{kind,target,intensity})}async setWarmth(warmth){return this.send("warmth",String(Math.round(warmth)))}async setSensitivity(kind,target,level){return this.send("sensitivity",{kind,target,level})}async send(op,value){let channel=this.channel;if(channel===void 0)return!1;let described;try{described=await channel.describe()}catch(error){return this.set({...this.snapshot,error:error instanceof Error?error.message:String(error)}),!1}if(described==null||described.ok!==!0)return this.set({...this.snapshot,error:described?.error?.message??"宿主没有返回可用的数据"}),!1;let view=described.value.namespaces.find(entry=>entry?.ns===EMOTION_NAMESPACE);if(view===void 0)return!1;let payload=typeof value=="string"?value:JSON.stringify(value);try{let result=await channel.update(EMOTION_NAMESPACE,{request:{op,value:payload}},view.revision);if(result==null||result.ok!==!0)return this.set({...this.snapshot,error:result?.error?.message??"写入被拒绝"}),!1}catch(error){return this.set({...this.snapshot,error:error instanceof Error?error.message:String(error)}),!1}return await this.load({quiet:!0}),!0}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:""},timeBase:{effective:"",source:"",learnedAt:""},diaryStats:{total:0,opened:0},reminders:[],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:{},tb=typeof raw.timeBase=="object"&&raw.timeBase!==null?raw.timeBase:{},ds=typeof raw.diaryStats=="object"&&raw.diaryStats!==null?raw.diaryStats:{},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:""},timeBase:{effective:typeof tb.effective=="string"?tb.effective:"",source:typeof tb.source=="string"?tb.source:"",learnedAt:typeof tb.learnedAt=="string"?tb.learnedAt:""},diaryStats:{total:typeof ds.total=="number"&&Number.isFinite(ds.total)?ds.total:0,opened:typeof ds.opened=="number"&&Number.isFinite(ds.opened)?ds.opened:0},reminders:(Array.isArray(raw.reminders)?raw.reminders:[]).map(entry=>{let item=entry??{};return{title:typeof item.title=="string"?item.title:"",at:typeof item.at=="string"?item.at:"",kind:typeof item.kind=="string"?item.kind:""}}).filter(item=>item.title!==""),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 setEnergy(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:"energy",value:String(Math.round(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 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",PAGES=["overview","soul","identity","emotion","memory","autonomy","settings"],DEFAULT_PAGE="overview";var emotionZh={"emotion.tab":"情绪","emotion.title":"它此刻","emotion.now.title":"此刻的情绪","emotion.block.title":"情绪","emotion.sensitivityFactor":"磨出的敏感:×{factor} 倍(因为:{cause})","emotion.sensitivityNone":"磨出的敏感:还没磨出来(×{factor} 倍)","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.now.title":"Right now","emotion.block.title":"Emotion","emotion.sensitivityFactor":"Sensitivity: ×{factor} (because: {cause})","emotion.sensitivityNone":"Sensitivity: not worn in yet (×{factor})","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 pagesZh={"page.nav":"工作台页面","page.overview":"概览","page.soul":"灵魂","page.identity":"身份卡","page.emotion":"情绪","page.memory":"记忆","page.autonomy":"自主","page.settings":"设置","page.overviewHint":"她此刻的样子:她是谁、什么心情、在做什么、攒下了多少。一屏读完。","page.soulHint":"她是谁:底色与性格的四根轴。底色对 Agent 封存,只有你能改。","page.identityHint":"她以外的人。先立板块,内容以后再拆。","page.emotionHint":"它此刻的心情,全由她的经历算出来。标准与沉浸模式下这一页只看不改。","page.memoryHint":"她记得的事,一条时间线。可以删一条,也可以看一条她本来不想说的。","page.autonomyHint":"她自己的时间:醒来、写日记、给你留话、自己攒起来的东西。","page.settingsHint":"她怎么运行:模式、时间基准、四个模块的开关与参数。改完立刻生效。","mode.immersive":"沉浸","mode.standard":"标准","mode.lab":"实验","mode.immersiveHint":"沉浸:只读。除了时区、她的房间、一天醒几次、记忆条数与独立判断,别处都改不了。","mode.standardHint":"标准:常规编辑。人格、信息、性格理由、记忆删除、日记翻阅都开放。","mode.labHint":"实验:在标准之上,连算出来的中间值也能直接写(情绪强度、敏感、关系温度、精力)。","overview.identity":"她是谁","overview.now":"她此刻","overview.movement":"她的动向","overview.collection":"她的积累","overview.name":"姓名","overview.gender":"性别","overview.age":"年龄","overview.ageHint":"从她人格封存那一刻算起 —— 封存才是她真正开始过日子的时刻。","overview.language":"语言","overview.emotion":"当前情绪","overview.emotionHint":"此刻最强的那一条(强度 0 的不算)。","overview.emotionCalm":"现在没有明显的情绪","overview.warmth":"关系温度","overview.warmthHint":"你们之间的暖度,0–100,会慢慢回到基线。","overview.sleep":"现在","overview.nextWake":"下一次醒","overview.nextWakeHint":"她自己排的下一次醒来时间。你正在说话时闹钟会被压着,这里是压完之后的时刻。","overview.tell":"她留的话","overview.tellEmpty":"暂时没有","overview.tellHint":"她主动留给你、还没送出去或者你还没看的那一句。","overview.memory":"记忆","overview.memoryValue":"{count} 条(公开 {publicCount} · 隐私 {privateCount})","overview.memoryHint":'她自己的经历账里现在有多少条;公开与隐私按"说出来要付多大代价"分。',"overview.diary":"日记","overview.diaryValue":"{count} 篇(看过 {opened})","overview.diaryHint":'她一共写了多少天;"看过"是你翻开过的天数。',"soul.fixedInfo.title":"基本信息","soul.language":"语言","soul.age.title":"她多大了","soul.age.unborn":"还没出生(人格未封存)","soul.age.days":"{days} 天","soul.age.yearsMonths":"{years} 岁 {months} 个月","soul.age.hint":"从人格封存那一刻算起 —— 记忆、情绪、她自己的时间都从那时开始。","soul.birthday":"生日","soul.birthdayHint":"留空 = 按她人格封存那一刻算。迁移换机器、重装、或者封存时间被重置之后,在这里填回真实的那一天,年龄不会被打回零。","soul.birthdayUnset":"按封存时刻算","soul.characterValue":"此刻的值","identity.standInNote":"这一页现在装的还是「她怎么跟你相处」(称呼、说话风格、行为边界、关系)。「你是谁」的档案(姓名、职业、生日、家人)系统里还没有专门的地方放。","autonomy.reminders.title":"她给你排的事","autonomy.reminders.hint":"她自己用定时任务建出来的提醒(比如提醒你吃药)。她自己那三条固定通道——醒来、写日记、主动找你——不算在这里,那是机制。","autonomy.reminders.empty":"她还没给你排过事。","autonomy.reminders.repeating":"循环","emotion.setValue":"直接填","memory.strength":"强度","settings.mode.title":"模式","settings.mode.hint":"决定这一整块界面能改什么。任何模式下都能切回来。","settings.time.title":"时间基准","settings.time.auto":"时区自动跟随浏览器","settings.time.autoHint":"开:每次网页对话时按你浏览器的时区校准。关:用下面填的固定时区。","settings.time.fixed":"固定时区","settings.time.fixedHint":"IANA 时区名,例如 Asia/Shanghai。只在自动跟随关掉时生效。","settings.time.fixedPlaceholder":"例如 Asia/Shanghai","settings.time.effective":"现在实际是","settings.time.effectiveHint":'她记日子、算"今天/昨天"、排醒来时间用的就是这个时区。它是结果,不是偏好:自动跟随时由你浏览器的上报决定。',"settings.time.unknown":"还不知道(还没收到过网页端的时区)","settings.time.source.auto":"跟浏览器学的","settings.time.source.manual":"你在上面指定的","settings.time.source.env":"部署环境指定的","settings.time.source.default":"系统默认","settings.persona.title":"人格","settings.persona.enabled":"人格模块","settings.persona.enabledHint":"关掉后不再注入人格,已有数据一律保留。","settings.persona.retention":"历史保留","settings.persona.retentionHint":"被改名、被删掉的旧内容留多久。0 表示永久保留。","settings.emotion.title":"情绪","settings.emotion.enabled":"情绪模块","settings.emotion.enabledHint":"关掉后不再评估、不再注入,已有状态保留。","settings.memory.title":"记忆","settings.memory.enabled":"记忆模块","settings.memory.enabledHint":"关掉后不再写、不再注入,已有记忆保留。","settings.memory.maxInject":"每轮带进对话","settings.memory.maxInjectHint":"每轮最多把几条记忆带进对话(0–3)。","settings.memory.decay":"记忆随时间变淡","settings.memory.decayHint":"关掉后强度不再随时间下降(只在调试时用)。","settings.autonomy.title":"自主","settings.autonomy.enabled":"自主模块","settings.autonomy.enabledHint":"关掉后她不醒来、不写日记,已有日记与记忆保留。","settings.autonomy.wakes":"一天最多醒几次","settings.autonomy.wakesHint":"上限,不是配额:累了就少醒。0 = 只能手动叫醒。","settings.autonomy.minGap":"两次醒来的最短间隔","settings.autonomy.maxGap":"两次醒来的最长间隔","settings.autonomy.gapHint":"实际间隔在这两条线之间随机取。","settings.autonomy.room":"她的房间","settings.autonomy.roomHint":"空 = 老位置;填名字 = 建在数据目录里;填完整路径 = 就用那条。改了等于搬家,旧会话留在原处。","settings.autonomy.roomPlaceholder":"名字,或完整路径","settings.unit.days":"天(0 = 永久保留)","settings.unit.entries":"条","settings.unit.timesPerDay":"次/天","settings.unit.minutes":"分钟","settings.loading":"正在读取配置…","settings.unavailable":"读不到配置:通道还没就绪(刷新页面试试)。","settings.failed":"读取失败:{message}","settings.saving":"正在保存…","settings.saved":"已保存","settings.readonly":"当前部署的设置是只读的,改不了。"},pagesEn={"page.nav":"Workbench pages","page.overview":"Overview","page.soul":"Soul","page.identity":"Identity","page.emotion":"Emotion","page.memory":"Memory","page.autonomy":"Autonomy","page.settings":"Settings","page.overviewHint":"Who she is, how she feels, what she is doing, what she has gathered — in one screen.","page.soulHint":"Who she is: the fixed layer and the four character axes. Only you can edit the fixed layer.","page.identityHint":"People other than her. The section exists first; the content will be split later.","page.emotionHint":"How she feels right now, all derived from her experience. Read-only except in Lab mode.","page.memoryHint":"What she remembers, as one timeline. You can delete one, or see one she would not say.","page.autonomyHint":"Her own time: waking up, writing her diary, leaving you a word, gathering her own things.","page.settingsHint":"How she runs: mode, time base, and the four modules. Changes take effect immediately.","mode.immersive":"Immersive","mode.standard":"Standard","mode.lab":"Lab","mode.immersiveHint":"Immersive: read-only. Only time zone, her room, wakes per day, memory count and independent judgment can change.","mode.standardHint":"Standard: normal editing. Persona, info, character reasons, memory deletion and diary access are open.","mode.labHint":"Lab: on top of standard, the computed intermediate values can be written directly.","overview.identity":"Who she is","overview.now":"Right now","overview.movement":"What comes next","overview.collection":"What she has gathered","overview.name":"Name","overview.gender":"Gender","overview.age":"Age","overview.ageHint":"Counted from the moment her persona was sealed — that is when she really started living.","overview.language":"Language","overview.emotion":"Current emotion","overview.emotionHint":"The strongest one right now (zero intensity does not count).","overview.emotionCalm":"Nothing strong right now","overview.warmth":"Warmth","overview.warmthHint":"How warm things are between you, 0–100; it drifts back to its baseline.","overview.sleep":"State","overview.nextWake":"Next waking","overview.nextWakeHint":"Her own next scheduled waking. While you are talking the alarm is held back; this is the held-back time.","overview.tell":"Left a word","overview.tellEmpty":"Nothing yet","overview.tellHint":"What she left for you but has not sent, or you have not read.","overview.memory":"Memory","overview.memoryValue":"{count} ({publicCount} open · {privateCount} private)","overview.memoryHint":"How many entries her own experience log holds; open vs private follows the cost of saying it.","overview.diary":"Diary","overview.diaryValue":"{count} ({opened} read)","overview.diaryHint":'How many days she has written a diary; "read" counts the days you opened.',"soul.fixedInfo.title":"Basics","soul.language":"Language","soul.age.title":"How old she is","soul.age.unborn":"Not born yet (persona unsealed)","soul.age.days":"{days} days","soul.age.yearsMonths":"{years}y {months}m","soul.age.hint":"Counted from the moment the persona was sealed — memory, emotion and her own time all start there.","soul.birthday":"Birthday","soul.birthdayHint":"Leave empty to count from the persona seal. After a migration or reinstall you can put the real day back here so the age does not reset.","soul.birthdayUnset":"from the seal time","soul.characterValue":"Current value","identity.standInNote":'This page currently holds "how she gets along with you" (form of address, speaking style, boundaries, relationship). There is no dedicated place yet for "who you are" (name, job, birthday, family).',"autonomy.reminders.title":"Things she scheduled for you","autonomy.reminders.hint":"Reminders she created with scheduled tasks (e.g. telling you to take medicine). Her own three channels (waking, diary, reaching out) are not listed — those are mechanism.","autonomy.reminders.empty":"She has not scheduled anything for you yet.","autonomy.reminders.repeating":"repeating","emotion.setValue":"Set it","memory.strength":"Strength","settings.mode.title":"Mode","settings.mode.hint":"Decides what this workbench lets you change. You can always switch back.","settings.time.title":"Time base","settings.time.auto":"Follow the browser time zone","settings.time.autoHint":"On: recalibrate to your browser time zone on every web chat. Off: use the fixed zone below.","settings.time.fixed":"Fixed time zone","settings.time.fixedHint":"IANA name, e.g. Asia/Shanghai. Only used when auto-follow is off.","settings.time.fixedPlaceholder":"e.g. Asia/Shanghai","settings.time.effective":"Actually in effect","settings.time.effectiveHint":'This is the zone she uses for days, "today/yesterday" and waking times. It is a result, not a preference.',"settings.time.unknown":"Unknown yet (no web time zone has been reported)","settings.time.source.auto":"learned from browser","settings.time.source.manual":"set by you","settings.time.source.env":"set by deployment","settings.time.source.default":"system default","settings.persona.title":"Persona","settings.persona.enabled":"Persona module","settings.persona.enabledHint":"Off: the persona is no longer injected; existing data is kept.","settings.persona.retention":"History retention","settings.persona.retentionHint":"How long renamed or deleted content is kept. 0 means keep forever.","settings.emotion.title":"Emotion","settings.emotion.enabled":"Emotion module","settings.emotion.enabledHint":"Off: no more appraisal and no injection; existing state is kept.","settings.memory.title":"Memory","settings.memory.enabled":"Memory module","settings.memory.enabledHint":"Off: nothing more is written or injected; existing memory is kept.","settings.memory.maxInject":"Entries per turn","settings.memory.maxInjectHint":"How many memories may enter the conversation per turn (0–3).","settings.memory.decay":"Memory fades over time","settings.memory.decayHint":"Off: strength stops decaying (debug only).","settings.autonomy.title":"Autonomy","settings.autonomy.enabled":"Autonomy module","settings.autonomy.enabledHint":"Off: she stops waking and writing diaries; existing data is kept.","settings.autonomy.wakes":"Max wakings per day","settings.autonomy.wakesHint":"A ceiling, not a quota. 0 means manual waking only.","settings.autonomy.minGap":"Shortest gap between wakings","settings.autonomy.maxGap":"Longest gap between wakings","settings.autonomy.gapHint":"The actual gap is picked randomly between these two.","settings.autonomy.room":"Her room","settings.autonomy.roomHint":"Empty = legacy location; a name = under the data directory; a full path = use it as is. Changing it means moving; old sessions stay put.","settings.autonomy.roomPlaceholder":"A name, or a full path","settings.unit.days":"days (0 = keep forever)","settings.unit.entries":"entries","settings.unit.timesPerDay":"times/day","settings.unit.minutes":"minutes","settings.loading":"Reading configuration…","settings.unavailable":"Configuration unreadable: the channel is not ready (try reloading).","settings.failed":"Read failed: {message}","settings.saving":"Saving…","settings.saved":"Saved","settings.readonly":"This deployment serves settings read-only."};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.room.legacyName":"老位置(还没填过)","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.room.legacyName":"Legacy location (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.freshness":"新鲜度(绿=还牢 · 黄=在淡 · 红=快忘)","memory.stat.public":"公开","memory.stat.private":"隐私","memory.stat.today":"今天新增","memory.search.placeholder":"搜内容…","memory.filter.about":"关于谁","memory.filter.all":"全部","memory.sort":"排序","memory.sort.newest":"最新","memory.sort.strong":"最牢","memory.sort.weak":"最淡","memory.noMatch":"没有符合条件的条目。","memory.opened":"👁 你看过","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.freshness":"Freshness (green = holding, amber = fading, red = nearly gone)","memory.stat.public":"open","memory.stat.private":"private","memory.stat.today":"added today","memory.search.placeholder":"Search content…","memory.filter.about":"About","memory.filter.all":"All","memory.sort":"Sort","memory.sort.newest":"Newest","memory.sort.strong":"Strongest","memory.sort.weak":"Faintest","memory.noMatch":"Nothing matches.","memory.opened":"👁 You opened this","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,...pagesZh},en={...workbenchEn,...personaEn,...emotionEn,...memoryEn,...pagesEn};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=title2=>LOCKED_SECTION_TITLES.includes(title2);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=(title2,index)=>title2===""?`mutableLayer.sections[${index}]`:`mutableLayer.sections.${title2}`,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 title2 of LOCKED_SECTION_TITLES)!(prev===void 0||prev.mutableLayer.sections.some(section=>section.title===title2))||titles.has(title2)||issues.push({code:"mutable.section-locked-missing",path:`mutableLayer.sections.${title2}`,severity:"rejected",message:`「${title2}」是默认锁定项(底色 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:title2,items}=section;if(title2===""){items.length>0&&issues.push({code:"mutable.section-title-empty",path:sectionPath(title2,index),severity:"rejected",message:`信息有一节没有小标题(里面还有 ${items.length} 条内容),而**没有名字的小节不会进提示词**。请给它取个名字(自定义标题即可),或把这些条目并入已有小节。`});return}seen.has(title2)&&issues.push({code:"mutable.section-duplicate",path:sectionPath(title2,index),severity:"rejected",message:`信息出现重复小标题「${title2}」,同一类内容只能有一个当前快照。`}),seen.add(title2),CORE_KEYS.has(title2)&&issues.push({code:"mutable.core-key-shadowed",path:sectionPath(title2,index),severity:"rejected",message:`「${title2}」是底色字段名,不能作为信息小标题;底色只能由对方在 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=title2=>`section:${title2}`;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(row3=>row3.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(row3=>row3.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(row3=>row3.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(row3=>row3.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(title2=>({title:title2,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(title2=>{let found=sections.find(section=>section?.title===title2);return found===void 0?[]:[{title:title2,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 setCharacterNumber(draft,key,field,value){let axis=draft.character?.axes?.find(item=>item.key===key);axis!==void 0&&(axis[field]=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,title2){if(isLockedSectionTitle(title2))return;let at=draft.mutableLayer.sections.findIndex(section=>section.title===title2);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(row3=>row3.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,title2,text){let section=draft.mutableLayer.sections.find(entry=>entry.title===title2);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(title2,text){this.edit(draft=>setSectionText(draft,title2,text))}setCharacterReason(key,value){this.edit(draft=>setCharacterReason(draft,key,value))}setCharacterNumber(key,field,value){this.edit(draft=>setCharacterNumber(draft,key,field,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,private:0,public: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),openedAt:str(item.openedAt),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),private:num(stats2.private),public:stats2.public===void 0?num(stats2.total,entries.length):num(stats2.public)},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 setStrength(id,percent2){return this.command("strength",id,String(Math.round(percent2)))}async command(op,id,value=""){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,value},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","humanity-emotion"];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 INITIAL={status:"idle",writable:!1,config:void 0,revision:0,saving:!1,error:void 0,savedAt:""},SettingsWorkbenchController=class{state=INITIAL;channel;listeners=new Set;subscribe=listener=>(this.listeners.add(listener),()=>this.listeners.delete(listener));getSnapshot=()=>this.state;attach(channel){this.channel=channel,this.load({quiet:!0})}detach(){this.channel=void 0,this.update({status:"unavailable",writable:!1})}async load(options={}){let channel=this.channel;if(channel===void 0){this.update({status:"unavailable",writable:!1});return}options.quiet!==!0&&this.update({status:"loading",error:void 0});let result;try{result=await channel.describe()}catch(error){this.update({status:options.quiet===!0?this.state.status:"failed",error:error instanceof Error?error.message:String(error)});return}if(!result.ok){this.update({status:options.quiet===!0?this.state.status:"failed",error:result.error.message});return}let view=result.value.namespaces.find(entry=>entry.ns===HUMANITY_NAMESPACE);if(view===void 0){this.update({status:"unavailable",writable:!1});return}this.update({status:"ready",writable:result.value.writable,config:view.value,revision:view.revision,error:void 0})}async patch(patch){let channel=this.channel;if(channel===void 0)return this.update({error:"通道未就绪"}),!1;if(this.state.writable!==!0)return!1;this.update({saving:!0,error:void 0});let result;try{result=await channel.update(HUMANITY_NAMESPACE,patch,this.state.revision)}catch(error){return this.update({saving:!1,error:error instanceof Error?error.message:String(error)}),!1}return result.ok?(this.update({saving:!1,config:result.value.value,revision:result.value.revision,savedAt:new Date().toISOString()}),!0):(this.update({saving:!1,error:result.error.message}),!1)}async setMode(mode){return this.patch({workbenchMode:mode})}update(patch){this.state={...this.state,...patch};for(let listener of this.listeners)listener()}};var import_react2=require("react"),PersonaBoundary=class extends import_react2.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_dsh_client_ui_primitives9=require("@deepseek-ai/dsh-client-ui-primitives"),import_react11=require("react");var import_dsh_client_ui_primitives=require("@deepseek-ai/dsh-client-ui-primitives");var import_jsx_runtime2=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_runtime2.jsx)(import_dsh_client_ui_primitives.Tooltip,{label,side,delayMs,maxWidth:360,children:(0,import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.Button,{size:"sm",variant:"ghost",style:anchor,"aria-label":label,children:IconQuestion?(0,import_jsx_runtime2.jsx)(IconQuestion,{size:14}):(0,import_jsx_runtime2.jsx)("span",{"aria-hidden":!0,children:"?"})})})}var MODES=["immersive","standard","lab"];function policy(open){return{...{identityEdit:!1,mutableEdit:!1,seal:!1,characterReason:!1,characterRange:!1,characterValue:!1,memoryDelete:!1,memoryReveal:!1,diaryOpen:!1,growDrop:!1,stateValues:!1,moduleSwitch:!1,timeZone:!1,room:!1,wakes:!1,memoryInject:!1,independentJudgment:!1,advanced:!1,switchMode:!0},...open}}var POLICIES={immersive:policy({timeZone:!0,room:!0,wakes:!0,memoryInject:!0,independentJudgment:!0}),standard:policy({identityEdit:!0,mutableEdit:!0,seal:!0,characterReason:!0,memoryDelete:!0,memoryReveal:!0,diaryOpen:!0,growDrop:!0,moduleSwitch:!0,timeZone:!0,room:!0,wakes:!0,memoryInject:!0,independentJudgment:!0,advanced:!0}),lab:policy({identityEdit:!0,mutableEdit:!0,seal:!0,characterReason:!0,characterRange:!0,characterValue:!0,memoryDelete:!0,memoryReveal:!0,diaryOpen:!0,growDrop:!0,stateValues:!0,moduleSwitch:!0,timeZone:!0,room:!0,wakes:!0,memoryInject:!0,independentJudgment:!0,advanced:!0})};function policyOf(mode){return POLICIES[mode??"immersive"]??POLICIES.immersive}function modeLabelKey(mode){return mode==="immersive"?"mode.immersive":mode==="lab"?"mode.lab":"mode.standard"}function modeHintKey(mode){return mode==="immersive"?"mode.immersiveHint":mode==="lab"?"mode.labHint":"mode.standardHint"}var import_react3=require("react");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)"},toggleRow={display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"4px 0"},toggleText={display:"flex",flexDirection:"column",gap:2},toggleState={display:"flex",alignItems:"center",gap:8,color:"var(--dsw-alias-label-secondary)",fontSize:"0.9em"},navBar={display:"flex",alignItems:"center",gap:16,marginTop:24},navGrid={display:"grid",gridTemplateColumns:"repeat(7, minmax(0, 1fr))",gap:8,flex:1,minWidth:0};var pad=value=>String(value).padStart(2,"0");function stamp(iso){if(iso==="")return"—";let at=Date.parse(iso);if(!Number.isFinite(at))return"—";let date=new Date(at);return`${pad(date.getMonth()+1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`}var import_jsx_runtime3=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 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,canOpen}){let[confirming,setConfirming]=(0,import_react3.useState)(!1);return(0,import_jsx_runtime3.jsxs)("div",{style:{padding:"10px 0",borderBottom:"1px solid var(--dsw-alias-border-l2)"},children:[(0,import_jsx_runtime3.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,import_jsx_runtime3.jsx)("span",{style:{fontVariantNumeric:"tabular-nums"},children:item.date}),item.opened?(0,import_jsx_runtime3.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))]}):canOpen?confirming?(0,import_jsx_runtime3.jsxs)("span",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,import_jsx_runtime3.jsx)("span",{style:{fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.diary.confirm")}),(0,import_jsx_runtime3.jsx)("button",{type:"button",onClick:()=>{setConfirming(!1),onOpen(item.date)},children:t("workbench.evolution.diary.confirmYes")}),(0,import_jsx_runtime3.jsx)("button",{type:"button",onClick:()=>setConfirming(!1),children:t("workbench.evolution.diary.confirmNo")})]}):(0,import_jsx_runtime3.jsx)("button",{type:"button",onClick:()=>setConfirming(!0),children:t("workbench.evolution.diary.open")}):null]}),item.opened&&item.text!==""?(0,import_jsx_runtime3.jsx)("p",{style:{margin:"8px 0 0",whiteSpace:"pre-wrap",lineHeight:1.75},children:item.text}):null]})}function AutonomyPage({t,controller,policy:policy2=policyOf("immersive")}){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_runtime3.jsxs)(import_jsx_runtime3.Fragment,{children:[(0,import_jsx_runtime3.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime3.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.today"),(0,import_jsx_runtime3.jsx)(InfoHint,{label:t("workbench.evolution.todayHint")})]}),unavailable?(0,import_jsx_runtime3.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.metric.unavailable")}):status.started?(0,import_jsx_runtime3.jsxs)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"max-content 1fr",gap:"8px 16px"},children:[(0,import_jsx_runtime3.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.state")}),(0,import_jsx_runtime3.jsx)("dd",{style:{margin:0},children:status.sleeping?t("workbench.evolution.state.sleeping"):t("workbench.evolution.state.awake")}),(0,import_jsx_runtime3.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.energy")}),(0,import_jsx_runtime3.jsxs)("dd",{style:{margin:0,display:"flex",alignItems:"center",gap:8},children:[(0,import_jsx_runtime3.jsx)("span",{children:energyText(t,status.energy)}),policy2.stateValues?(0,import_jsx_runtime3.jsx)("input",{type:"number",min:0,max:100,step:1,style:{width:64},defaultValue:Math.round(status.energy),"aria-label":t("workbench.evolution.field.energy"),onKeyDown:event=>{event.key==="Enter"&&event.target.blur()},onBlur:event=>{let raw=Number(event.target.value);if(!Number.isFinite(raw))return;let next=Math.round(Math.min(100,Math.max(0,raw)));next!==Math.round(status.energy)&&controller.setEnergy(next)}}):null]}),(0,import_jsx_runtime3.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.wakes")}),(0,import_jsx_runtime3.jsxs)("dd",{style:{margin:0,display:"flex",alignItems:"center",gap:8},children:[(0,import_jsx_runtime3.jsx)("span",{children:t("workbench.evolution.wakesValue").replace("{count}",String(status.dayCount)).replace("{max}",String(status.maxPerDay))}),policy2.wakes?(0,import_jsx_runtime3.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)}}):null]}),(0,import_jsx_runtime3.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.lastWake")}),(0,import_jsx_runtime3.jsx)("dd",{style:{margin:0,fontVariantNumeric:"tabular-nums"},children:stamp(status.lastWakeAt)}),(0,import_jsx_runtime3.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.lastTurn")}),(0,import_jsx_runtime3.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_runtime3.jsx)("dt",{style:{color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.field.nextWake")}),(0,import_jsx_runtime3.jsxs)("dd",{style:{margin:0,fontVariantNumeric:"tabular-nums"},children:[stamp(status.nextAt),status.busy?(0,import_jsx_runtime3.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_runtime3.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.notStarted")}),status.lastError!==""?(0,import_jsx_runtime3.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_runtime3.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime3.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.room.title"),(0,import_jsx_runtime3.jsx)(InfoHint,{label:t("workbench.evolution.room.hint")})]}),(0,import_jsx_runtime3.jsx)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:policy2.room?(0,import_jsx_runtime3.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_runtime3.jsx)("span",{children:status.roomText===""?t("workbench.evolution.room.legacyName"):status.roomText})}),(0,import_jsx_runtime3.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_runtime3.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_runtime3.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime3.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.tell.title"),(0,import_jsx_runtime3.jsx)(InfoHint,{label:t("workbench.evolution.tell.hint")})]}),state.doc.tell.pending!==""?(0,import_jsx_runtime3.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_runtime3.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_runtime3.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_runtime3.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_runtime3.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.tell.empty")}):null]}),(0,import_jsx_runtime3.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime3.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("autonomy.reminders.title"),(0,import_jsx_runtime3.jsx)(InfoHint,{label:t("autonomy.reminders.hint")})]}),state.doc.reminders.length===0?(0,import_jsx_runtime3.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("autonomy.reminders.empty")}):(0,import_jsx_runtime3.jsx)("ul",{style:{margin:0,paddingLeft:18,lineHeight:1.8},children:state.doc.reminders.map((item,index)=>(0,import_jsx_runtime3.jsxs)("li",{children:[item.title,(0,import_jsx_runtime3.jsx)("span",{style:{marginLeft:8,fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:item.at===""?t("autonomy.reminders.repeating"):stamp(item.at)})]},`${item.title}-${String(index)}`))})]}),(0,import_jsx_runtime3.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime3.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.diary.title"),(0,import_jsx_runtime3.jsx)(InfoHint,{label:t("workbench.evolution.diary.hint")})]}),state.doc.notice!==""?(0,import_jsx_runtime3.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_runtime3.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_runtime3.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_runtime3.jsx)(DiaryRow,{t,item,onOpen:date=>controller.open(date),canOpen:policy2.diaryOpen},item.date))]}),(0,import_jsx_runtime3.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime3.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.grow.title"),(0,import_jsx_runtime3.jsx)(InfoHint,{label:t("workbench.evolution.grow.hint")})]}),state.doc.grow.lastRun.at!==""?(0,import_jsx_runtime3.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_runtime3.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.grow.empty")}):(0,import_jsx_runtime3.jsx)("ul",{style:{margin:0,paddingLeft:18,lineHeight:1.8},children:state.doc.grow.candidates.map((item,index)=>(0,import_jsx_runtime3.jsxs)("li",{children:[item.text,(0,import_jsx_runtime3.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))]}),policy2.growDrop?(0,import_jsx_runtime3.jsx)("button",{type:"button",style:{marginLeft:8,fontSize:12},onClick:()=>{controller.dropCandidate(item.text)},children:t("workbench.evolution.grow.drop")}):null]},`${item.text}-${String(index)}`))})]}),(0,import_jsx_runtime3.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime3.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.threads.title"),(0,import_jsx_runtime3.jsx)(InfoHint,{label:t("workbench.evolution.threads.hint")})]}),state.doc.threads.length===0?(0,import_jsx_runtime3.jsx)("p",{style:{margin:0,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.threads.empty")}):(0,import_jsx_runtime3.jsx)("ul",{style:{margin:0,paddingLeft:18,lineHeight:1.8},children:state.doc.threads.map(line=>(0,import_jsx_runtime3.jsx)("li",{children:line},line))})]}),(0,import_jsx_runtime3.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime3.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("workbench.evolution.works.title"),(0,import_jsx_runtime3.jsx)(InfoHint,{label:t("workbench.evolution.works.hint")})]}),state.doc.works.length===0?(0,import_jsx_runtime3.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_runtime3.jsxs)("div",{style:{padding:"8px 0",borderBottom:"1px solid var(--dsw-alias-border-l2)"},children:[(0,import_jsx_runtime3.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,import_jsx_runtime3.jsx)("span",{children:item.name}),(0,import_jsx_runtime3.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,import_jsx_runtime3.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_runtime3.jsx)("button",{type:"button",onClick:()=>{controller.download(item.name)},children:t("workbench.evolution.works.download")})]})]}),item.kind==="text"&&item.preview!==""?(0,import_jsx_runtime3.jsxs)("details",{style:{marginTop:6},children:[(0,import_jsx_runtime3.jsx)("summary",{style:{cursor:"pointer",fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:t("workbench.evolution.works.previewToggle")}),(0,import_jsx_runtime3.jsx)("pre",{style:{margin:"6px 0 0",whiteSpace:"pre-wrap",fontSize:13,lineHeight:1.7},children:item.preview})]}):(0,import_jsx_runtime3.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_react4=require("react");var EMOTION_KINDS=["joy","trust","fear","surprise","sadness","disgust","anger","anticipation"],EMOTION_TARGETS=["user","self","world"],EMOTION_TARGET_LABELS={user:"对TA",self:"对自己",world:""},EMOTION_LABELS={joy:"喜悦",trust:"信任",fear:"恐惧",surprise:"惊讶",sadness:"悲伤",disgust:"厌恶",anger:"愤怒",anticipation:"期待"};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 HISTORY_SLOT_COUNT=EMOTION_KINDS.length*EMOTION_TARGETS.length;function historySlotOf(kind,target){let kindAt=EMOTION_KINDS.indexOf(kind),targetAt=EMOTION_TARGETS.indexOf(target);return kindAt<0||targetAt<0?-1:kindAt*EMOTION_TARGETS.length+targetAt}var SAMPLE_TICK_MS=60*1e3,HISTORY_WINDOW_MS=1440*60*1e3,HISTORY_MAX_POINTS=120,HISTORY_BUCKET_MS=Math.floor(HISTORY_WINDOW_MS/HISTORY_MAX_POINTS);var import_jsx_runtime4=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"},chargeBlock={padding:"10px 0 2px",borderTop:"1px solid var(--dsw-alias-border-l1)"},meta={margin:"4px 0 0",color:"var(--dsw-alias-label-secondary)",fontSize:"0.9em"},chargeLine={display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},TIER_KEYS={burst:"emotion.tier.burst",clear:"emotion.tier.clear",faint:"emotion.tier.faint",calm:"emotion.tier.calm"};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)})}var TARGET_COLORS={user:"#4a9eff",self:"#3fb950",world:"#d29922"};function Sparkline({points,lines,nowMs,windowMs}){let startMs=nowMs-windowMs,xOf=iso=>{let at=Date.parse(iso);return Number.isFinite(at)?Math.max(0,Math.min(100,(at-startMs)/windowMs*100)):0},yOf=value=>56-Math.max(0,Math.min(100,value))/100*56;return(0,import_jsx_runtime4.jsxs)("svg",{viewBox:"0 0 100 56",preserveAspectRatio:"none",style:{display:"block",width:"100%",height:56,marginTop:6,border:"1px solid var(--dsw-alias-border-l2)",borderRadius:6,background:"var(--dsw-alias-bg-layer-1)"},"aria-hidden":!0,children:[[.25,.5,.75].map(ratio=>(0,import_jsx_runtime4.jsx)("line",{x1:0,x2:100,y1:56-ratio*56,y2:56-ratio*56,stroke:"var(--dsw-alias-border-l2)",strokeWidth:.5,vectorEffect:"non-scaling-stroke"},ratio)),lines.map(line=>(0,import_jsx_runtime4.jsx)("polyline",{points:points.map(point=>`${xOf(point.at).toFixed(2)},${yOf(point.values[line.slot]??0).toFixed(2)}`).join(" "),fill:"none",stroke:line.color,strokeWidth:1.4,vectorEffect:"non-scaling-stroke"},line.color))]})}function EmotionRow({t,kindLabel,main,now,editable,onSet,series,points,sensitivityHint}){let absent=main===void 0||main.intensity<=0,cur=main===void 0?0:Math.max(0,Math.min(100,main.intensity)),duration=main===void 0||absent?"":durationText(t,main.since,now),cause=main===void 0||main.cause===""?t("emotion.noCause"):main.cause;return(0,import_jsx_runtime4.jsxs)("div",{style:chargeBlock,children:[(0,import_jsx_runtime4.jsxs)("div",{style:chargeLine,children:[(0,import_jsx_runtime4.jsx)("span",{style:{fontWeight:absent?400:600,whiteSpace:"nowrap",minWidth:72},children:kindLabel}),(0,import_jsx_runtime4.jsx)("span",{style:{...meta,margin:0,flex:1,color:absent?"var(--dsw-alias-label-tertiary)":meta.color},children:absent?t("emotion.absent"):`${main?.targetLabel??""}${main?.targetLabel===""?"":" "}${t("emotion.cause")}:${cause}${duration===""?"":` · ${duration}`}`}),(0,import_jsx_runtime4.jsx)("span",{style:{fontSize:13,fontVariantNumeric:"tabular-nums",minWidth:56,textAlign:"right"},children:editable&&main!==void 0?(0,import_jsx_runtime4.jsx)("input",{type:"number",min:0,max:100,step:1,style:{width:56,textAlign:"right",fontVariantNumeric:"tabular-nums"},defaultValue:Math.round(cur),"aria-label":`${main.targetLabel}${kindLabel}`,onKeyDown:event=>{event.key==="Enter"&&event.target.blur()},onBlur:event=>{let raw=Number(event.target.value);if(!Number.isFinite(raw))return;let next=Math.round(Math.min(100,Math.max(0,raw)));next!==Math.round(cur)&&onSet(main.target,next)}}):Math.round(cur)}),(0,import_jsx_runtime4.jsx)("span",{style:{...meta,margin:0,minWidth:40},children:absent?"":t(TIER_KEYS[main.tier]??"emotion.tier.calm")}),(0,import_jsx_runtime4.jsx)(InfoHint,{label:sensitivityHint})]}),(0,import_jsx_runtime4.jsx)("div",{style:{...meta,margin:"6px 0 0",display:"flex",gap:14,flexWrap:"wrap"},children:series.map(line=>(0,import_jsx_runtime4.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[(0,import_jsx_runtime4.jsx)("span",{style:{width:8,height:8,borderRadius:4,background:line.value>0?line.color:"var(--dsw-alias-border-l3)"}}),line.label,(0,import_jsx_runtime4.jsx)("span",{style:{fontVariantNumeric:"tabular-nums"},children:Math.round(line.value)})]},line.target))}),(0,import_jsx_runtime4.jsx)(Sparkline,{points,lines:series.map(line=>({color:line.color,slot:line.slot})),nowMs:now,windowMs:HISTORY_WINDOW_MS})]})}function EmotionPage({t,controller,policy:policy2=policyOf("immersive")}){let state=(0,import_react4.useSyncExternalStore)(controller.subscribe,controller.getSnapshot,controller.getSnapshot);(0,import_react4.useEffect)(()=>{controller.load({quiet:!0});let timer=setInterval(()=>{controller.load({quiet:!0})},3e4);return()=>{clearInterval(timer)}},[controller]);let now=Date.now(),document2=state.document,paramsHint=[t("emotion.params.hint"),t("emotion.params.floor",{floor:RENDER_FLOOR}),t("emotion.params.tiers",{faint:tierAt("faint"),clear:tierAt("clear"),burst:tierAt("burst")}),t("emotion.params.sensitivity",{boost:(1+SENSITIVITY_MAX_BOOST).toFixed(1),hours:Math.round(SENSITIVITY_HALF_LIFE_MINUTES/60)}),t("emotion.params.soothe",{minutes:SOOTHE_QUIET_MINUTES})].join(" ");if(state.status==="loading")return(0,import_jsx_runtime4.jsx)("p",{style:subtitle,children:t("emotion.loading")});if(state.status==="unavailable")return(0,import_jsx_runtime4.jsx)("p",{style:subtitle,children:t("emotion.unavailable")});if(state.status==="failed")return(0,import_jsx_runtime4.jsx)("p",{style:subtitle,children:t("emotion.failed",{message:state.error??""})});if(document2===void 0)return null;let sensitivityHintOf=charge=>{let entry=charge===void 0?void 0:document2.sensitivities.find(item=>item.kind===charge.kind&&item.target===charge.target),factor=(1+SENSITIVITY_MAX_BOOST*(entry?.level??0)).toFixed(2);return entry===void 0?t("emotion.sensitivityNone",{factor}):t("emotion.sensitivityFactor",{factor,cause:entry.cause===""?t("emotion.noCause"):entry.cause})},targetTextOf=target=>target==="world"?"对事":EMOTION_TARGET_LABELS[target]??target,chartPoints=(()=>{if(document2.history.points.length>=2)return document2.history.points;let current=new Array(document2.history.points[0]?.values.length??0).fill(0);for(let[index,value]of(document2.history.points[0]?.values??[]).entries())current[index]=value;for(let charge of document2.charges){let slot=historySlotOf(charge.kind,charge.target);slot>=0&&(current[slot]=Math.round(charge.intensity))}return current.length===0?[]:[{at:new Date(now-HISTORY_WINDOW_MS).toISOString(),values:current},{at:new Date(now).toISOString(),values:current}]})();return(0,import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment,{children:[document2.perceived===""?null:(0,import_jsx_runtime4.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime4.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("emotion.perceived"),(0,import_jsx_runtime4.jsx)(InfoHint,{label:t("emotion.perceivedHint")})]}),(0,import_jsx_runtime4.jsx)("p",{style:{margin:"8px 0 0"},children:document2.perceived})]}),(0,import_jsx_runtime4.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime4.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("emotion.warmth"),(0,import_jsx_runtime4.jsx)(InfoHint,{label:t("emotion.warmthHint")})]}),(0,import_jsx_runtime4.jsx)("div",{style:{...barTrack,marginTop:10},children:(0,import_jsx_runtime4.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_runtime4.jsx)("p",{style:meta,children:document2.warmthCause}),policy2.stateValues?(0,import_jsx_runtime4.jsxs)("div",{style:{...meta,display:"flex",alignItems:"center",gap:8},children:[(0,import_jsx_runtime4.jsx)("span",{children:t("emotion.setValue")}),(0,import_jsx_runtime4.jsx)("input",{type:"number",min:0,max:100,step:1,style:{width:64,textAlign:"right",fontVariantNumeric:"tabular-nums"},defaultValue:Math.round(document2.warmth),"aria-label":t("emotion.warmth"),onKeyDown:event=>{event.key==="Enter"&&event.target.blur()},onBlur:event=>{let raw=Number(event.target.value);if(!Number.isFinite(raw))return;let next=Math.round(Math.min(100,Math.max(0,raw)));next!==Math.round(document2.warmth)&&controller.setWarmth(next)}})]}):null]}),(0,import_jsx_runtime4.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime4.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("emotion.block.title"),(0,import_jsx_runtime4.jsx)(InfoHint,{label:paramsHint})]}),document2.charges.length===0?(0,import_jsx_runtime4.jsx)("p",{style:{...hint,margin:0},children:t("emotion.empty")}):EMOTION_KINDS.map(kind=>{let charges=document2.charges.filter(charge=>charge.kind===kind),main=charges.reduce((best,charge)=>best===void 0||charge.intensity>best.intensity?charge:best,void 0),series=EMOTION_TARGETS.map(target=>{let charge=charges.find(item=>item.target===target);return{target,label:targetTextOf(target),value:charge?.intensity??0,color:TARGET_COLORS[target]??"var(--dsw-alias-label-secondary)",slot:historySlotOf(kind,target)}});return(0,import_jsx_runtime4.jsx)(EmotionRow,{t,kindLabel:EMOTION_LABELS[kind],main,now,editable:policy2.stateValues,onSet:(target,value)=>{controller.setCharge(kind,target,value)},series,points:chartPoints,sensitivityHint:sensitivityHintOf(main)},kind)}),document2.compositeLabel===""?null:(0,import_jsx_runtime4.jsxs)("p",{style:{...meta,marginTop:16},children:[t("emotion.composite"),":",(0,import_jsx_runtime4.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_runtime4.jsx)("p",{style:{...meta,marginTop:12},children:t("emotion.tier.burstHint")})]}),(0,import_jsx_runtime4.jsxs)("p",{style:{...subtitle,marginTop:16},children:[t("emotion.settledAt",{time:agoText(t,document2.settledAt,now)})," · ",t("emotion.globalHint")]})]})}var import_dsh_client_ui_primitives4=require("@deepseek-ai/dsh-client-ui-primitives");var import_dsh_client_ui_primitives2=require("@deepseek-ai/dsh-client-ui-primitives");var import_jsx_runtime5=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_runtime5.jsxs)("div",{style:toggleRow,children:[(0,import_jsx_runtime5.jsx)("div",{style:toggleText,children:(0,import_jsx_runtime5.jsxs)("span",{style:headingWithHint,children:[t("persona.independentJudgment"),(0,import_jsx_runtime5.jsx)(InfoHint,{label:hint2})]})}),(0,import_jsx_runtime5.jsxs)("div",{style:toggleState,children:[(0,import_jsx_runtime5.jsx)("span",{children:state}),(0,import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives2.Switch,{checked,disabled,label:t("persona.independentJudgment"),title:hint2,onChange})]})]})}var import_react5=require("react"),import_dsh_client_ui_primitives3=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))"};var readOnlyValue={display:"block",width:"100%",minHeight:22,fontSize:13,lineHeight:1.7,whiteSpace:"pre-wrap",overflowWrap:"anywhere",color:"var(--dsw-alias-label-primary)"},verticalList={display:"flex",flexDirection:"column"},verticalRow={borderTop:"1px solid var(--dsw-alias-border-l2)",padding:"12px 0 4px"},verticalHead={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:6};var import_jsx_runtime6=require("react/jsx-runtime");function Marked({marker:marker2,itemId,children}){return(0,import_jsx_runtime6.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_runtime6.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_runtime6.jsx)("span",{"data-persona-cell":"name","data-persona-item":itemId,"data-persona-editor":"rename","data-persona-rename":itemId,style:editorCell,children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Input,{value:form.name,placeholder:t("persona.fieldKey"),"aria-label":t("persona.rename"),disabled,onChange:event=>controller.setRenameName(event.target.value)})}):(0,import_jsx_runtime6.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,locked}){if(locked===!0)return(0,import_jsx_runtime6.jsx)("div",{"data-persona-cell":"actions","data-persona-actions":itemId,style:itemActions});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_runtime6.jsxs)("div",{"data-persona-cell":"actions","data-persona-actions":itemId,style:itemActions,children:[(0,import_jsx_runtime6.jsx)(Marked,{marker:"rename-confirm",itemId,children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button,{size:"sm",variant:"primary",disabled:disabled||issue!==void 0,onClick:()=>controller.confirmRename(),children:t("persona.renameConfirm")})}),(0,import_jsx_runtime6.jsx)(Marked,{marker:"rename-cancel",itemId,children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button,{size:"sm",variant:"ghost",disabled,onClick:()=>controller.cancelRename(),children:t("persona.cancel")})})]}):(0,import_jsx_runtime6.jsxs)("div",{"data-persona-cell":"actions","data-persona-actions":itemId,style:itemActions,children:[renameable?(0,import_jsx_runtime6.jsx)(Marked,{marker:"rename",itemId,children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button,{variant:"ghost",size:"sm",disabled,onClick:()=>controller.beginRename(itemId),children:t("persona.rename")})}):null,deletable?(0,import_jsx_runtime6.jsx)(Marked,{marker:"delete",itemId,children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.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_runtime6.jsxs)("div",{style:{...deleteBand,gridColumn:"1 / -1"},"data-persona-action":"delete-confirm-band","data-persona-item":itemId,children:[(0,import_jsx_runtime6.jsx)("span",{children:t("persona.deleteConfirm",{name:name2})}),(0,import_jsx_runtime6.jsx)(Marked,{marker:"delete-confirm",itemId,children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button,{size:"sm",variant:"primary",disabled,onClick:()=>controller.confirmDelete(),children:t("persona.deleteConfirmYes")})}),(0,import_jsx_runtime6.jsx)(Marked,{marker:"delete-cancel",itemId,children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button,{size:"sm",variant:"ghost",disabled,onClick:()=>controller.cancelDelete(),children:t("persona.cancel")})})]})}function RenameIssueBand({t,itemId,issue}){return(0,import_jsx_runtime6.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_runtime6.jsx)(RenameIssueBand,{t,itemId,issue})}var valueBox={...textarea,minHeight:38,padding:"6px 10px"};function IdentityFieldCells({t,controller,disabled,state,locked,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_runtime6.jsxs)("div",{"data-persona-item":itemId,style:verticalRow,children:[(0,import_jsx_runtime6.jsxs)("div",{style:verticalHead,children:[(0,import_jsx_runtime6.jsx)(NameCell,{t,controller,disabled,state,itemId,name:field.key,renameable:renameable&&locked!==!0}),(0,import_jsx_runtime6.jsx)(ActionsCell,{t,controller,disabled,state,itemId,renameable,deletable,locked})]}),(0,import_jsx_runtime6.jsx)(ContentCell,{name:"value",itemId,children:locked===!0?(0,import_jsx_runtime6.jsx)("span",{style:readOnlyValue,children:field.value===""?"—":field.value}):(0,import_jsx_runtime6.jsx)("textarea",{style:valueBox,value:field.value,rows:1,placeholder:t("persona.fieldValue"),"aria-label":field.key===""?t("persona.fieldValue"):field.key,disabled,onChange:event=>controller.setIdentityValue(index,event.target.value)})}),pending2?(0,import_jsx_runtime6.jsx)(DeleteConfirm,{t,controller,disabled,itemId,name:field.key===""?t("persona.fieldValue"):field.key}):null,(0,import_jsx_runtime6.jsx)(RenameIssueBandIfAny,{t,state,itemId})]})}function IdentityFields({t,controller,disabled,state,locked,except}){let shared={t,controller,disabled,state},skip=new Set(except??[]);return(0,import_jsx_runtime6.jsxs)("div",{style:verticalList,"data-persona-list":"identity",children:[state.draft.identityCard.fields.map((field,index)=>skip.has(field.key)?null:(0,import_jsx_runtime6.jsx)(IdentityFieldCells,{...shared,locked,index},`field-${index}`)),locked===!0?null:(0,import_jsx_runtime6.jsx)(AddEntry,{...shared,disabled,kind:"identity",openLabel:t("persona.addField"),nameLabel:t("persona.fieldKey"),valueLabel:t("persona.fieldValue")})]})}function MutableSectionCells({t,controller,disabled,state,locked,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_runtime6.jsxs)(import_react5.Fragment,{children:[(0,import_jsx_runtime6.jsx)(NameCell,{t,controller,disabled,state,itemId,name:section.title,locked:!deletable,renameable:renameable&&locked!==!0}),(0,import_jsx_runtime6.jsx)(ContentCell,{name:"section",itemId,children:locked===!0?(0,import_jsx_runtime6.jsx)("span",{style:readOnlyValue,children:text===""?"—":text}):(0,import_jsx_runtime6.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_runtime6.jsx)(ActionsCell,{t,controller,disabled,state,itemId,renameable,deletable,locked}),pending2?(0,import_jsx_runtime6.jsx)(DeleteConfirm,{t,controller,disabled,itemId,name:section.title}):null,(0,import_jsx_runtime6.jsx)(RenameIssueBandIfAny,{t,state,itemId})]})}function MutableFields({t,controller,disabled,state,locked}){let shared={t,controller,disabled,state};return(0,import_jsx_runtime6.jsxs)("div",{style:itemList,"data-persona-list":"section",children:[orderedSections(state.draft).map(section=>(0,import_jsx_runtime6.jsx)(MutableSectionCells,{...shared,locked,section},section.title)),locked===!0?null:(0,import_jsx_runtime6.jsx)(AddEntry,{...shared,disabled,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,valueLabel,multiline=!1}){let form=state.addForm;if(form===void 0||form.kind!==kind)return(0,import_jsx_runtime6.jsx)("div",{style:{gridColumn:"1 / -1"},"data-persona-add-open":kind,children:(0,import_jsx_runtime6.jsx)(Marked,{marker:"add-open",children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button,{variant:"outline",size:"sm",disabled,onClick:()=>controller.openAdd(kind),children:openLabel})})});let ready=addFormReady(form);return(0,import_jsx_runtime6.jsx)("div",{style:addBand,"data-persona-add":kind,children:(0,import_jsx_runtime6.jsxs)("div",{style:itemGrid,children:[(0,import_jsx_runtime6.jsx)("span",{"data-persona-editor":"add-name",style:editorCell,children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Input,{value:form.name,placeholder:nameLabel,"aria-label":nameLabel,disabled,onChange:event=>controller.setAddField("name",event.target.value)})}),multiline?(0,import_jsx_runtime6.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_runtime6.jsx)("span",{"data-persona-editor":"add-value",style:editorCell,children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Input,{value:form.value,placeholder:valueLabel,"aria-label":valueLabel,disabled,onChange:event=>controller.setAddField("value",event.target.value)})}),(0,import_jsx_runtime6.jsxs)("div",{style:itemActions,children:[(0,import_jsx_runtime6.jsx)(Marked,{marker:"add-save",children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button,{size:"sm",variant:"primary",disabled:disabled||!ready,onClick:()=>{controller.commitAdd()},children:t("persona.save")})}),(0,import_jsx_runtime6.jsx)(Marked,{marker:"add-cancel",children:(0,import_jsx_runtime6.jsx)(import_dsh_client_ui_primitives3.Button,{size:"sm",variant:"ghost",disabled,onClick:()=>controller.cancelAdd(),children:t("persona.cancel")})})]})]})})}var import_jsx_runtime7=require("react/jsx-runtime");function CardSaveButton({t,controller,state,enabled}){let busy=state.saving;return(0,import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives4.Button,{size:"sm",variant:"primary",disabled:busy||!state.writable||!isDirty(state)||!enabled,onClick:()=>{controller.save()},children:t(busy?"persona.saving":"persona.save")})}function IdentityCardEditor({t,controller,state,policy:policy2}){let sealed=state.stored.identityCard.sealedAt!=="",editable=!state.saving&&state.writable&&policy2.identityEdit;return(0,import_jsx_runtime7.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime7.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("persona.identityCard")," ",(0,import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives4.Tag,{tone:sealed?"neutral":"outline",children:t(sealed?"persona.sealed":"persona.unsealed")}),sealed||!policy2.seal?null:(0,import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives4.Button,{size:"sm",variant:"outline",disabled:state.saving||!state.writable,onClick:()=>{controller.seal()},children:t("persona.sealAction")}),policy2.identityEdit?(0,import_jsx_runtime7.jsx)(CardSaveButton,{t,controller,state,policy:policy2,enabled:policy2.identityEdit}):null,(0,import_jsx_runtime7.jsx)(InfoHint,{label:t("persona.identityHint")})]}),(0,import_jsx_runtime7.jsx)(IndependentJudgmentRow,{t,checked:sealed&&state.independentJudgment,disabled:state.independentJudgmentSaving||!state.writable||!sealed||!policy2.independentJudgment,saving:state.independentJudgmentSaving,sealed,onChange:next=>{controller.setIndependentJudgment(next)}}),(0,import_jsx_runtime7.jsx)(IdentityFields,{t,controller,disabled:!editable,state,locked:!policy2.identityEdit,except:FIXED_INFO_KEYS})]})}var FIXED_INFO_KEYS=["姓名","性别","主语言"];function MutableCardEditor({t,controller,state,policy:policy2}){let shared={t,controller,disabled:state.saving||!state.writable||!policy2.mutableEdit};return(0,import_jsx_runtime7.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime7.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("persona.mutableCard"),(0,import_jsx_runtime7.jsx)(InfoHint,{label:t("persona.mutableHint")}),policy2.mutableEdit?(0,import_jsx_runtime7.jsx)(CardSaveButton,{t,controller,state,policy:policy2,enabled:policy2.mutableEdit}):null]}),(0,import_jsx_runtime7.jsx)(MutableFields,{...shared,state,locked:!policy2.mutableEdit})]})}var import_dsh_client_ui_primitives5=require("@deepseek-ai/dsh-client-ui-primitives");var import_jsx_runtime8=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_runtime8.jsxs)(import_jsx_runtime8.Fragment,{children:[(0,import_jsx_runtime8.jsx)("p",{style:{...statusText,marginTop:16},...alert===!0?{role:"alert"}:{},children:label}),(0,import_jsx_runtime8.jsx)("ul",{style:issueList,children:issues.map((issue,index)=>(0,import_jsx_runtime8.jsxs)("li",{style:tone,children:[issueText(t,issue)," ",(0,import_jsx_runtime8.jsx)("span",{style:issuePath,children:issue.path})]},`issue-${index}`))})]})}function IssueNotices({t,issues,error}){let rejected=issues.filter(issue=>issue.severity==="rejected"),warnings=issues.filter(issue=>issue.severity==="warning");return(0,import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment,{children:[(0,import_jsx_runtime8.jsx)(IssueGroup,{t,label:t("persona.blocked",{count:String(rejected.length)}),issues:rejected,tone:issueRejected,alert:!0}),(0,import_jsx_runtime8.jsx)(IssueGroup,{t,label:t("persona.warnings",{count:String(warnings.length)}),issues:warnings,tone:issueWarning}),error!==void 0?(0,import_jsx_runtime8.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_runtime8.jsxs)("div",{style:footer,children:[(0,import_jsx_runtime8.jsx)("p",{style:statusText,children:status}),(0,import_jsx_runtime8.jsx)("div",{style:actions,children:(0,import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives5.Button,{variant:"ghost",size:"sm",disabled:busy,onClick:()=>{controller.load()},children:t("persona.reload")})})]})}function StatusNotice({t,state}){return state.status==="loading"||state.status==="idle"?(0,import_jsx_runtime8.jsx)("p",{style:hint,children:t("persona.loading")}):state.status==="unavailable"?(0,import_jsx_runtime8.jsx)("p",{style:hint,children:t("persona.unavailable")}):state.status==="failed"?(0,import_jsx_runtime8.jsx)("p",{style:hint,role:"alert",children:t("persona.failed",{message:state.error??""})}):null}var import_react6=require("react");function usePersonaWorkbench(controller){let state=(0,import_react6.useSyncExternalStore)(controller.subscribe,controller.getSnapshot,controller.getSnapshot);return(0,import_react6.useEffect)(()=>{controller.load()},[controller]),state}var import_jsx_runtime9=require("react/jsx-runtime");function IdentityCardPage({t,controller,policy:policy2=policyOf("immersive")}){let state=usePersonaWorkbench(controller),notice2=StatusNotice({t,state});return notice2!==null?notice2:(0,import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment,{children:[(0,import_jsx_runtime9.jsx)("p",{style:{...subtitle,marginTop:0},children:t("identity.standInNote")}),(0,import_jsx_runtime9.jsx)(MutableCardEditor,{t,controller,state,policy:policy2}),(0,import_jsx_runtime9.jsx)(IssueNotices,{t,issues:state.issues,error:state.error})]})}var import_dsh_client_ui_primitives6=require("@deepseek-ai/dsh-client-ui-primitives"),import_react8=require("react");var import_react7=require("react");function useVisibleRefresh(reload){(0,import_react7.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_runtime10=require("react/jsx-runtime"),DISCLOSURE_THRESHOLD=.5,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"},dot={display:"inline-block",width:8,height:8,borderRadius:4,flex:"0 0 auto"},openedBadge={fontSize:11,padding:"1px 6px",borderRadius:6,color:"var(--dsw-alias-label-secondary)",background:"var(--dsw-alias-bg-layer-3)"},toolbar={display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",margin:"10px 0 6px"},picker={boxSizing:"border-box",padding:"5px 8px",borderRadius:8,border:"0.5px solid var(--dsw-alias-border-l4)",background:"var(--dsw-alias-bg-layer-1)",color:"var(--dsw-alias-label-primary)",font:"inherit",fontSize:13,colorScheme:"dark"},warnText={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 freshnessColor(strength){return strength>=.6?"#3fb950":strength>=.3?"#d29922":"#f85149"}function EntryRow({entry,t,pending:pending2,onAsk,onConfirm,deleting,onDeleteAsk,onDeleteConfirm,canDelete,canReveal,canEditStrength,onStrength}){let percent2=`${Math.round(Math.min(1,Math.max(0,entry.strength))*100)}%`,secret=entry.cost>DISCLOSURE_THRESHOLD;return(0,import_jsx_runtime10.jsxs)("div",{style:row,children:[(0,import_jsx_runtime10.jsxs)("div",{style:meta2,children:[(0,import_jsx_runtime10.jsx)("span",{style:{...dot,background:freshnessColor(entry.strength)},title:t("memory.freshness")}),(0,import_jsx_runtime10.jsx)("span",{children:dayOf(entry.when)}),entry.openedAt===""?null:(0,import_jsx_runtime10.jsx)("span",{style:openedBadge,title:entry.openedAt,children:t("memory.opened")}),(0,import_jsx_runtime10.jsx)("span",{children:aboutText(entry.about,t)}),(0,import_jsx_runtime10.jsx)("span",{children:t(`memory.tier.${entry.tier}`)}),entry.feltLabel!==""?(0,import_jsx_runtime10.jsx)("span",{children:t("memory.felt").replace("{label}",entry.feltLabel)}):null,entry.covers>0?(0,import_jsx_runtime10.jsx)("span",{children:t("memory.covers").replace("{count}",String(entry.covers))}):null,entry.recalled>0?(0,import_jsx_runtime10.jsx)("span",{children:t("memory.recalled").replace("{count}",String(entry.recalled))}):null,canDelete?(0,import_jsx_runtime10.jsx)("div",{style:rowActions,children:deleting?(0,import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment,{children:[(0,import_jsx_runtime10.jsx)("span",{style:warnText,children:t("memory.delete.warn")}),(0,import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives6.Button,{size:"sm",variant:"outline",onClick:onDeleteConfirm,children:t("memory.delete.confirm")})]}):(0,import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives6.Button,{size:"sm",variant:"ghost",onClick:onDeleteAsk,children:t("memory.delete.ask")})}):null]}),secret?(0,import_jsx_runtime10.jsxs)("p",{style:what,children:[(0,import_jsx_runtime10.jsxs)("span",{style:secretMask,children:["🔒 ",t("memory.secret")]})," ",canReveal?pending2?(0,import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment,{children:[(0,import_jsx_runtime10.jsx)("span",{style:warnText,children:t("memory.reveal.warn")})," ",(0,import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives6.Button,{size:"sm",variant:"primary",onClick:onConfirm,children:t("memory.reveal.confirm")})]}):(0,import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives6.Button,{size:"sm",variant:"ghost",onClick:onAsk,children:t("memory.reveal.ask")}):null]}):(0,import_jsx_runtime10.jsx)("p",{style:what,children:entry.what}),(0,import_jsx_runtime10.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,import_jsx_runtime10.jsx)("div",{style:{...track,flex:1},"aria-hidden":!0,children:(0,import_jsx_runtime10.jsx)("div",{style:{...fill,width:percent2,background:freshnessColor(entry.strength)}})}),(0,import_jsx_runtime10.jsx)("span",{style:{minWidth:32,textAlign:"right",fontSize:12,fontVariantNumeric:"tabular-nums",color:"var(--dsw-alias-label-secondary)"},title:t("memory.strength"),children:canEditStrength?null:Math.round(Math.min(1,Math.max(0,entry.strength))*100)}),canEditStrength?(0,import_jsx_runtime10.jsx)("input",{type:"number",min:0,max:100,step:1,style:{width:56,textAlign:"right",fontVariantNumeric:"tabular-nums"},defaultValue:Math.round(Math.min(1,Math.max(0,entry.strength))*100),"aria-label":t("memory.strength"),onKeyDown:event=>{event.key==="Enter"&&event.target.blur()},onBlur:event=>{let raw=Number(event.target.value);if(!Number.isFinite(raw))return;let next=Math.round(Math.min(100,Math.max(0,raw)));next!==Math.round(entry.strength*100)&&onStrength(next)}}):null]})]})}function MemoryPage({t,controller,policy:policy2=policyOf("immersive")}){let state=(0,import_react8.useSyncExternalStore)(controller.subscribe,controller.getSnapshot,controller.getSnapshot),[pendingId,setPendingId]=(0,import_react8.useState)(""),[deletingId,setDeletingId]=(0,import_react8.useState)(""),[query,setQuery]=(0,import_react8.useState)(""),[about,setAbout]=(0,import_react8.useState)(""),[sort,setSort]=(0,import_react8.useState)("newest");(0,import_react8.useEffect)(()=>{controller.load()},[controller]);let reload=(0,import_react8.useCallback)(()=>{controller.load({quiet:!0})},[controller]);useVisibleRefresh(reload);let{doc}=state,ready=state.status==="ready",todayKey=dayOf(new Date().toISOString()),todayCount=ready?doc.entries.filter(entry=>dayOf(entry.when)===todayKey).length:0,keyword=query.trim(),visible=ready?doc.entries.filter(entry=>about===""||entry.about===about).filter(entry=>keyword===""||entry.what.includes(keyword)).slice().sort((left,right)=>sort==="strong"?right.strength-left.strength:sort==="weak"?left.strength-right.strength:Date.parse(right.when)-Date.parse(left.when)):[];return(0,import_jsx_runtime10.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime10.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("memory.title"),(0,import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives6.Button,{size:"sm",variant:"ghost",onClick:()=>{controller.load()},children:t("memory.reload")})]}),state.status==="loading"?(0,import_jsx_runtime10.jsx)("p",{style:notice,children:t("memory.loading")}):null,state.status==="unavailable"?(0,import_jsx_runtime10.jsx)("p",{style:notice,children:t("memory.unavailable")}):null,state.status==="failed"?(0,import_jsx_runtime10.jsx)("p",{style:notice,children:state.error??t("memory.failed")}):null,ready&&doc.notice!==""?(0,import_jsx_runtime10.jsx)("p",{style:noticeLine,children:doc.notice}):null,ready?(0,import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment,{children:[(0,import_jsx_runtime10.jsxs)("div",{style:stats,children:[(0,import_jsx_runtime10.jsx)("span",{children:t("memory.total").replace("{count}",String(doc.stats.total))}),(0,import_jsx_runtime10.jsxs)("span",{children:[t("memory.stat.public")," ",doc.stats.public]}),(0,import_jsx_runtime10.jsxs)("span",{children:[t("memory.stat.private")," ",doc.stats.private]}),todayCount>0?(0,import_jsx_runtime10.jsxs)("span",{children:[t("memory.stat.today")," ",todayCount]}):null,(0,import_jsx_runtime10.jsx)("span",{children:t("memory.recalledTotal").replace("{count}",String(doc.stats.recalled))})]}),(0,import_jsx_runtime10.jsxs)("div",{style:toolbar,children:[(0,import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives6.Input,{style:{flex:1,minWidth:160},value:query,placeholder:t("memory.search.placeholder"),"aria-label":t("memory.search.placeholder"),onChange:event=>setQuery(event.target.value)}),(0,import_jsx_runtime10.jsxs)("select",{style:picker,value:about,"aria-label":t("memory.filter.about"),onChange:event=>setAbout(event.target.value),children:[(0,import_jsx_runtime10.jsx)("option",{value:"",children:t("memory.filter.all")}),(0,import_jsx_runtime10.jsx)("option",{value:"user",children:t("memory.about.user")}),(0,import_jsx_runtime10.jsx)("option",{value:"us",children:t("memory.about.us")}),(0,import_jsx_runtime10.jsx)("option",{value:"self",children:t("memory.about.self")}),(0,import_jsx_runtime10.jsx)("option",{value:"world",children:t("memory.about.world")})]}),(0,import_jsx_runtime10.jsxs)("select",{style:picker,value:sort,"aria-label":t("memory.sort"),onChange:event=>setSort(event.target.value),children:[(0,import_jsx_runtime10.jsx)("option",{value:"newest",children:t("memory.sort.newest")}),(0,import_jsx_runtime10.jsx)("option",{value:"strong",children:t("memory.sort.strong")}),(0,import_jsx_runtime10.jsx)("option",{value:"weak",children:t("memory.sort.weak")})]})]}),doc.lastRecall.items.length>0?(0,import_jsx_runtime10.jsxs)("div",{style:whyBox,children:[(0,import_jsx_runtime10.jsx)("p",{style:whyTitle,children:t("memory.why.title")}),doc.lastRecall.cue!==""?(0,import_jsx_runtime10.jsx)("p",{style:whyCue,children:t("memory.why.cue").replace("{cue}",doc.lastRecall.cue)}):null,(0,import_jsx_runtime10.jsx)("ul",{style:whyList,children:doc.lastRecall.items.map((item,index)=>(0,import_jsx_runtime10.jsxs)("li",{children:[item.withheld?t("memory.why.withheld"):item.what,item.match!==""?(0,import_jsx_runtime10.jsx)("span",{style:whyMatch,children:t(`memory.why.match.${item.match}`)}):null]},`${index}-${item.what}`))})]}):null,doc.entries.length===0?(0,import_jsx_runtime10.jsx)("p",{style:notice,children:doc.dormant?t("memory.dormant"):t("memory.empty")}):visible.length===0?(0,import_jsx_runtime10.jsx)("p",{style:notice,children:t("memory.noMatch")}):visible.map(entry=>(0,import_jsx_runtime10.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})})},canDelete:policy2.memoryDelete,canReveal:policy2.memoryReveal,canEditStrength:policy2.stateValues,onStrength:percent2=>{controller.setStrength(entry.id,percent2).then(ok=>{ok&&controller.load({quiet:!0})})}},entry.id))]}):null]})}var import_react9=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_dsh_client_ui_primitives7=require("@deepseek-ai/dsh-client-ui-primitives");var import_jsx_runtime11=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,display:"flex",alignItems:"center",gap:6},numberBox={width:64,fontVariantNumeric:"tabular-nums",textAlign:"right"},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:64,resize:"vertical",overflow:"auto"},valueRow={display:"flex",alignItems:"center",gap:8,margin:"0 0 8px",fontSize:12,color:"var(--dsw-alias-label-secondary)"},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_runtime11.jsxs)("div",{style:track2,"aria-hidden":!0,children:[(0,import_jsx_runtime11.jsx)("div",{style:{...span,left:percent(low),width:percent(high-low)}}),(0,import_jsx_runtime11.jsx)("div",{style:{...marker,left:percent(axis.value)}})]})}function UnitInput({label,value,disabled,onCommit}){return(0,import_jsx_runtime11.jsx)("input",{type:"number",step:"0.01",min:0,max:1,style:numberBox,defaultValue:value.toFixed(2),disabled,"aria-label":label,onKeyDown:event=>{event.key==="Enter"&&event.target.blur()},onBlur:event=>{let raw=Number(event.target.value);if(!Number.isFinite(raw))return;let next=Math.round(Math.min(1,Math.max(0,raw))*100)/100;next!==Number(value.toFixed(2))&&onCommit(next)}})}function CharacterCardEditor({t,controller,state,policy:policy2}){let readOnly=state.saving||!state.writable,character=state.draft.character,ready=character.derivedAt!==""&&character.axes.length>0,editable=!readOnly;return(0,import_jsx_runtime11.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime11.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("persona.characterCard"),(0,import_jsx_runtime11.jsx)(InfoHint,{label:t("persona.characterHint")}),policy2.characterReason?(0,import_jsx_runtime11.jsx)(CardSaveButton,{t,controller,state,policy:policy2,enabled:policy2.characterReason}):null]}),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_runtime11.jsx)("div",{style:axisBlock,children:(0,import_jsx_runtime11.jsxs)("div",{style:axisHead,children:[(0,import_jsx_runtime11.jsx)("span",{style:axisName,children:label}),(0,import_jsx_runtime11.jsx)("span",{style:axisRange,children:t("persona.characterAxisMissing")})]})},key):(0,import_jsx_runtime11.jsxs)("div",{style:axisBlock,children:[(0,import_jsx_runtime11.jsxs)("div",{style:axisHead,children:[(0,import_jsx_runtime11.jsx)("span",{style:axisName,children:label}),policy2.characterRange?(0,import_jsx_runtime11.jsxs)("span",{style:axisRange,children:[(0,import_jsx_runtime11.jsx)(UnitInput,{label:`${label} ${t("persona.characterRange")} 下限`,value:axis.min,disabled:!editable,onCommit:next=>controller.setCharacterNumber(key,"min",next)}),(0,import_jsx_runtime11.jsx)("span",{children:"–"}),(0,import_jsx_runtime11.jsx)(UnitInput,{label:`${label} ${t("persona.characterRange")} 上限`,value:axis.max,disabled:!editable,onCommit:next=>controller.setCharacterNumber(key,"max",next)})]}):(0,import_jsx_runtime11.jsxs)("span",{style:axisRange,children:[t("persona.characterRange")," ",rangeText(axis)]})]}),(0,import_jsx_runtime11.jsx)(AxisTrack,{axis}),policy2.characterValue?(0,import_jsx_runtime11.jsxs)("div",{style:valueRow,children:[(0,import_jsx_runtime11.jsx)("span",{children:t("soul.characterValue")}),(0,import_jsx_runtime11.jsx)(UnitInput,{label:`${label} ${t("soul.characterValue")}`,value:axis.value,disabled:!editable,onCommit:next=>controller.setCharacterNumber(key,"value",next)})]}):null,policy2.characterReason?(0,import_jsx_runtime11.jsx)("textarea",{style:reasonBox,value:axis.reason,rows:3,"aria-label":`${label} ${t("persona.characterReason")}`,placeholder:t("persona.characterReasonPlaceholder"),readOnly:!editable,onChange:event=>controller.setCharacterReason(key,event.target.value)}):(0,import_jsx_runtime11.jsx)("span",{style:{...readOnlyValue,fontSize:12,color:"var(--dsw-alias-label-secondary)"},children:axis.reason===""?"—":axis.reason})]},key)}):(0,import_jsx_runtime11.jsx)("p",{style:pending,children:t("persona.characterPending")})]})}var import_jsx_runtime12=require("react/jsx-runtime");function birthDateOf(birthday,sealedAt){let trimmed=(birthday??"").trim();return trimmed===""?sealedAt:trimmed}function ageText(t,birthday,sealedAt,now){let age=ageOf(birthDateOf(birthday,sealedAt),now);return age===void 0?t("soul.age.unborn"):age.years===0&&age.months===0?t("soul.age.days",{days:String(age.days)}):t("soul.age.yearsMonths",{years:String(age.years),months:String(age.months)})}function ageOf(birthIso,now){let at=Date.parse(birthIso);if(birthIso===""||!Number.isFinite(at))return;let birth=new Date(at),years=now.getFullYear()-birth.getFullYear(),months=now.getMonth()-birth.getMonth();now.getDate()<birth.getDate()&&(months-=1),months<0&&(years-=1,months+=12);let days=Math.max(0,Math.floor((now.getTime()-at)/864e5));return{years:Math.max(0,years),months:Math.max(0,months),days}}var cell={display:"flex",flexDirection:"column",gap:4},cellLabel={fontSize:12,color:"var(--dsw-alias-label-secondary)"},dateInput={boxSizing:"border-box",flex:1,minWidth:0,padding:"6px 10px",borderRadius:8,border:"0.5px solid var(--dsw-alias-border-l4)",background:"var(--dsw-alias-bg-layer-1)",color:"var(--dsw-alias-label-primary)",font:"inherit",fontSize:13,colorScheme:"dark"};function FixedInfoPanel({t,controller,state,policy:policy2,birthday,onBirthday}){let fields=state.draft.identityCard.fields,editable=!state.saving&&state.writable&&policy2.identityEdit,rows=[{key:"姓名",label:t("overview.name")},{key:"性别",label:t("overview.gender")},{key:"主语言",label:t("soul.language")}];return(0,import_jsx_runtime12.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime12.jsx)("h2",{style:panelTitle,children:t("soul.fixedInfo.title")}),(0,import_jsx_runtime12.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:"12px 16px"},children:[rows.map(row3=>{let index=fields.findIndex(field=>field.key===row3.key);if(index<0)return null;let value=fields[index]?.value??"";return(0,import_jsx_runtime12.jsxs)("div",{style:cell,children:[(0,import_jsx_runtime12.jsx)("span",{style:cellLabel,children:row3.label}),editable?(0,import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives7.Input,{value,"aria-label":row3.label,onChange:event=>controller.setIdentityValue(index,event.target.value)}):(0,import_jsx_runtime12.jsx)("span",{style:{fontSize:13},children:value===""?"—":value})]},row3.key)}),(0,import_jsx_runtime12.jsxs)("div",{style:cell,children:[(0,import_jsx_runtime12.jsx)("span",{style:cellLabel,children:t("soul.birthday")}),onBirthday===void 0?(0,import_jsx_runtime12.jsx)("span",{style:{fontSize:13,fontVariantNumeric:"tabular-nums"},children:birthday===""?t("soul.birthdayUnset"):birthday}):(0,import_jsx_runtime12.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,import_jsx_runtime12.jsx)("input",{type:"date",style:dateInput,value:birthday,"aria-label":t("soul.birthday"),onChange:event=>onBirthday(event.target.value)}),(0,import_jsx_runtime12.jsx)(InfoHint,{label:t("soul.birthdayHint")})]})]})]})]})}function SoulPage({t,controller,policy:policy2=policyOf("immersive"),birthday="",onBirthday}){let state=usePersonaWorkbench(controller),notice2=StatusNotice({t,state});return notice2!==null?notice2:(0,import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment,{children:[(0,import_jsx_runtime12.jsx)(FixedInfoPanel,{t,controller,state,policy:policy2,birthday,...onBirthday===void 0?{}:{onBirthday}}),(0,import_jsx_runtime12.jsx)(IdentityCardEditor,{t,controller,state,policy:policy2}),(0,import_jsx_runtime12.jsx)(CharacterCardEditor,{t,controller,state,policy:policy2}),(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})]})}var import_jsx_runtime13=require("react/jsx-runtime"),NOOP_SUBSCRIBE=()=>()=>{};function MetricRow({t,metric}){return(0,import_jsx_runtime13.jsxs)("div",{style:metricRow,"data-overview-metric":metric.key,children:[(0,import_jsx_runtime13.jsxs)("dt",{style:{...metricLabelSmall,...headingWithHint},children:[metric.label,metric.hint===void 0?null:(0,import_jsx_runtime13.jsx)(InfoHint,{label:metric.hint})]}),(0,import_jsx_runtime13.jsx)("dd",{style:metricValueStrong,children:metric.value})]})}function MetricSection({t,title:title2,hint:hint2,metrics}){return(0,import_jsx_runtime13.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime13.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[title2,hint2===void 0?null:(0,import_jsx_runtime13.jsx)(InfoHint,{label:hint2})]}),(0,import_jsx_runtime13.jsx)("dl",{style:metricList,children:metrics.map(metric=>(0,import_jsx_runtime13.jsx)(MetricRow,{t,metric},metric.key))})]})}function fieldValue(fields,key){return(fields.find(field=>field.key===key)?.value??"").trim()}function OverviewPage({t,persona,emotion,memory,evolution,birthday=""}){let personaController=persona??{subscribe:NOOP_SUBSCRIBE,getSnapshot:()=>{}},emotionController=emotion??{subscribe:NOOP_SUBSCRIBE,getSnapshot:()=>{}},memoryController=memory??{subscribe:NOOP_SUBSCRIBE,getSnapshot:()=>{}},evolutionController=evolution??{subscribe:NOOP_SUBSCRIBE,getSnapshot:()=>{}},personaState=(0,import_react9.useSyncExternalStore)(personaController.subscribe,personaController.getSnapshot,personaController.getSnapshot),emotionState=(0,import_react9.useSyncExternalStore)(emotionController.subscribe,emotionController.getSnapshot,emotionController.getSnapshot),memoryState=(0,import_react9.useSyncExternalStore)(memoryController.subscribe,memoryController.getSnapshot,memoryController.getSnapshot),evolutionState=(0,import_react9.useSyncExternalStore)(evolutionController.subscribe,evolutionController.getSnapshot,evolutionController.getSnapshot);(0,import_react9.useEffect)(()=>{persona!==void 0&&persona.load(),emotion!==void 0&&emotion.load({quiet:!0}),memory!==void 0&&memory.load({quiet:!0}),evolution!==void 0&&evolution.load({quiet:!0})},[persona,emotion,memory,evolution]);let unavailable=t("workbench.metric.unavailable"),fields=personaState?.draft.identityCard.fields??[],sealedAt=personaState?.stored.identityCard.sealedAt??"",name2=fieldValue(fields,"姓名"),identity=[{key:"name",label:t("overview.name"),value:name2===""?t("workbench.metric.nameEmpty"):name2},{key:"gender",label:t("overview.gender"),value:fieldValue(fields,"性别")||"—"},{key:"age",label:t("overview.age"),value:ageText(t,birthday,sealedAt,new Date),hint:t("overview.ageHint")},{key:"language",label:t("overview.language"),value:fieldValue(fields,"主语言")||"—"}],document2=emotionState?.document,strongest=document2?.charges.find(charge=>charge.intensity>0),now=[{key:"emotion",label:t("overview.emotion"),value:document2===void 0?unavailable:strongest===void 0?t("overview.emotionCalm"):`${strongest.targetLabel}${strongest.label} ${Math.round(strongest.intensity)}`,hint:t("overview.emotionHint")},{key:"warmth",label:t("overview.warmth"),value:document2===void 0?unavailable:Math.round(document2.warmth).toString(),hint:t("overview.warmthHint")}],evolutionDoc=evolutionState?.doc,status=evolutionDoc?.status,lookEmpty=status!==void 0&&status.maxPerDay===0&&status.dayCount===0&&status.lastWakeAt===""&&status.nextAt==="",tell=evolutionDoc?.tell,pending2=tell===void 0?"":tell.pending!==""?tell.pending:tell.lastText,movement=[{key:"sleep",label:t("overview.sleep"),value:status===void 0||evolutionState?.status!=="ready"||lookEmpty?unavailable:status.started?status.sleeping?t("workbench.evolution.state.sleeping"):t("workbench.evolution.state.awake"):t("workbench.evolution.notStarted")},{key:"nextWake",label:t("overview.nextWake"),value:status===void 0||lookEmpty||!status.started?"—":stamp(status.nextAt),hint:t("overview.nextWakeHint")},{key:"tell",label:t("overview.tell"),value:pending2===""?t("overview.tellEmpty"):pending2,hint:t("overview.tellHint")}],memoryDoc=memoryState?.doc,memoryReady=memoryState?.status==="ready"&&memoryDoc!==void 0,collection=[{key:"memory",label:t("overview.memory"),value:memoryReady?t("overview.memoryValue",{count:String(memoryDoc.stats.total),publicCount:String(memoryDoc.stats.public),privateCount:String(memoryDoc.stats.private)}):unavailable,hint:t("overview.memoryHint")},{key:"diary",label:t("overview.diary"),value:evolutionState?.status!=="ready"||lookEmpty?unavailable:t("overview.diaryValue",{count:String(evolutionDoc?.diaryStats.total??0),opened:String(evolutionDoc?.diaryStats.opened??0)}),hint:t("overview.diaryHint")}];return(0,import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment,{children:[(0,import_jsx_runtime13.jsx)(MetricSection,{t,title:t("overview.identity"),metrics:identity}),(0,import_jsx_runtime13.jsx)(MetricSection,{t,title:t("overview.now"),metrics:now}),(0,import_jsx_runtime13.jsx)(MetricSection,{t,title:t("overview.movement"),metrics:movement}),(0,import_jsx_runtime13.jsx)(MetricSection,{t,title:t("overview.collection"),metrics:collection})]})}var import_dsh_client_ui_primitives8=require("@deepseek-ai/dsh-client-ui-primitives"),import_react10=require("react");var import_jsx_runtime14=require("react/jsx-runtime"),row2={display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"10px 0",borderTop:"1px solid var(--dsw-alias-border-l1)"},rowText={display:"flex",flexDirection:"column",gap:2,minWidth:0},rowHint={margin:0,fontSize:12,color:"var(--dsw-alias-label-secondary)"},numberInput={width:88};function SwitchRow({label,hintText,checked,disabled,onChange}){return(0,import_jsx_runtime14.jsxs)("div",{style:row2,children:[(0,import_jsx_runtime14.jsx)("div",{style:rowText,children:(0,import_jsx_runtime14.jsxs)("span",{style:headingWithHint,children:[label,hintText===void 0?null:(0,import_jsx_runtime14.jsx)(InfoHint,{label:hintText})]})}),(0,import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives8.Switch,{checked,disabled,label:String(label),onChange})]})}function NumberRow({label,hintText,value,min,max,disabled,unit,onCommit}){return(0,import_jsx_runtime14.jsxs)("div",{style:row2,children:[(0,import_jsx_runtime14.jsxs)("div",{style:rowText,children:[(0,import_jsx_runtime14.jsxs)("span",{style:headingWithHint,children:[label,hintText===void 0?null:(0,import_jsx_runtime14.jsx)(InfoHint,{label:hintText})]}),unit===void 0?null:(0,import_jsx_runtime14.jsx)("p",{style:rowHint,children:unit})]}),(0,import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives8.Input,{type:"number",style:numberInput,defaultValue:String(value),disabled,"aria-label":String(label),onKeyDown:event=>{event.key==="Enter"&&event.target.blur()},onBlur:event=>{let raw=Number(event.target.value);if(!Number.isFinite(raw))return;let next=Math.min(max,Math.max(min,Math.round(raw)));next!==value&&onCommit(next)}})]})}var SOURCE_KEYS={auto:"settings.time.source.auto",manual:"settings.time.source.manual",env:"settings.time.source.env",default:"settings.time.source.default"};function SettingsPage({t,controller,policy:policy2=policyOf("immersive"),timeBase}){let state=(0,import_react10.useSyncExternalStore)(controller.subscribe,controller.getSnapshot,controller.getSnapshot);(0,import_react10.useEffect)(()=>{controller.load()},[controller]);let config=state.config,editable=state.writable&&!state.saving,effective=timeBase?.effective??"";if(state.status==="unavailable")return(0,import_jsx_runtime14.jsx)("p",{style:subtitle,children:t("settings.unavailable")});if(state.status==="failed")return(0,import_jsx_runtime14.jsx)("p",{style:subtitle,children:t("settings.failed",{message:state.error??""})});if(config===void 0)return(0,import_jsx_runtime14.jsx)("p",{style:subtitle,children:t("settings.loading")});let mode=config.workbenchMode??"standard";return(0,import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment,{children:[(0,import_jsx_runtime14.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime14.jsxs)("h2",{style:{...panelTitle,...headingWithHint},children:[t("settings.mode.title"),(0,import_jsx_runtime14.jsx)(InfoHint,{label:t("settings.mode.hint")})]}),(0,import_jsx_runtime14.jsx)("div",{style:{...titleRow,marginTop:8},children:MODES.map(id=>(0,import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives8.Button,{size:"sm",variant:mode===id?"primary":"outline","aria-current":mode===id?"page":void 0,disabled:!policy2.switchMode||state.writable!==!0||state.saving,onClick:()=>{controller.setMode(id)},children:t(modeLabelKey(id))},id))}),(0,import_jsx_runtime14.jsx)("p",{style:{...rowHint,marginTop:8},children:t(modeHintKey(mode))}),state.error===void 0?null:(0,import_jsx_runtime14.jsx)("p",{style:{...hint,marginTop:8,color:"var(--dsw-alias-state-warn-label)"},role:"alert",children:state.error})]}),(0,import_jsx_runtime14.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime14.jsx)("h2",{style:panelTitle,children:t("settings.time.title")}),(0,import_jsx_runtime14.jsx)(SwitchRow,{label:t("settings.time.auto"),hintText:t("settings.time.autoHint"),checked:config.timeZone.auto,disabled:!policy2.timeZone||!editable,onChange:next=>{controller.patch({timeZone:{auto:next}})}}),(0,import_jsx_runtime14.jsxs)("div",{style:row2,children:[(0,import_jsx_runtime14.jsx)("div",{style:rowText,children:(0,import_jsx_runtime14.jsxs)("span",{style:headingWithHint,children:[t("settings.time.fixed"),(0,import_jsx_runtime14.jsx)(InfoHint,{label:t("settings.time.fixedHint")})]})}),(0,import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives8.Input,{style:{width:200},defaultValue:config.timeZone.fixed,placeholder:t("settings.time.fixedPlaceholder"),disabled:!policy2.timeZone||!editable||config.timeZone.auto,"aria-label":t("settings.time.fixed"),onKeyDown:event=>{event.key==="Enter"&&controller.patch({timeZone:{fixed:event.target.value.trim()}})}})]}),(0,import_jsx_runtime14.jsxs)("div",{style:row2,children:[(0,import_jsx_runtime14.jsx)("div",{style:rowText,children:(0,import_jsx_runtime14.jsxs)("span",{style:headingWithHint,children:[t("settings.time.effective"),(0,import_jsx_runtime14.jsx)(InfoHint,{label:t("settings.time.effectiveHint")})]})}),(0,import_jsx_runtime14.jsxs)("span",{style:{fontVariantNumeric:"tabular-nums",fontSize:13},children:[effective===""?t("settings.time.unknown"):effective,effective===""?"":` · ${t(SOURCE_KEYS[timeBase?.source??""]??"settings.time.source.default")}`]})]})]}),(0,import_jsx_runtime14.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime14.jsx)("h2",{style:panelTitle,children:t("settings.persona.title")}),(0,import_jsx_runtime14.jsx)(SwitchRow,{label:t("settings.persona.enabled"),hintText:t("settings.persona.enabledHint"),checked:config.modules.persona.enabled,disabled:!policy2.moduleSwitch||!editable,onChange:next=>{controller.patch({modules:{persona:{enabled:next}}})}}),(0,import_jsx_runtime14.jsx)(NumberRow,{label:t("settings.persona.retention"),hintText:t("settings.persona.retentionHint"),value:config.modules.persona.historyRetentionDays,min:0,max:3650,disabled:!policy2.advanced||!editable,unit:t("settings.unit.days"),onCommit:next=>{controller.patch({modules:{persona:{historyRetentionDays:next}}})}})]}),(0,import_jsx_runtime14.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime14.jsx)("h2",{style:panelTitle,children:t("settings.emotion.title")}),(0,import_jsx_runtime14.jsx)(SwitchRow,{label:t("settings.emotion.enabled"),hintText:t("settings.emotion.enabledHint"),checked:config.modules.emotion.enabled,disabled:!policy2.moduleSwitch||!editable,onChange:next=>{controller.patch({modules:{emotion:{enabled:next}}})}})]}),(0,import_jsx_runtime14.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime14.jsx)("h2",{style:panelTitle,children:t("settings.memory.title")}),(0,import_jsx_runtime14.jsx)(SwitchRow,{label:t("settings.memory.enabled"),hintText:t("settings.memory.enabledHint"),checked:config.modules.memory.enabled,disabled:!policy2.moduleSwitch||!editable,onChange:next=>{controller.patch({modules:{memory:{enabled:next}}})}}),(0,import_jsx_runtime14.jsx)(NumberRow,{label:t("settings.memory.maxInject"),hintText:t("settings.memory.maxInjectHint"),value:config.modules.memory.maxInject,min:0,max:3,disabled:!policy2.memoryInject||!editable,unit:t("settings.unit.entries"),onCommit:next=>{controller.patch({modules:{memory:{maxInject:next}}})}}),(0,import_jsx_runtime14.jsx)(SwitchRow,{label:t("settings.memory.decay"),hintText:t("settings.memory.decayHint"),checked:config.modules.memory.decay,disabled:!policy2.advanced||!editable,onChange:next=>{controller.patch({modules:{memory:{decay:next}}})}})]}),(0,import_jsx_runtime14.jsxs)("section",{style:panel,children:[(0,import_jsx_runtime14.jsx)("h2",{style:panelTitle,children:t("settings.autonomy.title")}),(0,import_jsx_runtime14.jsx)(SwitchRow,{label:t("settings.autonomy.enabled"),hintText:t("settings.autonomy.enabledHint"),checked:config.modules.evolution.enabled,disabled:!policy2.moduleSwitch||!editable,onChange:next=>{controller.patch({modules:{evolution:{enabled:next}}})}}),(0,import_jsx_runtime14.jsx)(NumberRow,{label:t("settings.autonomy.wakes"),hintText:t("settings.autonomy.wakesHint"),value:config.modules.evolution.maxWakesPerDay,min:0,max:24,disabled:!policy2.wakes||!editable,unit:t("settings.unit.timesPerDay"),onCommit:next=>{controller.patch({modules:{evolution:{maxWakesPerDay:next}}})}}),(0,import_jsx_runtime14.jsx)(NumberRow,{label:t("settings.autonomy.minGap"),hintText:t("settings.autonomy.gapHint"),value:config.modules.evolution.minGapMinutes,min:1,max:1440,disabled:!policy2.advanced||!editable,unit:t("settings.unit.minutes"),onCommit:next=>{controller.patch({modules:{evolution:{minGapMinutes:next}}})}}),(0,import_jsx_runtime14.jsx)(NumberRow,{label:t("settings.autonomy.maxGap"),value:config.modules.evolution.maxGapMinutes,min:1,max:1440,disabled:!policy2.advanced||!editable,unit:t("settings.unit.minutes"),onCommit:next=>{controller.patch({modules:{evolution:{maxGapMinutes:next}}})}}),(0,import_jsx_runtime14.jsxs)("div",{style:row2,children:[(0,import_jsx_runtime14.jsx)("div",{style:rowText,children:(0,import_jsx_runtime14.jsxs)("span",{style:headingWithHint,children:[t("settings.autonomy.room"),(0,import_jsx_runtime14.jsx)(InfoHint,{label:t("settings.autonomy.roomHint")})]})}),(0,import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives8.Input,{style:{width:240},defaultValue:config.modules.evolution.room,placeholder:t("settings.autonomy.roomPlaceholder"),disabled:!policy2.room||!editable,"aria-label":t("settings.autonomy.room"),onKeyDown:event=>{event.key==="Enter"&&controller.patch({modules:{evolution:{room:event.target.value.trim()}}})}})]})]}),(0,import_jsx_runtime14.jsx)("p",{style:{...subtitle,marginTop:12},children:state.saving?t("settings.saving"):state.savedAt===""?t("settings.readonly"):t("settings.saved")})]})}var import_jsx_runtime15=require("react/jsx-runtime"),PAGE_LABEL={overview:"page.overview",soul:"page.soul",identity:"page.identity",emotion:"page.emotion",memory:"page.memory",autonomy:"page.autonomy",settings:"page.settings"},PAGE_HINT={overview:"page.overviewHint",soul:"page.soulHint",identity:"page.identityHint",emotion:"page.emotionHint",memory:"page.memoryHint",autonomy:"page.autonomyHint",settings:"page.settingsHint"};function Workbench({t,persona,emotion,memory,evolution,settings}){let[current,setCurrent]=(0,import_react11.useState)(DEFAULT_PAGE),settingsState=(0,import_react11.useSyncExternalStore)(settings.subscribe,settings.getSnapshot,settings.getSnapshot),mode=settingsState.config?.workbenchMode??"standard",policy2=policyOf(mode),evolutionState=(0,import_react11.useSyncExternalStore)(evolution.subscribe,evolution.getSnapshot,evolution.getSnapshot),body=current==="overview"?(0,import_jsx_runtime15.jsx)(OverviewPage,{t,persona,emotion,memory,evolution,birthday:settingsState.config?.birthday??""}):current==="soul"?(0,import_jsx_runtime15.jsx)(SoulPage,{t,controller:persona,policy:policy2,birthday:settingsState.config?.birthday??"",onBirthday:next=>{settings.patch({birthday:next})}}):current==="identity"?(0,import_jsx_runtime15.jsx)(IdentityCardPage,{t,controller:persona,policy:policy2}):current==="emotion"?(0,import_jsx_runtime15.jsx)(EmotionPage,{t,controller:emotion,policy:policy2}):current==="memory"?(0,import_jsx_runtime15.jsx)(MemoryPage,{t,controller:memory,policy:policy2}):current==="autonomy"?(0,import_jsx_runtime15.jsx)(AutonomyPage,{t,controller:evolution,policy:policy2}):(0,import_jsx_runtime15.jsx)(SettingsPage,{t,controller:settings,policy:policy2,timeBase:evolutionState.doc.timeBase});return(0,import_jsx_runtime15.jsx)("div",{style:page,children:(0,import_jsx_runtime15.jsxs)("div",{style:column,children:[(0,import_jsx_runtime15.jsxs)("header",{children:[(0,import_jsx_runtime15.jsxs)("div",{style:titleRow,children:[(0,import_jsx_runtime15.jsx)("h1",{style:title,children:t(PAGE_LABEL[current])}),(0,import_jsx_runtime15.jsx)(InfoHint,{label:t(PAGE_HINT[current])})]}),(0,import_jsx_runtime15.jsx)("p",{style:subtitle,children:t(modeHintKey(mode))})]}),(0,import_jsx_runtime15.jsxs)("nav",{style:navBar,"aria-label":t("page.nav"),children:[(0,import_jsx_runtime15.jsx)("div",{style:navGrid,children:PAGES.map(id=>(0,import_jsx_runtime15.jsx)(import_dsh_client_ui_primitives9.Button,{size:"sm",variant:current===id?"primary":"outline","aria-current":current===id?"page":void 0,style:{width:"100%"},onClick:()=>setCurrent(id),children:t(PAGE_LABEL[id])},id))}),(0,import_jsx_runtime15.jsx)("span",{style:{fontSize:12,color:"var(--dsw-alias-label-secondary)",whiteSpace:"nowrap"},children:t(modeLabelKey(mode))})]}),body]})})}var import_jsx_runtime16=require("react/jsx-runtime"),fallbackTranslate=key=>String(key);function FallbackNote({kind}){return(0,import_jsx_runtime16.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,settings){return function(props){let t=typeof props?.t=="function"?props.t:fallbackTranslate,unwired=[controller,emotion,memory,evolution,settings].some(seat=>seat==null);return(0,import_jsx_runtime16.jsx)(PersonaBoundary,{fallback:(0,import_jsx_runtime16.jsx)(FallbackNote,{kind:"broken"}),children:unwired?(0,import_jsx_runtime16.jsx)(FallbackNote,{kind:"unwired"}):(0,import_jsx_runtime16.jsx)(Workbench,{t,persona:controller,emotion,memory,evolution,settings})})}}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,settings=new SettingsWorkbenchController;attachRemoteController(ctx,controller,PERSONA_NAMESPACE,"人格"),attachRemoteController(ctx,emotion,EMOTION_NAMESPACE,"情绪"),attachRemoteController(ctx,memory,MEMORY_NAMESPACE,"记忆",{pollMs:12e4}),attachRemoteController(ctx,evolution,EVOLUTION_NAMESPACE,"自主",{pollMs:6e4}),attachRemoteController(ctx,settings,"humanity","设置",{pollMs:6e4}),registerSidebarEntry(ctx),registerWorkbench(ctx,createWorkbenchSeat(controller,emotion,memory,evolution,settings))}
11
11
 
12
12
  return module.exports;
13
13
  }