close #4: [feat] add config
This commit is contained in:
parent
7b3f82e805
commit
3448266c1d
4 changed files with 100 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ from .model import (
|
||||||
LoggingConfig,
|
LoggingConfig,
|
||||||
MetricsConfig,
|
MetricsConfig,
|
||||||
OtelConfig,
|
OtelConfig,
|
||||||
|
SandboxConfig,
|
||||||
SecurityConfig,
|
SecurityConfig,
|
||||||
TracingConfig,
|
TracingConfig,
|
||||||
)
|
)
|
||||||
|
|
@ -38,6 +39,7 @@ def load_config(
|
||||||
logging_section = _section(yaml_data, 'logging')
|
logging_section = _section(yaml_data, 'logging')
|
||||||
metrics_section = _section(yaml_data, 'metrics')
|
metrics_section = _section(yaml_data, 'metrics')
|
||||||
tracing_section = _section(yaml_data, 'tracing')
|
tracing_section = _section(yaml_data, 'tracing')
|
||||||
|
sandbox_section = _section(yaml_data, 'sandbox')
|
||||||
security_section = _section(yaml_data, 'security')
|
security_section = _section(yaml_data, 'security')
|
||||||
|
|
||||||
logging_output = _yaml_or_env_choice(
|
logging_output = _yaml_or_env_choice(
|
||||||
|
|
@ -128,6 +130,7 @@ def load_config(
|
||||||
enable_metrics=metrics_enabled,
|
enable_metrics=metrics_enabled,
|
||||||
enable_tracing=tracing_enabled,
|
enable_tracing=tracing_enabled,
|
||||||
),
|
),
|
||||||
|
sandbox=_load_sandbox_config(sandbox_section, env_values),
|
||||||
security=SecurityConfig(
|
security=SecurityConfig(
|
||||||
token_header=_yaml_or_env_str(
|
token_header=_yaml_or_env_str(
|
||||||
security_section,
|
security_section,
|
||||||
|
|
@ -221,6 +224,77 @@ def _optional_section(data: Mapping[str, object], name: str) -> dict[str, object
|
||||||
return section
|
return section
|
||||||
|
|
||||||
|
|
||||||
|
def _load_sandbox_config(
|
||||||
|
section: Mapping[str, object],
|
||||||
|
env: Mapping[str, str],
|
||||||
|
) -> SandboxConfig:
|
||||||
|
return SandboxConfig(
|
||||||
|
image=_yaml_or_env_str(
|
||||||
|
section,
|
||||||
|
'image',
|
||||||
|
'sandbox.image',
|
||||||
|
env,
|
||||||
|
'APP_SANDBOX_IMAGE',
|
||||||
|
),
|
||||||
|
ttl_seconds=_yaml_or_env_int(
|
||||||
|
section,
|
||||||
|
'ttl_seconds',
|
||||||
|
'sandbox.ttl_seconds',
|
||||||
|
env,
|
||||||
|
'APP_SANDBOX_TTL_SECONDS',
|
||||||
|
),
|
||||||
|
cleanup_interval_seconds=_yaml_or_env_int(
|
||||||
|
section,
|
||||||
|
'cleanup_interval_seconds',
|
||||||
|
'sandbox.cleanup_interval_seconds',
|
||||||
|
env,
|
||||||
|
'APP_SANDBOX_CLEANUP_INTERVAL_SECONDS',
|
||||||
|
),
|
||||||
|
chats_root=_yaml_or_env_str(
|
||||||
|
section,
|
||||||
|
'chats_root',
|
||||||
|
'sandbox.chats_root',
|
||||||
|
env,
|
||||||
|
'APP_SANDBOX_CHATS_ROOT',
|
||||||
|
),
|
||||||
|
dependencies_host_path=_yaml_or_env_str(
|
||||||
|
section,
|
||||||
|
'dependencies_host_path',
|
||||||
|
'sandbox.dependencies_host_path',
|
||||||
|
env,
|
||||||
|
'APP_SANDBOX_DEPENDENCIES_HOST_PATH',
|
||||||
|
),
|
||||||
|
lambda_tools_host_path=_yaml_or_env_str(
|
||||||
|
section,
|
||||||
|
'lambda_tools_host_path',
|
||||||
|
'sandbox.lambda_tools_host_path',
|
||||||
|
env,
|
||||||
|
'APP_SANDBOX_LAMBDA_TOOLS_HOST_PATH',
|
||||||
|
),
|
||||||
|
chat_mount_path=_yaml_or_env_str(
|
||||||
|
section,
|
||||||
|
'chat_mount_path',
|
||||||
|
'sandbox.chat_mount_path',
|
||||||
|
env,
|
||||||
|
'APP_SANDBOX_CHAT_MOUNT_PATH',
|
||||||
|
),
|
||||||
|
dependencies_mount_path=_yaml_or_env_str(
|
||||||
|
section,
|
||||||
|
'dependencies_mount_path',
|
||||||
|
'sandbox.dependencies_mount_path',
|
||||||
|
env,
|
||||||
|
'APP_SANDBOX_DEPENDENCIES_MOUNT_PATH',
|
||||||
|
),
|
||||||
|
lambda_tools_mount_path=_yaml_or_env_str(
|
||||||
|
section,
|
||||||
|
'lambda_tools_mount_path',
|
||||||
|
'sandbox.lambda_tools_mount_path',
|
||||||
|
env,
|
||||||
|
'APP_SANDBOX_LAMBDA_TOOLS_MOUNT_PATH',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _load_otel_config(
|
def _load_otel_config(
|
||||||
data: Mapping[str, object],
|
data: Mapping[str, object],
|
||||||
env: Mapping[str, str],
|
env: Mapping[str, str],
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,19 @@ class OtelConfig:
|
||||||
metric_export_interval: int
|
metric_export_interval: int
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True, slots=True)
|
||||||
|
class SandboxConfig:
|
||||||
|
image: str
|
||||||
|
ttl_seconds: int
|
||||||
|
cleanup_interval_seconds: int
|
||||||
|
chats_root: str
|
||||||
|
dependencies_host_path: str
|
||||||
|
lambda_tools_host_path: str
|
||||||
|
chat_mount_path: str
|
||||||
|
dependencies_mount_path: str
|
||||||
|
lambda_tools_mount_path: str
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, slots=True)
|
@dataclass(frozen=True, slots=True)
|
||||||
class SecurityConfig:
|
class SecurityConfig:
|
||||||
token_header: str
|
token_header: str
|
||||||
|
|
@ -55,4 +68,5 @@ class AppConfig:
|
||||||
metrics: MetricsConfig
|
metrics: MetricsConfig
|
||||||
tracing: TracingConfig
|
tracing: TracingConfig
|
||||||
otel: OtelConfig
|
otel: OtelConfig
|
||||||
|
sandbox: SandboxConfig
|
||||||
security: SecurityConfig
|
security: SecurityConfig
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,16 @@ otel:
|
||||||
traces_endpoint: http://localhost:4318/v1/traces
|
traces_endpoint: http://localhost:4318/v1/traces
|
||||||
metric_export_interval: 1000
|
metric_export_interval: 1000
|
||||||
|
|
||||||
|
sandbox:
|
||||||
|
image: ai-agent:latest
|
||||||
|
ttl_seconds: 300
|
||||||
|
cleanup_interval_seconds: 60
|
||||||
|
chats_root: var/sandbox/chats
|
||||||
|
dependencies_host_path: var/sandbox/dependencies
|
||||||
|
lambda_tools_host_path: var/sandbox/lambda-tools
|
||||||
|
chat_mount_path: /workspace/chat
|
||||||
|
dependencies_mount_path: /opt/dependencies
|
||||||
|
lambda_tools_mount_path: /opt/lambda-tools
|
||||||
|
|
||||||
security:
|
security:
|
||||||
token_header: X-API-Token
|
token_header: X-API-Token
|
||||||
|
|
|
||||||
2
tasks.md
2
tasks.md
|
|
@ -42,7 +42,7 @@
|
||||||
### M02. Typed config для sandbox runtime
|
### M02. Typed config для sandbox runtime
|
||||||
|
|
||||||
- Субагент: `feature-developer`
|
- Субагент: `feature-developer`
|
||||||
- Статус: pending
|
- Статус: completed
|
||||||
- Зависимости: `M01`
|
- Зависимости: `M01`
|
||||||
- Commit required: no
|
- Commit required: no
|
||||||
- Scope: расширить typed-config слоем `sandbox` с настройками image, TTL, cleanup interval, host paths и container mount paths
|
- Scope: расширить typed-config слоем `sandbox` с настройками image, TTL, cleanup interval, host paths и container mount paths
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue