Skip to content

API Reference parrot.outputs.a2ui.deeplink

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.outputs.a2ui.deeplink

View source

Deep-link token service (Module 8, goal G6).

requires_actions components on static (baked) surfaces cannot dispatch actions in v1 (no ActionRouter — FEAT-B). Each action degrades to a single-use, TTL-bound deep link: clicking it resumes the originating channel/session and injects the action as a structured user message.

Token strategy (spec §8): navigator_auth exposes a JWT create_token mint, but binding core to it would violate the one-way import rule (G8). This service therefore uses the pre-approved Redis opaque one-shot token — an opaque secrets.token_urlsafe(32) id whose server-side payload (session/user/agent/channel/action) is stored in Redis with a TTL and deleted on first consume. The URL embeds ONLY the opaque id — never the payload (spec §7). The Redis consume record is exactly the single-use/replay guard the spec mandates regardless of mint source.

Copies the one-shot nonce machinery of parrot.auth.oauth2_base (key template, token_urlsafe(32), TTL set, get → delete one-shot consume).

Class DeepLinkError

Base class for deep-link errors.

Class DeepLinkExpiredError

Raised when a token is missing, expired, or already consumed (single-use).

Class DeepLinkService

Mints and consumes single-use, TTL-bound deep-link tokens.

Parameter Type Default Description
redis Any An async Redis client exposing set(key, value, ex=...), get(key), and delete(key) coroutines (injected — mirrors oauth2_base).
base_url str '' Base URL for building resume links (e.g. https://app.example).
default_ttl int _DEFAULT_TTL_SECONDS Default token lifetime in seconds.
key_template str _KEY_TEMPLATE Redis key template with a {token_id} placeholder.

Method DeepLinkService.mint

Mint a single-use deep link for a degraded action.

mint(*, session_id: str, user_id: str, agent_id: str, channel: str, action_payload: dict[str, Any], ttl: Optional[int] = None) -> DeepLink

Parameter Type Default Description
session_id str Originating session id.
user_id str Originating user id.
agent_id str Originating agent id.
channel str Channel to resume (e.g. "web", "telegram", "msteams").
action_payload dict[str, Any] A v1.0 A2UIRendererMessage action envelope to inject on resume (server-side only) — see :class:ResumePayload.
ttl Optional[int] None Optional TTL override (seconds).

Returns: DeepLink — class:DeepLink whose URL embeds only the opaque token id.

Method DeepLinkService.consume

Consume a token exactly once, returning its server-side payload.

consume(token: str) -> ResumePayload

Parameter Type Default Description
token str The opaque token id from the deep-link URL.

Returns: ResumePayload — class:ResumePayload stored at mint time.

Raises:

  • DeepLinkExpiredError — If the token is missing, expired, or already used.

Class ResumePayload

Server-side payload restored when a deep link is consumed.

Never serialized into the token URL — it lives only in Redis (spec §7).

Fields:

Field Type Default Description
session_id str
user_id str
agent_id str
channel str
action_payload dict[str, Any] A v1.0 A2UI-A2A A2UIRendererMessage envelope whose message key is action (FEAT-470 G6) — i.e. {"version": "v1.0", "action": {...}}. Validated at construction time; a non-action (or otherwise malformed) envelope raises ValueError.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally