neuro-simulator 0.5.1__py3-none-any.whl → 0.5.3__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 (53) hide show
  1. neuro_simulator-0.5.1.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 -20
  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/cli.py +52 -65
  17. neuro_simulator/core/application.py +50 -8
  18. neuro_simulator/core/config.py +21 -51
  19. neuro_simulator/dashboard/assets/AgentView-0fzVkKxU.js +2 -0
  20. neuro_simulator/dashboard/assets/AgentView-TDgmx5bK.css +1 -0
  21. neuro_simulator/dashboard/assets/ChatBotView-DifkK6-9.js +2 -0
  22. neuro_simulator/dashboard/assets/ChatBotView-Dyd6g14G.css +1 -0
  23. neuro_simulator/dashboard/assets/ConfigView-BTWWYQah.js +2 -0
  24. neuro_simulator/dashboard/assets/ContextTab-BAcGlJgU.js +1 -0
  25. neuro_simulator/dashboard/assets/ContextTab-DyPsixHQ.css +1 -0
  26. neuro_simulator/dashboard/assets/ControlView-BUCt3umR.css +1 -0
  27. neuro_simulator/dashboard/assets/ControlView-DnOBRK05.js +1 -0
  28. neuro_simulator/dashboard/assets/FieldRenderer-CCuLNhHG.js +1 -0
  29. neuro_simulator/dashboard/assets/LogsTab-wg3i3S6b.css +1 -0
  30. neuro_simulator/dashboard/assets/LogsTab-ylrlgzPh.js +1 -0
  31. neuro_simulator/dashboard/assets/LogsView-BtzSwkDM.js +1 -0
  32. neuro_simulator/dashboard/assets/LogsView-D2F8f-Mc.css +1 -0
  33. neuro_simulator/dashboard/assets/MemoryTab-CT6mH7oh.js +6 -0
  34. neuro_simulator/dashboard/assets/MemoryTab-DPthi6jg.css +1 -0
  35. neuro_simulator/dashboard/assets/ToolsTab-BAt1r6ui.js +1 -0
  36. neuro_simulator/dashboard/assets/index-BGoCthX_.js +34 -0
  37. neuro_simulator/dashboard/assets/index-w9eUSFF9.css +5 -0
  38. neuro_simulator/dashboard/assets/materialdesignicons-webfont-B7mPwVP_.ttf +0 -0
  39. neuro_simulator/dashboard/assets/materialdesignicons-webfont-CSr8KVlo.eot +0 -0
  40. neuro_simulator/dashboard/assets/materialdesignicons-webfont-Dp5v-WZN.woff2 +0 -0
  41. neuro_simulator/dashboard/assets/materialdesignicons-webfont-PXm3-2wK.woff +0 -0
  42. neuro_simulator/dashboard/favicon.ico +0 -0
  43. neuro_simulator/dashboard/first-coffee.woff2 +0 -0
  44. neuro_simulator/dashboard/index.html +14 -0
  45. neuro_simulator/services/audio.py +30 -0
  46. neuro_simulator-0.5.3.dist-info/METADATA +284 -0
  47. neuro_simulator-0.5.3.dist-info/RECORD +103 -0
  48. {neuro_simulator-0.5.1.dist-info → neuro_simulator-0.5.3.dist-info}/WHEEL +1 -2
  49. neuro_simulator-0.5.3.dist-info/licenses/LICENSE +21 -0
  50. requirements.txt +11 -0
  51. neuro_simulator-0.5.1.dist-info/RECORD +0 -62
  52. neuro_simulator-0.5.1.dist-info/top_level.txt +0 -1
  53. {neuro_simulator-0.5.1.dist-info → neuro_simulator-0.5.3.dist-info}/entry_points.txt +0 -0
neuro_simulator/cli.py CHANGED
@@ -19,7 +19,7 @@ def main():
19
19
 
20
20
  args = parser.parse_args()
21
21
 
22
- # 1. Set working directory
22
+ # --- 1. Setup Working Directory ---
23
23
  if args.dir:
24
24
  work_dir = Path(args.dir).resolve()
25
25
  if not work_dir.exists():
@@ -32,83 +32,70 @@ def main():
32
32
  os.chdir(work_dir)
33
33
  logging.info(f"Using working directory: {work_dir}")
34
34
 
35
- # 2. Initialize paths and load configuration
35
+ # --- 2. Initialize Path Manager ---
36
36
  from neuro_simulator.core import path_manager
37
- from neuro_simulator.core.config import config_manager
38
- import uvicorn
39
-
40
37
  path_manager.initialize_path_manager(os.getcwd())
41
38
 
42
- # Define example_path early for config loading
43
- example_path = Path(__file__).parent / "config.yaml.example"
44
-
45
- # 2.2. Copy default config.yaml.example if it doesn't exist
39
+ # --- 3. First-Run Environment Initialization ---
40
+ # This block ensures that a new user has all the necessary default files.
46
41
  try:
47
- source_config_example = example_path
48
- destination_config_example = path_manager.path_manager.working_dir / "config.yaml.example"
49
- if not destination_config_example.exists():
50
- shutil.copy(source_config_example, destination_config_example)
51
- logging.info(f"Copyed default config.yaml.example to {destination_config_example}")
42
+ package_source_path = Path(__file__).parent
43
+
44
+ # Helper to copy files if they don't exist
45
+ def copy_if_not_exists(src: Path, dest: Path):
46
+ if not dest.exists():
47
+ dest.parent.mkdir(parents=True, exist_ok=True)
48
+ shutil.copy(src, dest)
49
+ logging.info(f"Copied default file to {dest}")
50
+
51
+ # Copy config.yaml.example
52
+ copy_if_not_exists(package_source_path / "config.yaml.example", work_dir / "config.yaml.example")
53
+
54
+ # Copy prompts
55
+ copy_if_not_exists(package_source_path / "agent" / "neuro_prompt.txt", path_manager.path_manager.neuro_prompt_path)
56
+ copy_if_not_exists(package_source_path / "agent" / "memory_prompt.txt", path_manager.path_manager.memory_agent_prompt_path)
57
+
58
+ # Copy default memory JSON files
59
+ copy_if_not_exists(package_source_path / "agent" / "memory" / "core_memory.json", path_manager.path_manager.core_memory_path)
60
+ copy_if_not_exists(package_source_path / "agent" / "memory" / "init_memory.json", path_manager.path_manager.init_memory_path)
61
+ copy_if_not_exists(package_source_path / "agent" / "memory" / "temp_memory.json", path_manager.path_manager.temp_memory_path)
62
+
63
+ # Copy default assets directory
64
+ source_assets_dir = package_source_path / "assets"
65
+ destination_assets_dir = path_manager.path_manager.assets_dir
66
+ if not destination_assets_dir.exists():
67
+ shutil.copytree(source_assets_dir, destination_assets_dir)
68
+ logging.info(f"Copied default asset directory to {destination_assets_dir}")
69
+
52
70
  except Exception as e:
53
- logging.warning(f"Could not copy default config.yaml.example: {e}")
71
+ logging.warning(f"Could not copy all default files: {e}")
54
72
 
55
- main_config_path = path_manager.path_manager.working_dir / "config.yaml"
56
- config_manager.load_and_validate(str(main_config_path), str(example_path))
73
+ # --- 4. Load Configuration ---
74
+ from neuro_simulator.core.config import config_manager
75
+ from pydantic import ValidationError
76
+ import uvicorn
57
77
 
58
- # 2.5. Copy default prompt templates if they don't exist
78
+ main_config_path = path_manager.path_manager.working_dir / "config.yaml"
59
79
  try:
60
- # Use Path(__file__).parent for robust path resolution
61
- base_path = Path(__file__).parent
62
- neuro_prompt_example = base_path / "agent" / "neuro_prompt.txt"
63
- memory_prompt_example = base_path / "agent" / "memory_prompt.txt"
64
-
65
- if not path_manager.path_manager.neuro_prompt_path.exists():
66
- shutil.copy(neuro_prompt_example, path_manager.path_manager.neuro_prompt_path)
67
- logging.info(f"Copied default neuro prompt to {path_manager.path_manager.neuro_prompt_path}")
68
- if not path_manager.path_manager.memory_agent_prompt_path.exists():
69
- shutil.copy(memory_prompt_example, path_manager.path_manager.memory_agent_prompt_path)
70
- logging.info(f"Copied default memory prompt to {path_manager.path_manager.memory_agent_prompt_path}")
71
-
72
- # Copy default memory JSON files if they don't exist
73
- memory_files = {
74
- "core_memory.json": path_manager.path_manager.core_memory_path,
75
- "init_memory.json": path_manager.path_manager.init_memory_path,
76
- "temp_memory.json": path_manager.path_manager.temp_memory_path,
77
- }
78
- for filename, dest_path in memory_files.items():
79
- src_path = base_path / "agent" / "memory" / filename
80
- if not dest_path.exists():
81
- shutil.copy(src_path, dest_path)
82
- logging.info(f"Copied default {filename} to {dest_path}")
83
-
84
- # Copy default assets directory if it doesn't exist
85
- source_assets_dir = base_path / "assets"
86
- destination_assets_dir = path_manager.path_manager.assets_dir
87
-
88
- # Ensure the destination assets directory exists
89
- destination_assets_dir.mkdir(parents=True, exist_ok=True)
90
-
91
- # Copy individual files from source assets to destination assets
92
- for item in source_assets_dir.iterdir():
93
- if item.is_file():
94
- dest_file = destination_assets_dir / item.name
95
- if not dest_file.exists():
96
- shutil.copy(item, dest_file)
97
- logging.info(f"Copied asset {item.name} to {dest_file}")
98
- elif item.is_dir():
99
- # Recursively copy subdirectories if they don't exist
100
- dest_subdir = destination_assets_dir / item.name
101
- if not dest_subdir.exists():
102
- shutil.copytree(item, dest_subdir)
103
- logging.info(f"Copied asset directory {item.name} to {dest_subdir}")
80
+ config_manager.load(str(main_config_path))
81
+ except FileNotFoundError:
82
+ logging.error(f"FATAL: Configuration file '{main_config_path.name}' not found.")
83
+ logging.error(f"If this is your first time, please rename 'config.yaml.example' to 'config.yaml' after filling it out.")
84
+ sys.exit(1)
85
+ except ValidationError as e:
86
+ logging.error(f"FATAL: Configuration error in '{main_config_path.name}':")
87
+ logging.error(e)
88
+ sys.exit(1)
104
89
  except Exception as e:
105
- logging.warning(f"Could not copy default prompt templates, memory files, or assets: {e}")
90
+ logging.error(f"FATAL: An unexpected error occurred while loading the configuration: {e}")
91
+ sys.exit(1)
106
92
 
107
- # 3. Determine server host and port
93
+ # --- 5. Determine Server Host and Port ---
94
+ # Command-line arguments override config file settings
108
95
  server_host = args.host or config_manager.settings.server.host
109
96
  server_port = args.port or config_manager.settings.server.port
110
97
 
111
- # 4. Run the server
98
+ # --- 6. Run the Server ---
112
99
  logging.info(f"Starting Neuro-Simulator server on {server_host}:{server_port}...")
113
100
  try:
114
101
  uvicorn.run(
@@ -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
 
@@ -482,23 +525,22 @@ async def handle_admin_ws_message(websocket: WebSocket, data: dict):
482
525
  response["payload"] = status
483
526
 
484
527
  # Config Management Actions
528
+ elif action == "get_settings_schema":
529
+ response["payload"] = config_manager.settings.model_json_schema()
530
+
485
531
  elif action == "get_configs":
486
- from ..api.system import filter_config_for_frontend
487
- configs = filter_config_for_frontend(config_manager.settings)
488
- response["payload"] = configs
532
+ response["payload"] = config_manager.settings.model_dump()
489
533
 
490
534
  elif action == "update_configs":
491
- from ..api.system import filter_config_for_frontend
492
535
  await config_manager.update_settings(payload)
493
- updated_configs = filter_config_for_frontend(config_manager.settings)
536
+ updated_configs = config_manager.settings.model_dump()
494
537
  response["payload"] = updated_configs
495
538
  await connection_manager.broadcast_to_admins({"type": "config_updated", "payload": updated_configs})
496
539
 
497
540
  elif action == "reload_configs":
498
541
  await config_manager.update_settings({})
499
542
  response["payload"] = {"status": "success", "message": "Configuration reloaded"}
500
- from ..api.system import filter_config_for_frontend
501
- updated_configs = filter_config_for_frontend(config_manager.settings)
543
+ updated_configs = config_manager.settings.model_dump()
502
544
  await connection_manager.broadcast_to_admins({"type": "config_updated", "payload": updated_configs})
503
545
 
504
546
  # Other Agent Actions
@@ -110,56 +110,29 @@ class ConfigManager:
110
110
  self._update_callbacks = []
111
111
  self._initialized = True
112
112
 
113
- def load_and_validate(self, config_path_str: str, example_path_str: str):
114
- """Loads the main config file, handling first-run scenarios, and validates it."""
113
+ def load(self, config_path_str: str):
114
+ """
115
+ Loads the configuration from the given path, validates it, and sets it
116
+ on the manager instance.
117
+
118
+ Raises:
119
+ FileNotFoundError: If the config file does not exist.
120
+ ValueError: If the config file is empty.
121
+ pydantic.ValidationError: If the config file content does not match the AppSettings schema.
122
+ """
115
123
  config_path = Path(config_path_str)
116
- example_path = Path(example_path_str)
117
-
118
- # Scenario 1: Both config and example are missing in the working directory.
119
- if not config_path.exists() and not example_path.exists():
120
- try:
121
- import importlib.resources
122
- # For Python 3.9+, prefer importlib.resources.files
123
- ref = importlib.resources.files('neuro_simulator') / 'config.yaml.example'
124
- with importlib.resources.as_file(ref) as package_example_path:
125
- shutil.copy(package_example_path, example_path)
126
- logging.info(f"Created '{example_path}' from package resource.")
127
- logging.error(f"Configuration file '{config_path.name}' not found. A new '{example_path.name}' has been created. Please configure it and rename it to '{config_path.name}'.")
128
- sys.exit(1)
129
- except Exception as e:
130
- logging.error(f"FATAL: Could not create config from package resources: {e}")
131
- sys.exit(1)
132
-
133
- # Scenario 2: Config is missing, but example exists.
134
- elif not config_path.exists() and example_path.exists():
135
- logging.error(f"Configuration file '{config_path.name}' not found, but '{example_path.name}' exists. Please rename it to '{config_path.name}' after configuration.")
136
- sys.exit(1)
137
-
138
- # Scenario 3: Config exists, but example is missing.
139
- elif config_path.exists() and not example_path.exists():
140
- try:
141
- import importlib.resources
142
- # For Python 3.9+, prefer importlib.resources.files
143
- ref = importlib.resources.files('neuro_simulator') / 'config.yaml.example'
144
- with importlib.resources.as_file(ref) as package_example_path:
145
- shutil.copy(package_example_path, example_path)
146
- logging.info(f"Created missing '{example_path.name}' from package resource.")
147
- except Exception as e:
148
- logging.warning(f"Could not create missing '{example_path.name}': {e}")
149
-
150
- # Proceed with loading the config if it exists.
151
- try:
152
- with open(config_path, 'r', encoding='utf-8') as f:
153
- yaml_config = yaml.safe_load(f)
154
- if yaml_config is None:
155
- raise ValueError(f"Configuration file '{config_path}' is empty.")
156
-
157
- self.settings = AppSettings.model_validate(yaml_config)
158
- logging.info("Main configuration loaded successfully.")
159
124
 
160
- except Exception as e:
161
- logging.error(f"Error loading or parsing {config_path}: {e}")
162
- sys.exit(1) # Exit if the main config is invalid
125
+ if not config_path.exists():
126
+ raise FileNotFoundError(f"Configuration file '{config_path}' not found.")
127
+
128
+ with open(config_path, 'r', encoding='utf-8') as f:
129
+ yaml_config = yaml.safe_load(f)
130
+ if yaml_config is None:
131
+ raise ValueError(f"Configuration file '{config_path}' is empty.")
132
+
133
+ # This will raise ValidationError on failure
134
+ self.settings = AppSettings.model_validate(yaml_config)
135
+ logging.info("Configuration loaded and validated successfully.")
163
136
 
164
137
  def save_settings(self):
165
138
  """Saves the current configuration to config.yaml while preserving comments and formatting."""
@@ -312,9 +285,6 @@ class ConfigManager:
312
285
  model to ensure sub-models are correctly instantiated, and then
313
286
  notifying callbacks.
314
287
  """
315
- # Prevent API keys from being updated from the panel
316
- new_settings_data.pop('api_keys', None)
317
-
318
288
  try:
319
289
  # 1. Dump the current settings model to a dictionary.
320
290
  current_settings_dict = self.settings.model_dump()
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContextTab-BAcGlJgU.js","assets/index-BGoCthX_.js","assets/index-w9eUSFF9.css","assets/ContextTab-DyPsixHQ.css","assets/MemoryTab-CT6mH7oh.js","assets/MemoryTab-DPthi6jg.css","assets/ToolsTab-BAt1r6ui.js","assets/LogsTab-ylrlgzPh.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-BGoCthX_.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-BAcGlJgU.js"),__vite__mapDeps([0,1,2,3]))),b=r(()=>u(()=>import("./MemoryTab-CT6mH7oh.js"),__vite__mapDeps([4,1,2,5]))),V=r(()=>u(()=>import("./ToolsTab-BAt1r6ui.js"),__vite__mapDeps([6,1,2]))),w=r(()=>u(()=>import("./LogsTab-ylrlgzPh.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-BAcGlJgU.js","assets/index-BGoCthX_.js","assets/index-w9eUSFF9.css","assets/ContextTab-DyPsixHQ.css","assets/MemoryTab-CT6mH7oh.js","assets/MemoryTab-DPthi6jg.css","assets/ToolsTab-BAt1r6ui.js","assets/LogsTab-ylrlgzPh.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-BGoCthX_.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-BAcGlJgU.js"),__vite__mapDeps([0,1,2,3]))),p=r(()=>v(()=>import("./MemoryTab-CT6mH7oh.js"),__vite__mapDeps([4,1,2,5]))),f=r(()=>v(()=>import("./ToolsTab-BAt1r6ui.js"),__vite__mapDeps([6,1,2]))),c=r(()=>v(()=>import("./LogsTab-ylrlgzPh.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-CCuLNhHG.js","assets/index-BGoCthX_.js","assets/index-w9eUSFF9.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-BGoCthX_.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-CCuLNhHG.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
+ 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-BGoCthX_.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
+ .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
+ .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-BGoCthX_.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-BGoCthX_.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
+ .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 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-BGoCthX_.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
+ 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-BGoCthX_.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-BGoCthX_.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-BGoCthX_.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};