HelixAgentAi 0.1.3__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.
- .env.example +117 -0
- api/__init__.py +0 -0
- api/deps.py +75 -0
- api/errors.py +58 -0
- api/gateway.py +624 -0
- api/models.py +29 -0
- api/prometheus.py +23 -0
- cli/__init__.py +3 -0
- cli/__main__.py +6 -0
- cli/commands/__init__.py +0 -0
- cli/commands/chat.py +511 -0
- cli/commands/config.py +76 -0
- cli/commands/cron.py +112 -0
- cli/commands/docs.py +69 -0
- cli/commands/doctor.py +62 -0
- cli/commands/gateway.py +87 -0
- cli/commands/hub.py +408 -0
- cli/commands/install_cmd.py +89 -0
- cli/commands/logs.py +185 -0
- cli/commands/mcp.py +506 -0
- cli/commands/memory.py +53 -0
- cli/commands/models.py +648 -0
- cli/commands/run.py +58 -0
- cli/commands/search.py +223 -0
- cli/commands/skills.py +323 -0
- cli/commands/telegram.py +108 -0
- cli/commands/telegram_setup.py +198 -0
- cli/commands/update_cmd.py +106 -0
- cli/config/__init__.py +0 -0
- cli/core.py +329 -0
- cli/doctor/__init__.py +5 -0
- cli/doctor/checks.py +733 -0
- cli/doctor/findings.py +35 -0
- cli/doctor/fixes.py +128 -0
- cli/doctor/llm_doctor.py +180 -0
- cli/doctor/report.py +74 -0
- cli/doctor/runner.py +77 -0
- cli/installer/__init__.py +29 -0
- cli/installer/manifest.py +95 -0
- cli/installer/system.py +379 -0
- cli/installer/update.py +426 -0
- cli/main.py +322 -0
- cli/services/__init__.py +5 -0
- cli/services/cron_worker.py +33 -0
- cli/services/docs_site.py +128 -0
- cli/services/docs_worker.py +30 -0
- cli/services/gateway_daemon.py +271 -0
- cli/services/gateway_state.py +137 -0
- cli/services/gateway_worker.py +63 -0
- cli/services/supervisor.py +265 -0
- cli/shared/__init__.py +24 -0
- cli/shared/agent_host.py +43 -0
- cli/shared/commands/__init__.py +3 -0
- cli/shared/commands/agent_commands.py +488 -0
- cli/shared/commands/context_compress.py +87 -0
- cli/shared/commands/cron_commands.py +224 -0
- cli/shared/commands/project_init.py +67 -0
- cli/shared/commands/registry.py +118 -0
- cli/shared/commands/search_commands.py +75 -0
- cli/shared/commands/skills_commands.py +149 -0
- cli/shared/commands/subagent_commands.py +92 -0
- cli/shared/rich_text.py +35 -0
- cli/shared/slash_input.py +74 -0
- cli/tui/__init__.py +24 -0
- cli/tui/app.py +5 -0
- cli/tui/code/__init__.py +19 -0
- cli/tui/code/app.py +1374 -0
- cli/tui/code/handlers/__init__.py +4 -0
- cli/tui/code/handlers/events.py +211 -0
- cli/tui/code/handlers/slash.py +7 -0
- cli/tui/code/styles.py +85 -0
- cli/tui/code/widgets/__init__.py +17 -0
- cli/tui/code/widgets/context_bar.py +34 -0
- cli/tui/code/widgets/copy_selection_bar.py +77 -0
- cli/tui/code/widgets/prompt.py +11 -0
- cli/tui/code/widgets/slash_suggestions.py +40 -0
- cli/tui/code/widgets/status_bar.py +12 -0
- cli/tui/code/widgets/transcript.py +25 -0
- cli/tui/code/widgets/transcript_panel.py +41 -0
- cli/tui/legacy/app.py +4005 -0
- cli/tui/legacy/confirmation_modal.py +5 -0
- cli/tui/legacy/handlers/__init__.py +6 -0
- cli/tui/legacy/handlers/event_handler.py +381 -0
- cli/tui/legacy/handlers/slash_commands.py +306 -0
- cli/tui/legacy/plan_review_modal.py +35 -0
- cli/tui/legacy/subagents_widget.py +406 -0
- cli/tui/legacy/widgets/__init__.py +15 -0
- cli/tui/legacy/widgets/chat_log.py +42 -0
- cli/tui/legacy/widgets/input_area.py +15 -0
- cli/tui/legacy/widgets/main_content.py +29 -0
- cli/tui/legacy/widgets/sidebar.py +52 -0
- cli/tui/legacy/widgets/styles.py +366 -0
- cli/tui/modals/__init__.py +7 -0
- cli/tui/modals/confirmation.py +148 -0
- cli/tui/modals/confirmation_presenter.py +74 -0
- cli/tui/modals/cron_manager.py +222 -0
- cli/tui/modals/hub_browser.py +1054 -0
- cli/tui/modals/model_picker.py +188 -0
- cli/tui/modals/plan_review.py +135 -0
- cli/tui/modals/stack.py +29 -0
- cli/tui/modals/transcript_viewer.py +109 -0
- cli/tui/shared/__init__.py +43 -0
- cli/tui/shared/clipboard.py +91 -0
- cli/tui/shared/copy_bar.py +38 -0
- cli/tui/shared/diff_render.py +161 -0
- cli/tui/shared/formatters.py +73 -0
- cli/tui/shared/host_protocol.py +20 -0
- cli/tui/shared/keyboard_layout.py +131 -0
- cli/tui/shared/slash_suggestions.py +65 -0
- cli/tui/shared/text_escape.py +18 -0
- cli/tui/shared/transcript_store.py +134 -0
- cli/tui/web_entry.py +27 -0
- cli/tui/web_security.py +139 -0
- cli/tui/web_serve.py +88 -0
- cli/tui/web_server.py +70 -0
- cli/utils/__init__.py +0 -0
- cli/utils/banner.py +59 -0
- cli/utils/ports.py +42 -0
- cli/utils/rich_console.py +158 -0
- config.py +240 -0
- core/__init__.py +0 -0
- core/agent.py +409 -0
- core/agent_events.py +638 -0
- core/agent_execution.py +529 -0
- core/config_utils.py +126 -0
- core/context/__init__.py +17 -0
- core/context/compressor.py +186 -0
- core/context/manager.py +258 -0
- core/context/token_counter.py +125 -0
- core/cron/__init__.py +12 -0
- core/cron/expressions.py +43 -0
- core/cron/models.py +43 -0
- core/cron/notifier.py +79 -0
- core/cron/runner.py +211 -0
- core/cron/schedule_parse.py +76 -0
- core/cron/scheduler.py +76 -0
- core/cron/session_sync.py +75 -0
- core/cron/store.py +130 -0
- core/di/__init__.py +20 -0
- core/di/container.py +105 -0
- core/di/factories.py +20 -0
- core/di/providers.py +53 -0
- core/di/runtime_config.py +225 -0
- core/env_loader.py +178 -0
- core/evolution/__init__.py +7 -0
- core/evolution/engine.py +258 -0
- core/graph/__init__.py +7 -0
- core/graph/builder.py +199 -0
- core/graph/modes/__init__.py +13 -0
- core/graph/modes/_compile.py +22 -0
- core/graph/modes/hybrid.py +55 -0
- core/graph/modes/plan_execute.py +77 -0
- core/graph/modes/react.py +45 -0
- core/graph/modes/router.py +157 -0
- core/graph/nodes/__init__.py +3 -0
- core/graph/nodes/collect_subagent_node.py +60 -0
- core/graph/nodes/delegate_subagent_node.py +69 -0
- core/graph/nodes/execute_step_node.py +223 -0
- core/graph/nodes/finalize_node.py +146 -0
- core/graph/nodes/memory_retrieval_node.py +128 -0
- core/graph/nodes/meta_agent_node.py +83 -0
- core/graph/nodes/plan_node.py +481 -0
- core/graph/nodes/plan_review_node.py +177 -0
- core/graph/nodes/react_node.py +425 -0
- core/graph/nodes/self_refinement_node.py +117 -0
- core/graph/nodes/step_orchestrate_node.py +202 -0
- core/graph/nodes/tool_execution_node.py +108 -0
- core/graph/routers.py +99 -0
- core/graph/state.py +94 -0
- core/graph/tools.py +180 -0
- core/graph/visualization.py +310 -0
- core/hub/__init__.py +6 -0
- core/hub/autoupdate.py +119 -0
- core/hub/catalog.py +157 -0
- core/hub/claude_convert.py +45 -0
- core/hub/claude_marketplace.py +203 -0
- core/hub/claude_mcp.py +67 -0
- core/hub/clawhub.py +140 -0
- core/hub/hermes_hub.py +116 -0
- core/hub/importer.py +495 -0
- core/hub/installed.py +149 -0
- core/hub/interactive.py +178 -0
- core/hub/lockfile.py +75 -0
- core/hub/normalize.py +120 -0
- core/hub/skills_sh.py +67 -0
- core/hub/slash_registry.py +108 -0
- core/hub/sources.py +95 -0
- core/hub/updates.py +46 -0
- core/i18n/__init__.py +23 -0
- core/i18n/locale.py +81 -0
- core/i18n/messages.py +271 -0
- core/logging/__init__.py +14 -0
- core/logging/events.py +62 -0
- core/logging/paths.py +86 -0
- core/logging/reader.py +230 -0
- core/logging/rotation.py +81 -0
- core/logging/setup.py +93 -0
- core/logging/state.py +42 -0
- core/loop.py +55 -0
- core/loop_streaming.py +79 -0
- core/mcp/config.py +90 -0
- core/mcp/installer.py +269 -0
- core/mcp/manager.py +263 -0
- core/mcp/popular.py +144 -0
- core/mcp/tool.py +62 -0
- core/mcp/validate.py +52 -0
- core/memory/__init__.py +14 -0
- core/memory/chroma_embeddings.py +48 -0
- core/memory/conversation.py +274 -0
- core/memory/episodic.py +270 -0
- core/memory/facade.py +173 -0
- core/memory/ltm.py +128 -0
- core/memory/manager.py +17 -0
- core/memory/markdown.py +99 -0
- core/memory/procedural.py +218 -0
- core/memory/semantic.py +222 -0
- core/memory/strategic.py +286 -0
- core/memory/summarizer.py +77 -0
- core/memory/vector.py +236 -0
- core/meta_agent.py +300 -0
- core/models/__init__.py +32 -0
- core/models/catalog.py +436 -0
- core/models/client_factory.py +67 -0
- core/models/discovery.py +203 -0
- core/models/manager.py +186 -0
- core/models/profile_cleanup.py +118 -0
- core/models/provider.py +93 -0
- core/models/selector.py +106 -0
- core/models/setup_helpers.py +362 -0
- core/monitoring/__init__.py +4 -0
- core/monitoring/event_fields.py +25 -0
- core/monitoring/logger.py +152 -0
- core/monitoring/metrics.py +203 -0
- core/persistence.py +51 -0
- core/plan_review/__init__.py +27 -0
- core/plan_review/markdown_builder.py +144 -0
- core/plan_review/parser.py +245 -0
- core/plan_review/plan_storage.py +263 -0
- core/plan_review/review_events.py +121 -0
- core/plan_review/review_guard.py +200 -0
- core/platform_compat.py +213 -0
- core/presenters/__init__.py +3 -0
- core/presenters/live_buffer.py +108 -0
- core/project/__init__.py +27 -0
- core/project/helix_md.py +89 -0
- core/project/init_prompt.py +103 -0
- core/prompt_builder.py +132 -0
- core/runtime/__init__.py +6 -0
- core/runtime/executor.py +59 -0
- core/runtime/session.py +52 -0
- core/search/__init__.py +6 -0
- core/search/catalog.py +70 -0
- core/search/config.py +80 -0
- core/search/content.py +166 -0
- core/search/engine.py +108 -0
- core/search/providers.py +203 -0
- core/security/__init__.py +24 -0
- core/security/auth.py +178 -0
- core/security/confirmation.py +635 -0
- core/security/confirmation_events.py +117 -0
- core/security/permissions.py +53 -0
- core/security/safety.py +142 -0
- core/self_refinement/__init__.py +7 -0
- core/self_refinement/loop.py +295 -0
- core/session_models.py +176 -0
- core/skills/__init__.py +0 -0
- core/skills/assignments.py +165 -0
- core/skills/bundled/helix-cron/SKILL.md +124 -0
- core/skills/bundled.py +93 -0
- core/skills/generator.py +158 -0
- core/skills/manager.py +421 -0
- core/subagents/__init__.py +11 -0
- core/subagents/async_runner.py +375 -0
- core/subagents/base.py +134 -0
- core/subagents/communication.py +355 -0
- core/subagents/interaction.py +258 -0
- core/subagents/interaction_events.py +41 -0
- core/subagents/manager.py +405 -0
- core/subagents/process.py +933 -0
- core/subagents/registry.py +174 -0
- core/subagents/spawn.py +39 -0
- core/tools/__init__.py +0 -0
- core/tools/aliases.py +31 -0
- core/tools/ask_user.py +53 -0
- core/tools/base.py +42 -0
- core/tools/browser/__init__.py +5 -0
- core/tools/browser/policy.py +76 -0
- core/tools/browser/session.py +124 -0
- core/tools/browser/snapshot.py +77 -0
- core/tools/browser/tools.py +247 -0
- core/tools/code_executor.py +219 -0
- core/tools/database.py +167 -0
- core/tools/execution_context.py +52 -0
- core/tools/file_diff.py +77 -0
- core/tools/file_ops.py +155 -0
- core/tools/registry.py +182 -0
- core/tools/subagents.py +168 -0
- core/tools/terminal.py +79 -0
- core/tools/web_search.py +87 -0
- helixagentai-0.1.3.dist-info/METADATA +225 -0
- helixagentai-0.1.3.dist-info/RECORD +375 -0
- helixagentai-0.1.3.dist-info/WHEEL +4 -0
- helixagentai-0.1.3.dist-info/entry_points.txt +2 -0
- helixagentai-0.1.3.dist-info/licenses/LICENSE +21 -0
- integrations/__init__.py +1 -0
- integrations/telegram/__init__.py +5 -0
- integrations/telegram/agent_setup.py +32 -0
- integrations/telegram/approvals.py +237 -0
- integrations/telegram/bot.py +494 -0
- integrations/telegram/commands.py +140 -0
- integrations/telegram/config.py +59 -0
- integrations/telegram/env_store.py +123 -0
- integrations/telegram/event_handler.py +201 -0
- integrations/telegram/file_handler.py +478 -0
- integrations/telegram/host.py +649 -0
- integrations/telegram/interactive.py +781 -0
- integrations/telegram/keyboards.py +318 -0
- integrations/telegram/live_presenter.py +120 -0
- integrations/telegram/main.py +25 -0
- integrations/telegram/markdown.py +215 -0
- integrations/telegram/media_group.py +84 -0
- integrations/telegram/model_switch.py +286 -0
- integrations/telegram/render.py +76 -0
- integrations/telegram/session.py +65 -0
- integrations/telegram/setup_api.py +83 -0
- integrations/telegram/typing_indicator.py +66 -0
- integrations/telegram/voice_handler.py +355 -0
- web-docs/assets/css/style.css +816 -0
- web-docs/assets/js/app.js +633 -0
- web-docs/assets/logo.svg +33 -0
- web-docs/build.py +105 -0
- web-docs/content/en/ARCHITECTURE.md +71 -0
- web-docs/content/en/BROWSER_TOOLS.md +67 -0
- web-docs/content/en/CLI.md +493 -0
- web-docs/content/en/CONFIGURATION.md +134 -0
- web-docs/content/en/DEPLOYMENT.md +28 -0
- web-docs/content/en/DOCTOR.md +40 -0
- web-docs/content/en/GATEWAY.md +43 -0
- web-docs/content/en/HUB.md +74 -0
- web-docs/content/en/INSTALLATION.md +154 -0
- web-docs/content/en/LOGS.md +144 -0
- web-docs/content/en/PYPI.md +231 -0
- web-docs/content/en/QUICKSTART.md +31 -0
- web-docs/content/en/README.md +40 -0
- web-docs/content/en/SECURITY.md +53 -0
- web-docs/content/en/SLASH_COMMANDS.md +188 -0
- web-docs/content/en/START_HERE.md +75 -0
- web-docs/content/en/TELEGRAM.md +91 -0
- web-docs/content/en/TROUBLESHOOTING.md +52 -0
- web-docs/content/en/TUI.md +35 -0
- web-docs/content/en/USER_GUIDE.md +854 -0
- web-docs/content/ru/ARCHITECTURE.md +19 -0
- web-docs/content/ru/BROWSER_TOOLS.md +41 -0
- web-docs/content/ru/CLI.md +260 -0
- web-docs/content/ru/CONFIGURATION.md +63 -0
- web-docs/content/ru/DEPLOYMENT.md +28 -0
- web-docs/content/ru/DOCTOR.md +39 -0
- web-docs/content/ru/GATEWAY.md +37 -0
- web-docs/content/ru/HUB.md +74 -0
- web-docs/content/ru/INSTALLATION.md +102 -0
- web-docs/content/ru/LOGS.md +90 -0
- web-docs/content/ru/PYPI.md +90 -0
- web-docs/content/ru/QUICKSTART.md +20 -0
- web-docs/content/ru/README.md +29 -0
- web-docs/content/ru/SECURITY.md +53 -0
- web-docs/content/ru/SLASH_COMMANDS.md +161 -0
- web-docs/content/ru/START_HERE.md +72 -0
- web-docs/content/ru/TELEGRAM.md +118 -0
- web-docs/content/ru/TROUBLESHOOTING.md +50 -0
- web-docs/content/ru/TUI.md +35 -0
- web-docs/content/ru/USER_GUIDE.md +854 -0
- web-docs/index.html +86 -0
- web-docs/nav.json +122 -0
- web-docs/search-index.json +402 -0
- web-docs/serve.py +32 -0
.env.example
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Helix environment — copy to ~/.helix/.env (primary location)
|
|
2
|
+
# Optional: ./.env in a project dir (lower priority than ~/.helix/.env)
|
|
3
|
+
|
|
4
|
+
# --- Environment ---
|
|
5
|
+
HELIX_ENV=development
|
|
6
|
+
# HELIX_HOME= # override data dir (default: ~/.helix, XDG_DATA_HOME/helix, or %LOCALAPPDATA%\Helix on Windows)
|
|
7
|
+
# production: forces auth, stricter Telegram/CORS checks
|
|
8
|
+
|
|
9
|
+
# --- LLM (legacy single-provider; prefer helix models setup + profile providers) ---
|
|
10
|
+
MODEL=qwen2.5-coder:32b
|
|
11
|
+
BASE_URL=http://localhost:11434/v1
|
|
12
|
+
API_KEY=ollama
|
|
13
|
+
TEMPERATURE=0.7
|
|
14
|
+
|
|
15
|
+
# --- Cloud provider API keys (used via ${ENV:VAR} in ~/.helix/profiles/*/config.yaml) ---
|
|
16
|
+
# OPENAI_API_KEY=
|
|
17
|
+
# OPENROUTER_API_KEY=
|
|
18
|
+
# OPENROUTER_HTTP_REFERER=https://github.com/your-org/helix
|
|
19
|
+
# DEEPSEEK_API_KEY=
|
|
20
|
+
# MOONSHOT_API_KEY=
|
|
21
|
+
# XAI_API_KEY=
|
|
22
|
+
# GROQ_API_KEY=
|
|
23
|
+
# GOOGLE_API_KEY=
|
|
24
|
+
# MISTRAL_API_KEY=
|
|
25
|
+
# TOGETHER_API_KEY=
|
|
26
|
+
# FIREWORKS_API_KEY=
|
|
27
|
+
# CEREBRAS_API_KEY=
|
|
28
|
+
# LITELLM_API_KEY=
|
|
29
|
+
# Hosts for local / remote inference (used by helix models add ollama|litellm|vllm)
|
|
30
|
+
# OLLAMA_HOST=http://127.0.0.1:11434
|
|
31
|
+
# LITELLM_API_BASE=http://127.0.0.1:4000
|
|
32
|
+
# VLLM_HOST=http://127.0.0.1:8000
|
|
33
|
+
|
|
34
|
+
# --- Agent ---
|
|
35
|
+
MAX_STEPS=15
|
|
36
|
+
DATA_DIR=data
|
|
37
|
+
|
|
38
|
+
# --- Logging (helix logs) ---
|
|
39
|
+
# HELIX_LOG_LEVEL=INFO
|
|
40
|
+
# HELIX_LOG_DEBUG=false
|
|
41
|
+
# HELIX_LOG_MAX_BYTES=10485760
|
|
42
|
+
# HELIX_LOG_BACKUP_COUNT=10
|
|
43
|
+
# HELIX_LOG_ROTATION_DAYS=14
|
|
44
|
+
|
|
45
|
+
# --- Web TUI (helix tui --web) ---
|
|
46
|
+
# HELIX_TUI_WEB_TOKEN= # required for --allow-lan / production; optional on 127.0.0.1
|
|
47
|
+
|
|
48
|
+
# --- Gateway ---
|
|
49
|
+
HELIX_GATEWAY_HOST=127.0.0.1
|
|
50
|
+
HELIX_GATEWAY_PORT=8000
|
|
51
|
+
# HELIX_GATEWAY_WITH_DOCS=1
|
|
52
|
+
# HELIX_DOCS_HOST=127.0.0.1
|
|
53
|
+
# HELIX_DOCS_PORT=8080
|
|
54
|
+
HELIX_REQUIRE_AUTH=false
|
|
55
|
+
HELIX_CORS_ORIGINS=http://127.0.0.1:8000,http://localhost:8000
|
|
56
|
+
HELIX_API_KEYS_DB=data/security/api_keys.db
|
|
57
|
+
HELIX_API_KEY_PEPPER=
|
|
58
|
+
HELIX_RATE_LIMIT_RPM=100
|
|
59
|
+
HELIX_ADMIN_RATE_LIMIT_RPM=30
|
|
60
|
+
HELIX_ENABLE_PROMETHEUS_METRICS=true
|
|
61
|
+
|
|
62
|
+
# --- Tools (production: disable risky tools) ---
|
|
63
|
+
HELIX_ENABLE_CODE_EXECUTOR=true
|
|
64
|
+
HELIX_ENABLE_TERMINAL_TOOL=true
|
|
65
|
+
HELIX_TERMINAL_COMMAND_WHITELIST=true
|
|
66
|
+
# Extra allowed commands/prefixes (comma-separated): helix gateway start, docker, make
|
|
67
|
+
# HELIX_TERMINAL_WHITELIST_EXTRA=helix,uv,docker,make
|
|
68
|
+
|
|
69
|
+
# --- Telegram (optional: uv sync --extra telegram) ---
|
|
70
|
+
TELEGRAM_BOT_TOKEN=
|
|
71
|
+
HELIX_TELEGRAM_ALLOWED_USERS=
|
|
72
|
+
# HELIX_TELEGRAM_ALLOW_ALL=true # dev only: allow any Telegram user (never use in production)
|
|
73
|
+
HELIX_TELEGRAM_PROFILE=default
|
|
74
|
+
|
|
75
|
+
# --- Voice Messages (Telegram) ---
|
|
76
|
+
# Вариант A — OpenAI Whisper напрямую:
|
|
77
|
+
# OPENAI_API_KEY=sk-...
|
|
78
|
+
# HELIX_WHISPER_MODEL=whisper-1
|
|
79
|
+
#
|
|
80
|
+
# Вариант B — через LiteLLM proxy (нужна модель whisper в config LiteLLM):
|
|
81
|
+
# HELIX_WHISPER_BASE_URL=http://192.168.88.252:4000/v1
|
|
82
|
+
# HELIX_WHISPER_API_KEY=sk-... # virtual key LiteLLM
|
|
83
|
+
# HELIX_WHISPER_MODEL=whisper # model_name из LiteLLM config, не whisper-1
|
|
84
|
+
#
|
|
85
|
+
# Вариант C — тот же litellm-провайдер из профиля (HELIX_WHISPER_USE_PROFILE_LITELLM=true):
|
|
86
|
+
# HELIX_WHISPER_MODEL=whisper
|
|
87
|
+
#
|
|
88
|
+
# Вариант D — локально на машине с агентом (без облака, нужен ffmpeg):
|
|
89
|
+
# uv sync --extra voice
|
|
90
|
+
# HELIX_WHISPER_BACKEND=local
|
|
91
|
+
# HELIX_WHISPER_LOCAL_MODEL=base # tiny | base | small | medium | large-v3
|
|
92
|
+
# HELIX_WHISPER_LOCAL_DEVICE=cpu # cuda для GPU
|
|
93
|
+
# HELIX_WHISPER_LOCAL_COMPUTE_TYPE=int8 # float16 на GPU
|
|
94
|
+
# HELIX_WHISPER_AUTO_DOWNLOAD=true # скачать модель при старте бота (по умолчанию)
|
|
95
|
+
# HELIX_WHISPER_LOCAL_DOWNLOAD_ROOT= # каталог кэша (по умолчанию ~/.helix/models/whisper)
|
|
96
|
+
# HELIX_TELEGRAM_VOICE_LANGUAGE=ru
|
|
97
|
+
#
|
|
98
|
+
# HELIX_WHISPER_BACKEND=auto # local если установлен faster-whisper, иначе API
|
|
99
|
+
# HELIX_TELEGRAM_VOICE_ENABLED=true
|
|
100
|
+
|
|
101
|
+
# --- Telegram files (photos, documents) ---
|
|
102
|
+
# HELIX_TELEGRAM_FILES_ENABLED=true
|
|
103
|
+
# HELIX_TELEGRAM_MAX_FILE_MB=20
|
|
104
|
+
# HELIX_TELEGRAM_MEDIA_GROUP_DELAY_MS=800 # пауза перед обработкой альбома
|
|
105
|
+
# HELIX_TELEGRAM_VISION_MODEL=smart # имя модели в LiteLLM с поддержкой vision
|
|
106
|
+
# Требуются также LITELLM_API_KEY + LITELLM_API_BASE (или helix models setup)
|
|
107
|
+
|
|
108
|
+
# --- Browser (optional: uv sync --extra browser) ---
|
|
109
|
+
ENABLE_BROWSER_TOOLS=true
|
|
110
|
+
BROWSER_HEADLESS=true
|
|
111
|
+
BROWSER_ALLOWED_HOSTS=
|
|
112
|
+
|
|
113
|
+
# --- Web search (helix search configure) ---
|
|
114
|
+
# FIRECRAWL_API_KEY=fc-...
|
|
115
|
+
# SEARXNG_BASE_URL=http://127.0.0.1:8080
|
|
116
|
+
|
|
117
|
+
# Profile secrets in config.yaml: use ${OPENAI_API_KEY} or ${ENV:OPENAI_API_KEY}
|
api/__init__.py
ADDED
|
File without changes
|
api/deps.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""FastAPI dependencies for Helix gateway."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from fastapi import Header, HTTPException
|
|
8
|
+
|
|
9
|
+
from config import settings
|
|
10
|
+
|
|
11
|
+
# Set by gateway lifespan
|
|
12
|
+
api_key_manager = None
|
|
13
|
+
rate_limiter = None
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _extract_api_key(
|
|
17
|
+
authorization: Optional[str],
|
|
18
|
+
x_api_key: Optional[str],
|
|
19
|
+
) -> Optional[str]:
|
|
20
|
+
if authorization and authorization.startswith("Bearer "):
|
|
21
|
+
return authorization[7:]
|
|
22
|
+
if x_api_key:
|
|
23
|
+
return x_api_key
|
|
24
|
+
return None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
async def _validate_key(api_key: str, *, default_limit: int) -> dict:
|
|
28
|
+
if api_key_manager is None:
|
|
29
|
+
raise HTTPException(status_code=503, detail="API key manager not initialized")
|
|
30
|
+
|
|
31
|
+
key_info = await api_key_manager.validate_api_key(api_key)
|
|
32
|
+
if not key_info:
|
|
33
|
+
raise HTTPException(status_code=401, detail="Invalid API key")
|
|
34
|
+
|
|
35
|
+
limit = int(key_info.get("rate_limit") or default_limit)
|
|
36
|
+
key_hash = api_key_manager.hash_key(api_key)
|
|
37
|
+
if rate_limiter and not rate_limiter.check_rate_limit(key_hash, limit):
|
|
38
|
+
raise HTTPException(status_code=429, detail="Rate limit exceeded")
|
|
39
|
+
|
|
40
|
+
return key_info
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
async def verify_api_key(
|
|
44
|
+
authorization: Optional[str] = Header(None),
|
|
45
|
+
x_api_key: Optional[str] = Header(None),
|
|
46
|
+
) -> Optional[dict]:
|
|
47
|
+
"""Optional auth for public /v1 routes when require_auth is disabled."""
|
|
48
|
+
if not settings.effective_require_auth:
|
|
49
|
+
api_key = _extract_api_key(authorization, x_api_key)
|
|
50
|
+
if not api_key:
|
|
51
|
+
return None
|
|
52
|
+
return await _validate_key(api_key, default_limit=settings.rate_limit_rpm)
|
|
53
|
+
|
|
54
|
+
api_key = _extract_api_key(authorization, x_api_key)
|
|
55
|
+
if not api_key:
|
|
56
|
+
raise HTTPException(status_code=401, detail="API key required")
|
|
57
|
+
return await _validate_key(api_key, default_limit=settings.rate_limit_rpm)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def verify_admin_key(
|
|
61
|
+
authorization: Optional[str] = Header(None),
|
|
62
|
+
x_api_key: Optional[str] = Header(None),
|
|
63
|
+
) -> dict:
|
|
64
|
+
"""Admin routes always require a valid admin API key."""
|
|
65
|
+
from core.security.permissions import PermissionChecker
|
|
66
|
+
|
|
67
|
+
api_key = _extract_api_key(authorization, x_api_key)
|
|
68
|
+
if not api_key:
|
|
69
|
+
raise HTTPException(status_code=401, detail="Admin API key required")
|
|
70
|
+
|
|
71
|
+
key_info = await _validate_key(api_key, default_limit=settings.admin_rate_limit_rpm)
|
|
72
|
+
checker = PermissionChecker(key_info["permissions"])
|
|
73
|
+
if not checker.is_admin():
|
|
74
|
+
raise HTTPException(status_code=403, detail="Admin permission required")
|
|
75
|
+
return key_info
|
api/errors.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""OpenAI-compatible error mapping for the API gateway."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from fastapi import HTTPException
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def openai_error_body(
|
|
9
|
+
message: str,
|
|
10
|
+
*,
|
|
11
|
+
error_type: str = "server_error",
|
|
12
|
+
code: str = "internal_error",
|
|
13
|
+
) -> dict:
|
|
14
|
+
return {
|
|
15
|
+
"error": {
|
|
16
|
+
"message": message,
|
|
17
|
+
"type": error_type,
|
|
18
|
+
"code": code,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def agent_error_to_http(exc: Exception, *, default_status: int = 500) -> HTTPException:
|
|
24
|
+
"""Map agent/runtime exceptions to OpenAI-style HTTPException detail."""
|
|
25
|
+
if isinstance(exc, HTTPException):
|
|
26
|
+
return exc
|
|
27
|
+
|
|
28
|
+
message = str(exc) or "Unknown error"
|
|
29
|
+
lower = message.lower()
|
|
30
|
+
status = default_status
|
|
31
|
+
error_type = "server_error"
|
|
32
|
+
code = "internal_error"
|
|
33
|
+
|
|
34
|
+
if "not initialized" in lower or "not ready" in lower:
|
|
35
|
+
status = 503
|
|
36
|
+
error_type = "service_unavailable"
|
|
37
|
+
code = "agent_unavailable"
|
|
38
|
+
elif "permission" in lower or "forbidden" in lower:
|
|
39
|
+
status = 403
|
|
40
|
+
error_type = "permission_denied"
|
|
41
|
+
code = "insufficient_permissions"
|
|
42
|
+
elif "confirmation" in lower or "denied" in lower:
|
|
43
|
+
status = 409
|
|
44
|
+
error_type = "confirmation_required"
|
|
45
|
+
code = "confirmation_denied"
|
|
46
|
+
elif "plan review" in lower or "review" in lower and "not found" in lower:
|
|
47
|
+
status = 404
|
|
48
|
+
error_type = "invalid_request_error"
|
|
49
|
+
code = "plan_review_not_found"
|
|
50
|
+
elif "timeout" in lower:
|
|
51
|
+
status = 504
|
|
52
|
+
error_type = "timeout"
|
|
53
|
+
code = "gateway_timeout"
|
|
54
|
+
|
|
55
|
+
return HTTPException(
|
|
56
|
+
status_code=status,
|
|
57
|
+
detail=openai_error_body(message, error_type=error_type, code=code),
|
|
58
|
+
)
|