MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / subscribe

Method subscribe

apps/kimi-web/src/api/daemon/ws.ts:156–167  ·  view source on GitHub ↗

* Subscribe to events for a session at a `{seq, epoch}` cursor. * If connected, sends immediately; otherwise queues until after server_hello.

(sessionId: string, cursor: SessionCursor = { seq: 0 })

Source from the content-addressed store, hash-verified

154 * If connected, sends immediately; otherwise queues until after server_hello.
155 */
156 subscribe(sessionId: string, cursor: SessionCursor = { seq: 0 }): void {
157 this.subscriptions.set(sessionId, { ...cursor });
158
159 if (this.connected) {
160 this.sendSubscribe([sessionId], { [sessionId]: cursor });
161 } else {
162 // Remove any earlier pending entry for this session, then enqueue
163 const idx = this.pendingSubscriptions.findIndex((p) => p.sessionId === sessionId);
164 if (idx !== -1) this.pendingSubscriptions.splice(idx, 1);
165 this.pendingSubscriptions.push({ sessionId, cursor: { ...cursor } });
166 }
167 }
168
169 /** Unsubscribe from a session's events. */
170 unsubscribe(sessionId: string): void {

Callers

nothing calls this directly

Calls 3

sendSubscribeMethod · 0.95
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected