Skip to content

Agent Zero AI framework

Docker runtime - SSH, runtime args

frdel66f1ab7baff0
diff --git a/docker/run/Dockerfile b/docker/run/Dockerfile
index b8a529008..5049a5d3e 100644
--- a/docker/run/Dockerfile
+++ b/docker/run/Dockerfile
@@ -15,7 +15,8 @@ RUN apt-get update && apt-get install -y \
sudo \
curl \
wget \
- git
+ git \
+ ffmpeg
# Cleanup package list
RUN rm -rf /var/lib/apt/lists/*
@@ -49,6 +50,8 @@ RUN $VIRTUAL_ENV/bin/pip install \
# Install A0 python packages
RUN $VIRTUAL_ENV/bin/pip install -r /git/agent-zero/requirements.txt
+# Preload A0
+RUN $VIRTUAL_ENV/bin/python /git/agent-zero/preload.py
# Expose ports
EXPOSE 22 80
diff --git a/docker/run/build.txt b/docker/run/build.txt
index 49f29adb8..605762818 100644
--- a/docker/run/build.txt
+++ b/docker/run/build.txt
@@ -3,4 +3,4 @@ docker build -t agent-zero-run:latest .
# dockerhub
docker login
-docker buildx build --platform linux/amd64,linux/arm64 -t frdel/agent-zero-exe:latest --push .
\ No newline at end of file
+docker buildx build --platform linux/amd64,linux/arm64 -t frdel/agent-zero-run:latest --push .
\ No newline at end of file
diff --git a/docker/run/fs/exe/run_A0.sh b/docker/run/fs/exe/run_A0.sh
index ea8394fa2..266c6459c 100644
--- a/docker/run/fs/exe/run_A0.sh
+++ b/docker/run/fs/exe/run_A0.sh
@@ -1,14 +1,11 @@
#!/bin/bash
# Paths
-PYTHON_SCRIPT="/a0/run_ui.py"
SOURCE_DIR="/git/agent-zero"
TARGET_DIR="/a0"
-# Loop to restart the Python script when it finishes
-while true; do
-
+function setup_venv() {
# Create virtual environment if it doesn't exist
if [ ! -d /opt/venv ]; then
echo "Creating virtual environment..."
@@ -18,6 +15,16 @@ while true; do
# Activate the virtual environment
source /opt/venv/bin/activate
+}
+
+# preload A0
+setup_venv
+python /a0/preload.py
+
+# Loop to restart the Python script when it finishes
+while true; do
+
+ setup_venv
# Copy repository files if target is empty
if [ -z "$(ls -A "$TARGET_DIR")" ]; then
@@ -26,7 +33,15 @@ while true; do
fi
echo "Starting A0..."
- python "$PYTHON_SCRIPT" --port 80 --host "0.0.0.0"
+ python /a0/run_ui.py \
+ --port 80 \
+ --host "0.0.0.0" \
+ --code_exec_docker_enabled False \
+ --code_exec_ssh_enabled True \
+ --code_exec_ssh_addr "localhost" \
+ --code_exec_ssh_port 22 \
+ --code_exec_ssh_user "root" \
+ --code_exec_ssh_pass "toor"
# Check the exit status
if [ $? -ne 0 ]; then
diff --git a/docker/run/initialize.sh b/docker/run/initialize.sh
index 03ec8da54..1f9b0db5b 100644
--- a/docker/run/initialize.sh
+++ b/docker/run/initialize.sh
@@ -10,8 +10,12 @@ chmod 444 /root/.profile
# update package list to save time later
apt-get update
-# Start A0
-bash /exe/run_A0.sh
+# Start SSH service in background
+/usr/sbin/sshd -D &
-# Start SSH service
-exec /usr/sbin/sshd -D
\ No newline at end of file
+# Start A0 and restart on exit
+bash /exe/run_A0.sh
+if [ $? -ne 0 ]; then
+ echo "A0 script exited with an error. Restarting container..."
+ exit 1
+fi
\ No newline at end of file
diff --git a/initialize.py b/initialize.py
index 7be67a357..e8b6d8611 100644
--- a/initialize.py
+++ b/initialize.py
@@ -2,6 +2,12 @@ import models
from agent import AgentConfig
from python.helpers import files, settings
+global_kwargs = {}
+
+def set_global_kwargs(**kwargs):
+ global global_kwargs
+ global_kwargs = kwargs
+
def initialize():
# main chat model used by agents (smarter, more accurate)
@@ -45,7 +51,7 @@ def initialize():
# msgs_keep_end = 10,
max_tool_response_length = 3000,
# response_timeout_seconds = 60,
- code_exec_docker_enabled = True,
+ # code_exec_docker_enabled = True,
# code_exec_docker_name = "agent-zero-exe",
# code_exec_docker_image = "frdel/agent-zero-exe:latest",
# code_exec_docker_ports = { "22/tcp": 50022 }
@@ -53,7 +59,7 @@ def initialize():
# files.get_abs_path("work_dir"): {"bind": "/root", "mode": "rw"},
# files.get_abs_path("instruments"): {"bind": "/instruments", "mode": "rw"},
# },
- code_exec_ssh_enabled = True,
+ # code_exec_ssh_enabled = True,
# code_exec_ssh_addr = "localhost",
# code_exec_ssh_port = 50022,
# code_exec_ssh_user = "root",
@@ -61,5 +67,10 @@ def initialize():
# additional = {},
)
+ # update config with kwargs
+ for key, value in global_kwargs.items():
+ if hasattr(config, key):
+ setattr(config, key, value)
+
# return config object
return config
diff --git a/models.py b/models.py
index 4211fe5c5..ed194bae3 100644
--- a/models.py
+++ b/models.py
@@ -26,6 +26,7 @@ from langchain_google_genai import (
)
from langchain_mistralai import ChatMistralAI
from pydantic.v1.types import SecretStr
+from python.helpers import dotenv
from python.helpers.dotenv import load_dotenv
# environment variables
@@ -57,7 +58,7 @@ class ModelProvider(Enum):
# Utility function to get API keys from environment variables
def get_api_key(service):
- return os.getenv(f"API_KEY_{service.upper()}") or os.getenv(f"{service.upper()}_API_KEY") or "None"
+ return dotenv.get_dotenv_value(f"API_KEY_{service.upper()}") or dotenv.get_dotenv_value(f"{service.upper()}_API_KEY") or "None"
def get_model(type: ModelType, provider: ModelProvider, name: str, **kwargs):
@@ -70,7 +71,7 @@ def get_model(type: ModelType, provider: ModelProvider, name: str, **kwargs):
def get_ollama_chat(
model_name: str,
temperature=DEFAULT_TEMPERATURE,
- base_url=os.getenv("OLLAMA_BASE_URL") or "http://127.0.0.1:11434",
+ base_url=dotenv.get_dotenv_value("OLLAMA_BASE_URL") or "http://127.0.0.1:11434",
num_ctx=8192,
**kwargs,
):
@@ -86,7 +87,7 @@ def get_ollama_chat(
def get_ollama_embedding(
model_name: str,
temperature=DEFAULT_TEMPERATURE,
- base_url=os.getenv("OLLAMA_BASE_URL") or "http://127.0.0.1:11434",
+ base_url=dotenv.get_dotenv_value("OLLAMA_BASE_URL") or "http://127.0.0.1:11434",
**kwargs,
):
return OllamaEmbeddings(
@@ -126,7 +127,7 @@ def get_huggingface_embedding(model_name: str, **kwargs):
def get_lmstudio_chat(
model_name: str,
temperature=DEFAULT_TEMPERATURE,
- base_url=os.getenv("LM_STUDIO_BASE_URL") or "http://127.0.0.1:1234/v1",
+ base_url=dotenv.get_dotenv_value("LM_STUDIO_BASE_URL") or "http://127.0.0.1:1234/v1",
**kwargs,
):
return ChatOpenAI(model_name=model_name, base_url=base_url, temperature=temperature, api_key="none", **kwargs) # type: ignore
@@ -134,7 +135,7 @@ def get_lmstudio_chat(
def get_lmstudio_embedding(
model_name: str,
- base_url=os.getenv("LM_STUDIO_BASE_URL") or "http://127.0.0.1:1234/v1",
+ base_url=dotenv.get_dotenv_value("LM_STUDIO_BASE_URL") or "http://127.0.0.1:1234/v1",
**kwargs,
):
return OpenAIEmbeddings(model=model_name, api_key="none", base_url=base_url, check_embedding_ctx_length=False, **kwargs) # type: ignore
@@ -186,7 +187,7 @@ def get_azure_openai_chat(
deployment_name: str,
api_key=get_api_key("openai_azure"),
temperature=DEFAULT_TEMPERATURE,
- azure_endpoint=os.getenv("OPENAI_AZURE_ENDPOINT"),
+ azure_endpoint=dotenv.get_dotenv_value("OPENAI_AZURE_ENDPOINT"),
**kwargs,
):
return AzureChatOpenAI(deployment_name=deployment_name, temperature=temperature, api_key=api_key, azure_endpoint=azure_endpoint, **kwargs) # type: ignore
@@ -196,7 +197,7 @@ def get_azure_openai_instruct(
deployment_name: str,
api_key=get_api_key("openai_azure"),
temperature=DEFAULT_TEMPERATURE,
- azure_endpoint=os.getenv("OPENAI_AZURE_ENDPOINT"),
+ azure_endpoint=dotenv.get_dotenv_value("OPENAI_AZURE_ENDPOINT"),
**kwargs,
):
return AzureOpenAI(deployment_name=deployment_name, temperature=temperature, api_key=api_key, azure_endpoint=azure_endpoint, **kwargs) # type: ignore
@@ -205,7 +206,7 @@ def get_azure_openai_instruct(
def get_azure_openai_embedding(
deployment_name: str,
api_key=get_api_key("openai_azure"),
- azure_endpoint=os.getenv("OPENAI_AZURE_ENDPOINT"),
+ azure_endpoint=dotenv.get_dotenv_value("OPENAI_AZURE_ENDPOINT"),
**kwargs,
):
return AzureOpenAIEmbeddings(deployment_name=deployment_name, api_key=api_key, azure_endpoint=azure_endpoint, **kwargs) # type: ignore
@@ -254,7 +255,7 @@ def get_openrouter_chat(
model_name: str,
api_key=get_api_key("openrouter"),
temperature=DEFAULT_TEMPERATURE,
- base_url=os.getenv("OPEN_ROUTER_BASE_URL") or "https://openrouter.ai/api/v1",
+ base_url=dotenv.get_dotenv_value("OPEN_ROUTER_BASE_URL") or "https://openrouter.ai/api/v1",
**kwargs,
):
return ChatOpenAI(api_key=api_key, model=model_name, temperature=temperature, base_url=base_url, **kwargs) # type: ignore
@@ -263,7 +264,7 @@ def get_openrouter_chat(
def get_openrouter_embedding(
model_name: str,
api_key=get_api_key("openrouter"),
- base_url=os.getenv("OPEN_ROUTER_BASE_URL") or "https://openrouter.ai/api/v1",
+ base_url=dotenv.get_dotenv_value("OPEN_ROUTER_BASE_URL") or "https://openrouter.ai/api/v1",
**kwargs,
):
return OpenAIEmbeddings(model=model_name, api_key=api_key, base_url=base_url, **kwargs) # type: ignore
@@ -274,7 +275,7 @@ def get_sambanova_chat(
model_name: str,
api_key=get_api_key("sambanova"),
temperature=DEFAULT_TEMPERATURE,
- base_url=os.getenv("SAMBANOVA_BASE_URL") or "https://fast-api.snova.ai/v1",
+ base_url=dotenv.get_dotenv_value("SAMBANOVA_BASE_URL") or "https://fast-api.snova.ai/v1",
max_tokens=1024,
**kwargs,
):
@@ -285,7 +286,7 @@ def get_sambanova_chat(
def get_sambanova_embedding(
model_name: str,
api_key=get_api_key("sambanova"),
- base_url=os.getenv("SAMBANOVA_BASE_URL") or "https://fast-api.snova.ai/v1",
+ base_url=dotenv.get_dotenv_value("SAMBANOVA_BASE_URL") or "https://fast-api.snova.ai/v1",
**kwargs,
):
return OpenAIEmbeddings(model=model_name, api_key=api_key, base_url=base_url, **kwargs) # type: ignore
diff --git a/preload.py b/preload.py
new file mode 100644
index 000000000..85c75d76c
--- /dev/null
+++ b/preload.py
@@ -0,0 +1,3 @@
+from python.helpers import whisper_oai
+
+whisper_oai.preload() # preload transcription model
\ No newline at end of file
diff --git a/python/helpers/dotenv.py b/python/helpers/dotenv.py
index b35ec85a0..ee0eed165 100644
--- a/python/helpers/dotenv.py
+++ b/python/helpers/dotenv.py
@@ -1,6 +1,31 @@
+import os
+import re
from .files import get_abs_path
from dotenv import load_dotenv as _load_dotenv
+
def load_dotenv():
- dotenv_path = get_abs_path(".env")
- _load_dotenv(dotenv_path)
\ No newline at end of file
+ _load_dotenv(get_dotenv_file_path())
+
+
+def get_dotenv_file_path():
+ return get_abs_path(".env")
+
+def get_dotenv_value(key: str):
+ load_dotenv()
+ return os.getenv(key)
+
+def save_dotenv_value(key: str, value: str):
+ dotenv_path = get_dotenv_file_path()
+ with open(dotenv_path, "r+") as f:
+ lines = f.readlines()
+ found = False
+ for i, line in enumerate(lines):
+ if re.match(rf"^\s*{key}\s*=", line):
+ lines[i] = f"{key}={value}\n"
+ found = True
+ if not found:
+ lines.append(f"\n{key}={value}")
+ f.seek(0)
+ f.writelines(lines)
+ f.truncate()
diff --git a/python/helpers/settings.py b/python/helpers/settings.py
index 8463190e5..9480a7222 100644
--- a/python/helpers/settings.py
+++ b/python/helpers/settings.py
@@ -2,11 +2,14 @@ import json
import os
import re
from typing import Any, Optional, TypedDict
-from . import files
+
+import models
+from . import files, dotenv
from models import get_model, ModelProvider, ModelType
from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.embeddings import Embeddings
+
class Settings(TypedDict):
chat_model_provider: str
chat_model_name: str
@@ -22,6 +25,8 @@ class Settings(TypedDict):
embed_model_name: str
embed_model_kwargs: dict[str, str]
+ api_keys: dict[str, str]
+
class PartialSettings(Settings, total=False):
pass
@@ -212,17 +217,55 @@ def convert_out(settings: Settings) -> dict[str, Any]:
"fields": embed_model_fields,
}
- result = {"sections": [chat_model_section, util_model_section, embed_model_section]}
+ # embedding model section
+ api_keys_fields = []
+ api_keys_fields.append(_get_api_key_field(settings, "openai", "OpenAI API Key"))
+ api_keys_fields.append(_get_api_key_field(settings, "anthropic", "Anthropic API Key"))
+ api_keys_fields.append(_get_api_key_field(settings, "groq", "Groq API Key"))
+ api_keys_fields.append(_get_api_key_field(settings, "google", "Google API Key"))
+ api_keys_fields.append(_get_api_key_field(settings, "openrouter", "OpenRouter API Key"))
+ api_keys_fields.append(_get_api_key_field(settings, "sambanova", "Sambanova API Key"))
+ api_keys_fields.append(_get_api_key_field(settings, "mistralai", "MistralAI API Key"))
+
+ api_keys_section = {
+ "title": "API Keys",
+ "description": "API keys for model providers and services used by Agent Zero.",
+ "fields": api_keys_fields,
+ }
+
+ result = {
+ "sections": [
+ chat_model_section,
+ util_model_section,
+ embed_model_section,
+ api_keys_section,
+ ]
+ }
return result
+
+def _get_api_key_field(settings: Settings, provider: str, title: str):
+ key = settings["api_keys"].get(provider, models.get_api_key(provider))
+ return {
+ "id": f"api_key_{provider}",
+ "title": title,
+ "type": "password",
+ "value": key if key != "None" else "",
+ }
+
+
def convert_in(settings: dict[str, Any]) -> Settings:
current = get_settings()
for section in settings["sections"]:
for field in section["fields"]:
if field["id"].endswith("_kwargs"):
- current[field["id"]] = _env_to_dict(field["value"]) #parse KWARGS from env format
+ current[field["id"]] = _env_to_dict(
+ field["value"]
+ ) # parse KWARGS from env format
+ elif field["id"].startswith("api_key_"):
+ current["api_keys"][field["id"]] = field["value"]
else:
- current[field["id"]] = field["value"]
+ current[field["id"]] = field["value"]
return current
@@ -238,7 +281,7 @@ def get_settings() -> Settings:
def set_settings(settings: Settings):
global _settings
_settings = normalize_settings(settings)
- _apply_settings()
+ _apply_settings()
_write_settings_file(_settings)
@@ -291,6 +334,12 @@ def _read_settings_file() -> Settings | None:
def _write_settings_file(settings: Settings):
+ #write api keys
+ for key, val in settings["api_keys"].items():
+ dotenv.save_dotenv_value(key.upper(), val)
+ settings["api_keys"] = {} # remove API keys before saving
+
+ #write settings
content = json.dumps(settings, indent=4)
files.write_file(SETTINGS_FILE, content)
@@ -308,8 +357,10 @@ def _get_default_settings() -> Settings:
embed_model_provider=ModelProvider.OPENAI.name,
embed_model_name="text-embedding-3-small",
embed_model_kwargs={},
+ api_keys={},
)
+
def _apply_settings():
global _settings
if _settings:
@@ -317,16 +368,17 @@ def _apply_settings():
from initialize import initialize
for ctx in AgentContext._contexts.values():
- ctx.config = initialize() # reinitialize context config with new settings
- #apply config to agents
+ ctx.config = initialize() # reinitialize context config with new settings
+ # apply config to agents
agent = ctx.agent0
while agent:
agent.config = ctx.config
agent = agent.get_data("subordinate")
-def _env_to_dict(data:str):
+
+def _env_to_dict(data: str):
env_dict = {}
- line_pattern = re.compile(r'\s*([^#][^=]*)\s*=\s*(.*)')
+ line_pattern = re.compile(r"\s*([^#][^=]*)\s*=\s*(.*)")
for line in data.splitlines():
match = line_pattern.match(line)
if match:
@@ -336,12 +388,13 @@ def _env_to_dict(data:str):
env_dict[key.strip()] = value
return env_dict
+
def _dict_to_env(data_dict):
lines = []
for key, value in data_dict.items():
- if '\n' in value:
+ if "\n" in value:
value = f"'{value}'"
- elif ' ' in value or value == '' or any(c in value for c in '"\''):
+ elif " " in value or value == "" or any(c in value for c in "\"'"):
value = f'"{value}"'
lines.append(f"{key}={value}")
- return "\n".join(lines)
\ No newline at end of file
+ return "\n".join(lines)
diff --git a/python/helpers/whisper_oai.py b/python/helpers/whisper_oai.py
index 3c79f11c0..7e917e523 100644
--- a/python/helpers/whisper_oai.py
+++ b/python/helpers/whisper_oai.py
@@ -1,13 +1,23 @@
# Import the necessary libraries
import whisper
import files
+import tempfile
-# Load the base model from Whisper
-model = whisper.load_model("base")
+model = None
-# Add your Audio File
-audio = files.get_abs_path("audio.ogg")
+def preload():
+ global model
+ model = whisper.load_model("base")
+ return model
-# Transcribe the audio file
-result = model.transcribe(audio, fp16=False)
-print(result["text"])
\ No newline at end of file
+def transcribe(audio_bytes):
+ global model
+ if model is None:
+ model = preload()
+
+ #create temp audio file
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as audio_file:
+ audio_file.write(audio_bytes)
+
+ # Transcribe the audio file
+ result = model.transcribe(audio_file.name, fp16=False)
\ No newline at end of file
diff --git a/python/tools/knowledge_tool.py b/python/tools/knowledge_tool.py
index d4b09744f..7d318833b 100644
--- a/python/tools/knowledge_tool.py
+++ b/python/tools/knowledge_tool.py
@@ -1,6 +1,6 @@
import os
import asyncio
-from python.helpers import memory, perplexity_search, duckduckgo_search
+from python.helpers import dotenv, memory, perplexity_search, duckduckgo_search
from python.helpers.tool import Tool, Response
from python.helpers.print_style import PrintStyle
from python.helpers.errors import handle_error
@@ -33,7 +33,7 @@ class Knowledge(Tool):
return Response(message=msg, break_loop=False)
async def perplexity_search(self, question):
- if os.getenv("API_KEY_PERPLEXITY"):
+ if dotenv.get_dotenv_value("API_KEY_PERPLEXITY"):
return await asyncio.to_thread(perplexity_search.perplexity_search, question)
else:
PrintStyle.hint("No API key provided for Perplexity. Skipping Perplexity search.")
diff --git a/run_ui.py b/run_ui.py
index 6d4517348..a7ef249ff 100644
--- a/run_ui.py
+++ b/run_ui.py
@@ -8,7 +8,7 @@ import uuid
from flask import Flask, request, jsonify, Response
from flask_basicauth import BasicAuth
from agent import AgentContext
-from initialize import initialize
+from initialize import initialize, set_global_kwargs
from python.helpers import files
from python.helpers.files import get_abs_path
from python.helpers.print_style import PrintStyle
@@ -572,7 +572,15 @@ def run():
def log_request(self, code="-", size="-"):
pass # Override to suppress request logging
- args,_ = parser.parse_known_args()
+ args, add_args = parser.parse_known_args()
+ #add_args to dict
+ glob_args = {}
+ for arg in add_args:
+ if "=" in arg:
+ key, value = arg.split("=", 1)
+ key = key.lstrip("-")
+ glob_args[key] = value
+ set_global_kwargs(**glob_args)
# Get configuration from environment
port = args.port or int(os.environ.get("WEB_UI_PORT", 0)) or None
diff --git a/webui/index.html b/webui/index.html
index 84c33e008..70ec50c1d 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -232,7 +232,7 @@
});
}
}">
-
+
<!-- Preview section -->
<div x-show="hasAttachments" class="preview-section">
<template x-for="(attachment, index) in attachments" :key="index">
@@ -246,12 +246,12 @@
<span class="extension" x-text="attachment.extension.toUpperCase()"></span>
</div>
</template>
- <button @click="attachments.splice(index, 1); hasAttachments = attachments.length > 0"
- class="remove-attachment">&times;</button>
+ <button @click="attachments.splice(index, 1); hasAttachments = attachments.length > 0"
+ class="remove-attachment">&times;</button>
</div>
</template>
</div>
-
+
<!-- Top row with input and buttons -->
<div class="input-row">
<!-- Attachment icon with tooltip -->
@@ -264,20 +264,21 @@
d="M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z" />
</svg>
</label>
- <input type="file" id="file-input" accept=".png, .jpg, .jpeg, .txt, .pdf, .csv, .html, .json, .md, .py, .js, .sh, .css" multiple style="display: none"
- @change="handleFileUpload($event)">
+ <input type="file" id="file-input"
+ accept=".png, .jpg, .jpeg, .txt, .pdf, .csv, .html, .json, .md, .py, .js, .sh, .css"
+ multiple style="display: none" @change="handleFileUpload($event)">
- <div x-show="showTooltip" class="tooltip">
- Limit: 4 attachments per message
+ <div x-show="showTooltip" class="tooltip">
+ Limit: 4 attachments per message
+ </div>
</div>
- </div>
- <!-- Text input -->
- <textarea id="chat-input" placeholder="Type your message here..." rows="1"></textarea>
+ <!-- Text input -->
+ <textarea id="chat-input" placeholder="Type your message here..." rows="1"></textarea>
- <div id="chat-buttons-wrapper">
- <!-- Send button -->
- <button class="chat-button" id="send-button" aria-label="Send message">
+ <div id="chat-buttons-wrapper">
+ <!-- Send button -->
+ <button class="chat-button" id="send-button" aria-label="Send message">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<path d="M25 20 L75 50 L25 80" fill="none" stroke="currentColor" stroke-width="15">
</path>
@@ -377,6 +378,13 @@
@input="field.value = $event.target.value">
</template>
+ <!-- Password field -->
+ <template x-if="field.type === 'password'">
+ <input type="password" :class="field.classes" :value="field.value"
+ :readonly="field.readonly === true"
+ @input="field.value = $event.target.value">
+ </template>
+
<!-- Textarea field -->
<template x-if="field.type === 'textarea'">
<textarea :class="field.classes" :value="field.value"
diff --git a/webui/settings.css b/webui/settings.css
index 7a17b6473..50c8af021 100644
--- a/webui/settings.css
+++ b/webui/settings.css
@@ -1,336 +1,358 @@
select {
- transition: none;
- }
-
- .modal-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 2001;
- }
-
- .modal-container {
- background: var(--color-panel);
- color: var(--color-primary);
- border-radius: 0.5rem;
- width: 90%;
- max-width: 800px;
- max-height: 90vh;
- display: flex;
- flex-direction: column;
- }
-
+ transition: none;
+}
+
+.modal-overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0, 0, 0, 0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 2001;
+}
+
+.modal-container {
+ background: var(--color-panel);
+ color: var(--color-primary);
+ border-radius: 0.5rem;
+ width: 90%;
+ max-width: 800px;
+ max-height: 90vh;
+ display: flex;
+ flex-direction: column;
+}
+
+.modal-header {
+ padding: 1em 1em;
+ border-bottom: 1px solid var(--color-border);
+}
+
+.modal-header h2 {
+ font-size: 1.25rem;
+ margin: 0;
+}
+
+.modal-header ul {
+ margin-bottom: 0;
+}
+
+.modal-content {
+ padding: var(--spacing-sm);
+ overflow-y: auto;
+ flex-grow: 1;
+ background-clip: border-box;
+ border: 6px solid transparent;
+ transition: all 0.3s ease;
+ margin-bottom: 0;
+ padding-bottom: 0;
+}
+
+.modal-content::-webkit-scrollbar {
+ width: 6px;
+ height: 6px;
+}
+
+.modal-content::-webkit-scrollbar-track {
+ background: transparent;
+ margin: 4px 0;
+ border-radius: 6px;
+}
+
+.modal-content::-webkit-scrollbar-thumb {
+ background-color: rgba(155, 155, 155, 0.5);
+ border-radius: 6px;
+ transition: background-color 0.2s ease;
+}
+
+.modal-content::-webkit-scrollbar-thumb:hover {
+ background-color: rgba(155, 155, 155, 0.7);
+}
+
+.modal-footer {
+ padding: var(--spacing-sm);
+ border-top: 1px solid var(--color-border);
+ display: flex;
+ justify-content: flex-end;
+ gap: 1rem;
+ background: var(--color-background);
+}
+
+.section {
+ margin-bottom: 2rem;
+ padding: 1rem;
+ border: 1px solid var(--color-border);
+ border-radius: 0.5rem;
+}
+
+.section-title {
+ font-size: 1.25rem;
+ font-weight: bold;
+ margin-bottom: 0.5rem;
+}
+
+.section-description {
+ color: #666;
+ margin-bottom: 1rem;
+}
+
+.field {
+ display: grid;
+ margin-block-start: 1rem;
+ grid-template-columns: 250px 1fr;
+ align-items: center;
+}
+
+.field.field-full {
+ grid-template-columns: 1fr;
+}
+
+.field-label {
+ display: flex;
+ flex-direction: column;
+}
+
+.field-title {
+ font-weight: bold;
+}
+
+.field-description {
+ color: #666;
+ font-size: 0.875rem;
+ margin-top: 0.25rem;
+ margin-bottom: 0.5rem;
+}
+
+.field-control {
+ width: 100%;
+ display: flex;
+ align-items: center;
+}
+
+input[type="text"] {
+ width: 100%;
+ padding: 0.5rem;
+ border: 1px solid #ddd;
+ border-radius: 0.25rem;
+ font-family: "Rubik", Arial, Helvetica, sans-serif;
+}
+
+input[type="password"] {
+ width: 100%;
+ padding: 0.5rem;
+ border: 1px solid #ddd;
+ border-radius: 0.25rem;
+ font-family: "Rubik", Arial, Helvetica, sans-serif;
+}
+
+textarea {
+ width: 100%;
+ min-height: 100px;
+ padding: 0.5rem;
+ border: 1px solid #ddd;
+ border-radius: 0.25rem;
+ font-family: Roboto Mono;
+ scroll-behavior: smooth;
+ resize: none;
+ /*-/* scrollbar padding */
+ background-clip: border-box;
+ border: 6px solid transparent;
+ transition: all 0.3s ease;
+}
+
+.toggle {
+ position: relative;
+ display: inline-block;
+ width: 60px;
+ height: 34px;
+ margin: 0;
+}
+
+.toggle input {
+ opacity: 0;
+ width: 0;
+ height: 0;
+}
+
+.toggler {
+ position: absolute;
+ cursor: pointer;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: #ccc;
+ transition: 0.4s;
+ border-radius: 34px;
+}
+
+.toggler:before {
+ position: absolute;
+ content: "";
+ height: 26px;
+ width: 26px;
+ left: 4px;
+ bottom: 4px;
+ background-color: white;
+ transition: 0.4s;
+ border-radius: 50%;
+}
+
+input:checked + .toggler {
+ background-color: #2196f3;
+}
+
+input:checked + .toggler:before {
+ transform: translateX(26px);
+}
+
+input[type="range"] {
+ width: 100%;
+}
+
+.range-value {
+ min-width: 3em;
+ text-align: right;
+}
+
+#buttons-container {
+ display: flex;
+ gap: 0.875rem;
+}
+
+.btn {
+ padding: 0.7rem 1.5rem;
+ border-radius: 0.25rem;
+ cursor: pointer;
+ border: none;
+ font-size: 0.875rem;
+ font-family: "Rubik", Arial, Helvetica, sans-serif;
+}
+
+.btn-ok {
+ background: #3270e2;
+ color: white;
+ transition: background 0.3s ease-in-out;
+}
+
+.btn-ok:hover {
+ background: #3265c0;
+}
+
+.btn-ok:active {
+ background: #345693;
+}
+
+.btn-cancel {
+ background: #ddd;
+ color: #333;
+ transition: background 0.3s ease-in-out;
+}
+
+.btn-cancel:hover {
+ background: #a6a6a6;
+}
+
+.btn-cancel:active {
+ background: #808080;
+}
+
+.btn-field {
+ background: #2196f3;
+ color: white;
+ width: fit-content;
+}
+
+.btn-field:disabled {
+ background: #ccc;
+ cursor: not-allowed;
+}
+
+select {
+ width: 100%;
+ padding: 0.5rem;
+ border: 1px solid #ddd;
+ border-radius: 0.25rem;
+ background-color: white;
+ font-size: inherit;
+ cursor: pointer;
+ font-family: "Rubik", Arial, Helvetica, sans-serif;
+ outline: none;
+}
+
+select:disabled {
+ background-color: #f5f5f5;
+ cursor: not-allowed;
+}
+
+/* Style for navigation links */
+nav ul {
+ list-style-type: none;
+ padding: 0;
+}
+
+nav ul li {
+ display: inline;
+ margin-right: 1rem;
+}
+
+nav ul li a {
+ text-decoration: none;
+ color: #2196f3;
+ font-weight: bold;
+}
+
+nav ul li a:hover {
+ text-decoration: underline;
+}
+
+@media (max-width: 768px) {
.modal-header {
- padding: 0.875rem 2rem;
- border-bottom: 1px solid var(--color-border);
- }
-
- .modal-content {
- padding: 1.5rem;
- overflow-y: auto;
- flex-grow: 1;
- background-clip: border-box;
- border: 6px solid transparent;
- transition: all 0.3s ease;
- margin-bottom: 0;
- padding-bottom: 0;
+ padding: var(--spacing-sm);
+ border-bottom: 1px solid var(--color-border);
}
-
- .modal-content::-webkit-scrollbar {
- width: 6px;
- height: 6px;
+
+ .modal-header h2 {
+ font-size: 1.25rem;
+ margin: 0;
}
-
- .modal-content::-webkit-scrollbar-track {
- background: transparent;
- margin: 4px 0;
- border-radius: 6px;
- }
-
- .modal-content::-webkit-scrollbar-thumb {
- background-color: rgba(155, 155, 155, 0.5);
- border-radius: 6px;
- transition: background-color 0.2s ease;
- }
-
- .modal-content::-webkit-scrollbar-thumb:hover {
- background-color: rgba(155, 155, 155, 0.7);
+
+ .modal-content {
+ padding: 1rem;
+ overflow-y: auto;
+ flex-grow: 1;
}
-
+
.modal-footer {
- padding: 1.5rem 2rem;
- border-top: 1px solid var(--color-border);
- display: flex;
- justify-content: flex-end;
- gap: 1rem;
- background: var(--color-background);
- }
-
- .section {
- margin-bottom: 2rem;
- padding: 1rem;
- border: 1px solid var(--color-border);
- border-radius: 0.5rem;
- }
-
- .section-title {
- font-size: 1.25rem;
- font-weight: bold;
- margin-bottom: 0.5rem;
- }
-
- .section-description {
- color: #666;
- margin-bottom: 1rem;
- }
-
- .field {
- display: grid;
- margin-block-start: 1rem;
- grid-template-columns: 250px 1fr;
- align-items: center;
- }
-
- .field.field-full {
- grid-template-columns: 1fr;
- }
-
- .field-label {
- display: flex;
- flex-direction: column;
- }
-
- .field-title {
- font-weight: bold;
- }
-
- .field-description {
- color: #666;
- font-size: 0.875rem;
- margin-top: 0.25rem;
- margin-bottom: 0.5rem;
- }
-
- .field-control {
- width: 100%;
- display: flex;
- align-items: center;
- }
-
- input[type="text"] {
- width: 100%;
- padding: 0.5rem;
- border: 1px solid #ddd;
- border-radius: 0.25rem;
- font-family: "Rubik", Arial, Helvetica, sans-serif;
+ padding: var(--spacing-sm);
}
-
- textarea {
- width: 100%;
- min-height: 100px;
- padding: 0.5rem;
- border: 1px solid #ddd;
- border-radius: 0.25rem;
- font-family: Roboto Mono;
- scroll-behavior: smooth;
- resize: none;
- /*-/* scrollbar padding */
- background-clip: border-box;
- border: 6px solid transparent;
- transition: all 0.3s ease;
- }
-
- .toggle {
- position: relative;
- display: inline-block;
- width: 60px;
- height: 34px;
- margin: 0;
- }
-
- .toggle input {
- opacity: 0;
- width: 0;
- height: 0;
- }
-
- .toggler {
- position: absolute;
- cursor: pointer;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: #ccc;
- transition: .4s;
- border-radius: 34px;
- }
-
- .toggler:before {
- position: absolute;
- content: "";
- height: 26px;
- width: 26px;
- left: 4px;
- bottom: 4px;
- background-color: white;
- transition: .4s;
- border-radius: 50%;
- }
-
- input:checked+.toggler {
- background-color: #2196F3;
- }
-
- input:checked+.toggler:before {
- transform: translateX(26px);
- }
-
- input[type="range"] {
- width: 100%;
- }
-
- .range-value {
- min-width: 3em;
- text-align: right;
- }
-
+
#buttons-container {
- display: flex;
- gap: 0.875rem;
- }
-
- .btn {
- padding: 0.7rem 1.5rem;
- border-radius: 0.25rem;
- cursor: pointer;
- border: none;
- font-size: 0.875rem;
- font-family: "Rubik", Arial, Helvetica, sans-serif;
- }
-
- .btn-ok {
- background: #3270e2;
- color: white;
- transition: background 0.3s ease-in-out;
- }
-
- .btn-ok:hover{
- background: #3265c0;
- }
-
- .btn-ok:active{
- background: #345693;
+ display: flex;
+ gap: 1rem;
+ margin: 0 auto;
}
-
- .btn-cancel {
- background: #ddd;
- color: #333;
- transition: background 0.3s ease-in-out;
- }
-
- .btn-cancel:hover {
- background: #a6a6a6
- }
-
- .btn-cancel:active {
- background: #808080
- }
-
- .btn-field {
- background: #2196F3;
- color: white;
- width: fit-content;
- }
-
- .btn-field:disabled {
- background: #ccc;
- cursor: not-allowed;
- }
-
- select {
- width: 100%;
- padding: 0.5rem;
- border: 1px solid #ddd;
- border-radius: 0.25rem;
- background-color: white;
- font-size: inherit;
- cursor: pointer;
- font-family: "Rubik", Arial, Helvetica, sans-serif;
- outline: none;
- }
-
- select:disabled {
- background-color: #f5f5f5;
- cursor: not-allowed;
- }
-
- /* Style for navigation links */
- nav ul {
- list-style-type: none;
- padding: 0;
+
+ .section {
+ margin-bottom: 1.5rem;
+ padding: 1rem;
+ border: 1px solid var(--color-border);
+ border-radius: 0.5rem;
}
-
- nav ul li {
- display: inline;
- margin-right: 1rem;
+
+ .field-control {
+ width: 100%;
}
-
- nav ul li a {
- text-decoration: none;
- color: #2196F3;
- font-weight: bold;
+ .field-description {
+ padding-bottom: var(--spacing-sm);
}
-
- nav ul li a:hover {
- text-decoration: underline;
+ .field {
+ padding-top: var(--spacing-xs);
+ padding-bottom: var(--spacing-xs);
+ display: block;
+ align-items: center;
}
-
- @media (max-width: 768px) {
- .modal-header {
- padding: 0.7rem 2rem;
- border-bottom: 1px solid var(--color-border);
- }
-
- .modal-content {
- padding: 1rem;
- overflow-y: auto;
- flex-grow: 1;
- }
-
- .modal-footer {
- padding: 1.5rem;
- }
-
- #buttons-container {
- display: flex;
- gap: 1rem;
- margin: 0 auto;
- }
-
- .section {
- margin-bottom: 1.5rem;
- padding: 1rem;
- border: 1px solid var(--color-border);
- border-radius: 0.5rem;
- }
-
- .field-control {
- width: 100%;
- }
- .field-description {
- padding-bottom: var(--spacing-sm);
- }
- .field {
- padding-top: var(--spacing-xs);
- padding-bottom: var(--spacing-xs);
- display: block;
- align-items: center;
- }
- }
\ No newline at end of file
+}