Commit Graph

2 Commits

Author SHA1 Message Date
alt-glitch
1fadfed3f1 fix(shared): the gateway client's terminal-failure hook names its own line; test the default path
Review of the move:

- `isTerminalConnectFailure` becomes `terminalConnectFailure`, which returns the line to report.
  The shared client no longer parses Ink's `gateway unavailable:` format; Ink's subclass does, and
  logs the same line as before.
- apps/shared/src/node/gateway-client.test.ts runs the client with only `connect` (no Ink
  options): it dials the grant with its subprotocols, reads runtime.describe before readiness,
  creates a `source: tui` session, rejects a pending request with the English close text, and
  redials through `connect(false, true)`.
- Docs say sessions are created with `source: "tui"` and that `hermes gateway attach` comes with
  #142159; option and file comments are corrected (connection fields, `text`, prompt-history's
  HERMES_HOME, the i18n and helper comments that named the old files).
- Duplicate `@hermes/shared/gateway-types` imports are merged, and apps/shared/tsconfig.json keeps
  its original formatting.
2026-11-06 11:14:34 -05:00
alt-glitch
ab334f6fdd refactor(tui): move the gateway client into @hermes/shared so other clients skip Ink's source
A third-party Node frontend had to compile ui-tui's private source to talk to the gateway:
gatewayClient.ts, canonicalGateway.ts, gatewayTypes.ts and the slash, history and provider
helpers beside them. hermes-tern bundles 36 such imports through a `.hermes-src` alias.

The renderer-free client now lives in apps/shared:

- src/node/gateway-client.ts: transport, ticketed dial, runtime.describe, the session.create
  contract, reconnect and bounded owner recovery, typed request/events (Node-only).
- src/gateway-canonical.ts, src/gateway-types.ts, src/gateway-text.ts: the hermes-gateway-v1
  request/result translation, the typed results (SessionInfo and SlashCategory with them) and
  the client's English text, keyed by Ink's catalog keys.
- src/slash-input.ts, slash-score.ts, provider-names.ts, interpolation.ts, circular-buffer.ts and
  src/node/prompt-history.ts: helpers with no Ink or React import, moved as they were.

Everything Ink-specific became a constructor option that Ink's own GatewayClient
(ui-tui/src/gatewayClient.ts) passes exactly as before: `connect` (its gateway_bootstrap.py
helper), the terminal-failure predicate, HERMES_TUI_GATEWAY_URL / _SIDECAR_URL, the startup and
RPC timeouts, the launch tool-progress pin, the crash-log breadcrumbs, its i18n `t`, and undici
as the WebSocket when the runtime has none. The launcher's env parsing stays in Ink
(launchOptions.ts). Node-only modules sit in src/node, which the web app's typecheck excludes;
the package typechecks src and src/node with separate configs, and boundary.test.ts fails if
its program ever includes another workspace's file. apps/shared now runs its tests in `check`.
2026-11-06 11:14:34 -05:00