You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(dev): wire WSS tunnel into mirrorstack dev (--tunnel)
Closes the CLI-side gap. \`mirrorstack dev --tunnel\` now:
1. Loads credentials (errors out with login hint if expired)
2. POSTs /v1/tunnel/token to mirrorstack-dispatch → ttok + wss_url
3. Parses Config.ID out of main.go (the canonical module id)
4. Opens WSS, sends register {module_id, local_url, version}, awaits
register_ack with a 10s timeout
5. Holds the tunnel handle for the lifetime of the dev session
6. On Ctrl-C / module exit: shutdown signal → close frame → drop conn
The tunnel comes up BEFORE compose so a registration failure doesn't
waste the user's time bringing containers up first.
Notable wiring choices:
- \`new_multi_thread\` runtime with one worker, not \`new_current_thread\`.
The pinger / inbound-frame reader is a spawned task; current-thread
runtimes only tick during \`block_on\`, which would freeze the spawned
future the moment the connect call returned.
- Module identity comes from parsing \`Config.ID = "..."\` out of main.go.
That's the same value the SDK uses for \`mod_<id>\` schemas, and what
the CLI scaffold substituted from the platform UUID. A future PR can
switch to a \`.mirrorstack/meta.json\` written at scaffold time; for
now, parsing main.go is a one-line regex on a file whose shape we
control.
- New \`--local-url\` flag (default http://localhost:8080) tells dispatch
where to 302 incoming Leaf 1 calls. Most modules will run there, but
the SDK's HTTP listener is configurable, so the flag stays.
- New \`MIRRORSTACK_DISPATCH_URL\` env (default https://api.mirrorstack.ai
per ingress path-routing convention) overrides the dispatch base.
Adds \`tokio.rt-multi-thread\` feature; otherwise no new deps.
Test plan:
- [x] cargo test (43 pass; 5 new module_meta tests)
- [x] cargo clippy --all-targets -- -D warnings clean
- [x] cargo fmt --all -- --check clean
- [ ] After WS API GW IaC ships: \`mirrorstack dev --tunnel\` against a
deployed dispatch service, confirm register_ack arrives + browser
hits to /m/<module_id>/foo 302 to localhost
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments