Skip to content

feat: make adapter internals protected to enable subclassing#475

Merged
bensabic merged 13 commits into
vercel:mainfrom
slmnsh:main
May 10, 2026
Merged

feat: make adapter internals protected to enable subclassing#475
bensabic merged 13 commits into
vercel:mainfrom
slmnsh:main

Conversation

@slmnsh
Copy link
Copy Markdown
Contributor

@slmnsh slmnsh commented May 9, 2026

Summary

Fixes #433

Test plan

Checklist

  • All commits are signed and verified
  • pnpm validate passes
  • Changeset added (or N/A — see CONTRIBUTING.md)
  • Documentation updated (or N/A)

@slmnsh slmnsh requested a review from a team as a code owner May 9, 2026 18:56
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 9, 2026

@slmnsh is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@bensabic bensabic changed the title chore: changed class function access to protected feat: make adapter internals protected to enable subclassing May 10, 2026
bensabic added 8 commits May 10, 2026 11:57
…xtension surface

Narrow scope of vercel#475: caches, polling/runtime state, and one-shot warning
flags stay private. Methods and shared helpers (logger, formatConverter,
chat, config) remain protected as the documented extension surface.

Also fixes a typecheck failure where gchat's oauth2Client (now private)
no longer requires a portable type for the emitted .d.ts.
Each adapter now has a compile-time test that subclasses can access the
documented protected surface. If any of these members revert to private,
the test file fails to type-check.
These three protected static cache TTLs are configuration constants, not
mutable state. Marking them readonly prevents subclasses (the new extension
surface from this PR) from mutating values shared across every instance
in-process.
Mirrors the inline comment from the Telegram subclass test across the other
nine adapter tests so future readers immediately understand these blocks are
type-only sentinels — they fail at typecheck (not vitest) if a member reverts
to private.
Adds a "Customizing an adapter via subclassing" section to the Adapters page
that walks through extending an official adapter to override a protected hook
(using the issue vercel#433 Telegram processUpdate scenario as the canonical
example) and clarifies that private members are intentionally off-limits.
The surrounding refreshClientCredentialsToken and ensureValidToken methods
are now protected, but accessTokenExpiry was kept private — meaning a
subclass overriding either method couldn't read or update the expiry without
calling super. Flipping it to protected lets subclasses fully reimplement
the token-refresh flow.
This PR adds a new, additive capability — subclassing official adapters to
override protected hooks. Per CONTRIBUTING.md, additive backward-compatible
features warrant a minor bump rather than a patch.
@slmnsh
Copy link
Copy Markdown
Contributor Author

slmnsh commented May 10, 2026

Thanks @bensabic, is there anything else left on this?

Correct the parenthetical describing what stays `private` (credentials are
now `protected`) and add a callout warning that the `protected` extension
surface is intentionally broader than the public API but not yet fully
stable, so subclass authors know to pin versions and prefer overriding
the smallest hook.
@bensabic bensabic merged commit 2ffed48 into vercel:main May 10, 2026
7 of 9 checks passed
bensabic added a commit that referenced this pull request May 11, 2026
…erge

The merge of main into konsistent brought in PR #475's `protected`
field modifiers on top of the WebAdapterOptions → WebAdapterConfig
rename, leaving two stale references to the (un-imported) old name.
Switch them to WebAdapterConfig and update a stale JSDoc reference
in als.ts to match.
bensabic added a commit that referenced this pull request May 11, 2026
…pter, and state adapter conventions (#466)

* set up konsistent with basic initial config

* add konsistent to CI

* fix konsistent.json formatting

* fix(gchat): move GoogleChatAdapterConfig to ./types for konsistent

* fix(slack): move SlackAdapterConfig to ./types and drop Partial wrapper from createSlackAdapter

* fix(messenger): name createMessengerAdapter parameter MessengerAdapterConfig

* fix(web): rename WebAdapterOptions to WebAdapterConfig and import Adapter type in index.ts

* fix(whatsapp): align WhatsAppAdapterConfig and creator with konsistent + map kebab to PascalCase

* fix(state-memory): add MemoryStateAdapterOptions type for konsistent

* fix(state-ioredis): unify URL and client options under IoRedisStateAdapterOptions

* fix(state-redis): unify URL and client options under RedisStateAdapterOptions

* fix(state-pg): unify URL and client options under PostgresStateAdapterOptions

* chore: changeset for konsistent convention alignment

* chore: drop CHANGELOG.md from konsistent's required files list

CHANGELOG.md is generated automatically by changesets on each release —
it's never hand-authored and doesn't exist for a package until its first
release lands. Requiring it as a convention check makes CI fail
indefinitely for any newly added package, with no honest fix available
(an empty placeholder is just noise that gets overwritten on first
release).

* docs: document konsistent and package shape conventions

* fix(web): use WebAdapterConfig in WebAdapter field types after main merge

The merge of main into konsistent brought in PR #475's `protected`
field modifiers on top of the WebAdapterOptions → WebAdapterConfig
rename, leaving two stale references to the (un-imported) old name.
Switch them to WebAdapterConfig and update a stale JSDoc reference
in als.ts to match.

---------

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
Co-authored-by: Ben Sabic <27636870+bensabic@users.noreply.github.com>
patrick-chinchill added a commit to Chinchill-AI/chat-sdk-python that referenced this pull request May 29, 2026
Alpha sync starter for upstream chat@4.29.0 (release commit 6581d31, May 18 2026). Upstream skipped tagging chat@4.27.0 and chat@4.28.0; chat@4.29.0 is the next real tag.

- Bumps version → 0.4.29a1
- Bumps UPSTREAM_PARITY → "4.29.0"
- Updates README, CLAUDE.md, CHANGELOG with in-flight status and full porting plan

Pre-audit (this session's scoping subagents) found two items already done in 0.4.27 — no work needed:
- vercel/chat#446 (Telegram MarkdownV2 streaming-chunk safety trim) — PR #89 helpers cover it
- vercel/chat#475 (private → protected internals) — Python _underscore convention already provides this

Detailed scope, design issues (#109 chat/ai, #110 Messenger), and open questions in CHANGELOG entry.

Tracking issue: #98.
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.

Make chat adapter extensible

2 participants