the Stores

This commit is contained in:
lda
2026-06-02 11:03:05 +07:00 Verified
parent 10eaaec737
commit 09995d86d5
20 changed files with 707 additions and 68 deletions
+5 -8
View File
@@ -3,11 +3,7 @@ from __future__ import annotations
import json
from pathlib import Path
from wf_artifacts import (
FileDraftWorkspaceStore,
FileRunStore,
FileWorkflowArtifactStore,
)
from wf_api import file_workflow_stores
from ..control import BrokerConfigFile
from ..models import BrokerConfig
@@ -27,11 +23,12 @@ def load_broker_config(path: str | Path) -> BrokerConfig:
def build_service_from_config(config: BrokerConfig) -> WfMcpService:
"""Create a broker service with SDK adapters for configured connections."""
runtime_factory = PersistentSessionFactory()
workflow_stores = file_workflow_stores(config.store_root)
service = WfMcpService(
store=FileStore(config.store_root),
artifact_store=FileWorkflowArtifactStore(config.store_root),
draft_workspace_store=FileDraftWorkspaceStore(config.store_root),
run_store=FileRunStore(config.store_root),
artifact_store=workflow_stores.artifact_store,
draft_workspace_store=workflow_stores.draft_workspace_store,
run_store=workflow_stores.run_store,
# Discovery can use short-lived SDK sessions. Workflow execution needs
# a persistent runtime so stateful MCP servers keep session/page state
# across sequential workflow nodes.
+6 -19
View File
@@ -2,16 +2,12 @@ from __future__ import annotations
import time
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any
from pydantic import BaseModel
from wf_artifacts import (
DraftWorkspaceStore,
FileDraftWorkspaceStore,
FileRunStore,
FileWorkflowArtifactStore,
RunStore,
WorkflowArtifact,
WorkflowArtifactCatalogEntry,
@@ -68,12 +64,6 @@ from .builtins import builtin_sources
from .specs import get_qualified_spec, qualify_spec
def _store_root(store: Store) -> Path:
"""Return the file root for stores that expose one, else use local default."""
root = getattr(store, "root", None)
return root if isinstance(root, Path) else Path(".wf_mcp_store")
@dataclass(slots=True)
class WfMcpService:
store: Store
@@ -89,15 +79,12 @@ class WfMcpService:
tool_executor: ToolExecutor | None = None
def __post_init__(self) -> None:
"""Install broker-local system specs when enabled."""
if self.artifact_store is None:
self.artifact_store = FileWorkflowArtifactStore(_store_root(self.store))
if self.draft_workspace_store is None:
self.draft_workspace_store = FileDraftWorkspaceStore(
_store_root(self.store)
)
if self.run_store is None:
self.run_store = FileRunStore(_store_root(self.store))
"""Install broker-local system specs when enabled.
Workflow stores are injected by entrypoint/config construction. This service
must not guess workflow persistence from the MCP catalog/auth store because
CLI, MCP, and future HTTP frontends may share or swap those stores.
"""
if self.include_builtin_specs:
for source in builtin_sources().values():
self.register_capability_source(source)