Skip to content

channels: deduplicate probe and token resolution types with shared base types#16986

Merged
thewilloftheshadow merged 1 commit intoopenclaw:mainfrom
iyoda:dedup-probe-token-types
Feb 15, 2026
Merged

channels: deduplicate probe and token resolution types with shared base types#16986
thewilloftheshadow merged 1 commit intoopenclaw:mainfrom
iyoda:dedup-probe-token-types

Conversation

@iyoda
Copy link

@iyoda iyoda commented Feb 15, 2026

Summary

Introduces BaseProbeResult and BaseTokenResolution shared base types, then unifies 15 channel probe types and 3 token resolution types to extend them — eliminating repeated ok: boolean; error?: string | null and token: string; source: string field declarations across core channels and extensions.

Motivation

Every channel probe type independently declared ok and error fields with slightly varying signatures (string vs string | null). Similarly, token resolution types repeated token and source fields. This made it harder to write generic probe/token handling code and increased maintenance surface.

Changes

Commit 1: Foundation types

  • Add BaseProbeResult = { ok: boolean; error?: string | null } and BaseTokenResolution = { token: string; source: string } to src/channels/plugins/types.core.ts
  • Re-export from types.ts and plugin-sdk/index.ts
  • Add type assignability tests (vitest expectTypeOf)

Commit 2: Core probe unification (6 types)

  • TelegramProbe, DiscordProbe, SlackProbe, SignalProbe, IMessageProbe, LineProbeResult → extend BaseProbeResult

Commit 3: Extension probe unification (9 types)

  • BlueBubblesProbe, ProbeMSTeamsResult, ZaloProbeResult, MatrixProbe, MattermostProbe, ProbeTwitchResult, FeishuProbeResult, IrcProbe, ZalouserProbeResult → extend BaseProbeResult

Commit 4: Token type unification (3 types)

  • TelegramTokenResolution, DiscordTokenResolution, ZaloTokenResolution → extend BaseTokenResolution

Design decisions

  • Intersection types (&) instead of interface extends — preserves existing type narrowing (e.g., error?: string stays narrower than string | null)
  • Type-only change — no runtime behavior change, no function signature changes
  • Conservative scope — account resolution was audited (17 implementations) and intentionally left unchanged; each channel's credential system is different by design
  • Slack and MSTeams token types excluded (structurally different: Slack has dual tokens, MSTeams has 3 credentials)

Verification

  • tsc --noEmit: zero new errors (all errors are pre-existing extension dependency issues)
  • vitest run: 855 passed, 10 failed (same pre-existing failures), zero regressions
  • 8 type assignability tests added verifying compile-time compatibility

Stats

  • 22 files changed, +100 / −54 lines
  • Net: −54 lines of duplicated field declarations removed

Greptile Summary

This PR successfully eliminates type duplication across 18 channel implementations by introducing two shared base types. The refactoring is purely type-level with zero runtime changes - all probe and token resolution functions continue to work identically.

Key changes:

  • Adds BaseProbeResult (ok, error) and BaseTokenResolution (token, source) to src/channels/plugins/types.core.ts
  • Unifies 15 probe types (6 core + 9 extensions) to extend BaseProbeResult
  • Unifies 3 token resolution types to extend BaseTokenResolution
  • Adds 8 type assignability tests to verify compile-time compatibility
  • Net -54 lines of duplicated field declarations removed

Type safety impact:
Some types that previously declared error?: string now inherit error?: string | null from BaseProbeResult. This slightly widens the type but better reflects actual runtime behavior where implementations do set error to null. The change is backward compatible - all existing error checks (if (result.error)) continue to work correctly.

Verification:
The commit structure is clean and logical (foundation → core → extensions → tokens). The PR's statistics (22 files, +100/-54 lines, 18 types unified) are accurate. Type assignability tests ensure no regressions in type compatibility.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it's a pure type refactoring with no runtime changes
  • This is an exemplary refactoring PR: (1) zero runtime behavior changes - only type declarations modified; (2) comprehensive type assignability tests verify backward compatibility; (3) clean commit structure makes changes easy to review; (4) all statistics and claims in PR description verified accurate; (5) the type widening from string to string | null for some error fields actually improves type accuracy to match runtime behavior
  • No files require special attention - all changes follow the same safe pattern of replacing explicit field declarations with base type intersections

Last reviewed commit: 2b7cd6e

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle bot added channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser channel: feishu Channel integration: feishu channel: twitch Channel integration: twitch channel: irc size: S labels Feb 15, 2026
@thewilloftheshadow thewilloftheshadow self-assigned this Feb 15, 2026
@thewilloftheshadow thewilloftheshadow merged commit c6b3736 into openclaw:main Feb 15, 2026
9 of 10 checks passed
@thewilloftheshadow
Copy link
Member

Landed via temp rebase onto main.

  • Gate: pnpm vitest run --config vitest.unit.config.ts src/channels/plugins/base-types-assignability.test.ts
  • Land commit: ${land_sha}
  • Merge commit: ${merge_sha}

Thanks @iyoda!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: imessage Channel integration: imessage channel: irc channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: twitch Channel integration: twitch channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments