Commit Graph
102 Commits
Author SHA1 Message Date
Alessandro bea0c16d50 Overlap embedding warm-up with startup watchdogs
Run initialization end hooks while embedding preload continues, then invoke
startup completion to perform the existing bounded wait and start MCP/jobs
before HTTP. Preserve initialization and preload extension skip controls,
best-effort failures, and the ten-second additional wait limit.

Five balanced cached-model boots per version reduced median HTTP readiness
from 17.063s to 15.907s (1.156s, 6.8%) and boot-to-first-token from 19.075s to
18.051s (1.024s, 5.4%). Useful overlap increased from 2.390s to 6.059s.
Post-Send latency increased by 0.146s in this sample; local preparation
increased by 0.025s. Models were warm before HTTP in all five candidate runs.

Validation: 24 focused framework tests passed, including actual ten-second
construction and encoding stalls, deterministic end-hook/warmup overlap,
and extension skip/error paths. The clean live restart returned HTTP 200
and completed preload before HTTP. Temporary probes and benchmark chats
were removed.
2026-10-12 17:57:20 +02:00
Alessandro cc098d3e98 Speed up chat restoration and bound embedding warm-up
Reuse Git version metadata within each chat-load operation and pass saved
message token counts into reconstruction. Preserve per-agent settings and
credential reads, initialization hooks, profiles and legacy token behavior.

Give the existing deferred embedding preload up to 10 extra seconds after
chat restoration, within extensible init_a0. Continue startup on timeout or
task failure while allowing unfinished model loading to complete.

Across five trials per version with the same chat workload and a cached
embedding model, median HTTP readiness after the restart command returned
fell from 38.1 to 27.8 seconds: 10.3 seconds saved, or 27% less waiting.
Boot-to-first-token fell from 42.7 to 33.4 seconds. Post-send first-token
latency did not improve in this sample (4.709 to 5.108 seconds).

Validation: 146 focused framework tests passed, followed by 20 preload tests
including seven new edge cases. Real ten-second stalled-loading/inference
checks and offline missing/cached-model checks passed. Five DeferredTask
lifecycle tests passed separately; an existing test-order failure when
combined with preload imports also reproduces without the new cases.

Fresh-install performance was not measured; the full repository suite was
not run.
2026-10-11 19:27:39 +02:00
Alessandro 2afffe8edc Overlap embedding warm-up with chat restoration
Load sentence-transformers on the existing cache miss and construct the
preloaded model off the shared background event loop. Start warm-up before
chat restoration inside extensible init_a0, preserving start-hook control
and sharing the loaded model with ordinary runtime requests.

Remove unused speech preload imports and dead warm-up functions. Seed APT
indexes only when absent, skipping the refresh on normal container boots.
Keep the existing Python tunnel service and its provider lifecycle.

Validation: 49 focused framework tests passed, including extension-hook
short-circuit behavior, concurrent embedding-cache reuse, APT cache states,
tunnel behavior and CSRF origins. Three cold Fable chat trials per version:
median submit-to-first-token 9.588s -> 4.234s;
local preparation 6.904s -> 1.197s;
HTTP readiness 42.637s -> 41.139s;
boot-to-first-token 52.093s -> 46.657s.
Provider timing varies; these are local repeated measurements. The live
baseline already omitted APT refresh, so it receives no timing credit.
2026-10-10 16:36:08 +02:00
Alessandro ca4efe6e6a Fix Tailscale Remote Control CSRF origins
Normalize active Remote Control URLs to same-origin values before adding them to CSRF allowlists, so Tailscale Funnel URLs with paths or trailing slashes can bootstrap tokens correctly.

Allow WebSocket origin validation to trust only the currently active Remote Control origin, including Docker split-process tunnel service URLs, while preserving rejection for unrelated external origins.

Add focused regression coverage for active Tailscale-style origins, tunnel-service origin lookup, and negative cross-origin cases; keep run_ui decorator re-exports compatible with existing CSRF tests.
2026-06-04 14:54:39 +02:00
Alessandro d1827e6c66 Refactor: use user locale for time displays
Add user-configurable timezone and 12/24-hour preferences, then wire them through settings, runtime snapshots, scheduler payloads, wait handling, notifications, backups, memory, plugin metadata, and frontend formatters.

Keep UTC as the boundary for absolute instants while serializing user-facing dates in the configured or browser-resolved timezone. Preserve scheduler wall-clock inputs in the selected timezone, propagate TZ into desktop/runtime process environments, and restart active desktop sessions when the runtime timezone changes.

Cover the risky paths with timezone regression tests for settings normalization, auto and fixed timezone resolution, scheduler round-trips, memory timestamp conversion, and desktop timezone sync.
2026-05-21 15:26:00 +02:00
frdel b94d4b79ae refactor: comprehensive UI server restructuring and self-update enhancements
- Extract UI server setup into UiServerRuntime class with modular initialization
- Move environment configuration, route registration, and transport handlers to helpers/ui_server.py
- Add released_at timestamp tracking for git tags and branch heads across update system
- Implement get_current_major_main_latest_info to find latest same-major version on main branch
- Add major_upgrade_versions and main_branch_latest fields to update info payload
- Remove
2026-03-31 15:20:57 +02:00
keyboardstaff 1d81f72a31 refactor: Backend core rewrite - WsHandler + WsManager + handler migration
- Add WsHandler base class, WsManager (connection tracking / event routing / buffering), WsResult
- Extract network.py (is_loopback_address) and context_utils.py (use_context) to eliminate duplication
- Migrate three handlers to api/ following the ws_* py naming convention
- Simplify run_ui.py WebSocket init from ~170 lines to ~10
- Update import paths in api.py, plugins.py, state_monitor.py
2026-03-26 00:58:01 -07:00
frdel a5620506d5 refactor: rename state_sync namespace to webui and simplify handler event registration
- Rename /state_sync namespace to /webui throughout codebase
- Remove get_event_types() from WebSocketHandler - handlers now process all events for their namespace
- Replace per-event handler registration with namespace-wide registration
- Add validate_event_type() class method for runtime event name validation
- Update UserMessage instantiation to use keyword arguments (message=, attachments=)
- Move send_data
2026-03-20 15:34:59 +01:00
frdel 651deac6f7 refactor: add websocket wildcard event support and improve cache clearing
- Add wildcard pattern matching for websocket events (*, eventPattern compilation)
- Update WebSocketClient.on() to handle wildcard subscriptions with onAny/offAny
- Add send_data helper and set_shared_websocket_manager for global websocket access
- Broadcast cache clear events to frontend via websocket
- Subscribe to wildcard events in sync-store and route to extensions
- Move get_default_value import to function scope in
2026-03-20 14:04:43 +01:00
frdel 7eb6d5b19a refactor: optimize WebSocket handler lifecycle and fix extension asset path handling
- Change `_active_handlers` from list of tuples to dict mapping paths to handler instances
- Cache handler instances on connect instead of recreating them for each event
- Reuse cached instances in `_dispatch` instead of instantiating new ones
- Remove redundant handler instantiation in `_on_disconnect`
- Add type ignore comments for socketio event decorators
- Fix extension asset path construction to use proper directory variable
2026-03-17 17:00:40 +01:00
keyboardstaff 28002047e6 refactor: websocket dynamic endpoints 2026-03-16 07:37:33 -07:00
Paolo Calvi 07f94ef4b5 Fix WebSocket CSRF validation failure on Chromium browsers over HTTPS
SameSite=Strict cookies are not sent with WebSocket upgrade requests on
Chromium-based browsers (Brave confirmed), causing the CSRF cookie
check at connect time to fail with 'csrf cookie mismatch'. This breaks
the state_sync namespace, preventing the UI from loading chats.

Change SameSite from Strict to Lax for both the Flask session cookie
and the JavaScript-set CSRF token cookie. Lax still prevents cross-site
POST CSRF while allowing same-origin WebSocket upgrades to include
cookies.

Fixes #1237
2026-03-11 00:00:33 +01:00
frdel ab9fc4ee7f Refactor extensions to async/sync API
Redesign extension handling to support explicit async/sync execution. helpers/extension.py rewrites the extensible decorator, adds call_extensions_async / call_extensions_sync, and a helper to gather extension classes; caching flag adjusted. Updated call sites across the codebase (agent, APIs, plugins, tools, settings, extensions) to use extension.extensible and the new call_extensions_async/sync API, and converted several extension handlers from async to sync. Also small frontend tweaks (use globalThis.runtimeInfo) and minor import updates (csrf_protect in run_ui). This centralizes extension discovery/execution and avoids previously scattered asyncio.run usage.
2026-03-06 11:32:08 +01:00
frdel d02dda3667 BIG PYTHON REFACTOR
Python scripts moved out of python/ folder to root to be unified with plugins

+ frontend extension around api calls
2026-03-05 17:28:11 +01:00
frdel f7b7683918 Add extensible hooks and improve agent detection
Annotate many Agent and AgentContext methods with @extensible to expose extension points and enable runtime hooks. Refactor python/helpers/extension.py to derive extension points from __qualname__, add a _get_agent helper that more robustly finds an Agent instance in args/kwargs, and skip extension handling when module/qualname cannot be determined. Apply extensible to relevant Flask handlers in run_ui and import the extension helper. Also bump the default sleep_time in the code execution tool from 0.1 to 0.5s to reduce polling frequency.
2026-02-25 20:32:49 +01:00
frdel 4e243a996c Refactor API routing, add cache and security
Centralize API routing and security: moved loopback/API-key/auth/CSRF decorators into python/helpers/api.py and added register_api_route to dynamically dispatch handlers from built-in python/api and plugin api folders. Added a simple thread-safe in-memory cache (python/helpers/cache.py) to store wrapped handlers. register_api_route resolves handler classes, enforces allowed methods, composes required security wrappers, caches the resulting callables, and registers a single /api/<path> rule. Also updated runtime RFC URL to use /api/rfc. Removed the duplicate handler registration and security helper code from run_ui.py and replaced it with the new register_api_route import.
2026-02-20 09:43:21 +01:00
frdel 5acb733b9e Refactor plugin/project helpers; add plugin UI
Major refactor of plugin and project helper APIs and add a plugin management UI.

Key changes:
- Rename project meta helpers from get_project_meta_folder -> get_project_meta and update callers across many modules (projects, memory, skills_import, secrets, subagents, skills).
- Overhaul python/helpers/plugins.py: introduce PluginMetadata and PluginListItem (Pydantic), new get_plugins_list/get_enhanced_plugins_list, support for reading plugin config (config.json), enable/disable logic (.enabled/.disabled), get_enabled_plugin_paths(), and helpers to find/read/save plugin assets. Plugin discovery now supports webui/main/config detection.
- Use enabled-plugin-aware lookups in subagents, extension loading, and other places (plugins.get_enabled_plugin_paths / get_enhanced_plugins_list used instead of previous list_plugins/get_plugin_paths where appropriate).
- Add API endpoint python/api/plugins_list.py to return JSON plugin lists.
- Add frontend plugin management UI: web components webui/components/plugins/list/plugin-list.html and pluginListStore.js; wire quick-actions button to open the plugins modal.
- Add new webui assets and config pages for example_agent and memory plugins; add plugins/plugin.json metadata for example_agent and memory.
- Memory plugin fixes: updated calls to use get_project_meta and adjusted memory path helpers to use project meta layout.
- File helper: add read_file_json to read JSON files directly.
- run_ui: tightened plugin asset serving security (only serve from plugin webui or plugin extensions/webui), added unified _serve_plugin_asset helper, and load plugin API handlers using enhanced plugin list.
- Small fixes: adjustments to parse_prompt/read_prompt/tool lookup to use updated subagents.get_paths signature, extension loader now uses enabled plugin paths, and web UI extensions JS updated to expect string paths.

These changes centralize project meta handling, improve plugin discovery and enable/disable behavior, and add a basic plugin management UI and API.
2026-02-19 17:20:14 +01:00
frdel 07c128130b Refactor plugin discovery and asset serving
Add basic plugin manifests and refactor plugin/file helpers to support flexible plugin resolution and secure asset serving.

- Add placeholder plugin.json for example_agent and memory plugins.
- Introduce constants and small cleanup in python/helpers/files.py (AGENTS_DIR, PLUGINS_DIR, PROJECTS_DIR, USER_DIR) and add helpers: is_file, is_dir, get_abs_path_dockerized, plus minor formatting/style fixes.
- Refactor plugin metadata code in python/helpers/plugins.py: replace Plugin dataclass with a lightweight PluginListItem, centralize plugin roots, and implement find_plugin_dir, find_plugin_file, get_plugin_settings, save_plugin_settings and determine_plugin_save_file_path to resolve plugin files across usr/, plugins/, projects and agent profiles with correct precedence.
- Update run_ui.py to use plugin_name (instead of plugin_id), resolve plugin directories via new helpers, enforce directory traversal/security checks using files.is_in_dir and files.is_file, and namespace API routes by plugin.name.

These changes enable per-user/project/agent plugin overrides, add settings load/save support, and harden static asset serving.
2026-02-18 21:41:41 +01:00
frdel 3918133cbf plugins - frontend PoC 2026-02-16 20:01:25 +01:00
Alessandro d69e30adc6 simplification and further memory decoupling
components.js restore
plugins tools fix
restore agent.py
2026-02-15 03:25:33 +01:00
3clyp50 54fb4746a4 initial plugins effort; memory system PoC
plugin manifest update
add memory plugin PoC files
offload memory prompts
cleanup imports
extract memory UI
fix paths
plugin docs
2026-02-14 17:05:37 +01:00
frdel cc3f02e163 supress warnings, test connectivity on start 2026-02-10 12:00:22 +01:00
frdel 85d8c4894e better logging in websockets 2026-02-10 10:12:03 +01:00
frdel c223b46818 workdir outside project, gitkeeps 2026-02-08 14:54:49 +01:00
frdel 65607a36fc fix backup and file limit 2026-02-06 14:11:57 +01:00
frdel 181135f58a Settings polishing, logout button 2026-02-05 22:02:49 +01:00
frdel 4932e12546 WebSocket merge 2026-02-01 16:07:45 +01:00
linuztx 10bc874f05 refactor: migrate user data to usr/ + update frontend paths 2025-12-12 10:11:12 +08:00
frdel c18c04d772 csrf ALLOWED_ORIGINS protection 2025-10-06 12:20:15 +02:00
frdel 43613d8f80 browser use upgrade 2025-09-23 14:55:10 +02:00
frdel 6814777869 login page polishing 2025-09-23 09:49:52 +02:00
Wabifocus 603aed49be Refactor: Update backend logic 2025-09-01 02:14:22 -07:00
frdel 8a6355aa63 settings .env+json config, logging fix 2025-08-26 14:44:43 +02:00
frdel b11e5d746f API endpoints merge + Ace editor 2025-08-07 15:04:21 +02:00
frdel d0a0bf67b8 shell echo fix, faster startup 2025-08-01 15:38:05 +02:00
frdel 9c6da37f8d a2a polishing 2025-07-31 21:49:50 +02:00
frdel 644cc40d42 Merge branch 'pr/636' into development 2025-07-31 21:22:55 +02:00
Rafael Uzarowski f3605eb53b fix: token auth and reconfiguration 2025-07-31 19:12:08 +02:00
Rafael Uzarowski d84d24b3be feat: A2A Client/Server Implementation 2025-07-31 17:06:09 +02:00
frdel 2b23d2510d files polishing 2025-07-31 10:39:01 +02:00
The Master 3eb6d8ff61 Read file refactor + Fix include path errors (#633)
* refactor: read_file to read_prompt_file

* fix: ignore absolute paths in includes
2025-07-31 10:21:33 +02:00
Rafael Uzarowski e74dabb40a feat: External API Endpoints 2025-07-27 14:40:36 +02:00
frdel ff29f2b12d debug messages cleanup 2025-07-21 22:19:15 +02:00
frdel 5600687618 preload improvement 2025-07-15 23:01:44 +02:00
Rffanand7934-方露宇 fe1a386095 fix timezone not found on windows (#568)
Co-authored-by: 7934-方露宇 <fangluyu@wondersgroup.com>
2025-07-09 14:25:46 +02:00
frdel f51766778b csrf + inor fixes 2025-07-02 17:03:03 +02:00
frdel 2fbba0d794 session collision fix 2025-07-02 14:16:41 +02:00
frdel 2fcc8ec885 merge prep 2025-06-30 16:16:51 +02:00
frdel 1bb4123dcb security fixes
- CSRF tokens implemented into api calls
- password change shell injection fixed
2025-06-24 14:19:49 +02:00
frdel 7528c79fc1 Better initialization 2025-06-07 22:28:47 +02:00