feat: expose read-only admin surface

This commit is contained in:
lda
2026-06-03 22:15:11 +07:00 Verified
parent f0d0cffa17
commit 6a9c71b5d9
23 changed files with 498 additions and 22 deletions
+2
View File
@@ -5,6 +5,7 @@ from typing import Annotated
import typer
from .commands import (
admin,
artifacts,
caps,
deployments,
@@ -62,6 +63,7 @@ app.add_typer(artifacts.app, name="artifact")
app.add_typer(deployments.app, name="deploy")
app.add_typer(runs.app, name="run")
app.add_typer(sources.app, name="source")
app.add_typer(admin.app, name="admin")
app.add_typer(docs.app, name="docs")
app.add_typer(schema.app, name="schema")
app.command("explain")(explain.explain_command)
+72
View File
@@ -0,0 +1,72 @@
from __future__ import annotations
import asyncio
from typing import Annotated
import typer
from wf_cli.context import load_cli_context_from_typer
from wf_cli.formats import ListOutputFormat, emit_list_payload
app = typer.Typer(
name="admin",
help="Read workflow server admin and config state.",
no_args_is_help=True,
)
@app.command("connections")
def list_connections(
ctx: typer.Context,
output_format: Annotated[
ListOutputFormat, typer.Option("--format", help="Output format.")
] = ListOutputFormat.JSON,
) -> None:
"""List configured upstream connections known to the target."""
context = load_cli_context_from_typer(ctx)
payload = asyncio.run(context.admin.list_connections())
emit_list_payload(
payload,
collection_key="connections",
output_format=output_format,
id_field="id",
summary_fields=("server", "account", "enabled"),
)
@app.command("statuses")
def get_connection_statuses(
ctx: typer.Context,
output_format: Annotated[
ListOutputFormat, typer.Option("--format", help="Output format.")
] = ListOutputFormat.JSON,
) -> None:
"""List connection catalog/status summaries."""
context = load_cli_context_from_typer(ctx)
payload = asyncio.run(context.admin.get_connection_statuses())
emit_list_payload(
payload,
collection_key="statuses",
output_format=output_format,
id_field="connection_id",
summary_fields=("server", "account", "enabled", "has_snapshot"),
)
@app.command("events")
def list_events(
ctx: typer.Context,
output_format: Annotated[
ListOutputFormat, typer.Option("--format", help="Output format.")
] = ListOutputFormat.JSON,
) -> None:
"""List recorded workflow platform events."""
context = load_cli_context_from_typer(ctx)
payload = asyncio.run(context.admin.list_events())
emit_list_payload(
payload,
collection_key="events",
output_format=output_format,
id_field="kind",
summary_fields=("connection_id", "capability_id", "workflow_name"),
)
+10
View File
@@ -10,6 +10,8 @@ from pydantic import ValidationError
from wf_api import (
WorkflowApi,
WorkflowAdminApi,
WorkflowAdminSurface,
WorkflowApiSurface,
WorkflowSourceAdminApi,
WorkflowSourceAdminSurface,
@@ -35,6 +37,7 @@ class CliContext:
service: WfMcpService | None
handlers: WorkflowApiSurface
source_admin: WorkflowSourceAdminSurface
admin: WorkflowAdminSurface
@dataclass(frozen=True)
@@ -116,6 +119,7 @@ def load_cli_context(
service=None,
handlers=client,
source_admin=client,
admin=client,
)
if _is_legacy_mcp_config(resolved_config_path):
@@ -126,6 +130,10 @@ def load_cli_context(
service=service,
handlers=WorkflowApi(context_from_service(service)),
source_admin=WorkflowSourceAdminApi(context_from_service(service)),
admin=WorkflowAdminApi(
connections=service.connection_service,
events=service.events,
),
)
config = load_workflow_config(resolved_config_path)
@@ -140,6 +148,7 @@ def load_cli_context(
service=None,
handlers=server.api,
source_admin=server.source_admin,
admin=server.admin,
)
if isinstance(target, RpcHttpTargetConfig):
client = RpcWorkflowApiClient(
@@ -155,6 +164,7 @@ def load_cli_context(
service=None,
handlers=client,
source_admin=client,
admin=client,
)
raise ValueError(f"unsupported workflow target {target!r}")