Skip to content

refactor: Phase 4.2 — extract widget public endpoints (#547)#566

Merged
shikhalev merged 1 commit intomainfrom
server/phase-4.2-widget-public
Mar 13, 2026
Merged

refactor: Phase 4.2 — extract widget public endpoints (#547)#566
shikhalev merged 1 commit intomainfrom
server/phase-4.2-widget-public

Conversation

@shikhalev
Copy link
Collaborator

Summary

  • Extract 6 public widget endpoints + 4 helpers (~520 lines) from orchestrator.pymodules/channels/widget/router_public.py
  • Modernize imports: async_*_manager → domain service singletons (widget_instance_service, chat_service, config_service, cloud_provider_service, amocrm_service, user_identity_service)
  • Remove 4 now-unused orchestrator imports (async_chat_manager, async_config_manager, async_widget_instance_manager, retry_on_busy)
  • Widget path resolution: Path(__file__).parents[3] instead of Path(__file__).parent (accounts for new module depth)
  • amoCRM helpers kept lazy (try/except) for graceful degradation
  • orchestrator.py: 4062 → 3544 lines (−518)

Endpoints moved

Method Path Purpose
GET /widget.js Dynamic widget script
GET /widget/status Widget enabled check
POST /widget/chat/session Create session
GET /widget/chat/session/{id} Get session
POST /widget/chat/session/{id}/stream SSE streaming
POST /widget/chat/session/{id}/contacts Submit contacts

Test plan

  • ruff check + ruff format --check — clean
  • pytest tests/ — 65 passed
  • Syntax verification via ast.parse

Closes #547

🤖 Generated with Claude Code

…router_public.py (#547)

Phase 4.2 — move 6 public widget endpoints + 4 helper functions (~520 lines)
from orchestrator.py to a dedicated router module. No authentication required
on these endpoints (public widget chat).

Endpoints moved:
- GET /widget.js — dynamic widget script generation
- GET /widget/status — widget enabled check
- POST /widget/chat/session — create chat session
- GET /widget/chat/session/{id} — get session with history
- POST /widget/chat/session/{id}/stream — SSE streaming response
- POST /widget/chat/session/{id}/contacts — submit contacts to amoCRM

Import modernization:
- async_widget_instance_manager → widget_instance_service (modules.channels.widget.service)
- async_chat_manager → chat_service (modules.chat.service)
- async_config_manager → config_service (modules.core.service)
- async_cloud_provider_manager → cloud_provider_service (modules.llm.service)
- async_amocrm_manager → amocrm_service (modules.crm.service)
- async_user_identity_manager → user_identity_service (modules.core.service)

4 unused orchestrator imports removed (async_chat_manager, async_config_manager,
async_widget_instance_manager, retry_on_busy).

orchestrator.py: 4062 → 3544 lines (−518)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@shikhalev shikhalev merged commit cade363 into main Mar 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 4.2: Widget public endpoints → modules/channels/widget/

1 participant