Files
bot/apps/macos/Sources/OpenClaw/GatewayPushSubscription.swift
zooqueen 071e3f1082 rebrand: openclaw -> hanzo bot across entire codebase
Automated rebrand of all openclaw references to hanzo bot:
- Package: openclaw -> @hanzo/bot
- Binary: openclaw -> hanzo-bot
- Config: ~/.openclaw -> ~/.hanzo/bot
- Docker: ghcr.io/hanzoai/bot
- Env vars: OPENCLAW_* -> BOT_*
- Bundle IDs: ai.hanzo.bot.*
- Product name: Hanzo Bot
2026-03-19 13:52:32 -07:00

35 lines
946 B
Swift

import Hanzo BotKit
enum GatewayPushSubscription {
@MainActor
static func consume(
bufferingNewest: Int? = nil,
onPush: @escaping @MainActor (GatewayPush) -> Void) async
{
let stream: AsyncStream<GatewayPush> = if let bufferingNewest {
await GatewayConnection.shared.subscribe(bufferingNewest: bufferingNewest)
} else {
await GatewayConnection.shared.subscribe()
}
for await push in stream {
if Task.isCancelled { return }
await MainActor.run {
onPush(push)
}
}
}
@MainActor
static func restartTask(
task: inout Task<Void, Never>?,
bufferingNewest: Int? = nil,
onPush: @escaping @MainActor (GatewayPush) -> Void)
{
task?.cancel()
task = Task {
await self.consume(bufferingNewest: bufferingNewest, onPush: onPush)
}
}
}