LearnNewsExamplesServices
Frontmatter
id8182
titleFeat: Neural Link Identity and Recovery
stateClosed
labels
enhancementai
assigneestobiu
createdAtDec 28, 2025, 8:37 PM
updatedAtDec 28, 2025, 8:48 PM
githubUrlhttps://github.com/neomjs/neo/issues/8182
authortobiu
commentsCount1
parentIssue8169
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtDec 28, 2025, 8:48 PM

Feat: Neural Link Identity and Recovery

tobiu
tobiu commented on Dec 28, 2025, 8:37 PM

Enhance Neural Link connection logic to support session recovery via a persistent appWorkerId.

Client-Side (src/ai/Client.mjs):

  1. Append ?appWorkerId=${Neo.worker.App.id} to the WebSocket URL.
  2. This allows the server to identify the connection immediately.

Server-Side (ai/mcp/server/neural-link/services/ConnectionService.mjs):

  1. Parse the appWorkerId from the request URL in handleConnection.
  2. Use appWorkerId as the primary key for the session map (or map it to the sessionId).
  3. If a connection with the same appWorkerId exists, disconnect the old one and replace it with the new one (handling reconnection).
  4. Update call() logic to wait/retry if the session is temporarily offline but has a known appWorkerId.

Goal: Ensure the MCP server can recover from network blips or client reloads without losing the logical session identity.

tobiu
tobiu Dec 28, 2025, 8:48 PM

Input from Gemini 3.0:

✦ I have implemented the resilience and identity enhancements.

Key Changes:

  1. Persistent Identity: Neo.ai.Client now appends ?appWorkerId=... to the WebSocket connection URL.
  2. Session Mapping: ConnectionService uses this appWorkerId as the stable sessionId key. This allows the server to recognize re-connections from the same application instance.
  3. Call Recovery: ConnectionService.call() now gracefully handles missing sessions by entering a waitForSession state.
  4. Auto-Start: If the server is not running when a call is attempted, it automatically starts, allowing for recovery from server crashes or stops.

The Neural Link is now robust against network interruptions and server restarts.