Skip to content

[bug] Fix /llmesh/file/1.0.0 transfer and agent file handler #2

@Nkovaturient

Description

@Nkovaturient

Description

  • Protocol and UI hooks exist (sendFile, node.handle('/llmesh/file/1.0.0')). Transfers fail in practice; received-file UI is incomplete.
Browser Console logs
[P2P] Spawning browser libp2p node (ws + circuit-relay + gossipsub)...
stores.js:13 [P2P] Node ready as nGDFs6pe
extension-provider.js:13 📦 Registering extension: echo v1.0.0 at /uc/extension/echo/1.0.0
extension-provider.js:92  Extension echo registered and will be advertised via Identify
stores.js:13 [P2P] Example extension registered: echo
chatroom.js:67 [CHAT] Subscribed to topic: universal-connectivity
chatroom.js:70 [CHAT] Subscribed to discovery topic: universal-connectivity-browser-peer-discovery
chatroom.js:105 [CHAT] Message handlers registered successfully
chatroom.js:46 [CHAT] Joined chat room as: nGDFs6pe
ucep-client.js:26 🔍 Extension Test Client: Starting...
ucep-client.js:33  Extension Test Client: Listening for extensions
stores.js:13 [P2P] UCEP extension discovery client initialized
gossipsub-extension-manager.js:32 📡 GossipSub Extension Manager: Starting...
gossipsub-extension-manager.js:36  Subscribed to extension discovery topic: universal connectivity
gossipsub-extension-manager.js:47  GossipSub Extension Manager: Listening for extensions
stores.js:13 [P2P] GossipSub extension manager initialized
p2p.js:210 🌐 Extension commands available:
p2p.js:211   - window.listExtensions() - List all discovered extensions
p2p.js:212   - window.testExtension(id, cmd, args) - Test UCEP extension
p2p.js:213   - window.installExtension(id) - Install GossipSub extension
p2p.js:214   - window.executeExtensionCommand(id, cmd, args) - Execute GossipSub extension command
stores.js:13 [P2P] Dialing Agent at /ip4/127.0.0.1/tcp/54006/ws/p2p/12D3KooWPjLTB6oCBz7RAV9cX6APbFBY3CtMUhHjhdZ9QoB8xANT
stores.js:13 [P2P] Connected to peer QoB8xANT
stores.js:13 [P2P] Identify complete with QoB8xANT
ucep-client.js:43 🔍 Peer identified: 12D3KooW... with 12 protocols
ucep-client.js:51 📦 Found extension: echo v1.0.0 from peer 12D3KooW...
extension-provider.js:46  Sent manifest for echo
chatroom.js:87 [GOSSIPSUB] subscription-change from QoB8xANT: [{"topic":"universal-connectivity","subscribe":true},{"topic":"universal-connectivity-workshop-js-peer-discovery","subscribe":true}]
chatroom.js:92 [GOSSIPSUB]  Peer QoB8xANT subscribed to universal-connectivity
chatroom.js:99 [GOSSIPSUB] Mesh snapshot: 1 subscriber(s)
chatroom.js:100 [GOSSIPSUB]   - QoB8xANT
ucep-client.js:92 🔍 Extension Test Client: Received response: Object
ucep-client.js:61  Extension discovered: Echo Extension
ucep-client.js:62    Description: Echoes back messages for testing UCEP
ucep-client.js:63    Commands: echo, ping
2stores.js:13 [P2P] Message from QoB8xANT
stores.js:13 [P2P] Mesh formed with 1 peer(s)
stores.js:13 [P2P] Mesh active with 1 peer(s)
chatroom.js:200 [CHAT] Publishing message to 1 peer(s) in mesh
chatroom.js:207 [CHAT]  Message sent: "Hello! I'm nGDFs6pe - ready to chat!"
chatroom.js:200 [CHAT] Publishing message to 1 peer(s) in mesh
chatroom.js:207 [CHAT]  Message sent: "echo "hii""
chatroom.js:200 [CHAT] Publishing message to 1 peer(s) in mesh
chatroom.js:207 [CHAT]  Message sent: "ping"
stores.js:13 [P2P] Sending file chainpulse-logo.png to QoB8xANT...
Local terminal p2p node logs
 app git:(main)  npm start    

> p2p-x@1.0.0 start
> tsx index.js

Starting Universal Connectivity Application...
[SYSTEM] Generated Peer ID: 12D3KooWEMp3b4FvGLfbaoLJrdyw81rU4Rboo8n8PsAURwzZ2RMs
[SYSTEM] Node started successfully
[SYSTEM] Listening on 6 address(es):
[SYSTEM]   /ip4/127.0.0.1/tcp/54005/p2p/12D3KooWPjLTB6oCBz7RAV9cX6APbFBY3CtMUhHjhdZ9QoB8xANT
[SYSTEM]   /ip4/192.168.0.4/tcp/54005/p2p/12D3KooWPjLTB6oCBz7RAV9cX6APbFBY3CtMUhHjhdZ9QoB8xANT
[SYSTEM]   /ip4/127.0.0.1/tcp/54006/ws/p2p/12D3KooWPjLTB6oCBz7RAV9cX6APbFBY3CtMUhHjhdZ9QoB8xANT
[SYSTEM]   /ip4/192.168.0.4/tcp/54006/ws/p2p/12D3KooWPjLTB6oCBz7RAV9cX6APbFBY3CtMUhHjhdZ9QoB8xANT
[SYSTEM]   /ip4/127.0.0.1/udp/54004/webrtc-direct/certhash/uEiBUdI2Rwd-edHCRAp0dSvUhfA-1rlHBPASdYujMbSBwmw/p2p/12D3KooWPjLTB6oCBz7RAV9cX6APbFBY3CtMUhHjhdZ9QoB8xANT
[SYSTEM]   /ip4/192.168.0.4/udp/54004/webrtc-direct/certhash/uEiBUdI2Rwd-edHCRAp0dSvUhfA-1rlHBPASdYujMbSBwmw/p2p/12D3KooWPjLTB6oCBz7RAV9cX6APbFBY3CtMUhHjhdZ9QoB8xANT
[DHT] Kademlia DHT initialized in server mode
📦 Registering extension: echo v1.0.0 at /uc/extension/echo/1.0.0
 Extension echo registered and will be advertised via Identify
[UCEP] Example extension registered: echo
[UCEP] LLM extension registered: alien-x-llm
🔍 Extension Test Client: Starting...
 Extension Test Client: Listening for extensions
[UCEP] Extension discovery client initialized

[CHAT] Initializing chat room...
[CHAT] Subscribed to topic: universal-connectivity
[CHAT] Subscribed to discovery topic: universal-connectivity-workshop-js-peer-discovery
[CHAT] Message handlers registered successfully
[CHAT] Joined chat room as: QoB8xANT
[SYSTEM] No remote peers specified - running in standalone mode
[CHAT] Waiting for Identify protocol to exchange supported protocols...
[CHAT] Waiting for Identify protocol(s) that advertise pubsub...
[CHAT] Warning: no peer advertised gossipsub within timeout. Continuing checks...
[CHAT] Checking Gossipsub status...
[DEBUG] Connected to 0 peer(s):
[DEBUG] Local subscriptions: universal-connectivity, universal-connectivity-workshop-js-peer-discovery
[DEBUG] Topic "universal-connectivity": 0 peer(s)
[DEBUG] Topic "universal-connectivity-workshop-js-peer-discovery": 0 peer(s)
[CHAT] Waiting up to 10 seconds for mesh to form...
[CHAT] Check 1/10: 0 peer(s) in mesh
[CHAT] Check 2/10: 0 peer(s) in mesh
[CHAT] Check 3/10: 0 peer(s) in mesh
[CHAT] Check 4/10: 0 peer(s) in mesh
[CONNECTION] Connected to peer: 12D3KooWFpiW6kb4rTxEknxvR5Koy9ih2iuN8FzszE7enGDFs6pe
[IDENTIFY] Received identify from: 12D3KooWFpiW6kb4rTxEknxvR5Koy9ih2iuN8FzszE7enGDFs6pe
[IDENTIFY]   Protocol Version: ipfs/0.1.0
[IDENTIFY]   Agent Version: js-libp2p/3.1.2 browser/Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
[IDENTIFY]   Protocols: 9 protocol(s)
[IDENTIFY]     - /floodsub/1.0.0
[IDENTIFY]     - /ipfs/id/1.0.0
[IDENTIFY]     - /ipfs/ping/1.0.0
[IDENTIFY]     - /libp2p/circuit/relay/0.2.0/stop
[IDENTIFY]     - /llmesh/file/1.0.0
[IDENTIFY]     ... and 4 more
[IDENTIFY]   Addresses: 0 address(es)
🔍 Peer identified: 12D3KooW... with 9 protocols
📦 Found extension: echo v1.0.0 from peer 12D3KooW...
[GOSSIPSUB] subscription-change from nGDFs6pe: [{"topic":"universal-connectivity","subscribe":true},{"topic":"universal-connectivity-browser-peer-discovery","subscribe":true},{"topic":"universal connectivity","subscribe":true}]
[GOSSIPSUB]  Peer nGDFs6pe subscribed to universal-connectivity
[GOSSIPSUB] Mesh snapshot: 1 subscriber(s)
[GOSSIPSUB]   - nGDFs6pe
 Sent manifest for echo
🔍 Extension Test Client: Received response: {
  payload: undefined,
  hasManifest: true,
  hasCommand: false,
  responseKeys: [ 'manifest' ],
  manifestData: {
    timestamp: 1779047943469n,
    manifest: {
      id: 'echo',
      name: 'Echo Extension',
      version: '1.0.0',
      description: 'Echoes back messages for testing UCEP',
      author: 'Universal Connectivity',
      publicUrl: '',
      commands: [Array],
      icon: ''
    }
  }
}
 Extension discovered: Echo Extension
   Description: Echoes back messages for testing UCEP
   Commands: echo, ping
[CHAT] Check 5/10: 1 peer(s) in mesh
[CHAT]  Mesh formed with 1 peer(s)!

============================================================
 GOSSIPSUB MESH SUCCESSFULLY FORMED!
============================================================
[CHAT] Connected to 1 peer(s) in mesh:
[CHAT]    12D3KooWFpiW6kb4rTxEknxvR5Koy9ih2iuN8FzszE7enGDFs6pe
============================================================
 READY TO CHAT!

[CHAT] Publishing message to 1 peer(s) in mesh
[CHAT]  Message sent: "Hello! I'm QoB8xANT - ready to chat!"

============================================================
  Welcome to Universal Connectivity Chat!
============================================================
  Your nickname: QoB8xANT
  Peer ID: 12D3KooWPjLTB6oCBz7RAV9cX6APbFBY3CtMUhHjhdZ9QoB8xANT
  Type messages and press Enter to send
  Press Ctrl+C to exit
============================================================

[QoB8xANT]> [CHAT] Publishing message to 1 peer(s) in mesh
[CHAT]  Message sent: "QoB8xANT has joined the chat!"
[nGDFs6pe]: Hello! I'm nGDFs6pe - ready to chat!
[nGDFs6pe]: echo "hii"
[nGDFs6pe]: ping
[FILE] Incoming file stream from nGDFs6pe
[CONNECTION] Disconnected from peer: 12D3KooWFpiW6kb4rTxEknxvR5Koy9ih2iuN8FzszE7enGDFs6pe
[CONNECTION] Connection closed
[FILE] Error handling incoming file stream: DOMException [AbortError]: This operation was aborted
    at new DOMException (node:internal/per_context/domexception:76:18)
    at AbortController.abort (node:internal/abort_controller:506:18)
    at AbortSignal.onAbort (/Users/matrix/Documents/Season1/libp2p-ai/p2p-X/web/app/node_modules/any-signal/src/index.ts:14:16)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:845:20)
    at AbortSignal.dispatchEvent (node:internal/event_target:778:26)
    at runAbort (node:internal/abort_controller:488:10)
    at abortSignal (node:internal/abort_controller:459:3)
    at Timeout._onTimeout (node:internal/abort_controller:152:7)
    at listOnTimeout (node:internal/timers:608:17)
    at process.processTimers (node:internal/timers:543:7)
[CHAT] Publishing message to 1 peer(s) in mesh
[CHAT] ⚠️  Gossipsub error: No peers subscribed to topic
[CHAT] This means the mesh hasn't formed yet or peers disconnected
[CONNECTION] Disconnected from peer: 12D3KooWFpiW6kb4rTxEknxvR5Koy9ih2iuN8FzszE7enGDFs6pe
[CONNECTION] Connection closed
[QoB8xANT]> 

Problem defined

Observed (local ws mesh):
- Browser: [P2P] Sending file chainpulse-logo.png to QoB8xANT...
- Agent: [FILE] Incoming file stream from nGDFs6pe → peer disconnect → AbortError: This operation was aborted during for await (const chunk of stream).
- Mesh publish then fails: Gossipsub error: No peers subscribed to topic.

Code issues:
- Sender: dialProtocol(multiaddr('/p2p/${id}'), '/llmesh/file/1.0.0') + writeStreamWithSend with AbortSignal.timeout on drain/close — may abort receiver mid-read.
- Agent: llmService.analyzeFile(...) called but llmService is never constructed (new LLMService() missing).
- Browser receiver populates receivedFiles store; no UI renders downloads for peer-to-peer receives.
- File picker always targets getAgentPeerId() only (no mesh peer selection).

Acceptance Criteria

  • Send PNG/text (≥100KB) browser → terminal over active /ws connection without disconnect/AbortError.
  • Agent logs full receive: filename + byte length; publishes LLM analysis (or clear error) to gossipsub mesh.
  • llmService initialized once; file handler and UCEP chat share same LLMService instance.
  • Sender shows success/failure in chat UI (not silent failure).
  • Browser-side receive: incoming files from peers appear in UI (use receivedFiles store).
  • Document supported types (text, image) and Ollama llava requirement for images in app/README.md.

Expected Demo

  1. cd p2p-X/web/app && npm start — copy /ws multiaddr.
  2. cd p2p-X/web && npm run dev — connect, wait for MESH SYNCED.
  3. Attach .png, small .txt or any file via chat file control.
  4. Pass: agent terminal shows received bytes + mesh message with analysis; browser shows success.
  5. Fail today: agent AbortError + optional gossipsub publish error (see terminal log excerpt in issue body).

Out of Scope: File transfer over HTTPS/Vercel → agent depends on production dial path (webrtc-direct / WSS / relay).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions