refactor(session-broker): split broker into reusable runtime-neutral packages#205
refactor(session-broker): split broker into reusable runtime-neutral packages#205benvinegar merged 8 commits intomainfrom
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Greptile SummaryThis PR extracts the session broker into four layered workspace packages ( Confidence Score: 5/5Safe to merge; all findings are P2 style and code-quality suggestions with no impact on correctness. The refactor cleanly separates concerns, preserves Hunk-specific behavior at the app layer, and includes good test coverage across all new packages. The only open findings are a duplicate constant block, an asymmetric double-stop pattern in the Bun adapter vs. the Node adapter, a technically incorrect header type cast, and a misleading engines.node entry—none of which affect runtime behavior. packages/session-broker-bun/src/serve.ts (double-stop asymmetry), src/session-broker/brokerServer.ts (duplicate default constants) Important Files Changed
Sequence DiagramsequenceDiagram
participant App as Hunk App (brokerClient.ts)
participant SBC as SessionBrokerConnection<br/>(@hunk/session-broker)
participant BunAdapt as serveSessionBrokerDaemon<br/>(@hunk/session-broker-bun)
participant Daemon as SessionBrokerDaemon<br/>(@hunk/session-broker)
participant Broker as SessionBroker<br/>(@hunk/session-broker)
participant State as SessionBrokerState<br/>(@hunk/session-broker-core)
App->>SBC: start() / updateSnapshot()
SBC-->>BunAdapt: WebSocket connect → register / snapshot / heartbeat
BunAdapt->>Daemon: handleConnectionMessage(peer, msg)
Daemon->>Broker: registerSession / updateSnapshot / markSessionSeen
Broker->>State: (delegates all session storage)
Note over App,State: HTTP path (agent / CLI)
App->>BunAdapt: POST /session-api (brokerServer handleRequest)
BunAdapt->>Daemon: handleRequest(request)
Daemon->>Broker: listSessions / getSession / dispatchCommand
Broker->>State: resolves session, enqueues command
State-->>SBC: WebSocket command message
SBC-->>App: bridge.dispatchCommand(msg) → result
App-->>State: command-result via WebSocket
State-->>Broker: pending command resolved
Broker-->>Daemon: response
Daemon-->>BunAdapt: Response.json(result)
BunAdapt-->>App: HTTP 200
|
Summary
@hunk/session-broker-core@hunk/session-brokeras the main runtime-neutral broker daemon and connection package@hunk/session-broker-bunand@hunk/session-broker-nodePackage layout
@hunk/session-broker-core@hunk/session-broker@hunk/session-broker-bun@hunk/session-broker-nodewsadapterHunk integration changes
Verification
bun run typecheckbun run testbun run lintbun run format:checkThis PR description was generated by Pi using GPT-5