molecule-sdk-python/tests
Hongming Wang 70d66cd814 feat: poll-mode inbound delivery + molecule connect CLI (Phase 30.8c)
External agents that can't expose a public HTTP endpoint (laptops behind
NAT, ephemeral CI runners, hermes self-hosted, codex et al) had to reverse-
engineer the activity-poll loop from molecule-mcp-claude-channel/server.ts
because the SDK only shipped the push-mode `A2AServer` (Phase 30.8b).

This adds the complementary path:

- `RemoteAgentClient.fetch_inbound(since_id=…)` — one-shot GET against
  `/workspaces/:id/activity?type=a2a_receive&since_id=…`. Cursor-loss (410)
  surfaces as `CursorLostError`; caller resets and re-polls.
- `RemoteAgentClient.reply(msg, text)` — smart-routes to `/notify` for
  canvas users, `/a2a` (JSON-RPC envelope + X-Source-Workspace-Id) for peer
  agents. Hides the reply-path bifurcation from connector authors.
- `PollDelivery` / `PushDelivery` / `InboundDelivery` protocol — same
  `MessageHandler` callback works for both transports.
- `RemoteAgentClient.run_agent_loop(handler, delivery=None)` — combined
  heartbeat + state-poll + inbound dispatch. Defaults to `PollDelivery`.
  Async handlers detected and `asyncio.run`'d (matches A2AServer pattern).
  Sleep cadence = min(heartbeat_interval, delivery.interval).
- `python -m molecule_agent connect` CLI — one-line bootstrap. Loads a
  user's `module:function` via importlib, registers, runs the loop until
  pause/delete or SIGTERM. All flags also read from environment variables.

Tests: 50 new (test_inbound.py, test_cli_connect.py) covering every prod
branch — source normalization, cursor advancement, 410 reset, async/sync
handler dispatch, handler exception → log+continue+advance, smart-reply
routing for canvas vs peer vs unknown sources, run_agent_loop terminal
states, sleep-interval selection, CLI handler resolution failures.

Resolves #17.
2026-04-30 13:03:44 -07:00
..
conftest.py feat(tests): GAP-05 add _get_with_retry() with 429 back-off + fix broken test_call_peer_errors 2026-04-23 18:18:12 +00:00
test_a2a_server.py feat(sdk): add A2AServer for Phase 30.8b inbound A2A support 2026-04-23 22:50:19 +00:00
test_call_peer_errors.py feat(tests): GAP-05 add _get_with_retry() with 429 back-off + fix broken test_call_peer_errors 2026-04-23 18:18:12 +00:00
test_cli_connect.py feat: poll-mode inbound delivery + molecule connect CLI (Phase 30.8c) 2026-04-30 13:03:44 -07:00
test_inbound.py feat: poll-mode inbound delivery + molecule connect CLI (Phase 30.8c) 2026-04-30 13:03:44 -07:00
test_remote_agent.py feat(sdk): add idempotency-key delegation to RemoteAgentClient 2026-04-23 18:18:23 +00:00
test_retry_backoff.py feat(tests): GAP-05 add _get_with_retry() with 429 back-off + fix broken test_call_peer_errors (#11) 2026-04-21 07:08:01 +00:00
test_safe_extract.py fix(tests): add conftest.py + fix test_call_peer_errors.py broken imports 2026-04-23 18:18:10 +00:00
test_sdk.py fix(tests): add pytest-asyncio markers to async adaptor tests (#4) 2026-04-21 00:54:07 +00:00
test_sha256_verification.py fix(tests): add conftest.py + fix test_call_peer_errors.py broken imports 2026-04-23 18:18:10 +00:00
test_validators.py feat: initial Python SDK (extracted from molecule-monorepo/sdk/python) 2026-04-16 03:15:38 -07:00