Add built-in Posit Connect provider - #81
Conversation
Only the Mantle route respected an explicit baseUrl; the other two hardcoded the resolved AWS runtime endpoint, so a gateway-routed caller (e.g. Connect's Bedrock gateway) fell through to AWS directly.
Convert Connect OAuth integrations from runtime-injected custom providers into a first-class built-in connect provider. ai-config: add "connect" to the provider/client-kind vocabulary, map POSIT_CONNECT_GATEWAY_URL to providers.connect.baseUrl, and add the Connect Bedrock model table with capability inference that borrows limits from the Anthropic-on-Bedrock table. ai-provider-bridge: add connect-provider.ts with integration discovery against /__api__/v1/oauth/integrations, template shaping (anthropic live-discovered via the gateway, aws declared from the table with Viewer-auth filtering), model ids namespaced as connect-<slug>/<modelId>, and a protocol-dispatching client that routes anthropic-messages through AnthropicClient with the federated token and bedrock-converse through BedrockClient with per-request STS credentials minted via ConnectProviderCallbacks.
Parse the discovery-stamped gateway baseUrl for server, template, and guid so stamped models never depend on discovery-time cache state; the integration cache is now replaced wholesale per discovery and consulted only for unstamped override models on the same server. The template selects the transport, so a protocol override can pick the wire format but never re-route off the integration's gateway. Bedrock chats tie the credential mint to chat cancellation, require complete minted keys (no ambient-chain fallback), sign with the integration's sts_region, and forward provider customHeaders. AWS-backed integrations are skipped with a warning when no credential callback exists, and ids whose first segment is not a connect- prefix (raw ARNs) pass through unsplit.
|
I have some questions about endpoints:
In general, it's best to speak a model's native protocol whenever possible. Some feedback from running the
|
Bedrock's client passed customHeaders straight to the SDK factories unlike every other direct-SDK client, risking a caller-supplied header clobbering an SDK-managed one; route it through safeSdkCustomHeaders like the rest. Also stop silently warning-and-proceeding when an explicit baseUrl overrides a FIPS runtime endpoint - reject it by default, and require callers that route through a trusted gateway (Connect) to opt in via allowBaseUrlUnderFips.
The shared model-list cache keyed only on providerId, so a registry called with different credentials over time (e.g. distinct user sessions against the same provider) would silently share one cached model list across them. Add an optional cacheKey so a provider whose credentials materially change the fetched list can partition the cache; omitting it keeps prior single-entry behavior.
The gateway-guid cache used to route unstamped model IDs and enrich stamped ones was keyed only by Connect server URL, so two sessions against the same server (different API keys) could resolve each other's integrations. Gate every read against a credential-derived key set when the cache was populated. Also fix baseUrl selection for unstamped models: ai-config's resolver can fall back to the bare Connect root as a model's baseUrl when no gateway URL was discovered, which `??` treated as a real override and preferred over the cached integration's gateway URL. Distinguish a genuine discovery-stamped gateway URL from that meaningless fallback before deciding which one wins. Simplify prefix minting to always embed the integration's guid, which makes prefixes collision-free by construction and removes the order-dependent takenId fallback. Declare Anthropic-model Bedrock gateway routes as anthropic-messages instead of bedrock-converse, and pass allowBaseUrlUnderFips to BedrockClient since Connect's gateway redirect is a trusted, admin-configured route.
Keep Connect routing state scoped and bounded with the model cache, use opaque credential fingerprints, and cover partitioning and interleaved sessions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Ok chatted with the connect team. The this feature is preview. So the support is a little limited right now.
|
Make Posit Connect a built-in provider: one provider fronts every OAuth integration on a Connect server, folding their models into a single namespaced list instead of runtime-injected custom-provider entries.
POSIT_CONNECT_URL; without one the provider lists no models.connect-provider.ts; the regenerated JSON schema and lockfile are churn.Testing
New tests cover integration shaping (template allowlist, Viewer-auth filtering, prefix minting with collisions), raw discovery requests against both gateways, per-integration failure isolation, chat dispatch on both protocols including credential-mint failures, and the capability table's delegation and fallback. Bedrock's base-URL honoring gets its own routing tests.
Commits
🤖 Generated with Claude Code