neuro-simulator 0.5.2__py3-none-any.whl → 0.5.4__py3-none-any.whl

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.
Files changed (49) hide show
  1. neuro_simulator-0.5.2.dist-info/METADATA → README.md +0 -37
  2. WEBSOCKET_API.md +345 -0
  3. neuro_simulator/agent/memory/chat_history.json +20 -0
  4. neuro_simulator/agent/memory/core_memory.json +52 -0
  5. neuro_simulator/agent/memory/init_memory.json +42 -0
  6. neuro_simulator/agent/memory/temp_memory.json +8 -0
  7. neuro_simulator/api/system.py +0 -9
  8. neuro_simulator/chatbot/memory/core_memory.json +15 -0
  9. neuro_simulator/chatbot/memory/init_memory.json +13 -0
  10. neuro_simulator/chatbot/memory/temp_memory.json +1 -0
  11. neuro_simulator/chatbot/nickname_gen/data/adjectives.txt +8 -0
  12. neuro_simulator/chatbot/nickname_gen/data/nouns.txt +8 -0
  13. neuro_simulator/chatbot/nickname_gen/data/special_users.txt +14 -0
  14. neuro_simulator/chatbot/prompts/chatbot_prompt.txt +30 -0
  15. neuro_simulator/chatbot/prompts/memory_prompt.txt +14 -0
  16. neuro_simulator/core/application.py +44 -1
  17. neuro_simulator/dashboard/assets/AgentView-C6qW7TIe.js +2 -0
  18. neuro_simulator/dashboard/assets/AgentView-TDgmx5bK.css +1 -0
  19. neuro_simulator/dashboard/assets/ChatBotView-BRYIM_8s.js +2 -0
  20. neuro_simulator/dashboard/assets/ChatBotView-Dyd6g14G.css +1 -0
  21. neuro_simulator/dashboard/assets/ConfigView-Cw-VPFzt.js +2 -0
  22. neuro_simulator/dashboard/assets/ContextTab-DyPsixHQ.css +1 -0
  23. neuro_simulator/dashboard/assets/ContextTab-GRHICOS3.js +1 -0
  24. neuro_simulator/dashboard/assets/ControlView-BUCt3umR.css +1 -0
  25. neuro_simulator/dashboard/assets/ControlView-D5vPB_OE.js +1 -0
  26. neuro_simulator/dashboard/assets/FieldRenderer-DaTYxmtO.js +1 -0
  27. neuro_simulator/dashboard/assets/LogsTab-CATao-mZ.js +1 -0
  28. neuro_simulator/dashboard/assets/LogsTab-wg3i3S6b.css +1 -0
  29. neuro_simulator/dashboard/assets/LogsView-BM419A5R.js +1 -0
  30. neuro_simulator/dashboard/assets/LogsView-D2F8f-Mc.css +1 -0
  31. neuro_simulator/dashboard/assets/MemoryTab-BSUWFbcV.js +6 -0
  32. neuro_simulator/dashboard/assets/MemoryTab-DPthi6jg.css +1 -0
  33. neuro_simulator/dashboard/assets/ToolsTab-Bjcm3fFL.js +1 -0
  34. neuro_simulator/dashboard/assets/index-BiAhe8fO.js +34 -0
  35. neuro_simulator/dashboard/assets/index-C7dox9UB.css +5 -0
  36. neuro_simulator/dashboard/assets/materialdesignicons-webfont-B7mPwVP_.ttf +0 -0
  37. neuro_simulator/dashboard/assets/materialdesignicons-webfont-CSr8KVlo.eot +0 -0
  38. neuro_simulator/dashboard/assets/materialdesignicons-webfont-Dp5v-WZN.woff2 +0 -0
  39. neuro_simulator/dashboard/assets/materialdesignicons-webfont-PXm3-2wK.woff +0 -0
  40. neuro_simulator/dashboard/favicon.ico +0 -0
  41. neuro_simulator/dashboard/first-coffee.woff2 +0 -0
  42. neuro_simulator/dashboard/index.html +14 -0
  43. neuro_simulator-0.5.4.dist-info/METADATA +284 -0
  44. {neuro_simulator-0.5.2.dist-info → neuro_simulator-0.5.4.dist-info}/RECORD +48 -7
  45. {neuro_simulator-0.5.2.dist-info → neuro_simulator-0.5.4.dist-info}/WHEEL +1 -2
  46. neuro_simulator-0.5.4.dist-info/licenses/LICENSE +21 -0
  47. requirements.txt +11 -0
  48. neuro_simulator-0.5.2.dist-info/top_level.txt +0 -1
  49. {neuro_simulator-0.5.2.dist-info → neuro_simulator-0.5.4.dist-info}/entry_points.txt +0 -0
@@ -9,7 +9,6 @@ import re
9
9
  import time
10
10
  import os
11
11
  from typing import List
12
-
13
12
  from fastapi import FastAPI, WebSocket, WebSocketDisconnect
14
13
  from fastapi.middleware.cors import CORSMiddleware
15
14
  from starlette.websockets import WebSocketState
@@ -25,6 +24,13 @@ from ..services.builtin import BuiltinAgentWrapper
25
24
  # --- API Routers ---
26
25
  from ..api.system import router as system_router
27
26
 
27
+ # --- Additional Imports for SPA Hosting ---
28
+ import os
29
+ from importlib.resources import files # Modern way to find package resources
30
+ from fastapi.responses import FileResponse
31
+ from starlette.staticfiles import StaticFiles
32
+ from starlette.exceptions import HTTPException as StarletteHTTPException
33
+
28
34
  # --- Services and Utilities ---
29
35
  from ..services.audio import synthesize_audio_segment
30
36
  from ..services.stream import live_stream_manager
@@ -222,6 +228,43 @@ async def neuro_response_cycle():
222
228
  @app.on_event("startup")
223
229
  async def startup_event():
224
230
  """Actions to perform on application startup."""
231
+ # --- Mount Frontend ---
232
+ # This logic is placed here to run at runtime, ensuring all package paths are finalized.
233
+ from fastapi.responses import FileResponse
234
+ from starlette.staticfiles import StaticFiles
235
+ from starlette.exceptions import HTTPException as StarletteHTTPException
236
+ from importlib.resources import files
237
+
238
+ class SPAStaticFiles(StaticFiles):
239
+ async def get_response(self, path: str, scope):
240
+ try:
241
+ return await super().get_response(path, scope)
242
+ except (StarletteHTTPException) as ex:
243
+ if ex.status_code == 404:
244
+ return await super().get_response("index.html", scope)
245
+ else:
246
+ raise ex
247
+ try:
248
+ # Production/Standard install: find frontend in the package
249
+ frontend_dir_traversable = files('neuro_simulator').joinpath('dashboard')
250
+ if not frontend_dir_traversable.is_dir(): raise FileNotFoundError
251
+ frontend_dir = str(frontend_dir_traversable)
252
+ logger.info(f"Found frontend via package resources (production mode): '{frontend_dir}'")
253
+ except (ModuleNotFoundError, FileNotFoundError):
254
+ # Editable/Development install: fall back to relative path from source
255
+ logger.info("Could not find frontend via package resources, falling back to development mode path.")
256
+ dev_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'dashboard', 'dist'))
257
+ if os.path.isdir(dev_path):
258
+ frontend_dir = dev_path
259
+ logger.info(f"Found frontend via relative path (development mode): '{frontend_dir}'")
260
+ else:
261
+ frontend_dir = None
262
+
263
+ if frontend_dir:
264
+ app.mount("/", SPAStaticFiles(directory=frontend_dir, html=True), name="dashboard")
265
+ else:
266
+ logger.error("Frontend directory not found in either production or development locations.")
267
+
225
268
  # 1. Configure logging first
226
269
  configure_server_logging()
227
270
 
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContextTab-GRHICOS3.js","assets/index-BiAhe8fO.js","assets/index-C7dox9UB.css","assets/ContextTab-DyPsixHQ.css","assets/MemoryTab-BSUWFbcV.js","assets/MemoryTab-DPthi6jg.css","assets/ToolsTab-Bjcm3fFL.js","assets/LogsTab-CATao-mZ.js","assets/LogsTab-wg3i3S6b.css"])))=>i.map(i=>d[i]);
2
+ import{d as C,i as k,j as I,k as L,m as c,y as P,e as t,g as v,w as o,b as n,f as a,h as d,p as r,q as u,o as f,_ as D}from"./index-BiAhe8fO.js";const N={class:"agent-view-wrapper"},O={key:0,class:"overlay"},R={class:"overlay-content"},B=C({__name:"AgentView",setup(S){const g=r(()=>u(()=>import("./ContextTab-GRHICOS3.js"),__vite__mapDeps([0,1,2,3]))),b=r(()=>u(()=>import("./MemoryTab-BSUWFbcV.js"),__vite__mapDeps([4,1,2,5]))),V=r(()=>u(()=>import("./ToolsTab-Bjcm3fFL.js"),__vite__mapDeps([6,1,2]))),w=r(()=>u(()=>import("./LogsTab-CATao-mZ.js"),__vite__mapDeps([7,1,2,8]))),m=k(),s=I("context"),p=L(()=>m.config?.agent_type&&m.config.agent_type!=="builtin");return(U,e)=>{const x=n("v-icon"),l=n("v-tab"),y=n("v-tabs"),_=n("v-window-item"),E=n("v-window"),T=n("v-card-text"),A=n("v-card");return f(),c("div",N,[p.value?(f(),c("div",O,[v("div",R,[t(x,{size:"x-large",class:"mb-4"},{default:o(()=>[...e[2]||(e[2]=[a("mdi-link-variant",-1)])]),_:1}),e[3]||(e[3]=v("h2",{class:"text-h5"},"当前正在调用外部 Agent",-1)),e[4]||(e[4]=v("p",{class:"text-body-1"},"请前往相应平台进行控制",-1))])])):P("",!0),t(A,{disabled:p.value},{default:o(()=>[t(y,{modelValue:s.value,"onUpdate:modelValue":e[0]||(e[0]=i=>s.value=i),"bg-color":"primary",grow:""},{default:o(()=>[t(l,{value:"context"},{default:o(()=>[...e[5]||(e[5]=[a("对话",-1)])]),_:1}),t(l,{value:"memory"},{default:o(()=>[...e[6]||(e[6]=[a("记忆",-1)])]),_:1}),t(l,{value:"tools"},{default:o(()=>[...e[7]||(e[7]=[a("工具",-1)])]),_:1}),t(l,{value:"logs"},{default:o(()=>[...e[8]||(e[8]=[a("日志",-1)])]),_:1})]),_:1},8,["modelValue"]),t(T,null,{default:o(()=>[t(E,{modelValue:s.value,"onUpdate:modelValue":e[1]||(e[1]=i=>s.value=i)},{default:o(()=>[t(_,{value:"context"},{default:o(()=>[t(d(g))]),_:1}),t(_,{value:"memory"},{default:o(()=>[t(d(b))]),_:1}),t(_,{value:"tools"},{default:o(()=>[t(d(V))]),_:1}),t(_,{value:"logs"},{default:o(()=>[t(d(w))]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["disabled"])])}}}),q=D(B,[["__scopeId","data-v-871d2dc1"]]);export{q as default};
@@ -0,0 +1 @@
1
+ .agent-view-wrapper[data-v-871d2dc1]{position:relative}.overlay[data-v-871d2dc1]{position:absolute;inset:0;background-color:#ffffffb3;z-index:10;display:flex;align-items:center;justify-content:center;border-radius:4px}.overlay-content[data-v-871d2dc1]{text-align:center;padding:20px;background-color:#fffffff2;border-radius:8px;box-shadow:0 4px 12px #0000001a}
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContextTab-GRHICOS3.js","assets/index-BiAhe8fO.js","assets/index-C7dox9UB.css","assets/ContextTab-DyPsixHQ.css","assets/MemoryTab-BSUWFbcV.js","assets/MemoryTab-DPthi6jg.css","assets/ToolsTab-Bjcm3fFL.js","assets/LogsTab-CATao-mZ.js","assets/LogsTab-wg3i3S6b.css"])))=>i.map(i=>d[i]);
2
+ import{d as E,j as y,m as C,g as d,e as o,w as e,b as a,f as n,h as u,p as r,q as v,o as g,_ as A}from"./index-BiAhe8fO.js";const I={class:"chatbot-view-wrapper"},P={class:"overlay"},B={class:"overlay-content"},L=E({__name:"ChatBotView",setup(D){const i=r(()=>v(()=>import("./ContextTab-GRHICOS3.js"),__vite__mapDeps([0,1,2,3]))),p=r(()=>v(()=>import("./MemoryTab-BSUWFbcV.js"),__vite__mapDeps([4,1,2,5]))),f=r(()=>v(()=>import("./ToolsTab-Bjcm3fFL.js"),__vite__mapDeps([6,1,2]))),c=r(()=>v(()=>import("./LogsTab-CATao-mZ.js"),__vite__mapDeps([7,1,2,8]))),s=y("context");return(O,t)=>{const b=a("v-icon"),l=a("v-tab"),w=a("v-tabs"),_=a("v-window-item"),V=a("v-window"),x=a("v-card-text"),T=a("v-card");return g(),C("div",I,[d("div",P,[d("div",B,[o(b,{size:"x-large",class:"mb-4"},{default:e(()=>[...t[2]||(t[2]=[n("mdi-dev-to",-1)])]),_:1}),t[3]||(t[3]=d("h2",{class:"text-h5"},"Chatbot 控制开发中",-1)),t[4]||(t[4]=d("p",{class:"text-body-1"},"后端 API 尚未实现",-1))])]),o(T,null,{default:e(()=>[o(w,{modelValue:s.value,"onUpdate:modelValue":t[0]||(t[0]=m=>s.value=m),"bg-color":"primary",grow:""},{default:e(()=>[o(l,{value:"context"},{default:e(()=>[...t[5]||(t[5]=[n("对话",-1)])]),_:1}),o(l,{value:"memory"},{default:e(()=>[...t[6]||(t[6]=[n("记忆",-1)])]),_:1}),o(l,{value:"tools"},{default:e(()=>[...t[7]||(t[7]=[n("工具",-1)])]),_:1}),o(l,{value:"logs"},{default:e(()=>[...t[8]||(t[8]=[n("日志",-1)])]),_:1})]),_:1},8,["modelValue"]),o(x,null,{default:e(()=>[o(V,{modelValue:s.value,"onUpdate:modelValue":t[1]||(t[1]=m=>s.value=m)},{default:e(()=>[o(_,{value:"context"},{default:e(()=>[o(u(i))]),_:1}),o(_,{value:"memory"},{default:e(()=>[o(u(p))]),_:1}),o(_,{value:"tools"},{default:e(()=>[o(u(f))]),_:1}),o(_,{value:"logs"},{default:e(()=>[o(u(c))]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1})])}}}),N=A(L,[["__scopeId","data-v-ed63d404"]]);export{N as default};
@@ -0,0 +1 @@
1
+ .chatbot-view-wrapper[data-v-ed63d404]{position:relative}.overlay[data-v-ed63d404]{position:absolute;inset:0;background-color:#ffffffb3;z-index:10;display:flex;align-items:center;justify-content:center;border-radius:inherit}.overlay-content[data-v-ed63d404]{text-align:center;padding:20px;background-color:#fffffff2;border-radius:8px;box-shadow:0 4px 12px #0000001a}
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FieldRenderer-DaTYxmtO.js","assets/index-BiAhe8fO.js","assets/index-C7dox9UB.css"])))=>i.map(i=>d[i]);
2
+ import{d as N,i as A,a as E,j as g,k as G,l as L,m as s,e as r,g as O,b as n,w as l,F as k,n as w,f as V,o,c as h,t as $,h as D,p as M,q as P}from"./index-BiAhe8fO.js";const R={key:0,class:"text-center pa-10"},T={key:1},I=N({__name:"ConfigView",setup(U){const S=M(()=>P(()=>import("./FieldRenderer-DaTYxmtO.js"),__vite__mapDeps([0,1,2]))),c=A(),b=E(),_=g(!0),u=g(null),f=g(!1),C=G(()=>{const a=c.schema;return!a||!a.properties?[]:Object.keys(a.properties).map(e=>{const i=a.properties[e];if(i.$ref){const v=i.$ref.split("/").pop()||"",d=a.$defs?.[v]||{},p=d.properties||{};return{key:e,title:d.title||e,isGroup:!0,properties:Object.keys(p).map(m=>({key:m,schema:p[m]}))}}return{key:e,title:i.title||e,isGroup:!1,properties:[{key:e,schema:i}]}})});async function x(){if(b.isConnected){f.value=!0;try{await b.sendAdminWsMessage("update_configs",c.config),console.log("Config saved successfully!")}catch(a){console.error("Failed to save config:",a)}finally{f.value=!1}}}return L(async()=>{_.value=!0;try{await c.fetchSchema(),await c.fetchConfig()}finally{_.value=!1}}),(a,e)=>{const i=n("v-progress-circular"),v=n("v-tab"),d=n("v-tabs"),p=n("v-btn"),m=n("v-card-actions"),j=n("v-card"),B=n("v-window-item"),F=n("v-window");return o(),s("div",null,[_.value?(o(),s("div",R,[r(i,{indeterminate:"",color:"primary"}),e[2]||(e[2]=O("p",{class:"mt-4"},"正在加载配置...",-1))])):(o(),s("div",T,[r(d,{modelValue:u.value,"onUpdate:modelValue":e[0]||(e[0]=t=>u.value=t),"bg-color":"primary",class:"mb-4",grow:""},{default:l(()=>[(o(!0),s(k,null,w(C.value,t=>(o(),h(v,{key:t.key,value:t.key},{default:l(()=>[V($(t.title),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"]),r(m,{class:"justify-end pa-4"},{default:l(()=>[r(p,{onClick:x,color:"primary",variant:"flat",loading:f.value},{default:l(()=>[...e[3]||(e[3]=[V("保存配置",-1)])]),_:1},8,["loading"])]),_:1}),r(F,{modelValue:u.value,"onUpdate:modelValue":e[1]||(e[1]=t=>u.value=t),eager:""},{default:l(()=>[(o(!0),s(k,null,w(C.value,t=>(o(),h(B,{key:t.key,value:t.key},{default:l(()=>[r(j,{flat:"",class:"pa-4"},{default:l(()=>[(o(!0),s(k,null,w(t.properties,y=>(o(),s("div",{key:y.key},[r(D(S),{"group-key":t.isGroup?t.key:null,"prop-key":y.key,"prop-schema":y.schema},null,8,["group-key","prop-key","prop-schema"])]))),128))]),_:2},1024)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]))])}}});export{I as default};
@@ -0,0 +1 @@
1
+ .context-prompt-view pre[data-v-dd6969bb]{background-color:#1e1e1e;color:#d4d4d4;font-family:Courier New,Courier,monospace;padding:16px;border-radius:4px;white-space:pre-wrap;word-wrap:break-word;max-height:70vh;overflow-y:auto}.message-item[data-v-dd6969bb]{padding:8px 0;border-bottom:1px solid #e0e0e0}
@@ -0,0 +1 @@
1
+ import{d as m,j as g,z as v,a as x,v as f,b as C,m as o,o as s,g as r,e as h,t as l,h as p,F as y,n as b,f as w,_ as V}from"./index-BiAhe8fO.js";const k={class:"d-flex align-center mb-4"},S={key:0,class:"context-prompt-view"},M={key:1,class:"context-conversation-view"},A=m({__name:"ContextTab",setup(B){const t=g(!1),n=v(),c=x();async function i(){if(c.isConnected)if(t.value)try{const e=await c.sendAdminWsMessage("get_last_prompt");n.agentContext=e.prompt}catch(e){console.error("获取最新Prompt失败:",e),n.agentContext=`获取提示词失败: ${e}`}else try{const e=await c.sendAdminWsMessage("get_agent_context");n.agentContext=e}catch(e){console.error("获取上下文失败:",e)}}return f(t,i),i(),(e,d)=>{const u=C("v-switch");return s(),o("div",null,[r("div",k,[h(u,{modelValue:t.value,"onUpdate:modelValue":d[0]||(d[0]=a=>t.value=a),label:"上下文模式",color:"primary","hide-details":""},null,8,["modelValue"])]),t.value?(s(),o("div",S,[r("pre",null,l(p(n).agentContext),1)])):(s(),o("div",M,[(s(!0),o(y,null,b(p(n).agentContext,(a,_)=>(s(),o("div",{key:_,class:"message-item"},[r("p",null,[r("strong",null,l(a.role)+":",1),w(" "+l(a.content),1)])]))),128))]))])}}}),T=V(A,[["__scopeId","data-v-dd6969bb"]]);export{T as default};
@@ -0,0 +1 @@
1
+ .stream-status[data-v-607a7661]{margin-bottom:20px}.control-buttons[data-v-607a7661]{display:flex;gap:16px}
@@ -0,0 +1 @@
1
+ import{d as C,u as S,a as w,r as x,c as k,w as o,b as r,e as a,f as n,g as i,h as _,t as V,o as b,_ as A}from"./index-BiAhe8fO.js";const B={class:"stream-status"},M={class:"control-buttons"},N=C({__name:"ControlView",setup(W){const d=S(),l=w(),e=x({start:!1,stop:!1,restart:!1});async function u(){e.start=!0;try{await l.sendAdminWsMessage("start_stream")}catch(s){console.error(s)}finally{e.start=!1}}async function f(){e.stop=!0;try{await l.sendAdminWsMessage("stop_stream")}catch(s){console.error(s)}finally{e.stop=!1}}async function p(){e.restart=!0;try{await l.sendAdminWsMessage("restart_stream")}catch(s){console.error(s)}finally{e.restart=!1}}return(s,t)=>{const m=r("v-card-title"),g=r("v-chip"),c=r("v-btn"),v=r("v-card-text"),y=r("v-card");return b(),k(y,null,{default:o(()=>[a(m,null,{default:o(()=>[...t[0]||(t[0]=[n("直播控制",-1)])]),_:1}),a(v,null,{default:o(()=>[i("div",B,[i("p",null,[t[1]||(t[1]=n("当前状态: ",-1)),a(g,{color:_(d).isRunning?"green":"red",dark:""},{default:o(()=>[n(V(_(d).isRunning?"运行中":"已停止"),1)]),_:1},8,["color"])])]),i("div",M,[a(c,{color:"primary",onClick:u,loading:e.start},{default:o(()=>[...t[2]||(t[2]=[n("开始直播",-1)])]),_:1},8,["loading"]),a(c,{color:"error",onClick:f,loading:e.stop},{default:o(()=>[...t[3]||(t[3]=[n("停止直播",-1)])]),_:1},8,["loading"]),a(c,{color:"warning",onClick:p,loading:e.restart},{default:o(()=>[...t[4]||(t[4]=[n("重启直播",-1)])]),_:1},8,["loading"])])]),_:1})]),_:1})}}}),D=A(N,[["__scopeId","data-v-607a7661"]]);export{D as default};
@@ -0,0 +1 @@
1
+ import{d as f,i as b,k as S,b as p,m as V,o as a,c as r,y as d}from"./index-BiAhe8fO.js";const g={class:"mb-6"},k=f({__name:"FieldRenderer",props:{groupKey:{},propKey:{},propSchema:{}},setup(e){const o=e,m=b();function i(u){return o.propSchema.type===u?!0:Array.isArray(o.propSchema.anyOf)?o.propSchema.anyOf.some(t=>t.type===u):!1}const l=S({get(){return o.groupKey?m.config[o.groupKey]?.[o.propKey]:m.config[o.propKey]},set(u){o.groupKey?(m.config[o.groupKey]||(m.config[o.groupKey]={}),m.config[o.groupKey][o.propKey]=u):m.config[o.propKey]=u}});return(u,t)=>{const c=p("v-text-field"),s=p("v-textarea"),y=p("v-switch"),h=p("v-select"),v=p("v-combobox");return a(),V("div",g,[i("integer")||i("number")?(a(),r(c,{key:0,modelValue:l.value,"onUpdate:modelValue":t[0]||(t[0]=n=>l.value=n),modelModifiers:{number:!0},label:e.propSchema.title||e.propKey,hint:e.propSchema.description,type:"number","persistent-hint":"",variant:"outlined",density:"compact"},null,8,["modelValue","label","hint"])):i("string")&&e.propSchema.format==="password"?(a(),r(c,{key:1,modelValue:l.value,"onUpdate:modelValue":t[1]||(t[1]=n=>l.value=n),label:e.propSchema.title||e.propKey,hint:e.propSchema.description,type:"password","persistent-hint":"",variant:"outlined",density:"compact"},null,8,["modelValue","label","hint"])):i("string")&&e.propSchema.format==="text-area"?(a(),r(s,{key:2,modelValue:l.value,"onUpdate:modelValue":t[2]||(t[2]=n=>l.value=n),label:e.propSchema.title||e.propKey,hint:e.propSchema.description,"persistent-hint":"",variant:"outlined"},null,8,["modelValue","label","hint"])):i("string")&&!e.propSchema.enum?(a(),r(c,{key:3,modelValue:l.value,"onUpdate:modelValue":t[3]||(t[3]=n=>l.value=n),label:e.propSchema.title||e.propKey,hint:e.propSchema.description,"persistent-hint":"",variant:"outlined",density:"compact"},null,8,["modelValue","label","hint"])):d("",!0),i("boolean")?(a(),r(y,{key:4,modelValue:l.value,"onUpdate:modelValue":t[4]||(t[4]=n=>l.value=n),label:e.propSchema.title||e.propKey,hint:e.propSchema.description,"persistent-hint":"",color:"primary",inset:""},null,8,["modelValue","label","hint"])):d("",!0),e.propSchema.enum?(a(),r(h,{key:5,modelValue:l.value,"onUpdate:modelValue":t[5]||(t[5]=n=>l.value=n),items:e.propSchema.enum,label:e.propSchema.title||e.propKey,hint:e.propSchema.description,"persistent-hint":"",variant:"outlined",density:"compact"},null,8,["modelValue","items","label","hint"])):d("",!0),i("array")?(a(),r(v,{key:6,modelValue:l.value,"onUpdate:modelValue":t[6]||(t[6]=n=>l.value=n),label:e.propSchema.title||e.propKey,hint:e.propSchema.description,"persistent-hint":"",chips:"",multiple:"","closable-chips":"",variant:"outlined",density:"compact"},null,8,["modelValue","label","hint"])):d("",!0)])}}});export{k as default};
@@ -0,0 +1 @@
1
+ import{d as r,s as l,j as c,v as g,m as s,o as t,F as u,n as i,t as _,h as p,x as f,_ as d}from"./index-BiAhe8fO.js";const m=r({__name:"LogsTab",setup(v){const a=l(),e=c(null);return g(()=>a.agentLogs.length,async()=>{await f(),e.value&&(e.value.scrollTop=e.value.scrollHeight)},{deep:!0}),(L,h)=>(t(),s("div",{ref_key:"logsContainer",ref:e,class:"logs-output"},[(t(!0),s(u,null,i(p(a).agentLogs,(o,n)=>(t(),s("div",{key:`agent-${n}`,class:"log-entry"},_(o),1))),128))],512))}}),x=d(m,[["__scopeId","data-v-20098789"]]);export{x as default};
@@ -0,0 +1 @@
1
+ .logs-output[data-v-20098789]{background-color:#1e1e1e;color:#d4d4d4;font-family:Courier New,Courier,monospace;font-size:.9rem;white-space:pre-wrap;height:70vh;overflow-y:auto;padding:16px;border-radius:4px}.log-entry[data-v-20098789]{margin-bottom:4px}
@@ -0,0 +1 @@
1
+ import{d as v,s as f,j as p,v as g,c as m,w as t,b as s,e as n,f as x,g as k,m as l,n as w,h as L,F as y,o as a,t as C,x as V,_ as h}from"./index-BiAhe8fO.js";const B=v({__name:"LogsView",setup(S){const o=f(),e=p(null);return g(()=>o.serverLogs.length,async()=>{await V(),e.value&&(e.value.scrollTop=e.value.scrollHeight)},{deep:!0}),(N,r)=>{const c=s("v-card-title"),_=s("v-card-text"),d=s("v-card");return a(),m(d,null,{default:t(()=>[n(c,null,{default:t(()=>[...r[0]||(r[0]=[x("Server 日志",-1)])]),_:1}),n(_,null,{default:t(()=>[k("div",{ref_key:"logsContainer",ref:e,class:"logs-output"},[(a(!0),l(y,null,w(L(o).serverLogs,(u,i)=>(a(),l("div",{key:`server-${i}`,class:"log-entry"},C(u),1))),128))],512)]),_:1})]),_:1})}}}),F=h(B,[["__scopeId","data-v-f9df559f"]]);export{F as default};
@@ -0,0 +1 @@
1
+ .logs-output[data-v-f9df559f]{background-color:#1e1e1e;color:#d4d4d4;font-family:Courier New,Courier,monospace;font-size:.9rem;white-space:pre-wrap;height:75vh;overflow-y:auto;padding:16px;border-radius:4px}.log-entry[data-v-f9df559f]{margin-bottom:4px}
@@ -0,0 +1,6 @@
1
+ import{d as le,z as ne,a as oe,A as re,j as x,l as ae,b as i,m as f,o as s,e as t,w as l,g as v,c as V,f as d,h as k,F as U,n as F,t as C,_ as ie}from"./index-BiAhe8fO.js";const se={class:"d-flex mb-4"},de={key:1},ue={class:"d-flex mb-4"},me={key:1},ce={class:"d-flex mb-4"},fe={key:0},ve={key:1},pe={class:"text-h5"},_e={class:"text-h5"},ye=le({__name:"MemoryTab",setup(xe){const p=ne(),a=oe();re();const M=x(!1),y=x({role:"user",content:""}),g=x(!1),m=x({}),b=x(!1),c=x({});function z(n=null){n?m.value={...n,contentStr:n.content.join(`
2
+ `)}:m.value={title:"",description:"",contentStr:""},g.value=!0}async function G(){if(!a.isConnected)return;const n=m.value,e={title:n.title,description:n.description,content:n.contentStr.split(`
3
+ `).filter(r=>r.trim()!=="")};try{n.id?await a.sendAdminWsMessage("update_core_memory_block",{block_id:n.id,...e}):await a.sendAdminWsMessage("create_core_memory_block",e),g.value=!1}catch(r){console.error("Failed to save core memory block:",r)}}function O(n=null,e=null){if(n!==null){let r=e;Array.isArray(e)?r=e.join(`
4
+ `):typeof e=="object"&&(r=JSON.stringify(e,null,2)),c.value={key:n,valueStr:r,isEditing:!0}}else c.value={key:"",valueStr:"",isEditing:!1};b.value=!0}async function H(){if(!a.isConnected||!c.value.key.trim())return;const{key:n,valueStr:e}=c.value;let r=e;try{const u=e.trim();u.startsWith("{")&&u.endsWith("}")||u.startsWith("[")&&u.endsWith("]")?r=JSON.parse(u):u.includes(`
5
+ `)&&(r=u.split(`
6
+ `).filter(S=>S.trim()!==""))}catch(u){console.warn("Could not parse value as JSON or array, saving as string.",u)}try{await a.sendAdminWsMessage("update_init_memory_item",{key:n,value:r}),b.value=!1}catch(u){console.error(`Failed to save init memory item ${n}:`,u)}}async function K(){if(!(!a.isConnected||!y.value.content.trim()))try{await a.sendAdminWsMessage("add_temp_memory",y.value),M.value=!1,y.value.content=""}catch(n){console.error("Failed to add temp memory:",n)}}async function Q(n){if(a.isConnected&&confirm("确定要删除这个记忆块吗?"))try{await a.sendAdminWsMessage("delete_core_memory_block",{block_id:n})}catch(e){console.error(`Failed to delete core memory block ${n}:`,e)}}async function R(n){if(a.isConnected&&confirm(`确定要删除键 "${n}" 吗?`))try{await a.sendAdminWsMessage("delete_init_memory_key",{key:n})}catch(e){console.error(`Failed to delete init memory item ${n}:`,e)}}async function X(n){if(a.isConnected)try{await a.sendAdminWsMessage("delete_temp_memory_item",{item_id:n})}catch(e){console.error(`Failed to delete temp memory item ${n}:`,e)}}async function Y(){if(a.isConnected&&confirm("确定要清空所有临时记忆吗?"))try{await a.sendAdminWsMessage("clear_temp_memory")}catch(n){console.error("Failed to clear temp memory:",n)}}async function E(){if(a.isConnected)try{const n=await a.sendAdminWsMessage("get_init_memory");p.handleInitMemoryUpdate(n)}catch(n){console.error("Failed to refresh init memory:",n)}}async function q(){if(a.isConnected)try{const n=await a.sendAdminWsMessage("get_temp_memory");p.handleTempMemoryUpdate(n)}catch(n){console.error("Failed to refresh temp memory:",n)}}async function J(){if(a.isConnected)try{const n=await a.sendAdminWsMessage("get_core_memory_blocks");p.handleCoreMemoryUpdate(n)}catch(n){console.error("Failed to refresh core memory:",n)}}async function Z(){a.isConnected&&await Promise.all([E(),q(),J()])}return ae(()=>{Z()}),(n,e)=>{const r=i("v-btn"),u=i("v-list-item-subtitle"),S=i("v-list-item"),L=i("v-list"),T=i("v-expansion-panel-text"),I=i("v-expansion-panel"),w=i("v-card-title"),h=i("v-card-subtitle"),$=i("v-card-text"),A=i("v-card"),ee=i("v-expansion-panels"),te=i("v-select"),W=i("v-textarea"),j=i("v-spacer"),B=i("v-card-actions"),D=i("v-dialog"),P=i("v-text-field");return s(),f("div",null,[t(ee,{variant:"inset",class:"my-4"},{default:l(()=>[t(I,{title:"初始化记忆 (Init Memory)"},{default:l(()=>[t(T,null,{default:l(()=>[v("div",se,[t(r,{onClick:E,class:"mr-2"},{default:l(()=>[...e[16]||(e[16]=[d("刷新",-1)])]),_:1}),t(r,{onClick:e[0]||(e[0]=o=>O()),color:"primary"},{default:l(()=>[...e[17]||(e[17]=[d("添加",-1)])]),_:1})]),Object.keys(k(p).initMemory).length>0?(s(),V(L,{key:0,lines:"one"},{default:l(()=>[(s(!0),f(U,null,F(k(p).initMemory,(o,_)=>(s(),V(S,{key:_,title:_},{append:l(()=>[t(r,{onClick:N=>O(_.toString(),o),icon:"mdi-pencil",size:"x-small",variant:"text"},null,8,["onClick"]),t(r,{onClick:N=>R(_.toString()),icon:"mdi-delete",size:"x-small",variant:"text",color:"error"},null,8,["onClick"])]),default:l(()=>[t(u,{class:"value-display"},{default:l(()=>[v("pre",null,C(o),1)]),_:2},1024)]),_:2},1032,["title"]))),128))]),_:1})):(s(),f("p",de,"没有初始化记忆。"))]),_:1})]),_:1}),t(I,{title:"临时记忆 (Temp Memory)"},{default:l(()=>[t(T,null,{default:l(()=>[v("div",ue,[t(r,{onClick:q,class:"mr-2"},{default:l(()=>[...e[18]||(e[18]=[d("刷新",-1)])]),_:1}),t(r,{onClick:e[1]||(e[1]=o=>M.value=!0),color:"primary",class:"mr-2"},{default:l(()=>[...e[19]||(e[19]=[d("添加",-1)])]),_:1}),t(r,{onClick:Y,color:"error"},{default:l(()=>[...e[20]||(e[20]=[d("清空",-1)])]),_:1})]),k(p).tempMemory.length>0?(s(),V(L,{key:0,lines:"one"},{default:l(()=>[(s(!0),f(U,null,F(k(p).tempMemory,o=>(s(),V(S,{key:o.id,title:`[${o.role}] ${o.content||o.text}`,subtitle:new Date(o.timestamp).toLocaleString()},{append:l(()=>[t(r,{onClick:_=>X(o.id),icon:"mdi-delete",size:"x-small",variant:"text",color:"error"},null,8,["onClick"])]),_:2},1032,["title","subtitle"]))),128))]),_:1})):(s(),f("p",me,"没有临时记忆。"))]),_:1})]),_:1}),t(I,{title:"核心记忆 (Core Memory)"},{default:l(()=>[t(T,null,{default:l(()=>[v("div",ce,[t(r,{onClick:J,class:"mr-2"},{default:l(()=>[...e[21]||(e[21]=[d("刷新",-1)])]),_:1}),t(r,{onClick:e[2]||(e[2]=o=>z()),color:"primary"},{default:l(()=>[...e[22]||(e[22]=[d("添加记忆块",-1)])]),_:1})]),Object.keys(k(p).coreMemory).length>0?(s(),f("div",fe,[(s(!0),f(U,null,F(k(p).coreMemory,o=>(s(),V(A,{key:o.id,class:"mb-4",variant:"outlined"},{default:l(()=>[t(w,{class:"d-flex justify-space-between"},{default:l(()=>[v("span",null,C(o.title),1),v("div",null,[t(r,{onClick:_=>z(o),icon:"mdi-pencil",size:"x-small",variant:"text"},null,8,["onClick"]),t(r,{onClick:_=>Q(o.id),icon:"mdi-delete",size:"x-small",variant:"text",color:"error"},null,8,["onClick"])])]),_:2},1024),t(h,null,{default:l(()=>[d(C(o.description),1)]),_:2},1024),t($,null,{default:l(()=>[v("ul",null,[(s(!0),f(U,null,F(o.content,(_,N)=>(s(),f("li",{key:N},C(_),1))),128))])]),_:2},1024)]),_:2},1024))),128))])):(s(),f("p",ve,"没有核心记忆。"))]),_:1})]),_:1})]),_:1}),t(D,{modelValue:M.value,"onUpdate:modelValue":e[6]||(e[6]=o=>M.value=o),"max-width":"500px"},{default:l(()=>[t(A,null,{default:l(()=>[t(w,null,{default:l(()=>[...e[23]||(e[23]=[v("span",{class:"text-h5"},"添加临时记忆",-1)])]),_:1}),t($,null,{default:l(()=>[t(te,{modelValue:y.value.role,"onUpdate:modelValue":e[3]||(e[3]=o=>y.value.role=o),items:["system","user","assistant"],label:"角色",required:""},null,8,["modelValue"]),t(W,{modelValue:y.value.content,"onUpdate:modelValue":e[4]||(e[4]=o=>y.value.content=o),label:"内容",required:""},null,8,["modelValue"])]),_:1}),t(B,null,{default:l(()=>[t(j),t(r,{color:"blue-darken-1",variant:"text",onClick:e[5]||(e[5]=o=>M.value=!1)},{default:l(()=>[...e[24]||(e[24]=[d("取消",-1)])]),_:1}),t(r,{color:"blue-darken-1",variant:"text",onClick:K},{default:l(()=>[...e[25]||(e[25]=[d("添加",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),t(D,{modelValue:g.value,"onUpdate:modelValue":e[11]||(e[11]=o=>g.value=o),"max-width":"600px"},{default:l(()=>[t(A,null,{default:l(()=>[t(w,null,{default:l(()=>[v("span",pe,C(m.value.id?"编辑":"添加")+"核心记忆块",1)]),_:1}),t($,null,{default:l(()=>[t(P,{modelValue:m.value.title,"onUpdate:modelValue":e[7]||(e[7]=o=>m.value.title=o),label:"标题",required:""},null,8,["modelValue"]),t(W,{modelValue:m.value.description,"onUpdate:modelValue":e[8]||(e[8]=o=>m.value.description=o),label:"描述"},null,8,["modelValue"]),t(W,{modelValue:m.value.contentStr,"onUpdate:modelValue":e[9]||(e[9]=o=>m.value.contentStr=o),label:"内容 (每行一条)"},null,8,["modelValue"])]),_:1}),t(B,null,{default:l(()=>[t(j),t(r,{color:"blue-darken-1",variant:"text",onClick:e[10]||(e[10]=o=>g.value=!1)},{default:l(()=>[...e[26]||(e[26]=[d("取消",-1)])]),_:1}),t(r,{color:"blue-darken-1",variant:"text",onClick:G},{default:l(()=>[...e[27]||(e[27]=[d("保存",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),t(D,{modelValue:b.value,"onUpdate:modelValue":e[15]||(e[15]=o=>b.value=o),"max-width":"600px"},{default:l(()=>[t(A,null,{default:l(()=>[t(w,null,{default:l(()=>[v("span",_e,C(c.value.isEditing?"编辑":"添加")+"初始化记忆项",1)]),_:1}),t($,null,{default:l(()=>[t(P,{modelValue:c.value.key,"onUpdate:modelValue":e[12]||(e[12]=o=>c.value.key=o),label:"键",disabled:c.value.isEditing,required:""},null,8,["modelValue","disabled"]),t(W,{modelValue:c.value.valueStr,"onUpdate:modelValue":e[13]||(e[13]=o=>c.value.valueStr=o),label:"值 (可以是字符串, JSON, 或换行分隔的数组)"},null,8,["modelValue"])]),_:1}),t(B,null,{default:l(()=>[t(j),t(r,{color:"blue-darken-1",variant:"text",onClick:e[14]||(e[14]=o=>b.value=!1)},{default:l(()=>[...e[28]||(e[28]=[d("取消",-1)])]),_:1}),t(r,{color:"blue-darken-1",variant:"text",onClick:H},{default:l(()=>[...e[29]||(e[29]=[d("保存",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),Ce=ie(ye,[["__scopeId","data-v-89d9881f"]]);export{Ce as default};
@@ -0,0 +1 @@
1
+ .value-display pre[data-v-89d9881f]{white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word}
@@ -0,0 +1 @@
1
+ import{d as F,B as D,a as R,j as W,v as E,l as G,b as s,c as b,o as u,w as e,e as t,g as n,f as d,m,F as A,n as h,h as k,t as f}from"./index-BiAhe8fO.js";const J={class:"d-flex mb-4"},O={class:"text-center"},j={class:"text-center"},P=F({__name:"ToolsTab",setup(I){const c=D(),r=R(),i=W({neuro_agent:[],memory_agent:[]});E(()=>c.allocations,l=>{i.value=JSON.parse(JSON.stringify(l||{neuro_agent:[],memory_agent:[]}))},{deep:!0,immediate:!0});async function S(){if(r.isConnected)try{await r.sendAdminWsMessage("set_agent_tool_allocations",{allocations:i.value}),console.log("Tool allocations saved successfully!")}catch(l){console.error("Failed to save allocations:",l)}}async function T(){if(r.isConnected)try{await r.sendAdminWsMessage("reload_tools")}catch(l){console.error("Failed to reload tools:",l)}}async function B(){if(r.isConnected)try{const[l,o]=await Promise.all([r.sendAdminWsMessage("get_all_tools"),r.sendAdminWsMessage("get_agent_tool_allocations")]);console.log("DEBUG: toolsResponse:",l),console.log("DEBUG: allocationsResponse:",o),c.handleAvailableToolsUpdate(l.tools),c.handleAllocationsUpdate(o.allocations)}catch(l){console.error("Failed to fetch tools initial data:",l)}}return G(()=>{B()}),(l,o)=>{const C=s("v-btn"),_=s("v-col"),v=s("v-row"),p=s("v-card-title"),V=s("v-checkbox-btn"),N=s("v-table"),g=s("v-card-text"),y=s("v-card"),w=s("v-chip"),M=s("v-chip-group"),U=s("v-container");return u(),b(U,{fluid:""},{default:e(()=>[t(v,null,{default:e(()=>[t(_,{cols:"12"},{default:e(()=>[n("div",J,[t(C,{onClick:T,class:"mr-2"},{default:e(()=>[...o[2]||(o[2]=[d("重载工具",-1)])]),_:1}),t(C,{onClick:S,color:"primary"},{default:e(()=>[...o[3]||(o[3]=[d("保存分配",-1)])]),_:1})]),o[4]||(o[4]=n("p",{class:"text-caption"},"在这里为 Agent 分配可用的工具标签。Neuro Agent 负责与观众互动,Memory Agent 负责在后台整理记忆。",-1))]),_:1})]),_:1}),t(v,null,{default:e(()=>[t(_,{cols:"12"},{default:e(()=>[t(y,{variant:"outlined"},{default:e(()=>[t(p,null,{default:e(()=>[...o[5]||(o[5]=[d("所有可用工具",-1)])]),_:1}),t(g,null,{default:e(()=>[t(N,{density:"compact"},{default:e(()=>[o[6]||(o[6]=n("thead",null,[n("tr",null,[n("th",{class:"text-left"},"工具名称"),n("th",{class:"text-left"},"描述"),n("th",{class:"text-center"},"Neuro Agent"),n("th",{class:"text-center"},"Memory Agent")])],-1)),n("tbody",null,[(u(!0),m(A,null,h(k(c).availableTools,a=>(u(),m("tr",{key:a.name},[n("td",null,f(a.name),1),n("td",null,f(a.description),1),n("td",O,[t(V,{modelValue:i.value.neuro_agent,"onUpdate:modelValue":o[0]||(o[0]=x=>i.value.neuro_agent=x),value:a.name,"hide-details":""},null,8,["modelValue","value"])]),n("td",j,[t(V,{modelValue:i.value.memory_agent,"onUpdate:modelValue":o[1]||(o[1]=x=>i.value.memory_agent=x),value:a.name,"hide-details":""},null,8,["modelValue","value"])])]))),128))])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),t(v,null,{default:e(()=>[t(_,{md:"6",cols:"12"},{default:e(()=>[t(y,{variant:"outlined"},{default:e(()=>[t(p,null,{default:e(()=>[...o[7]||(o[7]=[d("Neuro Agent 工具集",-1)])]),_:1}),t(g,null,{default:e(()=>[t(M,{column:""},{default:e(()=>[(u(!0),m(A,null,h(k(c).allocations.neuro_agent,a=>(u(),b(w,{key:a},{default:e(()=>[d(f(a),1)]),_:2},1024))),128))]),_:1})]),_:1})]),_:1})]),_:1}),t(_,{md:"6",cols:"12"},{default:e(()=>[t(y,{variant:"outlined"},{default:e(()=>[t(p,null,{default:e(()=>[...o[8]||(o[8]=[d("Memory Agent 工具集",-1)])]),_:1}),t(g,null,{default:e(()=>[t(M,{column:""},{default:e(()=>[(u(!0),m(A,null,h(k(c).allocations.memory_agent,a=>(u(),b(w,{key:a},{default:e(()=>[d(f(a),1)]),_:2},1024))),128))]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}}});export{P as default};