Pydantic AI API¶
Install threvo-actions[pydantic-ai] before importing this module.
pydantic_ai ¶
Pydantic AI Capability for confirm-first financial actions.
SafeReference
module-attribute
¶
SafeReference = Annotated[str, StringConstraints(min_length=1, max_length=255), AfterValidator(_validate_safe_reference)]
_TOOL_NAME_PATTERN
module-attribute
¶
__all__
module-attribute
¶
__all__ = ['ActionAgentContext', 'ActionCapability', 'ActionContextResolver', 'ActionToolBinding', 'ActionToolResult', 'DeferredActionRequest', 'InlineAuthorityHandler', 'IntegrationOutcome']
ActionType ¶
EvidenceConsumer ¶
Bases: ExperimentalModel
ExperimentalModel ¶
Bases: BaseModel
Strict, immutable base for the experimental public contract.
model_config
class-attribute
instance-attribute
¶
LifecycleStatus ¶
ProposingAgent ¶
Bases: ExperimentalModel
RequestingPrincipal ¶
Bases: ExperimentalModel
kind
class-attribute
instance-attribute
¶
ReadContext ¶
Bases: ExperimentalModel
ActionOperationResult ¶
Bases: ExperimentalModel
display_preview
class-attribute
instance-attribute
¶
fresh_proposal_reference
class-attribute
instance-attribute
¶
fresh_proposal_reference: SafeReference | None = None
is_terminal
property
¶
Whether the proposal lifecycle has no valid transition left.
needs_reconciliation
property
¶
Whether authoritative reconciliation may advance this proposal.
ActionRuntime ¶
ActionRuntime(*, store: ActionStore, retention_store: RetentionStore | None = None, clock: Clock | None = None, identifiers: IdentifierProvider | None = None, event_sink: EventSink | None = None, runtime_revision: str | None = None)
Coordinates host-owned controls without owning host business truth.
prepare
async
¶
prepare(definition: ActionDefinition[CommandT, PrivateSnapshotT, PreviewT, ResultT], *, tenant_reference: str, command: CommandT, requesting_principal: RequestingPrincipal, proposing_agent: ProposingAgent | None = None) -> ActionOperationResult
record_authority
async
¶
record_authority(definition: ActionDefinition[CommandT, PrivateSnapshotT, PreviewT, ResultT], *, evidence: AuthorityEvidence, authenticated_authority: ConfirmingAuthority, proposal_reference: str | None = None) -> ActionOperationResult
expire_due
async
¶
expire_due(definition: ActionDefinition[CommandT, PrivateSnapshotT, PreviewT, ResultT], *, tenant_reference: str, proposal_reference: str) -> ActionOperationResult
Expire an unexecuted proposal once its prepared lifetime has elapsed.
execute
async
¶
execute(definition: ActionDefinition[CommandT, PrivateSnapshotT, PreviewT, ResultT], *, tenant_reference: str, proposal_reference: str) -> ActionOperationResult
reconcile
async
¶
reconcile(definition: ActionDefinition[CommandT, PrivateSnapshotT, PreviewT, ResultT], *, tenant_reference: str, proposal_reference: str) -> ActionOperationResult
read
async
¶
read(definition: ActionDefinition[CommandT, PrivateSnapshotT, PreviewT, ResultT], *, proposal_reference: str, context: ReadContext) -> ProposalView
erase
async
¶
erase(definition: ActionDefinition[CommandT, PrivateSnapshotT, PreviewT, ResultT], *, proposal_reference: str, context: ReadContext) -> ActionOperationResult
AuthorizationDeniedError ¶
Bases: PermissionError
OperationOutcome ¶
ActionDefinition
dataclass
¶
ActionDefinition(action_type: ActionType, command_model: type[CommandT], private_snapshot_model: type[PrivateSnapshotT], display_preview_model: type[PreviewT], result_model: type[ResultT], preparation: PreparationPort[CommandT, PrivateSnapshotT, PreviewT], authorization: AuthorizationPort[CommandT, PrivateSnapshotT], authority_evaluator: AuthorityEvaluatorPort, state_resolver: StateResolverPort[PrivateSnapshotT, PreviewT], executor: GovernedExecutorPort[PrivateSnapshotT, ResultT], verifier: VerifierPort[ResultT], commitment_provider: CommitmentProvider, protection_codec: ProtectionCodec, retention: RetentionPort, proposal_ttl: timedelta, executor_identity: GovernedExecutor, target_identity: AuthoritativeTarget, authority_audience: str, authority_channel_assurance: str, verification_delay: timedelta = timedelta(0), max_verification_attempts: int = 3, effect_kind: EffectKind = 'single', allow_resend_after_final_absence: bool = False, verification_lease_duration: timedelta = timedelta(minutes=1), semantic_idempotency_strategy: Literal['host_defined'] = 'host_defined')
Bases: Generic[CommandT, PrivateSnapshotT, PreviewT, ResultT]
ActionAgentContext ¶
IntegrationOutcome ¶
ActionToolResult ¶
Bases: ExperimentalModel
Display-safe result returned to the model after a continuation attempt.
proposal_reference
class-attribute
instance-attribute
¶
proposal_reference: SafeReference | None = None
lifecycle_status
class-attribute
instance-attribute
¶
lifecycle_status: LifecycleStatus | None = None
display_preview
class-attribute
instance-attribute
¶
display_preview: JsonObject = Field(default_factory=dict)
fresh_proposal_reference
class-attribute
instance-attribute
¶
fresh_proposal_reference: SafeReference | None = None
DeferredActionRequest ¶
ActionContextResolver ¶
Bases: Protocol[DepsContraT]
InlineAuthorityHandler ¶
Bases: Protocol[DepsContraT]
_ContinuationMetadata ¶
Bases: ExperimentalModel
_BuildableBinding ¶
Bases: Protocol[DepsContraT]
ActionToolBinding
dataclass
¶
ActionToolBinding(definition: ActionDefinition[CommandT, PrivateSnapshotT, PreviewT, ResultT], context_resolver: ActionContextResolver[DepsT], name: str, description: str)
Bases: Generic[DepsT, CommandT, PrivateSnapshotT, PreviewT, ResultT]
Explicitly binds one action definition to one model-visible tool.
definition
instance-attribute
¶
definition: ActionDefinition[CommandT, PrivateSnapshotT, PreviewT, ResultT]
ActionCapability
dataclass
¶
ActionCapability(*, runtime: ActionRuntime, bindings: Sequence[_BuildableBinding[DepsT]], inline_authority_handler: InlineAuthorityHandler[DepsT] | None = None, id: str = 'threvo_actions')
Bases: AbstractCapability[DepsT]
Expose confirm-first actions without trusting framework approval as authority.