Skip to content

Move provider to a plugin-architecture - #661

Merged
steipete merged 217 commits into
mainfrom
provider-plugins
Jan 11, 2026
Merged

steipete merged 217 commits into
mainfrom
provider-plugins

Conversation

@steipete

@steipete steipete commented Jan 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Providers (iMessage, Discord, WhatsApp, …) are plugin-driven end-to-end (CLI, gateway runtime, status/probes, outbound, followup routing). Adding/removing a provider no longer requires touching gateway core switch statements.

Breaking changes (vs main)

  • Gateway protocol providers.status is v3: provider-keyed maps (providers, providerAccounts, providerOrder, providerLabels).
  • Provider runtime snapshot is map-based ({ providers, providerAccounts }); old per-provider top-level fields are gone.

Architecture (vs main)

  • Plugin contract: src/providers/plugins/types.ts (ProviderPlugin + adapters).
  • Heavy registry: src/providers/plugins/index.ts (all plugins; use for UX surfaces / listing).
  • Light dock: src/providers/dock.ts (cheap metadata/defaults for shared flows; avoid init cycles).
  • IDs + aliases: src/providers/registry.ts (canonical ids + input aliases).

Gateway

  • Lifecycle/runtime: src/gateway/server-providers.ts (start/stop/logout via plugins; map-based runtime snapshot).
  • RPC surface: src/gateway/server-methods/providers.ts (generic provider.status/logout/login routing).

Status

  • src/commands/health.ts: provider-keyed maps (providers, providerOrder, providerLabels).
  • src/commands/status-all/providers.ts: tables rendered from plugin config/status.
  • src/commands/status-all.ts: attaches gateway provider issues via provider ids (no label→id string mapping).

Outbound + followups

  • Outbound delivery: src/infra/outbound/deliver.ts delegates to plugin.outbound and supports replyToId, threadId, and abortSignal.
  • Lazy plugin load on send paths: src/providers/plugins/load.ts loads a single provider plugin on-demand (avoid importing the heavy registry on hot paths).
  • Queued followup routing: src/auto-reply/reply/route-reply.ts uses outbound delivery (lazy import) instead of a per-provider switch.

Onboarding

  • Provider-specific onboarding prompts moved into adapters under src/commands/onboarding/providers/* and wired via src/commands/onboarding/registry.ts.

WhatsApp / Baileys import cost

  • Cheap auth-store helpers: src/web/auth-store.ts (file-based auth checks + self id) so status/outbound don’t pay Baileys import cost.
  • WhatsApp plugin defers Baileys-heavy login helpers via lazy imports (login / QR).

Adding a provider

  1. Implement src/providers/plugins/<id>.ts (ProviderPlugin).
  2. Register in src/providers/plugins/index.ts and add ids/aliases in src/providers/registry.ts.
  3. Add a dock entry in src/providers/dock.ts for shared behavior (allowFrom formatting, mention stripping, threading defaults, streaming defaults).
  4. Optional hooks: status, outbound, gateway, auth, reload, pairing, onboarding, agentTools.
  5. If protocol changes: run pnpm protocol:check.

Notes

  • Implementation notes: docs/refactor/provider-plugin.md.

Testing

  • pnpm lint && pnpm build && pnpm test && pnpm protocol:check && pnpm docs:build

@cursor

cursor Bot commented Jan 10, 2026 •

Copy link
Copy Markdown

PR Summary

Major provider refactor with protocol and app updates.

  • Providers now plugin-driven end-to-end (gateway/CLI/outbound); providers.status is v3 with provider-keyed maps; add generic providers.logout; add msteams id
  • Gateway protocol/client: bump to GATEWAY_PROTOCOL_VERSION=3; connect payload uses client.id/displayName and mode ui/backend
  • Agent/tools: route message actions via provider plugins; aggregate provider-owned agent tools; include tool summaries in system prompt; sandbox/tool deny uses provider ids; text chunking/command auth/command registry generalized per provider
  • macOS app: adopt provider-map snapshots throughout (Connections, HealthStore, Instances, General/Onboarding/menu); update health summaries and link-age logic; new SettingsWindowOpener; installer handler constrained to MainActor; launchd command resolution/error handling improved
  • Replace specific logouts (web.logout/telegram.logout) with providers.logout; update tests/docs to new provider model and health semantics

Written by Cursor Bugbot for commit d0beb09. This will update automatically on new commits. Configure here.

@steipete

Copy link
Copy Markdown
Contributor Author

Rebased provider-plugins onto origin/main (2026-01-10) and force-pushed.

CI fixes:

  • protocol:check was failing due to regenerated Swift models; committed ProvidersLogoutParams in apps/macos/Sources/ClawdbotProtocol/GatewayModels.swift.
  • pnpm test src/auto-reply/reply.block-streaming.test.ts passes locally; keeping an eye on the prior CI-only failure.

Fresh CI run queued; I’ll watch and follow up if anything flakes.

@steipete

Copy link
Copy Markdown
Contributor Author

Fixed HealthStore regression: degrade health when linked provider probe fails.\n\nCommit: a582b7c97\nFile: apps/macos/Sources/Clawdbot/HealthStore.swift\n\nCI re-run is queued from the push; I’ll keep watching for flakes.

kindTarget,
)
: undefined;
return { provider, to: normalized ?? kindTarget };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Session target prefix breaks iMessage and MS Teams routing

High Severity

The refactored resolveAnnounceTargetFromKey now adds group: or channel: prefix to ALL recognized providers' targets, but providers without messaging.normalizeTarget (like iMessage and MS Teams) don't strip this prefix. Previously, only Discord got channel: and Signal got group:, with other providers getting bare IDs. Now iMessage group sessions return to: "group:chat123" instead of to: "chat123", and MS Teams returns to: "group:conversationId" instead of bare to: "conversationId". These prefixed values pass through resolveOutboundTarget unchanged and could cause downstream send functions to fail or route to wrong destinations.

Fix in Cursor Fix in Web

@steipete

Copy link
Copy Markdown
Contributor Author

Rebased provider-plugins onto origin/main @ 1ac7338d9 (force-pushed with lease).

Local gate green:

  • pnpm docs:list
  • pnpm lint
  • pnpm build
  • pnpm test

Follow-ups after rebase:

  • Lint/import ordering + WEBSITE_URL init order (src/providers/registry.ts).
  • Deflaked src/cli/gateway-cli.coverage.test.ts (use --json for call coverage + bump per-test timeout).

@steipete

Copy link
Copy Markdown
Contributor Author

Rebased provider-plugins onto main @ 1fe9f64.

Local gate green:

  • pnpm docs:list && pnpm lint && pnpm build && pnpm test
  • swiftformat --lint apps/macos/Sources --config .swiftformat

CI fix: macos-app (lint) failure was SwiftFormat lint in apps/macos/Sources/Clawdbot/HealthStore.swift; now formatted.

New commits:

  • 8e24ea0 refactor(provider-plugins): simplify provider ids
  • 98c0484 test(pairing-cli): avoid provider-specific ternary
  • eb72a1a style(macos): swiftformat HealthStore

@steipete

Copy link
Copy Markdown
Contributor Author

Follow-up: default sandbox tool denylist no longer calls listProviderPlugins() at module init (avoids Vitest hoisting/TDZ); it now uses PROVIDER_IDS.

Local gate green again:

  • pnpm lint && pnpm build && pnpm test

New commits:

  • b6284a9 refactor(sandbox): derive provider tool denylist
  • 03d6f05 fix(sandbox): avoid plugin init in defaults

@steipete

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (origin/main @ 0279f09).

Follow-up cleanup:

  • Centralized provider aliases in src/providers/registry.ts (removed plugin meta alias duplication).
  • Added src/providers/plugins/index.test.ts to keep plugin registry + PROVIDER_IDS in sync.

CI should be green again after rerun; running full gate locally next.

action: Type.Union(
nonSendActions.map((action) => Type.Literal(action)),
),
to: Type.Optional(Type.String()),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object spread order makes required params optional in schema

Medium Severity

The send action schema construction spreads ...props after defining required to: Type.String() and message: Type.String(). Since MessageToolCommonSchema contains to: Type.Optional(Type.String()) and message: Type.Optional(Type.String()), and JavaScript object spread puts later properties over earlier ones, the required versions get overridden by the optional versions. This means the schema will incorrectly allow send actions without to or message parameters.

Additional Locations (1)

Fix in Cursor Fix in Web

This branch was successfully deployed

1 active deployment
staging - docs — d0beb094 Deployed Jan 11, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants