360 Secure SkillHub
360 安全技能中心

a2a-Market-WebSocket-Realtime

这是为a2a市场打造的WebSocket实时推送框架,核心功能包括:为买卖方、管理员提供权限可控的订阅通道,推送意向创建、报价接收等交易全流程事件,支持基于游标重连回放错过的事件,以及心跳保活机制。典型用于市场客户端实现推送通道、订阅鉴权、会话生命周期管理。通过标准接口交互,输出版本兼容的结构化事件Payload,对非法请求返回规范错误码,目前是可发布的稳定契约框架,支持本地运行。

luoqianchenguni-max
luoqianchenguni-max
热度 49.15
最近更新 2026-05-11 17:33:38
分类:开发依赖:代码执行 / 读写文件 / 内部调用大模型应用场景:代码生成 / API 集成 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add a2a-market-websocket-realtime
Metadata
name
a2a-market-websocket-realtime
description
Deliver real-time websocket updates for intent, quote, negotiation, order, and payment events. Use when implementing push channels, subscription authorization, and connection/session lifecycle for market clients.

a2a-Market WebSocket Realtime

Set up realtime delivery skeleton for buyer and operator clients.

Current status: publishable framework with stable event contracts, not full scale tuning.

Scope

  • Define channel naming and auth guard for buyer, node, and admin roles.
  • Push canonical domain events with predictable payload shape.
  • Manage reconnect semantics and last-event cursor replay.

Suggested Project Layout

  • app/interfaces/ws/socket_gateway.py
  • app/application/services/realtime_service.py
  • app/infrastructure/ws/connection_registry.py
  • app/infrastructure/cache/replay_cursor_store.py

Minimum Contracts (MVP P0)

  1. subscribe(channel, cursor) validates permission and registers stream.
  2. publish_event(channel, event) fans out to online subscribers.
  3. resume(channel, cursor) replays missed events within retention window.
  4. heartbeat(connection_id) updates liveness and cleanup scheduling.

Required Event Coverage

  • INTENT_CREATED
  • QUOTE_RECEIVED
  • NEGOTIATION_STARTED
  • ORDER_CREATED
  • PAYMENT_SUCCEEDED

Guardrails

  • Keep payloads versioned and backward compatible.
  • Limit per-connection queue to prevent memory blowups.
  • Drop unauthorized subscription attempts with structured error codes.

Implementation Backlog

  • Add presence channels and typing/status hints for negotiation UI.
  • Add regional relay nodes for cross-region latency reduction.

Runtime Implementation

  • Status: implemented in local runtime package.
  • Primary code paths:
  • runtime/src/interfaces/ws/event-bus.js
  • Validation: covered by runtime/tests and npm test in runtime/.