connect method

Future<void> connect()

Connects the socket, translating failure into the seam's error type.

VSCodeBridgeClient.connect answers with a bool rather than throwing, so the falsehood is what gets translated here.

Implementation

Future<void> connect() async {
  if (!await client.connect()) {
    throw LlmTransportException(
      LlmErrorKind.unreachable,
      // Reached only after the server was found — the hosted scan saw it, or
      // the standalone child printed its ready line — so the likeliest cause
      // is that it went away in between. That is what the sentence says to
      // do something about.
      'Could not connect to the AI server on ${client.host}:${client.port}, '
      'which answered moments ago. Try again; if it keeps failing, restart '
      'what runs it — the VS Code window for the hosted server, this app '
      'for the standalone one.',
      transportId: transportId,
    );
  }
}