photon_platform.clerk.actions

Declarative context-aware Action Registry and ecosystem tool adapters for Clerk.

Submodules

Attributes

ActionSafety

Classes

ActionRegistry

Central registry of context-aware actions shared by CLI, Web UI, and MCP.

ActionResult

Structured JSON-serializable output returned by every Clerk action.

ActionSpec

Declarative specification for one context-aware Clerk action.

Functions

get_default_registry() → ActionRegistry

Return the process-wide default ActionRegistry populated with built-ins and adapters.

Package Contents

class photon_platform.clerk.actions.ActionRegistry

Central registry of context-aware actions shared by CLI, Web UI, and MCP.

register(spec: ActionSpec) → None

Register or replace an ActionSpec by its unique id.

get(action_id: str) → ActionSpec | None

Look up an action by action_id.

list_all() → list[ActionSpec]

Return all registered actions sorted by category and id.

list_for_context(ctx: photon_platform.clerk.context.Context, *, include_interactive: bool = True) → list[ActionSpec]

Return all actions valid at ctx sorted by category and id.

execute(ctx: photon_platform.clerk.context.Context, action_id: str, params: dict[str, Any] | None = None, *, dry_run: bool = False, allow_interactive: bool = True) → ActionResult

Validate and execute a registered action against ctx.

Parameters:
  • ctx – Resolved Context for the target path.

  • action_id – Registered action identifier (e.g. "publish.build").

  • params – Optional parameter dictionary matching spec.input_schema.

  • dry_run – Request dry-run execution when supported by the action.

  • allow_interactive – Reject interactive GUI actions when False (e.g. MCP).

Returns:

Structured ActionResult.

class photon_platform.clerk.actions.ActionResult

Structured JSON-serializable output returned by every Clerk action.

ok: bool
action_id: str
path: str
dry_run: bool = False
summary: str = ''
data: dict[str, Any]
error: str | None = None
elapsed_ms: float = 0.0
to_dict() → dict[str, Any]

Serialize result to a JSON-compatible dictionary.

photon_platform.clerk.actions.ActionSafety
class photon_platform.clerk.actions.ActionSpec

Declarative specification for one context-aware Clerk action.

id: str
title: str
description: str
category: str
levels: frozenset[str]
handler: ActionHandler
key: str | None = None
requires: frozenset[str]
archetypes: frozenset[str] | None = None
safety: ActionSafety = 'read'
input_schema: dict[str, Any]
applies_to(ctx: photon_platform.clerk.context.Context) → bool

Return whether this action is valid for the given Context.

to_dict() → dict[str, Any]

Serialize metadata and JSON Schema (excluding the Python callable).

photon_platform.clerk.actions.get_default_registry() → ActionRegistry

Return the process-wide default ActionRegistry populated with built-ins and adapters.