Files
hermes-agent/apps/shared/src/index.ts
T
teknium1 bab5cece78 refactor(ts): one reconnect backoff in apps/shared; web events feed rides the shared client and survives reconnects
Four backoff formulas (ui-tui 1000/30s, desktop 300/15s jittered, web events
1000/30s, web PTY inline 250/3s cap 5 — untested) collapse into
apps/shared/src/reconnect-backoff.ts::reconnectBackoffDelayMs(attempt,
{baseDelayMs, capMs, jitter}). Every caller keeps its own parameters
(table in the PR body); the PTY ladder gains a test.

web/src/components/ChatSidebar.tsx hand-rolled a third WebSocket frame
dispatcher (`new WebSocket` + JSON.parse + `frame.method === "event"` switch
+ a private RpcEnvelope re-declaring shared JsonRpcFrame) for /api/events.
That socket now goes through EventsFeedClient, a notification-only subclass
of the shared JsonRpcGatewayClient (replay off, heartbeat off, connect
timeout covering ticket minting); the effect keeps only the retry ladder and
the banner. Both sidebar clients are now created once per component instead
of per `version` bump, so the shared client's seq watermarks survive a drop
and its `session.events.since` gap replay can actually fire for web
(previously the client was rebuilt on every reconnect and replay never ran).

Behavior change: web sidecar reconnects reuse the same JsonRpcGatewayClient
(gap replay now runs); the events feed's handshake `error`+`close` pair is one
`closed` transition (one retry timer, as before); no parameter of any
backoff ladder changed.
2026-09-13 05:42:31 -07:00

168 lines
4.1 KiB
TypeScript

export { backendScopeKey, backendScopePrefix, LOCAL_CONNECTION_ID, registryBackendScopeKey } from './backend-scope'
export {
BILLING_REFUSAL_POLICY,
type BillingRecovery,
type BillingRefusalPolicy,
refusalPolicy
} from './billing-policy'
export type {
BillingAutoReload,
BillingBlock,
BillingCardInfo,
BillingChargeResponse,
BillingChargeStatusResponse,
BillingErrorPayload,
BillingMonthlyCap,
BillingMutationResponse,
BillingPaymentMethod,
BillingRefusalCode,
BillingStateResponse,
ChargeFailureReason,
KnownBillingRefusalCode,
KnownChargeFailureReason,
SubscriptionPreviewResponse,
SubscriptionStateResponse,
SubscriptionTierOption,
SubscriptionUpgradeResponse,
UsageBarData,
UsageModelData
} from './billing-types'
export {
driveChargeSettlement,
SETTLEMENT_MAX_RETRY_AFTER_MS,
SETTLEMENT_POLL_CAP_MS,
SETTLEMENT_POLL_INTERVAL_MS,
type SettlementDeps,
type SettlementOutcome
} from './charge-settlement'
export {
createCronTriggerController,
type CronTriggerController,
type CronTriggerRunResult
} from './cron-trigger-controller'
export {
clampDataUrlReadMaxMb,
DATA_URL_READ_DEFAULT_MAX_MB,
DATA_URL_READ_MAX_MAX_MB,
DATA_URL_READ_MIN_MAX_MB
} from './data-url-read-max'
export {
type ApprovalRequestPayload,
BACKEND_EVENT_NAMES,
type BackendGatewayEventMap,
type BackendGatewayEventName,
type ClarifyQuestion,
type ClarifyRequestPayload,
type ClientLocalGatewayEventMap,
type ErrorPayload,
type ErrorSurface,
type GatewayEvent,
type GatewayEventMap,
type GatewayEventName,
type GatewayReadyPayload,
type GatewayTranscriptMessage,
type McpSetupRequestPayload,
type MessageCompletePayload,
type MessageInterimPayload,
type ModelCapabilities,
type ModelOptionProvider,
type ModelOptionsResponse,
type ModelPricing,
type NotificationShowPayload,
type RequestExpirePayload,
type SecretRequestPayload,
type SessionInflightTurn,
type SessionListItem,
type SessionListResponse,
type SessionReclaimedPayload,
type SessionResumeResponse,
type SessionUsagePayload,
type StatusUpdatePayload,
type StreamDeltaPayload,
type SubagentEventPayload,
type SubagentStatus,
type TodoStatePayload,
type ToolCompletePayload,
type ToolStartPayload,
type Usage,
type VaultUnlockRequestPayload,
type WakeDetectedPayload
} from './gateway-events'
export {
DEFAULT_HEARTBEAT_DEADLINE_MS,
DEFAULT_HEARTBEAT_INTERVAL_MS,
type GatewayRequestId,
JSON_RPC_METHOD_NOT_FOUND,
jsonRpcErrorFromFrame,
type JsonRpcErrorPayload,
type JsonRpcFrame,
JsonRpcGatewayError,
JsonRpcRequestChannel,
type JsonRpcRequestChannelOptions,
type JsonRpcTransport,
wireFrameText
} from './json-rpc-channel'
export {
type ConnectionState,
type GatewayClientOptions,
GatewayEventHub,
isGatewayWebSocketUrl,
JsonRpcGatewayClient,
type WebSocketLike
} from './json-rpc-gateway'
export { reconnectBackoffDelayMs, type ReconnectBackoffOptions } from './reconnect-backoff'
export { skillInvocationText } from './skill-scaffold'
export {
type HermesSkin,
SKIN_BRANDING_TOKENS,
SKIN_COLOR_TOKENS,
type SkinBranding,
type SkinBrandingToken,
type SkinColors,
type SkinColorToken
} from './skin'
export {
backgroundMaterialFor,
clampIntensity,
DEFAULT_GLASS_MATERIAL,
DEFAULT_GLASS_SCOPE,
GLASS_MATERIALS,
GLASS_SCOPES,
glassActive,
type GlassMaterial,
glassMaterialForPicker,
glassMaterialsFor,
type GlassScope,
glassSupportedOn,
glassSurfaceKeep,
normalizeMaterial,
normalizeMode,
normalizeScope,
normalizeState,
TRANSLUCENCY_CURVE,
TRANSLUCENCY_MAX,
TRANSLUCENCY_MIN,
TRANSLUCENCY_OPACITY_FLOOR,
TRANSLUCENCY_STEP,
type TranslucencyMode,
type TranslucencyState,
translucencySupportedOn,
vibrancyFor,
windowOpacityFor,
WINDOWS_BACKGROUND_MATERIALS,
WINDOWS_GLASS_MIN_BUILD,
type WindowsBackgroundMaterial
} from './translucency'
export {
buildHermesWebSocketUrl,
type GatewayAuthMode,
GatewayReauthRequiredError,
type GatewayWsConnection,
type GatewayWsUrlResult,
type HermesWebSocketUrlOptions,
isGatewayReauthRequired,
resolveGatewayWsUrl,
type ResolveGatewayWsUrlDeps,
type WebSocketAuthParam
} from './websocket-url'