oc_connect
Loading...
Searching...
No Matches
oc_connect.__main__ Namespace Reference

Functions

argparse.ArgumentParser _parser ()
str _grant_id (str grantee, str destination)
str _render_message (InboundMessage message)
InboundPoller _default_poller (*, CredentialBroker broker, DestinationStore destinations, CommsBus bus, InboxStore inbox, AuditStore audit, Outbox outbox, str destination_name, int long_poll_seconds)
int _inbox_loop (argparse.Namespace args, *, InboundPoller poller, WorkerReportStore reports, SessionAlertStore alerts, Callable[[str], None] output, Callable[[float], None] sleep, int|None poll_limit)
int _inbox_command (argparse.Namespace args, *, CredentialBroker broker, DestinationStore destinations, CommsBus bus, InboxStore inbox, AuditStore audit, Outbox outbox, WorkerReportStore reports, SessionAlertStore alerts, Callable[[str], None] output, Callable[..., InboundPoller] poller_factory, Callable[[float], None] sleep, int|None poll_limit)
int _relay_once (argparse.Namespace args, *, CredentialBroker broker, DestinationStore destinations, GrantStore grants, CommsBus bus, Outbox outbox, AuditStore audit, Callable[[str], None] output, ConnectorRegistry|None connectors, bool announce_empty=True)
int _relay_command (argparse.Namespace args, *, CredentialBroker broker, DestinationStore destinations, GrantStore grants, CommsBus bus, Outbox outbox, AuditStore audit, Callable[[str], None] output, ConnectorRegistry|None connectors, Callable[[float], None] sleep=time.sleep, int|None poll_limit=None)
int cli (Sequence[str]|None argv=None, *, Callable[[str], str] input_reader=input, Callable[[str], None] output=print, str|Path|None root=None, ConnectorRegistry|None connectors=None, Callable[..., InboundPoller] poller_factory=_default_poller, Callable[[float], None] sleep=time.sleep, int|None poll_limit=None)

Variables

str WORKER_REPORT_SECTION = "== lane: worker-reports (worker -> orchestrator) =="
str OPERATOR_SECTION = "== lane: inbound-telegram (operator -> orchestrator) =="
str SESSION_ALERT_SECTION = "== lane: session-alerts (product -> operator) =="

Detailed Description

Command-line setup, grant, send, inbox, and worker-report relay workflows.

Dependencies
------------
- oc_connect.audit (AuditStore, timestamp, utc_now - the audit trail and the grant command's timestamps)
- oc_connect.comms (CommsBus - the comms bus layout and the one-shot plan-219 state migration)
- oc_connect.connectors.telegram.destinations (DestinationStore - the named Telegram destinations)
- oc_connect.connectors.telegram.setup_flow (TelegramSetup, SetupCancelled - the setup command)
- oc_connect.connectors.telegram.transport (TelegramTransport - the Bot API transport of the default inbox poller)
- oc_connect.credentials (CredentialBroker, CredentialNotFoundError - the sidecar credential broker)
- oc_connect.delivery (OutboundSender, parse_choices, CHOICES_RULE - the send command and the relay send path)
- oc_connect.egress (EgressBlockedError - reports a relay the egress filter blocked)
- oc_connect.grants (GrantStore, GrantRequiredError - the grant command and send authorisation)
- oc_connect.hub_lane (HubLaneRelay, HubLaneStore, hub_lane_dir, HUB_LANE - relays the hub lane)
- oc_connect.inbound.classify (render_untrusted - the fenced display of operator messages)
- oc_connect.inbound.inbox (InboxStore, InboxStoreError - the inbox list, read and ack actions)
- oc_connect.inbound.poller (InboundPoller - fetches operator replies for the inbox command)
- oc_connect.outbox (Outbox - the durable outbox inside the comms bus)
- oc_connect.registry (ConnectorRegistry - the injectable outbound connector registry)
- oc_connect.session_alerts (SessionAlertRelay, SessionAlertStore, render_event - lists and relays the session-alerts lane)
- oc_connect.worker_reports (WorkerReportRelay, WorkerReportStore, render_event - lists and relays the worker-reports lane)
- oc_connect.workspace (state_dir, WorkspaceNotFoundError - the legacy state directory to migrate and the no-workspace exit)
- option_c_connector_contracts (ConnectorGrant, OperatorConsent, InboundMessage - grant records and inbox messages)

Function Documentation

◆ _default_poller()

InboundPoller oc_connect.__main__._default_poller ( * ,
CredentialBroker broker,
DestinationStore destinations,
CommsBus bus,
InboxStore inbox,
AuditStore audit,
Outbox outbox,
str destination_name,
int long_poll_seconds )
protected
Build the real poller; the credential never leaves this call.

Definition at line 205 of file __main__.py.

◆ _grant_id()

str oc_connect.__main__._grant_id ( str grantee,
str destination )
protected

Definition at line 186 of file __main__.py.

Here is the caller graph for this function:

◆ _inbox_command()

int oc_connect.__main__._inbox_command ( argparse.Namespace args,
* ,
CredentialBroker broker,
DestinationStore destinations,
CommsBus bus,
InboxStore inbox,
AuditStore audit,
Outbox outbox,
WorkerReportStore reports,
SessionAlertStore alerts,
Callable[[str], None] output,
Callable[..., InboundPoller] poller_factory,
Callable[[float], None] sleep,
int | None poll_limit )
protected
Run one inbox action; retention prunes on every invocation.

Definition at line 291 of file __main__.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _inbox_loop()

int oc_connect.__main__._inbox_loop ( argparse.Namespace args,
* ,
InboundPoller poller,
WorkerReportStore reports,
SessionAlertStore alerts,
Callable[[str], None] output,
Callable[[float], None] sleep,
int | None poll_limit )
protected
Poll on an interval, printing only arrivals, until interrupted.

Both lanes are polled on the same interval and each prints under its own
banner, so a worker report reaches the orchestrator the same way an
operator reply does. Worker reports are local files rather than transport
updates, so "new" is tracked here by event id rather than by a cursor.

Definition at line 230 of file __main__.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _parser()

argparse.ArgumentParser oc_connect.__main__._parser ( )
protected

Definition at line 76 of file __main__.py.

Here is the caller graph for this function:

◆ _relay_command()

int oc_connect.__main__._relay_command ( argparse.Namespace args,
* ,
CredentialBroker broker,
DestinationStore destinations,
GrantStore grants,
CommsBus bus,
Outbox outbox,
AuditStore audit,
Callable[[str], None] output,
ConnectorRegistry | None connectors,
Callable[[float], None] sleep = time.sleep,
int | None poll_limit = None )
protected
Relay the requested lane once, or on an interval under ``--loop``.

``--loop`` exists so an operator can leave the relay running beside the
inbox loop and have a session's cost alerts reach their phone as they
happen rather than at the next manual pass. It is bounded in tests by
*poll_limit* for the same reason ``inbox --loop`` is; production leaves it
``None`` and the loop runs until interrupted.

Definition at line 523 of file __main__.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _relay_once()

int oc_connect.__main__._relay_once ( argparse.Namespace args,
* ,
CredentialBroker broker,
DestinationStore destinations,
GrantStore grants,
CommsBus bus,
Outbox outbox,
AuditStore audit,
Callable[[str], None] output,
ConnectorRegistry | None connectors,
bool announce_empty = True )
protected
Relay one pass of the requested lane through the standard send path.

Both lanes share this body because both share the pipeline: the only thing
that varies is which store is read and how one delivered event prints.
*announce_empty* is false inside ``--loop``, where "nothing new" every ten
seconds is noise rather than information.

Definition at line 395 of file __main__.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _render_message()

str oc_connect.__main__._render_message ( InboundMessage message)
protected
Return one inbox entry; bodies appear only inside the ยง2 fence.

Definition at line 190 of file __main__.py.

Here is the caller graph for this function:

◆ cli()

int oc_connect.__main__.cli ( Sequence[str] | None argv = None,
* ,
Callable[[str], str] input_reader = input,
Callable[[str], None] output = print,
str | Path | None root = None,
ConnectorRegistry | None connectors = None,
Callable[..., InboundPoller] poller_factory = _default_poller,
Callable[[float], None] sleep = time.sleep,
int | None poll_limit = None )
Run the CLI and return a process exit code.

*root* pins the workspace explicitly instead of discovering it;
*connectors*, *poller_factory* and *sleep* inject the outbound registry,
the inbound transport and the loop clock. They exist so the suite can drive
the real command surface against a tmp workspace and a mock transport,
never the operator's live state or the network. *poll_limit* bounds
``--loop`` for the same reason; production leaves it ``None`` and the loop
runs until the operator interrupts it.

Definition at line 571 of file __main__.py.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ OPERATOR_SECTION

str oc_connect.__main__.OPERATOR_SECTION = "== lane: inbound-telegram (operator -> orchestrator) =="

Definition at line 72 of file __main__.py.

◆ SESSION_ALERT_SECTION

str oc_connect.__main__.SESSION_ALERT_SECTION = "== lane: session-alerts (product -> operator) =="

Definition at line 73 of file __main__.py.

◆ WORKER_REPORT_SECTION

str oc_connect.__main__.WORKER_REPORT_SECTION = "== lane: worker-reports (worker -> orchestrator) =="

Definition at line 71 of file __main__.py.