zrb 1.7.3__py3-none-any.whl → 1.7.5__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.
- zrb/__init__.py +1 -1
- zrb/builtin/llm/tool/file.py +15 -23
- zrb/runner/cli.py +1 -2
- zrb/runner/web_app.py +3 -2
- zrb/runner/web_config.py +189 -0
- zrb/runner/web_route/error_page/serve_default_404.py +1 -1
- zrb/runner/web_route/home_page/home_page_route.py +1 -1
- zrb/runner/web_route/login_api_route.py +1 -1
- zrb/runner/web_route/login_page/login_page_route.py +1 -1
- zrb/runner/web_route/logout_api_route.py +1 -1
- zrb/runner/web_route/logout_page/logout_page_route.py +1 -1
- zrb/runner/web_route/node_page/node_page_route.py +1 -1
- zrb/runner/web_route/refresh_token_api_route.py +1 -1
- zrb/runner/web_route/static/static_route.py +1 -1
- zrb/runner/web_route/task_input_api_route.py +1 -1
- zrb/runner/web_route/task_session_api_route.py +1 -1
- zrb/runner/web_util/cookie.py +1 -1
- zrb/runner/web_util/token.py +1 -1
- zrb/runner/web_util/user.py +1 -1
- {zrb-1.7.3.dist-info → zrb-1.7.5.dist-info}/METADATA +1 -1
- {zrb-1.7.3.dist-info → zrb-1.7.5.dist-info}/RECORD +23 -24
- zrb/runner/web_config/config.py +0 -91
- zrb/runner/web_config/config_factory.py +0 -15
- {zrb-1.7.3.dist-info → zrb-1.7.5.dist-info}/WHEEL +0 -0
- {zrb-1.7.3.dist-info → zrb-1.7.5.dist-info}/entry_points.txt +0 -0
zrb/__init__.py
CHANGED
@@ -35,7 +35,7 @@ from zrb.input.str_input import StrInput
|
|
35
35
|
from zrb.input.text_input import TextInput
|
36
36
|
from zrb.llm_config import llm_config
|
37
37
|
from zrb.runner.cli import cli
|
38
|
-
from zrb.runner.web_config
|
38
|
+
from zrb.runner.web_config import web_config
|
39
39
|
from zrb.runner.web_schema.user import User
|
40
40
|
from zrb.session.session import Session
|
41
41
|
from zrb.task.any_task import AnyTask
|
zrb/builtin/llm/tool/file.py
CHANGED
@@ -201,11 +201,11 @@ def read_from_file(
|
|
201
201
|
Raises:
|
202
202
|
Exception: If an error occurs.
|
203
203
|
"""
|
204
|
+
abs_path = os.path.abspath(os.path.expanduser(path))
|
205
|
+
# Check if file exists
|
206
|
+
if not os.path.exists(abs_path):
|
207
|
+
raise FileNotFoundError(f"File not found: {path}")
|
204
208
|
try:
|
205
|
-
abs_path = os.path.abspath(os.path.expanduser(path))
|
206
|
-
# Check if file exists
|
207
|
-
if not os.path.exists(abs_path):
|
208
|
-
return json.dumps({"error": f"File {path} does not exist"})
|
209
209
|
content = read_file_with_line_numbers(abs_path)
|
210
210
|
lines = content.splitlines()
|
211
211
|
total_lines = len(lines)
|
@@ -402,24 +402,15 @@ def apply_diff(
|
|
402
402
|
Raises:
|
403
403
|
Exception: If an error occurs.
|
404
404
|
"""
|
405
|
+
abs_path = os.path.abspath(os.path.expanduser(path))
|
406
|
+
if not os.path.exists(abs_path):
|
407
|
+
raise FileNotFoundError(f"File not found: {path}")
|
405
408
|
try:
|
406
|
-
abs_path = os.path.abspath(os.path.expanduser(path))
|
407
|
-
if not os.path.exists(abs_path):
|
408
|
-
return json.dumps(
|
409
|
-
{"success": False, "path": path, "error": f"File not found at {path}"}
|
410
|
-
)
|
411
409
|
content = read_file(abs_path)
|
412
410
|
lines = content.splitlines()
|
413
411
|
if start_line < 1 or end_line > len(lines) or start_line > end_line:
|
414
|
-
|
415
|
-
{
|
416
|
-
"success": False,
|
417
|
-
"path": path,
|
418
|
-
"error": (
|
419
|
-
f"Invalid line range {start_line}-{end_line} "
|
420
|
-
f"for file with {len(lines)} lines."
|
421
|
-
),
|
422
|
-
}
|
412
|
+
raise ValueError(
|
413
|
+
f"Invalid line range {start_line}-{end_line} for file with {len(lines)} lines"
|
423
414
|
)
|
424
415
|
original_content = "\n".join(lines[start_line - 1 : end_line])
|
425
416
|
if original_content != search_content:
|
@@ -465,9 +456,8 @@ async def analyze_file(ctx: AnyContext, path: str, query: str) -> str:
|
|
465
456
|
"""
|
466
457
|
abs_path = os.path.abspath(os.path.expanduser(path))
|
467
458
|
if not os.path.exists(abs_path):
|
468
|
-
|
469
|
-
|
470
|
-
)
|
459
|
+
raise FileNotFoundError(f"File not found: {path}")
|
460
|
+
file_content = read_file(abs_path)
|
471
461
|
_analyze_file = create_sub_agent_tool(
|
472
462
|
tool_name="analyze_file",
|
473
463
|
tool_description="analyze file with LLM capability",
|
@@ -484,10 +474,12 @@ async def analyze_file(ctx: AnyContext, path: str, query: str) -> str:
|
|
484
474
|
ctx,
|
485
475
|
"\n".join(
|
486
476
|
[
|
487
|
-
|
488
|
-
abs_path,
|
477
|
+
file_content,
|
489
478
|
"# Instruction",
|
490
479
|
query,
|
480
|
+
"# File path",
|
481
|
+
abs_path,
|
482
|
+
"# File content",
|
491
483
|
]
|
492
484
|
),
|
493
485
|
)
|
zrb/runner/cli.py
CHANGED
@@ -8,7 +8,7 @@ from zrb.group.any_group import AnyGroup
|
|
8
8
|
from zrb.group.group import Group
|
9
9
|
from zrb.runner.common_util import get_run_kwargs
|
10
10
|
from zrb.runner.web_app import create_web_app
|
11
|
-
from zrb.runner.web_config
|
11
|
+
from zrb.runner.web_config import web_config
|
12
12
|
from zrb.session.session import Session
|
13
13
|
from zrb.session_state_logger.session_state_logger_factory import session_state_logger
|
14
14
|
from zrb.task.any_task import AnyTask
|
@@ -19,7 +19,6 @@ from zrb.util.cli.style import (
|
|
19
19
|
stylize_section_header,
|
20
20
|
)
|
21
21
|
from zrb.util.group import extract_node_from_args, get_non_empty_subgroups, get_subtasks
|
22
|
-
from zrb.util.init_path import get_init_path_list
|
23
22
|
from zrb.util.string.conversion import double_quote
|
24
23
|
|
25
24
|
|
zrb/runner/web_app.py
CHANGED
@@ -4,7 +4,7 @@ from typing import TYPE_CHECKING
|
|
4
4
|
|
5
5
|
from zrb.config import CFG
|
6
6
|
from zrb.group.any_group import AnyGroup
|
7
|
-
from zrb.runner.web_config
|
7
|
+
from zrb.runner.web_config import WebConfig
|
8
8
|
from zrb.runner.web_route.docs_route import serve_docs
|
9
9
|
from zrb.runner.web_route.error_page.serve_default_404 import serve_default_404
|
10
10
|
from zrb.runner.web_route.home_page.home_page_route import serve_home_page
|
@@ -37,8 +37,9 @@ def create_web_app(
|
|
37
37
|
|
38
38
|
@asynccontextmanager
|
39
39
|
async def lifespan(app: FastAPI):
|
40
|
+
capitalized_group_name = CFG.ROOT_GROUP_NAME.capitalize()
|
40
41
|
for line in CFG.BANNER.split("\n") + [
|
41
|
-
f"
|
42
|
+
f"{capitalized_group_name} Server running on http://localhost:{web_config.port}"
|
42
43
|
]:
|
43
44
|
print(line, file=sys.stderr)
|
44
45
|
yield
|
zrb/runner/web_config.py
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
from typing import Callable
|
2
|
+
|
3
|
+
from zrb.config import CFG
|
4
|
+
from zrb.runner.web_schema.user import User
|
5
|
+
from zrb.task.any_task import AnyTask
|
6
|
+
|
7
|
+
|
8
|
+
class WebConfig:
|
9
|
+
def __init__(
|
10
|
+
self,
|
11
|
+
port: int | None = None,
|
12
|
+
secret_key: str | None = None,
|
13
|
+
access_token_expire_minutes: int | None = None,
|
14
|
+
refresh_token_expire_minutes: int | None = None,
|
15
|
+
access_token_cookie_name: str | None = None,
|
16
|
+
refresh_token_cookie_name: str | None = None,
|
17
|
+
enable_auth: bool | None = None,
|
18
|
+
super_admin_username: str | None = None,
|
19
|
+
super_admin_password: str | None = None,
|
20
|
+
guest_username: str | None = None,
|
21
|
+
guest_accessible_tasks: list[AnyTask | str] = [],
|
22
|
+
find_user_by_username: Callable[[str], User | None] | None = None,
|
23
|
+
):
|
24
|
+
self._port = port
|
25
|
+
self._secret_key = secret_key
|
26
|
+
self._access_token_expire_minutes = access_token_expire_minutes
|
27
|
+
self._refresh_token_expire_minutes = refresh_token_expire_minutes
|
28
|
+
self._access_token_cookie_name = access_token_cookie_name
|
29
|
+
self._refresh_token_cookie_name = refresh_token_cookie_name
|
30
|
+
self._enable_auth = enable_auth
|
31
|
+
self._super_admin_username = super_admin_username
|
32
|
+
self._super_admin_password = super_admin_password
|
33
|
+
self._guest_username = guest_username
|
34
|
+
self._user_list = []
|
35
|
+
self._guest_accessible_tasks = guest_accessible_tasks
|
36
|
+
self._find_user_by_username = find_user_by_username
|
37
|
+
|
38
|
+
@property
|
39
|
+
def port(self) -> int:
|
40
|
+
if self._port is not None:
|
41
|
+
return self._port
|
42
|
+
return CFG.WEB_HTTP_PORT
|
43
|
+
|
44
|
+
@property
|
45
|
+
def secret_key(self) -> str:
|
46
|
+
if self._secret_key is not None:
|
47
|
+
return self._secret_key
|
48
|
+
return CFG.WEB_SECRET_KEY
|
49
|
+
|
50
|
+
@property
|
51
|
+
def access_token_expire_minutes(self) -> int:
|
52
|
+
if self._access_token_expire_minutes is not None:
|
53
|
+
return self._access_token_expire_minutes
|
54
|
+
return CFG.WEB_AUTH_ACCESS_TOKEN_EXPIRE_MINUTES
|
55
|
+
|
56
|
+
@property
|
57
|
+
def refresh_token_expire_minutes(self) -> int:
|
58
|
+
if self._refresh_token_expire_minutes is not None:
|
59
|
+
return self._refresh_token_expire_minutes
|
60
|
+
return CFG.WEB_AUTH_REFRESH_TOKEN_EXPIRE_MINUTES
|
61
|
+
|
62
|
+
@property
|
63
|
+
def access_token_cookie_name(self) -> str:
|
64
|
+
if self._access_token_cookie_name is not None:
|
65
|
+
return self._access_token_cookie_name
|
66
|
+
return CFG.WEB_ACCESS_TOKEN_COOKIE_NAME
|
67
|
+
|
68
|
+
@property
|
69
|
+
def refresh_token_cookie_name(self) -> str:
|
70
|
+
if self._refresh_token_cookie_name is not None:
|
71
|
+
return self._refresh_token_cookie_name
|
72
|
+
return CFG.WEB_REFRESH_TOKEN_COOKIE_NAME
|
73
|
+
|
74
|
+
@property
|
75
|
+
def enable_auth(self) -> bool:
|
76
|
+
if self._enable_auth is not None:
|
77
|
+
return self._enable_auth
|
78
|
+
return CFG.WEB_ENABLE_AUTH
|
79
|
+
|
80
|
+
@property
|
81
|
+
def super_admin_username(self) -> str:
|
82
|
+
if self._super_admin_username is not None:
|
83
|
+
return self._super_admin_username
|
84
|
+
return CFG.WEB_SUPER_ADMIN_USERNAME
|
85
|
+
|
86
|
+
@property
|
87
|
+
def super_admin_password(self) -> str:
|
88
|
+
if self._super_admin_password is not None:
|
89
|
+
return self._super_admin_password
|
90
|
+
return CFG.WEB_SUPER_ADMIN_PASSWORD
|
91
|
+
|
92
|
+
@property
|
93
|
+
def guest_username(self) -> str:
|
94
|
+
if self._guest_username is not None:
|
95
|
+
return self._guest_username
|
96
|
+
return CFG.WEB_GUEST_USERNAME
|
97
|
+
|
98
|
+
@property
|
99
|
+
def guest_accessible_tasks(self) -> list[AnyTask | str]:
|
100
|
+
return self._guest_accessible_tasks
|
101
|
+
|
102
|
+
@property
|
103
|
+
def default_user(self) -> User:
|
104
|
+
if self.enable_auth:
|
105
|
+
return User(
|
106
|
+
username=self.guest_username,
|
107
|
+
password="",
|
108
|
+
is_guest=True,
|
109
|
+
accessible_tasks=self.guest_accessible_tasks,
|
110
|
+
)
|
111
|
+
return User(
|
112
|
+
username=self.guest_username,
|
113
|
+
password="",
|
114
|
+
is_guest=True,
|
115
|
+
is_super_admin=True,
|
116
|
+
)
|
117
|
+
|
118
|
+
@property
|
119
|
+
def super_admin(self) -> User:
|
120
|
+
return User(
|
121
|
+
username=self.super_admin_username,
|
122
|
+
password=self.super_admin_password,
|
123
|
+
is_super_admin=True,
|
124
|
+
)
|
125
|
+
|
126
|
+
@property
|
127
|
+
def user_list(self) -> list[User]:
|
128
|
+
if not self.enable_auth:
|
129
|
+
return [self.default_user]
|
130
|
+
return self._user_list + [self.super_admin, self.default_user]
|
131
|
+
|
132
|
+
def set_port(self, port: int):
|
133
|
+
self._port = port
|
134
|
+
|
135
|
+
def set_secret_key(self, secret_key: str):
|
136
|
+
self._secret_key = secret_key
|
137
|
+
|
138
|
+
def set_access_token_expire_minutes(self, minutes: int):
|
139
|
+
self._access_token_expire_minutes = minutes
|
140
|
+
|
141
|
+
def set_refresh_token_expire_minutes(self, minutes: int):
|
142
|
+
self._refresh_token_expire_minutes = minutes
|
143
|
+
|
144
|
+
def set_access_token_cookie_name(self, name: str):
|
145
|
+
self._access_token_cookie_name = name
|
146
|
+
|
147
|
+
def set_refresh_token_cookie_name(self, name: str):
|
148
|
+
self._refresh_token_cookie_name = name
|
149
|
+
|
150
|
+
def set_enable_auth(self, enable: bool):
|
151
|
+
self._enable_auth = enable
|
152
|
+
|
153
|
+
def set_super_admin_username(self, username: str):
|
154
|
+
self._super_admin_username = username
|
155
|
+
|
156
|
+
def set_super_admin_password(self, password: str):
|
157
|
+
self._super_admin_password = password
|
158
|
+
|
159
|
+
def set_guest_username(self, username: str):
|
160
|
+
self._guest_username = username
|
161
|
+
|
162
|
+
def set_guest_accessible_tasks(self, tasks: list[AnyTask | str]):
|
163
|
+
self._guest_accessible_tasks = tasks
|
164
|
+
|
165
|
+
def set_find_user_by_username(
|
166
|
+
self, find_user_by_username: Callable[[str], User | None]
|
167
|
+
):
|
168
|
+
self._find_user_by_username = find_user_by_username
|
169
|
+
|
170
|
+
def append_user(self, user: User):
|
171
|
+
duplicates = [
|
172
|
+
existing_user
|
173
|
+
for existing_user in self.user_list
|
174
|
+
if existing_user.username == user.username
|
175
|
+
]
|
176
|
+
if len(duplicates) > 0:
|
177
|
+
raise ValueError(f"User already exists {user.username}")
|
178
|
+
self._user_list.append(user)
|
179
|
+
|
180
|
+
def find_user_by_username(self, username: str) -> User | None:
|
181
|
+
user = None
|
182
|
+
if self._find_user_by_username is not None:
|
183
|
+
user = self._find_user_by_username(username)
|
184
|
+
if user is None:
|
185
|
+
user = next((u for u in self.user_list if u.username == username), None)
|
186
|
+
return user
|
187
|
+
|
188
|
+
|
189
|
+
web_config = WebConfig()
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from typing import TYPE_CHECKING
|
2
2
|
|
3
3
|
from zrb.group.any_group import AnyGroup
|
4
|
-
from zrb.runner.web_config
|
4
|
+
from zrb.runner.web_config import WebConfig
|
5
5
|
from zrb.runner.web_route.error_page.show_error_page import show_error_page
|
6
6
|
from zrb.runner.web_util.user import get_user_from_request
|
7
7
|
|
@@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
|
|
3
3
|
|
4
4
|
from zrb.config import CFG
|
5
5
|
from zrb.group.any_group import AnyGroup
|
6
|
-
from zrb.runner.web_config
|
6
|
+
from zrb.runner.web_config import WebConfig
|
7
7
|
from zrb.runner.web_util.html import (
|
8
8
|
get_html_auth_link,
|
9
9
|
get_html_subgroup_info,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import TYPE_CHECKING, Annotated
|
2
2
|
|
3
|
-
from zrb.runner.web_config
|
3
|
+
from zrb.runner.web_config import WebConfig
|
4
4
|
from zrb.runner.web_util.cookie import set_auth_cookie
|
5
5
|
from zrb.runner.web_util.token import generate_tokens_by_credentials
|
6
6
|
|
@@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
|
|
3
3
|
|
4
4
|
from zrb.config import CFG
|
5
5
|
from zrb.group.any_group import AnyGroup
|
6
|
-
from zrb.runner.web_config
|
6
|
+
from zrb.runner.web_config import WebConfig
|
7
7
|
from zrb.runner.web_util.html import get_html_auth_link
|
8
8
|
from zrb.runner.web_util.user import get_user_from_request
|
9
9
|
from zrb.util.file import read_file
|
@@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
|
|
3
3
|
|
4
4
|
from zrb.config import CFG
|
5
5
|
from zrb.group.any_group import AnyGroup
|
6
|
-
from zrb.runner.web_config
|
6
|
+
from zrb.runner.web_config import WebConfig
|
7
7
|
from zrb.runner.web_util.html import get_html_auth_link
|
8
8
|
from zrb.runner.web_util.user import get_user_from_request
|
9
9
|
from zrb.util.file import read_file
|
@@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
|
|
3
3
|
|
4
4
|
from zrb.context.shared_context import SharedContext
|
5
5
|
from zrb.group.any_group import AnyGroup
|
6
|
-
from zrb.runner.web_config
|
6
|
+
from zrb.runner.web_config import WebConfig
|
7
7
|
from zrb.runner.web_route.error_page.show_error_page import show_error_page
|
8
8
|
from zrb.runner.web_route.node_page.group.show_group_page import show_group_page
|
9
9
|
from zrb.runner.web_route.node_page.task.show_task_page import show_task_page
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import TYPE_CHECKING
|
2
2
|
|
3
|
-
from zrb.runner.web_config
|
3
|
+
from zrb.runner.web_config import WebConfig
|
4
4
|
from zrb.runner.web_schema.token import RefreshTokenRequest
|
5
5
|
from zrb.runner.web_util.cookie import set_auth_cookie
|
6
6
|
from zrb.runner.web_util.token import regenerate_tokens
|
@@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
|
|
3
3
|
|
4
4
|
from zrb.group.any_group import AnyGroup
|
5
5
|
from zrb.runner.common_util import get_run_kwargs
|
6
|
-
from zrb.runner.web_config
|
6
|
+
from zrb.runner.web_config import WebConfig
|
7
7
|
from zrb.runner.web_util.user import get_user_from_request
|
8
8
|
from zrb.task.any_task import AnyTask
|
9
9
|
from zrb.util.group import NodeNotFoundError, extract_node_from_args
|
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any
|
|
5
5
|
|
6
6
|
from zrb.context.shared_context import SharedContext
|
7
7
|
from zrb.group.any_group import AnyGroup
|
8
|
-
from zrb.runner.web_config
|
8
|
+
from zrb.runner.web_config import WebConfig
|
9
9
|
from zrb.runner.web_schema.session import NewSessionResponse
|
10
10
|
from zrb.runner.web_util.user import get_user_from_request
|
11
11
|
from zrb.session.session import Session
|
zrb/runner/web_util/cookie.py
CHANGED
zrb/runner/web_util/token.py
CHANGED
zrb/runner/web_util/user.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
zrb/__init__.py,sha256=
|
1
|
+
zrb/__init__.py,sha256=auzZHgBCBZLIp24JWIbLjjigOpnUv01DMdjyOsLnbGw,3088
|
2
2
|
zrb/__main__.py,sha256=Kr_AkgmwBEycQcPVkZmrNh4hp2g62G-7ZXeOhJg0Qis,2603
|
3
3
|
zrb/attr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
zrb/attr/type.py,sha256=4TV5gPYMMrKh5V-yB6iRYKCbsXAH_AvGXMsjxKLHcUs,568
|
@@ -17,7 +17,7 @@ zrb/builtin/llm/previous-session.js,sha256=xMKZvJoAbrwiyHS0OoPrWuaKxWYLoyR5sgueP
|
|
17
17
|
zrb/builtin/llm/tool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
18
|
zrb/builtin/llm/tool/api.py,sha256=yR9I0ZsI96OeQl9pgwORMASVuXsAL0a89D_iPS4C8Dc,1699
|
19
19
|
zrb/builtin/llm/tool/cli.py,sha256=_CNEmEc6K2Z0i9ppYeM7jGpqaEdT3uxaWQatmxP3jKE,858
|
20
|
-
zrb/builtin/llm/tool/file.py,sha256=
|
20
|
+
zrb/builtin/llm/tool/file.py,sha256=nCY74VtruTr9LgAq5mroSr4zF0g6LA_uXMI5sh9c8OE,17909
|
21
21
|
zrb/builtin/llm/tool/rag.py,sha256=VUyRBvnSeDf8T_lKY--c5HVTfccNgiEJU3QpwssJF8E,8182
|
22
22
|
zrb/builtin/llm/tool/sub_agent.py,sha256=7n14KzUSFe5Bjf2lpluKlLyL-b1Mehj2QekkuDzo0ik,5091
|
23
23
|
zrb/builtin/llm/tool/web.py,sha256=pXRLhcB_Y6z-2w4C4WezH8n-pg3PSMgt_bwn3aaqi6g,5479
|
@@ -247,32 +247,31 @@ zrb/input/str_input.py,sha256=NevZHX9rf1g8eMatPyy-kUX3DglrVAQpzvVpKAzf7bA,81
|
|
247
247
|
zrb/input/text_input.py,sha256=6T3MngWdUs0u0ZVs5Dl11w5KS7nN1RkgrIR_zKumzPM,3695
|
248
248
|
zrb/llm_config.py,sha256=h3LyjoOunc-2FxOOyCwM6Xcll3iXDykvvbV6xob-iB8,12244
|
249
249
|
zrb/runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
250
|
-
zrb/runner/cli.py,sha256=
|
250
|
+
zrb/runner/cli.py,sha256=6XIkgnmoH5HFDJzezbeWaqGBH5x-cv8ccWWgeCfura0,6969
|
251
251
|
zrb/runner/common_util.py,sha256=JDMcwvQ8cxnv9kQrAoKVLA40Q1omfv-u5_d5MvvwHeE,1373
|
252
|
-
zrb/runner/web_app.py,sha256=
|
253
|
-
zrb/runner/web_config
|
254
|
-
zrb/runner/web_config/config_factory.py,sha256=GIvAwQKY_jkAb_IVt179KvphqHPY7gfBiQrZmELVQdQ,636
|
252
|
+
zrb/runner/web_app.py,sha256=XWqA-MEk5ORD0UeIxeySJvWqOb1KQjCS3tu6aXv5sv8,2700
|
253
|
+
zrb/runner/web_config.py,sha256=uayxLUK_VlHhKVsccQFGQQAbFpIfaGzA_PsYV5TqxRg,6348
|
255
254
|
zrb/runner/web_route/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
256
255
|
zrb/runner/web_route/docs_route.py,sha256=06QfDITvXTRphZWI0qlxbDfnB-44_eZpE-xotwKsvY8,514
|
257
|
-
zrb/runner/web_route/error_page/serve_default_404.py,sha256=
|
256
|
+
zrb/runner/web_route/error_page/serve_default_404.py,sha256=0e5TDg7uQMZ_4uOsVyxtDLrI8pgcNhG8ZhWb3qhFgMk,1049
|
258
257
|
zrb/runner/web_route/error_page/show_error_page.py,sha256=8U3jbBYVJIdYjR1AVCBfrmfLQ4dE4MbHwA3AovtIab4,1275
|
259
258
|
zrb/runner/web_route/error_page/view.html,sha256=h58zKnB170h2BTczBtD8CoECEEdXpojWMBbL_KwS4yU,1204
|
260
259
|
zrb/runner/web_route/home_page/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
261
|
-
zrb/runner/web_route/home_page/home_page_route.py,sha256=
|
260
|
+
zrb/runner/web_route/home_page/home_page_route.py,sha256=5f2vH_UdnYY_yWCkTT4xkfW4N1ojiB-oJe8IhTuOExY,2549
|
262
261
|
zrb/runner/web_route/home_page/view.html,sha256=oWvirSGh74ABHHDPYboQueZI6_xMeMLDf5LZNLZO52k,422
|
263
|
-
zrb/runner/web_route/login_api_route.py,sha256=
|
264
|
-
zrb/runner/web_route/login_page/login_page_route.py,sha256=
|
262
|
+
zrb/runner/web_route/login_api_route.py,sha256=I8rE6IfRKHtIZ9G0RbS_3lWBOleH5krZCGLf2Otxxbo,1118
|
263
|
+
zrb/runner/web_route/login_page/login_page_route.py,sha256=6TT3YJRrl-brsxMT4d4_t8hO8VXg9fhqfiyBerWXDcU,1688
|
265
264
|
zrb/runner/web_route/login_page/view.html,sha256=KLHZWm5MxcGCOQjeq_JtXMTLvDX8JyphSBbK6DDrkg8,1139
|
266
|
-
zrb/runner/web_route/logout_api_route.py,sha256=
|
267
|
-
zrb/runner/web_route/logout_page/logout_page_route.py,sha256=
|
265
|
+
zrb/runner/web_route/logout_api_route.py,sha256=giPg7l4FvNSoFRUy42MBDKu9bZQnKGP7fxr2k5TW1l8,605
|
266
|
+
zrb/runner/web_route/logout_page/logout_page_route.py,sha256=33dbiLwbQuOpZQFAKPE4Ci5QtUufQGw2JFBWOskfTpM,1733
|
268
267
|
zrb/runner/web_route/logout_page/view.html,sha256=P1S9cv7eXMbwUZTPfP4sshBNI-m9nWhLP-mrmtoEHCs,742
|
269
268
|
zrb/runner/web_route/node_page/group/show_group_page.py,sha256=QL_AawyOdmMQLyhS3lIF5Ko0vhuDH02QN-93rjxCVTQ,1943
|
270
269
|
zrb/runner/web_route/node_page/group/view.html,sha256=3d1O2Vqc2PzxY-_xWt0Rsb2mG1yrvQ1TuaZXuYGolJw,566
|
271
|
-
zrb/runner/web_route/node_page/node_page_route.py,sha256=
|
270
|
+
zrb/runner/web_route/node_page/node_page_route.py,sha256=f37cyR1gV0eHrygY5_WmiXaGdWYTDMnimVtbQK1CJSA,2261
|
272
271
|
zrb/runner/web_route/node_page/task/partial/input.html,sha256=X2jy0q7TLQGP853exZMed0lqPezL3gzn6mnhB5QKfkc,178
|
273
272
|
zrb/runner/web_route/node_page/task/show_task_page.py,sha256=uZB7r5uQvG4OJwtGUu7DaTU-8qgSsVEf3nY8KaTE4TI,3344
|
274
273
|
zrb/runner/web_route/node_page/task/view.html,sha256=mp_DeoPXhWPypAbKSZ6iTIDVlTRUQzIuJfDExxOWBWc,2598
|
275
|
-
zrb/runner/web_route/refresh_token_api_route.py,sha256=
|
274
|
+
zrb/runner/web_route/refresh_token_api_route.py,sha256=V9ixg9bft7O2yp5vV5E_bwlWuHXB5CxwQcuQGDAJ5UQ,1471
|
276
275
|
zrb/runner/web_route/static/global_template.html,sha256=M00b1F-Y31vx6xQVGMVGkSJzCrQHWHe9zI_WSffS6Ck,999
|
277
276
|
zrb/runner/web_route/static/refresh-token.template.js,sha256=AWXhdxTMyuzBZoMftH7BjlU2CMIafwqWcbkZoiUEE50,1074
|
278
277
|
zrb/runner/web_route/static/resources/common.css,sha256=Kk8o0mcArKTOxPllR0ecaa0ZRVVig0CG0KvLXIqmGJo,517
|
@@ -285,16 +284,16 @@ zrb/runner/web_route/static/resources/session/common-util.js,sha256=t7_s5DXgMyZl
|
|
285
284
|
zrb/runner/web_route/static/resources/session/current-session.js,sha256=tzUdK7qJKnMBGlIaMZJIPc2oeL5csk1JTBbjTsjhrFA,7008
|
286
285
|
zrb/runner/web_route/static/resources/session/event.js,sha256=X5OlSHefK0SDB9VkFCRyBKE_Pb7mqM319mW9jRGoDOk,4716
|
287
286
|
zrb/runner/web_route/static/resources/session/past-session.js,sha256=RwGJYKSp75K8NZ-iZP58XppWgdzkiKFaiC5wgcMLxDo,5470
|
288
|
-
zrb/runner/web_route/static/static_route.py,sha256=
|
289
|
-
zrb/runner/web_route/task_input_api_route.py,sha256=
|
290
|
-
zrb/runner/web_route/task_session_api_route.py,sha256=
|
287
|
+
zrb/runner/web_route/static/static_route.py,sha256=glPzG5y1za7yX9p63R9K7KMT2pNw5HR5hdCDIwGdhSA,1532
|
288
|
+
zrb/runner/web_route/task_input_api_route.py,sha256=bowIoUkxF_GwvzVC3ueu2AotNJEwww0Usbela72ioBY,1744
|
289
|
+
zrb/runner/web_route/task_session_api_route.py,sha256=4CyIQD6zAMmwKAGfgJ467l70UHDn2BzeFl0Vl_39Lro,6001
|
291
290
|
zrb/runner/web_schema/session.py,sha256=NwbuS2Sv-CXO52nU-EZv8OMlD4vgCQWNeLC_dT0FK7I,92
|
292
291
|
zrb/runner/web_schema/token.py,sha256=Y7XCPS4WzrxslTDtHeLcPTTUpmWhPOkRcl4b99zrC7c,185
|
293
292
|
zrb/runner/web_schema/user.py,sha256=Kp10amg4i-f8Y-4czogv1YN7rwy0HdbePFiuovYu1ts,1018
|
294
|
-
zrb/runner/web_util/cookie.py,sha256=
|
293
|
+
zrb/runner/web_util/cookie.py,sha256=6k5HfyYoDjjEIXpjadehddq3i1Ji8ZQZS3rgtRiEUTQ,1047
|
295
294
|
zrb/runner/web_util/html.py,sha256=TuUHjX3eKCBzoa7TYdMt8dfWWy06idauyCaG66X4Ygc,1838
|
296
|
-
zrb/runner/web_util/token.py,sha256=
|
297
|
-
zrb/runner/web_util/user.py,sha256=
|
295
|
+
zrb/runner/web_util/token.py,sha256=F0JxxSzBR5EaykvtgoZvziUAHptq9gxvcmY9ieRzXWA,2577
|
296
|
+
zrb/runner/web_util/user.py,sha256=Jui1oKFe6jEEguuBoj8qe6mC1nXNmjVUOylUr2LHKh4,1960
|
298
297
|
zrb/session/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
299
298
|
zrb/session/any_session.py,sha256=x57mS15E-AfUjdVxwOWEzCBjW32zjer7WoeBw0guoDc,5266
|
300
299
|
zrb/session/session.py,sha256=aDaLV1tuE7PhcC17LMk6c7KiSs7yX7QXI9O-Z4MMZO8,9967
|
@@ -370,7 +369,7 @@ zrb/util/string/name.py,sha256=SXEfxJ1-tDOzHqmSV8kvepRVyMqs2XdV_vyoh_9XUu0,1584
|
|
370
369
|
zrb/util/todo.py,sha256=VGISej2KQZERpornK-8X7bysp4JydMrMUTnG8B0-liI,20708
|
371
370
|
zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
372
371
|
zrb/xcom/xcom.py,sha256=o79rxR9wphnShrcIushA0Qt71d_p3ZTxjNf7x9hJB78,1571
|
373
|
-
zrb-1.7.
|
374
|
-
zrb-1.7.
|
375
|
-
zrb-1.7.
|
376
|
-
zrb-1.7.
|
372
|
+
zrb-1.7.5.dist-info/METADATA,sha256=mNeB3qvnX8OdAWf8hufJ-8A49kONSASS_nWoeN_WUvw,8385
|
373
|
+
zrb-1.7.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
374
|
+
zrb-1.7.5.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
|
375
|
+
zrb-1.7.5.dist-info/RECORD,,
|
zrb/runner/web_config/config.py
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
from typing import Callable
|
2
|
-
|
3
|
-
from zrb.runner.web_schema.user import User
|
4
|
-
from zrb.task.any_task import AnyTask
|
5
|
-
|
6
|
-
|
7
|
-
class WebConfig:
|
8
|
-
def __init__(
|
9
|
-
self,
|
10
|
-
port: int,
|
11
|
-
secret_key: str,
|
12
|
-
access_token_expire_minutes: int,
|
13
|
-
refresh_token_expire_minutes: int,
|
14
|
-
access_token_cookie_name: str,
|
15
|
-
refresh_token_cookie_name: str,
|
16
|
-
enable_auth: bool,
|
17
|
-
super_admin_username: str,
|
18
|
-
super_admin_password: str,
|
19
|
-
guest_username: str,
|
20
|
-
guest_accessible_tasks: list[AnyTask | str] = [],
|
21
|
-
find_user_by_username: Callable[[str], User | None] | None = None,
|
22
|
-
):
|
23
|
-
self.secret_key = secret_key
|
24
|
-
self.access_token_expire_minutes = access_token_expire_minutes
|
25
|
-
self.refresh_token_expire_minutes = refresh_token_expire_minutes
|
26
|
-
self.access_token_cookie_name = access_token_cookie_name
|
27
|
-
self.refresh_token_cookie_name = refresh_token_cookie_name
|
28
|
-
self.enable_auth = enable_auth
|
29
|
-
self.port = port
|
30
|
-
self._user_list = []
|
31
|
-
self.super_admin_username = super_admin_username
|
32
|
-
self.super_admin_password = super_admin_password
|
33
|
-
self.guest_username = guest_username
|
34
|
-
self.guest_accessible_tasks = guest_accessible_tasks
|
35
|
-
self._find_user_by_username = find_user_by_username
|
36
|
-
|
37
|
-
@property
|
38
|
-
def default_user(self) -> User:
|
39
|
-
if self.enable_auth:
|
40
|
-
return User(
|
41
|
-
username=self.guest_username,
|
42
|
-
password="",
|
43
|
-
is_guest=True,
|
44
|
-
accessible_tasks=self.guest_accessible_tasks,
|
45
|
-
)
|
46
|
-
return User(
|
47
|
-
username=self.guest_username,
|
48
|
-
password="",
|
49
|
-
is_guest=True,
|
50
|
-
is_super_admin=True,
|
51
|
-
)
|
52
|
-
|
53
|
-
@property
|
54
|
-
def super_admin(self) -> User:
|
55
|
-
return User(
|
56
|
-
username=self.super_admin_username,
|
57
|
-
password=self.super_admin_password,
|
58
|
-
is_super_admin=True,
|
59
|
-
)
|
60
|
-
|
61
|
-
@property
|
62
|
-
def user_list(self) -> list[User]:
|
63
|
-
if not self.enable_auth:
|
64
|
-
return [self.default_user]
|
65
|
-
return self._user_list + [self.super_admin, self.default_user]
|
66
|
-
|
67
|
-
def set_guest_accessible_tasks(self, tasks: list[AnyTask | str]):
|
68
|
-
self.guest_accessible_tasks = tasks
|
69
|
-
|
70
|
-
def set_find_user_by_username(
|
71
|
-
self, find_user_by_username: Callable[[str], User | None]
|
72
|
-
):
|
73
|
-
self._find_user_by_username = find_user_by_username
|
74
|
-
|
75
|
-
def append_user(self, user: User):
|
76
|
-
duplicates = [
|
77
|
-
existing_user
|
78
|
-
for existing_user in self.user_list
|
79
|
-
if existing_user.username == user.username
|
80
|
-
]
|
81
|
-
if len(duplicates) > 0:
|
82
|
-
raise ValueError(f"User already exists {user.username}")
|
83
|
-
self._user_list.append(user)
|
84
|
-
|
85
|
-
def find_user_by_username(self, username: str) -> User | None:
|
86
|
-
user = None
|
87
|
-
if self._find_user_by_username is not None:
|
88
|
-
user = self._find_user_by_username(username)
|
89
|
-
if user is None:
|
90
|
-
user = next((u for u in self.user_list if u.username == username), None)
|
91
|
-
return user
|
@@ -1,15 +0,0 @@
|
|
1
|
-
from zrb.config import CFG
|
2
|
-
from zrb.runner.web_config.config import WebConfig
|
3
|
-
|
4
|
-
web_config = WebConfig(
|
5
|
-
port=CFG.WEB_HTTP_PORT,
|
6
|
-
secret_key=CFG.WEB_SECRET_KEY,
|
7
|
-
access_token_expire_minutes=CFG.WEB_AUTH_ACCESS_TOKEN_EXPIRE_MINUTES,
|
8
|
-
refresh_token_expire_minutes=CFG.WEB_AUTH_REFRESH_TOKEN_EXPIRE_MINUTES,
|
9
|
-
access_token_cookie_name=CFG.WEB_ACCESS_TOKEN_COOKIE_NAME,
|
10
|
-
refresh_token_cookie_name=CFG.WEB_REFRESH_TOKEN_COOKIE_NAME,
|
11
|
-
enable_auth=CFG.WEB_ENABLE_AUTH,
|
12
|
-
super_admin_username=CFG.WEB_SUPER_ADMIN_USERNAME,
|
13
|
-
super_admin_password=CFG.WEB_SUPER_ADMIN_PASSWORD,
|
14
|
-
guest_username=CFG.WEB_GUEST_USERNAME,
|
15
|
-
)
|
File without changes
|
File without changes
|