flock-core 0.4.0b34__py3-none-any.whl → 0.4.0b36__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.
Potentially problematic release.
This version of flock-core might be problematic. Click here for more details.
- flock/__init__.py +53 -8
- flock/cli/loaded_flock_cli.py +38 -18
- flock/core/api/main.py +138 -39
- flock/core/flock.py +48 -3
- flock/themes/alabaster.toml +43 -43
- flock/themes/guezwhoz.toml +43 -43
- flock/themes/wildcherry.toml +43 -43
- flock/themes/wombat.toml +43 -43
- flock/themes/zenburn.toml +43 -43
- flock/webapp/__init__.py +1 -0
- flock/webapp/app/__init__.py +0 -0
- flock/webapp/app/api/__init__.py +0 -0
- flock/webapp/app/api/agent_management.py +270 -0
- flock/webapp/app/api/execution.py +173 -0
- flock/webapp/app/api/flock_management.py +102 -0
- flock/webapp/app/api/registry_viewer.py +30 -0
- flock/webapp/app/config.py +87 -0
- flock/webapp/app/main.py +1074 -0
- flock/webapp/app/models_ui.py +7 -0
- flock/webapp/app/services/__init__.py +0 -0
- flock/webapp/app/services/flock_service.py +291 -0
- flock/webapp/app/templates/theme_mapper.html +326 -0
- flock/webapp/app/theme_mapper.py +812 -0
- flock/webapp/app/utils.py +85 -0
- flock/webapp/run.py +132 -0
- flock/webapp/static/css/custom.css +612 -0
- flock/webapp/templates/base.html +105 -0
- flock/webapp/templates/flock_editor.html +17 -0
- flock/webapp/templates/index.html +12 -0
- flock/webapp/templates/partials/_agent_detail_form.html +98 -0
- flock/webapp/templates/partials/_agent_list.html +19 -0
- flock/webapp/templates/partials/_agent_manager_view.html +53 -0
- flock/webapp/templates/partials/_agent_manager_view_old.html +19 -0
- flock/webapp/templates/partials/_agent_tools_checklist.html +14 -0
- flock/webapp/templates/partials/_create_flock_form.html +52 -0
- flock/webapp/templates/partials/_dashboard_flock_detail.html +18 -0
- flock/webapp/templates/partials/_dashboard_flock_file_list.html +17 -0
- flock/webapp/templates/partials/_dashboard_flock_properties_preview.html +29 -0
- flock/webapp/templates/partials/_dashboard_upload_flock_form.html +17 -0
- flock/webapp/templates/partials/_dynamic_input_form_content.html +22 -0
- flock/webapp/templates/partials/_env_vars_table.html +25 -0
- flock/webapp/templates/partials/_execution_form.html +48 -0
- flock/webapp/templates/partials/_execution_view_container.html +20 -0
- flock/webapp/templates/partials/_flock_file_list.html +24 -0
- flock/webapp/templates/partials/_flock_properties_form.html +52 -0
- flock/webapp/templates/partials/_flock_upload_form.html +17 -0
- flock/webapp/templates/partials/_header_flock_status.html +5 -0
- flock/webapp/templates/partials/_load_manager_view.html +50 -0
- flock/webapp/templates/partials/_registry_table.html +25 -0
- flock/webapp/templates/partials/_registry_viewer_content.html +47 -0
- flock/webapp/templates/partials/_results_display.html +35 -0
- flock/webapp/templates/partials/_settings_env_content.html +10 -0
- flock/webapp/templates/partials/_settings_theme_content.html +15 -0
- flock/webapp/templates/partials/_settings_view.html +36 -0
- flock/webapp/templates/partials/_sidebar.html +70 -0
- flock/webapp/templates/partials/_structured_data_view.html +40 -0
- flock/webapp/templates/partials/_theme_preview.html +23 -0
- flock/webapp/templates/registry_viewer.html +84 -0
- {flock_core-0.4.0b34.dist-info → flock_core-0.4.0b36.dist-info}/METADATA +1 -1
- {flock_core-0.4.0b34.dist-info → flock_core-0.4.0b36.dist-info}/RECORD +63 -14
- {flock_core-0.4.0b34.dist-info → flock_core-0.4.0b36.dist-info}/WHEEL +0 -0
- {flock_core-0.4.0b34.dist-info → flock_core-0.4.0b36.dist-info}/entry_points.txt +0 -0
- {flock_core-0.4.0b34.dist-info → flock_core-0.4.0b36.dist-info}/licenses/LICENSE +0 -0
flock/__init__.py
CHANGED
|
@@ -1,8 +1,61 @@
|
|
|
1
1
|
"""Flock package initialization."""
|
|
2
2
|
|
|
3
|
+
import argparse
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
|
|
3
7
|
|
|
4
8
|
def main():
|
|
5
9
|
"""Main function."""
|
|
10
|
+
# Parse command line arguments
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
description="Flock - Declarative LLM Orchestration at Scale"
|
|
13
|
+
)
|
|
14
|
+
parser.add_argument(
|
|
15
|
+
"--web",
|
|
16
|
+
action="store_true",
|
|
17
|
+
help="Start the web interface instead of the CLI",
|
|
18
|
+
)
|
|
19
|
+
parser.add_argument(
|
|
20
|
+
"--theme",
|
|
21
|
+
type=str,
|
|
22
|
+
default=None,
|
|
23
|
+
help="Specify the theme name for the web interface (if --web is used).",
|
|
24
|
+
)
|
|
25
|
+
args = parser.parse_args()
|
|
26
|
+
|
|
27
|
+
# If --web flag is provided, start the web server
|
|
28
|
+
if args.web:
|
|
29
|
+
try:
|
|
30
|
+
# Set environment variable for theme if provided
|
|
31
|
+
if args.theme:
|
|
32
|
+
print(
|
|
33
|
+
f"Setting FLOCK_WEB_THEME environment variable to: {args.theme}"
|
|
34
|
+
)
|
|
35
|
+
os.environ["FLOCK_WEB_THEME"] = args.theme
|
|
36
|
+
else:
|
|
37
|
+
# Ensure it's not set if no theme arg is passed
|
|
38
|
+
if "FLOCK_WEB_THEME" in os.environ:
|
|
39
|
+
del os.environ["FLOCK_WEB_THEME"]
|
|
40
|
+
|
|
41
|
+
# Import and run the standalone webapp main function
|
|
42
|
+
# It will now read the theme from the environment variable
|
|
43
|
+
from flock.webapp.run import main as run_webapp_main
|
|
44
|
+
|
|
45
|
+
run_webapp_main()
|
|
46
|
+
|
|
47
|
+
except ImportError:
|
|
48
|
+
print(
|
|
49
|
+
"Error: Could not import webapp components. Ensure web dependencies are installed.",
|
|
50
|
+
file=sys.stderr,
|
|
51
|
+
)
|
|
52
|
+
sys.exit(1)
|
|
53
|
+
except Exception as e:
|
|
54
|
+
print(f"Error starting webapp: {e}", file=sys.stderr)
|
|
55
|
+
sys.exit(1)
|
|
56
|
+
return
|
|
57
|
+
|
|
58
|
+
# Otherwise, run the CLI interface
|
|
6
59
|
import questionary
|
|
7
60
|
from rich.console import Console
|
|
8
61
|
from rich.panel import Panel
|
|
@@ -31,8 +84,6 @@ def main():
|
|
|
31
84
|
console = Console()
|
|
32
85
|
|
|
33
86
|
# Show a welcome message on first run with the new tool serialization format
|
|
34
|
-
import os
|
|
35
|
-
|
|
36
87
|
cfg_file = os.path.expanduser(f"~/.flock/{CLI_CFG_FILE}")
|
|
37
88
|
if not os.path.exists(cfg_file):
|
|
38
89
|
# Create the directory if it doesn't exist
|
|
@@ -115,12 +166,6 @@ def main():
|
|
|
115
166
|
manage_registry()
|
|
116
167
|
elif result == CLI_SETTINGS:
|
|
117
168
|
settings_editor()
|
|
118
|
-
elif result == CLI_START_WEB_SERVER:
|
|
119
|
-
# Simple web server without a loaded Flock - could create a new one
|
|
120
|
-
console.print(
|
|
121
|
-
"[yellow]Web server without loaded Flock not yet implemented.[/]"
|
|
122
|
-
)
|
|
123
|
-
input("\nPress Enter to continue...")
|
|
124
169
|
elif result == CLI_NOTES:
|
|
125
170
|
load_release_notes()
|
|
126
171
|
elif result == CLI_EXIT:
|
flock/cli/loaded_flock_cli.py
CHANGED
|
@@ -12,8 +12,8 @@ from flock.cli.constants import (
|
|
|
12
12
|
CLI_REGISTRY_MANAGEMENT,
|
|
13
13
|
CLI_SETTINGS,
|
|
14
14
|
)
|
|
15
|
-
from flock.core.api import runner
|
|
16
15
|
from flock.core.flock import Flock
|
|
16
|
+
from flock.core.logging.logging import get_logger
|
|
17
17
|
from flock.core.util.cli_helper import init_console
|
|
18
18
|
|
|
19
19
|
# Import future modules we'll create
|
|
@@ -48,6 +48,7 @@ except ImportError:
|
|
|
48
48
|
|
|
49
49
|
# Create console instance
|
|
50
50
|
console = Console()
|
|
51
|
+
logger = get_logger("cli.loaded_flock")
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
def start_loaded_flock_cli(
|
|
@@ -188,17 +189,11 @@ def start_loaded_flock_cli(
|
|
|
188
189
|
|
|
189
190
|
|
|
190
191
|
def _start_web_server(flock: Flock, create_ui: bool = False) -> None:
|
|
191
|
-
"""Start a web server with the loaded Flock instance.
|
|
192
|
-
|
|
193
|
-
Args:
|
|
194
|
-
flock: The loaded Flock instance
|
|
195
|
-
create_ui: Whether to create a UI for the web server
|
|
196
|
-
"""
|
|
192
|
+
"""Start a web server with the loaded Flock instance."""
|
|
197
193
|
host = "127.0.0.1"
|
|
198
194
|
port = 8344
|
|
199
|
-
server_name = "
|
|
195
|
+
# server_name = flock.name + " API" # Use flock name by default for server_name
|
|
200
196
|
|
|
201
|
-
# Get configuration from user
|
|
202
197
|
console.print("\n[bold]Web Server Configuration[/]")
|
|
203
198
|
|
|
204
199
|
host_input = questionary.text(
|
|
@@ -214,21 +209,46 @@ def _start_web_server(flock: Flock, create_ui: bool = False) -> None:
|
|
|
214
209
|
port = int(port_input)
|
|
215
210
|
|
|
216
211
|
server_name_input = questionary.text(
|
|
217
|
-
"Server name (default: FlockName API):", default=flock.name
|
|
212
|
+
"Server name (default: FlockName API):", default=f"{flock.name or 'Flock'} API"
|
|
218
213
|
).ask()
|
|
219
|
-
if server_name_input:
|
|
220
|
-
|
|
214
|
+
# if server_name_input: # server_name will be set by flock.start_api if not passed, or use its default
|
|
215
|
+
# server_name = server_name_input
|
|
216
|
+
|
|
217
|
+
ui_theme_to_pass = None
|
|
218
|
+
if create_ui:
|
|
219
|
+
try:
|
|
220
|
+
from flock.webapp.app.config import (
|
|
221
|
+
DEFAULT_THEME_NAME,
|
|
222
|
+
list_available_themes,
|
|
223
|
+
)
|
|
224
|
+
available_themes = list_available_themes()
|
|
225
|
+
theme_choices = ["default (current environment setting)", "random"] + sorted(available_themes)
|
|
226
|
+
|
|
227
|
+
selected_theme_choice = questionary.select(
|
|
228
|
+
"Select UI theme:",
|
|
229
|
+
choices=theme_choices,
|
|
230
|
+
default="default (current environment setting)"
|
|
231
|
+
).ask()
|
|
232
|
+
|
|
233
|
+
if selected_theme_choice == "random":
|
|
234
|
+
ui_theme_to_pass = "random"
|
|
235
|
+
elif selected_theme_choice and selected_theme_choice != "default (current environment setting)":
|
|
236
|
+
ui_theme_to_pass = selected_theme_choice
|
|
237
|
+
# If "default" or None, ui_theme_to_pass remains None, Flock.start_api will use its logic
|
|
238
|
+
|
|
239
|
+
except ImportError:
|
|
240
|
+
logger.warning("Could not import webapp theme configuration for CLI selection. Theme will use default.")
|
|
241
|
+
ui_theme_to_pass = None # Fallback if webapp components not there
|
|
221
242
|
|
|
222
|
-
# Start the web server
|
|
223
243
|
console.print(
|
|
224
|
-
f"\nStarting web server on {host}:{port} {'with UI' if create_ui else 'without UI'}..."
|
|
244
|
+
f"\nStarting web server on {host}:{port} {'with UI' if create_ui else 'without UI'}{' (Theme: ' + (ui_theme_to_pass if ui_theme_to_pass else 'default') + ')' if create_ui else ''}..."
|
|
225
245
|
)
|
|
226
246
|
|
|
227
|
-
#
|
|
228
|
-
|
|
229
|
-
flock=flock,
|
|
247
|
+
# Call the Flock instance's own start_api method directly
|
|
248
|
+
flock.start_api(
|
|
230
249
|
host=host,
|
|
231
250
|
port=port,
|
|
232
|
-
server_name=
|
|
251
|
+
server_name=server_name_input, # Pass the chosen server name
|
|
233
252
|
create_ui=create_ui,
|
|
253
|
+
ui_theme=ui_theme_to_pass,
|
|
234
254
|
)
|
flock/core/api/main.py
CHANGED
|
@@ -12,14 +12,56 @@ from flock.core.api.models import FlockBatchRequest
|
|
|
12
12
|
from flock.core.flock import Flock
|
|
13
13
|
from flock.core.logging.logging import get_logger
|
|
14
14
|
|
|
15
|
+
logger = get_logger("api.main")
|
|
16
|
+
|
|
15
17
|
from .endpoints import create_api_router
|
|
16
18
|
|
|
17
19
|
# Import components from the api package
|
|
18
20
|
from .run_store import RunStore
|
|
19
|
-
from .ui.routes import FASTHTML_AVAILABLE, create_ui_app
|
|
20
|
-
from .ui.utils import format_result_to_html, parse_input_spec # Import UI utils
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
# Conditionally import for the new UI integration
|
|
23
|
+
NEW_UI_SERVICE_AVAILABLE = False
|
|
24
|
+
WEBAPP_FASTAPI_APP = None
|
|
25
|
+
try:
|
|
26
|
+
from flock.webapp.app.main import (
|
|
27
|
+
app as webapp_fastapi_app, # Import the FastAPI app instance
|
|
28
|
+
)
|
|
29
|
+
from flock.webapp.app.services.flock_service import (
|
|
30
|
+
set_current_flock_instance_programmatically,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
WEBAPP_FASTAPI_APP = webapp_fastapi_app
|
|
34
|
+
NEW_UI_SERVICE_AVAILABLE = True
|
|
35
|
+
except ImportError:
|
|
36
|
+
logger.warning(
|
|
37
|
+
"New webapp components (flock.webapp.app.main:app or flock.webapp.app.services.flock_service) not found. "
|
|
38
|
+
"UI mode will fall back to old FastHTML UI if available."
|
|
39
|
+
)
|
|
40
|
+
# Fallback: Import old UI components if new one isn't available and create_ui is True
|
|
41
|
+
try:
|
|
42
|
+
from .ui.routes import FASTHTML_AVAILABLE, create_ui_app
|
|
43
|
+
|
|
44
|
+
if FASTHTML_AVAILABLE: # Only import utils if fasthtml is there
|
|
45
|
+
from .ui.utils import format_result_to_html, parse_input_spec
|
|
46
|
+
else:
|
|
47
|
+
# Define placeholders if fasthtml itself is not available
|
|
48
|
+
def parse_input_spec(*args, **kwargs):
|
|
49
|
+
return []
|
|
50
|
+
|
|
51
|
+
def format_result_to_html(*args, **kwargs):
|
|
52
|
+
return ""
|
|
53
|
+
|
|
54
|
+
FASTHTML_AVAILABLE = False # Ensure it's false if import failed
|
|
55
|
+
|
|
56
|
+
except ImportError:
|
|
57
|
+
FASTHTML_AVAILABLE = False # Ensure it's defined as false
|
|
58
|
+
|
|
59
|
+
# Define placeholders if utils can't be imported
|
|
60
|
+
def parse_input_spec(*args, **kwargs):
|
|
61
|
+
return []
|
|
62
|
+
|
|
63
|
+
def format_result_to_html(*args, **kwargs):
|
|
64
|
+
return ""
|
|
23
65
|
|
|
24
66
|
|
|
25
67
|
class FlockAPI:
|
|
@@ -390,62 +432,119 @@ class FlockAPI:
|
|
|
390
432
|
server_name: str = "Flock API",
|
|
391
433
|
create_ui: bool = False,
|
|
392
434
|
):
|
|
393
|
-
"""Start the API server,
|
|
435
|
+
"""Start the API server. If create_ui is True, it mounts the new webapp or the old FastHTML UI at the root."""
|
|
394
436
|
if create_ui:
|
|
395
|
-
if
|
|
396
|
-
logger.
|
|
397
|
-
"
|
|
437
|
+
if NEW_UI_SERVICE_AVAILABLE and WEBAPP_FASTAPI_APP:
|
|
438
|
+
logger.info(
|
|
439
|
+
f"Preparing to mount new Scoped Web UI at root for Flock: {self.flock.name}"
|
|
398
440
|
)
|
|
399
|
-
else:
|
|
400
|
-
logger.info("Attempting to create and mount FastHTML UI at /ui")
|
|
401
441
|
try:
|
|
402
|
-
#
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
self,
|
|
406
|
-
api_host=host,
|
|
407
|
-
api_port=port,
|
|
408
|
-
server_name=server_name,
|
|
442
|
+
# Set the flock instance for the webapp
|
|
443
|
+
set_current_flock_instance_programmatically(
|
|
444
|
+
self.flock,
|
|
445
|
+
f"{self.flock.name.replace(' ', '_').lower()}_api_scoped.flock",
|
|
409
446
|
)
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
# Add root redirect only if UI was successfully mounted
|
|
414
|
-
@self.app.get(
|
|
415
|
-
"/",
|
|
416
|
-
include_in_schema=False,
|
|
417
|
-
response_class=RedirectResponse,
|
|
447
|
+
logger.info(
|
|
448
|
+
f"Flock '{self.flock.name}' set for the new web UI (now part of the main app)."
|
|
418
449
|
)
|
|
419
|
-
async def root_redirect():
|
|
420
|
-
logger.debug("Redirecting / to /ui/")
|
|
421
|
-
return "/ui/"
|
|
422
450
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
451
|
+
# Mount the new web UI app at the root of self.app
|
|
452
|
+
# The WEBAPP_FASTAPI_APP handles its own routes including '/', static files etc.
|
|
453
|
+
# It will need to be started with ui_mode=scoped, which should be handled by
|
|
454
|
+
# the client accessing /?ui_mode=scoped initially.
|
|
455
|
+
self.app.mount(
|
|
456
|
+
"/", WEBAPP_FASTAPI_APP, name="flock_ui_root"
|
|
457
|
+
)
|
|
458
|
+
logger.info(
|
|
459
|
+
f"New Web UI (scoped mode) mounted at root. Access at http://{host}:{port}/?ui_mode=scoped"
|
|
426
460
|
)
|
|
461
|
+
# No explicit root redirect needed from self.app to WEBAPP_FASTAPI_APP's root,
|
|
462
|
+
# as WEBAPP_FASTAPI_APP now *is* the handler for "/".
|
|
463
|
+
# The API's own routes (e.g. /api/...) will still be served by self.app if they don't conflict.
|
|
464
|
+
|
|
465
|
+
logger.info(
|
|
466
|
+
f"API server '{server_name}' (with integrated UI) starting on http://{host}:{port}"
|
|
467
|
+
)
|
|
468
|
+
logger.info(
|
|
469
|
+
f"Access the Scoped UI for '{self.flock.name}' at http://{host}:{port}/?ui_mode=scoped"
|
|
470
|
+
)
|
|
471
|
+
|
|
427
472
|
except Exception as e:
|
|
428
473
|
logger.error(
|
|
429
|
-
f"
|
|
474
|
+
f"Error setting up or mounting new scoped UI at root: {e}. "
|
|
475
|
+
"API will start, UI might be impacted.",
|
|
430
476
|
exc_info=True,
|
|
431
477
|
)
|
|
478
|
+
elif FASTHTML_AVAILABLE: # Fallback to old FastHTML UI
|
|
479
|
+
logger.warning(
|
|
480
|
+
"New webapp not available or WEBAPP_FASTAPI_APP is None. Falling back to old FastHTML UI (mounted at /ui)."
|
|
481
|
+
)
|
|
482
|
+
try:
|
|
483
|
+
from .ui.routes import create_ui_app
|
|
484
|
+
except ImportError:
|
|
485
|
+
logger.error(
|
|
486
|
+
"Failed to import create_ui_app for old UI. API running without UI."
|
|
487
|
+
)
|
|
488
|
+
FASTHTML_AVAILABLE = False
|
|
432
489
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
490
|
+
if FASTHTML_AVAILABLE:
|
|
491
|
+
logger.info(
|
|
492
|
+
"Attempting to create and mount old FastHTML UI at /ui"
|
|
493
|
+
) # Old UI stays at /ui
|
|
494
|
+
try:
|
|
495
|
+
fh_app = create_ui_app(
|
|
496
|
+
self,
|
|
497
|
+
api_host=host,
|
|
498
|
+
api_port=port,
|
|
499
|
+
server_name=server_name,
|
|
500
|
+
)
|
|
501
|
+
self.app.mount(
|
|
502
|
+
"/ui", fh_app, name="old_flock_ui"
|
|
503
|
+
) # Old UI still at /ui
|
|
504
|
+
logger.info(
|
|
505
|
+
"Old FastHTML UI mounted successfully at /ui."
|
|
506
|
+
)
|
|
507
|
+
|
|
508
|
+
@self.app.get(
|
|
509
|
+
"/",
|
|
510
|
+
include_in_schema=False,
|
|
511
|
+
response_class=RedirectResponse,
|
|
512
|
+
)
|
|
513
|
+
async def root_redirect_to_old_ui(): # Redirect / to /ui/ for old UI
|
|
514
|
+
logger.debug("Redirecting / to /ui/ (old UI)")
|
|
515
|
+
return RedirectResponse(url="/ui/", status_code=303)
|
|
516
|
+
|
|
517
|
+
logger.info(
|
|
518
|
+
f"Old FastHTML UI available at http://{host}:{port}/ui/"
|
|
519
|
+
)
|
|
520
|
+
except Exception as e:
|
|
521
|
+
logger.error(
|
|
522
|
+
f"An error occurred setting up the old FastHTML UI: {e}. Running API only.",
|
|
523
|
+
exc_info=True,
|
|
524
|
+
)
|
|
525
|
+
else:
|
|
526
|
+
logger.error(
|
|
527
|
+
"No UI components available. API running without UI."
|
|
528
|
+
)
|
|
529
|
+
|
|
530
|
+
if not create_ui:
|
|
531
|
+
logger.info(
|
|
532
|
+
f"API server '{server_name}' starting on http://{host}:{port} (UI not requested)."
|
|
439
533
|
)
|
|
534
|
+
elif (
|
|
535
|
+
not (NEW_UI_SERVICE_AVAILABLE and WEBAPP_FASTAPI_APP)
|
|
536
|
+
and not FASTHTML_AVAILABLE
|
|
440
537
|
):
|
|
441
|
-
logger.info(
|
|
538
|
+
logger.info(
|
|
539
|
+
f"API server '{server_name}' starting on http://{host}:{port}. UI was requested but no components found."
|
|
540
|
+
)
|
|
442
541
|
|
|
443
542
|
uvicorn.run(self.app, host=host, port=port)
|
|
444
543
|
|
|
445
544
|
async def stop(self):
|
|
446
545
|
"""Stop the API server."""
|
|
447
546
|
logger.info("Stopping API server (cleanup if necessary)")
|
|
448
|
-
pass
|
|
547
|
+
pass
|
|
449
548
|
|
|
450
549
|
|
|
451
550
|
# --- End of file ---
|
flock/core/flock.py
CHANGED
|
@@ -684,12 +684,57 @@ class Flock(BaseModel, Serializable):
|
|
|
684
684
|
port: int = 8344,
|
|
685
685
|
server_name: str = "Flock API",
|
|
686
686
|
create_ui: bool = False,
|
|
687
|
+
ui_theme: str | None = None,
|
|
687
688
|
) -> None:
|
|
688
|
-
"""Starts a REST API server for this Flock instance.
|
|
689
|
+
"""Starts a REST API server for this Flock instance.
|
|
690
|
+
If create_ui is True, integrates the web UI, potentially with a specific theme.
|
|
691
|
+
"""
|
|
689
692
|
# Import runner locally
|
|
690
|
-
|
|
693
|
+
# We need to decide if start_api now *always* tries to use the integrated approach
|
|
694
|
+
# or if it still calls the API-only runner when create_ui=False.
|
|
695
|
+
# Let's assume it uses the integrated approach starter if create_ui=True
|
|
696
|
+
# and the API-only starter (FlockAPI) if create_ui=False.
|
|
691
697
|
|
|
692
|
-
|
|
698
|
+
if create_ui:
|
|
699
|
+
# Use the integrated server approach
|
|
700
|
+
try:
|
|
701
|
+
# We need a function similar to start_flock_api but for the integrated app
|
|
702
|
+
# Let's assume it exists in webapp.run for now, called start_integrated_server
|
|
703
|
+
from flock.webapp.run import start_integrated_server
|
|
704
|
+
|
|
705
|
+
start_integrated_server(
|
|
706
|
+
flock_instance=self,
|
|
707
|
+
host=host,
|
|
708
|
+
port=port,
|
|
709
|
+
server_name=server_name,
|
|
710
|
+
theme_name=ui_theme,
|
|
711
|
+
)
|
|
712
|
+
except ImportError:
|
|
713
|
+
# Log error - cannot start integrated UI
|
|
714
|
+
from flock.core.logging.logging import get_logger
|
|
715
|
+
|
|
716
|
+
logger = get_logger("flock.core")
|
|
717
|
+
logger.error(
|
|
718
|
+
"Cannot start integrated UI: Required components (e.g., flock.webapp.run.start_integrated_server) not found."
|
|
719
|
+
)
|
|
720
|
+
except Exception as e:
|
|
721
|
+
from flock.core.logging.logging import get_logger
|
|
722
|
+
|
|
723
|
+
logger = get_logger("flock.core")
|
|
724
|
+
logger.error(
|
|
725
|
+
f"Failed to start integrated UI server: {e}", exc_info=True
|
|
726
|
+
)
|
|
727
|
+
else:
|
|
728
|
+
# Use the API-only server approach
|
|
729
|
+
from flock.core.api.runner import start_flock_api
|
|
730
|
+
|
|
731
|
+
start_flock_api(
|
|
732
|
+
flock=self,
|
|
733
|
+
host=host,
|
|
734
|
+
port=port,
|
|
735
|
+
server_name=server_name,
|
|
736
|
+
create_ui=False, # Explicitly false for API only runner
|
|
737
|
+
)
|
|
693
738
|
|
|
694
739
|
# --- CLI Starter ---
|
|
695
740
|
def start_cli(
|
flock/themes/alabaster.toml
CHANGED
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
panel_style = "on #f7f7f7"
|
|
3
3
|
table_header_style = "bold #000000 on #bfdbfe"
|
|
4
4
|
table_title_style = "bold #000000"
|
|
5
|
-
table_border_style = "#007acc"
|
|
6
|
-
panel_border_style = "#007acc"
|
|
5
|
+
table_border_style = " #007acc"
|
|
6
|
+
panel_border_style = " #007acc"
|
|
7
7
|
column_output = "bold #000000"
|
|
8
|
-
column_value = "#000000"
|
|
9
|
-
bright_black = "#777777"
|
|
10
|
-
bright_blue = "#007acc"
|
|
11
|
-
bright_cyan = "#00aacb"
|
|
12
|
-
bright_green = "#60cb00"
|
|
13
|
-
bright_magenta = "#e64ce6"
|
|
14
|
-
bright_red = "#f05050"
|
|
15
|
-
bright_white = "#f7f7f7"
|
|
16
|
-
bright_yellow = "#ffbc5d"
|
|
17
|
-
normal_black = "#000000"
|
|
18
|
-
normal_blue = "#325cc0"
|
|
19
|
-
normal_cyan = "#0083b2"
|
|
20
|
-
normal_green = "#448c27"
|
|
21
|
-
normal_magenta = "#7a3e9d"
|
|
22
|
-
normal_red = "#aa3731"
|
|
23
|
-
normal_white = "#f7f7f7"
|
|
24
|
-
normal_yellow = "#cb9000"
|
|
25
|
-
cursor_cursor = "#007acc"
|
|
26
|
-
cursor_text = "#bfdbfe"
|
|
8
|
+
column_value = " #000000"
|
|
9
|
+
bright_black = " #777777"
|
|
10
|
+
bright_blue = " #007acc"
|
|
11
|
+
bright_cyan = " #00aacb"
|
|
12
|
+
bright_green = " #60cb00"
|
|
13
|
+
bright_magenta = " #e64ce6"
|
|
14
|
+
bright_red = " #f05050"
|
|
15
|
+
bright_white = " #f7f7f7"
|
|
16
|
+
bright_yellow = " #ffbc5d"
|
|
17
|
+
normal_black = " #000000"
|
|
18
|
+
normal_blue = " #325cc0"
|
|
19
|
+
normal_cyan = " #0083b2"
|
|
20
|
+
normal_green = " #448c27"
|
|
21
|
+
normal_magenta = " #7a3e9d"
|
|
22
|
+
normal_red = " #aa3731"
|
|
23
|
+
normal_white = " #f7f7f7"
|
|
24
|
+
normal_yellow = " #cb9000"
|
|
25
|
+
cursor_cursor = " #007acc"
|
|
26
|
+
cursor_text = " #bfdbfe"
|
|
27
27
|
table_show_lines = false
|
|
28
28
|
table_box = "MINIMAL"
|
|
29
29
|
panel_padding = [ 1, 1,]
|
|
@@ -45,33 +45,33 @@ table_caption_justify = "center"
|
|
|
45
45
|
table_highlight = false
|
|
46
46
|
|
|
47
47
|
[colors.bright]
|
|
48
|
-
black = "#777777"
|
|
49
|
-
blue = "#007acc"
|
|
50
|
-
cyan = "#00aacb"
|
|
51
|
-
green = "#60cb00"
|
|
52
|
-
magenta = "#e64ce6"
|
|
53
|
-
red = "#f05050"
|
|
54
|
-
white = "#f7f7f7"
|
|
55
|
-
yellow = "#ffbc5d"
|
|
48
|
+
black = " #777777"
|
|
49
|
+
blue = " #007acc"
|
|
50
|
+
cyan = " #00aacb"
|
|
51
|
+
green = " #60cb00"
|
|
52
|
+
magenta = " #e64ce6"
|
|
53
|
+
red = " #f05050"
|
|
54
|
+
white = " #f7f7f7"
|
|
55
|
+
yellow = " #ffbc5d"
|
|
56
56
|
|
|
57
57
|
[colors.cursor]
|
|
58
|
-
cursor = "#007acc"
|
|
59
|
-
text = "#bfdbfe"
|
|
58
|
+
cursor = " #007acc"
|
|
59
|
+
text = " #bfdbfe"
|
|
60
60
|
|
|
61
61
|
[colors.normal]
|
|
62
|
-
black = "#000000"
|
|
63
|
-
blue = "#325cc0"
|
|
64
|
-
cyan = "#0083b2"
|
|
65
|
-
green = "#448c27"
|
|
66
|
-
magenta = "#7a3e9d"
|
|
67
|
-
red = "#aa3731"
|
|
68
|
-
white = "#f7f7f7"
|
|
69
|
-
yellow = "#cb9000"
|
|
62
|
+
black = " #000000"
|
|
63
|
+
blue = " #325cc0"
|
|
64
|
+
cyan = " #0083b2"
|
|
65
|
+
green = " #448c27"
|
|
66
|
+
magenta = " #7a3e9d"
|
|
67
|
+
red = " #aa3731"
|
|
68
|
+
white = " #f7f7f7"
|
|
69
|
+
yellow = " #cb9000"
|
|
70
70
|
|
|
71
71
|
[colors.primary]
|
|
72
|
-
background = "#f7f7f7"
|
|
73
|
-
foreground = "#000000"
|
|
72
|
+
background = " #f7f7f7"
|
|
73
|
+
foreground = " #000000"
|
|
74
74
|
|
|
75
75
|
[colors.selection]
|
|
76
|
-
background = "#bfdbfe"
|
|
77
|
-
text = "#000000"
|
|
76
|
+
background = " #bfdbfe"
|
|
77
|
+
text = " #000000"
|
flock/themes/guezwhoz.toml
CHANGED
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
panel_style = "on #1c1c1c"
|
|
3
3
|
table_header_style = "bold #eeeeee on #005f5f"
|
|
4
4
|
table_title_style = "bold #d0d0d0"
|
|
5
|
-
table_border_style = "#87afd7"
|
|
6
|
-
panel_border_style = "#87afd7"
|
|
5
|
+
table_border_style = " #87afd7"
|
|
6
|
+
panel_border_style = " #87afd7"
|
|
7
7
|
column_output = "bold #d0d0d0"
|
|
8
|
-
column_value = "#d0d0d0"
|
|
9
|
-
bright_black = "#8a8a8a"
|
|
10
|
-
bright_blue = "#87afd7"
|
|
11
|
-
bright_cyan = "#87d7d7"
|
|
12
|
-
bright_green = "#afd7af"
|
|
13
|
-
bright_magenta = "#afafd7"
|
|
14
|
-
bright_red = "#d75f5f"
|
|
15
|
-
bright_white = "#dadada"
|
|
16
|
-
bright_yellow = "#d7d7af"
|
|
17
|
-
normal_black = "#080808"
|
|
18
|
-
normal_blue = "#5fafd7"
|
|
19
|
-
normal_cyan = "#5fd7d7"
|
|
20
|
-
normal_green = "#87d7af"
|
|
21
|
-
normal_magenta = "#afafff"
|
|
22
|
-
normal_red = "#ff5f5f"
|
|
23
|
-
normal_white = "#dadada"
|
|
24
|
-
normal_yellow = "#d7d787"
|
|
25
|
-
cursor_cursor = "#eeeeee"
|
|
26
|
-
cursor_text = "#eeeeee"
|
|
8
|
+
column_value = " #d0d0d0"
|
|
9
|
+
bright_black = " #8a8a8a"
|
|
10
|
+
bright_blue = " #87afd7"
|
|
11
|
+
bright_cyan = " #87d7d7"
|
|
12
|
+
bright_green = " #afd7af"
|
|
13
|
+
bright_magenta = " #afafd7"
|
|
14
|
+
bright_red = " #d75f5f"
|
|
15
|
+
bright_white = " #dadada"
|
|
16
|
+
bright_yellow = " #d7d7af"
|
|
17
|
+
normal_black = " #080808"
|
|
18
|
+
normal_blue = " #5fafd7"
|
|
19
|
+
normal_cyan = " #5fd7d7"
|
|
20
|
+
normal_green = " #87d7af"
|
|
21
|
+
normal_magenta = " #afafff"
|
|
22
|
+
normal_red = " #ff5f5f"
|
|
23
|
+
normal_white = " #dadada"
|
|
24
|
+
normal_yellow = " #d7d787"
|
|
25
|
+
cursor_cursor = " #eeeeee"
|
|
26
|
+
cursor_text = " #eeeeee"
|
|
27
27
|
table_show_lines = false
|
|
28
28
|
table_box = "ROUNDED"
|
|
29
29
|
panel_padding = [ 1, 1,]
|
|
@@ -45,33 +45,33 @@ table_caption_justify = "center"
|
|
|
45
45
|
table_highlight = false
|
|
46
46
|
|
|
47
47
|
[colors.bright]
|
|
48
|
-
black = "#8a8a8a"
|
|
49
|
-
blue = "#87afd7"
|
|
50
|
-
cyan = "#87d7d7"
|
|
51
|
-
green = "#afd7af"
|
|
52
|
-
magenta = "#afafd7"
|
|
53
|
-
red = "#d75f5f"
|
|
54
|
-
white = "#dadada"
|
|
55
|
-
yellow = "#d7d7af"
|
|
48
|
+
black = " #8a8a8a"
|
|
49
|
+
blue = " #87afd7"
|
|
50
|
+
cyan = " #87d7d7"
|
|
51
|
+
green = " #afd7af"
|
|
52
|
+
magenta = " #afafd7"
|
|
53
|
+
red = " #d75f5f"
|
|
54
|
+
white = " #dadada"
|
|
55
|
+
yellow = " #d7d7af"
|
|
56
56
|
|
|
57
57
|
[colors.cursor]
|
|
58
|
-
cursor = "#eeeeee"
|
|
59
|
-
text = "#eeeeee"
|
|
58
|
+
cursor = " #eeeeee"
|
|
59
|
+
text = " #eeeeee"
|
|
60
60
|
|
|
61
61
|
[colors.normal]
|
|
62
|
-
black = "#080808"
|
|
63
|
-
blue = "#5fafd7"
|
|
64
|
-
cyan = "#5fd7d7"
|
|
65
|
-
green = "#87d7af"
|
|
66
|
-
magenta = "#afafff"
|
|
67
|
-
red = "#ff5f5f"
|
|
68
|
-
white = "#dadada"
|
|
69
|
-
yellow = "#d7d787"
|
|
62
|
+
black = " #080808"
|
|
63
|
+
blue = " #5fafd7"
|
|
64
|
+
cyan = " #5fd7d7"
|
|
65
|
+
green = " #87d7af"
|
|
66
|
+
magenta = " #afafff"
|
|
67
|
+
red = " #ff5f5f"
|
|
68
|
+
white = " #dadada"
|
|
69
|
+
yellow = " #d7d787"
|
|
70
70
|
|
|
71
71
|
[colors.primary]
|
|
72
|
-
background = "#1c1c1c"
|
|
73
|
-
foreground = "#d0d0d0"
|
|
72
|
+
background = " #1c1c1c"
|
|
73
|
+
foreground = " #d0d0d0"
|
|
74
74
|
|
|
75
75
|
[colors.selection]
|
|
76
|
-
background = "#005f5f"
|
|
77
|
-
text = "#eeeeee"
|
|
76
|
+
background = " #005f5f"
|
|
77
|
+
text = " #eeeeee"
|