Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
dist/
*.tsbuildinfo
*.tgz
235 changes: 235 additions & 0 deletions packages/ai-config/providers.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2909,6 +2909,241 @@
},
"type": "object"
},
"databricks": {
"additionalProperties": false,
"properties": {
"baseUrl": {
"type": "string"
},
"customHeaders": {
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"type": "string"
},
"type": "object"
},
"databricks": {
"additionalProperties": false,
"properties": {
"host": {
"type": "string"
}
},
"type": "object"
},
"enabled": {
"type": "boolean"
},
"endpoint": {
"type": "string"
},
"endpoints": {
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"enum": [
"anthropic-messages",
"openai-chat",
"openai-responses",
"bedrock-converse",
"google-generative"
],
"type": "string"
},
"type": "object"
},
"models": {
"additionalProperties": false,
"properties": {
"allow": {
"items": {
"type": "string"
},
"type": "array"
},
"custom": {
"items": {
"additionalProperties": false,
"properties": {
"baseUrl": {
"type": "string"
},
"family": {
"type": "string"
},
"id": {
"minLength": 1,
"type": "string"
},
"maxContextLength": {
"exclusiveMinimum": 0,
"maximum": 9007199254740991,
"type": "integer"
},
"maxInputTokens": {
"exclusiveMinimum": 0,
"maximum": 9007199254740991,
"type": "integer"
},
"maxOutputTokens": {
"exclusiveMinimum": 0,
"maximum": 9007199254740991,
"type": "integer"
},
"name": {
"minLength": 1,
"type": "string"
},
"protocol": {
"enum": [
"anthropic-messages",
"openai-chat",
"openai-responses",
"bedrock-converse",
"google-generative"
],
"type": "string"
},
"supportedInputMediaTypes": {
"items": {
"type": "string"
},
"type": "array"
},
"supportsImages": {
"type": "boolean"
},
"supportsToolResultImages": {
"type": "boolean"
},
"supportsTools": {
"type": "boolean"
},
"supportsWebSearch": {
"type": "boolean"
},
"thinkingEffortLevels": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"id",
"name",
"maxContextLength",
"supportsTools",
"supportsImages",
"supportsToolResultImages",
"supportsWebSearch"
],
"type": "object"
},
"type": "array"
},
"deny": {
"items": {
"type": "string"
},
"type": "array"
},
"discovery": {
"enum": [
"auto",
"off"
],
"type": "string"
},
"overrides": {
"additionalProperties": {
"additionalProperties": false,
"properties": {
"baseUrl": {
"type": "string"
},
"family": {
"type": "string"
},
"maxContextLength": {
"exclusiveMinimum": 0,
"maximum": 9007199254740991,
"type": "integer"
},
"maxInputTokens": {
"exclusiveMinimum": 0,
"maximum": 9007199254740991,
"type": "integer"
},
"maxOutputTokens": {
"exclusiveMinimum": 0,
"maximum": 9007199254740991,
"type": "integer"
},
"name": {
"type": "string"
},
"protocol": {
"enum": [
"anthropic-messages",
"openai-chat",
"openai-responses",
"bedrock-converse",
"google-generative"
],
"type": "string"
},
"supportedInputMediaTypes": {
"items": {
"type": "string"
},
"type": "array"
},
"supportsImages": {
"type": "boolean"
},
"supportsToolResultImages": {
"type": "boolean"
},
"supportsTools": {
"type": "boolean"
},
"supportsWebSearch": {
"type": "boolean"
},
"thinkingEffortLevels": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"propertyNames": {
"type": "string"
},
"type": "object"
}
},
"type": "object"
},
"protocol": {
"enum": [
"anthropic-messages",
"openai-chat",
"openai-responses",
"bedrock-converse",
"google-generative"
],
"type": "string"
}
},
"type": "object"
},
"deepseek": {
"additionalProperties": false,
"properties": {
Expand Down
22 changes: 11 additions & 11 deletions packages/ai-config/src/__tests__/load-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { loadResolvedProviderCatalog } from "../node/load-catalog.js";
import { mutateProvidersConfig } from "../node/mutate-config.js";
import type { ProvidersConfig, ResolvedProvider } from "../types.js";
import type { PlatformBaseline } from "../types.js";
import { BUILTIN_PROVIDER_IDS } from "../vocabulary.js";

// ---------------------------------------------------------------------------
// Helpers
Expand Down Expand Up @@ -72,8 +73,7 @@ describe("loadResolvedProviderCatalog", () => {
logger: mockLogger,
});

// 14 built-in providers
expect(catalog.length).toBe(14);
expect(catalog.length).toBe(BUILTIN_PROVIDER_IDS.length);
expect(findProvider(catalog, "positai")?.enabled).toBe(true);
expect(findProvider(catalog, "anthropic")?.enabled).toBe(true);
});
Expand All @@ -87,7 +87,7 @@ describe("loadResolvedProviderCatalog", () => {
logger: mockLogger,
});

expect(catalog.length).toBe(14);
expect(catalog.length).toBe(BUILTIN_PROVIDER_IDS.length);
});

it("should apply RStudio baseline (positai only)", async () => {
Expand Down Expand Up @@ -216,7 +216,7 @@ describe("loadResolvedProviderCatalog", () => {
logger: mockLogger,
});

expect(catalog.length).toBe(14);
expect(catalog.length).toBe(BUILTIN_PROVIDER_IDS.length);
expect(mockLogger.warn).toHaveBeenCalledWith(
expect.stringContaining("Failed to parse TEST_ENFORCED"),
);
Expand Down Expand Up @@ -291,7 +291,7 @@ describe("loadResolvedProviderCatalog", () => {
});

// Should fall back to user config (no custom provider)
expect(catalog.length).toBe(14);
expect(catalog.length).toBe(BUILTIN_PROVIDER_IDS.length);
expect(findProvider(catalog, "env-only-gateway")).toBeUndefined();
expect(mockLogger.warn).toHaveBeenCalledWith(
expect.stringContaining("invalid merged result"),
Expand Down Expand Up @@ -474,8 +474,8 @@ describe("loadResolvedProviderCatalog", () => {
logger: mockLogger,
});

// 14 built-ins + 1 custom
expect(catalog.length).toBe(15);
// built-ins + 1 custom
expect(catalog.length).toBe(BUILTIN_PROVIDER_IDS.length + 1);

const custom = findProvider(catalog, "my-gateway");
expect(custom).toBeDefined();
Expand Down Expand Up @@ -558,7 +558,7 @@ describe("loadResolvedProviderCatalog", () => {
logger: mockLogger,
});

expect(catalog.length).toBe(14); // defaults
expect(catalog.length).toBe(BUILTIN_PROVIDER_IDS.length); // defaults
expect(mockLogger.warn).toHaveBeenCalledWith(expect.stringContaining("Failed to parse"));
});

Expand All @@ -572,7 +572,7 @@ describe("loadResolvedProviderCatalog", () => {
logger: mockLogger,
});

expect(catalog.length).toBe(14); // defaults
expect(catalog.length).toBe(BUILTIN_PROVIDER_IDS.length); // defaults
expect(mockLogger.warn).toHaveBeenCalledWith(expect.stringContaining("Validation errors"));
});

Expand All @@ -591,7 +591,7 @@ describe("loadResolvedProviderCatalog", () => {
logger: mockLogger,
});

expect(catalog.length).toBe(14); // defaults
expect(catalog.length).toBe(BUILTIN_PROVIDER_IDS.length); // defaults
expect(findProvider(catalog, "anthropic")?.connection.aws).toBeUndefined();
expect(mockLogger.warn).toHaveBeenCalledWith(expect.stringContaining("Validation errors"));
});
Expand Down Expand Up @@ -652,7 +652,7 @@ describe("loadResolvedProviderCatalog", () => {
additionalSources: [emptyHostSource],
});

expect(catalog.length).toBe(14);
expect(catalog.length).toBe(BUILTIN_PROVIDER_IDS.length);
expect(findProvider(catalog, "anthropic")?.connection.baseUrl).toBeUndefined();
});

Expand Down
31 changes: 31 additions & 0 deletions packages/ai-config/src/__tests__/positron-source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ function fakeReader(
customHeaders?: Record<string, Record<string, string>>;
awsRegion?: string;
snowflake?: { host?: string; account?: string; home?: string };
databricks?: { host?: string };
} = {},
): PositronAuthSettingReader {
return {
getBaseUrl: (configKey) => overrides.baseUrls?.[configKey],
getCustomHeaders: (configKey) => overrides.customHeaders?.[configKey],
getAwsRegion: () => overrides.awsRegion,
getSnowflake: () => overrides.snowflake,
getDatabricks: () => overrides.databricks,
};
}

Expand All @@ -53,6 +55,11 @@ const SNOWFLAKE: PositronAuthSettingDescriptor = {
configKey: "snowflake",
read: "snowflake",
};
const DATABRICKS: PositronAuthSettingDescriptor = {
providerId: "databricks",
configKey: "databricks",
read: "databricks",
};

describe("buildAuthenticationFragment", () => {
it("returns an empty fragment when nothing is set", () => {
Expand Down Expand Up @@ -156,6 +163,30 @@ describe("buildAuthenticationFragment", () => {
});
});

it("emits the databricks host under the databricks section (+ customHeaders), not baseUrl", () => {
const reader = fakeReader({
databricks: { host: "https://adb-123.4.azuredatabricks.net" },
customHeaders: { databricks: { "x-databricks-use-coding-agent-mode": "true" } },
});
const fragment = buildAuthenticationFragment(reader, [DATABRICKS]);
// The host must NOT be emitted as baseUrl: per-model endpoint resolution
// falls back to the provider baseUrl, which would route chat requests to
// the bare workspace host instead of the serving-endpoints path.
expect(fragment).toEqual({
providers: {
databricks: {
databricks: { host: "https://adb-123.4.azuredatabricks.net" },
customHeaders: { "x-databricks-use-coding-agent-mode": "true" },
},
},
});
});

it("omits databricks when no host is set", () => {
const fragment = buildAuthenticationFragment(fakeReader(), [DATABRICKS]);
expect(fragment).toEqual({});
});

it("applies the descriptor's normalizeBaseUrl to a set base URL", () => {
const normalizeBaseUrl = (url: string) =>
url === "https://bare.example" ? "https://bare.example/v1" : url;
Expand Down
Loading