Add assembly webhooks listen command for local webhook development#110
Merged
Conversation
Two features that close gaps the solutions org keeps rebuilding by hand: - `assembly transcribe <dir|glob> --llm "prompt"` now works in batch mode: the prompt chain runs per source once its transcription is recorded, landing under the sidecar's `transform` key. The chain resumes on its own — a failed gateway call leaves a resumable transcription, and a re-run (or changed prompts/--model) replays just the LLM step against the recorded transcript id, never a second transcription. - `assembly webhooks listen` (stripe-CLI style): binds a local sink, exposes it via a cloudflared quick tunnel, prints each delivery (NDJSON under --json), and can re-POST bodies to a local app with --forward-to. --no-tunnel, --max-events, and a --port floor cover local/scripted use. The cloudflared plumbing (require/install hint, quick-tunnel spawn with API-key-stripped env, terminate) moved from the share command into aai_cli/init/tunnel.py for reuse. https://claude.ai/code/session_01VLyrC2KRm8hbptLatHeFSh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
assembly webhooks listencommand that binds a local HTTP server to receive AssemblyAI webhook deliveries, exposes it via a cloudflared quick tunnel for public access, and prints each delivery as it arrives. This enables local webhook development without deploying a public endpoint.Key Changes
New
webhook_listenmodule (aai_cli/webhook_listen.py): Core engine for the webhook listenershape_event(): Parses incoming webhook bodies and pulls uptranscript_id/statusfields for AssemblyAI webhooksforward(): Re-POSTs deliveries to a local app via--forward-to, with failures reported on the event rather than to AssemblyAI_EventSink: Serializes concurrent handler threads into one printed record per delivery, with--max-eventssupportrun_listen(): Orchestrates the HTTP server, tunnel setup, and delivery loopNew
webhookscommand (aai_cli/commands/webhooks.py): CLI interface with options for:--port: Local listener port (default 8989)--forward-to: Optional URL to relay deliveries to a local app--no-tunnel: Local-only mode (skip cloudflared)--max-events: Exit after N deliveries (0 = run until Ctrl-C)--json: NDJSON output modeEnhanced tunnel infrastructure (
aai_cli/init/tunnel.py):require_cloudflared(): Centralized missing-dependency check with platform-specific install hintsopen_quick_tunnel(): Spawns cloudflared process, captures tunnel URL and logs, strips API key from environmentinstall_hint(): Platform-aware installation guidance (brew on macOS, docs link elsewhere)Refactored
sharecommand (aai_cli/commands/share.py): Moved cloudflared dependency logic totunnelmodule to avoid duplicationBatch LLM support (
aai_cli/transcribe_batch.py): Extended batch mode to support--llmchainstransformkey_transform_satisfied(): Detects when a sidecar already records the exact chain (same prompts + model)_resume_one(): Finishes sources with completed transcriptions, optionally replaying the chainComprehensive test coverage (
tests/test_webhook_listen.py,tests/test_transcribe_batch_llm.py):Updated help text and examples: Added webhook examples to transcribe command, updated batch mode documentation to mention LLM resumption
Notable Implementation Details
@pytest.mark.allow_hosts(["127.0.0.1"])to permit loopback binding while blocking external networkhttps://claude.ai/code/session_01VLyrC2KRm8hbptLatHeFSh