Skip to content

Commit 7acd26a

Browse files
steipetelc0rpimfing
authored
Move provider to a plugin-architecture (#661)
* refactor: introduce provider plugin registry * refactor: move provider CLI to plugins * docs: add provider plugin implementation notes * refactor: shift provider runtime logic into plugins * refactor: add plugin defaults and summaries * docs: update provider plugin notes * feat(commands): add /commands slash list * Auto-reply: tidy help message * Auto-reply: fix status command lint * Tests: align google shared expectations * Auto-reply: tidy help message * Auto-reply: fix status command lint * refactor: move provider routing into plugins * test: align agent routing expectations * docs: update provider plugin notes * refactor: route replies via provider plugins * docs: note route-reply plugin hooks * refactor: extend provider plugin contract * refactor: derive provider status from plugins * refactor: unify gateway provider control * refactor: use plugin metadata in auto-reply * fix: parenthesize cron target selection * refactor: derive gateway methods from plugins * refactor: generalize provider logout * refactor: route provider logout through plugins * refactor: move WhatsApp web login methods into plugin * refactor: generalize provider log prefixes * refactor: centralize default chat provider * refactor: derive provider lists from registry * refactor: move provider reload noops into plugins * refactor: resolve web login provider via alias * refactor: derive CLI provider options from plugins * refactor: derive prompt provider list from plugins * style: apply biome lint fixes * fix: resolve provider routing edge cases * docs: update provider plugin refactor notes * fix(gateway): harden agent provider routing * refactor: move provider routing into plugins * refactor: move provider CLI to plugins * refactor: derive provider lists from registry * fix: restore slash command parsing * refactor: align provider ids for schema * refactor: unify outbound target resolution * fix: keep outbound labels stable * feat: add msteams to cron surfaces * fix: clean up lint build issues * refactor: localize chat provider alias normalization * refactor: drive gateway provider lists from plugins * docs: update provider plugin notes * style: format message-provider * fix: avoid provider registry init cycles * style: sort message-provider imports * fix: relax provider alias map typing * refactor: move provider routing into plugins * refactor: add plugin pairing/config adapters * refactor: route pairing and provider removal via plugins * refactor: align auto-reply provider typing * test: stabilize telegram media mocks * docs: update provider plugin refactor notes * refactor: pluginize outbound targets * refactor: pluginize provider selection * refactor: generalize text chunk limits * docs: update provider plugin notes * refactor: generalize group session/config * fix: normalize provider id for room detection * fix: avoid provider init in system prompt * style: formatting cleanup * refactor: normalize agent delivery targets * test: update outbound delivery labels * chore: fix lint regressions * refactor: extend provider plugin adapters * refactor: move elevated/block streaming defaults to plugins * refactor: defer outbound send deps to plugins * docs: note plugin-driven streaming/elevated defaults * refactor: centralize webchat provider constant * refactor: add provider setup adapters * refactor: delegate provider add config to plugins * docs: document plugin-driven provider add * refactor: add plugin state/binding metadata * refactor: build agent provider status from plugins * docs: note plugin-driven agent bindings * refactor: centralize internal provider constant usage * fix: normalize WhatsApp targets for groups and E.164 (#631) (thanks @imfing) * refactor: centralize default chat provider * refactor: centralize WhatsApp target normalization * refactor: move provider routing into plugins * refactor: normalize agent delivery targets * chore: fix lint regressions * fix: normalize WhatsApp targets for groups and E.164 (#631) (thanks @imfing) * feat: expand provider plugin adapters * refactor: route auto-reply via provider plugins * fix: align WhatsApp target normalization * fix: normalize WhatsApp targets for groups and E.164 (#631) (thanks @imfing) * refactor: centralize WhatsApp target normalization * feat: add /config chat config updates * docs: add /config get alias * feat(commands): add /commands slash list * refactor: centralize default chat provider * style: apply biome lint fixes * chore: fix lint regressions * fix: clean up whatsapp allowlist typing * style: format config command helpers * refactor: pluginize tool threading context * refactor: normalize session announce targets * docs: note new plugin threading and announce hooks * refactor: pluginize message actions * docs: update provider plugin actions notes * fix: align provider action adapters * refactor: centralize webchat checks * style: format message provider helpers * refactor: move provider onboarding into adapters * docs: note onboarding provider adapters * feat: add msteams onboarding adapter * style: organize onboarding imports * fix: normalize msteams allowFrom types * feat: add plugin text chunk limits * refactor: use plugin chunk limit fallbacks * feat: add provider mention stripping hooks * style: organize provider plugin type imports * refactor: generalize health snapshots * refactor: update macOS health snapshot handling * docs: refresh health snapshot notes * style: format health snapshot updates * refactor: drive security warnings via plugins * docs: note provider security adapter * style: format provider security adapters * refactor: centralize provider account defaults * refactor: type gateway client identity constants * chore: regen gateway protocol swift * fix: degrade health on failed provider probe * refactor: centralize pairing approve hint * docs: add plugin CLI command references * refactor: route auth and tool sends through plugins * docs: expand provider plugin hooks * refactor: document provider docking touchpoints * refactor: normalize internal provider defaults * refactor: streamline outbound delivery wiring * refactor: make provider onboarding plugin-owned * refactor: support provider-owned agent tools * refactor: move telegram draft chunking into telegram module * refactor: infer provider tool sends via extractToolSend * fix: repair plugin onboarding imports * refactor: de-dup outbound target normalization * style: tidy plugin and agent imports * refactor: data-drive provider selection line * fix: satisfy lint after provider plugin rebase * test: deflake gateway-cli coverage * style: format gateway-cli coverage test * refactor(provider-plugins): simplify provider ids * test(pairing-cli): avoid provider-specific ternary * style(macos): swiftformat HealthStore * refactor(sandbox): derive provider tool denylist * fix(sandbox): avoid plugin init in defaults * refactor(provider-plugins): centralize provider aliases * style(test): satisfy biome * refactor(protocol): v3 providers.status maps * refactor(ui): adapt to protocol v3 * refactor(macos): adapt to protocol v3 * test: update providers.status v3 fixtures * refactor(gateway): map provider runtime snapshot * test(gateway): update reload runtime snapshot * refactor(whatsapp): normalize heartbeat provider id * docs(refactor): update provider plugin notes * style: satisfy biome after rebase * fix: describe sandboxed elevated in prompt * feat(gateway): add agent image attachments + live probe * refactor: derive CLI provider options from plugins * fix(gateway): harden agent provider routing * fix(gateway): harden agent provider routing * refactor: align provider ids for schema * fix(protocol): keep agent provider string * fix(gateway): harden agent provider routing * fix(protocol): keep agent provider string * refactor: normalize agent delivery targets * refactor: support provider-owned agent tools * refactor(config): provider-keyed elevated allowFrom * style: satisfy biome * fix(gateway): appease provider narrowing * style: satisfy biome * refactor(reply): move group intro hints into plugin * fix(reply): avoid plugin registry init cycle * refactor(providers): add lightweight provider dock * refactor(gateway): use typed client id in connect * refactor(providers): document docks and avoid init cycles * refactor(providers): make media limit helper generic * fix(providers): break plugin registry import cycles * style: satisfy biome * refactor(status-all): build providers table from plugins * refactor(gateway): delegate web login to provider plugin * refactor(provider): drop web alias * refactor(provider): lazy-load monitors * style: satisfy lint/format * style: format status-all providers table * style: swiftformat gateway discovery model * test: make reload plan plugin-driven * fix: avoid token stringification in status-all * refactor: make provider IDs explicit in status * feat: warn on signal/imessage provider runtime errors * test: cover gateway provider runtime warnings in status * fix: add runtime kind to provider status issues * test: cover health degradation on probe failure * fix: keep routeReply lightweight * style: organize routeReply imports * refactor(web): extract auth-store helpers * refactor(whatsapp): lazy login imports * refactor(outbound): route replies via plugin outbound * docs: update provider plugin notes * style: format provider status issues * fix: make sandbox scope warning wrap-safe * refactor: load outbound adapters from provider plugins * docs: update provider plugin outbound notes * style(macos): fix swiftformat lint * docs: changelog for provider plugins * fix(macos): satisfy swiftformat * fix(macos): open settings via menu action * style: format after rebase * fix(macos): open Settings via menu action --------- Co-authored-by: LK <[email protected]> Co-authored-by: Luke K (pr-0f3t) <[email protected]> Co-authored-by: Xin <[email protected]>
1 parent 23eec7d commit 7acd26a

232 files changed

Lines changed: 13600 additions & 10767 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
- CLI: `clawdbot status` now table-based + shows OS/update/gateway/daemon/agents/sessions; `status --all` adds a full read-only debug report (tables, log tails, Tailscale summary, and scan progress via OSC-9 + spinner).
2121
- CLI Backends: add Codex CLI fallback with resume support (text output) and JSONL parsing for new runs, plus a live CLI resume probe.
2222
- CLI: add `clawdbot update` (safe-ish git checkout update) + `--update` shorthand. (#673) — thanks @fm1randa.
23-
- Gateway: add OpenAI-compatible `/v1/chat/completions` HTTP endpoint (auth, SSE streaming, per-agent routing). (#680) — thanks @steipete.
23+
- Gateway: add OpenAI-compatible `/v1/chat/completions` HTTP endpoint (auth, SSE streaming, per-agent routing). (#680).
2424

2525
### Changes
2626
- Onboarding/Models: add first-class Z.AI (GLM) auth choice (`zai-api-key`) + `--zai-api-key` flag.
@@ -30,7 +30,8 @@
3030
- Onboarding/Models: add catalog-backed default model picker to onboarding + configure. (#611) — thanks @jonasjancarik.
3131
- Agents/OpenCode Zen: update fallback models + defaults, keep legacy alias mappings. (#669) — thanks @magimetal.
3232
- CLI: add `clawdbot reset` and `clawdbot uninstall` flows (interactive + non-interactive) plus docker cleanup smoke test.
33-
- Providers: unify group history context wrappers across providers with per-provider/per-account `historyLimit` overrides (fallback to `messages.groupChat.historyLimit`). Set `0` to disable. (#672) — thanks @steipete.
33+
- Providers: move provider wiring to a plugin architecture. (#661).
34+
- Providers: unify group history context wrappers across providers with per-provider/per-account `historyLimit` overrides (fallback to `messages.groupChat.historyLimit`). Set `0` to disable. (#672).
3435
- Gateway/Heartbeat: optionally deliver heartbeat `Reasoning:` output (`agents.defaults.heartbeat.includeReasoning`). (#690)
3536
- Docker: allow optional home volume + extra bind mounts in `docker-setup.sh`. (#679) — thanks @gabriel-trigo.
3637

‎apps/macos/Sources/Clawdbot/CLIInstallPrompter.swift‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ final class CLIInstallPrompter {
6161

6262
private func openSettings(tab: SettingsTab) {
6363
SettingsTabRouter.request(tab)
64-
NotificationCenter.default.post(name: .clawdbotSelectSettingsTab, object: tab)
65-
NSApp.sendAction(#selector(NSApplication.showSettingsWindow), to: nil, from: nil)
64+
SettingsWindowOpener.shared.open()
65+
DispatchQueue.main.async {
66+
NotificationCenter.default.post(name: .clawdbotSelectSettingsTab, object: tab)
67+
}
6668
}
6769

6870
private static func appVersion() -> String? {

‎apps/macos/Sources/Clawdbot/CLIInstaller.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum CLIInstaller {
3434
self.installedLocation() != nil
3535
}
3636

37-
static func install(statusHandler: @escaping @Sendable (String) async -> Void) async {
37+
static func install(statusHandler: @escaping @MainActor @Sendable (String) async -> Void) async {
3838
let expected = GatewayEnvironment.expectedGatewayVersion()?.description ?? "latest"
3939
let prefix = Self.installPrefix()
4040
await statusHandler("Installing clawdbot CLI…")

‎apps/macos/Sources/Clawdbot/ConnectionsSettings+ProviderState.swift‎

Lines changed: 72 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import SwiftUI
22

33
extension ConnectionsSettings {
4+
private func providerStatus<T: Decodable>(
5+
_ id: String,
6+
as type: T.Type) -> T?
7+
{
8+
self.store.snapshot?.decodeProvider(id, as: type)
9+
}
10+
411
var whatsAppTint: Color {
5-
guard let status = self.store.snapshot?.whatsapp else { return .secondary }
12+
guard let status = self.providerStatus("whatsapp", as: ProvidersStatusSnapshot.WhatsAppStatus.self)
13+
else { return .secondary }
614
if !status.configured { return .secondary }
715
if !status.linked { return .red }
816
if status.lastError != nil { return .orange }
@@ -12,7 +20,8 @@ extension ConnectionsSettings {
1220
}
1321

1422
var telegramTint: Color {
15-
guard let status = self.store.snapshot?.telegram else { return .secondary }
23+
guard let status = self.providerStatus("telegram", as: ProvidersStatusSnapshot.TelegramStatus.self)
24+
else { return .secondary }
1625
if !status.configured { return .secondary }
1726
if status.lastError != nil { return .orange }
1827
if status.probe?.ok == false { return .orange }
@@ -21,7 +30,8 @@ extension ConnectionsSettings {
2130
}
2231

2332
var discordTint: Color {
24-
guard let status = self.store.snapshot?.discord else { return .secondary }
33+
guard let status = self.providerStatus("discord", as: ProvidersStatusSnapshot.DiscordStatus.self)
34+
else { return .secondary }
2535
if !status.configured { return .secondary }
2636
if status.lastError != nil { return .orange }
2737
if status.probe?.ok == false { return .orange }
@@ -30,7 +40,8 @@ extension ConnectionsSettings {
3040
}
3141

3242
var signalTint: Color {
33-
guard let status = self.store.snapshot?.signal else { return .secondary }
43+
guard let status = self.providerStatus("signal", as: ProvidersStatusSnapshot.SignalStatus.self)
44+
else { return .secondary }
3445
if !status.configured { return .secondary }
3546
if status.lastError != nil { return .orange }
3647
if status.probe?.ok == false { return .orange }
@@ -39,7 +50,8 @@ extension ConnectionsSettings {
3950
}
4051

4152
var imessageTint: Color {
42-
guard let status = self.store.snapshot?.imessage else { return .secondary }
53+
guard let status = self.providerStatus("imessage", as: ProvidersStatusSnapshot.IMessageStatus.self)
54+
else { return .secondary }
4355
if !status.configured { return .secondary }
4456
if status.lastError != nil { return .orange }
4557
if status.probe?.ok == false { return .orange }
@@ -48,43 +60,49 @@ extension ConnectionsSettings {
4860
}
4961

5062
var whatsAppSummary: String {
51-
guard let status = self.store.snapshot?.whatsapp else { return "Checking…" }
63+
guard let status = self.providerStatus("whatsapp", as: ProvidersStatusSnapshot.WhatsAppStatus.self)
64+
else { return "Checking…" }
5265
if !status.linked { return "Not linked" }
5366
if status.connected { return "Connected" }
5467
if status.running { return "Running" }
5568
return "Linked"
5669
}
5770

5871
var telegramSummary: String {
59-
guard let status = self.store.snapshot?.telegram else { return "Checking…" }
72+
guard let status = self.providerStatus("telegram", as: ProvidersStatusSnapshot.TelegramStatus.self)
73+
else { return "Checking…" }
6074
if !status.configured { return "Not configured" }
6175
if status.running { return "Running" }
6276
return "Configured"
6377
}
6478

6579
var discordSummary: String {
66-
guard let status = self.store.snapshot?.discord else { return "Checking…" }
80+
guard let status = self.providerStatus("discord", as: ProvidersStatusSnapshot.DiscordStatus.self)
81+
else { return "Checking…" }
6782
if !status.configured { return "Not configured" }
6883
if status.running { return "Running" }
6984
return "Configured"
7085
}
7186

7287
var signalSummary: String {
73-
guard let status = self.store.snapshot?.signal else { return "Checking…" }
88+
guard let status = self.providerStatus("signal", as: ProvidersStatusSnapshot.SignalStatus.self)
89+
else { return "Checking…" }
7490
if !status.configured { return "Not configured" }
7591
if status.running { return "Running" }
7692
return "Configured"
7793
}
7894

7995
var imessageSummary: String {
80-
guard let status = self.store.snapshot?.imessage else { return "Checking…" }
96+
guard let status = self.providerStatus("imessage", as: ProvidersStatusSnapshot.IMessageStatus.self)
97+
else { return "Checking…" }
8198
if !status.configured { return "Not configured" }
8299
if status.running { return "Running" }
83100
return "Configured"
84101
}
85102

86103
var whatsAppDetails: String? {
87-
guard let status = self.store.snapshot?.whatsapp else { return nil }
104+
guard let status = self.providerStatus("whatsapp", as: ProvidersStatusSnapshot.WhatsAppStatus.self)
105+
else { return nil }
88106
var lines: [String] = []
89107
if let e164 = status.`self`?.e164 ?? status.`self`?.jid {
90108
lines.append("Linked as \(e164)")
@@ -114,7 +132,8 @@ extension ConnectionsSettings {
114132
}
115133

116134
var telegramDetails: String? {
117-
guard let status = self.store.snapshot?.telegram else { return nil }
135+
guard let status = self.providerStatus("telegram", as: ProvidersStatusSnapshot.TelegramStatus.self)
136+
else { return nil }
118137
var lines: [String] = []
119138
if let source = status.tokenSource {
120139
lines.append("Token source: \(source)")
@@ -145,7 +164,8 @@ extension ConnectionsSettings {
145164
}
146165

147166
var discordDetails: String? {
148-
guard let status = self.store.snapshot?.discord else { return nil }
167+
guard let status = self.providerStatus("discord", as: ProvidersStatusSnapshot.DiscordStatus.self)
168+
else { return nil }
149169
var lines: [String] = []
150170
if let source = status.tokenSource {
151171
lines.append("Token source: \(source)")
@@ -173,7 +193,8 @@ extension ConnectionsSettings {
173193
}
174194

175195
var signalDetails: String? {
176-
guard let status = self.store.snapshot?.signal else { return nil }
196+
guard let status = self.providerStatus("signal", as: ProvidersStatusSnapshot.SignalStatus.self)
197+
else { return nil }
177198
var lines: [String] = []
178199
lines.append("Base URL: \(status.baseUrl)")
179200
if let probe = status.probe {
@@ -199,7 +220,8 @@ extension ConnectionsSettings {
199220
}
200221

201222
var imessageDetails: String? {
202-
guard let status = self.store.snapshot?.imessage else { return nil }
223+
guard let status = self.providerStatus("imessage", as: ProvidersStatusSnapshot.IMessageStatus.self)
224+
else { return nil }
203225
var lines: [String] = []
204226
if let cliPath = status.cliPath, !cliPath.isEmpty {
205227
lines.append("CLI: \(cliPath)")
@@ -221,11 +243,11 @@ extension ConnectionsSettings {
221243
}
222244

223245
var isTelegramTokenLocked: Bool {
224-
self.store.snapshot?.telegram.tokenSource == "env"
246+
self.providerStatus("telegram", as: ProvidersStatusSnapshot.TelegramStatus.self)?.tokenSource == "env"
225247
}
226248

227249
var isDiscordTokenLocked: Bool {
228-
self.store.snapshot?.discord?.tokenSource == "env"
250+
self.providerStatus("discord", as: ProvidersStatusSnapshot.DiscordStatus.self)?.tokenSource == "env"
229251
}
230252

231253
var orderedProviders: [ConnectionProvider] {
@@ -258,19 +280,24 @@ extension ConnectionsSettings {
258280
func providerEnabled(_ provider: ConnectionProvider) -> Bool {
259281
switch provider {
260282
case .whatsapp:
261-
guard let status = self.store.snapshot?.whatsapp else { return false }
283+
guard let status = self.providerStatus("whatsapp", as: ProvidersStatusSnapshot.WhatsAppStatus.self)
284+
else { return false }
262285
return status.configured || status.linked || status.running
263286
case .telegram:
264-
guard let status = self.store.snapshot?.telegram else { return false }
287+
guard let status = self.providerStatus("telegram", as: ProvidersStatusSnapshot.TelegramStatus.self)
288+
else { return false }
265289
return status.configured || status.running
266290
case .discord:
267-
guard let status = self.store.snapshot?.discord else { return false }
291+
guard let status = self.providerStatus("discord", as: ProvidersStatusSnapshot.DiscordStatus.self)
292+
else { return false }
268293
return status.configured || status.running
269294
case .signal:
270-
guard let status = self.store.snapshot?.signal else { return false }
295+
guard let status = self.providerStatus("signal", as: ProvidersStatusSnapshot.SignalStatus.self)
296+
else { return false }
271297
return status.configured || status.running
272298
case .imessage:
273-
guard let status = self.store.snapshot?.imessage else { return false }
299+
guard let status = self.providerStatus("imessage", as: ProvidersStatusSnapshot.IMessageStatus.self)
300+
else { return false }
274301
return status.configured || status.running
275302
}
276303
}
@@ -344,35 +371,48 @@ extension ConnectionsSettings {
344371
func providerLastCheck(_ provider: ConnectionProvider) -> Date? {
345372
switch provider {
346373
case .whatsapp:
347-
guard let status = self.store.snapshot?.whatsapp else { return nil }
374+
guard let status = self.providerStatus("whatsapp", as: ProvidersStatusSnapshot.WhatsAppStatus.self)
375+
else { return nil }
348376
return self.date(fromMs: status.lastEventAt ?? status.lastMessageAt ?? status.lastConnectedAt)
349377
case .telegram:
350-
return self.date(fromMs: self.store.snapshot?.telegram.lastProbeAt)
378+
return self
379+
.date(fromMs: self.providerStatus("telegram", as: ProvidersStatusSnapshot.TelegramStatus.self)?
380+
.lastProbeAt)
351381
case .discord:
352-
return self.date(fromMs: self.store.snapshot?.discord?.lastProbeAt)
382+
return self
383+
.date(fromMs: self.providerStatus("discord", as: ProvidersStatusSnapshot.DiscordStatus.self)?
384+
.lastProbeAt)
353385
case .signal:
354-
return self.date(fromMs: self.store.snapshot?.signal?.lastProbeAt)
386+
return self
387+
.date(fromMs: self.providerStatus("signal", as: ProvidersStatusSnapshot.SignalStatus.self)?.lastProbeAt)
355388
case .imessage:
356-
return self.date(fromMs: self.store.snapshot?.imessage?.lastProbeAt)
389+
return self
390+
.date(fromMs: self.providerStatus("imessage", as: ProvidersStatusSnapshot.IMessageStatus.self)?
391+
.lastProbeAt)
357392
}
358393
}
359394

360395
func providerHasError(_ provider: ConnectionProvider) -> Bool {
361396
switch provider {
362397
case .whatsapp:
363-
guard let status = self.store.snapshot?.whatsapp else { return false }
398+
guard let status = self.providerStatus("whatsapp", as: ProvidersStatusSnapshot.WhatsAppStatus.self)
399+
else { return false }
364400
return status.lastError?.isEmpty == false || status.lastDisconnect?.loggedOut == true
365401
case .telegram:
366-
guard let status = self.store.snapshot?.telegram else { return false }
402+
guard let status = self.providerStatus("telegram", as: ProvidersStatusSnapshot.TelegramStatus.self)
403+
else { return false }
367404
return status.lastError?.isEmpty == false || status.probe?.ok == false
368405
case .discord:
369-
guard let status = self.store.snapshot?.discord else { return false }
406+
guard let status = self.providerStatus("discord", as: ProvidersStatusSnapshot.DiscordStatus.self)
407+
else { return false }
370408
return status.lastError?.isEmpty == false || status.probe?.ok == false
371409
case .signal:
372-
guard let status = self.store.snapshot?.signal else { return false }
410+
guard let status = self.providerStatus("signal", as: ProvidersStatusSnapshot.SignalStatus.self)
411+
else { return false }
373412
return status.lastError?.isEmpty == false || status.probe?.ok == false
374413
case .imessage:
375-
guard let status = self.store.snapshot?.imessage else { return false }
414+
guard let status = self.providerStatus("imessage", as: ProvidersStatusSnapshot.IMessageStatus.self)
415+
else { return false }
376416
return status.lastError?.isEmpty == false || status.probe?.ok == false
377417
}
378418
}

‎apps/macos/Sources/Clawdbot/ConnectionsStore+Lifecycle.swift‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ extension ConnectionsStore {
100100
self.whatsappBusy = true
101101
defer { self.whatsappBusy = false }
102102
do {
103-
let result: WhatsAppLogoutResult = try await GatewayConnection.shared.requestDecoded(
104-
method: .webLogout,
105-
params: nil,
103+
let params: [String: AnyCodable] = [
104+
"provider": AnyCodable("whatsapp"),
105+
]
106+
let result: ProviderLogoutResult = try await GatewayConnection.shared.requestDecoded(
107+
method: .providersLogout,
108+
params: params,
106109
timeoutMs: 15000)
107110
self.whatsappLoginMessage = result.cleared
108111
? "Logged out and cleared credentials."
@@ -119,9 +122,12 @@ extension ConnectionsStore {
119122
self.telegramBusy = true
120123
defer { self.telegramBusy = false }
121124
do {
122-
let result: TelegramLogoutResult = try await GatewayConnection.shared.requestDecoded(
123-
method: .telegramLogout,
124-
params: nil,
125+
let params: [String: AnyCodable] = [
126+
"provider": AnyCodable("telegram"),
127+
]
128+
let result: ProviderLogoutResult = try await GatewayConnection.shared.requestDecoded(
129+
method: .providersLogout,
130+
params: params,
125131
timeoutMs: 15000)
126132
if result.envToken == true {
127133
self.configStatus = "Telegram token still set via env; config cleared."
@@ -148,11 +154,9 @@ private struct WhatsAppLoginWaitResult: Codable {
148154
let message: String
149155
}
150156

151-
private struct WhatsAppLogoutResult: Codable {
152-
let cleared: Bool
153-
}
154-
155-
private struct TelegramLogoutResult: Codable {
157+
private struct ProviderLogoutResult: Codable {
158+
let provider: String?
159+
let accountId: String?
156160
let cleared: Bool
157161
let envToken: Bool?
158162
}

0 commit comments

Comments
 (0)