move / dedup some wf_mcp things

This commit is contained in:
lda
2026-06-01 18:28:00 +07:00 Verified
parent 7af2355487
commit db91824861
7 changed files with 112 additions and 39 deletions
+12 -6
View File
@@ -1,10 +1,16 @@
"""Shared workflow-surface literals used by generated draft helpers."""
"""Compatibility shim for workflow API constants.
DEFAULT_CALL_STEP_ID = "call"
DEFAULT_ERROR_STEP_ID = "tool_error"
DEFAULT_OK_OUTCOME = "ok"
DEFAULT_ERROR_OUTCOME = "error"
RUNTIME_ERROR_CAPABILITY = "wf.std.runtime_error"
New code should import these literals from `wf_api.constants`. This module stays
so older MCP workflow-surface imports keep working during extraction.
"""
from wf_api.constants import (
DEFAULT_CALL_STEP_ID,
DEFAULT_ERROR_OUTCOME,
DEFAULT_ERROR_STEP_ID,
DEFAULT_OK_OUTCOME,
RUNTIME_ERROR_CAPABILITY,
)
__all__ = [
"DEFAULT_CALL_STEP_ID",
+7 -6
View File
@@ -47,20 +47,21 @@ from wf_core.models.steps import (
)
from wf_core.paths import GraphSourcePath, LocalPath, StatePath
from ..broker.service.adapters import require_adapter
from ..events import make_event
from ..models import RawWorkflowPlan
from ..shared import matches_query, paged_list_payload
from .constants import (
from wf_api.constants import (
DEFAULT_CALL_STEP_ID,
DEFAULT_ERROR_OUTCOME,
DEFAULT_ERROR_STEP_ID,
DEFAULT_OK_OUTCOME,
RUNTIME_ERROR_CAPABILITY,
)
from wf_api.refs import parse_workflow_surface_capability_id
from ..broker.service.adapters import require_adapter
from ..events import make_event
from ..models import RawWorkflowPlan
from ..shared import matches_query, paged_list_payload
from .models import TraceRange
from .next_actions import NextActions
from .refs import parse_workflow_surface_capability_id
from .saved_subgraphs import (
SavedSubgraphTree,
direct_wrapper_interrupt_diagnostic,
+12 -25
View File
@@ -1,28 +1,15 @@
from __future__ import annotations
"""Compatibility shim for workflow API capability refs.
from typing import Any, TypeAlias
New code should import from `wf_api.refs`. This module stays so older MCP
workflow-surface imports keep working during extraction.
"""
from wf_artifacts import WorkflowCapabilityRef
from wf_platform import CapabilityRef
from wf_api.refs import (
WorkflowSurfaceCapabilityId,
parse_workflow_surface_capability_id,
)
WorkflowSurfaceCapabilityId: TypeAlias = CapabilityRef | WorkflowCapabilityRef
def parse_workflow_surface_capability_id(
value: str | dict[str, Any],
) -> WorkflowSurfaceCapabilityId:
"""Parse a workflow-surface capability name into its real domain ref.
MCP tools still accept and return plain strings. Internally, workflow-facing
capability ids are either live source capabilities or saved wrapper
artifacts, so this parser avoids inventing a third identifier model.
"""
if isinstance(value, dict):
if "artifact_id" in value and "version" in value:
return WorkflowCapabilityRef._validate(value)
return CapabilityRef._validate(value)
try:
return WorkflowCapabilityRef.parse(value)
except ValueError:
return CapabilityRef.parse(value)
__all__ = [
"WorkflowSurfaceCapabilityId",
"parse_workflow_surface_capability_id",
]