Files
EvoScientist-Multi/EvoScientist/gateway/__init__.py
T
Xi Zhang fb329e4aaa perf: cut startup latency — lazy import surface, langgraph dev keepalive, indexed thread listing (#407)
* feat: add thread metadata index for improved performance in thread listing

- Implemented a new SQLite index on the `checkpoints` table to optimize thread listing queries by indexing relevant metadata fields.
- Updated the `list_threads` function to ensure the index is created if it does not exist.
- Added a test to verify the creation of the metadata index during thread listing.

feat: enhance workspace sidecar management with owner tracking

- Modified the workspace sidecar to include `owner_pids` to track the current process owners.
- Updated tests to validate the new owner tracking functionality and ensure proper behavior when managing workspace sidecars.

chore: introduce model registry for streamlined model management

- Created a new `registry.py` file to maintain a comprehensive model registry, including model names, IDs, providers, and routing tables.
- Added functions to retrieve models by provider and list available models, enhancing the modularity and maintainability of model management.

* feat: enhance workspace sidecar management and improve thread metadata indexing

* fix(tests): ensure sidecar correctly registers owner with original workspace and pid

* refactor: simplify workspace sidecar management by removing owner tracking

* feat(server): add commands to manage background langgraph dev server

- Introduced `server_app` for managing the langgraph dev server with commands to check status and stop the server.
- Enhanced workspace sidecar management to include configuration fingerprint for drift detection.
- Updated deployment functions to handle server configuration and state more effectively.

* feat(server): enhance server status command to display PID with stale record warning

* feat(langgraph_dev): exclusion-set config fingerprint, webui keepalive, unified stop guidance

* fix(cli): platform-specific manual-stop hint; document keepalive endpoint-change limitation
2026-08-11 08:37:58 +01:00

86 lines
2.2 KiB
Python

"""Graph/thread gateway abstractions.
The gateway package is the migration seam between UI surfaces and graph
execution. CLI, TUI, channels, and future frontends should depend on this
package for thread/run operations instead of reaching directly into
``sessions.py``, ``stream.events``, or the LangGraph SDK.
Backend implementations are attached lazily via :mod:`lazy_loader` (SPEC-1 /
PEP 562): importing the shared :mod:`.types` protocols must not cascade into
``sessions``/langgraph/langgraph_sdk, which every CLI invocation would pay.
"""
from typing import TYPE_CHECKING
import lazy_loader as _lazy
from .types import (
DEFAULT_GRAPH_ID,
GraphEvent,
GraphGateway,
GraphRunInput,
GraphStateValues,
GraphTarget,
RunRequest,
ThreadResolution,
ThreadStore,
)
if TYPE_CHECKING:
# Static counterparts of the lazy attach below — type checkers don't
# infer names served through __getattr__.
from . import background_runs
from .local import LocalGraphGateway, LocalThreadStore
from .runtime import (
RuntimeGatewayBackend,
RuntimeGateways,
create_runtime_gateways,
)
from .server import (
LangGraphServerGateway,
LangGraphServerThreadStore,
)
__getattr__, _attach_dir, _ = _lazy.attach(
__name__,
submodules=["background_runs"],
submod_attrs={
"local": ["LocalGraphGateway", "LocalThreadStore"],
"runtime": [
"RuntimeGatewayBackend",
"RuntimeGateways",
"create_runtime_gateways",
],
"server": [
"LangGraphServerGateway",
"LangGraphServerThreadStore",
],
},
)
def __dir__() -> list[str]:
# attach() only knows the lazy names; include the eager type exports too.
return sorted(set(_attach_dir()) | set(__all__))
__all__ = [
"DEFAULT_GRAPH_ID",
"GraphEvent",
"GraphGateway",
"GraphRunInput",
"GraphStateValues",
"GraphTarget",
"LangGraphServerGateway",
"LangGraphServerThreadStore",
"LocalGraphGateway",
"LocalThreadStore",
"RunRequest",
"RuntimeGatewayBackend",
"RuntimeGateways",
"ThreadResolution",
"ThreadStore",
"background_runs",
"create_runtime_gateways",
]