Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion memory-bank/aiConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ the map/translator live inside ai-config (see [Legacy Positron settings](#legacy
- **Vocabulary** (`src/vocabulary.ts`): `BUILTIN_PROVIDER_IDS`, `CLIENT_KIND_VALUES`, `PROTOCOL_VALUES`, `RESERVED_PROVIDER_KEYS`, `isBuiltinProviderId()`, and the `BuiltinProviderId` / `ClientKind` / `Protocol` / `ReservedProviderKey` types.
- **Schemas** (`src/schema.ts`): `providersConfigSchema` (full, strict) and `providersConfigFragmentSchema` (relaxed — custom-entry `type` optional; the fragment shape every catalog config source carries).
- **Types** (`src/types.ts`): types inferred from the Zod schemas (`ProvidersConfig`, `ProvidersMap`, `BuiltinProviderBlock`, `CustomProviderEntry`, `ModelsBlock`, `ModelOverride`, `CustomModel`, …) plus resolution outputs (`ResolvedProvider`, `ResolvedConnection`, `ResolvedConnectionProvenance`, `ResolvedModelInfo`) and the branded `CustomProviderId`. `mintCustomProviderId()` is the **only** way to produce a `CustomProviderId`.
- **Defaults** (`src/defaults.ts`): per-provider connection defaults and the `PROVIDER_CONNECTION_DEFAULTS` map. **Bedrock deliberately carries no entry**: `BEDROCK_DEFAULTS` (`us-east-1`) is exported but absent from `PROVIDER_CONNECTION_DEFAULTS`, because layering it into the resolved connection made the baked-in default outrank a user's stored credential region downstream (posit-dev/assistant#2002). Consumers apply the fallback at credential-synthesis time instead; do not "fix" the omission by adding Bedrock to the defaults map.
- **Defaults** (`src/defaults.ts`): per-provider connection defaults and the `PROVIDER_CONNECTION_DEFAULTS` map. **Bedrock deliberately carries no entry**: `BEDROCK_DEFAULTS` (`us-east-1`) is exported but absent from `PROVIDER_CONNECTION_DEFAULTS`, because layering it into the resolved connection made the baked-in default outrank a user's stored credential region downstream (posit-dev/assistant#2002). `BEDROCK_DEFAULTS` remains exported only as the standalone configure form's default region; credential synthesis no longer applies the fallback (synthesis is gated on catalog auth readiness, which requires deliberate region config). Do not "fix" the omission by adding Bedrock to the defaults map — a default-layer region would now pass readiness and make every install fetch Bedrock models.
- **Resolution helpers**: `resolveModels()` and `mergeEnforced()` are pure and exported; `resolveEnabled()` / connection resolution are internal helpers used by the catalog builder.
- **Config-source contracts** (`src/config-source.ts`): `ProviderConfigSource` (public — the resolver's input) and the internal `ProviderConfigSourceProvider` (loader machinery, not exported). `Disposable` stays public as the return type of `LegacySettingsReader.watch`.
- **Structured diagnostics** (`src/config-issue.ts`): `ConfigIssue` is source-agnostic; `SourcedConfigIssue` adds a required normalized `{ kind, label }` identity. Its source kind reuses `ProviderConfigSourceKind` and widens only for the resolver-private `"env"` source.
Expand Down
3 changes: 2 additions & 1 deletion packages/ai-config/src/node/load-catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export async function loadProviderCatalogReport(
const legacyProviders = createLegacyPositronSourceProviders(opts, env);
reports.push(...(await Promise.all(legacyProviders.map((provider) => provider.read()))));

const sources = reports.flatMap((report) => (report.source ? [report.source] : []));
const loaded = reports.flatMap((report) => (report.source ? [report.source] : []));
const sources = opts.transformSource ? loaded.map(opts.transformSource) : loaded;
const resolver = resolveProviderCatalogReport({
sources,
envVars: env,
Expand Down
11 changes: 11 additions & 0 deletions packages/ai-config/src/node/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import type { SourcedConfigIssue } from "../config-issue.js";
import type { Disposable as ConfigDisposable } from "../config-source.js";
import type { LegacySettingsReader } from "../legacy-positron-settings/translate.js";
import type { ProviderConfigSource } from "../resolve-catalog.js";
import type { LoggerLike, ResolvedProvider } from "../types.js";

// Re-export the pure logger type so node consumers can import it from here.
Expand Down Expand Up @@ -88,6 +89,16 @@ export interface LoadCatalogOptions {
* stale legacy setting the migration copied it from.
*/
readonly legacyPositronEnforcedSettings?: boolean;

/**
* Optional transform applied to every loaded source (file, env fragments,
* legacy) before resolution. Supports counterfactual ("what-if") queries —
* e.g. a clear-confirmation flow re-resolving the catalog without the
* user-layer leaves a disconnect would remove — while reusing the exact
* source options (paths, env vars, legacy channels) of the live load.
* Load-path only; watch paths never apply it.
*/
readonly transformSource?: (source: ProviderConfigSource) => ProviderConfigSource;
}

/**
Expand Down