Skip to content

feat(memos-local-plugin): TCP-first bridge transport#1606

Open
Starfie1d1272 wants to merge 1 commit intoMemTensor:mainfrom
Starfie1d1272:feat/tcp-first-bridge
Open

feat(memos-local-plugin): TCP-first bridge transport#1606
Starfie1d1272 wants to merge 1 commit intoMemTensor:mainfrom
Starfie1d1272:feat/tcp-first-bridge

Conversation

@Starfie1d1272
Copy link
Copy Markdown

Summary

Add TCP transport layer for daemon bridge mode. The bridge can now run as a persistent daemon with a TCP JSON-RPC server, and the Python client connects via TCP-first with automatic fallback to stdio.

Changes

bridge/tcp.ts (new) — TCP JSON-RPC server that accepts connections from remote clients and dispatches through the same Dispatcher as stdio. Broadcasts events/logs to all connected clients.

bridge.cts--daemon and --tcp=<port> flags. In daemon mode the stdio server is skipped (stdin is /dev/null). Reads version from package.json instead of hardcoding.

bridge_client.pyprefer_tcp=True (new default): try TCP connect first at 127.0.0.1:18911, fall back to spawning a stdio subprocess on failure. Transparent to existing callers.

daemon_manager.py — PID file management under MEMOS_HOME, kill stale bridges before spawning new ones, macOS process detection via ps(1) fallback when /proc is absent.

Backward compatibility

  • All existing callers continue to work — prefer_tcp=True falls back transparently
  • MemosBridgeClient(prefer_tcp=False) forces stdio mode

🤖 Generated with Claude Code

Add TCP transport layer for daemon bridge mode:

- bridge/tcp.ts: new TCP JSON-RPC server for daemon mode
- bridge.cts: --daemon and --tcp=<port> flags, skip stdio in daemon mode,
  re-entrancy guard during shutdown, read version from package.json
- bridge_client.py: prefer_tcp=True by default, try TCP connect first,
  fall back to spawning stdio subprocess on failure
- daemon_manager.py: PID file management, kill stale bridges, macOS
  process detection via ps(1), register_bridge lifecycle
Copilot AI review requested due to automatic review settings May 1, 2026 06:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants